From 4d9bd7dedf3b0615e62095659c93d68c3d6cb680 Mon Sep 17 00:00:00 2001 From: Daniel Kouchekinia Date: Wed, 19 Jul 2023 02:07:39 -0700 Subject: [PATCH] base: Added missing backup dummy __has_builtin definition (#99) Added dummy definition of __has_builtin to bitfield.hh's hasBuiltinCtz, which is already being done in popCount. Change-Id: I4a1760a142209462bb807c6df4bc868284b6f5f3 --- src/base/bitfield.hh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/base/bitfield.hh b/src/base/bitfield.hh index 8d3721b08a..c2eeb1fb55 100644 --- a/src/base/bitfield.hh +++ b/src/base/bitfield.hh @@ -310,6 +310,13 @@ namespace { template constexpr bool hasBuiltinCtz() { +// Since the defined(__has_builtin) in the subsequent #if statement +// won't short-circuit the macro expansion of +// __has_builtin(__builtin_ctz), we must explicitly define it as zero +// if it's undefined to avoid a preprocessor error. +#ifndef __has_builtin +# define __has_builtin(foo) 0 +#endif #if defined(__has_builtin) && __has_builtin(__builtin_ctz) return sizeof(unsigned long long) >= sizeof(T); #else