Merge changes I751520a1,I5762e815

* changes:
  Add legacy inline for wait4.
  Revert "Add legacy inlines for locale aware APIs."
diff --git a/libc/include/android/legacy_ctype_inlines.h b/libc/include/android/legacy_ctype_inlines.h
deleted file mode 100644
index ca01e3f..0000000
--- a/libc/include/android/legacy_ctype_inlines.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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 77fdd5d..93554e5 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>
 
-__BEGIN_DECLS
-
 #if __ANDROID_API__ < 21
 
+__BEGIN_DECLS
+
 static __inline float strtof(const char *nptr, char **endptr) {
   return (float)strtod(nptr, endptr);
 }
@@ -62,32 +62,7 @@
   return 0; /* devpts does this all for us! */
 }
 
-static __inline long double strtold_l(const char* nptr, char** endptr, locale_t l __unused) {
-  return strtold(nptr, endptr);
-}
-
-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
 #endif /* _ANDROID_LEGACY_STDLIB_INLINES_H_ */
diff --git a/libc/include/android/legacy_string_inlines.h b/libc/include/android/legacy_string_inlines.h
deleted file mode 100644
index ceab909..0000000
--- a/libc/include/android/legacy_string_inlines.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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 __attribute_pure__ int strcoll_l(const char* _Nonnull s1, const char* _Nonnull s2,
-                                                 locale_t l __unused)  {
-  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_sys_wait_inlines.h b/libc/include/android/legacy_sys_wait_inlines.h
new file mode 100644
index 0000000..63343eb
--- /dev/null
+++ b/libc/include/android/legacy_sys_wait_inlines.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ANDROID_LEGACY_SYS_WAIT_INLINES_H_
+#define _ANDROID_LEGACY_SYS_WAIT_INLINES_H_
+
+#include <sys/cdefs.h>
+#include <sys/syscall.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#if __ANDROID_API__ < 18
+
+__BEGIN_DECLS
+
+static __inline pid_t wait4(pid_t pid, int* status, int options, struct rusage* rusage) {
+  return __BIONIC_CAST(static_cast, pid_t, syscall(__NR_wait4, pid, status, options, rusage));
+}
+
+__END_DECLS
+
+#endif /* __ANDROID_API__ < 18 */
+
+#endif /* _ANDROID_LEGACY_SYS_WAIT_INLINES_H_ */
diff --git a/libc/include/android/legacy_time_inlines.h b/libc/include/android/legacy_time_inlines.h
deleted file mode 100644
index 319cc7c..0000000
--- a/libc/include/android/legacy_time_inlines.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 6c0d29e..0000000
--- a/libc/include/android/legacy_wchar_inlines.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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 wchar_t* _Nonnull ws2,
-                              locale_t l __unused) {
-  return wcscoll(ws1, ws2);
-}
-
-size_t wcsxfrm_l(wchar_t* dest, const wchar_t* _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
deleted file mode 100644
index c490944..0000000
--- a/libc/include/android/legacy_wctype_inlines.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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 e1b237a..f59b399 100644
--- a/libc/include/ctype.h
+++ b/libc/include/ctype.h
@@ -102,6 +102,4 @@
 
 __END_DECLS
 
-#include <android/legacy_ctype_inlines.h>
-
 #endif /* !_CTYPE_H_ */
diff --git a/libc/include/string.h b/libc/include/string.h
index 0114e6a..b3b3ed0 100644
--- a/libc/include/string.h
+++ b/libc/include/string.h
@@ -391,6 +391,4 @@
 
 __END_DECLS
 
-#include <android/legacy_string_inlines.h>
-
 #endif /* _STRING_H */
diff --git a/libc/include/sys/wait.h b/libc/include/sys/wait.h
index 90eb35b..f3972fc 100644
--- a/libc/include/sys/wait.h
+++ b/libc/include/sys/wait.h
@@ -51,7 +51,11 @@
 
 pid_t wait(int*);
 pid_t waitpid(pid_t, int*, int);
+#if __ANDROID_API__ >= 18
 pid_t wait4(pid_t, int*, int, struct rusage*) __INTRODUCED_IN(18);
+#else
+// Implemented as a static inline before 18.
+#endif
 
 /* Posix states that idtype_t should be an enumeration type, but
  * the kernel headers define P_ALL, P_PID and P_PGID as constant macros
@@ -63,4 +67,6 @@
 
 __END_DECLS
 
+#include <android/legacy_sys_wait_inlines.h>
+
 #endif /* _SYS_WAIT_H_ */
diff --git a/libc/include/time.h b/libc/include/time.h
index 898b816..37246b4 100644
--- a/libc/include/time.h
+++ b/libc/include/time.h
@@ -109,6 +109,4 @@
 
 __END_DECLS
 
-#include <android/legacy_time_inlines.h>
-
 #endif /* _TIME_H_ */
diff --git a/libc/include/wchar.h b/libc/include/wchar.h
index c3ad91c..2ee6c69 100644
--- a/libc/include/wchar.h
+++ b/libc/include/wchar.h
@@ -153,6 +153,4 @@
 
 __END_DECLS
 
-#include <android/legacy_wchar_inlines.h>
-
 #endif /* _WCHAR_H_ */
diff --git a/libc/include/wctype.h b/libc/include/wctype.h
index a77b212..0613e7e 100644
--- a/libc/include/wctype.h
+++ b/libc/include/wctype.h
@@ -63,6 +63,4 @@
 
 __END_DECLS
 
-#include <android/legacy_wctype_inlines.h>
-
 #endif /* _WCTYPE_H_ */