diff options
author | Ian Lance Taylor <iant@google.com> | 2012-09-18 18:06:28 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-09-18 18:06:28 +0000 |
commit | 3319ef17d271118e08da767daad9341cbe67c4e0 (patch) | |
tree | 44912af377a1284ca36611f9b8acc53b753eb783 /libbacktrace/posix.c | |
parent | bd3e497d0bab06d287a86af07fda9b6cade4e43f (diff) | |
download | gcc-3319ef17d271118e08da767daad9341cbe67c4e0.zip gcc-3319ef17d271118e08da767daad9341cbe67c4e0.tar.gz gcc-3319ef17d271118e08da767daad9341cbe67c4e0.tar.bz2 |
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
Diffstat (limited to 'libbacktrace/posix.c')
-rw-r--r-- | libbacktrace/posix.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libbacktrace/posix.c b/libbacktrace/posix.c index 0b76f1e..01afc42 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; } |