Skip to content

Commit a34ac08

Browse files
committed
stubs: clean up android support routines
Some of the previously used stubs are no longer needed in newer releases of the Android API. Android L and Android O provide the functions in their associated versions of bionic. This is needed to build against a newer version of the SDK.
1 parent 5b7b6ef commit a34ac08

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

stdlib/public/stubs/Stubs.cpp

Lines changed: 13 additions & 10 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

0 commit comments

Comments
 (0)