OLD | NEW |
1 /* Copyright (c) 2008, Google Inc. | 1 /* Copyright (c) 2008, Google Inc. |
2 * All rights reserved. | 2 * All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
11 * copyright notice, this list of conditions and the following disclaimer | 11 * copyright notice, this list of conditions and the following disclaimer |
12 * in the documentation and/or other materials provided with the | 12 * in the documentation and/or other materials provided with the |
13 * distribution. | 13 * distribution. |
14 * * Neither the name of Google Inc. nor the names of its | 14 * * Neither the name of Google Inc. nor the names of its |
15 * contributors may be used to endorse or promote products derived from | 15 * contributors may be used to endorse or promote products derived from |
16 * this software without specific prior written permission. | 16 * this software without specific prior written permission. |
17 * | 17 * |
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 * | |
30 * -- | |
31 * Author: Craig Silverstein | |
32 * | |
33 * C shims for the C++ malloc_extension.h. See malloc_extension.h for | |
34 * details. Note these C shims always work on | |
35 * MallocExtension::instance(); it is not possible to have more than | |
36 * one MallocExtension object in C applications. | |
37 */ | 29 */ |
38 | 30 |
39 #ifndef _MALLOC_EXTENSION_C_H_ | 31 /* The code has moved to gperftools/. Use that include-directory for |
40 #define _MALLOC_EXTENSION_C_H_ | 32 * new code. |
41 | |
42 #include <stddef.h> | |
43 #include <sys/types.h> | |
44 | |
45 /* Annoying stuff for windows -- makes sure clients can import these fns */ | |
46 #ifndef PERFTOOLS_DLL_DECL | |
47 # ifdef _WIN32 | |
48 # define PERFTOOLS_DLL_DECL __declspec(dllimport) | |
49 # else | |
50 # define PERFTOOLS_DLL_DECL | |
51 # endif | |
52 #endif | |
53 | |
54 #ifdef __cplusplus | |
55 extern "C" { | |
56 #endif | |
57 | |
58 #define kMallocExtensionHistogramSize 64 | |
59 | |
60 PERFTOOLS_DLL_DECL int MallocExtension_VerifyAllMemory(void); | |
61 PERFTOOLS_DLL_DECL int MallocExtension_VerifyNewMemory(void* p); | |
62 PERFTOOLS_DLL_DECL int MallocExtension_VerifyArrayNewMemory(void* p); | |
63 PERFTOOLS_DLL_DECL int MallocExtension_VerifyMallocMemory(void* p); | |
64 PERFTOOLS_DLL_DECL int MallocExtension_MallocMemoryStats(int* blocks, size_t* to
tal, | |
65 int histogram[kMallocExtensionHistogramSiz
e]); | |
66 PERFTOOLS_DLL_DECL void MallocExtension_GetStats(char* buffer, int buffer_length
); | |
67 | |
68 /* TODO(csilvers): write a C version of these routines, that perhaps | |
69 * takes a function ptr and a void *. | |
70 */ | 33 */ |
71 /* void MallocExtension_GetHeapSample(string* result); */ | 34 #include <gperftools/malloc_extension_c.h> |
72 /* void MallocExtension_GetHeapGrowthStacks(string* result); */ | |
73 | |
74 PERFTOOLS_DLL_DECL int MallocExtension_GetNumericProperty(const char* property,
size_t* value); | |
75 PERFTOOLS_DLL_DECL int MallocExtension_SetNumericProperty(const char* property,
size_t value); | |
76 PERFTOOLS_DLL_DECL void MallocExtension_MarkThreadIdle(void); | |
77 PERFTOOLS_DLL_DECL void MallocExtension_MarkThreadBusy(void); | |
78 PERFTOOLS_DLL_DECL void MallocExtension_ReleaseToSystem(size_t num_bytes); | |
79 PERFTOOLS_DLL_DECL void MallocExtension_ReleaseFreeMemory(void); | |
80 PERFTOOLS_DLL_DECL size_t MallocExtension_GetEstimatedAllocatedSize(size_t size)
; | |
81 PERFTOOLS_DLL_DECL size_t MallocExtension_GetAllocatedSize(void* p); | |
82 | |
83 #ifdef __cplusplus | |
84 } // extern "C" | |
85 #endif | |
86 | |
87 #endif /* _MALLOC_EXTENSION_C_H_ */ | |
OLD | NEW |