Skip to content

Commit 6a0a3d1

Browse files
authored
bson_atomic_int32_fetch_add uses a header declared type for the int32_t argument (#1250)
* DECL_ATOMIC_INTEGRAL_INT32 for bson-context.c and bson-atomic.c * Default DECL_ATOMIC_INTEGRAL_INT32 to int32_t
1 parent b9ca36f commit 6a0a3d1

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/libbson/src/bson/bson-atomic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
int32_t
2626
bson_atomic_int_add (volatile int32_t *p, int32_t n)
2727
{
28-
return n + bson_atomic_int32_fetch_add (p, n, bson_memory_order_seq_cst);
28+
return n + bson_atomic_int32_fetch_add ((DECL_ATOMIC_INTEGRAL_INT32 *) p, n, bson_memory_order_seq_cst);
2929
}
3030

3131
int64_t

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,10 @@ DECL_ATOMIC_INTEGRAL (int, int, )
380380
#endif
381381
#endif
382382

383+
#ifndef DECL_ATOMIC_INTEGRAL_INT32
384+
#define DECL_ATOMIC_INTEGRAL_INT32 int32_t
385+
#endif
386+
383387
BSON_EXPORT (int64_t)
384388
_bson_emul_atomic_int64_fetch_add (int64_t volatile *val,
385389
int64_t v,

src/libbson/src/bson/bson-context.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ _bson_context_set_oid_seq32 (bson_context_t *context, /* IN */
6262
bson_oid_t *oid) /* OUT */
6363
{
6464
uint32_t seq = (uint32_t) bson_atomic_int32_fetch_add (
65-
(int32_t *) &context->seq32, 1, bson_memory_order_seq_cst);
65+
(DECL_ATOMIC_INTEGRAL_INT32 *) &context->seq32, 1, bson_memory_order_seq_cst);
6666
seq = BSON_UINT32_TO_BE (seq);
6767
memcpy (&oid->bytes[BSON_OID_SEQ32_OFFSET],
6868
((uint8_t *) &seq) + 1,

0 commit comments

Comments
 (0)