aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/_smr.h
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2020-03-07 00:55:46 +0000
committerMark Johnston <markj@FreeBSD.org>2020-03-07 00:55:46 +0000
commit3fba886874ff09c0404b9c417f3c75bb34c1060f (patch)
treeb1de2dcff2521f7375f24bb8dee3ac63312aed19 /sys/sys/_smr.h
parent6fda2c54da8409ccb35bdd0b2661c72dc2920a68 (diff)
downloadsrc-3fba886874ff09c0404b9c417f3c75bb34c1060f.tar.gz
src-3fba886874ff09c0404b9c417f3c75bb34c1060f.zip
Move SMR pointer type definition and access macros to smr_types.h.
The intent is to provide a header that can be included by other headers without introducing too much pollution. smr.h depends on various headers and will likely grow over time, but is less likely to be required by system headers. Rename SMR_TYPE_DECLARE() to SMR_POINTER(): - One might use SMR to protect more than just pointers; it could be used for resizeable arrays, for example, so TYPE seems too generic. - It is useful to be able to define anonymous SMR-protected pointer types and the _DECLARE suffix makes that look wrong. Reviewed by: jeff, mjg, rlibby Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D23988
Notes
Notes: svn path=/head/; revision=358728
Diffstat (limited to 'sys/sys/_smr.h')
-rw-r--r--sys/sys/_smr.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/sys/_smr.h b/sys/sys/_smr.h
index 834d912783f5..272bf8c07077 100644
--- a/sys/sys/_smr.h
+++ b/sys/sys/_smr.h
@@ -35,4 +35,16 @@ typedef uint32_t smr_seq_t;
typedef int32_t smr_delta_t;
typedef struct smr *smr_t;
+#define SMR_ENTERED(smr) \
+ (curthread->td_critnest != 0 && zpcpu_get((smr))->c_seq != SMR_SEQ_INVALID)
+
+#define SMR_ASSERT_ENTERED(smr) \
+ KASSERT(SMR_ENTERED(smr), ("Not in smr section"))
+
+#define SMR_ASSERT_NOT_ENTERED(smr) \
+ KASSERT(!SMR_ENTERED(smr), ("In smr section."));
+
+#define SMR_ASSERT(ex, fn) \
+ KASSERT((ex), (fn ": Assertion " #ex " failed at %s:%d", __FILE__, __LINE__))
+
#endif /* __SYS_SMR_H_ */