]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
posix.c (O_BINARY): Define if not defined.
authorIan Lance Taylor <iant@google.com>
Tue, 18 Sep 2012 18:06:28 +0000 (18:06 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Tue, 18 Sep 2012 18:06:28 +0000 (18:06 +0000)
* posix.c (O_BINARY): Define if not defined.
(backtrace_open): Pass O_BINARY to open.  Only call fcntl if
HAVE_FCNTL is defined.
* configure.ac: Test for the fcntl function.
* configure, config.h.in: Rebuild.

From-SVN: r191443

libbacktrace/ChangeLog
libbacktrace/config.h.in
libbacktrace/configure
libbacktrace/configure.ac
libbacktrace/posix.c

index e7c3bcaa15b23a3edfc31ac096dda5ec467bc1d7..15a94391a1e4e85531cb2b1aa6a5fe5d2e95d944 100644 (file)
@@ -1,3 +1,11 @@
+2012-09-18  Ian Lance Taylor  <iant@google.com>
+
+       * posix.c (O_BINARY): Define if not defined.
+       (backtrace_open): Pass O_BINARY to open.  Only call fcntl if
+       HAVE_FCNTL is defined.
+       * configure.ac: Test for the fcntl function.
+       * configure, config.h.in: Rebuild.
+
 2012-09-18  Ian Lance Taylor  <iant@google.com>
 
        * btest.c (test1, test2, test3, test4): Add the unused attribute.
index 6a31c53d0287185f324bc35c4b2003ac559594e4..090e8d86bc3b00151b9bff32fad78b55c6314c3b 100644 (file)
@@ -10,6 +10,9 @@
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
+/* Define to 1 if you have the fcntl function */
+#undef HAVE_FCNTL
+
 /* Define if _Unwind_GetIPInfo is available. */
 #undef HAVE_GETIPINFO
 
index 518e99e00144c4a772bf8380dc8eea9e6d7a8c56..70ac451e0a413e87606544cfc4123dac7885e906 100755 (executable)
@@ -11713,6 +11713,27 @@ if test "$ALLOC_FILE" = "alloc.lo"; then
 fi
 
 
+# Check for the fcntl function.
+if test -n "${with_target_subdir}"; then
+   case "${host}" in
+   *-*-mingw*) have_fcntl=no ;;
+   *) have_fcntl=yes ;;
+   esac
+else
+  ac_fn_c_check_func "$LINENO" "fcntl" "ac_cv_func_fcntl"
+if test "x$ac_cv_func_fcntl" = x""yes; then :
+  have_fcntl=yes
+else
+  have_fcntl=no
+fi
+
+fi
+if test "$have_fcntl" = "yes"; then
+
+$as_echo "#define HAVE_FCNTL 1" >>confdefs.h
+
+fi
+
 ac_fn_c_check_decl "$LINENO" "strnlen" "ac_cv_have_decl_strnlen" "$ac_includes_default"
 if test "x$ac_cv_have_decl_strnlen" = x""yes; then :
   ac_have_decl=1
index 495e23e5c68321cd44c2c2721e8af4cfd374fccf..250423d19438d4ed024aa0e1a6bbe34cb00aa1cc 100644 (file)
@@ -201,6 +201,20 @@ if test "$ALLOC_FILE" = "alloc.lo"; then
 fi
 AC_SUBST(BACKTRACE_USES_MALLOC)
 
+# Check for the fcntl function.
+if test -n "${with_target_subdir}"; then
+   case "${host}" in
+   *-*-mingw*) have_fcntl=no ;;
+   *) have_fcntl=yes ;;
+   esac
+else
+  AC_CHECK_FUNC(fcntl, [have_fcntl=yes], [have_fcntl=no])
+fi
+if test "$have_fcntl" = "yes"; then
+  AC_DEFINE([HAVE_FCNTL], 1,
+           [Define to 1 if you have the fcntl function])
+fi
+
 AC_CHECK_DECLS(strnlen)
 
 AC_CACHE_CHECK([whether tests can run],
index 0b76f1e94a123b30af01aa335fd87130a192e7be..01afc42b08e3f4f11f84684bf524115307d8d26a 100644 (file)
@@ -41,6 +41,10 @@ POSSIBILITY OF SUCH DAMAGE.  */
 #include "backtrace.h"
 #include "internal.h"
 
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
 #ifndef O_CLOEXEC
 #define O_CLOEXEC 0
 #endif
@@ -57,18 +61,20 @@ backtrace_open (const char *filename, backtrace_error_callback error_callback,
 {
   int descriptor;
 
-  descriptor = open (filename, O_RDONLY | O_CLOEXEC);
+  descriptor = open (filename, O_RDONLY | O_BINARY | O_CLOEXEC);
   if (descriptor < 0)
     {
       error_callback (data, filename, errno);
       return -1;
     }
 
+#ifdef HAVE_FCNTL
   /* Set FD_CLOEXEC just in case the kernel does not support
      O_CLOEXEC. It doesn't matter if this fails for some reason.
      FIXME: At some point it should be safe to only do this if
      O_CLOEXEC == 0.  */
   fcntl (descriptor, F_SETFD, FD_CLOEXEC);
+#endif
 
   return descriptor;
 }