From owner-svn-src-stable@freebsd.org Tue Nov 22 21:02:37 2016 Return-Path: Delivered-To: svn-src-stable@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 51E83C50A74; Tue, 22 Nov 2016 21:02:37 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 07BAAAE3; Tue, 22 Nov 2016 21:02:36 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uAML2a22048125; Tue, 22 Nov 2016 21:02:36 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uAML2a8F048124; Tue, 22 Nov 2016 21:02:36 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201611222102.uAML2a8F048124@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Tue, 22 Nov 2016 21:02:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r309024 - stable/10/sys/sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Nov 2016 21:02:37 -0000 Author: asomers Date: Tue Nov 22 21:02:35 2016 New Revision: 309024 URL: https://svnweb.freebsd.org/changeset/base/309024 Log: MFC r307584 (partially) 307584 added the __min_size macro and replaced some static array sizes with __min_size. However, stable/10 doesn't yet have any static array sizes, so all this MFC does is add the __min_size macro. Original commit message: Fix C++ includability of crypto headers with static array sizes C99 allows array function parameters to use the static keyword for their sizes. This tells the compiler that the parameter will have at least the specified size, and calling code will fail to compile if that guarantee is not met. However, this syntax is not legal in C++. This commit reverts r300824, which worked around the problem for sys/sys/md5.h only, and introduces a new macro: min_size(). min_size(x) can be used in headers as a static array size, but will still compile in C++ mode. Modified: stable/10/sys/sys/cdefs.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/sys/cdefs.h ============================================================================== --- stable/10/sys/sys/cdefs.h Tue Nov 22 20:28:17 2016 (r309023) +++ stable/10/sys/sys/cdefs.h Tue Nov 22 21:02:35 2016 (r309024) @@ -332,6 +332,20 @@ __builtin_types_compatible_p(__typeof(expr), t), yes, no) #endif +/* + * C99 Static array indices in function parameter declarations. Syntax such as: + * void bar(int myArray[static 10]); + * is allowed in C99 but not in C++. Define __min_size appropriately so + * headers using it can be compiled in either language. Use like this: + * void bar(int myArray[__min_size(10)]); + */ +#if !defined(__cplusplus) && \ + (!defined(__STDC_VERSION) || (__STDC_VERSION__ >= 199901)) +#define __min_size(x) static (x) +#else +#define __min_size(x) (x) +#endif + #if __GNUC_PREREQ__(2, 96) #define __malloc_like __attribute__((__malloc__)) #define __pure __attribute__((__pure__))