]> pd.if.org Git - liblfds/blob - liblfds/liblfds7.0.0/liblfds700/src/lfds700_hash_addonly/lfds700_hash_addonly_init.c
Initial import (all versions, including the new 7.1.0)
[liblfds] / liblfds / liblfds7.0.0 / liblfds700 / src / lfds700_hash_addonly / lfds700_hash_addonly_init.c
1 /***** includes *****/
2 #include "lfds700_hash_addonly_internal.h"
3
4
5
6
7
8 /****************************************************************************/
9 void lfds700_hash_a_init_valid_on_current_logical_core( struct lfds700_hash_a_state *has,
10                           struct lfds700_btree_au_state *baus_array,
11                           lfds700_pal_uint_t array_size,
12                           int (*key_compare_function)(void const *new_key, void const *existing_key),
13                           void (*key_hash_function)(void const *key, lfds700_pal_uint_t *hash),
14                           enum lfds700_hash_a_existing_key existing_key,
15                           void *user_state )
16 {
17   enum lfds700_btree_au_existing_key
18     btree_au_existing_key = LFDS700_BTREE_AU_EXISTING_KEY_OVERWRITE; // TRD : for compiler warning
19
20   lfds700_pal_uint_t
21     loop;
22
23   LFDS700_PAL_ASSERT( has != NULL );
24   LFDS700_PAL_ASSERT( baus_array != NULL );
25   LFDS700_PAL_ASSERT( array_size > 0 );
26   LFDS700_PAL_ASSERT( key_compare_function != NULL );
27   LFDS700_PAL_ASSERT( key_hash_function != NULL );
28   // TRD : existing_key can be any value in its range
29   // TRD : user_state can be NULL
30
31   has->array_size = array_size;
32   has->key_compare_function = key_compare_function;
33   has->key_hash_function = key_hash_function;
34   has->existing_key = existing_key;
35   has->baus_array = baus_array;
36   has->user_state = user_state;
37
38   if( has->existing_key == LFDS700_HASH_A_EXISTING_KEY_OVERWRITE )
39     btree_au_existing_key = LFDS700_BTREE_AU_EXISTING_KEY_OVERWRITE;
40
41   if( has->existing_key == LFDS700_HASH_A_EXISTING_KEY_FAIL )
42     btree_au_existing_key = LFDS700_BTREE_AU_EXISTING_KEY_FAIL;
43
44   // TRD : since the addonly_hash atomic counts, if that flag is set, the btree_addonly_unbalanceds don't have to
45   for( loop = 0 ; loop < array_size ; loop++ )
46     lfds700_btree_au_init_valid_on_current_logical_core( has->baus_array+loop, key_compare_function, btree_au_existing_key, user_state );
47
48   LFDS700_MISC_BARRIER_STORE;
49
50   lfds700_misc_force_store();
51
52   return;
53 }
54