From a0887a4c2db88710c568f5051efd20bbf8696f07 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Fri, 30 Aug 2013 07:43:34 +0000 Subject: [PATCH] Add BIT_AND_ATOMIC() and CPU_AND_ATOMIC(). Sponsored by: The FreeBSD Foundation Reviewed by: alc Tested by: pho, bf --- sys/sys/bitset.h | 9 ++++++++- sys/sys/cpuset.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/sys/sys/bitset.h b/sys/sys/bitset.h index dee5542d68b7..7c24ecd04431 100644 --- a/sys/sys/bitset.h +++ b/sys/sys/bitset.h @@ -135,7 +135,14 @@ atomic_set_long(&(p)->__bits[__bitset_word(_s, n)], \ __bitset_mask((_s), n)) -/* Convenience functions catering special cases. */ +/* Convenience functions catering special cases. */ +#define BIT_AND_ATOMIC(_s, d, s) do { \ + __size_t __i; \ + for (__i = 0; __i < __bitset_words((_s)); __i++) \ + atomic_clear_long(&(d)->__bits[__i], \ + ~(s)->__bits[__i]); \ +} while (0) + #define BIT_OR_ATOMIC(_s, d, s) do { \ __size_t __i; \ for (__i = 0; __i < __bitset_words((_s)); __i++) \ diff --git a/sys/sys/cpuset.h b/sys/sys/cpuset.h index fc078d303bb8..e1ee37d020de 100644 --- a/sys/sys/cpuset.h +++ b/sys/sys/cpuset.h @@ -55,6 +55,7 @@ #define CPU_NAND(d, s) BIT_NAND(CPU_SETSIZE, d, s) #define CPU_CLR_ATOMIC(n, p) BIT_CLR_ATOMIC(CPU_SETSIZE, n, p) #define CPU_SET_ATOMIC(n, p) BIT_SET_ATOMIC(CPU_SETSIZE, n, p) +#define CPU_AND_ATOMIC(n, p) BIT_AND_ATOMIC(CPU_SETSIZE, n, p) #define CPU_OR_ATOMIC(d, s) BIT_OR_ATOMIC(CPU_SETSIZE, d, s) #define CPU_COPY_STORE_REL(f, t) BIT_COPY_STORE_REL(CPU_SETSIZE, f, t) #define CPU_FFS(p) BIT_FFS(CPU_SETSIZE, p)