From 7634c65fc1f34efe29df511ac562366b2f96d931 Mon Sep 17 00:00:00 2001 From: jimb Date: Fri, 28 Sep 2007 21:53:54 +0000 Subject: * bits/wchar.h (__WCHAR_MIN, __WCHAR_MAX): Use information provided by GCC and the preprocessor's behavior to handle both signed and unsigned wchar_t ranges. git-svn-id: svn://svn.eglibc.org/trunk@3646 7b3dc134-2b1b-0410-93df-9e9f96275f8d --- libc/ChangeLog.eglibc | 6 ++++++ libc/bits/wchar.h | 19 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/libc/ChangeLog.eglibc b/libc/ChangeLog.eglibc index 28f1a58fc..dfcadb638 100644 --- a/libc/ChangeLog.eglibc +++ b/libc/ChangeLog.eglibc @@ -1,3 +1,9 @@ +2007-09-27 Jim Blandy + + * bits/wchar.h (__WCHAR_MIN, __WCHAR_MAX): Use information + provided by GCC and the preprocessor's behavior to handle both + signed and unsigned wchar_t ranges. + 2007-09-24 Jim Blandy * option-groups.def (OPTION_EGLIBC_NSSWITCH): Doc fixes. diff --git a/libc/bits/wchar.h b/libc/bits/wchar.h index ef1f56363..73ab694fd 100644 --- a/libc/bits/wchar.h +++ b/libc/bits/wchar.h @@ -20,7 +20,24 @@ #ifndef _BITS_WCHAR_H #define _BITS_WCHAR_H 1 -#define __WCHAR_MIN (-2147483647 - 1) +/* Use GCC's __WCHAR_MAX__ when available. */ +#ifdef __WCHAR_MAX__ +#define __WCHAR_MAX __WCHAR_MAX__ +#else #define __WCHAR_MAX (2147483647) +#endif + +/* GCC may also define __WCHAR_UNSIGNED__. + Use L'\0' to give the expression the correct (unsigned) type. */ +#ifdef __WCHAR_UNSIGNED__ +#define WCHAR_MIN L'\0' + +/* Failing that, rely on the preprocessor's knowledge of the + signedness of wchar_t. */ +#elif L'\0' - 1 > 0 +#define WCHAR_MIN L'\0' +#else +#define WCHAR_MIN (-WCHAR_MAX - 1) +#endif #endif /* bits/wchar.h */ -- cgit v1.2.3