From 119e35b79127c7688d8782635fbe1a9642a851bc Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Wed, 5 Oct 2016 16:27:46 +0900 Subject: [PATCH] eina: Fix compilation with clang It's not because the bug with __builtin_prefetch is inside clang/llvm that we must break the build for people who prefer it over gcc. As soon as a non-broken version is out, the ifdef must be either removed (and ask people to update their clang install) or add a version check based on __clang_xxx__. Compilation tested with clang 3.8.1 and gcc 6.2.1. --- src/lib/eina/eina_types.h | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/lib/eina/eina_types.h b/src/lib/eina/eina_types.h index 139dafa..fc01c69 100644 --- a/src/lib/eina/eina_types.h +++ b/src/lib/eina/eina_types.h @@ -193,10 +193,18 @@ # define EINA_UNLIKELY(exp) __builtin_expect((exp), 0) # define EINA_LIKELY(exp) __builtin_expect((exp), 1) # define EINA_SENTINEL __attribute__((__sentinel__)) -# define EINA_PREFETCH(arg) __builtin_prefetch(arg) -# define EINA_PREFETCH_WRITE(arg) __builtin_prefetch(arg, 1) -# define EINA_PREFETCH_NOCACHE(arg) __builtin_prefetch(arg, 0, 0) -# define EINA_PREFETCH_NOCACHE_WRITE(arg) __builtin_prefetch(arg, 1, 0) +# ifndef __clang__ +# define EINA_PREFETCH(arg) __builtin_prefetch(arg) +# define EINA_PREFETCH_WRITE(arg) __builtin_prefetch(arg, 1) +# define EINA_PREFETCH_NOCACHE(arg) __builtin_prefetch(arg, 0, 0) +# define EINA_PREFETCH_NOCACHE_WRITE(arg) __builtin_prefetch(arg, 1, 0) +# else +/* LLVM Clang workaround (crash on compilation) */ +# define EINA_PREFETCH(arg) ((void) (arg)) +# define EINA_PREFETCH_WRITE(arg) ((void) (arg)) +# define EINA_PREFETCH_NOCACHE(arg) ((void) (arg)) +# define EINA_PREFETCH_NOCACHE_WRITE(arg) ((void) (arg)) +# endif # else # define EINA_PRINTF(fmt, arg) # define EINA_SCANF(fmt, arg) @@ -206,10 +214,10 @@ # define EINA_UNLIKELY(exp) exp # define EINA_LIKELY(exp) exp # define EINA_SENTINEL -# define EINA_PREFETCH(arg) -# define EINA_PREFETCH_WRITE(arg) -# define EINA_PREFETCH_NOCACHE(arg) -# define EINA_PREFETCH_NOCACHE_WRITE(arg) +# define EINA_PREFETCH(arg) ((void) (arg)) +# define EINA_PREFETCH_WRITE(arg) ((void) (arg)) +# define EINA_PREFETCH_NOCACHE(arg) ((void) (arg)) +# define EINA_PREFETCH_NOCACHE_WRITE(arg) ((void) (arg)) # endif #elif defined(_MSC_VER) @@ -231,10 +239,10 @@ # define EINA_UNLIKELY(exp) exp # define EINA_LIKELY(exp) exp # define EINA_SENTINEL -# define EINA_PREFETCH(arg) -# define EINA_PREFETCH_WRITE(arg) -# define EINA_PREFETCH_NOCACHE(arg) -# define EINA_PREFETCH_NOCACHE_WRITE(arg) +# define EINA_PREFETCH(arg) ((void) (arg)) +# define EINA_PREFETCH_WRITE(arg) ((void) (arg)) +# define EINA_PREFETCH_NOCACHE(arg) ((void) (arg)) +# define EINA_PREFETCH_NOCACHE_WRITE(arg) ((void) (arg)) #elif defined(__SUNPRO_C) # define EINA_UNUSED @@ -260,10 +268,10 @@ # define EINA_UNLIKELY(exp) exp # define EINA_LIKELY(exp) exp # define EINA_SENTINEL -# define EINA_PREFETCH(arg) -# define EINA_PREFETCH_WRITE(arg) -# define EINA_PREFETCH_NOCACHE(arg) -# define EINA_PREFETCH_NOCACHE_WRITE(arg) +# define EINA_PREFETCH(arg) ((void) (arg)) +# define EINA_PREFETCH_WRITE(arg) ((void) (arg)) +# define EINA_PREFETCH_NOCACHE(arg) ((void) (arg)) +# define EINA_PREFETCH_NOCACHE_WRITE(arg) ((void) (arg)) #else /* ! __GNUC__ && ! _MSC_VER && ! __SUNPRO_C */ -- 2.7.4