From 4a96df73e770bcca6396d3c8ffe3fd1693c73e50 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Sun, 21 Sep 2014 17:25:49 -0700 Subject: mesa: Replace a priori knowledge of gcc builtins with configure tests. Presumbly this will let clang and other compilers use the built-ins as well. Notice two changes specifically: - in _mesa_next_pow_two_64(), always use __builtin_clzll and add a static assertion that this is safe. - in macros.h, remove the clang-specific definition since it should be able to detect __builtin_unreachable in configure. Reviewed-by: Jason Ekstrand [C bits] Reviewed-by: Ian Romanick --- scons/gallium.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'scons') diff --git a/scons/gallium.py b/scons/gallium.py index 1dcfa6b243c..ef6df1ae1a9 100755 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -583,6 +583,24 @@ def generate(env): env.Append(CCFLAGS = ['-fopenmp']) env.Append(LIBS = ['gomp']) + if gcc_compat: + ccversion = env['CCVERSION'] + cppdefines += [ + 'HAVE___BUILTIN_EXPECT', + 'HAVE___BUILTIN_FFS', + 'HAVE___BUILTIN_FFSLL', + ] + if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('3.4'): + cppdefines += [ + 'HAVE___BUILTIN_CTZ', + 'HAVE___BUILTIN_POPCOUNT', + 'HAVE___BUILTIN_POPCOUNTLL', + 'HAVE___BUILTIN_CLZ', + 'HAVE___BUILTIN_CLZLL', + ] + if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.5'): + cppdefines += ['HAVE___BUILTIN_UNREACHABLE'] + # Load tools env.Tool('lex') env.Tool('yacc') -- cgit v1.2.3