From 08cc9481653abc3a6a8bdc2419dcb8d71e39ca31 Mon Sep 17 00:00:00 2001 From: LoveSy Date: Thu, 13 Jun 2024 13:47:11 +0000 Subject: [PATCH] Merge FMT_MODULE and FMT_IMPORT_STD --- include/fmt/args.h | 2 +- include/fmt/base.h | 8 ++--- include/fmt/chrono.h | 2 +- include/fmt/compile.h | 2 +- include/fmt/format-inl.h | 11 +++--- include/fmt/format.h | 7 ++-- include/fmt/os.h | 8 ++--- include/fmt/ostream.h | 2 +- include/fmt/printf.h | 2 +- include/fmt/ranges.h | 2 +- include/fmt/std.h | 4 +-- include/fmt/xchar.h | 5 ++- src/fmt.cc | 2 ++ src/os.cc | 74 +++++++++++++++++++++------------------- 14 files changed, 64 insertions(+), 67 deletions(-) diff --git a/include/fmt/args.h b/include/fmt/args.h index d45b965bc51a..31a60e8faf1a 100644 --- a/include/fmt/args.h +++ b/include/fmt/args.h @@ -8,7 +8,7 @@ #ifndef FMT_ARGS_H_ #define FMT_ARGS_H_ -#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +#ifndef FMT_MODULE # include // std::reference_wrapper # include // std::unique_ptr # include diff --git a/include/fmt/base.h b/include/fmt/base.h index 396d268faaab..0e9758b70b2f 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -8,19 +8,19 @@ #ifndef FMT_BASE_H_ #define FMT_BASE_H_ +#if defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +# define FMT_MODULE +#endif + // c headers are preferable for performance reasons #ifndef FMT_MODULE # include // CHAR_BIT # include // FILE # include // strlen -#endif -#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) // is also included transitively from . # include // std::byte # include // std::enable_if -#elif !defined(FMT_MODULE) -import std; #endif // The fmt library version in the form major * 10000 + minor * 100 + patch. diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index 3406a4a673f2..c93123fd3353 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -8,7 +8,7 @@ #ifndef FMT_CHRONO_H_ #define FMT_CHRONO_H_ -#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +#ifndef FMT_MODULE # include # include # include // std::isfinite diff --git a/include/fmt/compile.h b/include/fmt/compile.h index a98e1bc0531b..b2afc2c309f4 100644 --- a/include/fmt/compile.h +++ b/include/fmt/compile.h @@ -8,7 +8,7 @@ #ifndef FMT_COMPILE_H_ #define FMT_COMPILE_H_ -#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +#ifndef FMT_MODULE # include // std::back_inserter #endif diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index db6d74d4c95f..0750e7fcb947 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -8,17 +8,14 @@ #ifndef FMT_FORMAT_INL_H_ #define FMT_FORMAT_INL_H_ -#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) -# include -# include -# include -#endif - #ifndef FMT_MODULE +# include # include // errno # include +# include +# include -# if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) && !defined(FMT_IMPORT_STD) +# if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) # include # endif #endif diff --git a/include/fmt/format.h b/include/fmt/format.h index bfdb2e0e3fe8..38ea62194627 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -38,7 +38,7 @@ # define FMT_REMOVE_TRANSITIVE_INCLUDES #endif -#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +#ifndef FMT_MODULE # include // std::signbit # include // uint32_t # include // std::memcpy @@ -56,15 +56,14 @@ #include "base.h" // Checking FMT_CPLUSPLUS for warning suppression in MSVC. -#if FMT_HAS_INCLUDE() && FMT_CPLUSPLUS > 201703L && \ - !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +#if FMT_HAS_INCLUDE() && FMT_CPLUSPLUS > 201703L && !defined(FMT_MODULE) # include // std::bit_cast #endif // libc++ supports string_view in pre-c++17. #if FMT_HAS_INCLUDE() && \ (FMT_CPLUSPLUS >= 201703L || defined(_LIBCPP_VERSION)) -# if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +# if !defined(FMT_MODULE) # include # endif # define FMT_USE_STRING_VIEW diff --git a/include/fmt/os.h b/include/fmt/os.h index 5462661a026a..5344e5c2378b 100644 --- a/include/fmt/os.h +++ b/include/fmt/os.h @@ -10,11 +10,9 @@ #ifndef FMT_MODULE # include -# ifndef FMT_IMPORT_STD -# include -# include -# include // std::system_error -# endif +# include +# include +# include // std::system_error #endif #include "format.h" diff --git a/include/fmt/ostream.h b/include/fmt/ostream.h index 0be26709dcd0..98faef659f52 100644 --- a/include/fmt/ostream.h +++ b/include/fmt/ostream.h @@ -8,7 +8,7 @@ #ifndef FMT_OSTREAM_H_ #define FMT_OSTREAM_H_ -#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +#ifndef FMT_MODULE # include // std::filebuf #endif diff --git a/include/fmt/printf.h b/include/fmt/printf.h index 3b2b9b4be8b3..ee4b06fd5e72 100644 --- a/include/fmt/printf.h +++ b/include/fmt/printf.h @@ -8,7 +8,7 @@ #ifndef FMT_PRINTF_H_ #define FMT_PRINTF_H_ -#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +#ifndef FMT_MODULE # include // std::max # include // std::numeric_limits #endif diff --git a/include/fmt/ranges.h b/include/fmt/ranges.h index f3377ab5c312..66329aae71ed 100644 --- a/include/fmt/ranges.h +++ b/include/fmt/ranges.h @@ -8,7 +8,7 @@ #ifndef FMT_RANGES_H_ #define FMT_RANGES_H_ -#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +#ifndef FMT_MODULE # include # include # include diff --git a/include/fmt/std.h b/include/fmt/std.h index 5f1f403c41ee..01635e18a43b 100644 --- a/include/fmt/std.h +++ b/include/fmt/std.h @@ -8,7 +8,7 @@ #ifndef FMT_STD_H_ #define FMT_STD_H_ -#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +#ifndef FMT_MODULE # include # include # include @@ -29,7 +29,7 @@ # include #endif -#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +#ifndef FMT_MODULE // Checking FMT_CPLUSPLUS for warning suppression in MSVC. # if FMT_CPLUSPLUS >= 201703L # if FMT_HAS_INCLUDE() diff --git a/include/fmt/xchar.h b/include/fmt/xchar.h index 31bdccdb97ee..6c19bf3e722f 100644 --- a/include/fmt/xchar.h +++ b/include/fmt/xchar.h @@ -8,7 +8,7 @@ #ifndef FMT_XCHAR_H_ #define FMT_XCHAR_H_ -#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +#ifndef FMT_MODULE # include #endif @@ -16,8 +16,7 @@ #include "format.h" #include "ranges.h" -#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) && !defined(FMT_IMPORT_STD) && \ - !defined(FMT_MODULE) +#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) && !defined(FMT_MODULE) # include #endif diff --git a/src/fmt.cc b/src/fmt.cc index 108f15312b3b..28f4bb821ad8 100644 --- a/src/fmt.cc +++ b/src/fmt.cc @@ -41,6 +41,8 @@ module; # include # include # include + +import std; #endif #include #include diff --git a/src/os.cc b/src/os.cc index 81177b263e48..7bc18e2a8e51 100644 --- a/src/os.cc +++ b/src/os.cc @@ -12,47 +12,49 @@ #include "fmt/os.h" -#include +#ifndef FMT_MODULE +# include -#if FMT_USE_FCNTL -# include -# include - -# ifdef _WRS_KERNEL // VxWorks7 kernel -# include // getpagesize -# endif +# if FMT_USE_FCNTL +# include +# include -# ifndef _WIN32 -# include -# else -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN +# ifdef _WRS_KERNEL // VxWorks7 kernel +# include // getpagesize # endif -# include -# ifndef S_IRUSR -# define S_IRUSR _S_IREAD -# endif -# ifndef S_IWUSR -# define S_IWUSR _S_IWRITE -# endif -# ifndef S_IRGRP -# define S_IRGRP 0 -# endif -# ifndef S_IWGRP -# define S_IWGRP 0 -# endif -# ifndef S_IROTH -# define S_IROTH 0 -# endif -# ifndef S_IWOTH -# define S_IWOTH 0 -# endif -# endif // _WIN32 -#endif // FMT_USE_FCNTL +# ifndef _WIN32 +# include +# else +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +# include -#ifdef _WIN32 -# include +# ifndef S_IRUSR +# define S_IRUSR _S_IREAD +# endif +# ifndef S_IWUSR +# define S_IWUSR _S_IWRITE +# endif +# ifndef S_IRGRP +# define S_IRGRP 0 +# endif +# ifndef S_IWGRP +# define S_IWGRP 0 +# endif +# ifndef S_IROTH +# define S_IROTH 0 +# endif +# ifndef S_IWOTH +# define S_IWOTH 0 +# endif +# endif // _WIN32 +# endif // FMT_USE_FCNTL + +# ifdef _WIN32 +# include +# endif #endif namespace {