Re: Build errors on Solaris 2.6 & 7

2013-01-20 Thread Tom G. Christensen

On 01/20/2013 04:14 AM, Paul Eggert wrote:

How about the following patch instead?  It relies on
including  if and only if
!defined __XOPEN_OR_POSIX || defined __EXTENSIONS__.
This last expression is something I picked up on Solaris 10,
and I'm hoping it's also good for Solaris 2.6.


It is close though on Solaris < 10 it looks like this in :
#if defined(__EXTENSIONS__) || \
(!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE))


Unfortunately this patch causes a different problem.
While it actually allowed dtotimespec.c to build on Solaris 2.6 most 
everything else now fails with this error:


depbase=`echo accept4.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc -std=gnu99 -DHAVE_CONFIG_H -DEXEEXT=\"\" -DEXEEXT=\"\" 
-DNO_XMALLOC -DEXEEXT=\"\" -I. -I..  -DGNULIB_STRICT_CHECKING=
1 -I../intl -I/usr/tgcware/include -D_REENTRANT  -g -O2 -MT accept4.o 
-MD -MP -MF $depbase.Tpo -c -o accept4.o accept4.c &&\

mv -f $depbase.Tpo $depbase.Po
In file included from /usr/include/sys/time.h:405,
 from ./sys/time.h:38,
 from /usr/include/sys/select.h:16,
 from ./sys/select.h:33,
 from 
/usr/tgcware/gcc-4.3.6/lib/gcc/sparc-sun-solaris2.6/4.3.6/include-fixed/sys/types.h:431,

 from ./sys/types.h:27,
 from ./sys/socket.h:51,
 from accept4.c:20:
./sys/select.h:551: error: expected declaration specifiers or '...' 
before 'fd_set'
./sys/select.h:551: error: expected declaration specifiers or '...' 
before 'fd_set'
./sys/select.h:551: error: expected declaration specifiers or '...' 
before 'fd_set'


The same happens on Solaris 7 and 9 (8 not tested).

The problem now is that struct fd_set is not defined since gnulib 
 is parsed before system .


Preprocessed copies of accept4.c here:
http://jupiterrise.com/tmp/sol26-accept4.i
http://jupiterrise.com/tmp/sol9-accept4.i

-tgc



[PATCH] bootstrap: remove the need for a sorted .gitignore

2013-01-20 Thread Bernhard Voelker
During bootstrap, files may be created which are already included
in .gitignore, but the test to add such a file relied on the
sort order.  Now, it just adds such a new entry and thus only
changes the file if the line count would change.

* bootstrap (insert_if_absent): Instead of comparing the
sorted new file with the original, the function compares the line
count, and only in case of a difference, the given file is changed.
Also ensure that the given ignore file does not already include
duplicate entries, as otherwise, the entry count would be innacurate.
(sort_patterns): Remove this now redundant function.
(gitignore_entries): A new function to return significant entries
from .gitignore.

Improved-by: Pádraig Brady
---
 ChangeLog   |   11 +++
 build-aux/bootstrap |   45 +++--
 2 files changed, 34 insertions(+), 22 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8218eb3..311abce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2013-01-20  Bernhard Voelker  
+
+   bootstrap: remove the need for a sorted .gitignore file
+   * build-aux/bootstrap (insert_sorted_if_absent): Adjust and
+   rename to insert_if_absent(), so that we don't need or generate
+   a sorted .gitignore file.  We do require a .gitignore with no
+   existing duplicate entries and enforce that.
+   (sort_patterns): Remove this function as we now use the simpler
+   technigue of inserting blacklist entries at the top of the file,
+   assuming gnulib won't be inserting !whitelist entries.
+
 2013-01-16  Paul Eggert  
 
unistd: port to recent mingw
diff --git a/build-aux/bootstrap b/build-aux/bootstrap
index 012907a..888145a 100755
--- a/build-aux/bootstrap
+++ b/build-aux/bootstrap
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Print a version string.
-scriptversion=2012-12-28.10; # UTC
+scriptversion=2013-01-20.16; # UTC
 
 # Bootstrap this package from checked-out sources.
 
@@ -306,34 +306,34 @@ if test -n "$checkout_only_file" && test ! -r 
"$checkout_only_file"; then
   die "Bootstrapping from a non-checked-out distribution is risky."
 fi
 
-# Ensure that lines starting with ! sort last, per gitignore conventions
-# for whitelisting exceptions after a more generic blacklist pattern.
-sort_patterns() {
-  sort -u "$@" | sed '/^!/ {
-H
-d
-  }
-  $ {
-P
-x
-s/^\n//
-  }' | sed '/^$/d'
+# Strip blank and comment lines to leave significant entries.
+gitignore_entries() {
+  sed '/^#/d; /^$/d' "$@"
 }
 
-# If $STR is not already on a line by itself in $FILE, insert it,
-# sorting the new contents of the file and replacing $FILE with the result.
-insert_sorted_if_absent() {
+# If $STR is not already on a line by itself in $FILE, insert it at the start.
+# Entries are inserted at the start of the ignore list to ensure existing
+# entries starting with ! are not overridden.  Such entries support
+# whitelisting exceptions after a more generic blacklist pattern.
+insert_if_absent() {
   file=$1
   str=$2
   test -f $file || touch $file
-  echo "$str" | sort_patterns - $file | cmp -s - $file > /dev/null \
-|| { echo "$str" | sort_patterns - $file > $file.bak \
-  && mv $file.bak $file; } \
-|| die "insert_sorted_if_absent $file $str: failed"
+  test -r $file || die "Error: failed to read ignore file: $file"
+  duplicate_entries=$(gitignore_entries $file | sort | uniq -d)
+  if [ "$duplicate_entries" ] ; then
+die "Error: Duplicate entries in $file: " $duplicate_entries
+  fi
+  linesold=$(gitignore_entries $file | wc -l)
+  linesnew=$(echo "$str" | gitignore_entries - $file | sort -u | wc -l)
+  if [ $linesold != $linesnew ] ; then
+{ echo "$str" | cat - $file > $file.bak && mv $file.bak $file; } \
+  || die "insert_if_absent $file $str: failed"
+  fi
 }
 
 # Adjust $PATTERN for $VC_IGNORE_FILE and insert it with
-# insert_sorted_if_absent.
+# insert_if_absent.
 insert_vc_ignore() {
   vc_ignore_file="$1"
   pattern="$2"
@@ -344,7 +344,7 @@ insert_vc_ignore() {
 # .gitignore entry.
 pattern=$(echo "$pattern" | sed s,^,/,);;
   esac
-  insert_sorted_if_absent "$vc_ignore_file" "$pattern"
+  insert_if_absent "$vc_ignore_file" "$pattern"
 }
 
 # Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
@@ -356,6 +356,7 @@ grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' 
configure.ac \
 test $found_aux_dir = yes \
   || die "configure.ac lacks 'AC_CONFIG_AUX_DIR([$build_aux])'; add it"
 
+
 # If $build_aux doesn't exist, create it now, otherwise some bits
 # below will malfunction.  If creating it, also mark it as ignored.
 if test ! -d $build_aux; then
-- 
1.7.6.4




Re: sigaction test failure on FreeBSD 9.1 when pthread is used

2013-01-20 Thread Daiki Ueno
Paul Eggert  writes:

> On 01/17/13 23:04, Daiki Ueno wrote:
>> It seems -fopenmp flag causes the error.  It can also be reproduced
>> without openmp, but with CFLAGS="-O2 -pthread".
>
> I can't reproduce it with Fedora 17, but I guess that's not
> too surprising.

Yes.

> Can you send the output of this shell command?
>
> truss ./test-sigaction

Here it is:

mmap(0x0,32768,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34366128128 
(0x800618000)
issetugid(0x800817f80,0x7fffefa4,0x40,0x0,0x800800818fdc,0x0) = 0 (0x0)
lstat("/etc",{ mode=drwxr-xr-x ,inode=481536,size=2048,blksize=32768 }) = 0 
(0x0)
lstat("/etc/libmap.conf",0x7fffc610) ERR#2 'No such file or 
directory'
open("/var/run/ld-elf.so.hints",O_RDONLY,057)= 3 (0x3)
read(3,"Ehnt\^A\0\0\0\M^@\0\0\0-\0\0\0\0"...,128) = 128 (0x80)
lseek(3,0x80,SEEK_SET)   = 128 (0x80)
read(3,"/lib:/usr/lib:/usr/lib/compat:/u"...,45) = 45 (0x2d)
close(3) = 0 (0x0)
access("/lib/libgomp.so.1",0)ERR#2 'No such file or 
directory'
access("/usr/lib/libgomp.so.1",0)= 0 (0x0)
open("/usr/lib/libgomp.so.1",O_RDONLY,040305300) = 3 (0x3)
fstat(3,{ mode=-r--r--r-- ,inode=1693510,size=31248,blksize=32768 }) = 0 (0x0)
mmap(0x0,4096,PROT_READ,MAP_PRIVATE|0x4,3,0x0) = 34366160896 (0x80062)
mmap(0x0,2125824,PROT_NONE,MAP_PRIVATE|MAP_ANON|MAP_NOCORE,-1,0x0) = 
34368229376 (0x800819000)
mmap(0x800819000,28672,PROT_READ|PROT_EXEC,MAP_PRIVATE|MAP_FIXED|MAP_NOCORE|0x4,3,0x0)
 = 34368229376 (0x800819000)
mmap(0x800a1f000,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED|0x4,3,0x6000)
 = 34370351104 (0x800a1f000)
munmap(0x80062,4096) = 0 (0x0)
close(3) = 0 (0x0)
access("/lib/libthr.so.3",0) = 0 (0x0)
open("/lib/libthr.so.3",O_RDONLY,040305300)  = 3 (0x3)
fstat(3,{ mode=-r--r--r-- ,inode=1364383,size=101048,blksize=32768 }) = 0 (0x0)
mmap(0x0,4096,PROT_READ,MAP_PRIVATE|0x4,3,0x0) = 34366160896 (0x80062)
mmap(0x0,2236416,PROT_NONE,MAP_PRIVATE|MAP_ANON|MAP_NOCORE,-1,0x0) = 
34370355200 (0x800a2)
mmap(0x800a2,94208,PROT_READ|PROT_EXEC,MAP_PRIVATE|MAP_FIXED|MAP_NOCORE|0x4,3,0x0)
 = 34370355200 (0x800a2)
mmap(0x800c36000,8192,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED|0x4,3,0x16000)
 = 34372542464 (0x800c36000)
mmap(0x800c38000,40960,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED|MAP_ANON,-1,0x0)
 = 34372550656 (0x800c38000)
munmap(0x80062,4096) = 0 (0x0)
close(3) = 0 (0x0)
access("/lib/libc.so.7",0)   = 0 (0x0)
open("/lib/libc.so.7",O_RDONLY,040305300)= 3 (0x3)
fstat(3,{ mode=-r--r--r-- ,inode=1364354,size=1369520,blksize=32768 }) = 0 (0x0)
mmap(0x0,4096,PROT_READ,MAP_PRIVATE|0x4,3,0x0) = 34366160896 (0x80062)
mmap(0x0,3485696,PROT_NONE,MAP_PRIVATE|MAP_ANON|MAP_NOCORE,-1,0x0) = 
34372591616 (0x800c42000)
mmap(0x800c42000,1236992,PROT_READ|PROT_EXEC,MAP_PRIVATE|MAP_FIXED|MAP_NOCORE|0x4,3,0x0)
 = 34372591616 (0x800c42000)
mmap(0x800f6f000,45056,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED|0x4,3,0x12d000)
 = 34375921664 (0x800f6f000)
mmap(0x800f7a000,110592,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED|MAP_ANON,-1,0x0)
 = 34375966720 (0x800f7a000)
munmap(0x80062,4096) = 0 (0x0)
close(3) = 0 (0x0)
munmap(0x80061f000,4096) = 0 (0x0)
mmap(0x0,40960,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34366156800 
(0x80061f000)
munmap(0x800622000,28672)= 0 (0x0)
mmap(0x0,102400,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34366169088 
(0x800622000)
sysarch(0x81,0x7fffd380,0x80061d1c8,0x0,0xff6c4e70,0x8080808080808080)
 = 0 (0x0)
sigprocmask(SIG_BLOCK,SIGHUP|SIGINT|SIGQUIT|SIGKILL|SIGPIPE|SIGALRM|SIGTERM|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXFSZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIGUSR1|SIGUSR2,0x0)
 = 0 (0x0)
sigprocmask(SIG_SETMASK,0x0,0x0) = 0 (0x0)
sigprocmask(SIG_BLOCK,SIGHUP|SIGINT|SIGQUIT|SIGKILL|SIGPIPE|SIGALRM|SIGTERM|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXFSZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIGUSR1|SIGUSR2,0x0)
 = 0 (0x0)
sigprocmask(SIG_SETMASK,0x0,0x0) = 0 (0x0)
getpid() = 849 (0x351)
__sysctl(0x7fffd2e0,0x2,0x800c41f80,0x7fffd2e8,0x0,0x0) = 0 (0x0)
__sysctl(0x7fffd210,0x2,0x7fffd240,0x7fffd2a8,0x800a33a30,0xd) = 0 
(0x0)
__sysctl(0x7fffd240,0x3,0x800c40e68,0x7fffd2e8,0x0,0x0) = 0 (0x0)
readlink("/etc/malloc.conf",0x7fffcde0,1024) ERR#2 'No such file or 
directory'
issetugid(0x800d49659,0x7fffcde0,0x,0x0,0x2,0x0) = 0 (0x0)
break(0x600da0)  = 0 (0x0)
break(0x80)   

Re: sigaction test failure on FreeBSD 9.1 when pthread is used

2013-01-20 Thread Paul Eggert
Thanks for looking into it.  From the trace, my guess
is that FreeBSD always reports that SA_SIGINFO is set
because FreeBSD always passes the relevant info to signal handlers
(at the low level, this doesn't cause problems so it's OK).
Always reporting SA_SIGINFO violates POSIX but I doubt whether
anybody really cares, so does the following patch fix things for you?
It simply adjusts the test so that it doesn't check for this bug.

diff --git a/tests/test-sigaction.c b/tests/test-sigaction.c
index 2b5ba53..ab32419 100644
--- a/tests/test-sigaction.c
+++ b/tests/test-sigaction.c
@@ -66,7 +66,6 @@ handler (int sig)
   struct sigaction sa;
   ASSERT (sig == SIGABRT);
   ASSERT (sigaction (SIGABRT, NULL, &sa) == 0);
-  ASSERT ((sa.sa_flags & SA_SIGINFO) == 0);
   switch (entry_count++)
 {
 case 0:
@@ -106,7 +105,6 @@ main (void)
 
   sa.sa_handler = SIG_DFL;
   ASSERT (sigaction (SIGABRT, &sa, &old_sa) == 0);
-  ASSERT ((old_sa.sa_flags & SA_SIGINFO) == 0);
 #if !(defined __GLIBC__ || defined __UCLIBC__) /* see above */
   ASSERT (old_sa.sa_handler == SIG_DFL);
 #endif



Re: Build errors on Solaris 2.6 & 7

2013-01-20 Thread Paul Eggert
Oh, my.  I guess it's time to try a more-drastic fix.
Does the following work for you?

---
 ChangeLog   | 16 +
 lib/sys_select.in.h | 96 +++--
 2 files changed, 43 insertions(+), 69 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8218eb3..be59d41 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2013-01-20  Paul Eggert  
+
+   sys_select: port to Solaris 2.6
+   * lib/sys_select.in.h: Redo to resemble sys_time.in.h, which
+   delegates to the system's header when being invoked recursively,
+   and doesn't have split double-inclusion guards.  This breaks
+   a circularity problem on Solaris 2.6, where  includes
+for struct timespec.  The include nesting is gnulib
+   , system , gnulib , system
+   , gnulib , system , gnulib
+   , gnulib , system , system
+   ; the last, innermost file needs struct
+   timestruc_t, which is defined in , which has not been
+   fully parsed.  Problem reported by Tom G. Christensen in
+   .
+
 2013-01-16  Paul Eggert  
 
unistd: port to recent mingw
diff --git a/lib/sys_select.in.h b/lib/sys_select.in.h
index b48c1bb..9ee52ad 100644
--- a/lib/sys_select.in.h
+++ b/lib/sys_select.in.h
@@ -19,91 +19,44 @@
 # endif
 @PRAGMA_COLUMNS@
 
-/* On OSF/1,  and  include .
-   Simply delegate to the system's header in this case.  */
-#if @HAVE_SYS_SELECT_H@ && defined __osf__ && (defined _SYS_TYPES_H_ && 
!defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H) && defined _OSF_SOURCE
+#ifdef _@GUARD_PREFIX@_SYS_SELECT_H
 
-# define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H
-# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
-
-#elif @HAVE_SYS_SELECT_H@ && defined __osf__ && (defined _SYS_TIME_H_ && 
!defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H) && defined _OSF_SOURCE
-
-# define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H
-# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
-
-/* On IRIX 6.5,  includes , which includes
-   , which includes .  At this point we cannot
-   include , because that includes , which
-   gives a syntax error because  has not been completely
-   processed.  Simply delegate to the system's header in this case.  */
-#elif @HAVE_SYS_SELECT_H@ && defined __sgi && (defined _SYS_BSD_TYPES_H && 
!defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_BSD_TYPES_H)
-
-# define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_BSD_TYPES_H
-# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
-
-/* On OpenBSD 5.0,  includes , which includes
-   .  At this point we cannot include , because that
-   includes gnulib's pthread.h override, which gives a syntax error because
-   /usr/include/pthread.h has not been completely processed.  Simply delegate
-   to the system's header in this case.  */
-#elif @HAVE_SYS_SELECT_H@ && defined __OpenBSD__ && (defined _PTHREAD_H_ && 
!defined PTHREAD_MUTEX_INITIALIZER)
-
-# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
+/* Simply delegate to the system's header, without adding anything.  */
+# if @HAVE_SYS_SELECT_H@
+#  @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
+# endif
 
 #else
 
-#ifndef _@GUARD_PREFIX@_SYS_SELECT_H
+#define _@GUARD_PREFIX@_SYS_SELECT_H
 
 /* On many platforms,  assumes prior inclusion of
.  Also, mingw defines sigset_t there, instead of
in  where it belongs.  */
 #include 
 
-#if @HAVE_SYS_SELECT_H@
+/* Get the 'struct timeval' and 'fd_set' types and the FD_* macros
+   on many platforms.  But avoid namespace pollution on glibc systems.  */
+#ifndef __GLIBC__
 
 /* On OSF/1 4.0,  provides only a forward declaration
of 'struct timeval', and no definition of this type.
-   Also, Mac OS X, AIX, HP-UX, IRIX, Solaris, Interix declare select()
-   in .
-   But avoid namespace pollution on glibc systems.  */
-# ifndef __GLIBC__
-#  include 
-# endif
-
-/* On AIX 7 and Solaris 10,  provides an FD_ZERO implementation
-   that relies on memset(), but without including .
-   But in any case avoid namespace pollution on glibc systems.  */
-# if (defined __OpenBSD__ || defined _AIX || defined __sun || defined __osf__ 
|| defined __BEOS__) \
- && ! defined __GLIBC__
-#  include 
-# endif
-
-/* The include_next requires a split double-inclusion guard.  */
-# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
+   Also, Mac OS X, AIX, HP-UX, IRIX, Solaris, Interix declare select
+   in .  */
+# include 
 
+/* On AIX 7 and Solaris 10, 's FD_ZERO
+   implementation relies on memset, but without including .
+   HP-UX 11 has a similar problem with 's FD_ZERO.  */
+# include 
 #endif
 
-/* Get definition of 'sigset_t'.
-   But avoid namespace pollution on glibc systems.
-   Do this after the include_next (for the sake of OpenBSD 5.0) but before
-   the split double-inclusion guard (for the sake of Solaris).  */
-#if !(defined __GLIBC__ && !defined __UCLIBC__)
-# include 
-#endif
+#if @HAVE_SYS_SELECT_H@
 
-#ifndef _@GUARD_PREFIX@_SYS_SELECT_H
-#define _@GUARD_PREFIX@_SYS_SELECT_H
+# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
+
+#els