Skip to content
This repository was archived by the owner on Jan 26, 2024. It is now read-only.

Commit d9f8976

Browse files
committed
Fixes for musl support
1 parent 90af834 commit d9f8976

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

os/os.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,17 @@
2929

3030
#if defined(__linux__)
3131
#include <sched.h>
32+
#include <libgen.h>
3233
#endif
3334

3435
#ifdef _WIN32
3536
#include <Basetsd.h> // For KAFFINITY
3637
#endif // _WIN32
3738

39+
#ifndef __cpu_mask
40+
typedef unsigned long __cpu_mask;
41+
#endif
42+
3843
// Smallest supported VM page size.
3944
#define MIN_PAGE_SHIFT 12
4045
#define MIN_PAGE_SIZE (1UL << MIN_PAGE_SHIFT)

os/os_posix.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,15 +374,22 @@ const void* Os::createOsThread(amd::Thread* thread) {
374374
for (int i = 0; i < processorCount_; i++) {
375375
CPU_SET(i, &cpuset);
376376
}
377+
#ifdef pthread_attr_setaffinity_np
377378
if (0 != pthread_attr_setaffinity_np(&threadAttr, sizeof(cpu_set_t), &cpuset)) {
378379
fatal("pthread_attr_setaffinity_np failed to set affinity");
379380
}
381+
#endif
380382
}
381383

382384
pthread_t handle = 0;
383385
if (0 != ::pthread_create(&handle, &threadAttr, (void* (*)(void*)) & Thread::entry, thread)) {
384386
thread->setState(Thread::FAILED);
385387
}
388+
#ifndef pthread_attr_setaffinity_np
389+
if (0 != pthread_setaffinity_np(handle, sizeof(cpu_set_t), &cpuset)) {
390+
fatal("pthread_attr_setaffinity_np failed to set affinity");
391+
}
392+
#endif
386393

387394
::pthread_attr_destroy(&threadAttr);
388395
return reinterpret_cast<const void*>(handle);

0 commit comments

Comments
 (0)