Skip to content

Commit

Permalink
Fix TU-local entity exposition errors in GCC 15
Browse files Browse the repository at this point in the history
  • Loading branch information
tkhyn committed Feb 13, 2025
1 parent 5928feb commit 87f88bf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/fmt/format-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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}};
Expand Down
16 changes: 10 additions & 6 deletions src/os.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned>(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
Expand Down Expand Up @@ -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))));
Expand All @@ -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
Expand Down

0 comments on commit 87f88bf

Please sign in to comment.