From: Austin Clements Date: Thu, 13 Feb 2014 06:50:59 +0000 (+1900) Subject: [PATCH v2] new: Detect dirent.d_type support at configure time X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0c7f88ddf4e982abe66f7e5913be9d7a99ae25ae;p=notmuch-archives.git [PATCH v2] new: Detect dirent.d_type support at configure time --- diff --git a/ab/047700b7ed60795c46b73d3e5940391144785f b/ab/047700b7ed60795c46b73d3e5940391144785f new file mode 100644 index 000000000..db36c9b87 --- /dev/null +++ b/ab/047700b7ed60795c46b73d3e5940391144785f @@ -0,0 +1,172 @@ +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 4005D431FBD + for ; Wed, 12 Feb 2014 22:51:16 -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 1uTjYMs3b3Z1 for ; + Wed, 12 Feb 2014 22:51:10 -0800 (PST) +Received: from dmz-mailsec-scanner-4.mit.edu (dmz-mailsec-scanner-4.mit.edu + [18.9.25.15]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id D19F4431FAE + for ; Wed, 12 Feb 2014 22:51:09 -0800 (PST) +X-AuditID: 1209190f-f790b6d000000c3a-e6-52fc6b5b5c9e +Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) + (using TLS with cipher AES256-SHA (256/256 bits)) + (Client did not present a certificate) + by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP + id F6.16.03130.B5B6CF25; Thu, 13 Feb 2014 01:51:07 -0500 (EST) +Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) + by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id s1D6p3Ej007008; + Thu, 13 Feb 2014 01:51:03 -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 s1D6p0KX018783 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Thu, 13 Feb 2014 01:51:02 -0500 +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1WDq8S-0005B0-Pa; Thu, 13 Feb 2014 01:51:00 -0500 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH v2] new: Detect dirent.d_type support at configure time +Date: Thu, 13 Feb 2014 01:50:59 -0500 +Message-Id: <1392274259-19765-1-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.8.4.rc3 +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFlrPIsWRmVeSWpSXmKPExsUixCmqrBud/SfI4PB2QYum6c4W12/OZLZ4 + s3IeqwOzx+GvC1k8bt1/ze7xbNUt5gDmKC6blNSczLLUIn27BK6MOa0dTAX3pSuWTnnM3MB4 + UKSLkZNDQsBEYsvOVYwQtpjEhXvr2boYuTiEBGYzSbxY9IYRwtnIKHFk9nco5w6TxJmD31kh + nLmMEoeOTWMD6WcT0JDYtn852CwRAWmJnXdns4LYzALeEm+uHgSrERZwl5jx9w4TiM0ioCox + /28/WA2vgINEQ8diJog7lCQWntrGOoGRdwEjwypG2ZTcKt3cxMyc4tRk3eLkxLy81CJdE73c + zBK91JTSTYzgcJHk38H47aDSIUYBDkYlHl6NGb+DhFgTy4orcw8xSnIwKYny7sn4EyTEl5Sf + UpmRWJwRX1Sak1p8iFGCg1lJhFdGAijHm5JYWZValA+TkuZgURLnrbX4FSQkkJ5YkpqdmlqQ + WgSTleHgUJLg/ZEJ1ChYlJqeWpGWmVOCkGbi4AQZzgM0/BFIDW9xQWJucWY6RP4Uo6KUOO9p + kIsEQBIZpXlwvbB4fsUoDvSKMO9vkHYeYCqA634FNJgJaHBq1G+QwSWJCCmpBsYar8e5My/8 + +X1djWntI8/tJ7U2ypv+6VbWvxWqF5mmv6/gfVfaXs+zTmsEfj54Jh89bfl+5+nz0059v7/9 + 4cYlebnvHVM1tH5v6LX9aZHsZvVJRF2rg/ur/uEVWUlda/beUN/3u9ByS7lEfrD4vZtG+StP + CGptMrlo696attZWIVjqU8aW1AglluKMREMt5qLiRAAWBRTKwgIAAA== +Cc: tomi.ollila@iki.fi +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: Thu, 13 Feb 2014 06:51:16 -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. +--- +This is a trivial rebase of +id:1385262952-29240-1-git-send-email-amdragon@mit.edu, which I +apparently never got around to sending. Tomi and Jani checked off v1 +of this patch, so I'm marking it ready. + + 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 66aaedb..2eaed4a 100755 +--- a/configure ++++ b/configure +@@ -578,6 +578,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 +@@ -769,6 +780,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} + +@@ -829,6 +843,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) \\ +@@ -839,6 +854,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 cd74489..8529fdd 100644 +--- a/notmuch-new.c ++++ b/notmuch-new.c +@@ -173,7 +173,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 +