This macro checks if the compiler supports one of GCC’s built-in functions; many other compilers also provide those same built-ins.
The BUILTIN parameter is the name of the built-in function.
If BUILTIN is supported define HAVE_<BUILTIN>. Keep in mind that since builtins usually start with two underscores they will be copied over into the HAVE_<BUILTIN> definition (e.g. HAVE___BUILTIN_EXPECT for __builtin_expect()).
The macro caches its result in the ax_cv_have_<BUILTIN> variable (e.g. ax_cv_have___builtin_expect).
The macro currently supports the following built-in functions:
__builtin_assume_aligned __builtin_bswap16 __builtin_bswap32 __builtin_bswap64 __builtin_choose_expr __builtin___clear_cache __builtin_clrsb __builtin_clrsbl __builtin_clrsbll __builtin_clz __builtin_clzl __builtin_clzll __builtin_complex __builtin_constant_p __builtin_cpu_init __builtin_cpu_is __builtin_cpu_supports __builtin_ctz __builtin_ctzl __builtin_ctzll __builtin_expect __builtin_ffs __builtin_ffsl __builtin_ffsll __builtin_fpclassify __builtin_huge_val __builtin_huge_valf __builtin_huge_vall __builtin_inf __builtin_infd128 __builtin_infd32 __builtin_infd64 __builtin_inff __builtin_infl __builtin_isinf_sign __builtin_nan __builtin_nand128 __builtin_nand32 __builtin_nand64 __builtin_nanf __builtin_nanl __builtin_nans __builtin_nansf __builtin_nansl __builtin_object_size __builtin_parity __builtin_parityl __builtin_parityll __builtin_popcount __builtin_popcountl __builtin_popcountll __builtin_powi __builtin_powif __builtin_powil __builtin_prefetch __builtin_trap __builtin_types_compatible_p __builtin_unreachable
Unsupported built-ins will be tested with an empty parameter set and the result of the check might be wrong or meaningless so use with care.
Download the latest version of ax_gcc_builtin.m4 or browse the macro’s revision history.
Copyright © 2013 Gabriele Svelto firstname.lastname@example.org
Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty.