blob: 5b16071d9cdbbab84c04b75193db3ce32bdfd211 [file] [log] [blame]
Marshall Clowb38f8f02014-07-10 15:20:28 +00001// -*- C++ -*-
2//===------------------- support/android/locale_bionic.h ------------------===//
3//
Chandler Carruth57b08b02019-01-19 10:56:40 +00004// 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 Clowb38f8f02014-07-10 15:20:28 +00007//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H
11#define _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H
12
Dan Albertc9917092016-09-19 18:00:45 +000013#if defined(__BIONIC__)
Marshall Clowb38f8f02014-07-10 15:20:28 +000014
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19#include <stdlib.h>
20#include <xlocale.h>
21
Marshall Clowb38f8f02014-07-10 15:20:28 +000022#ifdef __cplusplus
23}
24#endif
Jonathan Roelofs4f1561a2014-09-19 20:09:12 +000025
Saleem Abdulrasoola4e874c2018-04-13 18:14:57 +000026#if defined(__ANDROID__)
27
28#include <android/api-level.h>
Peter Collingbourneacd1f4e2018-05-16 22:40:12 +000029#include <android/ndk-version.h>
Ben Craig57b8b1f2016-05-20 12:58:41 +000030#include <support/xlocale/__posix_l_fallback.h>
Peter Collingbourneacd1f4e2018-05-16 22:40:12 +000031// 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 Abdulrasoola4e874c2018-04-13 18:14:57 +000037
38#if defined(__cplusplus)
39extern "C" {
40#endif
41
Louis Dionnedc7200b2018-07-11 23:14:33 +000042inline _LIBCPP_INLINE_VISIBILITY float strtof_l(const char* __nptr, char** __endptr,
43 locale_t) {
Saleem Abdulrasoola4e874c2018-04-13 18:14:57 +000044 return ::strtof(__nptr, __endptr);
45}
46
Louis Dionnedc7200b2018-07-11 23:14:33 +000047inline _LIBCPP_INLINE_VISIBILITY double strtod_l(const char* __nptr,
48 char** __endptr, locale_t) {
Saleem Abdulrasoola4e874c2018-04-13 18:14:57 +000049 return ::strtod(__nptr, __endptr);
50}
51
Louis Dionnedc7200b2018-07-11 23:14:33 +000052inline _LIBCPP_INLINE_VISIBILITY long strtol_l(const char* __nptr, char** __endptr,
53 int __base, locale_t) {
Saleem Abdulrasoola4e874c2018-04-13 18:14:57 +000054 return ::strtol(__nptr, __endptr, __base);
55}
56
57#if defined(__cplusplus)
58}
59#endif
60
61#endif // __ANDROID_API__ < 26
62
Peter Collingbourneacd1f4e2018-05-16 22:40:12 +000063#endif // __NDK_MAJOR__ <= 16
Saleem Abdulrasoola4e874c2018-04-13 18:14:57 +000064#endif // defined(__ANDROID__)
Jonathan Roelofs4f1561a2014-09-19 20:09:12 +000065
Dan Albertc9917092016-09-19 18:00:45 +000066#endif // defined(__BIONIC__)
Marshall Clowb38f8f02014-07-10 15:20:28 +000067#endif // _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H