diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -65,6 +65,7 @@ ctgmath ctime ctype.h + cuchar cwchar cwctype deque diff --git a/libcxx/include/cuchar b/libcxx/include/cuchar new file mode 100644 --- /dev/null +++ b/libcxx/include/cuchar @@ -0,0 +1,63 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_CUCHAR +#define _LIBCPP_CUCHAR + +/* + cuchar synopsis + +Macros: + + __STDC_UTF_16__ + __STDC_UTF_32__ + +namespace std { + +Types: + + mbstate_t + size_t + +size_t mbrtoc8(char8_t* pc8, const char* s, size_t n, mbstate_t* ps); // since C++20 +size_t c8rtomb(char* s, char8_t c8, mbstate_t* ps); // since C++20 +size_t mbrtoc16(char16_t* pc16, const char* s, size_t n, mbstate_t* ps); +size_t c16rtomb(char* s, char16_t c16, mbstate_t* ps); +size_t mbrtoc32(char32_t* pc32, const char* s, size_t n, mbstate_t* ps); +size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps); + +} // std + +*/ + +#include <__config> + +#if __has_include() +# include +#endif + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if __has_include() + using ::mbstate_t; + using ::size_t; + + using ::mbrtoc16; + using ::c16rtomb; + using ::mbrtoc32; + using ::c32rtomb; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP_CUCHAR diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap --- a/libcxx/include/module.modulemap +++ b/libcxx/include/module.modulemap @@ -201,7 +201,10 @@ header "ctime" export * } - // FIXME: is missing. + module cuchar { + header "cuchar" + export * + } module cwchar { header "cwchar" export depr.stdio_h diff --git a/libcxx/test/libcxx/double_include.sh.cpp b/libcxx/test/libcxx/double_include.sh.cpp --- a/libcxx/test/libcxx/double_include.sh.cpp +++ b/libcxx/test/libcxx/double_include.sh.cpp @@ -80,6 +80,7 @@ #include #include #include +#include #include #include #include diff --git a/libcxx/test/libcxx/min_max_macros.compile.pass.cpp b/libcxx/test/libcxx/min_max_macros.compile.pass.cpp --- a/libcxx/test/libcxx/min_max_macros.compile.pass.cpp +++ b/libcxx/test/libcxx/min_max_macros.compile.pass.cpp @@ -116,6 +116,8 @@ TEST_MACROS(); #include TEST_MACROS(); +#include +TEST_MACROS(); #include TEST_MACROS(); #include diff --git a/libcxx/test/libcxx/no_assert_include.compile.pass.cpp b/libcxx/test/libcxx/no_assert_include.compile.pass.cpp --- a/libcxx/test/libcxx/no_assert_include.compile.pass.cpp +++ b/libcxx/test/libcxx/no_assert_include.compile.pass.cpp @@ -73,6 +73,7 @@ #include #include #include +#include #include #include #include diff --git a/libcxx/test/libcxx/strings/c.strings/version_cuchar.pass.cpp b/libcxx/test/libcxx/strings/c.strings/version_cuchar.pass.cpp --- a/libcxx/test/libcxx/strings/c.strings/version_cuchar.pass.cpp +++ b/libcxx/test/libcxx/strings/c.strings/version_cuchar.pass.cpp @@ -5,8 +5,6 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -// -// XFAIL: * // diff --git a/libcxx/test/std/strings/c.strings/cuchar.pass.cpp b/libcxx/test/std/strings/c.strings/cuchar.pass.cpp --- a/libcxx/test/std/strings/c.strings/cuchar.pass.cpp +++ b/libcxx/test/std/strings/c.strings/cuchar.pass.cpp @@ -5,8 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -// -// XFAIL: libc++ + +// The macOS SDK doesn't contain yet, so these tests fail. +// XFAIL: darwin // @@ -14,8 +15,20 @@ #include "test_macros.h" -int main(int, char**) -{ +// __STDC_UTF_16__ may or may not be defined by the C standard library +// __STDC_UTF_32__ may or may not be defined by the C standard library + +int main(int, char**) { +#if TEST_STD_VER > 17 && !defined(_LIBCPP_VERSION) // TODO: implement this in libc++ + ASSERT_SAME_TYPE(size_t, decltype(std::mbrtoc8((char8_t*)0, (char const*)0, size_t(), (mbstate_t*)0))); + ASSERT_SAME_TYPE(size_t, decltype(std::c8rtomb((char*)0, char8_t{}, (mbstate_t*)0))); +#endif + + ASSERT_SAME_TYPE(size_t, decltype(std::mbrtoc16((char16_t*)0, (const char*)0, size_t{}, (mbstate_t*)0))); + ASSERT_SAME_TYPE(size_t, decltype(std::c16rtomb((char*)0, char16_t{}, (mbstate_t*)0))); + + ASSERT_SAME_TYPE(size_t, decltype(std::mbrtoc32((char32_t*)0, (const char*)0, size_t{}, (mbstate_t*)0))); + ASSERT_SAME_TYPE(size_t, decltype(std::c16rtomb((char*)0, char32_t{}, (mbstate_t*)0))); - return 0; + return 0; }