Skip to content

Commit 7bfa2dc

Browse files
authored
Add locking primitives for TARGET_OS_WASI in CFLocking.h
WebAssembly/WASI doesn't support multi-threading yet, so these primitives don't do anything in this single-threaded environment, but allow the rest of the code using them to compile.
1 parent 20ee0e1 commit 7bfa2dc

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

CoreFoundation/Base.subproj/CFLocking.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,20 @@ typedef CFLock_t OSSpinLock;
9696
#define OSSpinLockLock(lock) __CFLock(lock)
9797
#define OSSpinLockUnlock(lock) __CFUnlock(lock)
9898

99+
#elif TARGET_OS_WASI
100+
typedef int32_t CFLock_t;
101+
typedef CFLock_t OSSpinLock;
102+
#define CFLockInit 0
103+
#define CF_LOCK_INIT_FOR_STRUCTS(X) (X = CFLockInit)
104+
#define OS_SPINLOCK_INIT CFLockInit
105+
106+
#define OSSpinLockLock(lock) __CFLock(lock)
107+
#define OSSpinLockUnlock(lock) __CFUnlock(lock)
108+
#define __CFLock(A) do {} while (0)
109+
#define __CFUnlock(A) do {} while (0)
110+
111+
static inline CFLock_t __CFLockInit(void) { return CFLockInit; }
112+
99113
#else
100114

101115
#warning CF locks not defined for this platform -- CF is not thread-safe

0 commit comments

Comments
 (0)