gsasl-commit
[Top][All Lists]
Advanced

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

[SCM] GNU gsasl branch, master, updated. gsasl-1-6-0-35-ge953dcc


From: Simon Josefsson
Subject: [SCM] GNU gsasl branch, master, updated. gsasl-1-6-0-35-ge953dcc
Date: Tue, 07 Feb 2012 13:19:18 +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 gsasl".

http://git.savannah.gnu.org/cgit/gsasl.git/commit/?id=e953dccdc88d32a4efce935f2cf033df38d2ab3f

The branch, master has been updated
       via  e953dccdc88d32a4efce935f2cf033df38d2ab3f (commit)
       via  0b8c68e6405cbddafedc8fad78e246685af9ecd7 (commit)
       via  2228d32699afcb9f89cc25763b215449579e94b0 (commit)
       via  79b04900d429411f9a6cdf4e6a067b559c24fad5 (commit)
       via  a35dcab9d952238358c1bedaeb4b1f3939e69fcb (commit)
       via  58c754ebced56069175eb0d943046fecb35fc7e9 (commit)
       via  43b24605d9fd327586ef40d667bade36a13adbee (commit)
       via  424ac902edaef3d80f433a776ba28e0641feeaeb (commit)
       via  3454ddfa33d4df8da44f07c0b79aab1f1f960b92 (commit)
       via  e3e7d799925e220a105d7fbbab353c6f686bed86 (commit)
       via  694ff738a1bc7e591ff594c330feaa3a1cbf6c49 (commit)
       via  c07d827c851541efe0ef4dd6658c04eeb1cffb09 (commit)
       via  87e7f1a02c7decfde6489b088d282069041e03fd (commit)
       via  76b19cadf6ee686bbbbf09fef9bcfcef0b413265 (commit)
       via  904a1ae4455337c51826ddaea56cb1806e7dffd8 (commit)
      from  db63c51b413fc5f75eab67c4f968055756d84cdf (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 e953dccdc88d32a4efce935f2cf033df38d2ab3f
Author: Simon Josefsson <address@hidden>
Date:   Tue Feb 7 14:18:58 2012 +0100

    Add.

commit 0b8c68e6405cbddafedc8fad78e246685af9ecd7
Author: Simon Josefsson <address@hidden>
Date:   Tue Feb 7 14:11:10 2012 +0100

    Don't use getline in examples.

commit 2228d32699afcb9f89cc25763b215449579e94b0
Author: Simon Josefsson <address@hidden>
Date:   Tue Feb 7 14:03:36 2012 +0100

    Fix logic.

commit 79b04900d429411f9a6cdf4e6a067b559c24fad5
Author: Simon Josefsson <address@hidden>
Date:   Tue Feb 7 11:08:10 2012 +0100

    Disable OPENID20 and SAML20 by default.

commit a35dcab9d952238358c1bedaeb4b1f3939e69fcb
Author: Simon Josefsson <address@hidden>
Date:   Tue Feb 7 11:07:08 2012 +0100

    Fix memory leak and warnings.

commit 58c754ebced56069175eb0d943046fecb35fc7e9
Author: Simon Josefsson <address@hidden>
Date:   Tue Feb 7 11:06:32 2012 +0100

    Silence warning.

commit 43b24605d9fd327586ef40d667bade36a13adbee
Author: Simon Josefsson <address@hidden>
Date:   Tue Feb 7 11:01:37 2012 +0100

    Fix memory leak.

commit 424ac902edaef3d80f433a776ba28e0641feeaeb
Author: Simon Josefsson <address@hidden>
Date:   Tue Feb 7 10:15:32 2012 +0100

    Sync with TP.

commit 3454ddfa33d4df8da44f07c0b79aab1f1f960b92
Author: Simon Josefsson <address@hidden>
Date:   Tue Feb 7 10:12:29 2012 +0100

    Silence warning.

commit e3e7d799925e220a105d7fbbab353c6f686bed86
Author: Simon Josefsson <address@hidden>
Date:   Tue Feb 7 09:54:43 2012 +0100

    Update gnulib files.

commit 694ff738a1bc7e591ff594c330feaa3a1cbf6c49
Author: Enrico Scholz <address@hidden>
Date:   Sat Nov 12 23:35:17 2011 +0100

    ignore untagged responses during IMAP authentication
    
    Some IMAP server (e.g. dovecot) return new capabilities as untagged
    response.  Old code expected only one line (e.g. the final '. OK')
    which would be given out as part of the application data.  E.g. without
    this patch, authentication to a dovecot server would look like:
    
    | $ gsasl mailbox 143 --imap ...
    | ...
    | + BQQF/wAMAAAAAAAAIO4EoAH...
    | BQQE/wAMAAAAAAAAII9BbgH...
    | * CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ...
    | Client authentication finished (server trusted)...
    | Enter application data (EOF to finish):
    | . OK Logged in
    
    Patches changes it to
    
    | + BQQF/wAMAAAAAAAAIX...
    | BQQE/wAMAAAAAAAAK2...
    | * CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ...
    | . OK Logged in
    | Client authentication finished (server trusted)...
    | Enter application data (EOF to finish):
    
    Dialog with cyrus-imapd is not changed and ends always with
    
    | + BQQF/wAMAAAAAAAAPqx...
    | BQQE/wAMAAAAAAAAL...
    | . OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ...] Success (tls protection)
    | Client authentication finished (server trusted)...
    | Enter application data (EOF to finish):
    
    Signed-off-by: Enrico Scholz <address@hidden>
    Signed-off-by: Simon Josefsson <address@hidden>

commit c07d827c851541efe0ef4dd6658c04eeb1cffb09
Author: Simon Josefsson <address@hidden>
Date:   Fri Nov 25 01:31:52 2011 +0100

    Print newline after messages.

commit 87e7f1a02c7decfde6489b088d282069041e03fd
Author: Simon Josefsson <address@hidden>
Date:   Fri Nov 25 01:22:38 2011 +0100

    Fix trailing backslash problem.  Reported by Bruno Haible.

commit 76b19cadf6ee686bbbbf09fef9bcfcef0b413265
Author: Simon Josefsson <address@hidden>
Date:   Tue Nov 22 11:06:19 2011 +0100

    Silence warning.

commit 904a1ae4455337c51826ddaea56cb1806e7dffd8
Author: Simon Josefsson <address@hidden>
Date:   Thu Jun 30 12:40:03 2011 +0200

    libgsasl: Implement OPENID20 mechanism for OpenID authentication.
    
    Following draft-ietf-kitten-sasl-openid-03.

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

Summary of changes:
 .gitignore                               |   65 ++
 GNUmakefile                              |   14 +-
 NEWS                                     |   12 +-
 cfg.mk                                   |   10 +-
 doc/fdl-1.3.texi                         |    3 +-
 doc/gendocs_template                     |    2 +-
 doc/gsasl.texi                           |   16 +-
 doc/reference/gsasl-docs.sgml            |    2 +-
 examples/client-xmpp-saml20.c            |   15 +-
 examples/server-xmpp-saml20.c            |   29 +-
 gl/Makefile.am                           |  556 +++++++---
 gl/alignof.h                             |   53 -
 gl/alloca.c                              |    2 +-
 gl/alloca.in.h                           |    2 +-
 gl/arpa_inet.in.h                        |   36 +-
 gl/asnprintf.c                           |    2 +-
 gl/asprintf.c                            |    2 +-
 gl/c-ctype.c                             |    2 +-
 gl/c-ctype.h                             |   36 +-
 gl/c-strcase.h                           |    7 +-
 gl/c-strcasecmp.c                        |    2 +-
 gl/c-strcaseeq.h                         |  184 ++++
 gl/c-strncasecmp.c                       |    2 +-
 gl/close.c                               |   35 +-
 gl/config.charset                        |    4 +-
 gl/connect.c                             |   31 +-
 gl/errno.in.h                            |  130 ++-
 gl/error.c                               |   17 +-
 gl/error.h                               |    8 +-
 gl/exitfail.c                            |    2 +-
 gl/exitfail.h                            |    2 +-
 gl/fclose.c                              |   84 --
 gl/fd-hook.c                             |    2 +-
 gl/fd-hook.h                             |    2 +-
 gl/fflush.c                              |  218 ----
 gl/float+.h                              |    2 +-
 gl/float.c                               |    4 +-
 gl/float.in.h                            |   18 +-
 gl/fpurge.c                              |  137 ---
 gl/freading.c                            |   68 --
 gl/freading.h                            |   53 -
 gl/fseek.c                               |    2 +-
 gl/fseeko.c                              |   26 +-
 gl/fstat.c                               |   82 ++
 gl/ftell.c                               |   38 -
 gl/ftello.c                              |   77 --
 gl/gai_strerror.c                        |    2 +-
 gl/getaddrinfo.c                         |   14 +-
 gl/getdelim.c                            |    2 +-
 gl/getline.c                             |    2 +-
 gl/getopt.c                              |   77 +-
 gl/getopt.in.h                           |   54 +-
 gl/getopt1.c                             |    6 +-
 gl/getopt_int.h                          |   16 +-
 gl/getpass.c                             |   21 +-
 gl/getpass.h                             |    2 +-
 gl/gettext.h                             |    8 +-
 gl/iconv.c                               |    2 +-
 gl/iconv.in.h                            |    2 +-
 gl/iconv_close.c                         |    2 +-
 gl/iconv_open.c                          |    4 +-
 gl/inet_ntop.c                           |   57 +-
 gl/intprops.h                            |    2 +-
 gl/itold.c                               |   28 +
 gl/localcharset.c                        |   30 +-
 gl/localcharset.h                        |    2 +-
 gl/lseek.c                               |    4 +-
 gl/m4/00gnulib.m4                        |    2 +-
 gl/m4/alloca.m4                          |   36 +-
 gl/m4/arpa_inet_h.m4                     |    6 +-
 gl/m4/autobuild.m4                       |    2 +-
 gl/m4/btowc.m4                           |    2 +-
 gl/m4/close.m4                           |   29 +-
 gl/m4/codeset.m4                         |    2 +-
 gl/m4/configmake.m4                      |    2 +-
 gl/m4/dup2.m4                            |   28 +-
 gl/m4/eealloc.m4                         |    2 +-
 gl/m4/environ.m4                         |   15 +-
 gl/m4/errno_h.m4                         |   10 +-
 gl/m4/error.m4                           |    2 +-
 gl/m4/exponentd.m4                       |  116 ++
 gl/m4/extensions.m4                      |   11 +-
 gl/m4/fclose.m4                          |   20 -
 gl/m4/fcntl-o.m4                         |   17 +-
 gl/m4/fcntl_h.m4                         |   10 +-
 gl/m4/fdopen.m4                          |   49 +
 gl/m4/fflush.m4                          |   81 --
 gl/m4/float_h.m4                         |   55 +-
 gl/m4/fpieee.m4                          |    2 +-
 gl/m4/fpurge.m4                          |   45 -
 gl/m4/freading.m4                        |   10 -
 gl/m4/fseek.m4                           |    2 +-
 gl/m4/fseeko.m4                          |    2 +-
 gl/m4/fstat.m4                           |   28 +
 gl/m4/ftell.m4                           |   15 -
 gl/m4/ftello.m4                          |  127 ---
 gl/m4/ftruncate.m4                       |   24 +
 gl/m4/getaddrinfo.m4                     |   29 +-
 gl/m4/getcwd.m4                          |   85 ++-
 gl/m4/getdelim.m4                        |    2 +-
 gl/m4/getline.m4                         |    2 +-
 gl/m4/getopt.m4                          |   91 +-
 gl/m4/getpagesize.m4                     |    2 +-
 gl/m4/getpass.m4                         |   12 +-
 gl/m4/gettimeofday.m4                    |    8 +-
 gl/m4/glibc21.m4                         |    2 +-
 gl/m4/gnulib-cache.m4                    |   26 +-
 gl/m4/gnulib-common.m4                   |   94 ++-
 gl/m4/gnulib-comp.m4                     |  275 +++--
 gl/m4/gnulib-tool.m4                     |    2 +-
 gl/m4/hostent.m4                         |    2 +-
 gl/m4/iconv.m4                           |    6 +-
 gl/m4/iconv_h.m4                         |    2 +-
 gl/m4/iconv_open.m4                      |    2 +-
 gl/m4/include_next.m4                    |   54 +-
 gl/m4/inet_ntop.m4                       |   73 +-
 gl/m4/inet_pton.m4                       |   73 +-
 gl/m4/inline.m4                          |    2 +-
 gl/m4/intlmacosx.m4                      |    2 +-
 gl/m4/intmax_t.m4                        |    2 +-
 gl/m4/inttypes-pri.m4                    |    2 +-
 gl/m4/inttypes.m4                        |   21 +-
 gl/m4/inttypes_h.m4                      |    2 +-
 gl/m4/ioctl.m4                           |   11 +-
 gl/m4/largefile.m4                       |  104 ++
 gl/m4/lcmessage.m4                       |    2 +-
 gl/m4/lib-ld.m4                          |    2 +-
 gl/m4/lib-link.m4                        |    2 +-
 gl/m4/lib-prefix.m4                      |    2 +-
 gl/m4/libunistring-base.m4               |    2 +-
 gl/m4/localcharset.m4                    |    2 +-
 gl/m4/locale-fr.m4                       |   20 +-
 gl/m4/locale-ja.m4                       |   13 +-
 gl/m4/locale-tr.m4                       |   10 +-
 gl/m4/locale-zh.m4                       |   10 +-
 gl/m4/locale_h.m4                        |    2 +-
 gl/m4/localename.m4                      |    2 +-
 gl/m4/lock.m4                            |    2 +-
 gl/m4/longlong.m4                        |    8 +-
 gl/m4/lseek.m4                           |   12 +-
 gl/m4/lstat.m4                           |    6 +-
 gl/m4/malloc.m4                          |    2 +-
 gl/m4/malloca.m4                         |    2 +-
 gl/m4/manywarnings.m4                    |   36 +-
 gl/m4/math_h.m4                          |  243 ++++
 gl/m4/mbrtowc.m4                         |   20 +-
 gl/m4/mbsinit.m4                         |   20 +-
 gl/m4/mbstate_t.m4                       |    2 +-
 gl/m4/mbtowc.m4                          |    2 +-
 gl/m4/memchr.m4                          |    2 +-
 gl/m4/mmap-anon.m4                       |   10 +-
 gl/m4/mode_t.m4                          |    2 +-
 gl/m4/msvc-inval.m4                      |   19 +
 gl/m4/msvc-nothrow.m4                    |   10 +
 gl/m4/multiarch.m4                       |    2 +-
 gl/m4/netdb_h.m4                         |    2 +-
 gl/m4/netinet_in_h.m4                    |    2 +-
 gl/m4/nocrash.m4                         |  130 +++
 gl/m4/open.m4                            |   42 +-
 gl/m4/pathmax.m4                         |   42 +
 gl/m4/perror.m4                          |   30 +-
 gl/m4/pipe.m4                            |    2 +-
 gl/m4/poll.m4                            |   32 +-
 gl/m4/poll_h.m4                          |    2 +-
 gl/m4/printf.m4                          |  139 ++-
 gl/m4/putenv.m4                          |    2 +-
 gl/m4/quote.m4                           |    2 +-
 gl/m4/quotearg.m4                        |    2 +-
 gl/m4/readline.m4                        |    8 +-
 gl/m4/realloc.m4                         |    2 +-
 gl/m4/select.m4                          |   29 +-
 gl/m4/servent.m4                         |    2 +-
 gl/m4/setenv.m4                          |    8 +-
 gl/m4/setlocale.m4                       |    2 +-
 gl/m4/signal_h.m4                        |   83 ++
 gl/m4/size_max.m4                        |    2 +-
 gl/m4/snprintf.m4                        |   15 +-
 gl/m4/socketlib.m4                       |    2 +-
 gl/m4/sockets.m4                         |    2 +-
 gl/m4/socklen.m4                         |    2 +-
 gl/m4/sockpfaf.m4                        |    2 +-
 gl/m4/ssize_t.m4                         |   23 +
 gl/m4/stat.m4                            |    2 +-
 gl/m4/stdalign.m4                        |   51 +
 gl/m4/stdarg.m4                          |    2 +-
 gl/m4/stdbool.m4                         |    2 +-
 gl/m4/stddef_h.m4                        |    2 +-
 gl/m4/stdint.m4                          |   16 +-
 gl/m4/stdint_h.m4                        |    2 +-
 gl/m4/stdio_h.m4                         |   11 +-
 gl/m4/stdlib_h.m4                        |   21 +-
 gl/m4/strdup.m4                          |    2 +-
 gl/m4/strerror.m4                        |    2 +-
 gl/m4/strerror_r.m4                      |   11 +-
 gl/m4/string_h.m4                        |   14 +-
 gl/m4/strtok_r.m4                        |    2 +-
 gl/m4/symlink.m4                         |    2 +-
 gl/m4/sys_ioctl_h.m4                     |    2 +-
 gl/m4/sys_select_h.m4                    |   23 +-
 gl/m4/sys_socket_h.m4                    |    2 +-
 gl/m4/sys_stat_h.m4                      |   10 +-
 gl/m4/sys_time_h.m4                      |   40 +-
 gl/m4/sys_types_h.m4                     |   21 +
 gl/m4/sys_uio_h.m4                       |    2 +-
 gl/m4/thread.m4                          |    2 +-
 gl/m4/threadlib.m4                       |   34 +-
 gl/m4/time_h.m4                          |    6 +-
 gl/m4/ungetc.m4                          |    2 +-
 gl/m4/unistd_h.m4                        |   36 +-
 gl/m4/valgrind-tests.m4                  |   11 +-
 gl/m4/vasnprintf.m4                      |   13 +-
 gl/m4/vasprintf.m4                       |    2 +-
 gl/m4/version-etc.m4                     |    2 +-
 gl/m4/warn-on-use.m4                     |   10 +-
 gl/m4/warnings.m4                        |   17 +-
 gl/m4/wchar_h.m4                         |    2 +-
 gl/m4/wchar_t.m4                         |    2 +-
 gl/m4/wcrtomb.m4                         |   20 +-
 gl/m4/wctob.m4                           |    8 +-
 gl/m4/wctomb.m4                          |    2 +-
 gl/m4/wctype_h.m4                        |   43 +-
 gl/m4/wint_t.m4                          |    2 +-
 gl/m4/xalloc.m4                          |    2 +-
 gl/m4/xsize.m4                           |    2 +-
 gl/m4/yield.m4                           |    2 +-
 gl/malloc.c                              |    2 +-
 gl/mbrtowc.c                             |    2 +-
 gl/mbsinit.c                             |    2 +-
 gl/memchr.c                              |    2 +-
 gl/msvc-inval.c                          |  130 +++
 gl/msvc-inval.h                          |  223 ++++
 gl/msvc-nothrow.c                        |   50 +
 gl/msvc-nothrow.h                        |   44 +
 gl/netdb.in.h                            |   20 +-
 gl/netinet_in.in.h                       |    2 +-
 gl/override/lib/dup2.c.diff              |   40 -
 gl/override/lib/getpass.c.diff           |   42 -
 gl/override/lib/gettext.h.diff           |   18 +-
 gl/override/m4/open.m4.diff              |   34 -
 gl/poll.c                                |   45 +-
 gl/poll.in.h                             |    4 +-
 gl/printf-args.c                         |    2 +-
 gl/printf-args.h                         |    2 +-
 gl/printf-parse.c                        |    4 +-
 gl/printf-parse.h                        |    2 +-
 gl/progname.c                            |    2 +-
 gl/progname.h                            |    2 +-
 gl/quote.c                               |    2 +-
 gl/quote.h                               |    2 +-
 gl/quotearg.c                            |   78 +-
 gl/quotearg.h                            |    8 +-
 gl/readline.c                            |    2 +-
 gl/readline.h                            |    2 +-
 gl/realloc.c                             |    2 +-
 gl/recv.c                                |   19 +-
 gl/ref-add.sin                           |    2 +-
 gl/ref-del.sin                           |    2 +-
 gl/select.c                              |   43 +-
 gl/shutdown.c                            |   19 +-
 gl/signal.in.h                           |  447 ++++++++
 gl/size_max.h                            |    2 +-
 gl/snprintf.c                            |    2 +-
 gl/socket.c                              |    2 +-
 gl/sockets.c                             |    3 +-
 gl/sockets.h                             |   17 +-
 gl/stdalign.in.h                         |   91 ++
 gl/stdarg.in.h                           |    2 +-
 gl/stdbool.in.h                          |    2 +-
 gl/stddef.in.h                           |    2 +-
 gl/stdint.in.h                           |  128 ++-
 gl/stdio-impl.h                          |    4 +-
 gl/stdio.in.h                            |   44 +-
 gl/stdlib.in.h                           |  186 +++-
 gl/strdup.c                              |    2 +-
 gl/streq.h                               |    2 +-
 gl/strerror-override.c                   |  114 ++-
 gl/strerror-override.h                   |    6 +-
 gl/strerror.c                            |    2 +-
 gl/striconv.c                            |    2 +-
 gl/striconv.h                            |    2 +-
 gl/string.in.h                           |   32 +-
 gl/strtok_r.c                            |    2 +-
 gl/sys_select.in.h                       |  195 ++++-
 gl/sys_socket.in.h                       |   62 +-
 gl/sys_stat.in.h                         |  698 ++++++++++++
 gl/sys_time.in.h                         |  109 ++-
 gl/sys_types.in.h                        |   40 +
 gl/sys_uio.in.h                          |    4 +-
 gl/time.in.h                             |  249 +++++
 gl/unistd.in.h                           |  334 ++++--
 gl/unistr.in.h                           |    2 +-
 gl/unistr/u8-mbtoucr.c                   |    2 +-
 gl/unistr/u8-uctomb-aux.c                |    2 +-
 gl/unistr/u8-uctomb.c                    |    2 +-
 gl/unitypes.in.h                         |    2 +-
 gl/vasnprintf.c                          |   91 +-
 gl/vasnprintf.h                          |    2 +-
 gl/vasprintf.c                           |    2 +-
 gl/verify.h                              |   16 +-
 gl/version-etc.c                         |    4 +-
 gl/version-etc.h                         |    8 +-
 gl/w32sock.h                             |   89 ++-
 gl/wchar.in.h                            |   14 +-
 gl/wctype.in.h                           |   24 +-
 gl/xalloc-die.c                          |    4 +-
 gl/xalloc-oversized.h                    |    2 +-
 gl/xalloc.h                              |   16 +-
 gl/xmalloc.c                             |    2 +-
 gl/xsize.h                               |    2 +-
 gltests/Makefile.am                      |  592 ++++++-----
 gltests/accept.c                         |   20 +-
 gltests/binary-io.h                      |    2 +-
 gltests/bind.c                           |   19 +-
 gltests/btowc.c                          |    2 +-
 gltests/dosname.h                        |    2 +-
 gltests/dup2.c                           |   88 +-
 gltests/fcntl.in.h                       |   12 +-
 gltests/fdopen.c                         |   69 ++
 gltests/fpucw.h                          |    2 +-
 gltests/ftruncate.c                      |   43 +
 gltests/getcwd-lgpl.c                    |    4 +-
 gltests/getpagesize.c                    |    4 +-
 gltests/gettimeofday.c                   |   13 +-
 gltests/glthread/lock.c                  |    4 +-
 gltests/glthread/lock.h                  |   17 +-
 gltests/glthread/thread.c                |    4 +-
 gltests/glthread/thread.h                |   13 +-
 gltests/glthread/threadlib.c             |    2 +-
 gltests/glthread/yield.h                 |    7 +-
 gltests/ignore-value.h                   |    7 +-
 gltests/inet_pton.c                      |   51 +-
 gltests/init.sh                          |  122 ++-
 gltests/inttypes.in.h                    | 1770 +++++++++++++++---------------
 gltests/ioctl.c                          |    9 +-
 gltests/listen.c                         |   19 +-
 gltests/locale.in.h                      |    2 +-
 gltests/localename.c                     |   26 +-
 gltests/localename.h                     |    2 +-
 gltests/lstat.c                          |   18 +-
 gltests/macros.h                         |    2 +-
 gltests/malloca.c                        |    8 +-
 gltests/malloca.h                        |    2 +-
 gltests/mbtowc-impl.h                    |    2 +-
 gltests/mbtowc.c                         |    2 +-
 gltests/open.c                           |   13 +-
 gltests/pathmax.h                        |   84 ++
 gltests/perror.c                         |    2 +-
 gltests/pipe.c                           |   15 +-
 gltests/putenv.c                         |   14 +-
 gltests/same-inode.h                     |   16 +-
 gltests/setenv.c                         |   12 +-
 gltests/setlocale.c                      |    4 +-
 gltests/setsockopt.c                     |   33 +-
 gltests/signature.h                      |    2 +-
 gltests/stat.c                           |   26 +-
 gltests/strerror_r.c                     |   35 +-
 gltests/symlink.c                        |    2 +-
 gltests/sys_ioctl.in.h                   |    2 +-
 gltests/sys_stat.in.h                    |  658 -----------
 gltests/test-accept.c                    |   54 +
 gltests/test-alignof.c                   |   59 -
 gltests/test-alloca-opt.c                |    2 +-
 gltests/test-arpa_inet.c                 |    2 +-
 gltests/test-binary-io.c                 |   11 +-
 gltests/test-binary-io.sh                |    1 +
 gltests/test-bind.c                      |   56 +
 gltests/test-btowc.c                     |    2 +-
 gltests/test-c-ctype.c                   |    2 +-
 gltests/test-c-strcasecmp.c              |    2 +-
 gltests/test-c-strncasecmp.c             |    2 +-
 gltests/test-close.c                     |   44 +
 gltests/test-connect.c                   |   58 +
 gltests/test-dup2.c                      |   13 +-
 gltests/test-environ.c                   |    2 +-
 gltests/test-errno.c                     |    2 +-
 gltests/test-fclose.c                    |   90 --
 gltests/test-fcntl-h.c                   |    7 +-
 gltests/test-fdopen.c                    |   54 +
 gltests/test-fflush.c                    |  146 ---
 gltests/test-fflush2.c                   |  108 --
 gltests/test-fflush2.sh                  |    9 -
 gltests/test-fgetc.c                     |   96 ++
 gltests/test-float.c                     |    6 +-
 gltests/test-fpurge.c                    |  134 ---
 gltests/test-fputc.c                     |   90 ++
 gltests/test-fread.c                     |   99 ++
 gltests/test-freading.c                  |  130 ---
 gltests/test-fseek.c                     |    2 +-
 gltests/test-fseeko.c                    |    2 +-
 gltests/test-fseeko3.c                   |   51 +
 gltests/test-fseeko3.sh                  |    7 +
 gltests/test-fseeko4.c                   |   71 ++
 gltests/test-fseeko4.sh                  |    5 +
 gltests/test-fstat.c                     |   48 +
 gltests/test-ftell.c                     |  107 --
 gltests/test-ftell.sh                    |    5 -
 gltests/test-ftell2.sh                   |    3 -
 gltests/test-ftell3.c                    |   78 --
 gltests/test-ftello.c                    |  118 --
 gltests/test-ftello.sh                   |    5 -
 gltests/test-ftello2.sh                  |    3 -
 gltests/test-ftello3.c                   |   78 --
 gltests/test-ftruncate.c                 |   59 +
 gltests/test-ftruncate.sh                |    3 +
 gltests/test-fwrite.c                    |   93 ++
 gltests/test-getaddrinfo.c               |    2 +-
 gltests/test-getcwd-lgpl.c               |    2 +-
 gltests/test-getdelim.c                  |    2 +-
 gltests/test-getline.c                   |    2 +-
 gltests/test-getopt.c                    |    2 +-
 gltests/test-getopt.h                    |   24 +-
 gltests/test-getopt_long.h               |   21 +-
 gltests/test-gettimeofday.c              |    2 +-
 gltests/test-iconv-h.c                   |    2 +-
 gltests/test-iconv.c                     |    2 +-
 gltests/test-ignore-value.c              |    2 +-
 gltests/test-inet_ntop.c                 |    2 +-
 gltests/test-inet_pton.c                 |    2 +-
 gltests/test-init.sh                     |   73 ++
 gltests/test-intprops.c                  |    2 +-
 gltests/test-inttypes.c                  |    5 +-
 gltests/test-ioctl.c                     |   49 +
 gltests/test-listen.c                    |   47 +
 gltests/test-locale.c                    |    2 +-
 gltests/test-localename.c                |    2 +-
 gltests/test-lock.c                      |   18 +-
 gltests/test-lseek.c                     |   14 +-
 gltests/test-lstat.c                     |    2 +-
 gltests/test-lstat.h                     |    2 +-
 gltests/test-malloca.c                   |    2 +-
 gltests/test-mbrtowc-w32.c               |    2 +-
 gltests/test-mbrtowc.c                   |    2 +-
 gltests/test-mbsinit.c                   |    2 +-
 gltests/test-memchr.c                    |    2 +-
 gltests/test-netdb.c                     |    2 +-
 gltests/test-netinet_in.c                |    2 +-
 gltests/test-open.c                      |    2 +-
 gltests/test-open.h                      |    2 +-
 gltests/test-pathmax.c                   |   32 +
 gltests/test-perror.c                    |    2 +-
 gltests/test-perror2.c                   |    2 +-
 gltests/test-pipe.c                      |    8 +-
 gltests/test-poll-h.c                    |    2 +-
 gltests/test-poll.c                      |   35 +-
 gltests/test-quotearg-simple.c           |   35 +-
 gltests/test-quotearg.h                  |    2 +-
 gltests/test-recv.c                      |   49 +
 gltests/test-select-fd.c                 |    2 +-
 gltests/test-select-stdin.c              |    2 +-
 gltests/test-select.c                    |  371 +-------
 gltests/test-select.h                    |  436 ++++++++
 gltests/test-setenv.c                    |    2 +-
 gltests/test-setlocale1.c                |    2 +-
 gltests/test-setlocale2.c                |    2 +-
 gltests/test-setlocale2.sh               |    6 +-
 gltests/test-setsockopt.c                |   53 +
 gltests/test-shutdown.c                  |   47 +
 gltests/test-signal-h.c                  |  129 +++
 gltests/test-snprintf.c                  |   10 +-
 gltests/test-sockets.c                   |    2 +-
 gltests/test-stat.c                      |    2 +-
 gltests/test-stat.h                      |    2 +-
 gltests/test-stdalign.c                  |  116 ++
 gltests/test-stdbool.c                   |    2 +-
 gltests/test-stddef.c                    |    2 +-
 gltests/test-stdint.c                    |    4 +-
 gltests/test-stdio.c                     |    2 +-
 gltests/test-stdlib.c                    |    2 +-
 gltests/test-strerror.c                  |    4 +-
 gltests/test-strerror_r.c                |    2 +-
 gltests/test-striconv.c                  |    2 +-
 gltests/test-string.c                    |    2 +-
 gltests/test-symlink.c                   |    2 +-
 gltests/test-symlink.h                   |    2 +-
 gltests/test-sys_ioctl.c                 |    2 +-
 gltests/test-sys_select.c                |   27 +-
 gltests/test-sys_socket.c                |    6 +-
 gltests/test-sys_stat.c                  |   47 +-
 gltests/test-sys_time.c                  |    6 +-
 gltests/test-sys_types.c                 |   34 +
 gltests/test-sys_uio.c                   |    2 +-
 gltests/test-sys_wait.h                  |    2 +-
 gltests/test-thread_create.c             |   78 ++
 gltests/test-thread_self.c               |   34 +
 gltests/test-time.c                      |   10 +-
 gltests/test-unistd.c                    |    2 +-
 gltests/test-unsetenv.c                  |    2 +-
 gltests/test-vasnprintf.c                |    2 +-
 gltests/test-vasprintf.c                 |    2 +-
 gltests/test-vc-list-files-cvs.sh        |    3 +-
 gltests/test-vc-list-files-git.sh        |    2 +-
 gltests/test-verify.c                    |    2 +-
 gltests/test-version-etc.c               |    2 +-
 gltests/test-version-etc.sh              |    2 +-
 gltests/test-wchar.c                     |    2 +-
 gltests/test-wcrtomb-w32.c               |    2 +-
 gltests/test-wcrtomb.c                   |    2 +-
 gltests/test-wctype-h.c                  |    2 +-
 gltests/test-xalloc-die.c                |    2 +-
 gltests/test-xalloc-die.sh               |    2 +-
 gltests/time.in.h                        |  249 -----
 gltests/unistr/test-u8-mbtoucr.c         |    2 +-
 gltests/unistr/test-u8-uctomb.c          |    2 +-
 gltests/unsetenv.c                       |    4 +-
 gltests/version-etc-fsf.c                |    2 +-
 gltests/w32sock.h                        |   89 ++-
 gltests/wcrtomb.c                        |    2 +-
 gltests/wctob.c                          |    2 +-
 gltests/wctomb-impl.h                    |    2 +-
 gltests/wctomb.c                         |    2 +-
 gltests/zerosize-ptr.h                   |    2 +-
 lib/GNUmakefile                          |   14 +-
 lib/Makefile.am                          |    6 +-
 lib/NEWS                                 |    3 +
 lib/README                               |    2 +
 lib/build-aux/arg-nonnull.h              |   26 -
 lib/build-aux/c++defs.h                  |  271 -----
 lib/build-aux/config.rpath               |    4 +-
 lib/build-aux/pmccabe.css                |    4 +-
 lib/build-aux/pmccabe2html               |    2 +-
 lib/build-aux/snippet/_Noreturn.h        |   10 +
 lib/build-aux/snippet/arg-nonnull.h      |   26 +
 lib/build-aux/snippet/c++defs.h          |  271 +++++
 lib/build-aux/snippet/unused-parameter.h |   36 +
 lib/build-aux/snippet/warn-on-use.h      |  109 ++
 lib/build-aux/unused-parameter.h         |   36 -
 lib/build-aux/useless-if-before-free     |   10 +-
 lib/build-aux/vc-list-files              |    2 +-
 lib/build-aux/warn-on-use.h              |  109 --
 lib/configure.ac                         |   17 +-
 lib/gl/Makefile.am                       |  278 +++--
 lib/gl/alloca.in.h                       |    2 +-
 lib/gl/asnprintf.c                       |    2 +-
 lib/gl/asprintf.c                        |    2 +-
 lib/gl/base64.c                          |   10 +-
 lib/gl/base64.h                          |    4 +-
 lib/gl/c-ctype.c                         |    2 +-
 lib/gl/c-ctype.h                         |   36 +-
 lib/gl/errno.in.h                        |  130 ++-
 lib/gl/float+.h                          |    2 +-
 lib/gl/float.c                           |    4 +-
 lib/gl/float.in.h                        |   18 +-
 lib/gl/gc-gnulib.c                       |    2 +-
 lib/gl/gc-libgcrypt.c                    |    2 +-
 lib/gl/gc-pbkdf2-sha1.c                  |    2 +-
 lib/gl/gc.h                              |    2 +-
 lib/gl/getdelim.c                        |    2 +-
 lib/gl/getline.c                         |    2 +-
 lib/gl/gettext.h                         |    8 +-
 lib/gl/hmac-md5.c                        |    2 +-
 lib/gl/hmac-sha1.c                       |    2 +-
 lib/gl/hmac.h                            |    2 +-
 lib/gl/itold.c                           |   28 +
 lib/gl/m4/00gnulib.m4                    |    2 +-
 lib/gl/m4/alloca.m4                      |   36 +-
 lib/gl/m4/base64.m4                      |    2 +-
 lib/gl/m4/codeset.m4                     |    2 +-
 lib/gl/m4/errno_h.m4                     |   10 +-
 lib/gl/m4/exponentd.m4                   |  116 ++
 lib/gl/m4/extensions.m4                  |   11 +-
 lib/gl/m4/fcntl-o.m4                     |   17 +-
 lib/gl/m4/fdopen.m4                      |   49 +
 lib/gl/m4/float_h.m4                     |   55 +-
 lib/gl/m4/fpieee.m4                      |    2 +-
 lib/gl/m4/gc-hmac-md5.m4                 |    2 +-
 lib/gl/m4/gc-hmac-sha1.m4                |    2 +-
 lib/gl/m4/gc-md5.m4                      |    2 +-
 lib/gl/m4/gc-random.m4                   |   10 +-
 lib/gl/m4/gc-sha1.m4                     |    2 +-
 lib/gl/m4/gc.m4                          |    2 +-
 lib/gl/m4/getdelim.m4                    |    2 +-
 lib/gl/m4/getline.m4                     |    2 +-
 lib/gl/m4/getpagesize.m4                 |    2 +-
 lib/gl/m4/gettext.m4                     |    4 +-
 lib/gl/m4/glibc2.m4                      |    2 +-
 lib/gl/m4/glibc21.m4                     |    2 +-
 lib/gl/m4/gnulib-cache.m4                |   26 +-
 lib/gl/m4/gnulib-common.m4               |   94 ++-
 lib/gl/m4/gnulib-comp.m4                 |  113 ++-
 lib/gl/m4/gnulib-tool.m4                 |    2 +-
 lib/gl/m4/iconv.m4                       |    6 +-
 lib/gl/m4/include_next.m4                |   54 +-
 lib/gl/m4/intdiv0.m4                     |    2 +-
 lib/gl/m4/intl.m4                        |    6 +-
 lib/gl/m4/intldir.m4                     |    2 +-
 lib/gl/m4/intlmacosx.m4                  |    2 +-
 lib/gl/m4/intmax.m4                      |    2 +-
 lib/gl/m4/intmax_t.m4                    |    2 +-
 lib/gl/m4/inttypes-pri.m4                |    2 +-
 lib/gl/m4/inttypes.m4                    |   21 +-
 lib/gl/m4/inttypes_h.m4                  |    2 +-
 lib/gl/m4/lcmessage.m4                   |    2 +-
 lib/gl/m4/ld-output-def.m4               |    2 +-
 lib/gl/m4/ld-version-script.m4           |   17 +-
 lib/gl/m4/lib-ld.m4                      |    2 +-
 lib/gl/m4/lib-link.m4                    |    2 +-
 lib/gl/m4/lib-prefix.m4                  |    2 +-
 lib/gl/m4/lock.m4                        |    2 +-
 lib/gl/m4/longlong.m4                    |    8 +-
 lib/gl/m4/malloc.m4                      |    2 +-
 lib/gl/m4/math_h.m4                      |  243 ++++
 lib/gl/m4/md5.m4                         |    2 +-
 lib/gl/m4/memchr.m4                      |    2 +-
 lib/gl/m4/memmem.m4                      |    2 +-
 lib/gl/m4/memxor.m4                      |    2 +-
 lib/gl/m4/minmax.m4                      |    2 +-
 lib/gl/m4/mmap-anon.m4                   |   10 +-
 lib/gl/m4/msvc-inval.m4                  |   19 +
 lib/gl/m4/multiarch.m4                   |    2 +-
 lib/gl/m4/nls.m4                         |    2 +-
 lib/gl/m4/po.m4                          |   27 +-
 lib/gl/m4/printf-posix.m4                |    2 +-
 lib/gl/m4/printf.m4                      |  139 ++-
 lib/gl/m4/progtest.m4                    |    2 +-
 lib/gl/m4/realloc.m4                     |    2 +-
 lib/gl/m4/sha1.m4                        |    2 +-
 lib/gl/m4/size_max.m4                    |    2 +-
 lib/gl/m4/ssize_t.m4                     |   23 +
 lib/gl/m4/stdalign.m4                    |   51 +
 lib/gl/m4/stdbool.m4                     |    2 +-
 lib/gl/m4/stddef_h.m4                    |    2 +-
 lib/gl/m4/stdint.m4                      |   16 +-
 lib/gl/m4/stdint_h.m4                    |    2 +-
 lib/gl/m4/stdio_h.m4                     |   11 +-
 lib/gl/m4/stdlib_h.m4                    |   21 +-
 lib/gl/m4/string_h.m4                    |   14 +-
 lib/gl/m4/strnlen.m4                     |    2 +-
 lib/gl/m4/strverscmp.m4                  |    2 +-
 lib/gl/m4/threadlib.m4                   |   34 +-
 lib/gl/m4/uintmax_t.m4                   |    2 +-
 lib/gl/m4/unistd_h.m4                    |   36 +-
 lib/gl/m4/vasnprintf.m4                  |   13 +-
 lib/gl/m4/vasprintf.m4                   |    2 +-
 lib/gl/m4/visibility.m4                  |    2 +-
 lib/gl/m4/warn-on-use.m4                 |   10 +-
 lib/gl/m4/wchar_h.m4                     |    2 +-
 lib/gl/m4/wchar_t.m4                     |    2 +-
 lib/gl/m4/wint_t.m4                      |    2 +-
 lib/gl/m4/xsize.m4                       |    2 +-
 lib/gl/md5.c                             |    8 +-
 lib/gl/md5.h                             |    4 +-
 lib/gl/memchr.c                          |    2 +-
 lib/gl/memmem.c                          |    2 +-
 lib/gl/memxor.c                          |    2 +-
 lib/gl/memxor.h                          |    2 +-
 lib/gl/minmax.h                          |    2 +-
 lib/gl/override/lib/gettext.h.diff       |   18 +-
 lib/gl/printf-args.c                     |    2 +-
 lib/gl/printf-args.h                     |    2 +-
 lib/gl/printf-parse.c                    |    4 +-
 lib/gl/printf-parse.h                    |    2 +-
 lib/gl/realloc.c                         |    2 +-
 lib/gl/sha1.c                            |    8 +-
 lib/gl/sha1.h                            |    2 +-
 lib/gl/size_max.h                        |    2 +-
 lib/gl/stdalign.in.h                     |   91 ++
 lib/gl/stdbool.in.h                      |    2 +-
 lib/gl/stddef.in.h                       |    2 +-
 lib/gl/stdint.in.h                       |  128 ++-
 lib/gl/stdio.in.h                        |   44 +-
 lib/gl/stdlib.in.h                       |  186 +++-
 lib/gl/str-two-way.h                     |    2 +-
 lib/gl/string.in.h                       |   32 +-
 lib/gl/strnlen.c                         |    2 +-
 lib/gl/strverscmp.c                      |    4 +-
 lib/gl/unistd.in.h                       |  334 ++++--
 lib/gl/vasnprintf.c                      |   91 +-
 lib/gl/vasnprintf.h                      |    2 +-
 lib/gl/vasprintf.c                       |    2 +-
 lib/gl/verify.h                          |   16 +-
 lib/gl/wchar.in.h                        |   14 +-
 lib/gl/xsize.h                           |    2 +-
 lib/gltests/Makefile.am                  |  282 ++++--
 lib/gltests/dummy.c                      |    2 +-
 lib/gltests/fdopen.c                     |   69 ++
 lib/gltests/fpucw.h                      |    2 +-
 lib/gltests/getpagesize.c                |    4 +-
 lib/gltests/init.sh                      |  122 ++-
 lib/gltests/intprops.h                   |    2 +-
 lib/gltests/inttypes.in.h                | 1770 +++++++++++++++---------------
 lib/gltests/macros.h                     |    2 +-
 lib/gltests/msvc-inval.c                 |  130 +++
 lib/gltests/msvc-inval.h                 |  223 ++++
 lib/gltests/signature.h                  |    2 +-
 lib/gltests/test-alloca-opt.c            |    2 +-
 lib/gltests/test-base64.c                |   16 +-
 lib/gltests/test-c-ctype.c               |    2 +-
 lib/gltests/test-errno.c                 |    2 +-
 lib/gltests/test-fdopen.c                |   54 +
 lib/gltests/test-fgetc.c                 |   96 ++
 lib/gltests/test-float.c                 |    6 +-
 lib/gltests/test-fputc.c                 |   90 ++
 lib/gltests/test-fread.c                 |   99 ++
 lib/gltests/test-fwrite.c                |   93 ++
 lib/gltests/test-gc-hmac-md5.c           |    2 +-
 lib/gltests/test-gc-hmac-sha1.c          |    2 +-
 lib/gltests/test-gc-md5.c                |    2 +-
 lib/gltests/test-gc-pbkdf2-sha1.c        |    2 +-
 lib/gltests/test-gc-sha1.c               |    2 +-
 lib/gltests/test-gc.c                    |    2 +-
 lib/gltests/test-getdelim.c              |    2 +-
 lib/gltests/test-getline.c               |    2 +-
 lib/gltests/test-hmac-md5.c              |  147 +++
 lib/gltests/test-hmac-sha1.c             |  121 ++
 lib/gltests/test-init.sh                 |   73 ++
 lib/gltests/test-intprops.c              |    2 +-
 lib/gltests/test-inttypes.c              |    5 +-
 lib/gltests/test-md5.c                   |   67 ++
 lib/gltests/test-memchr.c                |    2 +-
 lib/gltests/test-memmem.c                |    2 +-
 lib/gltests/test-sha1.c                  |   48 +
 lib/gltests/test-stdalign.c              |  116 ++
 lib/gltests/test-stdbool.c               |    2 +-
 lib/gltests/test-stddef.c                |    2 +-
 lib/gltests/test-stdint.c                |    4 +-
 lib/gltests/test-stdio.c                 |    2 +-
 lib/gltests/test-stdlib.c                |    2 +-
 lib/gltests/test-string.c                |    2 +-
 lib/gltests/test-strnlen.c               |    2 +-
 lib/gltests/test-strverscmp.c            |    2 +-
 lib/gltests/test-sys_wait.h              |    2 +-
 lib/gltests/test-unistd.c                |    2 +-
 lib/gltests/test-vasnprintf.c            |    2 +-
 lib/gltests/test-vasprintf.c             |    2 +-
 lib/gltests/test-verify.c                |    2 +-
 lib/gltests/test-wchar.c                 |    2 +-
 lib/gltests/zerosize-ptr.h               |    2 +-
 lib/maint.mk                             |  148 ++-
 lib/openid20/Makefile.am                 |   33 +
 lib/openid20/client.c                    |  108 ++
 lib/openid20/mechinfo.c                  |   61 +
 lib/openid20/openid20.h                  |   54 +
 lib/openid20/server.c                    |   88 ++
 lib/po/sr.po.in                          |  319 ++++--
 lib/saml20/client.c                      |    5 +-
 lib/scram/client.c                       |    2 +
 lib/src/Makefile.am                      |    6 +-
 lib/src/error.c                          |    4 +-
 lib/src/gsasl.h                          |    5 +
 lib/src/init.c                           |    9 +-
 lib/src/internal.h                       |    1 +
 lib/src/mechtools.c                      |   13 +-
 lib/src/mechtools.h                      |    4 +-
 lib/src/property.c                       |    4 +
 lib/src/xfinish.c                        |    1 +
 lib/tests/test-error.c                   |    4 +-
 maint.mk                                 |  148 ++-
 po/sr.po.in                              |  190 +++-
 src/callbacks.c                          |   11 +
 src/gsasl.c                              |    4 +-
 src/imap.c                               |   13 +-
 tests/Makefile.am                        |    2 +-
 tests/readnz.c                           |    4 +-
 tests/saml20.c                           |   10 +-
 754 files changed, 17691 insertions(+), 9063 deletions(-)
 delete mode 100644 gl/alignof.h
 create mode 100644 gl/c-strcaseeq.h
 delete mode 100644 gl/fclose.c
 delete mode 100644 gl/fflush.c
 delete mode 100644 gl/fpurge.c
 delete mode 100644 gl/freading.c
 delete mode 100644 gl/freading.h
 create mode 100644 gl/fstat.c
 delete mode 100644 gl/ftell.c
 delete mode 100644 gl/ftello.c
 create mode 100644 gl/itold.c
 create mode 100644 gl/m4/exponentd.m4
 delete mode 100644 gl/m4/fclose.m4
 create mode 100644 gl/m4/fdopen.m4
 delete mode 100644 gl/m4/fflush.m4
 delete mode 100644 gl/m4/fpurge.m4
 delete mode 100644 gl/m4/freading.m4
 create mode 100644 gl/m4/fstat.m4
 delete mode 100644 gl/m4/ftell.m4
 delete mode 100644 gl/m4/ftello.m4
 create mode 100644 gl/m4/ftruncate.m4
 create mode 100644 gl/m4/largefile.m4
 create mode 100644 gl/m4/math_h.m4
 create mode 100644 gl/m4/msvc-inval.m4
 create mode 100644 gl/m4/msvc-nothrow.m4
 create mode 100644 gl/m4/nocrash.m4
 create mode 100644 gl/m4/pathmax.m4
 create mode 100644 gl/m4/signal_h.m4
 create mode 100644 gl/m4/ssize_t.m4
 create mode 100644 gl/m4/stdalign.m4
 create mode 100644 gl/m4/sys_types_h.m4
 create mode 100644 gl/msvc-inval.c
 create mode 100644 gl/msvc-inval.h
 create mode 100644 gl/msvc-nothrow.c
 create mode 100644 gl/msvc-nothrow.h
 delete mode 100644 gl/override/lib/dup2.c.diff
 delete mode 100644 gl/override/lib/getpass.c.diff
 delete mode 100644 gl/override/m4/open.m4.diff
 create mode 100644 gl/signal.in.h
 create mode 100644 gl/stdalign.in.h
 create mode 100644 gl/sys_stat.in.h
 create mode 100644 gl/sys_types.in.h
 create mode 100644 gl/time.in.h
 create mode 100644 gltests/fdopen.c
 create mode 100644 gltests/ftruncate.c
 create mode 100644 gltests/pathmax.h
 delete mode 100644 gltests/sys_stat.in.h
 create mode 100644 gltests/test-accept.c
 delete mode 100644 gltests/test-alignof.c
 create mode 100644 gltests/test-bind.c
 create mode 100644 gltests/test-close.c
 create mode 100644 gltests/test-connect.c
 delete mode 100644 gltests/test-fclose.c
 create mode 100644 gltests/test-fdopen.c
 delete mode 100644 gltests/test-fflush.c
 delete mode 100644 gltests/test-fflush2.c
 delete mode 100755 gltests/test-fflush2.sh
 create mode 100644 gltests/test-fgetc.c
 delete mode 100644 gltests/test-fpurge.c
 create mode 100644 gltests/test-fputc.c
 create mode 100644 gltests/test-fread.c
 delete mode 100644 gltests/test-freading.c
 create mode 100644 gltests/test-fseeko3.c
 create mode 100755 gltests/test-fseeko3.sh
 create mode 100644 gltests/test-fseeko4.c
 create mode 100755 gltests/test-fseeko4.sh
 create mode 100644 gltests/test-fstat.c
 delete mode 100644 gltests/test-ftell.c
 delete mode 100755 gltests/test-ftell.sh
 delete mode 100755 gltests/test-ftell2.sh
 delete mode 100644 gltests/test-ftell3.c
 delete mode 100644 gltests/test-ftello.c
 delete mode 100755 gltests/test-ftello.sh
 delete mode 100755 gltests/test-ftello2.sh
 delete mode 100644 gltests/test-ftello3.c
 create mode 100644 gltests/test-ftruncate.c
 create mode 100755 gltests/test-ftruncate.sh
 create mode 100644 gltests/test-fwrite.c
 create mode 100755 gltests/test-init.sh
 create mode 100644 gltests/test-ioctl.c
 create mode 100644 gltests/test-listen.c
 create mode 100644 gltests/test-pathmax.c
 create mode 100644 gltests/test-recv.c
 create mode 100644 gltests/test-select.h
 create mode 100644 gltests/test-setsockopt.c
 create mode 100644 gltests/test-shutdown.c
 create mode 100644 gltests/test-signal-h.c
 create mode 100644 gltests/test-stdalign.c
 create mode 100644 gltests/test-sys_types.c
 create mode 100644 gltests/test-thread_create.c
 create mode 100644 gltests/test-thread_self.c
 delete mode 100644 gltests/time.in.h
 delete mode 100644 lib/build-aux/arg-nonnull.h
 delete mode 100644 lib/build-aux/c++defs.h
 create mode 100644 lib/build-aux/snippet/_Noreturn.h
 create mode 100644 lib/build-aux/snippet/arg-nonnull.h
 create mode 100644 lib/build-aux/snippet/c++defs.h
 create mode 100644 lib/build-aux/snippet/unused-parameter.h
 create mode 100644 lib/build-aux/snippet/warn-on-use.h
 delete mode 100644 lib/build-aux/unused-parameter.h
 delete mode 100644 lib/build-aux/warn-on-use.h
 create mode 100644 lib/gl/itold.c
 create mode 100644 lib/gl/m4/exponentd.m4
 create mode 100644 lib/gl/m4/fdopen.m4
 create mode 100644 lib/gl/m4/math_h.m4
 create mode 100644 lib/gl/m4/msvc-inval.m4
 create mode 100644 lib/gl/m4/ssize_t.m4
 create mode 100644 lib/gl/m4/stdalign.m4
 create mode 100644 lib/gl/stdalign.in.h
 create mode 100644 lib/gltests/fdopen.c
 create mode 100644 lib/gltests/msvc-inval.c
 create mode 100644 lib/gltests/msvc-inval.h
 create mode 100644 lib/gltests/test-fdopen.c
 create mode 100644 lib/gltests/test-fgetc.c
 create mode 100644 lib/gltests/test-fputc.c
 create mode 100644 lib/gltests/test-fread.c
 create mode 100644 lib/gltests/test-fwrite.c
 create mode 100644 lib/gltests/test-hmac-md5.c
 create mode 100644 lib/gltests/test-hmac-sha1.c
 create mode 100755 lib/gltests/test-init.sh
 create mode 100644 lib/gltests/test-md5.c
 create mode 100644 lib/gltests/test-sha1.c
 create mode 100644 lib/gltests/test-stdalign.c
 create mode 100644 lib/openid20/Makefile.am
 create mode 100644 lib/openid20/client.c
 create mode 100644 lib/openid20/mechinfo.c
 create mode 100644 lib/openid20/openid20.h
 create mode 100644 lib/openid20/server.c

diff --git a/.gitignore b/.gitignore
index 3998438..9fcb755 100644
--- a/.gitignore
+++ b/.gitignore
@@ -88,7 +88,11 @@ examples/client-mech
 examples/client-mech.o
 examples/client-serverfirst
 examples/client-serverfirst.o
+examples/client-xmpp-saml20
+examples/client-xmpp-saml20.o
 examples/client.o
+examples/server-xmpp-saml20
+examples/server-xmpp-saml20.o
 gl/.deps/
 gl/.libs/
 gl/Makefile
@@ -111,6 +115,8 @@ gl/close-hook.o
 gl/configmake.h
 gl/exitfail.lo
 gl/exitfail.o
+gl/fclose.lo
+gl/fclose.o
 gl/fd-hook.lo
 gl/fd-hook.o
 gl/fflush.lo
@@ -119,6 +125,8 @@ gl/fpurge.lo
 gl/fpurge.o
 gl/freading.lo
 gl/freading.o
+gl/fseek.lo
+gl/fseek.o
 gl/fseeko.lo
 gl/fseeko.o
 gl/iconv.h
@@ -150,11 +158,25 @@ gl/sockets.lo
 gl/sockets.o
 gl/stdio.h
 gl/stdlib.h
+gl/strerror.lo
+gl/strerror.o
 gl/striconv.lo
 gl/striconv.o
 gl/string.h
 gl/sys/
 gl/unistd.h
+gl/unistr.h
+gl/unistr/.deps/
+gl/unistr/.dirstamp
+gl/unistr/.libs/
+gl/unistr/u8-mbtoucr.lo
+gl/unistr/u8-mbtoucr.o
+gl/unistr/u8-uctomb-aux.lo
+gl/unistr/u8-uctomb-aux.o
+gl/unistr/u8-uctomb.lo
+gl/unistr/u8-uctomb.o
+gl/unitypes.h
+gl/unused-parameter.h
 gl/vasnprintf.lo
 gl/vasnprintf.o
 gl/version-etc.lo
@@ -177,11 +199,14 @@ gltests/glthread/.dirstamp
 gltests/glthread/lock.o
 gltests/glthread/thread.o
 gltests/glthread/threadlib.o
+gltests/inttypes.h
 gltests/ioctl.o
 gltests/libtests.a
 gltests/locale.h
 gltests/localename.o
 gltests/malloca.o
+gltests/perror.o
+gltests/strerror_r.o
 gltests/sys/
 gltests/test-alignof
 gltests/test-alignof.o
@@ -205,16 +230,22 @@ gltests/test-environ
 gltests/test-environ.o
 gltests/test-errno
 gltests/test-errno.o
+gltests/test-fclose
+gltests/test-fclose.o
 gltests/test-fcntl-h
 gltests/test-fcntl-h.o
 gltests/test-fflush
 gltests/test-fflush.o
 gltests/test-fflush2
 gltests/test-fflush2.o
+gltests/test-float
+gltests/test-float.o
 gltests/test-fpurge
 gltests/test-fpurge.o
 gltests/test-freading
 gltests/test-freading.o
+gltests/test-fseek
+gltests/test-fseek.o
 gltests/test-fseeko
 gltests/test-fseeko.o
 gltests/test-ftell
@@ -227,6 +258,8 @@ gltests/test-ftello3
 gltests/test-ftello3.o
 gltests/test-getaddrinfo
 gltests/test-getaddrinfo.o
+gltests/test-getcwd-lgpl
+gltests/test-getcwd-lgpl.o
 gltests/test-getdelim
 gltests/test-getdelim.o
 gltests/test-getline
@@ -245,6 +278,10 @@ gltests/test-inet_ntop
 gltests/test-inet_ntop.o
 gltests/test-inet_pton
 gltests/test-inet_pton.o
+gltests/test-intprops
+gltests/test-intprops.o
+gltests/test-inttypes
+gltests/test-inttypes.o
 gltests/test-locale
 gltests/test-locale.o
 gltests/test-localename
@@ -273,6 +310,8 @@ gltests/test-open
 gltests/test-open.o
 gltests/test-perror
 gltests/test-perror.o
+gltests/test-perror2
+gltests/test-perror2.o
 gltests/test-pipe
 gltests/test-pipe.o
 gltests/test-poll
@@ -313,6 +352,8 @@ gltests/test-stdlib
 gltests/test-stdlib.o
 gltests/test-strerror
 gltests/test-strerror.o
+gltests/test-strerror_r
+gltests/test-strerror_r.o
 gltests/test-striconv
 gltests/test-striconv.o
 gltests/test-string
@@ -335,6 +376,8 @@ gltests/test-sys_wait
 gltests/test-sys_wait.o
 gltests/test-time
 gltests/test-time.o
+gltests/test-u8-mbtoucr
+gltests/test-u8-uctomb
 gltests/test-unistd
 gltests/test-unistd.o
 gltests/test-unsetenv
@@ -359,6 +402,11 @@ gltests/test-wctype.o
 gltests/test-xalloc-die
 gltests/test-xalloc-die.o
 gltests/time.h
+gltests/unistr/.deps/
+gltests/unistr/.dirstamp
+gltests/unistr/test-u8-mbtoucr.o
+gltests/unistr/test-u8-uctomb.o
+gltests/unused-parameter.h
 gltests/version-etc-fsf.o
 gltests/warn-on-use.h
 gsasl-*.tar.gz
@@ -379,6 +427,7 @@ lib/anonymous/mechinfo.o
 lib/anonymous/server.lo
 lib/anonymous/server.o
 lib/autom4te.cache/
+lib/build-aux/compile
 lib/build-aux/config.guess
 lib/build-aux/config.sub
 lib/build-aux/depcomp
@@ -492,6 +541,7 @@ lib/gltests/Makefile.in
 lib/gltests/arg-nonnull.h
 lib/gltests/c++defs.h
 lib/gltests/dummy.o
+lib/gltests/inttypes.h
 lib/gltests/libtests.a
 lib/gltests/test-alloca-opt
 lib/gltests/test-alloca-opt.o
@@ -501,6 +551,8 @@ lib/gltests/test-c-ctype
 lib/gltests/test-c-ctype.o
 lib/gltests/test-errno
 lib/gltests/test-errno.o
+lib/gltests/test-float
+lib/gltests/test-float.o
 lib/gltests/test-gc
 lib/gltests/test-gc-hmac-md5
 lib/gltests/test-gc-hmac-md5.o
@@ -517,6 +569,10 @@ lib/gltests/test-getdelim
 lib/gltests/test-getdelim.o
 lib/gltests/test-getline
 lib/gltests/test-getline.o
+lib/gltests/test-intprops
+lib/gltests/test-intprops.o
+lib/gltests/test-inttypes
+lib/gltests/test-inttypes.o
 lib/gltests/test-memchr
 lib/gltests/test-memchr.o
 lib/gltests/test-memmem
@@ -636,6 +692,15 @@ lib/ntlm/mechinfo.lo
 lib/ntlm/mechinfo.o
 lib/ntlm/ntlm.lo
 lib/ntlm/ntlm.o
+lib/openid20/.deps/
+lib/openid20/.libs/
+lib/openid20/client.lo
+lib/openid20/client.o
+lib/openid20/libgsasl-openid20.la
+lib/openid20/mechinfo.lo
+lib/openid20/mechinfo.o
+lib/openid20/server.lo
+lib/openid20/server.o
 lib/plain/.deps/
 lib/plain/.libs/
 lib/plain/Makefile
diff --git a/GNUmakefile b/GNUmakefile
index 6e00ec8..d0fd3e8 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -1,11 +1,11 @@
-# Having a separate GNUmakefile lets me `include' the dynamically
+# Having a separate GNUmakefile lets me 'include' the dynamically
 # generated rules created via cfg.mk (package-local configuration)
 # as well as maint.mk (generic maintainer rules).
 # This makefile is used only if you run GNU Make.
 # It is necessary if you want to build targets usually of interest
 # only to the maintainer.
 
-# Copyright (C) 2001, 2003, 2006-2011 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2003, 2006-2012 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
@@ -45,12 +45,13 @@ include Makefile
 
 # Some projects override e.g., _autoreconf here.
 -include $(srcdir)/cfg.mk
-include $(srcdir)/maint.mk
 
 # Allow cfg.mk to override these.
 _build-aux ?= build-aux
 _autoreconf ?= autoreconf -v
 
+include $(srcdir)/maint.mk
+
 # Ensure that $(VERSION) is up to date for dist-related targets, but not
 # for others: rerunning autoreconf and recompiling everything isn't cheap.
 _have-git-version-gen := \
@@ -100,6 +101,11 @@ srcdir = .
 
 # The package can override .DEFAULT_GOAL to run actions like autoreconf.
 -include ./cfg.mk
+
+# Allow cfg.mk to override these.
+_build-aux ?= build-aux
+_autoreconf ?= autoreconf -v
+
 include ./maint.mk
 
 ifeq ($(.DEFAULT_GOAL),abort-due-to-no-makefile)
@@ -108,7 +114,7 @@ endif
 
 abort-due-to-no-makefile:
        @echo There seems to be no Makefile in this directory.   1>&2
-       @echo "You must run ./configure before running \`make'." 1>&2
+       @echo "You must run ./configure before running 'make'." 1>&2
        @exit 1
 
 endif
diff --git a/NEWS b/NEWS
index 5791549..4471b1d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,5 @@
 GNU SASL NEWS -- History of user-visible changes.
-Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Simon 
Josefsson
+Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 
Simon Josefsson
 See the end for copying conditions.
 
 Note that changes to the GNU SASL Library is documented in lib/NEWS.
@@ -8,6 +8,15 @@ SASL.  That include the manual, the command line tool, and 
self tests.
 
 * Version 1.7.1 (unreleased) [alpha]
 
+** gsasl: Ignore untagged responses during IMAP authentication.
+Patch from Enrico Scholz <address@hidden>.
+
+** tests: Disable the test-poll self-test, it doesn't seem to work on Solaris.
+Reported by Dagobert Michelsen <address@hidden>.
+
+** libgsasl: Implement OPENID20 mechanism for OpenID authentication.
+Following draft-ietf-kitten-sasl-openid-03.
+
 ** Demand gettext >= 0.18.1 in order to get newer M4 files.
 The old M4 files associated with 0.17 caused problems on Solaris,
 which will hopefully be fixed with this.  Reported by Dagobert
@@ -20,6 +29,7 @@ Michelsen <address@hidden>.
 ** i18n: Updated translations.
 
 ** examples: Added client-xmpp-saml20 and server-xmpp-saml20.
+The examples illustrates a sample SAML20 client and server.
 
 * Version 1.7.0 (released 2010-10-22) [alpha]
 
diff --git a/cfg.mk b/cfg.mk
index ac41c29..c995885 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -1,4 +1,4 @@
-# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Simon Josefsson
+# Copyright (C) 2006-2012 Simon Josefsson
 #
 # This file is part of GNU SASL.
 #
@@ -19,7 +19,7 @@ WFLAGS ?= --enable-gcc-warnings
 ADDFLAGS ?=
 CFGFLAGS ?= --enable-gtk-doc --enable-gtk-doc-pdf $(ADDFLAGS) $(WFLAGS)
 
-build_aux = lib/build-aux
+_build-aux = lib/build-aux
 
 INDENT_SOURCES = `find . -name \*.c -or -name \*.h | grep -v -e /gl -e 
build-aux -e /win32/ -e /examples/`
 
@@ -47,9 +47,9 @@ autoreconf:
        for f in po/*.po.in lib/po/*.po.in; do \
                cp $$f `echo $$f | sed 's/.in//'`; \
        done
-       mv $(build_aux)/config.rpath $(build_aux)/config.rpath-
+       mv $(_build-aux)/config.rpath $(_build-aux)/config.rpath-
        test -f ./configure || autoreconf --install
-       mv $(build_aux)/config.rpath- $(build_aux)/config.rpath
+       mv $(_build-aux)/config.rpath- $(_build-aux)/config.rpath
 
 update-po:
        $(MAKE) -C lib refresh-po PACKAGE=libgsasl
@@ -103,7 +103,7 @@ upload:
 web:
        cd doc && env MAKEINFO="makeinfo -I ../examples" \
                      TEXI2DVI="texi2dvi -I ../examples" \
-               $(SHELL) ../$(build_aux)/gendocs.sh \
+               $(SHELL) ../$(_build-aux)/gendocs.sh \
                        --html "--css-include=texinfo.css" \
                        -o ../$(htmldir)/manual/ $(PACKAGE) "$(PACKAGE_NAME)"
        cd doc/doxygen && doxygen && cd ../.. && cp -v doc/doxygen/html/* 
$(htmldir)/doxygen/ && cd doc/doxygen/latex && make refman.pdf && cd ../../../ 
&& cp doc/doxygen/latex/refman.pdf $(htmldir)/doxygen/$(PACKAGE).pdf
diff --git a/doc/fdl-1.3.texi b/doc/fdl-1.3.texi
index fc19ddd..cb71f05 100644
--- a/doc/fdl-1.3.texi
+++ b/doc/fdl-1.3.texi
@@ -481,7 +481,7 @@ license notices just after the title page:
 @end smallexample
 
 If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
-replace the address@hidden'' line with this:
+replace the address@hidden''@: line with this:
 
 @smallexample
 @group
@@ -503,4 +503,3 @@ to permit their use in free software.
 @c Local Variables:
 @c ispell-local-pdict: "ispell-dict"
 @c End:
-
diff --git a/doc/gendocs_template b/doc/gendocs_template
index d40333f..b69a098 100644
--- a/doc/gendocs_template
+++ b/doc/gendocs_template
@@ -90,7 +90,7 @@ the FSF.<br />
 Please send broken links and other corrections or suggestions to
 <a href="mailto:%%EMAIL%%";>&lt;%%EMAIL%%&gt;</a>.</p>
 
-<p>Copyright &copy; 2011 Free Software Foundation, Inc.</p>
+<p>Copyright &copy; 2012 Free Software Foundation, Inc.</p>
 
 <p>Verbatim copying and distribution of this entire article are
 permitted worldwide, without royalty, in any medium, provided this
diff --git a/doc/gsasl.texi b/doc/gsasl.texi
index ae76540..7c82488 100644
--- a/doc/gsasl.texi
+++ b/doc/gsasl.texi
@@ -172,7 +172,8 @@ manual.  The library includes support for the framework 
(with
 authentication functions and application data privacy and integrity
 functions) and at least partial support for the ANONYMOUS, CRAM-MD5,
 DIGEST-MD5, EXTERNAL, GS2-KRB5, GSSAPI, LOGIN, NTLM, PLAIN,
-SCRAM-SHA-1 (and SCRAM-SHA-1-PLUS), SAML20, and SECURID mechanisms.
+SCRAM-SHA-1, SCRAM-SHA-1-PLUS, SAML20, OPENID20, and SECURID
+mechanisms.
 
 The library is easily ported because it does not do network
 communication by itself, but rather leaves it up to the calling
@@ -518,6 +519,7 @@ want to limit the size of the library.
 @itemx --enable-kerberos_v5
 @itemx --disable-scram-sha1
 @itemx --disable-saml20
address@hidden --disable-openid20
 Disable or enable individual mechanisms (@pxref{Mechanisms}).
 
 @item --without-stringprep
@@ -1678,6 +1680,7 @@ entirely dependent on callbacks.
 * GS2-KRB5::                Improved GSSAPI (Kerberos 5) authentication.
 * KERBEROS_V5::             Experimental KERBEROS_V5 authentication.
 * SAML20::                  Experimental SAML20 authentication.
+* OPENID20::                Experimental OPENID20 authentication.
 @end menu
 
 @node EXTERNAL
@@ -2037,7 +2040,7 @@ XXX: update when implementation has matured
 
 The SAML20 mechanism makes it possible to use SAML in SASL, in a way
 that offloads the authentication exchange to an external browser.  The
-protocol version implemented is as specified in
+protocol implemented is as specified in
 @code{draft-ietf-kitten-sasl-saml-01}.
 
 The mechanism makes use of the following properties: GSASL_AUTHZID,
@@ -2061,6 +2064,15 @@ hopefully complete authentication in the browser.  The 
server callback
 GSASL_VALIDATE_SAML20 should check whether the authentication attempt
 was successful.
 
address@hidden OPENID20
address@hidden The OPENID20 mechanism
address@hidden OpenID
+
+The OPENID20 mechanism makes it possible to use OpenID in SASL, in a
+way that offloads the authentication exchange to an external browser.
+The protocol implemented is as specified in
address@hidden
+
 @c **********************************************************
 @c *****************  Global Functions  *********************
 @c **********************************************************
diff --git a/doc/reference/gsasl-docs.sgml b/doc/reference/gsasl-docs.sgml
index 4ad9cd2..930f628 100644
--- a/doc/reference/gsasl-docs.sgml
+++ b/doc/reference/gsasl-docs.sgml
@@ -23,7 +23,7 @@ library includes support for the framework (with 
authentication
 functions and application data privacy and integrity functions) and at
 least partial support for the ANONYMOUS, CRAM-MD5, DIGEST-MD5,
 EXTERNAL, GS2-KRB5, GSSAPI, LOGIN, NTLM, PLAIN, SCRAM-SHA-1,
-SCRAM-SHA-1-PLUS, and SECURID mechanisms.
+SCRAM-SHA-1-PLUS, SAML20, OPENID20, and SECURID mechanisms.
     </para>
 
     <para>
diff --git a/examples/client-xmpp-saml20.c b/examples/client-xmpp-saml20.c
index b1a016a..6e22b14 100644
--- a/examples/client-xmpp-saml20.c
+++ b/examples/client-xmpp-saml20.c
@@ -1,5 +1,5 @@
 /* client-xmpp-saml20.c --- Example XMPP SASL SAML20 client.
- * Copyright (C) 2004, 2005, 2007, 2009, 2010  Simon Josefsson
+ * Copyright (C) 2004, 2005, 2007, 2009, 2010, 2012  Simon Josefsson
  *
  * This file is part of GNU SASL.
  *
@@ -55,7 +55,7 @@ client_xmpp (Gsasl_session * session)
   rc = gsasl_step64 (session, buf, &p);
   if (rc != GSASL_NEEDS_MORE)
     {
-      printf ("SAML20 init error (%d): %s\n", rc, gsasl_strerror (rc));
+      printf ("SAML20 step error (%d): %s\n", rc, gsasl_strerror (rc));
       return;
     }
 
@@ -64,16 +64,13 @@ client_xmpp (Gsasl_session * session)
 
   do
     {
-      char *line = NULL;
-      size_t n;
-      ssize_t len;
       char *b64;
 
-      len = getline (&line, &n, stdin);
-      if (len <= 0)
-       break;
+      fgets (buf, sizeof (buf) - 1, stdin);
+      if (buf[strlen (buf) - 1] == '\n')
+        buf[strlen (buf) - 1] = '\0';
 
-      b64 = xmltob64 (line);
+      b64 = xmltob64 (buf);
 
       printf ("parsed: '%s'\n", b64);
 
diff --git a/examples/server-xmpp-saml20.c b/examples/server-xmpp-saml20.c
index 5fd1e74..4dd4a1c 100644
--- a/examples/server-xmpp-saml20.c
+++ b/examples/server-xmpp-saml20.c
@@ -1,5 +1,5 @@
 /* server-xmpp-saml20.c --- Example XMPP SASL SAML20 server.
- * Copyright (C) 2004, 2005, 2007, 2009, 2010  Simon Josefsson
+ * Copyright (C) 2004-2012  Simon Josefsson
  *
  * This file is part of GNU SASL.
  *
@@ -43,19 +43,18 @@ static void
 server_xmpp (Gsasl_session * session)
 {
   char *b64, *p;
-  int rc;
+  int rc = GSASL_AUTHENTICATION_ERROR;
 
   do
     {
-      char *line = NULL;
-      size_t n;
-      ssize_t len;
+      char buf[BUFSIZ] = "";
 
-      len = getline (&line, &n, stdin);
-      if (len <= 0)
+      if (fgets (buf, sizeof (buf) - 1, stdin) == NULL)
        break;
+      if (buf[strlen (buf) - 1] == '\n')
+        buf[strlen (buf) - 1] = '\0';
 
-      b64 = xmltob64 (line);
+      b64 = xmltob64 (buf);
 
       printf ("parsed: '%s'\n", b64);
 
@@ -145,9 +144,7 @@ callback (Gsasl * ctx, Gsasl_session * sctx, Gsasl_property 
prop)
 
     case GSASL_VALIDATE_SAML20:
       {
-       char *line = NULL;
-       size_t n;
-       ssize_t len;
+       char buf[BUFSIZ] = "";
 
        puts ("Authorization decision time!");
        printf ("User identity: %s\n",
@@ -155,17 +152,15 @@ callback (Gsasl * ctx, Gsasl_session * sctx, 
Gsasl_property prop)
        printf ("Accept user? (y/n) ");
        fflush (stdout);
 
-       len = getline (&line, &n, stdin);
-       if (len <= 0)
+       if (fgets (buf, sizeof (buf) - 1, stdin) == NULL)
          break;
-       if (line[strlen (line) - 1] == '\n')
-         line[strlen (line) - 1] = '\0';
+       if (buf[strlen (buf) - 1] == '\n')
+         buf[strlen (buf) - 1] = '\0';
 
-       if (strcmp (line, "y") == 0 || strcmp (line, "Y") == 0)
+       if (strcmp (buf, "y") == 0 || strcmp (buf, "Y") == 0)
          rc = GSASL_OK;
        else
          rc = GSASL_AUTHENTICATION_ERROR;
-       free (line);
       }
       break;
 
diff --git a/gl/Makefile.am b/gl/Makefile.am
index caf3e0a..9511690 100644
--- a/gl/Makefile.am
+++ b/gl/Makefile.am
@@ -1,15 +1,27 @@
 ## DO NOT EDIT! GENERATED AUTOMATICALLY!
 ## Process this file with automake to produce Makefile.in.
-# Copyright (C) 2002-2011 Free Software Foundation, Inc.
+# Copyright (C) 2002-2012 Free Software Foundation, Inc.
 #
-# This file is free software, distributed under the terms of the GNU
-# General Public License.  As a special exception to the GNU General
-# Public License, this file may be distributed as part of a program
-# that contains a configuration script generated by Autoconf, under
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception to the GNU General Public License,
+# this file may be distributed as part of a program that
+# contains a configuration script generated by Autoconf, under
 # the same distribution terms as the rest of that program.
 #
 # Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl/override 
--lib=libgl --source-base=gl --m4-base=gl/m4 --doc-base=doc 
--tests-base=gltests --aux-dir=lib/build-aux --with-tests 
--avoid=fcntl-h-c++-tests --avoid=iconv-h-c++-tests --avoid=stdio-c++-tests 
--avoid=stdlib-c++-tests --avoid=string-c++-tests --avoid=sys_ioctl-c++-tests 
--avoid=sys_select-c++-tests --avoid=sys_socket-c++-tests 
--avoid=sys_stat-c++-tests --avoid=sys_time-c++-tests --avoid=time-c++-tests 
--avoid=unistd-c++-tests --avoid=wchar-c++-tests --avoid=wctype-c++-tests 
--no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files 
autobuild close connect error fdl-1.3 gendocs getaddrinfo getopt-gnu getpass 
gpl-3.0 lgpl-2.1 maintainer-makefile manywarnings netdb netinet_in pmccabe2html 
poll progname quote readline recv shutdown socket striconv strtok_r sys_time 
unistd valgrind-tests vasprintf version-etc warnings xalloc
+# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl/override 
--lib=libgl --source-base=gl --m4-base=gl/m4 --doc-base=doc 
--tests-base=gltests --aux-dir=lib/build-aux --with-tests 
--no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files 
autobuild close connect error fdl-1.3 gendocs getaddrinfo getopt-gnu getpass 
gpl-3.0 lgpl-2.1 maintainer-makefile manywarnings netdb netinet_in pmccabe2html 
poll progname quote readline recv shutdown socket striconv strtok_r sys_time 
unistd valgrind-tests vasprintf version-etc warnings xalloc
 
 AUTOMAKE_OPTIONS = 1.5 gnits subdir-objects
 
@@ -42,18 +54,13 @@ libgl_la_LDFLAGS += $(GETADDRINFO_LIB)
 libgl_la_LDFLAGS += $(HOSTENT_LIB)
 libgl_la_LDFLAGS += $(INET_NTOP_LIB)
 libgl_la_LDFLAGS += $(LIBSOCKET)
+libgl_la_LDFLAGS += $(LIB_POLL)
+libgl_la_LDFLAGS += $(LIB_SELECT)
 libgl_la_LDFLAGS += $(LTLIBICONV)
 libgl_la_LDFLAGS += $(LTLIBINTL)
 libgl_la_LDFLAGS += $(LTLIBREADLINE)
 libgl_la_LDFLAGS += $(SERVENT_LIB)
 
-## begin gnulib module alignof
-
-
-EXTRA_DIST += alignof.h
-
-## end   gnulib module alignof
-
 ## begin gnulib module alloca
 
 
@@ -88,30 +95,6 @@ EXTRA_DIST += alloca.in.h
 
 ## end   gnulib module alloca-opt
 
-## begin gnulib module arg-nonnull
-
-# The BUILT_SOURCES created by this Makefile snippet are not used via #include
-# statements but through direct file reference. Therefore this snippet must be
-# present in all Makefile.am that need it. This is ensured by the applicability
-# 'all' defined above.
-
-BUILT_SOURCES += arg-nonnull.h
-# The arg-nonnull.h that gets inserted into generated .h files is the same as
-# build-aux/arg-nonnull.h, except that it has the copyright header cut off.
-arg-nonnull.h: $(top_srcdir)/lib/build-aux/arg-nonnull.h
-       $(AM_V_GEN)rm -f address@hidden $@ && \
-       sed -n -e '/GL_ARG_NONNULL/,$$p' \
-         < $(top_srcdir)/lib/build-aux/arg-nonnull.h \
-         > address@hidden && \
-       mv address@hidden $@
-MOSTLYCLEANFILES += arg-nonnull.h arg-nonnull.h-t
-
-ARG_NONNULL_H=arg-nonnull.h
-
-EXTRA_DIST += $(top_srcdir)/lib/build-aux/arg-nonnull.h
-
-## end   gnulib module arg-nonnull
-
 ## begin gnulib module arpa_inet
 
 BUILT_SOURCES += arpa/inet.h
@@ -133,6 +116,8 @@ arpa/inet.h: arpa_inet.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) $(WARN_ON
              -e 's/@''GNULIB_INET_PTON''@/$(GNULIB_INET_PTON)/g' \
              -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \
              -e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \
+             -e 's|@''REPLACE_INET_NTOP''@|$(REPLACE_INET_NTOP)|g' \
+             -e 's|@''REPLACE_INET_PTON''@|$(REPLACE_INET_PTON)|g' \
              -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
              -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
              -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
@@ -146,30 +131,6 @@ EXTRA_DIST += arpa_inet.in.h
 
 ## end   gnulib module arpa_inet
 
-## begin gnulib module c++defs
-
-# The BUILT_SOURCES created by this Makefile snippet are not used via #include
-# statements but through direct file reference. Therefore this snippet must be
-# present in all Makefile.am that need it. This is ensured by the applicability
-# 'all' defined above.
-
-BUILT_SOURCES += c++defs.h
-# The c++defs.h that gets inserted into generated .h files is the same as
-# build-aux/c++defs.h, except that it has the copyright header cut off.
-c++defs.h: $(top_srcdir)/lib/build-aux/c++defs.h
-       $(AM_V_GEN)rm -f address@hidden $@ && \
-       sed -n -e '/_GL_CXXDEFS/,$$p' \
-         < $(top_srcdir)/lib/build-aux/c++defs.h \
-         > address@hidden && \
-       mv address@hidden $@
-MOSTLYCLEANFILES += c++defs.h c++defs.h-t
-
-CXXDEFS_H=c++defs.h
-
-EXTRA_DIST += $(top_srcdir)/lib/build-aux/c++defs.h
-
-## end   gnulib module c++defs
-
 ## begin gnulib module c-ctype
 
 libgl_la_SOURCES += c-ctype.h c-ctype.c
@@ -182,6 +143,13 @@ libgl_la_SOURCES += c-strcase.h c-strcasecmp.c 
c-strncasecmp.c
 
 ## end   gnulib module c-strcase
 
+## begin gnulib module c-strcaseeq
+
+
+EXTRA_DIST += c-strcaseeq.h
+
+## end   gnulib module c-strcaseeq
+
 ## begin gnulib module close
 
 
@@ -227,12 +195,8 @@ configmake.h: Makefile
          echo '#define PKGINCLUDEDIR "$(pkgincludedir)"'; \
          echo '#define PKGLIBDIR "$(pkglibdir)"'; \
          echo '#define PKGLIBEXECDIR "$(pkglibexecdir)"'; \
-       } | sed '/""/d' > address@hidden && \
-       if test -f $@ && cmp address@hidden $@ > /dev/null; then \
-         rm -f address@hidden; \
-       else \
-         rm -f $@; mv address@hidden $@; \
-       fi
+       } | sed '/""/d' > address@hidden
+       mv -f address@hidden $@
 
 BUILT_SOURCES += configmake.h
 CLEANFILES += configmake.h configmake.h-t
@@ -299,15 +263,6 @@ EXTRA_DIST += exitfail.h
 
 ## end   gnulib module exitfail
 
-## begin gnulib module fclose
-
-
-EXTRA_DIST += fclose.c
-
-EXTRA_libgl_la_SOURCES += fclose.c
-
-## end   gnulib module fclose
-
 ## begin gnulib module fd-hook
 
 libgl_la_SOURCES += fd-hook.c
@@ -316,15 +271,6 @@ EXTRA_DIST += fd-hook.h
 
 ## end   gnulib module fd-hook
 
-## begin gnulib module fflush
-
-
-EXTRA_DIST += fflush.c stdio-impl.h
-
-EXTRA_libgl_la_SOURCES += fflush.c
-
-## end   gnulib module fflush
-
 ## begin gnulib module float
 
 BUILT_SOURCES += $(FLOAT_H)
@@ -340,6 +286,7 @@ float.h: float.in.h $(top_builddir)/config.status
              -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' \
+             -e 's|@''REPLACE_ITOLD''@|$(REPLACE_ITOLD)|g' \
              < $(srcdir)/float.in.h; \
        } > address@hidden && \
        mv address@hidden $@
@@ -349,29 +296,12 @@ float.h: $(top_builddir)/config.status
 endif
 MOSTLYCLEANFILES += float.h float.h-t
 
-EXTRA_DIST += float.c float.in.h
+EXTRA_DIST += float.c float.in.h itold.c
 
-EXTRA_libgl_la_SOURCES += float.c
+EXTRA_libgl_la_SOURCES += float.c itold.c
 
 ## end   gnulib module float
 
-## begin gnulib module fpurge
-
-
-EXTRA_DIST += fpurge.c stdio-impl.h
-
-EXTRA_libgl_la_SOURCES += fpurge.c
-
-## end   gnulib module fpurge
-
-## begin gnulib module freading
-
-libgl_la_SOURCES += freading.c
-
-EXTRA_DIST += freading.h stdio-impl.h
-
-## end   gnulib module freading
-
 ## begin gnulib module fseek
 
 
@@ -390,23 +320,14 @@ EXTRA_libgl_la_SOURCES += fseeko.c
 
 ## end   gnulib module fseeko
 
-## begin gnulib module ftell
-
-
-EXTRA_DIST += ftell.c
-
-EXTRA_libgl_la_SOURCES += ftell.c
-
-## end   gnulib module ftell
+## begin gnulib module fstat
 
-## begin gnulib module ftello
 
+EXTRA_DIST += fstat.c
 
-EXTRA_DIST += ftello.c stdio-impl.h
+EXTRA_libgl_la_SOURCES += fstat.c
 
-EXTRA_libgl_la_SOURCES += ftello.c
-
-## end   gnulib module ftello
+## end   gnulib module fstat
 
 ## begin gnulib module gendocs
 
@@ -712,6 +633,24 @@ EXTRA_libgl_la_SOURCES += memchr.c
 
 ## end   gnulib module memchr
 
+## begin gnulib module msvc-inval
+
+
+EXTRA_DIST += msvc-inval.c msvc-inval.h
+
+EXTRA_libgl_la_SOURCES += msvc-inval.c
+
+## end   gnulib module msvc-inval
+
+## begin gnulib module msvc-nothrow
+
+
+EXTRA_DIST += msvc-nothrow.c msvc-nothrow.h
+
+EXTRA_libgl_la_SOURCES += msvc-nothrow.c
+
+## end   gnulib module msvc-nothrow
+
 ## begin gnulib module netdb
 
 BUILT_SOURCES += netdb.h
@@ -889,12 +828,160 @@ EXTRA_libgl_la_SOURCES += shutdown.c
 
 ## end   gnulib module shutdown
 
+## begin gnulib module signal-h
+
+BUILT_SOURCES += signal.h
+
+# We need the following in order to create <signal.h> when the system
+# doesn't have a complete one.
+signal.h: signal.in.h $(top_builddir)/config.status $(CXXDEFS_H) 
$(ARG_NONNULL_H) $(WARN_ON_USE_H)
+       $(AM_V_GEN)rm -f address@hidden $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e 's|@''GUARD_PREFIX''@|GL|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_SIGNAL_H''@|$(NEXT_SIGNAL_H)|g' \
+             -e 's|@''GNULIB_PTHREAD_SIGMASK''@|$(GNULIB_PTHREAD_SIGMASK)|g' \
+             -e 's|@''GNULIB_RAISE''@|$(GNULIB_RAISE)|g' \
+             -e 's/@''GNULIB_SIGNAL_H_SIGPIPE''@/$(GNULIB_SIGNAL_H_SIGPIPE)/g' 
\
+             -e 's/@''GNULIB_SIGPROCMASK''@/$(GNULIB_SIGPROCMASK)/g' \
+             -e 's/@''GNULIB_SIGACTION''@/$(GNULIB_SIGACTION)/g' \
+             -e 
's|@''HAVE_POSIX_SIGNALBLOCKING''@|$(HAVE_POSIX_SIGNALBLOCKING)|g' \
+             -e 's|@''HAVE_PTHREAD_SIGMASK''@|$(HAVE_PTHREAD_SIGMASK)|g' \
+             -e 's|@''HAVE_RAISE''@|$(HAVE_RAISE)|g' \
+             -e 's|@''HAVE_SIGSET_T''@|$(HAVE_SIGSET_T)|g' \
+             -e 's|@''HAVE_SIGINFO_T''@|$(HAVE_SIGINFO_T)|g' \
+             -e 's|@''HAVE_SIGACTION''@|$(HAVE_SIGACTION)|g' \
+             -e 
's|@''HAVE_STRUCT_SIGACTION_SA_SIGACTION''@|$(HAVE_STRUCT_SIGACTION_SA_SIGACTION)|g'
 \
+             -e 
's|@''HAVE_TYPE_VOLATILE_SIG_ATOMIC_T''@|$(HAVE_TYPE_VOLATILE_SIG_ATOMIC_T)|g' \
+             -e 's|@''HAVE_SIGHANDLER_T''@|$(HAVE_SIGHANDLER_T)|g' \
+             -e 's|@''REPLACE_PTHREAD_SIGMASK''@|$(REPLACE_PTHREAD_SIGMASK)|g' 
\
+             -e 's|@''REPLACE_RAISE''@|$(REPLACE_RAISE)|g' \
+             -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+             -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+             -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+             < $(srcdir)/signal.in.h; \
+       } > address@hidden && \
+       mv address@hidden $@
+MOSTLYCLEANFILES += signal.h signal.h-t
+
+EXTRA_DIST += signal.in.h
+
+## end   gnulib module signal-h
+
 ## begin gnulib module size_max
 
 libgl_la_SOURCES += size_max.h
 
 ## end   gnulib module size_max
 
+## begin gnulib module snippet/_Noreturn
+
+# Because this Makefile snippet defines a variable used by other
+# gnulib Makefile snippets, it must be present in all Makefile.am that
+# need it. This is ensured by the applicability 'all' defined above.
+
+_NORETURN_H=$(top_srcdir)/lib/build-aux/snippet/_Noreturn.h
+
+EXTRA_DIST += $(top_srcdir)/lib/build-aux/snippet/_Noreturn.h
+
+## end   gnulib module snippet/_Noreturn
+
+## begin gnulib module snippet/arg-nonnull
+
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+
+BUILT_SOURCES += arg-nonnull.h
+# The arg-nonnull.h that gets inserted into generated .h files is the same as
+# build-aux/snippet/arg-nonnull.h, except that it has the copyright header cut
+# off.
+arg-nonnull.h: $(top_srcdir)/lib/build-aux/snippet/arg-nonnull.h
+       $(AM_V_GEN)rm -f address@hidden $@ && \
+       sed -n -e '/GL_ARG_NONNULL/,$$p' \
+         < $(top_srcdir)/lib/build-aux/snippet/arg-nonnull.h \
+         > address@hidden && \
+       mv address@hidden $@
+MOSTLYCLEANFILES += arg-nonnull.h arg-nonnull.h-t
+
+ARG_NONNULL_H=arg-nonnull.h
+
+EXTRA_DIST += $(top_srcdir)/lib/build-aux/snippet/arg-nonnull.h
+
+## end   gnulib module snippet/arg-nonnull
+
+## begin gnulib module snippet/c++defs
+
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+
+BUILT_SOURCES += c++defs.h
+# The c++defs.h that gets inserted into generated .h files is the same as
+# build-aux/snippet/c++defs.h, except that it has the copyright header cut off.
+c++defs.h: $(top_srcdir)/lib/build-aux/snippet/c++defs.h
+       $(AM_V_GEN)rm -f address@hidden $@ && \
+       sed -n -e '/_GL_CXXDEFS/,$$p' \
+         < $(top_srcdir)/lib/build-aux/snippet/c++defs.h \
+         > address@hidden && \
+       mv address@hidden $@
+MOSTLYCLEANFILES += c++defs.h c++defs.h-t
+
+CXXDEFS_H=c++defs.h
+
+EXTRA_DIST += $(top_srcdir)/lib/build-aux/snippet/c++defs.h
+
+## end   gnulib module snippet/c++defs
+
+## begin gnulib module snippet/unused-parameter
+
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+
+BUILT_SOURCES += unused-parameter.h
+# The unused-parameter.h that gets inserted into generated .h files is the same
+# as build-aux/snippet/unused-parameter.h, except that it has the copyright
+# header cut off.
+unused-parameter.h: $(top_srcdir)/lib/build-aux/snippet/unused-parameter.h
+       $(AM_V_GEN)rm -f address@hidden $@ && \
+       sed -n -e '/GL_UNUSED_PARAMETER/,$$p' \
+         < $(top_srcdir)/lib/build-aux/snippet/unused-parameter.h \
+         > address@hidden && \
+       mv address@hidden $@
+MOSTLYCLEANFILES += unused-parameter.h unused-parameter.h-t
+
+UNUSED_PARAMETER_H=unused-parameter.h
+
+EXTRA_DIST += $(top_srcdir)/lib/build-aux/snippet/unused-parameter.h
+
+## end   gnulib module snippet/unused-parameter
+
+## begin gnulib module snippet/warn-on-use
+
+BUILT_SOURCES += warn-on-use.h
+# The warn-on-use.h that gets inserted into generated .h files is the same as
+# build-aux/snippet/warn-on-use.h, except that it has the copyright header cut
+# off.
+warn-on-use.h: $(top_srcdir)/lib/build-aux/snippet/warn-on-use.h
+       $(AM_V_GEN)rm -f address@hidden $@ && \
+       sed -n -e '/^.ifndef/,$$p' \
+         < $(top_srcdir)/lib/build-aux/snippet/warn-on-use.h \
+         > address@hidden && \
+       mv address@hidden $@
+MOSTLYCLEANFILES += warn-on-use.h warn-on-use.h-t
+
+WARN_ON_USE_H=warn-on-use.h
+
+EXTRA_DIST += $(top_srcdir)/lib/build-aux/snippet/warn-on-use.h
+
+## end   gnulib module snippet/warn-on-use
+
 ## begin gnulib module snprintf
 
 
@@ -921,6 +1008,29 @@ EXTRA_DIST += w32sock.h
 
 ## end   gnulib module sockets
 
+## begin gnulib module stdalign
+
+BUILT_SOURCES += $(STDALIGN_H)
+
+# We need the following in order to create <stdalign.h> when the system
+# doesn't have one that works.
+if GL_GENERATE_STDALIGN_H
+stdalign.h: stdalign.in.h $(top_builddir)/config.status
+       $(AM_V_GEN)rm -f address@hidden $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         cat $(srcdir)/stdalign.in.h; \
+       } > address@hidden && \
+       mv address@hidden $@
+else
+stdalign.h: $(top_builddir)/config.status
+       rm -f $@
+endif
+MOSTLYCLEANFILES += stdalign.h stdalign.h-t
+
+EXTRA_DIST += stdalign.in.h
+
+## end   gnulib module stdalign
+
 ## begin gnulib module stdarg
 
 BUILT_SOURCES += $(STDARG_H)
@@ -1068,6 +1178,7 @@ stdio.h: stdio.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) $(ARG_NONNULL_H)
              -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \
              -e 's/@''GNULIB_DPRINTF''@/$(GNULIB_DPRINTF)/g' \
              -e 's/@''GNULIB_FCLOSE''@/$(GNULIB_FCLOSE)/g' \
+             -e 's/@''GNULIB_FDOPEN''@/$(GNULIB_FDOPEN)/g' \
              -e 's/@''GNULIB_FFLUSH''@/$(GNULIB_FFLUSH)/g' \
              -e 's/@''GNULIB_FGETC''@/$(GNULIB_FGETC)/g' \
              -e 's/@''GNULIB_FGETS''@/$(GNULIB_FGETS)/g' \
@@ -1092,6 +1203,7 @@ stdio.h: stdio.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) $(ARG_NONNULL_H)
              -e 's/@''GNULIB_GETS''@/$(GNULIB_GETS)/g' \
              -e 's/@''GNULIB_OBSTACK_PRINTF''@/$(GNULIB_OBSTACK_PRINTF)/g' \
              -e 
's/@''GNULIB_OBSTACK_PRINTF_POSIX''@/$(GNULIB_OBSTACK_PRINTF_POSIX)/g' \
+             -e 's/@''GNULIB_PCLOSE''@/$(GNULIB_PCLOSE)/g' \
              -e 's/@''GNULIB_PERROR''@/$(GNULIB_PERROR)/g' \
              -e 's/@''GNULIB_POPEN''@/$(GNULIB_POPEN)/g' \
              -e 's/@''GNULIB_PRINTF''@/$(GNULIB_PRINTF)/g' \
@@ -1130,11 +1242,14 @@ stdio.h: stdio.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) $(ARG_NONNULL_H)
              -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \
              -e 's|@''HAVE_FSEEKO''@|$(HAVE_FSEEKO)|g' \
              -e 's|@''HAVE_FTELLO''@|$(HAVE_FTELLO)|g' \
+             -e 's|@''HAVE_PCLOSE''@|$(HAVE_PCLOSE)|g' \
+             -e 's|@''HAVE_POPEN''@|$(HAVE_POPEN)|g' \
              -e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \
              -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \
              -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \
              -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \
              -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \
+             -e 's|@''REPLACE_FDOPEN''@|$(REPLACE_FDOPEN)|g' \
              -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \
              -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \
              -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \
@@ -1182,7 +1297,8 @@ BUILT_SOURCES += stdlib.h
 
 # We need the following in order to create <stdlib.h> when the system
 # doesn't have one that works with the given compiler.
-stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) 
$(ARG_NONNULL_H) $(WARN_ON_USE_H)
+stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
+  $(_NORETURN_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
        $(AM_V_GEN)rm -f address@hidden $@ && \
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
          sed -e 's|@''GUARD_PREFIX''@|GL|g' \
@@ -1204,8 +1320,11 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) $(ARG_NONNULL_H
              -e 's/@''GNULIB_MKOSTEMPS''@/$(GNULIB_MKOSTEMPS)/g' \
              -e 's/@''GNULIB_MKSTEMP''@/$(GNULIB_MKSTEMP)/g' \
              -e 's/@''GNULIB_MKSTEMPS''@/$(GNULIB_MKSTEMPS)/g' \
+             -e 's/@''GNULIB_POSIX_OPENPT''@/$(GNULIB_POSIX_OPENPT)/g' \
              -e 's/@''GNULIB_PTSNAME''@/$(GNULIB_PTSNAME)/g' \
+             -e 's/@''GNULIB_PTSNAME_R''@/$(GNULIB_PTSNAME_R)/g' \
              -e 's/@''GNULIB_PUTENV''@/$(GNULIB_PUTENV)/g' \
+             -e 's/@''GNULIB_RANDOM''@/$(GNULIB_RANDOM)/g' \
              -e 's/@''GNULIB_RANDOM_R''@/$(GNULIB_RANDOM_R)/g' \
              -e 's/@''GNULIB_REALLOC_POSIX''@/$(GNULIB_REALLOC_POSIX)/g' \
              -e 's/@''GNULIB_REALPATH''@/$(GNULIB_REALPATH)/g' \
@@ -1230,7 +1349,10 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) $(ARG_NONNULL_H
              -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \
              -e 's|@''HAVE_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \
              -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \
+             -e 's|@''HAVE_POSIX_OPENPT''@|$(HAVE_POSIX_OPENPT)|g' \
              -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \
+             -e 's|@''HAVE_PTSNAME_R''@|$(HAVE_PTSNAME_R)|g' \
+             -e 's|@''HAVE_RANDOM''@|$(HAVE_RANDOM)|g' \
              -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \
              -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
              -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \
@@ -1248,7 +1370,9 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) $(ARG_NONNULL_H
              -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \
              -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \
              -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
+             -e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \
              -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
+             -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \
              -e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \
              -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
              -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \
@@ -1256,6 +1380,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) $(ARG_NONNULL_H
              -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \
              -e 's|@''REPLACE_WCTOMB''@|$(REPLACE_WCTOMB)|g' \
              -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+             -e '/definition of _Noreturn/r $(_NORETURN_H)' \
              -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
              -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
        } > address@hidden && \
@@ -1323,6 +1448,8 @@ string.h: string.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) $(ARG_NONNULL_H
              -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_FFSL''@/$(GNULIB_FFSL)/g' \
+             -e 's/@''GNULIB_FFSLL''@/$(GNULIB_FFSLL)/g' \
              -e 's/@''GNULIB_MBSLEN''@/$(GNULIB_MBSLEN)/g' \
              -e 's/@''GNULIB_MBSNLEN''@/$(GNULIB_MBSNLEN)/g' \
              -e 's/@''GNULIB_MBSCHR''@/$(GNULIB_MBSCHR)/g' \
@@ -1359,7 +1486,9 @@ string.h: string.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) $(ARG_NONNULL_H
              -e 's/@''GNULIB_STRSIGNAL''@/$(GNULIB_STRSIGNAL)/g' \
              -e 's/@''GNULIB_STRVERSCMP''@/$(GNULIB_STRVERSCMP)/g' \
              < $(srcdir)/string.in.h | \
-         sed -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \
+         sed -e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \
+             -e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \
+             -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \
              -e 's|@''HAVE_MEMCHR''@|$(HAVE_MEMCHR)|g' \
              -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \
              -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \
@@ -1430,8 +1559,11 @@ sys/select.h: sys_select.in.h 
$(top_builddir)/config.status $(CXXDEFS_H) $(WARN_
              -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_SYS_SELECT_H''@|$(NEXT_SYS_SELECT_H)|g' \
              -e 's|@''HAVE_SYS_SELECT_H''@|$(HAVE_SYS_SELECT_H)|g' \
+             -e 's/@''GNULIB_PSELECT''@/$(GNULIB_PSELECT)/g' \
              -e 's/@''GNULIB_SELECT''@/$(GNULIB_SELECT)/g' \
              -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
+             -e 's|@''HAVE_PSELECT''@|$(HAVE_PSELECT)|g' \
+             -e 's|@''REPLACE_PSELECT''@|$(REPLACE_PSELECT)|g' \
              -e 's|@''REPLACE_SELECT''@|$(REPLACE_SELECT)|g' \
              -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
              -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
@@ -1496,6 +1628,67 @@ EXTRA_DIST += sys_socket.in.h
 
 ## end   gnulib module sys_socket
 
+## begin gnulib module sys_stat
+
+BUILT_SOURCES += sys/stat.h
+
+# We need the following in order to create <sys/stat.h> when the system
+# has one that is incomplete.
+sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) 
$(ARG_NONNULL_H) $(WARN_ON_USE_H)
+       $(AM_V_at)$(MKDIR_P) sys
+       $(AM_V_GEN)rm -f address@hidden $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's|@''GUARD_PREFIX''@|GL|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_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
+             -e 's/@''GNULIB_FCHMODAT''@/$(GNULIB_FCHMODAT)/g' \
+             -e 's/@''GNULIB_FSTAT''@/$(GNULIB_FSTAT)/g' \
+             -e 's/@''GNULIB_FSTATAT''@/$(GNULIB_FSTATAT)/g' \
+             -e 's/@''GNULIB_FUTIMENS''@/$(GNULIB_FUTIMENS)/g' \
+             -e 's/@''GNULIB_LCHMOD''@/$(GNULIB_LCHMOD)/g' \
+             -e 's/@''GNULIB_LSTAT''@/$(GNULIB_LSTAT)/g' \
+             -e 's/@''GNULIB_MKDIRAT''@/$(GNULIB_MKDIRAT)/g' \
+             -e 's/@''GNULIB_MKFIFO''@/$(GNULIB_MKFIFO)/g' \
+             -e 's/@''GNULIB_MKFIFOAT''@/$(GNULIB_MKFIFOAT)/g' \
+             -e 's/@''GNULIB_MKNOD''@/$(GNULIB_MKNOD)/g' \
+             -e 's/@''GNULIB_MKNODAT''@/$(GNULIB_MKNODAT)/g' \
+             -e 's/@''GNULIB_STAT''@/$(GNULIB_STAT)/g' \
+             -e 's/@''GNULIB_UTIMENSAT''@/$(GNULIB_UTIMENSAT)/g' \
+             -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \
+             -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \
+             -e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \
+             -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \
+             -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \
+             -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \
+             -e 's|@''HAVE_MKFIFO''@|$(HAVE_MKFIFO)|g' \
+             -e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \
+             -e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \
+             -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \
+             -e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \
+             -e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \
+             -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \
+             -e 's|@''REPLACE_FUTIMENS''@|$(REPLACE_FUTIMENS)|g' \
+             -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \
+             -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \
+             -e 's|@''REPLACE_MKFIFO''@|$(REPLACE_MKFIFO)|g' \
+             -e 's|@''REPLACE_MKNOD''@|$(REPLACE_MKNOD)|g' \
+             -e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \
+             -e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \
+             -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+             -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+             -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+             < $(srcdir)/sys_stat.in.h; \
+       } > address@hidden && \
+       mv address@hidden $@
+MOSTLYCLEANFILES += sys/stat.h sys/stat.h-t
+MOSTLYCLEANDIRS += sys
+
+EXTRA_DIST += sys_stat.in.h
+
+## end   gnulib module sys_stat
+
 ## begin gnulib module sys_time
 
 BUILT_SOURCES += sys/time.h
@@ -1513,9 +1706,11 @@ sys/time.h: sys_time.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) $(ARG_NONNU
              -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_SYS_TIME_H''@|$(NEXT_SYS_TIME_H)|g' \
              -e 's/@''GNULIB_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/g' \
+             -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
              -e 's/@''HAVE_GETTIMEOFDAY''@/$(HAVE_GETTIMEOFDAY)/g' \
              -e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \
              -e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \
+             -e 's/@''REPLACE_STRUCT_TIMEVAL''@/$(REPLACE_STRUCT_TIMEVAL)/g' \
              -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
              -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
              -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
@@ -1528,6 +1723,30 @@ EXTRA_DIST += sys_time.in.h
 
 ## end   gnulib module sys_time
 
+## begin gnulib module sys_types
+
+BUILT_SOURCES += sys/types.h
+
+# We need the following in order to create <sys/types.h> when the system
+# doesn't have one that works with the given compiler.
+sys/types.h: sys_types.in.h $(top_builddir)/config.status
+       $(AM_V_at)$(MKDIR_P) sys
+       $(AM_V_GEN)rm -f address@hidden $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's|@''GUARD_PREFIX''@|GL|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_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \
+             < $(srcdir)/sys_types.in.h; \
+       } > address@hidden && \
+       mv address@hidden $@
+MOSTLYCLEANFILES += sys/types.h sys/types.h-t
+
+EXTRA_DIST += sys_types.in.h
+
+## end   gnulib module sys_types
+
 ## begin gnulib module sys_uio
 
 BUILT_SOURCES += sys/uio.h
@@ -1554,6 +1773,48 @@ EXTRA_DIST += sys_uio.in.h
 
 ## end   gnulib module sys_uio
 
+## begin gnulib module time
+
+BUILT_SOURCES += time.h
+
+# We need the following in order to create <time.h> when the system
+# doesn't have one that works with the given compiler.
+time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) 
$(WARN_ON_USE_H)
+       $(AM_V_GEN)rm -f address@hidden $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e 's|@''GUARD_PREFIX''@|GL|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_TIME_H''@|$(NEXT_TIME_H)|g' \
+             -e 's/@''GNULIB_MKTIME''@/$(GNULIB_MKTIME)/g' \
+             -e 's/@''GNULIB_NANOSLEEP''@/$(GNULIB_NANOSLEEP)/g' \
+             -e 's/@''GNULIB_STRPTIME''@/$(GNULIB_STRPTIME)/g' \
+             -e 's/@''GNULIB_TIMEGM''@/$(GNULIB_TIMEGM)/g' \
+             -e 's/@''GNULIB_TIME_R''@/$(GNULIB_TIME_R)/g' \
+             -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \
+             -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \
+             -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
+             -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
+             -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
+             -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
+             -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
+             -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
+             -e 
's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g'
 \
+             -e 
's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g'
 \
+             -e 
's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
+             -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+             -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+             -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+             < $(srcdir)/time.in.h; \
+       } > address@hidden && \
+       mv address@hidden $@
+MOSTLYCLEANFILES += time.h time.h-t
+
+EXTRA_DIST += time.in.h
+
+## end   gnulib module time
+
 ## begin gnulib module unistd
 
 BUILT_SOURCES += unistd.h
@@ -1569,8 +1830,10 @@ unistd.h: unistd.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) $(ARG_NONNULL_H
              -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_CHDIR''@/$(GNULIB_CHDIR)/g' \
              -e 's/@''GNULIB_CHOWN''@/$(GNULIB_CHOWN)/g' \
              -e 's/@''GNULIB_CLOSE''@/$(GNULIB_CLOSE)/g' \
+             -e 's/@''GNULIB_DUP''@/$(GNULIB_DUP)/g' \
              -e 's/@''GNULIB_DUP2''@/$(GNULIB_DUP2)/g' \
              -e 's/@''GNULIB_DUP3''@/$(GNULIB_DUP3)/g' \
              -e 's/@''GNULIB_ENVIRON''@/$(GNULIB_ENVIRON)/g' \
@@ -1578,6 +1841,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) $(ARG_NONNULL_H
              -e 's/@''GNULIB_FACCESSAT''@/$(GNULIB_FACCESSAT)/g' \
              -e 's/@''GNULIB_FCHDIR''@/$(GNULIB_FCHDIR)/g' \
              -e 's/@''GNULIB_FCHOWNAT''@/$(GNULIB_FCHOWNAT)/g' \
+             -e 's/@''GNULIB_FDATASYNC''@/$(GNULIB_FDATASYNC)/g' \
              -e 's/@''GNULIB_FSYNC''@/$(GNULIB_FSYNC)/g' \
              -e 's/@''GNULIB_FTRUNCATE''@/$(GNULIB_FTRUNCATE)/g' \
              -e 's/@''GNULIB_GETCWD''@/$(GNULIB_GETCWD)/g' \
@@ -1590,6 +1854,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) $(ARG_NONNULL_H
              -e 's/@''GNULIB_GETPAGESIZE''@/$(GNULIB_GETPAGESIZE)/g' \
              -e 's/@''GNULIB_GETUSERSHELL''@/$(GNULIB_GETUSERSHELL)/g' \
              -e 's/@''GNULIB_GROUP_MEMBER''@/$(GNULIB_GROUP_MEMBER)/g' \
+             -e 's/@''GNULIB_ISATTY''@/$(GNULIB_ISATTY)/g' \
              -e 's/@''GNULIB_LCHOWN''@/$(GNULIB_LCHOWN)/g' \
              -e 's/@''GNULIB_LINK''@/$(GNULIB_LINK)/g' \
              -e 's/@''GNULIB_LINKAT''@/$(GNULIB_LINKAT)/g' \
@@ -1602,11 +1867,12 @@ unistd.h: unistd.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) $(ARG_NONNULL_H
              -e 's/@''GNULIB_READLINK''@/$(GNULIB_READLINK)/g' \
              -e 's/@''GNULIB_READLINKAT''@/$(GNULIB_READLINKAT)/g' \
              -e 's/@''GNULIB_RMDIR''@/$(GNULIB_RMDIR)/g' \
+             -e 's/@''GNULIB_SETHOSTNAME''@/$(GNULIB_SETHOSTNAME)/g' \
              -e 's/@''GNULIB_SLEEP''@/$(GNULIB_SLEEP)/g' \
              -e 's/@''GNULIB_SYMLINK''@/$(GNULIB_SYMLINK)/g' \
              -e 's/@''GNULIB_SYMLINKAT''@/$(GNULIB_SYMLINKAT)/g' \
              -e 's/@''GNULIB_TTYNAME_R''@/$(GNULIB_TTYNAME_R)/g' \
-             -e 's/@''GNULIB_UNISTD_H_GETOPT''@/$(GNULIB_UNISTD_H_GETOPT)/g' \
+             -e 
's/@''GNULIB_UNISTD_H_GETOPT''@/0$(GNULIB_GL_UNISTD_H_GETOPT)/g' \
              -e 
's/@''GNULIB_UNISTD_H_NONBLOCKING''@/$(GNULIB_UNISTD_H_NONBLOCKING)/g' \
              -e 's/@''GNULIB_UNISTD_H_SIGPIPE''@/$(GNULIB_UNISTD_H_SIGPIPE)/g' 
\
              -e 's/@''GNULIB_UNLINK''@/$(GNULIB_UNLINK)/g' \
@@ -1621,6 +1887,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) $(ARG_NONNULL_H
              -e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \
              -e 's|@''HAVE_FCHDIR''@|$(HAVE_FCHDIR)|g' \
              -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \
+             -e 's|@''HAVE_FDATASYNC''@|$(HAVE_FDATASYNC)|g' \
              -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \
              -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \
              -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \
@@ -1638,6 +1905,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) $(ARG_NONNULL_H
              -e 's|@''HAVE_PWRITE''@|$(HAVE_PWRITE)|g' \
              -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \
              -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \
+             -e 's|@''HAVE_SETHOSTNAME''@|$(HAVE_SETHOSTNAME)|g' \
              -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \
              -e 's|@''HAVE_SYMLINK''@|$(HAVE_SYMLINK)|g' \
              -e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \
@@ -1645,10 +1913,12 @@ unistd.h: unistd.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) $(ARG_NONNULL_H
              -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \
              -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
              -e 's|@''HAVE_DECL_FCHDIR''@|$(HAVE_DECL_FCHDIR)|g' \
+             -e 's|@''HAVE_DECL_FDATASYNC''@|$(HAVE_DECL_FDATASYNC)|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' \
+             -e 's|@''HAVE_DECL_SETHOSTNAME''@|$(HAVE_DECL_SETHOSTNAME)|g' \
              -e 's|@''HAVE_DECL_TTYNAME_R''@|$(HAVE_DECL_TTYNAME_R)|g' \
              -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \
              -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \
@@ -1663,6 +1933,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) $(ARG_NONNULL_H
              -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \
              -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \
              -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
+             -e 's|@''REPLACE_ISATTY''@|$(REPLACE_ISATTY)|g' \
              -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
              -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \
              -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \
@@ -1740,31 +2011,6 @@ EXTRA_DIST += unitypes.in.h
 
 ## end   gnulib module unitypes
 
-## begin gnulib module unused-parameter
-
-# The BUILT_SOURCES created by this Makefile snippet are not used via #include
-# statements but through direct file reference. Therefore this snippet must be
-# present in all Makefile.am that need it. This is ensured by the applicability
-# 'all' defined above.
-
-BUILT_SOURCES += unused-parameter.h
-# The unused-parameter.h that gets inserted into generated .h files is the same
-# as build-aux/unused-parameter.h, except that it has the copyright header cut
-# off.
-unused-parameter.h: $(top_srcdir)/lib/build-aux/unused-parameter.h
-       $(AM_V_GEN)rm -f address@hidden $@ && \
-       sed -n -e '/GL_UNUSED_PARAMETER/,$$p' \
-         < $(top_srcdir)/lib/build-aux/unused-parameter.h \
-         > address@hidden && \
-       mv address@hidden $@
-MOSTLYCLEANFILES += unused-parameter.h unused-parameter.h-t
-
-UNUSED_PARAMETER_H=unused-parameter.h
-
-EXTRA_DIST += $(top_srcdir)/lib/build-aux/unused-parameter.h
-
-## end   gnulib module unused-parameter
-
 ## begin gnulib module useless-if-before-free
 
 
@@ -1810,25 +2056,6 @@ libgl_la_SOURCES += version-etc.h version-etc.c
 
 ## end   gnulib module version-etc
 
-## begin gnulib module warn-on-use
-
-BUILT_SOURCES += warn-on-use.h
-# The warn-on-use.h that gets inserted into generated .h files is the same as
-# build-aux/warn-on-use.h, except that it has the copyright header cut off.
-warn-on-use.h: $(top_srcdir)/lib/build-aux/warn-on-use.h
-       $(AM_V_GEN)rm -f address@hidden $@ && \
-       sed -n -e '/^.ifndef/,$$p' \
-         < $(top_srcdir)/lib/build-aux/warn-on-use.h \
-         > address@hidden && \
-       mv address@hidden $@
-MOSTLYCLEANFILES += warn-on-use.h warn-on-use.h-t
-
-WARN_ON_USE_H=warn-on-use.h
-
-EXTRA_DIST += $(top_srcdir)/lib/build-aux/warn-on-use.h
-
-## end   gnulib module warn-on-use
-
 ## begin gnulib module wchar
 
 BUILT_SOURCES += wchar.h
@@ -1977,6 +2204,7 @@ wctype.h: wctype.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) $(WARN_ON_USE_H
              -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \
              -e 's/@''REPLACE_ISWBLANK''@/$(REPLACE_ISWBLANK)/g' \
              -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \
+             -e 's/@''REPLACE_TOWLOWER''@/$(REPLACE_TOWLOWER)/g' \
              -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
              -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
              < $(srcdir)/wctype.in.h; \
diff --git a/gl/alignof.h b/gl/alignof.h
deleted file mode 100644
index 1c1f75c..0000000
--- a/gl/alignof.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Determine alignment of types.
-   Copyright (C) 2003-2004, 2006, 2009-2011 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
-   the Free Software Foundation; either version 3, 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 General Public License for more details.
-
-   You should have received a copy of the GNU 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.  */
-
-#ifndef _ALIGNOF_H
-#define _ALIGNOF_H
-
-#include <stddef.h>
-
-/* Determine the alignment of a structure slot (field) of a given type,
-   at compile time.  Note that the result depends on the ABI.
-   Note: The result cannot be used as a value for an 'enum' constant,
-   due to bugs in HP-UX 10.20 cc and AIX 3.2.5 xlc.  */
-#if defined __cplusplus
-  template <class type> struct alignof_helper { char __slot1; type __slot2; };
-# define alignof_slot(type) offsetof (alignof_helper<type>, __slot2)
-#else
-# define alignof_slot(type) offsetof (struct { char __slot1; type __slot2; }, 
__slot2)
-#endif
-
-/* Determine the good alignment of an object of the given type at compile time.
-   Note that this is not necessarily the same as alignof_slot(type).
-   For example, with GNU C on x86 platforms: alignof_type(double) = 8, but
-   - when -malign-double is not specified:  alignof_slot(double) = 4,
-   - when -malign-double is specified:      alignof_slot(double) = 8.
-   Note: The result cannot be used as a value for an 'enum' constant,
-   due to bugs in HP-UX 10.20 cc and AIX 3.2.5 xlc.  */
-#if defined __GNUC__
-# define alignof_type __alignof__
-#else
-# define alignof_type alignof_slot
-#endif
-
-/* alignof is an alias for alignof_slot semantics, since that's what most
-   callers need.
-   Note: The result cannot be used as a value for an 'enum' constant,
-   due to bugs in HP-UX 10.20 cc and AIX 3.2.5 xlc.  */
-#define alignof alignof_slot
-
-#endif /* _ALIGNOF_H */
diff --git a/gl/alloca.c b/gl/alloca.c
index 06b12a7..ee0f018 100644
--- a/gl/alloca.c
+++ b/gl/alloca.c
@@ -475,4 +475,4 @@ i00afunc (long address)
 #  endif /* CRAY */
 
 # endif /* no alloca */
-#endif /* not GCC version 3 */
+#endif /* not GCC 2 */
diff --git a/gl/alloca.in.h b/gl/alloca.in.h
index 5b69c6c..ca9e7fe 100644
--- a/gl/alloca.in.h
+++ b/gl/alloca.in.h
@@ -1,6 +1,6 @@
 /* Memory allocation on the stack.
 
-   Copyright (C) 1995, 1999, 2001-2004, 2006-2011 Free Software Foundation,
+   Copyright (C) 1995, 1999, 2001-2004, 2006-2012 Free Software Foundation,
    Inc.
 
    This program is free software; you can redistribute it and/or modify it
diff --git a/gl/arpa_inet.in.h b/gl/arpa_inet.in.h
index 4dde1dc..91b1008 100644
--- a/gl/arpa_inet.in.h
+++ b/gl/arpa_inet.in.h
@@ -1,6 +1,6 @@
 /* A GNU-like <arpa/inet.h>.
 
-   Copyright (C) 2005-2006, 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2005-2006, 2008-2012 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
@@ -58,7 +58,6 @@
 
 
 #if @GNULIB_INET_NTOP@
-# if address@hidden@
 /* Converts an internet address from internal format to a printable,
    presentable format.
    AF is an internet address family, such as AF_INET or AF_INET6.
@@ -74,16 +73,31 @@
 
    For more details, see the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/inet_ntop.html>.  */
+# if @REPLACE_INET_NTOP@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef inet_ntop
+#   define inet_ntop rpl_inet_ntop
+#  endif
+_GL_FUNCDECL_RPL (inet_ntop, const char *,
+                  (int af, const void *restrict src,
+                   char *restrict dst, socklen_t cnt)
+                  _GL_ARG_NONNULL ((2, 3)));
+_GL_CXXALIAS_RPL (inet_ntop, const char *,
+                  (int af, const void *restrict src,
+                   char *restrict dst, socklen_t cnt));
+# else
+#  if address@hidden@
 _GL_FUNCDECL_SYS (inet_ntop, const char *,
                   (int af, const void *restrict src,
                    char *restrict dst, socklen_t cnt)
                   _GL_ARG_NONNULL ((2, 3)));
-# endif
+#  endif
 /* Need to cast, because on NonStop Kernel, the fourth parameter is
                                             size_t cnt.  */
 _GL_CXXALIAS_SYS_CAST (inet_ntop, const char *,
                        (int af, const void *restrict src,
                         char *restrict dst, socklen_t cnt));
+# endif
 _GL_CXXALIASWARN (inet_ntop);
 #elif defined GNULIB_POSIXCHECK
 # undef inet_ntop
@@ -94,13 +108,25 @@ _GL_WARN_ON_USE (inet_ntop, "inet_ntop is unportable - "
 #endif
 
 #if @GNULIB_INET_PTON@
-# if address@hidden@
+# if @REPLACE_INET_PTON@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef inet_pton
+#   define inet_pton rpl_inet_pton
+#  endif
+_GL_FUNCDECL_RPL (inet_pton, int,
+                  (int af, const char *restrict src, void *restrict dst)
+                  _GL_ARG_NONNULL ((2, 3)));
+_GL_CXXALIAS_RPL (inet_pton, int,
+                  (int af, const char *restrict src, void *restrict dst));
+# else
+#  if address@hidden@
 _GL_FUNCDECL_SYS (inet_pton, int,
                   (int af, const char *restrict src, void *restrict dst)
                   _GL_ARG_NONNULL ((2, 3)));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (inet_pton, int,
                   (int af, const char *restrict src, void *restrict dst));
+# endif
 _GL_CXXALIASWARN (inet_pton);
 #elif defined GNULIB_POSIXCHECK
 # undef inet_pton
diff --git a/gl/asnprintf.c b/gl/asnprintf.c
index e4fd95c..416a586 100644
--- a/gl/asnprintf.c
+++ b/gl/asnprintf.c
@@ -1,5 +1,5 @@
 /* Formatted output to strings.
-   Copyright (C) 1999, 2002, 2006, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2002, 2006, 2009-2012 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
diff --git a/gl/asprintf.c b/gl/asprintf.c
index 2f13126..b8b405f 100644
--- a/gl/asprintf.c
+++ b/gl/asprintf.c
@@ -1,5 +1,5 @@
 /* Formatted output to strings.
-   Copyright (C) 1999, 2002, 2006-2007, 2009-2011 Free Software Foundation,
+   Copyright (C) 1999, 2002, 2006-2007, 2009-2012 Free Software Foundation,
    Inc.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/gl/c-ctype.c b/gl/c-ctype.c
index 0fb4295..6ca7992 100644
--- a/gl/c-ctype.c
+++ b/gl/c-ctype.c
@@ -1,6 +1,6 @@
 /* Character handling in C locale.
 
-   Copyright 2000-2003, 2006, 2009-2011 Free Software Foundation, Inc.
+   Copyright 2000-2003, 2006, 2009-2012 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
diff --git a/gl/c-ctype.h b/gl/c-ctype.h
index 57e71ee..a857748 100644
--- a/gl/c-ctype.h
+++ b/gl/c-ctype.h
@@ -5,7 +5,7 @@
    <ctype.h> functions' behaviour depends on the current locale set via
    setlocale.
 
-   Copyright (C) 2000-2003, 2006, 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2000-2003, 2006, 2008-2012 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
@@ -118,23 +118,23 @@ extern "C" {
          if (c_isalpha (*s)) ...
  */
 
-extern bool c_isascii (int c); /* not locale dependent */
-
-extern bool c_isalnum (int c);
-extern bool c_isalpha (int c);
-extern bool c_isblank (int c);
-extern bool c_iscntrl (int c);
-extern bool c_isdigit (int c);
-extern bool c_islower (int c);
-extern bool c_isgraph (int c);
-extern bool c_isprint (int c);
-extern bool c_ispunct (int c);
-extern bool c_isspace (int c);
-extern bool c_isupper (int c);
-extern bool c_isxdigit (int c);
-
-extern int c_tolower (int c);
-extern int c_toupper (int c);
+extern bool c_isascii (int c) _GL_ATTRIBUTE_CONST; /* not locale dependent */
+
+extern bool c_isalnum (int c) _GL_ATTRIBUTE_CONST;
+extern bool c_isalpha (int c) _GL_ATTRIBUTE_CONST;
+extern bool c_isblank (int c) _GL_ATTRIBUTE_CONST;
+extern bool c_iscntrl (int c) _GL_ATTRIBUTE_CONST;
+extern bool c_isdigit (int c) _GL_ATTRIBUTE_CONST;
+extern bool c_islower (int c) _GL_ATTRIBUTE_CONST;
+extern bool c_isgraph (int c) _GL_ATTRIBUTE_CONST;
+extern bool c_isprint (int c) _GL_ATTRIBUTE_CONST;
+extern bool c_ispunct (int c) _GL_ATTRIBUTE_CONST;
+extern bool c_isspace (int c) _GL_ATTRIBUTE_CONST;
+extern bool c_isupper (int c) _GL_ATTRIBUTE_CONST;
+extern bool c_isxdigit (int c) _GL_ATTRIBUTE_CONST;
+
+extern int c_tolower (int c) _GL_ATTRIBUTE_CONST;
+extern int c_toupper (int c) _GL_ATTRIBUTE_CONST;
 
 
 #if defined __GNUC__ && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ && 
!defined NO_C_CTYPE_MACROS
diff --git a/gl/c-strcase.h b/gl/c-strcase.h
index 4148c34..8854833 100644
--- a/gl/c-strcase.h
+++ b/gl/c-strcase.h
@@ -1,5 +1,5 @@
 /* Case-insensitive string comparison functions in C locale.
-   Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2011 Free Software
+   Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2012 Free Software
    Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
@@ -40,12 +40,13 @@ extern "C" {
 /* Compare strings S1 and S2, ignoring case, returning less than, equal to or
    greater than zero if S1 is lexicographically less than, equal to or greater
    than S2.  */
-extern int c_strcasecmp (const char *s1, const char *s2);
+extern int c_strcasecmp (const char *s1, const char *s2) _GL_ATTRIBUTE_PURE;
 
 /* Compare no more than N characters of strings S1 and S2, ignoring case,
    returning less than, equal to or greater than zero if S1 is
    lexicographically less than, equal to or greater than S2.  */
-extern int c_strncasecmp (const char *s1, const char *s2, size_t n);
+extern int c_strncasecmp (const char *s1, const char *s2, size_t n)
+  _GL_ATTRIBUTE_PURE;
 
 
 #ifdef __cplusplus
diff --git a/gl/c-strcasecmp.c b/gl/c-strcasecmp.c
index 4c4e106..7f117ec 100644
--- a/gl/c-strcasecmp.c
+++ b/gl/c-strcasecmp.c
@@ -1,5 +1,5 @@
 /* c-strcasecmp.c -- case insensitive string comparator in C locale
-   Copyright (C) 1998-1999, 2005-2006, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 1998-1999, 2005-2006, 2009-2012 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
diff --git a/gl/c-strcaseeq.h b/gl/c-strcaseeq.h
new file mode 100644
index 0000000..5c4bdff
--- /dev/null
+++ b/gl/c-strcaseeq.h
@@ -0,0 +1,184 @@
+/* Optimized case-insensitive string comparison in C locale.
+   Copyright (C) 2001-2002, 2007, 2009-2012 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 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
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <address@hidden>.  */
+
+#include "c-strcase.h"
+#include "c-ctype.h"
+
+/* STRCASEEQ allows to optimize string comparison with a small literal string.
+     STRCASEEQ (s, "UTF-8", 'U','T','F','-','8',0,0,0,0)
+   is semantically equivalent to
+     c_strcasecmp (s, "UTF-8") == 0
+   just faster.  */
+
+/* Help GCC to generate good code for string comparisons with
+   immediate strings. */
+#if defined (__GNUC__) && defined (__OPTIMIZE__)
+
+/* Case insensitive comparison of ASCII characters.  */
+# if C_CTYPE_ASCII
+#  define CASEEQ(other,upper) \
+     (c_isupper (upper) ? ((other) & ~0x20) == (upper) : (other) == (upper))
+# elif C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
+#  define CASEEQ(other,upper) \
+     (c_isupper (upper) ? (other) == (upper) || (other) == (upper) - 'A' + 'a' 
: (other) == (upper))
+# else
+#  define CASEEQ(other,upper) \
+     (c_toupper (other) == (upper))
+# endif
+
+static inline int
+strcaseeq9 (const char *s1, const char *s2)
+{
+  return c_strcasecmp (s1 + 9, s2 + 9) == 0;
+}
+
+static inline int
+strcaseeq8 (const char *s1, const char *s2, char s28)
+{
+  if (CASEEQ (s1[8], s28))
+    {
+      if (s28 == 0)
+        return 1;
+      else
+        return strcaseeq9 (s1, s2);
+    }
+  else
+    return 0;
+}
+
+static inline int
+strcaseeq7 (const char *s1, const char *s2, char s27, char s28)
+{
+  if (CASEEQ (s1[7], s27))
+    {
+      if (s27 == 0)
+        return 1;
+      else
+        return strcaseeq8 (s1, s2, s28);
+    }
+  else
+    return 0;
+}
+
+static inline int
+strcaseeq6 (const char *s1, const char *s2, char s26, char s27, char s28)
+{
+  if (CASEEQ (s1[6], s26))
+    {
+      if (s26 == 0)
+        return 1;
+      else
+        return strcaseeq7 (s1, s2, s27, s28);
+    }
+  else
+    return 0;
+}
+
+static inline int
+strcaseeq5 (const char *s1, const char *s2, char s25, char s26, char s27, char 
s28)
+{
+  if (CASEEQ (s1[5], s25))
+    {
+      if (s25 == 0)
+        return 1;
+      else
+        return strcaseeq6 (s1, s2, s26, s27, s28);
+    }
+  else
+    return 0;
+}
+
+static inline int
+strcaseeq4 (const char *s1, const char *s2, char s24, char s25, char s26, char 
s27, char s28)
+{
+  if (CASEEQ (s1[4], s24))
+    {
+      if (s24 == 0)
+        return 1;
+      else
+        return strcaseeq5 (s1, s2, s25, s26, s27, s28);
+    }
+  else
+    return 0;
+}
+
+static inline int
+strcaseeq3 (const char *s1, const char *s2, char s23, char s24, char s25, char 
s26, char s27, char s28)
+{
+  if (CASEEQ (s1[3], s23))
+    {
+      if (s23 == 0)
+        return 1;
+      else
+        return strcaseeq4 (s1, s2, s24, s25, s26, s27, s28);
+    }
+  else
+    return 0;
+}
+
+static inline int
+strcaseeq2 (const char *s1, const char *s2, char s22, char s23, char s24, char 
s25, char s26, char s27, char s28)
+{
+  if (CASEEQ (s1[2], s22))
+    {
+      if (s22 == 0)
+        return 1;
+      else
+        return strcaseeq3 (s1, s2, s23, s24, s25, s26, s27, s28);
+    }
+  else
+    return 0;
+}
+
+static inline int
+strcaseeq1 (const char *s1, const char *s2, char s21, char s22, char s23, char 
s24, char s25, char s26, char s27, char s28)
+{
+  if (CASEEQ (s1[1], s21))
+    {
+      if (s21 == 0)
+        return 1;
+      else
+        return strcaseeq2 (s1, s2, s22, s23, s24, s25, s26, s27, s28);
+    }
+  else
+    return 0;
+}
+
+static inline int
+strcaseeq0 (const char *s1, const char *s2, char s20, char s21, char s22, char 
s23, char s24, char s25, char s26, char s27, char s28)
+{
+  if (CASEEQ (s1[0], s20))
+    {
+      if (s20 == 0)
+        return 1;
+      else
+        return strcaseeq1 (s1, s2, s21, s22, s23, s24, s25, s26, s27, s28);
+    }
+  else
+    return 0;
+}
+
+#define STRCASEEQ(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \
+  strcaseeq0 (s1, s2, s20, s21, s22, s23, s24, s25, s26, s27, s28)
+
+#else
+
+#define STRCASEEQ(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \
+  (c_strcasecmp (s1, s2) == 0)
+
+#endif
diff --git a/gl/c-strncasecmp.c b/gl/c-strncasecmp.c
index 0c433b9..3717aed 100644
--- a/gl/c-strncasecmp.c
+++ b/gl/c-strncasecmp.c
@@ -1,5 +1,5 @@
 /* c-strncasecmp.c -- case insensitive string comparator in C locale
-   Copyright (C) 1998-1999, 2005-2006, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 1998-1999, 2005-2006, 2009-2012 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
diff --git a/gl/close.c b/gl/close.c
index 2c41c75..4b7accb 100644
--- a/gl/close.c
+++ b/gl/close.c
@@ -1,5 +1,5 @@
 /* close replacement.
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
@@ -19,18 +19,45 @@
 /* Specification.  */
 #include <unistd.h>
 
+#include <errno.h>
+
 #include "fd-hook.h"
+#include "msvc-inval.h"
+
+#undef close
+
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+static int
+close_nothrow (int fd)
+{
+  int result;
+
+  TRY_MSVC_INVAL
+    {
+      result = close (fd);
+    }
+  CATCH_MSVC_INVAL
+    {
+      result = -1;
+      errno = EBADF;
+    }
+  DONE_MSVC_INVAL;
+
+  return result;
+}
+#else
+# define close_nothrow close
+#endif
 
 /* Override close() to call into other gnulib modules.  */
 
 int
 rpl_close (int fd)
-#undef close
 {
 #if WINDOWS_SOCKETS
-  int retval = execute_all_close_hooks (close, fd);
+  int retval = execute_all_close_hooks (close_nothrow, fd);
 #else
-  int retval = close (fd);
+  int retval = close_nothrow (fd);
 #endif
 
 #if REPLACE_FCHDIR
diff --git a/gl/config.charset b/gl/config.charset
index 93b5a5d..1383d9b 100644
--- a/gl/config.charset
+++ b/gl/config.charset
@@ -1,7 +1,7 @@
 #! /bin/sh
 # Output a system dependent table of character encoding aliases.
 #
-#   Copyright (C) 2000-2004, 2006-2011 Free Software Foundation, Inc.
+#   Copyright (C) 2000-2004, 2006-2012 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
@@ -30,6 +30,8 @@
 # The current list of GNU canonical charset names is as follows.
 #
 #       name              MIME?             used by which systems
+#                                    (darwin = MacOS X, woe32 = native Windows)
+#
 #   ASCII, ANSI_X3.4-1968       glibc solaris freebsd netbsd darwin cygwin
 #   ISO-8859-1              Y   glibc aix hpux irix osf solaris freebsd netbsd 
openbsd darwin cygwin
 #   ISO-8859-2              Y   glibc aix hpux irix osf solaris freebsd netbsd 
openbsd darwin cygwin
diff --git a/gl/connect.c b/gl/connect.c
index ea03e77..939b399 100644
--- a/gl/connect.c
+++ b/gl/connect.c
@@ -1,6 +1,6 @@
 /* connect.c --- wrappers for Windows connect function
 
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
@@ -32,16 +32,25 @@ int
 rpl_connect (int fd, const struct sockaddr *sockaddr, socklen_t len)
 {
   SOCKET sock = FD_TO_SOCKET (fd);
-  int r = connect (sock, sockaddr, len);
-  if (r < 0)
-    {
-      /* EINPROGRESS is not returned by WinSock 2.0; for backwards
-         compatibility, connect(2) uses EWOULDBLOCK.  */
-      if (WSAGetLastError () == WSAEWOULDBLOCK)
-        WSASetLastError (WSAEINPROGRESS);
 
-      set_winsock_errno ();
+  if (sock == INVALID_SOCKET)
+    {
+      errno = EBADF;
+      return -1;
+    }
+  else
+    {
+      int r = connect (sock, sockaddr, len);
+      if (r < 0)
+        {
+          /* EINPROGRESS is not returned by WinSock 2.0; for backwards
+             compatibility, connect(2) uses EWOULDBLOCK.  */
+          if (WSAGetLastError () == WSAEWOULDBLOCK)
+            WSASetLastError (WSAEINPROGRESS);
+
+          set_winsock_errno ();
+        }
+
+      return r;
     }
-
-  return r;
 }
diff --git a/gl/errno.in.h b/gl/errno.in.h
index a63b92a..5271bcd 100644
--- a/gl/errno.in.h
+++ b/gl/errno.in.h
@@ -1,6 +1,6 @@
 /* A POSIX-like <errno.h>.
 
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
@@ -33,50 +33,106 @@
 /* On native Windows platforms, many macros are not defined.  */
 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
 
-/* POSIX says that EAGAIN and EWOULDBLOCK may have the same value.  */
-#  define EWOULDBLOCK     EAGAIN
-
-/* Values >= 100 seem safe to use.  */
-#  define ETXTBSY   100
-#  define GNULIB_defined_ETXTBSY 1
+/* These are the same values as defined by MSVC 10, for interoperability.  */
+
+#  ifndef ENOMSG
+#   define ENOMSG    122
+#   define GNULIB_defined_ENOMSG 1
+#  endif
+
+#  ifndef EIDRM
+#   define EIDRM     111
+#   define GNULIB_defined_EIDRM 1
+#  endif
+
+#  ifndef ENOLINK
+#   define ENOLINK   121
+#   define GNULIB_defined_ENOLINK 1
+#  endif
+
+#  ifndef EPROTO
+#   define EPROTO    134
+#   define GNULIB_defined_EPROTO 1
+#  endif
+
+#  ifndef EBADMSG
+#   define EBADMSG   104
+#   define GNULIB_defined_EBADMSG 1
+#  endif
+
+#  ifndef EOVERFLOW
+#   define EOVERFLOW 132
+#   define GNULIB_defined_EOVERFLOW 1
+#  endif
+
+#  ifndef ENOTSUP
+#   define ENOTSUP   129
+#   define GNULIB_defined_ENOTSUP 1
+#  endif
+
+#  ifndef ENETRESET
+#   define ENETRESET 117
+#   define GNULIB_defined_ENETRESET 1
+#  endif
+
+#  ifndef ECONNABORTED
+#   define ECONNABORTED 106
+#   define GNULIB_defined_ECONNABORTED 1
+#  endif
+
+#  ifndef ECANCELED
+#   define ECANCELED 105
+#   define GNULIB_defined_ECANCELED 1
+#  endif
+
+#  ifndef EINPROGRESS
+#   define EINPROGRESS     112
+#   define EALREADY        103
+#   define ENOTSOCK        128
+#   define EDESTADDRREQ    109
+#   define EMSGSIZE        115
+#   define EPROTOTYPE      136
+#   define ENOPROTOOPT     123
+#   define EPROTONOSUPPORT 135
+#   define EOPNOTSUPP      130
+#   define EAFNOSUPPORT    102
+#   define EADDRINUSE      100
+#   define EADDRNOTAVAIL   101
+#   define ENETDOWN        116
+#   define ENETUNREACH     118
+#   define ECONNRESET      108
+#   define ENOBUFS         119
+#   define EISCONN         113
+#   define ENOTCONN        126
+#   define ETIMEDOUT       138
+#   define ECONNREFUSED    107
+#   define ELOOP           114
+#   define EHOSTUNREACH    110
+#   define EWOULDBLOCK     140
+#   define ETXTBSY         139
+#   define ENODATA         120  /* not required by POSIX */
+#   define ENOSR           124  /* not required by POSIX */
+#   define ENOSTR          125  /* not required by POSIX */
+#   define ENOTRECOVERABLE 127  /* not required by POSIX */
+#   define EOWNERDEAD      133  /* not required by POSIX */
+#   define ETIME           137  /* not required by POSIX */
+#   define EOTHER          131  /* not required by POSIX */
+#   define GNULIB_defined_ESOCK 1
+#  endif
 
 /* These are intentionally the same values as the WSA* error numbers, defined
    in <winsock2.h>.  */
-#  define EINPROGRESS     10036
-#  define EALREADY        10037
-#  define ENOTSOCK        10038
-#  define EDESTADDRREQ    10039
-#  define EMSGSIZE        10040
-#  define EPROTOTYPE      10041
-#  define ENOPROTOOPT     10042
-#  define EPROTONOSUPPORT 10043
 #  define ESOCKTNOSUPPORT 10044  /* not required by POSIX */
-#  define EOPNOTSUPP      10045
 #  define EPFNOSUPPORT    10046  /* not required by POSIX */
-#  define EAFNOSUPPORT    10047
-#  define EADDRINUSE      10048
-#  define EADDRNOTAVAIL   10049
-#  define ENETDOWN        10050
-#  define ENETUNREACH     10051
-#  define ENETRESET       10052
-#  define ECONNABORTED    10053
-#  define ECONNRESET      10054
-#  define ENOBUFS         10055
-#  define EISCONN         10056
-#  define ENOTCONN        10057
 #  define ESHUTDOWN       10058  /* not required by POSIX */
 #  define ETOOMANYREFS    10059  /* not required by POSIX */
-#  define ETIMEDOUT       10060
-#  define ECONNREFUSED    10061
-#  define ELOOP           10062
 #  define EHOSTDOWN       10064  /* not required by POSIX */
-#  define EHOSTUNREACH    10065
 #  define EPROCLIM        10067  /* not required by POSIX */
 #  define EUSERS          10068  /* not required by POSIX */
 #  define EDQUOT          10069
 #  define ESTALE          10070
 #  define EREMOTE         10071  /* not required by POSIX */
-#  define GNULIB_defined_ESOCK 1
+#  define GNULIB_defined_EWINSOCK 1
 
 # endif
 
@@ -147,6 +203,16 @@
 #  define GNULIB_defined_ENOTSUP 1
 # endif
 
+# ifndef ENETRESET
+#  define ENETRESET 2011
+#  define GNULIB_defined_ENETRESET 1
+# endif
+
+# ifndef ECONNABORTED
+#  define ECONNABORTED 2012
+#  define GNULIB_defined_ECONNABORTED 1
+# endif
+
 # ifndef ESTALE
 #  define ESTALE    2009
 #  define GNULIB_defined_ESTALE 1
diff --git a/gl/error.c b/gl/error.c
index 7482baa..dc8c65f 100644
--- a/gl/error.c
+++ b/gl/error.c
@@ -1,5 +1,5 @@
 /* Error handler for noninteractive utilities
-   Copyright (C) 1990-1998, 2000-2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 1990-1998, 2000-2007, 2009-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    This program is free software: you can redistribute it and/or modify
@@ -54,7 +54,7 @@
    function without parameters instead.  */
 void (*error_print_progname) (void);
 
-/* This variable is incremented each time `error' is called.  */
+/* This variable is incremented each time 'error' is called.  */
 unsigned int error_message_count;
 
 #ifdef _LIBC
@@ -65,7 +65,7 @@ unsigned int error_message_count;
 # include <limits.h>
 # include <libio/libioP.h>
 
-/* In GNU libc we want do not want to use the common name `error' directly.
+/* In GNU libc we want do not want to use the common name 'error' directly.
    Instead make it a weak alias.  */
 extern void __error (int status, int errnum, const char *message, ...)
      __attribute__ ((__format__ (__printf__, 3, 4)));
@@ -89,9 +89,11 @@ extern void __error_at_line (int status, int errnum, const 
char *file_name,
 # include <unistd.h>
 
 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-/* Get declarations of the Win32 API functions.  */
+/* Get declarations of the native Windows API functions.  */
 #  define WIN32_LEAN_AND_MEAN
 #  include <windows.h>
+/* Get _get_osfhandle.  */
+#  include "msvc-nothrow.h"
 # endif
 
 /* The gnulib override of fcntl is not needed in this file.  */
@@ -123,9 +125,10 @@ static inline int
 is_open (int fd)
 {
 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-  /* On Win32: The initial state of unassigned standard file descriptors is
-     that they are open but point to an INVALID_HANDLE_VALUE.  There is no
-     fcntl, and the gnulib replacement fcntl does not support F_GETFL.  */
+  /* On native Windows: The initial state of unassigned standard file
+     descriptors is that they are open but point to an INVALID_HANDLE_VALUE.
+     There is no fcntl, and the gnulib replacement fcntl does not support
+     F_GETFL.  */
   return (HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE;
 # else
 #  ifndef F_GETFL
diff --git a/gl/error.h b/gl/error.h
index 80f81bc..9c2cb8b 100644
--- a/gl/error.h
+++ b/gl/error.h
@@ -1,5 +1,5 @@
 /* Declaration for error-reporting function
-   Copyright (C) 1995-1997, 2003, 2006, 2008-2011 Free Software Foundation,
+   Copyright (C) 1995-1997, 2003, 2006, 2008-2012 Free Software Foundation,
    Inc.
    This file is part of the GNU C Library.
 
@@ -35,9 +35,9 @@
 extern "C" {
 #endif
 
-/* Print a message with `fprintf (stderr, FORMAT, ...)';
+/* Print a message with 'fprintf (stderr, FORMAT, ...)';
    if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
-   If STATUS is nonzero, terminate the program with `exit (STATUS)'.  */
+   If STATUS is nonzero, terminate the program with 'exit (STATUS)'.  */
 
 extern void error (int __status, int __errnum, const char *__format, ...)
      _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 4));
@@ -51,7 +51,7 @@ extern void error_at_line (int __status, int __errnum, const 
char *__fname,
    function without parameters instead.  */
 extern void (*error_print_progname) (void);
 
-/* This variable is incremented each time `error' is called.  */
+/* This variable is incremented each time 'error' is called.  */
 extern unsigned int error_message_count;
 
 /* Sometimes we want to have at most one error per line.  This
diff --git a/gl/exitfail.c b/gl/exitfail.c
index 953aa02..fdd674c 100644
--- a/gl/exitfail.c
+++ b/gl/exitfail.c
@@ -1,6 +1,6 @@
 /* Failure exit status
 
-   Copyright (C) 2002-2003, 2005-2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2005-2007, 2009-2012 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
diff --git a/gl/exitfail.h b/gl/exitfail.h
index 6d01d4f..074f212 100644
--- a/gl/exitfail.h
+++ b/gl/exitfail.h
@@ -1,6 +1,6 @@
 /* Failure exit status
 
-   Copyright (C) 2002, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2009-2012 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
diff --git a/gl/fclose.c b/gl/fclose.c
deleted file mode 100644
index 27f6836..0000000
--- a/gl/fclose.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/* fclose replacement.
-   Copyright (C) 2008-2011 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
-   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 General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#include <config.h>
-
-/* Specification.  */
-#include <stdio.h>
-
-#include <errno.h>
-#include <unistd.h>
-
-#include "freading.h"
-
-/* Override fclose() to call the overridden fflush() or close().  */
-
-int
-rpl_fclose (FILE *fp)
-#undef fclose
-{
-  int saved_errno = 0;
-  int fd;
-  int result = 0;
-
-  /* Don't change behavior on memstreams.  */
-  fd = fileno (fp);
-  if (fd < 0)
-    return fclose (fp);
-
-  /* We only need to flush the file if it is not reading or if it is
-     seekable.  This only guarantees the file position of input files
-     if the fflush module is also in use.  */
-  if ((!freading (fp) || lseek (fileno (fp), 0, SEEK_CUR) != -1)
-      && fflush (fp))
-    saved_errno = errno;
-
-  /* fclose() calls close(), but we need to also invoke all hooks that our
-     overridden close() function invokes.  See lib/close.c.  */
-#if WINDOWS_SOCKETS
-  /* Call the overridden close(), then the original fclose().
-     Note about multithread-safety: There is a race condition where some
-     other thread could open fd between our close and fclose.  */
-  if (close (fd) < 0 && saved_errno == 0)
-    saved_errno = errno;
-
-  fclose (fp); /* will fail with errno = EBADF, if we did not lose a race */
-
-#else /* !WINDOWS_SOCKETS */
-  /* Call fclose() and invoke all hooks of the overridden close().  */
-
-# if REPLACE_FCHDIR
-  /* Note about multithread-safety: There is a race condition here as well.
-     Some other thread could open fd between our calls to fclose and
-     _gl_unregister_fd.  */
-  result = fclose (fp);
-  if (result == 0)
-    _gl_unregister_fd (fd);
-# else
-  /* No race condition here.  */
-  result = fclose (fp);
-# endif
-
-#endif /* !WINDOWS_SOCKETS */
-
-  if (saved_errno != 0)
-    {
-      errno = saved_errno;
-      result = EOF;
-    }
-
-  return result;
-}
diff --git a/gl/fd-hook.c b/gl/fd-hook.c
index b58300d..8f4ffe2 100644
--- a/gl/fd-hook.c
+++ b/gl/fd-hook.c
@@ -1,5 +1,5 @@
 /* Hook for making making file descriptor functions close(), ioctl() 
extensible.
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2009.
 
    This program is free software: you can redistribute it and/or modify it
diff --git a/gl/fd-hook.h b/gl/fd-hook.h
index ada4c87..721e9ad 100644
--- a/gl/fd-hook.h
+++ b/gl/fd-hook.h
@@ -1,5 +1,5 @@
 /* Hook for making making file descriptor functions close(), ioctl() 
extensible.
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 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
diff --git a/gl/fflush.c b/gl/fflush.c
deleted file mode 100644
index 437e310..0000000
--- a/gl/fflush.c
+++ /dev/null
@@ -1,218 +0,0 @@
-/* fflush.c -- allow flushing input streams
-   Copyright (C) 2007-2011 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
-   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 General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-/* Written by Eric Blake. */
-
-#include <config.h>
-
-/* Specification.  */
-#include <stdio.h>
-
-#include <errno.h>
-#include <unistd.h>
-
-#include "freading.h"
-
-#include "stdio-impl.h"
-
-#undef fflush
-
-
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, 
Linux libc5 */
-
-/* Clear the stream's ungetc buffer, preserving the value of ftello (fp).  */
-static inline void
-clear_ungetc_buffer_preserving_position (FILE *fp)
-{
-  if (fp->_flags & _IO_IN_BACKUP)
-    /* _IO_free_backup_area is a bit complicated.  Simply call fseek.  */
-    fseeko (fp, 0, SEEK_CUR);
-}
-
-#else
-
-/* Clear the stream's ungetc buffer.  May modify the value of ftello (fp).  */
-static inline void
-clear_ungetc_buffer (FILE *fp)
-{
-# if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, 
DragonFly, MacOS X, Cygwin */
-  if (HASUB (fp))
-    {
-      fp_->_p += fp_->_r;
-      fp_->_r = 0;
-    }
-# elif defined __EMX__              /* emx+gcc */
-  if (fp->_ungetc_count > 0)
-    {
-      fp->_ungetc_count = 0;
-      fp->_rcount = - fp->_rcount;
-    }
-# elif defined _IOERR               /* AIX, HP-UX, IRIX, OSF/1, Solaris, 
OpenServer, mingw, NonStop Kernel */
-  /* Nothing to do.  */
-# else                              /* other implementations */
-  fseeko (fp, 0, SEEK_CUR);
-# endif
-}
-
-#endif
-
-#if (defined __sferror || defined __DragonFly__) && defined __SNPT /* FreeBSD, 
NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
-
-static inline int
-disable_seek_optimization (FILE *fp)
-{
-  int saved_flags = fp_->_flags & (__SOPT | __SNPT);
-  fp_->_flags = (fp_->_flags & ~__SOPT) | __SNPT;
-  return saved_flags;
-}
-
-static inline void
-restore_seek_optimization (FILE *fp, int saved_flags)
-{
-  fp_->_flags = (fp_->_flags & ~(__SOPT | __SNPT)) | saved_flags;
-}
-
-#endif
-
-static inline void
-update_fpos_cache (FILE *fp, off_t pos)
-{
-#if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, 
DragonFly, MacOS X, Cygwin */
-# if defined __CYGWIN__
-  /* fp_->_offset is typed as an integer.  */
-  fp_->_offset = pos;
-# else
-  /* fp_->_offset is an fpos_t.  */
-  /* Use a union, since on NetBSD, the compilation flags determine
-     whether fpos_t is typedef'd to off_t or a struct containing a
-     single off_t member.  */
-  union
-    {
-      fpos_t f;
-      off_t o;
-    } u;
-  u.o = pos;
-  fp_->_offset = u.f;
-# endif
-  fp_->_flags |= __SOFF;
-#endif
-}
-
-/* Flush all pending data on STREAM according to POSIX rules.  Both
-   output and seekable input streams are supported.  */
-int
-rpl_fflush (FILE *stream)
-{
-  /* When stream is NULL, POSIX and C99 only require flushing of "output
-     streams and update streams in which the most recent operation was not
-     input", and all implementations do this.
-
-     When stream is "an output stream or an update stream in which the most
-     recent operation was not input", POSIX and C99 requires that fflush
-     writes out any buffered data, and all implementations do this.
-
-     When stream is, however, an input stream or an update stream in
-     which the most recent operation was input, C99 specifies nothing,
-     and POSIX only specifies behavior if the stream is seekable.
-     mingw, in particular, drops the input buffer, leaving the file
-     descriptor positioned at the end of the input buffer. I.e. ftell
-     (stream) is lost.  We don't want to call the implementation's
-     fflush in this case.
-
-     We test ! freading (stream) here, rather than fwriting (stream), because
-     what we need to know is whether the stream holds a "read buffer", and on
-     mingw this is indicated by _IOREAD, regardless of _IOWRT.  */
-  if (stream == NULL || ! freading (stream))
-    return fflush (stream);
-
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, 
Linux libc5 */
-
-  clear_ungetc_buffer_preserving_position (stream);
-
-  return fflush (stream);
-
-#else
-  {
-    /* Notes about the file-position indicator:
-       1) The file position indicator is incremented by fgetc() and decremented
-          by ungetc():
-          <http://www.opengroup.org/susv3/functions/fgetc.html>
-            "... the fgetc() function shall ... advance the associated file
-             position indicator for the stream ..."
-          <http://www.opengroup.org/susv3/functions/ungetc.html>
-            "The file-position indicator is decremented by each successful
-             call to ungetc()..."
-       2) <http://www.opengroup.org/susv3/functions/ungetc.html> says:
-            "The value of the file-position indicator for the stream after
-             reading or discarding all pushed-back bytes shall be the same
-             as it was before the bytes were pushed back."
-          Here we are discarding all pushed-back bytes.  But more specifically,
-       3) <http://www.opengroup.org/austin/aardvark/latest/xshbug3.txt> says:
-            "[After fflush(),] the file offset of the underlying open file
-             description shall be set to the file position of the stream, and
-             any characters pushed back onto the stream by ungetc() ... shall
-             be discarded."  */
-
-    /* POSIX does not specify fflush behavior for non-seekable input
-       streams.  Some implementations purge unread data, some return
-       EBADF, some do nothing.  */
-    off_t pos = ftello (stream);
-    if (pos == -1)
-      {
-        errno = EBADF;
-        return EOF;
-      }
-
-    /* Clear the ungetc buffer.  */
-    clear_ungetc_buffer (stream);
-
-    /* To get here, we must be flushing a seekable input stream, so the
-       semantics of fpurge are now appropriate to clear the buffer.  To
-       avoid losing data, the lseek is also necessary.  */
-    {
-      int result = fpurge (stream);
-      if (result != 0)
-        return result;
-    }
-
-# if (defined __sferror || defined __DragonFly__) && defined __SNPT /* 
FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
-
-    {
-      /* Disable seek optimization for the next fseeko call.  This tells the
-         following fseeko call to seek to the desired position directly, rather
-         than to seek to a block-aligned boundary.  */
-      int saved_flags = disable_seek_optimization (stream);
-      int result = fseeko (stream, pos, SEEK_SET);
-
-      restore_seek_optimization (stream, saved_flags);
-      return result;
-    }
-
-# else
-
-    pos = lseek (fileno (stream), pos, SEEK_SET);
-    if (pos == -1)
-      return EOF;
-    /* After a successful lseek, update the file descriptor's position cache
-       in the stream.  */
-    update_fpos_cache (stream, pos);
-
-    return 0;
-
-# endif
-  }
-#endif
-}
diff --git a/gl/float+.h b/gl/float+.h
index 2e84489..c294350 100644
--- a/gl/float+.h
+++ b/gl/float+.h
@@ -1,5 +1,5 @@
 /* Supplemental information about the floating-point formats.
-   Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2007.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/gl/float.c b/gl/float.c
index c453d6d..ea31866 100644
--- a/gl/float.c
+++ b/gl/float.c
@@ -1,5 +1,5 @@
 /* Auxiliary definitions for <float.h>.
-   Copyright (C) 2011 Free Software Foundation, Inc.
+   Copyright (C) 2011-2012 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2011.
 
    This program is free software: you can redistribute it and/or modify
@@ -20,7 +20,7 @@
 /* Specification.  */
 #include <float.h>
 
-#if (defined _ARCH_PPC || defined _POWER) && defined _AIX && (LDBL_MANT_DIG == 
106) && defined __GNUC__
+#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined 
__linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__
 const union gl_long_double_union gl_LDBL_MAX =
   { { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL } };
 #elif defined __i386__
diff --git a/gl/float.in.h b/gl/float.in.h
index 57b7bc9..b420510 100644
--- a/gl/float.in.h
+++ b/gl/float.in.h
@@ -1,6 +1,6 @@
 /* A correct <float.h>.
 
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
@@ -109,7 +109,8 @@ extern const union gl_long_double_union gl_LDBL_MAX;
 #endif
 
 /* On AIX 7.1 with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_MAX are
-   wrong.  */
+   wrong.
+   On Linux/PowerPC with gcc 4.4, the value of LDBL_MAX is wrong.  */
 #if (defined _ARCH_PPC || defined _POWER) && defined _AIX && (LDBL_MANT_DIG == 
106) && defined __GNUC__
 # undef LDBL_MIN_EXP
 # define LDBL_MIN_EXP DBL_MIN_EXP
@@ -117,6 +118,8 @@ extern const union gl_long_double_union gl_LDBL_MAX;
 # define LDBL_MIN_10_EXP DBL_MIN_10_EXP
 # undef LDBL_MIN
 # define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 
2^-1022 */
+#endif
+#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined 
__linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__
 # undef LDBL_MAX
 /* LDBL_MAX is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xFFFFFFFF 
}.
    It is not easy to define:
@@ -170,5 +173,16 @@ extern const union gl_long_double_union gl_LDBL_MAX;
 # endif
 #endif
 
+#if @REPLACE_ITOLD@
+/* Pull in a function that fixes the 'int' to 'long double' conversion
+   of glibc 2.7.  */
+extern
+# ifdef __cplusplus
+"C"
+# endif
+void _Qp_itoq (long double *, int);
+static void (*_gl_float_fix_itold) (long double *, int) = _Qp_itoq;
+#endif
+
 #endif /* address@hidden@_FLOAT_H */
 #endif /* address@hidden@_FLOAT_H */
diff --git a/gl/fpurge.c b/gl/fpurge.c
deleted file mode 100644
index 7e69fb4..0000000
--- a/gl/fpurge.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/* Flushing buffers of a FILE stream.
-   Copyright (C) 2007-2011 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
-   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 General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#include <config.h>
-
-/* Specification.  */
-#include <stdio.h>
-
-#if HAVE___FPURGE                   /* glibc >= 2.2, Haiku, Solaris >= 7 */
-# include <stdio_ext.h>
-#endif
-#include <stdlib.h>
-
-#include "stdio-impl.h"
-
-int
-fpurge (FILE *fp)
-{
-#if HAVE___FPURGE                   /* glibc >= 2.2, Haiku, Solaris >= 7 */
-
-  __fpurge (fp);
-  /* The __fpurge function does not have a return value.  */
-  return 0;
-
-#elif HAVE_FPURGE                   /* FreeBSD, NetBSD, OpenBSD, DragonFly, 
MacOS X, Cygwin 1.7 */
-
-  /* Call the system's fpurge function.  */
-# undef fpurge
-# if !HAVE_DECL_FPURGE
-  extern int fpurge (FILE *);
-# endif
-  int result = fpurge (fp);
-# if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, 
DragonFly, MacOS X, Cygwin */
-  if (result == 0)
-    /* Correct the invariants that fpurge broke.
-       <stdio.h> on BSD systems says:
-         "The following always hold: if _flags & __SRD, _w is 0."
-       If this invariant is not fulfilled and the stream is read-write but
-       currently reading, subsequent putc or fputc calls will write directly
-       into the buffer, although they shouldn't be allowed to.  */
-    if ((fp_->_flags & __SRD) != 0)
-      fp_->_w = 0;
-# endif
-  return result;
-
-#else
-
-  /* Most systems provide FILE as a struct and the necessary bitmask in
-     <stdio.h>, because they need it for implementing getc() and putc() as
-     fast macros.  */
-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, 
Haiku, Linux libc5 */
-  fp->_IO_read_end = fp->_IO_read_ptr;
-  fp->_IO_write_ptr = fp->_IO_write_base;
-  /* Avoid memory leak when there is an active ungetc buffer.  */
-  if (fp->_IO_save_base != NULL)
-    {
-      free (fp->_IO_save_base);
-      fp->_IO_save_base = NULL;
-    }
-  return 0;
-# elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, 
DragonFly, MacOS X, Cygwin */
-  fp_->_p = fp_->_bf._base;
-  fp_->_r = 0;
-  fp_->_w = ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered 
and not currently reading? */
-             ? fp_->_bf._size
-             : 0);
-  /* Avoid memory leak when there is an active ungetc buffer.  */
-  if (fp_ub._base != NULL)
-    {
-      if (fp_ub._base != fp_->_ubuf)
-        free (fp_ub._base);
-      fp_ub._base = NULL;
-    }
-  return 0;
-# elif defined __EMX__              /* emx+gcc */
-  fp->_ptr = fp->_buffer;
-  fp->_rcount = 0;
-  fp->_wcount = 0;
-  fp->_ungetc_count = 0;
-  return 0;
-# elif defined _IOERR               /* AIX, HP-UX, IRIX, OSF/1, Solaris, 
OpenServer, mingw, NonStop Kernel */
-  fp->_ptr = fp->_base;
-  if (fp->_ptr != NULL)
-    fp->_cnt = 0;
-  return 0;
-# elif defined __UCLIBC__           /* uClibc */
-#  ifdef __STDIO_BUFFERS
-  if (fp->__modeflags & __FLAG_WRITING)
-    fp->__bufpos = fp->__bufstart;
-  else if (fp->__modeflags & (__FLAG_READONLY | __FLAG_READING))
-    fp->__bufpos = fp->__bufread;
-#  endif
-  return 0;
-# elif defined __QNX__              /* QNX */
-  fp->_Rback = fp->_Back + sizeof (fp->_Back);
-  fp->_Rsave = NULL;
-  if (fp->_Mode & 0x2000 /* _MWRITE */)
-    /* fp->_Buf <= fp->_Next <= fp->_Wend */
-    fp->_Next = fp->_Buf;
-  else
-    /* fp->_Buf <= fp->_Next <= fp->_Rend */
-    fp->_Rend = fp->_Next;
-  return 0;
-# elif defined __MINT__             /* Atari FreeMiNT */
-  if (fp->__pushed_back)
-    {
-      fp->__bufp = fp->__pushback_bufp;
-      fp->__pushed_back = 0;
-    }
-  /* Preserve the current file position.  */
-  if (fp->__target != -1)
-    fp->__target += fp->__bufp - fp->__buffer;
-  fp->__bufp = fp->__buffer;
-  /* Nothing in the buffer, next getc is nontrivial.  */
-  fp->__get_limit = fp->__bufp;
-  /* Nothing in the buffer, next putc is nontrivial.  */
-  fp->__put_limit = fp->__buffer;
-  return 0;
-# else
-#  error "Please port gnulib fpurge.c to your platform! Look at the 
definitions of fflush, setvbuf and ungetc on your system, then report this to 
bug-gnulib."
-# endif
-
-#endif
-}
diff --git a/gl/freading.c b/gl/freading.c
deleted file mode 100644
index 51aed0e..0000000
--- a/gl/freading.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/* Retrieve information about a FILE stream.
-   Copyright (C) 2007-2011 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
-   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 General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#include <config.h>
-
-/* Specification.  */
-#include "freading.h"
-
-#include "stdio-impl.h"
-
-/* Don't use glibc's __freading function in glibc < 2.7, see
-   <http://sourceware.org/bugzilla/show_bug.cgi?id=4359>  */
-#if !(HAVE___FREADING && (!defined __GLIBC__ || defined __UCLIBC__ || 
__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)))
-
-bool
-freading (FILE *fp)
-{
-  /* Most systems provide FILE as a struct and the necessary bitmask in
-     <stdio.h>, because they need it for implementing getc() and putc() as
-     fast macros.  */
-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, 
Haiku, Linux libc5 */
-  return ((fp->_flags & _IO_NO_WRITES) != 0
-          || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
-              && fp->_IO_read_base != NULL));
-# elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, 
DragonFly, MacOS X, Cygwin */
-  return (fp_->_flags & __SRD) != 0;
-# elif defined __EMX__               /* emx+gcc */
-  return (fp->_flags & _IOREAD) != 0;
-# elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, 
OpenServer, mingw, NonStop Kernel */
-#  if defined __sun                  /* Solaris */
-  return (fp->_flag & _IOREAD) != 0 && (fp->_flag & _IOWRT) == 0;
-#  else
-  return (fp->_flag & _IOREAD) != 0;
-#  endif
-# elif defined __UCLIBC__            /* uClibc */
-  return (fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) != 0;
-# elif defined __QNX__               /* QNX */
-  return ((fp->_Mode & 0x2 /* _MOPENW */) == 0
-          || (fp->_Mode & 0x1000 /* _MREAD */) != 0);
-# elif defined __MINT__              /* Atari FreeMiNT */
-  if (!fp->__mode.__write)
-    return 1;
-  if (!fp->__mode.__read)
-    return 0;
-#  ifdef _IO_CURRENTLY_GETTING /* Flag added on 2009-02-28 */
-  return (fp->__flags & _IO_CURRENTLY_GETTING) != 0;
-#  else
-  return (fp->__buffer < fp->__get_limit /*|| fp->__bufp == fp->__put_limit 
??*/);
-#  endif
-# else
-#  error "Please port gnulib freading.c to your platform!"
-# endif
-}
-
-#endif
diff --git a/gl/freading.h b/gl/freading.h
deleted file mode 100644
index a19aea6..0000000
--- a/gl/freading.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Retrieve information about a FILE stream.
-   Copyright (C) 2007-2011 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
-   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 General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#include <stdbool.h>
-#include <stdio.h>
-
-/* Return true if the stream STREAM is opened read-only, or if the
-   last operation on the stream was a read operation.  Return false if
-   the stream is opened write-only or append-only, or if it supports
-   writing and there is no current read operation (such as fgetc).
-
-   freading and fwriting will never both be true.  If STREAM supports
-   both reads and writes, then:
-     - both freading and fwriting might be false when the stream is first
-       opened, after read encounters EOF, or after fflush,
-     - freading might be false or true and fwriting might be false
-       after repositioning (such as fseek, fsetpos, or rewind),
-   depending on the underlying implementation.
-
-   STREAM must not be wide-character oriented.  */
-
-#if HAVE___FREADING && (!defined __GLIBC__ || defined __UCLIBC__ || __GLIBC__ 
> 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7))
-/* Solaris >= 7, not glibc >= 2.2, but glibc >= 2.7  */
-
-# include <stdio_ext.h>
-# define freading(stream) (__freading (stream) != 0)
-
-#else
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-extern bool freading (FILE *stream);
-
-# ifdef __cplusplus
-}
-# endif
-
-#endif
diff --git a/gl/fseek.c b/gl/fseek.c
index bcb76d8..20f5e2c 100644
--- a/gl/fseek.c
+++ b/gl/fseek.c
@@ -1,5 +1,5 @@
 /* An fseek() function that, together with fflush(), is POSIX compliant.
-   Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2012 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
diff --git a/gl/fseeko.c b/gl/fseeko.c
index 2dd4cdc..08e1f71 100644
--- a/gl/fseeko.c
+++ b/gl/fseeko.c
@@ -1,5 +1,5 @@
 /* An fseeko() function that, together with fflush(), is POSIX compliant.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
@@ -69,6 +69,9 @@ fseeko (FILE *fp, off_t offset, int whence)
       && fp->_rcount == 0
       && fp->_wcount == 0
       && fp->_ungetc_count == 0)
+#elif defined __minix               /* Minix */
+  if (fp_->_ptr == fp_->_buf
+      && (fp_->_ptr == NULL || fp_->_count == 0))
 #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, 
OpenServer, mingw, NonStop Kernel */
   if (fp_->_ptr == fp_->_base
       && (fp_->_ptr == NULL || fp_->_cnt == 0))
@@ -86,18 +89,17 @@ fseeko (FILE *fp, off_t offset, int whence)
       && fp->__get_limit == fp->__bufp
       && fp->__put_limit == fp->__bufp
       && !fp->__pushed_back)
+#elif defined EPLAN9                /* Plan9 */
+  if (fp->rp == fp->buf
+      && fp->wp == fp->buf)
 #else
   #error "Please port gnulib fseeko.c to your platform! Look at the code in 
fpurge.c, then report this to bug-gnulib."
 #endif
     {
-      /* We get here when an fflush() call immediately preceded this one.  We
-         know there are no buffers.
-         POSIX requires us to modify the file descriptor's position.
-         But we cannot position beyond end of file here.  */
-      off_t pos =
-        lseek (fileno (fp),
-               whence == SEEK_END && offset > 0 ? 0 : offset,
-               whence);
+      /* We get here when an fflush() call immediately preceded this one (or
+         if ftell() has created buffers but no I/O has occurred on a
+         newly-opened stream).  We know there are no buffers.  */
+      off_t pos = lseek (fileno (fp), offset, whence);
       if (pos == -1)
         {
 #if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, 
DragonFly, MacOS X, Cygwin */
@@ -108,6 +110,7 @@ fseeko (FILE *fp, off_t offset, int whence)
 
 #if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, 
Linux libc5 */
       fp->_flags &= ~_IO_EOF_SEEN;
+      fp->_offset = pos;
 #elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, 
DragonFly, MacOS X, Cygwin */
 # if defined __CYGWIN__
       /* fp_->_offset is typed as an integer.  */
@@ -137,10 +140,7 @@ fseeko (FILE *fp, off_t offset, int whence)
       fp->__offset = pos;
       fp->__eof = 0;
 #endif
-      /* If we were not requested to position beyond end of file, we're
-         done.  */
-      if (!(whence == SEEK_END && offset > 0))
-        return 0;
+      return 0;
     }
   return fseeko (fp, offset, whence);
 }
diff --git a/gl/fstat.c b/gl/fstat.c
new file mode 100644
index 0000000..4918495
--- /dev/null
+++ b/gl/fstat.c
@@ -0,0 +1,82 @@
+/* fstat() replacement.
+   Copyright (C) 2011-2012 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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* If the user's config.h happens to include <sys/stat.h>, let it include only
+   the system's <sys/stat.h> here, so that orig_fstat doesn't recurse to
+   rpl_fstat.  */
+#define __need_system_sys_stat_h
+#include <config.h>
+
+/* Get the original definition of fstat.  It might be defined as a macro.  */
+#include <sys/types.h>
+#include <sys/stat.h>
+#undef __need_system_sys_stat_h
+
+static inline int
+orig_fstat (int fd, struct stat *buf)
+{
+  return fstat (fd, buf);
+}
+
+/* Specification.  */
+/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
+   eliminates this include because of the preliminary #include <sys/stat.h>
+   above.  */
+#include "sys/stat.h"
+
+#include <errno.h>
+#include <unistd.h>
+
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+#endif
+
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+static inline int
+fstat_nothrow (int fd, struct stat *buf)
+{
+  int result;
+
+  TRY_MSVC_INVAL
+    {
+      result = orig_fstat (fd, buf);
+    }
+  CATCH_MSVC_INVAL
+    {
+      result = -1;
+      errno = EBADF;
+    }
+  DONE_MSVC_INVAL;
+
+  return result;
+}
+#else
+# define fstat_nothrow orig_fstat
+#endif
+
+int
+rpl_fstat (int fd, struct stat *buf)
+{
+#if REPLACE_FCHDIR && REPLACE_OPEN_DIRECTORY
+  /* Handle the case when rpl_open() used a dummy file descriptor to work
+     around an open() that can't normally visit directories.  */
+  const char *name = _gl_directory_name (fd);
+  if (name != NULL)
+    return stat (name, buf);
+#endif
+
+  return fstat_nothrow (fd, buf);
+}
diff --git a/gl/ftell.c b/gl/ftell.c
deleted file mode 100644
index 79083fb..0000000
--- a/gl/ftell.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* An ftell() function that works around platform bugs.
-   Copyright (C) 2007-2011 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
-   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 General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#include <config.h>
-
-/* Specification.  */
-#include <stdio.h>
-
-#include <errno.h>
-/* Get off_t.  */
-#include <unistd.h>
-
-long
-ftell (FILE *fp)
-{
-  /* Use the replacement ftello function with all its workarounds.  */
-  off_t offset = ftello (fp);
-  if (offset == (long)offset)
-    return (long)offset;
-  else
-    {
-      errno = EOVERFLOW;
-      return -1;
-    }
-}
diff --git a/gl/ftello.c b/gl/ftello.c
deleted file mode 100644
index fbdc44f..0000000
--- a/gl/ftello.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/* An ftello() function that works around platform bugs.
-   Copyright (C) 2007, 2009-2011 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
-   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 General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#include <config.h>
-
-/* Specification.  */
-#include <stdio.h>
-
-/* Get lseek.  */
-#include <unistd.h>
-
-#include "stdio-impl.h"
-
-off_t
-ftello (FILE *fp)
-#undef ftello
-#if !HAVE_FTELLO
-# undef ftell
-# define ftello ftell
-#endif
-{
-#if LSEEK_PIPE_BROKEN
-  /* mingw gives bogus answers rather than failure on non-seekable files.  */
-  if (lseek (fileno (fp), 0, SEEK_CUR) == -1)
-    return -1;
-#endif
-
-#if FTELLO_BROKEN_AFTER_SWITCHING_FROM_READ_TO_WRITE /* Solaris */
-  /* The Solaris stdio leaves the _IOREAD flag set after reading from a file
-     reaches EOF and the program then starts writing to the file.  ftello
-     gets confused by this.  */
-  if (fp_->_flag & _IOWRT)
-    {
-      off_t pos;
-
-      /* Call ftello nevertheless, for the side effects that it does on fp.  */
-      ftello (fp);
-
-      /* Compute the file position ourselves.  */
-      pos = lseek (fileno (fp), (off_t) 0, SEEK_CUR);
-      if (pos >= 0)
-        {
-          if ((fp_->_flag & _IONBF) == 0 && fp_->_base != NULL)
-            pos += fp_->_ptr - fp_->_base;
-        }
-      return pos;
-    }
-#endif
-
-#if defined __SL64 && defined __SCLE /* Cygwin */
-  if ((fp->_flags & __SL64) == 0)
-    {
-      /* Cygwin 1.5.0 through 1.5.24 failed to open stdin in 64-bit
-         mode; but has an ftello that requires 64-bit mode.  */
-      FILE *tmp = fopen ("/dev/null", "r");
-      if (!tmp)
-        return -1;
-      fp->_flags |= __SL64;
-      fp->_seek64 = tmp->_seek64;
-      fclose (tmp);
-    }
-#endif
-  return ftello (fp);
-}
diff --git a/gl/gai_strerror.c b/gl/gai_strerror.c
index 052c9a0..b846e48 100644
--- a/gl/gai_strerror.c
+++ b/gl/gai_strerror.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2011 Free Software
+/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2012 Free Software
    Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Philip Blundell <address@hidden>, 1997.
diff --git a/gl/getaddrinfo.c b/gl/getaddrinfo.c
index 99b29ec..c538967 100644
--- a/gl/getaddrinfo.c
+++ b/gl/getaddrinfo.c
@@ -1,5 +1,5 @@
 /* Get address information (partial implementation).
-   Copyright (C) 1997, 2001-2002, 2004-2011 Free Software Foundation, Inc.
+   Copyright (C) 1997, 2001-2002, 2004-2012 Free Software Foundation, Inc.
    Contributed by Simon Josefsson <address@hidden>.
 
    This program is free software; you can redistribute it and/or modify
@@ -56,13 +56,13 @@
 #endif
 
 #if defined _WIN32 || defined __WIN32__
-# define WIN32_NATIVE
+# define WINDOWS_NATIVE
 #endif
 
 /* gl_sockets_startup */
 #include "sockets.h"
 
-#ifdef WIN32_NATIVE
+#ifdef WINDOWS_NATIVE
 typedef int (WSAAPI *getaddrinfo_func) (const char*, const char*,
                                         const struct addrinfo*,
                                         struct addrinfo**);
@@ -153,7 +153,7 @@ getaddrinfo (const char *restrict nodename,
   };
 #endif
 
-#ifdef WIN32_NATIVE
+#ifdef WINDOWS_NATIVE
   if (use_win32_p ())
     return getaddrinfo_ptr (nodename, servname, hints, res);
 #endif
@@ -332,11 +332,11 @@ getaddrinfo (const char *restrict nodename,
   return 0;
 }
 
-/* Free `addrinfo' structure AI including associated storage.  */
+/* Free 'addrinfo' structure AI including associated storage.  */
 void
 freeaddrinfo (struct addrinfo *ai)
 {
-#ifdef WIN32_NATIVE
+#ifdef WINDOWS_NATIVE
   if (use_win32_p ())
     {
       freeaddrinfo_ptr (ai);
@@ -362,7 +362,7 @@ getnameinfo (const struct sockaddr *restrict sa, socklen_t 
salen,
              char *restrict service, socklen_t servicelen,
              int flags)
 {
-#ifdef WIN32_NATIVE
+#ifdef WINDOWS_NATIVE
   if (use_win32_p ())
     return getnameinfo_ptr (sa, salen, node, nodelen,
                             service, servicelen, flags);
diff --git a/gl/getdelim.c b/gl/getdelim.c
index 14a8bce..d80c583 100644
--- a/gl/getdelim.c
+++ b/gl/getdelim.c
@@ -1,5 +1,5 @@
 /* getdelim.c --- Implementation of replacement getdelim function.
-   Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2011 Free Software
+   Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2012 Free Software
    Foundation, Inc.
 
    This program is free software; you can redistribute it and/or
diff --git a/gl/getline.c b/gl/getline.c
index e6e9187..ab64d80 100644
--- a/gl/getline.c
+++ b/gl/getline.c
@@ -1,5 +1,5 @@
 /* getline.c --- Implementation of replacement getline function.
-   Copyright (C) 2005-2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2005-2007, 2009-2012 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
diff --git a/gl/getopt.c b/gl/getopt.c
index 2af8352..4342a34 100644
--- a/gl/getopt.c
+++ b/gl/getopt.c
@@ -2,7 +2,7 @@
    NOTE: getopt is part of the C library, so if you don't know what
    "Keep this file name-space clean" means, talk to address@hidden
    before changing it!
-   Copyright (C) 1987-1996, 1998-2004, 2006, 2008-2011 Free Software
+   Copyright (C) 1987-1996, 1998-2004, 2006, 2008-2012 Free Software
    Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -41,15 +41,15 @@
 # include <wchar.h>
 #endif
 
-/* This version of `getopt' appears to the caller like standard Unix `getopt'
+/* This version of 'getopt' appears to the caller like standard Unix 'getopt'
    but it behaves differently for the user, since it allows the user
    to intersperse the options with the other arguments.
 
-   As `getopt_long' works, it permutes the elements of ARGV so that,
+   As 'getopt_long' works, it permutes the elements of ARGV so that,
    when it is done, all the options precede everything else.  Thus
    all application programs are extended to handle flexible argument order.
 
-   Using `getopt' or setting the environment variable POSIXLY_CORRECT
+   Using 'getopt' or setting the environment variable POSIXLY_CORRECT
    disables permutation.
    Then the behavior is completely standard.
 
@@ -58,24 +58,24 @@
 
 #include "getopt_int.h"
 
-/* For communication from `getopt' to the caller.
-   When `getopt' finds an option that takes an argument,
+/* For communication from 'getopt' to the caller.
+   When 'getopt' finds an option that takes an argument,
    the argument value is returned here.
-   Also, when `ordering' is RETURN_IN_ORDER,
+   Also, when 'ordering' is RETURN_IN_ORDER,
    each non-option ARGV-element is returned here.  */
 
 char *optarg;
 
 /* Index in ARGV of the next element to be scanned.
    This is used for communication to and from the caller
-   and for communication between successive calls to `getopt'.
+   and for communication between successive calls to 'getopt'.
 
-   On entry to `getopt', zero means this is the first call; initialize.
+   On entry to 'getopt', zero means this is the first call; initialize.
 
-   When `getopt' returns -1, this is the index of the first of the
+   When 'getopt' returns -1, this is the index of the first of the
    non-option elements that the caller should itself scan.
 
-   Otherwise, `optind' communicates from one call to the next
+   Otherwise, 'optind' communicates from one call to the next
    how much of ARGV has been scanned so far.  */
 
 /* 1003.2 says this must be 1 before any call.  */
@@ -137,7 +137,7 @@ extern char *__getopt_nonoption_flags;
    The other is elements [last_nonopt,optind), which contains all
    the options processed since those non-options were skipped.
 
-   `first_nonopt' and `last_nonopt' are relocated so that they describe
+   'first_nonopt' and 'last_nonopt' are relocated so that they describe
    the new indices of the non-options in ARGV after they are moved.  */
 
 static void
@@ -154,7 +154,7 @@ exchange (char **argv, struct _getopt_data *d)
      but it consists of two parts that need to be swapped next.  */
 
 #if defined _LIBC && defined USE_NONOPTION_FLAGS
-  /* First make sure the handling of the `__getopt_nonoption_flags'
+  /* First make sure the handling of the '__getopt_nonoption_flags'
      string can work normally.  Our top argument must be in the range
      of the string.  */
   if (d->__nonoption_flags_len > 0 && top >= d->__nonoption_flags_max_len)
@@ -291,48 +291,48 @@ _getopt_initialize (int argc _GL_UNUSED,
 
    If an element of ARGV starts with '-', and is not exactly "-" or "--",
    then it is an option element.  The characters of this element
-   (aside from the initial '-') are option characters.  If `getopt'
+   (aside from the initial '-') are option characters.  If 'getopt'
    is called repeatedly, it returns successively each of the option characters
    from each of the option elements.
 
-   If `getopt' finds another option character, it returns that character,
-   updating `optind' and `nextchar' so that the next call to `getopt' can
+   If 'getopt' finds another option character, it returns that character,
+   updating 'optind' and 'nextchar' so that the next call to 'getopt' can
    resume the scan with the following option character or ARGV-element.
 
-   If there are no more option characters, `getopt' returns -1.
-   Then `optind' is the index in ARGV of the first ARGV-element
+   If there are no more option characters, 'getopt' returns -1.
+   Then 'optind' is the index in ARGV of the first ARGV-element
    that is not an option.  (The ARGV-elements have been permuted
    so that those that are not options now come last.)
 
    OPTSTRING is a string containing the legitimate option characters.
    If an option character is seen that is not listed in OPTSTRING,
-   return '?' after printing an error message.  If you set `opterr' to
+   return '?' after printing an error message.  If you set 'opterr' to
    zero, the error message is suppressed but we still return '?'.
 
    If a char in OPTSTRING is followed by a colon, that means it wants an arg,
    so the following text in the same ARGV-element, or the text of the following
-   ARGV-element, is returned in `optarg'.  Two colons mean an option that
+   ARGV-element, is returned in 'optarg'.  Two colons mean an option that
    wants an optional arg; if there is text in the current ARGV-element,
-   it is returned in `optarg', otherwise `optarg' is set to zero.
+   it is returned in 'optarg', otherwise 'optarg' is set to zero.
 
-   If OPTSTRING starts with `-' or `+', it requests different methods of
+   If OPTSTRING starts with '-' or '+', it requests different methods of
    handling the non-option ARGV-elements.
    See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
 
-   Long-named options begin with `--' instead of `-'.
+   Long-named options begin with '--' instead of '-'.
    Their names may be abbreviated as long as the abbreviation is unique
    or is an exact match for some defined option.  If they have an
    argument, it follows the option name in the same ARGV-element, separated
-   from the option name by a `=', or else the in next ARGV-element.
-   When `getopt' finds a long-named option, it returns 0 if that option's
-   `flag' field is nonzero, the value of the option's `val' field
-   if the `flag' field is zero.
+   from the option name by a '=', or else the in next ARGV-element.
+   When 'getopt' finds a long-named option, it returns 0 if that option's
+   'flag' field is nonzero, the value of the option's 'val' field
+   if the 'flag' field is zero.
 
    The elements of ARGV aren't really const, because we permute them.
    But we pretend they're const in the prototype to be compatible
    with other systems.
 
-   LONGOPTS is a vector of `struct option' terminated by an
+   LONGOPTS is a vector of 'struct option' terminated by an
    element containing a name which is zero.
 
    LONGIND returns the index in LONGOPT of the long-named option found.
@@ -409,7 +409,7 @@ _getopt_internal_r (int argc, char **argv, const char 
*optstring,
           d->__last_nonopt = d->optind;
         }
 
-      /* The special ARGV-element `--' means premature end of options.
+      /* The special ARGV-element '--' means premature end of options.
          Skip it like a null option,
          then exchange with previous non-options as if it were an option,
          then skip everything else like a non-option.  */
@@ -788,7 +788,7 @@ _getopt_internal_r (int argc, char **argv, const char 
*optstring,
     char c = *d->__nextchar++;
     const char *temp = strchr (optstring, c);
 
-    /* Increment `optind' when we start to process its last character.  */
+    /* Increment 'optind' when we start to process its last character.  */
     if (*d->__nextchar == '\0')
       ++d->optind;
 
@@ -829,7 +829,7 @@ _getopt_internal_r (int argc, char **argv, const char 
*optstring,
         return '?';
       }
     /* Convenience. Treat POSIX -W foo same as long option --foo */
-    if (temp[0] == 'W' && temp[1] == ';' && longopts)
+    if (temp[0] == 'W' && temp[1] == ';')
       {
         char *nameend;
         const struct option *p;
@@ -839,6 +839,9 @@ _getopt_internal_r (int argc, char **argv, const char 
*optstring,
         int indfound = 0;
         int option_index;
 
+        if (longopts == NULL)
+          goto no_longs;
+
         /* This is an option that requires an argument.  */
         if (*d->__nextchar != '\0')
           {
@@ -884,7 +887,7 @@ _getopt_internal_r (int argc, char **argv, const char 
*optstring,
             return c;
           }
         else
-          /* We already incremented `d->optind' once;
+          /* We already incremented 'd->optind' once;
              increment it again when taking next ARGV-elt as argument.  */
           d->optarg = argv[d->optind++];
 
@@ -1046,8 +1049,10 @@ _getopt_internal_r (int argc, char **argv, const char 
*optstring,
               }
             return pfound->val;
           }
-          d->__nextchar = NULL;
-          return 'W';   /* Let the application handle it.   */
+
+      no_longs:
+        d->__nextchar = NULL;
+        return 'W';   /* Let the application handle it.   */
       }
     if (temp[1] == ':')
       {
@@ -1109,7 +1114,7 @@ _getopt_internal_r (int argc, char **argv, const char 
*optstring,
                   c = '?';
               }
             else
-              /* We already incremented `optind' once;
+              /* We already incremented 'optind' once;
                  increment it again when taking next ARGV-elt as argument.  */
               d->optarg = argv[d->optind++];
             d->__nextchar = NULL;
@@ -1172,7 +1177,7 @@ __posix_getopt (int argc, char *const *argv, const char 
*optstring)
 #ifdef TEST
 
 /* Compile with -DTEST to make an executable for use in testing
-   the above definition of `getopt'.  */
+   the above definition of 'getopt'.  */
 
 int
 main (int argc, char **argv)
diff --git a/gl/getopt.in.h b/gl/getopt.in.h
index 0f3918a..06b6dfc 100644
--- a/gl/getopt.in.h
+++ b/gl/getopt.in.h
@@ -1,5 +1,5 @@
 /* Declarations for getopt.
-   Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2011 Free Software
+   Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2012 Free Software
    Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -82,7 +82,7 @@
    getopt_long_only can permute argv; this is required for backward
    compatibility (e.g., for LSB 2.0.1).
 
-   This used to be `#if defined __GETOPT_PREFIX && !defined __need_getopt',
+   This used to be '#if defined __GETOPT_PREFIX && !defined __need_getopt',
    but it caused redefinition warnings if both unistd.h and getopt.h were
    included, since unistd.h includes getopt.h having previously defined
    __need_getopt.
@@ -128,29 +128,29 @@
 extern "C" {
 #endif
 
-/* For communication from `getopt' to the caller.
-   When `getopt' finds an option that takes an argument,
+/* For communication from 'getopt' to the caller.
+   When 'getopt' finds an option that takes an argument,
    the argument value is returned here.
-   Also, when `ordering' is RETURN_IN_ORDER,
+   Also, when 'ordering' is RETURN_IN_ORDER,
    each non-option ARGV-element is returned here.  */
 
 extern char *optarg;
 
 /* Index in ARGV of the next element to be scanned.
    This is used for communication to and from the caller
-   and for communication between successive calls to `getopt'.
+   and for communication between successive calls to 'getopt'.
 
-   On entry to `getopt', zero means this is the first call; initialize.
+   On entry to 'getopt', zero means this is the first call; initialize.
 
-   When `getopt' returns -1, this is the index of the first of the
+   When 'getopt' returns -1, this is the index of the first of the
    non-option elements that the caller should itself scan.
 
-   Otherwise, `optind' communicates from one call to the next
+   Otherwise, 'optind' communicates from one call to the next
    how much of ARGV has been scanned so far.  */
 
 extern int optind;
 
-/* Callers store zero here to inhibit the error message `getopt' prints
+/* Callers store zero here to inhibit the error message 'getopt' prints
    for unrecognized options.  */
 
 extern int opterr;
@@ -162,24 +162,24 @@ extern int optopt;
 #ifndef __need_getopt
 /* Describe the long-named options requested by the application.
    The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
-   of `struct option' terminated by an element containing a name which is
+   of 'struct option' terminated by an element containing a name which is
    zero.
 
-   The field `has_arg' is:
+   The field 'has_arg' is:
    no_argument          (or 0) if the option does not take an argument,
    required_argument    (or 1) if the option requires an argument,
    optional_argument    (or 2) if the option takes an optional argument.
 
-   If the field `flag' is not NULL, it points to a variable that is set
-   to the value given in the field `val' when the option is found, but
+   If the field 'flag' is not NULL, it points to a variable that is set
+   to the value given in the field 'val' when the option is found, but
    left unchanged if the option is not found.
 
-   To have a long-named option do something other than set an `int' to
-   a compiled-in constant, such as set a value from `optarg', set the
-   option's `flag' field to zero and its `val' field to a nonzero
+   To have a long-named option do something other than set an 'int' to
+   a compiled-in constant, such as set a value from 'optarg', set the
+   option's 'flag' field to zero and its 'val' field to a nonzero
    value (the equivalent single-letter option character, if there is
-   one).  For long options that have a zero `flag' field, `getopt'
-   returns the contents of the `val' field.  */
+   one).  For long options that have a zero 'flag' field, 'getopt'
+   returns the contents of the 'val' field.  */
 
 # if !GNULIB_defined_struct_option
 struct option
@@ -194,7 +194,7 @@ struct option
 #  define GNULIB_defined_struct_option 1
 # endif
 
-/* Names for the values of the `has_arg' field of `struct option'.  */
+/* Names for the values of the 'has_arg' field of 'struct option'.  */
 
 # define no_argument            0
 # define required_argument      1
@@ -208,23 +208,23 @@ struct option
 
    Return the option character from OPTS just read.  Return -1 when
    there are no more options.  For unrecognized options, or options
-   missing arguments, `optopt' is set to the option letter, and '?' is
+   missing arguments, 'optopt' is set to the option letter, and '?' is
    returned.
 
    The OPTS string is a list of characters which are recognized option
    letters, optionally followed by colons, specifying that that letter
-   takes an argument, to be placed in `optarg'.
+   takes an argument, to be placed in 'optarg'.
 
    If a letter in OPTS is followed by two colons, its argument is
-   optional.  This behavior is specific to the GNU `getopt'.
+   optional.  This behavior is specific to the GNU 'getopt'.
 
-   The argument `--' causes premature termination of argument
-   scanning, explicitly telling `getopt' that there are no more
+   The argument '--' causes premature termination of argument
+   scanning, explicitly telling 'getopt' that there are no more
    options.
 
-   If OPTS begins with `-', then non-option arguments are treated as
+   If OPTS begins with '-', then non-option arguments are treated as
    arguments to the option '\1'.  This behavior is specific to the GNU
-   `getopt'.  If OPTS begins with `+', or POSIXLY_CORRECT is set in
+   'getopt'.  If OPTS begins with '+', or POSIXLY_CORRECT is set in
    the environment, then do not permute arguments.  */
 
 extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
diff --git a/gl/getopt1.c b/gl/getopt1.c
index 3656802..fb2a8f5 100644
--- a/gl/getopt1.c
+++ b/gl/getopt1.c
@@ -1,5 +1,5 @@
 /* getopt_long and getopt_long_only entry points for GNU getopt.
-   Copyright (C) 1987-1994, 1996-1998, 2004, 2006, 2009-2011 Free Software
+   Copyright (C) 1987-1994, 1996-1998, 2004, 2006, 2009-2012 Free Software
    Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -141,11 +141,11 @@ main (int argc, char **argv)
           break;
 
         case 'c':
-          printf ("option c with value `%s'\n", optarg);
+          printf ("option c with value '%s'\n", optarg);
           break;
 
         case 'd':
-          printf ("option d with value `%s'\n", optarg);
+          printf ("option d with value '%s'\n", optarg);
           break;
 
         case '?':
diff --git a/gl/getopt_int.h b/gl/getopt_int.h
index 9f0c713..2da020c 100644
--- a/gl/getopt_int.h
+++ b/gl/getopt_int.h
@@ -1,5 +1,5 @@
 /* Internal declarations for getopt.
-   Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2011 Free Software
+   Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2012 Free Software
    Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -40,7 +40,7 @@ extern int _getopt_internal (int ___argc, char **___argv,
    stop option processing when the first non-option is seen.
    This is what Unix does.
    This mode of operation is selected by either setting the environment
-   variable POSIXLY_CORRECT, or using `+' as the first character
+   variable POSIXLY_CORRECT, or using '+' as the first character
    of the list of option characters, or by calling getopt.
 
    PERMUTE is the default.  We permute the contents of ARGV as we
@@ -52,12 +52,12 @@ extern int _getopt_internal (int ___argc, char **___argv,
    written to expect options and other ARGV-elements in any order
    and that care about the ordering of the two.  We describe each
    non-option ARGV-element as if it were the argument of an option
-   with character code 1.  Using `-' as the first character of the
+   with character code 1.  Using '-' as the first character of the
    list of option characters selects this mode of operation.
 
-   The special argument `--' forces an end of option-scanning regardless
-   of the value of `ordering'.  In the case of RETURN_IN_ORDER, only
-   `--' can cause `getopt' to return -1 with `optind' != ARGC.  */
+   The special argument '--' forces an end of option-scanning regardless
+   of the value of 'ordering'.  In the case of RETURN_IN_ORDER, only
+   '--' can cause 'getopt' to return -1 with 'optind' != ARGC.  */
 
 enum __ord
   {
@@ -99,8 +99,8 @@ struct _getopt_data
   /* Handle permutation of arguments.  */
 
   /* Describe the part of ARGV that contains non-options that have
-     been skipped.  `first_nonopt' is the index in ARGV of the first
-     of them; `last_nonopt' is the index after the last of them.  */
+     been skipped.  'first_nonopt' is the index in ARGV of the first
+     of them; 'last_nonopt' is the index after the last of them.  */
 
   int __first_nonopt;
   int __last_nonopt;
diff --git a/gl/getpass.c b/gl/getpass.c
index fb38348..25f1e18 100644
--- a/gl/getpass.c
+++ b/gl/getpass.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992-2001, 2003-2007, 2009-2011 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2001, 2003-2007, 2009-2012 Free Software Foundation, Inc.
 
    This file is part of the GNU C Library.
 
@@ -192,7 +192,6 @@ getpass (const char *prompt)
   char getpassbuf[PASS_MAX + 1];
   size_t i = 0;
   int c;
-  int use_getc = 0;
 
   if (prompt)
     {
@@ -202,20 +201,8 @@ getpass (const char *prompt)
 
   for (;;)
     {
-      if (use_getc)
-        c = getc (stdin);
-      else
-        {
-          c = _getch ();
-          if (c == -1)
-            {
-              /* Under Wine, _getch always returns -1.  Fall back to
-                 using getc.  */
-              use_getc = 1;
-              continue;
-            }
-        }
-      if (c == '\n' || c == '\r')
+      c = _getch ();
+      if (c == '\r')
         {
           getpassbuf[i] = '\0';
           break;
@@ -232,7 +219,7 @@ getpass (const char *prompt)
         }
     }
 
-  if (prompt && !use_getc)
+  if (prompt)
     {
       fputs ("\r\n", stderr);
       fflush (stderr);
diff --git a/gl/getpass.h b/gl/getpass.h
index f1e67b5..0d923c6 100644
--- a/gl/getpass.h
+++ b/gl/getpass.h
@@ -1,5 +1,5 @@
 /* getpass.h -- Read a password of arbitrary length from /dev/tty or stdin.
-   Copyright (C) 2004, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2009-2012 Free Software Foundation, Inc.
    Contributed by Simon Josefsson <address@hidden>, 2004.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/gl/gettext.h b/gl/gettext.h
index 88d9867..f018a2e 100644
--- a/gl/gettext.h
+++ b/gl/gettext.h
@@ -1,5 +1,5 @@
 /* Convenience header for conditional use of GNU <libintl.h>.
-   Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2011 Free Software
+   Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2012 Free Software
    Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
@@ -178,4 +178,10 @@ npgettext_aux (const char *domain,
     return translation;
 }
 
+/* The same thing extended for non-constant arguments.  Here MSGCTXT and MSGID
+   can be arbitrary expressions.  But for string literals these macros are
+   less efficient than those above.  */
+
+#include <string.h>
+
 #endif /* _LIBGETTEXT_H */
diff --git a/gl/iconv.c b/gl/iconv.c
index 8928376..d929a9b 100644
--- a/gl/iconv.c
+++ b/gl/iconv.c
@@ -1,5 +1,5 @@
 /* Character set conversion.
-   Copyright (C) 1999-2001, 2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 1999-2001, 2007, 2009-2012 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
diff --git a/gl/iconv.in.h b/gl/iconv.in.h
index 83ca719..bce6fd3 100644
--- a/gl/iconv.in.h
+++ b/gl/iconv.in.h
@@ -1,6 +1,6 @@
 /* A GNU-like <iconv.h>.
 
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
diff --git a/gl/iconv_close.c b/gl/iconv_close.c
index 72cbf88..4beec07 100644
--- a/gl/iconv_close.c
+++ b/gl/iconv_close.c
@@ -1,5 +1,5 @@
 /* Character set conversion.
-   Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2012 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
diff --git a/gl/iconv_open.c b/gl/iconv_open.c
index e857cbb..d1e08d5 100644
--- a/gl/iconv_open.c
+++ b/gl/iconv_open.c
@@ -1,5 +1,5 @@
 /* Character set conversion.
-   Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2012 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
@@ -57,7 +57,7 @@ rpl_iconv_open (const char *tocode, const char *fromcode)
      iconv() to these encoding inserts a BOM, which is wrong.
      We do not need to handle conversion between arbitrary encodings and
      UTF-{16,32}{BE,LE}, because the 'striconveh' module implements two-step
-     conversion throough UTF-8.
+     conversion through UTF-8.
      The _ICONV_* constants are chosen to be disjoint from any iconv_t
      returned by the system's iconv_open() functions.  Recall that iconv_t
      is a scalar type.  */
diff --git a/gl/inet_ntop.c b/gl/inet_ntop.c
index c1b3b70..ab3c1ff 100644
--- a/gl/inet_ntop.c
+++ b/gl/inet_ntop.c
@@ -1,6 +1,6 @@
 /* inet_ntop.c -- convert IPv4 and IPv6 addresses from binary to text form
 
-   Copyright (C) 2005-2006, 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2005-2006, 2008-2012 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
@@ -38,12 +38,35 @@
 /* Specification.  */
 #include <arpa/inet.h>
 
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
+/* Use this to suppress gcc's "...may be used before initialized" warnings.
+   Beware: The Code argument must not contain commas.  */
+#ifndef IF_LINT
+# ifdef lint
+#  define IF_LINT(Code) Code
+# else
+#  define IF_LINT(Code) /* empty */
+# endif
+#endif
+
+#if HAVE_DECL_INET_NTOP
+
+# undef inet_ntop
+
+const char *
+rpl_inet_ntop (int af, const void *restrict src,
+               char *restrict dst, socklen_t cnt)
+{
+  return inet_ntop (af, src, dst, cnt);
+}
 
-#define NS_IN6ADDRSZ 16
-#define NS_INT16SZ 2
+#else
+
+# include <stdio.h>
+# include <string.h>
+# include <errno.h>
+
+# define NS_IN6ADDRSZ 16
+# define NS_INT16SZ 2
 
 /*
  * WARNING: Don't even consider trying to compile this on a system where
@@ -52,16 +75,16 @@
 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
+# if HAVE_IPV6
 static const char *inet_ntop6 (const unsigned char *src, char *dst, socklen_t 
size);
-#endif
+# endif
 
 
 /* char *
  * inet_ntop(af, src, dst, size)
  *      convert a network format address to presentation format.
  * return:
- *      pointer to presentation format address (`dst'), or NULL (see errno).
+ *      pointer to presentation format address ('dst'), or NULL (see errno).
  * author:
  *      Paul Vixie, 1996.
  */
@@ -71,15 +94,15 @@ inet_ntop (int af, const void *restrict src,
 {
   switch (af)
     {
-#if HAVE_IPV4
+# if HAVE_IPV4
     case AF_INET:
       return (inet_ntop4 (src, dst, cnt));
-#endif
+# endif
 
-#if HAVE_IPV6
+# if HAVE_IPV6
     case AF_INET6:
       return (inet_ntop6 (src, dst, cnt));
-#endif
+# endif
 
     default:
       errno = EAFNOSUPPORT;
@@ -92,7 +115,7 @@ inet_ntop (int af, const void *restrict src,
  * inet_ntop4(src, dst, size)
  *      format an IPv4 address
  * return:
- *      `dst' (as a const)
+ *      'dst' (as a const)
  * notes:
  *      (1) uses no statics
  *      (2) takes a u_char* not an in_addr as input
@@ -118,7 +141,7 @@ inet_ntop4 (const unsigned char *src, char *dst, socklen_t 
size)
   return strcpy (dst, tmp);
 }
 
-#if HAVE_IPV6
+# if HAVE_IPV6
 
 /* const char *
  * inet_ntop6(src, dst, size)
@@ -154,6 +177,8 @@ inet_ntop6 (const unsigned char *src, char *dst, socklen_t 
size)
     words[i / 2] = (src[i] << 8) | src[i + 1];
   best.base = -1;
   cur.base = -1;
+  IF_LINT(best.len = 0);
+  IF_LINT(cur.len = 0);
   for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++)
     {
       if (words[i] == 0)
@@ -231,4 +256,6 @@ inet_ntop6 (const unsigned char *src, char *dst, socklen_t 
size)
   return strcpy (dst, tmp);
 }
 
+# endif
+
 #endif
diff --git a/gl/intprops.h b/gl/intprops.h
index 1f6a539..2485c78 100644
--- a/gl/intprops.h
+++ b/gl/intprops.h
@@ -1,6 +1,6 @@
 /* intprops.h -- properties of integer types
 
-   Copyright (C) 2001-2005, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2001-2005, 2009-2012 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
diff --git a/gl/itold.c b/gl/itold.c
new file mode 100644
index 0000000..95ff7e1
--- /dev/null
+++ b/gl/itold.c
@@ -0,0 +1,28 @@
+/* Replacement for 'int' to 'long double' conversion routine.
+   Copyright (C) 2011-2012 Free Software Foundation, Inc.
+   Written by Bruno Haible <address@hidden>, 2011.
+
+   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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <float.h>
+
+void
+_Qp_itoq (long double *result, int a)
+{
+  /* Convert from 'int' to 'double', then from 'double' to 'long double'.  */
+  *result = (double) a;
+}
diff --git a/gl/localcharset.c b/gl/localcharset.c
index 96739c7..1b164cc 100644
--- a/gl/localcharset.c
+++ b/gl/localcharset.c
@@ -1,6 +1,6 @@
 /* Determine a canonical name for the current locale's character encoding.
 
-   Copyright (C) 2000-2006, 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2000-2006, 2008-2012 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
@@ -34,7 +34,7 @@
 #endif
 
 #if defined _WIN32 || defined __WIN32__
-# define WIN32_NATIVE
+# define WINDOWS_NATIVE
 #endif
 
 #if defined __EMX__
@@ -44,7 +44,7 @@
 # endif
 #endif
 
-#if !defined WIN32_NATIVE
+#if !defined WINDOWS_NATIVE
 # include <unistd.h>
 # if HAVE_LANGINFO_CODESET
 #  include <langinfo.h>
@@ -57,7 +57,7 @@
 #  define WIN32_LEAN_AND_MEAN
 #  include <windows.h>
 # endif
-#elif defined WIN32_NATIVE
+#elif defined WINDOWS_NATIVE
 # define WIN32_LEAN_AND_MEAN
 # include <windows.h>
 #endif
@@ -83,7 +83,7 @@
 #endif
 
 #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined 
__EMX__ || defined __DJGPP__
-  /* Win32, Cygwin, OS/2, DOS */
+  /* Native Windows, Cygwin, OS/2, DOS */
 # define ISSLASH(C) ((C) == '/' || (C) == '\\')
 #endif
 
@@ -123,7 +123,7 @@ get_charset_aliases (void)
   cp = charset_aliases;
   if (cp == NULL)
     {
-#if !(defined DARWIN7 || defined VMS || defined WIN32_NATIVE || defined 
__CYGWIN__)
+#if !(defined DARWIN7 || defined VMS || defined WINDOWS_NATIVE || defined 
__CYGWIN__)
       const char *dir;
       const char *base = "charset.alias";
       char *file_name;
@@ -308,7 +308,7 @@ get_charset_aliases (void)
            "DECKOREAN" "\0" "EUC-KR" "\0";
 # endif
 
-# if defined WIN32_NATIVE || defined __CYGWIN__
+# if defined WINDOWS_NATIVE || defined __CYGWIN__
       /* To avoid the troubles of installing a separate file in the same
          directory as the DLL and of retrieving the DLL's directory at
          runtime, simply inline the aliases here.  */
@@ -360,7 +360,7 @@ locale_charset (void)
   const char *codeset;
   const char *aliases;
 
-#if !(defined WIN32_NATIVE || defined OS2)
+#if !(defined WINDOWS_NATIVE || defined OS2)
 
 # if HAVE_LANGINFO_CODESET
 
@@ -407,10 +407,10 @@ locale_charset (void)
             }
         }
 
-      /* Woe32 has a function returning the locale's codepage as a number:
-         GetACP().  This encoding is used by Cygwin, unless the user has set
-         the environment variable CYGWIN=codepage:oem (which very few people
-         do).
+      /* The Windows API has a function returning the locale's codepage as a
+         number: GetACP().  This encoding is used by Cygwin, unless the user
+         has set the environment variable CYGWIN=codepage:oem (which very few
+         people do).
          Output directed to console windows needs to be converted (to
          GetOEMCP() if the console is using a raster font, or to
          GetConsoleOutputCP() if it is using a TrueType font).  Cygwin does
@@ -453,12 +453,12 @@ locale_charset (void)
 
 # endif
 
-#elif defined WIN32_NATIVE
+#elif defined WINDOWS_NATIVE
 
   static char buf[2 + 10 + 1];
 
-  /* Woe32 has a function returning the locale's codepage as a number:
-     GetACP().
+  /* The Windows API has a function returning the locale's codepage as a
+     number: GetACP().
      When the output goes to a console window, it needs to be provided in
      GetOEMCP() encoding if the console is using a raster font, or in
      GetConsoleOutputCP() encoding if it is using a TrueType font.
diff --git a/gl/localcharset.h b/gl/localcharset.h
index edbb13b..bc5c1e0 100644
--- a/gl/localcharset.h
+++ b/gl/localcharset.h
@@ -1,5 +1,5 @@
 /* Determine a canonical name for the current locale's character encoding.
-   Copyright (C) 2000-2003, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2000-2003, 2009-2012 Free Software Foundation, Inc.
    This file is part of the GNU CHARSET Library.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/gl/lseek.c b/gl/lseek.c
index 8339044..5433678 100644
--- a/gl/lseek.c
+++ b/gl/lseek.c
@@ -1,5 +1,5 @@
 /* An lseek() function that detects pipes.
-   Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2012 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
@@ -24,6 +24,8 @@
 /* Windows platforms.  */
 /* Get GetFileType.  */
 # include <windows.h>
+/* Get _get_osfhandle.  */
+# include "msvc-nothrow.h"
 #else
 # include <sys/stat.h>
 #endif
diff --git a/gl/m4/00gnulib.m4 b/gl/m4/00gnulib.m4
index 7feed46..d978cb8 100644
--- a/gl/m4/00gnulib.m4
+++ b/gl/m4/00gnulib.m4
@@ -1,5 +1,5 @@
 # 00gnulib.m4 serial 2
-dnl Copyright (C) 2009-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2009-2012 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.
diff --git a/gl/m4/alloca.m4 b/gl/m4/alloca.m4
index 891fc8b..656924b 100644
--- a/gl/m4/alloca.m4
+++ b/gl/m4/alloca.m4
@@ -1,5 +1,5 @@
-# alloca.m4 serial 12
-dnl Copyright (C) 2002-2004, 2006-2007, 2009-2011 Free Software Foundation,
+# alloca.m4 serial 14
+dnl Copyright (C) 2002-2004, 2006-2007, 2009-2012 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -53,8 +53,8 @@ m4_version_prereq([2.69], [] ,[
 
 # _AC_LIBOBJ_ALLOCA
 # -----------------
-# Set up the LIBOBJ replacement of `alloca'.  Well, not exactly
-# AC_LIBOBJ since we actually set the output variable `ALLOCA'.
+# Set up the LIBOBJ replacement of 'alloca'.  Well, not exactly
+# AC_LIBOBJ since we actually set the output variable 'ALLOCA'.
 # Nevertheless, for Automake, AC_LIBSOURCES it.
 m4_define([_AC_LIBOBJ_ALLOCA],
 [# The SVR3 libPW and SVR4 libucb both contain incompatible functions
@@ -63,9 +63,9 @@ m4_define([_AC_LIBOBJ_ALLOCA],
 # use ar to extract alloca.o from them instead of compiling alloca.c.
 AC_LIBSOURCES(alloca.c)
 AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.$ac_objext])dnl
-AC_DEFINE(C_ALLOCA, 1, [Define to 1 if using `alloca.c'.])
+AC_DEFINE(C_ALLOCA, 1, [Define to 1 if using 'alloca.c'.])
 
-AC_CACHE_CHECK(whether `alloca.c' needs Cray hooks, ac_cv_os_cray,
+AC_CACHE_CHECK(whether 'alloca.c' needs Cray hooks, ac_cv_os_cray,
 [AC_EGREP_CPP(webecray,
 [#if defined CRAY && ! defined CRAY2
 webecray
@@ -76,17 +76,17 @@ wenotbecray
 if test $ac_cv_os_cray = yes; then
   for ac_func in _getb67 GETB67 getb67; do
     AC_CHECK_FUNC($ac_func,
-                 [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func,
-                                     [Define to one of `_getb67', `GETB67',
-                                      `getb67' for Cray-2 and Cray-YMP
-                                      systems. This function is required for
-                                      `alloca.c' support on those systems.])
+                  [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func,
+                                      [Define to one of '_getb67', 'GETB67',
+                                       'getb67' for Cray-2 and Cray-YMP
+                                       systems. This function is required for
+                                       'alloca.c' support on those systems.])
     break])
   done
 fi
 
 AC_CACHE_CHECK([stack direction for C alloca],
-              [ac_cv_c_stack_direction],
+               [ac_cv_c_stack_direction],
 [AC_RUN_IFELSE([AC_LANG_SOURCE(
 [AC_INCLUDES_DEFAULT
 int
@@ -105,16 +105,16 @@ main (int argc, char **argv)
 {
   return find_stack_direction (0, argc + !argv + 20) < 0;
 }])],
-              [ac_cv_c_stack_direction=1],
-              [ac_cv_c_stack_direction=-1],
-              [ac_cv_c_stack_direction=0])])
+               [ac_cv_c_stack_direction=1],
+               [ac_cv_c_stack_direction=-1],
+               [ac_cv_c_stack_direction=0])])
 AH_VERBATIM([STACK_DIRECTION],
 [/* If using the C implementation of alloca, define if you know the
    direction of stack growth for your system; otherwise it will be
    automatically deduced at runtime.
-       STACK_DIRECTION > 0 => grows toward higher addresses
-       STACK_DIRECTION < 0 => grows toward lower addresses
-       STACK_DIRECTION = 0 => direction of growth unknown */
+        STACK_DIRECTION > 0 => grows toward higher addresses
+        STACK_DIRECTION < 0 => grows toward lower addresses
+        STACK_DIRECTION = 0 => direction of growth unknown */
 @%:@undef STACK_DIRECTION])dnl
 AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
 ])# _AC_LIBOBJ_ALLOCA
diff --git a/gl/m4/arpa_inet_h.m4 b/gl/m4/arpa_inet_h.m4
index 6dc0fdb..36915d1 100644
--- a/gl/m4/arpa_inet_h.m4
+++ b/gl/m4/arpa_inet_h.m4
@@ -1,5 +1,5 @@
-# arpa_inet_h.m4 serial 12
-dnl Copyright (C) 2006, 2008-2011 Free Software Foundation, Inc.
+# arpa_inet_h.m4 serial 13
+dnl Copyright (C) 2006, 2008-2012 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.
@@ -52,4 +52,6 @@ AC_DEFUN([gl_ARPA_INET_H_DEFAULTS],
   dnl Assume proper GNU behavior unless another module says otherwise.
   HAVE_DECL_INET_NTOP=1;  AC_SUBST([HAVE_DECL_INET_NTOP])
   HAVE_DECL_INET_PTON=1;  AC_SUBST([HAVE_DECL_INET_PTON])
+  REPLACE_INET_NTOP=0;    AC_SUBST([REPLACE_INET_NTOP])
+  REPLACE_INET_PTON=0;    AC_SUBST([REPLACE_INET_PTON])
 ])
diff --git a/gl/m4/autobuild.m4 b/gl/m4/autobuild.m4
index 04971d4..284dc60 100644
--- a/gl/m4/autobuild.m4
+++ b/gl/m4/autobuild.m4
@@ -1,5 +1,5 @@
 # autobuild.m4 serial 7
-dnl Copyright (C) 2004, 2006-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2004, 2006-2012 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.
diff --git a/gl/m4/btowc.m4 b/gl/m4/btowc.m4
index 2b845e7..e565321 100644
--- a/gl/m4/btowc.m4
+++ b/gl/m4/btowc.m4
@@ -1,5 +1,5 @@
 # btowc.m4 serial 10
-dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2008-2012 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.
diff --git a/gl/m4/close.m4 b/gl/m4/close.m4
index fc13138..379e70d 100644
--- a/gl/m4/close.m4
+++ b/gl/m4/close.m4
@@ -1,26 +1,33 @@
-# close.m4 serial 5
-dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
+# close.m4 serial 8
+dnl Copyright (C) 2008-2012 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_FUNC_CLOSE],
 [
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+  AC_REQUIRE([gl_MSVC_INVAL])
+  if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
+    REPLACE_CLOSE=1
+  fi
   m4_ifdef([gl_PREREQ_SYS_H_WINSOCK2], [
     gl_PREREQ_SYS_H_WINSOCK2
     if test $UNISTD_H_HAVE_WINSOCK2_H = 1; then
       dnl Even if the 'socket' module is not used here, another part of the
       dnl application may use it and pass file descriptors that refer to
       dnl sockets to the close() function. So enable the support for sockets.
-      gl_REPLACE_CLOSE
+      REPLACE_CLOSE=1
+    fi
+  ])
+  dnl Replace close() for supporting the gnulib-defined fchdir() function,
+  dnl to keep fchdir's bookkeeping up-to-date.
+  m4_ifdef([gl_FUNC_FCHDIR], [
+    if test $REPLACE_CLOSE = 0; then
+      gl_TEST_FCHDIR
+      if test $HAVE_FCHDIR = 0; then
+        REPLACE_CLOSE=1
+      fi
     fi
   ])
-])
-
-AC_DEFUN([gl_REPLACE_CLOSE],
-[
-  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
-  REPLACE_CLOSE=1
-  AC_LIBOBJ([close])
-  gl_REPLACE_FCLOSE
 ])
diff --git a/gl/m4/codeset.m4 b/gl/m4/codeset.m4
index da73552..cf53d24 100644
--- a/gl/m4/codeset.m4
+++ b/gl/m4/codeset.m4
@@ -1,5 +1,5 @@
 # codeset.m4 serial 5 (gettext-0.18.2)
-dnl Copyright (C) 2000-2002, 2006, 2008-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2000-2002, 2006, 2008-2012 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.
diff --git a/gl/m4/configmake.m4 b/gl/m4/configmake.m4
index a029823..8c82371 100644
--- a/gl/m4/configmake.m4
+++ b/gl/m4/configmake.m4
@@ -1,5 +1,5 @@
 # configmake.m4 serial 1
-dnl Copyright (C) 2010-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2010-2012 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.
diff --git a/gl/m4/dup2.m4 b/gl/m4/dup2.m4
index 8d7f62c..dec27fa 100644
--- a/gl/m4/dup2.m4
+++ b/gl/m4/dup2.m4
@@ -1,5 +1,5 @@
-#serial 13
-dnl Copyright (C) 2002, 2005, 2007, 2009-2011 Free Software Foundation, Inc.
+#serial 17
+dnl Copyright (C) 2002, 2005, 2007, 2009-2012 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.
@@ -12,7 +12,6 @@ AC_DEFUN([gl_FUNC_DUP2],
     AC_CHECK_FUNCS_ONCE([dup2])
     if test $ac_cv_func_dup2 = no; then
       HAVE_DUP2=0
-      AC_LIBOBJ([dup2])
     fi
   ], [
     AC_DEFINE([HAVE_DUP2], [1], [Define to 1 if you have the 'dup2' function.])
@@ -60,17 +59,20 @@ AC_DEFUN([gl_FUNC_DUP2],
          esac])
       ])
     if test "$gl_cv_func_dup2_works" = no; then
-      gl_REPLACE_DUP2
+      REPLACE_DUP2=1
     fi
   fi
+  dnl Replace dup2() for supporting the gnulib-defined fchdir() function,
+  dnl to keep fchdir's bookkeeping up-to-date.
+  m4_ifdef([gl_FUNC_FCHDIR], [
+    gl_TEST_FCHDIR
+    if test $HAVE_FCHDIR = 0; then
+      if test $HAVE_DUP2 = 1; then
+        REPLACE_DUP2=1
+      fi
+    fi
+  ])
 ])
 
-AC_DEFUN([gl_REPLACE_DUP2],
-[
-  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
-  AC_CHECK_FUNCS_ONCE([dup2])
-  if test $ac_cv_func_dup2 = yes; then
-    REPLACE_DUP2=1
-  fi
-  AC_LIBOBJ([dup2])
-])
+# Prerequisites of lib/dup2.c.
+AC_DEFUN([gl_PREREQ_DUP2], [])
diff --git a/gl/m4/eealloc.m4 b/gl/m4/eealloc.m4
index 3006c48..75f17e2 100644
--- a/gl/m4/eealloc.m4
+++ b/gl/m4/eealloc.m4
@@ -1,5 +1,5 @@
 # eealloc.m4 serial 2
-dnl Copyright (C) 2003, 2009-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2003, 2009-2012 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.
diff --git a/gl/m4/environ.m4 b/gl/m4/environ.m4
index 7457ad1..8eb57c9 100644
--- a/gl/m4/environ.m4
+++ b/gl/m4/environ.m4
@@ -1,5 +1,5 @@
-# environ.m4 serial 5
-dnl Copyright (C) 2001-2004, 2006-2011 Free Software Foundation, Inc.
+# environ.m4 serial 6
+dnl Copyright (C) 2001-2004, 2006-2012 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.
@@ -9,7 +9,16 @@ AC_DEFUN_ONCE([gl_ENVIRON],
   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
   dnl Persuade glibc <unistd.h> to declare environ.
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
-  gt_CHECK_VAR_DECL([#include <unistd.h>], environ)
+
+  AC_CHECK_HEADERS_ONCE([unistd.h])
+  gt_CHECK_VAR_DECL(
+    [#if HAVE_UNISTD_H
+     #include <unistd.h>
+     #endif
+     /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>.  
*/
+     #include <stdlib.h>
+    ],
+    [environ])
   if test $gt_cv_var_environ_declaration != yes; then
     HAVE_DECL_ENVIRON=0
   fi
diff --git a/gl/m4/errno_h.m4 b/gl/m4/errno_h.m4
index a6d37f3..4f0bb83 100644
--- a/gl/m4/errno_h.m4
+++ b/gl/m4/errno_h.m4
@@ -1,5 +1,5 @@
-# errno_h.m4 serial 9
-dnl Copyright (C) 2004, 2006, 2008-2011 Free Software Foundation, Inc.
+# errno_h.m4 serial 10
+dnl Copyright (C) 2004, 2006, 2008-2012 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.
@@ -34,6 +34,12 @@ booboo
 #if !defined ENOTSUP
 booboo
 #endif
+#if !defined ENETRESET
+booboo
+#endif
+#if !defined ECONNABORTED
+booboo
+#endif
 #if !defined ESTALE
 booboo
 #endif
diff --git a/gl/m4/error.m4 b/gl/m4/error.m4
index e7022fe..5d9c70a 100644
--- a/gl/m4/error.m4
+++ b/gl/m4/error.m4
@@ -1,6 +1,6 @@
 #serial 14
 
-# Copyright (C) 1996-1998, 2001-2004, 2009-2011 Free Software Foundation, Inc.
+# Copyright (C) 1996-1998, 2001-2004, 2009-2012 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
diff --git a/gl/m4/exponentd.m4 b/gl/m4/exponentd.m4
new file mode 100644
index 0000000..0ae4ccf
--- /dev/null
+++ b/gl/m4/exponentd.m4
@@ -0,0 +1,116 @@
+# exponentd.m4 serial 3
+dnl Copyright (C) 2007-2008, 2010-2012 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_DOUBLE_EXPONENT_LOCATION],
+[
+  AC_CACHE_CHECK([where to find the exponent in a 'double'],
+    [gl_cv_cc_double_expbit0],
+    [
+      AC_RUN_IFELSE(
+        [AC_LANG_SOURCE([[
+#include <float.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
+#define NWORDS \
+  ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
+typedef union { double value; unsigned int word[NWORDS]; } memory_double;
+static unsigned int ored_words[NWORDS];
+static unsigned int anded_words[NWORDS];
+static void add_to_ored_words (double x)
+{
+  memory_double m;
+  size_t i;
+  /* Clear it first, in case sizeof (double) < sizeof (memory_double).  */
+  memset (&m, 0, sizeof (memory_double));
+  m.value = x;
+  for (i = 0; i < NWORDS; i++)
+    {
+      ored_words[i] |= m.word[i];
+      anded_words[i] &= m.word[i];
+    }
+}
+int main ()
+{
+  size_t j;
+  FILE *fp = fopen ("conftest.out", "w");
+  if (fp == NULL)
+    return 1;
+  for (j = 0; j < NWORDS; j++)
+    anded_words[j] = ~ (unsigned int) 0;
+  add_to_ored_words (0.25);
+  add_to_ored_words (0.5);
+  add_to_ored_words (1.0);
+  add_to_ored_words (2.0);
+  add_to_ored_words (4.0);
+  /* Remove bits that are common (e.g. if representation of the first mantissa
+     bit is explicit).  */
+  for (j = 0; j < NWORDS; j++)
+    ored_words[j] &= ~anded_words[j];
+  /* Now find the nonzero word.  */
+  for (j = 0; j < NWORDS; j++)
+    if (ored_words[j] != 0)
+      break;
+  if (j < NWORDS)
+    {
+      size_t i;
+      for (i = j + 1; i < NWORDS; i++)
+        if (ored_words[i] != 0)
+          {
+            fprintf (fp, "unknown");
+            return (fclose (fp) != 0);
+          }
+      for (i = 0; ; i++)
+        if ((ored_words[j] >> i) & 1)
+          {
+            fprintf (fp, "word %d bit %d", (int) j, (int) i);
+            return (fclose (fp) != 0);
+          }
+    }
+  fprintf (fp, "unknown");
+  return (fclose (fp) != 0);
+}
+        ]])],
+        [gl_cv_cc_double_expbit0=`cat conftest.out`],
+        [gl_cv_cc_double_expbit0="unknown"],
+        [
+          dnl On ARM, there are two 'double' floating-point formats, used by
+          dnl different sets of instructions: The older FPA instructions assume
+          dnl that they are stored in big-endian word order, while the words
+          dnl (like integer types) are stored in little-endian byte order.
+          dnl The newer VFP instructions assume little-endian order
+          dnl consistently.
+          AC_EGREP_CPP([mixed_endianness], [
+#if defined arm || defined __arm || defined __arm__
+  mixed_endianness
+#endif
+            ],
+            [gl_cv_cc_double_expbit0="unknown"],
+            [
+              pushdef([AC_MSG_CHECKING],[:])dnl
+              pushdef([AC_MSG_RESULT],[:])dnl
+              pushdef([AC_MSG_RESULT_UNQUOTED],[:])dnl
+              AC_C_BIGENDIAN(
+                [gl_cv_cc_double_expbit0="word 0 bit 20"],
+                [gl_cv_cc_double_expbit0="word 1 bit 20"],
+                [gl_cv_cc_double_expbit0="unknown"])
+              popdef([AC_MSG_RESULT_UNQUOTED])dnl
+              popdef([AC_MSG_RESULT])dnl
+              popdef([AC_MSG_CHECKING])dnl
+            ])
+        ])
+      rm -f conftest.out
+    ])
+  case "$gl_cv_cc_double_expbit0" in
+    word*bit*)
+      word=`echo "$gl_cv_cc_double_expbit0" | sed -e 's/word //' -e 's/ 
bit.*//'`
+      bit=`echo "$gl_cv_cc_double_expbit0" | sed -e 's/word.*bit //'`
+      AC_DEFINE_UNQUOTED([DBL_EXPBIT0_WORD], [$word],
+        [Define as the word index where to find the exponent of 'double'.])
+      AC_DEFINE_UNQUOTED([DBL_EXPBIT0_BIT], [$bit],
+        [Define as the bit index in the word where to find bit 0 of the 
exponent of 'double'.])
+      ;;
+  esac
+])
diff --git a/gl/m4/extensions.m4 b/gl/m4/extensions.m4
index 1330503..0bfaef6 100644
--- a/gl/m4/extensions.m4
+++ b/gl/m4/extensions.m4
@@ -1,7 +1,7 @@
-# serial 9  -*- Autoconf -*-
+# serial 11  -*- Autoconf -*-
 # Enable extensions on systems that normally disable them.
 
-# Copyright (C) 2003, 2006-2011 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2006-2012 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -43,7 +43,7 @@ AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
   AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=])
   if test "$MINIX" = yes; then
     AC_DEFINE([_POSIX_SOURCE], [1],
-      [Define to 1 if you need to in order for `stat' and other
+      [Define to 1 if you need to in order for 'stat' and other
        things to work.])
     AC_DEFINE([_POSIX_1_SOURCE], [2],
       [Define to 2 if the system does not provide POSIX.1 features
@@ -67,6 +67,10 @@ AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
 #ifndef _ALL_SOURCE
 # undef _ALL_SOURCE
 #endif
+/* Enable general extensions on MacOS X.  */
+#ifndef _DARWIN_C_SOURCE
+# undef _DARWIN_C_SOURCE
+#endif
 /* Enable GNU extensions on systems that have them.  */
 #ifndef _GNU_SOURCE
 # undef _GNU_SOURCE
@@ -95,6 +99,7 @@ AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
   test $ac_cv_safe_to_define___extensions__ = yes &&
     AC_DEFINE([__EXTENSIONS__])
   AC_DEFINE([_ALL_SOURCE])
+  AC_DEFINE([_DARWIN_C_SOURCE])
   AC_DEFINE([_GNU_SOURCE])
   AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
   AC_DEFINE([_TANDEM_SOURCE])
diff --git a/gl/m4/fclose.m4 b/gl/m4/fclose.m4
deleted file mode 100644
index 349b5f1..0000000
--- a/gl/m4/fclose.m4
+++ /dev/null
@@ -1,20 +0,0 @@
-# fclose.m4 serial 4
-dnl Copyright (C) 2008-2011 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_FUNC_FCLOSE],
-[
-  gl_FUNC_FFLUSH_STDIN
-  if test $gl_cv_func_fflush_stdin = no; then
-    gl_REPLACE_FCLOSE
-  fi
-])
-
-AC_DEFUN([gl_REPLACE_FCLOSE],
-[
-  AC_REQUIRE([gl_STDIO_H_DEFAULTS])
-  REPLACE_FCLOSE=1
-  AC_LIBOBJ([fclose])
-])
diff --git a/gl/m4/fcntl-o.m4 b/gl/m4/fcntl-o.m4
index 88db07e..9862741 100644
--- a/gl/m4/fcntl-o.m4
+++ b/gl/m4/fcntl-o.m4
@@ -1,5 +1,5 @@
-# fcntl-o.m4 serial 3
-dnl Copyright (C) 2006, 2009-2011 Free Software Foundation, Inc.
+# fcntl-o.m4 serial 4
+dnl Copyright (C) 2006, 2009-2012 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.
@@ -17,12 +17,21 @@ AC_DEFUN([gl_FCNTL_O_FLAGS],
   m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],
     [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])],
     [AC_REQUIRE([AC_GNU_SOURCE])])
+
+  AC_CHECK_HEADERS_ONCE([unistd.h])
+  AC_CHECK_FUNCS_ONCE([symlink])
   AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
     [AC_RUN_IFELSE(
        [AC_LANG_PROGRAM(
           [[#include <sys/types.h>
            #include <sys/stat.h>
-           #include <unistd.h>
+           #if HAVE_UNISTD_H
+           # include <unistd.h>
+           #else /* on Windows with MSVC */
+           # include <io.h>
+           # include <stdlib.h>
+           # defined sleep(n) _sleep ((n) * 1000)
+           #endif
            #include <fcntl.h>
            #ifndef O_NOATIME
             #define O_NOATIME 0
@@ -38,6 +47,7 @@ AC_DEFUN([gl_FCNTL_O_FLAGS],
           ]],
           [[
             int result = !constants;
+            #if HAVE_SYMLINK
             {
               static char const sym[] = "conftest.sym";
               if (symlink (".", sym) != 0)
@@ -53,6 +63,7 @@ AC_DEFUN([gl_FCNTL_O_FLAGS],
                 }
               unlink (sym);
             }
+            #endif
             {
               static char const file[] = "confdefs.h";
               int fd = open (file, O_RDONLY | O_NOATIME);
diff --git a/gl/m4/fcntl_h.m4 b/gl/m4/fcntl_h.m4
index c466da4..cac28ae 100644
--- a/gl/m4/fcntl_h.m4
+++ b/gl/m4/fcntl_h.m4
@@ -1,6 +1,6 @@
-# serial 13
+# serial 15
 # Configure fcntl.h.
-dnl Copyright (C) 2006-2007, 2009-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2006-2007, 2009-2012 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.
@@ -13,6 +13,12 @@ AC_DEFUN([gl_FCNTL_H],
   AC_REQUIRE([gl_FCNTL_O_FLAGS])
   gl_NEXT_HEADERS([fcntl.h])
 
+  dnl Ensure the type pid_t gets defined.
+  AC_REQUIRE([AC_TYPE_PID_T])
+
+  dnl Ensure the type mode_t gets defined.
+  AC_REQUIRE([AC_TYPE_MODE_T])
+
   dnl Check for declarations of anything we want to poison if the
   dnl corresponding gnulib module is not in use, if it is not common
   dnl enough to be declared everywhere.
diff --git a/gl/m4/fdopen.m4 b/gl/m4/fdopen.m4
new file mode 100644
index 0000000..9ca9d2a
--- /dev/null
+++ b/gl/m4/fdopen.m4
@@ -0,0 +1,49 @@
+# fdopen.m4 serial 2
+dnl Copyright (C) 2011-2012 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_FUNC_FDOPEN],
+[
+  AC_REQUIRE([gl_STDIO_H_DEFAULTS])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_REQUIRE([gl_MSVC_INVAL])
+  if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
+    REPLACE_FDOPEN=1
+  else
+    dnl Test whether fdopen() sets errno when it fails due to a bad fd 
argument.
+    AC_CACHE_CHECK([whether fdopen sets errno], [gl_cv_func_fdopen_works],
+      [
+        AC_RUN_IFELSE(
+          [AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <errno.h>
+int
+main (void)
+{
+  FILE *fp;
+  errno = 0;
+  fp = fdopen (-1, "r");
+  if (fp != NULL)
+    return 1;
+  if (errno == 0)
+    return 2;
+  return 0;
+}]])],
+          [gl_cv_func_fdopen_works=yes],
+          [gl_cv_func_fdopen_works=no],
+          [case "$host_os" in
+             mingw*) gl_cv_func_fdopen_works="guessing no" ;;
+             *)      gl_cv_func_fdopen_works="guessing yes" ;;
+           esac
+          ])
+      ])
+    case "$gl_cv_func_fdopen_works" in
+      *no) REPLACE_FDOPEN=1 ;;
+    esac
+  fi
+])
+
+dnl Prerequisites of lib/fdopen.c.
+AC_DEFUN([gl_PREREQ_FDOPEN], [])
diff --git a/gl/m4/fflush.m4 b/gl/m4/fflush.m4
deleted file mode 100644
index a91ee0b..0000000
--- a/gl/m4/fflush.m4
+++ /dev/null
@@ -1,81 +0,0 @@
-# fflush.m4 serial 12
-
-# Copyright (C) 2007-2011 Free Software Foundation, Inc.
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-dnl From Eric Blake
-
-dnl Find out how to obey POSIX semantics of fflush(stdin) discarding
-dnl unread input on seekable streams, rather than C99 undefined semantics.
-
-AC_DEFUN([gl_FUNC_FFLUSH],
-[
-  AC_REQUIRE([gl_STDIO_H_DEFAULTS])
-  gl_FUNC_FFLUSH_STDIN
-  if test $gl_cv_func_fflush_stdin = no; then
-    REPLACE_FFLUSH=1
-  fi
-])
-
-dnl Determine whether fflush works on input streams.
-dnl Sets gl_cv_func_fflush_stdin.
-
-AC_DEFUN([gl_FUNC_FFLUSH_STDIN],
-[
-  AC_CACHE_CHECK([whether fflush works on input streams],
-    [gl_cv_func_fflush_stdin],
-    [echo hello world > conftest.txt
-     AC_RUN_IFELSE([AC_LANG_PROGRAM(
-       [[
-#include <stdio.h>
-#include <unistd.h>
-       ]], [[FILE *f = fopen ("conftest.txt", "r");
-         char buffer[10];
-         int fd;
-         int c;
-         if (f == NULL)
-           return 1;
-         fd = fileno (f);
-         if (fd < 0 || fread (buffer, 1, 5, f) != 5)
-           return 2;
-         /* For deterministic results, ensure f read a bigger buffer.  */
-         if (lseek (fd, 0, SEEK_CUR) == 5)
-           return 3;
-         /* POSIX requires fflush-fseek to set file offset of fd.  This fails
-            on BSD systems and on mingw.  */
-         if (fflush (f) != 0 || fseek (f, 0, SEEK_CUR) != 0)
-           return 4;
-         if (lseek (fd, 0, SEEK_CUR) != 5)
-           return 5;
-         /* Verify behaviour of fflush after ungetc. See
-            <http://www.opengroup.org/austin/aardvark/latest/xshbug3.txt>  */
-         /* Verify behaviour of fflush after a backup ungetc.  This fails on
-            mingw.  */
-         c = fgetc (f);
-         ungetc (c, f);
-         fflush (f);
-         if (fgetc (f) != c)
-           return 6;
-         /* Verify behaviour of fflush after a non-backup ungetc.  This fails
-            on glibc 2.8 and on BSD systems.  */
-         c = fgetc (f);
-         ungetc ('@', f);
-         fflush (f);
-         if (fgetc (f) != c)
-           return 7;
-         return 0;
-       ]])], [gl_cv_func_fflush_stdin=yes], [gl_cv_func_fflush_stdin=no],
-     [dnl Pessimistically assume fflush is broken.
-      gl_cv_func_fflush_stdin=no])
-     rm conftest.txt
-    ])
-])
-
-# Prerequisites of lib/fflush.c.
-AC_DEFUN([gl_PREREQ_FFLUSH],
-[
-  AC_REQUIRE([AC_C_INLINE])
-  :
-])
diff --git a/gl/m4/float_h.m4 b/gl/m4/float_h.m4
index 261f1ac..51c9c7b 100644
--- a/gl/m4/float_h.m4
+++ b/gl/m4/float_h.m4
@@ -1,5 +1,5 @@
-# float_h.m4 serial 7
-dnl Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+# float_h.m4 serial 9
+dnl Copyright (C) 2007, 2009-2012 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.
@@ -33,17 +33,66 @@ changequote([,])dnl
           ;;
       esac
       ;;
+    linux*)
+      case "$host_cpu" in
+        powerpc*)
+          FLOAT_H=float.h
+          ;;
+      esac
+      ;;
   esac
   case "$host_os" in
-    aix* | freebsd*)
+    aix* | freebsd* | linux*)
       if test -n "$FLOAT_H"; then
         REPLACE_FLOAT_LDBL=1
       fi
       ;;
   esac
+
+  dnl Test against glibc-2.7 Linux/SPARC64 bug.
+  REPLACE_ITOLD=0
+  AC_CACHE_CHECK([whether conversion from 'int' to 'long double' works],
+    [gl_cv_func_itold_works],
+    [
+      AC_RUN_IFELSE(
+        [AC_LANG_SOURCE([[
+int i = -1;
+volatile long double ld;
+int main ()
+{
+  ld += i * 1.0L;
+  if (ld > 0)
+    return 1;
+  return 0;
+}]])],
+        [gl_cv_func_itold_works=yes],
+        [gl_cv_func_itold_works=no],
+        [case "$host" in
+           sparc*-*-linux*)
+             AC_EGREP_CPP([yes],
+               [#if defined __LP64__ || defined __arch64__
+                yes
+                #endif],
+               [gl_cv_func_itold_works="guessing no"],
+               [gl_cv_func_itold_works="guessing yes"])
+             ;;
+           *) gl_cv_func_itold_works="guessing yes" ;;
+         esac
+        ])
+    ])
+  case "$gl_cv_func_itold_works" in
+    *no)
+      REPLACE_ITOLD=1
+      dnl We add the workaround to <float.h> but also to <math.h>,
+      dnl to increase the chances that the fix function gets pulled in.
+      FLOAT_H=float.h
+      ;;
+  esac
+
   if test -n "$FLOAT_H"; then
     gl_NEXT_HEADERS([float.h])
   fi
   AC_SUBST([FLOAT_H])
   AM_CONDITIONAL([GL_GENERATE_FLOAT_H], [test -n "$FLOAT_H"])
+  AC_SUBST([REPLACE_ITOLD])
 ])
diff --git a/gl/m4/fpieee.m4 b/gl/m4/fpieee.m4
index 7872876..93b8d90 100644
--- a/gl/m4/fpieee.m4
+++ b/gl/m4/fpieee.m4
@@ -1,5 +1,5 @@
 # fpieee.m4 serial 1
-dnl Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2007, 2009-2012 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.
diff --git a/gl/m4/fpurge.m4 b/gl/m4/fpurge.m4
deleted file mode 100644
index 234f563..0000000
--- a/gl/m4/fpurge.m4
+++ /dev/null
@@ -1,45 +0,0 @@
-# fpurge.m4 serial 7
-dnl Copyright (C) 2007, 2009-2011 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_FUNC_FPURGE],
-[
-  AC_REQUIRE([gl_STDIO_H_DEFAULTS])
-  AC_CHECK_FUNCS_ONCE([fpurge])
-  AC_CHECK_FUNCS_ONCE([__fpurge])
-  AC_CHECK_DECLS([fpurge], , , [[#include <stdio.h>]])
-  if test "x$ac_cv_func_fpurge" = xyes; then
-    HAVE_FPURGE=1
-    # Detect BSD bug.  Only cygwin 1.7 is known to be immune.
-    AC_CACHE_CHECK([whether fpurge works], [gl_cv_func_fpurge_works],
-      [AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
-]], [FILE *f = fopen ("conftest.txt", "w+");
-        if (!f) return 1;
-        if (fputc ('a', f) != 'a') return 2;
-        rewind (f);
-        if (fgetc (f) != 'a') return 3;
-        if (fgetc (f) != EOF) return 4;
-        if (fpurge (f) != 0) return 5;
-        if (putc ('b', f) != 'b') return 6;
-        if (fclose (f) != 0) return 7;
-        if ((f = fopen ("conftest.txt", "r")) == NULL) return 8;
-        if (fgetc (f) != 'a') return 9;
-        if (fgetc (f) != 'b') return 10;
-        if (fgetc (f) != EOF) return 11;
-        if (fclose (f) != 0) return 12;
-        if (remove ("conftest.txt") != 0) return 13;
-        return 0;])],
-      [gl_cv_func_fpurge_works=yes], [gl_cv_func_fpurge_works=no],
-      [gl_cv_func_fpurge_works='guessing no'])])
-    if test "x$gl_cv_func_fpurge_works" != xyes; then
-      REPLACE_FPURGE=1
-    fi
-  else
-    HAVE_FPURGE=0
-  fi
-  if test "x$ac_cv_have_decl_fpurge" = xno; then
-    HAVE_DECL_FPURGE=0
-  fi
-])
diff --git a/gl/m4/freading.m4 b/gl/m4/freading.m4
deleted file mode 100644
index 59d502e..0000000
--- a/gl/m4/freading.m4
+++ /dev/null
@@ -1,10 +0,0 @@
-# freading.m4 serial 1
-dnl Copyright (C) 2007, 2009-2011 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_FUNC_FREADING],
-[
-  AC_CHECK_FUNCS_ONCE([__freading])
-])
diff --git a/gl/m4/fseek.m4 b/gl/m4/fseek.m4
index 135a22b..d9cd70a 100644
--- a/gl/m4/fseek.m4
+++ b/gl/m4/fseek.m4
@@ -1,5 +1,5 @@
 # fseek.m4 serial 4
-dnl Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2007, 2009-2012 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.
diff --git a/gl/m4/fseeko.m4 b/gl/m4/fseeko.m4
index 391948d..be5bb35 100644
--- a/gl/m4/fseeko.m4
+++ b/gl/m4/fseeko.m4
@@ -1,5 +1,5 @@
 # fseeko.m4 serial 15
-dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2007-2012 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.
diff --git a/gl/m4/fstat.m4 b/gl/m4/fstat.m4
new file mode 100644
index 0000000..e3f8f3e
--- /dev/null
+++ b/gl/m4/fstat.m4
@@ -0,0 +1,28 @@
+# fstat.m4 serial 1
+dnl Copyright (C) 2011-2012 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_FUNC_FSTAT],
+[
+  AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
+  AC_REQUIRE([gl_MSVC_INVAL])
+  if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
+    REPLACE_FSTAT=1
+  fi
+  dnl Replace fstat() for supporting the gnulib-defined open() on directories.
+  m4_ifdef([gl_FUNC_FCHDIR], [
+    gl_TEST_FCHDIR
+    if test $HAVE_FCHDIR = 0 \
+       && test "$gl_cv_func_open_directory_works" != yes; then
+      REPLACE_FSTAT=1
+    fi
+  ])
+])
+
+# Prerequisites of lib/fstat.c.
+AC_DEFUN([gl_PREREQ_FSTAT],
+[
+  AC_REQUIRE([AC_C_INLINE])
+])
diff --git a/gl/m4/ftell.m4 b/gl/m4/ftell.m4
deleted file mode 100644
index c529c50..0000000
--- a/gl/m4/ftell.m4
+++ /dev/null
@@ -1,15 +0,0 @@
-# ftell.m4 serial 3
-dnl Copyright (C) 2007, 2009-2011 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_FUNC_FTELL],
-[
-  AC_REQUIRE([gl_STDIO_H_DEFAULTS])
-  AC_REQUIRE([gl_FUNC_FTELLO])
-  dnl When ftello needs fixes, ftell needs them too.
-  if test $HAVE_FTELLO = 0 || test $REPLACE_FTELLO = 1; then
-    REPLACE_FTELL=1
-  fi
-])
diff --git a/gl/m4/ftello.m4 b/gl/m4/ftello.m4
deleted file mode 100644
index 10cf429..0000000
--- a/gl/m4/ftello.m4
+++ /dev/null
@@ -1,127 +0,0 @@
-# ftello.m4 serial 10
-dnl Copyright (C) 2007-2011 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_FUNC_FTELLO],
-[
-  AC_REQUIRE([gl_STDIO_H_DEFAULTS])
-  AC_REQUIRE([AC_PROG_CC])
-  AC_REQUIRE([gl_STDIN_LARGE_OFFSET])
-
-  dnl Persuade glibc <stdio.h> to declare ftello().
-  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
-
-  AC_CHECK_DECLS_ONCE([ftello])
-  if test $ac_cv_have_decl_ftello = no; then
-    HAVE_DECL_FTELLO=0
-  fi
-
-  AC_CACHE_CHECK([for ftello], [gl_cv_func_ftello],
-    [
-      AC_LINK_IFELSE(
-        [AC_LANG_PROGRAM(
-           [[#include <stdio.h>]],
-           [[ftello (stdin);]])],
-        [gl_cv_func_ftello=yes],
-        [gl_cv_func_ftello=no])
-    ])
-  if test $gl_cv_func_ftello = no; then
-    HAVE_FTELLO=0
-  else
-    if test $gl_cv_var_stdin_large_offset = no; then
-      REPLACE_FTELLO=1
-    else
-      dnl Detect bug on Solaris.
-      dnl ftell and ftello produce incorrect results after putc that followed a
-      dnl getc call that reached EOF on Solaris. This is because the _IOREAD
-      dnl flag does not get cleared in this case, even though _IOWRT gets set,
-      dnl and ftell and ftello look whether the _IOREAD flag is set.
-      AC_REQUIRE([AC_CANONICAL_HOST])
-      AC_CACHE_CHECK([whether ftello works],
-        [gl_cv_func_ftello_works],
-        [
-          dnl Initial guess, used when cross-compiling or when /dev/tty cannot
-          dnl be opened.
-changequote(,)dnl
-          case "$host_os" in
-                      # Guess no on Solaris.
-            solaris*) gl_cv_func_ftello_works="guessing no" ;;
-                      # Guess yes otherwise.
-            *)        gl_cv_func_ftello_works="guessing yes" ;;
-          esac
-changequote([,])dnl
-          AC_RUN_IFELSE(
-            [AC_LANG_SOURCE([[
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#define TESTFILE "conftest.tmp"
-int
-main (void)
-{
-  FILE *fp;
-
-  /* Create a file with some contents.  */
-  fp = fopen (TESTFILE, "w");
-  if (fp == NULL)
-    return 70;
-  if (fwrite ("foogarsh", 1, 8, fp) < 8)
-    return 71;
-  if (fclose (fp))
-    return 72;
-
-  /* The file's contents is now "foogarsh".  */
-
-  /* Try writing after reading to EOF.  */
-  fp = fopen (TESTFILE, "r+");
-  if (fp == NULL)
-    return 73;
-  if (fseek (fp, -1, SEEK_END))
-    return 74;
-  if (!(getc (fp) == 'h'))
-    return 1;
-  if (!(getc (fp) == EOF))
-    return 2;
-  if (!(ftell (fp) == 8))
-    return 3;
-  if (!(ftell (fp) == 8))
-    return 4;
-  if (!(putc ('!', fp) == '!'))
-    return 5;
-  if (!(ftell (fp) == 9))
-    return 6;
-  if (!(fclose (fp) == 0))
-    return 7;
-  fp = fopen (TESTFILE, "r");
-  if (fp == NULL)
-    return 75;
-  {
-    char buf[10];
-    if (!(fread (buf, 1, 10, fp) == 9))
-      return 10;
-    if (!(memcmp (buf, "foogarsh!", 9) == 0))
-      return 11;
-  }
-  if (!(fclose (fp) == 0))
-    return 12;
-
-  /* The file's contents is now "foogarsh!".  */
-
-  return 0;
-}]])],
-            [gl_cv_func_ftello_works=yes],
-            [gl_cv_func_ftello_works=no], [:])
-        ])
-      case "$gl_cv_func_ftello_works" in
-        *yes) ;;
-        *)
-          REPLACE_FTELLO=1
-          AC_DEFINE([FTELLO_BROKEN_AFTER_SWITCHING_FROM_READ_TO_WRITE], [1],
-            [Define to 1 if the system's ftello function has the Solaris bug.])
-          ;;
-      esac
-    fi
-  fi
-])
diff --git a/gl/m4/ftruncate.m4 b/gl/m4/ftruncate.m4
new file mode 100644
index 0000000..1007f34
--- /dev/null
+++ b/gl/m4/ftruncate.m4
@@ -0,0 +1,24 @@
+# serial 18
+
+# See if we need to emulate a missing ftruncate function using chsize.
+
+# Copyright (C) 2000-2001, 2003-2007, 2009-2012 Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_FTRUNCATE],
+[
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([ftruncate])
+  if test $ac_cv_func_ftruncate = no; then
+    HAVE_FTRUNCATE=0
+  fi
+])
+
+# Prerequisites of lib/ftruncate.c.
+AC_DEFUN([gl_PREREQ_FTRUNCATE],
+[
+  AC_REQUIRE([AC_C_INLINE])
+  AC_CHECK_FUNCS([chsize])
+])
diff --git a/gl/m4/getaddrinfo.m4 b/gl/m4/getaddrinfo.m4
index 20a6226..9cd3e67 100644
--- a/gl/m4/getaddrinfo.m4
+++ b/gl/m4/getaddrinfo.m4
@@ -1,5 +1,5 @@
-# getaddrinfo.m4 serial 26
-dnl Copyright (C) 2004-2011 Free Software Foundation, Inc.
+# getaddrinfo.m4 serial 29
+dnl Copyright (C) 2004-2012 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.
@@ -63,7 +63,7 @@ AC_DEFUN([gl_GETADDRINFO],
   # We can't use AC_REPLACE_FUNCS here because gai_strerror may be an
   # inline function declared in ws2tcpip.h, so we need to get that
   # header included somehow.
-  AC_CHECK_DECLS([gai_strerror, gai_strerrorA], [], [break], [[
+  AC_CHECK_DECLS([gai_strerror], [], [], [[
 #include <sys/types.h>
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
@@ -77,6 +77,19 @@ AC_DEFUN([gl_GETADDRINFO],
 #include <stddef.h>
 ]])
   if test $ac_cv_have_decl_gai_strerror = yes; then
+    AC_CHECK_DECLS([gai_strerrorA], [], [], [[
+#include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+#ifdef HAVE_WS2TCPIP_H
+#include <ws2tcpip.h>
+#endif
+#include <stddef.h>
+]])
     dnl check for correct signature
     AC_CACHE_CHECK([for gai_strerror with POSIX signature],
      [gl_cv_func_gai_strerror_posix_signature], [
@@ -92,7 +105,11 @@ AC_DEFUN([gl_GETADDRINFO],
 #include <ws2tcpip.h>
 #endif
 #include <stddef.h>
-extern const char *gai_strerror(int);]])],
+extern
+#ifdef __cplusplus
+"C"
+#endif
+const char *gai_strerror(int);]])],
         [gl_cv_func_gai_strerror_posix_signature=yes],
         [gl_cv_func_gai_strerror_posix_signature=no])])
     if test $gl_cv_func_gai_strerror_posix_signature = no; then
@@ -129,7 +146,7 @@ AC_DEFUN([gl_PREREQ_GETADDRINFO], [
 
   AC_CHECK_HEADERS_ONCE([netinet/in.h])
 
-  AC_CHECK_DECLS([getaddrinfo, freeaddrinfo, getnameinfo],,,[
+  AC_CHECK_DECLS([getaddrinfo, freeaddrinfo, getnameinfo],,,[[
   /* sys/types.h is not needed according to POSIX, but the
      sys/socket.h in i386-unknown-freebsd4.10 and
      powerpc-apple-darwin5.5 required it. */
@@ -143,7 +160,7 @@ AC_DEFUN([gl_PREREQ_GETADDRINFO], [
 #ifdef HAVE_WS2TCPIP_H
 #include <ws2tcpip.h>
 #endif
-])
+]])
   if test $ac_cv_have_decl_getaddrinfo = no; then
     HAVE_DECL_GETADDRINFO=0
   fi
diff --git a/gl/m4/getcwd.m4 b/gl/m4/getcwd.m4
index 269fdd7..ccb1f47 100644
--- a/gl/m4/getcwd.m4
+++ b/gl/m4/getcwd.m4
@@ -1,20 +1,25 @@
 # getcwd.m4 - check for working getcwd that is compatible with glibc
 
-# Copyright (C) 2001, 2003-2007, 2009-2011 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2003-2007, 2009-2012 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
 # Written by Paul Eggert.
-# serial 7
+# serial 11
 
 AC_DEFUN([gl_FUNC_GETCWD_NULL],
   [
    AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+   AC_CHECK_HEADERS_ONCE([unistd.h])
    AC_CACHE_CHECK([whether getcwd (NULL, 0) allocates memory for result],
      [gl_cv_func_getcwd_null],
      [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
-#        include <unistd.h>
+#        if HAVE_UNISTD_H
+#         include <unistd.h>
+#        else /* on Windows with MSVC */
+#         include <direct.h>
+#        endif
 #        ifndef getcwd
          char *getcwd ();
 #        endif
@@ -37,9 +42,6 @@ AC_DEFUN([gl_FUNC_GETCWD_NULL],
                return 0;
              }
 #endif
-         /* If size is non-zero, allocation must fail if size is too small */
-         if (getcwd (NULL, 1))
-           return 5;
          ]])],
         [gl_cv_func_getcwd_null=yes],
         [gl_cv_func_getcwd_null=no],
@@ -55,6 +57,24 @@ AC_DEFUN([gl_FUNC_GETCWD_NULL],
         ]])])
 ])
 
+AC_DEFUN([gl_FUNC_GETCWD_SIGNATURE],
+[
+  AC_CACHE_CHECK([for getcwd with POSIX signature],
+    [gl_cv_func_getcwd_posix_signature],
+    [AC_COMPILE_IFELSE(
+      [AC_LANG_PROGRAM(
+         [[#include <unistd.h>]],
+         [[extern
+           #ifdef __cplusplus
+           "C"
+           #endif
+           char *getcwd (char *, size_t);
+         ]])
+      ],
+      [gl_cv_func_getcwd_posix_signature=yes],
+      [gl_cv_func_getcwd_posix_signature=no])
+   ])
+])
 
 dnl Guarantee that getcwd will malloc with a NULL first argument.  Assumes
 dnl that either the system getcwd is robust, or that calling code is okay
@@ -67,9 +87,10 @@ AC_DEFUN([gl_FUNC_GETCWD_LGPL],
 [
   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
   AC_REQUIRE([gl_FUNC_GETCWD_NULL])
+  AC_REQUIRE([gl_FUNC_GETCWD_SIGNATURE])
 
-  case $gl_cv_func_getcwd_null in
-  *yes) ;;
+  case $gl_cv_func_getcwd_null,$gl_cv_func_getcwd_posix_signature in
+  *yes,yes) ;;
   *)
     dnl Minimal replacement lib/getcwd-lgpl.c.
     REPLACE_GETCWD=1
@@ -83,23 +104,47 @@ AC_DEFUN([gl_FUNC_GETCWD],
 [
   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
   AC_REQUIRE([gl_FUNC_GETCWD_NULL])
+  AC_REQUIRE([gl_FUNC_GETCWD_SIGNATURE])
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
 
   gl_abort_bug=no
-  case $gl_cv_func_getcwd_null,$host_os in
-  *,mingw*)
-    gl_cv_func_getcwd_path_max=yes;;
-  yes,*)
-    gl_FUNC_GETCWD_PATH_MAX
-    gl_FUNC_GETCWD_ABORT_BUG([gl_abort_bug=yes]);;
+  case "$host_os" in
+    mingw*)
+      gl_cv_func_getcwd_path_max=yes
+      ;;
+    *)
+      gl_FUNC_GETCWD_PATH_MAX
+      case "$gl_cv_func_getcwd_null" in
+        *yes)
+          gl_FUNC_GETCWD_ABORT_BUG([gl_abort_bug=yes])
+          ;;
+      esac
+      ;;
   esac
-
-  case $gl_cv_func_getcwd_null,$gl_cv_func_getcwd_path_max,$gl_abort_bug in
-  *yes,yes,no) ;;
-  *)
-    dnl Full replacement lib/getcwd.c, overrides LGPL replacement.
-    REPLACE_GETCWD=1;;
+  dnl Define HAVE_MINIMALLY_WORKING_GETCWD and HAVE_PARTLY_WORKING_GETCWD
+  dnl if appropriate.
+  case "$gl_cv_func_getcwd_path_max" in
+    "no, it has the AIX bug") ;;
+    *)
+      AC_DEFINE([HAVE_MINIMALLY_WORKING_GETCWD], [1],
+        [Define to 1 if getcwd minimally works, that is, its result can be
+         trusted when it succeeds.])
+      ;;
+  esac
+  case "$gl_cv_func_getcwd_path_max" in
+    "no, but it is partly working")
+      AC_DEFINE([HAVE_PARTLY_WORKING_GETCWD], [1],
+        [Define to 1 if getcwd works, except it sometimes fails when it
+         shouldn't, setting errno to ERANGE, ENAMETOOLONG, or ENOENT.])
+      ;;
   esac
+
+  if { case "$gl_cv_func_getcwd_null" in *yes) false;; *) true;; esac; } \
+     || test $gl_cv_func_getcwd_posix_signature != yes \
+     || test "$gl_cv_func_getcwd_path_max" != yes \
+     || test $gl_abort_bug = yes; then
+    REPLACE_GETCWD=1
+  fi
 ])
 
 # Prerequisites of lib/getcwd.c, when full replacement is in effect.
diff --git a/gl/m4/getdelim.m4 b/gl/m4/getdelim.m4
index 6a0f632..8bd3d3f 100644
--- a/gl/m4/getdelim.m4
+++ b/gl/m4/getdelim.m4
@@ -1,6 +1,6 @@
 # getdelim.m4 serial 9
 
-dnl Copyright (C) 2005-2007, 2009-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2005-2007, 2009-2012 Free Software Foundation, Inc.
 dnl
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
diff --git a/gl/m4/getline.m4 b/gl/m4/getline.m4
index 4c57797..01f38cf 100644
--- a/gl/m4/getline.m4
+++ b/gl/m4/getline.m4
@@ -1,6 +1,6 @@
 # getline.m4 serial 25
 
-dnl Copyright (C) 1998-2003, 2005-2007, 2009-2011 Free Software Foundation,
+dnl Copyright (C) 1998-2003, 2005-2007, 2009-2012 Free Software Foundation,
 dnl Inc.
 dnl
 dnl This file is free software; the Free Software Foundation
diff --git a/gl/m4/getopt.m4 b/gl/m4/getopt.m4
index 4d8450f..2aea895 100644
--- a/gl/m4/getopt.m4
+++ b/gl/m4/getopt.m4
@@ -1,5 +1,5 @@
-# getopt.m4 serial 35
-dnl Copyright (C) 2002-2006, 2008-2011 Free Software Foundation, Inc.
+# getopt.m4 serial 39
+dnl Copyright (C) 2002-2006, 2008-2012 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.
@@ -25,8 +25,6 @@ AC_DEFUN([gl_FUNC_GETOPT_POSIX],
   if test $REPLACE_GETOPT = 1; then
     dnl Arrange for getopt.h to be created.
     gl_GETOPT_SUBSTITUTE_HEADER
-    dnl Arrange for unistd.h to include getopt.h.
-    GNULIB_UNISTD_H_GETOPT=1
   fi
 ])
 
@@ -89,15 +87,15 @@ AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
     AC_CACHE_CHECK([whether getopt is POSIX compatible],
       [gl_cv_func_getopt_posix],
       [
-        dnl BSD getopt_long uses an incompatible method to reset
-        dnl option processing.  Existence of the variable, in and of
+        dnl BSD getopt_long uses an incompatible method to reset option
+        dnl processing.  Existence of the optreset variable, in and of
         dnl itself, is not a reason to replace getopt, but knowledge
         dnl of the variable is needed to determine how to reset and
         dnl whether a reset reparses the environment.  Solaris
         dnl supports neither optreset nor optind=0, but keeps no state
         dnl that needs a reset beyond setting optind=1; detect Solaris
         dnl by getopt_clip.
-        AC_COMPILE_IFELSE(
+        AC_LINK_IFELSE(
           [AC_LANG_PROGRAM(
              [[#include <unistd.h>]],
              [[int *p = &optreset; return optreset;]])],
@@ -121,22 +119,20 @@ int
 main ()
 {
   {
-    int argc = 0;
-    char *argv[10];
+    static char program[] = "program";
+    static char a[] = "-a";
+    static char foo[] = "foo";
+    static char bar[] = "bar";
+    char *argv[] = { program, a, foo, bar, NULL };
     int c;
 
-    argv[argc++] = "program";
-    argv[argc++] = "-a";
-    argv[argc++] = "foo";
-    argv[argc++] = "bar";
-    argv[argc] = NULL;
     optind = OPTIND_MIN;
     opterr = 0;
 
-    c = getopt (argc, argv, "ab");
+    c = getopt (4, argv, "ab");
     if (!(c == 'a'))
       return 1;
-    c = getopt (argc, argv, "ab");
+    c = getopt (4, argv, "ab");
     if (!(c == -1))
       return 2;
     if (!(optind == 2))
@@ -144,22 +140,20 @@ main ()
   }
   /* Some internal state exists at this point.  */
   {
-    int argc = 0;
-    char *argv[10];
+    static char program[] = "program";
+    static char donald[] = "donald";
+    static char p[] = "-p";
+    static char billy[] = "billy";
+    static char duck[] = "duck";
+    static char a[] = "-a";
+    static char bar[] = "bar";
+    char *argv[] = { program, donald, p, billy, duck, a, bar, NULL };
     int c;
 
-    argv[argc++] = "program";
-    argv[argc++] = "donald";
-    argv[argc++] = "-p";
-    argv[argc++] = "billy";
-    argv[argc++] = "duck";
-    argv[argc++] = "-a";
-    argv[argc++] = "bar";
-    argv[argc] = NULL;
     optind = OPTIND_MIN;
     opterr = 0;
 
-    c = getopt (argc, argv, "+abp:q:");
+    c = getopt (7, argv, "+abp:q:");
     if (!(c == -1))
       return 4;
     if (!(strcmp (argv[0], "program") == 0))
@@ -181,7 +175,9 @@ main ()
   }
   /* Detect MacOS 10.5, AIX 7.1 bug.  */
   {
-    char *argv[3] = { "program", "-ab", NULL };
+    static char program[] = "program";
+    static char ab[] = "-ab";
+    char *argv[3] = { program, ab, NULL };
     optind = OPTIND_MIN;
     opterr = 0;
     if (getopt (2, argv, "ab:") != 'a')
@@ -233,25 +229,32 @@ dnl is ambiguous with environment values that contain 
newlines.
         [AC_LANG_PROGRAM([[#include <getopt.h>
                            #include <stddef.h>
                            #include <string.h>
+           ]GL_NOCRASH[
            ]], [[
              int result = 0;
+
+             nocrash_init();
+
              /* This code succeeds on glibc 2.8, OpenBSD 4.0, Cygwin, mingw,
                 and fails on MacOS X 10.5, AIX 5.2, HP-UX 11, IRIX 6.5,
                 OSF/1 5.1, Solaris 10.  */
              {
-               char *myargv[3];
-               myargv[0] = "conftest";
-               myargv[1] = "-+";
-               myargv[2] = 0;
+               static char conftest[] = "conftest";
+               static char plus[] = "-+";
+               char *argv[3] = { conftest, plus, NULL };
                opterr = 0;
-               if (getopt (2, myargv, "+a") != '?')
+               if (getopt (2, argv, "+a") != '?')
                  result |= 1;
              }
              /* This code succeeds on glibc 2.8, mingw,
                 and fails on MacOS X 10.5, OpenBSD 4.0, AIX 5.2, HP-UX 11,
                 IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x.  */
              {
-               char *argv[] = { "program", "-p", "foo", "bar", NULL };
+               static char program[] = "program";
+               static char p[] = "-p";
+               static char foo[] = "foo";
+               static char bar[] = "bar";
+               char *argv[] = { program, p, foo, bar, NULL };
 
                optind = 1;
                if (getopt (4, argv, "p::") != 'p')
@@ -265,7 +268,10 @@ dnl is ambiguous with environment values that contain 
newlines.
              }
              /* This code succeeds on glibc 2.8 and fails on Cygwin 1.7.0.  */
              {
-               char *argv[] = { "program", "foo", "-p", NULL };
+               static char program[] = "program";
+               static char foo[] = "foo";
+               static char p[] = "-p";
+               char *argv[] = { program, foo, p, NULL };
                optind = 0;
                if (getopt (3, argv, "-p") != 1)
                  result |= 16;
@@ -274,13 +280,26 @@ dnl is ambiguous with environment values that contain 
newlines.
              }
              /* This code fails on glibc 2.11.  */
              {
-               char *argv[] = { "program", "-b", "-a", NULL };
+               static char program[] = "program";
+               static char b[] = "-b";
+               static char a[] = "-a";
+               char *argv[] = { program, b, a, NULL };
                optind = opterr = 0;
                if (getopt (3, argv, "+:a:b") != 'b')
                  result |= 64;
                else if (getopt (3, argv, "+:a:b") != ':')
                  result |= 64;
              }
+             /* This code dumps core on glibc 2.14.  */
+             {
+               static char program[] = "program";
+               static char w[] = "-W";
+               static char dummy[] = "dummy";
+               char *argv[] = { program, w, dummy, NULL };
+               optind = opterr = 1;
+               if (getopt (3, argv, "W;") != 'W')
+                 result |= 128;
+             }
              return result;
            ]])],
         [gl_cv_func_getopt_gnu=yes],
diff --git a/gl/m4/getpagesize.m4 b/gl/m4/getpagesize.m4
index f7ac1ef..156133a 100644
--- a/gl/m4/getpagesize.m4
+++ b/gl/m4/getpagesize.m4
@@ -1,5 +1,5 @@
 # getpagesize.m4 serial 9
-dnl Copyright (C) 2002, 2004-2005, 2007, 2009-2011 Free Software Foundation,
+dnl Copyright (C) 2002, 2004-2005, 2007, 2009-2012 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
diff --git a/gl/m4/getpass.m4 b/gl/m4/getpass.m4
index 64cee1e..2a7e160 100644
--- a/gl/m4/getpass.m4
+++ b/gl/m4/getpass.m4
@@ -1,5 +1,5 @@
-# getpass.m4 serial 13
-dnl Copyright (C) 2002-2003, 2005-2006, 2009-2011 Free Software Foundation,
+# getpass.m4 serial 14
+dnl Copyright (C) 2002-2003, 2005-2006, 2009-2012 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -45,10 +45,10 @@ AC_DEFUN([gl_PREREQ_GETPASS], [
   AC_CHECK_HEADERS_ONCE([stdio_ext.h termios.h])
   AC_CHECK_FUNCS_ONCE([__fsetlocking tcgetattr tcsetattr])
   AC_CHECK_DECLS([__fsetlocking],,,
-    [#include <stdio.h>
-     #if HAVE_STDIO_EXT_H
-      #include <stdio_ext.h>
-     #endif])
+    [[#include <stdio.h>
+      #if HAVE_STDIO_EXT_H
+       #include <stdio_ext.h>
+      #endif]])
   AC_CHECK_DECLS_ONCE([fflush_unlocked])
   AC_CHECK_DECLS_ONCE([flockfile])
   AC_CHECK_DECLS_ONCE([fputs_unlocked])
diff --git a/gl/m4/gettimeofday.m4 b/gl/m4/gettimeofday.m4
index 47c1e1d..dc68c43 100644
--- a/gl/m4/gettimeofday.m4
+++ b/gl/m4/gettimeofday.m4
@@ -1,6 +1,6 @@
-# serial 17
+# serial 18
 
-# Copyright (C) 2001-2003, 2005, 2007, 2009-2011 Free Software Foundation, Inc.
+# Copyright (C) 2001-2003, 2005, 2007, 2009-2012 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -50,6 +50,10 @@ int gettimeofday (struct timeval *restrict, struct timezone 
*restrict);
     elif test $gl_cv_func_gettimeofday_posix_signature != yes; then
       REPLACE_GETTIMEOFDAY=1
     fi
+    dnl If we override 'struct timeval', we also have to override gettimeofday.
+    if test $REPLACE_STRUCT_TIMEVAL = 1; then
+      REPLACE_GETTIMEOFDAY=1
+    fi
     m4_ifdef([gl_FUNC_TZSET_CLOBBER], [
       gl_FUNC_TZSET_CLOBBER
       if test $gl_cv_func_tzset_clobber = yes; then
diff --git a/gl/m4/glibc21.m4 b/gl/m4/glibc21.m4
index bc81c11..c938fb1 100644
--- a/gl/m4/glibc21.m4
+++ b/gl/m4/glibc21.m4
@@ -1,5 +1,5 @@
 # glibc21.m4 serial 5
-dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2011 Free Software Foundation,
+dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2012 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4
index 1a8e645..3f92cf3 100644
--- a/gl/m4/gnulib-cache.m4
+++ b/gl/m4/gnulib-cache.m4
@@ -1,9 +1,21 @@
-# Copyright (C) 2002-2011 Free Software Foundation, Inc.
+# Copyright (C) 2002-2012 Free Software Foundation, Inc.
 #
-# This file is free software, distributed under the terms of the GNU
-# General Public License.  As a special exception to the GNU General
-# Public License, this file may be distributed as part of a program
-# that contains a configuration script generated by Autoconf, under
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception to the GNU General Public License,
+# this file may be distributed as part of a program that
+# contains a configuration script generated by Autoconf, under
 # the same distribution terms as the rest of that program.
 #
 # Generated by gnulib-tool.
@@ -15,7 +27,7 @@
 
 
 # Specification in the form of a command-line invocation:
-#   gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgl 
--source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gltests 
--aux-dir=lib/build-aux --with-tests --avoid=fcntl-h-c++-tests 
--avoid=iconv-h-c++-tests --avoid=stdio-c++-tests --avoid=stdlib-c++-tests 
--avoid=string-c++-tests --avoid=sys_ioctl-c++-tests 
--avoid=sys_select-c++-tests --avoid=sys_socket-c++-tests 
--avoid=sys_stat-c++-tests --avoid=sys_time-c++-tests --avoid=time-c++-tests 
--avoid=unistd-c++-tests --avoid=wchar-c++-tests --avoid=wctype-c++-tests 
--no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files 
autobuild close connect error fdl-1.3 gendocs getaddrinfo getopt-gnu getpass 
gpl-3.0 lgpl-2.1 maintainer-makefile manywarnings netdb netinet_in pmccabe2html 
poll progname quote readline recv shutdown socket striconv strtok_r sys_time 
unistd valgrind-tests vasprintf version-etc warnings xalloc
+#   gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgl 
--source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gltests 
--aux-dir=lib/build-aux --with-tests --no-conditional-dependencies --libtool 
--macro-prefix=gl --no-vc-files autobuild close connect error fdl-1.3 gendocs 
getaddrinfo getopt-gnu getpass gpl-3.0 lgpl-2.1 maintainer-makefile 
manywarnings netdb netinet_in pmccabe2html poll progname quote readline recv 
shutdown socket striconv strtok_r sys_time unistd valgrind-tests vasprintf 
version-etc warnings xalloc
 
 # Specification in the form of a few gnulib-tool.m4 macro invocations:
 gl_LOCAL_DIR([gl/override])
@@ -53,7 +65,7 @@ gl_MODULES([
   warnings
   xalloc
 ])
-gl_AVOID([fcntl-h-c++-tests iconv-h-c++-tests stdio-c++-tests stdlib-c++-tests 
string-c++-tests sys_ioctl-c++-tests sys_select-c++-tests sys_socket-c++-tests 
sys_stat-c++-tests sys_time-c++-tests time-c++-tests unistd-c++-tests 
wchar-c++-tests wctype-c++-tests])
+gl_AVOID([])
 gl_SOURCE_BASE([gl])
 gl_M4_BASE([gl/m4])
 gl_PO_BASE([])
diff --git a/gl/m4/gnulib-common.m4 b/gl/m4/gnulib-common.m4
index 843efe0..ae4d254 100644
--- a/gl/m4/gnulib-common.m4
+++ b/gl/m4/gnulib-common.m4
@@ -1,5 +1,5 @@
-# gnulib-common.m4 serial 26
-dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
+# gnulib-common.m4 serial 32
+dnl Copyright (C) 2007-2012 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.
@@ -12,6 +12,19 @@ AC_DEFUN([gl_COMMON], [
   AC_REQUIRE([gl_COMMON_BODY])
 ])
 AC_DEFUN([gl_COMMON_BODY], [
+  AH_VERBATIM([_Noreturn],
+[/* The _Noreturn keyword of C11.  */
+#ifndef _Noreturn
+# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
+      || 0x5110 <= __SUNPRO_C)
+#  define _Noreturn __attribute__ ((__noreturn__))
+# elif defined _MSC_VER && 1200 <= _MSC_VER
+#  define _Noreturn __declspec (noreturn)
+# else
+#  define _Noreturn
+# endif
+#endif
+])
   AH_VERBATIM([isoc99_inline],
 [/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports
    the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of
@@ -198,6 +211,83 @@ m4_ifndef([AS_VAR_IF],
 [m4_define([AS_VAR_IF],
 [AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])])
 
+# gl_PROG_CC_C99
+# Modifies the value of the shell variable CC in an attempt to make $CC
+# understand ISO C99 source code.
+# This is like AC_PROG_CC_C99, except that
+# - AC_PROG_CC_C99 did not exist in Autoconf versions < 2.60,
+# - AC_PROG_CC_C99 does not mix well with AC_PROG_CC_STDC
+#   <http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00367.html>,
+#   but many more packages use AC_PROG_CC_STDC than AC_PROG_CC_C99
+#   <http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00441.html>.
+# Remaining problems:
+# - When AC_PROG_CC_STDC is invoked twice, it adds the C99 enabling options
+#   to CC twice
+#   <http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00431.html>.
+# - AC_PROG_CC_STDC is likely to change now that C11 is an ISO standard.
+AC_DEFUN([gl_PROG_CC_C99],
+[
+  dnl Change that version number to the minimum Autoconf version that supports
+  dnl mixing AC_PROG_CC_C99 calls with AC_PROG_CC_STDC calls.
+  m4_version_prereq([9.0],
+    [AC_REQUIRE([AC_PROG_CC_C99])],
+    [AC_REQUIRE([AC_PROG_CC_STDC])])
+])
+
+# gl_PROG_AR_RANLIB
+# Determines the values for AR, ARFLAGS, RANLIB that fit with the compiler.
+# The user can set the variables AR, ARFLAGS, RANLIB if he wants to override
+# the values.
+AC_DEFUN([gl_PROG_AR_RANLIB],
+[
+  dnl Minix 3 comes with two toolchains: The Amsterdam Compiler Kit compiler
+  dnl as "cc", and GCC as "gcc". They have different object file formats and
+  dnl library formats. In particular, the GNU binutils programs ar, ranlib
+  dnl produce libraries that work only with gcc, not with cc.
+  AC_REQUIRE([AC_PROG_CC])
+  AC_CACHE_CHECK([for Minix Amsterdam compiler], [gl_cv_c_amsterdam_compiler],
+    [
+      AC_EGREP_CPP([Amsterdam],
+        [
+#ifdef __ACK__
+Amsterdam
+#endif
+        ],
+        [gl_cv_c_amsterdam_compiler=yes],
+        [gl_cv_c_amsterdam_compiler=no])
+    ])
+  if test -z "$AR"; then
+    if test $gl_cv_c_amsterdam_compiler = yes; then
+      AR='cc -c.a'
+      if test -z "$ARFLAGS"; then
+        ARFLAGS='-o'
+      fi
+    else
+      dnl Use the Automake-documented default values for AR and ARFLAGS,
+      dnl but prefer ${host}-ar over ar (useful for cross-compiling).
+      AC_CHECK_TOOL([AR], [ar], [ar])
+      if test -z "$ARFLAGS"; then
+        ARFLAGS='cru'
+      fi
+    fi
+  else
+    if test -z "$ARFLAGS"; then
+      ARFLAGS='cru'
+    fi
+  fi
+  AC_SUBST([AR])
+  AC_SUBST([ARFLAGS])
+  if test -z "$RANLIB"; then
+    if test $gl_cv_c_amsterdam_compiler = yes; then
+      RANLIB=':'
+    else
+      dnl Use the ranlib program if it is available.
+      AC_PROG_RANLIB
+    fi
+  fi
+  AC_SUBST([RANLIB])
+])
+
 # AC_PROG_MKDIR_P
 # is a backport of autoconf-2.60's AC_PROG_MKDIR_P, with a fix
 # for interoperability with automake-1.9.6 from autoconf-2.62.
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4
index 2037879..eaec029 100644
--- a/gl/m4/gnulib-comp.m4
+++ b/gl/m4/gnulib-comp.m4
@@ -1,10 +1,22 @@
 # DO NOT EDIT! GENERATED AUTOMATICALLY!
-# Copyright (C) 2002-2011 Free Software Foundation, Inc.
+# Copyright (C) 2002-2012 Free Software Foundation, Inc.
 #
-# This file is free software, distributed under the terms of the GNU
-# General Public License.  As a special exception to the GNU General
-# Public License, this file may be distributed as part of a program
-# that contains a configuration script generated by Autoconf, under
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception to the GNU General Public License,
+# this file may be distributed as part of a program that
+# contains a configuration script generated by Autoconf, under
 # the same distribution terms as the rest of that program.
 #
 # Generated by gnulib-tool.
@@ -25,15 +37,13 @@ AC_DEFUN([gl_EARLY],
   m4_pattern_allow([^gl_ES$])dnl a valid locale name
   m4_pattern_allow([^gl_LIBOBJS$])dnl a variable
   m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable
-  AC_REQUIRE([AC_PROG_RANLIB])
+  AC_REQUIRE([gl_PROG_AR_RANLIB])
   AC_REQUIRE([AM_PROG_CC_C_O])
   # Code from module accept:
-  # Code from module alignof:
-  # Code from module alignof-tests:
+  # Code from module accept-tests:
   # Code from module alloca:
   # Code from module alloca-opt:
   # Code from module alloca-opt-tests:
-  # Code from module arg-nonnull:
   # Code from module arpa_inet:
   # Code from module arpa_inet-tests:
   # Code from module autobuild:
@@ -41,16 +51,19 @@ AC_DEFUN([gl_EARLY],
   # Code from module binary-io:
   # Code from module binary-io-tests:
   # Code from module bind:
+  # Code from module bind-tests:
   # Code from module btowc:
   # Code from module btowc-tests:
-  # Code from module c++defs:
   # Code from module c-ctype:
   # Code from module c-ctype-tests:
   # Code from module c-strcase:
   # Code from module c-strcase-tests:
+  # Code from module c-strcaseeq:
   # Code from module close:
+  # Code from module close-tests:
   # Code from module configmake:
   # Code from module connect:
+  # Code from module connect-tests:
   # Code from module dosname:
   # Code from module dup2:
   # Code from module dup2-tests:
@@ -62,34 +75,30 @@ AC_DEFUN([gl_EARLY],
   # Code from module exitfail:
   # Code from module extensions:
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
-  # Code from module fclose:
-  # Code from module fclose-tests:
   # Code from module fcntl-h:
   # Code from module fcntl-h-tests:
   # Code from module fd-hook:
   # Code from module fdl-1.3:
-  # Code from module fflush:
-  AC_REQUIRE([AC_FUNC_FSEEKO])
-  # Code from module fflush-tests:
+  # Code from module fdopen:
+  # Code from module fdopen-tests:
+  # Code from module fgetc-tests:
   # Code from module float:
   # Code from module float-tests:
   # Code from module fpieee:
   AC_REQUIRE([gl_FP_IEEE])
   # Code from module fpucw:
-  # Code from module fpurge:
-  # Code from module fpurge-tests:
-  # Code from module freading:
-  # Code from module freading-tests:
+  # Code from module fputc-tests:
+  # Code from module fread-tests:
   # Code from module fseek:
   # Code from module fseek-tests:
   # Code from module fseeko:
   AC_REQUIRE([AC_FUNC_FSEEKO])
   # Code from module fseeko-tests:
-  # Code from module ftell:
-  # Code from module ftell-tests:
-  # Code from module ftello:
-  AC_REQUIRE([AC_FUNC_FSEEKO])
-  # Code from module ftello-tests:
+  # Code from module fstat:
+  # Code from module fstat-tests:
+  # Code from module ftruncate:
+  # Code from module ftruncate-tests:
+  # Code from module fwrite-tests:
   # Code from module gendocs:
   # Code from module getaddrinfo:
   # Code from module getaddrinfo-tests:
@@ -131,8 +140,12 @@ AC_DEFUN([gl_EARLY],
   # Code from module inttypes-incomplete:
   # Code from module inttypes-tests:
   # Code from module ioctl:
+  # Code from module ioctl-tests:
+  # Code from module largefile:
+  AC_REQUIRE([AC_SYS_LARGEFILE])
   # Code from module lgpl-2.1:
   # Code from module listen:
+  # Code from module listen-tests:
   # Code from module localcharset:
   # Code from module locale:
   # Code from module locale-tests:
@@ -156,13 +169,18 @@ AC_DEFUN([gl_EARLY],
   # Code from module mbtowc:
   # Code from module memchr:
   # Code from module memchr-tests:
+  # Code from module msvc-inval:
+  # Code from module msvc-nothrow:
   # Code from module multiarch:
   # Code from module netdb:
   # Code from module netdb-tests:
   # Code from module netinet_in:
   # Code from module netinet_in-tests:
+  # Code from module nocrash:
   # Code from module open:
   # Code from module open-tests:
+  # Code from module pathmax:
+  # Code from module pathmax-tests:
   # Code from module perror:
   # Code from module perror-tests:
   # Code from module pipe-posix:
@@ -181,6 +199,7 @@ AC_DEFUN([gl_EARLY],
   # Code from module readline:
   # Code from module realloc-posix:
   # Code from module recv:
+  # Code from module recv-tests:
   # Code from module same-inode:
   # Code from module select:
   # Code from module select-tests:
@@ -190,8 +209,17 @@ AC_DEFUN([gl_EARLY],
   # Code from module setlocale:
   # Code from module setlocale-tests:
   # Code from module setsockopt:
+  # Code from module setsockopt-tests:
   # Code from module shutdown:
+  # Code from module shutdown-tests:
+  # Code from module signal-h:
+  # Code from module signal-h-tests:
   # Code from module size_max:
+  # Code from module snippet/_Noreturn:
+  # Code from module snippet/arg-nonnull:
+  # Code from module snippet/c++defs:
+  # Code from module snippet/unused-parameter:
+  # Code from module snippet/warn-on-use:
   # Code from module snprintf:
   # Code from module snprintf-tests:
   # Code from module socket:
@@ -199,14 +227,17 @@ AC_DEFUN([gl_EARLY],
   # Code from module sockets:
   # Code from module sockets-tests:
   # Code from module socklen:
+  # Code from module ssize_t:
   # Code from module stat:
   # Code from module stat-tests:
+  # Code from module stdalign:
+  # Code from module stdalign-tests:
   # Code from module stdarg:
   dnl Some compilers (e.g., AIX 5.3 cc) need to be in c99 mode
   dnl for the builtin va_copy to work.  With Autoconf 2.60 or later,
-  dnl AC_PROG_CC_STDC arranges for this.  With older Autoconf AC_PROG_CC_STDC
+  dnl gl_PROG_CC_C99 arranges for this.  With older Autoconf gl_PROG_CC_C99
   dnl shouldn't hurt, though installers are on their own to set c99 mode.
-  AC_REQUIRE([AC_PROG_CC_STDC])
+  gl_PROG_CC_C99
   # Code from module stdbool:
   # Code from module stdbool-tests:
   # Code from module stddef:
@@ -241,9 +272,14 @@ AC_DEFUN([gl_EARLY],
   # Code from module sys_stat-tests:
   # Code from module sys_time:
   # Code from module sys_time-tests:
+  # Code from module sys_types:
+  # Code from module sys_types-tests:
   # Code from module sys_uio:
   # Code from module sys_uio-tests:
+  # Code from module test-framework-sh:
+  # Code from module test-framework-sh-tests:
   # Code from module thread:
+  # Code from module thread-tests:
   # Code from module threadlib:
   gl_THREADLIB_EARLY
   # Code from module time:
@@ -258,7 +294,6 @@ AC_DEFUN([gl_EARLY],
   # Code from module unitypes:
   # Code from module unsetenv:
   # Code from module unsetenv-tests:
-  # Code from module unused-parameter:
   # Code from module useless-if-before-free:
   # Code from module valgrind-tests:
   # Code from module vasnprintf:
@@ -272,7 +307,6 @@ AC_DEFUN([gl_EARLY],
   # Code from module version-etc:
   # Code from module version-etc-fsf:
   # Code from module version-etc-tests:
-  # Code from module warn-on-use:
   # Code from module warnings:
   # Code from module wchar:
   # Code from module wchar-tests:
@@ -312,6 +346,9 @@ gl_FUNC_ALLOCA
 gl_HEADER_ARPA_INET
 AC_PROG_MKDIR_P
 gl_FUNC_CLOSE
+if test $REPLACE_CLOSE = 1; then
+  AC_LIBOBJ([close])
+fi
 gl_UNISTD_MODULE_INDICATOR([close])
 gl_CONFIGMAKE_PREP
 AC_REQUIRE([gl_HEADER_SYS_SOCKET])
@@ -328,25 +365,13 @@ fi
 m4_ifdef([AM_XGETTEXT_OPTION],
   [AM_][XGETTEXT_OPTION([--flag=error:3:c-format])
    AM_][XGETTEXT_OPTION([--flag=error_at_line:5:c-format])])
-gl_FUNC_FCLOSE
-gl_STDIO_MODULE_INDICATOR([fclose])
-gl_FUNC_FFLUSH
-if test $REPLACE_FFLUSH = 1; then
-  AC_LIBOBJ([fflush])
-  gl_PREREQ_FFLUSH
-fi
-gl_MODULE_INDICATOR([fflush])
-gl_STDIO_MODULE_INDICATOR([fflush])
 gl_FLOAT_H
 if test $REPLACE_FLOAT_LDBL = 1; then
   AC_LIBOBJ([float])
 fi
-gl_FUNC_FPURGE
-if test $HAVE_FPURGE = 0 || test $REPLACE_FPURGE = 1; then
-  AC_LIBOBJ([fpurge])
+if test $REPLACE_ITOLD = 1; then
+  AC_LIBOBJ([itold])
 fi
-gl_STDIO_MODULE_INDICATOR([fpurge])
-gl_FUNC_FREADING
 gl_FUNC_FSEEK
 if test $REPLACE_FSEEK = 1; then
   AC_LIBOBJ([fseek])
@@ -357,16 +382,12 @@ if test $HAVE_FSEEKO = 0 || test $REPLACE_FSEEKO = 1; then
   AC_LIBOBJ([fseeko])
 fi
 gl_STDIO_MODULE_INDICATOR([fseeko])
-gl_FUNC_FTELL
-if test $REPLACE_FTELL = 1; then
-  AC_LIBOBJ([ftell])
+gl_FUNC_FSTAT
+if test $REPLACE_FSTAT = 1; then
+  AC_LIBOBJ([fstat])
+  gl_PREREQ_FSTAT
 fi
-gl_STDIO_MODULE_INDICATOR([ftell])
-gl_FUNC_FTELLO
-if test $HAVE_FTELLO = 0 || test $REPLACE_FTELLO = 1; then
-  AC_LIBOBJ([ftello])
-fi
-gl_STDIO_MODULE_INDICATOR([ftello])
+gl_SYS_STAT_MODULE_INDICATOR([fstat])
 gl_GETADDRINFO
 if test $HAVE_GETADDRINFO = 0; then
   AC_LIBOBJ([getaddrinfo])
@@ -392,14 +413,20 @@ if test $REPLACE_GETOPT = 1; then
   AC_LIBOBJ([getopt])
   AC_LIBOBJ([getopt1])
   gl_PREREQ_GETOPT
+  dnl Arrange for unistd.h to include getopt.h.
+  GNULIB_GL_UNISTD_H_GETOPT=1
 fi
+AC_SUBST([GNULIB_GL_UNISTD_H_GETOPT])
 gl_MODULE_INDICATOR_FOR_TESTS([getopt-gnu])
 gl_FUNC_GETOPT_POSIX
 if test $REPLACE_GETOPT = 1; then
   AC_LIBOBJ([getopt])
   AC_LIBOBJ([getopt1])
   gl_PREREQ_GETOPT
+  dnl Arrange for unistd.h to include getopt.h.
+  GNULIB_GL_UNISTD_H_GETOPT=1
 fi
+AC_SUBST([GNULIB_GL_UNISTD_H_GETOPT])
 gl_FUNC_GETPASS
 if test $HAVE_GETPASS = 0; then
   AC_LIBOBJ([getpass])
@@ -431,14 +458,14 @@ if test $REPLACE_ICONV = 1; then
   AC_LIBOBJ([iconv_close])
 fi
 gl_FUNC_INET_NTOP
-if test $HAVE_INET_NTOP = 0; then
+if test $HAVE_INET_NTOP = 0 || test $REPLACE_INET_NTOP = 1; then
   AC_LIBOBJ([inet_ntop])
   gl_PREREQ_INET_NTOP
 fi
 gl_ARPA_INET_MODULE_INDICATOR([inet_ntop])
 gl_INLINE
 gl_LOCALCHARSET
-LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(top_builddir)/$gl_source_base\""
+LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(abs_top_builddir)/$gl_source_base\""
 AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT])
 gl_FUNC_LSEEK
 if test $REPLACE_LSEEK = 1; then
@@ -470,6 +497,14 @@ if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then
   gl_PREREQ_MEMCHR
 fi
 gl_STRING_MODULE_INDICATOR([memchr])
+gl_MSVC_INVAL
+if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
+  AC_LIBOBJ([msvc-inval])
+fi
+gl_MSVC_NOTHROW
+if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
+  AC_LIBOBJ([msvc-nothrow])
+fi
 gl_MULTIARCH
 gl_HEADER_NETDB
 gl_HEADER_NETINET_IN
@@ -512,6 +547,7 @@ if test "$ac_cv_header_winsock2_h" = yes; then
   AC_LIBOBJ([shutdown])
 fi
 gl_SYS_SOCKET_MODULE_INDICATOR([shutdown])
+gl_SIGNAL_H
 gl_SIZE_MAX
 gl_FUNC_SNPRINTF
 gl_STDIO_MODULE_INDICATOR([snprintf])
@@ -533,6 +569,8 @@ gl_SYS_SOCKET_MODULE_INDICATOR([socket])
 gl_SOCKETLIB
 gl_SOCKETS
 gl_TYPE_SOCKLEN_T
+gt_TYPE_SSIZE_T
+gl_STDALIGN_H
 gl_STDARG_H
 AM_STDBOOL_H
 gl_STDDEF_H
@@ -572,10 +610,15 @@ gl_HEADER_SYS_SELECT
 AC_PROG_MKDIR_P
 gl_HEADER_SYS_SOCKET
 AC_PROG_MKDIR_P
+gl_HEADER_SYS_STAT_H
+AC_PROG_MKDIR_P
 gl_HEADER_SYS_TIME_H
 AC_PROG_MKDIR_P
+gl_SYS_TYPES_H
+AC_PROG_MKDIR_P
 gl_HEADER_SYS_UIO
 AC_PROG_MKDIR_P
+gl_HEADER_TIME_H
 gl_UNISTD_H
 gl_LIBUNISTRING_LIBHEADER([0.9.2], [unistr.h])
 gl_MODULE_INDICATOR([unistr/u8-mbtoucr])
@@ -663,14 +706,28 @@ gt_LOCALE_FR_UTF8
 gt_LOCALE_FR
 gt_LOCALE_TR_UTF8
 gl_FUNC_DUP2
+if test $HAVE_DUP2 = 0 || test $REPLACE_DUP2 = 1; then
+  AC_LIBOBJ([dup2])
+  gl_PREREQ_DUP2
+fi
 gl_UNISTD_MODULE_INDICATOR([dup2])
 gl_ENVIRON
 gl_UNISTD_MODULE_INDICATOR([environ])
 gl_FCNTL_H
+gl_FUNC_FDOPEN
+if test $REPLACE_FDOPEN = 1; then
+  AC_LIBOBJ([fdopen])
+  gl_PREREQ_FDOPEN
+fi
+gl_STDIO_MODULE_INDICATOR([fdopen])
 gl_FUNC_UNGETC_WORKS
 gl_FUNC_UNGETC_WORKS
-gl_FUNC_UNGETC_WORKS
-gl_FUNC_UNGETC_WORKS
+gl_FUNC_FTRUNCATE
+if test $HAVE_FTRUNCATE = 0; then
+  AC_LIBOBJ([ftruncate])
+  gl_PREREQ_FTRUNCATE
+fi
+gl_UNISTD_MODULE_INDICATOR([ftruncate])
 gl_FUNC_GETCWD_LGPL
 if test $REPLACE_GETCWD = 1; then
   AC_LIBOBJ([getcwd-lgpl])
@@ -690,7 +747,7 @@ gl_SYS_TIME_MODULE_INDICATOR([gettimeofday])
 AC_REQUIRE([AC_C_INLINE])
 AC_C_BIGENDIAN
 gl_FUNC_INET_PTON
-if test $HAVE_INET_PTON = 0; then
+if test $HAVE_INET_PTON = 0 || test $REPLACE_INET_NTOP = 1; then
   AC_LIBOBJ([inet_pton])
   gl_PREREQ_INET_PTON
 fi
@@ -736,7 +793,12 @@ gl_FUNC_MMAP_ANON
 AC_CHECK_HEADERS_ONCE([sys/mman.h])
 AC_CHECK_FUNCS_ONCE([mprotect])
 gl_FUNC_OPEN
+if test $REPLACE_OPEN = 1; then
+  AC_LIBOBJ([open])
+  gl_PREREQ_OPEN
+fi
 gl_FCNTL_MODULE_INDICATOR([open])
+gl_PATHMAX
 gl_FUNC_PERROR
 if test $REPLACE_PERROR = 1; then
   AC_LIBOBJ([perror])
@@ -796,11 +858,8 @@ gl_UNISTD_MODULE_INDICATOR([symlink])
 gl_SYS_IOCTL_H
 AC_PROG_MKDIR_P
 AC_CHECK_FUNCS_ONCE([shutdown])
-gl_HEADER_SYS_STAT_H
-AC_PROG_MKDIR_P
 gl_THREAD
 gl_THREADLIB
-gl_HEADER_TIME_H
 gl_FUNC_UNSETENV
 if test $HAVE_UNSETENV = 0 || test $REPLACE_UNSETENV = 1; then
   AC_LIBOBJ([unsetenv])
@@ -925,21 +984,21 @@ AC_DEFUN([gltests_LIBSOURCES], [
 # This macro records the list of files which have been installed by
 # gnulib-tool and may be removed by future gnulib-tool invocations.
 AC_DEFUN([gl_FILE_LIST], [
-  build-aux/arg-nonnull.h
-  build-aux/c++defs.h
   build-aux/config.rpath
   build-aux/gendocs.sh
   build-aux/pmccabe.css
   build-aux/pmccabe2html
-  build-aux/unused-parameter.h
+  build-aux/snippet/_Noreturn.h
+  build-aux/snippet/arg-nonnull.h
+  build-aux/snippet/c++defs.h
+  build-aux/snippet/unused-parameter.h
+  build-aux/snippet/warn-on-use.h
   build-aux/useless-if-before-free
   build-aux/vc-list-files
-  build-aux/warn-on-use.h
   doc/fdl-1.3.texi
   doc/gendocs_template
   doc/gpl-3.0.texi
   doc/lgpl-2.1.texi
-  lib/alignof.h
   lib/alloca.c
   lib/alloca.in.h
   lib/arpa_inet.in.h
@@ -949,6 +1008,7 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/c-ctype.h
   lib/c-strcase.h
   lib/c-strcasecmp.c
+  lib/c-strcaseeq.h
   lib/c-strncasecmp.c
   lib/close.c
   lib/config.charset
@@ -958,20 +1018,14 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/error.h
   lib/exitfail.c
   lib/exitfail.h
-  lib/fclose.c
   lib/fd-hook.c
   lib/fd-hook.h
-  lib/fflush.c
   lib/float+.h
   lib/float.c
   lib/float.in.h
-  lib/fpurge.c
-  lib/freading.c
-  lib/freading.h
   lib/fseek.c
   lib/fseeko.c
-  lib/ftell.c
-  lib/ftello.c
+  lib/fstat.c
   lib/gai_strerror.c
   lib/getaddrinfo.c
   lib/getdelim.c
@@ -994,6 +1048,7 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/iconv_open.c
   lib/inet_ntop.c
   lib/intprops.h
+  lib/itold.c
   lib/localcharset.c
   lib/localcharset.h
   lib/lseek.c
@@ -1002,6 +1057,10 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/mbsinit.c
   lib/memchr.c
   lib/memchr.valgrind
+  lib/msvc-inval.c
+  lib/msvc-inval.h
+  lib/msvc-nothrow.c
+  lib/msvc-nothrow.h
   lib/netdb.in.h
   lib/netinet_in.in.h
   lib/poll.c
@@ -1024,11 +1083,13 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/ref-del.sin
   lib/select.c
   lib/shutdown.c
+  lib/signal.in.h
   lib/size_max.h
   lib/snprintf.c
   lib/socket.c
   lib/sockets.c
   lib/sockets.h
+  lib/stdalign.in.h
   lib/stdarg.in.h
   lib/stdbool.in.h
   lib/stddef.in.h
@@ -1047,8 +1108,11 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/strtok_r.c
   lib/sys_select.in.h
   lib/sys_socket.in.h
+  lib/sys_stat.in.h
   lib/sys_time.in.h
+  lib/sys_types.in.h
   lib/sys_uio.in.h
+  lib/time.in.h
   lib/unistd.in.h
   lib/unistr.in.h
   lib/unistr/u8-mbtoucr.c
@@ -1082,19 +1146,17 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/environ.m4
   m4/errno_h.m4
   m4/error.m4
+  m4/exponentd.m4
   m4/extensions.m4
-  m4/fclose.m4
   m4/fcntl-o.m4
   m4/fcntl_h.m4
-  m4/fflush.m4
+  m4/fdopen.m4
   m4/float_h.m4
   m4/fpieee.m4
-  m4/fpurge.m4
-  m4/freading.m4
   m4/fseek.m4
   m4/fseeko.m4
-  m4/ftell.m4
-  m4/ftello.m4
+  m4/fstat.m4
+  m4/ftruncate.m4
   m4/getaddrinfo.m4
   m4/getcwd.m4
   m4/getdelim.m4
@@ -1119,6 +1181,7 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/inttypes.m4
   m4/inttypes_h.m4
   m4/ioctl.m4
+  m4/largefile.m4
   m4/lcmessage.m4
   m4/lib-ld.m4
   m4/lib-link.m4
@@ -1138,6 +1201,7 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/malloc.m4
   m4/malloca.m4
   m4/manywarnings.m4
+  m4/math_h.m4
   m4/mbrtowc.m4
   m4/mbsinit.m4
   m4/mbstate_t.m4
@@ -1145,10 +1209,14 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/memchr.m4
   m4/mmap-anon.m4
   m4/mode_t.m4
+  m4/msvc-inval.m4
+  m4/msvc-nothrow.m4
   m4/multiarch.m4
   m4/netdb_h.m4
   m4/netinet_in_h.m4
+  m4/nocrash.m4
   m4/open.m4
+  m4/pathmax.m4
   m4/perror.m4
   m4/pipe.m4
   m4/poll.m4
@@ -1163,13 +1231,16 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/servent.m4
   m4/setenv.m4
   m4/setlocale.m4
+  m4/signal_h.m4
   m4/size_max.m4
   m4/snprintf.m4
   m4/socketlib.m4
   m4/sockets.m4
   m4/socklen.m4
   m4/sockpfaf.m4
+  m4/ssize_t.m4
   m4/stat.m4
+  m4/stdalign.m4
   m4/stdarg.m4
   m4/stdbool.m4
   m4/stddef_h.m4
@@ -1188,6 +1259,7 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/sys_socket_h.m4
   m4/sys_stat_h.m4
   m4/sys_time_h.m4
+  m4/sys_types_h.m4
   m4/sys_uio_h.m4
   m4/thread.m4
   m4/threadlib.m4
@@ -1213,11 +1285,12 @@ AC_DEFUN([gl_FILE_LIST], [
   tests/init.sh
   tests/macros.h
   tests/signature.h
-  tests/test-alignof.c
+  tests/test-accept.c
   tests/test-alloca-opt.c
   tests/test-arpa_inet.c
   tests/test-binary-io.c
   tests/test-binary-io.sh
+  tests/test-bind.c
   tests/test-btowc.c
   tests/test-btowc1.sh
   tests/test-btowc2.sh
@@ -1225,31 +1298,31 @@ AC_DEFUN([gl_FILE_LIST], [
   tests/test-c-strcase.sh
   tests/test-c-strcasecmp.c
   tests/test-c-strncasecmp.c
+  tests/test-close.c
+  tests/test-connect.c
   tests/test-dup2.c
   tests/test-environ.c
   tests/test-errno.c
-  tests/test-fclose.c
   tests/test-fcntl-h.c
-  tests/test-fflush.c
-  tests/test-fflush2.c
-  tests/test-fflush2.sh
+  tests/test-fdopen.c
+  tests/test-fgetc.c
   tests/test-float.c
-  tests/test-fpurge.c
-  tests/test-freading.c
+  tests/test-fputc.c
+  tests/test-fread.c
   tests/test-fseek.c
   tests/test-fseek.sh
   tests/test-fseek2.sh
   tests/test-fseeko.c
   tests/test-fseeko.sh
   tests/test-fseeko2.sh
-  tests/test-ftell.c
-  tests/test-ftell.sh
-  tests/test-ftell2.sh
-  tests/test-ftell3.c
-  tests/test-ftello.c
-  tests/test-ftello.sh
-  tests/test-ftello2.sh
-  tests/test-ftello3.c
+  tests/test-fseeko3.c
+  tests/test-fseeko3.sh
+  tests/test-fseeko4.c
+  tests/test-fseeko4.sh
+  tests/test-fstat.c
+  tests/test-ftruncate.c
+  tests/test-ftruncate.sh
+  tests/test-fwrite.c
   tests/test-getaddrinfo.c
   tests/test-getcwd-lgpl.c
   tests/test-getdelim.c
@@ -1263,8 +1336,11 @@ AC_DEFUN([gl_FILE_LIST], [
   tests/test-ignore-value.c
   tests/test-inet_ntop.c
   tests/test-inet_pton.c
+  tests/test-init.sh
   tests/test-intprops.c
   tests/test-inttypes.c
+  tests/test-ioctl.c
+  tests/test-listen.c
   tests/test-locale.c
   tests/test-localename.c
   tests/test-lock.c
@@ -1291,6 +1367,7 @@ AC_DEFUN([gl_FILE_LIST], [
   tests/test-netinet_in.c
   tests/test-open.c
   tests/test-open.h
+  tests/test-pathmax.c
   tests/test-perror.c
   tests/test-perror.sh
   tests/test-perror2.c
@@ -1299,20 +1376,26 @@ AC_DEFUN([gl_FILE_LIST], [
   tests/test-poll.c
   tests/test-quotearg-simple.c
   tests/test-quotearg.h
+  tests/test-recv.c
   tests/test-select-fd.c
   tests/test-select-in.sh
   tests/test-select-out.sh
   tests/test-select-stdin.c
   tests/test-select.c
+  tests/test-select.h
   tests/test-setenv.c
   tests/test-setlocale1.c
   tests/test-setlocale1.sh
   tests/test-setlocale2.c
   tests/test-setlocale2.sh
+  tests/test-setsockopt.c
+  tests/test-shutdown.c
+  tests/test-signal-h.c
   tests/test-snprintf.c
   tests/test-sockets.c
   tests/test-stat.c
   tests/test-stat.h
+  tests/test-stdalign.c
   tests/test-stdbool.c
   tests/test-stddef.c
   tests/test-stdint.c
@@ -1329,8 +1412,11 @@ AC_DEFUN([gl_FILE_LIST], [
   tests/test-sys_socket.c
   tests/test-sys_stat.c
   tests/test-sys_time.c
+  tests/test-sys_types.c
   tests/test-sys_uio.c
   tests/test-sys_wait.h
+  tests/test-thread_create.c
+  tests/test-thread_self.c
   tests/test-time.c
   tests/test-unistd.c
   tests/test-unsetenv.c
@@ -1364,7 +1450,9 @@ AC_DEFUN([gl_FILE_LIST], [
   tests=lib/dosname.h
   tests=lib/dup2.c
   tests=lib/fcntl.in.h
+  tests=lib/fdopen.c
   tests=lib/fpucw.h
+  tests=lib/ftruncate.c
   tests=lib/getcwd-lgpl.c
   tests=lib/getpagesize.c
   tests=lib/gettimeofday.c
@@ -1389,6 +1477,7 @@ AC_DEFUN([gl_FILE_LIST], [
   tests=lib/mbtowc-impl.h
   tests=lib/mbtowc.c
   tests=lib/open.c
+  tests=lib/pathmax.h
   tests=lib/perror.c
   tests=lib/pipe.c
   tests=lib/putenv.c
@@ -1400,8 +1489,6 @@ AC_DEFUN([gl_FILE_LIST], [
   tests=lib/strerror_r.c
   tests=lib/symlink.c
   tests=lib/sys_ioctl.in.h
-  tests=lib/sys_stat.in.h
-  tests=lib/time.in.h
   tests=lib/unsetenv.c
   tests=lib/version-etc-fsf.c
   tests=lib/w32sock.h
diff --git a/gl/m4/gnulib-tool.m4 b/gl/m4/gnulib-tool.m4
index ed41e9d..a09ffc1 100644
--- a/gl/m4/gnulib-tool.m4
+++ b/gl/m4/gnulib-tool.m4
@@ -1,5 +1,5 @@
 # gnulib-tool.m4 serial 2
-dnl Copyright (C) 2004-2005, 2009-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2004-2005, 2009-2012 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.
diff --git a/gl/m4/hostent.m4 b/gl/m4/hostent.m4
index 36ade7e..5134775 100644
--- a/gl/m4/hostent.m4
+++ b/gl/m4/hostent.m4
@@ -1,5 +1,5 @@
 # hostent.m4 serial 2
-dnl Copyright (C) 2008, 2010-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2008, 2010-2012 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.
diff --git a/gl/m4/iconv.m4 b/gl/m4/iconv.m4
index 085cd06..6a47236 100644
--- a/gl/m4/iconv.m4
+++ b/gl/m4/iconv.m4
@@ -1,5 +1,5 @@
-# iconv.m4 serial 17 (gettext-0.18.2)
-dnl Copyright (C) 2000-2002, 2007-2011 Free Software Foundation, Inc.
+# iconv.m4 serial 18 (gettext-0.18.2)
+dnl Copyright (C) 2000-2002, 2007-2012 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.
@@ -242,7 +242,7 @@ extern
 #ifdef __cplusplus
 "C"
 #endif
-#if defined(__STDC__) || defined(__cplusplus)
+#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus)
 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, 
size_t *outbytesleft);
 #else
 size_t iconv();
diff --git a/gl/m4/iconv_h.m4 b/gl/m4/iconv_h.m4
index 8cca7fd..aa86cf8 100644
--- a/gl/m4/iconv_h.m4
+++ b/gl/m4/iconv_h.m4
@@ -1,5 +1,5 @@
 # iconv_h.m4 serial 8
-dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2007-2012 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.
diff --git a/gl/m4/iconv_open.m4 b/gl/m4/iconv_open.m4
index accdecc..07f4849 100644
--- a/gl/m4/iconv_open.m4
+++ b/gl/m4/iconv_open.m4
@@ -1,5 +1,5 @@
 # iconv_open.m4 serial 14
-dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2007-2012 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.
diff --git a/gl/m4/include_next.m4 b/gl/m4/include_next.m4
index b3c7849..a60a261 100644
--- a/gl/m4/include_next.m4
+++ b/gl/m4/include_next.m4
@@ -1,5 +1,5 @@
-# include_next.m4 serial 18
-dnl Copyright (C) 2006-2011 Free Software Foundation, Inc.
+# include_next.m4 serial 23
+dnl Copyright (C) 2006-2012 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.
@@ -143,7 +143,7 @@ choke me
 # even if the compiler does not support include_next.
 # The three "///" are to pacify Sun C 5.8, which otherwise would say
 # "warning: #include of /usr/include/... may be non-portable".
-# Use `""', not `<>', so that the /// cannot be confused with a C99 comment.
+# Use '""', not '<>', so that the /// cannot be confused with a C99 comment.
 # Note: This macro assumes that the header file is not empty after
 # preprocessing, i.e. it does not only define preprocessor macros but also
 # provides some type/enum definitions or function/variable declarations.
@@ -175,11 +175,13 @@ AC_DEFUN([gl_NEXT_HEADERS_INTERNAL],
     [AC_CHECK_HEADERS_ONCE([$1])
     ])
 
+dnl FIXME: gl_next_header and gl_header_exists must be used unquoted
+dnl until we can assume autoconf 2.64 or newer.
   m4_foreach_w([gl_HEADER_NAME], [$1],
     [AS_VAR_PUSHDEF([gl_next_header],
                     [gl_cv_next_]m4_defn([gl_HEADER_NAME]))
      if test $gl_cv_have_include_next = yes; then
-       AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
+       AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>'])
      else
        AC_CACHE_CHECK(
          [absolute name of <]m4_defn([gl_HEADER_NAME])[>],
@@ -205,33 +207,57 @@ AC_DEFUN([gl_NEXT_HEADERS_INTERNAL],
                  aix*) gl_absname_cpp="$ac_cpp -C" ;;
                  *)    gl_absname_cpp="$ac_cpp" ;;
                esac
+changequote(,)
+               case "$host_os" in
+                 mingw*)
+                   dnl For the sake of native Windows compilers (excluding 
gcc),
+                   dnl treat backslash as a directory separator, like /.
+                   dnl Actually, these compilers use a double-backslash as
+                   dnl directory separator, inside the
+                   dnl   # line "filename"
+                   dnl directives.
+                   gl_dirsep_regex='[/\\]'
+                   ;;
+                 *)
+                   gl_dirsep_regex='\/'
+                   ;;
+               esac
+               dnl A sed expression that turns a string into a basic regular
+               dnl expression, for use within "/.../".
+               gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
+changequote([,])
+               gl_header_literal_regex=`echo ']m4_defn([gl_HEADER_NAME])[' \
+                                        | sed -e "$gl_make_literal_regex_sed"`
+               
gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
+                   
s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
+changequote(,)dnl
+                   s|^/[^/]|//&|
+changequote([,])dnl
+                   p
+                   q
+                 }'
                dnl eval is necessary to expand gl_absname_cpp.
                dnl Ultrix and Pyramid sh refuse to redirect output of eval,
                dnl so use subshell.
-               AS_VAR_SET([gl_next_header],
+               AS_VAR_SET(gl_next_header,
                  ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 
2>&AS_MESSAGE_LOG_FD |
-                  sed -n '\#/]m4_defn([gl_HEADER_NAME])[#{
-                    s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1#
-                    s#^/[^/]#//&#
-                    p
-                    q
-                  }'`'"'])
+                      sed -n "$gl_absolute_header_sed"`'"'])
           m4_if([$2], [check],
             [else
-               AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
+               AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>'])
              fi
             ])
          ])
      fi
      AC_SUBST(
        AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])),
-       [AS_VAR_GET([gl_next_header])])
+       [AS_VAR_GET(gl_next_header)])
      if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = 
buggy; then
        # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
        gl_next_as_first_directive='<'gl_HEADER_NAME'>'
      else
        # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
-       gl_next_as_first_directive=AS_VAR_GET([gl_next_header])
+       gl_next_as_first_directive=AS_VAR_GET(gl_next_header)
      fi
      AC_SUBST(
        AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])),
diff --git a/gl/m4/inet_ntop.m4 b/gl/m4/inet_ntop.m4
index 45be497..1ebd960 100644
--- a/gl/m4/inet_ntop.m4
+++ b/gl/m4/inet_ntop.m4
@@ -1,44 +1,65 @@
-# inet_ntop.m4 serial 15
-dnl Copyright (C) 2005-2006, 2008-2011 Free Software Foundation, Inc.
+# inet_ntop.m4 serial 19
+dnl Copyright (C) 2005-2006, 2008-2012 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_FUNC_INET_NTOP],
 [
+  AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
+
   dnl Persuade Solaris <arpa/inet.h> to declare inet_ntop.
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
 
+  AC_REQUIRE([AC_C_RESTRICT])
+
   dnl Most platforms that provide inet_ntop define it in libc.
   dnl Solaris 8..10 provide inet_ntop in libnsl instead.
+  dnl Solaris 2.6..7 provide inet_ntop in libresolv instead.
+  dnl Native Windows provides it in -lws2_32 instead, with a declaration in
+  dnl <ws2tcpip.h>, and it uses stdcall calling convention, not cdecl
+  dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it).
   HAVE_INET_NTOP=1
-  gl_save_LIBS=$LIBS
-  AC_SEARCH_LIBS([inet_ntop], [nsl], [],
-    [AC_CHECK_FUNCS([inet_ntop])
-     if test $ac_cv_func_inet_ntop = no; then
-       HAVE_INET_NTOP=0
-     fi
-    ])
-  LIBS=$gl_save_LIBS
-
   INET_NTOP_LIB=
-  if test "$ac_cv_search_inet_ntop" != "no" &&
-     test "$ac_cv_search_inet_ntop" != "none required"; then
-    INET_NTOP_LIB="$ac_cv_search_inet_ntop"
-  fi
-  AC_SUBST([INET_NTOP_LIB])
+  gl_PREREQ_SYS_H_WINSOCK2
+  if test $HAVE_WINSOCK2_H = 1; then
+    AC_CHECK_DECLS([inet_ntop],,, [[#include <ws2tcpip.h>]])
+    if test $ac_cv_have_decl_inet_ntop = yes; then
+      dnl It needs to be overridden, because the stdcall calling convention
+      dnl is not compliant with POSIX.
+      REPLACE_INET_NTOP=1
+      INET_NTOP_LIB="-lws2_32"
+    else
+      HAVE_DECL_INET_NTOP=0
+      HAVE_INET_NTOP=0
+    fi
+  else
+    gl_save_LIBS=$LIBS
+    AC_SEARCH_LIBS([inet_ntop], [nsl resolv], [],
+      [AC_CHECK_FUNCS([inet_ntop])
+       if test $ac_cv_func_inet_ntop = no; then
+         HAVE_INET_NTOP=0
+       fi
+      ])
+    LIBS=$gl_save_LIBS
+
+    if test "$ac_cv_search_inet_ntop" != "no" \
+       && test "$ac_cv_search_inet_ntop" != "none required"; then
+      INET_NTOP_LIB="$ac_cv_search_inet_ntop"
+    fi
 
-  AC_CHECK_HEADERS_ONCE([netdb.h])
-  AC_CHECK_DECLS([inet_ntop],,,
-    [#include <arpa/inet.h>
-     #if HAVE_NETDB_H
-     # include <netdb.h>
-     #endif
-    ])
-  if test $ac_cv_have_decl_inet_ntop = no; then
-    HAVE_DECL_INET_NTOP=0
-    AC_REQUIRE([AC_C_RESTRICT])
+    AC_CHECK_HEADERS_ONCE([netdb.h])
+    AC_CHECK_DECLS([inet_ntop],,,
+      [[#include <arpa/inet.h>
+        #if HAVE_NETDB_H
+        # include <netdb.h>
+        #endif
+      ]])
+    if test $ac_cv_have_decl_inet_ntop = no; then
+      HAVE_DECL_INET_NTOP=0
+    fi
   fi
+  AC_SUBST([INET_NTOP_LIB])
 ])
 
 # Prerequisites of lib/inet_ntop.c.
diff --git a/gl/m4/inet_pton.m4 b/gl/m4/inet_pton.m4
index 9fc64df..e7b44e2 100644
--- a/gl/m4/inet_pton.m4
+++ b/gl/m4/inet_pton.m4
@@ -1,44 +1,65 @@
-# inet_pton.m4 serial 13
-dnl Copyright (C) 2006, 2008-2011 Free Software Foundation, Inc.
+# inet_pton.m4 serial 17
+dnl Copyright (C) 2006, 2008-2012 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_FUNC_INET_PTON],
 [
+  AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
+
   dnl Persuade Solaris <arpa/inet.h> to declare inet_pton.
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
 
+  AC_REQUIRE([AC_C_RESTRICT])
+
   dnl Most platforms that provide inet_pton define it in libc.
   dnl Solaris 8..10 provide inet_pton in libnsl instead.
+  dnl Solaris 2.6..7 provide inet_pton in libresolv instead.
+  dnl Native Windows provides it in -lws2_32 instead, with a declaration in
+  dnl <ws2tcpip.h>, and it uses stdcall calling convention, not cdecl
+  dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it).
   HAVE_INET_PTON=1
-  gl_save_LIBS=$LIBS
-  AC_SEARCH_LIBS([inet_pton], [nsl], [],
-    [AC_CHECK_FUNCS([inet_pton])
-     if test $ac_cv_func_inet_pton = no; then
-       HAVE_INET_PTON=0
-     fi
-    ])
-  LIBS=$gl_save_LIBS
-
   INET_PTON_LIB=
-  if test "$ac_cv_search_inet_pton" != "no" &&
-     test "$ac_cv_search_inet_pton" != "none required"; then
-    INET_PTON_LIB="$ac_cv_search_inet_pton"
-  fi
-  AC_SUBST([INET_PTON_LIB])
+  gl_PREREQ_SYS_H_WINSOCK2
+  if test $HAVE_WINSOCK2_H = 1; then
+    AC_CHECK_DECLS([inet_pton],,, [[#include <ws2tcpip.h>]])
+    if test $ac_cv_have_decl_inet_pton = yes; then
+      dnl It needs to be overridden, because the stdcall calling convention
+      dnl is not compliant with POSIX.
+      REPLACE_INET_PTON=1
+      INET_PTON_LIB="-lws2_32"
+    else
+      HAVE_DECL_INET_PTON=0
+      HAVE_INET_PTON=0
+    fi
+  else
+    gl_save_LIBS=$LIBS
+    AC_SEARCH_LIBS([inet_pton], [nsl resolv], [],
+      [AC_CHECK_FUNCS([inet_pton])
+       if test $ac_cv_func_inet_pton = no; then
+         HAVE_INET_PTON=0
+       fi
+      ])
+    LIBS=$gl_save_LIBS
+
+    if test "$ac_cv_search_inet_pton" != "no" \
+       && test "$ac_cv_search_inet_pton" != "none required"; then
+      INET_PTON_LIB="$ac_cv_search_inet_pton"
+    fi
 
-  AC_CHECK_HEADERS_ONCE([netdb.h])
-  AC_CHECK_DECLS([inet_pton],,,
-    [#include <arpa/inet.h>
-     #if HAVE_NETDB_H
-     # include <netdb.h>
-     #endif
-    ])
-  if test $ac_cv_have_decl_inet_pton = no; then
-    HAVE_DECL_INET_PTON=0
-    AC_REQUIRE([AC_C_RESTRICT])
+    AC_CHECK_HEADERS_ONCE([netdb.h])
+    AC_CHECK_DECLS([inet_pton],,,
+      [[#include <arpa/inet.h>
+        #if HAVE_NETDB_H
+        # include <netdb.h>
+        #endif
+      ]])
+    if test $ac_cv_have_decl_inet_pton = no; then
+      HAVE_DECL_INET_PTON=0
+    fi
   fi
+  AC_SUBST([INET_PTON_LIB])
 ])
 
 # Prerequisites of lib/inet_pton.c.
diff --git a/gl/m4/inline.m4 b/gl/m4/inline.m4
index a459080..6fa9972 100644
--- a/gl/m4/inline.m4
+++ b/gl/m4/inline.m4
@@ -1,5 +1,5 @@
 # inline.m4 serial 4
-dnl Copyright (C) 2006, 2009-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2006, 2009-2012 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.
diff --git a/gl/m4/intlmacosx.m4 b/gl/m4/intlmacosx.m4
index 51f8547..dc2ddfe 100644
--- a/gl/m4/intlmacosx.m4
+++ b/gl/m4/intlmacosx.m4
@@ -1,5 +1,5 @@
 # intlmacosx.m4 serial 4 (gettext-0.18.2)
-dnl Copyright (C) 2004-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2004-2012 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.
diff --git a/gl/m4/intmax_t.m4 b/gl/m4/intmax_t.m4
index 7341054..c1a4a75 100644
--- a/gl/m4/intmax_t.m4
+++ b/gl/m4/intmax_t.m4
@@ -1,5 +1,5 @@
 # intmax_t.m4 serial 8
-dnl Copyright (C) 1997-2004, 2006-2007, 2009-2011 Free Software Foundation,
+dnl Copyright (C) 1997-2004, 2006-2007, 2009-2012 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
diff --git a/gl/m4/inttypes-pri.m4 b/gl/m4/inttypes-pri.m4
index e252b27..977206f 100644
--- a/gl/m4/inttypes-pri.m4
+++ b/gl/m4/inttypes-pri.m4
@@ -1,5 +1,5 @@
 # inttypes-pri.m4 serial 7 (gettext-0.18.2)
-dnl Copyright (C) 1997-2002, 2006, 2008-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 1997-2002, 2006, 2008-2012 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.
diff --git a/gl/m4/inttypes.m4 b/gl/m4/inttypes.m4
index cc027a4..eec4f41 100644
--- a/gl/m4/inttypes.m4
+++ b/gl/m4/inttypes.m4
@@ -1,5 +1,5 @@
-# inttypes.m4 serial 24
-dnl Copyright (C) 2006-2011 Free Software Foundation, Inc.
+# inttypes.m4 serial 26
+dnl Copyright (C) 2006-2012 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.
@@ -24,22 +24,6 @@ AC_DEFUN_ONCE([gl_INTTYPES_INCOMPLETE],
 
   AC_REQUIRE([gl_MULTIARCH])
 
-  dnl Ensure that <stdint.h> defines the limit macros, since gnulib's
-  dnl <inttypes.h> relies on them.  This macro is only needed when a
-  dnl C++ compiler is in use; it has no effect for a C compiler.
-  dnl Also be careful to define __STDC_LIMIT_MACROS only when gnulib's
-  dnl <inttypes.h> is going to be created, and to avoid redefinition warnings
-  dnl if the __STDC_LIMIT_MACROS is already defined through the CPPFLAGS.
-  AC_DEFINE([GL_TRIGGER_STDC_LIMIT_MACROS], [1],
-    [Define to make the limit macros in <stdint.h> visible.])
-  AH_VERBATIM([__STDC_LIMIT_MACROS_ZZZ],
-[/* Ensure that <stdint.h> defines the limit macros, since gnulib's
-   <inttypes.h> relies on them.  */
-#if defined __cplusplus && !defined __STDC_LIMIT_MACROS && 
GL_TRIGGER_STDC_LIMIT_MACROS
-# define __STDC_LIMIT_MACROS 1
-#endif
-])
-
   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([[#include <inttypes.h>
@@ -163,6 +147,7 @@ AC_DEFUN([gl_INTTYPES_H_DEFAULTS],
   HAVE_DECL_IMAXDIV=1;   AC_SUBST([HAVE_DECL_IMAXDIV])
   HAVE_DECL_STRTOIMAX=1; AC_SUBST([HAVE_DECL_STRTOIMAX])
   HAVE_DECL_STRTOUMAX=1; AC_SUBST([HAVE_DECL_STRTOUMAX])
+  REPLACE_STRTOIMAX=0;   AC_SUBST([REPLACE_STRTOIMAX])
   INT32_MAX_LT_INTMAX_MAX=1;  AC_SUBST([INT32_MAX_LT_INTMAX_MAX])
   INT64_MAX_EQ_LONG_MAX='defined _LP64';  AC_SUBST([INT64_MAX_EQ_LONG_MAX])
   PRI_MACROS_BROKEN=0;   AC_SUBST([PRI_MACROS_BROKEN])
diff --git a/gl/m4/inttypes_h.m4 b/gl/m4/inttypes_h.m4
index f10fd54..91c7bca 100644
--- a/gl/m4/inttypes_h.m4
+++ b/gl/m4/inttypes_h.m4
@@ -1,5 +1,5 @@
 # inttypes_h.m4 serial 10
-dnl Copyright (C) 1997-2004, 2006, 2008-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 1997-2004, 2006, 2008-2012 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.
diff --git a/gl/m4/ioctl.m4 b/gl/m4/ioctl.m4
index e799600..ec0b728 100644
--- a/gl/m4/ioctl.m4
+++ b/gl/m4/ioctl.m4
@@ -1,5 +1,5 @@
-# ioctl.m4 serial 3
-dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
+# ioctl.m4 serial 4
+dnl Copyright (C) 2008-2012 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.
@@ -24,7 +24,12 @@ AC_DEFUN([gl_FUNC_IOCTL],
       [AC_COMPILE_IFELSE(
          [AC_LANG_PROGRAM(
             [[#include <sys/ioctl.h>]],
-            [[extern int ioctl (int, int, ...);]])
+            [[extern
+              #ifdef __cplusplus
+              "C"
+              #endif
+              int ioctl (int, int, ...);
+            ]])
          ],
          [gl_cv_func_ioctl_posix_signature=yes],
          [gl_cv_func_ioctl_posix_signature=no])
diff --git a/gl/m4/largefile.m4 b/gl/m4/largefile.m4
new file mode 100644
index 0000000..1369bbe
--- /dev/null
+++ b/gl/m4/largefile.m4
@@ -0,0 +1,104 @@
+# Enable large files on systems where this is not the default.
+
+# Copyright 1992-1996, 1998-2012 Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# The following implementation works around a problem in autoconf <= 2.68;
+# AC_SYS_LARGEFILE does not configure for large inodes on Mac OS X 10.5.
+m4_version_prereq([2.69], [] ,[
+
+# _AC_SYS_LARGEFILE_TEST_INCLUDES
+# -------------------------------
+m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES],
address@hidden:@include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+    We can't simply define LARGE_OFF_T to be 9223372036854775807,
+    since some C++ compilers masquerading as C compilers
+    incorrectly reject 9223372036854775807.  */
address@hidden:@define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+  int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721
+                       && LARGE_OFF_T % 2147483647 == 1)
+                      ? 1 : -1]];[]dnl
+])
+
+
+# _AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE,
+#                              CACHE-VAR,
+#                              DESCRIPTION,
+#                              PROLOGUE, [FUNCTION-BODY])
+# --------------------------------------------------------
+m4_define([_AC_SYS_LARGEFILE_MACRO_VALUE],
+[AC_CACHE_CHECK([for $1 value needed for large files], [$3],
+[while :; do
+  m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
+    [AC_LANG_PROGRAM([$5], [$6])],
+    [$3=no; break])
+  m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
+    [AC_LANG_PROGRAM(address@hidden:@define $1 $2
+$5], [$6])],
+    [$3=$2; break])
+  $3=unknown
+  break
+done])
+case $$3 in #(
+  no | unknown) ;;
+  *) AC_DEFINE_UNQUOTED([$1], [$$3], [$4]);;
+esac
+rm -rf conftest*[]dnl
+])# _AC_SYS_LARGEFILE_MACRO_VALUE
+
+
+# AC_SYS_LARGEFILE
+# ----------------
+# By default, many hosts won't let programs access large files;
+# one must use special compiler options to get large-file access to work.
+# For more details about this brain damage please see:
+# http://www.unix-systems.org/version2/whatsnew/lfs20mar.html
+AC_DEFUN([AC_SYS_LARGEFILE],
+[AC_ARG_ENABLE(largefile,
+               [  --disable-largefile     omit support for large files])
+if test "$enable_largefile" != no; then
+
+  AC_CACHE_CHECK([for special C compiler options needed for large files],
+    ac_cv_sys_largefile_CC,
+    [ac_cv_sys_largefile_CC=no
+     if test "$GCC" != yes; then
+       ac_save_CC=$CC
+       while :; do
+         # IRIX 6.2 and later do not support large files by default,
+         # so use the C compiler's -n32 option if that helps.
+         AC_LANG_CONFTEST([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_INCLUDES])])
+         AC_COMPILE_IFELSE([], [break])
+         CC="$CC -n32"
+         AC_COMPILE_IFELSE([], [ac_cv_sys_largefile_CC=' -n32'; break])
+         break
+       done
+       CC=$ac_save_CC
+       rm -f conftest.$ac_ext
+    fi])
+  if test "$ac_cv_sys_largefile_CC" != no; then
+    CC=$CC$ac_cv_sys_largefile_CC
+  fi
+
+  _AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
+    ac_cv_sys_file_offset_bits,
+    [Number of bits in a file offset, on hosts where this is settable.],
+    [_AC_SYS_LARGEFILE_TEST_INCLUDES])
+  if test $ac_cv_sys_file_offset_bits = unknown; then
+    _AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
+      ac_cv_sys_large_files,
+      [Define for large files, on AIX-style hosts.],
+      [_AC_SYS_LARGEFILE_TEST_INCLUDES])
+  fi
+
+  AH_VERBATIM([_DARWIN_USE_64_BIT_INODE],
+[/* Enable large inode numbers on Mac OS X.  */
+#ifndef _DARWIN_USE_64_BIT_INODE
+# define _DARWIN_USE_64_BIT_INODE 1
+#endif])
+fi
+])# AC_SYS_LARGEFILE
+
+])# m4_version_prereq 2.69
diff --git a/gl/m4/lcmessage.m4 b/gl/m4/lcmessage.m4
index baf41c5..4ed0eb6 100644
--- a/gl/m4/lcmessage.m4
+++ b/gl/m4/lcmessage.m4
@@ -1,5 +1,5 @@
 # lcmessage.m4 serial 7 (gettext-0.18.2)
-dnl Copyright (C) 1995-2002, 2004-2005, 2008-2011 Free Software Foundation,
+dnl Copyright (C) 1995-2002, 2004-2005, 2008-2012 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
diff --git a/gl/m4/lib-ld.m4 b/gl/m4/lib-ld.m4
index ae003f7..4e1374d 100644
--- a/gl/m4/lib-ld.m4
+++ b/gl/m4/lib-ld.m4
@@ -1,5 +1,5 @@
 # lib-ld.m4 serial 5 (gettext-0.18.2)
-dnl Copyright (C) 1996-2003, 2009-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 1996-2003, 2009-2012 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.
diff --git a/gl/m4/lib-link.m4 b/gl/m4/lib-link.m4
index e7c9ba9..d11b4b4 100644
--- a/gl/m4/lib-link.m4
+++ b/gl/m4/lib-link.m4
@@ -1,5 +1,5 @@
 # lib-link.m4 serial 26 (gettext-0.18.2)
-dnl Copyright (C) 2001-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2001-2012 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.
diff --git a/gl/m4/lib-prefix.m4 b/gl/m4/lib-prefix.m4
index 7e5f0bd..007aa05 100644
--- a/gl/m4/lib-prefix.m4
+++ b/gl/m4/lib-prefix.m4
@@ -1,5 +1,5 @@
 # lib-prefix.m4 serial 7 (gettext-0.18)
-dnl Copyright (C) 2001-2005, 2008-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2001-2005, 2008-2012 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.
diff --git a/gl/m4/libunistring-base.m4 b/gl/m4/libunistring-base.m4
index 9831448..d91c42b 100644
--- a/gl/m4/libunistring-base.m4
+++ b/gl/m4/libunistring-base.m4
@@ -1,5 +1,5 @@
 # libunistring-base.m4 serial 5
-dnl Copyright (C) 2010-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2010-2012 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.
diff --git a/gl/m4/localcharset.m4 b/gl/m4/localcharset.m4
index 6801ca9..8010379 100644
--- a/gl/m4/localcharset.m4
+++ b/gl/m4/localcharset.m4
@@ -1,5 +1,5 @@
 # localcharset.m4 serial 7
-dnl Copyright (C) 2002, 2004, 2006, 2009-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2004, 2006, 2009-2012 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.
diff --git a/gl/m4/locale-fr.m4 b/gl/m4/locale-fr.m4
index 3f4f954..04d801f 100644
--- a/gl/m4/locale-fr.m4
+++ b/gl/m4/locale-fr.m4
@@ -1,5 +1,5 @@
-# locale-fr.m4 serial 13
-dnl Copyright (C) 2003, 2005-2011 Free Software Foundation, Inc.
+# locale-fr.m4 serial 16
+dnl Copyright (C) 2003, 2005-2012 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.
@@ -26,9 +26,9 @@ char buf[16];
 int main () {
   /* Check whether the given locale name is recognized by the system.  */
 #if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
-  /* On native Win32, setlocale(category, "") looks at the system settings,
+  /* On native Windows, setlocale(category, "") looks at the system settings,
      not at the environment variables.  Also, when an encoding suffix such
-     as ".65001" or ".54936" is speficied, it succeeds but sets the LC_CTYPE
+     as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
      category of the locale to "C".  */
   if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
       || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
@@ -63,10 +63,12 @@ int main () {
      one byte long. This excludes the UTF-8 encoding.  */
   t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
   if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1;
+#if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy.  */
   /* Check whether the decimal separator is a comma.
      On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
      are nl_langinfo(RADIXCHAR) are both ".".  */
   if (localeconv () ->decimal_point[0] != ',') return 1;
+#endif
   return 0;
 }
 changequote([,])dnl
@@ -80,7 +82,7 @@ changequote([,])dnl
         # "ja" as "Japanese" or "Japanese_Japan.932",
         # and similar.
         mingw*)
-          # Test for the native Win32 locale name.
+          # Test for the native Windows locale name.
           if (LC_ALL=French_France.1252 LC_TIME= LC_CTYPE= ./conftest; exit) 
2>/dev/null; then
             gt_cv_locale_fr=French_France.1252
           else
@@ -152,9 +154,9 @@ int main () {
 #if !(defined __BEOS__ || defined __HAIKU__)
   /* Check whether the given locale name is recognized by the system.  */
 # if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
-  /* On native Win32, setlocale(category, "") looks at the system settings,
+  /* On native Windows, setlocale(category, "") looks at the system settings,
      not at the environment variables.  Also, when an encoding suffix such
-     as ".65001" or ".54936" is speficied, it succeeds but sets the LC_CTYPE
+     as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
      category of the locale to "C".  */
   if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
       || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
@@ -189,10 +191,12 @@ int main () {
       || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v')
     return 1;
 #endif
+#if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy.  */
   /* Check whether the decimal separator is a comma.
      On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
      are nl_langinfo(RADIXCHAR) are both ".".  */
   if (localeconv () ->decimal_point[0] != ',') return 1;
+#endif
   return 0;
 }
 changequote([,])dnl
@@ -206,7 +210,7 @@ changequote([,])dnl
         # "ja" as "Japanese" or "Japanese_Japan.932",
         # and similar.
         mingw*)
-          # Test for the hypothetical native Win32 locale name.
+          # Test for the hypothetical native Windows locale name.
           if (LC_ALL=French_France.65001 LC_TIME= LC_CTYPE= ./conftest; exit) 
2>/dev/null; then
             gt_cv_locale_fr_utf8=French_France.65001
           else
diff --git a/gl/m4/locale-ja.m4 b/gl/m4/locale-ja.m4
index d44c2c8..201ac4e 100644
--- a/gl/m4/locale-ja.m4
+++ b/gl/m4/locale-ja.m4
@@ -1,5 +1,5 @@
-# locale-ja.m4 serial 9
-dnl Copyright (C) 2003, 2005-2011 Free Software Foundation, Inc.
+# locale-ja.m4 serial 11
+dnl Copyright (C) 2003, 2005-2012 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.
@@ -28,9 +28,9 @@ int main ()
   const char *p;
   /* Check whether the given locale name is recognized by the system.  */
 #if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
-  /* On native Win32, setlocale(category, "") looks at the system settings,
+  /* On native Windows, setlocale(category, "") looks at the system settings,
      not at the environment variables.  Also, when an encoding suffix such
-     as ".65001" or ".54936" is speficied, it succeeds but sets the LC_CTYPE
+     as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
      category of the locale to "C".  */
   if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
       || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
@@ -84,8 +84,9 @@ changequote([,])dnl
         # "ja" as "Japanese" or "Japanese_Japan.932",
         # and similar.
         mingw*)
-          # Note that on native Win32, the Japanese locale is 
Japanese_Japan.932,
-          # and CP932 is very different from EUC-JP, so we cannot use it here.
+          # Note that on native Windows, the Japanese locale is
+          # Japanese_Japan.932, and CP932 is very different from EUC-JP, so we
+          # cannot use it here.
           gt_cv_locale_ja=none
           ;;
         *)
diff --git a/gl/m4/locale-tr.m4 b/gl/m4/locale-tr.m4
index 19ded1b..26b2ba2 100644
--- a/gl/m4/locale-tr.m4
+++ b/gl/m4/locale-tr.m4
@@ -1,5 +1,5 @@
-# locale-tr.m4 serial 7
-dnl Copyright (C) 2003, 2005-2011 Free Software Foundation, Inc.
+# locale-tr.m4 serial 9
+dnl Copyright (C) 2003, 2005-2012 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.
@@ -31,9 +31,9 @@ int main () {
      program return 1 on BeOS.  */
   /* Check whether the given locale name is recognized by the system.  */
 #if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
-  /* On native Win32, setlocale(category, "") looks at the system settings,
+  /* On native Windows, setlocale(category, "") looks at the system settings,
      not at the environment variables.  Also, when an encoding suffix such
-     as ".65001" or ".54936" is speficied, it succeeds but sets the LC_CTYPE
+     as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
      category of the locale to "C".  */
   if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
       || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
@@ -85,7 +85,7 @@ changequote([,])dnl
         # "ja" as "Japanese" or "Japanese_Japan.932",
         # and similar.
         mingw*)
-          # Test for the hypothetical native Win32 locale name.
+          # Test for the hypothetical native Windows locale name.
           if (LC_ALL=Turkish_Turkey.65001 LC_TIME= LC_CTYPE= ./conftest; exit) 
2>/dev/null; then
             gt_cv_locale_tr_utf8=Turkish_Turkey.65001
           else
diff --git a/gl/m4/locale-zh.m4 b/gl/m4/locale-zh.m4
index 5e06398..0cf5ada 100644
--- a/gl/m4/locale-zh.m4
+++ b/gl/m4/locale-zh.m4
@@ -1,5 +1,5 @@
-# locale-zh.m4 serial 9
-dnl Copyright (C) 2003, 2005-2011 Free Software Foundation, Inc.
+# locale-zh.m4 serial 11
+dnl Copyright (C) 2003, 2005-2012 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.
@@ -29,9 +29,9 @@ int main ()
   const char *p;
   /* Check whether the given locale name is recognized by the system.  */
 #if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
-  /* On native Win32, setlocale(category, "") looks at the system settings,
+  /* On native Windows, setlocale(category, "") looks at the system settings,
      not at the environment variables.  Also, when an encoding suffix such
-     as ".65001" or ".54936" is speficied, it succeeds but sets the LC_CTYPE
+     as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
      category of the locale to "C".  */
   if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
       || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
@@ -85,7 +85,7 @@ changequote([,])dnl
         # "ja" as "Japanese" or "Japanese_Japan.932",
         # and similar.
         mingw*)
-          # Test for the hypothetical native Win32 locale name.
+          # Test for the hypothetical native Windows locale name.
           if (LC_ALL=Chinese_China.54936 LC_TIME= LC_CTYPE= ./conftest; exit) 
2>/dev/null; then
             gt_cv_locale_zh_CN=Chinese_China.54936
           else
diff --git a/gl/m4/locale_h.m4 b/gl/m4/locale_h.m4
index e77a303..4289587 100644
--- a/gl/m4/locale_h.m4
+++ b/gl/m4/locale_h.m4
@@ -1,5 +1,5 @@
 # locale_h.m4 serial 14
-dnl Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2007, 2009-2012 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.
diff --git a/gl/m4/localename.m4 b/gl/m4/localename.m4
index 926ada6..2ba295e 100644
--- a/gl/m4/localename.m4
+++ b/gl/m4/localename.m4
@@ -1,5 +1,5 @@
 # localename.m4 serial 2
-dnl Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2007, 2009-2012 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.
diff --git a/gl/m4/lock.m4 b/gl/m4/lock.m4
index 9686945..c0a6206 100644
--- a/gl/m4/lock.m4
+++ b/gl/m4/lock.m4
@@ -1,5 +1,5 @@
 # lock.m4 serial 11 (gettext-0.18.2)
-dnl Copyright (C) 2005-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2005-2012 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.
diff --git a/gl/m4/longlong.m4 b/gl/m4/longlong.m4
index aed816c..b9c65c7 100644
--- a/gl/m4/longlong.m4
+++ b/gl/m4/longlong.m4
@@ -1,5 +1,5 @@
-# longlong.m4 serial 16
-dnl Copyright (C) 1999-2007, 2009-2011 Free Software Foundation, Inc.
+# longlong.m4 serial 17
+dnl Copyright (C) 1999-2007, 2009-2012 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.
@@ -51,7 +51,7 @@ AC_DEFUN([AC_TYPE_LONG_LONG_INT],
       fi])
   if test $ac_cv_type_long_long_int = yes; then
     AC_DEFINE([HAVE_LONG_LONG_INT], [1],
-      [Define to 1 if the system has the type `long long int'.])
+      [Define to 1 if the system has the type 'long long int'.])
   fi
 ])
 
@@ -77,7 +77,7 @@ AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT],
      fi])
   if test $ac_cv_type_unsigned_long_long_int = yes; then
     AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1],
-      [Define to 1 if the system has the type `unsigned long long int'.])
+      [Define to 1 if the system has the type 'unsigned long long int'.])
   fi
 ])
 
diff --git a/gl/m4/lseek.m4 b/gl/m4/lseek.m4
index b454884..86db59e 100644
--- a/gl/m4/lseek.m4
+++ b/gl/m4/lseek.m4
@@ -1,5 +1,5 @@
-# lseek.m4 serial 7
-dnl Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+# lseek.m4 serial 8
+dnl Copyright (C) 2007, 2009-2012 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.
@@ -8,12 +8,18 @@ AC_DEFUN([gl_FUNC_LSEEK],
 [
   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
   AC_REQUIRE([AC_PROG_CC])
+  AC_CHECK_HEADERS_ONCE([unistd.h])
   AC_CACHE_CHECK([whether lseek detects pipes], [gl_cv_func_lseek_pipe],
     [if test $cross_compiling = no; then
        AC_LINK_IFELSE([AC_LANG_PROGRAM([[
 #include <sys/types.h> /* for off_t */
 #include <stdio.h> /* for SEEK_CUR */
-#include <unistd.h>]], [[
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#else /* on Windows with MSVC */
+# include <io.h>
+#endif
+]], [[
   /* Exit with success only if stdin is seekable.  */
   return lseek (0, (off_t)0, SEEK_CUR) < 0;
 ]])],
diff --git a/gl/m4/lstat.m4 b/gl/m4/lstat.m4
index fe161d4..b83858b 100644
--- a/gl/m4/lstat.m4
+++ b/gl/m4/lstat.m4
@@ -1,6 +1,6 @@
-# serial 23
+# serial 24
 
-# Copyright (C) 1997-2001, 2003-2011 Free Software Foundation, Inc.
+# Copyright (C) 1997-2001, 2003-2012 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -65,6 +65,6 @@ AC_DEFUN([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK],
     ])
   test $gl_cv_func_lstat_dereferences_slashed_symlink = yes &&
     AC_DEFINE_UNQUOTED([LSTAT_FOLLOWS_SLASHED_SYMLINK], [1],
-      [Define to 1 if `lstat' dereferences a symlink specified
+      [Define to 1 if 'lstat' dereferences a symlink specified
        with a trailing slash.])
 ])
diff --git a/gl/m4/malloc.m4 b/gl/m4/malloc.m4
index 87018ec..d3c39f5 100644
--- a/gl/m4/malloc.m4
+++ b/gl/m4/malloc.m4
@@ -1,5 +1,5 @@
 # malloc.m4 serial 13
-dnl Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2007, 2009-2012 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.
diff --git a/gl/m4/malloca.m4 b/gl/m4/malloca.m4
index aec43f5..7841979 100644
--- a/gl/m4/malloca.m4
+++ b/gl/m4/malloca.m4
@@ -1,5 +1,5 @@
 # malloca.m4 serial 1
-dnl Copyright (C) 2003-2004, 2006-2007, 2009-2011 Free Software Foundation,
+dnl Copyright (C) 2003-2004, 2006-2007, 2009-2012 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
diff --git a/gl/m4/manywarnings.m4 b/gl/m4/manywarnings.m4
index 67db064..fd0e372 100644
--- a/gl/m4/manywarnings.m4
+++ b/gl/m4/manywarnings.m4
@@ -1,5 +1,5 @@
-# manywarnings.m4 serial 1
-dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
+# manywarnings.m4 serial 3
+dnl Copyright (C) 2008-2012 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.
@@ -30,9 +30,9 @@ AC_DEFUN([gl_MANYWARN_COMPLEMENT],
 
 # gl_MANYWARN_ALL_GCC(VARIABLE)
 # -----------------------------
-# Add all documented GCC (currently as per version 4.4) warning
-# parameters to variable VARIABLE.  Note that you need to test them
-# using gl_WARN_ADD if you want to make sure your gcc understands it.
+# Add all documented GCC warning parameters to variable VARIABLE.
+# Note that you need to test them using gl_WARN_ADD if you want to
+# make sure your gcc understands it.
 AC_DEFUN([gl_MANYWARN_ALL_GCC],
 [
   dnl First, check if -Wno-missing-field-initializers is needed.
@@ -148,6 +148,32 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
     ; do
     gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
   done
+  # More warnings from gcc 4.6.2 --help=warnings.
+  for gl_manywarn_item in \
+    -Wabi \
+    -Wcpp \
+    -Wdeprecated \
+    -Wdeprecated-declarations \
+    -Wdiv-by-zero \
+    -Wdouble-promotion \
+    -Wendif-labels \
+    -Wextra \
+    -Wformat-contains-nul \
+    -Wformat-extra-args \
+    -Wformat-zero-length \
+    -Wformat=2 \
+    -Wmultichar \
+    -Wnormalized=nfc \
+    -Woverflow \
+    -Wpointer-to-int-cast \
+    -Wpragmas \
+    -Wsuggest-attribute=const \
+    -Wsuggest-attribute=noreturn \
+    -Wsuggest-attribute=pure \
+    -Wtrampolines \
+    ; do
+    gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
+  done
 
   # Disable the missing-field-initializers warning if needed
   if test "$gl_cv_cc_nomfi_needed" = yes; then
diff --git a/gl/m4/math_h.m4 b/gl/m4/math_h.m4
new file mode 100644
index 0000000..5d7d52b
--- /dev/null
+++ b/gl/m4/math_h.m4
@@ -0,0 +1,243 @@
+# math_h.m4 serial 56
+dnl Copyright (C) 2007-2012 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_MATH_H],
+[
+  AC_REQUIRE([gl_MATH_H_DEFAULTS])
+  gl_CHECK_NEXT_HEADERS([math.h])
+  AC_REQUIRE([AC_C_INLINE])
+
+  AC_CACHE_CHECK([whether NAN macro works], [gl_cv_header_math_nan_works],
+    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(address@hidden:@include <math.h>]],
+      [[/* Solaris 10 has a broken definition of NAN.  Other platforms
+        fail to provide NAN, or provide it only in C99 mode; this
+        test only needs to fail when NAN is provided but wrong.  */
+         float f = 1.0f;
+#ifdef NAN
+         f = NAN;
+#endif
+         return f == 0;]])],
+      [gl_cv_header_math_nan_works=yes],
+      [gl_cv_header_math_nan_works=no])])
+  if test $gl_cv_header_math_nan_works = no; then
+    REPLACE_NAN=1
+  fi
+  AC_CACHE_CHECK([whether HUGE_VAL works], [gl_cv_header_math_huge_val_works],
+    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(address@hidden:@include <math.h>]],
+      [[/* Solaris 10 has a broken definition of HUGE_VAL.  */
+         double d = HUGE_VAL;
+         return d == 0;]])],
+      [gl_cv_header_math_huge_val_works=yes],
+      [gl_cv_header_math_huge_val_works=no])])
+  if test $gl_cv_header_math_huge_val_works = no; then
+    REPLACE_HUGE_VAL=1
+  fi
+
+  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([[#include <math.h>]],
+    [acosf acosl asinf asinl atanf atanl
+     ceilf ceill copysign copysignf copysignl cosf cosl coshf
+     expf expl fabsf floorf floorl fma fmaf fmal fmodf frexpf frexpl
+     ldexpf ldexpl logb logf logl log10f modff powf
+     rint rintf rintl round roundf roundl sinf sinl sinhf sqrtf sqrtl
+     tanf tanl tanhf trunc truncf truncl])
+])
+
+AC_DEFUN([gl_MATH_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_MATH_H_DEFAULTS])
+  gl_MODULE_INDICATOR_SET_VARIABLE([$1])
+  dnl Define it also as a C macro, for the benefit of the unit tests.
+  gl_MODULE_INDICATOR_FOR_TESTS([$1])
+])
+
+AC_DEFUN([gl_MATH_H_DEFAULTS],
+[
+  GNULIB_ACOSF=0;     AC_SUBST([GNULIB_ACOSF])
+  GNULIB_ACOSL=0;     AC_SUBST([GNULIB_ACOSL])
+  GNULIB_ASINF=0;     AC_SUBST([GNULIB_ASINF])
+  GNULIB_ASINL=0;     AC_SUBST([GNULIB_ASINL])
+  GNULIB_ATANF=0;     AC_SUBST([GNULIB_ATANF])
+  GNULIB_ATANL=0;     AC_SUBST([GNULIB_ATANL])
+  GNULIB_ATAN2F=0;    AC_SUBST([GNULIB_ATAN2F])
+  GNULIB_CEIL=0;      AC_SUBST([GNULIB_CEIL])
+  GNULIB_CEILF=0;     AC_SUBST([GNULIB_CEILF])
+  GNULIB_CEILL=0;     AC_SUBST([GNULIB_CEILL])
+  GNULIB_COPYSIGN=0;  AC_SUBST([GNULIB_COPYSIGN])
+  GNULIB_COPYSIGNF=0; AC_SUBST([GNULIB_COPYSIGNF])
+  GNULIB_COPYSIGNL=0; AC_SUBST([GNULIB_COPYSIGNL])
+  GNULIB_COSF=0;      AC_SUBST([GNULIB_COSF])
+  GNULIB_COSL=0;      AC_SUBST([GNULIB_COSL])
+  GNULIB_COSHF=0;     AC_SUBST([GNULIB_COSHF])
+  GNULIB_EXPF=0;      AC_SUBST([GNULIB_EXPF])
+  GNULIB_EXPL=0;      AC_SUBST([GNULIB_EXPL])
+  GNULIB_FABSF=0;     AC_SUBST([GNULIB_FABSF])
+  GNULIB_FLOOR=0;     AC_SUBST([GNULIB_FLOOR])
+  GNULIB_FLOORF=0;    AC_SUBST([GNULIB_FLOORF])
+  GNULIB_FLOORL=0;    AC_SUBST([GNULIB_FLOORL])
+  GNULIB_FMA=0;       AC_SUBST([GNULIB_FMA])
+  GNULIB_FMAF=0;      AC_SUBST([GNULIB_FMAF])
+  GNULIB_FMAL=0;      AC_SUBST([GNULIB_FMAL])
+  GNULIB_FMODF=0;     AC_SUBST([GNULIB_FMODF])
+  GNULIB_FREXPF=0;    AC_SUBST([GNULIB_FREXPF])
+  GNULIB_FREXP=0;     AC_SUBST([GNULIB_FREXP])
+  GNULIB_FREXPL=0;    AC_SUBST([GNULIB_FREXPL])
+  GNULIB_ISFINITE=0;  AC_SUBST([GNULIB_ISFINITE])
+  GNULIB_ISINF=0;     AC_SUBST([GNULIB_ISINF])
+  GNULIB_ISNAN=0;     AC_SUBST([GNULIB_ISNAN])
+  GNULIB_ISNANF=0;    AC_SUBST([GNULIB_ISNANF])
+  GNULIB_ISNAND=0;    AC_SUBST([GNULIB_ISNAND])
+  GNULIB_ISNANL=0;    AC_SUBST([GNULIB_ISNANL])
+  GNULIB_LDEXPF=0;    AC_SUBST([GNULIB_LDEXPF])
+  GNULIB_LDEXPL=0;    AC_SUBST([GNULIB_LDEXPL])
+  GNULIB_LOGB=0;      AC_SUBST([GNULIB_LOGB])
+  GNULIB_LOGF=0;      AC_SUBST([GNULIB_LOGF])
+  GNULIB_LOGL=0;      AC_SUBST([GNULIB_LOGL])
+  GNULIB_LOG10F=0;    AC_SUBST([GNULIB_LOG10F])
+  GNULIB_MODFF=0;     AC_SUBST([GNULIB_MODFF])
+  GNULIB_POWF=0;      AC_SUBST([GNULIB_POWF])
+  GNULIB_RINT=0;      AC_SUBST([GNULIB_RINT])
+  GNULIB_RINTF=0;     AC_SUBST([GNULIB_RINTF])
+  GNULIB_RINTL=0;     AC_SUBST([GNULIB_RINTL])
+  GNULIB_ROUND=0;     AC_SUBST([GNULIB_ROUND])
+  GNULIB_ROUNDF=0;    AC_SUBST([GNULIB_ROUNDF])
+  GNULIB_ROUNDL=0;    AC_SUBST([GNULIB_ROUNDL])
+  GNULIB_SIGNBIT=0;   AC_SUBST([GNULIB_SIGNBIT])
+  GNULIB_SINF=0;      AC_SUBST([GNULIB_SINF])
+  GNULIB_SINL=0;      AC_SUBST([GNULIB_SINL])
+  GNULIB_SINHF=0;     AC_SUBST([GNULIB_SINHF])
+  GNULIB_SQRTF=0;     AC_SUBST([GNULIB_SQRTF])
+  GNULIB_SQRTL=0;     AC_SUBST([GNULIB_SQRTL])
+  GNULIB_TANF=0;      AC_SUBST([GNULIB_TANF])
+  GNULIB_TANL=0;      AC_SUBST([GNULIB_TANL])
+  GNULIB_TANHF=0;     AC_SUBST([GNULIB_TANHF])
+  GNULIB_TRUNC=0;     AC_SUBST([GNULIB_TRUNC])
+  GNULIB_TRUNCF=0;    AC_SUBST([GNULIB_TRUNCF])
+  GNULIB_TRUNCL=0;    AC_SUBST([GNULIB_TRUNCL])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_ACOSF=1;                AC_SUBST([HAVE_ACOSF])
+  HAVE_ACOSL=1;                AC_SUBST([HAVE_ACOSL])
+  HAVE_ASINF=1;                AC_SUBST([HAVE_ASINF])
+  HAVE_ASINL=1;                AC_SUBST([HAVE_ASINL])
+  HAVE_ATANF=1;                AC_SUBST([HAVE_ATANF])
+  HAVE_ATANL=1;                AC_SUBST([HAVE_ATANL])
+  HAVE_ATAN2F=1;               AC_SUBST([HAVE_ATAN2F])
+  HAVE_COPYSIGN=1;             AC_SUBST([HAVE_COPYSIGN])
+  HAVE_COPYSIGNF=1;            AC_SUBST([HAVE_COPYSIGNF])
+  HAVE_COPYSIGNL=1;            AC_SUBST([HAVE_COPYSIGNL])
+  HAVE_COSF=1;                 AC_SUBST([HAVE_COSF])
+  HAVE_COSL=1;                 AC_SUBST([HAVE_COSL])
+  HAVE_COSHF=1;                AC_SUBST([HAVE_COSHF])
+  HAVE_EXPF=1;                 AC_SUBST([HAVE_EXPF])
+  HAVE_EXPL=1;                 AC_SUBST([HAVE_EXPL])
+  HAVE_FABSF=1;                AC_SUBST([HAVE_FABSF])
+  HAVE_FMA=1;                  AC_SUBST([HAVE_FMA])
+  HAVE_FMAF=1;                 AC_SUBST([HAVE_FMAF])
+  HAVE_FMAL=1;                 AC_SUBST([HAVE_FMAL])
+  HAVE_FMODF=1;                AC_SUBST([HAVE_FMODF])
+  HAVE_FREXPF=1;               AC_SUBST([HAVE_FREXPF])
+  HAVE_ISNANF=1;               AC_SUBST([HAVE_ISNANF])
+  HAVE_ISNAND=1;               AC_SUBST([HAVE_ISNAND])
+  HAVE_ISNANL=1;               AC_SUBST([HAVE_ISNANL])
+  HAVE_LDEXPF=1;               AC_SUBST([HAVE_LDEXPF])
+  HAVE_LOGF=1;                 AC_SUBST([HAVE_LOGF])
+  HAVE_LOGL=1;                 AC_SUBST([HAVE_LOGL])
+  HAVE_LOG10F=1;               AC_SUBST([HAVE_LOG10F])
+  HAVE_MODFF=1;                AC_SUBST([HAVE_MODFF])
+  HAVE_POWF=1;                 AC_SUBST([HAVE_POWF])
+  HAVE_RINT=1;                 AC_SUBST([HAVE_RINT])
+  HAVE_RINTF=1;                AC_SUBST([HAVE_RINTF])
+  HAVE_RINTL=1;                AC_SUBST([HAVE_RINTL])
+  HAVE_SINF=1;                 AC_SUBST([HAVE_SINF])
+  HAVE_SINL=1;                 AC_SUBST([HAVE_SINL])
+  HAVE_SINHF=1;                AC_SUBST([HAVE_SINHF])
+  HAVE_SQRTF=1;                AC_SUBST([HAVE_SQRTF])
+  HAVE_SQRTL=1;                AC_SUBST([HAVE_SQRTL])
+  HAVE_TANF=1;                 AC_SUBST([HAVE_TANF])
+  HAVE_TANL=1;                 AC_SUBST([HAVE_TANL])
+  HAVE_TANHF=1;                AC_SUBST([HAVE_TANHF])
+  HAVE_DECL_ACOSL=1;           AC_SUBST([HAVE_DECL_ACOSL])
+  HAVE_DECL_ASINL=1;           AC_SUBST([HAVE_DECL_ASINL])
+  HAVE_DECL_ATANL=1;           AC_SUBST([HAVE_DECL_ATANL])
+  HAVE_DECL_CEILF=1;           AC_SUBST([HAVE_DECL_CEILF])
+  HAVE_DECL_CEILL=1;           AC_SUBST([HAVE_DECL_CEILL])
+  HAVE_DECL_COSL=1;            AC_SUBST([HAVE_DECL_COSL])
+  HAVE_DECL_EXPL=1;            AC_SUBST([HAVE_DECL_EXPL])
+  HAVE_DECL_FLOORF=1;          AC_SUBST([HAVE_DECL_FLOORF])
+  HAVE_DECL_FLOORL=1;          AC_SUBST([HAVE_DECL_FLOORL])
+  HAVE_DECL_FREXPL=1;          AC_SUBST([HAVE_DECL_FREXPL])
+  HAVE_DECL_LDEXPL=1;          AC_SUBST([HAVE_DECL_LDEXPL])
+  HAVE_DECL_LOGB=1;            AC_SUBST([HAVE_DECL_LOGB])
+  HAVE_DECL_LOGL=1;            AC_SUBST([HAVE_DECL_LOGL])
+  HAVE_DECL_ROUND=1;           AC_SUBST([HAVE_DECL_ROUND])
+  HAVE_DECL_ROUNDF=1;          AC_SUBST([HAVE_DECL_ROUNDF])
+  HAVE_DECL_ROUNDL=1;          AC_SUBST([HAVE_DECL_ROUNDL])
+  HAVE_DECL_SINL=1;            AC_SUBST([HAVE_DECL_SINL])
+  HAVE_DECL_SQRTL=1;           AC_SUBST([HAVE_DECL_SQRTL])
+  HAVE_DECL_TANL=1;            AC_SUBST([HAVE_DECL_TANL])
+  HAVE_DECL_TRUNC=1;           AC_SUBST([HAVE_DECL_TRUNC])
+  HAVE_DECL_TRUNCF=1;          AC_SUBST([HAVE_DECL_TRUNCF])
+  HAVE_DECL_TRUNCL=1;          AC_SUBST([HAVE_DECL_TRUNCL])
+  REPLACE_CEIL=0;              AC_SUBST([REPLACE_CEIL])
+  REPLACE_CEILF=0;             AC_SUBST([REPLACE_CEILF])
+  REPLACE_CEILL=0;             AC_SUBST([REPLACE_CEILL])
+  REPLACE_FLOOR=0;             AC_SUBST([REPLACE_FLOOR])
+  REPLACE_FLOORF=0;            AC_SUBST([REPLACE_FLOORF])
+  REPLACE_FLOORL=0;            AC_SUBST([REPLACE_FLOORL])
+  REPLACE_FMA=0;               AC_SUBST([REPLACE_FMA])
+  REPLACE_FMAF=0;              AC_SUBST([REPLACE_FMAF])
+  REPLACE_FMAL=0;              AC_SUBST([REPLACE_FMAL])
+  REPLACE_FREXPF=0;            AC_SUBST([REPLACE_FREXPF])
+  REPLACE_FREXP=0;             AC_SUBST([REPLACE_FREXP])
+  REPLACE_FREXPL=0;            AC_SUBST([REPLACE_FREXPL])
+  REPLACE_HUGE_VAL=0;          AC_SUBST([REPLACE_HUGE_VAL])
+  REPLACE_ISFINITE=0;          AC_SUBST([REPLACE_ISFINITE])
+  REPLACE_ISINF=0;             AC_SUBST([REPLACE_ISINF])
+  REPLACE_ISNAN=0;             AC_SUBST([REPLACE_ISNAN])
+  REPLACE_LDEXPL=0;            AC_SUBST([REPLACE_LDEXPL])
+  REPLACE_NAN=0;               AC_SUBST([REPLACE_NAN])
+  REPLACE_ROUND=0;             AC_SUBST([REPLACE_ROUND])
+  REPLACE_ROUNDF=0;            AC_SUBST([REPLACE_ROUNDF])
+  REPLACE_ROUNDL=0;            AC_SUBST([REPLACE_ROUNDL])
+  REPLACE_SIGNBIT=0;           AC_SUBST([REPLACE_SIGNBIT])
+  REPLACE_SIGNBIT_USING_GCC=0; AC_SUBST([REPLACE_SIGNBIT_USING_GCC])
+  REPLACE_TRUNC=0;             AC_SUBST([REPLACE_TRUNC])
+  REPLACE_TRUNCF=0;            AC_SUBST([REPLACE_TRUNCF])
+  REPLACE_TRUNCL=0;            AC_SUBST([REPLACE_TRUNCL])
+])
+
+# gl_LONG_DOUBLE_VS_DOUBLE
+# determines whether 'long double' and 'double' have the same representation.
+# Sets variable HAVE_SAME_LONG_DOUBLE_AS_DOUBLE to 0 or 1, and defines
+# HAVE_SAME_LONG_DOUBLE_AS_DOUBLE accordingly.
+# The currently known platforms where this is the case are:
+# Linux/HPPA, Minix 3.1.8, AIX 5, AIX 6 and 7 with xlc, MSVC 9.
+AC_DEFUN([gl_LONG_DOUBLE_VS_DOUBLE],
+[
+  AC_CACHE_CHECK([whether long double and double are the same],
+    [gl_cv_long_double_equals_double],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM([[#include <float.h>]],
+          [[typedef int check[sizeof (long double) == sizeof (double)
+                              && LDBL_MANT_DIG == DBL_MANT_DIG
+                              && LDBL_MAX_EXP == DBL_MAX_EXP
+                              && LDBL_MIN_EXP == DBL_MIN_EXP
+                              ? 1 : -1];
+          ]])],
+       [gl_cv_long_double_equals_double=yes],
+       [gl_cv_long_double_equals_double=no])
+    ])
+  if test $gl_cv_long_double_equals_double = yes; then
+    AC_DEFINE([HAVE_SAME_LONG_DOUBLE_AS_DOUBLE], [1],
+      [Define to 1 if 'long double' and 'double' have the same 
representation.])
+    HAVE_SAME_LONG_DOUBLE_AS_DOUBLE=1
+  else
+    HAVE_SAME_LONG_DOUBLE_AS_DOUBLE=0
+  fi
+  AC_SUBST([HAVE_SAME_LONG_DOUBLE_AS_DOUBLE])
+])
diff --git a/gl/m4/mbrtowc.m4 b/gl/m4/mbrtowc.m4
index b9e01e7..8f829c8 100644
--- a/gl/m4/mbrtowc.m4
+++ b/gl/m4/mbrtowc.m4
@@ -1,5 +1,5 @@
-# mbrtowc.m4 serial 24
-dnl Copyright (C) 2001-2002, 2004-2005, 2008-2011 Free Software Foundation,
+# mbrtowc.m4 serial 25
+dnl Copyright (C) 2001-2002, 2004-2005, 2008-2012 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -15,6 +15,22 @@ AC_DEFUN([gl_FUNC_MBRTOWC],
   AC_CHECK_FUNCS_ONCE([mbrtowc])
   if test $ac_cv_func_mbrtowc = no; then
     HAVE_MBRTOWC=0
+    AC_CHECK_DECLS([mbrtowc],,, [[
+/* 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
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+]])
+    if test $ac_cv_have_decl_mbrtowc = yes; then
+      dnl On Minix 3.1.8, the system's <wchar.h> declares mbrtowc() although
+      dnl it does not have the function. Avoid a collision with gnulib's
+      dnl replacement.
+      REPLACE_MBRTOWC=1
+    fi
   else
     if test $REPLACE_MBSTATE_T = 1; then
       REPLACE_MBRTOWC=1
diff --git a/gl/m4/mbsinit.m4 b/gl/m4/mbsinit.m4
index d364b7e..da56c3d 100644
--- a/gl/m4/mbsinit.m4
+++ b/gl/m4/mbsinit.m4
@@ -1,5 +1,5 @@
-# mbsinit.m4 serial 7
-dnl Copyright (C) 2008, 2010-2011 Free Software Foundation, Inc.
+# mbsinit.m4 serial 8
+dnl Copyright (C) 2008, 2010-2012 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.
@@ -15,6 +15,22 @@ AC_DEFUN([gl_FUNC_MBSINIT],
   AC_CHECK_FUNCS_ONCE([mbsinit])
   if test $ac_cv_func_mbsinit = no; then
     HAVE_MBSINIT=0
+    AC_CHECK_DECLS([mbsinit],,, [[
+/* 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
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+]])
+    if test $ac_cv_have_decl_mbsinit = yes; then
+      dnl On Minix 3.1.8, the system's <wchar.h> declares mbsinit() although
+      dnl it does not have the function. Avoid a collision with gnulib's
+      dnl replacement.
+      REPLACE_MBSINIT=1
+    fi
   else
     if test $REPLACE_MBSTATE_T = 1; then
       REPLACE_MBSINIT=1
diff --git a/gl/m4/mbstate_t.m4 b/gl/m4/mbstate_t.m4
index f7c46b8..61a8190 100644
--- a/gl/m4/mbstate_t.m4
+++ b/gl/m4/mbstate_t.m4
@@ -1,5 +1,5 @@
 # mbstate_t.m4 serial 13
-dnl Copyright (C) 2000-2002, 2008-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2000-2002, 2008-2012 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.
diff --git a/gl/m4/mbtowc.m4 b/gl/m4/mbtowc.m4
index 7793a00..fec0d25 100644
--- a/gl/m4/mbtowc.m4
+++ b/gl/m4/mbtowc.m4
@@ -1,5 +1,5 @@
 # mbtowc.m4 serial 2
-dnl Copyright (C) 2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2011-2012 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.
diff --git a/gl/m4/memchr.m4 b/gl/m4/memchr.m4
index f6dc3e7..0040294 100644
--- a/gl/m4/memchr.m4
+++ b/gl/m4/memchr.m4
@@ -1,5 +1,5 @@
 # memchr.m4 serial 12
-dnl Copyright (C) 2002-2004, 2009-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2004, 2009-2012 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.
diff --git a/gl/m4/mmap-anon.m4 b/gl/m4/mmap-anon.m4
index 7ba7fd2..4613cbe 100644
--- a/gl/m4/mmap-anon.m4
+++ b/gl/m4/mmap-anon.m4
@@ -1,5 +1,5 @@
 # mmap-anon.m4 serial 9
-dnl Copyright (C) 2005, 2007, 2009-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2005, 2007, 2009-2012 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.
@@ -27,18 +27,18 @@ AC_DEFUN([gl_FUNC_MMAP_ANON],
   gl_have_mmap_anonymous=no
   if test $gl_have_mmap = yes; then
     AC_MSG_CHECKING([for MAP_ANONYMOUS])
-    AC_EGREP_CPP([I cant identify this map.], [
+    AC_EGREP_CPP([I cant identify this map], [
 #include <sys/mman.h>
 #ifdef MAP_ANONYMOUS
-    I cant identify this map.
+    I cant identify this map
 #endif
 ],
       [gl_have_mmap_anonymous=yes])
     if test $gl_have_mmap_anonymous != yes; then
-      AC_EGREP_CPP([I cant identify this map.], [
+      AC_EGREP_CPP([I cant identify this map], [
 #include <sys/mman.h>
 #ifdef MAP_ANON
-    I cant identify this map.
+    I cant identify this map
 #endif
 ],
         [AC_DEFINE([MAP_ANONYMOUS], [MAP_ANON],
diff --git a/gl/m4/mode_t.m4 b/gl/m4/mode_t.m4
index f9cf704..40f612a 100644
--- a/gl/m4/mode_t.m4
+++ b/gl/m4/mode_t.m4
@@ -1,5 +1,5 @@
 # mode_t.m4 serial 2
-dnl Copyright (C) 2009-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2009-2012 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.
diff --git a/gl/m4/msvc-inval.m4 b/gl/m4/msvc-inval.m4
new file mode 100644
index 0000000..8db4617
--- /dev/null
+++ b/gl/m4/msvc-inval.m4
@@ -0,0 +1,19 @@
+# msvc-inval.m4 serial 1
+dnl Copyright (C) 2011-2012 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_MSVC_INVAL],
+[
+  AC_CHECK_FUNCS_ONCE([_set_invalid_parameter_handler])
+  if test $ac_cv_func__set_invalid_parameter_handler = yes; then
+    HAVE_MSVC_INVALID_PARAMETER_HANDLER=1
+    AC_DEFINE([HAVE_MSVC_INVALID_PARAMETER_HANDLER], [1],
+      [Define to 1 on MSVC platforms that have the "invalid parameter handler"
+       concept.])
+  else
+    HAVE_MSVC_INVALID_PARAMETER_HANDLER=0
+  fi
+  AC_SUBST([HAVE_MSVC_INVALID_PARAMETER_HANDLER])
+])
diff --git a/gl/m4/msvc-nothrow.m4 b/gl/m4/msvc-nothrow.m4
new file mode 100644
index 0000000..0125050
--- /dev/null
+++ b/gl/m4/msvc-nothrow.m4
@@ -0,0 +1,10 @@
+# msvc-nothrow.m4 serial 1
+dnl Copyright (C) 2011-2012 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_MSVC_NOTHROW],
+[
+  AC_REQUIRE([gl_MSVC_INVAL])
+])
diff --git a/gl/m4/multiarch.m4 b/gl/m4/multiarch.m4
index 691d892..b424dce 100644
--- a/gl/m4/multiarch.m4
+++ b/gl/m4/multiarch.m4
@@ -1,5 +1,5 @@
 # multiarch.m4 serial 6
-dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2008-2012 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.
diff --git a/gl/m4/netdb_h.m4 b/gl/m4/netdb_h.m4
index a54d670..e0f3ee8 100644
--- a/gl/m4/netdb_h.m4
+++ b/gl/m4/netdb_h.m4
@@ -1,5 +1,5 @@
 # netdb_h.m4 serial 11
-dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2008-2012 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.
diff --git a/gl/m4/netinet_in_h.m4 b/gl/m4/netinet_in_h.m4
index 87235b7..e181388 100644
--- a/gl/m4/netinet_in_h.m4
+++ b/gl/m4/netinet_in_h.m4
@@ -1,5 +1,5 @@
 # netinet_in_h.m4 serial 5
-dnl Copyright (C) 2006-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2006-2012 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.
diff --git a/gl/m4/nocrash.m4 b/gl/m4/nocrash.m4
new file mode 100644
index 0000000..08ef825
--- /dev/null
+++ b/gl/m4/nocrash.m4
@@ -0,0 +1,130 @@
+# nocrash.m4 serial 3
+dnl Copyright (C) 2005, 2009-2012 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 Based on libsigsegv, from Bruno Haible and Paolo Bonzini.
+
+AC_PREREQ([2.13])
+
+dnl Expands to some code for use in .c programs that will cause the configure
+dnl test to exit instead of crashing. This is useful to avoid triggering
+dnl action from a background debugger and to avoid core dumps.
+dnl Usage:   ...
+dnl          ]GL_NOCRASH[
+dnl          ...
+dnl          int main() { nocrash_init(); ... }
+AC_DEFUN([GL_NOCRASH],[[
+#include <stdlib.h>
+#if defined __MACH__ && defined __APPLE__
+/* Avoid a crash on MacOS X.  */
+#include <mach/mach.h>
+#include <mach/mach_error.h>
+#include <mach/thread_status.h>
+#include <mach/exception.h>
+#include <mach/task.h>
+#include <pthread.h>
+/* The exception port on which our thread listens.  */
+static mach_port_t our_exception_port;
+/* The main function of the thread listening for exceptions of type
+   EXC_BAD_ACCESS.  */
+static void *
+mach_exception_thread (void *arg)
+{
+  /* Buffer for a message to be received.  */
+  struct {
+    mach_msg_header_t head;
+    mach_msg_body_t msgh_body;
+    char data[1024];
+  } msg;
+  mach_msg_return_t retval;
+  /* Wait for a message on the exception port.  */
+  retval = mach_msg (&msg.head, MACH_RCV_MSG | MACH_RCV_LARGE, 0, sizeof (msg),
+                     our_exception_port, MACH_MSG_TIMEOUT_NONE, 
MACH_PORT_NULL);
+  if (retval != MACH_MSG_SUCCESS)
+    abort ();
+  exit (1);
+}
+static void
+nocrash_init (void)
+{
+  mach_port_t self = mach_task_self ();
+  /* Allocate a port on which the thread shall listen for exceptions.  */
+  if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port)
+      == KERN_SUCCESS) {
+    /* See 
http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html.
  */
+    if (mach_port_insert_right (self, our_exception_port, our_exception_port,
+                                MACH_MSG_TYPE_MAKE_SEND)
+        == KERN_SUCCESS) {
+      /* The exceptions we want to catch.  Only EXC_BAD_ACCESS is interesting
+         for us.  */
+      exception_mask_t mask = EXC_MASK_BAD_ACCESS;
+      /* Create the thread listening on the exception port.  */
+      pthread_attr_t attr;
+      pthread_t thread;
+      if (pthread_attr_init (&attr) == 0
+          && pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) == 0
+          && pthread_create (&thread, &attr, mach_exception_thread, NULL) == 
0) {
+        pthread_attr_destroy (&attr);
+        /* Replace the exception port info for these exceptions with our own.
+           Note that we replace the exception port for the entire task, not 
only
+           for a particular thread.  This has the effect that when our 
exception
+           port gets the message, the thread specific exception port has 
already
+           been asked, and we don't need to bother about it.
+           See 
http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html.
  */
+        task_set_exception_ports (self, mask, our_exception_port,
+                                  EXCEPTION_DEFAULT, MACHINE_THREAD_STATE);
+      }
+    }
+  }
+}
+#elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+/* Avoid a crash on native Windows.  */
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <winerror.h>
+static LONG WINAPI
+exception_filter (EXCEPTION_POINTERS *ExceptionInfo)
+{
+  switch (ExceptionInfo->ExceptionRecord->ExceptionCode)
+    {
+    case EXCEPTION_ACCESS_VIOLATION:
+    case EXCEPTION_IN_PAGE_ERROR:
+    case EXCEPTION_STACK_OVERFLOW:
+    case EXCEPTION_GUARD_PAGE:
+    case EXCEPTION_PRIV_INSTRUCTION:
+    case EXCEPTION_ILLEGAL_INSTRUCTION:
+    case EXCEPTION_DATATYPE_MISALIGNMENT:
+    case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
+    case EXCEPTION_NONCONTINUABLE_EXCEPTION:
+      exit (1);
+    }
+  return EXCEPTION_CONTINUE_SEARCH;
+}
+static void
+nocrash_init (void)
+{
+  SetUnhandledExceptionFilter ((LPTOP_LEVEL_EXCEPTION_FILTER) 
exception_filter);
+}
+#else
+/* Avoid a crash on POSIX systems.  */
+#include <signal.h>
+/* A POSIX signal handler.  */
+static void
+exception_handler (int sig)
+{
+  exit (1);
+}
+static void
+nocrash_init (void)
+{
+#ifdef SIGSEGV
+  signal (SIGSEGV, exception_handler);
+#endif
+#ifdef SIGBUS
+  signal (SIGBUS, exception_handler);
+#endif
+}
+#endif
+]])
diff --git a/gl/m4/open.m4 b/gl/m4/open.m4
index 3b7c212..c85971d 100644
--- a/gl/m4/open.m4
+++ b/gl/m4/open.m4
@@ -1,5 +1,5 @@
-# open.m4 serial 12
-dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
+# open.m4 serial 13
+dnl Copyright (C) 2007-2012 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.
@@ -9,9 +9,7 @@ AC_DEFUN([gl_FUNC_OPEN],
   AC_REQUIRE([AC_CANONICAL_HOST])
   case "$host_os" in
     mingw* | pw*)
-      # The misbehaviour is only under Wine, see
-      # http://bugs.winehq.org/show_bug.cgi?id=21292
-      gl_cv_func_open_slash=no
+      REPLACE_OPEN=1
       ;;
     *)
       dnl open("foo/") should not create a file when the file name has a
@@ -55,34 +53,36 @@ changequote([,])dnl
             ])
           rm -f conftest.sl conftest.tmp conftest.lnk
         ])
+      case "$gl_cv_func_open_slash" in
+        *no)
+          AC_DEFINE([OPEN_TRAILING_SLASH_BUG], [1],
+            [Define to 1 if open() fails to recognize a trailing slash.])
+          REPLACE_OPEN=1
+          ;;
+      esac
       ;;
   esac
-  case "$gl_cv_func_open_slash" in
-    *no)
-      AC_DEFINE([OPEN_TRAILING_SLASH_BUG], [1],
-                [Define to 1 if open() fails to recognize a trailing slash.])
-      gl_REPLACE_OPEN
-      ;;
-  esac
+  dnl Replace open() for supporting the gnulib-defined fchdir() function,
+  dnl to keep fchdir's bookkeeping up-to-date.
+  m4_ifdef([gl_FUNC_FCHDIR], [
+    if test $REPLACE_OPEN = 0; then
+      gl_TEST_FCHDIR
+      if test $HAVE_FCHDIR = 0; then
+        REPLACE_OPEN=1
+      fi
+    fi
+  ])
   dnl Replace open() for supporting the gnulib-defined O_NONBLOCK flag.
   m4_ifdef([gl_NONBLOCKING_IO], [
     if test $REPLACE_OPEN = 0; then
       gl_NONBLOCKING_IO
       if test $gl_cv_have_open_O_NONBLOCK != yes; then
-        gl_REPLACE_OPEN
+        REPLACE_OPEN=1
       fi
     fi
   ])
 ])
 
-AC_DEFUN([gl_REPLACE_OPEN],
-[
-  AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
-  REPLACE_OPEN=1
-  AC_LIBOBJ([open])
-  gl_PREREQ_OPEN
-])
-
 # Prerequisites of lib/open.c.
 AC_DEFUN([gl_PREREQ_OPEN],
 [
diff --git a/gl/m4/pathmax.m4 b/gl/m4/pathmax.m4
new file mode 100644
index 0000000..0117861
--- /dev/null
+++ b/gl/m4/pathmax.m4
@@ -0,0 +1,42 @@
+# pathmax.m4 serial 10
+dnl Copyright (C) 2002-2003, 2005-2006, 2009-2012 Free Software Foundation,
+dnl 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_PATHMAX],
+[
+  dnl Prerequisites of lib/pathmax.h.
+  AC_CHECK_HEADERS_ONCE([sys/param.h])
+])
+
+# Expands to a piece of C program that defines PATH_MAX in the same way as
+# "pathmax.h" will do.
+AC_DEFUN([gl_PATHMAX_SNIPPET], [[
+/* Arrange to define PATH_MAX, like "pathmax.h" does. */
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#include <limits.h>
+#if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN
+# include <sys/param.h>
+#endif
+#if !defined PATH_MAX && defined MAXPATHLEN
+# define PATH_MAX MAXPATHLEN
+#endif
+#ifdef __hpux
+# undef PATH_MAX
+# define PATH_MAX 1024
+#endif
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# undef PATH_MAX
+# define PATH_MAX 260
+#endif
+]])
+
+# Prerequisites of gl_PATHMAX_SNIPPET.
+AC_DEFUN([gl_PATHMAX_SNIPPET_PREREQ],
+[
+  AC_CHECK_HEADERS_ONCE([unistd.h sys/param.h])
+])
diff --git a/gl/m4/perror.m4 b/gl/m4/perror.m4
index 86e2020..369a824 100644
--- a/gl/m4/perror.m4
+++ b/gl/m4/perror.m4
@@ -1,5 +1,5 @@
-# perror.m4 serial 3
-dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
+# perror.m4 serial 6
+dnl Copyright (C) 2008-2012 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.
@@ -27,6 +27,8 @@ AC_DEFUN([gl_FUNC_PERROR],
            [AC_LANG_PROGRAM(
               [[#include <errno.h>
                 #include <stdio.h>
+                #include <stdlib.h>
+                #include <string.h>
               ]],
               [[char *str = strerror (-1);
                 if (!getenv("CONFTEST_OUTPUT")) return 0;
@@ -34,9 +36,10 @@ AC_DEFUN([gl_FUNC_PERROR],
                 puts (str);
                 errno = -1;
                 perror ("");
+                return 0;
               ]])],
-           [CONFTEST_OUTPUT=1 ./conftest$EXEEXT >conftest.txt1 2>conftest.txt2
-            if cmp conftest.txt1 conftest.txt2 >/dev/null; then
+           [if CONFTEST_OUTPUT=1 ./conftest$EXEEXT >conftest.txt1 
2>conftest.txt2 \
+               && cmp conftest.txt1 conftest.txt2 >/dev/null; then
               gl_cv_func_perror_works=yes
             else
               gl_cv_func_perror_works=no
@@ -44,12 +47,17 @@ AC_DEFUN([gl_FUNC_PERROR],
             rm -rf conftest.txt1 conftest.txt2],
            [gl_cv_func_perror_works=no],
            [dnl Guess no when cross-compiling.
-            gl_cv_func_perror_works="guessing no"])])
-       if test "$gl_cv_func_perror_works" != yes; then
-         REPLACE_PERROR=1
-       fi ;;
-    *) dnl The system's perror() probably inherits the bugs in the
-       dnl system's strerror_r(). Replace it.
-      REPLACE_PERROR=1 ;;
+            gl_cv_func_perror_works="guessing no"
+           ])
+        ])
+      if test "$gl_cv_func_perror_works" != yes; then
+        REPLACE_PERROR=1
+      fi
+      ;;
+    *)
+      dnl The system's perror() probably inherits the bugs in the
+      dnl system's strerror_r(). Replace it.
+      REPLACE_PERROR=1
+      ;;
   esac
 ])
diff --git a/gl/m4/pipe.m4 b/gl/m4/pipe.m4
index 9013174..37aef11 100644
--- a/gl/m4/pipe.m4
+++ b/gl/m4/pipe.m4
@@ -1,5 +1,5 @@
 # pipe.m4 serial 2
-dnl Copyright (C) 2010-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2010-2012 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.
diff --git a/gl/m4/poll.m4 b/gl/m4/poll.m4
index e489df7..9993a36 100644
--- a/gl/m4/poll.m4
+++ b/gl/m4/poll.m4
@@ -1,5 +1,5 @@
-# poll.m4 serial 14
-dnl Copyright (c) 2003, 2005-2007, 2009-2011 Free Software Foundation, Inc.
+# poll.m4 serial 16
+dnl Copyright (c) 2003, 2005-2007, 2009-2012 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.
@@ -7,7 +7,8 @@ dnl with or without modifications, as long as this notice is 
preserved.
 AC_DEFUN([gl_FUNC_POLL],
 [
   AC_REQUIRE([gl_POLL_H])
-  if test "$ac_cv_header_poll_h" = no; then
+  AC_REQUIRE([gl_SOCKETS])
+  if test $ac_cv_header_poll_h = no; then
     ac_cv_func_poll=no
     gl_cv_func_poll=no
   else
@@ -68,6 +69,31 @@ This is MacOSX or AIX
     AC_DEFINE([HAVE_POLL], [1],
       [Define to 1 if you have the 'poll' function and it works.])
   fi
+
+  dnl Determine the needed libraries.
+  LIB_POLL="$LIBSOCKET"
+  if test $HAVE_POLL = 0 || test $REPLACE_POLL = 1; then
+    case "$host_os" in
+      mingw*)
+        dnl On the MSVC platform, the function MsgWaitForMultipleObjects
+        dnl (used in lib/poll.c) requires linking with -luser32. On mingw,
+        dnl it is implicit.
+        AC_LINK_IFELSE(
+          [AC_LANG_SOURCE([[
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+int
+main ()
+{
+  MsgWaitForMultipleObjects (0, NULL, 0, 0, 0);
+  return 0;
+}]])],
+          [],
+          [LIB_POLL="$LIB_POLL -luser32"])
+        ;;
+    esac
+  fi
+  AC_SUBST([LIB_POLL])
 ])
 
 # Prerequisites of lib/poll.c.
diff --git a/gl/m4/poll_h.m4 b/gl/m4/poll_h.m4
index 3f2abf4..6181576 100644
--- a/gl/m4/poll_h.m4
+++ b/gl/m4/poll_h.m4
@@ -1,5 +1,5 @@
 # poll_h.m4 serial 2
-dnl Copyright (C) 2010-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2010-2012 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.
diff --git a/gl/m4/printf.m4 b/gl/m4/printf.m4
index ead5ece..d75aca0 100644
--- a/gl/m4/printf.m4
+++ b/gl/m4/printf.m4
@@ -1,5 +1,5 @@
-# printf.m4 serial 43
-dnl Copyright (C) 2003, 2007-2011 Free Software Foundation, Inc.
+# printf.m4 serial 48
+dnl Copyright (C) 2003, 2007-2012 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.
@@ -178,28 +178,28 @@ static double zero = 0.0;
 int main ()
 {
   int result = 0;
-  if (sprintf (buf, "%f", 1.0 / 0.0) < 0
+  if (sprintf (buf, "%f", 1.0 / zero) < 0
       || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
     result |= 1;
-  if (sprintf (buf, "%f", -1.0 / 0.0) < 0
+  if (sprintf (buf, "%f", -1.0 / zero) < 0
       || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
     result |= 1;
   if (sprintf (buf, "%f", zero / zero) < 0
       || !strisnan (buf, 0, strlen (buf)))
     result |= 2;
-  if (sprintf (buf, "%e", 1.0 / 0.0) < 0
+  if (sprintf (buf, "%e", 1.0 / zero) < 0
       || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
     result |= 4;
-  if (sprintf (buf, "%e", -1.0 / 0.0) < 0
+  if (sprintf (buf, "%e", -1.0 / zero) < 0
       || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
     result |= 4;
   if (sprintf (buf, "%e", zero / zero) < 0
       || !strisnan (buf, 0, strlen (buf)))
     result |= 8;
-  if (sprintf (buf, "%g", 1.0 / 0.0) < 0
+  if (sprintf (buf, "%g", 1.0 / zero) < 0
       || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
     result |= 16;
-  if (sprintf (buf, "%g", -1.0 / 0.0) < 0
+  if (sprintf (buf, "%g", -1.0 / zero) < 0
       || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
     result |= 16;
   if (sprintf (buf, "%g", zero / zero) < 0
@@ -251,6 +251,7 @@ AC_DEFUN([gl_PRINTF_INFINITE_LONG_DOUBLE],
   AC_REQUIRE([gl_PRINTF_LONG_DOUBLE])
   AC_REQUIRE([AC_PROG_CC])
   AC_REQUIRE([gl_BIGENDIAN])
+  AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
   dnl The user can set or unset the variable gl_printf_safe to indicate
   dnl that he wishes a safe handling of non-IEEE-754 'long double' values.
@@ -294,34 +295,34 @@ int main ()
 {
   int result = 0;
   nocrash_init();
-  if (sprintf (buf, "%Lf", 1.0L / 0.0L) < 0
+  if (sprintf (buf, "%Lf", 1.0L / zeroL) < 0
       || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
     result |= 1;
-  if (sprintf (buf, "%Lf", -1.0L / 0.0L) < 0
+  if (sprintf (buf, "%Lf", -1.0L / zeroL) < 0
       || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
     result |= 1;
   if (sprintf (buf, "%Lf", zeroL / zeroL) < 0
       || !strisnan (buf, 0, strlen (buf)))
     result |= 1;
-  if (sprintf (buf, "%Le", 1.0L / 0.0L) < 0
+  if (sprintf (buf, "%Le", 1.0L / zeroL) < 0
       || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
     result |= 1;
-  if (sprintf (buf, "%Le", -1.0L / 0.0L) < 0
+  if (sprintf (buf, "%Le", -1.0L / zeroL) < 0
       || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
     result |= 1;
   if (sprintf (buf, "%Le", zeroL / zeroL) < 0
       || !strisnan (buf, 0, strlen (buf)))
     result |= 1;
-  if (sprintf (buf, "%Lg", 1.0L / 0.0L) < 0
+  if (sprintf (buf, "%Lg", 1.0L / zeroL) < 0
       || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
     result |= 1;
-  if (sprintf (buf, "%Lg", -1.0L / 0.0L) < 0
+  if (sprintf (buf, "%Lg", -1.0L / zeroL) < 0
       || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
     result |= 1;
   if (sprintf (buf, "%Lg", zeroL / zeroL) < 0
       || !strisnan (buf, 0, strlen (buf)))
     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_))
+#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_)) && 
!HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
 /* Representation of an 80-bit 'long double' as an initializer for a sequence
    of 'unsigned int' words.  */
 # ifdef WORDS_BIGENDIAN
@@ -478,6 +479,7 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_A],
 #include <stdio.h>
 #include <string.h>
 static char buf[100];
+static double zero = 0.0;
 int main ()
 {
   int result = 0;
@@ -502,7 +504,7 @@ int main ()
     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
+  if (sprintf (buf, "%010a %d", 1.0 / zero, 33, 44, 55) < 0
       || buf[0] == '0')
     result |= 8;
   /* This catches a MacOS X 10.3.9 (Darwin 7.9) bug.  */
@@ -562,13 +564,14 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_F],
 #include <stdio.h>
 #include <string.h>
 static char buf[100];
+static double zero = 0.0;
 int main ()
 {
   int result = 0;
   if (sprintf (buf, "%F %d", 1234567.0, 33, 44, 55) < 0
       || strcmp (buf, "1234567.000000 33") != 0)
     result |= 1;
-  if (sprintf (buf, "%F", 1.0 / 0.0) < 0
+  if (sprintf (buf, "%F", 1.0 / zero) < 0
       || (strcmp (buf, "INF") != 0 && strcmp (buf, "INFINITY") != 0))
     result |= 2;
   /* This catches a Cygwin 1.5.x bug.  */
@@ -615,12 +618,27 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_N],
       AC_RUN_IFELSE(
         [AC_LANG_SOURCE([[
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
+#ifdef _MSC_VER
+/* See page about "Parameter Validation" on msdn.microsoft.com.  */
+static void cdecl
+invalid_parameter_handler (const wchar_t *expression,
+                           const wchar_t *function,
+                           const wchar_t *file, unsigned int line,
+                           uintptr_t dummy)
+{
+  exit (1);
+}
+#endif
 static char fmtstring[10];
 static char buf[100];
 int main ()
 {
   int count = -1;
+#ifdef _MSC_VER
+  _set_invalid_parameter_handler (invalid_parameter_handler);
+#endif
   /* Copy the format string.  Some systems (glibc with _FORTIFY_SOURCE=2)
      support %n in format strings in read-only memory but not in writable
      memory.  */
@@ -636,7 +654,8 @@ int main ()
         [
 changequote(,)dnl
          case "$host_os" in
-           *)     gl_cv_func_printf_directive_n="guessing yes";;
+           mingw*) gl_cv_func_printf_directive_n="guessing no";;
+           *)      gl_cv_func_printf_directive_n="guessing yes";;
          esac
 changequote([,])dnl
         ])
@@ -862,9 +881,10 @@ AC_DEFUN([gl_PRINTF_FLAG_ZERO],
 #include <stdio.h>
 #include <string.h>
 static char buf[100];
+static double zero = 0.0;
 int main ()
 {
-  if (sprintf (buf, "%010f", 1.0 / 0.0, 33, 44, 55) < 0
+  if (sprintf (buf, "%010f", 1.0 / zero, 33, 44, 55) < 0
       || (strcmp (buf, "       inf") != 0
           && strcmp (buf, "  infinity") != 0))
     return 1;
@@ -932,7 +952,7 @@ int main ()
         [
 changequote(,)dnl
          case "$host_os" in
-           # Guess no only on Solaris, native Win32, and BeOS systems.
+           # Guess no only on Solaris, native Windows, 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" ;;
@@ -1076,6 +1096,7 @@ AC_DEFUN([gl_SNPRINTF_TRUNCATION_C99],
 [
   AC_REQUIRE([AC_PROG_CC])
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_REQUIRE([gl_SNPRINTF_PRESENCE])
   AC_CACHE_CHECK([whether snprintf truncates the result as in C99],
     [gl_cv_func_snprintf_truncation_c99],
     [
@@ -1083,11 +1104,25 @@ AC_DEFUN([gl_SNPRINTF_TRUNCATION_C99],
         [AC_LANG_SOURCE([[
 #include <stdio.h>
 #include <string.h>
+#if HAVE_SNPRINTF
+# define my_snprintf snprintf
+#else
+# include <stdarg.h>
+static int my_snprintf (char *buf, int size, const char *format, ...)
+{
+  va_list args;
+  int ret;
+  va_start (args, format);
+  ret = vsnprintf (buf, size, format, args);
+  va_end (args);
+  return ret;
+}
+#endif
 static char buf[100];
 int main ()
 {
   strcpy (buf, "ABCDEF");
-  snprintf (buf, 3, "%d %d", 4567, 89);
+  my_snprintf (buf, 3, "%d %d", 4567, 89);
   if (memcmp (buf, "45\0DEF", 6) != 0)
     return 1;
   return 0;
@@ -1157,6 +1192,7 @@ AC_DEFUN_ONCE([gl_SNPRINTF_RETVAL_C99],
 [
   AC_REQUIRE([AC_PROG_CC])
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_REQUIRE([gl_SNPRINTF_PRESENCE])
   AC_CACHE_CHECK([whether snprintf returns a byte count as in C99],
     [gl_cv_func_snprintf_retval_c99],
     [
@@ -1164,15 +1200,29 @@ AC_DEFUN_ONCE([gl_SNPRINTF_RETVAL_C99],
         [AC_LANG_SOURCE([[
 #include <stdio.h>
 #include <string.h>
+#if HAVE_SNPRINTF
+# define my_snprintf snprintf
+#else
+# include <stdarg.h>
+static int my_snprintf (char *buf, int size, const char *format, ...)
+{
+  va_list args;
+  int ret;
+  va_start (args, format);
+  ret = vsnprintf (buf, size, format, args);
+  va_end (args);
+  return ret;
+}
+#endif
 static char buf[100];
 int main ()
 {
   strcpy (buf, "ABCDEF");
-  if (snprintf (buf, 3, "%d %d", 4567, 89) != 7)
+  if (my_snprintf (buf, 3, "%d %d", 4567, 89) != 7)
     return 1;
-  if (snprintf (buf, 0, "%d %d", 4567, 89) != 7)
+  if (my_snprintf (buf, 0, "%d %d", 4567, 89) != 7)
     return 2;
-  if (snprintf (NULL, 0, "%d %d", 4567, 89) != 7)
+  if (my_snprintf (NULL, 0, "%d %d", 4567, 89) != 7)
     return 3;
   return 0;
 }]])],
@@ -1221,6 +1271,7 @@ AC_DEFUN([gl_SNPRINTF_DIRECTIVE_N],
 [
   AC_REQUIRE([AC_PROG_CC])
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_REQUIRE([gl_SNPRINTF_PRESENCE])
   AC_CACHE_CHECK([whether snprintf fully supports the 'n' directive],
     [gl_cv_func_snprintf_directive_n],
     [
@@ -1228,6 +1279,20 @@ AC_DEFUN([gl_SNPRINTF_DIRECTIVE_N],
         [AC_LANG_SOURCE([[
 #include <stdio.h>
 #include <string.h>
+#if HAVE_SNPRINTF
+# define my_snprintf snprintf
+#else
+# include <stdarg.h>
+static int my_snprintf (char *buf, int size, const char *format, ...)
+{
+  va_list args;
+  int ret;
+  va_start (args, format);
+  ret = vsnprintf (buf, size, format, args);
+  va_end (args);
+  return ret;
+}
+#endif
 static char fmtstring[10];
 static char buf[100];
 int main ()
@@ -1237,7 +1302,7 @@ int main ()
      support %n in format strings in read-only memory but not in writable
      memory.  */
   strcpy (fmtstring, "%d %n");
-  snprintf (buf, 4, fmtstring, 12345, &count, 33, 44, 55);
+  my_snprintf (buf, 4, fmtstring, 12345, &count, 33, 44, 55);
   if (count != 6)
     return 1;
   return 0;
@@ -1289,16 +1354,31 @@ dnl Result is gl_cv_func_snprintf_size1.
 AC_DEFUN([gl_SNPRINTF_SIZE1],
 [
   AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([gl_SNPRINTF_PRESENCE])
   AC_CACHE_CHECK([whether snprintf respects a size of 1],
     [gl_cv_func_snprintf_size1],
     [
       AC_RUN_IFELSE(
         [AC_LANG_SOURCE([[
 #include <stdio.h>
+#if HAVE_SNPRINTF
+# define my_snprintf snprintf
+#else
+# include <stdarg.h>
+static int my_snprintf (char *buf, int size, const char *format, ...)
+{
+  va_list args;
+  int ret;
+  va_start (args, format);
+  ret = vsnprintf (buf, size, format, args);
+  va_end (args);
+  return ret;
+}
+#endif
 int main()
 {
   static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' };
-  snprintf (buf, 1, "%d", 12345);
+  my_snprintf (buf, 1, "%d", 12345);
   return buf[1] != 'E';
 }]])],
         [gl_cv_func_snprintf_size1=yes],
@@ -1465,7 +1545,7 @@ 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 11 2010-11             .  .  #  #  #  .  .  #  .  .  .  #  .  .  
.  .  .  .  .  .
+dnl   Solaris 11 2011-11             .  .  #  #  #  .  .  #  .  .  .  #  .  .  
.  .  .  .  .  .
 dnl   Solaris 10                     .  .  #  #  #  .  .  #  .  .  .  #  #  .  
.  .  .  .  .  .
 dnl   Solaris 2.6 ... 9              #  .  #  #  #  #  .  #  .  .  .  #  #  .  
.  .  #  .  .  .
 dnl   Solaris 2.5.1                  #  .  #  #  #  #  .  #  .  .  .  #  .  .  
#  #  #  #  #  #
@@ -1483,4 +1563,7 @@ dnl   NetBSD 4.0                     .  ?  ?  ?  ?  ?  .  
?  .  ?  ?  ?  ?  ?  .
 dnl   NetBSD 3.0                     .  .  .  .  #  #  .  ?  #  #  ?  #  .  #  
.  .  .  .  .  .
 dnl   Haiku                          .  .  .  #  #  #  .  #  .  .  .  .  .  ?  
.  .  ?  .  .  .
 dnl   BeOS                           #  #  .  #  #  #  .  ?  #  .  ?  .  #  ?  
.  .  ?  .  .  .
-dnl   mingw                          #  #  #  #  #  #  .  .  #  #  .  #  #  ?  
.  #  #  #  .  .
+dnl   old mingw / msvcrt             #  #  #  #  #  #  .  .  #  #  .  #  #  ?  
.  #  #  #  .  .
+dnl   MSVC 9                         #  #  #  #  #  #  #  .  #  #  .  #  #  ?  
#  #  #  #  .  .
+dnl   mingw 2009-2011                .  #  .  #  .  .  .  .  #  #  .  .  .  ?  
.  .  .  .  .  .
+dnl   mingw-w64 2011                 #  #  #  #  #  #  .  .  #  #  .  #  #  ?  
.  #  #  #  .  .
diff --git a/gl/m4/putenv.m4 b/gl/m4/putenv.m4
index 1497b4a..1cb23a5 100644
--- a/gl/m4/putenv.m4
+++ b/gl/m4/putenv.m4
@@ -1,5 +1,5 @@
 # putenv.m4 serial 18
-dnl Copyright (C) 2002-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2012 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.
diff --git a/gl/m4/quote.m4 b/gl/m4/quote.m4
index 1996120..7b05584 100644
--- a/gl/m4/quote.m4
+++ b/gl/m4/quote.m4
@@ -1,5 +1,5 @@
 # quote.m4 serial 6
-dnl Copyright (C) 2002-2003, 2005-2006, 2009-2011 Free Software Foundation,
+dnl Copyright (C) 2002-2003, 2005-2006, 2009-2012 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
diff --git a/gl/m4/quotearg.m4 b/gl/m4/quotearg.m4
index 990712b..09c36bb 100644
--- a/gl/m4/quotearg.m4
+++ b/gl/m4/quotearg.m4
@@ -1,5 +1,5 @@
 # quotearg.m4 serial 9
-dnl Copyright (C) 2002, 2004-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2004-2012 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.
diff --git a/gl/m4/readline.m4 b/gl/m4/readline.m4
index a5ab067..903886d 100644
--- a/gl/m4/readline.m4
+++ b/gl/m4/readline.m4
@@ -1,5 +1,5 @@
-# readline.m4 serial 9
-dnl Copyright (C) 2005-2006, 2009-2011 Free Software Foundation, Inc.
+# readline.m4 serial 10
+dnl Copyright (C) 2005-2006, 2009-2012 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.
@@ -29,7 +29,7 @@ AC_DEFUN([gl_FUNC_READLINE],
     am_save_LIBS="$LIBS"
     dnl On some systems, -lreadline doesn't link without an additional
     dnl -lncurses or -ltermcap.
-    dnl Try -lncurses before -ltermcap, because libtermcap is unsecure
+    dnl Try -lncurses before -ltermcap, because libtermcap is insecure
     dnl by design and obsolete since 1994. Try -lcurses last, because
     dnl libcurses is unusable on some old Unices.
     for extra_lib in "" ncurses termcap curses; do
@@ -72,7 +72,7 @@ AC_DEFUN([gl_FUNC_READLINE],
   AC_SUBST([LIBREADLINE])
   AC_SUBST([LTLIBREADLINE])
 
-  AC_CHECK_HEADERS([readline/readline.h])
+  AC_CHECK_HEADERS([readline/readline.h readline/history.h])
 ])
 
 # Prerequisites of lib/readline.c.
diff --git a/gl/m4/realloc.m4 b/gl/m4/realloc.m4
index 5cc1340..039ed19 100644
--- a/gl/m4/realloc.m4
+++ b/gl/m4/realloc.m4
@@ -1,5 +1,5 @@
 # realloc.m4 serial 12
-dnl Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2007, 2009-2012 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.
diff --git a/gl/m4/select.m4 b/gl/m4/select.m4
index d9c3465..037b3d3 100644
--- a/gl/m4/select.m4
+++ b/gl/m4/select.m4
@@ -1,5 +1,5 @@
-# select.m4 serial 5
-dnl Copyright (C) 2009-2011 Free Software Foundation, Inc.
+# select.m4 serial 6
+dnl Copyright (C) 2009-2012 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.
@@ -47,4 +47,29 @@ changequote([,])dnl
       *) REPLACE_SELECT=1 ;;
     esac
   fi
+
+  dnl Determine the needed libraries.
+  LIB_SELECT="$LIBSOCKET"
+  if test $REPLACE_SELECT = 1; then
+    case "$host_os" in
+      mingw*)
+        dnl On the MSVC platform, the function MsgWaitForMultipleObjects
+        dnl (used in lib/select.c) requires linking with -luser32. On mingw,
+        dnl it is implicit.
+        AC_LINK_IFELSE(
+          [AC_LANG_SOURCE([[
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+int
+main ()
+{
+  MsgWaitForMultipleObjects (0, NULL, 0, 0, 0);
+  return 0;
+}]])],
+          [],
+          [LIB_SELECT="$LIB_SELECT -luser32"])
+        ;;
+    esac
+  fi
+  AC_SUBST([LIB_SELECT])
 ])
diff --git a/gl/m4/servent.m4 b/gl/m4/servent.m4
index c5df01c..21da957 100644
--- a/gl/m4/servent.m4
+++ b/gl/m4/servent.m4
@@ -1,5 +1,5 @@
 # servent.m4 serial 2
-dnl Copyright (C) 2008, 2010-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2008, 2010-2012 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.
diff --git a/gl/m4/setenv.m4 b/gl/m4/setenv.m4
index 8927a6c..a1f30bc 100644
--- a/gl/m4/setenv.m4
+++ b/gl/m4/setenv.m4
@@ -1,5 +1,5 @@
-# setenv.m4 serial 24
-dnl Copyright (C) 2001-2004, 2006-2011 Free Software Foundation, Inc.
+# setenv.m4 serial 25
+dnl Copyright (C) 2001-2004, 2006-2012 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.
@@ -77,11 +77,7 @@ extern
 #ifdef __cplusplus
 "C"
 #endif
-#if defined(__STDC__) || defined(__cplusplus)
 int unsetenv (const char *name);
-#else
-int unsetenv();
-#endif
             ]],
             [[]])],
          [gt_cv_func_unsetenv_ret='int'],
diff --git a/gl/m4/setlocale.m4 b/gl/m4/setlocale.m4
index d64780d..c605241 100644
--- a/gl/m4/setlocale.m4
+++ b/gl/m4/setlocale.m4
@@ -1,5 +1,5 @@
 # setlocale.m4 serial 4
-dnl Copyright (C) 2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2011-2012 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.
diff --git a/gl/m4/signal_h.m4 b/gl/m4/signal_h.m4
new file mode 100644
index 0000000..ed4d730
--- /dev/null
+++ b/gl/m4/signal_h.m4
@@ -0,0 +1,83 @@
+# signal_h.m4 serial 18
+dnl Copyright (C) 2007-2012 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_SIGNAL_H],
+[
+  AC_REQUIRE([gl_SIGNAL_H_DEFAULTS])
+  AC_REQUIRE([gl_CHECK_TYPE_SIGSET_T])
+  gl_NEXT_HEADERS([signal.h])
+
+# AIX declares sig_atomic_t to already include volatile, and C89 compilers
+# then choke on 'volatile sig_atomic_t'.  C99 requires that it compile.
+  AC_CHECK_TYPE([volatile sig_atomic_t], [],
+    [HAVE_TYPE_VOLATILE_SIG_ATOMIC_T=0], [[
+#include <signal.h>
+    ]])
+
+  dnl Ensure the type pid_t gets defined.
+  AC_REQUIRE([AC_TYPE_PID_T])
+
+  AC_REQUIRE([AC_TYPE_UID_T])
+
+  dnl Persuade glibc <signal.h> to define sighandler_t.
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+  AC_CHECK_TYPE([sighandler_t], [], [HAVE_SIGHANDLER_T=0], [[
+#include <signal.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([[#include <signal.h>
+    ]], [pthread_sigmask sigaction
+    sigaddset sigdelset sigemptyset sigfillset sigismember
+    sigpending sigprocmask])
+])
+
+AC_DEFUN([gl_CHECK_TYPE_SIGSET_T],
+[
+  AC_CHECK_TYPES([sigset_t],
+    [gl_cv_type_sigset_t=yes], [gl_cv_type_sigset_t=no],
+    [[
+      #include <signal.h>
+      /* Mingw defines sigset_t not in <signal.h>, but in <sys/types.h>.  */
+      #include <sys/types.h>
+    ]])
+  if test $gl_cv_type_sigset_t != yes; then
+    HAVE_SIGSET_T=0
+  fi
+])
+
+AC_DEFUN([gl_SIGNAL_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_SIGNAL_H_DEFAULTS])
+  gl_MODULE_INDICATOR_SET_VARIABLE([$1])
+  dnl Define it also as a C macro, for the benefit of the unit tests.
+  gl_MODULE_INDICATOR_FOR_TESTS([$1])
+])
+
+AC_DEFUN([gl_SIGNAL_H_DEFAULTS],
+[
+  GNULIB_PTHREAD_SIGMASK=0;    AC_SUBST([GNULIB_PTHREAD_SIGMASK])
+  GNULIB_RAISE=0;              AC_SUBST([GNULIB_RAISE])
+  GNULIB_SIGNAL_H_SIGPIPE=0;   AC_SUBST([GNULIB_SIGNAL_H_SIGPIPE])
+  GNULIB_SIGPROCMASK=0;        AC_SUBST([GNULIB_SIGPROCMASK])
+  GNULIB_SIGACTION=0;          AC_SUBST([GNULIB_SIGACTION])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_POSIX_SIGNALBLOCKING=1; AC_SUBST([HAVE_POSIX_SIGNALBLOCKING])
+  HAVE_PTHREAD_SIGMASK=1;      AC_SUBST([HAVE_PTHREAD_SIGMASK])
+  HAVE_RAISE=1;                AC_SUBST([HAVE_RAISE])
+  HAVE_SIGSET_T=1;             AC_SUBST([HAVE_SIGSET_T])
+  HAVE_SIGINFO_T=1;            AC_SUBST([HAVE_SIGINFO_T])
+  HAVE_SIGACTION=1;            AC_SUBST([HAVE_SIGACTION])
+  HAVE_STRUCT_SIGACTION_SA_SIGACTION=1;
+                               AC_SUBST([HAVE_STRUCT_SIGACTION_SA_SIGACTION])
+  HAVE_TYPE_VOLATILE_SIG_ATOMIC_T=1;
+                               AC_SUBST([HAVE_TYPE_VOLATILE_SIG_ATOMIC_T])
+  HAVE_SIGHANDLER_T=1;         AC_SUBST([HAVE_SIGHANDLER_T])
+  REPLACE_PTHREAD_SIGMASK=0;   AC_SUBST([REPLACE_PTHREAD_SIGMASK])
+  REPLACE_RAISE=0;             AC_SUBST([REPLACE_RAISE])
+])
diff --git a/gl/m4/size_max.m4 b/gl/m4/size_max.m4
index e807098..5a8162b 100644
--- a/gl/m4/size_max.m4
+++ b/gl/m4/size_max.m4
@@ -1,5 +1,5 @@
 # size_max.m4 serial 10
-dnl Copyright (C) 2003, 2005-2006, 2008-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2003, 2005-2006, 2008-2012 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.
diff --git a/gl/m4/snprintf.m4 b/gl/m4/snprintf.m4
index 8aa5dbe..de94edd 100644
--- a/gl/m4/snprintf.m4
+++ b/gl/m4/snprintf.m4
@@ -1,9 +1,13 @@
-# snprintf.m4 serial 5
-dnl Copyright (C) 2002-2004, 2007-2011 Free Software Foundation, Inc.
+# snprintf.m4 serial 6
+dnl Copyright (C) 2002-2004, 2007-2012 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 Libintl 0.17 will replace snprintf only if it does not support %1$s,
+dnl but defers to any gnulib snprintf replacements.  Therefore, gnulib
+dnl must guarantee that the decision for replacing snprintf is a superset
+dnl of the reasons checked by libintl.
 AC_DEFUN([gl_FUNC_SNPRINTF],
 [
   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
@@ -16,7 +20,12 @@ AC_DEFUN([gl_FUNC_SNPRINTF],
         gl_SNPRINTF_RETVAL_C99
         case "$gl_cv_func_snprintf_retval_c99" in
           *yes)
-            gl_cv_func_snprintf_usable=yes
+            gl_PRINTF_POSITIONS
+            case "$gl_cv_func_printf_positions" in
+              *yes)
+                gl_cv_func_snprintf_usable=yes
+                ;;
+            esac
             ;;
         esac
         ;;
diff --git a/gl/m4/socketlib.m4 b/gl/m4/socketlib.m4
index 2aa972d..92a1af2 100644
--- a/gl/m4/socketlib.m4
+++ b/gl/m4/socketlib.m4
@@ -1,5 +1,5 @@
 # socketlib.m4 serial 1
-dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2008-2012 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.
diff --git a/gl/m4/sockets.m4 b/gl/m4/sockets.m4
index cbe754f..e3738d9 100644
--- a/gl/m4/sockets.m4
+++ b/gl/m4/sockets.m4
@@ -1,5 +1,5 @@
 # sockets.m4 serial 7
-dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2008-2012 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.
diff --git a/gl/m4/socklen.m4 b/gl/m4/socklen.m4
index 4475154..a4ab43b 100644
--- a/gl/m4/socklen.m4
+++ b/gl/m4/socklen.m4
@@ -1,5 +1,5 @@
 # socklen.m4 serial 10
-dnl Copyright (C) 2005-2007, 2009-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2005-2007, 2009-2012 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.
diff --git a/gl/m4/sockpfaf.m4 b/gl/m4/sockpfaf.m4
index c38daea..5f97c3e 100644
--- a/gl/m4/sockpfaf.m4
+++ b/gl/m4/sockpfaf.m4
@@ -1,5 +1,5 @@
 # sockpfaf.m4 serial 8
-dnl Copyright (C) 2004, 2006, 2009-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2004, 2006, 2009-2012 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.
diff --git a/gl/m4/ssize_t.m4 b/gl/m4/ssize_t.m4
new file mode 100644
index 0000000..209d64c
--- /dev/null
+++ b/gl/m4/ssize_t.m4
@@ -0,0 +1,23 @@
+# ssize_t.m4 serial 5 (gettext-0.18.2)
+dnl Copyright (C) 2001-2003, 2006, 2010-2012 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 From Bruno Haible.
+dnl Test whether ssize_t is defined.
+
+AC_DEFUN([gt_TYPE_SSIZE_T],
+[
+  AC_CACHE_CHECK([for ssize_t], [gt_cv_ssize_t],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <sys/types.h>]],
+          [[int x = sizeof (ssize_t *) + sizeof (ssize_t);
+            return !x;]])],
+       [gt_cv_ssize_t=yes], [gt_cv_ssize_t=no])])
+  if test $gt_cv_ssize_t = no; then
+    AC_DEFINE([ssize_t], [int],
+              [Define as a signed type of the same size as size_t.])
+  fi
+])
diff --git a/gl/m4/stat.m4 b/gl/m4/stat.m4
index c63f59f..d67dbcd 100644
--- a/gl/m4/stat.m4
+++ b/gl/m4/stat.m4
@@ -1,6 +1,6 @@
 # serial 8
 
-# Copyright (C) 2009-2011 Free Software Foundation, Inc.
+# Copyright (C) 2009-2012 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
diff --git a/gl/m4/stdalign.m4 b/gl/m4/stdalign.m4
new file mode 100644
index 0000000..6659c9c
--- /dev/null
+++ b/gl/m4/stdalign.m4
@@ -0,0 +1,51 @@
+# Check for stdalign.h that conforms to C11.
+
+dnl Copyright 2011-2012 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.
+
+# Prepare for substituting <stdalign.h> if it is not supported.
+
+AC_DEFUN([gl_STDALIGN_H],
+[
+  AC_CACHE_CHECK([for working stdalign.h],
+    [gl_cv_header_working_stdalign_h],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <stdalign.h>
+            #include <stddef.h>
+
+            /* Test that alignof yields a result consistent with offsetof.
+               This catches GCC bug 52023
+               <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>.  */
+            #ifdef __cplusplus
+               template <class t> struct alignof_helper { char a; t b; };
+            # define ao(type) offsetof (alignof_helper<type>, b)
+            #else
+            # define ao(type) offsetof (struct { char a; type b; }, b)
+            #endif
+            char test_double[ao (double) % _Alignof (double) == 0 ? 1 : -1];
+            char test_long[ao (long int) % _Alignof (long int) == 0 ? 1 : -1];
+            char test_alignof[alignof (double) == _Alignof (double) ? 1 : -1];
+
+            /* Test _Alignas only on platforms where gnulib can help.  */
+            #if \
+                (__GNUC__ || __IBMC__ || __IBMCPP__ \
+                 || 0x5110 <= __SUNPRO_C || 1300 <= _MSC_VER)
+              int alignas (8) alignas_int = 1;
+              char test_alignas[_Alignof (alignas_int) == 8 ? 1 : -1];
+            #endif
+          ]])],
+       [gl_cv_header_working_stdalign_h=yes],
+       [gl_cv_header_working_stdalign_h=no])])
+
+  if test $gl_cv_header_working_stdalign_h = yes; then
+    STDALIGN_H=''
+  else
+    STDALIGN_H='stdalign.h'
+  fi
+
+  AC_SUBST([STDALIGN_H])
+  AM_CONDITIONAL([GL_GENERATE_STDALIGN_H], [test -n "$STDALIGN_H"])
+])
diff --git a/gl/m4/stdarg.m4 b/gl/m4/stdarg.m4
index 5705de9..5c313cb 100644
--- a/gl/m4/stdarg.m4
+++ b/gl/m4/stdarg.m4
@@ -1,5 +1,5 @@
 # stdarg.m4 serial 6
-dnl Copyright (C) 2006, 2008-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2006, 2008-2012 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.
diff --git a/gl/m4/stdbool.m4 b/gl/m4/stdbool.m4
index 1ebf3e6..eabfa64 100644
--- a/gl/m4/stdbool.m4
+++ b/gl/m4/stdbool.m4
@@ -1,6 +1,6 @@
 # Check for stdbool.h that conforms to C99.
 
-dnl Copyright (C) 2002-2006, 2009-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2006, 2009-2012 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.
diff --git a/gl/m4/stddef_h.m4 b/gl/m4/stddef_h.m4
index 1ae2344..cc11609 100644
--- a/gl/m4/stddef_h.m4
+++ b/gl/m4/stddef_h.m4
@@ -1,6 +1,6 @@
 dnl A placeholder for POSIX 2008 <stddef.h>, for platforms that have issues.
 # stddef_h.m4 serial 4
-dnl Copyright (C) 2009-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2009-2012 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.
diff --git a/gl/m4/stdint.m4 b/gl/m4/stdint.m4
index c75e957..28d342e 100644
--- a/gl/m4/stdint.m4
+++ b/gl/m4/stdint.m4
@@ -1,5 +1,5 @@
-# stdint.m4 serial 41
-dnl Copyright (C) 2001-2011 Free Software Foundation, Inc.
+# stdint.m4 serial 43
+dnl Copyright (C) 2001-2012 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.
@@ -69,8 +69,6 @@ AC_DEFUN_ONCE([gl_STDINT_H],
       [gl_cv_header_working_stdint_h=no
        AC_COMPILE_IFELSE([
          AC_LANG_PROGRAM([[
-#define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */
-#define __STDC_CONSTANT_MACROS 1 /* to make it work also in C++ mode */
 #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
 #include <stdint.h>
 /* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in <wchar.h>.  */
@@ -219,8 +217,6 @@ struct s {
           dnl This detects a bug on HP-UX 11.23/ia64.
           AC_RUN_IFELSE([
             AC_LANG_PROGRAM([[
-#define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */
-#define __STDC_CONSTANT_MACROS 1 /* to make it work also in C++ mode */
 #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
 #include <stdint.h>
 ]
@@ -466,6 +462,14 @@ AC_DEFUN([gl_STDINT_TYPE_PROPERTIES],
   fi
   gl_INTEGER_TYPE_SUFFIX([sig_atomic_t wchar_t wint_t],
     [gl_STDINT_INCLUDES])
+
+  dnl If wint_t is smaller than 'int', it cannot satisfy the ISO C 99
+  dnl requirement that wint_t is "unchanged by default argument promotions".
+  dnl In this case gnulib's <wchar.h> and <wctype.h> override wint_t.
+  dnl Set the variable BITSIZEOF_WINT_T accordingly.
+  if test $BITSIZEOF_WINT_T -lt 32; then
+    BITSIZEOF_WINT_T=32
+  fi
 ])
 
 dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
diff --git a/gl/m4/stdint_h.m4 b/gl/m4/stdint_h.m4
index 356b14e..581de96 100644
--- a/gl/m4/stdint_h.m4
+++ b/gl/m4/stdint_h.m4
@@ -1,5 +1,5 @@
 # stdint_h.m4 serial 9
-dnl Copyright (C) 1997-2004, 2006, 2008-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 1997-2004, 2006, 2008-2012 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.
diff --git a/gl/m4/stdio_h.m4 b/gl/m4/stdio_h.m4
index a8326f3..1973e8d 100644
--- a/gl/m4/stdio_h.m4
+++ b/gl/m4/stdio_h.m4
@@ -1,5 +1,5 @@
-# stdio_h.m4 serial 37
-dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
+# stdio_h.m4 serial 40
+dnl Copyright (C) 2007-2012 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.
@@ -74,7 +74,7 @@ AC_DEFUN([gl_STDIO_H],
   dnl corresponding gnulib module is not in use, and which is not
   dnl guaranteed by C89.
   gl_WARN_ON_USE_PREPARE([[#include <stdio.h>
-    ]], [dprintf fpurge fseeko ftello getdelim getline popen renameat
+    ]], [dprintf fpurge fseeko ftello getdelim getline pclose popen renameat
     snprintf tmpfile vdprintf vsnprintf])
 ])
 
@@ -91,6 +91,7 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
 [
   GNULIB_DPRINTF=0;              AC_SUBST([GNULIB_DPRINTF])
   GNULIB_FCLOSE=0;               AC_SUBST([GNULIB_FCLOSE])
+  GNULIB_FDOPEN=0;               AC_SUBST([GNULIB_FDOPEN])
   GNULIB_FFLUSH=0;               AC_SUBST([GNULIB_FFLUSH])
   GNULIB_FGETC=0;                AC_SUBST([GNULIB_FGETC])
   GNULIB_FGETS=0;                AC_SUBST([GNULIB_FGETS])
@@ -115,6 +116,7 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
   GNULIB_GETS=0;                 AC_SUBST([GNULIB_GETS])
   GNULIB_OBSTACK_PRINTF=0;       AC_SUBST([GNULIB_OBSTACK_PRINTF])
   GNULIB_OBSTACK_PRINTF_POSIX=0; AC_SUBST([GNULIB_OBSTACK_PRINTF_POSIX])
+  GNULIB_PCLOSE=0;               AC_SUBST([GNULIB_PCLOSE])
   GNULIB_PERROR=0;               AC_SUBST([GNULIB_PERROR])
   GNULIB_POPEN=0;                AC_SUBST([GNULIB_POPEN])
   GNULIB_PRINTF=0;               AC_SUBST([GNULIB_PRINTF])
@@ -153,11 +155,14 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
   HAVE_DPRINTF=1;                AC_SUBST([HAVE_DPRINTF])
   HAVE_FSEEKO=1;                 AC_SUBST([HAVE_FSEEKO])
   HAVE_FTELLO=1;                 AC_SUBST([HAVE_FTELLO])
+  HAVE_PCLOSE=1;                 AC_SUBST([HAVE_PCLOSE])
+  HAVE_POPEN=1;                  AC_SUBST([HAVE_POPEN])
   HAVE_RENAMEAT=1;               AC_SUBST([HAVE_RENAMEAT])
   HAVE_VASPRINTF=1;              AC_SUBST([HAVE_VASPRINTF])
   HAVE_VDPRINTF=1;               AC_SUBST([HAVE_VDPRINTF])
   REPLACE_DPRINTF=0;             AC_SUBST([REPLACE_DPRINTF])
   REPLACE_FCLOSE=0;              AC_SUBST([REPLACE_FCLOSE])
+  REPLACE_FDOPEN=0;              AC_SUBST([REPLACE_FDOPEN])
   REPLACE_FFLUSH=0;              AC_SUBST([REPLACE_FFLUSH])
   REPLACE_FOPEN=0;               AC_SUBST([REPLACE_FOPEN])
   REPLACE_FPRINTF=0;             AC_SUBST([REPLACE_FPRINTF])
diff --git a/gl/m4/stdlib_h.m4 b/gl/m4/stdlib_h.m4
index 25fdada..ab43728 100644
--- a/gl/m4/stdlib_h.m4
+++ b/gl/m4/stdlib_h.m4
@@ -1,5 +1,5 @@
-# stdlib_h.m4 serial 37
-dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
+# stdlib_h.m4 serial 41
+dnl Copyright (C) 2007-2012 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.
@@ -19,10 +19,11 @@ AC_DEFUN([gl_STDLIB_H],
 #if HAVE_RANDOM_H
 # include <random.h>
 #endif
-    ]], [_Exit atoll canonicalize_file_name getloadavg getsubopt grantpt 
mkdtemp
-    mkostemp mkostemps mkstemp mkstemps ptsname random_r initstat_r srandom_r
-    setstate_r realpath rpmatch setenv strtod strtoll strtoull unlockpt
-    unsetenv])
+    ]], [_Exit atoll canonicalize_file_name getloadavg getsubopt grantpt
+    initstate initstate_r mkdtemp mkostemp mkostemps mkstemp mkstemps
+    posix_openpt ptsname ptsname_r random random_r realpath rpmatch
+    setenv setstate setstate_r srandom srandom_r
+    strtod strtoll strtoull unlockpt unsetenv])
 ])
 
 AC_DEFUN([gl_STDLIB_MODULE_INDICATOR],
@@ -50,8 +51,11 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
   GNULIB_MKOSTEMPS=0;     AC_SUBST([GNULIB_MKOSTEMPS])
   GNULIB_MKSTEMP=0;       AC_SUBST([GNULIB_MKSTEMP])
   GNULIB_MKSTEMPS=0;      AC_SUBST([GNULIB_MKSTEMPS])
+  GNULIB_POSIX_OPENPT=0;  AC_SUBST([GNULIB_POSIX_OPENPT])
   GNULIB_PTSNAME=0;       AC_SUBST([GNULIB_PTSNAME])
+  GNULIB_PTSNAME_R=0;     AC_SUBST([GNULIB_PTSNAME_R])
   GNULIB_PUTENV=0;        AC_SUBST([GNULIB_PUTENV])
+  GNULIB_RANDOM=0;        AC_SUBST([GNULIB_RANDOM])
   GNULIB_RANDOM_R=0;      AC_SUBST([GNULIB_RANDOM_R])
   GNULIB_REALLOC_POSIX=0; AC_SUBST([GNULIB_REALLOC_POSIX])
   GNULIB_REALPATH=0;      AC_SUBST([GNULIB_REALPATH])
@@ -76,7 +80,10 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
   HAVE_MKOSTEMPS=1;          AC_SUBST([HAVE_MKOSTEMPS])
   HAVE_MKSTEMP=1;            AC_SUBST([HAVE_MKSTEMP])
   HAVE_MKSTEMPS=1;           AC_SUBST([HAVE_MKSTEMPS])
+  HAVE_POSIX_OPENPT=1;       AC_SUBST([HAVE_POSIX_OPENPT])
   HAVE_PTSNAME=1;            AC_SUBST([HAVE_PTSNAME])
+  HAVE_PTSNAME_R=1;          AC_SUBST([HAVE_PTSNAME_R])
+  HAVE_RANDOM=1;             AC_SUBST([HAVE_RANDOM])
   HAVE_RANDOM_H=1;           AC_SUBST([HAVE_RANDOM_H])
   HAVE_RANDOM_R=1;           AC_SUBST([HAVE_RANDOM_R])
   HAVE_REALPATH=1;           AC_SUBST([HAVE_REALPATH])
@@ -95,7 +102,9 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
   REPLACE_MALLOC=0;          AC_SUBST([REPLACE_MALLOC])
   REPLACE_MBTOWC=0;          AC_SUBST([REPLACE_MBTOWC])
   REPLACE_MKSTEMP=0;         AC_SUBST([REPLACE_MKSTEMP])
+  REPLACE_PTSNAME_R=0;       AC_SUBST([REPLACE_PTSNAME_R])
   REPLACE_PUTENV=0;          AC_SUBST([REPLACE_PUTENV])
+  REPLACE_RANDOM_R=0;        AC_SUBST([REPLACE_RANDOM_R])
   REPLACE_REALLOC=0;         AC_SUBST([REPLACE_REALLOC])
   REPLACE_REALPATH=0;        AC_SUBST([REPLACE_REALPATH])
   REPLACE_SETENV=0;          AC_SUBST([REPLACE_SETENV])
diff --git a/gl/m4/strdup.m4 b/gl/m4/strdup.m4
index d744ad5..db0c8c1 100644
--- a/gl/m4/strdup.m4
+++ b/gl/m4/strdup.m4
@@ -1,6 +1,6 @@
 # strdup.m4 serial 13
 
-dnl Copyright (C) 2002-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2012 Free Software Foundation, Inc.
 
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
diff --git a/gl/m4/strerror.m4 b/gl/m4/strerror.m4
index ca05be6..6bf14ef 100644
--- a/gl/m4/strerror.m4
+++ b/gl/m4/strerror.m4
@@ -1,5 +1,5 @@
 # strerror.m4 serial 16
-dnl Copyright (C) 2002, 2007-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2007-2012 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.
diff --git a/gl/m4/strerror_r.m4 b/gl/m4/strerror_r.m4
index f6aceff..5bdf0ab 100644
--- a/gl/m4/strerror_r.m4
+++ b/gl/m4/strerror_r.m4
@@ -1,5 +1,5 @@
-# strerror_r.m4 serial 12
-dnl Copyright (C) 2002, 2007-2011 Free Software Foundation, Inc.
+# strerror_r.m4 serial 14
+dnl Copyright (C) 2002, 2007-2012 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.
@@ -43,6 +43,7 @@ AC_DEFUN([gl_PREREQ_STRERROR_R], [
   dnl glibc >= 2.3.4 and cygwin 1.7.9 have a function __xpg_strerror_r.
   AC_CHECK_FUNCS_ONCE([__xpg_strerror_r])
   AC_CHECK_FUNCS_ONCE([catgets])
+  AC_CHECK_FUNCS_ONCE([snprintf])
 ])
 
 # Detect if strerror_r works, but without affecting whether a replacement
@@ -138,7 +139,11 @@ changequote([,])dnl
                [AC_LANG_PROGRAM(
                   [[#include <errno.h>
                     #include <string.h>
-                    extern int __xpg_strerror_r(int, char *, size_t);
+                    extern
+                    #ifdef __cplusplus
+                    "C"
+                    #endif
+                    int __xpg_strerror_r(int, char *, size_t);
                   ]],
                   [[int result = 0;
                     char buf[256] = "^";
diff --git a/gl/m4/string_h.m4 b/gl/m4/string_h.m4
index df8c403..5677e09 100644
--- a/gl/m4/string_h.m4
+++ b/gl/m4/string_h.m4
@@ -1,11 +1,11 @@
 # Configure a GNU-like replacement for <string.h>.
 
-# Copyright (C) 2007-2011 Free Software Foundation, Inc.
+# Copyright (C) 2007-2012 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 20
+# serial 21
 
 # Written by Paul Eggert.
 
@@ -27,9 +27,9 @@ AC_DEFUN([gl_HEADER_STRING_H_BODY],
   dnl guaranteed by C89.
   gl_WARN_ON_USE_PREPARE([[#include <string.h>
     ]],
-    [memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul strdup
-     strncat strndup strnlen strpbrk strsep strcasestr strtok_r strerror_r
-     strsignal strverscmp])
+    [ffsl ffsll memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul
+     strdup strncat strndup strnlen strpbrk strsep strcasestr strtok_r
+     strerror_r strsignal strverscmp])
 ])
 
 AC_DEFUN([gl_STRING_MODULE_INDICATOR],
@@ -43,6 +43,8 @@ AC_DEFUN([gl_STRING_MODULE_INDICATOR],
 
 AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
 [
+  GNULIB_FFSL=0;        AC_SUBST([GNULIB_FFSL])
+  GNULIB_FFSLL=0;       AC_SUBST([GNULIB_FFSLL])
   GNULIB_MEMCHR=0;      AC_SUBST([GNULIB_MEMCHR])
   GNULIB_MEMMEM=0;      AC_SUBST([GNULIB_MEMMEM])
   GNULIB_MEMPCPY=0;     AC_SUBST([GNULIB_MEMPCPY])
@@ -80,6 +82,8 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
   GNULIB_STRVERSCMP=0;  AC_SUBST([GNULIB_STRVERSCMP])
   HAVE_MBSLEN=0;        AC_SUBST([HAVE_MBSLEN])
   dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_FFSL=1;                  AC_SUBST([HAVE_FFSL])
+  HAVE_FFSLL=1;                 AC_SUBST([HAVE_FFSLL])
   HAVE_MEMCHR=1;                AC_SUBST([HAVE_MEMCHR])
   HAVE_DECL_MEMMEM=1;           AC_SUBST([HAVE_DECL_MEMMEM])
   HAVE_MEMPCPY=1;               AC_SUBST([HAVE_MEMPCPY])
diff --git a/gl/m4/strtok_r.m4 b/gl/m4/strtok_r.m4
index 59ea3d7..60e33a6 100644
--- a/gl/m4/strtok_r.m4
+++ b/gl/m4/strtok_r.m4
@@ -1,5 +1,5 @@
 # strtok_r.m4 serial 13
-dnl Copyright (C) 2002-2004, 2006-2007, 2009-2011 Free Software Foundation,
+dnl Copyright (C) 2002-2004, 2006-2007, 2009-2012 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
diff --git a/gl/m4/symlink.m4 b/gl/m4/symlink.m4
index 680c14f..f84b21e 100644
--- a/gl/m4/symlink.m4
+++ b/gl/m4/symlink.m4
@@ -1,7 +1,7 @@
 # serial 5
 # See if we need to provide symlink replacement.
 
-dnl Copyright (C) 2009-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2009-2012 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.
diff --git a/gl/m4/sys_ioctl_h.m4 b/gl/m4/sys_ioctl_h.m4
index 8c7d112..94a2669 100644
--- a/gl/m4/sys_ioctl_h.m4
+++ b/gl/m4/sys_ioctl_h.m4
@@ -1,5 +1,5 @@
 # sys_ioctl_h.m4 serial 10
-dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2008-2012 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.
diff --git a/gl/m4/sys_select_h.m4 b/gl/m4/sys_select_h.m4
index f167118..eaf056a 100644
--- a/gl/m4/sys_select_h.m4
+++ b/gl/m4/sys_select_h.m4
@@ -1,12 +1,12 @@
-# sys_select_h.m4 serial 16
-dnl Copyright (C) 2006-2011 Free Software Foundation, Inc.
+# sys_select_h.m4 serial 20
+dnl Copyright (C) 2006-2012 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_HEADER_SYS_SELECT],
 [
-  AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+  AC_REQUIRE([AC_C_RESTRICT])
   AC_REQUIRE([gl_SYS_SELECT_H_DEFAULTS])
   AC_CACHE_CHECK([whether <sys/select.h> is self-contained],
     [gl_cv_header_sys_select_h_selfcontained],
@@ -32,10 +32,18 @@ AC_DEFUN([gl_HEADER_SYS_SELECT],
              [AC_LANG_PROGRAM([[#include <sys/select.h>]], [[
                   #undef memset
                   #define memset nonexistent_memset
-                  extern void *memset (void *, int, unsigned long);
+                  extern
+                  #ifdef __cplusplus
+                  "C"
+                  #endif
+                  void *memset (void *, int, unsigned long);
                   #undef bzero
                   #define bzero nonexistent_bzero
-                  extern void bzero (void *, unsigned long);
+                  extern
+                  #ifdef __cplusplus
+                  "C"
+                  #endif
+                  void bzero (void *, unsigned long);
                   fd_set fds;
                   FD_ZERO (&fds);
                 ]])
@@ -64,7 +72,7 @@ AC_DEFUN([gl_HEADER_SYS_SELECT],
 # include <sys/time.h>
 #endif
 #include <sys/select.h>
-    ]], [select])
+    ]], [pselect select])
 ])
 
 AC_DEFUN([gl_SYS_SELECT_MODULE_INDICATOR],
@@ -78,7 +86,10 @@ AC_DEFUN([gl_SYS_SELECT_MODULE_INDICATOR],
 
 AC_DEFUN([gl_SYS_SELECT_H_DEFAULTS],
 [
+  GNULIB_PSELECT=0; AC_SUBST([GNULIB_PSELECT])
   GNULIB_SELECT=0; AC_SUBST([GNULIB_SELECT])
   dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_PSELECT=1; AC_SUBST([HAVE_PSELECT])
+  REPLACE_PSELECT=0; AC_SUBST([REPLACE_PSELECT])
   REPLACE_SELECT=0; AC_SUBST([REPLACE_SELECT])
 ])
diff --git a/gl/m4/sys_socket_h.m4 b/gl/m4/sys_socket_h.m4
index 7da91a4..8d4e7e1 100644
--- a/gl/m4/sys_socket_h.m4
+++ b/gl/m4/sys_socket_h.m4
@@ -1,5 +1,5 @@
 # sys_socket_h.m4 serial 22
-dnl Copyright (C) 2005-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2005-2012 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.
diff --git a/gl/m4/sys_stat_h.m4 b/gl/m4/sys_stat_h.m4
index fc41912..a0b96bc 100644
--- a/gl/m4/sys_stat_h.m4
+++ b/gl/m4/sys_stat_h.m4
@@ -1,5 +1,5 @@
-# sys_stat_h.m4 serial 24   -*- Autoconf -*-
-dnl Copyright (C) 2006-2011 Free Software Foundation, Inc.
+# sys_stat_h.m4 serial 26   -*- Autoconf -*-
+dnl Copyright (C) 2006-2012 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.
@@ -19,6 +19,9 @@ AC_DEFUN([gl_HEADER_SYS_STAT_H],
 
   gl_CHECK_NEXT_HEADERS([sys/stat.h])
 
+  dnl Ensure the type mode_t gets defined.
+  AC_REQUIRE([AC_TYPE_MODE_T])
+
   dnl Define types that are supposed to be defined in <sys/types.h> or
   dnl <sys/stat.h>.
   AC_CHECK_TYPE([nlink_t], [],
@@ -30,7 +33,7 @@ AC_DEFUN([gl_HEADER_SYS_STAT_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([[#include <sys/stat.h>
-    ]], [fchmodat fstatat futimens lchmod lstat mkdirat mkfifo mkfifoat
+    ]], [fchmodat fstat fstatat futimens lchmod lstat mkdirat mkfifo mkfifoat
     mknod mknodat stat utimensat])
 ]) # gl_HEADER_SYS_STAT_H
 
@@ -47,6 +50,7 @@ AC_DEFUN([gl_SYS_STAT_H_DEFAULTS],
 [
   AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) dnl for REPLACE_FCHDIR
   GNULIB_FCHMODAT=0;    AC_SUBST([GNULIB_FCHMODAT])
+  GNULIB_FSTAT=0;       AC_SUBST([GNULIB_FSTAT])
   GNULIB_FSTATAT=0;     AC_SUBST([GNULIB_FSTATAT])
   GNULIB_FUTIMENS=0;    AC_SUBST([GNULIB_FUTIMENS])
   GNULIB_LCHMOD=0;      AC_SUBST([GNULIB_LCHMOD])
diff --git a/gl/m4/sys_time_h.m4 b/gl/m4/sys_time_h.m4
index 3a3adc8..26eaf8e 100644
--- a/gl/m4/sys_time_h.m4
+++ b/gl/m4/sys_time_h.m4
@@ -1,7 +1,7 @@
 # Configure a replacement for <sys/time.h>.
-# serial 6
+# serial 8
 
-# Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+# Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -27,6 +27,9 @@ AC_DEFUN([gl_HEADER_SYS_TIME_H_BODY],
     HAVE_SYS_TIME_H=0
   fi
 
+  dnl On native Windows with MSVC, 'struct timeval' is defined in <winsock2.h>
+  dnl only. So include that header in the list.
+  gl_PREREQ_SYS_H_WINSOCK2
   AC_CACHE_CHECK([for struct timeval], [gl_cv_sys_struct_timeval],
     [AC_COMPILE_IFELSE(
        [AC_LANG_PROGRAM(
@@ -34,12 +37,42 @@ AC_DEFUN([gl_HEADER_SYS_TIME_H_BODY],
              #include <sys/time.h>
             #endif
             #include <time.h>
+            #if HAVE_WINSOCK2_H
+            # include <winsock2.h>
+            #endif
           ]],
           [[static struct timeval x; x.tv_sec = x.tv_usec;]])],
        [gl_cv_sys_struct_timeval=yes],
-       [gl_cv_sys_struct_timeval=no])])
+       [gl_cv_sys_struct_timeval=no])
+    ])
   if test $gl_cv_sys_struct_timeval != yes; then
     HAVE_STRUCT_TIMEVAL=0
+  else
+    dnl On native Windows with a 64-bit 'time_t', 'struct timeval' is defined
+    dnl (in <sys/time.h> and <winsock2.h> for mingw64, in <winsock2.h> only
+    dnl for MSVC) with a tv_sec field of type 'long' (32-bit!), which is
+    dnl smaller than the 'time_t' type mandated by POSIX.
+    AC_CACHE_CHECK([for correct struct timeval.tv_sec member],
+      [gl_cv_sys_struct_timeval_tv_sec],
+      [AC_COMPILE_IFELSE(
+         [AC_LANG_PROGRAM(
+            [[#if HAVE_SYS_TIME_H
+               #include <sys/time.h>
+              #endif
+              #include <time.h>
+              #if HAVE_WINSOCK2_H
+              # include <winsock2.h>
+              #endif
+            ]],
+            [[static struct timeval x;
+              typedef int verify_tv_sec_type[sizeof (x.tv_sec) == sizeof 
(time_t) ? 1 : -1];
+            ]])],
+         [gl_cv_sys_struct_timeval_tv_sec=yes],
+         [gl_cv_sys_struct_timeval_tv_sec=no])
+      ])
+    if test $gl_cv_sys_struct_timeval_tv_sec != yes; then
+      REPLACE_STRUCT_TIMEVAL=1
+    fi
   fi
 
   dnl Check for declarations of anything we want to poison if the
@@ -69,4 +102,5 @@ AC_DEFUN([gl_HEADER_SYS_TIME_H_DEFAULTS],
   HAVE_STRUCT_TIMEVAL=1;     AC_SUBST([HAVE_STRUCT_TIMEVAL])
   HAVE_SYS_TIME_H=1;         AC_SUBST([HAVE_SYS_TIME_H])
   REPLACE_GETTIMEOFDAY=0;    AC_SUBST([REPLACE_GETTIMEOFDAY])
+  REPLACE_STRUCT_TIMEVAL=0;  AC_SUBST([REPLACE_STRUCT_TIMEVAL])
 ])
diff --git a/gl/m4/sys_types_h.m4 b/gl/m4/sys_types_h.m4
new file mode 100644
index 0000000..8d18ddb
--- /dev/null
+++ b/gl/m4/sys_types_h.m4
@@ -0,0 +1,21 @@
+# sys_types_h.m4 serial 2
+dnl Copyright (C) 2011-2012 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_SYS_TYPES_H],
+[
+  AC_REQUIRE([gl_SYS_TYPES_H_DEFAULTS])
+  gl_NEXT_HEADERS([sys/types.h])
+
+  dnl Ensure the type pid_t gets defined.
+  AC_REQUIRE([AC_TYPE_PID_T])
+
+  dnl Ensure the type mode_t gets defined.
+  AC_REQUIRE([AC_TYPE_MODE_T])
+])
+
+AC_DEFUN([gl_SYS_TYPES_H_DEFAULTS],
+[
+])
diff --git a/gl/m4/sys_uio_h.m4 b/gl/m4/sys_uio_h.m4
index bafa0ac..ddf844b 100644
--- a/gl/m4/sys_uio_h.m4
+++ b/gl/m4/sys_uio_h.m4
@@ -1,5 +1,5 @@
 # sys_uio_h.m4 serial 1
-dnl Copyright (C) 2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2011-2012 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.
diff --git a/gl/m4/thread.m4 b/gl/m4/thread.m4
index 49a4bc7..cd66c3e 100644
--- a/gl/m4/thread.m4
+++ b/gl/m4/thread.m4
@@ -1,5 +1,5 @@
 # thread.m4 serial 2
-dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2008-2012 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.
diff --git a/gl/m4/threadlib.m4 b/gl/m4/threadlib.m4
index 8a621fd..9cedb67 100644
--- a/gl/m4/threadlib.m4
+++ b/gl/m4/threadlib.m4
@@ -1,5 +1,5 @@
-# threadlib.m4 serial 8 (gettext-0.18.2)
-dnl Copyright (C) 2005-2011 Free Software Foundation, Inc.
+# threadlib.m4 serial 9 (gettext-0.18.2)
+dnl Copyright (C) 2005-2012 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.
@@ -15,7 +15,7 @@ dnl default is 'no', otherwise it is system dependent. In 
both cases, the user
 dnl can change the choice through the options --enable-threads=choice or
 dnl --disable-threads.
 dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS,
-dnl USE_PTH_THREADS, USE_WIN32_THREADS
+dnl USE_PTH_THREADS, USE_WINDOWS_THREADS
 dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use
 dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with
 dnl libtool).
@@ -53,7 +53,7 @@ AC_DEFUN([gl_THREADLIB_EARLY_BODY],
     [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])],
     [m4_divert_text([DEFAULTS], [gl_use_threads_default=])])
   AC_ARG_ENABLE([threads],
-AC_HELP_STRING([--enable-threads={posix|solaris|pth|win32}], [specify 
multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [
+AC_HELP_STRING([--enable-threads={posix|solaris|pth|windows}], [specify 
multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [
 AC_HELP_STRING([--disable-threads], [build without multithread safety])]),
     [gl_use_threads=$enableval],
     [if test -n "$gl_use_threads_default"; then
@@ -276,17 +276,19 @@ int main ()
       fi
     fi
     if test -z "$gl_have_pthread"; then
-      if test "$gl_use_threads" = yes || test "$gl_use_threads" = win32; then
-        if { case "$host_os" in
-               mingw*) true;;
-               *) false;;
-             esac
-           }; then
-          gl_threads_api=win32
-          AC_DEFINE([USE_WIN32_THREADS], [1],
-            [Define if the Win32 multithreading API can be used.])
-        fi
-      fi
+      case "$gl_use_threads" in
+        yes | windows | win32) # The 'win32' is for backward compatibility.
+          if { case "$host_os" in
+                 mingw*) true;;
+                 *) false;;
+               esac
+             }; then
+            gl_threads_api=windows
+            AC_DEFINE([USE_WINDOWS_THREADS], [1],
+              [Define if the native Windows multithreading API can be used.])
+          fi
+          ;;
+      esac
     fi
   fi
   AC_MSG_CHECKING([for multithread API to use])
@@ -358,7 +360,7 @@ dnl Cygwin            posix       -lpthread       Y      OK
 dnl
 dnl Any of the above  pth         -lpth                  0.0
 dnl
-dnl Mingw             win32                       N      OK
+dnl Mingw             windows                     N      OK
 dnl
 dnl BeOS 5            --
 dnl
diff --git a/gl/m4/time_h.m4 b/gl/m4/time_h.m4
index 615da1c..b88da76 100644
--- a/gl/m4/time_h.m4
+++ b/gl/m4/time_h.m4
@@ -1,8 +1,8 @@
 # Configure a more-standard replacement for <time.h>.
 
-# Copyright (C) 2000-2001, 2003-2007, 2009-2011 Free Software Foundation, Inc.
+# Copyright (C) 2000-2001, 2003-2007, 2009-2012 Free Software Foundation, Inc.
 
-# serial 4
+# serial 6
 
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -25,7 +25,7 @@ AC_DEFUN([gl_HEADER_TIME_H_BODY],
   AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
 ])
 
-dnl Define HAVE_STRUCT_TIMESPEC if `struct timespec' is declared
+dnl Define HAVE_STRUCT_TIMESPEC if 'struct timespec' is declared
 dnl in time.h, sys/time.h, or pthread.h.
 
 AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
diff --git a/gl/m4/ungetc.m4 b/gl/m4/ungetc.m4
index 749f6bd..95bb3eb 100644
--- a/gl/m4/ungetc.m4
+++ b/gl/m4/ungetc.m4
@@ -1,5 +1,5 @@
 # ungetc.m4 serial 2
-dnl Copyright (C) 2009-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2009-2012 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.
diff --git a/gl/m4/unistd_h.m4 b/gl/m4/unistd_h.m4
index fb6fe07..7595534 100644
--- a/gl/m4/unistd_h.m4
+++ b/gl/m4/unistd_h.m4
@@ -1,5 +1,5 @@
-# unistd_h.m4 serial 56
-dnl Copyright (C) 2006-2011 Free Software Foundation, Inc.
+# unistd_h.m4 serial 63
+dnl Copyright (C) 2006-2012 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.
@@ -21,9 +21,15 @@ AC_DEFUN([gl_UNISTD_H],
   fi
   AC_SUBST([HAVE_UNISTD_H])
 
+  dnl Ensure the type pid_t gets defined.
+  AC_REQUIRE([AC_TYPE_PID_T])
+
   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([[#include <unistd.h>
+  gl_WARN_ON_USE_PREPARE([[
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
 /* Some systems declare various items in the wrong headers.  */
 #if !(defined __GLIBC__ && !defined __UCLIBC__)
 # include <fcntl.h>
@@ -33,12 +39,13 @@ AC_DEFUN([gl_UNISTD_H],
 #  include <io.h>
 # endif
 #endif
-    ]], [chown dup2 dup3 environ euidaccess faccessat fchdir fchownat
-    fsync ftruncate getcwd getdomainname getdtablesize getgroups
-    gethostname getlogin getlogin_r getpagesize getusershell setusershell
-    endusershell group_member lchown link linkat lseek pipe pipe2 pread pwrite
-    readlink readlinkat rmdir sleep symlink symlinkat ttyname_r unlink unlinkat
-    usleep])
+    ]], [chdir chown dup dup2 dup3 environ euidaccess faccessat fchdir fchownat
+    fdatasync fsync ftruncate getcwd getdomainname getdtablesize getgroups
+    gethostname getlogin getlogin_r getpagesize
+    getusershell setusershell endusershell
+    group_member isatty lchown link linkat lseek pipe pipe2 pread pwrite
+    readlink readlinkat rmdir sethostname sleep symlink symlinkat ttyname_r
+    unlink unlinkat usleep])
 ])
 
 AC_DEFUN([gl_UNISTD_MODULE_INDICATOR],
@@ -52,8 +59,10 @@ AC_DEFUN([gl_UNISTD_MODULE_INDICATOR],
 
 AC_DEFUN([gl_UNISTD_H_DEFAULTS],
 [
+  GNULIB_CHDIR=0;                AC_SUBST([GNULIB_CHDIR])
   GNULIB_CHOWN=0;                AC_SUBST([GNULIB_CHOWN])
   GNULIB_CLOSE=0;                AC_SUBST([GNULIB_CLOSE])
+  GNULIB_DUP=0;                  AC_SUBST([GNULIB_DUP])
   GNULIB_DUP2=0;                 AC_SUBST([GNULIB_DUP2])
   GNULIB_DUP3=0;                 AC_SUBST([GNULIB_DUP3])
   GNULIB_ENVIRON=0;              AC_SUBST([GNULIB_ENVIRON])
@@ -61,6 +70,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   GNULIB_FACCESSAT=0;            AC_SUBST([GNULIB_FACCESSAT])
   GNULIB_FCHDIR=0;               AC_SUBST([GNULIB_FCHDIR])
   GNULIB_FCHOWNAT=0;             AC_SUBST([GNULIB_FCHOWNAT])
+  GNULIB_FDATASYNC=0;            AC_SUBST([GNULIB_FDATASYNC])
   GNULIB_FSYNC=0;                AC_SUBST([GNULIB_FSYNC])
   GNULIB_FTRUNCATE=0;            AC_SUBST([GNULIB_FTRUNCATE])
   GNULIB_GETCWD=0;               AC_SUBST([GNULIB_GETCWD])
@@ -73,6 +83,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   GNULIB_GETPAGESIZE=0;          AC_SUBST([GNULIB_GETPAGESIZE])
   GNULIB_GETUSERSHELL=0;         AC_SUBST([GNULIB_GETUSERSHELL])
   GNULIB_GROUP_MEMBER=0;         AC_SUBST([GNULIB_GROUP_MEMBER])
+  GNULIB_ISATTY=0;               AC_SUBST([GNULIB_ISATTY])
   GNULIB_LCHOWN=0;               AC_SUBST([GNULIB_LCHOWN])
   GNULIB_LINK=0;                 AC_SUBST([GNULIB_LINK])
   GNULIB_LINKAT=0;               AC_SUBST([GNULIB_LINKAT])
@@ -85,11 +96,11 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   GNULIB_READLINK=0;             AC_SUBST([GNULIB_READLINK])
   GNULIB_READLINKAT=0;           AC_SUBST([GNULIB_READLINKAT])
   GNULIB_RMDIR=0;                AC_SUBST([GNULIB_RMDIR])
+  GNULIB_SETHOSTNAME=0;          AC_SUBST([GNULIB_SETHOSTNAME])
   GNULIB_SLEEP=0;                AC_SUBST([GNULIB_SLEEP])
   GNULIB_SYMLINK=0;              AC_SUBST([GNULIB_SYMLINK])
   GNULIB_SYMLINKAT=0;            AC_SUBST([GNULIB_SYMLINKAT])
   GNULIB_TTYNAME_R=0;            AC_SUBST([GNULIB_TTYNAME_R])
-  GNULIB_UNISTD_H_GETOPT=0;      AC_SUBST([GNULIB_UNISTD_H_GETOPT])
   GNULIB_UNISTD_H_NONBLOCKING=0; AC_SUBST([GNULIB_UNISTD_H_NONBLOCKING])
   GNULIB_UNISTD_H_SIGPIPE=0;     AC_SUBST([GNULIB_UNISTD_H_SIGPIPE])
   GNULIB_UNLINK=0;               AC_SUBST([GNULIB_UNLINK])
@@ -104,6 +115,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   HAVE_FACCESSAT=1;       AC_SUBST([HAVE_FACCESSAT])
   HAVE_FCHDIR=1;          AC_SUBST([HAVE_FCHDIR])
   HAVE_FCHOWNAT=1;        AC_SUBST([HAVE_FCHOWNAT])
+  HAVE_FDATASYNC=1;       AC_SUBST([HAVE_FDATASYNC])
   HAVE_FSYNC=1;           AC_SUBST([HAVE_FSYNC])
   HAVE_FTRUNCATE=1;       AC_SUBST([HAVE_FTRUNCATE])
   HAVE_GETDTABLESIZE=1;   AC_SUBST([HAVE_GETDTABLESIZE])
@@ -121,6 +133,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   HAVE_PWRITE=1;          AC_SUBST([HAVE_PWRITE])
   HAVE_READLINK=1;        AC_SUBST([HAVE_READLINK])
   HAVE_READLINKAT=1;      AC_SUBST([HAVE_READLINKAT])
+  HAVE_SETHOSTNAME=1;     AC_SUBST([HAVE_SETHOSTNAME])
   HAVE_SLEEP=1;           AC_SUBST([HAVE_SLEEP])
   HAVE_SYMLINK=1;         AC_SUBST([HAVE_SYMLINK])
   HAVE_SYMLINKAT=1;       AC_SUBST([HAVE_SYMLINKAT])
@@ -128,10 +141,12 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   HAVE_USLEEP=1;          AC_SUBST([HAVE_USLEEP])
   HAVE_DECL_ENVIRON=1;    AC_SUBST([HAVE_DECL_ENVIRON])
   HAVE_DECL_FCHDIR=1;     AC_SUBST([HAVE_DECL_FCHDIR])
+  HAVE_DECL_FDATASYNC=1;  AC_SUBST([HAVE_DECL_FDATASYNC])
   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])
+  HAVE_DECL_SETHOSTNAME=1; AC_SUBST([HAVE_DECL_SETHOSTNAME])
   HAVE_DECL_TTYNAME_R=1;  AC_SUBST([HAVE_DECL_TTYNAME_R])
   HAVE_OS_H=0;            AC_SUBST([HAVE_OS_H])
   HAVE_SYS_PARAM_H=0;     AC_SUBST([HAVE_SYS_PARAM_H])
@@ -145,6 +160,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   REPLACE_GETLOGIN_R=0;   AC_SUBST([REPLACE_GETLOGIN_R])
   REPLACE_GETGROUPS=0;    AC_SUBST([REPLACE_GETGROUPS])
   REPLACE_GETPAGESIZE=0;  AC_SUBST([REPLACE_GETPAGESIZE])
+  REPLACE_ISATTY=0;       AC_SUBST([REPLACE_ISATTY])
   REPLACE_LCHOWN=0;       AC_SUBST([REPLACE_LCHOWN])
   REPLACE_LINK=0;         AC_SUBST([REPLACE_LINK])
   REPLACE_LINKAT=0;       AC_SUBST([REPLACE_LINKAT])
diff --git a/gl/m4/valgrind-tests.m4 b/gl/m4/valgrind-tests.m4
index ab9e25a..6f2790e 100644
--- a/gl/m4/valgrind-tests.m4
+++ b/gl/m4/valgrind-tests.m4
@@ -1,5 +1,5 @@
-# valgrind-tests.m4 serial 2
-dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
+# valgrind-tests.m4 serial 3
+dnl Copyright (C) 2008-2012 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.
@@ -21,9 +21,12 @@ AC_DEFUN([gl_VALGRIND_TESTS],
     AC_CHECK_PROGS(VALGRIND, valgrind)
   fi
 
-  if test -n "$VALGRIND" && $VALGRIND -q true > /dev/null 2>&1; then
+  OPTS="-q --error-exitcode=1 --leak-check=full"
+
+  if test -n "$VALGRIND" \
+     && $VALGRIND $OPTS $SHELL -c 'exit 0' > /dev/null 2>&1; then
     opt_valgrind_tests=yes
-    VALGRIND="$VALGRIND -q --error-exitcode=1 --leak-check=full"
+    VALGRIND="$VALGRIND $OPTS"
   else
     opt_valgrind_tests=no
     VALGRIND=
diff --git a/gl/m4/vasnprintf.m4 b/gl/m4/vasnprintf.m4
index 32ea985..0ce11da 100644
--- a/gl/m4/vasnprintf.m4
+++ b/gl/m4/vasnprintf.m4
@@ -1,5 +1,5 @@
-# vasnprintf.m4 serial 32
-dnl Copyright (C) 2002-2004, 2006-2011 Free Software Foundation, Inc.
+# vasnprintf.m4 serial 35
+dnl Copyright (C) 2002-2004, 2006-2012 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.
@@ -29,7 +29,7 @@ AC_DEFUN([gl_REPLACE_VASNPRINTF],
   gl_PREREQ_ASNPRINTF
 ])
 
-# Prequisites of lib/printf-args.h, lib/printf-args.c.
+# Prerequisites of lib/printf-args.h, lib/printf-args.c.
 AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
 [
   AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
@@ -37,7 +37,7 @@ AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
   AC_REQUIRE([gt_TYPE_WINT_T])
 ])
 
-# Prequisites of lib/printf-parse.h, lib/printf-parse.c.
+# Prerequisites of lib/printf-parse.h, lib/printf-parse.c.
 AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
 [
   AC_REQUIRE([gl_FEATURES_H])
@@ -63,7 +63,10 @@ AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
   AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
   dnl Use the _snprintf function only if it is declared (because on NetBSD it
   dnl is defined as a weak alias of snprintf; we prefer to use the latter).
-  AC_CHECK_DECLS([_snprintf], , , [#include <stdio.h>])
+  AC_CHECK_DECLS([_snprintf], , , [[#include <stdio.h>]])
+  dnl Knowing DBL_EXPBIT0_WORD and DBL_EXPBIT0_BIT enables an optimization
+  dnl in the code for NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE.
+  AC_REQUIRE([gl_DOUBLE_EXPONENT_LOCATION])
   dnl We can avoid a lot of code by assuming that snprintf's return value
   dnl conforms to ISO C99. So check that.
   AC_REQUIRE([gl_SNPRINTF_RETVAL_C99])
diff --git a/gl/m4/vasprintf.m4 b/gl/m4/vasprintf.m4
index 6db52b1..205ceea 100644
--- a/gl/m4/vasprintf.m4
+++ b/gl/m4/vasprintf.m4
@@ -1,5 +1,5 @@
 # vasprintf.m4 serial 6
-dnl Copyright (C) 2002-2003, 2006-2007, 2009-2011 Free Software Foundation,
+dnl Copyright (C) 2002-2003, 2006-2007, 2009-2012 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
diff --git a/gl/m4/version-etc.m4 b/gl/m4/version-etc.m4
index 5032bf8..4c6c678 100644
--- a/gl/m4/version-etc.m4
+++ b/gl/m4/version-etc.m4
@@ -1,5 +1,5 @@
 # version-etc.m4 serial 1
-# Copyright (C) 2009-2011 Free Software Foundation, Inc.
+# Copyright (C) 2009-2012 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/warn-on-use.m4 b/gl/m4/warn-on-use.m4
index e0d0f27..03b113c 100644
--- a/gl/m4/warn-on-use.m4
+++ b/gl/m4/warn-on-use.m4
@@ -1,5 +1,5 @@
-# warn-on-use.m4 serial 2
-dnl Copyright (C) 2010-2011 Free Software Foundation, Inc.
+# warn-on-use.m4 serial 4
+dnl Copyright (C) 2010-2012 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.
@@ -27,6 +27,8 @@ AC_DEFUN([gl_WARN_ON_USE_PREPARE],
     [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])),
       [Define to 1 if ]m4_defn([gl_decl])[ is declared even after
        undefining macros.])])dnl
+dnl FIXME: gl_Symbol must be used unquoted until we can assume
+dnl autoconf 2.64 or newer.
   for gl_func in m4_flatten([$2]); do
     AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl
     AC_CACHE_CHECK([whether $gl_func is declared without a macro],
@@ -35,8 +37,8 @@ AC_DEFUN([gl_WARN_ON_USE_PREPARE],
 address@hidden:@undef $gl_func
   (void) $gl_func;])],
         [AS_VAR_SET(gl_Symbol, [yes])], [AS_VAR_SET(gl_Symbol, [no])])])
-     AS_VAR_IF(gl_Symbol, [yes],
-       [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1])
+    AS_VAR_IF(gl_Symbol, [yes],
+      [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1])
        dnl shortcut - if the raw declaration exists, then set a cache
        dnl variable to allow skipping any later AC_CHECK_DECL efforts
        eval ac_cv_have_decl_$gl_func=yes])
diff --git a/gl/m4/warnings.m4 b/gl/m4/warnings.m4
index b2d1a29..69d05a6 100644
--- a/gl/m4/warnings.m4
+++ b/gl/m4/warnings.m4
@@ -1,5 +1,5 @@
-# warnings.m4 serial 3
-dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
+# warnings.m4 serial 5
+dnl Copyright (C) 2008-2012 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.
@@ -19,18 +19,19 @@ m4_ifdef([AS_VAR_APPEND],
 # Adds parameter to WARN_CFLAGS if the compiler supports it.  For example,
 # gl_WARN_ADD([-Wparentheses]).
 AC_DEFUN([gl_WARN_ADD],
+dnl FIXME: gl_Warn must be used unquoted until we can assume
+dnl autoconf 2.64 or newer.
 [AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_$1])dnl
-AC_CACHE_CHECK([whether compiler handles $1], [gl_Warn], [
+AC_CACHE_CHECK([whether compiler handles $1], m4_defn([gl_Warn]), [
   gl_save_CPPFLAGS="$CPPFLAGS"
   CPPFLAGS="${CPPFLAGS} $1"
   AC_PREPROC_IFELSE([AC_LANG_PROGRAM([])],
-                    [AS_VAR_SET([gl_Warn], [yes])],
-                    [AS_VAR_SET([gl_Warn], [no])])
+                    [AS_VAR_SET(gl_Warn, [yes])],
+                    [AS_VAR_SET(gl_Warn, [no])])
   CPPFLAGS="$gl_save_CPPFLAGS"
 ])
-AS_VAR_PUSHDEF([gl_Flags], m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]))dnl
-AS_VAR_IF([gl_Warn], [yes], [gl_AS_VAR_APPEND([gl_Flags], [" $1"])])
-AS_VAR_POPDEF([gl_Flags])dnl
+AS_VAR_IF(gl_Warn, [yes],
+  [gl_AS_VAR_APPEND(m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]), [" $1"])])
 AS_VAR_POPDEF([gl_Warn])dnl
 m4_ifval([$2], [AS_LITERAL_IF([$2], [AC_SUBST([$2])], [])])dnl
 ])
diff --git a/gl/m4/wchar_h.m4 b/gl/m4/wchar_h.m4
index 977491f..c7a8b2d 100644
--- a/gl/m4/wchar_h.m4
+++ b/gl/m4/wchar_h.m4
@@ -1,6 +1,6 @@
 dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues.
 
-dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2007-2012 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.
diff --git a/gl/m4/wchar_t.m4 b/gl/m4/wchar_t.m4
index d2c03c4..534735d 100644
--- a/gl/m4/wchar_t.m4
+++ b/gl/m4/wchar_t.m4
@@ -1,5 +1,5 @@
 # wchar_t.m4 serial 4 (gettext-0.18.2)
-dnl Copyright (C) 2002-2003, 2008-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2003, 2008-2012 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.
diff --git a/gl/m4/wcrtomb.m4 b/gl/m4/wcrtomb.m4
index d21f1b9..00d7302 100644
--- a/gl/m4/wcrtomb.m4
+++ b/gl/m4/wcrtomb.m4
@@ -1,5 +1,5 @@
-# wcrtomb.m4 serial 10
-dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
+# wcrtomb.m4 serial 11
+dnl Copyright (C) 2008-2012 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.
@@ -14,6 +14,22 @@ AC_DEFUN([gl_FUNC_WCRTOMB],
   AC_CHECK_FUNCS_ONCE([wcrtomb])
   if test $ac_cv_func_wcrtomb = no; then
     HAVE_WCRTOMB=0
+    AC_CHECK_DECLS([wcrtomb],,, [[
+/* 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
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+]])
+    if test $ac_cv_have_decl_wcrtomb = yes; then
+      dnl On Minix 3.1.8, the system's <wchar.h> declares wcrtomb() although
+      dnl it does not have the function. Avoid a collision with gnulib's
+      dnl replacement.
+      REPLACE_WCRTOMB=1
+    fi
   else
     if test $REPLACE_MBSTATE_T = 1; then
       REPLACE_WCRTOMB=1
diff --git a/gl/m4/wctob.m4 b/gl/m4/wctob.m4
index 8175d00..786c881 100644
--- a/gl/m4/wctob.m4
+++ b/gl/m4/wctob.m4
@@ -1,5 +1,5 @@
-# wctob.m4 serial 9
-dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
+# wctob.m4 serial 10
+dnl Copyright (C) 2008-2012 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.
@@ -104,7 +104,7 @@ int main ()
     if test $REPLACE_WCTOB = 0; then
 
       dnl IRIX 6.5 has the wctob() function but does not declare it.
-      AC_CHECK_DECLS([wctob], [], [], [
+      AC_CHECK_DECLS([wctob], [], [], [[
 /* 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 included
@@ -113,7 +113,7 @@ int main ()
 #include <stdio.h>
 #include <time.h>
 #include <wchar.h>
-])
+]])
       if test $ac_cv_have_decl_wctob != yes; then
         HAVE_DECL_WCTOB=0
       fi
diff --git a/gl/m4/wctomb.m4 b/gl/m4/wctomb.m4
index ee16a7e..88fd6be 100644
--- a/gl/m4/wctomb.m4
+++ b/gl/m4/wctomb.m4
@@ -1,5 +1,5 @@
 # wctomb.m4 serial 2
-dnl Copyright (C) 2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2011-2012 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.
diff --git a/gl/m4/wctype_h.m4 b/gl/m4/wctype_h.m4
index ef9fb04..a109383 100644
--- a/gl/m4/wctype_h.m4
+++ b/gl/m4/wctype_h.m4
@@ -1,8 +1,8 @@
-# wctype_h.m4 serial 14
+# wctype_h.m4 serial 16
 
 dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it.
 
-dnl Copyright (C) 2006-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2006-2012 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.
@@ -75,7 +75,44 @@ AC_DEFUN([gl_WCTYPE_H],
   AC_SUBST([REPLACE_ISWCNTRL])
 
   if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then
-    dnl Redefine all of iswcntrl, ..., towupper in <wctype.h>.
+    dnl Redefine all of iswcntrl, ..., iswxdigit in <wctype.h>.
+    :
+  fi
+
+  if test $REPLACE_ISWCNTRL = 1; then
+    REPLACE_TOWLOWER=1
+  else
+    AC_CHECK_FUNCS([towlower])
+    if test $ac_cv_func_towlower = yes; then
+      REPLACE_TOWLOWER=0
+    else
+      AC_CHECK_DECLS([towlower],,,
+        [[/* 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 included before <wchar.h>.  */
+          #include <stddef.h>
+          #include <stdio.h>
+          #include <time.h>
+          #include <wchar.h>
+          #if HAVE_WCTYPE_H
+          # include <wctype.h>
+          #endif
+        ]])
+      if test $ac_cv_have_decl_towlower = yes; then
+        dnl On Minix 3.1.8, the system's <wctype.h> declares towlower() and
+        dnl towupper() although it does not have the functions. Avoid a
+        dnl collision with gnulib's replacement.
+        REPLACE_TOWLOWER=1
+      else
+        REPLACE_TOWLOWER=0
+      fi
+    fi
+  fi
+  AC_SUBST([REPLACE_TOWLOWER])
+
+  if test $HAVE_ISWCNTRL = 0 || test $REPLACE_TOWLOWER = 1; then
+    dnl Redefine towlower, towupper in <wctype.h>.
     :
   fi
 
diff --git a/gl/m4/wint_t.m4 b/gl/m4/wint_t.m4
index da1ce3d..3260cce 100644
--- a/gl/m4/wint_t.m4
+++ b/gl/m4/wint_t.m4
@@ -1,5 +1,5 @@
 # wint_t.m4 serial 5 (gettext-0.18.2)
-dnl Copyright (C) 2003, 2007-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2003, 2007-2012 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.
diff --git a/gl/m4/xalloc.m4 b/gl/m4/xalloc.m4
index 2fca850..f47b649 100644
--- a/gl/m4/xalloc.m4
+++ b/gl/m4/xalloc.m4
@@ -1,5 +1,5 @@
 # xalloc.m4 serial 17
-dnl Copyright (C) 2002-2006, 2009-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2006, 2009-2012 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.
diff --git a/gl/m4/xsize.m4 b/gl/m4/xsize.m4
index 8c693bc..b3b7fee 100644
--- a/gl/m4/xsize.m4
+++ b/gl/m4/xsize.m4
@@ -1,5 +1,5 @@
 # xsize.m4 serial 4
-dnl Copyright (C) 2003-2004, 2008-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2003-2004, 2008-2012 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.
diff --git a/gl/m4/yield.m4 b/gl/m4/yield.m4
index 15d5ac2..94e69c4 100644
--- a/gl/m4/yield.m4
+++ b/gl/m4/yield.m4
@@ -1,5 +1,5 @@
 # yield.m4 serial 2
-dnl Copyright (C) 2005-2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2005-2012 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.
diff --git a/gl/malloc.c b/gl/malloc.c
index da45618..ffe042b 100644
--- a/gl/malloc.c
+++ b/gl/malloc.c
@@ -1,6 +1,6 @@
 /* malloc() function that is glibc compatible.
 
-   Copyright (C) 1997-1998, 2006-2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 1997-1998, 2006-2007, 2009-2012 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
diff --git a/gl/mbrtowc.c b/gl/mbrtowc.c
index 7a8e599..a60e56d 100644
--- a/gl/mbrtowc.c
+++ b/gl/mbrtowc.c
@@ -1,5 +1,5 @@
 /* Convert multibyte character to wide character.
-   Copyright (C) 1999-2002, 2005-2011 Free Software Foundation, Inc.
+   Copyright (C) 1999-2002, 2005-2012 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2008.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/gl/mbsinit.c b/gl/mbsinit.c
index 8ac2137..638142e 100644
--- a/gl/mbsinit.c
+++ b/gl/mbsinit.c
@@ -1,5 +1,5 @@
 /* Test for initial conversion state.
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2008.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/gl/memchr.c b/gl/memchr.c
index 6d903b1..b8fb0ef 100644
--- a/gl/memchr.c
+++ b/gl/memchr.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2011
+/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2012
    Free Software Foundation, Inc.
 
    Based on strlen implementation by Torbjorn Granlund (address@hidden),
diff --git a/gl/msvc-inval.c b/gl/msvc-inval.c
new file mode 100644
index 0000000..b7a917d
--- /dev/null
+++ b/gl/msvc-inval.c
@@ -0,0 +1,130 @@
+/* Invalid parameter handler for MSVC runtime libraries.
+   Copyright (C) 2011-2012 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
+   the Free Software Foundation; either version 3, 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 General Public License for more details.
+
+   You should have received a copy of the GNU 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.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include "msvc-inval.h"
+
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER \
+    && !(MSVC_INVALID_PARAMETER_HANDLING == SANE_LIBRARY_HANDLING)
+
+/* Get _invalid_parameter_handler type and _set_invalid_parameter_handler
+   declaration.  */
+# include <stdlib.h>
+
+# if MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING
+
+static void cdecl
+gl_msvc_invalid_parameter_handler (const wchar_t *expression,
+                                   const wchar_t *function,
+                                   const wchar_t *file,
+                                   unsigned int line,
+                                   uintptr_t dummy)
+{
+}
+
+# else
+
+/* Get declarations of the native Windows API functions.  */
+#  define WIN32_LEAN_AND_MEAN
+#  include <windows.h>
+
+#  if defined _MSC_VER
+
+static void cdecl
+gl_msvc_invalid_parameter_handler (const wchar_t *expression,
+                                   const wchar_t *function,
+                                   const wchar_t *file,
+                                   unsigned int line,
+                                   uintptr_t dummy)
+{
+  RaiseException (STATUS_GNULIB_INVALID_PARAMETER, 0, 0, NULL);
+}
+
+#  else
+
+/* An index to thread-local storage.  */
+static DWORD tls_index;
+static int tls_initialized /* = 0 */;
+
+/* Used as a fallback only.  */
+static struct gl_msvc_inval_per_thread not_per_thread;
+
+struct gl_msvc_inval_per_thread *
+gl_msvc_inval_current (void)
+{
+  if (!tls_initialized)
+    {
+      tls_index = TlsAlloc ();
+      tls_initialized = 1;
+    }
+  if (tls_index == TLS_OUT_OF_INDEXES)
+    /* TlsAlloc had failed.  */
+    return &not_per_thread;
+  else
+    {
+      struct gl_msvc_inval_per_thread *pointer =
+        (struct gl_msvc_inval_per_thread *) TlsGetValue (tls_index);
+      if (pointer == NULL)
+        {
+          /* First call.  Allocate a new 'struct gl_msvc_inval_per_thread'.  */
+          pointer =
+            (struct gl_msvc_inval_per_thread *)
+            malloc (sizeof (struct gl_msvc_inval_per_thread));
+          if (pointer == NULL)
+            /* Could not allocate memory.  Use the global storage.  */
+            pointer = &not_per_thread;
+          TlsSetValue (tls_index, pointer);
+        }
+      return pointer;
+    }
+}
+
+static void cdecl
+gl_msvc_invalid_parameter_handler (const wchar_t *expression,
+                                   const wchar_t *function,
+                                   const wchar_t *file,
+                                   unsigned int line,
+                                   uintptr_t dummy)
+{
+  struct gl_msvc_inval_per_thread *current = gl_msvc_inval_current ();
+  if (current->restart_valid)
+    longjmp (current->restart, 1);
+  else
+    /* An invalid parameter notification from outside the gnulib code.
+       Give the caller a chance to intervene.  */
+    RaiseException (STATUS_GNULIB_INVALID_PARAMETER, 0, 0, NULL);
+}
+
+#  endif
+
+# endif
+
+static int gl_msvc_inval_initialized /* = 0 */;
+
+void
+gl_msvc_inval_ensure_handler (void)
+{
+  if (gl_msvc_inval_initialized == 0)
+    {
+      _set_invalid_parameter_handler (gl_msvc_invalid_parameter_handler);
+      gl_msvc_inval_initialized = 1;
+    }
+}
+
+#endif
diff --git a/gl/msvc-inval.h b/gl/msvc-inval.h
new file mode 100644
index 0000000..373f9bf
--- /dev/null
+++ b/gl/msvc-inval.h
@@ -0,0 +1,223 @@
+/* Invalid parameter handler for MSVC runtime libraries.
+   Copyright (C) 2011-2012 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
+   the Free Software Foundation; either version 3, 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 General Public License for more details.
+
+   You should have received a copy of the GNU 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.  */
+
+#ifndef _MSVC_INVAL_H
+#define _MSVC_INVAL_H
+
+/* With MSVC runtime libraries with the "invalid parameter handler" concept,
+   functions like fprintf(), dup2(), or close() crash when the caller passes
+   an invalid argument.  But POSIX wants error codes (such as EINVAL or EBADF)
+   instead.
+   This file defines macros that turn such an invalid parameter notification
+   into a non-local exit.  An error code can then be produced at the target
+   of this exit.  You can thus write code like
+
+     TRY_MSVC_INVAL
+       {
+         <Code that can trigger an invalid parameter notification
+          but does not do 'return', 'break', 'continue', nor 'goto'.>
+       }
+     CATCH_MSVC_INVAL
+       {
+         <Code that handles an invalid parameter notification
+          but does not do 'return', 'break', 'continue', nor 'goto'.>
+       }
+     DONE_MSVC_INVAL;
+
+   This entire block expands to a single statement.
+
+   The handling of invalid parameters can be done in three ways:
+
+     * The default way, which is reasonable for programs (not libraries):
+       AC_DEFINE([MSVC_INVALID_PARAMETER_HANDLING], [DEFAULT_HANDLING])
+
+     * The way for libraries that make "hairy" calls (like close(-1), or
+       fclose(fp) where fileno(fp) is closed, or simply getdtablesize()):
+       AC_DEFINE([MSVC_INVALID_PARAMETER_HANDLING], [HAIRY_LIBRARY_HANDLING])
+
+     * The way for libraries that make no "hairy" calls:
+       AC_DEFINE([MSVC_INVALID_PARAMETER_HANDLING], [SANE_LIBRARY_HANDLING])
+ */
+
+#define DEFAULT_HANDLING       0
+#define HAIRY_LIBRARY_HANDLING 1
+#define SANE_LIBRARY_HANDLING  2
+
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER \
+    && !(MSVC_INVALID_PARAMETER_HANDLING == SANE_LIBRARY_HANDLING)
+/* A native Windows platform with the "invalid parameter handler" concept,
+   and either DEFAULT_HANDLING or HAIRY_LIBRARY_HANDLING.  */
+
+# if MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING
+/* Default handling.  */
+
+#  ifdef __cplusplus
+extern "C" {
+#  endif
+
+/* Ensure that the invalid parameter handler in installed that just returns.
+   Because we assume no other part of the program installs a different
+   invalid parameter handler, this solution is multithread-safe.  */
+extern void gl_msvc_inval_ensure_handler (void);
+
+#  ifdef __cplusplus
+}
+#  endif
+
+#  define TRY_MSVC_INVAL \
+     do                                                                        
\
+       {                                                                       
\
+         gl_msvc_inval_ensure_handler ();                                      
\
+         if (1)
+#  define CATCH_MSVC_INVAL \
+         else
+#  define DONE_MSVC_INVAL \
+       }                                                                       
\
+     while (0)
+
+# else
+/* Handling for hairy libraries.  */
+
+#  include <excpt.h>
+
+/* Gnulib can define its own status codes, as described in the page
+   "Raising Software Exceptions" on microsoft.com
+   <http://msdn.microsoft.com/en-us/library/het71c37.aspx>.
+   Our status codes are composed of
+     - 0xE0000000, mandatory for all user-defined status codes,
+     - 0x474E550, a API identifier ("GNU"),
+     - 0, 1, 2, ..., used to distinguish different status codes from the
+       same API.  */
+#  define STATUS_GNULIB_INVALID_PARAMETER (0xE0000000 + 0x474E550 + 0)
+
+#  if defined _MSC_VER
+/* A compiler that supports __try/__except, as described in the page
+   "try-except statement" on microsoft.com
+   <http://msdn.microsoft.com/en-us/library/s58ftw19.aspx>.
+   With __try/__except, we can use the multithread-safe exception handling.  */
+
+#   ifdef __cplusplus
+extern "C" {
+#   endif
+
+/* Ensure that the invalid parameter handler in installed that raises a
+   software exception with code STATUS_GNULIB_INVALID_PARAMETER.
+   Because we assume no other part of the program installs a different
+   invalid parameter handler, this solution is multithread-safe.  */
+extern void gl_msvc_inval_ensure_handler (void);
+
+#   ifdef __cplusplus
+}
+#   endif
+
+#   define TRY_MSVC_INVAL \
+      do                                                                       
\
+        {                                                                      
\
+          gl_msvc_inval_ensure_handler ();                                     
\
+          __try
+#   define CATCH_MSVC_INVAL \
+          __except (GetExceptionCode () == STATUS_GNULIB_INVALID_PARAMETER     
\
+                    ? EXCEPTION_EXECUTE_HANDLER                                
\
+                    : EXCEPTION_CONTINUE_SEARCH)
+#   define DONE_MSVC_INVAL \
+        }                                                                      
\
+      while (0)
+
+#  else
+/* Any compiler.
+   We can only use setjmp/longjmp.  */
+
+#   include <setjmp.h>
+
+#   ifdef __cplusplus
+extern "C" {
+#   endif
+
+struct gl_msvc_inval_per_thread
+{
+  /* The restart that will resume execution at the code between
+     CATCH_MSVC_INVAL and DONE_MSVC_INVAL.  It is enabled only between
+     TRY_MSVC_INVAL and CATCH_MSVC_INVAL.  */
+  jmp_buf restart;
+
+  /* Tells whether the contents of restart is valid.  */
+  int restart_valid;
+};
+
+/* Ensure that the invalid parameter handler in installed that passes
+   control to the gl_msvc_inval_restart if it is valid, or raises a
+   software exception with code STATUS_GNULIB_INVALID_PARAMETER otherwise.
+   Because we assume no other part of the program installs a different
+   invalid parameter handler, this solution is multithread-safe.  */
+extern void gl_msvc_inval_ensure_handler (void);
+
+/* Return a pointer to the per-thread data for the current thread.  */
+extern struct gl_msvc_inval_per_thread *gl_msvc_inval_current (void);
+
+#   ifdef __cplusplus
+}
+#   endif
+
+#   define TRY_MSVC_INVAL \
+      do                                                                       
\
+        {                                                                      
\
+          struct gl_msvc_inval_per_thread *msvc_inval_current;                 
\
+          gl_msvc_inval_ensure_handler ();                                     
\
+          msvc_inval_current = gl_msvc_inval_current ();                       
\
+          /* First, initialize gl_msvc_inval_restart.  */                      
\
+          if (setjmp (msvc_inval_current->restart) == 0)                       
\
+            {                                                                  
\
+              /* Then, mark it as valid.  */                                   
\
+              msvc_inval_current->restart_valid = 1;
+#   define CATCH_MSVC_INVAL \
+              /* Execution completed.                                          
\
+                 Mark gl_msvc_inval_restart as invalid.  */                    
\
+              msvc_inval_current->restart_valid = 0;                           
\
+            }                                                                  
\
+          else                                                                 
\
+            {                                                                  
\
+              /* Execution triggered an invalid parameter notification.        
\
+                 Mark gl_msvc_inval_restart as invalid.  */                    
\
+              msvc_inval_current->restart_valid = 0;
+#   define DONE_MSVC_INVAL \
+            }                                                                  
\
+        }                                                                      
\
+      while (0)
+
+#  endif
+
+# endif
+
+#else
+/* A platform that does not need to the invalid parameter handler,
+   or when SANE_LIBRARY_HANDLING is desired.  */
+
+/* The braces here avoid GCC warnings like
+   "warning: suggest explicit braces to avoid ambiguous 'else'".  */
+# define TRY_MSVC_INVAL \
+    do                                                                         
\
+      {                                                                        
\
+        if (1)
+# define CATCH_MSVC_INVAL \
+        else
+# define DONE_MSVC_INVAL \
+      }                                                                        
\
+    while (0)
+
+#endif
+
+#endif /* _MSVC_INVAL_H */
diff --git a/gl/msvc-nothrow.c b/gl/msvc-nothrow.c
new file mode 100644
index 0000000..f0fea17
--- /dev/null
+++ b/gl/msvc-nothrow.c
@@ -0,0 +1,50 @@
+/* Wrappers that don't throw invalid parameter notifications
+   with MSVC runtime libraries.
+   Copyright (C) 2011-2012 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
+   the Free Software Foundation; either version 3, 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 General Public License for more details.
+
+   You should have received a copy of the GNU 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.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include "msvc-nothrow.h"
+
+/* Get declarations of the native Windows API functions.  */
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+#include "msvc-inval.h"
+
+#undef _get_osfhandle
+
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+intptr_t
+_gl_nothrow_get_osfhandle (int fd)
+{
+  intptr_t result;
+
+  TRY_MSVC_INVAL
+    {
+      result = _get_osfhandle (fd);
+    }
+  CATCH_MSVC_INVAL
+    {
+      result = (intptr_t) INVALID_HANDLE_VALUE;
+    }
+  DONE_MSVC_INVAL;
+
+  return result;
+}
+#endif
diff --git a/gl/msvc-nothrow.h b/gl/msvc-nothrow.h
new file mode 100644
index 0000000..e066b24
--- /dev/null
+++ b/gl/msvc-nothrow.h
@@ -0,0 +1,44 @@
+/* Wrappers that don't throw invalid parameter notifications
+   with MSVC runtime libraries.
+   Copyright (C) 2011-2012 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
+   the Free Software Foundation; either version 3, 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 General Public License for more details.
+
+   You should have received a copy of the GNU 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.  */
+
+#ifndef _MSVC_NOTHROW_H
+#define _MSVC_NOTHROW_H
+
+/* With MSVC runtime libraries with the "invalid parameter handler" concept,
+   functions like fprintf(), dup2(), or close() crash when the caller passes
+   an invalid argument.  But POSIX wants error codes (such as EINVAL or EBADF)
+   instead.
+   This file defines wrappers that turn such an invalid parameter notification
+   into an error code.  */
+
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+
+/* Get original declaration of _get_osfhandle.  */
+# include <io.h>
+
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+
+/* Override _get_osfhandle.  */
+extern intptr_t _gl_nothrow_get_osfhandle (int fd);
+#  define _get_osfhandle _gl_nothrow_get_osfhandle
+
+# endif
+
+#endif
+
+#endif /* _MSVC_NOTHROW_H */
diff --git a/gl/netdb.in.h b/gl/netdb.in.h
index 69b6d5d..ddc97b9 100644
--- a/gl/netdb.in.h
+++ b/gl/netdb.in.h
@@ -1,5 +1,5 @@
 /* Provide a netdb.h header file for systems lacking it (read: MinGW).
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 Free Software Foundation, Inc.
    Written by Simon Josefsson.
 
    This program is free software; you can redistribute it and/or modify
@@ -80,9 +80,9 @@ struct addrinfo
 
 # endif
 
-/* Possible values for `ai_flags' field in `addrinfo' structure.  */
+/* Possible values for 'ai_flags' field in 'addrinfo' structure.  */
 # ifndef AI_PASSIVE
-#  define AI_PASSIVE    0x0001  /* Socket address is intended for `bind'.  */
+#  define AI_PASSIVE    0x0001  /* Socket address is intended for 'bind'.  */
 # endif
 # ifndef AI_CANONNAME
 #  define AI_CANONNAME  0x0002  /* Request for canonical name.  */
@@ -111,16 +111,16 @@ struct addrinfo
                                       returned address type.  */
 # endif
 
-/* Error values for `getaddrinfo' function.  */
+/* Error values for 'getaddrinfo' function.  */
 # ifndef EAI_BADFLAGS
-#  define EAI_BADFLAGS    -1    /* Invalid value for `ai_flags' field.  */
+#  define EAI_BADFLAGS    -1    /* Invalid value for 'ai_flags' field.  */
 #  define EAI_NONAME      -2    /* NAME or SERVICE is unknown.  */
 #  define EAI_AGAIN       -3    /* Temporary failure in name resolution.  */
 #  define EAI_FAIL        -4    /* Non-recoverable failure in name res.  */
 #  define EAI_NODATA      -5    /* No address associated with NAME.  */
-#  define EAI_FAMILY      -6    /* `ai_family' not supported.  */
-#  define EAI_SOCKTYPE    -7    /* `ai_socktype' not supported.  */
-#  define EAI_SERVICE     -8    /* SERVICE not supported for `ai_socktype'.  */
+#  define EAI_FAMILY      -6    /* 'ai_family' not supported.  */
+#  define EAI_SOCKTYPE    -7    /* 'ai_socktype' not supported.  */
+#  define EAI_SERVICE     -8    /* SERVICE not supported for 'ai_socktype'.  */
 #  define EAI_MEMORY      -10   /* Memory allocation failure.  */
 # endif
 
@@ -141,7 +141,7 @@ struct addrinfo
 # endif
 # ifndef EAI_SYSTEM
 /* Not defined on mingw32. */
-#  define EAI_SYSTEM      -11   /* System error returned in `errno'.  */
+#  define EAI_SYSTEM      -11   /* System error returned in 'errno'.  */
 # endif
 
 # if 0
@@ -179,7 +179,7 @@ _GL_CXXALIAS_SYS (getaddrinfo, int,
 _GL_CXXALIASWARN (getaddrinfo);
 
 # if address@hidden@
-/* Free `addrinfo' structure AI including associated storage.
+/* Free 'addrinfo' structure AI including associated storage.
    For more details, see the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/getaddrinfo.html>.  */
 _GL_FUNCDECL_SYS (freeaddrinfo, void, (struct addrinfo *ai)
diff --git a/gl/netinet_in.in.h b/gl/netinet_in.in.h
index 966d6a5..e06dfe0 100644
--- a/gl/netinet_in.in.h
+++ b/gl/netinet_in.in.h
@@ -1,5 +1,5 @@
 /* Substitute for <netinet/in.h>.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
diff --git a/gl/override/lib/dup2.c.diff b/gl/override/lib/dup2.c.diff
deleted file mode 100644
index e48354d..0000000
--- a/gl/override/lib/dup2.c.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-diff --git a/gltests/dup2.c b/gltests/dup2.c
-index a4422bf..b9b329c 100644
---- a/gltests/dup2.c
-+++ b/gltests/dup2.c
-@@ -40,6 +40,7 @@ rpl_dup2 (int fd, int desired_fd)
- {
-   int result;
- # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-+  int fd_mode = -1;
-   /* If fd is closed, mingw hangs on dup2 (fd, fd).  If fd is open,
-      dup2 (fd, fd) returns 0, but all further attempts to use fd in
-      future dup2 calls will hang.  */
-@@ -59,6 +60,14 @@ rpl_dup2 (int fd, int desired_fd)
-       errno = EBADF;
-       return -1;
-     }
-+  /* Wine 1.0.1 puts desired_fd into binary mode when fd is in text
-+     mode, so we save the old mode here.
-+     http://bugs.winehq.org/show_bug.cgi?id=21291 */
-+  if ((HANDLE) _get_osfhandle (fd) != (HANDLE) -1)
-+    {
-+      fd_mode = setmode (fd, O_BINARY);
-+      setmode (fd, fd_mode);
-+    }
- # endif
-   result = dup2 (fd, desired_fd);
- # ifdef __linux__
-@@ -80,6 +89,12 @@ rpl_dup2 (int fd, int desired_fd)
-   if (fd != desired_fd && result != -1)
-     result = _gl_register_dup (fd, result);
- # endif
-+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-+  /* Restore text mode if needed.
-+     http://bugs.winehq.org/show_bug.cgi?id=21291 */
-+  if (result != -1 && fd_mode != -1)
-+    setmode (desired_fd, fd_mode);
-+# endif
-   return result;
- }
- 
diff --git a/gl/override/lib/getpass.c.diff b/gl/override/lib/getpass.c.diff
deleted file mode 100644
index b8148b3..0000000
--- a/gl/override/lib/getpass.c.diff
+++ /dev/null
@@ -1,42 +0,0 @@
---- gl/getpass.c.orig  2010-01-12 12:48:52.000000000 +0100
-+++ gl/getpass.c       2010-01-12 12:51:39.000000000 +0100
-@@ -192,6 +192,7 @@
-   char getpassbuf[PASS_MAX + 1];
-   size_t i = 0;
-   int c;
-+  int use_getc = 0;
- 
-   if (prompt)
-     {
-@@ -201,8 +202,20 @@
- 
-   for (;;)
-     {
--      c = _getch ();
--      if (c == '\r')
-+      if (use_getc)
-+        c = getc (stdin);
-+      else
-+        {
-+          c = _getch ();
-+          if (c == -1)
-+            {
-+              /* Under Wine, _getch always returns -1.  Fall back to
-+                 using getc.  */
-+              use_getc = 1;
-+              continue;
-+            }
-+        }
-+      if (c == '\n' || c == '\r')
-         {
-           getpassbuf[i] = '\0';
-           break;
-@@ -219,7 +232,7 @@
-         }
-     }
- 
--  if (prompt)
-+  if (prompt && !use_getc)
-     {
-       fputs ("\r\n", stderr);
-       fflush (stderr);
diff --git a/gl/override/lib/gettext.h.diff b/gl/override/lib/gettext.h.diff
index eb1889b..f575362 100644
--- a/gl/override/lib/gettext.h.diff
+++ b/gl/override/lib/gettext.h.diff
@@ -1,17 +1,11 @@
---- gl/gettext.h.orig  2010-01-12 13:01:46.000000000 +0100
-+++ gl/gettext.h       2010-01-12 13:01:39.000000000 +0100
-@@ -172,109 +172,4 @@
-     return translation;
- }
+--- gl/gettext.h.orig  2012-02-07 10:01:26.854383205 +0100
++++ gl/gettext.h       2012-02-07 10:01:39.923793105 +0100
+@@ -184,103 +184,4 @@
+ 
+ #include <string.h>
  
--/* The same thing extended for non-constant arguments.  Here MSGCTXT and MSGID
--   can be arbitrary expressions.  But for string literals these macros are
--   less efficient than those above.  */
--
--#include <string.h>
--
 -#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
--  (((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) \
+-  (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \
 -   /* || __STDC_VERSION__ >= 199901L */ )
 -
 -#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
diff --git a/gl/override/m4/open.m4.diff b/gl/override/m4/open.m4.diff
deleted file mode 100644
index 1ea367f..0000000
--- a/gl/override/m4/open.m4.diff
+++ /dev/null
@@ -1,34 +0,0 @@
---- gl/m4/open.m4.orig 2010-01-12 12:13:11.000000000 +0100
-+++ gl/m4/open.m4      2010-01-12 12:13:20.000000000 +0100
-@@ -9,7 +9,9 @@
-   AC_REQUIRE([AC_CANONICAL_HOST])
-   case "$host_os" in
-     mingw* | pw*)
--      gl_REPLACE_OPEN
-+      # The misbehaviour is only under Wine, see
-+      # http://bugs.winehq.org/show_bug.cgi?id=21292
-+      gl_cv_func_open_slash=no
-       ;;
-     *)
-       dnl open("foo/") should not create a file when the file name has a
-@@ -46,13 +48,13 @@
-             ])
-           rm -f conftest.sl conftest.tmp conftest.lnk
-         ])
--      case "$gl_cv_func_open_slash" in
--        *no)
--          AC_DEFINE([OPEN_TRAILING_SLASH_BUG], [1],
--            [Define to 1 if open() fails to recognize a trailing slash.])
--          gl_REPLACE_OPEN
--          ;;
--      esac
-+      ;;
-+  esac
-+  case "$gl_cv_func_open_slash" in
-+    *no)
-+      AC_DEFINE([OPEN_TRAILING_SLASH_BUG], [1],
-+                [Define to 1 if open() fails to recognize a trailing slash.])
-+      gl_REPLACE_OPEN
-       ;;
-   esac
- ])
diff --git a/gl/poll.c b/gl/poll.c
index f7b3fdd..fd12751 100644
--- a/gl/poll.c
+++ b/gl/poll.c
@@ -1,7 +1,7 @@
 /* Emulation for poll(2)
    Contributed by Paolo Bonzini.
 
-   Copyright 2001-2003, 2006-2011 Free Software Foundation, Inc.
+   Copyright 2001-2003, 2006-2012 Free Software Foundation, Inc.
 
    This file is part of gnulib.
 
@@ -37,12 +37,13 @@
 #include <assert.h>
 
 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-# define WIN32_NATIVE
+# define WINDOWS_NATIVE
 # include <winsock2.h>
 # include <windows.h>
 # include <io.h>
 # include <stdio.h>
 # include <conio.h>
+# include "msvc-nothrow.h"
 #else
 # include <sys/time.h>
 # include <sys/socket.h>
@@ -68,9 +69,11 @@
 # define MSG_PEEK 0
 #endif
 
-#ifdef WIN32_NATIVE
+#ifdef WINDOWS_NATIVE
 
-#define IsConsoleHandle(h) (((long) (h) & 3) == 3)
+/* Optimized test whether a HANDLE refers to a console.
+   See <http://lists.gnu.org/archive/html/bug-gnulib/2009-08/msg00065.html>.  
*/
+#define IsConsoleHandle(h) (((intptr_t) (h) & 3) == 3)
 
 static BOOL
 IsSocketHandle (HANDLE h)
@@ -125,7 +128,7 @@ typedef DWORD (WINAPI *PNtQueryInformationFile)
    for the handle, eliminate them from *P_SOUGHT.  */
 
 static int
-win32_compute_revents (HANDLE h, int *p_sought)
+windows_compute_revents (HANDLE h, int *p_sought)
 {
   int i, ret, happened;
   INPUT_RECORD *irbuffer;
@@ -160,11 +163,12 @@ win32_compute_revents (HANDLE h, int *p_sought)
         {
           /* It was the write-end of the pipe.  Check if it is writable.
              If NtQueryInformationFile fails, optimistically assume the pipe is
-             writable.  This could happen on Win9x, where 
NtQueryInformationFile
-             is not available, or if we inherit a pipe that doesn't permit
-             FILE_READ_ATTRIBUTES access on the write end (I think this should
-             not happen since WinXP SP2; WINE seems fine too).  Otherwise,
-             ensure that enough space is available for atomic writes.  */
+             writable.  This could happen on Windows 9x, where
+             NtQueryInformationFile is not available, or if we inherit a pipe
+             that doesn't permit FILE_READ_ATTRIBUTES access on the write end
+             (I think this should not happen since Windows XP SP2; WINE seems
+             fine too).  Otherwise, ensure that enough space is available for
+             atomic writes.  */
           memset (&iosb, 0, sizeof (iosb));
           memset (&fpli, 0, sizeof (fpli));
 
@@ -223,7 +227,7 @@ win32_compute_revents (HANDLE h, int *p_sought)
 /* Convert fd_sets returned by select into revents values.  */
 
 static int
-win32_compute_revents_socket (SOCKET h, int sought, long lNetworkEvents)
+windows_compute_revents_socket (SOCKET h, int sought, long lNetworkEvents)
 {
   int happened = 0;
 
@@ -317,7 +321,7 @@ compute_revents (int fd, int sought, fd_set *rfds, fd_set 
*wfds, fd_set *efds)
 int
 poll (struct pollfd *pfd, nfds_t nfd, int timeout)
 {
-#ifndef WIN32_NATIVE
+#ifndef WINDOWS_NATIVE
   fd_set rfds, wfds, efds;
   struct timeval tv;
   struct timeval *ptv;
@@ -452,6 +456,7 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
   if (!hEvent)
     hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
 
+restart:
   handle_array[0] = hEvent;
   nhandles = 1;
   FD_ZERO (&rfds);
@@ -499,9 +504,9 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
         {
           /* Poll now.  If we get an event, do not poll again.  Also,
              screen buffer handles are waitable, and they'll block until
-             a character is available.  win32_compute_revents eliminates
+             a character is available.  windows_compute_revents eliminates
              bits for the "wrong" direction. */
-          pfd[i].revents = win32_compute_revents (h, &sought);
+          pfd[i].revents = windows_compute_revents (h, &sought);
           if (sought)
             handle_array[nhandles++] = h;
           if (pfd[i].revents)
@@ -577,14 +582,14 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
           if (FD_ISSET ((SOCKET) h, &xfds))
             ev.lNetworkEvents |= FD_OOB;
 
-          happened = win32_compute_revents_socket ((SOCKET) h, pfd[i].events,
-                                                   ev.lNetworkEvents);
+          happened = windows_compute_revents_socket ((SOCKET) h, pfd[i].events,
+                                                     ev.lNetworkEvents);
         }
       else
         {
           /* Not a socket.  */
           int sought = pfd[i].events;
-          happened = win32_compute_revents (h, &sought);
+          happened = windows_compute_revents (h, &sought);
           nhandles++;
         }
 
@@ -592,6 +597,12 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
         rc++;
     }
 
+  if (!rc && timeout == INFTIM)
+    {
+      SwitchToThread();
+      goto restart;
+    }
+
   return rc;
 #endif
 }
diff --git a/gl/poll.in.h b/gl/poll.in.h
index 694d1df..9ff40a7 100644
--- a/gl/poll.in.h
+++ b/gl/poll.in.h
@@ -1,7 +1,7 @@
 /* Header for poll(2) emulation
    Contributed by Paolo Bonzini.
 
-   Copyright 2001-2003, 2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright 2001-2003, 2007, 2009-2012 Free Software Foundation, Inc.
 
    This file is part of gnulib.
 
@@ -45,7 +45,7 @@
 /* fake a poll(2) environment */
 # define POLLIN      0x0001      /* any readable data available   */
 # define POLLPRI     0x0002      /* OOB/Urgent readable data      */
-# define POLLOUT     0x0004      /* file descriptor is writeable  */
+# define POLLOUT     0x0004      /* file descriptor is writable   */
 # define POLLERR     0x0008      /* some poll error occurred      */
 # define POLLHUP     0x0010      /* file descriptor was "hung up" */
 # define POLLNVAL    0x0020      /* requested events "invalid"    */
diff --git a/gl/printf-args.c b/gl/printf-args.c
index 8f3727b..979435f 100644
--- a/gl/printf-args.c
+++ b/gl/printf-args.c
@@ -1,5 +1,5 @@
 /* Decomposed printf argument list.
-   Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2011 Free Software
+   Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2012 Free Software
    Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/gl/printf-args.h b/gl/printf-args.h
index 70cca4f..39ec7f4 100644
--- a/gl/printf-args.h
+++ b/gl/printf-args.h
@@ -1,5 +1,5 @@
 /* Decomposed printf argument list.
-   Copyright (C) 1999, 2002-2003, 2006-2007, 2011 Free Software
+   Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2012 Free Software
    Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/gl/printf-parse.c b/gl/printf-parse.c
index ff24ba4..d2a58a1 100644
--- a/gl/printf-parse.c
+++ b/gl/printf-parse.c
@@ -1,5 +1,5 @@
 /* Formatted output to strings.
-   Copyright (C) 1999-2000, 2002-2003, 2006-2011 Free Software Foundation, Inc.
+   Copyright (C) 1999-2000, 2002-2003, 2006-2012 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
@@ -421,7 +421,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, 
arguments *a)
                     }
 #endif
 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-                  /* On native Win32, PRIdMAX is defined as "I64d".
+                  /* On native Windows, PRIdMAX is defined as "I64d".
                      We cannot change it to "lld" because PRIdMAX must also
                      be understood by the system's printf routines.  */
                   else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4')
diff --git a/gl/printf-parse.h b/gl/printf-parse.h
index 76e5ba3..3830f3c 100644
--- a/gl/printf-parse.h
+++ b/gl/printf-parse.h
@@ -1,5 +1,5 @@
 /* Parse printf format string.
-   Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2011 Free Software
+   Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2012 Free Software
    Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/gl/progname.c b/gl/progname.c
index 2465748..bdd4dd7 100644
--- a/gl/progname.c
+++ b/gl/progname.c
@@ -1,5 +1,5 @@
 /* Program name management.
-   Copyright (C) 2001-2003, 2005-2011 Free Software Foundation, Inc.
+   Copyright (C) 2001-2003, 2005-2012 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2001.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/gl/progname.h b/gl/progname.h
index 0844066..a75a02e 100644
--- a/gl/progname.h
+++ b/gl/progname.h
@@ -1,5 +1,5 @@
 /* Program name management.
-   Copyright (C) 2001-2004, 2006, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2001-2004, 2006, 2009-2012 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2001.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/gl/quote.c b/gl/quote.c
index 1989c8c..b46fd83 100644
--- a/gl/quote.c
+++ b/gl/quote.c
@@ -1,6 +1,6 @@
 /* quote.c - quote arguments for output
 
-   Copyright (C) 1998-2001, 2003, 2005-2006, 2009-2011 Free Software
+   Copyright (C) 1998-2001, 2003, 2005-2006, 2009-2012 Free Software
    Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/gl/quote.h b/gl/quote.h
index d0acb51..140908b 100644
--- a/gl/quote.h
+++ b/gl/quote.h
@@ -1,6 +1,6 @@
 /* quote.h - prototypes for quote.c
 
-   Copyright (C) 1998-2001, 2003, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 1998-2001, 2003, 2009-2012 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
diff --git a/gl/quotearg.c b/gl/quotearg.c
index da8ba1e..c37aa35 100644
--- a/gl/quotearg.c
+++ b/gl/quotearg.c
@@ -1,6 +1,6 @@
 /* quotearg.c - quote arguments for output
 
-   Copyright (C) 1998-2002, 2004-2011 Free Software Foundation, Inc.
+   Copyright (C) 1998-2002, 2004-2012 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
@@ -17,11 +17,20 @@
 
 /* Written by Paul Eggert <address@hidden> */
 
+/* Without this pragma, gcc 4.7.0 20111124 mistakenly suggests that
+   the quoting_options_from_style function might be candidate for
+   attribute 'pure'  */
+#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
+# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
+#endif
+
 #include <config.h>
 
 #include "quotearg.h"
 
 #include "xalloc.h"
+#include "c-strcaseeq.h"
+#include "localcharset.h"
 
 #include <ctype.h>
 #include <errno.h>
@@ -165,7 +174,7 @@ set_custom_quoting (struct quoting_options *o,
 }
 
 /* Return quoting options for STYLE, with no extra quoting.  */
-static struct quoting_options
+static struct quoting_options /* NOT PURE!! */
 quoting_options_from_style (enum quoting_style style)
 {
   struct quoting_options o = { 0 };
@@ -176,14 +185,43 @@ quoting_options_from_style (enum quoting_style style)
 }
 
 /* MSGID approximates a quotation mark.  Return its translation if it
-   has one; otherwise, return either it or "\"", depending on S.  */
+   has one; otherwise, return either it or "\"", depending on S.
+
+   S is either clocale_quoting_style or locale_quoting_style.  */
 static char const *
 gettext_quote (char const *msgid, enum quoting_style s)
 {
   char const *translation = _(msgid);
-  if (translation == msgid && s == clocale_quoting_style)
-    translation = "\"";
-  return translation;
+  char const *locale_code;
+
+  if (translation != msgid)
+    return translation;
+
+  /* For UTF-8 and GB-18030, use single quotes U+2018 and U+2019.
+     Here is a list of other locales that include U+2018 and U+2019:
+
+        ISO-8859-7   0xA1                 KOI8-T       0x91
+        CP869        0x8B                 CP874        0x91
+        CP932        0x81 0x65            CP936        0xA1 0xAE
+        CP949        0xA1 0xAE            CP950        0xA1 0xA5
+        CP1250       0x91                 CP1251       0x91
+        CP1252       0x91                 CP1253       0x91
+        CP1254       0x91                 CP1255       0x91
+        CP1256       0x91                 CP1257       0x91
+        EUC-JP       0xA1 0xC6            EUC-KR       0xA1 0xAE
+        EUC-TW       0xA1 0xE4            BIG5         0xA1 0xA5
+        BIG5-HKSCS   0xA1 0xA5            EUC-CN       0xA1 0xAE
+        GBK          0xA1 0xAE            Georgian-PS  0x91
+        PT154        0x91
+
+     None of these is still in wide use; using iconv is overkill.  */
+  locale_code = locale_charset ();
+  if (STRCASEEQ (locale_code, "UTF-8", 'U','T','F','-','8',0,0,0,0))
+    return msgid[0] == '`' ? "\xe2\x80\x98": "\xe2\x80\x99";
+  if (STRCASEEQ (locale_code, "GB18030", 'G','B','1','8','0','3','0',0,0))
+    return msgid[0] == '`' ? "\xa1\ae": "\xa1\xaf";
+
+  return (s == clocale_quoting_style ? "\"" : "'");
 }
 
 /* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of
@@ -251,22 +289,24 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
           {
             /* TRANSLATORS:
                Get translations for open and closing quotation marks.
-
                The message catalog should translate "`" to a left
                quotation mark suitable for the locale, and similarly for
-               "'".  If the catalog has no translation,
-               locale_quoting_style quotes `like this', and
-               clocale_quoting_style quotes "like this".
-
-               For example, an American English Unicode locale should
-               translate "`" to U+201C (LEFT DOUBLE QUOTATION MARK), and
-               should translate "'" to U+201D (RIGHT DOUBLE QUOTATION
-               MARK).  A British English Unicode locale should instead
-               translate these to U+2018 (LEFT SINGLE QUOTATION MARK)
-               and U+2019 (RIGHT SINGLE QUOTATION MARK), respectively.
+               "'".  For example, a French Unicode local should translate
+               these to U+00AB (LEFT-POINTING DOUBLE ANGLE
+               QUOTATION MARK), and U+00BB (RIGHT-POINTING DOUBLE ANGLE
+               QUOTATION MARK), respectively.
+
+               If the catalog has no translation, we will try to
+               use Unicode U+2018 (LEFT SINGLE QUOTATION MARK) and
+               Unicode U+2019 (RIGHT SINGLE QUOTATION MARK).  If the
+               current locale is not Unicode, locale_quoting_style
+               will quote 'like this', and clocale_quoting_style will
+               quote "like this".  You should always include translations
+               for "`" and "'" even if U+2018 and U+2019 are appropriate
+               for your locale.
 
                If you don't know what to put here, please see
-               <http://en.wikipedia.org/wiki/Quotation_mark#Glyphs>
+               
<http://en.wikipedia.org/wiki/Quotation_marks_in_other_languages>
                and use glyphs suitable for your language.  */
             left_quote = gettext_quote (N_("`"), quoting_style);
             right_quote = gettext_quote (N_("'"), quoting_style);
@@ -730,7 +770,7 @@ quotearg_n_options (int n, char const *arg, size_t argsize,
 
   if (nslots <= n0)
     {
-      /* FIXME: technically, the type of n1 should be `unsigned int',
+      /* FIXME: technically, the type of n1 should be 'unsigned int',
          but that evokes an unsuppressible warning from gcc-4.0.1 and
          older.  If gcc ever provides an option to suppress that warning,
          revert to the original type, so that the test in xalloc_oversized
diff --git a/gl/quotearg.h b/gl/quotearg.h
index 2756d76..e6b08ab 100644
--- a/gl/quotearg.h
+++ b/gl/quotearg.h
@@ -1,6 +1,6 @@
 /* quotearg.h - quote arguments for output
 
-   Copyright (C) 1998-2002, 2004, 2006, 2008-2011 Free Software Foundation,
+   Copyright (C) 1998-2002, 2004, 2006, 2008-2012 Free Software Foundation,
    Inc.
 
    This program is free software: you can redistribute it and/or modify
@@ -112,8 +112,10 @@ enum quoting_style
     */
     escape_quoting_style,
 
-    /* Like clocale_quoting_style, but quote `like this' instead of
-       "like this" in the default C locale (ls --quoting-style=locale).
+    /* Like clocale_quoting_style, but use single quotes in the
+       default C locale or if the program does not use gettext
+       (ls --quoting-style=locale).  For UTF-8 locales, quote
+       characters will use Unicode.
 
        LC_MESSAGES=C
        quotearg_buffer:
diff --git a/gl/readline.c b/gl/readline.c
index 72a93c3..0adb8e5 100644
--- a/gl/readline.c
+++ b/gl/readline.c
@@ -1,5 +1,5 @@
 /* readline.c --- Simple implementation of readline.
-   Copyright (C) 2005-2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2005-2007, 2009-2012 Free Software Foundation, Inc.
    Written by Simon Josefsson
 
    This program is free software: you can redistribute it and/or modify
diff --git a/gl/readline.h b/gl/readline.h
index ac77b53..ac87b0f 100644
--- a/gl/readline.h
+++ b/gl/readline.h
@@ -1,5 +1,5 @@
 /* readline.h --- Simple implementation of readline.
-   Copyright (C) 2005, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2009-2012 Free Software Foundation, Inc.
    Written by Simon Josefsson
 
    This program is free software: you can redistribute it and/or modify
diff --git a/gl/realloc.c b/gl/realloc.c
index 0c96ffa..99556cc 100644
--- a/gl/realloc.c
+++ b/gl/realloc.c
@@ -1,6 +1,6 @@
 /* realloc() function that is glibc compatible.
 
-   Copyright (C) 1997, 2003-2004, 2006-2007, 2009-2011 Free Software
+   Copyright (C) 1997, 2003-2004, 2006-2007, 2009-2012 Free Software
    Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/gl/recv.c b/gl/recv.c
index d99b7a4..c6e2c00 100644
--- a/gl/recv.c
+++ b/gl/recv.c
@@ -1,6 +1,6 @@
 /* recv.c --- wrappers for Windows recv function
 
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
@@ -32,9 +32,18 @@ ssize_t
 rpl_recv (int fd, void *buf, size_t len, int flags)
 {
   SOCKET sock = FD_TO_SOCKET (fd);
-  int r = recv (sock, buf, len, flags);
-  if (r < 0)
-    set_winsock_errno ();
 
-  return r;
+  if (sock == INVALID_SOCKET)
+    {
+      errno = EBADF;
+      return -1;
+    }
+  else
+    {
+      int r = recv (sock, buf, len, flags);
+      if (r < 0)
+        set_winsock_errno ();
+
+      return r;
+    }
 }
diff --git a/gl/ref-add.sin b/gl/ref-add.sin
index a57eaef..d51d3bb 100644
--- a/gl/ref-add.sin
+++ b/gl/ref-add.sin
@@ -1,6 +1,6 @@
 # Add this package to a list of references stored in a text file.
 #
-#   Copyright (C) 2000, 2009-2011 Free Software Foundation, Inc.
+#   Copyright (C) 2000, 2009-2012 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
diff --git a/gl/ref-del.sin b/gl/ref-del.sin
index e23097d..29543c3 100644
--- a/gl/ref-del.sin
+++ b/gl/ref-del.sin
@@ -1,6 +1,6 @@
 # Remove this package from a list of references stored in a text file.
 #
-#   Copyright (C) 2000, 2009-2011 Free Software Foundation, Inc.
+#   Copyright (C) 2000, 2009-2012 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
diff --git a/gl/select.c b/gl/select.c
index e4fb445..0c821dd 100644
--- a/gl/select.c
+++ b/gl/select.c
@@ -1,7 +1,7 @@
 /* Emulation for select(2)
    Contributed by Paolo Bonzini.
 
-   Copyright 2008-2011 Free Software Foundation, Inc.
+   Copyright 2008-2012 Free Software Foundation, Inc.
 
    This file is part of gnulib.
 
@@ -24,10 +24,9 @@
 #include <assert.h>
 
 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-/* Native Win32.  */
+/* Native Windows.  */
 
 #include <sys/types.h>
-#include <stdbool.h>
 #include <errno.h>
 #include <limits.h>
 
@@ -38,6 +37,13 @@
 #include <conio.h>
 #include <time.h>
 
+/* Get the overridden 'struct timeval'.  */
+#include <sys/time.h>
+
+#include "msvc-nothrow.h"
+
+#undef select
+
 struct bitset {
   unsigned char in[FD_SETSIZE / CHAR_BIT];
   unsigned char out[FD_SETSIZE / CHAR_BIT];
@@ -77,7 +83,9 @@ typedef DWORD (WINAPI *PNtQueryInformationFile)
 #define PIPE_BUF        512
 #endif
 
-#define IsConsoleHandle(h) (((long) (h) & 3) == 3)
+/* Optimized test whether a HANDLE refers to a console.
+   See <http://lists.gnu.org/archive/html/bug-gnulib/2009-08/msg00065.html>.  
*/
+#define IsConsoleHandle(h) (((intptr_t) (h) & 3) == 3)
 
 static BOOL
 IsSocketHandle (HANDLE h)
@@ -94,11 +102,14 @@ IsSocketHandle (HANDLE h)
   return ev.lNetworkEvents != 0xDEADBEEF;
 }
 
-/* Compute output fd_sets for libc descriptor FD (whose Win32 handle is H).  */
+/* Compute output fd_sets for libc descriptor FD (whose Windows handle is
+   H).  */
 
 static int
-win32_poll_handle (HANDLE h, int fd, struct bitset *rbits, struct bitset 
*wbits,
-                   struct bitset *xbits)
+windows_poll_handle (HANDLE h, int fd,
+                     struct bitset *rbits,
+                     struct bitset *wbits,
+                     struct bitset *xbits)
 {
   BOOL read, write, except;
   int i, ret;
@@ -139,11 +150,12 @@ win32_poll_handle (HANDLE h, int fd, struct bitset 
*rbits, struct bitset *wbits,
         {
           /* It was the write-end of the pipe.  Check if it is writable.
              If NtQueryInformationFile fails, optimistically assume the pipe is
-             writable.  This could happen on Win9x, where 
NtQueryInformationFile
-             is not available, or if we inherit a pipe that doesn't permit
-             FILE_READ_ATTRIBUTES access on the write end (I think this should
-             not happen since WinXP SP2; WINE seems fine too).  Otherwise,
-             ensure that enough space is available for atomic writes.  */
+             writable.  This could happen on Windows 9x, where
+             NtQueryInformationFile is not available, or if we inherit a pipe
+             that doesn't permit FILE_READ_ATTRIBUTES access on the write end
+             (I think this should not happen since Windows XP SP2; WINE seems
+             fine too).  Otherwise, ensure that enough space is available for
+             atomic writes.  */
           memset (&iosb, 0, sizeof (iosb));
           memset (&fpli, 0, sizeof (fpli));
 
@@ -230,6 +242,7 @@ win32_poll_handle (HANDLE h, int fd, struct bitset *rbits, 
struct bitset *wbits,
 int
 rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds,
             struct timeval *timeout)
+#undef timeval
 {
   static struct timeval tv0;
   static HANDLE hEvent;
@@ -368,7 +381,7 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set 
*xfds,
 
           /* Poll now.  If we get an event, do not wait below.  */
           if (wait_timeout != 0
-              && win32_poll_handle (h, i, &rbits, &wbits, &xbits))
+              && windows_poll_handle (h, i, &rbits, &wbits, &xbits))
             wait_timeout = 0;
         }
     }
@@ -445,7 +458,7 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set 
*xfds,
         {
           /* Not a socket.  */
           nhandles++;
-          win32_poll_handle (h, i, &rbits, &wbits, &xbits);
+          windows_poll_handle (h, i, &rbits, &wbits, &xbits);
           if (rbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
             {
               rc++;
@@ -467,7 +480,7 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set 
*xfds,
   return rc;
 }
 
-#else /* ! Native Win32.  */
+#else /* ! Native Windows.  */
 
 #include <sys/select.h>
 
diff --git a/gl/shutdown.c b/gl/shutdown.c
index 26c4932..ea19421 100644
--- a/gl/shutdown.c
+++ b/gl/shutdown.c
@@ -1,6 +1,6 @@
 /* shutdown.c --- wrappers for Windows shutdown function
 
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
@@ -32,9 +32,18 @@ int
 rpl_shutdown (int fd, int how)
 {
   SOCKET sock = FD_TO_SOCKET (fd);
-  int r = shutdown (sock, how);
-  if (r < 0)
-    set_winsock_errno ();
 
-  return r;
+  if (sock == INVALID_SOCKET)
+    {
+      errno = EBADF;
+      return -1;
+    }
+  else
+    {
+      int r = shutdown (sock, how);
+      if (r < 0)
+        set_winsock_errno ();
+
+      return r;
+    }
 }
diff --git a/gl/signal.in.h b/gl/signal.in.h
new file mode 100644
index 0000000..e0f0554
--- /dev/null
+++ b/gl/signal.in.h
@@ -0,0 +1,447 @@
+/* A GNU-like <signal.h>.
+
+   Copyright (C) 2006-2012 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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#if __GNUC__ >= 3
address@hidden@
+#endif
address@hidden@
+
+#if defined __need_sig_atomic_t || defined __need_sigset_t || defined 
_GL_ALREADY_INCLUDING_SIGNAL_H || (defined _SIGNAL_H && !defined 
__SIZEOF_PTHREAD_MUTEX_T)
+/* Special invocation convention:
+   - Inside glibc header files.
+   - On glibc systems we have a sequence of nested includes
+     <signal.h> -> <ucontext.h> -> <signal.h>.
+     In this situation, the functions are not yet declared, therefore we cannot
+     provide the C++ aliases.
+   - On glibc systems with GCC 4.3 we have a sequence of nested includes
+     <csignal> -> </usr/include/signal.h> -> <sys/ucontext.h> -> <signal.h>.
+     In this situation, some of the functions are not yet declared, therefore
+     we cannot provide the C++ aliases.  */
+
+# @INCLUDE_NEXT@ @NEXT_SIGNAL_H@
+
+#else
+/* Normal invocation convention.  */
+
+#ifndef address@hidden@_SIGNAL_H
+
+#define _GL_ALREADY_INCLUDING_SIGNAL_H
+
+/* Define pid_t, uid_t.
+   Also, mingw defines sigset_t not in <signal.h>, but in <sys/types.h>.
+   On Solaris 10, <signal.h> includes <sys/types.h>, which eventually includes
+   us; so include <sys/types.h> now, before the second inclusion guard.  */
+#include <sys/types.h>
+
+/* The include_next requires a split double-inclusion guard.  */
address@hidden@ @NEXT_SIGNAL_H@
+
+#undef _GL_ALREADY_INCLUDING_SIGNAL_H
+
+#ifndef address@hidden@_SIGNAL_H
+#define address@hidden@_SIGNAL_H
+
+/* MacOS X 10.3, FreeBSD 6.4, OpenBSD 3.8, OSF/1 4.0, Solaris 2.6 declare
+   pthread_sigmask in <pthread.h>, not in <signal.h>.
+   But avoid namespace pollution on glibc systems.*/
+#if (@GNULIB_PTHREAD_SIGMASK@ || defined GNULIB_POSIXCHECK) \
+    && ((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || 
defined __OpenBSD__ || defined __osf__ || defined __sun) \
+    && ! defined __GLIBC__
+# include <pthread.h>
+#endif
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
+/* On AIX, sig_atomic_t already includes volatile.  C99 requires that
+   'volatile sig_atomic_t' ignore the extra modifier, but C89 did not.
+   Hence, redefine this to a non-volatile type as needed.  */
+#if ! @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@
+# if !GNULIB_defined_sig_atomic_t
+typedef int rpl_sig_atomic_t;
+#  undef sig_atomic_t
+#  define sig_atomic_t rpl_sig_atomic_t
+#  define GNULIB_defined_sig_atomic_t 1
+# endif
+#endif
+
+/* A set or mask of signals.  */
+#if address@hidden@
+# if !GNULIB_defined_sigset_t
+typedef unsigned int sigset_t;
+#  define GNULIB_defined_sigset_t 1
+# endif
+#endif
+
+/* Define sighandler_t, the type of signal handlers.  A GNU extension.  */
+#if address@hidden@
+# ifdef __cplusplus
+extern "C" {
+# endif
+# if !GNULIB_defined_sighandler_t
+typedef void (*sighandler_t) (int);
+#  define GNULIB_defined_sighandler_t 1
+# endif
+# ifdef __cplusplus
+}
+# endif
+#endif
+
+
+#if @GNULIB_SIGNAL_H_SIGPIPE@
+# ifndef SIGPIPE
+/* Define SIGPIPE to a value that does not overlap with other signals.  */
+#  define SIGPIPE 13
+#  define GNULIB_defined_SIGPIPE 1
+/* To actually use SIGPIPE, you also need the gnulib modules 'sigprocmask',
+   'write', 'stdio'.  */
+# endif
+#endif
+
+
+/* Maximum signal number + 1.  */
+#ifndef NSIG
+# if defined __TANDEM
+#  define NSIG 32
+# endif
+#endif
+
+
+#if @GNULIB_PTHREAD_SIGMASK@
+# if @REPLACE_PTHREAD_SIGMASK@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef pthread_sigmask
+#   define pthread_sigmask rpl_pthread_sigmask
+#  endif
+_GL_FUNCDECL_RPL (pthread_sigmask, int,
+                  (int how, const sigset_t *new_mask, sigset_t *old_mask));
+_GL_CXXALIAS_RPL (pthread_sigmask, int,
+                  (int how, const sigset_t *new_mask, sigset_t *old_mask));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (pthread_sigmask, int,
+                  (int how, const sigset_t *new_mask, sigset_t *old_mask));
+#  endif
+_GL_CXXALIAS_SYS (pthread_sigmask, int,
+                  (int how, const sigset_t *new_mask, sigset_t *old_mask));
+# endif
+_GL_CXXALIASWARN (pthread_sigmask);
+#elif defined GNULIB_POSIXCHECK
+# undef pthread_sigmask
+# if HAVE_RAW_DECL_PTHREAD_SIGMASK
+_GL_WARN_ON_USE (pthread_sigmask, "pthread_sigmask is not portable - "
+                 "use gnulib module pthread_sigmask for portability");
+# endif
+#endif
+
+
+#if @GNULIB_RAISE@
+# if @REPLACE_RAISE@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef raise
+#   define raise rpl_raise
+#  endif
+_GL_FUNCDECL_RPL (raise, int, (int sig));
+_GL_CXXALIAS_RPL (raise, int, (int sig));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (raise, int, (int sig));
+#  endif
+_GL_CXXALIAS_SYS (raise, int, (int sig));
+# endif
+_GL_CXXALIASWARN (raise);
+#elif defined GNULIB_POSIXCHECK
+# undef raise
+/* Assume raise is always declared.  */
+_GL_WARN_ON_USE (raise, "raise can crash on native Windows - "
+                 "use gnulib module raise for portability");
+#endif
+
+
+#if @GNULIB_SIGPROCMASK@
+# if address@hidden@
+
+#  ifndef GNULIB_defined_signal_blocking
+#   define GNULIB_defined_signal_blocking 1
+#  endif
+
+/* Maximum signal number + 1.  */
+#  ifndef NSIG
+#   define NSIG 32
+#  endif
+
+/* This code supports only 32 signals.  */
+#  if !GNULIB_defined_verify_NSIG_constraint
+typedef int verify_NSIG_constraint[NSIG <= 32 ? 1 : -1];
+#   define GNULIB_defined_verify_NSIG_constraint 1
+#  endif
+
+# endif
+
+/* Test whether a given signal is contained in a signal set.  */
+# if @HAVE_POSIX_SIGNALBLOCKING@
+/* This function is defined as a macro on MacOS X.  */
+#  if defined __cplusplus && defined GNULIB_NAMESPACE
+#   undef sigismember
+#  endif
+# else
+_GL_FUNCDECL_SYS (sigismember, int, (const sigset_t *set, int sig)
+                                    _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (sigismember, int, (const sigset_t *set, int sig));
+_GL_CXXALIASWARN (sigismember);
+
+/* Initialize a signal set to the empty set.  */
+# if @HAVE_POSIX_SIGNALBLOCKING@
+/* This function is defined as a macro on MacOS X.  */
+#  if defined __cplusplus && defined GNULIB_NAMESPACE
+#   undef sigemptyset
+#  endif
+# else
+_GL_FUNCDECL_SYS (sigemptyset, int, (sigset_t *set) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (sigemptyset, int, (sigset_t *set));
+_GL_CXXALIASWARN (sigemptyset);
+
+/* Add a signal to a signal set.  */
+# if @HAVE_POSIX_SIGNALBLOCKING@
+/* This function is defined as a macro on MacOS X.  */
+#  if defined __cplusplus && defined GNULIB_NAMESPACE
+#   undef sigaddset
+#  endif
+# else
+_GL_FUNCDECL_SYS (sigaddset, int, (sigset_t *set, int sig)
+                                  _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (sigaddset, int, (sigset_t *set, int sig));
+_GL_CXXALIASWARN (sigaddset);
+
+/* Remove a signal from a signal set.  */
+# if @HAVE_POSIX_SIGNALBLOCKING@
+/* This function is defined as a macro on MacOS X.  */
+#  if defined __cplusplus && defined GNULIB_NAMESPACE
+#   undef sigdelset
+#  endif
+# else
+_GL_FUNCDECL_SYS (sigdelset, int, (sigset_t *set, int sig)
+                                  _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (sigdelset, int, (sigset_t *set, int sig));
+_GL_CXXALIASWARN (sigdelset);
+
+/* Fill a signal set with all possible signals.  */
+# if @HAVE_POSIX_SIGNALBLOCKING@
+/* This function is defined as a macro on MacOS X.  */
+#  if defined __cplusplus && defined GNULIB_NAMESPACE
+#   undef sigfillset
+#  endif
+# else
+_GL_FUNCDECL_SYS (sigfillset, int, (sigset_t *set) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (sigfillset, int, (sigset_t *set));
+_GL_CXXALIASWARN (sigfillset);
+
+/* Return the set of those blocked signals that are pending.  */
+# if address@hidden@
+_GL_FUNCDECL_SYS (sigpending, int, (sigset_t *set) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (sigpending, int, (sigset_t *set));
+_GL_CXXALIASWARN (sigpending);
+
+/* If OLD_SET is not NULL, put the current set of blocked signals in *OLD_SET.
+   Then, if SET is not NULL, affect the current set of blocked signals by
+   combining it with *SET as indicated in OPERATION.
+   In this implementation, you are not allowed to change a signal handler
+   while the signal is blocked.  */
+# if address@hidden@
+#  define SIG_BLOCK   0  /* blocked_set = blocked_set | *set; */
+#  define SIG_SETMASK 1  /* blocked_set = *set; */
+#  define SIG_UNBLOCK 2  /* blocked_set = blocked_set & ~*set; */
+_GL_FUNCDECL_SYS (sigprocmask, int,
+                  (int operation, const sigset_t *set, sigset_t *old_set));
+# endif
+_GL_CXXALIAS_SYS (sigprocmask, int,
+                  (int operation, const sigset_t *set, sigset_t *old_set));
+_GL_CXXALIASWARN (sigprocmask);
+
+/* Install the handler FUNC for signal SIG, and return the previous
+   handler.  */
+# ifdef __cplusplus
+extern "C" {
+# endif
+# if !GNULIB_defined_function_taking_int_returning_void_t
+typedef void (*_gl_function_taking_int_returning_void_t) (int);
+#  define GNULIB_defined_function_taking_int_returning_void_t 1
+# endif
+# ifdef __cplusplus
+}
+# endif
+# if address@hidden@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define signal rpl_signal
+#  endif
+_GL_FUNCDECL_RPL (signal, _gl_function_taking_int_returning_void_t,
+                  (int sig, _gl_function_taking_int_returning_void_t func));
+_GL_CXXALIAS_RPL (signal, _gl_function_taking_int_returning_void_t,
+                  (int sig, _gl_function_taking_int_returning_void_t func));
+# else
+_GL_CXXALIAS_SYS (signal, _gl_function_taking_int_returning_void_t,
+                  (int sig, _gl_function_taking_int_returning_void_t func));
+# endif
+_GL_CXXALIASWARN (signal);
+
+# if address@hidden@ && GNULIB_defined_SIGPIPE
+/* Raise signal SIGPIPE.  */
+_GL_EXTERN_C int _gl_raise_SIGPIPE (void);
+# endif
+
+#elif defined GNULIB_POSIXCHECK
+# undef sigaddset
+# if HAVE_RAW_DECL_SIGADDSET
+_GL_WARN_ON_USE (sigaddset, "sigaddset is unportable - "
+                 "use the gnulib module sigprocmask for portability");
+# endif
+# undef sigdelset
+# if HAVE_RAW_DECL_SIGDELSET
+_GL_WARN_ON_USE (sigdelset, "sigdelset is unportable - "
+                 "use the gnulib module sigprocmask for portability");
+# endif
+# undef sigemptyset
+# if HAVE_RAW_DECL_SIGEMPTYSET
+_GL_WARN_ON_USE (sigemptyset, "sigemptyset is unportable - "
+                 "use the gnulib module sigprocmask for portability");
+# endif
+# undef sigfillset
+# if HAVE_RAW_DECL_SIGFILLSET
+_GL_WARN_ON_USE (sigfillset, "sigfillset is unportable - "
+                 "use the gnulib module sigprocmask for portability");
+# endif
+# undef sigismember
+# if HAVE_RAW_DECL_SIGISMEMBER
+_GL_WARN_ON_USE (sigismember, "sigismember is unportable - "
+                 "use the gnulib module sigprocmask for portability");
+# endif
+# undef sigpending
+# if HAVE_RAW_DECL_SIGPENDING
+_GL_WARN_ON_USE (sigpending, "sigpending is unportable - "
+                 "use the gnulib module sigprocmask for portability");
+# endif
+# undef sigprocmask
+# if HAVE_RAW_DECL_SIGPROCMASK
+_GL_WARN_ON_USE (sigprocmask, "sigprocmask is unportable - "
+                 "use the gnulib module sigprocmask for portability");
+# endif
+#endif /* @GNULIB_SIGPROCMASK@ */
+
+
+#if @GNULIB_SIGACTION@
+# if address@hidden@
+
+#  if address@hidden@
+
+#   if !GNULIB_defined_siginfo_types
+
+/* Present to allow compilation, but unsupported by gnulib.  */
+union sigval
+{
+  int sival_int;
+  void *sival_ptr;
+};
+
+/* Present to allow compilation, but unsupported by gnulib.  */
+struct siginfo_t
+{
+  int si_signo;
+  int si_code;
+  int si_errno;
+  pid_t si_pid;
+  uid_t si_uid;
+  void *si_addr;
+  int si_status;
+  long si_band;
+  union sigval si_value;
+};
+typedef struct siginfo_t siginfo_t;
+
+#    define GNULIB_defined_siginfo_types 1
+#   endif
+
+#  endif /* address@hidden@ */
+
+/* We assume that platforms which lack the sigaction() function also lack
+   the 'struct sigaction' type, and vice versa.  */
+
+#  if !GNULIB_defined_struct_sigaction
+
+struct sigaction
+{
+  union
+  {
+    void (*_sa_handler) (int);
+    /* Present to allow compilation, but unsupported by gnulib.  POSIX
+       says that implementations may, but not must, make sa_sigaction
+       overlap with sa_handler, but we know of no implementation where
+       they do not overlap.  */
+    void (*_sa_sigaction) (int, siginfo_t *, void *);
+  } _sa_func;
+  sigset_t sa_mask;
+  /* Not all POSIX flags are supported.  */
+  int sa_flags;
+};
+#   define sa_handler _sa_func._sa_handler
+#   define sa_sigaction _sa_func._sa_sigaction
+/* Unsupported flags are not present.  */
+#   define SA_RESETHAND 1
+#   define SA_NODEFER 2
+#   define SA_RESTART 4
+
+#   define GNULIB_defined_struct_sigaction 1
+#  endif
+
+_GL_FUNCDECL_SYS (sigaction, int, (int, const struct sigaction *restrict,
+                                   struct sigaction *restrict));
+
+# elif address@hidden@
+
+#  define sa_sigaction sa_handler
+
+# endif /* address@hidden@, address@hidden@ */
+
+_GL_CXXALIAS_SYS (sigaction, int, (int, const struct sigaction *restrict,
+                                   struct sigaction *restrict));
+_GL_CXXALIASWARN (sigaction);
+
+#elif defined GNULIB_POSIXCHECK
+# undef sigaction
+# if HAVE_RAW_DECL_SIGACTION
+_GL_WARN_ON_USE (sigaction, "sigaction is unportable - "
+                 "use the gnulib module sigaction for portability");
+# endif
+#endif
+
+/* Some systems don't have SA_NODEFER.  */
+#ifndef SA_NODEFER
+# define SA_NODEFER 0
+#endif
+
+
+#endif /* address@hidden@_SIGNAL_H */
+#endif /* address@hidden@_SIGNAL_H */
+#endif
diff --git a/gl/size_max.h b/gl/size_max.h
index d5f3152..e669bf1 100644
--- a/gl/size_max.h
+++ b/gl/size_max.h
@@ -1,5 +1,5 @@
 /* size_max.h -- declare SIZE_MAX through system headers
-   Copyright (C) 2005-2006, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2005-2006, 2009-2012 Free Software Foundation, Inc.
    Written by Simon Josefsson.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/gl/snprintf.c b/gl/snprintf.c
index 9db2379..bb01880 100644
--- a/gl/snprintf.c
+++ b/gl/snprintf.c
@@ -1,5 +1,5 @@
 /* Formatted output to strings.
-   Copyright (C) 2004, 2006-2011 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2006-2012 Free Software Foundation, Inc.
    Written by Simon Josefsson and Paul Eggert.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/gl/socket.c b/gl/socket.c
index af6be25..c668df0 100644
--- a/gl/socket.c
+++ b/gl/socket.c
@@ -1,6 +1,6 @@
 /* socket.c --- wrappers for Windows socket function
 
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
diff --git a/gl/sockets.c b/gl/sockets.c
index 53cb66e..3daec45 100644
--- a/gl/sockets.c
+++ b/gl/sockets.c
@@ -1,6 +1,6 @@
 /* sockets.c --- wrappers for Windows socket functions
 
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
@@ -28,6 +28,7 @@
 # include <sys/socket.h>
 
 # include "fd-hook.h"
+# include "msvc-nothrow.h"
 
 /* Get set_winsock_errno, FD_TO_SOCKET etc. */
 # include "w32sock.h"
diff --git a/gl/sockets.h b/gl/sockets.h
index 93ae5d2..2efa413 100644
--- a/gl/sockets.h
+++ b/gl/sockets.h
@@ -1,6 +1,6 @@
 /* sockets.h - wrappers for Windows socket functions
 
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
@@ -26,8 +26,17 @@
 #define SOCKETS_2_1 0x201
 #define SOCKETS_2_2 0x202
 
-int gl_sockets_startup (int version);
-int gl_sockets_cleanup (void);
+int gl_sockets_startup (int version)
+#if !WINDOWS_SOCKETS
+  _GL_ATTRIBUTE_CONST
+#endif
+  ;
+
+int gl_sockets_cleanup (void)
+#if !WINDOWS_SOCKETS
+  _GL_ATTRIBUTE_CONST
+#endif
+  ;
 
 /* This function is useful it you create a socket using gnulib's
    Winsock wrappers but needs to pass on the socket handle to some
@@ -36,6 +45,8 @@ int gl_sockets_cleanup (void);
 
 #include <sys/socket.h>
 
+#include "msvc-nothrow.h"
+
 static inline SOCKET
 gl_fd_to_handle (int fd)
 {
diff --git a/gl/stdalign.in.h b/gl/stdalign.in.h
new file mode 100644
index 0000000..ae8d5b9
--- /dev/null
+++ b/gl/stdalign.in.h
@@ -0,0 +1,91 @@
+/* A substitute for ISO C11 <stdalign.h>.
+
+   Copyright 2011-2012 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
+   the Free Software Foundation; either version 3, 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 General Public License for more details.
+
+   You should have received a copy of the GNU 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 Paul Eggert and Bruno Haible.  */
+
+#ifndef _GL_STDALIGN_H
+#define _GL_STDALIGN_H
+
+/* ISO C11 <stdalign.h> for platforms that lack it.
+
+   References:
+   ISO C11 (latest free draft
+   <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf>)
+   sections 6.5.3.4, 6.7.5, 7.15.
+   C++11 (latest free draft
+   <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf>)
+   section 18.10. */
+
+/* alignof (TYPE), also known as _Alignof (TYPE), yields the alignment
+   requirement of a structure member (i.e., slot or field) that is of
+   type TYPE, as an integer constant expression.
+
+   This differs from GCC's __alignof__ operator, which can yield a
+   better-performing alignment for an object of that type.  For
+   example, on x86 with GCC, __alignof__ (double) and __alignof__
+   (long long) are 8, whereas alignof (double) and alignof (long long)
+   are 4 unless the option '-malign-double' is used.
+
+   The result cannot be used as a value for an 'enum' constant, if you
+   want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc.  */
+#include <stddef.h>
+#if defined __cplusplus
+   template <class __t> struct __alignof_helper { char __a; __t __b; };
+# define _Alignof(type) offsetof (__alignof_helper<type>, __b)
+#else
+# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b)
+#endif
+#define alignof _Alignof
+#define __alignof_is_defined 1
+
+/* alignas (A), also known as _Alignas (A), aligns a variable or type
+   to the alignment A, where A is an integer constant expression.  For
+   example:
+
+      int alignas (8) foo;
+      struct s { int a; int alignas (8) bar; };
+
+   aligns the address of FOO and the offset of BAR to be multiples of 8.
+
+   A should be a power of two that is at least the type's alignment
+   and at most the implementation's alignment limit.  This limit is
+   2**28 on typical GNUish hosts, and 2**13 on MSVC.  To be portable
+   to MSVC through at least version 10.0, A should be an integer
+   constant, as MSVC does not support expressions such as 1 << 3.
+   To be portable to Sun C 5.11, do not align auto variables to
+   anything stricter than their default alignment.
+
+   The following C11 requirements are not supported here:
+
+     - If A is zero, alignas has no effect.
+     - alignas can be used multiple times; the strictest one wins.
+     - alignas (TYPE) is equivalent to alignas (alignof (TYPE)).
+
+   */
+
+#if __GNUC__ || __IBMC__ || __IBMCPP__ || 0x5110 <= __SUNPRO_C
+# define _Alignas(a) __attribute__ ((__aligned__ (a)))
+#elif 1300 <= _MSC_VER
+# define _Alignas(a) __declspec (align (a))
+#endif
+#ifdef _Alignas
+# define alignas _Alignas
+# define __alignas_is_defined 1
+#endif
+
+#endif /* _GL_STDALIGN_H */
diff --git a/gl/stdarg.in.h b/gl/stdarg.in.h
index 43f9607..3e0e43f 100644
--- a/gl/stdarg.in.h
+++ b/gl/stdarg.in.h
@@ -1,5 +1,5 @@
 /* Substitute for and wrapper around <stdarg.h>.
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
diff --git a/gl/stdbool.in.h b/gl/stdbool.in.h
index b64dc75..cabe4b8 100644
--- a/gl/stdbool.in.h
+++ b/gl/stdbool.in.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2003, 2006-2011 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2003, 2006-2012 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2001.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/gl/stddef.in.h b/gl/stddef.in.h
index c7b98e7..65e1775 100644
--- a/gl/stddef.in.h
+++ b/gl/stddef.in.h
@@ -1,6 +1,6 @@
 /* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
 
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 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
diff --git a/gl/stdint.in.h b/gl/stdint.in.h
index 09ac138..67df6d9 100644
--- a/gl/stdint.in.h
+++ b/gl/stdint.in.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2002, 2004-2011 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2002, 2004-2012 Free Software Foundation, Inc.
    Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
    This file is part of gnulib.
 
@@ -34,6 +34,16 @@
    <inttypes.h>.  */
 #define _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
 
+/* On Android (Bionic libc), <sys/types.h> includes this file before
+   having defined 'time_t'.  Therefore in this case avoid including
+   other system header files; just include the system's <stdint.h>.
+   Ideally we should test __BIONIC__ here, but it is only defined after
+   <sys/cdefs.h> has been included; hence test __ANDROID__ instead.  */
+#if defined __ANDROID__ \
+    && defined _SYS_TYPES_H_ && !defined _SSIZE_T_DEFINED_
+# @INCLUDE_NEXT@ @NEXT_STDINT_H@
+#else
+
 /* Get those types that are already defined in other system include
    files, so that we can "#define int8_t signed char" below without
    worrying about a later system include file containing a "typedef
@@ -49,6 +59,17 @@
       diagnostics.  */
 #  define __STDINT_H__
 # endif
+
+  /* Some pre-C++11 <stdint.h> implementations need this.  */
+# ifdef __cplusplus
+#  ifndef __STDC_CONSTANT_MACROS
+#   define __STDC_CONSTANT_MACROS 1
+#  endif
+#  ifndef __STDC_LIMIT_MACROS
+#   define __STDC_LIMIT_MACROS 1
+#  endif
+# endif
+
   /* Other systems may have an incomplete or buggy <stdint.h>.
      Include it before <inttypes.h>, since any "#include <stdint.h>"
      in <inttypes.h> would reinclude us, skipping our contents because
@@ -270,26 +291,36 @@ typedef unsigned long int gl_uintptr_t;
 /* Note: These types are compiler dependent. It may be unwise to use them in
    public header files. */
 
-#undef intmax_t
-#if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
+/* If the system defines INTMAX_MAX, assume that intmax_t works, and
+   similarly for UINTMAX_MAX and uintmax_t.  This avoids problems with
+   assuming one type where another is used by the system.  */
+
+#ifndef INTMAX_MAX
+# undef INTMAX_C
+# undef intmax_t
+# if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
 typedef long long int gl_intmax_t;
-# define intmax_t gl_intmax_t
-#elif defined GL_INT64_T
-# define intmax_t int64_t
-#else
+#  define intmax_t gl_intmax_t
+# elif defined GL_INT64_T
+#  define intmax_t int64_t
+# else
 typedef long int gl_intmax_t;
-# define intmax_t gl_intmax_t
+#  define intmax_t gl_intmax_t
+# endif
 #endif
 
-#undef uintmax_t
-#if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
+#ifndef UINTMAX_MAX
+# undef UINTMAX_C
+# undef uintmax_t
+# if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
 typedef unsigned long long int gl_uintmax_t;
-# define uintmax_t gl_uintmax_t
-#elif defined GL_UINT64_T
-# define uintmax_t uint64_t
-#else
+#  define uintmax_t gl_uintmax_t
+# elif defined GL_UINT64_T
+#  define uintmax_t uint64_t
+# else
 typedef unsigned long int gl_uintmax_t;
-# define uintmax_t gl_uintmax_t
+#  define uintmax_t gl_uintmax_t
+# endif
 #endif
 
 /* Verify that intmax_t and uintmax_t have the same size.  Too much code
@@ -303,8 +334,6 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof 
(uintmax_t)
 
 /* 7.18.2. Limits of specified-width integer types */
 
-#if ! defined __cplusplus || defined __STDC_LIMIT_MACROS
-
 /* 7.18.2.1. Limits of exact-width integer types */
 
 /* Here we assume a standard architecture where the hardware integer
@@ -431,21 +460,23 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == 
sizeof (uintmax_t)
 
 /* 7.18.2.5. Limits of greatest-width integer types */
 
-#undef INTMAX_MIN
-#undef INTMAX_MAX
-#ifdef INT64_MAX
-# define INTMAX_MIN  INT64_MIN
-# define INTMAX_MAX  INT64_MAX
-#else
-# define INTMAX_MIN  INT32_MIN
-# define INTMAX_MAX  INT32_MAX
+#ifndef INTMAX_MAX
+# undef INTMAX_MIN
+# ifdef INT64_MAX
+#  define INTMAX_MIN  INT64_MIN
+#  define INTMAX_MAX  INT64_MAX
+# else
+#  define INTMAX_MIN  INT32_MIN
+#  define INTMAX_MAX  INT32_MAX
+# endif
 #endif
 
-#undef UINTMAX_MAX
-#ifdef UINT64_MAX
-# define UINTMAX_MAX  UINT64_MAX
-#else
-# define UINTMAX_MAX  UINT32_MAX
+#ifndef UINTMAX_MAX
+# ifdef UINT64_MAX
+#  define UINTMAX_MAX  UINT64_MAX
+# else
+#  define UINTMAX_MAX  UINT32_MAX
+# endif
 #endif
 
 /* 7.18.3. Limits of other integer types */
@@ -522,12 +553,8 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == 
sizeof (uintmax_t)
 #define WINT_MAX  \
    _STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, address@hidden@)
 
-#endif /* !defined __cplusplus || defined __STDC_LIMIT_MACROS */
-
 /* 7.18.4. Macros for integer constants */
 
-#if ! defined __cplusplus || defined __STDC_CONSTANT_MACROS
-
 /* 7.18.4.1. Macros for minimum-width integer constants */
 /* According to ISO C 99 Technical Corrigendum 1 */
 
@@ -568,25 +595,26 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == 
sizeof (uintmax_t)
 
 /* 7.18.4.2. Macros for greatest-width integer constants */
 
-#undef INTMAX_C
-#if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
-# define INTMAX_C(x)   x##LL
-#elif defined GL_INT64_T
-# define INTMAX_C(x)   INT64_C(x)
-#else
-# define INTMAX_C(x)   x##L
+#ifndef INTMAX_C
+# if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
+#  define INTMAX_C(x)   x##LL
+# elif defined GL_INT64_T
+#  define INTMAX_C(x)   INT64_C(x)
+# else
+#  define INTMAX_C(x)   x##L
+# endif
 #endif
 
-#undef UINTMAX_C
-#if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
-# define UINTMAX_C(x)  x##ULL
-#elif defined GL_UINT64_T
-# define UINTMAX_C(x)  UINT64_C(x)
-#else
-# define UINTMAX_C(x)  x##UL
+#ifndef UINTMAX_C
+# if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
+#  define UINTMAX_C(x)  x##ULL
+# elif defined GL_UINT64_T
+#  define UINTMAX_C(x)  UINT64_C(x)
+# else
+#  define UINTMAX_C(x)  x##UL
+# endif
 #endif
 
-#endif /* !defined __cplusplus || defined __STDC_CONSTANT_MACROS */
-
 #endif /* address@hidden@_STDINT_H */
+#endif /* !(defined __ANDROID__ && ...) */
 #endif /* !defined address@hidden@_STDINT_H && !defined 
_GL_JUST_INCLUDE_SYSTEM_STDINT_H */
diff --git a/gl/stdio-impl.h b/gl/stdio-impl.h
index d41c32f..4935795 100644
--- a/gl/stdio-impl.h
+++ b/gl/stdio-impl.h
@@ -1,5 +1,5 @@
 /* Implementation details of FILE streams.
-   Copyright (C) 2007-2008, 2010-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2008, 2010-2012 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
@@ -26,6 +26,8 @@
 # include <sys/param.h>
 #endif
 
+#include <errno.h>                             /* For detecting Plan9.  */
+
 #if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, 
DragonFly, MacOS X, Cygwin */
 
 # if defined __DragonFly__          /* DragonFly */
diff --git a/gl/stdio.in.h b/gl/stdio.in.h
index 473c84c..06d9780 100644
--- a/gl/stdio.in.h
+++ b/gl/stdio.in.h
@@ -1,6 +1,6 @@
 /* A GNU-like <stdio.h>.
 
-   Copyright (C) 2004, 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2007-2012 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
@@ -170,6 +170,26 @@ _GL_WARN_ON_USE (fclose, "fclose is not always POSIX 
compliant - "
                  "use gnulib module fclose for portable POSIX compliance");
 #endif
 
+#if @GNULIB_FDOPEN@
+# if @REPLACE_FDOPEN@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef fdopen
+#   define fdopen rpl_fdopen
+#  endif
+_GL_FUNCDECL_RPL (fdopen, FILE *, (int fd, const char *mode)
+                                  _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode));
+# else
+_GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
+# endif
+_GL_CXXALIASWARN (fdopen);
+#elif defined GNULIB_POSIXCHECK
+# undef fdopen
+/* Assume fdopen is always declared.  */
+_GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX 
compliant - "
+                 "use gnulib module fdopen for portability");
+#endif
+
 #if @GNULIB_FFLUSH@
 /* Flush all pending data on STREAM according to POSIX rules.  Both
    output and seekable input streams are supported.
@@ -239,7 +259,7 @@ _GL_CXXALIASWARN (fopen);
 #elif defined GNULIB_POSIXCHECK
 # undef fopen
 /* Assume fopen is always declared.  */
-_GL_WARN_ON_USE (fopen, "fopen on Win32 platforms is not POSIX compatible - "
+_GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX 
compliant - "
                  "use gnulib module fopen for portability");
 #endif
 
@@ -367,7 +387,7 @@ _GL_CXXALIASWARN (freopen);
 # undef freopen
 /* Assume freopen is always declared.  */
 _GL_WARN_ON_USE (freopen,
-                 "freopen on Win32 platforms is not POSIX compatible - "
+                 "freopen on native Windows platforms is not POSIX compliant - 
"
                  "use gnulib module freopen for portability");
 #endif
 
@@ -750,6 +770,20 @@ _GL_CXXALIAS_SYS (obstack_vprintf, int,
 _GL_CXXALIASWARN (obstack_vprintf);
 #endif
 
+#if @GNULIB_PCLOSE@
+# if address@hidden@
+_GL_FUNCDECL_SYS (pclose, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (pclose, int, (FILE *stream));
+_GL_CXXALIASWARN (pclose);
+#elif defined GNULIB_POSIXCHECK
+# undef pclose
+# if HAVE_RAW_DECL_PCLOSE
+_GL_WARN_ON_USE (pclose, "pclose is unportable - "
+                 "use gnulib module pclose for more portability");
+# endif
+#endif
+
 #if @GNULIB_PERROR@
 /* Print a message to standard error, describing the value of ERRNO,
    (if STRING is not NULL and not empty) prefixed with STRING and ": ",
@@ -781,6 +815,10 @@ _GL_FUNCDECL_RPL (popen, FILE *, (const char *cmd, const 
char *mode)
                                  _GL_ARG_NONNULL ((1, 2)));
 _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode));
 # else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (popen, FILE *, (const char *cmd, const char *mode)
+                                 _GL_ARG_NONNULL ((1, 2)));
+#  endif
 _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode));
 # endif
 _GL_CXXALIASWARN (popen);
diff --git a/gl/stdlib.in.h b/gl/stdlib.in.h
index 62a2ce9..e92a614 100644
--- a/gl/stdlib.in.h
+++ b/gl/stdlib.in.h
@@ -1,6 +1,6 @@
 /* A GNU-like <stdlib.h>.
 
-   Copyright (C) 1995, 2001-2004, 2006-2011 Free Software Foundation, Inc.
+   Copyright (C) 1995, 2001-2004, 2006-2012 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
@@ -49,6 +49,11 @@
 # include <sys/loadavg.h>
 #endif
 
+/* Native Windows platforms declare mktemp() in <io.h>.  */
+#if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
+# include <io.h>
+#endif
+
 #if @GNULIB_RANDOM_R@
 
 /* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included
@@ -58,7 +63,7 @@
 #  include <random.h>
 # endif
 
-# if address@hidden@ || address@hidden@
+# if address@hidden@ || @REPLACE_RANDOM_R@ || address@hidden@
 #  include <stdint.h>
 # endif
 
@@ -89,11 +94,7 @@ struct random_data
 # include <unistd.h>
 #endif
 
-#if 3 <= __GNUC__ || __GNUC__ == 2 && 8 <= __GNUC_MINOR__
-# define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
-#else
-# define _GL_ATTRIBUTE_NORETURN
-#endif
+/* The definition of _Noreturn is copied here.  */
 
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
@@ -120,7 +121,7 @@ struct random_data
 /* Terminate the current process with the given return code, without running
    the 'atexit' handlers.  */
 # if address@hidden@
-_GL_FUNCDECL_SYS (_Exit, void, (int status) _GL_ATTRIBUTE_NORETURN);
+_GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status));
 # endif
 _GL_CXXALIAS_SYS (_Exit, void, (int status));
 _GL_CXXALIASWARN (_Exit);
@@ -251,7 +252,7 @@ _GL_CXXALIASWARN (grantpt);
 #elif defined GNULIB_POSIXCHECK
 # undef grantpt
 # if HAVE_RAW_DECL_GRANTPT
-_GL_WARN_ON_USE (ptsname, "grantpt is not portable - "
+_GL_WARN_ON_USE (grantpt, "grantpt is not portable - "
                  "use gnulib module grantpt for portability");
 # endif
 #endif
@@ -427,6 +428,22 @@ _GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - "
 # endif
 #endif
 
+#if @GNULIB_POSIX_OPENPT@
+/* Return an FD open to the master side of a pseudo-terminal.  Flags should
+   include O_RDWR, and may also include O_NOCTTY.  */
+# if address@hidden@
+_GL_FUNCDECL_SYS (posix_openpt, int, (int flags));
+# endif
+_GL_CXXALIAS_SYS (posix_openpt, int, (int flags));
+_GL_CXXALIASWARN (posix_openpt);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_openpt
+# if HAVE_RAW_DECL_POSIX_OPENPT
+_GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - "
+                 "use gnulib module posix_openpt for portability");
+# endif
+#endif
+
 #if @GNULIB_PTSNAME@
 /* Return the pathname of the pseudo-terminal slave associated with
    the master FD is open on, or NULL on errors.  */
@@ -443,6 +460,32 @@ _GL_WARN_ON_USE (ptsname, "ptsname is not portable - "
 # endif
 #endif
 
+#if @GNULIB_PTSNAME_R@
+/* Set the pathname of the pseudo-terminal slave associated with
+   the master FD is open on and return 0, or set errno and return
+   non-zero on errors.  */
+# if @REPLACE_PTSNAME_R@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef ptsname_r
+#   define ptsname_r rpl_ptsname_r
+#  endif
+_GL_FUNCDECL_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
+_GL_CXXALIAS_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
+#  endif
+_GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
+# endif
+_GL_CXXALIASWARN (ptsname_r);
+#elif defined GNULIB_POSIXCHECK
+# undef ptsname_r
+# if HAVE_RAW_DECL_PTSNAME_R
+_GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - "
+                 "use gnulib module ptsname_r for portability");
+# endif
+#endif
+
 #if @GNULIB_PUTENV@
 # if @REPLACE_PUTENV@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -466,12 +509,83 @@ _GL_CXXALIASWARN (putenv);
 # endif
 #endif
 
+
+#if @GNULIB_RANDOM@
+# if address@hidden@
+_GL_FUNCDECL_SYS (random, long, (void));
+# endif
+_GL_CXXALIAS_SYS (random, long, (void));
+_GL_CXXALIASWARN (random);
+#elif defined GNULIB_POSIXCHECK
+# undef random
+# if HAVE_RAW_DECL_RANDOM
+_GL_WARN_ON_USE (random, "random is unportable - "
+                 "use gnulib module random for portability");
+# endif
+#endif
+
+#if @GNULIB_RANDOM@
+# if address@hidden@
+_GL_FUNCDECL_SYS (srandom, void, (unsigned int seed));
+# endif
+_GL_CXXALIAS_SYS (srandom, void, (unsigned int seed));
+_GL_CXXALIASWARN (srandom);
+#elif defined GNULIB_POSIXCHECK
+# undef srandom
+# if HAVE_RAW_DECL_SRANDOM
+_GL_WARN_ON_USE (srandom, "srandom is unportable - "
+                 "use gnulib module random for portability");
+# endif
+#endif
+
+#if @GNULIB_RANDOM@
+# if address@hidden@
+_GL_FUNCDECL_SYS (initstate, char *,
+                  (unsigned int seed, char *buf, size_t buf_size)
+                  _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (initstate, char *,
+                  (unsigned int seed, char *buf, size_t buf_size));
+_GL_CXXALIASWARN (initstate);
+#elif defined GNULIB_POSIXCHECK
+# undef initstate
+# if HAVE_RAW_DECL_INITSTATE_R
+_GL_WARN_ON_USE (initstate, "initstate is unportable - "
+                 "use gnulib module random for portability");
+# endif
+#endif
+
+#if @GNULIB_RANDOM@
+# if address@hidden@
+_GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (setstate, char *, (char *arg_state));
+_GL_CXXALIASWARN (setstate);
+#elif defined GNULIB_POSIXCHECK
+# undef setstate
+# if HAVE_RAW_DECL_SETSTATE_R
+_GL_WARN_ON_USE (setstate, "setstate is unportable - "
+                 "use gnulib module random for portability");
+# endif
+#endif
+
+
 #if @GNULIB_RANDOM_R@
-# if address@hidden@
+# if @REPLACE_RANDOM_R@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef random_r
+#   define random_r rpl_random_r
+#  endif
+_GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result)
+                                 _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result));
+# else
+#  if address@hidden@
 _GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result)
                                  _GL_ARG_NONNULL ((1, 2)));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result));
+# endif
 _GL_CXXALIASWARN (random_r);
 #elif defined GNULIB_POSIXCHECK
 # undef random_r
@@ -482,13 +596,25 @@ _GL_WARN_ON_USE (random_r, "random_r is unportable - "
 #endif
 
 #if @GNULIB_RANDOM_R@
-# if address@hidden@
+# if @REPLACE_RANDOM_R@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef srandom_r
+#   define srandom_r rpl_srandom_r
+#  endif
+_GL_FUNCDECL_RPL (srandom_r, int,
+                  (unsigned int seed, struct random_data *rand_state)
+                  _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (srandom_r, int,
+                  (unsigned int seed, struct random_data *rand_state));
+# else
+#  if address@hidden@
 _GL_FUNCDECL_SYS (srandom_r, int,
                   (unsigned int seed, struct random_data *rand_state)
                   _GL_ARG_NONNULL ((2)));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (srandom_r, int,
                   (unsigned int seed, struct random_data *rand_state));
+# endif
 _GL_CXXALIASWARN (srandom_r);
 #elif defined GNULIB_POSIXCHECK
 # undef srandom_r
@@ -499,15 +625,29 @@ _GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - "
 #endif
 
 #if @GNULIB_RANDOM_R@
-# if address@hidden@
+# if @REPLACE_RANDOM_R@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef initstate_r
+#   define initstate_r rpl_initstate_r
+#  endif
+_GL_FUNCDECL_RPL (initstate_r, int,
+                  (unsigned int seed, char *buf, size_t buf_size,
+                   struct random_data *rand_state)
+                  _GL_ARG_NONNULL ((2, 4)));
+_GL_CXXALIAS_RPL (initstate_r, int,
+                  (unsigned int seed, char *buf, size_t buf_size,
+                   struct random_data *rand_state));
+# else
+#  if address@hidden@
 _GL_FUNCDECL_SYS (initstate_r, int,
                   (unsigned int seed, char *buf, size_t buf_size,
                    struct random_data *rand_state)
                   _GL_ARG_NONNULL ((2, 4)));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (initstate_r, int,
                   (unsigned int seed, char *buf, size_t buf_size,
                    struct random_data *rand_state));
+# endif
 _GL_CXXALIASWARN (initstate_r);
 #elif defined GNULIB_POSIXCHECK
 # undef initstate_r
@@ -518,13 +658,25 @@ _GL_WARN_ON_USE (initstate_r, "initstate_r is unportable 
- "
 #endif
 
 #if @GNULIB_RANDOM_R@
-# if address@hidden@
+# if @REPLACE_RANDOM_R@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef setstate_r
+#   define setstate_r rpl_setstate_r
+#  endif
+_GL_FUNCDECL_RPL (setstate_r, int,
+                  (char *arg_state, struct random_data *rand_state)
+                  _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (setstate_r, int,
+                  (char *arg_state, struct random_data *rand_state));
+# else
+#  if address@hidden@
 _GL_FUNCDECL_SYS (setstate_r, int,
                   (char *arg_state, struct random_data *rand_state)
                   _GL_ARG_NONNULL ((1, 2)));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (setstate_r, int,
                   (char *arg_state, struct random_data *rand_state));
+# endif
 _GL_CXXALIASWARN (setstate_r);
 #elif defined GNULIB_POSIXCHECK
 # undef setstate_r
diff --git a/gl/strdup.c b/gl/strdup.c
index ba7e76b..c083551 100644
--- a/gl/strdup.c
+++ b/gl/strdup.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1996-1998, 2002-2004, 2006-2007, 2009-2011 Free Software
+/* Copyright (C) 1991, 1996-1998, 2002-2004, 2006-2007, 2009-2012 Free Software
    Foundation, Inc.
 
    This file is part of the GNU C Library.
diff --git a/gl/streq.h b/gl/streq.h
index c7794f6..57784e6 100644
--- a/gl/streq.h
+++ b/gl/streq.h
@@ -1,5 +1,5 @@
 /* Optimized string comparison.
-   Copyright (C) 2001-2002, 2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2001-2002, 2007, 2009-2012 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
diff --git a/gl/strerror-override.c b/gl/strerror-override.c
index e103173..9ca6523 100644
--- a/gl/strerror-override.c
+++ b/gl/strerror-override.c
@@ -1,6 +1,6 @@
 /* strerror-override.c --- POSIX compatible system error routine
 
-   Copyright (C) 2010-2011 Free Software Foundation, Inc.
+   Copyright (C) 2010-2012 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
@@ -23,7 +23,7 @@
 
 #include <errno.h>
 
-#if GNULIB_defined_ESOCK /* native Windows platforms */
+#if GNULIB_defined_EWINSOCK /* native Windows platforms */
 # if HAVE_WINSOCK2_H
 #  include <winsock2.h>
 # endif
@@ -42,13 +42,7 @@ strerror_override (int errnum)
       return "Success";
 #endif
 
-#if GNULIB_defined_ETXTBSY
-    case ETXTBSY:
-      return "Text file busy";
-#endif
-
-#if GNULIB_defined_ESOCK /* native Windows platforms */
-      /* EWOULDBLOCK is the same as EAGAIN.  */
+#if GNULIB_defined_ESOCK /* native Windows platforms with older <errno.h> */
     case EINPROGRESS:
       return "Operation now in progress";
     case EALREADY:
@@ -65,12 +59,8 @@ strerror_override (int errnum)
       return "Protocol not available";
     case EPROTONOSUPPORT:
       return "Protocol not supported";
-    case ESOCKTNOSUPPORT:
-      return "Socket type not supported";
     case EOPNOTSUPP:
       return "Operation not supported";
-    case EPFNOSUPPORT:
-      return "Protocol family not supported";
     case EAFNOSUPPORT:
       return "Address family not supported by protocol";
     case EADDRINUSE:
@@ -81,10 +71,6 @@ strerror_override (int errnum)
       return "Network is down";
     case ENETUNREACH:
       return "Network is unreachable";
-    case ENETRESET:
-      return "Network dropped connection on reset";
-    case ECONNABORTED:
-      return "Software caused connection abort";
     case ECONNRESET:
       return "Connection reset by peer";
     case ENOBUFS:
@@ -93,20 +79,44 @@ strerror_override (int errnum)
       return "Transport endpoint is already connected";
     case ENOTCONN:
       return "Transport endpoint is not connected";
-    case ESHUTDOWN:
-      return "Cannot send after transport endpoint shutdown";
-    case ETOOMANYREFS:
-      return "Too many references: cannot splice";
     case ETIMEDOUT:
       return "Connection timed out";
     case ECONNREFUSED:
       return "Connection refused";
     case ELOOP:
       return "Too many levels of symbolic links";
-    case EHOSTDOWN:
-      return "Host is down";
     case EHOSTUNREACH:
       return "No route to host";
+    case EWOULDBLOCK:
+      return "Operation would block";
+    case ETXTBSY:
+      return "Text file busy";
+    case ENODATA:
+      return "No data available";
+    case ENOSR:
+      return "Out of streams resources";
+    case ENOSTR:
+      return "Device not a stream";
+    case ENOTRECOVERABLE:
+      return "State not recoverable";
+    case EOWNERDEAD:
+      return "Owner died";
+    case ETIME:
+      return "Timer expired";
+    case EOTHER:
+      return "Other error";
+#endif
+#if GNULIB_defined_EWINSOCK /* native Windows platforms */
+    case ESOCKTNOSUPPORT:
+      return "Socket type not supported";
+    case EPFNOSUPPORT:
+      return "Protocol family not supported";
+    case ESHUTDOWN:
+      return "Cannot send after transport endpoint shutdown";
+    case ETOOMANYREFS:
+      return "Too many references: cannot splice";
+    case EHOSTDOWN:
+      return "Host is down";
     case EPROCLIM:
       return "Too many processes";
     case EUSERS:
@@ -134,36 +144,36 @@ strerror_override (int errnum)
       /* WSAEINVAL maps to EINVAL */
       /* WSAEMFILE maps to EMFILE */
       /* WSAEWOULDBLOCK maps to EWOULDBLOCK */
-      /* WSAEINPROGRESS is EINPROGRESS */
-      /* WSAEALREADY is EALREADY */
-      /* WSAENOTSOCK is ENOTSOCK */
-      /* WSAEDESTADDRREQ is EDESTADDRREQ */
-      /* WSAEMSGSIZE is EMSGSIZE */
-      /* WSAEPROTOTYPE is EPROTOTYPE */
-      /* WSAENOPROTOOPT is ENOPROTOOPT */
-      /* WSAEPROTONOSUPPORT is EPROTONOSUPPORT */
+      /* WSAEINPROGRESS maps to EINPROGRESS */
+      /* WSAEALREADY maps to EALREADY */
+      /* WSAENOTSOCK maps to ENOTSOCK */
+      /* WSAEDESTADDRREQ maps to EDESTADDRREQ */
+      /* WSAEMSGSIZE maps to EMSGSIZE */
+      /* WSAEPROTOTYPE maps to EPROTOTYPE */
+      /* WSAENOPROTOOPT maps to ENOPROTOOPT */
+      /* WSAEPROTONOSUPPORT maps to EPROTONOSUPPORT */
       /* WSAESOCKTNOSUPPORT is ESOCKTNOSUPPORT */
-      /* WSAEOPNOTSUPP is EOPNOTSUPP */
+      /* WSAEOPNOTSUPP maps to EOPNOTSUPP */
       /* WSAEPFNOSUPPORT is EPFNOSUPPORT */
-      /* WSAEAFNOSUPPORT is EAFNOSUPPORT */
-      /* WSAEADDRINUSE is EADDRINUSE */
-      /* WSAEADDRNOTAVAIL is EADDRNOTAVAIL */
-      /* WSAENETDOWN is ENETDOWN */
-      /* WSAENETUNREACH is ENETUNREACH */
-      /* WSAENETRESET is ENETRESET */
-      /* WSAECONNABORTED is ECONNABORTED */
-      /* WSAECONNRESET is ECONNRESET */
-      /* WSAENOBUFS is ENOBUFS */
-      /* WSAEISCONN is EISCONN */
-      /* WSAENOTCONN is ENOTCONN */
+      /* WSAEAFNOSUPPORT maps to EAFNOSUPPORT */
+      /* WSAEADDRINUSE maps to EADDRINUSE */
+      /* WSAEADDRNOTAVAIL maps to EADDRNOTAVAIL */
+      /* WSAENETDOWN maps to ENETDOWN */
+      /* WSAENETUNREACH maps to ENETUNREACH */
+      /* WSAENETRESET maps to ENETRESET */
+      /* WSAECONNABORTED maps to ECONNABORTED */
+      /* WSAECONNRESET maps to ECONNRESET */
+      /* WSAENOBUFS maps to ENOBUFS */
+      /* WSAEISCONN maps to EISCONN */
+      /* WSAENOTCONN maps to ENOTCONN */
       /* WSAESHUTDOWN is ESHUTDOWN */
       /* WSAETOOMANYREFS is ETOOMANYREFS */
-      /* WSAETIMEDOUT is ETIMEDOUT */
-      /* WSAECONNREFUSED is ECONNREFUSED */
-      /* WSAELOOP is ELOOP */
+      /* WSAETIMEDOUT maps to ETIMEDOUT */
+      /* WSAECONNREFUSED maps to ECONNREFUSED */
+      /* WSAELOOP maps to ELOOP */
       /* WSAENAMETOOLONG maps to ENAMETOOLONG */
       /* WSAEHOSTDOWN is EHOSTDOWN */
-      /* WSAEHOSTUNREACH is EHOSTUNREACH */
+      /* WSAEHOSTUNREACH maps to EHOSTUNREACH */
       /* WSAENOTEMPTY maps to ENOTEMPTY */
       /* WSAEPROCLIM is EPROCLIM */
       /* WSAEUSERS is EUSERS */
@@ -248,6 +258,16 @@ strerror_override (int errnum)
       return "Not supported";
 #endif
 
+#if GNULIB_defined_ENETRESET
+    case ENETRESET:
+      return "Network dropped connection on reset";
+#endif
+
+#if GNULIB_defined_ECONNABORTED
+    case ECONNABORTED:
+      return "Software caused connection abort";
+#endif
+
 #if GNULIB_defined_ESTALE
     case ESTALE:
       return "Stale NFS file handle";
diff --git a/gl/strerror-override.h b/gl/strerror-override.h
index a26e11a..09526ea 100644
--- a/gl/strerror-override.h
+++ b/gl/strerror-override.h
@@ -1,6 +1,6 @@
 /* strerror-override.h --- POSIX compatible system error routine
 
-   Copyright (C) 2010-2011 Free Software Foundation, Inc.
+   Copyright (C) 2010-2012 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
@@ -29,8 +29,8 @@
 /* If ERRNUM maps to an errno value defined by gnulib, return a string
    describing the error.  Otherwise return NULL.  */
 # if REPLACE_STRERROR_0 \
-     || GNULIB_defined_ETXTBSY \
      || GNULIB_defined_ESOCK \
+     || GNULIB_defined_EWINSOCK \
      || GNULIB_defined_ENOMSG \
      || GNULIB_defined_EIDRM \
      || GNULIB_defined_ENOLINK \
@@ -39,6 +39,8 @@
      || GNULIB_defined_EBADMSG \
      || GNULIB_defined_EOVERFLOW \
      || GNULIB_defined_ENOTSUP \
+     || GNULIB_defined_ENETRESET \
+     || GNULIB_defined_ECONNABORTED \
      || GNULIB_defined_ESTALE \
      || GNULIB_defined_EDQUOT \
      || GNULIB_defined_ECANCELED
diff --git a/gl/strerror.c b/gl/strerror.c
index 63899ca..587bd21 100644
--- a/gl/strerror.c
+++ b/gl/strerror.c
@@ -1,6 +1,6 @@
 /* strerror.c --- POSIX compatible system error routine
 
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
diff --git a/gl/striconv.c b/gl/striconv.c
index f710d05..d50d3fd 100644
--- a/gl/striconv.c
+++ b/gl/striconv.c
@@ -1,5 +1,5 @@
 /* Charset conversion.
-   Copyright (C) 2001-2007, 2010-2011 Free Software Foundation, Inc.
+   Copyright (C) 2001-2007, 2010-2012 Free Software Foundation, Inc.
    Written by Bruno Haible and Simon Josefsson.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/gl/striconv.h b/gl/striconv.h
index 2165d71..3752209 100644
--- a/gl/striconv.h
+++ b/gl/striconv.h
@@ -1,5 +1,5 @@
 /* Charset conversion.
-   Copyright (C) 2001-2004, 2006-2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2001-2004, 2006-2007, 2009-2012 Free Software Foundation, Inc.
    Written by Bruno Haible and Simon Josefsson.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/gl/string.in.h b/gl/string.in.h
index d9c95a4..93f70de 100644
--- a/gl/string.in.h
+++ b/gl/string.in.h
@@ -1,6 +1,6 @@
 /* A GNU-like <string.h>.
 
-   Copyright (C) 1995-1996, 2001-2011 Free Software Foundation, Inc.
+   Copyright (C) 1995-1996, 2001-2012 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
@@ -59,6 +59,36 @@
 /* The definition of _GL_WARN_ON_USE is copied here.  */
 
 
+/* Find the index of the least-significant set bit.  */
+#if @GNULIB_FFSL@
+# if address@hidden@
+_GL_FUNCDECL_SYS (ffsl, int, (long int i));
+# endif
+_GL_CXXALIAS_SYS (ffsl, int, (long int i));
+_GL_CXXALIASWARN (ffsl);
+#elif defined GNULIB_POSIXCHECK
+# undef ffsl
+# if HAVE_RAW_DECL_FFSL
+_GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module");
+# endif
+#endif
+
+
+/* Find the index of the least-significant set bit.  */
+#if @GNULIB_FFSLL@
+# if address@hidden@
+_GL_FUNCDECL_SYS (ffsll, int, (long long int i));
+# endif
+_GL_CXXALIAS_SYS (ffsll, int, (long long int i));
+_GL_CXXALIASWARN (ffsll);
+#elif defined GNULIB_POSIXCHECK
+# undef ffsll
+# if HAVE_RAW_DECL_FFSLL
+_GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module");
+# endif
+#endif
+
+
 /* Return the first instance of C within N bytes of S, or NULL.  */
 #if @GNULIB_MEMCHR@
 # if @REPLACE_MEMCHR@
diff --git a/gl/strtok_r.c b/gl/strtok_r.c
index b60efcd..e1499bc 100644
--- a/gl/strtok_r.c
+++ b/gl/strtok_r.c
@@ -1,5 +1,5 @@
 /* Reentrant string tokenizer.  Generic version.
-   Copyright (C) 1991, 1996-1999, 2001, 2004, 2007, 2009-2011 Free Software
+   Copyright (C) 1991, 1996-1999, 2001, 2004, 2007, 2009-2012 Free Software
    Foundation, Inc.
    This file is part of the GNU C Library.
 
diff --git a/gl/sys_select.in.h b/gl/sys_select.in.h
index 1522db9..4b35d19 100644
--- a/gl/sys_select.in.h
+++ b/gl/sys_select.in.h
@@ -1,5 +1,5 @@
 /* Substitute for <sys/select.h>.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
@@ -32,15 +32,35 @@
 # define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H
 # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
 
+/* On IRIX 6.5, <sys/timespec.h> includes <sys/types.h>, which includes
+   <sys/bsd_types.h>, which includes <sys/select.h>.  At this point we cannot
+   include <signal.h>, because that includes <internal/signal_core.h>, which
+   gives a syntax error because <sys/timespec.h> has not been completely
+   processed.  Simply delegate to the system's header in this case.  */
+#elif @HAVE_SYS_SELECT_H@ && defined __sgi && (defined _SYS_BSD_TYPES_H && 
!defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_BSD_TYPES_H)
+
+# define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_BSD_TYPES_H
+# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
+
+/* On OpenBSD 5.0, <pthread.h> includes <sys/types.h>, which includes
+   <sys/select.h>.  At this point we cannot include <signal.h>, because that
+   includes gnulib's pthread.h override, which gives a syntax error because
+   /usr/include/pthread.h has not been completely processed.  Simply delegate
+   to the system's header in this case.  */
+#elif @HAVE_SYS_SELECT_H@ && defined __OpenBSD__ && (defined _PTHREAD_H_ && 
!defined PTHREAD_MUTEX_INITIALIZER)
+
+# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
+
 #else
 
 #ifndef address@hidden@_SYS_SELECT_H
 
-#if @HAVE_SYS_SELECT_H@
-
 /* On many platforms, <sys/select.h> assumes prior inclusion of
-   <sys/types.h>.  */
-# include <sys/types.h>
+   <sys/types.h>.  Also, mingw defines sigset_t there, instead of
+   in <signal.h> where it belongs.  */
+#include <sys/types.h>
+
+#if @HAVE_SYS_SELECT_H@
 
 /* On OSF/1 4.0, <sys/select.h> provides only a forward declaration
    of 'struct timeval', and no definition of this type.
@@ -64,6 +84,14 @@
 
 #endif
 
+/* Get definition of 'sigset_t'.
+   But avoid namespace pollution on glibc systems.
+   Do this after the include_next (for the sake of OpenBSD 5.0) but before
+   the split double-inclusion guard (for the sake of Solaris).  */
+#if !(defined __GLIBC__ && !defined __UCLIBC__)
+# include <signal.h>
+#endif
+
 #ifndef address@hidden@_SYS_SELECT_H
 #define address@hidden@_SYS_SELECT_H
 
@@ -78,9 +106,16 @@
 #  include <string.h>
 # endif
 /* On native Windows platforms:
-   Get the 'fd_set' type.  Also, gnulib's <sys/socket.h> redefines select
-   so as to hide the declaration from <winsock2.h>.  */
-# include <sys/socket.h>
+   Get the 'fd_set' type.
+   Get the close() declaration before we override it.  */
+# if @HAVE_WINSOCK2_H@
+#  if !defined _GL_INCLUDING_WINSOCK2_H
+#   define _GL_INCLUDING_WINSOCK2_H
+#   include <winsock2.h>
+#   undef _GL_INCLUDING_WINSOCK2_H
+#  endif
+#  include <io.h>
+# endif
 #endif
 
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
@@ -88,6 +123,150 @@
 /* The definition of _GL_WARN_ON_USE is copied here.  */
 
 
+/* Fix some definitions from <winsock2.h>.  */
+
+#if @HAVE_WINSOCK2_H@
+
+# if !GNULIB_defined_rpl_fd_isset
+
+/* Re-define FD_ISSET to avoid a WSA call while we are not using
+   network sockets.  */
+static inline int
+rpl_fd_isset (SOCKET fd, fd_set * set)
+{
+  u_int i;
+  if (set == NULL)
+    return 0;
+
+  for (i = 0; i < set->fd_count; i++)
+    if (set->fd_array[i] == fd)
+      return 1;
+
+  return 0;
+}
+
+#  define GNULIB_defined_rpl_fd_isset 1
+# endif
+
+# undef FD_ISSET
+# define FD_ISSET(fd, set) rpl_fd_isset(fd, set)
+
+#endif
+
+/* Hide some function declarations from <winsock2.h>.  */
+
+#if @HAVE_WINSOCK2_H@
+# if !defined address@hidden@_UNISTD_H
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef close
+#   define close close_used_without_including_unistd_h
+#  else
+    _GL_WARN_ON_USE (close,
+                     "close() used without including <unistd.h>");
+#  endif
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef gethostname
+#   define gethostname gethostname_used_without_including_unistd_h
+#  else
+    _GL_WARN_ON_USE (gethostname,
+                     "gethostname() used without including <unistd.h>");
+#  endif
+# endif
+# if !defined address@hidden@_SYS_SOCKET_H
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef socket
+#   define socket              socket_used_without_including_sys_socket_h
+#   undef connect
+#   define connect             connect_used_without_including_sys_socket_h
+#   undef accept
+#   define accept              accept_used_without_including_sys_socket_h
+#   undef bind
+#   define bind                bind_used_without_including_sys_socket_h
+#   undef getpeername
+#   define getpeername         getpeername_used_without_including_sys_socket_h
+#   undef getsockname
+#   define getsockname         getsockname_used_without_including_sys_socket_h
+#   undef getsockopt
+#   define getsockopt          getsockopt_used_without_including_sys_socket_h
+#   undef listen
+#   define listen              listen_used_without_including_sys_socket_h
+#   undef recv
+#   define recv                recv_used_without_including_sys_socket_h
+#   undef send
+#   define send                send_used_without_including_sys_socket_h
+#   undef recvfrom
+#   define recvfrom            recvfrom_used_without_including_sys_socket_h
+#   undef sendto
+#   define sendto              sendto_used_without_including_sys_socket_h
+#   undef setsockopt
+#   define setsockopt          setsockopt_used_without_including_sys_socket_h
+#   undef shutdown
+#   define shutdown            shutdown_used_without_including_sys_socket_h
+#  else
+    _GL_WARN_ON_USE (socket,
+                     "socket() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (connect,
+                     "connect() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (accept,
+                     "accept() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (bind,
+                     "bind() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (getpeername,
+                     "getpeername() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (getsockname,
+                     "getsockname() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (getsockopt,
+                     "getsockopt() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (listen,
+                     "listen() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (recv,
+                     "recv() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (send,
+                     "send() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (recvfrom,
+                     "recvfrom() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (sendto,
+                     "sendto() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (setsockopt,
+                     "setsockopt() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (shutdown,
+                     "shutdown() used without including <sys/socket.h>");
+#  endif
+# endif
+#endif
+
+
+#if @GNULIB_PSELECT@
+# if @REPLACE_PSELECT@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef pselect
+#   define pselect rpl_pselect
+#  endif
+_GL_FUNCDECL_RPL (pselect, int,
+                  (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
+                   struct timespec const *restrict, const sigset_t *restrict));
+_GL_CXXALIAS_RPL (pselect, int,
+                  (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
+                   struct timespec const *restrict, const sigset_t *restrict));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (pselect, int,
+                  (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
+                   struct timespec const *restrict, const sigset_t *restrict));
+#  endif
+_GL_CXXALIAS_SYS (pselect, int,
+                  (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
+                   struct timespec const *restrict, const sigset_t *restrict));
+# endif
+_GL_CXXALIASWARN (pselect);
+#elif defined GNULIB_POSIXCHECK
+# undef pselect
+# if HAVE_RAW_DECL_PSELECT
+_GL_WARN_ON_USE (pselect, "pselect is not portable - "
+                 "use gnulib module pselect for portability");
+# endif
+#endif
+
 #if @GNULIB_SELECT@
 # if @REPLACE_SELECT@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
diff --git a/gl/sys_socket.in.h b/gl/sys_socket.in.h
index b792171..819aff1 100644
--- a/gl/sys_socket.in.h
+++ b/gl/sys_socket.in.h
@@ -1,6 +1,6 @@
 /* Provide a sys/socket header file for systems lacking it (read: MinGW)
    and for systems where it is incomplete.
-   Copyright (C) 2005-2011 Free Software Foundation, Inc.
+   Copyright (C) 2005-2012 Free Software Foundation, Inc.
    Written by Simon Josefsson.
 
    This program is free software; you can redistribute it and/or modify
@@ -85,7 +85,7 @@ typedef unsigned short  sa_family_t;
 #  endif
 # endif
 #else
-# include <alignof.h>
+# include <stdalign.h>
 /* Code taken from glibc sysdeps/unix/sysv/linux/bits/socket.h on
    2009-05-08, licensed under LGPLv2.1+, plus portability fixes. */
 # define __ss_aligntype unsigned long int
@@ -143,7 +143,7 @@ struct sockaddr_storage
    that you can influence which definitions you get by setting the
    WINVER symbol before including these two files.  For example,
    getaddrinfo is only available if _WIN32_WINNT >= 0x0501 (that
-   symbol is set indiriectly through WINVER).  You can set this by
+   symbol is set indirectly through WINVER).  You can set this by
    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
@@ -194,6 +194,8 @@ struct msghdr {
 
 #endif
 
+/* Fix some definitions from <winsock2.h>.  */
+
 #if @HAVE_WINSOCK2_H@
 
 # if !GNULIB_defined_rpl_fd_isset
@@ -222,28 +224,38 @@ rpl_fd_isset (SOCKET fd, fd_set * set)
 
 #endif
 
-/* Wrap everything else to use libc file descriptors for sockets.  */
+/* Hide some function declarations from <winsock2.h>.  */
 
-#if @HAVE_WINSOCK2_H@ && !defined address@hidden@_UNISTD_H
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#  undef close
-#  define close close_used_without_including_unistd_h
-# else
-   _GL_WARN_ON_USE (close,
-                    "close() used without including <unistd.h>");
+#if @HAVE_WINSOCK2_H@
+# if !defined address@hidden@_UNISTD_H
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef close
+#   define close close_used_without_including_unistd_h
+#  else
+    _GL_WARN_ON_USE (close,
+                     "close() used without including <unistd.h>");
+#  endif
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef gethostname
+#   define gethostname gethostname_used_without_including_unistd_h
+#  else
+    _GL_WARN_ON_USE (gethostname,
+                     "gethostname() used without including <unistd.h>");
+#  endif
 # endif
-#endif
-
-#if @HAVE_WINSOCK2_H@ && !defined address@hidden@_UNISTD_H
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#  undef gethostname
-#  define gethostname gethostname_used_without_including_unistd_h
-# else
-   _GL_WARN_ON_USE (gethostname,
-                    "gethostname() used without including <unistd.h>");
+# if !defined address@hidden@_SYS_SELECT_H
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef select
+#   define select select_used_without_including_sys_select_h
+#  else
+    _GL_WARN_ON_USE (select,
+                     "select() used without including <sys/select.h>");
+#  endif
 # endif
 #endif
 
+/* Wrap everything else to use libc file descriptors for sockets.  */
+
 #if @GNULIB_SOCKET@
 # if @HAVE_WINSOCK2_H@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -633,16 +645,6 @@ _GL_WARN_ON_USE (shutdown, "shutdown is not always POSIX 
compliant - "
 # endif
 #endif
 
-#if @HAVE_WINSOCK2_H@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#  undef select
-#  define select select_used_without_including_sys_select_h
-# else
-   _GL_WARN_ON_USE (select,
-                    "select() used without including <sys/select.h>");
-# endif
-#endif
-
 #if @GNULIB_ACCEPT4@
 /* Accept a connection on a socket, with specific opening flags.
    The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
diff --git a/gl/sys_stat.in.h b/gl/sys_stat.in.h
new file mode 100644
index 0000000..6d159f0
--- /dev/null
+++ b/gl/sys_stat.in.h
@@ -0,0 +1,698 @@
+/* Provide a more complete sys/stat header file.
+   Copyright (C) 2005-2012 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
+   the Free Software Foundation; either version 3, 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 General Public License for more details.
+
+   You should have received a copy of the GNU 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 Eric Blake, Paul Eggert, and Jim Meyering.  */
+
+/* This file is supposed to be used on platforms where <sys/stat.h> is
+   incomplete.  It is intended to provide definitions and prototypes
+   needed by an application.  Start with what the system provides.  */
+
+#if __GNUC__ >= 3
address@hidden@
+#endif
address@hidden@
+
+#if defined __need_system_sys_stat_h
+/* Special invocation convention.  */
+
address@hidden@ @NEXT_SYS_STAT_H@
+
+#else
+/* Normal invocation convention.  */
+
+#ifndef address@hidden@_SYS_STAT_H
+
+/* Get nlink_t.  */
+#include <sys/types.h>
+
+/* Get struct timespec.  */
+#include <time.h>
+
+/* The include_next requires a split double-inclusion guard.  */
address@hidden@ @NEXT_SYS_STAT_H@
+
+#ifndef address@hidden@_SYS_STAT_H
+#define address@hidden@_SYS_STAT_H
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
+/* Before doing "#define mkdir rpl_mkdir" below, we need to include all
+   headers that may declare mkdir().  Native Windows platforms declare mkdir
+   in <io.h> and/or <direct.h>, not in <unistd.h>.  */
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# include <io.h>     /* mingw32, mingw64 */
+# include <direct.h> /* mingw64, MSVC 9 */
+#endif
+
+/* Native Windows platforms declare umask() in <io.h>.  */
+#if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
+# include <io.h>
+#endif
+
+#ifndef S_IFIFO
+# ifdef _S_IFIFO
+#  define S_IFIFO _S_IFIFO
+# endif
+#endif
+
+#ifndef S_IFMT
+# define S_IFMT 0170000
+#endif
+
+#if STAT_MACROS_BROKEN
+# undef S_ISBLK
+# undef S_ISCHR
+# undef S_ISDIR
+# undef S_ISFIFO
+# undef S_ISLNK
+# undef S_ISNAM
+# undef S_ISMPB
+# undef S_ISMPC
+# undef S_ISNWK
+# undef S_ISREG
+# undef S_ISSOCK
+#endif
+
+#ifndef S_ISBLK
+# ifdef S_IFBLK
+#  define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
+# else
+#  define S_ISBLK(m) 0
+# endif
+#endif
+
+#ifndef S_ISCHR
+# ifdef S_IFCHR
+#  define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
+# else
+#  define S_ISCHR(m) 0
+# endif
+#endif
+
+#ifndef S_ISDIR
+# ifdef S_IFDIR
+#  define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+# else
+#  define S_ISDIR(m) 0
+# endif
+#endif
+
+#ifndef S_ISDOOR /* Solaris 2.5 and up */
+# define S_ISDOOR(m) 0
+#endif
+
+#ifndef S_ISFIFO
+# ifdef S_IFIFO
+#  define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
+# else
+#  define S_ISFIFO(m) 0
+# endif
+#endif
+
+#ifndef S_ISLNK
+# ifdef S_IFLNK
+#  define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
+# else
+#  define S_ISLNK(m) 0
+# endif
+#endif
+
+#ifndef S_ISMPB /* V7 */
+# ifdef S_IFMPB
+#  define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
+#  define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
+# else
+#  define S_ISMPB(m) 0
+#  define S_ISMPC(m) 0
+# endif
+#endif
+
+#ifndef S_ISNAM /* Xenix */
+# ifdef S_IFNAM
+#  define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
+# else
+#  define S_ISNAM(m) 0
+# endif
+#endif
+
+#ifndef S_ISNWK /* HP/UX */
+# ifdef S_IFNWK
+#  define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
+# else
+#  define S_ISNWK(m) 0
+# endif
+#endif
+
+#ifndef S_ISPORT /* Solaris 10 and up */
+# define S_ISPORT(m) 0
+#endif
+
+#ifndef S_ISREG
+# ifdef S_IFREG
+#  define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
+# else
+#  define S_ISREG(m) 0
+# endif
+#endif
+
+#ifndef S_ISSOCK
+# ifdef S_IFSOCK
+#  define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
+# else
+#  define S_ISSOCK(m) 0
+# endif
+#endif
+
+
+#ifndef S_TYPEISMQ
+# define S_TYPEISMQ(p) 0
+#endif
+
+#ifndef S_TYPEISTMO
+# define S_TYPEISTMO(p) 0
+#endif
+
+
+#ifndef S_TYPEISSEM
+# ifdef S_INSEM
+#  define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
+# else
+#  define S_TYPEISSEM(p) 0
+# endif
+#endif
+
+#ifndef S_TYPEISSHM
+# ifdef S_INSHD
+#  define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
+# else
+#  define S_TYPEISSHM(p) 0
+# endif
+#endif
+
+/* high performance ("contiguous data") */
+#ifndef S_ISCTG
+# define S_ISCTG(p) 0
+#endif
+
+/* Cray DMF (data migration facility): off line, with data  */
+#ifndef S_ISOFD
+# define S_ISOFD(p) 0
+#endif
+
+/* Cray DMF (data migration facility): off line, with no data  */
+#ifndef S_ISOFL
+# define S_ISOFL(p) 0
+#endif
+
+/* 4.4BSD whiteout */
+#ifndef S_ISWHT
+# define S_ISWHT(m) 0
+#endif
+
+/* If any of the following are undefined,
+   define them to their de facto standard values.  */
+#if !S_ISUID
+# define S_ISUID 04000
+#endif
+#if !S_ISGID
+# define S_ISGID 02000
+#endif
+
+/* S_ISVTX is a common extension to POSIX.  */
+#ifndef S_ISVTX
+# define S_ISVTX 01000
+#endif
+
+#if !S_IRUSR && S_IREAD
+# define S_IRUSR S_IREAD
+#endif
+#if !S_IRUSR
+# define S_IRUSR 00400
+#endif
+#if !S_IRGRP
+# define S_IRGRP (S_IRUSR >> 3)
+#endif
+#if !S_IROTH
+# define S_IROTH (S_IRUSR >> 6)
+#endif
+
+#if !S_IWUSR && S_IWRITE
+# define S_IWUSR S_IWRITE
+#endif
+#if !S_IWUSR
+# define S_IWUSR 00200
+#endif
+#if !S_IWGRP
+# define S_IWGRP (S_IWUSR >> 3)
+#endif
+#if !S_IWOTH
+# define S_IWOTH (S_IWUSR >> 6)
+#endif
+
+#if !S_IXUSR && S_IEXEC
+# define S_IXUSR S_IEXEC
+#endif
+#if !S_IXUSR
+# define S_IXUSR 00100
+#endif
+#if !S_IXGRP
+# define S_IXGRP (S_IXUSR >> 3)
+#endif
+#if !S_IXOTH
+# define S_IXOTH (S_IXUSR >> 6)
+#endif
+
+#if !S_IRWXU
+# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
+#endif
+#if !S_IRWXG
+# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
+#endif
+#if !S_IRWXO
+# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
+#endif
+
+/* S_IXUGO is a common extension to POSIX.  */
+#if !S_IXUGO
+# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
+#endif
+
+#ifndef S_IRWXUGO
+# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
+#endif
+
+/* Macros for futimens and utimensat.  */
+#ifndef UTIME_NOW
+# define UTIME_NOW (-1)
+# define UTIME_OMIT (-2)
+#endif
+
+
+#if @GNULIB_FCHMODAT@
+# if address@hidden@
+_GL_FUNCDECL_SYS (fchmodat, int,
+                  (int fd, char const *file, mode_t mode, int flag)
+                  _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (fchmodat, int,
+                  (int fd, char const *file, mode_t mode, int flag));
+_GL_CXXALIASWARN (fchmodat);
+#elif defined GNULIB_POSIXCHECK
+# undef fchmodat
+# if HAVE_RAW_DECL_FCHMODAT
+_GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - "
+                 "use gnulib module openat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_FSTAT@
+# if @REPLACE_FSTAT@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef fstat
+#   define fstat rpl_fstat
+#  endif
+_GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL 
((2)));
+_GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
+# else
+_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
+# endif
+_GL_CXXALIASWARN (fstat);
+#elif defined GNULIB_POSIXCHECK
+# undef fstat
+# if HAVE_RAW_DECL_FSTAT
+_GL_WARN_ON_USE (fstat, "fstat has portability problems - "
+                 "use gnulib module fstat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_FSTATAT@
+# if @REPLACE_FSTATAT@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef fstatat
+#   define fstatat rpl_fstatat
+#  endif
+_GL_FUNCDECL_RPL (fstatat, int,
+                  (int fd, char const *name, struct stat *st, int flags)
+                  _GL_ARG_NONNULL ((2, 3)));
+_GL_CXXALIAS_RPL (fstatat, int,
+                  (int fd, char const *name, struct stat *st, int flags));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (fstatat, int,
+                  (int fd, char const *name, struct stat *st, int flags)
+                  _GL_ARG_NONNULL ((2, 3)));
+#  endif
+_GL_CXXALIAS_SYS (fstatat, int,
+                  (int fd, char const *name, struct stat *st, int flags));
+# endif
+_GL_CXXALIASWARN (fstatat);
+#elif defined GNULIB_POSIXCHECK
+# undef fstatat
+# if HAVE_RAW_DECL_FSTATAT
+_GL_WARN_ON_USE (fstatat, "fstatat is not portable - "
+                 "use gnulib module openat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_FUTIMENS@
+/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our futimens
+   implementation relies on futimesat, which on Solaris 10 makes an invocation
+   to futimens that is meant to invoke the libc's futimens(), not gnulib's
+   futimens().  */
+# if @REPLACE_FUTIMENS@ || (address@hidden@ && defined __sun)
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef futimens
+#   define futimens rpl_futimens
+#  endif
+_GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2]));
+_GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2]));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2]));
+#  endif
+_GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
+# endif
+# if @HAVE_FUTIMENS@
+_GL_CXXALIASWARN (futimens);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef futimens
+# if HAVE_RAW_DECL_FUTIMENS
+_GL_WARN_ON_USE (futimens, "futimens is not portable - "
+                 "use gnulib module futimens for portability");
+# endif
+#endif
+
+
+#if @GNULIB_LCHMOD@
+/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
+   denotes a symbolic link.  */
+# if address@hidden@
+/* The lchmod replacement follows symbolic links.  Callers should take
+   this into account; lchmod should be applied only to arguments that
+   are known to not be symbolic links.  On hosts that lack lchmod,
+   this can lead to race conditions between the check and the
+   invocation of lchmod, but we know of no workarounds that are
+   reliable in general.  You might try requesting support for lchmod
+   from your operating system supplier.  */
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define lchmod chmod
+#  endif
+/* Need to cast, because on mingw, the second parameter of chmod is
+                                                int mode.  */
+_GL_CXXALIAS_RPL_CAST_1 (lchmod, chmod, int,
+                         (const char *filename, mode_t mode));
+# else
+#  if 0 /* assume already declared */
+_GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode)
+                               _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode));
+# endif
+# if @HAVE_LCHMOD@
+_GL_CXXALIASWARN (lchmod);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef lchmod
+# if HAVE_RAW_DECL_LCHMOD
+_GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
+                 "use gnulib module lchmod for portability");
+# endif
+#endif
+
+
+#if @GNULIB_LSTAT@
+# if ! @HAVE_LSTAT@
+/* mingw does not support symlinks, therefore it does not have lstat.  But
+   without links, stat does just fine.  */
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define lstat stat
+#  endif
+_GL_CXXALIAS_RPL_1 (lstat, stat, int, (const char *name, struct stat *buf));
+# elif @REPLACE_LSTAT@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef lstat
+#   define lstat rpl_lstat
+#  endif
+_GL_FUNCDECL_RPL (lstat, int, (const char *name, struct stat *buf)
+                              _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (lstat, int, (const char *name, struct stat *buf));
+# else
+_GL_CXXALIAS_SYS (lstat, int, (const char *name, struct stat *buf));
+# endif
+# if @HAVE_LSTAT@
+_GL_CXXALIASWARN (lstat);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef lstat
+# if HAVE_RAW_DECL_LSTAT
+_GL_WARN_ON_USE (lstat, "lstat is unportable - "
+                 "use gnulib module lstat for portability");
+# endif
+#endif
+
+
+#if @REPLACE_MKDIR@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#  undef mkdir
+#  define mkdir rpl_mkdir
+# endif
+_GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode)
+                              _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
+#else
+/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
+   Additionally, it declares _mkdir (and depending on compile flags, an
+   alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
+   which are included above.  */
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+
+#  if !GNULIB_defined_rpl_mkdir
+static inline int
+rpl_mkdir (char const *name, mode_t mode)
+{
+  return _mkdir (name);
+}
+#   define GNULIB_defined_rpl_mkdir 1
+#  endif
+
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define mkdir rpl_mkdir
+#  endif
+_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
+# else
+_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
+# endif
+#endif
+_GL_CXXALIASWARN (mkdir);
+
+
+#if @GNULIB_MKDIRAT@
+# if address@hidden@
+_GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)
+                                _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode));
+_GL_CXXALIASWARN (mkdirat);
+#elif defined GNULIB_POSIXCHECK
+# undef mkdirat
+# if HAVE_RAW_DECL_MKDIRAT
+_GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - "
+                 "use gnulib module openat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_MKFIFO@
+# if @REPLACE_MKFIFO@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef mkfifo
+#   define mkfifo rpl_mkfifo
+#  endif
+_GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode)
+                               _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode)
+                               _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode));
+# endif
+_GL_CXXALIASWARN (mkfifo);
+#elif defined GNULIB_POSIXCHECK
+# undef mkfifo
+# if HAVE_RAW_DECL_MKFIFO
+_GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
+                 "use gnulib module mkfifo for portability");
+# endif
+#endif
+
+
+#if @GNULIB_MKFIFOAT@
+# if address@hidden@
+_GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)
+                                 _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
+_GL_CXXALIASWARN (mkfifoat);
+#elif defined GNULIB_POSIXCHECK
+# undef mkfifoat
+# if HAVE_RAW_DECL_MKFIFOAT
+_GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - "
+                 "use gnulib module mkfifoat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_MKNOD@
+# if @REPLACE_MKNOD@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef mknod
+#   define mknod rpl_mknod
+#  endif
+_GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)
+                              _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev)
+                              _GL_ARG_NONNULL ((1)));
+#  endif
+/* Need to cast, because on OSF/1 5.1, the third parameter is '...'.  */
+_GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev));
+# endif
+_GL_CXXALIASWARN (mknod);
+#elif defined GNULIB_POSIXCHECK
+# undef mknod
+# if HAVE_RAW_DECL_MKNOD
+_GL_WARN_ON_USE (mknod, "mknod is not portable - "
+                 "use gnulib module mknod for portability");
+# endif
+#endif
+
+
+#if @GNULIB_MKNODAT@
+# if address@hidden@
+_GL_FUNCDECL_SYS (mknodat, int,
+                  (int fd, char const *file, mode_t mode, dev_t dev)
+                  _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (mknodat, int,
+                  (int fd, char const *file, mode_t mode, dev_t dev));
+_GL_CXXALIASWARN (mknodat);
+#elif defined GNULIB_POSIXCHECK
+# undef mknodat
+# if HAVE_RAW_DECL_MKNODAT
+_GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
+                 "use gnulib module mkfifoat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_STAT@
+# if @REPLACE_STAT@
+/* We can't use the object-like #define stat rpl_stat, because of
+   struct stat.  This means that rpl_stat will not be used if the user
+   does (stat)(a,b).  Oh well.  */
+#  if defined _AIX && defined stat && defined _LARGE_FILES
+    /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
+       so we have to replace stat64() instead of stat(). */
+#   undef stat64
+#   define stat64(name, st) rpl_stat (name, st)
+#  elif defined __MINGW32__ && defined stat
+#   ifdef _USE_32BIT_TIME_T
+     /* The system headers define stat to _stat32i64.  */
+#    undef _stat32i64
+#    define _stat32i64(name, st) rpl_stat (name, st)
+#   else
+     /* The system headers define stat to _stat64.  */
+#    undef _stat64
+#    define _stat64(name, st) rpl_stat (name, st)
+#   endif
+#  elif defined _MSC_VER && defined stat
+#   ifdef _USE_32BIT_TIME_T
+     /* The system headers define stat to _stat32.  */
+#    undef _stat32
+#    define _stat32(name, st) rpl_stat (name, st)
+#   else
+     /* The system headers define stat to _stat64i32.  */
+#    undef _stat64i32
+#    define _stat64i32(name, st) rpl_stat (name, st)
+#   endif
+#  else /* !(_AIX ||__MINGW32__ ||  _MSC_VER) */
+#   undef stat
+#   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));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef stat
+# if HAVE_RAW_DECL_STAT
+_GL_WARN_ON_USE (stat, "stat is unportable - "
+                 "use gnulib module stat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_UTIMENSAT@
+/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat
+   implementation relies on futimesat, which on Solaris 10 makes an invocation
+   to utimensat that is meant to invoke the libc's utimensat(), not gnulib's
+   utimensat().  */
+# if @REPLACE_UTIMENSAT@ || (address@hidden@ && defined __sun)
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef utimensat
+#   define utimensat rpl_utimensat
+#  endif
+_GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name,
+                                   struct timespec const times[2], int flag)
+                                  _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name,
+                                   struct timespec const times[2], int flag));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
+                                   struct timespec const times[2], int flag)
+                                  _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
+                                   struct timespec const times[2], int flag));
+# endif
+# if @HAVE_UTIMENSAT@
+_GL_CXXALIASWARN (utimensat);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef utimensat
+# if HAVE_RAW_DECL_UTIMENSAT
+_GL_WARN_ON_USE (utimensat, "utimensat is not portable - "
+                 "use gnulib module utimensat for portability");
+# endif
+#endif
+
+
+#endif /* address@hidden@_SYS_STAT_H */
+#endif /* address@hidden@_SYS_STAT_H */
+#endif
diff --git a/gl/sys_time.in.h b/gl/sys_time.in.h
index e615058..ee86ccc 100644
--- a/gl/sys_time.in.h
+++ b/gl/sys_time.in.h
@@ -1,6 +1,6 @@
 /* Provide a more complete sys/time.h.
 
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
@@ -40,6 +40,16 @@
 #  include <time.h>
 # endif
 
+/* On native Windows with MSVC, get the 'struct timeval' type.
+   Also, on native Windows with a 64-bit time_t, where we are overriding the
+   'struct timeval' type, get all declarations of system functions whose
+   signature contains 'struct timeval'.  */
+# if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && 
!defined _GL_INCLUDING_WINSOCK2_H
+#  define _GL_INCLUDING_WINSOCK2_H
+#  include <winsock2.h>
+#  undef _GL_INCLUDING_WINSOCK2_H
+# endif
+
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
 /* The definition of _GL_ARG_NONNULL is copied here.  */
@@ -50,7 +60,11 @@
 extern "C" {
 # endif
 
-# if ! @HAVE_STRUCT_TIMEVAL@
+# if address@hidden@ || @REPLACE_STRUCT_TIMEVAL@
+
+#  if @REPLACE_STRUCT_TIMEVAL@
+#   define timeval rpl_timeval
+#  endif
 
 #  if !GNULIB_defined_struct_timeval
 struct timeval
@@ -98,4 +112,95 @@ _GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable 
- "
 #  endif
 # endif
 
+/* Hide some function declarations from <winsock2.h>.  */
+
+# if defined _MSC_VER && @HAVE_WINSOCK2_H@
+#  if !defined address@hidden@_UNISTD_H
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#    undef close
+#    define close close_used_without_including_unistd_h
+#   else
+     _GL_WARN_ON_USE (close,
+                      "close() used without including <unistd.h>");
+#   endif
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#    undef gethostname
+#    define gethostname gethostname_used_without_including_unistd_h
+#   else
+     _GL_WARN_ON_USE (gethostname,
+                      "gethostname() used without including <unistd.h>");
+#   endif
+#  endif
+#  if !defined address@hidden@_SYS_SOCKET_H
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#    undef socket
+#    define socket              socket_used_without_including_sys_socket_h
+#    undef connect
+#    define connect             connect_used_without_including_sys_socket_h
+#    undef accept
+#    define accept              accept_used_without_including_sys_socket_h
+#    undef bind
+#    define bind                bind_used_without_including_sys_socket_h
+#    undef getpeername
+#    define getpeername         getpeername_used_without_including_sys_socket_h
+#    undef getsockname
+#    define getsockname         getsockname_used_without_including_sys_socket_h
+#    undef getsockopt
+#    define getsockopt          getsockopt_used_without_including_sys_socket_h
+#    undef listen
+#    define listen              listen_used_without_including_sys_socket_h
+#    undef recv
+#    define recv                recv_used_without_including_sys_socket_h
+#    undef send
+#    define send                send_used_without_including_sys_socket_h
+#    undef recvfrom
+#    define recvfrom            recvfrom_used_without_including_sys_socket_h
+#    undef sendto
+#    define sendto              sendto_used_without_including_sys_socket_h
+#    undef setsockopt
+#    define setsockopt          setsockopt_used_without_including_sys_socket_h
+#    undef shutdown
+#    define shutdown            shutdown_used_without_including_sys_socket_h
+#   else
+     _GL_WARN_ON_USE (socket,
+                      "socket() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (connect,
+                      "connect() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (accept,
+                      "accept() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (bind,
+                      "bind() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (getpeername,
+                      "getpeername() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (getsockname,
+                      "getsockname() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (getsockopt,
+                      "getsockopt() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (listen,
+                      "listen() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (recv,
+                      "recv() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (send,
+                      "send() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (recvfrom,
+                      "recvfrom() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (sendto,
+                      "sendto() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (setsockopt,
+                      "setsockopt() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (shutdown,
+                      "shutdown() used without including <sys/socket.h>");
+#   endif
+#  endif
+#  if !defined address@hidden@_SYS_SELECT_H
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#    undef select
+#    define select select_used_without_including_sys_select_h
+#   else
+     _GL_WARN_ON_USE (select,
+                      "select() used without including <sys/select.h>");
+#   endif
+#  endif
+# endif
+
 #endif /* address@hidden@_SYS_TIME_H */
diff --git a/gl/sys_types.in.h b/gl/sys_types.in.h
new file mode 100644
index 0000000..f37b999
--- /dev/null
+++ b/gl/sys_types.in.h
@@ -0,0 +1,40 @@
+/* Provide a more complete sys/types.h.
+
+   Copyright (C) 2011-2012 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
+   the Free Software Foundation; either version 3, 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 General Public License for more details.
+
+   You should have received a copy of the GNU 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.  */
+
+#if __GNUC__ >= 3
address@hidden@
+#endif
address@hidden@
+
+#ifndef address@hidden@_SYS_TYPES_H
+
+/* The include_next requires a split double-inclusion guard.  */
address@hidden@ @NEXT_SYS_TYPES_H@
+
+#ifndef address@hidden@_SYS_TYPES_H
+#define address@hidden@_SYS_TYPES_H
+
+/* MSVC 9 defines size_t in <stddef.h>, not in <sys/types.h>.  */
+/* But avoid namespace pollution on glibc systems.  */
+#if ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) \
+    && ! defined __GLIBC__
+# include <stddef.h>
+#endif
+
+#endif /* address@hidden@_SYS_TYPES_H */
+#endif /* address@hidden@_SYS_TYPES_H */
diff --git a/gl/sys_uio.in.h b/gl/sys_uio.in.h
index de49090..07b9629 100644
--- a/gl/sys_uio.in.h
+++ b/gl/sys_uio.in.h
@@ -1,5 +1,5 @@
 /* Substitute for <sys/uio.h>.
-   Copyright (C) 2011 Free Software Foundation, Inc.
+   Copyright (C) 2011-2012 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
@@ -37,7 +37,7 @@
 
 #if address@hidden@
 /* A platform that lacks <sys/uio.h>.  */
-/* Get 'ssize_t'.  */
+/* Get 'size_t' and 'ssize_t'.  */
 # include <sys/types.h>
 
 # ifdef __cplusplus
diff --git a/gl/time.in.h b/gl/time.in.h
new file mode 100644
index 0000000..5080d45
--- /dev/null
+++ b/gl/time.in.h
@@ -0,0 +1,249 @@
+/* A more-standard <time.h>.
+
+   Copyright (C) 2007-2012 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
+   the Free Software Foundation; either version 3, 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 General Public License for more details.
+
+   You should have received a copy of the GNU 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.  */
+
+#if __GNUC__ >= 3
address@hidden@
+#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
+   symbols.  Also, Solaris 8 <time.h> eventually includes itself
+   recursively; if that is happening, just include the system <time.h>
+   without adding our own declarations.  */
+#if (defined __need_time_t || defined __need_clock_t \
+     || defined __need_timespec \
+     || defined address@hidden@_TIME_H)
+
+# @INCLUDE_NEXT@ @NEXT_TIME_H@
+
+#else
+
+# define address@hidden@_TIME_H
+
+# @INCLUDE_NEXT@ @NEXT_TIME_H@
+
+/* NetBSD 5.0 mis-defines NULL.  */
+# include <stddef.h>
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
+/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3).
+   Or they define it with the wrong member names or define it in <sys/time.h>
+   (e.g., FreeBSD circa 1997).  Stock Mingw does not define it, but the
+   pthreads-win32 library defines it in <pthread.h>.  */
+# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
+#  if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
+#   include <sys/time.h>
+#  elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
+#   include <pthread.h>
+/* The pthreads-win32 <pthread.h> also defines a couple of broken macros.  */
+#   undef asctime_r
+#   undef ctime_r
+#   undef gmtime_r
+#   undef localtime_r
+#   undef rand_r
+#   undef strtok_r
+#  else
+
+#   ifdef __cplusplus
+extern "C" {
+#   endif
+
+#   if !GNULIB_defined_struct_timespec
+#    undef timespec
+#    define timespec rpl_timespec
+struct timespec
+{
+  time_t tv_sec;
+  long int tv_nsec;
+};
+#    define GNULIB_defined_struct_timespec 1
+#   endif
+
+#   ifdef __cplusplus
+}
+#   endif
+
+#  endif
+# endif
+
+# if !GNULIB_defined_struct_time_t_must_be_integral
+/* 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;
+};
+#  define GNULIB_defined_struct_time_t_must_be_integral 1
+# endif
+
+/* 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>.  */
+# if @GNULIB_NANOSLEEP@
+#  if @REPLACE_NANOSLEEP@
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#    define nanosleep rpl_nanosleep
+#   endif
+_GL_FUNCDECL_RPL (nanosleep, int,
+                  (struct timespec const *__rqtp, struct timespec *__rmtp)
+                  _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (nanosleep, int,
+                  (struct timespec const *__rqtp, struct timespec *__rmtp));
+#  else
+#   if ! @HAVE_NANOSLEEP@
+_GL_FUNCDECL_SYS (nanosleep, int,
+                  (struct timespec const *__rqtp, struct timespec *__rmtp)
+                  _GL_ARG_NONNULL ((1)));
+#   endif
+_GL_CXXALIAS_SYS (nanosleep, int,
+                  (struct timespec const *__rqtp, struct timespec *__rmtp));
+#  endif
+_GL_CXXALIASWARN (nanosleep);
+# endif
+
+/* Return the 'time_t' representation of TP and normalize TP.  */
+# if @GNULIB_MKTIME@
+#  if @REPLACE_MKTIME@
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#    define mktime rpl_mktime
+#   endif
+_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
+#  else
+_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
+#  endif
+_GL_CXXALIASWARN (mktime);
+# endif
+
+/* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
+   <http://www.opengroup.org/susv3xsh/localtime_r.html> and
+   <http://www.opengroup.org/susv3xsh/gmtime_r.html>.  */
+# if @GNULIB_TIME_R@
+#  if @REPLACE_LOCALTIME_R@
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#    undef localtime_r
+#    define localtime_r rpl_localtime_r
+#   endif
+_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
+                                             struct tm *restrict __result)
+                                            _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
+                                             struct tm *restrict __result));
+#  else
+#   if ! @HAVE_DECL_LOCALTIME_R@
+_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
+                                             struct tm *restrict __result)
+                                            _GL_ARG_NONNULL ((1, 2)));
+#   endif
+_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
+                                             struct tm *restrict __result));
+#  endif
+#  if @HAVE_DECL_LOCALTIME_R@
+_GL_CXXALIASWARN (localtime_r);
+#  endif
+#  if @REPLACE_LOCALTIME_R@
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#    undef gmtime_r
+#    define gmtime_r rpl_gmtime_r
+#   endif
+_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
+                                          struct tm *restrict __result)
+                                         _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
+                                          struct tm *restrict __result));
+#  else
+#   if ! @HAVE_DECL_LOCALTIME_R@
+_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
+                                          struct tm *restrict __result)
+                                         _GL_ARG_NONNULL ((1, 2)));
+#   endif
+_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
+                                          struct tm *restrict __result));
+#  endif
+#  if @HAVE_DECL_LOCALTIME_R@
+_GL_CXXALIASWARN (gmtime_r);
+#  endif
+# endif
+
+/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
+   the resulting broken-down time into TM.  See
+   <http://www.opengroup.org/susv3xsh/strptime.html>.  */
+# if @GNULIB_STRPTIME@
+#  if ! @HAVE_STRPTIME@
+_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
+                                     char const *restrict __format,
+                                     struct tm *restrict __tm)
+                                    _GL_ARG_NONNULL ((1, 2, 3)));
+#  endif
+_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
+                                     char const *restrict __format,
+                                     struct tm *restrict __tm));
+_GL_CXXALIASWARN (strptime);
+# endif
+
+/* Convert TM to a time_t value, assuming UTC.  */
+# if @GNULIB_TIMEGM@
+#  if @REPLACE_TIMEGM@
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#    undef timegm
+#    define timegm rpl_timegm
+#   endif
+_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
+#  else
+#   if ! @HAVE_TIMEGM@
+_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
+#   endif
+_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
+#  endif
+_GL_CXXALIASWARN (timegm);
+# endif
+
+/* Encourage applications to avoid unsafe functions that can overrun
+   buffers when given outlandish struct tm values.  Portable
+   applications should use strftime (or even sprintf) instead.  */
+# if defined GNULIB_POSIXCHECK
+#  undef asctime
+_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
+                 "better use strftime (or even sprintf) instead");
+# endif
+# if defined GNULIB_POSIXCHECK
+#  undef asctime_r
+_GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - "
+                 "better use strftime (or even sprintf) instead");
+# endif
+# if defined GNULIB_POSIXCHECK
+#  undef ctime
+_GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - "
+                 "better use strftime (or even sprintf) instead");
+# endif
+# if defined GNULIB_POSIXCHECK
+#  undef ctime_r
+_GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - "
+                 "better use strftime (or even sprintf) instead");
+# endif
+
+#endif
diff --git a/gl/unistd.in.h b/gl/unistd.in.h
index fdf0fca..660094a 100644
--- a/gl/unistd.in.h
+++ b/gl/unistd.in.h
@@ -1,5 +1,5 @@
 /* Substitute for and wrapper around <unistd.h>.
-   Copyright (C) 2003-2011 Free Software Foundation, Inc.
+   Copyright (C) 2003-2012 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
@@ -75,16 +75,27 @@
 #endif
 
 /* mingw fails to declare _exit in <unistd.h>.  */
-/* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>.  */
+/* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
+   <unistd.h>.  */
 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>.  */
 /* But avoid namespace pollution on glibc systems.  */
 #ifndef __GLIBC__
 # include <stdlib.h>
 #endif
 
-/* mingw declares getcwd in <io.h>, not in <unistd.h>.  */
-#if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \
+/* Native Windows platforms declare chdir, getcwd, rmdir in
+   <io.h> and/or <direct.h>, not in <unistd.h>.
+   They also declare access(), chmod(), close(), dup(), dup2(), isatty(),
+   lseek(), read(), unlink(), write() in <io.h>.  */
+#if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \
+      || defined GNULIB_POSIXCHECK) \
      && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
+# include <io.h>     /* mingw32, mingw64 */
+# include <direct.h> /* mingw64, MSVC 9 */
+#elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
+       || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ 
\
+       || defined GNULIB_POSIXCHECK) \
+      && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
 # include <io.h>
 #endif
 
@@ -97,6 +108,12 @@
 # include <netdb.h>
 #endif
 
+/* MSVC defines off_t in <sys/types.h>.  */
+#if address@hidden@
+/* Get off_t.  */
+# include <sys/types.h>
+#endif
+
 #if (@GNULIB_READ@ || @GNULIB_WRITE@ \
      || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
      || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
@@ -117,78 +134,77 @@
 /* The definition of _GL_WARN_ON_USE is copied here.  */
 
 
-#if @GNULIB_GETHOSTNAME@
-/* Get all possible declarations of gethostname().  */
-# if @UNISTD_H_HAVE_WINSOCK2_H@
-#  if !defined address@hidden@_SYS_SOCKET_H
-#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#    undef socket
-#    define socket              socket_used_without_including_sys_socket_h
-#    undef connect
-#    define connect             connect_used_without_including_sys_socket_h
-#    undef accept
-#    define accept              accept_used_without_including_sys_socket_h
-#    undef bind
-#    define bind                bind_used_without_including_sys_socket_h
-#    undef getpeername
-#    define getpeername         getpeername_used_without_including_sys_socket_h
-#    undef getsockname
-#    define getsockname         getsockname_used_without_including_sys_socket_h
-#    undef getsockopt
-#    define getsockopt          getsockopt_used_without_including_sys_socket_h
-#    undef listen
-#    define listen              listen_used_without_including_sys_socket_h
-#    undef recv
-#    define recv                recv_used_without_including_sys_socket_h
-#    undef send
-#    define send                send_used_without_including_sys_socket_h
-#    undef recvfrom
-#    define recvfrom            recvfrom_used_without_including_sys_socket_h
-#    undef sendto
-#    define sendto              sendto_used_without_including_sys_socket_h
-#    undef setsockopt
-#    define setsockopt          setsockopt_used_without_including_sys_socket_h
-#    undef shutdown
-#    define shutdown            shutdown_used_without_including_sys_socket_h
-#   else
-     _GL_WARN_ON_USE (socket,
-                      "socket() used without including <sys/socket.h>");
-     _GL_WARN_ON_USE (connect,
-                      "connect() used without including <sys/socket.h>");
-     _GL_WARN_ON_USE (accept,
-                      "accept() used without including <sys/socket.h>");
-     _GL_WARN_ON_USE (bind,
-                      "bind() used without including <sys/socket.h>");
-     _GL_WARN_ON_USE (getpeername,
-                      "getpeername() used without including <sys/socket.h>");
-     _GL_WARN_ON_USE (getsockname,
-                      "getsockname() used without including <sys/socket.h>");
-     _GL_WARN_ON_USE (getsockopt,
-                      "getsockopt() used without including <sys/socket.h>");
-     _GL_WARN_ON_USE (listen,
-                      "listen() used without including <sys/socket.h>");
-     _GL_WARN_ON_USE (recv,
-                      "recv() used without including <sys/socket.h>");
-     _GL_WARN_ON_USE (send,
-                      "send() used without including <sys/socket.h>");
-     _GL_WARN_ON_USE (recvfrom,
-                      "recvfrom() used without including <sys/socket.h>");
-     _GL_WARN_ON_USE (sendto,
-                      "sendto() used without including <sys/socket.h>");
-     _GL_WARN_ON_USE (setsockopt,
-                      "setsockopt() used without including <sys/socket.h>");
-     _GL_WARN_ON_USE (shutdown,
-                      "shutdown() used without including <sys/socket.h>");
-#   endif
+/* Hide some function declarations from <winsock2.h>.  */
+
+#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
+# if !defined address@hidden@_SYS_SOCKET_H
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef socket
+#   define socket              socket_used_without_including_sys_socket_h
+#   undef connect
+#   define connect             connect_used_without_including_sys_socket_h
+#   undef accept
+#   define accept              accept_used_without_including_sys_socket_h
+#   undef bind
+#   define bind                bind_used_without_including_sys_socket_h
+#   undef getpeername
+#   define getpeername         getpeername_used_without_including_sys_socket_h
+#   undef getsockname
+#   define getsockname         getsockname_used_without_including_sys_socket_h
+#   undef getsockopt
+#   define getsockopt          getsockopt_used_without_including_sys_socket_h
+#   undef listen
+#   define listen              listen_used_without_including_sys_socket_h
+#   undef recv
+#   define recv                recv_used_without_including_sys_socket_h
+#   undef send
+#   define send                send_used_without_including_sys_socket_h
+#   undef recvfrom
+#   define recvfrom            recvfrom_used_without_including_sys_socket_h
+#   undef sendto
+#   define sendto              sendto_used_without_including_sys_socket_h
+#   undef setsockopt
+#   define setsockopt          setsockopt_used_without_including_sys_socket_h
+#   undef shutdown
+#   define shutdown            shutdown_used_without_including_sys_socket_h
+#  else
+    _GL_WARN_ON_USE (socket,
+                     "socket() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (connect,
+                     "connect() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (accept,
+                     "accept() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (bind,
+                     "bind() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (getpeername,
+                     "getpeername() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (getsockname,
+                     "getsockname() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (getsockopt,
+                     "getsockopt() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (listen,
+                     "listen() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (recv,
+                     "recv() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (send,
+                     "send() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (recvfrom,
+                     "recvfrom() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (sendto,
+                     "sendto() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (setsockopt,
+                     "setsockopt() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (shutdown,
+                     "shutdown() used without including <sys/socket.h>");
 #  endif
-#  if !defined address@hidden@_SYS_SELECT_H
-#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#    undef select
-#    define select              select_used_without_including_sys_select_h
-#   else
-     _GL_WARN_ON_USE (select,
-                      "select() used without including <sys/select.h>");
-#   endif
+# endif
+# if !defined address@hidden@_SYS_SELECT_H
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef select
+#   define select              select_used_without_including_sys_select_h
+#  else
+    _GL_WARN_ON_USE (select,
+                     "select() used without including <sys/select.h>");
 #  endif
 # endif
 #endif
@@ -224,12 +240,24 @@ _GL_WARN_ON_USE (access, "the access function is a 
security risk - "
 #endif
 
 
+#if @GNULIB_CHDIR@
+_GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIASWARN (chdir);
+#elif defined GNULIB_POSIXCHECK
+# undef chdir
+# if HAVE_RAW_DECL_CHDIR
+_GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - "
+                 "use gnulib module chdir for portability");
+# endif
+#endif
+
+
 #if @GNULIB_CHOWN@
 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
    to GID (if GID is not -1).  Follow symbolic links.
    Return 0 if successful, otherwise -1 and errno set.
-   See the POSIX:2001 specification
-   <http://www.opengroup.org/susv3xsh/chown.html>.  */
+   See the POSIX:2008 specification
+   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html.  */
 # if @REPLACE_CHOWN@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   undef chown
@@ -280,24 +308,32 @@ _GL_WARN_ON_USE (close, "close does not portably work on 
sockets - "
 #endif
 
 
-#if @REPLACE_DUP@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#  define dup rpl_dup
-# endif
+#if @GNULIB_DUP@
+# if @REPLACE_DUP@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define dup rpl_dup
+#  endif
 _GL_FUNCDECL_RPL (dup, int, (int oldfd));
 _GL_CXXALIAS_RPL (dup, int, (int oldfd));
-#else
+# else
 _GL_CXXALIAS_SYS (dup, int, (int oldfd));
-#endif
+# endif
 _GL_CXXALIASWARN (dup);
+#elif defined GNULIB_POSIXCHECK
+# undef dup
+# if HAVE_RAW_DECL_DUP
+_GL_WARN_ON_USE (dup, "dup is unportable - "
+                 "use gnulib module dup for portability");
+# endif
+#endif
 
 
 #if @GNULIB_DUP2@
 /* Copy the file descriptor OLDFD into file descriptor NEWFD.  Do nothing if
    NEWFD = OLDFD, otherwise close NEWFD first if it is open.
    Return newfd if successful, otherwise -1 and errno set.
-   See the POSIX:2001 specification
-   <http://www.opengroup.org/susv3xsh/dup2.html>.  */
+   See the POSIX:2008 specification
+   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>.  */
 # if @REPLACE_DUP2@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   define dup2 rpl_dup2
@@ -426,8 +462,8 @@ _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
 /* Change the process' current working directory to the directory on which
    the given file descriptor is open.
    Return 0 if successful, otherwise -1 and errno set.
-   See the POSIX:2001 specification
-   <http://www.opengroup.org/susv3xsh/fchdir.html>.  */
+   See the POSIX:2008 specification
+   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>.  */
 # if ! @HAVE_FCHDIR@
 _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
 
@@ -484,11 +520,30 @@ _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
 #endif
 
 
-#if @GNULIB_FSYNC@
+#if @GNULIB_FDATASYNC@
 /* Synchronize changes to a file.
    Return 0 if successful, otherwise -1 and errno set.
-   See POSIX:2001 specification
-   <http://www.opengroup.org/susv3xsh/fsync.html>.  */
+   See POSIX:2008 specification
+   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. 
 */
+# if address@hidden@ || address@hidden@
+_GL_FUNCDECL_SYS (fdatasync, int, (int fd));
+# endif
+_GL_CXXALIAS_SYS (fdatasync, int, (int fd));
+_GL_CXXALIASWARN (fdatasync);
+#elif defined GNULIB_POSIXCHECK
+# undef fdatasync
+# if HAVE_RAW_DECL_FDATASYNC
+_GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - "
+                 "use gnulib module fdatasync for portability");
+# endif
+#endif
+
+
+#if @GNULIB_FSYNC@
+/* Synchronize changes, including metadata, to a file.
+   Return 0 if successful, otherwise -1 and errno set.
+   See POSIX:2008 specification
+   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>.  */
 # if address@hidden@
 _GL_FUNCDECL_SYS (fsync, int, (int fd));
 # endif
@@ -506,8 +561,8 @@ _GL_WARN_ON_USE (fsync, "fsync is unportable - "
 #if @GNULIB_FTRUNCATE@
 /* Change the size of the file to which FD is opened to become equal to LENGTH.
    Return 0 if successful, otherwise -1 and errno set.
-   See the POSIX:2001 specification
-   <http://www.opengroup.org/susv3xsh/ftruncate.html>.  */
+   See the POSIX:2008 specification
+   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. 
 */
 # if address@hidden@
 _GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
 # endif
@@ -527,8 +582,8 @@ _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
    of BUF.
    Return BUF if successful, or NULL if the directory couldn't be determined
    or SIZE was too small.
-   See the POSIX:2001 specification
-   <http://www.opengroup.org/susv3xsh/getcwd.html>.
+   See the POSIX:2008 specification
+   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
    Additionally, the gnulib module 'getcwd' guarantees the following GNU
    extension: If BUF is NULL, an array is allocated with 'malloc'; the array
    is SIZE bytes long, unless SIZE == 0, in which case it is as big as
@@ -887,12 +942,33 @@ _GL_WARN_ON_USE (group_member, "group_member is 
unportable - "
 #endif
 
 
+#if @GNULIB_ISATTY@
+# if @REPLACE_ISATTY@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef isatty
+#   define isatty rpl_isatty
+#  endif
+_GL_FUNCDECL_RPL (isatty, int, (int fd));
+_GL_CXXALIAS_RPL (isatty, int, (int fd));
+# else
+_GL_CXXALIAS_SYS (isatty, int, (int fd));
+# endif
+_GL_CXXALIASWARN (isatty);
+#elif defined GNULIB_POSIXCHECK
+# undef isatty
+# if HAVE_RAW_DECL_ISATTY
+_GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - "
+                 "use gnulib module isatty for portability");
+# endif
+#endif
+
+
 #if @GNULIB_LCHOWN@
 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
    to GID (if GID is not -1).  Do not follow symbolic links.
    Return 0 if successful, otherwise -1 and errno set.
-   See the POSIX:2001 specification
-   <http://www.opengroup.org/susv3xsh/lchown.html>.  */
+   See the POSIX:2008 specification
+   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>.  */
 # if @REPLACE_LCHOWN@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   undef lchown
@@ -921,8 +997,8 @@ _GL_WARN_ON_USE (lchown, "lchown is unportable to 
pre-POSIX.1-2001 systems - "
 #if @GNULIB_LINK@
 /* Create a new hard link for an existing file.
    Return 0 if successful, otherwise -1 and errno set.
-   See POSIX:2001 specification
-   <http://www.opengroup.org/susv3xsh/link.html>.  */
+   See POSIX:2008 specification
+   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>.  */
 # if @REPLACE_LINK@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   define link rpl_link
@@ -987,8 +1063,8 @@ _GL_WARN_ON_USE (linkat, "linkat is unportable - "
 #if @GNULIB_LSEEK@
 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
    Return the new offset if successful, otherwise -1 and errno set.
-   See the POSIX:2001 specification
-   <http://www.opengroup.org/susv3xsh/lseek.html>.  */
+   See the POSIX:2008 specification
+   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>.  */
 # if @REPLACE_LSEEK@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   define lseek rpl_lseek
@@ -1058,8 +1134,9 @@ _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
 #if @GNULIB_PREAD@
 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
    Return the number of bytes placed into BUF if successful, otherwise
-   set errno and return -1.  0 indicates EOF.  See the POSIX:2001
-   specification <http://www.opengroup.org/susv3xsh/pread.html>.  */
+   set errno and return -1.  0 indicates EOF.
+   See the POSIX:2008 specification
+   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>.  */
 # if @REPLACE_PREAD@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   undef pread
@@ -1093,8 +1170,8 @@ _GL_WARN_ON_USE (pread, "pread is unportable - "
 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
    Return the number of bytes written if successful, otherwise
    set errno and return -1.  0 indicates nothing written.  See the
-   POSIX:2001 specification
-   <http://www.opengroup.org/susv3xsh/pwrite.html>.  */
+   POSIX:2008 specification
+   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>.  */
 # if @REPLACE_PWRITE@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   undef pwrite
@@ -1126,9 +1203,9 @@ _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
 
 #if @GNULIB_READ@
 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
-   at BUF.  See the POSIX:2001 specification
-   <http://www.opengroup.org/susv3xsh/read.html>.  */
-# if @REPLACE_READ@ && @GNULIB_UNISTD_H_NONBLOCKING@
+   at BUF.  See the POSIX:2008 specification
+   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>.  */
+# if @REPLACE_READ@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   undef read
 #   define read rpl_read
@@ -1150,8 +1227,8 @@ _GL_CXXALIASWARN (read);
 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
    bytes of it into BUF.  Return the number of bytes placed into BUF if
    successful, otherwise -1 and errno set.
-   See the POSIX:2001 specification
-   <http://www.opengroup.org/susv3xsh/readlink.html>.  */
+   See the POSIX:2008 specification
+   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>.  
*/
 # if @REPLACE_READLINK@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   define readlink rpl_readlink
@@ -1219,11 +1296,38 @@ _GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
 #endif
 
 
+#if @GNULIB_SETHOSTNAME@
+/* Set the host name of the machine.
+   The host name may or may not be fully qualified.
+
+   Put LEN bytes of NAME into the host name.
+   Return 0 if successful, otherwise, set errno and return -1.
+
+   Platforms with no ability to set the hostname return -1 and set
+   errno = ENOSYS.  */
+# if address@hidden@ || address@hidden@
+_GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len)
+                                    _GL_ARG_NONNULL ((1)));
+# endif
+/* Need to cast, because on Solaris 11 2011-10, MacOS X 10.5, IRIX 6.5
+   and FreeBSD 6.4 the second parameter is int.  On Solaris 11
+   2011-10, the first parameter is not const.  */
+_GL_CXXALIAS_SYS_CAST (sethostname, int, (const char *name, size_t len));
+_GL_CXXALIASWARN (sethostname);
+#elif defined GNULIB_POSIXCHECK
+# undef sethostname
+# if HAVE_RAW_DECL_SETHOSTNAME
+_GL_WARN_ON_USE (sethostname, "sethostname is unportable - "
+                 "use gnulib module sethostname for portability");
+# endif
+#endif
+
+
 #if @GNULIB_SLEEP@
 /* Pause the execution of the current thread for N seconds.
    Returns the number of seconds left to sleep.
-   See the POSIX:2001 specification
-   <http://www.opengroup.org/susv3xsh/sleep.html>.  */
+   See the POSIX:2008 specification
+   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>.  */
 # if @REPLACE_SLEEP@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   undef sleep
@@ -1372,7 +1476,7 @@ _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
 /* Pause the execution of the current thread for N microseconds.
    Returns 0 on completion, or -1 on range error.
    See the POSIX:2001 specification
-   <http://www.opengroup.org/susv3xsh/sleep.html>.  */
+   <http://www.opengroup.org/susv3xsh/usleep.html>.  */
 # if @REPLACE_USLEEP@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   undef usleep
@@ -1398,9 +1502,9 @@ _GL_WARN_ON_USE (usleep, "usleep is unportable - "
 
 #if @GNULIB_WRITE@
 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
-   See the POSIX:2001 specification
-   <http://www.opengroup.org/susv3xsh/write.html>.  */
-# if @REPLACE_WRITE@ && (@GNULIB_UNISTD_H_NONBLOCKING@ || 
@GNULIB_UNISTD_H_SIGPIPE@)
+   See the POSIX:2008 specification
+   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>.  */
+# if @REPLACE_WRITE@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   undef write
 #   define write rpl_write
diff --git a/gl/unistr.in.h b/gl/unistr.in.h
index 0330cf8..479075e 100644
--- a/gl/unistr.in.h
+++ b/gl/unistr.in.h
@@ -1,5 +1,5 @@
 /* Elementary Unicode string functions.
-   Copyright (C) 2001-2002, 2005-2011 Free Software Foundation, Inc.
+   Copyright (C) 2001-2002, 2005-2012 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
diff --git a/gl/unistr/u8-mbtoucr.c b/gl/unistr/u8-mbtoucr.c
index f658d67..8bc59d7 100644
--- a/gl/unistr/u8-mbtoucr.c
+++ b/gl/unistr/u8-mbtoucr.c
@@ -1,5 +1,5 @@
 /* Look at first character in UTF-8 string, returning an error code.
-   Copyright (C) 1999-2002, 2006-2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 1999-2002, 2006-2007, 2009-2012 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2001.
 
    This program is free software: you can redistribute it and/or modify it
diff --git a/gl/unistr/u8-uctomb-aux.c b/gl/unistr/u8-uctomb-aux.c
index cc9ed99..5ee212b 100644
--- a/gl/unistr/u8-uctomb-aux.c
+++ b/gl/unistr/u8-uctomb-aux.c
@@ -1,5 +1,5 @@
 /* Conversion UCS-4 to UTF-8.
-   Copyright (C) 2002, 2006-2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2006-2007, 2009-2012 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2002.
 
    This program is free software: you can redistribute it and/or modify it
diff --git a/gl/unistr/u8-uctomb.c b/gl/unistr/u8-uctomb.c
index ba11dc8..e56e4a2 100644
--- a/gl/unistr/u8-uctomb.c
+++ b/gl/unistr/u8-uctomb.c
@@ -1,5 +1,5 @@
 /* Store a character in UTF-8 string.
-   Copyright (C) 2002, 2005-2006, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2005-2006, 2009-2012 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2002.
 
    This program is free software: you can redistribute it and/or modify it
diff --git a/gl/unitypes.in.h b/gl/unitypes.in.h
index 20cbf45..b1235e6 100644
--- a/gl/unitypes.in.h
+++ b/gl/unitypes.in.h
@@ -1,5 +1,5 @@
 /* Elementary types for the GNU UniString library.
-   Copyright (C) 2002, 2005-2006, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2005-2006, 2009-2012 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
diff --git a/gl/vasnprintf.c b/gl/vasnprintf.c
index 3f2e91d..297eb20 100644
--- a/gl/vasnprintf.c
+++ b/gl/vasnprintf.c
@@ -1,5 +1,5 @@
 /* vsprintf with automatic memory allocation.
-   Copyright (C) 1999, 2002-2011 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2002-2012 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
@@ -553,32 +553,61 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
       size_t s;
       {
         mp_limb_t msd = b_ptr[b_len - 1]; /* = b[n-1], > 0 */
-        s = 31;
-        if (msd >= 0x10000)
-          {
-            msd = msd >> 16;
-            s -= 16;
-          }
-        if (msd >= 0x100)
-          {
-            msd = msd >> 8;
-            s -= 8;
-          }
-        if (msd >= 0x10)
-          {
-            msd = msd >> 4;
-            s -= 4;
-          }
-        if (msd >= 0x4)
+        /* Determine s = GMP_LIMB_BITS - integer_length (msd).
+           Code copied from gnulib's integer_length.c.  */
+# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+        s = __builtin_clz (msd);
+# else
+#  if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT
+        if (GMP_LIMB_BITS <= DBL_MANT_BIT)
           {
-            msd = msd >> 2;
-            s -= 2;
+            /* Use 'double' operations.
+               Assumes an IEEE 754 'double' implementation.  */
+#   define DBL_EXP_MASK ((DBL_MAX_EXP - DBL_MIN_EXP) | 7)
+#   define DBL_EXP_BIAS (DBL_EXP_MASK / 2 - 1)
+#   define NWORDS \
+     ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
+            union { double value; unsigned int word[NWORDS]; } m;
+
+            /* Use a single integer to floating-point conversion.  */
+            m.value = msd;
+
+            s = GMP_LIMB_BITS
+                - (((m.word[DBL_EXPBIT0_WORD] >> DBL_EXPBIT0_BIT) & 
DBL_EXP_MASK)
+                   - DBL_EXP_BIAS);
           }
-        if (msd >= 0x2)
+        else
+#   undef NWORDS
+#  endif
           {
-            msd = msd >> 1;
-            s -= 1;
+            s = 31;
+            if (msd >= 0x10000)
+              {
+                msd = msd >> 16;
+                s -= 16;
+              }
+            if (msd >= 0x100)
+              {
+                msd = msd >> 8;
+                s -= 8;
+              }
+            if (msd >= 0x10)
+              {
+                msd = msd >> 4;
+                s -= 4;
+              }
+            if (msd >= 0x4)
+              {
+                msd = msd >> 2;
+                s -= 2;
+              }
+            if (msd >= 0x2)
+              {
+                msd = msd >> 1;
+                s -= 1;
+              }
           }
+# endif
       }
       /* 0 <= s < GMP_LIMB_BITS.
          Copy b, shifting it left by s bits.  */
@@ -885,9 +914,9 @@ decode_long_double (long double x, int *ep, mpn_t *mp)
   y = frexpl (x, &exp);
   if (!(y >= 0.0L && y < 1.0L))
     abort ();
-  /* x = 2^exp * y = 2^(exp - LDBL_MANT_BIT) * (y * LDBL_MANT_BIT), and the
+  /* x = 2^exp * y = 2^(exp - LDBL_MANT_BIT) * (y * 2^LDBL_MANT_BIT), and the
      latter is an integer.  */
-  /* Convert the mantissa (y * LDBL_MANT_BIT) to a sequence of limbs.
+  /* Convert the mantissa (y * 2^LDBL_MANT_BIT) to a sequence of limbs.
      I'm not sure whether it's safe to cast a 'long double' value between
      2^31 and 2^32 to 'unsigned int', therefore play safe and cast only
      'long double' values between 0 and 2^16 (to 'unsigned int' or 'int',
@@ -973,9 +1002,9 @@ decode_double (double x, int *ep, mpn_t *mp)
   y = frexp (x, &exp);
   if (!(y >= 0.0 && y < 1.0))
     abort ();
-  /* x = 2^exp * y = 2^(exp - DBL_MANT_BIT) * (y * DBL_MANT_BIT), and the
+  /* x = 2^exp * y = 2^(exp - DBL_MANT_BIT) * (y * 2^DBL_MANT_BIT), and the
      latter is an integer.  */
-  /* Convert the mantissa (y * DBL_MANT_BIT) to a sequence of limbs.
+  /* Convert the mantissa (y * 2^DBL_MANT_BIT) to a sequence of limbs.
      I'm not sure whether it's safe to cast a 'double' value between
      2^31 and 2^32 to 'unsigned int', therefore play safe and cast only
      'double' values between 0 and 2^16 (to 'unsigned int' or 'int',
@@ -2785,7 +2814,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                   if (has_width)
                     {
 #  if ENABLE_UNISTDIO
-                      /* Outside POSIX, it's preferrable to compare the width
+                      /* Outside POSIX, it's preferable to compare the width
                          against the number of _characters_ of the converted
                          value.  */
                       w = DCHAR_MBSNLEN (result + length, characters);
@@ -4856,7 +4885,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                    in format strings in writable memory may crash the program
                    (if compiled with _FORTIFY_SOURCE=2), so we should avoid it
                    in this situation.  */
-                /* On native Win32 systems (such as mingw), we can avoid using
+                /* On native Windows systems (such as mingw), we can avoid 
using
                    %n because:
                      - Although the gl_SNPRINTF_TRUNCATION_C99 test fails,
                        snprintf does not write more than the specified number
@@ -4865,7 +4894,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                      - Although the gl_SNPRINTF_RETVAL_C99 test fails, snprintf
                        allows us to recognize the case of an insufficient
                        buffer size: it returns -1 in this case.
-                   On native Win32 systems (such as mingw) where the OS is
+                   On native Windows systems (such as mingw) where the OS is
                    Windows Vista, the use of %n in format strings by default
                    crashes the program. See
                      <http://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and
@@ -5388,7 +5417,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                       {
                         size_t w;
 # if ENABLE_UNISTDIO
-                        /* Outside POSIX, it's preferrable to compare the width
+                        /* Outside POSIX, it's preferable to compare the width
                            against the number of _characters_ of the converted
                            value.  */
                         w = DCHAR_MBSNLEN (result + length, count);
diff --git a/gl/vasnprintf.h b/gl/vasnprintf.h
index c9f4c21..fdd5868 100644
--- a/gl/vasnprintf.h
+++ b/gl/vasnprintf.h
@@ -1,5 +1,5 @@
 /* vsprintf with automatic memory allocation.
-   Copyright (C) 2002-2004, 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2002-2004, 2007-2012 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
diff --git a/gl/vasprintf.c b/gl/vasprintf.c
index 3001c26..6d1cd97 100644
--- a/gl/vasprintf.c
+++ b/gl/vasprintf.c
@@ -1,5 +1,5 @@
 /* Formatted output to strings.
-   Copyright (C) 1999, 2002, 2006-2011 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2002, 2006-2012 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
diff --git a/gl/verify.h b/gl/verify.h
index 9a8caad..cef14ad 100644
--- a/gl/verify.h
+++ b/gl/verify.h
@@ -1,6 +1,6 @@
 /* Compile-time assert-like macros.
 
-   Copyright (C) 2005-2006, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2005-2006, 2009-2012 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
@@ -21,13 +21,11 @@
 # define _GL_VERIFY_H
 
 
-/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert works as per the
-   C1X draft N1548 section 6.7.10.  This is supported by GCC 4.6.0 and
-   later, in C mode, and its use here generates easier-to-read diagnostics
-   when verify (R) fails.
+/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert works as per C11.
+   This is supported by GCC 4.6.0 and later, in C mode, and its use
+   here generates easier-to-read diagnostics when verify (R) fails.
 
-   Define _GL_HAVE_STATIC_ASSERT to 1 if static_assert works as per the
-   C++0X draft N3242 section 7.(4).
+   Define _GL_HAVE_STATIC_ASSERT to 1 if static_assert works as per C++11.
    This will likely be supported by future GCC versions, in C++ mode.
 
    Use this only with GCC.  If we were willing to slow 'configure'
@@ -188,7 +186,7 @@ template <int w>
    trailing ';'.  If R is false, fail at compile-time, preferably
    with a diagnostic that includes the string-literal DIAGNOSTIC.
 
-   Unfortunately, unlike C1X, this implementation must appear as an
+   Unfortunately, unlike C11, this implementation must appear as an
    ordinary declaration, and cannot appear inside struct { ... }.  */
 
 # ifdef _GL_HAVE__STATIC_ASSERT
@@ -205,7 +203,7 @@ template <int w>
 #   define _Static_assert(R, DIAGNOSTIC) _GL_VERIFY (R, DIAGNOSTIC)
 #  endif
 #  if !defined _GL_HAVE_STATIC_ASSERT && !defined static_assert
-#   define static_assert _Static_assert /* Draft C1X requires this #define.  */
+#   define static_assert _Static_assert /* C11 requires this #define.  */
 #  endif
 # endif
 
diff --git a/gl/version-etc.c b/gl/version-etc.c
index b8d4724..ae1e44d 100644
--- a/gl/version-etc.c
+++ b/gl/version-etc.c
@@ -1,5 +1,5 @@
 /* Print --version and bug-reporting information in a consistent format.
-   Copyright (C) 1999-2011 Free Software Foundation, Inc.
+   Copyright (C) 1999-2012 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
@@ -38,7 +38,7 @@
 # define PACKAGE PACKAGE_TARNAME
 #endif
 
-enum { COPYRIGHT_YEAR = 2011 };
+enum { COPYRIGHT_YEAR = 2012 };
 
 /* The three functions below display the --version information the
    standard way.
diff --git a/gl/version-etc.h b/gl/version-etc.h
index a9b313d..5548c02 100644
--- a/gl/version-etc.h
+++ b/gl/version-etc.h
@@ -1,5 +1,5 @@
 /* Print --version and bug-reporting information in a consistent format.
-   Copyright (C) 1999, 2003, 2005, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2003, 2005, 2009-2012 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,7 +22,7 @@
 # include <stdarg.h>
 # include <stdio.h>
 
-/* The `sentinel' attribute was added in gcc 4.0.  */
+/* The 'sentinel' attribute was added in gcc 4.0.  */
 #ifndef _GL_ATTRIBUTE_SENTINEL
 # if 4 <= __GNUC__
 #  define _GL_ATTRIBUTE_SENTINEL __attribute__ ((__sentinel__))
@@ -37,7 +37,7 @@ extern const char version_etc_copyright[];
    standard way: command and package names, package version, followed
    by a short GPLv3+ notice and a list of up to 10 author names.
 
-   If COMMAND_NAME is NULL, the PACKAGE is asumed to be the name of
+   If COMMAND_NAME is NULL, the PACKAGE is assumed to be the name of
    the program.  The formats are therefore:
 
    PACKAGE VERSION
@@ -72,7 +72,7 @@ extern void version_etc (FILE *stream,
                          /* const char *author1, ..., NULL */ ...)
   _GL_ATTRIBUTE_SENTINEL;
 
-/* Display the usual `Report bugs to' stanza */
+/* Display the usual "Report bugs to" stanza.  */
 extern void emit_bug_reporting_address (void);
 
 #endif /* VERSION_ETC_H */
diff --git a/gl/w32sock.h b/gl/w32sock.h
index 651a76d..ef0b593 100644
--- a/gl/w32sock.h
+++ b/gl/w32sock.h
@@ -1,6 +1,6 @@
-/* w32sock.h --- internal auxilliary functions for Windows socket functions
+/* w32sock.h --- internal auxiliary functions for Windows socket functions
 
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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,11 +22,14 @@
 /* Get O_RDWR and O_BINARY.  */
 #include <fcntl.h>
 
-/* Get _get_osfhandle() and _open_osfhandle().  */
+/* Get _open_osfhandle().  */
 #include <io.h>
 
+/* Get _get_osfhandle().  */
+#include "msvc-nothrow.h"
+
 #define FD_TO_SOCKET(fd)   ((SOCKET) _get_osfhandle ((fd)))
-#define SOCKET_TO_FD(fh)   (_open_osfhandle ((long) (fh), O_RDWR | O_BINARY))
+#define SOCKET_TO_FD(fh)   (_open_osfhandle ((intptr_t) (fh), O_RDWR | 
O_BINARY))
 
 static inline void
 set_winsock_errno (void)
@@ -45,15 +48,87 @@ set_winsock_errno (void)
     case WSA_INVALID_PARAMETER:
       errno = EINVAL;
       break;
-    case WSAEWOULDBLOCK:
-      errno = EWOULDBLOCK;
-      break;
     case WSAENAMETOOLONG:
       errno = ENAMETOOLONG;
       break;
     case WSAENOTEMPTY:
       errno = ENOTEMPTY;
       break;
+    case WSAEWOULDBLOCK:
+      errno = EWOULDBLOCK;
+      break;
+    case WSAEINPROGRESS:
+      errno = EINPROGRESS;
+      break;
+    case WSAEALREADY:
+      errno = EALREADY;
+      break;
+    case WSAENOTSOCK:
+      errno = ENOTSOCK;
+      break;
+    case WSAEDESTADDRREQ:
+      errno = EDESTADDRREQ;
+      break;
+    case WSAEMSGSIZE:
+      errno = EMSGSIZE;
+      break;
+    case WSAEPROTOTYPE:
+      errno = EPROTOTYPE;
+      break;
+    case WSAENOPROTOOPT:
+      errno = ENOPROTOOPT;
+      break;
+    case WSAEPROTONOSUPPORT:
+      errno = EPROTONOSUPPORT;
+      break;
+    case WSAEOPNOTSUPP:
+      errno = EOPNOTSUPP;
+      break;
+    case WSAEAFNOSUPPORT:
+      errno = EAFNOSUPPORT;
+      break;
+    case WSAEADDRINUSE:
+      errno = EADDRINUSE;
+      break;
+    case WSAEADDRNOTAVAIL:
+      errno = EADDRNOTAVAIL;
+      break;
+    case WSAENETDOWN:
+      errno = ENETDOWN;
+      break;
+    case WSAENETUNREACH:
+      errno = ENETUNREACH;
+      break;
+    case WSAENETRESET:
+      errno = ENETRESET;
+      break;
+    case WSAECONNABORTED:
+      errno = ECONNABORTED;
+      break;
+    case WSAECONNRESET:
+      errno = ECONNRESET;
+      break;
+    case WSAENOBUFS:
+      errno = ENOBUFS;
+      break;
+    case WSAEISCONN:
+      errno = EISCONN;
+      break;
+    case WSAENOTCONN:
+      errno = ENOTCONN;
+      break;
+    case WSAETIMEDOUT:
+      errno = ETIMEDOUT;
+      break;
+    case WSAECONNREFUSED:
+      errno = ECONNREFUSED;
+      break;
+    case WSAELOOP:
+      errno = ELOOP;
+      break;
+    case WSAEHOSTUNREACH:
+      errno = EHOSTUNREACH;
+      break;
     default:
       errno = (err > 10000 && err < 10025) ? err - 10000 : err;
       break;
diff --git a/gl/wchar.in.h b/gl/wchar.in.h
index 1401ae2..86c97ff 100644
--- a/gl/wchar.in.h
+++ b/gl/wchar.in.h
@@ -1,6 +1,6 @@
 /* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
 
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
@@ -98,6 +98,18 @@
 #  define WEOF -1
 # endif
 #else
+/* MSVC defines wint_t as 'unsigned short' in <crtdefs.h>.
+   This is too small: ISO C 99 section 7.24.1.(2) says that wint_t must be
+   "unchanged by default argument promotions".  Override it.  */
+# if defined _MSC_VER
+#  if !GNULIB_defined_wint_t
+#   include <crtdefs.h>
+typedef unsigned int rpl_wint_t;
+#   undef wint_t
+#   define wint_t rpl_wint_t
+#   define GNULIB_defined_wint_t 1
+#  endif
+# endif
 # ifndef WEOF
 #  define WEOF ((wint_t) -1)
 # endif
diff --git a/gl/wctype.in.h b/gl/wctype.in.h
index 9997696..3e8b025 100644
--- a/gl/wctype.in.h
+++ b/gl/wctype.in.h
@@ -1,6 +1,6 @@
 /* A substitute for ISO C99 <wctype.h>, for platforms that lack it.
 
-   Copyright (C) 2006-2011 Free Software Foundation, Inc.
+   Copyright (C) 2006-2012 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
@@ -79,6 +79,18 @@
 #  define WEOF -1
 # endif
 #else
+/* MSVC defines wint_t as 'unsigned short' in <crtdefs.h>.
+   This is too small: ISO C 99 section 7.24.1.(2) says that wint_t must be
+   "unchanged by default argument promotions".  Override it.  */
+# if defined _MSC_VER
+#  if !GNULIB_defined_wint_t
+#   include <crtdefs.h>
+typedef unsigned int rpl_wint_t;
+#   undef wint_t
+#   define wint_t rpl_wint_t
+#   define GNULIB_defined_wint_t 1
+#  endif
+# endif
 # ifndef WEOF
 #  define WEOF ((wint_t) -1)
 # endif
@@ -128,6 +140,10 @@
 #    define iswspace rpl_iswspace
 #    define iswupper rpl_iswupper
 #    define iswxdigit rpl_iswxdigit
+#   endif
+#  endif
+#  if @REPLACE_TOWLOWER@
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #    define towlower rpl_towlower
 #    define towupper rpl_towupper
 #   endif
@@ -271,7 +287,7 @@ iswxdigit
 }
 
 static inline wint_t
-#  if @REPLACE_ISWCNTRL@
+#  if @REPLACE_TOWLOWER@
 rpl_towlower
 #  else
 towlower
@@ -282,7 +298,7 @@ towlower
 }
 
 static inline wint_t
-#  if @REPLACE_ISWCNTRL@
+#  if @REPLACE_TOWLOWER@
 rpl_towupper
 #  else
 towupper
@@ -429,7 +445,7 @@ _GL_WARN_ON_USE (iswctype, "iswctype is unportable - "
 # endif
 #endif
 
-#if @REPLACE_ISWCNTRL@ || defined __MINGW32__
+#if @REPLACE_TOWLOWER@ || defined __MINGW32__
 _GL_CXXALIAS_RPL (towlower, wint_t, (wint_t wc));
 _GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc));
 #else
diff --git a/gl/xalloc-die.c b/gl/xalloc-die.c
index aba4a06..e85d6df 100644
--- a/gl/xalloc-die.c
+++ b/gl/xalloc-die.c
@@ -1,6 +1,6 @@
 /* Report a memory allocation failure and exit.
 
-   Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2011 Free Software
+   Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2012 Free Software
    Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
@@ -33,7 +33,7 @@ xalloc_die (void)
 {
   error (exit_failure, 0, "%s", _("memory exhausted"));
 
-  /* The `noreturn' cannot be given to error, since it may return if
+  /* _Noreturn cannot be given to error, since it may return if
      its first argument is 0.  To help compilers understand the
      xalloc_die does not return, call abort.  Also, the abort is a
      safety feature if exit_failure is 0 (which shouldn't happen).  */
diff --git a/gl/xalloc-oversized.h b/gl/xalloc-oversized.h
index ab19bcf..6779755 100644
--- a/gl/xalloc-oversized.h
+++ b/gl/xalloc-oversized.h
@@ -1,6 +1,6 @@
 /* xalloc-oversized.h -- memory allocation size checking
 
-   Copyright (C) 1990-2000, 2003-2004, 2006-2011 Free Software Foundation, Inc.
+   Copyright (C) 1990-2000, 2003-2004, 2006-2012 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
diff --git a/gl/xalloc.h b/gl/xalloc.h
index c1bbe7e..6f5b87e 100644
--- a/gl/xalloc.h
+++ b/gl/xalloc.h
@@ -1,6 +1,6 @@
 /* xalloc.h -- malloc with out-of-memory checking
 
-   Copyright (C) 1990-2000, 2003-2004, 2006-2011 Free Software Foundation, Inc.
+   Copyright (C) 1990-2000, 2003-2004, 2006-2012 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
@@ -27,12 +27,6 @@ extern "C" {
 # endif
 
 
-# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
-#  define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
-# else
-#  define _GL_ATTRIBUTE_NORETURN /* empty */
-# endif
-
 # if __GNUC__ >= 3
 #  define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
 # else
@@ -50,7 +44,7 @@ extern "C" {
    or by using gnulib's xalloc-die module.  This is the
    function to call when one wants the program to die because of a
    memory allocation failure.  */
-extern void xalloc_die (void) _GL_ATTRIBUTE_NORETURN;
+extern _Noreturn void xalloc_die (void);
 
 void *xmalloc (size_t s)
       _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
@@ -198,9 +192,9 @@ x2nrealloc (void *p, size_t *pn, size_t s)
         {
           /* The approximate size to use for initial small allocation
              requests, when the invoking code specifies an old size of
-             zero.  64 bytes is the largest "small" request for the
-             GNU C library malloc.  */
-          enum { DEFAULT_MXFAST = 64 };
+             zero.  This is the largest "small" request for the GNU C
+             library malloc.  */
+          enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 };
 
           n = DEFAULT_MXFAST / s;
           n += !n;
diff --git a/gl/xmalloc.c b/gl/xmalloc.c
index 08c30fb..3b5f86c 100644
--- a/gl/xmalloc.c
+++ b/gl/xmalloc.c
@@ -1,6 +1,6 @@
 /* xmalloc.c -- malloc with out of memory checking
 
-   Copyright (C) 1990-2000, 2002-2006, 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 1990-2000, 2002-2006, 2008-2012 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
diff --git a/gl/xsize.h b/gl/xsize.h
index 6505c42..4c1e615 100644
--- a/gl/xsize.h
+++ b/gl/xsize.h
@@ -1,6 +1,6 @@
 /* xsize.h -- Checked size_t computations.
 
-   Copyright (C) 2003, 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2008-2012 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
diff --git a/gltests/Makefile.am b/gltests/Makefile.am
index cf22d2a..91a6591 100644
--- a/gltests/Makefile.am
+++ b/gltests/Makefile.am
@@ -1,11 +1,23 @@
 ## DO NOT EDIT! GENERATED AUTOMATICALLY!
 ## Process this file with automake to produce Makefile.in.
-# Copyright (C) 2002-2011 Free Software Foundation, Inc.
+# Copyright (C) 2002-2012 Free Software Foundation, Inc.
 #
-# This file is free software, distributed under the terms of the GNU
-# General Public License.  As a special exception to the GNU General
-# Public License, this file may be distributed as part of a program
-# that contains a configuration script generated by Autoconf, under
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception to the GNU General Public License,
+# this file may be distributed as part of a program that
+# contains a configuration script generated by Autoconf, under
 # the same distribution terms as the rest of that program.
 #
 # Generated by gnulib-tool.
@@ -55,14 +67,14 @@ EXTRA_libtests_a_SOURCES += accept.c
 
 ## end   gnulib module accept
 
-## begin gnulib module alignof-tests
-
-TESTS += test-alignof
-check_PROGRAMS += test-alignof
+## begin gnulib module accept-tests
 
-EXTRA_DIST += test-alignof.c
+TESTS += test-accept
+check_PROGRAMS += test-accept
+test_accept_LDADD = $(LDADD) @LIBSOCKET@
+EXTRA_DIST += test-accept.c signature.h macros.h
 
-## end   gnulib module alignof-tests
+## end   gnulib module accept-tests
 
 ## begin gnulib module alloca-opt-tests
 
@@ -73,30 +85,6 @@ EXTRA_DIST += test-alloca-opt.c
 
 ## end   gnulib module alloca-opt-tests
 
-## begin gnulib module arg-nonnull
-
-# The BUILT_SOURCES created by this Makefile snippet are not used via #include
-# statements but through direct file reference. Therefore this snippet must be
-# present in all Makefile.am that need it. This is ensured by the applicability
-# 'all' defined above.
-
-BUILT_SOURCES += arg-nonnull.h
-# The arg-nonnull.h that gets inserted into generated .h files is the same as
-# build-aux/arg-nonnull.h, except that it has the copyright header cut off.
-arg-nonnull.h: $(top_srcdir)/lib/build-aux/arg-nonnull.h
-       $(AM_V_GEN)rm -f address@hidden $@ && \
-       sed -n -e '/GL_ARG_NONNULL/,$$p' \
-         < $(top_srcdir)/lib/build-aux/arg-nonnull.h \
-         > address@hidden && \
-       mv address@hidden $@
-MOSTLYCLEANFILES += arg-nonnull.h arg-nonnull.h-t
-
-ARG_NONNULL_H=arg-nonnull.h
-
-EXTRA_DIST += $(top_srcdir)/lib/build-aux/arg-nonnull.h
-
-## end   gnulib module arg-nonnull
-
 ## begin gnulib module arpa_inet-tests
 
 TESTS += test-arpa_inet
@@ -129,6 +117,15 @@ EXTRA_libtests_a_SOURCES += bind.c
 
 ## end   gnulib module bind
 
+## begin gnulib module bind-tests
+
+TESTS += test-bind
+check_PROGRAMS += test-bind
+test_bind_LDADD = $(LDADD) @LIBSOCKET@ $(INET_PTON_LIB)
+EXTRA_DIST += test-bind.c signature.h macros.h
+
+## end   gnulib module bind-tests
+
 ## begin gnulib module btowc
 
 
@@ -148,30 +145,6 @@ EXTRA_DIST += test-btowc1.sh test-btowc2.sh test-btowc.c 
signature.h macros.h
 
 ## end   gnulib module btowc-tests
 
-## begin gnulib module c++defs
-
-# The BUILT_SOURCES created by this Makefile snippet are not used via #include
-# statements but through direct file reference. Therefore this snippet must be
-# present in all Makefile.am that need it. This is ensured by the applicability
-# 'all' defined above.
-
-BUILT_SOURCES += c++defs.h
-# The c++defs.h that gets inserted into generated .h files is the same as
-# build-aux/c++defs.h, except that it has the copyright header cut off.
-c++defs.h: $(top_srcdir)/lib/build-aux/c++defs.h
-       $(AM_V_GEN)rm -f address@hidden $@ && \
-       sed -n -e '/_GL_CXXDEFS/,$$p' \
-         < $(top_srcdir)/lib/build-aux/c++defs.h \
-         > address@hidden && \
-       mv address@hidden $@
-MOSTLYCLEANFILES += c++defs.h c++defs.h-t
-
-CXXDEFS_H=c++defs.h
-
-EXTRA_DIST += $(top_srcdir)/lib/build-aux/c++defs.h
-
-## end   gnulib module c++defs
-
 ## begin gnulib module c-ctype-tests
 
 TESTS += test-c-ctype
@@ -190,6 +163,23 @@ EXTRA_DIST += test-c-strcase.sh test-c-strcasecmp.c 
test-c-strncasecmp.c macros.
 
 ## end   gnulib module c-strcase-tests
 
+## begin gnulib module close-tests
+
+TESTS += test-close
+check_PROGRAMS += test-close
+EXTRA_DIST += test-close.c signature.h macros.h
+
+## end   gnulib module close-tests
+
+## begin gnulib module connect-tests
+
+TESTS += test-connect
+check_PROGRAMS += test-connect
+test_connect_LDADD = $(LDADD) @LIBSOCKET@ $(INET_PTON_LIB)
+EXTRA_DIST += test-connect.c signature.h macros.h
+
+## end   gnulib module connect-tests
+
 ## begin gnulib module dosname
 
 
@@ -232,14 +222,6 @@ EXTRA_DIST += test-errno.c
 
 ## end   gnulib module errno-tests
 
-## begin gnulib module fclose-tests
-
-TESTS += test-fclose
-check_PROGRAMS += test-fclose
-EXTRA_DIST += test-fclose.c
-
-## end   gnulib module fclose-tests
-
 ## begin gnulib module fcntl-h
 
 BUILT_SOURCES += fcntl.h
@@ -283,14 +265,30 @@ EXTRA_DIST += test-fcntl-h.c
 
 ## end   gnulib module fcntl-h-tests
 
-## begin gnulib module fflush-tests
+## begin gnulib module fdopen
+
+
+EXTRA_DIST += fdopen.c
+
+EXTRA_libtests_a_SOURCES += fdopen.c
 
-TESTS += test-fflush test-fflush2.sh
-check_PROGRAMS += test-fflush test-fflush2
-MOSTLYCLEANFILES += test-fflush.txt
-EXTRA_DIST += test-fflush.c test-fflush2.sh test-fflush2.c signature.h macros.h
+## end   gnulib module fdopen
 
-## end   gnulib module fflush-tests
+## begin gnulib module fdopen-tests
+
+TESTS += test-fdopen
+check_PROGRAMS += test-fdopen
+EXTRA_DIST += test-fdopen.c signature.h macros.h
+
+## end   gnulib module fdopen-tests
+
+## begin gnulib module fgetc-tests
+
+TESTS += test-fgetc
+check_PROGRAMS += test-fgetc
+EXTRA_DIST += test-fgetc.c signature.h macros.h
+
+## end   gnulib module fgetc-tests
 
 ## begin gnulib module float-tests
 
@@ -307,23 +305,21 @@ EXTRA_DIST += fpucw.h
 
 ## end   gnulib module fpucw
 
-## begin gnulib module fpurge-tests
+## begin gnulib module fputc-tests
 
-TESTS += test-fpurge
-check_PROGRAMS += test-fpurge
-MOSTLYCLEANFILES += t-fpurge.tmp
-EXTRA_DIST += test-fpurge.c macros.h
+TESTS += test-fputc
+check_PROGRAMS += test-fputc
+EXTRA_DIST += test-fputc.c signature.h macros.h
 
-## end   gnulib module fpurge-tests
+## end   gnulib module fputc-tests
 
-## begin gnulib module freading-tests
+## begin gnulib module fread-tests
 
-TESTS += test-freading
-check_PROGRAMS += test-freading
-MOSTLYCLEANFILES += t-freading.tmp
-EXTRA_DIST += test-freading.c macros.h
+TESTS += test-fread
+check_PROGRAMS += test-fread
+EXTRA_DIST += test-fread.c signature.h macros.h
 
-## end   gnulib module freading-tests
+## end   gnulib module fread-tests
 
 ## begin gnulib module fseek-tests
 
@@ -335,29 +331,44 @@ EXTRA_DIST += test-fseek.c test-fseek.sh test-fseek2.sh 
signature.h macros.h
 
 ## begin gnulib module fseeko-tests
 
-TESTS += test-fseeko.sh test-fseeko2.sh
-check_PROGRAMS += test-fseeko
-EXTRA_DIST += test-fseeko.c test-fseeko.sh test-fseeko2.sh signature.h macros.h
+TESTS += test-fseeko.sh test-fseeko2.sh test-fseeko3.sh test-fseeko4.sh
+check_PROGRAMS += test-fseeko test-fseeko3 test-fseeko4
+EXTRA_DIST += test-fseeko.c test-fseeko.sh test-fseeko2.sh test-fseeko3.c 
test-fseeko3.sh test-fseeko4.c test-fseeko4.sh signature.h macros.h
 
 ## end   gnulib module fseeko-tests
 
-## begin gnulib module ftell-tests
+## begin gnulib module fstat-tests
+
+TESTS += test-fstat
+check_PROGRAMS += test-fstat
+EXTRA_DIST += test-fstat.c signature.h macros.h
+
+## end   gnulib module fstat-tests
 
-TESTS += test-ftell.sh test-ftell2.sh test-ftell3
-check_PROGRAMS += test-ftell test-ftell3
-MOSTLYCLEANFILES += t-ftell3.tmp
-EXTRA_DIST += test-ftell.c test-ftell.sh test-ftell2.sh test-ftell3.c 
signature.h macros.h
+## begin gnulib module ftruncate
 
-## end   gnulib module ftell-tests
 
-## begin gnulib module ftello-tests
+EXTRA_DIST += ftruncate.c
 
-TESTS += test-ftello.sh test-ftello2.sh test-ftello3
-check_PROGRAMS += test-ftello test-ftello3
-MOSTLYCLEANFILES += t-ftello3.tmp
-EXTRA_DIST += test-ftello.c test-ftello.sh test-ftello2.sh test-ftello3.c 
signature.h macros.h
+EXTRA_libtests_a_SOURCES += ftruncate.c
 
-## end   gnulib module ftello-tests
+## end   gnulib module ftruncate
+
+## begin gnulib module ftruncate-tests
+
+TESTS += test-ftruncate.sh
+check_PROGRAMS += test-ftruncate
+EXTRA_DIST += test-ftruncate.c test-ftruncate.sh signature.h macros.h
+
+## end   gnulib module ftruncate-tests
+
+## begin gnulib module fwrite-tests
+
+TESTS += test-fwrite
+check_PROGRAMS += test-fwrite
+EXTRA_DIST += test-fwrite.c signature.h macros.h
+
+## end   gnulib module fwrite-tests
 
 ## begin gnulib module getaddrinfo-tests
 
@@ -381,6 +392,7 @@ EXTRA_libtests_a_SOURCES += getcwd-lgpl.c
 
 TESTS += test-getcwd-lgpl
 check_PROGRAMS += test-getcwd-lgpl
+test_getcwd_lgpl_LDADD = $(LDADD) $(LIBINTL)
 EXTRA_DIST += test-getcwd-lgpl.c signature.h macros.h
 
 ## end   gnulib module getcwd-lgpl-tests
@@ -513,7 +525,7 @@ BUILT_SOURCES += inttypes.h
 
 # We need the following in order to create <inttypes.h> when the system
 # doesn't have one that works with the given compiler.
-inttypes.h: inttypes.in.h $(top_builddir)/config.status $(WARN_ON_USE_H) 
$(ARG_NONNULL_H)
+inttypes.h: inttypes.in.h $(top_builddir)/config.status $(CXXDEFS_H) 
$(WARN_ON_USE_H) $(ARG_NONNULL_H)
        $(AM_V_GEN)rm -f address@hidden $@ && \
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          sed -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
@@ -534,10 +546,12 @@ inttypes.h: inttypes.in.h $(top_builddir)/config.status 
$(WARN_ON_USE_H) $(ARG_N
              -e 's/@''HAVE_DECL_IMAXDIV''@/$(HAVE_DECL_IMAXDIV)/g' \
              -e 's/@''HAVE_DECL_STRTOIMAX''@/$(HAVE_DECL_STRTOIMAX)/g' \
              -e 's/@''HAVE_DECL_STRTOUMAX''@/$(HAVE_DECL_STRTOUMAX)/g' \
+             -e 's/@''REPLACE_STRTOIMAX''@/$(REPLACE_STRTOIMAX)/g' \
              -e 's/@''INT32_MAX_LT_INTMAX_MAX''@/$(INT32_MAX_LT_INTMAX_MAX)/g' 
\
              -e 's/@''INT64_MAX_EQ_LONG_MAX''@/$(INT64_MAX_EQ_LONG_MAX)/g' \
              -e 
's/@''UINT32_MAX_LT_UINTMAX_MAX''@/$(UINT32_MAX_LT_UINTMAX_MAX)/g' \
              -e 's/@''UINT64_MAX_EQ_ULONG_MAX''@/$(UINT64_MAX_EQ_ULONG_MAX)/g' 
\
+             -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
              -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
              -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
              < $(srcdir)/inttypes.in.h; \
@@ -566,6 +580,14 @@ EXTRA_libtests_a_SOURCES += ioctl.c
 
 ## end   gnulib module ioctl
 
+## begin gnulib module ioctl-tests
+
+TESTS += test-ioctl
+check_PROGRAMS += test-ioctl
+EXTRA_DIST += test-ioctl.c signature.h macros.h
+
+## end   gnulib module ioctl-tests
+
 ## begin gnulib module listen
 
 
@@ -575,6 +597,15 @@ EXTRA_libtests_a_SOURCES += listen.c
 
 ## end   gnulib module listen
 
+## begin gnulib module listen-tests
+
+TESTS += test-listen
+check_PROGRAMS += test-listen
+test_listen_LDADD = $(LDADD) @LIBSOCKET@
+EXTRA_DIST += test-listen.c signature.h macros.h
+
+## end   gnulib module listen-tests
+
 ## begin gnulib module locale
 
 BUILT_SOURCES += locale.h
@@ -767,6 +798,21 @@ EXTRA_DIST += test-open.h test-open.c signature.h macros.h
 
 ## end   gnulib module open-tests
 
+## begin gnulib module pathmax
+
+
+EXTRA_DIST += pathmax.h
+
+## end   gnulib module pathmax
+
+## begin gnulib module pathmax-tests
+
+TESTS += test-pathmax
+check_PROGRAMS += test-pathmax
+EXTRA_DIST += test-pathmax.c
+
+## end   gnulib module pathmax-tests
+
 ## begin gnulib module perror
 
 
@@ -780,7 +826,7 @@ EXTRA_libtests_a_SOURCES += perror.c
 
 TESTS += test-perror.sh test-perror2
 check_PROGRAMS += test-perror test-perror2
-EXTRA_DIST += init.sh macros.h signature.h test-perror.c test-perror2.c 
test-perror.sh
+EXTRA_DIST += macros.h signature.h test-perror.c test-perror2.c test-perror.sh
 
 ## end   gnulib module perror-tests
 
@@ -813,8 +859,8 @@ EXTRA_DIST += test-poll-h.c
 
 TESTS += test-poll
 check_PROGRAMS += test-poll
-test_poll_LDADD = $(LDADD) @LIBSOCKET@ $(INET_PTON_LIB)
-EXTRA_DIST += signature.h test-poll.c
+test_poll_LDADD = $(LDADD) $(LIB_POLL) @LIBSOCKET@ $(INET_PTON_LIB)
+EXTRA_DIST += test-poll.c signature.h macros.h
 
 ## end   gnulib module poll-tests
 
@@ -836,6 +882,15 @@ EXTRA_DIST += test-quotearg-simple.c test-quotearg.h 
macros.h
 
 ## end   gnulib module quotearg-simple-tests
 
+## begin gnulib module recv-tests
+
+TESTS += test-recv
+check_PROGRAMS += test-recv
+test_recv_LDADD = $(LDADD) @LIBSOCKET@
+EXTRA_DIST += test-recv.c signature.h macros.h
+
+## end   gnulib module recv-tests
+
 ## begin gnulib module same-inode
 
 
@@ -848,10 +903,10 @@ EXTRA_DIST += same-inode.h
 TESTS += test-select test-select-in.sh test-select-out.sh
 # test-select-stdin has to be run by hand.
 check_PROGRAMS += test-select test-select-fd test-select-stdin
-test_select_LDADD = $(LDADD) @LIBSOCKET@ $(INET_PTON_LIB)
-test_select_fd_LDADD = $(LDADD) @LIBSOCKET@
-test_select_stdin_LDADD = $(LDADD) @LIBSOCKET@
-EXTRA_DIST += macros.h signature.h test-select.c test-select-fd.c 
test-select-in.sh test-select-out.sh test-select-stdin.c
+test_select_LDADD = $(LDADD) @LIB_SELECT@ @LIBSOCKET@ $(INET_PTON_LIB)
+test_select_fd_LDADD = $(LDADD) @LIB_SELECT@
+test_select_stdin_LDADD = $(LDADD) @LIB_SELECT@
+EXTRA_DIST += macros.h signature.h test-select.c test-select.h 
test-select-fd.c test-select-in.sh test-select-out.sh test-select-stdin.c
 
 ## end   gnulib module select-tests
 
@@ -903,6 +958,138 @@ EXTRA_libtests_a_SOURCES += setsockopt.c
 
 ## end   gnulib module setsockopt
 
+## begin gnulib module setsockopt-tests
+
+TESTS += test-setsockopt
+check_PROGRAMS += test-setsockopt
+test_setsockopt_LDADD = $(LDADD) @LIBSOCKET@
+EXTRA_DIST += test-setsockopt.c signature.h macros.h
+
+## end   gnulib module setsockopt-tests
+
+## begin gnulib module shutdown-tests
+
+TESTS += test-shutdown
+check_PROGRAMS += test-shutdown
+test_shutdown_LDADD = $(LDADD) @LIBSOCKET@
+EXTRA_DIST += test-shutdown.c signature.h macros.h
+
+## end   gnulib module shutdown-tests
+
+## begin gnulib module signal-h-tests
+
+TESTS += test-signal-h
+check_PROGRAMS += test-signal-h
+EXTRA_DIST += test-signal-h.c
+
+## end   gnulib module signal-h-tests
+
+## begin gnulib module snippet/_Noreturn
+
+# Because this Makefile snippet defines a variable used by other
+# gnulib Makefile snippets, it must be present in all Makefile.am that
+# need it. This is ensured by the applicability 'all' defined above.
+
+_NORETURN_H=$(top_srcdir)/lib/build-aux/snippet/_Noreturn.h
+
+EXTRA_DIST += $(top_srcdir)/lib/build-aux/snippet/_Noreturn.h
+
+## end   gnulib module snippet/_Noreturn
+
+## begin gnulib module snippet/arg-nonnull
+
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+
+BUILT_SOURCES += arg-nonnull.h
+# The arg-nonnull.h that gets inserted into generated .h files is the same as
+# build-aux/snippet/arg-nonnull.h, except that it has the copyright header cut
+# off.
+arg-nonnull.h: $(top_srcdir)/lib/build-aux/snippet/arg-nonnull.h
+       $(AM_V_GEN)rm -f address@hidden $@ && \
+       sed -n -e '/GL_ARG_NONNULL/,$$p' \
+         < $(top_srcdir)/lib/build-aux/snippet/arg-nonnull.h \
+         > address@hidden && \
+       mv address@hidden $@
+MOSTLYCLEANFILES += arg-nonnull.h arg-nonnull.h-t
+
+ARG_NONNULL_H=arg-nonnull.h
+
+EXTRA_DIST += $(top_srcdir)/lib/build-aux/snippet/arg-nonnull.h
+
+## end   gnulib module snippet/arg-nonnull
+
+## begin gnulib module snippet/c++defs
+
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+
+BUILT_SOURCES += c++defs.h
+# The c++defs.h that gets inserted into generated .h files is the same as
+# build-aux/snippet/c++defs.h, except that it has the copyright header cut off.
+c++defs.h: $(top_srcdir)/lib/build-aux/snippet/c++defs.h
+       $(AM_V_GEN)rm -f address@hidden $@ && \
+       sed -n -e '/_GL_CXXDEFS/,$$p' \
+         < $(top_srcdir)/lib/build-aux/snippet/c++defs.h \
+         > address@hidden && \
+       mv address@hidden $@
+MOSTLYCLEANFILES += c++defs.h c++defs.h-t
+
+CXXDEFS_H=c++defs.h
+
+EXTRA_DIST += $(top_srcdir)/lib/build-aux/snippet/c++defs.h
+
+## end   gnulib module snippet/c++defs
+
+## begin gnulib module snippet/unused-parameter
+
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+
+BUILT_SOURCES += unused-parameter.h
+# The unused-parameter.h that gets inserted into generated .h files is the same
+# as build-aux/snippet/unused-parameter.h, except that it has the copyright
+# header cut off.
+unused-parameter.h: $(top_srcdir)/lib/build-aux/snippet/unused-parameter.h
+       $(AM_V_GEN)rm -f address@hidden $@ && \
+       sed -n -e '/GL_UNUSED_PARAMETER/,$$p' \
+         < $(top_srcdir)/lib/build-aux/snippet/unused-parameter.h \
+         > address@hidden && \
+       mv address@hidden $@
+MOSTLYCLEANFILES += unused-parameter.h unused-parameter.h-t
+
+UNUSED_PARAMETER_H=unused-parameter.h
+
+EXTRA_DIST += $(top_srcdir)/lib/build-aux/snippet/unused-parameter.h
+
+## end   gnulib module snippet/unused-parameter
+
+## begin gnulib module snippet/warn-on-use
+
+BUILT_SOURCES += warn-on-use.h
+# The warn-on-use.h that gets inserted into generated .h files is the same as
+# build-aux/snippet/warn-on-use.h, except that it has the copyright header cut
+# off.
+warn-on-use.h: $(top_srcdir)/lib/build-aux/snippet/warn-on-use.h
+       $(AM_V_GEN)rm -f address@hidden $@ && \
+       sed -n -e '/^.ifndef/,$$p' \
+         < $(top_srcdir)/lib/build-aux/snippet/warn-on-use.h \
+         > address@hidden && \
+       mv address@hidden $@
+MOSTLYCLEANFILES += warn-on-use.h warn-on-use.h-t
+
+WARN_ON_USE_H=warn-on-use.h
+
+EXTRA_DIST += $(top_srcdir)/lib/build-aux/snippet/warn-on-use.h
+
+## end   gnulib module snippet/warn-on-use
+
 ## begin gnulib module snprintf-tests
 
 TESTS += test-snprintf
@@ -934,10 +1121,19 @@ EXTRA_libtests_a_SOURCES += stat.c
 
 TESTS += test-stat
 check_PROGRAMS += test-stat
+test_stat_LDADD = $(LDADD) $(LIBINTL)
 EXTRA_DIST += test-stat.h test-stat.c signature.h macros.h
 
 ## end   gnulib module stat-tests
 
+## begin gnulib module stdalign-tests
+
+TESTS += test-stdalign
+check_PROGRAMS += test-stdalign
+EXTRA_DIST += test-stdalign.c macros.h
+
+## end   gnulib module stdalign-tests
+
 ## begin gnulib module stdbool-tests
 
 TESTS += test-stdbool
@@ -1082,7 +1278,7 @@ EXTRA_DIST += test-sys_ioctl.c
 
 TESTS += test-sys_select
 check_PROGRAMS += test-sys_select
-EXTRA_DIST += test-sys_select.c
+EXTRA_DIST += test-sys_select.c signature.h
 
 ## end   gnulib module sys_select-tests
 
@@ -1094,66 +1290,6 @@ EXTRA_DIST += test-sys_socket.c
 
 ## end   gnulib module sys_socket-tests
 
-## begin gnulib module sys_stat
-
-BUILT_SOURCES += sys/stat.h
-
-# We need the following in order to create <sys/stat.h> when the system
-# has one that is incomplete.
-sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) 
$(ARG_NONNULL_H) $(WARN_ON_USE_H)
-       $(AM_V_at)$(MKDIR_P) sys
-       $(AM_V_GEN)rm -f address@hidden $@ && \
-       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
-         sed -e 's|@''GUARD_PREFIX''@|GL|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_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
-             -e 's/@''GNULIB_FCHMODAT''@/$(GNULIB_FCHMODAT)/g' \
-             -e 's/@''GNULIB_FSTATAT''@/$(GNULIB_FSTATAT)/g' \
-             -e 's/@''GNULIB_FUTIMENS''@/$(GNULIB_FUTIMENS)/g' \
-             -e 's/@''GNULIB_LCHMOD''@/$(GNULIB_LCHMOD)/g' \
-             -e 's/@''GNULIB_LSTAT''@/$(GNULIB_LSTAT)/g' \
-             -e 's/@''GNULIB_MKDIRAT''@/$(GNULIB_MKDIRAT)/g' \
-             -e 's/@''GNULIB_MKFIFO''@/$(GNULIB_MKFIFO)/g' \
-             -e 's/@''GNULIB_MKFIFOAT''@/$(GNULIB_MKFIFOAT)/g' \
-             -e 's/@''GNULIB_MKNOD''@/$(GNULIB_MKNOD)/g' \
-             -e 's/@''GNULIB_MKNODAT''@/$(GNULIB_MKNODAT)/g' \
-             -e 's/@''GNULIB_STAT''@/$(GNULIB_STAT)/g' \
-             -e 's/@''GNULIB_UTIMENSAT''@/$(GNULIB_UTIMENSAT)/g' \
-             -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \
-             -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \
-             -e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \
-             -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \
-             -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \
-             -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \
-             -e 's|@''HAVE_MKFIFO''@|$(HAVE_MKFIFO)|g' \
-             -e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \
-             -e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \
-             -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \
-             -e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \
-             -e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \
-             -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \
-             -e 's|@''REPLACE_FUTIMENS''@|$(REPLACE_FUTIMENS)|g' \
-             -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \
-             -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \
-             -e 's|@''REPLACE_MKFIFO''@|$(REPLACE_MKFIFO)|g' \
-             -e 's|@''REPLACE_MKNOD''@|$(REPLACE_MKNOD)|g' \
-             -e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \
-             -e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \
-             -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-             -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-             -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
-             < $(srcdir)/sys_stat.in.h; \
-       } > address@hidden && \
-       mv address@hidden $@
-MOSTLYCLEANFILES += sys/stat.h sys/stat.h-t
-MOSTLYCLEANDIRS += sys
-
-EXTRA_DIST += sys_stat.in.h
-
-## end   gnulib module sys_stat
-
 ## begin gnulib module sys_stat-tests
 
 TESTS += test-sys_stat
@@ -1170,6 +1306,14 @@ EXTRA_DIST += test-sys_time.c
 
 ## end   gnulib module sys_time-tests
 
+## begin gnulib module sys_types-tests
+
+TESTS += test-sys_types
+check_PROGRAMS += test-sys_types
+EXTRA_DIST += test-sys_types.c
+
+## end   gnulib module sys_types-tests
+
 ## begin gnulib module sys_uio-tests
 
 TESTS += test-sys_uio
@@ -1178,12 +1322,30 @@ EXTRA_DIST += test-sys_uio.c
 
 ## end   gnulib module sys_uio-tests
 
+## begin gnulib module test-framework-sh-tests
+
+TESTS += test-init.sh
+EXTRA_DIST += init.sh
+EXTRA_DIST += test-init.sh
+
+## end   gnulib module test-framework-sh-tests
+
 ## begin gnulib module thread
 
 libtests_a_SOURCES += glthread/thread.h glthread/thread.c
 
 ## end   gnulib module thread
 
+## begin gnulib module thread-tests
+
+TESTS += test-thread_self test-thread_create
+check_PROGRAMS += test-thread_self test-thread_create
+test_thread_self_LDADD = $(LDADD) @LIBTHREAD@
+test_thread_create_LDADD = $(LDADD) @LIBMULTITHREAD@
+EXTRA_DIST += test-thread_self.c test-thread_create.c macros.h
+
+## end   gnulib module thread-tests
+
 ## begin gnulib module threadlib
 
 libtests_a_SOURCES += glthread/threadlib.c
@@ -1192,48 +1354,6 @@ EXTRA_DIST += $(top_srcdir)/lib/build-aux/config.rpath
 
 ## end   gnulib module threadlib
 
-## begin gnulib module time
-
-BUILT_SOURCES += time.h
-
-# We need the following in order to create <time.h> when the system
-# doesn't have one that works with the given compiler.
-time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) 
$(WARN_ON_USE_H)
-       $(AM_V_GEN)rm -f address@hidden $@ && \
-       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
-         sed -e 's|@''GUARD_PREFIX''@|GL|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_TIME_H''@|$(NEXT_TIME_H)|g' \
-             -e 's/@''GNULIB_MKTIME''@/$(GNULIB_MKTIME)/g' \
-             -e 's/@''GNULIB_NANOSLEEP''@/$(GNULIB_NANOSLEEP)/g' \
-             -e 's/@''GNULIB_STRPTIME''@/$(GNULIB_STRPTIME)/g' \
-             -e 's/@''GNULIB_TIMEGM''@/$(GNULIB_TIMEGM)/g' \
-             -e 's/@''GNULIB_TIME_R''@/$(GNULIB_TIME_R)/g' \
-             -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \
-             -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \
-             -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
-             -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
-             -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
-             -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
-             -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
-             -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
-             -e 
's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g'
 \
-             -e 
's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g'
 \
-             -e 
's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
-             -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-             -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-             -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
-             < $(srcdir)/time.in.h; \
-       } > address@hidden && \
-       mv address@hidden $@
-MOSTLYCLEANFILES += time.h time.h-t
-
-EXTRA_DIST += time.in.h
-
-## end   gnulib module time
-
 ## begin gnulib module time-tests
 
 TESTS += test-time
@@ -1287,31 +1407,6 @@ EXTRA_DIST += test-unsetenv.c signature.h macros.h
 
 ## end   gnulib module unsetenv-tests
 
-## begin gnulib module unused-parameter
-
-# The BUILT_SOURCES created by this Makefile snippet are not used via #include
-# statements but through direct file reference. Therefore this snippet must be
-# present in all Makefile.am that need it. This is ensured by the applicability
-# 'all' defined above.
-
-BUILT_SOURCES += unused-parameter.h
-# The unused-parameter.h that gets inserted into generated .h files is the same
-# as build-aux/unused-parameter.h, except that it has the copyright header cut
-# off.
-unused-parameter.h: $(top_srcdir)/lib/build-aux/unused-parameter.h
-       $(AM_V_GEN)rm -f address@hidden $@ && \
-       sed -n -e '/GL_UNUSED_PARAMETER/,$$p' \
-         < $(top_srcdir)/lib/build-aux/unused-parameter.h \
-         > address@hidden && \
-       mv address@hidden $@
-MOSTLYCLEANFILES += unused-parameter.h unused-parameter.h-t
-
-UNUSED_PARAMETER_H=unused-parameter.h
-
-EXTRA_DIST += $(top_srcdir)/lib/build-aux/unused-parameter.h
-
-## end   gnulib module unused-parameter
-
 ## begin gnulib module vasnprintf-tests
 
 TESTS += test-vasnprintf
@@ -1335,7 +1430,7 @@ EXTRA_DIST += test-vasprintf.c signature.h macros.h
 TESTS += test-vc-list-files-git.sh
 TESTS += test-vc-list-files-cvs.sh
 TESTS_ENVIRONMENT += abs_aux_dir='$(abs_aux_dir)'
-EXTRA_DIST += test-vc-list-files-git.sh test-vc-list-files-cvs.sh init.sh
+EXTRA_DIST += test-vc-list-files-git.sh test-vc-list-files-cvs.sh
 
 ## end   gnulib module vc-list-files-tests
 
@@ -1344,7 +1439,7 @@ EXTRA_DIST += test-vc-list-files-git.sh 
test-vc-list-files-cvs.sh init.sh
 TESTS_ENVIRONMENT += MAKE='$(MAKE)'
 TESTS += test-verify test-verify.sh
 check_PROGRAMS += test-verify
-EXTRA_DIST += test-verify.c test-verify.sh init.sh
+EXTRA_DIST += test-verify.c test-verify.sh
 
 ## end   gnulib module verify-tests
 
@@ -1363,25 +1458,6 @@ EXTRA_DIST += test-version-etc.c test-version-etc.sh
 
 ## end   gnulib module version-etc-tests
 
-## begin gnulib module warn-on-use
-
-BUILT_SOURCES += warn-on-use.h
-# The warn-on-use.h that gets inserted into generated .h files is the same as
-# build-aux/warn-on-use.h, except that it has the copyright header cut off.
-warn-on-use.h: $(top_srcdir)/lib/build-aux/warn-on-use.h
-       $(AM_V_GEN)rm -f address@hidden $@ && \
-       sed -n -e '/^.ifndef/,$$p' \
-         < $(top_srcdir)/lib/build-aux/warn-on-use.h \
-         > address@hidden && \
-       mv address@hidden $@
-MOSTLYCLEANFILES += warn-on-use.h warn-on-use.h-t
-
-WARN_ON_USE_H=warn-on-use.h
-
-EXTRA_DIST += $(top_srcdir)/lib/build-aux/warn-on-use.h
-
-## end   gnulib module warn-on-use
-
 ## begin gnulib module wchar-tests
 
 TESTS += test-wchar
@@ -1447,7 +1523,7 @@ EXTRA_DIST += test-wctype-h.c macros.h
 TESTS += test-xalloc-die.sh
 check_PROGRAMS += test-xalloc-die
 test_xalloc_die_LDADD = $(LDADD) @LIBINTL@
-EXTRA_DIST += test-xalloc-die.c test-xalloc-die.sh init.sh
+EXTRA_DIST += test-xalloc-die.c test-xalloc-die.sh
 
 ## end   gnulib module xalloc-die-tests
 
diff --git a/gltests/accept.c b/gltests/accept.c
index 5591fa5..8775aae 100644
--- a/gltests/accept.c
+++ b/gltests/accept.c
@@ -1,6 +1,6 @@
 /* accept.c --- wrappers for Windows accept function
 
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
@@ -31,12 +31,22 @@
 int
 rpl_accept (int fd, struct sockaddr *addr, socklen_t *addrlen)
 {
-  SOCKET fh = accept (FD_TO_SOCKET (fd), addr, addrlen);
-  if (fh == INVALID_SOCKET)
+  SOCKET sock = FD_TO_SOCKET (fd);
+
+  if (sock == INVALID_SOCKET)
     {
-      set_winsock_errno ();
+      errno = EBADF;
       return -1;
     }
   else
-    return SOCKET_TO_FD (fh);
+    {
+      SOCKET fh = accept (sock, addr, addrlen);
+      if (fh == INVALID_SOCKET)
+        {
+          set_winsock_errno ();
+          return -1;
+        }
+      else
+        return SOCKET_TO_FD (fh);
+    }
 }
diff --git a/gltests/binary-io.h b/gltests/binary-io.h
index c09dbf5..824ad5b 100644
--- a/gltests/binary-io.h
+++ b/gltests/binary-io.h
@@ -1,5 +1,5 @@
 /* Binary mode I/O.
-   Copyright (C) 2001, 2003, 2005, 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2003, 2005, 2008-2012 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
diff --git a/gltests/bind.c b/gltests/bind.c
index e6d959d..0045c9d 100644
--- a/gltests/bind.c
+++ b/gltests/bind.c
@@ -1,6 +1,6 @@
 /* bind.c --- wrappers for Windows bind function
 
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
@@ -32,9 +32,18 @@ int
 rpl_bind (int fd, const struct sockaddr *sockaddr, socklen_t len)
 {
   SOCKET sock = FD_TO_SOCKET (fd);
-  int r = bind (sock, sockaddr, len);
-  if (r < 0)
-    set_winsock_errno ();
 
-  return r;
+  if (sock == INVALID_SOCKET)
+    {
+      errno = EBADF;
+      return -1;
+    }
+  else
+    {
+      int r = bind (sock, sockaddr, len);
+      if (r < 0)
+        set_winsock_errno ();
+
+      return r;
+    }
 }
diff --git a/gltests/btowc.c b/gltests/btowc.c
index 9b3908d..cec9eca 100644
--- a/gltests/btowc.c
+++ b/gltests/btowc.c
@@ -1,5 +1,5 @@
 /* Convert unibyte character to wide character.
-   Copyright (C) 2008, 2010-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2010-2012 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2008.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/gltests/dosname.h b/gltests/dosname.h
index acdd03b..0468ce4 100644
--- a/gltests/dosname.h
+++ b/gltests/dosname.h
@@ -1,6 +1,6 @@
 /* File names on MS-DOS/Windows systems.
 
-   Copyright (C) 2000-2001, 2004-2006, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2000-2001, 2004-2006, 2009-2012 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
diff --git a/gltests/dup2.c b/gltests/dup2.c
index ae546d2..f6d0f1c 100644
--- a/gltests/dup2.c
+++ b/gltests/dup2.c
@@ -1,6 +1,6 @@
 /* Duplicate an open file descriptor to a specified file descriptor.
 
-   Copyright (C) 1999, 2004-2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2004-2007, 2009-2012 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
@@ -25,22 +25,26 @@
 #include <errno.h>
 #include <fcntl.h>
 
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-/* Get declarations of the Win32 API functions.  */
-# define WIN32_LEAN_AND_MEAN
-# include <windows.h>
-#endif
-
 #if HAVE_DUP2
 
 # undef dup2
 
-int
-rpl_dup2 (int fd, int desired_fd)
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+
+/* Get declarations of the native Windows API functions.  */
+#  define WIN32_LEAN_AND_MEAN
+#  include <windows.h>
+
+#  include "msvc-inval.h"
+
+/* Get _get_osfhandle.  */
+#  include "msvc-nothrow.h"
+
+static int
+ms_windows_dup2 (int fd, int desired_fd)
 {
   int result;
-# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-  int fd_mode = -1;
+
   /* If fd is closed, mingw hangs on dup2 (fd, fd).  If fd is open,
      dup2 (fd, fd) returns 0, but all further attempts to use fd in
      future dup2 calls will hang.  */
@@ -53,6 +57,7 @@ rpl_dup2 (int fd, int desired_fd)
         }
       return fd;
     }
+
   /* Wine 1.0.1 return 0 when desired_fd is negative but not -1:
      http://bugs.winehq.org/show_bug.cgi?id=21289 */
   if (desired_fd < 0)
@@ -60,45 +65,50 @@ rpl_dup2 (int fd, int desired_fd)
       errno = EBADF;
       return -1;
     }
-# elif !defined __linux__
-  /* On Haiku, dup2 (fd, fd) mistakenly clears FD_CLOEXEC.  */
-  if (fd == desired_fd)
-    return fcntl (fd, F_GETFL) == -1 ? -1 : fd;
-# endif
-  result = dup2 (fd, desired_fd);
-# ifdef __linux__
-  /* Correct a Linux return value.
-     
<http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.30.y.git;a=commitdiff;h=2b79bc4f7ebbd5af3c8b867968f9f15602d5f802>
-   */
-  if (fd == desired_fd && result == (unsigned int) -EBADF)
+
+  TRY_MSVC_INVAL
     {
-      errno = EBADF;
-      result = -1;
+      result = dup2 (fd, desired_fd);
     }
-  /* Wine 1.0.1 puts desired_fd into binary mode when fd is in text
-     mode, so we save the old mode here.
-     http://bugs.winehq.org/show_bug.cgi?id=21291 */
-  if ((HANDLE) _get_osfhandle (fd) != (HANDLE) -1)
+  CATCH_MSVC_INVAL
     {
-      fd_mode = setmode (fd, O_BINARY);
-      setmode (fd, fd_mode);
+      errno = EBADF;
+      result = -1;
     }
-# endif
+  DONE_MSVC_INVAL;
+
   if (result == 0)
     result = desired_fd;
-  /* Correct a cygwin 1.5.x errno value.  */
-  else if (result == -1 && errno == EMFILE)
+
+  return result;
+}
+
+#  define dup2 ms_windows_dup2
+
+# endif
+
+int
+rpl_dup2 (int fd, int desired_fd)
+{
+  int result;
+
+# ifdef F_GETFL
+  /* On Linux kernels 2.6.26-2.6.29, dup2 (fd, fd) returns -EBADF.
+     On Cygwin 1.5.x, dup2 (1, 1) returns 0.
+     On Haiku, dup2 (fd, fd) mistakenly clears FD_CLOEXEC.  */
+  if (fd == desired_fd)
+    return fcntl (fd, F_GETFL) == -1 ? -1 : fd;
+# endif
+
+  result = dup2 (fd, desired_fd);
+
+  /* Correct an errno value on FreeBSD 6.1 and Cygwin 1.5.x.  */
+  if (result == -1 && errno == EMFILE)
     errno = EBADF;
 # if REPLACE_FCHDIR
   if (fd != desired_fd && result != -1)
     result = _gl_register_dup (fd, result);
 # endif
-# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-  /* Restore text mode if needed.
-     http://bugs.winehq.org/show_bug.cgi?id=21291 */
-  if (result != -1 && fd_mode != -1)
-    setmode (desired_fd, fd_mode);
-# endif
   return result;
 }
 
diff --git a/gltests/fcntl.in.h b/gltests/fcntl.in.h
index 0a07221..344bbe4 100644
--- a/gltests/fcntl.in.h
+++ b/gltests/fcntl.in.h
@@ -1,6 +1,6 @@
 /* Like <fcntl.h>, but with non-working flags defined to 0.
 
-   Copyright (C) 2006-2011 Free Software Foundation, Inc.
+   Copyright (C) 2006-2012 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
@@ -62,6 +62,12 @@
 # include <unistd.h>
 #endif
 
+/* Native Windows platforms declare open(), creat() in <io.h>.  */
+#if (@GNULIB_OPEN@ || defined GNULIB_POSIXCHECK) \
+    && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
+# include <io.h>
+#endif
+
 
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
@@ -177,12 +183,12 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
 /* Fix up the O_* macros.  */
 
 #if !defined O_DIRECT && defined O_DIRECTIO
-/* Tru64 spells it `O_DIRECTIO'.  */
+/* Tru64 spells it 'O_DIRECTIO'.  */
 # define O_DIRECT O_DIRECTIO
 #endif
 
 #if !defined O_CLOEXEC && defined O_NOINHERIT
-/* Mingw spells it `O_NOINHERIT'.  */
+/* Mingw spells it 'O_NOINHERIT'.  */
 # define O_CLOEXEC O_NOINHERIT
 #endif
 
diff --git a/gltests/fdopen.c b/gltests/fdopen.c
new file mode 100644
index 0000000..6595b16
--- /dev/null
+++ b/gltests/fdopen.c
@@ -0,0 +1,69 @@
+/* Open a stream with a given file descriptor.
+   Copyright (C) 2011-2012 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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <stdio.h>
+
+#include <errno.h>
+
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+#endif
+
+#undef fdopen
+
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+static FILE *
+fdopen_nothrow (int fd, const char *mode)
+{
+  FILE *result;
+
+  TRY_MSVC_INVAL
+    {
+      result = fdopen (fd, mode);
+    }
+  CATCH_MSVC_INVAL
+    {
+      result = NULL;
+    }
+  DONE_MSVC_INVAL;
+
+  return result;
+}
+#else
+# define fdopen_nothrow fdopen
+#endif
+
+FILE *
+rpl_fdopen (int fd, const char *mode)
+{
+  int saved_errno = errno;
+  FILE *fp;
+
+  errno = 0;
+  fp = fdopen_nothrow (fd, mode);
+  if (fp == NULL)
+    {
+      if (errno == 0)
+        errno = EBADF;
+    }
+  else
+    errno = saved_errno;
+
+  return fp;
+}
diff --git a/gltests/fpucw.h b/gltests/fpucw.h
index 07403bf..a62c51d 100644
--- a/gltests/fpucw.h
+++ b/gltests/fpucw.h
@@ -1,5 +1,5 @@
 /* Manipulating the FPU control word.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2007.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/gltests/ftruncate.c b/gltests/ftruncate.c
new file mode 100644
index 0000000..ae1e858
--- /dev/null
+++ b/gltests/ftruncate.c
@@ -0,0 +1,43 @@
+/* ftruncate emulations for native Windows.
+   This file is in the public domain.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <unistd.h>
+
+#if HAVE_CHSIZE
+
+# include <errno.h>
+# include <io.h>
+
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+#  include "msvc-inval.h"
+static inline int
+chsize_nothrow (int fd, long length)
+{
+  int result;
+
+  TRY_MSVC_INVAL
+    {
+      result = chsize (fd, length);
+    }
+  CATCH_MSVC_INVAL
+    {
+      result = -1;
+      errno = EBADF;
+    }
+  DONE_MSVC_INVAL;
+
+  return result;
+}
+#  define chsize chsize_nothrow
+# endif
+
+int
+ftruncate (int fd, off_t length)
+{
+  return chsize (fd, length);
+}
+
+#endif
diff --git a/gltests/getcwd-lgpl.c b/gltests/getcwd-lgpl.c
index 2761422..f1e821b 100644
--- a/gltests/getcwd-lgpl.c
+++ b/gltests/getcwd-lgpl.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011 Free Software Foundation, Inc.
+/* Copyright (C) 2011-2012 Free Software Foundation, Inc.
    This file is part of gnulib.
 
    This program is free software: you can redistribute it and/or modify
@@ -32,7 +32,7 @@ typedef int dummy;
    (perhaps because the absolute name was longer than PATH_MAX, or
    because of missing read/search permissions on parent directories)
    or SIZE was too small.  If successful, returns BUF.  If BUF is
-   NULL, an array is allocated with `malloc'; the array is SIZE bytes
+   NULL, an array is allocated with 'malloc'; the array is SIZE bytes
    long, unless SIZE == 0, in which case it is as big as
    necessary.  */
 
diff --git a/gltests/getpagesize.c b/gltests/getpagesize.c
index d7c1ba8..02c00fb 100644
--- a/gltests/getpagesize.c
+++ b/gltests/getpagesize.c
@@ -1,6 +1,6 @@
 /* getpagesize emulation for systems where it cannot be done in a C macro.
 
-   Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2012 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,7 +22,7 @@
 /* Specification. */
 #include <unistd.h>
 
-/* This implementation is only for native Win32 systems.  */
+/* This implementation is only for native Windows systems.  */
 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
 
 # define WIN32_LEAN_AND_MEAN
diff --git a/gltests/gettimeofday.c b/gltests/gettimeofday.c
index adfb51f..d18606a 100644
--- a/gltests/gettimeofday.c
+++ b/gltests/gettimeofday.c
@@ -1,6 +1,6 @@
 /* Provide gettimeofday for systems that don't have it or for which it's 
broken.
 
-   Copyright (C) 2001-2003, 2005-2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2001-2003, 2005-2007, 2009-2012 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
@@ -110,7 +110,18 @@ gettimeofday (struct timeval *restrict tv, void *restrict 
tz)
   struct tm save = *localtime_buffer_addr;
 # endif
 
+# if defined timeval /* 'struct timeval' overridden by gnulib?  */
+#  undef timeval
+  struct timeval otv;
+  int result = gettimeofday (&otv, (struct timezone *) tz);
+  if (result == 0)
+    {
+      tv->tv_sec = otv.tv_sec;
+      tv->tv_usec = otv.tv_usec;
+    }
+# else
   int result = gettimeofday (tv, (struct timezone *) tz);
+# endif
 
 # if GETTIMEOFDAY_CLOBBERS_LOCALTIME
   *localtime_buffer_addr = save;
diff --git a/gltests/glthread/lock.c b/gltests/glthread/lock.c
index 64dbd3f..3ab4fad 100644
--- a/gltests/glthread/lock.c
+++ b/gltests/glthread/lock.c
@@ -1,5 +1,5 @@
 /* Locking in multithreaded situations.
-   Copyright (C) 2005-2011 Free Software Foundation, Inc.
+   Copyright (C) 2005-2012 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
@@ -630,7 +630,7 @@ glthread_once_singlethreaded (gl_once_t *once_control)
 
 /* ========================================================================= */
 
-#if USE_WIN32_THREADS
+#if USE_WINDOWS_THREADS
 
 /* -------------------------- gl_lock_t datatype -------------------------- */
 
diff --git a/gltests/glthread/lock.h b/gltests/glthread/lock.h
index 6267500..02377cd 100644
--- a/gltests/glthread/lock.h
+++ b/gltests/glthread/lock.h
@@ -1,5 +1,5 @@
 /* Locking in multithreaded situations.
-   Copyright (C) 2005-2011 Free Software Foundation, Inc.
+   Copyright (C) 2005-2012 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
@@ -614,16 +614,17 @@ extern int glthread_once_singlethreaded (gl_once_t 
*once_control);
 
 /* ========================================================================= */
 
-#if USE_WIN32_THREADS
+#if USE_WINDOWS_THREADS
 
+# define WIN32_LEAN_AND_MEAN  /* avoid including junk */
 # include <windows.h>
 
 # ifdef __cplusplus
 extern "C" {
 # endif
 
-/* We can use CRITICAL_SECTION directly, rather than the Win32 Event, Mutex,
-   Semaphore types, because
+/* We can use CRITICAL_SECTION directly, rather than the native Windows Event,
+   Mutex, Semaphore types, because
      - we need only to synchronize inside a single process (address space),
        not inter-process locking,
      - we don't need to support trylock operations.  (TryEnterCriticalSection
@@ -709,9 +710,9 @@ extern int glthread_rwlock_destroy_func (gl_rwlock_t *lock);
 
 /* --------------------- gl_recursive_lock_t datatype --------------------- */
 
-/* The Win32 documentation says that CRITICAL_SECTION already implements a
-   recursive lock.  But we need not rely on it: It's easy to implement a
-   recursive lock without this assumption.  */
+/* The native Windows documentation says that CRITICAL_SECTION already
+   implements a recursive lock.  But we need not rely on it: It's easy to
+   implement a recursive lock without this assumption.  */
 
 typedef struct
         {
@@ -763,7 +764,7 @@ extern void glthread_once_func (gl_once_t *once_control, 
void (*initfunction) (v
 
 /* ========================================================================= */
 
-#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || 
USE_WIN32_THREADS)
+#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || 
USE_WINDOWS_THREADS)
 
 /* Provide dummy implementation if threads are not supported.  */
 
diff --git a/gltests/glthread/thread.c b/gltests/glthread/thread.c
index 83b8c57..be0a871 100644
--- a/gltests/glthread/thread.c
+++ b/gltests/glthread/thread.c
@@ -1,5 +1,5 @@
 /* Creating and controlling threads.
-   Copyright (C) 2005-2011 Free Software Foundation, Inc.
+   Copyright (C) 2005-2012 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
@@ -43,7 +43,7 @@ const gl_thread_t gl_null_thread /* = { .p = NULL } */;
 
 /* ========================================================================= */
 
-#if USE_WIN32_THREADS
+#if USE_WINDOWS_THREADS
 
 #include <process.h>
 
diff --git a/gltests/glthread/thread.h b/gltests/glthread/thread.h
index d2bdffc..b95d6a2 100644
--- a/gltests/glthread/thread.h
+++ b/gltests/glthread/thread.h
@@ -1,5 +1,5 @@
 /* Creating and controlling threads.
-   Copyright (C) 2005-2011 Free Software Foundation, Inc.
+   Copyright (C) 2005-2012 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
@@ -53,7 +53,7 @@
 
    Terminating the current thread:
        gl_thread_exit (return_value);
-       extern void gl_thread_exit (void *return_value) __attribute__ 
((noreturn));
+       extern _Noreturn void gl_thread_exit (void *return_value);
 
    Requesting custom code to be executed at fork() time(not supported on all
    platforms):
@@ -161,9 +161,9 @@ typedef pthread_t gl_thread_t;
 extern const gl_thread_t gl_null_thread;
 # else
 #  define gl_thread_self() \
-     (pthread_in_use () ? (void *) pthread_self () : NULL)
+     (pthread_in_use () ? pthread_self () : (pthread_t) NULL)
 #  define gl_thread_self_pointer() \
-     gl_thread_self ()
+     (pthread_in_use () ? (void *) pthread_self () : NULL)
 # endif
 # define gl_thread_exit(RETVAL) \
     (pthread_in_use () ? pthread_exit (RETVAL) : 0)
@@ -290,8 +290,9 @@ typedef thread_t gl_thread_t;
 
 /* ========================================================================= */
 
-#if USE_WIN32_THREADS
+#if USE_WINDOWS_THREADS
 
+# define WIN32_LEAN_AND_MEAN  /* avoid including junk */
 # include <windows.h>
 
 # ifdef __cplusplus
@@ -336,7 +337,7 @@ extern int gl_thread_exit_func (void *retval);
 
 /* ========================================================================= */
 
-#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || 
USE_WIN32_THREADS)
+#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || 
USE_WINDOWS_THREADS)
 
 /* Provide dummy implementation if threads are not supported.  */
 
diff --git a/gltests/glthread/threadlib.c b/gltests/glthread/threadlib.c
index 646defa..30d6d51 100644
--- a/gltests/glthread/threadlib.c
+++ b/gltests/glthread/threadlib.c
@@ -1,5 +1,5 @@
 /* Multithreading primitives.
-   Copyright (C) 2005-2011 Free Software Foundation, Inc.
+   Copyright (C) 2005-2012 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
diff --git a/gltests/glthread/yield.h b/gltests/glthread/yield.h
index 4eb1cb8..040afe3 100644
--- a/gltests/glthread/yield.h
+++ b/gltests/glthread/yield.h
@@ -1,5 +1,5 @@
 /* Yielding the processor to other threads and processes.
-   Copyright (C) 2005-2011 Free Software Foundation, Inc.
+   Copyright (C) 2005-2012 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
@@ -89,8 +89,9 @@ extern "C" {
 
 /* ========================================================================= */
 
-#if USE_WIN32_THREADS
+#if USE_WINDOWS_THREADS
 
+# define WIN32_LEAN_AND_MEAN  /* avoid including junk */
 # include <windows.h>
 
 # ifdef __cplusplus
@@ -108,7 +109,7 @@ extern "C" {
 
 /* ========================================================================= */
 
-#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || 
USE_WIN32_THREADS)
+#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || 
USE_WINDOWS_THREADS)
 
 /* Provide dummy implementation if threads are not supported.  */
 
diff --git a/gltests/ignore-value.h b/gltests/ignore-value.h
index f021a1a..52919de 100644
--- a/gltests/ignore-value.h
+++ b/gltests/ignore-value.h
@@ -1,6 +1,6 @@
 /* ignore a function return without a compiler warning
 
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
@@ -54,9 +54,4 @@
 #  define ignore_value(x) (({ __typeof__ (x) __x = (x); (void) __x; }))
 # endif
 
-/* ignore_value works for scalars, pointers and aggregates;
-   deprecate ignore_ptr.  */
-static inline void _GL_ATTRIBUTE_DEPRECATED
-ignore_ptr (void *p) { (void) p; } /* deprecated: use ignore_value */
-
 #endif
diff --git a/gltests/inet_pton.c b/gltests/inet_pton.c
index 8b38e80..4096365 100644
--- a/gltests/inet_pton.c
+++ b/gltests/inet_pton.c
@@ -1,6 +1,6 @@
 /* inet_pton.c -- convert IPv4 and IPv6 addresses from text to binary form
 
-   Copyright (C) 2006, 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2008-2012 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
@@ -37,13 +37,25 @@
 /* Specification.  */
 #include <arpa/inet.h>
 
-#include <c-ctype.h>
-#include <string.h>
-#include <errno.h>
+#if HAVE_DECL_INET_PTON
 
-#define NS_INADDRSZ 4
-#define NS_IN6ADDRSZ 16
-#define NS_INT16SZ 2
+# undef inet_pton
+
+int
+rpl_inet_pton (int af, const char *restrict src, void *restrict dst)
+{
+  return inet_pton (af, src, dst);
+}
+
+#else
+
+# include <c-ctype.h>
+# include <string.h>
+# include <errno.h>
+
+# define NS_INADDRSZ 4
+# define NS_IN6ADDRSZ 16
+# define NS_INT16SZ 2
 
 /*
  * WARNING: Don't even consider trying to compile this on a system where
@@ -51,9 +63,9 @@
  */
 
 static int inet_pton4 (const char *src, unsigned char *dst);
-#if HAVE_IPV6
+# if HAVE_IPV6
 static int inet_pton6 (const char *src, unsigned char *dst);
-#endif
+# endif
 
 /* int
  * inet_pton(af, src, dst)
@@ -61,8 +73,8 @@ static int inet_pton6 (const char *src, unsigned char *dst);
  *      to network format (which is usually some kind of binary format).
  * return:
  *      1 if the address was valid for the specified address family
- *      0 if the address wasn't valid (`dst' is untouched in this case)
- *      -1 if some other error occurred (`dst' is untouched in this case, too)
+ *      0 if the address wasn't valid ('dst' is untouched in this case)
+ *      -1 if some other error occurred ('dst' is untouched in this case, too)
  * author:
  *      Paul Vixie, 1996.
  */
@@ -74,10 +86,10 @@ inet_pton (int af, const char *restrict src, void *restrict 
dst)
     case AF_INET:
       return (inet_pton4 (src, dst));
 
-#if HAVE_IPV6
+# if HAVE_IPV6
     case AF_INET6:
       return (inet_pton6 (src, dst));
-#endif
+# endif
 
     default:
       errno = EAFNOSUPPORT;
@@ -91,9 +103,9 @@ inet_pton (int af, const char *restrict src, void *restrict 
dst)
  *      like inet_aton() but without all the hexadecimal, octal (with the
  *      exception of 0) and shorthand.
  * return:
- *      1 if `src' is a valid dotted quad, else 0.
+ *      1 if 'src' is a valid dotted quad, else 0.
  * notice:
- *      does not touch `dst' unless it's returning 1.
+ *      does not touch 'dst' unless it's returning 1.
  * author:
  *      Paul Vixie, 1996.
  */
@@ -141,15 +153,15 @@ inet_pton4 (const char *restrict src, unsigned char 
*restrict dst)
   return (1);
 }
 
-#if HAVE_IPV6
+# if HAVE_IPV6
 
 /* int
  * inet_pton6(src, dst)
  *      convert presentation level address to network order binary form.
  * return:
- *      1 if `src' is a valid [RFC1884 2.2] address, else 0.
+ *      1 if 'src' is a valid [RFC1884 2.2] address, else 0.
  * notice:
- *      (1) does not touch `dst' unless it's returning 1.
+ *      (1) does not touch 'dst' unless it's returning 1.
  *      (2) :: in a full address is silently ignored.
  * credit:
  *      inspired by Mark Andrews.
@@ -250,4 +262,7 @@ inet_pton6 (const char *restrict src, unsigned char 
*restrict dst)
   memcpy (dst, tmp, NS_IN6ADDRSZ);
   return (1);
 }
+
+# endif
+
 #endif
diff --git a/gltests/init.sh b/gltests/init.sh
index 0da6c1e..ae86714 100644
--- a/gltests/init.sh
+++ b/gltests/init.sh
@@ -1,6 +1,6 @@
 # source this file; set up for tests
 
-# Copyright (C) 2009-2011 Free Software Foundation, Inc.
+# Copyright (C) 2009-2012 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
@@ -61,7 +61,7 @@ ME_=`expr "./$0" : '.*/\(.*\)$'`
 
 # We use a trap below for cleanup.  This requires us to go through
 # hoops to get the right exit status transported through the handler.
-# So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
+# So use 'Exit STATUS' instead of 'exit STATUS' inside of the tests.
 # Turn off errexit here so that we don't trip the bug with OSF1/Tru64
 # sh inside this function.
 Exit () { set +e; (exit $1); exit $1; }
@@ -74,7 +74,20 @@ Exit () { set +e; (exit $1); exit $1; }
 # the reason for skip/failure to console, rather than to the .log files.
 : ${stderr_fileno_=2}
 
-warn_ () { echo "$@" 1>&$stderr_fileno_; }
+# Note that correct expansion of "$*" depends on IFS starting with ' '.
+# Always write the full diagnostic to stderr.
+# When stderr_fileno_ is not 2, also emit the first line of the
+# diagnostic to that file descriptor.
+warn_ ()
+{
+  # If IFS does not start with ' ', set it and emit the warning in a subshell.
+  case $IFS in
+    ' '*) printf '%s\n' "$*" >&2
+          test $stderr_fileno_ = 2 \
+            || { printf '%s\n' "$*" | sed 1q >&$stderr_fileno_ ; } ;;
+    *) (IFS=' '; warn_ "$@");;
+  esac
+}
 fail_ () { warn_ "$ME_: failed test: $@"; Exit 1; }
 skip_ () { warn_ "$ME_: skipped test: $@"; Exit 77; }
 fatal_ () { warn_ "$ME_: hard error: $@"; Exit 99; }
@@ -159,7 +172,7 @@ else
     if test "$re_shell_" = __current__; then
       # 'eval'ing this code makes Solaris 10's /bin/sh exit with
       # $? set to 2.  It does not evaluate any of the code after the
-      # "unexpected" first `('.  Thus, we must run it in a subshell.
+      # "unexpected" first '('.  Thus, we must run it in a subshell.
       ( eval "$gl_shell_test_script_" ) > /dev/null 2>&1
     else
       "$re_shell_" -c "$gl_shell_test_script_" 2>/dev/null
@@ -208,14 +221,105 @@ export MALLOC_PERTURB_
 # a partition, or to undo any other global state changes.
 cleanup_ () { :; }
 
-if ( diff --version < /dev/null 2>&1 | grep GNU ) > /dev/null 2>&1; then
-  compare () { diff -u "$@"; }
+# Emit a header similar to that from diff -u;  Print the simulated "diff"
+# command so that the order of arguments is clear.  Don't bother with @@ lines.
+emit_diff_u_header_ ()
+{
+  printf '%s\n' "diff -u $*" \
+    "--- $1    1970-01-01" \
+    "+++ $2    1970-01-01"
+}
+
+# Arrange not to let diff or cmp operate on /dev/null,
+# since on some systems (at least OSF/1 5.1), that doesn't work.
+# When there are not two arguments, or no argument is /dev/null, return 2.
+# When one argument is /dev/null and the other is not empty,
+# cat the nonempty file to stderr and return 1.
+# Otherwise, return 0.
+compare_dev_null_ ()
+{
+  test $# = 2 || return 2
+
+  if test "x$1" = x/dev/null; then
+    test -s "$2" || return 0
+    emit_diff_u_header_ "$@"; sed 's/^/+/' "$2"
+    return 1
+  fi
+
+  if test "x$2" = x/dev/null; then
+    test -s "$1" || return 0
+    emit_diff_u_header_ "$@"; sed 's/^/-/' "$1"
+    return 1
+  fi
+
+  return 2
+}
+
+if diff_out_=`exec 2>/dev/null; diff -u "$0" "$0" < /dev/null` \
+   && diff -u Makefile "$0" 2>/dev/null | grep '^[+]#!' >/dev/null; then
+  # diff accepts the -u option and does not (like AIX 7 'diff') produce an
+  # extra space on column 1 of every content line.
+  if test -z "$diff_out_"; then
+    compare_ () { diff -u "$@"; }
+  else
+    compare_ ()
+    {
+      if diff -u "$@" > diff.out; then
+        # No differences were found, but Solaris 'diff' produces output
+        # "No differences encountered". Hide this output.
+        rm -f diff.out
+        true
+      else
+        cat diff.out
+        rm -f diff.out
+        false
+      fi
+    }
+  fi
+elif diff_out_=`exec 2>/dev/null; diff -c "$0" "$0" < /dev/null`; then
+  if test -z "$diff_out_"; then
+    compare_ () { diff -c "$@"; }
+  else
+    compare_ ()
+    {
+      if diff -c "$@" > diff.out; then
+        # No differences were found, but AIX and HP-UX 'diff' produce output
+        # "No differences encountered" or "There are no differences between the
+        # files.". Hide this output.
+        rm -f diff.out
+        true
+      else
+        cat diff.out
+        rm -f diff.out
+        false
+      fi
+    }
+  fi
 elif ( cmp --version < /dev/null 2>&1 | grep GNU ) > /dev/null 2>&1; then
-  compare () { cmp -s "$@"; }
+  compare_ () { cmp -s "$@"; }
 else
-  compare () { cmp "$@"; }
+  compare_ () { cmp "$@"; }
 fi
 
+# Usage: compare EXPECTED ACTUAL
+#
+# Given compare_dev_null_'s preprocessing, defer to compare_ if 2 or more.
+# Otherwise, propagate $? to caller: any diffs have already been printed.
+compare ()
+{
+  # This looks like it can be factored to use a simple "case $?"
+  # after unchecked compare_dev_null_ invocation, but that would
+  # fail in a "set -e" environment.
+  if compare_dev_null_ "$@"; then
+    return 0
+  else
+    case $? in
+      1) return 1;;
+      *) compare_ "$@";;
+    esac
+  fi
+}
+
 # An arbitrary prefix to help distinguish test directories.
 testdir_prefix_ () { printf gt; }
 
@@ -426,7 +530,7 @@ mktempd_ ()
   esac
 
   # First, try to use mktemp.
-  d=`unset TMPDIR; mktemp -d -t -p "$destdir_" "$template_" 2>/dev/null` \
+  d=`unset TMPDIR; { mktemp -d -t -p "$destdir_" "$template_"; } 2>/dev/null` \
     || fail=1
 
   # The resulting name must be in the specified directory.
diff --git a/gltests/inttypes.in.h b/gltests/inttypes.in.h
index 7abf394..b9da2b5 100644
--- a/gltests/inttypes.in.h
+++ b/gltests/inttypes.in.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2006-2011 Free Software Foundation, Inc.
+/* Copyright (C) 2006-2012 Free Software Foundation, Inc.
    Written by Paul Eggert, Bruno Haible, Derek Price.
    This file is part of gnulib.
 
@@ -31,6 +31,12 @@
    The include_next requires a split double-inclusion guard.  */
 #if ! defined INTTYPES_H || defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
 # if @HAVE_INTTYPES_H@
+
+   /* Some pre-C++11 <stdint.h> implementations need this.  */
+#  if defined __cplusplus && ! defined __STDC_FORMAT_MACROS
+#   define __STDC_FORMAT_MACROS 1
+#  endif
+
 #  @INCLUDE_NEXT@ @NEXT_INTTYPES_H@
 # endif
 #endif
@@ -50,994 +56,992 @@
 # error "This file assumes that 'int' has exactly 32 bits. Please report your 
platform and compiler to <address@hidden>."
 #endif
 
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
 /* The definition of _GL_ARG_NONNULL is copied here.  */
 
 /* The definition of _GL_WARN_ON_USE is copied here.  */
 
 /* 7.8.1 Macros for format specifiers */
 
-#if ! defined __cplusplus || defined __STDC_FORMAT_MACROS
-
-# if defined _TNS_R_TARGET
+#if defined _TNS_R_TARGET
    /* Tandem NonStop R series and compatible platforms released before
       July 2005 support %Ld but not %lld.  */
-#  define _LONG_LONG_FORMAT_PREFIX "L"
-# else
-#  define _LONG_LONG_FORMAT_PREFIX "ll"
-# endif
+# define _LONG_LONG_FORMAT_PREFIX "L"
+#else
+# define _LONG_LONG_FORMAT_PREFIX "ll"
+#endif
 
-# if !defined PRId8 || @PRI_MACROS_BROKEN@
-#  undef PRId8
-#  ifdef INT8_MAX
-#   define PRId8 "d"
-#  endif
+#if !defined PRId8 || @PRI_MACROS_BROKEN@
+# undef PRId8
+# ifdef INT8_MAX
+#  define PRId8 "d"
 # endif
-# if !defined PRIi8 || @PRI_MACROS_BROKEN@
-#  undef PRIi8
-#  ifdef INT8_MAX
-#   define PRIi8 "i"
-#  endif
+#endif
+#if !defined PRIi8 || @PRI_MACROS_BROKEN@
+# undef PRIi8
+# ifdef INT8_MAX
+#  define PRIi8 "i"
 # endif
-# if !defined PRIo8 || @PRI_MACROS_BROKEN@
-#  undef PRIo8
-#  ifdef UINT8_MAX
-#   define PRIo8 "o"
-#  endif
+#endif
+#if !defined PRIo8 || @PRI_MACROS_BROKEN@
+# undef PRIo8
+# ifdef UINT8_MAX
+#  define PRIo8 "o"
 # endif
-# if !defined PRIu8 || @PRI_MACROS_BROKEN@
-#  undef PRIu8
-#  ifdef UINT8_MAX
-#   define PRIu8 "u"
-#  endif
+#endif
+#if !defined PRIu8 || @PRI_MACROS_BROKEN@
+# undef PRIu8
+# ifdef UINT8_MAX
+#  define PRIu8 "u"
 # endif
-# if !defined PRIx8 || @PRI_MACROS_BROKEN@
-#  undef PRIx8
-#  ifdef UINT8_MAX
-#   define PRIx8 "x"
-#  endif
+#endif
+#if !defined PRIx8 || @PRI_MACROS_BROKEN@
+# undef PRIx8
+# ifdef UINT8_MAX
+#  define PRIx8 "x"
 # endif
-# if !defined PRIX8 || @PRI_MACROS_BROKEN@
-#  undef PRIX8
-#  ifdef UINT8_MAX
-#   define PRIX8 "X"
-#  endif
+#endif
+#if !defined PRIX8 || @PRI_MACROS_BROKEN@
+# undef PRIX8
+# ifdef UINT8_MAX
+#  define PRIX8 "X"
 # endif
-# if !defined PRId16 || @PRI_MACROS_BROKEN@
-#  undef PRId16
-#  ifdef INT16_MAX
-#   define PRId16 "d"
-#  endif
+#endif
+#if !defined PRId16 || @PRI_MACROS_BROKEN@
+# undef PRId16
+# ifdef INT16_MAX
+#  define PRId16 "d"
 # endif
-# if !defined PRIi16 || @PRI_MACROS_BROKEN@
-#  undef PRIi16
-#  ifdef INT16_MAX
-#   define PRIi16 "i"
-#  endif
+#endif
+#if !defined PRIi16 || @PRI_MACROS_BROKEN@
+# undef PRIi16
+# ifdef INT16_MAX
+#  define PRIi16 "i"
 # endif
-# if !defined PRIo16 || @PRI_MACROS_BROKEN@
-#  undef PRIo16
-#  ifdef UINT16_MAX
-#   define PRIo16 "o"
-#  endif
+#endif
+#if !defined PRIo16 || @PRI_MACROS_BROKEN@
+# undef PRIo16
+# ifdef UINT16_MAX
+#  define PRIo16 "o"
 # endif
-# if !defined PRIu16 || @PRI_MACROS_BROKEN@
-#  undef PRIu16
-#  ifdef UINT16_MAX
-#   define PRIu16 "u"
-#  endif
+#endif
+#if !defined PRIu16 || @PRI_MACROS_BROKEN@
+# undef PRIu16
+# ifdef UINT16_MAX
+#  define PRIu16 "u"
 # endif
-# if !defined PRIx16 || @PRI_MACROS_BROKEN@
-#  undef PRIx16
-#  ifdef UINT16_MAX
-#   define PRIx16 "x"
-#  endif
+#endif
+#if !defined PRIx16 || @PRI_MACROS_BROKEN@
+# undef PRIx16
+# ifdef UINT16_MAX
+#  define PRIx16 "x"
 # endif
-# if !defined PRIX16 || @PRI_MACROS_BROKEN@
-#  undef PRIX16
-#  ifdef UINT16_MAX
-#   define PRIX16 "X"
-#  endif
+#endif
+#if !defined PRIX16 || @PRI_MACROS_BROKEN@
+# undef PRIX16
+# ifdef UINT16_MAX
+#  define PRIX16 "X"
 # endif
-# if !defined PRId32 || @PRI_MACROS_BROKEN@
-#  undef PRId32
-#  ifdef INT32_MAX
-#   define PRId32 "d"
-#  endif
+#endif
+#if !defined PRId32 || @PRI_MACROS_BROKEN@
+# undef PRId32
+# ifdef INT32_MAX
+#  define PRId32 "d"
 # endif
-# if !defined PRIi32 || @PRI_MACROS_BROKEN@
-#  undef PRIi32
-#  ifdef INT32_MAX
-#   define PRIi32 "i"
-#  endif
+#endif
+#if !defined PRIi32 || @PRI_MACROS_BROKEN@
+# undef PRIi32
+# ifdef INT32_MAX
+#  define PRIi32 "i"
 # endif
-# if !defined PRIo32 || @PRI_MACROS_BROKEN@
-#  undef PRIo32
-#  ifdef UINT32_MAX
-#   define PRIo32 "o"
-#  endif
+#endif
+#if !defined PRIo32 || @PRI_MACROS_BROKEN@
+# undef PRIo32
+# ifdef UINT32_MAX
+#  define PRIo32 "o"
 # endif
-# if !defined PRIu32 || @PRI_MACROS_BROKEN@
-#  undef PRIu32
-#  ifdef UINT32_MAX
-#   define PRIu32 "u"
-#  endif
+#endif
+#if !defined PRIu32 || @PRI_MACROS_BROKEN@
+# undef PRIu32
+# ifdef UINT32_MAX
+#  define PRIu32 "u"
 # endif
-# if !defined PRIx32 || @PRI_MACROS_BROKEN@
-#  undef PRIx32
-#  ifdef UINT32_MAX
-#   define PRIx32 "x"
-#  endif
+#endif
+#if !defined PRIx32 || @PRI_MACROS_BROKEN@
+# undef PRIx32
+# ifdef UINT32_MAX
+#  define PRIx32 "x"
 # endif
-# if !defined PRIX32 || @PRI_MACROS_BROKEN@
-#  undef PRIX32
-#  ifdef UINT32_MAX
-#   define PRIX32 "X"
-#  endif
+#endif
+#if !defined PRIX32 || @PRI_MACROS_BROKEN@
+# undef PRIX32
+# ifdef UINT32_MAX
+#  define PRIX32 "X"
 # endif
-# ifdef INT64_MAX
-#  if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @INT64_MAX_EQ_LONG_MAX@)
-#   define _PRI64_PREFIX "l"
-#  elif defined _MSC_VER || defined __MINGW32__
-#   define _PRI64_PREFIX "I64"
-#  elif @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
-#   define _PRI64_PREFIX _LONG_LONG_FORMAT_PREFIX
-#  endif
-#  if !defined PRId64 || @PRI_MACROS_BROKEN@
-#   undef PRId64
-#   define PRId64 _PRI64_PREFIX "d"
-#  endif
-#  if !defined PRIi64 || @PRI_MACROS_BROKEN@
-#   undef PRIi64
-#   define PRIi64 _PRI64_PREFIX "i"
-#  endif
+#endif
+#ifdef INT64_MAX
+# if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @INT64_MAX_EQ_LONG_MAX@)
+#  define _PRI64_PREFIX "l"
+# elif defined _MSC_VER || defined __MINGW32__
+#  define _PRI64_PREFIX "I64"
+# elif @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
+#  define _PRI64_PREFIX _LONG_LONG_FORMAT_PREFIX
+# endif
+# if !defined PRId64 || @PRI_MACROS_BROKEN@
+#  undef PRId64
+#  define PRId64 _PRI64_PREFIX "d"
+# endif
+# if !defined PRIi64 || @PRI_MACROS_BROKEN@
+#  undef PRIi64
+#  define PRIi64 _PRI64_PREFIX "i"
 # endif
-# ifdef UINT64_MAX
-#  if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @UINT64_MAX_EQ_ULONG_MAX@)
-#   define _PRIu64_PREFIX "l"
-#  elif defined _MSC_VER || defined __MINGW32__
-#   define _PRIu64_PREFIX "I64"
-#  elif @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
-#   define _PRIu64_PREFIX _LONG_LONG_FORMAT_PREFIX
-#  endif
-#  if !defined PRIo64 || @PRI_MACROS_BROKEN@
-#   undef PRIo64
-#   define PRIo64 _PRIu64_PREFIX "o"
-#  endif
-#  if !defined PRIu64 || @PRI_MACROS_BROKEN@
-#   undef PRIu64
-#   define PRIu64 _PRIu64_PREFIX "u"
-#  endif
-#  if !defined PRIx64 || @PRI_MACROS_BROKEN@
-#   undef PRIx64
-#   define PRIx64 _PRIu64_PREFIX "x"
-#  endif
-#  if !defined PRIX64 || @PRI_MACROS_BROKEN@
-#   undef PRIX64
-#   define PRIX64 _PRIu64_PREFIX "X"
-#  endif
+#endif
+#ifdef UINT64_MAX
+# if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @UINT64_MAX_EQ_ULONG_MAX@)
+#  define _PRIu64_PREFIX "l"
+# elif defined _MSC_VER || defined __MINGW32__
+#  define _PRIu64_PREFIX "I64"
+# elif @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
+#  define _PRIu64_PREFIX _LONG_LONG_FORMAT_PREFIX
+# endif
+# if !defined PRIo64 || @PRI_MACROS_BROKEN@
+#  undef PRIo64
+#  define PRIo64 _PRIu64_PREFIX "o"
+# endif
+# if !defined PRIu64 || @PRI_MACROS_BROKEN@
+#  undef PRIu64
+#  define PRIu64 _PRIu64_PREFIX "u"
+# endif
+# if !defined PRIx64 || @PRI_MACROS_BROKEN@
+#  undef PRIx64
+#  define PRIx64 _PRIu64_PREFIX "x"
+# endif
+# if !defined PRIX64 || @PRI_MACROS_BROKEN@
+#  undef PRIX64
+#  define PRIX64 _PRIu64_PREFIX "X"
 # endif
+#endif
 
-# if !defined PRIdLEAST8 || @PRI_MACROS_BROKEN@
-#  undef PRIdLEAST8
-#  define PRIdLEAST8 "d"
-# endif
-# if !defined PRIiLEAST8 || @PRI_MACROS_BROKEN@
-#  undef PRIiLEAST8
-#  define PRIiLEAST8 "i"
-# endif
-# if !defined PRIoLEAST8 || @PRI_MACROS_BROKEN@
-#  undef PRIoLEAST8
-#  define PRIoLEAST8 "o"
-# endif
-# if !defined PRIuLEAST8 || @PRI_MACROS_BROKEN@
-#  undef PRIuLEAST8
-#  define PRIuLEAST8 "u"
-# endif
-# if !defined PRIxLEAST8 || @PRI_MACROS_BROKEN@
-#  undef PRIxLEAST8
-#  define PRIxLEAST8 "x"
-# endif
-# if !defined PRIXLEAST8 || @PRI_MACROS_BROKEN@
-#  undef PRIXLEAST8
-#  define PRIXLEAST8 "X"
-# endif
-# if !defined PRIdLEAST16 || @PRI_MACROS_BROKEN@
-#  undef PRIdLEAST16
-#  define PRIdLEAST16 "d"
-# endif
-# if !defined PRIiLEAST16 || @PRI_MACROS_BROKEN@
-#  undef PRIiLEAST16
-#  define PRIiLEAST16 "i"
-# endif
-# if !defined PRIoLEAST16 || @PRI_MACROS_BROKEN@
-#  undef PRIoLEAST16
-#  define PRIoLEAST16 "o"
-# endif
-# if !defined PRIuLEAST16 || @PRI_MACROS_BROKEN@
-#  undef PRIuLEAST16
-#  define PRIuLEAST16 "u"
-# endif
-# if !defined PRIxLEAST16 || @PRI_MACROS_BROKEN@
-#  undef PRIxLEAST16
-#  define PRIxLEAST16 "x"
-# endif
-# if !defined PRIXLEAST16 || @PRI_MACROS_BROKEN@
-#  undef PRIXLEAST16
-#  define PRIXLEAST16 "X"
-# endif
-# if !defined PRIdLEAST32 || @PRI_MACROS_BROKEN@
-#  undef PRIdLEAST32
-#  define PRIdLEAST32 "d"
-# endif
-# if !defined PRIiLEAST32 || @PRI_MACROS_BROKEN@
-#  undef PRIiLEAST32
-#  define PRIiLEAST32 "i"
-# endif
-# if !defined PRIoLEAST32 || @PRI_MACROS_BROKEN@
-#  undef PRIoLEAST32
-#  define PRIoLEAST32 "o"
-# endif
-# if !defined PRIuLEAST32 || @PRI_MACROS_BROKEN@
-#  undef PRIuLEAST32
-#  define PRIuLEAST32 "u"
-# endif
-# if !defined PRIxLEAST32 || @PRI_MACROS_BROKEN@
-#  undef PRIxLEAST32
-#  define PRIxLEAST32 "x"
-# endif
-# if !defined PRIXLEAST32 || @PRI_MACROS_BROKEN@
-#  undef PRIXLEAST32
-#  define PRIXLEAST32 "X"
-# endif
-# ifdef INT64_MAX
-#  if !defined PRIdLEAST64 || @PRI_MACROS_BROKEN@
-#   undef PRIdLEAST64
-#   define PRIdLEAST64 PRId64
-#  endif
-#  if !defined PRIiLEAST64 || @PRI_MACROS_BROKEN@
-#   undef PRIiLEAST64
-#   define PRIiLEAST64 PRIi64
-#  endif
+#if !defined PRIdLEAST8 || @PRI_MACROS_BROKEN@
+# undef PRIdLEAST8
+# define PRIdLEAST8 "d"
+#endif
+#if !defined PRIiLEAST8 || @PRI_MACROS_BROKEN@
+# undef PRIiLEAST8
+# define PRIiLEAST8 "i"
+#endif
+#if !defined PRIoLEAST8 || @PRI_MACROS_BROKEN@
+# undef PRIoLEAST8
+# define PRIoLEAST8 "o"
+#endif
+#if !defined PRIuLEAST8 || @PRI_MACROS_BROKEN@
+# undef PRIuLEAST8
+# define PRIuLEAST8 "u"
+#endif
+#if !defined PRIxLEAST8 || @PRI_MACROS_BROKEN@
+# undef PRIxLEAST8
+# define PRIxLEAST8 "x"
+#endif
+#if !defined PRIXLEAST8 || @PRI_MACROS_BROKEN@
+# undef PRIXLEAST8
+# define PRIXLEAST8 "X"
+#endif
+#if !defined PRIdLEAST16 || @PRI_MACROS_BROKEN@
+# undef PRIdLEAST16
+# define PRIdLEAST16 "d"
+#endif
+#if !defined PRIiLEAST16 || @PRI_MACROS_BROKEN@
+# undef PRIiLEAST16
+# define PRIiLEAST16 "i"
+#endif
+#if !defined PRIoLEAST16 || @PRI_MACROS_BROKEN@
+# undef PRIoLEAST16
+# define PRIoLEAST16 "o"
+#endif
+#if !defined PRIuLEAST16 || @PRI_MACROS_BROKEN@
+# undef PRIuLEAST16
+# define PRIuLEAST16 "u"
+#endif
+#if !defined PRIxLEAST16 || @PRI_MACROS_BROKEN@
+# undef PRIxLEAST16
+# define PRIxLEAST16 "x"
+#endif
+#if !defined PRIXLEAST16 || @PRI_MACROS_BROKEN@
+# undef PRIXLEAST16
+# define PRIXLEAST16 "X"
+#endif
+#if !defined PRIdLEAST32 || @PRI_MACROS_BROKEN@
+# undef PRIdLEAST32
+# define PRIdLEAST32 "d"
+#endif
+#if !defined PRIiLEAST32 || @PRI_MACROS_BROKEN@
+# undef PRIiLEAST32
+# define PRIiLEAST32 "i"
+#endif
+#if !defined PRIoLEAST32 || @PRI_MACROS_BROKEN@
+# undef PRIoLEAST32
+# define PRIoLEAST32 "o"
+#endif
+#if !defined PRIuLEAST32 || @PRI_MACROS_BROKEN@
+# undef PRIuLEAST32
+# define PRIuLEAST32 "u"
+#endif
+#if !defined PRIxLEAST32 || @PRI_MACROS_BROKEN@
+# undef PRIxLEAST32
+# define PRIxLEAST32 "x"
+#endif
+#if !defined PRIXLEAST32 || @PRI_MACROS_BROKEN@
+# undef PRIXLEAST32
+# define PRIXLEAST32 "X"
+#endif
+#ifdef INT64_MAX
+# if !defined PRIdLEAST64 || @PRI_MACROS_BROKEN@
+#  undef PRIdLEAST64
+#  define PRIdLEAST64 PRId64
 # endif
-# ifdef UINT64_MAX
-#  if !defined PRIoLEAST64 || @PRI_MACROS_BROKEN@
-#   undef PRIoLEAST64
-#   define PRIoLEAST64 PRIo64
-#  endif
-#  if !defined PRIuLEAST64 || @PRI_MACROS_BROKEN@
-#   undef PRIuLEAST64
-#   define PRIuLEAST64 PRIu64
-#  endif
-#  if !defined PRIxLEAST64 || @PRI_MACROS_BROKEN@
-#   undef PRIxLEAST64
-#   define PRIxLEAST64 PRIx64
-#  endif
-#  if !defined PRIXLEAST64 || @PRI_MACROS_BROKEN@
-#   undef PRIXLEAST64
-#   define PRIXLEAST64 PRIX64
-#  endif
+# if !defined PRIiLEAST64 || @PRI_MACROS_BROKEN@
+#  undef PRIiLEAST64
+#  define PRIiLEAST64 PRIi64
+# endif
+#endif
+#ifdef UINT64_MAX
+# if !defined PRIoLEAST64 || @PRI_MACROS_BROKEN@
+#  undef PRIoLEAST64
+#  define PRIoLEAST64 PRIo64
+# endif
+# if !defined PRIuLEAST64 || @PRI_MACROS_BROKEN@
+#  undef PRIuLEAST64
+#  define PRIuLEAST64 PRIu64
+# endif
+# if !defined PRIxLEAST64 || @PRI_MACROS_BROKEN@
+#  undef PRIxLEAST64
+#  define PRIxLEAST64 PRIx64
 # endif
+# if !defined PRIXLEAST64 || @PRI_MACROS_BROKEN@
+#  undef PRIXLEAST64
+#  define PRIXLEAST64 PRIX64
+# endif
+#endif
 
-# if !defined PRIdFAST8 || @PRI_MACROS_BROKEN@
-#  undef PRIdFAST8
-#  if INT_FAST8_MAX > INT32_MAX
-#   define PRIdFAST8 PRId64
-#  else
-#   define PRIdFAST8 "d"
-#  endif
+#if !defined PRIdFAST8 || @PRI_MACROS_BROKEN@
+# undef PRIdFAST8
+# if INT_FAST8_MAX > INT32_MAX
+#  define PRIdFAST8 PRId64
+# else
+#  define PRIdFAST8 "d"
 # endif
-# if !defined PRIiFAST8 || @PRI_MACROS_BROKEN@
-#  undef PRIiFAST8
-#  if INT_FAST8_MAX > INT32_MAX
-#   define PRIiFAST8 PRIi64
-#  else
-#   define PRIiFAST8 "i"
-#  endif
+#endif
+#if !defined PRIiFAST8 || @PRI_MACROS_BROKEN@
+# undef PRIiFAST8
+# if INT_FAST8_MAX > INT32_MAX
+#  define PRIiFAST8 PRIi64
+# else
+#  define PRIiFAST8 "i"
 # endif
-# if !defined PRIoFAST8 || @PRI_MACROS_BROKEN@
-#  undef PRIoFAST8
-#  if UINT_FAST8_MAX > UINT32_MAX
-#   define PRIoFAST8 PRIo64
-#  else
-#   define PRIoFAST8 "o"
-#  endif
+#endif
+#if !defined PRIoFAST8 || @PRI_MACROS_BROKEN@
+# undef PRIoFAST8
+# if UINT_FAST8_MAX > UINT32_MAX
+#  define PRIoFAST8 PRIo64
+# else
+#  define PRIoFAST8 "o"
 # endif
-# if !defined PRIuFAST8 || @PRI_MACROS_BROKEN@
-#  undef PRIuFAST8
-#  if UINT_FAST8_MAX > UINT32_MAX
-#   define PRIuFAST8 PRIu64
-#  else
-#   define PRIuFAST8 "u"
-#  endif
+#endif
+#if !defined PRIuFAST8 || @PRI_MACROS_BROKEN@
+# undef PRIuFAST8
+# if UINT_FAST8_MAX > UINT32_MAX
+#  define PRIuFAST8 PRIu64
+# else
+#  define PRIuFAST8 "u"
 # endif
-# if !defined PRIxFAST8 || @PRI_MACROS_BROKEN@
-#  undef PRIxFAST8
-#  if UINT_FAST8_MAX > UINT32_MAX
-#   define PRIxFAST8 PRIx64
-#  else
-#   define PRIxFAST8 "x"
-#  endif
+#endif
+#if !defined PRIxFAST8 || @PRI_MACROS_BROKEN@
+# undef PRIxFAST8
+# if UINT_FAST8_MAX > UINT32_MAX
+#  define PRIxFAST8 PRIx64
+# else
+#  define PRIxFAST8 "x"
 # endif
-# if !defined PRIXFAST8 || @PRI_MACROS_BROKEN@
-#  undef PRIXFAST8
-#  if UINT_FAST8_MAX > UINT32_MAX
-#   define PRIXFAST8 PRIX64
-#  else
-#   define PRIXFAST8 "X"
-#  endif
+#endif
+#if !defined PRIXFAST8 || @PRI_MACROS_BROKEN@
+# undef PRIXFAST8
+# if UINT_FAST8_MAX > UINT32_MAX
+#  define PRIXFAST8 PRIX64
+# else
+#  define PRIXFAST8 "X"
 # endif
-# if !defined PRIdFAST16 || @PRI_MACROS_BROKEN@
-#  undef PRIdFAST16
-#  if INT_FAST16_MAX > INT32_MAX
-#   define PRIdFAST16 PRId64
-#  else
-#   define PRIdFAST16 "d"
-#  endif
+#endif
+#if !defined PRIdFAST16 || @PRI_MACROS_BROKEN@
+# undef PRIdFAST16
+# if INT_FAST16_MAX > INT32_MAX
+#  define PRIdFAST16 PRId64
+# else
+#  define PRIdFAST16 "d"
 # endif
-# if !defined PRIiFAST16 || @PRI_MACROS_BROKEN@
-#  undef PRIiFAST16
-#  if INT_FAST16_MAX > INT32_MAX
-#   define PRIiFAST16 PRIi64
-#  else
-#   define PRIiFAST16 "i"
-#  endif
+#endif
+#if !defined PRIiFAST16 || @PRI_MACROS_BROKEN@
+# undef PRIiFAST16
+# if INT_FAST16_MAX > INT32_MAX
+#  define PRIiFAST16 PRIi64
+# else
+#  define PRIiFAST16 "i"
 # endif
-# if !defined PRIoFAST16 || @PRI_MACROS_BROKEN@
-#  undef PRIoFAST16
-#  if UINT_FAST16_MAX > UINT32_MAX
-#   define PRIoFAST16 PRIo64
-#  else
-#   define PRIoFAST16 "o"
-#  endif
+#endif
+#if !defined PRIoFAST16 || @PRI_MACROS_BROKEN@
+# undef PRIoFAST16
+# if UINT_FAST16_MAX > UINT32_MAX
+#  define PRIoFAST16 PRIo64
+# else
+#  define PRIoFAST16 "o"
 # endif
-# if !defined PRIuFAST16 || @PRI_MACROS_BROKEN@
-#  undef PRIuFAST16
-#  if UINT_FAST16_MAX > UINT32_MAX
-#   define PRIuFAST16 PRIu64
-#  else
-#   define PRIuFAST16 "u"
-#  endif
+#endif
+#if !defined PRIuFAST16 || @PRI_MACROS_BROKEN@
+# undef PRIuFAST16
+# if UINT_FAST16_MAX > UINT32_MAX
+#  define PRIuFAST16 PRIu64
+# else
+#  define PRIuFAST16 "u"
 # endif
-# if !defined PRIxFAST16 || @PRI_MACROS_BROKEN@
-#  undef PRIxFAST16
-#  if UINT_FAST16_MAX > UINT32_MAX
-#   define PRIxFAST16 PRIx64
-#  else
-#   define PRIxFAST16 "x"
-#  endif
+#endif
+#if !defined PRIxFAST16 || @PRI_MACROS_BROKEN@
+# undef PRIxFAST16
+# if UINT_FAST16_MAX > UINT32_MAX
+#  define PRIxFAST16 PRIx64
+# else
+#  define PRIxFAST16 "x"
 # endif
-# if !defined PRIXFAST16 || @PRI_MACROS_BROKEN@
-#  undef PRIXFAST16
-#  if UINT_FAST16_MAX > UINT32_MAX
-#   define PRIXFAST16 PRIX64
-#  else
-#   define PRIXFAST16 "X"
-#  endif
+#endif
+#if !defined PRIXFAST16 || @PRI_MACROS_BROKEN@
+# undef PRIXFAST16
+# if UINT_FAST16_MAX > UINT32_MAX
+#  define PRIXFAST16 PRIX64
+# else
+#  define PRIXFAST16 "X"
 # endif
-# if !defined PRIdFAST32 || @PRI_MACROS_BROKEN@
-#  undef PRIdFAST32
-#  if INT_FAST32_MAX > INT32_MAX
-#   define PRIdFAST32 PRId64
-#  else
-#   define PRIdFAST32 "d"
-#  endif
+#endif
+#if !defined PRIdFAST32 || @PRI_MACROS_BROKEN@
+# undef PRIdFAST32
+# if INT_FAST32_MAX > INT32_MAX
+#  define PRIdFAST32 PRId64
+# else
+#  define PRIdFAST32 "d"
 # endif
-# if !defined PRIiFAST32 || @PRI_MACROS_BROKEN@
-#  undef PRIiFAST32
-#  if INT_FAST32_MAX > INT32_MAX
-#   define PRIiFAST32 PRIi64
-#  else
-#   define PRIiFAST32 "i"
-#  endif
+#endif
+#if !defined PRIiFAST32 || @PRI_MACROS_BROKEN@
+# undef PRIiFAST32
+# if INT_FAST32_MAX > INT32_MAX
+#  define PRIiFAST32 PRIi64
+# else
+#  define PRIiFAST32 "i"
 # endif
-# if !defined PRIoFAST32 || @PRI_MACROS_BROKEN@
-#  undef PRIoFAST32
-#  if UINT_FAST32_MAX > UINT32_MAX
-#   define PRIoFAST32 PRIo64
-#  else
-#   define PRIoFAST32 "o"
-#  endif
+#endif
+#if !defined PRIoFAST32 || @PRI_MACROS_BROKEN@
+# undef PRIoFAST32
+# if UINT_FAST32_MAX > UINT32_MAX
+#  define PRIoFAST32 PRIo64
+# else
+#  define PRIoFAST32 "o"
 # endif
-# if !defined PRIuFAST32 || @PRI_MACROS_BROKEN@
-#  undef PRIuFAST32
-#  if UINT_FAST32_MAX > UINT32_MAX
-#   define PRIuFAST32 PRIu64
-#  else
-#   define PRIuFAST32 "u"
-#  endif
+#endif
+#if !defined PRIuFAST32 || @PRI_MACROS_BROKEN@
+# undef PRIuFAST32
+# if UINT_FAST32_MAX > UINT32_MAX
+#  define PRIuFAST32 PRIu64
+# else
+#  define PRIuFAST32 "u"
 # endif
-# if !defined PRIxFAST32 || @PRI_MACROS_BROKEN@
-#  undef PRIxFAST32
-#  if UINT_FAST32_MAX > UINT32_MAX
-#   define PRIxFAST32 PRIx64
-#  else
-#   define PRIxFAST32 "x"
-#  endif
+#endif
+#if !defined PRIxFAST32 || @PRI_MACROS_BROKEN@
+# undef PRIxFAST32
+# if UINT_FAST32_MAX > UINT32_MAX
+#  define PRIxFAST32 PRIx64
+# else
+#  define PRIxFAST32 "x"
 # endif
-# if !defined PRIXFAST32 || @PRI_MACROS_BROKEN@
-#  undef PRIXFAST32
-#  if UINT_FAST32_MAX > UINT32_MAX
-#   define PRIXFAST32 PRIX64
-#  else
-#   define PRIXFAST32 "X"
-#  endif
+#endif
+#if !defined PRIXFAST32 || @PRI_MACROS_BROKEN@
+# undef PRIXFAST32
+# if UINT_FAST32_MAX > UINT32_MAX
+#  define PRIXFAST32 PRIX64
+# else
+#  define PRIXFAST32 "X"
 # endif
-# ifdef INT64_MAX
-#  if !defined PRIdFAST64 || @PRI_MACROS_BROKEN@
-#   undef PRIdFAST64
-#   define PRIdFAST64 PRId64
-#  endif
-#  if !defined PRIiFAST64 || @PRI_MACROS_BROKEN@
-#   undef PRIiFAST64
-#   define PRIiFAST64 PRIi64
-#  endif
+#endif
+#ifdef INT64_MAX
+# if !defined PRIdFAST64 || @PRI_MACROS_BROKEN@
+#  undef PRIdFAST64
+#  define PRIdFAST64 PRId64
 # endif
-# ifdef UINT64_MAX
-#  if !defined PRIoFAST64 || @PRI_MACROS_BROKEN@
-#   undef PRIoFAST64
-#   define PRIoFAST64 PRIo64
-#  endif
-#  if !defined PRIuFAST64 || @PRI_MACROS_BROKEN@
-#   undef PRIuFAST64
-#   define PRIuFAST64 PRIu64
-#  endif
-#  if !defined PRIxFAST64 || @PRI_MACROS_BROKEN@
-#   undef PRIxFAST64
-#   define PRIxFAST64 PRIx64
-#  endif
-#  if !defined PRIXFAST64 || @PRI_MACROS_BROKEN@
-#   undef PRIXFAST64
-#   define PRIXFAST64 PRIX64
-#  endif
+# if !defined PRIiFAST64 || @PRI_MACROS_BROKEN@
+#  undef PRIiFAST64
+#  define PRIiFAST64 PRIi64
+# endif
+#endif
+#ifdef UINT64_MAX
+# if !defined PRIoFAST64 || @PRI_MACROS_BROKEN@
+#  undef PRIoFAST64
+#  define PRIoFAST64 PRIo64
+# endif
+# if !defined PRIuFAST64 || @PRI_MACROS_BROKEN@
+#  undef PRIuFAST64
+#  define PRIuFAST64 PRIu64
+# endif
+# if !defined PRIxFAST64 || @PRI_MACROS_BROKEN@
+#  undef PRIxFAST64
+#  define PRIxFAST64 PRIx64
 # endif
+# if !defined PRIXFAST64 || @PRI_MACROS_BROKEN@
+#  undef PRIXFAST64
+#  define PRIXFAST64 PRIX64
+# endif
+#endif
 
-# if !defined PRIdMAX || @PRI_MACROS_BROKEN@
-#  undef PRIdMAX
-#  if @INT32_MAX_LT_INTMAX_MAX@
-#   define PRIdMAX PRId64
-#  else
-#   define PRIdMAX "ld"
-#  endif
+#if !defined PRIdMAX || @PRI_MACROS_BROKEN@
+# undef PRIdMAX
+# if @INT32_MAX_LT_INTMAX_MAX@
+#  define PRIdMAX PRId64
+# else
+#  define PRIdMAX "ld"
 # endif
-# if !defined PRIiMAX || @PRI_MACROS_BROKEN@
-#  undef PRIiMAX
-#  if @INT32_MAX_LT_INTMAX_MAX@
-#   define PRIiMAX PRIi64
-#  else
-#   define PRIiMAX "li"
-#  endif
+#endif
+#if !defined PRIiMAX || @PRI_MACROS_BROKEN@
+# undef PRIiMAX
+# if @INT32_MAX_LT_INTMAX_MAX@
+#  define PRIiMAX PRIi64
+# else
+#  define PRIiMAX "li"
 # endif
-# if !defined PRIoMAX || @PRI_MACROS_BROKEN@
-#  undef PRIoMAX
-#  if @UINT32_MAX_LT_UINTMAX_MAX@
-#   define PRIoMAX PRIo64
-#  else
-#   define PRIoMAX "lo"
-#  endif
+#endif
+#if !defined PRIoMAX || @PRI_MACROS_BROKEN@
+# undef PRIoMAX
+# if @UINT32_MAX_LT_UINTMAX_MAX@
+#  define PRIoMAX PRIo64
+# else
+#  define PRIoMAX "lo"
 # endif
-# if !defined PRIuMAX || @PRI_MACROS_BROKEN@
-#  undef PRIuMAX
-#  if @UINT32_MAX_LT_UINTMAX_MAX@
-#   define PRIuMAX PRIu64
-#  else
-#   define PRIuMAX "lu"
-#  endif
+#endif
+#if !defined PRIuMAX || @PRI_MACROS_BROKEN@
+# undef PRIuMAX
+# if @UINT32_MAX_LT_UINTMAX_MAX@
+#  define PRIuMAX PRIu64
+# else
+#  define PRIuMAX "lu"
 # endif
-# if !defined PRIxMAX || @PRI_MACROS_BROKEN@
-#  undef PRIxMAX
-#  if @UINT32_MAX_LT_UINTMAX_MAX@
-#   define PRIxMAX PRIx64
-#  else
-#   define PRIxMAX "lx"
-#  endif
+#endif
+#if !defined PRIxMAX || @PRI_MACROS_BROKEN@
+# undef PRIxMAX
+# if @UINT32_MAX_LT_UINTMAX_MAX@
+#  define PRIxMAX PRIx64
+# else
+#  define PRIxMAX "lx"
 # endif
-# if !defined PRIXMAX || @PRI_MACROS_BROKEN@
-#  undef PRIXMAX
-#  if @UINT32_MAX_LT_UINTMAX_MAX@
-#   define PRIXMAX PRIX64
-#  else
-#   define PRIXMAX "lX"
-#  endif
+#endif
+#if !defined PRIXMAX || @PRI_MACROS_BROKEN@
+# undef PRIXMAX
+# if @UINT32_MAX_LT_UINTMAX_MAX@
+#  define PRIXMAX PRIX64
+# else
+#  define PRIXMAX "lX"
 # endif
+#endif
 
-# if !defined PRIdPTR || @PRI_MACROS_BROKEN@
-#  undef PRIdPTR
-#  ifdef INTPTR_MAX
-#   define PRIdPTR @PRIPTR_PREFIX@ "d"
-#  endif
+#if !defined PRIdPTR || @PRI_MACROS_BROKEN@
+# undef PRIdPTR
+# ifdef INTPTR_MAX
+#  define PRIdPTR @PRIPTR_PREFIX@ "d"
 # endif
-# if !defined PRIiPTR || @PRI_MACROS_BROKEN@
-#  undef PRIiPTR
-#  ifdef INTPTR_MAX
-#   define PRIiPTR @PRIPTR_PREFIX@ "i"
-#  endif
+#endif
+#if !defined PRIiPTR || @PRI_MACROS_BROKEN@
+# undef PRIiPTR
+# ifdef INTPTR_MAX
+#  define PRIiPTR @PRIPTR_PREFIX@ "i"
 # endif
-# if !defined PRIoPTR || @PRI_MACROS_BROKEN@
-#  undef PRIoPTR
-#  ifdef UINTPTR_MAX
-#   define PRIoPTR @PRIPTR_PREFIX@ "o"
-#  endif
+#endif
+#if !defined PRIoPTR || @PRI_MACROS_BROKEN@
+# undef PRIoPTR
+# ifdef UINTPTR_MAX
+#  define PRIoPTR @PRIPTR_PREFIX@ "o"
 # endif
-# if !defined PRIuPTR || @PRI_MACROS_BROKEN@
-#  undef PRIuPTR
-#  ifdef UINTPTR_MAX
-#   define PRIuPTR @PRIPTR_PREFIX@ "u"
-#  endif
+#endif
+#if !defined PRIuPTR || @PRI_MACROS_BROKEN@
+# undef PRIuPTR
+# ifdef UINTPTR_MAX
+#  define PRIuPTR @PRIPTR_PREFIX@ "u"
 # endif
-# if !defined PRIxPTR || @PRI_MACROS_BROKEN@
-#  undef PRIxPTR
-#  ifdef UINTPTR_MAX
-#   define PRIxPTR @PRIPTR_PREFIX@ "x"
-#  endif
+#endif
+#if !defined PRIxPTR || @PRI_MACROS_BROKEN@
+# undef PRIxPTR
+# ifdef UINTPTR_MAX
+#  define PRIxPTR @PRIPTR_PREFIX@ "x"
 # endif
-# if !defined PRIXPTR || @PRI_MACROS_BROKEN@
-#  undef PRIXPTR
-#  ifdef UINTPTR_MAX
-#   define PRIXPTR @PRIPTR_PREFIX@ "X"
-#  endif
+#endif
+#if !defined PRIXPTR || @PRI_MACROS_BROKEN@
+# undef PRIXPTR
+# ifdef UINTPTR_MAX
+#  define PRIXPTR @PRIPTR_PREFIX@ "X"
 # endif
+#endif
 
-# if !defined SCNd8 || @PRI_MACROS_BROKEN@
-#  undef SCNd8
-#  ifdef INT8_MAX
-#   define SCNd8 "hhd"
-#  endif
+#if !defined SCNd8 || @PRI_MACROS_BROKEN@
+# undef SCNd8
+# ifdef INT8_MAX
+#  define SCNd8 "hhd"
 # endif
-# if !defined SCNi8 || @PRI_MACROS_BROKEN@
-#  undef SCNi8
-#  ifdef INT8_MAX
-#   define SCNi8 "hhi"
-#  endif
+#endif
+#if !defined SCNi8 || @PRI_MACROS_BROKEN@
+# undef SCNi8
+# ifdef INT8_MAX
+#  define SCNi8 "hhi"
 # endif
-# if !defined SCNo8 || @PRI_MACROS_BROKEN@
-#  undef SCNo8
-#  ifdef UINT8_MAX
-#   define SCNo8 "hho"
-#  endif
+#endif
+#if !defined SCNo8 || @PRI_MACROS_BROKEN@
+# undef SCNo8
+# ifdef UINT8_MAX
+#  define SCNo8 "hho"
 # endif
-# if !defined SCNu8 || @PRI_MACROS_BROKEN@
-#  undef SCNu8
-#  ifdef UINT8_MAX
-#   define SCNu8 "hhu"
-#  endif
+#endif
+#if !defined SCNu8 || @PRI_MACROS_BROKEN@
+# undef SCNu8
+# ifdef UINT8_MAX
+#  define SCNu8 "hhu"
 # endif
-# if !defined SCNx8 || @PRI_MACROS_BROKEN@
-#  undef SCNx8
-#  ifdef UINT8_MAX
-#   define SCNx8 "hhx"
-#  endif
+#endif
+#if !defined SCNx8 || @PRI_MACROS_BROKEN@
+# undef SCNx8
+# ifdef UINT8_MAX
+#  define SCNx8 "hhx"
 # endif
-# if !defined SCNd16 || @PRI_MACROS_BROKEN@
-#  undef SCNd16
-#  ifdef INT16_MAX
-#   define SCNd16 "hd"
-#  endif
+#endif
+#if !defined SCNd16 || @PRI_MACROS_BROKEN@
+# undef SCNd16
+# ifdef INT16_MAX
+#  define SCNd16 "hd"
 # endif
-# if !defined SCNi16 || @PRI_MACROS_BROKEN@
-#  undef SCNi16
-#  ifdef INT16_MAX
-#   define SCNi16 "hi"
-#  endif
+#endif
+#if !defined SCNi16 || @PRI_MACROS_BROKEN@
+# undef SCNi16
+# ifdef INT16_MAX
+#  define SCNi16 "hi"
 # endif
-# if !defined SCNo16 || @PRI_MACROS_BROKEN@
-#  undef SCNo16
-#  ifdef UINT16_MAX
-#   define SCNo16 "ho"
-#  endif
+#endif
+#if !defined SCNo16 || @PRI_MACROS_BROKEN@
+# undef SCNo16
+# ifdef UINT16_MAX
+#  define SCNo16 "ho"
 # endif
-# if !defined SCNu16 || @PRI_MACROS_BROKEN@
-#  undef SCNu16
-#  ifdef UINT16_MAX
-#   define SCNu16 "hu"
-#  endif
+#endif
+#if !defined SCNu16 || @PRI_MACROS_BROKEN@
+# undef SCNu16
+# ifdef UINT16_MAX
+#  define SCNu16 "hu"
 # endif
-# if !defined SCNx16 || @PRI_MACROS_BROKEN@
-#  undef SCNx16
-#  ifdef UINT16_MAX
-#   define SCNx16 "hx"
-#  endif
+#endif
+#if !defined SCNx16 || @PRI_MACROS_BROKEN@
+# undef SCNx16
+# ifdef UINT16_MAX
+#  define SCNx16 "hx"
 # endif
-# if !defined SCNd32 || @PRI_MACROS_BROKEN@
-#  undef SCNd32
-#  ifdef INT32_MAX
-#   define SCNd32 "d"
-#  endif
+#endif
+#if !defined SCNd32 || @PRI_MACROS_BROKEN@
+# undef SCNd32
+# ifdef INT32_MAX
+#  define SCNd32 "d"
 # endif
-# if !defined SCNi32 || @PRI_MACROS_BROKEN@
-#  undef SCNi32
-#  ifdef INT32_MAX
-#   define SCNi32 "i"
-#  endif
+#endif
+#if !defined SCNi32 || @PRI_MACROS_BROKEN@
+# undef SCNi32
+# ifdef INT32_MAX
+#  define SCNi32 "i"
 # endif
-# if !defined SCNo32 || @PRI_MACROS_BROKEN@
-#  undef SCNo32
-#  ifdef UINT32_MAX
-#   define SCNo32 "o"
-#  endif
+#endif
+#if !defined SCNo32 || @PRI_MACROS_BROKEN@
+# undef SCNo32
+# ifdef UINT32_MAX
+#  define SCNo32 "o"
 # endif
-# if !defined SCNu32 || @PRI_MACROS_BROKEN@
-#  undef SCNu32
-#  ifdef UINT32_MAX
-#   define SCNu32 "u"
-#  endif
+#endif
+#if !defined SCNu32 || @PRI_MACROS_BROKEN@
+# undef SCNu32
+# ifdef UINT32_MAX
+#  define SCNu32 "u"
 # endif
-# if !defined SCNx32 || @PRI_MACROS_BROKEN@
-#  undef SCNx32
-#  ifdef UINT32_MAX
-#   define SCNx32 "x"
-#  endif
+#endif
+#if !defined SCNx32 || @PRI_MACROS_BROKEN@
+# undef SCNx32
+# ifdef UINT32_MAX
+#  define SCNx32 "x"
 # endif
-# ifdef INT64_MAX
-#  if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @INT64_MAX_EQ_LONG_MAX@)
-#   define _SCN64_PREFIX "l"
-#  elif defined _MSC_VER || defined __MINGW32__
-#   define _SCN64_PREFIX "I64"
-#  elif @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
-#   define _SCN64_PREFIX _LONG_LONG_FORMAT_PREFIX
-#  endif
-#  if !defined SCNd64 || @PRI_MACROS_BROKEN@
-#   undef SCNd64
-#   define SCNd64 _SCN64_PREFIX "d"
-#  endif
-#  if !defined SCNi64 || @PRI_MACROS_BROKEN@
-#   undef SCNi64
-#   define SCNi64 _SCN64_PREFIX "i"
-#  endif
+#endif
+#ifdef INT64_MAX
+# if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @INT64_MAX_EQ_LONG_MAX@)
+#  define _SCN64_PREFIX "l"
+# elif defined _MSC_VER || defined __MINGW32__
+#  define _SCN64_PREFIX "I64"
+# elif @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
+#  define _SCN64_PREFIX _LONG_LONG_FORMAT_PREFIX
+# endif
+# if !defined SCNd64 || @PRI_MACROS_BROKEN@
+#  undef SCNd64
+#  define SCNd64 _SCN64_PREFIX "d"
+# endif
+# if !defined SCNi64 || @PRI_MACROS_BROKEN@
+#  undef SCNi64
+#  define SCNi64 _SCN64_PREFIX "i"
 # endif
-# ifdef UINT64_MAX
-#  if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @UINT64_MAX_EQ_ULONG_MAX@)
-#   define _SCNu64_PREFIX "l"
-#  elif defined _MSC_VER || defined __MINGW32__
-#   define _SCNu64_PREFIX "I64"
-#  elif @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
-#   define _SCNu64_PREFIX _LONG_LONG_FORMAT_PREFIX
-#  endif
-#  if !defined SCNo64 || @PRI_MACROS_BROKEN@
-#   undef SCNo64
-#   define SCNo64 _SCNu64_PREFIX "o"
-#  endif
-#  if !defined SCNu64 || @PRI_MACROS_BROKEN@
-#   undef SCNu64
-#   define SCNu64 _SCNu64_PREFIX "u"
-#  endif
-#  if !defined SCNx64 || @PRI_MACROS_BROKEN@
-#   undef SCNx64
-#   define SCNx64 _SCNu64_PREFIX "x"
-#  endif
+#endif
+#ifdef UINT64_MAX
+# if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @UINT64_MAX_EQ_ULONG_MAX@)
+#  define _SCNu64_PREFIX "l"
+# elif defined _MSC_VER || defined __MINGW32__
+#  define _SCNu64_PREFIX "I64"
+# elif @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
+#  define _SCNu64_PREFIX _LONG_LONG_FORMAT_PREFIX
+# endif
+# if !defined SCNo64 || @PRI_MACROS_BROKEN@
+#  undef SCNo64
+#  define SCNo64 _SCNu64_PREFIX "o"
+# endif
+# if !defined SCNu64 || @PRI_MACROS_BROKEN@
+#  undef SCNu64
+#  define SCNu64 _SCNu64_PREFIX "u"
+# endif
+# if !defined SCNx64 || @PRI_MACROS_BROKEN@
+#  undef SCNx64
+#  define SCNx64 _SCNu64_PREFIX "x"
 # endif
+#endif
 
-# if !defined SCNdLEAST8 || @PRI_MACROS_BROKEN@
-#  undef SCNdLEAST8
-#  define SCNdLEAST8 "hhd"
-# endif
-# if !defined SCNiLEAST8 || @PRI_MACROS_BROKEN@
-#  undef SCNiLEAST8
-#  define SCNiLEAST8 "hhi"
-# endif
-# if !defined SCNoLEAST8 || @PRI_MACROS_BROKEN@
-#  undef SCNoLEAST8
-#  define SCNoLEAST8 "hho"
-# endif
-# if !defined SCNuLEAST8 || @PRI_MACROS_BROKEN@
-#  undef SCNuLEAST8
-#  define SCNuLEAST8 "hhu"
-# endif
-# if !defined SCNxLEAST8 || @PRI_MACROS_BROKEN@
-#  undef SCNxLEAST8
-#  define SCNxLEAST8 "hhx"
-# endif
-# if !defined SCNdLEAST16 || @PRI_MACROS_BROKEN@
-#  undef SCNdLEAST16
-#  define SCNdLEAST16 "hd"
-# endif
-# if !defined SCNiLEAST16 || @PRI_MACROS_BROKEN@
-#  undef SCNiLEAST16
-#  define SCNiLEAST16 "hi"
-# endif
-# if !defined SCNoLEAST16 || @PRI_MACROS_BROKEN@
-#  undef SCNoLEAST16
-#  define SCNoLEAST16 "ho"
-# endif
-# if !defined SCNuLEAST16 || @PRI_MACROS_BROKEN@
-#  undef SCNuLEAST16
-#  define SCNuLEAST16 "hu"
-# endif
-# if !defined SCNxLEAST16 || @PRI_MACROS_BROKEN@
-#  undef SCNxLEAST16
-#  define SCNxLEAST16 "hx"
-# endif
-# if !defined SCNdLEAST32 || @PRI_MACROS_BROKEN@
-#  undef SCNdLEAST32
-#  define SCNdLEAST32 "d"
-# endif
-# if !defined SCNiLEAST32 || @PRI_MACROS_BROKEN@
-#  undef SCNiLEAST32
-#  define SCNiLEAST32 "i"
-# endif
-# if !defined SCNoLEAST32 || @PRI_MACROS_BROKEN@
-#  undef SCNoLEAST32
-#  define SCNoLEAST32 "o"
-# endif
-# if !defined SCNuLEAST32 || @PRI_MACROS_BROKEN@
-#  undef SCNuLEAST32
-#  define SCNuLEAST32 "u"
-# endif
-# if !defined SCNxLEAST32 || @PRI_MACROS_BROKEN@
-#  undef SCNxLEAST32
-#  define SCNxLEAST32 "x"
-# endif
-# ifdef INT64_MAX
-#  if !defined SCNdLEAST64 || @PRI_MACROS_BROKEN@
-#   undef SCNdLEAST64
-#   define SCNdLEAST64 SCNd64
-#  endif
-#  if !defined SCNiLEAST64 || @PRI_MACROS_BROKEN@
-#   undef SCNiLEAST64
-#   define SCNiLEAST64 SCNi64
-#  endif
+#if !defined SCNdLEAST8 || @PRI_MACROS_BROKEN@
+# undef SCNdLEAST8
+# define SCNdLEAST8 "hhd"
+#endif
+#if !defined SCNiLEAST8 || @PRI_MACROS_BROKEN@
+# undef SCNiLEAST8
+# define SCNiLEAST8 "hhi"
+#endif
+#if !defined SCNoLEAST8 || @PRI_MACROS_BROKEN@
+# undef SCNoLEAST8
+# define SCNoLEAST8 "hho"
+#endif
+#if !defined SCNuLEAST8 || @PRI_MACROS_BROKEN@
+# undef SCNuLEAST8
+# define SCNuLEAST8 "hhu"
+#endif
+#if !defined SCNxLEAST8 || @PRI_MACROS_BROKEN@
+# undef SCNxLEAST8
+# define SCNxLEAST8 "hhx"
+#endif
+#if !defined SCNdLEAST16 || @PRI_MACROS_BROKEN@
+# undef SCNdLEAST16
+# define SCNdLEAST16 "hd"
+#endif
+#if !defined SCNiLEAST16 || @PRI_MACROS_BROKEN@
+# undef SCNiLEAST16
+# define SCNiLEAST16 "hi"
+#endif
+#if !defined SCNoLEAST16 || @PRI_MACROS_BROKEN@
+# undef SCNoLEAST16
+# define SCNoLEAST16 "ho"
+#endif
+#if !defined SCNuLEAST16 || @PRI_MACROS_BROKEN@
+# undef SCNuLEAST16
+# define SCNuLEAST16 "hu"
+#endif
+#if !defined SCNxLEAST16 || @PRI_MACROS_BROKEN@
+# undef SCNxLEAST16
+# define SCNxLEAST16 "hx"
+#endif
+#if !defined SCNdLEAST32 || @PRI_MACROS_BROKEN@
+# undef SCNdLEAST32
+# define SCNdLEAST32 "d"
+#endif
+#if !defined SCNiLEAST32 || @PRI_MACROS_BROKEN@
+# undef SCNiLEAST32
+# define SCNiLEAST32 "i"
+#endif
+#if !defined SCNoLEAST32 || @PRI_MACROS_BROKEN@
+# undef SCNoLEAST32
+# define SCNoLEAST32 "o"
+#endif
+#if !defined SCNuLEAST32 || @PRI_MACROS_BROKEN@
+# undef SCNuLEAST32
+# define SCNuLEAST32 "u"
+#endif
+#if !defined SCNxLEAST32 || @PRI_MACROS_BROKEN@
+# undef SCNxLEAST32
+# define SCNxLEAST32 "x"
+#endif
+#ifdef INT64_MAX
+# if !defined SCNdLEAST64 || @PRI_MACROS_BROKEN@
+#  undef SCNdLEAST64
+#  define SCNdLEAST64 SCNd64
 # endif
-# ifdef UINT64_MAX
-#  if !defined SCNoLEAST64 || @PRI_MACROS_BROKEN@
-#   undef SCNoLEAST64
-#   define SCNoLEAST64 SCNo64
-#  endif
-#  if !defined SCNuLEAST64 || @PRI_MACROS_BROKEN@
-#   undef SCNuLEAST64
-#   define SCNuLEAST64 SCNu64
-#  endif
-#  if !defined SCNxLEAST64 || @PRI_MACROS_BROKEN@
-#   undef SCNxLEAST64
-#   define SCNxLEAST64 SCNx64
-#  endif
+# if !defined SCNiLEAST64 || @PRI_MACROS_BROKEN@
+#  undef SCNiLEAST64
+#  define SCNiLEAST64 SCNi64
+# endif
+#endif
+#ifdef UINT64_MAX
+# if !defined SCNoLEAST64 || @PRI_MACROS_BROKEN@
+#  undef SCNoLEAST64
+#  define SCNoLEAST64 SCNo64
+# endif
+# if !defined SCNuLEAST64 || @PRI_MACROS_BROKEN@
+#  undef SCNuLEAST64
+#  define SCNuLEAST64 SCNu64
+# endif
+# if !defined SCNxLEAST64 || @PRI_MACROS_BROKEN@
+#  undef SCNxLEAST64
+#  define SCNxLEAST64 SCNx64
 # endif
+#endif
 
-# if !defined SCNdFAST8 || @PRI_MACROS_BROKEN@
-#  undef SCNdFAST8
-#  if INT_FAST8_MAX > INT32_MAX
-#   define SCNdFAST8 SCNd64
-#  elif INT_FAST8_MAX == 0x7fff
-#   define SCNdFAST8 "hd"
-#  elif INT_FAST8_MAX == 0x7f
-#   define SCNdFAST8 "hhd"
-#  else
-#   define SCNdFAST8 "d"
-#  endif
+#if !defined SCNdFAST8 || @PRI_MACROS_BROKEN@
+# undef SCNdFAST8
+# if INT_FAST8_MAX > INT32_MAX
+#  define SCNdFAST8 SCNd64
+# elif INT_FAST8_MAX == 0x7fff
+#  define SCNdFAST8 "hd"
+# elif INT_FAST8_MAX == 0x7f
+#  define SCNdFAST8 "hhd"
+# else
+#  define SCNdFAST8 "d"
 # endif
-# if !defined SCNiFAST8 || @PRI_MACROS_BROKEN@
-#  undef SCNiFAST8
-#  if INT_FAST8_MAX > INT32_MAX
-#   define SCNiFAST8 SCNi64
-#  elif INT_FAST8_MAX == 0x7fff
-#   define SCNiFAST8 "hi"
-#  elif INT_FAST8_MAX == 0x7f
-#   define SCNiFAST8 "hhi"
-#  else
-#   define SCNiFAST8 "i"
-#  endif
+#endif
+#if !defined SCNiFAST8 || @PRI_MACROS_BROKEN@
+# undef SCNiFAST8
+# if INT_FAST8_MAX > INT32_MAX
+#  define SCNiFAST8 SCNi64
+# elif INT_FAST8_MAX == 0x7fff
+#  define SCNiFAST8 "hi"
+# elif INT_FAST8_MAX == 0x7f
+#  define SCNiFAST8 "hhi"
+# else
+#  define SCNiFAST8 "i"
 # endif
-# if !defined SCNoFAST8 || @PRI_MACROS_BROKEN@
-#  undef SCNoFAST8
-#  if UINT_FAST8_MAX > UINT32_MAX
-#   define SCNoFAST8 SCNo64
-#  elif UINT_FAST8_MAX == 0xffff
-#   define SCNoFAST8 "ho"
-#  elif UINT_FAST8_MAX == 0xff
-#   define SCNoFAST8 "hho"
-#  else
-#   define SCNoFAST8 "o"
-#  endif
+#endif
+#if !defined SCNoFAST8 || @PRI_MACROS_BROKEN@
+# undef SCNoFAST8
+# if UINT_FAST8_MAX > UINT32_MAX
+#  define SCNoFAST8 SCNo64
+# elif UINT_FAST8_MAX == 0xffff
+#  define SCNoFAST8 "ho"
+# elif UINT_FAST8_MAX == 0xff
+#  define SCNoFAST8 "hho"
+# else
+#  define SCNoFAST8 "o"
 # endif
-# if !defined SCNuFAST8 || @PRI_MACROS_BROKEN@
-#  undef SCNuFAST8
-#  if UINT_FAST8_MAX > UINT32_MAX
-#   define SCNuFAST8 SCNu64
-#  elif UINT_FAST8_MAX == 0xffff
-#   define SCNuFAST8 "hu"
-#  elif UINT_FAST8_MAX == 0xff
-#   define SCNuFAST8 "hhu"
-#  else
-#   define SCNuFAST8 "u"
-#  endif
+#endif
+#if !defined SCNuFAST8 || @PRI_MACROS_BROKEN@
+# undef SCNuFAST8
+# if UINT_FAST8_MAX > UINT32_MAX
+#  define SCNuFAST8 SCNu64
+# elif UINT_FAST8_MAX == 0xffff
+#  define SCNuFAST8 "hu"
+# elif UINT_FAST8_MAX == 0xff
+#  define SCNuFAST8 "hhu"
+# else
+#  define SCNuFAST8 "u"
 # endif
-# if !defined SCNxFAST8 || @PRI_MACROS_BROKEN@
-#  undef SCNxFAST8
-#  if UINT_FAST8_MAX > UINT32_MAX
-#   define SCNxFAST8 SCNx64
-#  elif UINT_FAST8_MAX == 0xffff
-#   define SCNxFAST8 "hx"
-#  elif UINT_FAST8_MAX == 0xff
-#   define SCNxFAST8 "hhx"
-#  else
-#   define SCNxFAST8 "x"
-#  endif
+#endif
+#if !defined SCNxFAST8 || @PRI_MACROS_BROKEN@
+# undef SCNxFAST8
+# if UINT_FAST8_MAX > UINT32_MAX
+#  define SCNxFAST8 SCNx64
+# elif UINT_FAST8_MAX == 0xffff
+#  define SCNxFAST8 "hx"
+# elif UINT_FAST8_MAX == 0xff
+#  define SCNxFAST8 "hhx"
+# else
+#  define SCNxFAST8 "x"
 # endif
-# if !defined SCNdFAST16 || @PRI_MACROS_BROKEN@
-#  undef SCNdFAST16
-#  if INT_FAST16_MAX > INT32_MAX
-#   define SCNdFAST16 SCNd64
-#  elif INT_FAST16_MAX == 0x7fff
-#   define SCNdFAST16 "hd"
-#  else
-#   define SCNdFAST16 "d"
-#  endif
+#endif
+#if !defined SCNdFAST16 || @PRI_MACROS_BROKEN@
+# undef SCNdFAST16
+# if INT_FAST16_MAX > INT32_MAX
+#  define SCNdFAST16 SCNd64
+# elif INT_FAST16_MAX == 0x7fff
+#  define SCNdFAST16 "hd"
+# else
+#  define SCNdFAST16 "d"
 # endif
-# if !defined SCNiFAST16 || @PRI_MACROS_BROKEN@
-#  undef SCNiFAST16
-#  if INT_FAST16_MAX > INT32_MAX
-#   define SCNiFAST16 SCNi64
-#  elif INT_FAST16_MAX == 0x7fff
-#   define SCNiFAST16 "hi"
-#  else
-#   define SCNiFAST16 "i"
-#  endif
+#endif
+#if !defined SCNiFAST16 || @PRI_MACROS_BROKEN@
+# undef SCNiFAST16
+# if INT_FAST16_MAX > INT32_MAX
+#  define SCNiFAST16 SCNi64
+# elif INT_FAST16_MAX == 0x7fff
+#  define SCNiFAST16 "hi"
+# else
+#  define SCNiFAST16 "i"
 # endif
-# if !defined SCNoFAST16 || @PRI_MACROS_BROKEN@
-#  undef SCNoFAST16
-#  if UINT_FAST16_MAX > UINT32_MAX
-#   define SCNoFAST16 SCNo64
-#  elif UINT_FAST16_MAX == 0xffff
-#   define SCNoFAST16 "ho"
-#  else
-#   define SCNoFAST16 "o"
-#  endif
+#endif
+#if !defined SCNoFAST16 || @PRI_MACROS_BROKEN@
+# undef SCNoFAST16
+# if UINT_FAST16_MAX > UINT32_MAX
+#  define SCNoFAST16 SCNo64
+# elif UINT_FAST16_MAX == 0xffff
+#  define SCNoFAST16 "ho"
+# else
+#  define SCNoFAST16 "o"
 # endif
-# if !defined SCNuFAST16 || @PRI_MACROS_BROKEN@
-#  undef SCNuFAST16
-#  if UINT_FAST16_MAX > UINT32_MAX
-#   define SCNuFAST16 SCNu64
-#  elif UINT_FAST16_MAX == 0xffff
-#   define SCNuFAST16 "hu"
-#  else
-#   define SCNuFAST16 "u"
-#  endif
+#endif
+#if !defined SCNuFAST16 || @PRI_MACROS_BROKEN@
+# undef SCNuFAST16
+# if UINT_FAST16_MAX > UINT32_MAX
+#  define SCNuFAST16 SCNu64
+# elif UINT_FAST16_MAX == 0xffff
+#  define SCNuFAST16 "hu"
+# else
+#  define SCNuFAST16 "u"
 # endif
-# if !defined SCNxFAST16 || @PRI_MACROS_BROKEN@
-#  undef SCNxFAST16
-#  if UINT_FAST16_MAX > UINT32_MAX
-#   define SCNxFAST16 SCNx64
-#  elif UINT_FAST16_MAX == 0xffff
-#   define SCNxFAST16 "hx"
-#  else
-#   define SCNxFAST16 "x"
-#  endif
+#endif
+#if !defined SCNxFAST16 || @PRI_MACROS_BROKEN@
+# undef SCNxFAST16
+# if UINT_FAST16_MAX > UINT32_MAX
+#  define SCNxFAST16 SCNx64
+# elif UINT_FAST16_MAX == 0xffff
+#  define SCNxFAST16 "hx"
+# else
+#  define SCNxFAST16 "x"
 # endif
-# if !defined SCNdFAST32 || @PRI_MACROS_BROKEN@
-#  undef SCNdFAST32
-#  if INT_FAST32_MAX > INT32_MAX
-#   define SCNdFAST32 SCNd64
-#  else
-#   define SCNdFAST32 "d"
-#  endif
+#endif
+#if !defined SCNdFAST32 || @PRI_MACROS_BROKEN@
+# undef SCNdFAST32
+# if INT_FAST32_MAX > INT32_MAX
+#  define SCNdFAST32 SCNd64
+# else
+#  define SCNdFAST32 "d"
 # endif
-# if !defined SCNiFAST32 || @PRI_MACROS_BROKEN@
-#  undef SCNiFAST32
-#  if INT_FAST32_MAX > INT32_MAX
-#   define SCNiFAST32 SCNi64
-#  else
-#   define SCNiFAST32 "i"
-#  endif
+#endif
+#if !defined SCNiFAST32 || @PRI_MACROS_BROKEN@
+# undef SCNiFAST32
+# if INT_FAST32_MAX > INT32_MAX
+#  define SCNiFAST32 SCNi64
+# else
+#  define SCNiFAST32 "i"
 # endif
-# if !defined SCNoFAST32 || @PRI_MACROS_BROKEN@
-#  undef SCNoFAST32
-#  if UINT_FAST32_MAX > UINT32_MAX
-#   define SCNoFAST32 SCNo64
-#  else
-#   define SCNoFAST32 "o"
-#  endif
+#endif
+#if !defined SCNoFAST32 || @PRI_MACROS_BROKEN@
+# undef SCNoFAST32
+# if UINT_FAST32_MAX > UINT32_MAX
+#  define SCNoFAST32 SCNo64
+# else
+#  define SCNoFAST32 "o"
 # endif
-# if !defined SCNuFAST32 || @PRI_MACROS_BROKEN@
-#  undef SCNuFAST32
-#  if UINT_FAST32_MAX > UINT32_MAX
-#   define SCNuFAST32 SCNu64
-#  else
-#   define SCNuFAST32 "u"
-#  endif
+#endif
+#if !defined SCNuFAST32 || @PRI_MACROS_BROKEN@
+# undef SCNuFAST32
+# if UINT_FAST32_MAX > UINT32_MAX
+#  define SCNuFAST32 SCNu64
+# else
+#  define SCNuFAST32 "u"
 # endif
-# if !defined SCNxFAST32 || @PRI_MACROS_BROKEN@
-#  undef SCNxFAST32
-#  if UINT_FAST32_MAX > UINT32_MAX
-#   define SCNxFAST32 SCNx64
-#  else
-#   define SCNxFAST32 "x"
-#  endif
+#endif
+#if !defined SCNxFAST32 || @PRI_MACROS_BROKEN@
+# undef SCNxFAST32
+# if UINT_FAST32_MAX > UINT32_MAX
+#  define SCNxFAST32 SCNx64
+# else
+#  define SCNxFAST32 "x"
 # endif
-# ifdef INT64_MAX
-#  if !defined SCNdFAST64 || @PRI_MACROS_BROKEN@
-#   undef SCNdFAST64
-#   define SCNdFAST64 SCNd64
-#  endif
-#  if !defined SCNiFAST64 || @PRI_MACROS_BROKEN@
-#   undef SCNiFAST64
-#   define SCNiFAST64 SCNi64
-#  endif
+#endif
+#ifdef INT64_MAX
+# if !defined SCNdFAST64 || @PRI_MACROS_BROKEN@
+#  undef SCNdFAST64
+#  define SCNdFAST64 SCNd64
 # endif
-# ifdef UINT64_MAX
-#  if !defined SCNoFAST64 || @PRI_MACROS_BROKEN@
-#   undef SCNoFAST64
-#   define SCNoFAST64 SCNo64
-#  endif
-#  if !defined SCNuFAST64 || @PRI_MACROS_BROKEN@
-#   undef SCNuFAST64
-#   define SCNuFAST64 SCNu64
-#  endif
-#  if !defined SCNxFAST64 || @PRI_MACROS_BROKEN@
-#   undef SCNxFAST64
-#   define SCNxFAST64 SCNx64
-#  endif
+# if !defined SCNiFAST64 || @PRI_MACROS_BROKEN@
+#  undef SCNiFAST64
+#  define SCNiFAST64 SCNi64
+# endif
+#endif
+#ifdef UINT64_MAX
+# if !defined SCNoFAST64 || @PRI_MACROS_BROKEN@
+#  undef SCNoFAST64
+#  define SCNoFAST64 SCNo64
 # endif
+# if !defined SCNuFAST64 || @PRI_MACROS_BROKEN@
+#  undef SCNuFAST64
+#  define SCNuFAST64 SCNu64
+# endif
+# if !defined SCNxFAST64 || @PRI_MACROS_BROKEN@
+#  undef SCNxFAST64
+#  define SCNxFAST64 SCNx64
+# endif
+#endif
 
-# if !defined SCNdMAX || @PRI_MACROS_BROKEN@
-#  undef SCNdMAX
-#  if @INT32_MAX_LT_INTMAX_MAX@
-#   define SCNdMAX SCNd64
-#  else
-#   define SCNdMAX "ld"
-#  endif
+#if !defined SCNdMAX || @PRI_MACROS_BROKEN@
+# undef SCNdMAX
+# if @INT32_MAX_LT_INTMAX_MAX@
+#  define SCNdMAX SCNd64
+# else
+#  define SCNdMAX "ld"
 # endif
-# if !defined SCNiMAX || @PRI_MACROS_BROKEN@
-#  undef SCNiMAX
-#  if @INT32_MAX_LT_INTMAX_MAX@
-#   define SCNiMAX SCNi64
-#  else
-#   define SCNiMAX "li"
-#  endif
+#endif
+#if !defined SCNiMAX || @PRI_MACROS_BROKEN@
+# undef SCNiMAX
+# if @INT32_MAX_LT_INTMAX_MAX@
+#  define SCNiMAX SCNi64
+# else
+#  define SCNiMAX "li"
 # endif
-# if !defined SCNoMAX || @PRI_MACROS_BROKEN@
-#  undef SCNoMAX
-#  if @UINT32_MAX_LT_UINTMAX_MAX@
-#   define SCNoMAX SCNo64
-#  else
-#   define SCNoMAX "lo"
-#  endif
+#endif
+#if !defined SCNoMAX || @PRI_MACROS_BROKEN@
+# undef SCNoMAX
+# if @UINT32_MAX_LT_UINTMAX_MAX@
+#  define SCNoMAX SCNo64
+# else
+#  define SCNoMAX "lo"
 # endif
-# if !defined SCNuMAX || @PRI_MACROS_BROKEN@
-#  undef SCNuMAX
-#  if @UINT32_MAX_LT_UINTMAX_MAX@
-#   define SCNuMAX SCNu64
-#  else
-#   define SCNuMAX "lu"
-#  endif
+#endif
+#if !defined SCNuMAX || @PRI_MACROS_BROKEN@
+# undef SCNuMAX
+# if @UINT32_MAX_LT_UINTMAX_MAX@
+#  define SCNuMAX SCNu64
+# else
+#  define SCNuMAX "lu"
 # endif
-# if !defined SCNxMAX || @PRI_MACROS_BROKEN@
-#  undef SCNxMAX
-#  if @UINT32_MAX_LT_UINTMAX_MAX@
-#   define SCNxMAX SCNx64
-#  else
-#   define SCNxMAX "lx"
-#  endif
+#endif
+#if !defined SCNxMAX || @PRI_MACROS_BROKEN@
+# undef SCNxMAX
+# if @UINT32_MAX_LT_UINTMAX_MAX@
+#  define SCNxMAX SCNx64
+# else
+#  define SCNxMAX "lx"
 # endif
+#endif
 
-# if !defined SCNdPTR || @PRI_MACROS_BROKEN@
-#  undef SCNdPTR
-#  ifdef INTPTR_MAX
-#   define SCNdPTR @PRIPTR_PREFIX@ "d"
-#  endif
+#if !defined SCNdPTR || @PRI_MACROS_BROKEN@
+# undef SCNdPTR
+# ifdef INTPTR_MAX
+#  define SCNdPTR @PRIPTR_PREFIX@ "d"
 # endif
-# if !defined SCNiPTR || @PRI_MACROS_BROKEN@
-#  undef SCNiPTR
-#  ifdef INTPTR_MAX
-#   define SCNiPTR @PRIPTR_PREFIX@ "i"
-#  endif
+#endif
+#if !defined SCNiPTR || @PRI_MACROS_BROKEN@
+# undef SCNiPTR
+# ifdef INTPTR_MAX
+#  define SCNiPTR @PRIPTR_PREFIX@ "i"
 # endif
-# if !defined SCNoPTR || @PRI_MACROS_BROKEN@
-#  undef SCNoPTR
-#  ifdef UINTPTR_MAX
-#   define SCNoPTR @PRIPTR_PREFIX@ "o"
-#  endif
+#endif
+#if !defined SCNoPTR || @PRI_MACROS_BROKEN@
+# undef SCNoPTR
+# ifdef UINTPTR_MAX
+#  define SCNoPTR @PRIPTR_PREFIX@ "o"
 # endif
-# if !defined SCNuPTR || @PRI_MACROS_BROKEN@
-#  undef SCNuPTR
-#  ifdef UINTPTR_MAX
-#   define SCNuPTR @PRIPTR_PREFIX@ "u"
-#  endif
+#endif
+#if !defined SCNuPTR || @PRI_MACROS_BROKEN@
+# undef SCNuPTR
+# ifdef UINTPTR_MAX
+#  define SCNuPTR @PRIPTR_PREFIX@ "u"
 # endif
-# if !defined SCNxPTR || @PRI_MACROS_BROKEN@
-#  undef SCNxPTR
-#  ifdef UINTPTR_MAX
-#   define SCNxPTR @PRIPTR_PREFIX@ "x"
-#  endif
+#endif
+#if !defined SCNxPTR || @PRI_MACROS_BROKEN@
+# undef SCNxPTR
+# ifdef UINTPTR_MAX
+#  define SCNxPTR @PRIPTR_PREFIX@ "x"
 # endif
-
 #endif
 
 /* 7.8.2 Functions for greatest-width integer types */
@@ -1075,10 +1079,23 @@ _GL_WARN_ON_USE (imaxdiv, "imaxdiv is unportable - "
 #endif
 
 #if @GNULIB_STRTOIMAX@
-# if address@hidden@
-#  undef strtoimax
-extern intmax_t strtoimax (const char *, char **, int) _GL_ARG_NONNULL ((1));
+# if @REPLACE_STRTOIMAX@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef strtoimax
+#   define strtoimax rpl_strtoimax
+#  endif
+_GL_FUNCDECL_RPL (strtoimax, intmax_t,
+                  (const char *, char **, int) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (strtoimax, intmax_t, (const char *, char **, int));
+# else
+#  if address@hidden@
+#   undef strtoimax
+_GL_FUNCDECL_SYS (strtoimax, intmax_t,
+                  (const char *, char **, int) _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (strtoimax, intmax_t, (const char *, char **, int));
 # endif
+_GL_CXXALIASWARN (strtoimax);
 #elif defined GNULIB_POSIXCHECK
 # undef strtoimax
 # if HAVE_RAW_DECL_STRTOIMAX
@@ -1090,8 +1107,11 @@ _GL_WARN_ON_USE (strtoimax, "strtoimax is unportable - "
 #if @GNULIB_STRTOUMAX@
 # if address@hidden@
 #  undef strtoumax
-extern uintmax_t strtoumax (const char *, char **, int) _GL_ARG_NONNULL ((1));
+_GL_FUNCDECL_SYS (strtoumax, uintmax_t,
+                  (const char *, char **, int) _GL_ARG_NONNULL ((1)));
 # endif
+_GL_CXXALIAS_SYS (strtoumax, uintmax_t, (const char *, char **, int));
+_GL_CXXALIASWARN (strtoumax);
 #elif defined GNULIB_POSIXCHECK
 # undef strtoumax
 # if HAVE_RAW_DECL_STRTOUMAX
diff --git a/gltests/ioctl.c b/gltests/ioctl.c
index c6ba989..2e51c92 100644
--- a/gltests/ioctl.c
+++ b/gltests/ioctl.c
@@ -1,6 +1,6 @@
 /* ioctl.c --- wrappers for Windows ioctl function
 
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
@@ -47,6 +47,8 @@ rpl_ioctl (int fd, int request, ... /* {void *,char *} arg */)
 # include <errno.h>
 
 # include "fd-hook.h"
+/* Get _get_osfhandle.  */
+# include "msvc-nothrow.h"
 
 static int
 primary_ioctl (int fd, int request, void *arg)
@@ -55,7 +57,10 @@ primary_ioctl (int fd, int request, void *arg)
      fds non-blocking, use the gnulib 'nonblocking' module, until
      gnulib implements fcntl F_GETFL / F_SETFL with O_NONBLOCK.  */
 
-  errno = ENOSYS;
+  if ((HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE)
+    errno = ENOSYS;
+  else
+    errno = EBADF;
   return -1;
 }
 
diff --git a/gltests/listen.c b/gltests/listen.c
index 938aa75..a1b2ab7 100644
--- a/gltests/listen.c
+++ b/gltests/listen.c
@@ -1,6 +1,6 @@
 /* listen.c --- wrappers for Windows listen function
 
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
@@ -32,9 +32,18 @@ int
 rpl_listen (int fd, int backlog)
 {
   SOCKET sock = FD_TO_SOCKET (fd);
-  int r = listen (sock, backlog);
-  if (r < 0)
-    set_winsock_errno ();
 
-  return r;
+  if (sock == INVALID_SOCKET)
+    {
+      errno = EBADF;
+      return -1;
+    }
+  else
+    {
+      int r = listen (sock, backlog);
+      if (r < 0)
+        set_winsock_errno ();
+
+      return r;
+    }
 }
diff --git a/gltests/locale.in.h b/gltests/locale.in.h
index 79c1490..a97e3e7 100644
--- a/gltests/locale.in.h
+++ b/gltests/locale.in.h
@@ -1,5 +1,5 @@
 /* A POSIX <locale.h>.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
diff --git a/gltests/localename.c b/gltests/localename.c
index faab700..869dbf2 100644
--- a/gltests/localename.c
+++ b/gltests/localename.c
@@ -1,5 +1,5 @@
 /* Determine name of the currently selected locale.
-   Copyright (C) 1995-2011 Free Software Foundation, Inc.
+   Copyright (C) 1995-2012 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
@@ -15,7 +15,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* Written by Ulrich Drepper <address@hidden>, 1995.  */
-/* Win32 code written by Tor Lillqvist <address@hidden>.  */
+/* Native Windows code written by Tor Lillqvist <address@hidden>.  */
 /* MacOS X code written by Bruno Haible <address@hidden>.  */
 
 #include <config.h>
@@ -54,10 +54,10 @@
 #endif
 
 #if defined _WIN32 || defined __WIN32__
-# define WIN32_NATIVE
+# define WINDOWS_NATIVE
 #endif
 
-#if defined WIN32_NATIVE || defined __CYGWIN__ /* WIN32 or Cygwin */
+#if defined WINDOWS_NATIVE || defined __CYGWIN__ /* Native Windows or Cygwin */
 # define WIN32_LEAN_AND_MEAN
 # include <windows.h>
 /* List of language codes, sorted by value:
@@ -1405,11 +1405,11 @@ gl_locale_name_canonicalize (char *name)
 #endif
 
 
-#if defined WIN32_NATIVE || defined __CYGWIN__ /* WIN32 or Cygwin */
+#if defined WINDOWS_NATIVE || defined __CYGWIN__ /* Native Windows or Cygwin */
 
-/* Canonicalize a Win32 native locale name to a Unix locale name.
+/* Canonicalize a Windows native locale name to a Unix locale name.
    NAME is a sufficiently large buffer.
-   On input, it contains the Win32 locale name.
+   On input, it contains the Windows locale name.
    On output, it contains the Unix locale name.  */
 # if !defined IN_LIBINTL
 static
@@ -1465,9 +1465,9 @@ gl_locale_name_from_win32_LANGID (LANGID langid)
     }
   /* Internet Explorer has an LCID to RFC3066 name mapping stored in
      HKEY_CLASSES_ROOT\Mime\Database\Rfc1766.  But we better don't use that
-     since IE's i18n subsystem is known to be inconsistent with the Win32 base
-     (e.g. they have different character conversion facilities that produce
-     different results).  */
+     since IE's i18n subsystem is known to be inconsistent with the native
+     Windows base (e.g. they have different character conversion facilities
+     that produce different results).  */
   /* Use our own table.  */
   {
     int primary, sub;
@@ -2866,7 +2866,7 @@ gl_locale_name_default (void)
          "C.UTF-8" locale, which operates in the same way as the "C" locale.
   */
 
-#if !(HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE || defined 
WIN32_NATIVE || defined __CYGWIN__)
+#if !(HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE || defined 
WINDOWS_NATIVE || defined __CYGWIN__)
 
   /* The system does not have a way of setting the locale, other than the
      POSIX specified environment variables.  We use C as default locale.  */
@@ -2921,11 +2921,11 @@ gl_locale_name_default (void)
 
 # endif
 
-# if defined WIN32_NATIVE || defined __CYGWIN__ /* WIN32 or Cygwin */
+# if defined WINDOWS_NATIVE || defined __CYGWIN__ /* Native Windows or Cygwin 
*/
   {
     LCID lcid;
 
-    /* Use native Win32 API locale ID.  */
+    /* Use native Windows API locale ID.  */
     lcid = GetThreadLocale ();
 
     return gl_locale_name_from_win32_LCID (lcid);
diff --git a/gltests/localename.h b/gltests/localename.h
index ea59f51..330932d 100644
--- a/gltests/localename.h
+++ b/gltests/localename.h
@@ -1,5 +1,5 @@
 /* Determine name of the currently selected locale.
-   Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2012 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
diff --git a/gltests/lstat.c b/gltests/lstat.c
index b26065e..db119a1 100644
--- a/gltests/lstat.c
+++ b/gltests/lstat.c
@@ -1,6 +1,6 @@
 /* Work around a bug of lstat on some systems
 
-   Copyright (C) 1997-2006, 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 1997-2006, 2008-2012 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
@@ -17,6 +17,10 @@
 
 /* written by Jim Meyering */
 
+/* If the user's config.h happens to include <sys/stat.h>, let it include only
+   the system's <sys/stat.h> here, so that orig_lstat doesn't recurse to
+   rpl_lstat.  */
+#define __need_system_sys_stat_h
 #include <config.h>
 
 #if !HAVE_LSTAT
@@ -27,7 +31,6 @@ typedef int dummy;
 #else /* HAVE_LSTAT */
 
 /* Get the original definition of lstat.  It might be defined as a macro.  */
-# define __need_system_sys_stat_h
 # include <sys/types.h>
 # include <sys/stat.h>
 # undef __need_system_sys_stat_h
@@ -39,17 +42,20 @@ orig_lstat (const char *filename, struct stat *buf)
 }
 
 /* Specification.  */
-# include <sys/stat.h>
+/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
+   eliminates this include because of the preliminary #include <sys/stat.h>
+   above.  */
+# include "sys/stat.h"
 
 # include <string.h>
 # include <errno.h>
 
 /* lstat works differently on Linux and Solaris systems.  POSIX (see
-   `pathname resolution' in the glossary) requires that programs like
-   `ls' take into consideration the fact that FILE has a trailing slash
+   "pathname resolution" in the glossary) requires that programs like
+   'ls' take into consideration the fact that FILE has a trailing slash
    when FILE is a symbolic link.  On Linux and Solaris 10 systems, the
    lstat function already has the desired semantics (in treating
-   `lstat ("symlink/", sbuf)' just like `lstat ("symlink/.", sbuf)',
+   'lstat ("symlink/", sbuf)' just like 'lstat ("symlink/.", sbuf)',
    but on Solaris 9 and earlier it does not.
 
    If FILE has a trailing slash and specifies a symbolic link,
diff --git a/gltests/macros.h b/gltests/macros.h
index adb3744..77a92f8 100644
--- a/gltests/macros.h
+++ b/gltests/macros.h
@@ -1,5 +1,5 @@
 /* Common macros used by gnulib tests.
-   Copyright (C) 2006-2011 Free Software Foundation, Inc.
+   Copyright (C) 2006-2012 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
diff --git a/gltests/malloca.c b/gltests/malloca.c
index ce071f1..009ca0c 100644
--- a/gltests/malloca.c
+++ b/gltests/malloca.c
@@ -1,5 +1,5 @@
 /* Safe automatic memory allocation.
-   Copyright (C) 2003, 2006-2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2006-2007, 2009-2012 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2003.
 
    This program is free software; you can redistribute it and/or modify
@@ -22,6 +22,8 @@
 /* Specification.  */
 #include "malloca.h"
 
+#include <stdint.h>
+
 #include "verify.h"
 
 /* The speed critical point in this file is freea() applied to an alloca()
@@ -85,7 +87,7 @@ mmalloca (size_t n)
           ((int *) p)[-1] = MAGIC_NUMBER;
 
           /* Enter p into the hash table.  */
-          slot = (unsigned long) p % HASH_TABLE_SIZE;
+          slot = (uintptr_t) p % HASH_TABLE_SIZE;
           ((struct header *) (p - HEADER_SIZE))->next = mmalloca_results[slot];
           mmalloca_results[slot] = p;
 
@@ -118,7 +120,7 @@ freea (void *p)
         {
           /* Looks like a mmalloca() result.  To see whether it really is one,
              perform a lookup in the hash table.  */
-          size_t slot = (unsigned long) p % HASH_TABLE_SIZE;
+          size_t slot = (uintptr_t) p % HASH_TABLE_SIZE;
           void **chain = &mmalloca_results[slot];
           for (; *chain != NULL;)
             {
diff --git a/gltests/malloca.h b/gltests/malloca.h
index 7083a58..725cc22 100644
--- a/gltests/malloca.h
+++ b/gltests/malloca.h
@@ -1,5 +1,5 @@
 /* Safe automatic memory allocation.
-   Copyright (C) 2003-2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2003-2007, 2009-2012 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2003.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/gltests/mbtowc-impl.h b/gltests/mbtowc-impl.h
index 1645eb5..bb75ed2 100644
--- a/gltests/mbtowc-impl.h
+++ b/gltests/mbtowc-impl.h
@@ -1,5 +1,5 @@
 /* Convert multibyte character to wide character.
-   Copyright (C) 2011 Free Software Foundation, Inc.
+   Copyright (C) 2011-2012 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2011.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/gltests/mbtowc.c b/gltests/mbtowc.c
index b3848a1..97eab4e 100644
--- a/gltests/mbtowc.c
+++ b/gltests/mbtowc.c
@@ -1,5 +1,5 @@
 /* Convert multibyte character to wide character.
-   Copyright (C) 2011 Free Software Foundation, Inc.
+   Copyright (C) 2011-2012 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2011.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/gltests/open.c b/gltests/open.c
index e60b619..27801b9 100644
--- a/gltests/open.c
+++ b/gltests/open.c
@@ -1,5 +1,5 @@
 /* Open a descriptor to a file.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
@@ -16,13 +16,16 @@
 
 /* Written by Bruno Haible <address@hidden>, 2007.  */
 
+/* If the user's config.h happens to include <fcntl.h>, let it include only
+   the system's <fcntl.h> here, so that orig_open doesn't recurse to
+   rpl_open.  */
+#define __need_system_fcntl_h
 #include <config.h>
 
 /* Get the original definition of open.  It might be defined as a macro.  */
-#define __need_system_fcntl_h
 #include <fcntl.h>
-#undef __need_system_fcntl_h
 #include <sys/types.h>
+#undef __need_system_fcntl_h
 
 static inline int
 orig_open (const char *filename, int flags, mode_t mode)
@@ -31,7 +34,9 @@ orig_open (const char *filename, int flags, mode_t mode)
 }
 
 /* Specification.  */
-#include <fcntl.h>
+/* Write "fcntl.h" here, not <fcntl.h>, otherwise OSF/1 5.1 DTK cc eliminates
+   this include because of the preliminary #include <fcntl.h> above.  */
+#include "fcntl.h"
 
 #include <errno.h>
 #include <stdarg.h>
diff --git a/gltests/pathmax.h b/gltests/pathmax.h
new file mode 100644
index 0000000..0fd9296
--- /dev/null
+++ b/gltests/pathmax.h
@@ -0,0 +1,84 @@
+/* Define PATH_MAX somehow.  Requires sys/types.h.
+   Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2012 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
+   the Free Software Foundation; either version 3, 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 General Public License for more details.
+
+   You should have received a copy of the GNU 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.  */
+
+#ifndef _PATHMAX_H
+# define _PATHMAX_H
+
+/* POSIX:2008 defines PATH_MAX to be the maximum number of bytes in a filename,
+   including the terminating NUL byte.
+   <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html>
+   PATH_MAX is not defined on systems which have no limit on filename length,
+   such as GNU/Hurd.
+
+   This file does *not* define PATH_MAX always.  Programs that use this file
+   can handle the GNU/Hurd case in several ways:
+     - Either with a package-wide handling, or with a per-file handling,
+     - Either through a
+         #ifdef PATH_MAX
+       or through a fallback like
+         #ifndef PATH_MAX
+         # define PATH_MAX 8192
+         #endif
+       or through a fallback like
+         #ifndef PATH_MAX
+         # define PATH_MAX pathconf ("/", _PC_PATH_MAX)
+         #endif
+ */
+
+# include <unistd.h>
+
+# include <limits.h>
+
+# ifndef _POSIX_PATH_MAX
+#  define _POSIX_PATH_MAX 256
+# endif
+
+/* Don't include sys/param.h if it already has been.  */
+# if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN
+#  include <sys/param.h>
+# endif
+
+# if !defined PATH_MAX && defined MAXPATHLEN
+#  define PATH_MAX MAXPATHLEN
+# endif
+
+# ifdef __hpux
+/* On HP-UX, PATH_MAX designates the maximum number of bytes in a filename,
+   *not* including the terminating NUL byte, and is set to 1023.
+   Additionally, when _XOPEN_SOURCE is defined to 500 or more, PATH_MAX is
+   not defined at all any more.  */
+#  undef PATH_MAX
+#  define PATH_MAX 1024
+# endif
+
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+/* The page "Naming Files, Paths, and Namespaces" on msdn.microsoft.com,
+   section "Maximum Path Length Limitation",
+   <http://msdn.microsoft.com/en-us/library/aa365247(v=vs.85).aspx#maxpath>
+   explains that the maximum size of a filename, including the terminating
+   NUL byte, is 260 = 3 + 256 + 1.
+   This is the same value as
+     - FILENAME_MAX in <stdio.h>,
+     - _MAX_PATH in <stdlib.h>,
+     - MAX_PATH in <windef.h>.
+   Undefine the original value, because mingw's <limits.h> gets it wrong.  */
+#  undef PATH_MAX
+#  define PATH_MAX 260
+# endif
+
+#endif /* _PATHMAX_H */
diff --git a/gltests/perror.c b/gltests/perror.c
index af4b56c..4853d1b 100644
--- a/gltests/perror.c
+++ b/gltests/perror.c
@@ -1,5 +1,5 @@
 /* Print a message describing error code.
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 Free Software Foundation, Inc.
    Written by Bruno Haible and Simon Josefsson.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/gltests/pipe.c b/gltests/pipe.c
index cfd8acb..e7e4253 100644
--- a/gltests/pipe.c
+++ b/gltests/pipe.c
@@ -1,5 +1,5 @@
 /* Create a pipe.
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 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
@@ -21,7 +21,7 @@
 #include <unistd.h>
 
 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-/* Native Woe32 API.  */
+/* Native Windows API.  */
 
 /* Get _pipe().  */
 # include <io.h>
@@ -32,7 +32,16 @@
 int
 pipe (int fd[2])
 {
-  return _pipe (fd, 4096, _O_BINARY);
+  /* Mingw changes fd to {-1,-1} on failure, but this violates
+     http://austingroupbugs.net/view.php?id=467 */
+  int tmp[2];
+  int result = _pipe (tmp, 4096, _O_BINARY);
+  if (!result)
+    {
+      fd[0] = tmp[0];
+      fd[1] = tmp[1];
+    }
+  return result;
 }
 
 #else
diff --git a/gltests/putenv.c b/gltests/putenv.c
index 68e5fec..3c0f7ea 100644
--- a/gltests/putenv.c
+++ b/gltests/putenv.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1994, 1997-1998, 2000, 2003-2011 Free Software
+/* Copyright (C) 1991, 1994, 1997-1998, 2000, 2003-2012 Free Software
    Foundation, Inc.
 
    NOTE: The canonical source of this file is maintained with the GNU C
@@ -34,14 +34,16 @@
 #include <string.h>
 #include <unistd.h>
 
-#if HAVE_GNU_LD
-# define environ __environ
-#else
+#if _LIBC
+# if HAVE_GNU_LD
+#  define environ __environ
+# else
 extern char **environ;
+# endif
 #endif
 
 #if _LIBC
-/* This lock protects against simultaneous modifications of `environ'.  */
+/* This lock protects against simultaneous modifications of 'environ'.  */
 # include <bits/libc-lock.h>
 __libc_lock_define_initialized (static, envlock)
 # define LOCK   __libc_lock_lock (envlock)
@@ -89,7 +91,7 @@ _unsetenv (const char *name)
 
 
 /* Put STRING, which is of the form "NAME=VALUE", in the environment.
-   If STRING contains no `=', then remove STRING from the environment.  */
+   If STRING contains no '=', then remove STRING from the environment.  */
 int
 putenv (char *string)
 {
diff --git a/gltests/same-inode.h b/gltests/same-inode.h
index d434b94..8c3900d 100644
--- a/gltests/same-inode.h
+++ b/gltests/same-inode.h
@@ -1,6 +1,6 @@
 /* Determine whether two stat buffers refer to the same file.
 
-   Copyright (C) 2006, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2009-2012 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
@@ -18,8 +18,16 @@
 #ifndef SAME_INODE_H
 # define SAME_INODE_H 1
 
-# define SAME_INODE(Stat_buf_1, Stat_buf_2) \
-   ((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
-    && (Stat_buf_1).st_dev == (Stat_buf_2).st_dev)
+# ifdef __VMS
+#  define SAME_INODE(a, b)             \
+    ((a).st_ino[0] == (b).st_ino[0]    \
+     && (a).st_ino[1] == (b).st_ino[1] \
+     && (a).st_ino[2] == (b).st_ino[2] \
+     && (a).st_dev == (b).st_dev)
+# else
+#  define SAME_INODE(a, b)    \
+    ((a).st_ino == (b).st_ino \
+     && (a).st_dev == (b).st_dev)
+# endif
 
 #endif
diff --git a/gltests/setenv.c b/gltests/setenv.c
index 0a5f67d..8201be2 100644
--- a/gltests/setenv.c
+++ b/gltests/setenv.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1995-2003, 2005-2011 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1995-2003, 2005-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    This program is free software: you can redistribute it and/or modify
@@ -49,7 +49,7 @@
 #endif
 
 #if _LIBC
-/* This lock protects against simultaneous modifications of `environ'.  */
+/* This lock protects against simultaneous modifications of 'environ'.  */
 # include <bits/libc-lock.h>
 __libc_lock_define_initialized (static, envlock)
 # define LOCK   __libc_lock_lock (envlock)
@@ -103,11 +103,11 @@ static void *known_values;
 static char **last_environ;
 
 
-/* This function is used by `setenv' and `putenv'.  The difference between
+/* This function is used by 'setenv' and 'putenv'.  The difference between
    the two functions is that for the former must create a new string which
-   is then placed in the environment, while the argument of `putenv'
+   is then placed in the environment, while the argument of 'putenv'
    must be used directly.  This is all complicated by the fact that we try
-   to reuse values once generated for a `setenv' call since we can never
+   to reuse values once generated for a 'setenv' call since we can never
    free the strings.  */
 int
 __add_to_environ (const char *name, const char *value, const char *combined,
@@ -299,7 +299,7 @@ setenv (const char *name, const char *value, int replace)
   return __add_to_environ (name, value, NULL, replace);
 }
 
-/* The `clearenv' was planned to be added to POSIX.1 but probably
+/* The 'clearenv' was planned to be added to POSIX.1 but probably
    never made it.  Nevertheless the POSIX.9 standard (POSIX bindings
    for Fortran 77) requires this function.  */
 int
diff --git a/gltests/setlocale.c b/gltests/setlocale.c
index 0cef00f..8a47cde 100644
--- a/gltests/setlocale.c
+++ b/gltests/setlocale.c
@@ -1,5 +1,5 @@
 /* Set the current locale.
-   Copyright (C) 2009, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2011-2012 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
@@ -74,7 +74,7 @@ category_to_name (int category)
 
 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
 
-/* The native Win32 setlocale() function expects locale names of the form
+/* The native Windows setlocale() function expects locale names of the form
    "German" or "German_Germany" or "DEU", but not "de" or "de_DE".  We need
    to convert the names from the form with ISO 639 language code and ISO 3166
    country code to the form with English names or with three-letter identifier.
diff --git a/gltests/setsockopt.c b/gltests/setsockopt.c
index a31a10e..9f414d5 100644
--- a/gltests/setsockopt.c
+++ b/gltests/setsockopt.c
@@ -1,6 +1,6 @@
 /* setsockopt.c --- wrappers for Windows setsockopt function
 
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
@@ -34,23 +34,32 @@
 int
 rpl_setsockopt (int fd, int level, int optname, const void *optval, socklen_t 
optlen)
 {
-  int r;
   SOCKET sock = FD_TO_SOCKET (fd);
+  int r;
 
-  if (level == SOL_SOCKET && (optname == SO_RCVTIMEO || optname == 
SO_SNDTIMEO))
+  if (sock == INVALID_SOCKET)
     {
-      const struct timeval *tv = optval;
-      int milliseconds = tv->tv_sec * 1000 + tv->tv_usec / 1000;
-      optval = &milliseconds;
-      r = setsockopt (sock, level, optname, optval, sizeof (int));
+      errno = EBADF;
+      return -1;
     }
   else
     {
-      r = setsockopt (sock, level, optname, optval, optlen);
-    }
+      if (level == SOL_SOCKET
+          && (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO))
+        {
+          const struct timeval *tv = optval;
+          int milliseconds = tv->tv_sec * 1000 + tv->tv_usec / 1000;
+          optval = &milliseconds;
+          r = setsockopt (sock, level, optname, optval, sizeof (int));
+        }
+      else
+        {
+          r = setsockopt (sock, level, optname, optval, optlen);
+        }
 
-  if (r < 0)
-    set_winsock_errno ();
+      if (r < 0)
+        set_winsock_errno ();
 
-  return r;
+      return r;
+    }
 }
diff --git a/gltests/signature.h b/gltests/signature.h
index 8256989..d9d8b47 100644
--- a/gltests/signature.h
+++ b/gltests/signature.h
@@ -1,5 +1,5 @@
 /* Macro for checking that a function declaration is compliant.
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 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
diff --git a/gltests/stat.c b/gltests/stat.c
index f07370d..9ea53c1 100644
--- a/gltests/stat.c
+++ b/gltests/stat.c
@@ -1,5 +1,5 @@
 /* Work around platform bugs in stat.
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 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
@@ -16,10 +16,13 @@
 
 /* written by Eric Blake */
 
+/* If the user's config.h happens to include <sys/stat.h>, let it include only
+   the system's <sys/stat.h> here, so that orig_stat doesn't recurse to
+   rpl_stat.  */
+#define __need_system_sys_stat_h
 #include <config.h>
 
 /* Get the original definition of stat.  It might be defined as a macro.  */
-#define __need_system_sys_stat_h
 #include <sys/types.h>
 #include <sys/stat.h>
 #undef __need_system_sys_stat_h
@@ -31,7 +34,10 @@ orig_stat (const char *filename, struct stat *buf)
 }
 
 /* Specification.  */
-#include <sys/stat.h>
+/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
+   eliminates this include because of the preliminary #include <sys/stat.h>
+   above.  */
+#include "sys/stat.h"
 
 #include <errno.h>
 #include <limits.h>
@@ -40,6 +46,15 @@ orig_stat (const char *filename, struct stat *buf)
 #include "dosname.h"
 #include "verify.h"
 
+#if REPLACE_FUNC_STAT_DIR
+# include "pathmax.h"
+  /* The only known systems where REPLACE_FUNC_STAT_DIR is needed also
+     have a constant PATH_MAX.  */
+# ifndef PATH_MAX
+#  error "Please port this replacement to your platform"
+# endif
+#endif
+
 /* Store information about NAME into ST.  Work around bugs with
    trailing slashes.  Mingw has other bugs (such as st_ino always
    being 0 on success) which this wrapper does not work around.  But
@@ -64,11 +79,6 @@ rpl_stat (char const *name, struct stat *st)
     }
 #endif /* REPLACE_FUNC_STAT_FILE */
 #if REPLACE_FUNC_STAT_DIR
-  /* The only known systems where REPLACE_FUNC_STAT_DIR is needed also
-     have a constant PATH_MAX.  */
-# ifndef PATH_MAX
-#  error "Please port this replacement to your platform"
-# endif
 
   if (result == -1 && errno == ENOENT)
     {
diff --git a/gltests/strerror_r.c b/gltests/strerror_r.c
index 2b3f1f2..be76b0d 100644
--- a/gltests/strerror_r.c
+++ b/gltests/strerror_r.c
@@ -1,6 +1,6 @@
 /* strerror_r.c --- POSIX compatible system error routine
 
-   Copyright (C) 2010-2011 Free Software Foundation, Inc.
+   Copyright (C) 2010-2012 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
@@ -86,6 +86,27 @@ gl_lock_define_initialized(static, strerror_lock)
 
 #endif
 
+/* On MSVC, there is no snprintf() function, just a _snprintf().
+   It is of lower quality, but sufficient for the simple use here.
+   We only have to make sure to NUL terminate the result (_snprintf
+   does not NUL terminate, like strncpy).  */
+#if !HAVE_SNPRINTF
+static int
+local_snprintf (char *buf, size_t buflen, const char *format, ...)
+{
+  va_list args;
+  int result;
+
+  va_start (args, format);
+  result = _vsnprintf (buf, buflen, format, args);
+  va_end (args);
+  if (buflen > 0 && (result < 0 || result >= buflen))
+    buf[buflen - 1] = '\0';
+  return result;
+}
+# define snprintf local_snprintf
+#endif
+
 /* Copy as much of MSG into BUF as possible, without corrupting errno.
    Return 0 if MSG fit in BUFLEN, otherwise return ERANGE.  */
 static int
@@ -220,13 +241,13 @@ strerror_r (int errnum, char *buf, size_t buflen)
     /* Try to do what strerror (errnum) does, but without clobbering the
        buffer used by strerror().  */
 
-# if defined __NetBSD__ || defined __hpux || ((defined _WIN32 || defined 
__WIN32__) && !defined __CYGWIN__) || defined __CYGWIN__ /* NetBSD, HP-UX, 
native Win32, Cygwin */
+# if defined __NetBSD__ || defined __hpux || ((defined _WIN32 || defined 
__WIN32__) && !defined __CYGWIN__) || defined __CYGWIN__ /* NetBSD, HP-UX, 
native Windows, Cygwin */
 
-    /* NetBSD:        sys_nerr, sys_errlist are declared through _NETBSD_SOURCE
-                      and <errno.h> above.
-       HP-UX:         sys_nerr, sys_errlist are declared explicitly above.
-       native Win32:  sys_nerr, sys_errlist are declared in <stdlib.h>.
-       Cygwin:        sys_nerr, sys_errlist are declared in <errno.h>.  */
+    /* NetBSD:         sys_nerr, sys_errlist are declared through 
_NETBSD_SOURCE
+                       and <errno.h> above.
+       HP-UX:          sys_nerr, sys_errlist are declared explicitly above.
+       native Windows: sys_nerr, sys_errlist are declared in <stdlib.h>.
+       Cygwin:         sys_nerr, sys_errlist are declared in <errno.h>.  */
     if (errnum >= 0 && errnum < sys_nerr)
       {
 #  if HAVE_CATGETS && (defined __NetBSD__ || defined __hpux)
diff --git a/gltests/symlink.c b/gltests/symlink.c
index 2896cc9..642ca66 100644
--- a/gltests/symlink.c
+++ b/gltests/symlink.c
@@ -1,5 +1,5 @@
 /* Stub for symlink().
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 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
diff --git a/gltests/sys_ioctl.in.h b/gltests/sys_ioctl.in.h
index dc8aeda..f213411 100644
--- a/gltests/sys_ioctl.in.h
+++ b/gltests/sys_ioctl.in.h
@@ -1,5 +1,5 @@
 /* Substitute for and wrapper around <sys/ioctl.h>.
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
diff --git a/gltests/sys_stat.in.h b/gltests/sys_stat.in.h
deleted file mode 100644
index 5acee70..0000000
--- a/gltests/sys_stat.in.h
+++ /dev/null
@@ -1,658 +0,0 @@
-/* Provide a more complete sys/stat header file.
-   Copyright (C) 2005-2011 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
-   the Free Software Foundation; either version 3, 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 General Public License for more details.
-
-   You should have received a copy of the GNU 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 Eric Blake, Paul Eggert, and Jim Meyering.  */
-
-/* This file is supposed to be used on platforms where <sys/stat.h> is
-   incomplete.  It is intended to provide definitions and prototypes
-   needed by an application.  Start with what the system provides.  */
-
-#if __GNUC__ >= 3
address@hidden@
-#endif
address@hidden@
-
-#if defined __need_system_sys_stat_h
-/* Special invocation convention.  */
-
address@hidden@ @NEXT_SYS_STAT_H@
-
-#else
-/* Normal invocation convention.  */
-
-#ifndef address@hidden@_SYS_STAT_H
-
-/* Get nlink_t.  */
-#include <sys/types.h>
-
-/* Get struct timespec.  */
-#include <time.h>
-
-/* The include_next requires a split double-inclusion guard.  */
address@hidden@ @NEXT_SYS_STAT_H@
-
-#ifndef address@hidden@_SYS_STAT_H
-#define address@hidden@_SYS_STAT_H
-
-/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
-
-/* The definition of _GL_ARG_NONNULL is copied here.  */
-
-/* The definition of _GL_WARN_ON_USE is copied here.  */
-
-/* Before doing "#define mkdir rpl_mkdir" below, we need to include all
-   headers that may declare mkdir().  */
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-# include <io.h>     /* mingw32, mingw64 */
-# include <direct.h> /* mingw64 */
-#endif
-
-#ifndef S_IFMT
-# define S_IFMT 0170000
-#endif
-
-#if STAT_MACROS_BROKEN
-# undef S_ISBLK
-# undef S_ISCHR
-# undef S_ISDIR
-# undef S_ISFIFO
-# undef S_ISLNK
-# undef S_ISNAM
-# undef S_ISMPB
-# undef S_ISMPC
-# undef S_ISNWK
-# undef S_ISREG
-# undef S_ISSOCK
-#endif
-
-#ifndef S_ISBLK
-# ifdef S_IFBLK
-#  define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
-# else
-#  define S_ISBLK(m) 0
-# endif
-#endif
-
-#ifndef S_ISCHR
-# ifdef S_IFCHR
-#  define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
-# else
-#  define S_ISCHR(m) 0
-# endif
-#endif
-
-#ifndef S_ISDIR
-# ifdef S_IFDIR
-#  define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
-# else
-#  define S_ISDIR(m) 0
-# endif
-#endif
-
-#ifndef S_ISDOOR /* Solaris 2.5 and up */
-# define S_ISDOOR(m) 0
-#endif
-
-#ifndef S_ISFIFO
-# ifdef S_IFIFO
-#  define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
-# else
-#  define S_ISFIFO(m) 0
-# endif
-#endif
-
-#ifndef S_ISLNK
-# ifdef S_IFLNK
-#  define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
-# else
-#  define S_ISLNK(m) 0
-# endif
-#endif
-
-#ifndef S_ISMPB /* V7 */
-# ifdef S_IFMPB
-#  define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
-#  define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
-# else
-#  define S_ISMPB(m) 0
-#  define S_ISMPC(m) 0
-# endif
-#endif
-
-#ifndef S_ISNAM /* Xenix */
-# ifdef S_IFNAM
-#  define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
-# else
-#  define S_ISNAM(m) 0
-# endif
-#endif
-
-#ifndef S_ISNWK /* HP/UX */
-# ifdef S_IFNWK
-#  define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
-# else
-#  define S_ISNWK(m) 0
-# endif
-#endif
-
-#ifndef S_ISPORT /* Solaris 10 and up */
-# define S_ISPORT(m) 0
-#endif
-
-#ifndef S_ISREG
-# ifdef S_IFREG
-#  define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
-# else
-#  define S_ISREG(m) 0
-# endif
-#endif
-
-#ifndef S_ISSOCK
-# ifdef S_IFSOCK
-#  define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
-# else
-#  define S_ISSOCK(m) 0
-# endif
-#endif
-
-
-#ifndef S_TYPEISMQ
-# define S_TYPEISMQ(p) 0
-#endif
-
-#ifndef S_TYPEISTMO
-# define S_TYPEISTMO(p) 0
-#endif
-
-
-#ifndef S_TYPEISSEM
-# ifdef S_INSEM
-#  define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
-# else
-#  define S_TYPEISSEM(p) 0
-# endif
-#endif
-
-#ifndef S_TYPEISSHM
-# ifdef S_INSHD
-#  define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
-# else
-#  define S_TYPEISSHM(p) 0
-# endif
-#endif
-
-/* high performance ("contiguous data") */
-#ifndef S_ISCTG
-# define S_ISCTG(p) 0
-#endif
-
-/* Cray DMF (data migration facility): off line, with data  */
-#ifndef S_ISOFD
-# define S_ISOFD(p) 0
-#endif
-
-/* Cray DMF (data migration facility): off line, with no data  */
-#ifndef S_ISOFL
-# define S_ISOFL(p) 0
-#endif
-
-/* 4.4BSD whiteout */
-#ifndef S_ISWHT
-# define S_ISWHT(m) 0
-#endif
-
-/* If any of the following are undefined,
-   define them to their de facto standard values.  */
-#if !S_ISUID
-# define S_ISUID 04000
-#endif
-#if !S_ISGID
-# define S_ISGID 02000
-#endif
-
-/* S_ISVTX is a common extension to POSIX.  */
-#ifndef S_ISVTX
-# define S_ISVTX 01000
-#endif
-
-#if !S_IRUSR && S_IREAD
-# define S_IRUSR S_IREAD
-#endif
-#if !S_IRUSR
-# define S_IRUSR 00400
-#endif
-#if !S_IRGRP
-# define S_IRGRP (S_IRUSR >> 3)
-#endif
-#if !S_IROTH
-# define S_IROTH (S_IRUSR >> 6)
-#endif
-
-#if !S_IWUSR && S_IWRITE
-# define S_IWUSR S_IWRITE
-#endif
-#if !S_IWUSR
-# define S_IWUSR 00200
-#endif
-#if !S_IWGRP
-# define S_IWGRP (S_IWUSR >> 3)
-#endif
-#if !S_IWOTH
-# define S_IWOTH (S_IWUSR >> 6)
-#endif
-
-#if !S_IXUSR && S_IEXEC
-# define S_IXUSR S_IEXEC
-#endif
-#if !S_IXUSR
-# define S_IXUSR 00100
-#endif
-#if !S_IXGRP
-# define S_IXGRP (S_IXUSR >> 3)
-#endif
-#if !S_IXOTH
-# define S_IXOTH (S_IXUSR >> 6)
-#endif
-
-#if !S_IRWXU
-# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
-#endif
-#if !S_IRWXG
-# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
-#endif
-#if !S_IRWXO
-# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
-#endif
-
-/* S_IXUGO is a common extension to POSIX.  */
-#if !S_IXUGO
-# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
-#endif
-
-#ifndef S_IRWXUGO
-# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
-#endif
-
-/* Macros for futimens and utimensat.  */
-#ifndef UTIME_NOW
-# define UTIME_NOW (-1)
-# define UTIME_OMIT (-2)
-#endif
-
-
-#if @GNULIB_FCHMODAT@
-# if address@hidden@
-_GL_FUNCDECL_SYS (fchmodat, int,
-                  (int fd, char const *file, mode_t mode, int flag)
-                  _GL_ARG_NONNULL ((2)));
-# endif
-_GL_CXXALIAS_SYS (fchmodat, int,
-                  (int fd, char const *file, mode_t mode, int flag));
-_GL_CXXALIASWARN (fchmodat);
-#elif defined GNULIB_POSIXCHECK
-# undef fchmodat
-# if HAVE_RAW_DECL_FCHMODAT
-_GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - "
-                 "use gnulib module openat for portability");
-# endif
-#endif
-
-
-#if @REPLACE_FSTAT@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#  define fstat rpl_fstat
-# endif
-_GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL 
((2)));
-_GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
-#else
-_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
-#endif
-_GL_CXXALIASWARN (fstat);
-
-
-#if @GNULIB_FSTATAT@
-# if @REPLACE_FSTATAT@
-#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#   undef fstatat
-#   define fstatat rpl_fstatat
-#  endif
-_GL_FUNCDECL_RPL (fstatat, int,
-                  (int fd, char const *name, struct stat *st, int flags)
-                  _GL_ARG_NONNULL ((2, 3)));
-_GL_CXXALIAS_RPL (fstatat, int,
-                  (int fd, char const *name, struct stat *st, int flags));
-# else
-#  if address@hidden@
-_GL_FUNCDECL_SYS (fstatat, int,
-                  (int fd, char const *name, struct stat *st, int flags)
-                  _GL_ARG_NONNULL ((2, 3)));
-#  endif
-_GL_CXXALIAS_SYS (fstatat, int,
-                  (int fd, char const *name, struct stat *st, int flags));
-# endif
-_GL_CXXALIASWARN (fstatat);
-#elif defined GNULIB_POSIXCHECK
-# undef fstatat
-# if HAVE_RAW_DECL_FSTATAT
-_GL_WARN_ON_USE (fstatat, "fstatat is not portable - "
-                 "use gnulib module openat for portability");
-# endif
-#endif
-
-
-#if @GNULIB_FUTIMENS@
-/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our futimens
-   implementation relies on futimesat, which on Solaris 10 makes an invocation
-   to futimens that is meant to invoke the libc's futimens(), not gnulib's
-   futimens().  */
-# if @REPLACE_FUTIMENS@ || (address@hidden@ && defined __sun)
-#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#   undef futimens
-#   define futimens rpl_futimens
-#  endif
-_GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2]));
-_GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2]));
-# else
-#  if address@hidden@
-_GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2]));
-#  endif
-_GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
-# endif
-# if @HAVE_FUTIMENS@
-_GL_CXXALIASWARN (futimens);
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef futimens
-# if HAVE_RAW_DECL_FUTIMENS
-_GL_WARN_ON_USE (futimens, "futimens is not portable - "
-                 "use gnulib module futimens for portability");
-# endif
-#endif
-
-
-#if @GNULIB_LCHMOD@
-/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
-   denotes a symbolic link.  */
-# if address@hidden@
-/* The lchmod replacement follows symbolic links.  Callers should take
-   this into account; lchmod should be applied only to arguments that
-   are known to not be symbolic links.  On hosts that lack lchmod,
-   this can lead to race conditions between the check and the
-   invocation of lchmod, but we know of no workarounds that are
-   reliable in general.  You might try requesting support for lchmod
-   from your operating system supplier.  */
-#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#   define lchmod chmod
-#  endif
-/* Need to cast, because on mingw, the second parameter of chmod is
-                                                int mode.  */
-_GL_CXXALIAS_RPL_CAST_1 (lchmod, chmod, int,
-                         (const char *filename, mode_t mode));
-# else
-#  if 0 /* assume already declared */
-_GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode)
-                               _GL_ARG_NONNULL ((1)));
-#  endif
-_GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode));
-# endif
-# if @HAVE_LCHMOD@
-_GL_CXXALIASWARN (lchmod);
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef lchmod
-# if HAVE_RAW_DECL_LCHMOD
-_GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
-                 "use gnulib module lchmod for portability");
-# endif
-#endif
-
-
-#if @GNULIB_LSTAT@
-# if ! @HAVE_LSTAT@
-/* mingw does not support symlinks, therefore it does not have lstat.  But
-   without links, stat does just fine.  */
-#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#   define lstat stat
-#  endif
-_GL_CXXALIAS_RPL_1 (lstat, stat, int, (const char *name, struct stat *buf));
-# elif @REPLACE_LSTAT@
-#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#   undef lstat
-#   define lstat rpl_lstat
-#  endif
-_GL_FUNCDECL_RPL (lstat, int, (const char *name, struct stat *buf)
-                              _GL_ARG_NONNULL ((1, 2)));
-_GL_CXXALIAS_RPL (lstat, int, (const char *name, struct stat *buf));
-# else
-_GL_CXXALIAS_SYS (lstat, int, (const char *name, struct stat *buf));
-# endif
-# if @HAVE_LSTAT@
-_GL_CXXALIASWARN (lstat);
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef lstat
-# if HAVE_RAW_DECL_LSTAT
-_GL_WARN_ON_USE (lstat, "lstat is unportable - "
-                 "use gnulib module lstat for portability");
-# endif
-#endif
-
-
-#if @REPLACE_MKDIR@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#  undef mkdir
-#  define mkdir rpl_mkdir
-# endif
-_GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode)
-                              _GL_ARG_NONNULL ((1)));
-_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
-#else
-/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
-   Additionally, it declares _mkdir (and depending on compile flags, an
-   alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
-   which are included above.  */
-# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-
-#  if !GNULIB_defined_rpl_mkdir
-static inline int
-rpl_mkdir (char const *name, mode_t mode)
-{
-  return _mkdir (name);
-}
-#   define GNULIB_defined_rpl_mkdir 1
-#  endif
-
-#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#   define mkdir rpl_mkdir
-#  endif
-_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
-# else
-_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
-# endif
-#endif
-_GL_CXXALIASWARN (mkdir);
-
-
-#if @GNULIB_MKDIRAT@
-# if address@hidden@
-_GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)
-                                _GL_ARG_NONNULL ((2)));
-# endif
-_GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode));
-_GL_CXXALIASWARN (mkdirat);
-#elif defined GNULIB_POSIXCHECK
-# undef mkdirat
-# if HAVE_RAW_DECL_MKDIRAT
-_GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - "
-                 "use gnulib module openat for portability");
-# endif
-#endif
-
-
-#if @GNULIB_MKFIFO@
-# if @REPLACE_MKFIFO@
-#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#   undef mkfifo
-#   define mkfifo rpl_mkfifo
-#  endif
-_GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode)
-                               _GL_ARG_NONNULL ((1)));
-_GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode));
-# else
-#  if address@hidden@
-_GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode)
-                               _GL_ARG_NONNULL ((1)));
-#  endif
-_GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode));
-# endif
-_GL_CXXALIASWARN (mkfifo);
-#elif defined GNULIB_POSIXCHECK
-# undef mkfifo
-# if HAVE_RAW_DECL_MKFIFO
-_GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
-                 "use gnulib module mkfifo for portability");
-# endif
-#endif
-
-
-#if @GNULIB_MKFIFOAT@
-# if address@hidden@
-_GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)
-                                 _GL_ARG_NONNULL ((2)));
-# endif
-_GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
-_GL_CXXALIASWARN (mkfifoat);
-#elif defined GNULIB_POSIXCHECK
-# undef mkfifoat
-# if HAVE_RAW_DECL_MKFIFOAT
-_GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - "
-                 "use gnulib module mkfifoat for portability");
-# endif
-#endif
-
-
-#if @GNULIB_MKNOD@
-# if @REPLACE_MKNOD@
-#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#   undef mknod
-#   define mknod rpl_mknod
-#  endif
-_GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)
-                              _GL_ARG_NONNULL ((1)));
-_GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev));
-# else
-#  if address@hidden@
-_GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev)
-                              _GL_ARG_NONNULL ((1)));
-#  endif
-/* Need to cast, because on OSF/1 5.1, the third parameter is '...'.  */
-_GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev));
-# endif
-_GL_CXXALIASWARN (mknod);
-#elif defined GNULIB_POSIXCHECK
-# undef mknod
-# if HAVE_RAW_DECL_MKNOD
-_GL_WARN_ON_USE (mknod, "mknod is not portable - "
-                 "use gnulib module mknod for portability");
-# endif
-#endif
-
-
-#if @GNULIB_MKNODAT@
-# if address@hidden@
-_GL_FUNCDECL_SYS (mknodat, int,
-                  (int fd, char const *file, mode_t mode, dev_t dev)
-                  _GL_ARG_NONNULL ((2)));
-# endif
-_GL_CXXALIAS_SYS (mknodat, int,
-                  (int fd, char const *file, mode_t mode, dev_t dev));
-_GL_CXXALIASWARN (mknodat);
-#elif defined GNULIB_POSIXCHECK
-# undef mknodat
-# if HAVE_RAW_DECL_MKNODAT
-_GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
-                 "use gnulib module mkfifoat for portability");
-# endif
-#endif
-
-
-#if @GNULIB_STAT@
-# if @REPLACE_STAT@
-/* We can't use the object-like #define stat rpl_stat, because of
-   struct stat.  This means that rpl_stat will not be used if the user
-   does (stat)(a,b).  Oh well.  */
-#  undef stat
-#  ifdef _LARGE_FILES
-    /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
-       so we have to replace stat64() instead of stat(). */
-#   define stat stat64
-#   undef stat64
-#   define stat64(name, st) rpl_stat (name, st)
-#  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));
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef stat
-# if HAVE_RAW_DECL_STAT
-_GL_WARN_ON_USE (stat, "stat is unportable - "
-                 "use gnulib module stat for portability");
-# endif
-#endif
-
-
-#if @GNULIB_UTIMENSAT@
-/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat
-   implementation relies on futimesat, which on Solaris 10 makes an invocation
-   to utimensat that is meant to invoke the libc's utimensat(), not gnulib's
-   utimensat().  */
-# if @REPLACE_UTIMENSAT@ || (address@hidden@ && defined __sun)
-#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#   undef utimensat
-#   define utimensat rpl_utimensat
-#  endif
-_GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name,
-                                   struct timespec const times[2], int flag)
-                                  _GL_ARG_NONNULL ((2)));
-_GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name,
-                                   struct timespec const times[2], int flag));
-# else
-#  if address@hidden@
-_GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
-                                   struct timespec const times[2], int flag)
-                                  _GL_ARG_NONNULL ((2)));
-#  endif
-_GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
-                                   struct timespec const times[2], int flag));
-# endif
-# if @HAVE_UTIMENSAT@
-_GL_CXXALIASWARN (utimensat);
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef utimensat
-# if HAVE_RAW_DECL_UTIMENSAT
-_GL_WARN_ON_USE (utimensat, "utimensat is not portable - "
-                 "use gnulib module utimensat for portability");
-# endif
-#endif
-
-
-#endif /* address@hidden@_SYS_STAT_H */
-#endif /* address@hidden@_SYS_STAT_H */
-#endif
diff --git a/gltests/test-accept.c b/gltests/test-accept.c
new file mode 100644
index 0000000..265ef64
--- /dev/null
+++ b/gltests/test-accept.c
@@ -0,0 +1,54 @@
+/* Test accepting a connection to a server socket.
+   Copyright (C) 2011-2012 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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include <sys/socket.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (accept, int, (int, struct sockaddr *, socklen_t *));
+
+#include <errno.h>
+#include <netinet/in.h>
+
+#include "sockets.h"
+#include "macros.h"
+
+int
+main (void)
+{
+  (void) gl_sockets_startup (SOCKETS_1_1);
+
+  /* Test behaviour for invalid file descriptors.  */
+  {
+    struct sockaddr_in addr;
+    socklen_t addrlen = sizeof (addr);
+
+    errno = 0;
+    ASSERT (accept (-1, (struct sockaddr *) &addr, &addrlen) == -1);
+    ASSERT (errno == EBADF);
+  }
+  {
+    struct sockaddr_in addr;
+    socklen_t addrlen = sizeof (addr);
+
+    errno = 0;
+    ASSERT (accept (99, (struct sockaddr *) &addr, &addrlen) == -1);
+    ASSERT (errno == EBADF);
+  }
+
+  return 0;
+}
diff --git a/gltests/test-alignof.c b/gltests/test-alignof.c
deleted file mode 100644
index cc10bc1..0000000
--- a/gltests/test-alignof.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Test of <alignof.h>.
-   Copyright (C) 2009-2011 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
-   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 General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-/* Written by Bruno Haible <address@hidden>, 2009.  */
-
-#include <config.h>
-
-#include <alignof.h>
-
-#include <stddef.h>
-#include <stdint.h>
-
-#include "verify.h"
-
-typedef long double longdouble;
-typedef struct { char a[1]; } struct1;
-typedef struct { char a[2]; } struct2;
-typedef struct { char a[3]; } struct3;
-typedef struct { char a[4]; } struct4;
-
-#define CHECK(type) \
-  typedef struct { char slot1; type slot2; } type##_helper; \
-  verify (alignof_slot (type) == offsetof (type##_helper, slot2)); \
-  const int type##_slot_alignment = alignof_slot (type); \
-  const int type##_type_alignment = alignof_type (type);
-
-CHECK (char)
-CHECK (short)
-CHECK (int)
-CHECK (long)
-CHECK (float)
-CHECK (double)
-CHECK (longdouble)
-#ifdef INT64_MAX
-CHECK (int64_t)
-#endif
-CHECK (struct1)
-CHECK (struct2)
-CHECK (struct3)
-CHECK (struct4)
-
-int
-main ()
-{
-  return 0;
-}
diff --git a/gltests/test-alloca-opt.c b/gltests/test-alloca-opt.c
index 5aa1645..4e814c6 100644
--- a/gltests/test-alloca-opt.c
+++ b/gltests/test-alloca-opt.c
@@ -1,5 +1,5 @@
 /* Test of optional automatic memory allocation.
-   Copyright (C) 2005, 2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2007, 2009-2012 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
diff --git a/gltests/test-arpa_inet.c b/gltests/test-arpa_inet.c
index ce7d19f..bda6709 100644
--- a/gltests/test-arpa_inet.c
+++ b/gltests/test-arpa_inet.c
@@ -1,5 +1,5 @@
 /* Test of <arpa/inet.h> substitute.
-   Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2012 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
diff --git a/gltests/test-binary-io.c b/gltests/test-binary-io.c
index 8e5d193..c695454 100644
--- a/gltests/test-binary-io.c
+++ b/gltests/test-binary-io.c
@@ -1,5 +1,5 @@
 /* Test of binary mode I/O.
-   Copyright (C) 2005, 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2007-2012 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
@@ -46,19 +46,10 @@ main ()
       exit (1);
     ASSERT (statbuf.st_size == 6);
   }
-  unlink ("t-bin-out2.tmp");
 
   /* Test the SET_BINARY macro.  */
   SET_BINARY (1);
   fputs ("Hello\n", stdout);
-  fclose (stdout);
-  fclose (stderr);
-  {
-    struct stat statbuf;
-    if (stat ("t-bin-out1.tmp", &statbuf) < 0)
-      exit (1);
-    ASSERT (statbuf.st_size == 6);
-  }
 
   return 0;
 }
diff --git a/gltests/test-binary-io.sh b/gltests/test-binary-io.sh
index 33e128c..272edef 100755
--- a/gltests/test-binary-io.sh
+++ b/gltests/test-binary-io.sh
@@ -5,6 +5,7 @@ trap 'rm -fr $tmpfiles' 1 2 3 15
 
 tmpfiles="$tmpfiles t-bin-out1.tmp t-bin-out2.tmp"
 ./test-binary-io${EXEEXT} > t-bin-out1.tmp || exit 1
+cmp t-bin-out1.tmp t-bin-out2.tmp > /dev/null || exit 1
 
 rm -fr $tmpfiles
 
diff --git a/gltests/test-bind.c b/gltests/test-bind.c
new file mode 100644
index 0000000..e97be2a
--- /dev/null
+++ b/gltests/test-bind.c
@@ -0,0 +1,56 @@
+/* Test binding a server socket to a port.
+   Copyright (C) 2011-2012 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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include <sys/socket.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (bind, int, (int, const struct sockaddr *, socklen_t));
+
+#include <errno.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include "sockets.h"
+#include "macros.h"
+
+int
+main (void)
+{
+  (void) gl_sockets_startup (SOCKETS_1_1);
+
+  /* Test behaviour for invalid file descriptors.  */
+  {
+    struct sockaddr_in addr;
+
+    addr.sin_family = AF_INET;
+    inet_pton (AF_INET, "127.0.0.1", &addr.sin_addr);
+    addr.sin_port = htons (80);
+    {
+      errno = 0;
+      ASSERT (bind (-1, (const struct sockaddr *) &addr, sizeof (addr)) == -1);
+      ASSERT (errno == EBADF);
+    }
+    {
+      errno = 0;
+      ASSERT (bind (99, (const struct sockaddr *) &addr, sizeof (addr)) == -1);
+      ASSERT (errno == EBADF);
+    }
+  }
+
+  return 0;
+}
diff --git a/gltests/test-btowc.c b/gltests/test-btowc.c
index 7907cbe..845fe06 100644
--- a/gltests/test-btowc.c
+++ b/gltests/test-btowc.c
@@ -1,5 +1,5 @@
 /* Test of conversion of unibyte character to wide character.
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
diff --git a/gltests/test-c-ctype.c b/gltests/test-c-ctype.c
index 9d748ff..a9cb655 100644
--- a/gltests/test-c-ctype.c
+++ b/gltests/test-c-ctype.c
@@ -1,5 +1,5 @@
 /* Test of character handling in C locale.
-   Copyright (C) 2005, 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2007-2012 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
diff --git a/gltests/test-c-strcasecmp.c b/gltests/test-c-strcasecmp.c
index faa3001..1eb5958 100644
--- a/gltests/test-c-strcasecmp.c
+++ b/gltests/test-c-strcasecmp.c
@@ -1,5 +1,5 @@
 /* Test of case-insensitive string comparison function.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
diff --git a/gltests/test-c-strncasecmp.c b/gltests/test-c-strncasecmp.c
index 6a225c7..479528b 100644
--- a/gltests/test-c-strncasecmp.c
+++ b/gltests/test-c-strncasecmp.c
@@ -1,5 +1,5 @@
 /* Test of case-insensitive string comparison function.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
diff --git a/gltests/test-close.c b/gltests/test-close.c
new file mode 100644
index 0000000..83f71c0
--- /dev/null
+++ b/gltests/test-close.c
@@ -0,0 +1,44 @@
+/* Test closing a file or socket.
+   Copyright (C) 2011-2012 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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include <unistd.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (close, int, (int));
+
+#include <errno.h>
+
+#include "macros.h"
+
+int
+main (void)
+{
+  /* Test behaviour for invalid file descriptors.  */
+  {
+    errno = 0;
+    ASSERT (close (-1) == -1);
+    ASSERT (errno == EBADF);
+  }
+  {
+    errno = 0;
+    ASSERT (close (99) == -1);
+    ASSERT (errno == EBADF);
+  }
+
+  return 0;
+}
diff --git a/gltests/test-connect.c b/gltests/test-connect.c
new file mode 100644
index 0000000..9ef8923
--- /dev/null
+++ b/gltests/test-connect.c
@@ -0,0 +1,58 @@
+/* Test connecting a client socket.
+   Copyright (C) 2011-2012 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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include <sys/socket.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (connect, int, (int, const struct sockaddr *, socklen_t));
+
+#include <errno.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include "sockets.h"
+#include "macros.h"
+
+int
+main (void)
+{
+  (void) gl_sockets_startup (SOCKETS_1_1);
+
+  /* Test behaviour for invalid file descriptors.  */
+  {
+    struct sockaddr_in addr;
+
+    addr.sin_family = AF_INET;
+    inet_pton (AF_INET, "127.0.0.1", &addr.sin_addr);
+    addr.sin_port = htons (80);
+    {
+      errno = 0;
+      ASSERT (connect (-1, (const struct sockaddr *) &addr, sizeof (addr))
+              == -1);
+      ASSERT (errno == EBADF);
+    }
+    {
+      errno = 0;
+      ASSERT (connect (99, (const struct sockaddr *) &addr, sizeof (addr))
+              == -1);
+      ASSERT (errno == EBADF);
+    }
+  }
+
+  return 0;
+}
diff --git a/gltests/test-dup2.c b/gltests/test-dup2.c
index e2ad88b..5043c0c 100644
--- a/gltests/test-dup2.c
+++ b/gltests/test-dup2.c
@@ -1,5 +1,5 @@
 /* Test duplicating file descriptors.
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 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
@@ -33,9 +33,11 @@ SIGNATURE_CHECK (dup2, int, (int, int));
 #endif
 
 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-/* Get declarations of the Win32 API functions.  */
+/* Get declarations of the native Windows API functions.  */
 # define WIN32_LEAN_AND_MEAN
 # include <windows.h>
+/* Get _get_osfhandle.  */
+# include "msvc-nothrow.h"
 #endif
 
 #include "macros.h"
@@ -45,7 +47,7 @@ static int
 is_open (int fd)
 {
 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-  /* On Win32, the initial state of unassigned standard file
+  /* On native Windows, the initial state of unassigned standard file
      descriptors is that they are open but point to an
      INVALID_HANDLE_VALUE, and there is no fcntl.  */
   return (HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE;
@@ -63,7 +65,7 @@ static int
 is_inheritable (int fd)
 {
 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-  /* On Win32, the initial state of unassigned standard file
+  /* On native Windows, the initial state of unassigned standard file
      descriptors is that they are open but point to an
      INVALID_HANDLE_VALUE, and there is no fcntl.  */
   HANDLE h = (HANDLE) _get_osfhandle (fd);
@@ -121,6 +123,9 @@ main (void)
   ASSERT (dup2 (-1, fd) == -1);
   ASSERT (errno == EBADF);
   errno = 0;
+  ASSERT (dup2 (99, fd) == -1);
+  ASSERT (errno == EBADF);
+  errno = 0;
   ASSERT (dup2 (AT_FDCWD, fd) == -1);
   ASSERT (errno == EBADF);
   ASSERT (is_open (fd));
diff --git a/gltests/test-environ.c b/gltests/test-environ.c
index 4beec64..17f9f77 100644
--- a/gltests/test-environ.c
+++ b/gltests/test-environ.c
@@ -1,5 +1,5 @@
 /* Test of environ variable.
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
diff --git a/gltests/test-errno.c b/gltests/test-errno.c
index 7851c22..d9a030f 100644
--- a/gltests/test-errno.c
+++ b/gltests/test-errno.c
@@ -1,5 +1,5 @@
 /* Test of <errno.h> substitute.
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
diff --git a/gltests/test-fclose.c b/gltests/test-fclose.c
deleted file mode 100644
index a11eca9..0000000
--- a/gltests/test-fclose.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/* Test of fclose module.
-   Copyright (C) 2011 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
-   the Free Software Foundation; either version 3, 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 General Public License for more details.
-
-   You should have received a copy of the GNU 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 Eric Blake.  */
-
-#include <config.h>
-
-#include <stdio.h>
-
-#include "signature.h"
-SIGNATURE_CHECK (fclose, int, (FILE *));
-
-#include <errno.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "macros.h"
-
-#define BASE "test-fclose.t"
-
-int
-main (int argc, char **argv)
-{
-  const char buf[] = "hello world";
-  int fd;
-  int fd2;
-  FILE *f;
-
-  /* Prepare a seekable file.  */
-  fd = open (BASE, O_RDWR | O_CREAT | O_TRUNC, 0600);
-  ASSERT (0 <= fd);
-  ASSERT (write (fd, buf, sizeof buf) == sizeof buf);
-  ASSERT (lseek (fd, 1, SEEK_SET) == 1);
-
-  /* Create an output stream visiting the file; when it is closed, all
-     other file descriptors visiting the file must see the new file
-     position.  */
-  fd2 = dup (fd);
-  ASSERT (0 <= fd2);
-  f = fdopen (fd2, "w");
-  ASSERT (f);
-  ASSERT (fputc (buf[1], f) == buf[1]);
-  ASSERT (fclose (f) == 0);
-  errno = 0;
-  ASSERT (lseek (fd2, 0, SEEK_CUR) == -1);
-  ASSERT (errno == EBADF);
-  ASSERT (lseek (fd, 0, SEEK_CUR) == 2);
-
-  /* Likewise for an input stream.  */
-  fd2 = dup (fd);
-  ASSERT (0 <= fd2);
-  f = fdopen (fd2, "r");
-  ASSERT (f);
-  ASSERT (fgetc (f) == buf[2]);
-  ASSERT (fclose (f) == 0);
-  errno = 0;
-  ASSERT (lseek (fd2, 0, SEEK_CUR) == -1);
-  ASSERT (errno == EBADF);
-  ASSERT (lseek (fd, 0, SEEK_CUR) == 3);
-
-  /* Test that fclose() sets errno if someone else closes the stream
-     fd behind the back of stdio.  */
-  f = fdopen (fd, "w+");
-  ASSERT (f);
-  ASSERT (close (fd) == 0);
-  errno = 0;
-  ASSERT (fclose (f) == EOF);
-  ASSERT (errno == EBADF);
-
-  /* Clean up.  */
-  ASSERT (remove (BASE) == 0);
-
-  return 0;
-}
diff --git a/gltests/test-fcntl-h.c b/gltests/test-fcntl-h.c
index 648701e..00c5468 100644
--- a/gltests/test-fcntl-h.c
+++ b/gltests/test-fcntl-h.c
@@ -1,5 +1,5 @@
 /* Test of <fcntl.h> substitute.
-   Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2012 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
@@ -31,6 +31,11 @@ int sk[] = { SEEK_CUR, SEEK_END, SEEK_SET };
 /* Check that the FD_* macros are defined.  */
 int i = FD_CLOEXEC;
 
+/* Check that the types are all defined.  */
+pid_t t1;
+off_t t2;
+mode_t t3;
+
 int
 main (void)
 {
diff --git a/gltests/test-fdopen.c b/gltests/test-fdopen.c
new file mode 100644
index 0000000..8e2f7bf
--- /dev/null
+++ b/gltests/test-fdopen.c
@@ -0,0 +1,54 @@
+/* Test opening a stream with a file descriptor.
+   Copyright (C) 2011-2012 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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (fdopen, FILE *, (int, const char *));
+
+#include <errno.h>
+
+#include "macros.h"
+
+int
+main (void)
+{
+  /* Test behaviour for invalid file descriptors.  */
+  {
+    FILE *fp;
+
+    errno = 0;
+    fp = fdopen (-1, "r");
+    if (fp == NULL)
+      ASSERT (errno == EBADF);
+    else
+      fclose (fp);
+  }
+  {
+    FILE *fp;
+
+    errno = 0;
+    fp = fdopen (99, "r");
+    if (fp == NULL)
+      ASSERT (errno == EBADF);
+    else
+      fclose (fp);
+  }
+
+  return 0;
+}
diff --git a/gltests/test-fflush.c b/gltests/test-fflush.c
deleted file mode 100644
index a6c0e18..0000000
--- a/gltests/test-fflush.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/* Test of POSIX compatible fflush() function.
-   Copyright (C) 2007, 2009-2011 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
-   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 General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-/* Written by Eric Blake, 2007.  */
-
-#include <config.h>
-
-/* None of the files accessed by this test are large, so disable the
-   ftell link warning if we are not using the gnulib ftell module.  */
-#define _GL_NO_LARGE_FILES
-#include <stdio.h>
-
-#include "signature.h"
-SIGNATURE_CHECK (fflush, int, (FILE *));
-
-#include <unistd.h>
-
-int
-main (void)
-{
-  FILE *f;
-  char buffer[10];
-  int fd;
-
-  /* Create test file.  */
-  f = fopen ("test-fflush.txt", "w");
-  if (!f || fwrite ("1234567890ABCDEFG", 1, 17, f) != 17 || fclose (f) != 0)
-    {
-      fputs ("Failed to create sample file.\n", stderr);
-      unlink ("test-fflush.txt");
-      return 1;
-    }
-
-  /* Test fflush.  */
-  f = fopen ("test-fflush.txt", "r");
-  fd = fileno (f);
-  if (!f || 0 > fd || fread (buffer, 1, 5, f) != 5)
-    {
-      fputs ("Failed initial read of sample file.\n", stderr);
-      if (f)
-        fclose (f);
-      unlink ("test-fflush.txt");
-      return 1;
-    }
-  /* For deterministic results, ensure f read a bigger buffer.
-     This is not the case on BeOS, nor on uClibc.  */
-#if !(defined __BEOS__ || defined __UCLIBC__)
-  if (lseek (fd, 0, SEEK_CUR) == 5)
-    {
-      fputs ("Sample file was not buffered after fread.\n", stderr);
-      fclose (f);
-      unlink ("test-fflush.txt");
-      return 1;
-    }
-#endif
-  /* POSIX requires fflush-fseek to set file offset of fd.  */
-  if (fflush (f) != 0 || fseeko (f, 0, SEEK_CUR) != 0)
-    {
-      fputs ("Failed to flush-fseek sample file.\n", stderr);
-      fclose (f);
-      unlink ("test-fflush.txt");
-      return 1;
-    }
-  /* Check that offset is correct.  */
-  if (lseek (fd, 0, SEEK_CUR) != 5)
-    {
-      fprintf (stderr, "File offset is wrong after fseek: %ld.\n",
-               (long) lseek (fd, 0, SEEK_CUR));
-      fclose (f);
-      unlink ("test-fflush.txt");
-      return 1;
-    }
-  if (ftell (f) != 5)
-    {
-      fprintf (stderr, "ftell result is wrong after fseek: %ld.\n",
-               (long) ftell (f));
-      fclose (f);
-      unlink ("test-fflush.txt");
-      return 1;
-    }
-  /* Check that file reading resumes at correct location.  */
-  if (fgetc (f) != '6')
-    {
-      fputs ("Failed to read next byte after fseek.\n", stderr);
-      fclose (f);
-      unlink ("test-fflush.txt");
-      return 1;
-    }
-  /* For deterministic results, ensure f read a bigger buffer.  */
-  if (lseek (fd, 0, SEEK_CUR) == 6)
-    {
-      fputs ("Sample file was not buffered after fgetc.\n", stderr);
-      fclose (f);
-      unlink ("test-fflush.txt");
-      return 1;
-    }
-  /* POSIX requires fflush-fseeko to set file offset of fd.  */
-  if (fflush (f) != 0 || fseeko (f, 0, SEEK_CUR) != 0)
-    {
-      fputs ("Failed to flush-fseeko sample file.\n", stderr);
-      fclose (f);
-      unlink ("test-fflush.txt");
-      return 1;
-    }
-  /* Check that offset is correct.  */
-  if (lseek (fd, 0, SEEK_CUR) != 6)
-    {
-      fprintf (stderr, "File offset is wrong after fseeko: %ld.\n",
-               (long) lseek (fd, 0, SEEK_CUR));
-      fclose (f);
-      unlink ("test-fflush.txt");
-      return 1;
-    }
-  if (ftell (f) != 6)
-    {
-      fprintf (stderr, "ftell result is wrong after fseeko: %ld.\n",
-               (long) ftell (f));
-      fclose (f);
-      unlink ("test-fflush.txt");
-      return 1;
-    }
-  /* Check that file reading resumes at correct location.  */
-  if (fgetc (f) != '7')
-    {
-      fputs ("Failed to read next byte after fseeko.\n", stderr);
-      fclose (f);
-      unlink ("test-fflush.txt");
-      return 1;
-    }
-  fclose (f);
-  unlink ("test-fflush.txt");
-  return 0;
-}
diff --git a/gltests/test-fflush2.c b/gltests/test-fflush2.c
deleted file mode 100644
index ac2217d..0000000
--- a/gltests/test-fflush2.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/* Test of POSIX compatible fflush() function.
-   Copyright (C) 2008-2011 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
-   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 General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#include <config.h>
-
-#include <stdio.h>
-
-#include "binary-io.h"
-#include "macros.h"
-
-int
-main (int argc, char **argv)
-{
-  int c;
-
-  /* Avoid the well-known bugs of fflush() on streams in O_TEXT mode
-     on native Windows platforms.  */
-  SET_BINARY (0);
-
-  if (argc > 1)
-    switch (argv[1][0])
-      {
-      case '1':
-        /* Check fflush after a backup ungetc() call.  This is case 1a in
-           terms of
-           
<http://lists.gnu.org/archive/html/bug-gnulib/2008-03/msg00131.html>,
-           according to the Austin Group's resolution on 2009-01-08.  */
-
-        c = fgetc (stdin);
-        ASSERT (c == '#');
-
-        c = fgetc (stdin);
-        ASSERT (c == '!');
-
-        /* Here the file-position indicator must be 2.  */
-
-        c = ungetc ('!', stdin);
-        ASSERT (c == '!');
-
-        fflush (stdin);
-
-        /* Here the file-position indicator must be 1.  */
-
-        c = fgetc (stdin);
-        ASSERT (c == '!');
-
-        c = fgetc (stdin);
-        ASSERT (c == '/');
-
-        return 0;
-
-      case '2':
-        /* Check fflush after a non-backup ungetc() call.  This is case 2a in
-           terms of
-           
<http://lists.gnu.org/archive/html/bug-gnulib/2008-03/msg00131.html>,
-           according to the Austin Group's resolution on 2009-01-08.  */
-        /* Check that fflush after a non-backup ungetc() call discards the
-           ungetc buffer.  This is mandated by POSIX
-           <http://www.opengroup.org/susv3/functions/ungetc.html>:
-             "The value of the file-position indicator for the stream after
-              reading or discarding all pushed-back bytes shall be the same
-              as it was before the bytes were pushed back."
-           <http://www.opengroup.org/austin/aardvark/latest/xshbug3.txt>
-             "[After fflush(),] the file offset of the underlying open file
-              description shall be set to the file position of the stream, and
-              any characters pushed back onto the stream by ungetc() or
-              ungetwc() that have not subsequently been read from the stream
-              shall be discarded."  */
-
-        c = fgetc (stdin);
-        ASSERT (c == '#');
-
-        c = fgetc (stdin);
-        ASSERT (c == '!');
-
-        /* Here the file-position indicator must be 2.  */
-
-        c = ungetc ('@', stdin);
-        ASSERT (c == '@');
-
-        fflush (stdin);
-
-        /* Here the file-position indicator must be 1.  */
-
-        c = fgetc (stdin);
-        ASSERT (c == '!');
-
-        c = fgetc (stdin);
-        ASSERT (c == '/');
-
-        return 0;
-      }
-
-  return 1;
-}
diff --git a/gltests/test-fflush2.sh b/gltests/test-fflush2.sh
deleted file mode 100755
index ef77fa4..0000000
--- a/gltests/test-fflush2.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-# Execute the test only with seekable input stream.
-# The behaviour of fflush() on a non-seekable input stream is undefined.
-./test-fflush2${EXEEXT} 1 < "$srcdir/test-fflush2.sh" || exit $?
-./test-fflush2${EXEEXT} 2 < "$srcdir/test-fflush2.sh" || exit $?
-#cat "$srcdir/test-fflush2.sh" | ./test-fflush2${EXEEXT} || exit $?
-
-exit 0
diff --git a/gltests/test-fgetc.c b/gltests/test-fgetc.c
new file mode 100644
index 0000000..669a71e
--- /dev/null
+++ b/gltests/test-fgetc.c
@@ -0,0 +1,96 @@
+/* Test of fgetc() function.
+   Copyright (C) 2011-2012 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
+   the Free Software Foundation; either version 3, 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 General Public License for more details.
+
+   You should have received a copy of the GNU 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.  */
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (fgetc, int, (FILE *));
+
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "msvc-inval.h"
+
+#include "macros.h"
+
+int
+main (int argc, char **argv)
+{
+  const char *filename = "test-fgetc.txt";
+
+  /* We don't have an fgetc() function that installs an invalid parameter
+     handler so far.  So install that handler here, explicitly.  */
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER \
+    && MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING
+  gl_msvc_inval_ensure_handler ();
+#endif
+
+  /* Prepare a file.  */
+  {
+    const char text[] = "hello world";
+    int fd = open (filename, O_RDWR | O_CREAT | O_TRUNC, 0600);
+    ASSERT (fd >= 0);
+    ASSERT (write (fd, text, sizeof (text)) == sizeof (text));
+    ASSERT (close (fd) == 0);
+  }
+
+  /* Test that fgetc() sets errno if someone else closes the stream
+     fd behind the back of stdio.  */
+  {
+    FILE *fp = fopen (filename, "r");
+    ASSERT (fp != NULL);
+    ASSERT (close (fileno (fp)) == 0);
+    errno = 0;
+    ASSERT (fgetc (fp) == EOF);
+    ASSERT (errno == EBADF);
+    ASSERT (ferror (fp));
+    fclose (fp);
+  }
+
+  /* Test that fgetc() sets errno if the stream was constructed with
+     an invalid file descriptor.  */
+  {
+    FILE *fp = fdopen (-1, "r");
+    if (fp != NULL)
+      {
+        errno = 0;
+        ASSERT (fgetc (fp) == EOF);
+        ASSERT (errno == EBADF);
+        ASSERT (ferror (fp));
+        fclose (fp);
+      }
+  }
+  {
+    FILE *fp = fdopen (99, "r");
+    if (fp != NULL)
+      {
+        errno = 0;
+        ASSERT (fgetc (fp) == EOF);
+        ASSERT (errno == EBADF);
+        ASSERT (ferror (fp));
+        fclose (fp);
+      }
+  }
+
+  /* Clean up.  */
+  unlink (filename);
+
+  return 0;
+}
diff --git a/gltests/test-float.c b/gltests/test-float.c
index 47de211..f3691be 100644
--- a/gltests/test-float.c
+++ b/gltests/test-float.c
@@ -1,5 +1,5 @@
 /* Test of <float.h> substitute.
-   Copyright (C) 2011 Free Software Foundation, Inc.
+   Copyright (C) 2011-2012 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
@@ -298,7 +298,7 @@ test_long_double (void)
 
   /* Check that 'long double' is at least as wide as 'double'.  */
   ASSERT (LDBL_MANT_DIG >= DBL_MANT_DIG);
-  ASSERT (LDBL_MIN_EXP <= DBL_MIN_EXP);
+  ASSERT (LDBL_MIN_EXP - LDBL_MANT_DIG <= DBL_MIN_EXP - DBL_MANT_DIG);
   ASSERT (LDBL_MAX_EXP >= DBL_MAX_EXP);
 
   /* Check the value of LDBL_DIG.  */
@@ -377,7 +377,7 @@ main ()
 int
 main ()
 {
-  fprintf (stderr, "FLT_RADIX is not 2.\n");
+  fprintf (stderr, "Skipping test: FLT_RADIX is not 2.\n");
   return 77;
 }
 
diff --git a/gltests/test-fpurge.c b/gltests/test-fpurge.c
deleted file mode 100644
index 0f36221..0000000
--- a/gltests/test-fpurge.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/* Test of fpurge() function.
-   Copyright (C) 2007-2011 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
-   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 General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-/* Written by Bruno Haible <address@hidden>, 2007.  */
-
-#include <config.h>
-
-/* None of the files accessed by this test are large, so disable the
-   fseek link warning if we are not using the gnulib fseek module.  */
-#define _GL_NO_LARGE_FILES
-#include <stdio.h>
-
-#include <string.h>
-
-#include "macros.h"
-
-#define TESTFILE "t-fpurge.tmp"
-
-int
-main (void)
-{
-  int check_filepos;
-
-  for (check_filepos = 0; check_filepos <= 1; check_filepos++)
-    {
-      FILE *fp;
-
-      /* Create a file with some contents.  */
-      fp = fopen (TESTFILE, "w");
-      if (fp == NULL)
-        goto skip;
-      if (fwrite ("foobarsh", 1, 8, fp) < 8)
-        goto skip;
-      if (fclose (fp))
-        goto skip;
-
-      /* The file's contents is now "foobarsh".  */
-
-      /* Open it in read-write mode.  */
-      fp = fopen (TESTFILE, "r+");
-      if (fp == NULL)
-        goto skip;
-      if (fseek (fp, 3, SEEK_CUR))
-        goto skip;
-      if (fwrite ("g", 1, 1, fp) < 1)
-        goto skip;
-      if (fflush (fp))
-        goto skip;
-      if (fwrite ("bz", 1, 2, fp) < 2)
-        goto skip;
-      /* Discard pending write.  */
-      ASSERT (fpurge (fp) == 0);
-      /* Verify that when discarding pending output, the file position is set
-         back to where it was before the write calls.  */
-      if (check_filepos)
-        ASSERT (ftell (fp) == 4);
-      ASSERT (fclose (fp) == 0);
-
-      /* Open it in read-only mode.  */
-      fp = fopen (TESTFILE, "r");
-      if (fp == NULL)
-        goto skip;
-      /* Verify that the pending writes before the fpurge were really
-         discarded.  */
-      {
-        char buf[8];
-        if (fread (buf, 1, 7, fp) < 7)
-          goto skip;
-        ASSERT (memcmp (buf, "foogars", 7) == 0);
-      }
-      /* Discard the buffered 'h'.  */
-      if (check_filepos)
-        ASSERT (ftell (fp) == 7);
-      ASSERT (fpurge (fp) == 0);
-      /* Verify that when discarding pending input, the file position is
-         advanced to match the end of the previously read input.  */
-      if (check_filepos)
-        ASSERT (ftell (fp) == 8);
-      ASSERT (getc (fp) == EOF);
-      ASSERT (fclose (fp) == 0);
-
-      /* The file's contents is now "foogarsh".  */
-
-      /* Ensure that purging a read does not corrupt subsequent writes.  */
-      fp = fopen (TESTFILE, "r+");
-      if (fp == NULL)
-        goto skip;
-      if (fseek (fp, -1, SEEK_END))
-        goto skip;
-      ASSERT (getc (fp) == 'h');
-      ASSERT (getc (fp) == EOF);
-      if (check_filepos)
-        ASSERT (ftell (fp) == 8);
-      ASSERT (fpurge (fp) == 0);
-      if (check_filepos)
-        ASSERT (ftell (fp) == 8);
-      ASSERT (putc ('!', fp) == '!');
-      if (check_filepos)
-        ASSERT (ftell (fp) == 9);
-      ASSERT (fclose (fp) == 0);
-      fp = fopen (TESTFILE, "r");
-      if (fp == NULL)
-        goto skip;
-      {
-        char buf[10];
-        ASSERT (fread (buf, 1, 10, fp) == 9);
-        ASSERT (memcmp (buf, "foogarsh!", 9) == 0);
-      }
-      ASSERT (fclose (fp) == 0);
-
-      /* The file's contents is now "foogarsh!".  */
-    }
-
-  remove (TESTFILE);
-  return 0;
-
- skip:
-  fprintf (stderr, "Skipping test: prerequisite file operations failed.\n");
-  remove (TESTFILE);
-  return 77;
-}
diff --git a/gltests/test-fputc.c b/gltests/test-fputc.c
new file mode 100644
index 0000000..924c222
--- /dev/null
+++ b/gltests/test-fputc.c
@@ -0,0 +1,90 @@
+/* Test of fputc() function.
+   Copyright (C) 2011-2012 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
+   the Free Software Foundation; either version 3, 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 General Public License for more details.
+
+   You should have received a copy of the GNU 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.  */
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (fputc, int, (int, FILE *));
+
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "msvc-inval.h"
+
+#include "macros.h"
+
+int
+main (int argc, char **argv)
+{
+  const char *filename = "test-fputc.txt";
+
+  /* We don't have an fputc() function that installs an invalid parameter
+     handler so far.  So install that handler here, explicitly.  */
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER \
+    && MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING
+  gl_msvc_inval_ensure_handler ();
+#endif
+
+  /* Test that fputc() on an unbuffered stream sets errno if someone else
+     closes the stream fd behind the back of stdio.  */
+  {
+    FILE *fp = fopen (filename, "w");
+    ASSERT (fp != NULL);
+    setvbuf (fp, NULL, _IONBF, 0);
+    ASSERT (close (fileno (fp)) == 0);
+    errno = 0;
+    ASSERT (fputc ('x', fp) == EOF);
+    ASSERT (errno == EBADF);
+    ASSERT (ferror (fp));
+    fclose (fp);
+  }
+
+  /* Test that fputc() on an unbuffered stream sets errno if the stream
+     was constructed with an invalid file descriptor.  */
+  {
+    FILE *fp = fdopen (-1, "w");
+    if (fp != NULL)
+      {
+        setvbuf (fp, NULL, _IONBF, 0);
+        errno = 0;
+        ASSERT (fputc ('x', fp) == EOF);
+        ASSERT (errno == EBADF);
+        ASSERT (ferror (fp));
+        fclose (fp);
+      }
+  }
+  {
+    FILE *fp = fdopen (99, "w");
+    if (fp != NULL)
+      {
+        setvbuf (fp, NULL, _IONBF, 0);
+        errno = 0;
+        ASSERT (fputc ('x', fp) == EOF);
+        ASSERT (errno == EBADF);
+        ASSERT (ferror (fp));
+        fclose (fp);
+      }
+  }
+
+  /* Clean up.  */
+  unlink (filename);
+
+  return 0;
+}
diff --git a/gltests/test-fread.c b/gltests/test-fread.c
new file mode 100644
index 0000000..fd2ac83
--- /dev/null
+++ b/gltests/test-fread.c
@@ -0,0 +1,99 @@
+/* Test of fread() function.
+   Copyright (C) 2011-2012 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
+   the Free Software Foundation; either version 3, 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 General Public License for more details.
+
+   You should have received a copy of the GNU 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.  */
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (fread, size_t, (void *, size_t, size_t, FILE *));
+
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "msvc-inval.h"
+
+#include "macros.h"
+
+int
+main (int argc, char **argv)
+{
+  const char *filename = "test-fread.txt";
+
+  /* We don't have an fread() function that installs an invalid parameter
+     handler so far.  So install that handler here, explicitly.  */
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER \
+    && MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING
+  gl_msvc_inval_ensure_handler ();
+#endif
+
+  /* Prepare a file.  */
+  {
+    const char text[] = "hello world";
+    int fd = open (filename, O_RDWR | O_CREAT | O_TRUNC, 0600);
+    ASSERT (fd >= 0);
+    ASSERT (write (fd, text, sizeof (text)) == sizeof (text));
+    ASSERT (close (fd) == 0);
+  }
+
+  /* Test that fread() sets errno if someone else closes the stream
+     fd behind the back of stdio.  */
+  {
+    FILE *fp = fopen (filename, "r");
+    char buf[5];
+    ASSERT (fp != NULL);
+    ASSERT (close (fileno (fp)) == 0);
+    errno = 0;
+    ASSERT (fread (buf, 1, sizeof (buf), fp) == 0);
+    ASSERT (errno == EBADF);
+    ASSERT (ferror (fp));
+    fclose (fp);
+  }
+
+  /* Test that fread() sets errno if the stream was constructed with
+     an invalid file descriptor.  */
+  {
+    FILE *fp = fdopen (-1, "r");
+    if (fp != NULL)
+      {
+        char buf[1];
+        errno = 0;
+        ASSERT (fread (buf, 1, 1, fp) == 0);
+        ASSERT (errno == EBADF);
+        ASSERT (ferror (fp));
+        fclose (fp);
+      }
+  }
+  {
+    FILE *fp = fdopen (99, "r");
+    if (fp != NULL)
+      {
+        char buf[1];
+        errno = 0;
+        ASSERT (fread (buf, 1, 1, fp) == 0);
+        ASSERT (errno == EBADF);
+        ASSERT (ferror (fp));
+        fclose (fp);
+      }
+  }
+
+  /* Clean up.  */
+  unlink (filename);
+
+  return 0;
+}
diff --git a/gltests/test-freading.c b/gltests/test-freading.c
deleted file mode 100644
index 723de4d..0000000
--- a/gltests/test-freading.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/* Test of freading() function.
-   Copyright (C) 2007-2011 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
-   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 General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-/* Written by Bruno Haible <address@hidden>, 2007.  */
-
-#include <config.h>
-
-/* None of the files accessed by this test are large, so disable the
-   fseek link warning if we are not using the gnulib fseek module.  */
-#define _GL_NO_LARGE_FILES
-#include "freading.h"
-
-#include <stdio.h>
-
-#include "macros.h"
-
-#define TESTFILE "t-freading.tmp"
-
-int
-main (void)
-{
-  FILE *fp;
-
-  /* Create a file with some contents.  Write-only file is never reading.  */
-  fp = fopen (TESTFILE, "w");
-  ASSERT (fp);
-  ASSERT (!freading (fp));
-  ASSERT (fwrite ("foobarsh", 1, 8, fp) == 8);
-  ASSERT (!freading (fp));
-  ASSERT (fclose (fp) == 0);
-
-  /* Open it in read-only mode.  Read-only file is always reading.  */
-  fp = fopen (TESTFILE, "r");
-  ASSERT (fp);
-  ASSERT (freading (fp));
-  ASSERT (fgetc (fp) == 'f');
-  ASSERT (freading (fp));
-  ASSERT (fseek (fp, 2, SEEK_CUR) == 0);
-  ASSERT (freading (fp));
-  ASSERT (fgetc (fp) == 'b');
-  ASSERT (freading (fp));
-  fflush (fp);
-  ASSERT (freading (fp));
-  ASSERT (fgetc (fp) == 'a');
-  ASSERT (freading (fp));
-  ASSERT (fseek (fp, 0, SEEK_END) == 0);
-  ASSERT (freading (fp));
-  ASSERT (fclose (fp) == 0);
-
-  /* Open it in read-write mode.  POSIX requires a reposition (fseek,
-     fsetpos, rewind) or EOF when transitioning from read to write;
-     freading is only deterministic after input or output, but this
-     test case should be portable even on open, after reposition, and
-     at EOF.  */
-  /* First a scenario with only fgetc, fseek, fputc.  */
-  fp = fopen (TESTFILE, "r+");
-  ASSERT (fp);
-  ASSERT (!freading (fp));
-  ASSERT (fgetc (fp) == 'f');
-  ASSERT (freading (fp));
-  ASSERT (fseek (fp, 2, SEEK_CUR) ==  0);
-  /* freading (fp) is undefined here, but fwriting (fp) is false.  */
-  ASSERT (fgetc (fp) == 'b');
-  ASSERT (freading (fp));
-  /* This fseek call is necessary when switching from reading to writing.
-     See the description of fopen(), ISO C 99 7.19.5.3.(6).  */
-  ASSERT (fseek (fp, 0, SEEK_CUR) == 0);
-  /* freading (fp) is undefined here, but fwriting (fp) is false.  */
-  ASSERT (fputc ('x', fp) == 'x');
-  ASSERT (!freading (fp));
-  ASSERT (fseek (fp, 0, SEEK_END) == 0);
-  /* freading (fp) is undefined here, because on some implementations (e.g.
-     glibc) fseek causes a buffer to be read.
-     fwriting (fp) is undefined as well.  */
-  ASSERT (fclose (fp) == 0);
-
-  /* Open it in read-write mode.  POSIX requires a reposition (fseek,
-     fsetpos, rewind) or EOF when transitioning from read to write;
-     freading is only deterministic after input or output, but this
-     test case should be portable even on open, after reposition, and
-     at EOF.  */
-  /* Here a scenario that includes fflush.  */
-  fp = fopen (TESTFILE, "r+");
-  ASSERT (fp);
-  ASSERT (!freading (fp));
-  ASSERT (fgetc (fp) == 'f');
-  ASSERT (freading (fp));
-  ASSERT (fseek (fp, 2, SEEK_CUR) == 0);
-  /* freading (fp) is undefined here, but fwriting (fp) is false.  */
-  ASSERT (fgetc (fp) == 'b');
-  ASSERT (freading (fp));
-  fflush (fp);
-  /* freading (fp) is undefined here, but fwriting (fp) is false.  */
-  ASSERT (fgetc (fp) == 'x');
-  ASSERT (freading (fp));
-  /* This fseek call is necessary when switching from reading to writing.
-     See the description of fopen(), ISO C 99 7.19.5.3.(6).  */
-  ASSERT (fseek (fp, 0, SEEK_CUR) == 0);
-  /* freading (fp) is undefined here, but fwriting (fp) is false.  */
-  ASSERT (fputc ('z', fp) == 'z');
-  ASSERT (!freading (fp));
-  ASSERT (fseek (fp, 0, SEEK_END) == 0);
-  /* freading (fp) is undefined here, because on some implementations (e.g.
-     glibc) fseek causes a buffer to be read.
-     fwriting (fp) is undefined as well.  */
-  ASSERT (fclose (fp) == 0);
-
-  /* Open it in append mode.  Write-only file is never reading.  */
-  fp = fopen (TESTFILE, "a");
-  ASSERT (fp);
-  ASSERT (!freading (fp));
-  ASSERT (fwrite ("bla", 1, 3, fp) == 3);
-  ASSERT (!freading (fp));
-  ASSERT (fclose (fp) == 0);
-  ASSERT (remove (TESTFILE) == 0);
-  return 0;
-}
diff --git a/gltests/test-fseek.c b/gltests/test-fseek.c
index 150b5f0..1dc03c5 100644
--- a/gltests/test-fseek.c
+++ b/gltests/test-fseek.c
@@ -1,5 +1,5 @@
 /* Test of fseek() function.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
diff --git a/gltests/test-fseeko.c b/gltests/test-fseeko.c
index ad5eec8..d2b348e 100644
--- a/gltests/test-fseeko.c
+++ b/gltests/test-fseeko.c
@@ -1,5 +1,5 @@
 /* Test of fseeko() function.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
diff --git a/gltests/test-fseeko3.c b/gltests/test-fseeko3.c
new file mode 100644
index 0000000..ffeb50f
--- /dev/null
+++ b/gltests/test-fseeko3.c
@@ -0,0 +1,51 @@
+/* Test of fseeko() function.
+   Copyright (C) 2011-2012 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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Eric Blake <address@hidden>, 2011.  */
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include <stdlib.h>
+
+#include "macros.h"
+
+int
+main (int argc, char **argv)
+{
+  int do_initial_ftell = atoi (argv[1]);
+  const char *filename = argv[2];
+  FILE *fp = fopen (filename, "r");
+  ASSERT (fp != NULL);
+
+  if (do_initial_ftell)
+    {
+      off_t pos = ftell (fp);
+      ASSERT (pos == 0);
+    }
+
+  ASSERT (fseeko (fp, 0, SEEK_END) == 0);
+
+  {
+    off_t pos = ftell (fp);
+    ASSERT (pos > 0);
+  }
+
+  ASSERT (fclose (fp) == 0);
+
+  return 0;
+}
diff --git a/gltests/test-fseeko3.sh b/gltests/test-fseeko3.sh
new file mode 100755
index 0000000..c50b4a2
--- /dev/null
+++ b/gltests/test-fseeko3.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+./test-fseeko3${EXEEXT} 0 "$srcdir/test-fseeko3.sh" || exit 1
+
+./test-fseeko3${EXEEXT} 1 "$srcdir/test-fseeko3.sh" || exit 1
+
+exit 0
diff --git a/gltests/test-fseeko4.c b/gltests/test-fseeko4.c
new file mode 100644
index 0000000..3642d3c
--- /dev/null
+++ b/gltests/test-fseeko4.c
@@ -0,0 +1,71 @@
+/* Test of fseeko() function.
+   Copyright (C) 2011-2012 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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include <errno.h>
+#include <unistd.h>
+
+#include "macros.h"
+
+int
+main (int argc, char **argv)
+{
+  const char *filename = argv[1];
+
+  /* Test that fseeko() sets errno if someone else closes the stream
+     fd behind the back of stdio.  */
+  {
+    FILE *fp = fopen (filename, "r");
+    ASSERT (fp != NULL);
+    setvbuf (fp, NULL, _IONBF, 0);
+    ASSERT (ftell (fp) == 0);
+    ASSERT (fseeko (fp, 0, SEEK_END) == 0);
+    ASSERT (ftell (fp) > 0);
+    ASSERT (close (fileno (fp)) == 0);
+    errno = 0;
+    ASSERT (fseeko (fp, 0, SEEK_SET) == -1);
+    ASSERT (errno == EBADF);
+    fclose (fp);
+  }
+
+  /* Test that fseeko() sets errno if the stream was constructed with
+     an invalid file descriptor.  */
+  {
+    FILE *fp = fdopen (-1, "w");
+    if (fp != NULL)
+      {
+        errno = 0;
+        ASSERT (fseeko (fp, 0, SEEK_END) == -1);
+        ASSERT (errno == EBADF);
+        fclose (fp);
+      }
+  }
+  {
+    FILE *fp = fdopen (99, "w");
+    if (fp != NULL)
+      {
+        errno = 0;
+        ASSERT (fseeko (fp, 0, SEEK_END) == -1);
+        ASSERT (errno == EBADF);
+        fclose (fp);
+      }
+  }
+
+  return 0;
+}
diff --git a/gltests/test-fseeko4.sh b/gltests/test-fseeko4.sh
new file mode 100755
index 0000000..e6464ae
--- /dev/null
+++ b/gltests/test-fseeko4.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+./test-fseeko4${EXEEXT} "$srcdir/test-fseeko4.sh" || exit 1
+
+exit 0
diff --git a/gltests/test-fstat.c b/gltests/test-fstat.c
new file mode 100644
index 0000000..7f3c3c4
--- /dev/null
+++ b/gltests/test-fstat.c
@@ -0,0 +1,48 @@
+/* Tests of fstat() function.
+   Copyright (C) 2011-2012 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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include <sys/stat.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (fstat, int, (int, struct stat *));
+
+#include <errno.h>
+
+#include "macros.h"
+
+int
+main (int argc, char *argv[])
+{
+  /* Test behaviour for invalid file descriptors.  */
+  {
+    struct stat statbuf;
+
+    errno = 0;
+    ASSERT (fstat (-1, &statbuf) == -1);
+    ASSERT (errno == EBADF);
+  }
+  {
+    struct stat statbuf;
+
+    errno = 0;
+    ASSERT (fstat (99, &statbuf) == -1);
+    ASSERT (errno == EBADF);
+  }
+
+  return 0;
+}
diff --git a/gltests/test-ftell.c b/gltests/test-ftell.c
deleted file mode 100644
index 54ede05..0000000
--- a/gltests/test-ftell.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/* Test of ftell() function.
-   Copyright (C) 2007-2011 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
-   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 General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-/* Written by Bruno Haible <address@hidden>, 2007.  */
-
-#include <config.h>
-
-/* None of the files accessed by this test are large, so disable the
-   fseek link warning if we are not using the gnulib fseek module.  */
-#define _GL_NO_LARGE_FILES
-#include <stdio.h>
-
-#include "signature.h"
-SIGNATURE_CHECK (ftell, long, (FILE *));
-
-#include "binary-io.h"
-#include "macros.h"
-
-#ifndef FUNC_UNGETC_BROKEN
-# define FUNC_UNGETC_BROKEN 0
-#endif
-
-int
-main (int argc, char **argv)
-{
-  int ch;
-  /* Assume stdin is seekable iff argc > 1.  */
-  if (argc == 1)
-    {
-      ASSERT (ftell (stdin) == -1);
-      return 0;
-    }
-
-  /* mingw ftell is unreliable on text mode input.  */
-  SET_BINARY (0);
-
-  /* Simple tests.  */
-  ASSERT (ftell (stdin) == 0);
-
-  ch = fgetc (stdin);
-  ASSERT (ch == '#');
-  ASSERT (ftell (stdin) == 1);
-
-  /* Test ftell after ungetc of read input.  */
-  ch = ungetc ('#', stdin);
-  ASSERT (ch == '#');
-  ASSERT (ftell (stdin) == 0);
-
-  ch = fgetc (stdin);
-  ASSERT (ch == '#');
-  ASSERT (ftell (stdin) == 1);
-
-  /* Test ftell after fseek.  */
-  ASSERT (fseek (stdin, 2, SEEK_SET) == 0);
-  ASSERT (ftell (stdin) == 2);
-
-  /* Test ftell after random ungetc.  */
-  ch = fgetc (stdin);
-  ASSERT (ch == '/');
-  ch = ungetc ('@', stdin);
-  ASSERT (ch == '@');
-  ASSERT (ftell (stdin) == 2);
-
-  ch = fgetc (stdin);
-  ASSERT (ch == '@');
-  ASSERT (ftell (stdin) == 3);
-
-  if (2 < argc)
-    {
-      if (FUNC_UNGETC_BROKEN)
-        {
-          fputs ("Skipping test: ungetc cannot handle arbitrary bytes\n",
-                 stderr);
-          return 77;
-        }
-      /* Test ftell after ungetc without read.  */
-      ASSERT (fseek (stdin, 0, SEEK_CUR) == 0);
-      ASSERT (ftell (stdin) == 3);
-
-      ch = ungetc ('~', stdin);
-      ASSERT (ch == '~');
-      ASSERT (ftell (stdin) == 2);
-    }
-
-#if !defined __MINT__ /* FreeMiNT has problems seeking past end of file */
-  /* Test ftell beyond end of file.  */
-  ASSERT (fseek (stdin, 0, SEEK_END) == 0);
-  ch = ftell (stdin);
-  ASSERT (fseek (stdin, 10, SEEK_END) == 0);
-  ASSERT (ftell (stdin) == ch + 10);
-#endif
-
-  return 0;
-}
diff --git a/gltests/test-ftell.sh b/gltests/test-ftell.sh
deleted file mode 100755
index bf55d2e..0000000
--- a/gltests/test-ftell.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-./test-ftell${EXEEXT} 1 < "$srcdir/test-ftell.sh" || exit 1
-echo hi | ./test-ftell${EXEEXT} || exit 1
-exit 0
diff --git a/gltests/test-ftell2.sh b/gltests/test-ftell2.sh
deleted file mode 100755
index 3b645b8..0000000
--- a/gltests/test-ftell2.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-exec ./test-ftell${EXEEXT} 1 2 < "$srcdir/test-ftell2.sh"
diff --git a/gltests/test-ftell3.c b/gltests/test-ftell3.c
deleted file mode 100644
index a5167ef..0000000
--- a/gltests/test-ftell3.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/* Test of ftell() function.
-   Copyright (C) 2007-2011 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
-   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 General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#include <config.h>
-
-/* None of the files accessed by this test are large, so disable the
-   fseek link warning if we are not using the gnulib fseek module.  */
-#define _GL_NO_LARGE_FILES
-#include <stdio.h>
-
-#include <string.h>
-
-#include "macros.h"
-
-#define TESTFILE "t-ftell3.tmp"
-
-int
-main (void)
-{
-  FILE *fp;
-
-  /* Create a file with some contents.  */
-  fp = fopen (TESTFILE, "w");
-  if (fp == NULL)
-    goto skip;
-  if (fwrite ("foogarsh", 1, 8, fp) < 8)
-    goto skip;
-  if (fclose (fp))
-    goto skip;
-
-  /* The file's contents is now "foogarsh".  */
-
-  /* Try writing after reading to EOF.  */
-  fp = fopen (TESTFILE, "r+");
-  if (fp == NULL)
-    goto skip;
-  if (fseek (fp, -1, SEEK_END))
-    goto skip;
-  ASSERT (getc (fp) == 'h');
-  ASSERT (getc (fp) == EOF);
-  ASSERT (ftell (fp) == 8);
-  ASSERT (ftell (fp) == 8);
-  ASSERT (putc ('!', fp) == '!');
-  ASSERT (ftell (fp) == 9);
-  ASSERT (fclose (fp) == 0);
-  fp = fopen (TESTFILE, "r");
-  if (fp == NULL)
-    goto skip;
-  {
-    char buf[10];
-    ASSERT (fread (buf, 1, 10, fp) == 9);
-    ASSERT (memcmp (buf, "foogarsh!", 9) == 0);
-  }
-  ASSERT (fclose (fp) == 0);
-
-  /* The file's contents is now "foogarsh!".  */
-
-  remove (TESTFILE);
-  return 0;
-
- skip:
-  fprintf (stderr, "Skipping test: prerequisite file operations failed.\n");
-  remove (TESTFILE);
-  return 77;
-}
diff --git a/gltests/test-ftello.c b/gltests/test-ftello.c
deleted file mode 100644
index 636da81..0000000
--- a/gltests/test-ftello.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/* Test of ftello() function.
-   Copyright (C) 2007-2011 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
-   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 General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-/* Written by Bruno Haible <address@hidden>, 2007.  */
-
-#include <config.h>
-
-/* None of the files accessed by this test are large, so disable the
-   fseek link warning if we are not using the gnulib fseek module.  */
-#define _GL_NO_LARGE_FILES
-#include <stdio.h>
-
-#include "signature.h"
-SIGNATURE_CHECK (ftello, off_t, (FILE *));
-
-#include "binary-io.h"
-#include "macros.h"
-
-#ifndef FUNC_UNGETC_BROKEN
-# define FUNC_UNGETC_BROKEN 0
-#endif
-
-int
-main (int argc, char **argv _GL_UNUSED)
-{
-  int ch;
-  /* Assume stdin is seekable iff argc > 1.  */
-  if (argc == 1)
-    {
-      ASSERT (ftell (stdin) == -1);
-      ASSERT (ftello (stdin) == -1);
-      return 0;
-    }
-
-  /* mingw ftell is unreliable on text mode input.  */
-  SET_BINARY (0);
-
-  /* Simple tests.  For each test, make sure ftell and ftello agree.  */
-  ASSERT (ftell (stdin) == 0);
-  ASSERT (ftello (stdin) == 0);
-
-  ch = fgetc (stdin);
-  ASSERT (ch == '#');
-  ASSERT (ftell (stdin) == 1);
-  ASSERT (ftello (stdin) == 1);
-
-  /* Test ftell after ungetc of read input.  */
-  ch = ungetc ('#', stdin);
-  ASSERT (ch == '#');
-  ASSERT (ftell (stdin) == 0);
-  ASSERT (ftello (stdin) == 0);
-
-  ch = fgetc (stdin);
-  ASSERT (ch == '#');
-  ASSERT (ftell (stdin) == 1);
-  ASSERT (ftello (stdin) == 1);
-
-  /* Test ftell after fseek.  */
-  ASSERT (fseek (stdin, 2, SEEK_SET) == 0);
-  ASSERT (ftell (stdin) == 2);
-  ASSERT (ftello (stdin) == 2);
-
-  /* Test ftell after random ungetc.  */
-  ch = fgetc (stdin);
-  ASSERT (ch == '/');
-  ch = ungetc ('@', stdin);
-  ASSERT (ch == '@');
-  ASSERT (ftell (stdin) == 2);
-  ASSERT (ftello (stdin) == 2);
-
-  ch = fgetc (stdin);
-  ASSERT (ch == '@');
-  ASSERT (ftell (stdin) == 3);
-  ASSERT (ftello (stdin) == 3);
-
-  if (2 < argc)
-    {
-      if (FUNC_UNGETC_BROKEN)
-        {
-          fputs ("Skipping test: ungetc cannot handle arbitrary bytes\n",
-                 stderr);
-          return 77;
-        }
-      /* Test ftell after ungetc without read.  */
-      ASSERT (fseek (stdin, 0, SEEK_CUR) == 0);
-      ASSERT (ftell (stdin) == 3);
-      ASSERT (ftello (stdin) == 3);
-
-      ch = ungetc ('~', stdin);
-      ASSERT (ch == '~');
-      ASSERT (ftell (stdin) == 2);
-      ASSERT (ftello (stdin) == 2);
-    }
-
-#if !defined __MINT__ /* FreeMiNT has problems seeking past end of file */
-  /* Test ftell beyond end of file.  */
-  ASSERT (fseek (stdin, 0, SEEK_END) == 0);
-  ch = ftello (stdin);
-  ASSERT (fseek (stdin, 10, SEEK_END) == 0);
-  ASSERT (ftell (stdin) == ch + 10);
-  ASSERT (ftello (stdin) == ch + 10);
-#endif
-
-  return 0;
-}
diff --git a/gltests/test-ftello.sh b/gltests/test-ftello.sh
deleted file mode 100755
index 33d2e83..0000000
--- a/gltests/test-ftello.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-./test-ftello${EXEEXT} 1 < "$srcdir/test-ftello.sh" || exit 1
-echo hi | ./test-ftello${EXEEXT} || exit 1
-exit 0
diff --git a/gltests/test-ftello2.sh b/gltests/test-ftello2.sh
deleted file mode 100755
index ba750b0..0000000
--- a/gltests/test-ftello2.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-exec ./test-ftello${EXEEXT} 1 2 < "$srcdir/test-ftello2.sh"
diff --git a/gltests/test-ftello3.c b/gltests/test-ftello3.c
deleted file mode 100644
index 50d4b88..0000000
--- a/gltests/test-ftello3.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/* Test of ftello() function.
-   Copyright (C) 2007-2011 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
-   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 General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#include <config.h>
-
-/* None of the files accessed by this test are large, so disable the
-   fseek link warning if we are not using the gnulib fseek module.  */
-#define _GL_NO_LARGE_FILES
-#include <stdio.h>
-
-#include <string.h>
-
-#include "macros.h"
-
-#define TESTFILE "t-ftello3.tmp"
-
-int
-main (void)
-{
-  FILE *fp;
-
-  /* Create a file with some contents.  */
-  fp = fopen (TESTFILE, "w");
-  if (fp == NULL)
-    goto skip;
-  if (fwrite ("foogarsh", 1, 8, fp) < 8)
-    goto skip;
-  if (fclose (fp))
-    goto skip;
-
-  /* The file's contents is now "foogarsh".  */
-
-  /* Try writing after reading to EOF.  */
-  fp = fopen (TESTFILE, "r+");
-  if (fp == NULL)
-    goto skip;
-  if (fseek (fp, -1, SEEK_END))
-    goto skip;
-  ASSERT (getc (fp) == 'h');
-  ASSERT (getc (fp) == EOF);
-  ASSERT (ftello (fp) == 8);
-  ASSERT (ftello (fp) == 8);
-  ASSERT (putc ('!', fp) == '!');
-  ASSERT (ftello (fp) == 9);
-  ASSERT (fclose (fp) == 0);
-  fp = fopen (TESTFILE, "r");
-  if (fp == NULL)
-    goto skip;
-  {
-    char buf[10];
-    ASSERT (fread (buf, 1, 10, fp) == 9);
-    ASSERT (memcmp (buf, "foogarsh!", 9) == 0);
-  }
-  ASSERT (fclose (fp) == 0);
-
-  /* The file's contents is now "foogarsh!".  */
-
-  remove (TESTFILE);
-  return 0;
-
- skip:
-  fprintf (stderr, "Skipping test: prerequisite file operations failed.\n");
-  remove (TESTFILE);
-  return 77;
-}
diff --git a/gltests/test-ftruncate.c b/gltests/test-ftruncate.c
new file mode 100644
index 0000000..9a85314
--- /dev/null
+++ b/gltests/test-ftruncate.c
@@ -0,0 +1,59 @@
+/* Test truncating a file.
+   Copyright (C) 2011-2012 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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include <unistd.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (ftruncate, int, (int, off_t));
+
+#include <errno.h>
+#include <fcntl.h>
+
+#include "macros.h"
+
+int
+main (int argc, char *argv[])
+{
+  const char *filename = argv[1];
+
+  /* Test behaviour for invalid file descriptors.  */
+  {
+    errno = 0;
+    ASSERT (ftruncate (-1, 0) == -1);
+    ASSERT (errno == EBADF);
+  }
+  {
+    errno = 0;
+    ASSERT (ftruncate (99, 0) == -1);
+    ASSERT (errno == EBADF);
+  }
+
+  /* Test behaviour for read-only file descriptors.  */
+  {
+    int fd = open (filename, O_RDONLY);
+    ASSERT (fd >= 0);
+    errno = 0;
+    ASSERT (ftruncate (fd, 0) == -1);
+    ASSERT (errno == EBADF || errno == EINVAL
+            || errno == EACCES /* seen on mingw */
+           );
+    close (fd);
+  }
+
+  return 0;
+}
diff --git a/gltests/test-ftruncate.sh b/gltests/test-ftruncate.sh
new file mode 100755
index 0000000..d7394d2
--- /dev/null
+++ b/gltests/test-ftruncate.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec ./test-ftruncate${EXEEXT} "$srcdir/test-ftruncate.sh"
diff --git a/gltests/test-fwrite.c b/gltests/test-fwrite.c
new file mode 100644
index 0000000..d69f463
--- /dev/null
+++ b/gltests/test-fwrite.c
@@ -0,0 +1,93 @@
+/* Test of fwrite() function.
+   Copyright (C) 2011-2012 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
+   the Free Software Foundation; either version 3, 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 General Public License for more details.
+
+   You should have received a copy of the GNU 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.  */
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (fwrite, size_t, (const void *, size_t, size_t, FILE *));
+
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "msvc-inval.h"
+
+#include "macros.h"
+
+int
+main (int argc, char **argv)
+{
+  const char *filename = "test-fwrite.txt";
+
+  /* We don't have an fwrite() function that installs an invalid parameter
+     handler so far.  So install that handler here, explicitly.  */
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER \
+    && MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING
+  gl_msvc_inval_ensure_handler ();
+#endif
+
+  /* Test that fwrite() on an unbuffered stream sets errno if someone else
+     closes the stream fd behind the back of stdio.  */
+  {
+    FILE *fp = fopen (filename, "w");
+    char buf[5] = "world";
+    ASSERT (fp != NULL);
+    setvbuf (fp, NULL, _IONBF, 0);
+    ASSERT (close (fileno (fp)) == 0);
+    errno = 0;
+    ASSERT (fwrite (buf, 1, sizeof (buf), fp) == 0);
+    ASSERT (errno == EBADF);
+    ASSERT (ferror (fp));
+    fclose (fp);
+  }
+
+  /* Test that fwrite() on an unbuffered stream sets errno if the stream
+     was constructed with an invalid file descriptor.  */
+  {
+    FILE *fp = fdopen (-1, "w");
+    if (fp != NULL)
+      {
+        char buf[5] = "world";
+        setvbuf (fp, NULL, _IONBF, 0);
+        errno = 0;
+        ASSERT (fwrite (buf, 1, sizeof (buf), fp) == 0);
+        ASSERT (errno == EBADF);
+        ASSERT (ferror (fp));
+        fclose (fp);
+      }
+  }
+  {
+    FILE *fp = fdopen (99, "w");
+    if (fp != NULL)
+      {
+        char buf[5] = "world";
+        setvbuf (fp, NULL, _IONBF, 0);
+        errno = 0;
+        ASSERT (fwrite (buf, 1, sizeof (buf), fp) == 0);
+        ASSERT (errno == EBADF);
+        ASSERT (ferror (fp));
+        fclose (fp);
+      }
+  }
+
+  /* Clean up.  */
+  unlink (filename);
+
+  return 0;
+}
diff --git a/gltests/test-getaddrinfo.c b/gltests/test-getaddrinfo.c
index d2984e2..5123196 100644
--- a/gltests/test-getaddrinfo.c
+++ b/gltests/test-getaddrinfo.c
@@ -1,6 +1,6 @@
 /* Test the getaddrinfo module.
 
-   Copyright (C) 2006-2011 Free Software Foundation, Inc.
+   Copyright (C) 2006-2012 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
diff --git a/gltests/test-getcwd-lgpl.c b/gltests/test-getcwd-lgpl.c
index 69a7b90..3010760 100644
--- a/gltests/test-getcwd-lgpl.c
+++ b/gltests/test-getcwd-lgpl.c
@@ -1,5 +1,5 @@
 /* Test of getcwd() function.
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 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
diff --git a/gltests/test-getdelim.c b/gltests/test-getdelim.c
index f4d1c9d..08c6197 100644
--- a/gltests/test-getdelim.c
+++ b/gltests/test-getdelim.c
@@ -1,5 +1,5 @@
 /* Test of getdelim() function.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
diff --git a/gltests/test-getline.c b/gltests/test-getline.c
index bead4b6..d8bb8a3 100644
--- a/gltests/test-getline.c
+++ b/gltests/test-getline.c
@@ -1,5 +1,5 @@
 /* Test of getline() function.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
diff --git a/gltests/test-getopt.c b/gltests/test-getopt.c
index 69f2cfa..e08a834 100644
--- a/gltests/test-getopt.c
+++ b/gltests/test-getopt.c
@@ -1,5 +1,5 @@
 /* Test of command line argument processing.
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 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
diff --git a/gltests/test-getopt.h b/gltests/test-getopt.h
index 9c877b3..978b753 100644
--- a/gltests/test-getopt.h
+++ b/gltests/test-getopt.h
@@ -1,5 +1,5 @@
 /* Test of command line argument processing.
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 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
@@ -1365,5 +1365,27 @@ test_getopt (void)
       ASSERT (optind == 3);
       ASSERT (!output);
     }
+
+  /* Check that 'W' does not dump core:
+     http://sourceware.org/bugzilla/show_bug.cgi?id=12922
+     Technically, POSIX says the presence of ';' in the opt-string
+     gives unspecified behavior, so we only test this when GNU compliance
+     is desired.  */
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int argc = 0;
+      const char *argv[10];
+      int pos = ftell (stderr);
+
+      argv[argc++] = "program";
+      argv[argc++] = "-W";
+      argv[argc++] = "dummy";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 1;
+      ASSERT (getopt (argc, (char **) argv, "W;") == 'W');
+      ASSERT (ftell (stderr) == pos);
+      ASSERT (optind == 2);
+    }
 #endif /* GNULIB_TEST_GETOPT_GNU */
 }
diff --git a/gltests/test-getopt_long.h b/gltests/test-getopt_long.h
index 7a74867..9d55c65 100644
--- a/gltests/test-getopt_long.h
+++ b/gltests/test-getopt_long.h
@@ -1,5 +1,5 @@
 /* Test of command line argument processing.
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 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
@@ -314,6 +314,25 @@ test_getopt_long (void)
       }
   }
 
+  /* Test that 'W' does not dump core:
+     http://sourceware.org/bugzilla/show_bug.cgi?id=12922  */
+  {
+    int argc = 0;
+    const char *argv[10];
+    int option_index;
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "-W";
+    argv[argc++] = "dummy";
+    argv[argc] = NULL;
+    optind = 1;
+    opterr = 0;
+    c = do_getopt_long (argc, argv, "W;", NULL, &option_index);
+    ASSERT (c == 'W');
+    ASSERT (optind == 2);
+  }
+
   /* Test processing of boolean short options.  */
   for (start = 0; start <= 1; start++)
     {
diff --git a/gltests/test-gettimeofday.c b/gltests/test-gettimeofday.c
index 7d09fc3..4a9d264 100644
--- a/gltests/test-gettimeofday.c
+++ b/gltests/test-gettimeofday.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005, 2007, 2009-2011 Free Software Foundation, Inc.
+ * Copyright (C) 2005, 2007, 2009-2012 Free Software Foundation, Inc.
  * Written by Jim Meyering.
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/gltests/test-iconv-h.c b/gltests/test-iconv-h.c
index 246060b..bc2bfb8 100644
--- a/gltests/test-iconv-h.c
+++ b/gltests/test-iconv-h.c
@@ -1,5 +1,5 @@
 /* Test of <iconv.h> substitute.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
diff --git a/gltests/test-iconv.c b/gltests/test-iconv.c
index 0f46f42..333af2a 100644
--- a/gltests/test-iconv.c
+++ b/gltests/test-iconv.c
@@ -1,5 +1,5 @@
 /* Test of character set conversion.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
diff --git a/gltests/test-ignore-value.c b/gltests/test-ignore-value.c
index 6953f4c..f036134 100644
--- a/gltests/test-ignore-value.c
+++ b/gltests/test-ignore-value.c
@@ -1,6 +1,6 @@
 /* Test the "ignore-value" module.
 
-   Copyright (C) 2011 Free Software Foundation, Inc.
+   Copyright (C) 2011-2012 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
diff --git a/gltests/test-inet_ntop.c b/gltests/test-inet_ntop.c
index ebb7c1c..34de5f6 100644
--- a/gltests/test-inet_ntop.c
+++ b/gltests/test-inet_ntop.c
@@ -1,5 +1,5 @@
 /* Test of inet_ntop function.
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 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
diff --git a/gltests/test-inet_pton.c b/gltests/test-inet_pton.c
index 49c140c..844908c 100644
--- a/gltests/test-inet_pton.c
+++ b/gltests/test-inet_pton.c
@@ -1,5 +1,5 @@
 /* Test of inet_pton function.
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 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
diff --git a/gltests/test-init.sh b/gltests/test-init.sh
new file mode 100755
index 0000000..a2825cc
--- /dev/null
+++ b/gltests/test-init.sh
@@ -0,0 +1,73 @@
+#!/bin/sh
+# Unit tests for init.sh
+# Copyright (C) 2011-2012 Free Software Foundation, Inc.
+# This file is part of the GNUlib Library.
+#
+# 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
+# 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+: ${srcdir=.}
+. "$srcdir/init.sh"; path_prepend_ .
+
+fail=0
+
+test_compare()
+{
+  touch empty || fail=1
+  echo xyz > in || fail=1
+
+  compare /dev/null /dev/null >out 2>err || fail=1
+  test -s out && fail_ "out not empty: $(cat out)"
+  # "err" should be empty, too, but has "set -x" output when VERBOSE=yes
+  case $- in *x*) ;; *) test -s err && fail_ "err not empty: $(cat err)";; esac
+
+  compare /dev/null empty >out 2>err || fail=1
+  test -s out && fail_ "out not empty: $(cat out)"
+  case $- in *x*) ;; *) test -s err && fail_ "err not empty: $(cat err)";; esac
+
+  compare in in >out 2>err || fail=1
+  test -s out && fail_ "out not empty: $(cat out)"
+  case $- in *x*) ;; *) test -s err && fail_ "err not empty: $(cat err)";; esac
+
+  compare /dev/null in >out 2>err && fail=1
+  cat <<\EOF > exp
+diff -u /dev/null in
+--- /dev/null  1970-01-01
++++ in 1970-01-01
++xyz
+EOF
+  compare exp out || fail=1
+  case $- in *x*) ;; *) test -s err && fail_ "err not empty: $(cat err)";; esac
+
+  compare empty in >out 2>err && fail=1
+  # Compare against expected output only if compare is using diff -u.
+  if grep @ out >/dev/null; then
+    # Remove the TAB-date suffix on each --- and +++ line,
+    # for both the expected and the actual output files.
+    # Also remove the @@ line, since Solaris 5.10 and GNU diff formats differ:
+    # -@@ -0,0 +1 @@
+    # +@@ -1,0 +1,1 @@
+    sed 's/    .*//;/^@@/d' out > k && mv k out
+    cat <<\EOF > exp
+--- empty
++++ in
++xyz
+EOF
+    compare exp out || fail=1
+  fi
+  case $- in *x*) ;; *) test -s err && fail_ "err not empty: $(cat err)";; esac
+}
+
+test_compare
+
+Exit $fail
diff --git a/gltests/test-intprops.c b/gltests/test-intprops.c
index 1a34d77..aeb1168 100644
--- a/gltests/test-intprops.c
+++ b/gltests/test-intprops.c
@@ -1,5 +1,5 @@
 /* Test intprops.h.
-   Copyright (C) 2011 Free Software Foundation, Inc.
+   Copyright (C) 2011-2012 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
diff --git a/gltests/test-inttypes.c b/gltests/test-inttypes.c
index 5bf952c..698d3dc 100644
--- a/gltests/test-inttypes.c
+++ b/gltests/test-inttypes.c
@@ -1,5 +1,5 @@
 /* Test of <inttypes.h> substitute.
-   Copyright (C) 2006-2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2006-2007, 2009-2012 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
@@ -18,9 +18,6 @@
 
 #include <config.h>
 
-#define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */
-#define __STDC_CONSTANT_MACROS 1 /* to make it work also in C++ mode */
-#define __STDC_FORMAT_MACROS 1 /* to make it work also in C++ mode */
 #include <inttypes.h>
 
 #include <stddef.h>
diff --git a/gltests/test-ioctl.c b/gltests/test-ioctl.c
new file mode 100644
index 0000000..c3aadce
--- /dev/null
+++ b/gltests/test-ioctl.c
@@ -0,0 +1,49 @@
+/* Test of ioctl() function.
+   Copyright (C) 2011-2012 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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <sys/ioctl.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (ioctl, int, (int, int, ...));
+
+#include <errno.h>
+
+#include "macros.h"
+
+int
+main (void)
+{
+#ifdef FIONREAD
+  /* Test behaviour for invalid file descriptors.  */
+  {
+    int value;
+    errno = 0;
+    ASSERT (ioctl (-1, FIONREAD, &value) == -1);
+    ASSERT (errno == EBADF);
+  }
+  {
+    int value;
+    errno = 0;
+    ASSERT (ioctl (99, FIONREAD, &value) == -1);
+    ASSERT (errno == EBADF);
+  }
+#endif
+
+  return 0;
+}
diff --git a/gltests/test-listen.c b/gltests/test-listen.c
new file mode 100644
index 0000000..b81558a
--- /dev/null
+++ b/gltests/test-listen.c
@@ -0,0 +1,47 @@
+/* Test listen() function.
+   Copyright (C) 2011-2012 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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include <sys/socket.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (listen, int, (int, int));
+
+#include <errno.h>
+
+#include "sockets.h"
+#include "macros.h"
+
+int
+main (void)
+{
+  (void) gl_sockets_startup (SOCKETS_1_1);
+
+  /* Test behaviour for invalid file descriptors.  */
+  {
+    errno = 0;
+    ASSERT (listen (-1, 1) == -1);
+    ASSERT (errno == EBADF);
+  }
+  {
+    errno = 0;
+    ASSERT (listen (99 ,1) == -1);
+    ASSERT (errno == EBADF);
+  }
+
+  return 0;
+}
diff --git a/gltests/test-locale.c b/gltests/test-locale.c
index 9b55e37..1cd3dac 100644
--- a/gltests/test-locale.c
+++ b/gltests/test-locale.c
@@ -1,5 +1,5 @@
 /* Test of <locale.h> substitute.
-   Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2012 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
diff --git a/gltests/test-localename.c b/gltests/test-localename.c
index 09f002c..f04c301 100644
--- a/gltests/test-localename.c
+++ b/gltests/test-localename.c
@@ -1,5 +1,5 @@
 /* Test of gl_locale_name function and its variants.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
diff --git a/gltests/test-lock.c b/gltests/test-lock.c
index 3f8846b..5cada7d 100644
--- a/gltests/test-lock.c
+++ b/gltests/test-lock.c
@@ -1,5 +1,5 @@
 /* Test of locking in multithreaded situations.
-   Copyright (C) 2005, 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2008-2012 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
@@ -18,7 +18,7 @@
 
 #include <config.h>
 
-#if USE_POSIX_THREADS || USE_SOLARIS_THREADS || USE_PTH_THREADS || 
USE_WIN32_THREADS
+#if USE_POSIX_THREADS || USE_SOLARIS_THREADS || USE_PTH_THREADS || 
USE_WINDOWS_THREADS
 
 #if USE_POSIX_THREADS
 # define TEST_POSIX_THREADS 1
@@ -29,8 +29,8 @@
 #if USE_PTH_THREADS
 # define TEST_PTH_THREADS 1
 #endif
-#if USE_WIN32_THREADS
-# define TEST_WIN32_THREADS 1
+#if USE_WINDOWS_THREADS
+# define TEST_WINDOWS_THREADS 1
 #endif
 
 /* Whether to enable locking.
@@ -69,7 +69,7 @@
 # undef USE_POSIX_THREADS
 # undef USE_SOLARIS_THREADS
 # undef USE_PTH_THREADS
-# undef USE_WIN32_THREADS
+# undef USE_WINDOWS_THREADS
 #endif
 #include "glthread/lock.h"
 
@@ -83,8 +83,8 @@
 # if TEST_PTH_THREADS
 #  define USE_PTH_THREADS 1
 # endif
-# if TEST_WIN32_THREADS
-#  define USE_WIN32_THREADS 1
+# if TEST_WINDOWS_THREADS
+#  define USE_WINDOWS_THREADS 1
 # endif
 #endif
 
@@ -495,7 +495,7 @@ test_once (void)
   for (repeat = 0; repeat <= REPEAT_COUNT; repeat++)
     {
       /* Wait until every thread is ready.  */
-      dbgprintf ("Main thread before synchonizing for round %d\n", repeat);
+      dbgprintf ("Main thread before synchronizing for round %d\n", repeat);
       for (;;)
         {
           int ready_count = 0;
@@ -509,7 +509,7 @@ test_once (void)
             break;
           yield ();
         }
-      dbgprintf ("Main thread after  synchonizing for round %d\n", repeat);
+      dbgprintf ("Main thread after  synchronizing for round %d\n", repeat);
 
       if (repeat > 0)
         {
diff --git a/gltests/test-lseek.c b/gltests/test-lseek.c
index ce2263c..114b06e 100644
--- a/gltests/test-lseek.c
+++ b/gltests/test-lseek.c
@@ -1,5 +1,5 @@
 /* Test of lseek() function.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
@@ -81,12 +81,24 @@ main (int argc, char **argv)
          invoking shell are not enough on HP-UX.  */
       close (0);
       close (1);
+
       errno = 0;
       ASSERT (lseek (0, (off_t)0, SEEK_CUR) == -1);
       ASSERT (errno == EBADF);
+
       errno = 0;
       ASSERT (lseek (1, (off_t)0, SEEK_CUR) == -1);
       ASSERT (errno == EBADF);
+
+      /* Test behaviour for invalid file descriptors.  */
+      errno = 0;
+      ASSERT (lseek (-1, (off_t)0, SEEK_CUR) == -1);
+      ASSERT (errno == EBADF);
+
+      errno = 0;
+      ASSERT (lseek (99, (off_t)0, SEEK_CUR) == -1);
+      ASSERT (errno == EBADF);
+
       break;
 
     default:
diff --git a/gltests/test-lstat.c b/gltests/test-lstat.c
index 372e056..459bf88 100644
--- a/gltests/test-lstat.c
+++ b/gltests/test-lstat.c
@@ -1,5 +1,5 @@
 /* Test of lstat() function.
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
diff --git a/gltests/test-lstat.h b/gltests/test-lstat.h
index 883c4e8..4a81494 100644
--- a/gltests/test-lstat.h
+++ b/gltests/test-lstat.h
@@ -1,5 +1,5 @@
 /* Test of lstat() function.
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
diff --git a/gltests/test-malloca.c b/gltests/test-malloca.c
index 92c86f2..d7732c3 100644
--- a/gltests/test-malloca.c
+++ b/gltests/test-malloca.c
@@ -1,5 +1,5 @@
 /* Test of safe automatic memory allocation.
-   Copyright (C) 2005, 2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2007, 2009-2012 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
diff --git a/gltests/test-mbrtowc-w32.c b/gltests/test-mbrtowc-w32.c
index ee8caf9..50006c0 100644
--- a/gltests/test-mbrtowc-w32.c
+++ b/gltests/test-mbrtowc-w32.c
@@ -1,5 +1,5 @@
 /* Test of conversion of multibyte character to wide character.
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
diff --git a/gltests/test-mbrtowc.c b/gltests/test-mbrtowc.c
index 727016a..02b7841 100644
--- a/gltests/test-mbrtowc.c
+++ b/gltests/test-mbrtowc.c
@@ -1,5 +1,5 @@
 /* Test of conversion of multibyte character to wide character.
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
diff --git a/gltests/test-mbsinit.c b/gltests/test-mbsinit.c
index 2cc2924..dae7569 100644
--- a/gltests/test-mbsinit.c
+++ b/gltests/test-mbsinit.c
@@ -1,5 +1,5 @@
 /* Test of test for initial conversion state.
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
diff --git a/gltests/test-memchr.c b/gltests/test-memchr.c
index a11f6cd..1298c27 100644
--- a/gltests/test-memchr.c
+++ b/gltests/test-memchr.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008-2011 Free Software Foundation, Inc.
+ * Copyright (C) 2008-2012 Free Software Foundation, Inc.
  * Written by Eric Blake and Bruno Haible
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/gltests/test-netdb.c b/gltests/test-netdb.c
index 13a8925..2312f3f 100644
--- a/gltests/test-netdb.c
+++ b/gltests/test-netdb.c
@@ -1,5 +1,5 @@
 /* Test of <netdb.h> substitute.
-   Copyright (C) 2007-2008, 2010-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2008, 2010-2012 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
diff --git a/gltests/test-netinet_in.c b/gltests/test-netinet_in.c
index b1edc66..d318e47 100644
--- a/gltests/test-netinet_in.c
+++ b/gltests/test-netinet_in.c
@@ -1,5 +1,5 @@
 /* Test of <netinet/in.h> substitute.
-   Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2012 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
diff --git a/gltests/test-open.c b/gltests/test-open.c
index 3c5b2ab..b9ec9bf 100644
--- a/gltests/test-open.c
+++ b/gltests/test-open.c
@@ -1,5 +1,5 @@
 /* Test of opening a file descriptor.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
diff --git a/gltests/test-open.h b/gltests/test-open.h
index 2ba5d13..cab1d27 100644
--- a/gltests/test-open.h
+++ b/gltests/test-open.h
@@ -1,5 +1,5 @@
 /* Test of opening a file descriptor.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
diff --git a/gltests/test-pathmax.c b/gltests/test-pathmax.c
new file mode 100644
index 0000000..c6d0ccc
--- /dev/null
+++ b/gltests/test-pathmax.c
@@ -0,0 +1,32 @@
+/* Test of "pathmax.h".
+   Copyright (C) 2011-2012 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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <address@hidden>, 2011.  */
+
+#include <config.h>
+
+#include "pathmax.h"
+
+/* Check that PATH_MAX is a constant if it is defined.  */
+#ifdef PATH_MAX
+int a = PATH_MAX;
+#endif
+
+int
+main (void)
+{
+  return 0;
+}
diff --git a/gltests/test-perror.c b/gltests/test-perror.c
index d3751d8..dbbeb33 100644
--- a/gltests/test-perror.c
+++ b/gltests/test-perror.c
@@ -1,5 +1,5 @@
 /* Test of perror() function.
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
diff --git a/gltests/test-perror2.c b/gltests/test-perror2.c
index e230f92..446bce9 100644
--- a/gltests/test-perror2.c
+++ b/gltests/test-perror2.c
@@ -1,5 +1,5 @@
 /* Test of perror() function.
-   Copyright (C) 2011 Free Software Foundation, Inc.
+   Copyright (C) 2011-2012 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
diff --git a/gltests/test-pipe.c b/gltests/test-pipe.c
index 5302c3e..ebee805 100644
--- a/gltests/test-pipe.c
+++ b/gltests/test-pipe.c
@@ -1,5 +1,5 @@
 /* Test of pipe.
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 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
@@ -26,9 +26,11 @@ SIGNATURE_CHECK (pipe, int, (int[2]));
 #include <stdbool.h>
 
 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-/* Get declarations of the Win32 API functions.  */
+/* Get declarations of the native Windows API functions.  */
 # define WIN32_LEAN_AND_MEAN
 # include <windows.h>
+/* Get _get_osfhandle.  */
+# include "msvc-nothrow.h"
 #endif
 
 #include "binary-io.h"
@@ -39,7 +41,7 @@ static bool
 is_open (int fd)
 {
 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-  /* On Win32, the initial state of unassigned standard file
+  /* On native Windows, the initial state of unassigned standard file
      descriptors is that they are open but point to an
      INVALID_HANDLE_VALUE, and there is no fcntl.  */
   return (HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE;
diff --git a/gltests/test-poll-h.c b/gltests/test-poll-h.c
index c2c063d..0bd4acd 100644
--- a/gltests/test-poll-h.c
+++ b/gltests/test-poll-h.c
@@ -1,5 +1,5 @@
 /* Test of <poll.h> substitute.
-   Copyright (C) 2010-2011 Free Software Foundation, Inc.
+   Copyright (C) 2010-2012 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
diff --git a/gltests/test-poll.c b/gltests/test-poll.c
index 6a616cb..dbf019b 100644
--- a/gltests/test-poll.c
+++ b/gltests/test-poll.c
@@ -1,5 +1,5 @@
 /* Test of poll() function.
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
@@ -36,11 +36,13 @@ SIGNATURE_CHECK (poll, int, (struct pollfd[], nfds_t, int));
 #include <sys/ioctl.h>
 #include <errno.h>
 
+#include "macros.h"
+
 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-# define WIN32_NATIVE
+# define WINDOWS_NATIVE
 #endif
 
-#ifdef WIN32_NATIVE
+#ifdef WINDOWS_NATIVE
 #include <io.h>
 #define pipe(x) _pipe(x, 256, O_BINARY)
 #endif
@@ -132,7 +134,7 @@ connect_to_socket (int blocking)
 
   if (!blocking)
     {
-#ifdef WIN32_NATIVE
+#ifdef WINDOWS_NATIVE
       unsigned long iMode = 1;
       ioctl (s, FIONBIO, (char *) &iMode);
 
@@ -246,7 +248,7 @@ test_connect_first (void)
 static void
 test_accept_first (void)
 {
-#ifndef WIN32_NATIVE
+#ifndef WINDOWS_NATIVE
   int s = open_server_socket ();
   struct sockaddr_in ia;
   socklen_t addrlen;
@@ -261,9 +263,10 @@ test_accept_first (void)
     {
       addrlen = sizeof (ia);
       c = accept (s, (struct sockaddr *) &ia, &addrlen);
+      ASSERT (c >= 0);
       close (s);
-      write (c, "foo", 3);
-      read (c, buf, 3);
+      ASSERT (write (c, "foo", 3) == 3);
+      ASSERT (read (c, buf, 3) == 3);
       shutdown (c, SHUT_RD);
       close (c);
       exit (0);
@@ -272,15 +275,16 @@ test_accept_first (void)
     {
       close (s);
       c = connect_to_socket (true);
+      ASSERT (c >= 0);
       if (poll1_nowait (c, POLLOUT | POLLWRNORM | POLLRDBAND)
           != (POLLOUT | POLLWRNORM))
         failed ("cannot write after blocking connect");
-      write (c, "foo", 3);
+      ASSERT (write (c, "foo", 3) == 3);
       wait (&pid);
       if (poll1_wait (c, POLLIN) != POLLIN)
         failed ("cannot read data left in the socket by closed process");
-      read (c, buf, 3);
-      write (c, "foo", 3);
+      ASSERT (read (c, buf, 3) == 3);
+      ASSERT (write (c, "foo", 3) == 3);
       if ((poll1_wait (c, POLLIN | POLLOUT) & (POLLHUP | POLLERR)) == 0)
         failed ("expecting POLLHUP after shutdown");
       close (c);
@@ -304,7 +308,7 @@ test_pair (int rd, int wd)
       != POLLWRNORM)
     failed ("expecting POLLWRNORM before writing");
 
-  write (wd, "foo", 3);
+  ASSERT (write (wd, "foo", 3) == 3);
   if (poll1_wait (rd, POLLIN | POLLRDNORM) != (POLLIN | POLLRDNORM))
     failed ("expecting POLLIN | POLLRDNORM after writing");
   if (poll1_nowait (rd, POLLIN) != POLLIN)
@@ -312,7 +316,7 @@ test_pair (int rd, int wd)
   if (poll1_nowait (rd, POLLRDNORM) != POLLRDNORM)
     failed ("expecting POLLRDNORM after writing");
 
-  read (rd, buf, 3);
+  ASSERT (read (rd, buf, 3) == 3);
 }
 
 
@@ -327,12 +331,15 @@ test_socket_pair (void)
   int s = open_server_socket ();
   int c1 = connect_to_socket (false);
   int c2 = accept (s, (struct sockaddr *) &ia, &addrlen);
+  ASSERT (s >= 0);
+  ASSERT (c1 >= 0);
+  ASSERT (c2 >= 0);
 
   close (s);
 
   test_pair (c1, c2);
   close (c1);
-  write (c2, "foo", 3);
+  ASSERT (write (c2, "foo", 3) == 3);
   if ((poll1_nowait (c2, POLLIN | POLLOUT) & (POLLHUP | POLLERR)) == 0)
     failed ("expecting POLLHUP after shutdown");
 
@@ -347,7 +354,7 @@ test_pipe (void)
 {
   int fd[2];
 
-  pipe (fd);
+  ASSERT (pipe (fd) >= 0);
   test_pair (fd[0], fd[1]);
   close (fd[0]);
   if ((poll1_wait (fd[1], POLLIN | POLLOUT) & (POLLHUP | POLLERR)) == 0)
diff --git a/gltests/test-quotearg-simple.c b/gltests/test-quotearg-simple.c
index 4d9c87c..e21ceb0 100644
--- a/gltests/test-quotearg-simple.c
+++ b/gltests/test-quotearg-simple.c
@@ -1,5 +1,5 @@
 /* Test of quotearg family of functions.
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
@@ -27,6 +27,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "localcharset.h"
 #include "progname.h"
 #include "macros.h"
 
@@ -85,12 +86,12 @@ static struct result_groups results_g[] = {
       "a\\\\b", LQ_ENC RQ_ENC, LQ RQ } },
 
   /* locale_quoting_style */
-  { { "`'", "`\\0001\\0'", 9, "`simple'", "` \\t\\n\\'\"\\033?""?/\\\\'",
-      "`a:b'", "`a\\\\b'", "`" LQ_ENC RQ_ENC "'", "`" LQ RQ "'" },
-    { "`'", "`\\0001\\0'", 9, "`simple'", "` \\t\\n\\'\"\\033?""?/\\\\'",
-      "`a:b'", "`a\\\\b'", "`" LQ_ENC RQ_ENC "'", "`" LQ RQ "'" },
-    { "`'", "`\\0001\\0'", 9, "`simple'", "` \\t\\n\\'\"\\033?""?/\\\\'",
-      "`a\\:b'", "`a\\\\b'", "`" LQ_ENC RQ_ENC "'", "`" LQ RQ "'" } },
+  { { "''", "'\\0001\\0'", 9, "'simple'", "' \\t\\n\\'\"\\033?""?/\\\\'",
+      "'a:b'", "'a\\\\b'", "'" LQ_ENC RQ_ENC "'", "'" LQ RQ "'" },
+    { "''", "'\\0001\\0'", 9, "'simple'", "' \\t\\n\\'\"\\033?""?/\\\\'",
+      "'a:b'", "'a\\\\b'", "'" LQ_ENC RQ_ENC "'", "'" LQ RQ "'" },
+    { "''", "'\\0001\\0'", 9, "'simple'", "' \\t\\n\\'\"\\033?""?/\\\\'",
+      "'a\\:b'", "'a\\\\b'", "'" LQ_ENC RQ_ENC "'", "'" LQ RQ "'" } },
 
   /* clocale_quoting_style */
   { { "\"\"", "\"\\0001\\0\"", 9, "\"simple\"",
@@ -245,12 +246,20 @@ main (int argc _GL_UNUSED, char *argv[])
   for (i = literal_quoting_style; i <= clocale_quoting_style; i++)
     {
       set_quoting_style (NULL, (enum quoting_style) i);
-      compare_strings (use_quotearg_buffer, &results_g[i].group1, ascii_only);
-      compare_strings (use_quotearg, &results_g[i].group2, ascii_only);
-      if (i == c_quoting_style)
-        compare_strings (use_quote_double_quotes, &results_g[i].group2,
-                         ascii_only);
-      compare_strings (use_quotearg_colon, &results_g[i].group3, ascii_only);
+      if (!(i == locale_quoting_style || i == clocale_quoting_style)
+          || (strcmp (locale_charset (), "ASCII") == 0
+              || strcmp (locale_charset (), "ANSI_X3.4-1968") == 0))
+        {
+          compare_strings (use_quotearg_buffer, &results_g[i].group1,
+                           ascii_only);
+          compare_strings (use_quotearg, &results_g[i].group2,
+                           ascii_only);
+          if (i == c_quoting_style)
+            compare_strings (use_quote_double_quotes, &results_g[i].group2,
+                             ascii_only);
+          compare_strings (use_quotearg_colon, &results_g[i].group3,
+                           ascii_only);
+        }
     }
 
   set_quoting_style (NULL, literal_quoting_style);
diff --git a/gltests/test-quotearg.h b/gltests/test-quotearg.h
index f2e9558..93afcf3 100644
--- a/gltests/test-quotearg.h
+++ b/gltests/test-quotearg.h
@@ -1,5 +1,5 @@
 /* Test of quotearg family of functions.
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
diff --git a/gltests/test-recv.c b/gltests/test-recv.c
new file mode 100644
index 0000000..2186b8e
--- /dev/null
+++ b/gltests/test-recv.c
@@ -0,0 +1,49 @@
+/* Test the recv() function.
+   Copyright (C) 2011-2012 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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include <sys/socket.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (recv, ssize_t, (int, void *, size_t, int));
+
+#include <errno.h>
+
+#include "sockets.h"
+#include "macros.h"
+
+int
+main (void)
+{
+  (void) gl_sockets_startup (SOCKETS_1_1);
+
+  /* Test behaviour for invalid file descriptors.  */
+  {
+    char byte;
+    errno = 0;
+    ASSERT (recv (-1, &byte, 1, 0) == -1);
+    ASSERT (errno == EBADF);
+  }
+  {
+    char byte;
+    errno = 0;
+    ASSERT (recv (99, &byte, 1, 0) == -1);
+    ASSERT (errno == EBADF);
+  }
+
+  return 0;
+}
diff --git a/gltests/test-select-fd.c b/gltests/test-select-fd.c
index de2f3e9..32df4b7 100644
--- a/gltests/test-select-fd.c
+++ b/gltests/test-select-fd.c
@@ -1,5 +1,5 @@
 /* Test of select() substitute, reading or writing from a given file 
descriptor.
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
diff --git a/gltests/test-select-stdin.c b/gltests/test-select-stdin.c
index 5a6f81a..75dd855 100644
--- a/gltests/test-select-stdin.c
+++ b/gltests/test-select-stdin.c
@@ -1,5 +1,5 @@
 /* Test of select() substitute, reading from stdin.
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
diff --git a/gltests/test-select.c b/gltests/test-select.c
index 5c15320..f6e193e 100644
--- a/gltests/test-select.c
+++ b/gltests/test-select.c
@@ -1,5 +1,5 @@
 /* Test of select() substitute.
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
@@ -21,377 +21,14 @@
 #include <sys/select.h>
 
 #include "signature.h"
+
 SIGNATURE_CHECK (select, int, (int, fd_set *, fd_set *, fd_set *,
                                struct timeval *));
-/* The following may be macros without underlying functions, so only
-   check signature if they are not macros.  */
-#ifndef FD_CLR
-SIGNATURE_CHECK (FD_CLR, void, (int, fd_set *));
-#endif
-#ifndef FD_ISSET
-SIGNATURE_CHECK (FD_ISSET, void, (int, fd_set *));
-#endif
-#ifndef FD_SET
-SIGNATURE_CHECK (FD_SET, int, (int, fd_set *));
-#endif
-#ifndef FD_ZERO
-SIGNATURE_CHECK (FD_ZERO, void, (fd_set *));
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <sys/ioctl.h>
-#include <errno.h>
-
-#include "macros.h"
-
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-# define WIN32_NATIVE
-#endif
-
-#ifdef HAVE_SYS_WAIT_H
-# include <sys/wait.h>
-#endif
-
-#ifndef SO_REUSEPORT
-# define SO_REUSEPORT    SO_REUSEADDR
-#endif
-
-#define TEST_PORT       12345
-
-
-/* Minimal testing infrastructure.  */
-
-static int failures;
-
-static void
-failed (const char *reason)
-{
-  if (++failures > 1)
-    printf ("  ");
-  printf ("failed (%s)\n", reason);
-}
-
-static int
-test (void (*fn) (void), const char *msg)
-{
-  failures = 0;
-  printf ("%s... ", msg);
-  fflush (stdout);
-  fn ();
-
-  if (!failures)
-    printf ("passed\n");
-
-  return failures;
-}
-
-
-/* Funny socket code.  */
-
-static int
-open_server_socket (void)
-{
-  int s, x;
-  struct sockaddr_in ia;
-
-  s = socket (AF_INET, SOCK_STREAM, 0);
-
-  memset (&ia, 0, sizeof (ia));
-  ia.sin_family = AF_INET;
-  inet_pton (AF_INET, "127.0.0.1", &ia.sin_addr);
-  ia.sin_port = htons (TEST_PORT);
-  if (bind (s, (struct sockaddr *) &ia, sizeof (ia)) < 0)
-    {
-      perror ("bind");
-      exit (77);
-    }
-
-  x = 1;
-  setsockopt (s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof (x));
-
-  if (listen (s, 1) < 0)
-    {
-      perror ("listen");
-      exit (77);
-    }
-
-  return s;
-}
-
-static int
-connect_to_socket (bool blocking)
-{
-  int s;
-  struct sockaddr_in ia;
-
-  s = socket (AF_INET, SOCK_STREAM, 0);
-
-  memset (&ia, 0, sizeof (ia));
-  ia.sin_family = AF_INET;
-  inet_pton (AF_INET, "127.0.0.1", &ia.sin_addr);
-  ia.sin_port = htons (TEST_PORT);
-
-  if (!blocking)
-    {
-#ifdef WIN32_NATIVE
-      unsigned long iMode = 1;
-      ioctl (s, FIONBIO, (char *) &iMode);
-
-#elif defined F_GETFL
-      int oldflags = fcntl (s, F_GETFL, NULL);
-
-      if (!(oldflags & O_NONBLOCK))
-        fcntl (s, F_SETFL, oldflags | O_NONBLOCK);
-#endif
-    }
-
-  if (connect (s, (struct sockaddr *) &ia, sizeof (ia)) < 0
-      && (blocking || errno != EINPROGRESS))
-    {
-      perror ("connect");
-      exit (77);
-    }
-
-  return s;
-}
-
-
-/* A slightly more convenient interface to select(2).
-   Waits until a specific event occurs on a file descriptor FD.
-   EV is a bit mask of events to look for:
-     SEL_IN - input can be polled without blocking,
-     SEL_OUT - output can be provided without blocking,
-     SEL_EXC - an exception occurred,
-   A maximum wait time is specified by TIMEOUT.
-   *TIMEOUT = { 0, 0 } means to return immediately,
-   TIMEOUT = NULL means to wait indefinitely.  */
-
-enum { SEL_IN = 1, SEL_OUT = 2, SEL_EXC = 4 };
-
-static int
-do_select (int fd, int ev, struct timeval *timeout)
-{
-  fd_set rfds, wfds, xfds;
-  int r, rev;
-
-  FD_ZERO (&rfds);
-  FD_ZERO (&wfds);
-  FD_ZERO (&xfds);
-  if (ev & SEL_IN)
-    FD_SET (fd, &rfds);
-  if (ev & SEL_OUT)
-    FD_SET (fd, &wfds);
-  if (ev & SEL_EXC)
-    FD_SET (fd, &xfds);
-  r = select (fd + 1, &rfds, &wfds, &xfds, timeout);
-  if (r < 0)
-    return r;
-
-  rev = 0;
-  if (FD_ISSET (fd, &rfds))
-    rev |= SEL_IN;
-  if (FD_ISSET (fd, &wfds))
-    rev |= SEL_OUT;
-  if (FD_ISSET (fd, &xfds))
-    rev |= SEL_EXC;
-  if (rev && r == 0)
-    failed ("select returned 0");
-  if (rev & ~ev)
-    failed ("select returned unrequested events");
-
-  return rev;
-}
-
-static int
-do_select_nowait (int fd, int ev)
-{
-  struct timeval tv0;
-  tv0.tv_sec = 0;
-  tv0.tv_usec = 0;
-  return do_select (fd, ev, &tv0);
-}
-
-static int
-do_select_wait (int fd, int ev)
-{
-  return do_select (fd, ev, NULL);
-}
-
-
-/* Test select(2) for TTYs.  */
-
-#ifdef INTERACTIVE
-static void
-test_tty (void)
-{
-  if (do_select_nowait (0, SEL_IN) != 0)
-    failed ("can read");
-  if (do_select_nowait (0, SEL_OUT) == 0)
-    failed ("cannot write");
-
-  if (do_select_wait (0, SEL_IN) == 0)
-    failed ("return with infinite timeout");
-
-  getchar ();
-  if (do_select_nowait (0, SEL_IN) != 0)
-    failed ("can read after getc");
-}
-#endif
-
-
-/* Test select(2) for unconnected nonblocking sockets.  */
-
-static void
-test_connect_first (void)
-{
-  int s = open_server_socket ();
-  struct sockaddr_in ia;
-  socklen_t addrlen;
-
-  int c1, c2;
-
-  if (do_select_nowait (s, SEL_IN | SEL_EXC) != 0)
-    failed ("can read, socket not connected");
-
-  c1 = connect_to_socket (false);
-
-  if (do_select_wait (s, SEL_IN | SEL_EXC) != SEL_IN)
-    failed ("expecting readability on passive socket");
-  if (do_select_nowait (s, SEL_IN | SEL_EXC) != SEL_IN)
-    failed ("expecting readability on passive socket");
-
-  addrlen = sizeof (ia);
-  c2 = accept (s, (struct sockaddr *) &ia, &addrlen);
-  ASSERT (close (s) == 0);
-  ASSERT (close (c1) == 0);
-  ASSERT (close (c2) == 0);
-}
-
-
-/* Test select(2) for unconnected blocking sockets.  */
-
-static void
-test_accept_first (void)
-{
-#ifndef WIN32_NATIVE
-  int s = open_server_socket ();
-  struct sockaddr_in ia;
-  socklen_t addrlen;
-  char buf[3];
-  int c, pid;
-
-  pid = fork ();
-  if (pid < 0)
-    return;
-
-  if (pid == 0)
-    {
-      addrlen = sizeof (ia);
-      c = accept (s, (struct sockaddr *) &ia, &addrlen);
-      ASSERT (close (s) == 0);
-      ASSERT (write (c, "foo", 3) == 3);
-      ASSERT (read (c, buf, 3) == 3);
-      shutdown (c, SHUT_RD);
-      ASSERT (close (c) == 0);
-      exit (0);
-    }
-  else
-    {
-      ASSERT (close (s) == 0);
-      c = connect_to_socket (true);
-      if (do_select_nowait (c, SEL_OUT) != SEL_OUT)
-        failed ("cannot write after blocking connect");
-      ASSERT (write (c, "foo", 3) == 3);
-      wait (&pid);
-      if (do_select_wait (c, SEL_IN) != SEL_IN)
-        failed ("cannot read data left in the socket by closed process");
-      ASSERT (read (c, buf, 3) == 3);
-      ASSERT (write (c, "foo", 3) == 3);
-      (void) close (c); /* may fail with errno = ECONNRESET */
-    }
-#endif
-}
 
-
-/* Common code for pipes and connected sockets.  */
-
-static void
-test_pair (int rd, int wd)
-{
-  char buf[3];
-  if (do_select_wait (wd, SEL_IN | SEL_OUT | SEL_EXC) != SEL_OUT)
-    failed ("expecting writability before writing");
-  if (do_select_nowait (wd, SEL_IN | SEL_OUT | SEL_EXC) != SEL_OUT)
-    failed ("expecting writability before writing");
-
-  ASSERT (write (wd, "foo", 3) == 3);
-  if (do_select_wait (rd, SEL_IN) != SEL_IN)
-    failed ("expecting readability after writing");
-  if (do_select_nowait (rd, SEL_IN) != SEL_IN)
-    failed ("expecting readability after writing");
-
-  ASSERT (read (rd, buf, 3) == 3);
-}
-
-
-/* Test select(2) on connected sockets.  */
-
-static void
-test_socket_pair (void)
-{
-  struct sockaddr_in ia;
-
-  socklen_t addrlen = sizeof (ia);
-  int s = open_server_socket ();
-  int c1 = connect_to_socket (false);
-  int c2 = accept (s, (struct sockaddr *) &ia, &addrlen);
-
-  ASSERT (close (s) == 0);
-
-  test_pair (c1, c2);
-  ASSERT (close (c1) == 0);
-  ASSERT (write (c2, "foo", 3) == 3);
-  (void) close (c2); /* may fail with errno = ECONNRESET */
-}
-
-
-/* Test select(2) on pipes.  */
-
-static void
-test_pipe (void)
-{
-  int fd[2];
-
-  ASSERT (pipe (fd) == 0);
-  test_pair (fd[0], fd[1]);
-  ASSERT (close (fd[0]) == 0);
-  ASSERT (close (fd[1]) == 0);
-}
-
-
-/* Do them all.  */
+#include "test-select.h"
 
 int
 main (void)
 {
-  int result;
-
-#ifdef INTERACTIVE
-  printf ("Please press Enter\n");
-  test (test_tty, "TTY");
-#endif
-
-  result = test (test_connect_first, "Unconnected socket test");
-  result += test (test_socket_pair, "Connected sockets test");
-  result += test (test_accept_first, "General socket test with fork");
-  result += test (test_pipe, "Pipe test");
-
-  exit (result);
+  return test_function (select);
 }
diff --git a/gltests/test-select.h b/gltests/test-select.h
new file mode 100644
index 0000000..9fe998c
--- /dev/null
+++ b/gltests/test-select.h
@@ -0,0 +1,436 @@
+/* Test of select() substitute.
+   Copyright (C) 2008-2012 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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Paolo Bonzini, 2008.  */
+
+#include <stdio.h>
+#include <string.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+
+#include "macros.h"
+
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# define WINDOWS_NATIVE
+#endif
+
+#ifdef HAVE_SYS_WAIT_H
+# include <sys/wait.h>
+#endif
+
+#ifndef SO_REUSEPORT
+# define SO_REUSEPORT    SO_REUSEADDR
+#endif
+
+#define TEST_PORT       12345
+
+
+typedef int (*select_fn) (int, fd_set *, fd_set *, fd_set *, struct timeval *);
+
+
+/* Minimal testing infrastructure.  */
+
+static int failures;
+
+static void
+failed (const char *reason)
+{
+  if (++failures > 1)
+    printf ("  ");
+  printf ("failed (%s)\n", reason);
+}
+
+static int
+test (void (*fn) (select_fn), select_fn my_select, const char *msg)
+{
+  failures = 0;
+  printf ("%s... ", msg);
+  fflush (stdout);
+  fn (my_select);
+
+  if (!failures)
+    printf ("passed\n");
+
+  return failures;
+}
+
+
+/* Funny socket code.  */
+
+static int
+open_server_socket (void)
+{
+  int s, x;
+  struct sockaddr_in ia;
+
+  s = socket (AF_INET, SOCK_STREAM, 0);
+
+  memset (&ia, 0, sizeof (ia));
+  ia.sin_family = AF_INET;
+  inet_pton (AF_INET, "127.0.0.1", &ia.sin_addr);
+  ia.sin_port = htons (TEST_PORT);
+  if (bind (s, (struct sockaddr *) &ia, sizeof (ia)) < 0)
+    {
+      perror ("bind");
+      exit (77);
+    }
+
+  x = 1;
+  setsockopt (s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof (x));
+
+  if (listen (s, 1) < 0)
+    {
+      perror ("listen");
+      exit (77);
+    }
+
+  return s;
+}
+
+static int
+connect_to_socket (bool blocking)
+{
+  int s;
+  struct sockaddr_in ia;
+
+  s = socket (AF_INET, SOCK_STREAM, 0);
+
+  memset (&ia, 0, sizeof (ia));
+  ia.sin_family = AF_INET;
+  inet_pton (AF_INET, "127.0.0.1", &ia.sin_addr);
+  ia.sin_port = htons (TEST_PORT);
+
+  if (!blocking)
+    {
+#ifdef WINDOWS_NATIVE
+      unsigned long iMode = 1;
+      ioctl (s, FIONBIO, (char *) &iMode);
+
+#elif defined F_GETFL
+      int oldflags = fcntl (s, F_GETFL, NULL);
+
+      if (!(oldflags & O_NONBLOCK))
+        fcntl (s, F_SETFL, oldflags | O_NONBLOCK);
+#endif
+    }
+
+  if (connect (s, (struct sockaddr *) &ia, sizeof (ia)) < 0
+      && (blocking || errno != EINPROGRESS))
+    {
+      perror ("connect");
+      exit (77);
+    }
+
+  return s;
+}
+
+
+/* A slightly more convenient interface to select(2).
+   Waits until a specific event occurs on a file descriptor FD.
+   EV is a bit mask of events to look for:
+     SEL_IN - input can be polled without blocking,
+     SEL_OUT - output can be provided without blocking,
+     SEL_EXC - an exception occurred,
+   A maximum wait time is specified by TIMEOUT.
+   *TIMEOUT = { 0, 0 } means to return immediately,
+   TIMEOUT = NULL means to wait indefinitely.  */
+
+enum { SEL_IN = 1, SEL_OUT = 2, SEL_EXC = 4 };
+
+static int
+do_select (int fd, int ev, struct timeval *timeout, select_fn my_select)
+{
+  fd_set rfds, wfds, xfds;
+  int r, rev;
+
+  FD_ZERO (&rfds);
+  FD_ZERO (&wfds);
+  FD_ZERO (&xfds);
+  if (ev & SEL_IN)
+    FD_SET (fd, &rfds);
+  if (ev & SEL_OUT)
+    FD_SET (fd, &wfds);
+  if (ev & SEL_EXC)
+    FD_SET (fd, &xfds);
+  r = my_select (fd + 1, &rfds, &wfds, &xfds, timeout);
+  if (r < 0)
+    return r;
+
+  rev = 0;
+  if (FD_ISSET (fd, &rfds))
+    rev |= SEL_IN;
+  if (FD_ISSET (fd, &wfds))
+    rev |= SEL_OUT;
+  if (FD_ISSET (fd, &xfds))
+    rev |= SEL_EXC;
+  if (rev && r == 0)
+    failed ("select returned 0");
+  if (rev & ~ev)
+    failed ("select returned unrequested events");
+
+  return rev;
+}
+
+static int
+do_select_nowait (int fd, int ev, select_fn my_select)
+{
+  struct timeval tv0;
+  tv0.tv_sec = 0;
+  tv0.tv_usec = 0;
+  return do_select (fd, ev, &tv0, my_select);
+}
+
+static int
+do_select_wait (int fd, int ev, select_fn my_select)
+{
+  return do_select (fd, ev, NULL, my_select);
+}
+
+
+/* Test select(2) for TTYs.  */
+
+#ifdef INTERACTIVE
+static void
+test_tty (select_fn my_select)
+{
+  if (do_select_nowait (0, SEL_IN, my_select) != 0)
+    failed ("can read");
+  if (do_select_nowait (0, SEL_OUT, my_select) == 0)
+    failed ("cannot write");
+
+  if (do_select_wait (0, SEL_IN, my_select) == 0)
+    failed ("return with infinite timeout");
+
+  getchar ();
+  if (do_select_nowait (0, SEL_IN, my_select) != 0)
+    failed ("can read after getc");
+}
+#endif
+
+
+/* Test select(2) on invalid file descriptors.  */
+
+static int
+do_select_bad_fd (int fd, int ev, struct timeval *timeout, select_fn my_select)
+{
+  fd_set rfds, wfds, xfds;
+
+  FD_ZERO (&rfds);
+  FD_ZERO (&wfds);
+  FD_ZERO (&xfds);
+  if (ev & SEL_IN)
+    FD_SET (fd, &rfds);
+  if (ev & SEL_OUT)
+    FD_SET (fd, &wfds);
+  if (ev & SEL_EXC)
+    FD_SET (fd, &xfds);
+  return my_select (fd + 1, &rfds, &wfds, &xfds, timeout);
+  /* In this case, when fd is invalid, on some platforms, the bit for fd
+     is left alone in the fd_set, whereas on other platforms it is cleared.
+     So, don't check the bit for fd here.  */
+}
+
+static int
+do_select_bad_fd_nowait (int fd, int ev, select_fn my_select)
+{
+  struct timeval tv0;
+  tv0.tv_sec = 0;
+  tv0.tv_usec = 0;
+  return do_select_bad_fd (fd, ev, &tv0, my_select);
+}
+
+static void
+test_bad_fd (select_fn my_select)
+{
+  /* This tests fails on OSF/1 and native Windows, even with fd = 16.  */
+#if !(defined __osf__ || defined WINDOWS_NATIVE)
+  int fd;
+
+  /* On Linux, MacOS X, *BSD, values of fd like 99 or 399 are discarded
+     by the kernel early and therefore do *not* lead to EBADF, as required
+     by POSIX.  */
+# if defined __linux__ || (defined __APPLE__ && defined __MACH__) || defined 
__FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__
+  fd = 16;
+# else
+  fd = 99;
+# endif
+
+  if (do_select_bad_fd_nowait (fd, SEL_IN, my_select) == 0 || errno != EBADF)
+    failed ("invalid fd among rfds");
+  if (do_select_bad_fd_nowait (fd, SEL_OUT, my_select) == 0 || errno != EBADF)
+    failed ("invalid fd among wfds");
+  if (do_select_bad_fd_nowait (fd, SEL_EXC, my_select) == 0 || errno != EBADF)
+    failed ("invalid fd among xfds");
+#endif
+}
+
+
+/* Test select(2) for unconnected nonblocking sockets.  */
+
+static void
+test_connect_first (select_fn my_select)
+{
+  int s = open_server_socket ();
+  struct sockaddr_in ia;
+  socklen_t addrlen;
+
+  int c1, c2;
+
+  if (do_select_nowait (s, SEL_IN | SEL_EXC, my_select) != 0)
+    failed ("can read, socket not connected");
+
+  c1 = connect_to_socket (false);
+
+  if (do_select_wait (s, SEL_IN | SEL_EXC, my_select) != SEL_IN)
+    failed ("expecting readability on passive socket");
+  if (do_select_nowait (s, SEL_IN | SEL_EXC, my_select) != SEL_IN)
+    failed ("expecting readability on passive socket");
+
+  addrlen = sizeof (ia);
+  c2 = accept (s, (struct sockaddr *) &ia, &addrlen);
+  ASSERT (close (s) == 0);
+  ASSERT (close (c1) == 0);
+  ASSERT (close (c2) == 0);
+}
+
+
+/* Test select(2) for unconnected blocking sockets.  */
+
+static void
+test_accept_first (select_fn my_select)
+{
+#ifndef WINDOWS_NATIVE
+  int s = open_server_socket ();
+  struct sockaddr_in ia;
+  socklen_t addrlen;
+  char buf[3];
+  int c, pid;
+
+  pid = fork ();
+  if (pid < 0)
+    return;
+
+  if (pid == 0)
+    {
+      addrlen = sizeof (ia);
+      c = accept (s, (struct sockaddr *) &ia, &addrlen);
+      ASSERT (close (s) == 0);
+      ASSERT (write (c, "foo", 3) == 3);
+      ASSERT (read (c, buf, 3) == 3);
+      shutdown (c, SHUT_RD);
+      ASSERT (close (c) == 0);
+      exit (0);
+    }
+  else
+    {
+      ASSERT (close (s) == 0);
+      c = connect_to_socket (true);
+      if (do_select_nowait (c, SEL_OUT, my_select) != SEL_OUT)
+        failed ("cannot write after blocking connect");
+      ASSERT (write (c, "foo", 3) == 3);
+      wait (&pid);
+      if (do_select_wait (c, SEL_IN, my_select) != SEL_IN)
+        failed ("cannot read data left in the socket by closed process");
+      ASSERT (read (c, buf, 3) == 3);
+      ASSERT (write (c, "foo", 3) == 3);
+      (void) close (c); /* may fail with errno = ECONNRESET */
+    }
+#endif
+}
+
+
+/* Common code for pipes and connected sockets.  */
+
+static void
+test_pair (int rd, int wd, select_fn my_select)
+{
+  char buf[3];
+  if (do_select_wait (wd, SEL_IN | SEL_OUT | SEL_EXC, my_select) != SEL_OUT)
+    failed ("expecting writability before writing");
+  if (do_select_nowait (wd, SEL_IN | SEL_OUT | SEL_EXC, my_select) != SEL_OUT)
+    failed ("expecting writability before writing");
+
+  ASSERT (write (wd, "foo", 3) == 3);
+  if (do_select_wait (rd, SEL_IN, my_select) != SEL_IN)
+    failed ("expecting readability after writing");
+  if (do_select_nowait (rd, SEL_IN, my_select) != SEL_IN)
+    failed ("expecting readability after writing");
+
+  ASSERT (read (rd, buf, 3) == 3);
+}
+
+
+/* Test select(2) on connected sockets.  */
+
+static void
+test_socket_pair (select_fn my_select)
+{
+  struct sockaddr_in ia;
+
+  socklen_t addrlen = sizeof (ia);
+  int s = open_server_socket ();
+  int c1 = connect_to_socket (false);
+  int c2 = accept (s, (struct sockaddr *) &ia, &addrlen);
+
+  ASSERT (close (s) == 0);
+
+  test_pair (c1, c2, my_select);
+  ASSERT (close (c1) == 0);
+  ASSERT (write (c2, "foo", 3) == 3);
+  (void) close (c2); /* may fail with errno = ECONNRESET */
+}
+
+
+/* Test select(2) on pipes.  */
+
+static void
+test_pipe (select_fn my_select)
+{
+  int fd[2];
+
+  ASSERT (pipe (fd) == 0);
+  test_pair (fd[0], fd[1], my_select);
+  ASSERT (close (fd[0]) == 0);
+  ASSERT (close (fd[1]) == 0);
+}
+
+
+/* Do them all.  */
+
+static int
+test_function (select_fn my_select)
+{
+  int result = 0;
+
+#ifdef INTERACTIVE
+  printf ("Please press Enter\n");
+  test (test_tty, "TTY", my_select);
+#endif
+
+  result += test (test_bad_fd, my_select, "Invalid fd test");
+  result += test (test_connect_first, my_select, "Unconnected socket test");
+  result += test (test_socket_pair, my_select, "Connected sockets test");
+  result += test (test_accept_first, my_select, "General socket test with 
fork");
+  result += test (test_pipe, my_select, "Pipe test");
+
+  return result;
+}
diff --git a/gltests/test-setenv.c b/gltests/test-setenv.c
index 50eb71b..4752a11 100644
--- a/gltests/test-setenv.c
+++ b/gltests/test-setenv.c
@@ -1,5 +1,5 @@
 /* Tests of setenv.
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 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
diff --git a/gltests/test-setlocale1.c b/gltests/test-setlocale1.c
index ea7945c..08f9224 100644
--- a/gltests/test-setlocale1.c
+++ b/gltests/test-setlocale1.c
@@ -1,5 +1,5 @@
 /* Test of setting the current locale.
-   Copyright (C) 2011 Free Software Foundation, Inc.
+   Copyright (C) 2011-2012 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
diff --git a/gltests/test-setlocale2.c b/gltests/test-setlocale2.c
index 7bfc42a..7416647 100644
--- a/gltests/test-setlocale2.c
+++ b/gltests/test-setlocale2.c
@@ -1,5 +1,5 @@
 /* Test of setting the current locale.
-   Copyright (C) 2011 Free Software Foundation, Inc.
+   Copyright (C) 2011-2012 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
diff --git a/gltests/test-setlocale2.sh b/gltests/test-setlocale2.sh
index 723e74e..904e147 100755
--- a/gltests/test-setlocale2.sh
+++ b/gltests/test-setlocale2.sh
@@ -2,14 +2,16 @@
 
 # Test locale names with likely unsupported encoding in Unix syntax.
 for name in ar_SA.ISO-8859-1 fr_FR.CP1251 zh_TW.GB18030 zh_CN.BIG5; do
-  LC_ALL=$name ./test-setlocale2${EXEEXT} 1 || exit 1
+  env LC_ALL=$name ./test-setlocale2${EXEEXT} 1 || exit 1
 done
 
 # Test locale names with likely unsupported encoding in native Windows syntax.
 for name in "Arabic_Saudi Arabia.1252" "Arabic_Saudi Arabia.65001" \
             French_France.65001 Japanese_Japan.65001 Turkish_Turkey.65001 \
             Chinese_Taiwan.65001 Chinese_China.54936 Chinese_China.65001; do
-  LC_ALL=$name ./test-setlocale2${EXEEXT} 1 || exit 1
+  # Here we use 'env' to set the LC_ALL environment variable, because on
+  # Solaris 11 2011-11, the /bin/sh refuses to do it for Turkish_Turkey.65001.
+  env LC_ALL="$name" ./test-setlocale2${EXEEXT} 1 || exit 1
 done
 
 exit 0
diff --git a/gltests/test-setsockopt.c b/gltests/test-setsockopt.c
new file mode 100644
index 0000000..c14d217
--- /dev/null
+++ b/gltests/test-setsockopt.c
@@ -0,0 +1,53 @@
+/* Test setsockopt() function.
+   Copyright (C) 2011-2012 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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include <sys/socket.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (setsockopt, int, (int, int, int, const void *, socklen_t));
+
+#include <errno.h>
+
+#include "sockets.h"
+#include "macros.h"
+
+int
+main (void)
+{
+  (void) gl_sockets_startup (SOCKETS_1_1);
+
+  /* Test behaviour for invalid file descriptors.  */
+  {
+    int value = 1;
+
+    errno = 0;
+    ASSERT (setsockopt (-1, SOL_SOCKET, SO_REUSEADDR, &value, sizeof (value))
+            == -1);
+    ASSERT (errno == EBADF);
+  }
+  {
+    int value = 1;
+
+    errno = 0;
+    ASSERT (setsockopt (99, SOL_SOCKET, SO_REUSEADDR, &value, sizeof (value))
+            == -1);
+    ASSERT (errno == EBADF);
+  }
+
+  return 0;
+}
diff --git a/gltests/test-shutdown.c b/gltests/test-shutdown.c
new file mode 100644
index 0000000..be9f550
--- /dev/null
+++ b/gltests/test-shutdown.c
@@ -0,0 +1,47 @@
+/* Test the shutdown() function.
+   Copyright (C) 2011-2012 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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include <sys/socket.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (shutdown, int, (int, int));
+
+#include <errno.h>
+
+#include "sockets.h"
+#include "macros.h"
+
+int
+main (void)
+{
+  (void) gl_sockets_startup (SOCKETS_1_1);
+
+  /* Test behaviour for invalid file descriptors.  */
+  {
+    errno = 0;
+    ASSERT (shutdown (-1, SHUT_RD) == -1);
+    ASSERT (errno == EBADF);
+  }
+  {
+    errno = 0;
+    ASSERT (shutdown (99, SHUT_RD) == -1);
+    ASSERT (errno == EBADF);
+  }
+
+  return 0;
+}
diff --git a/gltests/test-signal-h.c b/gltests/test-signal-h.c
new file mode 100644
index 0000000..9529017
--- /dev/null
+++ b/gltests/test-signal-h.c
@@ -0,0 +1,129 @@
+/* Test of <signal.h> substitute.
+   Copyright (C) 2009-2012 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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Eric Blake <address@hidden>, 2009.  */
+
+#include <config.h>
+
+#include <signal.h>
+
+/* Check for required types.  */
+struct
+{
+  size_t a;
+  uid_t b;
+  volatile sig_atomic_t c;
+  sigset_t d;
+  pid_t e;
+#if 0
+  /* Not guaranteed by gnulib.  */
+  pthread_t f;
+  struct timespec g;
+#endif
+} s;
+
+/* Check that NSIG is defined.  */
+int nsig = NSIG;
+
+int
+main (void)
+{
+  switch (0)
+    {
+      /* The following are guaranteed by C.  */
+    case 0:
+    case SIGABRT:
+    case SIGFPE:
+    case SIGILL:
+    case SIGINT:
+    case SIGSEGV:
+    case SIGTERM:
+      /* The following is guaranteed by gnulib.  */
+#if GNULIB_SIGPIPE || defined SIGPIPE
+    case SIGPIPE:
+#endif
+      /* Ensure no conflict with other standardized names.  */
+#ifdef SIGALRM
+    case SIGALRM:
+#endif
+      /* On Haiku, SIGBUS is mistakenly equal to SIGSEGV.  */
+#if defined SIGBUS && SIGBUS != SIGSEGV
+    case SIGBUS:
+#endif
+#ifdef SIGCHLD
+    case SIGCHLD:
+#endif
+#ifdef SIGCONT
+    case SIGCONT:
+#endif
+#ifdef SIGHUP
+    case SIGHUP:
+#endif
+#ifdef SIGKILL
+    case SIGKILL:
+#endif
+#ifdef SIGQUIT
+    case SIGQUIT:
+#endif
+#ifdef SIGSTOP
+    case SIGSTOP:
+#endif
+#ifdef SIGTSTP
+    case SIGTSTP:
+#endif
+#ifdef SIGTTIN
+    case SIGTTIN:
+#endif
+#ifdef SIGTTOU
+    case SIGTTOU:
+#endif
+#ifdef SIGUSR1
+    case SIGUSR1:
+#endif
+#ifdef SIGUSR2
+    case SIGUSR2:
+#endif
+#ifdef SIGSYS
+    case SIGSYS:
+#endif
+#ifdef SIGTRAP
+    case SIGTRAP:
+#endif
+#ifdef SIGURG
+    case SIGURG:
+#endif
+#ifdef SIGVTALRM
+    case SIGVTALRM:
+#endif
+#ifdef SIGXCPU
+    case SIGXCPU:
+#endif
+#ifdef SIGXFSZ
+    case SIGXFSZ:
+#endif
+      /* SIGRTMIN and SIGRTMAX need not be compile-time constants.  */
+#if 0
+# ifdef SIGRTMIN
+    case SIGRTMIN:
+# endif
+# ifdef SIGRTMAX
+    case SIGRTMAX:
+# endif
+#endif
+      ;
+    }
+  return s.a + s.b + s.c + s.e;
+}
diff --git a/gltests/test-snprintf.c b/gltests/test-snprintf.c
index 95a352d..bd66449 100644
--- a/gltests/test-snprintf.c
+++ b/gltests/test-snprintf.c
@@ -1,5 +1,5 @@
 /* Test of snprintf() function.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
@@ -60,5 +60,13 @@ main (int argc, char *argv[])
         }
     }
 
+  /* Test the support of the POSIX/XSI format strings with positions.  */
+  {
+    char result[100];
+    retval = snprintf (result, sizeof (result), "%2$d %1$d", 33, 55);
+    ASSERT (strcmp (result, "55 33") == 0);
+    ASSERT (retval == strlen (result));
+  }
+
   return 0;
 }
diff --git a/gltests/test-sockets.c b/gltests/test-sockets.c
index 0170d37..f43e011 100644
--- a/gltests/test-sockets.c
+++ b/gltests/test-sockets.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008-2011 Free Software Foundation, Inc.
+ * Copyright (C) 2008-2012 Free Software Foundation, Inc.
  * Written by Simon Josefsson.
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/gltests/test-stat.c b/gltests/test-stat.c
index cd74491..db9adf9 100644
--- a/gltests/test-stat.c
+++ b/gltests/test-stat.c
@@ -1,5 +1,5 @@
 /* Tests of stat.
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 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
diff --git a/gltests/test-stat.h b/gltests/test-stat.h
index 3c8f7ad..2c9afc0 100644
--- a/gltests/test-stat.h
+++ b/gltests/test-stat.h
@@ -1,5 +1,5 @@
 /* Tests of stat.
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 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
diff --git a/gltests/test-stdalign.c b/gltests/test-stdalign.c
new file mode 100644
index 0000000..d4c1d2e
--- /dev/null
+++ b/gltests/test-stdalign.c
@@ -0,0 +1,116 @@
+/* Test of <stdalign.h>.
+   Copyright 2009-2012 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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Paul Eggert, inspired by Bruno Haible's test-alignof.c.  */
+
+#include <config.h>
+
+#include <stdalign.h>
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "verify.h"
+
+#include "macros.h"
+
+typedef long double longdouble;
+typedef struct { char a[1]; } struct1;
+typedef struct { char a[2]; } struct2;
+typedef struct { char a[3]; } struct3;
+typedef struct { char a[4]; } struct4;
+
+verify (__alignof_is_defined == 1);
+#ifndef alignof
+# error "alignof is not a macro"
+#endif
+
+#if __alignas_is_defined
+verify (__alignas_is_defined == 1);
+# ifndef alignas
+#  error "alignas is not a macro"
+# endif
+/* mingw can go up only to 8.  8 is all that GNU Emacs needs, so let's
+   limit the test to 8 for now.  */
+# define TEST_ALIGNMENT 8
+#else
+# define _Alignas(alignment)
+# define alignas(alignment)
+# define TEST_ALIGNMENT 1
+#endif
+
+#define CHECK_STATIC(type) \
+  typedef struct { char slot1; type slot2; } type##_helper; \
+  verify (alignof (type) == offsetof (type##_helper, slot2)); \
+  verify (_Alignof (type) == alignof (type)); \
+  const int type##_alignment = alignof (type); \
+  type alignas (TEST_ALIGNMENT) static_##type##_alignas; \
+  type _Alignas (TEST_ALIGNMENT) static_##type##_Alignas
+
+#define CHECK_ALIGNED(var) ASSERT ((uintptr_t) &(var) % TEST_ALIGNMENT == 0)
+
+CHECK_STATIC (char);
+CHECK_STATIC (short);
+CHECK_STATIC (int);
+CHECK_STATIC (long);
+#ifdef INT64_MAX
+CHECK_STATIC (int64_t);
+#endif
+CHECK_STATIC (float);
+CHECK_STATIC (double);
+/* CHECK_STATIC (longdouble); */
+CHECK_STATIC (struct1);
+CHECK_STATIC (struct2);
+CHECK_STATIC (struct3);
+CHECK_STATIC (struct4);
+
+int
+main ()
+{
+#if defined __SUNPRO_C
+  /* Avoid a test failure due to Sun Studio Developer Bug Report #2125432.  */
+  fputs ("Skipping test: known Sun C compiler bug\n", stderr);
+  return 77;
+#else
+  CHECK_ALIGNED (static_char_alignas);
+  CHECK_ALIGNED (static_char_Alignas);
+  CHECK_ALIGNED (static_short_alignas);
+  CHECK_ALIGNED (static_short_Alignas);
+  CHECK_ALIGNED (static_int_alignas);
+  CHECK_ALIGNED (static_int_Alignas);
+  CHECK_ALIGNED (static_long_alignas);
+  CHECK_ALIGNED (static_long_Alignas);
+# ifdef INT64_MAX
+  CHECK_ALIGNED (static_int64_t_alignas);
+  CHECK_ALIGNED (static_int64_t_Alignas);
+# endif
+  CHECK_ALIGNED (static_float_alignas);
+  CHECK_ALIGNED (static_float_Alignas);
+  CHECK_ALIGNED (static_double_alignas);
+  CHECK_ALIGNED (static_double_Alignas);
+  /* CHECK_ALIGNED (static_longdouble_alignas); */
+  /* CHECK_ALIGNED (static_longdouble_Alignas); */
+  CHECK_ALIGNED (static_struct1_alignas);
+  CHECK_ALIGNED (static_struct1_Alignas);
+  CHECK_ALIGNED (static_struct2_alignas);
+  CHECK_ALIGNED (static_struct2_Alignas);
+  CHECK_ALIGNED (static_struct3_alignas);
+  CHECK_ALIGNED (static_struct3_Alignas);
+  CHECK_ALIGNED (static_struct4_alignas);
+  CHECK_ALIGNED (static_struct4_Alignas);
+  return 0;
+#endif
+}
diff --git a/gltests/test-stdbool.c b/gltests/test-stdbool.c
index e115ba2..c22ca1f 100644
--- a/gltests/test-stdbool.c
+++ b/gltests/test-stdbool.c
@@ -1,5 +1,5 @@
 /* Test of <stdbool.h> substitute.
-   Copyright (C) 2002-2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2002-2007, 2009-2012 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
diff --git a/gltests/test-stddef.c b/gltests/test-stddef.c
index c929af8..d7237b3 100644
--- a/gltests/test-stddef.c
+++ b/gltests/test-stddef.c
@@ -1,5 +1,5 @@
 /* Test of <stddef.h> substitute.
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 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
diff --git a/gltests/test-stdint.c b/gltests/test-stdint.c
index f606cc3..23b2b28 100644
--- a/gltests/test-stdint.c
+++ b/gltests/test-stdint.c
@@ -1,5 +1,5 @@
 /* Test of <stdint.h> substitute.
-   Copyright (C) 2006-2011 Free Software Foundation, Inc.
+   Copyright (C) 2006-2012 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
@@ -21,8 +21,6 @@
 /* Whether to enable pedantic checks. */
 #define DO_PEDANTIC 0
 
-#define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */
-#define __STDC_CONSTANT_MACROS 1 /* likewise */
 #include <stdint.h>
 
 #include "verify.h"
diff --git a/gltests/test-stdio.c b/gltests/test-stdio.c
index 7e7a206..7bd67c2 100644
--- a/gltests/test-stdio.c
+++ b/gltests/test-stdio.c
@@ -1,5 +1,5 @@
 /* Test of <stdio.h> substitute.
-   Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2012 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
diff --git a/gltests/test-stdlib.c b/gltests/test-stdlib.c
index 210aab4..7eeb410 100644
--- a/gltests/test-stdlib.c
+++ b/gltests/test-stdlib.c
@@ -1,5 +1,5 @@
 /* Test of <stdlib.h> substitute.
-   Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2012 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
diff --git a/gltests/test-strerror.c b/gltests/test-strerror.c
index 3ffb12e..14673f2 100644
--- a/gltests/test-strerror.c
+++ b/gltests/test-strerror.c
@@ -1,5 +1,5 @@
 /* Test of strerror() function.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
@@ -64,7 +64,7 @@ main (void)
   ASSERT (strstr (str, "ndefined") == NULL);
 
   /* POSIX requires strerror to produce a non-NULL result for all
-     inputs; as an extension, we also guarantee a non-empty reseult.
+     inputs; as an extension, we also guarantee a non-empty result.
      Reporting EINVAL is optional.  */
   errno = 0;
   str = strerror (-3);
diff --git a/gltests/test-strerror_r.c b/gltests/test-strerror_r.c
index 956c458..0539de2 100644
--- a/gltests/test-strerror_r.c
+++ b/gltests/test-strerror_r.c
@@ -1,5 +1,5 @@
 /* Test of strerror_r() function.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
diff --git a/gltests/test-striconv.c b/gltests/test-striconv.c
index 20cdd71..cd8d8ef 100644
--- a/gltests/test-striconv.c
+++ b/gltests/test-striconv.c
@@ -1,5 +1,5 @@
 /* Test of character set conversion.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
diff --git a/gltests/test-string.c b/gltests/test-string.c
index 54c49a9..56e5974 100644
--- a/gltests/test-string.c
+++ b/gltests/test-string.c
@@ -1,5 +1,5 @@
 /* Test of <string.h> substitute.
-   Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2012 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
diff --git a/gltests/test-symlink.c b/gltests/test-symlink.c
index 367e045..b3caac9 100644
--- a/gltests/test-symlink.c
+++ b/gltests/test-symlink.c
@@ -1,5 +1,5 @@
 /* Tests of symlink.
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 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
diff --git a/gltests/test-symlink.h b/gltests/test-symlink.h
index 4d93929..a7c4079 100644
--- a/gltests/test-symlink.h
+++ b/gltests/test-symlink.h
@@ -1,5 +1,5 @@
 /* Tests of symlink.
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 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
diff --git a/gltests/test-sys_ioctl.c b/gltests/test-sys_ioctl.c
index dd01b4a..725cabf 100644
--- a/gltests/test-sys_ioctl.c
+++ b/gltests/test-sys_ioctl.c
@@ -1,5 +1,5 @@
 /* Test of <sys/ioctl.h> substitute.
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 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
diff --git a/gltests/test-sys_select.c b/gltests/test-sys_select.c
index 0dfb8ef..78f66ed 100644
--- a/gltests/test-sys_select.c
+++ b/gltests/test-sys_select.c
@@ -1,5 +1,5 @@
 /* Test of <sys/select.h> substitute.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
@@ -20,8 +20,31 @@
 
 #include <sys/select.h>
 
+#include "signature.h"
+
+/* The following may be macros without underlying functions, so only
+   check signature if they are not macros.  */
+#ifndef FD_CLR
+SIGNATURE_CHECK (FD_CLR, void, (int, fd_set *));
+#endif
+#ifndef FD_ISSET
+SIGNATURE_CHECK (FD_ISSET, void, (int, fd_set *));
+#endif
+#ifndef FD_SET
+SIGNATURE_CHECK (FD_SET, int, (int, fd_set *));
+#endif
+#ifndef FD_ZERO
+SIGNATURE_CHECK (FD_ZERO, void, (fd_set *));
+#endif
+
 /* Check that the 'struct timeval' type is defined.  */
-struct timeval t1;
+struct timeval a;
+
+/* Check that &a.tv_sec is a 'time_t *', ignoring signedness issues.  */
+typedef int verify_tv_sec_type[sizeof (a.tv_sec) == sizeof (time_t) ? 1 : -1];
+
+/* Check that sigset_t is defined.  */
+sigset_t t2;
 
 int
 main (void)
diff --git a/gltests/test-sys_socket.c b/gltests/test-sys_socket.c
index a6e99d6..271815d 100644
--- a/gltests/test-sys_socket.c
+++ b/gltests/test-sys_socket.c
@@ -1,5 +1,5 @@
 /* Test of <sys/socket.h> substitute.
-   Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2012 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
@@ -30,6 +30,10 @@ int a[] = { SHUT_RD, SHUT_WR, SHUT_RDWR };
 /* Check that the 'socklen_t' type is defined.  */
 socklen_t t1;
 
+/* Check that the 'size_t' and 'ssize_t' types are defined.  */
+size_t t2;
+ssize_t t3;
+
 /* Check that 'struct iovec' is defined.  */
 struct iovec io;
 
diff --git a/gltests/test-sys_stat.c b/gltests/test-sys_stat.c
index cd07d86..0702e04 100644
--- a/gltests/test-sys_stat.c
+++ b/gltests/test-sys_stat.c
@@ -1,5 +1,5 @@
 /* Test of <sys/stat.h> substitute.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
@@ -26,11 +26,14 @@
 int a[] =
   {
     S_IFMT,
-    S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, S_IFREG,
-#ifdef S_IFLNK /* missing on mingw and djgpp */
+#ifdef S_IFBLK /* missing on MSVC */
+    S_IFBLK,
+#endif
+    S_IFCHR, S_IFDIR, S_IFIFO, S_IFREG,
+#ifdef S_IFLNK /* missing on native Windows and DJGPP */
     S_IFLNK,
 #endif
-#ifdef S_IFSOCK /* missing on mingw and djgpp */
+#ifdef S_IFSOCK /* missing on native Windows and DJGPP */
     S_IFSOCK,
 #endif
     S_IRWXU, S_IRUSR, S_IWUSR, S_IXUSR,
@@ -61,7 +64,9 @@ verify (S_IRWXU == (S_IRUSR | S_IWUSR | S_IXUSR));
 verify (S_IRWXG == (S_IRGRP | S_IWGRP | S_IXGRP));
 verify (S_IRWXO == (S_IROTH | S_IWOTH | S_IXOTH));
 
+#ifdef S_IFBLK
 verify (S_ISBLK (S_IFBLK));
+#endif
 verify (!S_ISBLK (S_IFCHR));
 verify (!S_ISBLK (S_IFDIR));
 verify (!S_ISBLK (S_IFIFO));
@@ -73,7 +78,9 @@ verify (!S_ISBLK (S_IFLNK));
 verify (!S_ISBLK (S_IFSOCK));
 #endif
 
+#ifdef S_IFBLK
 verify (!S_ISCHR (S_IFBLK));
+#endif
 verify (S_ISCHR (S_IFCHR));
 verify (!S_ISCHR (S_IFDIR));
 verify (!S_ISCHR (S_IFIFO));
@@ -85,7 +92,9 @@ verify (!S_ISCHR (S_IFLNK));
 verify (!S_ISCHR (S_IFSOCK));
 #endif
 
+#ifdef S_IFBLK
 verify (!S_ISDIR (S_IFBLK));
+#endif
 verify (!S_ISDIR (S_IFCHR));
 verify (S_ISDIR (S_IFDIR));
 verify (!S_ISDIR (S_IFIFO));
@@ -97,7 +106,9 @@ verify (!S_ISDIR (S_IFLNK));
 verify (!S_ISDIR (S_IFSOCK));
 #endif
 
+#ifdef S_IFBLK
 verify (!S_ISFIFO (S_IFBLK));
+#endif
 verify (!S_ISFIFO (S_IFCHR));
 verify (!S_ISFIFO (S_IFDIR));
 verify (S_ISFIFO (S_IFIFO));
@@ -109,7 +120,9 @@ verify (!S_ISFIFO (S_IFLNK));
 verify (!S_ISFIFO (S_IFSOCK));
 #endif
 
+#ifdef S_IFBLK
 verify (!S_ISREG (S_IFBLK));
+#endif
 verify (!S_ISREG (S_IFCHR));
 verify (!S_ISREG (S_IFDIR));
 verify (!S_ISREG (S_IFIFO));
@@ -121,7 +134,9 @@ verify (!S_ISREG (S_IFLNK));
 verify (!S_ISREG (S_IFSOCK));
 #endif
 
+#ifdef S_IFBLK
 verify (!S_ISLNK (S_IFBLK));
+#endif
 verify (!S_ISLNK (S_IFCHR));
 verify (!S_ISLNK (S_IFDIR));
 verify (!S_ISLNK (S_IFIFO));
@@ -133,7 +148,9 @@ verify (S_ISLNK (S_IFLNK));
 verify (!S_ISLNK (S_IFSOCK));
 #endif
 
+#ifdef S_IFBLK
 verify (!S_ISSOCK (S_IFBLK));
+#endif
 verify (!S_ISSOCK (S_IFCHR));
 verify (!S_ISSOCK (S_IFDIR));
 verify (!S_ISSOCK (S_IFIFO));
@@ -145,7 +162,9 @@ verify (!S_ISSOCK (S_IFLNK));
 verify (S_ISSOCK (S_IFSOCK));
 #endif
 
+#ifdef S_IFBLK
 verify (!S_ISDOOR (S_IFBLK));
+#endif
 verify (!S_ISDOOR (S_IFCHR));
 verify (!S_ISDOOR (S_IFDIR));
 verify (!S_ISDOOR (S_IFIFO));
@@ -157,7 +176,9 @@ verify (!S_ISDOOR (S_IFLNK));
 verify (!S_ISDOOR (S_IFSOCK));
 #endif
 
+#ifdef S_IFBLK
 verify (!S_ISMPB (S_IFBLK));
+#endif
 verify (!S_ISMPB (S_IFCHR));
 verify (!S_ISMPB (S_IFDIR));
 verify (!S_ISMPB (S_IFIFO));
@@ -169,7 +190,9 @@ verify (!S_ISMPB (S_IFLNK));
 verify (!S_ISMPB (S_IFSOCK));
 #endif
 
+#ifdef S_IFBLK
 verify (!S_ISNAM (S_IFBLK));
+#endif
 verify (!S_ISNAM (S_IFCHR));
 verify (!S_ISNAM (S_IFDIR));
 verify (!S_ISNAM (S_IFIFO));
@@ -181,7 +204,9 @@ verify (!S_ISNAM (S_IFLNK));
 verify (!S_ISNAM (S_IFSOCK));
 #endif
 
+#ifdef S_IFBLK
 verify (!S_ISNWK (S_IFBLK));
+#endif
 verify (!S_ISNWK (S_IFCHR));
 verify (!S_ISNWK (S_IFDIR));
 verify (!S_ISNWK (S_IFIFO));
@@ -193,7 +218,9 @@ verify (!S_ISNWK (S_IFLNK));
 verify (!S_ISNWK (S_IFSOCK));
 #endif
 
+#ifdef S_IFBLK
 verify (!S_ISPORT (S_IFBLK));
+#endif
 verify (!S_ISPORT (S_IFCHR));
 verify (!S_ISPORT (S_IFDIR));
 verify (!S_ISPORT (S_IFIFO));
@@ -205,7 +232,9 @@ verify (!S_ISPORT (S_IFLNK));
 verify (!S_ISPORT (S_IFSOCK));
 #endif
 
+#ifdef S_IFBLK
 verify (!S_ISCTG (S_IFBLK));
+#endif
 verify (!S_ISCTG (S_IFCHR));
 verify (!S_ISCTG (S_IFDIR));
 verify (!S_ISCTG (S_IFIFO));
@@ -217,7 +246,9 @@ verify (!S_ISCTG (S_IFLNK));
 verify (!S_ISCTG (S_IFSOCK));
 #endif
 
+#ifdef S_IFBLK
 verify (!S_ISOFD (S_IFBLK));
+#endif
 verify (!S_ISOFD (S_IFCHR));
 verify (!S_ISOFD (S_IFDIR));
 verify (!S_ISOFD (S_IFIFO));
@@ -229,7 +260,9 @@ verify (!S_ISOFD (S_IFLNK));
 verify (!S_ISOFD (S_IFSOCK));
 #endif
 
+#ifdef S_IFBLK
 verify (!S_ISOFL (S_IFBLK));
+#endif
 verify (!S_ISOFL (S_IFCHR));
 verify (!S_ISOFL (S_IFDIR));
 verify (!S_ISOFL (S_IFIFO));
@@ -241,7 +274,9 @@ verify (!S_ISOFL (S_IFLNK));
 verify (!S_ISOFL (S_IFSOCK));
 #endif
 
+#ifdef S_IFBLK
 verify (!S_ISWHT (S_IFBLK));
+#endif
 verify (!S_ISWHT (S_IFCHR));
 verify (!S_ISWHT (S_IFDIR));
 verify (!S_ISWHT (S_IFIFO));
@@ -278,8 +313,10 @@ invalid UTIME macros
 
 /* Check the existence of some types.  */
 nlink_t t1;
+off_t t2;
+mode_t t3;
 
-struct timespec t2;
+struct timespec st;
 
 int
 main (void)
diff --git a/gltests/test-sys_time.c b/gltests/test-sys_time.c
index da64b85..44e21a2 100644
--- a/gltests/test-sys_time.c
+++ b/gltests/test-sys_time.c
@@ -1,5 +1,5 @@
 /* Test of <sys/time.h> substitute.
-   Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2012 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
@@ -20,8 +20,12 @@
 
 #include <sys/time.h>
 
+/* Check that the 'struct timeval' type is defined.  */
 struct timeval a;
 
+/* Check that &a.tv_sec is a 'time_t *', ignoring signedness issues.  */
+typedef int verify_tv_sec_type[sizeof (a.tv_sec) == sizeof (time_t) ? 1 : -1];
+
 int
 main (void)
 {
diff --git a/gltests/test-sys_types.c b/gltests/test-sys_types.c
new file mode 100644
index 0000000..c2af992
--- /dev/null
+++ b/gltests/test-sys_types.c
@@ -0,0 +1,34 @@
+/* Test of <sys/types.h> substitute.
+   Copyright (C) 2011-2012 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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <address@hidden>, 2011.  */
+
+#include <config.h>
+
+#include <sys/types.h>
+
+/* Check that the types are all defined.  */
+pid_t t1;
+size_t t2;
+ssize_t t3;
+off_t t4;
+mode_t t5;
+
+int
+main (void)
+{
+  return 0;
+}
diff --git a/gltests/test-sys_uio.c b/gltests/test-sys_uio.c
index 7855a6b..ffb46ce 100644
--- a/gltests/test-sys_uio.c
+++ b/gltests/test-sys_uio.c
@@ -1,5 +1,5 @@
 /* Test of <sys/uio.h> substitute.
-   Copyright (C) 2011 Free Software Foundation, Inc.
+   Copyright (C) 2011-2012 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
diff --git a/gltests/test-sys_wait.h b/gltests/test-sys_wait.h
index 3c9b322..d3726df 100644
--- a/gltests/test-sys_wait.h
+++ b/gltests/test-sys_wait.h
@@ -1,5 +1,5 @@
 /* Test of macros shared between <sys/wait.h> and <stdlib.h>.
-   Copyright (C) 2010-2011 Free Software Foundation, Inc.
+   Copyright (C) 2010-2012 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
diff --git a/gltests/test-thread_create.c b/gltests/test-thread_create.c
new file mode 100644
index 0000000..0f86771
--- /dev/null
+++ b/gltests/test-thread_create.c
@@ -0,0 +1,78 @@
+/* Test of gl_thread_create () macro.
+   Copyright (C) 2011-2012 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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <address@hidden>, 2011.  */
+
+#include <config.h>
+
+#include "glthread/thread.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include "macros.h"
+
+static gl_thread_t main_thread_before;
+static gl_thread_t main_thread_after;
+static gl_thread_t worker_thread;
+
+static int dummy;
+static volatile int work_done;
+
+static void *
+worker_thread_func (void *arg)
+{
+  work_done = 1;
+  return &dummy;
+}
+
+int
+main ()
+{
+  main_thread_before = gl_thread_self ();
+
+  if (glthread_create (&worker_thread, worker_thread_func, NULL) == 0)
+    {
+      void *ret;
+
+      /* Check that gl_thread_self () has the same value before than after the
+         first call to gl_thread_create ().  */
+      main_thread_after = gl_thread_self ();
+      ASSERT (memcmp (&main_thread_before, &main_thread_after,
+                      sizeof (gl_thread_t))
+              == 0);
+
+      gl_thread_join (worker_thread, &ret);
+
+      /* Check the return value of the thread.  */
+      ASSERT (ret == &dummy);
+
+      /* Check that worker_thread_func () has finished executing.  */
+      ASSERT (work_done);
+
+      return 0;
+    }
+  else
+    {
+#if USE_POSIX_THREADS || USE_SOLARIS_THREADS || USE_PTH_THREADS || 
USE_WINDOWS_THREADS
+      fputs ("glthread_create failed\n", stderr);
+      return 1;
+#else
+      fputs ("Skipping test: multithreading not enabled\n", stderr);
+      return 77;
+#endif
+    }
+}
diff --git a/gltests/test-thread_self.c b/gltests/test-thread_self.c
new file mode 100644
index 0000000..707f7fe
--- /dev/null
+++ b/gltests/test-thread_self.c
@@ -0,0 +1,34 @@
+/* Test of gl_thread_self () macro.
+   Copyright (C) 2011-2012 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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <address@hidden>, 2011.  */
+
+#include <config.h>
+
+#include "glthread/thread.h"
+
+gl_thread_t main_thread;
+
+int
+main ()
+{
+  /* Check that gl_thread_self () can be used with just $(LIBTHREAD), not
+     $(LIBMULTITHREAD), i.e. in libraries that are multithread-safe but don't
+     create threads themselves.  */
+  main_thread = gl_thread_self ();
+
+  return 0;
+}
diff --git a/gltests/test-time.c b/gltests/test-time.c
index 0c78f36..acf3d2d 100644
--- a/gltests/test-time.c
+++ b/gltests/test-time.c
@@ -1,5 +1,5 @@
 /* Test of <time.h> substitute.
-   Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2012 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,7 +22,13 @@
 
 #include "verify.h"
 
-struct timespec a;
+/* Check that the types are all defined.  */
+struct timespec t1;
+#if 0
+/* POSIX:2008 does not require pid_t in <time.h> unconditionally, and indeed
+   it's missing on MacOS X 10.5, FreeBSD 6.4, OpenBSD 4.9, mingw.  */
+pid_t t2;
+#endif
 
 /* Check that NULL can be passed through varargs as a pointer type,
    per POSIX 2008.  */
diff --git a/gltests/test-unistd.c b/gltests/test-unistd.c
index be1ae06..e53fd7a 100644
--- a/gltests/test-unistd.c
+++ b/gltests/test-unistd.c
@@ -1,5 +1,5 @@
 /* Test of <unistd.h> substitute.
-   Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2012 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
diff --git a/gltests/test-unsetenv.c b/gltests/test-unsetenv.c
index 4296f5c..fd588ad 100644
--- a/gltests/test-unsetenv.c
+++ b/gltests/test-unsetenv.c
@@ -1,5 +1,5 @@
 /* Tests of unsetenv.
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 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
diff --git a/gltests/test-vasnprintf.c b/gltests/test-vasnprintf.c
index 6b2a0ff..4e548b1 100644
--- a/gltests/test-vasnprintf.c
+++ b/gltests/test-vasnprintf.c
@@ -1,5 +1,5 @@
 /* Test of vasnprintf() and asnprintf() functions.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
diff --git a/gltests/test-vasprintf.c b/gltests/test-vasprintf.c
index 6882d18..4d7635b 100644
--- a/gltests/test-vasprintf.c
+++ b/gltests/test-vasprintf.c
@@ -1,5 +1,5 @@
 /* Test of vasprintf() and asprintf() functions.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
diff --git a/gltests/test-vc-list-files-cvs.sh 
b/gltests/test-vc-list-files-cvs.sh
index 531b269..68b0a0f 100755
--- a/gltests/test-vc-list-files-cvs.sh
+++ b/gltests/test-vc-list-files-cvs.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 # Unit tests for vc-list-files
-# Copyright (C) 2008-2011 Free Software Foundation, Inc.
+# Copyright (C) 2008-2012 Free Software Foundation, Inc.
 # This file is part of the GNUlib Library.
 #
 # This program is free software: you can redistribute it and/or modify
@@ -36,7 +36,6 @@ for i in with-cvsu without; do
   ok=0
   mkdir $tmpdir && cd $tmpdir &&
     # without cvs, skip the test
-    # The double use of 'exit' is needed for the reference to $? inside the 
trap.
     { ( cvs -Q -d "$repo" init ) > /dev/null 2>&1 \
       || skip_ "cvs not found in PATH"; } &&
     mkdir w && cd w &&
diff --git a/gltests/test-vc-list-files-git.sh 
b/gltests/test-vc-list-files-git.sh
index 523b2a9..1ea6d89 100755
--- a/gltests/test-vc-list-files-git.sh
+++ b/gltests/test-vc-list-files-git.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 # Unit tests for vc-list-files
-# Copyright (C) 2008-2011 Free Software Foundation, Inc.
+# Copyright (C) 2008-2012 Free Software Foundation, Inc.
 # This file is part of the GNUlib Library.
 #
 # This program is free software: you can redistribute it and/or modify
diff --git a/gltests/test-verify.c b/gltests/test-verify.c
index 454f4f4..5ab9c58 100644
--- a/gltests/test-verify.c
+++ b/gltests/test-verify.c
@@ -1,6 +1,6 @@
 /* Test the "verify" module.
 
-   Copyright (C) 2005, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2009-2012 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
diff --git a/gltests/test-version-etc.c b/gltests/test-version-etc.c
index 00a5d7c..36ced60 100644
--- a/gltests/test-version-etc.c
+++ b/gltests/test-version-etc.c
@@ -1,5 +1,5 @@
 /* Test suite for version-etc.
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 Free Software Foundation, Inc.
    This file is part of the GNUlib Library.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/gltests/test-version-etc.sh b/gltests/test-version-etc.sh
index c1ed827..945383b 100755
--- a/gltests/test-version-etc.sh
+++ b/gltests/test-version-etc.sh
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Test suite for version-etc.
-# Copyright (C) 2009-2011 Free Software Foundation, Inc.
+# Copyright (C) 2009-2012 Free Software Foundation, Inc.
 # This file is part of the GNUlib Library.
 #
 # This program is free software: you can redistribute it and/or modify
diff --git a/gltests/test-wchar.c b/gltests/test-wchar.c
index 2d3bad7..0d72005 100644
--- a/gltests/test-wchar.c
+++ b/gltests/test-wchar.c
@@ -1,5 +1,5 @@
 /* Test of <wchar.h> substitute.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
diff --git a/gltests/test-wcrtomb-w32.c b/gltests/test-wcrtomb-w32.c
index 0b09498..9342f78 100644
--- a/gltests/test-wcrtomb-w32.c
+++ b/gltests/test-wcrtomb-w32.c
@@ -1,5 +1,5 @@
 /* Test of conversion of wide character to multibyte character.
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
diff --git a/gltests/test-wcrtomb.c b/gltests/test-wcrtomb.c
index a50817f..99e427d 100644
--- a/gltests/test-wcrtomb.c
+++ b/gltests/test-wcrtomb.c
@@ -1,5 +1,5 @@
 /* Test of conversion of wide character to multibyte character.
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
diff --git a/gltests/test-wctype-h.c b/gltests/test-wctype-h.c
index aed3b77..467f05b 100644
--- a/gltests/test-wctype-h.c
+++ b/gltests/test-wctype-h.c
@@ -1,5 +1,5 @@
 /* Test of <wctype.h> substitute.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007-2012 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
diff --git a/gltests/test-xalloc-die.c b/gltests/test-xalloc-die.c
index d33e671..7b5aa69 100644
--- a/gltests/test-xalloc-die.c
+++ b/gltests/test-xalloc-die.c
@@ -1,5 +1,5 @@
 /* Test of xalloc_die() function.
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 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
diff --git a/gltests/test-xalloc-die.sh b/gltests/test-xalloc-die.sh
index 399d249..233fd96 100755
--- a/gltests/test-xalloc-die.sh
+++ b/gltests/test-xalloc-die.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 # Test suite for xalloc_die.
-# Copyright (C) 2009-2011 Free Software Foundation, Inc.
+# Copyright (C) 2009-2012 Free Software Foundation, Inc.
 # This file is part of the GNUlib Library.
 #
 # This program is free software: you can redistribute it and/or modify
diff --git a/gltests/time.in.h b/gltests/time.in.h
deleted file mode 100644
index 1fbebf4..0000000
--- a/gltests/time.in.h
+++ /dev/null
@@ -1,249 +0,0 @@
-/* A more-standard <time.h>.
-
-   Copyright (C) 2007-2011 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
-   the Free Software Foundation; either version 3, 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 General Public License for more details.
-
-   You should have received a copy of the GNU 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.  */
-
-#if __GNUC__ >= 3
address@hidden@
-#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
-   symbols.  Also, Solaris 8 <time.h> eventually includes itself
-   recursively; if that is happening, just include the system <time.h>
-   without adding our own declarations.  */
-#if (defined __need_time_t || defined __need_clock_t \
-     || defined __need_timespec \
-     || defined address@hidden@_TIME_H)
-
-# @INCLUDE_NEXT@ @NEXT_TIME_H@
-
-#else
-
-# define address@hidden@_TIME_H
-
-# @INCLUDE_NEXT@ @NEXT_TIME_H@
-
-/* NetBSD 5.0 mis-defines NULL.  */
-# include <stddef.h>
-
-/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
-
-/* The definition of _GL_ARG_NONNULL is copied here.  */
-
-/* The definition of _GL_WARN_ON_USE is copied here.  */
-
-/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3).
-   Or they define it with the wrong member names or define it in <sys/time.h>
-   (e.g., FreeBSD circa 1997).  Stock Mingw does not define it, but the
-   pthreads-win32 library defines it in <pthread.h>.  */
-# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
-#  if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
-#   include <sys/time.h>
-#  elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
-#   include <pthread.h>
-/* The pthreads-win32 <pthread.h> also defines a couple of broken macros.  */
-#   undef asctime_r
-#   undef ctime_r
-#   undef gmtime_r
-#   undef localtime_r
-#   undef rand_r
-#   undef strtok_r
-#  else
-
-#   ifdef __cplusplus
-extern "C" {
-#   endif
-
-#   if !GNULIB_defined_struct_timespec
-#    undef timespec
-#    define timespec rpl_timespec
-struct timespec
-{
-  time_t tv_sec;
-  long int tv_nsec;
-};
-#    define GNULIB_defined_struct_timespec 1
-#   endif
-
-#   ifdef __cplusplus
-}
-#   endif
-
-#  endif
-# endif
-
-# if !GNULIB_defined_struct_time_t_must_be_integral
-/* 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;
-};
-#  define GNULIB_defined_struct_time_t_must_be_integral 1
-# endif
-
-/* 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>.  */
-# if @GNULIB_NANOSLEEP@
-#  if @REPLACE_NANOSLEEP@
-#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#    define nanosleep rpl_nanosleep
-#   endif
-_GL_FUNCDECL_RPL (nanosleep, int,
-                  (struct timespec const *__rqtp, struct timespec *__rmtp)
-                  _GL_ARG_NONNULL ((1)));
-_GL_CXXALIAS_RPL (nanosleep, int,
-                  (struct timespec const *__rqtp, struct timespec *__rmtp));
-#  else
-#   if ! @HAVE_NANOSLEEP@
-_GL_FUNCDECL_SYS (nanosleep, int,
-                  (struct timespec const *__rqtp, struct timespec *__rmtp)
-                  _GL_ARG_NONNULL ((1)));
-#   endif
-_GL_CXXALIAS_SYS (nanosleep, int,
-                  (struct timespec const *__rqtp, struct timespec *__rmtp));
-#  endif
-_GL_CXXALIASWARN (nanosleep);
-# endif
-
-/* Return the 'time_t' representation of TP and normalize TP.  */
-# if @GNULIB_MKTIME@
-#  if @REPLACE_MKTIME@
-#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#    define mktime rpl_mktime
-#   endif
-_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
-_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
-#  else
-_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
-#  endif
-_GL_CXXALIASWARN (mktime);
-# endif
-
-/* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
-   <http://www.opengroup.org/susv3xsh/localtime_r.html> and
-   <http://www.opengroup.org/susv3xsh/gmtime_r.html>.  */
-# if @GNULIB_TIME_R@
-#  if @REPLACE_LOCALTIME_R@
-#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#    undef localtime_r
-#    define localtime_r rpl_localtime_r
-#   endif
-_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
-                                             struct tm *restrict __result)
-                                            _GL_ARG_NONNULL ((1, 2)));
-_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
-                                             struct tm *restrict __result));
-#  else
-#   if ! @HAVE_DECL_LOCALTIME_R@
-_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
-                                             struct tm *restrict __result)
-                                            _GL_ARG_NONNULL ((1, 2)));
-#   endif
-_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
-                                             struct tm *restrict __result));
-#  endif
-#  if @HAVE_DECL_LOCALTIME_R@
-_GL_CXXALIASWARN (localtime_r);
-#  endif
-#  if @REPLACE_LOCALTIME_R@
-#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#    undef gmtime_r
-#    define gmtime_r rpl_gmtime_r
-#   endif
-_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
-                                          struct tm *restrict __result)
-                                         _GL_ARG_NONNULL ((1, 2)));
-_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
-                                          struct tm *restrict __result));
-#  else
-#   if ! @HAVE_DECL_LOCALTIME_R@
-_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
-                                          struct tm *restrict __result)
-                                         _GL_ARG_NONNULL ((1, 2)));
-#   endif
-_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
-                                          struct tm *restrict __result));
-#  endif
-#  if @HAVE_DECL_LOCALTIME_R@
-_GL_CXXALIASWARN (gmtime_r);
-#  endif
-# endif
-
-/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
-   the resulting broken-down time into TM.  See
-   <http://www.opengroup.org/susv3xsh/strptime.html>.  */
-# if @GNULIB_STRPTIME@
-#  if ! @HAVE_STRPTIME@
-_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
-                                     char const *restrict __format,
-                                     struct tm *restrict __tm)
-                                    _GL_ARG_NONNULL ((1, 2, 3)));
-#  endif
-_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
-                                     char const *restrict __format,
-                                     struct tm *restrict __tm));
-_GL_CXXALIASWARN (strptime);
-# endif
-
-/* Convert TM to a time_t value, assuming UTC.  */
-# if @GNULIB_TIMEGM@
-#  if @REPLACE_TIMEGM@
-#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#    undef timegm
-#    define timegm rpl_timegm
-#   endif
-_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
-_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
-#  else
-#   if ! @HAVE_TIMEGM@
-_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
-#   endif
-_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
-#  endif
-_GL_CXXALIASWARN (timegm);
-# endif
-
-/* Encourage applications to avoid unsafe functions that can overrun
-   buffers when given outlandish struct tm values.  Portable
-   applications should use strftime (or even sprintf) instead.  */
-# if defined GNULIB_POSIXCHECK
-#  undef asctime
-_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
-                 "better use strftime (or even sprintf) instead");
-# endif
-# if defined GNULIB_POSIXCHECK
-#  undef asctime_r
-_GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - "
-                 "better use strftime (or even sprintf) instead");
-# endif
-# if defined GNULIB_POSIXCHECK
-#  undef ctime
-_GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - "
-                 "better use strftime (or even sprintf) instead");
-# endif
-# if defined GNULIB_POSIXCHECK
-#  undef ctime_r
-_GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - "
-                 "better use strftime (or even sprintf) instead");
-# endif
-
-#endif
diff --git a/gltests/unistr/test-u8-mbtoucr.c b/gltests/unistr/test-u8-mbtoucr.c
index 092af56..9e38885 100644
--- a/gltests/unistr/test-u8-mbtoucr.c
+++ b/gltests/unistr/test-u8-mbtoucr.c
@@ -1,5 +1,5 @@
 /* Test of u8_mbtoucr() function.
-   Copyright (C) 2010-2011 Free Software Foundation, Inc.
+   Copyright (C) 2010-2012 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
diff --git a/gltests/unistr/test-u8-uctomb.c b/gltests/unistr/test-u8-uctomb.c
index 01e6b4e..988808e 100644
--- a/gltests/unistr/test-u8-uctomb.c
+++ b/gltests/unistr/test-u8-uctomb.c
@@ -1,5 +1,5 @@
 /* Test of u8_uctomb() function.
-   Copyright (C) 2010-2011 Free Software Foundation, Inc.
+   Copyright (C) 2010-2012 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
diff --git a/gltests/unsetenv.c b/gltests/unsetenv.c
index 16b50d1..ddbe9a4 100644
--- a/gltests/unsetenv.c
+++ b/gltests/unsetenv.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1995-2002, 2005-2011 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1995-2002, 2005-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    This program is free software: you can redistribute it and/or modify
@@ -36,7 +36,7 @@
 #endif
 
 #if _LIBC
-/* This lock protects against simultaneous modifications of `environ'.  */
+/* This lock protects against simultaneous modifications of 'environ'.  */
 # include <bits/libc-lock.h>
 __libc_lock_define_initialized (static, envlock)
 # define LOCK   __libc_lock_lock (envlock)
diff --git a/gltests/version-etc-fsf.c b/gltests/version-etc-fsf.c
index c821583..c452f40 100644
--- a/gltests/version-etc-fsf.c
+++ b/gltests/version-etc-fsf.c
@@ -1,5 +1,5 @@
 /* Variable with FSF copyright information, for version-etc.
-   Copyright (C) 1999-2006, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 1999-2006, 2009-2012 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
diff --git a/gltests/w32sock.h b/gltests/w32sock.h
index 651a76d..ef0b593 100644
--- a/gltests/w32sock.h
+++ b/gltests/w32sock.h
@@ -1,6 +1,6 @@
-/* w32sock.h --- internal auxilliary functions for Windows socket functions
+/* w32sock.h --- internal auxiliary functions for Windows socket functions
 
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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,11 +22,14 @@
 /* Get O_RDWR and O_BINARY.  */
 #include <fcntl.h>
 
-/* Get _get_osfhandle() and _open_osfhandle().  */
+/* Get _open_osfhandle().  */
 #include <io.h>
 
+/* Get _get_osfhandle().  */
+#include "msvc-nothrow.h"
+
 #define FD_TO_SOCKET(fd)   ((SOCKET) _get_osfhandle ((fd)))
-#define SOCKET_TO_FD(fh)   (_open_osfhandle ((long) (fh), O_RDWR | O_BINARY))
+#define SOCKET_TO_FD(fh)   (_open_osfhandle ((intptr_t) (fh), O_RDWR | 
O_BINARY))
 
 static inline void
 set_winsock_errno (void)
@@ -45,15 +48,87 @@ set_winsock_errno (void)
     case WSA_INVALID_PARAMETER:
       errno = EINVAL;
       break;
-    case WSAEWOULDBLOCK:
-      errno = EWOULDBLOCK;
-      break;
     case WSAENAMETOOLONG:
       errno = ENAMETOOLONG;
       break;
     case WSAENOTEMPTY:
       errno = ENOTEMPTY;
       break;
+    case WSAEWOULDBLOCK:
+      errno = EWOULDBLOCK;
+      break;
+    case WSAEINPROGRESS:
+      errno = EINPROGRESS;
+      break;
+    case WSAEALREADY:
+      errno = EALREADY;
+      break;
+    case WSAENOTSOCK:
+      errno = ENOTSOCK;
+      break;
+    case WSAEDESTADDRREQ:
+      errno = EDESTADDRREQ;
+      break;
+    case WSAEMSGSIZE:
+      errno = EMSGSIZE;
+      break;
+    case WSAEPROTOTYPE:
+      errno = EPROTOTYPE;
+      break;
+    case WSAENOPROTOOPT:
+      errno = ENOPROTOOPT;
+      break;
+    case WSAEPROTONOSUPPORT:
+      errno = EPROTONOSUPPORT;
+      break;
+    case WSAEOPNOTSUPP:
+      errno = EOPNOTSUPP;
+      break;
+    case WSAEAFNOSUPPORT:
+      errno = EAFNOSUPPORT;
+      break;
+    case WSAEADDRINUSE:
+      errno = EADDRINUSE;
+      break;
+    case WSAEADDRNOTAVAIL:
+      errno = EADDRNOTAVAIL;
+      break;
+    case WSAENETDOWN:
+      errno = ENETDOWN;
+      break;
+    case WSAENETUNREACH:
+      errno = ENETUNREACH;
+      break;
+    case WSAENETRESET:
+      errno = ENETRESET;
+      break;
+    case WSAECONNABORTED:
+      errno = ECONNABORTED;
+      break;
+    case WSAECONNRESET:
+      errno = ECONNRESET;
+      break;
+    case WSAENOBUFS:
+      errno = ENOBUFS;
+      break;
+    case WSAEISCONN:
+      errno = EISCONN;
+      break;
+    case WSAENOTCONN:
+      errno = ENOTCONN;
+      break;
+    case WSAETIMEDOUT:
+      errno = ETIMEDOUT;
+      break;
+    case WSAECONNREFUSED:
+      errno = ECONNREFUSED;
+      break;
+    case WSAELOOP:
+      errno = ELOOP;
+      break;
+    case WSAEHOSTUNREACH:
+      errno = EHOSTUNREACH;
+      break;
     default:
       errno = (err > 10000 && err < 10025) ? err - 10000 : err;
       break;
diff --git a/gltests/wcrtomb.c b/gltests/wcrtomb.c
index 6632589..9e6494e 100644
--- a/gltests/wcrtomb.c
+++ b/gltests/wcrtomb.c
@@ -1,5 +1,5 @@
 /* Convert wide character to multibyte character.
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2008.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/gltests/wctob.c b/gltests/wctob.c
index cc26afc..0885c1b 100644
--- a/gltests/wctob.c
+++ b/gltests/wctob.c
@@ -1,5 +1,5 @@
 /* Convert wide character to unibyte character.
-   Copyright (C) 2008, 2010-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2010-2012 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2008.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/gltests/wctomb-impl.h b/gltests/wctomb-impl.h
index 4e95de6..68264cf 100644
--- a/gltests/wctomb-impl.h
+++ b/gltests/wctomb-impl.h
@@ -1,5 +1,5 @@
 /* Convert wide character to multibyte character.
-   Copyright (C) 2011 Free Software Foundation, Inc.
+   Copyright (C) 2011-2012 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2011.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/gltests/wctomb.c b/gltests/wctomb.c
index 889a3c6..736a7c7 100644
--- a/gltests/wctomb.c
+++ b/gltests/wctomb.c
@@ -1,5 +1,5 @@
 /* Convert wide character to multibyte character.
-   Copyright (C) 2011 Free Software Foundation, Inc.
+   Copyright (C) 2011-2012 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2011.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/gltests/zerosize-ptr.h b/gltests/zerosize-ptr.h
index beeb3da..9c060e7 100644
--- a/gltests/zerosize-ptr.h
+++ b/gltests/zerosize-ptr.h
@@ -1,5 +1,5 @@
 /* Return a pointer to a zero-size object in memory.
-   Copyright (C) 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 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
diff --git a/lib/GNUmakefile b/lib/GNUmakefile
index 6e00ec8..d0fd3e8 100644
--- a/lib/GNUmakefile
+++ b/lib/GNUmakefile
@@ -1,11 +1,11 @@
-# Having a separate GNUmakefile lets me `include' the dynamically
+# Having a separate GNUmakefile lets me 'include' the dynamically
 # generated rules created via cfg.mk (package-local configuration)
 # as well as maint.mk (generic maintainer rules).
 # This makefile is used only if you run GNU Make.
 # It is necessary if you want to build targets usually of interest
 # only to the maintainer.
 
-# Copyright (C) 2001, 2003, 2006-2011 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2003, 2006-2012 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
@@ -45,12 +45,13 @@ include Makefile
 
 # Some projects override e.g., _autoreconf here.
 -include $(srcdir)/cfg.mk
-include $(srcdir)/maint.mk
 
 # Allow cfg.mk to override these.
 _build-aux ?= build-aux
 _autoreconf ?= autoreconf -v
 
+include $(srcdir)/maint.mk
+
 # Ensure that $(VERSION) is up to date for dist-related targets, but not
 # for others: rerunning autoreconf and recompiling everything isn't cheap.
 _have-git-version-gen := \
@@ -100,6 +101,11 @@ srcdir = .
 
 # The package can override .DEFAULT_GOAL to run actions like autoreconf.
 -include ./cfg.mk
+
+# Allow cfg.mk to override these.
+_build-aux ?= build-aux
+_autoreconf ?= autoreconf -v
+
 include ./maint.mk
 
 ifeq ($(.DEFAULT_GOAL),abort-due-to-no-makefile)
@@ -108,7 +114,7 @@ endif
 
 abort-due-to-no-makefile:
        @echo There seems to be no Makefile in this directory.   1>&2
-       @echo "You must run ./configure before running \`make'." 1>&2
+       @echo "You must run ./configure before running 'make'." 1>&2
        @exit 1
 
 endif
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 0702d7d..10ab390 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,4 +1,4 @@
-# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Simon 
Josefsson
+# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 
Simon Josefsson
 #
 # This file is part of GNU SASL Library.
 #
@@ -66,6 +66,10 @@ if SAML20
 SUBDIRS += saml20
 endif
 
+if OPENID20
+SUBDIRS += openid20
+endif
+
 if NTLM
 SUBDIRS += ntlm
 endif
diff --git a/lib/NEWS b/lib/NEWS
index 1273846..c33e469 100644
--- a/lib/NEWS
+++ b/lib/NEWS
@@ -4,6 +4,9 @@ See the end for copying conditions.
 
 * Version 1.7.1 (unreleased) [alpha]
 
+** libgsasl: Implement OPENID20 mechanism for OpenID authentication.
+Following draft-ietf-kitten-sasl-openid-03.
+
 ** libgsasl.pc: Add a Libs.private.
 Reported by Volker Grabsch <address@hidden>.
 
diff --git a/lib/README b/lib/README
index 5f67d6a..4210fa3 100644
--- a/lib/README
+++ b/lib/README
@@ -34,6 +34,8 @@ Currently there is some support for the following mechanisms:
   - LOGIN (non-standard)
   - NTLM (non-standard, client only, requires Libntlm)
   - KERBEROS_V5 (experimental, requires Shishi)
+  - SAML20 (draft-ietf-kitten-sasl-saml-01)
+  - OPENID20 (draft-ietf-kitten-sasl-openid-03)
 
 The library should be portable to all C89 platforms.
 
diff --git a/lib/build-aux/arg-nonnull.h b/lib/build-aux/arg-nonnull.h
deleted file mode 100644
index 6c2f1e8..0000000
--- a/lib/build-aux/arg-nonnull.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* A C macro for declaring that specific arguments must not be NULL.
-   Copyright (C) 2009-2011 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 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
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-/* _GL_ARG