]> pd.if.org Git - liblfds/blob - liblfds/liblfds6.0.0/liblfds600/src/lfds600_slist/lfds600_slist_link.c
Initial import (all versions, including the new 7.1.0)
[liblfds] / liblfds / liblfds6.0.0 / liblfds600 / src / lfds600_slist / lfds600_slist_link.c
1 #include "lfds600_slist_internal.h"
2
3
4
5
6
7 /****************************************************************************/
8 void lfds600_slist_internal_link_element_to_head( struct lfds600_slist_state *ss, struct lfds600_slist_element *volatile se )
9 {
10   LFDS600_ALIGN(LFDS600_ALIGN_SINGLE_POINTER) struct lfds600_slist_element
11     *se_next;
12
13   assert( ss != NULL );
14   assert( se != NULL );
15
16   se_next = ss->head;
17
18   do
19   {
20     se->next = se_next;
21   }
22   while( se->next != (se_next = (struct lfds600_slist_element *) lfds600_abstraction_cas((volatile lfds600_atom_t *) &ss->head, (lfds600_atom_t) se, (lfds600_atom_t) se->next)) );
23
24   return;
25 }
26
27
28
29
30
31 /****************************************************************************/
32 void lfds600_slist_internal_link_element_after_element( struct lfds600_slist_element *volatile lfds600_slist_in_list_element, struct lfds600_slist_element *volatile se )
33 {
34   LFDS600_ALIGN(LFDS600_ALIGN_SINGLE_POINTER) struct lfds600_slist_element
35     *se_prev,
36     *se_next;
37
38   assert( lfds600_slist_in_list_element != NULL );
39   assert( se != NULL );
40
41   se_prev = (struct lfds600_slist_element *) lfds600_slist_in_list_element;
42
43   se_next = se_prev->next;
44
45   do
46   {
47     se->next = se_next;
48   }
49   while( se->next != (se_next = (struct lfds600_slist_element *) lfds600_abstraction_cas((volatile lfds600_atom_t *) &se_prev->next, (lfds600_atom_t) se, (lfds600_atom_t) se->next)) );
50
51   return;
52 }
53