]> pd.if.org Git - liblfds/blob - liblfds/liblfds7.1.0/test_and_benchmark/libshared/inc/libshared/libshared_memory.h
Initial import (all versions, including the new 7.1.0)
[liblfds] / liblfds / liblfds7.1.0 / test_and_benchmark / libshared / inc / libshared / libshared_memory.h
1 /***** enums *****/
2 enum libshared_memory_query
3 {
4   LIBSHARED_MEMORY_QUERY_GET_AVAILABLE
5 };
6
7 /***** structs *****/
8 struct libshared_memory_element
9 {
10   char unsigned
11     *original,
12     *original_after_me_alloc,
13     *current_pointer, // TRD : "_pointer" on the end 'cause Linux kernel has lower case defines one of which is "current"
14     *rollback;
15
16   enum flag
17     known_numa_node_flag;
18
19   lfds710_pal_uint_t
20     current_memory_size_in_bytes,
21     numa_node_id,
22     original_memory_size_in_bytes,
23     original_after_me_alloc_memory_size_in_bytes,
24     rollback_memory_size_in_bytes;
25
26   struct lfds710_list_asu_element
27     lasue;
28 };
29
30 struct libshared_memory_state
31 {
32   struct lfds710_list_asu_state
33     list_of_allocations;
34 };
35
36 /***** public prototypes *****/
37 void libshared_memory_init( struct libshared_memory_state *ms );
38 void libshared_memory_cleanup( struct libshared_memory_state *ms,
39                                void (*memory_cleanup_callback)(enum flag known_numa_node_flag,
40                                                                void *store,
41                                                                lfds710_pal_uint_t size) );
42
43 void libshared_memory_add_memory( struct libshared_memory_state *ms,
44                                   void *memory,
45                                   lfds710_pal_uint_t memory_size_in_bytes );
46 void libshared_memory_add_memory_from_numa_node( struct libshared_memory_state *ms,
47                                                  lfds710_pal_uint_t numa_node_id,
48                                                  void *memory,
49                                                  lfds710_pal_uint_t memory_size_in_bytes );
50
51 void *libshared_memory_alloc_from_unknown_node( struct libshared_memory_state *ms, lfds710_pal_uint_t size_in_bytes, lfds710_pal_uint_t alignment_in_bytes );
52 void *libshared_memory_alloc_from_specific_node( struct libshared_memory_state *ms, lfds710_pal_uint_t numa_node_id, lfds710_pal_uint_t size_in_bytes, lfds710_pal_uint_t alignment_in_bytes );
53 void *libshared_memory_alloc_from_most_free_space_node( struct libshared_memory_state *ms, lfds710_pal_uint_t size_in_bytes, lfds710_pal_uint_t alignment_in_bytes );
54 void *libshared_memory_alloc_largest_possible_array_from_unknown_node( struct libshared_memory_state *ms, lfds710_pal_uint_t element_size_in_bytes, lfds710_pal_uint_t alignment_in_bytes, lfds710_pal_uint_t *number_elements );
55
56 void libshared_memory_set_rollback( struct libshared_memory_state *ms );
57 void libshared_memory_rollback( struct libshared_memory_state *ms );
58
59 void libshared_memory_query( struct libshared_memory_state *ms,
60                              enum libshared_memory_query query_type,
61                              void *query_input,
62                              void *query_output );
63