Skip to content

Add locking primitives for TARGET_OS_WASI in CFLocking.h #2867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CoreFoundation/Base.subproj/CFLocking.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,22 @@ typedef CFLock_t OSSpinLock;
#define OSSpinLockLock(lock) __CFLock(lock)
#define OSSpinLockUnlock(lock) __CFUnlock(lock)

#elif TARGET_OS_WASI

// Empty shims until https://bugs.swift.org/browse/SR-12097 is resolved.
typedef int32_t CFLock_t;
typedef CFLock_t OSSpinLock;
#define CFLockInit 0
#define CF_LOCK_INIT_FOR_STRUCTS(X) (X = CFLockInit)
#define OS_SPINLOCK_INIT CFLockInit

#define OSSpinLockLock(lock) __CFLock(lock)
#define OSSpinLockUnlock(lock) __CFUnlock(lock)
#define __CFLock(A) do {} while (0)
#define __CFUnlock(A) do {} while (0)

static inline CFLock_t __CFLockInit(void) { return CFLockInit; }

#else

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