summaryrefslogtreecommitdiff
path: root/lib/zebra.h
diff options
context:
space:
mode:
authorRenato Westphal <renato@openbsd.org>2018-03-09 11:25:37 -0300
committerGitHub <noreply@github.com>2018-03-09 11:25:37 -0300
commitc67667e74cfbb4e4f2edd3b70609cf9716d5c432 (patch)
treec3fc590ec00266221903856031435be68b4087ca /lib/zebra.h
parent2aedb75283aa2564e16ad700bb3da121af5930aa (diff)
parentaea03ad6e8198a91578f550cb0c835020e673031 (diff)
Merge pull request #1808 from qlyoung/debug-mt-safe
MT-safe debug facilities
Diffstat (limited to 'lib/zebra.h')
-rw-r--r--lib/zebra.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/zebra.h b/lib/zebra.h
index df367bd27b..262ad2e43d 100644
--- a/lib/zebra.h
+++ b/lib/zebra.h
@@ -481,6 +481,16 @@ typedef enum {
#define UNSET_FLAG(V,F) (V) &= ~(F)
#define RESET_FLAG(V) (V) = 0
+/* Atomic flag manipulation macros. */
+#define CHECK_FLAG_ATOMIC(PV, F) \
+ ((atomic_load_explicit(PV, memory_order_seq_cst)) & (F))
+#define SET_FLAG_ATOMIC(PV, F) \
+ ((atomic_fetch_or_explicit(PV, (F), memory_order_seq_cst)))
+#define UNSET_FLAG_ATOMIC(PV, F) \
+ ((atomic_fetch_and_explicit(PV, ~(F), memory_order_seq_cst)))
+#define RESET_FLAG_ATOMIC(PV) \
+ ((atomic_store_explicit(PV, 0, memory_order_seq_cst)))
+
/* Zebra types. Used in Zserv message header. */
typedef u_int16_t zebra_size_t;
typedef u_int16_t zebra_command_t;