]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: threads: add a portable barrier for threads and non-threads
authorWilly Tarreau <w@1wt.eu>
Tue, 31 Oct 2017 17:00:20 +0000 (18:00 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 31 Oct 2017 17:01:18 +0000 (18:01 +0100)
HA_BARRIER() is just a simple memory barrier to prevent the compiler
from reordering our code.

include/common/hathreads.h

index 25c1737e1e52d5e3b6d2b9820e545139a1e58097..3524ef189c7b5ff31857ab76f9a2f6f2d33c43e2 100644 (file)
@@ -60,6 +60,7 @@ extern THREAD_LOCAL unsigned int tid_bit; /* The bit corresponding to the thread
                *(val);                                                 \
        })
 
+#define HA_BARRIER() do { } while (0)
 
 #define THREAD_SYNC_INIT(m)  do { /* do nothing */ } while(0)
 #define THREAD_SYNC_ENABLE() do { /* do nothing */ } while(0)
@@ -118,6 +119,8 @@ extern THREAD_LOCAL unsigned int tid_bit; /* The bit corresponding to the thread
                (*val);                                                 \
        })
 
+#define HA_BARRIER() pl_barrier()
+
 #define THREAD_SYNC_INIT(m)   thread_sync_init(m)
 #define THREAD_SYNC_ENABLE()  thread_sync_enable()
 #define THREAD_WANT_SYNC()    thread_want_sync()