From 37df70b260173715a59f9bcc926a13dda093fb19 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Sun, 24 Nov 2013 22:15:52 +1900 Subject: [PATCH] [PATCH] new: Detect dirent.d_type support at configure time --- a6/c1f3439ce2616a5a1f49fe042e72ce70b639e4 | 167 ++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 a6/c1f3439ce2616a5a1f49fe042e72ce70b639e4 diff --git a/a6/c1f3439ce2616a5a1f49fe042e72ce70b639e4 b/a6/c1f3439ce2616a5a1f49fe042e72ce70b639e4 new file mode 100644 index 000000000..2336c4681 --- /dev/null +++ b/a6/c1f3439ce2616a5a1f49fe042e72ce70b639e4 @@ -0,0 +1,167 @@ +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 1929E431FD5 + for ; Sat, 23 Nov 2013 19:16:13 -0800 (PST) +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 gOj9JCQrZZKO for ; + Sat, 23 Nov 2013 19:16:05 -0800 (PST) +Received: from dmz-mailsec-scanner-1.mit.edu (dmz-mailsec-scanner-1.mit.edu + [18.9.25.12]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id D8122431FCB + for ; Sat, 23 Nov 2013 19:16:04 -0800 (PST) +X-AuditID: 1209190c-b7f7f6d000000bbd-84-52916f732467 +Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) + (using TLS with cipher AES256-SHA (256/256 bits)) + (Client did not present a certificate) + by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP + id 81.BF.03005.47F61925; Sat, 23 Nov 2013 22:16:04 -0500 (EST) +Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) + by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id rAO3G01R003508; + Sat, 23 Nov 2013 22:16:01 -0500 +Received: from drake.dyndns.org + (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com + [216.15.114.40]) (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id rAO3Fw0n006349 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Sat, 23 Nov 2013 22:16:00 -0500 +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1VkQAw-0007cL-Ay; Sat, 23 Nov 2013 22:15:58 -0500 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH] new: Detect dirent.d_type support at configure time +Date: Sat, 23 Nov 2013 22:15:52 -0500 +Message-Id: <1385262952-29240-1-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.8.4.rc3 +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFlrKIsWRmVeSWpSXmKPExsUixCmqrVuSPzHIYNFVVovrN2cyWxw928Pm + wOTxbNUtZo+VLy6zBzBFcdmkpOZklqUW6dslcGXc/v+HtaBZqmLZ0egGxknCXYycHBICJhKP + fy1ihbDFJC7cW8/WxcjFISQwm0ni+N4LzBDORkaJTRfaWSGcO0wSzafWQjlzGSX+9s9lA+ln + E9CQ2LZ/OSOILSIgLbHz7mywucwCNhKf9r9lBrGFBVwket41gcVZBFQlns/ewAJi8wo4SNxe + cJQJ4g4liYWntrFOYORdwMiwilE2JbdKNzcxM6c4NVm3ODkxLy+1SNdQLzezRC81pXQTIzg0 + JHl2ML45qHSIUYCDUYmHV+D+hCAh1sSy4srcQ4ySHExKoryLciYGCfEl5adUZiQWZ8QXleak + Fh9ilOBgVhLh7YoHyvGmJFZWpRblw6SkOViUxHlvctgHCQmkJ5akZqemFqQWwWRlODiUJHil + 8oAaBYtS01Mr0jJzShDSTBycIMN5gIY7g9TwFhck5hZnpkPkTzEqSonzvs0FSgiAJDJK8+B6 + YbH7ilEc6BVhXhOQdh5g3MN1vwIazAQ0mF2yG2RwSSJCSqqB0SqKvW76s5bv3GFWa8vWv1Iv + 7VubHrfo8SUX+9xMW7FNM8rD+jMWqijtfR/hEzr7eA2D39P8Mrml/gI3JpzcHvKeRWnD3/XZ + ucGzC+8LhUrOtl6ybNOkpCNBBUe8a6p+ND6dm/DvgquX8I0d6kEHKnLfpS++FdGjM8lbQKr0 + UW6Sc2nN7P0FSizFGYmGWsxFxYkAigEnHbgCAAA= +Cc: pi-notmuch@pihost.us +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, 24 Nov 2013 03:16:13 -0000 + +Support for dirent.d_type is OS-specific. Previously, we used +_DIRENT_HAVE_D_TYPE to detect support for this, but this is apparently +a glic-ism (FreeBSD, for example, supports d_type, but does not define +this). Since there's no cross-platform way to detect support for +dirent.d_type, detect it using a test compile at configure time. +--- + compat/have_d_type.c | 10 ++++++++++ + configure | 16 ++++++++++++++++ + notmuch-new.c | 2 +- + 3 files changed, 27 insertions(+), 1 deletion(-) + create mode 100644 compat/have_d_type.c + +diff --git a/compat/have_d_type.c b/compat/have_d_type.c +new file mode 100644 +index 0000000..9ca6c6e +--- /dev/null ++++ b/compat/have_d_type.c +@@ -0,0 +1,10 @@ ++#include ++ ++int main() ++{ ++ struct dirent ent; ++ ++ (void) ent.d_type; ++ ++ return 0; ++} +diff --git a/configure b/configure +index 1a8e939..d2d193c 100755 +--- a/configure ++++ b/configure +@@ -557,6 +557,17 @@ else + fi + rm -f compat/have_timegm + ++printf "Checking for dirent.d_type... " ++if ${CC} -o compat/have_d_type "$srcdir"/compat/have_d_type.c > /dev/null 2>&1 ++then ++ printf "Yes.\n" ++ have_d_type="1" ++else ++ printf "No (will use stat instead).\n" ++ have_d_type="0" ++fi ++rm -f compat/have_d_type ++ + printf "Checking for standard version of getpwuid_r... " + if ${CC} -o compat/check_getpwuid "$srcdir"/compat/check_getpwuid.c > /dev/null 2>&1 + then +@@ -745,6 +756,9 @@ HAVE_STRCASESTR = ${have_strcasestr} + # build its own version) + HAVE_STRSEP = ${have_strsep} + ++# Whether struct dirent has d_type (if not, then notmuch will use stat) ++HAVE_D_TYPE = ${have_d_type} ++ + # Whether the Xapian version in use supports compaction + HAVE_XAPIAN_COMPACT = ${have_xapian_compact} + +@@ -805,6 +819,7 @@ CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\ + \$(VALGRIND_CFLAGS) \\ + -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR) \\ + -DHAVE_STRSEP=\$(HAVE_STRSEP) \\ ++ -DHAVE_D_TYPE=\$(HAVE_D_TYPE) \\ + -DSTD_GETPWUID=\$(STD_GETPWUID) \\ + -DSTD_ASCTIME=\$(STD_ASCTIME) \\ + -DHAVE_XAPIAN_COMPACT=\$(HAVE_XAPIAN_COMPACT) +@@ -813,6 +828,7 @@ CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\ + \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS) \\ + -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR) \\ + -DHAVE_STRSEP=\$(HAVE_STRSEP) \\ ++ -DHAVE_D_TYPE=\$(HAVE_D_TYPE) \\ + -DSTD_GETPWUID=\$(STD_GETPWUID) \\ + -DSTD_ASCTIME=\$(STD_ASCTIME) \\ + -DHAVE_XAPIAN_COMPACT=\$(HAVE_XAPIAN_COMPACT) +diff --git a/notmuch-new.c b/notmuch-new.c +index ba05cb4..423e188 100644 +--- a/notmuch-new.c ++++ b/notmuch-new.c +@@ -167,7 +167,7 @@ dirent_type (const char *path, const struct dirent *entry) + char *abspath; + int err, saved_errno; + +-#ifdef _DIRENT_HAVE_D_TYPE ++#if HAVE_D_TYPE + /* Mapping from d_type to stat mode_t. We omit DT_LNK so that + * we'll fall through to stat and get the real file type. */ + static const mode_t modes[] = { +-- +1.8.4.rc3 + -- 2.26.2