* tree-loop-distribution.c (bb_top_order_index): New.
[official-gcc.git] / libffi / testsuite / libffi.special / ffitestcxx.h
blob83f5442849e5f1b39932a89ed4216d7ea13fd898
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <fcntl.h>
4 #include <ffi.h>
5 #include "fficonfig.h"
7 #define MAX_ARGS 256
10 /* Define __UNUSED__ that also other compilers than gcc can run the tests. */
11 #undef __UNUSED__
12 #if defined(__GNUC__)
13 #define __UNUSED__ __attribute__((__unused__))
14 #else
15 #define __UNUSED__
16 #endif
18 #define CHECK(x) (!(x) ? abort() : (void)0)
20 /* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a
21 file open. */
22 #ifdef HAVE_MMAP_ANON
23 # undef HAVE_MMAP_DEV_ZERO
25 # include <sys/mman.h>
26 # ifndef MAP_FAILED
27 # define MAP_FAILED -1
28 # endif
29 # if !defined (MAP_ANONYMOUS) && defined (MAP_ANON)
30 # define MAP_ANONYMOUS MAP_ANON
31 # endif
32 # define USING_MMAP
34 #endif
36 #ifdef HAVE_MMAP_DEV_ZERO
38 # include <sys/mman.h>
39 # ifndef MAP_FAILED
40 # define MAP_FAILED -1
41 # endif
42 # define USING_MMAP
44 #endif
47 /* MinGW kludge. */
48 #ifdef _WIN64
49 #define PRIdLL "I64d"
50 #define PRIuLL "I64u"
51 #else
52 #define PRIdLL "lld"
53 #define PRIuLL "llu"
54 #endif
56 #ifdef USING_MMAP
57 static inline void *
58 allocate_mmap (size_t size)
60 void *page;
61 #if defined (HAVE_MMAP_DEV_ZERO)
62 static int dev_zero_fd = -1;
63 #endif
65 #ifdef HAVE_MMAP_DEV_ZERO
66 if (dev_zero_fd == -1)
68 dev_zero_fd = open ("/dev/zero", O_RDONLY);
69 if (dev_zero_fd == -1)
71 perror ("open /dev/zero: %m");
72 exit (1);
75 #endif
78 #ifdef HAVE_MMAP_ANON
79 page = mmap (NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC,
80 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
81 #endif
82 #ifdef HAVE_MMAP_DEV_ZERO
83 page = mmap (NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC,
84 MAP_PRIVATE, dev_zero_fd, 0);
85 #endif
87 if (page == (char *) MAP_FAILED)
89 perror ("virtual memory exhausted");
90 exit (1);
93 return page;
96 #endif