]> git.ozlabs.org Git - ccan/commitdiff
ccan/compiler: add cpu_supports() macro.
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 11 Jun 2019 04:54:11 +0000 (14:24 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 11 Jun 2019 04:54:11 +0000 (14:24 +0930)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/compiler/compiler.h

index 624474b7e3b9fd030b3c8b953c8e531d14914819..1bbb3b8b61c6cb4a0fd44ab39e5bf7505eaa91bd 100644 (file)
 #define LAST_ARG_NULL
 #endif
 
+#if HAVE_BUILTIN_CPU_SUPPORTS
+/**
+ * cpu_supports - test if current CPU supports the named feature.
+ *
+ * This takes a literal string, and currently only works on glibc platforms.
+ *
+ * Example:
+ * if (cpu_supports("mmx"))
+ *     printf("MMX support engaged!\n");
+ */
+#define cpu_supports(x) __builtin_cpu_supports(x)
+#else
+#define cpu_supports(x) 0
+#endif /* HAVE_BUILTIN_CPU_SUPPORTS */
+
 #endif /* CCAN_COMPILER_H */