From 51c93c4b3959cdb4b4588f86af5e8cc5b75f0966 Mon Sep 17 00:00:00 2001 From: Jeremy Soller <jackpot51@gmail.com> Date: Thu, 11 May 2023 10:41:49 -0600 Subject: [PATCH] Cleanup of wchar_t and wint_t definitions --- include/bits/wchar.h | 14 ++++++++------ include/bits/wctype.h | 8 -------- include/stddef.h | 6 ------ src/c/wchar.c | 2 ++ src/header/stdlib/cbindgen.toml | 2 +- src/header/wchar/cbindgen.toml | 3 +-- src/header/wctype/cbindgen.toml | 1 - 7 files changed, 12 insertions(+), 24 deletions(-) delete mode 100644 include/bits/wctype.h diff --git a/include/bits/wchar.h b/include/bits/wchar.h index b5f910eb..6eddf334 100644 --- a/include/bits/wchar.h +++ b/include/bits/wchar.h @@ -1,17 +1,19 @@ #ifndef _BITS_WCHAR_H #define _BITS_WCHAR_H -#define WEOF (0xffffffffu) -#define WCHAR_MIN (0) -#define WCHAR_MAX (0x7fffffff) - +// NULL, size_t #define __need_size_t -#define __need_wchar_t -#define __need_wint_t #define __need_NULL +#include <stddef.h> +// int32_t, uint32_t, WCHAR_MIN, WCHAR_MAX #include <stdint.h> +#define WEOF (0xffffffffu) + +typedef int32_t wchar_t; +typedef uint32_t wint_t; + int wprintf(const wchar_t * fmt, ...); int fwprintf(FILE * stream, const wchar_t * fmt, ...); int swprintf(wchar_t *s, size_t n, const wchar_t * fmt, ...); diff --git a/include/bits/wctype.h b/include/bits/wctype.h deleted file mode 100644 index 26315b44..00000000 --- a/include/bits/wctype.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _BITS_WCTYPE_H -#define _BITS_WCTYPE_H - -#define __need_wint_t - -#include <stdint.h> - -#endif /* _BITS_WCTYPE_H */ diff --git a/include/stddef.h b/include/stddef.h index b3973d4a..334267f4 100644 --- a/include/stddef.h +++ b/include/stddef.h @@ -9,12 +9,6 @@ #endif typedef __PTRDIFF_TYPE__ ptrdiff_t; -#ifndef __cplusplus -typedef int32_t wchar_t; -#endif /* #ifndef __cplusplus */ -typedef uint32_t wint_t; - - typedef long unsigned int size_t; typedef struct { long long __ll; long double __ld; } max_align_t; diff --git a/src/c/wchar.c b/src/c/wchar.c index ada9ae70..09956c4b 100644 --- a/src/c/wchar.c +++ b/src/c/wchar.c @@ -3,6 +3,8 @@ typedef struct FILE FILE; +#include <bits/wchar.h> + int vwprintf(const wchar_t * fmt, va_list ap); int wprintf(const wchar_t * fmt, ...) { diff --git a/src/header/stdlib/cbindgen.toml b/src/header/stdlib/cbindgen.toml index c6db0e6c..6de6a6fa 100644 --- a/src/header/stdlib/cbindgen.toml +++ b/src/header/stdlib/cbindgen.toml @@ -1,4 +1,4 @@ -sys_includes = ["stddef.h", "alloca.h"] +sys_includes = ["stddef.h", "alloca.h", "wchar.h"] include_guard = "_RELIBC_STDLIB_H" trailer = "#include <bits/stdlib.h>" language = "C" diff --git a/src/header/wchar/cbindgen.toml b/src/header/wchar/cbindgen.toml index dd2fd8e4..08dbb389 100644 --- a/src/header/wchar/cbindgen.toml +++ b/src/header/wchar/cbindgen.toml @@ -1,6 +1,5 @@ -sys_includes = ["stddef.h", "stdint.h", "time.h", "stdio.h" ] +sys_includes = ["stddef.h", "stdint.h", "stdio.h", "time.h", "bits/wchar.h"] include_guard = "_RELIBC_WCHAR_H" -trailer = "#include <bits/wchar.h>" language = "C" style = "Type" no_includes = true diff --git a/src/header/wctype/cbindgen.toml b/src/header/wctype/cbindgen.toml index 58fb8271..bd9cdd85 100644 --- a/src/header/wctype/cbindgen.toml +++ b/src/header/wctype/cbindgen.toml @@ -1,6 +1,5 @@ sys_includes = ["wchar.h" ] include_guard = "_RELIBC_WCTYPE_H" -header = "#include <bits/wctype.h>" language = "C" style = "Type" no_includes = true -- GitLab