aboutsummaryrefslogtreecommitdiff
path: root/include/cpu_features_macros.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/cpu_features_macros.h')
-rw-r--r--include/cpu_features_macros.h39
1 files changed, 36 insertions, 3 deletions
diff --git a/include/cpu_features_macros.h b/include/cpu_features_macros.h
index 4b231a1..6a2f76a 100644
--- a/include/cpu_features_macros.h
+++ b/include/cpu_features_macros.h
@@ -67,20 +67,33 @@
// Os
////////////////////////////////////////////////////////////////////////////////
-#if defined(__linux__)
-#define CPU_FEATURES_OS_LINUX_OR_ANDROID
+#if (defined(__freebsd__) || defined(__FreeBSD__))
+#define CPU_FEATURES_OS_FREEBSD
#endif
#if defined(__ANDROID__)
#define CPU_FEATURES_OS_ANDROID
#endif
+#if defined(__linux__) && !defined(CPU_FEATURES_OS_FREEBSD) && \
+ !defined(CPU_FEATURES_OS_ANDROID)
+#define CPU_FEATURES_OS_LINUX
+#endif
+
#if (defined(_WIN64) || defined(_WIN32))
#define CPU_FEATURES_OS_WINDOWS
#endif
#if (defined(__apple__) || defined(__APPLE__) || defined(__MACH__))
-#define CPU_FEATURES_OS_DARWIN
+// From https://stackoverflow.com/a/49560690
+#include "TargetConditionals.h"
+#if defined(TARGET_OS_OSX)
+#define CPU_FEATURES_OS_MACOS
+#endif
+#if defined(TARGET_OS_IPHONE)
+// This is set for any non-Mac Apple products (IOS, TV, WATCH)
+#define CPU_FEATURES_OS_IPHONE
+#endif
#endif
////////////////////////////////////////////////////////////////////////////////
@@ -213,4 +226,24 @@
#endif // defined(__mips_msa)
#endif // defined(CPU_FEATURES_ARCH_MIPS)
+////////////////////////////////////////////////////////////////////////////////
+// Utils
+////////////////////////////////////////////////////////////////////////////////
+
+// Communicates to the compiler that the block is unreachable
+#if defined(CPU_FEATURES_COMPILER_CLANG) || defined(CPU_FEATURES_COMPILER_GCC)
+#define CPU_FEATURES_UNREACHABLE() __builtin_unreachable()
+#elif defined(CPU_FEATURES_COMPILER_MSC)
+#define CPU_FEATURES_UNREACHABLE() __assume(0)
+#else
+#define CPU_FEATURES_UNREACHABLE()
+#endif
+
+// Communicates to the compiler that the function is now deprecated
+#if defined(CPU_FEATURES_COMPILER_CLANG) || defined(CPU_FEATURES_COMPILER_GCC)
+#define CPU_FEATURES_DEPRECATED(message) __attribute__((deprecated(message)))
+#else
+#define CPU_FEATURES_DEPRECATED(message)
+#endif
+
#endif // CPU_FEATURES_INCLUDE_CPU_FEATURES_MACROS_H_