[libcxx-commits] [libcxx] [libc++] Clean up windows macros (PR #207577)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Jul 5 11:03:14 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Nikolas Klauser (philnik777)
<details>
<summary>Changes</summary>
We have multiple macros for different Windows. However, most of them don't actually define different things. We can condense the macros to
- `_WIN32` directly if it only depends on windows, or
- `_LIBCPP_LIBC_MSVCRT` (which is equivalent to the old `_LIBCPP_MSVCRT`)
This patch drops `_LIBCPP_MSVCRT_LIKE` and `_LIBCPP_WIN32API`, since they are equivalent to `_WIN32`.
---
Patch is 49.54 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/207577.diff
39 Files Affected:
- (modified) libcxx/include/__config (+7-10)
- (modified) libcxx/include/__filesystem/path.h (+17-17)
- (modified) libcxx/include/__filesystem/u8path.h (+7-7)
- (modified) libcxx/include/__locale (+1-1)
- (modified) libcxx/include/__locale_dir/locale_base_api.h (+1-1)
- (modified) libcxx/include/__locale_dir/support/windows.h (+1-1)
- (modified) libcxx/include/__math/gamma.h (+1-1)
- (modified) libcxx/include/__math/traits.h (+1-1)
- (modified) libcxx/include/__ostream/print.h (+2-2)
- (modified) libcxx/include/fstream (+5-5)
- (modified) libcxx/include/math.h (+5-5)
- (modified) libcxx/include/print (+6-6)
- (modified) libcxx/include/stdlib.h (+2-2)
- (modified) libcxx/include/string.h (+1-1)
- (modified) libcxx/include/text_encoding (+1-1)
- (modified) libcxx/include/wchar.h (+3-3)
- (modified) libcxx/src/chrono.cpp (+4-4)
- (modified) libcxx/src/filesystem/directory_iterator.cpp (+2-2)
- (modified) libcxx/src/filesystem/error.h (+2-2)
- (modified) libcxx/src/filesystem/file_descriptor.h (+7-7)
- (modified) libcxx/src/filesystem/filesystem_clock.cpp (+3-3)
- (modified) libcxx/src/filesystem/format_string.h (+1-1)
- (modified) libcxx/src/filesystem/operations.cpp (+7-7)
- (modified) libcxx/src/filesystem/path.cpp (+1-1)
- (modified) libcxx/src/filesystem/path_parser.h (+2-2)
- (modified) libcxx/src/filesystem/posix_compat.h (+3-3)
- (modified) libcxx/src/filesystem/time_utils.h (+5-5)
- (modified) libcxx/src/fstream.cpp (+2-2)
- (modified) libcxx/src/include/aligned_alloc.h (+2-2)
- (modified) libcxx/src/include/config_elast.h (+2-2)
- (modified) libcxx/src/iostream.cpp (+1-1)
- (modified) libcxx/src/locale.cpp (+20-20)
- (modified) libcxx/src/print.cpp (+4-4)
- (modified) libcxx/src/std_stream.h (+2-2)
- (modified) libcxx/src/string.cpp (+1-1)
- (modified) libcxx/src/support/win32/locale_win32.cpp (+3-3)
- (modified) libcxx/src/system_error.cpp (+5-5)
- (modified) libcxx/src/thread.cpp (+2-2)
- (modified) libcxx/test/support/count_new.h (+1-1)
``````````diff
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 3f271ff504767..bf2cb865fa0e5 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -43,14 +43,11 @@
# endif
# if defined(_WIN32)
-# define _LIBCPP_WIN32API
# define _LIBCPP_SHORT_WCHAR 1
-// Both MinGW and native MSVC provide a "MSVC"-like environment
-# define _LIBCPP_MSVCRT_LIKE
-// If mingw not explicitly detected, assume using MS C runtime only if
-// a MS compatibility version is specified.
-# if defined(_MSC_VER) && !defined(__MINGW32__)
-# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
+# if defined(__MINGW32__)
+# define _LIBCPP_LIBC_MINGW
+# else
+# define _LIBCPP_LIBC_MSVCRT
# endif
# define _LIBCPP_HAS_OPEN_WITH_WCHAR 1
# else
@@ -100,7 +97,7 @@
# define _LIBCPP_USING_GETENTROPY
# elif defined(__Fuchsia__)
# define _LIBCPP_USING_FUCHSIA_CPRNG
-# elif defined(_LIBCPP_WIN32API)
+# elif defined(_WIN32)
# define _LIBCPP_USING_WIN32_RANDOM
# else
# define _LIBCPP_USING_DEV_RANDOM
@@ -170,7 +167,7 @@ typedef __char32_t char32_t;
// If we are getting operator new from the MSVC CRT, then allocation overloads
// for align_val_t were added in 19.12, aka VS 2017 version 15.3.
-# if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
+# if defined(_LIBCPP_LIBC_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
# define _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION 0
# elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new)
// We're deferring to Microsoft's STL to provide aligned new et al. We don't
@@ -227,7 +224,7 @@ typedef __char32_t char32_t;
// TODO(44575): Switch to C11 thread API when possible.
# undef _LIBCPP_HAS_THREAD_API_PTHREAD
# define _LIBCPP_HAS_THREAD_API_PTHREAD 1
-# elif defined(_LIBCPP_WIN32API)
+# elif defined(_WIN32)
# undef _LIBCPP_HAS_THREAD_API_WIN32
# define _LIBCPP_HAS_THREAD_API_WIN32 1
# else
diff --git a/libcxx/include/__filesystem/path.h b/libcxx/include/__filesystem/path.h
index a63c4ee611ebf..f89c829505d61 100644
--- a/libcxx/include/__filesystem/path.h
+++ b/libcxx/include/__filesystem/path.h
@@ -80,7 +80,7 @@ struct __can_convert_char<char32_t> {
template <class _ECharT, __enable_if_t<__can_convert_char<_ECharT>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI bool __is_separator(_ECharT __e) {
-# if defined(_LIBCPP_WIN32API)
+# ifdef _WIN32
return __e == _ECharT('/') || __e == _ECharT('\\');
# else
return __e == _ECharT('/');
@@ -181,7 +181,7 @@ struct __is_pathable<_Tp, false, true, false> : __is_pathable_char_array<_Tp> {}
template <class _Tp>
struct __is_pathable<_Tp, false, false, true> : __is_pathable_iter<_Tp> {};
-# if defined(_LIBCPP_WIN32API)
+# ifdef _WIN32
typedef wstring __path_string;
typedef wchar_t __path_value;
# else
@@ -189,7 +189,7 @@ typedef string __path_string;
typedef char __path_value;
# endif
-# if defined(_LIBCPP_WIN32API)
+# ifdef _WIN32
_LIBCPP_EXPORTED_FROM_ABI size_t __wide_to_char(const wstring&, char*, size_t);
_LIBCPP_EXPORTED_FROM_ABI size_t __char_to_wide(const string&, wchar_t*, size_t);
# endif
@@ -203,12 +203,12 @@ struct _PathCVT {
static_assert(__can_convert_char<_ECharT>::value, "Char type not convertible");
typedef __narrow_to_utf8<sizeof(_ECharT) * __CHAR_BIT__> _Narrower;
-# if defined(_LIBCPP_WIN32API)
+# ifdef _WIN32
typedef __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Widener;
# endif
_LIBCPP_HIDE_FROM_ABI static void __append_range(__path_string& __dest, _ECharT const* __b, _ECharT const* __e) {
-# if defined(_LIBCPP_WIN32API)
+# ifdef _WIN32
string __utf8;
_Narrower()(back_inserter(__utf8), __b, __e);
_Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size());
@@ -223,7 +223,7 @@ struct _PathCVT {
if (__b == __e)
return;
basic_string<_ECharT> __tmp(__b, __e);
-# if defined(_LIBCPP_WIN32API)
+# ifdef _WIN32
string __utf8;
_Narrower()(back_inserter(__utf8), __tmp.data(), __tmp.data() + __tmp.length());
_Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size());
@@ -241,7 +241,7 @@ struct _PathCVT {
basic_string<_ECharT> __tmp;
for (; *__b != __sentinel; ++__b)
__tmp.push_back(*__b);
-# if defined(_LIBCPP_WIN32API)
+# ifdef _WIN32
string __utf8;
_Narrower()(back_inserter(__utf8), __tmp.data(), __tmp.data() + __tmp.length());
_Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size());
@@ -284,7 +284,7 @@ struct _PathCVT<__path_value> {
}
};
-# if defined(_LIBCPP_WIN32API)
+# ifdef _WIN32
template <>
struct _PathCVT<char> {
_LIBCPP_HIDE_FROM_ABI static void __append_string(__path_string& __dest, const basic_string<char>& __str) {
@@ -369,7 +369,7 @@ struct _PathExport<char8_t> {
};
# endif // _LIBCPP_HAS_CHAR8_T
# endif // _LIBCPP_HAS_LOCALIZATION
-# endif // _LIBCPP_WIN32API
+# endif // _WIN32
class _LIBCPP_EXPORTED_FROM_ABI path {
template <class _SourceOrIter, class _Tp = path&>
@@ -382,7 +382,7 @@ class _LIBCPP_EXPORTED_FROM_ABI path {
using _SourceCVT _LIBCPP_NODEBUG = _PathCVT<_SourceChar<_Tp> >;
public:
-# if defined(_LIBCPP_WIN32API)
+# ifdef _WIN32
typedef wchar_t value_type;
static constexpr value_type preferred_separator = L'\\';
# else
@@ -468,7 +468,7 @@ class _LIBCPP_EXPORTED_FROM_ABI path {
public:
// appends
-# if defined(_LIBCPP_WIN32API)
+# ifdef _WIN32
_LIBCPP_HIDE_FROM_ABI path& operator/=(const path& __p) {
auto __p_root_name = __p.__root_name();
auto __p_root_name_size = __p_root_name.size();
@@ -602,7 +602,7 @@ class _LIBCPP_EXPORTED_FROM_ABI path {
_LIBCPP_HIDE_FROM_ABI void clear() noexcept { __pn_.clear(); }
_LIBCPP_HIDE_FROM_ABI path& make_preferred() _LIBCPP_LIFETIMEBOUND {
-# if defined(_LIBCPP_WIN32API)
+# ifdef _WIN32
std::replace(__pn_.begin(), __pn_.end(), L'/', L'\\');
# endif
return *this;
@@ -667,7 +667,7 @@ class _LIBCPP_EXPORTED_FROM_ABI path {
_LIBCPP_HIDE_FROM_ABI operator string_type() const { return __pn_; }
-# if defined(_LIBCPP_WIN32API)
+# ifdef _WIN32
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::wstring wstring() const { return __pn_; }
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::wstring generic_wstring() const {
@@ -722,7 +722,7 @@ class _LIBCPP_EXPORTED_FROM_ABI path {
return __s;
}
# endif // _LIBCPP_HAS_LOCALIZATION
-# else /* _LIBCPP_WIN32API */
+# else // _WIN32
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::string string() const { return __pn_; }
# if _LIBCPP_HAS_CHAR8_T
@@ -775,7 +775,7 @@ class _LIBCPP_EXPORTED_FROM_ABI path {
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::u16string generic_u16string() const { return string<char16_t>(); }
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::u32string generic_u32string() const { return string<char32_t>(); }
# endif // _LIBCPP_HAS_LOCALIZATION
-# endif /* !_LIBCPP_WIN32API */
+# endif // _WIN32
private:
int __compare(__string_view) const;
@@ -799,7 +799,7 @@ class _LIBCPP_EXPORTED_FROM_ABI path {
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI path root_name() const { return string_type(__root_name()); }
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI path root_directory() const { return string_type(__root_directory()); }
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI path root_path() const {
-# if defined(_LIBCPP_WIN32API)
+# ifdef _WIN32
return string_type(__root_path_raw());
# else
return root_name().append(string_type(__root_directory()));
@@ -824,7 +824,7 @@ class _LIBCPP_EXPORTED_FROM_ABI path {
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool has_extension() const { return !__extension().empty(); }
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool is_absolute() const {
-# if defined(_LIBCPP_WIN32API)
+# ifdef _WIN32
__string_view __root_name_str = __root_name();
__string_view __root_dir = __root_directory();
if (__root_name_str.size() == 2 && __root_name_str[1] == ':') {
diff --git a/libcxx/include/__filesystem/u8path.h b/libcxx/include/__filesystem/u8path.h
index aabd2bbd3c26c..77e7c0d6653da 100644
--- a/libcxx/include/__filesystem/u8path.h
+++ b/libcxx/include/__filesystem/u8path.h
@@ -24,7 +24,7 @@
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
-# if !defined(_LIBCPP_WIN32API) || _LIBCPP_HAS_LOCALIZATION
+# if !defined(_WIN32) || _LIBCPP_HAS_LOCALIZATION
template <class _InputIt, __enable_if_t<__is_pathable<_InputIt>::value, int> = 0>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f, _InputIt __l) {
static_assert(
@@ -34,7 +34,7 @@ template <class _InputIt, __enable_if_t<__is_pathable<_InputIt>::value, int> = 0
is_same<typename __is_pathable<_InputIt>::__char_type, char>::value,
"u8path(Iter, Iter) requires Iter have a value_type of type 'char'"
" or 'char8_t'");
-# if defined(_LIBCPP_WIN32API)
+# if defined(_WIN32)
string __tmp(__f, __l);
using _CVT = __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__>;
std::wstring __w;
@@ -43,11 +43,11 @@ template <class _InputIt, __enable_if_t<__is_pathable<_InputIt>::value, int> = 0
return path(__w);
# else
return path(__f, __l);
-# endif // defined(_LIBCPP_WIN32API)
+# endif // defined(_WIN32)
}
-# endif // !defined(_LIBCPP_WIN32API) || _LIBCPP_HAS_LOCALIZATION
+# endif // !defined(_WIN32) || _LIBCPP_HAS_LOCALIZATION
-# if defined(_LIBCPP_WIN32API) && _LIBCPP_HAS_LOCALIZATION
+# if defined(_WIN32) && _LIBCPP_HAS_LOCALIZATION
template <class _InputIt, __enable_if_t<__is_pathable<_InputIt>::value, int> = 0>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f, _NullSentinel) {
static_assert(
@@ -67,7 +67,7 @@ template <class _InputIt, __enable_if_t<__is_pathable<_InputIt>::value, int> = 0
_CVT()(back_inserter(__w), __tmp.data(), __tmp.data() + __tmp.size());
return path(__w);
}
-# endif // defined(_LIBCPP_WIN32API) && _LIBCPP_HAS_LOCALIZATION
+# endif // defined(_WIN32) && _LIBCPP_HAS_LOCALIZATION
template <class _Source, __enable_if_t<__is_pathable<_Source>::value, int> = 0>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(const _Source& __s) {
@@ -78,7 +78,7 @@ template <class _Source, __enable_if_t<__is_pathable<_Source>::value, int> = 0>
is_same<typename __is_pathable<_Source>::__char_type, char>::value,
"u8path(Source const&) requires Source have a character type of type "
"'char' or 'char8_t'");
-# if defined(_LIBCPP_WIN32API)
+# if defined(_WIN32)
using _Traits = __is_pathable<_Source>;
return u8path(std::__unwrap_iter(_Traits::__range_begin(__s)), std::__unwrap_iter(_Traits::__range_end(__s)));
# else
diff --git a/libcxx/include/__locale b/libcxx/include/__locale
index bb8f8e7bbf5d9..e0524cf4abc4c 100644
--- a/libcxx/include/__locale
+++ b/libcxx/include/__locale
@@ -352,7 +352,7 @@ public:
# else
static const mask __regex_word = 0x80;
# endif
-# elif defined(_LIBCPP_MSVCRT_LIKE)
+# elif defined(_WIN32)
typedef unsigned short mask;
static const mask space = _SPACE;
static const mask print = _BLANK | _PUNCT | _ALPHA | _DIGIT;
diff --git a/libcxx/include/__locale_dir/locale_base_api.h b/libcxx/include/__locale_dir/locale_base_api.h
index f973d95ef244d..017d971ec72ba 100644
--- a/libcxx/include/__locale_dir/locale_base_api.h
+++ b/libcxx/include/__locale_dir/locale_base_api.h
@@ -116,7 +116,7 @@
# include <__locale_dir/support/netbsd.h>
# elif defined(__OpenBSD__)
# include <__locale_dir/support/openbsd.h>
-# elif defined(_LIBCPP_MSVCRT_LIKE)
+# elif defined(_WIN32)
# include <__locale_dir/support/windows.h>
# elif defined(__Fuchsia__)
# include <__locale_dir/support/fuchsia.h>
diff --git a/libcxx/include/__locale_dir/support/windows.h b/libcxx/include/__locale_dir/support/windows.h
index 6675cfb740b29..a20b5226738a6 100644
--- a/libcxx/include/__locale_dir/support/windows.h
+++ b/libcxx/include/__locale_dir/support/windows.h
@@ -172,7 +172,7 @@ _LIBCPP_EXPORTED_FROM_ABI const char* __get_locale_encoding(__locale_t __loc);
//
// the *_l functions are prefixed on Windows, only available for msvcr80+, VS2005+
-#if defined(_LIBCPP_MSVCRT)
+#if defined(_LIBCPP_LIBC_MSVCRT)
inline _LIBCPP_HIDE_FROM_ABI float __strtof(const char* __nptr, char** __endptr, __locale_t __loc) {
return ::_strtof_l(__nptr, __endptr, __loc);
}
diff --git a/libcxx/include/__math/gamma.h b/libcxx/include/__math/gamma.h
index a742ea42d9009..08e09d7cb7aef 100644
--- a/libcxx/include/__math/gamma.h
+++ b/libcxx/include/__math/gamma.h
@@ -62,7 +62,7 @@ inline _LIBCPP_HIDE_FROM_ABI double tgamma(_A1 __x) _NOEXCEPT {
// declare it differently in the first place: instead use `asm` to get the compiler to call the right
// function.
-#if defined(_LIBCPP_MSVCRT_LIKE) // reentrant version is not available on Windows
+#ifdef _WIN32 // reentrant version is not available on Windows
inline _LIBCPP_HIDE_FROM_ABI double __lgamma_r(double __d) _NOEXCEPT { return __builtin_lgamma(__d); }
diff --git a/libcxx/include/__math/traits.h b/libcxx/include/__math/traits.h
index ff22cee7305d7..5dd489c8b0a36 100644
--- a/libcxx/include/__math/traits.h
+++ b/libcxx/include/__math/traits.h
@@ -188,7 +188,7 @@ template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_ar
// TODO: Remove the workaround once UCRT fixes these functions. Note that this doesn't seem planned as of 2025-07 per
// https://developercommunity.visualstudio.com/t/10294165.
-#if defined(_LIBCPP_MSVCRT) && _LIBCPP_STD_VER >= 20
+#if defined(_LIBCPP_LIBC_MSVCRT) && _LIBCPP_STD_VER >= 20
namespace __ucrt {
template <class _A1>
requires is_integral_v<_A1>
diff --git a/libcxx/include/__ostream/print.h b/libcxx/include/__ostream/print.h
index 5b4ab60a45eea..4a519c177b990 100644
--- a/libcxx/include/__ostream/print.h
+++ b/libcxx/include/__ostream/print.h
@@ -89,7 +89,7 @@ _LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
# if _LIBCPP_HAS_UNICODE
template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
_LIBCPP_HIDE_FROM_ABI void __vprint_unicode(ostream& __os, string_view __fmt, format_args __args, bool __write_nl) {
-# ifndef _LIBCPP_WIN32API
+# ifndef _WIN32
return std::__vprint_nonunicode(__os, __fmt, __args, __write_nl);
# else
FILE* __file = std::__get_ostream_file(__os);
@@ -123,7 +123,7 @@ _LIBCPP_HIDE_FROM_ABI void __vprint_unicode(ostream& __os, string_view __fmt, fo
__os.__set_badbit_and_consider_rethrow();
}
# endif // _LIBCPP_HAS_EXCEPTIONS
-# endif // _LIBCPP_WIN32API
+# endif // _WIN32
}
template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index 7b84bf6609086..78fcdf254b493 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -222,7 +222,7 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
-# if _LIBCPP_STD_VER >= 23 && defined(_LIBCPP_WIN32API)
+# if _LIBCPP_STD_VER >= 23 && defined(_WIN32)
_LIBCPP_EXPORTED_FROM_ABI void* __filebuf_windows_native_handle(FILE* __file) noexcept;
# endif
@@ -236,7 +236,7 @@ public:
typedef typename traits_type::off_type off_type;
typedef typename traits_type::state_type state_type;
# if _LIBCPP_STD_VER >= 26
-# if defined(_LIBCPP_WIN32API)
+# if defined(_WIN32)
using native_handle_type = void*; // HANDLE
# elif __has_include(<unistd.h>)
using native_handle_type = int; // POSIX file descriptor
@@ -272,7 +272,7 @@ public:
# if _LIBCPP_STD_VER >= 26
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept {
_LIBCPP_ASSERT_UNCATEGORIZED(this->is_open(), "File must be opened");
-# if defined(_LIBCPP_WIN32API)
+# if defined(_WIN32)
return std::__filebuf_windows_native_handle(__file_);
# elif __has_include(<unistd.h>)
return fileno(__file_);
@@ -1020,7 +1020,7 @@ basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way,
template <class _CharT, class _Traits>
int basic_filebuf<_CharT, _Traits>::__fseek(FILE* __file, pos_type __offset, int __whence) {
-# if defined(_LIBCPP_MSVCRT_LIKE)
+# ifdef _WIN32
return _fseeki64(__file, __offset, __whence);
# elif _LIBCPP_LIBC_NEWLIB
return fseek(__file, __offset, __whence);
@@ -1031,7 +1031,7 @@ int basic_filebuf<_CharT, _Traits>::__fseek(FILE* __file, pos_type __offset, int
template <class _CharT, class _Traits>
typename basic_filebuf<_CharT, _Traits>::pos_type basic_filebuf<_CharT, _Traits>::__ftell(FILE* __file) {
-# if defined(_LIBCPP_MSVCRT_LIKE)
+# ifdef _WIN32
return _ftelli64(__file);
# elif _LIBCPP_LIBC_NEWLIB
return ftell(__file);
diff --git a/libcxx/include/math.h b/libcxx/include/math.h
index 1db61538e995f..d35d305a682eb 100644
--- a/libcxx/include/math.h
+++ b/libcxx/include/math.h
@@ -416,7 +416,7 @@ using std::__math::fpclassify;
using std::__math::signbit;
// The MSVC runtime already provides these functions as templates
-# ifndef _LIBCPP_MSVCRT
+# ifndef _LIBCPP_LIBC_MSVCRT
using std::__math::isfinite;
using std::__math::isgreater;
using std::__math::isgreaterequal;
@@ -427,9 +427,9 @@ using std::__math::islessgreater;
using std::__math::isnan;
using std::__math::isnormal;
using std::__math::isunordered;
-# endif // _LIBCPP_MSVCRT
+# endif // _LIBCPP_LIBC_MSVCRT
-# if defined(_LIBCPP_MSVCRT) && _LIBCPP_STD_VER >= 20
+# if defined(_LIBCPP_LIBC_MSVCRT) && _LIBCPP_STD_VER >= 20
// MS UCRT incorrectly defines some functions in a way not working with integer types. Until C++20, this was worked
// around by -fdelayed-template-parsing. Since C++20, we can use standard feature "requires" instead.
@@ -446,7 +446,7 @@ using std::__math::__ucrt::islessgreater;
using std::__math::__ucrt::isnan;
using std::__math::__ucrt::isnormal;
using std::__math::__ucrt::isunordered;
-# endif // defined(_LIBCPP_MSVCRT) && _LIBCPP_STD_VER >= 20
+# endif // defined(_LIBCPP_LIBC_MSVCRT) && _LIBCPP_STD_VER >= 20
// We have to provide double overloads for <math.h> to work on platforms that don't provide the full set of math
// functions. To make the overload set work with multiple functions that take the same arguments, we make our overloads
@@ -527,7 +527,7 @@ using std::__math::trunc;
//
// and receive the definitions of mathematical constants, even if <math.h>
// has previously been included.
-# if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES)
+# if defined(_LIBCPP_LIBC_MSVCRT) && defined(_USE_MATH_DEFINES)
# include_next <math.h>
# endif
diff --git a/libcxx/include/print b/libcxx/include/print
index cf62743846f42..a9c4ee686f5f9 100644
--- a/libcxx/include/print
+++ b/libcxx/include/print
@@ -56,7 +56,7 @@ namespace std {
_LIBCPP_BEGIN_NAMESPACE_STD
-# ifdef _LIBCPP_WIN32API
+# ifdef _WIN32
_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
_LIBCPP_EXPORTED_FROM_ABI bool __is_windows_terminal(FILE* __stream);
@@ -73,7 +73,7 @@ _LIBCPP_EXPORTED_FROM_ABI bool __is_windows_terminal(FILE* __stream);
_LIBCPP_EXPORTED_FROM_ABI void __write_to_windows_console(FILE* __stream, wstring_view __view);
# endif // _LIBCPP_HAS_WIDE_CHARACTERS
_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
-# endif // _LIBCPP_WIN32API
+# endif // _WIN32
# if _LIBCPP_HAS_UNICODE
// This is the code to transcode UTF-8 to UTF-16. This is used on
@@ -197,7 +197,7 @@ inline constexpr bool __use_unicode_execution_charset = _MSVC_EXECUTION_CHARACTE
inline constexpr bool __use_unicode_execution_charset = true;
# endif
-# ifdef _LIBCPP_WIN32API
+# ifdef _WIN32
_LIBCPP_HIDE_FROM_ABI inline bool __is_terminal([[maybe_unused]] FILE* __stream) {
// The macro _LIBCPP_TESTING_PRINT_IS_TERMINAL is used to change
// the behavior in the test. This is not part of the public API.
@@ -207,7 +207,7 @@ _LIBCPP_HIDE_FROM_ABI inline bool __is_terminal([[maybe_unused]] FILE* __stream)
return std::__is_windows_terminal(__stream);
# endif
}
-# endif // _LIBCPP_WIN32API
+# endif // _WIN32
[[noreturn]] _LIBCPP_HIDE_FROM_ABI inline void __handle_out...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/207577
More information about the libcxx-commits
mailing list