aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/bits/types.h20
-rw-r--r--include/wchar.h12
2 files changed, 29 insertions, 3 deletions
diff --git a/include/bits/types.h b/include/bits/types.h
index dfaef5d..f2318c1 100644
--- a/include/bits/types.h
+++ b/include/bits/types.h
@@ -94,11 +94,27 @@ typedef unsigned __LIMITED_PTR_INT uptrdiff_t;
*/
# if defined(__NEED_wchar_t) && !defined(__DEFINED_wchar_t)
# define __DEFINED_wchar_t
-typedef long int wchar_t
+# if __WCHAR_BIT == 8
+typedef __WCHAR_SIGNESS __INT8 wchar_t
+# elif __WCHAR_BIT == 16
+typedef __WCHAR_SIGNESS __INT16 wchar_t
+# elif __WCHAR_BIT == 32
+typedef __WCHAR_SIGNESS __INT32 wchar_t
+# elif __WCHAR_BIT == 64
+typedef __WCHAR_SIGNESS __INT64 wchar_t
+# endif
__warning("'wchar_t' is not guaranteed to be defined as expected, use 'int32_t'.");
# endif
# ifndef __WCHAR_MAX
-# define __WCHAR_MAX INTPTR_MAX
+# if __WCHAR_BIT == 8
+# define __WCHAR_MAX INT8_MAX
+# elif __WCHAR_BIT == 16
+# define __WCHAR_MAX INT16_MAX
+# elif __WCHAR_BIT == 32
+# define __WCHAR_MAX INT32_MAX
+# elif __WCHAR_BIT == 64
+# define __WCHAR_MAX INT64_MAX
+# endif
# endif
diff --git a/include/wchar.h b/include/wchar.h
index aade683..4437e6d 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -42,7 +42,17 @@
* End of a wide-character stream
*/
#ifndef WEOF
-# define WEOF -1L
+# if __WCHAR_BIT == __CHAR_BIT
+# define WEOF -1
+# elif __WCHAR_BIT == __SHORT_BIT
+# define WEOF -1
+# elif __WCHAR_BIT == __INT_BIT
+# define WEOF -1
+# elif __WCHAR_BIT == __LONG_BIT
+# define WEOF -1L
+# else
+# define WEOF -1LL
+# endif
#endif