/[emacs]/emacs/src/w32heap.c
ViewVC logotype

Diff of /emacs/src/w32heap.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.21 by pj, Tue Jan 1 19:10:04 2002 UTC revision 1.21.4.1 by miles, Fri Apr 4 06:21:04 2003 UTC
# Line 58  int os_subtype; Line 58  int os_subtype;
58  void  void
59  cache_system_info (void)  cache_system_info (void)
60  {  {
61    union    union
62      {      {
63        struct info        struct info
64          {          {
65            char  major;            char  major;
66            char  minor;            char  minor;
# Line 157  sbrk (unsigned long increment) Line 157  sbrk (unsigned long increment)
157  {  {
158    void *result;    void *result;
159    long size = (long) increment;    long size = (long) increment;
160      
161    result = data_region_end;    result = data_region_end;
162      
163    /* If size is negative, shrink the heap by decommitting pages.  */    /* If size is negative, shrink the heap by decommitting pages.  */
164    if (size < 0)    if (size < 0)
165      {      {
166        int new_size;        int new_size;
167        unsigned char *new_data_region_end;        unsigned char *new_data_region_end;
# Line 172  sbrk (unsigned long increment) Line 172  sbrk (unsigned long increment)
172        if ((data_region_end - size) < data_region_base)        if ((data_region_end - size) < data_region_base)
173          return NULL;          return NULL;
174    
175        /* We can only decommit full pages, so allow for        /* We can only decommit full pages, so allow for
176           partial deallocation [cga].  */           partial deallocation [cga].  */
177        new_data_region_end = (data_region_end - size);        new_data_region_end = (data_region_end - size);
178        new_data_region_end = (unsigned char *)        new_data_region_end = (unsigned char *)
# Line 188  sbrk (unsigned long increment) Line 188  sbrk (unsigned long increment)
188          }          }
189    
190        data_region_end -= size;        data_region_end -= size;
191      }      }
192    /* If size is positive, grow the heap by committing reserved pages.  */    /* If size is positive, grow the heap by committing reserved pages.  */
193    else if (size > 0)    else if (size > 0)
194      {      {
195        /* Sanity checks.  */        /* Sanity checks.  */
196        if ((data_region_end + size) >        if ((data_region_end + size) >
# Line 209  sbrk (unsigned long increment) Line 209  sbrk (unsigned long increment)
209        real_data_region_end = (unsigned char *)        real_data_region_end = (unsigned char *)
210            ((long) (data_region_end + syspage_mask) & ~syspage_mask);            ((long) (data_region_end + syspage_mask) & ~syspage_mask);
211      }      }
212      
213    return result;    return result;
214  }  }
215    
# Line 232  init_heap () Line 232  init_heap ()
232    PIMAGE_NT_HEADERS nt_header;    PIMAGE_NT_HEADERS nt_header;
233    
234    dos_header = (PIMAGE_DOS_HEADER) RVA_TO_PTR (0);    dos_header = (PIMAGE_DOS_HEADER) RVA_TO_PTR (0);
235    nt_header = (PIMAGE_NT_HEADERS) (((unsigned long) dos_header) +    nt_header = (PIMAGE_NT_HEADERS) (((unsigned long) dos_header) +
236                                     dos_header->e_lfanew);                                     dos_header->e_lfanew);
237    preload_heap_section = find_section ("EMHEAP", nt_header);    preload_heap_section = find_section ("EMHEAP", nt_header);
238    
# Line 247  init_heap () Line 247  init_heap ()
247    
248        /* Ensure that the addresses don't use the upper tag bits since        /* Ensure that the addresses don't use the upper tag bits since
249           the Lisp type goes there.  */           the Lisp type goes there.  */
250        if (((unsigned long) data_region_base & ~VALMASK) != 0)        if (((unsigned long) data_region_base & ~VALMASK) != 0)
251          {          {
252            printf ("Error: The heap was allocated in upper memory.\n");            printf ("Error: The heap was allocated in upper memory.\n");
253            exit (1);            exit (1);
# Line 274  round_heap (unsigned long align) Line 274  round_heap (unsigned long align)
274  {  {
275    unsigned long needs_to_be;    unsigned long needs_to_be;
276    unsigned long need_to_alloc;    unsigned long need_to_alloc;
277      
278    needs_to_be = (unsigned long) ROUND_UP (get_heap_end (), align);    needs_to_be = (unsigned long) ROUND_UP (get_heap_end (), align);
279    need_to_alloc = needs_to_be - (unsigned long) get_heap_end ();    need_to_alloc = needs_to_be - (unsigned long) get_heap_end ();
280      
281    if (need_to_alloc)    if (need_to_alloc)
282      sbrk (need_to_alloc);      sbrk (need_to_alloc);
283  }  }
284    
285  #if (_MSC_VER >= 1000 && !defined(USE_CRT_DLL))  #if (_MSC_VER >= 1000 && _MSC_VER < 1300 && !defined(USE_CRT_DLL))
286    
287  /* MSVC 4.2 invokes these functions from mainCRTStartup to initialize  /* MSVC 4.2 invokes these functions from mainCRTStartup to initialize
288     a heap via HeapCreate.  They are normally defined by the runtime,     a heap via HeapCreate.  They are normally defined by the runtime,

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.21.4.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26