locale_bionic.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // -*- C++ -*-
  2. //===------------------- support/android/locale_bionic.h ------------------===//
  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_SUPPORT_ANDROID_LOCALE_BIONIC_H
  10. #define _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H
  11. #if defined(__BIONIC__)
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. #include <stdlib.h>
  16. #include <xlocale.h>
  17. #ifdef __cplusplus
  18. }
  19. #endif
  20. #if defined(__ANDROID__)
  21. #include <android/api-level.h>
  22. #include <android/ndk-version.h>
  23. #include <support/xlocale/__posix_l_fallback.h>
  24. // In NDK versions later than 16, locale-aware functions are provided by
  25. // legacy_stdlib_inlines.h
  26. #if __NDK_MAJOR__ <= 16
  27. #if __ANDROID_API__ < 21
  28. #include <support/xlocale/__strtonum_fallback.h>
  29. #elif __ANDROID_API__ < 26
  30. #if defined(__cplusplus)
  31. extern "C" {
  32. #endif
  33. inline _LIBCPP_INLINE_VISIBILITY float strtof_l(const char* __nptr, char** __endptr,
  34. locale_t) {
  35. return ::strtof(__nptr, __endptr);
  36. }
  37. inline _LIBCPP_INLINE_VISIBILITY double strtod_l(const char* __nptr,
  38. char** __endptr, locale_t) {
  39. return ::strtod(__nptr, __endptr);
  40. }
  41. inline _LIBCPP_INLINE_VISIBILITY long strtol_l(const char* __nptr, char** __endptr,
  42. int __base, locale_t) {
  43. return ::strtol(__nptr, __endptr, __base);
  44. }
  45. #if defined(__cplusplus)
  46. }
  47. #endif
  48. #endif // __ANDROID_API__ < 26
  49. #endif // __NDK_MAJOR__ <= 16
  50. #endif // defined(__ANDROID__)
  51. #endif // defined(__BIONIC__)
  52. #endif // _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H