From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Rottmann Newsgroups: gmane.emacs.devel Subject: Re: [RFC, PATCH] shrink struct vectorlike_header #2 Date: Fri, 09 Nov 2012 19:04:42 +0100 Message-ID: <87wqxuac05.fsf@delenn.home.rotty.xx.vu> References: <50766A2C.8070705@yandex.ru> <50994448.6020602@yandex.ru> <509A76F7.3050105@yandex.ru> <509B4246.2050203@cs.ucla.edu> <87sj8kng9f.fsf@spindle.srvr.nix> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1352484299 25163 80.91.229.3 (9 Nov 2012 18:04:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 9 Nov 2012 18:04:59 +0000 (UTC) Cc: Paul Eggert , Dmitry Antipov , Stefan Monnier , Emacs development discussions To: Nix Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Nov 09 19:05:04 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TWsww-0002PR-Q3 for ged-emacs-devel@m.gmane.org; Fri, 09 Nov 2012 19:05:02 +0100 Original-Received: from localhost ([::1]:53069 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TWswn-00070p-I6 for ged-emacs-devel@m.gmane.org; Fri, 09 Nov 2012 13:04:53 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:43606) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TWswl-00070T-DM for emacs-devel@gnu.org; Fri, 09 Nov 2012 13:04:52 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TWswj-0007Bv-Sy for emacs-devel@gnu.org; Fri, 09 Nov 2012 13:04:51 -0500 Original-Received: from mailout-de.gmx.net ([213.165.64.23]:42612) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1TWswj-0007Ba-Ji for emacs-devel@gnu.org; Fri, 09 Nov 2012 13:04:49 -0500 Original-Received: (qmail invoked by alias); 09 Nov 2012 18:04:47 -0000 Original-Received: from 85-127-112-13.dynamic.xdsl-line.inode.at (EHLO cubox.home.rotty.xx.vu) [85.127.112.13] by mail.gmx.net (mp069) with SMTP; 09 Nov 2012 19:04:47 +0100 X-Authenticated: #3102804 X-Provags-ID: V01U2FsdGVkX1+xwxRv6ruxsz+7Y55n0OECnxoPcZWxKzBQjrgT8a tcb1uW5tnyuG8W Original-Received: from delenn.home.rotty.xx.vu (unknown [192.168.2.11]) by cubox.home.rotty.xx.vu (Postfix) with ESMTP id 66695160087; Fri, 9 Nov 2012 19:04:42 +0100 (CET) Original-Received: by delenn.home.rotty.xx.vu (Postfix, from userid 1000) id 3A7A832540D; Fri, 9 Nov 2012 19:04:42 +0100 (CET) In-Reply-To: <87sj8kng9f.fsf@spindle.srvr.nix> (nix@esperi.org.uk's message of "Thu, 08 Nov 2012 17:42:04 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 213.165.64.23 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:154771 Archived-At: Nix writes: > On 8 Nov 2012, Paul Eggert spake thusly: >> But better yet would be to omit the casts entirely. >> This might let GCC do more optimizations safely. That is, >> change struct Lisp_Vector to be something like this: >> >> struct Lisp_Vector >> { >> struct vectorlike_header header; >> union >> { >> Lisp_Object contents[1]; >> struct Lisp_Vector *next; >> } u; >> }; >> >> Replace all current uses of 'contents' >> with 'u.contents', and then use u.next >> when you want to use the memory as a next field. > > It's a shame we can't use an unnamed union here: > > struct Lisp_Vector > { > struct vectorlike_header header; > union > { > Lisp_Object contents[1]; > struct Lisp_Vector *next; > }; > }; > > No changes to source necessary. > > Downside: GCC extension :( which probably rules it out unless wrapped in > compiler-specific macro trickery, and if you're doing that you might as > well just unconditionally use a named union. > At least according to Wikipedia[0], anonymous unions and structs are part of C11, so they're not compiler-specific any longer. However, given the newness of C11, similiar considerations regarding portability to non-GCC compilers may still apply. [0] http://en.wikipedia.org/wiki/C11_(C_standard_revision) Regards, Rotty -- Andreas Rottmann --