replace: add checks for atomic_thread_fence(memory_order_seq_cst) and add possible...
authorStefan Metzmacher <metze@samba.org>
Thu, 21 Jun 2018 12:17:35 +0000 (14:17 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 24 Jul 2018 15:38:26 +0000 (17:38 +0200)
commit5fa5764f30c47b46f12ceb7637985e8def0190ca
treedd339ab817291e511076a07bf86d8e9f4ece65e0
parent6f8c1b6736875d63c11f8630ecf1c8d3dcd70fc5
replace: add checks for atomic_thread_fence(memory_order_seq_cst) and add possible fallbacks

This implements a full memory barrier.
On ubuntu amd64 with results in an 'mfence' instruction.

This is required to syncronization between threads, where
there's typically only one write of a memory that should be
synced between all threads with the barrier.

Much more details can be found here:
https://gcc.gnu.org/onlinedocs/gcc-7.3.0/gcc/_005f_005fatomic-Builtins.html#g_t_005f_005fatomic-Builtins
https://gcc.gnu.org/onlinedocs/gcc-7.3.0/gcc/_005f_005fsync-Builtins.html#g_t_005f_005fsync-Builtins

The main one we use seems to be in C11 via stdatomic.h,
the oldest fallback is __sync_synchronize(), which is available
since 2005 in gcc.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
lib/replace/system/threads.h
lib/replace/wscript