@@ -1278,7 +1278,7 @@ CF_PRIVATE int _NS_gettimeofday(struct timeval *tv, struct timezone *tz) {
12781278#pragma mark -
12791279#pragma mark Linux OSAtomic
12801280
1281- #if TARGET_OS_LINUX || TARGET_OS_BSD
1281+ #if TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_WASI
12821282
12831283bool OSAtomicCompareAndSwapPtr (void * oldp , void * newp , void * volatile * dst )
12841284{
@@ -1337,72 +1337,7 @@ void OSMemoryBarrier() {
13371337 __sync_synchronize ();
13381338}
13391339
1340- #elif TARGET_OS_WASI
1341-
1342- bool OSAtomicCompareAndSwapPtr (void * oldp , void * newp , void * volatile * dst ) {
1343- if (* dst == oldp ) {
1344- * dst = newp ;
1345- return true;
1346- }
1347- return false;
1348- }
1349-
1350- bool OSAtomicCompareAndSwapLong (long oldl , long newl , long volatile * dst ) {
1351- if (* dst == oldl ) {
1352- * dst = newl ;
1353- return true;
1354- }
1355- return false;
1356- }
1357-
1358- bool OSAtomicCompareAndSwapPtrBarrier (void * oldp , void * newp , void * volatile * dst ) {
1359- return OSAtomicCompareAndSwapPtr (oldp , newp , dst );
1360- }
1361-
1362- int32_t OSAtomicAdd32Barrier (int32_t theAmount , volatile int32_t * theValue ) {
1363- * theValue += theAmount ;
1364- return theValue ;
1365- }
1366-
1367- bool OSAtomicCompareAndSwap32Barrier (int32_t oldValue , int32_t newValue , volatile int32_t * theValue ) {
1368- if (* theValue == oldValue ) {
1369- * theValue = newValue ;
1370- return true;
1371- }
1372- return false;
1373- }
1374-
1375- bool OSAtomicCompareAndSwap64Barrier (int64_t oldValue , int64_t newValue , volatile int64_t * theValue ) {
1376- if (* theValue == oldValue ) {
1377- * theValue = newValue ;
1378- return true;
1379- }
1380- return false;
1381- }
1382-
1383- int32_t OSAtomicDecrement32Barrier (volatile int32_t * dst ) {
1384- return OSAtomicAdd32Barrier (-1 , dst );
1385- }
1386-
1387- int32_t OSAtomicIncrement32Barrier (volatile int32_t * dst ) {
1388- return OSAtomicAdd32Barrier (1 , dst );
1389- }
1390-
1391- int32_t OSAtomicAdd32 ( int32_t theAmount , volatile int32_t * theValue ) {
1392- return OSAtomicAdd32Barrier (theAmount , theValue );
1393- }
1394-
1395- int32_t OSAtomicIncrement32 (volatile int32_t * theValue ) {
1396- return OSAtomicIncrement32Barrier (theValue );
1397- }
1398-
1399- int32_t OSAtomicDecrement32 (volatile int32_t * theValue ) {
1400- return OSAtomicDecrement32Barrier (theValue );
1401- }
1402-
1403- void OSMemoryBarrier () {}
1404-
1405- #endif // TARGET_OS_LINUX
1340+ #endif // TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_WASI
14061341
14071342#pragma mark -
14081343#pragma mark Dispatch Replacements
0 commit comments