blob: d638757fd759e7ff1d2f6bc9d92784556a225a49 [file] [log] [blame]
Marshall Clowb38f8f02014-07-10 15:20:28 +00001// -*- 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
Dan Albertc9917092016-09-19 18:00:45 +000014#if defined(__BIONIC__)
Marshall Clowb38f8f02014-07-10 15:20:28 +000015
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20#include <stdlib.h>
21#include <xlocale.h>
22
Marshall Clowb38f8f02014-07-10 15:20:28 +000023#ifdef __cplusplus
24}
25#endif
Jonathan Roelofs4f1561a2014-09-19 20:09:12 +000026
Saleem Abdulrasoola4e874c2018-04-13 18:14:57 +000027#if defined(__ANDROID__)
28
29#include <android/api-level.h>
Peter Collingbourneacd1f4e2018-05-16 22:40:12 +000030#include <android/ndk-version.h>
Ben Craig57b8b1f2016-05-20 12:58:41 +000031#include <support/xlocale/__posix_l_fallback.h>
Peter Collingbourneacd1f4e2018-05-16 22:40:12 +000032// In NDK versions later than 16, locale-aware functions are provided by
33// legacy_stdlib_inlines.h
34#if __NDK_MAJOR__ <= 16
35#if __ANDROID_API__ < 21
36#include <support/xlocale/__strtonum_fallback.h>
37#elif __ANDROID_API__ < 26
Saleem Abdulrasoola4e874c2018-04-13 18:14:57 +000038
39#if defined(__cplusplus)
40extern "C" {
41#endif
42
43inline _LIBCPP_ALWAYS_INLINE float strtof_l(const char* __nptr, char** __endptr,
44 locale_t) {
45 return ::strtof(__nptr, __endptr);
46}
47
48inline _LIBCPP_ALWAYS_INLINE double strtod_l(const char* __nptr,
49 char** __endptr, locale_t) {
50 return ::strtod(__nptr, __endptr);
51}
52
53inline _LIBCPP_ALWAYS_INLINE long strtol_l(const char* __nptr, char** __endptr,
54 int __base, locale_t) {
55 return ::strtol(__nptr, __endptr, __base);
56}
57
58#if defined(__cplusplus)
59}
60#endif
61
62#endif // __ANDROID_API__ < 26
63
Peter Collingbourneacd1f4e2018-05-16 22:40:12 +000064#endif // __NDK_MAJOR__ <= 16
Saleem Abdulrasoola4e874c2018-04-13 18:14:57 +000065#endif // defined(__ANDROID__)
Jonathan Roelofs4f1561a2014-09-19 20:09:12 +000066
Dan Albertc9917092016-09-19 18:00:45 +000067#endif // defined(__BIONIC__)
Marshall Clowb38f8f02014-07-10 15:20:28 +000068#endif // _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H