From 052aff95782fefe9c63566471063e8b20836bfb8 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Wed, 23 Jan 2013 00:42:51 +0000 Subject: Make bits/wchar.h correct for all architectures (bug 15036). --- ChangeLog | 8 ++++++++ NEWS | 2 +- bits/wchar.h | 28 ++++++++++++++++++++++++++-- sysdeps/unix/sysv/linux/x86/bits/wchar.h | 32 -------------------------------- 4 files changed, 35 insertions(+), 35 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/x86/bits/wchar.h diff --git a/ChangeLog b/ChangeLog index 7d8eaf7a15..3d378c8d43 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2013-01-23 Joseph Myers + + [BZ #15036] + * bits/wchar.h (__WCHAR_MAX): Define based on __WCHAR_MAX__, or + based on [L'\0' - 1 > 0] if [!__WCHAR_MAX__]. + (__WCHAR_MIN): Likewise, using __WCHAR_MIN__. + * sysdeps/unix/sysv/linux/x86/bits/wchar.h: Remove. + 2013-01-21 David S. Miller * sysdeps/sparc/backtrace.c: New file. diff --git a/NEWS b/NEWS index abbbbaeec5..9a039d8f4d 100644 --- a/NEWS +++ b/NEWS @@ -10,7 +10,7 @@ Version 2.18 * The following bugs are resolved with this release: 13951, 14200, 14317, 14327, 14496, 14964, 14981, 14982, 14985, 14994, - 14996, 15003, 15020, 15023. + 14996, 15003, 15020, 15023, 15036. Version 2.17 diff --git a/bits/wchar.h b/bits/wchar.h index eb07151152..ef93d0e784 100644 --- a/bits/wchar.h +++ b/bits/wchar.h @@ -19,7 +19,31 @@ #ifndef _BITS_WCHAR_H #define _BITS_WCHAR_H 1 -#define __WCHAR_MIN (-2147483647 - 1) -#define __WCHAR_MAX (2147483647) +/* The fallback definitions, for when __WCHAR_MAX__ or __WCHAR_MIN__ + are not defined, give the right value and type as long as both int + and wchar_t are 32-bit types. Adding L'\0' to a constant value + ensures that the type is correct; it is necessary to use (L'\0' + + 0) rather than just L'\0' so that the type in C++ is the promoted + version of wchar_t rather than the distinct wchar_t type itself. + Because wchar_t in preprocessor #if expressions is treated as + intmax_t or uintmax_t, the expression (L'\0' - 1) would have the + wrong value for WCHAR_MAX in such expressions and so cannot be used + to define __WCHAR_MAX in the unsigned case. */ + +#ifdef __WCHAR_MAX__ +# define __WCHAR_MAX __WCHAR_MAX__ +#elif L'\0' - 1 > 0 +# define __WCHAR_MAX (0xffffffffu + L'\0') +#else +# define __WCHAR_MAX (0x7fffffff + L'\0') +#endif + +#ifdef __WCHAR_MIN__ +# define __WCHAR_MIN __WCHAR_MIN__ +#elif L'\0' - 1 > 0 +# define __WCHAR_MIN (L'\0' + 0) +#else +# define __WCHAR_MIN (-__WCHAR_MAX - 1) +#endif #endif /* bits/wchar.h */ diff --git a/sysdeps/unix/sysv/linux/x86/bits/wchar.h b/sysdeps/unix/sysv/linux/x86/bits/wchar.h deleted file mode 100644 index 16b8b77c8a..0000000000 --- a/sysdeps/unix/sysv/linux/x86/bits/wchar.h +++ /dev/null @@ -1,32 +0,0 @@ -/* wchar_t type related definitions. i386/x86-64 version. - Copyright (C) 2000-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#ifndef _BITS_WCHAR_H -#define _BITS_WCHAR_H 1 - -#include - -#if __WORDSIZE == 64 -# define __WCHAR_MIN (-2147483647 - 1) -# define __WCHAR_MAX (2147483647) -#else -# define __WCHAR_MIN (-2147483647l - 1l) -# define __WCHAR_MAX (2147483647l) -#endif - -#endif /* bits/wchar.h */ -- cgit 1.4.1