From owner-svn-src-head@freebsd.org Sun Aug 2 05:35:30 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 285A79AF680; Sun, 2 Aug 2015 05:35:30 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail108.syd.optusnet.com.au (mail108.syd.optusnet.com.au [211.29.132.59]) by mx1.freebsd.org (Postfix) with ESMTP id A60D5199A; Sun, 2 Aug 2015 05:35:28 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from c211-30-166-197.carlnfd1.nsw.optusnet.com.au (c211-30-166-197.carlnfd1.nsw.optusnet.com.au [211.30.166.197]) by mail108.syd.optusnet.com.au (Postfix) with ESMTPS id EAB8C1A2646; Sun, 2 Aug 2015 15:35:25 +1000 (AEST) Date: Sun, 2 Aug 2015 15:35:15 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: John-Mark Gurney cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r286170 - head/share/man/man9 In-Reply-To: <201508020022.t720MFqp023071@repo.freebsd.org> Message-ID: <20150802145434.V1128@besplex.bde.org> References: <201508020022.t720MFqp023071@repo.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=XMDNMlVE c=1 sm=1 tr=0 a=KA6XNC2GZCFrdESI5ZmdjQ==:117 a=PO7r1zJSAAAA:8 a=JzwRw_2MAAAA:8 a=kj9zAlcOel0A:10 a=JJchhklRDgoQpUDWXggA:9 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Aug 2015 05:35:30 -0000 On Sun, 2 Aug 2015, John-Mark Gurney wrote: > Log: > mark this function as deprecated, and put the warning first, since I > doubt most people will read to the end... Note the use of sys/cdefs.h > for pre-C11 compilers... This function shouldn't be deprecated. It is a kernel wrapper with a good name for hiding the implementation detail or not-yet standard interface _Static_assert(). CTASSERT() is the compile-time variant of KASSERT(). We intentionally use KASSERT() instead of anything like the standard assert(3) since we don't like the API or semantics of assert() and want one with different design and implementation bugs. I can't think of any use for different semantics to _Static_assert(), but using CTASSERT() retains flexibility. isn't a prerequisite for this function. The correct prerequisites for this function are already documented. They are and . > I didn't included a note about being compatibile w/ userland since a > C11 feature should be obviously usable in userland... If CTASSERT() is abused in userland, then the kernel environment must be faked. > Modified: head/share/man/man9/CTASSERT.9 > ============================================================================== > --- head/share/man/man9/CTASSERT.9 Sun Aug 2 00:18:48 2015 (r286169) > +++ head/share/man/man9/CTASSERT.9 Sun Aug 2 00:22:14 2015 (r286170) > @@ -26,7 +26,7 @@ > .\" > .\" $FreeBSD$ > .\" > -.Dd July 30, 2015 > +.Dd August 1, 2015 > .Dt CTASSERT 9 > .Os > .Sh NAME > @@ -39,6 +39,15 @@ > .Sh DESCRIPTION > The > .Fn CTASSERT > +macro is deprecated and the C11 standard > +.Fn _Static_assert > +should be used instead. > +The header > +.Fa sys/cdefs.h > +should be included to provide compatibility for pre-C11 compilers. _Static_assert() shoudn't be used instead, but when it is including sys/cdefs.h isn' optional. Then the documented prerequisites for this function might not be needed for the replacement but in the kernel they must be provided for other functions. Some section 9 man pages, e.g., atomic.9, document a minimal prerequisite like , but this sets a bad example and inhibits adding conditional features like KASSERTS()s in atomic.h. atomic.h is so low-level that you normally wouldn't want to bloat it with assertions, but you might want to add them for debugging. In fact, it is a style bug for any kernel file to use the documented prerequisite for the atomic functions. is part of the standard pollution in and it is a style bug to not depend on that. sys/param.h is a documented prerequisite in 264 section 9 man pages (at the source level; many more counting links). sys/systm.h is in only 34. sys/types.h is in 41. > +.Pp > +The > +.Fn CTASSERT > macro evaluates > .Fa expression > at compile time and causes a compiler error if it is false. > @@ -48,10 +57,6 @@ The > macro is useful for asserting the size or alignment of important > data structures and variables during compilation, which would > otherwise cause the code to fail at run time. > -.Pp > -The > -.Fn CTASSERT > -macro is not usable in userland. The CTASSERT() macro is still not usable in userland. It is only abusable. Its alternative _Static_assert() is usable, but most people won't read to the beginning of this to find it here. > .Sh EXAMPLES > Assert that the size of the > .Vt uuid Bruce