* 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
+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.
/* 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
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
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],
#include "backtrace.h"
#include "internal.h"
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif
{
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;
}