10
10
#include <inttypes.h>
11
11
#include <pthread.h>
12
12
#include <emscripten/html5.h>
13
+ #include <emscripten/atomic.h>
13
14
14
15
#ifdef __cplusplus
15
16
extern "C" {
@@ -31,86 +32,6 @@ int emscripten_num_logical_cores(void);
31
32
// 'emscripten_num_logical_cores()' to query the number of cores in the system.
32
33
void emscripten_force_num_logical_cores (int cores );
33
34
34
- // Atomically stores the given value to the memory location, and returns the
35
- // value that was there prior to the store.
36
- uint8_t emscripten_atomic_exchange_u8 (void /*uint8_t*/ * addr , uint8_t newVal );
37
- uint16_t emscripten_atomic_exchange_u16 (void /*uint16_t*/ * addr , uint16_t newVal );
38
- uint32_t emscripten_atomic_exchange_u32 (void /*uint32_t*/ * addr , uint32_t newVal );
39
- uint64_t emscripten_atomic_exchange_u64 (void /*uint64_t*/ * addr , uint64_t newVal ); // In asm.js/asm2wasm this is emulated with locks, very slow!
40
-
41
- // CAS returns the *old* value that was in the memory location before the
42
- // operation took place.
43
- // That is, if the return value when calling this function equals to 'oldVal',
44
- // then the operation succeeded, otherwise it was ignored.
45
- uint8_t emscripten_atomic_cas_u8 (void /*uint8_t*/ * addr , uint8_t oldVal , uint8_t newVal );
46
- uint16_t emscripten_atomic_cas_u16 (void /*uint16_t*/ * addr , uint16_t oldVal , uint16_t newVal );
47
- uint32_t emscripten_atomic_cas_u32 (void /*uint32_t*/ * addr , uint32_t oldVal , uint32_t newVal );
48
- // In Wasm, this is a native instruction. In asm.js this is emulated with locks,
49
- // very slow!
50
- uint64_t emscripten_atomic_cas_u64 (void /*uint64_t*/ * addr , uint64_t oldVal , uint64_t newVal );
51
-
52
- uint8_t emscripten_atomic_load_u8 (const void /*uint8_t*/ * addr );
53
- uint16_t emscripten_atomic_load_u16 (const void /*uint16_t*/ * addr );
54
- uint32_t emscripten_atomic_load_u32 (const void /*uint32_t*/ * addr );
55
- float emscripten_atomic_load_f32 (const void /*float*/ * addr );
56
- // In Wasm, this is a native instruction. In asm.js this is emulated with locks,
57
- // very slow!
58
- uint64_t emscripten_atomic_load_u64 (const void /*uint64_t*/ * addr );
59
- // In Wasm, this is a native instruction. In asm.js this is emulated with locks,
60
- // very slow!
61
- double emscripten_atomic_load_f64 (const void /*double*/ * addr );
62
-
63
- // Returns the value that was stored (i.e. 'val')
64
- uint8_t emscripten_atomic_store_u8 (void /*uint8_t*/ * addr , uint8_t val );
65
- uint16_t emscripten_atomic_store_u16 (void /*uint16_t*/ * addr , uint16_t val );
66
- uint32_t emscripten_atomic_store_u32 (void /*uint32_t*/ * addr , uint32_t val );
67
- float emscripten_atomic_store_f32 (void /*float*/ * addr , float val );
68
- // In Wasm, this is a native instruction. In asm.js this is emulated with locks,
69
- // very slow!
70
- uint64_t emscripten_atomic_store_u64 (void /*uint64_t*/ * addr , uint64_t val );
71
- // In Wasm, this is a native instruction. In asm.js this is emulated with locks,
72
- // very slow!
73
- double emscripten_atomic_store_f64 (void /*double*/ * addr , double val );
74
-
75
- void emscripten_atomic_fence (void );
76
-
77
- // Each of the functions below (add, sub, and, or, xor) return the value that
78
- // was in the memory location before the operation occurred.
79
- uint8_t emscripten_atomic_add_u8 (void /*uint8_t*/ * addr , uint8_t val );
80
- uint16_t emscripten_atomic_add_u16 (void /*uint16_t*/ * addr , uint16_t val );
81
- uint32_t emscripten_atomic_add_u32 (void /*uint32_t*/ * addr , uint32_t val );
82
- // In Wasm, this is a native instruction. In asm.js this is emulated with locks,
83
- // very slow!
84
- uint64_t emscripten_atomic_add_u64 (void /*uint64_t*/ * addr , uint64_t val );
85
-
86
- uint8_t emscripten_atomic_sub_u8 (void /*uint8_t*/ * addr , uint8_t val );
87
- uint16_t emscripten_atomic_sub_u16 (void /*uint16_t*/ * addr , uint16_t val );
88
- uint32_t emscripten_atomic_sub_u32 (void /*uint32_t*/ * addr , uint32_t val );
89
- // In Wasm, this is a native instruction. In asm.js this is emulated with locks,
90
- // very slow!
91
- uint64_t emscripten_atomic_sub_u64 (void /*uint64_t*/ * addr , uint64_t val );
92
-
93
- uint8_t emscripten_atomic_and_u8 (void /*uint8_t*/ * addr , uint8_t val );
94
- uint16_t emscripten_atomic_and_u16 (void /*uint16_t*/ * addr , uint16_t val );
95
- uint32_t emscripten_atomic_and_u32 (void /*uint32_t*/ * addr , uint32_t val );
96
- // In Wasm, this is a native instruction. In asm.js this is emulated with locks,
97
- // very slow!
98
- uint64_t emscripten_atomic_and_u64 (void /*uint64_t*/ * addr , uint64_t val );
99
-
100
- uint8_t emscripten_atomic_or_u8 (void /*uint8_t*/ * addr , uint8_t val );
101
- uint16_t emscripten_atomic_or_u16 (void /*uint16_t*/ * addr , uint16_t val );
102
- uint32_t emscripten_atomic_or_u32 (void /*uint32_t*/ * addr , uint32_t val );
103
- // In Wasm, this is a native instruction. In asm.js this is emulated with locks,
104
- // very slow!
105
- uint64_t emscripten_atomic_or_u64 (void /*uint64_t*/ * addr , uint64_t val );
106
-
107
- uint8_t emscripten_atomic_xor_u8 (void /*uint8_t*/ * addr , uint8_t val );
108
- uint16_t emscripten_atomic_xor_u16 (void /*uint16_t*/ * addr , uint16_t val );
109
- uint32_t emscripten_atomic_xor_u32 (void /*uint32_t*/ * addr , uint32_t val );
110
- // In Wasm, this is a native instruction. In asm.js this is emulated with locks,
111
- // very slow!
112
- uint64_t emscripten_atomic_xor_u64 (void /*uint64_t*/ * addr , uint64_t val );
113
-
114
35
// If the given memory address contains value val, puts the calling thread to
115
36
// sleep waiting for that address to be notified.
116
37
int emscripten_futex_wait (volatile void /*uint32_t*/ * addr , uint32_t val , double maxWaitMilliseconds );
0 commit comments