bitset: rename confusing macro NAND to ANDNOT

s/BIT_NAND/BIT_ANDNOT/, and for CPU and DOMAINSET too.  The actual
implementation is "and not" (or "but not"), i.e. A but not B.
Fortunately this does appear to be what all existing callers want.

Don't supply a NAND (not (A and B)) operation at this time.

Discussed with:	jeff
Reviewed by:	cem
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D22791
This commit is contained in:
Ryan Libby 2019-12-13 09:32:16 +00:00
parent f7af501519
commit 9825eadf2c
14 changed files with 26 additions and 26 deletions

View File

@ -607,7 +607,7 @@ MLINKS+=bitset.9 BITSET_DEFINE.9 \
bitset.9 BIT_CMP.9 \
bitset.9 BIT_OR.9 \
bitset.9 BIT_AND.9 \
bitset.9 BIT_NAND.9 \
bitset.9 BIT_ANDNOT.9 \
bitset.9 BIT_CLR_ATOMIC.9 \
bitset.9 BIT_SET_ATOMIC.9 \
bitset.9 BIT_SET_ATOMIC_ACQ.9 \
@ -856,7 +856,7 @@ MLINKS+=cpuset.9 CPUSET_T_INITIALIZER.9 \
cpuset.9 CPU_CMP.9 \
cpuset.9 CPU_OR.9 \
cpuset.9 CPU_AND.9 \
cpuset.9 CPU_NAND.9 \
cpuset.9 CPU_ANDNOT.9 \
cpuset.9 CPU_CLR_ATOMIC.9 \
cpuset.9 CPU_SET_ATOMIC.9 \
cpuset.9 CPU_SET_ATOMIC_ACQ.9 \

View File

@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd July 7, 2017
.Dd December 12, 2019
.Dt BITSET 9
.Os
.Sh NAME
@ -52,8 +52,8 @@
.Nm BIT_OR2 ,
.Nm BIT_AND ,
.Nm BIT_AND2 ,
.Nm BIT_NAND ,
.Nm BIT_NAND2 ,
.Nm BIT_ANDNOT ,
.Nm BIT_ANDNOT2 ,
.Nm BIT_XOR ,
.Nm BIT_XOR2 ,
.Nm BIT_CLR_ATOMIC ,
@ -116,8 +116,8 @@
.Fa "struct STRUCTNAME *src1"
.Fa "struct STRUCTNAME *src2"
.Fc
.Fn BIT_NAND "const SETSIZE" "struct STRUCTNAME *dst" "struct STRUCTNAME *src"
.Fo BIT_NAND2
.Fn BIT_ANDNOT "const SETSIZE" "struct STRUCTNAME *dst" "struct STRUCTNAME *src"
.Fo BIT_ANDNOT2
.Fa "const SETSIZE"
.Fa "struct STRUCTNAME *dst"
.Fa "struct STRUCTNAME *src1"
@ -412,7 +412,7 @@ equivalent of the scalar:
.Fa src2 . )
.Pp
The
.Fn BIT_NAND
.Fn BIT_ANDNOT
macro clears bits set in
.Fa src
from
@ -425,7 +425,7 @@ equivalent of the scalar:
.Fa ~ src . )
.Pp
The
.Fn BIT_NAND2
.Fn BIT_ANDNOT2
macro computes
.Fa src1
bitwise and not

View File

@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd July 29, 2016
.Dd December 12, 2019
.Dt CPUSET 9
.Os
.Sh NAME
@ -48,7 +48,7 @@
.Nm CPU_CMP ,
.Nm CPU_OR ,
.Nm CPU_AND ,
.Nm CPU_NAND ,
.Nm CPU_ANDNOT ,
.Nm CPU_CLR_ATOMIC ,
.Nm CPU_SET_ATOMIC ,
.Nm CPU_SET_ATOMIC_ACQ ,
@ -88,7 +88,7 @@
.Fn CPU_CMP "cpuset_t *cpuset1" "cpuset_t *cpuset2"
.Fn CPU_OR "cpuset_t *dst" "cpuset_t *src"
.Fn CPU_AND "cpuset_t *dst" "cpuset_t *src"
.Fn CPU_NAND "cpuset_t *dst" "cpuset_t *src"
.Fn CPU_ANDNOT "cpuset_t *dst" "cpuset_t *src"
.\"
.Fn CPU_CLR_ATOMIC "size_t cpu_idx" "cpuset_t *cpuset"
.Fn CPU_SET_ATOMIC "size_t cpu_idx" "cpuset_t *cpuset"
@ -303,7 +303,7 @@ is similar, with the same atomic semantics as
.Fn CPU_OR_ATOMIC .
.Pp
The
.Fn CPU_NAND
.Fn CPU_ANDNOT
macro removes CPUs in
.Fa src
from

View File

@ -598,7 +598,7 @@ sf_buf_shootdown(struct sf_buf *sf, int flags)
if ((flags & SFB_CPUPRIVATE) == 0) {
other_cpus = all_cpus;
CPU_CLR(cpuid, &other_cpus);
CPU_NAND(&other_cpus, &sf->cpumask);
CPU_ANDNOT(&other_cpus, &sf->cpumask);
if (!CPU_EMPTY(&other_cpus)) {
CPU_OR(&sf->cpumask, &other_cpus);
smp_masked_invlpg(other_cpus, sf->kva, kernel_pmap);

View File

@ -510,7 +510,7 @@ domainset_empty_vm(struct domainset *domain)
return (true);
/* Remove empty domains from the set and recompute. */
DOMAINSET_NAND(&domain->ds_mask, &empty);
DOMAINSET_ANDNOT(&domain->ds_mask, &empty);
domain->ds_cnt = DOMAINSET_COUNT(&domain->ds_mask);
for (i = j = 0; i < DOMAINSET_FLS(&domain->ds_mask); i++)
if (DOMAINSET_ISSET(i, &domain->ds_mask))

View File

@ -542,7 +542,7 @@ _rm_wlock(struct rmlock *rm)
if (CPU_CMP(&rm->rm_writecpus, &all_cpus)) {
/* Get all read tokens back */
readcpus = all_cpus;
CPU_NAND(&readcpus, &rm->rm_writecpus);
CPU_ANDNOT(&readcpus, &rm->rm_writecpus);
rm->rm_writecpus = all_cpus;
/*

View File

@ -1181,7 +1181,7 @@ forward_wakeup(int cpunum)
if (forward_wakeup_use_mask) {
map = idle_cpus_mask;
CPU_NAND(&map, &dontuse);
CPU_ANDNOT(&map, &dontuse);
/* If they are both on, compare and use loop if different. */
if (forward_wakeup_use_loop) {
@ -1366,7 +1366,7 @@ sched_add(struct thread *td, int flags)
} else {
if (!single_cpu) {
tidlemsk = idle_cpus_mask;
CPU_NAND(&tidlemsk, &hlt_cpus_mask);
CPU_ANDNOT(&tidlemsk, &hlt_cpus_mask);
CPU_CLR(cpuid, &tidlemsk);
if (!CPU_ISSET(cpuid, &idle_cpus_mask) &&

View File

@ -705,7 +705,7 @@ cpu_search(const struct cpu_group *cg, struct cpu_search *low,
if (match & CPU_SEARCH_HIGHEST)
hgroup.cs_cpu = -1;
if (child) { /* Handle child CPU group. */
CPU_NAND(&cpumask, &child->cg_mask);
CPU_ANDNOT(&cpumask, &child->cg_mask);
switch (match) {
case CPU_SEARCH_LOWEST:
load = cpu_search_lowest(child, &lgroup);

View File

@ -666,7 +666,7 @@ kdb_trap(int type, int code, struct trapframe *tf)
if (!SCHEDULER_STOPPED()) {
#ifdef SMP
other_cpus = all_cpus;
CPU_NAND(&other_cpus, &stopped_cpus);
CPU_ANDNOT(&other_cpus, &stopped_cpus);
CPU_CLR(PCPU_GET(cpuid), &other_cpus);
stop_cpus_hard(other_cpus);
#endif

View File

@ -493,7 +493,7 @@ cpu_mp_shutdown(void)
if (CPU_CMP(&stopped_cpus, &cpus)) {
/* cpus is just a flat "on" mask without curcpu. */
CPU_NAND(&cpus, &stopped_cpus);
CPU_ANDNOT(&cpus, &stopped_cpus);
stop_cpus(cpus);
}
i = 0;

View File

@ -149,13 +149,13 @@
(d)->__bits[__i] = (s1)->__bits[__i] & (s2)->__bits[__i];\
} while (0)
#define BIT_NAND(_s, d, s) do { \
#define BIT_ANDNOT(_s, d, s) do { \
__size_t __i; \
for (__i = 0; __i < __bitset_words((_s)); __i++) \
(d)->__bits[__i] &= ~(s)->__bits[__i]; \
} while (0)
#define BIT_NAND2(_s, d, s1, s2) do { \
#define BIT_ANDNOT2(_s, d, s1, s2) do { \
__size_t __i; \
for (__i = 0; __i < __bitset_words((_s)); __i++) \
(d)->__bits[__i] = (s1)->__bits[__i] & ~(s2)->__bits[__i];\

View File

@ -57,7 +57,7 @@
#define CPU_CMP(p, c) BIT_CMP(CPU_SETSIZE, p, c)
#define CPU_OR(d, s) BIT_OR(CPU_SETSIZE, d, s)
#define CPU_AND(d, s) BIT_AND(CPU_SETSIZE, d, s)
#define CPU_NAND(d, s) BIT_NAND(CPU_SETSIZE, d, s)
#define CPU_ANDNOT(d, s) BIT_ANDNOT(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_SET_ATOMIC_ACQ(n, p) BIT_SET_ATOMIC_ACQ(CPU_SETSIZE, n, p)

View File

@ -58,7 +58,7 @@
#define DOMAINSET_CMP(p, c) BIT_CMP(DOMAINSET_SETSIZE, p, c)
#define DOMAINSET_OR(d, s) BIT_OR(DOMAINSET_SETSIZE, d, s)
#define DOMAINSET_AND(d, s) BIT_AND(DOMAINSET_SETSIZE, d, s)
#define DOMAINSET_NAND(d, s) BIT_NAND(DOMAINSET_SETSIZE, d, s)
#define DOMAINSET_ANDNOT(d, s) BIT_ANDNOT(DOMAINSET_SETSIZE, d, s)
#define DOMAINSET_CLR_ATOMIC(n, p) BIT_CLR_ATOMIC(DOMAINSET_SETSIZE, n, p)
#define DOMAINSET_SET_ATOMIC(n, p) BIT_SET_ATOMIC(DOMAINSET_SETSIZE, n, p)
#define DOMAINSET_SET_ATOMIC_ACQ(n, p) \

View File

@ -447,7 +447,7 @@ cpu_reset(void)
if (smp_started) {
map = all_cpus;
CPU_CLR(PCPU_GET(cpuid), &map);
CPU_NAND(&map, &stopped_cpus);
CPU_ANDNOT(&map, &stopped_cpus);
if (!CPU_EMPTY(&map)) {
printf("cpu_reset: Stopping other CPUs\n");
stop_cpus(map);