]> pd.if.org Git - liblfds/blob - liblfds/liblfds6.0.0/liblfds600/src/lfds600_queue/lfds600_queue_internal.h
Initial import (all versions, including the new 7.1.0)
[liblfds] / liblfds / liblfds6.0.0 / liblfds600 / src / lfds600_queue / lfds600_queue_internal.h
1 /***** the library wide include file *****/
2 #include "lfds600_internal.h"
3
4 /***** pragmas *****/
5
6 /***** defines *****/
7 #define LFDS600_QUEUE_STATE_UNKNOWN               -1
8 #define LFDS600_QUEUE_STATE_EMPTY                  0
9 #define LFDS600_QUEUE_STATE_ENQUEUE_OUT_OF_PLACE   1
10 #define LFDS600_QUEUE_STATE_ATTEMPT_DELFDS600_QUEUE        2
11
12 #define LFDS600_QUEUE_POINTER 0
13 #define LFDS600_QUEUE_COUNTER 1
14 #define LFDS600_QUEUE_PAC_SIZE 2
15
16 /***** structures *****/
17 #pragma pack( push, LFDS600_ALIGN_DOUBLE_POINTER )
18
19 struct lfds600_queue_state
20 {
21   struct lfds600_queue_element
22     *volatile enqueue[LFDS600_QUEUE_PAC_SIZE],
23     *volatile dequeue[LFDS600_QUEUE_PAC_SIZE];
24
25   lfds600_atom_t
26     aba_counter;
27
28   struct lfds600_freelist_state
29     *fs;
30 };
31
32 struct lfds600_queue_element
33 {
34   // TRD : next in a lfds600_queue requires volatile as it is target of CAS
35   struct lfds600_queue_element
36     *volatile next[LFDS600_QUEUE_PAC_SIZE];
37
38   struct lfds600_freelist_element
39     *fe;
40
41   void
42     *user_data;
43 };
44
45 #pragma pack( pop )
46
47 /***** externs *****/
48
49 /***** private prototypes *****/
50 int lfds600_queue_internal_freelist_init_function( void **user_data, void *user_state );
51 void lfds600_queue_internal_freelist_delete_function( void *user_data, void *user_state );
52
53 void lfds600_queue_internal_new_element_from_freelist( struct lfds600_queue_state *qs, struct lfds600_queue_element *qe[LFDS600_QUEUE_PAC_SIZE], void *user_data );
54 void lfds600_queue_internal_guaranteed_new_element_from_freelist( struct lfds600_queue_state *qs, struct lfds600_queue_element * qe[LFDS600_QUEUE_PAC_SIZE], void *user_data );
55 void lfds600_queue_internal_init_element( struct lfds600_queue_state *qs, struct lfds600_queue_element *qe[LFDS600_QUEUE_PAC_SIZE], struct lfds600_freelist_element *fe, void *user_data );
56
57 void lfds600_queue_internal_queue( struct lfds600_queue_state *qs, struct lfds600_queue_element *qe[LFDS600_QUEUE_PAC_SIZE] );
58
59 void lfds600_queue_internal_validate( struct lfds600_queue_state *qs, struct lfds600_validation_info *vi, enum data_structure_validity *lfds600_queue_validity, enum data_structure_validity *lfds600_freelist_validity );
60