62
62
#include < unistd.h> // For syscall()
63
63
#endif
64
64
65
+ #if defined(__CYGWIN__)
66
+ #include < sys/cpuset.h>
67
+ #endif
68
+
65
69
#if defined(__HAIKU__)
66
70
#include < OS.h> // For B_OS_NAME_LENGTH
67
71
#endif
@@ -165,6 +169,8 @@ static constexpr uint32_t get_max_thread_name_length_impl() {
165
169
return 16 ;
166
170
#elif defined(__OpenBSD__)
167
171
return 24 ;
172
+ #elif defined(__CYGWIN__)
173
+ return 16 ;
168
174
#else
169
175
return 0 ;
170
176
#endif
@@ -241,7 +247,7 @@ void llvm::get_thread_name(SmallVectorImpl<char> &Name) {
241
247
}
242
248
free (kp);
243
249
return ;
244
- #elif defined(__linux__) && HAVE_PTHREAD_GETNAME_NP
250
+ #elif ( defined(__linux__) || defined(__CYGWIN__) ) && HAVE_PTHREAD_GETNAME_NP
245
251
constexpr uint32_t len = get_max_thread_name_length_impl ();
246
252
char Buffer[len] = {' \0 ' }; // FIXME: working around MSan false positive.
247
253
if (0 == ::pthread_getname_np (::pthread_self (), Buffer, len))
@@ -263,7 +269,7 @@ void llvm::get_thread_name(SmallVectorImpl<char> &Name) {
263
269
}
264
270
265
271
SetThreadPriorityResult llvm::set_thread_priority (ThreadPriority Priority) {
266
- #if defined(__linux__) && defined(SCHED_IDLE)
272
+ #if ( defined(__linux__) || defined(__CYGWIN__) ) && defined(SCHED_IDLE)
267
273
// Some *really* old glibcs are missing SCHED_IDLE.
268
274
// http://man7.org/linux/man-pages/man3/pthread_setschedparam.3.html
269
275
// http://man7.org/linux/man-pages/man2/sched_setscheduler.2.html
@@ -316,7 +322,7 @@ static int computeHostNumHardwareThreads() {
316
322
if (cpuset_getaffinity (CPU_LEVEL_WHICH, CPU_WHICH_TID, -1 , sizeof (mask),
317
323
&mask) == 0 )
318
324
return CPU_COUNT (&mask);
319
- #elif defined(__linux__)
325
+ #elif ( defined(__linux__) || defined(__CYGWIN__) )
320
326
cpu_set_t Set;
321
327
CPU_ZERO (&Set);
322
328
if (sched_getaffinity (0 , sizeof (Set), &Set) == 0 )
@@ -338,7 +344,8 @@ llvm::BitVector llvm::get_thread_affinity_mask() {
338
344
339
345
unsigned llvm::get_cpus () { return 1 ; }
340
346
341
- #if defined(__linux__) && (defined(__i386__) || defined(__x86_64__))
347
+ #if (defined(__linux__) || defined(__CYGWIN__)) && \
348
+ (defined(__i386__) || defined(__x86_64__))
342
349
// On Linux, the number of physical cores can be computed from /proc/cpuinfo,
343
350
// using the number of unique physical/core id pairs. The following
344
351
// implementation reads the /proc/cpuinfo format on an x86_64 system.
0 commit comments