public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] bitset: implement BIT_TEST_CLR_ATOMIC & BIT_TEST_SET_ATOMIC
@ 2022-06-24  5:42 Sebastian Huber
  0 siblings, 0 replies; only message in thread
From: Sebastian Huber @ 2022-06-24  5:42 UTC (permalink / raw)
  To: newlib-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=fb0a5865e47c31370758bc0bd98f59c9f4b049af

commit fb0a5865e47c31370758bc0bd98f59c9f4b049af
Author: Ryan Libby <rlibby@FreeBSD.org>
Date:   Thu Dec 31 13:02:45 2020 -0800

    bitset: implement BIT_TEST_CLR_ATOMIC & BIT_TEST_SET_ATOMIC
    
    That is, provide wrappers around the atomic_testandclear and
    atomic_testandset primitives.
    
    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/rtems/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] = (s1)->__bits[__i] ^ (s2)->__bits[__i];\
 } while (0)
 
+/*
+ * 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))
 
+#define	BIT_TEST_CLR_ATOMIC(_s, n, p)					\
+	(atomic_testandclear_long(					\
+	    &(p)->__bits[__bitset_word((_s), (n))], (n)) != 0)
+
+#define	BIT_TEST_SET_ATOMIC(_s, n, p)					\
+	(atomic_testandset_long(					\
+	    &(p)->__bits[__bitset_word((_s), (n))], (n)) != 0)
+
 /* Convenience functions catering special cases. */
 #define	BIT_AND_ATOMIC(_s, d, s) do {					\
 	__size_t __i;							\


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-24  5:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-24  5:42 [newlib-cygwin] bitset: implement BIT_TEST_CLR_ATOMIC & BIT_TEST_SET_ATOMIC Sebastian Huber

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).