public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
From: Sebastian Huber <sh@sourceware.org>
To: newlib-cvs@sourceware.org
Subject: [newlib-cygwin] bitset: implement BIT_TEST_CLR_ATOMIC & BIT_TEST_SET_ATOMIC
Date: Fri, 24 Jun 2022 05:42:39 +0000 (GMT)	[thread overview]
Message-ID: <20220624054239.76BF7384F017@sourceware.org> (raw)

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


                 reply	other threads:[~2022-06-24  5:42 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=20220624054239.76BF7384F017@sourceware.org \
    --to=sh@sourceware.org \
    --cc=newlib-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: link
Be 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).