From: Austin Clements Date: Sun, 13 May 2012 17:19:17 +0000 (+2000) Subject: Re: [PATCH] ruby: extern linkage portability improvement X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=7d2c7bc9f780c292ab17f8f0017d4782f9cfe497;p=notmuch-archives.git Re: [PATCH] ruby: extern linkage portability improvement --- diff --git a/92/8aebd81ec55ec1c10319aebe779aaf363c4db0 b/92/8aebd81ec55ec1c10319aebe779aaf363c4db0 new file mode 100644 index 000000000..e55b7e35e --- /dev/null +++ b/92/8aebd81ec55ec1c10319aebe779aaf363c4db0 @@ -0,0 +1,184 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id E4FF7431FB6 + for ; Sun, 13 May 2012 10:19:23 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id E5s8n4wkl1nD for ; + Sun, 13 May 2012 10:19:22 -0700 (PDT) +Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU + [18.9.25.13]) + by olra.theworths.org (Postfix) with ESMTP id C42A5431FAE + for ; Sun, 13 May 2012 10:19:22 -0700 (PDT) +X-AuditID: 1209190d-b7fbf6d0000008ba-fc-4fafed19f001 +Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) + by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP + id 62.34.02234.91DEFAF4; Sun, 13 May 2012 13:19:21 -0400 (EDT) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q4DHJLxv027983; + Sun, 13 May 2012 13:19:21 -0400 +Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) + (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q4DHJI6T001659 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Sun, 13 May 2012 13:19:20 -0400 (EDT) +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) + (envelope-from ) + id 1STcRx-0004hq-Of; Sun, 13 May 2012 13:19:17 -0400 +Date: Sun, 13 May 2012 13:19:17 -0400 +From: Austin Clements +To: Tomi Ollila +Subject: Re: [PATCH] ruby: extern linkage portability improvement +Message-ID: <20120513171917.GL11804@mit.edu> +References: <1336669964-24231-1-git-send-email-tomi.ollila@iki.fi> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1336669964-24231-1-git-send-email-tomi.ollila@iki.fi> +User-Agent: Mutt/1.5.21 (2010-09-15) +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42IR4hRV1pV8u97fYOJJa4vrN2cyW7xZOY/V + gcnj8NeFLB7PVt1iDmCK4rJJSc3JLEst0rdL4MpYcegnU8FCmYrDF3ayNTCeEe9i5OSQEDCR + mHntHAuELSZx4d56ti5GLg4hgX2MEtfmLWaCcDYwSlw6/ogVwjnJJDFn1h1GCGcJo8StiZeY + QfpZBFQlprdMYgex2QQ0JLbtX84IYosIqEg8aFvPCmIzC0hLfPvdzARiCws4ShzbdwJoHwcH + r4COxK4JDiBhIQEnif/X+sDG8AoISpyc+YQFolVL4sa/l0wg5SBjlv/jAAlzCjhLPJnRADZd + FGjTlJPb2CYwCs1C0j0LSfcshO4FjMyrGGVTcqt0cxMzc4pTk3WLkxPz8lKLdI30cjNL9FJT + SjcxgsNakncH47uDSocYBTgYlXh4F4iu9xdiTSwrrsw9xCjJwaQkysv9BijEl5SfUpmRWJwR + X1Sak1p8iFGCg1lJhHf9Q6Acb0piZVVqUT5MSpqDRUmcV1XrnZ+QQHpiSWp2ampBahFMVoaD + Q0mClw9kqGBRanpqRVpmTglCmomDE2Q4D9BwUZAa3uKCxNzizHSI/ClGRSlx3mqQhABIIqM0 + D64XlnZeMYoDvSLMqw9SxQNMWXDdr4AGMwEN5hdYBzK4JBEhJdXAuFc2WuBZXp/coS/ex1gW + /tht67TU9+jysEyGELew155zX1kc22Ctdu3vvFubHi87c9V0t/xkyzvL7TkY4j+t/xTCopGu + NFVEPXGGt5lU6z3dPwf2unwoSetb2c9n3f33lUDwhzmlHAVOmm/N2VdN6eIraaowPOjLEXLA + 8V+C/wonx0XJpz5tUGIpzkg01GIuKk4EAG/T1+cWAwAA +Cc: notmuch@notmuchmail.org +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 13 May 2012 17:19:24 -0000 + +Quoth Tomi Ollila on May 10 at 8:12 pm: +> Some C compilers are stricter when it comes to (tentative) definition +> of a variable -- in those compilers introducing variable without 'extern' +> keyword always allocates new 'storage' to the variable and linking all +> these modules fails due to duplicate symbols. +> +> This change uses some macro trickery to avoid writing every variable twice. +> +> This is reimplementation of Charlie Allom's patch: +> id:"1336481467-66356-1-git-send-email-charlie@mediasp.com" +> +> combining information from other change made by Ali Polatel. +> --- +> +> Charlie: could you test whether this patch actually work ? :) +> +> Everyone: what do you think of the "hiding extern" macro trick ? + +This seems like a hacky and nonstandard way to do this. Granted, the +standard way to do this---always declare variables extern in .h files +and also give a non-extern definition in exactly one .c file---is more +verbose, but nobody will be surprised or confused by it. + +> bindings/ruby/defs.h | 56 +++++++++++++++++++++++++++---------------------- +> bindings/ruby/init.c | 2 + +> 2 files changed, 33 insertions(+), 25 deletions(-) +> +> diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h +> index 85d8205..2531760 100644 +> --- a/bindings/ruby/defs.h +> +++ b/bindings/ruby/defs.h +> @@ -24,31 +24,37 @@ +> #include +> #include "notmuch.h" +> +> -VALUE notmuch_rb_cDatabase; +> -VALUE notmuch_rb_cDirectory; +> -VALUE notmuch_rb_cFileNames; +> -VALUE notmuch_rb_cQuery; +> -VALUE notmuch_rb_cThreads; +> -VALUE notmuch_rb_cThread; +> -VALUE notmuch_rb_cMessages; +> -VALUE notmuch_rb_cMessage; +> -VALUE notmuch_rb_cTags; +> - +> -VALUE notmuch_rb_eBaseError; +> -VALUE notmuch_rb_eDatabaseError; +> -VALUE notmuch_rb_eMemoryError; +> -VALUE notmuch_rb_eReadOnlyError; +> -VALUE notmuch_rb_eXapianError; +> -VALUE notmuch_rb_eFileError; +> -VALUE notmuch_rb_eFileNotEmailError; +> -VALUE notmuch_rb_eNullPointerError; +> -VALUE notmuch_rb_eTagTooLongError; +> -VALUE notmuch_rb_eUnbalancedFreezeThawError; +> -VALUE notmuch_rb_eUnbalancedAtomicError; +> - +> -ID ID_call; +> -ID ID_db_create; +> -ID ID_db_mode; +> +#ifdef RUBY_INIT_C +> +#define extern +> +#endif +> + +> +extern VALUE notmuch_rb_cDatabase; +> +extern VALUE notmuch_rb_cDirectory; +> +extern VALUE notmuch_rb_cFileNames; +> +extern VALUE notmuch_rb_cQuery; +> +extern VALUE notmuch_rb_cThreads; +> +extern VALUE notmuch_rb_cThread; +> +extern VALUE notmuch_rb_cMessages; +> +extern VALUE notmuch_rb_cMessage; +> +extern VALUE notmuch_rb_cTags; +> + +> +extern VALUE notmuch_rb_eBaseError; +> +extern VALUE notmuch_rb_eDatabaseError; +> +extern VALUE notmuch_rb_eMemoryError; +> +extern VALUE notmuch_rb_eReadOnlyError; +> +extern VALUE notmuch_rb_eXapianError; +> +extern VALUE notmuch_rb_eFileError; +> +extern VALUE notmuch_rb_eFileNotEmailError; +> +extern VALUE notmuch_rb_eNullPointerError; +> +extern VALUE notmuch_rb_eTagTooLongError; +> +extern VALUE notmuch_rb_eUnbalancedFreezeThawError; +> +extern VALUE notmuch_rb_eUnbalancedAtomicError; +> + +> +extern ID ID_call; +> +extern ID ID_db_create; +> +extern ID ID_db_mode; +> + +> +#undef extern +> +> /* RSTRING_PTR() is new in ruby-1.9 */ +> #if !defined(RSTRING_PTR) +> diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c +> index 3fe60fb..b2dc7f6 100644 +> --- a/bindings/ruby/init.c +> +++ b/bindings/ruby/init.c +> @@ -18,7 +18,9 @@ +> * Author: Ali Polatel +> */ +> +> +#define RUBY_INIT_C +> #include "defs.h" +> +#undef RUBY_INIT_C +> +> /* +> * Document-module: Notmuch