concurrencykit / ck

Concurrency primitives, safe memory reclamation mechanisms and non-blocking (including lock-free) data structures designed to aid in the research, design and implementation of high performance concurrent systems developed in C99+.
http://concurrencykit.org/
Other
2.38k stars 313 forks source link

Fix aliasing violations in CAS2 operations #46

Open sbahra opened 9 years ago

sbahra commented 9 years ago

This has been around forever, and compilers will complain. Quick fix and localized. Problem code is below (which most CAS2 operations are built on).

CK_CC_INLINE static bool
ck_pr_cas_64_2(uint64_t target[2], uint64_t compare[2], uint64_t set[2])
{
        bool z;

        __asm__ __volatile__("movq 0(%4), %%rax;"
                             "movq 8(%4), %%rdx;"
                             CK_PR_LOCK_PREFIX "cmpxchg16b %0; setz %1"
                                : "+m" (*target),
                                  "=q" (z)
                                : "b"  (set[0]),
                                  "c"  (set[1]),
                                  "q"  (compare)
                                : "memory", "cc", "%rax", "%rdx");
        return z;
}

Other CAS2 variants affected.