__mbstate_t.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _LIBCPP___MBSTATE_T_H
  10. #define _LIBCPP___MBSTATE_T_H
  11. #include <__config>
  12. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  13. # pragma GCC system_header
  14. #endif
  15. // The goal of this header is to provide mbstate_t without requiring all of
  16. // <uchar.h> or <wchar.h>. It's also used by the libc++ versions of <uchar.h>
  17. // and <wchar.h> to get mbstate_t when the C library doesn't provide <uchar.h>
  18. // or <wchar.h>, hence the #include_next of those headers instead of #include.
  19. // (e.g. if <wchar.h> isn't present in the C library, the libc++ <wchar.h>
  20. // will include this header. This header needs to not turn around and cyclically
  21. // include <wchar.h>, but fall through to <uchar.h>.)
  22. //
  23. // This does not define std::mbstate_t -- this only brings in the declaration
  24. // in the global namespace.
  25. // We define this here to support older versions of glibc <wchar.h> that do
  26. // not define this for clang. This is also set in libc++'s <wchar.h> header,
  27. // and we need to do so here too to avoid a different function signature given
  28. // a different include order.
  29. #ifdef __cplusplus
  30. # define __CORRECT_ISO_CPP_WCHAR_H_PROTO
  31. #endif
  32. #if defined(_LIBCPP_HAS_MUSL_LIBC)
  33. # define __NEED_mbstate_t
  34. # include <bits/alltypes.h>
  35. # undef __NEED_mbstate_t
  36. #elif __has_include(<bits/types/mbstate_t.h>)
  37. # include <bits/types/mbstate_t.h> // works on most Unixes
  38. #elif __has_include(<sys/_types/_mbstate_t.h>)
  39. # include <sys/_types/_mbstate_t.h> // works on Darwin
  40. #elif !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) && __has_include_next(<wchar.h>)
  41. # include_next <wchar.h> // fall back to the C standard provider of mbstate_t
  42. #elif __has_include_next(<uchar.h>)
  43. # include_next <uchar.h> // <uchar.h> is also required to make mbstate_t visible
  44. #else
  45. # error "We don't know how to get the definition of mbstate_t without <wchar.h> on your platform."
  46. #endif
  47. #endif // _LIBCPP___MBSTATE_T_H