From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1921) id 76BF7384F017; Fri, 24 Jun 2022 05:42:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 76BF7384F017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Sebastian Huber To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] bitset: implement BIT_TEST_CLR_ATOMIC & BIT_TEST_SET_ATOMIC X-Act-Checkin: newlib-cygwin X-Git-Author: Ryan Libby X-Git-Refname: refs/heads/master X-Git-Oldrev: 9d50b446899810ca22daf98cbb309510073f1bd0 X-Git-Newrev: fb0a5865e47c31370758bc0bd98f59c9f4b049af Message-Id: <20220624054239.76BF7384F017@sourceware.org> Date: Fri, 24 Jun 2022 05:42:39 +0000 (GMT) X-BeenThere: newlib-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib GIT logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jun 2022 05:42:39 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Dfb0a5865e47= c31370758bc0bd98f59c9f4b049af commit fb0a5865e47c31370758bc0bd98f59c9f4b049af Author: Ryan Libby Date: Thu Dec 31 13:02:45 2020 -0800 bitset: implement BIT_TEST_CLR_ATOMIC & BIT_TEST_SET_ATOMIC =20 That is, provide wrappers around the atomic_testandclear and atomic_testandset primitives. =20 Submitted by: jeff Reviewed by: cem, kib, markj Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D22702 Diff: --- newlib/libc/sys/rtems/include/sys/bitset.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/newlib/libc/sys/rtems/include/sys/bitset.h b/newlib/libc/sys/r= tems/include/sys/bitset.h index 3f263acd0..913fa290d 100644 --- a/newlib/libc/sys/rtems/include/sys/bitset.h +++ b/newlib/libc/sys/rtems/include/sys/bitset.h @@ -176,6 +176,12 @@ (d)->__bits[__i] =3D (s1)->__bits[__i] ^ (s2)->__bits[__i];\ } while (0) =20 +/* + * Note, the atomic(9) API is not consistent between clear/set and + * testandclear/testandset in whether the value argument is a mask + * or a bit index. + */ + #define BIT_CLR_ATOMIC(_s, n, p) \ atomic_clear_long(&(p)->__bits[__bitset_word(_s, n)], \ __bitset_mask((_s), n)) @@ -188,6 +194,14 @@ atomic_set_acq_long(&(p)->__bits[__bitset_word(_s, n)], \ __bitset_mask((_s), n)) =20 +#define BIT_TEST_CLR_ATOMIC(_s, n, p) \ + (atomic_testandclear_long( \ + &(p)->__bits[__bitset_word((_s), (n))], (n)) !=3D 0) + +#define BIT_TEST_SET_ATOMIC(_s, n, p) \ + (atomic_testandset_long( \ + &(p)->__bits[__bitset_word((_s), (n))], (n)) !=3D 0) + /* Convenience functions catering special cases. */ #define BIT_AND_ATOMIC(_s, d, s) do { \ __size_t __i; \