Merge changes Ic43d690d,Ifec6c320 * changes: Add legacy inlines for locale aware APIs. Add strtof_l and strtod_l.
diff --git a/libc/bionic/locale.cpp b/libc/bionic/locale.cpp index 2a4ce68..e51b38c 100644 --- a/libc/bionic/locale.cpp +++ b/libc/bionic/locale.cpp
@@ -196,6 +196,18 @@ return strncasecmp(s1, s2, n); } +double strtod_l(const char* s, char** end_ptr, locale_t) { + return strtod(s, end_ptr); +} + +float strtof_l(const char* s, char** end_ptr, locale_t) { + return strtof(s, end_ptr); +} + +long strtol_l(const char* s, char** end_ptr, int base, locale_t) { + return strtol(s, end_ptr, base); +} + long double strtold_l(const char* s, char** end_ptr, locale_t) { return strtold(s, end_ptr); } @@ -204,6 +216,10 @@ return strtoll(s, end_ptr, base); } +unsigned long strtoul_l(const char* s, char** end_ptr, int base, locale_t) { + return strtoul(s, end_ptr, base); +} + unsigned long long strtoull_l(const char* s, char** end_ptr, int base, locale_t) { return strtoull(s, end_ptr, base); }
diff --git a/libc/include/android/legacy_ctype_inlines.h b/libc/include/android/legacy_ctype_inlines.h new file mode 100644 index 0000000..ca01e3f --- /dev/null +++ b/libc/include/android/legacy_ctype_inlines.h
@@ -0,0 +1,87 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_LEGACY_CTYPE_INLINES_H +#define ANDROID_LEGACY_CTYPE_INLINES_H + +#include <ctype.h> +#include <sys/cdefs.h> + +__BEGIN_DECLS + +#if __ANDROID_API__ < 21 + +static __inline int isalnum_l(int c, locale_t l __unused) { + return isalnum(c); +} + +static __inline int isalpha_l(int c, locale_t l __unused) { + return isalpha(c); +} + +static __inline int isblank_l(int c, locale_t l __unused) { + return isblank(c); +} + +static __inline int iscntrl_l(int c, locale_t l __unused) { + return iscntrl(c); +} + +static __inline int isdigit_l(int c, locale_t l __unused) { + return isdigit(c); +} + +static __inline int isgraph_l(int c, locale_t l __unused) { + return isgraph(c); +} + +static __inline int islower_l(int c, locale_t l __unused) { + return islower(c); +} + +static __inline int isprint_l(int c, locale_t l __unused) { + return isprint(c); +} + +static __inline int ispunct_l(int c, locale_t l __unused) { + return ispunct(c); +} + +static __inline int isspace_l(int c, locale_t l __unused) { + return isspace(c); +} + +static __inline int isupper_l(int c, locale_t l __unused) { + return isupper(c); +} + +static __inline int isxdigit_l(int c, locale_t l __unused) { + return isxdigit(c); +} + +static __inline int tolower_l(int c, locale_t l __unused) { + return tolower(c); +} + +static __inline int toupper_l(int c, locale_t l __unused) { + return toupper(c); +} + +#endif /* __ANDROID_API__ < 21 */ + +__END_DECLS + +#endif /* ANDROID_LEGACY_CTYPE_INLINES_H */
diff --git a/libc/include/android/legacy_stdlib_inlines.h b/libc/include/android/legacy_stdlib_inlines.h index 93554e5..77fdd5d 100644 --- a/libc/include/android/legacy_stdlib_inlines.h +++ b/libc/include/android/legacy_stdlib_inlines.h
@@ -32,10 +32,10 @@ #include <stdlib.h> #include <sys/cdefs.h> -#if __ANDROID_API__ < 21 - __BEGIN_DECLS +#if __ANDROID_API__ < 21 + static __inline float strtof(const char *nptr, char **endptr) { return (float)strtod(nptr, endptr); } @@ -62,7 +62,32 @@ return 0; /* devpts does this all for us! */ } -__END_DECLS +static __inline long double strtold_l(const char* nptr, char** endptr, locale_t l __unused) { + return strtold(nptr, endptr); +} -#endif +static __inline long long strtoll_l(const char* nptr, char** endptr, int base, locale_t l __unused) { + return strtoll(nptr, endptr, base); +} + +static __inline unsigned long long strtoull_l(const char* nptr, char** endptr, int base, + locale_t l __unused) { + return strtoull(nptr, endptr, base); +} + +#endif /* __ANDROID_API__ < 21 */ + +#if __ANDROID_API__ < __ANDROID_API_FUTURE__ + +static __inline float strtof_l(const char* nptr, char** endptr, locale_t l __unused) { + return strtof(nptr, endptr); +} + +static __inline double strtod_l(const char* nptr, char** endptr, locale_t l __unused) { + return strtod(nptr, endptr); +} + +#endif /* __ANDROID_API__ < __ANDROID_API_FUTURE__ */ + +__END_DECLS #endif /* _ANDROID_LEGACY_STDLIB_INLINES_H_ */
diff --git a/libc/include/android/legacy_string_inlines.h b/libc/include/android/legacy_string_inlines.h new file mode 100644 index 0000000..6b711d7 --- /dev/null +++ b/libc/include/android/legacy_string_inlines.h
@@ -0,0 +1,41 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_LEGACY_STRING_INLINES_H +#define ANDROID_LEGACY_STRING_INLINES_H + +#include <string.h> +#include <sys/cdefs.h> + +__BEGIN_DECLS + +#if __ANDROID_API__ < 21 + +static __inline int strcoll_l(const char* _Nonnull s1, const char* _Nonnull s2, + locale_t l __unused) __purefunc { + return strcoll(s1, s2); +} + +size_t strxfrm_l(char* __restrict dest, const char* _Nonnull __restrict src, size_t n, + locale_t l __unused) { + return strxfrm(dest, src, n); +} + +#endif /* __ANDROID_API__ < 21 */ + +__END_DECLS + +#endif /* ANDROID_LEGACY_STRING_INLINES_H */
diff --git a/libc/include/android/legacy_time_inlines.h b/libc/include/android/legacy_time_inlines.h new file mode 100644 index 0000000..319cc7c --- /dev/null +++ b/libc/include/android/legacy_time_inlines.h
@@ -0,0 +1,36 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_LEGACY_TIME_INLINES_H +#define ANDROID_LEGACY_TIME_INLINES_H + +#include <sys/cdefs.h> +#include <time.h> + +__BEGIN_DECLS + +#if __ANDROID_API__ < 21 + +static __inline int strftime_l(char* s, size_t max, const char* format, const struct tm* tm, + locale_t l __unused) { + return strftime(s, max, format, tm); +} + +#endif /* __ANDROID_API__ < 21 */ + +__END_DECLS + +#endif /* ANDROID_LEGACY_TIME_INLINES_H */
diff --git a/libc/include/android/legacy_wchar_inlines.h b/libc/include/android/legacy_wchar_inlines.h new file mode 100644 index 0000000..d8f1b7b --- /dev/null +++ b/libc/include/android/legacy_wchar_inlines.h
@@ -0,0 +1,54 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_LEGACY_WCHAR_INLINES_H +#define ANDROID_LEGACY_WCHAR_INLINES_H + +#include <sys/cdefs.h> +#include <wchar.h> + +__BEGIN_DECLS + +#if __ANDROID_API__ < 21 + +static __inline int wcscoll_l(const wchar_t* _Nonnull ws1, const char* _Nonull ws2, + locale_t l __unused) { + return wcscoll(ws1, ws2); +} + +size_t wcsxfrm_l(wchar_t* dest, const char* _Nonnull src, size_t n, locale_t l __unused) { + return wcsxfrm(dest, src, n); +} + +static inline long double wcstold_l(const wchar_t* nptr, wchar_t** endptr, locale_t l __unused) { + return wcstold(nptr, endptr); +} + +static inline long long wcstoll_l(const wchar_t* nptr, wchar_t** endptr, int base, + locale_t l __unused) { + return wcstoll(nptr, endptr, base); +} + +static inline unsigned long long wcstoull_l(const wchar_t* nptr, wchar_t** endptr, int base, + locale_t l __unused) { + return wcstoull(nptr, endptr, base); +} + +#endif /* __ANDROID_API__ < 21 */ + +__END_DECLS + +#endif /* ANDROID_LEGACY_WCHAR_INLINES_H */
diff --git a/libc/include/android/legacy_wctype_inlines.h b/libc/include/android/legacy_wctype_inlines.h new file mode 100644 index 0000000..c490944 --- /dev/null +++ b/libc/include/android/legacy_wctype_inlines.h
@@ -0,0 +1,87 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_LEGACY_WCTYPE_INLINES_H +#define ANDROID_LEGACY_WCTYPE_INLINES_H + +#include <sys/cdefs.h> +#include <wctype.h> + +__BEGIN_DECLS + +#if __ANDROID_API__ < 21 + +static __inline int iswalnum_l(wint_t wc, locale_t l __unused) { + return iswalnum(wc); +} + +static __inline int iswalpha_l(wint_t wc, locale_t l __unused) { + return iswalpha(wc); +} + +static __inline int iswblank_l(wint_t wc, locale_t l __unused) { + return iswblank(wc); +} + +static __inline int iswcntrl_l(wint_t wc, locale_t l __unused) { + return iswcntrl(wc); +} + +static __inline int iswdigit_l(wint_t wc, locale_t l __unused) { + return iswdigit(wc); +} + +static __inline int iswgraph_l(wint_t wc, locale_t l __unused) { + return iswgraph(wc); +} + +static __inline int iswlower_l(wint_t wc, locale_t l __unused) { + return iswlower(wc); +} + +static __inline int iswprint_l(wint_t wc, locale_t l __unused) { + return iswprint(wc); +} + +static __inline int iswpunct_l(wint_t wc, locale_t l __unused) { + return iswpunct(wc); +} + +static __inline int iswspace_l(wint_t wc, locale_t l __unused) { + return iswspace(wc); +} + +static __inline int iswupper_l(wint_t wc, locale_t l __unused) { + return iswupper(wc); +} + +static __inline int iswxdigit_l(wint_t wc, locale_t l __unused) { + return iswxdigit(wc); +} + +static __inline wint_t towlower_l(wint_t wc, locale_t l __unused) { + return towlower(wc); +} + +static __inline wint_t towupper_l(wint_t wc, locale_t l __unused) { + return towupper(wc); +} + +#endif /* __ANDROID_API__ < 21 */ + +__END_DECLS + +#endif /* ANDROID_LEGACY_WCTYPE_INLINES_H */
diff --git a/libc/include/ctype.h b/libc/include/ctype.h index a07f9c8..4818fef 100644 --- a/libc/include/ctype.h +++ b/libc/include/ctype.h
@@ -97,4 +97,6 @@ __END_DECLS +#include <android/legacy_ctype_inlines.h> + #endif /* !_CTYPE_H_ */
diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h index 6b0ec12..f7f4014 100644 --- a/libc/include/stdlib.h +++ b/libc/include/stdlib.h
@@ -77,8 +77,12 @@ double strtod(const char*, char**); long double strtold(const char*, char**) __INTRODUCED_IN(21); +double strtod_l(const char*, char**, locale_t) __INTRODUCED_IN_FUTURE; +float strtof_l(const char*, char**, locale_t) __INTRODUCED_IN_FUTURE; +long strtol_l(const char*, char**, int, locale_t) __INTRODUCED_IN_FUTURE; long double strtold_l(const char*, char**, locale_t) __INTRODUCED_IN(21); long long strtoll_l(const char*, char**, int, locale_t) __INTRODUCED_IN(21); +unsigned long strtoul_l(const char*, char**, int, locale_t) __INTRODUCED_IN_FUTURE; unsigned long long strtoull_l(const char*, char**, int, locale_t) __INTRODUCED_IN(21); int atoi(const char*) __purefunc;
diff --git a/libc/include/string.h b/libc/include/string.h index 4a83c4e..b945883 100644 --- a/libc/include/string.h +++ b/libc/include/string.h
@@ -387,4 +387,6 @@ __END_DECLS +#include <android/legacy_string_inlines.h> + #endif /* _STRING_H */
diff --git a/libc/include/time.h b/libc/include/time.h index 888ce12..691aa06 100644 --- a/libc/include/time.h +++ b/libc/include/time.h
@@ -104,4 +104,6 @@ __END_DECLS +#include <android/legacy_time_inlines.h> + #endif /* _TIME_H_ */
diff --git a/libc/include/wchar.h b/libc/include/wchar.h index e7c294f..1c0327e 100644 --- a/libc/include/wchar.h +++ b/libc/include/wchar.h
@@ -149,4 +149,6 @@ __END_DECLS +#include <android/legacy_wchar_inlines.h> + #endif /* _WCHAR_H_ */
diff --git a/libc/include/wctype.h b/libc/include/wctype.h index 1c9731f..fb17f22 100644 --- a/libc/include/wctype.h +++ b/libc/include/wctype.h
@@ -59,4 +59,6 @@ __END_DECLS +#include <android/legacy_wctype_inlines.h> + #endif /* _WCTYPE_H_ */
diff --git a/libc/libc.arm.map b/libc/libc.arm.map index c4243f4..eb75e8f 100644 --- a/libc/libc.arm.map +++ b/libc/libc.arm.map
@@ -1306,6 +1306,10 @@ sigpause; # future sigrelse; # future sigset; # future + strtod_l; # future + strtof_l; # future + strtol_l; # future + strtoul_l; # future sync_file_range; # future towctrans; # future towctrans_l; # future
diff --git a/libc/libc.arm64.map b/libc/libc.arm64.map index 2393d22..28755d4 100644 --- a/libc/libc.arm64.map +++ b/libc/libc.arm64.map
@@ -1228,6 +1228,10 @@ sigpause; # future sigrelse; # future sigset; # future + strtod_l; # future + strtof_l; # future + strtol_l; # future + strtoul_l; # future sync_file_range; # future towctrans; # future towctrans_l; # future
diff --git a/libc/libc.map.txt b/libc/libc.map.txt index 19fdb4b..1fba8ee 100644 --- a/libc/libc.map.txt +++ b/libc/libc.map.txt
@@ -1331,6 +1331,10 @@ sigpause; # future sigrelse; # future sigset; # future + strtod_l; # future + strtof_l; # future + strtol_l; # future + strtoul_l; # future sync_file_range; # future towctrans; # future towctrans_l; # future
diff --git a/libc/libc.mips.map b/libc/libc.mips.map index 1461dc5..f61f615 100644 --- a/libc/libc.mips.map +++ b/libc/libc.mips.map
@@ -1290,6 +1290,10 @@ sigpause; # future sigrelse; # future sigset; # future + strtod_l; # future + strtof_l; # future + strtol_l; # future + strtoul_l; # future sync_file_range; # future towctrans; # future towctrans_l; # future
diff --git a/libc/libc.mips64.map b/libc/libc.mips64.map index 2393d22..28755d4 100644 --- a/libc/libc.mips64.map +++ b/libc/libc.mips64.map
@@ -1228,6 +1228,10 @@ sigpause; # future sigrelse; # future sigset; # future + strtod_l; # future + strtof_l; # future + strtol_l; # future + strtoul_l; # future sync_file_range; # future towctrans; # future towctrans_l; # future
diff --git a/libc/libc.x86.map b/libc/libc.x86.map index 57b81a8..a166361 100644 --- a/libc/libc.x86.map +++ b/libc/libc.x86.map
@@ -1288,6 +1288,10 @@ sigpause; # future sigrelse; # future sigset; # future + strtod_l; # future + strtof_l; # future + strtol_l; # future + strtoul_l; # future sync_file_range; # future towctrans; # future towctrans_l; # future
diff --git a/libc/libc.x86_64.map b/libc/libc.x86_64.map index 2393d22..28755d4 100644 --- a/libc/libc.x86_64.map +++ b/libc/libc.x86_64.map
@@ -1228,6 +1228,10 @@ sigpause; # future sigrelse; # future sigset; # future + strtod_l; # future + strtof_l; # future + strtol_l; # future + strtoul_l; # future sync_file_range; # future towctrans; # future towctrans_l; # future