Re: [PATCH 10/10] timegm: add portable implementation (Solaris support)
authorJani Nikula <jani@nikula.org>
Sun, 4 Nov 2012 20:58:26 +0000 (22:58 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:50:18 +0000 (09:50 -0800)
62/e9fc66c169184f84ffb56c5b98f1c738fe5a4c [new file with mode: 0644]

diff --git a/62/e9fc66c169184f84ffb56c5b98f1c738fe5a4c b/62/e9fc66c169184f84ffb56c5b98f1c738fe5a4c
new file mode 100644 (file)
index 0000000..7bf95f0
--- /dev/null
@@ -0,0 +1,129 @@
+Return-Path: <jani@nikula.org>\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 D0834431FAF\r
+       for <notmuch@notmuchmail.org>; Sun,  4 Nov 2012 12:58:33 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[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 iGcxivQl3Izo for <notmuch@notmuchmail.org>;\r
+       Sun,  4 Nov 2012 12:58:33 -0800 (PST)\r
+Received: from mail-la0-f53.google.com (mail-la0-f53.google.com\r
+       [209.85.215.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id ECD6B431FAE\r
+       for <notmuch@notmuchmail.org>; Sun,  4 Nov 2012 12:58:32 -0800 (PST)\r
+Received: by mail-la0-f53.google.com with SMTP id l5so4020644lah.26\r
+       for <notmuch@notmuchmail.org>; Sun, 04 Nov 2012 12:58:31 -0800 (PST)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=google.com; s=20120113;\r
+       h=from:to:cc:subject:in-reply-to:references:user-agent:date\r
+       :message-id:mime-version:content-type:x-gm-message-state;\r
+       bh=hHXnhcLoBLT5KIN5NG6/x/fKbZv8RnFa9VR4qPsXto0=;\r
+       b=nUoCS8s8bc97b1nZf6c1DwFtzPHfFlAqJ5hgG1E6ubR1ldaDuaV880qI1toSL54Tet\r
+       8CpdCG8mbA65WhUO4ktgqrCWYu++bZv5BYRpnjcYgAwyaDkjbEFKUNcTk3d9BajIi10n\r
+       KRV+7BDoGZpR0SQgwDskeJ1y0cLGvzZARPp2pf4DqhcLSJPmipbiki3WNWh+CewR8ZtM\r
+       wxs1RzUSWMCs5dlTheGbYd0wZgc8dH1bXnkWTSTV2UKslakChHOyDcQBwMX6W/g0ROY+\r
+       VsbDOwZfR0vgLatWfvA8D0h8E1jBIZbQYjS2szw810FNr/G4fahTmrEYzGrvVVcJP0np\r
+       RIvw==\r
+Received: by 10.112.14.9 with SMTP id l9mr3280837lbc.78.1352062710189;\r
+       Sun, 04 Nov 2012 12:58:30 -0800 (PST)\r
+Received: from localhost (dsl-hkibrasgw4-fe51df00-27.dhcp.inet.fi.\r
+       [80.223.81.27])\r
+       by mx.google.com with ESMTPS id j9sm5070191lbk.17.2012.11.04.12.58.28\r
+       (version=SSLv3 cipher=OTHER); Sun, 04 Nov 2012 12:58:29 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: Blake Jones <blakej@foo.net>\r
+Subject: Re: [PATCH 10/10] timegm: add portable implementation (Solaris\r
+       support)\r
+In-Reply-To: <12349.1352043650@foo.net>\r
+References: <12349.1352043650@foo.net>\r
+User-Agent: Notmuch/0.14+81~g1924356 (http://notmuchmail.org) Emacs/23.4.1\r
+       (i686-pc-linux-gnu)\r
+Date: Sun, 04 Nov 2012 22:58:26 +0200\r
+Message-ID: <87ip9lf5l9.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Gm-Message-State:\r
+ ALoCoQl/q1s8W6WYzw+VI6ifA1o0KiwDlXcFxSxH0rOcFfC86uotU8orr/BUcVRPtXfr0xxRqUeF\r
+Cc: 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: Sun, 04 Nov 2012 20:58:34 -0000\r
+\r
+On Sun, 04 Nov 2012, Blake Jones <blakej@foo.net> wrote:\r
+> Hi Jani,\r
+>\r
+>> I'd prefer to use timegm() where available, and the suggested\r
+>> alternative [1] elsewhere.\r
+>> \r
+>> [1] http://www.kernel.org/doc/man-pages/online/pages/man3/timegm.3.html\r
+>\r
+> I considered this alternative, but decided against it because it's\r
+> completely MT-unsafe.  I don't know whether libnotmuch itself is\r
+> MT-safe, but a process which called this routine in one thread would\r
+> temporarily throw off any timezone-related work that any other threads\r
+> were doing, even if they weren't using libnotmuch.\r
+\r
+That is a valid point. Yet it doesn't change the fact that I'd prefer to\r
+use timegm() where available. Internally, glibc uses the same code to\r
+implement both timegm() and mktime(), and I'd hate it if the results\r
+were subtly different depending on whether the time zone was specified\r
+in the input or not. That said, I'm not opposed to using your simple\r
+timegm() alternative in the compat code if you think it's good enough to\r
+get you going on Solaris.\r
+\r
+As to solving the compat linking problem, I think the patch at the end\r
+of this message should fix it. Please try that with the regular notmuch\r
+approach to portability. The general idea is to keep parse-time-string\r
+as independent as possible from the rest of notmuch (possibly turning it\r
+into a dynamic library and a package of its own eventually), but I think\r
+including compat.h is an acceptable exception to make.\r
+\r
+HTH,\r
+Jani.\r
+\r
+\r
+diff --git a/parse-time-string/Makefile.local b/parse-time-string/Makefile.local\r
+index 53534f3..b3e5385 100644\r
+--- a/parse-time-string/Makefile.local\r
++++ b/parse-time-string/Makefile.local\r
+@@ -1,7 +1,9 @@\r
+ dir := parse-time-string\r
+ extra_cflags += -I$(srcdir)/$(dir)\r
+ \r
+-libparse-time-string_c_srcs := $(dir)/parse-time-string.c\r
++libparse-time-string_c_srcs =         \\r
++      $(notmuch_compat_srcs)          \\r
++      $(dir)/parse-time-string.c\r
+ \r
+ libparse-time-string_modules := $(libparse-time-string_c_srcs:.c=.o)\r
+ \r
+diff --git a/parse-time-string/parse-time-string.c b/parse-time-string/parse-time-string.c\r
+index 584067d3..ccad422 100644\r
+--- a/parse-time-string/parse-time-string.c\r
++++ b/parse-time-string/parse-time-string.c\r
+@@ -32,6 +32,7 @@\r
+ #include <sys/time.h>\r
+ #include <sys/types.h>\r
+ \r
++#include "compat.h"\r
+ #include "parse-time-string.h"\r
+ \r
+ /*\r