Skip to content

Commit 44031b5

Browse files
[wasm] Miscellanous Base.subproj fixes
* Remove too conservative include guards * Update class table to exclude unavailable classes * Port mach_absolute_time to WASI platform
1 parent 83634d0 commit 44031b5

File tree

6 files changed

+8
-17
lines changed

6 files changed

+8
-17
lines changed

CoreFoundation/Base.subproj/CFPriv.h

-2
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@
4646
#include <CoreFoundation/CFMessagePort.h>
4747
#endif
4848

49-
#if !TARGET_OS_WASI
5049
#include <CoreFoundation/CFRunLoop.h>
5150
#include <CoreFoundation/CFSocket.h>
52-
#endif
5351
#include <CoreFoundation/CFBundlePriv.h>
5452

5553

CoreFoundation/Base.subproj/CFRuntime.c

+2
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,14 @@ _CFClassTables __CFRuntimeClassTables __attribute__((aligned)) = {
239239

240240

241241

242+
#if !TARGET_OS_WASI
242243
[_kCFRuntimeIDCFRunLoopMode] = &__CFRunLoopModeClass,
243244
[_kCFRuntimeIDCFRunLoop] = &__CFRunLoopClass,
244245
[_kCFRuntimeIDCFRunLoopSource] = &__CFRunLoopSourceClass,
245246
[_kCFRuntimeIDCFRunLoopObserver] = &__CFRunLoopObserverClass,
246247
[_kCFRuntimeIDCFRunLoopTimer] = &__CFRunLoopTimerClass,
247248
[_kCFRuntimeIDCFSocket] = &__CFSocketClass,
249+
#endif
248250
[_kCFRuntimeIDCFReadStream] = &__CFReadStreamClass,
249251
[_kCFRuntimeIDCFWriteStream] = &__CFWriteStreamClass,
250252
[_kCFRuntimeIDCFAttributedString] = &__CFAttributedStringClass,

CoreFoundation/Base.subproj/CoreFoundation_Prefix.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ CF_INLINE uint64_t mach_absolute_time() {
260260
ULONGLONG ullTime;
261261
QueryUnbiasedInterruptTimePrecise(&ullTime);
262262
return ullTime;
263-
#elif TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_MAC
263+
#elif TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_MAC || TARGET_OS_WASI
264264
struct timespec ts;
265265
clock_gettime(CLOCK_MONOTONIC, &ts);
266266
return (uint64_t)ts.tv_nsec + (uint64_t)ts.tv_sec * 1000000000UL;

CoreFoundation/Base.subproj/ForFoundationOnly.h

-6
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@
2828
#include <CoreFoundation/CFBag.h>
2929
#include <CoreFoundation/CFCalendar.h>
3030

31-
#if !TARGET_OS_WASI
3231
#include <CoreFoundation/CFStreamPriv.h>
3332
#include <CoreFoundation/CFRuntime.h>
34-
#endif
3533
#include <math.h>
3634
#include <limits.h>
3735

@@ -102,7 +100,6 @@ CF_EXPORT BOOL _NSIsNSCFConstantString(NSISARGTYPE arg);
102100
CF_EXPORT BOOL _NSIsNSIndexSet(NSISARGTYPE arg);
103101
CF_EXPORT BOOL _NSIsNSAttributedString(NSISARGTYPE arg);
104102

105-
#if !TARGET_OS_WASI
106103
#pragma mark - CFBundle
107104

108105
#include <CoreFoundation/CFBundlePriv.h>
@@ -127,7 +124,6 @@ CF_EXPORT Boolean _CFBundleLoadExecutableAndReturnError(CFBundleRef bundle, Bool
127124
CF_EXPORT CFErrorRef _CFBundleCreateError(CFAllocatorRef _Nullable allocator, CFBundleRef bundle, CFIndex code);
128125

129126
_CF_EXPORT_SCOPE_END
130-
#endif
131127

132128
#pragma mark - CFUUID
133129

@@ -651,7 +647,6 @@ CF_CROSS_PLATFORM_EXPORT void _CFURLInitWithFileSystemPathRelativeToBase(CFURLRe
651647
CF_CROSS_PLATFORM_EXPORT Boolean _CFURLInitWithURLString(CFURLRef url, CFStringRef string, Boolean checkForLegalCharacters, _Nullable CFURLRef baseURL);
652648
CF_CROSS_PLATFORM_EXPORT Boolean _CFURLInitAbsoluteURLWithBytes(CFURLRef url, const UInt8 *relativeURLBytes, CFIndex length, CFStringEncoding encoding, _Nullable CFURLRef baseURL);
653649

654-
#if !TARGET_OS_WASI
655650
CF_EXPORT Boolean _CFRunLoopFinished(CFRunLoopRef rl, CFStringRef mode);
656651
CF_EXPORT CFTypeRef _CFRunLoopGet2(CFRunLoopRef rl);
657652
CF_EXPORT Boolean _CFRunLoopIsCurrent(CFRunLoopRef rl);
@@ -662,7 +657,6 @@ CF_EXPORT void _CFWriteStreamInitialize(CFWriteStreamRef writeStream);
662657
CF_EXPORT void _CFReadStreamDeallocate(CFReadStreamRef readStream);
663658
CF_EXPORT void _CFWriteStreamDeallocate(CFWriteStreamRef writeStream);
664659
CF_EXPORT CFReadStreamRef CFReadStreamCreateWithData(_Nullable CFAllocatorRef alloc, CFDataRef data);
665-
#endif
666660

667661
#if TARGET_OS_MAC
668662
typedef struct {

CoreFoundation/Base.subproj/ForSwiftFoundationOnly.h

+2-7
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
#include <termios.h>
6767
#elif TARGET_OS_WASI
6868
#include <fcntl.h>
69+
#include <sys/stat.h>
6970
// Define _WASI_EMULATED_MMAN here to use the emulated mman functions in
7071
// Foundation-side without requiring transitive clients to define it.
7172
#undef _WASI_EMULATED_MMAN
@@ -387,9 +388,7 @@ CF_PRIVATE uint64_t __CFMemorySize(void);
387388
CF_PRIVATE CFIndex __CFActiveProcessorCount(void);
388389
CF_CROSS_PLATFORM_EXPORT CFStringRef CFCopyFullUserName(void);
389390

390-
#if !TARGET_OS_WASI
391391
extern CFWriteStreamRef _CFWriteStreamCreateFromFileDescriptor(CFAllocatorRef alloc, int fd);
392-
#endif
393392

394393
#if !__COREFOUNDATION_FORFOUNDATIONONLY__
395394
typedef const struct __CFKeyedArchiverUID * CFKeyedArchiverUIDRef;
@@ -401,9 +400,7 @@ extern uint32_t _CFKeyedArchiverUIDGetValue(CFKeyedArchiverUIDRef uid);
401400
extern CFIndex __CFBinaryPlistWriteToStream(CFPropertyListRef plist, CFTypeRef stream);
402401
CF_CROSS_PLATFORM_EXPORT CFDataRef _CFPropertyListCreateXMLDataWithExtras(CFAllocatorRef allocator, CFPropertyListRef propertyList);
403402

404-
#if !TARGET_OS_WASI
405403
extern CFWriteStreamRef _CFWriteStreamCreateFromFileDescriptor(CFAllocatorRef alloc, int fd);
406-
#endif
407404

408405
CF_EXPORT char *_Nullable *_Nonnull _CFEnviron(void);
409406

@@ -451,7 +448,6 @@ CF_EXPORT CFCharacterSetRef _CFCharacterSetCreateCopy(CFAllocatorRef alloc, CFCh
451448
CF_EXPORT CFMutableCharacterSetRef _CFCharacterSetCreateMutableCopy(CFAllocatorRef alloc, CFCharacterSetRef theSet);
452449
CF_CROSS_PLATFORM_EXPORT void _CFCharacterSetInitCopyingSet(CFAllocatorRef alloc, CFMutableCharacterSetRef cset, CFCharacterSetRef theSet, bool isMutable, bool validateSubclasses);
453450

454-
#if !TARGET_OS_WASI
455451
CF_EXPORT _Nullable CFErrorRef CFReadStreamCopyError(CFReadStreamRef _Null_unspecified stream);
456452

457453
CF_EXPORT _Nullable CFErrorRef CFWriteStreamCopyError(CFWriteStreamRef _Null_unspecified stream);
@@ -460,7 +456,6 @@ CF_CROSS_PLATFORM_EXPORT CFStringRef _Nullable _CFBundleCopyExecutablePath(CFBun
460456
CF_CROSS_PLATFORM_EXPORT Boolean _CFBundleSupportsFHSBundles(void);
461457
CF_CROSS_PLATFORM_EXPORT Boolean _CFBundleSupportsFreestandingBundles(void);
462458
CF_CROSS_PLATFORM_EXPORT CFStringRef _Nullable _CFBundleCopyLoadedImagePathForAddress(const void *p);
463-
#endif
464459

465460
CF_CROSS_PLATFORM_EXPORT CFStringRef __CFTimeZoneCopyDataVersionString(void);
466461

@@ -566,7 +561,7 @@ CF_CROSS_PLATFORM_EXPORT CFIndex __CFCharDigitValue(UniChar ch);
566561

567562
#if TARGET_OS_WIN32
568563
CF_CROSS_PLATFORM_EXPORT int _CFOpenFileWithMode(const unsigned short *path, int opts, mode_t mode);
569-
#elif !TARGET_OS_WASI
564+
#else
570565
CF_CROSS_PLATFORM_EXPORT int _CFOpenFileWithMode(const char *path, int opts, mode_t mode);
571566
#endif
572567
CF_CROSS_PLATFORM_EXPORT void *_CFReallocf(void *ptr, size_t size);

CoreFoundation/Base.subproj/SwiftRuntime/CoreFoundation.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,15 @@
8686
#include <CoreFoundation/CFUUID.h>
8787
#include <CoreFoundation/CFUtilities.h>
8888

89-
#if !TARGET_OS_WASI
9089
#include <CoreFoundation/CFBundle.h>
90+
#if !TARGET_OS_WASI
9191
#include <CoreFoundation/CFPlugIn.h>
9292
#include <CoreFoundation/CFMessagePort.h>
93+
#endif
9394
#include <CoreFoundation/CFPreferences.h>
9495
#include <CoreFoundation/CFRunLoop.h>
9596
#include <CoreFoundation/CFStream.h>
97+
#if !TARGET_OS_WASI
9698
#include <CoreFoundation/CFSocket.h>
9799
#include <CoreFoundation/CFMachPort.h>
98100
#endif

0 commit comments

Comments
 (0)