Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2000-07-04 00:14:06 +0400
committerChristopher Faylor <me@cgf.cx>2000-07-04 00:14:06 +0400
commit8366e93be9f55449a38d8640caf454640e5e9105 (patch)
tree87c45ef692fb3ef106ca41bde845d6460ef60abf /winsup/cygwin/heap.cc
parent4bedf498d65bb6e30ee983b6c19d63a2ced1bab7 (diff)
* 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".
Diffstat (limited to 'winsup/cygwin/heap.cc')
-rw-r--r--winsup/cygwin/heap.cc22
1 files changed, 14 insertions, 8 deletions
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 ();
}