From: Ryan Libby <rli...@freebsd.org>

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
---
 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;                                                   \
-- 
2.35.3

_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to