From 7c8ab133438d6e5ed47fa3d291831daa9df57902 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Wed, 2 Mar 2011 20:39:08 -0500 Subject: [PATCH] Some fixes for strict aliasing. Silence some warnings from clang. --- include/ck_ring.h | 4 +++- regressions/ck_pr/validate/ck_pr_cas.c | 6 ++++-- regressions/ck_spinlock/linux_spinlock.h | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/ck_ring.h b/include/ck_ring.h index e2c4b72..808240c 100644 --- a/include/ck_ring.h +++ b/include/ck_ring.h @@ -148,6 +148,7 @@ CK_CC_INLINE static bool ck_ring_dequeue_spsc(struct ck_ring *ring, void *data) { unsigned int consumer, producer; + void *value; consumer = ck_pr_load_uint(&ring->c_head); producer = ck_pr_load_uint(&ring->p_tail); @@ -156,7 +157,8 @@ ck_ring_dequeue_spsc(struct ck_ring *ring, void *data) return (false); ck_pr_fence_load(); - *(void **)data = ck_pr_load_ptr(ring->ring + consumer); + value = ck_pr_load_ptr(ring->ring + consumer); + ck_pr_store_ptr(data, value); ck_pr_store_uint(&ring->c_head, (consumer + 1) & ring->mask); return (true); diff --git a/regressions/ck_pr/validate/ck_pr_cas.c b/regressions/ck_pr/validate/ck_pr_cas.c index 7629a51..9585d9d 100644 --- a/regressions/ck_pr/validate/ck_pr_cas.c +++ b/regressions/ck_pr/validate/ck_pr_cas.c @@ -145,11 +145,13 @@ main(void) CK_PR_CAS_B(8); #endif +#ifdef CK_F_PR_CAS_64_VALUE uint64_t a = 0xffffffffaaaaaaaa, b = 0x8888888800000000; - printf("%" PRIx64 " -> ", b); + printf("%" PRIx64 " (%" PRIx64 ") -> ", b, a); ck_pr_cas_64_value(&a, a, b, &b); - printf("%" PRIx64 "\n", b); + printf("%" PRIx64 " (%" PRIx64 ")\n", b, a); +#endif return (0); } diff --git a/regressions/ck_spinlock/linux_spinlock.h b/regressions/ck_spinlock/linux_spinlock.h index 735efd3..5fe1f3e 100644 --- a/regressions/ck_spinlock/linux_spinlock.h +++ b/regressions/ck_spinlock/linux_spinlock.h @@ -4,7 +4,7 @@ CK_CC_INLINE static void spin_lock(volatile unsigned int *lock) { #ifdef __x86_64__ - asm volatile( + __asm__ __volatile__( "\n1:\t" "lock ; decl %0\n\t" "jns 2f\n" @@ -25,7 +25,7 @@ CK_CC_INLINE static void spin_unlock(volatile unsigned int *lock) { #ifdef __x86_64__ - asm volatile("movl $1,%0" :"=m" (*lock) :: "memory"); + __asm__ __volatile__("movl $1,%0" :"=m" (*lock) :: "memory"); #else *lock = 0; return;