use the -newos toolchain even if -elf is present.
[newos.git] / apps / rld / rldheap.c
blobbb048e561660f240f6f88728a953a30e248313ff
1 /*
2 ** Copyright 2002, Manuel J. Petit. All rights reserved.
3 ** Distributed under the terms of the NewOS License.
4 */
6 #include <string.h>
7 #include <sys/syscalls.h>
8 #include "rld_priv.h"
12 char const * const names[]=
14 "I'm too sexy!",
15 "BEWARE OF THE DUCK!",
16 "B_DONT_DO_THAT",
17 "I need a girlfriend!",
18 "assert(C++--!=C)",
19 "5038 RIP Nov. 2001",
20 "1.e4 e5 2.Nf3 Nc6 3.Bb5",
21 "Press any key..."
23 #define RLD_SCRATCH_SIZE 65536
24 #define RLD_PROGRAM_BASE 0x00200000 /* keep in sync with app ldscript */
28 static region_id rld_region;
29 static region_id rld_region_2;
30 static char *rld_base;
31 static char *rld_base_2;
32 static char *rld_ptr;
34 void
35 rldheap_init(void)
37 rld_region= _kern_vm_create_anonymous_region(
38 (char*)names[_kern_get_current_proc_id()%(sizeof(names)/sizeof(names[0]))],
39 (void**)&rld_base,
40 REGION_ADDR_ANY_ADDRESS,
41 RLD_SCRATCH_SIZE,
42 REGION_WIRING_LAZY,
43 LOCK_RW
47 * Fill in the gap upto RLD_PROGRAM_BASE,
49 * NOTE: this will be required only untile the vm finally
50 * support REGION_ADDR_ANY_ABOVE and REGION_ADDR_ANY_BELOW.
51 * Not doing these leads to some funny troubles with some
52 * libraries.
54 rld_region_2= _kern_vm_create_anonymous_region(
55 "RLD_padding",
56 (void**)&rld_base_2,
57 REGION_ADDR_ANY_ADDRESS,
58 RLD_PROGRAM_BASE - ((unsigned)(rld_base+RLD_SCRATCH_SIZE)),
59 REGION_WIRING_LAZY,
60 LOCK_RW
63 rld_ptr= rld_base;
66 void *
67 rldalloc(size_t s)
69 void *retval;
71 s= (s+15)&~15;
73 retval= rld_ptr;
74 rld_ptr+= s;
76 return retval;
79 void
80 rldfree(void *p)
82 (void)(p);