Skip to content

Commit

Permalink
Merge FMT_MODULE and FMT_IMPORT_STD
Browse files Browse the repository at this point in the history
  • Loading branch information
yujincheng08 committed Jun 14, 2024
1 parent 038afe7 commit b3abc6a
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 65 deletions.
2 changes: 1 addition & 1 deletion include/fmt/args.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef FMT_ARGS_H_
#define FMT_ARGS_H_

#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
#ifndef FMT_MODULE
# include <functional> // std::reference_wrapper
# include <memory> // std::unique_ptr
# include <vector>
Expand Down
8 changes: 4 additions & 4 deletions include/fmt/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <limits.h> // CHAR_BIT
# include <stdio.h> // FILE
# include <string.h> // strlen
#endif

#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
// <cstddef> is also included transitively from <type_traits>.
# include <cstddef> // std::byte
# include <type_traits> // std::enable_if
#elif !defined(FMT_MODULE)
import std;
#endif

// The fmt library version in the form major * 10000 + minor * 100 + patch.
Expand Down
2 changes: 1 addition & 1 deletion include/fmt/chrono.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef FMT_CHRONO_H_
#define FMT_CHRONO_H_

#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
#ifndef FMT_MODULE
# include <algorithm>
# include <chrono>
# include <cmath> // std::isfinite
Expand Down
2 changes: 1 addition & 1 deletion include/fmt/compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef FMT_COMPILE_H_
#define FMT_COMPILE_H_

#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
#ifndef FMT_MODULE
# include <iterator> // std::back_inserter
#endif

Expand Down
7 changes: 2 additions & 5 deletions include/fmt/format-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@
#ifndef FMT_FORMAT_INL_H_
#define FMT_FORMAT_INL_H_

#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
#ifndef FMT_MODULE
# include <algorithm>
# include <cmath>
# include <exception>
#endif

#ifndef FMT_MODULE
# include <cerrno> // errno
# include <climits>

# if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) && !defined(FMT_IMPORT_STD)
# if !defined(FMT_STATIC_THOUSANDS_SEPARATOR)
# include <locale>
# endif
#endif
Expand Down
7 changes: 3 additions & 4 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
# define FMT_REMOVE_TRANSITIVE_INCLUDES
#endif

#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
#ifndef FMT_MODULE
# include <cmath> // std::signbit
# include <cstdint> // uint32_t
# include <cstring> // std::memcpy
Expand All @@ -56,15 +56,14 @@
#include "base.h"

// Checking FMT_CPLUSPLUS for warning suppression in MSVC.
#if FMT_HAS_INCLUDE(<bit>) && FMT_CPLUSPLUS > 201703L && \
!defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
#if FMT_HAS_INCLUDE(<bit>) && FMT_CPLUSPLUS > 201703L && !defined(FMT_MODULE)
# include <bit> // std::bit_cast
#endif

// libc++ supports string_view in pre-c++17.
#if FMT_HAS_INCLUDE(<string_view>) && \
(FMT_CPLUSPLUS >= 201703L || defined(_LIBCPP_VERSION))
# if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
# if !defined(FMT_MODULE)
# include <string_view>
# endif
# define FMT_USE_STRING_VIEW
Expand Down
8 changes: 3 additions & 5 deletions include/fmt/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@

#ifndef FMT_MODULE
# include <cerrno>
# ifndef FMT_IMPORT_STD
# include <cstddef>
# include <cstdio>
# include <system_error> // std::system_error
# endif
# include <cstddef>
# include <cstdio>
# include <system_error> // std::system_error
#endif

#include "format.h"
Expand Down
2 changes: 1 addition & 1 deletion include/fmt/ostream.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef FMT_OSTREAM_H_
#define FMT_OSTREAM_H_

#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
#ifndef FMT_MODULE
# include <fstream> // std::filebuf
#endif

Expand Down
2 changes: 1 addition & 1 deletion include/fmt/printf.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef FMT_PRINTF_H_
#define FMT_PRINTF_H_

#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
#ifndef FMT_MODULE
# include <algorithm> // std::max
# include <limits> // std::numeric_limits
#endif
Expand Down
2 changes: 1 addition & 1 deletion include/fmt/ranges.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef FMT_RANGES_H_
#define FMT_RANGES_H_

#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
#ifndef FMT_MODULE
# include <initializer_list>
# include <iterator>
# include <string>
Expand Down
4 changes: 2 additions & 2 deletions include/fmt/std.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef FMT_STD_H_
#define FMT_STD_H_

#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
#ifndef FMT_MODULE
# include <atomic>
# include <bitset>
# include <complex>
Expand All @@ -29,7 +29,7 @@
# include <version>
#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(<filesystem>)
Expand Down
5 changes: 2 additions & 3 deletions include/fmt/xchar.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@
#ifndef FMT_XCHAR_H_
#define FMT_XCHAR_H_

#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
#ifndef FMT_MODULE
# include <cwchar>
#endif

#include "color.h"
#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 <locale>
#endif

Expand Down
2 changes: 2 additions & 0 deletions src/fmt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ module;
# include <stdint.h>
# include <stdio.h>
# include <time.h>

import std;
#endif
#include <cerrno>
#include <climits>
Expand Down
74 changes: 38 additions & 36 deletions src/os.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,49 @@

#include "fmt/os.h"

#include <climits>
#ifndef FMT_MODULE
# include <climits>

#if FMT_USE_FCNTL
# include <sys/stat.h>
# include <sys/types.h>

# ifdef _WRS_KERNEL // VxWorks7 kernel
# include <ioLib.h> // getpagesize
# endif
# if FMT_USE_FCNTL
# include <sys/stat.h>
# include <sys/types.h>

# ifndef _WIN32
# include <unistd.h>
# else
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# ifdef _WRS_KERNEL // VxWorks7 kernel
# include <ioLib.h> // getpagesize
# endif
# include <io.h>

# 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 <unistd.h>
# else
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# include <io.h>

#ifdef _WIN32
# include <windows.h>
# 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 <windows.h>
# endif
#endif

namespace {
Expand Down

0 comments on commit b3abc6a

Please sign in to comment.