Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc++] Handle _LIBCPP_HAS_NO_{THREADS,LOCALIZATION} consistently with other carve-outs #98319

Merged
merged 2 commits into from
Jul 15, 2024
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
6 changes: 6 additions & 0 deletions libcxx/docs/ReleaseNotes/19.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ Deprecations and Removals
`std-allocator-const <https://clang.llvm.org/extra/clang-tidy/checks/portability/std-allocator-const.html>`
enabled.

- When configuring libc++ with localization or threads disabled, the library no longer emits an error when
trying to ``#include <locale>`` and other such headers. Instead, those headers have no content. This is
consistent with the behavior for all other libc++ carve-outs like filesystem, wide characters, a source
of randomness, and others. Users that were checking whether including a header would fail (e.g. via a script
or CMake's ``try_compile`` will experience a change in behavior).


Upcoming Deprecations and Removals
----------------------------------
Expand Down
52 changes: 26 additions & 26 deletions libcxx/include/barrier
Original file line number Diff line number Diff line change
Expand Up @@ -47,38 +47,36 @@ namespace std

#include <__config>

#ifdef _LIBCPP_HAS_NO_THREADS
# error "<barrier> is not supported since libc++ has been configured without support for threads."
#endif

#include <__assert>
#include <__atomic/atomic_base.h>
#include <__atomic/memory_order.h>
#include <__memory/unique_ptr.h>
#include <__thread/poll_with_backoff.h>
#include <__thread/timed_backoff_policy.h>
#include <__utility/move.h>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <version>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
#if !defined(_LIBCPP_HAS_NO_THREADS)

# include <__assert>
# include <__atomic/atomic_base.h>
# include <__atomic/memory_order.h>
# include <__memory/unique_ptr.h>
# include <__thread/poll_with_backoff.h>
# include <__thread/timed_backoff_policy.h>
# include <__utility/move.h>
# include <cstddef>
# include <cstdint>
# include <limits>
# include <version>

# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif

_LIBCPP_PUSH_MACROS
#include <__undef_macros>
# include <__undef_macros>

#if _LIBCPP_STD_VER >= 14
# if _LIBCPP_STD_VER >= 14

_LIBCPP_BEGIN_NAMESPACE_STD

struct __empty_completion {
inline _LIBCPP_HIDE_FROM_ABI void operator()() noexcept {}
};

# ifndef _LIBCPP_HAS_NO_TREE_BARRIER
# ifndef _LIBCPP_HAS_NO_TREE_BARRIER

/*

Expand Down Expand Up @@ -152,7 +150,7 @@ public:
}
};

# else
# else

/*

Expand Down Expand Up @@ -253,7 +251,7 @@ public:
}
};

# endif // !_LIBCPP_HAS_NO_TREE_BARRIER
# endif // !_LIBCPP_HAS_NO_TREE_BARRIER

template <class _CompletionF = __empty_completion>
class _LIBCPP_DEPRECATED_ATOMIC_SYNC barrier {
Expand All @@ -265,7 +263,7 @@ public:
static _LIBCPP_HIDE_FROM_ABI constexpr ptrdiff_t max() noexcept { return __barrier_base<_CompletionF>::max(); }

_LIBCPP_AVAILABILITY_SYNC
_LIBCPP_HIDE_FROM_ABI explicit barrier(ptrdiff_t __count, _CompletionF __completion = _CompletionF())
_LIBCPP_HIDE_FROM_ABI explicit barrier(ptrdiff_t __count, _CompletionF __completion = _CompletionF())
: __b_(__count, std::move(__completion)) {
_LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
__count >= 0,
Expand All @@ -292,10 +290,12 @@ public:

_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 14
# endif // _LIBCPP_STD_VER >= 14

_LIBCPP_POP_MACROS

#endif // !defined(_LIBCPP_HAS_NO_THREADS)

#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <atomic>
# include <concepts>
Expand Down
Loading
Loading