xlocale.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. // This adds support for the extended locale functions that are currently
  10. // missing from the Musl C library.
  11. //
  12. // This only works when the specified locale is "C" or "POSIX", but that's
  13. // about as good as we can do without implementing full xlocale support
  14. // in Musl.
  15. //===----------------------------------------------------------------------===//
  16. #ifndef _LIBCPP_SUPPORT_MUSL_XLOCALE_H
  17. #define _LIBCPP_SUPPORT_MUSL_XLOCALE_H
  18. #include <cstdlib>
  19. #include <cwchar>
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. static inline long long strtoll_l(const char *nptr, char **endptr, int base,
  24. locale_t) {
  25. return strtoll(nptr, endptr, base);
  26. }
  27. static inline unsigned long long strtoull_l(const char *nptr, char **endptr,
  28. int base, locale_t) {
  29. return strtoull(nptr, endptr, base);
  30. }
  31. static inline long long wcstoll_l(const wchar_t *nptr, wchar_t **endptr,
  32. int base, locale_t) {
  33. return wcstoll(nptr, endptr, base);
  34. }
  35. static inline unsigned long long wcstoull_l(const wchar_t *nptr,
  36. wchar_t **endptr, int base,
  37. locale_t) {
  38. return wcstoull(nptr, endptr, base);
  39. }
  40. static inline long double wcstold_l(const wchar_t *nptr, wchar_t **endptr,
  41. locale_t) {
  42. return wcstold(nptr, endptr);
  43. }
  44. #ifdef __cplusplus
  45. }
  46. #endif
  47. #endif // _LIBCPP_SUPPORT_MUSL_XLOCALE_H