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: Proposal: immediate strings Date: Tue, 22 May 2012 15:13:47 -0700 Organization: UCLA Computer Science Department Message-ID: <4FBC0F9B.50109@cs.ucla.edu> References: <4FBB51E7.6080601@yandex.ru> <87sjesgcse.fsf@catnip.gol.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1337724845 14497 80.91.229.3 (22 May 2012 22:14:05 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 22 May 2012 22:14:05 +0000 (UTC) Cc: Dmitry Antipov , emacs-devel@gnu.org To: Miles Bader Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed May 23 00:14: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 1SWxL9-0001JR-94 for ged-emacs-devel@m.gmane.org; Wed, 23 May 2012 00:14:03 +0200 Original-Received: from localhost ([::1]:46393 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWxL8-0001LH-Od for ged-emacs-devel@m.gmane.org; Tue, 22 May 2012 18:14:02 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:39292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWxL6-0001L0-BU for emacs-devel@gnu.org; Tue, 22 May 2012 18:14:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SWxL4-0000az-L3 for emacs-devel@gnu.org; Tue, 22 May 2012 18:13:59 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:34157) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWxL4-0000ZF-Cm; Tue, 22 May 2012 18:13:58 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 78F2939E800A; Tue, 22 May 2012 15:13:48 -0700 (PDT) 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 giJxfKUPMbu0; Tue, 22 May 2012 15:13:47 -0700 (PDT) Original-Received: from penguin.cs.ucla.edu (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id ABB4739E8008; Tue, 22 May 2012 15:13:47 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 In-Reply-To: <87sjesgcse.fsf@catnip.gol.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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:150611 Archived-At: On 05/22/2012 01:51 PM, Miles Bader wrote: > Dmitry Antipov writes: >> + This assumes that sizeof (EMACS_INT) is equal to sizeof (void * ). */ > > Not a good assumption (especially given that it's easy to do it right)... Agreed, especially since the assumption is false on x86 when configured --with-wide-int. Another comment: #if __GNUC__ > 1 /* Any GCC still in use should support this. */ #define PACKED __attribute__((packed)) #else #define PACKED #endif Shouldn't this also support lcc / MSVC / Sun Studio (#pragma pack(1)), and IRIX cc (#pragma pack 1). Better yet, have 'configure' check for the packing syntax. Or do these other compilers not support the right kind of packing? Come to think of it, why use packing at all? Why not use a layout like the following in struct Lisp_String? union { /* If IMMBIT is 1, use IMM; otherwise use DAT. */ struct { unsigned immbit : 1; unsigned size : 7; unsigned gcmarkbit : 1; unsigned size_byte : 7; unsigned char data[STRING_IMM_MAX]; } PACKED imm; struct { unsigned immbit : 1; EMACS_UINT size : BITS_PER_EMACS_INT - 1; unsigned gcmarkbit : 1; EMACS_UINT size_byte : BITS_PER_EMACS_INT - 1; unsigned char *data; } PACKED dat; } u; That way, we don't need to worry about "packed". There are other possibilities too, I expect. The idea is that "packed" is not simply a portability problem, it's a performance issue, and we're better off avoiding it if we can.