-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[libc] Fix a couple issues in <wchar.h> header #164666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
|
@llvm/pr-subscribers-libc Author: Alexey Samsonov (vonosmas) Changes
This brings us closer to being able to build libcxx with wide-character support against llvm-libc headers. Full diff: https://github.com/llvm/llvm-project/pull/164666.diff 5 Files Affected:
diff --git a/libc/include/wchar.yaml b/libc/include/wchar.yaml
index 8178091ab2202..b8a0a748cd3ad 100644
--- a/libc/include/wchar.yaml
+++ b/libc/include/wchar.yaml
@@ -4,6 +4,7 @@ macros:
- macro_name: NULL
macro_header: null-macro.h
types:
+ - type_name: FILE
- type_name: size_t
- type_name: wint_t
- type_name: wchar_t
@@ -104,9 +105,9 @@ functions:
- name: wmemset
standards:
- stdc
- return_type: wchar_t*
+ return_type: wchar_t *
arguments:
- - type: wchar_t*
+ - type: wchar_t *
- type: wchar_t
- type: size_t
- name: wcschr
@@ -246,7 +247,7 @@ functions:
- type: const wchar_t **__restrict
- type: size_t
- type: size_t
- - type: mbstate_t
+ - type: mbstate_t *__restrict
- name: wcsrtombs
standards:
- stdc
@@ -255,7 +256,7 @@ functions:
- type: char *__restrict
- type: const wchar_t **__restrict
- type: size_t
- - type: mbstate_t
+ - type: mbstate_t *__restrict
- name: wcrtomb
standards:
- stdc
@@ -299,7 +300,7 @@ functions:
arguments:
- type: wchar_t *__restrict
- type: const wchar_t *__restrict
- - type: wchar_t** __restrict
+ - type: wchar_t **__restrict
- name: wcpcpy
standards:
- stdc
diff --git a/libc/src/wchar/wcsnrtombs.cpp b/libc/src/wchar/wcsnrtombs.cpp
index 7f25b248a0863..a344c2331b532 100644
--- a/libc/src/wchar/wcsnrtombs.cpp
+++ b/libc/src/wchar/wcsnrtombs.cpp
@@ -22,7 +22,7 @@ namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(size_t, wcsnrtombs,
(char *__restrict s, const wchar_t **__restrict pwcs,
- size_t nwc, size_t len, mbstate_t *ps)) {
+ size_t nwc, size_t len, mbstate_t *__restrict ps)) {
LIBC_CRASH_ON_NULLPTR(pwcs);
static internal::mbstate internal_mbstate;
auto result = internal::wcsnrtombs(
diff --git a/libc/src/wchar/wcsnrtombs.h b/libc/src/wchar/wcsnrtombs.h
index bf8add75b2951..2ca42c71e2e9d 100644
--- a/libc/src/wchar/wcsnrtombs.h
+++ b/libc/src/wchar/wcsnrtombs.h
@@ -17,7 +17,7 @@
namespace LIBC_NAMESPACE_DECL {
size_t wcsnrtombs(char *__restrict s, const wchar_t **__restrict pwcs,
- size_t nwc, size_t len, mbstate_t *ps);
+ size_t nwc, size_t len, mbstate_t *__restrict ps);
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/wchar/wcsrtombs.cpp b/libc/src/wchar/wcsrtombs.cpp
index 9d2508cb81a8c..0167e857128de 100644
--- a/libc/src/wchar/wcsrtombs.cpp
+++ b/libc/src/wchar/wcsrtombs.cpp
@@ -22,7 +22,7 @@ namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(size_t, wcsrtombs,
(char *__restrict s, const wchar_t **__restrict pwcs,
- size_t n, mbstate_t *ps)) {
+ size_t n, mbstate_t *__restrict ps)) {
LIBC_CRASH_ON_NULLPTR(pwcs);
static internal::mbstate internal_mbstate;
auto result = internal::wcsnrtombs(
diff --git a/libc/src/wchar/wcsrtombs.h b/libc/src/wchar/wcsrtombs.h
index d23573f5b9418..b85e2c6ed740a 100644
--- a/libc/src/wchar/wcsrtombs.h
+++ b/libc/src/wchar/wcsrtombs.h
@@ -17,7 +17,7 @@
namespace LIBC_NAMESPACE_DECL {
size_t wcsrtombs(char *__restrict s, const wchar_t **__restrict pwcs, size_t n,
- mbstate_t *ps);
+ mbstate_t *__restrict ps);
} // namespace LIBC_NAMESPACE_DECL
|
michaelrj-google
approved these changes
Oct 22, 2025
dvbuka
pushed a commit
to dvbuka/llvm-project
that referenced
this pull request
Oct 27, 2025
* 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.
Lukacma
pushed a commit
to Lukacma/llvm-project
that referenced
this pull request
Oct 29, 2025
* 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.
aokblast
pushed a commit
to aokblast/llvm-project
that referenced
this pull request
Oct 30, 2025
* 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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
<wchar.h>, as well as in<stdio.h>wcsrtombs/wcsnrtombsfunction - it should be restrict pointer tombstate_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.