]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/frratomic.h
Merge pull request #2743 from donaldsharp/bgp_null_stuff
[mirror_frr.git] / lib / frratomic.h
index 4ae84c401833bd3b194dbf9c6f926579fcd81af5..689b25255d9e41428a32fc65f54475a45f7062f6 100644 (file)
@@ -46,6 +46,8 @@
 #define atomic_exchange_explicit __atomic_exchange_n
 #define atomic_fetch_add_explicit __atomic_fetch_add
 #define atomic_fetch_sub_explicit __atomic_fetch_sub
+#define atomic_fetch_and_explicit __atomic_fetch_and
+#define atomic_fetch_or_explicit __atomic_fetch_or
 
 #define atomic_compare_exchange_weak_explicit(atom, expect, desire, mem1,      \
                                              mem2)                            \
                *_expect = rval;                                               \
                ret;                                                           \
        })
+#define atomic_fetch_and_explicit(ptr, val, mem)                               \
+       ({                                                                     \
+               __sync_synchronize();                                          \
+               typeof(*ptr) rval = __sync_fetch_and_and(ptr, val);            \
+               __sync_synchronize();                                          \
+               rval;                                                          \
+       })
+#define atomic_fetch_or_explicit(ptr, val, mem)                                \
+       ({                                                                     \
+               __sync_synchronize();                                          \
+               typeof(*ptr) rval = __sync_fetch_and_or(ptr, val);             \
+               __sync_synchronize();                                          \
+               rval;                                                          \
+       })
 
 #else /* !HAVE___ATOMIC && !HAVE_STDATOMIC_H */
 #error no atomic functions...