*lock: Simplify initialization semantics.

Compiler barrier used for backwards compatibility.
ck_pring
Samy Al Bahra 11 years ago
parent f3539396c2
commit 411afc3c47

@ -83,7 +83,7 @@ ck_spinlock_anderson_init(struct ck_spinlock_anderson *lock,
else else
lock->wrap = 0; lock->wrap = 0;
ck_pr_fence_store(); ck_pr_barrier();
return; return;
} }

@ -49,7 +49,8 @@ CK_CC_INLINE static void
ck_spinlock_cas_init(struct ck_spinlock_cas *lock) ck_spinlock_cas_init(struct ck_spinlock_cas *lock)
{ {
ck_pr_store_uint(&lock->value, false); lock->value = false;
ck_pr_barrier();
return; return;
} }

@ -46,10 +46,10 @@ CK_CC_INLINE static void
ck_spinlock_clh_init(struct ck_spinlock_clh **lock, struct ck_spinlock_clh *unowned) ck_spinlock_clh_init(struct ck_spinlock_clh **lock, struct ck_spinlock_clh *unowned)
{ {
ck_pr_store_ptr(&unowned->previous, NULL); unowned->previous = NULL;
ck_pr_store_uint(&unowned->wait, false); unowned->wait = false;
ck_pr_store_ptr(lock, unowned); *lock = unowned;
ck_pr_fence_store(); ck_pr_barrier();
return; return;
} }

@ -51,7 +51,8 @@ CK_CC_INLINE static void
ck_spinlock_dec_init(struct ck_spinlock_dec *lock) ck_spinlock_dec_init(struct ck_spinlock_dec *lock)
{ {
ck_pr_store_uint(&lock->value, 1); lock->value = 1;
ck_pr_barrier();
return; return;
} }

@ -47,7 +47,8 @@ CK_CC_INLINE static void
ck_spinlock_fas_init(struct ck_spinlock_fas *lock) ck_spinlock_fas_init(struct ck_spinlock_fas *lock)
{ {
ck_pr_store_uint(&lock->value, false); lock->value = false;
ck_pr_barrier();
return; return;
} }

@ -49,12 +49,12 @@ ck_spinlock_hclh_init(struct ck_spinlock_hclh **lock,
int cluster_id) int cluster_id)
{ {
ck_pr_store_ptr(&unowned->previous, NULL); unowned->previous = NULL;
ck_pr_store_uint(&unowned->wait, false); unowned->wait = false;
ck_pr_store_uint(&unowned->splice, false); unowned->splice = false;
ck_pr_store_int(&unowned->cluster_id, cluster_id); unowned->cluster_id = cluster_id;
ck_pr_store_ptr(lock, unowned); *lock = unowned;
ck_pr_fence_store(); ck_pr_barrier();
return; return;
} }

@ -48,7 +48,8 @@ CK_CC_INLINE static void
ck_spinlock_mcs_init(struct ck_spinlock_mcs **queue) ck_spinlock_mcs_init(struct ck_spinlock_mcs **queue)
{ {
ck_pr_store_ptr(queue, NULL); *queue = NULL;
ck_pr_barrier();
return; return;
} }

@ -79,7 +79,7 @@ ck_spinlock_ticket_init(struct ck_spinlock_ticket *ticket)
{ {
ticket->value = 0; ticket->value = 0;
ck_pr_fence_store(); ck_pr_barrier();
return; return;
} }
@ -203,7 +203,7 @@ ck_spinlock_ticket_init(struct ck_spinlock_ticket *ticket)
ticket->next = 0; ticket->next = 0;
ticket->position = 0; ticket->position = 0;
ck_pr_fence_store(); ck_pr_barrier();
return; return;
} }

Loading…
Cancel
Save