diff options
author | Christopher Faylor <me@cgf.cx> | 2000-02-26 01:11:54 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2000-02-26 01:11:54 +0000 |
commit | 8656ee07efbd5d47cde561d4ead67174970f989b (patch) | |
tree | f25b7adbe6236e9aec1b76b7eef1c18143b9a0b6 /winsup/cygwin/malloc_wrapper.cc | |
parent | 52aaab48f491505380eca98379beccdd8b4f2570 (diff) | |
download | newlib-8656ee07efbd5d47cde561d4ead67174970f989b.zip newlib-8656ee07efbd5d47cde561d4ead67174970f989b.tar.gz newlib-8656ee07efbd5d47cde561d4ead67174970f989b.tar.bz2 |
* exceptions.cc (interruptible): Make a little more structured.
(call_handler): Allow signals to be sent even if signalled thread is stopped.
Change order of signal_arrived arming/waiting threads clearing to eliminate a
race.
(reset_signal_arrived): New helper function.
* malloc.cc (malloc_init): Use mutos so that signal handler can keep track of
who owns the lock.
(__malloc_lock): Ditto.
(__malloc_unlock): Ditto.
* sync.h (new_muto): Actually use a muto for the "buffer".
* Makefile.in: Fix a dependency.
Diffstat (limited to 'winsup/cygwin/malloc_wrapper.cc')
-rw-r--r-- | winsup/cygwin/malloc_wrapper.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/winsup/cygwin/malloc_wrapper.cc b/winsup/cygwin/malloc_wrapper.cc index 3442c14..3fa5e06 100644 --- a/winsup/cygwin/malloc_wrapper.cc +++ b/winsup/cygwin/malloc_wrapper.cc @@ -13,6 +13,7 @@ details. */ #include "winsup.h" #include <stdlib.h> +#include "sync.h" /* we provide these stubs to call into a user's provided malloc if there is one - otherwise @@ -200,12 +201,12 @@ _strdup_r (struct _reent *, const char *s) newlib will call __malloc_lock and __malloc_unlock at appropriate times. */ -static NO_COPY CRITICAL_SECTION malloc_critical_section; +static NO_COPY muto *mprotect = NULL; void malloc_init () { - InitializeCriticalSection (&malloc_critical_section); + mprotect = new_muto (FALSE, NULL); /* Check if mallock is provided by application. If so, redirect all calls to export_malloc/free/realloc to application provided. This may happen if some other dll calls cygwin's malloc, but main code provides @@ -226,12 +227,12 @@ extern "C" void __malloc_lock (struct _reent *) { - SetResourceLock(LOCK_MEMORY_LIST,WRITE_LOCK|READ_LOCK," __malloc_lock"); + mprotect->acquire (); } extern "C" void __malloc_unlock (struct _reent *) { - ReleaseResourceLock(LOCK_MEMORY_LIST,WRITE_LOCK|READ_LOCK," __malloc_unlock"); + mprotect->release (); } |