Test POSIX 1003.1 2016 chapter 13 "Headers".

And fix one thing that this found: apparently <stdlib.h> should also
make the various *WAIT* macros available.

Bug: N/A
Test: builds
Change-Id: Id879bf3c1bddd1170261a809e7280150a74d6b3d
diff --git a/libc/include/bits/wait.h b/libc/include/bits/wait.h
new file mode 100644
index 0000000..a35f789
--- /dev/null
+++ b/libc/include/bits/wait.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2017 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 _BITS_WAIT_H_
+#define _BITS_WAIT_H_
+
+#include <sys/cdefs.h>
+
+#include <linux/wait.h>
+
+#define WEXITSTATUS(s) (((s) & 0xff00) >> 8)
+#define WCOREDUMP(s)   ((s) & 0x80)
+#define WTERMSIG(s)    ((s) & 0x7f)
+#define WSTOPSIG(s)    WEXITSTATUS(s)
+
+#define WIFEXITED(s)    (WTERMSIG(s) == 0)
+#define WIFSTOPPED(s)   (WTERMSIG(s) == 0x7f)
+#define WIFSIGNALED(s)  (WTERMSIG((s)+1) >= 2)
+#define WIFCONTINUED(s) ((s) == 0xffff)
+
+#define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
+#define W_STOPCODE(sig)      ((sig) << 8 | 0x7f)
+
+#endif
diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h
index cf0dea8..1ae3c6e 100644
--- a/libc/include/stdlib.h
+++ b/libc/include/stdlib.h
@@ -29,12 +29,12 @@
 #ifndef _STDLIB_H
 #define _STDLIB_H
 
-#include <sys/cdefs.h>
-#include <xlocale.h>
-
 #include <alloca.h>
+#include <bits/wait.h>
 #include <malloc.h>
 #include <stddef.h>
+#include <sys/cdefs.h>
+#include <xlocale.h>
 
 __BEGIN_DECLS
 
diff --git a/libc/include/sys/wait.h b/libc/include/sys/wait.h
index e259e31..106946b 100644
--- a/libc/include/sys/wait.h
+++ b/libc/include/sys/wait.h
@@ -29,6 +29,7 @@
 #ifndef _SYS_WAIT_H_
 #define _SYS_WAIT_H_
 
+#include <bits/wait.h>
 #include <sys/cdefs.h>
 #include <sys/types.h>
 #include <sys/resource.h>
@@ -37,19 +38,6 @@
 
 __BEGIN_DECLS
 
-#define WEXITSTATUS(s)  (((s) & 0xff00) >> 8)
-#define WCOREDUMP(s)    ((s) & 0x80)
-#define WTERMSIG(s)     ((s) & 0x7f)
-#define WSTOPSIG(s)     WEXITSTATUS(s)
-
-#define WIFEXITED(s)    (WTERMSIG(s) == 0)
-#define WIFSTOPPED(s)   (WTERMSIG(s) == 0x7f)
-#define WIFSIGNALED(s)  (WTERMSIG((s)+1) >= 2)
-#define WIFCONTINUED(s) ((s) == 0xffff)
-
-#define W_EXITCODE(ret, sig)    ((ret) << 8 | (sig))
-#define W_STOPCODE(sig)         ((sig) << 8 | 0x7f)
-
 pid_t wait(int* __status);
 pid_t waitpid(pid_t __pid, int* __status, int __options);
 #if __ANDROID_API__ >= __ANDROID_API_J_MR2__