From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 7FCC43858D35; Fri, 1 Mar 2024 21:37:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7FCC43858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1709329032; bh=QYXJHMRlgH6nf9a1BWgeCy8uLGa8HEA2Y2N/Wefcdl4=; h=From:To:Subject:Date:From; b=TV7CJdXuqGGNSrTKMvTJp01iH0ckERmNz9NZ4vw+ltYYPhsNUD/uPK0JBud1ObxUy rIYhVcdYtq/eP+HEEd5s3RiRKOvc4rScA5Wpnbd2BUQNMJqPTo5KDeYUlHktKofuBd HnaETPPzI8GFxjHyFN6Za4fUfXefztbvQogamRcA= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: cygheap: use SRWLOCK for cygheap locking X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/main X-Git-Oldrev: e2ea60728cf9de3085cb5f19b899d3470f2399e5 X-Git-Newrev: 5d3e79ec6bb7362cb56765025a5ca756da41a293 Message-Id: <20240301213712.7FCC43858D35@sourceware.org> Date: Fri, 1 Mar 2024 21:37:12 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D5d3e79ec6bb= 7362cb56765025a5ca756da41a293 commit 5d3e79ec6bb7362cb56765025a5ca756da41a293 Author: Corinna Vinschen AuthorDate: Fri Mar 1 22:24:37 2024 +0100 Commit: Corinna Vinschen CommitDate: Fri Mar 1 22:31:33 2024 +0100 Cygwin: cygheap: use SRWLOCK for cygheap locking =20 Signed-off-by: Corinna Vinschen 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 =3D init_cygheap NO_COPY *cygheap =3D (init_cygheap *) &cygheap_dummy; void NO_COPY *cygheap_max; =20 -static NO_COPY muto cygheap_protect; +static NO_COPY SRWLOCK cygheap_protect =3D SRWLOCK_INIT; =20 struct cygheap_entry { @@ -278,7 +278,6 @@ static const uint32_t bucket_val[NBUCKETS] =3D { void cygheap_init () { - cygheap_protect.init ("cygheap_protect"); if (cygheap =3D=3D &cygheap_dummy) { cygheap =3D (init_cygheap *) VirtualAlloc ((LPVOID) CYGHEAP_STORAGE_= LOW, @@ -364,7 +363,7 @@ _cmalloc (unsigned size) if (b >=3D NBUCKETS) return NULL; =20 - cygheap_protect.acquire (); + AcquireSRWLockExclusive (&cygheap_protect); if (cygheap->buckets[b]) { rvc =3D (_cmalloc_entry *) cygheap->buckets[b]; @@ -376,7 +375,7 @@ _cmalloc (unsigned size) rvc =3D (_cmalloc_entry *) _csbrk (bucket_val[b] + sizeof (_cmalloc_= entry)); if (!rvc) { - cygheap_protect.release (); + ReleaseSRWLockExclusive (&cygheap_protect); return NULL; } =20 @@ -384,19 +383,19 @@ _cmalloc (unsigned size) rvc->prev =3D cygheap->chain; cygheap->chain =3D rvc; } - cygheap_protect.release (); + ReleaseSRWLockExclusive (&cygheap_protect); return rvc->data; } =20 static void _cfree (void *ptr) { - cygheap_protect.acquire (); + AcquireSRWLockExclusive (&cygheap_protect); _cmalloc_entry *rvc =3D to_cmalloc (ptr); unsigned b =3D rvc->b; rvc->ptr =3D cygheap->buckets[b]; cygheap->buckets[b] =3D (char *) rvc; - cygheap_protect.release (); + ReleaseSRWLockExclusive (&cygheap_protect); } =20 static void *