File tree Expand file tree Collapse file tree 4 files changed +47
-13
lines changed Expand file tree Collapse file tree 4 files changed +47
-13
lines changed Original file line number Diff line number Diff line change @@ -169,19 +169,6 @@ typedef signed char bool;
169
169
#endif
170
170
171
171
172
- #if defined(__GNUC__ )
173
- #if (__GNUC__ > 4 ) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1 )
174
- #define bson_sync_synchronize () __sync_synchronize ()
175
- #elif defined(__i386__ ) || defined(__i486__ ) || defined(__i586__ ) || defined(__i686__ ) || defined(__x86_64__ )
176
- #define bson_sync_synchronize () asm volatile ("mfence" ::: "memory")
177
- #else
178
- #define bson_sync_synchronize () asm volatile ("sync" ::: "memory")
179
- #endif
180
- #elif defined(_MSC_VER )
181
- #define bson_sync_synchronize () MemoryBarrier ()
182
- #endif
183
-
184
-
185
172
#if !defined(va_copy ) && defined(__va_copy )
186
173
#define va_copy (dst , src ) __va_copy (dst, src)
187
174
#endif
@@ -216,6 +203,13 @@ typedef signed char bool;
216
203
#define BSON_IF_POSIX (...) __VA_ARGS__
217
204
#endif
218
205
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
+
219
213
220
214
BSON_END_DECLS
221
215
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2009-present MongoDB, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+
18
+ #include <bson/bson.h>
19
+ #include <common-macros-private.h> // BEGIN_IGNORE_DEPRECATIONS
20
+
21
+ #include "TestSuite.h"
22
+
23
+ static void
24
+ test_bson_sync_synchronize (void )
25
+ {
26
+ BEGIN_IGNORE_DEPRECATIONS
27
+
28
+ // This doesn't test for correct functionality, only that it exists and can be called
29
+ bson_sync_synchronize ();
30
+
31
+ END_IGNORE_DEPRECATIONS
32
+ }
33
+
34
+ void
35
+ test_bson_sync_install (TestSuite * suite )
36
+ {
37
+ TestSuite_Add (suite , "/bson/sync/synchronize" , test_bson_sync_synchronize );
38
+ }
Original file line number Diff line number Diff line change @@ -1040,6 +1040,7 @@ set (test-libmongoc-sources
1040
1040
${mongo-c-driver_SOURCE_DIR}/src/libbson/tests/test -bson-cmp.c
1041
1041
${mongo-c-driver_SOURCE_DIR}/src/libbson/tests/test -bson-corpus.c
1042
1042
${mongo-c-driver_SOURCE_DIR}/src/libbson/tests/test -bson-error.c
1043
+ ${mongo-c-driver_SOURCE_DIR}/src/libbson/tests/test -bson-sync.c
1043
1044
${mongo-c-driver_SOURCE_DIR}/src/libbson/tests/test -bson-version .c
1044
1045
${mongo-c-driver_SOURCE_DIR}/src/libbson/tests/test -bson.c
1045
1046
${mongo-c-driver_SOURCE_DIR}/src/libbson/tests/test -clock.c
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ main (int argc, char *argv[])
30
30
TEST_INSTALL (test_bson_corpus_install );
31
31
TEST_INSTALL (test_bson_error_install );
32
32
TEST_INSTALL (test_bson_install );
33
+ TEST_INSTALL (test_bson_sync_install );
33
34
TEST_INSTALL (test_bson_version_install );
34
35
TEST_INSTALL (test_clock_install );
35
36
TEST_INSTALL (test_decimal128_install );
You can’t perform that action at this time.
0 commit comments