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(
161161 libc.include .sys_auxv
162162)
163163
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+
164177add_subdirectory (types)
Original file line number Diff line number Diff line change @@ -199,7 +199,6 @@ add_proxy_header_library(
199199 libc.include .setjmp
200200)
201201
202-
203202add_proxy_header_library(
204203 struct_msghdr
205204 HDRS
@@ -226,3 +225,25 @@ add_proxy_header_library(
226225 libc.include .llvm-libc-types.socklen_t
227226 libc.include .sys_socket
228227)
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 99#ifndef LLVM_LIBC_TYPES_WCHAR_T_H
1010#define LLVM_LIBC_TYPES_WCHAR_T_H
1111
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 ;
1813
1914#endif // LLVM_LIBC_TYPES_WCHAR_T_H
Original file line number Diff line number Diff line change 99#ifndef LLVM_LIBC_TYPES_WINT_T_H
1010#define LLVM_LIBC_TYPES_WINT_T_H
1111
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 ;
1813
1914#endif // LLVM_LIBC_TYPES_WINT_T_H
Original file line number Diff line number Diff line change @@ -117,6 +117,8 @@ add_header_library(
117117 wctype_utils
118118 HDRS
119119 wctype_utils.h
120+ DEPENDS
121+ libc.hdr.types.wint_t
120122)
121123
122124add_header_library(
Original file line number Diff line number Diff line change 99#ifndef LLVM_LIBC_SRC___SUPPORT_WCTYPE_UTILS_H
1010#define LLVM_LIBC_SRC___SUPPORT_WCTYPE_UTILS_H
1111
12+ #include " hdr/types/wint_t.h"
1213#include " src/__support/CPP/optional.h"
1314#include " src/__support/macros/attributes.h" // LIBC_INLINE
1415#include " src/__support/macros/config.h"
1516
16- #define __need_wint_t
17- #define __need_wchar_t
18- #include < stddef.h> // needed for wint_t and wchar_t
19-
2017namespace LIBC_NAMESPACE_DECL {
2118namespace internal {
2219
You can’t perform that action at this time.
0 commit comments