Clean up <uchar.h> and <wctype.h> transitive includes.

Bug: http://b/30367366
Change-Id: I63212a34c54ca07223a15aa5be4da3bdc6aa38a8
diff --git a/libc/include/bits/mbstate_t.h b/libc/include/bits/mbstate_t.h
new file mode 100644
index 0000000..057a2c9
--- /dev/null
+++ b/libc/include/bits/mbstate_t.h
@@ -0,0 +1,41 @@
+/*
+ * 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 _BITS_MBSTATE_T_H_
+#define _BITS_MBSTATE_T_H_
+
+#include <sys/cdefs.h>
+
+typedef struct {
+  unsigned char __seq[4];
+#ifdef __LP64__
+  unsigned char __reserved[4];
+#endif
+} mbstate_t;
+
+#endif
diff --git a/libc/include/bits/wctype.h b/libc/include/bits/wctype.h
index fe7c80e..b98e500 100644
--- a/libc/include/bits/wctype.h
+++ b/libc/include/bits/wctype.h
@@ -35,6 +35,8 @@
 
 typedef __WINT_TYPE__ wint_t;
 
+#define WEOF __BIONIC_CAST(static_cast, wint_t, -1)
+
 int iswalnum(wint_t);
 int iswalpha(wint_t);
 int iswblank(wint_t) __INTRODUCED_IN(21);
diff --git a/libc/include/stdatomic.h b/libc/include/stdatomic.h
index 8347f83..b487fd1 100644
--- a/libc/include/stdatomic.h
+++ b/libc/include/stdatomic.h
@@ -141,11 +141,9 @@
  * bits as a T.
  */
 
-#include <stddef.h>  /* For ptrdiff_t.                          */
-#include <stdint.h>  /* TODO: Should pollute namespace less.    */
-#if __STDC_VERSION__ >= 201112L
-# include <uchar.h>  /* For char16_t and char32_t.              */
-#endif
+#include <stddef.h>  /* For ptrdiff_t. */
+#include <stdint.h>  /* TODO: don't drag in all the macros, just the types. */
+#include <uchar.h>   /* For char16_t and char32_t. */
 
 #ifdef __clang__
 # if __has_extension(c_atomic) || __has_extension(cxx_atomic)
diff --git a/libc/include/uchar.h b/libc/include/uchar.h
index 6b995ab..818acb1 100644
--- a/libc/include/uchar.h
+++ b/libc/include/uchar.h
@@ -29,8 +29,9 @@
 #ifndef _UCHAR_H_
 #define _UCHAR_H_
 
+#include <stddef.h>
 #include <sys/cdefs.h>
-#include <wchar.h>
+#include <bits/mbstate_t.h>
 
 __BEGIN_DECLS
 
diff --git a/libc/include/wchar.h b/libc/include/wchar.h
index 1f0c1c5..ee75148 100644
--- a/libc/include/wchar.h
+++ b/libc/include/wchar.h
@@ -36,18 +36,12 @@
 #include <time.h>
 #include <xlocale.h>
 
+#include <bits/mbstate_t.h>
 #include <bits/wchar_limits.h>
 #include <bits/wctype.h>
 
 __BEGIN_DECLS
 
-typedef struct {
-  uint8_t __seq[4];
-#ifdef __LP64__
-  char __reserved[4];
-#endif
-} mbstate_t;
-
 enum {
     WC_TYPE_INVALID = 0,
     WC_TYPE_ALNUM,
@@ -65,8 +59,6 @@
     WC_TYPE_MAX
 };
 
-#define  WEOF        ((wint_t)(-1))
-
 wint_t            btowc(int);
 int               fwprintf(FILE *, const wchar_t *, ...);
 int               fwscanf(FILE *, const wchar_t *, ...);
diff --git a/libc/include/wctype.h b/libc/include/wctype.h
index 96464b1..1c9731f 100644
--- a/libc/include/wctype.h
+++ b/libc/include/wctype.h
@@ -30,8 +30,8 @@
 #define _WCTYPE_H_
 
 #include <bits/wctype.h>
-#include <wchar.h>
 #include <sys/cdefs.h>
+#include <xlocale.h>
 
 __BEGIN_DECLS