aboutsummaryrefslogtreecommitdiff
path: root/bfd/bfdwin.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2024-03-13 06:31:28 -0700
committerH.J. Lu <hjl.tools@gmail.com>2024-03-13 06:55:44 -0700
commit2e384d4f44f15e560b2a068e0ed866438aaa7cd7 (patch)
tree57e59d6af7e7a76acfd3879885e399b509b78951 /bfd/bfdwin.c
parent32235d90951b4b7c2976c61a28c30d82cb7a7588 (diff)
downloadgdb-2e384d4f44f15e560b2a068e0ed866438aaa7cd7.zip
gdb-2e384d4f44f15e560b2a068e0ed866438aaa7cd7.tar.gz
gdb-2e384d4f44f15e560b2a068e0ed866438aaa7cd7.tar.bz2
bfd: Use MAP_FAILED for mmap failure
Use MAP_FAILED, instead of ((void *) -1), for mmap failure and use ((void *) -1) only if MAP_FAILED is undefined. * bfdio.c (bfd_mmap): Replace (void *) -1 with MAP_FAILED for mmap failure. * bfdwin.c: Don't include <sys/mman.h>. (MAP_FILE): Removed. (bfd_get_file_window): Replace (void *) -1 with MAP_FAILED for mmap failure. * cache.c: Don't include <sys/mman.h>. (cache_bmmap): Replace (void *) -1 with MAP_FAILED for mmap failure. * opncls.c (opncls_bmmap): Likewise. * sysdep.h: Include <sys/mman.h> if HAVE_MMAP is define. (MAP_FILE): New. Defined as 0 if undefined. (MAP_FAILED): New. Defined as ((void *) -1) if undefined.
Diffstat (limited to 'bfd/bfdwin.c')
-rw-r--r--bfd/bfdwin.c10
1 files changed, 1 insertions, 9 deletions
diff --git a/bfd/bfdwin.c b/bfd/bfdwin.c
index beb1739..2919c71 100644
--- a/bfd/bfdwin.c
+++ b/bfd/bfdwin.c
@@ -31,14 +31,6 @@
#undef HAVE_MPROTECT /* code's not tested yet */
-#if HAVE_MMAP || HAVE_MPROTECT || HAVE_MADVISE
-#include <sys/mman.h>
-#endif
-
-#ifndef MAP_FILE
-#define MAP_FILE 0
-#endif
-
static int debug_windows;
/* The idea behind the next and refcount fields is that one mapped
@@ -234,7 +226,7 @@ bfd_get_file_window (bfd *abfd,
? MAP_FILE | MAP_PRIVATE
: MAP_FILE | MAP_SHARED),
fd, file_offset);
- if (i->data == (void *) -1)
+ if (i->data == MAP_FAILED)
{
/* An error happened. Report it, or try using malloc, or
something. */