1 // -*- C++ -*-
2 //===------------------- support/android/locale_bionic.h ------------------===//
3 //
4 // The LLVM Compiler Infrastructure
5 //
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10
11 #ifndef _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H
12 #define _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H
13
14 #if defined(__BIONIC__)
15
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19
20 #include <stdlib.h>
21 #include <xlocale.h>
22
23 #ifdef __cplusplus
24 }
25 #endif
26
27 #if defined(__ANDROID__)
28
29 #include <android/api-level.h>
30 #if __ANDROID_API__ < 21
31 #include <support/xlocale/__posix_l_fallback.h>
32 #endif
33
34 // If we do not have this header, we are in a platform build rather than an NDK
35 // build, which will always be at least as new as the ToT NDK, in which case we
36 // don't need any of the inlines below since libc provides them.
37 #if __has_include(<android/ndk-version.h>)
38 #include <android/ndk-version.h>
39 // In NDK versions later than 16, locale-aware functions are provided by
40 // legacy_stdlib_inlines.h
41 #if __NDK_MAJOR__ <= 16
42 #if __ANDROID_API__ < 21
43 #include <support/xlocale/__strtonum_fallback.h>
44 #elif __ANDROID_API__ < 26
45
46 #if defined(__cplusplus)
47 extern "C" {
48 #endif
49
strtof_l(const char * __nptr,char ** __endptr,locale_t)50 inline _LIBCPP_INLINE_VISIBILITY float strtof_l(const char* __nptr, char** __endptr,
51 locale_t) {
52 return ::strtof(__nptr, __endptr);
53 }
54
strtod_l(const char * __nptr,char ** __endptr,locale_t)55 inline _LIBCPP_INLINE_VISIBILITY double strtod_l(const char* __nptr,
56 char** __endptr, locale_t) {
57 return ::strtod(__nptr, __endptr);
58 }
59
strtol_l(const char * __nptr,char ** __endptr,int __base,locale_t)60 inline _LIBCPP_INLINE_VISIBILITY long strtol_l(const char* __nptr, char** __endptr,
61 int __base, locale_t) {
62 return ::strtol(__nptr, __endptr, __base);
63 }
64
65 #if defined(__cplusplus)
66 }
67 #endif
68
69 #endif // __ANDROID_API__ < 26
70
71 #endif // __NDK_MAJOR__ <= 16
72 #endif // __has_include(<android/ndk-version.h>)
73 #endif // defined(__ANDROID__)
74
75 #endif // defined(__BIONIC__)
76 #endif // _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H
77