diff --git a/CoreFoundation/Base.subproj/CFInternal.h b/CoreFoundation/Base.subproj/CFInternal.h index ff416cd87e..e2d3215c74 100644 --- a/CoreFoundation/Base.subproj/CFInternal.h +++ b/CoreFoundation/Base.subproj/CFInternal.h @@ -1034,7 +1034,7 @@ enum { }; #endif // __has_include() -#if TARGET_OS_LINUX || TARGET_OS_WIN32 +#if TARGET_OS_LINUX || TARGET_OS_WIN32 || TARGET_OS_BSD #define QOS_CLASS_USER_INITIATED DISPATCH_QUEUE_PRIORITY_HIGH #define QOS_CLASS_DEFAULT DISPATCH_QUEUE_PRIORITY_DEFAULT #define QOS_CLASS_UTILITY DISPATCH_QUEUE_PRIORITY_LOW diff --git a/CoreFoundation/Base.subproj/CFPlatform.c b/CoreFoundation/Base.subproj/CFPlatform.c index d2b5251fc7..9929123bc7 100644 --- a/CoreFoundation/Base.subproj/CFPlatform.c +++ b/CoreFoundation/Base.subproj/CFPlatform.c @@ -1649,7 +1649,7 @@ int _CFOpenFile(const char *path, int opts) { } CF_CROSS_PLATFORM_EXPORT void *_CFReallocf(void *ptr, size_t size) { -#if TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_WIN32 || TARGET_OS_LINUX || defined(__OpenBSD__) void *mem = realloc(ptr, size); if (mem == NULL && ptr != NULL && size != 0) { free(ptr); diff --git a/CoreFoundation/Base.subproj/CFRuntime.c b/CoreFoundation/Base.subproj/CFRuntime.c index 57970ee35a..07761c0fc3 100644 --- a/CoreFoundation/Base.subproj/CFRuntime.c +++ b/CoreFoundation/Base.subproj/CFRuntime.c @@ -972,7 +972,7 @@ extern CFTypeID CFTreeGetTypeID(void); extern CFTypeID CFPlugInInstanceGetTypeID(void); extern CFTypeID CFStringTokenizerGetTypeID(void); extern CFTypeID CFStorageGetTypeID(void); -#if TARGET_OS_LINUX || (TARGET_OS_OSX && !DEPLOYMENT_RUNTIME_OBJC) +#if TARGET_OS_LINUX || TARGET_OS_BSD || (TARGET_OS_OSX && !DEPLOYMENT_RUNTIME_OBJC) CF_PRIVATE void __CFTSDInitialize(void); #endif #if TARGET_OS_WIN32 @@ -1105,7 +1105,7 @@ Boolean __CFInitialized = 0; // move the next 2 lines down into the #if below, and make it static, after Foundation gets off this symbol on other platforms. CF_EXPORT _CFThreadRef _CFMainPThread; _CFThreadRef _CFMainPThread = kNilPthreadT; -#if TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD CF_EXPORT _CFThreadRef _CF_pthread_main_thread_np(void); _CFThreadRef _CF_pthread_main_thread_np(void) { @@ -1144,7 +1144,7 @@ void __CFInitialize(void) { #if TARGET_OS_WIN32 // Must not call any CF functions __CFTSDWindowsInitialize(); -#elif TARGET_OS_LINUX || (TARGET_OS_MAC && !DEPLOYMENT_RUNTIME_OBJC) +#elif TARGET_OS_LINUX || TARGET_OS_BSD || (TARGET_OS_MAC && !DEPLOYMENT_RUNTIME_OBJC) __CFTSDInitialize(); #endif __CFProphylacticAutofsAccess = true; diff --git a/CoreFoundation/Base.subproj/CFUUID.c b/CoreFoundation/Base.subproj/CFUUID.c index 9ebd27af7a..6b64258dc5 100644 --- a/CoreFoundation/Base.subproj/CFUUID.c +++ b/CoreFoundation/Base.subproj/CFUUID.c @@ -152,7 +152,7 @@ CFUUIDRef CFUUIDCreate(CFAllocatorRef alloc) { long rStatus = UuidCreate(&u); if (RPC_S_OK != rStatus && RPC_S_UUID_LOCAL_ONLY != rStatus) retval = 1; memmove(&bytes, &u, sizeof(bytes)); -#elif TARGET_OS_MAC || TARGET_OS_LINUX +#elif TARGET_OS_MAC || TARGET_OS_LINUX || TARGET_OS_BSD static int8_t useV1UUIDs = -1; uuid_t uuid; if (useV1UUIDs == -1) { diff --git a/CoreFoundation/Base.subproj/CFUtilities.c b/CoreFoundation/Base.subproj/CFUtilities.c index aeb999e403..22d4713e42 100644 --- a/CoreFoundation/Base.subproj/CFUtilities.c +++ b/CoreFoundation/Base.subproj/CFUtilities.c @@ -544,7 +544,7 @@ CF_PRIVATE CFIndex __CFActiveProcessorCount(void) { if (result != 0) { pcnt = 0; } -#elif TARGET_OS_LINUX +#elif TARGET_OS_LINUX || TARGET_OS_BSD #ifdef HAVE_SCHED_GETAFFINITY cpu_set_t set; @@ -571,7 +571,7 @@ CF_PRIVATE CFIndex __CFProcessorCount() { if (result != 0) { pcnt = 0; } -#elif TARGET_OS_LINUX +#elif TARGET_OS_LINUX || TARGET_OS_BSD pcnt = sysconf(_SC_NPROCESSORS_CONF); #else // Assume the worst @@ -589,7 +589,7 @@ CF_PRIVATE uint64_t __CFMemorySize() { if (result != 0) { memsize = 0; } -#elif TARGET_OS_LINUX +#elif TARGET_OS_LINUX || TARGET_OS_BSD memsize = sysconf(_SC_PHYS_PAGES); memsize *= sysconf(_SC_PAGESIZE); #endif diff --git a/CoreFoundation/Base.subproj/CoreFoundation_Prefix.h b/CoreFoundation/Base.subproj/CoreFoundation_Prefix.h index 8935722d2e..35e08036d8 100644 --- a/CoreFoundation/Base.subproj/CoreFoundation_Prefix.h +++ b/CoreFoundation/Base.subproj/CoreFoundation_Prefix.h @@ -222,7 +222,7 @@ CF_INLINE uint64_t mach_absolute_time() { ULONGLONG ullTime; QueryUnbiasedInterruptTimePrecise(&ullTime); return ullTime; -#else +#elif TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_MAC struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); return (uint64_t)ts.tv_nsec + (uint64_t)ts.tv_sec * 1000000000UL; diff --git a/CoreFoundation/Locale.subproj/CFDateFormatter.c b/CoreFoundation/Locale.subproj/CFDateFormatter.c index 2e3eabb073..97e70ab2ef 100644 --- a/CoreFoundation/Locale.subproj/CFDateFormatter.c +++ b/CoreFoundation/Locale.subproj/CFDateFormatter.c @@ -1506,7 +1506,7 @@ static UDate __CFDateFormatterCorrectTimeToARangeAroundCurrentDate(UCalendar *ca return __CFDateFormatterCorrectTimeWithTarget(calendar, at, currEraOrCentury+offset, isEra, status); } -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD static int32_t __CFDateFormatterGetMaxYearGivenJapaneseEra(UCalendar *calendar, int32_t era, UErrorCode *status) { int32_t years = 0; __cficu_ucal_clear(calendar); @@ -1559,7 +1559,7 @@ static Boolean __CFDateFormatterHandleAmbiguousYear(CFDateFormatterRef formatter } } } else if (calendar_id == kCFCalendarIdentifierJapanese) { // ??? need more work -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD __cficu_ucal_clear(cal); __cficu_ucal_set(cal, UCAL_ERA, 1); __cficu_udat_parseCalendar(df, cal, ustr, length, NULL, status); diff --git a/CoreFoundation/Locale.subproj/CFLocale.c b/CoreFoundation/Locale.subproj/CFLocale.c index 4d1ae19ad7..a0a91f09b0 100644 --- a/CoreFoundation/Locale.subproj/CFLocale.c +++ b/CoreFoundation/Locale.subproj/CFLocale.c @@ -600,7 +600,7 @@ static CFLocaleRef _CFLocaleCopyCurrentGuts(CFStringRef name, Boolean useCache, // things which call this function thousands or millions of times in // a short period. if (!name) { -#if 0 // TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if 0 // TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD name = (CFStringRef)CFPreferencesCopyAppValue(CFSTR("AppleLocale"), kCFPreferencesCurrentApplication); #endif } else { @@ -938,7 +938,7 @@ CFStringRef CFLocaleCopyDisplayNameForPropertyValue(CFLocaleRef displayLocale, C langPref = (CFArrayRef)CFDictionaryGetValue(displayLocale->_prefs, CFSTR("AppleLanguages")); if (langPref) CFRetain(langPref); } else { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD langPref = (CFArrayRef)CFPreferencesCopyAppValue(CFSTR("AppleLanguages"), kCFPreferencesCurrentApplication); #endif } @@ -963,7 +963,7 @@ CFStringRef CFLocaleCopyDisplayNameForPropertyValue(CFLocaleRef displayLocale, C } CFArrayRef CFLocaleCopyAvailableLocaleIdentifiers(void) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD int32_t locale, localeCount = uloc_countAvailable(); CFMutableSetRef working = CFSetCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeSetCallBacks); for (locale = 0; locale < localeCount; ++locale) { @@ -984,7 +984,7 @@ CFArrayRef CFLocaleCopyAvailableLocaleIdentifiers(void) { #endif } -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD static CFArrayRef __CFLocaleCopyCStringsAsArray(const char* const* p) { CFMutableArrayRef working = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks); for (; *p; ++p) { @@ -1024,7 +1024,7 @@ static CFArrayRef __CFLocaleCopyUEnumerationAsArray(UEnumeration *enumer, UError #endif CFArrayRef CFLocaleCopyISOLanguageCodes(void) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD const char* const* p = uloc_getISOLanguages(); return __CFLocaleCopyCStringsAsArray(p); #else @@ -1033,7 +1033,7 @@ CFArrayRef CFLocaleCopyISOLanguageCodes(void) { } CFArrayRef CFLocaleCopyISOCountryCodes(void) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD const char* const* p = uloc_getISOCountries(); return __CFLocaleCopyCStringsAsArray(p); #else @@ -1042,7 +1042,7 @@ CFArrayRef CFLocaleCopyISOCountryCodes(void) { } CFArrayRef CFLocaleCopyISOCurrencyCodes(void) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD UErrorCode icuStatus = U_ZERO_ERROR; UEnumeration *enumer = ucurr_openISOCurrencies(UCURR_ALL, &icuStatus); CFArrayRef result = __CFLocaleCopyUEnumerationAsArray(enumer, &icuStatus); @@ -1054,7 +1054,7 @@ CFArrayRef CFLocaleCopyISOCurrencyCodes(void) { } CFArrayRef CFLocaleCopyCommonISOCurrencyCodes(void) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD UErrorCode icuStatus = U_ZERO_ERROR; UEnumeration *enumer = ucurr_openISOCurrencies(UCURR_COMMON|UCURR_NON_DEPRECATED, &icuStatus); CFArrayRef result = __CFLocaleCopyUEnumerationAsArray(enumer, &icuStatus); @@ -1066,7 +1066,7 @@ CFArrayRef CFLocaleCopyCommonISOCurrencyCodes(void) { } CFStringRef CFLocaleCreateLocaleIdentifierFromWindowsLocaleCode(CFAllocatorRef allocator, uint32_t lcid) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD char buffer[kMaxICUNameSize]; UErrorCode status = U_ZERO_ERROR; int32_t ret = uloc_getLocaleForLCID(lcid, buffer, kMaxICUNameSize, &status); @@ -1081,7 +1081,7 @@ CFStringRef CFLocaleCreateLocaleIdentifierFromWindowsLocaleCode(CFAllocatorRef a } uint32_t CFLocaleGetWindowsLocaleCodeFromLocaleIdentifier(CFStringRef localeIdentifier) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD CFStringRef ident = CFLocaleCreateCanonicalLocaleIdentifierFromString(kCFAllocatorSystemDefault, localeIdentifier); char localeID[ULOC_FULLNAME_CAPACITY+ULOC_KEYWORD_AND_VALUES_CAPACITY]; Boolean b = ident ? CFStringGetCString(ident, localeID, sizeof(localeID)/sizeof(char), kCFStringEncodingASCII) : false; @@ -1093,7 +1093,7 @@ uint32_t CFLocaleGetWindowsLocaleCodeFromLocaleIdentifier(CFStringRef localeIden } CFLocaleLanguageDirection CFLocaleGetLanguageCharacterDirection(CFStringRef isoLangCode) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD char localeID[ULOC_FULLNAME_CAPACITY+ULOC_KEYWORD_AND_VALUES_CAPACITY]; Boolean b = isoLangCode ? CFStringGetCString(isoLangCode, localeID, sizeof(localeID)/sizeof(char), kCFStringEncodingASCII) : false; CFLocaleLanguageDirection dir; @@ -1113,7 +1113,7 @@ CFLocaleLanguageDirection CFLocaleGetLanguageCharacterDirection(CFStringRef isoL } CFLocaleLanguageDirection CFLocaleGetLanguageLineDirection(CFStringRef isoLangCode) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD char localeID[ULOC_FULLNAME_CAPACITY+ULOC_KEYWORD_AND_VALUES_CAPACITY]; Boolean b = isoLangCode ? CFStringGetCString(isoLangCode, localeID, sizeof(localeID)/sizeof(char), kCFStringEncodingASCII) : false; CFLocaleLanguageDirection dir; @@ -1250,7 +1250,7 @@ static bool __CFLocaleCopyCodes(CFLocaleRef locale, bool user, CFTypeRef *cf, CF } } -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD CFCharacterSetRef _CFCreateCharacterSetFromUSet(USet *set) { UErrorCode icuErr = U_ZERO_ERROR; CFMutableCharacterSetRef working = CFCharacterSetCreateMutable(NULL); @@ -1306,7 +1306,7 @@ CFCharacterSetRef _CFCreateCharacterSetFromUSet(USet *set) { #endif static bool __CFLocaleCopyExemplarCharSet(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD char localeID[ULOC_FULLNAME_CAPACITY+ULOC_KEYWORD_AND_VALUES_CAPACITY]; if (CFStringGetCString(locale->_identifier, localeID, sizeof(localeID)/sizeof(char), kCFStringEncodingASCII)) { UErrorCode icuStatus = U_ZERO_ERROR; @@ -1327,7 +1327,7 @@ static bool __CFLocaleCopyExemplarCharSet(CFLocaleRef locale, bool user, CFTypeR static bool __CFLocaleCopyICUKeyword(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context, const char *keyword) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD char localeID[ULOC_FULLNAME_CAPACITY+ULOC_KEYWORD_AND_VALUES_CAPACITY]; if (CFStringGetCString(locale->_identifier, localeID, sizeof(localeID)/sizeof(char), kCFStringEncodingASCII)) { @@ -1345,7 +1345,7 @@ static bool __CFLocaleCopyICUKeyword(CFLocaleRef locale, bool user, CFTypeRef *c } static bool __CFLocaleCopyICUCalendarID(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context, const char *keyword) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD char localeID[ULOC_FULLNAME_CAPACITY+ULOC_KEYWORD_AND_VALUES_CAPACITY]; if (CFStringGetCString(locale->_identifier, localeID, sizeof(localeID)/sizeof(char), kCFStringEncodingASCII)) { UErrorCode icuStatus = U_ZERO_ERROR; @@ -1430,7 +1430,7 @@ static bool __CFLocaleCopyCalendarID(CFLocaleRef locale, bool user, CFTypeRef *c } static bool __CFLocaleCopyCalendar(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD if (__CFLocaleCopyCalendarID(locale, user, cf, context)) { CFCalendarRef calendar = _CFCalendarCreateCoWWithIdentifier((CFStringRef)*cf); CFCalendarSetLocale(calendar, locale); @@ -1464,7 +1464,7 @@ static bool __CFLocaleCopyCalendar(CFLocaleRef locale, bool user, CFTypeRef *cf, } static bool __CFLocaleCopyDelimiter(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD ULocaleDataDelimiterType type = (ULocaleDataDelimiterType)0; if (context == kCFLocaleQuotationBeginDelimiterKey) { type = ULOCDATA_QUOTATION_START; @@ -1587,7 +1587,7 @@ static CFStringRef _CFLocaleGetTemperatureUnitName(bool celsius) { } #endif -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunguarded-availability-new" @@ -1630,7 +1630,7 @@ static bool __CFLocaleGetMeasurementSystemForName(CFStringRef name, UMeasuremen #endif -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD static void __CFLocaleGetMeasurementSystemGuts(CFLocaleRef locale, bool user, UMeasurementSystem *outMeasurementSystem) { UMeasurementSystem output = UMS_SI; // Default is Metric bool done = false; @@ -1660,7 +1660,7 @@ static void __CFLocaleGetMeasurementSystemGuts(CFLocaleRef locale, bool user, UM static bool __CFLocaleCopyUsesMetric(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD UMeasurementSystem system = UMS_SI; __CFLocaleGetMeasurementSystemGuts(locale, user, &system); *cf = system != UMS_US ? kCFBooleanTrue : kCFBooleanFalse; @@ -1672,7 +1672,7 @@ static bool __CFLocaleCopyUsesMetric(CFLocaleRef locale, bool user, CFTypeRef *c } static bool __CFLocaleCopyMeasurementSystem(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD UMeasurementSystem system = UMS_SI; __CFLocaleGetMeasurementSystemGuts(locale, user, &system); *cf = CFRetain(__CFLocaleGetMeasurementSystemName(system)); @@ -1695,7 +1695,7 @@ static bool __CFLocaleCopyTemperatureUnit(CFLocaleRef locale, bool user, CFTypeR done = _CFLocaleGetTemperatureUnitForPreferences(temperatureUnitPref, &celsius); } #endif -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD if (!done) { char localeID[ULOC_FULLNAME_CAPACITY+ULOC_KEYWORD_AND_VALUES_CAPACITY]; if (CFStringGetCString(locale->_identifier, localeID, sizeof(localeID)/sizeof(char), kCFStringEncodingASCII)) { @@ -1733,7 +1733,7 @@ static bool __CFLocaleCopyTemperatureUnit(CFLocaleRef locale, bool user, CFTypeR static bool __CFLocaleCopyNumberFormat(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context) { CFStringRef str = NULL; -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD CFNumberFormatterRef nf = CFNumberFormatterCreate(kCFAllocatorSystemDefault, locale, kCFNumberFormatterDecimalStyle); str = nf ? (CFStringRef)CFNumberFormatterCopyProperty(nf, context) : NULL; if (nf) CFRelease(nf); @@ -1749,7 +1749,7 @@ static bool __CFLocaleCopyNumberFormat(CFLocaleRef locale, bool user, CFTypeRef // so we have to have another routine here which creates a Currency number formatter. static bool __CFLocaleCopyNumberFormat2(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context) { CFStringRef str = NULL; -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD CFNumberFormatterRef nf = CFNumberFormatterCreate(kCFAllocatorSystemDefault, locale, kCFNumberFormatterCurrencyStyle); str = nf ? (CFStringRef)CFNumberFormatterCopyProperty(nf, context) : NULL; if (nf) CFRelease(nf); @@ -1761,7 +1761,7 @@ static bool __CFLocaleCopyNumberFormat2(CFLocaleRef locale, bool user, CFTypeRef return false; } -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD typedef int32_t (*__CFICUFunction)(const char *, const char *, UChar *, int32_t, UErrorCode *); static bool __CFLocaleICUName(const char *locale, const char *valLocale, CFStringRef *out, __CFICUFunction icu) { @@ -1833,7 +1833,7 @@ static bool __CFLocaleICUCurrencyName(const char *locale, const char *value, UCu #endif static bool __CFLocaleFullName(const char *locale, const char *value, CFStringRef *out) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD UErrorCode icuStatus = U_ZERO_ERROR; int32_t size; UChar name[kMaxICUNameSize]; @@ -1866,7 +1866,7 @@ static bool __CFLocaleFullName(const char *locale, const char *value, CFStringRe } static bool __CFLocaleLanguageName(const char *locale, const char *value, CFStringRef *out) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD return __CFLocaleICUName(locale, value, out, uloc_getDisplayLanguage); #else *out = CFRetain(CFSTR("(none)")); @@ -1875,7 +1875,7 @@ static bool __CFLocaleLanguageName(const char *locale, const char *value, CFStri } static bool __CFLocaleCountryName(const char *locale, const char *value, CFStringRef *out) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD // Need to make a fake locale ID char lid[ULOC_FULLNAME_CAPACITY]; if (strlen(value) < sizeof(lid) - 3) { @@ -1891,7 +1891,7 @@ static bool __CFLocaleCountryName(const char *locale, const char *value, CFStrin } static bool __CFLocaleScriptName(const char *locale, const char *value, CFStringRef *out) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD // Need to make a fake locale ID char lid[ULOC_FULLNAME_CAPACITY]; if (strlen(value) == 4) { @@ -1908,7 +1908,7 @@ static bool __CFLocaleScriptName(const char *locale, const char *value, CFString } static bool __CFLocaleVariantName(const char *locale, const char *value, CFStringRef *out) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD // Need to make a fake locale ID char lid[ULOC_FULLNAME_CAPACITY+ULOC_KEYWORD_AND_VALUES_CAPACITY]; if (strlen(value) < sizeof(lid) - 6) { @@ -1924,7 +1924,7 @@ static bool __CFLocaleVariantName(const char *locale, const char *value, CFStrin } static bool __CFLocaleCalendarName(const char *locale, const char *value, CFStringRef *out) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD return __CFLocaleICUKeywordValueName(locale, value, kCalendarKeyword, out); #else *out = CFRetain(CFSTR("(none)")); @@ -1933,7 +1933,7 @@ static bool __CFLocaleCalendarName(const char *locale, const char *value, CFStri } static bool __CFLocaleCollationName(const char *locale, const char *value, CFStringRef *out) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD return __CFLocaleICUKeywordValueName(locale, value, kCollationKeyword, out); #else *out = CFRetain(CFSTR("(none)")); @@ -1942,7 +1942,7 @@ static bool __CFLocaleCollationName(const char *locale, const char *value, CFStr } static bool __CFLocaleCurrencyShortName(const char *locale, const char *value, CFStringRef *out) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD return __CFLocaleICUCurrencyName(locale, value, UCURR_SYMBOL_NAME, out); #else *out = CFRetain(CFSTR("(none)")); @@ -1951,7 +1951,7 @@ static bool __CFLocaleCurrencyShortName(const char *locale, const char *value, C } static bool __CFLocaleCurrencyFullName(const char *locale, const char *value, CFStringRef *out) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD return __CFLocaleICUCurrencyName(locale, value, UCURR_LONG_NAME, out); #else *out = CFRetain(CFSTR("(none)")); diff --git a/CoreFoundation/Locale.subproj/CFLocaleIdentifier.c b/CoreFoundation/Locale.subproj/CFLocaleIdentifier.c index bc8e6984bc..ac48113fc6 100644 --- a/CoreFoundation/Locale.subproj/CFLocaleIdentifier.c +++ b/CoreFoundation/Locale.subproj/CFLocaleIdentifier.c @@ -58,7 +58,7 @@ #include #include #include -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD #include #else #define ULOC_KEYWORD_SEPARATOR '@' @@ -1157,7 +1157,7 @@ enum { }; */ -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD struct LocaleToLegacyCodes { const char * locale; // reduced to language plus one other component (script, region, variant), separators normalized to'_' @@ -1595,7 +1595,7 @@ static void _UpdateFullLocaleString(char inLocaleString[], int locStringMaxLen, // If so, copy the keywords to varKeyValueString and delete the variant tag // from the original string (but don't otherwise use the ICU canonicalization). varKeyValueString[0] = 0; -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD if (variantTag) { UErrorCode icuStatus; int icuCanonStringLen; @@ -1722,7 +1722,7 @@ static void _GetKeyValueString(char inLocaleString[], char keyValueString[]) { } static void _AppendKeyValueString(char inLocaleString[], int locStringMaxLen, char keyValueString[]) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD if (keyValueString[0] != 0) { UErrorCode uerr = U_ZERO_ERROR; UEnumeration * uenum = uloc_openKeywords(keyValueString, &uerr); @@ -1954,12 +1954,12 @@ SPI: CFLocaleGetLanguageRegionEncodingForLocaleIdentifier gets the appropriate preferred localization in the current context (this function returns NO for a NULL localeIdentifier); and in this function langCode, regCode, and scriptCode are all SInt16* (not SInt32* like the equivalent parameters in CFBundleGetLocalizationInfoForLocalization). */ -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD static int CompareLocaleToLegacyCodesEntries( const void *entry1, const void *entry2 ); #endif Boolean CFLocaleGetLanguageRegionEncodingForLocaleIdentifier(CFStringRef localeIdentifier, LangCode *langCode, RegionCode *regCode, ScriptCode *scriptCode, CFStringEncoding *stringEncoding) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD Boolean returnValue = false; CFStringRef canonicalIdentifier = CFLocaleCreateCanonicalLocaleIdentifierFromString(NULL, localeIdentifier); if (canonicalIdentifier) { @@ -2037,7 +2037,7 @@ Boolean CFLocaleGetLanguageRegionEncodingForLocaleIdentifier(CFStringRef localeI #endif } -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD static int CompareLocaleToLegacyCodesEntries( const void *entry1, const void *entry2 ) { const char * localeString1 = ((const LocaleToLegacyCodes *)entry1)->locale; const char * localeString2 = ((const LocaleToLegacyCodes *)entry2)->locale; @@ -2047,7 +2047,7 @@ static int CompareLocaleToLegacyCodesEntries( const void *entry1, const void *en CFDictionaryRef CFLocaleCreateComponentsFromLocaleIdentifier(CFAllocatorRef allocator, CFStringRef localeID) { CFMutableDictionaryRef working = CFDictionaryCreateMutable(allocator, 10, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD char cLocaleID[ULOC_FULLNAME_CAPACITY+ULOC_KEYWORD_AND_VALUES_CAPACITY]; char buffer[ULOC_FULLNAME_CAPACITY+ULOC_KEYWORD_AND_VALUES_CAPACITY]; @@ -2177,7 +2177,7 @@ CFStringRef CFLocaleCreateLocaleIdentifierFromComponents(CFAllocatorRef allocato free(variant); free(buf1); -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD for (CFIndex idx = 0; idx < cnt; idx++) { if (keys[idx]) { char *key = __CStringFromString(keys[idx]); diff --git a/CoreFoundation/Preferences.subproj/CFPreferences.c b/CoreFoundation/Preferences.subproj/CFPreferences.c index ff7a4b8000..b8f028ab1b 100644 --- a/CoreFoundation/Preferences.subproj/CFPreferences.c +++ b/CoreFoundation/Preferences.subproj/CFPreferences.c @@ -420,7 +420,7 @@ static CFStringRef _CFPreferencesStandardDomainCacheKey(CFStringRef domainName static CFURLRef _CFPreferencesURLForStandardDomainWithSafetyLevel(CFStringRef domainName, CFStringRef userName, CFStringRef hostName, unsigned long safeLevel) { CFURLRef theURL = NULL; CFAllocatorRef prefAlloc = __CFPreferencesAllocator(); -#if TARGET_OS_OSX || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_OSX || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD CFURLRef prefDir = _preferencesCreateDirectoryForUserHostSafetyLevel(userName, hostName, safeLevel); CFStringRef appName; CFStringRef fileName; @@ -454,7 +454,7 @@ static CFURLRef _CFPreferencesURLForStandardDomainWithSafetyLevel(CFStringRef do CFRelease(appName); } if (fileName) { -#if TARGET_OS_MAC || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_LINUX || TARGET_OS_BSD theURL = CFURLCreateWithFileSystemPathRelativeToBase(prefAlloc, fileName, kCFURLPOSIXPathStyle, false, prefDir); #elif TARGET_OS_WIN32 theURL = CFURLCreateWithFileSystemPathRelativeToBase(prefAlloc, fileName, kCFURLWindowsPathStyle, false, prefDir); diff --git a/CoreFoundation/String.subproj/CFString.c b/CoreFoundation/String.subproj/CFString.c index 26339d41f2..a50c17aaae 100644 --- a/CoreFoundation/String.subproj/CFString.c +++ b/CoreFoundation/String.subproj/CFString.c @@ -28,7 +28,7 @@ #include "CFRuntime_Internal.h" #include #include -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD #include "CFLocaleInternal.h" #include "CFStringLocalizedFormattingInternal.h" #endif @@ -453,7 +453,7 @@ CF_INLINE CFStringEncoding __CFStringGetSystemEncoding(void) { CFStringEncoding CFStringFileSystemEncoding(void) { if (__CFDefaultFileSystemEncoding == kCFStringEncodingInvalidId) { -#if TARGET_OS_MAC || TARGET_OS_WIN32 +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_BSD __CFDefaultFileSystemEncoding = kCFStringEncodingUTF8; #else __CFDefaultFileSystemEncoding = CFStringGetSystemEncoding(); @@ -6102,7 +6102,7 @@ enum { CFFormatDummyPointerType = 42 /* special case for %n */ }; -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD /* Only come in here if spec->type is CFFormatLongType or CFFormatDoubleType. Pass in 0 for width or precision if not specified. Returns false if couldn't do the format (with the assumption the caller falls back to unlocalized). */ static Boolean __CFStringFormatLocalizedNumber(CFMutableStringRef output, CFLocaleRef locale, const CFPrintValue *values, const CFFormatSpec *spec, SInt32 width, SInt32 precision, Boolean hasPrecision) { @@ -7198,7 +7198,7 @@ static Boolean __CFStringAppendFormatCore(CFMutableStringRef outputString, CFStr switch (specs[curSpec].type) { case CFFormatLongType: case CFFormatDoubleType: -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD if (localizedFormatting && (specs[curSpec].flags & kCFStringFormatLocalizable)) { // We have a locale, so we do localized formatting if (__CFStringFormatLocalizedNumber(outputString, (CFLocaleRef)formatOptions, values, &specs[curSpec], width, precision, hasPrecision)) break; } @@ -7276,7 +7276,7 @@ static Boolean __CFStringAppendFormatCore(CFMutableStringRef outputString, CFStr } // See if we need to localize the decimal point if (formatOptions) { // We have localization info -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD CFStringRef decimalSeparator = (CFGetTypeID(formatOptions) == CFLocaleGetTypeID()) ? (CFStringRef)CFLocaleGetValue((CFLocaleRef)formatOptions, kCFLocaleDecimalSeparatorKey) : (CFStringRef)CFDictionaryGetValue(formatOptions, CFSTR("NSDecimalSeparator")); #else CFStringRef decimalSeparator = CFSTR("."); diff --git a/CoreFoundation/StringEncodings.subproj/CFStringEncodingDatabase.c b/CoreFoundation/StringEncodings.subproj/CFStringEncodingDatabase.c index edb70db6ed..c871281f34 100644 --- a/CoreFoundation/StringEncodings.subproj/CFStringEncodingDatabase.c +++ b/CoreFoundation/StringEncodings.subproj/CFStringEncodingDatabase.c @@ -568,7 +568,7 @@ CF_PRIVATE CFStringEncoding __CFStringEncodingGetFromCanonicalName(const char *c } #undef LENGTH_LIMIT -#if TARGET_OS_OSX || TARGET_OS_LINUX || TARGET_OS_WIN32 +#if TARGET_OS_OSX || TARGET_OS_LINUX || TARGET_OS_WIN32 || TARGET_OS_BSD // This list indexes from DOS range static uint16_t const __CFISO8859SimilarScriptList[] = { kCFStringEncodingMacRoman, @@ -777,7 +777,7 @@ static const char * const __CFOtherNameList[] = { "Western (NextStep)", "Western (EBCDIC Latin 1)", }; -#endif /* TARGET_OS_OSX || TARGET_OS_LINUX || TARGET_OS_WIN32 */ +#endif /* TARGET_OS_OSX || TARGET_OS_LINUX || TARGET_OS_WIN32 || TARGET_OS_BSD */ CF_PRIVATE CFStringEncoding __CFStringEncodingGetMostCompatibleMacScript(CFStringEncoding encoding) { #if TARGET_OS_OSX || TARGET_OS_LINUX @@ -817,7 +817,7 @@ CF_PRIVATE const char *__CFStringEncodingGetName(CFStringEncoding encoding) { case kCFStringEncodingUTF7: return "Unicode (UTF-7)"; break; } -#if TARGET_OS_OSX || TARGET_OS_LINUX || TARGET_OS_WIN32 +#if TARGET_OS_OSX || TARGET_OS_LINUX || TARGET_OS_WIN32 || TARGET_OS_BSD if (0x0200 == (encoding & 0x0F00)) { encoding &= 0x00FF; @@ -827,7 +827,7 @@ CF_PRIVATE const char *__CFStringEncodingGetName(CFStringEncoding encoding) { if (kCFNotFound != index) return __CFOtherNameList[index]; } -#endif /* TARGET_OS_OSX || TARGET_OS_LINUX || TARGET_OS_WIN32 */ +#endif /* TARGET_OS_OSX || TARGET_OS_LINUX || TARGET_OS_WIN32 || TARGET_OS_BSD */ return NULL; } diff --git a/CoreFoundation/URL.subproj/CFURL.c b/CoreFoundation/URL.subproj/CFURL.c index 802e4ad98a..ecc3513e5c 100644 --- a/CoreFoundation/URL.subproj/CFURL.c +++ b/CoreFoundation/URL.subproj/CFURL.c @@ -2278,7 +2278,7 @@ static CFURLRef _CFURLCreateWithFileSystemRepresentation(CFAllocatorRef allocato #endif struct __CFURL *result = NULL; if (bufLen > 0) { -#if TARGET_OS_MAC || TARGET_OS_LINUX +#if TARGET_OS_MAC || TARGET_OS_LINUX || TARGET_OS_BSD Boolean isAbsolute = bufLen && (*buffer == '/'); Boolean addedPercentEncoding; Boolean releaseBaseURL = false; diff --git a/Sources/Foundation/FileManager.swift b/Sources/Foundation/FileManager.swift index 5ec5758b58..6c0dc8287e 100644 --- a/Sources/Foundation/FileManager.swift +++ b/Sources/Foundation/FileManager.swift @@ -388,7 +388,7 @@ open class FileManager : NSObject { } #if os(macOS) || os(iOS) let modeT = number.uint16Value - #elseif os(Linux) || os(Android) || os(Windows) + #elseif os(Linux) || os(Android) || os(Windows) || os(OpenBSD) let modeT = number.uint32Value #endif #if os(Windows) diff --git a/Sources/Foundation/Host.swift b/Sources/Foundation/Host.swift index 4b7d02abba..f7a86e3314 100644 --- a/Sources/Foundation/Host.swift +++ b/Sources/Foundation/Host.swift @@ -273,7 +273,7 @@ open class Host: NSObject { } var hints = addrinfo() hints.ai_family = PF_UNSPEC -#if os(macOS) || os(iOS) || os(Android) +#if os(macOS) || os(iOS) || os(Android) || os(OpenBSD) hints.ai_socktype = SOCK_STREAM #else hints.ai_socktype = Int32(SOCK_STREAM.rawValue) diff --git a/Sources/Foundation/NSLock.swift b/Sources/Foundation/NSLock.swift index d6b5649a06..68d1214770 100644 --- a/Sources/Foundation/NSLock.swift +++ b/Sources/Foundation/NSLock.swift @@ -26,7 +26,7 @@ public protocol NSLocking { private typealias _MutexPointer = UnsafeMutablePointer private typealias _RecursiveMutexPointer = UnsafeMutablePointer private typealias _ConditionVariablePointer = UnsafeMutablePointer -#elseif CYGWIN +#elseif CYGWIN || os(OpenBSD) private typealias _MutexPointer = UnsafeMutablePointer private typealias _RecursiveMutexPointer = UnsafeMutablePointer private typealias _ConditionVariablePointer = UnsafeMutablePointer @@ -242,7 +242,7 @@ open class NSRecursiveLock: NSObject, NSLocking { InitializeConditionVariable(timeoutCond) InitializeSRWLock(timeoutMutex) #else -#if CYGWIN +#if CYGWIN || os(OpenBSD) var attrib : pthread_mutexattr_t? = nil #else var attrib = pthread_mutexattr_t() diff --git a/Sources/Foundation/NSPlatform.swift b/Sources/Foundation/NSPlatform.swift index 7e89c0567b..8a66a4af3f 100644 --- a/Sources/Foundation/NSPlatform.swift +++ b/Sources/Foundation/NSPlatform.swift @@ -9,7 +9,7 @@ #if os(macOS) || os(iOS) fileprivate let _NSPageSize = Int(vm_page_size) -#elseif os(Linux) || os(Android) +#elseif os(Linux) || os(Android) || os(OpenBSD) fileprivate let _NSPageSize = Int(getpagesize()) #elseif os(Windows) import WinSDK diff --git a/Sources/Foundation/NSSwiftRuntime.swift b/Sources/Foundation/NSSwiftRuntime.swift index ea42c8b6ed..462995a366 100644 --- a/Sources/Foundation/NSSwiftRuntime.swift +++ b/Sources/Foundation/NSSwiftRuntime.swift @@ -14,7 +14,7 @@ // This mimics the behavior of the swift sdk overlay on Darwin #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) @_exported import Darwin -#elseif os(Linux) || os(Android) || CYGWIN +#elseif os(Linux) || os(Android) || CYGWIN || os(OpenBSD) @_exported import Glibc #elseif os(Windows) @_exported import CRT diff --git a/Sources/Foundation/Process.swift b/Sources/Foundation/Process.swift index 4fde60d62b..fe09b2dfaa 100644 --- a/Sources/Foundation/Process.swift +++ b/Sources/Foundation/Process.swift @@ -781,7 +781,7 @@ open class Process: NSObject { } var taskSocketPair : [Int32] = [0, 0] -#if os(macOS) || os(iOS) || os(Android) +#if os(macOS) || os(iOS) || os(Android) || os(OpenBSD) socketpair(AF_UNIX, SOCK_STREAM, 0, &taskSocketPair) #else socketpair(AF_UNIX, Int32(SOCK_STREAM.rawValue), 0, &taskSocketPair) @@ -944,7 +944,7 @@ open class Process: NSObject { try _throwIfPosixError(_CFPosixSpawnFileActionsAddClose(fileActions, fd)) } -#if canImport(Darwin) || os(Android) +#if canImport(Darwin) || os(Android) || os(OpenBSD) var spawnAttrs: posix_spawnattr_t? = nil #else var spawnAttrs: posix_spawnattr_t = posix_spawnattr_t() diff --git a/Sources/Foundation/Thread.swift b/Sources/Foundation/Thread.swift index 163ca33880..cf01fad149 100644 --- a/Sources/Foundation/Thread.swift +++ b/Sources/Foundation/Thread.swift @@ -211,7 +211,7 @@ open class Thread : NSObject { get { _attrStorage.value } set { _attrStorage.value = newValue } } -#elseif CYGWIN +#elseif CYGWIN || os(OpenBSD) internal var _attr : pthread_attr_t? = nil #else internal var _attr = pthread_attr_t() @@ -251,7 +251,7 @@ open class Thread : NSObject { _status = .finished return } -#if CYGWIN +#if CYGWIN || os(OpenBSD) if let attr = self._attr { _thread = self.withRetainedReference { return _CFThreadCreate(attr, NSThreadStart, $0) @@ -359,7 +359,7 @@ open class Thread : NSObject { let maxSupportedStackDepth = 128; let addrs = UnsafeMutablePointer.allocate(capacity: maxSupportedStackDepth) defer { addrs.deallocate() } -#if os(Android) +#if os(Android) || os(OpenBSD) let count = 0 #elseif os(Windows) let count = RtlCaptureStackBackTrace(0, DWORD(maxSupportedStackDepth), @@ -380,7 +380,7 @@ open class Thread : NSObject { } open class var callStackSymbols: [String] { -#if os(Android) +#if os(Android) || os(OpenBSD) return [] #elseif os(Windows) let hProcess: HANDLE = GetCurrentProcess() diff --git a/Sources/UUID/uuid.c b/Sources/UUID/uuid.c index 004af3de6a..6115754d71 100644 --- a/Sources/UUID/uuid.c +++ b/Sources/UUID/uuid.c @@ -61,7 +61,7 @@ static inline void nanotime(struct timespec *tv) { tv->tv_nsec = now - (tv->tv_sec * 1000000000); } -#elif TARGET_OS_LINUX +#elif TARGET_OS_LINUX || TARGET_OS_BSD #include static inline void nanotime(struct timespec *tv) { diff --git a/Tests/Foundation/Tests/TestSocketPort.swift b/Tests/Foundation/Tests/TestSocketPort.swift index 913645452c..32366ea510 100644 --- a/Tests/Foundation/Tests/TestSocketPort.swift +++ b/Tests/Foundation/Tests/TestSocketPort.swift @@ -27,7 +27,7 @@ class TestSocketPort : XCTestCase { func tcpOrUdpPort(of socketPort: SocketPort) -> Int? { let data = socketPort.address - #if canImport(Darwin) || os(FreeBSD) + #if canImport(Darwin) || os(FreeBSD) || os(OpenBSD) let familyOffset = 1 #else let familyOffset = 0 diff --git a/Tests/Foundation/Tests/TestURL.swift b/Tests/Foundation/Tests/TestURL.swift index 01cc19143c..ca97aeee77 100644 --- a/Tests/Foundation/Tests/TestURL.swift +++ b/Tests/Foundation/Tests/TestURL.swift @@ -132,7 +132,7 @@ class TestURL : XCTestCase { #elseif os(Android) let baseURL = URL(fileURLWithPath: "/data", isDirectory: true) let relativePath = "local" - #elseif os(Linux) + #elseif os(Linux) || os(OpenBSD) let baseURL = URL(fileURLWithPath: "/usr", isDirectory: true) let relativePath = "include" #elseif os(Windows)