Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update libbson to 1.24.2 #47

Merged
merged 9 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 56 additions & 13 deletions src/bson/bson-atomic.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
int32_t
bson_atomic_int_add (volatile int32_t *p, int32_t n)
{
return n + bson_atomic_int32_fetch_add (p, n, bson_memory_order_seq_cst);
return n + bson_atomic_int32_fetch_add ((DECL_ATOMIC_INTEGRAL_INT32 *) p, n, bson_memory_order_seq_cst);
}

int64_t
Expand Down Expand Up @@ -54,7 +54,7 @@ bson_memory_barrier (void)
static int8_t gEmulAtomicLock = 0;

static void
_lock_emul_atomic ()
_lock_emul_atomic (void)
{
int i;
if (bson_atomic_int8_compare_exchange_weak (
Expand All @@ -78,7 +78,7 @@ _lock_emul_atomic ()
}

static void
_unlock_emul_atomic ()
_unlock_emul_atomic (void)
{
int64_t rv = bson_atomic_int8_exchange (
&gEmulAtomicLock, 0, bson_memory_order_release);
Expand All @@ -91,6 +91,9 @@ _bson_emul_atomic_int64_fetch_add (volatile int64_t *p,
enum bson_memory_order _unused)
{
int64_t ret;

BSON_UNUSED (_unused);

_lock_emul_atomic ();
ret = *p;
*p += n;
Expand All @@ -104,6 +107,9 @@ _bson_emul_atomic_int64_exchange (volatile int64_t *p,
enum bson_memory_order _unused)
{
int64_t ret;

BSON_UNUSED (_unused);

_lock_emul_atomic ();
ret = *p;
*p = n;
Expand All @@ -118,6 +124,9 @@ _bson_emul_atomic_int64_compare_exchange_strong (volatile int64_t *p,
enum bson_memory_order _unused)
{
int64_t ret;

BSON_UNUSED (_unused);

_lock_emul_atomic ();
ret = *p;
if (ret == expect_value) {
Expand Down Expand Up @@ -145,6 +154,9 @@ _bson_emul_atomic_int32_fetch_add (volatile int32_t *p,
enum bson_memory_order _unused)
{
int32_t ret;

BSON_UNUSED (_unused);

_lock_emul_atomic ();
ret = *p;
*p += n;
Expand All @@ -158,6 +170,9 @@ _bson_emul_atomic_int32_exchange (volatile int32_t *p,
enum bson_memory_order _unused)
{
int32_t ret;

BSON_UNUSED (_unused);

_lock_emul_atomic ();
ret = *p;
*p = n;
Expand All @@ -172,6 +187,9 @@ _bson_emul_atomic_int32_compare_exchange_strong (volatile int32_t *p,
enum bson_memory_order _unused)
{
int32_t ret;

BSON_UNUSED (_unused);

_lock_emul_atomic ();
ret = *p;
if (ret == expect_value) {
Expand All @@ -195,10 +213,13 @@ _bson_emul_atomic_int32_compare_exchange_weak (volatile int32_t *p,

int
_bson_emul_atomic_int_fetch_add (volatile int *p,
int n,
enum bson_memory_order _unused)
int n,
enum bson_memory_order _unused)
{
int ret;

BSON_UNUSED (_unused);

_lock_emul_atomic ();
ret = *p;
*p += n;
Expand All @@ -208,10 +229,13 @@ _bson_emul_atomic_int_fetch_add (volatile int *p,

int
_bson_emul_atomic_int_exchange (volatile int *p,
int n,
enum bson_memory_order _unused)
int n,
enum bson_memory_order _unused)
{
int ret;

BSON_UNUSED (_unused);

_lock_emul_atomic ();
ret = *p;
*p = n;
Expand All @@ -221,11 +245,14 @@ _bson_emul_atomic_int_exchange (volatile int *p,

int
_bson_emul_atomic_int_compare_exchange_strong (volatile int *p,
int expect_value,
int new_value,
enum bson_memory_order _unused)
int expect_value,
int new_value,
enum bson_memory_order _unused)
{
int ret;

BSON_UNUSED (_unused);

_lock_emul_atomic ();
ret = *p;
if (ret == expect_value) {
Expand All @@ -237,11 +264,27 @@ _bson_emul_atomic_int_compare_exchange_strong (volatile int *p,

int
_bson_emul_atomic_int_compare_exchange_weak (volatile int *p,
int expect_value,
int new_value,
enum bson_memory_order order)
int expect_value,
int new_value,
enum bson_memory_order order)
{
/* We're emulating. We can't do a weak version. */
return _bson_emul_atomic_int_compare_exchange_strong (
p, expect_value, new_value, order);
}

void *
_bson_emul_atomic_ptr_exchange (void *volatile *p,
void *n,
enum bson_memory_order _unused)
{
void *ret;

BSON_UNUSED (_unused);

_lock_emul_atomic ();
ret = *p;
*p = n;
_unlock_emul_atomic ();
return ret;
}
Loading
Loading