Go to the source code of this file.
Classes | |
struct | area_info_struct |
struct | bhdr_struct |
struct | free_ptr_struct |
struct | TLSF_struct |
Defines | |
#define | __inline__ |
#define | _DEBUG_TLSF_ (0) |
#define | BHDR_OVERHEAD (sizeof (bhdr_t) - MIN_BLOCK_SIZE) |
#define | BLOCK_ALIGN (sizeof(void *) * 2) |
#define | BLOCK_SIZE (0xFFFFFFFF - PTR_MASK) |
#define | BLOCK_STATE (0x1) |
#define | DEFAULT_AREA_SIZE (1024*10) |
#define | ERROR_MSG(fmt, args...) printf(fmt, ## args) |
#define | EXTRACT_BLOCK(_b, _tlsf, _fl, _sl) |
#define | EXTRACT_BLOCK_HDR(_b, _tlsf, _fl, _sl) |
#define | FLI_OFFSET (6) /* tlsf structure just will manage blocks bigger */ |
#define | FREE_BLOCK (0x1) |
#define | GET_NEXT_BLOCK(_addr, _r) ((bhdr_t *) ((char *) (_addr) + (_r))) |
#define | INSERT_BLOCK(_b, _tlsf, _fl, _sl) |
#define | MAX_FLI (30) |
#define | MAX_LOG2_SLI (5) |
#define | MAX_SLI (1 << MAX_LOG2_SLI) /* MAX_SLI = 2^MAX_LOG2_SLI */ |
#define | MEM_ALIGN ((BLOCK_ALIGN) - 1) |
#define | MIN_BLOCK_SIZE (sizeof (free_ptr_t)) |
#define | ORO_MEMORY_POOL |
#define | PREV_FREE (0x2) |
#define | PREV_STATE (0x2) |
#define | PREV_USED (0x0) |
#define | PRINT_MSG(fmt, args...) printf(fmt, ## args) |
#define | PTR_MASK (sizeof(void *) - 1) |
#define | REAL_FLI (MAX_FLI - FLI_OFFSET) |
#define | ROUNDDOWN_SIZE(_r) ((_r) & ~MEM_ALIGN) |
#define | ROUNDUP(_x, _v) ((((~(_x)) + 1) & ((_v)-1)) + (_x)) |
#define | ROUNDUP_SIZE(_r) (((_r) + MEM_ALIGN) & ~MEM_ALIGN) |
#define | SMALL_BLOCK (128) |
#define | TLSF_ADD_SIZE(tlsf, b) do{}while(0) |
#define | TLSF_REMOVE_SIZE(tlsf, b) do{}while(0) |
#define | TLSF_SIGNATURE (0x2A59FA59) |
#define | TLSF_STATISTIC (0) |
#define | TLSF_USE_LOCKS (1) |
#define | USE_MMAP (0) |
#define | USE_SBRK (0) |
#define | USED_BLOCK (0x0) |
Typedefs | |
typedef struct area_info_struct | area_info_t |
typedef struct bhdr_struct | bhdr_t |
typedef struct free_ptr_struct | free_ptr_t |
typedef struct TLSF_struct | tlsf_t |
typedef unsigned int | u32_t |
typedef unsigned char | u8_t |
Functions | |
size_t | add_new_area (void *area, size_t area_size, void *mem_pool) |
void * | calloc_ex (size_t nelem, size_t elem_size, void *mem_pool) |
static __inline__ void | clear_bit (int nr, u32_t *addr) |
void | destroy_memory_pool (void *mem_pool) |
static __inline__ bhdr_t * | FIND_SUITABLE_BLOCK (tlsf_t *_tlsf, int *_fl, int *_sl) |
void | free_ex (void *ptr, void *mem_pool) |
size_t | get_max_size (void *mem_pool) |
size_t | get_used_size (void *mem_pool) |
size_t | init_memory_pool (size_t mem_pool_size, void *mem_pool) |
static __inline__ int | ls_bit (int x) |
void * | malloc_ex (size_t size, void *mem_pool) |
static __inline__ void | MAPPING_INSERT (size_t _r, int *_fl, int *_sl) |
static __inline__ void | MAPPING_SEARCH (size_t *_r, int *_fl, int *_sl) |
static __inline__ int | ms_bit (int x) |
static __inline__ bhdr_t * | process_area (void *area, size_t size) |
void * | realloc_ex (void *ptr, size_t new_size, void *mem_pool) |
static __inline__ void | set_bit (int nr, u32_t *addr) |
void * | tlsf_calloc (size_t nelem, size_t elem_size) |
void | tlsf_free (void *ptr) |
void * | tlsf_malloc (size_t size) |
void * | tlsf_realloc (void *ptr, size_t size) |
Variables | |
static int | init_check = 0 |
static char * | mp = NULL |
static const int | table [] |
#define __inline__ |
#define _DEBUG_TLSF_ (0) |
#define BHDR_OVERHEAD (sizeof (bhdr_t) - MIN_BLOCK_SIZE) |
#define BLOCK_ALIGN (sizeof(void *) * 2) |
#define BLOCK_SIZE (0xFFFFFFFF - PTR_MASK) |
#define BLOCK_STATE (0x1) |
#define DEFAULT_AREA_SIZE (1024*10) |
#define EXTRACT_BLOCK | ( | _b, | |
_tlsf, | |||
_fl, | |||
_sl | |||
) |
do { \ if (_b -> ptr.free_ptr.next) \ _b -> ptr.free_ptr.next -> ptr.free_ptr.prev = _b -> ptr.free_ptr.prev; \ if (_b -> ptr.free_ptr.prev) \ _b -> ptr.free_ptr.prev -> ptr.free_ptr.next = _b -> ptr.free_ptr.next; \ if (_tlsf -> matrix [_fl][_sl] == _b) { \ _tlsf -> matrix [_fl][_sl] = _b -> ptr.free_ptr.next; \ if (!_tlsf -> matrix [_fl][_sl]) { \ clear_bit (_sl, &_tlsf -> sl_bitmap[_fl]); \ if (!_tlsf -> sl_bitmap [_fl]) \ clear_bit (_fl, &_tlsf -> fl_bitmap); \ } \ } \ _b -> ptr.free_ptr.prev = NULL; \ _b -> ptr.free_ptr.next = NULL; \ } while(0)
#define EXTRACT_BLOCK_HDR | ( | _b, | |
_tlsf, | |||
_fl, | |||
_sl | |||
) |
do { \ _tlsf -> matrix [_fl] [_sl] = _b -> ptr.free_ptr.next; \ if (_tlsf -> matrix[_fl][_sl]) \ _tlsf -> matrix[_fl][_sl] -> ptr.free_ptr.prev = NULL; \ else { \ clear_bit (_sl, &_tlsf -> sl_bitmap [_fl]); \ if (!_tlsf -> sl_bitmap [_fl]) \ clear_bit (_fl, &_tlsf -> fl_bitmap); \ } \ _b -> ptr.free_ptr.prev = NULL; \ _b -> ptr.free_ptr.next = NULL; \ }while(0)
#define FLI_OFFSET (6) /* tlsf structure just will manage blocks bigger */ |
#define FREE_BLOCK (0x1) |
#define GET_NEXT_BLOCK | ( | _addr, | |
_r | |||
) | ((bhdr_t *) ((char *) (_addr) + (_r))) |
#define INSERT_BLOCK | ( | _b, | |
_tlsf, | |||
_fl, | |||
_sl | |||
) |
do { \ _b -> ptr.free_ptr.prev = NULL; \ _b -> ptr.free_ptr.next = _tlsf -> matrix [_fl][_sl]; \ if (_tlsf -> matrix [_fl][_sl]) \ _tlsf -> matrix [_fl][_sl] -> ptr.free_ptr.prev = _b; \ _tlsf -> matrix [_fl][_sl] = _b; \ set_bit (_sl, &_tlsf -> sl_bitmap [_fl]); \ set_bit (_fl, &_tlsf -> fl_bitmap); \ } while(0)
#define MAX_LOG2_SLI (5) |
#define MAX_SLI (1 << MAX_LOG2_SLI) /* MAX_SLI = 2^MAX_LOG2_SLI */ |
#define MEM_ALIGN ((BLOCK_ALIGN) - 1) |
#define MIN_BLOCK_SIZE (sizeof (free_ptr_t)) |
#define ORO_MEMORY_POOL |
#define PREV_STATE (0x2) |
#define REAL_FLI (MAX_FLI - FLI_OFFSET) |
#define ROUNDDOWN_SIZE | ( | _r | ) | ((_r) & ~MEM_ALIGN) |
#define ROUNDUP | ( | _x, | |
_v | |||
) | ((((~(_x)) + 1) & ((_v)-1)) + (_x)) |
#define ROUNDUP_SIZE | ( | _r | ) | (((_r) + MEM_ALIGN) & ~MEM_ALIGN) |
#define SMALL_BLOCK (128) |
#define TLSF_ADD_SIZE | ( | tlsf, | |
b | |||
) | do{}while(0) |
#define TLSF_REMOVE_SIZE | ( | tlsf, | |
b | |||
) | do{}while(0) |
#define TLSF_SIGNATURE (0x2A59FA59) |
#define TLSF_STATISTIC (0) |
#define TLSF_USE_LOCKS (1) |
#define USED_BLOCK (0x0) |
typedef struct area_info_struct area_info_t |
typedef struct bhdr_struct bhdr_t |
typedef struct free_ptr_struct free_ptr_t |
typedef struct TLSF_struct tlsf_t |
size_t add_new_area | ( | void * | area, |
size_t | area_size, | ||
void * | mem_pool | ||
) |
void* calloc_ex | ( | size_t | nelem, |
size_t | elem_size, | ||
void * | mem_pool | ||
) |
static __inline__ void clear_bit | ( | int | nr, |
u32_t * | addr | ||
) | [static] |
void destroy_memory_pool | ( | void * | mem_pool | ) |
static __inline__ bhdr_t * FIND_SUITABLE_BLOCK | ( | tlsf_t * | _tlsf, |
int * | _fl, | ||
int * | _sl | ||
) | [static] |
size_t get_max_size | ( | void * | mem_pool | ) |
size_t get_used_size | ( | void * | mem_pool | ) |
size_t init_memory_pool | ( | size_t | mem_pool_size, |
void * | mem_pool | ||
) |
static __inline__ int ls_bit | ( | int | x | ) | [static] |
static __inline__ void MAPPING_INSERT | ( | size_t | _r, |
int * | _fl, | ||
int * | _sl | ||
) | [static] |
static __inline__ void MAPPING_SEARCH | ( | size_t * | _r, |
int * | _fl, | ||
int * | _sl | ||
) | [static] |
static __inline__ int ms_bit | ( | int | x | ) | [static] |
static __inline__ bhdr_t * process_area | ( | void * | area, |
size_t | size | ||
) | [static] |
void* realloc_ex | ( | void * | ptr, |
size_t | new_size, | ||
void * | mem_pool | ||
) |
static __inline__ void set_bit | ( | int | nr, |
u32_t * | addr | ||
) | [static] |
void* tlsf_calloc | ( | size_t | nelem, |
size_t | elem_size | ||
) |
void* tlsf_malloc | ( | size_t | size | ) |
void* tlsf_realloc | ( | void * | ptr, |
size_t | size | ||
) |
int init_check = 0 [static] |
const int table[] [static] |
{ -1, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }