Skip to content

Commit 76068b8

Browse files
authored
Merge pull request #2873 from apple/maxd/wasi-corefoundation-prefix
Add WASI support in CoreFoundation_Prefix.h
2 parents b1a6ce8 + d87855e commit 76068b8

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

CoreFoundation/Base.subproj/CoreFoundation_Prefix.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020

2121
#include <CoreFoundation/CFAvailability.h>
2222

23+
#if TARGET_OS_WASI
24+
#define __HAS_DISPATCH__ 0
25+
#else
2326
#define __HAS_DISPATCH__ 1
27+
#endif
2428

2529
#include <CoreFoundation/CFBase.h>
2630

@@ -193,7 +197,7 @@ typedef int boolean_t;
193197
#include <sys/stat.h> // mode_t
194198
#endif
195199

196-
#if TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_WIN32
200+
#if TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_WIN32 || TARGET_OS_WASI
197201
// Implemented in CFPlatform.c
198202
CF_EXPORT bool OSAtomicCompareAndSwapPtr(void *oldp, void *newp, void *volatile *dst);
199203
CF_EXPORT bool OSAtomicCompareAndSwapLong(long oldl, long newl, long volatile *dst);
@@ -227,9 +231,9 @@ CF_INLINE uint64_t mach_absolute_time() {
227231
}
228232

229233
#define malloc_default_zone() (void *)0
230-
#endif // TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_WIN32
234+
#endif // TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_WIN32 || TARGET_OS_WASI
231235

232-
#if TARGET_OS_LINUX || TARGET_OS_WIN32 || defined(__OpenBSD__)
236+
#if TARGET_OS_LINUX || TARGET_OS_WIN32 || defined(__OpenBSD__) || TARGET_OS_WASI
233237
#define strtod_l(a,b,locale) strtod(a,b)
234238
#define strtoul_l(a,b,c,locale) strtoul(a,b,c)
235239
#define strtol_l(a,b,c,locale) strtol(a,b,c)
@@ -244,17 +248,19 @@ CF_INLINE int flsl( long mask ) {
244248
}
245249
return idx;
246250
}
247-
#endif // TARGET_OS_LINUX || TARGET_OS_WIN32 || defined(__OpenBSD__)
251+
#endif // TARGET_OS_LINUX || TARGET_OS_WIN32 || defined(__OpenBSD__) || TARGET_OS_WASI
248252

249-
#if TARGET_OS_LINUX
253+
#if TARGET_OS_LINUX || TARGET_OS_WASI
250254

251255
#define CF_PRIVATE extern __attribute__((visibility("hidden")))
252256
#define __weak
253257

254258
#define strtoll_l(a,b,c,locale) strtoll(a,b,c)
255259
#define strncasecmp_l(a, b, c, d) strncasecmp(a, b, c)
256260

261+
#if !TARGET_OS_WASI
257262
#include <pthread.h>
263+
#endif
258264

259265
#if TARGET_OS_ANDROID
260266
typedef unsigned long fd_mask;

0 commit comments

Comments
 (0)