diff options
author | jimb <jimb@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2007-09-28 21:53:54 +0000 |
---|---|---|
committer | jimb <jimb@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2007-09-28 21:53:54 +0000 |
commit | 7634c65fc1f34efe29df511ac562366b2f96d931 (patch) | |
tree | 7f2b42590b70c6b85a201afe1110f7632891088b | |
parent | 39214d562d474c17d8242008f5454e9c9ca710ad (diff) |
* 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
-rw-r--r-- | libc/ChangeLog.eglibc | 6 | ||||
-rw-r--r-- | libc/bits/wchar.h | 19 |
2 files changed, 24 insertions, 1 deletions
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 <jimb@codesourcery.com> + + * 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 <jimb@codesourcery.com> * 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 */ |