1 Return-Path: <amdragon@mit.edu>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id E4FF7431FB6
\r
6 for <notmuch@notmuchmail.org>; Sun, 13 May 2012 10:19:23 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id E5s8n4wkl1nD for <notmuch@notmuchmail.org>;
\r
16 Sun, 13 May 2012 10:19:22 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id C42A5431FAE
\r
20 for <notmuch@notmuchmail.org>; Sun, 13 May 2012 10:19:22 -0700 (PDT)
\r
21 X-AuditID: 1209190d-b7fbf6d0000008ba-fc-4fafed19f001
\r
22 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])
\r
23 by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 62.34.02234.91DEFAF4; Sun, 13 May 2012 13:19:21 -0400 (EDT)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q4DHJLxv027983;
\r
27 Sun, 13 May 2012 13:19:21 -0400
\r
28 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])
\r
29 (authenticated bits=0)
\r
30 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
31 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q4DHJI6T001659
\r
32 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
33 Sun, 13 May 2012 13:19:20 -0400 (EDT)
\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)
\r
35 (envelope-from <amdragon@mit.edu>)
\r
36 id 1STcRx-0004hq-Of; Sun, 13 May 2012 13:19:17 -0400
\r
37 Date: Sun, 13 May 2012 13:19:17 -0400
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: Tomi Ollila <tomi.ollila@iki.fi>
\r
40 Subject: Re: [PATCH] ruby: extern linkage portability improvement
\r
41 Message-ID: <20120513171917.GL11804@mit.edu>
\r
42 References: <1336669964-24231-1-git-send-email-tomi.ollila@iki.fi>
\r
44 Content-Type: text/plain; charset=us-ascii
\r
45 Content-Disposition: inline
\r
46 In-Reply-To: <1336669964-24231-1-git-send-email-tomi.ollila@iki.fi>
\r
47 User-Agent: Mutt/1.5.21 (2010-09-15)
\r
48 X-Brightmail-Tracker:
\r
49 H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42IR4hRV1pV8u97fYOJJa4vrN2cyW7xZOY/V
\r
50 gcnj8NeFLB7PVt1iDmCK4rJJSc3JLEst0rdL4MpYcegnU8FCmYrDF3ayNTCeEe9i5OSQEDCR
\r
51 mHntHAuELSZx4d56ti5GLg4hgX2MEtfmLWaCcDYwSlw6/ogVwjnJJDFn1h1GCGcJo8StiZeY
\r
52 QfpZBFQlprdMYgex2QQ0JLbtX84IYosIqEg8aFvPCmIzC0hLfPvdzARiCws4ShzbdwJoHwcH
\r
53 r4COxK4JDiBhIQEnif/X+sDG8AoISpyc+YQFolVL4sa/l0wg5SBjlv/jAAlzCjhLPJnRADZd
\r
54 FGjTlJPb2CYwCs1C0j0LSfcshO4FjMyrGGVTcqt0cxMzc4pTk3WLkxPz8lKLdI30cjNL9FJT
\r
55 SjcxgsNakncH47uDSocYBTgYlXh4F4iu9xdiTSwrrsw9xCjJwaQkysv9BijEl5SfUpmRWJwR
\r
56 X1Sak1p8iFGCg1lJhHf9Q6Acb0piZVVqUT5MSpqDRUmcV1XrnZ+QQHpiSWp2ampBahFMVoaD
\r
57 Q0mClw9kqGBRanpqRVpmTglCmomDE2Q4D9BwUZAa3uKCxNzizHSI/ClGRSlx3mqQhABIIqM0
\r
58 D64XlnZeMYoDvSLMqw9SxQNMWXDdr4AGMwEN5hdYBzK4JBEhJdXAuFc2WuBZXp/coS/ex1gW
\r
59 /tht67TU9+jysEyGELew155zX1kc22Ctdu3vvFubHi87c9V0t/xkyzvL7TkY4j+t/xTCopGu
\r
60 NFVEPXGGt5lU6z3dPwf2unwoSetb2c9n3f33lUDwhzmlHAVOmm/N2VdN6eIraaowPOjLEXLA
\r
61 8V+C/wonx0XJpz5tUGIpzkg01GIuKk4EAG/T1+cWAwAA
\r
62 Cc: notmuch@notmuchmail.org
\r
63 X-BeenThere: notmuch@notmuchmail.org
\r
64 X-Mailman-Version: 2.1.13
\r
66 List-Id: "Use and development of the notmuch mail system."
\r
67 <notmuch.notmuchmail.org>
\r
68 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
69 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
70 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
71 List-Post: <mailto:notmuch@notmuchmail.org>
\r
72 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
73 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
74 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
75 X-List-Received-Date: Sun, 13 May 2012 17:19:24 -0000
\r
77 Quoth Tomi Ollila on May 10 at 8:12 pm:
\r
78 > Some C compilers are stricter when it comes to (tentative) definition
\r
79 > of a variable -- in those compilers introducing variable without 'extern'
\r
80 > keyword always allocates new 'storage' to the variable and linking all
\r
81 > these modules fails due to duplicate symbols.
\r
83 > This change uses some macro trickery to avoid writing every variable twice.
\r
85 > This is reimplementation of Charlie Allom's patch:
\r
86 > id:"1336481467-66356-1-git-send-email-charlie@mediasp.com"
\r
88 > combining information from other change made by Ali Polatel.
\r
91 > Charlie: could you test whether this patch actually work ? :)
\r
93 > Everyone: what do you think of the "hiding extern" macro trick ?
\r
95 This seems like a hacky and nonstandard way to do this. Granted, the
\r
96 standard way to do this---always declare variables extern in .h files
\r
97 and also give a non-extern definition in exactly one .c file---is more
\r
98 verbose, but nobody will be surprised or confused by it.
\r
100 > bindings/ruby/defs.h | 56 +++++++++++++++++++++++++++----------------------
\r
101 > bindings/ruby/init.c | 2 +
\r
102 > 2 files changed, 33 insertions(+), 25 deletions(-)
\r
104 > diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h
\r
105 > index 85d8205..2531760 100644
\r
106 > --- a/bindings/ruby/defs.h
\r
107 > +++ b/bindings/ruby/defs.h
\r
108 > @@ -24,31 +24,37 @@
\r
109 > #include <ruby.h>
\r
110 > #include "notmuch.h"
\r
112 > -VALUE notmuch_rb_cDatabase;
\r
113 > -VALUE notmuch_rb_cDirectory;
\r
114 > -VALUE notmuch_rb_cFileNames;
\r
115 > -VALUE notmuch_rb_cQuery;
\r
116 > -VALUE notmuch_rb_cThreads;
\r
117 > -VALUE notmuch_rb_cThread;
\r
118 > -VALUE notmuch_rb_cMessages;
\r
119 > -VALUE notmuch_rb_cMessage;
\r
120 > -VALUE notmuch_rb_cTags;
\r
122 > -VALUE notmuch_rb_eBaseError;
\r
123 > -VALUE notmuch_rb_eDatabaseError;
\r
124 > -VALUE notmuch_rb_eMemoryError;
\r
125 > -VALUE notmuch_rb_eReadOnlyError;
\r
126 > -VALUE notmuch_rb_eXapianError;
\r
127 > -VALUE notmuch_rb_eFileError;
\r
128 > -VALUE notmuch_rb_eFileNotEmailError;
\r
129 > -VALUE notmuch_rb_eNullPointerError;
\r
130 > -VALUE notmuch_rb_eTagTooLongError;
\r
131 > -VALUE notmuch_rb_eUnbalancedFreezeThawError;
\r
132 > -VALUE notmuch_rb_eUnbalancedAtomicError;
\r
135 > -ID ID_db_create;
\r
137 > +#ifdef RUBY_INIT_C
\r
141 > +extern VALUE notmuch_rb_cDatabase;
\r
142 > +extern VALUE notmuch_rb_cDirectory;
\r
143 > +extern VALUE notmuch_rb_cFileNames;
\r
144 > +extern VALUE notmuch_rb_cQuery;
\r
145 > +extern VALUE notmuch_rb_cThreads;
\r
146 > +extern VALUE notmuch_rb_cThread;
\r
147 > +extern VALUE notmuch_rb_cMessages;
\r
148 > +extern VALUE notmuch_rb_cMessage;
\r
149 > +extern VALUE notmuch_rb_cTags;
\r
151 > +extern VALUE notmuch_rb_eBaseError;
\r
152 > +extern VALUE notmuch_rb_eDatabaseError;
\r
153 > +extern VALUE notmuch_rb_eMemoryError;
\r
154 > +extern VALUE notmuch_rb_eReadOnlyError;
\r
155 > +extern VALUE notmuch_rb_eXapianError;
\r
156 > +extern VALUE notmuch_rb_eFileError;
\r
157 > +extern VALUE notmuch_rb_eFileNotEmailError;
\r
158 > +extern VALUE notmuch_rb_eNullPointerError;
\r
159 > +extern VALUE notmuch_rb_eTagTooLongError;
\r
160 > +extern VALUE notmuch_rb_eUnbalancedFreezeThawError;
\r
161 > +extern VALUE notmuch_rb_eUnbalancedAtomicError;
\r
163 > +extern ID ID_call;
\r
164 > +extern ID ID_db_create;
\r
165 > +extern ID ID_db_mode;
\r
169 > /* RSTRING_PTR() is new in ruby-1.9 */
\r
170 > #if !defined(RSTRING_PTR)
\r
171 > diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c
\r
172 > index 3fe60fb..b2dc7f6 100644
\r
173 > --- a/bindings/ruby/init.c
\r
174 > +++ b/bindings/ruby/init.c
\r
175 > @@ -18,7 +18,9 @@
\r
176 > * Author: Ali Polatel <alip@exherbo.org>
\r
179 > +#define RUBY_INIT_C
\r
180 > #include "defs.h"
\r
181 > +#undef RUBY_INIT_C
\r
184 > * Document-module: Notmuch
\r