diff options
-rw-r--r-- | CMakeLists.txt | 168 | ||||
-rw-r--r-- | cmake/DefineArchVariables.cmake | 10 | ||||
-rw-r--r-- | cmake/DefineTargetVariables.cmake | 13 | ||||
-rw-r--r-- | cmake/PCFromUContext.cmake | 6 | ||||
-rw-r--r-- | cmake/config.h.in | 294 | ||||
-rw-r--r-- | cmake/tcmalloc.h.in | 147 |
6 files changed, 589 insertions, 49 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c287b49..936e75c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,11 +15,6 @@ set(default_tcmalloc_alignment 16) set(need_nanosleep ON) set(host string(TOLOWER "${CMAKE_SYSTEM_NAME}")) -if(host MATCHES "freebsd") - set(FREEBSD ON) -elseif(CMAKE_VERSION VERSION_LESS "3.2" AND host MATCHES "mingw") - set(MINGW ON) -endif() if(MINGW) set(default_build_minimal ON) @@ -45,10 +40,10 @@ include(CheckTypeSize) include(CheckVariableExists) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) -include(DefineArchVariables) +include(DefineTargetVariables) include(PCFromUContext) -define_arch_variables() +define_target_variables() if(s390) set(default_enable_libunwind OFF) @@ -83,13 +78,16 @@ cmake_dependent_option( gperftools_build_debugalloc "Build debugalloc" ${default_build_debugalloc} "NOT gperftools_build_minimal" OFF) -option(gperftools_stacktrace_via_backtrace +option(gperftools_enable_stacktrace_via_backtrace "Enable use of backtrace() for stacktrace capturing (may deadlock)" ${default_enable_backtrace}) option(gperftools_enable_libunwind "Enable libunwind linking" ${default_enable_libunwind}) +set(enable_backtrace ${gperftools_enable_stacktrace_via_backtrace}) +set(enable_libunwind ${gperftools_enable_libunwind}) + set(gperftools_tcmalloc_pagesize ${default_tcmalloc_pagesize} CACHE STRING "Set the tcmalloc internal page size") set_property(CACHE gperftools_tcmalloc_pagesize PROPERTY STRINGS "8" "32" "64") @@ -101,6 +99,10 @@ if(NOT gperftools_tcmalloc_pagesize STREQUAL "8" AND "setting to default value (${default_tcmalloc_pagesize})") set(gperftools_tcmalloc_pagesize ${default_tcmalloc_pagesize}) endif() +if (gperftools_tcmalloc_pagesize STREQUAL "32" OR + gperftools_tcmalloc_pagesize STREQUAL "64") + set(TCMALLOC_${gperftools_tcmalloc_pagesize}K_PAGES ON) +endif() set(gperftools_tcmalloc_alignment ${default_tcmalloc_alignment} CACHE STRING "Set the tcmalloc allocation alignment") @@ -112,20 +114,24 @@ if(NOT gperftools_tcmalloc_alignment STREQUAL "8" AND "setting to default value (${default_tcmalloc_alignment})") set(gperftools_tcmalloc_alignment ${default_tcmalloc_alignment}) endif() - -# TODO: `target_add_definitions` for above (i.e. `TCMALLOC_32K_PAGES`, -# `TCMALLOC_ALIGN_8BYTES`) +if(gperftools_tcmalloc_alignment STREQUAL "8") + set(TCMALLOC_ALIGN_8BYTES ON) +endif() check_cxx_source_compiles("#include <stdlib.h> static void foo(void) __attribute__ ((unused)); - void foo(void) { exit(1); }" + void foo(void) { exit(1); } + int main() { return 0; }" HAVE___ATTRIBUTE__) -foreach(candidate IN "inline" "__inline" "__inline__" "") - check_cxx_source_compiles( - "static ${candidate} void foo() {}" candidate_compiled) - if(candidate_compiled) - set(inline "${candidate}") +set(inline) +foreach(inline_keyword "inline" "__inline" "__inline__") + check_cxx_source_compiles(" + static ${inline_keyword} void foo() {} + int main() { foo(); return 0; }" + have_${inline_keyword}) + if(have_${inline_keyword}) + set(inline ${inline_keyword}) break() endif() endforeach() @@ -142,16 +148,29 @@ check_function_exists("sbrk" HAVE_SBRK) check_function_exists("geteuid" HAVE_GETEUID) check_function_exists("fork" HAVE_FORK) check_include_file_cxx("features.h" HAVE_FEATURES_H) +check_include_file_cxx("inttypes.h" HAVE_INTTYPES_H) +check_include_file_cxx("stdint.h" HAVE_STDINT_H) +check_include_file_cxx("stdlib.h" HAVE_STDLIB_H) +check_include_file_cxx("strings.h" HAVE_STRINGS_H) +check_include_file_cxx("string.h" HAVE_STRING_H) +check_include_file_cxx("dlfcn.h" HAVE_DLFCN_H) check_include_file_cxx("malloc.h" HAVE_MALLOC_H) +check_include_file_cxx("sys/malloc.h" HAVE_SYS_MALLOC_H) +check_include_file_cxx("sys/param.h" HAVE_SYS_PARAM_H) check_include_file_cxx("glob.h" HAVE_GLOB_H) check_include_file_cxx("execinfo.h" HAVE_EXECINFO_H) check_include_file_cxx("unwind.h" HAVE_UNWIND_H) +check_include_file_cxx("unistd.h" HAVE_UNISTD_H) +check_include_file_cxx("valgrind.h" HAVE_VALGRIND_H) check_include_file_cxx("sched.h" HAVE_SCHED_H) check_include_file_cxx("conflict-signal.h" HAVE_CONFLICT_SIGNAL_H) +check_include_file_cxx("cygwin/signal.h" HAVE_CYGWIN_SIGNAL_H) check_include_file_cxx("sys/prctl.h" HAVE_SYS_PRCTL_H) check_include_file_cxx("linux/ptrace.h" HAVE_LINUX_PTRACE_H) check_include_file_cxx("sys/syscall.h" HAVE_SYS_SYSCALL_H) check_include_file_cxx("sys/socket.h" HAVE_SYS_SOCKET_H) +check_include_file_cxx("sys/stat.h" HAVE_SYS_STAT_H) +check_include_file_cxx("sys/types.h" HAVE_SYS_TYPES_H) check_include_file_cxx("sys/wait.h" HAVE_SYS_WAIT_H) check_include_file_cxx("poll.h" HAVE_POLL_H) check_include_file_cxx("fcntl.h" HAVE_FCNTL_H) @@ -160,7 +179,6 @@ check_include_file_cxx("pwd.h" HAVE_PWD_H) check_include_file_cxx("sys/resource.h" HAVE_SYS_RESOURCE_H) check_include_file_cxx("valgrind.h" HAVE_VALGRIND_H) check_include_file_cxx("sys/cdefs.h" HAVE_SYS_CDEFS_H) -check_include_file_cxx("features.h" HAVE_FEATURES_H) set(CMAKE_REQUIRED_DEFINITIONS -D_XOPEN_SOURCE=600) check_cxx_symbol_exists("cfree" "stdlib.h;malloc.h" HAVE_DECL_CFREE) @@ -169,22 +187,38 @@ check_cxx_symbol_exists("posix_memalign" "stdlib.h;malloc.h" HAVE_DECL_POSIX_MEM check_cxx_symbol_exists("memalign" "stdlib.h;malloc.h" HAVE_DECL_MEMALIGN) check_cxx_symbol_exists("valloc" "stdlib.h;malloc.h" HAVE_DECL_VALLOC) check_cxx_symbol_exists("pvalloc" "stdlib.h;malloc.h" HAVE_DECL_PVALLOC) -check_cxx_symbol_exists("mmap" "stdlib.h;unistd.h;sys/mman.h;sys/param.h" HAVE_DECL_MMAP) +check_cxx_symbol_exists("mmap" "stdlib.h;unistd.h;sys/mman.h;sys/param.h" HAVE_MMAP) +check_cxx_symbol_exists("uname" "sys/utsname.h" HAVE_DECL_UNAME) -check_cxx_source_compiles( - "#include <stdint.h>\nint main() { int32_t v1 = 0; intptr_t v2 = 0; return (&v1 - &v2); }" +check_function_exists("snprintf" HAVE_SNPRINTF) + +if(WIN32) + set(HAVE_GETPAGESIZE ON) +else() + check_function_exists("getpagesize" HAVE_GETPAGESIZE) +endif() + +check_cxx_source_compiles(" + #include <stdint.h> + int main() + { + int32_t v1 = 0; + intptr_t v2 = 0; + return (&v1 - &v2); + }" INT32_EQUALS_INTPTR) -pc_from_ucontext(pc_field) +pc_from_ucontext(PC_FROM_UCONTEXT_DEF) set(unwind_libs) if(gperftools_enable_libunwind) check_include_file_cxx("libunwind.h" HAVE_LIBUNWIND_H) find_library(libunwind_location NAMES unwind) if(libunwind_location) - check_library_exists(unwind backtrace ${libunwind_location} HAVE_LIBUNWIND) + check_library_exists( + unwind backtrace ${libunwind_location} have_libunwind) endif() - if(HAVE_LIBUNWIND) + if(have_libunwind) list(APPEND unwind_libs unwind) set(will_use_libunwind ON) endif() @@ -211,10 +245,20 @@ if(gperftools_sized_delete) set(ENABLE_SIZED_DELETE 1) endif() -check_cxx_compiler_flag("-fsized-deallocation" HAVE_SIZED_DEALLOCATION) +check_cxx_compiler_flag("-fsized-deallocation" HAVE_SIZED_FREE_OPTION) -check_cxx_source_compiles("include <unwind.h>\nint main() { &Unwind_Backtrace; return 0; }" - HAVE_UNWIND_BACKTRACE) +check_cxx_source_compiles( + "namespace abc { void foo() {} } int main() { abc::foo(); return 0; }" + HAVE_NAMESPACES) + +check_cxx_source_compiles(" + include <unwind.h> + int main() + { + &_Unwind_Backtrace; + return 0; + }" + HAVE_UNWIND_BACKTRACE) if(enable_backtrace) set(default_emergency_malloc ON) @@ -222,7 +266,7 @@ else() set(default_emergency_malloc OFF) endif() -if(will_use_libunwind AND arm) +if(will_use_libunwind AND ARM) set(default_emergency_malloc ON) endif() @@ -231,14 +275,19 @@ option(gperftools_emergency_malloc ${default_emergency_malloc}) check_cxx_source_compiles( - "int main() { void* sp = __buildin_stack_pointer(); return 0; }" + "int main() { void* sp = __builtin_stack_pointer(); return 0; }" HAVE_BUILTIN_STACK_POINTER) check_cxx_source_compiles( "int main() { return __builtin_expect(main != 0, 1); }" HAVE_BUILTIN_EXPECT) -check_cxx_source_compiles( - "#include <unistd.h>\nint main() { char** env = __environ; return 0; }" +check_cxx_source_compiles(" + #include <unistd.h> + int main() + { + char** env = __environ; + return 0; + }" HAVE___ENVIRON) if(CMAKE_CXX_COMPILER STREQUAL "GNU" AND @@ -255,7 +304,8 @@ endif() if(need_nanosleep) check_cxx_source_compiles( - "#include <time.h>\nint main() { static struct timespec ts; nanosleep(&ts, NULL); return 0; }" + "#include <time.h> + int main() { static struct timespec ts; nanosleep(&ts, NULL); return 0; }" nanosleep_ok) if(NOT nanosleep_ok) set(CMAKE_REQUIRED_LIBRARIES rt) @@ -271,25 +321,60 @@ if(need_nanosleep) endif() endif() +if(enable_backtrace) + check_cxx_symbol_exists("backtrace" "execinfo.h" HAVE_DECL_BACKTRACE) + check_function_exists("backtrace" backtrace_exists) + if(NOT backtrace_exists) + set(CMAKE_REQUIRED_LIBRARIES execinfo) + check_function_exists("backtrace" backtrace_exists) + message("backtrace_exists: ${backtrace_exists}") + set(CMAKE_REQUIRED_LIBRARIES) + if(backtrace_exists) + LIST(INSERT unwind_libs 0 execinfo) + endif() + endif() +endif() + +find_package(Threads REQUIRED) +set(HAVE_PTHREAD ${CMAKE_USE_PTHREADS_INIT}) +foreach(attr "PTHREAD_CREATE_JOINABLE" "PTHREAD_CREATE_UNDETACHED") + check_cxx_source_compiles(" + #include <pthread.h> + int main() { int attr = ${attr}; return attr; }" + ${attr}_ATTR) + if(${attr}_ATTR) + set(PTHREAD_CREATE_JOINABLE ${attr}) + break() + endif() +endforeach() + +if(FreeBSD) + set(PTHREADS_CRASHES_IF_RUN_TOO_EARLY ON) +endif() + if(EXISTS /usr/sfw/lib/libstdc++.la) file(READ /usr/sfw/lib/libstdc++.la _ch LIMIT 1) if(string(LENGTH _ch) EQUAL 0) - # TODO: list(APPEND LIBS "src/solaris") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Lsrc/solaris") endif() endif() check_cxx_source_compiles( - "#include <string>\n#include <vector>\nint main() { pthread_t th; pthread_join(th, 0); return 0; }" + "#include <string> + #include <vector> + int main() { pthread_t th; pthread_join(th, 0); return 0; }" HAVE_PTHREAD_DESPITE_ASKING_FOR) check_cxx_source_compiles( - "#include <vector>\nint main() { vector<int> t; return 0; }" + "#include <vector> + int main() { vector<int> t; return 0; }" STL_NAMESPACE_NONE) if(STL_NAMESPACE_NONE) set(STL_NAMESPACE "") else() check_cxx_source_compiles( - "#include <vector>\nint main() { std::vector<int> t; return 0; }" + "#include <vector> + int main() { std::vector<int> t; return 0; }" STL_NAMESPACE_STD) if (STL_NAMESPACE_STD) set(STL_NAMESPACE "std") @@ -302,3 +387,14 @@ if(MINGW) check_cxx_symbol_exists("sleep" "unistd.h" HAVE_DECL_SLEEP) check_cxx_symbol_exists("nanosleep" "time.h" HAVE_DECL_NANOSLEEP) endif() + +if(LINUX) + check_cxx_source_compiles(" + #include <signal.h> + #include <time.h> + int main() { return SIGEV_THREAD_ID || CLOCK_THREAD_CPUTIME_ID; }" + HAVE_LINUX_SIGEV_THREAD_ID) +endif() + +configure_file(cmake/config.h.in ${CMAKE_BINARY_DIR}/config.h @ONLY) +configure_file(cmake/tcmalloc.h.in ${CMAKE_BINARY_DIR}/gperftools/tcmalloc.h @ONLY) diff --git a/cmake/DefineArchVariables.cmake b/cmake/DefineArchVariables.cmake deleted file mode 100644 index 74e2b05..0000000 --- a/cmake/DefineArchVariables.cmake +++ /dev/null @@ -1,10 +0,0 @@ -if(NOT COMMAND check_cxx_source_compiles) - include(CheckCXXSourceCompiles) -endif() - -macro(define_arch_variables) - check_cxx_source_compiles("int main() { return __s390__; }" s390) - check_cxx_source_compiles("int main() { return __PPC64__; }" PPC64) - check_cxx_source_compiles("int main() { return __x86_64__; }" x86_64) - check_cxx_source_compiles("int main() { return __arm__; }" arm) -endmacro() diff --git a/cmake/DefineTargetVariables.cmake b/cmake/DefineTargetVariables.cmake new file mode 100644 index 0000000..cff175d --- /dev/null +++ b/cmake/DefineTargetVariables.cmake @@ -0,0 +1,13 @@ +if(NOT COMMAND check_cxx_source_compiles) + include(CheckCXXSourceCompiles) +endif() + +macro(define_target_variables) + check_cxx_source_compiles("int main() { return __s390__; }" s390) + check_cxx_source_compiles("int main() { return __PPC64__; }" PPC64) + check_cxx_source_compiles("int main() { return __x86_64__; }" x86_64) + check_cxx_source_compiles("int main() { return __arm__; }" ARM) + check_cxx_source_compiles("int main() { return __FreeBSD__; }" FreeBSD) + check_cxx_source_compiles("int main() { return __MINGW__; }" MINGW) + check_cxx_source_compiles("int main() { return __linux; }" LINUX) +endmacro() diff --git a/cmake/PCFromUContext.cmake b/cmake/PCFromUContext.cmake index c8ee57a..1d4eb85 100644 --- a/cmake/PCFromUContext.cmake +++ b/cmake/PCFromUContext.cmake @@ -42,7 +42,6 @@ macro(pc_from_ucontext variable) "uc_mcontext->__ss.__srr0") # OS X (>=10.5 [untested]) set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE=1) - set(CMAKE_REQUIRED_QUIET ON) if(HAVE_CYGWIN_SIGNAL_H) set(_inc "cygwin/signal.h") elseif(HAVE_SYS_UCONTEXT_H) @@ -51,10 +50,11 @@ macro(pc_from_ucontext variable) set(_inc "ucontext.h") endif() foreach(pc_field IN LISTS pc_fields) + string(MAKE_C_IDENTIFIER ${pc_field} pc_field_id) check_cxx_source_compiles( "#include <${_inc}>\nint main() { ucontext_t u; return u.${pc_field} == 0; }" - pc_field_found) - if(DEFINED pc_field_found) + HAVE_${pc_field_id}) + if(HAVE_${pc_field_id}) set(HAVE_${variable} ON) set(${variable} ${pc_field}) break() diff --git a/cmake/config.h.in b/cmake/config.h.in new file mode 100644 index 0000000..6bf5a57 --- /dev/null +++ b/cmake/config.h.in @@ -0,0 +1,294 @@ +#ifndef GPERFTOOLS_CONFIG_H_ +#define GPERFTOOLS_CONFIG_H_ + +#cmakedefine HAVE_SNPRINTF + +/* Define to 1 if compiler supports __builtin_stack_pointer */ +#cmakedefine HAVE_BUILTIN_STACK_POINTER + +/* Define to 1 if you have the <conflict-signal.h> header file. */ +#cmakedefine HAVE_CONFLICT_SIGNAL_H + +/* Define to 1 if you have the <cygwin/signal.h> header file. */ +#cmakedefine HAVE_CYGWIN_SIGNAL_H + +/* Define to 1 if you have the declaration of `cfree', and to 0 if you don't. + */ +#cmakedefine HAVE_DECL_CFREE + +/* Define to 1 if you have the declaration of `memalign', and to 0 if you + don't. */ +#cmakedefine HAVE_DECL_MEMALIGN + +/* Define to 1 if you have the declaration of `posix_memalign', and to 0 if + you don't. */ +#cmakedefine HAVE_DECL_POSIX_MEMALIGN + +/* Define to 1 if you have the declaration of `pvalloc', and to 0 if you + don't. */ +#cmakedefine HAVE_DECL_PVALLOC + +/* Define to 1 if you have the declaration of `uname', and to 0 if you don't. + */ +#cmakedefine HAVE_DECL_UNAME + +/* Define to 1 if you have the declaration of `valloc', and to 0 if you don't. + */ +#cmakedefine HAVE_DECL_VALLOC + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#cmakedefine HAVE_DLFCN_H + +/* Define to 1 if the system has the type `Elf32_Versym'. */ +#cmakedefine HAVE_ELF32_VERSYM + +/* Define to 1 if you have the <execinfo.h> header file. */ +#cmakedefine HAVE_EXECINFO_H + +/* Define to 1 if you have the <fcntl.h> header file. */ +#cmakedefine HAVE_FCNTL_H + +/* Define to 1 if you have the <features.h> header file. */ +#cmakedefine HAVE_FEATURES_H + +/* Define to 1 if you have the `geteuid' function. */ +#cmakedefine HAVE_GETEUID + +/* Define to 1 if you have the `getpagesize' function. */ +#cmakedefine HAVE_GETPAGESIZE + +/* Define to 1 if you have the <glob.h> header file. */ +#cmakedefine HAVE_GLOB_H + +/* Define to 1 if you have the <grp.h> header file. */ +#cmakedefine HAVE_GRP_H + +/* Define to 1 if you have the <inttypes.h> header file. */ +#cmakedefine HAVE_INTTYPES_H + +/* Define to 1 if you have the <libunwind.h> header file. */ +#cmakedefine HAVE_LIBUNWIND_H + +/* Define to 1 if you have the <linux/ptrace.h> header file. */ +#cmakedefine HAVE_LINUX_PTRACE_H + +/* Define to 1 if you have the <malloc.h> header file. */ +#cmakedefine HAVE_MALLOC_H + +/* Define to 1 if you have the <malloc/malloc.h> header file. */ +#cmakedefine HAVE_MALLOC_MALLOC_H + +/* Define to 1 if you have the <memory.h> header file. */ +#cmakedefine HAVE_MEMORY_H + +/* Define to 1 if you have a working `mmap' system call. */ +#cmakedefine HAVE_MMAP + +/* define if the compiler implements namespaces */ +#cmakedefine HAVE_NAMESPACES + +/* Define to 1 if you have the <poll.h> header file. */ +#cmakedefine HAVE_POLL_H + +/* define if libc has program_invocation_name */ +#cmakedefine HAVE_PROGRAM_INVOCATION_NAME + +/* Define if you have POSIX threads libraries and header files. */ +#cmakedefine HAVE_PTHREAD + +/* Define to 1 if you have the <pwd.h> header file. */ +#cmakedefine HAVE_PWD_H + +/* Define to 1 if you have the `sbrk' function. */ +#cmakedefine HAVE_SBRK + +/* Define to 1 if you have the <sched.h> header file. */ +#cmakedefine HAVE_SCHED_H + +/* Define to 1 if you have the <stdint.h> header file. */ +#cmakedefine HAVE_STDINT_H + +/* Define to 1 if you have the <stdlib.h> header file. */ +#cmakedefine HAVE_STDLIB_H 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#cmakedefine HAVE_STRINGS_H + +/* Define to 1 if you have the <string.h> header file. */ +#cmakedefine HAVE_STRING_H 1 + +/* Define to 1 if the system has the type `struct mallinfo'. */ +#cmakedefine HAVE_STRUCT_MALLINFO + +/* Define to 1 if you have the <sys/cdefs.h> header file. */ +#cmakedefine HAVE_SYS_CDEFS_H + +/* Define to 1 if you have the <sys/malloc.h> header file. */ +#cmakedefine HAVE_SYS_MALLOC_H + +/* Define to 1 if you have the <sys/param.h> header file. */ +#cmakedefine HAVE_SYS_PARAM_H + +/* Define to 1 if you have the <sys/prctl.h> header file. */ +#cmakedefine HAVE_SYS_PRCTL_H + +/* Define to 1 if you have the <sys/resource.h> header file. */ +#cmakedefine HAVE_SYS_RESOURCE_H + +/* Define to 1 if you have the <sys/socket.h> header file. */ +#cmakedefine HAVE_SYS_SOCKET_H + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#cmakedefine HAVE_SYS_STAT_H + +/* Define to 1 if you have the <sys/syscall.h> header file. */ +#cmakedefine HAVE_SYS_SYSCALL_H + +/* Define to 1 if you have the <sys/types.h> header file. */ +#cmakedefine HAVE_SYS_TYPES_H + +/* <sys/ucontext.h> is broken on redhat 7 */ +#cmakedefine HAVE_SYS_UCONTEXT_H + +/* Define to 1 if you have the <sys/wait.h> header file. */ +#cmakedefine HAVE_SYS_WAIT_H + +/* Define to 1 if compiler supports __thread */ +#cmakedefine HAVE_TLS + +/* Define to 1 if you have the <ucontext.h> header file. */ +#cmakedefine HAVE_UCONTEXT_H + +/* Define to 1 if you have the <unistd.h> header file. */ +#cmakedefine HAVE_UNISTD_H + +/* Define to 1 if you have the <unwind.h> header file. */ +#cmakedefine HAVE_UNWIND_H + +/* Define to 1 if you have the <valgrind.h> header file. */ +#cmakedefine HAVE_VALGRIND_H + +/* define if your compiler has __attribute__ */ +#cmakedefine HAVE___ATTRIBUTE__ + +/* Define to 1 if compiler supports __environ */ +#cmakedefine HAVE___ENVIRON + +/* Define to 1 if the system has the type `__int64'. */ +#cmakedefine HAVE___INT64 + +/* prefix where we look for installed files */ +#cmakedefine INSTALL_PREFIX + +/* Define to 1 if int32_t is equivalent to intptr_t */ +#cmakedefine INT32_EQUALS_INTPTR + +/* Define to the sub-directory in which libtool stores uninstalled libraries. */ +#cmakedefine LT_OBJDIR + +/* Define to 'volatile' if __malloc_hook is declared volatile */ +#cmakedefine MALLOC_HOOK_MAYBE_VOLATILE + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +#undef NO_MINUS_C_MINUS_O + +/* Name of package */ +#define PACKAGE "@PROJECT_NAME@" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "gperftools@googlegroups.com" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "@PROJECT_NAME@" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "@PROJECT_NAME@ @PROJECT_VERSION@" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "@PROJECT_NAME@" + +/* Define to the home page for this package. */ +#cmakedefine PACKAGE_URL + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "@PROJECT_VERSION@" + +/* How to access the PC from a struct ucontext */ +#define PC_FROM_UCONTEXT @PC_FROM_UCONTEXT_DEF@ + +/* Always the empty-string on non-windows systems. On windows, should be + "__declspec(dllexport)". This way, when we compile the dll, we export our + functions/classes. It's safe to define this here because config.h is only + used internally, to compile the DLL, and every DLL source file #includes + "config.h" before anything else. */ +#cmakedefine WIN32 +#if defined(WIN32) +#ifndef PERFTOOLS_DLL_DECL +# define PERFTOOLS_IS_A_DLL 1 /* not set if you're statically linking */ +# define PERFTOOLS_DLL_DECL __declspec(dllexport) +# define PERFTOOLS_DLL_DECL_FOR_UNITTESTS __declspec(dllimport) +#endif +#endif + +/* printf format code for printing a size_t and ssize_t */ +#define PRIdS "Id" + +/* printf format code for printing a size_t and ssize_t */ +#define PRIuS "Iu" + +/* printf format code for printing a size_t and ssize_t */ +#define PRIxS "Ix" + +/* Mark the systems where we know it's bad if pthreads runs too + early before main (before threads are initialized, presumably). */ +#cmakedefine PTHREADS_CRASHES_IF_RUN_TOO_EARLY + +/* Define to necessary symbol if this constant uses a non-standard name on + your system. */ +#define PTHREAD_CREATE_JOINABLE @PTHREAD_CREATE_JOINABLE@ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* the namespace where STL code like vector<> is defined */ +#cmakedefine STL_NAMESPACE std + +/* Version number of package */ +#define VERSION @PROJECT_VERSION@ + +/* C99 says: define this to get the PRI... macros from stdint.h */ +#ifndef __STDC_FORMAT_MACROS +# define __STDC_FORMAT_MACROS 1 +#endif + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#define inline @inline@ +#endif + +#if defined(WIN32) + +// --------------------------------------------------------------------- +// Extra stuff not found in config.h.in + +// This must be defined before the windows.h is included. We need at +// least 0x0400 for mutex.h to have access to TryLock, and at least +// 0x0501 for patch_functions.cc to have access to GetModuleHandleEx. +// (This latter is an optimization we could take out if need be.) +#ifndef _WIN32_WINNT +# define _WIN32_WINNT 0x0501 +#endif + +#define NO_HEAP_CHECK 1 + +// TODO(csilvers): include windows/port.h in every relevant source file instead? +#include "windows/port.h" + +#endif + +#ifdef __MINGW32__ +#include "windows/mingw.h" +#endif + +#endif /* #ifndef GPERFTOOLS_CONFIG_H_ */ diff --git a/cmake/tcmalloc.h.in b/cmake/tcmalloc.h.in new file mode 100644 index 0000000..3bffb6f --- /dev/null +++ b/cmake/tcmalloc.h.in @@ -0,0 +1,147 @@ +// -*- Mode: C; c-basic-offset: 2; indent-tabs-mode: nil -*- +/* Copyright (c) 2003, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * --- + * Author: Sanjay Ghemawat <opensource@google.com> + * .h file by Craig Silverstein <opensource@google.com> + */ + +#ifndef TCMALLOC_TCMALLOC_H_ +#define TCMALLOC_TCMALLOC_H_ + +#include <stddef.h> /* for size_t */ + +/* Define the version number so folks can check against it */ +#define TC_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ +#define TC_VERSION_MINOR @PROJECT_VERSION_MINOR@ +#define TC_VERSION_PATCH "@PROJECT_VERSION_PATCH@" +#define TC_VERSION_STRING "gperftools @TC_VERSION_MAJOR@.@TC_VERSION_MINOR@@TC_VERSION_PATCH@" + +/* For struct mallinfo, if it's defined. */ +#ifdef HAVE_STRUCT_MALLINFO +# include <malloc.h> +#endif + +#ifndef PERFTOOLS_NOTHROW + +#if __cplusplus >= 201103L +#define PERFTOOLS_NOTHROW noexcept +#elif defined(__cplusplus) +#define PERFTOOLS_NOTHROW throw() +#else +# ifdef __GNUC__ +# define PERFTOOLS_NOTHROW __attribute__((__nothrow__)) +# else +# define PERFTOOLS_NOTHROW +# endif +#endif + +#endif + +#ifndef PERFTOOLS_DLL_DECL +# ifdef _WIN32 +# define PERFTOOLS_DLL_DECL __declspec(dllimport) +# else +# define PERFTOOLS_DLL_DECL +# endif +#endif + +#ifdef __cplusplus +namespace std { +struct nothrow_t; +} + +extern "C" { +#endif + /* + * Returns a human-readable version string. If major, minor, + * and/or patch are not NULL, they are set to the major version, + * minor version, and patch-code (a string, usually ""). + */ + PERFTOOLS_DLL_DECL const char* tc_version(int* major, int* minor, + const char** patch) PERFTOOLS_NOTHROW; + + PERFTOOLS_DLL_DECL void* tc_malloc(size_t size) PERFTOOLS_NOTHROW; + PERFTOOLS_DLL_DECL void* tc_malloc_skip_new_handler(size_t size) PERFTOOLS_NOTHROW; + PERFTOOLS_DLL_DECL void tc_free(void* ptr) PERFTOOLS_NOTHROW; + PERFTOOLS_DLL_DECL void tc_free_sized(void *ptr, size_t size) PERFTOOLS_NOTHROW; + PERFTOOLS_DLL_DECL void* tc_realloc(void* ptr, size_t size) PERFTOOLS_NOTHROW; + PERFTOOLS_DLL_DECL void* tc_calloc(size_t nmemb, size_t size) PERFTOOLS_NOTHROW; + PERFTOOLS_DLL_DECL void tc_cfree(void* ptr) PERFTOOLS_NOTHROW; + + PERFTOOLS_DLL_DECL void* tc_memalign(size_t __alignment, + size_t __size) PERFTOOLS_NOTHROW; + PERFTOOLS_DLL_DECL int tc_posix_memalign(void** ptr, + size_t align, size_t size) PERFTOOLS_NOTHROW; + PERFTOOLS_DLL_DECL void* tc_valloc(size_t __size) PERFTOOLS_NOTHROW; + PERFTOOLS_DLL_DECL void* tc_pvalloc(size_t __size) PERFTOOLS_NOTHROW; + + PERFTOOLS_DLL_DECL void tc_malloc_stats(void) PERFTOOLS_NOTHROW; + PERFTOOLS_DLL_DECL int tc_mallopt(int cmd, int value) PERFTOOLS_NOTHROW; +#if HAVE_STRUCT_MALLINFO + PERFTOOLS_DLL_DECL struct mallinfo tc_mallinfo(void) PERFTOOLS_NOTHROW; +#endif + + /* + * This is an alias for MallocExtension::instance()->GetAllocatedSize(). + * It is equivalent to + * OS X: malloc_size() + * glibc: malloc_usable_size() + * Windows: _msize() + */ + PERFTOOLS_DLL_DECL size_t tc_malloc_size(void* ptr) PERFTOOLS_NOTHROW; + +#ifdef __cplusplus + PERFTOOLS_DLL_DECL int tc_set_new_mode(int flag) PERFTOOLS_NOTHROW; + PERFTOOLS_DLL_DECL void* tc_new(size_t size); + PERFTOOLS_DLL_DECL void* tc_new_nothrow(size_t size, + const std::nothrow_t&) PERFTOOLS_NOTHROW; + PERFTOOLS_DLL_DECL void tc_delete(void* p) PERFTOOLS_NOTHROW; + PERFTOOLS_DLL_DECL void tc_delete_sized(void* p, size_t size) PERFTOOLS_NOTHROW; + PERFTOOLS_DLL_DECL void tc_delete_nothrow(void* p, + const std::nothrow_t&) PERFTOOLS_NOTHROW; + PERFTOOLS_DLL_DECL void* tc_newarray(size_t size); + PERFTOOLS_DLL_DECL void* tc_newarray_nothrow(size_t size, + const std::nothrow_t&) PERFTOOLS_NOTHROW; + PERFTOOLS_DLL_DECL void tc_deletearray(void* p) PERFTOOLS_NOTHROW; + PERFTOOLS_DLL_DECL void tc_deletearray_sized(void* p, size_t size) PERFTOOLS_NOTHROW; + PERFTOOLS_DLL_DECL void tc_deletearray_nothrow(void* p, + const std::nothrow_t&) PERFTOOLS_NOTHROW; +} +#endif + +/* We're only un-defining for public */ +#if !defined(GPERFTOOLS_CONFIG_H_) + +#undef PERFTOOLS_NOTHROW + +#endif /* GPERFTOOLS_CONFIG_H_ */ + +#endif /* #ifndef TCMALLOC_TCMALLOC_H_ */ |