public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jose E.Marchesi <jemarch@sourceware.org>
To: bfd-cvs@sourceware.org, gdb-cvs@sourceware.org
Subject: [binutils-gdb] libctf: work on platforms without O_CLOEXEC.
Date: Tue, 04 Jun 2019 16:12:00 -0000	[thread overview]
Message-ID: <20190604161249.45241.qmail@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ad118caa9f690114d11384b0813f30980cc333f3

commit ad118caa9f690114d11384b0813f30980cc333f3
Author: Nick Alcock <nick.alcock@oracle.com>
Date:   Tue Jun 4 15:04:49 2019 +0100

    libctf: work on platforms without O_CLOEXEC.
    
    (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.

Diff:
---
 libctf/ChangeLog    |  7 +++++++
 libctf/config.h.in  |  3 +++
 libctf/configure    | 37 +++++++++++++++++++++++++++++++++++++
 libctf/configure.ac | 16 ++++++++++++++++
 libctf/ctf-decls.h  |  4 ++++
 5 files changed, 67 insertions(+)

diff --git a/libctf/ChangeLog b/libctf/ChangeLog
index c51efea..52c2e1e 100644
--- a/libctf/ChangeLog
+++ b/libctf/ChangeLog
@@ -1,5 +1,12 @@
 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...
 	* ctf-qsort_r.c: ... this.
 	(_quicksort): Define to ctf_qsort_r.
diff --git a/libctf/config.h.in b/libctf/config.h.in
index d81c500..3f45cd6 100644
--- a/libctf/config.h.in
+++ b/libctf/config.h.in
@@ -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
 
diff --git a/libctf/configure b/libctf/configure
index d485b1a..31f1667 100755
--- a/libctf/configure
+++ b/libctf/configure
@@ -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"
diff --git a/libctf/configure.ac b/libctf/configure.ac
index beb90ba..2a1a80b 100644
--- a/libctf/configure.ac
+++ b/libctf/configure.ac
@@ -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
diff --git a/libctf/ctf-decls.h b/libctf/ctf-decls.h
index d12409e..c840b79 100644
--- a/libctf/ctf-decls.h
+++ b/libctf/ctf-decls.h
@@ -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))


                 reply	other threads:[~2019-06-04 16:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190604161249.45241.qmail@sourceware.org \
    --to=jemarch@sourceware.org \
    --cc=bfd-cvs@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).