Fix modular build on clang

This commit is contained in:
Victor Zverovich 2023-04-10 09:43:56 -07:00
parent 119c6bd16f
commit c98e5a08a4
12 changed files with 99 additions and 117 deletions

View File

@ -460,7 +460,7 @@ auto write(OutputIt out, const std::tm& time, const std::locale& loc,
} // namespace detail } // namespace detail
FMT_EXPORT_BEGIN FMT_BEGIN_EXPORT
/** /**
Converts given time since epoch as ``std::time_t`` value into calendar time, Converts given time since epoch as ``std::time_t`` value into calendar time,
@ -2288,7 +2288,7 @@ template <typename Char> struct formatter<std::tm, Char> {
} }
}; };
FMT_EXPORT_END FMT_END_EXPORT
FMT_END_NAMESPACE FMT_END_NAMESPACE
#endif // FMT_CHRONO_H_ #endif // FMT_CHRONO_H_

View File

@ -11,7 +11,7 @@
#include "format.h" #include "format.h"
FMT_BEGIN_NAMESPACE FMT_BEGIN_NAMESPACE
FMT_EXPORT_BEGIN FMT_BEGIN_EXPORT
enum class color : uint32_t { enum class color : uint32_t {
alice_blue = 0xF0F8FF, // rgb(240,248,255) alice_blue = 0xF0F8FF, // rgb(240,248,255)
@ -627,7 +627,7 @@ FMT_CONSTEXPR auto styled(const T& value, text_style ts)
return detail::styled_arg<remove_cvref_t<T>>{value, ts}; return detail::styled_arg<remove_cvref_t<T>>{value, ts};
} }
FMT_EXPORT_END FMT_END_EXPORT
FMT_END_NAMESPACE FMT_END_NAMESPACE
#endif // FMT_COLOR_H_ #endif // FMT_COLOR_H_

View File

@ -497,7 +497,7 @@ constexpr auto compile(S format_str) {
#endif // defined(__cpp_if_constexpr) && defined(__cpp_return_type_deduction) #endif // defined(__cpp_if_constexpr) && defined(__cpp_return_type_deduction)
} // namespace detail } // namespace detail
FMT_EXPORT_BEGIN FMT_BEGIN_EXPORT
#if defined(__cpp_if_constexpr) && defined(__cpp_return_type_deduction) #if defined(__cpp_if_constexpr) && defined(__cpp_return_type_deduction)
@ -601,7 +601,7 @@ template <detail_exported::fixed_string Str> constexpr auto operator""_cf() {
} // namespace literals } // namespace literals
#endif #endif
FMT_EXPORT_END FMT_END_EXPORT
FMT_END_NAMESPACE FMT_END_NAMESPACE
#endif // FMT_COMPILE_H_ #endif // FMT_COMPILE_H_

View File

@ -183,21 +183,17 @@
#ifndef FMT_MODULE_EXPORT #ifndef FMT_MODULE_EXPORT
# define FMT_MODULE_EXPORT # define FMT_MODULE_EXPORT
# define FMT_EXPORT_BEGIN # define FMT_BEGIN_EXPORT
# define FMT_EXPORT_END # define FMT_END_EXPORT
# define FMT_BEGIN_DETAIL_NAMESPACE namespace detail {
# define FMT_END_DETAIL_NAMESPACE }
#endif #endif
#if !defined(FMT_HEADER_ONLY) && defined(_WIN32) #if !defined(FMT_HEADER_ONLY) && defined(_WIN32)
# define FMT_CLASS_API FMT_MSC_WARNING(suppress : 4275)
# ifdef FMT_LIB_EXPORT # ifdef FMT_LIB_EXPORT
# define FMT_API __declspec(dllexport) # define FMT_API __declspec(dllexport)
# elif defined(FMT_SHARED) # elif defined(FMT_SHARED)
# define FMT_API __declspec(dllimport) # define FMT_API __declspec(dllimport)
# endif # endif
#else #else
# define FMT_CLASS_API
# if defined(FMT_LIB_EXPORT) || defined(FMT_SHARED) # if defined(FMT_LIB_EXPORT) || defined(FMT_SHARED)
# if defined(__GNUC__) || defined(__clang__) # if defined(__GNUC__) || defined(__clang__)
# define FMT_API __attribute__((visibility("default"))) # define FMT_API __attribute__((visibility("default")))
@ -262,7 +258,6 @@ FMT_GCC_PRAGMA("GCC optimize(\"Og\")")
#endif #endif
FMT_BEGIN_NAMESPACE FMT_BEGIN_NAMESPACE
FMT_EXPORT_BEGIN
// Implementations of enable_if_t and other metafunctions for older systems. // Implementations of enable_if_t and other metafunctions for older systems.
template <bool B, typename T = void> template <bool B, typename T = void>
@ -300,8 +295,7 @@ inline auto format_as(std::byte b) -> unsigned char {
} }
#endif #endif
FMT_BEGIN_DETAIL_NAMESPACE namespace detail {
// Suppresses "unused variable" warnings with the method described in // Suppresses "unused variable" warnings with the method described in
// https://herbsutter.com/2009/10/18/mailbag-shutting-up-compiler-warnings/. // https://herbsutter.com/2009/10/18/mailbag-shutting-up-compiler-warnings/.
// (void)var does not work on many Intel compilers. // (void)var does not work on many Intel compilers.
@ -391,7 +385,7 @@ FMT_CONSTEXPR inline auto is_utf8() -> bool {
return FMT_UNICODE || (sizeof(section) == 3 && uchar(section[0]) == 0xC2 && return FMT_UNICODE || (sizeof(section) == 3 && uchar(section[0]) == 0xC2 &&
uchar(section[1]) == 0xA7); uchar(section[1]) == 0xA7);
} }
FMT_END_DETAIL_NAMESPACE } // namespace detail
/** /**
An implementation of ``std::basic_string_view`` for pre-C++17. It provides a An implementation of ``std::basic_string_view`` for pre-C++17. It provides a
@ -508,7 +502,7 @@ using string_view = basic_string_view<char>;
template <typename T> struct is_char : std::false_type {}; template <typename T> struct is_char : std::false_type {};
template <> struct is_char<char> : std::true_type {}; template <> struct is_char<char> : std::true_type {};
FMT_BEGIN_DETAIL_NAMESPACE namespace detail {
// A base class for compile-time strings. // A base class for compile-time strings.
struct compile_string {}; struct compile_string {};
@ -640,7 +634,7 @@ struct error_handler {
throw_format_error(message); throw_format_error(message);
} }
}; };
FMT_END_DETAIL_NAMESPACE } // namespace detail
/** String's character type. */ /** String's character type. */
template <typename S> using char_t = typename detail::char_t_impl<S>::type; template <typename S> using char_t = typename detail::char_t_impl<S>::type;
@ -719,7 +713,7 @@ template <typename Char> class basic_format_parse_context {
using format_parse_context = basic_format_parse_context<char>; using format_parse_context = basic_format_parse_context<char>;
FMT_BEGIN_DETAIL_NAMESPACE namespace detail {
// A parse context with extra data used only in compile-time checks. // A parse context with extra data used only in compile-time checks.
template <typename Char> template <typename Char>
class compile_parse_context : public basic_format_parse_context<Char> { class compile_parse_context : public basic_format_parse_context<Char> {
@ -757,7 +751,7 @@ class compile_parse_context : public basic_format_parse_context<Char> {
#endif #endif
} }
}; };
FMT_END_DETAIL_NAMESPACE } // namespace detail
template <typename Char> template <typename Char>
FMT_CONSTEXPR void basic_format_parse_context<Char>::do_check_arg_id(int id) { FMT_CONSTEXPR void basic_format_parse_context<Char>::do_check_arg_id(int id) {
@ -805,7 +799,7 @@ struct is_contiguous<std::basic_string<Char>> : std::true_type {};
class appender; class appender;
FMT_BEGIN_DETAIL_NAMESPACE namespace detail {
template <typename Context, typename T> template <typename Context, typename T>
constexpr auto has_const_formatter_impl(T*) constexpr auto has_const_formatter_impl(T*)
@ -1481,8 +1475,7 @@ enum { packed_arg_bits = 4 };
enum { max_packed_args = 62 / packed_arg_bits }; enum { max_packed_args = 62 / packed_arg_bits };
enum : unsigned long long { is_unpacked_bit = 1ULL << 63 }; enum : unsigned long long { is_unpacked_bit = 1ULL << 63 };
enum : unsigned long long { has_named_args_bit = 1ULL << 62 }; enum : unsigned long long { has_named_args_bit = 1ULL << 62 };
} // namespace detail
FMT_END_DETAIL_NAMESPACE
// An output iterator that appends to a buffer. // An output iterator that appends to a buffer.
// It is used to reduce symbol sizes for the common case. // It is used to reduce symbol sizes for the common case.
@ -1601,7 +1594,7 @@ FMT_CONSTEXPR FMT_INLINE auto visit_format_arg(
return vis(monostate()); return vis(monostate());
} }
FMT_BEGIN_DETAIL_NAMESPACE namespace detail {
template <typename Char, typename InputIt> template <typename Char, typename InputIt>
auto copy_str(InputIt begin, InputIt end, appender out) -> appender { auto copy_str(InputIt begin, InputIt end, appender out) -> appender {
@ -1716,7 +1709,7 @@ template <bool IS_PACKED, typename Context, type, typename T,
FMT_CONSTEXPR inline auto make_arg(T&& value) -> basic_format_arg<Context> { FMT_CONSTEXPR inline auto make_arg(T&& value) -> basic_format_arg<Context> {
return make_arg<Context>(value); return make_arg<Context>(value);
} }
FMT_END_DETAIL_NAMESPACE } // namespace detail
// Formatting context. // Formatting context.
template <typename OutputIt, typename Char> class basic_format_context { template <typename OutputIt, typename Char> class basic_format_context {
@ -2005,7 +1998,7 @@ enum type FMT_ENUM_UNDERLYING_TYPE(unsigned char){none, minus, plus, space};
} }
using sign_t = sign::type; using sign_t = sign::type;
FMT_BEGIN_DETAIL_NAMESPACE namespace detail {
// Workaround an array initialization issue in gcc 4.8. // Workaround an array initialization issue in gcc 4.8.
template <typename Char> struct fill_t { template <typename Char> struct fill_t {
@ -2030,7 +2023,7 @@ template <typename Char> struct fill_t {
return data_[index]; return data_[index];
} }
}; };
FMT_END_DETAIL_NAMESPACE } // namespace detail
enum class presentation_type : unsigned char { enum class presentation_type : unsigned char {
none, none,
@ -2075,7 +2068,7 @@ template <typename Char = char> struct format_specs {
localized(false) {} localized(false) {}
}; };
FMT_BEGIN_DETAIL_NAMESPACE namespace detail {
enum class arg_id_kind { none, index, name }; enum class arg_id_kind { none, index, name };
@ -2687,7 +2680,9 @@ FMT_API void vprint_mojibake(std::FILE*, string_view, format_args);
#ifndef _WIN32 #ifndef _WIN32
inline void vprint_mojibake(std::FILE*, string_view, format_args) {} inline void vprint_mojibake(std::FILE*, string_view, format_args) {}
#endif #endif
FMT_END_DETAIL_NAMESPACE } // namespace detail
FMT_BEGIN_EXPORT
// A formatter specialization for natively supported types. // A formatter specialization for natively supported types.
template <typename T, typename Char> template <typename T, typename Char>
@ -2940,7 +2935,7 @@ FMT_INLINE void println(format_string<T...> fmt, T&&... args) {
return fmt::println(stdout, fmt, std::forward<T>(args)...); return fmt::println(stdout, fmt, std::forward<T>(args)...);
} }
FMT_EXPORT_END FMT_END_EXPORT
FMT_GCC_PRAGMA("GCC pop_options") FMT_GCC_PRAGMA("GCC pop_options")
FMT_END_NAMESPACE FMT_END_NAMESPACE

View File

@ -144,10 +144,6 @@ FMT_API FMT_FUNC auto format_facet<std::locale>::do_put(
} }
#endif #endif
#if !FMT_MSC_VERSION
FMT_API FMT_FUNC format_error::~format_error() noexcept = default;
#endif
FMT_FUNC std::system_error vsystem_error(int error_code, string_view format_str, FMT_FUNC std::system_error vsystem_error(int error_code, string_view format_str,
format_args args) { format_args args) {
auto ec = std::error_code(error_code, std::generic_category()); auto ec = std::error_code(error_code, std::generic_category());

View File

@ -48,6 +48,11 @@
#include "core.h" #include "core.h"
#ifndef FMT_BEGIN_DETAIL_NAMESPACE
# define FMT_BEGIN_DETAIL_NAMESPACE namespace detail {
# define FMT_END_DETAIL_NAMESPACE }
#endif
#if FMT_HAS_CPP17_ATTRIBUTE(fallthrough) #if FMT_HAS_CPP17_ATTRIBUTE(fallthrough)
# define FMT_FALLTHROUGH [[fallthrough]] # define FMT_FALLTHROUGH [[fallthrough]]
#elif defined(__clang__) #elif defined(__clang__)
@ -97,12 +102,6 @@
# define FMT_NOINLINE # define FMT_NOINLINE
#endif #endif
#if FMT_MSC_VERSION
# define FMT_MSC_DEFAULT = default
#else
# define FMT_MSC_DEFAULT
#endif
#ifndef FMT_THROW #ifndef FMT_THROW
# if FMT_EXCEPTIONS # if FMT_EXCEPTIONS
# if FMT_MSC_VERSION || defined(__NVCC__) # if FMT_MSC_VERSION || defined(__NVCC__)
@ -893,7 +892,7 @@ template <typename T>
struct is_locale<T, void_t<decltype(T::classic())>> : std::true_type {}; struct is_locale<T, void_t<decltype(T::classic())>> : std::true_type {};
} // namespace detail } // namespace detail
FMT_EXPORT_BEGIN FMT_BEGIN_EXPORT
// The number of characters to store in the basic_memory_buffer object itself // The number of characters to store in the basic_memory_buffer object itself
// to avoid dynamic memory allocation. // to avoid dynamic memory allocation.
@ -936,7 +935,27 @@ class basic_memory_buffer final : public detail::buffer<T> {
} }
protected: protected:
FMT_CONSTEXPR20 void grow(size_t size) override; FMT_CONSTEXPR20 void grow(size_t size) override {
detail::abort_fuzzing_if(size > 5000);
const size_t max_size = std::allocator_traits<Allocator>::max_size(alloc_);
size_t old_capacity = this->capacity();
size_t new_capacity = old_capacity + old_capacity / 2;
if (size > new_capacity)
new_capacity = size;
else if (new_capacity > max_size)
new_capacity = size > max_size ? size : max_size;
T* old_data = this->data();
T* new_data =
std::allocator_traits<Allocator>::allocate(alloc_, new_capacity);
// The following code doesn't throw, so the raw pointer above doesn't leak.
std::uninitialized_copy(old_data, old_data + this->size(),
detail::make_checked(new_data, new_capacity));
this->set(new_data, new_capacity);
// deallocate must not throw according to the standard, but even if it does,
// the buffer already uses the new storage and will deallocate it in
// destructor.
if (old_data != store_) alloc_.deallocate(old_data, old_capacity);
}
public: public:
using value_type = T; using value_type = T;
@ -1013,30 +1032,6 @@ class basic_memory_buffer final : public detail::buffer<T> {
} }
}; };
template <typename T, size_t SIZE, typename Allocator>
FMT_CONSTEXPR20 void basic_memory_buffer<T, SIZE, Allocator>::grow(
size_t size) {
detail::abort_fuzzing_if(size > 5000);
const size_t max_size = std::allocator_traits<Allocator>::max_size(alloc_);
size_t old_capacity = this->capacity();
size_t new_capacity = old_capacity + old_capacity / 2;
if (size > new_capacity)
new_capacity = size;
else if (new_capacity > max_size)
new_capacity = size > max_size ? size : max_size;
T* old_data = this->data();
T* new_data =
std::allocator_traits<Allocator>::allocate(alloc_, new_capacity);
// The following code doesn't throw, so the raw pointer above doesn't leak.
std::uninitialized_copy(old_data, old_data + this->size(),
detail::make_checked(new_data, new_capacity));
this->set(new_data, new_capacity);
// deallocate must not throw according to the standard, but even if it does,
// the buffer already uses the new storage and will deallocate it in
// destructor.
if (old_data != store_) alloc_.deallocate(old_data, old_capacity);
}
using memory_buffer = basic_memory_buffer<char>; using memory_buffer = basic_memory_buffer<char>;
template <typename T, size_t SIZE, typename Allocator> template <typename T, size_t SIZE, typename Allocator>
@ -1050,16 +1045,15 @@ FMT_API bool write_console(std::FILE* f, string_view text);
FMT_API void print(std::FILE*, string_view); FMT_API void print(std::FILE*, string_view);
} // namespace detail } // namespace detail
// Suppress a misleading warning in older versions of clang.
#if FMT_CLANG_VERSION
# pragma clang diagnostic ignored "-Wweak-vtables"
#endif
/** An error reported from a formatting function. */ /** An error reported from a formatting function. */
FMT_CLASS_API
class FMT_API format_error : public std::runtime_error { class FMT_API format_error : public std::runtime_error {
public: public:
using std::runtime_error::runtime_error; using std::runtime_error::runtime_error;
format_error(const format_error&) = default;
format_error& operator=(const format_error&) = default;
format_error(format_error&&) = default;
format_error& operator=(format_error&&) = default;
~format_error() noexcept override FMT_MSC_DEFAULT;
}; };
namespace detail_exported { namespace detail_exported {
@ -4235,26 +4229,6 @@ class format_int {
auto str() const -> std::string { return std::string(str_, size()); } auto str() const -> std::string { return std::string(str_, size()); }
}; };
template <typename T, typename Char>
template <typename FormatContext>
FMT_CONSTEXPR FMT_INLINE auto
formatter<T, Char,
enable_if_t<detail::type_constant<T, Char>::value !=
detail::type::custom_type>>::format(const T& val,
FormatContext& ctx)
const -> decltype(ctx.out()) {
if (specs_.width_ref.kind != detail::arg_id_kind::none ||
specs_.precision_ref.kind != detail::arg_id_kind::none) {
auto specs = specs_;
detail::handle_dynamic_spec<detail::width_checker>(specs.width,
specs.width_ref, ctx);
detail::handle_dynamic_spec<detail::precision_checker>(
specs.precision, specs.precision_ref, ctx);
return detail::write<Char>(ctx.out(), val, specs, ctx.locale());
}
return detail::write<Char>(ctx.out(), val, specs_, ctx.locale());
}
template <typename T, typename Char> template <typename T, typename Char>
struct formatter<T, Char, enable_if_t<detail::has_format_as<T>::value>> struct formatter<T, Char, enable_if_t<detail::has_format_as<T>::value>>
: private formatter<detail::format_as_t<T>> { : private formatter<detail::format_as_t<T>> {
@ -4678,7 +4652,28 @@ FMT_NODISCARD FMT_INLINE auto formatted_size(const Locale& loc,
return buf.count(); return buf.count();
} }
FMT_EXPORT_END FMT_END_EXPORT
template <typename T, typename Char>
template <typename FormatContext>
FMT_CONSTEXPR FMT_INLINE auto
formatter<T, Char,
enable_if_t<detail::type_constant<T, Char>::value !=
detail::type::custom_type>>::format(const T& val,
FormatContext& ctx)
const -> decltype(ctx.out()) {
if (specs_.width_ref.kind != detail::arg_id_kind::none ||
specs_.precision_ref.kind != detail::arg_id_kind::none) {
auto specs = specs_;
detail::handle_dynamic_spec<detail::width_checker>(specs.width,
specs.width_ref, ctx);
detail::handle_dynamic_spec<detail::precision_checker>(
specs.precision, specs.precision_ref, ctx);
return detail::write<Char>(ctx.out(), val, specs, ctx.locale());
}
return detail::write<Char>(ctx.out(), val, specs_, ctx.locale());
}
FMT_END_NAMESPACE FMT_END_NAMESPACE
#ifdef FMT_HEADER_ONLY #ifdef FMT_HEADER_ONLY

View File

@ -71,7 +71,7 @@
#define FMT_RETRY(result, expression) FMT_RETRY_VAL(result, expression, -1) #define FMT_RETRY(result, expression) FMT_RETRY_VAL(result, expression, -1)
FMT_BEGIN_NAMESPACE FMT_BEGIN_NAMESPACE
FMT_EXPORT_BEGIN FMT_BEGIN_EXPORT
/** /**
\rst \rst
@ -465,7 +465,7 @@ inline ostream output_file(cstring_view path, T... params) {
} }
#endif // FMT_USE_FCNTL #endif // FMT_USE_FCNTL
FMT_EXPORT_END FMT_END_EXPORT
FMT_END_NAMESPACE FMT_END_NAMESPACE
#endif // FMT_OS_H_ #endif // FMT_OS_H_

View File

@ -14,7 +14,7 @@
#include "format.h" #include "format.h"
FMT_BEGIN_NAMESPACE FMT_BEGIN_NAMESPACE
FMT_EXPORT_BEGIN FMT_BEGIN_EXPORT
template <typename T> struct printf_formatter { printf_formatter() = delete; }; template <typename T> struct printf_formatter { printf_formatter() = delete; };
@ -673,7 +673,7 @@ inline auto printf(const S& fmt, const T&... args) -> int {
fmt::make_format_args<basic_printf_context_t<char_t<S>>>(args...)); fmt::make_format_args<basic_printf_context_t<char_t<S>>>(args...));
} }
FMT_EXPORT_END FMT_END_EXPORT
FMT_END_NAMESPACE FMT_END_NAMESPACE
#endif // FMT_PRINTF_H_ #endif // FMT_PRINTF_H_

View File

@ -683,7 +683,7 @@ struct formatter<T, Char,
} }
}; };
FMT_EXPORT_BEGIN FMT_BEGIN_EXPORT
/** /**
\rst \rst
@ -726,7 +726,7 @@ auto join(std::initializer_list<T> list, string_view sep)
return join(std::begin(list), std::end(list), sep); return join(std::begin(list), std::end(list), sep);
} }
FMT_EXPORT_END FMT_END_EXPORT
FMT_END_NAMESPACE FMT_END_NAMESPACE
#endif // FMT_RANGES_H_ #endif // FMT_RANGES_H_

View File

@ -37,7 +37,7 @@ inline auto write_loc(std::back_insert_iterator<detail::buffer<wchar_t>> out,
} }
} // namespace detail } // namespace detail
FMT_EXPORT_BEGIN FMT_BEGIN_EXPORT
using wstring_view = basic_string_view<wchar_t>; using wstring_view = basic_string_view<wchar_t>;
using wformat_parse_context = basic_format_parse_context<wchar_t>; using wformat_parse_context = basic_format_parse_context<wchar_t>;
@ -253,7 +253,7 @@ template <typename... T> void println(wformat_string<T...> fmt, T&&... args) {
template <typename T> inline auto to_wstring(const T& value) -> std::wstring { template <typename T> inline auto to_wstring(const T& value) -> std::wstring {
return format(FMT_STRING(L"{}"), value); return format(FMT_STRING(L"{}"), value);
} }
FMT_EXPORT_END FMT_END_EXPORT
FMT_END_NAMESPACE FMT_END_NAMESPACE
#endif // FMT_XCHAR_H_ #endif // FMT_XCHAR_H_

View File

@ -1,9 +1,5 @@
module; module;
#if !defined(WIN32_LEAN_AND_MEAN) && defined(_WIN32)
# define WIN32_LEAN_AND_MEAN
#endif
// Put all implementation-provided headers into the global module fragment // Put all implementation-provided headers into the global module fragment
// to prevent attachment to this module. // to prevent attachment to this module.
#include <algorithm> #include <algorithm>
@ -54,22 +50,23 @@ module;
# endif # endif
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h> # include <windows.h>
#endif #endif
export module fmt; export module fmt;
#define FMT_MODULE_EXPORT export #define FMT_MODULE_EXPORT export
#define FMT_EXPORT_BEGIN export { #define FMT_BEGIN_EXPORT export {
#define FMT_EXPORT_END } #define FMT_END_EXPORT }
#define FMT_BEGIN_DETAIL_NAMESPACE \ #define FMT_BEGIN_DETAIL_NAMESPACE \
} \ } \
namespace detail { namespace detail {
#define FMT_END_DETAIL_NAMESPACE \ #define FMT_END_DETAIL_NAMESPACE \
} \ } \
export { export {
// all library-provided declarations and definitions // All library-provided declarations and definitions must be in the module
// must be in the module purview to be exported // purview to be exported.
#include "fmt/args.h" #include "fmt/args.h"
#include "fmt/chrono.h" #include "fmt/chrono.h"
#include "fmt/color.h" #include "fmt/color.h"

View File

@ -372,22 +372,22 @@ file file::open_windows_file(wcstring_view path, int oflag) {
} }
# endif # endif
#if !defined(__MSDOS__) # if !defined(__MSDOS__)
long getpagesize() { long getpagesize() {
# ifdef _WIN32 # ifdef _WIN32
SYSTEM_INFO si; SYSTEM_INFO si;
GetSystemInfo(&si); GetSystemInfo(&si);
return si.dwPageSize; return si.dwPageSize;
# else # else
long size = FMT_POSIX_CALL(sysconf(_SC_PAGESIZE)); long size = FMT_POSIX_CALL(sysconf(_SC_PAGESIZE));
if (size < 0) if (size < 0)
FMT_THROW(system_error(errno, FMT_STRING("cannot get memory page size"))); FMT_THROW(system_error(errno, FMT_STRING("cannot get memory page size")));
return size; return size;
# endif # endif
} }
#endif # endif
FMT_BEGIN_DETAIL_NAMESPACE namespace detail {
void file_buffer::grow(size_t) { void file_buffer::grow(size_t) {
if (this->size() == this->capacity()) flush(); if (this->size() == this->capacity()) flush();
@ -410,8 +410,7 @@ file_buffer::~file_buffer() {
flush(); flush();
delete[] data(); delete[] data();
} }
} // namespace detail
FMT_END_DETAIL_NAMESPACE
ostream::~ostream() = default; ostream::~ostream() = default;
#endif // FMT_USE_FCNTL #endif // FMT_USE_FCNTL