]> pd.if.org Git - liblfds/blob - liblfds/liblfds6.1.0/test/src/internal.h
Initial import (all versions, including the new 7.1.0)
[liblfds] / liblfds / liblfds6.1.0 / test / src / internal.h
1 /***** ANSI includes *****/
2 /* TRD : _GNU_SOURCE is required by sched.h for pthread_attr_setaffinity_np, CPU_ZERO and CPU_SET
3          however it has to be defined very early as even the ANSI headers pull in stuff
4          which uses _GNU_SOURCE and which I think must be protected against multiple inclusion,
5          which basically means if you set it too late, it's not seen, because the headers
6          have already been parsed with _GNU_SOURCE unset
7 */
8
9 #define _GNU_SOURCE
10
11 #include <assert.h>
12 #include <math.h>
13 #include <stdio.h>
14 #include <stdarg.h>
15 #include <stdlib.h>
16 #include <string.h>
17 #include <time.h>
18
19 /***** internal includes *****/
20 #include "abstraction.h"
21
22 /***** external includes *****/
23 #include "liblfds610.h"
24
25 /***** defines *****/
26 #define and &&
27 #define or  ||
28
29 #define RAISED   1
30 #define LOWERED  0
31
32 #define NO_FLAGS 0x0
33
34 /***** enums *****/
35 enum lfds610_test_operation
36 {
37   UNKNOWN,
38   HELP,
39   TEST,
40   BENCHMARK
41 };
42
43 /***** structs *****/
44 #include "structures.h"
45
46 /***** prototypes *****/
47 int main( int argc, char **argv );
48
49 void internal_display_test_name( char *test_name );
50 void internal_display_test_result( unsigned int number_name_dvs_pairs, ... );
51 void internal_display_lfds610_data_structure_validity( enum lfds610_data_structure_validity dvs );
52
53 void benchmark_lfds610_freelist( void );
54   thread_return_t CALLING_CONVENTION benchmark_lfds610_freelist_thread_pop_and_push( void *freelist_benchmark );
55
56 void benchmark_lfds610_queue( void );
57   thread_return_t CALLING_CONVENTION benchmark_lfds610_queue_thread_delfds610_queue_and_enqueue( void *queue_benchmark );
58
59 void benchmark_lfds610_ringbuffer( void );
60   thread_return_t CALLING_CONVENTION benchmark_lfds610_ringbuffer_thread_write_and_read( void *ringbuffer_benchmark );
61
62 void benchmark_lfds610_stack( void );
63   thread_return_t CALLING_CONVENTION benchmark_lfds610_stack_thread_push_and_pop( void *stack_benchmark );
64
65 void test_lfds610_abstraction( void );
66   void abstraction_test_increment( void );
67     thread_return_t CALLING_CONVENTION abstraction_test_internal_thread_increment( void *shared_counter );
68     thread_return_t CALLING_CONVENTION abstraction_test_internal_thread_atomic_increment( void *shared_counter );
69   void abstraction_test_cas( void );
70     thread_return_t CALLING_CONVENTION abstraction_test_internal_thread_cas( void *abstraction_test_cas_state );
71   void abstraction_test_dcas( void );
72     thread_return_t CALLING_CONVENTION abstraction_test_internal_thread_dcas( void *abstraction_test_dcas_state );
73
74 void test_lfds610_freelist( void );
75   void freelist_test_internal_popping( void );
76     int freelist_test_internal_popping_init( void **user_data, void *user_state );
77     thread_return_t CALLING_CONVENTION freelist_test_internal_thread_popping( void *freelist_test_popping_state );
78   void freelist_test_internal_pushing( void );
79     int freelist_test_internal_pushing_init( void **user_data, void *user_state );
80     void freelist_test_internal_pushing_delete( void *user_data, void *user_state );
81     thread_return_t CALLING_CONVENTION freelist_test_internal_thread_pushing( void *freelist_test_pushing_state );
82   void freelist_test_internal_popping_and_pushing( void );
83     thread_return_t CALLING_CONVENTION freelist_test_internal_thread_popping_and_pushing_start_popping( void *freelist_test_popping_and_pushing_state );
84     thread_return_t CALLING_CONVENTION freelist_test_internal_thread_popping_and_pushing_start_pushing( void *freelist_test_popping_and_pushing_state );
85   void freelist_test_internal_rapid_popping_and_pushing( void );
86     thread_return_t CALLING_CONVENTION freelist_test_internal_thread_rapid_popping_and_pushing( void *lfds610_freelist_state );
87
88 void test_lfds610_queue( void );
89   void queue_test_enqueuing( void );
90     thread_return_t CALLING_CONVENTION queue_test_internal_thread_simple_enqueuer( void *queue_test_enqueuing_state );
91   void queue_test_dequeuing( void );
92     thread_return_t CALLING_CONVENTION queue_test_internal_thread_simple_dequeuer( void *queue_test_dequeuing_state );
93   void queue_test_enqueuing_and_dequeuing( void );
94     thread_return_t CALLING_CONVENTION queue_test_internal_thread_enqueuer_and_dequeuer( void *queue_test_rapid_enqueuing_and_dequeuing_state );
95   void queue_test_rapid_enqueuing_and_dequeuing( void );
96     thread_return_t CALLING_CONVENTION queue_test_internal_thread_rapid_enqueuer_and_dequeuer( void *queue_test_rapid_enqueuing_and_dequeuing_state );
97
98 void test_lfds610_ringbuffer( void );
99   void ringbuffer_test_reading( void );
100     thread_return_t CALLING_CONVENTION ringbuffer_test_thread_simple_reader( void *ringbuffer_test_reading_state );
101   void ringbuffer_test_writing( void );
102     thread_return_t CALLING_CONVENTION ringbuffer_test_thread_simple_writer( void *ringbuffer_test_writing_state );
103   void ringbuffer_test_reading_and_writing( void );
104     thread_return_t CALLING_CONVENTION ringbuffer_test_thread_reader_writer( void *ringbuffer_test_reading_and_writing_state );
105
106 void test_lfds610_slist( void );
107   void test_slist_new_delete_get( void );
108     thread_return_t CALLING_CONVENTION slist_test_internal_thread_new_delete_get_new_head_and_next( void *slist_test_state );
109     thread_return_t CALLING_CONVENTION slist_test_internal_thread_new_delete_get_delete_and_get( void *slist_test_state );
110   void test_slist_get_set_user_data( void );
111     thread_return_t CALLING_CONVENTION slist_test_internal_thread_get_set_user_data( void *slist_test_state );
112   void test_slist_delete_all_elements( void );
113
114 void test_lfds610_stack( void );
115   void stack_test_internal_popping( void );
116     thread_return_t CALLING_CONVENTION stack_test_internal_thread_popping( void *stack_test_popping_state );
117   void stack_test_internal_pushing( void );
118     thread_return_t CALLING_CONVENTION stack_test_internal_thread_pushing( void *stack_test_pushing_state );
119   void stack_test_internal_popping_and_pushing( void );
120     thread_return_t CALLING_CONVENTION stack_test_internal_thread_popping_and_pushing_start_popping( void *stack_test_popping_and_pushing_state );
121     thread_return_t CALLING_CONVENTION stack_test_internal_thread_popping_and_pushing_start_pushing( void *stack_test_popping_and_pushing_state );
122   void stack_test_internal_rapid_popping_and_pushing( void );
123     thread_return_t CALLING_CONVENTION stack_test_internal_thread_rapid_popping_and_pushing( void *stack_state );
124