Merge pull request #55 from mhaberler/machinekit

c++: introduce CK_CPP_CAST, apply to x86_64, arm
ck_pring
cognet 9 years ago
commit a7cf4a4dab

@ -162,4 +162,11 @@ ck_cc_popcount(unsigned int x)
} }
#endif #endif
#ifdef __cplusplus
#define CK_CPP_CAST(type, arg) static_cast<type>(arg)
#else
#define CK_CPP_CAST(type, arg) arg
#endif
#endif /* CK_CC_H */ #endif /* CK_CC_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_CC_INLINE static bool
ck_pr_cas_ptr_2_value(void *target, void *compare, void *set, void *value) ck_pr_cas_ptr_2_value(void *target, void *compare, void *set, void *value)
{ {
uint32_t *_compare = compare; uint32_t *_compare = CK_CPP_CAST(uint32_t *, compare);
uint32_t *_set = set; uint32_t *_set = CK_CPP_CAST(uint32_t *, set);
uint64_t __compare = ((uint64_t)_compare[0]) | ((uint64_t)_compare[1] << 32); uint64_t __compare = ((uint64_t)_compare[0]) | ((uint64_t)_compare[1] << 32);
uint64_t __set = ((uint64_t)_set[0]) | ((uint64_t)_set[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_CC_INLINE static bool
ck_pr_cas_ptr_2(void *target, void *compare, void *set) ck_pr_cas_ptr_2(void *target, void *compare, void *set)
{ {
uint32_t *_compare = compare; uint32_t *_compare = CK_CPP_CAST(uint32_t *, compare);
uint32_t *_set = set; uint32_t *_set = CK_CPP_CAST(uint32_t *, set);
uint64_t __compare = ((uint64_t)_compare[0]) | ((uint64_t)_compare[1] << 32); uint64_t __compare = ((uint64_t)_compare[0]) | ((uint64_t)_compare[1] << 32);
uint64_t __set = ((uint64_t)_set[0]) | ((uint64_t)_set[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 #endif

@ -191,7 +191,8 @@ ck_pr_load_64_2(const uint64_t target[2], uint64_t v[2])
CK_CC_INLINE static void CK_CC_INLINE static void
ck_pr_load_ptr_2(const void *t, void *v) 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; 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_CC_INLINE static bool
ck_pr_cas_ptr_2(void *t, void *c, void *s) 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 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_CC_INLINE static bool
ck_pr_cas_ptr_2_value(void *t, void *c, void *s, void *v) 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) \ #define CK_PR_CAS_V(S, W, T) \

Loading…
Cancel
Save