Add legacy inlines for locale aware APIs.

Test: make checkbuild tests
Bug: http://b/31639993
Change-Id: Ic43d690dff3c6960d7826bd0b064640a3ea0e883
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/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_ */