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." _______________________________________________ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"