Re: svn commit: r302601 - in head/sys: arm/include arm64/include [__WCHAR_MAX definition mostly]

From: Mark Millard <markmi_at_dsl-only.net>
Date: Mon, 11 Jul 2016 19:44:28 -0700
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)
> _at__at_ -107,7 +107,7 _at__at_ 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)
> _at__at_ -95,7 +95,7 _at__at_ 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
Received on Tue Jul 12 2016 - 00:44:32 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:06 UTC