aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarat Dukhan <maratek@gmail.com>2018-03-15 23:20:11 -0700
committerMarat Dukhan <maratek@gmail.com>2018-03-15 23:20:11 -0700
commit249d314cb9eff44e93ca7ad2015a38ddf684f168 (patch)
tree0e4011bfd9b3608a5d8341e099328e2df401cfd1 /src
parente2a71abf36df01619d152920f60d1e89216bc266 (diff)
downloadcpuinfo-249d314cb9eff44e93ca7ad2015a38ddf684f168.tar.gz
Support building cpuinfo for unsupported platforms and architectures.
- Build will succeed and library can be linked as usual. - CMake will report a warning about unsupported OS/architecture. - CMake will define CPUINFO_SUPPORTED_PLATFORM=0 for targets depending on cpuinfo target (if platform is supported, it defines CPUINFO_SUPPORTED_PLATFORM=1) - cpuinfo_initialize() function will log an error about unsupported OS/architecture and return false. - cpuinfo_get_* functions will return NULL or 0.
Diffstat (limited to 'src')
-rw-r--r--src/init.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/init.c b/src/init.c
index 68b50e1..45cffdc 100644
--- a/src/init.c
+++ b/src/init.c
@@ -6,6 +6,7 @@
#include <cpuinfo.h>
#include <api.h>
+#include <log.h>
#ifdef __APPLE__
#include "TargetConditionals.h"
@@ -27,7 +28,7 @@ bool CPUINFO_ABI cpuinfo_initialize(void) {
#elif defined(_WIN32)
InitOnceExecuteOnce(&init_guard, &cpuinfo_x86_windows_init, NULL, NULL);
#else
- #error Unsupported target OS
+ cpuinfo_log_error("operating system is not supported in cpuinfo");
#endif
#elif CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
#if defined(__linux__)
@@ -35,10 +36,10 @@ bool CPUINFO_ABI cpuinfo_initialize(void) {
#elif defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
pthread_once(&init_guard, &cpuinfo_arm_mach_init);
#else
- #error Unsupported target OS
+ cpuinfo_log_error("operating system is not supported in cpuinfo");
#endif
#else
- #error Unsupported target architecture
+ cpuinfo_log_error("processor architecture is not supported in cpuinfo");
#endif
return (cpuinfo_processors != NULL) && (cpuinfo_cores != NULL) && (cpuinfo_packages != NULL);
}