|
18 | 18 | #include <CoreFoundation/CFPriv.h>
|
19 | 19 | #include "CFInternal.h"
|
20 | 20 | #include "CFLocaleInternal.h"
|
| 21 | +#if !TARGET_OS_WASI |
21 | 22 | #include "CFBundle_Internal.h"
|
| 23 | +#endif |
22 | 24 | #include <CoreFoundation/CFPriv.h>
|
23 | 25 | #if TARGET_OS_MAC || TARGET_OS_WIN32
|
24 | 26 | #include <CoreFoundation/CFBundle.h>
|
25 | 27 | #endif
|
26 | 28 | #include <CoreFoundation/CFURLAccess.h>
|
| 29 | +#if !TARGET_OS_WASI |
27 | 30 | #include <CoreFoundation/CFPropertyList.h>
|
| 31 | +#endif |
28 | 32 | #if TARGET_OS_WIN32
|
29 | 33 | #include <process.h>
|
30 | 34 | #endif
|
|
65 | 69 | #include <os/lock.h>
|
66 | 70 | #endif
|
67 | 71 |
|
68 |
| -#if TARGET_OS_LINUX || TARGET_OS_BSD |
| 72 | +#if TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_WASI |
69 | 73 | #include <string.h>
|
70 | 74 | #include <sys/mman.h>
|
71 | 75 | #endif
|
@@ -354,6 +358,7 @@ static CFDictionaryRef _CFCopyVersionDictionary(CFStringRef path) {
|
354 | 358 | return (CFDictionaryRef)plist;
|
355 | 359 | }
|
356 | 360 |
|
| 361 | +#if !TARGET_OS_WASI |
357 | 362 | CFStringRef _CFCopySystemVersionDictionaryValue(CFStringRef key) {
|
358 | 363 | CFStringRef versionString;
|
359 | 364 | CFDictionaryRef dict = _CFCopyServerVersionDictionary();
|
@@ -462,15 +467,13 @@ CONST_STRING_DECL(_kCFSystemVersionProductUserVisibleVersionKey, "ProductUserVis
|
462 | 467 | CONST_STRING_DECL(_kCFSystemVersionBuildVersionKey, "ProductBuildVersion")
|
463 | 468 | CONST_STRING_DECL(_kCFSystemVersionProductVersionStringKey, "Version")
|
464 | 469 | CONST_STRING_DECL(_kCFSystemVersionBuildStringKey, "Build")
|
| 470 | +#endif |
465 | 471 |
|
466 | 472 |
|
467 | 473 | CF_EXPORT Boolean _CFExecutableLinkedOnOrAfter(CFSystemVersion version) {
|
468 | 474 | return true;
|
469 | 475 | }
|
470 | 476 |
|
471 |
| - |
472 |
| - |
473 |
| - |
474 | 477 | #if TARGET_OS_OSX
|
475 | 478 | CF_PRIVATE void *__CFLookupCarbonCoreFunction(const char *name) {
|
476 | 479 | static void *image = NULL;
|
@@ -637,7 +640,8 @@ CF_INLINE BOOL _CFCanChangeEUIDs(void) {
|
637 | 640 | return true;
|
638 | 641 | #endif
|
639 | 642 | }
|
640 |
| - |
| 643 | + |
| 644 | +#if !TARGET_OS_WASI |
641 | 645 | typedef struct _ugids {
|
642 | 646 | uid_t _euid;
|
643 | 647 | uid_t _egid;
|
@@ -690,6 +694,7 @@ CF_EXPORT uid_t _CFGetEGID(void) {
|
690 | 694 | __CFGetUGIDs(NULL, &egid);
|
691 | 695 | return egid;
|
692 | 696 | }
|
| 697 | +#endif // !TARGET_OS_WASI |
693 | 698 |
|
694 | 699 | const char *_CFPrintForDebugger(const void *obj) {
|
695 | 700 | static char *result = NULL;
|
@@ -900,6 +905,9 @@ static void _populateBanner(char **banner, char **time, char **thread, int *bann
|
900 | 905 | #elif TARGET_OS_WIN32
|
901 | 906 | bannerLen = asprintf(banner, "%04d-%02d-%02d %02d:%02d:%02d.%03d %s[%d:%lx] ", year, month, day, hour, minute, second, ms, *_CFGetProgname(), getpid(), GetCurrentThreadId());
|
902 | 907 | asprintf(thread, "%lx", GetCurrentThreadId());
|
| 908 | +#elif TARGET_OS_WASI |
| 909 | + bannerLen = asprintf(banner, "%04d-%02d-%02d %02d:%02d:%02d.%03d [%x] ", year, month, day, hour, minute, second, ms, (unsigned int)pthread_self()); |
| 910 | + asprintf(thread, "%lx", pthread_self()); |
903 | 911 | #else
|
904 | 912 | bannerLen = asprintf(banner, "%04d-%02d-%02d %02d:%02d:%02d.%03d %s[%d:%x] ", year, month, day, hour, minute, second, ms, *_CFGetProgname(), getpid(), (unsigned int)pthread_self());
|
905 | 913 | asprintf(thread, "%lx", pthread_self());
|
@@ -1080,8 +1088,12 @@ CF_PRIVATE void _CFLogSimple(int32_t lev, char *format, ...) {
|
1080 | 1088 |
|
1081 | 1089 | void CFLog(int32_t lev, CFStringRef format, ...) {
|
1082 | 1090 | va_list args;
|
1083 |
| - va_start(args, format); |
| 1091 | + va_start(args, format); |
| 1092 | +#if TARGET_OS_WASI |
| 1093 | + _CFLogvEx3(NULL, NULL, NULL, NULL, lev, format, args, NULL); |
| 1094 | +#else |
1084 | 1095 | _CFLogvEx3(NULL, NULL, NULL, NULL, lev, format, args, __builtin_return_address(0));
|
| 1096 | +#endif |
1085 | 1097 | va_end(args);
|
1086 | 1098 | }
|
1087 | 1099 |
|
@@ -1333,7 +1345,7 @@ CF_PRIVATE Boolean _CFReadMappedFromFile(CFStringRef path, Boolean map, Boolean
|
1333 | 1345 | if (0LL == statBuf.st_size) {
|
1334 | 1346 | bytes = malloc(8); // don't return constant string -- it's freed!
|
1335 | 1347 | length = 0;
|
1336 |
| -#if TARGET_OS_MAC || TARGET_OS_LINUX || TARGET_OS_BSD |
| 1348 | +#if TARGET_OS_MAC || TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_WASI |
1337 | 1349 | } else if (map) {
|
1338 | 1350 | if((void *)-1 == (bytes = mmap(0, (size_t)statBuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0))) {
|
1339 | 1351 | int32_t savederrno = errno;
|
@@ -1628,7 +1640,7 @@ CF_EXPORT Boolean _CFExtensionIsValidToAppend(CFStringRef extension) {
|
1628 | 1640 | }
|
1629 | 1641 |
|
1630 | 1642 |
|
1631 |
| -#if DEPLOYMENT_RUNTIME_SWIFT |
| 1643 | +#if DEPLOYMENT_RUNTIME_SWIFT && !TARGET_OS_WASI |
1632 | 1644 |
|
1633 | 1645 | CFDictionaryRef __CFGetEnvironment() {
|
1634 | 1646 | static dispatch_once_t once = 0L;
|
@@ -1689,4 +1701,4 @@ int32_t __CFGetPid() {
|
1689 | 1701 | return getpid();
|
1690 | 1702 | }
|
1691 | 1703 |
|
1692 |
| -#endif |
| 1704 | +#endif // DEPLOYMENT_RUNTIME_SWIFT && !TARGET_OS_WASI |
0 commit comments