Skip to content

Add necessary missing TARGET_OS_BSD directives. #2990

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CoreFoundation/Base.subproj/CFInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ enum {
};
#endif // __has_include(<dispatch/private.h>)

#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
Expand Down
2 changes: 1 addition & 1 deletion CoreFoundation/Base.subproj/CFPlatform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be worth adding a TARGET_OS_OPENBSD?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if it would be worth it. There shouldn't be too many points of divergence. Here, FreeBSD has reallocf and OpenBSD doesn't.

void *mem = realloc(ptr, size);
if (mem == NULL && ptr != NULL && size != 0) {
free(ptr);
Expand Down
6 changes: 3 additions & 3 deletions CoreFoundation/Base.subproj/CFRuntime.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion CoreFoundation/Base.subproj/CFUUID.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions CoreFoundation/Base.subproj/CFUtilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion CoreFoundation/Base.subproj/CoreFoundation_Prefix.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions CoreFoundation/Locale.subproj/CFDateFormatter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Loading