2 dnl Copyright (C) 2009 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.
7 # For now, this module ensures that fcntl()
8 # - supports or emulates F_DUPFD_CLOEXEC
9 # Still to be ported to various platforms:
10 # - supports F_DUPFD correctly
11 # Still to be ported to mingw:
12 # - F_GETFD, F_SETFD, F_DUPFD
15 # - F_GETOWN, F_SETOWN
16 # - F_GETLK, F_SETLK, F_SETLKW
17 AC_DEFUN([gl_FUNC_FCNTL],
19 dnl Persuade glibc to expose F_DUPFD_CLOEXEC.
20 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
21 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
22 AC_CHECK_FUNCS_ONCE([fcntl])
23 if test $ac_cv_func_fcntl = no; then
26 AC_CACHE_CHECK([whether fcntl understands F_DUPFD_CLOEXEC],
27 [gl_cv_func_fcntl_f_dupfd_cloexec],
28 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
30 #ifndef F_DUPFD_CLOEXEC
34 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
36 /* The Linux kernel only added F_DUPFD_CLOEXEC in 2.6.24, so we always replace
37 it to support the semantics on older kernels that failed with EINVAL. */
41 [gl_cv_func_fcntl_f_dupfd_cloexec=yes],
42 [gl_cv_func_fcntl_f_dupfd_cloexec="needs runtime check"])],
43 [gl_cv_func_fcntl_f_dupfd_cloexec=no])])
44 if test "$gl_cv_func_fcntl_f_dupfd_cloexec" != yes; then