From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: [RFC, PATCH] shrink struct vectorlike_header #2 Date: Thu, 08 Nov 2012 08:30:13 -0800 Organization: UCLA Computer Science Department Message-ID: <509BDE15.5080300@cs.ucla.edu> References: <50766A2C.8070705@yandex.ru> <50994448.6020602@yandex.ru> <509A76F7.3050105@yandex.ru> <509B4246.2050203@cs.ucla.edu> <509BC584.7080208@yandex.ru> <509BCAF2.2070404@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1352392235 5444 80.91.229.3 (8 Nov 2012 16:30:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 8 Nov 2012 16:30:35 +0000 (UTC) Cc: Stefan Monnier , Emacs development discussions To: Dmitry Antipov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 08 17:30:45 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 1TWV07-0004U1-Bi for ged-emacs-devel@m.gmane.org; Thu, 08 Nov 2012 17:30:43 +0100 Original-Received: from localhost ([::1]:38829 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TWUzy-0007oG-2g for ged-emacs-devel@m.gmane.org; Thu, 08 Nov 2012 11:30:34 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:49193) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TWUzs-0007nq-6o for emacs-devel@gnu.org; Thu, 08 Nov 2012 11:30:32 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TWUzm-0006n1-3M for emacs-devel@gnu.org; Thu, 08 Nov 2012 11:30:28 -0500 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:37321) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TWUzl-0006m0-U2 for emacs-devel@gnu.org; Thu, 08 Nov 2012 11:30:22 -0500 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 19163A60004; Thu, 8 Nov 2012 08:30:19 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UhJZtSewv9m9; Thu, 8 Nov 2012 08:30:18 -0800 (PST) Original-Received: from [192.168.1.3] (pool-108-23-119-2.lsanca.fios.verizon.net [108.23.119.2]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 91802A60001; Thu, 8 Nov 2012 08:30:18 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux i686; rv:16.0) Gecko/20121028 Thunderbird/16.0.2 In-Reply-To: <509BCAF2.2070404@yandex.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 131.179.128.62 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:154736 Archived-At: On 11/08/2012 07:08 AM, Dmitry Antipov wrote: > +#define NEXT_IN_FREE_LIST(v) ((struct Lisp_Vectorlike_Free *) v)->next This solution is nicer than what we have, but it still has the problem of casting pointers, which would let the C compiler do optimizations that we don't want to allow. Another possibility would be something like this: static struct Lisp_Vector * next_in_free_list (struct Lisp_Vector *v) { intptr_t i = XIL (v->contents[0]); return (struct Lisp_Vector *) i; } static void set_next_in_free_list (struct Lisp_Vector *v, struct Lisp_Vector *next) { v->contents[0] = XIL ((intptr_t) (next)); } That is, define a setter as well as a getter, and use the setter when modifying the next field. This would be simpler and arguably cleaner than the union and would be just as safe, since we know that Lisp_Object is at least as wide as intptr_t.