2003-12-22 19:29:21 +03:00
|
|
|
/*
|
2007-03-29 05:00:33 +04:00
|
|
|
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
|
2005-11-05 22:57:48 +03:00
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
2008-03-18 06:00:08 +03:00
|
|
|
* Copyright (c) 2004-2008 The University of Tennessee and The University
|
2005-11-05 22:57:48 +03:00
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2004-11-28 23:09:25 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-01-07 11:04:07 +03:00
|
|
|
* $HEADER$
|
2003-12-22 19:29:21 +03:00
|
|
|
*/
|
2004-01-07 11:04:07 +03:00
|
|
|
|
2004-01-07 21:39:35 +03:00
|
|
|
/** @file */
|
|
|
|
|
2005-07-04 05:36:20 +04:00
|
|
|
#ifndef OPAL_MALLOC_H
|
|
|
|
#define OPAL_MALLOC_H
|
2003-12-22 19:29:21 +03:00
|
|
|
|
2009-03-04 18:35:54 +03:00
|
|
|
#include "opal_config.h"
|
2004-01-22 03:29:32 +03:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2004-02-10 03:09:36 +03:00
|
|
|
/*
|
2005-07-04 05:36:20 +04:00
|
|
|
* THIS FILE CANNOT INCLUDE ANY OTHER OPAL HEADER FILES!!!
|
2004-02-10 03:09:36 +03:00
|
|
|
*
|
2007-03-29 05:00:33 +04:00
|
|
|
* It is included via <opal_config_bottom.h>. Hence, it should not
|
|
|
|
* include ANY other files, nor should it include "opal_config.h".
|
2004-02-10 03:09:36 +03:00
|
|
|
*
|
|
|
|
*/
|
2004-01-22 03:29:32 +03:00
|
|
|
|
2003-12-22 19:29:21 +03:00
|
|
|
/*
|
2005-07-04 05:36:20 +04:00
|
|
|
* Set OPAL_MALLOC_DEBUG_LEVEL to
|
2003-12-22 19:29:21 +03:00
|
|
|
* 0 for no checking
|
|
|
|
* 1 for basic error checking
|
|
|
|
* 2 for more error checking
|
|
|
|
*/
|
|
|
|
|
2005-07-04 05:36:20 +04:00
|
|
|
#ifndef OPAL_MALLOC_DEBUG_LEVEL
|
|
|
|
#define OPAL_MALLOC_DEBUG_LEVEL 2
|
2003-12-22 19:29:21 +03:00
|
|
|
#endif
|
|
|
|
|
2004-01-22 03:29:32 +03:00
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2004-02-10 03:09:36 +03:00
|
|
|
/**
|
|
|
|
* Initialize malloc debug output.
|
|
|
|
*
|
|
|
|
* This function is invoked to setup a dedicated output stream for
|
|
|
|
* malloc debug functions. It does \em not (currently) do anything
|
|
|
|
* other than that (i.e., no internal accounting for tracking
|
|
|
|
* malloc/free statements, etc.).
|
|
|
|
*
|
2005-07-04 05:36:20 +04:00
|
|
|
* It is invoked as part of opal_init(). Although this function is
|
|
|
|
* not \em necessary for OPAL_MALLOC() and OPAL_FREE(), it is strong
|
2004-02-10 03:09:36 +03:00
|
|
|
* recommended because no output messages -- regardless of the
|
2005-07-04 05:36:20 +04:00
|
|
|
* malloc debug level set by opal_malloc_debug() -- will be displayed
|
2004-02-10 03:09:36 +03:00
|
|
|
* unless this function is invoked first.
|
|
|
|
*/
|
2005-07-04 05:36:20 +04:00
|
|
|
void opal_malloc_init(void);
|
2005-04-05 08:08:08 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shut down malloc debug output.
|
|
|
|
*
|
2005-07-04 05:36:20 +04:00
|
|
|
* This function is invoked as part of opal_finalize() to shut down the
|
2005-04-05 08:08:08 +04:00
|
|
|
* output stream for malloc debug messages.
|
|
|
|
*/
|
2005-07-04 05:36:20 +04:00
|
|
|
void opal_malloc_finalize(void);
|
2004-02-10 03:09:36 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \internal
|
|
|
|
*
|
2005-07-04 05:36:20 +04:00
|
|
|
* Back-end error-checking malloc function for OPAL (you should use
|
2004-02-10 03:09:36 +03:00
|
|
|
* the normal malloc() instead of this function).
|
|
|
|
*
|
|
|
|
* @param size The number of bytes to allocate
|
|
|
|
* @param file Typically the __FILE__ macro
|
|
|
|
* @param line Typically the __LINE__ macro
|
|
|
|
*
|
|
|
|
* This function is only used when --enable-mem-debug was specified to
|
2004-03-27 17:53:42 +03:00
|
|
|
* configure (or by default if you're building in a SVN checkout).
|
2004-02-10 03:09:36 +03:00
|
|
|
*/
|
2007-03-20 16:01:32 +03:00
|
|
|
OPAL_DECLSPEC void *opal_malloc(size_t size, const char *file, int line) __opal_attribute_malloc__ __opal_attribute_warn_unused_result__;
|
2004-02-10 03:09:36 +03:00
|
|
|
|
2004-03-27 17:53:42 +03:00
|
|
|
/**
|
|
|
|
* \internal
|
|
|
|
*
|
2005-07-04 05:36:20 +04:00
|
|
|
* Back-end error-checking calloc function for OPAL (you should use
|
2004-03-27 17:53:42 +03:00
|
|
|
* the normal calloc() instead of this function).
|
|
|
|
*
|
|
|
|
* @param nmembers Number of elements to malloc
|
|
|
|
* @param size Size of each elements
|
|
|
|
* @param file Typically the __FILE__ macro
|
|
|
|
* @param line Typically the __LINE__ macro
|
|
|
|
*
|
|
|
|
* This function is only used when --enable-mem-debug was specified to
|
|
|
|
* configure (or by default if you're building in a SVN checkout).
|
|
|
|
*/
|
2007-03-20 16:01:32 +03:00
|
|
|
OPAL_DECLSPEC void *opal_calloc(size_t nmembers, size_t size, const char *file, int line) __opal_attribute_malloc__ __opal_attribute_warn_unused_result__;
|
2004-03-27 17:53:42 +03:00
|
|
|
|
2004-02-10 21:58:55 +03:00
|
|
|
/**
|
|
|
|
* \internal
|
|
|
|
*
|
2005-07-04 05:36:20 +04:00
|
|
|
* Back-end error-checking realloc function for OPAL (you should use
|
2004-02-10 21:58:55 +03:00
|
|
|
* the normal realloc() instead of this function).
|
|
|
|
*
|
|
|
|
* @param ptr Pointer to reallocate
|
|
|
|
* @param size The number of bytes to allocate
|
|
|
|
* @param file Typically the __FILE__ macro
|
|
|
|
* @param line Typically the __LINE__ macro
|
|
|
|
*
|
|
|
|
* This function is only used when --enable-mem-debug was specified to
|
2004-03-27 17:53:42 +03:00
|
|
|
* configure (or by default if you're building in a SVN checkout).
|
2004-02-10 21:58:55 +03:00
|
|
|
*/
|
2007-03-20 16:01:32 +03:00
|
|
|
OPAL_DECLSPEC void *opal_realloc(void *ptr, size_t size, const char *file, int line) __opal_attribute_malloc__ __opal_attribute_warn_unused_result__;
|
2004-02-10 21:58:55 +03:00
|
|
|
|
2004-02-10 03:09:36 +03:00
|
|
|
/**
|
|
|
|
* \internal
|
|
|
|
*
|
2005-07-04 05:36:20 +04:00
|
|
|
* Back-end error-checking free function for OPAL (you should use
|
2004-02-10 03:09:36 +03:00
|
|
|
* free() instead of this function).
|
|
|
|
*
|
|
|
|
* @param addr Address on the heap to free()
|
|
|
|
* @param file Typically the __FILE__ macro
|
|
|
|
* @param line Typically the __LINE__ macro
|
|
|
|
*
|
|
|
|
* This function is only used when --enable-mem-debug was specified
|
2004-03-27 17:53:42 +03:00
|
|
|
* to configure (or by default if you're building in a SVN
|
2004-02-10 03:09:36 +03:00
|
|
|
* checkout).
|
|
|
|
*/
|
2007-03-20 16:01:32 +03:00
|
|
|
OPAL_DECLSPEC void opal_free(void *addr, const char *file, int line) __opal_attribute_nonnull__(1);
|
2004-01-22 03:29:32 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Used to set the debug level for malloc debug.
|
|
|
|
*
|
|
|
|
* @param level The level of debugging (0 = none, 1 = some, 2 = more)
|
|
|
|
*
|
2005-07-04 05:36:20 +04:00
|
|
|
* This value defaults to the OPAL_MALLOC_DEBUG_LEVEL.
|
2004-01-22 03:29:32 +03:00
|
|
|
*/
|
2008-03-18 06:00:08 +03:00
|
|
|
OPAL_DECLSPEC void opal_malloc_debug(int level);
|
|
|
|
|
2004-11-02 16:14:34 +03:00
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
2004-01-07 11:35:32 +03:00
|
|
|
|
2005-07-04 05:36:20 +04:00
|
|
|
#endif /* OPAL_MALLOC_H */
|