summaryrefslogtreecommitdiff
path: root/libcxx/include/__mbstate_t.h
AgeCommit message (Collapse)Author
2025-02-18[libc++] Do not guard inclusion of wchar.h with _LIBCPP_HAS_WIDE_CHARACTERS ↵Steven Cooreman
(#126924) `mbstate_t` needs to be visible to libcpp, even when it is not providing wide character functionality (i.e. `_LIBCPP_HAS_WIDE_CHARACTERS` is turned off) and thus not using any of the C library's wide character functions. There are C libraries (such as newlib-nano/nanolib/picolibc) which do provide their definition of `mbstate_t` in `<wchar.h>` even though they do not come with wide character functions. Since there is a way to conditionally include the C library's `<wchar.h>` only if it exists, we should rely on the fact that if it exists, it will provide `mbstate_t`. Removing this guard will allow using libc++ on top of newlib-nano/picolibc while not breaking the cases where it is used on top of a C library which doesn't provide `<wchar.h>` (since it would then still go look for `<uchar.h>` or error out).
2024-11-06[libc++] Refactor the configuration macros to being always defined (#112094)Nikolas Klauser
This is a follow-up to #89178. This updates the `<__config_site>` macros.
2023-12-18[libc++] Format the code base (#74334)Louis Dionne
This patch runs clang-format on all of libcxx/include and libcxx/src, in accordance with the RFC discussed at [1]. Follow-up patches will format the benchmarks, the test suite and remaining parts of the code. I'm splitting this one into its own patch so the diff is a bit easier to review. This patch was generated with: find libcxx/include libcxx/src -type f \ | grep -v 'module.modulemap.in' \ | grep -v 'CMakeLists.txt' \ | grep -v 'README.txt' \ | grep -v 'libcxx.imp' \ | grep -v '__config_site.in' \ | xargs clang-format -i A Git merge driver is available in libcxx/utils/clang-format-merge-driver.sh to help resolve merge and rebase issues across these formatting changes. [1]: https://discourse.llvm.org/t/rfc-clang-formatting-all-of-libc-once-and-for-all
2023-05-30[libc++] Include "bits/alltypes.h" to provide mbstate_t when using musl libcPengxuan Zheng
With D148542, we ran into the following libc++ build error when using musl libc. ``` .../musl/include/bits/alltypes.h:354:16: error: definition of type '__mbstate_t' conflicts with typedef of the same name typedef struct __mbstate_t { unsigned __opaque1, __opaque2; } mbstate_t; ^ .../sysroot/usr/include/bits/types/__mbstate_t.h:21:3: note: '__mbstate_t' declared here } __mbstate_t; ^ 1 error generated. ``` This is because the mbstate_t definition in musl libc conflicts with the one from "bits/types/mbstate_t.h", and this patch attempts to fix this build issue when musl libc is used. Reviewed By: iana Differential Revision: https://reviews.llvm.org/D151740
2023-05-10[libc++] Consistently enable __CORRECT_ISO_CPP_WCHAR_H_PROTO in mbstate.Jordan Rupprecht
In libc++'s `wchar.h`, before we forward to the system `wchar.h`, we set `__CORRECT_ISO_CPP_WCHAR_H_PROTO` to ensure it defines the correct signature (e.g. `extern "C++" const wchar_t *wmemchr` and not `extern wchar_t *wmemchr`). After D148542, there are cases where we include the system `wchar.h` from within `__mbstate_t.h` without setting that, and so we get a function type mismatch if we transitively include `wchar.h` through multiple headers in a modules-enabled build. Consistently setting it here resolves those build errors. Alternative 1: we could put this in `__config` instead. I chose to put it here for a more limited scope. Alternative 2: we could patch `wchar.h` itself to work correctly and remove references `__CORRECT_ISO_CPP_WCHAR_H_PROTO` from libc++ entirely. It does already set it, but with an additional condition that it is being built by GCC >= 4.4. Clang does pretend to be GCC via `__GNUC__` etc. which can be controlled via `-fgnuc-version` command line flags, but that might have other consequences. Reviewed By: ldionne, #libc, MaskRay Differential Revision: https://reviews.llvm.org/D150015
2023-05-01[libc++] cuchar redeclares ::mbstate_t when it's in its own clang moduleIan Anderson
When cuchar is compiled independently on platforms that don't have <uchar.h>, it doesn't get a declaration of mbstate_t, and so makes an empty declaration for ::mbstate_t. That conflicts with the declarations in __mbstate_t.h and cwchar since both of those headers do get mbstate_t before making ::mbstate_t. Change `__mbstate_t.h` to just get the underlying declaration for mbstate_t and not make a declaration for ::mbstate_t. Include __mbstate_t.h in uchar.h and wchar.h when their next headers aren't available so that at least mbstate_t gets defined. Add __std_mbstate_t.h to declare ::mbstate_t for headers that need that when cuchar or cwchar aren't available (because either _LIBCPP_HAS_NO_WIDE_CHARACTERS or _LIBCPP_CXX03_LANG). Reviewed By: ldionne, Mordante, #libc, philnik Differential Revision: https://reviews.llvm.org/D148542
2022-02-04[libc++] Normalize all our '#pragma GCC system_header', and regression-test.Arthur O'Dwyer
Now we'll notice if a header forgets to include this magic phrase. Differential Revision: https://reviews.llvm.org/D118800
2021-10-12[libc++] Add an option to disable wide character support in libc++Louis Dionne
Some embedded platforms do not wish to support the C library functionality for handling wchar_t because they have no use for it. It makes sense for libc++ to work properly on those platforms, so this commit adds a carve-out of functionality for wchar_t. Unfortunately, unlike some other carve-outs (e.g. random device), this patch touches several parts of the library. However, despite the wide impact of this patch, I still think it is important to support this configuration since it makes it much simpler to port libc++ to some embedded platforms. Differential Revision: https://reviews.llvm.org/D111265