diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-09-18 18:06:28 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-09-18 18:06:28 +0000 |
commit | 7341e544a603b629235731ade8faace5666d1180 (patch) | |
tree | 44912af377a1284ca36611f9b8acc53b753eb783 /libbacktrace | |
parent | d48b4b141d4e420c86aafb9f746b397bc04cfaa9 (diff) | |
download | gcc-7341e544a603b629235731ade8faace5666d1180.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@191443 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libbacktrace')
-rw-r--r-- | libbacktrace/ChangeLog | 8 | ||||
-rw-r--r-- | libbacktrace/config.h.in | 3 | ||||
-rwxr-xr-x | libbacktrace/configure | 21 | ||||
-rw-r--r-- | libbacktrace/configure.ac | 14 | ||||
-rw-r--r-- | libbacktrace/posix.c | 8 |
5 files changed, 53 insertions, 1 deletions
diff --git a/libbacktrace/ChangeLog b/libbacktrace/ChangeLog index e7c3bcaa15b..15a94391a1e 100644 --- a/libbacktrace/ChangeLog +++ b/libbacktrace/ChangeLog @@ -1,5 +1,13 @@ 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. 2012-09-18 Ian Lance Taylor <iant@google.com> diff --git a/libbacktrace/config.h.in b/libbacktrace/config.h.in index 6a31c53d028..090e8d86bc3 100644 --- a/libbacktrace/config.h.in +++ b/libbacktrace/config.h.in @@ -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 diff --git a/libbacktrace/configure b/libbacktrace/configure index 518e99e0014..70ac451e0a4 100755 --- a/libbacktrace/configure +++ b/libbacktrace/configure @@ -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 diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac index 495e23e5c68..250423d1943 100644 --- a/libbacktrace/configure.ac +++ b/libbacktrace/configure.ac @@ -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], diff --git a/libbacktrace/posix.c b/libbacktrace/posix.c index 0b76f1e94a1..01afc42b08e 100644 --- a/libbacktrace/posix.c +++ b/libbacktrace/posix.c @@ -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; } |