From owner-svn-src-head@FreeBSD.ORG Sat Feb 14 18:15:18 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 57F13E78; Sat, 14 Feb 2015 18:15:18 +0000 (UTC) Received: from cell.glebius.int.ru (glebius.int.ru [81.19.69.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cell.glebius.int.ru", Issuer "cell.glebius.int.ru" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 828821FD; Sat, 14 Feb 2015 18:15:16 +0000 (UTC) Received: from cell.glebius.int.ru (localhost [127.0.0.1]) by cell.glebius.int.ru (8.14.9/8.14.9) with ESMTP id t1EIF9Vl038685 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 14 Feb 2015 21:15:09 +0300 (MSK) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebius.int.ru (8.14.9/8.14.9/Submit) id t1EIF8sR038684; Sat, 14 Feb 2015 21:15:08 +0300 (MSK) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebius.int.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Sat, 14 Feb 2015 21:15:08 +0300 From: Gleb Smirnoff To: Bruce Evans Subject: Re: svn commit: r278737 - head/usr.sbin/flowctl Message-ID: <20150214181508.GL15484@FreeBSD.org> References: <201502132357.t1DNvKda075915@svn.freebsd.org> <20150214193210.N945@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150214193210.N945@besplex.bde.org> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 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: Sat, 14 Feb 2015 18:15:18 -0000 Bruce, On Sat, Feb 14, 2015 at 08:46:58PM +1100, Bruce Evans wrote: B> Using VLAs and also the C99 feature of declarations anwhere, and extensions B> like __aligned(), we can almost implement a full alloca() using the fixed B> version of this change: B> B> /* B> * XXX need extended statement-expression so that __buf doesn't go out B> * of scope after the right brace. B> */ B> #define my_alloca(n) __extension__ ({ B> /* XXX need unique name. */ \ B> char __buf[__roundup2((n), MUMBLE)] __aligned(MUMBLE); \ B> \ B> (void *)__buf; \ B> }) I like this idea. But would this exact code work? The life of __buf is limited by the code block, and we exit the block immediately. Wouldn't the allocation be overwritten if we enter any function or block later? -- Totus tuus, Glebius.