From d0d8ba59d3334d51f9b9f3f8c1179747d2553564 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 18 Jul 2017 15:05:58 +0200 Subject: [PATCH] MINOR: threads/atomic: implement pl_bts() on non-x86 [ plock commit da17ba320aad3a8faf08e36fca604de9cad21fdd ] This one was missing, it can be done using sync_fetch_and_or(). --- include/import/atomic-ops.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/import/atomic-ops.h b/include/import/atomic-ops.h index f613a0ba1..dee0f8827 100644 --- a/include/import/atomic-ops.h +++ b/include/import/atomic-ops.h @@ -511,6 +511,9 @@ static inline void pl_mb() #define pl_or(ptr, x) ({ __sync_or_and_fetch((ptr), (x)); }) #define pl_xor(ptr, x) ({ __sync_xor_and_fetch((ptr), (x)); }) #define pl_sub(ptr, x) ({ __sync_sub_and_fetch((ptr), (x)); }) +#define pl_bts(ptr, bit) ({ typeof(*(ptr)) __pl_t = (1u << (bit)); \ + __sync_fetch_and_or((ptr), __pl_t) & __pl_t; \ + }) #define pl_xadd(ptr, x) ({ __sync_fetch_and_add((ptr), (x)); }) #define pl_cmpxchg(ptr, o, n) ({ __sync_val_compare_and_swap((ptr), (o), (n)); }) #define pl_xchg(ptr, x) ({ typeof(*(ptr)) __pl_t; \