Skip to content

Commit b6bec73

Browse files
authored
SWIFT-1419 Vendor libmongoc 1.21.0 (#732)
1 parent 07ad20f commit b6bec73

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1938
-930
lines changed

Sources/CLibMongoC/bson/bson-atomic.c

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ _bson_emul_atomic_int32_compare_exchange_weak (volatile int32_t *p,
195195

196196
int
197197
_bson_emul_atomic_int_fetch_add (volatile int *p,
198-
int n,
199-
enum bson_memory_order _unused)
198+
int n,
199+
enum bson_memory_order _unused)
200200
{
201201
int ret;
202202
_lock_emul_atomic ();
@@ -208,8 +208,8 @@ _bson_emul_atomic_int_fetch_add (volatile int *p,
208208

209209
int
210210
_bson_emul_atomic_int_exchange (volatile int *p,
211-
int n,
212-
enum bson_memory_order _unused)
211+
int n,
212+
enum bson_memory_order _unused)
213213
{
214214
int ret;
215215
_lock_emul_atomic ();
@@ -221,9 +221,9 @@ _bson_emul_atomic_int_exchange (volatile int *p,
221221

222222
int
223223
_bson_emul_atomic_int_compare_exchange_strong (volatile int *p,
224-
int expect_value,
225-
int new_value,
226-
enum bson_memory_order _unused)
224+
int expect_value,
225+
int new_value,
226+
enum bson_memory_order _unused)
227227
{
228228
int ret;
229229
_lock_emul_atomic ();
@@ -237,11 +237,24 @@ _bson_emul_atomic_int_compare_exchange_strong (volatile int *p,
237237

238238
int
239239
_bson_emul_atomic_int_compare_exchange_weak (volatile int *p,
240-
int expect_value,
241-
int new_value,
242-
enum bson_memory_order order)
240+
int expect_value,
241+
int new_value,
242+
enum bson_memory_order order)
243243
{
244244
/* We're emulating. We can't do a weak version. */
245245
return _bson_emul_atomic_int_compare_exchange_strong (
246246
p, expect_value, new_value, order);
247247
}
248+
249+
void *
250+
_bson_emul_atomic_ptr_exchange (void *volatile *p,
251+
void *n,
252+
enum bson_memory_order _unused)
253+
{
254+
void *ret;
255+
_lock_emul_atomic ();
256+
ret = *p;
257+
*p = n;
258+
_unlock_emul_atomic ();
259+
return ret;
260+
}

Sources/CLibMongoC/bson/bson-context-private.h

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,55 @@
2828
BSON_BEGIN_DECLS
2929

3030

31+
enum {
32+
BSON_OID_RANDOMESS_OFFSET = 4,
33+
BSON_OID_RANDOMNESS_SIZE = 5,
34+
BSON_OID_SEQ32_OFFSET = 9,
35+
BSON_OID_SEQ32_SIZE = 3,
36+
BSON_OID_SEQ64_OFFSET = 4,
37+
BSON_OID_SEQ64_SIZE = 8
38+
};
39+
3140
struct _bson_context_t {
3241
/* flags are defined in bson_context_flags_t */
3342
int flags;
34-
int32_t seq32;
35-
int64_t seq64;
36-
uint8_t rand[5];
37-
uint16_t pid;
38-
39-
void (*oid_set_seq32) (bson_context_t *context, bson_oid_t *oid);
40-
void (*oid_set_seq64) (bson_context_t *context, bson_oid_t *oid);
41-
42-
/* this function pointer allows us to mock gethostname for testing. */
43-
void (*gethostname) (char *out);
43+
uint32_t seq32;
44+
uint64_t seq64;
45+
uint8_t randomness[BSON_OID_RANDOMNESS_SIZE];
46+
uint64_t pid;
4447
};
4548

49+
/**
50+
* @brief Insert the context's randomness data into the given OID
51+
*
52+
* @param context A context for some random data
53+
* @param oid The OID to update.
54+
*/
4655
void
4756
_bson_context_set_oid_rand (bson_context_t *context, bson_oid_t *oid);
4857

58+
/**
59+
* @brief Insert the context's sequence counter into the given OID. Increments
60+
* the context's sequence counter.
61+
*
62+
* @param context The context with the counter to get+update
63+
* @param oid The OID to modify
64+
*/
65+
void
66+
_bson_context_set_oid_seq32 (bson_context_t *context, bson_oid_t *oid);
67+
68+
/**
69+
* @brief Write a 64-bit counter from the given context into the OID. Increments
70+
* the context's sequence counter.
71+
*
72+
* @param context The context with the counter to get+update
73+
* @param oid The OID to modify
74+
*
75+
* @note Only used by the deprecated @ref bson_oid_init_sequence
76+
*/
77+
void
78+
_bson_context_set_oid_seq64 (bson_context_t *context, bson_oid_t *oid);
79+
4980

5081
BSON_END_DECLS
5182

0 commit comments

Comments
 (0)