From ae98e87222f7265b20252984c3647373825d0628 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 26 Aug 2018 19:55:02 -0400 Subject: [PATCH] Fix OS X compile issues, bug1332. --- include/verilated_threads.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/include/verilated_threads.h b/include/verilated_threads.h index 341f2e52d..d7199b543 100644 --- a/include/verilated_threads.h +++ b/include/verilated_threads.h @@ -29,6 +29,9 @@ #include #include #include // For sched_getcpu() +#if defined(__APPLE__) +# include // For __cpuid_count() +#endif #include "verilated.h" // for VerilatedMutex and clang annotations @@ -193,13 +196,13 @@ public: #if defined(__linux) return sched_getcpu(); #elif defined(__APPLE__) - uint32_t CPUInfo[4]; - CPUID(CPUInfo, 1, 0); - /* CPUInfo[1] is EBX, bits 24-31 are APIC ID */ - if ((CPUInfo[3] & (1 << 9)) == 0) { + uint32_t info[4]; + __cpuid_count(1, 0, info[0], info[1], info[2], info[3]) + /* info[1] is EBX, bits 24-31 are APIC ID */ + if ((info[3] & (1 << 9)) == 0) { return -1; /* no APIC on chip */ } else { - return (unsigned)CPUInfo[1] >> 24; + return (unsigned)info[1] >> 24; } #else return 0;