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