public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/main] Cygwin: cygheap: use SRWLOCK for cygheap locking
@ 2024-03-01 21:37 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2024-03-01 21:37 UTC (permalink / raw)
To: cygwin-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=5d3e79ec6bb7362cb56765025a5ca756da41a293
commit 5d3e79ec6bb7362cb56765025a5ca756da41a293
Author: Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Fri Mar 1 22:24:37 2024 +0100
Commit: Corinna Vinschen <corinna@vinschen.de>
CommitDate: Fri Mar 1 22:31:33 2024 +0100
Cygwin: cygheap: use SRWLOCK for cygheap locking
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
winsup/cygwin/mm/cygheap.cc | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/winsup/cygwin/mm/cygheap.cc b/winsup/cygwin/mm/cygheap.cc
index 3dc0c011fae4..c763a0967388 100644
--- a/winsup/cygwin/mm/cygheap.cc
+++ b/winsup/cygwin/mm/cygheap.cc
@@ -35,7 +35,7 @@ static mini_cygheap NO_COPY cygheap_dummy =
init_cygheap NO_COPY *cygheap = (init_cygheap *) &cygheap_dummy;
void NO_COPY *cygheap_max;
-static NO_COPY muto cygheap_protect;
+static NO_COPY SRWLOCK cygheap_protect = SRWLOCK_INIT;
struct cygheap_entry
{
@@ -278,7 +278,6 @@ static const uint32_t bucket_val[NBUCKETS] = {
void
cygheap_init ()
{
- cygheap_protect.init ("cygheap_protect");
if (cygheap == &cygheap_dummy)
{
cygheap = (init_cygheap *) VirtualAlloc ((LPVOID) CYGHEAP_STORAGE_LOW,
@@ -364,7 +363,7 @@ _cmalloc (unsigned size)
if (b >= NBUCKETS)
return NULL;
- cygheap_protect.acquire ();
+ AcquireSRWLockExclusive (&cygheap_protect);
if (cygheap->buckets[b])
{
rvc = (_cmalloc_entry *) cygheap->buckets[b];
@@ -376,7 +375,7 @@ _cmalloc (unsigned size)
rvc = (_cmalloc_entry *) _csbrk (bucket_val[b] + sizeof (_cmalloc_entry));
if (!rvc)
{
- cygheap_protect.release ();
+ ReleaseSRWLockExclusive (&cygheap_protect);
return NULL;
}
@@ -384,19 +383,19 @@ _cmalloc (unsigned size)
rvc->prev = cygheap->chain;
cygheap->chain = rvc;
}
- cygheap_protect.release ();
+ ReleaseSRWLockExclusive (&cygheap_protect);
return rvc->data;
}
static void
_cfree (void *ptr)
{
- cygheap_protect.acquire ();
+ AcquireSRWLockExclusive (&cygheap_protect);
_cmalloc_entry *rvc = to_cmalloc (ptr);
unsigned b = rvc->b;
rvc->ptr = cygheap->buckets[b];
cygheap->buckets[b] = (char *) rvc;
- cygheap_protect.release ();
+ ReleaseSRWLockExclusive (&cygheap_protect);
}
static void *
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-03-01 21:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-01 21:37 [newlib-cygwin/main] Cygwin: cygheap: use SRWLOCK for cygheap locking Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).