aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/pcpu.h
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2020-02-12 11:14:23 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2020-02-12 11:14:23 +0000
commitbee115bc59bb89662fb0a45b4787fc54b2d37a08 (patch)
treec3e311925c0744696aa29ce5793c1f6201f0e73f /sys/sys/pcpu.h
parentfb886947d97375ea9906fa1396f83573b6d0674b (diff)
downloadsrc-bee115bc59bb89662fb0a45b4787fc54b2d37a08.tar.gz
src-bee115bc59bb89662fb0a45b4787fc54b2d37a08.zip
Dedup zpcpu assertions into one macro and guard the rest with #ifndef
Sponsored by: The FreeBSD Foundation
Notes
Notes: svn path=/head/; revision=357806
Diffstat (limited to 'sys/sys/pcpu.h')
-rw-r--r--sys/sys/pcpu.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/sys/sys/pcpu.h b/sys/sys/pcpu.h
index 954fba8507e2..43827b1af4fa 100644
--- a/sys/sys/pcpu.h
+++ b/sys/sys/pcpu.h
@@ -228,6 +228,10 @@ extern struct pcpu *cpuid_to_pcpu[];
#endif
#define curproc (curthread->td_proc)
+#ifndef ZPCPU_ASSERT_PROTECTED
+#define ZPCPU_ASSERT_PROTECTED() MPASS(curthread->td_critnest > 0)
+#endif
+
#ifndef zpcpu_offset_cpu
#define zpcpu_offset_cpu(cpu) (UMA_PCPU_ALLOC_SIZE * cpu)
#endif
@@ -277,26 +281,32 @@ extern struct pcpu *cpuid_to_pcpu[];
_old; \
})
+#ifndef zpcpu_set_protected
#define zpcpu_set_protected(base, val) ({ \
- MPASS(curthread->td_critnest > 0); \
+ ZPCPU_ASSERT_PROTECTED(); \
__typeof(val) *_ptr = zpcpu_get(base); \
\
*_ptr = (val); \
})
+#endif
+#ifndef zpcpu_add_protected
#define zpcpu_add_protected(base, val) ({ \
- MPASS(curthread->td_critnest > 0); \
+ ZPCPU_ASSERT_PROTECTED(); \
__typeof(val) *_ptr = zpcpu_get(base); \
\
*_ptr += (val); \
})
+#endif
+#ifndef zpcpu_sub_protected
#define zpcpu_sub_protected(base, val) ({ \
- MPASS(curthread->td_critnest > 0); \
+ ZPCPU_ASSERT_PROTECTED(); \
__typeof(val) *_ptr = zpcpu_get(base); \
\
*_ptr -= (val); \
})
+#endif
/*
* Machine dependent callouts. cpu_pcpu_init() is responsible for