[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commits] r3646 - in /trunk/libc: ChangeLog.eglibc bits/wchar.h



Author: jimb
Date: Fri Sep 28 14:53:54 2007
New Revision: 3646

Log:
* 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.

Modified:
    trunk/libc/ChangeLog.eglibc
    trunk/libc/bits/wchar.h

Modified: trunk/libc/ChangeLog.eglibc
==============================================================================
--- trunk/libc/ChangeLog.eglibc (original)
+++ trunk/libc/ChangeLog.eglibc Fri Sep 28 14:53:54 2007
@@ -1,3 +1,9 @@
+2007-09-27  Jim Blandy  <jimb@xxxxxxxxxxxxxxxx>
+
+	* 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@xxxxxxxxxxxxxxxx>
 
 	* option-groups.def (OPTION_EGLIBC_NSSWITCH): Doc fixes.

Modified: trunk/libc/bits/wchar.h
==============================================================================
--- trunk/libc/bits/wchar.h (original)
+++ trunk/libc/bits/wchar.h Fri Sep 28 14:53:54 2007
@@ -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 */