Skip to content

Commit bdb0c16

Browse files
author
Micah Scott @ MongoDB
authored
CDRIVER-4220 redefine bson_sync_synchronize in terms of bson_atomic_thread_fence (#1773)
Previously, change 71475df redefined bson_sync_synchronize in terms of __sync_synchronize, avoiding obsolete conditionals and inline asm. It failed on the "public-header-warnings" build target when CC=clang, because all warnings are enabled including -Watomic-implicit-seq-cst. This change uses bson_atomic_thread_fence instead, which is both the simpler solution and it already includes an exception for the compiler warning. The previous patch was written in an attempt to avoid moving the public bson_sync_synchronize entry point from bson-compat to bson-atomic, but now I know the BSON_INSIDE include guard makes this distinction unnecessary.
1 parent 71475df commit bdb0c16

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/libbson/src/bson/bson-atomic.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,12 @@ bson_atomic_thread_fence (void)
641641
BSON_IF_GNU_LEGACY_ATOMICS (__sync_synchronize ();)
642642
}
643643

644+
static BSON_INLINE void BSON_GNUC_DEPRECATED
645+
bson_sync_synchronize (void)
646+
{
647+
bson_atomic_thread_fence ();
648+
}
649+
644650
#ifdef BSON_USE_LEGACY_GCC_ATOMICS
645651
#undef BSON_IF_GNU_LIKE
646652
#define BSON_IF_GNU_LIKE(...) __VA_ARGS__

src/libbson/src/bson/bson-compat.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,6 @@ typedef signed char bool;
203203
#define BSON_IF_POSIX(...) __VA_ARGS__
204204
#endif
205205

206-
static BSON_INLINE void BSON_GNUC_DEPRECATED
207-
bson_sync_synchronize (void)
208-
{
209-
BSON_IF_MSVC (MemoryBarrier ();)
210-
BSON_IF_GNU_LIKE (__sync_synchronize ();)
211-
}
212-
213206

214207
BSON_END_DECLS
215208

0 commit comments

Comments
 (0)