Brian Silverman | 20350ac | 2021-11-17 18:19:55 -0800 | [diff] [blame^] | 1 | // -*- Mode: C; c-basic-offset: 2; indent-tabs-mode: nil -*- |
Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame] | 2 | /* Copyright (c) 2003, Google Inc. |
| 3 | * All rights reserved. |
Brian Silverman | 20350ac | 2021-11-17 18:19:55 -0800 | [diff] [blame^] | 4 | * |
Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame] | 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are |
| 7 | * met: |
Brian Silverman | 20350ac | 2021-11-17 18:19:55 -0800 | [diff] [blame^] | 8 | * |
Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame] | 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. |
Brian Silverman | 20350ac | 2021-11-17 18:19:55 -0800 | [diff] [blame^] | 18 | * |
Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame] | 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> |
Brian Silverman | 20350ac | 2021-11-17 18:19:55 -0800 | [diff] [blame^] | 33 | * .h file by Craig Silverstein <opensource@google.com> |
Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame] | 34 | */ |
| 35 | |
| 36 | #ifndef TCMALLOC_TCMALLOC_H_ |
| 37 | #define TCMALLOC_TCMALLOC_H_ |
| 38 | |
Brian Silverman | 20350ac | 2021-11-17 18:19:55 -0800 | [diff] [blame^] | 39 | #include <stddef.h> /* for size_t */ |
| 40 | #ifdef __cplusplus |
| 41 | #include <new> /* for std::nothrow_t, std::align_val_t */ |
Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame] | 42 | #endif |
| 43 | |
Brian Silverman | 20350ac | 2021-11-17 18:19:55 -0800 | [diff] [blame^] | 44 | /* Define the version number so folks can check against it */ |
Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame] | 45 | #define TC_VERSION_MAJOR 2 |
Brian Silverman | 20350ac | 2021-11-17 18:19:55 -0800 | [diff] [blame^] | 46 | #define TC_VERSION_MINOR 9 |
| 47 | #define TC_VERSION_PATCH ".1" |
| 48 | #define TC_VERSION_STRING "gperftools 2.9.1" |
Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame] | 49 | |
Brian Silverman | 20350ac | 2021-11-17 18:19:55 -0800 | [diff] [blame^] | 50 | #ifndef PERFTOOLS_NOTHROW |
Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame] | 51 | |
Brian Silverman | 20350ac | 2021-11-17 18:19:55 -0800 | [diff] [blame^] | 52 | #if __cplusplus >= 201103L |
| 53 | #define PERFTOOLS_NOTHROW noexcept |
| 54 | #elif defined(__cplusplus) |
| 55 | #define PERFTOOLS_NOTHROW throw() |
| 56 | #else |
| 57 | # ifdef __GNUC__ |
| 58 | # define PERFTOOLS_NOTHROW __attribute__((__nothrow__)) |
| 59 | # else |
| 60 | # define PERFTOOLS_NOTHROW |
| 61 | # endif |
| 62 | #endif |
| 63 | |
| 64 | #endif |
| 65 | |
Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame] | 66 | #ifndef PERFTOOLS_DLL_DECL |
| 67 | # ifdef _WIN32 |
| 68 | # define PERFTOOLS_DLL_DECL __declspec(dllimport) |
| 69 | # else |
| 70 | # define PERFTOOLS_DLL_DECL |
| 71 | # endif |
| 72 | #endif |
| 73 | |
| 74 | #ifdef __cplusplus |
Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame] | 75 | extern "C" { |
| 76 | #endif |
Brian Silverman | 20350ac | 2021-11-17 18:19:55 -0800 | [diff] [blame^] | 77 | /* |
| 78 | * Returns a human-readable version string. If major, minor, |
| 79 | * and/or patch are not NULL, they are set to the major version, |
| 80 | * minor version, and patch-code (a string, usually ""). |
| 81 | */ |
Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame] | 82 | PERFTOOLS_DLL_DECL const char* tc_version(int* major, int* minor, |
Brian Silverman | 20350ac | 2021-11-17 18:19:55 -0800 | [diff] [blame^] | 83 | const char** patch) PERFTOOLS_NOTHROW; |
Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame] | 84 | |
Brian Silverman | 20350ac | 2021-11-17 18:19:55 -0800 | [diff] [blame^] | 85 | PERFTOOLS_DLL_DECL void* tc_malloc(size_t size) PERFTOOLS_NOTHROW; |
| 86 | PERFTOOLS_DLL_DECL void* tc_malloc_skip_new_handler(size_t size) PERFTOOLS_NOTHROW; |
| 87 | PERFTOOLS_DLL_DECL void tc_free(void* ptr) PERFTOOLS_NOTHROW; |
| 88 | PERFTOOLS_DLL_DECL void tc_free_sized(void *ptr, size_t size) PERFTOOLS_NOTHROW; |
| 89 | PERFTOOLS_DLL_DECL void* tc_realloc(void* ptr, size_t size) PERFTOOLS_NOTHROW; |
| 90 | PERFTOOLS_DLL_DECL void* tc_calloc(size_t nmemb, size_t size) PERFTOOLS_NOTHROW; |
| 91 | PERFTOOLS_DLL_DECL void tc_cfree(void* ptr) PERFTOOLS_NOTHROW; |
Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame] | 92 | |
| 93 | PERFTOOLS_DLL_DECL void* tc_memalign(size_t __alignment, |
Brian Silverman | 20350ac | 2021-11-17 18:19:55 -0800 | [diff] [blame^] | 94 | size_t __size) PERFTOOLS_NOTHROW; |
Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame] | 95 | PERFTOOLS_DLL_DECL int tc_posix_memalign(void** ptr, |
Brian Silverman | 20350ac | 2021-11-17 18:19:55 -0800 | [diff] [blame^] | 96 | size_t align, size_t size) PERFTOOLS_NOTHROW; |
| 97 | PERFTOOLS_DLL_DECL void* tc_valloc(size_t __size) PERFTOOLS_NOTHROW; |
| 98 | PERFTOOLS_DLL_DECL void* tc_pvalloc(size_t __size) PERFTOOLS_NOTHROW; |
Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame] | 99 | |
Brian Silverman | 20350ac | 2021-11-17 18:19:55 -0800 | [diff] [blame^] | 100 | PERFTOOLS_DLL_DECL void tc_malloc_stats(void) PERFTOOLS_NOTHROW; |
| 101 | PERFTOOLS_DLL_DECL int tc_mallopt(int cmd, int value) PERFTOOLS_NOTHROW; |
Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame] | 102 | |
Brian Silverman | 20350ac | 2021-11-17 18:19:55 -0800 | [diff] [blame^] | 103 | /* |
| 104 | * This is an alias for MallocExtension::instance()->GetAllocatedSize(). |
| 105 | * It is equivalent to |
| 106 | * OS X: malloc_size() |
| 107 | * glibc: malloc_usable_size() |
| 108 | * Windows: _msize() |
| 109 | */ |
| 110 | PERFTOOLS_DLL_DECL size_t tc_malloc_size(void* ptr) PERFTOOLS_NOTHROW; |
Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame] | 111 | |
| 112 | #ifdef __cplusplus |
Brian Silverman | 20350ac | 2021-11-17 18:19:55 -0800 | [diff] [blame^] | 113 | PERFTOOLS_DLL_DECL int tc_set_new_mode(int flag) PERFTOOLS_NOTHROW; |
Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame] | 114 | PERFTOOLS_DLL_DECL void* tc_new(size_t size); |
| 115 | PERFTOOLS_DLL_DECL void* tc_new_nothrow(size_t size, |
Brian Silverman | 20350ac | 2021-11-17 18:19:55 -0800 | [diff] [blame^] | 116 | const std::nothrow_t&) PERFTOOLS_NOTHROW; |
| 117 | PERFTOOLS_DLL_DECL void tc_delete(void* p) PERFTOOLS_NOTHROW; |
| 118 | PERFTOOLS_DLL_DECL void tc_delete_sized(void* p, size_t size) PERFTOOLS_NOTHROW; |
Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame] | 119 | PERFTOOLS_DLL_DECL void tc_delete_nothrow(void* p, |
Brian Silverman | 20350ac | 2021-11-17 18:19:55 -0800 | [diff] [blame^] | 120 | const std::nothrow_t&) PERFTOOLS_NOTHROW; |
Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame] | 121 | PERFTOOLS_DLL_DECL void* tc_newarray(size_t size); |
| 122 | PERFTOOLS_DLL_DECL void* tc_newarray_nothrow(size_t size, |
Brian Silverman | 20350ac | 2021-11-17 18:19:55 -0800 | [diff] [blame^] | 123 | const std::nothrow_t&) PERFTOOLS_NOTHROW; |
| 124 | PERFTOOLS_DLL_DECL void tc_deletearray(void* p) PERFTOOLS_NOTHROW; |
| 125 | PERFTOOLS_DLL_DECL void tc_deletearray_sized(void* p, size_t size) PERFTOOLS_NOTHROW; |
Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame] | 126 | PERFTOOLS_DLL_DECL void tc_deletearray_nothrow(void* p, |
Brian Silverman | 20350ac | 2021-11-17 18:19:55 -0800 | [diff] [blame^] | 127 | const std::nothrow_t&) PERFTOOLS_NOTHROW; |
| 128 | |
| 129 | #if defined(__cpp_aligned_new) || (defined(_MSVC_LANG) && _MSVC_LANG > 201402L) |
| 130 | PERFTOOLS_DLL_DECL void* tc_new_aligned(size_t size, std::align_val_t al); |
| 131 | PERFTOOLS_DLL_DECL void* tc_new_aligned_nothrow(size_t size, std::align_val_t al, |
| 132 | const std::nothrow_t&) PERFTOOLS_NOTHROW; |
| 133 | PERFTOOLS_DLL_DECL void tc_delete_aligned(void* p, std::align_val_t al) PERFTOOLS_NOTHROW; |
| 134 | PERFTOOLS_DLL_DECL void tc_delete_sized_aligned(void* p, size_t size, std::align_val_t al) PERFTOOLS_NOTHROW; |
| 135 | PERFTOOLS_DLL_DECL void tc_delete_aligned_nothrow(void* p, std::align_val_t al, |
| 136 | const std::nothrow_t&) PERFTOOLS_NOTHROW; |
| 137 | PERFTOOLS_DLL_DECL void* tc_newarray_aligned(size_t size, std::align_val_t al); |
| 138 | PERFTOOLS_DLL_DECL void* tc_newarray_aligned_nothrow(size_t size, std::align_val_t al, |
| 139 | const std::nothrow_t&) PERFTOOLS_NOTHROW; |
| 140 | PERFTOOLS_DLL_DECL void tc_deletearray_aligned(void* p, std::align_val_t al) PERFTOOLS_NOTHROW; |
| 141 | PERFTOOLS_DLL_DECL void tc_deletearray_sized_aligned(void* p, size_t size, std::align_val_t al) PERFTOOLS_NOTHROW; |
| 142 | PERFTOOLS_DLL_DECL void tc_deletearray_aligned_nothrow(void* p, std::align_val_t al, |
| 143 | const std::nothrow_t&) PERFTOOLS_NOTHROW; |
| 144 | #endif |
Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame] | 145 | } |
| 146 | #endif |
| 147 | |
Brian Silverman | 20350ac | 2021-11-17 18:19:55 -0800 | [diff] [blame^] | 148 | /* We're only un-defining for public */ |
| 149 | #if !defined(GPERFTOOLS_CONFIG_H_) |
| 150 | |
| 151 | #undef PERFTOOLS_NOTHROW |
| 152 | |
| 153 | #endif /* GPERFTOOLS_CONFIG_H_ */ |
| 154 | |
| 155 | #endif /* #ifndef TCMALLOC_TCMALLOC_H_ */ |