X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fcompiler%2Fcompiler.h;h=1bbb3b8b61c6cb4a0fd44ab39e5bf7505eaa91bd;hb=42d7b648bd295e2204c5d064256fb1ad382b41c9;hp=624474b7e3b9fd030b3c8b953c8e531d14914819;hpb=9f06b8f85927202c05751e43f285cbef8054052b;p=ccan diff --git a/ccan/compiler/compiler.h b/ccan/compiler/compiler.h index 624474b7..1bbb3b8b 100644 --- a/ccan/compiler/compiler.h +++ b/ccan/compiler/compiler.h @@ -286,4 +286,19 @@ #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 */