Some fixes for strict aliasing. Silence some warnings from clang.

ck_pring
Samy Al Bahra 14 years ago
parent 114e9c8ed5
commit 7c8ab13343

@ -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);

@ -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);
}

@ -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;

Loading…
Cancel
Save