Index: third_party/tcmalloc/chromium/src/google/tcmalloc.h |
diff --git a/third_party/tcmalloc/chromium/src/stack_trace_table.h b/third_party/tcmalloc/chromium/src/google/tcmalloc.h |
similarity index 52% |
copy from third_party/tcmalloc/chromium/src/stack_trace_table.h |
copy to third_party/tcmalloc/chromium/src/google/tcmalloc.h |
index e1d6a8a988b88c12d70b321893f9a8ff90fe00bd..3b0fe7cadf883935acfaaf545241faba22fcdeff 100644 |
--- a/third_party/tcmalloc/chromium/src/stack_trace_table.h |
+++ b/third_party/tcmalloc/chromium/src/google/tcmalloc.h |
@@ -1,4 +1,4 @@ |
-// Copyright (c) 2009, Google Inc. |
+// Copyright (c) 2007, Google Inc. |
// All rights reserved. |
// |
// Redistribution and use in source and binary forms, with or without |
@@ -28,62 +28,42 @@ |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
// --- |
-// Author: Andrew Fikes |
+// Author: Craig Silverstein <opensource@google.com> |
// |
-// Utility class for coalescing sampled stack traces. Not thread-safe. |
- |
-#ifndef TCMALLOC_STACK_TRACE_TABLE_H_ |
-#define TCMALLOC_STACK_TRACE_TABLE_H_ |
+// Some obscure memory-allocation routines may not be declared on all |
+// systems. In those cases, we'll just declare them ourselves. |
+// This file is meant to be used only internally, for unittests. |
#include <config.h> |
-#include <stdint.h> // for uintptr_t |
-#include "common.h" |
- |
-namespace tcmalloc { |
- |
-class PERFTOOLS_DLL_DECL StackTraceTable { |
- public: |
- // REQUIRES: L < pageheap_lock |
- StackTraceTable(); |
- ~StackTraceTable(); |
- |
- // Adds stack trace "t" to table. |
- // |
- // REQUIRES: L >= pageheap_lock |
- void AddTrace(const StackTrace& t); |
- |
- // Returns stack traces formatted per MallocExtension guidelines. |
- // May return NULL on error. Clears state before returning. |
- // |
- // REQUIRES: L < pageheap_lock |
- void** ReadStackTracesAndClear(); |
- |
- // Exposed for PageHeapAllocator |
- struct Bucket { |
- // Key |
- uintptr_t hash; |
- StackTrace trace; |
- |
- // Payload |
- int count; |
- Bucket* next; |
- |
- bool KeyEqual(uintptr_t h, const StackTrace& t) const; |
- }; |
- |
- // For testing |
- int depth_total() const { return depth_total_; } |
- int bucket_total() const { return bucket_total_; } |
- |
- private: |
- static const int kHashTableSize = 1 << 14; // => table_ is 128k |
- bool error_; |
- int depth_total_; |
- int bucket_total_; |
- Bucket** table_; |
-}; |
+#ifndef _XOPEN_SOURCE |
+# define _XOPEN_SOURCE 600 // for posix_memalign |
+#endif |
+#include <stdlib.h> // for posix_memalign |
+// FreeBSD has malloc.h, but complains if you use it |
+#if defined(HAVE_MALLOC_H) && !defined(__FreeBSD__) |
+#include <malloc.h> // for memalign, valloc, pvalloc |
+#endif |
-} // namespace tcmalloc |
+// __THROW is defined in glibc systems. It means, counter-intuitively, |
+// "This function will never throw an exception." It's an optional |
+// optimization tool, but we may need to use it to match glibc prototypes. |
+#ifndef __THROW // I guess we're not on a glibc system |
+# define __THROW // __THROW is just an optimization, so ok to make it "" |
+#endif |
-#endif // TCMALLOC_STACK_TRACE_TABLE_H_ |
+#if !HAVE_CFREE_SYMBOL |
+extern "C" void cfree(void* ptr) __THROW; |
+#endif |
+#if !HAVE_POSIX_MEMALIGN_SYMBOL |
+extern "C" int posix_memalign(void** ptr, size_t align, size_t size) __THROW; |
+#endif |
+#if !HAVE_MEMALIGN_SYMBOL |
+extern "C" void* memalign(size_t __alignment, size_t __size) __THROW; |
+#endif |
+#if !HAVE_VALLOC_SYMBOL |
+extern "C" void* valloc(size_t __size) __THROW; |
+#endif |
+#if !HAVE_PVALLOC_SYMBOL |
+extern "C" void* pvalloc(size_t __size) __THROW; |
+#endif |