tcmalloc.h.in 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. #ifdef __cplusplus
  44. #define PERFTOOLS_THROW throw()
  45. #else
  46. # ifdef __GNUC__
  47. # define PERFTOOLS_THROW __attribute__((__nothrow__))
  48. # else
  49. # define PERFTOOLS_THROW
  50. # endif
  51. #endif
  52. #ifndef PERFTOOLS_DLL_DECL
  53. #define PERFTOOLS_DLL_DECL_DEFINED
  54. # ifdef _WIN32
  55. # define PERFTOOLS_DLL_DECL __declspec(dllimport)
  56. # else
  57. # define PERFTOOLS_DLL_DECL
  58. # endif
  59. #endif
  60. #ifdef __cplusplus
  61. namespace std {
  62. struct nothrow_t;
  63. }
  64. extern "C" {
  65. #endif
  66. /*
  67. * Returns a human-readable version string. If major, minor,
  68. * and/or patch are not NULL, they are set to the major version,
  69. * minor version, and patch-code (a string, usually "").
  70. */
  71. PERFTOOLS_DLL_DECL const char* tc_version(int* major, int* minor,
  72. const char** patch) PERFTOOLS_THROW;
  73. PERFTOOLS_DLL_DECL void* tc_malloc(size_t size) PERFTOOLS_THROW;
  74. PERFTOOLS_DLL_DECL void* tc_malloc_skip_new_handler(size_t size) PERFTOOLS_THROW;
  75. PERFTOOLS_DLL_DECL void tc_free(void* ptr) PERFTOOLS_THROW;
  76. PERFTOOLS_DLL_DECL void tc_free_sized(void *ptr, size_t size) PERFTOOLS_THROW;
  77. PERFTOOLS_DLL_DECL void* tc_realloc(void* ptr, size_t size) PERFTOOLS_THROW;
  78. PERFTOOLS_DLL_DECL void* tc_calloc(size_t nmemb, size_t size) PERFTOOLS_THROW;
  79. PERFTOOLS_DLL_DECL void tc_cfree(void* ptr) PERFTOOLS_THROW;
  80. PERFTOOLS_DLL_DECL void* tc_memalign(size_t __alignment,
  81. size_t __size) PERFTOOLS_THROW;
  82. PERFTOOLS_DLL_DECL int tc_posix_memalign(void** ptr,
  83. size_t align, size_t size) PERFTOOLS_THROW;
  84. PERFTOOLS_DLL_DECL void* tc_valloc(size_t __size) PERFTOOLS_THROW;
  85. PERFTOOLS_DLL_DECL void* tc_pvalloc(size_t __size) PERFTOOLS_THROW;
  86. PERFTOOLS_DLL_DECL void tc_malloc_stats(void) PERFTOOLS_THROW;
  87. PERFTOOLS_DLL_DECL int tc_mallopt(int cmd, int value) PERFTOOLS_THROW;
  88. /*
  89. * This is an alias for MallocExtension::instance()->GetAllocatedSize().
  90. * It is equivalent to
  91. * OS X: malloc_size()
  92. * glibc: malloc_usable_size()
  93. * Windows: _msize()
  94. */
  95. PERFTOOLS_DLL_DECL size_t tc_malloc_size(void* ptr) PERFTOOLS_THROW;
  96. #ifdef __cplusplus
  97. PERFTOOLS_DLL_DECL int tc_set_new_mode(int flag) PERFTOOLS_THROW;
  98. PERFTOOLS_DLL_DECL void* tc_new(size_t size);
  99. PERFTOOLS_DLL_DECL void* tc_new_nothrow(size_t size,
  100. const std::nothrow_t&) PERFTOOLS_THROW;
  101. PERFTOOLS_DLL_DECL void tc_delete(void* p) PERFTOOLS_THROW;
  102. PERFTOOLS_DLL_DECL void tc_delete_sized(void* p, size_t size) throw();
  103. PERFTOOLS_DLL_DECL void tc_delete_nothrow(void* p,
  104. const std::nothrow_t&) PERFTOOLS_THROW;
  105. PERFTOOLS_DLL_DECL void* tc_newarray(size_t size);
  106. PERFTOOLS_DLL_DECL void* tc_newarray_nothrow(size_t size,
  107. const std::nothrow_t&) PERFTOOLS_THROW;
  108. PERFTOOLS_DLL_DECL void tc_deletearray(void* p) PERFTOOLS_THROW;
  109. PERFTOOLS_DLL_DECL void tc_deletearray_sized(void* p, size_t size) throw();
  110. PERFTOOLS_DLL_DECL void tc_deletearray_nothrow(void* p,
  111. const std::nothrow_t&) PERFTOOLS_THROW;
  112. }
  113. #endif
  114. /* We're only un-defining those for public */
  115. #if !defined(GPERFTOOLS_CONFIG_H_)
  116. #undef PERFTOOLS_THROW
  117. #ifdef PERFTOOLS_DLL_DECL_DEFINED
  118. #undef PERFTOOLS_DLL_DECL
  119. #undef PERFTOOLS_DLL_DECL_DEFINED
  120. #endif
  121. #endif /* GPERFTOOLS_CONFIG_H_ */
  122. #endif /* #ifndef TCMALLOC_TCMALLOC_H_ */