[cfe-dev] How to disable built-in?
sbn at tbricks.com
Tue Apr 24 05:27:18 PDT 2012
On 24.04.2012 15:48, David Chisnall wrote:
> This builtin is also present in GCC 4.7. I suspect that the code brackets it in a version check that tests for a GCC version>= 4.7. Since clang reports the GCC version 4.2, this will fail.
No, in fact it has brackets for (X86 AND GCC):
/* x86/x86_64 gcc */
* x86/gcc Compare exchange for shared latches. i486+
* Returns 1 for success, 0 for failure
* GCC 4.1+ has an equivalent __sync_bool_compare_and_swap() as well as
* __sync_val_compare_and_swap() which returns the value read from *dest
* which configure could be changed to use.
static inline int __atomic_compare_exchange(
db_atomic_t *p, atomic_value_t oldval, atomic_value_t newval)
And check for x86/gcc looks like:
if test "$db_cv_atomic" = no; then
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#if ((defined(i386) || defined(__i386__)) && defined(__GNUC__))
#elif ((defined(x86_64) || defined(__x86_64__)) &&
FAIL TO COMPILE/LINK
if ac_fn_c_try_compile "$LINENO"; then :
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
> The correct fix is to wrap the check in !__has_builtin(__atomic_compare_exchange), rather than a specific compiler version. A more hacky work-around would be to #undef the GCC version macros before including this header and re#define them as gcc 4.7.
I think __has_builtin() itself should be bracketed by ifdef __GNUC__
(probably with specific version?).
So looks like the easiest way is to rename the function.
More information about the cfe-dev