build fixes

This commit is contained in:
chertus 2019-07-12 17:41:59 +03:00
parent 9739ac13e4
commit 9bd42366f0
4 changed files with 25 additions and 24 deletions

View File

@ -90,6 +90,12 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_definitions ("-fno-tree-loop-distribute-patterns")
endif ()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Enable C++14 sized global deallocation functions. It should be anabled by setting -std=c++14
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsized-deallocation")
endif ()
add_subdirectory (src)
set(dbms_headers)

View File

@ -36,7 +36,14 @@ void * operator new[](std::size_t size, const std::nothrow_t &) noexcept
/// delete
#if 0
/// C++17 std 21.6.2.1 (11)
/// If a function without a size parameter is defined, the program should also define the corresponding function with a size parameter.
/// If a function with a size parameter is defined, the program shall also define the corresponding version without the size parameter.
/// cppreference:
/// It's unspecified whether size-aware or size-unaware version is called when deleting objects of
/// incomplete type and arrays of non-class and trivially-destructible class types.
void operator delete(void * ptr) noexcept
{
Memory::deleteImpl(ptr);
@ -47,18 +54,6 @@ void operator delete[](void * ptr) noexcept
Memory::deleteImpl(ptr);
}
void operator delete(void * ptr, const std::nothrow_t &) noexcept
{
Memory::deleteImpl(ptr);
}
void operator delete[](void * ptr, const std::nothrow_t &) noexcept
{
Memory::deleteImpl(ptr);
}
#endif
void operator delete(void * ptr, std::size_t size) noexcept
{
CurrentMemoryTracker::free(size);

View File

@ -14,7 +14,7 @@
#define ALWAYS_INLINE __forceinline
#define NO_INLINE static __declspec(noinline)
#else
#define ALWAYS_INLINE __attribute__((__always_inline__))
#define ALWAYS_INLINE inline __attribute__((__always_inline__))
#define NO_INLINE __attribute__((__noinline__))
#endif
@ -23,7 +23,7 @@ namespace JeMalloc
void * handleOOM(std::size_t size, bool nothrow);
ALWAYS_INLINE inline void * newImpl(std::size_t size)
ALWAYS_INLINE void * newImpl(std::size_t size)
{
void * ptr = je_malloc(size);
if (likely(ptr != nullptr))
@ -32,7 +32,7 @@ ALWAYS_INLINE inline void * newImpl(std::size_t size)
return handleOOM(size, false);
}
ALWAYS_INLINE inline void * newNoExept(std::size_t size) noexcept
ALWAYS_INLINE void * newNoExept(std::size_t size) noexcept
{
void * ptr = je_malloc(size);
if (likely(ptr != nullptr))
@ -41,12 +41,12 @@ ALWAYS_INLINE inline void * newNoExept(std::size_t size) noexcept
return handleOOM(size, true);
}
ALWAYS_INLINE inline void deleteImpl(void * ptr) noexcept
ALWAYS_INLINE void deleteImpl(void * ptr) noexcept
{
je_free(ptr);
}
ALWAYS_INLINE inline void deleteSized(void * ptr, std::size_t size) noexcept
ALWAYS_INLINE void deleteSized(void * ptr, std::size_t size) noexcept
{
if (unlikely(ptr == nullptr))
return;
@ -66,27 +66,27 @@ namespace Memory
namespace Memory
{
ALWAYS_INLINE inline void * newImpl(std::size_t size)
ALWAYS_INLINE void * newImpl(std::size_t size)
{
auto * ptr = malloc(size);
if (likely(ptr != nullptr))
return ptr;
/// @note no std::get_new_handler logic implemented
std::__throw_bad_alloc();
throw std::bad_alloc{};
}
ALWAYS_INLINE inline void * newNoExept(std::size_t size) noexcept
ALWAYS_INLINE void * newNoExept(std::size_t size) noexcept
{
return malloc(size);
}
ALWAYS_INLINE inline void deleteImpl(void * ptr) noexcept
ALWAYS_INLINE void deleteImpl(void * ptr) noexcept
{
free(ptr);
}
ALWAYS_INLINE inline void deleteSized(void * ptr, std::size_t size) noexcept
ALWAYS_INLINE void deleteSized(void * ptr, std::size_t size) noexcept
{
free(ptr);
}

View File

@ -28,7 +28,7 @@ void * handleOOM(std::size_t size, bool nothrow)
}
if (ptr == nullptr && !nothrow)
std::__throw_bad_alloc();
throw std::bad_alloc{};
return ptr;
}