tcmalloc.h.in 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. // -*- Mode: C; c-basic-offset: 2; indent-tabs-mode: nil -*-
  2. /* Copyright (c) 2003, Google Inc.
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are
  7. * met:
  8. *
  9. * * Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * * Redistributions in binary form must reproduce the above
  12. * copyright notice, this list of conditions and the following disclaimer
  13. * in the documentation and/or other materials provided with the
  14. * distribution.
  15. * * Neither the name of Google Inc. nor the names of its
  16. * contributors may be used to endorse or promote products derived from
  17. * this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. *
  31. * ---
  32. * Author: Sanjay Ghemawat <opensource@google.com>
  33. * .h file by Craig Silverstein <opensource@google.com>
  34. */
  35. #ifndef TCMALLOC_TCMALLOC_H_
  36. #define TCMALLOC_TCMALLOC_H_
  37. #include <stddef.h> /* for size_t */
  38. /* Define the version number so folks can check against it */
  39. #define TC_VERSION_MAJOR @TC_VERSION_MAJOR@
  40. #define TC_VERSION_MINOR @TC_VERSION_MINOR@
  41. #define TC_VERSION_PATCH "@TC_VERSION_PATCH@"
  42. #define TC_VERSION_STRING "gperftools @TC_VERSION_MAJOR@.@TC_VERSION_MINOR@@TC_VERSION_PATCH@"
  43. /* For struct mallinfo, if it's defined. */
  44. #if @ac_cv_have_struct_mallinfo@
  45. # include <malloc.h>
  46. #endif
  47. #ifdef __cplusplus
  48. #define PERFTOOLS_THROW throw()
  49. #else
  50. # ifdef __GNUC__
  51. # define PERFTOOLS_THROW __attribute__((__nothrow__))
  52. # else
  53. # define PERFTOOLS_THROW
  54. # endif
  55. #endif
  56. #ifndef PERFTOOLS_DLL_DECL
  57. #define PERFTOOLS_DLL_DECL_DEFINED
  58. # ifdef _WIN32
  59. # define PERFTOOLS_DLL_DECL __declspec(dllimport)
  60. # else
  61. # define PERFTOOLS_DLL_DECL
  62. # endif
  63. #endif
  64. #ifdef __cplusplus
  65. namespace std {
  66. struct nothrow_t;
  67. }
  68. extern "C" {
  69. #endif
  70. /*
  71. * Returns a human-readable version string. If major, minor,
  72. * and/or patch are not NULL, they are set to the major version,
  73. * minor version, and patch-code (a string, usually "").
  74. */
  75. PERFTOOLS_DLL_DECL const char* tc_version(int* major, int* minor,
  76. const char** patch) PERFTOOLS_THROW;
  77. PERFTOOLS_DLL_DECL void* tc_malloc(size_t size) PERFTOOLS_THROW;
  78. PERFTOOLS_DLL_DECL void* tc_malloc_skip_new_handler(size_t size) PERFTOOLS_THROW;
  79. PERFTOOLS_DLL_DECL void tc_free(void* ptr) PERFTOOLS_THROW;
  80. PERFTOOLS_DLL_DECL void tc_free_sized(void *ptr, size_t size) PERFTOOLS_THROW;
  81. PERFTOOLS_DLL_DECL void* tc_realloc(void* ptr, size_t size) PERFTOOLS_THROW;
  82. PERFTOOLS_DLL_DECL void* tc_calloc(size_t nmemb, size_t size) PERFTOOLS_THROW;
  83. PERFTOOLS_DLL_DECL void tc_cfree(void* ptr) PERFTOOLS_THROW;
  84. PERFTOOLS_DLL_DECL void* tc_memalign(size_t __alignment,
  85. size_t __size) PERFTOOLS_THROW;
  86. PERFTOOLS_DLL_DECL int tc_posix_memalign(void** ptr,
  87. size_t align, size_t size) PERFTOOLS_THROW;
  88. PERFTOOLS_DLL_DECL void* tc_valloc(size_t __size) PERFTOOLS_THROW;
  89. PERFTOOLS_DLL_DECL void* tc_pvalloc(size_t __size) PERFTOOLS_THROW;
  90. PERFTOOLS_DLL_DECL void tc_malloc_stats(void) PERFTOOLS_THROW;
  91. PERFTOOLS_DLL_DECL int tc_mallopt(int cmd, int value) PERFTOOLS_THROW;
  92. #if @ac_cv_have_struct_mallinfo@
  93. PERFTOOLS_DLL_DECL struct mallinfo tc_mallinfo(void) PERFTOOLS_THROW;
  94. #endif
  95. /*
  96. * This is an alias for MallocExtension::instance()->GetAllocatedSize().
  97. * It is equivalent to
  98. * OS X: malloc_size()
  99. * glibc: malloc_usable_size()
  100. * Windows: _msize()
  101. */
  102. PERFTOOLS_DLL_DECL size_t tc_malloc_size(void* ptr) PERFTOOLS_THROW;
  103. #ifdef __cplusplus
  104. PERFTOOLS_DLL_DECL int tc_set_new_mode(int flag) PERFTOOLS_THROW;
  105. PERFTOOLS_DLL_DECL void* tc_new(size_t size);
  106. PERFTOOLS_DLL_DECL void* tc_new_nothrow(size_t size,
  107. const std::nothrow_t&) PERFTOOLS_THROW;
  108. PERFTOOLS_DLL_DECL void tc_delete(void* p) PERFTOOLS_THROW;
  109. PERFTOOLS_DLL_DECL void tc_delete_sized(void* p, size_t size) throw();
  110. PERFTOOLS_DLL_DECL void tc_delete_nothrow(void* p,
  111. const std::nothrow_t&) PERFTOOLS_THROW;
  112. PERFTOOLS_DLL_DECL void* tc_newarray(size_t size);
  113. PERFTOOLS_DLL_DECL void* tc_newarray_nothrow(size_t size,
  114. const std::nothrow_t&) PERFTOOLS_THROW;
  115. PERFTOOLS_DLL_DECL void tc_deletearray(void* p) PERFTOOLS_THROW;
  116. PERFTOOLS_DLL_DECL void tc_deletearray_sized(void* p, size_t size) throw();
  117. PERFTOOLS_DLL_DECL void tc_deletearray_nothrow(void* p,
  118. const std::nothrow_t&) PERFTOOLS_THROW;
  119. }
  120. #endif
  121. /* We're only un-defining those for public */
  122. #if !defined(GPERFTOOLS_CONFIG_H_)
  123. #undef PERFTOOLS_THROW
  124. #ifdef PERFTOOLS_DLL_DECL_DEFINED
  125. #undef PERFTOOLS_DLL_DECL
  126. #undef PERFTOOLS_DLL_DECL_DEFINED
  127. #endif
  128. #endif /* GPERFTOOLS_CONFIG_H_ */
  129. #endif /* #ifndef TCMALLOC_TCMALLOC_H_ */