Revert "Cygwin: convert malloc lock to SRWLOCK"

This reverts commit 44a79a6eca.
This commit is contained in:
Corinna Vinschen 2021-10-28 20:39:42 +02:00
parent 3860338968
commit 462ca33745
7 changed files with 9 additions and 12 deletions

View File

@ -36,11 +36,9 @@ void *mmap64 (void *, size_t, int, int, int, off_t);
#elif defined (__INSIDE_CYGWIN__)
# define __malloc_lock() AcquireSRWLockExclusive (&mallock)
# define __malloc_trylock() TryAcquireSRWLockExclusive (&mallock)
# define __malloc_unlock() ReleaseSRWLockExclusive (&mallock)
extern SRWLOCK NO_COPY mallock;
void malloc_init ();
# define __malloc_lock() mallock.acquire ()
# define __malloc_unlock() mallock.release ()
extern muto mallock;
#endif

View File

@ -29,7 +29,6 @@ details. */
#include "shared_info.h"
#include "cygwin_version.h"
#include "dll_init.h"
#include "cygmalloc.h"
#include "heap.h"
#include "tls_pbuf.h"
#include "exception.h"

View File

@ -296,7 +296,7 @@ frok::parent (volatile char * volatile stack_here)
si.lpReserved2 = (LPBYTE) &ch;
si.cbReserved2 = sizeof (ch);
bool locked = __malloc_trylock ();
bool locked = __malloc_lock ();
/* Remove impersonation */
cygheap->user.deimpersonate ();

View File

@ -230,6 +230,7 @@ user_heap_info::init ()
debug_printf ("heap base %p, heap top %p, heap size %ly (%lu)",
base, top, chunk, chunk);
page_const--;
// malloc_init ();
}
#define pround(n) (((size_t)(n) + page_const) & ~page_const)

View File

@ -10,6 +10,7 @@ details. */
/* Heap management. */
void heap_init ();
void malloc_init ();
#define inheap(s) \
(cygheap->user_heap.ptr && s \

View File

@ -269,11 +269,13 @@ strdup (const char *s)
newlib will call __malloc_lock and __malloc_unlock at appropriate
times. */
SRWLOCK NO_COPY mallock = SRWLOCK_INIT;
muto NO_COPY mallock;
void
malloc_init ()
{
mallock.init ("mallock");
/* Check if malloc is provided by application. If so, redirect all
calls to malloc/free/realloc to application provided. This may
happen if some other dll calls cygwin's malloc, but main code provides

View File

@ -78,7 +78,3 @@ Bug Fixes
- Fix access violation that can sometimes occur when copy/pasting between
32-bit and 64-bit Cygwin environments. Align clipboard descriptor layouts.
Addresses: https://cygwin.com/pipermail/cygwin-patches/2021q4/011517.html
- Fix a synchronization issue when running multiple threads from DLL
initialization which in turn call malloc.
Addresses: https://cygwin.com/pipermail/cygwin/2021-October/249635.html