-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatomic.js
43 lines (40 loc) · 1.12 KB
/
atomic.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const {
e,
l,
Struct,
push_export
} = require('./api');
e.SDL_atomic_t = Struct({
value: 'int'
});
e.SDL_AtomicIncRef = function(a) {
return l.SDL_AtomicAdd(a, 1);
}
e.SDL_AtomicDecRef = function(a) {
return l.SDL_AtomicAdd(a, -1) == 1;
}
e.SDL_CompilerBarrier = function() {
var tmp = 0;
l.SDL_AtomicLock(tmp);
return l.SDL_AtomicUnlock(tmp);
}
e.SDL_MemoryBarrierRelease = function() {
return l.SDL_MemoryBarrierReleaseFunction();
}
e.SDL_MemoryBarrierAcquire = function() {
return l.SDL_MemoryBarrierAcquireFunction();
}
push_export({
'SDL_AtomicTryLock': ['int', ['int*']],
'SDL_AtomicLock': ['void', ['int*']],
'SDL_AtomicUnlock': ['void', ['int*']],
'SDL_MemoryBarrierReleaseFunction': ['void', []],
'SDL_MemoryBarrierAcquireFunction': ['void', []],
'SDL_AtomicCAS': ['int', ['void*', 'int', 'int']],
'SDL_AtomicSet': ['void', ['void*', 'int']],
'SDL_AtomicGet': ['void', ['void*']],
'SDL_AtomicAdd': ['void', ['void*', 'int']],
'SDL_AtomicCASPtr': ['int', ['void**', 'void*', 'void*']],
'SDL_AtomicSetPtr': ['void*', ['void**', 'void*']],
'SDL_AtomicGetPtr': ['void*', ['void**']]
});