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
@@ -50106,16 +50106,16 @@ static JSValue js_atomics_op(JSContext *ctx,
50106
50106
50107
50107
#define OP(op_name, func_name) \
50108
50108
case ATOMICS_OP_ ## op_name | (0 << 3): \
50109
- a = func_name((_Atomic( uint8_t) *)ptr, v); \
50109
+ a = func_name((_Atomic uint8_t *)ptr, v); \
50110
50110
break; \
50111
50111
case ATOMICS_OP_ ## op_name | (1 << 3): \
50112
- a = func_name((_Atomic( uint16_t) *)ptr, v); \
50112
+ a = func_name((_Atomic uint16_t *)ptr, v); \
50113
50113
break; \
50114
50114
case ATOMICS_OP_ ## op_name | (2 << 3): \
50115
- a = func_name((_Atomic( uint32_t) *)ptr, v); \
50115
+ a = func_name((_Atomic uint32_t *)ptr, v); \
50116
50116
break; \
50117
50117
case ATOMICS_OP_ ## op_name | (3 << 3): \
50118
- a = func_name((_Atomic( uint64_t) *)ptr, v); \
50118
+ a = func_name((_Atomic uint64_t *)ptr, v); \
50119
50119
break;
50120
50120
OP(ADD, atomic_fetch_add)
50121
50121
OP(AND, atomic_fetch_and)
@@ -50126,42 +50126,42 @@ static JSValue js_atomics_op(JSContext *ctx,
50126
50126
#undef OP
50127
50127
50128
50128
case ATOMICS_OP_LOAD | (0 << 3):
50129
- a = atomic_load((_Atomic( uint8_t) *)ptr);
50129
+ a = atomic_load((_Atomic uint8_t *)ptr);
50130
50130
break;
50131
50131
case ATOMICS_OP_LOAD | (1 << 3):
50132
- a = atomic_load((_Atomic( uint16_t) *)ptr);
50132
+ a = atomic_load((_Atomic uint16_t *)ptr);
50133
50133
break;
50134
50134
case ATOMICS_OP_LOAD | (2 << 3):
50135
- a = atomic_load((_Atomic( uint32_t) *)ptr);
50135
+ a = atomic_load((_Atomic uint32_t *)ptr);
50136
50136
break;
50137
50137
case ATOMICS_OP_LOAD | (3 << 3):
50138
- a = atomic_load((_Atomic( uint64_t) *)ptr);
50138
+ a = atomic_load((_Atomic uint64_t *)ptr);
50139
50139
break;
50140
50140
case ATOMICS_OP_COMPARE_EXCHANGE | (0 << 3):
50141
50141
{
50142
50142
uint8_t v1 = v;
50143
- atomic_compare_exchange_strong((_Atomic( uint8_t) *)ptr, &v1, rep_val);
50143
+ atomic_compare_exchange_strong((_Atomic uint8_t *)ptr, &v1, rep_val);
50144
50144
a = v1;
50145
50145
}
50146
50146
break;
50147
50147
case ATOMICS_OP_COMPARE_EXCHANGE | (1 << 3):
50148
50148
{
50149
50149
uint16_t v1 = v;
50150
- atomic_compare_exchange_strong((_Atomic( uint16_t) *)ptr, &v1, rep_val);
50150
+ atomic_compare_exchange_strong((_Atomic uint16_t *)ptr, &v1, rep_val);
50151
50151
a = v1;
50152
50152
}
50153
50153
break;
50154
50154
case ATOMICS_OP_COMPARE_EXCHANGE | (2 << 3):
50155
50155
{
50156
50156
uint32_t v1 = v;
50157
- atomic_compare_exchange_strong((_Atomic( uint32_t) *)ptr, &v1, rep_val);
50157
+ atomic_compare_exchange_strong((_Atomic uint32_t *)ptr, &v1, rep_val);
50158
50158
a = v1;
50159
50159
}
50160
50160
break;
50161
50161
case ATOMICS_OP_COMPARE_EXCHANGE | (3 << 3):
50162
50162
{
50163
50163
uint64_t v1 = v;
50164
- atomic_compare_exchange_strong((_Atomic( uint64_t) *)ptr, &v1, rep_val);
50164
+ atomic_compare_exchange_strong((_Atomic uint64_t *)ptr, &v1, rep_val);
50165
50165
a = v1;
50166
50166
}
50167
50167
break;
@@ -50225,7 +50225,7 @@ static JSValue js_atomics_store(JSContext *ctx,
50225
50225
}
50226
50226
if (abuf->detached)
50227
50227
return JS_ThrowTypeErrorDetachedArrayBuffer(ctx);
50228
- atomic_store((_Atomic( uint64_t) *)ptr, v64);
50228
+ atomic_store((_Atomic uint64_t *)ptr, v64);
50229
50229
} else {
50230
50230
uint32_t v;
50231
50231
/* XXX: spec, would be simpler to return the written value */
@@ -50240,13 +50240,13 @@ static JSValue js_atomics_store(JSContext *ctx,
50240
50240
return JS_ThrowTypeErrorDetachedArrayBuffer(ctx);
50241
50241
switch(size_log2) {
50242
50242
case 0:
50243
- atomic_store((_Atomic( uint8_t) *)ptr, v);
50243
+ atomic_store((_Atomic uint8_t *)ptr, v);
50244
50244
break;
50245
50245
case 1:
50246
- atomic_store((_Atomic( uint16_t) *)ptr, v);
50246
+ atomic_store((_Atomic uint16_t *)ptr, v);
50247
50247
break;
50248
50248
case 2:
50249
- atomic_store((_Atomic( uint32_t) *)ptr, v);
50249
+ atomic_store((_Atomic uint32_t *)ptr, v);
50250
50250
break;
50251
50251
default:
50252
50252
abort();
0 commit comments