diff options
author | Quentin Young <qlyoung@cumulusnetworks.com> | 2018-02-28 22:11:42 +0100 |
---|---|---|
committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2018-02-28 22:50:49 +0100 |
commit | f765d422d1b54f51d3735dcc584efd714007f6e2 (patch) | |
tree | 95d5c5d84eda6c6113f6ff16e03cf74c8bc34621 /lib/zebra.h | |
parent | Merge pull request #1805 from donaldsharp/recursion (diff) | |
download | frr-f765d422d1b54f51d3735dcc584efd714007f6e2.tar.xz frr-f765d422d1b54f51d3735dcc584efd714007f6e2.zip |
lib: add atomic bitwise OR, AND
* Add support for C11 bitwise OR & AND operations
* Add atomic versions of bitfield macros
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib/zebra.h')
-rw-r--r-- | lib/zebra.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/zebra.h b/lib/zebra.h index 11bf764b6..e592118f6 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; |