2002-12-27 08:53:07 +00:00
|
|
|
/* mm.h - prototypes and declarations for memory manager */
|
|
|
|
/*
|
2004-04-04 13:46:03 +00:00
|
|
|
* GRUB -- GRand Unified Bootloader
|
2007-02-20 22:39:57 +00:00
|
|
|
* Copyright (C) 2002,2007 Free Software Foundation, Inc.
|
2002-12-27 08:53:07 +00:00
|
|
|
*
|
2007-07-21 23:32:33 +00:00
|
|
|
* GRUB is free software: you can redistribute it and/or modify
|
2002-12-27 08:53:07 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2007-07-21 23:32:33 +00:00
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
2002-12-27 08:53:07 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2007-07-21 23:32:33 +00:00
|
|
|
* GRUB is distributed in the hope that it will be useful,
|
2002-12-27 08:53:07 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2007-07-21 23:32:33 +00:00
|
|
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
2002-12-27 08:53:07 +00:00
|
|
|
*/
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
#ifndef GRUB_MM_H
|
|
|
|
#define GRUB_MM_H 1
|
2002-12-27 08:53:07 +00:00
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
#include <grub/types.h>
|
|
|
|
#include <grub/symbol.h>
|
2006-04-25 20:08:31 +00:00
|
|
|
#include <config.h>
|
2002-12-27 08:53:07 +00:00
|
|
|
|
2005-08-22 17:28:59 +00:00
|
|
|
#ifndef NULL
|
|
|
|
# define NULL ((void *) 0)
|
|
|
|
#endif
|
|
|
|
|
2005-01-20 17:25:39 +00:00
|
|
|
void grub_mm_init_region (void *addr, grub_size_t size);
|
|
|
|
void *EXPORT_FUNC(grub_malloc) (grub_size_t size);
|
2009-07-16 22:14:09 +00:00
|
|
|
void *EXPORT_FUNC(grub_zalloc) (grub_size_t size);
|
2004-04-04 13:46:03 +00:00
|
|
|
void EXPORT_FUNC(grub_free) (void *ptr);
|
2005-01-20 17:25:39 +00:00
|
|
|
void *EXPORT_FUNC(grub_realloc) (void *ptr, grub_size_t size);
|
|
|
|
void *EXPORT_FUNC(grub_memalign) (grub_size_t align, grub_size_t size);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
2010-08-28 19:27:10 +00:00
|
|
|
void grub_mm_check_real (char *file, int line);
|
2011-03-24 11:43:28 +00:00
|
|
|
#define grub_mm_check() grub_mm_check_real (GRUB_FILE, __LINE__);
|
2010-08-28 19:27:10 +00:00
|
|
|
|
2002-12-27 08:53:07 +00:00
|
|
|
/* For debugging. */
|
2010-02-07 03:23:44 +00:00
|
|
|
#if defined(MM_DEBUG) && !defined(GRUB_UTIL) && !defined (GRUB_MACHINE_EMU)
|
2006-04-25 20:08:31 +00:00
|
|
|
/* Set this variable to 1 when you want to trace all memory function calls. */
|
|
|
|
extern int EXPORT_VAR(grub_mm_debug);
|
|
|
|
|
2007-02-20 22:39:57 +00:00
|
|
|
void grub_mm_dump_free (void);
|
2004-04-04 13:46:03 +00:00
|
|
|
void grub_mm_dump (unsigned lineno);
|
2006-04-25 20:08:31 +00:00
|
|
|
|
|
|
|
#define grub_malloc(size) \
|
2010-02-09 14:32:42 +00:00
|
|
|
grub_debug_malloc (GRUB_FILE, __LINE__, size)
|
2006-04-25 20:08:31 +00:00
|
|
|
|
2009-07-16 22:14:09 +00:00
|
|
|
#define grub_zalloc(size) \
|
2010-02-09 14:32:42 +00:00
|
|
|
grub_debug_zalloc (GRUB_FILE, __LINE__, size)
|
2009-07-16 22:14:09 +00:00
|
|
|
|
2006-04-25 20:08:31 +00:00
|
|
|
#define grub_realloc(ptr,size) \
|
2010-02-09 14:32:42 +00:00
|
|
|
grub_debug_realloc (GRUB_FILE, __LINE__, ptr, size)
|
2006-04-25 20:08:31 +00:00
|
|
|
|
|
|
|
#define grub_memalign(align,size) \
|
2010-02-09 14:32:42 +00:00
|
|
|
grub_debug_memalign (GRUB_FILE, __LINE__, align, size)
|
2006-04-25 20:08:31 +00:00
|
|
|
|
|
|
|
#define grub_free(ptr) \
|
2010-02-09 14:32:42 +00:00
|
|
|
grub_debug_free (GRUB_FILE, __LINE__, ptr)
|
2006-04-25 20:08:31 +00:00
|
|
|
|
|
|
|
void *EXPORT_FUNC(grub_debug_malloc) (const char *file, int line,
|
|
|
|
grub_size_t size);
|
2009-07-16 22:14:09 +00:00
|
|
|
void *EXPORT_FUNC(grub_debug_zalloc) (const char *file, int line,
|
|
|
|
grub_size_t size);
|
2006-04-25 20:08:31 +00:00
|
|
|
void EXPORT_FUNC(grub_debug_free) (const char *file, int line, void *ptr);
|
|
|
|
void *EXPORT_FUNC(grub_debug_realloc) (const char *file, int line, void *ptr,
|
|
|
|
grub_size_t size);
|
|
|
|
void *EXPORT_FUNC(grub_debug_memalign) (const char *file, int line,
|
|
|
|
grub_size_t align, grub_size_t size);
|
|
|
|
#endif /* MM_DEBUG && ! GRUB_UTIL */
|
2002-12-27 08:53:07 +00:00
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
#endif /* ! GRUB_MM_H */
|