OLD | NEW |
(Empty) | |
| 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 |
| 36 #ifndef TCMALLOC_TCMALLOC_H_ |
| 37 #define TCMALLOC_TCMALLOC_H_ |
| 38 |
| 39 #include <stddef.h> /* for size_t */ |
| 40 |
| 41 /* Define the version number so folks can check against it */ |
| 42 #define TC_VERSION_MAJOR 2 |
| 43 #define TC_VERSION_MINOR 5 |
| 44 #define TC_VERSION_PATCH "" |
| 45 #define TC_VERSION_STRING "gperftools 2.5" |
| 46 |
| 47 /* For struct mallinfo, if it's defined. */ |
| 48 #if 1 |
| 49 # include <malloc.h> |
| 50 #endif |
| 51 |
| 52 #ifdef __cplusplus |
| 53 #define PERFTOOLS_THROW throw() |
| 54 #else |
| 55 # ifdef __GNUC__ |
| 56 # define PERFTOOLS_THROW __attribute__((__nothrow__)) |
| 57 # else |
| 58 # define PERFTOOLS_THROW |
| 59 # endif |
| 60 #endif |
| 61 |
| 62 #ifndef PERFTOOLS_DLL_DECL |
| 63 #define PERFTOOLS_DLL_DECL_DEFINED |
| 64 # ifdef _WIN32 |
| 65 # define PERFTOOLS_DLL_DECL __declspec(dllimport) |
| 66 # else |
| 67 # define PERFTOOLS_DLL_DECL |
| 68 # endif |
| 69 #endif |
| 70 |
| 71 #ifdef __cplusplus |
| 72 namespace std { |
| 73 struct nothrow_t; |
| 74 } |
| 75 |
| 76 extern "C" { |
| 77 #endif |
| 78 /* |
| 79 * Returns a human-readable version string. If major, minor, |
| 80 * and/or patch are not NULL, they are set to the major version, |
| 81 * minor version, and patch-code (a string, usually ""). |
| 82 */ |
| 83 PERFTOOLS_DLL_DECL const char* tc_version(int* major, int* minor, |
| 84 const char** patch) PERFTOOLS_THROW; |
| 85 |
| 86 PERFTOOLS_DLL_DECL void* tc_malloc(size_t size) PERFTOOLS_THROW; |
| 87 PERFTOOLS_DLL_DECL void* tc_malloc_skip_new_handler(size_t size) PERFTOOLS_THR
OW; |
| 88 PERFTOOLS_DLL_DECL void tc_free(void* ptr) PERFTOOLS_THROW; |
| 89 PERFTOOLS_DLL_DECL void tc_free_sized(void *ptr, size_t size) PERFTOOLS_THROW; |
| 90 PERFTOOLS_DLL_DECL void* tc_realloc(void* ptr, size_t size) PERFTOOLS_THROW; |
| 91 PERFTOOLS_DLL_DECL void* tc_calloc(size_t nmemb, size_t size) PERFTOOLS_THROW; |
| 92 PERFTOOLS_DLL_DECL void tc_cfree(void* ptr) PERFTOOLS_THROW; |
| 93 |
| 94 PERFTOOLS_DLL_DECL void* tc_memalign(size_t __alignment, |
| 95 size_t __size) PERFTOOLS_THROW; |
| 96 PERFTOOLS_DLL_DECL int tc_posix_memalign(void** ptr, |
| 97 size_t align, size_t size) PERFTOOLS_
THROW; |
| 98 PERFTOOLS_DLL_DECL void* tc_valloc(size_t __size) PERFTOOLS_THROW; |
| 99 PERFTOOLS_DLL_DECL void* tc_pvalloc(size_t __size) PERFTOOLS_THROW; |
| 100 |
| 101 PERFTOOLS_DLL_DECL void tc_malloc_stats(void) PERFTOOLS_THROW; |
| 102 PERFTOOLS_DLL_DECL int tc_mallopt(int cmd, int value) PERFTOOLS_THROW; |
| 103 #if 1 |
| 104 PERFTOOLS_DLL_DECL struct mallinfo tc_mallinfo(void) PERFTOOLS_THROW; |
| 105 #endif |
| 106 |
| 107 /* |
| 108 * This is an alias for MallocExtension::instance()->GetAllocatedSize(). |
| 109 * It is equivalent to |
| 110 * OS X: malloc_size() |
| 111 * glibc: malloc_usable_size() |
| 112 * Windows: _msize() |
| 113 */ |
| 114 PERFTOOLS_DLL_DECL size_t tc_malloc_size(void* ptr) PERFTOOLS_THROW; |
| 115 |
| 116 #ifdef __cplusplus |
| 117 PERFTOOLS_DLL_DECL int tc_set_new_mode(int flag) PERFTOOLS_THROW; |
| 118 PERFTOOLS_DLL_DECL void* tc_new(size_t size); |
| 119 PERFTOOLS_DLL_DECL void* tc_new_nothrow(size_t size, |
| 120 const std::nothrow_t&) PERFTOOLS_THROW
; |
| 121 PERFTOOLS_DLL_DECL void tc_delete(void* p) PERFTOOLS_THROW; |
| 122 PERFTOOLS_DLL_DECL void tc_delete_sized(void* p, size_t size) throw(); |
| 123 PERFTOOLS_DLL_DECL void tc_delete_nothrow(void* p, |
| 124 const std::nothrow_t&) PERFTOOLS_THR
OW; |
| 125 PERFTOOLS_DLL_DECL void* tc_newarray(size_t size); |
| 126 PERFTOOLS_DLL_DECL void* tc_newarray_nothrow(size_t size, |
| 127 const std::nothrow_t&) PERFTOOLS_
THROW; |
| 128 PERFTOOLS_DLL_DECL void tc_deletearray(void* p) PERFTOOLS_THROW; |
| 129 PERFTOOLS_DLL_DECL void tc_deletearray_sized(void* p, size_t size) throw(); |
| 130 PERFTOOLS_DLL_DECL void tc_deletearray_nothrow(void* p, |
| 131 const std::nothrow_t&) PERFTOOL
S_THROW; |
| 132 } |
| 133 #endif |
| 134 |
| 135 /* We're only un-defining those for public */ |
| 136 #if !defined(GPERFTOOLS_CONFIG_H_) |
| 137 |
| 138 #undef PERFTOOLS_THROW |
| 139 |
| 140 #ifdef PERFTOOLS_DLL_DECL_DEFINED |
| 141 #undef PERFTOOLS_DLL_DECL |
| 142 #undef PERFTOOLS_DLL_DECL_DEFINED |
| 143 #endif |
| 144 |
| 145 #endif /* GPERFTOOLS_CONFIG_H_ */ |
| 146 |
| 147 #endif /* #ifndef TCMALLOC_TCMALLOC_H_ */ |
OLD | NEW |