Subversion Repositories shark

Rev

Rev 141 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
141 trimarchi 1
/*
2
 * Doubly indexed dynamic memory allocator (DIDMA)
3
 * Version 0.61
4
 *
5
 * Written by Miguel Masmano Tello <mmasmano@disca.upv.es>
6
 * Copyright (C) Dec, 2002 OCERA Consortium
7
 * Release under the terms of the GNU General Public License Version 2
8
 *
9
 */
10
 
11
#ifndef _INDEXED_MALLOC_H_
12
#define _INDEXED_MALLOC_H_
13
 
14
#include <kernel/mem.h>
15
#include <stdio.h>
16
 
17
/*
18
 * if __DEBUG__ is defined several functions like mem_dump(),
19
 * free_blocks_context() will be availables.
20
 */
21
//#define __DEBUG__
22
 
23
/*
24
 * MAX_FL_INDEX define the max first level number of indexes
25
 */
26
static int MAX_FL_INDEX = 25;
27
 
28
#define PRINT_MSG printk
29
#define PRINT_DBG_C(message) printk(message)
30
#define PRINT_DBG_D(message) printk("%i", message);
31
//#define PRINT_DBG_F(message) rtl_printf("%f", message);
32
#define PRINT_DBG_H(message) printk("%i", message);
33
 
34
#define SYSTEM_MALLOC(size) (void *) kern_alloc(size)
35
#define SYSTEM_FREE(ptr) kern_free((void *) ptr, 0);
36
 
37
int init_memory_pool (int max_size);
38
void destroy_memory_pool(void);
39
 
40
/* see man malloc */
41
void *rt_malloc (size_t size);
42
 
43
/* see man realloc */
44
void *rt_realloc(void *p, size_t new_len);
45
 
46
/* see man calloc */
47
void *rt_calloc(size_t nelem, size_t elem_size);
48
 
49
/*  
50
 * see man free
51
 *
52
 * rt_free () is only guaranteed to work if ptr is the address of a block
53
 * allocated by rt_malloc() (and not yet freed).
54
 */
55
void rt_free (void *ptr);
56
 
57
#ifdef __DEBUG__
58
 
59
/* dump_mem () does a dumped of the memory context */
60
void dump_mem (void);
61
 
62
/*
63
 * free_blocks_context () show the content
64
 * of free blocks
65
 */
66
void free_blocks_context(void);
67
 
68
/*
69
 * structure_context () gives information about
70
 * algorithm structures
71
 */
72
void structure_context (void);
73
 
74
/*
75
 * check_mem () checks memory searching
76
 * errors and incoherences
77
 * return :
78
 * 0 if there isn't any error
79
 * or
80
 * -1 in other case
81
 */
82
int check_mem (void);
83
 
84
/*
85
 * global_state () returns overhead, free and used space
86
 */
87
void global_state (int *free, int *used, int *overhead);
88
 
89
#endif // DEBUG
90
#endif // #ifndef _INDEXED_MALLOC_H_