Debian Codegraph @

m4/freopen.m4

raw
1 # freopen.m4 serial 6
2 dnl Copyright (C) 2007-2020 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 AC_DEFUN([gl_FUNC_FREOPEN],
8 [
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST])
11 case "$host_os" in
12 mingw* | pw* | os2*)
13 REPLACE_FREOPEN=1
14 ;;
15 *)
16 AC_CACHE_CHECK([whether freopen works on closed fds],
17 [gl_cv_func_freopen_works_on_closed],
18 [AC_RUN_IFELSE(
19 [AC_LANG_PROGRAM(
20 [[#include <stdio.h>
21 #include <unistd.h>
22 ]],
23 [[close (0);
24 return !(freopen ("/dev/null", "r", stdin)
25 && getchar () == EOF
26 && !ferror (stdin) && feof (stdin));]])],
27 [gl_cv_func_freopen_works_on_closed=yes],
28 [gl_cv_func_freopen_works_on_closed=no],
29 [case $host_os in
30 *gnu*) gl_cv_func_freopen_works_on_closed="guessing no" ;;
31 *) gl_cv_func_freopen_works_on_closed="guessing yes";;
32 esac])])
33 case $gl_cv_func_freopen_works_on_closed in
34 *no) REPLACE_FREOPEN=1;;
35 esac
36 esac
37 ])
38
39 # Prerequisites of lib/freopen.c.
40 AC_DEFUN([gl_PREREQ_FREOPEN], [:])