From 8366e93be9f55449a38d8640caf454640e5e9105 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Mon, 3 Jul 2000 20:14:06 +0000 Subject: * exceptions.cc (stack_info::walk): Use method to find offset. (handle_exceptions): Be more assertive in finding ebp for use under W2K. Create a dummy stack frame for cases where program is dying and a stack dump is being output. (sig_handle): Fill out a GetThreadContext for use with a user-generated "core dump". --- winsup/cygwin/heap.cc | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'winsup/cygwin/heap.cc') diff --git a/winsup/cygwin/heap.cc b/winsup/cygwin/heap.cc index ce1cab5c4..5989aefca 100644 --- a/winsup/cygwin/heap.cc +++ b/winsup/cygwin/heap.cc @@ -20,6 +20,8 @@ details. */ static unsigned page_const = 0; +HANDLE cygwin_heap; + static __inline__ int getpagesize(void) { @@ -36,9 +38,9 @@ heap_init () /* If we're the forkee, we must allocate the heap at exactly the same place as our parent. If not, we don't care where it ends up. */ - page_const = getpagesize(); if (brkbase) { + DWORD chunk = brkchunk; /* allocation chunk */ /* total size commited in parent */ DWORD allocsize = (char *) brktop - (char *) brkbase; @@ -46,14 +48,13 @@ heap_init () DWORD reserve_size = chunk * ((allocsize + (chunk - 1)) / chunk); /* Loop until we've managed to reserve an adequate amount of memory. */ - char *p; + void *p; for (;;) { - p = (char *) VirtualAlloc (brkbase, reserve_size, - MEM_RESERVE, PAGE_READWRITE); + p = MapViewOfFileEx (cygwin_heap, FILE_MAP_COPY, 0L, 0L, 0L, brkbase); if (p) break; - if ((reserve_size -= page_const) <= allocsize) + if ((reserve_size -= (page_const + 1)) <= allocsize) break; } if (p == NULL) @@ -61,20 +62,25 @@ heap_init () brkchunk, myself->pid); if (p != brkbase) api_fatal ("heap allocated but not at %p", brkbase); - if (! VirtualAlloc (brkbase, allocsize, MEM_COMMIT, PAGE_READWRITE)) + if (!VirtualAlloc (brkbase, allocsize, MEM_COMMIT, PAGE_READWRITE)) api_fatal ("MEM_COMMIT failed, %E"); } else { + page_const = getpagesize() - 1; /* Initialize page mask and default heap size. Preallocate a heap * to assure contiguous memory. */ - brk = brktop = brkbase = VirtualAlloc(NULL, brkchunk, MEM_RESERVE, PAGE_NOACCESS); + cygwin_heap = CreateFileMapping ((HANDLE) 0xffffffff, &sec_all, PAGE_WRITECOPY | SEC_RESERVE, 0L, brkchunk, NULL); + if (cygwin_heap == NULL) + api_fatal ("2. unable to allocate shared memory for heap, heap_chunk_size %d, %E", brkchunk); + + brk = brktop = brkbase = MapViewOfFile (cygwin_heap, 0, 0L, 0L, 0); +// brk = brktop = brkbase = VirtualAlloc(NULL, brkchunk, MEM_RESERVE, PAGE_NOACCESS); if (brkbase == NULL) api_fatal ("2. unable to allocate heap, heap_chunk_size %d, %E", brkchunk); } - page_const--; malloc_init (); } -- cgit v1.2.3