Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion libcxx/include/__config
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@
#ifndef _LIBCPP___CONFIG
#define _LIBCPP___CONFIG

#include <__config_site>
/*
* ClickHouse specific options.
* Unstable ABI to provide better performance
* Availability annotations are not supported.
* _LIBCPP_ABI_NAMESPACE to preserve namespace compatibility
*/
#define _LIBCPP_ABI_VERSION 999
#define _LIBCPP_ABI_UNSTABLE
#define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
#define _LIBCPP_ABI_NAMESPACE __1

#if defined(_MSC_VER) && !defined(__clang__)
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Expand Down Expand Up @@ -256,6 +265,9 @@ If there are users of this configuration we are happy to provide support.
# define _LIBCPP_HAS_NO_INCOMPLETE_RANGES
# endif

#undef _LIBCPP_HAS_NO_INCOMPLETE_FORMAT
#undef _LIBCPP_HAS_NO_INCOMPLETE_RANGES

// Need to detect which libc we're using if we're on Linux.
# if defined(__linux__)
# include <features.h>
Expand Down Expand Up @@ -1101,6 +1113,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
# define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
# endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES

#define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION

# if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)
# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION
Expand Down Expand Up @@ -1145,6 +1159,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
# define _LIBCPP_HAS_NO_FGETPOS_FSETPOS
# endif

#ifndef _LIBCPP_INIT_PRIORITY_MAX
# if __has_attribute(init_priority)
// TODO: Remove this once we drop support for building libc++ with old Clangs
# if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1200) || \
Expand All @@ -1156,6 +1171,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
# else
# define _LIBCPP_INIT_PRIORITY_MAX
# endif
#endif

# if defined(__GNUC__) || defined(__clang__)
// The attribute uses 1-based indices for ordinary and static member functions.
Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/__iterator/reverse_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
#endif

#if _LIBCPP_STD_VER > 17
static_assert(__is_cpp17_bidirectional_iterator<_Iter>::value || bidirectional_iterator<_Iter>,
"reverse_iterator<It> requires It to be a bidirectional iterator.");
/// static_assert(__is_cpp17_bidirectional_iterator<_Iter>::value || bidirectional_iterator<_Iter>,
/// "reverse_iterator<It> requires It to be a bidirectional iterator.");
#endif // _LIBCPP_STD_VER > 17

protected:
Expand Down
28 changes: 14 additions & 14 deletions libcxx/include/__memory/assume_aligned.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ _LIBCPP_BEGIN_NAMESPACE_STD

#if _LIBCPP_STD_VER > 17

template <size_t _Np, class _Tp>
[[nodiscard]]
_LIBCPP_HIDE_FROM_ABI
constexpr _Tp* assume_aligned(_Tp* __ptr) {
static_assert(_Np != 0 && (_Np & (_Np - 1)) == 0,
"std::assume_aligned<N>(p) requires N to be a power of two");

if (is_constant_evaluated()) {
return __ptr;
} else {
_LIBCPP_ASSERT(reinterpret_cast<uintptr_t>(__ptr) % _Np == 0, "Alignment assumption is violated");
return static_cast<_Tp*>(__builtin_assume_aligned(__ptr, _Np));
}
}
/// template <size_t _Np, class _Tp>
/// [[nodiscard]]
/// _LIBCPP_HIDE_FROM_ABI
/// constexpr _Tp* assume_aligned(_Tp* __ptr) {
/// static_assert(_Np != 0 && (_Np & (_Np - 1)) == 0,
/// "std::assume_aligned<N>(p) requires N to be a power of two");
///
/// if (is_constant_evaluated()) {
/// return __ptr;
/// } else {
/// _LIBCPP_ASSERT(reinterpret_cast<uintptr_t>(__ptr) % _Np == 0, "Alignment assumption is violated");
/// return static_cast<_Tp*>(__builtin_assume_aligned(__ptr, _Np));
/// }
/// }

#endif // _LIBCPP_STD_VER > 17

Expand Down
31 changes: 30 additions & 1 deletion libcxx/include/exception
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,47 @@ template <class E> void rethrow_if_nested(const E& e);
# pragma GCC system_header
#endif

#ifdef STD_EXCEPTION_HAS_STACK_TRACE
extern "C" int unw_backtrace(void **, int);
#endif

namespace std // purposefully not using versioning namespace
{

#if !defined(_LIBCPP_ABI_VCRUNTIME)
class _LIBCPP_EXCEPTION_ABI exception
{
public:
_LIBCPP_INLINE_VISIBILITY exception() _NOEXCEPT {}
_LIBCPP_INLINE_VISIBILITY exception() _NOEXCEPT
{
#ifdef STD_EXCEPTION_HAS_STACK_TRACE
capture();
#endif
}
_LIBCPP_INLINE_VISIBILITY exception(const exception&) _NOEXCEPT = default;

virtual ~exception() _NOEXCEPT;
virtual const char* what() const _NOEXCEPT;
#ifdef STD_EXCEPTION_HAS_STACK_TRACE
/// This is ClickHouse patch to libc++. It breaks ABI, so you cannot link your code with any C++ library
/// that has any std::exception-related symbols exported and was built without this patch.
void ** const get_stack_trace_frames() const _NOEXCEPT { return const_cast<void**>(frames); }
int get_stack_trace_size() const _NOEXCEPT { return size; }
void set_stack_trace(void ** frames_, int size_) _NOEXCEPT
{
size = size_;
for (int i = 0; i < size; ++i)
frames[i] = frames_[i];
}
private:
static constexpr int capacity = 32;
void * frames[capacity];
int size = 0;
void capture() _NOEXCEPT
{
size = unw_backtrace(frames, capacity);
}
#endif
};

class _LIBCPP_EXCEPTION_ABI bad_exception
Expand Down
33 changes: 14 additions & 19 deletions libcxxabi/src/cxa_thread_atexit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
//
//===----------------------------------------------------------------------===//

/** This file was edited for ClickHouse.
* This is needed to avoid linking with "__cxa_thread_atexit_impl" function, that require too new (2.18) glibc library.
*
* Note: "__cxa_thread_atexit_impl" may provide sophisticated implementation to correct destruction of thread-local objects,
* that was created in different DSO. Read https://sourceware.org/glibc/wiki/Destructor%20support%20for%20thread_local%20variables
* We simply don't need this implementation, because we don't use thread-local objects from different DSO.
*/

#include "abort_message.h"
#include "cxxabi.h"
#include <__threading_support>
Expand All @@ -21,15 +29,6 @@ namespace __cxxabiv1 {

using Dtor = void(*)(void*);

extern "C"
#ifndef HAVE___CXA_THREAD_ATEXIT_IMPL
// A weak symbol is used to detect this function's presence in the C library
// at runtime, even if libc++ is built against an older libc
_LIBCXXABI_WEAK
#endif
int __cxa_thread_atexit_impl(Dtor, void*, void*);

#ifndef HAVE___CXA_THREAD_ATEXIT_IMPL

namespace {
// This implementation is used if the C library does not provide
Expand Down Expand Up @@ -104,17 +103,10 @@ namespace {
};
} // namespace

#endif // HAVE___CXA_THREAD_ATEXIT_IMPL

extern "C" {

_LIBCXXABI_FUNC_VIS int __cxa_thread_atexit(Dtor dtor, void* obj, void* dso_symbol) throw() {
#ifdef HAVE___CXA_THREAD_ATEXIT_IMPL
return __cxa_thread_atexit_impl(dtor, obj, dso_symbol);
#else
if (__cxa_thread_atexit_impl) {
return __cxa_thread_atexit_impl(dtor, obj, dso_symbol);
} else {
_LIBCXXABI_FUNC_VIS int __cxa_thread_atexit_impl(Dtor dtor, void* obj, void* dso_symbol) throw() {
// Initialize the dtors std::__libcpp_tls_key (uses __cxa_guard_*() for
// one-time initialization and __cxa_atexit() for destruction)
static DtorsManager manager;
Expand All @@ -137,8 +129,11 @@ extern "C" {
dtors = head;

return 0;
}
#endif // HAVE___CXA_THREAD_ATEXIT_IMPL
}

int __cxa_thread_atexit(Dtor dtor, void* obj, void* dso_symbol) throw()
{
return __cxa_thread_atexit_impl(dtor, obj, dso_symbol);
}

} // extern "C"
Expand Down