aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/pcpu.h
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2020-02-07 22:43:58 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2020-02-07 22:43:58 +0000
commitc77649d8e7ecbeb083a50ff6526844c3b616b2d3 (patch)
tree81b10ff7399455de99a52fd972e7e15f64a42a26 /sys/sys/pcpu.h
parent14d3b069199d6a780cb83f55dfff11ed1ccea69d (diff)
downloadsrc-c77649d8e7ecbeb083a50ff6526844c3b616b2d3.tar.gz
src-c77649d8e7ecbeb083a50ff6526844c3b616b2d3.zip
Add zpcpu_{set,add,sub}_protected.
The _protected suffix follows counter(9).
Notes
Notes: svn path=/head/; revision=357672
Diffstat (limited to 'sys/sys/pcpu.h')
-rw-r--r--sys/sys/pcpu.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/sys/sys/pcpu.h b/sys/sys/pcpu.h
index afccd9ec26f2..f859d09554c0 100644
--- a/sys/sys/pcpu.h
+++ b/sys/sys/pcpu.h
@@ -256,6 +256,24 @@ extern struct pcpu *cpuid_to_pcpu[];
_old; \
})
+#define zpcpu_set_protected(base, val) ({ \
+ MPASS(curthread->td_critnest > 0); \
+ __typeof(val) *_ptr = zpcpu_get(base); \
+ *_ptr = (val); \
+})
+
+#define zpcpu_add_protected(base, val) ({ \
+ MPASS(curthread->td_critnest > 0); \
+ __typeof(val) *_ptr = zpcpu_get(base); \
+ *_ptr += (val); \
+})
+
+#define zpcpu_sub_protected(base, val) ({ \
+ MPASS(curthread->td_critnest > 0); \
+ __typeof(val) *_ptr = zpcpu_get(base); \
+ *_ptr -= (val); \
+})
+
/*
* Machine dependent callouts. cpu_pcpu_init() is responsible for
* initializing machine dependent fields of struct pcpu, and