unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Solaris support - missing or incompatible functions
@ 2013-05-06 15:15 Vladimir.Marek
  2013-05-06 15:15 ` [PATCH 1/4] getpwuid: check for standards compliance (Solaris support) Vladimir.Marek
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Vladimir.Marek @ 2013-05-06 15:15 UTC (permalink / raw)
  To: notmuch

Hi,

This is next series of patches adding Solaris support to notmuch. I am mostly
using what Blake Jones sent some time ago + I fixed all the comments he
received back then. Since it's mostly his work, it's IMO fair to keep
him as an author. But since I made sure the patches work, I'm signing
them. I'm really git newbie, so hopefully this is right thing to do ...

I tested the build on Solaris using Oracle Studio and on Linux using
gcc (to make sure I haven't break anything).

I can't run the notmuch 'make test' on Solaris (too old bash) and on linux the
results are

421/525 tests passed.
25 tests failed.
79 tests skipped.

but they are the same without my changes too ...

Cheers
-- 
	Vlad

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

* [PATCH 1/4] getpwuid: check for standards compliance (Solaris support)
  2013-05-06 15:15 Solaris support - missing or incompatible functions Vladimir.Marek
@ 2013-05-06 15:15 ` Vladimir.Marek
  2013-05-06 15:16 ` [PATCH 2/4] asctime: " Vladimir.Marek
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 16+ messages in thread
From: Vladimir.Marek @ 2013-05-06 15:15 UTC (permalink / raw)
  To: notmuch; +Cc: Vladimir Marek

From: Blake Jones <blakej@foo.net>

Add checks to "configure" to see whether _POSIX_PTHREAD_SEMANTICS needs
to be defined to get the right number of arguments in the prototypes for
getpwuid_r().  Solaris' default implementation conforms to POSIX.1c
Draft 6, rather than the final POSIX.1c spec.  The standards-compliant
version can be used by defining _POSIX_PTHREAD_SEMANTICS.

This change also adds the file "compat/check_getpwuid.c", which
configure uses to perform its check, and modifies compat/compat.h to
define _POSIX_PTHREAD_SEMANTICS if configure detected it was needed.

Signed-off-by: Vladimir Marek <vlmarek@volny.cz>
---
 compat/check_getpwuid.c |   11 +++++++++++
 compat/compat.h         |    4 ++++
 configure               |   23 +++++++++++++++++++++--
 3 files changed, 36 insertions(+), 2 deletions(-)
 create mode 100644 compat/check_getpwuid.c

diff --git a/compat/check_getpwuid.c b/compat/check_getpwuid.c
new file mode 100644
index 0000000..c435eb8
--- /dev/null
+++ b/compat/check_getpwuid.c
@@ -0,0 +1,11 @@
+#include <stdio.h>
+#include <pwd.h>
+
+int main()
+{
+    struct passwd passwd, *ignored;
+
+    (void) getpwuid_r (0, &passwd, NULL, 0, &ignored);
+
+    return (0);
+}
diff --git a/compat/compat.h b/compat/compat.h
index b2e2736..c1ee0f9 100644
--- a/compat/compat.h
+++ b/compat/compat.h
@@ -30,6 +30,10 @@
 extern "C" {
 #endif
 
+#if !STD_GETPWUID
+#define _POSIX_PTHREAD_SEMANTICS 1
+#endif
+
 #if !HAVE_GETLINE
 #include <stdio.h>
 #include <unistd.h>
diff --git a/configure b/configure
index 460fcfc..8ef7bac 100755
--- a/configure
+++ b/configure
@@ -517,6 +517,17 @@ else
 fi
 rm -f compat/have_strcasestr
 
+printf "Checking for standard version of getpwuid_r... "
+if ${CC} -o compat/check_getpwuid "$srcdir"/compat/check_getpwuid.c > /dev/null 2>&1
+then
+    printf "Yes.\n"
+    std_getpwuid=1
+else
+    printf "No (will define _POSIX_PTHREAD_SEMANTICS to get it).\n"
+    std_getpwuid=0
+fi
+rm -f compat/check_getpwuid
+
 printf "int main(void){return 0;}\n" > minimal.c
 
 printf "Checking for rpath support... "
@@ -676,6 +687,11 @@ HAVE_GETLINE = ${have_getline}
 # build its own version)
 HAVE_STRCASESTR = ${have_strcasestr}
 
+# Whether the getpwuid_r function is standards-compliant
+# (if not, then notmuch will #define _POSIX_PTHREAD_SEMANTICS
+# to enable the standards-compliant version -- needed for Solaris)
+STD_GETPWUID = ${std_getpwuid}
+
 # Supported platforms (so far) are: LINUX, MACOSX, SOLARIS, FREEBSD, OPENBSD
 PLATFORM = ${platform}
 
@@ -720,10 +736,13 @@ WITH_ZSH = ${WITH_ZSH}
 # Combined flags for compiling and linking against all of the above
 CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)      \\
 		   \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND)   \\
-		   \$(VALGRIND_CFLAGS) -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)
+		   \$(VALGRIND_CFLAGS)                                   \\
+		   -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)                 \\
+		   -DSTD_GETPWUID=\$(STD_GETPWUID)
 CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)    \\
 		     \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
 		     \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS)             \\
-                     -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)
+		     -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)               \\
+		     -DSTD_GETPWUID=\$(STD_GETPWUID)
 CONFIGURE_LDFLAGS =  \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS)
 EOF
-- 
1.7.9.2

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

* [PATCH 2/4] asctime: check for standards compliance (Solaris support)
  2013-05-06 15:15 Solaris support - missing or incompatible functions Vladimir.Marek
  2013-05-06 15:15 ` [PATCH 1/4] getpwuid: check for standards compliance (Solaris support) Vladimir.Marek
@ 2013-05-06 15:16 ` Vladimir.Marek
  2013-05-06 15:16 ` [PATCH 3/4] strsep: check for availability " Vladimir.Marek
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 16+ messages in thread
From: Vladimir.Marek @ 2013-05-06 15:16 UTC (permalink / raw)
  To: notmuch; +Cc: Vladimir Marek

From: Vladimir Marek <vlmarek@volny.cz>

Add checks to "configure" to see whether _POSIX_PTHREAD_SEMANTICS needs
to be defined to get the right number of arguments in the prototypes for
asctime_r().  Solaris' default implementation conforms to POSIX.1c
Draft 6, rather than the final POSIX.1c spec.  The standards-compliant
version can be used by defining _POSIX_PTHREAD_SEMANTICS.

This change also adds the file "compat/check_asctime.c", which
configure uses to perform its check, and modifies compat/compat.h to
define _POSIX_PTHREAD_SEMANTICS if configure detected it was needed.

Signed-off-by: Vladimir Marek <vlmarek@volny.cz>
---
 compat/check_asctime.c |   11 +++++++++++
 compat/compat.h        |    3 +++
 configure              |   22 ++++++++++++++++++++--
 3 files changed, 34 insertions(+), 2 deletions(-)
 create mode 100644 compat/check_asctime.c

diff --git a/compat/check_asctime.c b/compat/check_asctime.c
new file mode 100644
index 0000000..b0e56f0
--- /dev/null
+++ b/compat/check_asctime.c
@@ -0,0 +1,11 @@
+#include <time.h>
+#include <stdio.h>
+
+int main()
+{
+    struct tm tm;
+
+    (void) asctime_r (&tm, NULL);
+
+    return (0);
+}
diff --git a/compat/compat.h b/compat/compat.h
index c1ee0f9..0c4ac66 100644
--- a/compat/compat.h
+++ b/compat/compat.h
@@ -33,6 +33,9 @@ extern "C" {
 #if !STD_GETPWUID
 #define _POSIX_PTHREAD_SEMANTICS 1
 #endif
+#if !STD_ASCTIME
+#define _POSIX_PTHREAD_SEMANTICS 1
+#endif
 
 #if !HAVE_GETLINE
 #include <stdio.h>
diff --git a/configure b/configure
index 8ef7bac..99ec71a 100755
--- a/configure
+++ b/configure
@@ -528,6 +528,17 @@ else
 fi
 rm -f compat/check_getpwuid
 
+printf "Checking for standard version of asctime_r... "
+if ${CC} -o compat/check_asctime "$srcdir"/compat/check_asctime.c > /dev/null 2>&1
+then
+    printf "Yes.\n"
+    std_asctime=1
+else
+    printf "No (will define _POSIX_PTHREAD_SEMANTICS to get it).\n"
+    std_asctime=0
+fi
+rm -f compat/check_asctime
+
 printf "int main(void){return 0;}\n" > minimal.c
 
 printf "Checking for rpath support... "
@@ -692,6 +703,11 @@ HAVE_STRCASESTR = ${have_strcasestr}
 # to enable the standards-compliant version -- needed for Solaris)
 STD_GETPWUID = ${std_getpwuid}
 
+# Whether the asctime_r function is standards-compliant
+# (if not, then notmuch will #define _POSIX_PTHREAD_SEMANTICS
+# to enable the standards-compliant version -- needed for Solaris)
+STD_ASCTIME = ${std_asctime}
+
 # Supported platforms (so far) are: LINUX, MACOSX, SOLARIS, FREEBSD, OPENBSD
 PLATFORM = ${platform}
 
@@ -738,11 +754,13 @@ CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)      \\
 		   \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND)   \\
 		   \$(VALGRIND_CFLAGS)                                   \\
 		   -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)                 \\
-		   -DSTD_GETPWUID=\$(STD_GETPWUID)
+		   -DSTD_GETPWUID=\$(STD_GETPWUID)                       \\
+		   -DSTD_ASCTIME=\$(STD_ASCTIME)
 CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)    \\
 		     \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
 		     \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS)             \\
 		     -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)               \\
-		     -DSTD_GETPWUID=\$(STD_GETPWUID)
+		     -DSTD_GETPWUID=\$(STD_GETPWUID)                     \\
+		     -DSTD_ASCTIME=\$(STD_ASCTIME)
 CONFIGURE_LDFLAGS =  \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS)
 EOF
-- 
1.7.9.2

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

* [PATCH 3/4] strsep: check for availability (Solaris support)
  2013-05-06 15:15 Solaris support - missing or incompatible functions Vladimir.Marek
  2013-05-06 15:15 ` [PATCH 1/4] getpwuid: check for standards compliance (Solaris support) Vladimir.Marek
  2013-05-06 15:16 ` [PATCH 2/4] asctime: " Vladimir.Marek
@ 2013-05-06 15:16 ` Vladimir.Marek
  2013-05-06 15:16 ` [PATCH 4/4] timegm: add portable implementation " Vladimir.Marek
  2013-05-12 20:02 ` Solaris support - missing or incompatible functions Jani Nikula
  4 siblings, 0 replies; 16+ messages in thread
From: Vladimir.Marek @ 2013-05-06 15:16 UTC (permalink / raw)
  To: notmuch; +Cc: Vladimir Marek

From: Blake Jones <blakej@foo.net>

Solaris does not ship a version of the strsep() function.  This change
adds a check to "configure" to see whether notmuch needs to provide its
own implementation, and if so, it uses the new version in
"compat/strsep.c" (which was copied from Mutt, and apparently before
that from glibc).

Signed-off-by: Vladimir Marek <vlmarek@volny.cz>
---
 compat/Makefile.local |    4 +++
 compat/compat.h       |    4 +++
 compat/have_strsep.c  |   11 +++++++++
 compat/strsep.c       |   65 +++++++++++++++++++++++++++++++++++++++++++++++++
 configure             |   17 +++++++++++++
 5 files changed, 101 insertions(+)
 create mode 100644 compat/have_strsep.c
 create mode 100644 compat/strsep.c

diff --git a/compat/Makefile.local b/compat/Makefile.local
index 13f16cd..2c4f65f 100644
--- a/compat/Makefile.local
+++ b/compat/Makefile.local
@@ -13,4 +13,8 @@ ifneq ($(HAVE_STRCASESTR),1)
 notmuch_compat_srcs += $(dir)/strcasestr.c
 endif
 
+ifneq ($(HAVE_STRSEP),1)
+notmuch_compat_srcs += $(dir)/strsep.c
+endif
+
 SRCS := $(SRCS) $(notmuch_compat_srcs)
diff --git a/compat/compat.h b/compat/compat.h
index 0c4ac66..ae762c3 100644
--- a/compat/compat.h
+++ b/compat/compat.h
@@ -53,6 +53,10 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp);
 char* strcasestr(const char *haystack, const char *needle);
 #endif /* !HAVE_STRCASESTR */
 
+#if !HAVE_STRSEP
+char *strsep(char **stringp, const char *delim);
+#endif /* !HAVE_STRSEP */
+
 /* Silence gcc warnings about unused results.  These warnings exist
  * for a reason; any use of this needs to be justified. */
 #ifdef __GNUC__
diff --git a/compat/have_strsep.c b/compat/have_strsep.c
new file mode 100644
index 0000000..2abab81
--- /dev/null
+++ b/compat/have_strsep.c
@@ -0,0 +1,11 @@
+#define _GNU_SOURCE
+#include <string.h>
+
+int main()
+{
+    char *found;
+    char **stringp;
+    const char *delim;
+
+    found = strsep(stringp, delim);
+}
diff --git a/compat/strsep.c b/compat/strsep.c
new file mode 100644
index 0000000..78ab9e7
--- /dev/null
+++ b/compat/strsep.c
@@ -0,0 +1,65 @@
+/* Copyright (C) 1992, 93, 96, 97, 98, 99, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <string.h>
+
+/* Taken from glibc 2.6.1 */
+
+char *strsep (char **stringp, const char *delim)
+{
+  char *begin, *end;
+
+  begin = *stringp;
+  if (begin == NULL)
+    return NULL;
+
+  /* A frequent case is when the delimiter string contains only one
+     character.  Here we don't need to call the expensive `strpbrk'
+     function and instead work using `strchr'.  */
+  if (delim[0] == '\0' || delim[1] == '\0')
+    {
+      char ch = delim[0];
+
+      if (ch == '\0')
+	end = NULL;
+      else
+	{
+	  if (*begin == ch)
+	    end = begin;
+	  else if (*begin == '\0')
+	    end = NULL;
+	  else
+	    end = strchr (begin + 1, ch);
+	}
+    }
+  else
+    /* Find the end of the token.  */
+    end = strpbrk (begin, delim);
+
+  if (end)
+    {
+      /* Terminate the token and set *STRINGP past NUL character.  */
+      *end++ = '\0';
+      *stringp = end;
+    }
+  else
+    /* No more delimiters; this is the last token.  */
+    *stringp = NULL;
+
+  return begin;
+}
diff --git a/configure b/configure
index 99ec71a..5243cac 100755
--- a/configure
+++ b/configure
@@ -517,6 +517,17 @@ else
 fi
 rm -f compat/have_strcasestr
 
+printf "Checking for strsep... "
+if ${CC} -o compat/have_strsep "$srcdir"/compat/have_strsep.c > /dev/null 2>&1
+then
+    printf "Yes.\n"
+    have_strsep="1"
+else
+    printf "No (will use our own instead).\n"
+    have_strsep="0"
+fi
+rm -f compat/have_strsep
+
 printf "Checking for standard version of getpwuid_r... "
 if ${CC} -o compat/check_getpwuid "$srcdir"/compat/check_getpwuid.c > /dev/null 2>&1
 then
@@ -698,6 +709,10 @@ HAVE_GETLINE = ${have_getline}
 # build its own version)
 HAVE_STRCASESTR = ${have_strcasestr}
 
+# Whether the strsep function is available (if not, then notmuch will
+# build its own version)
+HAVE_STRSEP = ${have_strsep}
+
 # Whether the getpwuid_r function is standards-compliant
 # (if not, then notmuch will #define _POSIX_PTHREAD_SEMANTICS
 # to enable the standards-compliant version -- needed for Solaris)
@@ -754,12 +769,14 @@ CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)      \\
 		   \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND)   \\
 		   \$(VALGRIND_CFLAGS)                                   \\
 		   -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)                 \\
+		   -DHAVE_STRSEP=\$(HAVE_STRSEP)                         \\
 		   -DSTD_GETPWUID=\$(STD_GETPWUID)                       \\
 		   -DSTD_ASCTIME=\$(STD_ASCTIME)
 CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)    \\
 		     \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
 		     \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS)             \\
 		     -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)               \\
+		     -DHAVE_STRSEP=\$(HAVE_STRSEP)                       \\
 		     -DSTD_GETPWUID=\$(STD_GETPWUID)                     \\
 		     -DSTD_ASCTIME=\$(STD_ASCTIME)
 CONFIGURE_LDFLAGS =  \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS)
-- 
1.7.9.2

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

* [PATCH 4/4] timegm: add portable implementation (Solaris support)
  2013-05-06 15:15 Solaris support - missing or incompatible functions Vladimir.Marek
                   ` (2 preceding siblings ...)
  2013-05-06 15:16 ` [PATCH 3/4] strsep: check for availability " Vladimir.Marek
@ 2013-05-06 15:16 ` Vladimir.Marek
  2013-05-12 20:02 ` Solaris support - missing or incompatible functions Jani Nikula
  4 siblings, 0 replies; 16+ messages in thread
From: Vladimir.Marek @ 2013-05-06 15:16 UTC (permalink / raw)
  To: notmuch; +Cc: Vladimir Marek

From: Blake Jones <blakej@foo.net>

The timegm(3) function is a non-standard extension to libc which is
available in GNU libc and on some BSDs.  Although SunOS had this
function in its libc, Solaris (unfortunately) removed it.  This patch
implements a very simple version of timegm() which is good enough for
parse-time-string.c.

Signed-off-by: Vladimir Marek <vlmarek@volny.cz>
---
 compat/Makefile.local                 |    4 ++++
 compat/compat.h                       |    5 +++++
 compat/have_timegm.c                  |    7 +++++++
 compat/timegm.c                       |   37 +++++++++++++++++++++++++++++++++
 configure                             |   11 ++++++++++
 parse-time-string/parse-time-string.c |    1 +
 6 files changed, 65 insertions(+)
 create mode 100644 compat/have_timegm.c
 create mode 100644 compat/timegm.c

diff --git a/compat/Makefile.local b/compat/Makefile.local
index 2c4f65f..b0d5417 100644
--- a/compat/Makefile.local
+++ b/compat/Makefile.local
@@ -17,4 +17,8 @@ ifneq ($(HAVE_STRSEP),1)
 notmuch_compat_srcs += $(dir)/strsep.c
 endif
 
+ifneq ($(HAVE_TIMEGM),1)
+notmuch_compat_srcs += $(dir)/timegm.c
+endif
+
 SRCS := $(SRCS) $(notmuch_compat_srcs)
diff --git a/compat/compat.h b/compat/compat.h
index ae762c3..5a402d5 100644
--- a/compat/compat.h
+++ b/compat/compat.h
@@ -57,6 +57,11 @@ char* strcasestr(const char *haystack, const char *needle);
 char *strsep(char **stringp, const char *delim);
 #endif /* !HAVE_STRSEP */
 
+#if !HAVE_TIMEGM
+#include <time.h>
+time_t timegm (struct tm *tm);
+#endif /* !HAVE_TIMEGM */
+
 /* Silence gcc warnings about unused results.  These warnings exist
  * for a reason; any use of this needs to be justified. */
 #ifdef __GNUC__
diff --git a/compat/have_timegm.c b/compat/have_timegm.c
new file mode 100644
index 0000000..b62b793
--- /dev/null
+++ b/compat/have_timegm.c
@@ -0,0 +1,7 @@
+#include <time.h>
+#include "compat.h"
+
+int main()
+{
+    return (int) timegm((struct tm *)0);
+}
diff --git a/compat/timegm.c b/compat/timegm.c
new file mode 100644
index 0000000..6d76164
--- /dev/null
+++ b/compat/timegm.c
@@ -0,0 +1,37 @@
+#include <time.h>
+#include "compat.h"
+
+static int
+leapyear (int year)
+{
+    return ((year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0));
+}
+
+/*
+ * This is a simple implementation of timegm() which does what is needed
+ * by create_output() -- just turns the "struct tm" into a GMT time_t.
+ * It does not normalize any of the fields of the "struct tm", nor does
+ * it set tm_wday or tm_yday.
+ */
+time_t
+timegm (struct tm *tm)
+{
+    int	monthlen[2][12] = {
+	{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
+	{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
+    };
+    int	year, month, days;
+
+    days = 365 * (tm->tm_year - 70);
+    for (year = 70; year < tm->tm_year; year++) {
+	if (leapyear(1900 + year)) {
+	    days++;
+	}
+    }
+    for (month = 0; month < tm->tm_mon; month++) {
+	days += monthlen[leapyear(1900 + year)][month];
+    }
+    days += tm->tm_mday - 1;
+
+    return ((((days * 24) + tm->tm_hour) * 60 + tm->tm_min) * 60 + tm->tm_sec);
+}
diff --git a/configure b/configure
index 5243cac..ee037d8 100755
--- a/configure
+++ b/configure
@@ -528,6 +528,17 @@ else
 fi
 rm -f compat/have_strsep
 
+printf "Checking for timegm... "
+if ${CC} -o compat/have_timegm "$srcdir"/compat/have_timegm.c > /dev/null 2>&1
+then
+    printf "Yes.\n"
+    have_timegm="1"
+else
+    printf "No (will use our own instead).\n"
+    have_timegm="0"
+fi
+rm -f compat/have_timegm
+
 printf "Checking for standard version of getpwuid_r... "
 if ${CC} -o compat/check_getpwuid "$srcdir"/compat/check_getpwuid.c > /dev/null 2>&1
 then
diff --git a/parse-time-string/parse-time-string.c b/parse-time-string/parse-time-string.c
index 584067d..ccad422 100644
--- a/parse-time-string/parse-time-string.c
+++ b/parse-time-string/parse-time-string.c
@@ -32,6 +32,7 @@
 #include <sys/time.h>
 #include <sys/types.h>
 
+#include "compat.h"
 #include "parse-time-string.h"
 
 /*
-- 
1.7.9.2

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

* Re: Solaris support - missing or incompatible functions
  2013-05-06 15:15 Solaris support - missing or incompatible functions Vladimir.Marek
                   ` (3 preceding siblings ...)
  2013-05-06 15:16 ` [PATCH 4/4] timegm: add portable implementation " Vladimir.Marek
@ 2013-05-12 20:02 ` Jani Nikula
  2013-05-12 20:21   ` Vladimir Marek
  4 siblings, 1 reply; 16+ messages in thread
From: Jani Nikula @ 2013-05-12 20:02 UTC (permalink / raw)
  To: Vladimir.Marek, notmuch

On Mon, 06 May 2013, Vladimir.Marek@oracle.com wrote:
> I can't run the notmuch 'make test' on Solaris (too old bash) and on linux the
> results are
>
> 421/525 tests passed.
> 25 tests failed.
> 79 tests skipped.
>
> but they are the same without my changes too ...

The series LGTM, except I didn't pay much attention to the timegm()
implementation. I hope the time parsing tests pass though. If they do,
and you think the implementation is good enough, then who am I to
argue. ;)

BR,
Jani.

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

* Re: Solaris support - missing or incompatible functions
  2013-05-12 20:02 ` Solaris support - missing or incompatible functions Jani Nikula
@ 2013-05-12 20:21   ` Vladimir Marek
  2013-05-12 20:45     ` Jani Nikula
  0 siblings, 1 reply; 16+ messages in thread
From: Vladimir Marek @ 2013-05-12 20:21 UTC (permalink / raw)
  To: Jani Nikula; +Cc: notmuch

> > I can't run the notmuch 'make test' on Solaris (too old bash) and on linux the
> > results are
> >
> > 421/525 tests passed.
> > 25 tests failed.
> > 79 tests skipped.
> >
> > but they are the same without my changes too ...
> 
> The series LGTM, except I didn't pay much attention to the timegm()
> implementation. I hope the time parsing tests pass though. If they do,
> and you think the implementation is good enough, then who am I to
> argue. ;)


I didn't pay too much attention to the test output as it's broken on
linux too :)

Thank you
-- 
	Vlad

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

* Re: Solaris support - missing or incompatible functions
  2013-05-12 20:21   ` Vladimir Marek
@ 2013-05-12 20:45     ` Jani Nikula
  2013-05-13  5:05       ` Vladimir Marek
  0 siblings, 1 reply; 16+ messages in thread
From: Jani Nikula @ 2013-05-12 20:45 UTC (permalink / raw)
  To: Vladimir Marek; +Cc: notmuch

On Sun, 12 May 2013, Vladimir Marek <Vladimir.Marek@Oracle.COM> wrote:
> I didn't pay too much attention to the test output as it's broken on
> linux too :)

It shouldn't be. All tests pass for me, and we're pretty strict about
maintaining that.

There may be some prerequisites to running tests that you're missing,
and the test setup fails to tell you about. A pastebin of the 'make
test' output might be helpful.

BR,
Jani.

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

* Re: Solaris support - missing or incompatible functions
  2013-05-12 20:45     ` Jani Nikula
@ 2013-05-13  5:05       ` Vladimir Marek
  2013-05-18 13:19         ` David Bremner
  2013-08-16 12:05         ` Vladimir Marek
  0 siblings, 2 replies; 16+ messages in thread
From: Vladimir Marek @ 2013-05-13  5:05 UTC (permalink / raw)
  To: Jani Nikula; +Cc: notmuch

> > I didn't pay too much attention to the test output as it's broken on
> > linux too :)
> 
> It shouldn't be. All tests pass for me, and we're pretty strict about
> maintaining that.
> 
> There may be some prerequisites to running tests that you're missing,
> and the test setup fails to tell you about. A pastebin of the 'make
> test' output might be helpful.

Ok, in that case please let me take a look at the tests first.

-- 
	Vlad

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

* Re: Solaris support - missing or incompatible functions
  2013-05-13  5:05       ` Vladimir Marek
@ 2013-05-18 13:19         ` David Bremner
  2013-05-20  9:48           ` Vladimir Marek
  2013-08-16 12:05         ` Vladimir Marek
  1 sibling, 1 reply; 16+ messages in thread
From: David Bremner @ 2013-05-18 13:19 UTC (permalink / raw)
  To: Vladimir Marek, Jani Nikula; +Cc: notmuch

Vladimir Marek <Vladimir.Marek@Oracle.COM> writes:

>> 
>> There may be some prerequisites to running tests that you're missing,
>> and the test setup fails to tell you about. A pastebin of the 'make
>> test' output might be helpful.
>
> Ok, in that case please let me take a look at the tests first.
>

For what it's worth, I can confirm no test failures for me either on
linux (Debian wheezy).

d

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

* Re: Re: Solaris support - missing or incompatible functions
  2013-05-18 13:19         ` David Bremner
@ 2013-05-20  9:48           ` Vladimir Marek
  2013-05-20 11:10             ` Tomi Ollila
  0 siblings, 1 reply; 16+ messages in thread
From: Vladimir Marek @ 2013-05-20  9:48 UTC (permalink / raw)
  To: David Bremner; +Cc: notmuch

> >> There may be some prerequisites to running tests that you're missing,
> >> and the test setup fails to tell you about. A pastebin of the 'make
> >> test' output might be helpful.
> >
> > Ok, in that case please let me take a look at the tests first.
> >
> 
> For what it's worth, I can confirm no test failures for me either on
> linux (Debian wheezy).

Thank you for looking into that. I'm still not done with fixing the test
suite on Solaris, but form ~70 broken tests I'm at 28. Mostly it's
because Solaris is trying to be posix correct while Linux does not.

There was one surprise though:

A='12\n34'
echo $A

prints two lines on Solaris bug only one line on Linux ('\n' is not
interpreted). That breaks most of json tests as they contain '\n').

Anyway once I'm done I'll have another patch.

-- 
	Vlad

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

* Re: Re: Solaris support - missing or incompatible functions
  2013-05-20  9:48           ` Vladimir Marek
@ 2013-05-20 11:10             ` Tomi Ollila
  2013-05-20 13:19               ` Vladimir Marek
  0 siblings, 1 reply; 16+ messages in thread
From: Tomi Ollila @ 2013-05-20 11:10 UTC (permalink / raw)
  To: Vladimir Marek, David Bremner; +Cc: notmuch

On Mon, May 20 2013, Vladimir Marek <Vladimir.Marek@Oracle.COM> wrote:

>> >> There may be some prerequisites to running tests that you're missing,
>> >> and the test setup fails to tell you about. A pastebin of the 'make
>> >> test' output might be helpful.
>> >
>> > Ok, in that case please let me take a look at the tests first.
>> >
>> 
>> For what it's worth, I can confirm no test failures for me either on
>> linux (Debian wheezy).
>
> Thank you for looking into that. I'm still not done with fixing the test
> suite on Solaris, but form ~70 broken tests I'm at 28. Mostly it's
> because Solaris is trying to be posix correct while Linux does not.
>
> There was one surprise though:
>
> A='12\n34'
> echo $A
>
> prints two lines on Solaris bug only one line on Linux ('\n' is not
> interpreted). That breaks most of json tests as they contain '\n').

That must be some setting in (your?) bash:

$ sh -c 'echo '\''foo\nbar'\'''
foo
bar

$ bash -c 'echo '\''foo\nbar'\'''
foo\nbar

$ dash -c 'echo '\''foo\nbar'\'''
foo
bar

... after a bit digging ...

$ bash -c 'shopt -s xpg_echo; echo '\''foo\nbar'\'''
foo
bar

$ bash -c 'shopt -u xpg_echo; echo '\''foo\nbar'\'''
foo\nbar


you could try adding  shopt -u xpg_echo  into test-lib.sh

Tomi

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

* Re: Re: Re: Solaris support - missing or incompatible functions
  2013-05-20 11:10             ` Tomi Ollila
@ 2013-05-20 13:19               ` Vladimir Marek
  0 siblings, 0 replies; 16+ messages in thread
From: Vladimir Marek @ 2013-05-20 13:19 UTC (permalink / raw)
  To: Tomi Ollila; +Cc: notmuch

[...]

> That must be some setting in (your?) bash:
> 
> $ sh -c 'echo '\''foo\nbar'\'''
> foo
> bar
> 
> $ bash -c 'echo '\''foo\nbar'\'''
> foo\nbar
> 
> $ dash -c 'echo '\''foo\nbar'\'''
> foo
> bar
> 
> ... after a bit digging ...
> 
> $ bash -c 'shopt -s xpg_echo; echo '\''foo\nbar'\'''
> foo
> bar
> 
> $ bash -c 'shopt -u xpg_echo; echo '\''foo\nbar'\'''
> foo\nbar
> 
> you could try adding  shopt -u xpg_echo  into test-lib.sh


Nice, that's the one! By quickly looking around Solaris it seems that
it's the default compiled in.

Thank you
-- 
	Vlad

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

* Re: Re: Solaris support - missing or incompatible functions
  2013-05-13  5:05       ` Vladimir Marek
  2013-05-18 13:19         ` David Bremner
@ 2013-08-16 12:05         ` Vladimir Marek
  2013-08-16 12:32           ` Tomi Ollila
  1 sibling, 1 reply; 16+ messages in thread
From: Vladimir Marek @ 2013-08-16 12:05 UTC (permalink / raw)
  To: Jani Nikula; +Cc: notmuch

Hi,

> > > I didn't pay too much attention to the test output as it's broken on
> > > linux too :)
> > 
> > It shouldn't be. All tests pass for me, and we're pretty strict about
> > maintaining that.
> > 
> > There may be some prerequisites to running tests that you're missing,
> > and the test setup fails to tell you about. A pastebin of the 'make
> > test' output might be helpful.
> 
> Ok, in that case please let me take a look at the tests first.

I'm sorry it took me so long, but finally I got as far as possible with
tests. At the moment the status is

Notmuch test suite complete.
548/557 tests passed.
9 tests failed.

1 test fails because there are new exported symbols in notmuch binary
2 test fails because I don't have gpg
6 test fails because my emacs somehow refuses to send email

With that I would like to ask for including the patches into notmuch
tree. Should I rebase them to the latest git tree or can you push them
as they are?

Thank you
-- 
	Vlad

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

* Re: Re: Solaris support - missing or incompatible functions
  2013-08-16 12:05         ` Vladimir Marek
@ 2013-08-16 12:32           ` Tomi Ollila
  0 siblings, 0 replies; 16+ messages in thread
From: Tomi Ollila @ 2013-08-16 12:32 UTC (permalink / raw)
  To: Vladimir Marek; +Cc: notmuch

On Fri, Aug 16 2013, Vladimir Marek <Vladimir.Marek@Oracle.COM> wrote:

> Hi,
>
>> > > I didn't pay too much attention to the test output as it's broken on
>> > > linux too :)
>> > 
>> > It shouldn't be. All tests pass for me, and we're pretty strict about
>> > maintaining that.
>> > 
>> > There may be some prerequisites to running tests that you're missing,
>> > and the test setup fails to tell you about. A pastebin of the 'make
>> > test' output might be helpful.
>> 
>> Ok, in that case please let me take a look at the tests first.
>
> I'm sorry it took me so long, but finally I got as far as possible with
> tests. At the moment the status is
>
> Notmuch test suite complete.
> 548/557 tests passed.
> 9 tests failed.
>
> 1 test fails because there are new exported symbols in notmuch binary
> 2 test fails because I don't have gpg
> 6 test fails because my emacs somehow refuses to send email
>
> With that I would like to ask for including the patches into notmuch
> tree. Should I rebase them to the latest git tree or can you push them
> as they are?

Rebase to current tree so we (I) can test those. If those apply 
on top of master i run tests and start reviewing those...

>
> Thank you
> -- 
> 	Vlad

Tomi


> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

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

* [PATCH 1/4] getpwuid: check for standards compliance (Solaris support)
  2013-08-16 14:38 Solaris support - missing or incompatible functions (v2) Vladimir.Marek
@ 2013-08-16 14:38 ` Vladimir.Marek
  0 siblings, 0 replies; 16+ messages in thread
From: Vladimir.Marek @ 2013-08-16 14:38 UTC (permalink / raw)
  To: notmuch; +Cc: Vladimir Marek

From: Blake Jones <blakej@foo.net>

Add checks to "configure" to see whether _POSIX_PTHREAD_SEMANTICS needs
to be defined to get the right number of arguments in the prototypes for
getpwuid_r().  Solaris' default implementation conforms to POSIX.1c
Draft 6, rather than the final POSIX.1c spec.  The standards-compliant
version can be used by defining _POSIX_PTHREAD_SEMANTICS.

This change also adds the file "compat/check_getpwuid.c", which
configure uses to perform its check, and modifies compat/compat.h to
define _POSIX_PTHREAD_SEMANTICS if configure detected it was needed.

Signed-off-by: Vladimir Marek <vlmarek@volny.cz>
---
 compat/check_getpwuid.c |   11 +++++++++++
 compat/compat.h         |    4 ++++
 configure               |   23 +++++++++++++++++++++--
 3 files changed, 36 insertions(+), 2 deletions(-)
 create mode 100644 compat/check_getpwuid.c

diff --git a/compat/check_getpwuid.c b/compat/check_getpwuid.c
new file mode 100644
index 0000000..c435eb8
--- /dev/null
+++ b/compat/check_getpwuid.c
@@ -0,0 +1,11 @@
+#include <stdio.h>
+#include <pwd.h>
+
+int main()
+{
+    struct passwd passwd, *ignored;
+
+    (void) getpwuid_r (0, &passwd, NULL, 0, &ignored);
+
+    return (0);
+}
diff --git a/compat/compat.h b/compat/compat.h
index b2e2736..c1ee0f9 100644
--- a/compat/compat.h
+++ b/compat/compat.h
@@ -30,6 +30,10 @@
 extern "C" {
 #endif
 
+#if !STD_GETPWUID
+#define _POSIX_PTHREAD_SEMANTICS 1
+#endif
+
 #if !HAVE_GETLINE
 #include <stdio.h>
 #include <unistd.h>
diff --git a/configure b/configure
index 3ba1ec3..b5465e4 100755
--- a/configure
+++ b/configure
@@ -519,6 +519,17 @@ else
 fi
 rm -f compat/have_strcasestr
 
+printf "Checking for standard version of getpwuid_r... "
+if ${CC} -o compat/check_getpwuid "$srcdir"/compat/check_getpwuid.c > /dev/null 2>&1
+then
+    printf "Yes.\n"
+    std_getpwuid=1
+else
+    printf "No (will define _POSIX_PTHREAD_SEMANTICS to get it).\n"
+    std_getpwuid=0
+fi
+rm -f compat/check_getpwuid
+
 printf "int main(void){return 0;}\n" > minimal.c
 
 printf "Checking for rpath support... "
@@ -681,6 +692,11 @@ HAVE_GETLINE = ${have_getline}
 # build its own version)
 HAVE_STRCASESTR = ${have_strcasestr}
 
+# Whether the getpwuid_r function is standards-compliant
+# (if not, then notmuch will #define _POSIX_PTHREAD_SEMANTICS
+# to enable the standards-compliant version -- needed for Solaris)
+STD_GETPWUID = ${std_getpwuid}
+
 # Supported platforms (so far) are: LINUX, MACOSX, SOLARIS, FREEBSD, OPENBSD
 PLATFORM = ${platform}
 
@@ -725,10 +741,13 @@ WITH_ZSH = ${WITH_ZSH}
 # Combined flags for compiling and linking against all of the above
 CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)      \\
 		   \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND)   \\
-		   \$(VALGRIND_CFLAGS) -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)
+		   \$(VALGRIND_CFLAGS)                                   \\
+		   -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)                 \\
+		   -DSTD_GETPWUID=\$(STD_GETPWUID)
 CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)    \\
 		     \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
 		     \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS)             \\
-                     -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)
+		     -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)               \\
+		     -DSTD_GETPWUID=\$(STD_GETPWUID)
 CONFIGURE_LDFLAGS =  \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS)
 EOF
-- 
1.7.9.2

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

end of thread, other threads:[~2013-08-16 14:38 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-06 15:15 Solaris support - missing or incompatible functions Vladimir.Marek
2013-05-06 15:15 ` [PATCH 1/4] getpwuid: check for standards compliance (Solaris support) Vladimir.Marek
2013-05-06 15:16 ` [PATCH 2/4] asctime: " Vladimir.Marek
2013-05-06 15:16 ` [PATCH 3/4] strsep: check for availability " Vladimir.Marek
2013-05-06 15:16 ` [PATCH 4/4] timegm: add portable implementation " Vladimir.Marek
2013-05-12 20:02 ` Solaris support - missing or incompatible functions Jani Nikula
2013-05-12 20:21   ` Vladimir Marek
2013-05-12 20:45     ` Jani Nikula
2013-05-13  5:05       ` Vladimir Marek
2013-05-18 13:19         ` David Bremner
2013-05-20  9:48           ` Vladimir Marek
2013-05-20 11:10             ` Tomi Ollila
2013-05-20 13:19               ` Vladimir Marek
2013-08-16 12:05         ` Vladimir Marek
2013-08-16 12:32           ` Tomi Ollila
  -- strict thread matches above, loose matches on Subject: below --
2013-08-16 14:38 Solaris support - missing or incompatible functions (v2) Vladimir.Marek
2013-08-16 14:38 ` [PATCH 1/4] getpwuid: check for standards compliance (Solaris support) Vladimir.Marek

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