comparison src/sheap.c @ 1157:6af03f821bbe

[xemacs-hg @ 2002-12-13 04:29:06 by andyp] static heap fiuxups
author andyp
date Fri, 13 Dec 2002 04:30:18 +0000
parents 184461bc8de4
children 70921960b980
comparison
equal deleted inserted replaced
1156:64df484c9156 1157:6af03f821bbe
25 25
26 #include <unistd.h> 26 #include <unistd.h>
27 #include <sheap-adjust.h> 27 #include <sheap-adjust.h>
28 28
29 #define STATIC_HEAP_BASE 0x800000 29 #define STATIC_HEAP_BASE 0x800000
30 #define STATIC_HEAP_SLOP 0x500000 30 #define STATIC_HEAP_SLOP 0x40000
31 #define STATIC_HEAP_SIZE \ 31 #define STATIC_HEAP_SIZE \
32 (STATIC_HEAP_BASE + SHEAP_ADJUSTMENT + STATIC_HEAP_SLOP) 32 (STATIC_HEAP_BASE + SHEAP_ADJUSTMENT + STATIC_HEAP_SLOP)
33 #define BLOCKSIZE (1<<12) 33 #define BLOCKSIZE (1<<12)
34 #define ALLOC_UNIT (BLOCKSIZE-1) 34 #define ALLOC_UNIT (BLOCKSIZE-1)
35 #define ALLOC_MASK ~((unsigned long)(ALLOC_UNIT)) 35 #define ALLOC_MASK ~((unsigned long)(ALLOC_UNIT))
127 int rc = 0; 127 int rc = 0;
128 128
129 Bytecount lost = STATIC_HEAP_SIZE 129 Bytecount lost = STATIC_HEAP_SIZE
130 - (static_heap_ptr - static_heap_buffer); 130 - (static_heap_ptr - static_heap_buffer);
131 char buf[200]; 131 char buf[200];
132 sprintf (buf, "Static heap usage: %ld of %ld, slop is %ld", 132 sprintf (buf, "Static heap usage: %ldk of %ldk, slop is %ldk",
133 (long) (static_heap_ptr - static_heap_buffer), 133 (long) ((static_heap_ptr - static_heap_buffer) /1024),
134 (long) (STATIC_HEAP_SIZE), 134 (long) (STATIC_HEAP_SIZE / 1024),
135 (long) STATIC_HEAP_SLOP); 135 (long) STATIC_HEAP_SLOP / 1024);
136 136
137 if (lost > STATIC_HEAP_SLOP) { 137 if (lost > STATIC_HEAP_SLOP) {
138 sprintf (buf + strlen (buf), " -- %ldk wasted", (long)(lost/1024)); 138 sprintf (buf + strlen (buf), " -- %ldk wasted", (long)(lost/1024));
139 if (die_if_pure_storage_exceeded) { 139 if (die_if_pure_storage_exceeded) {
140 sheap_adjust_h(STATIC_HEAP_SLOP - lost); 140 sheap_adjust_h(STATIC_HEAP_SLOP - lost);
141 sprintf (buf + strlen (buf), " -- reset to %ldk", 141 sprintf (buf + strlen (buf), " -- reset to %ldk",
142 (long) (STATIC_HEAP_SIZE + STATIC_HEAP_SLOP - lost)); 142 (long) ((STATIC_HEAP_SIZE + STATIC_HEAP_SLOP - lost) / 1024));
143 rc = -1; 143 rc = -1;
144 } 144 }
145 message ("%s", buf); 145 message ("%s", buf);
146 } 146 }
147 147