From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tom Tromey Newsgroups: gmane.emacs.devel Subject: Re: Packing of union fields and bool_bf Date: Sat, 13 Oct 2018 09:58:00 -0600 Message-ID: <87h8hpbzzr.fsf@tromey.com> References: <838t31vpwy.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1539446209 20126 195.159.176.226 (13 Oct 2018 15:56:49 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 13 Oct 2018 15:56:49 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Oct 13 17:56:45 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gBMHU-000574-MG for ged-emacs-devel@m.gmane.org; Sat, 13 Oct 2018 17:56:44 +0200 Original-Received: from localhost ([::1]:45403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gBMJY-0000Dp-Dm for ged-emacs-devel@m.gmane.org; Sat, 13 Oct 2018 11:58:52 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gBMIp-0008JQ-91 for emacs-devel@gnu.org; Sat, 13 Oct 2018 11:58:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gBMIm-00018H-1E for emacs-devel@gnu.org; Sat, 13 Oct 2018 11:58:07 -0400 Original-Received: from gateway21.websitewelcome.com ([192.185.45.154]:25440) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gBMIl-00017v-T1 for emacs-devel@gnu.org; Sat, 13 Oct 2018 11:58:03 -0400 Original-Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway21.websitewelcome.com (Postfix) with ESMTP id D5293400DA80E for ; Sat, 13 Oct 2018 10:58:01 -0500 (CDT) Original-Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id BMIjgThPVaSeyBMIjgp5JO; Sat, 13 Oct 2018 10:58:01 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=CGeO5b3MECZG0FIxzM6+k4n08cYM3TkxmipKW2kojis=; b=I7xX0Iv7LVgVdpl0OWQu3Noq42 a4lbnWRtd/UY9UjkI4reGghcv/8HaXL7cp+2Aj9FGqj3YHSx/IHNebNWi5a+143OEL7zt7oFO6ecw O0vE2ToV7Mb80s6dSVkj0EpDq; Original-Received: from 97-122-190-66.hlrn.qwest.net ([97.122.190.66]:35620 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1gBMIj-000caV-HK; Sat, 13 Oct 2018 10:58:01 -0500 X-Attribution: Tom In-Reply-To: <838t31vpwy.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 13 Oct 2018 18:15:25 +0300") X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.190.66 X-Source-L: No X-Exim-ID: 1gBMIj-000caV-HK X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-190-66.hlrn.qwest.net (bapiya) [97.122.190.66]:35620 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 192.185.45.154 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:230370 Archived-At: >>>>> "Eli" == Eli Zaretskii writes: Eli> While working on bug#33017, I found out something unexpected: using Eli> bool_bf in union members bloats the union. ... Eli> Note the difference between handling 'unsigned int' fields and Eli> 'bool_bf' fields: the former are nicely packed, whereas the latter are Eli> not. Which causes the size of union to be 12 bytes, instead of the Eli> expected 4. The 'bool' type is 1-byte wide on this platform. Eli> Is this expected? Should we continue using bool_bf in these cases? I think the MS ABI has special rules about packing bit fields. >From https://docs.microsoft.com/en-us/cpp/c-language/padding-and-alignment-of-structure-members?view=vs-2017: Adjacent bit fields are packed into the same 1-, 2-, or 4-byte allocation unit if the integral types are the same size and if the next bit field fits into the current allocation unit without crossing the boundary imposed by the common alignment requirements of the bit fields. So in this case, I think if the underlying type of bool_bf is "unsigned int", then it will continue to pack as expected. Tom