load correct syscall table for s390 and s390x
[trinity.git] / maps-static.c
blob2e3247d4a6aa48693f50dbd9d788c3bb95237790
1 #include <malloc.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include "arch.h"
5 #include "log.h"
6 #include "maps.h"
7 #include "random.h"
8 #include "utils.h"
10 /* "static" pages. */
11 char *page_zeros;
12 char *page_0xff;
13 char *page_rand;
14 unsigned long *page_allocs;
15 unsigned long *page_maps;
17 static void * __allocbuf(const char *name)
19 void *ptr;
21 ptr = memalign(page_size, page_size * 2);
22 if (!ptr)
23 exit(EXIT_FAILURE);
24 memset(ptr, 0, page_size * 2);
25 output(2, "%s @ %p\n", name, ptr);
26 return ptr;
29 void init_shared_pages(void)
31 unsigned int i;
33 // a page of zeros
34 page_zeros = __allocbuf("page_zeros");
36 // a page of 0xff
37 page_0xff = __allocbuf("page_0xff");
39 // a page of random crap (overwritten below)
40 page_rand = __allocbuf("page_rand");
42 // page containing ptrs to mallocs.
43 page_allocs = __allocbuf("page_allocs");
44 for (i = 0; i < (page_size / sizeof(unsigned long *)); i++)
45 page_allocs[i] = (unsigned long) malloc(page_size);
47 // a page of ptrs to mmaps (set up at child init time).
48 page_maps = __allocbuf("page_maps");
50 // mmaps that get shared across children.
51 setup_shared_mappings();
53 // generate_random_page may end up using shared_mappings, so has to be last.
54 generate_random_page(page_rand);