Mark Millard
2016-Jul-12 02:44 UTC
svn commit: r302601 - in head/sys: arm/include arm64/include [__WCHAR_MAX definition mostly]
https://lists.freebsd.org/pipermail/svn-src-head/2016-July/088998.html shows:> Modified: head/sys/arm/include/_types.h > =============================================================================> --- head/sys/arm/include/_types.h Mon Jul 11 23:15:54 2016 (r302600) > +++ head/sys/arm/include/_types.h Tue Jul 12 00:37:48 2016 (r302601) > @@ -107,7 +107,7 @@ typedef __uint32_t __vm_size_t; > > typedef unsigned int ___wchar_t; > #define __WCHAR_MIN 0 /* min value for a wchar_t */ > -#define __WCHAR_MAX __UINT_MAX /* max value for a wchar_t */ > +#define __WCHAR_MAX __INT_MAX /* max for a wchar_t <= WINT_MAX */ > > /* > * Unusual type definitions. > > Modified: head/sys/arm64/include/_types.h > =============================================================================> --- head/sys/arm64/include/_types.h Mon Jul 11 23:15:54 2016 (r302600) > +++ head/sys/arm64/include/_types.h Tue Jul 12 00:37:48 2016 (r302601) > @@ -95,7 +95,7 @@ typedef __uint64_t __vm_size_t; > typedef unsigned int ___wchar_t; > > #define __WCHAR_MIN 0 /* min value for a wchar_t */ > -#define __WCHAR_MAX __UINT_MAX /* max value for a wchar_t */ > +#define __WCHAR_MAX __INT_MAX /* max for a wchar_t <= WINT_MAX */ > > /* > * Unusual type definitions.My understanding of the criteria for __WCHAR_MIN and __WCHAR_MAX: A) __WCHAR_MIN and __WCHAR_MAX: same type as the integer promotion of ___wchar_t (if that is distinct). B) __WCHAR_MIN is the low value for ___wchar_t as an integer type; not necessarily a valid char value C) __WCHAR_MAX is the high value for ___wchar_t as an integer type; not necessarily a valid char value (A) and (C) seem to be violated here for __WHAR_MAX if I'm right about (A)-(C). [I'm not sure sure that (A)'s violation for __WCHAR_MIN here matters much if I got that combination right.] As far as I know arm FreeBSD uses unsigned character types (of whatever width). There is also at least one past example of Bruce Evans not objecting to __UINT_MAX for __WCHAR_MAX for arm: https://lists.freebsd.org/pipermail/freebsd-arch/2012-June/012721.html has his only comment being. . .> % +#ifdef __ARM_EABI__ > % +#define __WCHAR_MIN (0) > > Bogus parentheses. > > % +#define __WCHAR_MAX __UINT_MAX(The definitions were in a different file back then, leading to the ifdef use.) You may want to check with Bruce Evans. He has good coverage of the various standards to be covered (that may not all agree and how/what FreeBSD then picks). ==Mark Millard markmi at dsl-only.net
Andrey Chernov
2016-Jul-12 03:57 UTC
svn commit: r302601 - in head/sys: arm/include arm64/include [__WCHAR_MAX definition mostly]
On 12.07.2016 5:44, Mark Millard wrote:> My understanding of the criteria for __WCHAR_MIN and __WCHAR_MAX: > > A) __WCHAR_MIN and __WCHAR_MAX: same type as the integer promotion of > ___wchar_t (if that is distinct). > B) __WCHAR_MIN is the low value for ___wchar_t as an integer type; not > necessarily a valid char value > C) __WCHAR_MAX is the high value for ___wchar_t as an integer type; not > necessarily a valid char valueIt seems you are right about "not a valid char value", I'll back this change out.> As far as I know arm FreeBSD uses unsigned character types (of whatever > width).Probably it should be unsigned for other architectures too, clang does not generate negative values with L'<char>' literals and locale use only positive values too.