Lines 69-75
static struct mem_block *exec_heap = NULL;
Link Here
|
69 |
static unsigned char *exec_mem = NULL; |
69 |
static unsigned char *exec_mem = NULL; |
70 |
|
70 |
|
71 |
|
71 |
|
72 |
static void |
72 |
static int |
73 |
init_heap(void) |
73 |
init_heap(void) |
74 |
{ |
74 |
{ |
75 |
if (!exec_heap) |
75 |
if (!exec_heap) |
Lines 79-84
init_heap(void)
Link Here
|
79 |
exec_mem = (unsigned char *) mmap(0, EXEC_HEAP_SIZE, |
79 |
exec_mem = (unsigned char *) mmap(0, EXEC_HEAP_SIZE, |
80 |
PROT_EXEC | PROT_READ | PROT_WRITE, |
80 |
PROT_EXEC | PROT_READ | PROT_WRITE, |
81 |
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
81 |
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
|
|
82 |
|
83 |
return (exec_mem != MAP_FAILED); |
82 |
} |
84 |
} |
83 |
|
85 |
|
84 |
|
86 |
|
Lines 90-96
rtasm_exec_malloc(size_t size)
Link Here
|
90 |
|
92 |
|
91 |
pipe_mutex_lock(exec_mutex); |
93 |
pipe_mutex_lock(exec_mutex); |
92 |
|
94 |
|
93 |
init_heap(); |
95 |
if (!init_heap()) |
|
|
96 |
goto bail; |
94 |
|
97 |
|
95 |
if (exec_heap) { |
98 |
if (exec_heap) { |
96 |
size = (size + 31) & ~31; /* next multiple of 32 bytes */ |
99 |
size = (size + 31) & ~31; /* next multiple of 32 bytes */ |
Lines 101-107
rtasm_exec_malloc(size_t size)
Link Here
|
101 |
addr = exec_mem + block->ofs; |
104 |
addr = exec_mem + block->ofs; |
102 |
else |
105 |
else |
103 |
debug_printf("rtasm_exec_malloc failed\n"); |
106 |
debug_printf("rtasm_exec_malloc failed\n"); |
104 |
|
107 |
|
|
|
108 |
bail: |
105 |
pipe_mutex_unlock(exec_mutex); |
109 |
pipe_mutex_unlock(exec_mutex); |
106 |
|
110 |
|
107 |
return addr; |
111 |
return addr; |
108 |
- |
|
|