public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: cygheap: use SRWLOCK for cygheap locking Date: Fri, 1 Mar 2024 21:37:12 +0000 (GMT) [thread overview] Message-ID: <20240301213712.7FCC43858D35@sourceware.org> (raw) 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 *
reply other threads:[~2024-03-01 21:37 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240301213712.7FCC43858D35@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).