mirror of
https://github.com/gperftools/gperftools
synced 2025-01-18 12:51:02 +00:00
add uclibc support
* some variables defined with "char *" should be modified to "const char*" * For uclibc, glibc's "void malloc_stats(void)" should be "void malloc_stats(FILE *)", is commented now. * For uclibc, __sbrk is with attribute "hidden", so we use mmap allocator for uclibc.
This commit is contained in:
parent
7bd193bca9
commit
7c4888515e
2
Makefile.am
Normal file → Executable file
2
Makefile.am
Normal file → Executable file
@ -662,7 +662,7 @@ if GCC
|
||||
malloc_extension_c_test_CFLAGS += -ansi
|
||||
endif GCC
|
||||
malloc_extension_c_test_LDFLAGS = $(PTHREAD_CFLAGS) $(TCMALLOC_FLAGS)
|
||||
malloc_extension_c_test_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS)
|
||||
malloc_extension_c_test_LDADD = $(LIBTCMALLOC_MINIMAL) $(PTHREAD_LIBS) -lstdc++
|
||||
endif !ENABLE_STATIC
|
||||
endif !MINGW
|
||||
|
||||
|
5
src/heap-checker.cc
Normal file → Executable file
5
src/heap-checker.cc
Normal file → Executable file
@ -1652,8 +1652,13 @@ ssize_t HeapLeakChecker::ObjectsLeaked() const {
|
||||
// Save pid of main thread for using in naming dump files
|
||||
static int32 main_thread_pid = getpid();
|
||||
#ifdef HAVE_PROGRAM_INVOCATION_NAME
|
||||
#ifdef __UCLIBC__
|
||||
extern const char* program_invocation_name;
|
||||
extern const char* program_invocation_short_name;
|
||||
#else
|
||||
extern char* program_invocation_name;
|
||||
extern char* program_invocation_short_name;
|
||||
#endif
|
||||
static const char* invocation_name() { return program_invocation_short_name; }
|
||||
static string invocation_path() { return program_invocation_name; }
|
||||
#else
|
||||
|
8
src/heap-profiler.cc
Normal file → Executable file
8
src/heap-profiler.cc
Normal file → Executable file
@ -541,7 +541,13 @@ extern "C" void HeapProfilerDump(const char *reason) {
|
||||
// number is defined in the environment variable HEAPPROFILESIGNAL.
|
||||
static void HeapProfilerDumpSignal(int signal_number) {
|
||||
(void)signal_number;
|
||||
HeapProfilerDump("signal");
|
||||
if (!heap_lock.TryLock()) {
|
||||
return;
|
||||
}
|
||||
if (is_on && !dumping) {
|
||||
DumpProfileLocked("signal");
|
||||
}
|
||||
heap_lock.Unlock();
|
||||
}
|
||||
|
||||
|
||||
|
2
src/libc_override_gcc_and_weak.h
Normal file → Executable file
2
src/libc_override_gcc_and_weak.h
Normal file → Executable file
@ -82,7 +82,9 @@ extern "C" {
|
||||
void* pvalloc(size_t size) __THROW ALIAS(tc_pvalloc);
|
||||
int posix_memalign(void** r, size_t a, size_t s) __THROW
|
||||
ALIAS(tc_posix_memalign);
|
||||
#ifndef __UCLIBC__
|
||||
void malloc_stats(void) __THROW ALIAS(tc_malloc_stats);
|
||||
#endif
|
||||
int mallopt(int cmd, int value) __THROW ALIAS(tc_mallopt);
|
||||
#ifdef HAVE_STRUCT_MALLINFO
|
||||
struct mallinfo mallinfo(void) __THROW ALIAS(tc_mallinfo);
|
||||
|
3
src/malloc_hook_mmap_linux.h
Normal file → Executable file
3
src/malloc_hook_mmap_linux.h
Normal file → Executable file
@ -202,6 +202,7 @@ extern "C" void* mremap(void* old_addr, size_t old_size, size_t new_size,
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifndef __UCLIBC__
|
||||
// libc's version:
|
||||
extern "C" void* __sbrk(ptrdiff_t increment);
|
||||
|
||||
@ -212,6 +213,8 @@ extern "C" void* sbrk(ptrdiff_t increment) __THROW {
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*static*/void* MallocHook::UnhookedMMap(void *start, size_t length, int prot,
|
||||
int flags, int fd, off_t offset) {
|
||||
void* result;
|
||||
|
2
src/memory_region_map.cc
Normal file → Executable file
2
src/memory_region_map.cc
Normal file → Executable file
@ -797,8 +797,6 @@ void MemoryRegionMap::MremapHook(const void* result,
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void* __sbrk(ptrdiff_t increment); // defined in libc
|
||||
|
||||
void MemoryRegionMap::SbrkHook(const void* result, ptrdiff_t increment) {
|
||||
RAW_VLOG(10, "Sbrk = 0x%" PRIxPTR " of %" PRIdS "", (uintptr_t)result, increment);
|
||||
if (result != reinterpret_cast<void*>(-1)) {
|
||||
|
6
src/symbolize.cc
Normal file → Executable file
6
src/symbolize.cc
Normal file → Executable file
@ -76,9 +76,13 @@ static string* g_pprof_path = new string(FLAGS_symbolize_pprof);
|
||||
|
||||
// Returns NULL if we're on an OS where we can't get the invocation name.
|
||||
// Using a static var is ok because we're not called from a thread.
|
||||
static char* GetProgramInvocationName() {
|
||||
static const char* GetProgramInvocationName() {
|
||||
#if defined(HAVE_PROGRAM_INVOCATION_NAME)
|
||||
#ifdef __UCLIBC__
|
||||
extern const char* program_invocation_name; // uclibc provides this
|
||||
#else
|
||||
extern char* program_invocation_name; // gcc provides this
|
||||
#endif
|
||||
return program_invocation_name;
|
||||
#elif defined(__MACH__)
|
||||
// We don't want to allocate memory for this since we may be
|
||||
|
5
src/system-alloc.cc
Normal file → Executable file
5
src/system-alloc.cc
Normal file → Executable file
@ -202,8 +202,7 @@ static const char mmap_name[] = "MmapSysAllocator";
|
||||
|
||||
void* SbrkSysAllocator::Alloc(size_t size, size_t *actual_size,
|
||||
size_t alignment) {
|
||||
#ifndef HAVE_SBRK
|
||||
failed_ = true;
|
||||
#if !defined(HAVE_SBRK) || defined(__UCLIBC__)
|
||||
return NULL;
|
||||
#else
|
||||
// Check if we should use sbrk allocation.
|
||||
@ -275,7 +274,6 @@ void* SbrkSysAllocator::Alloc(size_t size, size_t *actual_size,
|
||||
void* MmapSysAllocator::Alloc(size_t size, size_t *actual_size,
|
||||
size_t alignment) {
|
||||
#ifndef HAVE_MMAP
|
||||
failed_ = true;
|
||||
return NULL;
|
||||
#else
|
||||
// Check if we should use mmap allocation.
|
||||
@ -344,7 +342,6 @@ void* MmapSysAllocator::Alloc(size_t size, size_t *actual_size,
|
||||
void* DevMemSysAllocator::Alloc(size_t size, size_t *actual_size,
|
||||
size_t alignment) {
|
||||
#ifndef HAVE_MMAP
|
||||
failed_ = true;
|
||||
return NULL;
|
||||
#else
|
||||
static bool initialized = false;
|
||||
|
Loading…
Reference in New Issue
Block a user