Debian Codegraph @

m4/fdopen.m4

raw
1 # fdopen.m4
2 # serial 6
3 dnl Copyright (C) 2011-2025 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7 dnl This file is offered as-is, without any warranty.
8
9 AC_DEFUN([gl_FUNC_FDOPEN],
10 [
11 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
12 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
13 m4_ifdef([gl_MSVC_INVAL], [
14 AC_REQUIRE([gl_MSVC_INVAL])
15 if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
16 REPLACE_FDOPEN=1
17 fi
18 ])
19 if test $REPLACE_FDOPEN = 0; then
20 dnl Test whether fdopen() sets errno when it fails due to a bad fd argument.
21 AC_CACHE_CHECK([whether fdopen sets errno], [gl_cv_func_fdopen_works],
22 [
23 AC_RUN_IFELSE(
24 [AC_LANG_SOURCE([[
25 #include <stdio.h>
26 #include <errno.h>
27 ]GL_MDA_DEFINES[
28 int
29 main (void)
30 {
31 FILE *fp;
32 errno = 0;
33 fp = fdopen (-1, "r");
34 if (fp == NULL && errno == 0)
35 return 1;
36 return 0;
37 }]])],
38 [gl_cv_func_fdopen_works=yes],
39 [gl_cv_func_fdopen_works=no],
40 [case "$host_os" in
41 mingw* | windows*) gl_cv_func_fdopen_works="guessing no" ;;
42 *) gl_cv_func_fdopen_works="guessing yes" ;;
43 esac
44 ])
45 ])
46 case "$gl_cv_func_fdopen_works" in
47 *no) REPLACE_FDOPEN=1 ;;
48 esac
49 fi
50 ])
51
52 dnl Prerequisites of lib/fdopen.c.
53 AC_DEFUN([gl_PREREQ_FDOPEN], [])