xref: /llvm-project/libcxx/include/__locale_dir/locale_base_api/android.h (revision 6bc68d0fe94e7fbdec40e1306bf8db1b0db3110c)
1 // -*- C++ -*-
2 //===-----------------------------------------------------------------------===//
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 
10 #ifndef _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_ANDROID_H
11 #define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_ANDROID_H
12 
13 #include <stdlib.h>
14 
15 // FIXME: Is this actually required?
16 extern "C" {
17 #include <xlocale.h>
18 }
19 
20 #include <android/api-level.h>
21 
22 // If we do not have this header, we are in a platform build rather than an NDK
23 // build, which will always be at least as new as the ToT NDK, in which case we
24 // don't need any of the inlines below since libc provides them.
25 #if __has_include(<android/ndk-version.h>)
26 #  include <android/ndk-version.h>
27 // In NDK versions later than 16, locale-aware functions are provided by
28 // legacy_stdlib_inlines.h
29 #  if __NDK_MAJOR__ <= 16
30 #    if __ANDROID_API__ < 26
31 
32 inline _LIBCPP_HIDE_FROM_ABI float strtof_l(const char* __nptr, char** __endptr, locale_t) {
33   return ::strtof(__nptr, __endptr);
34 }
35 
36 inline _LIBCPP_HIDE_FROM_ABI double strtod_l(const char* __nptr, char** __endptr, locale_t) {
37   return ::strtod(__nptr, __endptr);
38 }
39 
40 #    endif // __ANDROID_API__ < 26
41 
42 #  endif // __NDK_MAJOR__ <= 16
43 #endif   // __has_include(<android/ndk-version.h>)
44 
45 #endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_ANDROID_H
46