diff options
| author | Geoff Voelker | 1995-05-26 05:27:52 +0000 |
|---|---|---|
| committer | Geoff Voelker | 1995-05-26 05:27:52 +0000 |
| commit | 011db6707ecd645fbaefe66af90318ca4a6b743b (patch) | |
| tree | c3d07f9b91f5a2235d4093d69def2b1ec09a4a30 /src | |
| parent | e312961bb6f50eb3a4f2ad70557081d55cf05db4 (diff) | |
| download | emacs-011db6707ecd645fbaefe66af90318ca4a6b743b.tar.gz emacs-011db6707ecd645fbaefe66af90318ca4a6b743b.zip | |
(reserved_heap_size,allocate_heap): Defined.
(sbrk): Use allocate_heap.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32heap.c | 56 |
1 files changed, 52 insertions, 4 deletions
diff --git a/src/w32heap.c b/src/w32heap.c index 89afe6f5bf5..7c717fbdfd0 100644 --- a/src/w32heap.c +++ b/src/w32heap.c | |||
| @@ -76,6 +76,7 @@ round_to_next (unsigned char *address, unsigned long align) | |||
| 76 | unsigned char *data_region_base = NULL; | 76 | unsigned char *data_region_base = NULL; |
| 77 | unsigned char *data_region_end = NULL; | 77 | unsigned char *data_region_end = NULL; |
| 78 | unsigned long data_region_size = 0; | 78 | unsigned long data_region_size = 0; |
| 79 | unsigned long reserved_heap_size = 0; | ||
| 79 | 80 | ||
| 80 | /* The start of the data segment. */ | 81 | /* The start of the data segment. */ |
| 81 | unsigned char * | 82 | unsigned char * |
| @@ -91,6 +92,56 @@ get_data_end (void) | |||
| 91 | return data_region_end; | 92 | return data_region_end; |
| 92 | } | 93 | } |
| 93 | 94 | ||
| 95 | |||
| 96 | #ifdef WINDOWS95 | ||
| 97 | static char * | ||
| 98 | allocate_heap (void) | ||
| 99 | { | ||
| 100 | unsigned long base = 0x00030000; | ||
| 101 | unsigned long end = 0x00D00000; | ||
| 102 | |||
| 103 | reserved_heap_size = end - base; | ||
| 104 | |||
| 105 | return VirtualAlloc ((void *) base, | ||
| 106 | get_reserved_heap_size (), | ||
| 107 | MEM_RESERVE, | ||
| 108 | PAGE_NOACCESS); | ||
| 109 | } | ||
| 110 | #else | ||
| 111 | static char * | ||
| 112 | allocate_heap (void) | ||
| 113 | { | ||
| 114 | unsigned long start = 0x400000; | ||
| 115 | unsigned long stop = 0xF00000; | ||
| 116 | unsigned long increment = 0x100000; | ||
| 117 | char *ptr, *begin = NULL, *end = NULL; | ||
| 118 | int i; | ||
| 119 | |||
| 120 | for (i = start; i < stop; i += increment) | ||
| 121 | { | ||
| 122 | ptr = VirtualAlloc ((void *) i, increment, MEM_RESERVE, PAGE_NOACCESS); | ||
| 123 | if (ptr) | ||
| 124 | begin = begin ? begin : ptr; | ||
| 125 | else if (begin) | ||
| 126 | { | ||
| 127 | end = ptr; | ||
| 128 | break; | ||
| 129 | } | ||
| 130 | } | ||
| 131 | |||
| 132 | if (begin && !end) | ||
| 133 | end = (char *) i; | ||
| 134 | |||
| 135 | if (!begin) | ||
| 136 | /* We couldn't allocate any memory for the heap. Exit. */ | ||
| 137 | exit (-2); | ||
| 138 | |||
| 139 | reserved_heap_size = end - begin; | ||
| 140 | return begin; | ||
| 141 | } | ||
| 142 | #endif | ||
| 143 | |||
| 144 | |||
| 94 | /* Emulate Unix sbrk. */ | 145 | /* Emulate Unix sbrk. */ |
| 95 | void * | 146 | void * |
| 96 | sbrk (unsigned long increment) | 147 | sbrk (unsigned long increment) |
| @@ -101,10 +152,7 @@ sbrk (unsigned long increment) | |||
| 101 | /* Allocate our heap if we haven't done so already. */ | 152 | /* Allocate our heap if we haven't done so already. */ |
| 102 | if (!data_region_base) | 153 | if (!data_region_base) |
| 103 | { | 154 | { |
| 104 | data_region_base = VirtualAlloc ((void *) get_data_region_base (), | 155 | data_region_base = allocate_heap (); |
| 105 | get_reserved_heap_size (), | ||
| 106 | MEM_RESERVE, | ||
| 107 | PAGE_NOACCESS); | ||
| 108 | if (!data_region_base) | 156 | if (!data_region_base) |
| 109 | return NULL; | 157 | return NULL; |
| 110 | 158 | ||