mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
d09c5c871b
* Fix build * cmake: fix cpuinfo * Fix includes after processors merge Conflicts: dbms/src/Processors/Formats/Impl/CapnProtoRowInputFormat.cpp dbms/src/Processors/Formats/Impl/ParquetBlockOutputFormat.cpp dbms/src/Processors/Formats/Impl/ProtobufRowInputFormat.cpp dbms/src/Processors/Formats/Impl/ProtobufRowOutputFormat.cpp * Fix build in gcc8 * fix test link * fix test link * Fix test link * link fix * Fix includes after processors merge 2 Conflicts: dbms/src/Processors/Formats/Impl/ParquetBlockInputFormat.cpp * Fix includes after processors merge 3 * link fix * Fix likely/unlikely conflict with cython * Fix conflict with protobuf/stubs/atomicops.h * remove unlikely.h * Fix macos build (do not use timer_t)
82 lines
1.4 KiB
C++
82 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <new>
|
|
#include "likely.h"
|
|
|
|
#if __has_include(<common/config_common.h>)
|
|
#include <common/config_common.h>
|
|
#endif
|
|
|
|
#if USE_JEMALLOC
|
|
#include <jemalloc/jemalloc.h>
|
|
|
|
#if JEMALLOC_VERSION_MAJOR < 4
|
|
#undef USE_JEMALLOC
|
|
#define USE_JEMALLOC 0
|
|
#include <cstdlib>
|
|
#endif
|
|
#else
|
|
#include <cstdlib>
|
|
#endif
|
|
|
|
// Also defined in Core/Defines.h
|
|
#if !defined(ALWAYS_INLINE)
|
|
#if defined(_MSC_VER)
|
|
#define ALWAYS_INLINE inline __forceinline
|
|
#else
|
|
#define ALWAYS_INLINE inline __attribute__((__always_inline__))
|
|
#endif
|
|
#endif
|
|
|
|
#if !defined(NO_INLINE)
|
|
#if defined(_MSC_VER)
|
|
#define NO_INLINE static __declspec(noinline)
|
|
#else
|
|
#define NO_INLINE __attribute__((__noinline__))
|
|
#endif
|
|
#endif
|
|
|
|
namespace Memory
|
|
{
|
|
|
|
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
|
|
throw std::bad_alloc{};
|
|
}
|
|
|
|
ALWAYS_INLINE void * newNoExept(std::size_t size) noexcept
|
|
{
|
|
return malloc(size);
|
|
}
|
|
|
|
ALWAYS_INLINE void deleteImpl(void * ptr) noexcept
|
|
{
|
|
free(ptr);
|
|
}
|
|
|
|
#if USE_JEMALLOC
|
|
|
|
ALWAYS_INLINE void deleteSized(void * ptr, std::size_t size) noexcept
|
|
{
|
|
if (unlikely(ptr == nullptr))
|
|
return;
|
|
|
|
sdallocx(ptr, size, 0);
|
|
}
|
|
|
|
#else
|
|
|
|
ALWAYS_INLINE void deleteSized(void * ptr, std::size_t size [[maybe_unused]]) noexcept
|
|
{
|
|
free(ptr);
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|