Skip to content

Commit 5ad479e

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 514e2bd commit 5ad479e

File tree

6 files changed

+8
-17
lines changed

6 files changed

+8
-17
lines changed

CoreFoundation/Base.subproj/CFPriv.h

Lines changed: 0 additions & 2 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 0 additions & 6 deletions
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

Lines changed: 2 additions & 7 deletions
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
#elif TARGET_OS_LINUX
7071
#include <errno.h>
7172
#include <features.h>
@@ -382,9 +383,7 @@ CF_PRIVATE uint64_t __CFMemorySize(void);
382383
CF_PRIVATE CFIndex __CFActiveProcessorCount(void);
383384
CF_CROSS_PLATFORM_EXPORT CFStringRef CFCopyFullUserName(void);
384385

385-
#if !TARGET_OS_WASI
386386
extern CFWriteStreamRef _CFWriteStreamCreateFromFileDescriptor(CFAllocatorRef alloc, int fd);
387-
#endif
388387

389388
#if !__COREFOUNDATION_FORFOUNDATIONONLY__
390389
typedef const struct __CFKeyedArchiverUID * CFKeyedArchiverUIDRef;
@@ -396,9 +395,7 @@ extern uint32_t _CFKeyedArchiverUIDGetValue(CFKeyedArchiverUIDRef uid);
396395
extern CFIndex __CFBinaryPlistWriteToStream(CFPropertyListRef plist, CFTypeRef stream);
397396
CF_CROSS_PLATFORM_EXPORT CFDataRef _CFPropertyListCreateXMLDataWithExtras(CFAllocatorRef allocator, CFPropertyListRef propertyList);
398397

399-
#if !TARGET_OS_WASI
400398
extern CFWriteStreamRef _CFWriteStreamCreateFromFileDescriptor(CFAllocatorRef alloc, int fd);
401-
#endif
402399

403400
CF_EXPORT char *_Nullable *_Nonnull _CFEnviron(void);
404401

@@ -446,7 +443,6 @@ CF_EXPORT CFCharacterSetRef _CFCharacterSetCreateCopy(CFAllocatorRef alloc, CFCh
446443
CF_EXPORT CFMutableCharacterSetRef _CFCharacterSetCreateMutableCopy(CFAllocatorRef alloc, CFCharacterSetRef theSet);
447444
CF_CROSS_PLATFORM_EXPORT void _CFCharacterSetInitCopyingSet(CFAllocatorRef alloc, CFMutableCharacterSetRef cset, CFCharacterSetRef theSet, bool isMutable, bool validateSubclasses);
448445

449-
#if !TARGET_OS_WASI
450446
CF_EXPORT _Nullable CFErrorRef CFReadStreamCopyError(CFReadStreamRef _Null_unspecified stream);
451447

452448
CF_EXPORT _Nullable CFErrorRef CFWriteStreamCopyError(CFWriteStreamRef _Null_unspecified stream);
@@ -455,7 +451,6 @@ CF_CROSS_PLATFORM_EXPORT CFStringRef _Nullable _CFBundleCopyExecutablePath(CFBun
455451
CF_CROSS_PLATFORM_EXPORT Boolean _CFBundleSupportsFHSBundles(void);
456452
CF_CROSS_PLATFORM_EXPORT Boolean _CFBundleSupportsFreestandingBundles(void);
457453
CF_CROSS_PLATFORM_EXPORT CFStringRef _Nullable _CFBundleCopyLoadedImagePathForAddress(const void *p);
458-
#endif
459454

460455
CF_CROSS_PLATFORM_EXPORT CFStringRef __CFTimeZoneCopyDataVersionString(void);
461456

@@ -561,7 +556,7 @@ CF_CROSS_PLATFORM_EXPORT CFIndex __CFCharDigitValue(UniChar ch);
561556

562557
#if TARGET_OS_WIN32
563558
CF_CROSS_PLATFORM_EXPORT int _CFOpenFileWithMode(const unsigned short *path, int opts, mode_t mode);
564-
#elif !TARGET_OS_WASI
559+
#else
565560
CF_CROSS_PLATFORM_EXPORT int _CFOpenFileWithMode(const char *path, int opts, mode_t mode);
566561
#endif
567562
CF_CROSS_PLATFORM_EXPORT void *_CFReallocf(void *ptr, size_t size);

CoreFoundation/Base.subproj/SwiftRuntime/CoreFoundation.h

Lines changed: 3 additions & 1 deletion
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)