1 #ifdef _WIN32 2 #include <windows.h> 3 #else 4 #include <pthread.h> 5 #endif 6 7 #include <cpuinfo.h> 8 #include <cpuinfo/internal-api.h> 9 #include <cpuinfo/log.h> 10 11 #ifdef __APPLE__ 12 #include "TargetConditionals.h" 13 #endif 14 15 16 #ifdef _WIN32 17 static INIT_ONCE init_guard = INIT_ONCE_STATIC_INIT; 18 #else 19 static pthread_once_t init_guard = PTHREAD_ONCE_INIT; 20 #endif 21 cpuinfo_initialize(void)22bool CPUINFO_ABI cpuinfo_initialize(void) { 23 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 24 #if defined(__MACH__) && defined(__APPLE__) 25 pthread_once(&init_guard, &cpuinfo_x86_mach_init); 26 #elif defined(__linux__) 27 pthread_once(&init_guard, &cpuinfo_x86_linux_init); 28 #elif defined(_WIN32) 29 InitOnceExecuteOnce(&init_guard, &cpuinfo_x86_windows_init, NULL, NULL); 30 #else 31 cpuinfo_log_error("operating system is not supported in cpuinfo"); 32 #endif 33 #elif CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 34 #if defined(__linux__) 35 pthread_once(&init_guard, &cpuinfo_arm_linux_init); 36 #elif defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE 37 pthread_once(&init_guard, &cpuinfo_arm_mach_init); 38 #else 39 cpuinfo_log_error("operating system is not supported in cpuinfo"); 40 #endif 41 #else 42 cpuinfo_log_error("processor architecture is not supported in cpuinfo"); 43 #endif 44 return cpuinfo_is_initialized; 45 } 46 cpuinfo_deinitialize(void)47void CPUINFO_ABI cpuinfo_deinitialize(void) { 48 } 49