diff --git a/include/ck_cc.h b/include/ck_cc.h index 30ec383..b588616 100644 --- a/include/ck_cc.h +++ b/include/ck_cc.h @@ -162,4 +162,11 @@ ck_cc_popcount(unsigned int x) } #endif + +#ifdef __cplusplus +#define CK_CPP_CAST(type, arg) static_cast(arg) +#else +#define CK_CPP_CAST(type, arg) arg +#endif + #endif /* CK_CC_H */ diff --git a/include/gcc/arm/ck_pr.h b/include/gcc/arm/ck_pr.h index efa6638..3fb303a 100644 --- a/include/gcc/arm/ck_pr.h +++ b/include/gcc/arm/ck_pr.h @@ -217,12 +217,15 @@ ck_pr_cas_64_value(uint64_t *target, uint64_t compare, uint64_t set, uint64_t *v CK_CC_INLINE static bool ck_pr_cas_ptr_2_value(void *target, void *compare, void *set, void *value) { - uint32_t *_compare = compare; - uint32_t *_set = set; + uint32_t *_compare = CK_CPP_CAST(uint32_t *, compare); + uint32_t *_set = CK_CPP_CAST(uint32_t *, set); uint64_t __compare = ((uint64_t)_compare[0]) | ((uint64_t)_compare[1] << 32); uint64_t __set = ((uint64_t)_set[0]) | ((uint64_t)_set[1] << 32); - return (ck_pr_cas_64_value(target, __compare, __set, value)); + return (ck_pr_cas_64_value(CK_CPP_CAST(uint64_t *, target), + __compare, + __set, + CK_CPP_CAST(uint64_t *, value))); } @@ -253,11 +256,13 @@ ck_pr_cas_64(uint64_t *target, uint64_t compare, uint64_t set) CK_CC_INLINE static bool ck_pr_cas_ptr_2(void *target, void *compare, void *set) { - uint32_t *_compare = compare; - uint32_t *_set = set; + uint32_t *_compare = CK_CPP_CAST(uint32_t *, compare); + uint32_t *_set = CK_CPP_CAST(uint32_t *, set); uint64_t __compare = ((uint64_t)_compare[0]) | ((uint64_t)_compare[1] << 32); uint64_t __set = ((uint64_t)_set[0]) | ((uint64_t)_set[1] << 32); - return (ck_pr_cas_64(target, __compare, __set)); + return (ck_pr_cas_64(CK_CPP_CAST(uint64_t *, target), + __compare, + __set)); } #endif diff --git a/include/gcc/x86_64/ck_pr.h b/include/gcc/x86_64/ck_pr.h index 9c8dd6d..852a0a5 100644 --- a/include/gcc/x86_64/ck_pr.h +++ b/include/gcc/x86_64/ck_pr.h @@ -191,7 +191,8 @@ ck_pr_load_64_2(const uint64_t target[2], uint64_t v[2]) CK_CC_INLINE static void ck_pr_load_ptr_2(const void *t, void *v) { - ck_pr_load_64_2(t, v); + ck_pr_load_64_2(CK_CPP_CAST(const uint64_t *, t), + CK_CPP_CAST(uint64_t *, v)); return; } @@ -472,7 +473,9 @@ ck_pr_cas_64_2(uint64_t target[2], uint64_t compare[2], uint64_t set[2]) CK_CC_INLINE static bool ck_pr_cas_ptr_2(void *t, void *c, void *s) { - return ck_pr_cas_64_2(t, c, s); + return ck_pr_cas_64_2(CK_CPP_CAST(uint64_t *, t), + CK_CPP_CAST(uint64_t *, c), + CK_CPP_CAST(uint64_t *, s)); } CK_CC_INLINE static bool @@ -500,7 +503,10 @@ ck_pr_cas_64_2_value(uint64_t target[2], CK_CC_INLINE static bool ck_pr_cas_ptr_2_value(void *t, void *c, void *s, void *v) { - return ck_pr_cas_64_2_value(t, c, s, v); + return ck_pr_cas_64_2_value(CK_CPP_CAST(uint64_t *,t), + CK_CPP_CAST(uint64_t *,c), + CK_CPP_CAST(uint64_t *,s), + CK_CPP_CAST(uint64_t *,v)); } #define CK_PR_CAS_V(S, W, T) \