svn commit: r357806 - head/sys/sys
Mateusz Guzik
mjg at FreeBSD.org
Wed Feb 12 11:14:24 UTC 2020
Author: mjg
Date: Wed Feb 12 11:14:23 2020
New Revision: 357806
URL: https://svnweb.freebsd.org/changeset/base/357806
Log:
Dedup zpcpu assertions into one macro and guard the rest with #ifndef
Sponsored by: The FreeBSD Foundation
Modified:
head/sys/sys/pcpu.h
Modified: head/sys/sys/pcpu.h
==============================================================================
--- head/sys/sys/pcpu.h Wed Feb 12 11:12:13 2020 (r357805)
+++ head/sys/sys/pcpu.h Wed Feb 12 11:14:23 2020 (r357806)
@@ -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
More information about the svn-src-head
mailing list