mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-23 10:54:07 +08:00
posix.c (O_BINARY): Define if not defined.
* 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
This commit is contained in:
parent
bd3e497d0b
commit
3319ef17d2
@ -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.
|
||||
|
@ -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
|
||||
|
||||
|
21
libbacktrace/configure
vendored
21
libbacktrace/configure
vendored
@ -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
|
||||
|
@ -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],
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user