xref: /aosp_15_r20/external/libcxx/include/support/musl/xlocale.h (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1*58b9f456SAndroid Build Coastguard Worker // -*- C++ -*-
2*58b9f456SAndroid Build Coastguard Worker //===------------------- support/musl/xlocale.h ------------------------===//
3*58b9f456SAndroid Build Coastguard Worker //
4*58b9f456SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
5*58b9f456SAndroid Build Coastguard Worker //
6*58b9f456SAndroid Build Coastguard Worker // This file is dual licensed under the MIT and the University of Illinois Open
7*58b9f456SAndroid Build Coastguard Worker // Source Licenses. See LICENSE.TXT for details.
8*58b9f456SAndroid Build Coastguard Worker //
9*58b9f456SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
10*58b9f456SAndroid Build Coastguard Worker // This adds support for the extended locale functions that are currently
11*58b9f456SAndroid Build Coastguard Worker // missing from the Musl C library.
12*58b9f456SAndroid Build Coastguard Worker //
13*58b9f456SAndroid Build Coastguard Worker // This only works when the specified locale is "C" or "POSIX", but that's
14*58b9f456SAndroid Build Coastguard Worker // about as good as we can do without implementing full xlocale support
15*58b9f456SAndroid Build Coastguard Worker // in Musl.
16*58b9f456SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
17*58b9f456SAndroid Build Coastguard Worker 
18*58b9f456SAndroid Build Coastguard Worker #ifndef _LIBCPP_SUPPORT_MUSL_XLOCALE_H
19*58b9f456SAndroid Build Coastguard Worker #define _LIBCPP_SUPPORT_MUSL_XLOCALE_H
20*58b9f456SAndroid Build Coastguard Worker 
21*58b9f456SAndroid Build Coastguard Worker #include <cstdlib>
22*58b9f456SAndroid Build Coastguard Worker #include <cwchar>
23*58b9f456SAndroid Build Coastguard Worker 
24*58b9f456SAndroid Build Coastguard Worker #ifdef __cplusplus
25*58b9f456SAndroid Build Coastguard Worker extern "C" {
26*58b9f456SAndroid Build Coastguard Worker #endif
27*58b9f456SAndroid Build Coastguard Worker 
strtoll_l(const char * nptr,char ** endptr,int base,locale_t)28*58b9f456SAndroid Build Coastguard Worker static inline long long strtoll_l(const char *nptr, char **endptr, int base,
29*58b9f456SAndroid Build Coastguard Worker                                   locale_t) {
30*58b9f456SAndroid Build Coastguard Worker   return strtoll(nptr, endptr, base);
31*58b9f456SAndroid Build Coastguard Worker }
32*58b9f456SAndroid Build Coastguard Worker 
strtoull_l(const char * nptr,char ** endptr,int base,locale_t)33*58b9f456SAndroid Build Coastguard Worker static inline unsigned long long strtoull_l(const char *nptr, char **endptr,
34*58b9f456SAndroid Build Coastguard Worker                                             int base, locale_t) {
35*58b9f456SAndroid Build Coastguard Worker   return strtoull(nptr, endptr, base);
36*58b9f456SAndroid Build Coastguard Worker }
37*58b9f456SAndroid Build Coastguard Worker 
wcstoll_l(const wchar_t * nptr,wchar_t ** endptr,int base,locale_t)38*58b9f456SAndroid Build Coastguard Worker static inline long long wcstoll_l(const wchar_t *nptr, wchar_t **endptr,
39*58b9f456SAndroid Build Coastguard Worker                                   int base, locale_t) {
40*58b9f456SAndroid Build Coastguard Worker   return wcstoll(nptr, endptr, base);
41*58b9f456SAndroid Build Coastguard Worker }
42*58b9f456SAndroid Build Coastguard Worker 
wcstoull_l(const wchar_t * nptr,wchar_t ** endptr,int base,locale_t)43*58b9f456SAndroid Build Coastguard Worker static inline unsigned long long wcstoull_l(const wchar_t *nptr,
44*58b9f456SAndroid Build Coastguard Worker                                             wchar_t **endptr, int base,
45*58b9f456SAndroid Build Coastguard Worker                                             locale_t) {
46*58b9f456SAndroid Build Coastguard Worker   return wcstoull(nptr, endptr, base);
47*58b9f456SAndroid Build Coastguard Worker }
48*58b9f456SAndroid Build Coastguard Worker 
wcstold_l(const wchar_t * nptr,wchar_t ** endptr,locale_t)49*58b9f456SAndroid Build Coastguard Worker static inline long double wcstold_l(const wchar_t *nptr, wchar_t **endptr,
50*58b9f456SAndroid Build Coastguard Worker                                     locale_t) {
51*58b9f456SAndroid Build Coastguard Worker   return wcstold(nptr, endptr);
52*58b9f456SAndroid Build Coastguard Worker }
53*58b9f456SAndroid Build Coastguard Worker 
54*58b9f456SAndroid Build Coastguard Worker #ifdef __cplusplus
55*58b9f456SAndroid Build Coastguard Worker }
56*58b9f456SAndroid Build Coastguard Worker #endif
57*58b9f456SAndroid Build Coastguard Worker 
58*58b9f456SAndroid Build Coastguard Worker #endif // _LIBCPP_SUPPORT_MUSL_XLOCALE_H
59