Message ID | 1463642433-3104-1-git-send-email-maxim.uvarov@linaro.org |
---|---|
State | Accepted |
Commit | b484339a4b1cbd05a9228372be1a666b70c4ed87 |
Headers | show |
We shouldn't care about optimizing performance under obsolete versions of clang as long as we don't get compile/test failures under those old versions. So this check looks reasonable. On Thu, May 19, 2016 at 2:20 AM, Maxim Uvarov <maxim.uvarov@linaro.org> wrote: > Fix compilation error for clang: > In function `_odp_atomic_u128_xchg_mm': > undefined reference to `__atomic_exchange' > Clang less than 3.6 has issue with defined _SIZEOF_INT128_ and > __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 but not supported > __atomic_exchange(). This patch adds additional check for clang > version. > > Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> > Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org> > --- > v2: add check for clang version > > platform/linux-generic/include/odp_atomic_internal.h | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/platform/linux-generic/include/odp_atomic_internal.h > b/platform/linux-generic/include/odp_atomic_internal.h > index 3c5606c..67e8f82 100644 > --- a/platform/linux-generic/include/odp_atomic_internal.h > +++ b/platform/linux-generic/include/odp_atomic_internal.h > @@ -589,12 +589,21 @@ static inline void > _odp_atomic_flag_clear(_odp_atomic_flag_t *flag) > > /* Check if target and compiler supports 128-bit scalars and corresponding > * exchange and CAS operations */ > -/* GCC on x86-64 needs -mcx16 compiler option */ > +/* GCC/clang on x86-64 needs -mcx16 compiler option */ > #if defined __SIZEOF_INT128__ && defined > __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 > > -/** Preprocessor symbol that indicates support for 128-bit atomics */ > +#if defined(__clang__) > + > +#if ((__clang_major__ * 100 + __clang_minor__) >= 306) > +#define ODP_ATOMIC_U128 > +#endif > + > +#else /* gcc */ > #define ODP_ATOMIC_U128 > +#endif > +#endif > > +#ifdef ODP_ATOMIC_U128 > /** An unsigned 128-bit (16-byte) scalar type */ > typedef __int128 _uint128_t; > > -- > 2.7.1.250.gff4ea60 > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > https://lists.linaro.org/mailman/listinfo/lng-odp >
Merged, Maxim. On 05/19/16 14:48, Bill Fischofer wrote: > We shouldn't care about optimizing performance under obsolete versions > of clang as long as we don't get compile/test failures under those old > versions. So this check looks reasonable. > > On Thu, May 19, 2016 at 2:20 AM, Maxim Uvarov <maxim.uvarov@linaro.org > <mailto:maxim.uvarov@linaro.org>> wrote: > > Fix compilation error for clang: > In function `_odp_atomic_u128_xchg_mm': > undefined reference to `__atomic_exchange' > Clang less than 3.6 has issue with defined _SIZEOF_INT128_ and > __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 but not supported > __atomic_exchange(). This patch adds additional check for clang > version. > > Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org > <mailto:maxim.uvarov@linaro.org>> > > > Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org > <mailto:bill.fischofer@linaro.org>> > > --- > v2: add check for clang version > > platform/linux-generic/include/odp_atomic_internal.h | 13 > +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/platform/linux-generic/include/odp_atomic_internal.h > b/platform/linux-generic/include/odp_atomic_internal.h > index 3c5606c..67e8f82 100644 > --- a/platform/linux-generic/include/odp_atomic_internal.h > +++ b/platform/linux-generic/include/odp_atomic_internal.h > @@ -589,12 +589,21 @@ static inline void > _odp_atomic_flag_clear(_odp_atomic_flag_t *flag) > > /* Check if target and compiler supports 128-bit scalars and > corresponding > * exchange and CAS operations */ > -/* GCC on x86-64 needs -mcx16 compiler option */ > +/* GCC/clang on x86-64 needs -mcx16 compiler option */ > #if defined __SIZEOF_INT128__ && defined > __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 > > -/** Preprocessor symbol that indicates support for 128-bit atomics */ > +#if defined(__clang__) > + > +#if ((__clang_major__ * 100 + __clang_minor__) >= 306) > +#define ODP_ATOMIC_U128 > +#endif > + > +#else /* gcc */ > #define ODP_ATOMIC_U128 > +#endif > +#endif > > +#ifdef ODP_ATOMIC_U128 > /** An unsigned 128-bit (16-byte) scalar type */ > typedef __int128 _uint128_t; > > -- > 2.7.1.250.gff4ea60 > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org> > https://lists.linaro.org/mailman/listinfo/lng-odp > >
diff --git a/platform/linux-generic/include/odp_atomic_internal.h b/platform/linux-generic/include/odp_atomic_internal.h index 3c5606c..67e8f82 100644 --- a/platform/linux-generic/include/odp_atomic_internal.h +++ b/platform/linux-generic/include/odp_atomic_internal.h @@ -589,12 +589,21 @@ static inline void _odp_atomic_flag_clear(_odp_atomic_flag_t *flag) /* Check if target and compiler supports 128-bit scalars and corresponding * exchange and CAS operations */ -/* GCC on x86-64 needs -mcx16 compiler option */ +/* GCC/clang on x86-64 needs -mcx16 compiler option */ #if defined __SIZEOF_INT128__ && defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 -/** Preprocessor symbol that indicates support for 128-bit atomics */ +#if defined(__clang__) + +#if ((__clang_major__ * 100 + __clang_minor__) >= 306) +#define ODP_ATOMIC_U128 +#endif + +#else /* gcc */ #define ODP_ATOMIC_U128 +#endif +#endif +#ifdef ODP_ATOMIC_U128 /** An unsigned 128-bit (16-byte) scalar type */ typedef __int128 _uint128_t;
Fix compilation error for clang: In function `_odp_atomic_u128_xchg_mm': undefined reference to `__atomic_exchange' Clang less than 3.6 has issue with defined _SIZEOF_INT128_ and __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 but not supported __atomic_exchange(). This patch adds additional check for clang version. Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> --- v2: add check for clang version platform/linux-generic/include/odp_atomic_internal.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)