File tree Expand file tree Collapse file tree 16 files changed +161
-24
lines changed Expand file tree Collapse file tree 16 files changed +161
-24
lines changed Original file line number Diff line number Diff line change @@ -161,4 +161,17 @@ add_proxy_header_library(
161
161
libc.include .sys_auxv
162
162
)
163
163
164
+ add_header_library(wchar_overlay HDRS wchar_overlay.h)
165
+
166
+ add_proxy_header_library(
167
+ wchar_macros
168
+ HDRS
169
+ wchar_macros.h
170
+ DEPENDS
171
+ .wchar_overlay
172
+ FULL_BUILD_DEPENDS
173
+ libc.include .llvm-libc-macros .wchar_macros
174
+ libc.include .wchar
175
+ )
176
+
164
177
add_subdirectory (types)
Original file line number Diff line number Diff line change @@ -199,7 +199,6 @@ add_proxy_header_library(
199
199
libc.include .setjmp
200
200
)
201
201
202
-
203
202
add_proxy_header_library(
204
203
struct_msghdr
205
204
HDRS
@@ -226,3 +225,25 @@ add_proxy_header_library(
226
225
libc.include .llvm-libc-types.socklen_t
227
226
libc.include .sys_socket
228
227
)
228
+
229
+ add_proxy_header_library(
230
+ wchar_t
231
+ HDRS
232
+ wchar_t.h
233
+ DEPENDS
234
+ libc.hdr.wchar_overlay
235
+ FULL_BUILD_DEPENDS
236
+ libc.include .llvm-libc-types.wchar_t
237
+ libc.include .wchar
238
+ )
239
+
240
+ add_proxy_header_library(
241
+ wint_t
242
+ HDRS
243
+ wint_t.h
244
+ DEPENDS
245
+ libc.hdr.wchar_overlay
246
+ FULL_BUILD_DEPENDS
247
+ libc.include .llvm-libc-types.wint_t
248
+ libc.include .wchar
249
+ )
Original file line number Diff line number Diff line change
1
+ //===-- Definition of wchar_t.h -------------------------------------------===//
2
+ //
3
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
+ // See https://llvm.org/LICENSE.txt for license information.
5
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
+ //
7
+ //
8
+ //===----------------------------------------------------------------------===//
9
+
10
+ #ifndef LLVM_LIBC_HDR_TYPES_WCHAR_T_H
11
+ #define LLVM_LIBC_HDR_TYPES_WCHAR_T_H
12
+
13
+ #ifdef LIBC_FULL_BUILD
14
+
15
+ #include "include/llvm-libc-types/wchar_t.h"
16
+
17
+ #else // overlay mode
18
+
19
+ #include "hdr/wchar_overlay.h"
20
+
21
+ #endif // LLVM_LIBC_FULL_BUILD
22
+
23
+ #endif // LLVM_LIBC_HDR_TYPES_WCHAR_T_H
Original file line number Diff line number Diff line change
1
+ //===-- Definition of wint_t.h --------------------------------------------===//
2
+ //
3
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
+ // See https://llvm.org/LICENSE.txt for license information.
5
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
+ //
7
+ //
8
+ //===----------------------------------------------------------------------===//
9
+
10
+ #ifndef LLVM_LIBC_HDR_TYPES_WINT_T_H
11
+ #define LLVM_LIBC_HDR_TYPES_WINT_T_H
12
+
13
+ #ifdef LIBC_FULL_BUILD
14
+
15
+ #include "include/llvm-libc-types/wint_t.h"
16
+
17
+ #else // overlay mode
18
+
19
+ #include "hdr/wchar_overlay.h"
20
+
21
+ #endif // LLVM_LIBC_FULL_BUILD
22
+
23
+ #endif // LLVM_LIBC_HDR_TYPES_WINT_T_H
Original file line number Diff line number Diff line change
1
+ //===-- Definition of macros from wchar.h ---------------------------------===//
2
+ //
3
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
+ // See https://llvm.org/LICENSE.txt for license information.
5
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
+ //
7
+ //===----------------------------------------------------------------------===//
8
+
9
+ #ifndef LLVM_LIBC_HDR_WCHAR_MACROS_H
10
+ #define LLVM_LIBC_HDR_WCHAR_MACROS_H
11
+
12
+ #ifdef LIBC_FULL_BUILD
13
+
14
+ #include "include/llvm-libc-macros/wchar-macros.h"
15
+
16
+ #else // Overlay mode
17
+
18
+ #include "hdr/wchar_overlay.h"
19
+
20
+ #endif // LLVM_LIBC_FULL_BUILD
21
+
22
+ #endif // LLVM_LIBC_HDR_WCHAR_MACROS_H
Original file line number Diff line number Diff line change
1
+ //===-- Including wchar.h in overlay mode ---------------------------------===//
2
+ //
3
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
+ // See https://llvm.org/LICENSE.txt for license information.
5
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
+ //
7
+ //===----------------------------------------------------------------------===//
8
+
9
+ #ifndef LLVM_LIBC_HDR_WCHAR_OVERLAY_H
10
+ #define LLVM_LIBC_HDR_WCHAR_OVERLAY_H
11
+
12
+ #ifdef LIBC_FULL_BUILD
13
+ #error "This header should only be included in overlay mode"
14
+ #endif
15
+
16
+ // Overlay mode
17
+
18
+ // glibc <wchar.h header might provide extern inline definitions for few
19
+ // functions, causing external alias errors. They are guarded by
20
+ // `__USE_EXTERN_INLINES` macro. We temporarily disable `__USE_EXTERN_INLINES`
21
+ // macro by defining `__NO_INLINE__` before including <wchar.h>.
22
+ // And the same with `__USE_FORTIFY_LEVEL`, which will be temporarily disabled
23
+ // with `_FORTIFY_SOURCE`.
24
+
25
+ #ifdef _FORTIFY_SOURCE
26
+ #define LIBC_OLD_FORTIFY_SOURCE _FORTIFY_SOURCE
27
+ #undef _FORTIFY_SOURCE
28
+ #endif
29
+
30
+ #ifndef __NO_INLINE__
31
+ #define __NO_INLINE__ 1
32
+ #define LIBC_SET_NO_INLINE
33
+ #endif
34
+
35
+ #include <wchar.h>
36
+
37
+ #ifdef LIBC_OLD_FORTIFY_SOURCE
38
+ #define _FORTIFY_SOURCE LIBC_OLD_FORTIFY_SOURCE
39
+ #undef LIBC_OLD_FORTIFY_SOURCE
40
+ #endif
41
+
42
+ #ifdef LIBC_SET_NO_INLINE
43
+ #undef __NO_INLINE__
44
+ #undef LIBC_SET_NO_INLINE
45
+ #endif
46
+
47
+ #endif // LLVM_LIBC_HDR_WCHAR_OVERLAY_H
Original file line number Diff line number Diff line change 9
9
#ifndef LLVM_LIBC_TYPES_WCHAR_T_H
10
10
#define LLVM_LIBC_TYPES_WCHAR_T_H
11
11
12
- // Since __need_wchar_t is defined, we get the definition of wchar_t from the
13
- // standalone C header stddef.h. Also, because __need_wchar_t is defined,
14
- // including stddef.h will pull only the type wchar_t and nothing else.
15
- #define __need_wchar_t
16
- #include <stddef.h>
17
- #undef __need_wchar_t
12
+ typedef __WCHAR_TYPE__ wchar_t ;
18
13
19
14
#endif // LLVM_LIBC_TYPES_WCHAR_T_H
Original file line number Diff line number Diff line change 9
9
#ifndef LLVM_LIBC_TYPES_WINT_T_H
10
10
#define LLVM_LIBC_TYPES_WINT_T_H
11
11
12
- // Since __need_wint_t is defined, we get the definition of wint_t from the
13
- // standalone C header stddef.h. Also, because __need_wint_t is defined,
14
- // including stddef.h will pull only the type wint_t and nothing else.
15
- #define __need_wint_t
16
- #include <stddef.h>
17
- #undef __need_wint_t
12
+ typedef __WINT_TYPE__ wint_t ;
18
13
19
14
#endif // LLVM_LIBC_TYPES_WINT_T_H
Original file line number Diff line number Diff line change @@ -117,6 +117,8 @@ add_header_library(
117
117
wctype_utils
118
118
HDRS
119
119
wctype_utils.h
120
+ DEPENDS
121
+ libc.hdr.types.wint_t
120
122
)
121
123
122
124
add_header_library(
Original file line number Diff line number Diff line change 9
9
#ifndef LLVM_LIBC_SRC___SUPPORT_WCTYPE_UTILS_H
10
10
#define LLVM_LIBC_SRC___SUPPORT_WCTYPE_UTILS_H
11
11
12
+ #include " hdr/types/wint_t.h"
12
13
#include " src/__support/CPP/optional.h"
13
14
#include " src/__support/macros/attributes.h" // LIBC_INLINE
14
15
#include " src/__support/macros/config.h"
15
16
16
- #define __need_wint_t
17
- #define __need_wchar_t
18
- #include < stddef.h> // needed for wint_t and wchar_t
19
-
20
17
namespace LIBC_NAMESPACE_DECL {
21
18
namespace internal {
22
19
Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ add_entrypoint_object(
6
6
HDRS
7
7
wctob.h
8
8
DEPENDS
9
- libc.include .stdio
10
- libc.include .wchar
9
+ libc.hdr.types.wint_t
11
10
libc.src.__support.wctype_utils
12
11
)
Original file line number Diff line number Diff line change 12
12
#include " src/__support/wctype_utils.h"
13
13
14
14
#include " hdr/stdio_macros.h" // for EOF.
15
+ #include " hdr/types/wint_t.h"
15
16
16
17
namespace LIBC_NAMESPACE_DECL {
17
18
Original file line number Diff line number Diff line change 9
9
#ifndef LLVM_LIBC_SRC_WCHAR_BTOWC_H
10
10
#define LLVM_LIBC_SRC_WCHAR_BTOWC_H
11
11
12
+ #include " hdr/types/wint_t.h"
12
13
#include " src/__support/macros/config.h"
13
- #include < wchar.h>
14
14
15
15
namespace LIBC_NAMESPACE_DECL {
16
16
Original file line number Diff line number Diff line change 12
12
#include " src/__support/wctype_utils.h"
13
13
14
14
#include " hdr/stdio_macros.h" // for EOF.
15
+ #include " hdr/types/wint_t.h"
15
16
16
17
namespace LIBC_NAMESPACE_DECL {
17
18
Original file line number Diff line number Diff line change 9
9
#ifndef LLVM_LIBC_SRC_WCHAR_WCTOB_H
10
10
#define LLVM_LIBC_SRC_WCHAR_WCTOB_H
11
11
12
+ #include " hdr/types/wint_t.h"
12
13
#include " src/__support/macros/config.h"
13
- #include < wchar.h>
14
14
15
15
namespace LIBC_NAMESPACE_DECL {
16
16
Original file line number Diff line number Diff line change 6
6
//
7
7
// ===----------------------------------------------------------------------===//
8
8
9
- #include < wchar.h> // for WEOF
10
-
9
+ #include " hdr/wchar_macros.h" // for WEOF
11
10
#include " src/wchar/btowc.h"
12
-
13
11
#include " test/UnitTest/Test.h"
14
12
15
13
TEST (LlvmLibcBtowc, DefaultLocale) {
You can’t perform that action at this time.
0 commit comments