fix redef
This commit is contained in:
parent
1b3f711b7c
commit
051117ac08
@ -864,6 +864,7 @@ if(GPERFTOOLS_BUILD_HEAP_CHECKER OR GPERFTOOLS_BUILD_HEAP_PROFILER)
|
|||||||
add_library(tcmalloc_internal INTERFACE)
|
add_library(tcmalloc_internal INTERFACE)
|
||||||
target_sources(tcmalloc_internal INTERFACE $<TARGET_OBJECTS:tcmalloc_internal_object>)
|
target_sources(tcmalloc_internal INTERFACE $<TARGET_OBJECTS:tcmalloc_internal_object>)
|
||||||
target_link_libraries(tcmalloc_internal INTERFACE ${libtcmalloc_internal_la_LIBADD})
|
target_link_libraries(tcmalloc_internal INTERFACE ${libtcmalloc_internal_la_LIBADD})
|
||||||
|
target_include_directories(tcmalloc_internal INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||||
|
|
||||||
add_library(tcmalloc SHARED ${libtcmalloc_la_SOURCES})
|
add_library(tcmalloc SHARED ${libtcmalloc_la_SOURCES})
|
||||||
target_compile_definitions(tcmalloc PRIVATE ${libtcmalloc_la_DEFINE})
|
target_compile_definitions(tcmalloc PRIVATE ${libtcmalloc_la_DEFINE})
|
||||||
@ -939,6 +940,7 @@ if(GPERFTOOLS_BUILD_CPU_PROFILER)
|
|||||||
add_library(profiler SHARED ${libprofiler_la_SOURCES})
|
add_library(profiler SHARED ${libprofiler_la_SOURCES})
|
||||||
target_link_libraries(profiler PRIVATE ${libprofiler_la_LIBADD})
|
target_link_libraries(profiler PRIVATE ${libprofiler_la_LIBADD})
|
||||||
target_link_libraries(profiler PRIVATE Threads::Threads)
|
target_link_libraries(profiler PRIVATE Threads::Threads)
|
||||||
|
target_include_directories(profiler INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||||
set_target_properties(profiler PROPERTIES
|
set_target_properties(profiler PROPERTIES
|
||||||
VERSION ${PROFILER_SO_VERSION}
|
VERSION ${PROFILER_SO_VERSION}
|
||||||
SOVERSION ${PROFILER_SO_VERSION})
|
SOVERSION ${PROFILER_SO_VERSION})
|
||||||
@ -946,6 +948,7 @@ if(GPERFTOOLS_BUILD_CPU_PROFILER)
|
|||||||
if(GPERFTOOLS_BUILD_STATIC)
|
if(GPERFTOOLS_BUILD_STATIC)
|
||||||
add_library(profiler_static STATIC ${libprofiler_la_SOURCES})
|
add_library(profiler_static STATIC ${libprofiler_la_SOURCES})
|
||||||
target_link_libraries(profiler_static PRIVATE ${libprofiler_la_LIBADD})
|
target_link_libraries(profiler_static PRIVATE ${libprofiler_la_LIBADD})
|
||||||
|
target_include_directories(profiler_static INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
set_target_properties(profiler_static PROPERTIES OUTPUT_NAME profiler)
|
set_target_properties(profiler_static PROPERTIES OUTPUT_NAME profiler)
|
||||||
endif()
|
endif()
|
||||||
@ -987,6 +990,7 @@ if(GPERFTOOLS_BUILD_HEAP_PROFILER OR GPERFTOOLS_BUILD_HEAP_CHECKER)
|
|||||||
add_library(tcmalloc_and_profiler_static STATIC ${libtcmalloc_la_SOURCES} ${libprofiler_la_SOURCES})
|
add_library(tcmalloc_and_profiler_static STATIC ${libtcmalloc_la_SOURCES} ${libprofiler_la_SOURCES})
|
||||||
target_compile_definitions(tcmalloc_and_profiler_static PRIVATE ${libtcmalloc_la_DEFINE})
|
target_compile_definitions(tcmalloc_and_profiler_static PRIVATE ${libtcmalloc_la_DEFINE})
|
||||||
target_link_libraries(tcmalloc_and_profiler_static PRIVATE ${libtcmalloc_la_LIBADD})
|
target_link_libraries(tcmalloc_and_profiler_static PRIVATE ${libtcmalloc_la_LIBADD})
|
||||||
|
target_include_directories(tcmalloc_and_profiler_static INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
set_target_properties(tcmalloc_and_profiler_static PROPERTIES
|
set_target_properties(tcmalloc_and_profiler_static PROPERTIES
|
||||||
OUTPUT_NAME tcmalloc_and_profiler)
|
OUTPUT_NAME tcmalloc_and_profiler)
|
||||||
|
@ -16,7 +16,7 @@ set(BUILD_EXAMPLES OFF)
|
|||||||
add_library(sled STATIC "")
|
add_library(sled STATIC "")
|
||||||
|
|
||||||
add_subdirectory(3party/gperftools EXCLUDE_FROM_ALL)
|
add_subdirectory(3party/gperftools EXCLUDE_FROM_ALL)
|
||||||
add_subdirectory(3party/cppuprofile EXCLUDE_FROM_ALL)
|
# add_subdirectory(3party/cppuprofile EXCLUDE_FROM_ALL)
|
||||||
add_subdirectory(3party/protobuf-3.21.12 EXCLUDE_FROM_ALL)
|
add_subdirectory(3party/protobuf-3.21.12 EXCLUDE_FROM_ALL)
|
||||||
if (NOT TARGET marl)
|
if (NOT TARGET marl)
|
||||||
add_subdirectory(3party/marl EXCLUDE_FROM_ALL)
|
add_subdirectory(3party/marl EXCLUDE_FROM_ALL)
|
||||||
@ -72,11 +72,24 @@ target_sources(
|
|||||||
# set(BUILD_RTTR_DYNAMIC OFF) set(BUILD_UNIT_TESTS OFF)
|
# set(BUILD_RTTR_DYNAMIC OFF) set(BUILD_UNIT_TESTS OFF)
|
||||||
# set(BUILD_WITH_STATIC_RUNTIME_LIBS ON) set(BUILD_WITH_DOCUMENTATION OFF)
|
# set(BUILD_WITH_STATIC_RUNTIME_LIBS ON) set(BUILD_WITH_DOCUMENTATION OFF)
|
||||||
# add_subdirectory(3party/rttr EXCLUDE_FROM_ALL)
|
# add_subdirectory(3party/rttr EXCLUDE_FROM_ALL)
|
||||||
|
include(CheckCCompilerFlag)
|
||||||
|
check_c_compiler_flag("-Wl,--whole-archive" SUPPORT_COMPILE_WHOLE_ARCHIVE)
|
||||||
|
if (SUPPORT_COMPILE_WHOLE_ARCHIVE)
|
||||||
|
set(WHOLE_ARCHIVE_WRAPPER_START "-Wl,--whole-archive")
|
||||||
|
set(WHOLE_ARCHIVE_WRAPPER_END "-Wl,--no-whole-archive")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
target_link_libraries(sled
|
target_link_libraries(sled
|
||||||
PUBLIC rpc_core fmt marl protobuf::libprotobuf cppuprofile tcmalloc_and_profiler_static
|
PUBLIC rpc_core fmt marl protobuf::libprotobuf # cppuprofile
|
||||||
|
# ${WHOLE_ARCHIVE_WRAPPER_START}
|
||||||
|
tcmalloc_and_profiler_static
|
||||||
|
# ${WHOLE_ARCHIVE_WRAPPER_END}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
## set fPIC
|
||||||
|
set_target_properties(sled PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|
||||||
if(SLED_BUILD_BENCHMARK)
|
if(SLED_BUILD_BENCHMARK)
|
||||||
if (NOT TARGET benchmark)
|
if (NOT TARGET benchmark)
|
||||||
find_package(benchmark REQUIRED)
|
find_package(benchmark REQUIRED)
|
||||||
|
@ -2,7 +2,10 @@
|
|||||||
#ifndef SLED_LANG_ATTRIBUTES_H
|
#ifndef SLED_LANG_ATTRIBUTES_H
|
||||||
#define SLED_LANG_ATTRIBUTES_H
|
#define SLED_LANG_ATTRIBUTES_H
|
||||||
|
|
||||||
|
#include <marl/tsa.h>
|
||||||
|
|
||||||
#define SLED_DEPRECATED() __attribute__((deprecated))
|
#define SLED_DEPRECATED() __attribute__((deprecated))
|
||||||
|
#ifndef THREAD_ANNOTATION_ATTRIBUTE__
|
||||||
#if defined(__GNUC__) && defined(__SUPPORT_TS_ANNOTATION__) && !defined(SWIG)
|
#if defined(__GNUC__) && defined(__SUPPORT_TS_ANNOTATION__) && !defined(SWIG)
|
||||||
#define THREAD_ANNOTATION_ATTRIBUTE__(x)
|
#define THREAD_ANNOTATION_ATTRIBUTE__(x)
|
||||||
#elif defined(__clang__)
|
#elif defined(__clang__)
|
||||||
@ -10,12 +13,11 @@
|
|||||||
#else
|
#else
|
||||||
#define THREAD_ANNOTATION_ATTRIBUTE__(x)
|
#define THREAD_ANNOTATION_ATTRIBUTE__(x)
|
||||||
#endif
|
#endif
|
||||||
|
#endif// THREAD_ANNOTATION_ATTRIBUTE__
|
||||||
|
|
||||||
#if defined(GUARDED_BY)
|
#ifndef GUARDED_BY
|
||||||
#undef GUARDED_BY
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x))
|
#define GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x))
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
#define EXCLUSIVE_TRYLOCK_FUNCTION(...) THREAD_ANNOTATION_ATTRIBUTE__(exclusive_trylock_function(__VA_ARGS__))
|
#define EXCLUSIVE_TRYLOCK_FUNCTION(...) THREAD_ANNOTATION_ATTRIBUTE__(exclusive_trylock_function(__VA_ARGS__))
|
||||||
@ -24,14 +26,14 @@
|
|||||||
|
|
||||||
#define UNLOCK_FUNCTION(...) THREAD_ANNOTATION_ATTRIBUTE__(unlock_function(__VA_ARGS__))
|
#define UNLOCK_FUNCTION(...) THREAD_ANNOTATION_ATTRIBUTE__(unlock_function(__VA_ARGS__))
|
||||||
|
|
||||||
#define PT_GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x))
|
// #define PT_GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x))
|
||||||
|
|
||||||
#else// defined(__clang__)
|
#else// defined(__clang__)
|
||||||
|
|
||||||
#define EXCLUSIVE_TRYLOCK_FUNCTION(...) THREAD_ANNOTATION_ATTRIBUTE__(exclusive_trylock(__VA_ARGS__))
|
#define EXCLUSIVE_TRYLOCK_FUNCTION(...) THREAD_ANNOTATION_ATTRIBUTE__(exclusive_trylock(__VA_ARGS__))
|
||||||
#define EXCLUSIVE_LOCK_FUNCTION(...) THREAD_ANNOTATION_ATTRIBUTE__(exclusive_lock(__VA_ARGS__))
|
#define EXCLUSIVE_LOCK_FUNCTION(...) THREAD_ANNOTATION_ATTRIBUTE__(exclusive_lock(__VA_ARGS__))
|
||||||
#define UNLOCK_FUNCTION(...) THREAD_ANNOTATION_ATTRIBUTE__(unlock(__VA_ARGS__))
|
#define UNLOCK_FUNCTION(...) THREAD_ANNOTATION_ATTRIBUTE__(unlock(__VA_ARGS__))
|
||||||
#define PT_GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(point_to_guarded_by(x))
|
// #define PT_GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(point_to_guarded_by(x))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif// SLED_LANG_ATTRIBUTES_H
|
#endif// SLED_LANG_ATTRIBUTES_H
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
/**
|
|
||||||
* @file : {{FILE}}
|
|
||||||
* @created : {{TIMESTAMP}}
|
|
||||||
* @license : {{LICENSE}}
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef{{MACRO_GUARD } }
|
|
||||||
#define{{MACRO_GUARD } }
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
{
|
|
||||||
CURSOR
|
|
||||||
}
|
|
||||||
}// namespace
|
|
||||||
|
|
||||||
{
|
|
||||||
|
|
||||||
class {
|
|
||||||
{
|
|
||||||
CAMEL_CLASS
|
|
||||||
}
|
|
||||||
} {
|
|
||||||
public:
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}// namespace
|
|
||||||
|
|
||||||
#endif// {{MACRO_GUARD}}
|
|
@ -1,5 +1,6 @@
|
|||||||
#include "sled/profiling/profiling.h"
|
#include "sled/profiling/profiling.h"
|
||||||
#include <uprofile.h>
|
|
||||||
|
// #include <uprofile.h>
|
||||||
|
|
||||||
namespace sled {
|
namespace sled {
|
||||||
Profiling *
|
Profiling *
|
||||||
@ -12,7 +13,7 @@ Profiling::Instance()
|
|||||||
bool
|
bool
|
||||||
Profiling::Start(const std::string &file)
|
Profiling::Start(const std::string &file)
|
||||||
{
|
{
|
||||||
uprofile::start(file.c_str());
|
// uprofile::start(file.c_str());
|
||||||
started_ = true;
|
started_ = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -20,53 +21,53 @@ Profiling::Start(const std::string &file)
|
|||||||
void
|
void
|
||||||
Profiling::Stop()
|
Profiling::Stop()
|
||||||
{
|
{
|
||||||
uprofile::stop();
|
// uprofile::stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Profiling::TimeBegin(const std::string &name)
|
Profiling::TimeBegin(const std::string &name)
|
||||||
{
|
{
|
||||||
if (!started_) return;
|
if (!started_) return;
|
||||||
uprofile::timeBegin(name);
|
// uprofile::timeBegin(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Profiling::TimeEnd(const std::string &name)
|
Profiling::TimeEnd(const std::string &name)
|
||||||
{
|
{
|
||||||
if (!started_) return;
|
if (!started_) return;
|
||||||
uprofile::timeEnd(name);
|
// uprofile::timeEnd(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Profiling::StartProcessMemoryMonitoring(int period_ms)
|
Profiling::StartProcessMemoryMonitoring(int period_ms)
|
||||||
{
|
{
|
||||||
if (!started_) return;
|
if (!started_) return;
|
||||||
uprofile::startProcessMemoryMonitoring(period_ms);
|
// uprofile::startProcessMemoryMonitoring(period_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Profiling::StartSystemMemoryMonitoring(int period_ms)
|
Profiling::StartSystemMemoryMonitoring(int period_ms)
|
||||||
{
|
{
|
||||||
if (!started_) return;
|
if (!started_) return;
|
||||||
uprofile::startSystemMemoryMonitoring(period_ms);
|
// uprofile::startSystemMemoryMonitoring(period_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Profiling::StartCPUUsageMonitoring(int period_ms)
|
Profiling::StartCPUUsageMonitoring(int period_ms)
|
||||||
{
|
{
|
||||||
if (!started_) return;
|
if (!started_) return;
|
||||||
uprofile::startCPUUsageMonitoring(period_ms);
|
// uprofile::startCPUUsageMonitoring(period_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Profiling::GetSystemMemory(int &total_mem, int &available_mem, int &free_mem)
|
Profiling::GetSystemMemory(int &total_mem, int &available_mem, int &free_mem)
|
||||||
{
|
{
|
||||||
uprofile::getSystemMemory(total_mem, available_mem, free_mem);
|
// uprofile::getSystemMemory(total_mem, available_mem, free_mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Profiling::GetProcessMemory(int &rss, int &shared)
|
Profiling::GetProcessMemory(int &rss, int &shared)
|
||||||
{
|
{
|
||||||
uprofile::getProcessMemory(rss, shared);
|
// uprofile::getProcessMemory(rss, shared);
|
||||||
}
|
}
|
||||||
}// namespace sled
|
}// namespace sled
|
||||||
|
Loading…
x
Reference in New Issue
Block a user