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
50 changes: 25 additions & 25 deletions stl/inc/atomic
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ extern "C" inline void _Check_memory_order(const unsigned int _Order) noexcept {
}
}

// note: these macros are _not_ always safe to use with a trailing semicolon,
// we avoid wrapping them in do {} while (0) because MSVC generates code for such loops
// in debug mode.

#if defined(_M_IX86) || (defined(_M_X64) && !defined(_M_ARM64EC))
#define _ATOMIC_CHOOSE_INTRINSIC(_Order, _Result, _Intrinsic, ...) \
_Check_memory_order(_Order); \
Expand Down Expand Up @@ -160,23 +164,20 @@ extern "C" inline void _Check_memory_order(const unsigned int _Order) noexcept {

#endif // _STD_ATOMIC_USE_ARM64_LDAR_STLR == 1

// note: these macros are _not_ always safe to use with a trailing semicolon,
// we avoid wrapping them in do {} while (0) because MSVC generates code for such loops
// in debug mode.
#define _ATOMIC_LOAD_VERIFY_MEMORY_ORDER(_Order_var) \
switch (_Order_var) { \
case _Atomic_memory_order_relaxed: \
break; \
case _Atomic_memory_order_consume: \
case _Atomic_memory_order_acquire: \
case _Atomic_memory_order_seq_cst: \
_Compiler_or_memory_barrier(); \
break; \
case _Atomic_memory_order_release: \
case _Atomic_memory_order_acq_rel: \
default: \
_INVALID_MEMORY_ORDER; \
break; \
#define _ATOMIC_POST_LOAD_BARRIER_AS_NEEDED(_Order_var) \
switch (_Order_var) { \
case _Atomic_memory_order_relaxed: \
break; \
case _Atomic_memory_order_consume: \
case _Atomic_memory_order_acquire: \
case _Atomic_memory_order_seq_cst: \
_Compiler_or_memory_barrier(); \
break; \
case _Atomic_memory_order_release: \
case _Atomic_memory_order_acq_rel: \
default: \
_INVALID_MEMORY_ORDER; \
break; \
}

#if _STD_ATOMIC_USE_ARM64_LDAR_STLR == 1
Expand All @@ -185,13 +186,13 @@ extern "C" inline void _Check_memory_order(const unsigned int _Order) noexcept {
_Compiler_barrier(); \
__stlr##_Width(reinterpret_cast<volatile unsigned __int##_Width*>(_Ptr), (_Desired));

#else
#else // ^^^ _STD_ATOMIC_USE_ARM64_LDAR_STLR == 1 ^^^ / vvv _STD_ATOMIC_USE_ARM64_LDAR_STLR == 0 vvv

#define __STORE_RELEASE(_Width, _Ptr, _Desired) \
_Compiler_or_memory_barrier(); \
__iso_volatile_store##_Width((_Ptr), (_Desired));

#endif
#endif // ^^^ _STD_ATOMIC_USE_ARM64_LDAR_STLR == 0 ^^^

#define _ATOMIC_STORE_PREFIX(_Width, _Ptr, _Desired) \
case _Atomic_memory_order_relaxed: \
Expand All @@ -207,7 +208,6 @@ extern "C" inline void _Check_memory_order(const unsigned int _Order) noexcept {
_INVALID_MEMORY_ORDER; \
_FALLTHROUGH;


#define _ATOMIC_STORE_SEQ_CST_ARM(_Width, _Ptr, _Desired) \
_Memory_barrier(); \
__iso_volatile_store##_Width((_Ptr), (_Desired)); \
Expand Down Expand Up @@ -788,7 +788,7 @@ struct _Atomic_storage<_Ty, 1> { // lock-free using 1-byte intrinsics
_ATOMIC_LOAD_ARM64(_As_bytes, 8, _Mem, static_cast<unsigned int>(_Order))
#else
_As_bytes = __iso_volatile_load8(_Mem);
_ATOMIC_LOAD_VERIFY_MEMORY_ORDER(static_cast<unsigned int>(_Order))
_ATOMIC_POST_LOAD_BARRIER_AS_NEEDED(static_cast<unsigned int>(_Order))
#endif
return reinterpret_cast<_TVal&>(_As_bytes);
}
Expand Down Expand Up @@ -896,7 +896,7 @@ struct _Atomic_storage<_Ty, 2> { // lock-free using 2-byte intrinsics
_ATOMIC_LOAD_ARM64(_As_bytes, 16, _Mem, static_cast<unsigned int>(_Order))
#else
_As_bytes = __iso_volatile_load16(_Mem);
_ATOMIC_LOAD_VERIFY_MEMORY_ORDER(static_cast<unsigned int>(_Order))
_ATOMIC_POST_LOAD_BARRIER_AS_NEEDED(static_cast<unsigned int>(_Order))
#endif
return reinterpret_cast<_TVal&>(_As_bytes);
}
Expand Down Expand Up @@ -1003,7 +1003,7 @@ struct _Atomic_storage<_Ty, 4> { // lock-free using 4-byte intrinsics
_ATOMIC_LOAD_ARM64(_As_bytes, 32, _Mem, static_cast<unsigned int>(_Order))
#else
_As_bytes = __iso_volatile_load32(_Mem);
_ATOMIC_LOAD_VERIFY_MEMORY_ORDER(static_cast<unsigned int>(_Order))
_ATOMIC_POST_LOAD_BARRIER_AS_NEEDED(static_cast<unsigned int>(_Order))
#endif
return reinterpret_cast<_TVal&>(_As_bytes);
}
Expand Down Expand Up @@ -1120,7 +1120,7 @@ struct _Atomic_storage<_Ty, 8> { // lock-free using 8-byte intrinsics
_As_bytes = __iso_volatile_load64(_Mem);
#endif

_ATOMIC_LOAD_VERIFY_MEMORY_ORDER(static_cast<unsigned int>(_Order))
_ATOMIC_POST_LOAD_BARRIER_AS_NEEDED(static_cast<unsigned int>(_Order))
#endif // _STD_ATOMIC_USE_ARM64_LDAR_STLR == 1
return reinterpret_cast<_TVal&>(_As_bytes);
}
Expand Down Expand Up @@ -3045,7 +3045,7 @@ _STD_END
#undef _CMPXCHG_MASK_OUT_PADDING_BITS

#undef _ATOMIC_CHOOSE_INTRINSIC
#undef _ATOMIC_LOAD_VERIFY_MEMORY_ORDER
#undef _ATOMIC_POST_LOAD_BARRIER_AS_NEEDED
#undef _ATOMIC_STORE_PREFIX
#undef _ATOMIC_STORE_SEQ_CST_ARM
#undef _ATOMIC_STORE_SEQ_CST_X86_X64
Expand Down
10 changes: 0 additions & 10 deletions stl/inc/concepts
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,6 @@ _EXPORT_STD template <class _Derived, class _Base>
concept derived_from = __is_base_of(_Base, _Derived)
&& __is_convertible_to(const volatile _Derived*, const volatile _Base*);

_EXPORT_STD template <class _From, class _To>
#if !defined(__EDG__) && !defined(__clang__) // TRANSITION, DevCom-1627396
concept convertible_to = is_convertible_v<_From, _To>
#else // ^^^ workaround / no workaround vvv
concept convertible_to = __is_convertible_to(_From, _To)
#endif // ^^^ no workaround ^^^
&& requires {
static_cast<_To>(_STD declval<_From>());
};

template <class _From, class _To>
concept _Implicitly_convertible_to = is_convertible_v<_From, _To>;

Expand Down
24 changes: 12 additions & 12 deletions stl/inc/expected
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ public:

// [expected.object.monadic]
template <class _Fn>
requires is_copy_constructible_v<_Err>
requires is_constructible_v<_Err, _Err&>
constexpr auto and_then(_Fn&& _Func) & {
using _Uty = remove_cvref_t<invoke_result_t<_Fn, _Ty&>>;

Expand Down Expand Up @@ -789,7 +789,7 @@ public:
}

template <class _Fn>
requires is_move_constructible_v<_Err>
requires is_constructible_v<_Err, const _Err>
constexpr auto and_then(_Fn&& _Func) const&& {
using _Uty = remove_cvref_t<invoke_result_t<_Fn, const _Ty>>;

Expand All @@ -808,7 +808,7 @@ public:
}

template <class _Fn>
requires is_copy_constructible_v<_Ty>
requires is_constructible_v<_Ty, _Ty&>
constexpr auto or_else(_Fn&& _Func) & {
using _Uty = remove_cvref_t<invoke_result_t<_Fn, _Err&>>;

Expand Down Expand Up @@ -865,7 +865,7 @@ public:
}

template <class _Fn>
requires is_move_constructible_v<_Ty>
requires is_constructible_v<_Ty, const _Ty>
constexpr auto or_else(_Fn&& _Func) const&& {
using _Uty = remove_cvref_t<invoke_result_t<_Fn, const _Err>>;

Expand All @@ -884,7 +884,7 @@ public:
}

template <class _Fn>
requires is_copy_constructible_v<_Err>
requires is_constructible_v<_Err, _Err&>
constexpr auto transform(_Fn&& _Func) & {
static_assert(invocable<_Fn, _Ty&>, "expected<T, E>::transform(F) requires that F is invocable with T. "
"(N4928 [expected.object.monadic]/19)");
Expand Down Expand Up @@ -965,7 +965,7 @@ public:
}

template <class _Fn>
requires is_move_constructible_v<_Err>
requires is_constructible_v<_Err, const _Err>
constexpr auto transform(_Fn&& _Func) const&& {
static_assert(invocable<_Fn, const _Ty>, "expected<T, E>::transform(F) requires that F is invocable with T. "
"(N4928 [expected.object.monadic]/23)");
Expand All @@ -992,7 +992,7 @@ public:
}

template <class _Fn>
requires is_copy_constructible_v<_Ty>
requires is_constructible_v<_Ty, _Ty&>
constexpr auto transform_error(_Fn&& _Func) & {
static_assert(invocable<_Fn, _Err&>, "expected<T, E>::transform_error(F) requires that F is invocable with E. "
"(N4928 [expected.object.monadic]/27)");
Expand Down Expand Up @@ -1053,7 +1053,7 @@ public:
}

template <class _Fn>
requires is_move_constructible_v<_Ty>
requires is_constructible_v<_Ty, const _Ty>
constexpr auto transform_error(_Fn&& _Func) const&& {
static_assert(invocable<_Fn, const _Err>,
"expected<T, E>::transform_error(F) requires that F is invocable with E. "
Expand Down Expand Up @@ -1470,7 +1470,7 @@ public:

// [expected.void.monadic]
template <class _Fn>
requires is_copy_constructible_v<_Err>
requires is_constructible_v<_Err, _Err&>
constexpr auto and_then(_Fn&& _Func) & {
using _Uty = remove_cvref_t<invoke_result_t<_Fn>>;

Expand Down Expand Up @@ -1527,7 +1527,7 @@ public:
}

template <class _Fn>
requires is_move_constructible_v<_Err>
requires is_constructible_v<_Err, const _Err>
constexpr auto and_then(_Fn&& _Func) const&& {
using _Uty = remove_cvref_t<invoke_result_t<_Fn>>;

Expand Down Expand Up @@ -1618,7 +1618,7 @@ public:
}

template <class _Fn>
requires is_copy_constructible_v<_Err>
requires is_constructible_v<_Err, _Err&>
constexpr auto transform(_Fn&& _Func) & {
static_assert(invocable<_Fn>, "expected<void, E>::transform(F) requires that F is invocable with no arguments. "
"(N4928 [expected.void.monadic]/17)");
Expand Down Expand Up @@ -1696,7 +1696,7 @@ public:
}

template <class _Fn>
requires is_move_constructible_v<_Err>
requires is_constructible_v<_Err, const _Err>
constexpr auto transform(_Fn&& _Func) const&& {
static_assert(invocable<_Fn>, "expected<void, E>::transform(F) requires that F is invocable with no arguments. "
"(N4928 [expected.void.monadic]/21)");
Expand Down
8 changes: 6 additions & 2 deletions stl/inc/format
Original file line number Diff line number Diff line change
Expand Up @@ -1410,13 +1410,17 @@ _NODISCARD constexpr basic_format_arg<_Context> _Get_arg(const _Context& _Ctx, c
return _Arg;
}

template <class _Ty>
inline constexpr bool _Is_signed_or_unsigned_large_integer_t =
_Is_any_of_v<remove_cv_t<_Ty>, int, unsigned int, long, unsigned long, long long, unsigned long long>;

// Checks that the type and value of an argument associated with a dynamic
// width specifier are valid.
class _Width_checker {
public:
template <class _Ty>
_NODISCARD constexpr unsigned long long operator()(const _Ty _Value) const {
if constexpr (is_integral_v<_Ty>) {
if constexpr (_Is_signed_or_unsigned_large_integer_t<_Ty>) {
if constexpr (is_signed_v<_Ty>) {
if (_Value < 0) {
_Throw_format_error("Negative width.");
Expand All @@ -1435,7 +1439,7 @@ class _Precision_checker {
public:
template <class _Ty>
_NODISCARD constexpr unsigned long long operator()(const _Ty _Value) const {
if constexpr (is_integral_v<_Ty>) {
if constexpr (_Is_signed_or_unsigned_large_integer_t<_Ty>) {
if constexpr (is_signed_v<_Ty>) {
if (_Value < 0) {
_Throw_format_error("Negative precision.");
Expand Down
10 changes: 9 additions & 1 deletion stl/inc/memory
Original file line number Diff line number Diff line change
Expand Up @@ -4179,7 +4179,15 @@ public:
explicit out_ptr_t(_SmartPtr& _Smart_ptr_, _ArgsT... _Args_) noexcept(
is_nothrow_constructible_v<tuple<_ArgsT...>, _ArgsT...>) /* strengthened */
: _Smart_ptr(_Smart_ptr_),
_Mypair(_One_then_variadic_args_t{}, tuple<_ArgsT...>{_STD forward<_ArgsT>(_Args_)...}) {}
_Mypair(_One_then_variadic_args_t{}, tuple<_ArgsT...>{_STD forward<_ArgsT>(_Args_)...}) {
constexpr bool _Is_resettable = requires { _Smart_ptr.reset(); }; // TRANSITION, DevCom-10291456
if constexpr (_Is_resettable) {
_Smart_ptr.reset();
} else {
static_assert(is_constructible_v<_SmartPtr>, "the adapted pointer type must be default constructible.");
_Smart_ptr = _SmartPtr();
}
}

out_ptr_t(const out_ptr_t&) = delete;

Expand Down
4 changes: 4 additions & 0 deletions stl/inc/memory_resource
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,10 @@ namespace pmr {

void _Increase_capacity(unsynchronized_pool_resource& _Pool_resource) {
// this pool has no free blocks; get a new chunk from upstream
if (_Next_capacity > _Pool_resource._Options.max_blocks_per_chunk) {
// This is a fresh pool, _Next_capacity hasn't yet been bounded by max_blocks_per_chunk:
_Next_capacity = _Pool_resource._Options.max_blocks_per_chunk;
}
const size_t _Size = _Size_for_capacity(_Next_capacity);
memory_resource* const _Resource = _Pool_resource.upstream_resource();
void* const _Ptr = _Resource->allocate(_Size, _Block_size);
Expand Down
Loading