Skip to content

Commit

Permalink
Update preprocessor #else comment in product code to clarify which …
Browse files Browse the repository at this point in the history
…mode is where (#3900)

Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
  • Loading branch information
AlexGuteniev and StephanTLavavej authored Aug 10, 2023
1 parent a669eae commit 9ad382e
Show file tree
Hide file tree
Showing 100 changed files with 703 additions and 708 deletions.
28 changes: 14 additions & 14 deletions stl/inc/__msvc_bit_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ _NODISCARD int _Countl_zero_lzcnt(const _Ty _Val) noexcept {
} else {
return _Countl_zero_lzcnt(_High);
}
#else // ^^^ _M_IX86 / !_M_IX86 vvv
#else // ^^^ defined(_M_IX86) / !defined(_M_IX86) vvv
return static_cast<int>(__lzcnt64(_Val));
#endif // _M_IX86
#endif // ^^^ !defined(_M_IX86) ^^^
}
}

Expand All @@ -114,11 +114,11 @@ _NODISCARD int _Countl_zero_bsr(const _Ty _Val) noexcept {
if (!_BitScanReverse(&_Result, _Low)) {
return _Digits;
}
#else // ^^^ _M_IX86 / !_M_IX86 vvv
#else // ^^^ defined(_M_IX86) / !defined(_M_IX86) vvv
if (!_BitScanReverse64(&_Result, _Val)) {
return _Digits;
}
#endif // _M_IX86
#endif // ^^^ !defined(_M_IX86) ^^^
}
return static_cast<int>(_Digits - 1 - _Result);
}
Expand All @@ -127,14 +127,14 @@ template <class _Ty>
_NODISCARD int _Checked_x86_x64_countl_zero(const _Ty _Val) noexcept {
#ifdef __AVX2__
return _Countl_zero_lzcnt(_Val);
#else // __AVX2__
#else // ^^^ defined(__AVX2__) / !defined(__AVX2__) vvv
const bool _Definitely_have_lzcnt = __isa_available >= _Stl_isa_available_avx2;
if (_Definitely_have_lzcnt) {
return _Countl_zero_lzcnt(_Val);
} else {
return _Countl_zero_bsr(_Val);
}
#endif // __AVX2__
#endif // ^^^ !defined(__AVX2__) ^^^
}
#endif // defined(_M_IX86) || (defined(_M_X64) && !defined(_M_ARM64EC))

Expand Down Expand Up @@ -250,9 +250,9 @@ _NODISCARD int _Countr_zero_tzcnt(const _Ty _Val) noexcept {
} else {
return static_cast<int>(_TZCNT_U32(_Low));
}
#else // ^^^ _M_IX86 / !_M_IX86 vvv
#else // ^^^ defined(_M_IX86) / !defined(_M_IX86) vvv
return static_cast<int>(_TZCNT_U64(_Val));
#endif // _M_IX86
#endif // ^^^ !defined(_M_IX86) ^^^
}
}

Expand Down Expand Up @@ -285,11 +285,11 @@ _NODISCARD int _Countr_zero_bsf(const _Ty _Val) noexcept {
} else {
return static_cast<int>(_Result + 32);
}
#else // ^^^ _M_IX86 / !_M_IX86 vvv
#else // ^^^ defined(_M_IX86) / !defined(_M_IX86) vvv
if (!_BitScanForward64(&_Result, _Val)) {
return _Digits;
}
#endif // _M_IX86
#endif // ^^^ !defined(_M_IX86) ^^^
}
return static_cast<int>(_Result);
}
Expand All @@ -298,14 +298,14 @@ template <class _Ty>
_NODISCARD int _Checked_x86_x64_countr_zero(const _Ty _Val) noexcept {
#ifdef __AVX2__
return _Countr_zero_tzcnt(_Val);
#else // __AVX2__
#else // ^^^ defined(__AVX2__) / !defined(__AVX2__) vvv
const bool _Definitely_have_tzcnt = __isa_available >= _Stl_isa_available_avx2;
if (_Definitely_have_tzcnt) {
return _Countr_zero_tzcnt(_Val);
} else {
return _Countr_zero_bsf(_Val);
}
#endif // __AVX2__
#endif // ^^^ !defined(__AVX2__) ^^^
}

#endif // _HAS_TZCNT_BSF_INTRINSICS
Expand All @@ -328,9 +328,9 @@ _NODISCARD int _Unchecked_x86_x64_popcount(const _Ty _Val) noexcept {
} else {
#ifdef _M_IX86
return static_cast<int>(__popcnt(_Val >> 32) + __popcnt(static_cast<unsigned int>(_Val)));
#else // ^^^ _M_IX86 / !_M_IX86 vvv
#else // ^^^ defined(_M_IX86) / !defined(_M_IX86) vvv
return static_cast<int>(__popcnt64(_Val));
#endif // _M_IX86
#endif // ^^^ !defined(_M_IX86) ^^^
}
}

Expand Down
6 changes: 3 additions & 3 deletions stl/inc/__msvc_cxx_stdatomic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
// provide a specific error message for C compilers, before the general error message in yvals_core.h
#ifndef __cplusplus
#error <__msvc_cxx_stdatomic.hpp> is an internal header. It is incompatible with C and should not be directly included.
#endif // __cplusplus
#endif // !defined(__cplusplus)

#include <yvals.h>

#ifdef _M_CEE_PURE
#error <stdatomic.h> is not supported when compiling with /clr:pure.
#endif // _M_CEE_PURE
#endif // defined(_M_CEE_PURE)

#if !_HAS_CXX23
_EMIT_STL_WARNING(STL4038, "The contents of <stdatomic.h> are available only with C++23 or later.");
Expand Down Expand Up @@ -63,7 +63,7 @@ using _STD atomic_ullong;

#ifdef __cpp_lib_char8_t
using _STD atomic_char8_t;
#endif // __cpp_lib_char8_t
#endif // defined(__cpp_lib_char8_t)

using _STD atomic_char16_t;
using _STD atomic_char32_t;
Expand Down
10 changes: 5 additions & 5 deletions stl/inc/__msvc_filebuf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ extern "C++" _CRTIMP2_PURE FILE* __CLRCALL_PURE_OR_CDECL _Fiopen(const wchar_t*,

#ifdef _CRTBLD
extern "C++" _CRTIMP2_PURE FILE* __CLRCALL_PURE_OR_CDECL _Fiopen(const unsigned short*, ios_base::openmode, int);
#endif // _CRTBLD
#endif // defined(_CRTBLD)

template <class _Elem>
bool _Fgetc(_Elem& _Ch, FILE* _File) { // get an element from a C stream
Expand Down Expand Up @@ -106,7 +106,7 @@ inline bool _Fgetc(unsigned short& _Wchar, FILE* _File) { // get an unsigned sho
return true;
}
}
#endif // _CRTBLD
#endif // defined(_CRTBLD)

template <class _Elem>
bool _Fputc(_Elem _Ch, FILE* _File) { // put an element to a C stream
Expand All @@ -128,7 +128,7 @@ template <>
inline bool _Fputc(unsigned short _Wchar, FILE* _File) { // put an unsigned short element to a C stream
return _CSTD fputwc(_Wchar, _File) != WEOF;
}
#endif // _CRTBLD
#endif // defined(_CRTBLD)

template <class _Elem>
bool _Ungetc(const _Elem&, FILE*) { // put back an arbitrary element to a C stream (always fail)
Expand Down Expand Up @@ -160,7 +160,7 @@ template <>
inline bool _Ungetc(const unsigned short& _Wchar, FILE* _File) { // put back an unsigned short element to a C stream
return _CSTD ungetwc(_Wchar, _File) != WEOF;
}
#endif // _CRTBLD
#endif // defined(_CRTBLD)

_EXPORT_STD template <class _Elem, class _Traits>
class basic_filebuf : public basic_streambuf<_Elem, _Traits> { // stream buffer associated with a C stream
Expand Down Expand Up @@ -378,7 +378,7 @@ class basic_filebuf : public basic_streambuf<_Elem, _Traits> { // stream buffer
return open(_Filename, static_cast<ios_base::openmode>(_Mode));
}
#endif // _HAS_OLD_IOSTREAMS_MEMBERS
#endif // _CRTBLD
#endif // defined(_CRTBLD)

basic_filebuf* close() {
basic_filebuf* _Ans;
Expand Down
4 changes: 2 additions & 2 deletions stl/inc/__msvc_iter_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ template <class _It, class _Se, ranges::subrange_kind _Ki>
struct tuple_element<1, const ranges::subrange<_It, _Se, _Ki>> {
using type = _Se;
};
#else // ^^^ __cpp_lib_concepts / !__cpp_lib_concepts vvv
#else // ^^^ defined(__cpp_lib_concepts) / !defined(__cpp_lib_concepts) vvv
template <class, class = void>
struct _Iterator_traits_base {}; // empty for non-iterators

Expand Down Expand Up @@ -509,7 +509,7 @@ struct iterator_traits : _Iterator_traits_base<_Iter> {}; // get traits from ite

template <class _Ty>
struct iterator_traits<_Ty*> : _Iterator_traits_pointer_base<_Ty> {}; // get traits from pointer, if possible
#endif // __cpp_lib_concepts
#endif // ^^^ !defined(__cpp_lib_concepts) ^^^
_STD_END

#pragma pop_macro("new")
Expand Down
Loading

0 comments on commit 9ad382e

Please sign in to comment.