comparison src/sheap.c @ 272:c5d627a313b1 r21-0b34

Import from CVS: tag r21-0b34
author cvs
date Mon, 13 Aug 2007 10:28:48 +0200
parents b2472a1930f2
children 90d73dddcdc4
comparison
equal deleted inserted replaced
271:c7b7086b0a39 272:c5d627a313b1
20 20
21 #include <config.h> 21 #include <config.h>
22 #include <stdio.h> 22 #include <stdio.h>
23 #include "lisp.h" 23 #include "lisp.h"
24 #include <stddef.h> 24 #include <stddef.h>
25 #include "sheap-adjust.h" 25 #include <sheap-adjust.h>
26 26
27 #define STATIC_HEAP_BASE 0x600000 27 #define STATIC_HEAP_BASE 0x600000
28 #define STATIC_HEAP_SLOP 0x40000 28 #define STATIC_HEAP_SLOP 0x40000
29 #define STATIC_HEAP_SIZE \ 29 #define STATIC_HEAP_SIZE \
30 (STATIC_HEAP_BASE + SHEAP_ADJUSTMENT + STATIC_HEAP_SLOP) 30 (STATIC_HEAP_BASE + SHEAP_ADJUSTMENT + STATIC_HEAP_SLOP)
42 42
43 void* more_static_core ( ptrdiff_t increment ) 43 void* more_static_core ( ptrdiff_t increment )
44 { 44 {
45 int size = (int) increment; 45 int size = (int) increment;
46 void *result; 46 void *result;
47 47
48 if (!static_heap_initialized) 48 if (!static_heap_initialized)
49 { 49 {
50 if (((unsigned long) static_heap_base & ~VALMASK) != 0) 50 if (((unsigned long) static_heap_base & ~VALMASK) != 0)
51 { 51 {
52 printf ("error: The heap was allocated in upper memory.\n"); 52 printf ("error: The heap was allocated in upper memory.\n");
53 exit (-1); 53 exit (-1);
54 } 54 }
55 static_heap_base=(char*)ALIGN_ALLOC(static_heap_buffer); 55 static_heap_base=(char*)ALIGN_ALLOC(static_heap_buffer);
56 static_heap_ptr=static_heap_base; 56 static_heap_ptr=static_heap_base;
57 static_heap_size=STATIC_HEAP_SIZE - 57 static_heap_size=STATIC_HEAP_SIZE -
58 (static_heap_base-static_heap_buffer); 58 (static_heap_base-static_heap_buffer);
59 #ifdef __CYGWIN32__ 59 #ifdef __CYGWIN32__
60 sbrk(BLOCKSIZE); /* force space for fork to work */ 60 sbrk(BLOCKSIZE); /* force space for fork to work */
61 #endif 61 #endif
62 static_heap_initialized=1; 62 static_heap_initialized=1;
63 } 63 }
64 64
65 result = static_heap_ptr; 65 result = static_heap_ptr;
66 66
67 /* we don't need to align - handled by gmalloc. */ 67 /* we don't need to align - handled by gmalloc. */
68 68
69 if (size < 0) 69 if (size < 0)
70 { 70 {
71 if (static_heap_ptr + size < static_heap_base) 71 if (static_heap_ptr + size < static_heap_base)
72 { 72 {
73 return 0; 73 return 0;
74 } 74 }
75 } 75 }
76 else 76 else
77 { 77 {
78 if (static_heap_ptr + size >= static_heap_base + static_heap_size) 78 if (static_heap_ptr + size >= static_heap_base + static_heap_size)
79 { 79 {
80 printf( 80 printf(
81 81
89 exit(-1); 89 exit(-1);
90 return 0; 90 return 0;
91 } 91 }
92 } 92 }
93 static_heap_ptr += size; 93 static_heap_ptr += size;
94 94
95 return result; 95 return result;
96 } 96 }
97 97
98 void 98 void
99 sheap_adjust_h () 99 sheap_adjust_h ()