]> pd.if.org Git - liblfds/blob - liblfds/liblfds7.1.0/liblfds710/inc/liblfds710/lfds710_stack.h
Initial import (all versions, including the new 7.1.0)
[liblfds] / liblfds / liblfds7.1.0 / liblfds710 / inc / liblfds710 / lfds710_stack.h
1 /***** defines *****/
2 #define LFDS710_STACK_GET_KEY_FROM_ELEMENT( stack_element )             ( (stack_element).key )
3 #define LFDS710_STACK_SET_KEY_IN_ELEMENT( stack_element, new_key )      ( (stack_element).key = (void *) (lfds710_pal_uint_t) (new_key) )
4 #define LFDS710_STACK_GET_VALUE_FROM_ELEMENT( stack_element )           ( (stack_element).value )
5 #define LFDS710_STACK_SET_VALUE_IN_ELEMENT( stack_element, new_value )  ( (stack_element).value = (void *) (lfds710_pal_uint_t) (new_value) )
6 #define LFDS710_STACK_GET_USER_STATE_FROM_STATE( stack_state )          ( (stack_state).user_state )
7
8 /***** enums *****/
9 enum lfds710_stack_query
10 {
11   LFDS710_STACK_QUERY_SINGLETHREADED_GET_COUNT,
12   LFDS710_STACK_QUERY_SINGLETHREADED_VALIDATE
13 };
14
15 /***** structures *****/
16 struct lfds710_stack_element
17 {
18   struct lfds710_stack_element
19     *next;
20
21   void
22     *key,
23     *value;
24 };
25
26 struct lfds710_stack_state
27 {
28   struct lfds710_stack_element LFDS710_PAL_ALIGN(LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES)
29     *volatile top[PAC_SIZE];
30
31   void LFDS710_PAL_ALIGN(LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES)
32     *user_state;
33
34   struct lfds710_misc_backoff_state
35     pop_backoff,
36     push_backoff;
37 };
38
39 /***** public prototypes *****/
40 void lfds710_stack_init_valid_on_current_logical_core( struct lfds710_stack_state *ss,
41                                                        void *user_state );
42   // TRD : used in conjunction with the #define LFDS710_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_LOGICAL_CORE
43
44 void lfds710_stack_cleanup( struct lfds710_stack_state *ss,
45                             void (*element_cleanup_callback)(struct lfds710_stack_state *ss, struct lfds710_stack_element *se) );
46
47 void lfds710_stack_push( struct lfds710_stack_state *ss,
48                          struct lfds710_stack_element *se );
49
50 int lfds710_stack_pop( struct lfds710_stack_state *ss,
51                        struct lfds710_stack_element **se );
52
53 void lfds710_stack_query( struct lfds710_stack_state *ss,
54                           enum lfds710_stack_query query_type,
55                           void *query_input,
56                           void *query_output );
57
58