summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsaac Hier <isaachier@gmail.com>2017-11-05 12:23:42 -0500
committerAliaksey Kandratsenka <alkondratenko@gmail.com>2020-12-19 18:52:40 -0800
commit6078fe40d9a5b829cbbadc6ec824163d6d9eda5b (patch)
tree8c4f372a09dd37322097fa7d83082181d8af7113
parent515fb221966a2413d00184186da97719b90e3915 (diff)
downloadgperftools-6078fe40d9a5b829cbbadc6ec824163d6d9eda5b.tar.gz
Finish configure.ac conversion to CMake, start on Makefile.am
-rw-r--r--CMakeLists.txt755
-rw-r--r--cmake/CheckNoFPByDefault.cmake41
-rw-r--r--cmake/DefineTargetVariables.cmake17
-rw-r--r--cmake/FindObjcopyWithWeaken.cmake34
-rw-r--r--cmake/GPerftoolsAddTarget.cmake14
-rw-r--r--cmake/PCFromUContext.cmake10
-rw-r--r--cmake/config.h.in19
7 files changed, 656 insertions, 234 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 936e75c..401c57b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 3.0)
+# Based on configure.ac
+
project(gperftools VERSION 2.6.1 LANGUAGES C CXX)
set(tcmalloc_so_version 8.5.4)
@@ -17,66 +19,70 @@ set(need_nanosleep ON)
set(host string(TOLOWER "${CMAKE_SYSTEM_NAME}"))
if(MINGW)
- set(default_build_minimal ON)
- set(default_build_debugalloc OFF)
- set(need_nanosleep OFF)
+ set(default_build_minimal ON)
+ set(default_build_debugalloc OFF)
+ set(need_nanosleep OFF)
elseif(CYGWIN)
- set(default_build_heap_checker OFF)
- set(default_build_cpu_profiler OFF)
+ set(default_build_heap_checker OFF)
+ set(default_build_cpu_profiler OFF)
elseif(host MATCHES "freebsd")
- set(default_build_heap_checker OFF)
+ set(default_build_heap_checker OFF)
elseif(APPLE)
- set(default_build_heap_checker OFF)
+ set(default_build_heap_checker OFF)
endif()
include(CMakeDependentOption)
-include(CheckCXXCompilerFlag)
+include(CheckCCompilerFlag)
+include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles)
-include(CheckCXXSymbolExists)
include(CheckFunctionExists)
-include(CheckIncludeFileCXX)
+include(CheckIncludeFile)
include(CheckLibraryExists)
+include(CheckSymbolExists)
include(CheckTypeSize)
include(CheckVariableExists)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
+include(CheckNoFPByDefault)
include(DefineTargetVariables)
+include(FindObjcopyWithWeaken)
+include(GPerftoolsAddTarget)
include(PCFromUContext)
define_target_variables()
if(s390)
- set(default_enable_libunwind OFF)
- set(default_enable_backtrace ON)
+ set(default_enable_libunwind OFF)
+ set(default_enable_backtrace ON)
else()
- set(default_enable_libunwind ON)
- set(default_enable_backtrace OFF)
+ set(default_enable_libunwind ON)
+ set(default_enable_backtrace OFF)
endif()
if(PPC64)
- set(default_enable_libunwind OFF)
- set(default_tcmalloc_pagesize 64)
+ set(default_enable_libunwind OFF)
+ set(default_tcmalloc_pagesize 64)
else()
- set(default_enable_libunwind ON)
- set(default_tcmalloc_pagesize 8)
+ set(default_enable_libunwind ON)
+ set(default_tcmalloc_pagesize 8)
endif()
option(
- gperftools_build_minimal
- "Build only tcmalloc-minimal (and maybe tcmalloc-minimal-debug)"
- ${default_build_minimal})
+ gperftools_build_minimal
+ "Build only tcmalloc-minimal (and maybe tcmalloc-minimal-debug)"
+ ${default_build_minimal})
cmake_dependent_option(
- gperftools_build_cpu_profiler "Build cpu-profiler" ${default_build_cpu_profiler}
- "NOT gperftools_build_minimal" OFF)
+ gperftools_build_cpu_profiler "Build cpu-profiler" ${default_build_cpu_profiler}
+ "NOT gperftools_build_minimal" OFF)
cmake_dependent_option(
- gperftools_build_heap_profiler "Build heap-profiler" ${default_build_heap_profiler}
- "NOT gperftools_build_minimal" OFF)
+ gperftools_build_heap_profiler "Build heap-profiler" ${default_build_heap_profiler}
+ "NOT gperftools_build_minimal" OFF)
cmake_dependent_option(
- gperftools_build_heap_checker "Build heap-checker" ${default_build_heap_checker}
- "NOT gperftools_build_minimal" OFF)
+ gperftools_build_heap_checker "Build heap-checker" ${default_build_heap_checker}
+ "NOT gperftools_build_minimal" OFF)
cmake_dependent_option(
- gperftools_build_debugalloc "Build debugalloc" ${default_build_debugalloc}
- "NOT gperftools_build_minimal" OFF)
+ gperftools_build_debugalloc "Build debugalloc" ${default_build_debugalloc}
+ "NOT gperftools_build_minimal" OFF)
option(gperftools_enable_stacktrace_via_backtrace
"Enable use of backtrace() for stacktrace capturing (may deadlock)"
@@ -89,54 +95,55 @@ 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")
+ CACHE STRING "Set the tcmalloc internal page size")
set_property(CACHE gperftools_tcmalloc_pagesize PROPERTY STRINGS "8" "32" "64")
if(NOT gperftools_tcmalloc_pagesize STREQUAL "8" AND
NOT gperftools_tcmalloc_pagesize STREQUAL "32" AND
NOT gperftools_tcmalloc_pagesize STREQUAL "64")
- message(WARNING
- "Invalid gperftools_tcmalloc_pagesize (${gperftools_tcmalloc_pagesize}), "
- "setting to default value (${default_tcmalloc_pagesize})")
- set(gperftools_tcmalloc_pagesize ${default_tcmalloc_pagesize})
+ message(WARNING
+ "Invalid gperftools_tcmalloc_pagesize (${gperftools_tcmalloc_pagesize}), "
+ "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)
+ 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")
+ CACHE STRING "Set the tcmalloc allocation alignment")
set_property(CACHE gperftools_tcmalloc_alignment PROPERTY STRINGS "8" "16")
if(NOT gperftools_tcmalloc_alignment STREQUAL "8" AND
NOT gperftools_tcmalloc_alignment STREQUAL "16")
- message(WARNING
- "Invalid gperftools_tcmalloc_alignment (${gperftools_tcmalloc_alignment}), "
- "setting to default value (${default_tcmalloc_alignment})")
- set(gperftools_tcmalloc_alignment ${default_tcmalloc_alignment})
+ message(WARNING
+ "Invalid gperftools_tcmalloc_alignment (${gperftools_tcmalloc_alignment}), "
+ "setting to default value (${default_tcmalloc_alignment})")
+ set(gperftools_tcmalloc_alignment ${default_tcmalloc_alignment})
endif()
if(gperftools_tcmalloc_alignment STREQUAL "8")
- set(TCMALLOC_ALIGN_8BYTES ON)
+ set(TCMALLOC_ALIGN_8BYTES ON)
endif()
-check_cxx_source_compiles("#include <stdlib.h>
- static void foo(void) __attribute__ ((unused));
- void foo(void) { exit(1); }
- int main() { return 0; }"
- HAVE___ATTRIBUTE__)
+check_c_source_compiles("#include <stdlib.h>
+ static void foo(void) __attribute__ ((unused));
+ void foo(void) { exit(1); }
+ int main() { return 0; }"
+ HAVE___ATTRIBUTE__)
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()
+ check_c_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()
-# TODO: Find `objcopy` with `--weaken` support
+option(gperftools_objcopy_path "Path to objcopy if present" "")
+find_objcopy_with_weaken(objcopy_exe ${gperftools_objcopy_path})
check_type_size("__int64" __INT64 LANGUAGE CXX)
set(CMAKE_EXTRA_INCLUDE_FILES "malloc.h")
@@ -147,254 +154,566 @@ set(CMAKE_EXTRA_INCLUDE_FILES)
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)
-check_include_file_cxx("grp.h" HAVE_GRP_H)
-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("features.h" HAVE_FEATURES_H)
+check_include_file("inttypes.h" HAVE_INTTYPES_H)
+check_include_file("stdint.h" HAVE_STDINT_H)
+check_include_file("stdlib.h" HAVE_STDLIB_H)
+check_include_file("strings.h" HAVE_STRINGS_H)
+check_include_file("string.h" HAVE_STRING_H)
+check_include_file("dlfcn.h" HAVE_DLFCN_H)
+check_include_file("malloc.h" HAVE_MALLOC_H)
+check_include_file("sys/malloc.h" HAVE_SYS_MALLOC_H)
+check_include_file("sys/param.h" HAVE_SYS_PARAM_H)
+check_include_file("glob.h" HAVE_GLOB_H)
+check_include_file("execinfo.h" HAVE_EXECINFO_H)
+check_include_file("unwind.h" HAVE_UNWIND_H)
+check_include_file("unistd.h" HAVE_UNISTD_H)
+check_include_file("valgrind.h" HAVE_VALGRIND_H)
+check_include_file("sched.h" HAVE_SCHED_H)
+check_include_file("conflict-signal.h" HAVE_CONFLICT_SIGNAL_H)
+check_include_file("cygwin/signal.h" HAVE_CYGWIN_SIGNAL_H)
+check_include_file("sys/prctl.h" HAVE_SYS_PRCTL_H)
+check_include_file("linux/ptrace.h" HAVE_LINUX_PTRACE_H)
+check_include_file("sys/syscall.h" HAVE_SYS_SYSCALL_H)
+check_include_file("sys/socket.h" HAVE_SYS_SOCKET_H)
+check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
+check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
+check_include_file("sys/wait.h" HAVE_SYS_WAIT_H)
+check_include_file("poll.h" HAVE_POLL_H)
+check_include_file("fcntl.h" HAVE_FCNTL_H)
+check_include_file("grp.h" HAVE_GRP_H)
+check_include_file("pwd.h" HAVE_PWD_H)
+check_include_file("sys/resource.h" HAVE_SYS_RESOURCE_H)
+check_include_file("valgrind.h" HAVE_VALGRIND_H)
+check_include_file("sys/cdefs.h" HAVE_SYS_CDEFS_H)
set(CMAKE_REQUIRED_DEFINITIONS -D_XOPEN_SOURCE=600)
-check_cxx_symbol_exists("cfree" "stdlib.h;malloc.h" HAVE_DECL_CFREE)
+check_symbol_exists("cfree" "stdlib.h;malloc.h" HAVE_DECL_CFREE)
set(CMAKE_REQUIRED_DEFINITIONS)
-check_cxx_symbol_exists("posix_memalign" "stdlib.h;malloc.h" HAVE_DECL_POSIX_MEMALIGN)
-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_MMAP)
-check_cxx_symbol_exists("uname" "sys/utsname.h" HAVE_DECL_UNAME)
+check_symbol_exists("posix_memalign" "stdlib.h;malloc.h" HAVE_DECL_POSIX_MEMALIGN)
+check_symbol_exists("memalign" "stdlib.h;malloc.h" HAVE_DECL_MEMALIGN)
+check_symbol_exists("valloc" "stdlib.h;malloc.h" HAVE_DECL_VALLOC)
+check_symbol_exists("pvalloc" "stdlib.h;malloc.h" HAVE_DECL_PVALLOC)
+check_symbol_exists("mmap" "stdlib.h;unistd.h;sys/mman.h;sys/param.h" HAVE_MMAP)
+check_symbol_exists("uname" "sys/utsname.h" HAVE_DECL_UNAME)
check_function_exists("snprintf" HAVE_SNPRINTF)
if(WIN32)
- set(HAVE_GETPAGESIZE ON)
+ set(HAVE_GETPAGESIZE ON)
else()
- check_function_exists("getpagesize" HAVE_GETPAGESIZE)
+ 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)
+check_c_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_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)
- endif()
- if(have_libunwind)
- list(APPEND unwind_libs unwind)
- set(will_use_libunwind ON)
- endif()
+ check_include_file("libunwind.h" HAVE_LIBUNWIND_H)
+ find_library(libunwind_location NAMES unwind)
+ if(libunwind_location)
+ check_library_exists(
+ unwind backtrace ${libunwind_location} have_libunwind)
+ endif()
+ if(have_libunwind)
+ set(unwind_libs unwind)
+ set(will_use_libunwind ON)
+ endif()
+endif()
+
+if(x86_64)
+ check_omit_fp_by_default(omit_fp_by_default)
+endif()
+
+if(x86_64 AND omit_fp_by_default)
+ set(fp_option_enabled "Success")
+else()
+ set(fp_option_enabled "Failed")
+ if(NOT x86_64)
+ set(fp_option_enabled "${fp_option_enabled}, not x86_64")
+ elseif(NOT omit_fp_by_default)
+ set(fp_option_enabled
+ "${fp_option_enabled}, frame pointer not omitted by default")
+ endif()
+ message(STATUS
+ "Enable option gperftools_enable_frame_pointers - ${fp_option_enabled}")
endif()
cmake_dependent_option(
- gperftools_enable_frame_pointers
- "On x86_64 systems, compile with -fno-omit-frame-pointer (see INSTALL)"
- OFF
- "x86_64"
- OFF)
+ gperftools_enable_frame_pointers
+ "On x86_64 systems, compile with -fno-omit-frame-pointer (see INSTALL)"
+ OFF
+ "x86_64;omit_fp_by_default"
+ OFF)
-check_cxx_compiler_flag("-Wno-unused-result" HAVE_W_NO_UNUSED_RESULT)
+check_c_compiler_flag("-Wno-unused-result" have_w_no_unused_result)
option(gperftools_dynamic_sized_delete_support
"Try to build run-time switch for sized delete operator"
OFF)
if(gperftools_dynamic_sized_delete_support)
- set(ENABLE_DYNAMIC_SIZED_DELETE 1)
+ set(ENABLE_DYNAMIC_SIZED_DELETE 1)
endif()
option(gperftools_sized_delete "Build sized delete operator" OFF)
if(gperftools_sized_delete)
- set(ENABLE_SIZED_DELETE 1)
+ set(ENABLE_SIZED_DELETE 1)
endif()
-check_cxx_compiler_flag("-fsized-deallocation" HAVE_SIZED_FREE_OPTION)
-
-check_cxx_source_compiles(
- "namespace abc { void foo() {} } int main() { abc::foo(); return 0; }"
- HAVE_NAMESPACES)
-
+set(CMAKE_REQUIRED_FLAGS -fsized-deallocation)
check_cxx_source_compiles("
- include <unwind.h>
- int main()
- {
- &_Unwind_Backtrace;
- return 0;
- }"
- HAVE_UNWIND_BACKTRACE)
+ #include <new>
+ int main() { (::operator delete)(0, 256); return 0; }"
+ have_sized_deallocation)
+set(CMAKE_REQUIRED_FLAGS)
+
+check_c_source_compiles(
+ "namespace abc { void foo() {} } int main() { abc::foo(); return 0; }"
+ HAVE_NAMESPACES)
+
+check_c_source_compiles("
+ #include <unwind.h>
+ int main()
+ {
+ &_Unwind_Backtrace;
+ return 0;
+ }"
+ HAVE_UNWIND_BACKTRACE)
if(enable_backtrace)
- set(default_emergency_malloc ON)
+ set(default_emergency_malloc ON)
else()
- set(default_emergency_malloc OFF)
+ set(default_emergency_malloc OFF)
endif()
if(will_use_libunwind AND ARM)
- set(default_emergency_malloc ON)
+ set(default_emergency_malloc ON)
endif()
option(gperftools_emergency_malloc
"Build emergency malloc"
${default_emergency_malloc})
-check_cxx_source_compiles(
- "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>
- int main()
- {
- char** env = __environ;
- return 0;
- }"
- HAVE___ENVIRON)
-
-if(CMAKE_CXX_COMPILER STREQUAL "GNU" AND
+check_c_source_compiles(
+ "int main() { void* sp = __builtin_stack_pointer(); return 0; }"
+ HAVE_BUILTIN_STACK_POINTER)
+check_c_source_compiles(
+ "int main() { return __builtin_expect(main != 0, 1); }"
+ HAVE_BUILTIN_EXPECT)
+
+check_c_source_compiles("
+ #include <unistd.h>
+ int main()
+ {
+ char** env = __environ;
+ return 0;
+ }"
+ HAVE___ENVIRON)
+
+if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.1.2")
- message(WARNING "gcc has this bug: http://gcc.gnu.org/ml/gcc-bugs/2006-09/msg02275.html")
+ message(WARNING "gcc has this bug: http://gcc.gnu.org/ml/gcc-bugs/2006-09/msg02275.html")
elseif(APPLE)
- message(WARNING "OSX __thread support is known to call malloc which makes "
+ message(WARNING "OSX __thread support is known to call malloc which makes "
"it unsafe to use from malloc replacement")
elseif(MINGW)
- message(WARNING "mingw doesn't really support tls")
+ message(WARNING "mingw doesn't really support tls")
else()
- check_cxx_source_compiles("static __thread int p = 0;" HAVE_TLS)
+ check_c_source_compiles("static __thread int p = 0;" HAVE_TLS)
endif()
if(need_nanosleep)
- check_cxx_source_compiles(
- "#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)
- check_cxx_source_compiles(
- "int main() { static struct timespec ts; nanosleep(&ts, NULL); return 0; }"
- nanosleep_ok)
- if(nanosleep_ok)
- list(APPEND LIBS rt)
- else()
- message(FATAL_ERROR "cannot find the nanosleep function")
- endif()
- set(CMAKE_REQUIRED_LIBRARIES)
+ check_c_source_compiles(
+ "#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)
+ check_c_source_compiles(
+ "#include <time.h>
+ int main()
+ { static struct timespec ts; nanosleep(&ts, NULL); return 0; }"
+ nanosleep_ok)
+ if(nanosleep_ok)
+ set(nanosleep_libs rt)
+ else()
+ message(FATAL_ERROR "cannot find the nanosleep function")
endif()
+ set(CMAKE_REQUIRED_LIBRARIES)
+ endif()
endif()
if(enable_backtrace)
- check_cxx_symbol_exists("backtrace" "execinfo.h" HAVE_DECL_BACKTRACE)
+ check_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)
- 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()
+ 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()
+ check_c_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()
+list(APPEND libs Threads::Threads)
if(FreeBSD)
- set(PTHREADS_CRASHES_IF_RUN_TOO_EARLY ON)
+ set(PTHREADS_CRASHES_IF_RUN_TOO_EARLY ON)
endif()
+set(libstdcxx_la_linker_flag)
if(EXISTS /usr/sfw/lib/libstdc++.la)
- file(READ /usr/sfw/lib/libstdc++.la _ch LIMIT 1)
- if(string(LENGTH _ch) EQUAL 0)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Lsrc/solaris")
- endif()
+ file(READ /usr/sfw/lib/libstdc++.la _ch LIMIT 1)
+ if(string(LENGTH _ch) EQUAL 0)
+ set(libstdcxx_la_linker_flag "-L${CMAKE_CURRENT_SOURCE_DIR}/src/solaris")
+ endif()
endif()
check_cxx_source_compiles(
- "#include <string>
+ "#include <string>
#include <vector>
int main() { pthread_t th; pthread_join(th, 0); return 0; }"
- HAVE_PTHREAD_DESPITE_ASKING_FOR)
+ have_pthread_despite_asking_for)
check_cxx_source_compiles(
- "#include <vector>
+ "#include <vector>
int main() { vector<int> t; return 0; }"
- STL_NAMESPACE_NONE)
+ STL_NAMESPACE_NONE)
if(STL_NAMESPACE_NONE)
- set(STL_NAMESPACE "")
+ set(STL_NAMESPACE "")
else()
- check_cxx_source_compiles(
- "#include <vector>
+ check_cxx_source_compiles(
+ "#include <vector>
int main() { std::vector<int> t; return 0; }"
- STL_NAMESPACE_STD)
- if (STL_NAMESPACE_STD)
- set(STL_NAMESPACE "std")
- endif()
+ STL_NAMESPACE_STD)
+ if (STL_NAMESPACE_STD)
+ set(STL_NAMESPACE "std")
+ endif()
endif()
check_variable_exists("program_invocation_name" HAVE_PROGRAM_INVOCATION_NAME)
if(MINGW)
- check_cxx_symbol_exists("sleep" "unistd.h" HAVE_DECL_SLEEP)
- check_cxx_symbol_exists("nanosleep" "time.h" HAVE_DECL_NANOSLEEP)
+ check_symbol_exists("sleep" "unistd.h" HAVE_DECL_SLEEP)
+ check_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)
+ check_c_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)
+configure_file(cmake/tcmalloc.h.in
+ ${CMAKE_BINARY_DIR}/gperftools/tcmalloc.h
+ @ONLY)
+
+if(gperftools_build_cpu_profiler OR
+ gperftools_build_heap_profiler OR
+ gperftools_build_heap_checker)
+ set(with_stack_trace ON)
+endif()
+
+if(gperftools_enable_frame_pointers AND
+ unwind_libs STREQUAL "" AND
+ NOT gperftools_build_minimal)
+ if(HAVE_UNWIND_BACKTRACE)
+ message(WARNING "No frame pointers and no libunwind. "
+ "Using experimental backtrace capturing via libgcc. "
+ "Expect crashy cpu profiler.")
+ if(gperftools_enable_stacktrace_via_backtrace)
+ message(WARNING "No frame pointers and no libunwind. "
+ "Using experimental backtrace(). "
+ "Expect crashy cpu profiler.")
+ else()
+ message(FATAL_ERROR "No frame pointers and no libunwind. "
+ "The compilation will fail.")
+ endif()
+ endif()
+endif()
+
+# Based on Makefile.am
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+list(APPEND inc $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>)
+if(NOT with_stack_trace)
+ list(APPEND def NO_TCMALLOC_SAMPLES)
+endif()
+
+if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ list(APPEND options
+ -Wall -Wwrite-strings -Woverloaded-virtual
+ -Wno-sign-compare
+ -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc
+ -fno-builtin-calloc -fno-builtin-cfree
+ -fno-builtin-memalign -fno-builtin-posix_memalign
+ -fno-builtin-valloc -fno-builtin-pvalloc)
+
+ if(i386)
+ list(APPEND options -mmmx -fno-omit-frame-pointer)
+ endif()
+endif()
+
+if(have_w_no_unused_result)
+ list(APPEND options -Wno-unused-result)
+endif()
+
+if(have_sized_deallocation)
+ list(APPEND options -fsized-deallocation)
+endif()
+
+list(APPEND libs ${libstdcxx_la_linker_flag})
+
+if(gperftools_enable_frame_pointers)
+ list(APPEND options -fno-omit-frame-pointer)
+elseif(NOT CMAKE_CXX_FLAGS MATCHES "-fno-omit-frame-pointer")
+ list(APPEND defs NO_FRAME_POINTER)
+endif()
+
+if(MINGW)
+ list(APPEND tcmalloc_lib_options "-Wl,-u__tcmalloc")
+endif()
+
+if(objcopy_exe)
+ set(weaken
+ -W malloc -W free -W realloc -W calloc -W cfree
+ -W memalign -W posix_memalign -W valloc -W pvalloc
+ -W aligned_alloc
+ -W malloc_stats -W mallopt -W mallinfo -W nallocx
+ -W _Znwm -W _ZnwmRKSt9nothrow_t -W _Znam -W _ZnamRKSt9nothrow_t
+ -W _ZdlPv -W _ZdaPv
+ -W __Znwm -W __ZnwmRKSt9nothrow_t -W __Znam -W __ZnamRKSt9nothrow_t
+ -W __ZdlPv -W __ZdaPv)
+endif()
+
+message(STATUS "includes: ${inc}")
+message(STATUS "libraries: ${libs}")
+message(STATUS "definitions: ${defs}")
+message(STATUS "options: ${options}")
+
+set(logging_headers
+ src/base/logging.h
+ src/base/commandlineflags.h
+ src/base/basictypes.h
+ src/base/dynamic_annotations.h
+ src/third_party/valgrind.h)
+add_library(logging
+ src/base/logging.cc
+ src/base/dynamic_annotations.c
+ ${logging_headers})
+gperftools_add_target(logging)
+
+set(sysinfo_headers
+ src/base/sysinfo.h
+ src/getenv_safe.h
+ src/base/arm_instruction_set_select.h
+ src/base/basictypes.h)
+add_library(sysinfo
+ src/base/sysinfo.cc
+ ${sysinfo_headers})
+target_link_libraries(sysinfo PUBLIC logging ${nanosleep_libs})
+
+set(spinlock_headers
+ src/base/spinlock.h
+ src/base/spinlock_internal.h
+ src/base/spinlock_win32-inl.h
+ src/base/spinlock_linux-inl.h
+ src/base/spinlock_posix-inl.h
+ src/base/atomicops-internals-macosx.h
+ src/base/atomicops-internals-linuxppc.h
+ src/base/atomicops-internals-arm-generic.h
+ src/base/atomicops-internals-arm-v6plus.h
+ src/base/atomicops-internals-mips.h
+ src/base/atomicops-internals-windows.h
+ src/base/atomicops-internals-gcc.h
+ src/base/atomicops-internals-x86.h)
+add_library(spinlock
+ src/base/spinlock.cc
+ src/base/spinlock_internal.cc
+ src/base/atomicops-internals-x86.cc
+ ${spinlock_headers})
+target_link_libraries(spinlock PUBLIC sysinfo ${nanosleep_libs})
+
+set(maybe_threads_headers src/maybe_threads.h)
+
+if(MINGW)
+ set(windows_headers
+ src/windows/port.h
+ src/windows/mingw.h
+ src/windows/mini_disassembler.h
+ src/windows/mini_disassembler_types.h
+ src/windows/preamble_patcher.h)
+ add_library(windows
+ src/windows/port.cc
+ src/windows/system-alloc.cc
+ src/windows/ia32_modrm_map.cc
+ src/windows/ia32_opcode_map.cc
+ src/windows/mini_disassembler.cc
+ src/windows/patch_functions.cc
+ src/windows/preamble_patcher.cc
+ src/windows/preamble_patcher_with_stub.cc
+ ${windows_headers})
+ gperftools_add_target(windows)
+ target_link_libraries(windows PUBLIC psapi)
+
+ target_link_libraries(spinlock PUBLIC windows)
+ target_link_libraries(sysinfo PUBLIC shlwapi)
+
+ if(have_pthread_despite_asking_for)
+ add_library(maybe_threads src/maybe_threads.cc ${maybe_threads_headers})
+ gperftools_add_target(maybe_threads)
+ set(maybe_threads_lib maybe_threads)
+ endif()
+else()
+ set(tcmalloc_cc "src/tcmalloc.cc")
+ set(system_alloc_cc "src/system-alloc.cc")
+
+ add_library(maybe_threads src/maybe_threads.cc ${maybe_threads_headers})
+ gperftools_add_target(maybe_threads)
+ set(maybe_threads_lib maybe_threads)
+endif()
+
+if(BUILD_TESTING)
+ add_executable(low_level_alloc_unittest
+ src/base/low_level_alloc.cc
+ src/malloc_hook.cc
+ src/tests/low_level_alloc_unittest.cc)
+ target_compile_definitions(low_level_alloc_unittest PUBLIC
+ NO_TCMALLOC_SAMPLES)
+ target_link_libraries(low_level_alloc_unittest PUBLIC spinlock maybe_threads)
+
+ add_executable(atomicops_unittest src/tests/atomicops_unittest.cc)
+ target_link_libraries(atomicops_unittest spinlock)
+endif()
+
+if(with_stack_trace)
+ set(stacktrace_headers
+ src/stacktrace_impl_setup-inl.h
+ src/stacktrace_generic-inl.h
+ src/stacktrace_libgcc-inl.h
+ src/stacktrace_libunwind-inl.h
+ src/stacktrace_arm-inl.h
+ src/stacktrace_powerpc-inl.h
+ src/stacktrace_powerpc-darwin-inl.h
+ src/stacktrace_powerpc-linux-inl.h
+ src/stacktrace_x86-inl.h
+ src/stacktrace_win32-inl.h
+ src/stacktrace_instrument-inl.h
+ src/base/elf_mem_image.h
+ src/base/vdso_support.h
+ src/gperftools/stacktrace.h)
+ add_library(stacktrace
+ src/stacktrace.cc
+ src/base/elf_mem_image.cc
+ src/base/vdso_support.cc
+ ${stacktrace_headers})
+ target_link_libraries(stacktrace PUBLIC unwind spinlock)
+ gperftools_add_target(stacktrace)
+
+ add_library(fake_stacktrace_scope src/fake_stacktrace_scope.cc)
+
+ if(BUILD_TESTING)
+ set(stacktrace_unittest_headers
+ src/config_for_unittests.h
+ src/base/commandlineflags.h)
+ add_executable(stacktrace_unittest
+ src/tests/stacktrace_unittest.cc
+ ${stacktrace_unittest_headers})
+ target_link_libraries(stacktrace_unittest PUBLIC
+ stacktrace logging fake_stacktrace_scope)
+ gperftools_add_target(stacktrace_unittest)
+
+ add_custom_target(pprof_unittest
+ COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/src/pprof -test
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/pprof)
+ endif()
+endif()
+
+set(tcmalloc_minimal_headers
+ src/common.h
+ src/internal_logging.h
+ src/system-alloc.h
+ src/packed-cache-inl.h
+ src/tcmalloc_guard.h
+ src/base/commandlineflags.h
+ src/base/basictypes.h
+ src/pagemap.h
+ src/sampler.h
+ src/central_freelist.h
+ src/linked_list.h
+ src/libc_override.h
+ src/libc_override_gcc_and_weak.h
+ src/libc_override_glibc.h
+ src/libc_override_osx.h
+ src/libc_override_redefine.h
+ src/page_heap.h
+ src/page_heap_allocator.h
+ src/span.h
+ src/static_vars.h
+ src/symbolize.h
+ src/thread_cache.h
+ src/stack_trace_table.h
+ src/base/thread_annotations.h
+ src/malloc_hook-inl.h
+ src/malloc_hook_mmap_linux.h
+ src/malloc_hook_mmap_freebsd.h)
+add_library(tcmalloc_minimal
+ src/common.cc
+ src/internal_logging.cc
+ ${system_alloc_cc}
+ src/memfs_malloc.cc
+ src/central_freelist.cc
+ src/page_heap.cc
+ src/sampler.cc
+ src/span.cc
+ src/stack_trace_table.cc
+ src/static_vars.cc
+ src/symbolize.cc
+ src/thread_cache.cc
+ src/malloc_hook.cc
+ src/malloc_extension.cc
+ ${tcmalloc_minimal_headers})
+target_compile_definitions(tcmalloc_minimal PUBLIC
+ NO_TCMALLOC_SAMPLES NO_HEAP_CHECK)
+target_link_libraries(tcmalloc_minimal PUBLIC
+ spinlock ${maybe_threads_lib} ${tcmalloc_lib_options})
+
+if(MINGW)
+ target_link_libraries(tcmalloc_minimal PUBLIC stacktrace)
+endif()
+
+if(BUILD_TESTING)
+ add_executable(tcmalloc_minimal_unittest
+ src/tests/tcmalloc_unittest.cc
+ src/tests/testutil.cc
+ src/tests/testutil.h)
+ target_link_libraries(tcmalloc_minimal_unittest PUBLIC tcmalloc_minimal)
+endif()
diff --git a/cmake/CheckNoFPByDefault.cmake b/cmake/CheckNoFPByDefault.cmake
new file mode 100644
index 0000000..0f32a47
--- /dev/null
+++ b/cmake/CheckNoFPByDefault.cmake
@@ -0,0 +1,41 @@
+function(check_omit_fp_by_default result)
+ set(src "${CMAKE_CURRENT_BINARY_DIR}/fp.c")
+ set(asm "${CMAKE_CURRENT_BINARY_DIR}/fp.s")
+ file(WRITE ${src}
+ "int f(int x) { return x; } int main() { return f(0); }")
+ execute_process(
+ COMMAND ${CMAKE_CXX_COMPILER} -O2 -S -o ${asm} ${src}
+ RESULT_VARIABLE compiled)
+ if(compiled EQUAL 0 AND EXISTS ${asm})
+ file(STRINGS ${asm} asm_instructions)
+ set(fp_instructions "mov" "rsp" "rbp")
+ foreach(asm_instruction IN LISTS asm_instructions)
+ list(GET fp_instructions 0 fp_instruction)
+ if(asm_instruction MATCHES "${fp_instruction}")
+ list(REMOVE_AT fp_instructions 0)
+ endif()
+
+ list(LENGTH fp_instructions len)
+ if(len EQUAL 0)
+ set(matched_all ON)
+ break()
+ endif()
+ endforeach()
+
+ file(REMOVE ${asm})
+ endif()
+
+ file(REMOVE ${src})
+
+ if(NOT matched_all)
+ set(${result} ON PARENT_SCOPE)
+ endif()
+
+ if(result)
+ set(fp_omitted "Success")
+ else()
+ set(fp_omitted "Failed")
+ endif()
+ message(
+ STATUS "Checking if frame pointers are omitted by default - ${fp_omitted}")
+endfunction()
diff --git a/cmake/DefineTargetVariables.cmake b/cmake/DefineTargetVariables.cmake
index cff175d..5b7c5da 100644
--- a/cmake/DefineTargetVariables.cmake
+++ b/cmake/DefineTargetVariables.cmake
@@ -1,13 +1,14 @@
if(NOT COMMAND check_cxx_source_compiles)
- include(CheckCXXSourceCompiles)
+ 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)
+ check_cxx_source_compiles("int main() { return __i386__; }" i386)
+ 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/FindObjcopyWithWeaken.cmake b/cmake/FindObjcopyWithWeaken.cmake
new file mode 100644
index 0000000..e5c3e16
--- /dev/null
+++ b/cmake/FindObjcopyWithWeaken.cmake
@@ -0,0 +1,34 @@
+function(find_objcopy_with_weaken result objcopy_path)
+ find_program(objcopy_exe "objcopy" PATHS ${objcopy_path})
+ if(objcopy_exe)
+ set(objcopy_found "found")
+ else()
+ set(objcopy_found "not found")
+ endif()
+ message(STATUS "Looking for objcopy that supports weaken - ${objcopy_found}")
+ if(objcopy_exe)
+ set(objcopy_test_src "${CMAKE_CURRENT_BINARY_DIR}/objcopy_test.c")
+ set(objcopy_test_exe "${CMAKE_CURRENT_BINARY_DIR}/objcopy_test")
+ file(WRITE ${objcopy_test_src} "void foo() {} int main() { return 0; }")
+ try_compile(objcopy_test_compiled
+ ${CMAKE_CURRENT_BINARY_DIR} ${objcopy_test_src}
+ COPY_FILE ${objcopy_test_exe})
+ if(objcopy_test_compiled AND EXISTS ${objcopy_test_exe})
+ execute_process(
+ COMMAND ${objcopy_exe} -W foo ${objcopy_test_exe}
+ RESULT_VARIABLE objcopy_result)
+ file(REMOVE ${objcopy_test_exe})
+ endif()
+ if(objcopy_result EQUAL 0)
+ set(objcopy_weaken ON)
+ endif()
+ file(REMOVE ${objcopy_test_src})
+ if(objcopy_weaken)
+ set(objcopy_has_weaken "Success")
+ set(${result} objcopy_exe PARENT_SCOPE)
+ else()
+ set(objcopy_has_weaken "Failed")
+ endif()
+ message(STATUS "objcopy has weaken support - ${objcopy_has_weaken}")
+ endif()
+endfunction(find_objcopy_with_weaken)
diff --git a/cmake/GPerftoolsAddTarget.cmake b/cmake/GPerftoolsAddTarget.cmake
new file mode 100644
index 0000000..988dd28
--- /dev/null
+++ b/cmake/GPerftoolsAddTarget.cmake
@@ -0,0 +1,14 @@
+function(gperftools_add_target target_name)
+ if(inc)
+ target_include_directories(${target_name} PUBLIC ${inc})
+ endif()
+ if(libs)
+ target_link_libraries(${target_name} PUBLIC ${libs})
+ endif()
+ if(defs)
+ target_compile_definitions(${target_name} PUBLIC ${defs})
+ endif()
+ if(options)
+ target_compile_options(${target_name} PUBLIC ${options})
+ endif()
+endfunction()
diff --git a/cmake/PCFromUContext.cmake b/cmake/PCFromUContext.cmake
index 1d4eb85..e2db2e3 100644
--- a/cmake/PCFromUContext.cmake
+++ b/cmake/PCFromUContext.cmake
@@ -3,7 +3,7 @@ include(CheckIncludeFile)
macro(pc_from_ucontext variable)
set(HAVE_${variable} OFF)
- check_include_file_cxx("ucontext.h" HAVE_UCONTEXT_H)
+ check_include_file("ucontext.h" HAVE_UCONTEXT_H)
if(EXISTS /etc/redhat-release)
set(redhat7_release_pattern "Red Hat Linux release 7")
file(STRINGS /etc/redhat-release redhat_release_match
@@ -12,12 +12,12 @@ macro(pc_from_ucontext variable)
if(redhat_release_match MATCHES ${redhat7_release_pattern})
set(HAVE_SYS_UCONTEXT_H OFF)
else()
- check_include_file_cxx("sys/ucontext.h" HAVE_SYS_UCONTEXT_H)
+ check_include_file("sys/ucontext.h" HAVE_SYS_UCONTEXT_H)
endif()
else()
- check_include_file_cxx("sys/ucontext.h" HAVE_SYS_UCONTEXT_H)
+ check_include_file("sys/ucontext.h" HAVE_SYS_UCONTEXT_H)
endif()
- check_include_file_cxx("cygwin/signal.h" HAVE_CYGWIN_SIGNAL_H)
+ check_include_file("cygwin/signal.h" HAVE_CYGWIN_SIGNAL_H)
set(pc_fields
"uc_mcontext.gregs[REG_PC]" # Solaris x86 (32 + 64 bit)
@@ -51,7 +51,7 @@ macro(pc_from_ucontext variable)
endif()
foreach(pc_field IN LISTS pc_fields)
string(MAKE_C_IDENTIFIER ${pc_field} pc_field_id)
- check_cxx_source_compiles(
+ check_c_source_compiles(
"#include <${_inc}>\nint main() { ucontext_t u; return u.${pc_field} == 0; }"
HAVE_${pc_field_id})
if(HAVE_${pc_field_id})
diff --git a/cmake/config.h.in b/cmake/config.h.in
index 6bf5a57..4007f02 100644
--- a/cmake/config.h.in
+++ b/cmake/config.h.in
@@ -115,10 +115,10 @@
#cmakedefine HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
-#cmakedefine HAVE_STRING_H 1
+#cmakedefine HAVE_STRING_H
/* Define to 1 if the system has the type `struct mallinfo'. */
-#cmakedefine HAVE_STRUCT_MALLINFO
+#cmakedefine01 HAVE_STRUCT_MALLINFO
/* Define to 1 if you have the <sys/cdefs.h> header file. */
#cmakedefine HAVE_SYS_CDEFS_H
@@ -156,6 +156,14 @@
/* Define to 1 if compiler supports __thread */
#cmakedefine HAVE_TLS
+#cmakedefine HAVE_DECL_SLEEP
+
+#cmakedefine HAVE_DECL_NANOSLEEP
+
+#cmakedefine HAVE_DECL_BACKTRACE
+
+#cmakedefine HAVE_UNWIND_BACKTRACE
+
/* Define to 1 if you have the <ucontext.h> header file. */
#cmakedefine HAVE_UCONTEXT_H
@@ -228,6 +236,11 @@
# define PERFTOOLS_DLL_DECL __declspec(dllexport)
# define PERFTOOLS_DLL_DECL_FOR_UNITTESTS __declspec(dllimport)
#endif
+#else
+#ifndef PERFTOOLS_DLL_DECL
+# define PERFTOOLS_DLL_DECL
+# define PERFTOOLS_DLL_DECL_FOR_UNITTESTS
+#endif
#endif
/* printf format code for printing a size_t and ssize_t */
@@ -251,7 +264,7 @@
#define STDC_HEADERS 1
/* the namespace where STL code like vector<> is defined */
-#cmakedefine STL_NAMESPACE std
+#define STL_NAMESPACE @STL_NAMESPACE@
/* Version number of package */
#define VERSION @PROJECT_VERSION@