45
45
#include < sstream>
46
46
#include < cmath>
47
47
#elif defined(__ANDROID__)
48
- // Android's libc implementation Bionic currently only supports the "C" locale
49
- // (https://android.googlesource.com/platform/bionic/+/ndk-r11c/libc/bionic/locale.cpp#40).
50
- // As such, we have no choice but to map functions like strtod_l, which should
51
- // respect the given locale_t parameter, to functions like strtod, which do not.
52
48
#include < locale.h>
49
+
50
+ #include < android/api-level.h>
51
+
52
+ #if __ANDROID_API__ < 21 // Introduced in Android API 21 - L
53
+ static inline long double swift_strtold_l (const char *nptr, char **endptr,
54
+ locale_t ) {
55
+ return strtod (nptr, endptr);
56
+ }
57
+ #define strtold_l swift_strtold_l
58
+ #endif
59
+
60
+ #if __ANDROID_API__ < 26 // Introduced in Android API 26 - O
53
61
static double swift_strtod_l (const char *nptr, char **endptr, locale_t loc) {
54
62
return strtod (nptr, endptr);
55
63
}
56
64
static float swift_strtof_l (const char *nptr, char **endptr, locale_t loc) {
57
65
return strtof (nptr, endptr);
58
66
}
59
- static long double swift_strtold_l (const char *nptr,
60
- char **endptr,
61
- locale_t loc) {
62
- return strtod (nptr, endptr);
63
- }
64
67
#define strtod_l swift_strtod_l
65
68
#define strtof_l swift_strtof_l
66
- #define strtold_l swift_strtold_l
69
+ #endif
67
70
#elif defined(__linux__)
68
71
#include < locale.h>
69
72
#else
@@ -168,10 +171,11 @@ static locale_t getCLocale() {
168
171
}
169
172
#endif
170
173
174
+ #if !SWIFT_DTOA_FLOAT80_SUPPORT
171
175
#if defined(__APPLE__)
172
176
#define swift_snprintf_l snprintf_l
173
177
#elif defined(__CYGWIN__) || defined(_WIN32) || defined(__HAIKU__)
174
- // In Cygwin, swift_snprintf_l() is not used.
178
+ // swift_snprintf_l() is not used.
175
179
#else
176
180
static int swift_snprintf_l (char *Str, size_t StrSize, locale_t Locale,
177
181
const char *Format, ...) {
@@ -191,7 +195,6 @@ static int swift_snprintf_l(char *Str, size_t StrSize, locale_t Locale,
191
195
}
192
196
#endif
193
197
194
- #if !SWIFT_DTOA_FLOAT80_SUPPORT
195
198
template <typename T>
196
199
static uint64_t swift_floatingPointToString (char *Buffer, size_t BufferLength,
197
200
T Value, const char *Format,
0 commit comments