Marshall Clow | b38f8f0 | 2014-07-10 15:20:28 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===------------------- support/android/locale_bionic.h ------------------===// |
| 3 | // |
Chandler Carruth | 57b08b0 | 2019-01-19 10:56:40 +0000 | [diff] [blame] | 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 |
Marshall Clow | b38f8f0 | 2014-07-10 15:20:28 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H |
| 11 | #define _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H |
| 12 | |
Dan Albert | c991709 | 2016-09-19 18:00:45 +0000 | [diff] [blame] | 13 | #if defined(__BIONIC__) |
Marshall Clow | b38f8f0 | 2014-07-10 15:20:28 +0000 | [diff] [blame] | 14 | |
| 15 | #ifdef __cplusplus |
| 16 | extern "C" { |
| 17 | #endif |
| 18 | |
| 19 | #include <stdlib.h> |
| 20 | #include <xlocale.h> |
| 21 | |
Marshall Clow | b38f8f0 | 2014-07-10 15:20:28 +0000 | [diff] [blame] | 22 | #ifdef __cplusplus |
| 23 | } |
| 24 | #endif |
Jonathan Roelofs | 4f1561a | 2014-09-19 20:09:12 +0000 | [diff] [blame] | 25 | |
Saleem Abdulrasool | a4e874c | 2018-04-13 18:14:57 +0000 | [diff] [blame] | 26 | #if defined(__ANDROID__) |
| 27 | |
| 28 | #include <android/api-level.h> |
Peter Collingbourne | acd1f4e | 2018-05-16 22:40:12 +0000 | [diff] [blame] | 29 | #include <android/ndk-version.h> |
Ben Craig | 57b8b1f | 2016-05-20 12:58:41 +0000 | [diff] [blame] | 30 | #include <support/xlocale/__posix_l_fallback.h> |
Peter Collingbourne | acd1f4e | 2018-05-16 22:40:12 +0000 | [diff] [blame] | 31 | // In NDK versions later than 16, locale-aware functions are provided by |
| 32 | // legacy_stdlib_inlines.h |
| 33 | #if __NDK_MAJOR__ <= 16 |
| 34 | #if __ANDROID_API__ < 21 |
| 35 | #include <support/xlocale/__strtonum_fallback.h> |
| 36 | #elif __ANDROID_API__ < 26 |
Saleem Abdulrasool | a4e874c | 2018-04-13 18:14:57 +0000 | [diff] [blame] | 37 | |
| 38 | #if defined(__cplusplus) |
| 39 | extern "C" { |
| 40 | #endif |
| 41 | |
Louis Dionne | dc7200b | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 42 | inline _LIBCPP_INLINE_VISIBILITY float strtof_l(const char* __nptr, char** __endptr, |
| 43 | locale_t) { |
Saleem Abdulrasool | a4e874c | 2018-04-13 18:14:57 +0000 | [diff] [blame] | 44 | return ::strtof(__nptr, __endptr); |
| 45 | } |
| 46 | |
Louis Dionne | dc7200b | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 47 | inline _LIBCPP_INLINE_VISIBILITY double strtod_l(const char* __nptr, |
| 48 | char** __endptr, locale_t) { |
Saleem Abdulrasool | a4e874c | 2018-04-13 18:14:57 +0000 | [diff] [blame] | 49 | return ::strtod(__nptr, __endptr); |
| 50 | } |
| 51 | |
Louis Dionne | dc7200b | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 52 | inline _LIBCPP_INLINE_VISIBILITY long strtol_l(const char* __nptr, char** __endptr, |
| 53 | int __base, locale_t) { |
Saleem Abdulrasool | a4e874c | 2018-04-13 18:14:57 +0000 | [diff] [blame] | 54 | return ::strtol(__nptr, __endptr, __base); |
| 55 | } |
| 56 | |
| 57 | #if defined(__cplusplus) |
| 58 | } |
| 59 | #endif |
| 60 | |
| 61 | #endif // __ANDROID_API__ < 26 |
| 62 | |
Peter Collingbourne | acd1f4e | 2018-05-16 22:40:12 +0000 | [diff] [blame] | 63 | #endif // __NDK_MAJOR__ <= 16 |
Saleem Abdulrasool | a4e874c | 2018-04-13 18:14:57 +0000 | [diff] [blame] | 64 | #endif // defined(__ANDROID__) |
Jonathan Roelofs | 4f1561a | 2014-09-19 20:09:12 +0000 | [diff] [blame] | 65 | |
Dan Albert | c991709 | 2016-09-19 18:00:45 +0000 | [diff] [blame] | 66 | #endif // defined(__BIONIC__) |
Marshall Clow | b38f8f0 | 2014-07-10 15:20:28 +0000 | [diff] [blame] | 67 | #endif // _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H |