Add compile-check around unw_set_cache_log_size.
authorMilian Wolff <mail@milianw.de>
Tue, 9 Dec 2014 10:18:08 +0000 (11:18 +0100)
committerMilian Wolff <mail@milianw.de>
Tue, 9 Dec 2014 10:18:08 +0000 (11:18 +0100)
CMakeLists.txt
libheaptrack.cpp

index 4eba06b..c28e8ce 100644 (file)
@@ -13,6 +13,8 @@ if (NOT HAVE_UNW_BACKTRACE)
     message(FATAL_ERROR "Your libunwind version is apparently too old and does not have the unw_backtrace function.")
 endif()
 
+check_library_exists (${LIBUNWIND_LIBRARY} _ULx86_64_set_cache_log_size "" HAVE_UNW_SET_CACHE_LOG_SIZE)
+
 include (CheckCXXSourceCompiles)
 check_cxx_source_compiles(
     "#include <unordered_map>
index 124e80b..ca3d0c5 100644 (file)
@@ -333,9 +333,11 @@ void heaptrack_init(const char *outputFileName, void (*initCallbackBefore) (), v
         if (unw_set_caching_policy(unw_local_addr_space, UNW_CACHE_PER_THREAD)) {
             fprintf(stderr, "Failed to enable per-thread libunwind caching.\n");
         }
+#if HAVE_UNW_SET_CACHE_LOG_SIZE
         if (unw_set_cache_log_size(unw_local_addr_space, 10)) {
             fprintf(stderr, "Failed to set libunwind cache size.\n");
         }
+#endif
 
         data.reset(new Data(outputFileName, stopCallback));