about summary refs log tree commit diff
path: root/wcsmbs/wchar.h
diff options
context:
space:
mode:
Diffstat (limited to 'wcsmbs/wchar.h')
-rw-r--r--wcsmbs/wchar.h30
1 files changed, 18 insertions, 12 deletions
diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h
index e9a3fba8c1..569fd2b2f6 100644
--- a/wcsmbs/wchar.h
+++ b/wcsmbs/wchar.h
@@ -23,7 +23,7 @@
 
 #ifndef _WCHAR_H
 
-#ifndef __need_mbstate_t
+#if !defined __need_mbstate_t && !defined __need_wint_t
 # define _WCHAR_H 1
 # include <features.h>
 #endif
@@ -39,38 +39,40 @@
 # define __need___va_list
 # include <stdarg.h>
 
+# include <bits/wchar.h>
+
 /* Get size_t, wchar_t, wint_t and NULL from <stddef.h>.  */
 # define __need_size_t
 # define __need_wchar_t
 # define __need_NULL
 #endif
-#define __need_wint_t
-#include <stddef.h>
-
-#include <bits/wchar.h>
+#if defined _WCHAR_H || defined __need_wint_t || !defined __WINT_TYPE__
+# undef __need_wint_t
+# define __need_wint_t
+# include <stddef.h>
 
 /* We try to get wint_t from <stddef.h>, but not all GCC versions define it
    there.  So define it ourselves if it remains undefined.  */
-#ifndef _WINT_T
+# ifndef _WINT_T
 /* Integral type unchanged by default argument promotions that can
    hold any value corresponding to members of the extended character
    set, as well as at least one value that does not correspond to any
    member of the extended character set.  */
-# define _WINT_T
+#  define _WINT_T
 typedef unsigned int wint_t;
-#else
+# else
 /* Work around problems with the <stddef.h> file which doesn't put
    wint_t in the std namespace.  */
-# if defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES \
-     && defined __WINT_TYPE__
+#  if defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES \
+      && defined __WINT_TYPE__
 __BEGIN_NAMESPACE_STD
 typedef __WINT_TYPE__ wint_t;
 __END_NAMESPACE_STD
+#  endif
 # endif
 #endif
 
-
-#ifndef __mbstate_t_defined
+#if (defined _WCHAR_H || defined __need_mbstate_t) && !defined __mbstate_t_defined
 # define __mbstate_t_defined	1
 /* Conversion state information.  */
 typedef struct
@@ -78,7 +80,11 @@ typedef struct
   int __count;
   union
   {
+# ifdef __WINT_TYPE__
+    __WINT_TYPE__ __wch;
+# else
     wint_t __wch;
+# endif
     char __wchb[4];
   } __value;		/* Value so far.  */
 } __mbstate_t;