diff options
author | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2010-04-07 21:11:46 -0400 |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2010-04-12 21:26:35 -0400 |
commit | 74da141e618ef99959d509cb2e7be35a348a39db (patch) | |
tree | 88ebc38b381a1021fc2d74864a71e230ae591c3d /gl/m4/fcntl.m4 | |
parent | c63a4f726a0b6ad8cf6040f947754a81fd4683bb (diff) | |
download | monitoring-plugins-74da141e618ef99959d509cb2e7be35a348a39db.tar.gz |
Sync with the latest Gnulib code (177f525)
Signed-off-by: Thomas Guyot-Sionnest <dermoth@aei.ca>
Diffstat (limited to 'gl/m4/fcntl.m4')
-rw-r--r-- | gl/m4/fcntl.m4 | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/gl/m4/fcntl.m4 b/gl/m4/fcntl.m4 new file mode 100644 index 00000000..fcb5f447 --- /dev/null +++ b/gl/m4/fcntl.m4 | |||
@@ -0,0 +1,83 @@ | |||
1 | # fcntl.m4 serial 3 | ||
2 | dnl Copyright (C) 2009, 2010 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 | # For now, this module ensures that fcntl() | ||
8 | # - supports F_DUPFD correctly | ||
9 | # - supports or emulates F_DUPFD_CLOEXEC | ||
10 | # - supports F_GETFD | ||
11 | # Still to be ported to mingw: | ||
12 | # - F_SETFD | ||
13 | # - F_GETFL, F_SETFL | ||
14 | # - F_GETOWN, F_SETOWN | ||
15 | # - F_GETLK, F_SETLK, F_SETLKW | ||
16 | AC_DEFUN([gl_FUNC_FCNTL], | ||
17 | [ | ||
18 | dnl Persuade glibc to expose F_DUPFD_CLOEXEC. | ||
19 | AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) | ||
20 | AC_REQUIRE([gl_FCNTL_H_DEFAULTS]) | ||
21 | AC_REQUIRE([AC_CANONICAL_HOST]) | ||
22 | AC_CHECK_FUNCS_ONCE([fcntl]) | ||
23 | if test $ac_cv_func_fcntl = no; then | ||
24 | gl_REPLACE_FCNTL | ||
25 | else | ||
26 | dnl cygwin 1.5.x F_DUPFD has wrong errno, and allows negative target | ||
27 | AC_CACHE_CHECK([whether fcntl handles F_DUPFD correctly], | ||
28 | [gl_cv_func_fcntl_f_dupfd_works], | ||
29 | [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ | ||
30 | #include <fcntl.h> | ||
31 | ]], [[return fcntl (0, F_DUPFD, -1) != -1; | ||
32 | ]])], | ||
33 | [gl_cv_func_fcntl_f_dupfd_works=yes], | ||
34 | [gl_cv_func_fcntl_f_dupfd_works=no], | ||
35 | [# Guess that it works on glibc systems | ||
36 | case $host_os in #(( | ||
37 | *-gnu*) gl_cv_func_fcntl_f_dupfd_works="guessing yes";; | ||
38 | *) gl_cv_func_fcntl_f_dupfd_works="guessing no";; | ||
39 | esac])]) | ||
40 | case $gl_cv_func_fcntl_f_dupfd_works in | ||
41 | *yes) ;; | ||
42 | *) gl_REPLACE_FCNTL | ||
43 | AC_DEFINE([FCNTL_DUPFD_BUGGY], [1], [Define this to 1 if F_DUPFD | ||
44 | behavior does not match POSIX]) ;; | ||
45 | esac | ||
46 | |||
47 | dnl Many systems lack F_DUPFD_CLOEXEC | ||
48 | AC_CACHE_CHECK([whether fcntl understands F_DUPFD_CLOEXEC], | ||
49 | [gl_cv_func_fcntl_f_dupfd_cloexec], | ||
50 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | ||
51 | #include <fcntl.h> | ||
52 | #ifndef F_DUPFD_CLOEXEC | ||
53 | choke me | ||
54 | #endif | ||
55 | ]])], | ||
56 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | ||
57 | #ifdef __linux__ | ||
58 | /* The Linux kernel only added F_DUPFD_CLOEXEC in 2.6.24, so we always replace | ||
59 | it to support the semantics on older kernels that failed with EINVAL. */ | ||
60 | choke me | ||
61 | #endif | ||
62 | ]])], | ||
63 | [gl_cv_func_fcntl_f_dupfd_cloexec=yes], | ||
64 | [gl_cv_func_fcntl_f_dupfd_cloexec="needs runtime check"])], | ||
65 | [gl_cv_func_fcntl_f_dupfd_cloexec=no])]) | ||
66 | if test "$gl_cv_func_fcntl_f_dupfd_cloexec" != yes; then | ||
67 | gl_REPLACE_FCNTL | ||
68 | dnl No witness macro needed for this bug. | ||
69 | fi | ||
70 | fi | ||
71 | ]) | ||
72 | |||
73 | AC_DEFUN([gl_REPLACE_FCNTL], | ||
74 | [ | ||
75 | AC_REQUIRE([gl_FCNTL_H_DEFAULTS]) | ||
76 | AC_CHECK_FUNCS_ONCE([fcntl]) | ||
77 | if test $ac_cv_func_fcntl = no; then | ||
78 | HAVE_FCNTL=0 | ||
79 | else | ||
80 | REPLACE_FCNTL=1 | ||
81 | fi | ||
82 | AC_LIBOBJ([fcntl]) | ||
83 | ]) | ||