refactor headers, especially alltypes.h, and improve C++ ABI compat
[musl] / include / wchar.h
index b1c6b7f..a6742e3 100644 (file)
@@ -5,14 +5,10 @@
 extern "C" {
 #endif
 
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
+#include <features.h>
 
 #define __NEED_FILE
-#define __NEED_va_list
+#define __NEED___isoc_va_list
 #define __NEED_size_t
 #define __NEED_wchar_t
 #define __NEED_wint_t
@@ -20,6 +16,7 @@ extern "C" {
 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
  || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
 #define __NEED_locale_t
+#define __NEED_va_list
 #endif
 
 #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
@@ -28,19 +25,20 @@ extern "C" {
 
 #include <bits/alltypes.h>
 
-#include <bits/wchar.h>
-
-#undef NULL
-#ifdef __cplusplus
-#define NULL 0
+#if L'\0'-1 > 0
+#define WCHAR_MAX (0xffffffffu+L'\0')
+#define WCHAR_MIN (0+L'\0')
 #else
-#define NULL ((void*)0)
+#define WCHAR_MAX (0x7fffffff+L'\0')
+#define WCHAR_MIN (-1-0x7fffffff+L'\0')
 #endif
 
+#define NULL 0L
+
 #undef WEOF
 #define WEOF (-1)
 
-typedef struct
+typedef struct __mbstate_t
 {
        unsigned __opaque1, __opaque2;
 } mbstate_t;
@@ -108,17 +106,17 @@ int wprintf (const wchar_t *__restrict, ...);
 int fwprintf (FILE *__restrict, const wchar_t *__restrict, ...);
 int swprintf (wchar_t *__restrict, size_t, const wchar_t *__restrict, ...);
 
-int vwprintf (const wchar_t *__restrict, va_list);
-int vfwprintf (FILE *__restrict, const wchar_t *__restrict, va_list);
-int vswprintf (wchar_t *__restrict, size_t, const wchar_t *__restrict, va_list);
+int vwprintf (const wchar_t *__restrict, __isoc_va_list);
+int vfwprintf (FILE *__restrict, const wchar_t *__restrict, __isoc_va_list);
+int vswprintf (wchar_t *__restrict, size_t, const wchar_t *__restrict, __isoc_va_list);
 
 int wscanf (const wchar_t *__restrict, ...);
 int fwscanf (FILE *__restrict, const wchar_t *__restrict, ...);
 int swscanf (const wchar_t *__restrict, const wchar_t *__restrict, ...);
 
-int vwscanf (const wchar_t *__restrict, va_list);
-int vfwscanf (FILE *__restrict, const wchar_t *__restrict, va_list);
-int vswscanf (const wchar_t *__restrict, const wchar_t *__restrict, va_list);
+int vwscanf (const wchar_t *__restrict, __isoc_va_list);
+int vfwscanf (FILE *__restrict, const wchar_t *__restrict, __isoc_va_list);
+int vswscanf (const wchar_t *__restrict, const wchar_t *__restrict, __isoc_va_list);
 
 wint_t fgetwc (FILE *);
 wint_t getwc (FILE *);