Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame^] | 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.in 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 | #ifdef HAVE_SYS_CDEFS_H |
| 41 | #include <sys/cdefs.h> // where glibc defines __THROW |
| 42 | #endif |
| 43 | |
| 44 | // __THROW is defined in glibc systems. It means, counter-intuitively, |
| 45 | // "This function will never throw an exception." It's an optional |
| 46 | // optimization tool, but we may need to use it to match glibc prototypes. |
| 47 | #ifndef __THROW /* I guess we're not on a glibc system */ |
| 48 | # define __THROW /* __THROW is just an optimization, so ok to make it "" */ |
| 49 | #endif |
| 50 | |
| 51 | // Define the version number so folks can check against it |
| 52 | #define TC_VERSION_MAJOR 2 |
| 53 | #define TC_VERSION_MINOR 4 |
| 54 | #define TC_VERSION_PATCH "" |
| 55 | #define TC_VERSION_STRING "gperftools 2.4" |
| 56 | |
| 57 | #include <stdlib.h> // for struct mallinfo, if it's defined |
| 58 | |
| 59 | // Annoying stuff for windows -- makes sure clients can import these functions |
| 60 | #ifndef PERFTOOLS_DLL_DECL |
| 61 | # ifdef _WIN32 |
| 62 | # define PERFTOOLS_DLL_DECL __declspec(dllimport) |
| 63 | # else |
| 64 | # define PERFTOOLS_DLL_DECL |
| 65 | # endif |
| 66 | #endif |
| 67 | |
| 68 | #ifdef __cplusplus |
| 69 | namespace std { |
| 70 | struct nothrow_t; |
| 71 | } |
| 72 | |
| 73 | extern "C" { |
| 74 | #endif |
| 75 | // Returns a human-readable version string. If major, minor, |
| 76 | // and/or patch are not NULL, they are set to the major version, |
| 77 | // minor version, and patch-code (a string, usually ""). |
| 78 | PERFTOOLS_DLL_DECL const char* tc_version(int* major, int* minor, |
| 79 | const char** patch) __THROW; |
| 80 | |
| 81 | PERFTOOLS_DLL_DECL void* tc_malloc(size_t size) __THROW; |
| 82 | PERFTOOLS_DLL_DECL void* tc_malloc_skip_new_handler(size_t size) __THROW; |
| 83 | PERFTOOLS_DLL_DECL void tc_free(void* ptr) __THROW; |
| 84 | PERFTOOLS_DLL_DECL void* tc_realloc(void* ptr, size_t size) __THROW; |
| 85 | PERFTOOLS_DLL_DECL void* tc_calloc(size_t nmemb, size_t size) __THROW; |
| 86 | PERFTOOLS_DLL_DECL void tc_cfree(void* ptr) __THROW; |
| 87 | |
| 88 | PERFTOOLS_DLL_DECL void* tc_memalign(size_t __alignment, |
| 89 | size_t __size) __THROW; |
| 90 | PERFTOOLS_DLL_DECL int tc_posix_memalign(void** ptr, |
| 91 | size_t align, size_t size) __THROW; |
| 92 | PERFTOOLS_DLL_DECL void* tc_valloc(size_t __size) __THROW; |
| 93 | PERFTOOLS_DLL_DECL void* tc_pvalloc(size_t __size) __THROW; |
| 94 | |
| 95 | PERFTOOLS_DLL_DECL void tc_malloc_stats(void) __THROW; |
| 96 | PERFTOOLS_DLL_DECL int tc_mallopt(int cmd, int value) __THROW; |
| 97 | #if 0 |
| 98 | PERFTOOLS_DLL_DECL struct mallinfo tc_mallinfo(void) __THROW; |
| 99 | #endif |
| 100 | |
| 101 | // This is an alias for MallocExtension::instance()->GetAllocatedSize(). |
| 102 | // It is equivalent to |
| 103 | // OS X: malloc_size() |
| 104 | // glibc: malloc_usable_size() |
| 105 | // Windows: _msize() |
| 106 | PERFTOOLS_DLL_DECL size_t tc_malloc_size(void* ptr) __THROW; |
| 107 | |
| 108 | #ifdef __cplusplus |
| 109 | PERFTOOLS_DLL_DECL int tc_set_new_mode(int flag) __THROW; |
| 110 | PERFTOOLS_DLL_DECL void* tc_new(size_t size); |
| 111 | PERFTOOLS_DLL_DECL void* tc_new_nothrow(size_t size, |
| 112 | const std::nothrow_t&) __THROW; |
| 113 | PERFTOOLS_DLL_DECL void tc_delete(void* p) __THROW; |
| 114 | PERFTOOLS_DLL_DECL void tc_delete_nothrow(void* p, |
| 115 | const std::nothrow_t&) __THROW; |
| 116 | PERFTOOLS_DLL_DECL void* tc_newarray(size_t size); |
| 117 | PERFTOOLS_DLL_DECL void* tc_newarray_nothrow(size_t size, |
| 118 | const std::nothrow_t&) __THROW; |
| 119 | PERFTOOLS_DLL_DECL void tc_deletearray(void* p) __THROW; |
| 120 | PERFTOOLS_DLL_DECL void tc_deletearray_nothrow(void* p, |
| 121 | const std::nothrow_t&) __THROW; |
| 122 | } |
| 123 | #endif |
| 124 | |
| 125 | #endif // #ifndef TCMALLOC_TCMALLOC_H_ |