unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] new: Detect dirent.d_type support at configure time
@ 2013-11-24  3:15 Austin Clements
  2013-11-24 17:08 ` Tomi Ollila
  2014-01-01 12:53 ` Jani Nikula
  0 siblings, 2 replies; 3+ messages in thread
From: Austin Clements @ 2013-11-24  3:15 UTC (permalink / raw)
  To: notmuch; +Cc: pi-notmuch

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 <dirent.h>
+
+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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] new: Detect dirent.d_type support at configure time
  2013-11-24  3:15 [PATCH] new: Detect dirent.d_type support at configure time Austin Clements
@ 2013-11-24 17:08 ` Tomi Ollila
  2014-01-01 12:53 ` Jani Nikula
  1 sibling, 0 replies; 3+ messages in thread
From: Tomi Ollila @ 2013-11-24 17:08 UTC (permalink / raw)
  To: Austin Clements, notmuch; +Cc: pi-notmuch

On Sun, Nov 24 2013, Austin Clements <amdragon@MIT.EDU> wrote:

> 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.
> ---

LGTM.

Tomi

>  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 <dirent.h>
> +
> +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
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] new: Detect dirent.d_type support at configure time
  2013-11-24  3:15 [PATCH] new: Detect dirent.d_type support at configure time Austin Clements
  2013-11-24 17:08 ` Tomi Ollila
@ 2014-01-01 12:53 ` Jani Nikula
  1 sibling, 0 replies; 3+ messages in thread
From: Jani Nikula @ 2014-01-01 12:53 UTC (permalink / raw)
  To: Austin Clements, notmuch; +Cc: pi-notmuch

On Sun, 24 Nov 2013, Austin Clements <amdragon@MIT.EDU> wrote:
> 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 <dirent.h>
> +
> +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)

The patch looks good, but the above two hunks no longer apply
cleanly. Please repost.

BR,
Jani.



> 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
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-01-01 12:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-24  3:15 [PATCH] new: Detect dirent.d_type support at configure time Austin Clements
2013-11-24 17:08 ` Tomi Ollila
2014-01-01 12:53 ` Jani Nikula

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).