libctf: work on platforms without O_CLOEXEC.
authorNick Alcock <nick.alcock@oracle.com>
Tue, 4 Jun 2019 14:04:49 +0000 (15:04 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Tue, 4 Jun 2019 16:05:08 +0000 (17:05 +0100)
(Not tested on any such platforms, since I don't have access to any at
the moment.  Testing encouraged.)

libctf/
* configure.ac: Check for O_CLOEXEC.
* ctf-decls.h (O_CLOEXEC): Define (to 0), if need be.
* config.h.in: Regenerate.

libctf/ChangeLog
libctf/config.h.in
libctf/configure
libctf/configure.ac
libctf/ctf-decls.h

index c51efea8bcd215ad4a34bb5be1f15d07bc8eba55..52c2e1e8fcbd01de7e4aee7818b37b4a8b28c2bc 100644 (file)
@@ -1,3 +1,10 @@
+2019-06-04  Nick Alcock  <nick.alcock@oracle.com>
+
+       * configure.ac: Check for O_CLOEXEC.
+       * ctf-decls.h (O_CLOEXEC): Define (to 0), if need be.
+       * config.h.in: Regenerate.
+       * configure: Likewise.
+
 2019-06-04  Nick Alcock  <nick.alcock@oracle.com>
 
        * qsort_r.c: Rename to...
index d81c500c5c3627b5dceec8002026e6dcbbb5b898..3f45cd6d745187e456eecdec88bd42cca6c70534 100644 (file)
@@ -24,6 +24,9 @@
 /* Define to 1 if you have a working `mmap' system call. */
 #undef HAVE_MMAP
 
+/* Whether the platform has a definition of O_CLOEXEC. */
+#undef HAVE_O_CLOEXEC
+
 /* Define to 1 if you have the `pread' function. */
 #undef HAVE_PREAD
 
index d485b1a7cec58371097f211a6723ddf69ddf4a12..31f166779eb453ad9af6c0653cb7561f70667324 100755 (executable)
@@ -6462,6 +6462,43 @@ else
 fi
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for O_CLOEXEC" >&5
+$as_echo_n "checking for O_CLOEXEC... " >&6; }
+if ${ac_cv_libctf_macro_O_CLOEXEC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <fcntl.h>
+                       #ifndef O_CLOEXEC
+                         choke me;
+                       #endif
+
+int
+main ()
+{
+return O_CLOEXEC;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_libctf_macro_O_CLOEXEC=yes
+else
+  ac_cv_libctf_macro_O_CLOEXEC=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libctf_macro_O_CLOEXEC" >&5
+$as_echo "$ac_cv_libctf_macro_O_CLOEXEC" >&6; }
+
+if test $ac_cv_libctf_macro_O_CLOEXEC = yes; then
+
+$as_echo "#define HAVE_O_CLOEXEC 1" >>confdefs.h
+
+fi
+
 ac_config_files="$ac_config_files Makefile"
 
 ac_config_headers="$ac_config_headers config.h"
index beb90ba75cc4cf58329da2f5551d81201affe2db..2a1a80b7ecbb667f56dbc40293e73c788dc25d58 100644 (file)
@@ -133,6 +133,22 @@ esac
 
 AM_CONDITIONAL(NEED_CTF_QSORT_R, test "${ac_cv_libctf_qsort_r_signature}" = unknown)
 
+AC_CACHE_CHECK([for O_CLOEXEC], [ac_cv_libctf_macro_O_CLOEXEC],
+  [AC_LINK_IFELSE(
+    [AC_LANG_PROGRAM([[#include <fcntl.h>
+                       #ifndef O_CLOEXEC
+                         choke me;
+                       #endif
+                     ]],
+                     [[return O_CLOEXEC;]])],
+    [ac_cv_libctf_macro_O_CLOEXEC=yes],
+    [ac_cv_libctf_macro_O_CLOEXEC=no])])
+
+if test $ac_cv_libctf_macro_O_CLOEXEC = yes; then
+  AC_DEFINE([HAVE_O_CLOEXEC], 1,
+           [Whether the platform has a definition of O_CLOEXEC.])
+fi
+
 AC_CONFIG_FILES(Makefile)
 AC_CONFIG_HEADERS(config.h)
 AC_OUTPUT
index d12409e4b608d28a68ff1db4f3c21ee2d2f58fc7..c840b793c9bdf8cb9983c42dd9f860f3c04a2e90 100644 (file)
@@ -62,6 +62,10 @@ void ctf_qsort_r (void *base, size_t nmemb, size_t size,
              void *arg);
 #endif
 
+#ifndef HAVE_O_CLOEXEC
+# define O_CLOEXEC 0
+#endif
+
 #undef MAX
 #undef MIN
 #define MAX(a, b) ((a) > (b) ? (a) : (b))
This page took 0.028955 seconds and 4 git commands to generate.