mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-13 06:43:52 +00:00
* Fix #17299 * Comment * Fix typo
This commit is contained in:
@@ -194,8 +194,23 @@ else:
|
||||
proc cpusetIncl(cpu: cint; s: var CpuSet) {.
|
||||
importc: "CPU_SET", header: schedh.}
|
||||
|
||||
proc setAffinity(thread: SysThread; setsize: csize_t; s: var CpuSet) {.
|
||||
importc: "pthread_setaffinity_np", header: pthreadh.}
|
||||
when defined(android):
|
||||
# libc of android doesn't implement pthread_setaffinity_np,
|
||||
# it exposes pthread_gettid_np though, so we can use that in combination
|
||||
# with sched_setaffinity to set the thread affinity.
|
||||
type Pid {.importc: "pid_t", header: "<sys/types.h>".} = int32 # From posix_other.nim
|
||||
|
||||
proc setAffinityTID(tid: Pid; setsize: csize_t; s: var CpuSet) {.
|
||||
importc: "sched_setaffinity", header: schedh.}
|
||||
|
||||
proc pthread_gettid_np(thread: SysThread): Pid {.
|
||||
importc: "pthread_gettid_np", header: pthreadh.}
|
||||
|
||||
proc setAffinity(thread: SysThread; setsize: csize_t; s: var CpuSet) =
|
||||
setAffinityTID(pthread_gettid_np(thread), setsize, s)
|
||||
else:
|
||||
proc setAffinity(thread: SysThread; setsize: csize_t; s: var CpuSet) {.
|
||||
importc: "pthread_setaffinity_np", header: pthreadh.}
|
||||
|
||||
|
||||
const
|
||||
|
||||
Reference in New Issue
Block a user