From 8c3769a7997198fae9a1077955d00b9afd7df1a1 Mon Sep 17 00:00:00 2001 From: Thomas Khyn Date: Thu, 13 Feb 2025 16:23:13 +1300 Subject: [PATCH] Fix TU-local entity exposition errors in GCC 15 --- include/fmt/format-inl.h | 2 +- src/os.cc | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index a5b79dbe49b5..66ee747abf5a 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -212,7 +212,7 @@ inline auto floor_log10_pow2_minus_log10_4_over_3(int e) noexcept -> int { return (e * 631305 - 261663) >> 21; } -FMT_INLINE_VARIABLE constexpr struct { +FMT_INLINE_VARIABLE constexpr struct div_small_pow10_infos_struct { uint32_t divisor; int shift_amount; } div_small_pow10_infos[] = {{10, 16}, {100, 16}}; diff --git a/src/os.cc b/src/os.cc index c833a0514186..ad1a4a9e0abb 100644 --- a/src/os.cc +++ b/src/os.cc @@ -61,18 +61,12 @@ namespace { #ifdef _WIN32 -// Return type of read and write functions. -using rwresult = int; - // On Windows the count argument to read and write is unsigned, so convert // it from size_t preventing integer overflow. inline unsigned convert_rwcount(std::size_t count) { return count <= UINT_MAX ? static_cast(count) : UINT_MAX; } #elif FMT_USE_FCNTL -// Return type of read and write functions. -using rwresult = ssize_t; - inline std::size_t convert_rwcount(std::size_t count) { return count; } #endif } // namespace @@ -266,6 +260,14 @@ long long file::size() const { # endif } + +// Return type of read and write functions. +#ifdef _WIN32 +#define rwresult int +#elif FMT_USE_FCNTL +#define rwresult ssize_t +#endif + std::size_t file::read(void* buffer, std::size_t count) { rwresult result = 0; FMT_RETRY(result, FMT_POSIX_CALL(read(fd_, buffer, convert_rwcount(count)))); @@ -282,6 +284,8 @@ std::size_t file::write(const void* buffer, std::size_t count) { return detail::to_unsigned(result); } +#undef rwresult + file file::dup(int fd) { // Don't retry as dup doesn't return EINTR. // http://pubs.opengroup.org/onlinepubs/009695399/functions/dup.html