@@ -104,7 +104,7 @@ CF_EXTERN_C_BEGIN
104
104
#include < stdatomic.h>
105
105
#include < Block.h>
106
106
107
- #if TARGET_OS_MAC || TARGET_OS_LINUX || TARGET_OS_BSD
107
+ #if TARGET_OS_MAC || TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_WASI
108
108
109
109
#if TARGET_OS_MAC || (TARGET_OS_BSD && !defined(__OpenBSD__)) || TARGET_OS_ANDROID
110
110
#include < xlocale.h>
@@ -113,7 +113,7 @@ CF_EXTERN_C_BEGIN
113
113
#include < sys/time.h>
114
114
#include < signal.h>
115
115
#include < stdio.h>
116
- #endif // TARGET_OS_MAC || TARGET_OS_LINUX || TARGET_OS_BSD
116
+ #endif // TARGET_OS_MAC || TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_WASI
117
117
118
118
#if __has_include(<unistd.h>)
119
119
#include < unistd.h>
@@ -317,10 +317,18 @@ static inline void __CFRuntimeSetValue(CFTypeRef cf, uint8_t n1, uint8_t n2, uin
317
317
__CFInfoType info = atomic_load (&(((CFRuntimeBase *)cf)->_cfinfoa ));
318
318
__CFInfoType newInfo;
319
319
__CFInfoType mask = __CFInfoMask (n1, n2);
320
+
321
+ #if !TARGET_OS_WASI
320
322
do {
323
+ #endif
321
324
// maybe don't need to do the negation part because the right side promises that we are not going to touch the rest of the word
322
325
newInfo = (info & ~mask) | ((x << n2) & mask);
326
+ // Atomics are not supported on WASI, see https://bugs.swift.org/browse/SR-12097 for more details
327
+ #if !TARGET_OS_WASI
323
328
} while (!atomic_compare_exchange_weak (&(((CFRuntimeBase *)cf)->_cfinfoa ), &info, newInfo));
329
+ #else
330
+ ((CFRuntimeBase *)cf)->_cfinfoa = newInfo;
331
+ #endif
324
332
}
325
333
326
334
// / Set a flag in a CFTypeRef info bitfield.
@@ -1024,7 +1032,7 @@ CF_INLINE const char *CFPathRelativeToAppleFrameworksRoot(const char *path, Bool
1024
1032
enum {
1025
1033
DISPATCH_QUEUE_OVERCOMMIT = 0x2ull ,
1026
1034
};
1027
- #endif
1035
+ #endif // __has_include(<dispatch/private.h>)
1028
1036
1029
1037
#if TARGET_OS_LINUX || TARGET_OS_WIN32
1030
1038
#define QOS_CLASS_USER_INITIATED DISPATCH_QUEUE_PRIORITY_HIGH
@@ -1040,7 +1048,7 @@ CF_INLINE long qos_class_self() {
1040
1048
return QOS_CLASS_DEFAULT ;
1041
1049
}
1042
1050
1043
- #endif
1051
+ #endif // TARGET_OS_LINUX || TARGET_OS_WIN32
1044
1052
1045
1053
// Returns a generic dispatch queue for when you want to just throw some work
1046
1054
// into the concurrent pile to execute, and don't care about specifics except
@@ -1064,12 +1072,13 @@ CF_INLINE dispatch_queue_t __CFDispatchQueueGetGenericBackground(void) {
1064
1072
return dispatch_get_global_queue (QOS_CLASS_UTILITY , DISPATCH_QUEUE_OVERCOMMIT);
1065
1073
}
1066
1074
1067
- #endif
1075
+ CF_PRIVATE dispatch_data_t _CFDataCreateDispatchData (CFDataRef data); // avoids copying in most cases
1076
+
1077
+ #endif // __HAS_DISPATCH__
1068
1078
1069
1079
CF_PRIVATE CFStringRef _CFStringCopyBundleUnloadingProtectedString (CFStringRef str);
1070
1080
1071
1081
CF_PRIVATE uint8_t *_CFDataGetBytePtrNonObjC (CFDataRef data);
1072
- CF_PRIVATE dispatch_data_t _CFDataCreateDispatchData (CFDataRef data); // avoids copying in most cases
1073
1082
1074
1083
// Use this for functions that are intended to be breakpoint hooks. If you do not, the compiler may optimize them away.
1075
1084
// Based on: BREAKPOINT_FUNCTION in objc-os.h
0 commit comments