From: Mathieu Desnoyers Date: Wed, 16 Jun 2021 14:03:48 +0000 (-0400) Subject: Fix: x86 and s390: uatomic __hp() macro C++ support X-Git-Tag: v0.13.1~7 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=e344a57787d785efae2670be15bc519c7d794f1f;p=userspace-rcu.git Fix: x86 and s390: uatomic __hp() macro C++ support C++ does not allow defining types in cast. Therefore, define the types with typedef and use them in the __hp() macro. Signed-off-by: Mathieu Desnoyers Change-Id: I92af62924f78dc6c5f7420a6376731212fbc5a20 --- diff --git a/include/urcu/uatomic/s390.h b/include/urcu/uatomic/s390.h index d7d545a..42f23e7 100644 --- a/include/urcu/uatomic/s390.h +++ b/include/urcu/uatomic/s390.h @@ -66,10 +66,14 @@ extern "C" { * containing an array of char of the specified size. This allows passing the * @addr arguments of the following inline functions as "m" and "+m" operands * to the assembly. The @size parameter should be a constant to support - * compilers such as clang which do not support VLA. + * compilers such as clang which do not support VLA. Create typedefs because + * C++ does not allow types be defined in casts. */ -#define __hp(size, x) ((struct { char v[size]; } *)(x)) +typedef struct { char v[4]; } __hp_4; +typedef struct { char v[8]; } __hp_8; + +#define __hp(size, x) ((__hp_##size *)(x)) /* xchg */ diff --git a/include/urcu/uatomic/x86.h b/include/urcu/uatomic/x86.h index c02c96d..f4e1887 100644 --- a/include/urcu/uatomic/x86.h +++ b/include/urcu/uatomic/x86.h @@ -41,10 +41,16 @@ extern "C" { * containing an array of char of the specified size. This allows passing the * @addr arguments of the following inline functions as "m" and "+m" operands * to the assembly. The @size parameter should be a constant to support - * compilers such as clang which do not support VLA. + * compilers such as clang which do not support VLA. Create typedefs because + * C++ does not allow types be defined in casts. */ -#define __hp(size, x) ((struct { char v[size]; } *)(x)) +typedef struct { char v[1]; } __hp_1; +typedef struct { char v[2]; } __hp_2; +typedef struct { char v[4]; } __hp_4; +typedef struct { char v[8]; } __hp_8; + +#define __hp(size, x) ((__hp_##size *)(x)) #define _uatomic_set(addr, v) ((void) CMM_STORE_SHARED(*(addr), (v)))