55 lines · c
1// -*- C++ -*-2//===----------------------------------------------------------------------===//3//4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5// See https://llvm.org/LICENSE.txt for license information.6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCPP___MBSTATE_T_H11#define _LIBCPP___MBSTATE_T_H12 13#include <__config>14 15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16# pragma GCC system_header17#endif18 19// The goal of this header is to provide mbstate_t without requiring all of20// <uchar.h> or <wchar.h>. It's also used by the libc++ versions of <uchar.h>21// and <wchar.h> to get mbstate_t when the C library doesn't provide <uchar.h>22// or <wchar.h>, hence the #include_next of those headers instead of #include.23// (e.g. if <wchar.h> isn't present in the C library, the libc++ <wchar.h>24// will include this header. This header needs to not turn around and cyclically25// include <wchar.h>, but fall through to <uchar.h>.)26//27// This does not define std::mbstate_t -- this only brings in the declaration28// in the global namespace.29 30// We define this here to support older versions of glibc <wchar.h> that do31// not define this for clang. This is also set in libc++'s <wchar.h> header,32// and we need to do so here too to avoid a different function signature given33// a different include order.34#ifdef __cplusplus35# define __CORRECT_ISO_CPP_WCHAR_H_PROTO36#endif37 38#if _LIBCPP_HAS_MUSL_LIBC39# define __NEED_mbstate_t40# include <bits/alltypes.h>41# undef __NEED_mbstate_t42#elif __has_include(<bits/types/mbstate_t.h>)43# include <bits/types/mbstate_t.h> // works on most Unixes44#elif __has_include(<sys/_types/_mbstate_t.h>)45# include <sys/_types/_mbstate_t.h> // works on Darwin46#elif __has_include_next(<wchar.h>)47# include_next <wchar.h> // use the C standard provider of mbstate_t if present48#elif __has_include_next(<uchar.h>)49# include_next <uchar.h> // Try <uchar.h> in absence of <wchar.h> for mbstate_t50#else51# error "We don't know how to get the definition of mbstate_t on your platform."52#endif53 54#endif // _LIBCPP___MBSTATE_T_H55