Skip to content

Commit 34f6711

Browse files
committed
third_party: spdlog: upgrade version to 1.15.1
1 parent 383a3fb commit 34f6711

17 files changed

+2983
-3231
lines changed

third_party/spdlog/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
This code is from [spdlog](https://github.com/gabime/spdlog).
22

3-
tag: 1.15.0
3+
tag: 1.15.1

third_party/spdlog/common.h

+1-6
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,7 @@ SPDLOG_CONSTEXPR_FUNC spdlog::wstring_view_t to_string_view(spdlog::wstring_view
364364
}
365365
#endif
366366

367-
#ifndef SPDLOG_USE_STD_FORMAT
368-
template <typename T, typename... Args>
369-
inline fmt::basic_string_view<T> to_string_view(fmt::basic_format_string<T, Args...> fmt) {
370-
return fmt;
371-
}
372-
#elif __cpp_lib_format >= 202207L
367+
#if defined(SPDLOG_USE_STD_FORMAT) && __cpp_lib_format >= 202207L
373368
template <typename T, typename... Args>
374369
SPDLOG_CONSTEXPR_FUNC std::basic_string_view<T> to_string_view(
375370
std::basic_format_string<T, Args...> fmt) SPDLOG_NOEXCEPT {

third_party/spdlog/details/file_helper-inl.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ SPDLOG_INLINE void file_helper::write(const memory_buf_t &buf) {
101101
if (fd_ == nullptr) return;
102102
size_t msg_size = buf.size();
103103
auto data = buf.data();
104-
if (std::fwrite(data, 1, msg_size, fd_) != msg_size) {
104+
105+
if (!details::os::fwrite_bytes(data, msg_size, fd_)) {
105106
throw_spdlog_ex("Failed writing to file " + os::filename_to_str(filename_), errno);
106107
}
107108
}

third_party/spdlog/details/os-inl.h

+12
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,18 @@ SPDLOG_INLINE bool fsync(FILE *fp) {
589589
#endif
590590
}
591591

592+
// Do non-locking fwrite if possible by the os or use the regular locking fwrite
593+
// Return true on success.
594+
SPDLOG_INLINE bool fwrite_bytes(const void *ptr, const size_t n_bytes, FILE *fp) {
595+
#if defined(_WIN32) && defined(SPDLOG_FWRITE_UNLOCKED)
596+
return _fwrite_nolock(ptr, 1, n_bytes, fp) == n_bytes;
597+
#elif defined(SPDLOG_FWRITE_UNLOCKED)
598+
return ::fwrite_unlocked(ptr, 1, n_bytes, fp) == n_bytes;
599+
#else
600+
return std::fwrite(ptr, 1, n_bytes, fp) == n_bytes;
601+
#endif
602+
}
603+
592604
} // namespace os
593605
} // namespace details
594606
} // namespace spdlog

third_party/spdlog/details/os.h

+4
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ SPDLOG_API std::string getenv(const char *field);
114114
// Return true on success.
115115
SPDLOG_API bool fsync(FILE *fp);
116116

117+
// Do non-locking fwrite if possible by the os or use the regular locking fwrite
118+
// Return true on success.
119+
SPDLOG_API bool fwrite_bytes(const void *ptr, const size_t n_bytes, FILE *fp);
120+
117121
} // namespace os
118122
} // namespace details
119123
} // namespace spdlog

0 commit comments

Comments
 (0)