1 #include "lfds610_liblfds_internal.h"
7 /****************************************************************************/
8 void lfds610_liblfds_abstraction_test_helper_increment_non_atomic( lfds610_atom_t *shared_counter )
10 /* TRD : lfds610_atom_t must be volatile or the compiler
11 optimizes it away into a single store
14 volatile lfds610_atom_t
17 assert( shared_counter != NULL );
19 while( count++ < 10000000 )
20 (*(lfds610_atom_t *) shared_counter)++;
29 /****************************************************************************/
30 void lfds610_liblfds_abstraction_test_helper_increment_atomic( volatile lfds610_atom_t *shared_counter )
35 assert( shared_counter != NULL );
37 while( count++ < 10000000 )
38 lfds610_abstraction_increment( shared_counter );
47 /****************************************************************************/
48 void lfds610_liblfds_abstraction_test_helper_cas( volatile lfds610_atom_t *shared_counter, lfds610_atom_t *local_counter )
54 LFDS610_ALIGN(LFDS610_ALIGN_SINGLE_POINTER) lfds610_atom_t
58 assert( shared_counter != NULL );
59 assert( local_counter != NULL );
61 while( loop++ < 1000000 )
65 compare = *shared_counter;
66 exchange = compare + 1;
68 original_destination = lfds610_abstraction_cas( shared_counter, exchange, compare );
70 while( original_destination != compare );
82 /****************************************************************************/
83 void lfds610_liblfds_abstraction_test_helper_dcas( volatile lfds610_atom_t *shared_counter, lfds610_atom_t *local_counter )
88 LFDS610_ALIGN(LFDS610_ALIGN_DOUBLE_POINTER) lfds610_atom_t
92 assert( shared_counter != NULL );
93 assert( local_counter != NULL );
95 while( loop++ < 1000000 )
97 compare[0] = *shared_counter;
98 compare[1] = *(shared_counter+1);
102 exchange[0] = compare[0] + 1;
103 exchange[1] = compare[1];
105 while( 0 == lfds610_abstraction_dcas(shared_counter, exchange, compare) );