From cdca6fc11386be8a35aa29d1b80ca17ef19bc906 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Tue, 29 Mar 2022 00:22:27 +0200 Subject: [PATCH] LibC: Make wchar size definitions available from stdint.h POSIX describes WCHAR_MIN and WCHAR_MAX in stdint.h(0P), while wchar.h(0P) only says "as described in stdint.h". As there isn't a trivial path of "may make visible", just move it to a shared header and include it from both files. --- Userland/Libraries/LibC/bits/stdint.h | 1 + Userland/Libraries/LibC/bits/wchar_size.h | 15 +++++++++++++++ Userland/Libraries/LibC/wchar.h | 11 +---------- 3 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 Userland/Libraries/LibC/bits/wchar_size.h diff --git a/Userland/Libraries/LibC/bits/stdint.h b/Userland/Libraries/LibC/bits/stdint.h index 7f0e2b3fc7..db63bbaddb 100644 --- a/Userland/Libraries/LibC/bits/stdint.h +++ b/Userland/Libraries/LibC/bits/stdint.h @@ -6,6 +6,7 @@ #pragma once +#include #include __BEGIN_DECLS diff --git a/Userland/Libraries/LibC/bits/wchar_size.h b/Userland/Libraries/LibC/bits/wchar_size.h new file mode 100644 index 0000000000..6620e20060 --- /dev/null +++ b/Userland/Libraries/LibC/bits/wchar_size.h @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2022, Tim Schumacher + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#define WCHAR_MAX __WCHAR_MAX__ +#ifdef __WCHAR_MIN__ +# define WCHAR_MIN __WCHAR_MIN__ +#else +// Note: This assumes that wchar_t is a signed type. +# define WCHAR_MIN (-WCHAR_MAX - 1) +#endif diff --git a/Userland/Libraries/LibC/wchar.h b/Userland/Libraries/LibC/wchar.h index 17f0af3209..33d129bf6e 100644 --- a/Userland/Libraries/LibC/wchar.h +++ b/Userland/Libraries/LibC/wchar.h @@ -7,6 +7,7 @@ #pragma once #include +#include #include #include #include @@ -17,16 +18,6 @@ __BEGIN_DECLS # define WEOF (0xffffffffu) #endif -#undef WCHAR_MAX -#undef WCHAR_MIN -#define WCHAR_MAX __WCHAR_MAX__ -#ifdef __WCHAR_MIN__ -# define WCHAR_MIN __WCHAR_MIN__ -#else -// Note: This assumes that wchar_t is a signed type. -# define WCHAR_MIN (-WCHAR_MAX - 1) -#endif - typedef __WINT_TYPE__ wint_t; typedef unsigned long int wctype_t;