8 #if defined HAVE_STDINT_H
12 #if defined HAVE_INTTYPES_H
18 #define CHECK(x) !(x) ? abort() : 0
20 /* Define __UNUSED__ that also other compilers than gcc can run the tests. */
23 #define __UNUSED__ __attribute__((__unused__))
28 /* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a
31 # undef HAVE_MMAP_DEV_ZERO
33 # include <sys/mman.h>
35 # define MAP_FAILED -1
37 # if !defined (MAP_ANONYMOUS) && defined (MAP_ANON)
38 # define MAP_ANONYMOUS MAP_ANON
44 #ifdef HAVE_MMAP_DEV_ZERO
46 # include <sys/mman.h>
48 # define MAP_FAILED -1
63 /* Tru64 UNIX kludge. */
64 #if defined(__alpha__) && defined(__osf__)
65 /* Tru64 UNIX V4.0 doesn't support %lld/%lld, but long is 64-bit. */
77 /* PA HP-UX kludge. */
78 #if defined(__hppa__) && defined(__hpux__) && !defined(PRIuPTR)
84 /* IRIX 6.5 <inttypes.h> provides all definitions, but only for C99
88 #if (_MIPS_SZLONG == 32)
92 /* This doesn't match <inttypes.h>, which always has "lld" here, but the
93 arguments are uint64_t, int64_t, which are unsigned long, long for
94 64-bit in <sgidefs.h>. */
95 #if (_MIPS_SZLONG == 64)
99 /* This doesn't match <inttypes.h>, which has "u" here, but the arguments
100 are uintptr_t, which is always unsigned long. */
104 /* Solaris < 10 kludge. */
105 #if defined(__sun__) && defined(__svr4__) && !defined(PRIuPTR)
106 #if defined(__arch64__) || defined (__x86_64__)
115 allocate_mmap (size_t size
)
118 #if defined (HAVE_MMAP_DEV_ZERO)
119 static int dev_zero_fd
= -1;
122 #ifdef HAVE_MMAP_DEV_ZERO
123 if (dev_zero_fd
== -1)
125 dev_zero_fd
= open ("/dev/zero", O_RDONLY
);
126 if (dev_zero_fd
== -1)
128 perror ("open /dev/zero: %m");
135 #ifdef HAVE_MMAP_ANON
136 page
= mmap (NULL
, size
, PROT_READ
| PROT_WRITE
| PROT_EXEC
,
137 MAP_PRIVATE
| MAP_ANONYMOUS
, -1, 0);
139 #ifdef HAVE_MMAP_DEV_ZERO
140 page
= mmap (NULL
, size
, PROT_READ
| PROT_WRITE
| PROT_EXEC
,
141 MAP_PRIVATE
, dev_zero_fd
, 0);
144 if (page
== (void *) MAP_FAILED
)
146 perror ("virtual memory exhausted");