From 660ccc83e6cea6a753004a76624133b10ec55aba Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Fri, 1 Mar 2024 08:51:05 +0000 Subject: [PATCH] [wasm] Port CoreFoundation/PlugIn.subproj --- CoreFoundation/PlugIn.subproj/CFBundle.c | 2 +- CoreFoundation/PlugIn.subproj/CFBundle_BinaryTypes.h | 1 + CoreFoundation/PlugIn.subproj/CFBundle_InfoPlist.c | 8 +++++++- CoreFoundation/PlugIn.subproj/CFBundle_Internal.h | 4 +++- CoreFoundation/PlugIn.subproj/CFBundle_Resources.c | 4 ++++ 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CoreFoundation/PlugIn.subproj/CFBundle.c b/CoreFoundation/PlugIn.subproj/CFBundle.c index e9e6db3de7..bdf20e0d27 100644 --- a/CoreFoundation/PlugIn.subproj/CFBundle.c +++ b/CoreFoundation/PlugIn.subproj/CFBundle.c @@ -42,7 +42,7 @@ #endif #endif /* BINARY_SUPPORT_DLFCN */ -#if TARGET_OS_MAC +#if TARGET_OS_MAC || TARGET_OS_WASI #include #elif TARGET_OS_WIN32 #include diff --git a/CoreFoundation/PlugIn.subproj/CFBundle_BinaryTypes.h b/CoreFoundation/PlugIn.subproj/CFBundle_BinaryTypes.h index 7528e80eb1..33e74b3fda 100644 --- a/CoreFoundation/PlugIn.subproj/CFBundle_BinaryTypes.h +++ b/CoreFoundation/PlugIn.subproj/CFBundle_BinaryTypes.h @@ -28,6 +28,7 @@ CF_EXTERN_C_BEGIN #define BINARY_SUPPORT_DLL 1 #elif TARGET_OS_LINUX || TARGET_OS_BSD #define BINARY_SUPPORT_DLFCN 1 +#elif TARGET_OS_WASI #else #error Unknown or unspecified DEPLOYMENT_TARGET #endif diff --git a/CoreFoundation/PlugIn.subproj/CFBundle_InfoPlist.c b/CoreFoundation/PlugIn.subproj/CFBundle_InfoPlist.c index 3a9e0101eb..5f4c926ba1 100644 --- a/CoreFoundation/PlugIn.subproj/CFBundle_InfoPlist.c +++ b/CoreFoundation/PlugIn.subproj/CFBundle_InfoPlist.c @@ -15,7 +15,7 @@ #include #include -#if (TARGET_OS_MAC || TARGET_OS_LINUX || TARGET_OS_BSD) && !TARGET_OS_CYGWIN +#if (TARGET_OS_MAC || TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_WASI) && !TARGET_OS_CYGWIN #include #if TARGET_OS_MAC || TARGET_OS_BSD #include @@ -142,6 +142,8 @@ CF_PRIVATE CFStringRef _CFBundleGetPlatformNameSuffix(void) { return _CFBundleLinuxPlatformNameSuffix; #elif TARGET_OS_BSD return _CFBundleFreeBSDPlatformNameSuffix; +#elif TARGET_OS_WASI + return _CFBundleWASIPlatformNameSuffix; #else #error Unknown or unspecified DEPLOYMENT_TARGET #endif @@ -174,6 +176,8 @@ CF_EXPORT CFStringRef _CFGetPlatformName(void) { #endif #elif TARGET_OS_BSD return _CFBundleFreeBSDPlatformName; +#elif TARGET_OS_WASI + return _CFBundleWASIPlatformName; #else #error Unknown or unspecified DEPLOYMENT_TARGET #endif @@ -194,6 +198,8 @@ CF_EXPORT CFStringRef _CFGetAlternatePlatformName(void) { #endif #elif TARGET_OS_BSD return CFSTR("FreeBSD"); +#elif TARGET_OS_WASI + return CFSTR("WASI"); #else #error Unknown or unspecified DEPLOYMENT_TARGET #endif diff --git a/CoreFoundation/PlugIn.subproj/CFBundle_Internal.h b/CoreFoundation/PlugIn.subproj/CFBundle_Internal.h index def3aafc8d..244f0494a7 100644 --- a/CoreFoundation/PlugIn.subproj/CFBundle_Internal.h +++ b/CoreFoundation/PlugIn.subproj/CFBundle_Internal.h @@ -32,7 +32,7 @@ CF_EXTERN_C_BEGIN // FHS bundles are supported on the Swift and C runtimes, except on Windows. #if !DEPLOYMENT_RUNTIME_OBJC && !TARGET_OS_WIN32 -#if TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_ANDROID +#if TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_ANDROID || TARGET_OS_WASI #define _CFBundleFHSSharedLibraryFilenamePrefix CFSTR("lib") #define _CFBundleFHSSharedLibraryFilenameSuffix CFSTR(".so") #elif TARGET_OS_MAC @@ -390,6 +390,7 @@ extern void _CFPlugInWillUnload(CFPlugInRef plugIn); #define _CFBundleSolarisPlatformName CFSTR("solaris") #define _CFBundleLinuxPlatformName CFSTR("linux") #define _CFBundleFreeBSDPlatformName CFSTR("freebsd") +#define _CFBundleWASIPlatformName CFSTR("wasi") #define _CFBundleMacOSXPlatformNameSuffix CFSTR("-macos") #define _CFBundleAlternateMacOSXPlatformNameSuffix CFSTR("-macosx") #define _CFBundleiPhoneOSPlatformNameSuffix CFSTR("-iphoneos") @@ -400,6 +401,7 @@ extern void _CFPlugInWillUnload(CFPlugInRef plugIn); #define _CFBundleSolarisPlatformNameSuffix CFSTR("-solaris") #define _CFBundleLinuxPlatformNameSuffix CFSTR("-linux") #define _CFBundleFreeBSDPlatformNameSuffix CFSTR("-freebsd") +#define _CFBundleWASIPlatformNameSuffix CFSTR("-wasi") STATIC_CONST_STRING_DECL(_CFBundleMacDeviceName, "mac"); STATIC_CONST_STRING_DECL(_CFBundleiPhoneDeviceName, "iphone"); diff --git a/CoreFoundation/PlugIn.subproj/CFBundle_Resources.c b/CoreFoundation/PlugIn.subproj/CFBundle_Resources.c index 601d014a73..acccefeada 100644 --- a/CoreFoundation/PlugIn.subproj/CFBundle_Resources.c +++ b/CoreFoundation/PlugIn.subproj/CFBundle_Resources.c @@ -507,6 +507,8 @@ CF_EXPORT CFStringRef _CFBundleGetCurrentPlatform(void) { #endif #elif TARGET_OS_BSD return CFSTR("FreeBSD"); +#elif TARGET_OS_WASI + return CFSTR("WASI"); #else #error Unknown or unspecified DEPLOYMENT_TARGET #endif @@ -529,6 +531,8 @@ CF_PRIVATE CFStringRef _CFBundleGetPlatformExecutablesSubdirectoryName(void) { #endif #elif TARGET_OS_BSD return CFSTR("FreeBSD"); +#elif TARGET_OS_WASI + return CFSTR("WASI"); #else #error Unknown or unspecified DEPLOYMENT_TARGET #endif