mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Preparation to build with Musl
This commit is contained in:
parent
d0a3420c3b
commit
41acc52458
@ -5,6 +5,10 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
#ifdef OS_LINUX
|
||||
/// We can detect if code is linked with one or another readline variants or open the library dynamically.
|
||||
|
@ -18,8 +18,10 @@
|
||||
* Define overrides for non-standard allocator-related functions if they are
|
||||
* present on the system.
|
||||
*/
|
||||
#if !defined(USE_MUSL)
|
||||
#define JEMALLOC_OVERRIDE_MEMALIGN
|
||||
#define JEMALLOC_OVERRIDE_VALLOC
|
||||
#endif
|
||||
|
||||
/*
|
||||
* At least Linux omits the "const" in:
|
||||
|
@ -1,6 +1,6 @@
|
||||
// OSX does not have this for system alloc functions, so you will get
|
||||
// "exception specification in declaration" error.
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__)
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(USE_MUSL)
|
||||
# undef JEMALLOC_NOTHROW
|
||||
# define JEMALLOC_NOTHROW
|
||||
|
||||
|
@ -13,12 +13,14 @@
|
||||
* Define overrides for non-standard allocator-related functions if they are
|
||||
* present on the system.
|
||||
*/
|
||||
#if !defined(USE_MUSL)
|
||||
#define JEMALLOC_OVERRIDE___LIBC_CALLOC
|
||||
#define JEMALLOC_OVERRIDE___LIBC_FREE
|
||||
#define JEMALLOC_OVERRIDE___LIBC_MALLOC
|
||||
#define JEMALLOC_OVERRIDE___LIBC_MEMALIGN
|
||||
#define JEMALLOC_OVERRIDE___LIBC_REALLOC
|
||||
#define JEMALLOC_OVERRIDE___LIBC_VALLOC
|
||||
#endif
|
||||
/* #undef JEMALLOC_OVERRIDE___POSIX_MEMALIGN */
|
||||
|
||||
/*
|
||||
|
@ -56,6 +56,10 @@ if (USE_UNWIND)
|
||||
target_compile_definitions(cxx PUBLIC -DSTD_EXCEPTION_HAS_STACK_TRACE=1)
|
||||
endif ()
|
||||
|
||||
if (USE_MUSL)
|
||||
target_compile_definitions(cxx PUBLIC -D_LIBCPP_HAS_MUSL_LIBC=1)
|
||||
endif ()
|
||||
|
||||
# Override the deduced attribute support that causes error.
|
||||
if (OS_DARWIN AND COMPILER_GCC)
|
||||
add_compile_definitions(_LIBCPP_INIT_PRIORITY_MAX)
|
||||
|
@ -98,7 +98,9 @@
|
||||
#define HAVE_BCOPY 1
|
||||
|
||||
/* Define to 1 if you have the <bits/types.h> header file. */
|
||||
#if !defined(USE_MUSL)
|
||||
#define HAVE_BITS_TYPES_H 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the `chroot' function. */
|
||||
#define HAVE_CHROOT 1
|
||||
|
@ -126,6 +126,8 @@ QueryProfilerBase<ProfilerImpl>::QueryProfilerBase(const UInt64 thread_id, const
|
||||
|
||||
#if defined(OS_FREEBSD)
|
||||
sev._sigev_un._threadid = thread_id;
|
||||
#elif defined(USE_MUSL)
|
||||
sev.sigev_notify_thread_id = thread_id;
|
||||
#else
|
||||
sev._sigev_un._tid = thread_id;
|
||||
#endif
|
||||
|
@ -17,7 +17,9 @@ extern "C"
|
||||
void *aligned_alloc(size_t alignment, size_t size);
|
||||
void *valloc(size_t size);
|
||||
void *memalign(size_t alignment, size_t size);
|
||||
#if !defined(USE_MUSL)
|
||||
void *pvalloc(size_t size);
|
||||
#endif
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
@ -39,6 +41,8 @@ static void dummyFunctionForInterposing()
|
||||
ignore(aligned_alloc(0, 0)); // -V575 NOLINT
|
||||
ignore(valloc(0)); // -V575 NOLINT
|
||||
ignore(memalign(0, 0)); // -V575 NOLINT
|
||||
#if !defined(USE_MUSL)
|
||||
ignore(pvalloc(0)); // -V575 NOLINT
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
@ -7,17 +7,6 @@
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
|
||||
#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined (__ANDROID__)
|
||||
# include <sys/endian.h>
|
||||
#elif defined(__sun)
|
||||
# include <endian.h>
|
||||
#elif defined(__APPLE__)
|
||||
# include <libkern/OSByteOrder.h>
|
||||
|
||||
# define htobe64(x) OSSwapHostToBigInt64(x)
|
||||
# define be64toh(x) OSSwapBigToHostInt64(x)
|
||||
#endif
|
||||
|
||||
|
||||
namespace DB
|
||||
{
|
||||
@ -152,7 +141,7 @@ private:
|
||||
memcpy(&tmp_buffer, source_current, bytes_to_read);
|
||||
source_current += bytes_to_read;
|
||||
|
||||
tmp_buffer = be64toh(tmp_buffer);
|
||||
tmp_buffer = __builtin_bswap64(tmp_buffer);
|
||||
|
||||
bits_buffer |= BufferType(tmp_buffer) << ((sizeof(BufferType) - sizeof(tmp_buffer)) * 8 - bits_count);
|
||||
bits_count += static_cast<UInt8>(bytes_to_read) * 8;
|
||||
@ -212,7 +201,7 @@ public:
|
||||
// flush contents of bits_buffer to the dest_current, partial bytes are completed with zeroes.
|
||||
inline void flush()
|
||||
{
|
||||
bits_count = (bits_count + 8 - 1) & ~(8 - 1); // align UP to 8-bytes, so doFlush will write ALL data from bits_buffer
|
||||
bits_count = (bits_count + 8 - 1) & ~(8 - 1); // align up to 8-bytes, so doFlush will write all data from bits_buffer
|
||||
while (bits_count != 0)
|
||||
doFlush();
|
||||
}
|
||||
@ -231,13 +220,12 @@ private:
|
||||
|
||||
if (available < to_write)
|
||||
{
|
||||
throw Exception("Can not write past end of buffer. Space available "
|
||||
+ std::to_string(available) + " bytes, required to write: "
|
||||
+ std::to_string(to_write) + ".",
|
||||
ErrorCodes::CANNOT_WRITE_AFTER_END_OF_BUFFER);
|
||||
throw Exception(ErrorCodes::CANNOT_WRITE_AFTER_END_OF_BUFFER,
|
||||
"Can not write past end of buffer. Space available {} bytes, required to write {} bytes.",
|
||||
available, to_write);
|
||||
}
|
||||
|
||||
const auto tmp_buffer = htobe64(static_cast<UInt64>(bits_buffer >> (sizeof(bits_buffer) - sizeof(UInt64)) * 8));
|
||||
const auto tmp_buffer = __builtin_bswap64(static_cast<UInt64>(bits_buffer >> (sizeof(bits_buffer) - sizeof(UInt64)) * 8));
|
||||
memcpy(dest_current, &tmp_buffer, to_write);
|
||||
dest_current += to_write;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user