From: Marc-Aurel Zent mzent@codeweavers.com
See _os_cpu_number at xnu/libsyscall/os/tsd.h. The arm and arm64 implementations are not stable across kernel releases (yet). --- dlls/ntdll/unix/thread.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c index a7114825118..d0fdc37171a 100644 --- a/dlls/ntdll/unix/thread.c +++ b/dlls/ntdll/unix/thread.c @@ -2563,6 +2563,13 @@ ULONG WINAPI NtGetCurrentProcessorNumber(void) #if defined(__linux__) && defined(__NR_getcpu) int res = syscall(__NR_getcpu, &processor, NULL, NULL); if (res != -1) return processor; +#elif defined(__APPLE__) && (defined(__x86_64__) || defined(__i386__)) + struct { + unsigned long p1, p2; + } p; + __asm__ __volatile__("sidt %[p]" : [p] "=&m"(p)); + processor = (ULONG)(p.p1 & 0xfff); + return processor; #endif
if (peb->NumberOfProcessors > 1)