|
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
|
|
0 commit comments