root/opal/util/malloc.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2008 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
  10  *                         University of Stuttgart.  All rights reserved.
  11  * Copyright (c) 2004-2005 The Regents of the University of California.
  12  *                         All rights reserved.
  13  * Copyright (c) 2018      Triad National Security, LLC. All rights
  14  *                         reserved.
  15  * $COPYRIGHT$
  16  *
  17  * Additional copyrights may follow
  18  *
  19  * $HEADER$
  20  */
  21 
  22 /** @file */
  23 
  24 #ifndef OPAL_MALLOC_H
  25 #define OPAL_MALLOC_H
  26 
  27 #include <stdio.h>
  28 #include <stdlib.h>
  29 
  30 /*
  31  * THIS FILE CANNOT INCLUDE ANY OTHER OPAL HEADER FILES!!!
  32  *
  33  * It is included via <opal_config_bottom.h>.  Hence, it should not
  34  * include ANY other files, nor should it include "opal_config.h".
  35  *
  36  */
  37 
  38 /*
  39  * Set OPAL_MALLOC_DEBUG_LEVEL to
  40  * 0 for no checking
  41  * 1 for basic error checking
  42  * 2 for more error checking
  43  */
  44 
  45 #ifndef OPAL_MALLOC_DEBUG_LEVEL
  46 #define OPAL_MALLOC_DEBUG_LEVEL 2
  47 #endif
  48 
  49 BEGIN_C_DECLS
  50   /**
  51    * Initialize malloc debug output.
  52    *
  53    * This function is invoked to setup a dedicated output stream for
  54    * malloc debug functions.  It does \em not (currently) do anything
  55    * other than that (i.e., no internal accounting for tracking
  56    * malloc/free statements, etc.).
  57    *
  58    * It is invoked as part of opal_init().  Although this function is
  59    * not \em necessary for OPAL_MALLOC() and OPAL_FREE(), it is strong
  60    * recommended because no output messages -- regardless of the
  61    * malloc debug level set by opal_malloc_debug() -- will be displayed
  62    * unless this function is invoked first.
  63    */
  64 void opal_malloc_init(void);
  65 
  66   /**
  67    * \internal
  68    *
  69    * Back-end error-checking malloc function for OPAL (you should use
  70    * the normal malloc() instead of this function).
  71    *
  72    * @param size The number of bytes to allocate
  73    * @param file Typically the __FILE__ macro
  74    * @param line Typically the __LINE__ macro
  75    *
  76    * This function is only used when --enable-mem-debug was specified to
  77    * configure (or by default if you're building in a SVN checkout).
  78    */
  79 OPAL_DECLSPEC void *opal_malloc(size_t size, const char *file, int line) __opal_attribute_malloc__ __opal_attribute_warn_unused_result__;
  80 
  81   /**
  82    * \internal
  83    *
  84    * Back-end error-checking calloc function for OPAL (you should use
  85    * the normal calloc() instead of this function).
  86    *
  87    * @param nmembers Number of elements to malloc
  88    * @param size Size of each elements
  89    * @param file Typically the __FILE__ macro
  90    * @param line Typically the __LINE__ macro
  91    *
  92    * This function is only used when --enable-mem-debug was specified to
  93    * configure (or by default if you're building in a SVN checkout).
  94    */
  95 OPAL_DECLSPEC void *opal_calloc(size_t nmembers, size_t size, const char *file, int line) __opal_attribute_malloc__ __opal_attribute_warn_unused_result__;
  96 
  97   /**
  98    * \internal
  99    *
 100    * Back-end error-checking realloc function for OPAL (you should use
 101    * the normal realloc() instead of this function).
 102    *
 103    * @param ptr Pointer to reallocate
 104    * @param size The number of bytes to allocate
 105    * @param file Typically the __FILE__ macro
 106    * @param line Typically the __LINE__ macro
 107    *
 108    * This function is only used when --enable-mem-debug was specified to
 109    * configure (or by default if you're building in a SVN checkout).
 110    */
 111 OPAL_DECLSPEC void *opal_realloc(void *ptr, size_t size, const char *file, int line) __opal_attribute_malloc__ __opal_attribute_warn_unused_result__;
 112 
 113   /**
 114    * \internal
 115    *
 116    * Back-end error-checking free function for OPAL (you should use
 117    * free() instead of this function).
 118    *
 119    * @param addr Address on the heap to free()
 120    * @param file Typically the __FILE__ macro
 121    * @param line Typically the __LINE__ macro
 122    *
 123    * This function is only used when --enable-mem-debug was specified
 124    * to configure (or by default if you're building in a SVN
 125    * checkout).
 126    */
 127 OPAL_DECLSPEC void opal_free(void *addr, const char *file, int line) __opal_attribute_nonnull__(1);
 128 
 129 /**
 130  * Used to set the debug level for malloc debug.
 131  *
 132  * @param level The level of debugging (0 = none, 1 = some, 2 = more)
 133  *
 134  * This value defaults to the OPAL_MALLOC_DEBUG_LEVEL.
 135  */
 136 OPAL_DECLSPEC void opal_malloc_debug(int level);
 137 
 138 END_C_DECLS
 139 
 140 #endif /* OPAL_MALLOC_H */

/* [<][>][^][v][top][bottom][index][help] */