Skip to content

Commit

Permalink
Merge branch 'cvet:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
djempuiw authored Jun 7, 2024
2 parents e4b9c31 + 3c0bc86 commit 9875446
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
5 changes: 2 additions & 3 deletions BuildTools/FinalizeGeneration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ if(WIN32 OR LINUX OR APPLE OR ANDROID)
include_directories("${FO_RPMALLOC_DIR}/rpmalloc")
add_library(rpmalloc ${FO_RPMALLOC_SOURCE})
add_compile_definitions(FO_HAVE_RPMALLOC=1)
add_compile_definitions(ENABLE_PRELOAD=1)
add_compile_definitions(ENABLE_PRELOAD=${expr_StandaloneRpmallocEnabled})
target_compile_definitions(rpmalloc PRIVATE "$<$<PLATFORM_ID:Linux>:_GNU_SOURCE>")
list(APPEND FO_COMMON_LIBS "rpmalloc")
DisableLibWarnings(rpmalloc)
Expand Down Expand Up @@ -128,10 +128,9 @@ DisableLibWarnings(SDL2main SDL2-static)
# Tracy profiler
StatusMessage("+ Tracy")
set(FO_TRACY_DIR "${FO_ENGINE_ROOT}/ThirdParty/tracy")
set(expr_TracyEnabled $<OR:$<CONFIG:Profiling>,$<CONFIG:Debug_Profiling>,$<CONFIG:Profiling_OnDemand>>)
add_compile_definitions($<${expr_TracyEnabled}:TRACY_ENABLE>)
add_compile_definitions($<$<CONFIG:Profiling_OnDemand>:TRACY_ON_DEMAND>)
add_compile_definitions(FO_TRACY=$<BOOL:${expr_TracyEnabled}>)
add_compile_definitions(FO_TRACY=${expr_TracyEnabled})
set(TRACY_STATIC ON CACHE BOOL "Forced by FOnline" FORCE)
add_subdirectory("${FO_TRACY_DIR}")
include_directories("${FO_TRACY_DIR}/public")
Expand Down
2 changes: 2 additions & 0 deletions BuildTools/StartGeneration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ add_compile_definitions($<$<CONFIG:San_Address_Undefined>:LLVM_USE_SANITIZER=Add
set(expr_FullOptimization $<OR:$<CONFIG:Release>,$<CONFIG:Release_Ext>,$<CONFIG:MinSizeRel>>)
set(expr_DebugInfo $<NOT:$<OR:$<CONFIG:Release>,$<CONFIG:Release_Ext>,$<CONFIG:MinSizeRel>>>)
set(expr_PrefixConfig $<NOT:$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>,$<CONFIG:MinSizeRel>>>)
set(expr_TracyEnabled $<OR:$<CONFIG:Profiling>,$<CONFIG:Debug_Profiling>,$<CONFIG:Profiling_OnDemand>>)
set(expr_StandaloneRpmallocEnabled $<NOT:${expr_TracyEnabled}>)

# Headless configuration (without video/audio/input)
if(FO_BUILD_CLIENT OR FO_BUILD_SERVER OR FO_BUILD_SINGLE OR FO_BUILD_EDITOR OR FO_BUILD_MAPPER)
Expand Down
41 changes: 24 additions & 17 deletions Source/Common/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ auto IsRunInDebugger() noexcept -> bool

auto BreakIntoDebugger([[maybe_unused]] string_view error_message) noexcept -> bool
{
STACK_TRACE_ENTRY();
NO_STACK_TRACE_ENTRY();

if (IsRunInDebugger()) {
#if FO_WINDOWS
Expand Down Expand Up @@ -748,7 +748,13 @@ void emscripten_sleep(unsigned int ms)
// Replace memory allocator
#if FO_HAVE_RPMALLOC

#if FO_TRACY
#include "client/tracy_rpmalloc.hpp"
#define RPMNS tracy
#else
#include "rpmalloc.h"
#define RPMNS
#endif

#include <new>

Expand All @@ -763,20 +769,20 @@ extern void CRTDECL operator delete(void* p) noexcept
#if FO_TRACY
TracyFree(p);
#endif
rpfree(p);
RPMNS::rpfree(p);
}

extern void CRTDECL operator delete[](void* p) noexcept
{
#if FO_TRACY
TracyFree(p);
#endif
rpfree(p);
RPMNS::rpfree(p);
}

extern void* CRTDECL operator new(std::size_t size) noexcept(false)
{
auto* p = rpmalloc(size);
auto* p = RPMNS::rpmalloc(size);
#if FO_TRACY
TracyAlloc(p, size);
#endif
Expand All @@ -785,7 +791,7 @@ extern void* CRTDECL operator new(std::size_t size) noexcept(false)

extern void* CRTDECL operator new[](std::size_t size) noexcept(false)
{
auto* p = rpmalloc(size);
auto* p = RPMNS::rpmalloc(size);
#if FO_TRACY
TracyAlloc(p, size);
#endif
Expand All @@ -795,7 +801,7 @@ extern void* CRTDECL operator new[](std::size_t size) noexcept(false)
extern void* CRTDECL operator new(std::size_t size, const std::nothrow_t& tag) noexcept
{
UNUSED_VARIABLE(tag);
auto* p = rpmalloc(size);
auto* p = RPMNS::rpmalloc(size);
#if FO_TRACY
TracyAlloc(p, size);
#endif
Expand All @@ -805,7 +811,7 @@ extern void* CRTDECL operator new(std::size_t size, const std::nothrow_t& tag) n
extern void* CRTDECL operator new[](std::size_t size, const std::nothrow_t& tag) noexcept
{
UNUSED_VARIABLE(tag);
auto* p = rpmalloc(size);
auto* p = RPMNS::rpmalloc(size);
#if FO_TRACY
TracyAlloc(p, size);
#endif
Expand All @@ -819,7 +825,7 @@ extern void CRTDECL operator delete(void* p, std::size_t size) noexcept
#if FO_TRACY
TracyFree(p);
#endif
rpfree(p);
RPMNS::rpfree(p);
}

extern void CRTDECL operator delete[](void* p, std::size_t size) noexcept
Expand All @@ -828,7 +834,7 @@ extern void CRTDECL operator delete[](void* p, std::size_t size) noexcept
#if FO_TRACY
TracyFree(p);
#endif
rpfree(p);
RPMNS::rpfree(p);
}
#endif

Expand All @@ -839,7 +845,7 @@ extern void CRTDECL operator delete(void* p, std::align_val_t align) noexcept
#if FO_TRACY
TracyFree(p);
#endif
rpfree(p);
RPMNS::rpfree(p);
}

extern void CRTDECL operator delete[](void* p, std::align_val_t align) noexcept
Expand All @@ -848,7 +854,7 @@ extern void CRTDECL operator delete[](void* p, std::align_val_t align) noexcept
#if FO_TRACY
TracyFree(p);
#endif
rpfree(p);
RPMNS::rpfree(p);
}

extern void CRTDECL operator delete(void* p, std::size_t size, std::align_val_t align) noexcept
Expand All @@ -858,7 +864,7 @@ extern void CRTDECL operator delete(void* p, std::size_t size, std::align_val_t
#if FO_TRACY
TracyFree(p);
#endif
rpfree(p);
RPMNS::rpfree(p);
}

extern void CRTDECL operator delete[](void* p, std::size_t size, std::align_val_t align) noexcept
Expand All @@ -868,12 +874,12 @@ extern void CRTDECL operator delete[](void* p, std::size_t size, std::align_val_
#if FO_TRACY
TracyFree(p);
#endif
rpfree(p);
RPMNS::rpfree(p);
}

extern void* CRTDECL operator new(std::size_t size, std::align_val_t align) noexcept(false)
{
auto* p = rpaligned_alloc(static_cast<size_t>(align), size);
auto* p = RPMNS::rpaligned_alloc(static_cast<size_t>(align), size);
#if FO_TRACY
TracyAlloc(p, size);
#endif
Expand All @@ -882,7 +888,7 @@ extern void* CRTDECL operator new(std::size_t size, std::align_val_t align) noex

extern void* CRTDECL operator new[](std::size_t size, std::align_val_t align) noexcept(false)
{
auto* p = rpaligned_alloc(static_cast<size_t>(align), size);
auto* p = RPMNS::rpaligned_alloc(static_cast<size_t>(align), size);
#if FO_TRACY
TracyAlloc(p, size);
#endif
Expand All @@ -892,7 +898,7 @@ extern void* CRTDECL operator new[](std::size_t size, std::align_val_t align) no
extern void* CRTDECL operator new(std::size_t size, std::align_val_t align, const std::nothrow_t& tag) noexcept
{
UNUSED_VARIABLE(tag);
auto* p = rpaligned_alloc(static_cast<size_t>(align), size);
auto* p = RPMNS::rpaligned_alloc(static_cast<size_t>(align), size);
#if FO_TRACY
TracyAlloc(p, size);
#endif
Expand All @@ -902,7 +908,7 @@ extern void* CRTDECL operator new(std::size_t size, std::align_val_t align, cons
extern void* CRTDECL operator new[](std::size_t size, std::align_val_t align, const std::nothrow_t& tag) noexcept
{
UNUSED_VARIABLE(tag);
auto* p = rpaligned_alloc(static_cast<size_t>(align), size);
auto* p = RPMNS::rpaligned_alloc(static_cast<size_t>(align), size);
#if FO_TRACY
TracyAlloc(p, size);
#endif
Expand All @@ -911,5 +917,6 @@ extern void* CRTDECL operator new[](std::size_t size, std::align_val_t align, co
#endif

#undef CRTDECL
#undef RPMNS

#endif

0 comments on commit 9875446

Please sign in to comment.