NVMLib  very early alpha
A library to optimally use a Hybrid RAM setup.
types.h
Go to the documentation of this file.
1 #ifndef __NVM_TYPES__
2 #define __NVM_TYPES__
3 
11 #include "globals.h"
12 #include "malloc.h"
13 #include "hashmap_tx.h"
14 
15 
16 #define LIB_TOID_NULL(t) ((LIB_TOID(t))MEMOID_NULL)
17 
18 
19 #define LIB_TOID_ASSIGN(o, value)(\
20 {\
21  (o).oidkey = value;\
22  (o); /* to avoid "error: statement with no effect" */\
23 })
24 
25 
26 #define LIB_TOID_EQUALS(lhs, rhs)\
27 (get_MEMoid((lhs).oid).off == get_MEMoid((rhs).oid).off &&\
28  get_MEMoid((lhs).oid).pool_uuid_lo == get_MEMoid((rhs).oid).pool_uuid_lo)
29 
30 
31 // dummys to make sure the <space> (ex: struct blah) has no effect
32 #define _lib_toid_struct
33 #define _lib_toid_union
34 #define _lib_toid_enum
35 
36 
43 #define LIB_TOID(t)\
44 union _lib_toid_##t##_toid
45 
55 #define LIB_TOID_DECLARE(t)\
56 typedef uint8_t _lib_toid_##t##_toid_type_num[__COUNTER__ + 1];\
57 LIB_TOID(t)\
58 {\
59  MEMoidKey oidkey;\
60  t *_type;\
61  _lib_toid_##t##_toid_type_num *_type_num;\
62 }
63 
64 // Type number
65 #define LIB_TOID_TYPE_NUM(t) (sizeof(_lib_toid_##t##_toid_type_num) - 1)
66 
67 
68 //Type number of object read from typed OID
69 #define LIB_TOID_TYPE_NUM_OF(o) (sizeof(*(o)._type_num) - 1)
70 
71 
73 #define LIB_TOID_IS_NULL(o) (get_MEMoid((o).oidkey).off == 0)
74 
75 // Actual type of stored object
76 #define LIB_TOID_TYPEOF(o) __typeof__(*(o)._type)
77 
78 // Direct Write
79 #define LIB_DIRECT_RW(o) (\
80 {__typeof__(o) _o; _o._type = NULL; (void)_o;\
81 (__typeof__(*(o)._type) *)get_memobj_direct(get_MEMoid((o).oidkey)); })
82 
83 // Direct Read
84 #define LIB_DIRECT_RO(o) (\
85 {__typeof__(o) _o; _o._type = NULL; (void)_o;\
86 (const __typeof__(*(o)._type) *)get_memobj_direct(get_MEMoid((o).oidkey)); })
87 
88 //#define LIB_TX_BEGIN uv_mutex_lock(&object_maintainence_hashmap_mutex)
89 //#define LIB_TX_END uv_mutex_unlock(&object_maintainence_hashmap_mutex)
90 
97 #define LIB_D_RW LIB_DIRECT_RW
98 
105 #define LIB_D_RO LIB_DIRECT_RO
106 
107 // Fuctions
108 
110 // It returns the MEMoid struct after querrying the HashTable.
112 
114 
116 
117 // Will be used by the logistics thread
118 TOID(struct hashmap_tx) *get_types_map();
119 
120 void debug_hashmap(MEMoidKey key);
121 
122 
123 // void* _key_get_first(MEMoidKey key);
124 // void* _key_get_last(MEMoidKey key)
125 // #define KEY_FIRST(key) (_key_get_first(key))
126 // #define KEY_LAST(key) (_key_get_last(key))
127 
128 #endif // ! __NVM_TYPES__
TOID
TOID(struct hashmap_tx) *get_types_map()
Definition: types.c:11
remove_object_from_hashmap
void remove_object_from_hashmap(MEMoidKey key)
Definition: types.c:74
hashmap_tx
Definition: hashmap_tx.h:48
get_MEMoid
MEMoid get_MEMoid(MEMoidKey key)
The function to obtain the MEMoid object given the MEMoidKey
Definition: types.c:64
MEMoid_st
The struct that stores the memptr for the object.
Definition: malloc.h:29
MEMoidKey
uint64_t MEMoidKey
The key of the HashTable that contains <MEMoidKey, MEMoid>.
Definition: malloc.h:49
init_types_table
void init_types_table()
globals.h
insert_object_to_hashmap
void insert_object_to_hashmap(MEMoidKey key, MEMoid oid)
Definition: types.c:70
malloc.h
debug_hashmap
void debug_hashmap(MEMoidKey key)
Definition: types.c:82
hashmap_tx.h