]> pd.if.org Git - liblfds/blob - liblfds/liblfds7.1.0/test_and_benchmark/libbenchmark/inc/libbenchmark/libbenchmark_datastructure_btree_au_gcc_spinlock_sync.h
Initial import (all versions, including the new 7.1.0)
[liblfds] / liblfds / liblfds7.1.0 / test_and_benchmark / libbenchmark / inc / libbenchmark / libbenchmark_datastructure_btree_au_gcc_spinlock_sync.h
1 /***** defines *****/
2 #define LIBBENCHMARK_DATASTRUCTURE_BTREE_AU_GCC_SPINLOCK_SYNC_GET_KEY_FROM_ELEMENT( btree_au_state, btree_au_element )                    ( (btree_au_element).key )
3 #define LIBBENCHMARK_DATASTRUCTURE_BTREE_AU_GCC_SPINLOCK_SYNC_SET_KEY_IN_ELEMENT( btree_au_state, btree_au_element, new_key )             ( (btree_au_element).key = (void *) (lfds710_pal_uint_t) (new_key) )
4 #define LIBBENCHMARK_DATASTRUCTURE_BTREE_AU_GCC_SPINLOCK_SYNC_GET_VALUE_FROM_ELEMENT( btree_au_state, btree_au_element, existing_value )  { LIBBENCHMARK_PAL_LOCK_GCC_SPINLOCK_SYNC_GET((btree_au_state).lock); (existing_value) = (btree_au_element).value; LIBBENCHMARK_PAL_LOCK_GCC_SPINLOCK_SYNC_RELEASE((btree_au_state).lock);                            }
5 #define LIBBENCHMARK_DATASTRUCTURE_BTREE_AU_GCC_SPINLOCK_SYNC_SET_VALUE_IN_ELEMENT( btree_au_state, btree_au_element, new_value )         { LIBBENCHMARK_PAL_LOCK_GCC_SPINLOCK_SYNC_GET((btree_au_state).lock); (btree_au_element).value = (void *) (lfds710_pal_uint_t) (new_value); LIBBENCHMARK_PAL_LOCK_GCC_SPINLOCK_SYNC_RELEASE((btree_au_state).lock); }
6 #define LIBBENCHMARK_DATASTRUCTURE_BTREE_AU_GCC_SPINLOCK_SYNC_GET_USER_STATE_FROM_STATE( btree_au_state )                                 ( (btree_au_state).user_state )
7
8 /***** enums *****/
9 enum libbenchmark_datastructure_btree_au_gcc_spinlock_sync_absolute_position
10 {
11   LIBBENCHMARK_DATASTRUCTURE_BTREE_AU_GCC_SPINLOCK_SYNC_ABSOLUTE_POSITION_ROOT,
12   LIBBENCHMARK_DATASTRUCTURE_BTREE_AU_GCC_SPINLOCK_SYNC_ABSOLUTE_POSITION_SMALLEST_IN_TREE,
13   LIBBENCHMARK_DATASTRUCTURE_BTREE_AU_GCC_SPINLOCK_SYNC_ABSOLUTE_POSITION_LARGEST_IN_TREE
14 };
15
16 enum libbenchmark_datastructure_btree_au_gcc_spinlock_sync_existing_key
17 {
18   LIBBENCHMARK_DATASTRUCTURE_BTREE_AU_GCC_SPINLOCK_SYNC_EXISTING_KEY_OVERWRITE,
19   LIBBENCHMARK_DATASTRUCTURE_BTREE_AU_GCC_SPINLOCK_SYNC_EXISTING_KEY_FAIL
20 };
21
22 enum libbenchmark_datastructure_btree_au_gcc_spinlock_sync_insert_result
23 {
24   LIBBENCHMARK_DATASTRUCTURE_BTREE_AU_GCC_SPINLOCK_SYNC_INSERT_RESULT_FAILURE_EXISTING_KEY,
25   LIBBENCHMARK_DATASTRUCTURE_BTREE_AU_GCC_SPINLOCK_SYNC_INSERT_RESULT_SUCCESS_OVERWRITE,
26   LIBBENCHMARK_DATASTRUCTURE_BTREE_AU_GCC_SPINLOCK_SYNC_INSERT_RESULT_SUCCESS
27 };
28
29 enum libbenchmark_datastructure_btree_au_gcc_spinlock_sync_relative_position
30 {
31   LIBBENCHMARK_DATASTRUCTURE_BTREE_AU_GCC_SPINLOCK_SYNC_RELATIVE_POSITION_UP,
32   LIBBENCHMARK_DATASTRUCTURE_BTREE_AU_GCC_SPINLOCK_SYNC_RELATIVE_POSITION_LEFT,
33   LIBBENCHMARK_DATASTRUCTURE_BTREE_AU_GCC_SPINLOCK_SYNC_RELATIVE_POSITION_RIGHT,
34   LIBBENCHMARK_DATASTRUCTURE_BTREE_AU_GCC_SPINLOCK_SYNC_RELATIVE_POSITION_SMALLEST_ELEMENT_BELOW_CURRENT_ELEMENT,
35   LIBBENCHMARK_DATASTRUCTURE_BTREE_AU_GCC_SPINLOCK_SYNC_RELATIVE_POSITION_LARGEST_ELEMENT_BELOW_CURRENT_ELEMENT,
36   LIBBENCHMARK_DATASTRUCTURE_BTREE_AU_GCC_SPINLOCK_SYNC_RELATIVE_POSITION_NEXT_SMALLER_ELEMENT_IN_ENTIRE_TREE,
37   LIBBENCHMARK_DATASTRUCTURE_BTREE_AU_GCC_SPINLOCK_SYNC_RELATIVE_POSITION_NEXT_LARGER_ELEMENT_IN_ENTIRE_TREE
38 };
39
40 /***** structs *****/
41 struct libbenchmark_datastructure_btree_au_gcc_spinlock_sync_element
42 {
43   struct libbenchmark_datastructure_btree_au_gcc_spinlock_sync_element
44     *left,
45     *right,
46     *up;
47
48   void
49     *key,
50     *value;
51 };
52
53 struct libbenchmark_datastructure_btree_au_gcc_spinlock_sync_state
54 {
55   struct libbenchmark_datastructure_btree_au_gcc_spinlock_sync_element
56     *root;
57
58   pal_lock_gcc_spinlock_sync_state LFDS710_PAL_ALIGN(LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES)
59     lock;
60
61   int
62     (*key_compare_function)( void const *new_key, void const *existing_key );
63
64   enum libbenchmark_datastructure_btree_au_gcc_spinlock_sync_existing_key 
65     existing_key;
66
67   void
68     *user_state;
69 };
70
71 /***** public prototypes *****/
72 void libbenchmark_datastructure_btree_au_gcc_spinlock_sync_init( struct libbenchmark_datastructure_btree_au_gcc_spinlock_sync_state *baus,
73                                                                    int (*key_compare_function)(void const *new_key, void const *existing_key),
74                                                                    enum libbenchmark_datastructure_btree_au_gcc_spinlock_sync_existing_key existing_key,
75                                                                    void *user_state );
76
77 void libbenchmark_datastructure_btree_au_gcc_spinlock_sync_cleanup( struct libbenchmark_datastructure_btree_au_gcc_spinlock_sync_state *baus,
78                                                                       void (*element_cleanup_callback)(struct libbenchmark_datastructure_btree_au_gcc_spinlock_sync_state *baus, struct libbenchmark_datastructure_btree_au_gcc_spinlock_sync_element *baue) );
79
80 enum libbenchmark_datastructure_btree_au_gcc_spinlock_sync_insert_result libbenchmark_datastructure_btree_au_gcc_spinlock_sync_insert( struct libbenchmark_datastructure_btree_au_gcc_spinlock_sync_state *baus,
81                                                                                                                                            struct libbenchmark_datastructure_btree_au_gcc_spinlock_sync_element *baue,
82                                                                                                                                            struct libbenchmark_datastructure_btree_au_gcc_spinlock_sync_element **existing_baue );
83
84 int libbenchmark_datastructure_btree_au_gcc_spinlock_sync_get_by_key( struct libbenchmark_datastructure_btree_au_gcc_spinlock_sync_state *baus, 
85                                                                         int (*key_compare_function)(void const *new_key, void const *existing_key),
86                                                                         void *key,
87                                                                         struct libbenchmark_datastructure_btree_au_gcc_spinlock_sync_element **baue );
88
89 int libbenchmark_datastructure_btree_au_gcc_spinlock_sync_get_by_absolute_position_and_then_by_relative_position( struct libbenchmark_datastructure_btree_au_gcc_spinlock_sync_state *baus,
90                                                                                                                     struct libbenchmark_datastructure_btree_au_gcc_spinlock_sync_element **baue,
91                                                                                                                     enum libbenchmark_datastructure_btree_au_gcc_spinlock_sync_absolute_position absolute_position,
92                                                                                                                     enum libbenchmark_datastructure_btree_au_gcc_spinlock_sync_relative_position relative_position );
93
94 int libbenchmark_datastructure_btree_au_gcc_spinlock_sync_get_by_absolute_position( struct libbenchmark_datastructure_btree_au_gcc_spinlock_sync_state *baus,
95                                                                                       struct libbenchmark_datastructure_btree_au_gcc_spinlock_sync_element **baue,
96                                                                                       enum libbenchmark_datastructure_btree_au_gcc_spinlock_sync_absolute_position absolute_position );
97
98 int libbenchmark_datastructure_btree_au_gcc_spinlock_sync_get_by_relative_position( struct libbenchmark_datastructure_btree_au_gcc_spinlock_sync_state *baus,
99                                                                                       struct libbenchmark_datastructure_btree_au_gcc_spinlock_sync_element **baue,
100                                                                                       enum libbenchmark_datastructure_btree_au_gcc_spinlock_sync_relative_position relative_position );
101