103
103
104
104
#ifdef CONFIG_ATOMICS
105
105
#include <pthread.h>
106
- #include <stdatomic.h>
106
+ #include "quickjs-c-atomics.h"
107
107
#include <errno.h>
108
108
#endif
109
109
@@ -50454,16 +50454,16 @@ static JSValue js_atomics_op(JSContext *ctx,
50454
50454
50455
50455
#define OP(op_name, func_name) \
50456
50456
case ATOMICS_OP_ ## op_name | (0 << 3): \
50457
- a = func_name((_Atomic( uint8_t) *)ptr, v); \
50457
+ a = func_name((_Atomic uint8_t *)ptr, v); \
50458
50458
break; \
50459
50459
case ATOMICS_OP_ ## op_name | (1 << 3): \
50460
- a = func_name((_Atomic( uint16_t) *)ptr, v); \
50460
+ a = func_name((_Atomic uint16_t *)ptr, v); \
50461
50461
break; \
50462
50462
case ATOMICS_OP_ ## op_name | (2 << 3): \
50463
- a = func_name((_Atomic( uint32_t) *)ptr, v); \
50463
+ a = func_name((_Atomic uint32_t *)ptr, v); \
50464
50464
break; \
50465
50465
case ATOMICS_OP_ ## op_name | (3 << 3): \
50466
- a = func_name((_Atomic( uint64_t) *)ptr, v); \
50466
+ a = func_name((_Atomic uint64_t *)ptr, v); \
50467
50467
break;
50468
50468
OP(ADD, atomic_fetch_add)
50469
50469
OP(AND, atomic_fetch_and)
@@ -50474,42 +50474,42 @@ static JSValue js_atomics_op(JSContext *ctx,
50474
50474
#undef OP
50475
50475
50476
50476
case ATOMICS_OP_LOAD | (0 << 3):
50477
- a = atomic_load((_Atomic( uint8_t) *)ptr);
50477
+ a = atomic_load((_Atomic uint8_t *)ptr);
50478
50478
break;
50479
50479
case ATOMICS_OP_LOAD | (1 << 3):
50480
- a = atomic_load((_Atomic( uint16_t) *)ptr);
50480
+ a = atomic_load((_Atomic uint16_t *)ptr);
50481
50481
break;
50482
50482
case ATOMICS_OP_LOAD | (2 << 3):
50483
- a = atomic_load((_Atomic( uint32_t) *)ptr);
50483
+ a = atomic_load((_Atomic uint32_t *)ptr);
50484
50484
break;
50485
50485
case ATOMICS_OP_LOAD | (3 << 3):
50486
- a = atomic_load((_Atomic( uint64_t) *)ptr);
50486
+ a = atomic_load((_Atomic uint64_t *)ptr);
50487
50487
break;
50488
50488
case ATOMICS_OP_COMPARE_EXCHANGE | (0 << 3):
50489
50489
{
50490
50490
uint8_t v1 = v;
50491
- atomic_compare_exchange_strong((_Atomic( uint8_t) *)ptr, &v1, rep_val);
50491
+ atomic_compare_exchange_strong((_Atomic uint8_t *)ptr, &v1, rep_val);
50492
50492
a = v1;
50493
50493
}
50494
50494
break;
50495
50495
case ATOMICS_OP_COMPARE_EXCHANGE | (1 << 3):
50496
50496
{
50497
50497
uint16_t v1 = v;
50498
- atomic_compare_exchange_strong((_Atomic( uint16_t) *)ptr, &v1, rep_val);
50498
+ atomic_compare_exchange_strong((_Atomic uint16_t *)ptr, &v1, rep_val);
50499
50499
a = v1;
50500
50500
}
50501
50501
break;
50502
50502
case ATOMICS_OP_COMPARE_EXCHANGE | (2 << 3):
50503
50503
{
50504
50504
uint32_t v1 = v;
50505
- atomic_compare_exchange_strong((_Atomic( uint32_t) *)ptr, &v1, rep_val);
50505
+ atomic_compare_exchange_strong((_Atomic uint32_t *)ptr, &v1, rep_val);
50506
50506
a = v1;
50507
50507
}
50508
50508
break;
50509
50509
case ATOMICS_OP_COMPARE_EXCHANGE | (3 << 3):
50510
50510
{
50511
50511
uint64_t v1 = v;
50512
- atomic_compare_exchange_strong((_Atomic( uint64_t) *)ptr, &v1, rep_val);
50512
+ atomic_compare_exchange_strong((_Atomic uint64_t *)ptr, &v1, rep_val);
50513
50513
a = v1;
50514
50514
}
50515
50515
break;
@@ -50573,7 +50573,7 @@ static JSValue js_atomics_store(JSContext *ctx,
50573
50573
}
50574
50574
if (abuf->detached)
50575
50575
return JS_ThrowTypeErrorDetachedArrayBuffer(ctx);
50576
- atomic_store((_Atomic( uint64_t) *)ptr, v64);
50576
+ atomic_store((_Atomic uint64_t *)ptr, v64);
50577
50577
} else {
50578
50578
uint32_t v;
50579
50579
/* XXX: spec, would be simpler to return the written value */
@@ -50588,13 +50588,13 @@ static JSValue js_atomics_store(JSContext *ctx,
50588
50588
return JS_ThrowTypeErrorDetachedArrayBuffer(ctx);
50589
50589
switch(size_log2) {
50590
50590
case 0:
50591
- atomic_store((_Atomic( uint8_t) *)ptr, v);
50591
+ atomic_store((_Atomic uint8_t *)ptr, v);
50592
50592
break;
50593
50593
case 1:
50594
- atomic_store((_Atomic( uint16_t) *)ptr, v);
50594
+ atomic_store((_Atomic uint16_t *)ptr, v);
50595
50595
break;
50596
50596
case 2:
50597
- atomic_store((_Atomic( uint32_t) *)ptr, v);
50597
+ atomic_store((_Atomic uint32_t *)ptr, v);
50598
50598
break;
50599
50599
default:
50600
50600
abort();
0 commit comments