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 | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c index a7114825118..5eaf3bf85b8 100644 --- a/dlls/ntdll/unix/thread.c +++ b/dlls/ntdll/unix/thread.c @@ -2563,6 +2563,12 @@ 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)); + return (ULONG)(p.p1 & 0xfff); #endif
if (peb->NumberOfProcessors > 1)