comparison mem.c @ 759:c47e1750c264

Use MAP_32BIT on Linux since my hint seems to be ignored
author Michael Pavone <pavone@retrodev.com>
date Sun, 28 Jun 2015 10:21:51 -0700
parents b52cd6854c28
children c3e3a0d734e2
comparison
equal deleted inserted replaced
758:b52cd6854c28 759:c47e1750c264
12 #include "mem.h" 12 #include "mem.h"
13 #ifndef MAP_ANONYMOUS 13 #ifndef MAP_ANONYMOUS
14 #define MAP_ANONYMOUS MAP_ANON 14 #define MAP_ANONYMOUS MAP_ANON
15 #endif 15 #endif
16 16
17 #ifndef MAP_32BIT
18 #define MAP_32BIT 0
19 #endif
20
17 void * alloc_code(size_t *size) 21 void * alloc_code(size_t *size)
18 { 22 {
19 //start at the 1GB mark to allow plenty of room for sbrk based malloc implementations 23 //start at the 1GB mark to allow plenty of room for sbrk based malloc implementations
20 //while still keeping well within 32-bit displacement range for calling code compiled into the executable 24 //while still keeping well within 32-bit displacement range for calling code compiled into the executable
21 static uint8_t *next = (uint8_t *)0x40000000; 25 static uint8_t *next = (uint8_t *)0x40000000;
22 *size += PAGE_SIZE - (*size & (PAGE_SIZE - 1)); 26 *size += PAGE_SIZE - (*size & (PAGE_SIZE - 1));
23 uint8_t *ret = mmap(NULL, *size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); 27 uint8_t *ret = mmap(NULL, *size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_32BIT, -1, 0);
24 next = ret + *size; 28 next = ret + *size;
25 return ret; 29 return ret;
26 } 30 }
27 31