[PATCH v2] new: Detect dirent.d_type support at configure time
authorAustin Clements <amdragon@MIT.EDU>
Thu, 13 Feb 2014 06:50:59 +0000 (01:50 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:59:56 +0000 (09:59 -0800)
ab/047700b7ed60795c46b73d3e5940391144785f [new file with mode: 0644]

diff --git a/ab/047700b7ed60795c46b73d3e5940391144785f b/ab/047700b7ed60795c46b73d3e5940391144785f
new file mode 100644 (file)
index 0000000..db36c9b
--- /dev/null
@@ -0,0 +1,172 @@
+Return-Path: <amdragon@mit.edu>\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 4005D431FBD\r
+       for <notmuch@notmuchmail.org>; Wed, 12 Feb 2014 22:51:16 -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 1uTjYMs3b3Z1 for <notmuch@notmuchmail.org>;\r
+       Wed, 12 Feb 2014 22:51:10 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-4.mit.edu (dmz-mailsec-scanner-4.mit.edu\r
+       [18.9.25.15])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id D19F4431FAE\r
+       for <notmuch@notmuchmail.org>; Wed, 12 Feb 2014 22:51:09 -0800 (PST)\r
+X-AuditID: 1209190f-f790b6d000000c3a-e6-52fc6b5b5c9e\r
+Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
+       (using TLS with cipher AES256-SHA (256/256 bits))\r
+       (Client did not present a certificate)\r
+       by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id F6.16.03130.B5B6CF25; Thu, 13 Feb 2014 01:51:07 -0500 (EST)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+       by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id s1D6p3Ej007008; \r
+       Thu, 13 Feb 2014 01:51:03 -0500\r
+Received: from drake.dyndns.org\r
+       (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
+       [216.15.114.40]) (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s1D6p0KX018783\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Thu, 13 Feb 2014 01:51:02 -0500\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1WDq8S-0005B0-Pa; Thu, 13 Feb 2014 01:51:00 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2] new: Detect dirent.d_type support at configure time\r
+Date: Thu, 13 Feb 2014 01:50:59 -0500\r
+Message-Id: <1392274259-19765-1-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.8.4.rc3\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFlrPIsWRmVeSWpSXmKPExsUixCmqrBud/SfI4PB2QYum6c4W12/OZLZ4\r
+       s3IeqwOzx+GvC1k8bt1/ze7xbNUt5gDmKC6blNSczLLUIn27BK6MOa0dTAX3pSuWTnnM3MB4\r
+       UKSLkZNDQsBEYsvOVYwQtpjEhXvr2boYuTiEBGYzSbxY9IYRwtnIKHFk9nco5w6TxJmD31kh\r
+       nLmMEoeOTWMD6WcT0JDYtn852CwRAWmJnXdns4LYzALeEm+uHgSrERZwl5jx9w4TiM0ioCox\r
+       /28/WA2vgINEQ8diJog7lCQWntrGOoGRdwEjwypG2ZTcKt3cxMyc4tRk3eLkxLy81CJdE73c\r
+       zBK91JTSTYzgcJHk38H47aDSIUYBDkYlHl6NGb+DhFgTy4orcw8xSnIwKYny7sn4EyTEl5Sf\r
+       UpmRWJwRX1Sak1p8iFGCg1lJhFdGAijHm5JYWZValA+TkuZgURLnrbX4FSQkkJ5YkpqdmlqQ\r
+       WgSTleHgUJLg/ZEJ1ChYlJqeWpGWmVOCkGbi4AQZzgM0/BFIDW9xQWJucWY6RP4Uo6KUOO9p\r
+       kIsEQBIZpXlwvbB4fsUoDvSKMO9vkHYeYCqA634FNJgJaHBq1G+QwSWJCCmpBsYar8e5My/8\r
+       +X1djWntI8/tJ7U2ypv+6VbWvxWqF5mmv6/gfVfaXs+zTmsEfj54Jh89bfl+5+nz0059v7/9\r
+       4cYlebnvHVM1tH5v6LX9aZHsZvVJRF2rg/ur/uEVWUlda/beUN/3u9ByS7lEfrD4vZtG+StP\r
+       CGptMrlo696attZWIVjqU8aW1AglluKMREMt5qLiRAAWBRTKwgIAAA==\r
+Cc: tomi.ollila@iki.fi\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: Thu, 13 Feb 2014 06:51:16 -0000\r
+\r
+Support for dirent.d_type is OS-specific.  Previously, we used\r
+_DIRENT_HAVE_D_TYPE to detect support for this, but this is apparently\r
+a glic-ism (FreeBSD, for example, supports d_type, but does not define\r
+this).  Since there's no cross-platform way to detect support for\r
+dirent.d_type, detect it using a test compile at configure time.\r
+---\r
+This is a trivial rebase of\r
+id:1385262952-29240-1-git-send-email-amdragon@mit.edu, which I\r
+apparently never got around to sending.  Tomi and Jani checked off v1\r
+of this patch, so I'm marking it ready.\r
+\r
+ compat/have_d_type.c | 10 ++++++++++\r
+ configure            | 16 ++++++++++++++++\r
+ notmuch-new.c        |  2 +-\r
+ 3 files changed, 27 insertions(+), 1 deletion(-)\r
+ create mode 100644 compat/have_d_type.c\r
+\r
+diff --git a/compat/have_d_type.c b/compat/have_d_type.c\r
+new file mode 100644\r
+index 0000000..9ca6c6e\r
+--- /dev/null\r
++++ b/compat/have_d_type.c\r
+@@ -0,0 +1,10 @@\r
++#include <dirent.h>\r
++\r
++int main()\r
++{\r
++    struct dirent ent;\r
++\r
++    (void) ent.d_type;\r
++\r
++    return 0;\r
++}\r
+diff --git a/configure b/configure\r
+index 66aaedb..2eaed4a 100755\r
+--- a/configure\r
++++ b/configure\r
+@@ -578,6 +578,17 @@ else\r
+ fi\r
+ rm -f compat/have_timegm\r
\r
++printf "Checking for dirent.d_type... "\r
++if ${CC} -o compat/have_d_type "$srcdir"/compat/have_d_type.c > /dev/null 2>&1\r
++then\r
++    printf "Yes.\n"\r
++    have_d_type="1"\r
++else\r
++    printf "No (will use stat instead).\n"\r
++    have_d_type="0"\r
++fi\r
++rm -f compat/have_d_type\r
++\r
+ printf "Checking for standard version of getpwuid_r... "\r
+ if ${CC} -o compat/check_getpwuid "$srcdir"/compat/check_getpwuid.c > /dev/null 2>&1\r
+ then\r
+@@ -769,6 +780,9 @@ HAVE_STRCASESTR = ${have_strcasestr}\r
+ # build its own version)\r
+ HAVE_STRSEP = ${have_strsep}\r
\r
++# Whether struct dirent has d_type (if not, then notmuch will use stat)\r
++HAVE_D_TYPE = ${have_d_type}\r
++\r
+ # Whether the Xapian version in use supports compaction\r
+ HAVE_XAPIAN_COMPACT = ${have_xapian_compact}\r
\r
+@@ -829,6 +843,7 @@ CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)      \\\r
+                  \$(VALGRIND_CFLAGS)                                   \\\r
+                  -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)                 \\\r
+                  -DHAVE_STRSEP=\$(HAVE_STRSEP)                         \\\r
++                 -DHAVE_D_TYPE=\$(HAVE_D_TYPE)                         \\\r
+                  -DSTD_GETPWUID=\$(STD_GETPWUID)                       \\\r
+                  -DSTD_ASCTIME=\$(STD_ASCTIME)                         \\\r
+                  -DHAVE_XAPIAN_COMPACT=\$(HAVE_XAPIAN_COMPACT)         \\\r
+@@ -839,6 +854,7 @@ CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)    \\\r
+                    \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS)             \\\r
+                    -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)               \\\r
+                    -DHAVE_STRSEP=\$(HAVE_STRSEP)                       \\\r
++                   -DHAVE_D_TYPE=\$(HAVE_D_TYPE)                       \\\r
+                    -DSTD_GETPWUID=\$(STD_GETPWUID)                     \\\r
+                    -DSTD_ASCTIME=\$(STD_ASCTIME)                       \\\r
+                    -DHAVE_XAPIAN_COMPACT=\$(HAVE_XAPIAN_COMPACT)       \\\r
+diff --git a/notmuch-new.c b/notmuch-new.c\r
+index cd74489..8529fdd 100644\r
+--- a/notmuch-new.c\r
++++ b/notmuch-new.c\r
+@@ -173,7 +173,7 @@ dirent_type (const char *path, const struct dirent *entry)\r
+     char *abspath;\r
+     int err, saved_errno;\r
\r
+-#ifdef _DIRENT_HAVE_D_TYPE\r
++#if HAVE_D_TYPE\r
+     /* Mapping from d_type to stat mode_t.  We omit DT_LNK so that\r
+      * we'll fall through to stat and get the real file type. */\r
+     static const mode_t modes[] = {\r
+-- \r
+1.8.4.rc3\r
+\r