File tree Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,14 @@ include(SwiftSupport)
24
24
include (GNUInstallDirs )
25
25
include (ExternalProject )
26
26
27
+ if (CMAKE_SYSTEM_NAME STREQUAL Linux )
28
+ include (CheckSymbolExists )
29
+ include (CheckIncludeFile )
30
+ list (APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE )
31
+ check_include_file ("sched.h" HAVE_SCHED_H )
32
+ check_symbol_exists (sched_getaffinity "sched.h" HAVE_SCHED_GETAFFINITY )
33
+ endif ()
34
+
27
35
string (TOLOWER ${CMAKE_SYSTEM_NAME} swift_os )
28
36
get_swift_host_arch (swift_arch )
29
37
Original file line number Diff line number Diff line change 71
71
#include <pthread.h>
72
72
#endif
73
73
74
- #if DEPLOYMENT_TARGET_LINUX && __has_include (< sched .h > )
74
+ #if DEPLOYMENT_TARGET_LINUX
75
+ #ifdef HAVE_SCHED_GETAFFINITY
75
76
#include <sched.h>
76
77
#endif
78
+ #endif
77
79
78
80
79
81
#if !defined(CF_HAVE_HW_CONFIG_COMMPAGE ) && defined(_COMM_PAGE_LOGICAL_CPUS ) && defined(_COMM_PAGE_PHYSICAL_CPUS ) && defined(_COMM_PAGE_ACTIVE_CPUS ) && !__has_feature (address_sanitizer )
@@ -455,7 +457,7 @@ CF_PRIVATE CFIndex __CFActiveProcessorCount() {
455
457
}
456
458
#elif DEPLOYMENT_TARGET_LINUX
457
459
458
- #ifdef _SCHED_H
460
+ #ifdef HAVE_SCHED_GETAFFINITY
459
461
cpu_set_t set ;
460
462
if (sched_getaffinity (getpid (), sizeof (set ), & set ) == 0 ) {
461
463
return CPU_COUNT (& set );
Original file line number Diff line number Diff line change @@ -337,6 +337,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL Android)
337
337
PRIVATE
338
338
-DDEPLOYMENT_TARGET_LINUX
339
339
-D_GNU_SOURCE )
340
+ if (HAVE_SCHED_GETAFFINITY )
341
+ target_compile_definitions (CoreFoundation
342
+ PRIVATE
343
+ -DHAVE_SCHED_GETAFFINITY )
344
+ endif ()
340
345
elseif (CMAKE_SYSTEM_NAME STREQUAL FreeBSD )
341
346
target_compile_definitions (CoreFoundation
342
347
PRIVATE
@@ -516,4 +521,3 @@ install(DIRECTORY
516
521
${CMAKE_INSTALL_PREFIX} /System/Library/Frameworks
517
522
USE_SOURCE_PERMISSIONS
518
523
PATTERN PrivateHeaders EXCLUDE )
519
-
You can’t perform that action at this time.
0 commit comments