From owner-svn-src-head@freebsd.org Mon Jan 4 23:36:13 2016 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 31955A62A8D for ; Mon, 4 Jan 2016 23:36:13 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qg0-x235.google.com (mail-qg0-x235.google.com [IPv6:2607:f8b0:400d:c04::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DEF721F69 for ; Mon, 4 Jan 2016 23:36:12 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qg0-x235.google.com with SMTP id 6so188413512qgy.1 for ; Mon, 04 Jan 2016 15:36:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=dr7JrpOzA8jLNFQd2f1cGOT/uhElsv6CWf0JRMKgBY0=; b=JBu+9ZKinE3Q4f2ImC/zJDHYsM3+E7Czrla/8RCb/FhdrFz4Dffz6nj2yZnhRtblHK FpgVLaSD13YvzSg+UqFVCY5weFhN0O2od4IcQvadGbybRc2z9ycR9URQ9yWYzyqGzCaf mRC8v0wFLlQ/UhiEnnwns72E3lIsINsT3g5j+lGPPUKM2FHU0s4ZUOiHqRboWdPVKa6R BlAhe7n0qWjeWkrIncZ9to5Vnf6dw9QZW6zlUXCD/kPJlTFYcZqg5egYeH91xVji4fUu kUaepEAxfCT42nMrsTWn/476U7g4Gt5LT5bCpzqFtifrUPWHZNz1zdpNsgyL8Juqtu50 e9CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=dr7JrpOzA8jLNFQd2f1cGOT/uhElsv6CWf0JRMKgBY0=; b=Fe4E5oxH4kipcLZnWMnP1wem5i5DosluwbSORrffCX4SA1kgVRmvCQZ/9uqKxt/VzT +dbTxSWjFcYVj85PvwL/EvFtmrStQDvIqBQyQeoo/7EchA4c8JvgUwkyq3R+UK05Tu4z Bx78Hpq8+nP3tuP7EKBUiC0AIlYLe9x+MWh3gJwQYV3I9KYqzNzPQYBszFS+qnSPGO4k jCu0hU+/q2OOlCs7M8iVwgwCFaXeFQCqtpxGPGcr4zns0TYt0AU3YmcATcMz2ZuujyPQ 1TpXq5X/J9EFM3C4+RLfr+On1lpENs9DexI5ONeOeQuXyVxffpOv9n8BW8YVLHGcr6Bi h3Yw== X-Gm-Message-State: ALoCoQldIE34KKiTNDW8WwSFt5NVzlw5t6E/s4vMhuh+SdR8SEtifPjPsFawLyDx+jM9KOlGGByBOO6fKIqWyjXiejkawRhyLQ== MIME-Version: 1.0 X-Received: by 10.140.250.70 with SMTP id v67mr127292793qhc.43.1451950571943; Mon, 04 Jan 2016 15:36:11 -0800 (PST) Sender: wlosh@bsdimp.com Received: by 10.140.27.181 with HTTP; Mon, 4 Jan 2016 15:36:11 -0800 (PST) X-Originating-IP: [2601:280:4900:3700:a51c:df79:65a:a353] In-Reply-To: <1451429489.1369.35.camel@freebsd.org> References: <201512272304.tBRN4C5D034464@repo.freebsd.org> <41508412.yspAtSoPCD@ralph.baldwin.cx> <2345870.SHMMVrpc1D@ralph.baldwin.cx> <1451429489.1369.35.camel@freebsd.org> Date: Mon, 4 Jan 2016 16:36:11 -0700 X-Google-Sender-Auth: xICLtk_G3QOMjn6Sk6XKvmpTm_Y Message-ID: Subject: Re: svn commit: r292809 - head/lib/libc/stdio From: Warner Losh To: Ian Lepore Cc: John Baldwin , src-committers , "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , Warner Losh Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 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: Mon, 04 Jan 2016 23:36:13 -0000 Be my guest to implement these things. I don't think it matters much, and adds a lot of complexity to avoid a single roundup call. And if we have more-strict alignment for glue than ALIGNBYTES, we're already doomed. We don't do that today. Warner On Tue, Dec 29, 2015 at 3:51 PM, Ian Lepore wrote: > On Tue, 2015-12-29 at 11:37 -0800, John Baldwin wrote: > > 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.) > > > > If there's going to be an assumption that __alignof__(glue) <= > __alignof__(FILE), it might be nice to have a static_assert() of that > to prevent a future time bomb similar to the one that exploded on arm > when it turned out the opposite assumption was wrong. > > -- Ian > >