Skip to content

Commit 9fc353e

Browse files
authored
[libc] Fix a couple issues in <wchar.h> header (#164666)
* Add FILE type declaration, as it should be presented in `<wchar.h>`, as well as in `<stdio.h>` * Fix argument type in `wcsrtombs` / `wcsnrtombs` function - it should be restrict pointer to `mbstate_t`. Add restrict qualifier to internal implementation as well. This brings us closer to being able to build libcxx with wide-character support against llvm-libc headers.
1 parent 04b5cc6 commit 9fc353e

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

libc/include/wchar.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ macros:
44
- macro_name: NULL
55
macro_header: null-macro.h
66
types:
7+
- type_name: FILE
78
- type_name: size_t
89
- type_name: wint_t
910
- type_name: wchar_t
@@ -104,9 +105,9 @@ functions:
104105
- name: wmemset
105106
standards:
106107
- stdc
107-
return_type: wchar_t*
108+
return_type: wchar_t *
108109
arguments:
109-
- type: wchar_t*
110+
- type: wchar_t *
110111
- type: wchar_t
111112
- type: size_t
112113
- name: wcschr
@@ -246,7 +247,7 @@ functions:
246247
- type: const wchar_t **__restrict
247248
- type: size_t
248249
- type: size_t
249-
- type: mbstate_t
250+
- type: mbstate_t *__restrict
250251
- name: wcsrtombs
251252
standards:
252253
- stdc
@@ -255,7 +256,7 @@ functions:
255256
- type: char *__restrict
256257
- type: const wchar_t **__restrict
257258
- type: size_t
258-
- type: mbstate_t
259+
- type: mbstate_t *__restrict
259260
- name: wcrtomb
260261
standards:
261262
- stdc
@@ -299,7 +300,7 @@ functions:
299300
arguments:
300301
- type: wchar_t *__restrict
301302
- type: const wchar_t *__restrict
302-
- type: wchar_t** __restrict
303+
- type: wchar_t **__restrict
303304
- name: wcpcpy
304305
standards:
305306
- stdc

libc/src/wchar/wcsnrtombs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace LIBC_NAMESPACE_DECL {
2222

2323
LLVM_LIBC_FUNCTION(size_t, wcsnrtombs,
2424
(char *__restrict s, const wchar_t **__restrict pwcs,
25-
size_t nwc, size_t len, mbstate_t *ps)) {
25+
size_t nwc, size_t len, mbstate_t *__restrict ps)) {
2626
LIBC_CRASH_ON_NULLPTR(pwcs);
2727
static internal::mbstate internal_mbstate;
2828
auto result = internal::wcsnrtombs(

libc/src/wchar/wcsnrtombs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
namespace LIBC_NAMESPACE_DECL {
1818

1919
size_t wcsnrtombs(char *__restrict s, const wchar_t **__restrict pwcs,
20-
size_t nwc, size_t len, mbstate_t *ps);
20+
size_t nwc, size_t len, mbstate_t *__restrict ps);
2121

2222
} // namespace LIBC_NAMESPACE_DECL
2323

libc/src/wchar/wcsrtombs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace LIBC_NAMESPACE_DECL {
2222

2323
LLVM_LIBC_FUNCTION(size_t, wcsrtombs,
2424
(char *__restrict s, const wchar_t **__restrict pwcs,
25-
size_t n, mbstate_t *ps)) {
25+
size_t n, mbstate_t *__restrict ps)) {
2626
LIBC_CRASH_ON_NULLPTR(pwcs);
2727
static internal::mbstate internal_mbstate;
2828
auto result = internal::wcsnrtombs(

libc/src/wchar/wcsrtombs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
namespace LIBC_NAMESPACE_DECL {
1818

1919
size_t wcsrtombs(char *__restrict s, const wchar_t **__restrict pwcs, size_t n,
20-
mbstate_t *ps);
20+
mbstate_t *__restrict ps);
2121

2222
} // namespace LIBC_NAMESPACE_DECL
2323

0 commit comments

Comments
 (0)