From owner-svn-src-head@FreeBSD.ORG Sun Feb 15 07:44:22 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 2FFF119A; Sun, 15 Feb 2015 07:44:22 +0000 (UTC) Received: from gold.funkthat.com (gate2.funkthat.com [208.87.223.18]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "gold.funkthat.com", Issuer "gold.funkthat.com" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id DA9E4764; Sun, 15 Feb 2015 07:44:21 +0000 (UTC) Received: from gold.funkthat.com (localhost [127.0.0.1]) by gold.funkthat.com (8.14.5/8.14.5) with ESMTP id t1F7iKtc003439 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 14 Feb 2015 23:44:20 -0800 (PST) (envelope-from jmg@gold.funkthat.com) Received: (from jmg@localhost) by gold.funkthat.com (8.14.5/8.14.5/Submit) id t1F7iKPi003438; Sat, 14 Feb 2015 23:44:20 -0800 (PST) (envelope-from jmg) Date: Sat, 14 Feb 2015 23:44:20 -0800 From: John-Mark Gurney To: Bruce Evans Subject: Re: svn commit: r278737 - head/usr.sbin/flowctl Message-ID: <20150215074419.GB1953@funkthat.com> References: <201502132357.t1DNvKda075915@svn.freebsd.org> <20150214193210.N945@besplex.bde.org> <20150214181508.GL15484@FreeBSD.org> <1423938828.80968.148.camel@freebsd.org> <54DFA7CC.20305@FreeBSD.org> <20150215162553.L977@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150215162553.L977@besplex.bde.org> X-Operating-System: FreeBSD 9.1-PRERELEASE amd64 X-PGP-Fingerprint: 54BA 873B 6515 3F10 9E88 9322 9CB1 8F74 6D3F A396 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html X-TipJar: bitcoin:13Qmb6AeTgQecazTWph4XasEsP7nGRbAPE X-to-the-FBI-CIA-and-NSA: HI! HOW YA DOIN? can i haz chizburger? User-Agent: Mutt/1.5.21 (2010-09-15) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.7 (gold.funkthat.com [127.0.0.1]); Sat, 14 Feb 2015 23:44:20 -0800 (PST) Cc: src-committers@freebsd.org, Ian Lepore , svn-src-all@freebsd.org, Pedro Giffuni , Gleb Smirnoff , svn-src-head@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: Sun, 15 Feb 2015 07:44:22 -0000 Bruce Evans wrote this message on Sun, Feb 15, 2015 at 17:53 +1100: > On Sat, 14 Feb 2015, Pedro Giffuni wrote: > > > On 02/14/15 13:33, Ian Lepore wrote: > >> On Sat, 2015-02-14 at 21:15 +0300, Gleb Smirnoff wrote: > >>> 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? Could this just be changed to something like: struct ng_mesg ng_mesg[(SORCVBUF_SIZE + sizeof(struct ng_mesg) - 1) / sizeof(struct ng_mesg)]; It might allocate a few extra bytes, but no more than 55, and gets alignment correct w/o lots of other hacks... -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."