]> git.proxmox.com Git - grub2.git/blob - include/grub/mm.h
bump version to 2.06-13+pmx2
[grub2.git] / include / grub / mm.h
1 /* mm.h - prototypes and declarations for memory manager */
2 /*
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2002,2007 Free Software Foundation, Inc.
5 *
6 * GRUB is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * GRUB is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef GRUB_MM_H
21 #define GRUB_MM_H 1
22
23 #include <grub/types.h>
24 #include <grub/symbol.h>
25 #include <config.h>
26
27 #ifndef NULL
28 # define NULL ((void *) 0)
29 #endif
30
31 void grub_mm_init_region (void *addr, grub_size_t size);
32 void *EXPORT_FUNC(grub_calloc) (grub_size_t nmemb, grub_size_t size);
33 void *EXPORT_FUNC(grub_malloc) (grub_size_t size);
34 void *EXPORT_FUNC(grub_zalloc) (grub_size_t size);
35 void EXPORT_FUNC(grub_free) (void *ptr);
36 void *EXPORT_FUNC(grub_realloc) (void *ptr, grub_size_t size);
37 #ifndef GRUB_MACHINE_EMU
38 void *EXPORT_FUNC(grub_memalign) (grub_size_t align, grub_size_t size);
39 #endif
40
41 void grub_mm_check_real (const char *file, int line);
42 #define grub_mm_check() grub_mm_check_real (GRUB_FILE, __LINE__);
43
44 /* For debugging. */
45 #if defined(MM_DEBUG) && !defined(GRUB_UTIL) && !defined (GRUB_MACHINE_EMU)
46 /* Set this variable to 1 when you want to trace all memory function calls. */
47 extern int EXPORT_VAR(grub_mm_debug);
48
49 void grub_mm_dump_free (void);
50 void grub_mm_dump (unsigned lineno);
51
52 #define grub_calloc(nmemb, size) \
53 grub_debug_calloc (GRUB_FILE, __LINE__, nmemb, size)
54
55 #define grub_malloc(size) \
56 grub_debug_malloc (GRUB_FILE, __LINE__, size)
57
58 #define grub_zalloc(size) \
59 grub_debug_zalloc (GRUB_FILE, __LINE__, size)
60
61 #define grub_realloc(ptr,size) \
62 grub_debug_realloc (GRUB_FILE, __LINE__, ptr, size)
63
64 #define grub_memalign(align,size) \
65 grub_debug_memalign (GRUB_FILE, __LINE__, align, size)
66
67 #define grub_free(ptr) \
68 grub_debug_free (GRUB_FILE, __LINE__, ptr)
69
70 void *EXPORT_FUNC(grub_debug_calloc) (const char *file, int line,
71 grub_size_t nmemb, grub_size_t size);
72 void *EXPORT_FUNC(grub_debug_malloc) (const char *file, int line,
73 grub_size_t size);
74 void *EXPORT_FUNC(grub_debug_zalloc) (const char *file, int line,
75 grub_size_t size);
76 void EXPORT_FUNC(grub_debug_free) (const char *file, int line, void *ptr);
77 void *EXPORT_FUNC(grub_debug_realloc) (const char *file, int line, void *ptr,
78 grub_size_t size);
79 void *EXPORT_FUNC(grub_debug_memalign) (const char *file, int line,
80 grub_size_t align, grub_size_t size);
81 #endif /* MM_DEBUG && ! GRUB_UTIL */
82
83 #endif /* ! GRUB_MM_H */