From owner-svn-src-head@freebsd.org Tue Dec 29 20:55:31 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 A4405A553B7; Tue, 29 Dec 2015 20:55:31 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7F8F91F15; Tue, 29 Dec 2015 20:55:31 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 978D4B983; Tue, 29 Dec 2015 15:55:30 -0500 (EST) From: John Baldwin To: Warner Losh Cc: src-committers , svn-src-head@freebsd.org, svn-src-all@freebsd.org, Warner Losh Subject: Re: svn commit: r292809 - head/lib/libc/stdio Date: Tue, 29 Dec 2015 11:37:42 -0800 Message-ID: <2345870.SHMMVrpc1D@ralph.baldwin.cx> User-Agent: KMail/4.14.3 (FreeBSD/10.2-STABLE; KDE/4.14.3; amd64; ; ) In-Reply-To: References: <201512272304.tBRN4C5D034464@repo.freebsd.org> <41508412.yspAtSoPCD@ralph.baldwin.cx> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Tue, 29 Dec 2015 15:55:30 -0500 (EST) 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: Tue, 29 Dec 2015 20:55:31 -0000 On Monday, December 28, 2015 01:01:26 PM Warner Losh wrote: > I'll look at that, but I don't think posix_memalign is the right way to go. > The alignment of FILE is more strict than posix_memalign will return. Ian's > idea of __alignof__ is the way to go. We allocate them in one block on > purpose for performance, and posix_memalign would be a one at a time affair. posix_memalign gives you whatever alignment you ask for. Using __alignof__ to determine the alignment instead of hardcoding sizeof(int64_t) would certainly be an improvement. If you move the glue after the FILE objects then you can use posix_memalign() directly as so: void *mem; int error; error = posix_memalign(&mem, MAX(ALIGNBYTES, __alignof__(mbstate_t)), n * sizeof(FILE) + sizeof(*g)); if (error) return (NULL); p = (FILE *)mem; g = (struct glue *)(p + n); g->next = NULL; g->niobs = n; g->iobs = p; ... (This presumes that the requested alignment of 'struct glue' is less than the alignment needed by FILE which should be true.) -- John Baldwin