Skip to content

Commit 14e0a5b

Browse files
authored
Merge pull request #15937 from compnerd/stubs
Stubs
2 parents 7f40440 + 302ce63 commit 14e0a5b

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

stdlib/public/stubs/Stubs.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,28 @@
4545
#include <sstream>
4646
#include <cmath>
4747
#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.
5248
#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
5361
static double swift_strtod_l(const char *nptr, char **endptr, locale_t loc) {
5462
return strtod(nptr, endptr);
5563
}
5664
static float swift_strtof_l(const char *nptr, char **endptr, locale_t loc) {
5765
return strtof(nptr, endptr);
5866
}
59-
static long double swift_strtold_l(const char *nptr,
60-
char **endptr,
61-
locale_t loc) {
62-
return strtod(nptr, endptr);
63-
}
6467
#define strtod_l swift_strtod_l
6568
#define strtof_l swift_strtof_l
66-
#define strtold_l swift_strtold_l
69+
#endif
6770
#elif defined(__linux__)
6871
#include <locale.h>
6972
#else
@@ -168,10 +171,11 @@ static locale_t getCLocale() {
168171
}
169172
#endif
170173

174+
#if !SWIFT_DTOA_FLOAT80_SUPPORT
171175
#if defined(__APPLE__)
172176
#define swift_snprintf_l snprintf_l
173177
#elif defined(__CYGWIN__) || defined(_WIN32) || defined(__HAIKU__)
174-
// In Cygwin, swift_snprintf_l() is not used.
178+
// swift_snprintf_l() is not used.
175179
#else
176180
static int swift_snprintf_l(char *Str, size_t StrSize, locale_t Locale,
177181
const char *Format, ...) {
@@ -191,7 +195,6 @@ static int swift_snprintf_l(char *Str, size_t StrSize, locale_t Locale,
191195
}
192196
#endif
193197

194-
#if !SWIFT_DTOA_FLOAT80_SUPPORT
195198
template <typename T>
196199
static uint64_t swift_floatingPointToString(char *Buffer, size_t BufferLength,
197200
T Value, const char *Format,

0 commit comments

Comments
 (0)