ck_pr: Adopt const qualifer for load/store.

We will adopt these semantics for the rest of _ptr
family at some point in the future as well.
ck_pring
Samy Al Bahra 12 years ago
parent 90745e4d60
commit 12da4128ff

@ -96,7 +96,7 @@ ck_pr_barrier(void)
#define CK_PR_LOAD(S, M, T, C, I) \
CK_CC_INLINE static T \
ck_pr_load_##S(M *target) \
ck_pr_load_##S(const M *target) \
{ \
T r; \
__asm__ __volatile__(I "%U1%X1 %0, %1" \
@ -132,7 +132,7 @@ CK_PR_LOAD_S(char, char, "lbz")
return; \
}
CK_PR_STORE(ptr, void, void *, uint32_t, "stw")
CK_PR_STORE(ptr, void, const void *, uint32_t, "stw")
#define CK_PR_STORE_S(S, T, I) CK_PR_STORE(S, T, T, T, I)

@ -99,7 +99,7 @@ ck_pr_barrier(void)
#define CK_PR_LOAD(S, M, T, C, I) \
CK_CC_INLINE static T \
ck_pr_load_##S(M *target) \
ck_pr_load_##S(const M *target) \
{ \
T r; \
__asm__ __volatile__(I "%U1%X1 %0, %1" \
@ -137,7 +137,7 @@ CK_PR_LOAD_S(double, double, "ld")
return; \
}
CK_PR_STORE(ptr, void, void *, uint64_t, "std")
CK_PR_STORE(ptr, void, const void *, uint64_t, "std")
#define CK_PR_STORE_S(S, T, I) CK_PR_STORE(S, T, T, T, I)

@ -98,7 +98,7 @@ ck_pr_barrier(void)
#define CK_PR_LOAD(S, M, T, C, I) \
CK_CC_INLINE static T \
ck_pr_load_##S(M *target) \
ck_pr_load_##S(const M *target) \
{ \
T r; \
__asm__ __volatile__(I " [%1], %0" \
@ -133,7 +133,7 @@ CK_PR_LOAD_S(int, int, "ldsw")
return; \
}
CK_PR_STORE(ptr, void, void *, uint64_t, "stx")
CK_PR_STORE(ptr, void, const void *, uint64_t, "stx")
#define CK_PR_STORE_S(S, T, I) CK_PR_STORE(S, T, T, T, I)

@ -140,7 +140,7 @@ CK_PR_FAS_S(8, uint8_t, "xchgb")
#define CK_PR_LOAD(S, M, T, C, I) \
CK_CC_INLINE static T \
ck_pr_load_##S(M *target) \
ck_pr_load_##S(const M *target) \
{ \
T r; \
__asm__ __volatile__(I " %1, %0" \
@ -175,7 +175,7 @@ CK_PR_LOAD_S(8, uint8_t, "movb")
return; \
}
CK_PR_STORE(ptr, void, void *, char, "movl")
CK_PR_STORE(ptr, void, const void *, char, "movl")
#define CK_PR_STORE_S(S, T, I) CK_PR_STORE(S, T, T, T, I)

@ -144,7 +144,7 @@ CK_PR_FAS_S(8, uint8_t, "xchgb")
*/
#define CK_PR_LOAD(S, M, T, C, I) \
CK_CC_INLINE static T \
ck_pr_load_##S(M *target) \
ck_pr_load_##S(const M *target) \
{ \
T r; \
__asm__ __volatile__(I " %1, %0" \
@ -171,15 +171,14 @@ CK_PR_LOAD_S(8, uint8_t, "movb")
#undef CK_PR_LOAD
CK_CC_INLINE static void
ck_pr_load_64_2(uint64_t target[2], uint64_t v[2])
ck_pr_load_64_2(const uint64_t target[2], uint64_t v[2])
{
__asm__ __volatile__("movq %%rdx, %%rcx;"
"movq %%rax, %%rbx;"
CK_PR_LOCK_PREFIX "cmpxchg16b %0;"
: "+m" (*(uint64_t *)target),
"=a" (v[0]),
: "=a" (v[0]),
"=d" (v[1])
:
: "m" (*(const uint64_t *)target)
: "rbx", "rcx", "memory", "cc");
return;
}
@ -193,9 +192,10 @@ ck_pr_load_ptr_2(void *t, void *v)
#define CK_PR_LOAD_2(S, W, T) \
CK_CC_INLINE static void \
ck_pr_load_##S##_##W(T t[2], T v[2]) \
ck_pr_load_##S##_##W(const T t[2], T v[2]) \
{ \
ck_pr_load_64_2((uint64_t *)(void *)t, (uint64_t *)(void *)v); \
ck_pr_load_64_2((const uint64_t *)(const void *)t, \
(uint64_t *)(void *)v); \
return; \
}
@ -222,7 +222,7 @@ CK_PR_LOAD_2(8, 16, uint8_t)
return; \
}
CK_PR_STORE(ptr, void, void *, char, "movq")
CK_PR_STORE(ptr, void, const void *, char, "movq")
#define CK_PR_STORE_S(S, T, I) CK_PR_STORE(S, T, T, T, I)

Loading…
Cancel
Save