===================================================================
@@ -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, ba
{
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;
}
===================================================================
@@ -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],