xref: /aosp_15_r20/external/fmtlib/src/fmt.cc (revision 5c90c05cd622c0a81b57953a4d343e0e489f2e08)
1 module;
2 
3 #ifdef _MSVC_LANG
4 #  define FMT_CPLUSPLUS _MSVC_LANG
5 #else
6 #  define FMT_CPLUSPLUS __cplusplus
7 #endif
8 
9 // Put all implementation-provided headers into the global module fragment
10 // to prevent attachment to this module.
11 #ifndef FMT_IMPORT_STD
12 #  include <algorithm>
13 #  include <bitset>
14 #  include <chrono>
15 #  include <cmath>
16 #  include <complex>
17 #  include <cstddef>
18 #  include <cstdint>
19 #  include <cstdio>
20 #  include <cstdlib>
21 #  include <cstring>
22 #  include <ctime>
23 #  include <exception>
24 #  if FMT_CPLUSPLUS > 202002L
25 #    include <expected>
26 #  endif
27 #  include <filesystem>
28 #  include <fstream>
29 #  include <functional>
30 #  include <iterator>
31 #  include <limits>
32 #  include <locale>
33 #  include <memory>
34 #  include <optional>
35 #  include <ostream>
36 #  include <source_location>
37 #  include <stdexcept>
38 #  include <string>
39 #  include <string_view>
40 #  include <system_error>
41 #  include <thread>
42 #  include <type_traits>
43 #  include <typeinfo>
44 #  include <utility>
45 #  include <variant>
46 #  include <vector>
47 #else
48 #  include <limits.h>
49 #  include <stdint.h>
50 #  include <stdio.h>
51 #  include <time.h>
52 #endif
53 #include <cerrno>
54 #include <climits>
55 #include <version>
56 
57 #if __has_include(<cxxabi.h>)
58 #  include <cxxabi.h>
59 #endif
60 #if defined(_MSC_VER) || defined(__MINGW32__)
61 #  include <intrin.h>
62 #endif
63 #if defined __APPLE__ || defined(__FreeBSD__)
64 #  include <xlocale.h>
65 #endif
66 #if __has_include(<winapifamily.h>)
67 #  include <winapifamily.h>
68 #endif
69 #if (__has_include(<fcntl.h>) || defined(__APPLE__) || \
70      defined(__linux__)) &&                            \
71     (!defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP))
72 #  include <fcntl.h>
73 #  include <sys/stat.h>
74 #  include <sys/types.h>
75 #  ifndef _WIN32
76 #    include <unistd.h>
77 #  else
78 #    include <io.h>
79 #  endif
80 #endif
81 #ifdef _WIN32
82 #  if defined(__GLIBCXX__)
83 #    include <ext/stdio_filebuf.h>
84 #    include <ext/stdio_sync_filebuf.h>
85 #  endif
86 #  define WIN32_LEAN_AND_MEAN
87 #  include <windows.h>
88 #endif
89 
90 export module fmt;
91 
92 #ifdef FMT_IMPORT_STD
93 import std;
94 #endif
95 
96 #define FMT_EXPORT export
97 #define FMT_BEGIN_EXPORT export {
98 #define FMT_END_EXPORT }
99 
100 // If you define FMT_ATTACH_TO_GLOBAL_MODULE
101 //  - all declarations are detached from module 'fmt'
102 //  - the module behaves like a traditional static library, too
103 //  - all library symbols are mangled traditionally
104 //  - you can mix TUs with either importing or #including the {fmt} API
105 #ifdef FMT_ATTACH_TO_GLOBAL_MODULE
106 extern "C++" {
107 #endif
108 
109 #ifndef FMT_OS
110 #  define FMT_OS 1
111 #endif
112 
113 // All library-provided declarations and definitions must be in the module
114 // purview to be exported.
115 #include "fmt/args.h"
116 #include "fmt/chrono.h"
117 #include "fmt/color.h"
118 #include "fmt/compile.h"
119 #include "fmt/format.h"
120 #if FMT_OS
121 #  include "fmt/os.h"
122 #endif
123 #include "fmt/ostream.h"
124 #include "fmt/printf.h"
125 #include "fmt/ranges.h"
126 #include "fmt/std.h"
127 #include "fmt/xchar.h"
128 
129 #ifdef FMT_ATTACH_TO_GLOBAL_MODULE
130 }
131 #endif
132 
133 // gcc doesn't yet implement private module fragments
134 #if !FMT_GCC_VERSION
135 module :private;
136 #endif
137 
138 #ifdef FMT_ATTACH_TO_GLOBAL_MODULE
139 extern "C++" {
140 #endif
141 
142 #if FMT_HAS_INCLUDE("format.cc")
143 #  include "format.cc"
144 #endif
145 #if FMT_OS && FMT_HAS_INCLUDE("os.cc")
146 #  include "os.cc"
147 #endif
148 
149 #ifdef FMT_ATTACH_TO_GLOBAL_MODULE
150 }
151 #endif
152