Skip to content

Commit

Permalink
DEPLOYMENT_TARGET_LINUX -> TARGET_OS_LINUX
Browse files Browse the repository at this point in the history
  • Loading branch information
compnerd committed May 10, 2019
1 parent db68efd commit 08b260e
Show file tree
Hide file tree
Showing 38 changed files with 179 additions and 181 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ if(FOUNDATION_ENABLE_LIBDISPATCH)
endif()

if(CMAKE_SYSTEM_NAME STREQUAL Android OR CMAKE_SYSTEM_NAME STREQUAL Linux)
set(deployment_target -DDEPLOYMENT_TARGET_LINUX)
set(Foundation_RPATH -Xlinker;-rpath;-Xlinker;"\\\$\$ORIGIN")
set(XDG_TEST_HELPER_RPATH -Xlinker;-rpath;-Xlinker;${CMAKE_CURRENT_BINARY_DIR})
elseif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
Expand Down
12 changes: 6 additions & 6 deletions CoreFoundation/Base.subproj/CFFileUtilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ CF_PRIVATE CFMutableArrayRef _CFCreateContentsOfDirectory(CFAllocatorRef alloc,
FindClose(handle);
pathBuf[pathLength] = '\0';

#elif TARGET_OS_OSX || TARGET_OS_IPHONE || DEPLOYMENT_TARGET_LINUX || TARGET_OS_BSD
#elif TARGET_OS_OSX || TARGET_OS_IPHONE || TARGET_OS_LINUX || TARGET_OS_BSD
uint8_t extBuff[CFMaxPathSize];
int extBuffInteriorDotCount = 0; //people insist on using extensions like ".trace.plist", so we need to know how many dots back to look :(

Expand Down Expand Up @@ -452,13 +452,13 @@ CF_PRIVATE CFMutableArrayRef _CFCreateContentsOfDirectory(CFAllocatorRef alloc,
isDir = ((statBuf.st_mode & S_IFMT) == S_IFDIR);
}
}
#if DEPLOYMENT_TARGET_LINUX
#if TARGET_OS_LINUX
fileURL = CFURLCreateFromFileSystemRepresentationRelativeToBase(alloc, (uint8_t *)dp->d_name, namelen, isDir, dirURL);
#else
fileURL = CFURLCreateFromFileSystemRepresentationRelativeToBase(alloc, (uint8_t *)dp->d_name, dp->d_namlen, isDir, dirURL);
#endif
} else {
#if DEPLOYMENT_TARGET_LINUX
#if TARGET_OS_LINUX
fileURL = CFURLCreateFromFileSystemRepresentationRelativeToBase (alloc, (uint8_t *)dp->d_name, namelen, false, dirURL);
#else
fileURL = CFURLCreateFromFileSystemRepresentationRelativeToBase (alloc, (uint8_t *)dp->d_name, dp->d_namlen, false, dirURL);
Expand Down Expand Up @@ -545,7 +545,7 @@ CF_PRIVATE SInt32 _CFGetPathProperties(CFAllocatorRef alloc, char *path, Boolean

if (modTime != NULL) {
if (fileExists) {
#if DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
#if DEPLOYMENT_TARGET_WINDOWS || TARGET_OS_LINUX
struct timespec ts = {statBuf.st_mtime, 0};
#else
struct timespec ts = statBuf.st_mtimespec;
Expand Down Expand Up @@ -1072,7 +1072,7 @@ CF_PRIVATE void _CFIterateDirectory(CFStringRef directoryPath, Boolean appendSla
struct dirent *dent;
if ((dirp = opendir(directoryPathBuf))) {
while ((dent = readdir(dirp))) {
#if DEPLOYMENT_TARGET_LINUX
#if TARGET_OS_LINUX
CFIndex nameLen = strlen(dent->d_name);
if (dent->d_type == DT_UNKNOWN) {
// on some old file systems readdir may always fill d_type as DT_UNKNOWN (0), double check with stat
Expand Down Expand Up @@ -1141,7 +1141,7 @@ CF_PRIVATE void _CFIterateDirectory(CFStringRef directoryPath, Boolean appendSla
if (dent->d_type == DT_DIR) {
isDirectory = true;
}
#if TARGET_OS_OSX || TARGET_OS_IPHONE || DEPLOYMENT_TARGET_LINUX || TARGET_OS_BSD
#if TARGET_OS_OSX || TARGET_OS_IPHONE || TARGET_OS_LINUX || TARGET_OS_BSD
else if (dent->d_type == DT_UNKNOWN) {
// We need to do an additional stat on this to see if it's really a directory or not.
// This path should be uncommon.
Expand Down
8 changes: 4 additions & 4 deletions CoreFoundation/Base.subproj/CFInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ CF_EXPORT void * __CFConstantStringClassReferencePtr;

#if DEPLOYMENT_RUNTIME_SWIFT && TARGET_OS_MAC

#if DEPLOYMENT_TARGET_LINUX
#if TARGET_OS_LINUX
#define CONST_STRING_SECTION __attribute__((section(".cfstr.data")))
#else
#define CONST_STRING_SECTION
Expand Down Expand Up @@ -543,7 +543,7 @@ CF_INLINE Boolean __CFLockTry(volatile CFLock_t *lock) {
return (InterlockedCompareExchange((LONG volatile *)lock, ~0, 0) == 0);
}

#elif DEPLOYMENT_TARGET_LINUX || TARGET_OS_BSD
#elif TARGET_OS_LINUX || TARGET_OS_BSD

typedef int32_t CFLock_t;
#define CFLockInit 0
Expand Down Expand Up @@ -971,7 +971,7 @@ CF_EXPORT bool _NS_pthread_equal(_CFThreadRef t1, _CFThreadRef t2);

#endif

#if DEPLOYMENT_TARGET_LINUX
#if TARGET_OS_LINUX
#define pthread_main_np _CFIsMainThread
#endif

Expand Down Expand Up @@ -1026,7 +1026,7 @@ enum {
};
#endif

#if DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_WINDOWS
#if TARGET_OS_LINUX || DEPLOYMENT_TARGET_WINDOWS
#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
26 changes: 13 additions & 13 deletions CoreFoundation/Base.subproj/CFPlatform.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const char *_CFProcessPath(void) {
}
#endif

#if DEPLOYMENT_TARGET_LINUX
#if TARGET_OS_LINUX
#include <unistd.h>
#if __has_include(<syscall.h>)
#include <syscall.h>
Expand Down Expand Up @@ -206,7 +206,7 @@ CF_PRIVATE CFStringRef _CFProcessNameString(void) {
}


#if TARGET_OS_OSX || TARGET_OS_IPHONE || DEPLOYMENT_TARGET_LINUX || TARGET_OS_BSD
#if TARGET_OS_OSX || TARGET_OS_IPHONE || TARGET_OS_LINUX || TARGET_OS_BSD

#include <pwd.h>
#include <sys/param.h>
Expand Down Expand Up @@ -262,7 +262,7 @@ CF_EXPORT CFStringRef CFGetUserName(void) {

CF_EXPORT CFStringRef CFCopyUserName(void) {
CFStringRef result = NULL;
#if TARGET_OS_OSX || TARGET_OS_IPHONE || DEPLOYMENT_TARGET_LINUX || TARGET_OS_BSD
#if TARGET_OS_OSX || TARGET_OS_IPHONE || TARGET_OS_LINUX || TARGET_OS_BSD
uid_t euid;
__CFGetUGIDs(&euid, NULL);
struct passwd *upwd = getpwuid(euid ? euid : getuid());
Expand Down Expand Up @@ -332,7 +332,7 @@ CF_CROSS_PLATFORM_EXPORT CFStringRef CFCopyFullUserName(void) {


CFURLRef CFCopyHomeDirectoryURL(void) {
#if TARGET_OS_OSX || TARGET_OS_IPHONE || DEPLOYMENT_TARGET_LINUX || TARGET_OS_BSD
#if TARGET_OS_OSX || TARGET_OS_IPHONE || TARGET_OS_LINUX || TARGET_OS_BSD
return _CFCopyHomeDirURLForUser(NULL, true);
#elif DEPLOYMENT_TARGET_WINDOWS
CFURLRef retVal = NULL;
Expand Down Expand Up @@ -412,7 +412,7 @@ CF_EXPORT CFURLRef CFCopyHomeDirectoryURLForUser(CFStringRef uName) {
}
}
#endif
#if TARGET_OS_OSX || TARGET_OS_IPHONE || DEPLOYMENT_TARGET_LINUX || TARGET_OS_BSD
#if TARGET_OS_OSX || TARGET_OS_IPHONE || TARGET_OS_LINUX || TARGET_OS_BSD
if (!uName) {
return _CFCopyHomeDirURLForUser(NULL, true);
} else {
Expand Down Expand Up @@ -614,7 +614,7 @@ CF_PRIVATE void __CFTSDInitialize() {
static void __CFTSDSetSpecific(void *arg) {
#if TARGET_OS_OSX || TARGET_OS_IPHONE
pthread_setspecific(__CFTSDIndexKey, arg);
#elif DEPLOYMENT_TARGET_LINUX
#elif TARGET_OS_LINUX
pthread_setspecific(__CFTSDIndexKey, arg);
#elif DEPLOYMENT_TARGET_WINDOWS
FlsSetValue(__CFTSDIndexKey, arg);
Expand All @@ -624,7 +624,7 @@ static void __CFTSDSetSpecific(void *arg) {
static void *__CFTSDGetSpecific() {
#if TARGET_OS_OSX || TARGET_OS_IPHONE
return pthread_getspecific(__CFTSDIndexKey);
#elif DEPLOYMENT_TARGET_LINUX
#elif TARGET_OS_LINUX
return pthread_getspecific(__CFTSDIndexKey);
#elif DEPLOYMENT_TARGET_WINDOWS
return FlsGetValue(__CFTSDIndexKey);
Expand Down Expand Up @@ -1182,7 +1182,7 @@ CF_PRIVATE int _NS_gettimeofday(struct timeval *tv, struct timezone *tz) {
#pragma mark -
#pragma mark Linux OSAtomic

#if defined(DEPLOYMENT_TARGET_LINUX) || TARGET_OS_BSD
#if TARGET_OS_LINUX || TARGET_OS_BSD

bool OSAtomicCompareAndSwapPtr(void *oldp, void *newp, void *volatile *dst)
{
Expand Down Expand Up @@ -1237,7 +1237,7 @@ void OSMemoryBarrier() {
__sync_synchronize();
}

#endif // DEPLOYMENT_TARGET_LINUX
#endif // TARGET_OS_LINUX

#pragma mark -
#pragma mark Dispatch Replacements
Expand Down Expand Up @@ -1348,7 +1348,7 @@ void _CF_dispatch_once(dispatch_once_t *predicate, void (^block)(void)) {
#pragma mark -
#pragma mark Windows and Linux Helpers

#if DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
#if DEPLOYMENT_TARGET_WINDOWS || TARGET_OS_LINUX

#include <stdio.h>

Expand Down Expand Up @@ -1483,15 +1483,15 @@ CF_CROSS_PLATFORM_EXPORT int _CFThreadSetName(_CFThreadRef thread, const char *_
}

return 0;
#elif DEPLOYMENT_TARGET_LINUX
#elif TARGET_OS_LINUX
return pthread_setname_np(thread, name);
#endif
}

CF_CROSS_PLATFORM_EXPORT int _CFThreadGetName(char *buf, int length) {
#if TARGET_OS_OSX || TARGET_OS_IPHONE
return pthread_getname_np(pthread_self(), buf, length);
#elif DEPLOYMENT_TARGET_LINUX
#elif TARGET_OS_LINUX
return pthread_getname_np(pthread_self(), buf, length);
#endif
return -1;
Expand All @@ -1516,7 +1516,7 @@ int _CFOpenFile(const char *path, int opts) {
}

CF_CROSS_PLATFORM_EXPORT void *_CFReallocf(void *ptr, size_t size) {
#if TARGET_OS_WIN32 || DEPLOYMENT_TARGET_LINUX
#if TARGET_OS_WIN32 || TARGET_OS_LINUX
void *mem = realloc(ptr, size);
if (mem == NULL && ptr != NULL && size != 0) {
free(ptr);
Expand Down
8 changes: 4 additions & 4 deletions CoreFoundation/Base.subproj/CFRuntime.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ __kCFRetainEvent = 28,
__kCFReleaseEvent = 29
};

#if DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
#if DEPLOYMENT_TARGET_WINDOWS || TARGET_OS_LINUX
#include <malloc.h>
#elif TARGET_OS_BSD
#include <stdlib.h> // malloc()
Expand Down Expand Up @@ -406,7 +406,7 @@ CF_INLINE CFRuntimeBase *_cf_aligned_malloc(size_t align, CFIndex size, const ch

#if TARGET_OS_OSX || TARGET_OS_IPHONE
memory = malloc_zone_memalign(malloc_default_zone(), align, size);
#elif DEPLOYMENT_TARGET_LINUX
#elif TARGET_OS_LINUX
int result = posix_memalign((void **)&memory, /*alignment*/ align, size);
int error = errno;
enum { errorStringBufferLength = 64 };
Expand Down Expand Up @@ -1094,7 +1094,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 DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
#if DEPLOYMENT_TARGET_WINDOWS || TARGET_OS_LINUX

CF_EXPORT _CFThreadRef _CF_pthread_main_thread_np(void);
_CFThreadRef _CF_pthread_main_thread_np(void) {
Expand All @@ -1106,7 +1106,7 @@ _CFThreadRef _CF_pthread_main_thread_np(void) {



#if DEPLOYMENT_TARGET_LINUX || TARGET_OS_BSD
#if TARGET_OS_LINUX || TARGET_OS_BSD
static void __CFInitialize(void) __attribute__ ((constructor));
static
#endif
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 @@ -151,7 +151,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_OSX || TARGET_OS_IPHONE || DEPLOYMENT_TARGET_LINUX
#elif TARGET_OS_OSX || TARGET_OS_IPHONE || TARGET_OS_LINUX
static Boolean useV1UUIDs = false, checked = false;
uuid_t uuid;
if (!checked) {
Expand Down
14 changes: 7 additions & 7 deletions CoreFoundation/Base.subproj/CFUtilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#include <os/lock.h>
#endif

#if DEPLOYMENT_TARGET_LINUX || TARGET_OS_BSD
#if TARGET_OS_LINUX || TARGET_OS_BSD
#include <string.h>
#include <sys/mman.h>
#endif
Expand All @@ -71,7 +71,7 @@
#include <pthread.h>
#endif

#if DEPLOYMENT_TARGET_LINUX
#if TARGET_OS_LINUX
#ifdef HAVE_SCHED_GETAFFINITY
#include <sched.h>
#endif
Expand Down Expand Up @@ -448,7 +448,7 @@ CF_PRIVATE CFIndex __CFActiveProcessorCount() {
if (result != 0) {
pcnt = 0;
}
#elif DEPLOYMENT_TARGET_LINUX
#elif TARGET_OS_LINUX

#ifdef HAVE_SCHED_GETAFFINITY
cpu_set_t set;
Expand All @@ -475,7 +475,7 @@ CF_PRIVATE CFIndex __CFProcessorCount() {
if (result != 0) {
pcnt = 0;
}
#elif DEPLOYMENT_TARGET_LINUX
#elif TARGET_OS_LINUX
pcnt = sysconf(_SC_NPROCESSORS_CONF);
#else
// Assume the worst
Expand All @@ -493,7 +493,7 @@ CF_PRIVATE uint64_t __CFMemorySize() {
if (result != 0) {
memsize = 0;
}
#elif DEPLOYMENT_TARGET_LINUX
#elif TARGET_OS_LINUX
memsize = sysconf(_SC_PHYS_PAGES);
memsize *= sysconf(_SC_PAGESIZE);
#endif
Expand Down Expand Up @@ -712,7 +712,7 @@ typedef enum {

static bool also_do_stderr(const _cf_logging_style style) {
bool result = false;
#if DEPLOYMENT_TARGET_LINUX
#if TARGET_OS_LINUX
// just log to stderr, other logging facilities are out
result = true;
#elif TARGET_OS_OSX || TARGET_OS_IPHONE
Expand Down Expand Up @@ -1232,7 +1232,7 @@ CF_PRIVATE Boolean _CFReadMappedFromFile(CFStringRef path, Boolean map, Boolean
if (0LL == statBuf.st_size) {
bytes = malloc(8); // don't return constant string -- it's freed!
length = 0;
#if TARGET_OS_OSX || TARGET_OS_IPHONE || DEPLOYMENT_TARGET_LINUX || TARGET_OS_BSD
#if TARGET_OS_OSX || TARGET_OS_IPHONE || TARGET_OS_LINUX || TARGET_OS_BSD
} else if (map) {
if((void *)-1 == (bytes = mmap(0, (size_t)statBuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0))) {
int32_t savederrno = errno;
Expand Down
8 changes: 4 additions & 4 deletions CoreFoundation/Base.subproj/CoreFoundation_Prefix.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ typedef int boolean_t;
#include <sys/stat.h> // mode_t
#endif

#if DEPLOYMENT_TARGET_LINUX
#if TARGET_OS_LINUX

#define CF_PRIVATE extern __attribute__((visibility("hidden")))
#define __weak
Expand Down Expand Up @@ -260,10 +260,10 @@ void OSMemoryBarrier();

#endif

#if DEPLOYMENT_TARGET_LINUX
#if TARGET_OS_LINUX
#include <sys/param.h>
#endif
#if DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
#if DEPLOYMENT_TARGET_WINDOWS || TARGET_OS_LINUX
#if !defined(ABS)
#define ABS(A) ((A) < 0 ? (-(A)) : (A))
#endif
Expand Down Expand Up @@ -454,7 +454,7 @@ CF_EXPORT int64_t OSAtomicAdd64Barrier( int64_t __theAmount, volatile int64_t *_
#define CF_TEST_PRIVATE CF_PRIVATE
#endif

#if DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_WINDOWS
#if TARGET_OS_LINUX || DEPLOYMENT_TARGET_WINDOWS

#include <stdarg.h>

Expand Down
2 changes: 1 addition & 1 deletion CoreFoundation/Base.subproj/ForFoundationOnly.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ CF_IMPLICIT_BRIDGING_DISABLED

// ---- CFRuntime material ----------------------------------------

#if DEPLOYMENT_TARGET_LINUX
#if TARGET_OS_LINUX
#include <malloc.h>
#elif TARGET_OS_BSD
#include <stdlib.h> // malloc()
Expand Down
1 change: 0 additions & 1 deletion CoreFoundation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ endif()
if(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL Android)
target_compile_definitions(CoreFoundation
PRIVATE
-DDEPLOYMENT_TARGET_LINUX
-D_GNU_SOURCE)
if(HAVE_SCHED_GETAFFINITY)
target_compile_definitions(CoreFoundation
Expand Down
2 changes: 1 addition & 1 deletion CoreFoundation/Collections.subproj/CFData.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ CF_INLINE unsigned long __CFPageSize() {
GetSystemInfo(&sysInfo);
return sysInfo.dwPageSize;
}
#elif DEPLOYMENT_TARGET_LINUX
#elif TARGET_OS_LINUX
#include <unistd.h>
CF_INLINE unsigned long __CFPageSize() {
return (unsigned long)getpagesize();
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 @@ -1557,7 +1557,7 @@ static UDate __CFDateFormatterCorrectTimeToARangeAroundCurrentDate(UCalendar *ca
return __CFDateFormatterCorrectTimeWithTarget(calendar, at, currEraOrCentury+offset, isEra, status);
}

#if TARGET_OS_OSX || TARGET_OS_IPHONE || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
#if TARGET_OS_OSX || TARGET_OS_IPHONE || DEPLOYMENT_TARGET_WINDOWS || TARGET_OS_LINUX
static int32_t __CFDateFormatterGetMaxYearGivenJapaneseEra(UCalendar *calendar, int32_t era, UErrorCode *status) {
int32_t years = 0;
__cficu_ucal_clear(calendar);
Expand Down Expand Up @@ -1610,7 +1610,7 @@ static Boolean __CFDateFormatterHandleAmbiguousYear(CFDateFormatterRef formatter
}
}
} else if (calendar_id == kCFCalendarIdentifierJapanese) { // ??? need more work
#if TARGET_OS_OSX || TARGET_OS_IPHONE || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
#if TARGET_OS_OSX || TARGET_OS_IPHONE || DEPLOYMENT_TARGET_WINDOWS || TARGET_OS_LINUX
__cficu_ucal_clear(cal);
__cficu_ucal_set(cal, UCAL_ERA, 1);
__cficu_udat_parseCalendar(df, cal, ustr, length, NULL, status);
Expand Down
Loading

0 comments on commit 08b260e

Please sign in to comment.