guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, master, updated. release_1-9-13-176-g3


From: Ludovic Courtès
Subject: [Guile-commits] GNU Guile branch, master, updated. release_1-9-13-176-g3df539b
Date: Tue, 07 Dec 2010 22:27:29 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=3df539b1a5535009d8522b997e2542496cfb06fb

The branch, master has been updated
       via  3df539b1a5535009d8522b997e2542496cfb06fb (commit)
       via  51fc066ae25a0e1aa272a2eba9ecd7b42dc9ea41 (commit)
       via  f0c0141fe4bd478edc8205b1eae793f0474d4aa3 (commit)
       via  3ae78cac88d38b9ab913ee0100b00ad1151db306 (commit)
       via  99dbafd66ace1b3c66b3e0f963411377627a62f8 (commit)
       via  0f00f2c33a85842a9611ed63f07e915ea9fd60de (commit)
       via  cb26e97a88e90d04e6d4efe3de0de92dea53d1e5 (commit)
       via  a94469c651ae096b84c9b6389b8278113da00100 (commit)
      from  c6920dc8bae4546ffeb250570d7abc8ace9ce91c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 3df539b1a5535009d8522b997e2542496cfb06fb
Author: Andreas Rottmann <address@hidden>
Date:   Tue Dec 7 23:13:55 2010 +0100

    Get rid of `define-macro' in the SRFI 26 implementation
    
    * module/srfi/srfi-26.scm (cut, cute): Implement using `syntax-case'.
      The new implementation is mostly just a transcription of the old code;
      the reference implementation which relies only on `syntax-rules' may
      (or may not) be considered more elegant :-).
    
    Signed-off-by: Ludovic Courtès <address@hidden>

commit 51fc066ae25a0e1aa272a2eba9ecd7b42dc9ea41
Author: Ludovic Courtès <address@hidden>
Date:   Tue Dec 7 23:11:53 2010 +0100

    Use `current-processor-count' to determine the number of future-workers.
    
    * module/ice-9/futures.scm (%worker-count): Use
      `current-processor-count'.
    
    * doc/ref/api-scheduling.texi (Futures): Add note about side-effects and
      I/O.  Mention `current-processor-count'.

commit f0c0141fe4bd478edc8205b1eae793f0474d4aa3
Author: Ludovic Courtès <address@hidden>
Date:   Tue Dec 7 23:10:41 2010 +0100

    Add `total-processor-count' and `current-processor-count'.
    
    * libguile/posix.c (scm_total_processor_count,
      scm_current_processor_count): New functions.
    
    * libguile/posix.h (scm_total_processor_count,
      scm_current_processor_count): New declarations.
    
    * test-suite/tests/posix.test ("nproc"): New test prefix.
    
    * doc/ref/posix.texi (Processes): Document `total-processor-count' and
      `current-processor-count'.

commit 3ae78cac88d38b9ab913ee0100b00ad1151db306
Author: Ludovic Courtès <address@hidden>
Date:   Tue Dec 7 22:56:07 2010 +0100

    Improve doc of `getaffinity' and `setaffinity'.
    
    * doc/ref/posix.texi (Processes): Add cross-reference from `setaffinity'
      and `getaffinity' to the corresponding node in the glibc manual.
    
    * libguile/posix.c (scm_getaffinity, scm_setaffinity): Likewise.

commit 99dbafd66ace1b3c66b3e0f963411377627a62f8
Author: Ludovic Courtès <address@hidden>
Date:   Tue Dec 7 22:49:46 2010 +0100

    Temporarily fix `unistr.in.h' to allow compilation with `-Wundef'.
    
    See <http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/24225> for details.
    
    * lib/unistr.in.h: Change #if's into #ifdef's.

commit 0f00f2c33a85842a9611ed63f07e915ea9fd60de
Author: Ludovic Courtès <address@hidden>
Date:   Tue Dec 7 21:43:04 2010 +0100

    Use Gnulib's `nproc'.
    
    This updates Gnulib to v0.0-4496-g6491120.
    
    * m4/gnulib-cache.m4: Add `nproc'.

commit cb26e97a88e90d04e6d4efe3de0de92dea53d1e5
Author: Ludovic Courtès <address@hidden>
Date:   Tue Dec 7 20:45:29 2010 +0100

    Build dlopenable modules with `-module'.
    
    * test-suite/standalone/Makefile.am (libtest_asmobs_la_LDFLAGS,
      libtest_ffi_la_LDFLAGS, libtest_extensions_la_LDFLAGS): Add `-module'.

commit a94469c651ae096b84c9b6389b8278113da00100
Author: Ludovic Courtès <address@hidden>
Date:   Tue Dec 7 20:43:49 2010 +0100

    Add a record type printer for vlists/vhashes.
    
    * module/ice-9/vlist.scm (<vlist>): Add a record type printer.

-----------------------------------------------------------------------

Summary of changes:
 .gitignore                        |    1 +
 GNUmakefile                       |    2 +-
 build-aux/gendocs.sh              |  111 ++++++------
 build-aux/git-version-gen         |    7 +-
 doc/ref/api-scheduling.texi       |   10 +-
 doc/ref/posix.texi                |   32 +++-
 lib/Makefile.am                   |   71 +++++++-
 lib/arpa_inet.in.h                |    5 +
 lib/close-hook.c                  |   91 ++++++++++
 lib/close-hook.h                  |   72 ++++++++
 lib/errno.in.h                    |    7 +
 lib/float+.h                      |    6 +-
 lib/float.in.h                    |    1 +
 lib/getaddrinfo.c                 |    5 +
 lib/gettext.h                     |    2 +-
 lib/iconv.in.h                    |   46 +++--
 lib/inet_ntop.c                   |    2 +-
 lib/isnan.c                       |    5 +-
 lib/locale.in.h                   |    1 +
 lib/malloca.c                     |    5 +-
 lib/math.in.h                     |   19 ++-
 lib/mbrtowc.c                     |    2 +-
 lib/netdb.in.h                    |    1 +
 lib/netinet_in.in.h               |    1 +
 lib/nproc.c                       |  358 +++++++++++++++++++++++++++++++++++++
 lib/nproc.h                       |   47 +++++
 lib/printf-parse.c                |    7 +
 lib/printf-parse.h                |    7 +
 lib/sockets.c                     |  118 ++++++++++++
 lib/sockets.h                     |   51 ++++++
 lib/stdarg.in.h                   |    1 +
 lib/stddef.in.h                   |    1 +
 lib/stdint.in.h                   |   77 +++++----
 lib/stdio.in.h                    |   11 +-
 lib/stdlib.in.h                   |   16 ++-
 lib/striconveh.c                  |   28 ++-
 lib/striconveh.h                  |    2 +-
 lib/string.in.h                   |   50 +++++-
 lib/strings.in.h                  |    1 +
 lib/sys_file.in.h                 |    1 +
 lib/sys_socket.in.h               |   14 ++-
 lib/sys_stat.in.h                 |    4 +-
 lib/time.in.h                     |   10 +
 lib/unistd.in.h                   |   30 +++-
 lib/unistr.in.h                   |   35 +++--
 lib/unistr/u8-mbtouc-aux.c        |  164 +++++++++++++-----
 lib/unistr/u8-mbtouc-unsafe-aux.c |  180 ++++++++++++++-----
 lib/unistr/u8-mbtouc-unsafe.c     |  180 ++++++++++++++-----
 lib/unistr/u8-mbtouc.c            |  164 +++++++++++++-----
 lib/unistr/u8-prev.c              |    2 +-
 lib/vasnprintf.c                  |   28 ++-
 lib/w32sock.h                     |   61 +++++++
 lib/wchar.in.h                    |    5 +
 libguile/posix.c                  |   40 ++++-
 libguile/posix.h                  |    2 +
 m4/alloca.m4                      |    6 +-
 m4/arpa_inet_h.m4                 |    8 +-
 m4/canonicalize.m4                |   23 ++-
 m4/duplocale.m4                   |    9 +-
 m4/errno_h.m4                     |    7 +-
 m4/fcntl-o.m4                     |   63 +++++--
 m4/float_h.m4                     |    4 +-
 m4/glibc21.m4                     |   13 +-
 m4/gnulib-cache.m4                |    3 +-
 m4/gnulib-common.m4               |   15 ++-
 m4/gnulib-comp.m4                 |   26 +++-
 m4/iconv.m4                       |   26 ++-
 m4/iconv_h.m4                     |    4 +-
 m4/iconv_open.m4                  |  234 ++++++++++++++----------
 m4/include_next.m4                |   27 +++-
 m4/isnanf.m4                      |   14 +-
 m4/isnanl.m4                      |   48 +++---
 m4/locale-fr.m4                   |    9 +-
 m4/locale-ja.m4                   |   11 +-
 m4/locale-zh.m4                   |   11 +-
 m4/lstat.m4                       |   43 +++++-
 m4/mbrlen.m4                      |    9 +-
 m4/mbrtowc.m4                     |    9 +-
 m4/memchr.m4                      |   11 +-
 m4/mmap-anon.m4                   |    6 +-
 m4/nproc.m4                       |   53 ++++++
 m4/printf.m4                      |  170 +++++++++---------
 m4/putenv.m4                      |    6 +-
 m4/socketlib.m4                   |   86 +++++++++
 m4/sockets.m4                     |   17 ++
 m4/stat.m4                        |   12 +-
 m4/stdint.m4                      |    4 +-
 m4/stdlib_h.m4                    |    3 +-
 m4/string_h.m4                    |    9 +-
 m4/sys_socket_h.m4                |   26 +++-
 m4/unistd_h.m4                    |    7 +-
 m4/vasnprintf.m4                  |    3 +-
 m4/wchar_h.m4                     |    6 +-
 maint.mk                          |   37 +++-
 module/ice-9/futures.scm          |    4 +-
 module/ice-9/vlist.scm            |   16 ++
 module/srfi/srfi-26.scm           |   69 +++++---
 test-suite/standalone/Makefile.am |    6 +-
 test-suite/tests/posix.test       |   13 ++
 99 files changed, 2673 insertions(+), 713 deletions(-)
 create mode 100644 lib/close-hook.c
 create mode 100644 lib/close-hook.h
 create mode 100644 lib/nproc.c
 create mode 100644 lib/nproc.h
 create mode 100644 lib/sockets.c
 create mode 100644 lib/sockets.h
 create mode 100644 lib/w32sock.h
 create mode 100644 m4/nproc.m4
 create mode 100644 m4/socketlib.m4
 create mode 100644 m4/sockets.m4

diff --git a/.gitignore b/.gitignore
index df46a80..f7f3258 100644
--- a/.gitignore
+++ b/.gitignore
@@ -137,3 +137,4 @@ INSTALL
 /lib/unitypes.h
 /lib/c++defs.h
 /.sc-start-*
+/lib/math.h
diff --git a/GNUmakefile b/GNUmakefile
index 97fea36..0394d98 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -57,7 +57,7 @@ _have-git-version-gen := \
   $(shell test -f $(srcdir)/$(_build-aux)/git-version-gen && echo yes)
 ifeq ($(_have-git-version-gen)0,yes$(MAKELEVEL))
   _is-dist-target ?= $(filter-out %clean, \
-    $(filter maintainer-% dist% alpha beta major,$(MAKECMDGOALS)))
+    $(filter maintainer-% dist% alpha beta stable,$(MAKECMDGOALS)))
   _is-install-target ?= $(filter-out %check, $(filter 
install%,$(MAKECMDGOALS)))
   ifneq (,$(_is-dist-target)$(_is-install-target))
     _curr-ver := $(shell cd $(srcdir)                          \
diff --git a/build-aux/gendocs.sh b/build-aux/gendocs.sh
index e219df3..3180841 100755
--- a/build-aux/gendocs.sh
+++ b/build-aux/gendocs.sh
@@ -2,10 +2,9 @@
 # gendocs.sh -- generate a GNU manual in many formats.  This script is
 #   mentioned in maintain.texi.  See the help message below for usage details.
 
-scriptversion=2010-07-26.16
+scriptversion=2010-11-27.07
 
-# Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-# Free Software Foundation, Inc.
+# Copyright 2003-2010 Free Software Foundation, Inc.
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -22,6 +21,13 @@ scriptversion=2010-07-26.16
 #
 # Original author: Mohit Agarwal.
 # Send bug reports and any other correspondence to address@hidden
+#
+# The latest version of this script, and the companion template, is
+# available from Texinfo CVS:
+# http://savannah.gnu.org/cgi-bin/viewcvs/texinfo/texinfo/util/gendocs.sh
+# http://savannah.gnu.org/cgi-bin/viewcvs/texinfo/texinfo/util/gendocs_template
+#
+# An up-to-date copy is also maintained in Gnulib (gnu.org/software/gnulib).
 
 prog=`basename "$0"`
 srcdir=`pwd`
@@ -177,8 +183,8 @@ if test ! -r $GENDOCS_TEMPLATE_DIR/gendocs_template; then
 fi
 
 case $outdir in
-  /*) dotdot_outdir="$outdir";;
-  *) dotdot_outdir="../$outdir";;
+  /*) abs_outdir=$outdir;;
+  *)  abs_outdir=$srcdir/$outdir;;
 esac
 
 echo Generating output formats for $srcfile
@@ -186,9 +192,9 @@ echo Generating output formats for $srcfile
 cmd="$SETLANG $MAKEINFO -o $PACKAGE.info \"$srcfile\""
 echo "Generating info files... ($cmd)"
 eval "$cmd"
-mkdir -p $outdir/
-tar czf $outdir/$PACKAGE.info.tar.gz $PACKAGE.info*
-info_tgz_size=`calcsize $outdir/$PACKAGE.info.tar.gz`
+mkdir -p "$outdir/"
+tar czf "$outdir/$PACKAGE.info.tar.gz" $PACKAGE.info*
+info_tgz_size=`calcsize "$outdir/$PACKAGE.info.tar.gz"`
 # do not mv the info files, there's no point in having them available
 # separately on the web.
 
@@ -201,26 +207,26 @@ echo Generating postscript...
 ${DVIPS} $PACKAGE -o
 gzip -f -9 $PACKAGE.ps
 ps_gz_size=`calcsize $PACKAGE.ps.gz`
-mv $PACKAGE.ps.gz $outdir/
+mv $PACKAGE.ps.gz "$outdir/"
 
 # compress/finish dvi:
 gzip -f -9 $PACKAGE.dvi
 dvi_gz_size=`calcsize $PACKAGE.dvi.gz`
-mv $PACKAGE.dvi.gz $outdir/
+mv $PACKAGE.dvi.gz "$outdir/"
 
 cmd="$SETLANG ${TEXI2DVI} --pdf \"$srcfile\""
 echo "Generating pdf ... ($cmd)"
 eval "$cmd"
 pdf_size=`calcsize $PACKAGE.pdf`
-mv $PACKAGE.pdf $outdir/
+mv $PACKAGE.pdf "$outdir/"
 
 cmd="$SETLANG $MAKEINFO -o $PACKAGE.txt --no-split --no-headers \"$srcfile\""
 echo "Generating ASCII... ($cmd)"
 eval "$cmd"
 ascii_size=`calcsize $PACKAGE.txt`
-gzip -f -9 -c $PACKAGE.txt >$outdir/$PACKAGE.txt.gz
-ascii_gz_size=`calcsize $outdir/$PACKAGE.txt.gz`
-mv $PACKAGE.txt $outdir/
+gzip -f -9 -c $PACKAGE.txt >"$outdir/$PACKAGE.txt.gz"
+ascii_gz_size=`calcsize "$outdir/$PACKAGE.txt.gz"`
+mv $PACKAGE.txt "$outdir/"
 
 html_split()
 {
@@ -232,12 +238,12 @@ html_split()
   (
     cd ${split_html_dir} || exit 1
     ln -sf ${PACKAGE}.html index.html
-    tar -czf $dotdot_outdir/${PACKAGE}.html_$1.tar.gz -- *.html
+    tar -czf "$abs_outdir/${PACKAGE}.html_$1.tar.gz" -- *.html
   )
-  eval html_$1_tgz_size=`calcsize $outdir/${PACKAGE}.html_$1.tar.gz`
-  rm -f $outdir/html_$1/*.html
-  mkdir -p $outdir/html_$1/
-  mv ${split_html_dir}/*.html $outdir/html_$1/
+  eval html_$1_tgz_size=`calcsize "$outdir/${PACKAGE}.html_$1.tar.gz"`
+  rm -f "$outdir"/html_$1/*.html
+  mkdir -p "$outdir/html_$1/"
+  mv ${split_html_dir}/*.html "$outdir/html_$1/"
   rmdir ${split_html_dir}
 }
 
@@ -248,9 +254,9 @@ if test -z "$use_texi2html"; then
   rm -rf $PACKAGE.html  # in case a directory is left over
   eval "$cmd"
   html_mono_size=`calcsize $PACKAGE.html`
-  gzip -f -9 -c $PACKAGE.html >$outdir/$PACKAGE.html.gz
-  html_mono_gz_size=`calcsize $outdir/$PACKAGE.html.gz`
-  mv $PACKAGE.html $outdir/
+  gzip -f -9 -c $PACKAGE.html >"$outdir/$PACKAGE.html.gz"
+  html_mono_gz_size=`calcsize "$outdir/$PACKAGE.html.gz"`
+  mv $PACKAGE.html "$outdir/"
 
   cmd="$SETLANG $MAKEINFO --html -o $PACKAGE.html $htmlarg \"$srcfile\""
   echo "Generating html by node... ($cmd)"
@@ -258,12 +264,12 @@ if test -z "$use_texi2html"; then
   split_html_dir=$PACKAGE.html
   (
    cd ${split_html_dir} || exit 1
-   tar -czf $dotdot_outdir/${PACKAGE}.html_node.tar.gz -- *.html
+   tar -czf "$abs_outdir/${PACKAGE}.html_node.tar.gz" -- *.html
   )
-  html_node_tgz_size=`calcsize $outdir/${PACKAGE}.html_node.tar.gz`
-  rm -f $outdir/html_node/*.html
-  mkdir -p $outdir/html_node/
-  mv ${split_html_dir}/*.html $outdir/html_node/
+  html_node_tgz_size=`calcsize "$outdir/${PACKAGE}.html_node.tar.gz"`
+  rm -f "$outdir"/html_node/*.html
+  mkdir -p "$outdir/html_node/"
+  mv ${split_html_dir}/*.html "$outdir/html_node/"
   rmdir ${split_html_dir}
 else
   cmd="$SETLANG $TEXI2HTML --output $PACKAGE.html $htmlarg \"$srcfile\""
@@ -271,9 +277,9 @@ else
   rm -rf $PACKAGE.html  # in case a directory is left over
   eval "$cmd"
   html_mono_size=`calcsize $PACKAGE.html`
-  gzip -f -9 -c $PACKAGE.html >$outdir/$PACKAGE.html.gz
-  html_mono_gz_size=`calcsize $outdir/$PACKAGE.html.gz`
-  mv $PACKAGE.html $outdir/
+  gzip -f -9 -c $PACKAGE.html >"$outdir/$PACKAGE.html.gz"
+  html_mono_gz_size=`calcsize "$outdir/$PACKAGE.html.gz"`
+  mv $PACKAGE.html "$outdir/"
 
   html_split node
   html_split chapter
@@ -282,51 +288,54 @@ fi
 
 echo Making .tar.gz for sources...
 d=`dirname $srcfile`
-srcfiles=`ls $d/*.texinfo $d/*.texi $d/*.txi $d/*.eps 2>/dev/null` || true
-tar cvzfh $outdir/$PACKAGE.texi.tar.gz $srcfiles
-texi_tgz_size=`calcsize $outdir/$PACKAGE.texi.tar.gz`
+(
+  cd "$d"
+  srcfiles=`ls *.texinfo *.texi *.txi *.eps 2>/dev/null` || true
+  tar cvzfh "$abs_outdir/$PACKAGE.texi.tar.gz" $srcfiles
+)
+texi_tgz_size=`calcsize "$outdir/$PACKAGE.texi.tar.gz"`
 
 if test -n "$docbook"; then
   cmd="$SETLANG $MAKEINFO -o - --docbook \"$srcfile\" > 
${srcdir}/$PACKAGE-db.xml"
   echo "Generating docbook XML... ($cmd)"
   eval "$cmd"
   docbook_xml_size=`calcsize $PACKAGE-db.xml`
-  gzip -f -9 -c $PACKAGE-db.xml >$outdir/$PACKAGE-db.xml.gz
-  docbook_xml_gz_size=`calcsize $outdir/$PACKAGE-db.xml.gz`
-  mv $PACKAGE-db.xml $outdir/
+  gzip -f -9 -c $PACKAGE-db.xml >"$outdir/$PACKAGE-db.xml.gz"
+  docbook_xml_gz_size=`calcsize "$outdir/$PACKAGE-db.xml.gz"`
+  mv $PACKAGE-db.xml "$outdir/"
 
-  cmd="${DOCBOOK2HTML} -o $split_html_db_dir ${outdir}/$PACKAGE-db.xml"
+  cmd="${DOCBOOK2HTML} -o $split_html_db_dir \"${outdir}/$PACKAGE-db.xml\""
   echo "Generating docbook HTML... ($cmd)"
   eval "$cmd"
   split_html_db_dir=html_node_db
   (
     cd ${split_html_db_dir} || exit 1
-    tar -czf $dotdot_outdir/${PACKAGE}.html_node_db.tar.gz -- *.html
+    tar -czf "$abs_outdir/${PACKAGE}.html_node_db.tar.gz" -- *.html
   )
-  html_node_db_tgz_size=`calcsize $outdir/${PACKAGE}.html_node_db.tar.gz`
-  rm -f $outdir/html_node_db/*.html
-  mkdir -p $outdir/html_node_db
-  mv ${split_html_db_dir}/*.html $outdir/html_node_db/
+  html_node_db_tgz_size=`calcsize "$outdir/${PACKAGE}.html_node_db.tar.gz"`
+  rm -f "$outdir"/html_node_db/*.html
+  mkdir -p "$outdir/html_node_db"
+  mv ${split_html_db_dir}/*.html "$outdir/html_node_db/"
   rmdir ${split_html_db_dir}
 
-  cmd="${DOCBOOK2TXT} ${outdir}/$PACKAGE-db.xml"
+  cmd="${DOCBOOK2TXT} \"${outdir}/$PACKAGE-db.xml\""
   echo "Generating docbook ASCII... ($cmd)"
   eval "$cmd"
   docbook_ascii_size=`calcsize $PACKAGE-db.txt`
-  mv $PACKAGE-db.txt $outdir/
+  mv $PACKAGE-db.txt "$outdir/"
 
-  cmd="${DOCBOOK2PS} ${outdir}/$PACKAGE-db.xml"
+  cmd="${DOCBOOK2PS} \"${outdir}/$PACKAGE-db.xml\""
   echo "Generating docbook PS... ($cmd)"
   eval "$cmd"
-  gzip -f -9 -c $PACKAGE-db.ps >$outdir/$PACKAGE-db.ps.gz
-  docbook_ps_gz_size=`calcsize $outdir/$PACKAGE-db.ps.gz`
-  mv $PACKAGE-db.ps $outdir/
+  gzip -f -9 -c $PACKAGE-db.ps >"$outdir/$PACKAGE-db.ps.gz"
+  docbook_ps_gz_size=`calcsize "$outdir/$PACKAGE-db.ps.gz"`
+  mv $PACKAGE-db.ps "$outdir/"
 
-  cmd="${DOCBOOK2PDF} ${outdir}/$PACKAGE-db.xml"
+  cmd="${DOCBOOK2PDF} \"${outdir}/$PACKAGE-db.xml\""
   echo "Generating docbook PDF... ($cmd)"
   eval "$cmd"
   docbook_pdf_size=`calcsize $PACKAGE-db.pdf`
-  mv $PACKAGE-db.pdf $outdir/
+  mv $PACKAGE-db.pdf "$outdir/"
 fi
 
 echo "Writing index file..."
@@ -363,7 +372,7 @@ sed \
    -e "s,%%SCRIPTURL%%,$scripturl,g" \
    -e "s!%%SCRIPTNAME%%!$prog!g" \
    -e "$CONDS" \
-$GENDOCS_TEMPLATE_DIR/gendocs_template >$outdir/index.html
+$GENDOCS_TEMPLATE_DIR/gendocs_template >"$outdir/index.html"
 
 echo "Done, see $outdir/ subdirectory for new files."
 
diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen
index 5617eb8..795a98b 100755
--- a/build-aux/git-version-gen
+++ b/build-aux/git-version-gen
@@ -1,6 +1,6 @@
 #!/bin/sh
 # Print a version string.
-scriptversion=2010-06-14.19; # UTC
+scriptversion=2010-10-13.20; # UTC
 
 # Copyright (C) 2007-2010 Free Software Foundation, Inc.
 #
@@ -98,7 +98,10 @@ fi
 if test -n "$v"
 then
     : # use $v
-elif test -d .git \
+# Otherwise, if there is at least one git commit involving the working
+# directory, and "git describe" output looks sensible, use that to
+# derive a version string.
+elif test "`git log -1 --pretty=format:x . 2>&1`" = x \
     && v=`git describe --abbrev=4 --match='v*' HEAD 2>/dev/null \
          || git describe --abbrev=4 HEAD 2>/dev/null` \
     && v=`printf '%s\n' "$v" | sed "$tag_sed_script"` \
diff --git a/doc/ref/api-scheduling.texi b/doc/ref/api-scheduling.texi
index 28e90e3..d202f4a 100644
--- a/doc/ref/api-scheduling.texi
+++ b/doc/ref/api-scheduling.texi
@@ -848,12 +848,18 @@ machine, though, the computation of @code{(find prime? 
lst2)} may be
 done in parallel with that of the other @code{find} call, which can
 reduce the execution time of @code{find-prime}.
 
+Note that futures are intended for the evaluation of purely functional
+expressions.  Expressions that have side-effects or rely on I/O may
+require additional care, such as explicit synchronization
+(@pxref{Mutexes and Condition Variables}).
+
 Guile's futures are implemented on top of POSIX threads
 (@pxref{Threads}).  Internally, a fixed-size pool of threads is used to
 evaluate futures, such that offloading the evaluation of an expression
 to another thread doesn't incur thread creation costs.  By default, the
-pool contains one thread per CPU core, minus one, to account for the
-main thread.
+pool contains one thread per available CPU core, minus one, to account
+for the main thread.  The number of available CPU cores is determined
+using @code{current-processor-count} (@pxref{Processes}).
 
 @deffn {Scheme Syntax} future exp
 Return a future for expression @var{exp}.  This is equivalent to:
diff --git a/doc/ref/posix.texi b/doc/ref/posix.texi
index 7149fb6..dc9d77b 100644
--- a/doc/ref/posix.texi
+++ b/doc/ref/posix.texi
@@ -1840,7 +1840,9 @@ has its corresponding bit set in the returned bitvector.
 The number of bits set is a good estimate of how many CPUs
 Guile can use without stepping on other processes' toes.
 
-Currently this procedure is only defined on GNU variants.
+Currently this procedure is only defined on GNU variants
+(@pxref{CPU Affinity, @code{sched_getaffinity},, libc, The
+GNU C Library Reference Manual}).
 @end deffn
 
 @deffn {Scheme Procedure} setaffinity pid mask
@@ -1849,7 +1851,33 @@ Install the CPU affinity mask @var{mask}, a bitvector, 
for
 the process or thread with ID @var{pid}.  The return value
 is unspecified.
 
-Currently this procedure is only defined on GNU variants.
+Currently this procedure is only defined on GNU variants
+(@pxref{CPU Affinity, @code{sched_setaffinity},, libc, The
+GNU C Library Reference Manual}).
address@hidden deffn
+
address@hidden {Scheme Procedure} total-processor-count
address@hidden {C Function} scm_total_processor_count ()
+Return the total number of processors of the machine, which
+is guaranteed to be at least 1.  A ``processor'' here is a
+thread execution unit, which can be either:
+
address@hidden
address@hidden an execution core in a (possibly multi-core) chip, in a
+  (possibly multi- chip) module, in a single computer, or
address@hidden a thread execution unit inside a core in the case of
+  @dfn{hyper-threaded} CPUs.
address@hidden itemize
+
+Which of the two definitions is used, is unspecified.
address@hidden deffn
+
address@hidden {Scheme Procedure} current-processor-count
address@hidden {C Function} scm_current_processor_count ()
+Like @code{total-processor-count}, but return the number of
+processors available to the current process.  See
address@hidden and @code{getaffinity} for more
+information.
 @end deffn
 
 
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 417f956..ea4a69f 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -9,7 +9,7 @@
 # the same distribution terms as the rest of that program.
 #
 # Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib 
--m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 
--libtool --macro-prefix=gl --no-vc-files alignof alloca-opt announce-gen 
autobuild byteswap canonicalize-lgpl duplocale environ extensions flock fpieee 
full-read full-write func gendocs getaddrinfo git-version-gen 
gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf 
inet_ntop inet_pton isinf isnan lib-symbol-versions lib-symbol-visibility 
libunistring locale maintainer-makefile putenv stat-time stdlib strcase 
strftime striconveh string sys_stat verify version-etc-fsf vsnprintf warnings
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib 
--m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 
--libtool --macro-prefix=gl --no-vc-files alignof alloca-opt announce-gen 
autobuild byteswap canonicalize-lgpl duplocale environ extensions flock fpieee 
full-read full-write func gendocs getaddrinfo git-version-gen 
gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf 
inet_ntop inet_pton isinf isnan lib-symbol-versions lib-symbol-visibility 
libunistring locale maintainer-makefile nproc putenv stat-time stdlib strcase 
strftime striconveh string sys_stat verify version-etc-fsf vsnprintf warnings
 
 AUTOMAKE_OPTIONS = 1.5 gnits subdir-objects
 
@@ -36,6 +36,19 @@ libgnu_la_LIBADD = $(gl_LTLIBOBJS)
 libgnu_la_DEPENDENCIES = $(gl_LTLIBOBJS)
 EXTRA_libgnu_la_SOURCES =
 libgnu_la_LDFLAGS = $(AM_LDFLAGS)
+libgnu_la_LDFLAGS += -no-undefined
+libgnu_la_LDFLAGS += $(GETADDRINFO_LIB)
+libgnu_la_LDFLAGS += $(HOSTENT_LIB)
+libgnu_la_LDFLAGS += $(INET_NTOP_LIB)
+libgnu_la_LDFLAGS += $(INET_PTON_LIB)
+libgnu_la_LDFLAGS += $(ISNAND_LIBM)
+libgnu_la_LDFLAGS += $(ISNANF_LIBM)
+libgnu_la_LDFLAGS += $(ISNANL_LIBM)
+libgnu_la_LDFLAGS += $(LIBSOCKET)
+libgnu_la_LDFLAGS += $(LTLIBICONV)
+libgnu_la_LDFLAGS += $(LTLIBINTL)
+libgnu_la_LDFLAGS += $(LTLIBUNISTRING)
+libgnu_la_LDFLAGS += $(SERVENT_LIB)
 
 ## begin gnulib module alignof
 
@@ -105,6 +118,8 @@ arpa/inet.h: arpa_inet.in.h $(WARN_ON_USE_H) 
$(ARG_NONNULL_H)
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \
              -e 's|@''NEXT_ARPA_INET_H''@|$(NEXT_ARPA_INET_H)|g' \
              -e 's|@''HAVE_ARPA_INET_H''@|$(HAVE_ARPA_INET_H)|g' \
              -e 's|@''GNULIB_INET_NTOP''@|$(GNULIB_INET_NTOP)|g' \
@@ -193,6 +208,14 @@ EXTRA_libgnu_la_SOURCES += canonicalize-lgpl.c
 
 ## end   gnulib module canonicalize-lgpl
 
+## begin gnulib module close-hook
+
+libgnu_la_SOURCES += close-hook.c
+
+EXTRA_DIST += close-hook.h
+
+## end   gnulib module close-hook
+
 ## begin gnulib module configmake
 
 # Retrieve values of the variables through 'configure' followed by
@@ -274,6 +297,7 @@ errno.h: errno.in.h
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
          sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_ERRNO_H''@|$(NEXT_ERRNO_H)|g' \
              -e 's|@''EMULTIHOP_HIDDEN''@|$(EMULTIHOP_HIDDEN)|g' \
              -e 's|@''EMULTIHOP_VALUE''@|$(EMULTIHOP_VALUE)|g' \
@@ -301,6 +325,7 @@ float.h: float.in.h
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
          sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_FLOAT_H''@|$(NEXT_FLOAT_H)|g' \
              < $(srcdir)/float.in.h; \
        } > address@hidden && \
@@ -416,7 +441,9 @@ iconv.h: iconv.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) 
$(WARN_ON_USE_H)
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
          sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_ICONV_H''@|$(NEXT_ICONV_H)|g' \
+             -e 's|@''GNULIB_ICONV''@|$(GNULIB_ICONV)|g' \
              -e 's|@''ICONV_CONST''@|$(ICONV_CONST)|g' \
              -e 's|@''REPLACE_ICONV''@|$(REPLACE_ICONV)|g' \
              -e 's|@''REPLACE_ICONV_OPEN''@|$(REPLACE_ICONV_OPEN)|g' \
@@ -626,6 +653,7 @@ locale.h: locale.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) 
$(WARN_ON_USE_H)
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
          sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_LOCALE_H''@|$(NEXT_LOCALE_H)|g' \
              -e 's|@''GNULIB_DUPLOCALE''@|$(GNULIB_DUPLOCALE)|g' \
              -e 's|@''HAVE_DUPLOCALE''@|$(HAVE_DUPLOCALE)|g' \
@@ -686,6 +714,7 @@ math.h: math.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) 
$(WARN_ON_USE_H)
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
          sed -e 
's|@''INCLUDE_NEXT_AS_FIRST_DIRECTIVE''@|$(INCLUDE_NEXT_AS_FIRST_DIRECTIVE)|g' \
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 
's|@''NEXT_AS_FIRST_DIRECTIVE_MATH_H''@|$(NEXT_AS_FIRST_DIRECTIVE_MATH_H)|g' \
              -e 's|@''GNULIB_ACOSL''@|$(GNULIB_ACOSL)|g' \
              -e 's|@''GNULIB_ASINL''@|$(GNULIB_ASINL)|g' \
@@ -828,6 +857,7 @@ netdb.h: netdb.in.h $(ARG_NONNULL_H) $(WARN_ON_USE_H)
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_NETDB_H''@|$(NEXT_NETDB_H)|g' \
              -e 's|@''HAVE_NETDB_H''@|$(HAVE_NETDB_H)|g' \
              -e 's|@''GNULIB_GETADDRINFO''@|$(GNULIB_GETADDRINFO)|g' \
@@ -859,6 +889,7 @@ netinet/in.h: netinet_in.in.h
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_NETINET_IN_H''@|$(NEXT_NETINET_IN_H)|g' \
              -e 's|@''HAVE_NETINET_IN_H''@|$(HAVE_NETINET_IN_H)|g' \
              < $(srcdir)/netinet_in.in.h; \
@@ -871,6 +902,14 @@ EXTRA_DIST += netinet_in.in.h
 
 ## end   gnulib module netinet_in
 
+## begin gnulib module nproc
+
+libgnu_la_SOURCES += nproc.c
+
+EXTRA_DIST += nproc.h
+
+## end   gnulib module nproc
+
 ## begin gnulib module pathmax
 
 
@@ -929,6 +968,14 @@ EXTRA_libgnu_la_SOURCES += snprintf.c
 
 ## end   gnulib module snprintf
 
+## begin gnulib module sockets
+
+libgnu_la_SOURCES += sockets.h sockets.c
+
+EXTRA_DIST += w32sock.h
+
+## end   gnulib module sockets
+
 ## begin gnulib module stat
 
 
@@ -956,6 +1003,7 @@ stdarg.h: stdarg.in.h
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
          sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_STDARG_H''@|$(NEXT_STDARG_H)|g' \
              < $(srcdir)/stdarg.in.h; \
        } > address@hidden && \
@@ -995,6 +1043,7 @@ stddef.h: stddef.in.h
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
          sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \
              -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \
              -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \
@@ -1019,6 +1068,7 @@ stdint.h: stdint.in.h
          sed -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \
              -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \
              -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \
              -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
@@ -1060,6 +1110,7 @@ stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) 
$(WARN_ON_USE_H)
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
          sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \
              -e 's|@''GNULIB_DPRINTF''@|$(GNULIB_DPRINTF)|g' \
              -e 's|@''GNULIB_FCLOSE''@|$(GNULIB_FCLOSE)|g' \
@@ -1170,6 +1221,7 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) 
$(WARN_ON_USE_H)
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
          sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \
              -e 's|@''GNULIB__EXIT''@|$(GNULIB__EXIT)|g' \
              -e 's|@''GNULIB_ATOLL''@|$(GNULIB_ATOLL)|g' \
@@ -1194,6 +1246,7 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) 
$(WARN_ON_USE_H)
              -e 's|@''GNULIB_STRTOD''@|$(GNULIB_STRTOD)|g' \
              -e 's|@''GNULIB_STRTOLL''@|$(GNULIB_STRTOLL)|g' \
              -e 's|@''GNULIB_STRTOULL''@|$(GNULIB_STRTOULL)|g' \
+             -e 's|@''GNULIB_SYSTEM_POSIX''@|$(GNULIB_SYSTEM_POSIX)|g' \
              -e 's|@''GNULIB_UNLOCKPT''@|$(GNULIB_UNLOCKPT)|g' \
              -e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \
              -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \
@@ -1289,6 +1342,7 @@ string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) 
$(WARN_ON_USE_H)
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
          sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \
              -e 's|@''GNULIB_MBSLEN''@|$(GNULIB_MBSLEN)|g' \
              -e 's|@''GNULIB_MBSNLEN''@|$(GNULIB_MBSNLEN)|g' \
@@ -1322,6 +1376,7 @@ string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) 
$(WARN_ON_USE_H)
              -e 's|@''GNULIB_STRCASESTR''@|$(GNULIB_STRCASESTR)|g' \
              -e 's|@''GNULIB_STRTOK_R''@|$(GNULIB_STRTOK_R)|g' \
              -e 's|@''GNULIB_STRERROR''@|$(GNULIB_STRERROR)|g' \
+             -e 's|@''GNULIB_STRERROR_R''@|$(GNULIB_STRERROR_R)|g' \
              -e 's|@''GNULIB_STRSIGNAL''@|$(GNULIB_STRSIGNAL)|g' \
              -e 's|@''GNULIB_STRVERSCMP''@|$(GNULIB_STRVERSCMP)|g' \
              < $(srcdir)/string.in.h | \
@@ -1341,6 +1396,7 @@ string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) 
$(WARN_ON_USE_H)
              -e 's|@''HAVE_STRSEP''@|$(HAVE_STRSEP)|g' \
              -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \
              -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \
+             -e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \
              -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \
              -e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \
              -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \
@@ -1350,6 +1406,7 @@ string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) 
$(WARN_ON_USE_H)
              -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
              -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
              -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
+             -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \
              -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \
              -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \
              -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \
@@ -1379,6 +1436,7 @@ strings.h: strings.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
          sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_STRINGS_H''@|$(NEXT_STRINGS_H)|g' \
              -e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \
              -e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \
@@ -1406,6 +1464,7 @@ sys/file.h: sys_file.in.h $(WARN_ON_USE_H)
          sed -e 's/@''HAVE_SYS_FILE_H''@/$(HAVE_SYS_FILE_H)/g' \
              -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_SYS_FILE_H''@|$(NEXT_SYS_FILE_H)|g' \
              -e 's/@''HAVE_FLOCK''@/$(HAVE_FLOCK)/g' \
              -e 's/@''GNULIB_FLOCK''@/$(GNULIB_FLOCK)/g' \
@@ -1432,6 +1491,7 @@ sys/socket.h: sys_socket.in.h $(CXXDEFS_H) 
$(WARN_ON_USE_H) $(ARG_NONNULL_H)
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_SYS_SOCKET_H''@|$(NEXT_SYS_SOCKET_H)|g' \
              -e 's|@''HAVE_SYS_SOCKET_H''@|$(HAVE_SYS_SOCKET_H)|g' \
              -e 's|@''GNULIB_CLOSE''@|$(GNULIB_CLOSE)|g' \
@@ -1453,6 +1513,7 @@ sys/socket.h: sys_socket.in.h $(CXXDEFS_H) 
$(WARN_ON_USE_H) $(ARG_NONNULL_H)
              -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
              -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \
              -e 
's|@''HAVE_STRUCT_SOCKADDR_STORAGE''@|$(HAVE_STRUCT_SOCKADDR_STORAGE)|g' \
+             -e 
's|@''HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY''@|$(HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY)|g'
 \
              -e 's|@''HAVE_SA_FAMILY_T''@|$(HAVE_SA_FAMILY_T)|g' \
              -e 's|@''HAVE_ACCEPT4''@|$(HAVE_ACCEPT4)|g' \
              -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
@@ -1480,6 +1541,7 @@ sys/stat.h: sys_stat.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) 
$(WARN_ON_USE_H)
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
              -e 's|@''GNULIB_FCHMODAT''@|$(GNULIB_FCHMODAT)|g' \
              -e 's|@''GNULIB_FSTATAT''@|$(GNULIB_FSTATAT)|g' \
@@ -1537,6 +1599,7 @@ time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) 
$(WARN_ON_USE_H)
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
          sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \
              -e 's|@''GNULIB_MKTIME''@|$(GNULIB_MKTIME)|g' \
              -e 's|@''GNULIB_NANOSLEEP''@|$(GNULIB_NANOSLEEP)|g' \
@@ -1587,6 +1650,7 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) 
$(WARN_ON_USE_H)
          sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \
              -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \
              -e 's|@''GNULIB_CHOWN''@|$(GNULIB_CHOWN)|g' \
              -e 's|@''GNULIB_CLOSE''@|$(GNULIB_CLOSE)|g' \
@@ -1638,7 +1702,6 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) 
$(WARN_ON_USE_H)
              -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \
              -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \
              -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \
-             -e 's|@''HAVE_GETDOMAINNAME''@|$(HAVE_GETDOMAINNAME)|g' \
              -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \
              -e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \
              -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \
@@ -1659,6 +1722,7 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) 
$(WARN_ON_USE_H)
              -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \
              -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \
              -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
+             -e 's|@''HAVE_DECL_GETDOMAINNAME''@|$(HAVE_DECL_GETDOMAINNAME)|g' 
\
              -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \
              -e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \
              -e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \
@@ -1670,6 +1734,7 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) 
$(WARN_ON_USE_H)
              -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \
              -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \
              -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
+             -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \
              -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \
              -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
              -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
@@ -1877,6 +1942,8 @@ wchar.h: wchar.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) 
$(WARN_ON_USE_H)
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \
              -e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \
              -e 's|@''HAVE_WCHAR_H''@|$(HAVE_WCHAR_H)|g' \
              -e 's|@''GNULIB_BTOWC''@|$(GNULIB_BTOWC)|g' \
diff --git a/lib/arpa_inet.in.h b/lib/arpa_inet.in.h
index 2dedcd7..6d9b8c7 100644
--- a/lib/arpa_inet.in.h
+++ b/lib/arpa_inet.in.h
@@ -21,6 +21,11 @@
 #if __GNUC__ >= 3
 @PRAGMA_SYSTEM_HEADER@
 #endif
address@hidden@
+
+#if @HAVE_FEATURES_H@
+# include <features.h> /* for __GLIBC__ */
+#endif
 
 /* Gnulib's sys/socket.h is responsible for pulling in winsock2.h etc
    under MinGW.
diff --git a/lib/close-hook.c b/lib/close-hook.c
new file mode 100644
index 0000000..15d67fb
--- /dev/null
+++ b/lib/close-hook.c
@@ -0,0 +1,91 @@
+/* Hook for making the close() function extensible.
+   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Written by Bruno Haible <address@hidden>, 2009.
+
+   This program 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 3 of the License, or
+   (at your option) any later version.
+
+   This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include "close-hook.h"
+
+#include <stdlib.h>
+#include <unistd.h>
+
+#undef close
+
+
+/* Currently, this entire code is only needed for the handling of sockets
+   on native Windows platforms.  */
+#if WINDOWS_SOCKETS
+
+/* The first and last link in the doubly linked list.
+   Initially the list is empty.  */
+static struct close_hook anchor = { &anchor, &anchor, NULL };
+
+int
+execute_close_hooks (int fd, const struct close_hook *remaining_list)
+{
+  if (remaining_list == &anchor)
+    /* End of list reached.  */
+    return close (fd);
+  else
+    return remaining_list->private_fn (fd, remaining_list->private_next);
+}
+
+int
+execute_all_close_hooks (int fd)
+{
+  return execute_close_hooks (fd, anchor.private_next);
+}
+
+void
+register_close_hook (close_hook_fn hook, struct close_hook *link)
+{
+  if (link->private_next == NULL && link->private_prev == NULL)
+    {
+      /* Add the link to the doubly linked list.  */
+      link->private_next = anchor.private_next;
+      link->private_prev = &anchor;
+      link->private_fn = hook;
+      anchor.private_next->private_prev = link;
+      anchor.private_next = link;
+    }
+  else
+    {
+      /* The link is already in use.  */
+      if (link->private_fn != hook)
+        abort ();
+    }
+}
+
+void
+unregister_close_hook (struct close_hook *link)
+{
+  struct close_hook *next = link->private_next;
+  struct close_hook *prev = link->private_prev;
+
+  if (next != NULL && prev != NULL)
+    {
+      /* The link is in use.  Remove it from the doubly linked list.  */
+      prev->private_next = next;
+      next->private_prev = prev;
+      /* Clear the link, to mark it unused.  */
+      link->private_next = NULL;
+      link->private_prev = NULL;
+      link->private_fn = NULL;
+    }
+}
+
+#endif
diff --git a/lib/close-hook.h b/lib/close-hook.h
new file mode 100644
index 0000000..aff5757
--- /dev/null
+++ b/lib/close-hook.h
@@ -0,0 +1,72 @@
+/* Hook for making the close() function extensible.
+   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+
+   This program 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 3 of the License, or
+   (at your option) any later version.
+
+   This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+
+#ifndef CLOSE_HOOK_H
+#define CLOSE_HOOK_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Currently, this entire code is only needed for the handling of sockets
+   on native Windows platforms.  */
+#if WINDOWS_SOCKETS
+
+
+/* An element of the list of close hooks.
+   The fields of this structure are considered private.  */
+struct close_hook
+{
+  /* Doubly linked list.  */
+  struct close_hook *private_next;
+  struct close_hook *private_prev;
+  /* Function that treats the types of FD that it knows about and calls
+     execute_close_hooks (FD, REMAINING_LIST) as a fallback.  */
+  int (*private_fn) (int fd, const struct close_hook *remaining_list);
+};
+
+/* This type of function closes FD, applying special knowledge for the FD
+   types it knows about, and calls execute_close_hooks (FD, REMAINING_LIST)
+   for the other FD types.  */
+typedef int (*close_hook_fn) (int fd, const struct close_hook *remaining_list);
+
+/* Execute the close hooks in REMAINING_LIST.
+   Return 0 or -1, like close() would do.  */
+extern int execute_close_hooks (int fd, const struct close_hook 
*remaining_list);
+
+/* Execute all close hooks.
+   Return 0 or -1, like close() would do.  */
+extern int execute_all_close_hooks (int fd);
+
+/* Add a function to the list of close hooks.
+   The LINK variable points to a piece of memory which is guaranteed to be
+   accessible until the corresponding call to unregister_close_hook.  */
+extern void register_close_hook (close_hook_fn hook, struct close_hook *link);
+
+/* Removes a function from the list of close hooks.  */
+extern void unregister_close_hook (struct close_hook *link);
+
+
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CLOSE_HOOK_H */
diff --git a/lib/errno.in.h b/lib/errno.in.h
index 0e6fb7f..3543adc 100644
--- a/lib/errno.in.h
+++ b/lib/errno.in.h
@@ -21,6 +21,7 @@
 #if __GNUC__ >= 3
 @PRAGMA_SYSTEM_HEADER@
 #endif
address@hidden@
 
 /* The include_next requires a split double-inclusion guard.  */
 address@hidden@ @NEXT_ERRNO_H@
@@ -98,6 +99,7 @@
 
 /* On OpenBSD 4.0 and on native Windows, the macros ENOMSG, EIDRM, ENOLINK,
    EPROTO, EMULTIHOP, EBADMSG, EOVERFLOW, ENOTSUP, ECANCELED are not defined.
+   Likewise, on NonStop Kernel, EDQUOT is not defined.
    Define them here.  Values >= 2000 seem safe to use: Solaris ESTALE = 151,
    HP-UX EWOULDBLOCK = 246, IRIX EDQUOT = 1133.
 
@@ -150,6 +152,11 @@
 #  define GNULIB_defined_ESTALE 1
 # endif
 
+# ifndef EDQUOT
+#  define EDQUOT 2010
+#  define GNULIB_defined_EDQUOT 1
+# endif
+
 # ifndef ECANCELED
 #  define ECANCELED 2008
 #  define GNULIB_defined_ECANCELED 1
diff --git a/lib/float+.h b/lib/float+.h
index 956eb28..5a4955f 100644
--- a/lib/float+.h
+++ b/lib/float+.h
@@ -141,8 +141,8 @@
 #define SIZEOF_LDBL ((LDBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT)
 
 /* Verify that SIZEOF_FLT <= sizeof (float) etc.  */
-typedef int verify_sizeof_flt[2 * (SIZEOF_FLT <= sizeof (float)) - 1];
-typedef int verify_sizeof_dbl[2 * (SIZEOF_DBL <= sizeof (double)) - 1];
-typedef int verify_sizeof_ldbl[2 * (SIZEOF_LDBL <= sizeof (long double)) - 1];
+typedef int verify_sizeof_flt[SIZEOF_FLT <= sizeof (float) ? 1 : -1];
+typedef int verify_sizeof_dbl[SIZEOF_DBL <= sizeof (double) ? 1 : - 1];
+typedef int verify_sizeof_ldbl[SIZEOF_LDBL <= sizeof (long double) ? 1 : - 1];
 
 #endif /* _FLOATPLUS_H */
diff --git a/lib/float.in.h b/lib/float.in.h
index ad99af3..83fbf9f 100644
--- a/lib/float.in.h
+++ b/lib/float.in.h
@@ -20,6 +20,7 @@
 #if __GNUC__ >= 3
 @PRAGMA_SYSTEM_HEADER@
 #endif
address@hidden@
 
 /* The include_next requires a split double-inclusion guard.  */
 address@hidden@ @NEXT_FLOAT_H@
diff --git a/lib/getaddrinfo.c b/lib/getaddrinfo.c
index 2e70903..1314871 100644
--- a/lib/getaddrinfo.c
+++ b/lib/getaddrinfo.c
@@ -59,6 +59,9 @@
 # define WIN32_NATIVE
 #endif
 
+/* gl_sockets_startup */
+#include "sockets.h"
+
 #ifdef WIN32_NATIVE
 typedef int (WSAAPI *getaddrinfo_func) (const char*, const char*,
                                         const struct addrinfo*,
@@ -101,6 +104,8 @@ use_win32_p (void)
       return 0;
     }
 
+  gl_sockets_startup (SOCKETS_1_1);
+
   return 1;
 }
 #endif
diff --git a/lib/gettext.h b/lib/gettext.h
index 6eed64d..d7705b5 100644
--- a/lib/gettext.h
+++ b/lib/gettext.h
@@ -54,7 +54,7 @@
    it now, to make later inclusions of <libintl.h> a NOP.  */
 #if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
 # include <cstdlib>
-# if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H
+# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H
 #  include <libintl.h>
 # endif
 #endif
diff --git a/lib/iconv.in.h b/lib/iconv.in.h
index 5512c60..260c758 100644
--- a/lib/iconv.in.h
+++ b/lib/iconv.in.h
@@ -21,6 +21,7 @@
 #if __GNUC__ >= 3
 @PRAGMA_SYSTEM_HEADER@
 #endif
address@hidden@
 
 /* The include_next requires a split double-inclusion guard.  */
 address@hidden@ @NEXT_ICONV_H@
@@ -35,22 +36,24 @@
 /* The definition of _GL_WARN_ON_USE is copied here.  */
 
 
-#if @REPLACE_ICONV_OPEN@
+#if @GNULIB_ICONV@
+# if @REPLACE_ICONV_OPEN@
 /* An iconv_open wrapper that supports the IANA standardized encoding names
    ("ISO-8859-1" etc.) as far as possible.  */
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#  define iconv_open rpl_iconv_open
-# endif
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define iconv_open rpl_iconv_open
+#  endif
 _GL_FUNCDECL_RPL (iconv_open, iconv_t,
                   (const char *tocode, const char *fromcode)
                   _GL_ARG_NONNULL ((1, 2)));
 _GL_CXXALIAS_RPL (iconv_open, iconv_t,
                   (const char *tocode, const char *fromcode));
-#else
+# else
 _GL_CXXALIAS_SYS (iconv_open, iconv_t,
                   (const char *tocode, const char *fromcode));
-#endif
+# endif
 _GL_CXXALIASWARN (iconv_open);
+#endif
 
 #if @REPLACE_ICONV_UTF@
 /* Special constants for supporting UTF-{16,32}{BE,LE} encodings.
@@ -65,10 +68,11 @@ _GL_CXXALIASWARN (iconv_open);
 # define _ICONV_UTF32LE_UTF8 (iconv_t)(-168)
 #endif
 
-#if @REPLACE_ICONV@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#  define iconv rpl_iconv
-# endif
+#if @GNULIB_ICONV@
+# if @REPLACE_ICONV@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define iconv rpl_iconv
+#  endif
 _GL_FUNCDECL_RPL (iconv, size_t,
                   (iconv_t cd,
                    @ICONV_CONST@ char **inbuf, size_t *inbytesleft,
@@ -77,24 +81,30 @@ _GL_CXXALIAS_RPL (iconv, size_t,
                   (iconv_t cd,
                    @ICONV_CONST@ char **inbuf, size_t *inbytesleft,
                    char **outbuf, size_t *outbytesleft));
-#else
+# else
 _GL_CXXALIAS_SYS (iconv, size_t,
                   (iconv_t cd,
                    @ICONV_CONST@ char **inbuf, size_t *inbytesleft,
                    char **outbuf, size_t *outbytesleft));
-#endif
+# endif
 _GL_CXXALIASWARN (iconv);
-
-#if @REPLACE_ICONV@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#  define iconv_close rpl_iconv_close
+# ifndef ICONV_CONST
+#  define ICONV_CONST @ICONV_CONST@
 # endif
+#endif
+
+#if @GNULIB_ICONV@
+# if @REPLACE_ICONV@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define iconv_close rpl_iconv_close
+#  endif
 _GL_FUNCDECL_RPL (iconv_close, int, (iconv_t cd));
 _GL_CXXALIAS_RPL (iconv_close, int, (iconv_t cd));
-#else
+# else
 _GL_CXXALIAS_SYS (iconv_close, int, (iconv_t cd));
-#endif
+# endif
 _GL_CXXALIASWARN (iconv_close);
+#endif
 
 
 #endif /* _GL_ICONV_H */
diff --git a/lib/inet_ntop.c b/lib/inet_ntop.c
index cd5dbf1..fc8c683 100644
--- a/lib/inet_ntop.c
+++ b/lib/inet_ntop.c
@@ -49,7 +49,7 @@
  * WARNING: Don't even consider trying to compile this on a system where
  * sizeof(int) < 4.  sizeof(int) > 4 is fine; all the world's not a VAX.
  */
-typedef int verify_int_size[2 * sizeof (int) - 7];
+typedef int verify_int_size[4 <= sizeof (int) ? 1 : -1];
 
 static const char *inet_ntop4 (const unsigned char *src, char *dst, socklen_t 
size);
 #if HAVE_IPV6
diff --git a/lib/isnan.c b/lib/isnan.c
index a59dea7..ad96c1f 100644
--- a/lib/isnan.c
+++ b/lib/isnan.c
@@ -117,8 +117,9 @@ FUNC (DOUBLE x)
 # else
   /* Be careful to not do any floating-point operation on x, such as x == x,
      because x may be a signaling NaN.  */
-#  if defined __SUNPRO_C || defined __DECC || (defined __sgi && !defined 
__GNUC__)
-  /* The Sun C 5.0 compilers and the Compaq (ex-DEC) 6.4 compilers don't
+#  if defined __TINYC__ || defined __SUNPRO_C || defined __DECC \
+      || (defined __sgi && !defined __GNUC__) || defined __ICC
+  /* The Sun C 5.0, Intel ICC 10.0, and Compaq (ex-DEC) 6.4 compilers don't
      recognize the initializers as constant expressions.  The latter compiler
      also fails when constant-folding 0.0 / 0.0 even when constant-folding is
      not required.  The SGI MIPSpro C compiler complains about "floating-point
diff --git a/lib/locale.in.h b/lib/locale.in.h
index 64212d8..9464877 100644
--- a/lib/locale.in.h
+++ b/lib/locale.in.h
@@ -19,6 +19,7 @@
 #if __GNUC__ >= 3
 @PRAGMA_SYSTEM_HEADER@
 #endif
address@hidden@
 
 /* The include_next requires a split double-inclusion guard.  */
 address@hidden@ @NEXT_LOCALE_H@
diff --git a/lib/malloca.c b/lib/malloca.c
index 5eb9e12..386a506 100644
--- a/lib/malloca.c
+++ b/lib/malloca.c
@@ -21,6 +21,8 @@
 /* Specification.  */
 #include "malloca.h"
 
+#include "verify.h"
+
 /* Use the system functions, not the gnulib overrides in this file.  */
 #undef malloc
 
@@ -53,8 +55,7 @@ struct preliminary_header { void *next; char 
room[MAGIC_SIZE]; };
 #define HEADER_SIZE \
   (((sizeof (struct preliminary_header) + sa_alignment_max - 1) / 
sa_alignment_max) * sa_alignment_max)
 struct header { void *next; char room[HEADER_SIZE - sizeof (struct 
preliminary_header) + MAGIC_SIZE]; };
-/* Verify that HEADER_SIZE == sizeof (struct header).  */
-typedef int verify1[2 * (HEADER_SIZE == sizeof (struct header)) - 1];
+verify (HEADER_SIZE == sizeof (struct header));
 /* We make the hash table quite big, so that during lookups the probability
    of empty hash buckets is quite high.  There is no need to make the hash
    table resizable, because when the hash table gets filled so much that the
diff --git a/lib/math.in.h b/lib/math.in.h
index c0b2f34..f1bda2e 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -20,6 +20,7 @@
 #if __GNUC__ >= 3
 @PRAGMA_SYSTEM_HEADER@
 #endif
address@hidden@
 
 /* The include_next requires a split double-inclusion guard.  */
 address@hidden@ @NEXT_AS_FIRST_DIRECTIVE_MATH_H@
@@ -609,7 +610,8 @@ _GL_EXTERN_C int isnanf (float x);
    This function is a gnulib extension, unlike isnan() which applied only
    to 'double' numbers earlier but now is a type-generic macro.  */
 # if @HAVE_ISNAND@
-/* The original <math.h> included above provides a declaration of isnan macro. 
 */
+/* The original <math.h> included above provides a declaration of isnan
+   macro.  */
 #  if __GNUC__ >= 4
     /* GCC 4.0 and newer provides three built-ins for isnan.  */
 #   undef isnand
@@ -629,7 +631,8 @@ _GL_EXTERN_C int isnand (double x);
 #if @GNULIB_ISNANL@
 /* Test for NaN for 'long double' numbers.  */
 # if @HAVE_ISNANL@
-/* The original <math.h> included above provides a declaration of isnan macro 
or (older) isnanl function.  */
+/* The original <math.h> included above provides a declaration of isnan
+   macro or (older) isnanl function.  */
 #  if __GNUC__ >= 4
     /* GCC 4.0 and newer provides three built-ins for isnan.  */
 #   undef isnanl
@@ -701,11 +704,13 @@ _GL_EXTERN_C int gl_signbitf (float arg);
 _GL_EXTERN_C int gl_signbitd (double arg);
 _GL_EXTERN_C int gl_signbitl (long double arg);
 #  if __GNUC__ >= 2 && !__STRICT_ANSI__
+#   define _GL_NUM_UINT_WORDS(type) \
+      ((sizeof (type) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
 #   if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT && !defined 
gl_signbitf
 #    define gl_signbitf_OPTIMIZED_MACRO
 #    define gl_signbitf(arg) \
        ({ union { float _value;                                         \
-                  unsigned int _word[(sizeof (float) + sizeof (unsigned int) - 
1) / sizeof (unsigned int)]; \
+                  unsigned int _word[_GL_NUM_UINT_WORDS (float)];       \
                 } _m;                                                   \
           _m._value = (arg);                                            \
           (_m._word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1;          \
@@ -714,8 +719,8 @@ _GL_EXTERN_C int gl_signbitl (long double arg);
 #   if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT && !defined 
gl_signbitd
 #    define gl_signbitd_OPTIMIZED_MACRO
 #    define gl_signbitd(arg) \
-       ({ union { double _value;                                               
 \
-                  unsigned int _word[(sizeof (double) + sizeof (unsigned int) 
- 1) / sizeof (unsigned int)]; \
+       ({ union { double _value;                                        \
+                  unsigned int _word[_GL_NUM_UINT_WORDS (double)];      \
                 } _m;                                                   \
           _m._value = (arg);                                            \
           (_m._word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1;          \
@@ -725,10 +730,10 @@ _GL_EXTERN_C int gl_signbitl (long double arg);
 #    define gl_signbitl_OPTIMIZED_MACRO
 #    define gl_signbitl(arg) \
        ({ union { long double _value;                                   \
-                  unsigned int _word[(sizeof (long double) + sizeof (unsigned 
int) - 1) / sizeof (unsigned int)]; \
+                  unsigned int _word[_GL_NUM_UINT_WORDS (long double)]; \
                 } _m;                                                   \
           _m._value = (arg);                                            \
-          (_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1;               
 \
+          (_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1;        \
         })
 #   endif
 #  endif
diff --git a/lib/mbrtowc.c b/lib/mbrtowc.c
index 31f229c..85f251c 100644
--- a/lib/mbrtowc.c
+++ b/lib/mbrtowc.c
@@ -91,7 +91,7 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
 
     /* Here m > 0.  */
 
-# if __GLIBC__
+# if __GLIBC__ || defined __UCLIBC__
     /* Work around bug <http://sourceware.org/bugzilla/show_bug.cgi?id=9674> */
     mbtowc (NULL, NULL, 0);
 # endif
diff --git a/lib/netdb.in.h b/lib/netdb.in.h
index d67a96c..6f761f1 100644
--- a/lib/netdb.in.h
+++ b/lib/netdb.in.h
@@ -25,6 +25,7 @@
 #if __GNUC__ >= 3
 @PRAGMA_SYSTEM_HEADER@
 #endif
address@hidden@
 
 #if @HAVE_NETDB_H@
 
diff --git a/lib/netinet_in.in.h b/lib/netinet_in.in.h
index bd0b6d9..e9af2a9 100644
--- a/lib/netinet_in.in.h
+++ b/lib/netinet_in.in.h
@@ -20,6 +20,7 @@
 #if __GNUC__ >= 3
 @PRAGMA_SYSTEM_HEADER@
 #endif
address@hidden@
 
 #if @HAVE_NETINET_IN_H@
 
diff --git a/lib/nproc.c b/lib/nproc.c
new file mode 100644
index 0000000..e4cdb3a
--- /dev/null
+++ b/lib/nproc.c
@@ -0,0 +1,358 @@
+/* Detect the number of processors.
+
+   Copyright (C) 2009-2010 Free Software Foundation, Inc.
+
+   This program 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, or (at your option)
+   any later version.
+
+   This program 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 this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* Written by Glen Lenker and Bruno Haible.  */
+
+#include <config.h>
+#include "nproc.h"
+
+#include <stdlib.h>
+#include <unistd.h>
+
+#if HAVE_PTHREAD_GETAFFINITY_NP && 0
+# include <pthread.h>
+# include <sched.h>
+#endif
+#if HAVE_SCHED_GETAFFINITY_LIKE_GLIBC || HAVE_SCHED_GETAFFINITY_NP
+# include <sched.h>
+#endif
+
+#include <sys/types.h>
+
+#if HAVE_SYS_PSTAT_H
+# include <sys/pstat.h>
+#endif
+
+#if HAVE_SYS_SYSMP_H
+# include <sys/sysmp.h>
+#endif
+
+#if HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+
+#if HAVE_SYS_SYSCTL_H
+# include <sys/sysctl.h>
+#endif
+
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+#endif
+
+#include "c-ctype.h"
+
+#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
+
+/* Return the number of processors available to the current process, based
+   on a modern system call that returns the "affinity" between the current
+   process and each CPU.  Return 0 if unknown or if such a system call does
+   not exist.  */
+static unsigned long
+num_processors_via_affinity_mask (void)
+{
+  /* glibc >= 2.3.3 with NPTL and NetBSD 5 have pthread_getaffinity_np,
+     but with different APIs.  Also it requires linking with -lpthread.
+     Therefore this code is not enabled.
+     glibc >= 2.3.4 has sched_getaffinity whereas NetBSD 5 has
+     sched_getaffinity_np.  */
+#if HAVE_PTHREAD_GETAFFINITY_NP && defined __GLIBC__ && 0
+  {
+    cpu_set_t set;
+
+    if (pthread_getaffinity_np (pthread_self (), sizeof (set), &set) == 0)
+      {
+        unsigned long count;
+
+# ifdef CPU_COUNT
+        /* glibc >= 2.6 has the CPU_COUNT macro.  */
+        count = CPU_COUNT (&set);
+# else
+        size_t i;
+
+        count = 0;
+        for (i = 0; i < CPU_SETSIZE; i++)
+          if (CPU_ISSET (i, &set))
+            count++;
+# endif
+        if (count > 0)
+          return count;
+      }
+  }
+#elif HAVE_PTHREAD_GETAFFINITY_NP && defined __NetBSD__ && 0
+  {
+    cpuset_t *set;
+
+    set = cpuset_create ();
+    if (set != NULL)
+      {
+        unsigned long count = 0;
+
+        if (pthread_getaffinity_np (pthread_self (), cpuset_size (set), set)
+            == 0)
+          {
+            cpuid_t i;
+
+            for (i = 0;; i++)
+              {
+                int ret = cpuset_isset (i, set);
+                if (ret < 0)
+                  break;
+                if (ret > 0)
+                  count++;
+              }
+          }
+        cpuset_destroy (set);
+        if (count > 0)
+          return count;
+      }
+  }
+#elif HAVE_SCHED_GETAFFINITY_LIKE_GLIBC /* glibc >= 2.3.4 */
+  {
+    cpu_set_t set;
+
+    if (sched_getaffinity (0, sizeof (set), &set) == 0)
+      {
+        unsigned long count;
+
+# ifdef CPU_COUNT
+        /* glibc >= 2.6 has the CPU_COUNT macro.  */
+        count = CPU_COUNT (&set);
+# else
+        size_t i;
+
+        count = 0;
+        for (i = 0; i < CPU_SETSIZE; i++)
+          if (CPU_ISSET (i, &set))
+            count++;
+# endif
+        if (count > 0)
+          return count;
+      }
+  }
+#elif HAVE_SCHED_GETAFFINITY_NP /* NetBSD >= 5 */
+  {
+    cpuset_t *set;
+
+    set = cpuset_create ();
+    if (set != NULL)
+      {
+        unsigned long count = 0;
+
+        if (sched_getaffinity_np (getpid (), cpuset_size (set), set) == 0)
+          {
+            cpuid_t i;
+
+            for (i = 0;; i++)
+              {
+                int ret = cpuset_isset (i, set);
+                if (ret < 0)
+                  break;
+                if (ret > 0)
+                  count++;
+              }
+          }
+        cpuset_destroy (set);
+        if (count > 0)
+          return count;
+      }
+  }
+#endif
+
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+  { /* This works on native Windows platforms.  */
+    DWORD_PTR process_mask;
+    DWORD_PTR system_mask;
+
+    if (GetProcessAffinityMask (GetCurrentProcess (),
+                                &process_mask, &system_mask))
+      {
+        DWORD_PTR mask = process_mask;
+        unsigned long count = 0;
+
+        for (; mask != 0; mask = mask >> 1)
+          if (mask & 1)
+            count++;
+        if (count > 0)
+          return count;
+      }
+  }
+#endif
+
+  return 0;
+}
+
+unsigned long int
+num_processors (enum nproc_query query)
+{
+  if (query == NPROC_CURRENT_OVERRIDABLE)
+    {
+      /* Test the environment variable OMP_NUM_THREADS, recognized also by all
+         programs that are based on OpenMP.  The OpenMP spec says that the
+         value assigned to the environment variable "may have leading and
+         trailing white space". */
+      const char *envvalue = getenv ("OMP_NUM_THREADS");
+
+      if (envvalue != NULL)
+        {
+          while (*envvalue != '\0' && c_isspace (*envvalue))
+            envvalue++;
+          /* Convert it from decimal to 'unsigned long'.  */
+          if (c_isdigit (*envvalue))
+            {
+              char *endptr = NULL;
+              unsigned long int value = strtoul (envvalue, &endptr, 10);
+
+              if (endptr != NULL)
+                {
+                  while (*endptr != '\0' && c_isspace (*endptr))
+                    endptr++;
+                  if (*endptr == '\0')
+                    return (value > 0 ? value : 1);
+                }
+            }
+        }
+
+      query = NPROC_CURRENT;
+    }
+  /* Here query is one of NPROC_ALL, NPROC_CURRENT.  */
+
+  /* On systems with a modern affinity mask system call, we have
+         sysconf (_SC_NPROCESSORS_CONF)
+            >= sysconf (_SC_NPROCESSORS_ONLN)
+               >= num_processors_via_affinity_mask ()
+     The first number is the number of CPUs configured in the system.
+     The second number is the number of CPUs available to the scheduler.
+     The third number is the number of CPUs available to the current process.
+
+     Note! On Linux systems with glibc, the first and second number come from
+     the /sys and /proc file systems (see
+     glibc/sysdeps/unix/sysv/linux/getsysstats.c).
+     In some situations these file systems are not mounted, and the sysconf
+     call returns 1, which does not reflect the reality.  */
+
+  if (query == NPROC_CURRENT)
+    {
+      /* Try the modern affinity mask system call.  */
+      {
+        unsigned long nprocs = num_processors_via_affinity_mask ();
+
+        if (nprocs > 0)
+          return nprocs;
+      }
+
+#if defined _SC_NPROCESSORS_ONLN
+      { /* This works on glibc, MacOS X 10.5, FreeBSD, AIX, OSF/1, Solaris,
+           Cygwin, Haiku.  */
+        long int nprocs = sysconf (_SC_NPROCESSORS_ONLN);
+        if (nprocs > 0)
+          return nprocs;
+      }
+#endif
+    }
+  else /* query == NPROC_ALL */
+    {
+#if defined _SC_NPROCESSORS_CONF
+      { /* This works on glibc, MacOS X 10.5, FreeBSD, AIX, OSF/1, Solaris,
+           Cygwin, Haiku.  */
+        long int nprocs = sysconf (_SC_NPROCESSORS_CONF);
+
+# if __GLIBC__ >= 2 && defined __linux__
+        /* On Linux systems with glibc, this information comes from the /sys 
and
+           /proc file systems (see 
glibc/sysdeps/unix/sysv/linux/getsysstats.c).
+           In some situations these file systems are not mounted, and the
+           sysconf call returns 1.  But we wish to guarantee that
+           num_processors (NPROC_ALL) >= num_processors (NPROC_CURRENT).  */
+        if (nprocs == 1)
+          {
+            unsigned long nprocs_current = num_processors_via_affinity_mask ();
+
+            if (nprocs_current > 0)
+              nprocs = nprocs_current;
+          }
+# endif
+
+        if (nprocs > 0)
+          return nprocs;
+      }
+#endif
+    }
+
+#if HAVE_PSTAT_GETDYNAMIC
+  { /* This works on HP-UX.  */
+    struct pst_dynamic psd;
+    if (pstat_getdynamic (&psd, sizeof psd, 1, 0) >= 0)
+      {
+        /* The field psd_proc_cnt contains the number of active processors.
+           In newer releases of HP-UX 11, the field psd_max_proc_cnt includes
+           deactivated processors.  */
+        if (query == NPROC_CURRENT)
+          {
+            if (psd.psd_proc_cnt > 0)
+              return psd.psd_proc_cnt;
+          }
+        else
+          {
+            if (psd.psd_max_proc_cnt > 0)
+              return psd.psd_max_proc_cnt;
+          }
+      }
+  }
+#endif
+
+#if HAVE_SYSMP && defined MP_NAPROCS && defined MP_NPROCS
+  { /* This works on IRIX.  */
+    /* MP_NPROCS yields the number of installed processors.
+       MP_NAPROCS yields the number of processors available to unprivileged
+       processes.  */
+    int nprocs =
+      sysmp (query == NPROC_CURRENT && getpid () != 0
+             ? MP_NAPROCS
+             : MP_NPROCS);
+    if (nprocs > 0)
+      return nprocs;
+  }
+#endif
+
+  /* Finally, as fallback, use the APIs that don't distinguish between
+     NPROC_CURRENT and NPROC_ALL.  */
+
+#if HAVE_SYSCTL && defined HW_NCPU
+  { /* This works on MacOS X, FreeBSD, NetBSD, OpenBSD.  */
+    int nprocs;
+    size_t len = sizeof (nprocs);
+    static int mib[2] = { CTL_HW, HW_NCPU };
+
+    if (sysctl (mib, ARRAY_SIZE (mib), &nprocs, &len, NULL, 0) == 0
+        && len == sizeof (nprocs)
+        && 0 < nprocs)
+      return nprocs;
+  }
+#endif
+
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+  { /* This works on native Windows platforms.  */
+    SYSTEM_INFO system_info;
+    GetSystemInfo (&system_info);
+    if (0 < system_info.dwNumberOfProcessors)
+      return system_info.dwNumberOfProcessors;
+  }
+#endif
+
+  return 1;
+}
diff --git a/lib/nproc.h b/lib/nproc.h
new file mode 100644
index 0000000..56af19e
--- /dev/null
+++ b/lib/nproc.h
@@ -0,0 +1,47 @@
+/* Detect the number of processors.
+
+   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+
+   This program 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, or (at your option)
+   any later version.
+
+   This program 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 this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* Written by Glen Lenker and Bruno Haible.  */
+
+/* Allow the use in C++ code.  */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* A "processor" in this context means a thread execution unit, that is either
+   - an execution core in a (possibly multi-core) chip, in a (possibly multi-
+     chip) module, in a single computer, or
+   - a thread execution unit inside a core
+     (hyper-threading, see <http://en.wikipedia.org/wiki/Hyper-threading>).
+   Which of the two definitions is used, is unspecified.  */
+
+enum nproc_query
+{
+  NPROC_ALL,                 /* total number of processors */
+  NPROC_CURRENT,             /* processors available to the current process */
+  NPROC_CURRENT_OVERRIDABLE  /* likewise, but overridable through the
+                                OMP_NUM_THREADS environment variable */
+};
+
+/* Return the total number of processors.  The result is guaranteed to
+   be at least 1.  */
+extern unsigned long int num_processors (enum nproc_query query);
+
+#ifdef __cplusplus
+}
+#endif /* C++ */
diff --git a/lib/printf-parse.c b/lib/printf-parse.c
index d88ddf3..8c68fda 100644
--- a/lib/printf-parse.c
+++ b/lib/printf-parse.c
@@ -206,6 +206,13 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, 
arguments *a)
                   dp->flags |= FLAG_ZERO;
                   cp++;
                 }
+#if __GLIBC__ >= 2 && !defined __UCLIBC__
+              else if (*cp == 'I')
+                {
+                  dp->flags |= FLAG_LOCALIZED;
+                  cp++;
+                }
+#endif
               else
                 break;
             }
diff --git a/lib/printf-parse.h b/lib/printf-parse.h
index 2cf965b..777bf4d 100644
--- a/lib/printf-parse.h
+++ b/lib/printf-parse.h
@@ -23,6 +23,10 @@
      ENABLE_UNISTDIO    Set to 1 to enable the unistdio extensions.
      STATIC             Set to 'static' to declare the function static.  */
 
+#if HAVE_FEATURES_H
+# include <features.h> /* for __GLIBC__, __UCLIBC__ */
+#endif
+
 #include "printf-args.h"
 
 
@@ -33,6 +37,9 @@
 #define FLAG_SPACE       8      /* space flag */
 #define FLAG_ALT        16      /* # flag */
 #define FLAG_ZERO       32
+#if __GLIBC__ >= 2 && !defined __UCLIBC__
+# define FLAG_LOCALIZED 64      /* I flag, uses localized digits */
+#endif
 
 /* arg_index value indicating that no argument is consumed.  */
 #define ARG_NONE        (~(size_t)0)
diff --git a/lib/sockets.c b/lib/sockets.c
new file mode 100644
index 0000000..a853c8c
--- /dev/null
+++ b/lib/sockets.c
@@ -0,0 +1,118 @@
+/* sockets.c --- wrappers for Windows socket functions
+
+   Copyright (C) 2008-2010 Free Software Foundation, Inc.
+
+   This program 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 3 of the License, or
+   (at your option) any later version.
+
+   This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Simon Josefsson */
+
+#include <config.h>
+
+/* Specification.  */
+#include "sockets.h"
+
+#if WINDOWS_SOCKETS
+
+/* This includes winsock2.h on MinGW. */
+# include <sys/socket.h>
+
+# include "close-hook.h"
+
+/* Get set_winsock_errno, FD_TO_SOCKET etc. */
+# include "w32sock.h"
+
+static int
+close_fd_maybe_socket (int fd, const struct close_hook *remaining_list)
+{
+  SOCKET sock;
+  WSANETWORKEVENTS ev;
+
+  /* Test whether fd refers to a socket.  */
+  sock = FD_TO_SOCKET (fd);
+  ev.lNetworkEvents = 0xDEADBEEF;
+  WSAEnumNetworkEvents (sock, NULL, &ev);
+  if (ev.lNetworkEvents != 0xDEADBEEF)
+    {
+      /* fd refers to a socket.  */
+      /* FIXME: other applications, like squid, use an undocumented
+         _free_osfhnd free function.  But this is not enough: The 'osfile'
+         flags for fd also needs to be cleared, but it is hard to access it.
+         Instead, here we just close twice the file descriptor.  */
+      if (closesocket (sock))
+        {
+          set_winsock_errno ();
+          return -1;
+        }
+      else
+        {
+          /* This call frees the file descriptor and does a
+             CloseHandle ((HANDLE) _get_osfhandle (fd)), which fails.  */
+          _close (fd);
+          return 0;
+        }
+    }
+  else
+    /* Some other type of file descriptor.  */
+    return execute_close_hooks (fd, remaining_list);
+}
+
+static struct close_hook close_sockets_hook;
+
+static int initialized_sockets_version /* = 0 */;
+
+#endif /* WINDOWS_SOCKETS */
+
+int
+gl_sockets_startup (int version _GL_UNUSED)
+{
+#if WINDOWS_SOCKETS
+  if (version > initialized_sockets_version)
+    {
+      WSADATA data;
+      int err;
+
+      err = WSAStartup (version, &data);
+      if (err != 0)
+        return 1;
+
+      if (data.wVersion < version)
+        return 2;
+
+      if (initialized_sockets_version == 0)
+        register_close_hook (close_fd_maybe_socket, &close_sockets_hook);
+
+      initialized_sockets_version = version;
+    }
+#endif
+
+  return 0;
+}
+
+int
+gl_sockets_cleanup (void)
+{
+#if WINDOWS_SOCKETS
+  int err;
+
+  initialized_sockets_version = 0;
+
+  unregister_close_hook (&close_sockets_hook);
+
+  err = WSACleanup ();
+  if (err != 0)
+    return 1;
+#endif
+
+  return 0;
+}
diff --git a/lib/sockets.h b/lib/sockets.h
new file mode 100644
index 0000000..0ecedce
--- /dev/null
+++ b/lib/sockets.h
@@ -0,0 +1,51 @@
+/* sockets.h - wrappers for Windows socket functions
+
+   Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
+
+   This program 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 3 of the License, or
+   (at your option) any later version.
+
+   This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Simon Josefsson */
+
+#ifndef SOCKETS_H
+# define SOCKETS_H 1
+
+#define SOCKETS_1_0 0x100  /* don't use - does not work on Windows XP */
+#define SOCKETS_1_1 0x101
+#define SOCKETS_2_0 0x200  /* don't use - does not work on Windows XP */
+#define SOCKETS_2_1 0x201
+#define SOCKETS_2_2 0x202
+
+int gl_sockets_startup (int version);
+int gl_sockets_cleanup (void);
+
+/* This function is useful it you create a socket using gnulib's
+   Winsock wrappers but needs to pass on the socket handle to some
+   other library that only accepts sockets. */
+#if WINDOWS_SOCKETS
+
+#include <sys/socket.h>
+
+static inline SOCKET
+gl_fd_to_handle (int fd)
+{
+  return _get_osfhandle (fd);
+}
+
+#else
+
+#define gl_fd_to_handle(x) (x)
+
+#endif /* WINDOWS_SOCKETS */
+
+#endif /* SOCKETS_H */
diff --git a/lib/stdarg.in.h b/lib/stdarg.in.h
index 4bbd01e..1062a12 100644
--- a/lib/stdarg.in.h
+++ b/lib/stdarg.in.h
@@ -20,6 +20,7 @@
 #if __GNUC__ >= 3
 @PRAGMA_SYSTEM_HEADER@
 #endif
address@hidden@
 
 /* The include_next requires a split double-inclusion guard.  */
 address@hidden@ @NEXT_STDARG_H@
diff --git a/lib/stddef.in.h b/lib/stddef.in.h
index b1dfb67..a69683e 100644
--- a/lib/stddef.in.h
+++ b/lib/stddef.in.h
@@ -26,6 +26,7 @@
 #if __GNUC__ >= 3
 @PRAGMA_SYSTEM_HEADER@
 #endif
address@hidden@
 
 #if defined __need_wchar_t || defined __need_size_t  \
   || defined __need_ptrdiff_t || defined __need_NULL \
diff --git a/lib/stdint.in.h b/lib/stdint.in.h
index 997e406..db1eec8 100644
--- a/lib/stdint.in.h
+++ b/lib/stdint.in.h
@@ -26,6 +26,7 @@
 #if __GNUC__ >= 3
 @PRAGMA_SYSTEM_HEADER@
 #endif
address@hidden@
 
 /* When including a system file that in turn includes <inttypes.h>,
    use the system <inttypes.h>, not our substitute.  This avoids
@@ -133,40 +134,53 @@ typedef unsigned int gl_uint32_t;
 #define int32_t gl_int32_t
 #define uint32_t gl_uint32_t
 
+/* If the system defines INT64_MAX, assume int64_t works.  That way,
+   if the underlying platform defines int64_t to be a 64-bit long long
+   int, the code below won't mistakenly define it to be a 64-bit long
+   int, which would mess up C++ name mangling.  */
+
+#if INT64_MAX
+# define GL_INT64_T
+#else
 /* Do not undefine int64_t if gnulib is not being used with 64-bit
    types, since otherwise it breaks platforms like Tandem/NSK.  */
-#if LONG_MAX >> 31 >> 31 == 1
-# undef int64_t
+# if LONG_MAX >> 31 >> 31 == 1
+#  undef int64_t
 typedef long int gl_int64_t;
-# define int64_t gl_int64_t
-# define GL_INT64_T
-#elif defined _MSC_VER
-# undef int64_t
+#  define int64_t gl_int64_t
+#  define GL_INT64_T
+# elif defined _MSC_VER
+#  undef int64_t
 typedef __int64 gl_int64_t;
-# define int64_t gl_int64_t
-# define GL_INT64_T
-#elif @HAVE_LONG_LONG_INT@
-# undef int64_t
+#  define int64_t gl_int64_t
+#  define GL_INT64_T
+# elif @HAVE_LONG_LONG_INT@
+#  undef int64_t
 typedef long long int gl_int64_t;
-# define int64_t gl_int64_t
-# define GL_INT64_T
+#  define int64_t gl_int64_t
+#  define GL_INT64_T
+# endif
 #endif
 
-#if ULONG_MAX >> 31 >> 31 >> 1 == 1
-# undef uint64_t
-typedef unsigned long int gl_uint64_t;
-# define uint64_t gl_uint64_t
+#if UINT64_MAX
 # define GL_UINT64_T
-#elif defined _MSC_VER
-# undef uint64_t
+#else
+# if ULONG_MAX >> 31 >> 31 >> 1 == 1
+#  undef uint64_t
+typedef unsigned long int gl_uint64_t;
+#  define uint64_t gl_uint64_t
+#  define GL_UINT64_T
+# elif defined _MSC_VER
+#  undef uint64_t
 typedef unsigned __int64 gl_uint64_t;
-# define uint64_t gl_uint64_t
-# define GL_UINT64_T
-#elif @HAVE_UNSIGNED_LONG_LONG_INT@
-# undef uint64_t
+#  define uint64_t gl_uint64_t
+#  define GL_UINT64_T
+# elif @HAVE_UNSIGNED_LONG_LONG_INT@
+#  undef uint64_t
 typedef unsigned long long int gl_uint64_t;
-# define uint64_t gl_uint64_t
-# define GL_UINT64_T
+#  define uint64_t gl_uint64_t
+#  define GL_UINT64_T
+# endif
 #endif
 
 /* Avoid collision with Solaris 2.5.1 <pthread.h> etc.  */
@@ -278,7 +292,8 @@ typedef unsigned long int gl_uintmax_t;
 /* Verify that intmax_t and uintmax_t have the same size.  Too much code
    breaks if this is not the case.  If this check fails, the reason is likely
    to be found in the autoconf macros.  */
-typedef int _verify_intmax_size[2 * (sizeof (intmax_t) == sizeof (uintmax_t)) 
- 1];
+typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
+                                ? 1 : -1];
 
 /* 7.18.2. Limits of specified-width integer types */
 
@@ -310,17 +325,14 @@ typedef int _verify_intmax_size[2 * (sizeof (intmax_t) == 
sizeof (uintmax_t)) -
 #define INT32_MAX  2147483647
 #define UINT32_MAX  4294967295U
 
-#undef INT64_MIN
-#undef INT64_MAX
-#ifdef GL_INT64_T
+#if defined GL_INT64_T && ! defined INT64_MAX
 /* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0
    evaluates the latter incorrectly in preprocessor expressions.  */
 # define INT64_MIN  (- INTMAX_C (1) << 63)
 # define INT64_MAX  INTMAX_C (9223372036854775807)
 #endif
 
-#undef UINT64_MAX
-#ifdef GL_UINT64_T
+#if defined GL_UINT64_T && ! defined UINT64_MAX
 # define UINT64_MAX  UINTMAX_C (18446744073709551615)
 #endif
 
@@ -475,8 +487,9 @@ typedef int _verify_intmax_size[2 * (sizeof (intmax_t) == 
sizeof (uintmax_t)) -
 
 /* wchar_t limits */
 /* Get WCHAR_MIN, WCHAR_MAX.
-   This include is not on the top, above, because on OSF/1 4.0 we have a 
sequence of nested
-   includes <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter 
includes
+   This include is not on the top, above, because on OSF/1 4.0 we have a
+   sequence of nested includes
+   <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes
    <stdint.h> and assumes its types are already defined.  */
 #if ! (defined WCHAR_MIN && defined WCHAR_MAX)
 # define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index d39b7dd..fbd096a 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -19,6 +19,7 @@
 #if __GNUC__ >= 3
 @PRAGMA_SYSTEM_HEADER@
 #endif
address@hidden@
 
 #if defined __need_FILE || defined __need___FILE
 /* Special invocation convention inside glibc header files.  */
@@ -56,6 +57,13 @@
 # endif
 #endif
 
+/* Solaris 10 declares renameat in <unistd.h>, not in <stdio.h>.  */
+/* But in any case avoid namespace pollution on glibc systems.  */
+#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __sun \
+    && ! defined __GLIBC__
+# include <unistd.h>
+#endif
+
 
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
@@ -265,7 +273,8 @@ _GL_CXXALIASWARN (freopen);
 #elif defined GNULIB_POSIXCHECK
 # undef freopen
 /* Assume freopen is always declared.  */
-_GL_WARN_ON_USE (freopen, "freopen on Win32 platforms is not POSIX compatible 
- "
+_GL_WARN_ON_USE (freopen,
+                 "freopen on Win32 platforms is not POSIX compatible - "
                  "use gnulib module freopen for portability");
 #endif
 
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index 6834a3e..04f32b6 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -18,6 +18,7 @@
 #if __GNUC__ >= 3
 @PRAGMA_SYSTEM_HEADER@
 #endif
address@hidden@
 
 #if defined __need_malloc_and_calloc
 /* Special invocation convention inside glibc header files.  */
@@ -38,6 +39,11 @@
 /* NetBSD 5.0 mis-defines NULL.  */
 #include <stddef.h>
 
+/* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>.  */
+#if @GNULIB_SYSTEM_POSIX@ && !defined WEXITSTATUS
+# include <sys/wait.h>
+#endif
+
 /* Solaris declares getloadavg() in <sys/loadavg.h>.  */
 #if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@
 # include <sys/loadavg.h>
@@ -55,6 +61,9 @@
 #endif
 
 #if address@hidden@
+/* Define 'struct random_data'.
+   But allow multiple gnulib generated <stdlib.h> replacements to coexist.  */
+# if !GNULIB_defined_struct_random_data
 struct random_data
 {
   int32_t *fptr;                /* Front pointer.  */
@@ -65,6 +74,8 @@ struct random_data
   int rand_sep;                 /* Distance between front and rear.  */
   int32_t *end_ptr;             /* Pointer behind state table.  */
 };
+#  define GNULIB_defined_struct_random_data 1
+# endif
 #endif
 
 #if (@GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! 
defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined 
__CYGWIN__)
@@ -172,7 +183,8 @@ _GL_CXXALIASWARN (canonicalize_file_name);
 #elif defined GNULIB_POSIXCHECK
 # undef canonicalize_file_name
 # if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
-_GL_WARN_ON_USE (canonicalize_file_name, "canonicalize_file_name is unportable 
- "
+_GL_WARN_ON_USE (canonicalize_file_name,
+                 "canonicalize_file_name is unportable - "
                  "use gnulib module canonicalize-lgpl for portability");
 # endif
 #endif
@@ -675,7 +687,7 @@ _GL_CXXALIASWARN (unlockpt);
 #elif defined GNULIB_POSIXCHECK
 # undef unlockpt
 # if HAVE_RAW_DECL_UNLOCKPT
-_GL_WARN_ON_USE (ptsname, "unlockpt is not portable - "
+_GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - "
                  "use gnulib module unlockpt for portability");
 # endif
 #endif
diff --git a/lib/striconveh.c b/lib/striconveh.c
index 8db6677..4fa4ea0 100644
--- a/lib/striconveh.c
+++ b/lib/striconveh.c
@@ -52,7 +52,8 @@ iconveh_open (const char *to_codeset, const char 
*from_codeset, iconveh_t *cdp)
   iconv_t cd2;
 
   /* Avoid glibc-2.1 bug with EUC-KR.  */
-# if (__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) && !defined 
_LIBICONV_VERSION
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
+     && !defined _LIBICONV_VERSION
   if (c_strcasecmp (from_codeset, "EUC-KR") == 0
       || c_strcasecmp (to_codeset, "EUC-KR") == 0)
     {
@@ -79,7 +80,9 @@ iconveh_open (const char *to_codeset, const char 
*from_codeset, iconveh_t *cdp)
     }
 
   if (STRCASEEQ (to_codeset, "UTF-8", 'U','T','F','-','8',0,0,0,0)
-# if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2 || 
_LIBICONV_VERSION >= 0x0105
+# if (((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2) \
+      && !defined __UCLIBC__) \
+     || _LIBICONV_VERSION >= 0x0105
       || c_strcasecmp (to_codeset, "UTF-8//TRANSLIT") == 0
 # endif
      )
@@ -136,7 +139,7 @@ iconveh_close (const iconveh_t *cd)
 /* iconv_carefully is like iconv, except that it stops as soon as it encounters
    a conversion error, and it returns in *INCREMENTED a boolean telling whether
    it has incremented the input pointers past the error location.  */
-# if !defined _LIBICONV_VERSION && !defined __GLIBC__
+# if !defined _LIBICONV_VERSION && !(defined __GLIBC__ && !defined __UCLIBC__)
 /* Irix iconv() inserts a NUL byte if it cannot convert.
    NetBSD iconv() inserts a question mark if it cannot convert.
    Only GNU libiconv and GNU libc are known to prefer to fail rather
@@ -244,7 +247,7 @@ iconv_carefully_1 (iconv_t cd,
 
   *inbuf = inptr;
   *inbytesleft = inptr_end - inptr;
-# if !defined _LIBICONV_VERSION && !defined __GLIBC__
+# if !defined _LIBICONV_VERSION && !(defined __GLIBC__ && !defined __UCLIBC__)
   /* Irix iconv() inserts a NUL byte if it cannot convert.
      NetBSD iconv() inserts a question mark if it cannot convert.
      Only GNU libiconv and GNU libc are known to prefer to fail rather
@@ -403,7 +406,8 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
 
     /* Avoid glibc-2.1 bug and Solaris 2.7-2.9 bug.  */
 # if defined _LIBICONV_VERSION \
-     || !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun)
+     || !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
+          || defined __sun)
     /* Set to the initial state.  */
     iconv (cd, NULL, NULL, NULL, NULL);
 # endif
@@ -531,7 +535,8 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
   /* Now get the conversion state back to the initial state.
      But avoid glibc-2.1 bug and Solaris 2.7 bug.  */
 #if defined _LIBICONV_VERSION \
-    || !((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) || defined __sun)
+    || !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
+         || defined __sun)
   for (;;)
     {
       char *outptr = result + length;
@@ -606,7 +611,8 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
 
     /* Avoid glibc-2.1 bug and Solaris 2.7-2.9 bug.  */
 # if defined _LIBICONV_VERSION \
-     || !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun)
+     || !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
+          || defined __sun)
     /* Set to the initial state.  */
     if (cd1 != (iconv_t)(-1))
       iconv (cd1, NULL, NULL, NULL, NULL);
@@ -658,7 +664,8 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
             /* Now get the conversion state of CD1 back to the initial state.
                But avoid glibc-2.1 bug and Solaris 2.7 bug.  */
 # if defined _LIBICONV_VERSION \
-     || !((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) || defined __sun)
+     || !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
+          || defined __sun)
             if (cd1 != (iconv_t)(-1))
               res1 = iconv (cd1, NULL, NULL, &out1ptr, &out1size);
             else
@@ -740,7 +747,8 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
                     /* Now get the conversion state of CD1 back to the initial
                        state.  But avoid glibc-2.1 bug and Solaris 2.7 bug.  */
 # if defined _LIBICONV_VERSION \
-     || !((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) || defined __sun)
+     || !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
+          || defined __sun)
                     if (cd2 != (iconv_t)(-1))
                       res2 = iconv (cd2, NULL, NULL, &out2ptr, &out2size);
                     else
@@ -883,7 +891,7 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
                               }
                             length = out2ptr - result;
                           }
-# if !defined _LIBICONV_VERSION && !defined __GLIBC__
+# if !defined _LIBICONV_VERSION && !(defined __GLIBC__ && !defined __UCLIBC__)
                         /* Irix iconv() inserts a NUL byte if it cannot 
convert.
                            NetBSD iconv() inserts a question mark if it cannot
                            convert.
diff --git a/lib/striconveh.h b/lib/striconveh.h
index dc92cea..1f1c3bc 100644
--- a/lib/striconveh.h
+++ b/lib/striconveh.h
@@ -33,7 +33,7 @@ extern "C" {
 
 #if HAVE_ICONV
 
-/* An conversion descriptor for use by the iconveh functions.  */
+/* A conversion descriptor for use by the iconveh functions.  */
 typedef struct
   {
     /* Conversion descriptor from FROM_CODESET to TO_CODESET, or (iconv_t)(-1)
diff --git a/lib/string.in.h b/lib/string.in.h
index 21045fe..57c1019 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -21,6 +21,7 @@
 #if __GNUC__ >= 3
 @PRAGMA_SYSTEM_HEADER@
 #endif
address@hidden@
 
 /* The include_next requires a split double-inclusion guard.  */
 address@hidden@ @NEXT_STRING_H@
@@ -49,6 +50,12 @@
 # define _GL_ATTRIBUTE_PURE /* empty */
 #endif
 
+/* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>.  */
+/* But in any case avoid namespace pollution on glibc systems.  */
+#if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \
+    && ! defined __GLIBC__
+# include <unistd.h>
+#endif
 
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
@@ -80,7 +87,7 @@ _GL_CXXALIAS_SYS_CAST2 (memchr,
                         void *, (void const *__s, int __c, size_t __n),
                         void const *, (void const *__s, int __c, size_t __n));
 # endif
-# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
 _GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n));
 _GL_CXXALIASWARN1 (memchr, void const *,
@@ -165,7 +172,7 @@ _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, 
size_t)
 _GL_CXXALIAS_SYS_CAST2 (memrchr,
                         void *, (void const *, int, size_t),
                         void const *, (void const *, int, size_t));
-# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
 _GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t));
 _GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t));
@@ -195,7 +202,7 @@ _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int 
__c_in)
 _GL_CXXALIAS_SYS_CAST2 (rawmemchr,
                         void *, (void const *__s, int __c_in),
                         void const *, (void const *__s, int __c_in));
-# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
 _GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in));
 _GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in));
@@ -286,7 +293,7 @@ _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int 
__c_in)
 _GL_CXXALIAS_SYS_CAST2 (strchrnul,
                         char *, (char const *__s, int __c_in),
                         char const *, (char const *__s, int __c_in));
-# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
 _GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in));
 _GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in));
@@ -432,7 +439,7 @@ _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char 
const *__accept)
 _GL_CXXALIAS_SYS_CAST2 (strpbrk,
                         char *, (char const *__s, char const *__accept),
                         const char *, (char const *__s, char const *__accept));
-# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
 _GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept));
 _GL_CXXALIASWARN1 (strpbrk, char const *,
@@ -534,7 +541,7 @@ _GL_CXXALIAS_SYS_CAST2 (strstr,
                         char *, (const char *haystack, const char *needle),
                         const char *, (const char *haystack, const char 
*needle));
 # endif
-# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
 _GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle));
 _GL_CXXALIASWARN1 (strstr, const char *,
@@ -583,7 +590,7 @@ _GL_CXXALIAS_SYS_CAST2 (strcasestr,
                         char *, (const char *haystack, const char *needle),
                         const char *, (const char *haystack, const char 
*needle));
 # endif
-# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
 _GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle));
 _GL_CXXALIASWARN1 (strcasestr, const char *,
@@ -895,6 +902,35 @@ _GL_WARN_ON_USE (strerror, "strerror is unportable - "
                  "use gnulib module strerror to guarantee non-NULL result");
 #endif
 
+/* Map any int, typically from errno, into an error message.  Multithread-safe.
+   Uses the POSIX declaration, not the glibc declaration.  */
+#if @GNULIB_STRERROR_R@
+# if @REPLACE_STRERROR_R@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef strerror_r
+#   define strerror_r rpl_strerror_r
+#  endif
+_GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)
+                                   _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)
+                                   _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen));
+# endif
+# if @HAVE_DECL_STRERROR_R@
+_GL_CXXALIASWARN (strerror_r);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strerror_r
+# if HAVE_RAW_DECL_STRERROR_R
+_GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
+                 "use gnulib module strerror_r-posix for portability");
+# endif
+#endif
+
 #if @GNULIB_STRSIGNAL@
 # if @REPLACE_STRSIGNAL@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
diff --git a/lib/strings.in.h b/lib/strings.in.h
index b2cf2cf..83b5823 100644
--- a/lib/strings.in.h
+++ b/lib/strings.in.h
@@ -21,6 +21,7 @@
 #if __GNUC__ >= 3
 @PRAGMA_SYSTEM_HEADER@
 #endif
address@hidden@
 
 /* The include_next requires a split double-inclusion guard.  */
 address@hidden@ @NEXT_STRINGS_H@
diff --git a/lib/sys_file.in.h b/lib/sys_file.in.h
index 9868850..c879f23 100644
--- a/lib/sys_file.in.h
+++ b/lib/sys_file.in.h
@@ -23,6 +23,7 @@
 #if __GNUC__ >= 3
 @PRAGMA_SYSTEM_HEADER@
 #endif
address@hidden@
 
 /* The include_next requires a split double-inclusion guard.  */
 #if @HAVE_SYS_FILE_H@
diff --git a/lib/sys_socket.in.h b/lib/sys_socket.in.h
index e62a8d0..5c84627 100644
--- a/lib/sys_socket.in.h
+++ b/lib/sys_socket.in.h
@@ -26,6 +26,7 @@
 #if __GNUC__ >= 3
 @PRAGMA_SYSTEM_HEADER@
 #endif
address@hidden@
 
 #if defined _GL_ALREADY_INCLUDING_SYS_SOCKET_H
 /* Special invocation convention:
@@ -69,7 +70,14 @@
 typedef unsigned short  sa_family_t;
 #endif
 
-#if address@hidden@
+#if @HAVE_STRUCT_SOCKADDR_STORAGE@
+/* Make the 'struct sockaddr_storage' field 'ss_family' visible on AIX 7.1.  */
+# if address@hidden@
+#  ifndef ss_family
+#   define ss_family __ss_family
+#  endif
+# endif
+#else
 # include <alignof.h>
 /* Code taken from glibc sysdeps/unix/sysv/linux/bits/socket.h on
    2009-05-08, licensed under LGPLv2.1+, plus portability fixes. */
@@ -122,8 +130,8 @@ struct sockaddr_storage
    adding AC_DEFINE(WINVER, 0x0501) to configure.ac.  Note that your
    code may not run on older Windows releases then.  My Windows 2000
    box was not able to run the code, for example.  The situation is
-   slightly confusing because:
-   
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/getaddrinfo_2.asp
+   slightly confusing because
+   <http://msdn.microsoft.com/en-us/library/ms738520>
    suggests that getaddrinfo should be available on all Windows
    releases. */
 
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index 69a307d..920da9a 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -24,6 +24,7 @@
 #if __GNUC__ >= 3
 @PRAGMA_SYSTEM_HEADER@
 #endif
address@hidden@
 
 #if defined __need_system_sys_stat_h
 /* Special invocation convention.  */
@@ -594,7 +595,8 @@ _GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
 #  else /* !_LARGE_FILES */
 #   define stat(name, st) rpl_stat (name, st)
 #  endif /* !_LARGE_FILES */
-_GL_EXTERN_C int stat (const char *name, struct stat *buf) _GL_ARG_NONNULL 
((1, 2));
+_GL_EXTERN_C int stat (const char *name, struct stat *buf)
+                      _GL_ARG_NONNULL ((1, 2));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef stat
diff --git a/lib/time.in.h b/lib/time.in.h
index 83b337d..e2974cd 100644
--- a/lib/time.in.h
+++ b/lib/time.in.h
@@ -19,6 +19,7 @@
 #if __GNUC__ >= 3
 @PRAGMA_SYSTEM_HEADER@
 #endif
address@hidden@
 
 /* Don't get in the way of glibc when it includes time.h merely to
    declare a few standard symbols, rather than to declare all the
@@ -83,6 +84,15 @@ struct timespec
 #  endif
 # endif
 
+/* Per http://austingroupbugs.net/view.php?id=327, POSIX requires
+   time_t to be an integer type, even though C99 permits floating
+   point.  We don't know of any implementation that uses floating
+   point, and it is much easier to write code that doesn't have to
+   worry about that corner case, so we force the issue.  */
+struct __time_t_must_be_integral {
+  unsigned int __floating_time_t_unsupported : (time_t) 1;
+};
+
 /* Sleep for at least RQTP seconds unless interrupted,  If interrupted,
    return -1 and store the remaining time into RMTP.  See
    <http://www.opengroup.org/susv3xsh/nanosleep.html>.  */
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 005ae97..8955f39 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -18,6 +18,7 @@
 #if __GNUC__ >= 3
 @PRAGMA_SYSTEM_HEADER@
 #endif
address@hidden@
 
 /* Special invocation convention:
    - On mingw, several headers, including <winsock2.h>, include <unistd.h>,
@@ -60,14 +61,16 @@
 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>.  */
 /* But avoid namespace pollution on glibc systems.  */
 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
-     || (@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK)) \
+     || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
+         && defined __CYGWIN__)) \
     && ! defined __GLIBC__
 # include <stdio.h>
 #endif
 
 /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>.  */
 /* But avoid namespace pollution on glibc systems.  */
-#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__
+#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \
+    && ! defined __GLIBC__
 # include <fcntl.h>
 #endif
 
@@ -85,6 +88,13 @@
 # include <io.h>
 #endif
 
+/* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.  */
+/* But avoid namespace pollution on glibc systems.  */
+#if @GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__) \
+    && !defined __GLIBC__
+# include <netdb.h>
+#endif
+
 #if (@GNULIB_WRITE@ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
      || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
 /* Get ssize_t.  */
@@ -548,13 +558,21 @@ _GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
    Null terminate it if the name is shorter than LEN.
    If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
    Return 0 if successful, otherwise set errno and return -1.  */
-# if address@hidden@
+# if @REPLACE_GETDOMAINNAME@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef getdomainname
+#   define getdomainname rpl_getdomainname
+#  endif
+_GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len)
+                                      _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len));
+# else
+#  if address@hidden@
 _GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
                                       _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len));
 # endif
-/* Need to cast, because on MacOS X 10.5 systems, the second parameter is
-                                                        int len.  */
-_GL_CXXALIAS_SYS_CAST (getdomainname, int, (char *name, size_t len));
 _GL_CXXALIASWARN (getdomainname);
 #elif defined GNULIB_POSIXCHECK
 # undef getdomainname
diff --git a/lib/unistr.in.h b/lib/unistr.in.h
index 26a3e33..2164d9d 100644
--- a/lib/unistr.in.h
+++ b/lib/unistr.in.h
@@ -134,7 +134,7 @@ extern int
 /* The variants with _safe suffix are safe, even if the library is compiled
    without --enable-safety.  */
 
-#ifdef GNULIB_UNISTR_U8_MBTOUC_UNSAFE
+#if defined GNULIB_UNISTR_U8_MBTOUC_UNSAFE || HAVE_LIBUNISTRING
 # if !HAVE_INLINE
 extern int
        u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n);
@@ -157,7 +157,7 @@ u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n)
 # endif
 #endif
 
-#ifdef GNULIB_UNISTR_U16_MBTOUC_UNSAFE
+#if defined GNULIB_UNISTR_U16_MBTOUC_UNSAFE || HAVE_LIBUNISTRING
 # if !HAVE_INLINE
 extern int
        u16_mbtouc_unsafe (ucs4_t *puc, const uint16_t *s, size_t n);
@@ -180,7 +180,7 @@ u16_mbtouc_unsafe (ucs4_t *puc, const uint16_t *s, size_t n)
 # endif
 #endif
 
-#ifdef GNULIB_UNISTR_U32_MBTOUC_UNSAFE
+#if defined GNULIB_UNISTR_U32_MBTOUC_UNSAFE || HAVE_LIBUNISTRING
 # if !HAVE_INLINE
 extern int
        u32_mbtouc_unsafe (ucs4_t *puc, const uint32_t *s, size_t n);
@@ -191,11 +191,11 @@ u32_mbtouc_unsafe (ucs4_t *puc,
 {
   uint32_t c = *s;
 
-#  if CONFIG_UNICODE_SAFETY
+#  ifdef CONFIG_UNICODE_SAFETY
   if (c < 0xd800 || (c >= 0xe000 && c < 0x110000))
 #  endif
     *puc = c;
-#  if CONFIG_UNICODE_SAFETY
+#  ifdef CONFIG_UNICODE_SAFETY
   else
     /* invalid multibyte character */
     *puc = 0xfffd;
@@ -205,7 +205,7 @@ u32_mbtouc_unsafe (ucs4_t *puc,
 # endif
 #endif
 
-#ifdef GNULIB_UNISTR_U8_MBTOUC
+#if defined GNULIB_UNISTR_U8_MBTOUC || HAVE_LIBUNISTRING
 # if !HAVE_INLINE
 extern int
        u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n);
@@ -228,7 +228,7 @@ u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n)
 # endif
 #endif
 
-#ifdef GNULIB_UNISTR_U16_MBTOUC
+#if defined GNULIB_UNISTR_U16_MBTOUC || HAVE_LIBUNISTRING
 # if !HAVE_INLINE
 extern int
        u16_mbtouc (ucs4_t *puc, const uint16_t *s, size_t n);
@@ -251,7 +251,7 @@ u16_mbtouc (ucs4_t *puc, const uint16_t *s, size_t n)
 # endif
 #endif
 
-#ifdef GNULIB_UNISTR_U32_MBTOUC
+#if defined GNULIB_UNISTR_U32_MBTOUC || HAVE_LIBUNISTRING
 # if !HAVE_INLINE
 extern int
        u32_mbtouc (ucs4_t *puc, const uint32_t *s, size_t n);
@@ -279,17 +279,17 @@ u32_mbtouc (ucs4_t *puc, const uint32_t *s, size_t n 
_GL_UNUSED_PARAMETER)
 /* Similar to u*_mbtouc(), except that the return value gives more details
    about the failure, similar to mbrtowc().  */
 
-#ifdef GNULIB_UNISTR_U8_MBTOUCR
+#if defined GNULIB_UNISTR_U8_MBTOUCR || HAVE_LIBUNISTRING
 extern int
        u8_mbtoucr (ucs4_t *puc, const uint8_t *s, size_t n);
 #endif
 
-#ifdef GNULIB_UNISTR_U16_MBTOUCR
+#if defined GNULIB_UNISTR_U16_MBTOUCR || HAVE_LIBUNISTRING
 extern int
        u16_mbtoucr (ucs4_t *puc, const uint16_t *s, size_t n);
 #endif
 
-#ifdef GNULIB_UNISTR_U32_MBTOUCR
+#if defined GNULIB_UNISTR_U32_MBTOUCR || HAVE_LIBUNISTRING
 extern int
        u32_mbtoucr (ucs4_t *puc, const uint32_t *s, size_t n);
 #endif
@@ -300,7 +300,7 @@ extern int
 /* Similar to wctomb(), except that s must not be NULL, and the argument n
    must be specified.  */
 
-#ifdef GNULIB_UNISTR_U8_UCTOMB
+#if defined GNULIB_UNISTR_U8_UCTOMB || HAVE_LIBUNISTRING
 /* Auxiliary function, also used by u8_chr, u8_strchr, u8_strrchr.  */
 extern int
        u8_uctomb_aux (uint8_t *s, ucs4_t uc, int n);
@@ -322,7 +322,7 @@ u8_uctomb (uint8_t *s, ucs4_t uc, int n)
 # endif
 #endif
 
-#ifdef GNULIB_UNISTR_U16_UCTOMB
+#if defined GNULIB_UNISTR_U16_UCTOMB || HAVE_LIBUNISTRING
 /* Auxiliary function, also used by u16_chr, u16_strchr, u16_strrchr.  */
 extern int
        u16_uctomb_aux (uint16_t *s, ucs4_t uc, int n);
@@ -344,7 +344,7 @@ u16_uctomb (uint16_t *s, ucs4_t uc, int n)
 # endif
 #endif
 
-#ifdef GNULIB_UNISTR_U32_UCTOMB
+#if defined GNULIB_UNISTR_U32_UCTOMB || HAVE_LIBUNISTRING
 # if !HAVE_INLINE
 extern int
        u32_uctomb (uint32_t *s, ucs4_t uc, int n);
@@ -559,8 +559,15 @@ extern uint32_t *
 
 /* Compare S1 and S2.  */
 /* Similar to strcmp(), wcscmp().  */
+#ifdef __sun
+/* Avoid a collision with the u8_strcmp() function in Solaris 11 libc.  */
+extern int
+       u8_strcmp_gnu (const uint8_t *s1, const uint8_t *s2);
+# define u8_strcmp u8_strcmp_gnu
+#else
 extern int
        u8_strcmp (const uint8_t *s1, const uint8_t *s2);
+#endif
 extern int
        u16_strcmp (const uint16_t *s1, const uint16_t *s2);
 extern int
diff --git a/lib/unistr/u8-mbtouc-aux.c b/lib/unistr/u8-mbtouc-aux.c
index c997589..3786802 100644
--- a/lib/unistr/u8-mbtouc-aux.c
+++ b/lib/unistr/u8-mbtouc-aux.c
@@ -45,21 +45,32 @@ u8_mbtouc_aux (ucs4_t *puc, const uint8_t *s, size_t n)
             {
               /* incomplete multibyte character */
               *puc = 0xfffd;
-              return n;
+              return 1;
             }
         }
       else if (c < 0xf0)
         {
           if (n >= 3)
             {
-              if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
-                  && (c >= 0xe1 || s[1] >= 0xa0)
-                  && (c != 0xed || s[1] < 0xa0))
+              if ((s[1] ^ 0x80) < 0x40)
                 {
-                  *puc = ((unsigned int) (c & 0x0f) << 12)
-                         | ((unsigned int) (s[1] ^ 0x80) << 6)
-                         | (unsigned int) (s[2] ^ 0x80);
-                  return 3;
+                  if ((s[2] ^ 0x80) < 0x40)
+                    {
+                      if ((c >= 0xe1 || s[1] >= 0xa0)
+                          && (c != 0xed || s[1] < 0xa0))
+                        {
+                          *puc = ((unsigned int) (c & 0x0f) << 12)
+                                 | ((unsigned int) (s[1] ^ 0x80) << 6)
+                                 | (unsigned int) (s[2] ^ 0x80);
+                          return 3;
+                        }
+                      /* invalid multibyte character */
+                      *puc = 0xfffd;
+                      return 3;
+                    }
+                  /* invalid multibyte character */
+                  *puc = 0xfffd;
+                  return 2;
                 }
               /* invalid multibyte character */
             }
@@ -67,26 +78,45 @@ u8_mbtouc_aux (ucs4_t *puc, const uint8_t *s, size_t n)
             {
               /* incomplete multibyte character */
               *puc = 0xfffd;
-              return n;
+              if (n == 1 || (s[1] ^ 0x80) >= 0x40)
+                return 1;
+              else
+                return 2;
             }
         }
       else if (c < 0xf8)
         {
           if (n >= 4)
             {
-              if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
-                  && (s[3] ^ 0x80) < 0x40
-                  && (c >= 0xf1 || s[1] >= 0x90)
+              if ((s[1] ^ 0x80) < 0x40)
+                {
+                  if ((s[2] ^ 0x80) < 0x40)
+                    {
+                      if ((s[3] ^ 0x80) < 0x40)
+                        {
+                          if ((c >= 0xf1 || s[1] >= 0x90)
 #if 1
-                  && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
+                              && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
 #endif
-                 )
-                {
-                  *puc = ((unsigned int) (c & 0x07) << 18)
-                         | ((unsigned int) (s[1] ^ 0x80) << 12)
-                         | ((unsigned int) (s[2] ^ 0x80) << 6)
-                         | (unsigned int) (s[3] ^ 0x80);
-                  return 4;
+                             )
+                            {
+                              *puc = ((unsigned int) (c & 0x07) << 18)
+                                     | ((unsigned int) (s[1] ^ 0x80) << 12)
+                                     | ((unsigned int) (s[2] ^ 0x80) << 6)
+                                     | (unsigned int) (s[3] ^ 0x80);
+                              return 4;
+                            }
+                          /* invalid multibyte character */
+                          *puc = 0xfffd;
+                          return 4;
+                        }
+                      /* invalid multibyte character */
+                      *puc = 0xfffd;
+                      return 3;
+                    }
+                  /* invalid multibyte character */
+                  *puc = 0xfffd;
+                  return 2;
                 }
               /* invalid multibyte character */
             }
@@ -94,7 +124,12 @@ u8_mbtouc_aux (ucs4_t *puc, const uint8_t *s, size_t n)
             {
               /* incomplete multibyte character */
               *puc = 0xfffd;
-              return n;
+              if (n == 1 || (s[1] ^ 0x80) >= 0x40)
+                return 1;
+              else if (n == 2 || (s[2] ^ 0x80) >= 0x40)
+                return 2;
+              else
+                return 3;
             }
         }
 #if 0
@@ -102,16 +137,37 @@ u8_mbtouc_aux (ucs4_t *puc, const uint8_t *s, size_t n)
         {
           if (n >= 5)
             {
-              if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
-                  && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
-                  && (c >= 0xf9 || s[1] >= 0x88))
+              if ((s[1] ^ 0x80) < 0x40)
                 {
-                  *puc = ((unsigned int) (c & 0x03) << 24)
-                         | ((unsigned int) (s[1] ^ 0x80) << 18)
-                         | ((unsigned int) (s[2] ^ 0x80) << 12)
-                         | ((unsigned int) (s[3] ^ 0x80) << 6)
-                         | (unsigned int) (s[4] ^ 0x80);
-                  return 5;
+                  if ((s[2] ^ 0x80) < 0x40)
+                    {
+                      if ((s[3] ^ 0x80) < 0x40)
+                        {
+                          if ((s[4] ^ 0x80) < 0x40)
+                            {
+                              if (c >= 0xf9 || s[1] >= 0x88)
+                                {
+                                  *puc = ((unsigned int) (c & 0x03) << 24)
+                                         | ((unsigned int) (s[1] ^ 0x80) << 18)
+                                         | ((unsigned int) (s[2] ^ 0x80) << 12)
+                                         | ((unsigned int) (s[3] ^ 0x80) << 6)
+                                         | (unsigned int) (s[4] ^ 0x80);
+                                  return 5;
+                                }
+                              /* invalid multibyte character */
+                              *puc = 0xfffd;
+                              return 5;
+                            }
+                          /* invalid multibyte character */
+                          *puc = 0xfffd;
+                          return 4;
+                        }
+                      /* invalid multibyte character */
+                      *puc = 0xfffd;
+                      return 3;
+                    }
+                  /* invalid multibyte character */
+                  return 2;
                 }
               /* invalid multibyte character */
             }
@@ -126,18 +182,44 @@ u8_mbtouc_aux (ucs4_t *puc, const uint8_t *s, size_t n)
         {
           if (n >= 6)
             {
-              if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
-                  && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
-                  && (s[5] ^ 0x80) < 0x40
-                  && (c >= 0xfd || s[1] >= 0x84))
+              if ((s[1] ^ 0x80) < 0x40)
                 {
-                  *puc = ((unsigned int) (c & 0x01) << 30)
-                         | ((unsigned int) (s[1] ^ 0x80) << 24)
-                         | ((unsigned int) (s[2] ^ 0x80) << 18)
-                         | ((unsigned int) (s[3] ^ 0x80) << 12)
-                         | ((unsigned int) (s[4] ^ 0x80) << 6)
-                         | (unsigned int) (s[5] ^ 0x80);
-                  return 6;
+                  if ((s[2] ^ 0x80) < 0x40)
+                    {
+                      if ((s[3] ^ 0x80) < 0x40)
+                        {
+                          if ((s[4] ^ 0x80) < 0x40)
+                            {
+                              if ((s[5] ^ 0x80) < 0x40)
+                                {
+                                  if (c >= 0xfd || s[1] >= 0x84)
+                                    {
+                                      *puc = ((unsigned int) (c & 0x01) << 30)
+                                             | ((unsigned int) (s[1] ^ 0x80) 
<< 24)
+                                             | ((unsigned int) (s[2] ^ 0x80) 
<< 18)
+                                             | ((unsigned int) (s[3] ^ 0x80) 
<< 12)
+                                             | ((unsigned int) (s[4] ^ 0x80) 
<< 6)
+                                             | (unsigned int) (s[5] ^ 0x80);
+                                      return 6;
+                                    }
+                                  /* invalid multibyte character */
+                                  *puc = 0xfffd;
+                                  return 6;
+                                }
+                              /* invalid multibyte character */
+                              *puc = 0xfffd;
+                              return 5;
+                            }
+                          /* invalid multibyte character */
+                          *puc = 0xfffd;
+                          return 4;
+                        }
+                      /* invalid multibyte character */
+                      *puc = 0xfffd;
+                      return 3;
+                    }
+                  /* invalid multibyte character */
+                  return 2;
                 }
               /* invalid multibyte character */
             }
diff --git a/lib/unistr/u8-mbtouc-unsafe-aux.c 
b/lib/unistr/u8-mbtouc-unsafe-aux.c
index 47590e3..1965e96 100644
--- a/lib/unistr/u8-mbtouc-unsafe-aux.c
+++ b/lib/unistr/u8-mbtouc-unsafe-aux.c
@@ -41,13 +41,15 @@ u8_mbtouc_unsafe_aux (ucs4_t *puc, const uint8_t *s, size_t 
n)
                          | (unsigned int) (s[1] ^ 0x80);
                   return 2;
                 }
+#if CONFIG_UNICODE_SAFETY
               /* invalid multibyte character */
+#endif
             }
           else
             {
               /* incomplete multibyte character */
               *puc = 0xfffd;
-              return n;
+              return 1;
             }
         }
       else if (c < 0xf0)
@@ -55,23 +57,39 @@ u8_mbtouc_unsafe_aux (ucs4_t *puc, const uint8_t *s, size_t 
n)
           if (n >= 3)
             {
 #if CONFIG_UNICODE_SAFETY
-              if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
-                  && (c >= 0xe1 || s[1] >= 0xa0)
-                  && (c != 0xed || s[1] < 0xa0))
-#endif
+              if ((s[1] ^ 0x80) < 0x40)
                 {
-                  *puc = ((unsigned int) (c & 0x0f) << 12)
-                         | ((unsigned int) (s[1] ^ 0x80) << 6)
-                         | (unsigned int) (s[2] ^ 0x80);
-                  return 3;
+                  if ((s[2] ^ 0x80) < 0x40)
+                    {
+                      if ((c >= 0xe1 || s[1] >= 0xa0)
+                          && (c != 0xed || s[1] < 0xa0))
+#endif
+                        {
+                          *puc = ((unsigned int) (c & 0x0f) << 12)
+                                 | ((unsigned int) (s[1] ^ 0x80) << 6)
+                                 | (unsigned int) (s[2] ^ 0x80);
+                          return 3;
+                        }
+#if CONFIG_UNICODE_SAFETY
+                      /* invalid multibyte character */
+                      *puc = 0xfffd;
+                      return 3;
+                    }
+                  /* invalid multibyte character */
+                  *puc = 0xfffd;
+                  return 2;
                 }
               /* invalid multibyte character */
+#endif
             }
           else
             {
               /* incomplete multibyte character */
               *puc = 0xfffd;
-              return n;
+              if (n == 1 || (s[1] ^ 0x80) >= 0x40)
+                return 1;
+              else
+                return 2;
             }
         }
       else if (c < 0xf8)
@@ -79,28 +97,51 @@ u8_mbtouc_unsafe_aux (ucs4_t *puc, const uint8_t *s, size_t 
n)
           if (n >= 4)
             {
 #if CONFIG_UNICODE_SAFETY
-              if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
-                  && (s[3] ^ 0x80) < 0x40
-                  && (c >= 0xf1 || s[1] >= 0x90)
+              if ((s[1] ^ 0x80) < 0x40)
+                {
+                  if ((s[2] ^ 0x80) < 0x40)
+                    {
+                      if ((s[3] ^ 0x80) < 0x40)
+                        {
+                          if ((c >= 0xf1 || s[1] >= 0x90)
 #if 1
-                  && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
+                              && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
 #endif
-                 )
+                             )
 #endif
-                {
-                  *puc = ((unsigned int) (c & 0x07) << 18)
-                         | ((unsigned int) (s[1] ^ 0x80) << 12)
-                         | ((unsigned int) (s[2] ^ 0x80) << 6)
-                         | (unsigned int) (s[3] ^ 0x80);
-                  return 4;
+                            {
+                              *puc = ((unsigned int) (c & 0x07) << 18)
+                                     | ((unsigned int) (s[1] ^ 0x80) << 12)
+                                     | ((unsigned int) (s[2] ^ 0x80) << 6)
+                                     | (unsigned int) (s[3] ^ 0x80);
+                              return 4;
+                            }
+#if CONFIG_UNICODE_SAFETY
+                          /* invalid multibyte character */
+                          *puc = 0xfffd;
+                          return 4;
+                        }
+                      /* invalid multibyte character */
+                      *puc = 0xfffd;
+                      return 3;
+                    }
+                  /* invalid multibyte character */
+                  *puc = 0xfffd;
+                  return 2;
                 }
               /* invalid multibyte character */
+#endif
             }
           else
             {
               /* incomplete multibyte character */
               *puc = 0xfffd;
-              return n;
+              if (n == 1 || (s[1] ^ 0x80) >= 0x40)
+                return 1;
+              else if (n == 2 || (s[2] ^ 0x80) >= 0x40)
+                return 2;
+              else
+                return 3;
             }
         }
 #if 0
@@ -109,19 +150,42 @@ u8_mbtouc_unsafe_aux (ucs4_t *puc, const uint8_t *s, 
size_t n)
           if (n >= 5)
             {
 #if CONFIG_UNICODE_SAFETY
-              if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
-                  && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
-                  && (c >= 0xf9 || s[1] >= 0x88))
-#endif
+              if ((s[1] ^ 0x80) < 0x40)
                 {
-                  *puc = ((unsigned int) (c & 0x03) << 24)
-                         | ((unsigned int) (s[1] ^ 0x80) << 18)
-                         | ((unsigned int) (s[2] ^ 0x80) << 12)
-                         | ((unsigned int) (s[3] ^ 0x80) << 6)
-                         | (unsigned int) (s[4] ^ 0x80);
-                  return 5;
+                  if ((s[2] ^ 0x80) < 0x40)
+                    {
+                      if ((s[3] ^ 0x80) < 0x40)
+                        {
+                          if ((s[4] ^ 0x80) < 0x40)
+                            {
+                              if (c >= 0xf9 || s[1] >= 0x88)
+#endif
+                                {
+                                  *puc = ((unsigned int) (c & 0x03) << 24)
+                                         | ((unsigned int) (s[1] ^ 0x80) << 18)
+                                         | ((unsigned int) (s[2] ^ 0x80) << 12)
+                                         | ((unsigned int) (s[3] ^ 0x80) << 6)
+                                         | (unsigned int) (s[4] ^ 0x80);
+                                  return 5;
+                                }
+#if CONFIG_UNICODE_SAFETY
+                              /* invalid multibyte character */
+                              *puc = 0xfffd;
+                              return 5;
+                            }
+                          /* invalid multibyte character */
+                          *puc = 0xfffd;
+                          return 4;
+                        }
+                      /* invalid multibyte character */
+                      *puc = 0xfffd;
+                      return 3;
+                    }
+                  /* invalid multibyte character */
+                  return 2;
                 }
               /* invalid multibyte character */
+#endif
             }
           else
             {
@@ -135,21 +199,49 @@ u8_mbtouc_unsafe_aux (ucs4_t *puc, const uint8_t *s, 
size_t n)
           if (n >= 6)
             {
 #if CONFIG_UNICODE_SAFETY
-              if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
-                  && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
-                  && (s[5] ^ 0x80) < 0x40
-                  && (c >= 0xfd || s[1] >= 0x84))
-#endif
+              if ((s[1] ^ 0x80) < 0x40)
                 {
-                  *puc = ((unsigned int) (c & 0x01) << 30)
-                         | ((unsigned int) (s[1] ^ 0x80) << 24)
-                         | ((unsigned int) (s[2] ^ 0x80) << 18)
-                         | ((unsigned int) (s[3] ^ 0x80) << 12)
-                         | ((unsigned int) (s[4] ^ 0x80) << 6)
-                         | (unsigned int) (s[5] ^ 0x80);
-                  return 6;
+                  if ((s[2] ^ 0x80) < 0x40)
+                    {
+                      if ((s[3] ^ 0x80) < 0x40)
+                        {
+                          if ((s[4] ^ 0x80) < 0x40)
+                            {
+                              if ((s[5] ^ 0x80) < 0x40)
+                                {
+                                  if (c >= 0xfd || s[1] >= 0x84)
+#endif
+                                    {
+                                      *puc = ((unsigned int) (c & 0x01) << 30)
+                                             | ((unsigned int) (s[1] ^ 0x80) 
<< 24)
+                                             | ((unsigned int) (s[2] ^ 0x80) 
<< 18)
+                                             | ((unsigned int) (s[3] ^ 0x80) 
<< 12)
+                                             | ((unsigned int) (s[4] ^ 0x80) 
<< 6)
+                                             | (unsigned int) (s[5] ^ 0x80);
+                                      return 6;
+                                    }
+#if CONFIG_UNICODE_SAFETY
+                                  /* invalid multibyte character */
+                                  *puc = 0xfffd;
+                                  return 6;
+                                }
+                              /* invalid multibyte character */
+                              *puc = 0xfffd;
+                              return 5;
+                            }
+                          /* invalid multibyte character */
+                          *puc = 0xfffd;
+                          return 4;
+                        }
+                      /* invalid multibyte character */
+                      *puc = 0xfffd;
+                      return 3;
+                    }
+                  /* invalid multibyte character */
+                  return 2;
                 }
               /* invalid multibyte character */
+#endif
             }
           else
             {
diff --git a/lib/unistr/u8-mbtouc-unsafe.c b/lib/unistr/u8-mbtouc-unsafe.c
index 41583f9..16af8f9 100644
--- a/lib/unistr/u8-mbtouc-unsafe.c
+++ b/lib/unistr/u8-mbtouc-unsafe.c
@@ -52,13 +52,15 @@ u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n)
                          | (unsigned int) (s[1] ^ 0x80);
                   return 2;
                 }
+#if CONFIG_UNICODE_SAFETY
               /* invalid multibyte character */
+#endif
             }
           else
             {
               /* incomplete multibyte character */
               *puc = 0xfffd;
-              return n;
+              return 1;
             }
         }
       else if (c < 0xf0)
@@ -66,23 +68,39 @@ u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n)
           if (n >= 3)
             {
 #if CONFIG_UNICODE_SAFETY
-              if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
-                  && (c >= 0xe1 || s[1] >= 0xa0)
-                  && (c != 0xed || s[1] < 0xa0))
-#endif
+              if ((s[1] ^ 0x80) < 0x40)
                 {
-                  *puc = ((unsigned int) (c & 0x0f) << 12)
-                         | ((unsigned int) (s[1] ^ 0x80) << 6)
-                         | (unsigned int) (s[2] ^ 0x80);
-                  return 3;
+                  if ((s[2] ^ 0x80) < 0x40)
+                    {
+                      if ((c >= 0xe1 || s[1] >= 0xa0)
+                          && (c != 0xed || s[1] < 0xa0))
+#endif
+                        {
+                          *puc = ((unsigned int) (c & 0x0f) << 12)
+                                 | ((unsigned int) (s[1] ^ 0x80) << 6)
+                                 | (unsigned int) (s[2] ^ 0x80);
+                          return 3;
+                        }
+#if CONFIG_UNICODE_SAFETY
+                      /* invalid multibyte character */
+                      *puc = 0xfffd;
+                      return 3;
+                    }
+                  /* invalid multibyte character */
+                  *puc = 0xfffd;
+                  return 2;
                 }
               /* invalid multibyte character */
+#endif
             }
           else
             {
               /* incomplete multibyte character */
               *puc = 0xfffd;
-              return n;
+              if (n == 1 || (s[1] ^ 0x80) >= 0x40)
+                return 1;
+              else
+                return 2;
             }
         }
       else if (c < 0xf8)
@@ -90,28 +108,51 @@ u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n)
           if (n >= 4)
             {
 #if CONFIG_UNICODE_SAFETY
-              if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
-                  && (s[3] ^ 0x80) < 0x40
-                  && (c >= 0xf1 || s[1] >= 0x90)
+              if ((s[1] ^ 0x80) < 0x40)
+                {
+                  if ((s[2] ^ 0x80) < 0x40)
+                    {
+                      if ((s[3] ^ 0x80) < 0x40)
+                        {
+                          if ((c >= 0xf1 || s[1] >= 0x90)
 #if 1
-                  && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
+                              && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
 #endif
-                 )
+                             )
 #endif
-                {
-                  *puc = ((unsigned int) (c & 0x07) << 18)
-                         | ((unsigned int) (s[1] ^ 0x80) << 12)
-                         | ((unsigned int) (s[2] ^ 0x80) << 6)
-                         | (unsigned int) (s[3] ^ 0x80);
-                  return 4;
+                            {
+                              *puc = ((unsigned int) (c & 0x07) << 18)
+                                     | ((unsigned int) (s[1] ^ 0x80) << 12)
+                                     | ((unsigned int) (s[2] ^ 0x80) << 6)
+                                     | (unsigned int) (s[3] ^ 0x80);
+                              return 4;
+                            }
+#if CONFIG_UNICODE_SAFETY
+                          /* invalid multibyte character */
+                          *puc = 0xfffd;
+                          return 4;
+                        }
+                      /* invalid multibyte character */
+                      *puc = 0xfffd;
+                      return 3;
+                    }
+                  /* invalid multibyte character */
+                  *puc = 0xfffd;
+                  return 2;
                 }
               /* invalid multibyte character */
+#endif
             }
           else
             {
               /* incomplete multibyte character */
               *puc = 0xfffd;
-              return n;
+              if (n == 1 || (s[1] ^ 0x80) >= 0x40)
+                return 1;
+              else if (n == 2 || (s[2] ^ 0x80) >= 0x40)
+                return 2;
+              else
+                return 3;
             }
         }
 #if 0
@@ -120,19 +161,42 @@ u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n)
           if (n >= 5)
             {
 #if CONFIG_UNICODE_SAFETY
-              if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
-                  && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
-                  && (c >= 0xf9 || s[1] >= 0x88))
-#endif
+              if ((s[1] ^ 0x80) < 0x40)
                 {
-                  *puc = ((unsigned int) (c & 0x03) << 24)
-                         | ((unsigned int) (s[1] ^ 0x80) << 18)
-                         | ((unsigned int) (s[2] ^ 0x80) << 12)
-                         | ((unsigned int) (s[3] ^ 0x80) << 6)
-                         | (unsigned int) (s[4] ^ 0x80);
-                  return 5;
+                  if ((s[2] ^ 0x80) < 0x40)
+                    {
+                      if ((s[3] ^ 0x80) < 0x40)
+                        {
+                          if ((s[4] ^ 0x80) < 0x40)
+                            {
+                              if (c >= 0xf9 || s[1] >= 0x88)
+#endif
+                                {
+                                  *puc = ((unsigned int) (c & 0x03) << 24)
+                                         | ((unsigned int) (s[1] ^ 0x80) << 18)
+                                         | ((unsigned int) (s[2] ^ 0x80) << 12)
+                                         | ((unsigned int) (s[3] ^ 0x80) << 6)
+                                         | (unsigned int) (s[4] ^ 0x80);
+                                  return 5;
+                                }
+#if CONFIG_UNICODE_SAFETY
+                              /* invalid multibyte character */
+                              *puc = 0xfffd;
+                              return 5;
+                            }
+                          /* invalid multibyte character */
+                          *puc = 0xfffd;
+                          return 4;
+                        }
+                      /* invalid multibyte character */
+                      *puc = 0xfffd;
+                      return 3;
+                    }
+                  /* invalid multibyte character */
+                  return 2;
                 }
               /* invalid multibyte character */
+#endif
             }
           else
             {
@@ -146,21 +210,49 @@ u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n)
           if (n >= 6)
             {
 #if CONFIG_UNICODE_SAFETY
-              if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
-                  && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
-                  && (s[5] ^ 0x80) < 0x40
-                  && (c >= 0xfd || s[1] >= 0x84))
-#endif
+              if ((s[1] ^ 0x80) < 0x40)
                 {
-                  *puc = ((unsigned int) (c & 0x01) << 30)
-                         | ((unsigned int) (s[1] ^ 0x80) << 24)
-                         | ((unsigned int) (s[2] ^ 0x80) << 18)
-                         | ((unsigned int) (s[3] ^ 0x80) << 12)
-                         | ((unsigned int) (s[4] ^ 0x80) << 6)
-                         | (unsigned int) (s[5] ^ 0x80);
-                  return 6;
+                  if ((s[2] ^ 0x80) < 0x40)
+                    {
+                      if ((s[3] ^ 0x80) < 0x40)
+                        {
+                          if ((s[4] ^ 0x80) < 0x40)
+                            {
+                              if ((s[5] ^ 0x80) < 0x40)
+                                {
+                                  if (c >= 0xfd || s[1] >= 0x84)
+#endif
+                                    {
+                                      *puc = ((unsigned int) (c & 0x01) << 30)
+                                             | ((unsigned int) (s[1] ^ 0x80) 
<< 24)
+                                             | ((unsigned int) (s[2] ^ 0x80) 
<< 18)
+                                             | ((unsigned int) (s[3] ^ 0x80) 
<< 12)
+                                             | ((unsigned int) (s[4] ^ 0x80) 
<< 6)
+                                             | (unsigned int) (s[5] ^ 0x80);
+                                      return 6;
+                                    }
+#if CONFIG_UNICODE_SAFETY
+                                  /* invalid multibyte character */
+                                  *puc = 0xfffd;
+                                  return 6;
+                                }
+                              /* invalid multibyte character */
+                              *puc = 0xfffd;
+                              return 5;
+                            }
+                          /* invalid multibyte character */
+                          *puc = 0xfffd;
+                          return 4;
+                        }
+                      /* invalid multibyte character */
+                      *puc = 0xfffd;
+                      return 3;
+                    }
+                  /* invalid multibyte character */
+                  return 2;
                 }
               /* invalid multibyte character */
+#endif
             }
           else
             {
diff --git a/lib/unistr/u8-mbtouc.c b/lib/unistr/u8-mbtouc.c
index 96cd5b7..2ddd864 100644
--- a/lib/unistr/u8-mbtouc.c
+++ b/lib/unistr/u8-mbtouc.c
@@ -55,21 +55,32 @@ u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n)
             {
               /* incomplete multibyte character */
               *puc = 0xfffd;
-              return n;
+              return 1;
             }
         }
       else if (c < 0xf0)
         {
           if (n >= 3)
             {
-              if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
-                  && (c >= 0xe1 || s[1] >= 0xa0)
-                  && (c != 0xed || s[1] < 0xa0))
+              if ((s[1] ^ 0x80) < 0x40)
                 {
-                  *puc = ((unsigned int) (c & 0x0f) << 12)
-                         | ((unsigned int) (s[1] ^ 0x80) << 6)
-                         | (unsigned int) (s[2] ^ 0x80);
-                  return 3;
+                  if ((s[2] ^ 0x80) < 0x40)
+                    {
+                      if ((c >= 0xe1 || s[1] >= 0xa0)
+                          && (c != 0xed || s[1] < 0xa0))
+                        {
+                          *puc = ((unsigned int) (c & 0x0f) << 12)
+                                 | ((unsigned int) (s[1] ^ 0x80) << 6)
+                                 | (unsigned int) (s[2] ^ 0x80);
+                          return 3;
+                        }
+                      /* invalid multibyte character */
+                      *puc = 0xfffd;
+                      return 3;
+                    }
+                  /* invalid multibyte character */
+                  *puc = 0xfffd;
+                  return 2;
                 }
               /* invalid multibyte character */
             }
@@ -77,26 +88,45 @@ u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n)
             {
               /* incomplete multibyte character */
               *puc = 0xfffd;
-              return n;
+              if (n == 1 || (s[1] ^ 0x80) >= 0x40)
+                return 1;
+              else
+                return 2;
             }
         }
       else if (c < 0xf8)
         {
           if (n >= 4)
             {
-              if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
-                  && (s[3] ^ 0x80) < 0x40
-                  && (c >= 0xf1 || s[1] >= 0x90)
+              if ((s[1] ^ 0x80) < 0x40)
+                {
+                  if ((s[2] ^ 0x80) < 0x40)
+                    {
+                      if ((s[3] ^ 0x80) < 0x40)
+                        {
+                          if ((c >= 0xf1 || s[1] >= 0x90)
 #if 1
-                  && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
+                              && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
 #endif
-                 )
-                {
-                  *puc = ((unsigned int) (c & 0x07) << 18)
-                         | ((unsigned int) (s[1] ^ 0x80) << 12)
-                         | ((unsigned int) (s[2] ^ 0x80) << 6)
-                         | (unsigned int) (s[3] ^ 0x80);
-                  return 4;
+                             )
+                            {
+                              *puc = ((unsigned int) (c & 0x07) << 18)
+                                     | ((unsigned int) (s[1] ^ 0x80) << 12)
+                                     | ((unsigned int) (s[2] ^ 0x80) << 6)
+                                     | (unsigned int) (s[3] ^ 0x80);
+                              return 4;
+                            }
+                          /* invalid multibyte character */
+                          *puc = 0xfffd;
+                          return 4;
+                        }
+                      /* invalid multibyte character */
+                      *puc = 0xfffd;
+                      return 3;
+                    }
+                  /* invalid multibyte character */
+                  *puc = 0xfffd;
+                  return 2;
                 }
               /* invalid multibyte character */
             }
@@ -104,7 +134,12 @@ u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n)
             {
               /* incomplete multibyte character */
               *puc = 0xfffd;
-              return n;
+              if (n == 1 || (s[1] ^ 0x80) >= 0x40)
+                return 1;
+              else if (n == 2 || (s[2] ^ 0x80) >= 0x40)
+                return 2;
+              else
+                return 3;
             }
         }
 #if 0
@@ -112,16 +147,37 @@ u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n)
         {
           if (n >= 5)
             {
-              if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
-                  && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
-                  && (c >= 0xf9 || s[1] >= 0x88))
+              if ((s[1] ^ 0x80) < 0x40)
                 {
-                  *puc = ((unsigned int) (c & 0x03) << 24)
-                         | ((unsigned int) (s[1] ^ 0x80) << 18)
-                         | ((unsigned int) (s[2] ^ 0x80) << 12)
-                         | ((unsigned int) (s[3] ^ 0x80) << 6)
-                         | (unsigned int) (s[4] ^ 0x80);
-                  return 5;
+                  if ((s[2] ^ 0x80) < 0x40)
+                    {
+                      if ((s[3] ^ 0x80) < 0x40)
+                        {
+                          if ((s[4] ^ 0x80) < 0x40)
+                            {
+                              if (c >= 0xf9 || s[1] >= 0x88)
+                                {
+                                  *puc = ((unsigned int) (c & 0x03) << 24)
+                                         | ((unsigned int) (s[1] ^ 0x80) << 18)
+                                         | ((unsigned int) (s[2] ^ 0x80) << 12)
+                                         | ((unsigned int) (s[3] ^ 0x80) << 6)
+                                         | (unsigned int) (s[4] ^ 0x80);
+                                  return 5;
+                                }
+                              /* invalid multibyte character */
+                              *puc = 0xfffd;
+                              return 5;
+                            }
+                          /* invalid multibyte character */
+                          *puc = 0xfffd;
+                          return 4;
+                        }
+                      /* invalid multibyte character */
+                      *puc = 0xfffd;
+                      return 3;
+                    }
+                  /* invalid multibyte character */
+                  return 2;
                 }
               /* invalid multibyte character */
             }
@@ -136,18 +192,44 @@ u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n)
         {
           if (n >= 6)
             {
-              if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
-                  && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
-                  && (s[5] ^ 0x80) < 0x40
-                  && (c >= 0xfd || s[1] >= 0x84))
+              if ((s[1] ^ 0x80) < 0x40)
                 {
-                  *puc = ((unsigned int) (c & 0x01) << 30)
-                         | ((unsigned int) (s[1] ^ 0x80) << 24)
-                         | ((unsigned int) (s[2] ^ 0x80) << 18)
-                         | ((unsigned int) (s[3] ^ 0x80) << 12)
-                         | ((unsigned int) (s[4] ^ 0x80) << 6)
-                         | (unsigned int) (s[5] ^ 0x80);
-                  return 6;
+                  if ((s[2] ^ 0x80) < 0x40)
+                    {
+                      if ((s[3] ^ 0x80) < 0x40)
+                        {
+                          if ((s[4] ^ 0x80) < 0x40)
+                            {
+                              if ((s[5] ^ 0x80) < 0x40)
+                                {
+                                  if (c >= 0xfd || s[1] >= 0x84)
+                                    {
+                                      *puc = ((unsigned int) (c & 0x01) << 30)
+                                             | ((unsigned int) (s[1] ^ 0x80) 
<< 24)
+                                             | ((unsigned int) (s[2] ^ 0x80) 
<< 18)
+                                             | ((unsigned int) (s[3] ^ 0x80) 
<< 12)
+                                             | ((unsigned int) (s[4] ^ 0x80) 
<< 6)
+                                             | (unsigned int) (s[5] ^ 0x80);
+                                      return 6;
+                                    }
+                                  /* invalid multibyte character */
+                                  *puc = 0xfffd;
+                                  return 6;
+                                }
+                              /* invalid multibyte character */
+                              *puc = 0xfffd;
+                              return 5;
+                            }
+                          /* invalid multibyte character */
+                          *puc = 0xfffd;
+                          return 4;
+                        }
+                      /* invalid multibyte character */
+                      *puc = 0xfffd;
+                      return 3;
+                    }
+                  /* invalid multibyte character */
+                  return 2;
                 }
               /* invalid multibyte character */
             }
diff --git a/lib/unistr/u8-prev.c b/lib/unistr/u8-prev.c
index 97a27f5..47f89b4 100644
--- a/lib/unistr/u8-prev.c
+++ b/lib/unistr/u8-prev.c
@@ -23,7 +23,7 @@
 const uint8_t *
 u8_prev (ucs4_t *puc, const uint8_t *s, const uint8_t *start)
 {
-  /* Keep in sync with unistr.h and utf8-ucs4.c.  */
+  /* Keep in sync with unistr.h and u8-mbtouc-aux.c.  */
   if (s != start)
     {
       uint8_t c_1 = s[-1];
diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
index d45cbdd..13e0ebc 100644
--- a/lib/vasnprintf.c
+++ b/lib/vasnprintf.c
@@ -88,6 +88,8 @@
 /* Checked size_t computations.  */
 #include "xsize.h"
 
+#include "verify.h"
+
 #if (NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL
 # include <math.h>
 # include "float+.h"
@@ -277,7 +279,7 @@ decimal_point_char (void)
      multithread-safe on glibc systems and MacOS X systems, but is not required
      to be multithread-safe by POSIX.  sprintf(), however, is multithread-safe.
      localeconv() is rarely multithread-safe.  */
-#  if HAVE_NL_LANGINFO && (__GLIBC__ || (defined __APPLE__ && defined 
__MACH__))
+#  if HAVE_NL_LANGINFO && (__GLIBC__ || defined __UCLIBC__ || (defined 
__APPLE__ && defined __MACH__))
   point = nl_langinfo (RADIXCHAR);
 #  elif 1
   char pointbuf[5];
@@ -322,11 +324,11 @@ is_infinite_or_zerol (long double x)
 
 typedef unsigned int mp_limb_t;
 # define GMP_LIMB_BITS 32
-typedef int mp_limb_verify[2 * (sizeof (mp_limb_t) * CHAR_BIT == 
GMP_LIMB_BITS) - 1];
+verify (sizeof (mp_limb_t) * CHAR_BIT == GMP_LIMB_BITS);
 
 typedef unsigned long long mp_twolimb_t;
 # define GMP_TWOLIMB_BITS 64
-typedef int mp_twolimb_verify[2 * (sizeof (mp_twolimb_t) * CHAR_BIT == 
GMP_TWOLIMB_BITS) - 1];
+verify (sizeof (mp_twolimb_t) * CHAR_BIT == GMP_TWOLIMB_BITS);
 
 /* Representation of a bignum >= 0.  */
 typedef struct
@@ -2621,7 +2623,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                   size_t characters;
 #  if !DCHAR_IS_TCHAR
                   /* This code assumes that TCHAR_T is 'char'.  */
-                  typedef int TCHAR_T_verify[2 * (sizeof (TCHAR_T) == 1) - 1];
+                  verify (sizeof (TCHAR_T) == 1);
                   TCHAR_T *tmpsrc;
                   DCHAR_T *tmpdst;
                   size_t tmpdst_len;
@@ -4597,6 +4599,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                 TCHAR_T *fbp;
                 unsigned int prefix_count;
                 int prefixes[2] IF_LINT (= { 0 });
+                int orig_errno;
 #if !USE_SNPRINTF
                 size_t tmp_length;
                 TCHAR_T tmpbuf[700];
@@ -4751,6 +4754,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                   *fbp++ = ' ';
                 if (flags & FLAG_ALT)
                   *fbp++ = '#';
+#if __GLIBC__ >= 2 && !defined __UCLIBC__
+                if (flags & FLAG_LOCALIZED)
+                  *fbp++ = 'I';
+#endif
                 if (!pad_ourselves)
                   {
                     if (flags & FLAG_ZERO)
@@ -4834,14 +4841,15 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
 #endif
                   *fbp = dp->conversion;
 #if USE_SNPRINTF
-# if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3) || ((defined 
_WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
+# if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && 
!defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined 
__CYGWIN__))
                 fbp[1] = '%';
                 fbp[2] = 'n';
                 fbp[3] = '\0';
 # else
                 /* On glibc2 systems from glibc >= 2.3 - probably also older
-                   ones - we know that snprintf's returns value conforms to
-                   ISO C 99: the gl_SNPRINTF_DIRECTIVE_N test passes.
+                   ones - we know that snprintf's return value conforms to
+                   ISO C 99: the tests gl_SNPRINTF_RETVAL_C99 and
+                   gl_SNPRINTF_TRUNCATION_C99 pass.
                    Therefore we can avoid using %n in this situation.
                    On glibc2 systems from 2004-10-18 or newer, the use of %n
                    in format strings in writable memory may crash the program
@@ -4900,6 +4908,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                 *(TCHAR_T *) (result + length) = '\0';
 #endif
 
+                orig_errno = errno;
+
                 for (;;)
                   {
                     int count = -1;
@@ -5284,8 +5294,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                         DCHAR_T *tmpdst;
                         size_t tmpdst_len;
                         /* This code assumes that TCHAR_T is 'char'.  */
-                        typedef int TCHAR_T_verify
-                                    [2 * (sizeof (TCHAR_T) == 1) - 1];
+                        verify (sizeof (TCHAR_T) == 1);
 # if USE_SNPRINTF
                         tmpsrc = (TCHAR_T *) (result + length);
 # else
@@ -5498,6 +5507,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                     length += count;
                     break;
                   }
+                errno = orig_errno;
 #undef pad_ourselves
 #undef prec_ourselves
               }
diff --git a/lib/w32sock.h b/lib/w32sock.h
new file mode 100644
index 0000000..bc0845c
--- /dev/null
+++ b/lib/w32sock.h
@@ -0,0 +1,61 @@
+/* w32sock.h --- internal auxilliary functions for Windows socket functions
+
+   Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
+
+   This program 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 3 of the License, or
+   (at your option) any later version.
+
+   This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Paolo Bonzini */
+
+#include <errno.h>
+
+/* Get O_RDWR and O_BINARY.  */
+#include <fcntl.h>
+
+/* Get _get_osfhandle() and _open_osfhandle().  */
+#include <io.h>
+
+#define FD_TO_SOCKET(fd)   ((SOCKET) _get_osfhandle ((fd)))
+#define SOCKET_TO_FD(fh)   (_open_osfhandle ((long) (fh), O_RDWR | O_BINARY))
+
+static inline void
+set_winsock_errno (void)
+{
+  int err = WSAGetLastError ();
+
+  /* Map some WSAE* errors to the runtime library's error codes.  */
+  switch (err)
+    {
+    case WSA_INVALID_HANDLE:
+      errno = EBADF;
+      break;
+    case WSA_NOT_ENOUGH_MEMORY:
+      errno = ENOMEM;
+      break;
+    case WSA_INVALID_PARAMETER:
+      errno = EINVAL;
+      break;
+    case WSAEWOULDBLOCK:
+      errno = EWOULDBLOCK;
+      break;
+    case WSAENAMETOOLONG:
+      errno = ENAMETOOLONG;
+      break;
+    case WSAENOTEMPTY:
+      errno = ENOTEMPTY;
+      break;
+    default:
+      errno = (err > 10000 && err < 10025) ? err - 10000 : err;
+      break;
+    }
+}
diff --git a/lib/wchar.in.h b/lib/wchar.in.h
index 3e3a0c3..0cd471a 100644
--- a/lib/wchar.in.h
+++ b/lib/wchar.in.h
@@ -29,6 +29,7 @@
 #if __GNUC__ >= 3
 @PRAGMA_SYSTEM_HEADER@
 #endif
address@hidden@
 
 #if defined __need_mbstate_t || defined __need_wint_t || (defined __hpux && 
((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined 
_GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H
 /* Special invocation convention:
@@ -52,6 +53,10 @@
 
 #define _GL_ALREADY_INCLUDING_WCHAR_H
 
+#if @HAVE_FEATURES_H@
+# include <features.h> /* for __GLIBC__ */
+#endif
+
 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
    <wchar.h>.
    BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
diff --git a/libguile/posix.c b/libguile/posix.c
index 2a2a77b..95beb6e 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -138,6 +138,7 @@ extern char *ttyname();
 #endif
 
 #include <sys/file.h>     /* from Gnulib */
+#include <nproc.h>
 
 /* Some Unix systems don't define these.  CPP hair is dangerous, but
    this seems safe enough... */
@@ -1930,7 +1931,9 @@ SCM_DEFINE (scm_getaffinity, "getaffinity", 1, 0, 0,
            "has its corresponding bit set in the returned bitvector.\n"
            "The number of bits set is a good estimate of how many CPUs\n"
            "Guile can use without stepping on other processes' toes.\n\n"
-           "Currently this procedure is only defined on GNU variants.\n")
+           "Currently this procedure is only defined on GNU variants\n"
+           "(@pxref{CPU Affinity, @code{sched_getaffinity},, libc, The\n"
+           "GNU C Library Reference Manual}).\n")
 #define FUNC_NAME s_scm_getaffinity
 {
   int err;
@@ -1954,7 +1957,9 @@ SCM_DEFINE (scm_setaffinity, "setaffinity", 2, 0, 0,
            "Install the CPU affinity mask @var{mask}, a bitvector, for\n"
            "the process or thread with ID @var{pid}.  The return value\n"
            "is unspecified.\n\n"
-           "Currently this procedure is only defined on GNU variants.\n")
+           "Currently this procedure is only defined on GNU variants\n"
+           "(@pxref{CPU Affinity, @code{sched_setaffinity},, libc, The\n"
+           "GNU C Library Reference Manual}).\n")
 #define FUNC_NAME s_scm_setaffinity
 {
   cpu_set_t cs;
@@ -1986,6 +1991,37 @@ SCM_DEFINE (scm_setaffinity, "setaffinity", 2, 0, 0,
 
 #endif /* HAVE_SCHED_SETAFFINITY */
 
+SCM_DEFINE (scm_total_processor_count, "total-processor-count", 0, 0, 0,
+           (void),
+           "Return the total number of processors of the machine, which\n"
+           "is guaranteed to be at least 1.  A ``processor'' here is a\n"
+           "thread execution unit, which can be either:\n\n"
+           "@itemize\n"
+           "@item an execution core in a (possibly multi-core) chip, in a\n"
+           "  (possibly multi- chip) module, in a single computer, or\n"
+           "@item a thread execution unit inside a core in the case of\n"
+           "  @dfn{hyper-threaded} CPUs.\n"
+           "@end itemize\n\n"
+           "Which of the two definitions is used, is unspecified.\n")
+#define FUNC_NAME s_scm_total_processor_count
+{
+  return scm_from_ulong (num_processors (NPROC_ALL));
+}
+#undef FUNC_NAME
+
+SCM_DEFINE (scm_current_processor_count, "current-processor-count", 0, 0, 0,
+           (void),
+           "Like @code{total-processor-count}, but return the number of\n"
+           "processors available to the current process.  See\n"
+           "@code{setaffinity} and @code{getaffinity} for more\n"
+           "information.\n")
+#define FUNC_NAME s_scm_total_processor_count
+{
+  return scm_from_ulong (num_processors (NPROC_CURRENT));
+}
+#undef FUNC_NAME
+
+
 #if HAVE_GETPASS
 SCM_DEFINE (scm_getpass, "getpass", 1, 0, 0, 
             (SCM prompt),
diff --git a/libguile/posix.h b/libguile/posix.h
index aa5e12c..e2e19dd 100644
--- a/libguile/posix.h
+++ b/libguile/posix.h
@@ -91,6 +91,8 @@ SCM_API SCM scm_sethostname (SCM name);
 SCM_API SCM scm_gethostname (void);
 SCM_API SCM scm_getaffinity (SCM pid);
 SCM_API SCM scm_setaffinity (SCM pid, SCM cpu_set);
+SCM_API SCM scm_total_processor_count (void);
+SCM_API SCM scm_current_processor_count (void);
 SCM_INTERNAL void scm_init_posix (void);
 
 SCM_INTERNAL scm_i_pthread_mutex_t scm_i_locale_mutex;
diff --git a/m4/alloca.m4 b/m4/alloca.m4
index f3ee343..80d67aa 100644
--- a/m4/alloca.m4
+++ b/m4/alloca.m4
@@ -1,4 +1,4 @@
-# alloca.m4 serial 9
+# alloca.m4 serial 10
 dnl Copyright (C) 2002-2004, 2006-2007, 2009-2010 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
@@ -7,10 +7,6 @@ dnl with or without modifications, as long as this notice is 
preserved.
 
 AC_DEFUN([gl_FUNC_ALLOCA],
 [
-  dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57.
-  AC_REQUIRE([AC_PROG_CPP])
-  AC_REQUIRE([AC_PROG_EGREP])
-
   AC_REQUIRE([AC_FUNC_ALLOCA])
   if test $ac_cv_func_alloca_works = no; then
     gl_PREREQ_ALLOCA
diff --git a/m4/arpa_inet_h.m4 b/m4/arpa_inet_h.m4
index 15a30e2..80fdb40 100644
--- a/m4/arpa_inet_h.m4
+++ b/m4/arpa_inet_h.m4
@@ -1,5 +1,5 @@
-# arpa_inet_h.m4 serial 8
-dnl Copyright (C) 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
+# arpa_inet_h.m4 serial 10
+dnl Copyright (C) 2006, 2008-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -22,11 +22,13 @@ AC_DEFUN([gl_HEADER_ARPA_INET],
   dnl <arpa/inet.h> is always overridden, because of GNULIB_POSIXCHECK.
   gl_CHECK_NEXT_HEADERS([arpa/inet.h])
 
+  AC_REQUIRE([gl_FEATURES_H])
+
   dnl Check for declarations of anything we want to poison if the
   dnl corresponding gnulib module is not in use.
   gl_WARN_ON_USE_PREPARE([[
 /* On some systems, this header is not self-consistent.  */
-#ifndef __GLIBC__
+#if !(defined __GLIBC__ || defined __UCLIBC__)
 # include <sys/socket.h>
 #endif
 #include <arpa/inet.h>
diff --git a/m4/canonicalize.m4 b/m4/canonicalize.m4
index d418de8..f554025 100644
--- a/m4/canonicalize.m4
+++ b/m4/canonicalize.m4
@@ -1,4 +1,4 @@
-# canonicalize.m4 serial 16
+# canonicalize.m4 serial 17
 
 dnl Copyright (C) 2003-2007, 2009-2010 Free Software Foundation, Inc.
 
@@ -65,10 +65,23 @@ AC_DEFUN([gl_FUNC_REALPATH_WORKS],
       AC_LANG_PROGRAM([[
         #include <stdlib.h>
       ]], [[
-        char *name1 = realpath ("conftest.a", NULL);
-        char *name2 = realpath ("conftest.b/../conftest.a", NULL);
-        char *name3 = realpath ("conftest.a/", NULL);
-        return !(name1 && *name1 == '/' && !name2 && !name3);
+        int result = 0;
+        {
+          char *name = realpath ("conftest.a", NULL);
+          if (!(name && *name == '/'))
+            result |= 1;
+        }
+        {
+          char *name = realpath ("conftest.b/../conftest.a", NULL);
+          if (name != NULL)
+            result |= 2;
+        }
+        {
+          char *name = realpath ("conftest.a/", NULL);
+          if (name != NULL)
+            result |= 4;
+        }
+        return result;
       ]])
     ], [gl_cv_func_realpath_works=yes], [gl_cv_func_realpath_works=no],
        [gl_cv_func_realpath_works="guessing no"])
diff --git a/m4/duplocale.m4 b/m4/duplocale.m4
index 4fc6137..6ddccb6 100644
--- a/m4/duplocale.m4
+++ b/m4/duplocale.m4
@@ -1,4 +1,4 @@
-# duplocale.m4 serial 4
+# duplocale.m4 serial 5
 dnl Copyright (C) 2009-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -31,17 +31,20 @@ int main ()
 }]])],
          [gl_cv_func_duplocale_works=yes],
          [gl_cv_func_duplocale_works=no],
-         [dnl Guess it works except on glibc < 2.12 and AIX.
+         [dnl Guess it works except on glibc < 2.12, uClibc, and AIX.
           case "$host_os" in
             aix*) gl_cv_func_duplocale_works="guessing no";;
             *-gnu*)
-              AC_EGREP_CPP([Unlucky GNU user], [
+              AC_EGREP_CPP([Unlucky], [
 #include <features.h>
 #ifdef __GNU_LIBRARY__
  #if (__GLIBC__ == 2 && __GLIBC_MINOR__ < 12)
   Unlucky GNU user
  #endif
 #endif
+#ifdef __UCLIBC__
+ Unlucky user
+#endif
                 ],
                 [gl_cv_func_duplocale_works="guessing no"],
                 [gl_cv_func_duplocale_works="guessing yes"])
diff --git a/m4/errno_h.m4 b/m4/errno_h.m4
index d02a039..e4325ac 100644
--- a/m4/errno_h.m4
+++ b/m4/errno_h.m4
@@ -1,5 +1,5 @@
-# errno_h.m4 serial 6
-dnl Copyright (C) 2004, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
+# errno_h.m4 serial 7
+dnl Copyright (C) 2004, 2006, 2008-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -37,6 +37,9 @@ booboo
 #if !defined ESTALE
 booboo
 #endif
+#if !defined EDQUOT
+booboo
+#endif
 #if !defined ECANCELED
 booboo
 #endif
diff --git a/m4/fcntl-o.m4 b/m4/fcntl-o.m4
index 1adacc8..46fad47 100644
--- a/m4/fcntl-o.m4
+++ b/m4/fcntl-o.m4
@@ -1,4 +1,4 @@
-# fcntl-o.m4 serial 2
+# fcntl-o.m4 serial 3
 dnl Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -37,34 +37,61 @@ AC_DEFUN([gl_FCNTL_O_FLAGS],
             };
           ]],
           [[
-            int status = !constants;
+            int result = !constants;
             {
               static char const sym[] = "conftest.sym";
-              if (symlink (".", sym) != 0
-                  || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
-                status |= 32;
+              if (symlink (".", sym) != 0)
+                result |= 2;
+              else
+                {
+                  int fd = open (sym, O_RDONLY | O_NOFOLLOW);
+                  if (fd >= 0)
+                    {
+                      close (fd);
+                      result |= 4;
+                    }
+                }
               unlink (sym);
             }
             {
               static char const file[] = "confdefs.h";
               int fd = open (file, O_RDONLY | O_NOATIME);
-              char c;
-              struct stat st0, st1;
-              if (fd < 0
-                  || fstat (fd, &st0) != 0
-                  || sleep (1) != 0
-                  || read (fd, &c, 1) != 1
-                  || close (fd) != 0
-                  || stat (file, &st1) != 0
-                  || st0.st_atime != st1.st_atime)
-                status |= 64;
+              if (fd < 0)
+                result |= 8;
+              else
+                {
+                  struct stat st0;
+                  if (fstat (fd, &st0) != 0)
+                    result |= 16;
+                  else
+                    {
+                      char c;
+                      sleep (1);
+                      if (read (fd, &c, 1) != 1)
+                        result |= 24;
+                      else
+                        {
+                          if (close (fd) != 0)
+                            result |= 32;
+                          else
+                            {
+                              struct stat st1;
+                              if (stat (file, &st1) != 0)
+                                result |= 40;
+                              else
+                                if (st0.st_atime != st1.st_atime)
+                                  result |= 64;
+                            }
+                        }
+                    }
+                }
             }
-            return status;]])],
+            return result;]])],
        [gl_cv_header_working_fcntl_h=yes],
        [case $? in #(
-        32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
+        4) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
         64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
-        96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
+        68) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
          *) gl_cv_header_working_fcntl_h='no';;
         esac],
        [gl_cv_header_working_fcntl_h=cross-compiling])])
diff --git a/m4/float_h.m4 b/m4/float_h.m4
index a74a0d9..f6099db 100644
--- a/m4/float_h.m4
+++ b/m4/float_h.m4
@@ -1,4 +1,4 @@
-# float_h.m4 serial 3
+# float_h.m4 serial 4
 dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -10,7 +10,7 @@ AC_DEFUN([gl_FLOAT_H],
   AC_REQUIRE([AC_CANONICAL_HOST])
   FLOAT_H=
   case "$host_os" in
-    beos* | openbsd*)
+    beos* | openbsd* | mirbsd*)
       FLOAT_H=float.h
       gl_CHECK_NEXT_HEADERS([float.h])
       ;;
diff --git a/m4/glibc21.m4 b/m4/glibc21.m4
index 68ada9d..bd08b38 100644
--- a/m4/glibc21.m4
+++ b/m4/glibc21.m4
@@ -1,17 +1,17 @@
-# glibc21.m4 serial 4
-dnl Copyright (C) 2000-2002, 2004, 2008-2010 Free Software Foundation, Inc.
+# glibc21.m4 serial 5
+dnl Copyright (C) 2000-2002, 2004, 2008, 2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
-# Test for the GNU C Library, version 2.1 or newer.
+# Test for the GNU C Library, version 2.1 or newer, or uClibc.
 # From Bruno Haible.
 
 AC_DEFUN([gl_GLIBC21],
   [
-    AC_CACHE_CHECK([whether we are using the GNU C Library 2.1 or newer],
+    AC_CACHE_CHECK([whether we are using the GNU C Library >= 2.1 or uClibc],
       [ac_cv_gnu_library_2_1],
-      [AC_EGREP_CPP([Lucky GNU user],
+      [AC_EGREP_CPP([Lucky],
         [
 #include <features.h>
 #ifdef __GNU_LIBRARY__
@@ -19,6 +19,9 @@ AC_DEFUN([gl_GLIBC21],
   Lucky GNU user
  #endif
 #endif
+#ifdef __UCLIBC__
+ Lucky user
+#endif
         ],
         [ac_cv_gnu_library_2_1=yes],
         [ac_cv_gnu_library_2_1=no])
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
index accf0c3..b0312d1 100644
--- a/m4/gnulib-cache.m4
+++ b/m4/gnulib-cache.m4
@@ -15,7 +15,7 @@
 
 
 # Specification in the form of a command-line invocation:
-#   gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 
--doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 --libtool 
--macro-prefix=gl --no-vc-files alignof alloca-opt announce-gen autobuild 
byteswap canonicalize-lgpl duplocale environ extensions flock fpieee full-read 
full-write func gendocs getaddrinfo git-version-gen gitlog-to-changelog 
gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isinf 
isnan lib-symbol-versions lib-symbol-visibility libunistring locale 
maintainer-makefile putenv stat-time stdlib strcase strftime striconveh string 
sys_stat verify version-etc-fsf vsnprintf warnings
+#   gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 
--doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 --libtool 
--macro-prefix=gl --no-vc-files alignof alloca-opt announce-gen autobuild 
byteswap canonicalize-lgpl duplocale environ extensions flock fpieee full-read 
full-write func gendocs getaddrinfo git-version-gen gitlog-to-changelog 
gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isinf 
isnan lib-symbol-versions lib-symbol-visibility libunistring locale 
maintainer-makefile nproc putenv stat-time stdlib strcase strftime striconveh 
string sys_stat verify version-etc-fsf vsnprintf warnings
 
 # Specification in the form of a few gnulib-tool.m4 macro invocations:
 gl_LOCAL_DIR([])
@@ -51,6 +51,7 @@ gl_MODULES([
   libunistring
   locale
   maintainer-makefile
+  nproc
   putenv
   stat-time
   stdlib
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index 4c7ac30..d0c8b66 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -1,4 +1,4 @@
-# gnulib-common.m4 serial 20
+# gnulib-common.m4 serial 21
 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -102,6 +102,19 @@ AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS],
     [Define to 1 when the gnulib module $1 should be tested.])
 ])
 
+# Test whether <features.h> exists.
+# Set HAVE_FEATURES_H.
+AC_DEFUN([gl_FEATURES_H],
+[
+  AC_CHECK_HEADERS_ONCE([features.h])
+  if test $ac_cv_header_features_h = yes; then
+    HAVE_FEATURES_H=1
+  else
+    HAVE_FEATURES_H=0
+  fi
+  AC_SUBST([HAVE_FEATURES_H])
+])
+
 # m4_foreach_w
 # is a backport of autoconf-2.59c's m4_foreach_w.
 # Remove this macro when we can assume autoconf >= 2.60.
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index 10b34fc..3258417 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -40,6 +40,7 @@ AC_DEFUN([gl_EARLY],
   # Code from module c-strcase:
   # Code from module c-strcaseeq:
   # Code from module canonicalize-lgpl:
+  # Code from module close-hook:
   # Code from module configmake:
   # Code from module duplocale:
   # Code from module environ:
@@ -94,6 +95,7 @@ AC_DEFUN([gl_EARLY],
   # Code from module multiarch:
   # Code from module netdb:
   # Code from module netinet_in:
+  # Code from module nproc:
   # Code from module pathmax:
   # Code from module putenv:
   # Code from module readlink:
@@ -102,6 +104,8 @@ AC_DEFUN([gl_EARLY],
   # Code from module servent:
   # Code from module size_max:
   # Code from module snprintf:
+  # Code from module socketlib:
+  # Code from module sockets:
   # Code from module socklen:
   # Code from module ssize_t:
   # Code from module stat:
@@ -185,6 +189,7 @@ AC_DEFUN([gl_INIT],
   gl_MODULE_INDICATOR([canonicalize-lgpl])
   gl_STDLIB_MODULE_INDICATOR([canonicalize_file_name])
   gl_STDLIB_MODULE_INDICATOR([realpath])
+  # Code from module close-hook:
   # Code from module configmake:
   # Code from module duplocale:
   gl_FUNC_DUPLOCALE
@@ -233,6 +238,7 @@ AC_DEFUN([gl_INIT],
   gl_HOSTENT
   # Code from module iconv:
   AM_ICONV
+  gl_ICONV_MODULE_INDICATOR([iconv])
   # Code from module iconv-h:
   gl_ICONV_H
   # Code from module iconv_open:
@@ -307,6 +313,8 @@ AC_DEFUN([gl_INIT],
   # Code from module netinet_in:
   gl_HEADER_NETINET_IN
   AC_PROG_MKDIR_P
+  # Code from module nproc:
+  gl_NPROC
   # Code from module pathmax:
   gl_PATHMAX
   # Code from module putenv:
@@ -326,6 +334,10 @@ AC_DEFUN([gl_INIT],
   # Code from module snprintf:
   gl_FUNC_SNPRINTF
   gl_STDIO_MODULE_INDICATOR([snprintf])
+  # Code from module socketlib:
+  gl_SOCKETLIB
+  # Code from module sockets:
+  gl_SOCKETS
   # Code from module socklen:
   gl_TYPE_SOCKLEN_T
   # Code from module ssize_t:
@@ -382,10 +394,10 @@ AC_DEFUN([gl_INIT],
   gl_LIBUNISTRING_LIBHEADER([0.9.2], [unistr.h])
   # Code from module unistr/u8-mbtouc:
   gl_MODULE_INDICATOR([unistr/u8-mbtouc])
-  gl_LIBUNISTRING_MODULE([0.9], [unistr/u8-mbtouc])
+  gl_LIBUNISTRING_MODULE([0.9.4], [unistr/u8-mbtouc])
   # Code from module unistr/u8-mbtouc-unsafe:
   gl_MODULE_INDICATOR([unistr/u8-mbtouc-unsafe])
-  gl_LIBUNISTRING_MODULE([0.9], [unistr/u8-mbtouc-unsafe])
+  gl_LIBUNISTRING_MODULE([0.9.4], [unistr/u8-mbtouc-unsafe])
   # Code from module unistr/u8-mbtoucr:
   gl_MODULE_INDICATOR([unistr/u8-mbtoucr])
   gl_LIBUNISTRING_MODULE([0.9], [unistr/u8-mbtoucr])
@@ -580,6 +592,8 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/c-strcaseeq.h
   lib/c-strncasecmp.c
   lib/canonicalize-lgpl.c
+  lib/close-hook.c
+  lib/close-hook.h
   lib/config.charset
   lib/duplocale.c
   lib/errno.in.h
@@ -627,6 +641,8 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/memchr.valgrind
   lib/netdb.in.h
   lib/netinet_in.in.h
+  lib/nproc.c
+  lib/nproc.h
   lib/pathmax.h
   lib/printf-args.c
   lib/printf-args.h
@@ -642,6 +658,8 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/safe-write.h
   lib/size_max.h
   lib/snprintf.c
+  lib/sockets.c
+  lib/sockets.h
   lib/stat-time.h
   lib/stat.c
   lib/stdarg.in.h
@@ -683,6 +701,7 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/version-etc.c
   lib/version-etc.h
   lib/vsnprintf.c
+  lib/w32sock.h
   lib/wchar.in.h
   lib/write.c
   lib/xsize.h
@@ -754,6 +773,7 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/multiarch.m4
   m4/netdb_h.m4
   m4/netinet_in_h.m4
+  m4/nproc.m4
   m4/pathmax.m4
   m4/printf.m4
   m4/putenv.m4
@@ -763,6 +783,8 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/servent.m4
   m4/size_max.m4
   m4/snprintf.m4
+  m4/socketlib.m4
+  m4/sockets.m4
   m4/socklen.m4
   m4/sockpfaf.m4
   m4/ssize_t.m4
diff --git a/m4/iconv.m4 b/m4/iconv.m4
index 425145c..006c907 100644
--- a/m4/iconv.m4
+++ b/m4/iconv.m4
@@ -1,4 +1,4 @@
-# iconv.m4 serial 15 (gettext-0.18.2)
+# iconv.m4 serial 17 (gettext-0.18.2)
 dnl Copyright (C) 2000-2002, 2007-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -78,6 +78,7 @@ AC_DEFUN([AM_ICONV_LINK],
 #include <string.h>
 int main ()
 {
+  int result = 0;
   /* Test against AIX 5.1 bug: Failures are not distinguishable from successful
      returns.  */
   {
@@ -94,7 +95,8 @@ int main ()
                             (char **) &inptr, &inbytesleft,
                             &outptr, &outbytesleft);
         if (res == 0)
-          return 1;
+          result |= 1;
+        iconv_close (cd_utf8_to_88591);
       }
   }
   /* Test against Solaris 10 bug: Failures are not distinguishable from
@@ -113,7 +115,8 @@ int main ()
                             (char **) &inptr, &inbytesleft,
                             &outptr, &outbytesleft);
         if (res == 0)
-          return 1;
+          result |= 2;
+        iconv_close (cd_ascii_to_88591);
       }
   }
   /* Test against AIX 6.1..7.1 bug: Buffer overrun.  */
@@ -131,7 +134,8 @@ int main ()
                             (char **) &inptr, &inbytesleft,
                             &outptr, &outbytesleft);
         if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD)
-          return 1;
+          result |= 4;
+        iconv_close (cd_88591_to_utf8);
       }
   }
 #if 0 /* This bug could be worked around by the caller.  */
@@ -150,7 +154,8 @@ int main ()
                             (char **) &inptr, &inbytesleft,
                             &outptr, &outbytesleft);
         if ((int)res > 0)
-          return 1;
+          result |= 8;
+        iconv_close (cd_88591_to_utf8);
       }
   }
 #endif
@@ -164,8 +169,8 @@ int main ()
       && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
       /* Try HP-UX names.  */
       && iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
-    return 1;
-  return 0;
+    result |= 16;
+  return result;
 }]])],
         [am_cv_func_iconv_works=yes],
         [am_cv_func_iconv_works=no],
@@ -252,5 +257,12 @@ size_t iconv();
          $am_cv_proto_iconv])
     AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1],
       [Define as const if the declaration of iconv() needs const.])
+    dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>.
+    m4_ifdef([gl_ICONV_H_DEFAULTS],
+      [AC_REQUIRE([gl_ICONV_H_DEFAULTS])
+       if test -n "$am_cv_proto_iconv_arg1"; then
+         ICONV_CONST="const"
+       fi
+      ])
   fi
 ])
diff --git a/m4/iconv_h.m4 b/m4/iconv_h.m4
index 7366cb9..3b9987b 100644
--- a/m4/iconv_h.m4
+++ b/m4/iconv_h.m4
@@ -1,4 +1,4 @@
-# iconv_h.m4 serial 6
+# iconv_h.m4 serial 7
 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -29,7 +29,9 @@ AC_DEFUN([gl_ICONV_MODULE_INDICATOR],
 
 AC_DEFUN([gl_ICONV_H_DEFAULTS],
 [
+  GNULIB_ICONV=0;       AC_SUBST([GNULIB_ICONV])
   dnl Assume proper GNU behavior unless another module says otherwise.
+  ICONV_CONST=;         AC_SUBST([ICONV_CONST])
   REPLACE_ICONV=0;      AC_SUBST([REPLACE_ICONV])
   REPLACE_ICONV_OPEN=0; AC_SUBST([REPLACE_ICONV_OPEN])
   REPLACE_ICONV_UTF=0;  AC_SUBST([REPLACE_ICONV_UTF])
diff --git a/m4/iconv_open.m4 b/m4/iconv_open.m4
index 8219ecf..da9b1fd 100644
--- a/m4/iconv_open.m4
+++ b/m4/iconv_open.m4
@@ -1,4 +1,4 @@
-# iconv_open.m4 serial 8
+# iconv_open.m4 serial 11
 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -16,7 +16,7 @@ AC_DEFUN([gl_FUNC_ICONV_OPEN],
     dnl We know that GNU libiconv and GNU libc do.
     AC_EGREP_CPP([gnu_iconv], [
       #include <iconv.h>
-      #if defined _LIBICONV_VERSION || defined __GLIBC__
+      #if defined _LIBICONV_VERSION || (defined __GLIBC__ && !defined 
__UCLIBC__)
        gnu_iconv
       #endif
       ], [gl_func_iconv_gnu=yes], [gl_func_iconv_gnu=no])
@@ -52,12 +52,6 @@ AC_DEFUN([gl_FUNC_ICONV_OPEN_UTF],
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
   AC_REQUIRE([gl_ICONV_H_DEFAULTS])
   if test "$am_cv_func_iconv" = yes; then
-    if test -n "$am_cv_proto_iconv_arg1"; then
-      ICONV_CONST="const"
-    else
-      ICONV_CONST=
-    fi
-    AC_SUBST([ICONV_CONST])
     AC_CACHE_CHECK([whether iconv supports conversion between UTF-8 and 
UTF-{16,32}{BE,LE}],
       [gl_cv_func_iconv_supports_utf],
       [
@@ -70,9 +64,9 @@ AC_DEFUN([gl_FUNC_ICONV_OPEN_UTF],
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#define ASSERT(expr) if (!(expr)) return 1;
 int main ()
 {
+  int result = 0;
   /* Test conversion from UTF-8 to UTF-16BE with no errors.  */
   {
     static const char input[] =
@@ -80,25 +74,33 @@ int main ()
     static const char expected[] =
       "\000J\000a\000p\000a\000n\000e\000s\000e\000 
\000(\145\345\147\054\212\236\000)\000 
\000[\330\065\335\015\330\065\335\036\330\065\335\055\000]";
     iconv_t cd;
-    char buf[100];
-    const char *inptr;
-    size_t inbytesleft;
-    char *outptr;
-    size_t outbytesleft;
-    size_t res;
     cd = iconv_open ("UTF-16BE", "UTF-8");
-    ASSERT (cd != (iconv_t)(-1));
-    inptr = input;
-    inbytesleft = sizeof (input) - 1;
-    outptr = buf;
-    outbytesleft = sizeof (buf);
-    res = iconv (cd,
-                 (ICONV_CONST char **) &inptr, &inbytesleft,
-                 &outptr, &outbytesleft);
-    ASSERT (res == 0 && inbytesleft == 0);
-    ASSERT (outptr == buf + (sizeof (expected) - 1));
-    ASSERT (memcmp (buf, expected, sizeof (expected) - 1) == 0);
-    ASSERT (iconv_close (cd) == 0);
+    if (cd == (iconv_t)(-1))
+      result |= 1;
+    else
+      {
+        char buf[100];
+        const char *inptr;
+        size_t inbytesleft;
+        char *outptr;
+        size_t outbytesleft;
+        size_t res;
+        inptr = input;
+        inbytesleft = sizeof (input) - 1;
+        outptr = buf;
+        outbytesleft = sizeof (buf);
+        res = iconv (cd,
+                     (ICONV_CONST char **) &inptr, &inbytesleft,
+                     &outptr, &outbytesleft);
+        if (!(res == 0 && inbytesleft == 0))
+          result |= 1;
+        else if (!(outptr == buf + (sizeof (expected) - 1)))
+          result |= 1;
+        else if (!(memcmp (buf, expected, sizeof (expected) - 1) == 0))
+          result |= 1;
+        else if (!(iconv_close (cd) == 0))
+          result |= 1;
+      }
   }
   /* Test conversion from UTF-8 to UTF-16LE with no errors.  */
   {
@@ -107,25 +109,33 @@ int main ()
     static const char expected[] =
       "J\000a\000p\000a\000n\000e\000s\000e\000 
\000(\000\345\145\054\147\236\212)\000 
\000[\000\065\330\015\335\065\330\036\335\065\330\055\335]\000";
     iconv_t cd;
-    char buf[100];
-    const char *inptr;
-    size_t inbytesleft;
-    char *outptr;
-    size_t outbytesleft;
-    size_t res;
     cd = iconv_open ("UTF-16LE", "UTF-8");
-    ASSERT (cd != (iconv_t)(-1));
-    inptr = input;
-    inbytesleft = sizeof (input) - 1;
-    outptr = buf;
-    outbytesleft = sizeof (buf);
-    res = iconv (cd,
-                 (ICONV_CONST char **) &inptr, &inbytesleft,
-                 &outptr, &outbytesleft);
-    ASSERT (res == 0 && inbytesleft == 0);
-    ASSERT (outptr == buf + (sizeof (expected) - 1));
-    ASSERT (memcmp (buf, expected, sizeof (expected) - 1) == 0);
-    ASSERT (iconv_close (cd) == 0);
+    if (cd == (iconv_t)(-1))
+      result |= 2;
+    else
+      {
+        char buf[100];
+        const char *inptr;
+        size_t inbytesleft;
+        char *outptr;
+        size_t outbytesleft;
+        size_t res;
+        inptr = input;
+        inbytesleft = sizeof (input) - 1;
+        outptr = buf;
+        outbytesleft = sizeof (buf);
+        res = iconv (cd,
+                     (ICONV_CONST char **) &inptr, &inbytesleft,
+                     &outptr, &outbytesleft);
+        if (!(res == 0 && inbytesleft == 0))
+          result |= 2;
+        else if (!(outptr == buf + (sizeof (expected) - 1)))
+          result |= 2;
+        else if (!(memcmp (buf, expected, sizeof (expected) - 1) == 0))
+          result |= 2;
+        else if (!(iconv_close (cd) == 0))
+          result |= 2;
+      }
   }
   /* Test conversion from UTF-8 to UTF-32BE with no errors.  */
   {
@@ -134,25 +144,33 @@ int main ()
     static const char expected[] =
       
"\000\000\000J\000\000\000a\000\000\000p\000\000\000a\000\000\000n\000\000\000e\000\000\000s\000\000\000e\000\000\000
 
\000\000\000(\000\000\145\345\000\000\147\054\000\000\212\236\000\000\000)\000\000\000
 \000\000\000[\000\001\325\015\000\001\325\036\000\001\325\055\000\000\000]";
     iconv_t cd;
-    char buf[100];
-    const char *inptr;
-    size_t inbytesleft;
-    char *outptr;
-    size_t outbytesleft;
-    size_t res;
     cd = iconv_open ("UTF-32BE", "UTF-8");
-    ASSERT (cd != (iconv_t)(-1));
-    inptr = input;
-    inbytesleft = sizeof (input) - 1;
-    outptr = buf;
-    outbytesleft = sizeof (buf);
-    res = iconv (cd,
-                 (ICONV_CONST char **) &inptr, &inbytesleft,
-                 &outptr, &outbytesleft);
-    ASSERT (res == 0 && inbytesleft == 0);
-    ASSERT (outptr == buf + (sizeof (expected) - 1));
-    ASSERT (memcmp (buf, expected, sizeof (expected) - 1) == 0);
-    ASSERT (iconv_close (cd) == 0);
+    if (cd == (iconv_t)(-1))
+      result |= 4;
+    else
+      {
+        char buf[100];
+        const char *inptr;
+        size_t inbytesleft;
+        char *outptr;
+        size_t outbytesleft;
+        size_t res;
+        inptr = input;
+        inbytesleft = sizeof (input) - 1;
+        outptr = buf;
+        outbytesleft = sizeof (buf);
+        res = iconv (cd,
+                     (ICONV_CONST char **) &inptr, &inbytesleft,
+                     &outptr, &outbytesleft);
+        if (!(res == 0 && inbytesleft == 0))
+          result |= 4;
+        else if (!(outptr == buf + (sizeof (expected) - 1)))
+          result |= 4;
+        else if (!(memcmp (buf, expected, sizeof (expected) - 1) == 0))
+          result |= 4;
+        else if (!(iconv_close (cd) == 0))
+          result |= 4;
+      }
   }
   /* Test conversion from UTF-8 to UTF-32LE with no errors.  */
   {
@@ -161,25 +179,33 @@ int main ()
     static const char expected[] =
       
"J\000\000\000a\000\000\000p\000\000\000a\000\000\000n\000\000\000e\000\000\000s\000\000\000e\000\000\000
 
\000\000\000(\000\000\000\345\145\000\000\054\147\000\000\236\212\000\000)\000\000\000
 
\000\000\000[\000\000\000\015\325\001\000\036\325\001\000\055\325\001\000]\000\000\000";
     iconv_t cd;
-    char buf[100];
-    const char *inptr;
-    size_t inbytesleft;
-    char *outptr;
-    size_t outbytesleft;
-    size_t res;
     cd = iconv_open ("UTF-32LE", "UTF-8");
-    ASSERT (cd != (iconv_t)(-1));
-    inptr = input;
-    inbytesleft = sizeof (input) - 1;
-    outptr = buf;
-    outbytesleft = sizeof (buf);
-    res = iconv (cd,
-                 (ICONV_CONST char **) &inptr, &inbytesleft,
-                 &outptr, &outbytesleft);
-    ASSERT (res == 0 && inbytesleft == 0);
-    ASSERT (outptr == buf + (sizeof (expected) - 1));
-    ASSERT (memcmp (buf, expected, sizeof (expected) - 1) == 0);
-    ASSERT (iconv_close (cd) == 0);
+    if (cd == (iconv_t)(-1))
+      result |= 8;
+    else
+      {
+        char buf[100];
+        const char *inptr;
+        size_t inbytesleft;
+        char *outptr;
+        size_t outbytesleft;
+        size_t res;
+        inptr = input;
+        inbytesleft = sizeof (input) - 1;
+        outptr = buf;
+        outbytesleft = sizeof (buf);
+        res = iconv (cd,
+                     (ICONV_CONST char **) &inptr, &inbytesleft,
+                     &outptr, &outbytesleft);
+        if (!(res == 0 && inbytesleft == 0))
+          result |= 8;
+        else if (!(outptr == buf + (sizeof (expected) - 1)))
+          result |= 8;
+        else if (!(memcmp (buf, expected, sizeof (expected) - 1) == 0))
+          result |= 8;
+        else if ((iconv_close (cd) == 0))
+          result |= 8;
+      }
   }
   /* Test conversion from UTF-16BE to UTF-8 with no errors.
      This test fails on NetBSD 3.0.  */
@@ -189,27 +215,35 @@ int main ()
     static const char expected[] =
       "Japanese (\346\227\245\346\234\254\350\252\236) 
[\360\235\224\215\360\235\224\236\360\235\224\255]";
     iconv_t cd;
-    char buf[100];
-    const char *inptr;
-    size_t inbytesleft;
-    char *outptr;
-    size_t outbytesleft;
-    size_t res;
     cd = iconv_open ("UTF-8", "UTF-16BE");
-    ASSERT (cd != (iconv_t)(-1));
-    inptr = input;
-    inbytesleft = sizeof (input) - 1;
-    outptr = buf;
-    outbytesleft = sizeof (buf);
-    res = iconv (cd,
-                 (ICONV_CONST char **) &inptr, &inbytesleft,
-                 &outptr, &outbytesleft);
-    ASSERT (res == 0 && inbytesleft == 0);
-    ASSERT (outptr == buf + (sizeof (expected) - 1));
-    ASSERT (memcmp (buf, expected, sizeof (expected) - 1) == 0);
-    ASSERT (iconv_close (cd) == 0);
+    if (cd == (iconv_t)(-1))
+      result |= 16;
+    else
+      {
+        char buf[100];
+        const char *inptr;
+        size_t inbytesleft;
+        char *outptr;
+        size_t outbytesleft;
+        size_t res;
+        inptr = input;
+        inbytesleft = sizeof (input) - 1;
+        outptr = buf;
+        outbytesleft = sizeof (buf);
+        res = iconv (cd,
+                     (ICONV_CONST char **) &inptr, &inbytesleft,
+                     &outptr, &outbytesleft);
+        if (!(res == 0 && inbytesleft == 0))
+          result |= 16;
+        else if (!(outptr == buf + (sizeof (expected) - 1)))
+          result |= 16;
+        else if (!(memcmp (buf, expected, sizeof (expected) - 1) == 0))
+          result |= 16;
+        else if (!(iconv_close (cd) == 0))
+          result |= 16;
+      }
   }
-  return 0;
+  return result;
 }]])],
           [gl_cv_func_iconv_supports_utf=yes],
           [gl_cv_func_iconv_supports_utf=no],
diff --git a/m4/include_next.m4 b/m4/include_next.m4
index 51a719b..e37eb05 100644
--- a/m4/include_next.m4
+++ b/m4/include_next.m4
@@ -1,4 +1,4 @@
-# include_next.m4 serial 15
+# include_next.m4 serial 16
 dnl Copyright (C) 2006-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -24,6 +24,13 @@ dnl does not warn about some things, and on some systems 
(Solaris and Interix)
 dnl __STDC__ evaluates to 0 instead of to 1. The latter is an undesired side
 dnl effect; we are therefore careful to use 'defined __STDC__' or '1' instead
 dnl of plain '__STDC__'.
+dnl
+dnl PRAGMA_COLUMNS can be used in files that override system header files, so
+dnl as to avoid compilation errors on HP NonStop systems when the gnulib file
+dnl is included by a system header file that does a "#pragma COLUMNS 80" (which
+dnl has the effect of truncating the lines of that file and all files that it
+dnl includes to 80 columns) and the gnulib file has lines longer than 80
+dnl columns.
 
 AC_DEFUN([gl_INCLUDE_NEXT],
 [
@@ -98,6 +105,24 @@ dnl We intentionally avoid using AC_LANG_SOURCE here.
   AC_SUBST([INCLUDE_NEXT])
   AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE])
   AC_SUBST([PRAGMA_SYSTEM_HEADER])
+  AC_CACHE_CHECK([whether system header files limit the line length],
+    [gl_cv_pragma_columns],
+    [dnl HP NonStop systems, which define __TANDEM, have this misfeature.
+     AC_EGREP_CPP([choke me],
+       [
+#ifdef __TANDEM
+choke me
+#endif
+       ],
+       [gl_cv_pragma_columns=yes],
+       [gl_cv_pragma_columns=no])
+    ])
+  if test $gl_cv_pragma_columns = yes; then
+    PRAGMA_COLUMNS="#pragma COLUMNS 10000"
+  else
+    PRAGMA_COLUMNS=
+  fi
+  AC_SUBST([PRAGMA_COLUMNS])
 ])
 
 # gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...)
diff --git a/m4/isnanf.m4 b/m4/isnanf.m4
index c040090..f1a28e8 100644
--- a/m4/isnanf.m4
+++ b/m4/isnanf.m4
@@ -1,4 +1,4 @@
-# isnanf.m4 serial 11
+# isnanf.m4 serial 12
 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -150,13 +150,13 @@ NaN ()
 typedef union { unsigned int word[NWORDS]; float value; } memory_float;
 int main()
 {
-  memory_float m;
+  int result = 0;
 
   if (isnanf (1.0f / 0.0f))
-    return 1;
+    result |= 1;
 
   if (!isnanf (NaN ()))
-    return 1;
+    result |= 2;
 
 #if defined FLT_EXPBIT0_WORD && defined FLT_EXPBIT0_BIT
   /* The isnanf function should be immune against changes in the sign bit and
@@ -164,16 +164,18 @@ int main()
      a sign bit or a mantissa bit.  */
   if (FLT_EXPBIT0_WORD == 0 && FLT_EXPBIT0_BIT > 0)
     {
+      memory_float m;
+
       m.value = NaN ();
       /* Set the bits below the exponent to 01111...111.  */
       m.word[0] &= -1U << FLT_EXPBIT0_BIT;
       m.word[0] |= 1U << (FLT_EXPBIT0_BIT - 1) - 1;
       if (!isnanf (m.value))
-        return 1;
+        result |= 4;
     }
 #endif
 
-  return 0;
+  return result;
 }]])],
         [gl_cv_func_isnanf_works=yes],
         [gl_cv_func_isnanf_works=no],
diff --git a/m4/isnanl.m4 b/m4/isnanl.m4
index de7eafb..0f425a1 100644
--- a/m4/isnanl.m4
+++ b/m4/isnanl.m4
@@ -1,4 +1,4 @@
-# isnanl.m4 serial 13
+# isnanl.m4 serial 14
 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -151,22 +151,26 @@ static long double NaNl ()
 #endif
 int main ()
 {
-  memory_long_double m;
-  unsigned int i;
+  int result = 0;
 
   if (!isnanl (NaNl ()))
-    return 1;
+    result |= 1;
 
-  /* The isnanl function should be immune against changes in the sign bit and
-     in the mantissa bits.  The xor operation twiddles a bit that can only be
-     a sign bit or a mantissa bit (since the exponent never extends to
-     bit 31).  */
-  m.value = NaNl ();
-  m.word[NWORDS / 2] ^= (unsigned int) 1 << (sizeof (unsigned int) * CHAR_BIT 
- 1);
-  for (i = 0; i < NWORDS; i++)
-    m.word[i] |= 1;
-  if (!isnanl (m.value))
-    return 1;
+  {
+    memory_long_double m;
+    unsigned int i;
+
+    /* The isnanl function should be immune against changes in the sign bit and
+       in the mantissa bits.  The xor operation twiddles a bit that can only be
+       a sign bit or a mantissa bit (since the exponent never extends to
+       bit 31).  */
+    m.value = NaNl ();
+    m.word[NWORDS / 2] ^= (unsigned int) 1 << (sizeof (unsigned int) * 
CHAR_BIT - 1);
+    for (i = 0; i < NWORDS; i++)
+      m.word[i] |= 1;
+    if (!isnanl (m.value))
+      result |= 1;
+  }
 
 #if ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined 
__amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined 
_M_IX86 || defined _X86_))
 /* Representation of an 80-bit 'long double' as an initializer for a sequence
@@ -185,14 +189,14 @@ int main ()
     static memory_long_double x =
       { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) };
     if (!isnanl (x.value))
-      return 1;
+      result |= 2;
   }
   {
     /* Signalling NaN.  */
     static memory_long_double x =
       { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) };
     if (!isnanl (x.value))
-      return 1;
+      result |= 2;
   }
   /* The isnanl function should recognize Pseudo-NaNs, Pseudo-Infinities,
      Pseudo-Zeroes, Unnormalized Numbers, and Pseudo-Denormals, as defined in
@@ -205,35 +209,35 @@ int main ()
     static memory_long_double x =
       { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) };
     if (!isnanl (x.value))
-      return 1;
+      result |= 4;
   }
   { /* Pseudo-Infinity.  */
     static memory_long_double x =
       { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) };
     if (!isnanl (x.value))
-      return 1;
+      result |= 8;
   }
   { /* Pseudo-Zero.  */
     static memory_long_double x =
       { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) };
     if (!isnanl (x.value))
-      return 1;
+      result |= 16;
   }
   { /* Unnormalized number.  */
     static memory_long_double x =
       { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) };
     if (!isnanl (x.value))
-      return 1;
+      result |= 32;
   }
   { /* Pseudo-Denormal.  */
     static memory_long_double x =
       { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) };
     if (!isnanl (x.value))
-      return 1;
+      result |= 64;
   }
 #endif
 
-  return 0;
+  return result;
 }]])],
         [gl_cv_func_isnanl_works=yes],
         [gl_cv_func_isnanl_works=no],
diff --git a/m4/locale-fr.m4 b/m4/locale-fr.m4
index 001f539..e353432 100644
--- a/m4/locale-fr.m4
+++ b/m4/locale-fr.m4
@@ -1,4 +1,4 @@
-# locale-fr.m4 serial 11
+# locale-fr.m4 serial 12
 dnl Copyright (C) 2003, 2005-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -31,11 +31,14 @@ int main () {
      is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
      On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
      succeeds but then nl_langinfo(CODESET) is "646". In this situation,
-     some unit tests fail.  */
+     some unit tests fail.
+     On MirBSD 10, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "UTF-8".  */
 #if HAVE_LANGINFO_CODESET
   {
     const char *cs = nl_langinfo (CODESET);
-    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
+        || strcmp (cs, "UTF-8") == 0)
       return 1;
   }
 #endif
diff --git a/m4/locale-ja.m4 b/m4/locale-ja.m4
index 0eedaf1..3168400 100644
--- a/m4/locale-ja.m4
+++ b/m4/locale-ja.m4
@@ -1,4 +1,4 @@
-# locale-ja.m4 serial 7
+# locale-ja.m4 serial 8
 dnl Copyright (C) 2003, 2005-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -33,11 +33,14 @@ int main ()
      is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
      On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
      succeeds but then nl_langinfo(CODESET) is "646". In this situation,
-     some unit tests fail.  */
+     some unit tests fail.
+     On MirBSD 10, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "UTF-8".  */
 #if HAVE_LANGINFO_CODESET
   {
     const char *cs = nl_langinfo (CODESET);
-    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
+        || strcmp (cs, "UTF-8") == 0)
       return 1;
   }
 #endif
@@ -52,7 +55,7 @@ int main ()
   if (MB_CUR_MAX == 1)
     return 1;
   /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
-     This excludes the UTF-8 encoding.  */
+     This excludes the UTF-8 encoding (except on MirBSD).  */
   t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
   if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
   for (p = buf; *p != '\0'; p++)
diff --git a/m4/locale-zh.m4 b/m4/locale-zh.m4
index 777fd14..be176c1 100644
--- a/m4/locale-zh.m4
+++ b/m4/locale-zh.m4
@@ -1,4 +1,4 @@
-# locale-zh.m4 serial 6
+# locale-zh.m4 serial 7
 dnl Copyright (C) 2003, 2005-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -34,11 +34,14 @@ int main ()
      is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
      On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
      succeeds but then nl_langinfo(CODESET) is "646". In this situation,
-     some unit tests fail.  */
+     some unit tests fail.
+     On MirBSD 10, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "UTF-8".  */
 #if HAVE_LANGINFO_CODESET
   {
     const char *cs = nl_langinfo (CODESET);
-    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
+        || strcmp (cs, "UTF-8") == 0)
       return 1;
   }
 #endif
@@ -49,7 +52,7 @@ int main ()
   if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
 #endif
   /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
-     This excludes the UTF-8 encoding.  */
+     This excludes the UTF-8 encoding (except on MirBSD).  */
   t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
   if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
   for (p = buf; *p != '\0'; p++)
diff --git a/m4/lstat.m4 b/m4/lstat.m4
index 5dbd16e..236af54 100644
--- a/m4/lstat.m4
+++ b/m4/lstat.m4
@@ -1,4 +1,4 @@
-# serial 20
+# serial 21
 
 # Copyright (C) 1997-2001, 2003-2010 Free Software Foundation, Inc.
 #
@@ -26,3 +26,44 @@ AC_DEFUN([gl_FUNC_LSTAT],
     HAVE_LSTAT=0
   fi
 ])
+
+# Redefine AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK, because it is no longer
+# maintained in Autoconf.
+AC_DEFUN([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK],
+[
+  AC_CACHE_CHECK([whether lstat correctly handles trailing slash],
+    [ac_cv_func_lstat_dereferences_slashed_symlink],
+    [rm -f conftest.sym conftest.file
+     echo >conftest.file
+     if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then
+       AC_RUN_IFELSE(
+         [AC_LANG_PROGRAM(
+            [AC_INCLUDES_DEFAULT],
+            [[struct stat sbuf;
+              /* Linux will dereference the symlink and fail, as required by
+                 POSIX.  That is better in the sense that it means we will not
+                 have to compile and use the lstat wrapper.  */
+              return lstat ("conftest.sym/", &sbuf) == 0;
+            ]])],
+         [ac_cv_func_lstat_dereferences_slashed_symlink=yes],
+         [ac_cv_func_lstat_dereferences_slashed_symlink=no],
+         [# When cross-compiling, be pessimistic so we will end up using the
+          # replacement version of lstat that checks for trailing slashes and
+          # calls lstat a second time when necessary.
+          ac_cv_func_lstat_dereferences_slashed_symlink=no
+         ])
+     else
+       # If the 'ln -s' command failed, then we probably don't even
+       # have an lstat function.
+       ac_cv_func_lstat_dereferences_slashed_symlink=no
+     fi
+     rm -f conftest.sym conftest.file
+    ])
+  test $ac_cv_func_lstat_dereferences_slashed_symlink = yes &&
+    AC_DEFINE_UNQUOTED([LSTAT_FOLLOWS_SLASHED_SYMLINK], [1],
+      [Define to 1 if `lstat' dereferences a symlink specified
+       with a trailing slash.])
+  if test "x$ac_cv_func_lstat_dereferences_slashed_symlink" = xno; then
+    AC_LIBOBJ([lstat])
+  fi
+])
diff --git a/m4/mbrlen.m4 b/m4/mbrlen.m4
index 731c2b3..c08cb85 100644
--- a/m4/mbrlen.m4
+++ b/m4/mbrlen.m4
@@ -1,4 +1,4 @@
-# mbrlen.m4 serial 3
+# mbrlen.m4 serial 4
 dnl Copyright (C) 2008, 2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -110,6 +110,7 @@ changequote([,])dnl
 #include <wchar.h>
 int main ()
 {
+  int result = 0;
   /* This fails on Solaris.  */
   if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
     {
@@ -121,7 +122,7 @@ int main ()
         {
           input[1] = '\0';
           if (mbrlen (input + 2, 5, &state) != 1)
-            return 1;
+            result |= 1;
         }
     }
   /* This fails on HP-UX 11.11.  */
@@ -135,10 +136,10 @@ int main ()
         {
           input[1] = '\0';
           if (mbrlen (input + 2, 5, &state) != 2)
-            return 1;
+            result |= 2;
         }
     }
-  return 0;
+  return result;
 }]])],
           [gl_cv_func_mbrlen_retval=yes],
           [gl_cv_func_mbrlen_retval=no],
diff --git a/m4/mbrtowc.m4 b/m4/mbrtowc.m4
index 28b9c43..1de9aab 100644
--- a/m4/mbrtowc.m4
+++ b/m4/mbrtowc.m4
@@ -1,4 +1,4 @@
-# mbrtowc.m4 serial 18
+# mbrtowc.m4 serial 19
 dnl Copyright (C) 2001-2002, 2004-2005, 2008-2010 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
@@ -271,6 +271,7 @@ changequote([,])dnl
 #include <wchar.h>
 int main ()
 {
+  int result = 0;
   /* This fails on Solaris.  */
   if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
     {
@@ -283,7 +284,7 @@ int main ()
         {
           input[1] = '\0';
           if (mbrtowc (&wc, input + 2, 5, &state) != 1)
-            return 1;
+            result |= 1;
         }
     }
   /* This fails on HP-UX 11.11.  */
@@ -298,10 +299,10 @@ int main ()
         {
           input[1] = '\0';
           if (mbrtowc (&wc, input + 2, 5, &state) != 2)
-            return 1;
+            result |= 2;
         }
     }
-  return 0;
+  return result;
 }]])],
           [gl_cv_func_mbrtowc_retval=yes],
           [gl_cv_func_mbrtowc_retval=no],
diff --git a/m4/memchr.m4 b/m4/memchr.m4
index ab773b8..46db9fb 100644
--- a/m4/memchr.m4
+++ b/m4/memchr.m4
@@ -1,4 +1,4 @@
-# memchr.m4 serial 8
+# memchr.m4 serial 10
 dnl Copyright (C) 2002-2004, 2009-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -35,6 +35,7 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
 # endif
 #endif
 ]], [[
+  int result = 0;
   char *fence = NULL;
 #if HAVE_SYS_MMAN_H && HAVE_MPROTECT
 # if HAVE_MAP_ANONYMOUS
@@ -58,12 +59,14 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
   if (fence)
     {
       if (memchr (fence, 0, 0))
-        return 1;
+        result |= 1;
       strcpy (fence - 9, "12345678");
       if (memchr (fence - 9, 0, 79) != fence - 1)
-        return 2;
+        result |= 2;
+      if (memchr (fence - 1, 0, 3) != fence - 1)
+        result |= 4;
     }
-  return 0;
+  return result;
 ]])], [gl_cv_func_memchr_works=yes], [gl_cv_func_memchr_works=no],
       [dnl Be pessimistic for now.
        gl_cv_func_memchr_works="guessing no"])])
diff --git a/m4/mmap-anon.m4 b/m4/mmap-anon.m4
index a6b7b9a..e20fc3c 100644
--- a/m4/mmap-anon.m4
+++ b/m4/mmap-anon.m4
@@ -1,4 +1,4 @@
-# mmap-anon.m4 serial 8
+# mmap-anon.m4 serial 9
 dnl Copyright (C) 2005, 2007, 2009-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -15,10 +15,6 @@ dnl with or without modifications, as long as this notice is 
preserved.
 
 AC_DEFUN([gl_FUNC_MMAP_ANON],
 [
-  dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57.
-  AC_REQUIRE([AC_PROG_CPP])
-  AC_REQUIRE([AC_PROG_EGREP])
-
   dnl Persuade glibc <sys/mman.h> to define MAP_ANONYMOUS.
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
 
diff --git a/m4/nproc.m4 b/m4/nproc.m4
new file mode 100644
index 0000000..06bec97
--- /dev/null
+++ b/m4/nproc.m4
@@ -0,0 +1,53 @@
+# nproc.m4 serial 4
+dnl Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_NPROC],
+[
+  gl_PREREQ_NPROC
+])
+
+# Prerequisites of lib/nproc.c.
+AC_DEFUN([gl_PREREQ_NPROC],
+[
+  dnl Persuade glibc <sched.h> to declare CPU_SETSIZE, CPU_ISSET etc.
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+  AC_CHECK_HEADERS([sys/pstat.h sys/sysmp.h sys/param.h],,,
+    [AC_INCLUDES_DEFAULT])
+  dnl <sys/sysctl.h> requires <sys/param.h> on OpenBSD 4.0.
+  AC_CHECK_HEADERS([sys/sysctl.h],,,
+    [AC_INCLUDES_DEFAULT
+     #if HAVE_SYS_PARAM_H
+     # include <sys/param.h>
+     #endif
+    ])
+
+  AC_CHECK_FUNCS([sched_getaffinity sched_getaffinity_np \
+                  pstat_getdynamic sysmp sysctl])
+
+  dnl Test whether sched_getaffinity has the expected declaration.
+  dnl glibc 2.3.[0-2]:
+  dnl   int sched_getaffinity (pid_t, unsigned int, unsigned long int *);
+  dnl glibc 2.3.3:
+  dnl   int sched_getaffinity (pid_t, cpu_set_t *);
+  dnl glibc >= 2.3.4:
+  dnl   int sched_getaffinity (pid_t, size_t, cpu_set_t *);
+  if test $ac_cv_func_sched_getaffinity = yes; then
+    AC_CACHE_CHECK([for glibc compatible sched_getaffinity],
+      [gl_cv_func_sched_getaffinity3],
+      [AC_COMPILE_IFELSE(
+         [AC_LANG_PROGRAM(
+            [[#include <sched.h>]],
+            [[sched_getaffinity (0, 0, (cpu_set_t *) 0);]])],
+         [gl_cv_func_sched_getaffinity3=yes],
+         [gl_cv_func_sched_getaffinity3=no])
+      ])
+    if test $gl_cv_func_sched_getaffinity3 = yes; then
+      AC_DEFINE([HAVE_SCHED_GETAFFINITY_LIKE_GLIBC], [1],
+        [Define to 1 if sched_getaffinity has a glibc compatible declaration.])
+    fi
+  fi
+])
diff --git a/m4/printf.m4 b/m4/printf.m4
index e850862..6d1cbfe 100644
--- a/m4/printf.m4
+++ b/m4/printf.m4
@@ -1,4 +1,4 @@
-# printf.m4 serial 35
+# printf.m4 serial 40
 dnl Copyright (C) 2003, 2007-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -32,25 +32,26 @@ AC_DEFUN([gl_PRINTF_SIZES_C99],
 static char buf[100];
 int main ()
 {
+  int result = 0;
 #if HAVE_STDINT_H_WITH_UINTMAX || HAVE_INTTYPES_H_WITH_UINTMAX
   buf[0] = '\0';
   if (sprintf (buf, "%ju %d", (uintmax_t) 12345671, 33, 44, 55) < 0
       || strcmp (buf, "12345671 33") != 0)
-    return 1;
+    result |= 1;
 #endif
   buf[0] = '\0';
   if (sprintf (buf, "%zu %d", (size_t) 12345672, 33, 44, 55) < 0
       || strcmp (buf, "12345672 33") != 0)
-    return 1;
+    result |= 2;
   buf[0] = '\0';
   if (sprintf (buf, "%tu %d", (ptrdiff_t) 12345673, 33, 44, 55) < 0
       || strcmp (buf, "12345673 33") != 0)
-    return 1;
+    result |= 4;
   buf[0] = '\0';
   if (sprintf (buf, "%Lg %d", (long double) 1.5, 33, 44, 55) < 0
       || strcmp (buf, "1.5 33") != 0)
-    return 1;
-  return 0;
+    result |= 8;
+  return result;
 }]])],
         [gl_cv_func_printf_sizes_c99=yes],
         [gl_cv_func_printf_sizes_c99=no],
@@ -102,19 +103,20 @@ AC_DEFUN([gl_PRINTF_LONG_DOUBLE],
 static char buf[10000];
 int main ()
 {
+  int result = 0;
   buf[0] = '\0';
   if (sprintf (buf, "%Lf %d", 1.75L, 33, 44, 55) < 0
       || strcmp (buf, "1.750000 33") != 0)
-    return 1;
+    result |= 1;
   buf[0] = '\0';
   if (sprintf (buf, "%Le %d", 1.75L, 33, 44, 55) < 0
       || strcmp (buf, "1.750000e+00 33") != 0)
-    return 1;
+    result |= 2;
   buf[0] = '\0';
   if (sprintf (buf, "%Lg %d", 1.75L, 33, 44, 55) < 0
       || strcmp (buf, "1.75 33") != 0)
-    return 1;
-  return 0;
+    result |= 4;
+  return result;
 }]])],
         [gl_cv_func_printf_long_double=yes],
         [gl_cv_func_printf_long_double=no],
@@ -175,39 +177,40 @@ static char buf[10000];
 static double zero = 0.0;
 int main ()
 {
+  int result = 0;
   if (sprintf (buf, "%f", 1.0 / 0.0) < 0
       || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
-    return 1;
+    result |= 1;
   if (sprintf (buf, "%f", -1.0 / 0.0) < 0
       || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
-    return 1;
+    result |= 1;
   if (sprintf (buf, "%f", zero / zero) < 0
       || !strisnan (buf, 0, strlen (buf)))
-    return 1;
+    result |= 2;
   if (sprintf (buf, "%e", 1.0 / 0.0) < 0
       || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
-    return 1;
+    result |= 4;
   if (sprintf (buf, "%e", -1.0 / 0.0) < 0
       || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
-    return 1;
+    result |= 4;
   if (sprintf (buf, "%e", zero / zero) < 0
       || !strisnan (buf, 0, strlen (buf)))
-    return 1;
+    result |= 8;
   if (sprintf (buf, "%g", 1.0 / 0.0) < 0
       || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
-    return 1;
+    result |= 16;
   if (sprintf (buf, "%g", -1.0 / 0.0) < 0
       || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
-    return 1;
+    result |= 16;
   if (sprintf (buf, "%g", zero / zero) < 0
       || !strisnan (buf, 0, strlen (buf)))
-    return 1;
+    result |= 32;
   /* This test fails on HP-UX 10.20.  */
   if (have_minus_zero ())
     if (sprintf (buf, "%g", - zero) < 0
         || strcmp (buf, "-0") != 0)
-    return 1;
-  return 0;
+    result |= 64;
+  return result;
 }]])],
         [gl_cv_func_printf_infinite=yes],
         [gl_cv_func_printf_infinite=no],
@@ -289,34 +292,35 @@ static char buf[10000];
 static long double zeroL = 0.0L;
 int main ()
 {
+  int result = 0;
   nocrash_init();
   if (sprintf (buf, "%Lf", 1.0L / 0.0L) < 0
       || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
-    return 1;
+    result |= 1;
   if (sprintf (buf, "%Lf", -1.0L / 0.0L) < 0
       || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
-    return 1;
+    result |= 1;
   if (sprintf (buf, "%Lf", zeroL / zeroL) < 0
       || !strisnan (buf, 0, strlen (buf)))
-    return 1;
+    result |= 1;
   if (sprintf (buf, "%Le", 1.0L / 0.0L) < 0
       || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
-    return 1;
+    result |= 1;
   if (sprintf (buf, "%Le", -1.0L / 0.0L) < 0
       || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
-    return 1;
+    result |= 1;
   if (sprintf (buf, "%Le", zeroL / zeroL) < 0
       || !strisnan (buf, 0, strlen (buf)))
-    return 1;
+    result |= 1;
   if (sprintf (buf, "%Lg", 1.0L / 0.0L) < 0
       || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
-    return 1;
+    result |= 1;
   if (sprintf (buf, "%Lg", -1.0L / 0.0L) < 0
       || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
-    return 1;
+    result |= 1;
   if (sprintf (buf, "%Lg", zeroL / zeroL) < 0
       || !strisnan (buf, 0, strlen (buf)))
-    return 1;
+    result |= 1;
 #if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined 
__x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || 
defined _I386 || defined _M_IX86 || defined _X86_))
 /* Representation of an 80-bit 'long double' as an initializer for a sequence
    of 'unsigned int' words.  */
@@ -335,13 +339,13 @@ int main ()
       { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) };
     if (sprintf (buf, "%Lf", x.value) < 0
         || !strisnan (buf, 0, strlen (buf)))
-      return 1;
+      result |= 2;
     if (sprintf (buf, "%Le", x.value) < 0
         || !strisnan (buf, 0, strlen (buf)))
-      return 1;
+      result |= 2;
     if (sprintf (buf, "%Lg", x.value) < 0
         || !strisnan (buf, 0, strlen (buf)))
-      return 1;
+      result |= 2;
   }
   {
     /* Signalling NaN.  */
@@ -349,81 +353,81 @@ int main ()
       { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) };
     if (sprintf (buf, "%Lf", x.value) < 0
         || !strisnan (buf, 0, strlen (buf)))
-      return 1;
+      result |= 2;
     if (sprintf (buf, "%Le", x.value) < 0
         || !strisnan (buf, 0, strlen (buf)))
-      return 1;
+      result |= 2;
     if (sprintf (buf, "%Lg", x.value) < 0
         || !strisnan (buf, 0, strlen (buf)))
-      return 1;
+      result |= 2;
   }
   { /* Pseudo-NaN.  */
     static union { unsigned int word[4]; long double value; } x =
       { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) };
     if (sprintf (buf, "%Lf", x.value) < 0
         || !strisnan (buf, 0, strlen (buf)))
-      return 1;
+      result |= 4;
     if (sprintf (buf, "%Le", x.value) < 0
         || !strisnan (buf, 0, strlen (buf)))
-      return 1;
+      result |= 4;
     if (sprintf (buf, "%Lg", x.value) < 0
         || !strisnan (buf, 0, strlen (buf)))
-      return 1;
+      result |= 4;
   }
   { /* Pseudo-Infinity.  */
     static union { unsigned int word[4]; long double value; } x =
       { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) };
     if (sprintf (buf, "%Lf", x.value) < 0
         || !strisnan (buf, 0, strlen (buf)))
-      return 1;
+      result |= 8;
     if (sprintf (buf, "%Le", x.value) < 0
         || !strisnan (buf, 0, strlen (buf)))
-      return 1;
+      result |= 8;
     if (sprintf (buf, "%Lg", x.value) < 0
         || !strisnan (buf, 0, strlen (buf)))
-      return 1;
+      result |= 8;
   }
   { /* Pseudo-Zero.  */
     static union { unsigned int word[4]; long double value; } x =
       { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) };
     if (sprintf (buf, "%Lf", x.value) < 0
         || !strisnan (buf, 0, strlen (buf)))
-      return 1;
+      result |= 16;
     if (sprintf (buf, "%Le", x.value) < 0
         || !strisnan (buf, 0, strlen (buf)))
-      return 1;
+      result |= 16;
     if (sprintf (buf, "%Lg", x.value) < 0
         || !strisnan (buf, 0, strlen (buf)))
-      return 1;
+      result |= 16;
   }
   { /* Unnormalized number.  */
     static union { unsigned int word[4]; long double value; } x =
       { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) };
     if (sprintf (buf, "%Lf", x.value) < 0
         || !strisnan (buf, 0, strlen (buf)))
-      return 1;
+      result |= 32;
     if (sprintf (buf, "%Le", x.value) < 0
         || !strisnan (buf, 0, strlen (buf)))
-      return 1;
+      result |= 32;
     if (sprintf (buf, "%Lg", x.value) < 0
         || !strisnan (buf, 0, strlen (buf)))
-      return 1;
+      result |= 32;
   }
   { /* Pseudo-Denormal.  */
     static union { unsigned int word[4]; long double value; } x =
       { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) };
     if (sprintf (buf, "%Lf", x.value) < 0
         || !strisnan (buf, 0, strlen (buf)))
-      return 1;
+      result |= 64;
     if (sprintf (buf, "%Le", x.value) < 0
         || !strisnan (buf, 0, strlen (buf)))
-      return 1;
+      result |= 64;
     if (sprintf (buf, "%Lg", x.value) < 0
         || !strisnan (buf, 0, strlen (buf)))
-      return 1;
+      result |= 64;
   }
 #endif
-  return 0;
+  return result;
 }]])],
             [gl_cv_func_printf_infinite_long_double=yes],
             [gl_cv_func_printf_infinite_long_double=no],
@@ -439,16 +443,9 @@ changequote(,)dnl
                                          # Guess yes on FreeBSD >= 6.
                    freebsd[1-5]*)        
gl_cv_func_printf_infinite_long_double="guessing no";;
                    freebsd* | kfreebsd*) 
gl_cv_func_printf_infinite_long_double="guessing yes";;
-                                         # Guess yes on MacOS X >= 10.3.
-                   darwin[1-6].*)        
gl_cv_func_printf_infinite_long_double="guessing no";;
-                   darwin*)              
gl_cv_func_printf_infinite_long_double="guessing yes";;
                                          # Guess yes on HP-UX >= 11.
                    hpux[7-9]* | hpux10*) 
gl_cv_func_printf_infinite_long_double="guessing no";;
                    hpux*)                
gl_cv_func_printf_infinite_long_double="guessing yes";;
-                                         # Guess yes on NetBSD >= 3.
-                   netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | 
netbsdcoff[1-2]*)
-                                         
gl_cv_func_printf_infinite_long_double="guessing no";;
-                   netbsd*)              
gl_cv_func_printf_infinite_long_double="guessing yes";;
                                          # If we don't know, assume the worst.
                    *)                    
gl_cv_func_printf_infinite_long_double="guessing no";;
                  esac
@@ -483,37 +480,38 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_A],
 static char buf[100];
 int main ()
 {
+  int result = 0;
   if (sprintf (buf, "%a %d", 3.1416015625, 33, 44, 55) < 0
       || (strcmp (buf, "0x1.922p+1 33") != 0
           && strcmp (buf, "0x3.244p+0 33") != 0
           && strcmp (buf, "0x6.488p-1 33") != 0
           && strcmp (buf, "0xc.91p-2 33") != 0))
-    return 1;
+    result |= 1;
   if (sprintf (buf, "%A %d", -3.1416015625, 33, 44, 55) < 0
       || (strcmp (buf, "-0X1.922P+1 33") != 0
           && strcmp (buf, "-0X3.244P+0 33") != 0
           && strcmp (buf, "-0X6.488P-1 33") != 0
           && strcmp (buf, "-0XC.91P-2 33") != 0))
-    return 1;
+    result |= 2;
   /* This catches a FreeBSD 6.1 bug: it doesn't round.  */
   if (sprintf (buf, "%.2a %d", 1.51, 33, 44, 55) < 0
       || (strcmp (buf, "0x1.83p+0 33") != 0
           && strcmp (buf, "0x3.05p-1 33") != 0
           && strcmp (buf, "0x6.0ap-2 33") != 0
           && strcmp (buf, "0xc.14p-3 33") != 0))
-    return 1;
+    result |= 4;
   /* This catches a FreeBSD 6.1 bug.  See
      <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
   if (sprintf (buf, "%010a %d", 1.0 / 0.0, 33, 44, 55) < 0
       || buf[0] == '0')
-    return 1;
+    result |= 8;
   /* This catches a MacOS X 10.3.9 (Darwin 7.9) bug.  */
   if (sprintf (buf, "%.1a", 1.999) < 0
       || (strcmp (buf, "0x1.0p+1") != 0
           && strcmp (buf, "0x2.0p+0") != 0
           && strcmp (buf, "0x4.0p-1") != 0
           && strcmp (buf, "0x8.0p-2") != 0))
-    return 1;
+    result |= 16;
   /* This catches the same MacOS X 10.3.9 (Darwin 7.9) bug and also a
      glibc 2.4 bug <http://sourceware.org/bugzilla/show_bug.cgi?id=2908>.  */
   if (sprintf (buf, "%.1La", 1.999L) < 0
@@ -521,8 +519,8 @@ int main ()
           && strcmp (buf, "0x2.0p+0") != 0
           && strcmp (buf, "0x4.0p-1") != 0
           && strcmp (buf, "0x8.0p-2") != 0))
-    return 1;
-  return 0;
+    result |= 32;
+  return result;
 }]])],
         [gl_cv_func_printf_directive_a=yes],
         [gl_cv_func_printf_directive_a=no],
@@ -533,7 +531,7 @@ int main ()
              AC_EGREP_CPP([BZ2908], [
                #include <features.h>
                #ifdef __GNU_LIBRARY__
-                #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 5) || (__GLIBC__ > 2)
+                #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 5) || (__GLIBC__ > 
2)) && !defined __UCLIBC__
                  BZ2908
                 #endif
                #endif
@@ -566,17 +564,18 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_F],
 static char buf[100];
 int main ()
 {
+  int result = 0;
   if (sprintf (buf, "%F %d", 1234567.0, 33, 44, 55) < 0
       || strcmp (buf, "1234567.000000 33") != 0)
-    return 1;
+    result |= 1;
   if (sprintf (buf, "%F", 1.0 / 0.0) < 0
       || (strcmp (buf, "INF") != 0 && strcmp (buf, "INFINITY") != 0))
-    return 1;
+    result |= 2;
   /* This catches a Cygwin 1.5.x bug.  */
   if (sprintf (buf, "%.F", 1234.0) < 0
       || strcmp (buf, "1234") != 0)
-    return 1;
-  return 0;
+    result |= 4;
+  return result;
 }]])],
         [gl_cv_func_printf_directive_f=yes],
         [gl_cv_func_printf_directive_f=no],
@@ -671,6 +670,7 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_LS],
 #include <string.h>
 int main ()
 {
+  int result = 0;
   char buf[100];
   /* Test whether %ls works at all.
      This test fails on OpenBSD 4.0, IRIX 6.5, Solaris 2.6, Haiku, but not on
@@ -680,7 +680,7 @@ int main ()
     buf[0] = '\0';
     if (sprintf (buf, "%ls", wstring) < 0
         || strcmp (buf, "abc") != 0)
-      return 1;
+      result |= 1;
   }
   /* This test fails on IRIX 6.5, Solaris 2.6, Cygwin 1.5, Haiku (with an
      assertion failure inside libc), but not on OpenBSD 4.0.  */
@@ -689,7 +689,7 @@ int main ()
     buf[0] = '\0';
     if (sprintf (buf, "%ls", wstring) < 0
         || strcmp (buf, "a") != 0)
-      return 1;
+      result |= 2;
   }
   /* Test whether precisions in %ls are supported as specified in ISO C 99
      section 7.19.6.1:
@@ -704,9 +704,9 @@ int main ()
     buf[0] = '\0';
     if (sprintf (buf, "%.2ls", wstring) < 0
         || strcmp (buf, "ab") != 0)
-      return 1;
+      result |= 8;
   }
-  return 0;
+  return result;
 }]])],
         [gl_cv_func_printf_directive_ls=yes],
         [gl_cv_func_printf_directive_ls=no],
@@ -889,8 +889,9 @@ changequote([,])dnl
 
 dnl Test whether the *printf family of functions supports large precisions.
 dnl On mingw, precisions larger than 512 are treated like 512, in integer,
-dnl floating-point or pointer output. On BeOS, precisions larger than 1044
-dnl crash the program.
+dnl floating-point or pointer output. On Solaris 10/x86, precisions larger
+dnl than 510 in floating-point output crash the program. On BeOS, precisions
+dnl larger than 1044 crash the program.
 dnl Result is gl_cv_func_printf_precision.
 
 AC_DEFUN([gl_PRINTF_PRECISION],
@@ -907,20 +908,24 @@ AC_DEFUN([gl_PRINTF_PRECISION],
 static char buf[5000];
 int main ()
 {
+  int result = 0;
 #ifdef __BEOS__
   /* On BeOS, this would crash and show a dialog box.  Avoid the crash.  */
   return 1;
 #endif
   if (sprintf (buf, "%.4000d %d", 1, 33, 44) < 4000 + 3)
-    return 1;
-  return 0;
+    result |= 1;
+  if (sprintf (buf, "%.4000f %d", 1.0, 33, 44) < 4000 + 5)
+    result |= 2;
+  return result;
 }]])],
         [gl_cv_func_printf_precision=yes],
         [gl_cv_func_printf_precision=no],
         [
 changequote(,)dnl
          case "$host_os" in
-           # Guess no only on native Win32 and BeOS systems.
+           # Guess no only on Solaris, native Win32, and BeOS systems.
+           solaris*)     gl_cv_func_printf_precision="guessing no" ;;
            mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;;
            beos*)        gl_cv_func_printf_precision="guessing no" ;;
            *)            gl_cv_func_printf_precision="guessing yes" ;;
@@ -1439,12 +1444,14 @@ dnl                                  1  2  3  4  5  6  
7  8  9 10 11 12 13 14 15
 dnl   glibc 2.5                      .  .  .  .  .  .  .  .  .  .  .  .  .  .  
.  .  .  .  .  .
 dnl   glibc 2.3.6                    .  .  .  .  #  .  .  .  .  .  .  .  .  .  
.  .  .  .  .  .
 dnl   FreeBSD 5.4, 6.1               .  .  .  .  #  .  .  .  .  .  .  #  .  #  
.  .  .  .  .  .
+dnl   MacOS X 10.5.8                 .  .  .  #  #  .  .  .  .  .  .  #  .  .  
.  .  .  .  .  .
 dnl   MacOS X 10.3.9                 .  .  .  .  #  .  .  .  .  .  .  #  .  #  
.  .  .  .  .  .
 dnl   OpenBSD 3.9, 4.0               .  .  #  #  #  #  .  #  .  #  .  #  .  #  
.  .  .  .  .  .
 dnl   Cygwin 1.7.0 (2009)            .  .  .  #  .  .  .  ?  .  .  .  .  .  ?  
.  .  .  .  .  .
 dnl   Cygwin 1.5.25 (2008)           .  .  .  #  #  .  .  #  .  .  .  .  .  #  
.  .  .  .  .  .
 dnl   Cygwin 1.5.19 (2006)           #  .  .  #  #  #  .  #  .  #  .  #  #  #  
.  .  .  .  .  .
-dnl   Solaris 10                     .  .  #  #  #  .  .  #  .  .  .  #  .  .  
.  .  .  .  .  .
+dnl   Solaris 11 2010-11             .  .  #  #  #  .  .  #  .  .  .  #  .  .  
.  .  .  .  .  .
+dnl   Solaris 10                     .  .  #  #  #  .  .  #  .  .  .  #  #  .  
.  .  .  .  .  .
 dnl   Solaris 2.6 ... 9              #  .  #  #  #  #  .  #  .  .  .  #  .  .  
.  .  .  .  .  .
 dnl   Solaris 2.5.1                  #  .  #  #  #  #  .  #  .  .  .  #  .  .  
#  #  #  #  #  #
 dnl   AIX 5.2, 7.1                   .  .  #  #  #  .  .  .  .  .  .  #  .  .  
.  .  .  .  .  .
@@ -1455,6 +1462,7 @@ dnl   HP-UX 10.20                    #  .  #  .  #  #  .  
?  .  .  #  #  .  .  .
 dnl   IRIX 6.5                       #  .  #  #  #  #  .  #  .  .  .  #  .  .  
.  .  #  .  .  .
 dnl   OSF/1 5.1                      #  .  #  #  #  #  .  .  .  .  .  #  .  .  
.  .  #  .  .  #
 dnl   OSF/1 4.0d                     #  .  #  #  #  #  .  .  .  .  .  #  .  .  
#  #  #  #  #  #
+dnl   NetBSD 5.0                     .  .  .  #  #  .  .  .  .  .  .  #  .  #  
.  .  .  .  .  .
 dnl   NetBSD 4.0                     .  ?  ?  ?  ?  ?  .  ?  .  ?  ?  ?  ?  ?  
.  .  .  ?  ?  ?
 dnl   NetBSD 3.0                     .  .  .  .  #  #  .  ?  #  #  ?  #  .  #  
.  .  .  .  .  .
 dnl   Haiku                          .  .  .  #  #  #  .  #  .  .  .  .  .  ?  
.  .  .  .  .  .
diff --git a/m4/putenv.m4 b/m4/putenv.m4
index dd9140c..a7f0b27 100644
--- a/m4/putenv.m4
+++ b/m4/putenv.m4
@@ -1,4 +1,4 @@
-# putenv.m4 serial 16
+# putenv.m4 serial 17
 dnl Copyright (C) 2002-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -21,11 +21,11 @@ AC_DEFUN([gl_FUNC_PUTENV],
 
     /* Try to remove it.  */
     if (putenv ("CONFTEST_putenv"))
-      return 1;
+      return 2;
 
     /* Make sure it was deleted.  */
     if (getenv ("CONFTEST_putenv") != 0)
-      return 1;
+      return 3;
 
     return 0;
               ]])],
diff --git a/m4/socketlib.m4 b/m4/socketlib.m4
new file mode 100644
index 0000000..7bf02b5
--- /dev/null
+++ b/m4/socketlib.m4
@@ -0,0 +1,86 @@
+# socketlib.m4 serial 1
+dnl Copyright (C) 2008-2010 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl gl_SOCKETLIB
+dnl Determines the library to use for socket functions.
+dnl Sets and AC_SUBSTs LIBSOCKET.
+
+AC_DEFUN([gl_SOCKETLIB],
+[
+  gl_PREREQ_SYS_H_WINSOCK2 dnl for HAVE_WINSOCK2_H
+  LIBSOCKET=
+  if test $HAVE_WINSOCK2_H = 1; then
+    dnl Native Windows API (not Cygwin).
+    AC_CACHE_CHECK([if we need to call WSAStartup in winsock2.h and -lws2_32],
+                   [gl_cv_func_wsastartup], [
+      gl_save_LIBS="$LIBS"
+      LIBS="$LIBS -lws2_32"
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#ifdef HAVE_WINSOCK2_H
+# include <winsock2.h>
+#endif]], [[
+          WORD wVersionRequested = MAKEWORD(1, 1);
+          WSADATA wsaData;
+          int err = WSAStartup(wVersionRequested, &wsaData);
+          WSACleanup ();]])],
+        gl_cv_func_wsastartup=yes, gl_cv_func_wsastartup=no)
+      LIBS="$gl_save_LIBS"
+    ])
+    if test "$gl_cv_func_wsastartup" = "yes"; then
+      AC_DEFINE([WINDOWS_SOCKETS], [1], [Define if WSAStartup is needed.])
+      LIBSOCKET='-lws2_32'
+    fi
+  else
+    dnl Unix API.
+    dnl Solaris has most socket functions in libsocket.
+    dnl Haiku has most socket functions in libnetwork.
+    dnl BeOS has most socket functions in libnet.
+    AC_CACHE_CHECK([for library containing setsockopt], [gl_cv_lib_socket], [
+      gl_cv_lib_socket=
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
+#ifdef __cplusplus
+"C"
+#endif
+char setsockopt();]], [[setsockopt();]])],
+        [],
+        [gl_save_LIBS="$LIBS"
+         LIBS="$gl_save_LIBS -lsocket"
+         AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
+#ifdef __cplusplus
+"C"
+#endif
+char setsockopt();]], [[setsockopt();]])],
+           [gl_cv_lib_socket="-lsocket"])
+         if test -z "$gl_cv_lib_socket"; then
+           LIBS="$gl_save_LIBS -lnetwork"
+           AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
+#ifdef __cplusplus
+"C"
+#endif
+char setsockopt();]], [[setsockopt();]])],
+             [gl_cv_lib_socket="-lnetwork"])
+           if test -z "$gl_cv_lib_socket"; then
+             LIBS="$gl_save_LIBS -lnet"
+             AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
+#ifdef __cplusplus
+"C"
+#endif
+char setsockopt();]], [[setsockopt();]])],
+               [gl_cv_lib_socket="-lnet"])
+           fi
+         fi
+         LIBS="$gl_save_LIBS"
+        ])
+      if test -z "$gl_cv_lib_socket"; then
+        gl_cv_lib_socket="none needed"
+      fi
+    ])
+    if test "$gl_cv_lib_socket" != "none needed"; then
+      LIBSOCKET="$gl_cv_lib_socket"
+    fi
+  fi
+  AC_SUBST([LIBSOCKET])
+])
diff --git a/m4/sockets.m4 b/m4/sockets.m4
new file mode 100644
index 0000000..ba9a563
--- /dev/null
+++ b/m4/sockets.m4
@@ -0,0 +1,17 @@
+# sockets.m4 serial 7
+dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_SOCKETS],
+[
+  AC_REQUIRE([AC_C_INLINE])
+  AC_REQUIRE([gl_SOCKETLIB])
+  gl_PREREQ_SOCKETS
+])
+
+# Prerequisites of lib/sockets.c.
+AC_DEFUN([gl_PREREQ_SOCKETS], [
+  :
+])
diff --git a/m4/stat.m4 b/m4/stat.m4
index 75e1d94..1ad8ef5 100644
--- a/m4/stat.m4
+++ b/m4/stat.m4
@@ -1,4 +1,4 @@
-# serial 5
+# serial 6
 
 # Copyright (C) 2009, 2010 Free Software Foundation, Inc.
 #
@@ -36,11 +36,15 @@ AC_DEFUN([gl_FUNC_STAT],
        AC_RUN_IFELSE(
          [AC_LANG_PROGRAM(
            [[#include <sys/stat.h>
-]], [[struct stat st;
-      if (!stat ("conftest.tmp/", &st)) return 1;
+]], [[int result = 0;
+      struct stat st;
+      if (!stat ("conftest.tmp/", &st))
+        result |= 1;
 #if HAVE_LSTAT
-      if (!stat ("conftest.lnk/", &st)) return 2;
+      if (!stat ("conftest.lnk/", &st))
+        result |= 2;
 #endif
+      return result;
            ]])],
          [gl_cv_func_stat_file_slash=yes], [gl_cv_func_stat_file_slash=no],
          [gl_cv_func_stat_file_slash="guessing no"])
diff --git a/m4/stdint.m4 b/m4/stdint.m4
index c5e813a..7fe2836 100644
--- a/m4/stdint.m4
+++ b/m4/stdint.m4
@@ -1,4 +1,4 @@
-# stdint.m4 serial 35
+# stdint.m4 serial 36
 dnl Copyright (C) 2001-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -259,7 +259,7 @@ static const char *macro_values[] =
           || strncmp (value, "((int)"/*)*/, 6) == 0
           || strncmp (value, "((signed short)"/*)*/, 15) == 0
           || strncmp (value, "((signed char)"/*)*/, 14) == 0)
-        return 1;
+        return mv - macro_values + 1;
     }
   return 0;
 ]])],
diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4
index fc15019..e4697ce 100644
--- a/m4/stdlib_h.m4
+++ b/m4/stdlib_h.m4
@@ -1,4 +1,4 @@
-# stdlib_h.m4 serial 30
+# stdlib_h.m4 serial 31
 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -73,6 +73,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
   GNULIB_STRTOD=0;        AC_SUBST([GNULIB_STRTOD])
   GNULIB_STRTOLL=0;       AC_SUBST([GNULIB_STRTOLL])
   GNULIB_STRTOULL=0;      AC_SUBST([GNULIB_STRTOULL])
+  GNULIB_SYSTEM_POSIX=0;  AC_SUBST([GNULIB_SYSTEM_POSIX])
   GNULIB_UNLOCKPT=0;      AC_SUBST([GNULIB_UNLOCKPT])
   GNULIB_UNSETENV=0;      AC_SUBST([GNULIB_UNSETENV])
   dnl Assume proper GNU behavior unless another module says otherwise.
diff --git a/m4/string_h.m4 b/m4/string_h.m4
index 1977aec..5844b2d 100644
--- a/m4/string_h.m4
+++ b/m4/string_h.m4
@@ -5,7 +5,7 @@
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 17
+# serial 18
 
 # Written by Paul Eggert.
 
@@ -28,8 +28,8 @@ AC_DEFUN([gl_HEADER_STRING_H_BODY],
   gl_WARN_ON_USE_PREPARE([[#include <string.h>
     ]],
     [memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul strdup
-     strncat strndup strnlen strpbrk strsep strcasestr strtok_r strsignal
-     strverscmp])
+     strncat strndup strnlen strpbrk strsep strcasestr strtok_r strerror_r
+     strsignal strverscmp])
 ])
 
 AC_DEFUN([gl_STRING_MODULE_INDICATOR],
@@ -75,6 +75,7 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
   GNULIB_MBSSEP=0;      AC_SUBST([GNULIB_MBSSEP])
   GNULIB_MBSTOK_R=0;    AC_SUBST([GNULIB_MBSTOK_R])
   GNULIB_STRERROR=0;    AC_SUBST([GNULIB_STRERROR])
+  GNULIB_STRERROR_R=0;  AC_SUBST([GNULIB_STRERROR_R])
   GNULIB_STRSIGNAL=0;   AC_SUBST([GNULIB_STRSIGNAL])
   GNULIB_STRVERSCMP=0;  AC_SUBST([GNULIB_STRVERSCMP])
   HAVE_MBSLEN=0;        AC_SUBST([HAVE_MBSLEN])
@@ -94,6 +95,7 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
   HAVE_STRSEP=1;                AC_SUBST([HAVE_STRSEP])
   HAVE_STRCASESTR=1;            AC_SUBST([HAVE_STRCASESTR])
   HAVE_DECL_STRTOK_R=1;         AC_SUBST([HAVE_DECL_STRTOK_R])
+  HAVE_DECL_STRERROR_R=1;       AC_SUBST([HAVE_DECL_STRERROR_R])
   HAVE_DECL_STRSIGNAL=1;        AC_SUBST([HAVE_DECL_STRSIGNAL])
   HAVE_STRVERSCMP=1;            AC_SUBST([HAVE_STRVERSCMP])
   REPLACE_MEMCHR=0;             AC_SUBST([REPLACE_MEMCHR])
@@ -103,6 +105,7 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
   REPLACE_STRSTR=0;             AC_SUBST([REPLACE_STRSTR])
   REPLACE_STRCASESTR=0;         AC_SUBST([REPLACE_STRCASESTR])
   REPLACE_STRERROR=0;           AC_SUBST([REPLACE_STRERROR])
+  REPLACE_STRERROR_R=0;         AC_SUBST([REPLACE_STRERROR_R])
   REPLACE_STRNCAT=0;            AC_SUBST([REPLACE_STRNCAT])
   REPLACE_STRNDUP=0;            AC_SUBST([REPLACE_STRNDUP])
   REPLACE_STRNLEN=0;            AC_SUBST([REPLACE_STRNLEN])
diff --git a/m4/sys_socket_h.m4 b/m4/sys_socket_h.m4
index 9f4db56..c7627cb 100644
--- a/m4/sys_socket_h.m4
+++ b/m4/sys_socket_h.m4
@@ -1,4 +1,4 @@
-# sys_socket_h.m4 serial 17
+# sys_socket_h.m4 serial 20
 dnl Copyright (C) 2005-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -57,6 +57,23 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET],
   if test $ac_cv_type_sa_family_t = no; then
     HAVE_SA_FAMILY_T=0
   fi
+  if test $ac_cv_type_struct_sockaddr_storage != no; then
+    AC_CHECK_MEMBERS([struct sockaddr_storage.ss_family],
+      [],
+      [HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY=0],
+      [#include <sys/types.h>
+       #ifdef HAVE_SYS_SOCKET_H
+       #include <sys/socket.h>
+       #endif
+       #ifdef HAVE_WS2TCPIP_H
+       #include <ws2tcpip.h>
+       #endif
+      ])
+  fi
+  if test $HAVE_STRUCT_SOCKADDR_STORAGE = 0 || test $HAVE_SA_FAMILY_T = 0 \
+     || test $HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY = 0; then
+    SYS_SOCKET_H='sys/socket.h'
+  fi
   gl_PREREQ_SYS_H_WINSOCK2
 
   dnl Check for declarations of anything we want to poison if the
@@ -64,10 +81,7 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET],
   gl_WARN_ON_USE_PREPARE([[
 /* Some systems require prerequisite headers.  */
 #include <sys/types.h>
-#if !defined __GLIBC__ && HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
-#include <sys/select.h>
+#include <sys/socket.h>
     ]], [socket connect accept bind getpeername getsockname getsockopt
     listen recv send recvfrom sendto setsockopt shutdown accept4])
 ])
@@ -148,6 +162,8 @@ AC_DEFUN([gl_SYS_SOCKET_H_DEFAULTS],
   GNULIB_SHUTDOWN=0;    AC_SUBST([GNULIB_SHUTDOWN])
   GNULIB_ACCEPT4=0;     AC_SUBST([GNULIB_ACCEPT4])
   HAVE_STRUCT_SOCKADDR_STORAGE=1; AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE])
+  HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY=1;
+                        AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY])
   HAVE_SA_FAMILY_T=1;   AC_SUBST([HAVE_SA_FAMILY_T])
   HAVE_ACCEPT4=1;       AC_SUBST([HAVE_ACCEPT4])
 ])
diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4
index 48d06c7..e2f7f2b 100644
--- a/m4/unistd_h.m4
+++ b/m4/unistd_h.m4
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 46
+# unistd_h.m4 serial 48
 dnl Copyright (C) 2006-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -27,7 +27,7 @@ AC_DEFUN([gl_UNISTD_H],
   dnl corresponding gnulib module is not in use.
   gl_WARN_ON_USE_PREPARE([[#include <unistd.h>
 /* Some systems declare various items in the wrong headers.  */
-#ifndef __GLIBC__
+#if !(defined __GLIBC__ && !defined __UCLIBC__)
 # include <fcntl.h>
 # include <stdio.h>
 # include <stdlib.h>
@@ -104,7 +104,6 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   HAVE_FCHOWNAT=1;        AC_SUBST([HAVE_FCHOWNAT])
   HAVE_FSYNC=1;           AC_SUBST([HAVE_FSYNC])
   HAVE_FTRUNCATE=1;       AC_SUBST([HAVE_FTRUNCATE])
-  HAVE_GETDOMAINNAME=1;   AC_SUBST([HAVE_GETDOMAINNAME])
   HAVE_GETDTABLESIZE=1;   AC_SUBST([HAVE_GETDTABLESIZE])
   HAVE_GETGROUPS=1;       AC_SUBST([HAVE_GETGROUPS])
   HAVE_GETHOSTNAME=1;     AC_SUBST([HAVE_GETHOSTNAME])
@@ -125,6 +124,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   HAVE_UNLINKAT=1;        AC_SUBST([HAVE_UNLINKAT])
   HAVE_USLEEP=1;          AC_SUBST([HAVE_USLEEP])
   HAVE_DECL_ENVIRON=1;    AC_SUBST([HAVE_DECL_ENVIRON])
+  HAVE_DECL_GETDOMAINNAME=1; AC_SUBST([HAVE_DECL_GETDOMAINNAME])
   HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R])
   HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE])
   HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL])
@@ -136,6 +136,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   REPLACE_DUP2=0;         AC_SUBST([REPLACE_DUP2])
   REPLACE_FCHOWNAT=0;     AC_SUBST([REPLACE_FCHOWNAT])
   REPLACE_GETCWD=0;       AC_SUBST([REPLACE_GETCWD])
+  REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME])
   REPLACE_GETGROUPS=0;    AC_SUBST([REPLACE_GETGROUPS])
   REPLACE_GETPAGESIZE=0;  AC_SUBST([REPLACE_GETPAGESIZE])
   REPLACE_LCHOWN=0;       AC_SUBST([REPLACE_LCHOWN])
diff --git a/m4/vasnprintf.m4 b/m4/vasnprintf.m4
index ebe3c52..9c04520 100644
--- a/m4/vasnprintf.m4
+++ b/m4/vasnprintf.m4
@@ -1,4 +1,4 @@
-# vasnprintf.m4 serial 31
+# vasnprintf.m4 serial 32
 dnl Copyright (C) 2002-2004, 2006-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -40,6 +40,7 @@ AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
 # Prequisites of lib/printf-parse.h, lib/printf-parse.c.
 AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
 [
+  AC_REQUIRE([gl_FEATURES_H])
   AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
   AC_REQUIRE([gt_TYPE_WCHAR_T])
   AC_REQUIRE([gt_TYPE_WINT_T])
diff --git a/m4/wchar_h.m4 b/m4/wchar_h.m4
index 8cae82d..8c8fad9 100644
--- a/m4/wchar_h.m4
+++ b/m4/wchar_h.m4
@@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is 
preserved.
 
 dnl Written by Eric Blake.
 
-# wchar_h.m4 serial 33
+# wchar_h.m4 serial 35
 
 AC_DEFUN([gl_WCHAR_H],
 [
@@ -26,6 +26,8 @@ AC_DEFUN([gl_WCHAR_H],
   fi
   AC_SUBST([HAVE_WCHAR_H])
 
+  AC_REQUIRE([gl_FEATURES_H])
+
   AC_REQUIRE([gt_TYPE_WINT_T])
   if test $gt_cv_c_wint_t = yes; then
     HAVE_WINT_T=1
@@ -38,7 +40,7 @@ AC_DEFUN([gl_WCHAR_H],
   dnl corresponding gnulib module is not in use.
   gl_WARN_ON_USE_PREPARE([[
 /* Some systems require additional headers.  */
-#ifndef __GLIBC__
+#if !(defined __GLIBC__ && !defined __UCLIBC__)
 # include <stddef.h>
 # include <stdio.h>
 # include <time.h>
diff --git a/maint.mk b/maint.mk
index 32320f8..315b223 100644
--- a/maint.mk
+++ b/maint.mk
@@ -590,10 +590,19 @@ sc_changelog:
 sc_program_name:
        @require='set_program_name *\(m?argv\[0\]\);'                   \
        in_vc_files='\.c$$'                                             \
-       containing='^main *('                                           \
+       containing='\<main *('                                          \
        halt='the above files do not call set_program_name'             \
          $(_sc_search_regexp)
 
+# Ensure that each .c file containing a "main" function also
+# calls bindtextdomain.
+sc_bindtextdomain:
+       @require='bindtextdomain *\('                                   \
+       in_vc_files='\.c$$'                                             \
+       containing='\<main *('                                          \
+       halt='the above files do not call bindtextdomain'               \
+         $(_sc_search_regexp)
+
 # Require that the final line of each test-lib.sh-using test be this one:
 # Exit $fail
 # Note: this test requires GNU grep's --label= option.
@@ -668,8 +677,9 @@ sc_prohibit_always_true_header_tests:
        @or=$(gl_header_upper_case_or_);                                \
        re="HAVE_($$or)_H";                                             \
        prohibit='\<'"$$re"'\>'                                         \
-       halt='do not test the above HAVE_<header>_H symbol(s);\n'\
-'  with the corresponding gnulib module, they are always true'         \
+       halt=$$(printf '%s\n'                                           \
+       'do not test the above HAVE_<header>_H symbol(s);'              \
+       '  with the corresponding gnulib module, they are always true') \
          $(_sc_search_regexp)
 
 # ==================================================================
@@ -731,7 +741,8 @@ sc_GFDL_version:
        halt='GFDL vN, N!=3'                                            \
          $(_sc_search_regexp)
 
-# Don't use Texinfo @acronym{} as it is not a good idea.
+# Don't use Texinfo's @acronym{}.
+# http://lists.gnu.org/archive/html/bug-gnulib/2010-03/msg00321.html
 texinfo_suffix_re_ ?= \.(txi|texi(nfo)?)$$
 sc_texinfo_acronym:
        @prohibit='@acronym\{'                                          \
@@ -807,6 +818,13 @@ sc_prohibit_test_minus_ao:
        halt='$(_ptm1); $(_ptm2)'                                       \
          $(_sc_search_regexp)
 
+# Avoid a test bashism.
+sc_prohibit_test_double_equal:
+       @prohibit='(\<test| \[+) .+ == '                                \
+       containing='#! */bin/[a-z]*sh'                                  \
+       halt='use "test x = x", not "test x =''= x"'                    \
+         $(_sc_search_regexp)
+
 # Each program that uses proper_name_utf8 must link with one of the
 # ICONV libraries.  Otherwise, some ICONV library must appear in LDADD.
 # The perl -0777 invocation below extracts the possibly-multi-line
@@ -1012,9 +1030,10 @@ sc_Wundef_boolean:
 sc_vulnerable_makefile_CVE-2009-4029:
        @prohibit='perm -777 -exec chmod a\+rwx|chmod 777 \$$\(distdir\)' \
        in_files=$$(find $(srcdir) -name Makefile.in)                   \
-       halt='the above files are vulnerable; beware of running\n'\
-'"make dist*" rules, and upgrade to fixed automake\n'\
-'see http://bugzilla.redhat.com/542609 for details'                    \
+       halt=$$(printf '%s\n'                                           \
+         'the above files are vulnerable; beware of running'           \
+         '  "make dist*" rules, and upgrade to fixed automake'         \
+         '  see http://bugzilla.redhat.com/542609 for details')        \
          $(_sc_search_regexp)
 
 vc-diff-check:
@@ -1079,7 +1098,6 @@ emit_upload_commands:
        @echo =====================================
        @echo =====================================
 
-noteworthy = * Noteworthy changes in release ?.? (????-??-??) [?]
 define emit-commit-log
   printf '%s\n' 'post-release administrivia' '' \
     '* NEWS: Add header line for next release.' \
@@ -1117,6 +1135,7 @@ alpha beta stable: $(local-check) writable-files 
no-submodule-changes
 # Override this in cfg.mk if you follow different procedures.
 release-prep-hook ?= release-prep
 
+gl_noteworthy_news_ = * Noteworthy changes in release ?.? (????-??-??) [?]
 .PHONY: release-prep
 release-prep:
        case $$RELEASE_TYPE in alpha|beta|stable) ;; \
@@ -1128,7 +1147,7 @@ release-prep:
        fi
        echo $(VERSION) > $(prev_version_file)
        $(MAKE) update-NEWS-hash
-       perl -pi -e '$$. == 3 and print "$(noteworthy)\n\n\n"' NEWS
+       perl -pi -e '$$. == 3 and print "$(gl_noteworthy_news_)\n\n\n"' NEWS
        $(emit-commit-log) > .ci-msg
        $(VC) commit -F .ci-msg -a
        rm .ci-msg
diff --git a/module/ice-9/futures.scm b/module/ice-9/futures.scm
index b2e4c0d..1e9247d 100644
--- a/module/ice-9/futures.scm
+++ b/module/ice-9/futures.scm
@@ -146,9 +146,7 @@ touched."
 
 (define %worker-count
   (if (provided? 'threads)
-      (if (defined? 'getaffinity)
-          (- (bit-count #t (getaffinity (getpid))) 1)
-          3) ;; FIXME: use Gnulib's `nproc' here.
+      (- (current-processor-count) 1)
       0))
 
 (define %workers
diff --git a/module/ice-9/vlist.scm b/module/ice-9/vlist.scm
index d72e6c1..5ea0936 100644
--- a/module/ice-9/vlist.scm
+++ b/module/ice-9/vlist.scm
@@ -19,6 +19,7 @@
 (define-module (ice-9 vlist)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-9)
+  #:use-module (srfi srfi-9 gnu)
   #:use-module (srfi srfi-26)
 
   #:export (vlist? vlist-cons vlist-head vlist-tail vlist-null?
@@ -148,6 +149,21 @@
   (base    vlist-base)
   (offset  vlist-offset))
 
+(set-record-type-printer! <vlist>
+                          (lambda (vl port)
+                            (cond ((vlist-null? vl)
+                                   (format port "#<vlist ()>"))
+                                  ((block-hash-table (vlist-base vl))
+                                   (format port "#<vhash ~x ~a pairs>"
+                                           (object-address vl)
+                                           (vhash-fold (lambda (k v r)
+                                                         (+ 1 r))
+                                                       0
+                                                       vl)))
+                                  (else
+                                   (format port "#<vlist ~a>"
+                                           (vlist->list vl))))))
+
 
 (define vlist-null
   ;; The empty vlist.
diff --git a/module/srfi/srfi-26.scm b/module/srfi/srfi-26.scm
index 324a5dc..4a9f441 100644
--- a/module/srfi/srfi-26.scm
+++ b/module/srfi/srfi-26.scm
@@ -1,6 +1,6 @@
 ;;; srfi-26.scm --- specializing parameters without currying.
 
-;; Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2006, 2010 Free Software Foundation, Inc.
 ;;
 ;; This library is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU Lesser General Public
@@ -21,29 +21,46 @@
 
 (cond-expand-provide (current-module) '(srfi-26))
 
-(define-macro (cut slot . slots)
-  (let loop ((slots    (cons slot slots))
-            (params    '())
-            (args      '()))
-    (if (null? slots)
-       `(lambda ,(reverse! params) ,(reverse! args))
-      (let ((s   (car slots))
-           (rest (cdr slots)))
-       (case s
-         ((<>)
-          (let ((var (gensym)))
-            (loop rest (cons var params) (cons var args))))
-         ((<...>)
-          (if (pair? rest)
-              (error "<...> not on the end of cut expression"))
-          (let ((var (gensym)))
-            `(lambda ,(append! (reverse! params) var)
-               (apply ,@(reverse! (cons var args))))))
-         (else
-          (loop rest params (cons s args))))))))
+(define-syntax cut
+  (lambda (stx)
+    (syntax-case stx ()
+      ((cut slot0 slot1+ ...)
+       (let loop ((slots       #'(slot0 slot1+ ...))
+                  (params      '())
+                  (args        '()))
+         (if (null? slots)
+             #`(lambda #,(reverse params) #,(reverse args))
+             (let ((s    (car slots))
+                   (rest (cdr slots)))
+               (with-syntax (((var) (generate-temporaries '(var))))
+                 (syntax-case s (<> <...>)
+                   (<>
+                    (loop rest (cons #'var params) (cons #'var args)))
+                   (<...>
+                    (if (pair? rest)
+                        (error "<...> not on the end of cut expression"))
+                    #`(lambda #,(append (reverse params) #'var)
+                        (apply #,@(reverse (cons #'var args)))))
+                   (else
+                    (loop rest params (cons s args))))))))))))
 
-(define-macro (cute . slots)
-  (let ((temp (map (lambda (s) (and (not (memq s '(<> <...>))) (gensym)))
-                  slots)))
-    `(let ,(delq! #f (map (lambda (t s) (and t (list t s))) temp slots))
-       (cut ,@(map (lambda (t s) (or t s)) temp slots)))))
+(define-syntax cute
+  (lambda (stx)
+    (syntax-case stx ()
+      ((cute slots ...)
+       (let loop ((slots #'(slots ...))
+                  (bindings '())
+                  (arguments '()))
+         (define (process-hole)
+           (loop (cdr slots) bindings (cons (car slots) arguments)))
+         (if (null? slots)
+             #`(let #,bindings
+                 (cut #,@(reverse arguments)))
+             (syntax-case (car slots) (<> <...>)
+               (<> (process-hole))
+               (<...> (process-hole))
+               (expr
+                (with-syntax (((t) (generate-temporaries '(t))))
+                  (loop (cdr slots)
+                        (cons #'(t expr) bindings)
+                        (cons #'t arguments)))))))))))
diff --git a/test-suite/standalone/Makefile.am 
b/test-suite/standalone/Makefile.am
index 3fa9540..e3b5a38 100644
--- a/test-suite/standalone/Makefile.am
+++ b/test-suite/standalone/Makefile.am
@@ -82,7 +82,7 @@ TESTS += test-round
 noinst_LTLIBRARIES += libtest-asmobs.la
 libtest_asmobs_la_SOURCES = test-asmobs-lib.c
 libtest_asmobs_la_CFLAGS = ${test_cflags}
-libtest_asmobs_la_LDFLAGS = -no-undefined -rpath `pwd` # so libtool will 
really build an .so
+libtest_asmobs_la_LDFLAGS = -module -no-undefined -rpath `pwd` # so libtool 
will really build an .so
 libtest_asmobs_la_LIBADD = ${top_builddir}/libguile/address@hidden@.la
 BUILT_SOURCES += test-asmobs-lib.x
 check_SCRIPTS += test-asmobs
@@ -92,7 +92,7 @@ TESTS += test-asmobs
 noinst_LTLIBRARIES += libtest-ffi.la
 libtest_ffi_la_SOURCES = test-ffi-lib.c
 libtest_ffi_la_CFLAGS = ${test_cflags}
-libtest_ffi_la_LDFLAGS = -no-undefined -rpath `pwd` # so libtool will really 
build an .so
+libtest_ffi_la_LDFLAGS = -module -no-undefined -rpath `pwd` # so libtool will 
really build an .so
 libtest_ffi_la_LIBADD = ${top_builddir}/libguile/address@hidden@.la
 check_SCRIPTS += test-ffi
 TESTS += test-ffi
@@ -158,7 +158,7 @@ TESTS += test-scm-take-u8vector
 noinst_LTLIBRARIES += libtest-extensions.la
 libtest_extensions_la_SOURCES = test-extensions-lib.c
 libtest_extensions_la_CFLAGS = ${test_cflags}
-libtest_extensions_la_LDFLAGS = -no-undefined -rpath `pwd` # so libtool will 
really build an .so
+libtest_extensions_la_LDFLAGS = -module -no-undefined -rpath `pwd` # so 
libtool will really build an .so
 libtest_extensions_la_LIBADD = ${top_builddir}/libguile/address@hidden@.la
 check_SCRIPTS += test-extensions
 TESTS += test-extensions
diff --git a/test-suite/tests/posix.test b/test-suite/tests/posix.test
index 9679042..79f3a92 100644
--- a/test-suite/tests/posix.test
+++ b/test-suite/tests/posix.test
@@ -198,3 +198,16 @@
           (setaffinity (getpid) mask)
           (equal? mask (getaffinity (getpid))))
         (throw 'unresolved))))
+
+;;
+;; nproc
+;;
+
+(with-test-prefix "nproc"
+
+  (pass-if "total-processor-count"
+    (>= (total-processor-count) 1))
+
+  (pass-if "current-processor-count"
+    (and (>= (current-processor-count) 1)
+         (>= (total-processor-count) (current-processor-count)))))


hooks/post-receive
-- 
GNU Guile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]