libc/wchar: Define mbstate_t correctly - scc - simple c99 compiler
 (HTM) git clone git://git.simple-cc.org/scc
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit ab077b6a7eb4f2d524d5cd53c49a3dde531cde4a
 (DIR) parent 3eedc954682df1ec5b47667cc27a9ab69642e7b1
 (HTM) Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
       Date:   Tue,  4 Mar 2025 19:45:27 +0100
       
       libc/wchar: Define mbstate_t correctly
       
       The definition of the mbstate_t type depends of the target
       platform, and it should be defined in the sys/cdefs.h files.
       
       Diffstat:
         M include/bits/darwin/sys/cdefs.h     |       9 ++++++++-
         M include/bits/dragonfly/sys/cdefs.h  |       9 ++++++++-
         M include/bits/freebsd/sys/cdefs.h    |       9 ++++++++-
         M include/bits/linux/sys/cdefs.h      |       9 ++++++++-
         M include/bits/netbsd/sys/cdefs.h     |       9 ++++++++-
         M include/bits/openbsd/sys/cdefs.h    |       9 ++++++++-
         M include/wchar.h                     |       7 +------
       
       7 files changed, 49 insertions(+), 12 deletions(-)
       ---
 (DIR) diff --git a/include/bits/darwin/sys/cdefs.h b/include/bits/darwin/sys/cdefs.h
       @@ -1 +1,8 @@
       -/* nothing fpr darwin */
       +#ifdef _NEED_MBSTATE_T
       +#ifndef _MBSTATE_T
       +typedef union {
       +        char __mbstate8[128];
       +} mbstate_t;
       +#define _MBSTATE_T
       +#endif
       +#endif
 (DIR) diff --git a/include/bits/dragonfly/sys/cdefs.h b/include/bits/dragonfly/sys/cdefs.h
       @@ -1 +1,8 @@
       -/* nothing for dragonfly */
       +#ifdef _NEED_MBSTATE_T
       +#ifndef _MBSTATE_T
       +typedef union {
       +        char __mbstate8[128];
       +} mbstate_t;
       +#define _MBSTATE_T
       +#endif
       +#endif
 (DIR) diff --git a/include/bits/freebsd/sys/cdefs.h b/include/bits/freebsd/sys/cdefs.h
       @@ -1 +1,8 @@
       -/* nothing for Openbsd */
       +#ifdef _NEED_MBSTATE_T
       +#ifndef _MBSTATE_T
       +typedef union {
       +        char __mbstate8[128];
       +} mbstate_t;
       +#define _MBSTATE_T
       +#endif
       +#endif
 (DIR) diff --git a/include/bits/linux/sys/cdefs.h b/include/bits/linux/sys/cdefs.h
       @@ -1 +1,8 @@
       -/* nothing for Linux */
       +#ifdef _NEED_MBSTATE_T
       +#ifndef _MBSTATE_T
       +typedef struct __mbstate_t {
       +        unsigned __opaque1, __opaque2;
       +} mbstate_t;
       +#define _MBSTATE_T
       +#endif
       +#endif
 (DIR) diff --git a/include/bits/netbsd/sys/cdefs.h b/include/bits/netbsd/sys/cdefs.h
       @@ -1 +1,8 @@
       -/* nothing for netbsd */
       +#ifdef _NEED_MBSTATE_T
       +#ifndef _MBSTATE_T
       +typedef union {
       +        char __mbstate8[128];
       +} mbstate_t;
       +#define _MBSTATE_T
       +#endif
       +#endif
 (DIR) diff --git a/include/bits/openbsd/sys/cdefs.h b/include/bits/openbsd/sys/cdefs.h
       @@ -1 +1,8 @@
       -/* nothing for Openbsd */
       +#ifdef _NEED_MBSTATE_T
       +#ifndef _MBSTATE_T
       +typedef union {
       +        char __mbstate8[128];
       +} mbstate_t;
       +#define _MBSTATE_T
       +#endif
       +#endif
 (DIR) diff --git a/include/wchar.h b/include/wchar.h
       @@ -8,15 +8,10 @@
        #define _NEED_WCHARLIM
        #define _NEED_WINT
        #define _NEED_VA_LIST
       +#define _NEED_MBSTATE_T
        #include <sys/cdefs.h>
        #include <arch/cdefs.h>
        
       -/*
       - * We only support utf8 as multibyte encoding and
       - * it does not have state.
       - */
       -typedef int mbstate_t;
       -
        struct tm;
        struct _FILE;