NVMLib  very early alpha
A library to optimally use a Hybrid RAM setup.
types.h File Reference
#include "globals.h"
#include "malloc.h"
#include "hashmap_tx.h"
Include dependency graph for types.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define LIB_TOID_NULL(t)   ((LIB_TOID(t))MEMOID_NULL)
 
#define LIB_TOID_ASSIGN(o, value)
 
#define LIB_TOID_EQUALS(lhs, rhs)
 
#define _lib_toid_struct
 
#define _lib_toid_union
 
#define _lib_toid_enum
 
#define LIB_TOID(t)   union _lib_toid_##t##_toid
 The MACRO used by user while allocating memory. More...
 
#define LIB_TOID_DECLARE(t)
 Declaration of a type. More...
 
#define LIB_TOID_TYPE_NUM(t)   (sizeof(_lib_toid_##t##_toid_type_num) - 1)
 
#define LIB_TOID_TYPE_NUM_OF(o)   (sizeof(*(o)._type_num) - 1)
 
#define LIB_TOID_IS_NULL(o)   (get_MEMoid((o).oidkey).off == 0)
 NULL check. More...
 
#define LIB_TOID_TYPEOF(o)   __typeof__(*(o)._type)
 
#define LIB_DIRECT_RW(o)
 
#define LIB_DIRECT_RO(o)
 
#define LIB_D_RW   LIB_DIRECT_RW
 The MACRO used by the user when they want to write into the object. More...
 
#define LIB_D_RO   LIB_DIRECT_RO
 The MACRO used by the user when they want to read from the object. More...
 

Functions

void init_types_table ()
 
MEMoid get_MEMoid (MEMoidKey key)
 The function to obtain the MEMoid object given the MEMoidKey More...
 
void insert_object_to_hashmap (MEMoidKey key, MEMoid oid)
 
void remove_object_from_hashmap (MEMoidKey key)
 
 TOID (struct hashmap_tx) *get_types_map()
 
void debug_hashmap (MEMoidKey key)
 

Detailed Description

This file contains the information required for maintaining the types of objects. The user facing APIs for reading and wrinting the object are defined here.

Definition in file types.h.

Macro Definition Documentation

◆ _lib_toid_enum

#define _lib_toid_enum

Definition at line 35 of file types.h.

◆ _lib_toid_struct

#define _lib_toid_struct

Definition at line 33 of file types.h.

◆ _lib_toid_union

#define _lib_toid_union

Definition at line 34 of file types.h.

◆ LIB_D_RO

#define LIB_D_RO   LIB_DIRECT_RO

The MACRO used by the user when they want to read from the object.

Example

int temp = LIB_D_RO(array)[3]; // Read from array[3].

Definition at line 106 of file types.h.

◆ LIB_D_RW

#define LIB_D_RW   LIB_DIRECT_RW

The MACRO used by the user when they want to write into the object.

Example

LIB_D_RW(array)[3] = 1729; // Wrote `3` into array[3].

Definition at line 98 of file types.h.

◆ LIB_DIRECT_RO

#define LIB_DIRECT_RO (   o)
Value:
(\
{__typeof__(o) _o; _o._type = NULL; (void)_o;\
(const __typeof__(*(o)._type) *)get_memobj_direct(get_MEMoid((o).oidkey)); })

Definition at line 85 of file types.h.

◆ LIB_DIRECT_RW

#define LIB_DIRECT_RW (   o)
Value:
(\
{__typeof__(o) _o; _o._type = NULL; (void)_o;\
(__typeof__(*(o)._type) *)get_memobj_direct(get_MEMoid((o).oidkey)); })

Definition at line 80 of file types.h.

◆ LIB_TOID

#define LIB_TOID (   t)    union _lib_toid_##t##_toid

The MACRO used by user while allocating memory.

Example

LIB_TOID(int) array = LIB_TOID(int)memalloc(10 * sizeof(int)); // allocated an integer array of size 10.

Definition at line 44 of file types.h.

◆ LIB_TOID_ASSIGN

#define LIB_TOID_ASSIGN (   o,
  value 
)
Value:
(\
{\
(o).oidkey = value;\
(o); /* to avoid "error: statement with no effect" */\
})

Definition at line 20 of file types.h.

◆ LIB_TOID_DECLARE

#define LIB_TOID_DECLARE (   t)
Value:
typedef uint8_t _lib_toid_##t##_toid_type_num[__COUNTER__ + 1];\
LIB_TOID(t)\
{\
MEMoidKey oidkey;\
t *_type;\
_lib_toid_##t##_toid_type_num *_type_num;\
}

Declaration of a type.

Example

LIB_TOID_DECLARE(int) // after this LIB_TOID(int) is valid.
Attention
The user has to use this for every type they want to use with memalloc, before the declare the varibale using LIB_TOID.
Warning
There is only one instance of __COUNTER__ in preprocessor!!!!!

Definition at line 56 of file types.h.

◆ LIB_TOID_EQUALS

#define LIB_TOID_EQUALS (   lhs,
  rhs 
)
Value:
(get_MEMoid((lhs).oid).off == get_MEMoid((rhs).oid).off &&\
get_MEMoid((lhs).oid).pool_uuid_lo == get_MEMoid((rhs).oid).pool_uuid_lo)

Definition at line 27 of file types.h.

◆ LIB_TOID_IS_NULL

#define LIB_TOID_IS_NULL (   o)    (get_MEMoid((o).oidkey).off == 0)

NULL check.

Definition at line 74 of file types.h.

◆ LIB_TOID_NULL

#define LIB_TOID_NULL (   t)    ((LIB_TOID(t))MEMOID_NULL)

Definition at line 17 of file types.h.

◆ LIB_TOID_TYPE_NUM

#define LIB_TOID_TYPE_NUM (   t)    (sizeof(_lib_toid_##t##_toid_type_num) - 1)

Definition at line 66 of file types.h.

◆ LIB_TOID_TYPE_NUM_OF

#define LIB_TOID_TYPE_NUM_OF (   o)    (sizeof(*(o)._type_num) - 1)

Definition at line 70 of file types.h.

◆ LIB_TOID_TYPEOF

#define LIB_TOID_TYPEOF (   o)    __typeof__(*(o)._type)

Definition at line 77 of file types.h.

Function Documentation

◆ debug_hashmap()

void debug_hashmap ( MEMoidKey  key)

Definition at line 82 of file types.c.

Here is the call graph for this function:

◆ get_MEMoid()

MEMoid get_MEMoid ( MEMoidKey  key)

The function to obtain the MEMoid object given the MEMoidKey

Parameters
keythe MEMoidKey
Returns
The MEMoid object represented by the key upon success.
MEMOID_NULL upon failure.

Definition at line 64 of file types.c.

Here is the call graph for this function:

◆ init_types_table()

void init_types_table ( )

◆ insert_object_to_hashmap()

void insert_object_to_hashmap ( MEMoidKey  key,
MEMoid  oid 
)

Definition at line 70 of file types.c.

Here is the call graph for this function:

◆ remove_object_from_hashmap()

void remove_object_from_hashmap ( MEMoidKey  key)

Definition at line 74 of file types.c.

Here is the call graph for this function:

◆ TOID()

TOID ( struct hashmap_tx  )

Definition at line 11 of file types.c.

Here is the call graph for this function:
get_memobj_direct
void * get_memobj_direct(MEMoid oid)
The function to return the actual memptr for a given MEMoid object.
Definition: malloc.c:316
get_MEMoid
MEMoid get_MEMoid(MEMoidKey key)
The function to obtain the MEMoid object given the MEMoidKey
Definition: types.c:64
LIB_D_RW
#define LIB_D_RW
The MACRO used by the user when they want to write into the object.
Definition: types.h:97
LIB_TOID
#define LIB_TOID(t)
The MACRO used by user while allocating memory.
Definition: types.h:43
memalloc
#define memalloc(size,...)
The user API for requesting allocation of object.
Definition: malloc.h:78
LIB_TOID_DECLARE
#define LIB_TOID_DECLARE(t)
Declaration of a type.
Definition: types.h:55
LIB_D_RO
#define LIB_D_RO
The MACRO used by the user when they want to read from the object.
Definition: types.h:105
NULL
#define NULL
Definition: list.h:13
uint8_t
__uint8_t uint8_t
Definition: globals.h:54