svn commit: r329910 - head/sys/cddl/contrib/opensolaris/uts/common/sys

Dimitry Andric dim at FreeBSD.org
Sun Feb 25 13:52:27 UTC 2018


On 24 Feb 2018, at 17:01, Alan Somers <asomers at freebsd.org> wrote:
> 
> Author: asomers
> Date: Sat Feb 24 16:01:21 2018
> New Revision: 329910
> URL: https://svnweb.freebsd.org/changeset/base/329910
> 
> Log:
>  Implement CTASSERT using _Static_assert
> 
>  Prevents warnings about "unused typedef" with GCC-6
> 
>  Reported by:	GCC-6
>  MFC after:	18 days
>  X-MFC-With:	329722
> 
> Modified:
>  head/sys/cddl/contrib/opensolaris/uts/common/sys/debug.h
> 
> Modified: head/sys/cddl/contrib/opensolaris/uts/common/sys/debug.h
> ==============================================================================
> --- head/sys/cddl/contrib/opensolaris/uts/common/sys/debug.h	Sat Feb 24 15:13:20 2018	(r329909)
> +++ head/sys/cddl/contrib/opensolaris/uts/common/sys/debug.h	Sat Feb 24 16:01:21 2018	(r329910)
> @@ -133,8 +133,8 @@ _NOTE(CONSTCOND) } while (0)
> #ifndef CTASSERT
> #define	CTASSERT(x)		_CTASSERT(x, __LINE__)
> #define	_CTASSERT(x, y)		__CTASSERT(x, y)
> -#define	__CTASSERT(x, y) \
> -	typedef char __compile_time_assertion__ ## y [(x) ? 1 : -1]
> +#define	__CTASSERT(x, y) 	\
> +	_Static_assert((x), "Static assert failed at " #y)
> #endif
> 
> #ifdef	_KERNEL

Note that the trick with the negatively indexed array is to support
older versions of gcc, which did not yet recognize _Static_assert.  It
looks like this was added in gcc 4.6.

-Dimitry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 223 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.freebsd.org/pipermail/svn-src-all/attachments/20180225/3c1681e4/attachment.sig>


More information about the svn-src-all mailing list