]> pd.if.org Git - liblfds/blob - liblfds/liblfds6.1.0/liblfds610/src/lfds610_slist/lfds610_slist_internal.h
Initial import (all versions, including the new 7.1.0)
[liblfds] / liblfds / liblfds6.1.0 / liblfds610 / src / lfds610_slist / lfds610_slist_internal.h
1 /***** the library wide include file *****/
2 #include "liblfds610_internal.h"
3
4 /***** defines *****/
5 #define LFDS610_SLIST_USER_DATA  0
6 #define LFDS610_SLIST_FLAGS      1
7
8 #define LFDS610_SLIST_NO_FLAGS      0x0
9 #define LFDS610_SLIST_FLAG_DELETED  0x1
10
11 /***** structures *****/
12 #pragma pack( push, LFDS610_ALIGN_SINGLE_POINTER )
13
14 struct lfds610_slist_state
15 {
16   struct lfds610_slist_element
17     *volatile head;
18
19   void
20     (*user_data_delete_function)( void *user_data, void *user_state ),
21     *user_state;
22 };
23
24 #pragma pack( pop )
25
26 #pragma pack( push, LFDS610_ALIGN_DOUBLE_POINTER )
27
28 /* TRD : this pragma pack doesn't seem to work under Windows
29          if the structure members are the correct way round
30          (next first), then user_data_and_flags ends up on
31          a single pointer boundary and DCAS crashes
32
33          accordingly, I've moved user_data_and_flags first
34 */
35
36 struct lfds610_slist_element
37 {
38   void
39     *volatile user_data_and_flags[2];
40
41   // TRD : requires volatile as is target of CAS
42   struct lfds610_slist_element
43     *volatile next;
44 };
45
46 #pragma pack( pop )
47
48 /***** private prototypes *****/
49 void lfds610_slist_internal_init_slist( struct lfds610_slist_state *ss, void (*user_data_delete_function)(void *user_data, void *user_state), void *user_state );
50
51 void lfds610_slist_internal_link_element_to_head( struct lfds610_slist_state *lfds610_slist_state, struct lfds610_slist_element *volatile se );
52 void lfds610_slist_internal_link_element_after_element( struct lfds610_slist_element *volatile lfds610_slist_in_list_element, struct lfds610_slist_element *volatile se );
53
54 void lfds610_slist_internal_move_to_first_undeleted_element( struct lfds610_slist_element **se );
55