Re: [PATCH] ruby: extern linkage portability improvement
authorAli Polatel <alip@exherbo.org>
Tue, 15 May 2012 15:08:45 +0000 (18:08 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:06 +0000 (09:47 -0800)
05/394cddaa782ce6d0293aa52caf160176e305f3 [new file with mode: 0644]

diff --git a/05/394cddaa782ce6d0293aa52caf160176e305f3 b/05/394cddaa782ce6d0293aa52caf160176e305f3
new file mode 100644 (file)
index 0000000..eb468c9
--- /dev/null
@@ -0,0 +1,186 @@
+Return-Path: <polatel@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 258E7431FB6\r
+       for <notmuch@notmuchmail.org>; Tue, 15 May 2012 08:09:10 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.699\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001,\r
+       RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id aegOBUxH8P49 for <notmuch@notmuchmail.org>;\r
+       Tue, 15 May 2012 08:09:08 -0700 (PDT)\r
+Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com\r
+       [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 7BD52431FAE\r
+       for <notmuch@notmuchmail.org>; Tue, 15 May 2012 08:09:08 -0700 (PDT)\r
+Received: by bkcjk13 with SMTP id jk13so5586826bkc.26\r
+       for <notmuch@notmuchmail.org>; Tue, 15 May 2012 08:09:05 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=mime-version:sender:in-reply-to:references:from:date\r
+       :x-google-sender-auth:message-id:subject:to:cc:content-type\r
+       :content-transfer-encoding;\r
+       bh=3gkD5CII2zFxTcnBL75YcxdnYrhR7IccSvvL7guVBDs=;\r
+       b=TpPZFrsPmSuIVaSVi1NFNdC8JTeumoZ+6EE2N7D/P4nPWzqeY7PNe/ofXNm3FUNsmj\r
+       5npjk/dsaLiWzDeU0djUIqnM1byFIpT5q2lSCHOuZvKoG2aUFcW/ctDLpnDaIE+SKlrz\r
+       8ibvfm4jqFPbBmBAHeMnoTgAaUeB9m2CXTMaeyLyCm1vNSshA53WoLN/uFG9CVsipNZR\r
+       dGNxeF2O0smPzGDDLxLTyAhKf2XbEFATIgIT9xkgn50gy7U2NS6QVFkDxzD+yGQRz4vJ\r
+       egnf2jgbTFyZgxB4NaUA27hkNga8oJLjCdJ3nesUsLKt6q4lgjjper7isfKBjQs1mp37\r
+       Ja5w==\r
+Received: by 10.204.151.82 with SMTP id b18mr4804109bkw.132.1337094545708;\r
+       Tue, 15 May 2012 08:09:05 -0700 (PDT)\r
+MIME-Version: 1.0\r
+Sender: polatel@gmail.com\r
+Received: by 10.204.50.132 with HTTP; Tue, 15 May 2012 08:08:45 -0700 (PDT)\r
+In-Reply-To: <20120513171917.GL11804@mit.edu>\r
+References: <1336669964-24231-1-git-send-email-tomi.ollila@iki.fi>\r
+       <20120513171917.GL11804@mit.edu>\r
+From: Ali Polatel <alip@exherbo.org>\r
+Date: Tue, 15 May 2012 18:08:45 +0300\r
+X-Google-Sender-Auth: 0GlUTlfvsv_LZmxS_3xfit9GWqk\r
+Message-ID:\r
+ <CADv3eywyAaqtAhzYJFjVp9xpWcPv35L1CGPYK3PK_GaDrAJOVw@mail.gmail.com>\r
+Subject: Re: [PATCH] ruby: extern linkage portability improvement\r
+To: Austin Clements <amdragon@mit.edu>\r
+Content-Type: text/plain; charset=ISO-8859-1\r
+Content-Transfer-Encoding: quoted-printable\r
+Cc: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 15 May 2012 15:09:10 -0000\r
+\r
+2012/5/13 Austin Clements <amdragon@mit.edu>:\r
+> Quoth Tomi Ollila on May 10 at =A08:12 pm:\r
+>> Some C compilers are stricter when it comes to (tentative) definition\r
+>> of a variable -- in those compilers introducing variable without 'extern=\r
+'\r
+>> keyword always allocates new 'storage' to the variable and linking all\r
+>> these modules fails due to duplicate symbols.\r
+>>\r
+>> This change uses some macro trickery to avoid writing every variable twi=\r
+ce.\r
+>>\r
+>> This is reimplementation of Charlie Allom's patch:\r
+>> id:"1336481467-66356-1-git-send-email-charlie@mediasp.com"\r
+>>\r
+>> combining information from other change made by Ali Polatel.\r
+>> ---\r
+>>\r
+>> Charlie: could you test whether this patch actually work ? :)\r
+>>\r
+>> Everyone: what do you think of the "hiding extern" macro trick ?\r
+>\r
+> This seems like a hacky and nonstandard way to do this. =A0Granted, the\r
+> standard way to do this---always declare variables extern in .h files\r
+> and also give a non-extern definition in exactly one .c file---is more\r
+> verbose, but nobody will be surprised or confused by it.\r
+\r
+I fully agree or otherwise I'd suggest using:\r
+http://minnie.tuhs.org/cgi-bin/utree.pl?file=3DV7/usr/src/cmd/sh/mac.h\r
+\r
+>> =A0bindings/ruby/defs.h | =A0 56 +++++++++++++++++++++++++++------------=\r
+----------\r
+>> =A0bindings/ruby/init.c | =A0 =A02 +\r
+>> =A02 files changed, 33 insertions(+), 25 deletions(-)\r
+>>\r
+>> diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h\r
+>> index 85d8205..2531760 100644\r
+>> --- a/bindings/ruby/defs.h\r
+>> +++ b/bindings/ruby/defs.h\r
+>> @@ -24,31 +24,37 @@\r
+>> =A0#include <ruby.h>\r
+>> =A0#include "notmuch.h"\r
+>>\r
+>> -VALUE notmuch_rb_cDatabase;\r
+>> -VALUE notmuch_rb_cDirectory;\r
+>> -VALUE notmuch_rb_cFileNames;\r
+>> -VALUE notmuch_rb_cQuery;\r
+>> -VALUE notmuch_rb_cThreads;\r
+>> -VALUE notmuch_rb_cThread;\r
+>> -VALUE notmuch_rb_cMessages;\r
+>> -VALUE notmuch_rb_cMessage;\r
+>> -VALUE notmuch_rb_cTags;\r
+>> -\r
+>> -VALUE notmuch_rb_eBaseError;\r
+>> -VALUE notmuch_rb_eDatabaseError;\r
+>> -VALUE notmuch_rb_eMemoryError;\r
+>> -VALUE notmuch_rb_eReadOnlyError;\r
+>> -VALUE notmuch_rb_eXapianError;\r
+>> -VALUE notmuch_rb_eFileError;\r
+>> -VALUE notmuch_rb_eFileNotEmailError;\r
+>> -VALUE notmuch_rb_eNullPointerError;\r
+>> -VALUE notmuch_rb_eTagTooLongError;\r
+>> -VALUE notmuch_rb_eUnbalancedFreezeThawError;\r
+>> -VALUE notmuch_rb_eUnbalancedAtomicError;\r
+>> -\r
+>> -ID ID_call;\r
+>> -ID ID_db_create;\r
+>> -ID ID_db_mode;\r
+>> +#ifdef RUBY_INIT_C\r
+>> +#define extern\r
+>> +#endif\r
+>> +\r
+>> +extern VALUE notmuch_rb_cDatabase;\r
+>> +extern VALUE notmuch_rb_cDirectory;\r
+>> +extern VALUE notmuch_rb_cFileNames;\r
+>> +extern VALUE notmuch_rb_cQuery;\r
+>> +extern VALUE notmuch_rb_cThreads;\r
+>> +extern VALUE notmuch_rb_cThread;\r
+>> +extern VALUE notmuch_rb_cMessages;\r
+>> +extern VALUE notmuch_rb_cMessage;\r
+>> +extern VALUE notmuch_rb_cTags;\r
+>> +\r
+>> +extern VALUE notmuch_rb_eBaseError;\r
+>> +extern VALUE notmuch_rb_eDatabaseError;\r
+>> +extern VALUE notmuch_rb_eMemoryError;\r
+>> +extern VALUE notmuch_rb_eReadOnlyError;\r
+>> +extern VALUE notmuch_rb_eXapianError;\r
+>> +extern VALUE notmuch_rb_eFileError;\r
+>> +extern VALUE notmuch_rb_eFileNotEmailError;\r
+>> +extern VALUE notmuch_rb_eNullPointerError;\r
+>> +extern VALUE notmuch_rb_eTagTooLongError;\r
+>> +extern VALUE notmuch_rb_eUnbalancedFreezeThawError;\r
+>> +extern VALUE notmuch_rb_eUnbalancedAtomicError;\r
+>> +\r
+>> +extern ID ID_call;\r
+>> +extern ID ID_db_create;\r
+>> +extern ID ID_db_mode;\r
+>> +\r
+>> +#undef extern\r
+>>\r
+>> =A0/* RSTRING_PTR() is new in ruby-1.9 */\r
+>> =A0#if !defined(RSTRING_PTR)\r
+>> diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c\r
+>> index 3fe60fb..b2dc7f6 100644\r
+>> --- a/bindings/ruby/init.c\r
+>> +++ b/bindings/ruby/init.c\r
+>> @@ -18,7 +18,9 @@\r
+>> =A0 * Author: Ali Polatel <alip@exherbo.org>\r
+>> =A0 */\r
+>>\r
+>> +#define RUBY_INIT_C\r
+>> =A0#include "defs.h"\r
+>> +#undef RUBY_INIT_C\r
+>>\r
+>> =A0/*\r
+>> =A0 * Document-module: Notmuch\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r