Index: trunk/src/libctests/glibc/Makefile
===================================================================
--- trunk/src/libctests/glibc/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/Makefile	(revision 2036)
@@ -0,0 +1,382 @@
+# Copyright (C) 1991-2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Master Makefile for the GNU C library
+#
+ifneq (,)
+This makefile requires GNU Make.
+endif
+
+include Makeconfig
+
+
+# This is the default target; it makes everything except the tests.
+.PHONY: all
+all: lib others
+
+
+ifneq ($(AUTOCONF),no)
+
+ifeq ($(with-cvs),yes)
+define autoconf-it-cvs
+test ! -d CVS || cvs $(CVSOPTS) commit -m'Regenerated: autoconf $(ACFLAGS) $<' $@
+endef
+else
+autoconf-it-cvs =
+endif
+
+define autoconf-it
+@-rm -f $@.new
+$(AUTOCONF) $(ACFLAGS) $< > $@.new
+chmod a-w,a+x $@.new
+mv -f $@.new $@
+$(autoconf-it-cvs)
+endef
+
+configure: configure.in aclocal.m4; $(autoconf-it)
+%/configure: %/configure.in aclocal.m4; $(autoconf-it)
+
+endif # $(AUTOCONF) = no
+
+
+# We don't want to run anything here in parallel.
+.NOTPARALLEL:
+
+# These are the targets that are made by making them in each subdirectory.
++subdir_targets	:= subdir_lib objects objs others subdir_mostlyclean	\
+		   subdir_clean subdir_distclean subdir_realclean	\
+		   tests xtests subdir_lint.out				\
+		   subdir_update-abi subdir_check-abi 			\
+		   subdir_echo-headers 					\
+		   subdir_install					\
+		   subdir_objs subdir_stubs subdir_testclean		\
+		   $(addprefix install-, no-libc.a bin lib data headers others)
+
+
+headers := limits.h values.h features.h gnu-versions.h bits/libc-lock.h \
+	   bits/xopen_lim.h gnu/libc-version.h
+
+echo-headers: subdir_echo-headers
+
+# The headers are in the include directory.
+subdir-dirs = include
+vpath %.h $(subdir-dirs)
+
+# What to install.
+install-others = $(inst_includedir)/gnu/stubs.h
+install-bin-script =
+
+ifeq (yes,$(build-shared))
+headers += gnu/lib-names.h
+endif
+
+include Makerules
+
+ifeq ($(build-programs),yes)
+others: $(addprefix $(objpfx),$(install-bin-script))
+endif
+
+# Install from subdirectories too.
+install: subdir_install
+
+# Explicit dependency so that `make install-headers' works
+install-headers: install-headers-nosubdir
+
+# Make sure that the dynamic linker is installed before libc.
+$(inst_slibdir)/libc-$(version).so: elf/ldso_install
+
+.PHONY: elf/ldso_install
+elf/ldso_install:
+	$(MAKE) -C $(@D) $(@F)
+
+# Create links for shared libraries using the `ldconfig' program if possible.
+# Ignore the error if we cannot update /etc/ld.so.cache.
+ifeq (no,$(cross-compiling))
+ifeq (yes,$(build-shared))
+install: install-symbolic-link
+.PHONY: install-symbolic-link
+install-symbolic-link: subdir_install
+	$(symbolic-link-prog) $(symbolic-link-list)
+	rm -f $(symbolic-link-list)
+
+install:
+	-test ! -x $(common-objpfx)elf/ldconfig || LC_ALL=C LANGUAGE=C \
+	  $(common-objpfx)elf/ldconfig $(addprefix -r ,$(install_root)) \
+				       $(slibdir) $(libdir)
+ifneq (no,$(PERL))
+ifeq (/usr,$(prefix))
+ifeq (,$(install_root))
+	CC="$(CC)" $(PERL) scripts/test-installation.pl $(common-objpfx)
+endif
+endif
+endif
+endif
+endif
+
+# Build subdirectory lib objects.
+lib-noranlib: subdir_lib
+
+ifeq (yes,$(build-shared))
+# Build the shared object from the PIC object library.
+lib: $(common-objpfx)libc.so
+endif
+
+
+# This is a handy script for running any dynamically linked program against
+# the current libc build for testing.
+$(common-objpfx)testrun.sh: $(common-objpfx)config.make \
+			    $(..)Makeconfig $(..)Makefile
+	(echo '#!/bin/sh'; \
+	 echo "GCONV_PATH='$(common-objpfx)iconvdata' \\"; \
+	 echo 'exec $(run-program-prefix) $${1+"$$@"}'; \
+	) > $@T
+	chmod a+x $@T
+	mv -f $@T $@
+postclean-generated += testrun.sh
+
+others: $(common-objpfx)testrun.sh
+
+
+# Makerules creates a file `stubs' in each subdirectory, which
+# contains `#define __stub_FUNCTION' for each function defined in that
+# directory which is a stub.
+# Here we paste all of these together into <gnu/stubs.h>.
+
+subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)$(dir)/stubs)
+
+ifeq ($(biarch),no)
+installed-stubs = $(inst_includedir)/gnu/stubs.h
+else
+installed-stubs = $(inst_includedir)/gnu/stubs-$(biarch).h
+
+$(inst_includedir)/gnu/stubs.h: include/stubs-biarch.h $(+force)
+	$(INSTALL_DATA) $< $@
+
+install-others-nosubdir: $(installed-stubs)
+endif
+
+
+# Since stubs.h is never needed when building the library, we simplify the
+# hairy installation process by producing it in place only as the last part
+# of the top-level `make install'.  It depends on subdir_install, which
+# iterates over all the subdirs; subdir_install in each subdir depends on
+# the subdir's stubs file.  Having more direct dependencies would result in
+# extra iterations over the list for subdirs and many recursive makes.
+$(installed-stubs): include/stubs-prologue.h subdir_install
+	$(make-target-directory)
+	@rm -f $(objpfx)stubs.h
+	(sed '/^@/d' $<; LC_ALL=C sort $(subdir-stubs)) > $(objpfx)stubs.h
+	if test -r $@ && cmp -s $(objpfx)stubs.h $@; \
+	then echo 'stubs.h unchanged'; \
+	else $(INSTALL_DATA) $(objpfx)stubs.h $@; fi
+	rm -f $(objpfx)stubs.h
+
+
+# This makes the Info or DVI file of the documentation from the Texinfo source.
+.PHONY: info dvi pdf html
+info dvi pdf html:
+	$(MAKE) $(PARALLELMFLAGS) -C manual $@
+
+
+# This makes all the subdirectory targets.
+
+# For each target, make it depend on DIR/target for each subdirectory DIR.
+$(+subdir_targets): %: $(addsuffix /%,$(subdirs))
+
+# Compute a list of all those targets.
+all-subdirs-targets := $(foreach dir,$(subdirs),\
+				 $(addprefix $(dir)/,$(+subdir_targets)))
+
+# The action for each of those is to cd into the directory and make the
+# target there.
+$(all-subdirs-targets):
+	$(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
+
+.PHONY: $(+subdir_targets) $(all-subdirs-targets)
+
+
+# Targets to clean things up to various degrees.
+
+.PHONY: clean realclean distclean distclean-1 parent-clean parent-mostlyclean \
+	tests-clean
+
+# Subroutines of all cleaning targets.
+parent-mostlyclean: common-mostlyclean # common-mostlyclean is in Makerules.
+	-rm -f $(foreach o,$(object-suffixes-for-libc),\
+		   $(common-objpfx)$(patsubst %,$(libtype$o),c)) \
+	       $(addprefix $(objpfx),$(install-lib))
+parent-clean: parent-mostlyclean common-clean
+
+postclean = $(addprefix $(common-objpfx),$(postclean-generated)) \
+	    $(addprefix $(objpfx),sysd-dirs sysd-rules) \
+	    $(addprefix $(objpfx),sysd-sorted soversions.mk soversions.i)
+
+clean: parent-clean
+# This is done this way rather than having `subdir_clean' be a
+# dependency of this target so that libc.a will be removed before the
+# subdirectories are dealt with and so they won't try to remove object
+# files from it when it's going to be removed anyway.
+	@$(MAKE) subdir_clean no_deps=t
+	-rm -f $(postclean)
+mostlyclean: parent-mostlyclean
+	@$(MAKE) subdir_mostlyclean no_deps=t
+	-rm -f $(postclean)
+
+tests-clean:
+	@$(MAKE) subdir_testclean no_deps=t
+
+tests: $(objpfx)c++-types-check.out
+ifneq ($(CXX),no)
+check-data := $(firstword $(wildcard \
+	        $(foreach M,$(config-machine) $(base-machine),\
+			  scripts/data/c++-types-$M-$(config-os).data)))
+ifneq (,$(check-data))
+$(objpfx)c++-types-check.out: $(check-data)
+	scripts/check-c++-types.sh $^ $(CXX) $(filter-out -std=gnu99 -Wstrict-prototypes,$(CFLAGS)) $(CPPFLAGS) > $@
+else
+$(objpfx)c++-types-check.out:
+	@echo 'WARNING C++ tests not run; create a c++-types-XXX file'
+	@echo "not run" > $@
+endif
+endif
+
+# The realclean target is just like distclean for the parent, but we want
+# the subdirs to know the difference in case they care.
+realclean distclean: parent-clean
+# This is done this way rather than having `subdir_distclean' be a
+# dependency of this target so that libc.a will be removed before the
+# subdirectories are dealt with and so they won't try to remove object
+# files from it when it's going to be removed anyway.
+	@$(MAKE) distclean-1 no_deps=t distclean-1=$@ avoid-generated=yes \
+		 sysdep-subdirs="$(sysdep-subdirs)"
+	-rm -f $(postclean)
+
+# Subroutine of distclean and realclean.
+distclean-1: subdir_$(distclean-1)
+	-rm -f $(config-generated)
+	-rm -f $(addprefix $(objpfx),config.status config.cache config.log)
+	-rm -f $(addprefix $(objpfx),config.make config-name.h config.h)
+ifdef objdir
+	-rm -f $(objpfx)Makefile
+endif
+	-rm -f $(sysdep-$(distclean-1))
+
+
+# Make the distribution tarfile.
+.PHONY: dist tag-for-dist
+
+generated := $(generated) stubs.h
+
+README: README.template version.h
+	-rm -f $@
+	sed -e 's/RELEASE/$(release)/' -e 's/VERSION/$(version)/' < $< > $@
+# Make it unwritable so I won't change it by mistake.
+	chmod 444 $@
+ifeq ($(with-cvs),yes)
+	test ! -d CVS || cvs $(CVSOPTS) commit -m'Remade for $(release)-$(version)' $@
+endif
+
+files-for-dist := README FAQ INSTALL NOTES configure
+
+tag-of-stem = glibc-$(subst .,_,$*)
+
+# Add-ons in the main repository but distributed in their own tar files.
+dist-separate = libidn linuxthreads
+
+# Directories in each add-on.
+dist-separate-libidn = libidn
+dist-separate-linuxthreads = linuxthreads linuxthreads_db
+
+glibc-%.tar $(dist-separate:%=glibc-%-%.tar): $(files-for-dist) \
+					      $(foreach D,$(dist-separate),\
+							$D/configure)
+	@rm -fr glibc-$*
+	$(MAKE) -q `find sysdeps $(addsuffix /sysdeps,$(add-ons)) \
+			 -name configure`
+	cvs $(CVSOPTS) -Q export -d glibc-$* -r $(tag-of-stem) libc
+# Touch all the configure scripts going into the tarball since cvs export
+# might have delivered configure.in newer than configure.
+	find glibc-$* -name configure -print | xargs touch
+	$(dist-do-separate-dirs)
+	tar cf glibc-$*.tar glibc-$*
+	rm -fr glibc-$*
+define dist-do-separate-dirs
+$(foreach dir,$(dist-separate),
+	tar cf glibc-$(dir)-$*.tar -C glibc-$* $(dist-separate-$(dir))
+	rm -rf $(addprefix glibc-$*/,$(dist-separate-$(dir)))
+)
+endef
+
+# Do `make dist dist-version=X.Y.Z' to make tar files of an older version.
+dist-version = $(version)
+
+dist: $(foreach Z,.bz2 .gz,glibc-$(dist-version).tar$Z \
+		           $(foreach D,$(dist-separate),\
+				     glibc-$D-$(dist-version).tar$Z))
+	md5sum $^
+
+tag-for-dist: tag-$(dist-version)
+tag-%: $(files-for-dist)
+	cvs $(CVSOPTS) -Q tag -c $(tag-of-stem)
+
+define format-me
+@rm -f $@
+makeinfo --no-validate --no-warn --no-headers $< -o $@
+-chmod a-w $@
+endef
+INSTALL: manual/install.texi; $(format-me)
+NOTES: manual/creature.texi; $(format-me)
+manual/dir-add.texi manual/dir-add.info: FORCE
+	$(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
+FAQ: scripts/gen-FAQ.pl FAQ.in
+	$(PERL) $^ > $@.new && rm -f $@ && mv $@.new $@ && chmod a-w $@
+ifeq ($(with-cvs),yes)
+	test ! -d CVS || cvs $(CVSOPTS) commit -m'Regenerated:  $(PERL) $^' $@
+endif
+FORCE:
+
+iconvdata/% localedata/% po/% manual/%:
+	$(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
+
+# glibc 2.0 contains some header files which aren't used with glibc 2.1
+# anymore.
+# These rules should remove those headers
+ifeq (,$(install_root))
+ifeq ($(old-glibc-headers),yes)
+install: remove-old-headers
+endif
+endif
+
+headers2_0 := 	__math.h bytesex.h confname.h direntry.h elfclass.h  	\
+		errnos.h fcntlbits.h huge_val.h ioctl-types.h 		\
+		ioctls.h iovec.h jmp_buf.h libc-lock.h local_lim.h 	\
+		mathcalls.h mpool.h nan.h ndbm.h posix1_lim.h  		\
+		posix2_lim.h posix_opt.h resourcebits.h schedbits.h 	\
+		selectbits.h semaphorebits.h sigaction.h sigcontext.h 	\
+		signum.h sigset.h sockaddrcom.h socketbits.h stab.def 	\
+		statbuf.h statfsbuf.h stdio-lock.h stdio_lim.h 		\
+		syscall-list.h termbits.h timebits.h ustatbits.h 	\
+		utmpbits.h utsnamelen.h waitflags.h waitstatus.h 	\
+		xopen_lim.h gnu/types.h sys/ipc_buf.h 			\
+		sys/kernel_termios.h sys/msq_buf.h sys/sem_buf.h 	\
+		sys/shm_buf.h sys/socketcall.h sigstack.h
+
+.PHONY: remove-old-headers
+remove-old-headers:
+	rm -f $(addprefix $(inst_includedir)/, $(headers2_0))
Index: trunk/src/libctests/glibc/argp/Makefile
===================================================================
--- trunk/src/libctests/glibc/argp/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/argp/Makefile	(revision 2036)
@@ -0,0 +1,35 @@
+# Copyright (C) 1997, 2002, 2003 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Makefile for argp.
+#
+subdir	:= argp
+
+headers		= argp.h
+distribute	= argp-fmtstream.h argp-namefrob.h
+routines	= $(addprefix argp-, ba fmtstream fs-xinl help parse pv \
+				     pvh xinl eexst)
+
+tests		= argp-test tst-argp1
+
+CFLAGS-argp-help.c = $(uses-callbacks) -fexceptions
+CFLAGS-argp-parse.c = $(uses-callbacks)
+CFLAGS-argp-fmtstream.c = -fexceptions
+
+include ../Rules
Index: trunk/src/libctests/glibc/argp/argp-fmtstream.c
===================================================================
--- trunk/src/libctests/glibc/argp/argp-fmtstream.c	(revision 2036)
+++ trunk/src/libctests/glibc/argp/argp-fmtstream.c	(revision 2036)
@@ -0,0 +1,445 @@
+/* Word-wrapping and line-truncating streams
+   Copyright (C) 1997,1998,1999,2001,2002,2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* This package emulates glibc `line_wrap_stream' semantics for systems that
+   don't have that.  */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <ctype.h>
+
+#include "argp-fmtstream.h"
+#include "argp-namefrob.h"
+
+#ifndef ARGP_FMTSTREAM_USE_LINEWRAP
+
+#ifndef isblank
+#define isblank(ch) ((ch)==' ' || (ch)=='\t')
+#endif
+
+#if defined _LIBC && defined USE_IN_LIBIO
+# include <wchar.h>
+# include <libio/libioP.h>
+# define __vsnprintf(s, l, f, a) _IO_vsnprintf (s, l, f, a)
+#endif
+
+#define INIT_BUF_SIZE 200
+#define PRINTF_SIZE_GUESS 150
+
+
+/* Return an argp_fmtstream that outputs to STREAM, and which prefixes lines
+   written on it with LMARGIN spaces and limits them to RMARGIN columns
+   total.  If WMARGIN >= 0, words that extend past RMARGIN are wrapped by
+   replacing the whitespace before them with a newline and WMARGIN spaces.
+   Otherwise, chars beyond RMARGIN are simply dropped until a newline.
+   Returns NULL if there was an error.  */
+argp_fmtstream_t
+__argp_make_fmtstream (FILE *stream,
+		       size_t lmargin, size_t rmargin, ssize_t wmargin)
+{
+  argp_fmtstream_t fs;
+
+  fs = (struct argp_fmtstream *) malloc (sizeof (struct argp_fmtstream));
+  if (fs != NULL)
+    {
+      fs->stream = stream;
+
+      fs->lmargin = lmargin;
+      fs->rmargin = rmargin;
+      fs->wmargin = wmargin;
+      fs->point_col = 0;
+      fs->point_offs = 0;
+
+      fs->buf = (char *) malloc (INIT_BUF_SIZE);
+      if (! fs->buf)
+	{
+	  free (fs);
+	  fs = 0;
+	}
+      else
+	{
+	  fs->p = fs->buf;
+	  fs->end = fs->buf + INIT_BUF_SIZE;
+	}
+    }
+
+  return fs;
+}
+#if 0
+/* Not exported.  */
+#ifdef weak_alias
+weak_alias (__argp_make_fmtstream, argp_make_fmtstream)
+#endif
+#endif
+
+/* Flush FS to its stream, and free it (but don't close the stream).  */
+void
+__argp_fmtstream_free (argp_fmtstream_t fs)
+{
+  __argp_fmtstream_update (fs);
+  if (fs->p > fs->buf)
+    {
+#ifdef USE_IN_LIBIO
+      if (_IO_fwide (fs->stream, 0) > 0)
+	__fwprintf (fs->stream, L"%.*s", (int) (fs->p - fs->buf), fs->buf);
+      else
+#endif
+	fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
+    }
+  free (fs->buf);
+  free (fs);
+}
+#if 0
+/* Not exported.  */
+#ifdef weak_alias
+weak_alias (__argp_fmtstream_free, argp_fmtstream_free)
+#endif
+#endif
+
+
+/* Process FS's buffer so that line wrapping is done from POINT_OFFS to the
+   end of its buffer.  This code is mostly from glibc stdio/linewrap.c.  */
+void
+__argp_fmtstream_update (argp_fmtstream_t fs)
+{
+  char *buf, *nl;
+  size_t len;
+
+  /* Scan the buffer for newlines.  */
+  buf = fs->buf + fs->point_offs;
+  while (buf < fs->p)
+    {
+      size_t r;
+
+      if (fs->point_col == 0 && fs->lmargin != 0)
+	{
+	  /* We are starting a new line.  Print spaces to the left margin.  */
+	  const size_t pad = fs->lmargin;
+	  if (fs->p + pad < fs->end)
+	    {
+	      /* We can fit in them in the buffer by moving the
+		 buffer text up and filling in the beginning.  */
+	      memmove (buf + pad, buf, fs->p - buf);
+	      fs->p += pad; /* Compensate for bigger buffer. */
+	      memset (buf, ' ', pad); /* Fill in the spaces.  */
+	      buf += pad; /* Don't bother searching them.  */
+	    }
+	  else
+	    {
+	      /* No buffer space for spaces.  Must flush.  */
+	      size_t i;
+	      for (i = 0; i < pad; i++)
+		{
+#ifdef USE_IN_LIBIO
+		  if (_IO_fwide (fs->stream, 0) > 0)
+		    putwc_unlocked (L' ', fs->stream);
+		  else
+#endif
+		    putc_unlocked (' ', fs->stream);
+		}
+	    }
+	  fs->point_col = pad;
+	}
+
+      len = fs->p - buf;
+      nl = memchr (buf, '\n', len);
+
+      if (fs->point_col < 0)
+	fs->point_col = 0;
+
+      if (!nl)
+	{
+	  /* The buffer ends in a partial line.  */
+
+	  if (fs->point_col + len < fs->rmargin)
+	    {
+	      /* The remaining buffer text is a partial line and fits
+		 within the maximum line width.  Advance point for the
+		 characters to be written and stop scanning.  */
+	      fs->point_col += len;
+	      break;
+	    }
+	  else
+	    /* Set the end-of-line pointer for the code below to
+	       the end of the buffer.  */
+	    nl = fs->p;
+	}
+      else if (fs->point_col + (nl - buf) < (ssize_t) fs->rmargin)
+	{
+	  /* The buffer contains a full line that fits within the maximum
+	     line width.  Reset point and scan the next line.  */
+	  fs->point_col = 0;
+	  buf = nl + 1;
+	  continue;
+	}
+
+      /* This line is too long.  */
+      r = fs->rmargin - 1;
+
+      if (fs->wmargin < 0)
+	{
+	  /* Truncate the line by overwriting the excess with the
+	     newline and anything after it in the buffer.  */
+	  if (nl < fs->p)
+	    {
+	      memmove (buf + (r - fs->point_col), nl, fs->p - nl);
+	      fs->p -= buf + (r - fs->point_col) - nl;
+	      /* Reset point for the next line and start scanning it.  */
+	      fs->point_col = 0;
+	      buf += r + 1; /* Skip full line plus \n. */
+	    }
+	  else
+	    {
+	      /* The buffer ends with a partial line that is beyond the
+		 maximum line width.  Advance point for the characters
+		 written, and discard those past the max from the buffer.  */
+	      fs->point_col += len;
+	      fs->p -= fs->point_col - r;
+	      break;
+	    }
+	}
+      else
+	{
+	  /* Do word wrap.  Go to the column just past the maximum line
+	     width and scan back for the beginning of the word there.
+	     Then insert a line break.  */
+
+	  char *p, *nextline;
+	  int i;
+
+	  p = buf + (r + 1 - fs->point_col);
+	  while (p >= buf && !isblank (*p))
+	    --p;
+	  nextline = p + 1;	/* This will begin the next line.  */
+
+	  if (nextline > buf)
+	    {
+	      /* Swallow separating blanks.  */
+	      if (p >= buf)
+		do
+		  --p;
+		while (p >= buf && isblank (*p));
+	      nl = p + 1;	/* The newline will replace the first blank. */
+	    }
+	  else
+	    {
+	      /* A single word that is greater than the maximum line width.
+		 Oh well.  Put it on an overlong line by itself.  */
+	      p = buf + (r + 1 - fs->point_col);
+	      /* Find the end of the long word.  */
+	      do
+		++p;
+	      while (p < nl && !isblank (*p));
+	      if (p == nl)
+		{
+		  /* It already ends a line.  No fussing required.  */
+		  fs->point_col = 0;
+		  buf = nl + 1;
+		  continue;
+		}
+	      /* We will move the newline to replace the first blank.  */
+	      nl = p;
+	      /* Swallow separating blanks.  */
+	      do
+		++p;
+	      while (isblank (*p));
+	      /* The next line will start here.  */
+	      nextline = p;
+	    }
+
+	  /* Note: There are a bunch of tests below for
+	     NEXTLINE == BUF + LEN + 1; this case is where NL happens to fall
+	     at the end of the buffer, and NEXTLINE is in fact empty (and so
+	     we need not be careful to maintain its contents).  */
+
+	  if ((nextline == buf + len + 1
+	       ? fs->end - nl < fs->wmargin + 1
+	       : nextline - (nl + 1) < fs->wmargin)
+	      && fs->p > nextline)
+	    {
+	      /* The margin needs more blanks than we removed.  */
+	      if (fs->end - fs->p > fs->wmargin + 1)
+		/* Make some space for them.  */
+		{
+		  size_t mv = fs->p - nextline;
+		  memmove (nl + 1 + fs->wmargin, nextline, mv);
+		  nextline = nl + 1 + fs->wmargin;
+		  len = nextline + mv - buf;
+		  *nl++ = '\n';
+		}
+	      else
+		/* Output the first line so we can use the space.  */
+		{
+#ifdef USE_IN_LIBIO
+		  if (_IO_fwide (fs->stream, 0) > 0)
+		    __fwprintf (fs->stream, L"%.*s\n",
+				(int) (nl - fs->buf), fs->buf);
+		  else
+#endif
+		    {
+		      if (nl > fs->buf)
+			fwrite_unlocked (fs->buf, 1, nl - fs->buf, fs->stream);
+		      putc_unlocked ('\n', fs->stream);
+		    }
+		  len += buf - fs->buf;
+		  nl = buf = fs->buf;
+		}
+	    }
+	  else
+	    /* We can fit the newline and blanks in before
+	       the next word.  */
+	    *nl++ = '\n';
+
+	  if (nextline - nl >= fs->wmargin
+	      || (nextline == buf + len + 1 && fs->end - nextline >= fs->wmargin))
+	    /* Add blanks up to the wrap margin column.  */
+	    for (i = 0; i < fs->wmargin; ++i)
+	      *nl++ = ' ';
+	  else
+	    for (i = 0; i < fs->wmargin; ++i)
+#ifdef USE_IN_LIBIO
+	      if (_IO_fwide (fs->stream, 0) > 0)
+		putwc_unlocked (L' ', fs->stream);
+	      else
+#endif
+		putc_unlocked (' ', fs->stream);
+
+	  /* Copy the tail of the original buffer into the current buffer
+	     position.  */
+	  if (nl < nextline)
+	    memmove (nl, nextline, buf + len - nextline);
+	  len -= nextline - buf;
+
+	  /* Continue the scan on the remaining lines in the buffer.  */
+	  buf = nl;
+
+	  /* Restore bufp to include all the remaining text.  */
+	  fs->p = nl + len;
+
+	  /* Reset the counter of what has been output this line.  If wmargin
+	     is 0, we want to avoid the lmargin getting added, so we set
+	     point_col to a magic value of -1 in that case.  */
+	  fs->point_col = fs->wmargin ? fs->wmargin : -1;
+	}
+    }
+
+  /* Remember that we've scanned as far as the end of the buffer.  */
+  fs->point_offs = fs->p - fs->buf;
+}
+
+
+/* Ensure that FS has space for AMOUNT more bytes in its buffer, either by
+   growing the buffer, or by flushing it.  True is returned iff we succeed. */
+int
+__argp_fmtstream_ensure (struct argp_fmtstream *fs, size_t amount)
+{
+  if ((size_t) (fs->end - fs->p) < amount)
+    {
+      ssize_t wrote;
+
+      /* Flush FS's buffer.  */
+      __argp_fmtstream_update (fs);
+
+#ifdef USE_IN_LIBIO
+      if (_IO_fwide (fs->stream, 0) > 0)
+	{
+	  __fwprintf (fs->stream, L"%.*s", (int) (fs->p - fs->buf), fs->buf);
+	  wrote = fs->p - fs->buf;
+	}
+      else
+#endif
+	wrote = fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
+      if (wrote == fs->p - fs->buf)
+	{
+	  fs->p = fs->buf;
+	  fs->point_offs = 0;
+	}
+      else
+	{
+	  fs->p -= wrote;
+	  fs->point_offs -= wrote;
+	  memmove (fs->buf, fs->buf + wrote, fs->p - fs->buf);
+	  return 0;
+	}
+
+      if ((size_t) (fs->end - fs->buf) < amount)
+	/* Gotta grow the buffer.  */
+	{
+	  size_t old_size = fs->end - fs->buf;
+	  size_t new_size = old_size + amount;
+	  char *new_buf;
+
+	  if (new_size < old_size || ! (new_buf = realloc (fs->buf, new_size)))
+	    {
+	      __set_errno (ENOMEM);
+	      return 0;
+	    }
+
+	  fs->buf = new_buf;
+	  fs->end = new_buf + new_size;
+	  fs->p = fs->buf;
+	}
+    }
+
+  return 1;
+}
+
+
+ssize_t
+__argp_fmtstream_printf (struct argp_fmtstream *fs, const char *fmt, ...)
+{
+  int out;
+  size_t avail;
+  size_t size_guess = PRINTF_SIZE_GUESS; /* How much space to reserve. */
+
+  do
+    {
+      va_list args;
+
+      if (! __argp_fmtstream_ensure (fs, size_guess))
+	return -1;
+
+      va_start (args, fmt);
+      avail = fs->end - fs->p;
+      out = __vsnprintf (fs->p, avail, fmt, args);
+      va_end (args);
+      if ((size_t) out >= avail)
+	size_guess = out + 1;
+    }
+  while ((size_t) out >= avail);
+
+  fs->p += out;
+
+  return out;
+}
+#if 0
+/* Not exported.  */
+#ifdef weak_alias
+weak_alias (__argp_fmtstream_printf, argp_fmtstream_printf)
+#endif
+#endif
+
+#endif /* !ARGP_FMTSTREAM_USE_LINEWRAP */
Index: trunk/src/libctests/glibc/argp/argp-fmtstream.h
===================================================================
--- trunk/src/libctests/glibc/argp/argp-fmtstream.h	(revision 2036)
+++ trunk/src/libctests/glibc/argp/argp-fmtstream.h	(revision 2036)
@@ -0,0 +1,313 @@
+/* Word-wrapping and line-truncating streams.
+   Copyright (C) 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* This package emulates glibc `line_wrap_stream' semantics for systems that
+   don't have that.  If the system does have it, it is just a wrapper for
+   that.  This header file is only used internally while compiling argp, and
+   shouldn't be installed.  */
+
+#ifndef _ARGP_FMTSTREAM_H
+#define _ARGP_FMTSTREAM_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#ifndef __attribute__
+/* This feature is available in gcc versions 2.5 and later.  */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
+#  define __attribute__(Spec) /* empty */
+# endif
+/* The __-protected variants of `format' and `printf' attributes
+   are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || __STRICT_ANSI__
+#  define __format__ format
+#  define __printf__ printf
+# endif
+#endif
+
+#if    (_LIBC - 0 && !defined (USE_IN_LIBIO)) \
+    || (defined (__GNU_LIBRARY__) && defined (HAVE_LINEWRAP_H))
+/* line_wrap_stream is available, so use that.  */
+#define ARGP_FMTSTREAM_USE_LINEWRAP
+#endif
+
+#ifdef ARGP_FMTSTREAM_USE_LINEWRAP
+/* Just be a simple wrapper for line_wrap_stream; the semantics are
+   *slightly* different, as line_wrap_stream doesn't actually make a new
+   object, it just modifies the given stream (reversibly) to do
+   line-wrapping.  Since we control who uses this code, it doesn't matter.  */
+
+#include <linewrap.h>
+
+typedef FILE *argp_fmtstream_t;
+
+#define argp_make_fmtstream line_wrap_stream
+#define __argp_make_fmtstream line_wrap_stream
+#define argp_fmtstream_free line_unwrap_stream
+#define __argp_fmtstream_free line_unwrap_stream
+
+#define __argp_fmtstream_putc(fs,ch) putc(ch,fs)
+#define argp_fmtstream_putc(fs,ch) putc(ch,fs)
+#define __argp_fmtstream_puts(fs,str) fputs(str,fs)
+#define argp_fmtstream_puts(fs,str) fputs(str,fs)
+#define __argp_fmtstream_write(fs,str,len) fwrite(str,1,len,fs)
+#define argp_fmtstream_write(fs,str,len) fwrite(str,1,len,fs)
+#define __argp_fmtstream_printf fprintf
+#define argp_fmtstream_printf fprintf
+
+#define __argp_fmtstream_lmargin line_wrap_lmargin
+#define argp_fmtstream_lmargin line_wrap_lmargin
+#define __argp_fmtstream_set_lmargin line_wrap_set_lmargin
+#define argp_fmtstream_set_lmargin line_wrap_set_lmargin
+#define __argp_fmtstream_rmargin line_wrap_rmargin
+#define argp_fmtstream_rmargin line_wrap_rmargin
+#define __argp_fmtstream_set_rmargin line_wrap_set_rmargin
+#define argp_fmtstream_set_rmargin line_wrap_set_rmargin
+#define __argp_fmtstream_wmargin line_wrap_wmargin
+#define argp_fmtstream_wmargin line_wrap_wmargin
+#define __argp_fmtstream_set_wmargin line_wrap_set_wmargin
+#define argp_fmtstream_set_wmargin line_wrap_set_wmargin
+#define __argp_fmtstream_point line_wrap_point
+#define argp_fmtstream_point line_wrap_point
+
+#else /* !ARGP_FMTSTREAM_USE_LINEWRAP */
+/* Guess we have to define our own version.  */
+
+#ifndef __const
+#define __const const
+#endif
+
+
+struct argp_fmtstream
+{
+  FILE *stream;			/* The stream we're outputting to.  */
+
+  size_t lmargin, rmargin;	/* Left and right margins.  */
+  ssize_t wmargin;		/* Margin to wrap to, or -1 to truncate.  */
+
+  /* Point in buffer to which we've processed for wrapping, but not output.  */
+  size_t point_offs;
+  /* Output column at POINT_OFFS, or -1 meaning 0 but don't add lmargin.  */
+  ssize_t point_col;
+
+  char *buf;			/* Output buffer.  */
+  char *p;			/* Current end of text in BUF. */
+  char *end;			/* Absolute end of BUF.  */
+};
+
+typedef struct argp_fmtstream *argp_fmtstream_t;
+
+/* Return an argp_fmtstream that outputs to STREAM, and which prefixes lines
+   written on it with LMARGIN spaces and limits them to RMARGIN columns
+   total.  If WMARGIN >= 0, words that extend past RMARGIN are wrapped by
+   replacing the whitespace before them with a newline and WMARGIN spaces.
+   Otherwise, chars beyond RMARGIN are simply dropped until a newline.
+   Returns NULL if there was an error.  */
+extern argp_fmtstream_t __argp_make_fmtstream (FILE *__stream,
+					       size_t __lmargin,
+					       size_t __rmargin,
+					       ssize_t __wmargin);
+extern argp_fmtstream_t argp_make_fmtstream (FILE *__stream,
+					     size_t __lmargin,
+					     size_t __rmargin,
+					     ssize_t __wmargin);
+
+/* Flush __FS to its stream, and free it (but don't close the stream).  */
+extern void __argp_fmtstream_free (argp_fmtstream_t __fs);
+extern void argp_fmtstream_free (argp_fmtstream_t __fs);
+
+extern ssize_t __argp_fmtstream_printf (argp_fmtstream_t __fs,
+				       __const char *__fmt, ...)
+     __attribute__ ((__format__ (printf, 2, 3)));
+extern ssize_t argp_fmtstream_printf (argp_fmtstream_t __fs,
+				      __const char *__fmt, ...)
+     __attribute__ ((__format__ (printf, 2, 3)));
+
+extern int __argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch);
+extern int argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch);
+
+extern int __argp_fmtstream_puts (argp_fmtstream_t __fs, __const char *__str);
+extern int argp_fmtstream_puts (argp_fmtstream_t __fs, __const char *__str);
+
+extern size_t __argp_fmtstream_write (argp_fmtstream_t __fs,
+				      __const char *__str, size_t __len);
+extern size_t argp_fmtstream_write (argp_fmtstream_t __fs,
+				    __const char *__str, size_t __len);
+
+
+/* Access macros for various bits of state.  */
+#define argp_fmtstream_lmargin(__fs) ((__fs)->lmargin)
+#define argp_fmtstream_rmargin(__fs) ((__fs)->rmargin)
+#define argp_fmtstream_wmargin(__fs) ((__fs)->wmargin)
+#define __argp_fmtstream_lmargin argp_fmtstream_lmargin
+#define __argp_fmtstream_rmargin argp_fmtstream_rmargin
+#define __argp_fmtstream_wmargin argp_fmtstream_wmargin
+
+/* Set __FS's left margin to LMARGIN and return the old value.  */
+extern size_t argp_fmtstream_set_lmargin (argp_fmtstream_t __fs,
+					  size_t __lmargin);
+extern size_t __argp_fmtstream_set_lmargin (argp_fmtstream_t __fs,
+					    size_t __lmargin);
+
+/* Set __FS's right margin to __RMARGIN and return the old value.  */
+extern size_t argp_fmtstream_set_rmargin (argp_fmtstream_t __fs,
+					  size_t __rmargin);
+extern size_t __argp_fmtstream_set_rmargin (argp_fmtstream_t __fs,
+					    size_t __rmargin);
+
+/* Set __FS's wrap margin to __WMARGIN and return the old value.  */
+extern size_t argp_fmtstream_set_wmargin (argp_fmtstream_t __fs,
+					  size_t __wmargin);
+extern size_t __argp_fmtstream_set_wmargin (argp_fmtstream_t __fs,
+					    size_t __wmargin);
+
+/* Return the column number of the current output point in __FS.  */
+extern size_t argp_fmtstream_point (argp_fmtstream_t __fs);
+extern size_t __argp_fmtstream_point (argp_fmtstream_t __fs);
+
+/* Internal routines.  */
+extern void _argp_fmtstream_update (argp_fmtstream_t __fs);
+extern void __argp_fmtstream_update (argp_fmtstream_t __fs);
+extern int _argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount);
+extern int __argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount);
+
+
+#ifdef __OPTIMIZE__
+/* Inline versions of above routines.  */
+
+#if !_LIBC
+#define __argp_fmtstream_putc argp_fmtstream_putc
+#define __argp_fmtstream_puts argp_fmtstream_puts
+#define __argp_fmtstream_write argp_fmtstream_write
+#define __argp_fmtstream_set_lmargin argp_fmtstream_set_lmargin
+#define __argp_fmtstream_set_rmargin argp_fmtstream_set_rmargin
+#define __argp_fmtstream_set_wmargin argp_fmtstream_set_wmargin
+#define __argp_fmtstream_point argp_fmtstream_point
+#define __argp_fmtstream_update _argp_fmtstream_update
+#define __argp_fmtstream_ensure _argp_fmtstream_ensure
+#endif
+
+#ifndef ARGP_FS_EI
+#define ARGP_FS_EI extern inline
+#endif
+
+ARGP_FS_EI size_t
+__argp_fmtstream_write (argp_fmtstream_t __fs,
+			__const char *__str, size_t __len)
+{
+  if (__fs->p + __len <= __fs->end || __argp_fmtstream_ensure (__fs, __len))
+    {
+      memcpy (__fs->p, __str, __len);
+      __fs->p += __len;
+      return __len;
+    }
+  else
+    return 0;
+}
+
+ARGP_FS_EI int
+__argp_fmtstream_puts (argp_fmtstream_t __fs, __const char *__str)
+{
+  size_t __len = strlen (__str);
+  if (__len)
+    {
+      size_t __wrote = __argp_fmtstream_write (__fs, __str, __len);
+      return __wrote == __len ? 0 : -1;
+    }
+  else
+    return 0;
+}
+
+ARGP_FS_EI int
+__argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch)
+{
+  if (__fs->p < __fs->end || __argp_fmtstream_ensure (__fs, 1))
+    return *__fs->p++ = __ch;
+  else
+    return EOF;
+}
+
+/* Set __FS's left margin to __LMARGIN and return the old value.  */
+ARGP_FS_EI size_t
+__argp_fmtstream_set_lmargin (argp_fmtstream_t __fs, size_t __lmargin)
+{
+  size_t __old;
+  if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
+    __argp_fmtstream_update (__fs);
+  __old = __fs->lmargin;
+  __fs->lmargin = __lmargin;
+  return __old;
+}
+
+/* Set __FS's right margin to __RMARGIN and return the old value.  */
+ARGP_FS_EI size_t
+__argp_fmtstream_set_rmargin (argp_fmtstream_t __fs, size_t __rmargin)
+{
+  size_t __old;
+  if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
+    __argp_fmtstream_update (__fs);
+  __old = __fs->rmargin;
+  __fs->rmargin = __rmargin;
+  return __old;
+}
+
+/* Set FS's wrap margin to __WMARGIN and return the old value.  */
+ARGP_FS_EI size_t
+__argp_fmtstream_set_wmargin (argp_fmtstream_t __fs, size_t __wmargin)
+{
+  size_t __old;
+  if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
+    __argp_fmtstream_update (__fs);
+  __old = __fs->wmargin;
+  __fs->wmargin = __wmargin;
+  return __old;
+}
+
+/* Return the column number of the current output point in __FS.  */
+ARGP_FS_EI size_t
+__argp_fmtstream_point (argp_fmtstream_t __fs)
+{
+  if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
+    __argp_fmtstream_update (__fs);
+  return __fs->point_col >= 0 ? __fs->point_col : 0;
+}
+
+#if !_LIBC
+#undef __argp_fmtstream_putc
+#undef __argp_fmtstream_puts
+#undef __argp_fmtstream_write
+#undef __argp_fmtstream_set_lmargin
+#undef __argp_fmtstream_set_rmargin
+#undef __argp_fmtstream_set_wmargin
+#undef __argp_fmtstream_point
+#undef __argp_fmtstream_update
+#undef __argp_fmtstream_ensure
+#endif
+
+#endif /* __OPTIMIZE__ */
+
+#endif /* ARGP_FMTSTREAM_USE_LINEWRAP */
+
+#endif /* argp-fmtstream.h */
Index: trunk/src/libctests/glibc/argp/argp-test.c
===================================================================
--- trunk/src/libctests/glibc/argp/argp-test.c	(revision 2036)
+++ trunk/src/libctests/glibc/argp/argp-test.c	(revision 2036)
@@ -0,0 +1,212 @@
+/* Test program for argp argument parser
+   Copyright (C) 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <time.h>
+#include <string.h>
+#include <argp.h>
+
+const char *argp_program_version = "argp-test 1.0";
+
+
+struct argp_option sub_options[] =
+{
+  {"subopt1",       's',     0,  0, "Nested option 1"},
+  {"subopt2",       'S',     0,  0, "Nested option 2"},
+
+  { 0, 0, 0, 0, "Some more nested options:", 10},
+  {"subopt3",       'p',     0,  0, "Nested option 3"},
+
+  {"subopt4",       'q',     0,  0, "Nested option 4", 1},
+
+  {0}
+};
+
+static const char sub_args_doc[] = "STRING...\n-";
+static const char sub_doc[] = "\vThis is the doc string from the sub-arg-parser.";
+
+static error_t
+sub_parse_opt (int key, char *arg, struct argp_state *state)
+{
+  switch (key)
+    {
+    case ARGP_KEY_NO_ARGS:
+      printf ("NO SUB ARGS\n");
+      break;
+    case ARGP_KEY_ARG:
+      printf ("SUB ARG: %s\n", arg);
+      break;
+
+    case 's' : case 'S': case 'p': case 'q':
+      printf ("SUB KEY %c\n", key);
+      break;
+
+    default:
+      return ARGP_ERR_UNKNOWN;
+    }
+  return 0;
+}
+
+static char *
+sub_help_filter (int key, const char *text, void *input)
+{
+  if (key == ARGP_KEY_HELP_EXTRA)
+    return strdup ("This is some extra text from the sub parser (note that it \
+is preceded by a blank line).");
+  else
+    return (char *)text;
+}
+
+static struct argp sub_argp = {
+  sub_options, sub_parse_opt, sub_args_doc, sub_doc, 0, sub_help_filter
+};
+
+
+/* Structure used to communicate with the parsing functions.  */
+struct params
+{
+  unsigned foonly;		/* Value parsed for foonly.  */
+  unsigned foonly_default;	/* Default value for it.  */
+};
+
+#define OPT_PGRP 1
+#define OPT_SESS 2
+
+struct argp_option options[] =
+{
+  {"pid",       'p',     "PID", 0, "List the process PID"},
+  {"pgrp",      OPT_PGRP,"PGRP",0, "List processes in the process group PGRP"},
+  {"no-parent", 'P',	 0,     0, "Include processes without parents"},
+  {0,           'x',     0,     OPTION_ALIAS},
+  {"all-fields",'Q',     0,     0, "Don't elide unusable fields (normally"
+				   " if there's some reason ps can't"
+				   " print a field for any process, it's"
+				   " removed from the output entirely)" },
+  {"reverse",   'r',    0,      0, "Reverse the order of any sort"},
+  {"gratuitously-long-reverse-option", 0, 0, OPTION_ALIAS},
+  {"session",  OPT_SESS,"SID",  OPTION_ARG_OPTIONAL,
+				   "Add the processes from the session"
+				   " SID (which defaults to the sid of"
+				   " the current process)" },
+
+  {0,0,0,0, "Here are some more options:"},
+  {"foonly", 'f', "ZOT", OPTION_ARG_OPTIONAL, "Glork a foonly"},
+  {"zaza", 'z', 0, 0, "Snit a zar"},
+
+  {0}
+};
+
+static const char args_doc[] = "STRING";
+static const char doc[] = "Test program for argp."
+ "\vThis doc string comes after the options."
+ "\nHey!  Some manual formatting!"
+ "\nThe current time is: %s";
+
+static void
+popt (int key, char *arg)
+{
+  char buf[10];
+  if (isprint (key))
+    sprintf (buf, "%c", key);
+  else
+    sprintf (buf, "%d", key);
+  if (arg)
+    printf ("KEY %s: %s\n", buf, arg);
+  else
+    printf ("KEY %s\n", buf);
+}
+
+static error_t
+parse_opt (int key, char *arg, struct argp_state *state)
+{
+  struct params *params = state->input;
+
+  switch (key)
+    {
+    case ARGP_KEY_NO_ARGS:
+      printf ("NO ARGS\n");
+      break;
+
+    case ARGP_KEY_ARG:
+      if (state->arg_num > 0)
+	return ARGP_ERR_UNKNOWN; /* Leave it for the sub-arg parser.  */
+      printf ("ARG: %s\n", arg);
+      break;
+
+    case 'f':
+      if (arg)
+	params->foonly = atoi (arg);
+      else
+	params->foonly = params->foonly_default;
+      popt (key, arg);
+      break;
+
+    case 'p': case 'P': case OPT_PGRP: case 'x': case 'Q':
+    case 'r': case OPT_SESS: case 'z':
+      popt (key, arg);
+      break;
+
+    default:
+      return ARGP_ERR_UNKNOWN;
+    }
+  return 0;
+}
+
+static char *
+help_filter (int key, const char *text, void *input)
+{
+  char *new_text;
+  struct params *params = input;
+
+  if (key == ARGP_KEY_HELP_POST_DOC && text)
+    {
+      time_t now = time (0);
+      asprintf (&new_text, text, ctime (&now));
+    }
+  else if (key == 'f')
+    /* Show the default for the --foonly option.  */
+    asprintf (&new_text, "%s (ZOT defaults to %x)",
+	      text, params->foonly_default);
+  else
+    new_text = (char *)text;
+
+  return new_text;
+}
+
+static struct argp_child argp_children[] = { { &sub_argp }, { 0 } };
+static struct argp argp = {
+  options, parse_opt, args_doc, doc, argp_children, help_filter
+};
+
+
+int
+main (int argc, char **argv)
+{
+  struct params params;
+  params.foonly = 0;
+  params.foonly_default = random ();
+  argp_parse (&argp, argc, argv, 0, 0, &params);
+  printf ("After parsing: foonly = %x\n", params.foonly);
+  return 0;
+}
Index: trunk/src/libctests/glibc/argp/tst-argp1.c
===================================================================
--- trunk/src/libctests/glibc/argp/tst-argp1.c	(revision 2036)
+++ trunk/src/libctests/glibc/argp/tst-argp1.c	(revision 2036)
@@ -0,0 +1,118 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <argp.h>
+
+
+
+
+#define OPT_TO_THREAD		300
+#define OPT_TO_PROCESS		301
+#define OPT_SYNC_SIGNAL		302
+#define OPT_SYNC_JOIN		303
+#define OPT_TOPLEVEL		304
+
+
+static const struct argp_option test_options[] =
+  {
+    { NULL, 0, NULL, 0, "\
+This is a test for threads so we allow ther user to selection the number of \
+threads which are used at any one time.  Independently the total number of \
+rounds can be selected.  This is the total number of threads which will have \
+run when the process terminates:" },
+    { "threads", 't', "NUMBER", 0, "Number of threads used at once" },
+    { "starts", 's', "NUMBER", 0, "Total number of working threads" },
+    { "toplevel", OPT_TOPLEVEL, "NUMBER", 0,
+      "Number of toplevel threads which start the other threads; this \
+implies --sync-join" },
+
+    { NULL, 0, NULL, 0, "\
+Each thread can do one of two things: sleep or do work.  The latter is 100% \
+CPU bound.  The work load is the probability a thread does work.  All values \
+from zero to 100 (inclusive) are valid.  How often each thread repeats this \
+can be determined by the number of rounds.  The work cost determines how long \
+each work session (not sleeping) takes.  If it is zero a thread would \
+effectively nothing.  By setting the number of rounds to zero the thread \
+does no work at all and pure thread creation times can be measured." },
+    { "workload", 'w', "PERCENT", 0, "Percentage of time spent working" },
+    { "workcost", 'c', "NUMBER", 0,
+      "Factor in the cost of each round of working" },
+    { "rounds", 'r', "NUMBER", 0, "Number of rounds each thread runs" },
+
+    { NULL, 0, NULL, 0, "\
+There are a number of different methods how thread creation can be \
+synchronized.  Synchronization is necessary since the number of concurrently \
+running threads is limited." },
+    { "sync-signal", OPT_SYNC_SIGNAL, NULL, 0,
+      "Synchronize using a signal (default)" },
+    { "sync-join", OPT_SYNC_JOIN, NULL, 0, "Synchronize using pthread_join" },
+
+    { NULL, 0, NULL, 0, "\
+One parameter for each threads execution is the size of the stack.  If this \
+parameter is not used the system's default stack size is used.  If many \
+threads are used the stack size should be chosen quite small." },
+    { "stacksize", 'S', "BYTES", 0, "Size of threads stack" },
+    { "guardsize", 'g', "BYTES", 0,
+      "Size of stack guard area; must fit into the stack" },
+
+    { NULL, 0, NULL, 0, "Signal options:" },
+    { "to-thread", OPT_TO_THREAD, NULL, 0, "Send signal to main thread" },
+    { "to-process", OPT_TO_PROCESS, NULL, 0,
+      "Send signal to process (default)" },
+
+    { NULL, 0, NULL, 0, "Administrative options:" },
+    { "progress", 'p', NULL, 0, "Show signs of progress" },
+    { "timing", 'T', NULL, 0,
+      "Measure time from startup to the last thread finishing" },
+    { NULL, 0, NULL, 0, NULL }
+  };
+
+/* Prototype for option handler.  */
+static error_t parse_opt (int key, char *arg, struct argp_state *state);
+
+/* Data structure to communicate with argp functions.  */
+static struct argp argp =
+{
+  test_options, parse_opt
+};
+
+
+static int
+do_test (void)
+{
+  int argc = 2;
+  char *argv[3] = { (char *) "tst-argp1", (char *) "--help", NULL };
+  int remaining;
+
+  /* Parse and process arguments.  */
+  argp_parse (&argp, argc, argv, 0, &remaining, NULL);
+
+  return 0;
+}
+
+
+/* Handle program arguments.  */
+static error_t
+parse_opt (int key, char *arg, struct argp_state *state)
+{
+  return ARGP_ERR_UNKNOWN;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/assert/Makefile
===================================================================
--- trunk/src/libctests/glibc/assert/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/assert/Makefile	(revision 2036)
@@ -0,0 +1,31 @@
+# Copyright (C) 1991, 1994, 1997, 1998, 2000 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Sub-makefile for assert portion of the library.
+#
+subdir	:= assert
+headers	:= assert.h
+
+routines := assert assert-perr __assert
+tests := test-assert test-assert-perr
+
+include ../Rules
+
+test-assert-ENV = LANGUAGE=C
+test-assert-perr-ENV = LANGUAGE=C
Index: trunk/src/libctests/glibc/assert/test-assert-perr.c
===================================================================
--- trunk/src/libctests/glibc/assert/test-assert-perr.c	(revision 2036)
+++ trunk/src/libctests/glibc/assert/test-assert-perr.c	(revision 2036)
@@ -0,0 +1,86 @@
+/* Test assert_perror().
+ *
+ * This is hairier than you'd think, involving games with
+ * stdio and signals.
+ *
+ */
+
+#include <signal.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <setjmp.h>
+
+jmp_buf rec;
+char buf[160];
+
+static void
+sigabrt (int unused)
+{
+  longjmp (rec, 1);  /* recover control */
+}
+
+#undef NDEBUG
+#include <assert.h>
+static void
+assert1 (void)
+{
+  assert_perror (1);
+}
+
+static void
+assert2 (void)
+{
+  assert_perror (0);
+}
+
+#define NDEBUG
+#include <assert.h>
+static void
+assert3 (void)
+{
+  assert_perror (2);
+}
+
+int
+main(void)
+{
+  volatile int failed = 1;  /* safety in presence of longjmp() */
+
+  fclose (stderr);
+  stderr = tmpfile ();
+  if (!stderr)
+    abort ();
+
+  signal (SIGABRT, sigabrt);
+
+  if (!setjmp (rec))
+    assert1 ();
+  else
+    failed = 0;  /* should happen */
+
+  if (!setjmp (rec))
+    assert2 ();
+  else
+    failed = 1; /* should not happen */
+
+  if (!setjmp (rec))
+    assert3 ();
+  else
+    failed = 1; /* should not happen */
+
+  rewind (stderr);
+  fgets (buf, 160, stderr);
+  if (!strstr(buf, strerror (1)))
+    failed = 1;
+
+  fgets (buf, 160, stderr);
+  if (strstr (buf, strerror (0)))
+    failed = 1;
+
+  fgets (buf, 160, stderr);
+  if (strstr (buf, strerror (2)))
+    failed = 1;
+
+  return failed;
+}
Index: trunk/src/libctests/glibc/assert/test-assert.c
===================================================================
--- trunk/src/libctests/glibc/assert/test-assert.c	(revision 2036)
+++ trunk/src/libctests/glibc/assert/test-assert.c	(revision 2036)
@@ -0,0 +1,88 @@
+/* Test assert().
+ *
+ * This is hairier than you'd think, involving games with
+ * stdio and signals.
+ *
+ */
+
+#include <signal.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <setjmp.h>
+
+jmp_buf rec;
+char buf[160];
+
+static void
+sigabrt (int unused)
+{
+  longjmp (rec, 1);  /* recover control */
+}
+
+#undef NDEBUG
+#include <assert.h>
+static void
+assert1 (void)
+{
+  assert (1 == 2);
+}
+
+static void
+assert2 (void)
+{
+  assert (1 == 1);
+}
+
+
+#define NDEBUG
+#include <assert.h>
+static void
+assert3 (void)
+{
+  assert (2 == 3);
+}
+
+int
+main (void)
+{
+
+  volatile int failed = 1;
+
+  fclose (stderr);
+  stderr = tmpfile ();
+  if(!stderr)
+    abort ();
+
+  signal (SIGABRT, sigabrt);
+
+  if (!setjmp (rec))
+    assert1 ();
+  else
+    failed = 0;  /* should happen */
+
+  if (!setjmp (rec))
+    assert2 ();
+  else
+    failed = 1; /* should not happen */
+
+  if (!setjmp (rec))
+    assert3 ();
+  else
+    failed = 1; /* should not happen */
+
+  rewind (stderr);
+  fgets (buf, 160, stderr);
+  if (!strstr (buf, "1 == 2"))
+    failed = 1;
+
+  fgets (buf, 160, stderr);
+  if (strstr (buf, "1 == 1"))
+    failed = 1;
+
+  fgets (buf, 160, stderr);
+  if (strstr (buf, "2 == 3"))
+    failed = 1;
+
+  return failed;
+}
Index: trunk/src/libctests/glibc/catgets/Makefile
===================================================================
--- trunk/src/libctests/glibc/catgets/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/catgets/Makefile	(revision 2036)
@@ -0,0 +1,86 @@
+# Copyright (C) 1996-2000, 2002, 2003, 2004 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Makefile for catgets.
+#
+subdir	:= catgets
+
+headers		= nl_types.h
+distribute	= catgetsinfo.h config.h xopen-msg.sed test1.msg test2.msg \
+		  test-gencat.sh sample.SJIS
+routines	= catgets open_catalog
+others		= gencat
+install-bin	= gencat
+extra-objs	= $(gencat-modules:=.o)
+
+tests = tst-catgets
+test-srcs = test-gencat
+
+gencat-modules	= xmalloc
+
+# To find xmalloc.c
+vpath %.c ../locale/programs
+
+
+include ../Rules
+
+$(objpfx)gencat: $(gencat-modules:%=$(objpfx)%.o)
+
+catgets-CPPFLAGS := -DNLSPATH='"$(msgcatdir)/%L/%N:$(msgcatdir)/%L/LC_MESSAGES/%N:$(msgcatdir)/%l/%N:$(msgcatdir)/%l/LC_MESSAGES/%N:"' \
+	    -DHAVE_CONFIG_H
+
+CPPFLAGS-gencat = -DNOT_IN_libc
+
+generated = de.msg test1.cat test1.h test2.cat test2.h sample.SJIS.cat \
+	    test-gencat.h
+generated-dirs = de
+
+tst-catgets-ENV = NLSPATH="$(objpfx)%l/%N.cat" LANG=de
+
+ifneq ($(cross-compiling),yes)
+tests: $(objpfx)de/libc.cat $(objpfx)test1.cat $(objpfx)test2.cat \
+       $(objpfx)test-gencat.out
+# This test just checks whether the program produces any error or not.
+# The result is not tested.
+$(objpfx)test1.cat: test1.msg $(objpfx)gencat
+	LC_ALL=hr_HR.ISO-8859-2 LOCPATH=$(common-objpfx)localedata \
+	GCONV_PATH=$(common-objpfx)iconvdata \
+	$(built-program-cmd) -H $(objpfx)test1.h $@ $<
+$(objpfx)test2.cat: test2.msg $(objpfx)gencat
+	LOCPATH=$(common-objpfx)localedata \
+	GCONV_PATH=$(common-objpfx)iconvdata \
+	$(built-program-cmd) -H $(objpfx)test2.h $@ $<
+$(objpfx)de/libc.cat: $(objpfx)de.msg $(objpfx)gencat
+	$(make-target-directory)
+	LC_ALL=de_DE.ISO-8859-1 LOCPATH=$(common-objpfx)localedata \
+	GCONV_PATH=$(common-objpfx)iconvdata $(built-program-cmd) $@ $<
+$(objpfx)tst-catgets.out: $(objpfx)de/libc.cat
+
+# Generate a non-simple input file.
+$(objpfx)de.msg: $(..)po/de.po
+	LC_ALL=C sed -f xopen-msg.sed $< > $@
+
+$(objpfx)test-gencat.out: test-gencat.sh $(objpfx)test-gencat \
+			  $(objpfx)sample.SJIS.cat
+	$(SHELL) -e $< $(common-objpfx) '$(built-program-cmd)'
+
+$(objpfx)sample.SJIS.cat: sample.SJIS $(objpfx)gencat
+	GCONV_PATH=$(common-objpfx)iconvdata LC_ALL=C \
+	$(built-program-cmd) -H $(objpfx)test-gencat.h < $(word 1,$^) > $@
+endif
Index: trunk/src/libctests/glibc/catgets/gencat.c
===================================================================
--- trunk/src/libctests/glibc/catgets/gencat.c	(revision 2036)
+++ trunk/src/libctests/glibc/catgets/gencat.c	(revision 2036)
@@ -0,0 +1,1366 @@
+/* Copyright (C) 1996-2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <argp.h>
+#include <assert.h>
+#include <ctype.h>
+#include <endian.h>
+#include <errno.h>
+#include <error.h>
+#include <fcntl.h>
+#include <iconv.h>
+#include <langinfo.h>
+#include <locale.h>
+#include <libintl.h>
+#include <limits.h>
+#include <nl_types.h>
+#include <obstack.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <wchar.h>
+
+#include "version.h"
+
+#include "catgetsinfo.h"
+
+
+#define SWAPU32(w) \
+  (((w) << 24) | (((w) & 0xff00) << 8) | (((w) >> 8) & 0xff00) | ((w) >> 24))
+
+struct message_list
+{
+  int number;
+  const char *message;
+
+  const char *fname;
+  size_t line;
+  const char *symbol;
+
+  struct message_list *next;
+};
+
+
+struct set_list
+{
+  int number;
+  int deleted;
+  struct message_list *messages;
+  int last_message;
+
+  const char *fname;
+  size_t line;
+  const char *symbol;
+
+  struct set_list *next;
+};
+
+
+struct catalog
+{
+  struct set_list *all_sets;
+  struct set_list *current_set;
+  size_t total_messages;
+  wint_t quote_char;
+  int last_set;
+
+  struct obstack mem_pool;
+};
+
+
+/* If non-zero force creation of new file, not using existing one.  */
+static int force_new;
+
+/* Name of output file.  */
+static const char *output_name;
+
+/* Name of generated C header file.  */
+static const char *header_name;
+
+/* Name and version of program.  */
+static void print_version (FILE *stream, struct argp_state *state);
+void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
+
+#define OPT_NEW 1
+
+/* Definitions of arguments for argp functions.  */
+static const struct argp_option options[] =
+{
+  { "header", 'H', N_("NAME"), 0,
+    N_("Create C header file NAME containing symbol definitions") },
+  { "new", OPT_NEW, NULL, 0,
+    N_("Do not use existing catalog, force new output file") },
+  { "output", 'o', N_("NAME"), 0, N_("Write output to file NAME") },
+  { NULL, 0, NULL, 0, NULL }
+};
+
+/* Short description of program.  */
+static const char doc[] = N_("Generate message catalog.\
+\vIf INPUT-FILE is -, input is read from standard input.  If OUTPUT-FILE\n\
+is -, output is written to standard output.\n");
+
+/* Strings for arguments in help texts.  */
+static const char args_doc[] = N_("\
+-o OUTPUT-FILE [INPUT-FILE]...\n[OUTPUT-FILE [INPUT-FILE]...]");
+
+/* Prototype for option handler.  */
+static error_t parse_opt (int key, char *arg, struct argp_state *state);
+
+/* Function to print some extra text in the help message.  */
+static char *more_help (int key, const char *text, void *input);
+
+/* Data structure to communicate with argp functions.  */
+static struct argp argp =
+{
+  options, parse_opt, args_doc, doc, NULL, more_help
+};
+
+
+/* Wrapper functions with error checking for standard functions.  */
+extern void *xmalloc (size_t n);
+extern void *xcalloc (size_t n, size_t s);
+extern void *xrealloc (void *o, size_t n);
+extern char *xstrdup (const char *);
+
+/* Prototypes for local functions.  */
+static void error_print (void);
+static struct catalog *read_input_file (struct catalog *current,
+					const char *fname);
+static void write_out (struct catalog *result, const char *output_name,
+		       const char *header_name);
+static struct set_list *find_set (struct catalog *current, int number);
+static void normalize_line (const char *fname, size_t line, iconv_t cd,
+			    wchar_t *string, wchar_t quote_char,
+			    wchar_t escape_char);
+static void read_old (struct catalog *catalog, const char *file_name);
+static int open_conversion (const char *codesetp, iconv_t *cd_towcp,
+			    iconv_t *cd_tombp, wchar_t *escape_charp);
+
+
+int
+main (int argc, char *argv[])
+{
+  struct catalog *result;
+  int remaining;
+
+  /* Set program name for messages.  */
+  error_print_progname = error_print;
+
+  /* Set locale via LC_ALL.  */
+  setlocale (LC_ALL, "");
+
+  /* Set the text message domain.  */
+  textdomain (PACKAGE);
+
+  /* Initialize local variables.  */
+  result = NULL;
+
+  /* Parse and process arguments.  */
+  argp_parse (&argp, argc, argv, 0, &remaining, NULL);
+
+  /* Determine output file.  */
+  if (output_name == NULL)
+    output_name = remaining < argc ? argv[remaining++] : "-";
+
+  /* Process all input files.  */
+  setlocale (LC_CTYPE, "C");
+  if (remaining < argc)
+    do
+      result = read_input_file (result, argv[remaining]);
+    while (++remaining < argc);
+  else
+    result = read_input_file (NULL, "-");
+
+  /* Write out the result.  */
+  if (result != NULL)
+    write_out (result, output_name, header_name);
+
+  return error_message_count != 0;
+}
+
+
+/* Handle program arguments.  */
+static error_t
+parse_opt (int key, char *arg, struct argp_state *state)
+{
+  switch (key)
+    {
+    case 'H':
+      header_name = arg;
+      break;
+    case OPT_NEW:
+      force_new = 1;
+      break;
+    case 'o':
+      output_name = arg;
+      break;
+    default:
+      return ARGP_ERR_UNKNOWN;
+    }
+  return 0;
+}
+
+
+static char *
+more_help (int key, const char *text, void *input)
+{
+  switch (key)
+    {
+    case ARGP_KEY_HELP_EXTRA:
+      /* We print some extra information.  */
+      return strdup (gettext ("\
+For bug reporting instructions, please see:\n\
+<http://www.gnu.org/software/libc/bugs.html>.\n"));
+    default:
+      break;
+    }
+  return (char *) text;
+}
+
+/* Print the version information.  */
+static void
+print_version (FILE *stream, struct argp_state *state)
+{
+  fprintf (stream, "gencat (GNU %s) %s\n", PACKAGE, VERSION);
+  fprintf (stream, gettext ("\
+Copyright (C) %s Free Software Foundation, Inc.\n\
+This is free software; see the source for copying conditions.  There is NO\n\
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
+"), "2005");
+  fprintf (stream, gettext ("Written by %s.\n"), "Ulrich Drepper");
+}
+
+
+/* The address of this function will be assigned to the hook in the
+   error functions.  */
+static void
+error_print ()
+{
+  /* We don't want the program name to be printed in messages.  Emacs'
+     compile.el does not like this.  */
+}
+
+
+static struct catalog *
+read_input_file (struct catalog *current, const char *fname)
+{
+  FILE *fp;
+  char *buf;
+  size_t len;
+  size_t line_number;
+  wchar_t *wbuf;
+  size_t wbufsize;
+  iconv_t cd_towc = (iconv_t) -1;
+  iconv_t cd_tomb = (iconv_t) -1;
+  wchar_t escape_char = L'\\';
+  char *codeset = NULL;
+
+  if (strcmp (fname, "-") == 0 || strcmp (fname, "/dev/stdin") == 0)
+    {
+      fp = stdin;
+      fname = gettext ("*standard input*");
+    }
+  else
+    fp = fopen (fname, "r");
+  if (fp == NULL)
+    {
+      error (0, errno, gettext ("cannot open input file `%s'"), fname);
+      return current;
+    }
+
+  /* If we haven't seen anything yet, allocate result structure.  */
+  if (current == NULL)
+    {
+      current = (struct catalog *) xcalloc (1, sizeof (*current));
+
+#define obstack_chunk_alloc malloc
+#define obstack_chunk_free free
+      obstack_init (&current->mem_pool);
+
+      current->current_set = find_set (current, NL_SETD);
+    }
+
+  buf = NULL;
+  len = 0;
+  line_number = 0;
+
+  wbufsize = 1024;
+  wbuf = (wchar_t *) xmalloc (wbufsize);
+
+  while (!feof (fp))
+    {
+      int continued;
+      int used;
+      size_t start_line = line_number + 1;
+      char *this_line;
+
+      do
+	{
+	  int act_len;
+
+	  act_len = getline (&buf, &len, fp);
+	  if (act_len <= 0)
+	    break;
+	  ++line_number;
+
+	  /* It the line continued?  */
+	  continued = 0;
+	  if (buf[act_len - 1] == '\n')
+	    {
+	      --act_len;
+
+	      /* There might be more than one backslash at the end of
+		 the line.  Only if there is an odd number of them is
+		 the line continued.  */
+	      if (act_len > 0 && buf[act_len - 1] == '\\')
+		{
+		  int temp_act_len = act_len;
+
+		  do
+		    {
+		      --temp_act_len;
+		      continued = !continued;
+		    }
+		  while (temp_act_len > 0 && buf[temp_act_len - 1] == '\\');
+
+		  if (continued)
+		    --act_len;
+		}
+	    }
+
+	  /* Append to currently selected line.  */
+	  obstack_grow (&current->mem_pool, buf, act_len);
+	}
+      while (continued);
+
+      obstack_1grow (&current->mem_pool, '\0');
+      this_line = (char *) obstack_finish (&current->mem_pool);
+
+      used = 0;
+      if (this_line[0] == '$')
+	{
+	  if (isblank (this_line[1]))
+	    {
+	      int cnt = 1;
+	      while (isblank (this_line[cnt]))
+		++cnt;
+	      if (strncmp (&this_line[cnt], "codeset=", 8) != 0)
+		/* This is a comment line. Do nothing.  */;
+	      else if (codeset != NULL)
+		/* Ignore multiple codeset. */;
+	      else
+		{
+		  int start = cnt + 8;
+		  cnt = start;
+		  while (this_line[cnt] != '\0' && !isspace (this_line[cnt]))
+		    ++cnt;
+		  if (cnt != start)
+		    {
+		      int len = cnt - start;
+		      codeset = xmalloc (len + 1);
+		      *((char *) mempcpy (codeset, &this_line[start], len))
+			= '\0';
+		    }
+		}
+	    }
+	  else if (strncmp (&this_line[1], "set", 3) == 0)
+	    {
+	      int cnt = sizeof ("set");
+	      int set_number;
+	      const char *symbol = NULL;
+	      while (isspace (this_line[cnt]))
+		++cnt;
+
+	      if (isdigit (this_line[cnt]))
+		{
+		  set_number = atol (&this_line[cnt]);
+
+		  /* If the given number for the character set is
+		     higher than any we used for symbolic set names
+		     avoid clashing by using only higher numbers for
+		     the following symbolic definitions.  */
+		  if (set_number > current->last_set)
+		    current->last_set = set_number;
+		}
+	      else
+		{
+		  /* See whether it is a reasonable identifier.  */
+		  int start = cnt;
+		  while (isalnum (this_line[cnt]) || this_line[cnt] == '_')
+		    ++cnt;
+
+		  if (cnt == start)
+		    {
+		      /* No correct character found.  */
+		      error_at_line (0, 0, fname, start_line,
+				     gettext ("illegal set number"));
+		      set_number = 0;
+		    }
+		  else
+		    {
+		      /* We have found seomthing that looks like a
+			 correct identifier.  */
+		      struct set_list *runp;
+
+		      this_line[cnt] = '\0';
+		      used = 1;
+		      symbol = &this_line[start];
+
+		      /* Test whether the identifier was already used.  */
+		      runp = current->all_sets;
+		      while (runp != 0)
+			if (runp->symbol != NULL
+			    && strcmp (runp->symbol, symbol) == 0)
+			  break;
+			else
+			  runp = runp->next;
+
+		      if (runp != NULL)
+			{
+			  /* We cannot allow duplicate identifiers for
+			     message sets.  */
+			  error_at_line (0, 0, fname, start_line,
+					 gettext ("duplicate set definition"));
+			  error_at_line (0, 0, runp->fname, runp->line,
+					 gettext ("\
+this is the first definition"));
+			  set_number = 0;
+			}
+		      else
+			/* Allocate next free message set for identifier.  */
+			set_number = ++current->last_set;
+		    }
+		}
+
+	      if (set_number != 0)
+		{
+		  /* We found a legal set number.  */
+		  current->current_set = find_set (current, set_number);
+		  if (symbol != NULL)
+		      used = 1;
+		  current->current_set->symbol = symbol;
+		  current->current_set->fname = fname;
+		  current->current_set->line = start_line;
+		}
+	    }
+	  else if (strncmp (&this_line[1], "delset", 6) == 0)
+	    {
+	      int cnt = sizeof ("delset");
+	      size_t set_number;
+	      while (isspace (this_line[cnt]))
+		++cnt;
+
+	      if (isdigit (this_line[cnt]))
+		{
+		  size_t set_number = atol (&this_line[cnt]);
+		  struct set_list *set;
+
+		  /* Mark the message set with the given number as
+		     deleted.  */
+		  set = find_set (current, set_number);
+		  set->deleted = 1;
+		}
+	      else
+		{
+		  /* See whether it is a reasonable identifier.  */
+		  int start = cnt;
+		  while (isalnum (this_line[cnt]) || this_line[cnt] == '_')
+		    ++cnt;
+
+		  if (cnt == start)
+		    {
+		      error_at_line (0, 0, fname, start_line,
+				     gettext ("illegal set number"));
+		      set_number = 0;
+		    }
+		  else
+		    {
+		      const char *symbol;
+		      struct set_list *runp;
+
+		      this_line[cnt] = '\0';
+		      used = 1;
+		      symbol = &this_line[start];
+
+		      /* We have a symbolic set name.  This name must
+			 appear somewhere else in the catalogs read so
+			 far.  */
+		      set_number = 0;
+		      for (runp = current->all_sets; runp != NULL;
+			   runp = runp->next)
+			{
+			  if (strcmp (runp->symbol, symbol) == 0)
+			    {
+			      runp->deleted = 1;
+			      break;
+			    }
+			}
+		      if (runp == NULL)
+			/* Name does not exist before.  */
+			error_at_line (0, 0, fname, start_line,
+				       gettext ("unknown set `%s'"), symbol);
+		    }
+		}
+	    }
+	  else if (strncmp (&this_line[1], "quote", 5) == 0)
+	    {
+	      char buf[2];
+	      char *bufptr;
+	      size_t buflen;
+	      char *wbufptr;
+	      size_t wbuflen;
+	      int cnt;
+
+	      cnt = sizeof ("quote");
+	      while (isspace (this_line[cnt]))
+		++cnt;
+
+	      /* We need the conversion.  */
+	      if (cd_towc == (iconv_t) -1
+		  && open_conversion (codeset, &cd_towc, &cd_tomb,
+				      &escape_char) != 0)
+		/* Something is wrong.  */
+		goto out;
+
+	      /* Yes, the quote char can be '\0'; this means no quote
+		 char.  The function using the information works on
+		 wide characters so we have to convert it here.  */
+	      buf[0] = this_line[cnt];
+	      buf[1] = '\0';
+	      bufptr = buf;
+	      buflen = 2;
+
+	      wbufptr = (char *) wbuf;
+	      wbuflen = wbufsize;
+
+	      /* Flush the state.  */
+	      iconv (cd_towc, NULL, NULL, NULL, NULL);
+
+	      iconv (cd_towc, &bufptr, &buflen, &wbufptr, &wbuflen);
+	      if (buflen != 0 || (wchar_t *) wbufptr != &wbuf[2])
+		error_at_line (0, 0, fname, start_line,
+			       gettext ("invalid quote character"));
+	      else
+		/* Use the converted wide character.  */
+		current->quote_char = wbuf[0];
+	    }
+	  else
+	    {
+	      int cnt;
+	      cnt = 2;
+	      while (this_line[cnt] != '\0' && !isspace (this_line[cnt]))
+		++cnt;
+	      this_line[cnt] = '\0';
+	      error_at_line (0, 0, fname, start_line,
+			     gettext ("unknown directive `%s': line ignored"),
+			     &this_line[1]);
+	    }
+	}
+      else if (isalnum (this_line[0]) || this_line[0] == '_')
+	{
+	  const char *ident = this_line;
+	  char *line = this_line;
+	  int message_number;
+
+	  do
+	    ++line;
+	  while (line[0] != '\0' && !isspace (line[0]));
+	  if (line[0] != '\0')
+	    *line++ = '\0';	/* Terminate the identifier.  */
+
+	  /* Now we found the beginning of the message itself.  */
+
+	  if (isdigit (ident[0]))
+	    {
+	      struct message_list *runp;
+	      struct message_list *lastp;
+
+	      message_number = atoi (ident);
+
+	      /* Find location to insert the new message.  */
+	      runp = current->current_set->messages;
+	      lastp = NULL;
+	      while (runp != NULL)
+		if (runp->number == message_number)
+		  break;
+		else
+		  {
+		    lastp = runp;
+		    runp = runp->next;
+		  }
+	      if (runp != NULL)
+		{
+		  /* Oh, oh.  There is already a message with this
+		     number in the message set.  */
+		  if (runp->symbol == NULL)
+		    {
+		      /* The existing message had its number specified
+			 by the user.  Fatal collision type uh, oh.  */
+		      error_at_line (0, 0, fname, start_line,
+				     gettext ("duplicated message number"));
+		      error_at_line (0, 0, runp->fname, runp->line,
+				     gettext ("this is the first definition"));
+		      message_number = 0;
+		    }
+		  else
+		    {
+		      /* Collision was with number auto-assigned to a
+			 symbolic.  Change existing symbolic number
+			 and move to end the list (if not already there).  */
+		      runp->number = ++current->current_set->last_message;
+
+		      if (runp->next != NULL)
+			{
+			  struct message_list *endp;
+
+			  if (lastp == NULL)
+			    current->current_set->messages=runp->next;
+			  else
+			    lastp->next=runp->next;
+
+			  endp = runp->next;
+			  while (endp->next != NULL)
+			    endp = endp->next;
+
+			  endp->next = runp;
+			  runp->next = NULL;
+			}
+		    }
+		}
+	      ident = NULL;	/* We don't have a symbol.  */
+
+	      if (message_number != 0
+		  && message_number > current->current_set->last_message)
+		current->current_set->last_message = message_number;
+	    }
+	  else if (ident[0] != '\0')
+	    {
+	      struct message_list *runp;
+	      struct message_list *lastp;
+
+	      /* Test whether the symbolic name was not used for
+		 another message in this message set.  */
+	      runp = current->current_set->messages;
+	      lastp = NULL;
+	      while (runp != NULL)
+		if (runp->symbol != NULL && strcmp (ident, runp->symbol) == 0)
+		  break;
+		else
+		  runp = runp->next;
+	      if (runp != NULL)
+		{
+		  /* The name is already used.  */
+		  error_at_line (0, 0, fname, start_line, gettext ("\
+duplicated message identifier"));
+		  error_at_line (0, 0, runp->fname, runp->line,
+				 gettext ("this is the first definition"));
+		  message_number = 0;
+		}
+	      else
+		/* Give the message the next unused number.  */
+		message_number = ++current->current_set->last_message;
+	    }
+	  else
+	    message_number = 0;
+
+	  if (message_number != 0)
+	    {
+	      char *inbuf;
+	      size_t inlen;
+	      char *outbuf;
+	      size_t outlen;
+	      struct message_list *newp;
+	      size_t line_len = strlen (line) + 1;
+	      size_t ident_len = 0;
+
+	      /* We need the conversion.  */
+	      if (cd_towc == (iconv_t) -1
+		  && open_conversion (codeset, &cd_towc, &cd_tomb,
+				      &escape_char) != 0)
+		/* Something is wrong.  */
+		goto out;
+
+	      /* Convert to a wide character string.  We have to
+		 interpret escape sequences which will be impossible
+		 without doing the conversion if the codeset of the
+		 message is stateful.  */
+	      while (1)
+		{
+		  inbuf = line;
+		  inlen = line_len;
+		  outbuf = (char *) wbuf;
+		  outlen = wbufsize;
+
+		  /* Flush the state.  */
+		  iconv (cd_towc, NULL, NULL, NULL, NULL);
+
+		  iconv (cd_towc, &inbuf, &inlen, &outbuf, &outlen);
+		  if (inlen == 0)
+		    {
+		      /* The string is converted.  */
+		      assert (outlen < wbufsize);
+		      assert (wbuf[(wbufsize - outlen) / sizeof (wchar_t) - 1]
+			      == L'\0');
+		      break;
+		    }
+
+		  if (outlen != 0)
+		    {
+		      /* Something is wrong with this string, we ignore it.  */
+		      error_at_line (0, 0, fname, start_line, gettext ("\
+invalid character: message ignored"));
+		      goto ignore;
+		    }
+
+		  /* The output buffer is too small.  */
+		  wbufsize *= 2;
+		  wbuf = (wchar_t *) xrealloc (wbuf, wbufsize);
+		}
+
+	      /* Strip quote characters, change escape sequences into
+		 correct characters etc.  */
+	      normalize_line (fname, start_line, cd_towc, wbuf,
+			      current->quote_char, escape_char);
+
+	      if (ident)
+		ident_len = line - this_line;
+
+	      /* Now the string is free of escape sequences.  Convert it
+		 back into a multibyte character string.  First free the
+		 memory allocated for the original string.  */
+	      obstack_free (&current->mem_pool, this_line);
+
+	      used = 1;	/* Yes, we use the line.  */
+
+	      /* Now fill in the new string.  It should never happen that
+		 the replaced string is longer than the original.  */
+	      inbuf = (char *) wbuf;
+	      inlen = (wcslen (wbuf) + 1) * sizeof (wchar_t);
+
+	      outlen = obstack_room (&current->mem_pool);
+	      obstack_blank (&current->mem_pool, outlen);
+	      this_line = (char *) obstack_base (&current->mem_pool);
+	      outbuf = this_line + ident_len;
+	      outlen -= ident_len;
+
+	      /* Flush the state.  */
+	      iconv (cd_tomb, NULL, NULL, NULL, NULL);
+
+	      iconv (cd_tomb, &inbuf, &inlen, &outbuf, &outlen);
+	      if (inlen != 0)
+		{
+		  error_at_line (0, 0, fname, start_line,
+				 gettext ("invalid line"));
+		  goto ignore;
+		}
+	      assert (outbuf[-1] == '\0');
+
+	      /* Free the memory in the obstack we don't use.  */
+	      obstack_blank (&current->mem_pool, -(int) outlen);
+	      line = obstack_finish (&current->mem_pool);
+
+	      newp = (struct message_list *) xmalloc (sizeof (*newp));
+	      newp->number = message_number;
+	      newp->message = line + ident_len;
+	      /* Remember symbolic name; is NULL if no is given.  */
+	      newp->symbol = ident ? line : NULL;
+	      /* Remember where we found the character.  */
+	      newp->fname = fname;
+	      newp->line = start_line;
+
+	      /* Find place to insert to message.  We keep them in a
+		 sorted single linked list.  */
+	      if (current->current_set->messages == NULL
+		  || current->current_set->messages->number > message_number)
+		{
+		  newp->next = current->current_set->messages;
+		  current->current_set->messages = newp;
+		}
+	      else
+		{
+		  struct message_list *runp;
+		  runp = current->current_set->messages;
+		  while (runp->next != NULL)
+		    if (runp->next->number > message_number)
+		      break;
+		    else
+		      runp = runp->next;
+		  newp->next = runp->next;
+		  runp->next = newp;
+		}
+	    }
+	  ++current->total_messages;
+	}
+      else
+	{
+	  size_t cnt;
+
+	  cnt = 0;
+	  /* See whether we have any non-white space character in this
+	     line.  */
+	  while (this_line[cnt] != '\0' && isspace (this_line[cnt]))
+	    ++cnt;
+
+	  if (this_line[cnt] != '\0')
+	    /* Yes, some unknown characters found.  */
+	    error_at_line (0, 0, fname, start_line,
+			   gettext ("malformed line ignored"));
+	}
+
+    ignore:
+      /* We can save the memory for the line if it was not used.  */
+      if (!used)
+	obstack_free (&current->mem_pool, this_line);
+    }
+
+  /* Close the conversion modules.  */
+  iconv_close (cd_towc);
+  iconv_close (cd_tomb);
+  free (codeset);
+
+ out:
+  free (wbuf);
+
+  if (fp != stdin)
+    fclose (fp);
+  return current;
+}
+
+
+static void
+write_out (struct catalog *catalog, const char *output_name,
+	   const char *header_name)
+{
+  /* Computing the "optimal" size.  */
+  struct set_list *set_run;
+  size_t best_total, best_size, best_depth;
+  size_t act_size, act_depth;
+  struct catalog_obj obj;
+  struct obstack string_pool;
+  const char *strings;
+  size_t strings_size;
+  uint32_t *array1, *array2;
+  size_t cnt;
+  int fd;
+
+  /* If not otherwise told try to read file with existing
+     translations.  */
+  if (!force_new)
+    read_old (catalog, output_name);
+
+  /* Initialize best_size with a very high value.  */
+  best_total = best_size = best_depth = UINT_MAX;
+
+  /* We need some start size for testing.  Let's start with
+     TOTAL_MESSAGES / 5, which theoretically provides a mean depth of
+     5.  */
+  act_size = 1 + catalog->total_messages / 5;
+
+  /* We determine the size of a hash table here.  Because the message
+     numbers can be chosen arbitrary by the programmer we cannot use
+     the simple method of accessing the array using the message
+     number.  The algorithm is based on the trivial hash function
+     NUMBER % TABLE_SIZE, where collisions are stored in a second
+     dimension up to TABLE_DEPTH.  We here compute TABLE_SIZE so that
+     the needed space (= TABLE_SIZE * TABLE_DEPTH) is minimal.  */
+  while (act_size <= best_total)
+    {
+      size_t deep[act_size];
+
+      act_depth = 1;
+      memset (deep, '\0', act_size * sizeof (size_t));
+      set_run = catalog->all_sets;
+      while (set_run != NULL)
+	{
+	  struct message_list *message_run;
+
+	  message_run = set_run->messages;
+	  while (message_run != NULL)
+	    {
+	      size_t idx = (message_run->number * set_run->number) % act_size;
+
+	      ++deep[idx];
+	      if (deep[idx] > act_depth)
+		{
+		  act_depth = deep[idx];
+		  if (act_depth * act_size > best_total)
+		    break;
+		}
+	      message_run = message_run->next;
+	    }
+	  set_run = set_run->next;
+	}
+
+      if (act_depth * act_size <= best_total)
+	{
+	  /* We have found a better solution.  */
+	  best_total = act_depth * act_size;
+	  best_size = act_size;
+	  best_depth = act_depth;
+	}
+
+      ++act_size;
+    }
+
+  /* let's be prepared for an empty message file.  */
+  if (best_size == UINT_MAX)
+    {
+      best_size = 1;
+      best_depth = 1;
+    }
+
+  /* OK, now we have the size we will use.  Fill in the header, build
+     the table and the second one with swapped byte order.  */
+  obj.magic = CATGETS_MAGIC;
+  obj.plane_size = best_size;
+  obj.plane_depth = best_depth;
+
+  /* Allocate room for all needed arrays.  */
+  array1 =
+    (uint32_t *) alloca (best_size * best_depth * sizeof (uint32_t) * 3);
+  memset (array1, '\0', best_size * best_depth * sizeof (uint32_t) * 3);
+  array2
+    = (uint32_t *) alloca (best_size * best_depth * sizeof (uint32_t) * 3);
+  obstack_init (&string_pool);
+
+  set_run = catalog->all_sets;
+  while (set_run != NULL)
+    {
+      struct message_list *message_run;
+
+      message_run = set_run->messages;
+      while (message_run != NULL)
+	{
+	  size_t idx = (((message_run->number * set_run->number) % best_size)
+			* 3);
+	  /* Determine collision depth.  */
+	  while (array1[idx] != 0)
+	    idx += best_size * 3;
+
+	  /* Store set number, message number and pointer into string
+	     space, relative to the first string.  */
+	  array1[idx + 0] = set_run->number;
+	  array1[idx + 1] = message_run->number;
+	  array1[idx + 2] = obstack_object_size (&string_pool);
+
+	  /* Add current string to the continuous space containing all
+	     strings.  */
+	  obstack_grow0 (&string_pool, message_run->message,
+			 strlen (message_run->message));
+
+	  message_run = message_run->next;
+	}
+
+      set_run = set_run->next;
+    }
+  strings_size = obstack_object_size (&string_pool);
+  strings = obstack_finish (&string_pool);
+
+  /* Compute ARRAY2 by changing the byte order.  */
+  for (cnt = 0; cnt < best_size * best_depth * 3; ++cnt)
+    array2[cnt] = SWAPU32 (array1[cnt]);
+
+  /* Now we can write out the whole data.  */
+  if (strcmp (output_name, "-") == 0
+      || strcmp (output_name, "/dev/stdout") == 0)
+    fd = STDOUT_FILENO;
+  else
+    {
+      fd = creat (output_name, 0666);
+      if (fd < 0)
+	error (EXIT_FAILURE, errno, gettext ("cannot open output file `%s'"),
+	       output_name);
+    }
+
+  /* Write out header.  */
+  write (fd, &obj, sizeof (obj));
+
+  /* We always write out the little endian version of the index
+     arrays.  */
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+  write (fd, array1, best_size * best_depth * sizeof (uint32_t) * 3);
+  write (fd, array2, best_size * best_depth * sizeof (uint32_t) * 3);
+#elif __BYTE_ORDER == __BIG_ENDIAN
+  write (fd, array2, best_size * best_depth * sizeof (uint32_t) * 3);
+  write (fd, array1, best_size * best_depth * sizeof (uint32_t) * 3);
+#else
+# error Cannot handle __BYTE_ORDER byte order
+#endif
+
+  /* Finally write the strings.  */
+  write (fd, strings, strings_size);
+
+  if (fd != STDOUT_FILENO)
+    close (fd);
+
+  /* If requested now write out the header file.  */
+  if (header_name != NULL)
+    {
+      int first = 1;
+      FILE *fp;
+
+      /* Open output file.  "-" or "/dev/stdout" means write to
+	 standard output.  */
+      if (strcmp (header_name, "-") == 0
+	  || strcmp (header_name, "/dev/stdout") == 0)
+	fp = stdout;
+      else
+	{
+	  fp = fopen (header_name, "w");
+	  if (fp == NULL)
+	    error (EXIT_FAILURE, errno,
+		   gettext ("cannot open output file `%s'"), header_name);
+	}
+
+      /* Iterate over all sets and all messages.  */
+      set_run = catalog->all_sets;
+      while (set_run != NULL)
+	{
+	  struct message_list *message_run;
+
+	  /* If the current message set has a symbolic name write this
+	     out first.  */
+	  if (set_run->symbol != NULL)
+	    fprintf (fp, "%s#define %sSet %#x\t/* %s:%Zu */\n",
+		     first ? "" : "\n", set_run->symbol, set_run->number - 1,
+		     set_run->fname, set_run->line);
+	  first = 0;
+
+	  message_run = set_run->messages;
+	  while (message_run != NULL)
+	    {
+	      /* If the current message has a symbolic name write
+		 #define out.  But we have to take care for the set
+		 not having a symbolic name.  */
+	      if (message_run->symbol != NULL)
+		{
+		  if (set_run->symbol == NULL)
+		    fprintf (fp, "#define AutomaticSet%d%s %#x\t/* %s:%Zu */\n",
+			     set_run->number, message_run->symbol,
+			     message_run->number, message_run->fname,
+			     message_run->line);
+		  else
+		    fprintf (fp, "#define %s%s %#x\t/* %s:%Zu */\n",
+			     set_run->symbol, message_run->symbol,
+			     message_run->number, message_run->fname,
+			     message_run->line);
+		}
+
+	      message_run = message_run->next;
+	    }
+
+	  set_run = set_run->next;
+	}
+
+      if (fp != stdout)
+	fclose (fp);
+    }
+}
+
+
+static struct set_list *
+find_set (struct catalog *current, int number)
+{
+  struct set_list *result = current->all_sets;
+
+  /* We must avoid set number 0 because a set of this number signals
+     in the tables that the entry is not occupied.  */
+  ++number;
+
+  while (result != NULL)
+    if (result->number == number)
+      return result;
+    else
+      result = result->next;
+
+  /* Prepare new message set.  */
+  result = (struct set_list *) xcalloc (1, sizeof (*result));
+  result->number = number;
+  result->next = current->all_sets;
+  current->all_sets = result;
+
+  return result;
+}
+
+
+/* Normalize given string *in*place* by processing escape sequences
+   and quote characters.  */
+static void
+normalize_line (const char *fname, size_t line, iconv_t cd, wchar_t *string,
+		wchar_t quote_char, wchar_t escape_char)
+{
+  int is_quoted;
+  wchar_t *rp = string;
+  wchar_t *wp = string;
+
+  if (quote_char != L'\0' && *rp == quote_char)
+    {
+      is_quoted = 1;
+      ++rp;
+    }
+  else
+    is_quoted = 0;
+
+  while (*rp != L'\0')
+    if (*rp == quote_char)
+      /* We simply end the string when we find the first time an
+	 not-escaped quote character.  */
+	break;
+    else if (*rp == escape_char)
+      {
+	++rp;
+	if (quote_char != L'\0' && *rp == quote_char)
+	  /* This is an extension to XPG.  */
+	  *wp++ = *rp++;
+	else
+	  /* Recognize escape sequences.  */
+	  switch (*rp)
+	    {
+	    case L'n':
+	      *wp++ = L'\n';
+	      ++rp;
+	      break;
+	    case L't':
+	      *wp++ = L'\t';
+	      ++rp;
+	      break;
+	    case L'v':
+	      *wp++ = L'\v';
+	      ++rp;
+	      break;
+	    case L'b':
+	      *wp++ = L'\b';
+	      ++rp;
+	      break;
+	    case L'r':
+	      *wp++ = L'\r';
+	      ++rp;
+	      break;
+	    case L'f':
+	      *wp++ = L'\f';
+	      ++rp;
+	      break;
+	    case L'0' ... L'7':
+	      {
+		int number;
+		char cbuf[2];
+		char *cbufptr;
+		size_t cbufin;
+		wchar_t wcbuf[2];
+		char *wcbufptr;
+		size_t wcbufin;
+
+		number = *rp++ - L'0';
+		while (number <= (255 / 8) && *rp >= L'0' && *rp <= L'7')
+		  {
+		    number *= 8;
+		    number += *rp++ - L'0';
+		  }
+
+		cbuf[0] = (char) number;
+		cbuf[1] = '\0';
+		cbufptr = cbuf;
+		cbufin = 2;
+
+		wcbufptr = (char *) wcbuf;
+		wcbufin = sizeof (wcbuf);
+
+		/* Flush the state.  */
+		iconv (cd, NULL, NULL, NULL, NULL);
+
+		iconv (cd, &cbufptr, &cbufin, &wcbufptr, &wcbufin);
+		if (cbufptr != &cbuf[2] || (wchar_t *) wcbufptr != &wcbuf[2])
+		  error_at_line (0, 0, fname, line,
+				 gettext ("invalid escape sequence"));
+		else
+		  *wp++ = wcbuf[0];
+	      }
+	      break;
+	    default:
+	      if (*rp == escape_char)
+		{
+		  *wp++ = escape_char;
+		  ++rp;
+		}
+	      else
+		/* Simply ignore the backslash character.  */;
+	      break;
+	    }
+      }
+    else
+      *wp++ = *rp++;
+
+  /* If we saw a quote character at the beginning we expect another
+     one at the end.  */
+  if (is_quoted && *rp != quote_char)
+    error_at_line (0, 0, fname, line, gettext ("unterminated message"));
+
+  /* Terminate string.  */
+  *wp = L'\0';
+  return;
+}
+
+
+static void
+read_old (struct catalog *catalog, const char *file_name)
+{
+  struct catalog_info old_cat_obj;
+  struct set_list *set = NULL;
+  int last_set = -1;
+  size_t cnt;
+
+  /* Try to open catalog, but don't look through the NLSPATH.  */
+  if (__open_catalog (file_name, NULL, NULL, &old_cat_obj) != 0)
+    {
+      if (errno == ENOENT)
+	/* No problem, the catalog simply does not exist.  */
+	return;
+      else
+	error (EXIT_FAILURE, errno,
+	       gettext ("while opening old catalog file"));
+    }
+
+  /* OK, we have the catalog loaded.  Now read all messages and merge
+     them.  When set and message number clash for any message the new
+     one is used.  If the new one is empty it indicates that the
+     message should be deleted.  */
+  for (cnt = 0; cnt < old_cat_obj.plane_size * old_cat_obj.plane_depth; ++cnt)
+    {
+      struct message_list *message, *last;
+
+      if (old_cat_obj.name_ptr[cnt * 3 + 0] == 0)
+	/* No message in this slot.  */
+	continue;
+
+      if (old_cat_obj.name_ptr[cnt * 3 + 0] - 1 != (uint32_t) last_set)
+	{
+	  last_set = old_cat_obj.name_ptr[cnt * 3 + 0] - 1;
+	  set = find_set (catalog, old_cat_obj.name_ptr[cnt * 3 + 0] - 1);
+	}
+
+      last = NULL;
+      message = set->messages;
+      while (message != NULL)
+	{
+	  if ((uint32_t) message->number >= old_cat_obj.name_ptr[cnt * 3 + 1])
+	    break;
+	  last = message;
+	  message = message->next;
+	}
+
+      if (message == NULL
+	  || (uint32_t) message->number > old_cat_obj.name_ptr[cnt * 3 + 1])
+	{
+	  /* We have found a message which is not yet in the catalog.
+	     Insert it at the right position.  */
+	  struct message_list *newp;
+
+	  newp = (struct message_list *) xmalloc (sizeof(*newp));
+	  newp->number = old_cat_obj.name_ptr[cnt * 3 + 1];
+	  newp->message =
+	    &old_cat_obj.strings[old_cat_obj.name_ptr[cnt * 3 + 2]];
+	  newp->fname = NULL;
+	  newp->line = 0;
+	  newp->symbol = NULL;
+	  newp->next = message;
+
+	  if (last == NULL)
+	    set->messages = newp;
+	  else
+	    last->next = newp;
+
+	  ++catalog->total_messages;
+	}
+      else if (*message->message == '\0')
+	{
+	  /* The new empty message has overridden the old one thus
+	     "deleting" it as required.  Now remove the empty remains. */
+	  if (last == NULL)
+	    set->messages = message->next;
+	  else
+	    last->next = message->next;
+	}
+    }
+}
+
+
+static int
+open_conversion (const char *codeset, iconv_t *cd_towcp, iconv_t *cd_tombp,
+		 wchar_t *escape_charp)
+{
+  char buf[2];
+  char *bufptr;
+  size_t bufsize;
+  wchar_t wbuf[2];
+  char *wbufptr;
+  size_t wbufsize;
+
+  /* If the input file does not specify the codeset use the locale's.  */
+  if (codeset == NULL)
+    {
+      setlocale (LC_ALL, "");
+      codeset = nl_langinfo (CODESET);
+      setlocale (LC_ALL, "C");
+    }
+
+  /* Get the conversion modules.  */
+  *cd_towcp = iconv_open ("WCHAR_T", codeset);
+  *cd_tombp = iconv_open (codeset, "WCHAR_T");
+  if (*cd_towcp == (iconv_t) -1 || *cd_tombp == (iconv_t) -1)
+    {
+      error (0, 0, gettext ("conversion modules not available"));
+      if (*cd_towcp != (iconv_t) -1)
+	iconv_close (*cd_towcp);
+
+      return 1;
+    }
+
+  /* One special case for historical reasons is the backslash
+     character.  In some codesets the byte value 0x5c is not mapped to
+     U005c in Unicode.  These charsets then don't have a backslash
+     character at all.  Therefore we have to live with whatever the
+     codeset provides and recognize, instead of the U005c, the character
+     the byte value 0x5c is mapped to.  */
+  buf[0] = '\\';
+  buf[1] = '\0';
+  bufptr = buf;
+  bufsize = 2;
+
+  wbufptr = (char *) wbuf;
+  wbufsize = sizeof (wbuf);
+
+  iconv (*cd_towcp, &bufptr, &bufsize, &wbufptr, &wbufsize);
+  if (bufsize != 0 || wbufsize != 0)
+    {
+      /* Something went wrong, we couldn't convert the byte 0x5c.  Go
+	 on with using U005c.  */
+      error (0, 0, gettext ("cannot determine escape character"));
+      *escape_charp = L'\\';
+    }
+  else
+    *escape_charp = wbuf[0];
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/catgets/sample.SJIS
===================================================================
--- trunk/src/libctests/glibc/catgets/sample.SJIS	(revision 2036)
+++ trunk/src/libctests/glibc/catgets/sample.SJIS	(revision 2036)
@@ -0,0 +1,14 @@
+$	test message catalog
+
+$ codeset=sjis
+$quote	"
+$set 1
+1 sample1:ABCDEF:
+2 sample2:ú{ê:
+3 sample3:\è\:
+4 sample4:TEST\tTAB:
+5 sample5:@\\t\íÞ:
+6 double slash\\
+7 "another line"
+$set Another
+FOO "message foo"
Index: trunk/src/libctests/glibc/catgets/test-gencat.c
===================================================================
--- trunk/src/libctests/glibc/catgets/test-gencat.c	(revision 2036)
+++ trunk/src/libctests/glibc/catgets/test-gencat.c	(revision 2036)
@@ -0,0 +1,31 @@
+#include <locale.h>
+#include <nl_types.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main (void)
+{
+  nl_catd catalog;
+  setlocale (LC_ALL, "");
+
+  printf ("LC_MESSAGES = %s\n", setlocale (LC_MESSAGES, NULL));
+
+  catalog = catopen ("sample", NL_CAT_LOCALE);
+  if (catalog == (nl_catd) -1)
+    {
+      printf ("no catalog: %m\n");
+      exit (1);
+    }
+
+  printf ("%s\n", catgets(catalog, 1, 1, "sample 1"));
+  printf ("%s\n", catgets(catalog, 1, 2, "sample 2"));
+  printf ("%s\n", catgets(catalog, 1, 3, "sample 3"));
+  printf ("%s\n", catgets(catalog, 1, 4, "sample 4"));
+  printf ("%s\n", catgets(catalog, 1, 5, "sample 5"));
+  printf ("%s\n", catgets(catalog, 1, 6, "sample 6"));
+  printf ("%s\n", catgets(catalog, 1, 7, "sample 7"));
+  catclose (catalog);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/catgets/test-gencat.sh
===================================================================
--- trunk/src/libctests/glibc/catgets/test-gencat.sh	(revision 2036)
+++ trunk/src/libctests/glibc/catgets/test-gencat.sh	(revision 2036)
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Test escape character handling in gencat.
+# Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+common_objpfx=$1
+run_program_prefix=$2
+
+# Run the test program.
+LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
+NLSPATH=${common_objpfx}catgets/%N.%c.cat LC_ALL=ja_JP.SJIS \
+  ${run_program_prefix} \
+    > ${common_objpfx}catgets/test-gencat.out
+
+# Compare with the expected result.
+cmp - ${common_objpfx}catgets/test-gencat.out <<"EOF"
+LC_MESSAGES = ja_JP.SJIS
+sample1:ABCDEF:
+sample2:ú{ê:
+sample3:\è\:
+sample4:TEST	TAB:
+sample5:@\	\íÞ:
+double slash\
+another line
+EOF
+res=$?
+
+cat <<EOF |
+#define AnotherSet 0x2	/* *standard input*:13 */
+#define AnotherFOO 0x1	/* *standard input*:14 */
+EOF
+cmp ${common_objpfx}catgets/test-gencat.h - || res=1
+
+exit $res
Index: trunk/src/libctests/glibc/catgets/test1.msg
===================================================================
--- trunk/src/libctests/glibc/catgets/test1.msg	(revision 2036)
+++ trunk/src/libctests/glibc/catgets/test1.msg	(revision 2036)
@@ -0,0 +1,5 @@
+$set 10
+$quote "
+$ Poznámka
+Welcome Vítejte v testovacím programu
+Author Autor: Vladimir Michl
Index: trunk/src/libctests/glibc/catgets/test2.msg
===================================================================
--- trunk/src/libctests/glibc/catgets/test2.msg	(revision 2036)
+++ trunk/src/libctests/glibc/catgets/test2.msg	(revision 2036)
@@ -0,0 +1,8 @@
+$set 42
+$ Two messages with auto-assigned numbers.
+Number1 Auto-assigned #1
+Number2 Auto-assigned #2
+$ Three messages with explicitly assigned numbers.
+0 Explicitly assigned #1
+1 Explicitly assigned #2
+2 Explicitly assigned #3
Index: trunk/src/libctests/glibc/catgets/tst-catgets.c
===================================================================
--- trunk/src/libctests/glibc/catgets/tst-catgets.c	(revision 2036)
+++ trunk/src/libctests/glibc/catgets/tst-catgets.c	(revision 2036)
@@ -0,0 +1,66 @@
+#include <mcheck.h>
+#include <nl_types.h>
+#include <stdio.h>
+#include <string.h>
+
+
+static const char *msgs[] =
+{
+#define INPUT(str)
+#define OUTPUT(str) str,
+#include <intl/msgs.h>
+};
+#define nmsgs (sizeof (msgs) / sizeof (msgs[0]))
+
+#define ROUNDS 5
+
+int
+main (void)
+{
+  int rnd;
+  int result = 0;
+
+  mtrace ();
+
+  /* We do this a few times to stress the memory handling.  */
+  for (rnd = 0; rnd < ROUNDS; ++rnd)
+    {
+      nl_catd cd = catopen ("libc", 0);
+      size_t cnt;
+
+      if (cd == (nl_catd) -1)
+	{
+	  printf ("cannot load catalog: %m\n");
+	  result = 1;
+	  break;
+	}
+
+      /* Go through all the messages and compare the result.  */
+      for (cnt = 0; cnt < nmsgs; ++cnt)
+	{
+	  char *trans;
+
+	  trans = catgets (cd, 1, 1 + cnt,
+			   "+#+# if this comes backs it's an error");
+
+	  if (trans == NULL)
+	    {
+	      printf ("catgets return NULL for %zd\n", cnt);
+	      result = 1;
+	    }
+	  else if (strcmp (trans, msgs[cnt]) != 0 && msgs[cnt][0] != '\0')
+	    {
+	      printf ("expected \"%s\", got \"%s\"\n", msgs[cnt], trans);
+	      result = 1;
+	    }
+	}
+
+      if (catclose (cd) != 0)
+	{
+	  printf ("catclose failed: %m\n");
+	  result = 1;
+	}
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/catgets/xopen-msg.sed
===================================================================
--- trunk/src/libctests/glibc/catgets/xopen-msg.sed	(revision 2036)
+++ trunk/src/libctests/glibc/catgets/xopen-msg.sed	(revision 2036)
@@ -0,0 +1,104 @@
+# po2msg.sed - Convert Uniforum style .po file to X/Open style .msg file
+# Copyright (C) 1995 Free Software Foundation, Inc.
+# Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
+#
+# 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 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+#
+# The first directive in the .msg should be the definition of the
+# message set number.  We use always set number 1.
+#
+1 {
+  i\
+$set 1 # Automatically created by po2msg.sed
+  h
+  s/.*/0/
+  x
+}
+#
+# We copy all comments into the .msg file.  Perhaps they can help.
+#
+/^#/ s/^#[ 	]*/$ /p
+#
+# We copy the original message as a comment into the .msg file.
+#
+/^msgid/ {
+# Does not work now
+#  /"$/! {
+#    s/\\$//
+#    s/$/ ... (more lines following)"/
+#  }
+  s/^msgid[ 	]*"\(.*\)"$/$ Original Message: \1/
+  p
+}
+#
+# The .msg file contains, other then the .po file, only the translations
+# but each given a unique ID.  Starting from 1 and incrementing by 1 for
+# each message we assign them to the messages.
+# It is important that the .po file used to generate the cat-id-tbl.c file
+# (with po-to-tbl) is the same as the one used here.  (At least the order
+# of declarations must not be changed.)
+#
+/^msgstr/ {
+  s/msgstr[ 	]*"\(.*\)"/\1/
+  x
+# The following nice solution is by
+# Bruno <Haible@ma2s2.mathematik.uni-karlsruhe.de>
+  td
+# Increment a decimal number in pattern space.
+# First hide trailing `9' digits.
+  :d
+  s/9\(_*\)$/_\1/
+  td
+# Assure at least one digit is available.
+  s/^\(_*\)$/0\1/
+# Increment the last digit.
+  s/8\(_*\)$/9\1/
+  s/7\(_*\)$/8\1/
+  s/6\(_*\)$/7\1/
+  s/5\(_*\)$/6\1/
+  s/4\(_*\)$/5\1/
+  s/3\(_*\)$/4\1/
+  s/2\(_*\)$/3\1/
+  s/1\(_*\)$/2\1/
+  s/0\(_*\)$/1\1/
+# Convert the hidden `9' digits to `0's.
+  s/_/0/g
+  x
+# Bring the line in the format `<number> <message>'
+  G
+  s/^[^\n]*$/& /
+  s/\(.*\)\n\([0-9]*\)/\2 \1/
+# Clear flag from last substitution.
+  tb
+# Append the next line.
+  :b
+  N
+# Look whether second part is a continuation line.
+  s/\(.*\n\)"\(.*\)"/\1\2/
+# Yes, then branch.
+  ta
+  P
+  D
+# Note that `D' includes a jump to the start!!
+# We found a continuation line.  But before printing insert '\'.
+  :a
+  s/\(.*\)\(\n.*\)/\1\\\2/
+  P
+# We cannot use the sed command `D' here
+  s/.*\n\(.*\)/\1/
+  tb
+}
+d
Index: trunk/src/libctests/glibc/conform/Makefile
===================================================================
--- trunk/src/libctests/glibc/conform/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/conform/Makefile	(revision 2036)
@@ -0,0 +1,27 @@
+# Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Sub-makefile for conform portion of the library.
+#
+subdir	:= conform
+
+distribute = conformtest.pl $(wildcard data/*.h-data) \
+	   $(wildcard data/*/*.h-data)
+
+include ../Rules
Index: trunk/src/libctests/glibc/conform/conformtest.pl
===================================================================
--- trunk/src/libctests/glibc/conform/conformtest.pl	(revision 2036)
+++ trunk/src/libctests/glibc/conform/conformtest.pl	(revision 2036)
@@ -0,0 +1,1107 @@
+#! /usr/bin/perl
+
+use Getopt::Long;
+
+$CC = "gcc";
+
+$dialect="XOPEN2K";
+GetOptions ('headers=s' => \@headers, 'dialect=s' => \$dialect);
+@headers = split(/,/,join(',',@headers));
+
+# List of the headers we are testing.
+if (@headers == ()) {
+  @headers = ("wordexp.h", "wctype.h", "wchar.h", "varargs.h", "utmpx.h",
+	      "utime.h", "unistd.h", "ulimit.h", "ucontext.h", "time.h",
+	      "tgmath.h", "termios.h", "tar.h", "sys/wait.h", "sys/utsname.h",
+	      "sys/un.h", "sys/uio.h", "sys/types.h", "sys/times.h",
+	      "sys/timeb.h", "sys/time.h", "sys/statvfs.h", "sys/stat.h",
+	      "sys/socket.h", "sys/shm.h", "sys/sem.h", "sys/select.h",
+	      "sys/resource.h", "sys/msg.h", "sys/mman.h", "sys/ipc.h",
+	      "syslog.h", "stropts.h", "strings.h", "string.h", "stdlib.h",
+	      "stdio.h", "stdint.h", "stddef.h", "stdarg.h", "spawn.h",
+	      "signal.h", "setjmp.h", "semaphore.h", "search.h", "sched.h",
+	      "regex.h", "pwd.h", "pthread.h", "poll.h", "nl_types.h",
+	      "netinet/tcp.h", "netinet/in.h", "net/if.h", "netdb.h", "ndbm.h",
+	      "mqueue.h", "monetary.h", "math.h", "locale.h", "libgen.h",
+	      "limits.h", "langinfo.h", "iso646.h", "inttypes.h", "iconv.h",
+	      "grp.h", "glob.h", "ftw.h", "fnmatch.h", "fmtmsg.h", "float.h",
+	      "fcntl.h", "errno.h", "dlfcn.h", "dirent.h", "ctype.h", "cpio.h",
+	      "complex.h", "assert.h", "arpa/inet.h", "aio.h");
+}
+
+if ($dialect ne "ISO" && $dialect ne "POSIX" && $dialect ne "XPG3"
+    && $dialect ne "XPG4" && $dialect ne "UNIX98" && $dialect ne "XOPEN2K") {
+  die "unknown dialect \"$dialect\"";
+}
+
+$CFLAGS{"ISO"} = "-I. -fno-builtin '-D__attribute__(x)=' -ansi";
+$CFLAGS{"POSIX"} = "-I. -fno-builtin '-D__attribute__(x)=' -D_POSIX_C_SOURCE=199912";
+$CFLAGS{"XPG3"} = "-I. -fno-builtin '-D__attribute__(x)=' -D_XOPEN_SOURCE";
+$CFLAGS{"XPG4"} = "-I. -fno-builtin '-D__attribute__(x)=' -D_XOPEN_SOURCE_EXTENDED";
+$CFLAGS{"UNIX98"} = "-I. -fno-builtin '-D__attribute__(x)=' -D_XOPEN_SOURCE=500";
+$CFLAGS{"XOPEN2K"} = "-I. -fno-builtin '-D__attribute__(x)=' -D_XOPEN_SOURCE=600";
+
+
+# These are the ISO C99 keywords.
+@keywords = ('auto', 'break', 'case', 'char', 'const', 'continue', 'default',
+	     'do', 'double', 'else', 'enum', 'extern', 'float', 'for', 'goto',
+	     'if', 'inline', 'int', 'long', 'register', 'restrict', 'return',
+	     'short', 'signed', 'sizeof', 'static', 'struct', 'switch',
+	     'typedef', 'union', 'unsigned', 'void', 'volatile', 'while');
+
+# These are symbols which are known to pollute the namespace.
+@knownproblems = ('unix', 'linux', 'i386');
+
+# Some headers need a bit more attention.
+$mustprepend{'inttypes.h'} = "#include <stddef.h>\n";
+$mustprepend{'regex.h'} = "#include <sys/types.h>\n";
+$mustprepend{'sched.h'} = "#include <sys/types.h>\n";
+$mustprepend{'signal.h'} = "#include <pthread.h>\n";
+$mustprepend{'stdio.h'} = "#include <sys/types.h>\n";
+$mustprepend{'wchar.h'} = "#include <stdarg.h>\n";
+$mustprepend{'wordexp.h'} = "#include <stddef.h>\n";
+
+# Make a hash table from this information.
+while ($#keywords >= 0) {
+  $iskeyword{pop (@keywords)} = 1;
+}
+
+# Make a hash table from the known problems.
+while ($#knownproblems >= 0) {
+  $isknown{pop (@knownproblems)} = 1;
+}
+
+$tmpdir = "/tmp";
+
+$verbose = 1;
+
+$total = 0;
+$skipped = 0;
+$errors = 0;
+
+
+sub poorfnmatch {
+  my($pattern, $string) = @_;
+  my($strlen) = length ($string);
+  my($res);
+
+  if (substr ($pattern, 0, 1) eq '*') {
+    my($patlen) = length ($pattern) - 1;
+    $res = ($strlen >= $patlen
+	    && substr ($pattern, -$patlen, $patlen) eq substr ($string, -$patlen, $patlen));
+  } elsif (substr ($pattern, -1, 1) eq '*') {
+    my($patlen) = length ($pattern) - 1;
+    $res = ($strlen >= $patlen
+	    && substr ($pattern, 0, $patlen) eq substr ($string, 0, $patlen));
+  } else {
+    $res = $pattern eq $string;
+  }
+  return $res;
+}
+
+
+sub compiletest
+{
+  my($fnamebase, $msg, $errmsg, $skip, $optional) = @_;
+  my($result) = $skip;
+  my($printlog) = 0;
+
+  ++$total;
+  printf ("  $msg...");
+
+  if ($skip != 0) {
+    ++$skipped;
+    printf (" SKIP\n");
+  } else {
+    $ret = system "$CC $CFLAGS{$dialect} -c $fnamebase.c -o $fnamebase.o > $fnamebase.out 2>&1";
+    if ($ret != 0) {
+      if ($optional != 0) {
+	printf (" $errmsg\n");
+	$result = 1;
+      } else {
+	printf (" FAIL\n");
+	if ($verbose != 0) {
+	  printf ("    $errmsg  Compiler message:\n");
+	  $printlog = 1;
+	}
+	++$errors;
+	$result = 1;
+      }
+    } else {
+      printf (" OK\n");
+      if ($verbose > 1 && -s "$fnamebase.out") {
+	# We print all warnings issued.
+	$printlog = 1;
+      }
+    }
+    if ($printlog != 0) {
+      printf ("    " . "-" x 71 . "\n");
+      open (MESSAGE, "< $fnamebase.out");
+      while (<MESSAGE>) {
+	printf ("    %s", $_);
+      }
+      close (MESSAGE);
+      printf ("    " . "-" x 71 . "\n");
+    }
+  }
+  unlink "$fnamebase.c";
+  unlink "$fnamebase.o";
+  unlink "$fnamebase.out";
+
+  $result;
+}
+
+
+sub runtest
+{
+  my($fnamebase, $msg, $errmsg, $skip) = @_;
+  my($result) = $skip;
+  my($printlog) = 0;
+
+  ++$total;
+  printf ("  $msg...");
+
+  if ($skip != 0) {
+    ++$skipped;
+    printf (" SKIP\n");
+  } else {
+    $ret = system "$CC $CFLAGS{$dialect} -o $fnamebase $fnamebase.c > $fnamebase.out 2>&1";
+    if ($ret != 0) {
+      printf (" FAIL\n");
+      if ($verbose != 0) {
+	printf ("    $errmsg  Compiler message:\n");
+	$printlog = 1;
+      }
+      ++$errors;
+      $result = 1;
+    } else {
+      # Now run the program.  If the exit code is not zero something is wrong.
+      $result = system "$fnamebase > $fnamebase.out2 2>&1";
+      if ($result == 0) {
+	printf (" OK\n");
+	if ($verbose > 1 && -s "$fnamebase.out") {
+	  # We print all warnings issued.
+	  $printlog = 1;
+	  system "cat $fnamebase.out2 >> $fnamebase.out";
+	}
+      } else {
+	printf (" FAIL\n");
+	++$errors;
+	$printlog = 1;
+	unlink "$fnamebase.out";
+	rename "$fnamebase.out2", "$fnamebase.out";
+      }
+    }
+    if ($printlog != 0) {
+      printf ("    " . "-" x 71 . "\n");
+      open (MESSAGE, "< $fnamebase.out");
+      while (<MESSAGE>) {
+	printf ("    %s", $_);
+      }
+      close (MESSAGE);
+      printf ("    " . "-" x 71 . "\n");
+    }
+  }
+  unlink "$fnamebase";
+  unlink "$fnamebase.c";
+  unlink "$fnamebase.o";
+  unlink "$fnamebase.out";
+  unlink "$fnamebase.out2";
+
+  $result;
+}
+
+
+sub newtoken {
+  my($token, @allow) = @_;
+  my($idx);
+
+  return if ($token =~ /^[0-9_]/ || $iskeyword{$token});
+
+  for ($idx = 0; $idx <= $#allow; ++$idx) {
+    return if (poorfnmatch ($allow[$idx], $token));
+  }
+
+  if ($isknown{$token}) {
+    ++$nknown;
+  } else {
+    $errors{$token} = 1;
+  }
+}
+
+
+sub removetoken {
+  my($token) = @_;
+  my($idx);
+
+  return if ($token =~ /^[0-9_]/ || $iskeyword{$token});
+
+  if (exists $errors{$token}) {
+    undef $errors{$token};
+  }
+}
+
+
+sub checknamespace {
+  my($h, $fnamebase, @allow) = @_;
+
+  ++$total;
+
+  # Generate a program to get the contents of this header.
+  open (TESTFILE, ">$fnamebase.c");
+  print TESTFILE "#include <$h>\n";
+  close (TESTFILE);
+
+  undef %errors;
+  $nknown = 0;
+  open (CONTENT, "$CC $CFLAGS{$dialect} -E $fnamebase.c -P -Wp,-dN | sed -e '/^# [1-9]/d' -e '/^[[:space:]]*\$/d' |");
+  loop: while (<CONTENT>) {
+    chop;
+    if (/^#define (.*)/) {
+      newtoken ($1, @allow);
+    } elsif (/^#undef (.*)/) {
+      removetoken ($1);
+    } else {
+      # We have to tokenize the line.
+      my($str) = $_;
+      my($index) = 0;
+      my($len) = length ($str);
+
+      foreach $token (split(/[^a-zA-Z0-9_]/, $str)) {
+	if ($token ne "") {
+	  newtoken ($token, @allow);
+	}
+      }
+    }
+  }
+  close (CONTENT);
+  unlink "$fnamebase.c";
+  $realerror = 0;
+  if ($#errors != 0) {
+    # Sort the output list so it's easier to compare results with diff.
+    foreach $f (sort keys(%errors)) {
+      if ($errors{$f} == 1) {
+	if ($realerror == 0) {
+	  printf ("FAIL\n    " . "-" x 72 . "\n");
+	  $realerror = 1;
+	  ++$errors;
+	}
+	printf ("    Namespace violation: \"%s\"\n", $f);
+      }
+    }
+    printf ("    " . "-" x 72 . "\n") if ($realerror != 0);
+  }
+
+  if ($realerror == 0) {
+    if ($nknown > 0) {
+      printf ("EXPECTED FAILURES\n");
+      ++$known;
+    } else {
+      printf ("OK\n");
+    }
+  }
+}
+
+
+while ($#headers >= 0) {
+  my($h) = pop (@headers);
+  my($hf) = $h;
+  $hf =~ s|/|-|;
+  my($fnamebase) = "$tmpdir/$hf-test";
+  my($missing);
+  my(@allow) = ();
+  my(@allowheader) = ();
+  my(%seenheader) = ();
+  my($prepend) = $mustprepend{$h};
+
+  printf ("Testing <$h>\n");
+  printf ("----------" . "-" x length ($h) . "\n");
+
+  # Generate a program to test for the availability of this header.
+  open (TESTFILE, ">$fnamebase.c");
+  print TESTFILE "$prepend";
+  print TESTFILE "#include <$h>\n";
+  close (TESTFILE);
+
+  $missing = compiletest ($fnamebase, "Checking whether <$h> is available",
+			  "Header <$h> not available", 0, 0);
+
+  printf ("\n");
+
+  open (CONTROL, "$CC -E -D$dialect - < data/$h-data |");
+  control: while (<CONTROL>) {
+    chop;
+    next control if (/^#/);
+    next control if (/^[	]*$/);
+
+    if (/^element *({([^}]*)}|([^{ ]*)) *({([^}]*)}|([^{ ]*)) *([A-Za-z0-9_]*) *(.*)/) {
+      my($struct) = "$2$3";
+      my($type) = "$5$6";
+      my($member) = "$7";
+      my($rest) = "$8";
+      my($res) = $missing;
+
+      # Remember that this name is allowed.
+      push @allow, $member;
+
+      # Generate a program to test for the availability of this member.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      print TESTFILE "$struct a;\n";
+      print TESTFILE "$struct b;\n";
+      print TESTFILE "extern void xyzzy (__typeof__ (&b.$member), __typeof__ (&a.$member), unsigned);\n";
+      print TESTFILE "void foobarbaz (void) {\n";
+      print TESTFILE "  xyzzy (&a.$member, &b.$member, sizeof (a.$member));\n";
+      print TESTFILE "}\n";
+      close (TESTFILE);
+
+      $res = compiletest ($fnamebase, "Testing for member $member",
+			  "Member \"$member\" not available.", $res, 0);
+
+
+      # Test the types of the members.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      print TESTFILE "$struct a;\n";
+      print TESTFILE "extern $type b$rest;\n";
+      print TESTFILE "extern __typeof__ (a.$member) b;\n";
+      close (TESTFILE);
+
+      compiletest ($fnamebase, "Testing for type of member $member",
+		   "Member \"$member\" does not have the correct type.",
+		   $res, 0);
+    } elsif (/^optional-element *({([^}]*)}|([^{ ]*)) *({([^}]*)}|([^{ ]*)) *([A-Za-z0-9_]*) *(.*)/) {
+      my($struct) = "$2$3";
+      my($type) = "$5$6";
+      my($member) = "$7";
+      my($rest) = "$8";
+      my($res) = $missing;
+
+      # Remember that this name is allowed.
+      push @allow, $member;
+
+      # Generate a program to test for the availability of this member.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      print TESTFILE "$struct a;\n";
+      print TESTFILE "$struct b;\n";
+      print TESTFILE "extern void xyzzy (__typeof__ (&b.$member), __typeof__ (&a.$member), unsigned);\n";
+      print TESTFILE "void foobarbaz (void) {\n";
+      print TESTFILE "  xyzzy (&a.$member, &b.$member, sizeof (a.$member));\n";
+      print TESTFILE "}\n";
+      close (TESTFILE);
+
+      $res = compiletest ($fnamebase, "Testing for member $member",
+			  "NOT AVAILABLE.", $res, 1);
+
+      if ($res == 0 || $missing != 0) {
+	# Test the types of the members.
+	open (TESTFILE, ">$fnamebase.c");
+	print TESTFILE "$prepend";
+	print TESTFILE "#include <$h>\n";
+	print TESTFILE "$struct a;\n";
+	print TESTFILE "extern $type b$rest;\n";
+	print TESTFILE "extern __typeof__ (a.$member) b;\n";
+	close (TESTFILE);
+
+	compiletest ($fnamebase, "Testing for type of member $member",
+		     "Member \"$member\" does not have the correct type.",
+		     $res, 0);
+      }
+    } elsif (/^optional-constant *([a-zA-Z0-9_]*) ([>=<]+) ([A-Za-z0-9_]*)/) {
+      my($const) = $1;
+      my($op) = $2;
+      my($value) = $3;
+      my($res) = $missing;
+
+      # Remember that this name is allowed.
+      push @allow, $const;
+
+      # Generate a program to test for the availability of this constant.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      print TESTFILE "__typeof__ ($const) a = $const;\n";
+      close (TESTFILE);
+
+      $res = compiletest ($fnamebase, "Testing for constant $const",
+			  "NOT PRESENT", $res, 1);
+
+      if ($value ne "" && $res == 0) {
+	# Generate a program to test for the value of this constant.
+	open (TESTFILE, ">$fnamebase.c");
+	print TESTFILE "$prepend";
+	print TESTFILE "#include <$h>\n";
+	# Negate the value since 0 means ok
+	print TESTFILE "int main (void) { return !($const $op $value); }\n";
+	close (TESTFILE);
+
+	$res = runtest ($fnamebase, "Testing for value of constant $const",
+			"Constant \"$const\" has not the right value.", $res);
+      }
+    } elsif (/^constant *([a-zA-Z0-9_]*) *([>=<]+) ([A-Za-z0-9_]*)/) {
+      my($const) = $1;
+      my($op) = $2;
+      my($value) = $3;
+      my($res) = $missing;
+
+      # Remember that this name is allowed.
+      push @allow, $const;
+
+      # Generate a program to test for the availability of this constant.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      print TESTFILE "__typeof__ ($const) a = $const;\n";
+      close (TESTFILE);
+
+      $res = compiletest ($fnamebase, "Testing for constant $const",
+			  "Constant \"$const\" not available.", $res, 0);
+
+      if ($value ne "") {
+	# Generate a program to test for the value of this constant.
+	open (TESTFILE, ">$fnamebase.c");
+	print TESTFILE "$prepend";
+	print TESTFILE "#include <$h>\n";
+	# Negate the value since 0 means ok
+	print TESTFILE "int main (void) { return !($const $op $value); }\n";
+	close (TESTFILE);
+
+	$res = runtest ($fnamebase, "Testing for value of constant $const",
+			"Constant \"$const\" has not the right value.", $res);
+      }
+    } elsif (/^typed-constant *([a-zA-Z0-9_]*) *({([^}]*)}|([^ ]*)) *([A-Za-z0-9_]*)?/) {
+      my($const) = $1;
+      my($type) = "$3$4";
+      my($value) = $5;
+      my($res) = $missing;
+
+      # Remember that this name is allowed.
+      push @allow, $const;
+
+      # Generate a program to test for the availability of this constant.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      print TESTFILE "__typeof__ ($const) a = $const;\n";
+      close (TESTFILE);
+
+      $res = compiletest ($fnamebase, "Testing for constant $const",
+			  "Constant \"$const\" not available.", $res, 0);
+
+      # Test the types of the members.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      print TESTFILE "__typeof__ (($type) 0) a;\n";
+      print TESTFILE "extern __typeof__ ($const) a;\n";
+      close (TESTFILE);
+
+      compiletest ($fnamebase, "Testing for type of constant $const",
+		   "Constant \"$const\" does not have the correct type.",
+		   $res, 0);
+
+      if ($value ne "") {
+	# Generate a program to test for the value of this constant.
+	open (TESTFILE, ">$fnamebase.c");
+	print TESTFILE "$prepend";
+	print TESTFILE "#include <$h>\n";
+	print TESTFILE "int main (void) { return $const != $value; }\n";
+	close (TESTFILE);
+
+	$res = runtest ($fnamebase, "Testing for value of constant $const",
+			"Constant \"$const\" has not the right value.", $res);
+      }
+    } elsif (/^optional-constant *([a-zA-Z0-9_]*) *([A-Za-z0-9_]*)?/) {
+      my($const) = $1;
+      my($value) = $2;
+      my($res) = $missing;
+
+      # Remember that this name is allowed.
+      push @allow, $const;
+
+      # Generate a program to test for the availability of this constant.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      print TESTFILE "__typeof__ ($const) a = $const;\n";
+      close (TESTFILE);
+
+      $res = compiletest ($fnamebase, "Testing for constant $const",
+			  "NOT PRESENT", $res, 1);
+
+      if ($value ne "" && $res == 0) {
+	# Generate a program to test for the value of this constant.
+	open (TESTFILE, ">$fnamebase.c");
+	print TESTFILE "$prepend";
+	print TESTFILE "#include <$h>\n";
+	print TESTFILE "int main (void) { return $const != $value; }\n";
+	close (TESTFILE);
+
+	$res = runtest ($fnamebase, "Testing for value of constant $const",
+			"Constant \"$const\" has not the right value.", $res);
+      }
+    } elsif (/^constant *([a-zA-Z0-9_]*) *([A-Za-z0-9_]*)?/) {
+      my($const) = $1;
+      my($value) = $2;
+      my($res) = $missing;
+
+      # Remember that this name is allowed.
+      push @allow, $const;
+
+      # Generate a program to test for the availability of this constant.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      print TESTFILE "__typeof__ ($const) a = $const;\n";
+      close (TESTFILE);
+
+      $res = compiletest ($fnamebase, "Testing for constant $const",
+			  "Constant \"$const\" not available.", $res, 0);
+
+      if ($value ne "") {
+	# Generate a program to test for the value of this constant.
+	open (TESTFILE, ">$fnamebase.c");
+	print TESTFILE "$prepend";
+	print TESTFILE "#include <$h>\n";
+	print TESTFILE "int main (void) { return $const != $value; }\n";
+	close (TESTFILE);
+
+	$res = runtest ($fnamebase, "Testing for value of constant $const",
+			"Constant \"$const\" has not the right value.", $res);
+      }
+    } elsif (/^symbol *([a-zA-Z0-9_]*) *([A-Za-z0-9_]*)?/) {
+      my($symbol) = $1;
+      my($value) = $2;
+      my($res) = $missing;
+
+      # Remember that this name is allowed.
+      push @allow, $symbol;
+
+      # Generate a program to test for the availability of this constant.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      print TESTFILE "void foobarbaz (void) {\n";
+      print TESTFILE "__typeof__ ($symbol) a = $symbol;\n";
+      print TESTFILE "}\n";
+      close (TESTFILE);
+
+      $res = compiletest ($fnamebase, "Testing for symbol $symbol",
+			  "Symbol \"$symbol\" not available.", $res, 0);
+
+      if ($value ne "") {
+	# Generate a program to test for the value of this constant.
+	open (TESTFILE, ">$fnamebase.c");
+	print TESTFILE "$prepend";
+	print TESTFILE "#include <$h>\n";
+	print TESTFILE "int main (void) { return $symbol != $value; }\n";
+	close (TESTFILE);
+
+	$res = runtest ($fnamebase, "Testing for value of symbol $symbol",
+			"Symbol \"$symbol\" has not the right value.", $res);
+      }
+    } elsif (/^typed-constant *([a-zA-Z0-9_]*) *({([^}]*)}|([^ ]*)) *([A-Za-z0-9_]*)?/) {
+      my($const) = $1;
+      my($type) = "$3$4";
+      my($value) = $5;
+      my($res) = $missing;
+
+      # Remember that this name is allowed.
+      push @allow, $const;
+
+      # Generate a program to test for the availability of this constant.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      print TESTFILE "__typeof__ ($const) a = $const;\n";
+      close (TESTFILE);
+
+      $res = compiletest ($fnamebase, "Testing for constant $const",
+			  "Constant \"$const\" not available.", $res, 0);
+
+      # Test the types of the members.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      print TESTFILE "__typeof__ (($type) 0) a;\n";
+      print TESTFILE "extern __typeof__ ($const) a;\n";
+      close (TESTFILE);
+
+      compiletest ($fnamebase, "Testing for type of constant $const",
+		   "Constant \"$const\" does not have the correct type.",
+		   $res, 0);
+
+      if ($value ne "") {
+	# Generate a program to test for the value of this constant.
+	open (TESTFILE, ">$fnamebase.c");
+	print TESTFILE "$prepend";
+	print TESTFILE "#include <$h>\n";
+	print TESTFILE "int main (void) { return $const != $value; }\n";
+	close (TESTFILE);
+
+	$res = runtest ($fnamebase, "Testing for value of constant $const",
+			"Constant \"$const\" has not the right value.", $res);
+      }
+    } elsif (/^optional-type *({([^}]*)|([a-zA-Z0-9_]*))/) {
+      my($type) = "$2$3";
+      my($maybe_opaque) = 0;
+
+      # Remember that this name is allowed.
+      if ($type =~ /^struct *(.*)/) {
+	push @allow, $1;
+      } elsif ($type =~ /^union *(.*)/) {
+	push @allow, $1;
+      } else {
+	push @allow, $type;
+	$maybe_opaque = 1;
+      }
+
+      # Remember that this name is allowed.
+      push @allow, $type;
+
+      # Generate a program to test for the availability of this constant.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      if ($maybe_opaque == 1) {
+	print TESTFILE "$type *a;\n";
+      } else {
+	print TESTFILE "$type a;\n";
+      }
+      close (TESTFILE);
+
+      compiletest ($fnamebase, "Testing for type $type",
+		   "NOT AVAILABLE", $missing, 1);
+    } elsif (/^type *({([^}]*)|([a-zA-Z0-9_]*))/) {
+      my($type) = "$2$3";
+      my($maybe_opaque) = 0;
+
+      # Remember that this name is allowed.
+      if ($type =~ /^struct *(.*)/) {
+	push @allow, $1;
+      } elsif ($type =~ /^union *(.*)/) {
+	push @allow, $1;
+      } else {
+	push @allow, $type;
+	$maybe_opaque = 1;
+      }
+
+      # Remember that this name is allowed.
+      push @allow, $type;
+
+      # Generate a program to test for the availability of this type.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      if ($maybe_opaque == 1) {
+	print TESTFILE "$type *a;\n";
+      } else {
+	print TESTFILE "$type a;\n";
+      }
+      close (TESTFILE);
+
+      compiletest ($fnamebase, "Testing for type $type",
+		   "Type \"$type\" not available.", $missing, 0);
+    } elsif (/^optional-function *({([^}]*)}|([a-zA-Z0-9_]*)) [(][*]([a-zA-Z0-9_]*) ([(].*[)])/) {
+      my($rettype) = "$2$3";
+      my($fname) = "$4";
+      my($args) = "$5";
+      my($res) = $missing;
+
+      # Remember that this name is allowed.
+      push @allow, $fname;
+
+      # Generate a program to test for availability of this function.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      # print TESTFILE "#undef $fname\n";
+      print TESTFILE "$rettype (*(*foobarbaz) $args = $fname;\n";
+      close (TESTFILE);
+
+      $res = compiletest ($fnamebase, "Test availability of function $fname",
+			  "NOT AVAILABLE", $res, 1);
+
+      if ($res == 0 || $missing == 1) {
+	# Generate a program to test for the type of this function.
+	open (TESTFILE, ">$fnamebase.c");
+	print TESTFILE "$prepend";
+	print TESTFILE "#include <$h>\n";
+	# print TESTFILE "#undef $fname\n";
+	print TESTFILE "extern $rettype (*(*foobarbaz) $args;\n";
+	print TESTFILE "extern __typeof__ (&$fname) foobarbaz;\n";
+	close (TESTFILE);
+
+	compiletest ($fnamebase, "Test for type of function $fname",
+		     "Function \"$fname\" has incorrect type.", $res, 0);
+      }
+    } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) [(][*]([a-zA-Z0-9_]*) ([(].*[)])/) {
+      my($rettype) = "$2$3";
+      my($fname) = "$4";
+      my($args) = "$5";
+      my($res) = $missing;
+
+      # Remember that this name is allowed.
+      push @allow, $fname;
+
+      # Generate a program to test for availability of this function.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      # print TESTFILE "#undef $fname\n";
+      print TESTFILE "$rettype (*(*foobarbaz) $args = $fname;\n";
+      close (TESTFILE);
+
+      $res = compiletest ($fnamebase, "Test availability of function $fname",
+			  "Function \"$fname\" is not available.", $res, 0);
+
+      # Generate a program to test for the type of this function.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      # print TESTFILE "#undef $fname\n";
+      print TESTFILE "extern $rettype (*(*foobarbaz) $args;\n";
+      print TESTFILE "extern __typeof__ (&$fname) foobarbaz;\n";
+      close (TESTFILE);
+
+      compiletest ($fnamebase, "Test for type of function $fname",
+		   "Function \"$fname\" has incorrect type.", $res, 0);
+    } elsif (/^optional-function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
+      my($rettype) = "$2$3";
+      my($fname) = "$4";
+      my($args) = "$5";
+      my($res) = $missing;
+
+      # Remember that this name is allowed.
+      push @allow, $fname;
+
+      # Generate a program to test for availability of this function.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      # print TESTFILE "#undef $fname\n";
+      print TESTFILE "$rettype (*foobarbaz) $args = $fname;\n";
+      close (TESTFILE);
+
+      $res = compiletest ($fnamebase, "Test availability of function $fname",
+			  "NOT AVAILABLE", $res, 1);
+
+      if ($res == 0 || $missing != 0) {
+	# Generate a program to test for the type of this function.
+	open (TESTFILE, ">$fnamebase.c");
+	print TESTFILE "$prepend";
+	print TESTFILE "#include <$h>\n";
+	# print TESTFILE "#undef $fname\n";
+	print TESTFILE "extern $rettype (*foobarbaz) $args;\n";
+	print TESTFILE "extern __typeof__ (&$fname) foobarbaz;\n";
+	close (TESTFILE);
+
+	compiletest ($fnamebase, "Test for type of function $fname",
+		     "Function \"$fname\" has incorrect type.", $res, 0);
+      }
+    } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
+      my($rettype) = "$2$3";
+      my($fname) = "$4";
+      my($args) = "$5";
+      my($res) = $missing;
+
+      # Remember that this name is allowed.
+      push @allow, $fname;
+
+      # Generate a program to test for availability of this function.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      # print TESTFILE "#undef $fname\n";
+      print TESTFILE "$rettype (*foobarbaz) $args = $fname;\n";
+      close (TESTFILE);
+
+      $res = compiletest ($fnamebase, "Test availability of function $fname",
+			  "Function \"$fname\" is not available.", $res, 0);
+
+      # Generate a program to test for the type of this function.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      # print TESTFILE "#undef $fname\n";
+      print TESTFILE "extern $rettype (*foobarbaz) $args;\n";
+      print TESTFILE "extern __typeof__ (&$fname) foobarbaz;\n";
+      close (TESTFILE);
+
+      compiletest ($fnamebase, "Test for type of function $fname",
+		   "Function \"$fname\" has incorrect type.", $res, 0);
+    } elsif (/^variable *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) *(.*)/) {
+      my($type) = "$2$3";
+      my($vname) = "$4";
+      my($rest) = "$5";
+      my($res) = $missing;
+
+      # Remember that this name is allowed.
+      push @allow, $vname;
+
+      # Generate a program to test for availability of this function.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      # print TESTFILE "#undef $fname\n";
+      print TESTFILE "typedef $type xyzzy$rest;\n";
+      print TESTFILE "$xyzzy *foobarbaz = &$vname;\n";
+      close (TESTFILE);
+
+      $res = compiletest ($fnamebase, "Test availability of variable $vname",
+			  "Variable \"$vname\" is not available.", $res, 0);
+
+      # Generate a program to test for the type of this function.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      # print TESTFILE "#undef $fname\n";
+      print TESTFILE "extern $type $vname$rest;\n";
+      close (TESTFILE);
+
+      compiletest ($fnamebase, "Test for type of variable $fname",
+		   "Variable \"$vname\" has incorrect type.", $res, 0);
+    } elsif (/^macro-function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
+      my($rettype) = "$2$3";
+      my($fname) = "$4";
+      my($args) = "$5";
+      my($res) = $missing;
+
+      # Remember that this name is allowed.
+      push @allow, $fname;
+
+      # Generate a program to test for availability of this function.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      print TESTFILE "#ifndef $fname\n";
+      print TESTFILE "$rettype (*foobarbaz) $args = $fname;\n";
+      print TESTFILE "#endif\n";
+      close (TESTFILE);
+
+      $res = compiletest ($fnamebase, "Test availability of function $fname",
+			  "Function \"$fname\" is not available.", $res, 0);
+
+      # Generate a program to test for the type of this function.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      print TESTFILE "#ifndef $fname\n";
+      print TESTFILE "extern $rettype (*foobarbaz) $args;\n";
+      print TESTFILE "extern __typeof__ (&$fname) foobarbaz;\n";
+      print TESTFILE "#endif\n";
+      close (TESTFILE);
+
+      compiletest ($fnamebase, "Test for type of function $fname",
+		   "Function \"$fname\" has incorrect type.", $res, 0);
+    } elsif (/^macro-str *([^	 ]*) *(\".*\")/) {
+      # The above regex doesn't handle a \" in a string.
+      my($macro) = "$1";
+      my($string) = "$2";
+      my($res) = $missing;
+
+      # Remember that this name is allowed.
+      push @allow, $macro;
+
+      # Generate a program to test for availability of this macro.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      print TESTFILE "#ifndef $macro\n";
+      print TESTFILE "# error \"Macro $macro not defined\"\n";
+      print TESTFILE "#endif\n";
+      close (TESTFILE);
+
+      compiletest ($fnamebase, "Test availability of macro $macro",
+		   "Macro \"$macro\" is not available.", $missing, 0);
+
+      # Generate a program to test for the value of this macro.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      # We can't include <string.h> here.
+      print TESTFILE "extern int (strcmp)(const char *, const char *);\n";
+      print TESTFILE "int main (void) { return (strcmp) ($macro, $string) != 0;}\n";
+      close (TESTFILE);
+
+      $res = runtest ($fnamebase, "Testing for value of macro $macro",
+		      "Macro \"$macro\" has not the right value.", $res);
+    } elsif (/^optional-macro *([^	]*)/) {
+      my($macro) = "$1";
+
+      # Remember that this name is allowed.
+      push @allow, $macro;
+
+      # Generate a program to test for availability of this macro.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      print TESTFILE "#ifndef $macro\n";
+      print TESTFILE "# error \"Macro $macro not defined\"\n";
+      print TESTFILE "#endif\n";
+      close (TESTFILE);
+
+      compiletest ($fnamebase, "Test availability of macro $macro",
+		   "NOT PRESENT", $missing, 1);
+    } elsif (/^macro *([a-zA-Z0-9_]*) *([>=<]+) ([A-Za-z0-9_]*)/) {
+      my($macro) = "$1";
+      my($op) = $2;
+      my($value) = $3;
+      my($res) = $missing;
+
+      # Remember that this name is allowed.
+      push @allow, $macro;
+
+      # Generate a program to test for availability of this macro.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      print TESTFILE "#ifndef $macro\n";
+      print TESTFILE "# error \"Macro $macro not defined\"\n";
+      print TESTFILE "#endif\n";
+      close (TESTFILE);
+
+      $res = compiletest ($fnamebase, "Test availability of macro $macro",
+			  "Macro \"$macro\" is not available.", $res, 0);
+
+      if ($value ne "") {
+	# Generate a program to test for the value of this constant.
+	open (TESTFILE, ">$fnamebase.c");
+	print TESTFILE "$prepend";
+	print TESTFILE "#include <$h>\n";
+	# Negate the value since 0 means ok
+	print TESTFILE "int main (void) { return !($macro $op $value); }\n";
+	close (TESTFILE);
+
+	$res = runtest ($fnamebase, "Testing for value of constant $macro",
+			"Macro \"$macro\" has not the right value.", $res);
+      }
+    } elsif (/^macro *([^	]*)/) {
+      my($macro) = "$1";
+
+      # Remember that this name is allowed.
+      push @allow, $macro;
+
+      # Generate a program to test for availability of this macro.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      print TESTFILE "#ifndef $macro\n";
+      print TESTFILE "# error \"Macro $macro not defined\"\n";
+      print TESTFILE "#endif\n";
+      close (TESTFILE);
+
+      compiletest ($fnamebase, "Test availability of macro $macro",
+		   "Macro \"$macro\" is not available.", $missing, 0);
+    } elsif (/^allow-header *(.*)/) {
+      my($pattern) = $1;
+      if ($seenheader{$pattern} != 1) {
+	push @allowheader, $pattern;
+	$seenheader{$pattern} = 1;
+      }
+      next control;
+    } elsif (/^allow *(.*)/) {
+      my($pattern) = $1;
+      push @allow, $pattern;
+      next control;
+    } else {
+      # printf ("line is `%s'\n", $_);
+      next control;
+    }
+
+    printf ("\n");
+  }
+  close (CONTROL);
+
+  # Read the data files for the header files which are allowed to be included.
+  while ($#allowheader >= 0) {
+    my($ah) = pop @allowheader;
+
+    open (ALLOW, "$CC -E -D$dialect - < data/$ah-data |");
+    acontrol: while (<ALLOW>) {
+      next acontrol if (/^#/);
+      next acontrol if (/^[	]*$/);
+
+      if (/^element *({([^}]*)}|([^ ]*)) *({([^}]*)}|([^ ]*)) *([A-Za-z0-9_]*) *(.*)/) {
+	push @allow, $7;
+      } elsif (/^constant *([a-zA-Z0-9_]*) *([A-Za-z0-9_]*)?/) {
+	push @allow, $1;
+      } elsif (/^typed-constant *([a-zA-Z0-9_]*) *({([^}]*)}|([^ ]*)) *([A-Za-z0-9_]*)?/) {
+	push @allow, 1;
+      } elsif (/^type *({([^}]*)|([a-zA-Z0-9_]*))/) {
+	my($type) = "$2$3";
+
+	# Remember that this name is allowed.
+	if ($type =~ /^struct *(.*)/) {
+	  push @allow, $1;
+	} elsif ($type =~ /^union *(.*)/) {
+	  push @allow, $1;
+	} else {
+	  push @allow, $type;
+	}
+      } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) [(][*]([a-zA-Z0-9_]*) ([(].*[)])/) {
+	push @allow, $4;
+      } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
+	push @allow, $4;
+      } elsif (/^variable *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*)/) {
+	push @allow, $4;
+      } elsif (/^macro-function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
+	push @allow, $4;
+      } elsif (/^macro *([^	]*)/) {
+	push @allow, $1;
+      } elsif (/^allow-header *(.*)/) {
+	if ($seenheader{$1} != 1) {
+	  push @allowheader, $1;
+	  $seenheader{$1} = 1;
+	}
+      } elsif (/^allow *(.*)/) {
+	push @allow, $1;
+      }
+    }
+    close (ALLOW);
+  }
+
+  # Now check the namespace.
+  printf ("  Checking the namespace of \"%s\"... ", $h);
+  if ($missing) {
+    ++$skipped;
+    printf ("SKIP\n");
+  } else {
+    checknamespace ($h, $fnamebase, @allow);
+  }
+
+  printf ("\n\n");
+}
+
+printf "-" x 76 . "\n";
+printf ("  Total number of tests   : %4d\n", $total);
+
+printf ("  Number of known failures: %4d (", $known);
+$percent = ($known * 100) / $total;
+if ($known > 0 && $percent < 1.0) {
+  printf (" <1%%)\n");
+} else {
+  printf ("%3d%%)\n", $percent);
+}
+
+printf ("  Number of failed tests  : %4d (", $errors);
+$percent = ($errors * 100) / $total;
+if ($errors > 0 && $percent < 1.0) {
+  printf (" <1%%)\n");
+} else {
+  printf ("%3d%%)\n", $percent);
+}
+
+printf ("  Number of skipped tests : %4d (", $skipped);
+$percent = ($skipped * 100) / $total;
+if ($skipped > 0 && $percent < 1.0) {
+  printf (" <1%%)\n");
+} else {
+  printf ("%3d%%)\n", $percent);
+}
+
+exit $errors != 0;
Index: trunk/src/libctests/glibc/conform/data/aio.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/aio.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/aio.h-data	(revision 2036)
@@ -0,0 +1,43 @@
+#ifndef ISO
+type {struct aiocb}
+
+// Test elements of the AIO control struct.
+element {struct aiocb} int aio_fildes
+element {struct aiocb} off_t aio_offset
+element {struct aiocb} {volatile void*} aio_buf
+element {struct aiocb} size_t aio_nbytes
+element {struct aiocb} int aio_reqprio
+element {struct aiocb} {struct sigevent} aio_sigevent
+element {struct aiocb} int aio_lio_opcode
+
+constant AIO_CANCELED
+constant AIO_NOTCANCELED
+constant AIO_ALLDONE
+constant LIO_WAIT
+constant LIO_NOWAIT
+constant LIO_READ
+constant LIO_WRITE
+constant LIO_NOP
+
+function int aio_cancel (int, struct aiocb*)
+function int aio_error (const struct aiocb*)
+function int aio_fsync (int, struct aiocb*)
+function int aio_read (struct aiocb*)
+function ssize_t aio_return (struct aiocb*)
+function int aio_suspend (const struct aiocb* const[], int, const struct timespec*)
+function int aio_write (struct aiocb*)
+function int lio_listio (int, struct aiocb *const[], int, struct sigevent*)
+
+# if !defined POSIX
+allow-header fcntl.h
+allow-header signal.h
+allow-header sys/types.h
+allow-header time.h
+# endif
+
+allow aio_*
+allow lio_*
+allow AIO_*
+allow LIO_*
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/arpa/inet.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/arpa/inet.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/arpa/inet.h-data	(revision 2036)
@@ -0,0 +1,31 @@
+#if !defined ISO && !defined POSIX
+// in_port_t should have exactly 16 bits
+type in_port_t
+// in_addr_t should have exactly 32 bits
+type in_addr_t
+
+type uint32_t
+type uint16_t
+
+macro INET_ADDRSTRLEN
+macro INET6_ADDRSTRLEN
+
+// The following can be declared as functions, defined as macros or both:
+function uint32_t htonl (uint32_t);
+function uint16_t htons (uint16_t);
+function uint32_t ntohl (uint32_t);
+function uint16_t htons (uint16_t);
+
+function in_addr_t inet_addr (const char*);
+function in_addr_t inet_lnaof (struct in_addr);
+function {struct in_addr} inet_makeaddr (in_addr_t, in_addr_t);
+function in_addr_t inet_netof (struct in_addr);
+function in_addr_t inet_network (const char *);
+function {char*} inet_ntoa (struct in_addr);
+function {const char*} inet_ntop (int, const void*, char*, socklen_t);
+function int inet_pton (int, const char*, void*);
+
+allow-header netinet/in.h
+allow-header inttypes.h
+
+#endif
Index: trunk/src/libctests/glibc/conform/data/assert.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/assert.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/assert.h-data	(revision 2036)
@@ -0,0 +1,3 @@
+macro assert
+
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/complex.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/complex.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/complex.h-data	(revision 2036)
@@ -0,0 +1,76 @@
+#ifdef XOPEN2K
+macro complex
+macro _Complex_I
+optional-macro imaginary
+optional-macro _Imaginary_I
+macro I
+
+function double cabs (double complex)
+function {double complex} cacos (double complex)
+function {double complex} cacosh (double complex)
+function double carg (double complex)
+function {double complex} casin (double complex)
+function {double complex} casinh (double complex)
+function {double complex} catan (double complex)
+function {double complex} catanh (double complex)
+function {double complex} ccos (double complex)
+function {double complex} ccosh (double complex)
+function {double complex} cexp (double complex)
+function double cimag (double complex)
+function {double complex} clog (double complex)
+function {double complex} conj (double complex)
+function {double complex} cpow (double complex, double complex)
+function {double complex} cproj (double complex)
+function double creal (double complex)
+function {double complex} csin (double complex)
+function {double complex} csinh (double complex)
+function {double complex} csqrt (double complex)
+function {double complex} ctan (double complex)
+function {double complex} ctanh (double complex)
+
+function float cabsf (float complex)
+function {float complex} cacosf (float complex)
+function {float complex} cacoshf (float complex)
+function float cargf (float complex)
+function {float complex} casinf (float complex)
+function {float complex} casinhf (float complex)
+function {float complex} catanf (float complex)
+function {float complex} catanhf (float complex)
+function {float complex} ccosf (float complex)
+function {float complex} ccoshf (float complex)
+function {float complex} cexpf (float complex)
+function float cimagf (float complex)
+function {float complex} clogf (float complex)
+function {float complex} conjf (float complex)
+function {float complex} cpowf (float complex, float complex)
+function {float complex} cprojf (float complex)
+function float crealf (float complex)
+function {float complex} csinf (float complex)
+function {float complex} csinhf (float complex)
+function {float complex} csqrtf (float complex)
+function {float complex} ctanf (float complex)
+function {float complex} ctanhf (float complex)
+
+function {long double} cabsl (long double complex)
+function {long double complex} cacosl (long double complex)
+function {long double complex} cacoshl (long double complex)
+function {long double} cargl (long double complex)
+function {long double complex} casinhl (long double complex)
+function {long double complex} casinl (long double complex)
+function {long double complex} catanhl (long double complex)
+function {long double complex} catanl (long double complex)
+function {long double complex} ccoshl (long double complex)
+function {long double complex} ccosl (long double complex)
+function {long double complex} cexpl (long double complex)
+function {long double} cimagl (long double complex)
+function {long double complex} clogl (long double complex)
+function {long double complex} conjl (long double complex)
+function {long double complex} cpowl (long double complex, long double complex)
+function {long double complex} cprojl (long double complex)
+function {long double} creall (long double complex)
+function {long double complex} csinhl (long double complex)
+function {long double complex} csinl (long double complex)
+function {long double complex} csqrtl (long double complex)
+function {long double complex} ctanhl (long double complex)
+function {long double complex} ctanl (long double complex)
+#endif
Index: trunk/src/libctests/glibc/conform/data/cpio.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/cpio.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/cpio.h-data	(revision 2036)
@@ -0,0 +1,26 @@
+#ifndef ISO
+constant C_IRUSR 0000400
+constant C_IWUSR 0000200
+constant C_IXUSR 0000100
+constant C_IRGRP 0000040
+constant C_IWGRP 0000020
+constant C_IXGRP 0000010
+constant C_IROTH 0000004
+constant C_IWOTH 0000002
+constant C_IXOTH 0000001
+constant C_ISUID 0004000
+constant C_ISGID 0002000
+constant C_ISVTX 0001000
+constant C_ISDIR 0040000
+constant C_ISFIFO 0010000
+constant C_ISREG 0100000
+constant C_ISBLK 0060000
+constant C_ISCHR 0020000
+constant C_ISCTG 0110000
+constant C_ISLNK 0120000
+constant C_ISSOCK 0140000
+
+macro-str MAGIC "070707"
+
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/ctype.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/ctype.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/ctype.h-data	(revision 2036)
@@ -0,0 +1,29 @@
+function int isalnum (int)
+function int isalpha (int)
+function int iscntrl (int)
+function int isdigit (int)
+function int isgraph (int)
+function int islower (int)
+function int isprint (int)
+function int ispunct (int)
+function int isspace (int)
+function int isupper (int)
+function int isxdigit (int)
+function int tolower (int)
+function int toupper (int)
+
+#ifndef ISO
+function int isascii (int)
+function int toascii (int)
+
+// XPG says the following two are macros.  But we test a bit more strictly.
+function int _toupper (int)
+function int _tolower (int)
+
+// The following is not entirely correct.  It should be is[a-z]* but the
+// replacement fnmatch implementation does not grok it.
+allow is*
+allow to*
+
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/dirent.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/dirent.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/dirent.h-data	(revision 2036)
@@ -0,0 +1,21 @@
+#ifndef ISO
+type DIR
+
+type {struct dirent}
+
+element {struct dirent} ino_t d_ino
+element {struct dirent} char d_name []
+
+type ino_t
+
+function int closedir (DIR*)
+function {DIR*} opendir (const char*)
+function {struct dirent*} readdir (DIR*)
+function int readdir_r (DIR*, struct dirent*, struct dirent**)
+function void rewinddir (DIR*)
+function void seekdir (DIR*, long int)
+function {long int} telldir (DIR*)
+
+allow d_*
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/dlfcn.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/dlfcn.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/dlfcn.h-data	(revision 2036)
@@ -0,0 +1,14 @@
+#if !defined ISO && !defined POSIX
+macro RTLD_LAZY
+macro RTLD_NOW
+macro RTLD_GLOBAL
+macro RTLD_LOCAL
+
+function {void*} dlopen (const char*, int)
+function {void*} dlsym (void *, const char*)
+function int dlclose (void*)
+function {char*} dlerror (void)
+
+allow *_t
+allow RTLD_*
+#endif
Index: trunk/src/libctests/glibc/conform/data/errno.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/errno.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/errno.h-data	(revision 2036)
@@ -0,0 +1,87 @@
+constant EDOM
+constant EILSEQ
+constant ERANGE
+
+#ifndef ISO
+constant E2BIG
+constant EACCES
+constant EADDRINUSE
+constant EADDRNOTAVAIL
+constant EAFNOSUPPORT
+constant EAGAIN
+constant EALREADY
+constant EBADF
+constant EBADMSG
+constant EBUSY
+constant ECANCELED
+constant ECHILD
+constant ECONNABORTED
+constant ECONNREFUSED
+constant ECONNRESET
+constant EDEADLK
+constant EDESTADDRREQ
+constant EDQUOT
+constant EEXIST
+constant EFAULT
+constant EFBIG
+constant EHOSTUNREACH
+constant EIDRM
+constant EINPROGRESS
+constant EINTR
+constant EINVAL
+constant EIO
+constant EISCONN
+constant EISDIR
+constant ELOOP
+constant EMFILE
+constant EMLINK
+constant EMSGSIZE
+constant EMULTIHOP
+constant ENAMETOOLONG
+constant ENETDOWN
+constant ENETUNREACH
+constant ENFILE
+constant ENOBUFS
+constant ENODATA
+constant ENODEV
+constant ENOENT
+constant ENOEXEC
+constant ENOLCK
+constant ENOLINK
+constant ENOMEM
+constant ENOMSG
+constant ENOPROTOOPT
+constant ENOSPC
+constant ENOSR
+constant ENOSTR
+constant ENOSYS
+constant ENOTCONN
+constant ENOTDIR
+constant ENOTEMPTY
+constant ENOTSOCK
+constant ENOTSUP
+constant ENOTTY
+constant ENXIO
+constant EOPNOTSUPP
+constant EOVERFLOW
+constant EPERM
+constant EPIPE
+constant EPROTO
+constant EPROTONOSUPPORT
+constant EPROTOTYPE
+constant EROFS
+constant ESPIPE
+constant ESRCH
+constant ESTALE
+constant ETIME
+constant ETIMEDOUT
+constant ETXTBSY
+constant EWOULDBLOCK
+constant EXDEV
+
+// variable int errno
+allow errno
+
+allow E*
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/fcntl.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/fcntl.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/fcntl.h-data	(revision 2036)
@@ -0,0 +1,102 @@
+#if !defined ISO && !defined POSIX
+constant F_DUPFD
+constant F_GETFD
+constant F_SETFD
+constant F_GETFL
+constant F_SETFL
+constant F_GETLK
+constant F_SETLK
+constant F_SETLKW
+constant F_GETOWN
+constant F_SETOWN
+
+constant FD_CLOEXEC
+
+constant F_RDLCK
+constant F_UNLCK
+constant F_WRLCK
+
+constant SEEK_SET
+constant SEEK_CUR
+constant SEEK_END
+
+constant O_CREAT
+constant O_EXCL
+constant O_NOCTTY
+constant O_TRUNC
+
+constant O_APPEND
+constant O_DSYNC
+constant O_NONBLOCK
+constant O_RSYNC
+constant O_SYNC
+
+constant O_ACCMODE
+
+constant O_RDONLY
+constant O_RDWR
+constant O_WRONLY
+
+constant S_IFMT
+constant S_IFBLK
+constant S_IFCHR
+constant S_IFIFO
+constant S_IFREG
+constant S_IFDIR
+constant S_IFLNK
+constant S_IFSOCK
+
+constant S_IRWXU
+constant S_IRUSR
+constant S_IWUSR
+constant S_IXUSR
+constant S_IRWXG
+constant S_IRGRP
+constant S_IWGRP
+constant S_IXGRP
+constant S_IRWXO
+constant S_IROTH
+constant S_IWOTH
+constant S_IXOTH
+constant S_ISUID
+constant S_ISGID
+constant S_ISVTX
+
+#ifdef XOPEN2K
+constant POSIX_FADV_NORMAL
+constant POSIX_FADV_SEQUENTIAL
+constant POSIX_FADV_RANDOM
+constant POSIX_FADV_WILLNEED
+constant POSIX_FADV_DONTNEED
+constant POSIX_FADV_NOREUSE
+#endif
+
+type {struct flock}
+
+element {struct flock} short l_type
+element {struct flock} short l_whence
+element {struct flock} off_t l_start
+element {struct flock} off_t l_len
+element {struct flock} pid_t l_pid
+
+type mode_t
+type off_t
+type pid_t
+
+function int creat (const char*, mode_t)
+function int fcntl (int, int, ...)
+function int open (const char*, int, ...)
+#ifdef XOPEN2K
+function int posix_fadvise (int, off_t, size_t, int)
+function int posix_fallocate (int, off_t, size_t)
+#endif
+
+allow-header sys/stat.h
+allow-header unistd.h
+
+allow l_*
+allow F_*
+allow O_*
+allow S_*
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/float.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/float.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/float.h-data	(revision 2036)
@@ -0,0 +1,41 @@
+macro FLT_RADIX
+
+constant FLT_ROUNDS
+
+macro FLT_MANT_DIG
+macro DBL_MANT_DIG
+macro LDBL_MANT_DIG
+
+constant FLT_DIG >= 6
+constant DBL_DIG >= 10
+constant LDBL_DIG >= 10
+
+macro FLT_MIN_EXP
+macro DBL_MIN_EXP
+macro LDBL_MIN_EXP
+
+constant FLT_MIN_10_EXP <= -37
+constant DBL_MIN_10_EXP <= -37
+constant LDBL_MIN_10_EXP <= -37
+
+macro FLT_MAX_EXP
+macro DBL_MAX_EXP
+macro LDBL_MAX_EXP
+
+constant FLT_MAX_10_EXP >= 37
+constant DBL_MAX_10_EXP >= 37
+constant LDBL_MAX_10_EXP >= 37
+
+constant FLT_MAX >= 1.0E37
+constant DBL_MAX >= 1.0E37
+constant LDBL_MAX >= 1.0E37
+
+macro FLT_EPSILON
+macro DBL_EPSILON
+macro LDBL_EPSILON
+
+macro FLT_MIN
+macro DBL_MIN
+macro LDBL_MIN
+
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/fmtmsg.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/fmtmsg.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/fmtmsg.h-data	(revision 2036)
@@ -0,0 +1,62 @@
+#if !defined ISO && !defined POSIX
+macro MM_HARD
+constant MM_HARD
+
+macro MM_SOFT
+constant MM_SOFT
+
+macro MM_FIRM
+constant MM_FIRM
+
+macro MM_APPL
+constant MM_APPL
+
+macro MM_UTIL
+constant MM_UTIL
+
+macro MM_OPSYS
+constant MM_OPSYS
+
+macro MM_RECOVER
+constant MM_RECOVER
+
+macro MM_NRECOV
+constant MM_NRECOV
+
+macro MM_HALT
+constant MM_HALT
+
+macro MM_ERROR
+constant MM_ERROR
+
+macro MM_WARNING
+constant MM_WARNING
+
+macro MM_INFO
+constant MM_INFO
+
+macro MM_NOSEV
+constant MM_NOSEV
+
+macro MM_PRINT
+constant MM_PRINT
+
+macro MM_CONSOLE
+constant MM_CONSOLE
+
+constant MM_NULLLBL 0
+constant MM_NULLSEV 0
+constant MM_NULLMC 0
+constant MM_NULLTXT 0
+constant MM_NULLACT 0
+constant MM_NULLTAG 0
+
+macro MM_OK
+macro MM_NOTOK
+macro MM_NOMSG
+macro MM_NOCON
+
+function int fmtmsg (long, const char*, int, const char*, const char*, const char*)
+
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/fnmatch.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/fnmatch.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/fnmatch.h-data	(revision 2036)
@@ -0,0 +1,12 @@
+#ifndef ISO
+constant FNM_NOMATCH
+constant FNM_PATHNAME
+constant FNM_PERIOD
+constant FNM_NOESCAPE
+constant FNM_NOSYS
+
+function int fnmatch (const char*, const char*, int)
+
+allow FNM_*
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/ftw.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/ftw.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/ftw.h-data	(revision 2036)
@@ -0,0 +1,25 @@
+#if !defined ISO && !defined POSIX
+type {struct FTW}
+element {struct FTW} int base
+element {struct FTW} int level
+
+macro FTW_F
+macro FTW_D
+macro FTW_DNR
+macro FTW_DP
+macro FTW_NS
+macro FTW_SL
+macro FTW_SLN
+
+macro FTW_PHYS
+macro FTW_MOUNT
+macro FTW_DEPTH
+macro FTW_CHDIR
+
+function int ftw (const char*, int (*) (const char *, const struct stat*, int), int)
+function int nftw (const char*, int (*) (const char *, const struct stat*, int, struct FTW *), int, int)
+
+allow-header sys/stat.h
+
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/glob.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/glob.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/glob.h-data	(revision 2036)
@@ -0,0 +1,26 @@
+#ifndef ISO
+type glob_t
+element glob_t size_t gl_pathc
+element glob_t {char**} gl_pathv
+element glob_t size_t gl_offs
+
+constant GLOB_APPEND
+constant GLOB_DOOFFS
+constant GLOB_ERR
+constant GLOB_MARK
+constant GLOB_NOCHECK
+constant GLOB_NOESCAPE
+constant GLOB_NOSORT
+
+constant GLOB_ABORTED
+constant GLOB_NOMATCH
+constant GLOB_NOSPACE
+constant GLOB_NOSYS
+
+function int glob (const char*, int, int (*) (const char*, int), glob_t*)
+function void globfree (glob_t *)
+
+allow gl_*
+allow GLOB_*
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/grp.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/grp.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/grp.h-data	(revision 2036)
@@ -0,0 +1,23 @@
+#ifndef ISO
+type {struct group}
+element {struct group} {char*} gr_name
+element {struct group} gid_t gr_gid
+element {struct group} {char**} gr_mem
+
+# ifndef POSIX
+type gid_t
+# endif
+
+function {struct group*} getgrgid (gid_t)
+function {struct group*} getgrnam (const char*)
+# ifndef POSIX
+function int getgrgid_r (gid_t, struct group*, char *, size_t, struct group**)
+function int getgrnam_r (const char *, struct group *, char *, size_t, struct group**)
+function {struct group*} getgrent (void)
+function void endgrent (void)
+function void setgrent (void)
+# endif
+
+allow gr_*
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/iconv.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/iconv.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/iconv.h-data	(revision 2036)
@@ -0,0 +1,9 @@
+#if !defined ISO && !defined POSIX
+type iconv_t
+
+function iconv_t iconv_open (const char*, const char*)
+function size_t iconv (iconv_t, char**, size_t*, char**, size_t*)
+function int iconv_close (iconv_t)
+
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/inttypes.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/inttypes.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/inttypes.h-data	(revision 2036)
@@ -0,0 +1,141 @@
+type int8_t
+type int16_t
+type int32_t
+type int64_t
+type uint8_t
+type uint16_t
+type uint32_t
+type uint64_t
+type intptr_t
+type uintptr_t
+
+type imaxdiv_t
+element imaxdiv_t intmax_t rem
+element imaxdiv_t intmax_t quot
+
+function intmax_t imaxabs (intmax_t)
+function imaxdiv_t imaxdiv (intmax_t, intmax_t)
+function intmax_t strtoimax (const char*, char**, int)
+function uintmax_t strtoumax (const char*, char**, int)
+function intmax_t wcstoimax (const wchar_t*, wchar_t**, int)
+function uintmax_t wcstoumax (const wchar_t*, wchar_t**, int)
+
+allow PRI*
+allow SCN*
+allow *_t
+
+// Now the content of <stdint.h>.  Update this whenever <stdint.h> changed.
+type int8_t
+type int16_t
+type int32_t
+type int64_t
+type uint8_t
+type uint16_t
+type uint32_t
+type uint64_t
+
+type int_least8_t
+type int_least16_t
+type int_least32_t
+type int_least64_t
+type uint_least8_t
+type uint_least16_t
+type uint_least32_t
+type uint_least64_t
+
+type int_fast8_t
+type int_fast16_t
+type int_fast32_t
+type int_fast64_t
+type uint_fast8_t
+type uint_fast16_t
+type uint_fast32_t
+type uint_fast64_t
+
+type intptr_t
+type uintptr_t
+
+type intmax_t
+type uintmax_t
+
+constant INT8_MIN == -128
+constant INT8_MAX == 127
+constant INT16_MIN == -32768
+constant INT16_MAX == 32767
+constant INT32_MIN == -2147483647-1
+constant INT32_MAX == 2147483647
+constant INT64_MIN == -9223372036854775807LL-1
+constant INT64_MAX == 9223372036854775807LL
+
+constant UINT8_MAX == 255
+constant UINT16_MAX == 65535
+constant UINT32_MAX == 4294967295U
+constant UINT64_MAX == 18446744073709551615ULL
+
+constant INT_LEAST8_MIN <= -128
+constant INT_LEAST8_MAX >= 127
+constant INT_LEAST16_MIN <= -32768
+constant INT_LEAST16_MAX >= 32767
+constant INT_LEAST32_MIN <= -2147483647-1
+constant INT_LEAST32_MAX >= 2147483647
+constant INT_LEAST64_MIN <= -9223372036854775807LL-1
+constant INT_LEAST64_MAX >= 9223372036854775807LL
+
+constant UINT_LEAST8_MAX >= 255
+constant UINT_LEAST16_MAX >= 65535
+constant UINT_LEAST32_MAX >= 4294967295U
+constant UINT_LEAST64_MAX >= 18446744073709551615ULL
+
+constant INT_FAST8_MIN <= -128
+constant INT_FAST8_MAX >= 127
+constant INT_FAST16_MIN <= -32768
+constant INT_FAST16_MAX >= 32767
+constant INT_FAST32_MIN <= -2147483647-1
+constant INT_FAST32_MAX >= 2147483647
+constant INT_FAST64_MIN <= -9223372036854775807LL-1
+constant INT_FAST64_MAX >= 9223372036854775807LL
+
+constant UINT_FAST8_MAX >= 255
+constant UINT_FAST16_MAX >= 65535
+constant UINT_FAST32_MAX >= 4294967295U
+constant UINT_FAST64_MAX >= 18446744073709551615ULL
+
+constant INTPTR_MIN <= -32768
+constant INTPTR_MAX >= 32767
+
+constant UINTPTR_MAX >= 65535
+
+constant INTMAX_MIN <= -9223372036854775807LL-1
+constant INTMAX_MAX >= 9223372036854775807LL
+
+constant UINTMAX_MAX >= 18446744073709551615ULL
+
+constant PTRDIFF_MIN <= -65535
+constant PTRDIFF_MAX >= 65535
+
+constant SIG_ATOMIC_MIN <= -127
+constant SIG_ATOMIC_MAX >= 127
+
+constant SIZE_MAX >= 65535
+
+constant WCHAR_MIN <= -127
+constant WCHAR_MAX >= 127
+
+constant WINT_MIN <= -127
+constant WINT_MAX >= 127
+
+macro INT8_C
+macro INT16_C
+macro INT32_C
+macro INT64_C
+macro UINT8_C
+macro UINT16_C
+macro UINT32_C
+macro UINT64_C
+macro INTMAX_C
+macro UINTMAX_C
+
+// The following expressions are not entirely correct but the current
+// fnamtch implementation doesn't grok the right form.
+allow INT*
+allow UINT*
Index: trunk/src/libctests/glibc/conform/data/iso646.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/iso646.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/iso646.h-data	(revision 2036)
@@ -0,0 +1,13 @@
+macro and
+macro and_eq
+macro bitand
+macro bitor
+macro compl
+macro not
+macro not_eq
+macro or
+macro or_eq
+macro xor
+macro xor_eq
+
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/langinfo.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/langinfo.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/langinfo.h-data	(revision 2036)
@@ -0,0 +1,63 @@
+#if !defined ISO && !defined POSIX
+constant CODESET
+constant D_T_FMT
+constant D_FMT
+constant T_FMT
+constant T_FMT_AMPM
+constant AM_STR
+constant PM_STR
+constant DAY_1
+constant DAY_2
+constant DAY_3
+constant DAY_4
+constant DAY_5
+constant DAY_6
+constant DAY_7
+constant ABDAY_1
+constant ABDAY_2
+constant ABDAY_3
+constant ABDAY_4
+constant ABDAY_5
+constant ABDAY_6
+constant ABDAY_7
+constant MON_1
+constant MON_2
+constant MON_3
+constant MON_4
+constant MON_5
+constant MON_6
+constant MON_7
+constant MON_8
+constant MON_9
+constant MON_10
+constant MON_11
+constant MON_12
+constant ABMON_1
+constant ABMON_2
+constant ABMON_3
+constant ABMON_4
+constant ABMON_5
+constant ABMON_6
+constant ABMON_7
+constant ABMON_8
+constant ABMON_9
+constant ABMON_10
+constant ABMON_11
+constant ABMON_12
+constant ERA
+constant ERA_D_FMT
+constant ERA_D_T_FMT
+constant ERA_T_FMT
+constant ALT_DIGITS
+constant RADIXCHAR
+constant THOUSEP
+constant YESEXPR
+constant NOEXPR
+constant CRNCYSTR
+
+function {char*} nl_langinfo (nl_item)
+
+allow-header nl_types.h
+
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/libgen.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/libgen.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/libgen.h-data	(revision 2036)
@@ -0,0 +1,6 @@
+#if !defined ISO && !defined POSIX
+function {char*} basename (char*)
+function {char*} dirname (char*)
+
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/limits.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/limits.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/limits.h-data	(revision 2036)
@@ -0,0 +1,128 @@
+// if these values exist, we should check the minimal value
+allow AIO_LIST_MAX
+allow AIO_MAX
+allow AIO_PRIO_DELTA_MAX
+allow ARG_MAX
+allow ATEXT_MAX
+allow CHILD_MAX
+allow DELAYTIMER_MAX
+allow IOV_MAX
+allow LOGIN_NAME_MAX
+allow MQ_OPEN_MAX
+allow OPEN_MAX
+allow PAGESIZE
+allow PAGE_SIZE
+allow PTHREAD_DESTRUCTOR_ITERATIONS
+allow PTHREAD_KEYS_MAX
+allow PTHREAD_STACK_MIN
+allow PTHREAD_THREADS_MAX
+allow RE_DUP_MAX
+allow RTSIG_MAX
+allow SEM_NSEMS_MAX
+allow SEM_VALUE_MAX
+allow SIGQUEUE_MAX
+allow SS_REPL_MAX
+allow STREAM_MAX
+allow SYMLOOP_MAX
+allow TIMER_MAX
+allow TTY_NAME_MAX
+allow TZNAME_MAX
+
+allow FILESIZEBITS
+allow LINK_MAX
+allow MAX_CANON
+allow MAX_INPUT
+allow NAME_MAX
+allow PATH_MAX
+allow PIPE_BUF
+allow POSIX_ALLOC_SIZE_MIN
+allow POSIX_REC_INCR_XFER_SIZE
+allow POSIX_REC_MAX_XFER_SIZE
+allow POSIX_REC_XFER_ALIGN
+allow SYMLINK_MAX
+
+macro BC_BASE_MAX
+macro BC_DIM_MAX
+macro BC_SCALE_MAX
+macro BC_STRING_MAX
+macro CHARCLASS_NAME_MAX
+macro COLL_WEIGHTS_MAX
+macro EXPR_NEST_MAX
+macro LINE_MAX
+constant NGROUPS_MAX >= 8
+macro RE_DUP_MAX
+
+constant _POSIX_CLOCKRES_MIN <= 20000000
+
+optional-constant _POSIX_AIO_LISTIO_MAX	2
+optional-constant _POSIX_AIO_MAX 1
+optional-constant _POSIX_ARG_MAX 4096
+optional-constant _POSIX_CHILD_MAX 6
+optional-constant _POSIX_DELAYTIMER_MAX 32
+optional-constant _POSIX_LINK_MAX 8
+optional-constant _POSIX_LOGIN_NAME_MAX 9
+optional-constant _POSIX_MAX_CANON 255
+optional-constant _POSIX_MAX_INPUT 255
+optional-constant _POSIX_MQ_OPEN_MAX 8
+optional-constant _POSIX_MQ_PRIO_MAX 32
+optional-constant _POSIX_NAME_MAX 14
+optional-constant _POSIX_NGROUPS_MAX 0
+optional-constant _POSIX_OPEN_MAX 16
+optional-constant _POSIX_PATH_MAX 256
+optional-constant _POSIX_PIPE_BUF 512
+optional-constant _POSIX2_RE_DUP_MAX 255
+optional-constant _POSIX_RTSIG_MAX 8
+optional-constant _POSIX_SEM_NSEMS_MAX 256
+optional-constant _POSIX_SEM_VALUE_MAX 32767
+optional-constant _POSIX_SIGQUEUE_MAX 32
+optional-constant _POSIX_SSIZE_MAX 32767
+optional-constant _POSIX_STREAM_MAX 8
+optional-constant _POSIX_SS_REPL_MAX 4
+optional-constant _POSIX_SYMLINK_MAX 255
+optional-constant _POSIX_SYMLOOP_MAX 8
+optional-constant _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
+optional-constant _POSIX_THREAD_KEYS_MAX 128
+optional-constant _POSIX_THREAD_THREADS_MAX 64
+optional-constant _POSIX_TIMER_MAX 32
+optional-constant _POSIX_TTY_NAME_MAX 9
+optional-constant _POSIX_TZNAME_MAX 6
+optional-constant _POSIX2_BC_BASE_MAX 99
+optional-constant _POSIX2_BC_DIM_MAX 2048
+optional-constant _POSIX2_BC_SCALE_MAX 99
+optional-constant _POSIX2_BC_STRING_MAX 1000
+optional-constant _POSIX2_CHARCLASS_NAME_MAX 14
+optional-constant _POSIX2_COLL_WEIGHTS_MAX 2
+optional-constant _POSIX2_EXPR_NEST_MAX 32
+optional-constant _POSIX2_LINE_MAX 2048
+optional-constant _POSIX2_RE_DUP_MAX 255
+optional-constant _XOPEN_IOV_MAX 16
+
+constant CHAR_BIT >= 8
+constant CHAR_MAX
+constant INT_MAX >= 2147483647
+constant LONG_BIT >= 32
+constant MB_LEN_MAX >= 1
+constant LONG_MAX >= 2147483647
+constant SCHAR_MAX >= 127
+constant SHRT_MAX >= 32767
+constant SSIZE_MAX
+constant UCHAR_MAX >= 255
+constant UINT_MAX >= 4294967295
+constant ULONG_MAX >= 4294967295
+constant USHRT_MAX >= 65535
+constant WORD_BIT >= 16
+constant CHAR_MIN
+constant INT_MIN <= 2147483647
+constant LONG_MIN <= 2147483647
+constant SCHAR_MIN <= -127
+constant SHRT_MIN <= -32767
+
+optional-constant CHARCLASS_NAME_MAX >= 14
+optional-constant NL_ARGMAX >= 9
+optional-constant NL_LANGMAX >= 14
+optional-constant NL_MSGMAX >= 32767
+optional-constant NL_NMAX
+optional-constant NL_SETMAX >= 255
+optional-constant NL_TEXTMAX
+optional-constant NZERO >= 20
+optional-constant TMP_MAX >= 10000
Index: trunk/src/libctests/glibc/conform/data/locale.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/locale.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/locale.h-data	(revision 2036)
@@ -0,0 +1,43 @@
+type {struct lconv}
+element {struct lconv} {char*} currency_symbol
+element {struct lconv} {char*} decimal_point
+element {struct lconv} char frac_digits
+element {struct lconv} {char*} grouping
+element {struct lconv} {char*} int_curr_symbol
+element {struct lconv} char int_frac_digits
+element {struct lconv} {char*} mon_decimal_point
+element {struct lconv} {char*} mon_thousands_sep
+element {struct lconv} {char*} mon_grouping
+element {struct lconv} {char*} negative_sign
+element {struct lconv} char n_cs_precedes
+element {struct lconv} char n_sep_by_space
+element {struct lconv} char n_sign_posn
+element {struct lconv} {char*} positive_sign
+element {struct lconv} char p_cs_precedes
+element {struct lconv} char p_sep_by_space
+element {struct lconv} char p_sign_posn
+element {struct lconv} {char*} thousands_sep
+#ifdef XOPEN2K
+element {struct lconv} char int_n_cs_precedes
+element {struct lconv} char int_n_sep_by_space
+element {struct lconv} char int_n_sign_posn
+element {struct lconv} char int_p_cs_precedes
+element {struct lconv} char int_p_sep_by_space
+element {struct lconv} char int_p_sign_posn
+#endif
+
+constant NULL
+
+macro LC_ALL
+macro LC_COLLATE
+macro LC_CTYPE
+macro LC_MESSAGES
+macro LC_MONETARY
+macro LC_NUMERIC
+macro LC_TIME
+
+function {struct lconv*} localeconv (void)
+function {char*} setlocale (int, const char*)
+
+allow LC_*
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/math.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/math.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/math.h-data	(revision 2036)
@@ -0,0 +1,360 @@
+#if !defined ISO && !defined POSIX
+macro fpclassify
+macro isfinite
+macro isinf
+macro isnan
+macro isnormal
+macro signbit
+macro isgreater
+macro isgreaterequal
+macro isless
+macro islessequal
+macro islessgreater
+macro isunordered
+
+constant M_E
+constant M_LOG2E
+constant M_LOG10E
+constant M_LN2
+constant M_LN10
+constant M_PI
+constant M_PI_2
+constant M_PI_4
+constant M_1_PI
+constant M_2_PI
+constant M_2_SQRTPI
+constant M_SQRT2
+constant M_SQRT1_2
+
+constant MAXFLOAT
+constant HUGE_VAL
+constant HUGE_VALF
+constant HUGE_VALL
+constant INFINITY
+constant NAN
+
+macro FP_INFINITE
+macro FP_NAN
+macro FP_NORMAL
+macro FP_SUBNORMAL
+macro FP_ZERO
+
+optional-macro FP_FAST_FMA
+optional-macro FP_FAST_FMAF
+optional-macro FP_FAST_FMAL
+
+constant FP_ILOGB0
+constant FP_ILOGBNAN
+
+macro MATH_ERRNO == 1
+macro MATH_ERREXCEPT == 2
+#endif
+
+function double acos (double)
+function double asin (double)
+function double atan (double)
+function double atan2 (double, double)
+function double ceil (double)
+function double copysign (double, double)
+function double cos (double)
+function double cosh (double)
+function double exp (double)
+function double exp2 (double)
+function double fabs (double)
+function double floor (double)
+function double fmod (double, double)
+function double frexp (double, int*)
+function double ldexp (double, int)
+function double log (double)
+function double log10 (double)
+function double log2 (double)
+function double modf (double, double*)
+function double pow (double, double)
+function double sin (double)
+function double sinh (double)
+function double sqrt (double)
+function double tan (double)
+function double tanh (double)
+function double erf (double)
+function double erfc (double)
+function double gamma (double)
+function double hypot (double, double)
+function double j0 (double)
+function double j1 (double)
+function double jn (int, double)
+function double lgamma (double)
+function double tgamma (double)
+function double y0 (double)
+function double y1 (double)
+function double yn (int, double)
+function int isnan (double)
+function double acosh (double)
+function double asinh (double)
+function double atanh (double)
+function double cbrt (double)
+function double expm1 (double)
+function int ilogb (double)
+function double log1p (double)
+function double logb (double)
+function double nextafter (double, double)
+function double nexttoward (double, long double)
+function double nearbyint (double)
+function double remainder (double, double)
+function double rint (double)
+function double round (double)
+function double trunc (double)
+function long lrint (double)
+function {long long} llrint (double)
+function long lround (double)
+function {long long} llround (double)
+function double remquo (double, double, int*)
+function double scalb (double, double)
+function double scalbn (double, int)
+function double scalbln (double, long)
+function double fdim (double, double)
+function double fmax (double, double)
+function double fmin (double, double)
+function double fma (double, double, double)
+function double nan (const char*)
+
+// variable signgam
+allow signgam
+
+#if !defined ISO && !defined POSIX
+function float acosf (float)
+function float asinf (float)
+function float atanf (float)
+function float atan2f (float, float)
+function float ceilf (float)
+function float copysignf (float, float)
+function float cosf (float)
+function float coshf (float)
+function float expf (float)
+function float exp2f (float)
+function float fabsf (float)
+function float floorf (float)
+function float fmodf (float, float)
+function float frexpf (float, int*)
+function float ldexpf (float, int)
+function float logf (float)
+function float log10f (float)
+function float log2f (float)
+function float modff (float, float*)
+function float powf (float, float)
+function float sinf (float)
+function float sinhf (float)
+function float sqrtf (float)
+function float tanf (float)
+function float tanhf (float)
+function float erff (float)
+function float erfcf (float)
+function float gammaf (float)
+function float hypotf (float, float)
+function float j0f (float)
+function float j1f (float)
+function float jnf (int, float)
+function float lgammaf (float)
+function float tgammaf (float)
+function float y0f (float)
+function float y1f (float)
+function float ynf (int, float)
+function int isnanf (float)
+function float acoshf (float)
+function float asinhf (float)
+function float atanhf (float)
+function float cbrtf (float)
+function float expm1f (float)
+function int ilogbf (float)
+function float log1pf (float)
+function float logbf (float)
+function float nextafterf (float, float)
+function float nexttowardf (float, long double)
+function float nearbyintf (float)
+function float remainderf (float, float)
+function float rintf (float)
+function float roundf (float)
+function float truncf (float)
+function long lrintf (float)
+function {long long} llrintf (float)
+function long lroundf (float)
+function {long long} llroundf (float)
+function float remquof (float, float, int*)
+function float scalbf (float, float)
+function float scalbnf (float, int)
+function float scalblnf (float, long)
+function float fdimf (float, float)
+function float fmaxf (float, float)
+function float fminf (float, float)
+function float fmaf (float, float, float)
+function float nanf (const char*)
+
+function {long double} acosl (long double)
+function {long double} asinl (long double)
+function {long double} atanl (long double)
+function {long double} atan2l (long double, long double)
+function {long double} ceill (long double)
+function {long double} copysignl (long double, long double)
+function {long double} cosl (long double)
+function {long double} coshl (long double)
+function {long double} expl (long double)
+function {long double} exp2l (long double)
+function {long double} fabsl (long double)
+function {long double} floorl (long double)
+function {long double} fmodl (long double, long double)
+function {long double} frexpl (long double, int*)
+function {long double} ldexpl (long double, int)
+function {long double} logl (long double)
+function {long double} log10l (long double)
+function {long double} log2l (long double)
+function {long double} modfl (long double, long double*)
+function {long double} powl (long double, long double)
+function {long double} sinl (long double)
+function {long double} sinhl (long double)
+function {long double} sqrtl (long double)
+function {long double} tanl (long double)
+function {long double} tanhl (long double)
+function {long double} erfl (long double)
+function {long double} erfcl (long double)
+function {long double} gammal (long double)
+function {long double} hypotl (long double, long double)
+function {long double} j0l (long double)
+function {long double} j1l (long double)
+function {long double} jnl (int, long double)
+function {long double} lgammal (long double)
+function {long double} tgammal (long double)
+function {long double} y0l (long double)
+function {long double} y1l (long double)
+function {long double} ynl (int, long double)
+function int isnanl (long double)
+function {long double} acoshl (long double)
+function {long double} asinhl (long double)
+function {long double} atanhl (long double)
+function {long double} cbrtl (long double)
+function {long double} expm1l (long double)
+function int ilogbl (long double)
+function {long double} log1pl (long double)
+function {long double} logbl (long double)
+function {long double} nextafterl (long double, long double)
+function {long double} nexttowardl (long double, long double)
+function {long double} nearbyintl (long double)
+function {long double} remainderl (long double, long double)
+function {long double} rintl (long double)
+function {long double} roundl (long double)
+function {long double} truncl (long double)
+function long lrintl (long double)
+function {long long} llrintl (long double)
+function long lroundl (long double)
+function {long long} llroundl (long double)
+function {long double} remquol (long double, long double, int*)
+function {long double} scalbl (long double, long double)
+function {long double} scalbnl (long double, int)
+function {long double} scalblnl (long double, long)
+function {long double} fdiml (long double, long double)
+function {long double} fmaxl (long double, long double)
+function {long double} fminl (long double, long double)
+function {long double} fmal (long double, long double, long double)
+function {long double} nanl (const char*)
+#else
+allow acosf
+allow asinf
+allow atanf
+allow atan2f
+allow ceilf
+allow copysignf
+allow cosf
+allow coshf
+allow expf
+allow exp2f
+allow fabsf
+allow floorf
+allow fmodf
+allow frexpf
+allow ldexpf
+allow logf
+allow log10f
+allow log2f
+allow powf
+allow sinf
+allow sinhf
+allow sqrtf
+allow tanf
+allow tanhf
+allow erff
+allow erfcf
+allow gammaf
+allow hypotf
+allow j0f
+allow j1f
+allow jnf
+allow lgammaf
+allow tgammaf
+allow y0f
+allow y1f
+allow ynf
+allow isnanf
+allow acoshf
+allow asinhf
+allow atanhf
+allow cbrtf
+allow expm1f
+allow ilogbf
+allow log1pf
+allow logbf
+allow nextafterf
+allow remainderf
+allow rintf
+allow scalbf
+
+allow acosl
+allow asinl
+allow atanl
+allow atan2l
+allow ceill
+allow copysignl
+allow cosl
+allow coshl
+allow expl
+allow exp2l
+allow fabsl
+allow floorl
+allow fmodl
+allow frexpl
+allow ldexpl
+allow logl
+allow log10l
+allow log2l
+allow powl
+allow sinl
+allow sinhl
+allow sqrtl
+allow tanl
+allow tanhl
+allow erfl
+allow erfcl
+allow gammal
+allow hypotl
+allow j0l
+allow j1l
+allow jnl
+allow lgammal
+allow tgammal
+allow y0l
+allow y1l
+allow ynl
+allow isnanl
+allow acoshl
+allow asinhl
+allow atanhl
+allow cbrtl
+allow expm1l
+allow ilogbl
+allow log1pl
+allow logbl
+allow nextafterl
+allow remainderl
+allow rintl
+allow scalbl
+#endif
+
+allow *_t
+allow FP_*
Index: trunk/src/libctests/glibc/conform/data/monetary.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/monetary.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/monetary.h-data	(revision 2036)
@@ -0,0 +1,8 @@
+#if !defined ISO && !defined POSIX
+type size_t
+type ssize_t
+
+function ssize_t strfmon (char*, size_t, const char*, ...)
+
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/mqueue.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/mqueue.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/mqueue.h-data	(revision 2036)
@@ -0,0 +1,28 @@
+#ifndef ISO
+// should test for not an array type.
+type mqd_t
+
+type {struct sigevent}
+
+type {struct mq_attr}
+element {struct mq_attr} long mq_flags
+element {struct mq_attr} long mq_maxmsg
+element {struct mq_attr} long mq_msgsize
+element {struct mq_attr} long mq_curmsg
+
+function int mq_close (mqd_t)
+function int mq_getattr (mqd_t, struct mq_attr*)
+function int mq_notify (mqd_t, const struct sigevent*)
+function mqd_t mq_open (const char*, int, ...)
+function ssize_t mq_receive (mqd_t, char*, size_t, unsigned int*)
+function int mq_send (mqd_t, const char*, size_t, unsigned int)
+function int mq_setattr (mqd_t, const struct mq_attr*, struct mq_attr*)
+function int mq_unlink (const char*)
+
+allow-header fcntl.h
+allow-header signal.h
+allow-header sys/types.h
+allow-header time.h
+
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/ndbm.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/ndbm.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/ndbm.h-data	(revision 2036)
@@ -0,0 +1,28 @@
+#if !defined ISO && !defined POSIX
+type datum
+element datum {void*} dptr
+element datum size_t dsize
+
+type size_t
+
+type DBM
+
+type mode_t
+
+constant DBM_INSERT
+constant DBM_REPLACE
+
+function int dbm_clearerr (DBM*)
+function void dbm_close (DBM*)
+function int dbm_delete (DBM*, datum)
+function int dbm_error (DBM*)
+function datum dbm_fetch (DBM*, datum)
+function datum dbm_firstkey (DBM*)
+function datum dbm_nextkey (DBM*)
+function {DBM*} dbm_open (const char*, int, mode_t)
+function int dbm_store (DBM*, datum, datum, int)
+
+allow dbm_*
+allow DBM_*
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/net/if.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/net/if.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/net/if.h-data	(revision 2036)
@@ -0,0 +1,15 @@
+#ifndef ISO
+type {struct if_nameindex}
+
+element {struct if_nameindex} {unsigned int} if_index
+element {struct if_nameindex} {char*} if_name
+
+macro IF_NAMESIZE
+
+function {unsigned int} if_nametoindex (const char*)
+function {char*} if_indextoname (unsigned int, char*)
+function {struct if_nameindex*} if_nameindex (void)
+function void if_freenameindex (struct if_nameindex*)
+
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/netdb.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/netdb.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/netdb.h-data	(revision 2036)
@@ -0,0 +1,104 @@
+#ifndef ISO
+optional-type in_port_t
+optional-type in_addr_t
+
+type {struct hostent}
+
+element {struct hostent} {char*} h_name
+element {struct hostent} {char**} h_aliases
+element {struct hostent} int h_addrtype
+element {struct hostent} int h_length
+element {struct hostent} {char**} h_addr_list
+
+type {struct netent}
+
+element {struct netent} {char*} n_name
+element {struct netent} {char**} n_aliases
+element {struct netent} int n_addrtype
+element {struct netent} uint32_t n_net
+
+type uint32_t
+
+type {struct protoent}
+
+element {struct protoent} {char*} p_name
+element {struct protoent} {char**} p_aliases
+element {struct protoent} int p_proto
+
+type {struct servent}
+
+element {struct servent} {char*} s_name
+element {struct servent} {char**} s_aliases
+element {struct servent} int s_port
+element {struct servent} {char*} s_proto
+
+macro IPPORT_RESERVED
+
+// variable int h_errno
+allow h_errno
+
+macro HOST_NOT_FOUND
+macro NO_DATA
+macro NO_RECOVERY
+macro TRY_AGAIN
+
+type {struct addrinfo}
+element {struct addrinfo} int ai_flags
+element {struct addrinfo} int ai_family
+element {struct addrinfo} int ai_socktype
+element {struct addrinfo} int ai_protocol
+element {struct addrinfo} socklen_t ai_addrlen
+element {struct addrinfo} {struct sockaddr*} ai_addr
+element {struct addrinfo} {char*} ai_canonname
+element {struct addrinfo} {struct addrinfo*} ai_next
+
+macro AI_PASSIVE
+macro AI_CANONNAME
+macro AI_NUMERICHOST
+
+macro NI_NOFQDN
+macro NI_NUMERICHOST
+macro NI_NAMEREQD
+macro NI_NUMERICSERV
+macro NI_DGRAM
+
+macro EAI_AGAIN
+macro EAI_BADFLAGS
+macro EAI_FAIL
+macro EAI_FAMILY
+macro EAI_MEMORY
+macro EAI_NONAME
+macro EAI_SERVICE
+macro EAI_SOCKTYPE
+macro EAI_SYSTEM
+
+function void endhostent (void)
+function void endnetent (void)
+function void endprotoent (void)
+function void endservent (void)
+function void freeaddrinfo (struct addrinfo*)
+function {const char*} gai_strerror (int)
+function int getaddrinfo (const char*, const char*, const struct addrinfo*, struct addrinfo**)
+function {struct hostent*} gethostbyaddr (const void*, socklen_t, int)
+function {struct hostent*} gethostbyname (const char*)
+function {struct hostent*} gethostent (void)
+function int getnameinfo (const struct sockaddr*, socklen_t, char*, socklen_t, char*, socklen_t, unsigned)
+function {struct netent*} getnetbyaddr (uint32_t, int)
+function {struct netent*} getnetbyname (const char*)
+function {struct netent*} getnetent (void)
+function {struct protoent*} getprotobyname (const char *)
+function {struct protoent*} getprotobynumber (int)
+function {struct protoent*} getprotoent (void)
+function {struct servent*} getservbyname (const char*, const char*)
+function {struct servent*} getservbyport (int, const char*)
+function {struct servent*} getservent (void)
+function void sethostent (int)
+function void setnetent (int)
+function void setprotoent (int)
+function void setservent (int)
+
+type socklen_t
+
+allow-header netinet/in.h
+allow-header inttypes.h
+#endif
Index: trunk/src/libctests/glibc/conform/data/netinet/in.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/netinet/in.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/netinet/in.h-data	(revision 2036)
@@ -0,0 +1,91 @@
+#ifndef ISO
+type in_port_t
+type in_addr_t
+
+type sa_family_t
+
+type {struct in_addr}
+
+element {struct in_addr} in_addr_t s_addr
+
+type {struct sockaddr_in}
+
+element {struct sockaddr_in} sa_family_t sin_family
+element {struct sockaddr_in} in_port_t sin_port
+element {struct sockaddr_in} {struct in_addr} sin_addr
+element {struct sockaddr_in} {unsigned char} sin_zero [8]
+
+type {struct in6_addr}
+
+element {struct in6_addr} uint8_t s6_addr [16]
+
+type {struct sockaddr_in6}
+
+element {struct sockaddr_in6} sa_family_t sin6_family
+element {struct sockaddr_in6} in_port_t sin6_port
+element {struct sockaddr_in6} uint32_t sin6_flowinfo
+element {struct sockaddr_in6} {struct in6_addr} sin6_addr
+element {struct sockaddr_in6} uint32_t sin6_scope_id
+
+variable {struct in6_addr} in6addr_any
+
+// constant IN6ADDR_ANY_INIT
+macro IN6ADDR_ANY_INIT
+
+variable {struct in6_addr} in6addr_loopback
+
+// constant IN6ADDR_LOOPBACK_INIT
+macro IN6ADDR_LOOPBACK_INIT
+
+type {struct ipv6_mreq}
+
+element {struct ipv6_mreq} {struct in6_addr} ipv6mr_multiaddr
+element {struct ipv6_mreq} {unsigned int} ipv6mr_interface
+
+macro IPPROTO_IP
+macro IPPROTO_IPV6
+macro IPPROTO_ICMP
+macro IPPROTO_TCP
+macro IPPROTO_UDP
+
+macro INADDR_ANY
+macro INADDR_BROADCAST
+
+constant INET_ADDRSTRLEN 16
+
+function uint32_t htonl (uint32_t)
+function uint16_t htons (uint16_t)
+function uint32_t ntohl (uint32_t)
+function uint16_t ntohs (uint16_t)
+
+allow-header inttypes.h
+allow-header arpa/inet.h
+
+constant INET6_ADDRSTRLEN 46
+
+macro IPV6_JOIN_GROUP
+macro IPV6_LEAVE_GROUP
+macro IPV6_MULTICAST_HOPS
+macro IPV6_MULTICAST_IF
+macro IPV6_MULTICAST_LOOP
+macro IPV6_UNICAST_HOPS
+
+macro IN6_IS_ADDR_UNSPECIFIED
+macro IN6_IS_ADDR_LOOPBACK
+macro IN6_IS_ADDR_MULTICAST
+macro IN6_IS_ADDR_LINKLOCAL
+macro IN6_IS_ADDR_SITELOCAL
+macro IN6_IS_ADDR_V4MAPPED
+macro IN6_IS_ADDR_V4COMPAT
+macro IN6_IS_ADDR_MC_NODELOCAL
+macro IN6_IS_ADDR_MC_LINKLOCAL
+macro IN6_IS_ADDR_MC_SITELOCAL
+macro IN6_IS_ADDR_MC_ORGLOCAL
+macro IN6_IS_ADDR_MC_GLOBAL
+
+allow IN_*
+allow IP_*
+allow IPPORT_*
+allow IPPROTO_*
+allow SOCK_*
+#endif
Index: trunk/src/libctests/glibc/conform/data/netinet/tcp.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/netinet/tcp.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/netinet/tcp.h-data	(revision 2036)
@@ -0,0 +1,5 @@
+#ifdef XOPEN2K
+macro TCP_NODELAY
+
+allow TCP_*
+#endif
Index: trunk/src/libctests/glibc/conform/data/nl_types.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/nl_types.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/nl_types.h-data	(revision 2036)
@@ -0,0 +1,14 @@
+#if !defined ISO && !defined POSIX
+type nl_catd
+type nl_item
+
+constant NL_SETD
+constant NL_CAT_LOCALE
+
+function int catclose (nl_catd)
+function {char*} catgets (nl_catd, int, int, const char*)
+function nl_catd catopen (const char*, int)
+
+allow NL_*
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/poll.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/poll.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/poll.h-data	(revision 2036)
@@ -0,0 +1,27 @@
+#if !defined ISO && !defined POSIX
+type {struct pollfd}
+element {struct pollfd} int fd
+element {struct pollfd} {short int} events
+element {struct pollfd} {short int} revents
+
+type nfds_t
+
+constant POLLIN
+constant POLLRDNORM
+constant POLLRDBAND
+constant POLLPRI
+constant POLLOUT
+constant POLLWRNORM
+constant POLLWRBAND
+constant POLLERR
+constant POLLHUP
+constant POLLNVAL
+
+function int poll (struct pollfd[], nfds_t, int)
+
+allow pd_*
+allow ph_*
+allow ps_*
+allow POLL*
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/pthread.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/pthread.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/pthread.h-data	(revision 2036)
@@ -0,0 +1,157 @@
+#ifndef ISO
+constant PTHREAD_CANCEL_ASYNCHRONOUS
+constant PTHREAD_CANCEL_ENABLE
+constant PTHREAD_CANCEL_DEFERRED
+constant PTHREAD_CANCEL_DISABLE
+constant PTHREAD_CANCELED
+macro PTHREAD_COND_INITIALIZER
+constant PTHREAD_CREATE_DETACHED
+constant PTHREAD_CREATE_JOINABLE
+constant PTHREAD_EXPLICIT_SCHED
+constant PTHREAD_INHERIT_SCHED
+constant PTHREAD_ONCE_INIT
+optional-constant PTHREAD_PRIO_INHERIT
+optional-constant PTHREAD_PRIO_NONE
+optional-constant PTHREAD_PRIO_PROTECT
+constant PTHREAD_PROCESS_SHARED
+constant PTHREAD_PROCESS_PRIVATE
+constant PTHREAD_SCOPE_PROCESS
+constant PTHREAD_SCOPE_SYSTEM
+# ifndef POSIX
+constant PTHREAD_MUTEX_DEFAULT
+constant PTHREAD_MUTEX_ERRORCHECK
+constant PTHREAD_MUTEX_NORMAL
+macro PTHREAD_MUTEX_INITIALIZER
+constant PTHREAD_MUTEX_RECURSIVE
+macro PTHREAD_RWLOCK_INITIALIZER
+# endif
+
+type pthread_attr_t
+type pthread_barrier_t
+type pthread_barrierattr_t
+type pthread_cond_t
+type pthread_condattr_t
+type pthread_key_t
+type pthread_mutex_t
+type pthread_mutexattr_t
+type pthread_once_t
+type pthread_rwlock_t
+type pthread_rwlockattr_t
+type pthread_spinlock_t
+type pthread_t
+
+function int pthread_attr_destroy (pthread_attr_t*)
+function int pthread_attr_getdetachstate (const pthread_attr_t*, int*)
+# ifndef POSIX
+function int pthread_attr_getguardsize (const pthread_attr_t*, size_t*)
+# endif
+function int pthread_attr_getinheritsched (const pthread_attr_t*, int*)
+function int pthread_attr_getschedparam (const pthread_attr_t*, struct sched_param*)
+function int pthread_attr_getschedpolicy (const pthread_attr_t*, int*)
+function int pthread_attr_getscope (const pthread_attr_t*, int*)
+function int pthread_attr_getstackaddr (const pthread_attr_t*, void**)
+function int pthread_attr_getstacksize (const pthread_attr_t*, size_t*)
+function int pthread_attr_init (pthread_attr_t*)
+function int pthread_attr_setdetachstate (pthread_attr_t*, int)
+# ifndef POSIX
+function int pthread_attr_setguardsize (pthread_attr_t*, size_t)
+# endif
+function int pthread_attr_setinheritsched (pthread_attr_t*, int)
+function int pthread_attr_setschedparam (pthread_attr_t*, const struct sched_param*)
+function int pthread_attr_setschedpolicy (pthread_attr_t*, int)
+function int pthread_attr_setscope (pthread_attr_t*, int)
+function int pthread_attr_setstackaddr (pthread_attr_t*, void*)
+function int pthread_attr_setstacksize (pthread_attr_t*, size_t)
+function int pthread_barrier_destroy (pthread_barrier_t*)
+function int pthread_barrier_init (pthread_barrier_t*, const pthread_barrierattr_t*, unsigned int)
+function int pthread_barrier_wait (pthread_barrier_t*)
+function int pthread_barrierattr_destroy (pthread_barrierattr_t*)
+function int pthread_barrierattr_getpshared (const pthread_barrierattr_t*, int*)
+function int pthread_barrierattr_init (pthread_barrierattr_t*)
+function int pthread_barrierattr_setpshared (pthread_barrierattr_t*, int)
+function int pthread_cancel (pthread_t)
+// function int pthread_cleanup_push (void (*) (void*), void*)
+macro pthread_cleanup_push
+// function int pthread_cleanup_pop (int)
+macro pthread_cleanup_pop
+function int pthread_cond_broadcast (pthread_cond_t*)
+function int pthread_cond_destroy (pthread_cond_t*)
+function int pthread_cond_init (pthread_cond_t*, const pthread_condattr_t*)
+function int pthread_cond_signal (pthread_cond_t*)
+function int pthread_cond_timedwait (pthread_cond_t*, pthread_mutex_t*, const struct timespec*)
+function int pthread_cond_wait (pthread_cond_t*, pthread_mutex_t*)
+function int pthread_condattr_destroy (pthread_condattr_t*)
+optional-function int pthread_condattr_getclock (const pthread_condattr_t*, clockid_t*)
+function int pthread_condattr_getpshared (const pthread_condattr_t*, int*)
+function int pthread_condattr_init (pthread_condattr_t*)
+optional-function int pthread_condattr_setclock (const pthread_condattr_t*, clockid_t*)
+function int pthread_condattr_setpshared (pthread_condattr_t*, int)
+function int pthread_create (pthread_t*, const pthread_attr_t*, void *(*) (void*), void*)
+function int pthread_detach (pthread_t)
+function int pthread_equal (pthread_t, pthread_t)
+function void pthread_exit (void*)
+# ifndef POSIX
+function int pthread_getconcurrency (void)
+# endif
+function int pthread_getcpuclockid (pthread_t, clockid_t*)
+function int pthread_getschedparam (pthread_t, int*, struct sched_param*)
+function {void*} pthread_getspecific (pthread_key_t)
+function int pthread_join (pthread_t, void**)
+function int pthread_key_create (pthread_key_t*, void (*)(void*))
+function int pthread_key_delete (pthread_key_t)
+function int pthread_mutex_destroy (pthread_mutex_t*)
+optional-function int pthread_mutex_getprioceiling (const pthread_mutex_t*, int*)
+function int pthread_mutex_init (pthread_mutex_t*, const pthread_mutexattr_t*)
+function int pthread_mutex_lock (pthread_mutex_t*)
+optional-function int pthread_mutex_setprioceiling (pthread_mutex_t*, int, int*)
+function int pthread_mutex_timedlock (pthread_mutex_t*, const struct timespec*)
+function int pthread_mutex_trylock (pthread_mutex_t*)
+function int pthread_mutex_unlock (pthread_mutex_t*)
+function int pthread_mutexattr_destroy (pthread_mutexattr_t*)
+optional-function int pthread_mutexattr_getprioceiling (const pthread_mutexattr_t*, int*)
+optional-function int pthread_mutexattr_getprotocol (const pthread_mutexattr_t*, int*)
+function int pthread_mutexattr_getpshared (const pthread_mutexattr_t*, int*)
+function int pthread_mutexattr_gettype (const pthread_mutexattr_t*, int*)
+function int pthread_mutexattr_init (pthread_mutexattr_t*)
+optional-function int pthread_mutexattr_setprioceiling (pthread_mutexattr_t*, int)
+optional-function int pthread_mutexattr_setprotocol (pthread_mutexattr_t*, int)
+function int pthread_mutexattr_setpshared (pthread_mutexattr_t*, int)
+function int pthread_mutexattr_settype (pthread_mutexattr_t*, int)
+function int pthread_once (pthread_once_t*, void (*) (void))
+# ifndef POSIX
+function int pthread_rwlock_init (pthread_rwlock_t*, const pthread_rwlockattr_t*)
+function int pthread_rwlock_rdlock (pthread_rwlock_t*)
+function int pthread_rwlock_timedrdlock (pthread_rwlock_t*, const struct timespec*)
+function int pthread_rwlock_timedwrlock (pthread_rwlock_t*, const struct timespec*)
+function int pthread_rwlock_tryrdlock (pthread_rwlock_t*)
+function int pthread_rwlock_trywrlock (pthread_rwlock_t*)
+function int pthread_rwlock_unlock (pthread_rwlock_t*)
+function int pthread_rwlock_wrlock (pthread_rwlock_t*)
+function int pthread_rwlockattr_destroy (pthread_rwlockattr_t*)
+function int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t*, int*)
+function int pthread_rwlockattr_init (pthread_rwlockattr_t*)
+function int pthread_rwlockattr_setpshared (pthread_rwlockattr_t*, int)
+# endif
+function pthread_t pthread_self (void)
+function int pthread_setcancelstate (int, int*)
+function int pthread_setcanceltype (int, int*)
+# ifndef POSIX
+function int pthread_setconcurrency (int)
+# endif
+function int pthread_setschedparam (pthread_t, int, const struct sched_param*)
+function int pthread_setspecific (pthread_key_t, const void*)
+function int pthread_sigmask (int, const sigset_t*, sigset_t*)
+function int pthread_spin_destroy (pthread_spinlock_t*)
+function int pthread_spin_init (pthread_spinlock_t*, int)
+function int pthread_spin_lock (pthread_spinlock_t*)
+function int pthread_spin_trylock (pthread_spinlock_t*)
+function int pthread_spin_unlock (pthread_spinlock_t*)
+function void pthread_testcancel (void)
+
+allow-header sched.h
+allow-header time.h
+
+allow PTHREAD_*
+allow pthread_*
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/pwd.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/pwd.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/pwd.h-data	(revision 2036)
@@ -0,0 +1,24 @@
+#ifndef ISO
+type {struct passwd}
+element {struct passwd} {char*} pw_name
+element {struct passwd} uid_t pw_uid
+element {struct passwd} gid_t pw_gid
+element {struct passwd} {char*} pw_dir
+element {struct passwd} {char*} pw_shell
+
+# ifndef POSIX
+type uid_t
+type gid_t
+# endif
+
+function {struct passwd*} getpwnam (const char*)
+function {struct passwd*} getpwuid (uid_t)
+function int getpwnam_r (const char*, struct passwd*, char*, size_t, struct passwd**)
+function int getpwuid_r (uid_t, struct passwd*, char*, size_t, struct passwd**)
+function void endpwent (void)
+function {struct passwd*} getpwent (void)
+function void setpwent (void)
+
+allow pw_*
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/regex.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/regex.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/regex.h-data	(revision 2036)
@@ -0,0 +1,42 @@
+#ifndef ISO
+type regex_t
+element regex_t size_t re_nsub
+
+type regoff_t
+
+type regmatch_t
+element regmatch_t regoff_t rm_so
+element regmatch_t regoff_t rm_eo
+
+constant REG_EXTENDED
+constant REG_ICASE
+constant REG_NOSUB
+constant REG_NEWLINE
+
+constant REG_NOTBOL
+constant REG_NOTEOL
+
+constant REG_NOMATCH
+constant REG_BADPAT
+constant REG_ECOLLATE
+constant REG_ECTYPE
+constant REG_EESCAPE
+constant REG_ESUBREG
+constant REG_EBRACK
+constant REG_EPAREN
+constant REG_EBRACE
+constant REG_BADBR
+constant REG_ESPACE
+constant REG_BADRPT
+constant REG_ENOSYS
+
+function int regcomp (regex_t*, const char*, int)
+function int regexec (const regex_t*, const char*, size_t, regmatch_t[], int)
+function size_t regerror (int, const regex_t*, char*, size_t)
+function void regfree (regex_t*)
+
+allow REG_*
+allow re_*
+allow rm_*
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/sched.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/sched.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/sched.h-data	(revision 2036)
@@ -0,0 +1,28 @@
+#ifndef ISO
+type {struct sched_param}
+element {struct sched_param} int sched_priority
+optional-element {struct sched_param} int sched_ss_low_priority
+optional-element {struct sched_param} {struct timespec} sched_ss_repl_period
+optional-element {struct sched_param} {struct timespec} sched_ss_init_budget
+optional-element {struct sched_param} int sched_ss_max_repl
+
+constant SCHED_FIFO
+constant SCHED_RR
+optional-constant SCHED_SPORADIC
+constant SCHED_OTHER
+
+function int sched_get_priority_max (int)
+function int sched_get_priority_min (int)
+function int sched_getparam (pid_t, struct sched_param*)
+function int sched_getscheduler (pid_t)
+function int sched_rr_get_interval (pid_t, struct timespec*)
+function int sched_setparam (pid_t, const struct sched_param*)
+function int sched_setscheduler (pid_t, int, const struct sched_param*)
+function int sched_yield (void)
+
+allow-header time.h
+
+allow sched_*
+allow SCHED_*
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/search.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/search.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/search.h-data	(revision 2036)
@@ -0,0 +1,30 @@
+#if !defined ISO && !defined POSIX
+type ENTRY
+type {struct entry}
+element {struct entry} {char*} key
+element {struct entry} {void*} data
+
+type ACTION
+constant FIND
+constant ENTER
+
+type VISIT
+constant preorder
+constant postorder
+constant endorder
+constant leaf
+
+function int hcreate (size_t)
+function void hdestroy (void)
+function {ENTRY*} hsearch (ENTRY, ACTION)
+function void insque (void*, void*)
+function {void*} lfind (const void*, const void*, size_t*, size_t, int (*)(const void*, const void*))
+function {void*} lsearch (const void*, void*, size_t*, size_t, int (*)(const void*, const void*))
+function void remque (void*)
+function {void*} tdelete (const void*, void**, int(*)(const void*, const void*))
+function {void*} tfind (const void*, void*const*, int(*)(const void*, const void*))
+function {void*} tsearch (const void*, void**, int(*)(const void*, const void*))
+function void twalk (const void*, void (*) (const void*, VISIT, int))
+
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/semaphore.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/semaphore.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/semaphore.h-data	(revision 2036)
@@ -0,0 +1,25 @@
+#if !defined ISO
+type sem_t
+
+constant SEM_FAILED
+
+function int sem_close (sem_t*)
+function int sem_destroy (sem_t*)
+function int sem_getvalue (sem_t*, int*)
+function int sem_init (sem_t*, int, unsigned int)
+function {sem_t*} sem_open (const char*, int, ...)
+function int sem_post (sem_t*)
+function int sem_timedwait (sem_t*, const struct timespec*)
+function int sem_trywait (sem_t*)
+function int sem_unlink (const char*)
+function int sem_wait (sem_t*)
+
+# if !defined POSIX
+allow-header fcntl.h
+allow-header sys/types.h
+# endif
+
+allow sem_*
+allow SEM_*
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/setjmp.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/setjmp.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/setjmp.h-data	(revision 2036)
@@ -0,0 +1,22 @@
+type jmp_buf
+#ifndef ISO
+type sigjmp_buf
+#endif
+
+function void longjmp (jmp_buf, int)
+#ifndef ISO
+function void siglongjmp (sigjmp_buf, int)
+# ifndef POSIX
+function void _longjmp (jmp_buf, int)
+# endif
+#endif
+
+macro-function int setjmp (jmp_buf)
+#ifndef ISO
+macro-function int sigsetjmp (sigjmp_buf, int)
+# ifndef POSIX
+macro-function int _setjmp (jmp_buf)
+# endif
+#endif
+
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/signal.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/signal.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/signal.h-data	(revision 2036)
@@ -0,0 +1,203 @@
+typed-constant SIG_DFL {void(*)(int)}
+typed-constant SIG_ERR {void(*)(int)}
+typed-constant SIG_HOLD {void(*)(int)}
+typed-constant SIG_IGN {void(*)(int)}
+
+type sig_atomic_t
+type sigset_t
+type pid_t
+
+element {union sigval} int sival_int
+element {union sigval} {void*} sival_ptr
+
+type {struct sigevent}
+
+// Test the elements of the sigevent_t structure.
+element {struct sigevent} int sigev_notify
+element {struct sigevent} int sigev_signo
+element {struct sigevent} {union sigval} sigev_value
+element {struct sigevent} {void(*} sigev_notify_function )(union sigval)
+element {struct sigevent} {pthread_attr_t*} sigev_notify_attributes
+
+constant SIGEV_NONE
+constant SIGEV_SIGNAL
+constant SIGEV_THREAD
+
+type {union sigval}
+
+macro SIGRTMIN
+macro SIGRTMAX
+
+constant SIGABRT
+constant SIGALRM
+constant SIGFPE
+constant SIGHUP
+constant SIGILL
+constant SIGINT
+constant SIGIO
+constant SIGKILL
+constant SIGPIPE
+constant SIGQUIT
+constant SIGSEGV
+constant SIGTERM
+constant SIGUSR1
+constant SIGUSR2
+constant SIGCHLD
+constant SIGCONT
+constant SIGSTOP
+constant SIGTSTP
+constant SIGTTIN
+constant SIGTTOU
+constant SIGBUS
+constant SIGPOLL
+constant SIGPROF
+constant SIGSYS
+constant SIGTRAP
+constant SIGURG
+constant SIGVTALRM
+constant SIGXCPU
+constant SIGXFSZ
+
+type {struct sigaction}
+
+element {struct sigaction} {void(*} sa_handler )(int)
+element {struct sigaction} sigset_t sa_mask
+element {struct sigaction} int sa_flags
+element {struct sigaction} {void(*} sa_sigaction )(int, siginfo_t*, void*)
+
+constant SA_NOCLDSTOP
+constant SIG_BLOCK
+constant SIG_UNBLOCK
+constant SIG_SETMASK
+constant SA_ONSTACK
+constant SA_RESETHAND
+constant SA_RESTART
+constant SA_SIGINFO
+constant SA_NOCLDWAIT
+constant SA_NODEFER
+constant SS_ONSTACK
+constant SS_DISABLE
+constant MINSIGSTKSZ
+constant SIGSTKSZ
+
+type ucontext_t
+
+element ucontext_t {ucontext_t*} uc_link
+element ucontext_t sigset_t uc_sigmask
+element ucontext_t stack_t uc_stack
+element ucontext_t mcontext_t uc_mcontext
+
+type stack_t
+
+element stack_t {void*} ss_sp
+element stack_t size_t ss_size
+element stack_t int ss_flags
+
+type {struct sigstack}
+
+element {struct sigstack} int ss_onstack
+element {struct sigstack} {void*} ss_sp
+
+type siginfo_t
+
+element siginfo_t int si_signo
+element siginfo_t int si_errno
+element siginfo_t int si_code
+element siginfo_t pid_t si_pid
+element siginfo_t uid_t si_uid
+element siginfo_t {void*} si_addr
+element siginfo_t int si_status
+element siginfo_t long si_band
+element siginfo_t {union sigval} si_value
+
+constant ILL_ILLOPC
+constant ILL_ILLOPN
+constant ILL_ILLADR
+constant ILL_ILLTRP
+constant ILL_PRVOPC
+constant ILL_PRVREG
+constant ILL_COPROC
+constant ILL_BADSTK
+constant FPE_INTDIV
+constant FPE_INTOVF
+constant FPE_FLTDIV
+constant FPE_FLTOVF
+constant FPE_FLTUND
+constant FPE_FLTRES
+constant FPE_FLTINV
+constant FPE_FLTSUB
+constant SEGV_MAPERR
+constant SEGV_ACCERR
+constant BUS_ADRALN
+constant BUS_ADRERR
+constant BUS_OBJERR
+constant TRAP_BRKPT
+constant TRAP_TRACE
+constant CLD_EXITED
+constant CLD_KILLED
+constant CLD_DUMPED
+constant CLD_TRAPPED
+constant CLD_STOPPED
+constant CLD_CONTINUED
+constant POLL_IN
+constant POLL_OUT
+constant POLL_MSG
+constant POLL_ERR
+constant POLL_PRI
+constant POLL_HUP
+constant SI_USER
+constant SI_QUEUE
+constant SI_TIMER
+constant SI_ASYNCIO
+constant SI_MESGQ
+
+function void (*bsd_signal (int, void(*)(int)))(int)
+function int kill (pid_t, int)
+function int killpg (pid_t, int)
+function int pthread_kill (pthread_t, int)
+function int pthread_sigmask (int, const sigset_t*, sigset_t*)
+function int raise (int)
+function int sigaction (int, const struct sigaction*, struct sigaction*)
+function int sigaddset (sigset_t*, int)
+function int sigaltstack (const stack_t*, stack_t*)
+function int sigdelset (sigset_t*, int)
+function int sigemptyset (sigset_t*)
+function int sigfillset (sigset_t*)
+function int sighold (int)
+function int sigignore (int)
+function int siginterrupt (int, int)
+function int sigismember (const sigset_t*, int)
+function void (*signal (int, void(*)(int)))(int)
+function int sigpause (int)
+function int sigpending (sigset_t*)
+function int sigprocmask (int, const sigset_t*, sigset_t*)
+function int sigqueue (pid_t, int, const union sigval)
+function int sigrelse (int)
+function void (*sigset (int, void(*)(int)))(int)
+function int sigstack (struct sigstack*, struct sigstack*)
+function int sigsuspend (const sigset_t*)
+function int sigtimedwait (const sigset_t*, siginfo_t*, const struct timespec*)
+function int sigwait (const sigset_t*, int*)
+function int sigwaitinfo (const sigset_t*, siginfo_t*)
+
+allow SIG*
+allow sa_*
+allow uc_*
+allow ss_*
+allow sv_*
+allow si_*
+allow SI_*
+allow sigev_*
+allow SIGEV_*
+allow sival_*
+allow SA_*
+allow BUS_*
+allow CLD_*
+allow FPE_*
+allow ILL_*
+allow POLL_*
+allow SEGV_*
+allow SS_*
+allow SV_*
+allow TRAP_*
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/spawn.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/spawn.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/spawn.h-data	(revision 2036)
@@ -0,0 +1,37 @@
+#ifndef ISO
+type posix_spawnattr_t
+type posix_spawn_file_actions_t
+
+constant POSIX_SPAWN_RESETIDS
+constant POSIX_SPAWN_SETPGROUP
+constant POSIX_SPAWN_SETSCHEDPARAM
+constant POSIX_SPAWN_SETSCHEDULER
+constant POSIX_SPAWN_SETSIGDEF
+constant POSIX_SPAWN_SETSIGMASK
+
+function int posix_spawnattr_destroy (posix_spawnattr_t*)
+function int posix_spawnattr_getsigdefault (const posix_spawnattr_t*, sigset_t*)
+function int posix_spawnattr_getflags (const posix_spawnattr_t*, short*)
+function int posix_spawnattr_getpgroup (const posix_spawnattr_t*, pid_t*)
+function int posix_spawnattr_getschedparam (const posix_spawnattr_t*, struct sched_param*)
+function int posix_spawnattr_getschedpolicy (const posix_spawnattr_t*, int*)
+function int posix_spawnattr_getsigmask (const posix_spawnattr_t*, sigset_t*)
+function int posix_spawnattr_init (posix_spawnattr_t*)
+function int posix_spawnattr_setsigdefault (posix_spawnattr_t*, const sigset_t*)
+function int posix_spawnattr_setflags (posix_spawnattr_t*, short)
+function int posix_spawnattr_setpgroup (posix_spawnattr_t*, pid_t)
+function int posix_spawnattr_setschedparam (posix_spawnattr_t*, const struct sched_param*)
+function int posix_spawnattr_setschedpolicy (posix_spawnattr_t*, int)
+function int posix_spawnattr_setsigmask (posix_spawnattr_t*, const sigset_t*)
+function int posix_spawn_file_actions_addclose (posix_spawn_file_actions_t*, int)
+function int posix_spawn_file_actions_adddup2 (posix_spawn_file_actions_t*, int, int)
+function int posix_spawn_file_actions_addopen (posix_spawn_file_actions_t*, int, const char *, int, mode_t)
+function int posix_spawn_file_actions_destroy (posix_spawn_file_actions_t*)
+function int posix_spawn_file_actions_init (posix_spawn_file_actions_t*)
+function int posix_spawn (pid_t*, const char*, const posix_spawn_file_actions_t*, const posix_spawnattr_t*, char *const[], char *const[]);
+function int posix_spawnp (pid_t*, const char*, const posix_spawn_file_actions_t*, const posix_spawnattr_t*, char *const[], char *const[]);
+
+allow-header sched.h
+allow-header signal.h
+allow-header sys/types.h
+#endif
Index: trunk/src/libctests/glibc/conform/data/stdarg.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/stdarg.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/stdarg.h-data	(revision 2036)
@@ -0,0 +1,9 @@
+type va_list
+
+// XXX We didn't check the parameters.
+macro va_start
+macro va_arg
+macro va_end
+macro va_copy
+
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/stddef.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/stddef.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/stddef.h-data	(revision 2036)
@@ -0,0 +1,9 @@
+constant NULL
+
+macro offsetof
+
+type ptrdiff_t
+type wchar_t
+type size_t
+
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/stdint.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/stdint.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/stdint.h-data	(revision 2036)
@@ -0,0 +1,114 @@
+type int8_t
+type int16_t
+type int32_t
+type int64_t
+type uint8_t
+type uint16_t
+type uint32_t
+type uint64_t
+
+type int_least8_t
+type int_least16_t
+type int_least32_t
+type int_least64_t
+type uint_least8_t
+type uint_least16_t
+type uint_least32_t
+type uint_least64_t
+
+type int_fast8_t
+type int_fast16_t
+type int_fast32_t
+type int_fast64_t
+type uint_fast8_t
+type uint_fast16_t
+type uint_fast32_t
+type uint_fast64_t
+
+type intptr_t
+type uintptr_t
+
+type intmax_t
+type uintmax_t
+
+constant INT8_MIN == -128
+constant INT8_MAX == 127
+constant INT16_MIN == -32768
+constant INT16_MAX == 32767
+constant INT32_MIN == -2147483647-1
+constant INT32_MAX == 2147483647
+constant INT64_MIN == -9223372036854775807LL-1
+constant INT64_MAX == 9223372036854775807LL
+
+constant UINT8_MAX == 255
+constant UINT16_MAX == 65535
+constant UINT32_MAX == 4294967295U
+constant UINT64_MAX == 18446744073709551615ULL
+
+constant INT_LEAST8_MIN <= -128
+constant INT_LEAST8_MAX >= 127
+constant INT_LEAST16_MIN <= -32768
+constant INT_LEAST16_MAX >= 32767
+constant INT_LEAST32_MIN <= -2147483647-1
+constant INT_LEAST32_MAX >= 2147483647
+constant INT_LEAST64_MIN <= -9223372036854775807LL-1
+constant INT_LEAST64_MAX >= 9223372036854775807LL
+
+constant UINT_LEAST8_MAX >= 255
+constant UINT_LEAST16_MAX >= 65535
+constant UINT_LEAST32_MAX >= 4294967295U
+constant UINT_LEAST64_MAX >= 18446744073709551615ULL
+
+constant INT_FAST8_MIN <= -128
+constant INT_FAST8_MAX >= 127
+constant INT_FAST16_MIN <= -32768
+constant INT_FAST16_MAX >= 32767
+constant INT_FAST32_MIN <= -2147483647-1
+constant INT_FAST32_MAX >= 2147483647
+constant INT_FAST64_MIN <= -9223372036854775807LL-1
+constant INT_FAST64_MAX >= 9223372036854775807LL
+
+constant UINT_FAST8_MAX >= 255
+constant UINT_FAST16_MAX >= 65535
+constant UINT_FAST32_MAX >= 4294967295U
+constant UINT_FAST64_MAX >= 18446744073709551615ULL
+
+constant INTPTR_MIN <= -32768
+constant INTPTR_MAX >= 32767
+
+constant UINTPTR_MAX >= 65535
+
+constant INTMAX_MIN <= -9223372036854775807LL-1
+constant INTMAX_MAX >= 9223372036854775807LL
+
+constant UINTMAX_MAX >= 18446744073709551615ULL
+
+constant PTRDIFF_MIN <= -65535
+constant PTRDIFF_MAX >= 65535
+
+constant SIG_ATOMIC_MIN <= -127
+constant SIG_ATOMIC_MAX >= 127
+
+constant SIZE_MAX >= 65535
+
+constant WCHAR_MIN <= -127
+constant WCHAR_MAX >= 127
+
+constant WINT_MIN <= -127
+constant WINT_MAX >= 127
+
+macro INT8_C
+macro INT16_C
+macro INT32_C
+macro INT64_C
+macro UINT8_C
+macro UINT16_C
+macro UINT32_C
+macro UINT64_C
+macro INTMAX_C
+macro UINTMAX_C
+
+// The following expressions are not entirely correct but the current
+// fnamtch implementation doesn't grok the right form.
+allow INT*
+allow UINT*
Index: trunk/src/libctests/glibc/conform/data/stdio.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/stdio.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/stdio.h-data	(revision 2036)
@@ -0,0 +1,119 @@
+constant BUFSIZ
+constant FILENAME_MAX
+constant FOPEN_MAX >= 8
+
+constant _IOFBF
+constant _IOLBF
+constant _IONBF
+
+constant L_ctermid
+constant L_cuserid
+constant L_tmpnam
+
+constant SEEK_CUR
+constant SEEK_END
+constant SEEK_SET
+
+constant TMP_MAX >= 10000
+
+constant EOF
+
+constant NULL
+
+constant P_tmpdir
+
+macro stdin
+macro stdout
+macro stderr
+
+type FILE
+type fpos_t
+type va_list
+type size_t
+
+function void clearerr (FILE*)
+function {char*} ctermid (char*)
+function {char*} cuserid (char*)
+function int fclose (FILE*)
+function {FILE*} fdopen (int, const char*)
+function int feof (FILE*)
+function int ferror (FILE*)
+function int fflush (FILE*)
+function int fgetc (FILE*)
+function int fgetpos (FILE*, fpos_t*)
+function {char*} fgets (char*, int, FILE*)
+function int fileno (FILE*)
+function void flockfile (FILE*)
+function {FILE*} fopen (const char*, const char*)
+function int fprintf (FILE*, const char*, ...)
+function int fputc (int, FILE*)
+function int fputs (const char*, FILE*)
+function size_t fread (void*, size_t, size_t, FILE*)
+function {FILE*} freopen (const char*, const char*, FILE*)
+function int fscanf (FILE*, const char*, ...)
+function int fseek (FILE*, long int, int)
+function int fseeko (FILE*, off_t, int)
+function int fsetpos (FILE*, const fpos_t*)
+function {long int} ftell (FILE*)
+function off_t ftello (FILE*)
+function int ftrylockfile (FILE*)
+function void funlockfile (FILE*)
+function size_t fwrite (const void*, size_t, size_t, FILE*)
+function int getc (FILE*)
+function int getchar (void)
+function int getc_unlocked (FILE*)
+function int getchar_unlocked ()
+#ifndef XOPEN2K
+function int getopt (int, char *const[], const char *)
+#endif
+function {char*} gets (char*)
+function int getw (FILE*)
+function int pclose (FILE*)
+function void perror (const char*)
+function {FILE*} popen (const char*, const char*)
+function int printf (const char*, ...)
+function int putc (int, FILE*)
+function int putchar (int)
+function int putc_unlocked (int, FILE*)
+function int putchar_unlocked (int)
+function int puts (const char*)
+function int putw (int, FILE*)
+function int remove (const char*)
+function int rename (const char*, const char*)
+function void rewind (FILE*)
+function int scanf (const char*, ...)
+function void setbuf (FILE*, char*)
+function int setvbuf (FILE*, char*, int, size_t)
+function int snprintf (char*, size_t, const char*, ...)
+function int sprintf (char *, const char *, ...)
+function int sscanf (const char*, const char*, ...)
+function {char*} tempnam (const char*, const char*)
+function {FILE*} tmpfile (void)
+function {char*} tmpnam (char*)
+function int ungetc (int, FILE*)
+function int vfprintf (FILE*, const char*, va_list)
+#ifdef XOPEN2K
+function int vfscanf (FILE*, const char*, va_list)
+#endif
+function int vprintf (const char*, va_list)
+#ifdef XOPEN2K
+function int vscanf (const char*, va_list)
+#endif
+function int vsnprintf (char*, size_t, const char*, va_list)
+function int vsprintf (char*, const char*, va_list)
+#ifdef XOPEN2K
+function int vsscanf (const char*, const char*, va_list)
+#endif
+
+#if !defined ISO && !defined POSIX
+#ifndef XOPEN2K
+variable {char*} optarg
+variable int opterr
+variable int optind
+variable int optopt
+#endif
+
+allow-header stddef.h
+
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/stdlib.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/stdlib.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/stdlib.h-data	(revision 2036)
@@ -0,0 +1,112 @@
+macro EXIT_FAILURE
+constant EXIT_SUCCESS 0
+macro NULL
+constant RAND_MAX >= 32767
+macro MB_CUR_MAX
+
+type div_t
+element div_t int quot
+element div_t int rem
+type ldiv_t
+element ldiv_t long quot
+element ldiv_t long rem
+#ifdef XOPEN2K
+type lldiv_t
+element lldiv_t {long long} quot
+element lldiv_t {long long} rem
+#endif
+type size_t
+type wchar_t
+
+constant WNOHANG
+constant WUNTRACED
+
+macro WEXITSTATUS
+macro WIFEXITED
+macro WIFSIGNALED
+macro WIFSTOPPED
+macro WSTOPSIG
+macro WTERMSIG
+
+function void _Exit (int)
+function long a64l (const char*)
+function void abort (void)
+function int abs (int)
+function int atexit (void(*)(void))
+function double atof (const char*)
+function int atoi (const char*)
+function {long int} atol (const char*)
+#ifdef XOPEN2K
+function {long long} atoll (const char*)
+#endif
+function {void*} bsearch (const void*, const void*, size_t, size_t, int(*)(const void*, const void*))
+function {void*} calloc (size_t, size_t)
+function div_t div (int, int)
+function double drand48 (void)
+function {char*} ecvt (double, int, int*, int*)
+function double erand48 (unsigned short int[3])
+function void exit (int)
+function {char*} fcvt (double, int, int*, int*)
+function void free (void*)
+function {char*} gcvt (double, int, char*)
+function {char*} getenv (const char*)
+function int getsubopt (char**, char *const*, char**)
+function int grantpt (int)
+function {char*} initstate (unsigned int, char*, size_t)
+function {long int} jrand48 (unsigned short int[3])
+function {char*} l64a (long)
+function {long int} labs (long int)
+function void lcong48 (unsigned short int[7])
+function ldiv_t ldiv (long int, long int)
+#ifdef XOPEN2K
+function {long long} llabs (long long)
+function lldiv_t lldiv (long long, long long)
+#endif
+function {long int} lrand48 (void)
+function {void*} malloc (size_t)
+function int mblen (const char*, size_t)
+function size_t mbstowcs (wchar_t*, const char*, size_t)
+function int mbtowc (wchar_t*, const char*, size_t)
+function {char*} mktemp (char*)
+function int mkstemp (char*)
+function {long int} mrand48 (void)
+function {long int} nrand48 (unsigned short int[3])
+function int posix_memalign (void**, size_t, size_t)
+#ifdef XOPEN2K
+function int posix_openpt (int)
+#endif
+function {char*} ptsname (int)
+function int putenv (char*)
+function void qsort (void*, size_t, size_t, int(*)(const void*, const void*))
+function int rand (void)
+function int rand_r (unsigned int*)
+function long random (void)
+function {void*} realloc (void*, size_t)
+function {char*} realpath (const char*, char*)
+function {unsigned short int*} seed48 (unsigned short int[3])
+function int setenv (const char*, const char*, int)
+function void setkey (const char*)
+function {char*} setstate (const char*)
+function void srand (unsigned int)
+function void srand48 (long int)
+function void srandom (unsigned)
+function double strtod (const char*, char**)
+function {long int} strtol (const char*, char**, int)
+function {unsigned long int} strtoul (const char*, char**, int)
+function int system (const char*)
+#ifndef XOPEN2K
+function int ttyslot (void)
+#endif
+function int unlockpt (int)
+function int unsetenv (const char*)
+function {void*} valloc (size_t)
+function size_t wcstombs (char*, const wchar_t*, size_t)
+function int wctomb (char*, wchar_t)
+
+allow-header stddef.h
+allow-header limits.h
+allow-header math.h
+allow-header sys/wait.h
+
+allow str*
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/string.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/string.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/string.h-data	(revision 2036)
@@ -0,0 +1,38 @@
+constant NULL
+
+type size_t
+
+function {void*} memccpy (void*, const void*, int, size_t)
+function {void*} memchr (const void*, int, size_t)
+function int memcmp (const void*, const void*, size_t)
+function {void*} memcpy (void*, const void*, size_t)
+function {void*} memmove (void*, const void*, size_t)
+function {void*} memset (void*, int, size_t)
+function {char*} strcat (char*, const char*)
+function {char*} strchr (const char*, int)
+function int strcmp (const char*, const char*)
+function int strcoll (const char*, const char*)
+function {char*} strcpy (char*, const char*)
+function size_t strcspn (const char*, const char*)
+function {char*} strdup (const char*)
+function {char*} strerror (int)
+#ifdef XOPEN2K
+function {char*} strerror_r (int, char*, size_t)
+#endif
+function size_t strlen (const char*)
+function {char*} strncat (char*, const char*, size_t)
+function int strncmp (const char*, const char*, size_t)
+function {char*} strncpy (char*, const char*, size_t)
+function {char*} strpbrk (const char*, const char*)
+function {char*} strrchr (const char*, int)
+function size_t strspn (const char*, const char*)
+function {char*} strstr (const char*, const char*)
+function {char*} strtok (char*, const char*)
+function {char*} strtok_r (char*, const char*, char**)
+function size_t strxfrm (char*, const char*, size_t)
+
+allow-header stddef.h
+
+allow str*
+allow wcs*
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/strings.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/strings.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/strings.h-data	(revision 2036)
@@ -0,0 +1,12 @@
+function int bcmp (const void*, const void*, size_t)
+function void bcopy (const void*, void*, size_t)
+function void bzero (void*, size_t)
+function int ffs (int)
+function {char*} index (const char*, int)
+function {char*} rindex (const char*, int)
+function int strcasecmp (const char*, const char*)
+function int strncasecmp (const char*, const char*, size_t)
+
+type size_t
+
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/stropts.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/stropts.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/stropts.h-data	(revision 2036)
@@ -0,0 +1,137 @@
+type {struct bandinfo}
+
+element {struct bandinfo} {unsigned char} bi_pri
+element {struct bandinfo} int bi_flag
+
+type {struct strpeek}
+
+element {struct strpeek} {struct strbuf} ctlbuf
+element {struct strpeek} {struct strbuf} databuf
+element {struct strpeek} t_uscalar_t flags
+
+type {struct strbuf}
+
+element {struct strbuf} int maxlen
+element {struct strbuf} int len
+element {struct strbuf} {char*} buf
+
+type {struct strfdinsert}
+
+element {struct strfdinsert} {struct strbuf} ctlbuf
+element {struct strfdinsert} {struct strbuf} databuf
+element {struct strfdinsert} t_uscalar_t flags
+element {struct strfdinsert} int fildes
+element {struct strfdinsert} int offset
+
+type {struct strioctl}
+
+element {struct strioctl} int ic_cmd
+element {struct strioctl} int ic_timout
+element {struct strioctl} int ic_len
+element {struct strioctl} {char*} ic_dp
+
+type {struct strrecvfd}
+
+element {struct strrecvfd} int fd
+element {struct strrecvfd} uid_t uid
+element {struct strrecvfd} gid_t gid
+
+type uid_t
+type gid_t
+
+type t_uscalar_t
+
+type {struct str_list}
+
+element {struct str_list} int sl_nmods
+element {struct str_list} {struct str_mlist*} sl_modlist
+
+type {struct str_mlist}
+
+element {struct str_mlist} char l_name [FMNAMESZ+1]
+
+macro I_PUSH
+macro I_POP
+macro I_LOOK
+macro FMNAMESZ
+macro I_FLUSH
+macro FLUSHR
+macro FLUSHW
+macro FLUSHRW
+macro I_FLUSHBAND
+macro I_SETSIG
+macro S_RDNORM
+macro S_RDBAND
+macro S_INPUT
+macro S_HIPRI
+macro S_OUTPUT
+macro S_WRNORM
+macro S_WRBAND
+macro S_MSG
+macro S_ERROR
+macro S_HANGUP
+macro S_BANDURG
+macro I_GETSIG
+macro I_FIND
+macro I_PEEK
+macro RS_HIPRI
+macro I_SRDOPT
+macro RNORM
+macro RMSGD
+macro RMSGN
+macro RPROTNORM
+macro RPROTDAT
+macro RPROTDIS
+macro I_GRDOPT
+macro I_NREAD
+macro I_FDINSERT
+macro I_STR
+macro I_SWROPT
+macro SNDZERO
+macro I_GWROPT
+macro I_SENDFD
+macro I_RECVFD
+macro I_LIST
+macro I_ATMARK
+macro ANYMARK
+macro LASTMARK
+macro I_CKBAND
+macro I_GETBAND
+macro I_CANPUT
+macro I_SETCLTIME
+macro I_GETCLTIME
+macro I_LINK
+macro I_UNLINK
+macro I_PLINK
+macro I_PUNLINK
+
+macro MSG_ANY
+macro MSG_BAND
+macro MSG_HIPRI
+macro MORECTL
+macro MOREDATA
+
+function int isastream (int)
+function int getmsg (int, struct strbuf*, struct strbuf*, int*)
+function int getpmsg (int, struct strbuf*, struct strbuf*, int*, int*)
+function int ioctl (int, int, ...)
+function int putmsg (int, const struct strbuf*, const struct strbuf*, int)
+function int putpmsg (int, const struct strbuf*, const struct strbuf*, int, int)
+function int fattach (int, const char*)
+function int fdetach (const char*)
+
+allow-header unistd.h
+
+allow bi_*
+allow ic_*
+allow l_*
+allow sl_*
+allow str_*
+allow FLUSH*
+allow I_*
+allow M_*
+allow MUXID_R*
+allow S_*
+allow SND*
+allow STR*
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/sys/ipc.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/sys/ipc.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/sys/ipc.h-data	(revision 2036)
@@ -0,0 +1,28 @@
+type {struct ipc_perm}
+
+element {struct ipc_perm} uid_t uid
+element {struct ipc_perm} gid_t gid
+element {struct ipc_perm} uid_t cuid
+element {struct ipc_perm} gid_t cgid
+element {struct ipc_perm} mode_t mode
+
+type uid_t
+type gid_t
+type mode_t
+type key_t
+
+constant IPC_CREAT
+constant IPC_EXCL
+constant IPC_NOWAIT
+
+constant IPC_PRIVATE
+
+constant IPC_RMID
+constant IPC_SET
+constant IPC_STAT
+
+function key_t ftok (const char*, int)
+
+allow ipc_*
+allow IPC_*
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/sys/mman.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/sys/mman.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/sys/mman.h-data	(revision 2036)
@@ -0,0 +1,56 @@
+constant PROT_READ
+constant PROT_WRITE
+constant PROT_EXEC
+constant PROT_NONE
+
+constant MAP_SHARED
+constant MAP_PRIVATE
+constant MAP_FIXED
+
+constant MS_ASYNC
+constant MS_SYNC
+constant MS_INVALIDATE
+
+constant MCL_CURRENT
+constant MCL_FUTURE
+
+constant MAP_FAILED
+
+constant POSIX_MADV_NORMAL
+constant POSIX_MADV_SEQUENTIAL
+constant POSIX_MADV_RANDOM
+constant POSIX_MADV_WILLNEED
+constant POSIX_MADV_DONTNEED
+
+optional-constant POSIX_TYPED_MEM_ALLOCATE
+optional-constant POSIX_TYPED_MEM_ALLOCATE_CONTIG
+optional-constant POSIX_TYPED_MEM_MAP_ALLOCATABLE
+
+type size_t
+type off_t
+type mode_t
+
+optional-type {struct posix_typedmem_info}
+optional-element {struct posix_typedmem_info} size_t posix_tmi_length
+
+function int mlock (const void*, size_t)
+function int mlockall (int)
+function {void*} mmap (void*, size_t, int, int, int, off_t)
+function int mprotect (void*, size_t, int)
+function int msync (void*, size_t, int)
+function int munlock (const void*, size_t)
+function int munlockall (void)
+function int munmap (void*, size_t)
+function int posix_madvise (void*, size_t, int)
+optional-function int posix_mem_offset (const void*, size_t, off_t*, size_t*, int*)
+optional-function int posix_typed_mem_get_info (int, struct posix_typed_mem_info*)
+optional-function int posix_typed_mem_open (const char*, int, int)
+function int shm_open (const char*, int, mode_t)
+function int shm_unlink (const char*)
+
+allow shm_*
+allow MAP_*
+allow MCL_*
+allow MS_*
+allow PROT_*
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/sys/msg.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/sys/msg.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/sys/msg.h-data	(revision 2036)
@@ -0,0 +1,32 @@
+type {struct msqid_ds}
+
+type msgqnum_t
+type msglen_t
+
+constant MSG_NOERROR
+
+element {struct msqid_ds} {struct ipc_perm} msg_perm
+element {struct msqid_ds} msgqnum_t msg_qnum
+element {struct msqid_ds} msglen_t msg_qbytes
+element {struct msqid_ds} pid_t msg_lspid
+element {struct msqid_ds} pid_t msg_lrpid
+element {struct msqid_ds} time_t msg_stime
+element {struct msqid_ds} time_t msg_rtime
+element {struct msqid_ds} time_t msg_ctime
+
+type pid_t
+type time_t
+type key_t
+type size_t
+type ssize_t
+
+function int msgctl (int, int, struct msqid_ds*)
+function int msgget (key_t, int)
+function ssize_t msgrcv (int, void*, size_t, long int, int)
+function int msgsnd (int, const void*, size_t, int)
+
+allow-header sys/ipc.h
+
+allow msg*
+allow MSG*
+allow *_h
Index: trunk/src/libctests/glibc/conform/data/sys/resource.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/sys/resource.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/sys/resource.h-data	(revision 2036)
@@ -0,0 +1,50 @@
+constant PRIO_PROCESS
+constant PRIO_PGRP
+constant PRIO_USER
+
+type rlim_t
+
+constant RLIM_INFINITY
+constant RLIM_SAVED_MAX
+constant RLIM_SAVED_CUR
+
+constant RUSAGE_SELF
+constant RUSAGE_CHILDREN
+
+type {struct rlimit}
+
+element {struct rlimit} rlim_t rlim_cur
+element {struct rlimit} rlim_t rlim_max
+
+type {struct rusage}
+
+element {struct rusage} {struct timeval} ru_utime
+element {struct rusage} {struct timeval} ru_stime
+
+type {struct timeval}
+
+constant RLIMIT_CORE
+constant RLIMIT_CPU
+constant RLIMIT_DATA
+constant RLIMIT_FSIZE
+constant RLIMIT_NOFILE
+constant RLIMIT_STACK
+constant RLIMIT_AS
+
+function int getpriority (int, id_t)
+function int getrlimit (int, struct rlimit*)
+function int getrusage (int, struct rusage*)
+function int setpriority (int, id_t, int)
+function int setrlimit (int, const struct rlimit*)
+
+type id_t
+
+allow-header sys/time.h
+
+allow rlim_*
+allow ru_*
+allow PRIO_*
+allow RLIM_*
+allow RLIMIT_*
+allow RUSAGE_*
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/sys/select.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/sys/select.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/sys/select.h-data	(revision 2036)
@@ -0,0 +1,33 @@
+#if !defined ISO && !defined POSIX
+type time_t
+type suseconds_t
+
+type {struct timeval}
+element {struct timeval} time_t tv_sec
+element {struct timeval} suseconds_t tv_usec
+
+type sigset_t
+
+type {struct timespec}
+element {struct timespec} time_t tv_sec
+element {struct timespec} long tv_nsec
+
+type fd_set
+element fd_set long fds_bits []
+
+function-macro void FD_CLR (int, fd_set*)
+function-macro int FD_ISSET (int, fd_set*)
+function-macro void FD_SET (int, fd_set*)
+function-macro void FD_ZERO (fd_set*)
+
+macro FD_SETSIZE
+
+#ifdef XOPEN2K
+function int pselect (int, fd_set*, fd_set*, fd_set*, const struct timespec*, const sigset_t*)
+#endif
+function int select (int, fd_set*, fd_set*, fd_set*, struct timeval*)
+
+allow-header signal.h
+allow-header sys/time.h
+allow-header time.h
+#endif
Index: trunk/src/libctests/glibc/conform/data/sys/sem.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/sys/sem.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/sys/sem.h-data	(revision 2036)
@@ -0,0 +1,37 @@
+constant SEM_UNDO
+
+constant GETNCNT
+constant GETPID
+constant GETVAL
+constant GETALL
+constant GETZCNT
+constant SETVAL
+constant SETALL
+
+type {struct semid_ds}
+
+element {struct semid_ds} {struct ipc_perm} sem_perm
+element {struct semid_ds} {unsigned short int} sem_nsems
+element {struct semid_ds} time_t sem_otime
+element {struct semid_ds} time_t sem_ctime
+
+type pid_t
+type time_t
+type key_t
+type size_t
+
+type {struct sembuf}
+
+element {struct sembuf} {unsigned short int} sem_num
+element {struct sembuf} {short int} sem_op
+element {struct sembuf} {short int} sem_flg
+
+function int semctl (int, int, int, ...)
+function int semget (key_t, int, int)
+function int semop (int, struct sembuf*, size_t)
+
+allow-header sys/ipc.h
+
+allow sem*
+allow SEM_*
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/sys/shm.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/sys/shm.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/sys/shm.h-data	(revision 2036)
@@ -0,0 +1,32 @@
+constant SHM_RDONLY
+symbol SHMLBA
+constant SHM_RND
+
+type shmatt_t
+
+type {struct shmid_ds}
+
+element {struct shmid_ds} {struct ipc_perm} shm_perm
+element {struct shmid_ds} size_t shm_segsz
+element {struct shmid_ds} pid_t shm_lpid
+element {struct shmid_ds} pid_t shm_cpid
+element {struct shmid_ds} shmatt_t shm_nattch
+element {struct shmid_ds} time_t shm_atime
+element {struct shmid_ds} time_t shm_dtime
+element {struct shmid_ds} time_t shm_ctime
+
+type pid_t
+type time_t
+type key_t
+type size_t
+
+function {void*} shmat (int, const void*, int)
+function int shmctl (int, int, struct shmid_ds*)
+function int shmdt (const void*)
+function int shmget (key_t, size_t, int)
+
+allow-header sys/ipc.h
+
+allow shm*
+allow SHM*
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/sys/socket.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/sys/socket.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/sys/socket.h-data	(revision 2036)
@@ -0,0 +1,121 @@
+#ifndef ISO
+type socklen_t
+
+type sa_family_t
+
+type {struct sockaddr}
+
+element {struct sockaddr} sa_family_t sa_family
+element {struct sockaddr} char sa_data []
+
+type {struct sockaddr_storage}
+
+element {struct sockaddr_storage} sa_family_t ss_family
+
+type {struct msghdr}
+
+element {struct msghdr} {void*} msg_name
+element {struct msghdr} socklen_t msg_namelen
+element {struct msghdr} {struct iovec*} msg_iov
+element {struct msghdr} int msg_iovlen
+element {struct msghdr} {void*} msg_control
+element {struct msghdr} socklen_t msg_controllen
+element {struct msghdr} int msg_flags
+
+type {struct iovec}
+
+element {struct iovec} {void*} iov_base
+element {struct iovec} size_t iov_len
+
+type {struct cmsghdr}
+
+element {struct cmsghdr} socklen_t cmsg_len
+element {struct cmsghdr} int cmsg_level
+element {struct cmsghdr} int cmsg_type
+
+macro SCM_RIGHTS
+
+macro CMSG_DATA
+macro CMSG_NXTHDR
+macro CMSG_FIRSTHDR
+
+type {struct linger}
+
+element {struct linger} int l_onoff
+element {struct linger} int l_linger
+
+macro SOCK_DGRAM
+macro SOCK_STREAM
+macro SOCK_SEQPACKET
+
+macro SOL_SOCKET
+
+macro SO_ACCEPTCONN
+macro SO_BROADCAST
+macro SO_DEBUG
+macro SO_DONTROUTE
+macro SO_ERROR
+macro SO_KEEPALIVE
+macro SO_LINGER
+macro SO_OOBINLINE
+macro SO_RCVBUF
+macro SO_RCVLOWAT
+macro SO_RCVTIMEO
+macro SO_REUSEADDR
+macro SO_SNDBUF
+macro SO_SNDLOWAT
+macro SO_SNDTIMEO
+macro SO_TYPE
+
+macro SOMAXCONN
+
+macro MSG_CTRUNC
+macro MSG_DONTROUTE
+macro MSG_EOR
+macro MSG_OOB
+macro MSG_PEEK
+macro MSG_TRUNC
+macro MSG_WAITALL
+
+macro AF_UNIX
+macro AF_UNSPEC
+macro AF_INET
+macro AF_INET6
+
+macro SHUT_RD
+macro SHUT_WR
+macro SHUT_RDWR
+
+function int accept (int, struct sockaddr*, socklen_t*)
+function int bind (int, const struct sockaddr*, socklen_t)
+function int connect (int, const struct sockaddr*, socklen_t)
+function int getpeername (int, struct sockaddr*, socklen_t*)
+function int getsockname (int, struct sockaddr*, socklen_t*)
+function int getsockopt (int, int, int, void*, socklen_t*)
+function int listen (int, int)
+function ssize_t recv (int, void*, size_t, int)
+function ssize_t recvfrom (int, void*, size_t, int, struct sockaddr*, socklen_t*)
+function ssize_t recvmsg (int, struct msghdr*, int)
+function ssize_t send (int, const void*, size_t, int)
+function ssize_t sendmsg (int, const struct msghdr*, int)
+function ssize_t sendto (int, const void*, size_t, int, const struct sockaddr*, socklen_t)
+function int setsockopt (int, int, int, const void*, socklen_t)
+function int shutdown (int, int)
+function int socket (int, int, int)
+function int socketpair (int, int, int, int[2])
+function int sockatmark (int)
+
+allow-header sys/uio.h
+
+allow ss_*
+allow sa_*
+allow if_*
+allow ifc_*
+allow ifru_*
+allow infu_*
+allow ifra_*
+allow msg_*
+allow cmsg_*
+allow l_*
+allow SO*
+#endif
Index: trunk/src/libctests/glibc/conform/data/sys/stat.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/sys/stat.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/sys/stat.h-data	(revision 2036)
@@ -0,0 +1,79 @@
+#ifndef ISO
+
+type {struct stat}
+
+element {struct stat} dev_t st_dev
+element {struct stat} ino_t st_ino
+element {struct stat} mode_t st_mode
+element {struct stat} nlink_t st_nlink
+element {struct stat} uid_t st_uid
+element {struct stat} gid_t st_gid
+element {struct stat} dev_t st_rdev
+element {struct stat} off_t st_size
+element {struct stat} time_t st_atime
+element {struct stat} time_t st_mtime
+element {struct stat} time_t st_ctime
+element {struct stat} blksize_t st_blksize
+element {struct stat} blkcnt_t st_blocks
+
+type blkcnt_t
+type blksize_t
+type dev_t
+type ino_t
+type mode_t
+type nlink_t
+type uid_t
+type gid_t
+type off_t
+type time_t
+
+constant S_IFMT
+constant S_IFBLK
+constant S_IFCHR
+constant S_IFIFO
+constant S_IFREG
+constant S_IFDIR
+constant S_IFLNK
+
+constant S_IRWXU
+constant S_IRUSR
+constant S_IWUSR
+constant S_IXUSR
+constant S_IRWXG
+constant S_IWGRP
+constant S_IXGRP
+constant S_IRWXO
+constant S_IROTH
+constant S_IWOTH
+constant S_IXOTH
+constant S_ISUID
+constant S_ISGID
+constant S_ISVTX
+
+macro S_ISBLK
+macro S_ISCHR
+macro S_ISDIR
+macro S_ISFIFO
+macro S_ISREG
+macro S_ISLNK
+
+// How to represent optional tests?
+optional-macro S_TYPEISMQ
+optional-macro S_TYPEISSEM
+optional-macro S_TYPEISSHM
+optional-macro S_TYPEISTMO
+
+function int chmod (const char*, mode_t)
+function int fchmod (int, mode_t)
+function int fstat (int, struct stat*)
+function int lstat (const char*, struct stat*)
+function int mkdir (const char*, mode_t)
+function int mkfifo (const char*, mode_t)
+function int mknod (const char*, mode_t, dev_t)
+function int stat (const char*, struct stat*)
+function mode_t umask (mode_t)
+
+allow st_*
+allow S_*
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/sys/statvfs.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/sys/statvfs.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/sys/statvfs.h-data	(revision 2036)
@@ -0,0 +1,26 @@
+type {struct statvfs}
+
+element {struct statvfs} {unsigned long} f_bsize
+element {struct statvfs} {unsigned long} f_frsize
+element {struct statvfs} fsblkcnt_t f_blocks
+element {struct statvfs} fsblkcnt_t f_bfree
+element {struct statvfs} fsblkcnt_t f_bavail
+element {struct statvfs} fsfilcnt_t f_files
+element {struct statvfs} fsfilcnt_t f_ffree
+element {struct statvfs} fsfilcnt_t f_favail
+element {struct statvfs} {unsigned long} f_fsid
+element {struct statvfs} {unsigned long} f_flag
+element {struct statvfs} {unsigned long} f_namemax
+
+type fsblkcnt_t
+type fsfilcnt_t
+
+constant ST_RDONLY
+constant ST_NOSUID
+
+function int statvfs (const char*, struct statvfs*)
+function int fstatvfs (int, struct statvfs*)
+
+allow f_*
+allow ST_*
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/sys/time.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/sys/time.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/sys/time.h-data	(revision 2036)
@@ -0,0 +1,43 @@
+#ifndef ISO
+type {struct timeval}
+
+element {struct timeval} time_t tv_sec
+element {struct timeval} suseconds_t tv_usec
+
+type {struct itimerval}
+
+element {struct itimerval} {struct timeval} it_interval
+element {struct itimerval} {struct timeval} it_value
+
+type time_t
+type suseconds_t
+
+type fd_set
+element fd_set long fds_bits []
+
+constant ITIMER_REAL
+constant ITIMER_VIRTUAL
+constant ITIMER_PROF
+
+macro FD_CLR
+macro FD_ISSET
+macro FD_SET
+macro FD_ZERO
+
+constant FD_SETSIZE
+
+function int getitimer (int, struct itimerval*)
+function int setitimer (int, const struct itimerval*, struct itimerval*)
+function int gettimeofday (struct timeval*, void*)
+function int select (int, fd_set*, fd_set*, fd_set*, struct timeval*)
+function int utimes (const char*, const struct timeval [2])
+
+allow fds_*
+allow it_*
+allow tv_*
+allow FD_*
+allow ITIMER_*
+allow *_t
+
+allow-header sys/select.h
+#endif
Index: trunk/src/libctests/glibc/conform/data/sys/timeb.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/sys/timeb.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/sys/timeb.h-data	(revision 2036)
@@ -0,0 +1,12 @@
+type {struct timeb}
+
+element {struct timeb} time_t time
+element {struct timeb} {unsigned short} millitm
+element {struct timeb} short timezone
+element {struct timeb} short dstflag
+
+type time_t
+
+function int ftime (struct timeb*)
+
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/sys/times.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/sys/times.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/sys/times.h-data	(revision 2036)
@@ -0,0 +1,13 @@
+type {struct tms}
+
+element {struct tms} clock_t tms_utime
+element {struct tms} clock_t tms_stime
+element {struct tms} clock_t tms_cutime
+element {struct tms} clock_t tms_cstime
+
+type clock_t
+
+function clock_t times (struct tms*)
+
+allow tms_*
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/sys/types.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/sys/types.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/sys/types.h-data	(revision 2036)
@@ -0,0 +1,37 @@
+type blkcnt_t
+type blksize_t
+type clock_t
+type clockid_t
+type dev_t
+type fsblkcnt_t
+type fsfilcnt_t
+type gid_t
+type id_t
+type ino_t
+type key_t
+type mode_t
+type nlink_t
+type off_t
+type pid_t
+type pthread_attr_t
+type pthread_barrier_t
+type pthread_barrierattr_t
+type pthread_cond_t
+type pthread_condattr_t
+type pthread_key_t
+type pthread_mutex_t
+type pthread_mutexattr_t
+type pthread_once_t
+type pthread_rwlock_t
+type pthread_rwlockattr_t
+type pthread_spinlock_t
+type pthread_t
+type size_t
+type ssize_t
+type suseconds_t
+type time_t
+type timer_t
+type uid_t
+type useconds_t
+
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/sys/uio.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/sys/uio.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/sys/uio.h-data	(revision 2036)
@@ -0,0 +1,12 @@
+type {struct iovec}
+
+element {struct iovec} {void*} iov_base
+element {struct iovec} size_t iov_len
+
+function ssize_t readv (int, const struct iovec*, int)
+function ssize_t writev (int, const struct iovec*, int)
+
+allow iov_*
+allow IOV_*
+allow *_t
+allow UIO_MAXIOV
Index: trunk/src/libctests/glibc/conform/data/sys/un.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/sys/un.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/sys/un.h-data	(revision 2036)
@@ -0,0 +1,8 @@
+#ifndef ISO
+type {struct sockaddr_un}
+
+element {struct sockaddr_un} sa_family_t sun_family
+element {struct sockaddr_un} char sun_path []
+
+type sa_family_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/sys/utsname.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/sys/utsname.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/sys/utsname.h-data	(revision 2036)
@@ -0,0 +1,11 @@
+#ifndef ISO
+type {struct utsname}
+
+element {struct utsname} char sysname []
+element {struct utsname} char nodename []
+element {struct utsname} char release []
+element {struct utsname} char version []
+element {struct utsname} char machine []
+
+function int uname (struct utsname *)
+#endif
Index: trunk/src/libctests/glibc/conform/data/sys/wait.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/sys/wait.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/sys/wait.h-data	(revision 2036)
@@ -0,0 +1,64 @@
+constant WNOHANG
+constant WUNTRACED
+
+macro WEXITSTATUS
+macro WIFCONTINUED
+macro WIFEXITED
+macro WIFSIGNALED
+macro WIFSTOPPED
+macro WSTOPSIG
+macro WTERMSIG
+
+constant WEXITED
+constant WSTOPPED
+constant WCONTINUED
+constant WNOHANG
+constant WNOWAIT
+
+type idtype_t
+
+constant P_ALL
+constant P_PID
+constant P_PGID
+
+type id_t
+
+type siginfo_t
+
+element siginfo_t int si_signo
+element siginfo_t int si_errno
+element siginfo_t int si_code
+element siginfo_t pid_t si_pid
+element siginfo_t uid_t si_uid
+element siginfo_t {void*} si_addr
+element siginfo_t int si_status
+element siginfo_t long si_band
+element siginfo_t {union sigval} si_value
+
+type {struct rusage}
+
+element {struct rusage} {struct timeval} ru_utime
+element {struct rusage} {struct timeval} ru_stime
+
+type pid_t
+
+function pid_t wait (int*)
+function pid_t wait3 (int*, int, struct rusage*)
+function int waitid (idtype_t, id_t, siginfo_t*, int)
+function pid_t waitpid (pid_t, int*, int)
+
+allow-header signal.h
+allow-header sys/resource.h
+
+allow si_*
+allow W*
+allow P_*
+allow BUS_
+allow CLD_
+allow FPE_
+allow ILL_
+allow POLL_
+allow SEGV_
+allow SI_
+allow TRAP_
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/syslog.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/syslog.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/syslog.h-data	(revision 2036)
@@ -0,0 +1,42 @@
+constant LOG_PID
+constant LOG_CONS
+constant LOG_NDELAY
+constant LOG_ODELAY
+constant LOG_NOWAIT
+
+constant LOG_KERN
+constant LOG_USER
+constant LOG_MAIL
+constant LOG_NEWS
+constant LOG_UUCP
+constant LOG_DAEMON
+constant LOG_AUTH
+constant LOG_CRON
+constant LOG_LPR
+constant LOG_LOCAL0
+constant LOG_LOCAL1
+constant LOG_LOCAL2
+constant LOG_LOCAL3
+constant LOG_LOCAL4
+constant LOG_LOCAL5
+constant LOG_LOCAL6
+constant LOG_LOCAL7
+
+macro LOG_MASK
+
+constant LOG_EMERG
+constant LOG_ALERT
+constant LOG_CRIT
+constant LOG_ERR
+constant LOG_WARNING
+constant LOG_NOTICE
+constant LOG_INFO
+constant LOG_DEBUG
+
+function void closelog (void)
+function void openlog (const char*, int, int)
+function int setlogmask (int)
+function void syslog (int, const char*, ...)
+
+allow LOG_*
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/tar.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/tar.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/tar.h-data	(revision 2036)
@@ -0,0 +1,29 @@
+macro-str TMAGIC "ustar"
+constant TMAGLEN 6
+macro-str TVERSION "00"
+constant TVERSLEN 2
+
+constant REGTYPE
+constant AREGTYPE
+constant LNKTYPE
+constant SYMTYPE
+constant CHRTYPE
+constant BLKTYPE
+constant DIRTYPE
+constant FIFOTYPE
+constant CONTTYPE
+
+constant TSUID 04000
+constant TSGID 02000
+constant TSVTX 01000
+constant TUREAD 00400
+constant TUWRITE 00200
+constant TUEXEC 00100
+constant TGREAD 00040
+constant TGWRITE 00020
+constant TGEXEC 00010
+constant TOREAD 00004
+constant TOWRITE 00002
+constant TOEXEC 00001
+
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/termios.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/termios.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/termios.h-data	(revision 2036)
@@ -0,0 +1,159 @@
+type cc_t
+type speed_t
+type tcflag_t
+
+type {struct termios}
+
+element {struct termios} tcflag_t c_iflag
+element {struct termios} tcflag_t c_oflag
+element {struct termios} tcflag_t c_cflag
+element {struct termios} tcflag_t c_lflag
+element {struct termios} cc_t c_cc[NCCS]
+
+constant NCCS
+
+constant VEOF
+constant VEOL
+constant VERASE
+constant VINTR
+constant VKILL
+constant VMIN
+constant VQUIT
+constant VSTART
+constant VSTOP
+constant VSUSP
+constant VTIME
+
+constant BRKINT
+constant ICRNL
+constant IGNBRK
+constant IGNCR
+constant IGNPAR
+constant INLCR
+constant INPCK
+constant ISTRIP
+constant IUCLC
+constant IXANY
+constant IXOFF
+constant IXON
+constant PARMRK
+
+constant OPOST
+constant OLCUC
+constant ONLCR
+constant OCRNL
+constant ONOCR
+constant ONLRET
+constant OFILL
+constant NLDLY
+constant NL0
+constant NL1
+constant CRDLY
+constant CR0
+constant CR1
+constant CR2
+constant CR3
+constant TABDLY
+constant TAB0
+constant TAB1
+constant TAB2
+constant TAB3
+constant BSDLY
+constant BS0
+constant BS1
+constant VTDLY
+constant VT0
+constant VT1
+constant FFDLY
+constant FF0
+constant FF1
+
+constant B0
+constant B50
+constant B75
+constant B110
+constant B134
+constant B150
+constant B200
+constant B300
+constant B600
+constant B1200
+constant B1800
+constant B2400
+constant B4800
+constant B9600
+constant B19200
+constant B38400
+
+constant CSIZE
+constant CS5
+constant CS6
+constant CS7
+constant CS8
+constant CSTOPB
+constant CREAD
+constant PARENB
+constant PARODD
+constant HUPCL
+constant CLOCAL
+
+constant ECHO
+constant ECHOE
+constant ECHOK
+constant ECHONL
+constant ICANON
+constant IEXTEN
+constant ISIG
+constant NOFLSH
+constant TOSTOP
+constant XCASE
+
+constant TCSANOW
+constant TCSADRAIN
+constant TCSAFLUSH
+
+constant TCIFLUSH
+constant TCIOFLUSH
+
+constant TCIOFF
+constant TCION
+constant TCOOFF
+constant TCOON
+
+function speed_t cfgetispeed (const struct termios*)
+function speed_t cfgetospeed (const struct termios*)
+function int cfsetispeed (struct termios*, speed_t)
+function int cfsetospeed (struct termios*, speed_t)
+function int tcdrain (int)
+function int tcflow (int, int)
+function int tcflush (int, int)
+function int tcgetattr (int, struct termios*)
+function pid_t tcgetsid (int)
+function int tcsendbreak (int, int)
+function int tcsetattr (int, int, const struct termios*)
+
+allow CBAUD
+allow DEFECHO
+allow ECHOCTL
+allow ECHOKE
+allow ECHOPRT
+allow EXTA
+allow EXTB
+allow FLUSHO
+allow LOBLK
+allow PENDIN
+allow SWTCH
+allow VDISCARD
+allow VDSUSP
+allow VLNEXT
+allow VREPRINT
+allow VSTATUS
+allow VWERASE
+
+allow c_*
+allow V*
+allow I*
+allow O*
+allow TC*
+allow B*
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/tgmath.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/tgmath.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/tgmath.h-data	(revision 2036)
@@ -0,0 +1,398 @@
+#ifdef XOPEN2K
+// <math.h>
+macro fpclassify
+macro isfinite
+macro isinf
+macro isnan
+macro isnormal
+macro signbit
+macro isgreater
+macro isgreaterequal
+macro isless
+macro islessequal
+macro islessgreater
+macro isunordered
+
+constant M_E
+constant M_LOG2E
+constant M_LOG10E
+constant M_LN2
+constant M_LN10
+constant M_PI
+constant M_PI_2
+constant M_PI_4
+constant M_1_PI
+constant M_2_PI
+constant M_2_SQRTPI
+constant M_SQRT2
+constant M_SQRT1_2
+
+constant MAXFLOAT
+constant HUGE_VAL
+constant HUGE_VALF
+constant HUGE_VALL
+constant INFINITY
+constant NAN
+
+macro FP_INFINITE
+macro FP_NAN
+macro FP_NORMAL
+macro FP_SUBNORMAL
+macro FP_ZERO
+
+optional-macro FP_FAST_FMA
+optional-macro FP_FAST_FMAF
+optional-macro FP_FAST_FMAL
+
+constant FP_ILOGB0
+constant FP_ILOGBNAN
+
+macro MATH_ERRNO == 1
+macro MATH_ERREXCEPT == 2
+
+function double acos (double)
+function double asin (double)
+function double atan (double)
+function double atan2 (double, double)
+function double ceil (double)
+function double copysign (double, double)
+function double cos (double)
+function double cosh (double)
+function double exp (double)
+function double exp2 (double)
+function double fabs (double)
+function double floor (double)
+function double fmod (double, double)
+function double frexp (double, int*)
+function double ldexp (double, int)
+function double log (double)
+function double log10 (double)
+function double log2 (double)
+function double modf (double, double*)
+function double pow (double, double)
+function double sin (double)
+function double sinh (double)
+function double sqrt (double)
+function double tan (double)
+function double tanh (double)
+function double erf (double)
+function double erfc (double)
+function double gamma (double)
+function double hypot (double, double)
+function double j0 (double)
+function double j1 (double)
+function double jn (int, double)
+function double lgamma (double)
+function double tgamma (double)
+function double y0 (double)
+function double y1 (double)
+function double yn (int, double)
+function int isnan (double)
+function double acosh (double)
+function double asinh (double)
+function double atanh (double)
+function double cbrt (double)
+function double expm1 (double)
+function int ilogb (double)
+function double log1p (double)
+function double logb (double)
+function double nextafter (double, double)
+function double nexttoward (double, long double)
+function double nearbyint (double)
+function double remainder (double, double)
+function double rint (double)
+function double round (double)
+function double trunc (double)
+function long lrint (double)
+function {long long} llrint (double)
+function long lround (double)
+function {long long} llround (double)
+function double remquo (double, double, int*)
+function double scalb (double, double)
+function double scalbn (double, int)
+function double scalbln (double, long)
+function double fdim (double, double)
+function double fmax (double, double)
+function double fmin (double, double)
+function double fma (double, double, double)
+function double nan (const char*)
+
+// variable signgam
+allow signgam
+
+function float acosf (float)
+function float asinf (float)
+function float atanf (float)
+function float atan2f (float, float)
+function float ceilf (float)
+function float copysignf (float, float)
+function float cosf (float)
+function float coshf (float)
+function float expf (float)
+function float exp2f (float)
+function float fabsf (float)
+function float floorf (float)
+function float fmodf (float, float)
+function float frexpf (float, int*)
+function float ldexpf (float, int)
+function float logf (float)
+function float log10f (float)
+function float log2f (float)
+function float modff (float, float*)
+function float powf (float, float)
+function float sinf (float)
+function float sinhf (float)
+function float sqrtf (float)
+function float tanf (float)
+function float tanhf (float)
+function float erff (float)
+function float erfcf (float)
+function float gammaf (float)
+function float hypotf (float, float)
+function float j0f (float)
+function float j1f (float)
+function float jnf (int, float)
+function float lgammaf (float)
+function float tgammaf (float)
+function float y0f (float)
+function float y1f (float)
+function float ynf (int, float)
+function int isnanf (float)
+function float acoshf (float)
+function float asinhf (float)
+function float atanhf (float)
+function float cbrtf (float)
+function float expm1f (float)
+function int ilogbf (float)
+function float log1pf (float)
+function float logbf (float)
+function float nextafterf (float, float)
+function float nexttowardf (float, long double)
+function float nearbyintf (float)
+function float remainderf (float, float)
+function float rintf (float)
+function float roundf (float)
+function float truncf (float)
+function long lrintf (float)
+function {long long} llrintf (float)
+function long lroundf (float)
+function {long long} llroundf (float)
+function float remquof (float, float, int*)
+function float scalbf (float, float)
+function float scalbnf (float, int)
+function float scalblnf (float, long)
+function float fdimf (float, float)
+function float fmaxf (float, float)
+function float fminf (float, float)
+function float fmaf (float, float, float)
+function float nanf (const char*)
+
+function {long double} acosl (long double)
+function {long double} asinl (long double)
+function {long double} atanl (long double)
+function {long double} atan2l (long double, long double)
+function {long double} ceill (long double)
+function {long double} copysignl (long double, long double)
+function {long double} cosl (long double)
+function {long double} coshl (long double)
+function {long double} expl (long double)
+function {long double} exp2l (long double)
+function {long double} fabsl (long double)
+function {long double} floorl (long double)
+function {long double} fmodl (long double, long double)
+function {long double} frexpl (long double, int*)
+function {long double} ldexpl (long double, int)
+function {long double} logl (long double)
+function {long double} log10l (long double)
+function {long double} log2l (long double)
+function {long double} modfl (long double, long double*)
+function {long double} powl (long double, long double)
+function {long double} sinl (long double)
+function {long double} sinhl (long double)
+function {long double} sqrtl (long double)
+function {long double} tanl (long double)
+function {long double} tanhl (long double)
+function {long double} erfl (long double)
+function {long double} erfcl (long double)
+function {long double} gammal (long double)
+function {long double} hypotl (long double, long double)
+function {long double} j0l (long double)
+function {long double} j1l (long double)
+function {long double} jnl (int, long double)
+function {long double} lgammal (long double)
+function {long double} tgammal (long double)
+function {long double} y0l (long double)
+function {long double} y1l (long double)
+function {long double} ynl (int, long double)
+function int isnanl (long double)
+function {long double} acoshl (long double)
+function {long double} asinhl (long double)
+function {long double} atanhl (long double)
+function {long double} cbrtl (long double)
+function {long double} expm1l (long double)
+function int ilogbl (long double)
+function {long double} log1pl (long double)
+function {long double} logbl (long double)
+function {long double} nextafterl (long double, long double)
+function {long double} nexttowardl (long double, long double)
+function {long double} nearbyintl (long double)
+function {long double} remainderl (long double, long double)
+function {long double} rintl (long double)
+function {long double} roundl (long double)
+function {long double} truncl (long double)
+function long lrintl (long double)
+function {long long} llrintl (long double)
+function long lroundl (long double)
+function {long long} llroundl (long double)
+function {long double} remquol (long double, long double, int*)
+function {long double} scalbl (long double, long double)
+function {long double} scalbnl (long double, int)
+function {long double} scalblnl (long double, long)
+function {long double} fdiml (long double, long double)
+function {long double} fmaxl (long double, long double)
+function {long double} fminl (long double, long double)
+function {long double} fmal (long double, long double, long double)
+function {long double} nanl (const char*)
+
+allow *_t
+allow FP_*
+
+// <complex.h>
+macro complex
+macro _Complex_I
+optional-macro imaginary
+optional-macro _Imaginary_I
+macro I
+
+function double cabs (double complex)
+function {double complex} cacos (double complex)
+function {double complex} cacosh (double complex)
+function double carg (double complex)
+function {double complex} casin (double complex)
+function {double complex} casinh (double complex)
+function {double complex} catan (double complex)
+function {double complex} catanh (double complex)
+function {double complex} ccos (double complex)
+function {double complex} ccosh (double complex)
+function {double complex} cexp (double complex)
+function double cimag (double complex)
+function {double complex} clog (double complex)
+function {double complex} conj (double complex)
+function {double complex} cpow (double complex, double complex)
+function {double complex} cproj (double complex)
+function double creal (double complex)
+function {double complex} csin (double complex)
+function {double complex} csinh (double complex)
+function {double complex} csqrt (double complex)
+function {double complex} ctan (double complex)
+function {double complex} ctanh (double complex)
+
+function float cabsf (float complex)
+function {float complex} cacosf (float complex)
+function {float complex} cacoshf (float complex)
+function float cargf (float complex)
+function {float complex} casinf (float complex)
+function {float complex} casinhf (float complex)
+function {float complex} catanf (float complex)
+function {float complex} catanhf (float complex)
+function {float complex} ccosf (float complex)
+function {float complex} ccoshf (float complex)
+function {float complex} cexpf (float complex)
+function float cimagf (float complex)
+function {float complex} clogf (float complex)
+function {float complex} conjf (float complex)
+function {float complex} cpowf (float complex, float complex)
+function {float complex} cprojf (float complex)
+function float crealf (float complex)
+function {float complex} csinf (float complex)
+function {float complex} csinhf (float complex)
+function {float complex} csqrtf (float complex)
+function {float complex} ctanf (float complex)
+function {float complex} ctanhf (float complex)
+
+function {long double} cabsl (long double complex)
+function {long double complex} cacosl (long double complex)
+function {long double complex} cacoshl (long double complex)
+function {long double} cargl (long double complex)
+function {long double complex} casinhl (long double complex)
+function {long double complex} casinl (long double complex)
+function {long double complex} catanhl (long double complex)
+function {long double complex} catanl (long double complex)
+function {long double complex} ccoshl (long double complex)
+function {long double complex} ccosl (long double complex)
+function {long double complex} cexpl (long double complex)
+function {long double} cimagl (long double complex)
+function {long double complex} clogl (long double complex)
+function {long double complex} conjl (long double complex)
+function {long double complex} cpowl (long double complex, long double complex)
+function {long double complex} cprojl (long double complex)
+function {long double} creall (long double complex)
+function {long double complex} csinhl (long double complex)
+function {long double complex} csinl (long double complex)
+function {long double complex} csqrtl (long double complex)
+function {long double complex} ctanhl (long double complex)
+function {long double complex} ctanl (long double complex)
+
+// <tgmath.h>
+macro acos
+macro asin
+macro atan
+macro acosh
+macro asinh
+macro atanh
+macro cos
+macro sin
+macro tan
+macro cosh
+macro sinh
+macro tanh
+macro exp
+macro pow
+macro sqrt
+macro fabs
+
+macro atan2
+macro cbrt
+macro ceil
+macro copysign
+macro erf
+macro erfc
+macro exp2
+macro expm1
+macro fdim
+macro floor
+macro fma
+macro fmax
+macro fmin
+macro fmod
+macro frexp
+macro hypot
+macro ilogb
+macro ldexp
+macro lgamma
+macro llrint
+macro llround
+macro log10
+macro log1p
+macro log2
+macro logb
+macro lrint
+macro lround
+macro nearbyint
+macro nextafter
+macro nexttoward
+macro remainder
+macro remquo
+macro rint
+macro round
+macro scalbn
+macro scalbln
+macro tgamma
+macro trunc
+
+macro carg
+macro cimag
+macro conj
+macro cproj
+macro creal
+#endif
Index: trunk/src/libctests/glibc/conform/data/time.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/time.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/time.h-data	(revision 2036)
@@ -0,0 +1,82 @@
+type {struct tm}
+
+element {struct tm} int tm_sec
+element {struct tm} int tm_min
+element {struct tm} int tm_hour
+element {struct tm} int tm_mday
+element {struct tm} int tm_mon
+element {struct tm} int tm_year
+element {struct tm} int tm_wday
+element {struct tm} int tm_yday
+element {struct tm} int tm_isdst
+
+constant NULL
+#ifndef XOPEN2K
+constant CLK_TCK
+#endif
+constant CLOCKS_PER_SEC
+constant CLOCK_PROCESS_CPUTIME_ID
+constant CLOCK_THREAD_CPUTIME_ID
+
+type {struct timespec}
+
+element {struct timespec} time_t tv_sec
+element {struct timespec} long tv_nsec
+
+type {struct itimerspec}
+
+element {struct itimerspec} {struct timespec} it_interval
+element {struct itimerspec} {struct timespec} it_value
+
+constant CLOCK_REALTIME
+constant TIME_ABSTIME
+constant CLOCK_MONOTONIC
+
+type clock_t
+type clockid_t
+type size_t
+type time_t
+type timer_t
+
+variable int getdate_err
+
+function {char*} asctime (const struct tm*)
+function {char*} asctime_r (const struct tm*, char*)
+function clock_t clock (void)
+function int clock_getcpuclockid (pid_t, clockid_t*)
+function int clock_getres (clockid_t, struct timespec*)
+function int clock_gettime (clockid_t, struct timespec*)
+function int clock_nanosleep (clockid_t, int, const struct timespec*, struct timespec*)
+function int clock_settime (clockid_t, const struct timespec*)
+function {char*} ctime (const time_t*)
+function {char*} ctime_r (const time_t*, char*)
+function double difftime (time_t, time_t)
+function {struct tm*} getdate (const char*)
+function {struct tm*} gmtime (const time_t*)
+function {struct tm*} gmtime_r (const time_t*, struct tm*)
+function {struct tm*} localtime (const time_t*)
+function {struct tm*} localtime_r (const time_t*, struct tm*)
+function time_t mktime (struct tm*)
+function int nanosleep (const struct timespec*, struct timespec*)
+function size_t strftime (char*, size_t, const char*, const struct tm*)
+function {char*} strptime (const char*, const char*, struct tm*)
+function time_t time (time_t*)
+function int timer_create (clockid_t, struct sigevent*, timer_t*)
+function int timer_delete (timer_t)
+function int timer_gettime (timer_t, struct itimerspec*)
+function int timer_getoverrun (timer_t)
+function int timer_settime (timer_t, int, const struct itimerspec*, struct itimerspec*)
+function void tzset (void)
+
+variable int daylight
+variable {long int} timezone
+variable {char*} tzname [2]
+
+allow tm_*
+allow clock_*
+allow timer_*
+allow it_*
+allow tv_*
+allow CLOCK_*
+allow TIMER_*
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/ucontext.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/ucontext.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/ucontext.h-data	(revision 2036)
@@ -0,0 +1,20 @@
+type mcontext_t
+
+type ucontext_t
+
+element ucontext_t {ucontext_t*} uc_link
+element ucontext_t sigset_t uc_sigmask
+element ucontext_t stack_t uc_stack
+element ucontext_t mcontext_t uc_mcontext
+
+type sigset_t
+type stack_t
+
+function int getcontext (ucontext_t*)
+function int setcontext (const ucontext_t*)
+function void makecontext (ucontext_t*, void(*)(void), int, ...)
+function int swapcontext (ucontext_t*, const ucontext_t*)
+
+allow uc_*
+allow ss_*
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/ulimit.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/ulimit.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/ulimit.h-data	(revision 2036)
@@ -0,0 +1,7 @@
+constant UL_GETFSIZE
+constant UL_SETFSIZE
+
+function {long int} ulimit (int, ...)
+
+allow UL_*
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/unistd.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/unistd.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/unistd.h-data	(revision 2036)
@@ -0,0 +1,377 @@
+#ifndef ISO
+optional-constant _POSIX_VERSION
+optional-constant _POSIX2_C_VERSION
+optional-constant _XOPEN_VERSION
+optional-constant _XOPEN_XCU_VERSION
+
+optional-constant _POSIX2_C_BIND
+optional-constant _POSIX2_CHAR_TERM
+optional-constant _POSIX2_LOCALEDEF
+optional-constant _POSIX2_UPE
+optional-constant _POSIX2_VERSION
+
+optional-constant _XOPEN_XPG2
+optional-constant _XOPEN_XPG3
+optional-constant _XOPEN_XPG4
+optional-constant _XOPEN_UNIX
+
+optional-constant _POSIX_ADVISORY_INFO
+optional-constant _POSIX_ASYNCHRONOUS_IO
+optional-constant _POSIX_BARRIERS
+optional-constant _POSIX_CHOWN_RESTRICTED
+optional-constant _POSIX_CLOCK_SELECTION
+optional-constant _POSIX_CPUTIME
+optional-constant _POSIX_NO_TRUNC
+optional-constant _POSIX_VDISABLE
+optional-constant _POSIX_SAVED_IDS
+optional-constant _POSIX_JOB_CONTROL
+optional-constant _POSIX_MONOTONIC_CLOCK
+optional-constant _POSIX_READER_WRITER_LOCKS
+optional-constant _POSIX_SHELL
+optional-constant _POSIX_SPAWN
+optional-constant _POSIX_SPIN_LOCKS
+optional-constant _POSIX_SPORADIC_SERVER
+optional-constant _POSIX_THREAD_CPUTIME
+optional-constant _POSIX_TYPED_MEMORY_OBJECTS
+
+optional-constant _POSIX_THREADS
+optional-constant _POSIX_THREAD_ATTR_STACKADDR
+optional-constant _POSIX_THREAD_ATTR_STACKSIZE
+optional-constant _POSIX_THREAD_PROCESS_SHARED
+optional-constant _POSIX_THREAD_SAFE_FUNCTIONS
+optional-constant _POSIX_THREAD_SPORADIC_SERVER
+
+optional-constant _POSIX2_C_DEV
+optional-constant _POSIX2_FORT_DEV
+optional-constant _POSIX2_FORT_RUN
+optional-constant _POSIX2_SW_DEV
+optional-constant _XOPEN_CRYPT
+optional-constant _XOPEN_ENH_I18N
+optional-constant _XOPEN_LEGACY
+optional-constant _XOPEN_REALTIME
+optional-constant _XOPEN_REALTIME_THREADS
+optional-constant _XOPEN_SHM
+optional-constant _XOPEN_STREAMS
+allow _XBS5_ILP32_OFF32
+allow _XBS5_ILP32_OFBIG
+allow _XBS5_LP64_OFF64
+allow _XBS5_LPBIG_OFFBIG
+optional-constant _POSIX_ASYNCHRONOUS_IO
+optional-constant _POSIX_MEMLOCK
+optional-constant _POSIX_MEMLOCK_RANGE
+optional-constant _POSIX_MESSAGE_PASSING
+optional-constant _POSIX_PRIORITY_SCHEDULING
+optional-constant _POSIX_REALTIME_SIGNALS
+optional-constant _POSIX_SEMAPHORES
+optional-constant _POSIX_SHARED_MEMORY_OBJECTS
+optional-constant _POSIX_SYNCHRONIZED_IO
+optional-constant _POSIX_TIMERS
+optional-constant _POSIX_TIMEOUTS
+
+optional-constant _POSIX_FSYNC
+optional-constant _POSIX_MAPPED_FILES
+optional-constant _POSIX_MEMORY_PROTECTION
+
+optional-constant _POSIX_PRIORITIZED_IO
+
+optional-constant _POSIX_THREAD_PRIORITY_SCHEDULING
+optional-constant _POSIX_THREAD_PRIO_INHERIT
+optional-constant _POSIX_THREAD_PRIO_PROTECT
+
+optional-constant _POSIX_ASYNC_IO
+optional-constant _POSIX_PRIO_IO
+optional-constant _POSIX_SYNC_IO
+
+optional-constant _POSIX2_PBS
+optional-constant _POSIX2_PBS_ACCOUNTING
+optional-constant _POSIX2_PBS_CHECKPOINT
+optional-constant _POSIX2_PBS_LOCATE
+optional-constant _POSIX2_PBS_MESSAGE
+optional-constant _POSIX2_PBS_TRACK
+
+constant NULL
+
+constant R_OK
+constant W_OK
+constant X_OK
+constant F_OK
+
+constant _CS_PATH
+constant _CS_XBS5_ILP32_OFF32_CFLAGS
+constant _CS_XBS5_ILP32_OFF32_LDFLAGS
+constant _CS_XBS5_ILP32_OFF32_LIBS
+constant _CS_XBS5_ILP32_OFF32_LINTFLAGS
+constant _CS_XBS5_ILP32_OFFBIG_CFLAGS
+constant _CS_XBS5_ILP32_OFFBIG_LDFLAGS
+constant _CS_XBS5_ILP32_OFFBIG_LIBS
+constant _CS_XBS5_ILP32_OFFBIG_LINTFLAGS
+constant _CS_XBS5_LP64_OFF64_CFLAGS
+constant _CS_XBS5_LP64_OFF64_LDFLAGS
+constant _CS_XBS5_LP64_OFF64_LIBS
+constant _CS_XBS5_LP64_OFF64_LINTFLAGS
+constant _CS_XBS5_LPBIG_OFFBIG_CFLAGS
+constant _CS_XBS5_LPBIG_OFFBIG_LDFLAGS
+constant _CS_XBS5_LPBIG_OFFBIG_LIBS
+constant _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS
+
+constant SEEK_SET
+constant SEEK_CUR
+constant SEEK_END
+
+constant _SC_2_C_BIND
+constant _SC_2_C_DEV
+constant _SC_2_C_VERSION
+constant _SC_2_FORT_DEV
+constant _SC_2_FORT_RUN
+constant _SC_2_LOCALEDEF
+constant _SC_2_PBS
+constant _SC_2_PBS_ACCOUNTING
+constant _SC_2_PBS_CHECKPOINT
+constant _SC_2_PBS_LOCATE
+constant _SC_2_PBS_MESSAGE
+constant _SC_2_PBS_TRACK
+constant _SC_2_SW_DEV
+constant _SC_2_UPE
+constant _SC_2_VERSION
+constant _SC_ARG_MAX
+constant _SC_AIO_LISTIO_MAX
+constant _SC_AIO_MAX
+constant _SC_AIO_PRIO_DELTA_MAX
+constant _SC_ASYNCHRONOUS_IO
+constant _SC_ATEXIT_MAX
+constant _SC_BARRIERS
+constant _SC_BASE
+constant _SC_BC_BASE_MAX
+constant _SC_BC_DIM_MAX
+constant _SC_BC_SCALE_MAX
+constant _SC_BC_STRING_MAX
+constant _SC_CHILD_MAX
+constant _SC_CLK_TCK
+constant _SC_CLOCK_SELECTION
+constant _SC_COLL_WEIGHTS_MAX
+constant _SC_DELAYTIMER_MAX
+constant _SC_DEVICE_IO
+constant _SC_DEVICE_SPECIFIC
+constant _SC_DEVICE_SPECIFIC_R
+constant _SC_EXPR_NEST_MAX
+constant _SC_FD_MGMT
+constant _SC_FIFO
+constant _SC_FILE_ATTRIBUTES
+constant _SC_FILE_LOCKING
+constant _SC_FILE_SYSTEM
+constant _SC_FSYNC
+constant _SC_GETGR_R_SIZE_MAX
+constant _SC_GETPW_R_SIZE_MAX
+constant _SC_IOV_MAX
+constant _SC_JOB_CONTROL
+constant _SC_LINE_MAX
+constant _SC_LOGIN_NAME_MAX
+constant _SC_MAPPED_FILES
+constant _SC_MEMLOCK
+constant _SC_MEMLOCK_RANGE
+constant _SC_MEMORY_PROTECTION
+constant _SC_MESSAGE_PASSING
+constant _SC_MONOTONIC_CLOCK
+constant _SC_MQ_OPEN_MAX
+constant _SC_MQ_PRIO_MAX
+constant _SC_NETWORKING
+constant _SC_NGROUPS_MAX
+constant _SC_OPEN_MAX
+constant _SC_PAGESIZE
+constant _SC_PAGE_SIZE
+constant _SC_PASS_MAX
+constant _SC_PIPE
+constant _SC_PRIORITIZED_IO
+constant _SC_PRIORITY_SCHEDULING
+constant _SC_RE_DUP_MAX
+constant _SC_READER_WRITER_LOCKS
+constant _SC_REALTIME_SIGNALS
+constant _SC_REGEXP
+constant _SC_RTSIG_MAX
+constant _SC_SAVED_IDS
+constant _SC_SEMAPHORES
+constant _SC_SEM_NSEMS_MAX
+constant _SC_SEM_VALUE_MAX
+constant _SC_SHARED_MEMORY_OBJECTS
+constant _SC_SHELL
+constant _SC_SIGNALS
+constant _SC_SIGQUEUE_MAX
+constant _SC_SINGLE_PROCESS
+constant _SC_SPIN_LOCKS
+constant _SC_STREAM_MAX
+constant _SC_SYNCHRONIZED_IO
+constant _SC_THREADS
+constant _SC_THREAD_ATTR_STACKADDR
+constant _SC_THREAD_ATTR_STACKSIZE
+constant _SC_THREAD_DESTRUCTOR_ITERATIONS
+constant _SC_THREAD_KEYS_MAX
+constant _SC_THREAD_PRIORITY_SCHEDULING
+constant _SC_THREAD_PRIO_INHERIT
+constant _SC_THREAD_PRIO_PROTECT
+constant _SC_THREAD_PROCESS_SHARED
+constant _SC_THREAD_SAFE_FUNCTIONS
+constant _SC_THREAD_STACK_MIN
+constant _SC_THREAD_THREADS_MAX
+constant _SC_TIMERS
+constant _SC_TIMER_MAX
+constant _SC_TTY_NAME_MAX
+constant _SC_TYPED_MEMORY_OBJECTS
+constant _SC_TZNAME_MAX
+constant _SC_USER_GROUPS
+constant _SC_USER_GROUPS_R
+constant _SC_VERSION
+constant _SC_XOPEN_VERSION
+constant _SC_XOPEN_CRYPT
+constant _SC_XOPEN_ENH_I18N
+constant _SC_XOPEN_SHM
+constant _SC_XOPEN_UNIX
+constant _SC_XOPEN_XCU_VERSION
+constant _SC_XOPEN_LEGACY
+constant _SC_XOPEN_REALTIME
+constant _SC_XOPEN_REALTIME_THREADS
+constant _SC_STREAMS
+constant _SC_XBS5_ILP32_OFF32
+constant _SC_XBS5_ILP32_OFFBIG
+constant _SC_XBS5_LP64_OFF64
+constant _SC_XBS5_LPBIG_OFFBIG
+
+constant F_LOCK
+constant F_ULOCK
+constant F_TEST
+constant F_TLOCK
+
+constant _PC_ASYNC_IO
+constant _PC_CHOWN_RESTRICTED
+constant _PC_FILESIZEBITS
+constant _PC_LINK_MAX
+constant _PC_MAX_CANON
+constant _PC_MAX_INPUT
+constant _PC_NAME_MAX
+constant _PC_NO_TRUNC
+constant _PC_PATH_MAX
+constant _PC_PIPE_BUF
+constant _PC_PRIO_IO
+constant _PC_REC_INCR_XFER_SIZE
+constant _PC_REC_MAX_XFER_SIZE
+constant _PC_REC_MIN_XFER_SIZE
+constant _PC_REC_XFER_ALIGN
+constant _PC_SYNC_IO
+constant _PC_VDISABLE
+
+constant STDIN_FILENO
+constant STDOUT_FILENO
+constant STDERR_FILENO
+
+type size_t
+type ssize_t
+type uid_t
+type gid_t
+type off_t
+type pid_t
+
+type useconds_t
+
+type intptr_t
+
+function int access (const char*, int)
+function {unsigned int} alarm (unsigned int)
+function int brk (void*)
+function int chdir (const char*)
+#if defined XPG3 || defined XPG4 || defined UNIX98
+function int chroot (const char*)
+#endif
+function int chown (const char*, uid_t, gid_t)
+function int close (int)
+function size_t confstr (int, char*, size_t)
+function {char*} crypt (const char*, const char*)
+function {char*} ctermid (char*)
+#if defined XPG3 || defined XPG4 || defined UNIX98
+function {char*} cuserid (char*)
+#endif
+function int dup (int)
+function int dup2 (int, int)
+function void encrypt (char[64], int)
+function int execl (const char*, const char*, ...)
+function int execle (const char*, const char*, ...)
+function int execlp (const char*, const char*, ...)
+function int execv (const char*, char *const[])
+function int execve (const char*, char *const[], char *const[])
+function int execvp (const char*, char *const[])
+function void _exit (int)
+function int fchown (int, uid_t, gid_t)
+function int fchdir (int)
+function int fdatasync (int)
+function pid_t fork (void)
+function {long int} fpathconf (int, int)
+function int fsync (int)
+function int ftruncate (int, off_t)
+function {char*} getcwd (char*, size_t)
+function int getdtablesize (void)
+function gid_t getegid (void)
+function uid_t geteuid (void)
+function gid_t getgid (void)
+function int getgroups (int, gid_t[])
+function long gethostid (void)
+function int gethostname (char*, size_t)
+function {char*} getlogin (void)
+function int getlogin_r (char*, size_t)
+function int getopt (int, char*const[], const char*)
+function int getpagesize (void)
+#if defined XPG3 || defined XPG4 || defined UNIX98
+function {char*} getpass (const char*)
+#endif
+function pid_t getpgid (pid_t)
+function pid_t getpgrp (void)
+function pid_t getpid (void)
+function pid_t getppid (void)
+function pid_t getsid (pid_t)
+function uid_t getuid (void)
+function {char*} getwd (char*)
+function int isatty (int)
+function int lchown (const char*, uid_t, gid_t)
+function int link (const char*, const char*)
+function int lockf (int, int, off_t)
+function off_t lseek (int, off_t, int)
+function int nice (int)
+function {long int} pathconf (const char*, int)
+function int pause (void)
+function int pipe (int[2])
+function ssize_t pread (int, void*, size_t, off_t)
+function int pthread_atfork (void(*)(void), void(*)(void), void(*)(void))
+function ssize_t pwrite (int, const void*, size_t, off_t)
+function ssize_t read (int, void*, size_t)
+function int readlink (const char*, char*, size_t)
+function int rmdir (const char*)
+function {void*} sbrk (intptr_t)
+function int setegid (gid_t)
+function int seteuid (uid_t)
+function int setgid (gid_t)
+function int setpgid (pid_t, pid_t)
+function pid_t setpgrp (void)
+function int setregid (gid_t, gid_t)
+function int setreuid (uid_t, uid_t)
+function pid_t setsid (void)
+function int setuid (uid_t)
+function {unsigned int} sleep (unsigned int)
+function void swab (const void*, void*, ssize_t)
+function int symlink (const char*, const char*)
+function void sync (void)
+function {long int} sysconf (int)
+function pid_t tcgetpgrp (int)
+function int tcsetpgrp (int, pid_t)
+function int truncate (const char*, off_t)
+function {char*} ttyname (int)
+function int ttyname_r (int, char*, size_t)
+function useconds_t ualarm (useconds_t, useconds_t)
+function int unlink (const char*)
+function int usleep (useconds_t)
+function pid_t vfork (void)
+function ssize_t write (int, const void*, size_t)
+
+variable {char*} optarg
+variable int optind
+variable int opterr
+variable int optopt
+
+allow *_t
+#endif
Index: trunk/src/libctests/glibc/conform/data/utime.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/utime.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/utime.h-data	(revision 2036)
@@ -0,0 +1,11 @@
+type {struct utimbuf}
+
+element {struct utimbuf} time_t actime
+element {struct utimbuf} time_t modtime
+
+type time_t
+
+function int utime (const char*, const struct utimbuf*)
+
+allow utim_*
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/utmpx.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/utmpx.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/utmpx.h-data	(revision 2036)
@@ -0,0 +1,36 @@
+type {struct utmpx}
+
+element {struct utmpx} char ut_user []
+element {struct utmpx} char ut_id []
+element {struct utmpx} char ut_line []
+element {struct utmpx} pid_t ut_pid
+element {struct utmpx} {short int} ut_type
+element {struct utmpx} {struct timeval} ut_tv
+
+type pid_t
+
+type {struct timeval}
+
+element {struct timeval} time_t tv_sec
+element {struct timeval} suseconds_t tv_usec
+
+constant EMPTY
+constant BOOT_TIME
+constant OLD_TIME
+constant NEW_TIME
+constant USER_PROCESS
+constant INIT_PROCESS
+constant LOGIN_PROCESS
+constant DEAD_PROCESS
+
+function void endutxent (void)
+function {struct utmpx*} getutxent (void)
+function {struct utmpx*} getutxid (const struct utmpx*)
+function {struct utmpx*} getutxline (const struct utmpx*)
+function {struct utmpx*} pututxline (const struct utmpx*)
+function void setutxent (void)
+
+allow-header sys/time.h
+
+allow ut_*
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/varargs.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/varargs.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/varargs.h-data	(revision 2036)
@@ -0,0 +1,8 @@
+macro va_alist
+macro va_dcl
+type va_list
+macro va_start
+macro va_arg
+macro va_end
+
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/wchar.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/wchar.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/wchar.h-data	(revision 2036)
@@ -0,0 +1,98 @@
+type wchar_t
+type wint_t
+type wctype_t
+type mbstate_t
+type FILE
+type size_t
+
+function wint_t btowc (int)
+function int fwprintf (FILE*, const wchar_t*, ...)
+function int fwscanf (FILE*, const wchar_t*, ...)
+#if !ISO
+function int iswalnum (wint_t)
+function int iswalpha (wint_t)
+function int iswcntrl (wint_t)
+function int iswdigit (wint_t)
+function int iswgraph (wint_t)
+function int iswlower (wint_t)
+function int iswprint (wint_t)
+function int iswpunct (wint_t)
+function int iswspace (wint_t)
+function int iswupper (wint_t)
+function int iswxdigit (wint_t)
+function int iswctype (wint_t, wctype_t)
+#endif
+function wint_t fgetwc (FILE*)
+function {wchar_t*} fgetws (wchar_t*, int, FILE*)
+function wint_t fputwc (wchar_t, FILE*)
+function int fputws (const wchar_t*, FILE*)
+function int fwide (FILE*, int)
+function wint_t getwc (FILE*)
+function wint_t getwchar (void)
+function int mbsinit (const mbstate_t*)
+function size_t mbrlen (const char*, size_t, mbstate_t*)
+function size_t mbrtowc (wchar_t*, const char*, size_t, mbstate_t*)
+function size_t mbsrtowcs (wchar_t*, const char**, size_t, mbstate_t*)
+function wint_t putwc (wchar_t, FILE*)
+function wint_t putwchar (wchar_t)
+function int swprintf (wchar_t*, size_t, const wchar_t*, ...)
+function int swscanf (const wchar_t*, const wchar_t*, ...)
+function wint_t towlower (wint_t)
+function wint_t towupper (wint_t)
+function wint_t ungetwc (wint_t, FILE*)
+function int vfwprintf (FILE*, const wchar_t*, va_list)
+function int vfwscanf (FILE*, const wchar_t*, va_list)
+function int vwprintf (const wchar_t*, va_list)
+function int vwscanf (const wchar_t*, va_list)
+function int vswprintf (wchar_t*, size_t, const wchar_t*, va_list)
+function int vswscanf (const wchar_t*, const wchar_t*, va_list)
+function size_t wcrtomb (char*, wchar_t, mbstate_t*)
+function {wchar_t*} wcscat (wchar_t*, const wchar_t*)
+function {wchar_t*} wcschr (const wchar_t*, wchar_t)
+function int wcscmp (const wchar_t*, const wchar_t*)
+function int wcscoll (const wchar_t*, const wchar_t*)
+function {wchar_t*} wcscpy (wchar_t*, const wchar_t*)
+function size_t wcscspn (const wchar_t*, const wchar_t*)
+function size_t wcsftime (wchar_t*, size_t, const wchar_t*, const struct tm*)
+function size_t wcslen (const wchar_t*)
+function {wchar_t*} wcsncat (wchar_t*, const wchar_t*, size_t)
+function int wcsncmp (const wchar_t*, const wchar_t*, size_t)
+function {wchar_t*} wcsncpy (wchar_t*, const wchar_t*, size_t)
+function {wchar_t*} wcspbrk (const wchar_t*, const wchar_t*)
+function {wchar_t*} wcsrchr (const wchar_t*, wchar_t)
+function size_t wcsrtombs (char*, const wchar_t**, size_t, mbstate_t*)
+function size_t wcsspn (const wchar_t*, const wchar_t*)
+function {wchar_t*} wcsstr (const wchar_t*, const wchar_t*)
+function double wcstod (const wchar_t*, wchar_t**)
+function {wchar_t*} wcstok (wchar_t*, const wchar_t*, wchar_t**)
+function {long int} wcstol (const wchar_t*, wchar_t**, int)
+function {unsigned long int} wcstoul (const wchar_t*, wchar_t**, int)
+function {wchar_t*} wcswcs (const wchar_t*, const wchar_t*)
+function int wcswidth (const wchar_t*, size_t)
+function size_t wcsxfrm (wchar_t*, const wchar_t*, size_t)
+function int wctob (wint_t)
+function wctype_t wctype (const char*)
+function int wcwidth (wchar_t)
+function {wchar_t*} wmemchr (const wchar_t*, wchar_t, size_t)
+function int wmemcmp (const wchar_t*, const wchar_t*, size_t)
+function {wchar_t*} wmemcpy (wchar_t*, const wchar_t*, size_t)
+function {wchar_t*} wmemmove (wchar_t*, const wchar_t*, size_t)
+function {wchar_t*} wmemset (wchar_t*, wchar_t, size_t)
+function int wprintf (const wchar_t*, ...)
+function int wscanf (const wchar_t*, ...)
+
+macro WCHAR_MAX
+macro WCHAR_MIN
+macro WEOF
+macro NULL
+
+allow-header ctype.h
+allow-header stdio.h
+allow-header stdarg.h
+allow-header stdlib.h
+allow-header string.h
+allow-header stddef.h
+allow-header time.h
+
+allow wcs*
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/wctype.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/wctype.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/wctype.h-data	(revision 2036)
@@ -0,0 +1,36 @@
+type wint_t
+type wctrans_t
+type wctype_t
+
+function int iswalnum (wint_t)
+function int iswalpha (wint_t)
+function int iswcntrl (wint_t)
+function int iswdigit (wint_t)
+function int iswgraph (wint_t)
+function int iswlower (wint_t)
+function int iswprint (wint_t)
+function int iswpunct (wint_t)
+function int iswspace (wint_t)
+function int iswupper (wint_t)
+function int iswxdigit (wint_t)
+function int iswctype (wint_t, wctype_t)
+function wint_t towctrans (wint_t, wctrans_t)
+function wint_t towlower (wint_t)
+function wint_t towupper (wint_t)
+function wctrans_t wctrans (const char*)
+function wctype_t wctype (const char*)
+
+macro WEOF
+
+allow-header ctype.h
+allow-header stdio.h
+allow-header stdarg.h
+allow-header stdlib.h
+allow-header string.h
+allow-header stddef.h
+allow-header time.h
+allow-header wchar.h
+
+allow is*
+allow to*
+allow *_t
Index: trunk/src/libctests/glibc/conform/data/wordexp.h-data
===================================================================
--- trunk/src/libctests/glibc/conform/data/wordexp.h-data	(revision 2036)
+++ trunk/src/libctests/glibc/conform/data/wordexp.h-data	(revision 2036)
@@ -0,0 +1,25 @@
+type wordexp_t
+
+element wordexp_t size_t we_wordc
+element wordexp_t {char**} we_wordv
+element wordexp_t size_t we_offs
+
+constant WRDE_APPEND
+constant WRDE_DOOFFS
+constant WRDE_NOCMD
+constant WRDE_REUSE
+constant WRDE_SHOWERR
+constant WRDE_UNDEF
+
+constant WRDE_BADCHAR
+constant WRDE_CMDSUB
+constant WRDE_NOSPACE
+constant WRDE_NOSYS
+constant WRDE_SYNTAX
+
+function int wordexp (const char*, wordexp_t*, int)
+function void wordfree (wordexp_t*)
+
+allow WRDE_*
+allow we_*
+allow *_t
Index: trunk/src/libctests/glibc/crypt/Makefile
===================================================================
--- trunk/src/libctests/glibc/crypt/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/crypt/Makefile	(revision 2036)
@@ -0,0 +1,60 @@
+# Copyright (C) 1996, 2000, 2001 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Sub-makefile for crypt() portion of the library.
+#
+subdir	:= crypt
+
+headers := crypt.h
+
+distribute := md5.h
+
+extra-libs := libcrypt
+extra-libs-others := $(extra-libs)
+
+libcrypt-routines := crypt-entry md5-crypt md5 crypt crypt_util
+
+tests = cert md5test md5c-test
+
+distribute = ufc-crypt.h crypt-private.h ufc.c speeds.c README.ufc-crypt \
+	     Banner md5.h
+
+include ../Makeconfig
+
+ifeq ($(crypt-in-libc),yes)
+routines += $(libcrypt-routines)
+endif
+
+$(objpfx)md5test: $(objpfx)md5.o
+
+include ../Rules
+
+ifeq (yes,$(build-shared))
+$(addprefix $(objpfx),$(tests)): $(objpfx)libcrypt.so
+else
+$(addprefix $(objpfx),$(tests)): $(objpfx)libcrypt.a
+endif
+ifeq (yes,$(build-bounded))
+$(tests:%=$(objpfx)%-bp): $(objpfx)libcrypt_b.a
+endif
+
+# Depend on libc.so so a DT_NEEDED is generated in the shared objects.
+# This ensures they will load libc.so for needed symbols if loaded by
+# a statically-linked program that hasn't already loaded it.
+$(objpfx)libcrypt.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a
Index: trunk/src/libctests/glibc/crypt/cert.c
===================================================================
--- trunk/src/libctests/glibc/crypt/cert.c	(revision 2036)
+++ trunk/src/libctests/glibc/crypt/cert.c	(revision 2036)
@@ -0,0 +1,113 @@
+
+/*
+ * This crypt(3) validation program shipped with UFC-crypt
+ * is derived from one distributed with Phil Karns PD DES package.
+ *
+ * @(#)cert.c	1.8 11 Aug 1996
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "crypt.h"
+
+int totfails = 0;
+
+#if __STDC__ - 0
+int main (int argc, char *argv[]);
+void get8 (char *cp);
+void put8 (char *cp);
+void good_bye (void) __attribute__ ((noreturn));
+#else
+void get8(), put8();
+#endif
+
+void good_bye ()
+{
+  if(totfails == 0) {
+    printf("Passed DES validation suite\n");
+    exit(0);
+  } else {
+    printf("%d failures during DES validation suite!!!\n", totfails);
+    exit(1);
+  }
+}
+
+int
+main(argc, argv)
+     int argc;
+     char *argv[];
+{
+	char key[64],plain[64],cipher[64],answer[64];
+	int i;
+	int test;
+	int fail;
+
+	for(test=0;!feof(stdin);test++){
+
+		get8(key);
+		printf(" K: "); put8(key);
+		setkey(key);
+
+		get8(plain);
+		printf(" P: "); put8(plain);
+
+		get8(answer);
+		printf(" C: "); put8(answer);
+
+		for(i=0;i<64;i++)
+			cipher[i] = plain[i];
+		encrypt(cipher, 0);
+
+		for(i=0;i<64;i++)
+			if(cipher[i] != answer[i])
+				break;
+		fail = 0;
+		if(i != 64){
+			printf(" Encrypt FAIL");
+			fail++; totfails++;
+		}
+
+		encrypt(cipher, 1);
+
+		for(i=0;i<64;i++)
+			if(cipher[i] != plain[i])
+				break;
+		if(i != 64){
+			printf(" Decrypt FAIL");
+			fail++; totfails++;
+		}
+
+		if(fail == 0)
+			printf(" OK");
+		printf("\n");
+	}
+	good_bye();
+}
+void
+get8(cp)
+char *cp;
+{
+	int i,j,t;
+
+	for(i=0;i<8;i++){
+		scanf("%2x",&t);
+		if(feof(stdin))
+		  good_bye();
+		for(j=0; j<8 ; j++) {
+		  *cp++ = (t & (0x01 << (7-j))) != 0;
+		}
+	}
+}
+void
+put8(cp)
+char *cp;
+{
+	int i,j,t;
+
+	for(i=0;i<8;i++){
+	  t = 0;
+	  for(j = 0; j<8; j++)
+	    t = (t<<1) | *cp++;
+	  printf("%02x", t);
+	}
+}
Index: trunk/src/libctests/glibc/crypt/cert.input
===================================================================
--- trunk/src/libctests/glibc/crypt/cert.input	(revision 2036)
+++ trunk/src/libctests/glibc/crypt/cert.input	(revision 2036)
@@ -0,0 +1,171 @@
+0101010101010101 95f8a5e5dd31d900 8000000000000000
+0101010101010101 dd7f121ca5015619 4000000000000000
+0101010101010101 2e8653104f3834ea 2000000000000000
+0101010101010101 4bd388ff6cd81d4f 1000000000000000
+0101010101010101 20b9e767b2fb1456 0800000000000000
+0101010101010101 55579380d77138ef 0400000000000000
+0101010101010101 6cc5defaaf04512f 0200000000000000
+0101010101010101 0d9f279ba5d87260 0100000000000000
+0101010101010101 d9031b0271bd5a0a 0080000000000000
+0101010101010101 424250b37c3dd951 0040000000000000
+0101010101010101 b8061b7ecd9a21e5 0020000000000000
+0101010101010101 f15d0f286b65bd28 0010000000000000
+0101010101010101 add0cc8d6e5deba1 0008000000000000
+0101010101010101 e6d5f82752ad63d1 0004000000000000
+0101010101010101 ecbfe3bd3f591a5e 0002000000000000
+0101010101010101 f356834379d165cd 0001000000000000
+0101010101010101 2b9f982f20037fa9 0000800000000000
+0101010101010101 889de068a16f0be6 0000400000000000
+0101010101010101 e19e275d846a1298 0000200000000000
+0101010101010101 329a8ed523d71aec 0000100000000000
+0101010101010101 e7fce22557d23c97 0000080000000000
+0101010101010101 12a9f5817ff2d65d 0000040000000000
+0101010101010101 a484c3ad38dc9c19 0000020000000000
+0101010101010101 fbe00a8a1ef8ad72 0000010000000000
+0101010101010101 750d079407521363 0000008000000000
+0101010101010101 64feed9c724c2faf 0000004000000000
+0101010101010101 f02b263b328e2b60 0000002000000000
+0101010101010101 9d64555a9a10b852 0000001000000000
+0101010101010101 d106ff0bed5255d7 0000000800000000
+0101010101010101 e1652c6b138c64a5 0000000400000000
+0101010101010101 e428581186ec8f46 0000000200000000
+0101010101010101 aeb5f5ede22d1a36 0000000100000000
+0101010101010101 e943d7568aec0c5c 0000000080000000
+0101010101010101 df98c8276f54b04b 0000000040000000
+0101010101010101 b160e4680f6c696f 0000000020000000
+0101010101010101 fa0752b07d9c4ab8 0000000010000000
+0101010101010101 ca3a2b036dbc8502 0000000008000000
+0101010101010101 5e0905517bb59bcf 0000000004000000
+0101010101010101 814eeb3b91d90726 0000000002000000
+0101010101010101 4d49db1532919c9f 0000000001000000
+0101010101010101 25eb5fc3f8cf0621 0000000000800000
+0101010101010101 ab6a20c0620d1c6f 0000000000400000
+0101010101010101 79e90dbc98f92cca 0000000000200000
+0101010101010101 866ecedd8072bb0e 0000000000100000
+0101010101010101 8b54536f2f3e64a8 0000000000080000
+0101010101010101 ea51d3975595b86b 0000000000040000
+0101010101010101 caffc6ac4542de31 0000000000020000
+0101010101010101 8dd45a2ddf90796c 0000000000010000
+0101010101010101 1029d55e880ec2d0 0000000000008000
+0101010101010101 5d86cb23639dbea9 0000000000004000
+0101010101010101 1d1ca853ae7c0c5f 0000000000002000
+0101010101010101 ce332329248f3228 0000000000001000
+0101010101010101 8405d1abe24fb942 0000000000000800
+0101010101010101 e643d78090ca4207 0000000000000400
+0101010101010101 48221b9937748a23 0000000000000200
+0101010101010101 dd7c0bbd61fafd54 0000000000000100
+0101010101010101 2fbc291a570db5c4 0000000000000080
+0101010101010101 e07c30d7e4e26e12 0000000000000040
+0101010101010101 0953e2258e8e90a1 0000000000000020
+0101010101010101 5b711bc4ceebf2ee 0000000000000010
+0101010101010101 cc083f1e6d9e85f6 0000000000000008
+0101010101010101 d2fd8867d50d2dfe 0000000000000004
+0101010101010101 06e7ea22ce92708f 0000000000000002
+0101010101010101 166b40b44aba4bd6 0000000000000001
+8001010101010101 0000000000000000 95a8d72813daa94d
+4001010101010101 0000000000000000 0eec1487dd8c26d5
+2001010101010101 0000000000000000 7ad16ffb79c45926
+1001010101010101 0000000000000000 d3746294ca6a6cf3
+0801010101010101 0000000000000000 809f5f873c1fd761
+0401010101010101 0000000000000000 c02faffec989d1fc
+0201010101010101 0000000000000000 4615aa1d33e72f10
+0180010101010101 0000000000000000 2055123350c00858
+0140010101010101 0000000000000000 df3b99d6577397c8
+0120010101010101 0000000000000000 31fe17369b5288c9
+0110010101010101 0000000000000000 dfdd3cc64dae1642
+0108010101010101 0000000000000000 178c83ce2b399d94
+0104010101010101 0000000000000000 50f636324a9b7f80
+0102010101010101 0000000000000000 a8468ee3bc18f06d
+0101800101010101 0000000000000000 a2dc9e92fd3cde92
+0101400101010101 0000000000000000 cac09f797d031287
+0101200101010101 0000000000000000 90ba680b22aeb525
+0101100101010101 0000000000000000 ce7a24f350e280b6
+0101080101010101 0000000000000000 882bff0aa01a0b87
+0101040101010101 0000000000000000 25610288924511c2
+0101020101010101 0000000000000000 c71516c29c75d170
+0101018001010101 0000000000000000 5199c29a52c9f059
+0101014001010101 0000000000000000 c22f0a294a71f29f
+0101012001010101 0000000000000000 ee371483714c02ea
+0101011001010101 0000000000000000 a81fbd448f9e522f
+0101010801010101 0000000000000000 4f644c92e192dfed
+0101010401010101 0000000000000000 1afa9a66a6df92ae
+0101010201010101 0000000000000000 b3c1cc715cb879d8
+0101010180010101 0000000000000000 19d032e64ab0bd8b
+0101010140010101 0000000000000000 3cfaa7a7dc8720dc
+0101010120010101 0000000000000000 b7265f7f447ac6f3
+0101010110010101 0000000000000000 9db73b3c0d163f54
+0101010108010101 0000000000000000 8181b65babf4a975
+0101010104010101 0000000000000000 93c9b64042eaa240
+0101010102010101 0000000000000000 5570530829705592
+0101010101800101 0000000000000000 8638809e878787a0
+0101010101400101 0000000000000000 41b9a79af79ac208
+0101010101200101 0000000000000000 7a9be42f2009a892
+0101010101100101 0000000000000000 29038d56ba6d2745
+0101010101080101 0000000000000000 5495c6abf1e5df51
+0101010101040101 0000000000000000 ae13dbd561488933
+0101010101020101 0000000000000000 024d1ffa8904e389
+0101010101018001 0000000000000000 d1399712f99bf02e
+0101010101014001 0000000000000000 14c1d7c1cffec79e
+0101010101012001 0000000000000000 1de5279dae3bed6f
+0101010101011001 0000000000000000 e941a33f85501303
+0101010101010801 0000000000000000 da99dbbc9a03f379
+0101010101010401 0000000000000000 b7fc92f91d8e92e9
+0101010101010201 0000000000000000 ae8e5caa3ca04e85
+0101010101010180 0000000000000000 9cc62df43b6eed74
+0101010101010140 0000000000000000 d863dbb5c59a91a0
+0101010101010120 0000000000000000 a1ab2190545b91d7
+0101010101010110 0000000000000000 0875041e64c570f7
+0101010101010108 0000000000000000 5a594528bebef1cc
+0101010101010104 0000000000000000 fcdb3291de21f0c0
+0101010101010102 0000000000000000 869efd7f9f265a09
+1046913489980131 0000000000000000 88d55e54f54c97b4
+1007103489988020 0000000000000000 0c0cc00c83ea48fd
+10071034c8980120 0000000000000000 83bc8ef3a6570183
+1046103489988020 0000000000000000 df725dcad94ea2e9
+1086911519190101 0000000000000000 e652b53b550be8b0
+1086911519580101 0000000000000000 af527120c485cbb0
+5107b01519580101 0000000000000000 0f04ce393db926d5
+1007b01519190101 0000000000000000 c9f00ffc74079067
+3107915498080101 0000000000000000 7cfd82a593252b4e
+3107919498080101 0000000000000000 cb49a2f9e91363e3
+10079115b9080140 0000000000000000 00b588be70d23f56
+3107911598080140 0000000000000000 406a9a6ab43399ae
+1007d01589980101 0000000000000000 6cb773611dca9ada
+9107911589980101 0000000000000000 67fd21c17dbb5d70
+9107d01589190101 0000000000000000 9592cb4110430787
+1007d01598980120 0000000000000000 a6b7ff68a318ddd3
+1007940498190101 0000000000000000 4d102196c914ca16
+0107910491190401 0000000000000000 2dfa9f4573594965
+0107910491190101 0000000000000000 b46604816c0e0774
+0107940491190401 0000000000000000 6e7e6221a4f34e87
+19079210981a0101 0000000000000000 aa85e74643233199
+1007911998190801 0000000000000000 2e5a19db4d1962d6
+10079119981a0801 0000000000000000 23a866a809d30894
+1007921098190101 0000000000000000 d812d961f017d320
+100791159819010b 0000000000000000 055605816e58608f
+1004801598190101 0000000000000000 abd88e8b1b7716f1
+1004801598190102 0000000000000000 537ac95be69da1e1
+1004801598190108 0000000000000000 aed0f6ae3c25cdd8
+1002911598100104 0000000000000000 b3e35a5ee53e7b8d
+1002911598190104 0000000000000000 61c79c71921a2ef8
+1002911598100201 0000000000000000 e2f5728f0995013c
+1002911698100101 0000000000000000 1aeac39a61f0a464
+7ca110454a1a6e57 01a1d6d039776742 690f5b0d9a26939b
+0131d9619dc1376e 5cd54ca83def57da 7a389d10354bd271
+07a1133e4a0b2686 0248d43806f67172 868ebb51cab4599a
+3849674c2602319e 51454b582ddf440a 7178876e01f19b2a
+04b915ba43feb5b6 42fd443059577fa2 af37fb421f8c4095
+0113b970fd34f2ce 059b5e0851cf143a 86a560f10ec6d85b
+0170f175468fb5e6 0756d8e0774761d2 0cd3da020021dc09
+43297fad38e373fe 762514b829bf486a ea676b2cb7db2b7a
+07a7137045da2a16 3bdd119049372802 dfd64a815caf1a0f
+04689104c2fd3b2f 26955f6835af609a 5c513c9c4886c088
+37d06bb516cb7546 164d5e404f275232 0a2aeeae3ff4ab77
+1f08260d1ac2465e 6b056e18759f5cca ef1bf03e5dfa575a
+584023641aba6176 004bd6ef09176062 88bf0db6d70dee56
+025816164629b007 480d39006ee762f2 a1f9915541020b56
+49793ebc79b3258f 437540c8698f3cfa 6fbf1cafcffd0556
+4fb05e1515ab73a7 072d43a077075292 2f22e49bab7ca1ac
+49e95d6d4ca229bf 02fe55778117f12a 5a6b612cc26cce4a
+018310dc409b26d6 1d9d5c5018f728c2 5f4c038ed12b2e41
+1c587f1c13924fef 305532286d6f295a 63fac0d034d9f793
Index: trunk/src/libctests/glibc/crypt/md5c-test.c
===================================================================
--- trunk/src/libctests/glibc/crypt/md5c-test.c	(revision 2036)
+++ trunk/src/libctests/glibc/crypt/md5c-test.c	(revision 2036)
@@ -0,0 +1,15 @@
+#include <crypt.h>
+#include <string.h>
+
+int
+main (int argc, char *argv[])
+{
+  const char salt[] = "$1$saltstring";
+  char *cp;
+  int result = 0;
+
+  cp = crypt ("Hello world!", salt);
+  result |= strcmp ("$1$saltstri$YMyguxXMBpd2TEZ.vS/3q1", cp);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/csu/Makefile
===================================================================
--- trunk/src/libctests/glibc/csu/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/csu/Makefile	(revision 2036)
@@ -0,0 +1,248 @@
+# Makefile for csu code for GNU C library.
+# Copyright (C) 1995-2004, 2005 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+# This directory contains the C startup code (that which calls main).  This
+# consists of the startfile, built from start.c and installed as crt0.o
+# (traditionally) or crt1.o (for ELF).	In ELF we also install crti.o and
+# crtn.o, special "initializer" and "finalizer" files used in the link
+# to make the .init and .fini sections work right; both these files are
+# built (in an arcane manner) from initfini.c.
+
+subdir := csu
+
+routines = init-first libc-start $(libc-init) sysdep version check_fds \
+	   libc-tls elf-init dso_handle
+aux	 = errno
+elide-routines.os = libc-tls
+static-only-routines = elf-init
+csu-dummies = $(filter-out $(start-installed-name),crt1.o Mcrt1.o)
+extra-objs = start.o gmon-start.o \
+	     $(start-installed-name) g$(start-installed-name) $(csu-dummies) \
+	     S$(start-installed-name)
+omit-deps = $(patsubst %.o,%,$(start-installed-name) g$(start-installed-name) \
+			     b$(start-installed-name) $(csu-dummies) \
+			     S$(start-installed-name))
+install-lib = $(start-installed-name) g$(start-installed-name) $(csu-dummies)
+distribute = initfini.c gmon-start.c start.c defs.awk munch.awk \
+	     abi-note.S init.c munch-tmpl.c not-cancel.h
+generated = version-info.h
+before-compile = $(objpfx)version-info.h
+
+tests := tst-empty tst-atomic tst-atomic-long
+tests-static := tst-empty
+
+all: # Make this the default target; it will be defined in Rules.
+
+include ../Makeconfig
+
+ifeq (yes,$(build-shared))
+extra-objs += S$(start-installed-name)
+install-lib += S$(start-installed-name)
+generated += start.os
+endif
+
+ifeq (yes,$(build-bounded))
+extra-objs += b$(start-installed-name)
+install-lib += b$(start-installed-name)
+generated += start.ob
+endif
+
+ifneq ($(start-installed-name),$(static-start-installed-name))
+extra-objs += $(static-start-installed-name) g$(static-start-installed-name)
+omit-deps += $(patsubst %.o,%,$(static-start-installed-name) \
+			     g$(static-start-installed-name))
+install-lib += $(static-start-installed-name) g$(static-start-installed-name)
+endif
+
+ifeq (yes,$(elf))
+before-compile += $(objpfx)abi-tag.h
+generated += abi-tag.h
+endif
+
+ifneq (yes,$(gnu-ld))
+libc-init = munch-init
+$(objpfx)munch-init.c: munch.awk munch-tmpl.c $(+subdir_inits)
+	$(AWK) -f $< subdirs='$(+init_subdirs)' $(word 2,$^) > $@-t
+	mv -f $@-t $@
+generated += munch-init.c
+
+# All initialization source files.
++subdir_inits	:= $(wildcard $(foreach dir,$(subdirs),$(dir)/init-$(dir).c))
+# All subdirectories containing initialization source files.
++init_subdirs	:= $(patsubst %/,%,$(dir $(+subdir_inits)))
+endif
+
+ifeq ($(have-initfini),yes)
+
+CPPFLAGS += -DHAVE_INITFINI
+
+# These are the special initializer/finalizer files.  They are always the
+# first and last file in the link.  crti.o ... crtn.o define the global
+# "functions" _init and _fini to run the .init and .fini sections.
+crtstuff = crti crtn
+
+install-lib += $(crtstuff:=.o)
+extra-objs += $(crtstuff:=.o)
+generated += $(crtstuff:=.S) initfini.s defs.h
+omit-deps += $(crtstuff)
+
+# Special rules for the building of crti.o and crtn.o
+$(crtstuff:%=$(objpfx)%.o): %.o: %.S $(objpfx)defs.h
+	$(compile.S) -g0 $(ASFLAGS-.os) -o $@
+
+CFLAGS-initfini.s = -g0 -fPIC -fno-inline-functions $(fno-unit-at-a-time)
+
+vpath initfini.c $(full_config_sysdirs)
+
+$(objpfx)initfini.s: initfini.c $(before-compile)
+	$(compile.c) -S $(CFLAGS-initfini.s) -finhibit-size-directive \
+		$(patsubst -f%,-fno-%,$(exceptions)) -o $@
+
+# We only have one kind of startup code files.	Static binaries and
+# shared libraries are build using the PIC version.
+$(objpfx)crti.S: $(objpfx)initfini.s
+	sed -n -e '1,/@HEADER_ENDS/p' \
+	       -e '/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \
+	       -e '/@TRAILER_BEGINS/,$$p' $< > $@
+
+$(objpfx)crtn.S: $(objpfx)initfini.s
+	sed -n -e '1,/@HEADER_ENDS/p' \
+	       -e '/@_.*_EPILOG_BEGINS/,/@_.*_EPILOG_ENDS/p' \
+	       -e '/@TRAILER_BEGINS/,$$p' $< > $@
+
+# These explicit rules are necessary when the $(objpfx) subdirectory
+# did not exist at the time make considered the implicit rules using it.
+# This comes up with a fresh build using no_deps=t.
+$(patsubst %,$(objpfx)crt%.o,i n): %.o: %.S
+
+$(objpfx)defs.h: $(objpfx)initfini.s
+	sed -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \
+		$(AWK) -f defs.awk > $@
+
+endif
+
+ifeq (yes,$(elf))
+extra-objs += abi-note.o init.o
+asm-CPPFLAGS += -I$(objpfx).
+endif
+
+include ../Rules
+
+# Make these in the lib pass so they're available in time to link things with.
+subdir_lib: $(extra-objs:%=$(objpfx)%)
+
+define link-relocatable
+$(CC) -nostdlib -nostartfiles -r -o $@ $^
+endef
+
+ifndef start-installed-name-rule
+ifeq (yes,$(elf))
+# We link the ELF startfile along with a SHT_NOTE section indicating
+# the kernel ABI the binaries linked with this library will require.
+$(objpfx)$(start-installed-name): $(objpfx)start.o $(objpfx)abi-note.o \
+				  $(objpfx)init.o
+	$(link-relocatable)
+$(objpfx)S$(start-installed-name): $(objpfx)start.os $(objpfx)abi-note.o \
+				  $(objpfx)init.o
+	$(link-relocatable)
+$(objpfx)b$(start-installed-name): $(objpfx)start.ob $(objpfx)abi-note.ob \
+				  $(objpfx)init.ob
+	$(link-relocatable)
+else
+# The startfile is installed under different names, so we just call our
+# source file `start.c' and copy to the installed name after compiling.
+$(objpfx)$(start-installed-name): $(objpfx)start.o
+	rm -f $@
+	ln $< $@
+$(objpfx)S$(start-installed-name): $(objpfx)start.os
+	rm -f $@
+	ln $< $@
+$(objpfx)b$(start-installed-name): $(objpfx)start.ob
+	rm -f $@
+	ln $< $@
+endif
+endif
+
+# The profiling startfile is made by linking together the normal
+# startfile with gmon-start.o, which defines a constructor function
+# to turn on profiling code at startup.
+$(addprefix $(objpfx),$(sort g$(start-installed-name) \
+			     g$(static-start-installed-name))): \
+  $(objpfx)g%: $(objpfx)% $(objpfx)gmon-start.o
+	$(link-relocatable)
+
+# These extra files are sometimes expected by system standard linking
+# procedures, but we have nothing for them to do.  So compile empty files.
+$(addprefix $(objpfx),$(filter-out $(start-installed-name), $(csu-dummies))):\
+  $(before-compile)
+	$(COMPILE.c) -o $@ -x c /dev/null
+
+# These headers are used by the startup code.
+$(objpfx)abi-tag.h: $(..)abi-tags
+	$(make-target-directory)
+	rm -f $@.new
+	sed -e 's/#.*$$//' -e '/^[	]*$$/d' $< | \
+	while read conf tagos tagver; do \
+	  test `expr '$(config-machine)-$(config-vendor)-$(config-os)' \
+		     : "$$conf"` != 0 || continue; \
+	  ( echo "$$tagos" | \
+	    sed -e 's/[^0-9xXa-fA-F 	]//' \
+		-e 's/^/#define __ABI_TAG_OS /'; \
+	    echo "#ifndef __ABI_TAG_VERSION"; \
+	    echo "$$tagver" | \
+	    sed -e 's/[^0-9xXa-fA-F]/ /g' -e 's/ *$$//' \
+	      -e 's/ /,/g' -e 's/^/# define __ABI_TAG_VERSION /'; \
+	    echo "#endif" ) > $@.new; \
+	done
+	if test -r $@.new; then mv -f $@.new $@; \
+	else echo >&2 'This configuration not matched in $<'; exit 1; fi
+
+all-Banner-files = $(wildcard $(addsuffix /Banner, \
+					$(addprefix $(..), $(subdirs))))
+$(objpfx)version-info.h: $(common-objpfx)config.make $(all-Banner-files)
+	$(make-target-directory)
+	(case $(config-os) in \
+	   linux*) version=`(printf '%s\n%s\n' \
+				    '#include <linux/version.h>' \
+				    UTS_RELEASE \
+			     | $(CC) $(CPPFLAGS) -E -P - -DNOT_IN_libc=1 | \
+			     sed -e 's/"\([^"]*\)".*/\1/p' -e d) 2>/dev/null`;\
+		   if [ -z "$$version" ]; then \
+		     if [ -r /proc/version ]; then \
+		       version=`sed 's/.*Linux version \([^ ]*\) .*/>>\1<</' \
+				< /proc/version`; \
+		     else \
+		       version=`uname -r`; \
+		     fi; \
+		   fi; \
+		   os=`uname -s 2> /dev/null`; \
+		   if [ -z "$$os" ]; then \
+		     os=Linux; \
+		   fi; \
+		   printf '"Compiled on a %s %s system on %s.\\n"\n' \
+			  "$$os" "$$version" "`date +%Y-%m-%d`";; \
+	   *) ;; \
+	 esac; \
+	 files="$(all-Banner-files)";				\
+	 if test -n "$$files"; then				\
+	   printf '"Available extensions:\\n"\n';		\
+	   sed -e '/^#/d' -e 's/^[[:space:]]*/	/'		\
+	       -e 's/^\(.*\)$$/\"\1\\n\"/' $$files;		\
+	 fi) > $@T
+	mv -f $@T $@
Index: trunk/src/libctests/glibc/csu/tst-atomic-long.c
===================================================================
--- trunk/src/libctests/glibc/csu/tst-atomic-long.c	(revision 2036)
+++ trunk/src/libctests/glibc/csu/tst-atomic-long.c	(revision 2036)
@@ -0,0 +1,28 @@
+/* Tests for atomic.h macros.
+   Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <bits/wordsize.h>
+
+#define atomic_t long
+#if __WORDSIZE == 64
+# define TEST_ATOMIC64 1
+#endif
+
+#include "tst-atomic.c"
Index: trunk/src/libctests/glibc/csu/tst-atomic.c
===================================================================
--- trunk/src/libctests/glibc/csu/tst-atomic.c	(revision 2036)
+++ trunk/src/libctests/glibc/csu/tst-atomic.c	(revision 2036)
@@ -0,0 +1,386 @@
+/* Tests for atomic.h macros.
+   Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <atomic.h>
+
+#ifndef atomic_t
+# define atomic_t int
+#endif
+
+/* Test various atomic.h macros.  */
+static int
+do_test (void)
+{
+  atomic_t mem;
+  int ret = 0;
+
+#ifdef atomic_compare_and_exchange_val_acq
+  mem = 24;
+  if (atomic_compare_and_exchange_val_acq (&mem, 35, 24) != 24
+      || mem != 35)
+    {
+      puts ("atomic_compare_and_exchange_val_acq test 1 failed");
+      ret = 1;
+    }
+
+  mem = 12;
+  if (atomic_compare_and_exchange_val_acq (&mem, 10, 15) != 12
+      || mem != 12)
+    {
+      puts ("atomic_compare_and_exchange_val_acq test 2 failed");
+      ret = 1;
+    }
+
+  mem = -15;
+  if (atomic_compare_and_exchange_val_acq (&mem, -56, -15) != -15
+      || mem != -56)
+    {
+      puts ("atomic_compare_and_exchange_val_acq test 3 failed");
+      ret = 1;
+    }
+
+  mem = -1;
+  if (atomic_compare_and_exchange_val_acq (&mem, 17, 0) != -1
+      || mem != -1)
+    {
+      puts ("atomic_compare_and_exchange_val_acq test 4 failed");
+      ret = 1;
+    }
+#endif
+
+  mem = 24;
+  if (atomic_compare_and_exchange_bool_acq (&mem, 35, 24)
+      || mem != 35)
+    {
+      puts ("atomic_compare_and_exchange_bool_acq test 1 failed");
+      ret = 1;
+    }
+
+  mem = 12;
+  if (! atomic_compare_and_exchange_bool_acq (&mem, 10, 15)
+      || mem != 12)
+    {
+      puts ("atomic_compare_and_exchange_bool_acq test 2 failed");
+      ret = 1;
+    }
+
+  mem = -15;
+  if (atomic_compare_and_exchange_bool_acq (&mem, -56, -15)
+      || mem != -56)
+    {
+      puts ("atomic_compare_and_exchange_bool_acq test 3 failed");
+      ret = 1;
+    }
+
+  mem = -1;
+  if (! atomic_compare_and_exchange_bool_acq (&mem, 17, 0)
+      || mem != -1)
+    {
+      puts ("atomic_compare_and_exchange_bool_acq test 4 failed");
+      ret = 1;
+    }
+
+  mem = 64;
+  if (atomic_exchange_acq (&mem, 31) != 64
+      || mem != 31)
+    {
+      puts ("atomic_exchange_acq test failed");
+      ret = 1;
+    }
+
+  mem = 2;
+  if (atomic_exchange_and_add (&mem, 11) != 2
+      || mem != 13)
+    {
+      puts ("atomic_exchange_and_add test failed");
+      ret = 1;
+    }
+
+  mem = -21;
+  atomic_add (&mem, 22);
+  if (mem != 1)
+    {
+      puts ("atomic_add test failed");
+      ret = 1;
+    }
+
+  mem = -1;
+  atomic_increment (&mem);
+  if (mem != 0)
+    {
+      puts ("atomic_increment test failed");
+      ret = 1;
+    }
+
+  mem = 2;
+  if (atomic_increment_val (&mem) != 3)
+    {
+      puts ("atomic_increment_val test failed");
+      ret = 1;
+    }
+
+  mem = 0;
+  if (atomic_increment_and_test (&mem)
+      || mem != 1)
+    {
+      puts ("atomic_increment_and_test test 1 failed");
+      ret = 1;
+    }
+
+  mem = 35;
+  if (atomic_increment_and_test (&mem)
+      || mem != 36)
+    {
+      puts ("atomic_increment_and_test test 2 failed");
+      ret = 1;
+    }
+
+  mem = -1;
+  if (! atomic_increment_and_test (&mem)
+      || mem != 0)
+    {
+      puts ("atomic_increment_and_test test 3 failed");
+      ret = 1;
+    }
+
+  mem = 17;
+  atomic_decrement (&mem);
+  if (mem != 16)
+    {
+      puts ("atomic_decrement test failed");
+      ret = 1;
+    }
+
+  if (atomic_decrement_val (&mem) != 15)
+    {
+      puts ("atomic_decrement_val test failed");
+      ret = 1;
+    }
+
+  mem = 0;
+  if (atomic_decrement_and_test (&mem)
+      || mem != -1)
+    {
+      puts ("atomic_decrement_and_test test 1 failed");
+      ret = 1;
+    }
+
+  mem = 15;
+  if (atomic_decrement_and_test (&mem)
+      || mem != 14)
+    {
+      puts ("atomic_decrement_and_test test 2 failed");
+      ret = 1;
+    }
+
+  mem = 1;
+  if (! atomic_decrement_and_test (&mem)
+      || mem != 0)
+    {
+      puts ("atomic_decrement_and_test test 3 failed");
+      ret = 1;
+    }
+
+  mem = 1;
+  if (atomic_decrement_if_positive (&mem) != 1
+      || mem != 0)
+    {
+      puts ("atomic_decrement_if_positive test 1 failed");
+      ret = 1;
+    }
+
+  mem = 0;
+  if (atomic_decrement_if_positive (&mem) != 0
+      || mem != 0)
+    {
+      puts ("atomic_decrement_if_positive test 2 failed");
+      ret = 1;
+    }
+
+  mem = -1;
+  if (atomic_decrement_if_positive (&mem) != -1
+      || mem != -1)
+    {
+      puts ("atomic_decrement_if_positive test 3 failed");
+      ret = 1;
+    }
+
+  mem = -12;
+  if (! atomic_add_negative (&mem, 10)
+      || mem != -2)
+    {
+      puts ("atomic_add_negative test 1 failed");
+      ret = 1;
+    }
+
+  mem = 0;
+  if (atomic_add_negative (&mem, 100)
+      || mem != 100)
+    {
+      puts ("atomic_add_negative test 2 failed");
+      ret = 1;
+    }
+
+  mem = 15;
+  if (atomic_add_negative (&mem, -10)
+      || mem != 5)
+    {
+      puts ("atomic_add_negative test 3 failed");
+      ret = 1;
+    }
+
+  mem = -12;
+  if (atomic_add_negative (&mem, 14)
+      || mem != 2)
+    {
+      puts ("atomic_add_negative test 4 failed");
+      ret = 1;
+    }
+
+  mem = 0;
+  if (! atomic_add_negative (&mem, -1)
+      || mem != -1)
+    {
+      puts ("atomic_add_negative test 5 failed");
+      ret = 1;
+    }
+
+  mem = -31;
+  if (atomic_add_negative (&mem, 31)
+      || mem != 0)
+    {
+      puts ("atomic_add_negative test 6 failed");
+      ret = 1;
+    }
+
+  mem = -34;
+  if (atomic_add_zero (&mem, 31)
+      || mem != -3)
+    {
+      puts ("atomic_add_zero test 1 failed");
+      ret = 1;
+    }
+
+  mem = -36;
+  if (! atomic_add_zero (&mem, 36)
+      || mem != 0)
+    {
+      puts ("atomic_add_zero test 2 failed");
+      ret = 1;
+    }
+
+  mem = 113;
+  if (atomic_add_zero (&mem, -13)
+      || mem != 100)
+    {
+      puts ("atomic_add_zero test 3 failed");
+      ret = 1;
+    }
+
+  mem = -18;
+  if (atomic_add_zero (&mem, 20)
+      || mem != 2)
+    {
+      puts ("atomic_add_zero test 4 failed");
+      ret = 1;
+    }
+
+  mem = 10;
+  if (atomic_add_zero (&mem, -20)
+      || mem != -10)
+    {
+      puts ("atomic_add_zero test 5 failed");
+      ret = 1;
+    }
+
+  mem = 10;
+  if (! atomic_add_zero (&mem, -10)
+      || mem != 0)
+    {
+      puts ("atomic_add_zero test 6 failed");
+      ret = 1;
+    }
+
+  mem = 0;
+  atomic_bit_set (&mem, 1);
+  if (mem != 2)
+    {
+      puts ("atomic_bit_set test 1 failed");
+      ret = 1;
+    }
+
+  mem = 8;
+  atomic_bit_set (&mem, 3);
+  if (mem != 8)
+    {
+      puts ("atomic_bit_set test 2 failed");
+      ret = 1;
+    }
+
+#ifdef TEST_ATOMIC64
+  mem = 16;
+  atomic_bit_set (&mem, 35);
+  if (mem != 0x800000010LL)
+    {
+      puts ("atomic_bit_set test 3 failed");
+      ret = 1;
+    }
+#endif
+
+  mem = 0;
+  if (atomic_bit_test_set (&mem, 1)
+      || mem != 2)
+    {
+      puts ("atomic_bit_test_set test 1 failed");
+      ret = 1;
+    }
+
+  mem = 8;
+  if (! atomic_bit_test_set (&mem, 3)
+      || mem != 8)
+    {
+      puts ("atomic_bit_test_set test 2 failed");
+      ret = 1;
+    }
+
+#ifdef TEST_ATOMIC64
+  mem = 16;
+  if (atomic_bit_test_set (&mem, 35)
+      || mem != 0x800000010LL)
+    {
+      puts ("atomic_bit_test_set test 3 failed");
+      ret = 1;
+    }
+
+  mem = 0x100000000LL;
+  if (! atomic_bit_test_set (&mem, 32)
+      || mem != 0x100000000LL)
+    {
+      puts ("atomic_bit_test_set test 4 failed");
+      ret = 1;
+    }
+#endif
+
+  return ret;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/csu/tst-empty.c
===================================================================
--- trunk/src/libctests/glibc/csu/tst-empty.c	(revision 2036)
+++ trunk/src/libctests/glibc/csu/tst-empty.c	(revision 2036)
@@ -0,0 +1,6 @@
+/* The most useful C program known to man.  */
+int
+main (void)
+{
+  return 0;
+}
Index: trunk/src/libctests/glibc/ctype/Makefile
===================================================================
--- trunk/src/libctests/glibc/ctype/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/ctype/Makefile	(revision 2036)
@@ -0,0 +1,30 @@
+# Copyright (C) 1991, 1992, 1993, 1997, 2002 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Sub-makefile for ctype portion of the library.
+#
+subdir	:= ctype
+headers	:= ctype.h
+
+routines	:= ctype ctype-extn ctype_l isctype
+aux		:= ctype-info
+
+tests	:= test_ctype
+
+include ../Rules
Index: trunk/src/libctests/glibc/ctype/test_ctype.c
===================================================================
--- trunk/src/libctests/glibc/ctype/test_ctype.c	(revision 2036)
+++ trunk/src/libctests/glibc/ctype/test_ctype.c	(revision 2036)
@@ -0,0 +1,101 @@
+/* Copyright (C) 1991, 1994, 1996, 1997, 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <limits.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#define XOR(e,f) (((e) && !(f)) || (!(e) && (f)))
+
+#ifdef	__GNUC__
+__inline
+#endif
+static void
+print_char (unsigned char c)
+{
+  printf("%d/", (int) c);
+  if (isgraph(c))
+    printf("'%c'", c);
+  else
+    printf("'\\%.3o'", c);
+}
+
+int
+main (int argc, char **argv)
+{
+  unsigned short int c;
+  int lose = 0;
+
+#define TRYEM do {							      \
+      TRY (isascii);							      \
+      TRY (isalnum);							      \
+      TRY (isalpha);							      \
+      TRY (iscntrl);							      \
+      TRY (isdigit);							      \
+      TRY (isgraph);							      \
+      TRY (islower);							      \
+      TRY (isprint);							      \
+      TRY (ispunct);							      \
+      TRY (isspace);							      \
+      TRY (isupper);							      \
+      TRY (isxdigit);							      \
+      TRY (isblank);							      \
+    } while (0)
+
+  for (c = 0; c <= UCHAR_MAX; ++c)
+    {
+      print_char (c);
+
+      if (XOR (islower (c), ISLOWER (c)) || toupper (c) != TOUPPER (c))
+	{
+	  fputs (" BOGUS", stdout);
+	  ++lose;
+	}
+
+#define TRY(isfoo) if (isfoo (c)) fputs (" " #isfoo, stdout)
+      TRYEM;
+#undef TRY
+
+      fputs("; lower = ", stdout);
+      print_char(tolower(c));
+      fputs("; upper = ", stdout);
+      print_char(toupper(c));
+      putchar('\n');
+    }
+
+  fputs ("EOF", stdout);
+  if (tolower (EOF) != EOF)
+    {
+      ++lose;
+      printf (" tolower BOGUS %d;", tolower (EOF));
+    }
+  if (toupper (EOF) != EOF)
+    {
+      ++lose;
+      printf (" toupper BOGUS %d;", toupper (EOF));
+    }
+
+#define TRY(isfoo) if (isfoo (EOF)) fputs (" " #isfoo, stdout), ++lose
+  TRYEM;
+#undef TRY
+
+  return lose ? EXIT_FAILURE : EXIT_SUCCESS;
+}
Index: trunk/src/libctests/glibc/debug/Makefile
===================================================================
--- trunk/src/libctests/glibc/debug/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/debug/Makefile	(revision 2036)
@@ -0,0 +1,107 @@
+# Copyright (C) 1998,1999,2000,2001,2004,2005 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Sub-makefile for debug portion of the library.
+#
+subdir	:= debug
+
+headers	:= execinfo.h
+distribute = sigcontextinfo.h register-dump.h frame.h
+
+routines  = backtrace backtracesyms backtracesymsfd noophooks \
+	    memcpy_chk memmove_chk mempcpy_chk memset_chk stpcpy_chk \
+	    strcat_chk strcpy_chk strncat_chk strncpy_chk \
+	    sprintf_chk vsprintf_chk snprintf_chk vsnprintf_chk \
+	    printf_chk fprintf_chk vprintf_chk vfprintf_chk \
+	    gets_chk chk_fail readonly-area fgets_chk fgets_u_chk \
+	    read_chk pread_chk pread64_chk recv_chk recvfrom_chk \
+	    readlink_chk getwd_chk getcwd_chk \
+	    $(static-only-routines)
+static-only-routines := warning-nop
+
+CFLAGS-backtrace.c = -fno-omit-frame-pointer
+CFLAGS-sprintf_chk.c = -D_IO_MTSAFE_IO
+CFLAGS-snprintf_chk.c = -D_IO_MTSAFE_IO
+CFLAGS-vsprintf_chk.c = -D_IO_MTSAFE_IO
+CFLAGS-vsnprintf_chk.c = -D_IO_MTSAFE_IO
+CFLAGS-printf_chk.c = -D_IO_MTSAFE_IO $(exceptions)
+CFLAGS-fprintf_chk.c = -D_IO_MTSAFE_IO $(exceptions)
+CFLAGS-vprintf_chk.c = -D_IO_MTSAFE_IO $(exceptions)
+CFLAGS-vfprintf_chk.c = -D_IO_MTSAFE_IO $(exceptions)
+CFLAGS-gets_chk.c = -D_IO_MTSAFE_IO $(exceptions)
+CFLAGS-fgets_chk.c = -D_IO_MTSAFE_IO $(exceptions)
+CFLAGS-fgets_u_chk.c = -D_IO_MTSAFE_IO $(exceptions)
+CFLAGS-read_chk.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-pread_chk.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-pread64_chk.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-recv_chk.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-recvfrom_chk.c = -fexceptions -fasynchronous-unwind-tables
+
+tests = backtrace-tst tst-chk1 tst-chk2 tst-chk3 \
+	tst-lfschk1 tst-lfschk2 tst-lfschk3 test-strcpy_chk test-stpcpy_chk
+
+extra-libs = libSegFault libpcprofile
+extra-libs-others = $(extra-libs)
+
+libSegFault-routines = segfault
+libSegFault-inhibit-o = $(filter-out .os,$(object-suffixes))
+
+libpcprofile-routines = pcprofile
+libpcprofile-inhibit-o = $(filter-out .os,$(object-suffixes))
+
+others = pcprofiledump
+install-bin = pcprofiledump
+install-bin-script = xtrace
+
+include ../Makeconfig
+
+distribute += catchsegv.sh xtrace.sh
+ifeq ($(elf),yes)
+ifeq ($(build-shared),yes)
+install-bin-script += catchsegv
+endif
+endif
+generated = catchsegv xtrace
+
+include ../Rules
+
+$(objpfx)catchsegv: catchsegv.sh $(common-objpfx)soversions.mk \
+		    $(common-objpfx)config.make
+	slibpfx=`echo $(slibdir)|sed 's/lib\(64\|\)$$/\\\\\\\\$$LIB/'`; \
+	sed -e 's|@VERSION@|$(version)|' -e "s|@SLIB@|$$slibpfx|" $< > $@.new
+	chmod 555 $@.new
+	mv -f $@.new $@
+
+$(objpfx)pcprofiledump: $(objpfx)pcprofiledump.o
+
+$(objpfx)xtrace: xtrace.sh
+	rm -f $@.new
+	sed -e 's|@BASH@|$(BASH)|' -e 's|@VERSION@|$(version)|' \
+	    -e 's|@SLIBDIR@|$(slibdir)|' -e 's|@BINDIR@|$(bindir)|' $^ > $@.new \
+	&& rm -f $@ && mv $@.new $@ && chmod +x $@
+
+# Depend on libc.so so a DT_NEEDED is generated in the shared objects.
+# This ensures they will load libc.so for needed symbols if loaded by
+# a statically-linked program that hasn't already loaded it.
+$(objpfx)libSegFault.so: $(common-objpfx)libc.so \
+			 $(common-objpfx)libc_nonshared.a \
+			 $(elf-objpfx)$(rtld-installed-name)
+$(objpfx)libpcprofile.so: $(common-objpfx)libc.so \
+			  $(common-objpfx)libc_nonshared.a \
+			  $(elf-objpfx)$(rtld-installed-name)
Index: trunk/src/libctests/glibc/debug/backtrace-tst.c
===================================================================
--- trunk/src/libctests/glibc/debug/backtrace-tst.c	(revision 2036)
+++ trunk/src/libctests/glibc/debug/backtrace-tst.c	(revision 2036)
@@ -0,0 +1,44 @@
+#include <execinfo.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static int
+compare (const void *p1, const void *p2)
+{
+  void *ba[20];
+  int n = backtrace (ba, sizeof (ba) / sizeof (ba[0]));
+  if (n != 0)
+    {
+      char **names = backtrace_symbols (ba, n);
+      if (names != NULL)
+	{
+	  int i;
+	  printf ("called from %s\n", names[0]);
+	  for (i = 1; i < n; ++i)
+	    printf ("            %s\n", names[i]);
+	  free (names);
+	}
+    }
+
+  return *(const uint32_t *) p1 - *(const uint32_t *) p2;
+}
+
+
+int
+main (int argc, char *argv[])
+{
+  uint32_t arr[20];
+  size_t cnt;
+
+  for (cnt = 0; cnt < sizeof (arr) / sizeof (arr[0]); ++cnt)
+    arr[cnt] = random ();
+
+  qsort (arr, sizeof (arr) / sizeof (arr[0]), sizeof (arr[0]), compare);
+
+  for (cnt = 0; cnt < sizeof (arr) / sizeof (arr[0]); ++cnt)
+    printf ("%" PRIx32 "\n", arr[cnt]);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/debug/test-stpcpy_chk.c
===================================================================
--- trunk/src/libctests/glibc/debug/test-stpcpy_chk.c	(revision 2036)
+++ trunk/src/libctests/glibc/debug/test-stpcpy_chk.c	(revision 2036)
@@ -0,0 +1,46 @@
+/* Test and measure stpcpy checking functions.
+   Copyright (C) 1999, 2002, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Jakub Jelinek <jakub@redhat.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define STRCPY_RESULT(dst, len) ((dst) + (len))
+#define TEST_MAIN
+#include "../string/test-string.h"
+
+extern void __attribute__ ((noreturn)) __chk_fail (void);
+char *simple_stpcpy_chk (char *, const char *, size_t);
+extern char *normal_stpcpy (char *, const char *, size_t)
+  __asm ("stpcpy");
+extern char *__stpcpy_chk (char *, const char *, size_t);
+
+IMPL (simple_stpcpy_chk, 0)
+IMPL (normal_stpcpy, 1)
+IMPL (__stpcpy_chk, 2)
+
+char *
+simple_stpcpy_chk (char *dst, const char *src, size_t len)
+{
+  if (! len)
+    __chk_fail ();
+  while ((*dst++ = *src++) != '\0')
+    if (--len == 0)
+      __chk_fail ();
+  return dst - 1;
+}
+
+#include "test-strcpy_chk.c"
Index: trunk/src/libctests/glibc/debug/test-strcpy_chk.c
===================================================================
--- trunk/src/libctests/glibc/debug/test-strcpy_chk.c	(revision 2036)
+++ trunk/src/libctests/glibc/debug/test-strcpy_chk.c	(revision 2036)
@@ -0,0 +1,387 @@
+/* Test and measure __strcpy_chk functions.
+   Copyright (C) 1999, 2002, 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Jakub Jelinek <jakub@redhat.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef STRCPY_RESULT
+# define STRCPY_RESULT(dst, len) dst
+# define TEST_MAIN
+# include "../string/test-string.h"
+
+extern void __attribute__ ((noreturn)) __chk_fail (void);
+char *simple_strcpy_chk (char *, const char *, size_t);
+extern char *normal_strcpy (char *, const char *, size_t)
+  __asm ("strcpy");
+extern char *__strcpy_chk (char *, const char *, size_t);
+
+IMPL (simple_strcpy_chk, 0)
+IMPL (normal_strcpy, 1)
+IMPL (__strcpy_chk, 2)
+
+char *
+simple_strcpy_chk (char *dst, const char *src, size_t len)
+{
+  char *ret = dst;
+  if (! len)
+    __chk_fail ();
+  while ((*dst++ = *src++) != '\0')
+    if (--len == 0)
+      __chk_fail ();
+  return ret;
+}
+#endif
+
+#include <fcntl.h>
+#include <paths.h>
+#include <setjmp.h>
+#include <signal.h>
+
+volatile int chk_fail_ok;
+jmp_buf chk_fail_buf;
+
+static void
+handler (int sig)
+{
+  if (chk_fail_ok)
+    {
+      chk_fail_ok = 0;
+      longjmp (chk_fail_buf, 1);
+    }
+  else
+    _exit (127);
+}
+
+typedef char *(*proto_t) (char *, const char *, size_t);
+
+static void
+do_one_test (impl_t *impl, char *dst, const char *src,
+	     size_t len, size_t dlen)
+{
+  char *res;
+  if (dlen <= len)
+    {
+      if (impl->test == 1)
+	return;
+
+      chk_fail_ok = 1;
+      if (setjmp (chk_fail_buf) == 0)
+	{
+	  res = CALL (impl, dst, src, dlen);
+	  printf ("*** Function %s (%zd; %zd) did not __chk_fail\n",
+		  impl->name, len, dlen);
+	  chk_fail_ok = 0;
+	  ret = 1;
+	}
+      return;
+    }
+  else
+    res = CALL (impl, dst, src, dlen);
+
+  if (res != STRCPY_RESULT (dst, len))
+    {
+      printf ("Wrong result in function %s %p %p\n", impl->name,
+	      res, STRCPY_RESULT (dst, len));
+      ret = 1;
+      return;
+    }
+
+  if (strcmp (dst, src) != 0)
+    {
+      printf ("Wrong result in function %s dst \"%s\" src \"%s\"\n",
+	      impl->name, dst, src);
+      ret = 1;
+      return;
+    }
+
+  if (HP_TIMING_AVAIL)
+    {
+      hp_timing_t start __attribute ((unused));
+      hp_timing_t stop __attribute ((unused));;
+      hp_timing_t best_time = ~ (hp_timing_t) 0;
+      size_t i;
+
+      for (i = 0; i < 32; ++i)
+	{
+	  HP_TIMING_NOW (start);
+	  CALL (impl, dst, src, dlen);
+	  HP_TIMING_NOW (stop);
+	  HP_TIMING_BEST (best_time, start, stop);
+	}
+
+      printf ("\t%zd", (size_t) best_time);
+    }
+}
+
+static void
+do_test (size_t align1, size_t align2, size_t len, size_t dlen, int max_char)
+{
+  size_t i;
+  char *s1, *s2;
+
+  align1 &= 7;
+  if (align1 + len >= page_size)
+    return;
+
+  align2 &= 7;
+  if (align2 + len >= page_size)
+    return;
+
+  s1 = buf1 + align1;
+  s2 = buf2 + align2;
+
+  for (i = 0; i < len; i++)
+    s1[i] = 32 + 23 * i % (max_char - 32);
+  s1[len] = 0;
+
+  if (HP_TIMING_AVAIL && dlen > len)
+    printf ("Length %4zd, alignment %2zd/%2zd:", len, align1, align2);
+
+  FOR_EACH_IMPL (impl, 0)
+    do_one_test (impl, s2, s1, len, dlen);
+
+  if (HP_TIMING_AVAIL && dlen > len)
+    putchar ('\n');
+}
+
+static void
+do_random_tests (void)
+{
+  size_t i, j, n, align1, align2, len, dlen;
+  unsigned char *p1 = buf1 + page_size - 512;
+  unsigned char *p2 = buf2 + page_size - 512;
+  unsigned char *res;
+
+  for (n = 0; n < ITERATIONS; n++)
+    {
+      align1 = random () & 31;
+      if (random () & 1)
+	align2 = random () & 31;
+      else
+	align2 = align1 + (random () & 24);
+      len = random () & 511;
+      j = align1;
+      if (align2 > j)
+	j = align2;
+      if (len + j >= 511)
+	len = 510 - j - (random () & 7);
+      j = len + align1 + 64;
+      if (j > 512)
+	j = 512;
+      for (i = 0; i < j; i++)
+	{
+	  if (i == len + align1)
+	    p1[i] = 0;
+	  else
+	    {
+	      p1[i] = random () & 255;
+	      if (i >= align1 && i < len + align1 && !p1[i])
+		p1[i] = (random () & 127) + 3;
+	    }
+	}
+
+      switch (random () & 7)
+	{
+	case 0:
+	  dlen = len - (random () & 31);
+	  if (dlen > len)
+	    dlen = len;
+	  break;
+	case 1:
+	  dlen = (size_t) -1;
+	  break;
+	case 2:
+	  dlen = len + 1 + (random () & 65535);
+	  break;
+	case 3:
+	  dlen = len + 1 + (random () & 255);
+	  break;
+	case 4:
+	  dlen = len + 1 + (random () & 31);
+	  break;
+	case 5:
+	  dlen = len + 1 + (random () & 7);
+	  break;
+	case 6:
+	  dlen = len + 1 + (random () & 3);
+	  break;
+	default:
+	  dlen = len + 1;
+	  break;
+	}
+
+      FOR_EACH_IMPL (impl, 1)
+	{
+	  if (dlen <= len)
+	    {
+	      if (impl->test != 1)
+		{
+		  chk_fail_ok = 1;
+		  if (setjmp (chk_fail_buf) == 0)
+		    {
+		      res = CALL (impl, p2 + align2, p1 + align1, dlen);
+		      printf ("Iteration %zd - did not __chk_fail\n", n);
+		      chk_fail_ok = 0;
+		      ret = 1;
+		    }
+		}
+	      continue;
+	    }
+	  memset (p2 - 64, '\1', 512 + 64);
+	  res = CALL (impl, p2 + align2, p1 + align1, dlen);
+	  if (res != STRCPY_RESULT (p2 + align2, len))
+	    {
+	      printf ("\
+Iteration %zd - wrong result in function %s (%zd, %zd, %zd) %p != %p\n",
+		      n, impl->name, align1, align2, len, res,
+		      STRCPY_RESULT (p2 + align2, len));
+	      ret = 1;
+	    }
+	  for (j = 0; j < align2 + 64; ++j)
+	    {
+	      if (p2[j - 64] != '\1')
+		{
+		  printf ("\
+Iteration %zd - garbage before, %s (%zd, %zd, %zd)\n",
+			  n, impl->name, align1, align2, len);
+		  ret = 1;
+		  break;
+		}
+	    }
+	  for (j = align2 + len + 1; j < 512; ++j)
+	    {
+	      if (p2[j] != '\1')
+		{
+		  printf ("\
+Iteration %zd - garbage after, %s (%zd, %zd, %zd)\n",
+			  n, impl->name, align1, align2, len);
+		  ret = 1;
+		  break;
+		}
+	    }
+	  if (memcmp (p1 + align1, p2 + align2, len + 1))
+	    {
+	      printf ("\
+Iteration %zd - different strings, %s (%zd, %zd, %zd)\n",
+		      n, impl->name, align1, align2, len);
+	      ret = 1;
+	    }
+	}
+    }
+}
+
+int
+test_main (void)
+{
+  size_t i;
+
+  struct sigaction sa;
+  sa.sa_handler = handler;
+  sa.sa_flags = 0;
+  sigemptyset (&sa.sa_mask);
+
+  sigaction (SIGABRT, &sa, NULL);
+
+  /* Avoid all the buffer overflow messages on stderr.  */
+  int fd = open (_PATH_DEVNULL, O_WRONLY);
+  if (fd == -1)
+    close (STDERR_FILENO);
+  else
+    {
+      dup2 (fd, STDERR_FILENO);
+      close (fd);
+    }
+  setenv ("LIBC_FATAL_STDERR_", "1", 1);
+
+  test_init ();
+
+  printf ("%23s", "");
+  FOR_EACH_IMPL (impl, 0)
+    printf ("\t%s", impl->name);
+  putchar ('\n');
+
+  for (i = 0; i < 16; ++i)
+    {
+      do_test (0, 0, i, i + 1, 127);
+      do_test (0, 0, i, i + 1, 255);
+      do_test (0, i, i, i + 1, 127);
+      do_test (i, 0, i, i + 1, 255);
+    }
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (0, 0, 8 << i, (8 << i) + 1, 127);
+      do_test (8 - i, 2 * i, (8 << i), (8 << i) + 1, 127);
+    }
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (i, 2 * i, (8 << i), (8 << i) + 1, 127);
+      do_test (2 * i, i, (8 << i), (8 << i) + 1, 255);
+      do_test (i, i, (8 << i), (8 << i) + 1, 127);
+      do_test (i, i, (8 << i), (8 << i) + 1, 255);
+    }
+
+  for (i = 0; i < 16; ++i)
+    {
+      do_test (0, 0, i, i + 256, 127);
+      do_test (0, 0, i, i + 256, 255);
+      do_test (0, i, i, i + 256, 127);
+      do_test (i, 0, i, i + 256, 255);
+    }
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (0, 0, 8 << i, (8 << i) + 256, 127);
+      do_test (8 - i, 2 * i, (8 << i), (8 << i) + 256, 127);
+    }
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (i, 2 * i, (8 << i), (8 << i) + 256, 127);
+      do_test (2 * i, i, (8 << i), (8 << i) + 256, 255);
+      do_test (i, i, (8 << i), (8 << i) + 256, 127);
+      do_test (i, i, (8 << i), (8 << i) + 256, 255);
+    }
+
+  for (i = 0; i < 16; ++i)
+    {
+      do_test (0, 0, i, i, 127);
+      do_test (0, 0, i, i + 2, 255);
+      do_test (0, i, i, i + 3, 127);
+      do_test (i, 0, i, i + 4, 255);
+    }
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (0, 0, 8 << i, (8 << i) - 15, 127);
+      do_test (8 - i, 2 * i, (8 << i), (8 << i) + 5, 127);
+    }
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (i, 2 * i, (8 << i), (8 << i) + i, 127);
+      do_test (2 * i, i, (8 << i), (8 << i) + (i - 1), 255);
+      do_test (i, i, (8 << i), (8 << i) + i + 2, 127);
+      do_test (i, i, (8 << i), (8 << i) + i + 3, 255);
+    }
+
+  do_random_tests ();
+  return ret;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/debug/tst-chk1.c
===================================================================
--- trunk/src/libctests/glibc/debug/tst-chk1.c	(revision 2036)
+++ trunk/src/libctests/glibc/debug/tst-chk1.c	(revision 2036)
@@ -0,0 +1,795 @@
+/* Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <fcntl.h>
+#include <paths.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <unistd.h>
+
+char *temp_filename;
+static void do_prepare (void);
+static int do_test (void);
+#define PREPARE(argc, argv) do_prepare ()
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
+
+static void
+do_prepare (void)
+{
+  int temp_fd = create_temp_file ("tst-chk1.", &temp_filename);
+  if (temp_fd == -1)
+    {
+      printf ("cannot create temporary file: %m\n");
+      exit (1);
+    }
+
+  const char *strs = "abcdefgh\nABCDEFGHI\nabcdefghij\nABCDEFGHIJ";
+  if (write (temp_fd, strs, strlen (strs)) != strlen (strs))
+    {
+      puts ("could not write test strings into file");
+      unlink (temp_filename);
+      exit (1);
+    }
+}
+
+volatile int chk_fail_ok;
+volatile int ret;
+jmp_buf chk_fail_buf;
+
+static void
+handler (int sig)
+{
+  if (chk_fail_ok)
+    {
+      chk_fail_ok = 0;
+      longjmp (chk_fail_buf, 1);
+    }
+  else
+    _exit (127);
+}
+
+char buf[10];
+volatile size_t l0;
+volatile char *p;
+const char *str1 = "JIHGFEDCBA";
+const char *str2 = "F";
+const char *str3 = "%s%n%s%n";
+const char *str4 = "Hello, ";
+const char *str5 = "World!\n";
+char buf2[10] = "%s";
+int num1 = 67;
+int num2 = 987654;
+
+#define FAIL() \
+  do { printf ("Failure on line %d\n", __LINE__); ret = 1; } while (0)
+#define CHK_FAIL_START \
+  chk_fail_ok = 1;				\
+  if (! setjmp (chk_fail_buf))			\
+    {
+#define CHK_FAIL_END \
+      chk_fail_ok = 0;				\
+      FAIL ();					\
+    }
+#if __USE_FORTIFY_LEVEL >= 2
+#define CHK_FAIL2_START CHK_FAIL_START
+#define CHK_FAIL2_END CHK_FAIL_END
+#else
+#define CHK_FAIL2_START
+#define CHK_FAIL2_END
+#endif
+
+static int
+do_test (void)
+{
+  struct sigaction sa;
+  sa.sa_handler = handler;
+  sa.sa_flags = 0;
+  sigemptyset (&sa.sa_mask);
+
+  sigaction (SIGABRT, &sa, NULL);
+
+  /* Avoid all the buffer overflow messages on stderr.  */
+  int fd = open (_PATH_DEVNULL, O_WRONLY);
+  if (fd == -1)
+    close (STDERR_FILENO);
+  else
+    {
+      dup2 (fd, STDERR_FILENO);
+      close (fd);
+    }
+  setenv ("LIBC_FATAL_STDERR_", "1", 1);
+
+  struct A { char buf1[9]; char buf2[1]; } a;
+
+  printf ("Test checking routines at fortify level %d\n",
+#ifdef __USE_FORTIFY_LEVEL
+	  (int) __USE_FORTIFY_LEVEL
+#else
+	  0
+#endif
+	  );
+
+  /* These ops can be done without runtime checking of object size.  */
+  memcpy (buf, "abcdefghij", 10);
+  memmove (buf + 1, buf, 9);
+  if (memcmp (buf, "aabcdefghi", 10))
+    FAIL ();
+
+  if (mempcpy (buf + 5, "abcde", 5) != buf + 10 || memcmp (buf, "aabcdabcde", 10))
+    FAIL ();
+
+  memset (buf + 8, 'j', 2);
+  if (memcmp (buf, "aabcdabcjj", 10))
+    FAIL ();
+
+  strcpy (buf + 4, "EDCBA");
+  if (memcmp (buf, "aabcEDCBA", 10))
+    FAIL ();
+
+  if (stpcpy (buf + 8, "F") != buf + 9 || memcmp (buf, "aabcEDCBF", 10))
+    FAIL ();
+
+  strncpy (buf + 6, "X", 4);
+  if (memcmp (buf, "aabcEDX\0\0", 10))
+    FAIL ();
+
+  if (sprintf (buf + 7, "%s", "67") != 2 || memcmp (buf, "aabcEDX67", 10))
+    FAIL ();
+
+  if (snprintf (buf + 7, 3, "%s", "987654") != 6
+      || memcmp (buf, "aabcEDX98", 10))
+    FAIL ();
+
+  /* These ops need runtime checking, but shouldn't __chk_fail.  */
+  memcpy (buf, "abcdefghij", l0 + 10);
+  memmove (buf + 1, buf, l0 + 9);
+  if (memcmp (buf, "aabcdefghi", 10))
+    FAIL ();
+
+  if (mempcpy (buf + 5, "abcde", l0 + 5) != buf + 10 || memcmp (buf, "aabcdabcde", 10))
+    FAIL ();
+
+  memset (buf + 8, 'j', l0 + 2);
+  if (memcmp (buf, "aabcdabcjj", 10))
+    FAIL ();
+
+  strcpy (buf + 4, str1 + 5);
+  if (memcmp (buf, "aabcEDCBA", 10))
+    FAIL ();
+
+  if (stpcpy (buf + 8, str2) != buf + 9 || memcmp (buf, "aabcEDCBF", 10))
+    FAIL ();
+
+  strncpy (buf + 6, "X", l0 + 4);
+  if (memcmp (buf, "aabcEDX\0\0", 10))
+    FAIL ();
+
+  if (sprintf (buf + 7, "%d", num1) != 2 || memcmp (buf, "aabcEDX67", 10))
+    FAIL ();
+
+  if (snprintf (buf + 7, 3, "%d", num2) != 6 || memcmp (buf, "aabcEDX98", 10))
+    FAIL ();
+
+  buf[l0 + 8] = '\0';
+  strcat (buf, "A");
+  if (memcmp (buf, "aabcEDX9A", 10))
+    FAIL ();
+
+  buf[l0 + 7] = '\0';
+  strncat (buf, "ZYXWV", l0 + 2);
+  if (memcmp (buf, "aabcEDXZY", 10))
+    FAIL ();
+
+  memcpy (a.buf1, "abcdefghij", l0 + 10);
+  memmove (a.buf1 + 1, a.buf1, l0 + 9);
+  if (memcmp (a.buf1, "aabcdefghi", 10))
+    FAIL ();
+
+  if (mempcpy (a.buf1 + 5, "abcde", l0 + 5) != a.buf1 + 10
+      || memcmp (a.buf1, "aabcdabcde", 10))
+    FAIL ();
+
+  memset (a.buf1 + 8, 'j', l0 + 2);
+  if (memcmp (a.buf1, "aabcdabcjj", 10))
+    FAIL ();
+
+#if __USE_FORTIFY_LEVEL < 2
+  /* The following tests are supposed to crash with -D_FORTIFY_SOURCE=2
+     and sufficient GCC support, as the string operations overflow
+     from a.buf1 into a.buf2.  */
+  strcpy (a.buf1 + 4, str1 + 5);
+  if (memcmp (a.buf1, "aabcEDCBA", 10))
+    FAIL ();
+
+  if (stpcpy (a.buf1 + 8, str2) != a.buf1 + 9 || memcmp (a.buf1, "aabcEDCBF", 10))
+    FAIL ();
+
+  strncpy (a.buf1 + 6, "X", l0 + 4);
+  if (memcmp (a.buf1, "aabcEDX\0\0", 10))
+    FAIL ();
+
+  if (sprintf (a.buf1 + 7, "%d", num1) != 2 || memcmp (a.buf1, "aabcEDX67", 10))
+    FAIL ();
+
+  if (snprintf (a.buf1 + 7, 3, "%d", num2) != 6
+      || memcmp (a.buf1, "aabcEDX98", 10))
+    FAIL ();
+
+  a.buf1[l0 + 8] = '\0';
+  strcat (a.buf1, "A");
+  if (memcmp (a.buf1, "aabcEDX9A", 10))
+    FAIL ();
+
+  a.buf1[l0 + 7] = '\0';
+  strncat (a.buf1, "ZYXWV", l0 + 2);
+  if (memcmp (a.buf1, "aabcEDXZY", 10))
+    FAIL ();
+
+#endif
+
+#if __USE_FORTIFY_LEVEL >= 1
+  /* Now check if all buffer overflows are caught at runtime.  */
+
+  CHK_FAIL_START
+  memcpy (buf + 1, "abcdefghij", l0 + 10);
+  CHK_FAIL_END
+
+  CHK_FAIL_START
+  memmove (buf + 2, buf + 1, l0 + 9);
+  CHK_FAIL_END
+
+  CHK_FAIL_START
+  p = mempcpy (buf + 6, "abcde", l0 + 5);
+  CHK_FAIL_END
+
+  CHK_FAIL_START
+  memset (buf + 9, 'j', l0 + 2);
+  CHK_FAIL_END
+
+  CHK_FAIL_START
+  strcpy (buf + 5, str1 + 5);
+  CHK_FAIL_END
+
+  CHK_FAIL_START
+  p = stpcpy (buf + 9, str2);
+  CHK_FAIL_END
+
+  CHK_FAIL_START
+  strncpy (buf + 7, "X", l0 + 4);
+  CHK_FAIL_END
+
+  CHK_FAIL_START
+  sprintf (buf + 8, "%d", num1);
+  CHK_FAIL_END
+
+  CHK_FAIL_START
+  snprintf (buf + 8, l0 + 3, "%d", num2);
+  CHK_FAIL_END
+
+  memcpy (buf, str1 + 2, l0 + 9);
+  CHK_FAIL_START
+  strcat (buf, "AB");
+  CHK_FAIL_END
+
+  memcpy (buf, str1 + 3, l0 + 8);
+  CHK_FAIL_START
+  strncat (buf, "ZYXWV", l0 + 3);
+  CHK_FAIL_END
+
+  CHK_FAIL_START
+  memcpy (a.buf1 + 1, "abcdefghij", l0 + 10);
+  CHK_FAIL_END
+
+  CHK_FAIL_START
+  memmove (a.buf1 + 2, a.buf1 + 1, l0 + 9);
+  CHK_FAIL_END
+
+  CHK_FAIL_START
+  p = mempcpy (a.buf1 + 6, "abcde", l0 + 5);
+  CHK_FAIL_END
+
+  CHK_FAIL_START
+  memset (a.buf1 + 9, 'j', l0 + 2);
+  CHK_FAIL_END
+
+#if __USE_FORTIFY_LEVEL >= 2
+# define O 0
+#else
+# define O 1
+#endif
+
+  CHK_FAIL_START
+  strcpy (a.buf1 + (O + 4), str1 + 5);
+  CHK_FAIL_END
+
+  CHK_FAIL_START
+  p = stpcpy (a.buf1 + (O + 8), str2);
+  CHK_FAIL_END
+
+  CHK_FAIL_START
+  strncpy (a.buf1 + (O + 6), "X", l0 + 4);
+  CHK_FAIL_END
+
+  CHK_FAIL_START
+  sprintf (a.buf1 + (O + 7), "%d", num1);
+  CHK_FAIL_END
+
+  CHK_FAIL_START
+  snprintf (a.buf1 + (O + 7), l0 + 3, "%d", num2);
+  CHK_FAIL_END
+
+  memcpy (a.buf1, str1 + (3 - O), l0 + 8 + O);
+  CHK_FAIL_START
+  strcat (a.buf1, "AB");
+  CHK_FAIL_END
+
+  memcpy (a.buf1, str1 + (4 - O), l0 + 7 + O);
+  CHK_FAIL_START
+  strncat (a.buf1, "ZYXWV", l0 + 3);
+  CHK_FAIL_END
+#endif
+
+  /* Now checks for %n protection.  */
+
+  /* Constant literals passed directly are always ok
+     (even with warnings about possible bugs from GCC).  */
+  int n1, n2;
+  if (sprintf (buf, "%s%n%s%n", str2, &n1, str2, &n2) != 2
+      || n1 != 1 || n2 != 2)
+    FAIL ();
+
+  /* In this case the format string is not known at compile time,
+     but resides in read-only memory, so is ok.  */
+  if (snprintf (buf, 4, str3, str2, &n1, str2, &n2) != 2
+      || n1 != 1 || n2 != 2)
+    FAIL ();
+
+  strcpy (buf2 + 2, "%n%s%n");
+  /* When the format string is writable and contains %n,
+     with -D_FORTIFY_SOURCE=2 it causes __chk_fail.  */
+  CHK_FAIL2_START
+  if (sprintf (buf, buf2, str2, &n1, str2, &n1) != 2)
+    FAIL ();
+  CHK_FAIL2_END
+
+  CHK_FAIL2_START
+  if (snprintf (buf, 3, buf2, str2, &n1, str2, &n1) != 2)
+    FAIL ();
+  CHK_FAIL2_END
+
+  /* But if there is no %n, even writable format string
+     should work.  */
+  buf2[6] = '\0';
+  if (sprintf (buf, buf2 + 4, str2) != 1)
+    FAIL ();
+
+  /* Constant literals passed directly are always ok
+     (even with warnings about possible bugs from GCC).  */
+  if (printf ("%s%n%s%n", str4, &n1, str5, &n2) != 14
+      || n1 != 7 || n2 != 14)
+    FAIL ();
+
+  /* In this case the format string is not known at compile time,
+     but resides in read-only memory, so is ok.  */
+  if (printf (str3, str4, &n1, str5, &n2) != 14
+      || n1 != 7 || n2 != 14)
+    FAIL ();
+
+  strcpy (buf2 + 2, "%n%s%n");
+  /* When the format string is writable and contains %n,
+     with -D_FORTIFY_SOURCE=2 it causes __chk_fail.  */
+  CHK_FAIL2_START
+  if (printf (buf2, str4, &n1, str5, &n1) != 14)
+    FAIL ();
+  CHK_FAIL2_END
+
+  /* But if there is no %n, even writable format string
+     should work.  */
+  buf2[6] = '\0';
+  if (printf (buf2 + 4, str5) != 7)
+    FAIL ();
+
+  FILE *fp = stdout;
+
+  /* Constant literals passed directly are always ok
+     (even with warnings about possible bugs from GCC).  */
+  if (fprintf (fp, "%s%n%s%n", str4, &n1, str5, &n2) != 14
+      || n1 != 7 || n2 != 14)
+    FAIL ();
+
+  /* In this case the format string is not known at compile time,
+     but resides in read-only memory, so is ok.  */
+  if (fprintf (fp, str3, str4, &n1, str5, &n2) != 14
+      || n1 != 7 || n2 != 14)
+    FAIL ();
+
+  strcpy (buf2 + 2, "%n%s%n");
+  /* When the format string is writable and contains %n,
+     with -D_FORTIFY_SOURCE=2 it causes __chk_fail.  */
+  CHK_FAIL2_START
+  if (fprintf (fp, buf2, str4, &n1, str5, &n1) != 14)
+    FAIL ();
+  CHK_FAIL2_END
+
+  /* But if there is no %n, even writable format string
+     should work.  */
+  buf2[6] = '\0';
+  if (fprintf (fp, buf2 + 4, str5) != 7)
+    FAIL ();
+
+  if (freopen (temp_filename, "r", stdin) == NULL)
+    {
+      puts ("could not open temporary file");
+      exit (1);
+    }
+
+  if (gets (buf) != buf || memcmp (buf, "abcdefgh", 9))
+    FAIL ();
+  if (gets (buf) != buf || memcmp (buf, "ABCDEFGHI", 10))
+    FAIL ();
+
+#if __USE_FORTIFY_LEVEL >= 1
+  CHK_FAIL_START
+  if (gets (buf) != buf)
+    FAIL ();
+  CHK_FAIL_END
+#endif
+
+  rewind (stdin);
+
+  if (fgets (buf, sizeof (buf), stdin) != buf
+      || memcmp (buf, "abcdefgh\n", 10))
+    FAIL ();
+  if (fgets (buf, sizeof (buf), stdin) != buf || memcmp (buf, "ABCDEFGHI", 10))
+    FAIL ();
+
+  rewind (stdin);
+
+  if (fgets (buf, l0 + sizeof (buf), stdin) != buf
+      || memcmp (buf, "abcdefgh\n", 10))
+    FAIL ();
+
+#if __USE_FORTIFY_LEVEL >= 1
+  CHK_FAIL_START
+  if (fgets (buf, sizeof (buf) + 1, stdin) != buf)
+    FAIL ();
+  CHK_FAIL_END
+
+  CHK_FAIL_START
+  if (fgets (buf, l0 + sizeof (buf) + 1, stdin) != buf)
+    FAIL ();
+  CHK_FAIL_END
+#endif
+
+  rewind (stdin);
+
+  if (fgets_unlocked (buf, sizeof (buf), stdin) != buf
+      || memcmp (buf, "abcdefgh\n", 10))
+    FAIL ();
+  if (fgets_unlocked (buf, sizeof (buf), stdin) != buf
+      || memcmp (buf, "ABCDEFGHI", 10))
+    FAIL ();
+
+  rewind (stdin);
+
+  if (fgets_unlocked (buf, l0 + sizeof (buf), stdin) != buf
+      || memcmp (buf, "abcdefgh\n", 10))
+    FAIL ();
+
+#if __USE_FORTIFY_LEVEL >= 1
+  CHK_FAIL_START
+  if (fgets_unlocked (buf, sizeof (buf) + 1, stdin) != buf)
+    FAIL ();
+  CHK_FAIL_END
+
+  CHK_FAIL_START
+  if (fgets_unlocked (buf, l0 + sizeof (buf) + 1, stdin) != buf)
+    FAIL ();
+  CHK_FAIL_END
+#endif
+
+  lseek (fileno (stdin), 0, SEEK_SET);
+
+  if (read (fileno (stdin), buf, sizeof (buf) - 1) != sizeof (buf) - 1
+      || memcmp (buf, "abcdefgh\n", 9))
+    FAIL ();
+  if (read (fileno (stdin), buf, sizeof (buf) - 1) != sizeof (buf) - 1
+      || memcmp (buf, "ABCDEFGHI", 9))
+    FAIL ();
+
+  lseek (fileno (stdin), 0, SEEK_SET);
+
+  if (read (fileno (stdin), buf, l0 + sizeof (buf) - 1) != sizeof (buf) - 1
+      || memcmp (buf, "abcdefgh\n", 9))
+    FAIL ();
+
+#if __USE_FORTIFY_LEVEL >= 1
+  CHK_FAIL_START
+  if (read (fileno (stdin), buf, sizeof (buf) + 1) != sizeof (buf) + 1)
+    FAIL ();
+  CHK_FAIL_END
+#endif
+
+  if (pread (fileno (stdin), buf, sizeof (buf) - 1, sizeof (buf) - 2)
+      != sizeof (buf) - 1
+      || memcmp (buf, "\nABCDEFGH", 9))
+    FAIL ();
+  if (pread (fileno (stdin), buf, sizeof (buf) - 1, 0) != sizeof (buf) - 1
+      || memcmp (buf, "abcdefgh\n", 9))
+    FAIL ();
+  if (pread (fileno (stdin), buf, l0 + sizeof (buf) - 1, sizeof (buf) - 3)
+      != sizeof (buf) - 1
+      || memcmp (buf, "h\nABCDEFG", 9))
+    FAIL ();
+
+#if __USE_FORTIFY_LEVEL >= 1
+  CHK_FAIL_START
+  if (pread (fileno (stdin), buf, sizeof (buf) + 1, 2 * sizeof (buf))
+      != sizeof (buf) + 1)
+    FAIL ();
+  CHK_FAIL_END
+#endif
+
+  if (pread64 (fileno (stdin), buf, sizeof (buf) - 1, sizeof (buf) - 2)
+      != sizeof (buf) - 1
+      || memcmp (buf, "\nABCDEFGH", 9))
+    FAIL ();
+  if (pread64 (fileno (stdin), buf, sizeof (buf) - 1, 0) != sizeof (buf) - 1
+      || memcmp (buf, "abcdefgh\n", 9))
+    FAIL ();
+  if (pread64 (fileno (stdin), buf, l0 + sizeof (buf) - 1, sizeof (buf) - 3)
+      != sizeof (buf) - 1
+      || memcmp (buf, "h\nABCDEFG", 9))
+    FAIL ();
+
+#if __USE_FORTIFY_LEVEL >= 1
+  CHK_FAIL_START
+  if (pread64 (fileno (stdin), buf, sizeof (buf) + 1, 2 * sizeof (buf))
+      != sizeof (buf) + 1)
+    FAIL ();
+  CHK_FAIL_END
+#endif
+
+  if (freopen (temp_filename, "r", stdin) == NULL)
+    {
+      puts ("could not open temporary file");
+      exit (1);
+    }
+
+  if (fseek (stdin, 9 + 10 + 11, SEEK_SET))
+    {
+      puts ("could not seek in test file");
+      exit (1);
+    }
+
+#if __USE_FORTIFY_LEVEL >= 1
+  CHK_FAIL_START
+  if (gets (buf) != buf)
+    FAIL ();
+  CHK_FAIL_END
+#endif
+
+  /* Check whether missing N$ formats are detected.  */
+  CHK_FAIL2_START
+  printf ("%3$d\n", 1, 2, 3, 4);
+  CHK_FAIL2_END
+
+  CHK_FAIL2_START
+  fprintf (stdout, "%3$d\n", 1, 2, 3, 4);
+  CHK_FAIL2_END
+
+  CHK_FAIL2_START
+  sprintf (buf, "%3$d\n", 1, 2, 3, 4);
+  CHK_FAIL2_END
+
+  CHK_FAIL2_START
+  snprintf (buf, sizeof (buf), "%3$d\n", 1, 2, 3, 4);
+  CHK_FAIL2_END
+
+  int sp[2];
+  if (socketpair (PF_UNIX, SOCK_STREAM, 0, sp))
+    FAIL ();
+  else
+    {
+      const char *sendstr = "abcdefgh\nABCDEFGH\n0123456789\n";
+      if (send (sp[0], sendstr, strlen (sendstr), 0) != strlen (sendstr))
+	FAIL ();
+
+      char recvbuf[12];
+      if (recv (sp[1], recvbuf, sizeof recvbuf, MSG_PEEK)
+	  != sizeof recvbuf
+	  || memcmp (recvbuf, sendstr, sizeof recvbuf) != 0)
+	FAIL ();
+
+      if (recv (sp[1], recvbuf + 6, l0 + sizeof recvbuf - 7, MSG_PEEK)
+	  != sizeof recvbuf - 7
+	  || memcmp (recvbuf + 6, sendstr, sizeof recvbuf - 7) != 0)
+	FAIL ();
+
+#if __USE_FORTIFY_LEVEL >= 1
+      CHK_FAIL_START
+      if (recv (sp[1], recvbuf + 1, sizeof recvbuf, MSG_PEEK)
+	  != sizeof recvbuf)
+	FAIL ();
+      CHK_FAIL_END
+
+      CHK_FAIL_START
+      if (recv (sp[1], recvbuf + 4, l0 + sizeof recvbuf - 3, MSG_PEEK)
+	  != sizeof recvbuf - 3)
+	FAIL ();
+      CHK_FAIL_END
+#endif
+
+      socklen_t sl;
+      struct sockaddr_un sa_un;
+
+      sl = sizeof (sa_un);
+      if (recvfrom (sp[1], recvbuf, sizeof recvbuf, MSG_PEEK, &sa_un, &sl)
+	  != sizeof recvbuf
+	  || memcmp (recvbuf, sendstr, sizeof recvbuf) != 0)
+	FAIL ();
+
+      sl = sizeof (sa_un);
+      if (recvfrom (sp[1], recvbuf + 6, l0 + sizeof recvbuf - 7, MSG_PEEK,
+	  &sa_un, &sl) != sizeof recvbuf - 7
+	  || memcmp (recvbuf + 6, sendstr, sizeof recvbuf - 7) != 0)
+	FAIL ();
+
+#if __USE_FORTIFY_LEVEL >= 1
+      CHK_FAIL_START
+      sl = sizeof (sa_un);
+      if (recvfrom (sp[1], recvbuf + 1, sizeof recvbuf, MSG_PEEK, &sa_un, &sl)
+	  != sizeof recvbuf)
+	FAIL ();
+      CHK_FAIL_END
+
+      CHK_FAIL_START
+      sl = sizeof (sa_un);
+      if (recvfrom (sp[1], recvbuf + 4, l0 + sizeof recvbuf - 3, MSG_PEEK,
+	  &sa_un, &sl) != sizeof recvbuf - 3)
+	FAIL ();
+      CHK_FAIL_END
+#endif
+
+      close (sp[0]);
+      close (sp[1]);
+    }
+
+  char fname[] = "/tmp/tst-chk1-dir-XXXXXX\0foo";
+  char *enddir = strchr (fname, '\0');
+  if (mkdtemp (fname) == NULL)
+    {
+      printf ("mkdtemp failed: %m\n");
+      return 1;
+    }
+  *enddir = '/';
+  if (symlink ("bar", fname) != 0)
+    FAIL ();
+
+  char readlinkbuf[4];
+  if (readlink (fname, readlinkbuf, 4) != 3
+      || memcmp (readlinkbuf, "bar", 3) != 0)
+    FAIL ();
+  if (readlink (fname, readlinkbuf + 1, l0 + 3) != 3
+      || memcmp (readlinkbuf, "bbar", 4) != 0)
+    FAIL ();
+
+#if __USE_FORTIFY_LEVEL >= 1
+  CHK_FAIL_START
+  if (readlink (fname, readlinkbuf + 2, l0 + 3) != 3)
+    FAIL ();
+  CHK_FAIL_END
+
+  CHK_FAIL_START
+  if (readlink (fname, readlinkbuf + 3, 4) != 3)
+    FAIL ();
+  CHK_FAIL_END
+#endif
+
+  char *cwd1 = getcwd (NULL, 0);
+  if (cwd1 == NULL)
+    FAIL ();
+
+  char *cwd2 = getcwd (NULL, 250);
+  if (cwd2 == NULL)
+    FAIL ();
+
+  if (cwd1 && cwd2)
+    {
+      if (strcmp (cwd1, cwd2) != 0)
+	FAIL ();
+
+      *enddir = '\0';
+      if (chdir (fname))
+	FAIL ();
+
+      char *cwd3 = getcwd (NULL, 0);
+      if (cwd3 == NULL)
+	FAIL ();
+      if (strcmp (fname, cwd3) != 0)
+	printf ("getcwd after chdir is '%s' != '%s',"
+		"get{c,}wd tests skipped\n", cwd3, fname);
+      else
+	{
+	  char getcwdbuf[sizeof fname - 3];
+
+	  char *cwd4 = getcwd (getcwdbuf, sizeof getcwdbuf);
+	  if (cwd4 != getcwdbuf
+	      || strcmp (getcwdbuf, fname) != 0)
+	    FAIL ();
+
+	  cwd4 = getcwd (getcwdbuf + 1, l0 + sizeof getcwdbuf - 1);
+	  if (cwd4 != getcwdbuf + 1
+	      || getcwdbuf[0] != fname[0]
+	      || strcmp (getcwdbuf + 1, fname) != 0)
+	    FAIL ();
+
+#if __USE_FORTIFY_LEVEL >= 1
+	  CHK_FAIL_START
+	  if (getcwd (getcwdbuf + 2, l0 + sizeof getcwdbuf)
+	      != getcwdbuf + 2)
+	    FAIL ();
+	  CHK_FAIL_END
+
+	  CHK_FAIL_START
+	  if (getcwd (getcwdbuf + 2, sizeof getcwdbuf)
+	      != getcwdbuf + 2)
+	    FAIL ();
+	  CHK_FAIL_END
+#endif
+
+	  if (getwd (getcwdbuf) != getcwdbuf
+	      || strcmp (getcwdbuf, fname) != 0)
+	    FAIL ();
+
+	  if (getwd (getcwdbuf + 1) != getcwdbuf + 1
+	      || strcmp (getcwdbuf + 1, fname) != 0)
+	    FAIL ();
+
+#if __USE_FORTIFY_LEVEL >= 1
+	  CHK_FAIL_START
+	  if (getwd (getcwdbuf + 2) != getcwdbuf + 2)
+	    FAIL ();
+	  CHK_FAIL_END
+#endif
+	}
+
+      if (chdir (cwd1) != 0)
+	FAIL ();
+      free (cwd3);
+    }
+
+  free (cwd1);
+  free (cwd2);
+  *enddir = '/';
+  if (unlink (fname) != 0)
+    FAIL ();
+
+  *enddir = '\0';
+  if (rmdir (fname) != 0)
+    FAIL ();
+
+  return ret;
+}
Index: trunk/src/libctests/glibc/debug/tst-chk2.c
===================================================================
--- trunk/src/libctests/glibc/debug/tst-chk2.c	(revision 2036)
+++ trunk/src/libctests/glibc/debug/tst-chk2.c	(revision 2036)
@@ -0,0 +1,2 @@
+#define _FORTIFY_SOURCE 1
+#include "tst-chk1.c"
Index: trunk/src/libctests/glibc/debug/tst-chk3.c
===================================================================
--- trunk/src/libctests/glibc/debug/tst-chk3.c	(revision 2036)
+++ trunk/src/libctests/glibc/debug/tst-chk3.c	(revision 2036)
@@ -0,0 +1,2 @@
+#define _FORTIFY_SOURCE 2
+#include "tst-chk1.c"
Index: trunk/src/libctests/glibc/debug/tst-lfschk1.c
===================================================================
--- trunk/src/libctests/glibc/debug/tst-lfschk1.c	(revision 2036)
+++ trunk/src/libctests/glibc/debug/tst-lfschk1.c	(revision 2036)
@@ -0,0 +1,2 @@
+#define _FILE_OFFSET_BITS 64
+#include "tst-chk1.c"
Index: trunk/src/libctests/glibc/debug/tst-lfschk2.c
===================================================================
--- trunk/src/libctests/glibc/debug/tst-lfschk2.c	(revision 2036)
+++ trunk/src/libctests/glibc/debug/tst-lfschk2.c	(revision 2036)
@@ -0,0 +1,2 @@
+#define _FILE_OFFSET_BITS 64
+#include "tst-chk2.c"
Index: trunk/src/libctests/glibc/debug/tst-lfschk3.c
===================================================================
--- trunk/src/libctests/glibc/debug/tst-lfschk3.c	(revision 2036)
+++ trunk/src/libctests/glibc/debug/tst-lfschk3.c	(revision 2036)
@@ -0,0 +1,2 @@
+#define _FILE_OFFSET_BITS 64
+#include "tst-chk3.c"
Index: trunk/src/libctests/glibc/dirent/Makefile
===================================================================
--- trunk/src/libctests/glibc/dirent/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/dirent/Makefile	(revision 2036)
@@ -0,0 +1,38 @@
+# Copyright (C) 1991-2000, 2002, 2003 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Sub-makefile for dirent portion of the library.
+#
+subdir		:= dirent
+
+headers		:= dirent.h bits/dirent.h
+routines	:= opendir closedir readdir readdir_r rewinddir \
+		   seekdir telldir scandir alphasort versionsort \
+		   getdents getdents64 dirfd readdir64 readdir64_r scandir64 \
+		   alphasort64 versionsort64
+distribute := dirstream.h
+
+tests	   := list tst-seekdir opendir-tst1 bug-readdir1
+
+CFLAGS-scandir.c = $(uses-callbacks)
+CFLAGS-scandir64.c = $(uses-callbacks)
+
+include ../Rules
+
+opendir-tst1-ARGS = --test-dir=${common-objpfx}dirent
Index: trunk/src/libctests/glibc/dirent/bug-readdir1.c
===================================================================
--- trunk/src/libctests/glibc/dirent/bug-readdir1.c	(revision 2036)
+++ trunk/src/libctests/glibc/dirent/bug-readdir1.c	(revision 2036)
@@ -0,0 +1,38 @@
+#include <dirent.h>
+#include <errno.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+
+int
+main (void)
+{
+  DIR *dirp;
+  struct dirent* ent;
+
+  /* open a dir stream */
+  dirp = opendir ("/tmp");
+  if (dirp == NULL)
+    {
+      if (errno == ENOENT)
+	exit (0);
+
+      perror ("opendir");
+      exit (1);
+    }
+
+  /* close the directory file descriptor, making it invalid */
+  if (close (dirfd (dirp)) != 0)
+    {
+      puts ("could not close directory file descriptor");
+      /* This is not an error.  It is not guaranteed this is possible.  */
+      return 0;
+    }
+
+  ent = readdir (dirp);
+
+  return ent != NULL || errno != EBADF;
+}
Index: trunk/src/libctests/glibc/dirent/list.c
===================================================================
--- trunk/src/libctests/glibc/dirent/list.c	(revision 2036)
+++ trunk/src/libctests/glibc/dirent/list.c	(revision 2036)
@@ -0,0 +1,76 @@
+/* Copyright (C) 1991, 1993, 1997, 1998, 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <dirent.h>
+
+
+static int
+test (const char *name)
+{
+  DIR *dirp;
+  struct dirent *entp;
+  int retval = 0;
+
+  puts (name);
+
+  dirp = opendir (name);
+  if (dirp == NULL)
+    {
+      perror ("opendir");
+      return 1;
+    }
+
+  errno = 0;
+  while ((entp = readdir (dirp)) != NULL)
+    printf ("%s\tfile number %lu\n",
+	    entp->d_name, (unsigned long int) entp->d_fileno);
+
+  if (errno)
+    {
+      perror ("readdir");
+      retval = 1;
+    }
+
+  if (closedir (dirp) < 0)
+    {
+      perror ("closedir");
+      retval = 1;
+    }
+
+  return retval;
+}
+
+int
+main (int argc, char **argv)
+{
+  int retval = 0;
+  --argc;
+  ++argv;
+
+  if (argc == 0)
+    retval = test (".");
+  else
+    while (argc-- > 0)
+      retval |= test (*argv++);
+
+  return retval;
+}
Index: trunk/src/libctests/glibc/dirent/opendir-tst1.c
===================================================================
--- trunk/src/libctests/glibc/dirent/opendir-tst1.c	(revision 2036)
+++ trunk/src/libctests/glibc/dirent/opendir-tst1.c	(revision 2036)
@@ -0,0 +1,97 @@
+/* Copyright (C) 1998, 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/* Name of the FIFO.  */
+char tmpname[] = "fifoXXXXXX";
+
+
+/* Do the real work.  */
+static int
+real_test (void)
+{
+  DIR *dirp;
+
+  /* This should not block for an FIFO.  */
+  dirp = opendir (tmpname);
+
+  /* Successful.  */
+  if (dirp != NULL)
+    {
+      /* Oh, oh, how can this work?  */
+      fputs ("`opendir' succeeded on a FIFO???\n", stdout);
+      closedir (dirp);
+      return 1;
+    }
+
+  if (errno != ENOTDIR)
+    {
+      fprintf (stdout, "`opendir' return error `%s' instead of `%s'\n",
+	       strerror (errno), strerror (ENOTDIR));
+      return 1;
+    }
+
+  return 0;
+}
+
+
+static int
+do_test (int argc, char *argv[])
+{
+  int retval;
+
+  if (mktemp (tmpname) == NULL)
+    {
+      perror ("mktemp");
+      return 1;
+    }
+
+  /* Try to generate a FIFO.  */
+  if (mknod (tmpname, 0600 | S_IFIFO, 0) < 0)
+    {
+      perror ("mknod");
+      /* We cannot make this an error.  */
+      return 0;
+    }
+
+  retval = real_test ();
+
+  remove (tmpname);
+
+  return retval;
+}
+
+
+static void
+do_cleanup (void)
+{
+  remove (tmpname);
+}
+#define CLEANUP_HANDLER do_cleanup ()
+
+
+/* Include the test skeleton.  */
+#include <test-skeleton.c>
Index: trunk/src/libctests/glibc/dirent/tst-seekdir.c
===================================================================
--- trunk/src/libctests/glibc/dirent/tst-seekdir.c	(revision 2036)
+++ trunk/src/libctests/glibc/dirent/tst-seekdir.c	(revision 2036)
@@ -0,0 +1,78 @@
+#include <stdio.h>
+#include <dirent.h>
+#include <stdlib.h>
+
+int
+main (int argc, char *argv[])
+{
+  DIR * dirp;
+  long int save3 = 0;
+  long int cur;
+  int i = 0;
+  int result = 0;
+  struct dirent *dp;
+  long int save0;
+  long int rewind;
+
+  dirp = opendir (".");
+  if (dirp == NULL)
+    {
+      printf ("opendir failed: %m\n");
+      return 1;
+    }
+
+  save0 = telldir (dirp);
+  if (save0 == -1)
+    {
+      printf ("telldir failed: %m\n");
+      result = 1;
+    }
+
+  for (dp = readdir (dirp); dp != NULL; dp = readdir (dirp))
+    {
+      /* save position 3 (after fourth entry) */
+      if (i++ == 3)
+	save3 = telldir (dirp);
+
+      printf ("%s\n", dp->d_name);
+
+      /* stop at 400 (just to make sure dirp->__offset and dirp->__size are
+	 scrambled */
+      if (i == 400)
+	break;
+    }
+
+  printf ("going back past 4-th entry...\n");
+
+  /* go back to saved entry */
+  seekdir (dirp, save3);
+
+  /* Check whether telldir equals to save3 now.  */
+  cur = telldir (dirp);
+  if (cur != save3)
+    {
+      printf ("seekdir (d, %ld); telldir (d) == %ld\n", save3, cur);
+      result = 1;
+    }
+
+  /* print remaining files (3-last) */
+  for (dp = readdir (dirp); dp != NULL; dp = readdir (dirp))
+    printf ("%s\n", dp->d_name);
+
+  /* Check rewinddir */
+  rewinddir (dirp);
+  rewind = telldir (dirp);
+  if (rewind == -1)
+    {
+      printf ("telldir failed: %m\n");
+      result = 1;
+    }
+  else if (save0 != rewind)
+    {
+      printf ("rewinddir didn't reset directory stream\n");
+      result = 1;
+    }
+
+  closedir (dirp);
+  return result;
+}
Index: trunk/src/libctests/glibc/dlfcn/Makefile
===================================================================
--- trunk/src/libctests/glibc/dlfcn/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/dlfcn/Makefile	(revision 2036)
@@ -0,0 +1,134 @@
+# Copyright (C) 1995-2002, 2003, 2004 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+subdir		:= dlfcn
+headers		:= bits/dlfcn.h dlfcn.h
+extra-libs	:= libdl
+libdl-routines	:= dlopen dlclose dlsym dlvsym dlerror dladdr dladdr1 dlinfo \
+		   dlmopen dlfcn
+routines	:= $(patsubst %,s%,$(filter-out dlfcn,$(libdl-routines)))
+elide-routines.os := $(routines)
+distribute	:= dlopenold.c glreflib1.c glreflib2.c failtestmod.c \
+		   defaultmod1.c defaultmod2.c errmsg1mod.c modatexit.c \
+		   modcxaatexit.c modstatic.c modstatic2.c \
+		   bug-dlsym1-lib1.c bug-dlsym1-lib2.c
+
+extra-libs-others := libdl
+
+include ../Makeconfig
+
+ifeq ($(versioning),yes)
+libdl-routines	+= dlopenold
+libdl-shared-only-routines := dlopenold dlfcn
+endif
+
+ifeq (yes,$(build-shared))
+tests = glrefmain failtest tst-dladdr default errmsg1 tstcxaatexit \
+	bug-dlopen1 bug-dlsym1 tst-dlinfo
+ifeq (yes,$(have-protected))
+tests += tstatexit
+endif
+endif
+modules-names = glreflib1 glreflib2 failtestmod defaultmod1 defaultmod2 \
+		errmsg1mod modatexit modcxaatexit \
+		bug-dlsym1-lib1 bug-dlsym1-lib2
+
+failtestmod.so-no-z-defs = yes
+glreflib2.so-no-z-defs = yes
+errmsg1mod.so-no-z-defs = yes
+
+ifeq (yesyesyes,$(build-static)$(build-shared)$(elf))
+tests += tststatic tststatic2
+tests-static += tststatic tststatic2
+modules-names += modstatic modstatic2
+tststatic-ENV = LD_LIBRARY_PATH=$(objpfx):$(common-objpfx):$(common-objpfx)elf
+tststatic2-ENV = LD_LIBRARY_PATH=$(objpfx):$(common-objpfx):$(common-objpfx)elf
+endif
+
+extra-objs += $(modules-names:=.os)
+generated := $(modules-names:=.so)
+
+include ../Rules
+
+test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(modules-names)))
+$(test-modules): $(objpfx)%.so: $(objpfx)%.os $(common-objpfx)shlib.lds
+	$(build-module)
+
+ifeq ($(build-shared),yes)
+# Build all the modules even when not actually running test programs.
+tests: $(test-modules)
+endif
+
+$(objpfx)glrefmain: $(libdl)
+$(objpfx)glrefmain.out: $(objpfx)glrefmain \
+			$(objpfx)glreflib1.so $(objpfx)glreflib2.so
+
+$(objpfx)failtest: $(libdl)
+$(objpfx)failtest.out: $(objpfx)failtestmod.so
+
+$(objpfx)tst-dladdr: $(libdl)
+$(objpfx)tst-dladdr.out: $(objpfx)glreflib1.so
+
+$(objpfx)tst-dlinfo: $(libdl)
+$(objpfx)tst-dlinfo.out: $(objpfx)glreflib1.so
+
+LDFLAGS-default = $(LDFLAGS-rdynamic)
+$(objpfx)default: $(libdl) $(objpfx)defaultmod1.so $(objpfx)defaultmod2.so
+$(objpfx)defaultmod1.so: $(libdl) $(common-objpfx)libc_nonshared.a
+LDFLAGS-defaultmod2.so = $(LDFLAGS-Bsymbolic)
+$(objpfx)defaultmod2.so: $(libdl) $(common-objpfx)libc_nonshared.a
+
+$(objpfx)errmsg1: $(libdl)
+$(objpfx)errmsg1.out: $(objpfx)errmsg1 $(objpfx)errmsg1mod.so
+
+$(objpfx)tstatexit: $(libdl)
+$(objpfx)tstatexit.out: $(objpfx)tstatexit $(objpfx)modatexit.so
+
+$(objpfx)tstcxaatexit: $(libdl)
+$(objpfx)tstcxaatexit.out: $(objpfx)tstcxaatexit $(objpfx)modcxaatexit.so
+
+$(objpfx)modatexit.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a
+
+$(objpfx)tststatic: $(objpfx)libdl.a
+$(objpfx)tststatic.out: $(objpfx)tststatic $(objpfx)modstatic.so
+
+$(objpfx)tststatic2: $(objpfx)libdl.a
+$(objpfx)tststatic2.out: $(objpfx)tststatic2 $(objpfx)modstatic.so \
+			 $(objpfx)modstatic2.so
+
+$(objpfx)modstatic2.so: $(libdl) $(common-objpfx)libc.so \
+			$(common-objpfx)libc_nonshared.a
+
+$(objpfx)bug-dlopen1: $(libdl)
+
+$(objpfx)bug-dlsym1: $(libdl) $(objpfx)bug-dlsym1-lib2.so
+$(objpfx)bug-dlsym1.out: $(objpfx)bug-dlsym1-lib1.so \
+			 $(objpfx)bug-dlsym1-lib2.so
+$(objpfx)bug-dlsym1-lib1.so: $(objpfx)bug-dlsym1-lib2.so \
+			     $(common-objpfx)libc.so \
+			     $(common-objpfx)libc_nonshared.a
+$(objpfx)bug-dlsym1-lib2.so: $(common-objpfx)libc.so \
+			     $(common-objpfx)libc_nonshared.a
+
+
+
+# Depend on libc.so so a DT_NEEDED is generated in the shared objects.
+# This ensures they will load libc.so for needed symbols if loaded by
+# a statically-linked program that hasn't already loaded it.
+$(objpfx)libdl.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a \
+		   $(if $(filter yes,$(elf)), $(elfobjdir)/ld.so)
Index: trunk/src/libctests/glibc/dlfcn/bug-dlopen1.c
===================================================================
--- trunk/src/libctests/glibc/dlfcn/bug-dlopen1.c	(revision 2036)
+++ trunk/src/libctests/glibc/dlfcn/bug-dlopen1.c	(revision 2036)
@@ -0,0 +1,12 @@
+/* Test case by Bruno Haible.  It test whether the dynamic string
+   token expansion can handle $ signs which do not start one of the
+   recognized keywords.  */
+
+#include <dlfcn.h>
+
+int main (void)
+{
+  dlopen ("gnu-gettext-GetURL$1", RTLD_GLOBAL | RTLD_LAZY);
+  dlopen ("gnu-gettext-GetURL${1", RTLD_GLOBAL | RTLD_LAZY);
+  return 0;
+}
Index: trunk/src/libctests/glibc/dlfcn/bug-dlsym1-lib1.c
===================================================================
--- trunk/src/libctests/glibc/dlfcn/bug-dlsym1-lib1.c	(revision 2036)
+++ trunk/src/libctests/glibc/dlfcn/bug-dlsym1-lib1.c	(revision 2036)
@@ -0,0 +1,11 @@
+/* Test module for bug-dlsym1.c test case.  */
+
+extern int dlopen_test_variable;
+
+extern char foo (void);
+
+/* here to get the unresolved symbol in our .so */
+char foo(void)
+{
+    return dlopen_test_variable;
+}
Index: trunk/src/libctests/glibc/dlfcn/bug-dlsym1-lib2.c
===================================================================
--- trunk/src/libctests/glibc/dlfcn/bug-dlsym1-lib2.c	(revision 2036)
+++ trunk/src/libctests/glibc/dlfcn/bug-dlsym1-lib2.c	(revision 2036)
@@ -0,0 +1,3 @@
+/* Test module for bug-dlsym1.c test case.  */
+
+char dlopen_test_variable;
Index: trunk/src/libctests/glibc/dlfcn/bug-dlsym1.c
===================================================================
--- trunk/src/libctests/glibc/dlfcn/bug-dlsym1.c	(revision 2036)
+++ trunk/src/libctests/glibc/dlfcn/bug-dlsym1.c	(revision 2036)
@@ -0,0 +1,28 @@
+/* Test case for bug in dlsym accessing dependency objects' symbols.  */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <dlfcn.h>
+
+int main(void)
+{
+    void *handle;
+    char *c;
+
+    /* open lib1.so, which has the unresolved test symbol and a DT_NEEDED
+       on lib2.so, which provides the symbol */
+    if ((handle = dlopen("bug-dlsym1-lib1.so", RTLD_NOW)) == NULL) {
+	printf("dlopen(\"bug-dlsym1-lib1.so\"): %s\n", dlerror());
+	abort();
+    }
+
+    if ((c = dlsym(handle, "dlopen_test_variable")) == NULL) {
+	printf("dlsym(handle, \"dlopen_test_variable\"): %s\n", dlerror());
+	abort();
+    }
+
+    (void) dlclose(handle);
+
+    return 0;
+}
Index: trunk/src/libctests/glibc/dlfcn/failtest.c
===================================================================
--- trunk/src/libctests/glibc/dlfcn/failtest.c	(revision 2036)
+++ trunk/src/libctests/glibc/dlfcn/failtest.c	(revision 2036)
@@ -0,0 +1,60 @@
+#include <dlfcn.h>
+#include <stdio.h>
+
+
+/* Number of rounds we perform the test.  */
+#define TEST_ROUNDS	10
+
+
+static const char unknown[] = "a-file-with-this-name-does-not-exist";
+static const char exists[] = "failtestmod.so";
+
+
+int
+main (void)
+{
+  int i;
+
+  setvbuf (stdout, NULL, _IONBF, 0);
+
+  for (i = 0; i < TEST_ROUNDS; ++i)
+    {
+      void *dsc;
+
+      printf ("Round %d: Try loading \"%s\"\n", i, unknown);
+
+      dsc = dlopen (unknown, RTLD_NOW);
+      if (dsc != NULL)
+	{
+	  printf ("We found a file of name \"%s\": this should not happen\n",
+		  unknown);
+	  return 1;
+	}
+
+      printf ("Round %d: loading \"%s\" failed\n", i, unknown);
+
+      /* Don't use `dlerror', just load an existing file.  */
+      dsc = dlopen (exists, RTLD_NOW);
+      if (dsc == NULL)
+	{
+	  printf ("Could not load \"%s\": %s\n", exists, dlerror ());
+	  return 1;
+	}
+
+      printf ("Round %d: Loaded \"%s\"\n", i, exists);
+
+      dlclose (dsc);
+
+      printf ("Round %d: Unloaded \"%s\"\n", i, exists);
+    }
+
+  return 0;
+}
+
+
+extern void foo (void);
+
+void
+foo (void)
+{
+}
Index: trunk/src/libctests/glibc/dlfcn/failtestmod.c
===================================================================
--- trunk/src/libctests/glibc/dlfcn/failtestmod.c	(revision 2036)
+++ trunk/src/libctests/glibc/dlfcn/failtestmod.c	(revision 2036)
@@ -0,0 +1,26 @@
+#include <dlfcn.h>
+#include <stdio.h>
+
+
+extern void constr (void) __attribute__ ((__constructor__));
+void
+__attribute__ ((__constructor__))
+constr (void)
+{
+  void *handle;
+  void *m;
+
+  /* Open the library.  */
+  handle = dlopen (NULL, RTLD_NOW);
+  if (handle == NULL)
+    {
+      puts ("Cannot get handle to own object");
+      return;
+    }
+
+  /* Get a symbol.  */
+  m = dlsym (handle, "main");
+  puts ("called dlsym() to get main");
+
+  dlclose (handle);
+}
Index: trunk/src/libctests/glibc/dlfcn/tst-dladdr.c
===================================================================
--- trunk/src/libctests/glibc/dlfcn/tst-dladdr.c	(revision 2036)
+++ trunk/src/libctests/glibc/dlfcn/tst-dladdr.c	(revision 2036)
@@ -0,0 +1,80 @@
+/* Test for dladdr.
+   Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Volkmar Sieh <vs@caldera.de> and Andreas Jaeger <aj@suse.de>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <dlfcn.h>
+#include <errno.h>
+#include <error.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <ldsodefs.h>
+
+
+#define TEST_FUNCTION do_test ()
+extern int do_test (void);
+
+int
+do_test (void)
+{
+  void *handle;
+  int (*sym) (void); /* We load ref1 from glreflib1.c.  */
+  Dl_info info;
+  int ret;
+
+
+  handle = dlopen ("glreflib1.so", RTLD_NOW);
+  if (handle == NULL)
+    error (EXIT_FAILURE, 0, "cannot load: glreflib1.so");
+
+  sym = dlsym (handle, "ref1");
+  if (sym == NULL)
+    error (EXIT_FAILURE, 0, "dlsym failed");
+
+  memset (&info, 0, sizeof (info));
+  ret = dladdr (sym, &info);
+
+  if (ret == 0)
+    error (EXIT_FAILURE, 0, "dladdr failed");
+
+  printf ("address of ref1 = %lx\n",
+	  (unsigned long int)  DL_LOOKUP_ADDRESS (sym));
+  printf ("ret = %d\n", ret);
+  printf ("info.dli_fname = %p (\"%s\")\n", info.dli_fname, info.dli_fname);
+  printf ("info.dli_fbase = %p\n", info.dli_fbase);
+  printf ("info.dli_sname = %p (\"%s\")\n", info.dli_sname, info.dli_sname);
+  printf ("info.dli_saddr = %p\n", info.dli_saddr);
+
+  if (info.dli_fname == NULL)
+    error (EXIT_FAILURE, 0, "dli_fname is NULL");
+  if (info.dli_fbase == NULL)
+    error (EXIT_FAILURE, 0, "dli_fbase is NULL");
+  if (info.dli_sname == NULL)
+    error (EXIT_FAILURE, 0, "dli_sname is NULL");
+  if (info.dli_saddr == NULL)
+    error (EXIT_FAILURE, 0, "dli_saddr is NULL");
+
+  dlclose (handle);
+
+  return 0;
+}
+
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/dlfcn/tst-dlinfo.c
===================================================================
--- trunk/src/libctests/glibc/dlfcn/tst-dlinfo.c	(revision 2036)
+++ trunk/src/libctests/glibc/dlfcn/tst-dlinfo.c	(revision 2036)
@@ -0,0 +1,96 @@
+/* Test for dlinfo.
+   Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <error.h>
+
+#define TEST_FUNCTION do_test ()
+
+static int
+do_test (void)
+{
+  int status = 0;
+
+  void *handle = dlopen ("glreflib1.so", RTLD_NOW);
+  if (handle == NULL)
+    error (EXIT_FAILURE, 0, "cannot load: glreflib1.so: %s", dlerror ());
+
+#define TRY(req, arg)							      \
+  if (dlinfo (handle, req, arg) != 0)					      \
+    {									      \
+      printf ("dlinfo failed for %s: %s\n", #req, dlerror ());		      \
+      status = 1;							      \
+    }									      \
+  else
+
+  struct link_map *l;
+  TRY (RTLD_DI_LINKMAP, &l)
+    {
+      if (l != handle)
+	{
+	  printf ("bogus link_map? %p != %p\n", l, handle);
+	  status = 1;
+	}
+    }
+
+  char origin[8192];		/* >= PATH_MAX, in theory */
+  TRY (RTLD_DI_ORIGIN, origin)
+    {
+      printf ("origin: %s\n", origin);
+    }
+
+  Dl_serinfo counts;
+  TRY (RTLD_DI_SERINFOSIZE, &counts)
+    {
+      Dl_serinfo *buf = alloca (counts.dls_size);
+      buf->dls_cnt = counts.dls_cnt;
+      buf->dls_size = counts.dls_size;
+      printf ("%u library directories\n", buf->dls_cnt);
+      TRY (RTLD_DI_SERINFO, buf)
+	{
+	  if (counts.dls_cnt != buf->dls_cnt)
+	    {
+	      printf ("??? became %u library directories\n", buf->dls_cnt);
+	      status = 1;
+	    }
+	  for (unsigned int i = 0; i < buf->dls_cnt; ++i)
+	    printf ("\t%#02x\t%s\n",
+		    buf->dls_serpath[i].dls_flags,
+		    buf->dls_serpath[i].dls_name);
+	}
+    }
+
+  unsigned long int lmid = 0xdeadbeefUL;
+  if (dlinfo (handle, RTLD_DI_LMID, &lmid) != 0)
+    printf ("dlinfo refuses RTLD_DI_LMID: %s\n", dlerror ());
+  else
+    {
+      printf ("dlinfo RTLD_DI_LMID worked? %#lx\n", lmid);
+      status = lmid == 0xdeadbeefUL;
+    }
+
+#undef TRY
+  dlclose (handle);
+
+  return status;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/dlfcn/tstatexit.c
===================================================================
--- trunk/src/libctests/glibc/dlfcn/tstatexit.c	(revision 2036)
+++ trunk/src/libctests/glibc/dlfcn/tstatexit.c	(revision 2036)
@@ -0,0 +1,71 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+extern void *__dso_handle __attribute__ ((__weak__));
+
+int
+main (void)
+{
+  const char fname[] = "modatexit.so";
+  void *h;
+  void (*fp) (void *);
+  int v = 0;
+
+  if (&__dso_handle == NULL)
+    {
+      puts ("__dso_handle not available, cannot perform the test");
+      exit (0);
+    }
+
+  h = dlopen (fname, RTLD_NOW);
+  if (h == NULL)
+    {
+      printf ("cannot open \"%s\": %s\n", fname, dlerror ());
+      exit (1);
+    }
+
+  fp = dlsym (h, "foo");
+  if (fp == NULL)
+    {
+      printf ("cannot find \"foo\": %s\n", dlerror ());
+      exit (1);
+    }
+
+  fp (&v);
+
+  if (dlclose (h) != 0)
+    {
+      printf ("cannot close \"%s\": %s\n", fname, dlerror ());
+      exit (1);
+    }
+
+  if (v != 1)
+    {
+      puts ("module unload didn't change `v'");
+      exit (1);
+    }
+
+  puts ("finishing now");
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/dlfcn/tstcxaatexit.c
===================================================================
--- trunk/src/libctests/glibc/dlfcn/tstcxaatexit.c	(revision 2036)
+++ trunk/src/libctests/glibc/dlfcn/tstcxaatexit.c	(revision 2036)
@@ -0,0 +1,70 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+extern void *__dso_handle __attribute__ ((__weak__));
+
+int
+main (void)
+{
+  const char fname[] = "modcxaatexit.so";
+  void *h;
+  void (*fp) (void *);
+  int v = 0;
+
+  if (&__dso_handle == NULL)
+    {
+      puts ("__dso_handle not available, cannot perform the test");
+      exit (0);
+    }
+
+  h = dlopen (fname, RTLD_LAZY);
+  if (h == NULL)
+    {
+      printf ("cannot open \"%s\": %s\n", fname, dlerror ());
+      exit (1);
+    }
+
+  fp = dlsym (h, "bar");
+  if (fp == NULL)
+    {
+      printf ("cannot find \"bar\": %s\n", dlerror ());
+      exit (1);
+    }
+
+  fp (&v);
+
+  if (dlclose (h) != 0)
+    {
+      printf ("cannot close \"%s\": %s\n", fname, dlerror ());
+      exit (1);
+    }
+
+  if (v != 1)
+    {
+      puts ("module unload didn't change `v'");
+      exit (1);
+    }
+
+  puts ("finishing now");
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/dlfcn/tststatic.c
===================================================================
--- trunk/src/libctests/glibc/dlfcn/tststatic.c	(revision 2036)
+++ trunk/src/libctests/glibc/dlfcn/tststatic.c	(revision 2036)
@@ -0,0 +1,35 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main (void)
+{
+  void *handle;
+  int (*test) (int);
+  int res;
+
+  handle = dlopen ("modstatic.so", RTLD_LAZY);
+  if (handle == NULL)
+    {
+      printf ("%s\n", dlerror ());
+      exit(1);
+    }
+
+  test = dlsym (handle, "test");
+  if (test == NULL)
+    {
+      printf ("%s\n", dlerror ());
+      exit(1);
+    }
+
+  res = test (2);
+  if (res != 4)
+    {
+      printf ("Got %i, expected 4\n", res);
+      exit (1);
+    }
+
+  dlclose (handle);
+  return 0;
+}
Index: trunk/src/libctests/glibc/dlfcn/tststatic2.c
===================================================================
--- trunk/src/libctests/glibc/dlfcn/tststatic2.c	(revision 2036)
+++ trunk/src/libctests/glibc/dlfcn/tststatic2.c	(revision 2036)
@@ -0,0 +1,166 @@
+#include <dlfcn.h>
+#include <link.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <gnu/lib-names.h>
+
+int
+main (void)
+{
+  void *handle = dlopen ("modstatic2-nonexistent.so", RTLD_LAZY);
+  if (handle == NULL)
+    printf ("nonexistent: %s\n", dlerror ());
+  else
+    exit (1);
+
+  handle = dlopen ("modstatic2.so", RTLD_LAZY);
+  if (handle == NULL)
+    {
+      printf ("%s\n", dlerror ());
+      exit (1);
+    }
+
+  int (*test) (FILE *, int);
+  test = dlsym (handle, "test");
+  if (test == NULL)
+    {
+      printf ("%s\n", dlerror ());
+      exit (1);
+    }
+
+  Dl_info info;
+  int res = dladdr (test, &info);
+  if (res == 0)
+    {
+      puts ("dladdr returned 0");
+      exit (1);
+    }
+  else
+    {
+      if (strstr (info.dli_fname, "modstatic2.so") == NULL
+	  || strcmp (info.dli_sname, "test") != 0)
+	{
+	  printf ("fname %s sname %s\n", info.dli_fname, info.dli_sname);
+	  exit (1);
+	}
+      if (info.dli_saddr != (void *) test)
+	{
+	  printf ("saddr %p != test %p\n", info.dli_saddr, test);
+	  exit (1);
+	}
+    }
+
+  ElfW(Sym) *sym;
+  void *symp;
+  res = dladdr1 (test, &info, &symp, RTLD_DL_SYMENT);
+  if (res == 0)
+    {
+      puts ("dladdr1 returned 0");
+      exit (1);
+    }
+  else
+    {
+      if (strstr (info.dli_fname, "modstatic2.so") == NULL
+	  || strcmp (info.dli_sname, "test") != 0)
+	{
+	  printf ("fname %s sname %s\n", info.dli_fname, info.dli_sname);
+	  exit (1);
+	}
+      if (info.dli_saddr != (void *) test)
+	{
+	  printf ("saddr %p != test %p\n", info.dli_saddr, test);
+	  exit (1);
+	}
+      sym = symp;
+      if (sym == NULL)
+	{
+	  puts ("sym == NULL\n");
+	  exit (1);
+	}
+      if (ELF32_ST_BIND (sym->st_info) != STB_GLOBAL
+	  || ELF32_ST_VISIBILITY (sym->st_other) != STV_DEFAULT)
+	{
+	  printf ("bind %d visibility %d\n",
+		  (int) ELF32_ST_BIND (sym->st_info),
+		  (int) ELF32_ST_VISIBILITY (sym->st_other));
+	  exit (1);
+	}
+    }
+
+  Lmid_t lmid;
+  res = dlinfo (handle, RTLD_DI_LMID, &lmid);
+  if (res != 0)
+    {
+      printf ("dlinfo returned %d %s\n", res, dlerror ());
+      exit (1);
+    }
+  else if (lmid != LM_ID_BASE)
+    {
+      printf ("lmid %d != %d\n", (int) lmid, (int) LM_ID_BASE);
+      exit (1);
+    }
+
+  res = test (stdout, 2);
+  if (res != 4)
+    {
+      printf ("Got %i, expected 4\n", res);
+      exit (1);
+    }
+
+  void *handle2 = dlopen (LIBDL_SO, RTLD_LAZY);
+  if (handle2 == NULL)
+    {
+      printf ("libdl.so: %s\n", dlerror ());
+      exit (1);
+    }
+
+#ifdef DO_VERSIONING
+  if (dlvsym (handle2, "_dlfcn_hook", "GLIBC_PRIVATE") == NULL)
+    {
+      printf ("dlvsym: %s\n", dlerror ());
+      exit (1);
+    }
+#endif
+
+  void *(*dlsymfn) (void *, const char *);
+  dlsymfn = dlsym (handle2, "dlsym");
+  if (dlsymfn == NULL)
+    {
+      printf ("dlsym \"dlsym\": %s\n", dlerror ());
+      exit (1);
+    }
+  void *test2 = dlsymfn (handle, "test");
+  if (test2 == NULL)
+    {
+      printf ("%s\n", dlerror ());
+      exit (1);
+    }
+  else if (test2 != (void *) test)
+    {
+      printf ("test %p != test2 %p\n", test, test2);
+      exit (1);
+    }
+
+  dlclose (handle2);
+  dlclose (handle);
+
+  handle = dlmopen (LM_ID_BASE, "modstatic2.so", RTLD_LAZY);
+  if (handle == NULL)
+    {
+      printf ("%s\n", dlerror ());
+      exit (1);
+    }
+  dlclose (handle);
+
+  handle = dlmopen (LM_ID_NEWLM, "modstatic2.so", RTLD_LAZY);
+  if (handle == NULL)
+    printf ("LM_ID_NEWLM: %s\n", dlerror ());
+  else
+    {
+      puts ("LM_ID_NEWLM unexpectedly succeeded");
+      exit (1);
+    }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/elf/Makefile
===================================================================
--- trunk/src/libctests/glibc/elf/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/elf/Makefile	(revision 2036)
@@ -0,0 +1,845 @@
+# Copyright (C) 1995-2004, 2005 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+# Makefile for elf subdirectory of GNU C Library.
+
+subdir		:= elf
+
+headers		= elf.h bits/elfclass.h link.h bits/link.h
+routines	= $(dl-routines) dl-support dl-iteratephdr \
+		  dl-addr enbl-secure dl-profstub \
+		  dl-origin dl-libc dl-sym dl-tsd
+
+# The core dynamic linking functions are in libc for the static and
+# profiled libraries.
+dl-routines	= $(addprefix dl-,load cache lookup object reloc deps \
+			          runtime error init fini debug misc \
+				  version profile conflict tls origin \
+				  execstack caller open close trampoline)
+all-dl-routines = $(dl-routines) $(sysdep-dl-routines)
+# But they are absent from the shared libc, because that code is in ld.so.
+elide-routines.os = $(all-dl-routines) dl-support enbl-secure dl-origin
+shared-only-routines += dl-caller
+
+# ld.so uses those routines, plus some special stuff for being the program
+# interpreter and operating independent of libc.
+rtld-routines	:= rtld $(dl-routines) dl-sysdep dl-environ dl-minimal
+all-rtld-routines = $(rtld-routines) $(sysdep-rtld-routines)
+
+distribute	:= rtld-Rules \
+		   $(rtld-routines:=.c) dynamic-link.h do-rel.h dl-machine.h \
+		   dl-cache.h dl-hash.h soinit.c sofini.c ldd.bash.in \
+		   genrtldtbl.awk atomicity.h dl-procinfo.h ldsodefs.h \
+		   dl-librecon.h interp.c sln.c dl-dst.h hp-timing.h \
+		   do-lookup.h dl-lookupcfg.h sprof.c gen-trusted-dirs.awk \
+		   testobj1.c testobj2.c testobj3.c testobj4.c testobj5.c \
+		   testobj6.c testobj1_1.c failobj.c unloadmod.c \
+		   ldconfig.h ldconfig.c cache.c readlib.c readelflib.c \
+		   chroot_canon.c gccframe.h \
+		   dep1.c dep2.c dep3.c dep4.c dl-dtprocnum.h unsecvars.h \
+		   vismain.c vismod1.c vismod2.c vismod3.c \
+		   constload2.c constload3.c filtmod1.c filtmod2.c \
+		   nodlopenmod.c nodelete.c nodelmod1.c nodelmod2.c \
+		   nodelmod3.c nodelmod4.c nodlopen.c dl-osinfo.h \
+		   reldepmod1.c reldepmod2.c reldepmod3.c reldepmod4.c \
+		   reldepmod5.c reldepmod6.c \
+		   reldep4mod1.c reldep4mod2.c reldep4mod3.c reldep4mod4.c \
+		   nextmod1.c nextmod2.c pathoptobj.c tst-pathopt.sh \
+		   neededobj1.c neededobj2.c neededobj3.c neededobj4.c \
+		   neededobj5.c neededobj6.c firstobj.c \
+		   unload2mod.c unload2dep.c ltglobmod1.c ltglobmod2.c \
+		   testobj.h vismod.h globalmod1.c \
+		   dblloadmod1.c dblloadmod2.c dblloadmod3.c \
+		   reldep6mod4.c reldep6mod3.c reldep6mod2.c reldep6mod1.c \
+		   reldep6mod0.c reldep7mod1.c reldep7mod2.c \
+		   unwind-dw2.c unwind-dw2-fde.c unwind.h unwind-pe.h \
+		   unwind-dw2-fde.h dwarf2.h dl-procinfo.c tls.h dl-tls.h \
+		   tst-tlsmod1.c tst-tlsmod2.c tst-tlsmod3.c tst-tlsmod4.c \
+		   tst-tlsmod5.c tst-tlsmod6.c tst-tlsmod7.c tst-tlsmod8.c \
+		   tst-tlsmod9.c tst-tlsmod10.c tst-tlsmod11.c \
+		   tst-tlsmod12.c tst-tls10.h tst-alignmod.c tst-alignmod2.c \
+		   circlemod1.c circlemod1a.c circlemod2.c circlemod2a.c \
+		   circlemod3.c circlemod3a.c nodlopenmod2.c \
+		   tls-macros.h \
+		   reldep8mod1.c reldep8mod2.c reldep8mod3.c \
+		   nodel2mod1.c nodel2mod2.c nodel2mod3.c \
+		   reldep9.c reldep9mod1.c reldep9mod2.c reldep9mod3.c \
+		   tst-array1.exp tst-array2.exp tst-array4.exp \
+		   tst-array2dep.c tst-piemod1.c \
+		   tst-execstack-mod.c tst-dlmodcount.c \
+		   check-textrel.c dl-sysdep.h test-dlopenrpathmod.c \
+		   tst-deep1mod1.c tst-deep1mod2.c tst-deep1mod3.c \
+		   unload3mod1.c unload3mod2.c unload3mod3.c unload3mod4.c \
+		   unload4mod1.c unload4mod2.c unload4mod3.c unload4mod4.c \
+		   unload6mod1.c unload6mod2.c unload6mod3.c tst-auditmod1.c \
+		   order2mod1.c order2mod2.c order2mod3.c order2mod4.c
+
+CFLAGS-dl-runtime.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-dl-lookup.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-dl-iterate-phdr.c = $(uses-callbacks)
+
+include ../Makeconfig
+
+ifeq ($(unwind-find-fde),yes)
+routines += unwind-dw2-fde-glibc
+shared-only-routines += unwind-dw2-fde-glibc
+endif
+
+before-compile  = $(objpfx)trusted-dirs.h
+generated	:= trusted-dirs.h trusted-dirs.st for-renamed/renamed.so
+generated-dirs	:= for-renamed
+
+ifeq ($(versioning),yes)
+ld-map		= $(common-objpfx)ld.map
+endif
+
+ifeq (yes,$(build-shared))
+extra-objs	= $(all-rtld-routines:%=%.os) soinit.os sofini.os interp.os
+generated	+= librtld.os dl-allobjs.os ld.so ldd
+install-others	= $(inst_slibdir)/$(rtld-installed-name)
+install-bin-script = ldd
+endif
+
+others		= sprof sln
+install-bin	= sprof
+others-static   = sln
+install-rootsbin = sln
+
+ifeq (yes,$(use-ldconfig))
+ifeq (yes,$(build-shared))
+others-static	+= ldconfig
+others		+= ldconfig
+install-rootsbin += ldconfig
+
+ldconfig-modules := cache readlib xmalloc xstrdup chroot_canon
+extra-objs	+= $(ldconfig-modules:=.o)
+
+# To find xmalloc.c and xstrdup.c
+vpath %.c ../locale/programs
+
+endif
+endif
+
+tests = tst-tls1 tst-tls2 tst-tls9
+ifeq (yes,$(have-initfini-array))
+tests += tst-array1 tst-array2 tst-array3 tst-array4
+endif
+ifeq (yes,$(build-static))
+tests-static = tst-tls1-static tst-tls2-static
+ifeq (yesyesyes,$(build-static)$(build-shared)$(elf))
+tests-static += tst-tls9-static
+tst-tls9-static-ENV = \
+       LD_LIBRARY_PATH=$(objpfx):$(common-objpfx):$(common-objpfx)dlfcn
+endif
+ifeq (yes,$(have-initfini-array))
+tests-static += tst-array1-static
+endif
+tests += $(tests-static)
+endif
+ifeq (yes,$(build-shared))
+tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
+	 constload1 order $(tests-vis-$(have-protected)) noload filter unload \
+	 reldep reldep2 reldep3 reldep4 $(tests-nodelete-$(have-z-nodelete)) \
+	 $(tests-nodlopen-$(have-z-nodlopen)) neededtest neededtest2 \
+	 neededtest3 neededtest4 unload2 lateglobal initfirst global \
+	 restest2 next dblload dblunload reldep5 reldep6 reldep7 reldep8 \
+	 circleload1 tst-tls3 tst-tls4 tst-tls5 tst-tls6 tst-tls7 tst-tls8 \
+	 tst-tls10 tst-tls11 tst-tls12 tst-tls13 tst-tls14 tst-tls15 tst-align \
+	 tst-align2 $(tests-execstack-$(have-z-execstack)) tst-dlmodcount \
+	 tst-dlopenrpath tst-deep1 tst-dlmopen1 tst-dlmopen2 tst-dlmopen3 \
+	 unload3 unload4 unload5 unload6 tst-audit1 tst-global1 order2
+#	 reldep9
+test-srcs = tst-pathopt
+tests-vis-yes = vismain
+tests-nodelete-yes = nodelete nodelete2
+tests-nodlopen-yes = nodlopen nodlopen2
+tests-execstack-yes = tst-execstack tst-execstack-needed tst-execstack-prog
+endif
+ifeq (yesyes,$(have-fpie)$(build-shared))
+tests: $(objpfx)tst-pie1.out
+endif
+modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
+		testobj1_1 failobj constload2 constload3 unloadmod \
+		dep1 dep2 dep3 dep4 $(modules-vis-$(have-protected)) \
+		$(modules-nodelete-$(have-z-nodelete)) \
+		$(modules-nodlopen-$(have-z-nodlopen)) filtmod1 filtmod2 \
+		reldepmod1 reldepmod2 reldepmod3 reldepmod4 nextmod1 nextmod2 \
+		reldep4mod1 reldep4mod2 reldep4mod3 reldep4mod4 \
+		neededobj1 neededobj2 neededobj3 neededobj4 \
+		neededobj5 neededobj6 firstobj globalmod1 \
+		unload2mod unload2dep ltglobmod1 ltglobmod2 pathoptobj \
+		dblloadmod1 dblloadmod2 dblloadmod3 reldepmod5 reldepmod6 \
+	        reldep6mod0 reldep6mod1 reldep6mod2 reldep6mod3 reldep6mod4 \
+		reldep7mod1 reldep7mod2 \
+		tst-tlsmod1 tst-tlsmod2 tst-tlsmod3 tst-tlsmod4 \
+		tst-tlsmod5 tst-tlsmod6 tst-tlsmod7 tst-tlsmod8 \
+		tst-tlsmod9 tst-tlsmod10 tst-tlsmod11 tst-tlsmod12 \
+		tst-tlsmod13 tst-tlsmod13a tst-tlsmod14a tst-tlsmod14b \
+		tst-tlsmod15a tst-tlsmod15b \
+		circlemod1 circlemod1a circlemod2 circlemod2a \
+		circlemod3 circlemod3a \
+		reldep8mod1 reldep8mod2 reldep8mod3 \
+		reldep9mod1 reldep9mod2 reldep9mod3 \
+		tst-alignmod tst-alignmod2 \
+		$(modules-execstack-$(have-z-execstack)) \
+		tst-dlopenrpathmod tst-deep1mod1 tst-deep1mod2 tst-deep1mod3 \
+		tst-dlmopen1mod tst-auditmod1 \
+		unload3mod1 unload3mod2 unload3mod3 unload3mod4 \
+		unload4mod1 unload4mod2 unload4mod3 unload4mod4 \
+		unload6mod1 unload6mod2 unload6mod3 \
+		order2mod1 order2mod2 order2mod3 order2mod4
+ifeq (yes,$(have-initfini-array))
+modules-names += tst-array2dep
+endif
+ifeq (yesyes,$(have-fpie)$(build-shared))
+modules-names += tst-piemod1
+endif
+modules-vis-yes = vismod1 vismod2 vismod3
+modules-nodelete-yes = nodelmod1 nodelmod2 nodelmod3 nodelmod4 \
+		       nodel2mod1 nodel2mod2 nodel2mod3
+modules-nodlopen-yes = nodlopenmod nodlopenmod2
+modules-execstack-yes = tst-execstack-mod
+extra-objs += $(addsuffix .os,$(strip $(modules-names)))
+# We need this variable to be sure the test modules get the right CPPFLAGS.
+test-extras += $(modules-names)
+
+include ../Rules
+
+check-abi: check-abi-ld
+update-abi: update-abi-ld
+
+ifeq (yes,$(build-shared))
+# Make sure these things are built in the `make lib' pass so they can be used
+# to run programs during the `make others' pass.
+lib-noranlib: $(objpfx)$(rtld-installed-name) \
+	      $(addprefix $(objpfx),$(extra-objs))
+endif
+
+# Command to link into a larger single relocatable object.
+reloc-link = $(LINK.o) -nostdlib -nostartfiles -r
+
+$(objpfx)dl-allobjs.os: $(all-rtld-routines:%=$(objpfx)%.os)
+	$(reloc-link) -o $@ $^
+
+# Link together the dynamic linker into a single relocatable object.
+# First we do a link against libc_pic.a just to get a link map,
+# and discard the object produced by that link.  From the link map
+# we can glean all the libc modules that need to go into the dynamic
+# linker.  Then we do a recursive make that goes into all the subdirs
+# those modules come from and builds special rtld-foo.os versions that
+# are compiled with special flags, and puts these modules into rtld-libc.a
+# for us.  Then we do the real link using rtld-libc.a instead of libc_pic.a.
+
+$(objpfx)librtld.map: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a
+	@-rm -f $@T
+	$(reloc-link) -o $@.o '-Wl,-(' $^ -lgcc '-Wl,-)' -Wl,-Map,$@T
+	rm -f $@.o
+	mv -f $@T $@
+
+$(objpfx)librtld.mk: $(objpfx)librtld.map Makefile
+	LC_ALL=C \
+	sed -n 's@^$(common-objpfx)\([^(]*\)(\([^)]*\.os\)) *.*$$@\1 \2@p' \
+	    $< | \
+	while read lib file; do \
+	  case $$lib in \
+	  libc_pic.a) \
+	    LC_ALL=C fgrep -l /$$file \
+		  $(common-objpfx)stamp.os $(common-objpfx)*/stamp.os | \
+	    LC_ALL=C \
+	    sed 's@^$(common-objpfx)\([^/]*\)/stamp\.os$$@rtld-\1'" +=$$file@"\
+	    ;; \
+	  */*.a) \
+	    echo rtld-$${lib%%/*} += $$file ;; \
+	  *) echo "Wasn't expecting $$lib($$file)" >&2; exit 1 ;; \
+	  esac; \
+	done > $@T
+	echo rtld-subdirs = `LC_ALL=C sed 's/^rtld-\([^ ]*\).*$$/\1/' $@T \
+			     | LC_ALL=C sort -u` >> $@T
+	mv -f $@T $@
+
+$(objpfx)rtld-libc.a: $(objpfx)librtld.mk FORCE
+	$(MAKE) -f $< -f rtld-Rules
+
+$(objpfx)librtld.os: $(objpfx)dl-allobjs.os $(objpfx)rtld-libc.a
+	$(LINK.o) -nostdlib -nostartfiles -r -o $@ '-Wl,-(' $^ -lgcc '-Wl,-)' \
+		  -Wl,-Map,$@.map
+
+generated += librtld.map librtld.mk rtld-libc.a librtld.os.map
+
+z-now-yes = -Wl,-z,now
+
+$(objpfx)ld.so: $(objpfx)librtld.os $(ld-map)
+	@rm -f $@.lds
+	$(LINK.o) -nostdlib -nostartfiles -shared $(z-now-$(bind-now))	\
+		  $(LDFLAGS-rtld) -Wl,-z,defs -Wl,--verbose 2>&1 |	\
+		  LC_ALL=C \
+		  sed -e '/^=========/,/^=========/!d;/^=========/d'	\
+		      -e 's/\. = 0 + SIZEOF_HEADERS;/& _begin = . - SIZEOF_HEADERS;/' \
+		  > $@.lds
+	$(LINK.o) -nostdlib -nostartfiles -shared -o $@			\
+		  $(LDFLAGS-rtld) -Wl,-z,defs $(z-now-$(bind-now))	\
+		  $(filter-out $(map-file),$^) $(load-map-file)		\
+		  -Wl,-soname=$(rtld-installed-name) -T $@.lds
+	rm -f $@.lds
+
+# interp.c exists just to get this string into the libraries.
+CFLAGS-interp.c = -D'RUNTIME_LINKER="$(slibdir)/$(rtld-installed-name)"' \
+		  -DNOT_IN_libc=1
+$(objpfx)interp.os: $(common-objpfx)config.make
+
+ifneq (ld.so,$(rtld-installed-name))
+# Make sure ld.so.1 exists in the build directory so we can link
+# against it.
+$(objpfx)$(rtld-installed-name): $(objpfx)ld.so
+	rm -f $@
+	ln -s $(<F) $@
+generated += $(rtld-installed-name)
+endif
+
+# Build a file mentioning all trustworthy directories to look for shared
+# libraries when using LD_LIBRARY_PATH in a setuid program.  The user can
+# add directories to the list by defining $(user-defined-trusted-dirs)
+# before starting make.
+$(objpfx)trusted-dirs.h: $(objpfx)trusted-dirs.st; @:
+$(objpfx)trusted-dirs.st: Makefile $(..)Makeconfig
+	$(make-target-directory)
+	echo "$(subst :, ,$(default-rpath) $(user-defined-trusted-dirs))"    \
+	| $(AWK) -f gen-trusted-dirs.awk > ${@:st=T};
+	echo '#define DL_DST_LIB "$(notdir $(slibdir))"' >> ${@:st=T}
+	$(move-if-change) ${@:st=T} ${@:st=h}
+	touch $@
+CPPFLAGS-dl-load.c = -I$(objpfx). -I$(csu-objpfx).
+
+ifeq (yes,$(build-shared))
+$(inst_slibdir)/$(rtld-version-installed-name): $(objpfx)ld.so $(+force)
+	$(make-target-directory)
+	$(do-install-program)
+
+$(inst_slibdir)/$(rtld-installed-name): \
+  $(inst_slibdir)/$(rtld-version-installed-name) \
+  $(inst_slibdir)/libc-$(version).so
+	$(make-shlib-link)
+
+# Special target called by parent to install just the dynamic linker.
+.PHONY: ldso_install
+ldso_install: $(inst_slibdir)/$(rtld-installed-name)
+endif
+
+
+common-ldd-rewrite = -e 's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
+		     -e 's%@VERSION@%$(version)%g'
+sh-ldd-rewrite = $(common-ldd-rewrite) -e 's%@BASH@%/bin/sh%g;s/\$$"/"/g'
+bash-ldd-rewrite = $(common-ldd-rewrite) -e 's%@BASH@%$(BASH)%g' \
+		   -e 's%@TEXTDOMAINDIR@%$(msgcatdir)%g'
+
+ifneq ($(have-bash2),yes)
+ldd-shell = sh
+else
+ldd-shell = bash
+endif
+
+ifeq ($(ldd-rewrite-script),no)
+define gen-ldd
+LC_ALL=C sed $($(ldd-shell)-ldd-rewrite) < $< > $@.new
+endef
+else
+define gen-ldd
+LC_ALL=C sed $($(ldd-shell)-ldd-rewrite) < $< | LC_ALL=C sed -f $(ldd-rewrite-script) > $@.new
+endef
+endif
+
+$(objpfx)ldd: ldd.bash.in $(common-objpfx)soversions.mk \
+	      $(common-objpfx)config.make
+	$(gen-ldd)
+	chmod 555 $@.new
+	mv -f $@.new $@
+
+$(objpfx)sprof: $(libdl)
+
+$(objpfx)ldconfig: $(ldconfig-modules:%=$(objpfx)%.o)
+SYSCONF-FLAGS := -D'SYSCONFDIR="$(sysconfdir)"'
+CFLAGS-ldconfig.c = $(SYSCONF-FLAGS) -D'LIBDIR="$(libdir)"' \
+		    -D'SLIBDIR="$(slibdir)"' -DIS_IN_ldconfig=1
+CFLAGS-dl-cache.c = $(SYSCONF-FLAGS)
+CFLAGS-cache.c = $(SYSCONF-FLAGS)
+
+CPPFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),-DNOT_IN_libc=1 -DIS_IN_rtld=1)
+
+test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(strip $(modules-names))))
+generated += $(addsuffix .so,$(strip $(modules-names)))
+
+ifeq (yes,$(build-shared))
+ifeq ($(cross-compiling),no)
+tests: $(objpfx)tst-pathopt.out
+endif
+endif
+
+$(objpfx)testobj1.so: $(libdl)
+$(objpfx)testobj1_1.so: $(objpfx)testobj1.so $(libdl)
+$(objpfx)testobj2.so: $(objpfx)testobj1.so $(libdl)
+$(objpfx)testobj3.so: $(libdl)
+$(objpfx)testobj4.so: $(libdl)
+$(objpfx)testobj5.so: $(libdl)
+$(objpfx)testobj6.so: $(objpfx)testobj1.so $(objpfx)testobj2.so $(libdl)
+$(objpfx)failobj.so: $(objpfx)testobj6.so
+$(objpfx)dep1.so: $(objpfx)dep2.so $(objpfx)dep4.so
+$(objpfx)dep2.so: $(objpfx)dep3.so $(objpfx)dep4.so
+$(objpfx)dep4.so: $(objpfx)dep3.so
+$(objpfx)nodelmod3.so: $(objpfx)nodelmod4.so
+$(objpfx)nextmod1.so: $(libdl)
+$(objpfx)neededobj1.so: $(libdl)
+$(objpfx)neededobj2.so: $(objpfx)neededobj1.so $(libdl)
+$(objpfx)neededobj3.so: $(objpfx)neededobj1.so $(objpfx)neededobj2.so $(libdl)
+$(objpfx)neededobj4.so: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
+			$(objpfx)neededobj3.so $(libdl)
+$(objpfx)neededobj6.so: $(objpfx)neededobj5.so
+$(objpfx)unload2mod.so: $(objpfx)unload2dep.so
+$(objpfx)ltglobmod2.so: $(libdl)
+$(objpfx)firstobj.so: $(shared-thread-library)
+$(objpfx)globalmod1.so: $(libdl)
+$(objpfx)reldep4mod1.so: $(objpfx)reldep4mod3.so
+$(objpfx)reldep4mod2.so: $(objpfx)reldep4mod4.so
+$(objpfx)dblloadmod1.so: $(objpfx)dblloadmod3.so
+$(objpfx)dblloadmod2.so: $(objpfx)dblloadmod3.so
+$(objpfx)reldepmod5.so: $(objpfx)reldepmod2.so
+$(objpfx)reldepmod6.so: $(objpfx)reldepmod2.so
+$(objpfx)reldep6mod1.so: $(objpfx)reldep6mod0.so
+$(objpfx)reldep6mod2.so: $(objpfx)reldep6mod1.so
+$(objpfx)reldep6mod3.so: $(objpfx)reldep6mod2.so
+$(objpfx)reldep6mod4.so: $(objpfx)reldep6mod1.so
+$(objpfx)tst-tlsmod3.so: $(objpfx)tst-tlsmod2.so
+$(objpfx)tst-tlsmod8.so: $(objpfx)tst-tlsmod7.so
+$(objpfx)tst-tlsmod10.so: $(objpfx)tst-tlsmod9.so
+$(objpfx)tst-tlsmod12.so: $(objpfx)tst-tlsmod11.so
+$(objpfx)tst-tlsmod13a.so: $(objpfx)tst-tlsmod13.so
+# For tst-tls9-static, make sure the modules it dlopens have libc.so in DT_NEEDED
+$(objpfx)tst-tlsmod5.so: $(common-objpfx)libc.so
+$(objpfx)tst-tlsmod6.so: $(common-objpfx)libc.so
+$(objpfx)reldep8mod3.so: $(objpfx)reldep8mod1.so $(objpfx)reldep8mod2.so
+$(objpfx)nodel2mod3.so: $(objpfx)nodel2mod1.so $(objpfx)nodel2mod2.so
+$(objpfx)reldep9mod2.so: $(objpfx)reldep9mod1.so
+$(objpfx)reldep9mod3.so: $(objpfx)reldep9mod1.so $(objpfx)reldep9mod2.so
+$(objpfx)unload3mod1.so: $(objpfx)unload3mod3.so
+$(objpfx)unload3mod2.so: $(objpfx)unload3mod3.so
+$(objpfx)unload3mod3.so: $(objpfx)unload3mod4.so
+$(objpfx)unload4mod1.so: $(objpfx)unload4mod2.so $(objpfx)unload4mod3.so
+$(objpfx)unload4mod2.so: $(objpfx)unload4mod4.so $(objpfx)unload4mod3.so
+$(objpfx)unload6mod1.so: $(libdl)
+$(objpfx)unload6mod2.so: $(libdl)
+$(objpfx)unload6mod3.so: $(libdl)
+
+LDFLAGS-tst-tlsmod5.so = -nostdlib
+LDFLAGS-tst-tlsmod6.so = -nostdlib
+
+testobj1.so-no-z-defs = yes
+testobj3.so-no-z-defs = yes
+testobj4.so-no-z-defs = yes
+testobj5.so-no-z-defs = yes
+testobj6.so-no-z-defs = yes
+failobj.so-no-z-defs = yes
+constload2.so-no-z-defs = yes
+constload3.so-no-z-defs = yes
+nodelmod1.so-no-z-defs = yes
+nodelmod2.so-no-z-defs = yes
+nodelmod4.so-no-z-defs = yes
+nodel2mod2.so-no-z-defs = yes
+reldepmod2.so-no-z-defs = yes
+reldepmod3.so-no-z-defs = yes
+reldepmod4.so-no-z-defs = yes
+reldep4mod4.so-no-z-defs = yes
+reldep4mod2.so-no-z-defs = yes
+ltglobmod2.so-no-z-defs = yes
+dblloadmod3.so-no-z-defs = yes
+tst-tlsmod1.so-no-z-defs = yes
+tst-tlsmod2.so-no-z-defs = yes
+tst-tlsmod3.so-no-z-defs = yes
+tst-tlsmod4.so-no-z-defs = yes
+tst-tlsmod7.so-no-z-defs = yes
+tst-tlsmod8.so-no-z-defs = yes
+tst-tlsmod9.so-no-z-defs = yes
+tst-tlsmod10.so-no-z-defs = yes
+tst-tlsmod12.so-no-z-defs = yes
+tst-tlsmod14a.so-no-z-defs = yes
+tst-tlsmod14b.so-no-z-defs = yes
+tst-tlsmod15a.so-no-z-defs = yes
+circlemod2.so-no-z-defs = yes
+circlemod3.so-no-z-defs = yes
+circlemod3a.so-no-z-defs = yes
+reldep8mod2.so-no-z-defs = yes
+reldep9mod1.so-no-z-defs = yes
+unload3mod4.so-no-z-defs = yes
+unload4mod1.so-no-z-defs = yes
+
+# filtmod1.so has a special rule
+$(filter-out $(objpfx)filtmod1.so, $(test-modules)): $(objpfx)%.so: $(objpfx)%.os
+	$(build-module)
+
+ifeq ($(build-shared),yes)
+# Build all the modules even when not actually running test programs.
+tests: $(test-modules)
+endif
+
+$(objpfx)loadtest: $(libdl)
+LDFLAGS-loadtest = -rdynamic
+
+$(objpfx)loadtest.out: $(test-modules)
+
+$(objpfx)neededtest: $(libdl)
+$(objpfx)neededtest.out: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
+			 $(objpfx)neededobj3.so
+
+$(objpfx)neededtest2: $(libdl)
+$(objpfx)neededtest2.out: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
+			  $(objpfx)neededobj3.so
+
+$(objpfx)neededtest3: $(libdl)
+$(objpfx)neededtest3.out: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
+			  $(objpfx)neededobj3.so $(objpfx)neededobj4.so
+
+neededtest4-ENV = LC_ALL=C LANGUAGE=C
+$(objpfx)neededtest4: $(libdl) $(objpfx)neededobj1.so
+$(objpfx)neededtest4.out: $(objpfx)neededobj5.so $(objpfx)neededobj6.so
+
+$(objpfx)restest1: $(objpfx)testobj1.so $(objpfx)testobj1_1.so $(libdl)
+LDFLAGS-restest1 = -rdynamic
+
+$(objpfx)restest2: $(libdl)
+LDFLAGS-restest2 = -rdynamic
+
+$(objpfx)restest1.out: $(test-modules)
+
+preloadtest-preloads = testobj1 testobj2 testobj3 testobj4 testobj5
+$(objpfx)preloadtest: $(objpfx)testobj6.so
+LDFLAGS-preloadtest = -rdynamic
+$(objpfx)preloadtest.out: $(preloadtest-preloads:%=$(objpfx)%.so)
+preloadtest-ENV = \
+  LD_PRELOAD=$(subst $(empty) ,:,$(strip $(preloadtest-preloads:=.so)))
+
+$(objpfx)loadfail: $(libdl)
+LDFLAGS-loadfail = -rdynamic
+
+$(objpfx)loadfail.out: $(objpfx)failobj.so
+
+$(objpfx)multiload: $(libdl)
+LDFLAGS-multiload = -rdynamic
+CFLAGS-multiload.c = -DOBJDIR=\"$(elf-objpfx)\"
+
+$(objpfx)multiload.out: $(objpfx)testobj1.so
+
+$(objpfx)origtest: $(libdl)
+LDFLAGS-origtest = -rdynamic
+$(objpfx)origtest.out: $(objpfx)testobj1.so
+
+ifeq ($(have-thread-library),yes)
+$(objpfx)resolvfail: $(libdl) $(shared-thread-library)
+else
+$(objpfx)resolvfail: $(libdl)
+endif
+
+$(objpfx)constload1: $(libdl)
+$(objpfx)constload1.out: $(objpfx)constload2.so $(objpfx)constload3.so
+
+$(objpfx)circleload1: $(libdl)
+$(objpfx)circleload1.out: $(objpfx)circlemod1.so \
+			  $(objpfx)circlemod1a.so
+
+$(objpfx)circlemod1.so: $(objpfx)circlemod2.so
+$(objpfx)circlemod2.so: $(objpfx)circlemod3.so
+$(objpfx)circlemod1a.so: $(objpfx)circlemod2a.so
+$(objpfx)circlemod2a.so: $(objpfx)circlemod3a.so
+
+$(objpfx)order: $(addprefix $(objpfx),dep4.so dep3.so dep2.so dep1.so)
+
+$(objpfx)order.out: $(objpfx)order
+	$(elf-objpfx)$(rtld-installed-name) \
+	  --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
+	  $(objpfx)order > $@
+	(echo "0123456789" | cmp $@ -) > /dev/null
+
+$(objpfx)vismain: $(addprefix $(objpfx),vismod1.so vismod2.so)
+$(objpfx)vismain.out: $(addprefix $(objpfx),vismod3.so)
+vismain-ENV = LD_PRELOAD=$(addprefix $(objpfx),vismod3.so)
+
+$(objpfx)noload: $(objpfx)testobj1.so
+LDFLAGS-noload = -rdynamic
+$(objpfx)noload.out: $(objpfx)testobj5.so
+
+LDFLAGS-nodelete = -rdynamic
+LDFLAGS-nodelmod1.so = -Wl,--enable-new-dtags,-z,nodelete
+LDFLAGS-nodelmod4.so = -Wl,--enable-new-dtags,-z,nodelete
+$(objpfx)nodelete: $(libdl)
+$(objpfx)nodelete.out: $(objpfx)nodelmod1.so $(objpfx)nodelmod2.so \
+		       $(objpfx)nodelmod3.so
+
+LDFLAGS-nodlopenmod.so = -Wl,--enable-new-dtags,-z,nodlopen
+$(objpfx)nodlopen: $(libdl)
+$(objpfx)nodlopen.out: $(objpfx)nodlopenmod.so
+
+$(objpfx)nodlopenmod2.so: $(objpfx)nodlopenmod.so
+$(objpfx)nodlopen2: $(libdl)
+$(objpfx)nodlopen2.out: $(objpfx)nodlopenmod2.so
+
+$(objpfx)filtmod1.so: $(objpfx)filtmod1.os $(objpfx)filtmod2.so
+	$(LINK.o) -shared -o $@ -B$(csu-objpfx) $(LDFLAGS.so) \
+		  -L$(subst :, -L,$(rpath-link)) \
+		  -Wl,-rpath-link=$(rpath-link) \
+		  $< -Wl,-F,$(objpfx)filtmod2.so
+$(objpfx)filter: $(objpfx)filtmod1.so
+
+$(objpfx)unload: $(libdl)
+$(objpfx)unload.out: $(objpfx)unloadmod.so
+
+$(objpfx)reldep: $(libdl)
+$(objpfx)reldep.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod2.so
+
+$(objpfx)reldep2: $(libdl)
+$(objpfx)reldep2.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod3.so
+
+$(objpfx)reldep3: $(libdl)
+$(objpfx)reldep3.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod4.so
+
+$(objpfx)reldep4: $(libdl)
+$(objpfx)reldep4.out: $(objpfx)reldep4mod1.so $(objpfx)reldep4mod2.so
+
+$(objpfx)next: $(objpfx)nextmod1.so $(objpfx)nextmod2.so $(libdl)
+
+$(objpfx)unload2: $(libdl)
+$(objpfx)unload2.out: $(objpfx)unload2mod.so $(objpfx)unload2dep.so
+
+$(objpfx)lateglobal: $(libdl)
+$(objpfx)lateglobal.out: $(objpfx)ltglobmod1.so $(objpfx)ltglobmod2.so
+
+$(objpfx)tst-pathopt: $(libdl)
+$(objpfx)tst-pathopt.out: tst-pathopt.sh $(objpfx)tst-pathopt \
+			  $(objpfx)pathoptobj.so
+	$(SHELL) -e $< $(common-objpfx)
+
+$(objpfx)initfirst: $(libdl)
+$(objpfx)initfirst.out: $(objpfx)firstobj.so
+
+$(objpfx)global: $(objpfx)globalmod1.so
+$(objpfx)global.out: $(objpfx)reldepmod1.so
+
+$(objpfx)dblload: $(libdl)
+$(objpfx)dblload.out: $(objpfx)dblloadmod1.so $(objpfx)dblloadmod2.so
+
+$(objpfx)dblunload: $(libdl)
+$(objpfx)dblunload.out: $(objpfx)dblloadmod1.so $(objpfx)dblloadmod2.so
+
+$(objpfx)reldep5: $(libdl)
+$(objpfx)reldep5.out: $(objpfx)reldepmod5.so $(objpfx)reldepmod5.so
+
+$(objpfx)reldep6: $(libdl)
+$(objpfx)reldep6.out: $(objpfx)reldep6mod3.so $(objpfx)reldep6mod4.so
+
+$(objpfx)reldep7: $(libdl)
+$(objpfx)reldep7.out: $(objpfx)reldep7mod1.so $(objpfx)reldep7mod2.so
+
+$(objpfx)reldep8: $(libdl)
+$(objpfx)reldep8.out: $(objpfx)reldep8mod3.so
+
+LDFLAGS-nodel2mod2.so = -Wl,--enable-new-dtags,-z,nodelete
+$(objpfx)nodelete2: $(libdl)
+$(objpfx)nodelete2.out: $(objpfx)nodel2mod3.so
+
+$(objpfx)reldep9: $(libdl)
+$(objpfx)reldep9.out: $(objpfx)reldep9mod3.so
+
+$(objpfx)tst-tls3: $(objpfx)tst-tlsmod1.so
+
+$(objpfx)tst-tls4: $(libdl)
+$(objpfx)tst-tls4.out: $(objpfx)tst-tlsmod2.so
+
+$(objpfx)tst-tls5: $(libdl)
+$(objpfx)tst-tls5.out: $(objpfx)tst-tlsmod2.so
+
+$(objpfx)tst-tls6: $(libdl)
+$(objpfx)tst-tls6.out: $(objpfx)tst-tlsmod2.so
+
+$(objpfx)tst-tls7: $(libdl)
+$(objpfx)tst-tls7.out: $(objpfx)tst-tlsmod3.so
+
+$(objpfx)tst-tls8: $(libdl)
+$(objpfx)tst-tls8.out: $(objpfx)tst-tlsmod3.so $(objpfx)tst-tlsmod4.so
+
+$(objpfx)tst-tls9: $(libdl)
+$(objpfx)tst-tls9.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
+
+$(objpfx)tst-tls10: $(objpfx)tst-tlsmod8.so
+
+$(objpfx)tst-tls11: $(objpfx)tst-tlsmod10.so
+
+$(objpfx)tst-tls12: $(objpfx)tst-tlsmod12.so
+
+$(objpfx)tst-tls13: $(libdl)
+$(objpfx)tst-tls13.out: $(objpfx)tst-tlsmod13a.so
+
+$(objpfx)tst-tls14: $(objpfx)tst-tlsmod14a.so $(libdl)
+$(objpfx)tst-tls14.out: $(objpfx)tst-tlsmod14b.so
+
+$(objpfx)tst-tls15: $(libdl)
+$(objpfx)tst-tls15.out: $(objpfx)tst-tlsmod15a.so $(objpfx)tst-tlsmod15b.so
+
+CFLAGS-tst-align.c = $(stack-align-test-flags)
+CFLAGS-tst-align2.c = $(stack-align-test-flags)
+CFLAGS-tst-alignmod.c = $(stack-align-test-flags)
+CFLAGS-tst-alignmod2.c = $(stack-align-test-flags)
+$(objpfx)tst-align: $(libdl)
+$(objpfx)tst-align.out: $(objpfx)tst-alignmod.so
+$(objpfx)tst-align2: $(objpfx)tst-alignmod2.so
+
+$(objpfx)unload3: $(libdl)
+$(objpfx)unload3.out: $(objpfx)unload3mod1.so $(objpfx)unload3mod2.so \
+		      $(objpfx)unload3mod3.so $(objpfx)unload3mod4.so
+
+$(objpfx)unload4: $(libdl)
+$(objpfx)unload4.out: $(objpfx)unload4mod1.so $(objpfx)unload4mod3.so
+
+$(objpfx)unload5: $(libdl)
+$(objpfx)unload5.out: $(objpfx)unload3mod1.so $(objpfx)unload3mod2.so \
+		      $(objpfx)unload3mod3.so $(objpfx)unload3mod4.so
+
+$(objpfx)unload6: $(libdl)
+$(objpfx)unload6.out: $(objpfx)unload6mod1.so $(objpfx)unload6mod2.so \
+		      $(objpfx)unload6mod3.so
+
+ifdef libdl
+$(objpfx)tst-tls9-static: $(common-objpfx)dlfcn/libdl.a
+$(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
+endif
+
+ifeq ($(have-z-execstack),yes)
+$(objpfx)tst-execstack: $(libdl)
+$(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
+LDFLAGS-tst-execstack = -Wl,-z,noexecstack
+LDFLAGS-tst-execstack-mod = -Wl,-z,execstack
+
+$(objpfx)tst-execstack-needed: $(objpfx)tst-execstack-mod.so
+LDFLAGS-tst-execstack-needed = -Wl,-z,noexecstack
+
+LDFLAGS-tst-execstack-prog = -Wl,-z,execstack
+endif
+
+$(objpfx)tst-array1.out: $(objpfx)tst-array1
+	$(elf-objpfx)$(rtld-installed-name) \
+	  --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
+	  $(objpfx)tst-array1 > $@
+	cmp $@ tst-array1.exp > /dev/null
+
+$(objpfx)tst-array1-static.out: $(objpfx)tst-array1-static
+	$(objpfx)tst-array1-static > $@
+	cmp $@ tst-array1.exp > /dev/null
+
+$(objpfx)tst-array2: $(objpfx)tst-array2dep.so
+$(objpfx)tst-array2.out: $(objpfx)tst-array2
+	$(elf-objpfx)$(rtld-installed-name) \
+	  --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
+	  $(objpfx)tst-array2 > $@
+	cmp $@ tst-array2.exp > /dev/null
+
+$(objpfx)tst-array3.out: $(objpfx)tst-array3
+	$(elf-objpfx)$(rtld-installed-name) \
+	  --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
+	  $(objpfx)tst-array3 > $@
+	cmp $@ tst-array1.exp > /dev/null
+
+$(objpfx)tst-array4: $(libdl)
+$(objpfx)tst-array4.out: $(objpfx)tst-array4 $(objpfx)tst-array2dep.so
+	$(elf-objpfx)$(rtld-installed-name) \
+	  --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
+	  $< > $@
+	cmp $@ tst-array4.exp > /dev/null
+
+ifeq (yesyes,$(have-fpie)$(build-shared))
+CFLAGS-tst-pie1.c += -fpie
+
+$(objpfx)tst-pie1.out: $(objpfx)tst-pie1
+	$(elf-objpfx)$(rtld-installed-name) \
+	  --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
+	  $< > $@
+
+$(objpfx)tst-pie1: $(objpfx)tst-pie1.o $(objpfx)tst-piemod1.so
+	$(LINK.o) -pie -Wl,-O1 \
+	  $(sysdep-LDFLAGS) $(config-LDFLAGS) \
+	  $(extra-B-$(@F:lib%.so=%).so) -B$(csu-objpfx) \
+	  $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
+	  $(LDFLAGS) $(LDFLAGS-$(@F)) \
+	  -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link) \
+	  -o $@ $(objpfx)tst-pie1.o $(objpfx)tst-piemod1.so \
+	  $(common-objpfx)libc_nonshared.a
+
+generated += tst-pie1 tst-pie1.out tst-pie1.o
+endif
+
+check-textrel-CFLAGS = -O -Wall -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
+$(objpfx)check-textrel: check-textrel.c
+	$(native-compile)
+
+ifeq (yes,$(build-shared))
+tests: $(objpfx)check-textrel.out
+
+$(objpfx)check-textrel.out: $(objpfx)check-textrel
+	$(dir $<)$(notdir $<) $(common-objpfx)libc.so \
+	  $(sort $(wildcard $(common-objpfx)*/lib*.so \
+			    $(common-objpfx)iconvdata/*.so)) > $@
+generated += check-textrel check-textrel.out
+
+$(objpfx)tst-dlmodcount: $(libdl)
+$(objpfx)tst-dlmodcount.out: $(test-modules)
+
+endif
+
+$(objpfx)tst-dlopenrpathmod.so: $(libdl)
+$(objpfx)tst-dlopenrpath: $(objpfx)tst-dlopenrpathmod.so $(libdl)
+CFLAGS-tst-dlopenrpath.c += -DPFX=\"$(objpfx)\"
+LDFLAGS-tst-dlopenrpathmod.so += -Wl,-rpath,\$$ORIGIN/test-subdir
+$(objpfx)tst-dlopenrpath.out: $(objpfx)firstobj.so
+
+$(objpfx)tst-deep1mod2.so: $(objpfx)tst-deep1mod3.so
+$(objpfx)tst-deep1: $(libdl) $(objpfx)tst-deep1mod1.so
+$(objpfx)tst-deep1.out: $(objpfx)tst-deep1mod2.so
+LDFLAGS-tst-deep1 += -rdynamic
+tst-deep1mod3.so-no-z-defs = yes
+
+$(objpfx)tst-dlmopen1mod.so: $(libdl)
+$(objpfx)tst-dlmopen1: $(libdl)
+$(objpfx)tst-dlmopen1.out: $(objpfx)tst-dlmopen1mod.so
+
+$(objpfx)tst-dlmopen2: $(libdl)
+$(objpfx)tst-dlmopen2.out: $(objpfx)tst-dlmopen1mod.so
+
+$(objpfx)tst-dlmopen3: $(libdl)
+$(objpfx)tst-dlmopen3.out: $(objpfx)tst-dlmopen1mod.so
+
+$(objpfx)tst-audit1.out: $(objpfx)tst-auditmod1.so
+tst-audit1-ENV = LD_AUDIT=$(objpfx)tst-auditmod1.so
+
+$(objpfx)tst-global1: $(libdl)
+$(objpfx)tst-global1.out: $(objpfx)testobj6.so $(objpfx)testobj2.so
+
+$(objpfx)order2: $(libdl)
+$(objpfx)order2.out: $(objpfx)order2 $(objpfx)order2mod1.so \
+		     $(objpfx)order2mod2.so
+	$(elf-objpfx)$(rtld-installed-name) \
+	  --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
+	  $(objpfx)order2 > $@
+	(echo "12345" | cmp $@ -) > /dev/null
+$(objpfx)order2mod1.so: $(objpfx)order2mod4.so
+$(objpfx)order2mod4.so: $(objpfx)order2mod3.so
+$(objpfx)order2mod2.so: $(objpfx)order2mod3.so
+order2mod2.so-no-z-defs = yes
Index: trunk/src/libctests/glibc/elf/loadtest.c
===================================================================
--- trunk/src/libctests/glibc/elf/loadtest.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/loadtest.c	(revision 2036)
@@ -0,0 +1,200 @@
+#include <assert.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <error.h>
+#include <mcheck.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+/* How many load/unload operations do we do.  */
+#define TEST_ROUNDS	1000
+
+
+static struct
+{
+  /* Name of the module.  */
+  const char *name;
+  /* The handle.  */
+  void *handle;
+} testobjs[] =
+{
+  { "testobj1.so", NULL },
+  { "testobj2.so", NULL },
+  { "testobj3.so", NULL },
+  { "testobj4.so", NULL },
+  { "testobj5.so", NULL },
+  { "testobj6.so", NULL },
+};
+#define NOBJS	(sizeof (testobjs) / sizeof (testobjs[0]))
+
+
+static const struct
+{
+  /* Name of a function to call.  */
+  const char *fname;
+  /* Index in status and handle array.  */
+  int index;
+  /* Options while loading the module.  */
+  int options;
+} tests[] =
+{
+  { "obj1func2", 0, RTLD_LAZY },
+  { "obj1func1", 0, RTLD_LAZY | RTLD_GLOBAL },
+  { "obj1func1", 0, RTLD_NOW, },
+  { "obj1func2", 0, RTLD_NOW | RTLD_GLOBAL },
+  { "obj2func2", 1, RTLD_LAZY },
+  { "obj2func1", 1, RTLD_LAZY | RTLD_GLOBAL, },
+  { "obj2func1", 1, RTLD_NOW, },
+  { "obj2func2", 1, RTLD_NOW | RTLD_GLOBAL },
+  { "obj3func2", 2, RTLD_LAZY },
+  { "obj3func1", 2, RTLD_LAZY | RTLD_GLOBAL },
+  { "obj3func1", 2, RTLD_NOW },
+  { "obj3func2", 2, RTLD_NOW | RTLD_GLOBAL },
+  { "obj4func2", 3, RTLD_LAZY },
+  { "obj4func1", 3, RTLD_LAZY | RTLD_GLOBAL },
+  { "obj4func1", 3, RTLD_NOW },
+  { "obj4func2", 3, RTLD_NOW | RTLD_GLOBAL },
+  { "obj5func2", 4, RTLD_LAZY },
+  { "obj5func1", 4, RTLD_LAZY | RTLD_GLOBAL },
+  { "obj5func1", 4, RTLD_NOW },
+  { "obj5func2", 4, RTLD_NOW | RTLD_GLOBAL },
+  { "obj6func2", 5, RTLD_LAZY },
+  { "obj6func1", 5, RTLD_LAZY | RTLD_GLOBAL },
+  { "obj6func1", 5, RTLD_NOW },
+  { "obj6func2", 5, RTLD_NOW | RTLD_GLOBAL },
+};
+#define NTESTS	(sizeof (tests) / sizeof (tests[0]))
+
+
+#include <include/link.h>
+
+#define OUT \
+  for (map = _r_debug.r_map; map != NULL; map = map->l_next)		      \
+    if (map->l_type == lt_loaded)					      \
+      printf ("name = \"%s\", direct_opencount = %d\n",			      \
+	      map->l_name, (int) map->l_direct_opencount);		      \
+  fflush (stdout)
+
+
+int
+main (int argc, char *argv[])
+{
+  int debug = argc > 1 && argv[1][0] != '\0';
+  int count = TEST_ROUNDS;
+  int result = 0;
+  struct link_map *map;
+
+  mtrace ();
+
+  /* Just a seed.  */
+  srandom (TEST_ROUNDS);
+
+  if (debug)
+    {
+      puts ("in the beginning");
+      OUT;
+    }
+
+  while (count--)
+    {
+      int nr = random () % NTESTS;
+      int index = tests[nr].index;
+
+      printf ("%4d: %4d: ", count + 1, nr);
+      fflush (stdout);
+
+      if (testobjs[index].handle == NULL)
+	{
+	  int (*fct) (int);
+
+	  /* Load the object.  */
+	  testobjs[index].handle = dlopen (testobjs[index].name,
+					   tests[nr].options);
+	  if (testobjs[index].handle == NULL)
+	    error (EXIT_FAILURE, 0, "cannot load `%s': %s",
+		   testobjs[index].name, dlerror ());
+
+	  /* Test the function call.  */
+	  fct = dlsym (testobjs[index].handle, tests[nr].fname);
+	  if (fct == NULL)
+	    error (EXIT_FAILURE, 0,
+		   "cannot get function `%s' from shared object `%s': %s",
+		   tests[nr].fname, testobjs[index].name, dlerror ());
+
+	  fct (10);
+
+	  printf ("successfully loaded `%s', handle %p\n",
+		  testobjs[index].name, testobjs[index].handle);
+	}
+      else
+	{
+	  if (dlclose (testobjs[index].handle) != 0)
+	    {
+	      printf ("failed to close %s\n", testobjs[index].name);
+	      result = 1;
+	    }
+	  else
+	    printf ("successfully unloaded `%s', handle %p\n",
+		    testobjs[index].name, testobjs[index].handle);
+
+	  testobjs[index].handle = NULL;
+
+	  if (testobjs[0].handle == NULL
+	      && testobjs[1].handle == NULL
+	      && testobjs[5].handle == NULL)
+	    {
+	      /* In this case none of the objects above should be
+		 present.  */
+	      for (map = _r_debug.r_map; map != NULL; map = map->l_next)
+		if (map->l_type == lt_loaded
+		    && (strstr (map->l_name, testobjs[0].name) != NULL
+			|| strstr (map->l_name, testobjs[1].name) != NULL
+			|| strstr (map->l_name, testobjs[5].name) != NULL))
+		  {
+		    printf ("`%s' is still loaded\n", map->l_name);
+		    result = 1;
+		  }
+	    }
+	}
+
+      if (debug)
+	OUT;
+    }
+
+  /* Unload all loaded modules.  */
+  for (count = 0; count < (int) NOBJS; ++count)
+    if (testobjs[count].handle != NULL)
+      {
+	printf ("\nclose: %s: l_initfini = %p, l_versions = %p\n",
+		testobjs[count].name,
+		((struct link_map *) testobjs[count].handle)->l_initfini,
+		((struct link_map *) testobjs[count].handle)->l_versions);
+
+	if (dlclose (testobjs[count].handle) != 0)
+	  {
+	    printf ("failed to close %s\n", testobjs[count].name);
+	    result = 1;
+	  }
+      }
+
+  /* Check whether all files are unloaded.  */
+  for (map = _r_debug.r_map; map != NULL; map = map->l_next)
+    if (map->l_type == lt_loaded)
+      {
+	printf ("name = \"%s\", direct_opencount = %d\n",
+		map->l_name, (int) map->l_direct_opencount);
+	result = 1;
+      }
+
+  return result;
+}
+
+
+extern int foo (int a);
+int
+foo (int a)
+{
+  return a - 1;
+}
Index: trunk/src/libctests/glibc/elf/neededtest.c
===================================================================
--- trunk/src/libctests/glibc/elf/neededtest.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/neededtest.c	(revision 2036)
@@ -0,0 +1,123 @@
+#include <dlfcn.h>
+#include <libintl.h>
+#include <link.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static int
+check_loaded_objects (const char **loaded)
+{
+  struct link_map *lm;
+  int n;
+  int *found = NULL;
+  int errors = 0;
+
+  for (n = 0; loaded[n]; n++)
+    /* NOTHING */;
+
+  if (n)
+    {
+      found = (int *) alloca (sizeof (int) * n);
+      memset (found, 0, sizeof (int) * n);
+    }
+
+  printf("   Name\n");
+  printf(" --------------------------------------------------------\n");
+  for (lm = _r_debug.r_map; lm; lm = lm->l_next)
+    {
+      if (lm->l_name && lm->l_name[0])
+	printf(" %s, count = %d\n", lm->l_name, (int) lm->l_direct_opencount);
+      if (lm->l_type == lt_loaded && lm->l_name)
+	{
+	  int match = 0;
+	  for (n = 0; loaded[n] != NULL; n++)
+	    {
+	      if (strcmp (basename (loaded[n]), basename (lm->l_name)) == 0)
+	        {
+		  found[n] = 1;
+		  match = 1;
+		  break;
+		}
+	    }
+
+	  if (match == 0)
+	    {
+	      ++errors;
+	      printf ("ERRORS: %s is not unloaded\n", lm->l_name);
+	    }
+	}
+    }
+
+  for (n = 0; loaded[n] != NULL; n++)
+    {
+      if (found[n] == 0)
+        {
+	  ++errors;
+	  printf ("ERRORS: %s is not loaded\n", loaded[n]);
+	}
+    }
+
+  return errors;
+}
+
+int
+main (void)
+{
+  void *obj2[2];
+  void *obj3;
+  const char *loaded[] = { NULL, NULL, NULL, NULL };
+  int errors = 0;
+
+  printf ("\nThis is what is in memory now:\n");
+  errors += check_loaded_objects (loaded);
+
+  printf( "Loading shared object neededobj3.so\n");
+  obj3 = dlopen( "neededobj3.so", RTLD_LAZY);
+  if (obj3 == NULL)
+    {
+      printf ("%s\n", dlerror ());
+      exit (1);
+    }
+  loaded[0] = "neededobj1.so";
+  loaded[1] = "neededobj2.so";
+  loaded[2] = "neededobj3.so";
+  errors += check_loaded_objects (loaded);
+
+  printf ("Now loading shared object neededobj2.so\n");
+  obj2[0] = dlopen ("neededobj2.so", RTLD_LAZY);
+  if (obj2[0] == NULL)
+    {
+      printf ("%s\n", dlerror ());
+      exit (1);
+    }
+  errors += check_loaded_objects (loaded);
+
+  printf ("And loading shared object neededobj2.so again\n");
+  obj2[1] = dlopen ("neededobj2.so", RTLD_LAZY);
+  if (obj2[1] == NULL)
+    {
+      printf ("%s\n", dlerror ());
+      exit (1);
+    }
+  errors += check_loaded_objects (loaded);
+
+  printf ("Closing neededobj2.so for the first time\n");
+  dlclose (obj2[0]);
+  errors += check_loaded_objects (loaded);
+
+  printf ("Closing neededobj3.so\n");
+  dlclose (obj3);
+  loaded[2] = NULL;
+  errors += check_loaded_objects (loaded);
+
+  printf ("Closing neededobj2.so for the second time\n");
+  dlclose (obj2[1]);
+  loaded[0] = NULL;
+  loaded[1] = NULL;
+  errors += check_loaded_objects (loaded);
+
+  if (errors != 0)
+    printf ("%d errors found\n", errors);
+  return errors;
+}
Index: trunk/src/libctests/glibc/elf/neededtest2.c
===================================================================
--- trunk/src/libctests/glibc/elf/neededtest2.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/neededtest2.c	(revision 2036)
@@ -0,0 +1,116 @@
+#include <dlfcn.h>
+#include <libintl.h>
+#include <link.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static int
+check_loaded_objects (const char **loaded)
+{
+  struct link_map *lm;
+  int n;
+  int *found = NULL;
+  int errors = 0;
+
+  for (n = 0; loaded[n]; n++)
+    /* NOTHING */;
+
+  if (n)
+    {
+      found = (int *) alloca (sizeof (int) * n);
+      memset (found, 0, sizeof (int) * n);
+    }
+
+  printf("   Name\n");
+  printf(" --------------------------------------------------------\n");
+  for (lm = _r_debug.r_map; lm; lm = lm->l_next)
+    {
+      if (lm->l_name && lm->l_name[0])
+	printf(" %s, count = %d\n", lm->l_name, (int) lm->l_direct_opencount);
+      if (lm->l_type == lt_loaded && lm->l_name)
+	{
+	  int match = 0;
+	  for (n = 0; loaded[n] != NULL; n++)
+	    {
+	      if (strcmp (basename (loaded[n]), basename (lm->l_name)) == 0)
+	        {
+		  found[n] = 1;
+		  match = 1;
+		  break;
+		}
+	    }
+
+	  if (match == 0)
+	    {
+	      ++errors;
+	      printf ("ERRORS: %s is not unloaded\n", lm->l_name);
+	    }
+	}
+    }
+
+  for (n = 0; loaded[n] != NULL; n++)
+    {
+      if (found[n] == 0)
+        {
+	  ++errors;
+	  printf ("ERRORS: %s is not loaded\n", loaded[n]);
+	}
+    }
+
+  return errors;
+}
+
+int
+main (void)
+{
+  void *obj2;
+  void *obj3[2];
+  const char *loaded[] = { NULL, NULL, NULL, NULL };
+  int errors = 0;
+
+  printf ("\nThis is what is in memory now:\n");
+  errors += check_loaded_objects (loaded);
+  printf ("\nLoading shared object neededobj2.so\n");
+  obj2 = dlopen ("neededobj2.so", RTLD_LAZY);
+  if (obj2 == NULL)
+    {
+      printf ("%s\n", dlerror ());
+      exit (1);
+    }
+  loaded[0] = "neededobj1.so";
+  loaded[1] = "neededobj2.so";
+  errors += check_loaded_objects (loaded);
+  printf ("\nLoading shared object neededobj3.so\n");
+  obj3[0] = dlopen( "neededobj3.so", RTLD_LAZY);
+  if (obj3[0] == NULL)
+    {
+      printf ("%s\n", dlerror ());
+      exit (1);
+    }
+  loaded[2] = "neededobj3.so";
+  errors += check_loaded_objects (loaded);
+  printf ("\nNow loading shared object neededobj3.so again\n");
+  obj3[1] = dlopen ("neededobj3.so", RTLD_LAZY);
+  if (obj3[1] == NULL)
+    {
+      printf ("%s\n", dlerror ());
+      exit (1);
+    }
+  errors += check_loaded_objects (loaded);
+  printf ("\nClosing neededobj3.so once\n");
+  dlclose (obj3[0]);
+  errors += check_loaded_objects (loaded);
+  printf ("\nClosing neededobj2.so\n");
+  dlclose (obj2);
+  errors += check_loaded_objects (loaded);
+  printf ("\nClosing neededobj3.so for the second time\n");
+  dlclose (obj3[1]);
+  loaded[0] = NULL;
+  loaded[1] = NULL;
+  loaded[2] = NULL;
+  errors += check_loaded_objects (loaded);
+  if (errors != 0)
+    printf ("%d errors found\n", errors);
+  return errors;
+}
Index: trunk/src/libctests/glibc/elf/neededtest3.c
===================================================================
--- trunk/src/libctests/glibc/elf/neededtest3.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/neededtest3.c	(revision 2036)
@@ -0,0 +1,127 @@
+#include <dlfcn.h>
+#include <libintl.h>
+#include <link.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static int
+check_loaded_objects (const char **loaded)
+{
+  struct link_map *lm;
+  int n;
+  int *found = NULL;
+  int errors = 0;
+
+  for (n = 0; loaded[n]; n++)
+    /* NOTHING */;
+
+  if (n)
+    {
+      found = (int *) alloca (sizeof (int) * n);
+      memset (found, 0, sizeof (int) * n);
+    }
+
+  printf("   Name\n");
+  printf(" --------------------------------------------------------\n");
+  for (lm = _r_debug.r_map; lm; lm = lm->l_next)
+    {
+      if (lm->l_name && lm->l_name[0])
+	printf(" %s, count = %d\n", lm->l_name, (int) lm->l_direct_opencount);
+      if (lm->l_type == lt_loaded && lm->l_name)
+	{
+	  int match = 0;
+	  for (n = 0; loaded[n] != NULL; n++)
+	    {
+	      if (strcmp (basename (loaded[n]), basename (lm->l_name)) == 0)
+	        {
+		  found[n] = 1;
+		  match = 1;
+		  break;
+		}
+	    }
+
+	  if (match == 0)
+	    {
+	      ++errors;
+	      printf ("ERRORS: %s is not unloaded\n", lm->l_name);
+	    }
+	}
+    }
+
+  for (n = 0; loaded[n] != NULL; n++)
+    {
+      if (found[n] == 0)
+        {
+	  ++errors;
+	  printf ("ERRORS: %s is not loaded\n", loaded[n]);
+	}
+    }
+
+  return errors;
+}
+
+int
+main (void)
+{
+  void *obj2;
+  void *obj3;
+  void *obj4;
+  const char *loaded[] = { NULL, NULL, NULL, NULL, NULL };
+  int errors = 0;
+
+  printf ("\nThis is what is in memory now:\n");
+  errors += check_loaded_objects (loaded);
+
+  printf ("Now loading shared object neededobj2.so\n");
+  obj2 = dlopen ("neededobj2.so", RTLD_LAZY);
+  if (obj2 == NULL)
+    {
+      printf ("%s\n", dlerror ());
+      exit (1);
+    }
+  loaded[0] = "neededobj1.so";
+  loaded[1] = "neededobj2.so";
+  errors += check_loaded_objects (loaded);
+
+  printf( "Loading shared object neededobj3.so\n");
+  obj3 = dlopen( "neededobj3.so", RTLD_LAZY);
+  if (obj3 == NULL)
+    {
+      printf ("%s\n", dlerror ());
+      exit (1);
+    }
+  loaded[2] = "neededobj3.so";
+  errors += check_loaded_objects (loaded);
+
+
+  printf( "Loading shared object neededobj4.so\n");
+  obj4 = dlopen( "neededobj4.so", RTLD_LAZY);
+  if (obj4 == NULL)
+    {
+      printf ("%s\n", dlerror ());
+      exit (1);
+    }
+  loaded[3] = "neededobj4.so";
+  errors += check_loaded_objects (loaded);
+
+  printf ("Closing neededobj2.so\n");
+  dlclose (obj2);
+  errors += check_loaded_objects (loaded);
+
+  printf ("Closing neededobj3.so\n");
+  dlclose (obj3);
+  errors += check_loaded_objects (loaded);
+
+  printf ("Closing neededobj4.so\n");
+  dlclose (obj4);
+  loaded[0] = NULL;
+  loaded[1] = NULL;
+  loaded[2] = NULL;
+  loaded[3] = NULL;
+  errors += check_loaded_objects (loaded);
+
+  if (errors != 0)
+    printf ("%d errors found\n", errors);
+  return errors;
+}
Index: trunk/src/libctests/glibc/elf/neededtest4.c
===================================================================
--- trunk/src/libctests/glibc/elf/neededtest4.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/neededtest4.c	(revision 2036)
@@ -0,0 +1,156 @@
+#include <dlfcn.h>
+#include <libintl.h>
+#include <link.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static int
+check_loaded_objects (const char **loaded)
+{
+  struct link_map *lm;
+  int n;
+  int *found = NULL;
+  int errors = 0;
+
+  for (n = 0; loaded[n]; n++)
+    /* NOTHING */;
+
+  if (n)
+    {
+      found = (int *) alloca (sizeof (int) * n);
+      memset (found, 0, sizeof (int) * n);
+    }
+
+  printf("   Name\n");
+  printf(" --------------------------------------------------------\n");
+  for (lm = _r_debug.r_map; lm; lm = lm->l_next)
+    {
+      if (lm->l_name && lm->l_name[0])
+	printf(" %s, count = %d\n", lm->l_name, (int) lm->l_direct_opencount);
+      if (lm->l_type == lt_loaded && lm->l_name)
+	{
+	  int match = 0;
+	  for (n = 0; loaded[n] != NULL; n++)
+	    {
+	      if (strcmp (basename (loaded[n]), basename (lm->l_name)) == 0)
+	        {
+		  found[n] = 1;
+		  match = 1;
+		  break;
+		}
+	    }
+
+	  if (match == 0)
+	    {
+	      ++errors;
+	      printf ("ERRORS: %s is not unloaded\n", lm->l_name);
+	    }
+	}
+    }
+
+  for (n = 0; loaded[n] != NULL; n++)
+    {
+      if (found[n] == 0)
+        {
+	  ++errors;
+	  printf ("ERRORS: %s is not loaded\n", loaded[n]);
+	}
+    }
+
+  return errors;
+}
+
+extern void c_function (void);
+extern char *dirname (__const char *__filename);
+
+int
+main (int argc, char **argv)
+{
+  void *obj;
+  const char *loaded[] = { NULL, NULL, NULL};
+  int errors = 0;
+  void (*f) (void);
+  const char *dir = dirname (argv [0]);
+  char *oldfilename;
+  char *newfilename;
+
+  c_function ();
+
+  printf ("\nThis is what is in memory now:\n");
+  errors += check_loaded_objects (loaded);
+
+  printf( "Loading shared object neededobj6.so\n");
+  obj = dlopen( "neededobj6.so", RTLD_LAZY);
+  if (obj == NULL)
+    {
+      printf ("%s\n", dlerror ());
+      exit (1);
+    }
+  f = dlsym (obj, "a2_function");
+  if (f == NULL)
+    {
+      printf ("%s\n", dlerror ());
+      exit (1);
+    }
+  f ();
+  loaded[0] = "neededobj5.so";
+  loaded[1] = "neededobj6.so";
+  errors += check_loaded_objects (loaded);
+
+  printf ("Closing neededobj6.so\n");
+  dlclose (obj);
+  loaded[0] = NULL;
+  errors += check_loaded_objects (loaded);
+
+  printf ("Rename neededobj5.so\n");
+  oldfilename = alloca (strlen (dir) + 1 + sizeof ("neededobj5.so"));
+  strcpy (oldfilename, dir);
+  strcat (oldfilename, "/");
+  strcat (oldfilename, "neededobj5.so");
+  newfilename = alloca (strlen (oldfilename) + sizeof (".renamed"));
+  strcpy (newfilename, oldfilename);
+  strcat (newfilename, ".renamed");
+  if (rename (oldfilename, newfilename))
+    {
+      perror ("rename");
+      exit (1);
+    }
+
+  printf( "Loading shared object neededobj6.so\n");
+  obj = dlopen( "neededobj6.so", RTLD_LAZY);
+  if (obj == NULL)
+    printf ("%s\n", dlerror ());
+  else
+    {
+      printf ("neededobj6.so should fail to load\n");
+      exit (1);
+    }
+
+  printf( "Loading shared object neededobj1.so\n");
+  obj = dlopen( "neededobj1.so", RTLD_LAZY);
+  if (obj == NULL)
+    {
+      printf ("%s\n", dlerror ());
+      exit (1);
+    }
+  errors += check_loaded_objects (loaded);
+  f = dlsym (obj, "c_function");
+  if (f == NULL)
+    {
+      printf ("%s\n", dlerror ());
+      exit (1);
+    }
+  f ();
+
+  printf ("Restore neededobj5.so\n");
+  if (rename (newfilename, oldfilename))
+    {
+      perror ("rename");
+      exit (1);
+    }
+
+  if (errors != 0)
+    printf ("%d errors found\n", errors);
+  return errors;
+}
Index: trunk/src/libctests/glibc/elf/origtest.c
===================================================================
--- trunk/src/libctests/glibc/elf/origtest.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/origtest.c	(revision 2036)
@@ -0,0 +1,39 @@
+#include <dlfcn.h>
+#include <error.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main (void)
+{
+  void *h;
+  int (*fp) (int);
+  int res;
+
+  h = dlopen ("${ORIGIN}/testobj1.so", RTLD_LAZY);
+  if (h == NULL)
+    error (EXIT_FAILURE, 0, "while loading `%s': %s", "testobj1.so",
+	   dlerror ());
+
+  fp = dlsym (h, "obj1func1");
+  if (fp == NULL)
+    error (EXIT_FAILURE, 0, "getting `obj1func1' in `%s': %s",
+	   "testobj1.so", dlerror ());
+
+  res = fp (10);
+  printf ("fp(10) = %d\n", res);
+
+  if (dlclose (h) != 0)
+    error (EXIT_FAILURE, 0, "while close `%s': %s",
+	   "testobj1.so", dlerror ());
+
+  return res != 42;
+}
+
+
+extern int foo (int a);
+int
+foo (int a)
+{
+  return a + 10;
+}
Index: trunk/src/libctests/glibc/elf/preloadtest.c
===================================================================
--- trunk/src/libctests/glibc/elf/preloadtest.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/preloadtest.c	(revision 2036)
@@ -0,0 +1,19 @@
+#include <stdio.h>
+
+#include "testobj.h"
+
+int
+main (void)
+{
+  int res = preload (42);
+
+  printf ("preload (42) = %d, %s\n", res, res == 92 ? "ok" : "wrong");
+
+  return res != 92;
+}
+
+int
+foo (int a)
+{
+  return a;
+}
Index: trunk/src/libctests/glibc/elf/restest1.c
===================================================================
--- trunk/src/libctests/glibc/elf/restest1.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/restest1.c	(revision 2036)
@@ -0,0 +1,57 @@
+#include <dlfcn.h>
+#include <error.h>
+#include <mcheck.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main (void)
+{
+  void *h1;
+  int (*fp1) (int);
+  void *h2;
+  int (*fp2) (int);
+  int res1;
+  int res2;
+
+  mtrace ();
+
+  h1 = dlopen ("testobj1.so", RTLD_LAZY);
+  if (h1 == NULL)
+    error (EXIT_FAILURE, 0, "while loading `%s': %s", "testobj1.so",
+	   dlerror ());
+
+  h2 = dlopen ("testobj1_1.so", RTLD_LAZY);
+  if (h1 == NULL)
+    error (EXIT_FAILURE, 0, "while loading `%s': %s", "testobj1_1.so",
+	   dlerror ());
+
+  fp1 = dlsym (h1, "obj1func1");
+  if (fp1 == NULL)
+    error (EXIT_FAILURE, 0, "getting `obj1func1' in `%s': %s",
+	   "testobj1.so", dlerror ());
+
+  fp2 = dlsym (h2, "obj1func1");
+  if (fp2 == NULL)
+    error (EXIT_FAILURE, 0, "getting `obj1func1' in `%s': %s",
+	   "testobj1_1.so", dlerror ());
+
+  res1 = fp1 (10);
+  res2 = fp2 (10);
+  printf ("fp1(10) = %d\nfp2(10) = %d\n", res1, res2);
+
+  if (dlclose (h1) != 0)
+    error (EXIT_FAILURE, 0, "cannot close testobj1.so: %s\n", dlerror ());
+  if (dlclose (h2) != 0)
+    error (EXIT_FAILURE, 0, "cannot close testobj1_1.so: %s\n", dlerror ());
+
+  return res1 != 42 || res2 != 72;
+}
+
+
+extern int foo (int a);
+int
+foo (int a)
+{
+  return a + 10;
+}
Index: trunk/src/libctests/glibc/elf/restest2.c
===================================================================
--- trunk/src/libctests/glibc/elf/restest2.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/restest2.c	(revision 2036)
@@ -0,0 +1,33 @@
+#include <sys/types.h>
+#include <dlfcn.h>
+#include <error.h>
+#include <mcheck.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+pid_t pid, pid2;
+
+pid_t getpid(void)
+{
+  pid_t (*f)(void);
+  f = (pid_t (*)(void)) dlsym (RTLD_NEXT, "getpid");
+  if (f == NULL)
+    error (EXIT_FAILURE, 0, "dlsym (RTLD_NEXT, \"getpid\"): %s", dlerror ());
+  return (pid2 = f()) + 26;
+}
+
+int
+main (void)
+{
+  pid_t (*f)(void);
+
+  mtrace ();
+
+  f = (pid_t (*)(void)) dlsym (RTLD_DEFAULT, "getpid");
+  if (f == NULL)
+    error (EXIT_FAILURE, 0, "dlsym (RTLD_DEFAULT, \"getpid\"): %s", dlerror ());
+  pid = f();
+  if (pid != pid2 + 26)
+    error (EXIT_FAILURE, 0, "main getpid() not called");
+  return 0;
+}
Index: trunk/src/libctests/glibc/elf/testobj.h
===================================================================
--- trunk/src/libctests/glibc/elf/testobj.h	(revision 2036)
+++ trunk/src/libctests/glibc/elf/testobj.h	(revision 2036)
@@ -0,0 +1,28 @@
+extern int preload (int a);
+
+extern int foo (int);
+
+extern int obj1func1 (int);
+
+extern int obj1func2 (int);
+
+extern int obj2func1 (int);
+
+extern int obj2func2 (int);
+
+extern int obj3func1 (int);
+
+extern int obj3func2 (int);
+
+extern int obj4func1 (int);
+			 
+extern int obj4func2 (int);
+			 
+extern int obj5func1 (int);
+			 
+extern int obj5func2 (int);
+			 
+extern int obj6func1 (int);
+			 
+extern int obj6func2 (int);
+
Index: trunk/src/libctests/glibc/elf/testobj1.c
===================================================================
--- trunk/src/libctests/glibc/elf/testobj1.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/testobj1.c	(revision 2036)
@@ -0,0 +1,25 @@
+#include <dlfcn.h>
+#include <stdlib.h>
+
+#include "testobj.h"
+
+int
+obj1func1 (int a __attribute__ ((unused)))
+{
+  return 42;
+}
+
+int
+obj1func2 (int a)
+{
+  return foo (a) + 10;
+}
+
+int
+preload (int a)
+{
+  int (*fp) (int) = dlsym (RTLD_NEXT, "preload");
+  if (fp != NULL)
+    return fp (a) + 10;
+  return 10;
+}
Index: trunk/src/libctests/glibc/elf/testobj1_1.c
===================================================================
--- trunk/src/libctests/glibc/elf/testobj1_1.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/testobj1_1.c	(revision 2036)
@@ -0,0 +1,7 @@
+#include "testobj.h"
+
+int
+obj1func1 (int a)
+{
+  return 42 + obj1func2 (a);
+}
Index: trunk/src/libctests/glibc/elf/testobj2.c
===================================================================
--- trunk/src/libctests/glibc/elf/testobj2.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/testobj2.c	(revision 2036)
@@ -0,0 +1,32 @@
+#include <dlfcn.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "testobj.h"
+
+int
+obj2func1 (int a __attribute__ ((unused)))
+{
+  return 43;
+}
+
+int
+obj2func2 (int a)
+{
+  return obj1func1 (a) + 10;
+}
+
+int
+preload (int a)
+{
+  int (*fp) (int) = dlsym (RTLD_NEXT, "preload");
+  if (fp != NULL)
+    return fp (a) + 10;
+  return 10;
+}
+
+void
+p (void)
+{
+  puts ("hello world");
+}
Index: trunk/src/libctests/glibc/elf/testobj3.c
===================================================================
--- trunk/src/libctests/glibc/elf/testobj3.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/testobj3.c	(revision 2036)
@@ -0,0 +1,26 @@
+#include <dlfcn.h>
+#include <stdlib.h>
+
+#include "testobj.h"
+
+
+int
+obj3func1 (int a __attribute__ ((unused)))
+{
+  return 44;
+}
+
+int
+obj3func2 (int a)
+{
+  return foo (a) + 42;
+}
+
+int
+preload (int a)
+{
+  int (*fp) (int) = dlsym (RTLD_NEXT, "preload");
+  if (fp != NULL)
+    return fp (a) + 10;
+  return 10;
+}
Index: trunk/src/libctests/glibc/elf/testobj4.c
===================================================================
--- trunk/src/libctests/glibc/elf/testobj4.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/testobj4.c	(revision 2036)
@@ -0,0 +1,25 @@
+#include <dlfcn.h>
+#include <stdlib.h>
+
+#include "testobj.h"
+
+int
+obj4func1 (int a __attribute__ ((unused)))
+{
+  return 55;
+}
+
+int
+obj4func2 (int a)
+{
+  return foo (a) + 43;
+}
+
+int
+preload (int a)
+{
+  int (*fp) (int) = dlsym (RTLD_NEXT, "preload");
+  if (fp != NULL)
+    return fp (a) + 10;
+  return 10;
+}
Index: trunk/src/libctests/glibc/elf/testobj5.c
===================================================================
--- trunk/src/libctests/glibc/elf/testobj5.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/testobj5.c	(revision 2036)
@@ -0,0 +1,26 @@
+#include <dlfcn.h>
+#include <stdlib.h>
+
+#include "testobj.h"
+
+
+int
+obj5func1 (int a __attribute__ ((unused)))
+{
+  return 66;
+}
+
+int
+obj5func2 (int a)
+{
+  return foo (a) + 44;
+}
+
+int
+preload (int a)
+{
+  int (*fp) (int) = dlsym (RTLD_NEXT, "preload");
+  if (fp != NULL)
+    return fp (a) + 10;
+  return 10;
+}
Index: trunk/src/libctests/glibc/elf/testobj6.c
===================================================================
--- trunk/src/libctests/glibc/elf/testobj6.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/testobj6.c	(revision 2036)
@@ -0,0 +1,19 @@
+#include "testobj.h"
+
+int
+obj6func1 (int a __attribute__ ((unused)))
+{
+  return 77;
+}
+
+int
+obj6func2 (int a)
+{
+  return foo (a) + 46;
+}
+
+int
+preload (int a)
+{
+  return a;
+}
Index: trunk/src/libctests/glibc/elf/tst-align.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-align.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-align.c	(revision 2036)
@@ -0,0 +1,54 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static int
+do_test (void)
+{
+  static const char modname[] = "tst-alignmod.so";
+  int result = 0;
+  void (*fp) (int *);
+  void *h;
+
+  h = dlopen (modname, RTLD_LAZY);
+  if (h == NULL)
+    {
+      printf ("cannot open '%s': %s\n", modname, dlerror ());
+      exit (1);
+    }
+
+  fp = dlsym (h, "in_dso");
+  if (fp == NULL)
+    {
+      printf ("cannot get symbol 'in_dso': %s\n", dlerror ());
+      exit (1);
+    }
+
+  fp (&result);
+
+  dlclose (h);
+
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/elf/tst-align2.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-align2.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-align2.c	(revision 2036)
@@ -0,0 +1,157 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2005.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <tst-stack-align.h>
+#include <unistd.h>
+
+static int res, fds[2], result;
+static bool test_destructors;
+
+extern void in_dso (int *, bool *, int *);
+
+static void __attribute__ ((constructor)) con (void)
+{
+  res = TEST_STACK_ALIGN () ? -1 : 1;
+}
+
+static void __attribute__ ((destructor)) des (void)
+{
+  if (!test_destructors)
+    return;
+
+  char c = TEST_STACK_ALIGN () ? 'B' : 'A';
+  write (fds[1], &c, 1);
+}
+
+static int
+do_test (void)
+{
+  if (!res)
+    {
+      puts ("binary's constructor has not been run");
+      result = 1;
+    }
+  else if (res != 1)
+    {
+      puts ("binary's constructor has been run without sufficient alignment");
+      result = 1;
+    }
+
+  if (TEST_STACK_ALIGN ())
+    {
+      puts ("insufficient stack alignment in do_test");
+      result = 1;
+    }
+
+  in_dso (&result, &test_destructors, &fds[1]);
+
+  if (pipe (fds) < 0)
+    {
+      printf ("couldn't create pipe: %m\n");
+      return 1;
+    }
+
+  pid_t pid = fork ();
+  if (pid < 0)
+    {
+      printf ("fork failed: %m\n");
+      return 1;
+    }
+
+  if (!pid)
+    {
+      close (fds[0]);
+      test_destructors = true;
+      exit (0);
+    }
+
+  close (fds[1]);
+
+  unsigned char c;
+  ssize_t len;
+  int des_seen = 0, dso_des_seen = 0;
+  while ((len = TEMP_FAILURE_RETRY (read (fds[0], &c, 1))) > 0)
+    {
+      switch (c)
+        {
+        case 'B':
+          puts ("insufficient alignment in binary's destructor");
+          result = 1;
+          /* FALLTHROUGH */
+        case 'A':
+          des_seen++;
+          break;
+        case 'D':
+          puts ("insufficient alignment in DSO destructor");
+          result = 1;
+          /* FALLTHROUGH */
+        case 'C':
+          dso_des_seen++;
+          break;
+        default:
+          printf ("unexpected character %x read from pipe", c);
+          result = 1;
+          break;
+        }
+    }
+
+  close (fds[0]);
+
+  if (des_seen != 1)
+    {
+      printf ("binary destructor run %d times instead of once\n", des_seen);
+      result = 1;
+    }
+
+  if (dso_des_seen != 1)
+    {
+      printf ("DSO destructor run %d times instead of once\n", dso_des_seen);
+      result = 1;
+    }
+
+  int status;
+  pid_t termpid;
+  termpid = TEMP_FAILURE_RETRY (waitpid (pid, &status, 0));
+  if (termpid == -1)
+    {
+      printf ("waitpid failed: %m\n");
+      result = 1;
+    }
+  else if (termpid != pid)
+    {
+      printf ("waitpid returned %ld != %ld\n",
+	      (long int) termpid, (long int) pid);
+      result = 1;
+    }
+  else if (!WIFEXITED (status) || WEXITSTATUS (status))
+    {
+      puts ("child hasn't exited with exit status 0");
+      result = 1;
+    }
+
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/elf/tst-alignmod.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-alignmod.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-alignmod.c	(revision 2036)
@@ -0,0 +1,53 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <tst-stack-align.h>
+
+static int res, *resp;
+
+static void __attribute__((constructor))
+con (void)
+{
+  res = TEST_STACK_ALIGN () ? -1 : 1;
+}
+
+void
+in_dso (int *result)
+{
+  if (!res)
+    {
+      puts ("constructor has not been run");
+      *result = 1;
+    }
+  else if (res != 1)
+    {
+      puts ("constructor has been run without sufficient alignment");
+      *result = 1;
+    }
+
+  resp = result;
+}
+
+static void __attribute__((destructor))
+des (void)
+{
+  if (TEST_STACK_ALIGN ())
+    *resp = 1;
+}
Index: trunk/src/libctests/glibc/elf/tst-alignmod2.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-alignmod2.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-alignmod2.c	(revision 2036)
@@ -0,0 +1,60 @@
+/* Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <tst-stack-align.h>
+#include <unistd.h>
+
+static int res, *fdp;
+static bool *test_destructorsp;
+
+static void __attribute__((constructor))
+con (void)
+{
+  res = TEST_STACK_ALIGN () ? -1 : 1;
+}
+
+void
+in_dso (int *result, bool *test_destructors, int *fd)
+{
+  if (!res)
+    {
+      puts ("constructor has not been run");
+      *result = 1;
+    }
+  else if (res != 1)
+    {
+      puts ("constructor has been run without sufficient alignment");
+      *result = 1;
+    }
+
+  test_destructorsp = test_destructors;
+  fdp = fd;
+}
+
+static void __attribute__((destructor))
+des (void)
+{
+  if (!test_destructorsp || !*test_destructorsp)
+    return;
+
+  char c = TEST_STACK_ALIGN () ? 'D' : 'C';
+  write (*fdp, &c, 1);
+}
Index: trunk/src/libctests/glibc/elf/tst-array1-static.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-array1-static.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-array1-static.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-array1.c"
Index: trunk/src/libctests/glibc/elf/tst-array1.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-array1.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-array1.c	(revision 2036)
@@ -0,0 +1,101 @@
+#include <unistd.h>
+
+static void init (void) __attribute__ ((constructor));
+
+static void
+init (void)
+{
+  write (STDOUT_FILENO, "init\n", 5);
+}
+
+static void fini (void) __attribute__ ((destructor));
+
+static void
+fini (void)
+{
+  write (STDOUT_FILENO, "fini\n", 5);
+}
+
+static void
+preinit_0 (void)
+{
+  write (STDOUT_FILENO, "preinit array 0\n", 16);
+}
+
+static void
+preinit_1 (void)
+{
+  write (STDOUT_FILENO, "preinit array 1\n", 16);
+}
+
+static void
+preinit_2 (void)
+{
+  write (STDOUT_FILENO, "preinit array 2\n", 16);
+}
+
+void (*const preinit_array []) (void)
+     __attribute__ ((section (".preinit_array"), aligned (sizeof (void *)))) =
+{
+  &preinit_0,
+  &preinit_1,
+  &preinit_2
+};
+
+static void
+init_0 (void)
+{
+  write (STDOUT_FILENO, "init array 0\n", 13);
+}
+
+static void
+init_1 (void)
+{
+  write (STDOUT_FILENO, "init array 1\n", 13);
+}
+
+static void
+init_2 (void)
+{
+  write (STDOUT_FILENO, "init array 2\n", 13);
+}
+
+void (*const init_array []) (void)
+     __attribute__ ((section (".init_array"), aligned (sizeof (void *)))) =
+{
+  &init_0,
+  &init_1,
+  &init_2
+};
+
+static void
+fini_0 (void)
+{
+  write (STDOUT_FILENO, "fini array 0\n", 13);
+}
+
+static void
+fini_1 (void)
+{
+  write (STDOUT_FILENO, "fini array 1\n", 13);
+}
+
+static void
+fini_2 (void)
+{
+  write (STDOUT_FILENO, "fini array 2\n", 13);
+}
+
+void (*const fini_array []) (void)
+     __attribute__ ((section (".fini_array"), aligned (sizeof (void *)))) =
+{
+  &fini_0,
+  &fini_1,
+  &fini_2
+};
+
+int
+main (void)
+{
+  return 0;
+}
Index: trunk/src/libctests/glibc/elf/tst-array2.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-array2.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-array2.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-array1.c"
Index: trunk/src/libctests/glibc/elf/tst-array2dep.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-array2dep.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-array2dep.c	(revision 2036)
@@ -0,0 +1,69 @@
+#include <unistd.h>
+
+static void init (void) __attribute__ ((constructor));
+
+static void
+init (void)
+{
+  write (STDOUT_FILENO, "DSO init\n", 9);
+}
+
+static void fini (void) __attribute__ ((destructor));
+
+static void
+fini (void)
+{
+  write (STDOUT_FILENO, "DSO fini\n", 9);
+}
+
+static void
+init_0 (void)
+{
+  write (STDOUT_FILENO, "DSO init array 0\n", 17);
+}
+
+static void
+init_1 (void)
+{
+  write (STDOUT_FILENO, "DSO init array 1\n", 17);
+}
+
+static void
+init_2 (void)
+{
+  write (STDOUT_FILENO, "DSO init array 2\n", 17);
+}
+
+void (*const init_array []) (void)
+     __attribute__ ((section (".init_array"), aligned (sizeof (void *)))) =
+{
+  &init_0,
+  &init_1,
+  &init_2
+};
+
+static void
+fini_0 (void)
+{
+  write (STDOUT_FILENO, "DSO fini array 0\n", 17);
+}
+
+static void
+fini_1 (void)
+{
+  write (STDOUT_FILENO, "DSO fini array 1\n", 17);
+}
+
+static void
+fini_2 (void)
+{
+  write (STDOUT_FILENO, "DSO fini array 2\n", 17);
+}
+
+void (*const fini_array []) (void)
+     __attribute__ ((section (".fini_array"), aligned (sizeof (void *)))) =
+{
+  &fini_0,
+  &fini_1,
+  &fini_2
+};
Index: trunk/src/libctests/glibc/elf/tst-array3.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-array3.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-array3.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-array1.c"
Index: trunk/src/libctests/glibc/elf/tst-array4.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-array4.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-array4.c	(revision 2036)
@@ -0,0 +1,18 @@
+#include <dlfcn.h>
+
+#define main array1_main
+#include "tst-array1.c"
+#undef main
+
+int
+main (void)
+{
+  void *handle = dlopen ("tst-array2dep.so", RTLD_LAZY);
+
+  array1_main ();
+
+  if (handle != NULL)
+    dlclose (handle);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/elf/tst-audit1.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-audit1.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-audit1.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "../io/pwd.c"
Index: trunk/src/libctests/glibc/elf/tst-auditmod1.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-auditmod1.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-auditmod1.c	(revision 2036)
@@ -0,0 +1,220 @@
+#include <dlfcn.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <bits/wordsize.h>
+#include <gnu/lib-names.h>
+
+
+unsigned int
+la_version (unsigned int v)
+{
+  setlinebuf (stdout);
+
+  printf ("version: %u\n", v);
+
+  char buf[20];
+  sprintf (buf, "%u", v);
+
+  return v;
+}
+
+void
+la_activity (uintptr_t *cookie, unsigned int flag)
+{
+  if (flag == LA_ACT_CONSISTENT)
+    printf ("activity: consistent\n");
+  else if (flag == LA_ACT_ADD)
+    printf ("activity: add\n");
+  else if (flag == LA_ACT_DELETE)
+    printf ("activity: delete\n");
+  else
+    printf ("activity: unknown activity %u\n", flag);
+}
+
+char *
+la_objsearch (const char *name, uintptr_t *cookie, unsigned int flag)
+{
+  char buf[100];
+  const char *flagstr;
+  if (flag == LA_SER_ORIG)
+    flagstr = "LA_SET_ORIG";
+  else if (flag == LA_SER_LIBPATH)
+    flagstr = "LA_SER_LIBPATH";
+  else if (flag == LA_SER_RUNPATH)
+    flagstr = "LA_SER_RUNPATH";
+  else if (flag == LA_SER_CONFIG)
+    flagstr = "LA_SER_CONFIG";
+  else if (flag == LA_SER_DEFAULT)
+    flagstr = "LA_SER_DEFAULT";
+  else if (flag == LA_SER_SECURE)
+    flagstr = "LA_SER_SECURE";
+  else
+    {
+       sprintf (buf, "unknown flag %d", flag);
+       flagstr = buf;
+    }
+  printf ("objsearch: %s, %s\n", name, flagstr);
+
+  return (char *) name;
+}
+
+unsigned int
+la_objopen (struct link_map *l, Lmid_t lmid, uintptr_t *cookie)
+{
+  printf ("objopen: %ld, %s\n", lmid, l->l_name);
+
+  return 3;
+}
+
+void
+la_preinit (uintptr_t *cookie)
+{
+  printf ("preinit\n");
+}
+
+unsigned int
+la_objclose  (uintptr_t *cookie)
+{
+  printf ("objclose\n");
+  return 0;
+}
+
+uintptr_t
+la_symbind32 (Elf32_Sym *sym, unsigned int ndx, uintptr_t *refcook,
+	      uintptr_t *defcook, unsigned int *flags, const char *symname)
+{
+  printf ("symbind32: symname=%s, st_value=%#lx, ndx=%u, flags=%u\n",
+	  symname, (long int) sym->st_value, ndx, *flags);
+
+  return sym->st_value;
+}
+
+uintptr_t
+la_symbind64 (Elf64_Sym *sym, unsigned int ndx, uintptr_t *refcook,
+	      uintptr_t *defcook, unsigned int *flags, const char *symname)
+{
+  printf ("symbind64: symname=%s, st_value=%#lx, ndx=%u, flags=%u\n",
+	  symname, (long int) sym->st_value, ndx, *flags);
+
+  return sym->st_value;
+}
+
+#ifdef __i386__
+# define pltenter la_i86_gnu_pltenter
+# define pltexit la_i86_gnu_pltexit
+# define La_regs La_i86_regs
+# define La_retval La_i86_retval
+# define int_retval lrv_eax
+#elif defined __x86_64__
+# define pltenter la_x86_64_gnu_pltenter
+# define pltexit la_x86_64_gnu_pltexit
+# define La_regs La_x86_64_regs
+# define La_retval La_x86_64_retval
+# define int_retval lrv_rax
+#elif defined __powerpc__ && __WORDSIZE == 32
+# define pltenter la_ppc32_gnu_pltenter
+# define pltexit la_ppc32_gnu_pltexit
+# define La_regs La_ppc32_regs
+# define La_retval La_ppc32_retval
+# define int_retval lrv_r3
+#elif defined __powerpc__ && __WORDSIZE == 64
+# define pltenter la_ppc64_gnu_pltenter
+# define pltexit la_ppc64_gnu_pltexit
+# define La_regs La_ppc64_regs
+# define La_retval La_ppc64_retval
+# define int_retval lrv_r3
+#elif defined __sh__
+# define pltenter la_sh_gnu_pltenter
+# define pltexit la_sh_gnu_pltexit
+# define La_regs La_sh_regs
+# define La_retval La_sh_retval
+# define int_retval lrv_r0
+#elif defined __mc68000__
+# define pltenter la_m68k_gnu_pltenter
+# define pltexit la_m68k_gnu_pltexit
+# define La_regs La_m68k_regs
+# define La_retval La_m68k_retval
+# define int_retval lrv_d0
+#elif defined __alpha__
+# define pltenter la_alpha_gnu_pltenter
+# define pltexit la_alpha_gnu_pltexit
+# define La_regs La_alpha_regs
+# define La_retval La_alpha_retval
+# define int_retval lrv_r0
+#elif defined __s390__ && __WORDSIZE == 32
+# define pltenter la_s390_32_gnu_pltenter
+# define pltexit la_s390_32_gnu_pltexit
+# define La_regs La_s390_32_regs
+# define La_retval La_s390_32_retval
+# define int_retval lrv_r2
+#elif defined __s390__ && __WORDSIZE == 64
+# define pltenter la_s390_64_gnu_pltenter
+# define pltexit la_s390_64_gnu_pltexit
+# define La_regs La_s390_64_regs
+# define La_retval La_s390_64_retval
+# define int_retval lrv_r2
+#elif defined __ia64__
+# define pltenter la_ia64_gnu_pltenter
+# define pltexit la_ia64_gnu_pltexit
+# define La_regs La_ia64_regs
+# define La_retval La_ia64_retval
+# define int_retval lrv_r8
+#elif defined __mips__ && _MIPS_SIM == _ABIO32
+# define pltenter la_mips_o32_gnu_pltenter
+# define pltexit la_mips_o32_gnu_pltexit
+# define La_regs La_mips_32_regs
+# define La_retval La_mips_32_retval
+# define int_retval lrv_v0
+#elif defined __mips__ && _MIPS_SIM == _ABIN32
+# define pltenter la_mips_n32_gnu_pltenter
+# define pltexit la_mips_n32_gnu_pltexit
+# define La_regs La_mips_64_regs
+# define La_retval La_mips_64_retval
+# define int_retval lrv_v0
+#elif defined __mips__ && _MIPS_SIM == _ABI64
+# define pltenter la_mips_n64_gnu_pltenter
+# define pltexit la_mips_n64_gnu_pltexit
+# define La_regs La_mips_64_regs
+# define La_retval La_mips_64_retval
+# define int_retval lrv_v0
+#elif defined __sparc__ && __WORDSIZE == 32
+# define pltenter la_sparc32_gnu_pltenter
+# define pltexit la_sparc32_gnu_pltexit
+# define La_regs La_sparc32_regs
+# define La_retval La_sparc32_retval
+# define int_retval lrv_reg[0]
+#elif defined __sparc__ && __WORDSIZE == 64
+# define pltenter la_sparc64_gnu_pltenter
+# define pltexit la_sparc64_gnu_pltexit
+# define La_regs La_sparc64_regs
+# define La_retval La_sparc64_retval
+# define int_retval lrv_reg[0]
+#else
+# error "architecture specific code needed"
+#endif
+
+
+ElfW(Addr)
+pltenter (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
+	  uintptr_t *defcook, La_regs *regs, unsigned int *flags,
+	  const char *symname, long int *framesizep)
+{
+  printf ("pltenter: symname=%s, st_value=%#lx, ndx=%u, flags=%u\n",
+	  symname, (long int) sym->st_value, ndx, *flags);
+
+  return sym->st_value;
+}
+
+unsigned int
+pltexit (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
+	 uintptr_t *defcook, const La_regs *inregs, La_retval *outregs,
+	 const char *symname)
+{
+  printf ("pltexit: symname=%s, st_value=%#lx, ndx=%u, retval=%tu\n",
+	  symname, (long int) sym->st_value, ndx, outregs->int_retval);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/elf/tst-deep1.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-deep1.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-deep1.c	(revision 2036)
@@ -0,0 +1,36 @@
+#include <dlfcn.h>
+#include <stdio.h>
+
+int
+xyzzy (void)
+{
+  printf ("%s:%s\n", __FILE__, __func__);
+  return 21;
+}
+
+int
+back (void)
+{
+  printf ("%s:%s\n", __FILE__, __func__);
+  return 1;
+}
+
+extern int foo (void);
+
+static int
+do_test (void)
+{
+  void *p = dlopen ("$ORIGIN/tst-deep1mod2.so", RTLD_LAZY|RTLD_DEEPBIND);
+
+  int (*f) (void) = dlsym (p, "bar");
+  if (f == NULL)
+    {
+      puts (dlerror ());
+      return 1;
+    }
+
+  return foo () + f ();
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/elf/tst-deep1mod1.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-deep1mod1.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-deep1mod1.c	(revision 2036)
@@ -0,0 +1,14 @@
+#include <stdio.h>
+int
+foo (void)
+{
+  printf ("%s:%s\n", __FILE__, __func__);
+  return 1;
+}
+
+int
+baz (void)
+{
+  printf ("%s:%s\n", __FILE__, __func__);
+  return 20;
+}
Index: trunk/src/libctests/glibc/elf/tst-deep1mod2.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-deep1mod2.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-deep1mod2.c	(revision 2036)
@@ -0,0 +1,16 @@
+#include <stdio.h>
+extern int baz (void);
+extern int xyzzy (void);
+int
+bar (void)
+{
+  printf ("%s:%s\n", __FILE__, __func__);
+  return baz () + xyzzy ();;
+}
+
+int
+back (void)
+{
+  printf ("%s:%s\n", __FILE__, __func__);
+  return -1;
+}
Index: trunk/src/libctests/glibc/elf/tst-deep1mod3.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-deep1mod3.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-deep1mod3.c	(revision 2036)
@@ -0,0 +1,17 @@
+#include <stdio.h>
+
+extern int back (void);
+
+int
+baz (void)
+{
+  printf ("%s:%s\n", __FILE__, __func__);
+  return back ();
+}
+
+int
+xyzzy (void)
+{
+  printf ("%s:%s\n", __FILE__, __func__);
+  return 0;
+}
Index: trunk/src/libctests/glibc/elf/tst-dlmodcount.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-dlmodcount.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-dlmodcount.c	(revision 2036)
@@ -0,0 +1,107 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by David Mosberger <davidm@hpl.hp.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <link.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define SET	0
+#define ADD	1
+#define REMOVE	2
+
+#define leq(l,r)	(((r) - (l)) <= ~0ULL / 2)
+
+static int
+callback (struct dl_phdr_info *info, size_t size, void *ptr)
+{
+  static int last_adds = 0, last_subs = 0;
+  intptr_t cmd = (intptr_t) ptr;
+
+  printf ("  size = %Zu\n", size);
+  if (size < (offsetof (struct dl_phdr_info, dlpi_subs)
+	      + sizeof (info->dlpi_subs)))
+    {
+      fprintf (stderr, "dl_iterate_phdr failed to pass dlpi_adds/dlpi_subs\n");
+      exit (5);
+    }
+
+  printf ("  dlpi_adds = %Lu dlpi_subs = %Lu\n",
+	  info->dlpi_adds, info->dlpi_subs);
+
+  switch (cmd)
+    {
+    case SET:
+      break;
+
+    case ADD:
+      if (leq (info->dlpi_adds, last_adds))
+	{
+	  fprintf (stderr, "dlpi_adds failed to get incremented!\n");
+	  exit (3);
+	}
+      break;
+
+    case REMOVE:
+      if (leq (info->dlpi_subs, last_subs))
+	{
+	  fprintf (stderr, "dlpi_subs failed to get incremented!\n");
+	  exit (4);
+	}
+      break;
+    }
+  last_adds = info->dlpi_adds;
+  last_subs = info->dlpi_subs;
+  return -1;
+}
+
+static void *
+load (const char *path)
+{
+  void *handle;
+
+  printf ("loading `%s'\n", path);
+  handle = dlopen (path, RTLD_LAZY);
+  if (!handle)
+    exit (1);
+  dl_iterate_phdr (callback, (void *)(intptr_t) ADD);
+  return handle;
+}
+
+static void
+unload (const char *path, void *handle)
+{
+  printf ("unloading `%s'\n", path);
+  if (dlclose (handle) < 0)
+    exit (2);
+  dl_iterate_phdr (callback, (void *)(intptr_t) REMOVE);
+}
+
+int
+main (int argc, char **argv)
+{
+  void *handle1, *handle2;
+
+  dl_iterate_phdr (callback, (void *)(intptr_t) SET);
+  handle1 = load ("firstobj.so");
+  handle2 = load ("globalmod1.so");
+  unload ("firstobj.so", handle1);
+  unload ("globalmod1.so", handle2);
+  return 0;
+}
Index: trunk/src/libctests/glibc/elf/tst-dlmopen1.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-dlmopen1.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-dlmopen1.c	(revision 2036)
@@ -0,0 +1,80 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <gnu/lib-names.h>
+
+
+static int
+do_test (void)
+{
+  void *h = dlopen (LIBC_SO, RTLD_LAZY|RTLD_NOLOAD);
+  if (h == NULL)
+    {
+      printf ("cannot get handle for %s: %s\n", LIBC_SO, dlerror ());
+      return 1;
+    }
+
+  Lmid_t ns = -10;
+  if (dlinfo (h, RTLD_DI_LMID, &ns) != 0)
+    {
+      printf ("dlinfo for %s in %s failed: %s\n",
+	      LIBC_SO, __func__, dlerror ());
+      return 1;
+    }
+
+  if (ns != LM_ID_BASE)
+    {
+      printf ("namespace for %s not LM_ID_BASE\n", LIBC_SO);
+      return 1;
+    }
+
+  if (dlclose (h) != 0)
+    {
+      printf ("dlclose for %s in %s failed: %s\n",
+	      LIBC_SO, __func__, dlerror ());
+      return 1;
+    }
+
+  h = dlmopen (LM_ID_NEWLM, "$ORIGIN/tst-dlmopen1mod.so", RTLD_LAZY);
+  if (h == NULL)
+    {
+      printf ("cannot get handle for %s: %s\n",
+	      "tst-dlmopen1mod.so", dlerror ());
+      return 1;
+    }
+
+  ns = -10;
+  if (dlinfo (h, RTLD_DI_LMID, &ns) != 0)
+    {
+      printf ("dlinfo for %s in %s failed: %s\n",
+	      "tst-dlmopen1mod.so", __func__, dlerror ());
+      return 1;
+    }
+
+  if (ns == LM_ID_BASE)
+    {
+      printf ("namespace for %s is LM_ID_BASE\n", LIBC_SO);
+      return 1;
+    }
+
+  int (*fct) (Lmid_t) = dlsym (h, "foo");
+  if (fct == NULL)
+    {
+      printf ("could not find %s: %s\n", "foo", dlerror ());
+      return 1;
+    }
+
+  if (fct (ns) != 0)
+    return 1;
+
+  if (dlclose (h) != 0)
+    {
+      printf ("dlclose for %s in %s failed: %s\n",
+	      LIBC_SO, __func__, dlerror ());
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/elf/tst-dlmopen1mod.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-dlmopen1mod.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-dlmopen1mod.c	(revision 2036)
@@ -0,0 +1,59 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <gnu/lib-names.h>
+
+
+static int cnt;
+
+static void
+__attribute ((constructor))
+constr (void)
+{
+  ++cnt;
+}
+
+
+int
+foo (Lmid_t ns2)
+{
+  void *h = dlopen (LIBC_SO, RTLD_LAZY|RTLD_NOLOAD);
+  if (h == NULL)
+    {
+      printf ("cannot get handle for %s: %s\n", LIBC_SO, dlerror ());
+      return 1;
+    }
+
+  Lmid_t ns = -10;
+  if (dlinfo (h, RTLD_DI_LMID, &ns) != 0)
+    {
+      printf ("dlinfo for %s in %s failed: %s\n",
+	      LIBC_SO, __func__, dlerror ());
+      return 1;
+    }
+
+  if (ns != ns2)
+    {
+      printf ("namespace for %s not LM_ID_BASE\n", LIBC_SO);
+      return 1;
+    }
+
+  if (dlclose (h) != 0)
+    {
+      printf ("dlclose for %s in %s failed: %s\n",
+	      LIBC_SO, __func__, dlerror ());
+      return 1;
+    }
+
+  if (cnt == 0)
+    {
+      puts ("constructor did not run");
+      return 1;
+    }
+  else if (cnt != 1)
+    {
+      puts ("constructor did not run exactly once");
+      return 1;
+    }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/elf/tst-dlmopen2.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-dlmopen2.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-dlmopen2.c	(revision 2036)
@@ -0,0 +1,70 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <string.h>
+#include <gnu/lib-names.h>
+#include <ldsodefs.h>
+
+
+static int
+do_test (void)
+{
+  int result = 0;
+
+  for (int i = 1; i <= 10; ++i)
+    {
+      void *h[DL_NNS - 1];
+      char used[DL_NNS];
+
+      printf ("round %d\n", i);
+
+      memset (used, '\0', sizeof (used));
+      used[LM_ID_BASE] = 1;
+
+      for (int j = 0; j < DL_NNS - 1; ++j)
+	{
+	  h[j] = dlmopen (LM_ID_NEWLM, "$ORIGIN/tst-dlmopen1mod.so",
+			  RTLD_LAZY);
+	  if (h[j] == NULL)
+	    {
+	      printf ("round %d, namespace %d: load failed: %s\n",
+		      i, j, dlerror ());
+	      return 1;
+	    }
+	  Lmid_t ns;
+	  if (dlinfo (h[j], RTLD_DI_LMID, &ns) != 0)
+	    {
+	      printf ("round %d, namespace %d: dlinfo failed: %s\n",
+		      i, j, dlerror ());
+	      return 1;
+	    }
+	  if (ns < 0 || ns >= DL_NNS)
+	    {
+	      printf ("round %d, namespace %d: invalid namespace %ld",
+		      i, j, (long int) ns);
+	      result = 1;
+	    }
+	  else if (used[ns] != 0)
+	    {
+	      printf ("\
+round %d, namespace %d: duplicate allocate of namespace %ld",
+		      i, j, (long int) ns);
+	      result = 1;
+	    }
+	  else
+	    used[ns] = 1;
+	}
+
+      for (int j = 0; j < DL_NNS - 1; ++j)
+	if (dlclose (h[j]) != 0)
+	  {
+	    printf ("round %d, namespace %d: close failed: %s\n",
+		    i, j, dlerror ());
+	    return 1;
+	  }
+    }
+
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/elf/tst-dlmopen3.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-dlmopen3.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-dlmopen3.c	(revision 2036)
@@ -0,0 +1,22 @@
+#include <dlfcn.h>
+#include <stdio.h>
+
+
+static int
+do_test (void)
+{
+  void *h = dlmopen (LM_ID_NEWLM, "$ORIGIN/tst-dlmopen1mod.so", RTLD_LAZY);
+  if (h == NULL)
+    {
+      printf ("cannot get handle for %s: %s\n",
+	      "tst-dlmopen1mod.so", dlerror ());
+      return 1;
+    }
+
+  /* Do not unload.  */
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/elf/tst-dlopenrpath.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-dlopenrpath.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-dlopenrpath.c	(revision 2036)
@@ -0,0 +1,72 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <dlfcn.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+
+extern int foo (void);
+
+static const char testsubdir[] = PFX "test-subdir";
+
+
+static int
+do_test (void)
+{
+  struct stat64 st;
+  int result = 1;
+
+  if (mkdir (testsubdir, 0777) != 0
+      && (errno != EEXIST
+	  || stat64 (testsubdir, &st) != 0
+	  || !S_ISDIR (st.st_mode)))
+    {
+      printf ("cannot create directory %s\n", testsubdir);
+      return 1;
+    }
+
+  if (system ("cp " PFX "firstobj.so " PFX "test-subdir/in-subdir.so") != 0)
+    {
+      puts ("cannot copy DSO");
+      return 1;
+    }
+
+  void *p = dlopen ("in-subdir.so", RTLD_LAZY|RTLD_LOCAL);
+  if (p != NULL)
+    {
+      puts ("succeeded in opening in-subdir.so from do_test");
+      dlclose (p);
+      goto out;
+    }
+
+  result = foo ();
+
+ out:
+  unlink (PFX "test-subdir/in-subdir.so");
+  rmdir (testsubdir);
+
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/elf/tst-dlopenrpathmod.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-dlopenrpathmod.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-dlopenrpathmod.c	(revision 2036)
@@ -0,0 +1,36 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <dlfcn.h>
+#include <stdio.h>
+
+
+int
+foo (void)
+{
+  void *p = dlopen ("in-subdir.so", RTLD_LAZY|RTLD_LOCAL);
+  if (p != NULL)
+    {
+      dlclose (p);
+      return 0;
+    }
+
+  puts ("couldn't open in-subdir.so from foo");
+  return 1;
+}
Index: trunk/src/libctests/glibc/elf/tst-execstack-mod.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-execstack-mod.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-execstack-mod.c	(revision 2036)
@@ -0,0 +1,30 @@
+/* Test module for making nonexecutable stacks executable
+   on load of a DSO that requires executable stacks.  */
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+void callme (void (*callback) (void));
+
+/* This is a function that makes use of executable stack by
+   using a local function trampoline.  */
+void
+tryme (void)
+{
+  bool ok = false;
+  void callback (void) { ok = true; }
+
+  callme (&callback);
+
+  if (ok)
+    printf ("DSO called ok (local %p, trampoline %p)\n", &ok, &callback);
+  else
+    abort ();
+}
+
+void
+callme (void (*callback) (void))
+{
+  (*callback) ();
+}
Index: trunk/src/libctests/glibc/elf/tst-execstack-needed.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-execstack-needed.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-execstack-needed.c	(revision 2036)
@@ -0,0 +1,36 @@
+/* Test program for making nonexecutable stacks executable
+   on DT_NEEDED load of a DSO that requires executable stacks.  */
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <error.h>
+
+extern void tryme (void);	/* from tst-execstack-mod.so */
+
+static void deeper (void (*f) (void));
+
+static int
+do_test (void)
+{
+  tryme ();
+
+  /* Test that growing the stack region gets new executable pages too.  */
+  deeper (&tryme);
+
+  return 0;
+}
+
+static void
+deeper (void (*f) (void))
+{
+  char stack[1100 * 1024];
+  memfrob (stack, sizeof stack);
+  (*f) ();
+  memfrob (stack, sizeof stack);
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/elf/tst-execstack-prog.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-execstack-prog.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-execstack-prog.c	(revision 2036)
@@ -0,0 +1,35 @@
+/* Test program for executable stacks in an executable itself.  */
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <error.h>
+
+#include "tst-execstack-mod.c"	/* This defines the `tryme' test function.  */
+
+static void deeper (void (*f) (void));
+
+static int
+do_test (void)
+{
+  tryme ();
+
+  /* Test that growing the stack region gets new executable pages too.  */
+  deeper (&tryme);
+
+  return 0;
+}
+
+static void
+deeper (void (*f) (void))
+{
+  char stack[1100 * 1024];
+  memfrob (stack, sizeof stack);
+  (*f) ();
+  memfrob (stack, sizeof stack);
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/elf/tst-execstack.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-execstack.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-execstack.c	(revision 2036)
@@ -0,0 +1,133 @@
+/* Test program for making nonexecutable stacks executable
+   on load of a DSO that requires executable stacks.  */
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <error.h>
+
+static void
+print_maps (void)
+{
+#if 0
+  char *cmd = NULL;
+  asprintf (&cmd, "cat /proc/%d/maps", getpid ());
+  system (cmd);
+  free (cmd);
+#endif
+}
+
+static void deeper (void (*f) (void));
+
+#if USE_PTHREADS
+# include <pthread.h>
+
+static void *
+tryme_thread (void *f)
+{
+  (*((void (*) (void)) f)) ();
+
+  return 0;
+}
+
+static pthread_barrier_t startup_barrier, go_barrier;
+static void *
+waiter_thread (void *arg)
+{
+  void **f = arg;
+  pthread_barrier_wait (&startup_barrier);
+  pthread_barrier_wait (&go_barrier);
+
+  (*((void (*) (void)) *f)) ();
+
+  return 0;
+}
+#endif
+
+static int
+do_test (void)
+{
+  static void *f;		/* Address of this is used in other threads. */
+
+#if USE_PTHREADS
+  /* Create some threads while stacks are nonexecutable.  */
+  #define N 5
+  pthread_t thr[N];
+
+  pthread_barrier_init (&startup_barrier, NULL, N + 1);
+  pthread_barrier_init (&go_barrier, NULL, N + 1);
+
+  for (int i = 0; i < N; ++i)
+    {
+      int rc = pthread_create (&thr[i], NULL, &waiter_thread, &f);
+      if (rc)
+	error (1, rc, "pthread_create");
+    }
+
+  /* Make sure they are all there using their stacks.  */
+  pthread_barrier_wait (&startup_barrier);
+  puts ("threads waiting");
+#endif
+
+  print_maps ();
+
+  /* Loading this module should force stacks to become executable.  */
+  void *h = dlopen ("tst-execstack-mod.so", RTLD_LAZY);
+  if (h == NULL)
+    {
+      printf ("cannot load: %s\n", dlerror ());
+      return 1;
+    }
+
+  f = dlsym (h, "tryme");
+  if (f == NULL)
+    {
+      printf ("symbol not found: %s\n", dlerror ());
+      return 1;
+    }
+
+  /* Test if that really made our stack executable.
+     The `tryme' function should crash if not.  */
+
+  (*((void (*) (void)) f)) ();
+
+  print_maps ();
+
+  /* Test that growing the stack region gets new executable pages too.  */
+  deeper ((void (*) (void)) f);
+
+  print_maps ();
+
+#if USE_PTHREADS
+  /* Test that a fresh thread now gets an executable stack.  */
+  {
+    pthread_t th;
+    int rc = pthread_create (&th, NULL, &tryme_thread, f);
+    if (rc)
+      error (1, rc, "pthread_create");
+  }
+
+  puts ("threads go");
+  /* The existing threads' stacks should have been changed.
+     Let them run to test it.  */
+  pthread_barrier_wait (&go_barrier);
+
+  pthread_exit (0);
+#endif
+
+  return 0;
+}
+
+static void
+deeper (void (*f) (void))
+{
+  char stack[1100 * 1024];
+  memfrob (stack, sizeof stack);
+  (*f) ();
+  memfrob (stack, sizeof stack);
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/elf/tst-global1.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-global1.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-global1.c	(revision 2036)
@@ -0,0 +1,36 @@
+#include <dlfcn.h>
+#include <stdio.h>
+
+int
+main (void)
+{
+  void *h1 = dlopen ("$ORIGIN/testobj6.so", RTLD_GLOBAL|RTLD_LAZY);
+  if (h1 == NULL)
+    {
+      puts ("cannot open testobj6");
+      return 1;
+    }
+
+  void *h2 = dlopen ("$ORIGIN/testobj2.so",
+		     RTLD_GLOBAL|RTLD_DEEPBIND|RTLD_LAZY);
+  if (h2 == NULL)
+    {
+      puts ("cannot open testobj2");
+      return 1;
+    }
+
+  dlclose (h1);
+
+  void (*f) (void) = dlsym (h2, "p");
+  if (f == NULL)
+    {
+      puts ("cannot find p");
+      return 1;
+    }
+
+  f ();
+
+  dlclose (h2);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/elf/tst-pathopt.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-pathopt.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-pathopt.c	(revision 2036)
@@ -0,0 +1,39 @@
+#include <dlfcn.h>
+#include <mcheck.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+int
+main (void)
+{
+  void *h;
+  int (*fp) (int);
+  int result;
+
+  mtrace ();
+
+  h = dlopen ("renamed.so", RTLD_LAZY);
+  if (h == NULL)
+    {
+      printf ("failed to load \"%s\": %s\n", "renamed.so", dlerror ());
+      exit (1);
+    }
+
+  fp = dlsym (h, "in_renamed");
+  if (fp == NULL)
+    {
+      printf ("lookup of \"%s\" failed: %s\n", "in_renamed", dlerror ());
+      exit (1);
+    }
+
+  result = fp (10);
+
+  if (dlclose (h) != 0)
+    {
+      printf ("failed to close \"%s\": %s\n", "renamed.so", dlerror ());
+      exit (1);
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/elf/tst-pathopt.sh
===================================================================
--- trunk/src/libctests/glibc/elf/tst-pathopt.sh	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-pathopt.sh	(revision 2036)
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Test lookup path optimization.
+# Copyright (C) 2000 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+common_objpfx=$1
+run_program_prefix=$2
+
+test -e ${common_objpfx}elf/will-be-empty &&
+  rm -fr ${common_objpfx}elf/will-be-empty
+test -d ${common_objpfx}elf/for-renamed ||
+  mkdir ${common_objpfx}elf/for-renamed
+
+cp ${common_objpfx}elf/pathoptobj.so ${common_objpfx}elf/for-renamed/renamed.so
+
+LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
+LC_ALL=C LD_LIBRARY_PATH=${common_objpfx}elf/will-be-empty:${common_objpfx}elf/for-renamed:${common_objpfx}.:${common_objpfx}dlfcn \
+  ${common_objpfx}elf/ld.so ${common_objpfx}elf/tst-pathopt \
+    > ${common_objpfx}elf/tst-pathopt.out
+
+exit $?
Index: trunk/src/libctests/glibc/elf/tst-pie1.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-pie1.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-pie1.c	(revision 2036)
@@ -0,0 +1,5 @@
+int
+foo (void)
+{
+  return 34;
+}
Index: trunk/src/libctests/glibc/elf/tst-piemod1.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-piemod1.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-piemod1.c	(revision 2036)
@@ -0,0 +1,20 @@
+#include <stdio.h>
+
+int
+foo (void)
+{
+  return 21;
+}
+
+int
+main (void)
+{
+  int val = foo ();
+  if (val != 34)
+    {
+      printf ("foo () returned %d\n", val);
+      return 1;
+    }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/elf/tst-tls1-static.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tls1-static.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tls1-static.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-tls1.c"
Index: trunk/src/libctests/glibc/elf/tst-tls1.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tls1.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tls1.c	(revision 2036)
@@ -0,0 +1,91 @@
+/* glibc test for TLS in ld.so.  */
+#include <stdio.h>
+
+#include <tls.h>
+
+#ifdef USE_TLS
+# include "tls-macros.h"
+
+
+/* Two common 'int' variables in TLS.  */
+COMMON_INT_DEF(foo);
+COMMON_INT_DEF(bar);
+#endif
+
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+#ifdef USE_TLS
+  int result = 0;
+  int *ap, *bp;
+
+
+  /* Set the variable using the local exec model.  */
+  puts ("set bar to 1 (LE)");
+  ap = TLS_LE (bar);
+  *ap = 1;
+
+
+  /* Get variables using initial exec model.  */
+  fputs ("get sum of foo and bar (IE)", stdout);
+  ap = TLS_IE (foo);
+  bp = TLS_IE (bar);
+  printf (" = %d\n", *ap + *bp);
+  result |= *ap + *bp != 1;
+  if (*ap != 0)
+    {
+      printf ("foo = %d\n", *ap);
+      result = 1;
+    }
+  if (*bp != 1)
+    {
+      printf ("bar = %d\n", *bp);
+      result = 1;
+    }
+
+
+  /* Get variables using local dynamic model.  */
+  fputs ("get sum of foo and bar (LD)", stdout);
+  ap = TLS_LD (foo);
+  bp = TLS_LD (bar);
+  printf (" = %d\n", *ap + *bp);
+  result |= *ap + *bp != 1;
+  if (*ap != 0)
+    {
+      printf ("foo = %d\n", *ap);
+      result = 1;
+    }
+  if (*bp != 1)
+    {
+      printf ("bar = %d\n", *bp);
+      result = 1;
+    }
+
+
+  /* Get variables using generic dynamic model.  */
+  fputs ("get sum of foo and bar (GD)", stdout);
+  ap = TLS_GD (foo);
+  bp = TLS_GD (bar);
+  printf (" = %d\n", *ap + *bp);
+  result |= *ap + *bp != 1;
+  if (*ap != 0)
+    {
+      printf ("foo = %d\n", *ap);
+      result = 1;
+    }
+  if (*bp != 1)
+    {
+      printf ("bar = %d\n", *bp);
+      result = 1;
+    }
+
+  return result;
+#else
+  return 0;
+#endif
+}
+
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/elf/tst-tls10.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tls10.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tls10.c	(revision 2036)
@@ -0,0 +1,40 @@
+#include "tst-tls10.h"
+
+#ifdef USE_TLS__THREAD
+__thread int dummy __attribute__((visibility ("hidden"))) = 12;
+__thread struct A local = { 1, 2, 3 };
+#endif
+
+#define CHECK(N, S)					\
+  p = f##N##a ();					\
+  if (p->a != S || p->b != S + 1 || p->c != S + 2)	\
+    abort ()
+
+int
+main (void)
+{
+#ifdef USE_TLS__THREAD
+  struct A *p;
+  if (local.a != 1 || local.b != 2 || local.c != 3)
+    abort ();
+  if (a1.a != 4 || a1.b != 5 || a1.c != 6)
+    abort ();
+  if (a2.a != 22 || a2.b != 23 || a2.c != 24)
+    abort ();
+  if (a3.a != 10 || a3.b != 11 || a3.c != 12)
+    abort ();
+  if (a4.a != 25 || a4.b != 26 || a4.c != 27)
+    abort ();
+  check1 ();
+  check2 ();
+  if (f1a () != &a1 || f2a () != &a2 || f3a () != &a3 || f4a () != &a4)
+    abort ();
+  CHECK (5, 16);
+  CHECK (6, 19);
+  if (f7a () != &a2 || f8a () != &a4)
+    abort ();
+  CHECK (9, 28);
+  CHECK (10, 31);
+#endif
+  exit (0);
+}
Index: trunk/src/libctests/glibc/elf/tst-tls10.h
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tls10.h	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tls10.h	(revision 2036)
@@ -0,0 +1,38 @@
+#include <tls.h>
+#include <stdlib.h>
+
+#if defined USE_TLS && defined HAVE___THREAD \
+    && defined HAVE_TLS_MODEL_ATTRIBUTE
+# define USE_TLS__THREAD
+
+struct A
+{
+  char a;
+  int b;
+  long long c;
+};
+
+extern __thread struct A a1, a2, a3, a4;
+extern struct A *f1a (void);
+extern struct A *f2a (void);
+extern struct A *f3a (void);
+extern struct A *f4a (void);
+extern struct A *f5a (void);
+extern struct A *f6a (void);
+extern struct A *f7a (void);
+extern struct A *f8a (void);
+extern struct A *f9a (void);
+extern struct A *f10a (void);
+extern int f1b (void);
+extern int f2b (void);
+extern int f3b (void);
+extern int f4b (void);
+extern int f5b (void);
+extern int f6b (void);
+extern int f7b (void);
+extern int f8b (void);
+extern int f9b (void);
+extern int f10b (void);
+extern void check1 (void);
+extern void check2 (void);
+#endif
Index: trunk/src/libctests/glibc/elf/tst-tls11.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tls11.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tls11.c	(revision 2036)
@@ -0,0 +1,27 @@
+#include "tst-tls10.h"
+
+#define CHECK(N, S)					\
+  p = f##N##a ();					\
+  if (p->a != S || p->b != S + 1 || p->c != S + 2)	\
+    abort ()
+
+int
+main (void)
+{
+#ifdef USE_TLS__THREAD
+  struct A *p;
+  check1 ();
+  check2 ();
+  CHECK (1, 4);
+  CHECK (2, 22);
+  CHECK (3, 10);
+  CHECK (4, 25);
+  CHECK (5, 16);
+  CHECK (6, 19);
+  CHECK (7, 22);
+  CHECK (8, 25);
+  CHECK (9, 28);
+  CHECK (10, 31);
+#endif
+  exit (0);
+}
Index: trunk/src/libctests/glibc/elf/tst-tls12.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tls12.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tls12.c	(revision 2036)
@@ -0,0 +1,18 @@
+#include "tst-tls10.h"
+
+#define CHECK(N, S)					\
+  p = &a##N;						\
+  if (p->a != S || p->b != S + 1 || p->c != S + 2)	\
+    abort ()
+
+int
+main (void)
+{
+#ifdef USE_TLS__THREAD
+  struct A *p;
+  check1 ();
+  CHECK (1, 4);
+  CHECK (2, 7);
+#endif
+  exit (0);
+}
Index: trunk/src/libctests/glibc/elf/tst-tls13.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tls13.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tls13.c	(revision 2036)
@@ -0,0 +1,30 @@
+/* Check unloading modules with data in static TLS block.  */
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static int
+do_test (void)
+{
+  int i;
+  for (i = 0; i < 1000;)
+    {
+      printf ("round %d\n",++i);
+
+      void *h = dlopen ("tst-tlsmod13a.so", RTLD_LAZY);
+      if (h == NULL)
+	{
+	  printf ("cannot load: %s\n", dlerror ());
+	  exit (1);
+	}
+
+      dlclose (h);
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 3
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/elf/tst-tls14.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tls14.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tls14.c	(revision 2036)
@@ -0,0 +1,66 @@
+/* Check alignment of TLS variable.  */
+#include <dlfcn.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <tls.h>
+
+#if USE_TLS && HAVE___THREAD
+
+#define AL 4096
+struct foo
+{
+  int i;
+} __attribute ((aligned (AL)));
+
+static __thread struct foo f;
+static struct foo g;
+
+
+extern int in_dso1 (void);
+
+
+static int
+do_test (void)
+{
+  int result = 0;
+
+  int fail = (((uintptr_t) &f) & (AL - 1)) != 0;
+  printf ("&f = %p %s\n", &f, fail ? "FAIL" : "OK");
+  result |= fail;
+
+  fail = (((uintptr_t) &g) & (AL - 1)) != 0;
+  printf ("&g = %p %s\n", &g, fail ? "FAIL" : "OK");
+  result |= fail;
+
+  result |= in_dso1 ();
+
+  void *h = dlopen ("tst-tlsmod14b.so", RTLD_LAZY);
+  if (h == NULL)
+    {
+      printf ("cannot open tst-tlsmod14b.so: %m\n");
+      exit (1);
+    }
+
+  int (*fp) (void) = (int (*) (void)) dlsym (h, "in_dso2");
+  if (fp == NULL)
+    {
+      puts ("cannot find in_dso2");
+      exit (1);
+    }
+
+  result |= fp ();
+
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+
+#else
+
+#define TEST_FUNCTION 0
+
+#endif
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/elf/tst-tls15.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tls15.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tls15.c	(revision 2036)
@@ -0,0 +1,32 @@
+#include <dlfcn.h>
+#include <stdio.h>
+
+static int
+do_test (void)
+{
+  void *h = dlopen ("tst-tlsmod15a.so", RTLD_NOW);
+  if (h != NULL)
+    {
+      puts ("unexpectedly succeeded to open tst-tlsmod15a.so");
+      exit (1);
+    }
+
+  h = dlopen ("tst-tlsmod15b.so", RTLD_NOW);
+  if (h == NULL)
+    {
+      puts ("failed to open tst-tlsmod15b.so");
+      exit (1);
+    }
+
+  int (*fp) (void) = (int (*) (void)) dlsym (h, "in_dso");
+  if (fp == NULL)
+    {
+      puts ("cannot find in_dso");
+      exit (1);
+    }
+
+  return fp ();
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/elf/tst-tls2-static.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tls2-static.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tls2-static.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-tls2.c"
Index: trunk/src/libctests/glibc/elf/tst-tls2.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tls2.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tls2.c	(revision 2036)
@@ -0,0 +1,91 @@
+/* glibc test for TLS in ld.so.  */
+#include <stdio.h>
+
+#include <tls.h>
+
+#ifdef USE_TLS
+# include "tls-macros.h"
+
+
+/* Two 'int' variables in TLS.  */
+VAR_INT_DEF(foo);
+VAR_INT_DEF(bar);
+#endif
+
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+#ifdef USE_TLS
+  int result = 0;
+  int *ap, *bp;
+
+
+  /* Set the variable using the local exec model.  */
+  puts ("set bar to 1 (LE)");
+  ap = TLS_LE (bar);
+  *ap = 1;
+
+
+  /* Get variables using initial exec model.  */
+  fputs ("get sum of foo and bar (IE)", stdout);
+  ap = TLS_IE (foo);
+  bp = TLS_IE (bar);
+  printf (" = %d\n", *ap + *bp);
+  result |= *ap + *bp != 1;
+  if (*ap != 0)
+    {
+      printf ("foo = %d\n", *ap);
+      result = 1;
+    }
+  if (*bp != 1)
+    {
+      printf ("bar = %d\n", *bp);
+      result = 1;
+    }
+
+
+  /* Get variables using local dynamic model.  */
+  fputs ("get sum of foo and bar (LD)", stdout);
+  ap = TLS_LD (foo);
+  bp = TLS_LD (bar);
+  printf (" = %d\n", *ap + *bp);
+  result |= *ap + *bp != 1;
+  if (*ap != 0)
+    {
+      printf ("foo = %d\n", *ap);
+      result = 1;
+    }
+  if (*bp != 1)
+    {
+      printf ("bar = %d\n", *bp);
+      result = 1;
+    }
+
+
+  /* Get variables using generic dynamic model.  */
+  fputs ("get sum of foo and bar (GD)", stdout);
+  ap = TLS_GD (foo);
+  bp = TLS_GD (bar);
+  printf (" = %d\n", *ap + *bp);
+  result |= *ap + *bp != 1;
+  if (*ap != 0)
+    {
+      printf ("foo = %d\n", *ap);
+      result = 1;
+    }
+  if (*bp != 1)
+    {
+      printf ("bar = %d\n", *bp);
+      result = 1;
+    }
+
+  return result;
+#else
+  return 0;
+#endif
+}
+
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/elf/tst-tls3.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tls3.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tls3.c	(revision 2036)
@@ -0,0 +1,76 @@
+/* glibc test for TLS in ld.so.  */
+#include <stdio.h>
+
+#include <tls.h>
+
+#ifdef USE_TLS
+# include "tls-macros.h"
+
+
+/* One define int variable, two externs.  */
+COMMON_INT_DECL(foo);
+VAR_INT_DECL(bar);
+VAR_INT_DEF(baz);
+#endif
+
+
+extern int in_dso (void);
+
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+#ifdef USE_TLS
+  int result = 0;
+  int *ap, *bp, *cp;
+
+
+  /* Set the variable using the local exec model.  */
+  puts ("set baz to 3 (LE)");
+  ap = TLS_LE (baz);
+  *ap = 3;
+
+
+  /* Get variables using initial exec model.  */
+  puts ("set variables foo and bar (IE)");
+  ap = TLS_IE (foo);
+  *ap = 1;
+  bp = TLS_IE (bar);
+  *bp = 2;
+
+
+  /* Get variables using local dynamic model.  */
+  fputs ("get sum of foo, bar (GD) and baz (LD)", stdout);
+  ap = TLS_GD (foo);
+  bp = TLS_GD (bar);
+  cp = TLS_LD (baz);
+  printf (" = %d\n", *ap + *bp + *cp);
+  result |= *ap + *bp + *cp != 6;
+  if (*ap != 1)
+    {
+      printf ("foo = %d\n", *ap);
+      result = 1;
+    }
+  if (*bp != 2)
+    {
+      printf ("bar = %d\n", *bp);
+      result = 1;
+    }
+  if (*cp != 3)
+    {
+      printf ("baz = %d\n", *cp);
+      result = 1;
+    }
+
+
+  result |= in_dso ();
+
+  return result;
+#else
+  return 0;
+#endif
+}
+
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/elf/tst-tls4.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tls4.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tls4.c	(revision 2036)
@@ -0,0 +1,56 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <tls.h>
+
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+#ifdef USE_TLS
+  static const char modname[] = "tst-tlsmod2.so";
+  int result = 0;
+  int *foop;
+  int (*fp) (int, int *);
+  void *h;
+
+  h = dlopen (modname, RTLD_LAZY);
+  if (h == NULL)
+    {
+      printf ("cannot open '%s': %s\n", modname, dlerror ());
+      exit (1);
+    }
+
+  fp = dlsym (h, "in_dso");
+  if (fp == NULL)
+    {
+      printf ("cannot get symbol 'in_dso': %s\n", dlerror ());
+      exit (1);
+    }
+
+  result |= fp (0, NULL);
+
+  foop = dlsym (h, "foo");
+  if (foop == NULL)
+    {
+      printf ("cannot get symbol 'foo' the second time: %s\n", dlerror ());
+      exit (1);
+    }
+  if (*foop != 16)
+    {
+      puts ("foo != 16");
+      result = 1;
+    }
+
+  dlclose (h);
+
+  return result;
+#else
+  return 0;
+#endif
+}
+
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/elf/tst-tls5.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tls5.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tls5.c	(revision 2036)
@@ -0,0 +1,72 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <tls.h>
+
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+#ifdef USE_TLS
+  static const char modname[] = "tst-tlsmod2.so";
+  int result = 0;
+  int *foop;
+  int *foop2;
+  int (*fp) (int, int *);
+  void *h;
+
+  h = dlopen (modname, RTLD_LAZY);
+  if (h == NULL)
+    {
+      printf ("cannot open '%s': %s\n", modname, dlerror ());
+      exit (1);
+    }
+
+  foop = dlsym (h, "foo");
+  if (foop == NULL)
+    {
+      printf ("cannot get symbol 'foo': %s\n", dlerror ());
+      exit (1);
+    }
+
+  *foop = 42;
+
+  fp = dlsym (h, "in_dso");
+  if (fp == NULL)
+    {
+      printf ("cannot get symbol 'in_dso': %s\n", dlerror ());
+      exit (1);
+    }
+
+  result |= fp (42, foop);
+
+  foop2 = dlsym (h, "foo");
+  if (foop2 == NULL)
+    {
+      printf ("cannot get symbol 'foo' the second time: %s\n", dlerror ());
+      exit (1);
+    }
+
+  if (foop != foop2)
+    {
+      puts ("address of 'foo' different the second time");
+      result = 1;
+    }
+  else if (*foop != 16)
+    {
+      puts ("foo != 16");
+      result = 1;
+    }
+
+  dlclose (h);
+
+  return result;
+#else
+  return 0;
+#endif
+}
+
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/elf/tst-tls6.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tls6.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tls6.c	(revision 2036)
@@ -0,0 +1,90 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <link.h>
+#include <tls.h>
+
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+#ifdef USE_TLS
+  static const char modname[] = "tst-tlsmod2.so";
+  int result = 0;
+  int *foop;
+  int *foop2;
+  int (*fp) (int, int *);
+  void *h;
+  int i;
+  int modid = -1;
+
+  for (i = 0; i < 10; ++i)
+    {
+      h = dlopen (modname, RTLD_LAZY);
+      if (h == NULL)
+	{
+	  printf ("cannot open '%s': %s\n", modname, dlerror ());
+	  exit (1);
+	}
+
+      /* Dirty test code here: we peek into a private data structure.
+	 We make sure that the module gets assigned the same ID every
+	 time.  The value of the first round is used.  */
+      if (modid == -1)
+	modid = ((struct link_map *) h)->l_tls_modid;
+      else if (((struct link_map *) h)->l_tls_modid != modid)
+	{
+	  printf ("round %d: modid now %zd, initially %d\n",
+		  i, ((struct link_map *) h)->l_tls_modid, modid);
+	  result = 1;
+	}
+
+      foop = dlsym (h, "foo");
+      if (foop == NULL)
+	{
+	  printf ("cannot get symbol 'foo': %s\n", dlerror ());
+	  exit (1);
+	}
+
+      *foop = 42 + i;
+
+      fp = dlsym (h, "in_dso");
+      if (fp == NULL)
+	{
+	  printf ("cannot get symbol 'in_dso': %s\n", dlerror ());
+	  exit (1);
+	}
+
+      result |= fp (42 + i, foop);
+
+      foop2 = dlsym (h, "foo");
+      if (foop2 == NULL)
+	{
+	  printf ("cannot get symbol 'foo' the second time: %s\n", dlerror ());
+	  exit (1);
+	}
+
+      if (foop != foop2)
+	{
+	  puts ("address of 'foo' different the second time");
+	  result = 1;
+	}
+      else if (*foop != 16)
+	{
+	  puts ("foo != 16");
+	  result = 1;
+	}
+
+      dlclose (h);
+    }
+
+  return result;
+#else
+  return 0;
+#endif
+}
+
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/elf/tst-tls7.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tls7.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tls7.c	(revision 2036)
@@ -0,0 +1,61 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <link.h>
+#include <tls.h>
+
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+#ifdef USE_TLS
+  static const char modname[] = "tst-tlsmod3.so";
+  int result = 0;
+  int (*fp) (void);
+  void *h;
+  int i;
+  int modid = -1;
+
+  for (i = 0; i < 10; ++i)
+    {
+      h = dlopen (modname, RTLD_LAZY);
+      if (h == NULL)
+	{
+	  printf ("cannot open '%s': %s\n", modname, dlerror ());
+	  exit (1);
+	}
+
+      /* Dirty test code here: we peek into a private data structure.
+	 We make sure that the module gets assigned the same ID every
+	 time.  The value of the first round is used.  */
+      if (modid == -1)
+	modid = ((struct link_map *) h)->l_tls_modid;
+      else if (((struct link_map *) h)->l_tls_modid != (size_t) modid)
+	{
+	  printf ("round %d: modid now %zu, initially %d\n",
+		  i, ((struct link_map *) h)->l_tls_modid, modid);
+	  result = 1;
+	}
+
+      fp = dlsym (h, "in_dso2");
+      if (fp == NULL)
+	{
+	  printf ("cannot get symbol 'in_dso2': %s\n", dlerror ());
+	  exit (1);
+	}
+
+      result |= fp ();
+
+      dlclose (h);
+    }
+
+  return result;
+#else
+  return 0;
+#endif
+}
+
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/elf/tst-tls8.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tls8.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tls8.c	(revision 2036)
@@ -0,0 +1,174 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <link.h>
+#include <tls.h>
+
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+#ifdef USE_TLS
+  static const char modname1[] = "tst-tlsmod3.so";
+  static const char modname2[] = "tst-tlsmod4.so";
+  int result = 0;
+  int (*fp1) (void);
+  int (*fp2) (int, int *);
+  void *h1;
+  void *h2;
+  int i;
+  size_t modid1 = (size_t) -1;
+  size_t modid2 = (size_t) -1;
+  int *bazp;
+
+  for (i = 0; i < 10; ++i)
+    {
+      h1 = dlopen (modname1, RTLD_LAZY);
+      if (h1 == NULL)
+	{
+	  printf ("cannot open '%s': %s\n", modname1, dlerror ());
+	  exit (1);
+	}
+
+      /* Dirty test code here: we peek into a private data structure.
+	 We make sure that the module gets assigned the same ID every
+	 time.  The value of the first round is used.  */
+      if (modid1 == (size_t) -1)
+	modid1 = ((struct link_map *) h1)->l_tls_modid;
+      else if (((struct link_map *) h1)->l_tls_modid != modid1)
+	{
+	  printf ("round %d: modid now %zd, initially %zd\n",
+		  i, ((struct link_map *) h1)->l_tls_modid, modid1);
+	  result = 1;
+	}
+
+      fp1 = dlsym (h1, "in_dso2");
+      if (fp1 == NULL)
+	{
+	  printf ("cannot get symbol 'in_dso2' in %s\n", modname1);
+	  exit (1);
+	}
+
+      result |= fp1 ();
+
+
+
+      h2 = dlopen (modname2, RTLD_LAZY);
+      if (h2 == NULL)
+	{
+	  printf ("cannot open '%s': %s\n", modname2, dlerror ());
+	  exit (1);
+	}
+
+      /* Dirty test code here: we peek into a private data structure.
+	 We make sure that the module gets assigned the same ID every
+	 time.  The value of the first round is used.  */
+      if (modid2 == (size_t) -1)
+	modid2 = ((struct link_map *) h1)->l_tls_modid;
+      else if (((struct link_map *) h1)->l_tls_modid != modid2)
+	{
+	  printf ("round %d: modid now %zd, initially %zd\n",
+		  i, ((struct link_map *) h1)->l_tls_modid, modid2);
+	  result = 1;
+	}
+
+      bazp = dlsym (h2, "baz");
+      if (bazp == NULL)
+	{
+	  printf ("cannot get symbol 'baz' in %s\n", modname2);
+	  exit (1);
+	}
+
+      *bazp = 42 + i;
+
+      fp2 = dlsym (h2, "in_dso");
+      if (fp2 == NULL)
+	{
+	  printf ("cannot get symbol 'in_dso' in %s\n", modname2);
+	  exit (1);
+	}
+
+      result |= fp2 (42 + i, bazp);
+
+      dlclose (h1);
+      dlclose (h2);
+
+
+      h1 = dlopen (modname1, RTLD_LAZY);
+      if (h1 == NULL)
+	{
+	  printf ("cannot open '%s': %s\n", modname1, dlerror ());
+	  exit (1);
+	}
+
+      /* Dirty test code here: we peek into a private data structure.
+	 We make sure that the module gets assigned the same ID every
+	 time.  The value of the first round is used.  */
+      if (((struct link_map *) h1)->l_tls_modid != modid1)
+	{
+	  printf ("round %d: modid now %zd, initially %zd\n",
+		  i, ((struct link_map *) h1)->l_tls_modid, modid1);
+	  result = 1;
+	}
+
+      fp1 = dlsym (h1, "in_dso2");
+      if (fp1 == NULL)
+	{
+	  printf ("cannot get symbol 'in_dso2' in %s\n", modname1);
+	  exit (1);
+	}
+
+      result |= fp1 ();
+
+
+
+      h2 = dlopen (modname2, RTLD_LAZY);
+      if (h2 == NULL)
+	{
+	  printf ("cannot open '%s': %s\n", modname2, dlerror ());
+	  exit (1);
+	}
+
+      /* Dirty test code here: we peek into a private data structure.
+	 We make sure that the module gets assigned the same ID every
+	 time.  The value of the first round is used.  */
+      if (((struct link_map *) h1)->l_tls_modid != modid2)
+	{
+	  printf ("round %d: modid now %zd, initially %zd\n",
+		  i, ((struct link_map *) h1)->l_tls_modid, modid2);
+	  result = 1;
+	}
+
+      bazp = dlsym (h2, "baz");
+      if (bazp == NULL)
+	{
+	  printf ("cannot get symbol 'baz' in %s\n", modname2);
+	  exit (1);
+	}
+
+      *bazp = 62 + i;
+
+      fp2 = dlsym (h2, "in_dso");
+      if (fp2 == NULL)
+	{
+	  printf ("cannot get symbol 'in_dso' in %s\n", modname2);
+	  exit (1);
+	}
+
+      result |= fp2 (62 + i, bazp);
+
+      /* This time the dlclose calls are in reverse order.  */
+      dlclose (h2);
+      dlclose (h1);
+    }
+
+  return result;
+#else
+  return 0;
+#endif
+}
+
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/elf/tst-tls9-static.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tls9-static.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tls9-static.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-tls9.c"
Index: trunk/src/libctests/glibc/elf/tst-tls9.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tls9.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tls9.c	(revision 2036)
@@ -0,0 +1,42 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <link.h>
+#include <tls.h>
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+#ifdef USE_TLS
+  static const char modname1[] = "tst-tlsmod5.so";
+  static const char modname2[] = "tst-tlsmod6.so";
+  int result = 0;
+
+  void *h1 = dlopen (modname1, RTLD_LAZY);
+  if (h1 == NULL)
+    {
+      printf ("cannot open '%s': %s\n", modname1, dlerror ());
+      result = 1;
+    }
+  void *h2 = dlopen (modname2, RTLD_LAZY);
+  if (h2 == NULL)
+    {
+      printf ("cannot open '%s': %s\n", modname2, dlerror ());
+      result = 1;
+    }
+
+  if (h1 != NULL)
+    dlclose (h1);
+  if (h2 != NULL)
+    dlclose (h2);
+
+  return result;
+#else
+  return 0;
+#endif
+}
+
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/elf/tst-tlsmod1.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tlsmod1.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tlsmod1.c	(revision 2036)
@@ -0,0 +1,68 @@
+#include <stdio.h>
+
+#include <tls.h>
+
+#ifdef USE_TLS
+#include "tls-macros.h"
+
+
+/* One define int variable, two externs.  */
+COMMON_INT_DEF(foo);
+VAR_INT_DEF(bar);
+VAR_INT_DECL(baz);
+#endif
+
+extern int in_dso (void);
+
+int
+in_dso (void)
+{
+  int result = 0;
+#ifdef USE_TLS
+  int *ap, *bp, *cp;
+
+  /* Get variables using initial exec model.  */
+  fputs ("get sum of foo and bar (IE)", stdout);
+  asm ("" ::: "memory");
+  ap = TLS_IE (foo);
+  bp = TLS_IE (bar);
+  printf (" = %d\n", *ap + *bp);
+  result |= *ap + *bp != 3;
+  if (*ap != 1)
+    {
+      printf ("foo = %d\n", *ap);
+      result = 1;
+    }
+  if (*bp != 2)
+    {
+      printf ("bar = %d\n", *bp);
+      result = 1;
+    }
+
+
+  /* Get variables using generic dynamic model.  */
+  fputs ("get sum of foo and bar and baz (GD)", stdout);
+  ap = TLS_GD (foo);
+  bp = TLS_GD (bar);
+  cp = TLS_GD (baz);
+  printf (" = %d\n", *ap + *bp + *cp);
+  result |= *ap + *bp + *cp != 6;
+  if (*ap != 1)
+    {
+      printf ("foo = %d\n", *ap);
+      result = 1;
+    }
+  if (*bp != 2)
+    {
+      printf ("bar = %d\n", *bp);
+      result = 1;
+    }
+  if (*cp != 3)
+    {
+      printf ("baz = %d\n", *cp);
+      result = 1;
+    }
+#endif
+
+  return result;
+}
Index: trunk/src/libctests/glibc/elf/tst-tlsmod10.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tlsmod10.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tlsmod10.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-tlsmod8.c"
Index: trunk/src/libctests/glibc/elf/tst-tlsmod11.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tlsmod11.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tlsmod11.c	(revision 2036)
@@ -0,0 +1,6 @@
+#include "tst-tls10.h"
+
+#ifdef USE_TLS__THREAD
+__thread struct A a1 = { 4, 5, 6 };
+__thread struct A a2 = { 7, 8, 9 };
+#endif
Index: trunk/src/libctests/glibc/elf/tst-tlsmod12.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tlsmod12.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tlsmod12.c	(revision 2036)
@@ -0,0 +1,14 @@
+#include "tst-tls10.h"
+
+#ifdef USE_TLS__THREAD
+extern __thread struct A a2 __attribute__((tls_model("initial-exec")));
+
+void
+check1 (void)
+{
+  if (a1.a != 4 || a1.b != 5 || a1.c != 6)
+    abort ();
+  if (a2.a != 7 || a2.b != 8 || a2.c != 9)
+    abort ();
+}
+#endif
Index: trunk/src/libctests/glibc/elf/tst-tlsmod13.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tlsmod13.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tlsmod13.c	(revision 2036)
@@ -0,0 +1,14 @@
+#include <tls.h>
+
+#if defined USE_TLS && defined HAVE___THREAD \
+    && defined HAVE_TLS_MODEL_ATTRIBUTE
+__thread int a[2] __attribute__ ((tls_model ("initial-exec")));
+#else
+int a[2];
+#endif
+
+int
+foo (void)
+{
+  return a[0];
+}
Index: trunk/src/libctests/glibc/elf/tst-tlsmod13a.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tlsmod13a.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tlsmod13a.c	(revision 2036)
@@ -0,0 +1,16 @@
+#include <tls.h>
+
+#if defined USE_TLS && defined HAVE___THREAD \
+    && defined HAVE_TLS_MODEL_ATTRIBUTE
+__thread int b[2] __attribute__ ((tls_model ("initial-exec")));
+#else
+int b[2];
+#endif
+
+extern int foo (void);
+
+int
+bar (void)
+{
+  return foo () + b[0];
+}
Index: trunk/src/libctests/glibc/elf/tst-tlsmod14a.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tlsmod14a.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tlsmod14a.c	(revision 2036)
@@ -0,0 +1,41 @@
+#include <stdint.h>
+#include <stdio.h>
+
+#include <tls.h>
+
+#if USE_TLS && HAVE___THREAD
+
+#define AL 4096
+struct foo
+{
+  int i;
+} __attribute ((aligned (AL)));
+
+static __thread struct foo f;
+static struct foo g;
+
+
+#ifndef FCT
+# define FCT in_dso1
+#endif
+
+
+int
+FCT (void)
+{
+  puts (__func__);
+
+  int result = 0;
+
+  int fail = (((uintptr_t) &f) & (AL - 1)) != 0;
+  printf ("&f = %p %s\n", &f, fail ? "FAIL" : "OK");
+  result |= fail;
+
+  fail = (((uintptr_t) &g) & (AL - 1)) != 0;
+  printf ("&g = %p %s\n", &g, fail ? "FAIL" : "OK");
+  result |= fail;
+
+  return result;
+}
+
+#endif
Index: trunk/src/libctests/glibc/elf/tst-tlsmod14b.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tlsmod14b.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tlsmod14b.c	(revision 2036)
@@ -0,0 +1,2 @@
+#define FCT in_dso2
+#include "tst-tlsmod14a.c"
Index: trunk/src/libctests/glibc/elf/tst-tlsmod15a.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tlsmod15a.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tlsmod15a.c	(revision 2036)
@@ -0,0 +1,6 @@
+extern int nonexistent_dummy_var;
+int *
+foo (void)
+{
+  return &nonexistent_dummy_var;
+}
Index: trunk/src/libctests/glibc/elf/tst-tlsmod15b.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tlsmod15b.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tlsmod15b.c	(revision 2036)
@@ -0,0 +1,17 @@
+#include "tst-tls10.h"
+
+#ifdef USE_TLS__THREAD
+__thread int mod15b_var __attribute__((tls_model("initial-exec")));
+
+int
+in_dso (void)
+{
+  return mod15b_var;
+}
+#else
+int
+in_dso (void)
+{
+  return 0;
+}
+#endif
Index: trunk/src/libctests/glibc/elf/tst-tlsmod2.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tlsmod2.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tlsmod2.c	(revision 2036)
@@ -0,0 +1,38 @@
+#include <stdio.h>
+
+#include <tls.h>
+
+#ifdef USE_TLS
+#include "tls-macros.h"
+
+
+COMMON_INT_DEF(foo);
+
+
+int
+in_dso (int n, int *caller_foop)
+{
+  int *foop;
+  int result = 0;
+
+  puts ("foo");			/* Make sure PLT is used before macros.  */
+  asm ("" ::: "memory");
+
+  foop = TLS_GD (foo);
+
+  if (caller_foop != NULL && foop != caller_foop)
+    {
+      printf ("callers address of foo differs: %p vs %p\n", caller_foop, foop);
+      result = 1;
+    }
+  else if (*foop != n)
+    {
+      printf ("foo != %d\n", n);
+      result = 1;
+    }
+
+  *foop = 16;
+
+  return result;
+}
+#endif
Index: trunk/src/libctests/glibc/elf/tst-tlsmod3.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tlsmod3.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tlsmod3.c	(revision 2036)
@@ -0,0 +1,41 @@
+#include <stdio.h>
+
+#include <tls.h>
+
+#ifdef USE_TLS
+# include "tls-macros.h"
+
+extern int in_dso (int n, int *caller_foop);
+
+COMMON_INT_DEF(comm_n);
+
+
+
+
+int
+in_dso2 (void)
+{
+  int *foop;
+  int result = 0;
+  static int n;
+  int *np;
+
+  puts ("foo");			/* Make sure PLT is used before macros.  */
+  asm ("" ::: "memory");
+
+  foop = TLS_GD (foo);
+  np = TLS_GD (comm_n);
+
+  if (n != *np)
+    {
+      printf ("n = %d != comm_n = %d\n", n, *np);
+      result = 1;
+    }
+
+  result |= in_dso (*foop = 42 + n++, foop);
+
+  *foop = 16;
+
+  return result;
+}
+#endif
Index: trunk/src/libctests/glibc/elf/tst-tlsmod4.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tlsmod4.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tlsmod4.c	(revision 2036)
@@ -0,0 +1,38 @@
+#include <stdio.h>
+
+#include <tls.h>
+
+#ifdef USE_TLS
+# include "tls-macros.h"
+
+
+COMMON_INT_DEF(baz);
+
+
+int
+in_dso (int n, int *caller_bazp)
+{
+  int *bazp;
+  int result = 0;
+
+  puts ("foo");			/* Make sure PLT is used before macros.  */
+  asm ("" ::: "memory");
+
+  bazp = TLS_GD (baz);
+
+  if (caller_bazp != NULL && bazp != caller_bazp)
+    {
+      printf ("callers address of baz differs: %p vs %p\n", caller_bazp, bazp);
+      result = 1;
+    }
+  else if (*bazp != n)
+    {
+      printf ("baz != %d\n", n);
+      result = 1;
+    }
+
+  *bazp = 16;
+
+  return result;
+}
+#endif
Index: trunk/src/libctests/glibc/elf/tst-tlsmod5.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tlsmod5.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tlsmod5.c	(revision 2036)
@@ -0,0 +1,7 @@
+#include <tls.h>
+
+#ifdef USE_TLS
+#include "tls-macros.h"
+
+COMMON_INT_DEF(foo);
+#endif
Index: trunk/src/libctests/glibc/elf/tst-tlsmod6.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tlsmod6.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tlsmod6.c	(revision 2036)
@@ -0,0 +1,7 @@
+#include <tls.h>
+
+#ifdef USE_TLS
+#include "tls-macros.h"
+
+COMMON_INT_DEF(bar);
+#endif
Index: trunk/src/libctests/glibc/elf/tst-tlsmod7.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tlsmod7.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tlsmod7.c	(revision 2036)
@@ -0,0 +1,103 @@
+#include "tst-tls10.h"
+
+#ifdef USE_TLS__THREAD
+__thread int dummy __attribute__((visibility ("hidden"))) = 12;
+__thread struct A a1 = { 4, 5, 6 };
+__thread struct A a2 = { 7, 8, 9 };
+__thread struct A a3 __attribute__((tls_model("initial-exec")))
+  = { 10, 11, 12 };
+__thread struct A a4 __attribute__((tls_model("initial-exec")))
+  = { 13, 14, 15 };
+static __thread struct A local1 = { 16, 17, 18 };
+static __thread struct A local2 __attribute__((tls_model("initial-exec")))
+  = { 19, 20, 21 };
+
+void
+check1 (void)
+{
+  if (a1.a != 4 || a1.b != 5 || a1.c != 6)
+    abort ();
+  if (a2.a != 22 || a2.b != 23 || a2.c != 24)
+    abort ();
+  if (a3.a != 10 || a3.b != 11 || a3.c != 12)
+    abort ();
+  if (a4.a != 25 || a4.b != 26 || a4.c != 27)
+    abort ();
+  if (local1.a != 16 || local1.b != 17 || local1.c != 18)
+    abort ();
+  if (local2.a != 19 || local2.b != 20 || local2.c != 21)
+    abort ();
+}
+
+struct A *
+f1a (void)
+{
+  return &a1;
+}
+
+struct A *
+f2a (void)
+{
+  return &a2;
+}
+
+struct A *
+f3a (void)
+{
+  return &a3;
+}
+
+struct A *
+f4a (void)
+{
+  return &a4;
+}
+
+struct A *
+f5a (void)
+{
+  return &local1;
+}
+
+struct A *
+f6a (void)
+{
+  return &local2;
+}
+
+int
+f1b (void)
+{
+  return a1.a;
+}
+
+int
+f2b (void)
+{
+  return a2.b;
+}
+
+int
+f3b (void)
+{
+  return a3.c;
+}
+
+int
+f4b (void)
+{
+  return a4.a;
+}
+
+int
+f5b (void)
+{
+  return local1.b;
+}
+
+int
+f6b (void)
+{
+  return local2.c;
+}
+#endif
Index: trunk/src/libctests/glibc/elf/tst-tlsmod8.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tlsmod8.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tlsmod8.c	(revision 2036)
@@ -0,0 +1,72 @@
+#include "tst-tls10.h"
+
+#ifdef USE_TLS__THREAD
+__thread long long dummy __attribute__((visibility ("hidden"))) = 12;
+__thread struct A a2 = { 22, 23, 24 };
+__thread struct A a4 __attribute__((tls_model("initial-exec")))
+  = { 25, 26, 27 };
+static __thread struct A local1 = { 28, 29, 30 };
+static __thread struct A local2 __attribute__((tls_model("initial-exec")))
+  = { 31, 32, 33 };
+
+void
+check2 (void)
+{
+  if (a2.a != 22 || a2.b != 23 || a2.c != 24)
+    abort ();
+  if (a4.a != 25 || a4.b != 26 || a4.c != 27)
+    abort ();
+  if (local1.a != 28 || local1.b != 29 || local1.c != 30)
+    abort ();
+  if (local2.a != 31 || local2.b != 32 || local2.c != 33)
+    abort ();
+}
+
+struct A *
+f7a (void)
+{
+  return &a2;
+}
+
+struct A *
+f8a (void)
+{
+  return &a4;
+}
+
+struct A *
+f9a (void)
+{
+  return &local1;
+}
+
+struct A *
+f10a (void)
+{
+  return &local2;
+}
+
+int
+f7b (void)
+{
+  return a2.b;
+}
+
+int
+f8b (void)
+{
+  return a4.a;
+}
+
+int
+f9b (void)
+{
+  return local1.b;
+}
+
+int
+f10b (void)
+{
+  return local2.c;
+}
+#endif
Index: trunk/src/libctests/glibc/elf/tst-tlsmod9.c
===================================================================
--- trunk/src/libctests/glibc/elf/tst-tlsmod9.c	(revision 2036)
+++ trunk/src/libctests/glibc/elf/tst-tlsmod9.c	(revision 2036)
@@ -0,0 +1,101 @@
+#include "tst-tls10.h"
+
+#ifdef USE_TLS__THREAD
+__thread int dummy __attribute__((visibility ("hidden"))) = 12;
+__thread struct A a1 = { 4, 5, 6 };
+__thread struct A a3 __attribute__((tls_model("initial-exec")))
+  = { 10, 11, 12 };
+extern __thread struct A a4 __attribute__((tls_model("initial-exec")));
+static __thread struct A local1 = { 16, 17, 18 };
+static __thread struct A local2 __attribute__((tls_model("initial-exec")))
+  = { 19, 20, 21 };
+
+void
+check1 (void)
+{
+  if (a1.a != 4 || a1.b != 5 || a1.c != 6)
+    abort ();
+  if (a2.a != 22 || a2.b != 23 || a2.c != 24)
+    abort ();
+  if (a3.a != 10 || a3.b != 11 || a3.c != 12)
+    abort ();
+  if (a4.a != 25 || a4.b != 26 || a4.c != 27)
+    abort ();
+  if (local1.a != 16 || local1.b != 17 || local1.c != 18)
+    abort ();
+  if (local2.a != 19 || local2.b != 20 || local2.c != 21)
+    abort ();
+}
+
+struct A *
+f1a (void)
+{
+  return &a1;
+}
+
+struct A *
+f2a (void)
+{
+  return &a2;
+}
+
+struct A *
+f3a (void)
+{
+  return &a3;
+}
+
+struct A *
+f4a (void)
+{
+  return &a4;
+}
+
+struct A *
+f5a (void)
+{
+  return &local1;
+}
+
+struct A *
+f6a (void)
+{
+  return &local2;
+}
+
+int
+f1b (void)
+{
+  return a1.a;
+}
+
+int
+f2b (void)
+{
+  return a2.b;
+}
+
+int
+f3b (void)
+{
+  return a3.c;
+}
+
+int
+f4b (void)
+{
+  return a4.a;
+}
+
+int
+f5b (void)
+{
+  return local1.b;
+}
+
+int
+f6b (void)
+{
+  return local2.c;
+}
+#endif
Index: trunk/src/libctests/glibc/gmon/Makefile
===================================================================
--- trunk/src/libctests/glibc/gmon/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/gmon/Makefile	(revision 2036)
@@ -0,0 +1,49 @@
+# Copyright (C) 1995, 1996, 1997, 2001, 2002 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Sub-makefile for gmon portion of the library.
+#
+subdir	:= gmon
+
+headers	:= sys/gmon.h sys/gmon_out.h sys/profil.h
+distribute := machine-gmon.h profil-counter.h
+routines := gmon mcount profil sprofil bb_init_func bb_exit_func prof-freq
+
+elide-routines.os = bb_init_func bb_exit_func
+
+tests	:= tst-sprofil
+
+# The mcount code won't work without a frame pointer.
+CFLAGS-mcount.c := -fno-omit-frame-pointer
+
+include ../Rules
+
+# We cannot compile mcount.c with -pg because that would
+# create recursive calls.  Just copy the normal static object.
+# On systems where `profil' is not a system call, the same
+# problem exists for the internal functions in profil.c.
+
+noprof := mcount
+ifeq (,$(filter profil,$(unix-syscalls)))
+noprof += profil sprofil
+endif
+
+$(noprof:%=$(objpfx)%.op): %.op: %.o
+	rm -f $@
+	ln $< $@
Index: trunk/src/libctests/glibc/gmon/tst-sprofil.c
===================================================================
--- trunk/src/libctests/glibc/gmon/tst-sprofil.c	(revision 2036)
+++ trunk/src/libctests/glibc/gmon/tst-sprofil.c	(revision 2036)
@@ -0,0 +1,172 @@
+/* Copyright (C) 2001, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by David Mosberger-Tang <davidm@hpl.hp.com>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/profil.h>
+
+#include <bits/wordsize.h>
+
+#define NELEMS(a)	(sizeof (a)/sizeof ((a)[0]))
+
+size_t taddr[] =
+  {
+    0x00001000,		/* elf32/hppa */
+    0x08048000,		/* Linux elf32/x86 */
+    0x80000000,		/* Linux elf32/m68k */
+    0x00400000,		/* Linux elf32/mips */
+    0x01800000,		/* Linux elf32/ppc */
+    0x00010000		/* Linux elf32/sparc */
+#if __WORDSIZE > 32
+    ,
+    0x4000000000000000,	/* Linux elf64/ia64 */
+    0x0000000120000000,	/* Linux elf64/alpha */
+    0x4000000000001000,	/* elf64/hppa */
+    0x0000000100000000	/* Linux elf64/sparc */
+#endif
+  };
+
+unsigned int buf[NELEMS (taddr)][0x10000 / sizeof (int)];
+unsigned int bshort[5][0x100 / sizeof (int)];
+unsigned int blong[1][0x1000 / sizeof (int)];
+unsigned int vlong[1][0x2000 / sizeof (int)];
+
+static long int
+fac (long int n)
+{
+  if (n == 0)
+    return 1;
+  return n * fac (n - 1);
+}
+
+int
+main (int argc, char **argv)
+{
+  unsigned int ovfl = 0, profcnt = 0;
+  struct timeval tv, start;
+  struct prof prof[32];
+  double t_tick, delta;
+  long int sum = 0;
+  int i, j;
+
+  for (i = 0; i < NELEMS (taddr); ++i)
+    {
+      prof[profcnt].pr_base = buf[i];
+      prof[profcnt].pr_size = sizeof (buf[i]);
+      prof[profcnt].pr_off = taddr[i];
+      prof[profcnt].pr_scale = 0x10000;
+      ++profcnt;
+    }
+
+  prof[profcnt].pr_base = blong[0];
+  prof[profcnt].pr_size = sizeof (blong[0]);
+  prof[profcnt].pr_off = 0x80001000;
+  prof[profcnt].pr_scale = 0x10000;
+  ++profcnt;
+
+  prof[profcnt].pr_base = bshort[0];
+  prof[profcnt].pr_size = sizeof (bshort[0]);
+  prof[profcnt].pr_off = 0x80000080;
+  prof[profcnt].pr_scale = 0x10000;
+  ++profcnt;
+
+  prof[profcnt].pr_base = bshort[1];
+  prof[profcnt].pr_size = sizeof (bshort[1]);
+  prof[profcnt].pr_off = 0x80000f80;
+  prof[profcnt].pr_scale = 0x10000;
+  ++profcnt;
+
+  prof[profcnt].pr_base = bshort[2];
+  prof[profcnt].pr_size = sizeof (bshort[2]);
+  prof[profcnt].pr_off = 0x80001080;
+  prof[profcnt].pr_scale = 0x10000;
+  ++profcnt;
+
+  prof[profcnt].pr_base = bshort[3];
+  prof[profcnt].pr_size = sizeof (bshort[3]);
+  prof[profcnt].pr_off = 0x80001f80;
+  prof[profcnt].pr_scale = 0x10000;
+  ++profcnt;
+
+  prof[profcnt].pr_base = bshort[4];
+  prof[profcnt].pr_size = sizeof (bshort[4]);
+  prof[profcnt].pr_off = 0x80002080;
+  prof[profcnt].pr_scale = 0x10000;
+  ++profcnt;
+
+  prof[profcnt].pr_base = vlong[0];
+  prof[profcnt].pr_size = sizeof (vlong[0]);
+  prof[profcnt].pr_off = 0x80000080;
+  prof[profcnt].pr_scale = 0x10000;
+  ++profcnt;
+
+  /* Set up overflow counter (must be last on Irix).  */
+  prof[profcnt].pr_base = &ovfl;
+  prof[profcnt].pr_size = sizeof (ovfl);
+  prof[profcnt].pr_off = 0;
+  prof[profcnt].pr_scale = 2;
+  ++profcnt;
+
+  /* Turn it on.  */
+  if (sprofil (prof, profcnt, &tv, PROF_UINT) < 0)
+    {
+      if (errno == ENOSYS)
+	exit (0);
+      perror ("sprofil");
+      exit (1);
+    }
+
+  t_tick = tv.tv_sec + 1e-6 * tv.tv_usec;
+  printf ("profiling period = %g ms\n", 1e3 * t_tick);
+
+  gettimeofday (&start, NULL);
+  do
+    {
+      for (i = 0; i < 21; ++i)
+	sum += fac (i);
+
+      gettimeofday (&tv, NULL);
+      timersub (&tv, &start, &tv);
+      delta = tv.tv_sec + 1e-6 * tv.tv_usec;
+    }
+  while (delta < 1000 * t_tick);
+
+  printf ("sum = 0x%lx\n", sum);
+
+  /* Turn it off.  */
+  if (sprofil (NULL, 0, NULL, 0) < 0)
+    {
+      if (errno == ENOSYS)
+	exit (0);
+      perror ("sprofil");
+      exit (1);
+    }
+
+  printf ("overflow = %u\n", ovfl);
+  for (i = 0; i < NELEMS (taddr); ++i)
+    for (j = 0; j < 0x10000 / sizeof (int); ++j)
+      if (buf[i][j] != 0)
+	printf ("%0*Zx\t%u\t(buffer %d)\n",
+		(int) (sizeof (size_t) * 2),
+		(taddr[i] + ((char *) &buf[i][j] - (char *) &buf[i][0])),
+		buf[i][j], i);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/gnulib/Makefile
===================================================================
--- trunk/src/libctests/glibc/gnulib/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/gnulib/Makefile	(revision 2036)
@@ -0,0 +1,26 @@
+# Copyright (C) 1991, 1997, 2000 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+subdir := gnulib
+
+# Maybe this is the right place for a test of gcc's interface.
+tests = tst-gcc
+
+# Which routines are required is machine-dependent.
+
+include ../Rules
Index: trunk/src/libctests/glibc/gnulib/tst-gcc.c
===================================================================
--- trunk/src/libctests/glibc/gnulib/tst-gcc.c	(revision 2036)
+++ trunk/src/libctests/glibc/gnulib/tst-gcc.c	(revision 2036)
@@ -0,0 +1,74 @@
+/* Test program for the gcc interface.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+
+#define __no_type_class		-1
+#define __void_type_class	 0
+#define __integer_type_class	 1
+#define __char_type_class	 2
+#define __enumeral_type_class	 3
+#define __boolean_type_class	 4
+#define __pointer_type_class	 5
+#define __reference_type_class	 6
+#define __offset_type_class	 7
+#define __real_type_class	 8
+#define __complex_type_class	 9
+#define __function_type_class	10
+#define __method_type_class	11
+#define __record_type_class	12
+#define __union_type_class	13
+#define __array_type_class	14
+#define __string_type_class	15
+#define __set_type_class	16
+#define __file_type_class	17
+#define __lang_type_class	18
+
+
+#define TEST(var) \
+  ({ int wrong = (__builtin_classify_type (__##var##_type)		      \
+		  != __##var##_type_class);				      \
+     printf ("%-15s is %d: %s\n",					      \
+	     #var, __builtin_classify_type (__##var##_type),		      \
+	     wrong ? "WRONG" : "OK");					      \
+     wrong;								      \
+  })
+
+
+int
+main (void)
+{
+  int result = 0;
+  int __integer_type;
+  void *__pointer_type;
+  double __real_type;
+  __complex__ double __complex_type;
+  struct { int a; } __record_type;
+  union { int a; int b; } __union_type;
+
+  result |= TEST (integer);
+  result |= TEST (pointer);
+  result |= TEST (real);
+  result |= TEST (complex);
+  result |= TEST (record);
+  result |= TEST (union);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/grp/Makefile
===================================================================
--- trunk/src/libctests/glibc/grp/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/grp/Makefile	(revision 2036)
@@ -0,0 +1,71 @@
+# Copyright (C) 1991,1992,1996-2000,2003,2004 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Sub-makefile for grp portion of the library.
+#
+subdir	:= grp
+headers := grp.h
+
+distribute := tst_fgetgrent.c tst_fgetgrent.sh compat-initgroups.c
+
+routines := fgetgrent initgroups setgroups \
+	    getgrent getgrgid getgrnam putgrent \
+	    getgrent_r getgrgid_r getgrnam_r fgetgrent_r
+
+include ../Makeconfig
+
+tests := testgrp
+
+ifeq (yes,$(build-shared))
+test-srcs :=  tst_fgetgrent
+endif
+
+
+include ../Rules
+
+ifeq (yes,$(build-static-nss))
+otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
+	     $(resolvobjdir)/libresolv.a
+endif
+
+
+ifeq ($(have-thread-library),yes)
+
+CFLAGS-getgrgid_r.c = -DUSE_NSCD=1 -fexceptions
+CFLAGS-getgrnam_r.c = -DUSE_NSCD=1 -fexceptions
+CFLAGS-getgrent_r.c = -fexceptions
+CFLAGS-getgrent.c = -fexceptions
+CFLAGS-fgetgrent.c = -fexceptions
+CFLAGS-fgetgrent_r.c = -fexceptions -D_IO_MTSAFE_IO
+CFLAGS-putgrent.c = -fexceptions -D_IO_MTSAFE_IO
+CFLAGS-initgroups.c = -DUSE_NSCD=1 -fexceptions
+CFLAGS-getgrgid.c = -fexceptions
+
+endif
+
+ifeq (no,$(cross-compiling))
+# tst_fgetgrent currently only works with shared libraries
+ifeq (yes,$(build-shared))
+tests: $(objpfx)tst_fgetgrent.out
+$(objpfx)tst_fgetgrent.out: tst_fgetgrent.sh $(objpfx)tst_fgetgrent
+	$(SHELL) -e tst_fgetgrent.sh $(common-objpfx) $(elf-objpfx) \
+		 $(rtld-installed-name)
+
+endif
+endif
Index: trunk/src/libctests/glibc/grp/testgrp.c
===================================================================
--- trunk/src/libctests/glibc/grp/testgrp.c	(revision 2036)
+++ trunk/src/libctests/glibc/grp/testgrp.c	(revision 2036)
@@ -0,0 +1,41 @@
+#include <grp.h>
+#include <pwd.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+int
+main (int argc, char *argv[])
+{
+  uid_t me;
+  struct passwd *my_passwd;
+  struct group *my_group = NULL;
+  char **members;
+
+  me = getuid ();
+  my_passwd = getpwuid (me);
+  if (my_passwd == NULL)
+    printf ("Cannot find user entry for UID %d\n", me);
+  else
+    {
+      printf ("My login name is %s.\n", my_passwd->pw_name);
+      printf ("My uid is %d.\n", (int)(my_passwd->pw_uid));
+      printf ("My home directory is %s.\n", my_passwd->pw_dir);
+      printf ("My default shell is %s.\n", my_passwd->pw_shell);
+
+      my_group = getgrgid (my_passwd->pw_gid);
+      if (my_group == NULL)
+	printf ("No data for group %d found\n", my_passwd->pw_gid);
+      else
+	{
+	  printf ("My default group is %s (%d).\n",
+		  my_group->gr_name, (int)(my_passwd->pw_gid));
+	  printf ("The members of this group are:\n");
+	  for (members = my_group->gr_mem; *members != NULL; ++members)
+	    printf ("  %s\n", *members);
+	}
+    }
+
+  return my_passwd && my_group ? EXIT_SUCCESS : EXIT_FAILURE;
+}
Index: trunk/src/libctests/glibc/grp/tst_fgetgrent.c
===================================================================
--- trunk/src/libctests/glibc/grp/tst_fgetgrent.c	(revision 2036)
+++ trunk/src/libctests/glibc/grp/tst_fgetgrent.c	(revision 2036)
@@ -0,0 +1,120 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@arthur.rhein-neckar.de>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <grp.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+
+static int errors;
+
+static void
+write_users (FILE *f, int large_pos, int pos)
+{
+  int i;
+
+  if (pos == large_pos)
+    {
+      if (large_pos == 3)
+	fprintf (f, ":three");
+
+      /* we need more than 2048 bytes for proper testing.  */
+      for (i = 0; i < 500; i++)
+	fprintf (f, ",user%03d", i);
+    }
+  fprintf (f, "\n");
+
+}
+
+static void
+write_group (const char *filename, int pos)
+{
+  FILE *f;
+
+  f = fopen (filename, "w");
+  fprintf (f, "one:x:1:one");
+  write_users (f, pos, 1);
+  fprintf (f, "two:x:2:two");
+  write_users (f, pos, 2);
+  fprintf (f, "three:x:3");
+  write_users (f, pos, 3);
+  fclose (f);
+}
+
+static void
+test_entry (const char *name, gid_t gid, struct group *g)
+{
+  if (!g)
+    {
+      printf ("Error: Entry is empty\n");
+      errors++;
+      return;
+    }
+
+  if ((g->gr_gid == gid) && (strcmp (g->gr_name, name) == 0))
+    printf ("Ok: %s: %d\n", g->gr_name, g->gr_gid);
+  else
+    {
+      printf ("Error: %s: %d should be: %s: %d\n", g->gr_name, g->gr_gid,
+	      name, gid);
+      errors++;
+    }
+}
+
+
+static void
+test_fgetgrent (const char *filename)
+{
+  struct group *g;
+  FILE *f;
+
+  f = fopen (filename,"r");
+
+  g = fgetgrent (f);
+  test_entry ("one", 1, g);
+  g = fgetgrent (f);
+  test_entry ("two", 2, g);
+  g = fgetgrent (f);
+  test_entry ("three", 3, g);
+  fclose (f);
+}
+
+
+int
+main (int argc, char *argv[])
+{
+  char *file = tmpnam (NULL);
+  int i = 0;
+
+  if (argc > 1)
+    i = atoi (argv[1]);
+  if (i > 3)
+    i = 3;
+  if (i)
+    printf ("Large group is group: %d\n", i);
+  else
+    printf ("Not using a large group\n");
+  write_group (file, i);
+  test_fgetgrent (file);
+
+  remove (file);
+
+  return (errors != 0);
+}
Index: trunk/src/libctests/glibc/grp/tst_fgetgrent.sh
===================================================================
--- trunk/src/libctests/glibc/grp/tst_fgetgrent.sh	(revision 2036)
+++ trunk/src/libctests/glibc/grp/tst_fgetgrent.sh	(revision 2036)
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 1999 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+# Contributed by Andreas Jaeger <aj@arthur.rhein-neckar.de>, 1999.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+common_objpfx=$1; shift
+elf_objpfx=$1; shift
+rtld_installed_name=$1; shift
+
+testout=${common_objpfx}/grp/tst_fgetgrent.out
+library_path=${common_objpfx}
+
+result=0
+
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}grp/tst_fgetgrent 0 > ${testout} || result=1
+
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}grp/tst_fgetgrent 1 >> ${testout} || result=1
+
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}grp/tst_fgetgrent 2 >> ${testout} || result=1
+
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}grp/tst_fgetgrent 3 >> ${testout} || result=1
+
+exit $result
Index: trunk/src/libctests/glibc/iconv/Makefile
===================================================================
--- trunk/src/libctests/glibc/iconv/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/iconv/Makefile	(revision 2036)
@@ -0,0 +1,92 @@
+# Copyright (C) 1997,1998,2000-2003,2004 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Makefile for iconv.
+#
+subdir	:= iconv
+
+include ../Makeconfig
+
+headers		= iconv.h gconv.h
+routines	= iconv_open iconv iconv_close \
+		  gconv_open gconv gconv_close gconv_db gconv_conf \
+		  gconv_builtin gconv_simple gconv_trans gconv_cache
+ifeq ($(elf),yes)
+routines	+= gconv_dl
+else
+CFLAGS-gconv_db.c = -DSTATIC_GCONV
+CFLAGS-gconv_cache.c = -DSTATIC_GCONV
+CFLAGS-gconv_simple.c = -DSTATIC_GCONV
+endif
+
+vpath %.c ../locale/programs ../intl
+
+iconv_prog-modules = iconv_charmap charmap charmap-dir linereader \
+		     dummy-repertoire simple-hash xstrdup xmalloc
+iconvconfig-modules = strtab xmalloc hash-string
+extra-objs	   = $(iconv_prog-modules:=.o) $(iconvconfig-modules:=.o)
+CFLAGS-iconv_prog.c = -I../locale/programs
+CFLAGS-iconv_charmap.c = -I../locale/programs
+CFLAGS-dummy-repertoire.c = -I../locale/programs
+CFLAGS-charmap.c = -DCHARMAP_PATH='"$(i18ndir)/charmaps"' \
+		   -DDEFAULT_CHARMAP=null_pointer -DNEED_NULL_POINTER
+CFLAGS-linereader.c = -DNO_TRANSLITERATION
+CFLAGS-simple-hash.c = -I../locale
+
+tests	= tst-iconv1 tst-iconv2 tst-iconv3 tst-iconv5
+
+distribute	= gconv_builtin.h gconv_int.h loop.c skeleton.c iconv_prog.h \
+		  iconv_charmap.c dummy-repertoire.c gconv_charset.h strtab.c \
+		  iconvconfig.h
+
+others		= iconv_prog iconvconfig
+install-others	= $(inst_bindir)/iconv
+install-sbin	= iconvconfig
+
+CFLAGS-gconv_cache.c += -DGCONV_DIR='"$(gconvdir)"'
+CFLAGS-gconv_conf.c = -DGCONV_PATH='"$(gconvdir)"'
+CFLAGS-iconvconfig.c = -DGCONV_PATH='"$(gconvdir)"' -DGCONV_DIR='"$(gconvdir)"'
+
+CPPFLAGS-iconv_prog = -DNOT_IN_libc
+CPPFLAGS-iconv_charmap = -DNOT_IN_libc
+CPPFLAGS-iconvconfig = -DNOT_IN_libc
+CPPFLAGS-linereader = -DNOT_IN_libc
+CPPFLAGS-strtab = -DNOT_IN_libc
+CPPFLAGS-charmap = -DNOT_IN_libc
+CPPFLAGS-charmap-dir = -DNOT_IN_libc
+
+include ../Rules
+
+$(inst_bindir)/iconv: $(objpfx)iconv_prog $(+force)
+	$(do-install-program)
+
+$(objpfx)iconv_prog: $(iconv_prog-modules:%=$(objpfx)%.o)
+$(objpfx)iconvconfig: $(iconvconfig-modules:%=$(objpfx)%.o)
+
+ifneq ($(cross-compiling),yes)
+xtests: test-iconvconfig
+endif
+
+.PHONY: test-iconvconfig
+test-iconvconfig: /dev/null $(objpfx)iconvconfig
+	tmp=$(objpfx)gconv-modules.cache.$$$$; \
+	rm -f $$tmp; \
+	$(make-test-out) --output=$$tmp --nostdlib $(inst_gconvdir) && \
+	cmp $$tmp $(inst_gconvdir)/gconv-modules.cache && \
+	rm -f $$tmp
Index: trunk/src/libctests/glibc/iconv/tst-iconv1.c
===================================================================
--- trunk/src/libctests/glibc/iconv/tst-iconv1.c	(revision 2036)
+++ trunk/src/libctests/glibc/iconv/tst-iconv1.c	(revision 2036)
@@ -0,0 +1,44 @@
+/* Test case by yaoz@nih.gov.  */
+
+#include <iconv.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
+
+int
+main (void)
+{
+  char utf8[5];
+  wchar_t ucs4[5];
+  iconv_t cd;
+  char *inbuf;
+  char *outbuf;
+  size_t inbytes;
+  size_t outbytes;
+  size_t n;
+
+  strcpy (utf8, "abcd");
+
+  /* From UTF8 to UCS4. */
+  cd = iconv_open ("UCS4", "UTF8");
+  if (cd == (iconv_t) -1)
+    {
+      perror ("iconv_open");
+      return 1;
+    }
+
+  inbuf = utf8;
+  inbytes = 4;
+  outbuf = (char *) ucs4;
+  outbytes = 4 * sizeof (wchar_t);    /* "Argument list too long" error. */
+  n = iconv (cd, &inbuf, &inbytes, &outbuf, &outbytes);
+  if (n == (size_t) -1)
+    {
+      printf ("iconv: %m\n");
+      iconv_close (cd);
+      return 1;
+    }
+  iconv_close (cd);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/iconv/tst-iconv2.c
===================================================================
--- trunk/src/libctests/glibc/iconv/tst-iconv2.c	(revision 2036)
+++ trunk/src/libctests/glibc/iconv/tst-iconv2.c	(revision 2036)
@@ -0,0 +1,100 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 2001.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <iconv.h>
+#include <mcheck.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+int
+main (void)
+{
+  char buf[3];
+  const wchar_t wc[1] = L"a";
+  iconv_t cd;
+  char *inptr;
+  size_t inlen;
+  char *outptr;
+  size_t outlen;
+  size_t n;
+  int e;
+  int result = 0;
+
+  mtrace ();
+
+  cd = iconv_open ("UCS4", "WCHAR_T");
+  if (cd == (iconv_t) -1)
+    {
+      printf ("cannot convert from wchar_t to UCS4: %m\n");
+      exit (1);
+    }
+
+  inptr = (char *) wc;
+  inlen = sizeof (wchar_t);
+  outptr = buf;
+  outlen = 3;
+
+  n = iconv (cd, &inptr, &inlen, &outptr, &outlen);
+  e = errno;
+
+  if (n != (size_t) -1)
+    {
+      printf ("incorrect iconv() return value: %zd, expected -1\n", n);
+      result = 1;
+    }
+
+  if (e != E2BIG)
+    {
+      printf ("incorrect error value: %s, expected %s\n",
+	      strerror (e), strerror (E2BIG));
+      result = 1;
+    }
+
+  if (inptr != (char *) wc)
+    {
+      puts ("inptr changed");
+      result = 1;
+    }
+
+  if (inlen != sizeof (wchar_t))
+    {
+      puts ("inlen changed");
+      result = 1;
+    }
+
+  if (outptr != buf)
+    {
+      puts ("outptr changed");
+      result = 1;
+    }
+
+  if (outlen != 3)
+    {
+      puts ("outlen changed");
+      result = 1;
+    }
+
+  iconv_close (cd);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/iconv/tst-iconv3.c
===================================================================
--- trunk/src/libctests/glibc/iconv/tst-iconv3.c	(revision 2036)
+++ trunk/src/libctests/glibc/iconv/tst-iconv3.c	(revision 2036)
@@ -0,0 +1,53 @@
+/* Contributed by Owen Taylor <otaylor@redhat.com>.  */
+
+#include <iconv.h>
+#include <errno.h>
+#include <stddef.h>
+#include <stdio.h>
+
+#define BUFSIZE 10000
+
+int
+main (int argc, char *argv[])
+{
+  char inbuf[BUFSIZE];
+  wchar_t outbuf[BUFSIZE];
+
+  iconv_t cd;
+  int i;
+  char *inptr;
+  char *outptr;
+  size_t inbytes_left, outbytes_left;
+  int count;
+  int result = 0;
+
+  for (i=0; i < BUFSIZE; i++)
+    inbuf[i] = 'a';
+
+  cd = iconv_open ("UCS-4LE", "UTF-8");
+
+  inbytes_left = BUFSIZE;
+  outbytes_left = BUFSIZE * 4;
+  inptr = inbuf;
+  outptr = (char *) outbuf;
+
+  count = iconv (cd, &inptr, &inbytes_left, &outptr, &outbytes_left);
+
+  if (count < 0)
+    {
+      if (errno == E2BIG)
+	printf ("Received E2BIG\n");
+      else
+	printf ("Received something else\n");
+
+      printf ("inptr change: %td\n", inptr - inbuf);
+      printf ("inlen change: %zd\n", BUFSIZE - inbytes_left);
+      printf ("outptr change: %td\n", outptr - (char *) outbuf);
+      printf ("outlen change: %zd\n", BUFSIZE * 4 - outbytes_left);
+      result = 1;
+    }
+  else
+    printf ("Succeeded\n");
+
+  return result;
+}
Index: trunk/src/libctests/glibc/iconv/tst-iconv5.c
===================================================================
--- trunk/src/libctests/glibc/iconv/tst-iconv5.c	(revision 2036)
+++ trunk/src/libctests/glibc/iconv/tst-iconv5.c	(revision 2036)
@@ -0,0 +1,158 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by GOTO Masanori <gotom@debian.or.jp>, 2004
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <iconv.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+
+#define SIZE 256		/* enough room for conversion */
+#define SAMPLESTR "abc"
+
+struct unalign
+{
+  char str1[1];
+  char str2[SIZE];
+};
+
+struct convcode
+{
+  const char *tocode;
+  const char *fromcode;
+};
+
+/* test builtin transformation */
+struct convcode testcode[] = {
+  {"ASCII", "ASCII"},
+  {"UTF-8", "ASCII"},
+  {"UCS-2BE", "ASCII"},
+  {"UCS-2LE", "ASCII"},
+  {"UCS-4BE", "ASCII"},
+  {"UCS-4LE", "ASCII"},
+};
+
+int number = (int) sizeof (testcode) / sizeof (struct convcode);
+
+int
+convert (const char *tocode, const char *fromcode, char *inbufp,
+	 size_t inbytesleft, char *outbufp, size_t outbytesleft)
+{
+  iconv_t *ic;
+  size_t outbytes = outbytesleft;
+  int ret;
+
+  ic = iconv_open (tocode, fromcode);
+  if (ic == (iconv_t *) - 1)
+    {
+      printf ("iconv_open failed: from: %s, to: %s: %s",
+	      fromcode, tocode, strerror (errno));
+      return -1;
+    }
+
+  while (inbytesleft > 0)
+    {
+      ret = iconv (ic, &inbufp, &inbytesleft, &outbufp, &outbytes);
+      if (ret == -1)
+	{
+	  printf ("iconv failed: from: %s, to: %s: %s",
+		  fromcode, tocode, strerror (errno));
+	  return -1;
+	}
+    }
+
+  ret = iconv_close (ic);
+  if (ret == -1)
+    {
+      printf ("iconv_close failed: from: %s, to: %s: %s",
+	      fromcode, tocode, strerror (errno));
+      return -1;
+    }
+
+  return outbytesleft - outbytes;
+}
+
+
+int
+test_unalign (struct convcode *codes, char *str, int len)
+{
+  struct unalign *inbufp, *outbufp;
+  char *inbuf, *outbuf;
+  size_t inbytesleft, outbytesleft;
+  int retlen;
+
+  /* allocating unaligned buffer for both inbuf and outbuf */
+  inbufp = (struct unalign *) malloc (sizeof (struct unalign));
+  if (!inbufp)
+    {
+      printf ("no memory available\n");
+      exit (1);
+    }
+  inbuf = inbufp->str2;
+
+  outbufp = (struct unalign *) malloc (sizeof (struct unalign));
+  if (!outbufp)
+    {
+      printf ("no memory available\n");
+      exit (1);
+    }
+  outbuf = outbufp->str2;
+
+  /* first iconv phase */
+  memcpy (inbuf, str, len);
+  inbytesleft = len;
+  outbytesleft = sizeof (struct unalign);
+  retlen = convert (codes->tocode, codes->fromcode, inbuf, inbytesleft,
+		    outbuf, outbytesleft);
+  if (retlen == -1)	/* failed */
+    return 1;
+
+  /* second round trip iconv phase */
+  memcpy (inbuf, outbuf, retlen);
+  inbytesleft = retlen;
+  outbytesleft = sizeof (struct unalign);
+  retlen = convert (codes->fromcode, codes->tocode, inbuf, inbytesleft,
+		    outbuf, outbytesleft);
+  if (retlen == -1)	/* failed */
+    return 1;
+
+  free (inbufp);
+  free (outbufp);
+
+  return 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+  int i;
+  int ret = 0;
+
+  for (i = 0; i < number; i++)
+    {
+      ret = test_unalign (&testcode[i], (char *) SAMPLESTR, sizeof (SAMPLESTR));
+      if (ret)
+	break;
+      printf ("iconv: %s <-> %s: ok\n",
+	      testcode[i].fromcode, testcode[i].tocode);
+    }
+  printf ("Succeeded.\n");
+
+  return ret;
+}
Index: trunk/src/libctests/glibc/inet/Makefile
===================================================================
--- trunk/src/libctests/glibc/inet/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/inet/Makefile	(revision 2036)
@@ -0,0 +1,98 @@
+# Copyright (C) 1991-2002, 2003, 2004 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Sub-makefile for inet portion of the library.
+#
+subdir	:= inet
+
+headers	:= netinet/ether.h netinet/in.h netinet/in_systm.h \
+	   netinet/if_ether.h netinet/igmp.h \
+	   netinet/tcp.h netinet/ip.h $(wildcard arpa/*.h protocols/*.h) \
+	   aliases.h ifaddrs.h netinet/ip6.h netinet/icmp6.h bits/in.h
+
+distribute := netgroup.h
+
+routines := htonl htons		\
+	    inet_lnaof inet_mkadr	\
+	    inet_netof inet_ntoa inet_net herrno herrno-loc \
+	    gethstbyad gethstbyad_r gethstbynm gethstbynm2 gethstbynm2_r \
+	    gethstbynm_r gethstent gethstent_r \
+	    getnetbyad getnetbyad_r getnetbynm getnetent getnetent_r \
+	    getnetbynm_r \
+	    getproto getproto_r getprtent getprtent_r getprtname getprtname_r \
+	    getsrvbynm getsrvbynm_r getsrvbypt getsrvbypt_r getservent \
+	    getservent_r	\
+	    getrpcent getrpcbyname getrpcbynumber \
+	    getrpcent_r getrpcbyname_r getrpcbynumber_r \
+	    ether_aton ether_aton_r ether_hton ether_line \
+	    ether_ntoa ether_ntoa_r ether_ntoh \
+	    rcmd rexec ruserpass \
+	    getnetgrent_r getnetgrent \
+	    getaliasent_r getaliasent getaliasname getaliasname_r \
+	    in6_addr getnameinfo if_index ifaddrs inet6_option \
+	    getipv4sourcefilter setipv4sourcefilter \
+	    getsourcefilter setsourcefilter
+
+aux := check_pf ifreq
+
+tests := htontest test_ifindex tst-ntoa tst-ether_aton tst-network \
+	 tst-gethnm test-ifaddrs bug-if1
+
+include ../Rules
+
+ifeq ($(have-thread-library),yes)
+
+CFLAGS-gethstbyad_r.c = -DUSE_NSCD=1 -fexceptions
+CFLAGS-gethstbyad.c = -fexceptions
+CFLAGS-gethstbynm_r.c = -DUSE_NSCD=1 -fexceptions
+CFLAGS-gethstbynm.c = -fexceptions
+CFLAGS-gethstbynm2_r.c = -DUSE_NSCD=1 -fexceptions
+CFLAGS-gethstbynm2.c = -fexceptions
+CFLAGS-gethstent_r.c = -fexceptions
+CFLAGS-gethstent.c = -fexceptions
+CFLAGS-rcmd.c = -fexceptions
+CFLAGS-getnetbynm_r.c = -fexceptions
+CFLAGS-getnetbynm.c = -fexceptions
+CFLAGS-getnetbyad_r.c = -fexceptions
+CFLAGS-getnetbyad.c = -fexceptions
+CFLAGS-getnetent_r.c = -fexceptions
+CFLAGS-getnetent.c = -fexceptions
+CFLAGS-getaliasent_r.c = -fexceptions
+CFLAGS-getaliasent.c = -fexceptions
+CFLAGS-getrpcent_r.c = -fexceptions
+CFLAGS-getrpcent.c = -fexceptions
+CFLAGS-getservent_r.c = -fexceptions
+CFLAGS-getservent.c = -fexceptions
+CFLAGS-getprtent_r.c = -fexceptions
+CFLAGS-getprtent.c = -fexceptions
+CFLAGS-either_ntoh.c = -fexceptions
+CFLAGS-either_hton.c = -fexceptions
+CFLAGS-getnetgrent.c = -fexceptions
+CFLAGS-getnetgrent_r.c = -fexceptions
+
+endif
+
+ifeq ($(build-static-nss),yes)
+CFLAGS += -DSTATIC_NSS
+endif
+
+ifeq (yes,$(build-static-nss))
+otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
+             $(resolvobjdir)/libresolv.a
+endif
Index: trunk/src/libctests/glibc/inet/bug-if1.c
===================================================================
--- trunk/src/libctests/glibc/inet/bug-if1.c	(revision 2036)
+++ trunk/src/libctests/glibc/inet/bug-if1.c	(revision 2036)
@@ -0,0 +1,54 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+#include <net/if.h>
+
+
+static int
+do_test (void)
+{
+  char buf[IF_NAMESIZE];
+  /* Index 0 is always invalid (see RFC 3493).  */
+  char *cp = if_indextoname (0, buf);
+  if (cp != NULL)
+    {
+      printf ("invalid index returned result \"%s\"\n", cp);
+      return 1;
+    }
+  else if (errno != ENXIO)
+    {
+      int err = errno;
+      char errbuf1[256];
+      char errbuf2[256];
+
+      printf ("errno = %d (%s), expected %d (%s)\n",
+	      err, strerror_r (err, errbuf1, sizeof (errbuf1)),
+	      ENXIO, strerror_r (ENXIO, errbuf2, sizeof (errbuf2)));
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/inet/htontest.c
===================================================================
--- trunk/src/libctests/glibc/inet/htontest.c	(revision 2036)
+++ trunk/src/libctests/glibc/inet/htontest.c	(revision 2036)
@@ -0,0 +1,71 @@
+/* Test hton/ntoh functions.
+   Copyright (C) 1997, 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <endian.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+
+#if BYTE_ORDER == BIG_ENDIAN
+# define TEST(orig, swapped, fct) \
+  if ((fct (orig)) != (orig)) {						      \
+    printf ("Failed for %s -> %#x\n", #fct "(" #orig ")", fct (orig));	      \
+    result = 1;								      \
+  }
+#elif BYTE_ORDER == LITTLE_ENDIAN
+# define TEST(orig, swapped, fct) \
+  if ((fct (orig)) != (swapped)) {					      \
+    printf ("Failed for %s -> %#x\n", #fct "(" #orig ")", fct (orig));	      \
+    result = 1;								      \
+  }
+#else
+# error "Bah, what kind of system do you use?"
+#endif
+
+u_int32_t lo = 0x67452301;
+u_int16_t foo = 0x1234;
+
+int
+main (void)
+{
+  int result = 0;
+
+  TEST (0x67452301, 0x01234567, htonl);
+  TEST (0x67452301, 0x01234567, (htonl));
+  TEST (0x67452301, 0x01234567, ntohl);
+  TEST (0x67452301, 0x01234567, (ntohl));
+
+  TEST (lo, 0x01234567, htonl);
+  TEST (lo, 0x01234567, (htonl));
+  TEST (lo, 0x01234567, ntohl);
+  TEST (lo, 0x01234567, (ntohl));
+
+  TEST (0x1234, 0x3412, htons);
+  TEST (0x1234, 0x3412, (htons));
+  TEST (0x1234, 0x3412, ntohs);
+  TEST (0x1234, 0x3412, (ntohs));
+
+  TEST (foo, 0x3412, htons);
+  TEST (foo, 0x3412, (htons));
+  TEST (foo, 0x3412, ntohs);
+  TEST (foo, 0x3412, (ntohs));
+
+  return result;
+}
Index: trunk/src/libctests/glibc/inet/test-ifaddrs.c
===================================================================
--- trunk/src/libctests/glibc/inet/test-ifaddrs.c	(revision 2036)
+++ trunk/src/libctests/glibc/inet/test-ifaddrs.c	(revision 2036)
@@ -0,0 +1,100 @@
+/* Test listing of network interface addresses.
+   Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ifaddrs.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+static int failures;
+
+static const char *
+addr_string (struct sockaddr *sa, char *buf, size_t size)
+{
+  if (sa == NULL)
+    return "<none>";
+
+  switch (sa->sa_family)
+    {
+    case AF_INET:
+      return inet_ntop (AF_INET, &((struct sockaddr_in *) sa)->sin_addr,
+			buf, size);
+    case AF_INET6:
+      return inet_ntop (AF_INET6, &((struct sockaddr_in6 *) sa)->sin6_addr,
+			buf, size);
+#ifdef AF_LINK
+    case AF_LINK:
+      return "<link>";
+#endif
+    case AF_UNSPEC:
+      return "---";
+
+#ifdef AF_PACKET
+    case AF_PACKET:
+      return "<packet>";
+#endif
+
+    default:
+      ++failures;
+      printf ("sa_family=%d %08x\n", sa->sa_family,
+	      *(int*)&((struct sockaddr_in *) sa)->sin_addr.s_addr);
+      return "<unexpected sockaddr family>";
+    }
+}
+
+
+static int
+do_test (void)
+{
+  struct ifaddrs *ifaces, *ifa;
+
+  if (getifaddrs (&ifaces) < 0)
+    {
+      if (errno != ENOSYS)
+	{
+	  printf ("Couldn't get any interfaces: %s.\n", strerror (errno));
+	  exit (1);
+	}
+      /* The function is simply not implemented.  */
+      exit (0);
+    }
+
+  puts ("\
+Name           Flags   Address         Netmask         Broadcast/Destination");
+
+  for (ifa = ifaces; ifa != NULL; ifa = ifa->ifa_next)
+    {
+      char abuf[64], mbuf[64], dbuf[64];
+      printf ("%-15s%#.4x  %-15s %-15s %-15s\n",
+	      ifa->ifa_name, ifa->ifa_flags,
+	      addr_string (ifa->ifa_addr, abuf, sizeof (abuf)),
+	      addr_string (ifa->ifa_netmask, mbuf, sizeof (mbuf)),
+	      addr_string (ifa->ifa_broadaddr, dbuf, sizeof (dbuf)));
+    }
+
+  freeifaddrs (ifaces);
+
+  return failures ? 1 : 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/inet/test_ifindex.c
===================================================================
--- trunk/src/libctests/glibc/inet/test_ifindex.c	(revision 2036)
+++ trunk/src/libctests/glibc/inet/test_ifindex.c	(revision 2036)
@@ -0,0 +1,68 @@
+/* Test interface name <-> index conversions.
+   Copyright (C) 1997, 2000, 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Philip Blundell <Philip.Blundell@pobox.com>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <net/if.h>
+
+static int
+do_test (void)
+{
+  int failures = 0;
+  struct if_nameindex *idx = if_nameindex (), *p;
+  if (idx == NULL)
+    {
+      if (errno != ENOSYS)
+	{
+	  printf ("Couldn't get any interfaces.\n");
+	  exit (1);
+	}
+      /* The function is simply not implemented.  */
+      exit (0);
+    }
+
+  printf ("Idx            Name | Idx           Name\n");
+
+  for (p = idx; p->if_index || p->if_name; ++p)
+    {
+      char buf[IFNAMSIZ];
+      unsigned int ni;
+      int result;
+      printf ("%3d %15s | ", p->if_index, p->if_name);
+      printf ("%3d", ni = if_nametoindex (p->if_name));
+      printf ("%15s", if_indextoname (p->if_index, buf));
+      result = (ni != p->if_index || (strcmp (buf, p->if_name)));
+      if (ni == p->if_index)
+	/* We have to make sure that this is not an alias with the
+	   same interface number.  */
+	if (p->if_index == if_nametoindex (buf))
+	  result = 0;
+      printf ("%10s", result ? "fail" : "okay");
+      printf ("\n");
+      failures += result;
+    }
+  if_freenameindex (idx);
+  return failures ? 1 : 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/inet/tst-ether_aton.c
===================================================================
--- trunk/src/libctests/glibc/inet/tst-ether_aton.c	(revision 2036)
+++ trunk/src/libctests/glibc/inet/tst-ether_aton.c	(revision 2036)
@@ -0,0 +1,57 @@
+#include <stdio.h>
+#include <string.h>
+#include <netinet/ether.h>
+
+int
+main (int argc, char *argv[])
+{
+  struct ether_addr *valp, val;
+  int result, r;
+  char hostname[32], buf[64], *p;
+
+  valp = ether_aton ("12:34:56:78:9a:bc");
+
+  printf ("ether_aton (\"12:34:56:78:9a:bc\") = %hhx:%hhx:%hhx:%hhx:%hhx:%hhx\n",
+	  valp->ether_addr_octet[0],
+	  valp->ether_addr_octet[1],
+	  valp->ether_addr_octet[2],
+	  valp->ether_addr_octet[3],
+	  valp->ether_addr_octet[4],
+	  valp->ether_addr_octet[5]);
+
+  result = (valp->ether_addr_octet[0] != 0x12
+	    || valp->ether_addr_octet[1] != 0x34
+	    || valp->ether_addr_octet[2] != 0x56
+	    || valp->ether_addr_octet[3] != 0x78
+	    || valp->ether_addr_octet[4] != 0x9a
+	    || valp->ether_addr_octet[5] != 0xbc);
+
+  if ((r = ether_line ("0:c0:f0:46:5f:97 host.ether.com \t# comment",
+		       &val, hostname)) == 0)
+    {
+      ether_ntoa_r (&val, buf);
+      p = strchr (buf, '\0');
+      *p++ = ' ';
+      strcpy (p, hostname);
+
+      printf ("ether_line (\"0:c0:f0:46:5f:97 host.ether.com\") = \"%s\"\n",
+	      buf);
+
+      result |= strcmp ("0:c0:f0:46:5f:97 host.ether.com", buf) != 0;
+    }
+  else
+    {
+      printf ("ether_line (\"0:c0:f0:46:5f:97 host.ether.com\") = %d\n", r);
+      result |= 1;
+    }
+
+  r = ether_line ("0:c0:2:d0 foo.bar   ", &val, hostname);
+  printf ("ether_line (\"0:c0:2:d0 foo.bar   \") = %d\n", r);
+  result |= r != -1;
+
+  r = ether_line ("0:c0:2:d0:1a:2a  ", &val, hostname);
+  printf ("ether_line (\"0:c0:2:d0:1a:2a  \") = %d\n", r);
+  result |= r != -1;
+
+  return result;
+}
Index: trunk/src/libctests/glibc/inet/tst-gethnm.c
===================================================================
--- trunk/src/libctests/glibc/inet/tst-gethnm.c	(revision 2036)
+++ trunk/src/libctests/glibc/inet/tst-gethnm.c	(revision 2036)
@@ -0,0 +1,64 @@
+/* Based on a test case by grd@algonet.se.  */
+
+#include <netdb.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+int
+main (void)
+{
+  struct hostent *ent;
+  struct in_addr hostaddr;
+  int result = 0;
+
+  inet_aton ("127.0.0.1", (struct in_addr *) &hostaddr.s_addr);
+  ent = gethostbyaddr (&hostaddr, sizeof (hostaddr), AF_INET);
+  if (ent == NULL)
+    puts ("gethostbyaddr (...) == NULL");
+  else
+    {
+      puts ("Using gethostbyaddr(..):");
+      printf ("h_name: %s\n", ent->h_name);
+
+      if (ent->h_aliases == NULL)
+	puts ("ent->h_aliases == NULL");
+      else
+	printf ("h_aliases[0]: %s\n", ent->h_aliases[0]);
+    }
+
+  ent = gethostbyname ("127.0.0.1");
+  if (ent == NULL)
+    {
+      puts ("gethostbyname (\"127.0.0.1\") == NULL");
+      result = 1;
+    }
+  else
+    {
+      printf ("\nNow using gethostbyname(..):\n");
+      printf ("h_name: %s\n", ent->h_name);
+      if (strcmp (ent->h_name, "127.0.0.1") != 0)
+	{
+	  puts ("ent->h_name != \"127.0.0.1\"");
+	  result = 1;
+	}
+
+      if (ent->h_aliases == NULL)
+	{
+	  puts ("ent->h_aliases == NULL");
+	  result = 1;
+	}
+      else
+	{
+	  printf ("h_aliases[0]: %s\n", ent->h_aliases[0]);
+	  result |= ent->h_aliases[0] != NULL;
+	}
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/inet/tst-network.c
===================================================================
--- trunk/src/libctests/glibc/inet/tst-network.c	(revision 2036)
+++ trunk/src/libctests/glibc/inet/tst-network.c	(revision 2036)
@@ -0,0 +1,73 @@
+/* Test for inet_network.
+   Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@suse.de>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+struct
+{
+  const char *network;
+  uint32_t number;
+} tests [] =
+{
+  {"1.0.0.0", 0x1000000},
+  {"1.0.0", 0x10000},
+  {"1.0", 0x100},
+  {"1", 0x1},
+  {"192.168.0.0", 0xC0A80000},
+  /* Now some invalid addresses.  */
+  {"141.30.225.2800", INADDR_NONE},
+  {"141.76.1.1.1", INADDR_NONE},
+  {"141.76.1.11.", INADDR_NONE},
+  {"1410", INADDR_NONE},
+  {"1.1410", INADDR_NONE},
+  {"1.1410.", INADDR_NONE},
+  {"1.1410", INADDR_NONE},
+  {"141.76.1111", INADDR_NONE},
+  {"141.76.1111.", INADDR_NONE}
+};
+
+
+int
+main (void)
+{
+  int errors = 0;
+  size_t i;
+  uint32_t res;
+
+  for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
+    {
+      printf ("Testing: %s\n", tests[i].network);
+      res = inet_network (tests[i].network);
+
+      if (res != tests[i].number)
+	{
+	  printf ("Test failed for inet_network (\"%s\"):\n",
+		  tests[i].network);
+	  printf ("Expected return value %u (0x%x) but got %u (0x%x).\n",
+		  tests[i].number, tests[i].number, res, res);
+	}
+
+    }
+
+  return errors != 0;
+}
Index: trunk/src/libctests/glibc/inet/tst-ntoa.c
===================================================================
--- trunk/src/libctests/glibc/inet/tst-ntoa.c	(revision 2036)
+++ trunk/src/libctests/glibc/inet/tst-ntoa.c	(revision 2036)
@@ -0,0 +1,36 @@
+#include <stdio.h>
+#include <string.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+
+
+static int
+test (unsigned int inaddr, const char *expected)
+{
+  struct in_addr addr;
+  char *res;
+  int fail;
+
+  addr.s_addr = htonl (inaddr);
+  res = inet_ntoa (addr);
+  fail = strcmp (res, expected);
+
+  printf ("%#010x -> \"%s\" -> %s%s\n", inaddr, res,
+	  fail ? "fail, expected" : "ok", fail ? expected : "");
+
+  return fail;
+}
+
+
+int
+main (void)
+{
+  int result = 0;
+
+  result |= test (INADDR_LOOPBACK, "127.0.0.1");
+  result |= test (INADDR_BROADCAST, "255.255.255.255");
+  result |= test (INADDR_ANY, "0.0.0.0");
+  result |= test (0xc0060746, "192.6.7.70");
+
+  return result;
+}
Index: trunk/src/libctests/glibc/intl/Makefile
===================================================================
--- trunk/src/libctests/glibc/intl/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/intl/Makefile	(revision 2036)
@@ -0,0 +1,131 @@
+# Copyright (C) 1995-2003, 2005 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+# Makefile for intl subdirectory: message handling code from GNU gettext.
+
+subdir = intl
+headers = libintl.h
+routines = bindtextdom dcgettext dgettext gettext	\
+	   dcigettext dcngettext dngettext ngettext \
+	   finddomain loadmsgcat localealias textdomain
+aux =	   l10nflist explodename plural plural-exp hash-string
+distribute = gmo.h gettextP.h hash-string.h loadinfo.h locale.alias \
+	     plural.y plural-exp.h plural-eval.c po2test.sed \
+	     tst-gettext.sh \
+	     tst-translit.sh translit.po \
+	     tst-gettext2.sh tstlang1.po tstlang2.po \
+	     tst-codeset.sh tstcodeset.po \
+	     tst-gettext3.sh \
+	     tst-gettext4.sh tst-gettext4-de.po tst-gettext4-fr.po \
+	     tst-gettext5.sh
+
+include ../Makeconfig
+
+multithread-test-srcs := tst-gettext4 tst-gettext5
+test-srcs := tst-gettext tst-translit tst-gettext2 tst-codeset tst-gettext3
+ifeq ($(have-thread-library),yes)
+test-srcs += $(multithread-test-srcs)
+endif
+tests = tst-ngettext
+
+before-compile = $(objpfx)msgs.h
+
+install-others = $(inst_msgcatdir)/locale.alias
+
+generated = msgs.h mtrace-tst-gettext tst-gettext.mtrace
+generated-dirs := domaindir localedir
+
+ifneq (no,$(BISON))
+plural.c: plural.y
+	$(BISON) $(BISONFLAGS) $@ $^
+ifeq ($(with-cvs),yes)
+	test ! -d CVS || cvs $(CVSOPTS) commit -m'$(BISON) $(BISONFLAGS) $@ $^' $@
+endif
+endif
+$(objpfx)plural.o: plural.c
+
+include ../Rules
+
+ifeq (no,$(cross-compiling))
+ifeq (yes,$(build-shared))
+ifneq ($(strip $(MSGFMT)),:)
+tests: $(objpfx)tst-translit.out $(objpfx)tst-gettext2.out \
+       $(objpfx)tst-codeset.out $(objpfx)tst-gettext3.out
+ifeq ($(have-thread-library),yes)
+tests: $(objpfx)tst-gettext4.out $(objpfx)tst-gettext5.out
+endif
+ifneq (no,$(PERL))
+tests: $(objpfx)mtrace-tst-gettext
+endif
+endif
+$(objpfx)mtrace-tst-gettext: $(objpfx)tst-gettext.out
+	$(common-objpfx)malloc/mtrace $(objpfx)tst-gettext.mtrace > $@
+$(objpfx)tst-gettext.out: tst-gettext.sh $(objpfx)tst-gettext
+	$(SHELL) -e $< $(common-objpfx) $(common-objpfx)intl/ \
+	  $(objpfx)tst-gettext.mtrace
+$(objpfx)tst-translit.out: tst-translit.sh $(objpfx)tst-translit
+	$(SHELL) -e $< $(common-objpfx) $(common-objpfx)intl/
+$(objpfx)tst-gettext2.out: tst-gettext2.sh $(objpfx)tst-gettext2
+	$(SHELL) -e $< $(common-objpfx) $(common-objpfx)intl/
+$(objpfx)tst-codeset.out: tst-codeset.sh $(objpfx)tst-codeset
+	$(SHELL) -e $< $(common-objpfx) $(common-objpfx)intl/
+$(objpfx)tst-gettext3.out: tst-gettext3.sh $(objpfx)tst-gettext3
+	$(SHELL) -e $< $(common-objpfx) $(common-objpfx)intl/
+$(objpfx)tst-gettext4.out: tst-gettext4.sh $(objpfx)tst-gettext4
+	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' $(common-objpfx)intl/
+$(objpfx)tst-gettext5.out: tst-gettext5.sh $(objpfx)tst-gettext5
+	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' $(common-objpfx)intl/
+endif
+endif
+
+$(objpfx)msgs.h: po2test.sed ../po/de.po
+	$(make-target-directory)
+	LC_ALL=C sed -f $^ > $@
+
+CFLAGS-tst-gettext.c = -DTESTSTRS_H=\"$(objpfx)msgs.h\"
+CFLAGS-tst-translit.c = -DOBJPFX=\"$(objpfx)\"
+CFLAGS-tst-gettext2.c = -DOBJPFX=\"$(objpfx)\"
+CFLAGS-tst-codeset.c = -DOBJPFX=\"$(objpfx)\"
+CFLAGS-tst-gettext3.c = -DOBJPFX=\"$(objpfx)\"
+CFLAGS-tst-gettext4.c = -DOBJPFX=\"$(objpfx)\"
+CFLAGS-tst-gettext5.c = -DOBJPFX=\"$(objpfx)\"
+
+ifeq ($(have-thread-library),yes)
+ifeq (yes,$(build-shared))
+$(addprefix $(objpfx),$(multithread-test-srcs)): $(shared-thread-library)
+else
+$(addprefix $(objpfx),$(multithread-test-srcs)): $(static-thread-library)
+endif
+ifeq (yes,$(build-bounded))
+$(multithread-test-srcs:%=$(objpfx)%-bp): $(bounded-thread-library)
+endif
+endif
+
+$(objpfx)tst-translit.out: $(objpfx)tst-gettext.out
+$(objpfx)tst-gettext2.out: $(objpfx)tst-gettext.out
+$(objpfx)tst-codeset.out: $(objpfx)tst-gettext.out
+$(objpfx)tst-gettext3.out: $(objpfx)tst-gettext.out
+$(objpfx)tst-gettext4.out: $(objpfx)tst-gettext.out
+$(objpfx)tst-gettext5.out: $(objpfx)tst-gettext.out
+
+CPPFLAGS += -D'LOCALEDIR="$(msgcatdir)"' \
+	    -D'LOCALE_ALIAS_PATH="$(msgcatdir)"'
+BISONFLAGS = --yacc --name-prefix=__gettext --output
+
+$(inst_msgcatdir)/locale.alias: locale.alias $(+force)
+	$(do-install)
Index: trunk/src/libctests/glibc/intl/po2test.sed
===================================================================
--- trunk/src/libctests/glibc/intl/po2test.sed	(revision 2036)
+++ trunk/src/libctests/glibc/intl/po2test.sed	(revision 2036)
@@ -0,0 +1,52 @@
+# po2test.sed - Convert Uniforum style .po file to C code for testing.
+# Copyright (C) 2000,2003 Free Software Foundation, Inc.
+# Ulrich Drepper <drepper@cygnus.com>, 2000.
+#
+# 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 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+
+#
+# We copy the original message as a comment into the .msg file.  But enclose
+# them with INPUT ( ).
+#
+s/^msgid[ 	]*"\(.*\)"/INPUT ("\1")/
+# Clear flag from last substitution and jump if matching
+tb
+
+#
+# Copy the translations as well and enclose them with OUTPUT ( ).
+#
+s/^msgstr[ 	]*"\(.*\)"/OUTPUT ("\1")/
+# Clear flag from last substitution and jump if matching
+tb
+
+d
+
+:b
+# Append the next line.
+$!N
+# Check whether second part is a continuation line.  If so, before printing
+# insert '\'.
+s/\(.*\)")\(\n\)"\(.*\)"/\1\\\2\3")/
+P
+ta
+# No, go to the top and process it. Note that `D' includes a jump to the start!!
+D
+# Yes, we found a continuation line.
+:a
+# We cannot use the sed command `D' here
+s/[^\n]*\n//
+# Clear the substitution flag and do the next line.
+tb
Index: trunk/src/libctests/glibc/intl/tst-codeset.c
===================================================================
--- trunk/src/libctests/glibc/intl/tst-codeset.c	(revision 2036)
+++ trunk/src/libctests/glibc/intl/tst-codeset.c	(revision 2036)
@@ -0,0 +1,58 @@
+/* Test of bind_textdomain_codeset.
+   Copyright (C) 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Bruno Haible <haible@clisp.cons.org>, 2001.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <libintl.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main (void)
+{
+  char *s;
+  int result = 0;
+
+  unsetenv ("LANGUAGE");
+  unsetenv ("OUTPUT_CHARSET");
+  setlocale (LC_ALL, "de_DE.ISO-8859-1");
+  textdomain ("codeset");
+  bindtextdomain ("codeset", OBJPFX "domaindir");
+
+  /* Here we expect output in ISO-8859-1.  */
+  s = gettext ("cheese");
+  if (strcmp (s, "K\344se"))
+    {
+      printf ("call 1 returned: %s\n", s);
+      result = 1;
+    }
+
+  bind_textdomain_codeset ("codeset", "UTF-8");
+
+  /* Here we expect output in UTF-8.  */
+  s = gettext ("cheese");
+  if (strcmp (s, "K\303\244se"))
+    {
+      printf ("call 2 returned: %s\n", s);
+      result = 1;
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/intl/tst-codeset.sh
===================================================================
--- trunk/src/libctests/glibc/intl/tst-codeset.sh	(revision 2036)
+++ trunk/src/libctests/glibc/intl/tst-codeset.sh	(revision 2036)
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Test of bind_textdomain_codeset.
+# Copyright (C) 2001, 2002, 2005 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+common_objpfx=$1
+objpfx=$2
+
+LC_ALL=C
+export LC_ALL
+
+# Generate the test data.
+msgfmt -o ${objpfx}codeset.mo.$$ tstcodeset.po || exit
+# Create the domain directories.
+mkdir -p ${objpfx}domaindir/de_DE/LC_MESSAGES
+# Populate them.
+mv -f ${objpfx}codeset.mo.$$ ${objpfx}domaindir/de_DE/LC_MESSAGES/codeset.mo
+
+GCONV_PATH=${common_objpfx}iconvdata
+export GCONV_PATH
+LOCPATH=${common_objpfx}localedata
+export LOCPATH
+
+${common_objpfx}elf/ld.so --library-path $common_objpfx \
+${objpfx}tst-codeset > ${objpfx}tst-codeset.out
+
+exit $?
Index: trunk/src/libctests/glibc/intl/tst-gettext.c
===================================================================
--- trunk/src/libctests/glibc/intl/tst-gettext.c	(revision 2036)
+++ trunk/src/libctests/glibc/intl/tst-gettext.c	(revision 2036)
@@ -0,0 +1,369 @@
+/* Test of the gettext functions.
+   Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <libintl.h>
+#include <locale.h>
+#include <mcheck.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <error.h>
+#include <errno.h>
+
+
+const struct
+{
+  const char *msgid;
+  const char *msgstr;
+} msgs[] =
+{
+#define INPUT(Str) { Str,
+#define OUTPUT(Str) Str },
+#include TESTSTRS_H
+};
+
+const char *catname[] =
+{
+  [LC_MESSAGES] = "LC_MESSAGES",
+  [LC_TIME] = "LC_TIME",
+  [LC_NUMERIC] = "LC_NUMERIC"
+};
+
+
+static int positive_gettext_test (void);
+static int negative_gettext_test (void);
+static int positive_dgettext_test (const char *domain);
+static int positive_dcgettext_test (const char *domain, int category);
+static int negative_dcgettext_test (const char *domain, int category);
+
+
+#define check_setlocale(cat, name) do {					      \
+    if (setlocale (cat, name) == NULL)					      \
+      {									      \
+	printf ("%s:%u: setlocale (%s, \"%s\"): %m\n",			      \
+		__FILE__, __LINE__, #cat, name);			      \
+	result = 1;							      \
+      }									      \
+  } while (0)
+
+int
+main (int argc, char *argv[])
+{
+  int result = 0;
+
+  /* For debugging.  */
+  mtrace ();
+
+  /* This is the place where the .mo files are placed.  */
+  if (argc > 1)
+    {
+      bindtextdomain ("existing-domain", argv[1]);
+      bindtextdomain ("existing-time-domain", argv[1]);
+      bindtextdomain ("non-existing-domain", argv[1]);
+    }
+
+  /* The locale the catalog is created for is "existing-category".  Now
+     set the various variables in question to this value and run the
+     test.  */
+  setenv ("LANGUAGE", "existing-locale", 1);
+  setenv ("LC_ALL", "non-existing-locale", 1);
+  setenv ("LC_MESSAGES", "non-existing-locale", 1);
+  setenv ("LC_CTYPE", "non-existing-locale", 1);
+  setenv ("LANG", "non-existing-locale", 1);
+  check_setlocale (LC_CTYPE, "de_DE.UTF-8");
+  check_setlocale (LC_MESSAGES, "de_DE.UTF-8");
+  unsetenv ("OUTPUT_CHARSET");
+  /* This is the name of the existing domain with a catalog for the
+     LC_MESSAGES category.  */
+  textdomain ("existing-domain");
+  puts ("test `gettext' with LANGUAGE set");
+  if (positive_gettext_test () != 0)
+    {
+      puts ("FAILED");
+      result = 1;
+    }
+  /* This is the name of a non-existing domain with a catalog for the
+     LC_MESSAGES category.  We leave this value set for the `dgettext'
+     and `dcgettext' tests.  */
+  textdomain ("non-existing-domain");
+  puts ("test `gettext' with LANGUAGE set");
+  if (negative_gettext_test () != 0)
+    {
+      puts ("FAILED");
+      result = 1;
+    }
+  puts ("test `dgettext' with LANGUAGE set");
+  if (positive_dgettext_test ("existing-domain") != 0)
+    {
+      puts ("FAILED");
+      result = 1;
+    }
+
+  /* Now the same tests with LC_ALL deciding.  */
+  unsetenv ("LANGUAGE");
+  setenv ("LC_ALL", "existing-locale", 1);
+  check_setlocale (LC_ALL, "");
+  puts ("test `gettext' with LC_ALL set");
+  /* This is the name of the existing domain with a catalog for the
+     LC_MESSAGES category.  */
+  textdomain ("existing-domain");
+  if (positive_gettext_test () != 0)
+    {
+      puts ("FAILED");
+      result = 1;
+    }
+  /* This is the name of a non-existing domain with a catalog for the
+     LC_MESSAGES category.  We leave this value set for the `dgettext'
+     and `dcgettext' tests.  */
+  textdomain ("non-existing-domain");
+  puts ("test `gettext' with LC_ALL deciding");
+  if (negative_gettext_test () != 0)
+    {
+      puts ("FAILED");
+      result = 1;
+    }
+  puts ("test `dgettext' with LC_ALL deciding");
+  if (positive_dgettext_test ("existing-domain") != 0)
+    {
+      puts ("FAILED");
+      result = 1;
+    }
+
+  /* Now the same tests with LC_MESSAGES deciding.  */
+  unsetenv ("LC_ALL");
+  setenv ("LC_MESSAGES", "existing-locale", 1);
+  check_setlocale (LC_MESSAGES, "");
+  setenv ("LC_TIME", "existing-locale", 1);
+  check_setlocale (LC_TIME, "");
+  setenv ("LC_NUMERIC", "non-existing-locale", 1);
+  char *what = setlocale (LC_NUMERIC, "");
+  if (what != NULL)
+    {
+      printf ("setlocale succeeded (%s), expected failure\n", what);
+      result = 1;
+    }
+
+  puts ("test `gettext' with LC_MESSAGES set");
+  /* This is the name of the existing domain with a catalog for the
+     LC_MESSAGES category.  */
+  textdomain ("existing-domain");
+  if (positive_gettext_test () != 0)
+    {
+      puts ("FAILED");
+      result = 1;
+    }
+  /* This is the name of a non-existing domain with a catalog for the
+     LC_MESSAGES category.  We leave this value set for the `dgettext'
+     and `dcgettext' tests.  */
+  textdomain ("non-existing-domain");
+  puts ("test `gettext' with LC_MESSAGES deciding");
+  if (negative_gettext_test () != 0)
+    {
+      puts ("FAILED");
+      result = 1;
+    }
+  puts ("test `dgettext' with LC_MESSAGES deciding");
+  if (positive_dgettext_test ("existing-domain") != 0)
+    {
+      puts ("FAILED");
+      result = 1;
+    }
+  puts ("test `dcgettext' with category == LC_MESSAGES");
+  if (positive_dcgettext_test ("existing-domain", LC_MESSAGES) != 0)
+    {
+      puts ("FAILED");
+      result = 1;
+    }
+  /* Try a different category.  For this we also switch the domain.  */
+  puts ("test `dcgettext' with LANGUAGE == LC_TIME");
+  if (positive_dcgettext_test ("existing-time-domain", LC_TIME) != 0)
+    {
+      puts ("FAILED");
+      result = 1;
+    }
+  /* This time use a category for which there is no catalog.  */
+  puts ("test `dcgettext' with LANGUAGE == LC_NUMERIC");
+  if (negative_dcgettext_test ("existing-domain", LC_NUMERIC) != 0)
+    {
+      puts ("FAILED");
+      result = 1;
+    }
+
+  /* Now the same tests with LANG deciding.  */
+  unsetenv ("LC_MESSAGES");
+  unsetenv ("LC_CTYPE");
+  unsetenv ("LC_TIME");
+  unsetenv ("LC_NUMERIC");
+  setenv ("LANG", "existing-locale", 1);
+  check_setlocale (LC_ALL, "");
+  /* This is the name of the existing domain with a catalog for the
+     LC_MESSAGES category.  */
+  textdomain ("existing-domain");
+  puts ("test `gettext' with LANG set");
+  if (positive_gettext_test () != 0)
+    {
+      puts ("FAILED");
+      result = 1;
+    }
+  /* This is the name of a non-existing domain with a catalog for the
+     LC_MESSAGES category.  We leave this value set for the `dgettext'
+     and `dcgettext' tests.  */
+  textdomain ("non-existing-domain");
+  puts ("test `gettext' with LANG set");
+  if (negative_gettext_test () != 0)
+    {
+      puts ("FAILED");
+      result = 1;
+    }
+  puts ("test `dgettext' with LANG set");
+  if (positive_dgettext_test ("existing-domain") != 0)
+    {
+      puts ("FAILED");
+      result = 1;
+    }
+
+  check_setlocale (LC_ALL, "C");
+
+  return result;
+}
+
+
+static int
+positive_gettext_test (void)
+{
+  size_t cnt;
+  int result = 0;
+
+  for (cnt = 0; cnt < sizeof (msgs) / sizeof (msgs[0]); ++cnt)
+    {
+      const char *found = gettext (msgs[cnt].msgid);
+
+      if (found == NULL
+	  || (msgs[cnt].msgstr[0] != '\0'
+	      && strcmp (found, msgs[cnt].msgstr) != 0))
+	{
+	  /* Oops, shouldn't happen.  */
+	  printf ("\
+  gettext (\"%s\") failed, returned \"%s\", expected \"%s\"\n",
+		  msgs[cnt].msgid, found, msgs[cnt].msgstr);
+	  result = 1;
+	}
+    }
+
+  return result;
+}
+
+
+static int
+negative_gettext_test (void)
+{
+  size_t cnt;
+  int result = 0;
+
+  for (cnt = 0; cnt < sizeof (msgs) / sizeof (msgs[0]); ++cnt)
+    {
+      const char *found = gettext (msgs[cnt].msgid);
+
+      if (found != msgs[cnt].msgid)
+	{
+	  /* Oops, shouldn't happen.  */
+	  printf ("  gettext (\"%s\") failed\n", msgs[cnt].msgid);
+	  result = 1;
+	}
+    }
+
+  return result;
+}
+
+
+static int
+positive_dgettext_test (const char *domain)
+{
+  size_t cnt;
+  int result = 0;
+
+  for (cnt = 0; cnt < sizeof (msgs) / sizeof (msgs[0]); ++cnt)
+    {
+      const char *found = dgettext (domain, msgs[cnt].msgid);
+
+      if (found == NULL
+	  || (msgs[cnt].msgstr[0] != '\0'
+	      && strcmp (found, msgs[cnt].msgstr) != 0))
+	{
+	  /* Oops, shouldn't happen.  */
+	  printf ("\
+  dgettext (\"%s\", \"%s\") failed, returned \"%s\", expected \"%s\"\n",
+		  domain, msgs[cnt].msgid, found, msgs[cnt].msgstr);
+	  result = 1;
+	}
+    }
+
+  return result;
+}
+
+
+static int
+positive_dcgettext_test (const char *domain, int category)
+{
+  size_t cnt;
+  int result = 0;
+
+  for (cnt = 0; cnt < sizeof (msgs) / sizeof (msgs[0]); ++cnt)
+    {
+      const char *found = dcgettext (domain, msgs[cnt].msgid, category);
+
+      if (found == NULL
+	  || (msgs[cnt].msgstr[0] != '\0'
+	      && strcmp (found, msgs[cnt].msgstr) != 0))
+	{
+	  /* Oops, shouldn't happen.  */
+	  printf ("\
+  dcgettext (\"%s\", \"%s\", %s) failed, returned \"%s\", expected \"%s\"\n",
+		  domain, msgs[cnt].msgid, catname[category], found,
+		  msgs[cnt].msgstr);
+	  result = 1;
+	}
+    }
+
+  return result;
+}
+
+
+static int
+negative_dcgettext_test (const char *domain, int category)
+{
+  size_t cnt;
+  int result = 0;
+
+  for (cnt = 0; cnt < sizeof (msgs) / sizeof (msgs[0]); ++cnt)
+    {
+      const char *found = dcgettext (domain, msgs[cnt].msgid, category);
+
+      if (found != msgs[cnt].msgid)
+	{
+	  /* Oops, shouldn't happen.  */
+	  printf ("  dcgettext (\"%s\", \"%s\", %s) failed\n",
+		  domain, msgs[cnt].msgid, catname[category]);
+	  result = 1;
+	}
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/intl/tst-gettext.sh
===================================================================
--- trunk/src/libctests/glibc/intl/tst-gettext.sh	(revision 2036)
+++ trunk/src/libctests/glibc/intl/tst-gettext.sh	(revision 2036)
@@ -0,0 +1,59 @@
+#! /bin/sh
+# Test of gettext functions.
+# Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+common_objpfx=$1
+objpfx=$2
+malloc_trace=$3
+
+LC_ALL=C
+export LC_ALL
+
+# Generate the test data.
+
+# Create the locale directories.
+mkdir -p ${objpfx}localedir/existing-locale/LC_MESSAGES
+for f in ADDRESS COLLATE CTYPE IDENTIFICATION MEASUREMENT MONETARY NAME NUMERIC PAPER TELEPHONE TIME; do
+  cp -f ${common_objpfx}localedata/de_DE.UTF-8/LC_$f \
+        ${objpfx}localedir/existing-locale
+done
+cp -f ${common_objpfx}localedata/de_DE.UTF-8/LC_MESSAGES/SYS_LC_MESSAGES \
+      ${objpfx}localedir/existing-locale/LC_MESSAGES
+
+# Create the domain directories.
+mkdir -p ${objpfx}domaindir/existing-locale/LC_MESSAGES
+mkdir -p ${objpfx}domaindir/existing-locale/LC_TIME
+# Populate them.
+msgfmt -o ${objpfx}domaindir/existing-locale/LC_MESSAGES/existing-domain.mo \
+       -f ../po/de.po
+msgfmt -o ${objpfx}domaindir/existing-locale/LC_TIME/existing-time-domain.mo \
+       -f ../po/de.po
+
+GCONV_PATH=${common_objpfx}iconvdata
+export GCONV_PATH
+LOCPATH=${common_objpfx}localedata
+export LOCPATH
+
+# Now run the test.
+MALLOC_TRACE=$malloc_trace LOCPATH=${objpfx}localedir:$LOCPATH \
+${common_objpfx}elf/ld.so --library-path $common_objpfx \
+${objpfx}tst-gettext > ${objpfx}tst-gettext.out ${objpfx}domaindir
+
+exit $?
Index: trunk/src/libctests/glibc/intl/tst-gettext2.c
===================================================================
--- trunk/src/libctests/glibc/intl/tst-gettext2.c	(revision 2036)
+++ trunk/src/libctests/glibc/intl/tst-gettext2.c	(revision 2036)
@@ -0,0 +1,73 @@
+/* Test of the gettext functions.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Thorsten Kukuk <kukuk@suse.de> and
+   Andreas Jaeger <aj@suse.de>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+
+#include <locale.h>
+#include <libintl.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+struct data_t
+{
+  const char *selection;
+  const char *description;
+};
+
+int data_cnt = 2;
+struct data_t strings[] =
+{
+  { "String1", N_("First string for testing.") },
+  { "String2", N_("Another string for testing.") }
+};
+
+const int lang_cnt = 3;
+const char *lang[] = {"lang1", "lang2", "lang3"};
+
+int
+main (void)
+{
+  int i;
+
+  /* Clean up environment.  */
+  unsetenv ("LANGUAGE");
+  unsetenv ("LC_ALL");
+  unsetenv ("LC_MESSAGES");
+  unsetenv ("LC_CTYPE");
+  unsetenv ("LANG");
+  unsetenv ("OUTPUT_CHARSET");
+
+  textdomain ("tstlang");
+
+  for (i = 0; i < lang_cnt; ++i)
+    {
+      int j;
+
+      if (setlocale (LC_ALL, lang[i]) == NULL)
+	setlocale (LC_ALL, "C");
+      bindtextdomain ("tstlang", OBJPFX "domaindir");
+
+      for (j = 0; j < data_cnt; ++j)
+	printf ("%s - %s\n", strings[j].selection,
+		gettext (strings[j].description));
+    }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/intl/tst-gettext2.sh
===================================================================
--- trunk/src/libctests/glibc/intl/tst-gettext2.sh	(revision 2036)
+++ trunk/src/libctests/glibc/intl/tst-gettext2.sh	(revision 2036)
@@ -0,0 +1,80 @@
+#! /bin/sh
+# Test of gettext functions.
+# Copyright (C) 2000, 2003, 2005 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+common_objpfx=$1
+objpfx=$2
+
+LC_ALL=C
+export LC_ALL
+
+# Generate the test data.
+mkdir -p ${objpfx}domaindir
+# Create the locale directories.
+test -d ${objpfx}domaindir/lang1 || {
+  mkdir ${objpfx}domaindir/lang1
+  for f in ADDRESS COLLATE CTYPE IDENTIFICATION MEASUREMENT MONETARY NAME NUMERIC PAPER TELEPHONE TIME; do
+    cp ${common_objpfx}localedata/de_DE.ISO-8859-1/LC_$f \
+       ${objpfx}domaindir/lang1
+  done
+}
+test -d ${objpfx}domaindir/lang2 || {
+  mkdir ${objpfx}domaindir/lang2
+  for f in ADDRESS COLLATE CTYPE IDENTIFICATION MEASUREMENT MONETARY NAME NUMERIC PAPER TELEPHONE TIME; do
+    cp ${common_objpfx}localedata/de_DE.ISO-8859-1/LC_$f \
+       ${objpfx}domaindir/lang2
+  done
+}
+test -d ${objpfx}domaindir/lang1/LC_MESSAGES || {
+  mkdir ${objpfx}domaindir/lang1/LC_MESSAGES
+  cp ${common_objpfx}localedata/de_DE.ISO-8859-1/LC_MESSAGES/SYS_LC_MESSAGES \
+     ${objpfx}domaindir/lang1/LC_MESSAGES
+}
+test -d ${objpfx}domaindir/lang2/LC_MESSAGES || {
+  mkdir ${objpfx}domaindir/lang2/LC_MESSAGES
+  cp ${common_objpfx}localedata/de_DE.ISO-8859-1/LC_MESSAGES/SYS_LC_MESSAGES \
+     ${objpfx}domaindir/lang2/LC_MESSAGES
+}
+
+# Populate them.
+msgfmt -o ${objpfx}domaindir/lang1/LC_MESSAGES/tstlang.mo \
+       tstlang1.po
+
+msgfmt -o ${objpfx}domaindir/lang2/LC_MESSAGES/tstlang.mo \
+       tstlang2.po
+
+GCONV_PATH=${common_objpfx}iconvdata
+export GCONV_PATH
+LOCPATH=${objpfx}domaindir
+export LOCPATH
+
+# Now run the test.
+${common_objpfx}elf/ld.so --library-path $common_objpfx \
+${objpfx}tst-gettext2 > ${objpfx}tst-gettext2.out ${objpfx}domaindir &&
+cmp ${objpfx}tst-gettext2.out - <<EOF
+String1 - Lang1: 1st string
+String2 - Lang1: 2nd string
+String1 - Lang2: 1st string
+String2 - Lang2: 2nd string
+String1 - First string for testing.
+String2 - Another string for testing.
+EOF
+
+exit $?
Index: trunk/src/libctests/glibc/intl/tst-gettext3.c
===================================================================
--- trunk/src/libctests/glibc/intl/tst-gettext3.c	(revision 2036)
+++ trunk/src/libctests/glibc/intl/tst-gettext3.c	(revision 2036)
@@ -0,0 +1,60 @@
+/* Test that the gettext() results come out in the correct encoding for
+   locales that differ only in their encoding.
+   Copyright (C) 2001, 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Bruno Haible <bruno@clisp.org>, 2001, 2005.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <libintl.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main (void)
+{
+  char *s;
+  int result = 0;
+
+  unsetenv ("LANGUAGE");
+  unsetenv ("OUTPUT_CHARSET");
+  textdomain ("codeset");
+  bindtextdomain ("codeset", OBJPFX "domaindir");
+
+  setlocale (LC_ALL, "de_DE.ISO-8859-1");
+
+  /* Here we expect output in ISO-8859-1.  */
+  s = gettext ("cheese");
+  if (strcmp (s, "K\344se"))
+    {
+      printf ("call 1 returned: %s\n", s);
+      result = 1;
+    }
+
+  setlocale (LC_ALL, "de_DE.UTF-8");
+
+  /* Here we expect output in UTF-8.  */
+  s = gettext ("cheese");
+  if (strcmp (s, "K\303\244se"))
+    {
+      printf ("call 2 returned: %s\n", s);
+      result = 1;
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/intl/tst-gettext3.sh
===================================================================
--- trunk/src/libctests/glibc/intl/tst-gettext3.sh	(revision 2036)
+++ trunk/src/libctests/glibc/intl/tst-gettext3.sh	(revision 2036)
@@ -0,0 +1,44 @@
+#! /bin/sh
+# Test that the gettext() results come out in the correct encoding for
+# locales that differ only in their encoding.
+# Copyright (C) 2001, 2002, 2005 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+common_objpfx=$1
+objpfx=$2
+
+LC_ALL=C
+export LC_ALL
+
+# Generate the test data.
+msgfmt -o ${objpfx}codeset.mo.$$ tstcodeset.po || exit
+# Create the domain directories.
+mkdir -p ${objpfx}domaindir/de_DE/LC_MESSAGES
+# Populate them.
+mv -f ${objpfx}codeset.mo.$$ ${objpfx}domaindir/de_DE/LC_MESSAGES/codeset.mo
+
+GCONV_PATH=${common_objpfx}iconvdata
+export GCONV_PATH
+LOCPATH=${common_objpfx}localedata
+export LOCPATH
+
+${common_objpfx}elf/ld.so --library-path $common_objpfx \
+${objpfx}tst-gettext3 > ${objpfx}tst-gettext3.out
+
+exit $?
Index: trunk/src/libctests/glibc/intl/tst-gettext4-de.po
===================================================================
--- trunk/src/libctests/glibc/intl/tst-gettext4-de.po	(revision 2036)
+++ trunk/src/libctests/glibc/intl/tst-gettext4-de.po	(revision 2036)
@@ -0,0 +1,8 @@
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Content-Transfer-Encoding: 8-bit\n"
+
+msgid "beauty"
+msgstr "Schönheit"
Index: trunk/src/libctests/glibc/intl/tst-gettext4-fr.po
===================================================================
--- trunk/src/libctests/glibc/intl/tst-gettext4-fr.po	(revision 2036)
+++ trunk/src/libctests/glibc/intl/tst-gettext4-fr.po	(revision 2036)
@@ -0,0 +1,8 @@
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Content-Transfer-Encoding: 8-bit\n"
+
+msgid "beauty"
+msgstr "beauté"
Index: trunk/src/libctests/glibc/intl/tst-gettext4.c
===================================================================
--- trunk/src/libctests/glibc/intl/tst-gettext4.c	(revision 2036)
+++ trunk/src/libctests/glibc/intl/tst-gettext4.c	(revision 2036)
@@ -0,0 +1,151 @@
+/* Test that gettext() in multithreaded applications works correctly if
+   different threads operate in different locales with the same encoding.
+   Copyright (C) 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Bruno Haible <bruno@clisp.org>, 2005.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <libintl.h>
+#include <locale.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* Set to 1 if the program is not behaving correctly.  */
+int result;
+
+/* Denotes which thread should run next.  */
+int flipflop;
+/* Lock and wait queue used to switch between the threads.  */
+pthread_mutex_t lock;
+pthread_cond_t waitqueue;
+
+/* Waits until the flipflop has a given value.
+   Before the call, the lock is unlocked.  After the call, it is locked.  */
+static void
+waitfor (int value)
+{
+  if (pthread_mutex_lock (&lock))
+    exit (10);
+  while (flipflop != value)
+    if (pthread_cond_wait (&waitqueue, &lock))
+      exit (11);
+}
+
+/* Sets the flipflop to a given value.
+   Before the call, the lock is locked.  After the call, it is unlocked.  */
+static void
+setto (int value)
+{
+  flipflop = value;
+  if (pthread_cond_signal (&waitqueue))
+    exit (20);
+  if (pthread_mutex_unlock (&lock))
+    exit (21);
+}
+
+void *
+thread1_execution (void *arg)
+{
+  char *s;
+
+  waitfor (1);
+  uselocale (newlocale (LC_ALL_MASK, "de_DE.ISO-8859-1", NULL));
+  setto (2);
+
+  waitfor (1);
+  s = gettext ("beauty");
+  puts (s);
+  if (strcmp (s, "Sch\366nheit"))
+    {
+      fprintf (stderr, "thread 1 call 1 returned: %s\n", s);
+      result = 1;
+    }
+  setto (2);
+
+  waitfor (1);
+  s = gettext ("beauty");
+  puts (s);
+  if (strcmp (s, "Sch\366nheit"))
+    {
+      fprintf (stderr, "thread 1 call 2 returned: %s\n", s);
+      result = 1;
+    }
+  setto (2);
+
+  return NULL;
+}
+
+void *
+thread2_execution (void *arg)
+{
+  char *s;
+
+  waitfor (2);
+  uselocale (newlocale (LC_ALL_MASK, "fr_FR.ISO-8859-1", NULL));
+  setto (1);
+
+  waitfor (2);
+  s = gettext ("beauty");
+  puts (s);
+  if (strcmp (s, "beaut\351"))
+    {
+      fprintf (stderr, "thread 2 call 1 returned: %s\n", s);
+      result = 1;
+    }
+  setto (1);
+
+  waitfor (2);
+  s = gettext ("beauty");
+  puts (s);
+  if (strcmp (s, "beaut\351"))
+    {
+      fprintf (stderr, "thread 2 call 2 returned: %s\n", s);
+      result = 1;
+    }
+  setto (1);
+
+  return NULL;
+}
+
+int
+main (void)
+{
+  pthread_t thread1;
+  pthread_t thread2;
+
+  unsetenv ("LANGUAGE");
+  unsetenv ("OUTPUT_CHARSET");
+  textdomain ("multithread");
+  bindtextdomain ("multithread", OBJPFX "domaindir");
+  result = 0;
+
+  flipflop = 1;
+  if (pthread_mutex_init (&lock, NULL))
+    exit (2);
+  if (pthread_cond_init (&waitqueue, NULL))
+    exit (2);
+  if (pthread_create (&thread1, NULL, &thread1_execution, NULL))
+    exit (2);
+  if (pthread_create (&thread2, NULL, &thread2_execution, NULL))
+    exit (2);
+  if (pthread_join (thread2, NULL))
+    exit (3);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/intl/tst-gettext4.sh
===================================================================
--- trunk/src/libctests/glibc/intl/tst-gettext4.sh	(revision 2036)
+++ trunk/src/libctests/glibc/intl/tst-gettext4.sh	(revision 2036)
@@ -0,0 +1,44 @@
+#! /bin/sh
+# Test that gettext() in multithreaded applications works correctly if
+# different threads operate in different locales with the same encoding.
+# Copyright (C) 2001, 2002, 2005 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+common_objpfx=$1
+run_program_prefix=$2
+objpfx=$3
+
+LC_ALL=C
+export LC_ALL
+
+# Create the domain directories.
+mkdir -p ${objpfx}domaindir/de_DE/LC_MESSAGES
+mkdir -p ${objpfx}domaindir/fr_FR/LC_MESSAGES
+# Populate them.
+msgfmt -o ${objpfx}domaindir/de_DE/LC_MESSAGES/multithread.mo tst-gettext4-de.po
+msgfmt -o ${objpfx}domaindir/fr_FR/LC_MESSAGES/multithread.mo tst-gettext4-fr.po
+
+GCONV_PATH=${common_objpfx}iconvdata
+export GCONV_PATH
+LOCPATH=${common_objpfx}localedata
+export LOCPATH
+
+${run_program_prefix} ${objpfx}tst-gettext4 > ${objpfx}tst-gettext4.out
+
+exit $?
Index: trunk/src/libctests/glibc/intl/tst-gettext5.c
===================================================================
--- trunk/src/libctests/glibc/intl/tst-gettext5.c	(revision 2036)
+++ trunk/src/libctests/glibc/intl/tst-gettext5.c	(revision 2036)
@@ -0,0 +1,156 @@
+/* Test that gettext() in multithreaded applications works correctly if
+   different threads operate in different locales referring to the same
+   catalog file but with different encodings.
+   Copyright (C) 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Bruno Haible <bruno@clisp.org>, 2005.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <libintl.h>
+#include <locale.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* Set to 1 if the program is not behaving correctly.  */
+int result;
+
+/* Denotes which thread should run next.  */
+int flipflop;
+/* Lock and wait queue used to switch between the threads.  */
+pthread_mutex_t lock;
+pthread_cond_t waitqueue;
+
+/* Waits until the flipflop has a given value.
+   Before the call, the lock is unlocked.  After the call, it is locked.  */
+static void
+waitfor (int value)
+{
+  if (pthread_mutex_lock (&lock))
+    exit (10);
+  while (flipflop != value)
+    if (pthread_cond_wait (&waitqueue, &lock))
+      exit (11);
+}
+
+/* Sets the flipflop to a given value.
+   Before the call, the lock is locked.  After the call, it is unlocked.  */
+static void
+setto (int value)
+{
+  flipflop = value;
+  if (pthread_cond_signal (&waitqueue))
+    exit (20);
+  if (pthread_mutex_unlock (&lock))
+    exit (21);
+}
+
+void *
+thread1_execution (void *arg)
+{
+  char *s;
+
+  waitfor (1);
+  uselocale (newlocale (LC_ALL_MASK, "de_DE.ISO-8859-1", NULL));
+  setto (2);
+
+  /* Here we expect output in ISO-8859-1.  */
+
+  waitfor (1);
+  s = gettext ("cheese");
+  puts (s);
+  if (strcmp (s, "K\344se"))
+    {
+      fprintf (stderr, "thread 1 call 1 returned: %s\n", s);
+      result = 1;
+    }
+  setto (2);
+
+  waitfor (1);
+  s = gettext ("cheese");
+  puts (s);
+  if (strcmp (s, "K\344se"))
+    {
+      fprintf (stderr, "thread 1 call 2 returned: %s\n", s);
+      result = 1;
+    }
+  setto (2);
+
+  return NULL;
+}
+
+void *
+thread2_execution (void *arg)
+{
+  char *s;
+
+  waitfor (2);
+  uselocale (newlocale (LC_ALL_MASK, "de_DE.UTF-8", NULL));
+  setto (1);
+
+  /* Here we expect output in UTF-8.  */
+
+  waitfor (2);
+  s = gettext ("cheese");
+  puts (s);
+  if (strcmp (s, "K\303\244se"))
+    {
+      fprintf (stderr, "thread 2 call 1 returned: %s\n", s);
+      result = 1;
+    }
+  setto (1);
+
+  waitfor (2);
+  s = gettext ("cheese");
+  puts (s);
+  if (strcmp (s, "K\303\244se"))
+    {
+      fprintf (stderr, "thread 2 call 2 returned: %s\n", s);
+      result = 1;
+    }
+  setto (1);
+
+  return NULL;
+}
+
+int
+main (void)
+{
+  pthread_t thread1;
+  pthread_t thread2;
+
+  unsetenv ("LANGUAGE");
+  unsetenv ("OUTPUT_CHARSET");
+  textdomain ("codeset");
+  bindtextdomain ("codeset", OBJPFX "domaindir");
+  result = 0;
+
+  flipflop = 1;
+  if (pthread_mutex_init (&lock, NULL))
+    exit (2);
+  if (pthread_cond_init (&waitqueue, NULL))
+    exit (2);
+  if (pthread_create (&thread1, NULL, &thread1_execution, NULL))
+    exit (2);
+  if (pthread_create (&thread2, NULL, &thread2_execution, NULL))
+    exit (2);
+  if (pthread_join (thread2, NULL))
+    exit (3);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/intl/tst-gettext5.sh
===================================================================
--- trunk/src/libctests/glibc/intl/tst-gettext5.sh	(revision 2036)
+++ trunk/src/libctests/glibc/intl/tst-gettext5.sh	(revision 2036)
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Test that gettext() in multithreaded applications works correctly if
+# different threads operate in different locales referring to the same
+# catalog file but with different encodings.
+# Copyright (C) 2001, 2002, 2005 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+common_objpfx=$1
+run_program_prefix=$2
+objpfx=$3
+
+LC_ALL=C
+export LC_ALL
+
+# Create the domain directories.
+mkdir -p ${objpfx}domaindir/de_DE/LC_MESSAGES
+# Populate them.
+msgfmt -o ${objpfx}domaindir/de_DE/LC_MESSAGES/codeset.mo tstcodeset.po
+
+GCONV_PATH=${common_objpfx}iconvdata
+export GCONV_PATH
+LOCPATH=${common_objpfx}localedata
+export LOCPATH
+
+${run_program_prefix} ${objpfx}tst-gettext5 > ${objpfx}tst-gettext5.out
+
+exit $?
Index: trunk/src/libctests/glibc/intl/tst-ngettext.c
===================================================================
--- trunk/src/libctests/glibc/intl/tst-ngettext.c	(revision 2036)
+++ trunk/src/libctests/glibc/intl/tst-ngettext.c	(revision 2036)
@@ -0,0 +1,66 @@
+/* Test of the ngettext functions.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <langinfo.h>
+#include <libintl.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+int
+main (void)
+{
+  const char *strs[2] = { "singular", "plural" };
+  unsigned long int i;
+  int res = 0;
+
+  /* We don't want any translation here.  */
+  setenv ("LANGUAGE", "C", 1);
+  unsetenv ("OUTPUT_CHARSET");
+
+  for (i = 0; i < 30; ++i)
+    {
+      char *tr;
+
+      tr = ngettext (strs[0], strs[1], i);
+#define TEST \
+      do								      \
+	if (tr != strs[i != 1])						      \
+	  {								      \
+	    if (strcmp (tr, strs[i != 1]) == 0)				      \
+	      printf ("%lu: correct string, wrong pointer (%s)\n", i, tr);    \
+	    else							      \
+	      printf ("%lu: wrong result (%s)\n", i, tr);		      \
+	    res = 1;							      \
+	  }								      \
+      while (0)
+      TEST;
+
+      tr = dngettext ("messages", strs[0], strs[1], i);
+      TEST;
+
+      tr = dcngettext ("messages", strs[0], strs[1], i, LC_MESSAGES);
+      TEST;
+    }
+
+  return res;
+}
Index: trunk/src/libctests/glibc/intl/tst-translit.c
===================================================================
--- trunk/src/libctests/glibc/intl/tst-translit.c	(revision 2036)
+++ trunk/src/libctests/glibc/intl/tst-translit.c	(revision 2036)
@@ -0,0 +1,52 @@
+/* Test of translitation in the gettext functions.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <libintl.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+int
+main (void)
+{
+  int result = 0;
+  const char *s;
+
+  setenv ("LANGUAGE", "existing-locale", 1);
+  unsetenv ("OUTPUT_CHARSET");
+  setlocale (LC_ALL, "en_US.ANSI_X3.4-1968");
+  textdomain ("translit");
+  bindtextdomain ("translit", OBJPFX "domaindir");
+
+#define TEST(in, exp) \
+  s = gettext (in);							      \
+  puts (s);								      \
+  result |= strcmp (s, exp) != 0;
+
+  TEST ("test", "<<(C) AEss>>");
+  TEST ("test", "<<(C) AEss>>");
+  TEST ("onemore", " 1/2 * 1/2 = 1/4 ");
+  TEST ("onemore", " 1/2 * 1/2 = 1/4 ");
+  TEST ("test", "<<(C) AEss>>");
+
+  return result;
+}
Index: trunk/src/libctests/glibc/intl/tst-translit.sh
===================================================================
--- trunk/src/libctests/glibc/intl/tst-translit.sh	(revision 2036)
+++ trunk/src/libctests/glibc/intl/tst-translit.sh	(revision 2036)
@@ -0,0 +1,42 @@
+#! /bin/sh
+# Test of transliteration in gettext functions.
+# Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+common_objpfx=$1
+objpfx=$2
+
+LC_ALL=C
+export LC_ALL
+
+# Create the locale directories.
+mkdir -p ${objpfx}localedir/existing-locale/LC_MESSAGES
+
+msgfmt -o ${objpfx}domaindir/existing-locale/LC_MESSAGES/translit.mo \
+       translit.po
+
+GCONV_PATH=${common_objpfx}iconvdata
+export GCONV_PATH
+LOCPATH=${common_objpfx}localedata
+export LOCPATH
+
+${common_objpfx}elf/ld.so --library-path $common_objpfx \
+${objpfx}tst-translit > ${objpfx}tst-translit.out ${objpfx}domaindir
+
+exit $?
Index: trunk/src/libctests/glibc/intl/tstcodeset.po
===================================================================
--- trunk/src/libctests/glibc/intl/tstcodeset.po	(revision 2036)
+++ trunk/src/libctests/glibc/intl/tstcodeset.po	(revision 2036)
@@ -0,0 +1,8 @@
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Content-Transfer-Encoding: 8-bit\n"
+
+msgid "cheese"
+msgstr "Käse"
Index: trunk/src/libctests/glibc/intl/tstlang1.po
===================================================================
--- trunk/src/libctests/glibc/intl/tstlang1.po	(revision 2036)
+++ trunk/src/libctests/glibc/intl/tstlang1.po	(revision 2036)
@@ -0,0 +1,13 @@
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=US-ASCII\n"
+"Content-Transfer-Encoding: 7-bit\n"
+
+#: tst-gettext2.c:33
+msgid "First string for testing."
+msgstr "Lang1: 1st string"
+
+#: tst-gettext2.c:34
+msgid "Another string for testing."
+msgstr "Lang1: 2nd string"
Index: trunk/src/libctests/glibc/intl/tstlang2.po
===================================================================
--- trunk/src/libctests/glibc/intl/tstlang2.po	(revision 2036)
+++ trunk/src/libctests/glibc/intl/tstlang2.po	(revision 2036)
@@ -0,0 +1,13 @@
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=US-ASCII\n"
+"Content-Transfer-Encoding: 7-bit\n"
+
+#: tst-gettext2.c:33
+msgid "First string for testing."
+msgstr "Lang2: 1st string"
+
+#: tst-gettext2.c:34
+msgid "Another string for testing."
+msgstr "Lang2: 2nd string"
Index: trunk/src/libctests/glibc/io/Makefile
===================================================================
--- trunk/src/libctests/glibc/io/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/io/Makefile	(revision 2036)
@@ -0,0 +1,103 @@
+# Copyright (C) 1992-2002, 2003 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Sub-makefile for I/O portion of the library.
+#
+subdir	:= io
+
+headers := sys/stat.h bits/stat.h sys/statfs.h bits/statfs.h sys/vfs.h \
+	   sys/statvfs.h bits/statvfs.h fcntl.h sys/fcntl.h bits/fcntl.h \
+	   poll.h sys/poll.h bits/poll.h \
+	   utime.h ftw.h fts.h sys/sendfile.h
+
+routines :=							      \
+	utime							      \
+	mkfifo							      \
+	stat fstat lstat mknod stat64 fstat64 lstat64		      \
+	xstat fxstat lxstat xmknod xstat64 fxstat64 lxstat64	      \
+	statfs fstatfs statfs64 fstatfs64			      \
+	statvfs fstatvfs statvfs64 fstatvfs64			      \
+	umask chmod fchmod lchmod mkdir				      \
+	open open64 close read write lseek lseek64 access euidaccess  \
+	fcntl flock lockf lockf64				      \
+	dup dup2 pipe						      \
+	creat creat64						      \
+	chdir fchdir						      \
+	getcwd getwd getdirname					      \
+	chown fchown lchown					      \
+	ttyname ttyname_r isatty				      \
+	link symlink readlink					      \
+	unlink rmdir						      \
+	ftw ftw64 fts poll					      \
+	posix_fadvise posix_fadvise64				      \
+	posix_fallocate posix_fallocate64			      \
+	sendfile sendfile64
+
+# These routines will be omitted from the libc shared object.
+# Instead the static object files will be included in a special archive
+# linked against when the shared library will be used.
+static-only-routines = stat fstat lstat mknod stat64 fstat64 lstat64
+
+others		:= pwd
+test-srcs	:= ftwtest
+tests		:= test-utime test-stat test-stat2 test-lfs tst-getcwd \
+		   tst-fcntl bug-ftw1 bug-ftw2 bug-ftw3 bug-ftw4 tst-statvfs
+
+distribute	:= ftwtest-sh
+
+include ../Rules
+
+CFLAGS-fcntl.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-poll.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-lockf.c = -fexceptions
+CFLAGS-statfs.c = -fexceptions
+CFLAGS-fstatfs.c = -fexceptions
+CFLAGS-statvfs.c = -fexceptions
+CFLAGS-fstatvfs.c = -fexceptions
+CFLAGS-fts.c = -Wno-uninitialized $(uses-callbacks) -fexceptions
+CFLAGS-ftw.c = $(uses-callbacks) -fexceptions
+CFLAGS-ftw64.c = $(uses-callbacks) -fexceptions
+CFLAGS-lockf.c = -fexceptions
+CFLAGS-posix_fallocate.c = -fexceptions
+CFLAGS-posix_fallocate64.c = -fexceptions
+
+CFLAGS-test-stat.c = -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
+CFLAGS-test-lfs.c = -D_LARGEFILE64_SOURCE
+
+ifeq (yes,$(have-protected))
+CFLAGS-stat.c = -DHAVE_DOT_HIDDEN
+CFLAGS-fstat.c = -DHAVE_DOT_HIDDEN
+CFLAGS-lstat.c = -DHAVE_DOT_HIDDEN
+CFLAGS-mknod.c = -DHAVE_DOT_HIDDEN
+CFLAGS-stat64.c = -DHAVE_DOT_HIDDEN
+CFLAGS-fstat64.c = -DHAVE_DOT_HIDDEN
+CFLAGS-lstat64.c = -DHAVE_DOT_HIDDEN
+endif
+
+test-stat2-ARGS = Makefile . $(objpfx)test-stat2
+
+tst-statvfs-ARGS = $(objpfx)tst-statvfs tst-statvfs.c /tmp
+
+ifeq ($(cross-compiling),no)
+tests: $(objpfx)ftwtest.out
+
+$(objpfx)ftwtest.out: $(objpfx)ftwtest
+	$(SHELL) -e ftwtest-sh $(shell cd $(common-objpfx). && pwd)/ \
+		 $(shell cd $(<D) && pwd)/$(<F) > $@
+endif
Index: trunk/src/libctests/glibc/io/bug-ftw1.c
===================================================================
--- trunk/src/libctests/glibc/io/bug-ftw1.c	(revision 2036)
+++ trunk/src/libctests/glibc/io/bug-ftw1.c	(revision 2036)
@@ -0,0 +1,78 @@
+/* Test for ftw function searching in root directory.
+   Copyright (C) 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 2001.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <ftw.h>
+#include <mcheck.h>
+#include <stdio.h>
+#include <string.h>
+
+
+int result;
+int cnt;
+int sawroot;
+
+
+static int
+callback (const char *fname, const struct stat *st, int flag)
+{
+  if (++cnt >= 10)
+    return 1;
+
+  printf ("%d: \"%s\" -> ", cnt, fname);
+  if (strcmp (fname, "/") == 0 && sawroot)
+    {
+      puts ("root directory reported twice");
+      result = 1;
+    }
+  else if (fname[0] != '/')
+    {
+      puts ("missing '/' as first character");
+      result = 1;
+    }
+  else if (fname[1] == '/')
+    {
+      puts ("double '/' at beginning");
+      result = 1;
+    }
+  else
+    {
+      puts ("OK");
+      sawroot |= strcmp (fname, "/") == 0;
+    }
+
+  return 0;
+}
+
+
+int
+main (void)
+{
+  mtrace ();
+
+  ftw ("/", callback, 10);
+
+  if (! sawroot)
+    {
+      puts ("root directory wasn't reported");
+      result = 1;
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/io/bug-ftw2.c
===================================================================
--- trunk/src/libctests/glibc/io/bug-ftw2.c	(revision 2036)
+++ trunk/src/libctests/glibc/io/bug-ftw2.c	(revision 2036)
@@ -0,0 +1,88 @@
+/* Test for ftw function searching in current directory.
+   Copyright (C) 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 2001.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <ftw.h>
+#include <mcheck.h>
+#include <stdio.h>
+#include <string.h>
+
+
+int cnt;
+int result;
+int sawown;
+int sawcur;
+
+
+static int
+callback (const char *fname, const struct stat *st, int flag)
+{
+  printf ("%d: \"%s\" -> ", ++cnt, fname);
+  if (strcmp (fname, ".") == 0 && sawcur)
+    {
+      puts ("current directory reported twice");
+      result = 1;
+    }
+  else if (strcmp (fname, "./bug-ftw2.c") == 0 && sawown)
+    {
+      puts ("source file reported twice");
+      result = 1;
+    }
+  else if (fname[0] != '.')
+    {
+      puts ("missing '.' as first character");
+      result = 1;
+    }
+  else if (fname[1] != '\0' && fname[1] != '/')
+    {
+      puts ("no '/' in second position");
+      result = 1;
+    }
+  else
+    {
+      puts ("OK");
+      sawcur |= strcmp (fname, ".") == 0;
+      sawown |= strcmp (fname, "./bug-ftw2.c") == 0;
+    }
+
+  return 0;
+}
+
+
+int
+main (void)
+{
+  mtrace ();
+
+  ftw (".", callback, 10);
+
+  if (! sawcur)
+    {
+      puts ("current directory wasn't reported");
+      result = 1;
+    }
+
+  if (! sawown)
+    {
+      puts ("source file wasn't reported");
+      result = 1;
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/io/bug-ftw3.c
===================================================================
--- trunk/src/libctests/glibc/io/bug-ftw3.c	(revision 2036)
+++ trunk/src/libctests/glibc/io/bug-ftw3.c	(revision 2036)
@@ -0,0 +1,69 @@
+#include <errno.h>
+#include <ftw.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+static int cb_called;
+
+static int
+cb (const char *fname, const struct stat *st, int flag)
+{
+  printf ("%s %d\n", fname, flag);
+  cb_called = 1;
+  return 0;
+}
+
+int
+main (void)
+{
+  char tmp[] = "/tmp/ftwXXXXXX";
+  char tmp2[] = "/tmp/ftwXXXXXX/ftwXXXXXX";
+  char *dname;
+  char *dname2;
+  int r;
+  int e;
+
+  if (getuid () == 0)
+    {
+      puts ("this test needs to be run by ordinary user");
+      exit (0);
+    }
+
+  dname = mkdtemp (tmp);
+  if (dname == NULL)
+    {
+      printf ("mkdtemp: %m\n");
+      exit (1);
+    }
+
+  memcpy (tmp2, tmp, strlen (tmp));
+  dname2 = mkdtemp (tmp2);
+  if (dname2 == NULL)
+    {
+      printf ("mkdtemp: %m\n");
+      rmdir (dname);
+      exit (1);
+    }
+
+  if (chmod (dname, S_IWUSR|S_IWGRP|S_IWOTH) != 0)
+    {
+      printf ("chmod: %m\n");
+      rmdir (dname);
+      exit (1);
+    }
+
+  r = ftw (dname2, cb, 10);
+  e = errno;
+  printf ("r = %d", r);
+  if (r != 0)
+    printf (", errno = %d", errno);
+  puts ("");
+
+  chmod (dname, S_IRWXU|S_IRWXG|S_IRWXO);
+  rmdir (dname2);
+  rmdir (dname);
+
+  return (r != -1 && e == EACCES) || cb_called;
+}
Index: trunk/src/libctests/glibc/io/bug-ftw4.c
===================================================================
--- trunk/src/libctests/glibc/io/bug-ftw4.c	(revision 2036)
+++ trunk/src/libctests/glibc/io/bug-ftw4.c	(revision 2036)
@@ -0,0 +1,125 @@
+/* Test if ftw function doesn't leak fds.
+   Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <fcntl.h>
+#include <ftw.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+static int cb_called;
+
+static int
+cb (const char *name, const struct stat64 *st, int type)
+{
+  return cb_called++ & 1;
+}
+
+int
+main (void)
+{
+  char name[32] = "/tmp/ftwXXXXXX", *p;
+  int ret, i, result = 0, fd, fd1, fd2;
+
+  if (mkdtemp (name) == NULL)
+    {
+      printf ("Couldn't make temporary directory: %m\n");
+      exit (EXIT_FAILURE);
+    }
+  p = strchr (name, '\0');
+  strcpy (p, "/1");
+  if (mkdir (name, 0755) < 0)
+    {
+      printf ("Couldn't make temporary subdirectory: %m\n");
+      exit (EXIT_FAILURE);
+    }
+  *p = '\0';
+
+  ret = ftw64 (name, cb, 20);
+  if (ret != 1)
+    {
+      printf ("ftw64 returned %d instead of 1", ret);
+      result = 1;
+    }
+
+  fd = open (name, O_RDONLY);
+  if (fd < 0)
+    {
+      printf ("open failed: %m\n");
+      result = 1;
+    }
+  fd1 = open (name, O_RDONLY);
+  if (fd1 < 0)
+    {
+      printf ("open failed: %m\n");
+      result = 1;
+    }
+  else
+    close (fd1);
+  if (fd >= 0)
+    close (fd);
+
+  for (i = 0; i < 128; ++i)
+    {
+      ret = ftw64 (name, cb, 20);
+      if (ret != 1)
+	{
+	  printf ("ftw64 returned %d instead of 1", ret);
+	  result = 1;
+	}
+    }
+
+  fd = open (name, O_RDONLY);
+  if (fd < 0)
+    {
+      printf ("open failed: %m\n");
+      result = 1;
+    }
+  fd2 = open (name, O_RDONLY);
+  if (fd2 < 0)
+    {
+      printf ("open failed: %m\n");
+      result = 1;
+    }
+  else
+    close (fd2);
+  if (fd >= 0)
+    close (fd);
+
+  if (fd2 >= fd1 + 128)
+    {
+      printf ("ftw64 leaking fds: %d -> %d\n", fd1, fd2);
+      result = 1;
+    }
+
+  if (cb_called != 129 * 2)
+    {
+      printf ("callback called %d times\n", cb_called);
+      result = 1;
+    }
+
+  strcpy (p, "/1");
+  rmdir (name);
+  *p = '\0';
+  rmdir (name);
+  return result;
+}
Index: trunk/src/libctests/glibc/io/ftwtest-sh
===================================================================
--- trunk/src/libctests/glibc/io/ftwtest-sh	(revision 2036)
+++ trunk/src/libctests/glibc/io/ftwtest-sh	(revision 2036)
@@ -0,0 +1,284 @@
+#! /bin/sh
+
+# The common objpfx, used to find libraries and the dynamic loader.
+objpfx=$1
+
+# We expect one parameter which is the test program.  This must understand
+# a number options:
+#   --phys		use the FTW_PHYS flag
+#   --chdir		use the FTW_CHDIR and print the current directory
+#			in the callback
+#   --depth		use the FTW_DEPTH flag
+#   --early-exit 	print file@2 item only and return non-zero from the
+#			callback when it is seen
+testprogram=$2
+
+# We cannot test this as root.
+if test `id | sed "s/uid=\([0-9]*\).*/\1/"` = 0; then
+  exit 0
+fi
+
+# Since we use `sort' we must make sure to use the same locale everywhere.
+LC_ALL=C
+export LC_ALL
+LANG=C
+export LANG
+
+# First create our scenario:
+tmp=`echo ${TMPDIR:-/tmp} | sed 's|\(.\)/*$|\1|'`
+tmpdir=$tmp/ftwtest.d
+
+[ -f ${objpfx}elf/ld.so ] && ldso=${objpfx}elf/ld.so
+
+trap 'chmod -fR a+x $tmpdir; rm -fr $tmpdir $testout' 1 2 3 15
+
+if test -d $tmpdir; then
+  chmod -fR a+x $tmpdir
+  rm -fr $tmpdir
+fi
+mkdir $tmpdir
+mkdir $tmpdir/foo
+mkdir $tmpdir/bar
+echo > $tmpdir/baz
+mkdir $tmpdir/foo/lvl1
+echo > $tmpdir/foo/lvl1/file@1
+mkdir $tmpdir/foo/lvl1/lvl2
+echo > $tmpdir/foo/lvl1/lvl2/file@2
+mkdir $tmpdir/foo/lvl1/lvl2/lvl3
+echo > $tmpdir/foo/lvl1/lvl2/lvl3/file@3
+ln -s $tmpdir $tmpdir/foo/lvl1/lvl2/lvl3/link@3
+ln -s $tmpdir/foo/lvl1/lvl2 $tmpdir/foo/lvl1/lvl2/link@2
+ln -s $tmpdir/foo/lvl1/lvl2/lvl3/lvl4 $tmpdir/foo/lvl1/link@1
+echo > $tmpdir/bar/xo
+chmod a-x,a+r $tmpdir/bar
+
+testout=${TMPDIR:-/tmp}/ftwtest.out
+
+LD_LIBRARY_PATH=$objpfx $ldso $testprogram $tmpdir |
+    sort > $testout
+
+cat <<EOF | cmp $testout - || exit 1
+base = "$tmp/", file = "ftwtest.d", flag = FTW_D, level = 0
+base = "$tmp/ftwtest.d/", file = "bar", flag = FTW_D, level = 1
+base = "$tmp/ftwtest.d/", file = "baz", flag = FTW_F, level = 1
+base = "$tmp/ftwtest.d/", file = "foo", flag = FTW_D, level = 1
+base = "$tmp/ftwtest.d/bar/", file = "xo", flag = FTW_NS, level = 2
+base = "$tmp/ftwtest.d/foo/", file = "lvl1", flag = FTW_D, level = 2
+base = "$tmp/ftwtest.d/foo/lvl1/", file = "file@1", flag = FTW_F, level = 3
+base = "$tmp/ftwtest.d/foo/lvl1/", file = "link@1", flag = FTW_SLN, level = 3
+base = "$tmp/ftwtest.d/foo/lvl1/", file = "lvl2", flag = FTW_D, level = 3
+base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "file@2", flag = FTW_F, level = 4
+base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "lvl3", flag = FTW_D, level = 4
+base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, level = 5
+EOF
+rm $testout
+
+LD_LIBRARY_PATH=$objpfx $ldso $testprogram --depth $tmpdir |
+    sort > $testout
+
+cat <<EOF | cmp $testout - || exit 1
+base = "$tmp/", file = "ftwtest.d", flag = FTW_DP, level = 0
+base = "$tmp/ftwtest.d/", file = "bar", flag = FTW_DP, level = 1
+base = "$tmp/ftwtest.d/", file = "baz", flag = FTW_F, level = 1
+base = "$tmp/ftwtest.d/", file = "foo", flag = FTW_DP, level = 1
+base = "$tmp/ftwtest.d/bar/", file = "xo", flag = FTW_NS, level = 2
+base = "$tmp/ftwtest.d/foo/", file = "lvl1", flag = FTW_DP, level = 2
+base = "$tmp/ftwtest.d/foo/lvl1/", file = "file@1", flag = FTW_F, level = 3
+base = "$tmp/ftwtest.d/foo/lvl1/", file = "link@1", flag = FTW_SLN, level = 3
+base = "$tmp/ftwtest.d/foo/lvl1/", file = "lvl2", flag = FTW_DP, level = 3
+base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "file@2", flag = FTW_F, level = 4
+base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "lvl3", flag = FTW_DP, level = 4
+base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, level = 5
+EOF
+rm $testout
+
+LD_LIBRARY_PATH=$objpfx $ldso $testprogram --phys $tmpdir |
+    sort > $testout
+
+cat <<EOF | cmp $testout - || exit 1
+base = "$tmp/", file = "ftwtest.d", flag = FTW_D, level = 0
+base = "$tmp/ftwtest.d/", file = "bar", flag = FTW_D, level = 1
+base = "$tmp/ftwtest.d/", file = "baz", flag = FTW_F, level = 1
+base = "$tmp/ftwtest.d/", file = "foo", flag = FTW_D, level = 1
+base = "$tmp/ftwtest.d/bar/", file = "xo", flag = FTW_NS, level = 2
+base = "$tmp/ftwtest.d/foo/", file = "lvl1", flag = FTW_D, level = 2
+base = "$tmp/ftwtest.d/foo/lvl1/", file = "file@1", flag = FTW_F, level = 3
+base = "$tmp/ftwtest.d/foo/lvl1/", file = "link@1", flag = FTW_SL, level = 3
+base = "$tmp/ftwtest.d/foo/lvl1/", file = "lvl2", flag = FTW_D, level = 3
+base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "file@2", flag = FTW_F, level = 4
+base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "link@2", flag = FTW_SL, level = 4
+base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "lvl3", flag = FTW_D, level = 4
+base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, level = 5
+base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "link@3", flag = FTW_SL, level = 5
+EOF
+rm $testout
+
+# For the next test everything must be readable.
+chmod -fR a+x $tmpdir
+
+LD_LIBRARY_PATH=$objpfx $ldso $testprogram --chdir $tmpdir |
+    sort > $testout
+
+# perhaps $tmp involves some symlinks...
+tmpreal=`cd $tmp; /bin/pwd 2>/dev/null || /usr/bin/pwd`
+
+cat <<EOF | cmp $testout - || exit 1
+base = "$tmp/", file = "ftwtest.d", flag = FTW_D, cwd = $tmpreal, level = 0
+base = "$tmp/ftwtest.d/", file = "bar", flag = FTW_D, cwd = $tmpreal/ftwtest.d, level = 1
+base = "$tmp/ftwtest.d/", file = "baz", flag = FTW_F, cwd = $tmpreal/ftwtest.d, level = 1
+base = "$tmp/ftwtest.d/", file = "foo", flag = FTW_D, cwd = $tmpreal/ftwtest.d, level = 1
+base = "$tmp/ftwtest.d/bar/", file = "xo", flag = FTW_F, cwd = $tmpreal/ftwtest.d/bar, level = 2
+base = "$tmp/ftwtest.d/foo/", file = "lvl1", flag = FTW_D, cwd = $tmpreal/ftwtest.d/foo, level = 2
+base = "$tmp/ftwtest.d/foo/lvl1/", file = "file@1", flag = FTW_F, cwd = $tmpreal/ftwtest.d/foo/lvl1, level = 3
+base = "$tmp/ftwtest.d/foo/lvl1/", file = "link@1", flag = FTW_SLN, cwd = $tmpreal/ftwtest.d/foo/lvl1, level = 3
+base = "$tmp/ftwtest.d/foo/lvl1/", file = "lvl2", flag = FTW_D, cwd = $tmpreal/ftwtest.d/foo/lvl1, level = 3
+base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "file@2", flag = FTW_F, cwd = $tmpreal/ftwtest.d/foo/lvl1/lvl2, level = 4
+base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "lvl3", flag = FTW_D, cwd = $tmpreal/ftwtest.d/foo/lvl1/lvl2, level = 4
+base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, cwd = $tmpreal/ftwtest.d/foo/lvl1/lvl2/lvl3, level = 5
+EOF
+rm $testout
+
+curwd=`/bin/pwd 2>/dev/null || /usr/bin/pwd`
+cd "$tmp"
+LD_LIBRARY_PATH=$objpfx $ldso $testprogram --chdir ftwtest.d |
+    sort > $testout
+cd "$curwd"
+
+cat <<EOF | diff -u $testout - || exit 1
+base = "", file = "ftwtest.d", flag = FTW_D, cwd = $tmpreal, level = 0
+base = "ftwtest.d/", file = "bar", flag = FTW_D, cwd = $tmpreal/ftwtest.d, level = 1
+base = "ftwtest.d/", file = "baz", flag = FTW_F, cwd = $tmpreal/ftwtest.d, level = 1
+base = "ftwtest.d/", file = "foo", flag = FTW_D, cwd = $tmpreal/ftwtest.d, level = 1
+base = "ftwtest.d/bar/", file = "xo", flag = FTW_F, cwd = $tmpreal/ftwtest.d/bar, level = 2
+base = "ftwtest.d/foo/", file = "lvl1", flag = FTW_D, cwd = $tmpreal/ftwtest.d/foo, level = 2
+base = "ftwtest.d/foo/lvl1/", file = "file@1", flag = FTW_F, cwd = $tmpreal/ftwtest.d/foo/lvl1, level = 3
+base = "ftwtest.d/foo/lvl1/", file = "link@1", flag = FTW_SLN, cwd = $tmpreal/ftwtest.d/foo/lvl1, level = 3
+base = "ftwtest.d/foo/lvl1/", file = "lvl2", flag = FTW_D, cwd = $tmpreal/ftwtest.d/foo/lvl1, level = 3
+base = "ftwtest.d/foo/lvl1/lvl2/", file = "file@2", flag = FTW_F, cwd = $tmpreal/ftwtest.d/foo/lvl1/lvl2, level = 4
+base = "ftwtest.d/foo/lvl1/lvl2/", file = "lvl3", flag = FTW_D, cwd = $tmpreal/ftwtest.d/foo/lvl1/lvl2, level = 4
+base = "ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, cwd = $tmpreal/ftwtest.d/foo/lvl1/lvl2/lvl3, level = 5
+EOF
+rm $testout
+
+curwd=`/bin/pwd 2>/dev/null || /usr/bin/pwd`
+cd "$tmp"
+LD_LIBRARY_PATH=$objpfx $ldso $testprogram --chdir ftwtest.d/. |
+    sort > $testout
+cd "$curwd"
+
+cat <<EOF | diff -u $testout - || exit 1
+base = "ftwtest.d/", file = ".", flag = FTW_D, cwd = $tmpreal/ftwtest.d, level = 0
+base = "ftwtest.d/./", file = "bar", flag = FTW_D, cwd = $tmpreal/ftwtest.d, level = 1
+base = "ftwtest.d/./", file = "baz", flag = FTW_F, cwd = $tmpreal/ftwtest.d, level = 1
+base = "ftwtest.d/./", file = "foo", flag = FTW_D, cwd = $tmpreal/ftwtest.d, level = 1
+base = "ftwtest.d/./bar/", file = "xo", flag = FTW_F, cwd = $tmpreal/ftwtest.d/bar, level = 2
+base = "ftwtest.d/./foo/", file = "lvl1", flag = FTW_D, cwd = $tmpreal/ftwtest.d/foo, level = 2
+base = "ftwtest.d/./foo/lvl1/", file = "file@1", flag = FTW_F, cwd = $tmpreal/ftwtest.d/foo/lvl1, level = 3
+base = "ftwtest.d/./foo/lvl1/", file = "link@1", flag = FTW_SLN, cwd = $tmpreal/ftwtest.d/foo/lvl1, level = 3
+base = "ftwtest.d/./foo/lvl1/", file = "lvl2", flag = FTW_D, cwd = $tmpreal/ftwtest.d/foo/lvl1, level = 3
+base = "ftwtest.d/./foo/lvl1/lvl2/", file = "file@2", flag = FTW_F, cwd = $tmpreal/ftwtest.d/foo/lvl1/lvl2, level = 4
+base = "ftwtest.d/./foo/lvl1/lvl2/", file = "lvl3", flag = FTW_D, cwd = $tmpreal/ftwtest.d/foo/lvl1/lvl2, level = 4
+base = "ftwtest.d/./foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, cwd = $tmpreal/ftwtest.d/foo/lvl1/lvl2/lvl3, level = 5
+EOF
+rm $testout
+
+curwd=`/bin/pwd 2>/dev/null || /usr/bin/pwd`
+cd "$tmp"
+LD_LIBRARY_PATH=$objpfx $ldso $testprogram --chdir ftwtest.d/foo/lvl1/link@1 |
+    sort > $testout
+cd "$curwd"
+
+cat <<EOF | diff -u $testout - || exit 1
+base = "ftwtest.d/foo/lvl1/", file = "link@1", flag = FTW_SLN, cwd = $tmpreal/ftwtest.d/foo/lvl1, level = 0
+EOF
+rm $testout
+
+LD_LIBRARY_PATH=$objpfx $ldso $testprogram --early-exit $tmpdir |
+    sort > $testout
+
+cat <<EOF | cmp $testout - || exit 1
+base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "file@2", flag = FTW_F, level = 4
+succeeded
+EOF
+rm $testout
+
+mkdir $tmpdir/foo/lvl1b
+echo > $tmpdir/foo/lvl1b/file@1b
+echo > $tmpdir/foo/lvl1b/file2@1b
+echo > $tmpdir/foo/lvl1b/file3@1b
+
+LD_LIBRARY_PATH=$objpfx $ldso $testprogram --skip-subtree=lvl1 $tmpdir |
+    sort > $testout
+
+cat <<EOF | diff -u $testout - || exit 1
+base = "$tmp/", file = "ftwtest.d", flag = FTW_D, level = 0
+base = "$tmp/ftwtest.d/", file = "bar", flag = FTW_D, level = 1
+base = "$tmp/ftwtest.d/", file = "baz", flag = FTW_F, level = 1
+base = "$tmp/ftwtest.d/", file = "foo", flag = FTW_D, level = 1
+base = "$tmp/ftwtest.d/bar/", file = "xo", flag = FTW_F, level = 2
+base = "$tmp/ftwtest.d/foo/", file = "lvl1", flag = FTW_D, level = 2
+base = "$tmp/ftwtest.d/foo/", file = "lvl1b", flag = FTW_D, level = 2
+base = "$tmp/ftwtest.d/foo/lvl1b/", file = "file2@1b", flag = FTW_F, level = 3
+base = "$tmp/ftwtest.d/foo/lvl1b/", file = "file3@1b", flag = FTW_F, level = 3
+base = "$tmp/ftwtest.d/foo/lvl1b/", file = "file@1b", flag = FTW_F, level = 3
+EOF
+rm $testout
+
+LD_LIBRARY_PATH=$objpfx $ldso $testprogram --skip-siblings=lvl1 $tmpdir |
+    sort > $testout
+
+# The filesystem is not required to put lvl1 before lvl1b.
+# If lvl1b comes after lvl1, it shouldn't be printed, while if it
+# comes before, it should.
+catcmd=cat
+[ -n "`ls -U $tmpdir/foo/ | sed -n '/lvl1$/,${/lvl1b$/p;}'`" ] \
+  && catcmd="grep -v lvl1b"
+
+$catcmd <<EOF | diff -u $testout - || exit 1
+base = "$tmp/", file = "ftwtest.d", flag = FTW_D, level = 0
+base = "$tmp/ftwtest.d/", file = "bar", flag = FTW_D, level = 1
+base = "$tmp/ftwtest.d/", file = "baz", flag = FTW_F, level = 1
+base = "$tmp/ftwtest.d/", file = "foo", flag = FTW_D, level = 1
+base = "$tmp/ftwtest.d/bar/", file = "xo", flag = FTW_F, level = 2
+base = "$tmp/ftwtest.d/foo/", file = "lvl1", flag = FTW_D, level = 2
+base = "$tmp/ftwtest.d/foo/", file = "lvl1b", flag = FTW_D, level = 2
+base = "$tmp/ftwtest.d/foo/lvl1b/", file = "file2@1b", flag = FTW_F, level = 3
+base = "$tmp/ftwtest.d/foo/lvl1b/", file = "file3@1b", flag = FTW_F, level = 3
+base = "$tmp/ftwtest.d/foo/lvl1b/", file = "file@1b", flag = FTW_F, level = 3
+EOF
+rm $testout
+
+LD_LIBRARY_PATH=$objpfx $ldso $testprogram --skip-siblings=file@1b $tmpdir |
+    sort > $testout
+
+# The filesystem is not required to put file2@1b and file3@1b after file@1b.
+# If file[23]@1b come after file@1b, it shouldn't be printed, while if they
+# come before, they should.
+regexp=`echo $(ls -U $tmp/ftwtest.d/foo/lvl1b \
+	       | sed -n '/file@1b$/,${/file[23]@1b$/p;}') | sed 's, ,|,'`
+catcmd=cat
+[ -n "$regexp" ] && catcmd="egrep -v $regexp"
+
+$catcmd <<EOF | diff -u $testout - || exit 1
+base = "$tmp/", file = "ftwtest.d", flag = FTW_D, level = 0
+base = "$tmp/ftwtest.d/", file = "bar", flag = FTW_D, level = 1
+base = "$tmp/ftwtest.d/", file = "baz", flag = FTW_F, level = 1
+base = "$tmp/ftwtest.d/", file = "foo", flag = FTW_D, level = 1
+base = "$tmp/ftwtest.d/bar/", file = "xo", flag = FTW_F, level = 2
+base = "$tmp/ftwtest.d/foo/", file = "lvl1", flag = FTW_D, level = 2
+base = "$tmp/ftwtest.d/foo/", file = "lvl1b", flag = FTW_D, level = 2
+base = "$tmp/ftwtest.d/foo/lvl1/", file = "file@1", flag = FTW_F, level = 3
+base = "$tmp/ftwtest.d/foo/lvl1/", file = "link@1", flag = FTW_SLN, level = 3
+base = "$tmp/ftwtest.d/foo/lvl1/", file = "lvl2", flag = FTW_D, level = 3
+base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "file@2", flag = FTW_F, level = 4
+base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "lvl3", flag = FTW_D, level = 4
+base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, level = 5
+base = "$tmp/ftwtest.d/foo/lvl1b/", file = "file2@1b", flag = FTW_F, level = 3
+base = "$tmp/ftwtest.d/foo/lvl1b/", file = "file3@1b", flag = FTW_F, level = 3
+base = "$tmp/ftwtest.d/foo/lvl1b/", file = "file@1b", flag = FTW_F, level = 3
+EOF
+rm $testout
+
+rm -fr $tmpdir
+
+exit 0
Index: trunk/src/libctests/glibc/io/ftwtest.c
===================================================================
--- trunk/src/libctests/glibc/io/ftwtest.c	(revision 2036)
+++ trunk/src/libctests/glibc/io/ftwtest.c	(revision 2036)
@@ -0,0 +1,120 @@
+#include <ftw.h>
+#include <getopt.h>
+#include <mcheck.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+
+int do_depth;
+int do_chdir;
+int do_phys;
+int do_exit;
+char *skip_subtree;
+char *skip_siblings;
+
+struct option options[] =
+{
+  { "depth", no_argument, &do_depth, 1 },
+  { "chdir", no_argument, &do_chdir, 1 },
+  { "phys", no_argument, &do_phys, 1 },
+  { "skip-subtree", required_argument, NULL, 't' },
+  { "skip-siblings", required_argument, NULL, 's' },
+  { "early-exit", no_argument, &do_exit, 1 },
+  { NULL, 0, NULL, 0 }
+};
+
+const char *flag2name[] =
+{
+  [FTW_F] = "FTW_F",
+  [FTW_D] = "FTW_D",
+  [FTW_DNR] = "FTW_DNR",
+  [FTW_NS] = "FTW_NS",
+  [FTW_SL] = "FTW_SL",
+  [FTW_DP] = "FTW_DP",
+  [FTW_SLN] = "FTW_SLN"
+};
+
+
+static int
+cb (const char *name, const struct stat *st, int flag, struct FTW *f)
+{
+  if (do_exit && strcmp (name + f->base, "file@2"))
+    return FTW_CONTINUE;
+
+  printf ("base = \"%.*s\", file = \"%s\", flag = %s",
+	  f->base, name, name + f->base, flag2name[flag]);
+  if (do_chdir)
+    {
+      char *cwd = getcwd (NULL, 0);
+      printf (", cwd = %s", cwd);
+      free (cwd);
+    }
+  printf (", level = %d\n", f->level);
+
+  if (skip_siblings && strcmp (name + f->base, skip_siblings) == 0)
+    return FTW_SKIP_SIBLINGS;
+
+  if (skip_subtree && strcmp (name + f->base, skip_subtree) == 0)
+    return FTW_SKIP_SUBTREE;
+
+  return do_exit ? 26 : FTW_CONTINUE;
+}
+
+int
+main (int argc, char *argv[])
+{
+  int opt;
+  int r;
+  int flag = 0;
+  mtrace ();
+
+  while ((opt = getopt_long_only (argc, argv, "", options, NULL)) != -1)
+    {
+      if (opt == 't')
+        skip_subtree = optarg;
+      else if (opt == 's')
+        skip_siblings = optarg;
+    }
+
+  if (do_chdir)
+    flag |= FTW_CHDIR;
+  if (do_depth)
+    flag |= FTW_DEPTH;
+  if (do_phys)
+    flag |= FTW_PHYS;
+  if (skip_subtree || skip_siblings)
+    {
+      flag |= FTW_ACTIONRETVAL;
+      if (do_exit)
+	{
+	  printf ("--early-exit cannot be used together with --skip-{siblings,subtree}");
+	  exit (1);
+	}
+    }
+
+  char *cw1 = getcwd (NULL, 0);
+
+  r = nftw (optind < argc ? argv[optind] : ".", cb, do_exit ? 1 : 3, flag);
+  if (r < 0)
+    perror ("nftw");
+
+  char *cw2 = getcwd (NULL, 0);
+
+  if (strcmp (cw1, cw2) != 0)
+    {
+      printf ("current working directory before and after nftw call differ:\n"
+	      "before: %s\n"
+	      "after:  %s\n", cw1, cw2);
+      exit (1);
+    }
+
+  if (do_exit)
+    {
+      puts (r == 26 ? "succeeded" : "failed");
+      return r == 26 ? 0 : 1;
+    }
+  return r;
+}
Index: trunk/src/libctests/glibc/io/test-lfs.c
===================================================================
--- trunk/src/libctests/glibc/io/test-lfs.c	(revision 2036)
+++ trunk/src/libctests/glibc/io/test-lfs.c	(revision 2036)
@@ -0,0 +1,202 @@
+/* Some basic tests for LFS.
+   Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@suse.de>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <error.h>
+#include <errno.h>
+#include <sys/resource.h>
+
+/* Prototype for our test function.  */
+extern void do_prepare (int argc, char *argv[]);
+extern int do_test (int argc, char *argv[]);
+
+/* We have a preparation function.  */
+#define PREPARE do_prepare
+
+/* We might need a bit longer timeout.  */
+#define TIMEOUT 20 /* sec */
+
+/* This defines the `main' function and some more.  */
+#include <test-skeleton.c>
+
+/* These are for the temporary file we generate.  */
+char *name;
+int fd;
+
+/* 2^31 = 2GB.  */
+#define TWO_GB 2147483648LL
+
+void
+do_prepare (int argc, char *argv[])
+{
+  char name_len;
+  struct rlimit64 rlim;
+
+  name_len = strlen (test_dir);
+  name = malloc (name_len + sizeof ("/lfsXXXXXX"));
+  mempcpy (mempcpy (name, test_dir, name_len),
+           "/lfsXXXXXX", sizeof ("/lfsXXXXXX"));
+  add_temp_file (name);
+
+  /* Open our test file.   */
+  fd = mkstemp64 (name);
+  if (fd == -1)
+    {
+      if (errno == ENOSYS)
+	{
+	  /* Fail silently.  */
+	  error (0, 0, "open64 is not supported");
+	  exit (EXIT_SUCCESS);
+	}
+      else
+	error (EXIT_FAILURE, errno, "cannot create temporary file");
+    }
+
+  if (getrlimit64 (RLIMIT_FSIZE, &rlim) != 0)
+    {
+      error (0, errno, "cannot get resource limit");
+      exit (0);
+    }
+  if (rlim.rlim_cur < TWO_GB + 200)
+    {
+      rlim.rlim_cur = TWO_GB + 200;
+      if (setrlimit64 (RLIMIT_FSIZE, &rlim) != 0)
+	{
+	  error (0, errno, "cannot reset file size limits");
+	  exit (0);
+	}
+    }
+}
+
+static void
+test_ftello (void)
+{
+  FILE *f;
+  int ret;
+  off64_t pos;
+
+  f = fopen64 (name, "w");
+
+  ret = fseeko64 (f, TWO_GB+100, SEEK_SET);
+  if (ret == -1 && errno == ENOSYS)
+    {
+      error (0, 0, "fseeko64 is not supported.");
+      exit (EXIT_SUCCESS);
+    }
+  if (ret == -1 && errno == EINVAL)
+    {
+      error (0, 0, "LFS seems not to be supported");
+      exit (EXIT_SUCCESS);
+    }
+  if (ret == -1)
+    {
+      error (0, errno, "fseeko64 failed with error");
+      exit (EXIT_FAILURE);
+    }
+
+  ret = fwrite ("Hello", 1, 5, f);
+  if (ret == -1 && errno == EFBIG)
+    {
+      error (0, errno, "LFS seems not to be supported");
+      exit (EXIT_SUCCESS);
+    }
+
+  if (ret == -1 && errno == ENOSPC)
+    {
+      error (0, 0, "Not enough space to write file.");
+      exit (EXIT_SUCCESS);
+    }
+
+  if (ret != 5)
+    error (EXIT_FAILURE, errno, "Cannot write test string to large file");
+
+  pos = ftello64 (f);
+
+  if (pos != TWO_GB+105)
+    {
+      error (0, 0, "ftello64 gives wrong result.");
+      exit (EXIT_FAILURE);
+    }
+
+  fclose (f);
+}
+
+int
+do_test (int argc, char *argv[])
+{
+  int ret;
+  struct stat64 statbuf;
+
+  ret = lseek64 (fd, TWO_GB+100, SEEK_SET);
+  if (ret == -1 && errno == ENOSYS)
+    {
+      error (0, 0, "lseek64 is not supported.");
+      exit (EXIT_SUCCESS);
+    }
+  if (ret == -1 && errno == EINVAL)
+    {
+      error (0, 0, "LFS seems not to be supported.");
+      exit (EXIT_SUCCESS);
+    }
+  if (ret == -1)
+    {
+      error (0, errno, "lseek64 failed with error");
+      exit (EXIT_FAILURE);
+    }
+
+  ret = write (fd, "Hello", 5);
+  if (ret == -1 && errno == EFBIG)
+    {
+      error (0, 0, "LFS seems not to be supported.");
+      exit (EXIT_SUCCESS);
+    }
+
+  if (ret == -1 && errno == ENOSPC)
+    {
+      error (0, 0, "Not enough space to write file.");
+      exit (EXIT_SUCCESS);
+    }
+
+  if (ret != 5)
+    error (EXIT_FAILURE, errno, "cannot write test string to large file");
+
+  ret = close (fd);
+
+  if (ret == -1)
+    error (EXIT_FAILURE, errno, "error closing file");
+
+  ret = stat64 (name, &statbuf);
+
+  if (ret == -1 && (errno == ENOSYS || errno == EOVERFLOW))
+    error (0, 0, "stat64 is not supported.");
+  else if (ret == -1)
+    error (EXIT_FAILURE, errno, "cannot stat file `%s'", name);
+  else if (statbuf.st_size != (TWO_GB + 100 + 5))
+    error (EXIT_FAILURE, 0, "stat reported size %lld instead of %lld.",
+	   (long long int) statbuf.st_size, (TWO_GB + 100 + 5));
+
+  test_ftello ();
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/io/test-stat.c
===================================================================
--- trunk/src/libctests/glibc/io/test-stat.c	(revision 2036)
+++ trunk/src/libctests/glibc/io/test-stat.c	(revision 2036)
@@ -0,0 +1,68 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+   Contributed by Maciej W. Rozycki <macro@ds2.pg.gda.pl>, 2000.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* We need to define:
+#define _FILE_OFFSET_BITS 64
+#define _LARGEFILE64_SOURCE 1
+*/
+
+#include <assert.h>
+#include <stddef.h>
+#include <sys/stat.h>
+
+int
+main (void)
+{
+  /* With _FILE_OFFSET_BITS=64 struct stat and struct stat64 should
+     be identical.  */
+  assert (sizeof (struct stat)
+	  == sizeof (struct stat64));
+  assert (offsetof (struct stat, st_dev)
+	  == offsetof (struct stat64, st_dev));
+  assert (offsetof (struct stat, st_ino)
+	  == offsetof (struct stat64, st_ino));
+  assert (offsetof (struct stat, st_mode)
+	  == offsetof (struct stat64, st_mode));
+  assert (offsetof (struct stat, st_nlink)
+	  == offsetof (struct stat64, st_nlink));
+  assert (offsetof (struct stat, st_uid)
+	  == offsetof (struct stat64, st_uid));
+  assert (offsetof (struct stat, st_gid)
+	  == offsetof (struct stat64, st_gid));
+  assert (offsetof (struct stat, st_rdev)
+	  == offsetof (struct stat64, st_rdev));
+  assert (offsetof (struct stat, st_size)
+	  == offsetof (struct stat64, st_size));
+  assert (offsetof (struct stat, st_atime)
+	  == offsetof (struct stat64, st_atime));
+  assert (offsetof (struct stat, st_mtime)
+	  == offsetof (struct stat64, st_mtime));
+  assert (offsetof (struct stat, st_ctime)
+	  == offsetof (struct stat64, st_ctime));
+  assert (offsetof (struct stat, st_blksize)
+	  == offsetof (struct stat64, st_blksize));
+  assert (offsetof (struct stat, st_blocks)
+	  == offsetof (struct stat64, st_blocks));
+#if 0
+  /* Some systems have st_fstype but not all.  Don't check it for now.  */
+  assert (offsetof (struct stat, st_fstype)
+	  == offsetof (struct stat64, st_fstype));
+#endif
+  return 0;
+}
Index: trunk/src/libctests/glibc/io/test-stat2.c
===================================================================
--- trunk/src/libctests/glibc/io/test-stat2.c	(revision 2036)
+++ trunk/src/libctests/glibc/io/test-stat2.c	(revision 2036)
@@ -0,0 +1,88 @@
+/* Test consistence of results of stat and stat64.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <sys/stat.h>
+
+int
+main (int argc, char *argv[])
+{
+  int i;
+  int result = 0;
+
+  for (i = 1; i < argc; ++i)
+    {
+      struct stat st;
+      struct stat64 st64;
+      int same;
+
+      if (stat (argv[i], &st) != 0)
+	{
+	  if (errno != EOVERFLOW)
+	    {
+	      /* Something is wrong.  */
+	      printf ("stat(\"%s\",....) failed: %m", argv[i]);
+	      result = 1;
+	    }
+	  continue;
+	}
+
+      if (stat64 (argv[i], &st64) != 0)
+	{
+	  if (errno != ENOSYS)
+	    {
+	      /* Something is wrong.  */
+	      printf ("stat64(\"%s\",....) failed: %m", argv[i]);
+	      result = 1;
+	    }
+	  continue;
+	}
+
+      printf ("\nName: %s\n", argv[i]);
+
+#define TEST(name) \
+      same = st.name == st64.name;					      \
+      printf (#name ": %jd vs %jd  %s\n",				      \
+	      (intmax_t) st.name, (intmax_t) st64.name,			      \
+	      same ? "OK" : "FAIL");					      \
+      result |= ! same
+
+      TEST (st_dev);
+      TEST (st_ino);
+      TEST (st_mode);
+      TEST (st_nlink);
+      TEST (st_uid);
+      TEST (st_gid);
+#ifdef _STATBUF_ST_RDEV
+      TEST (st_rdev);
+#endif
+#ifdef _STATBUF_ST_BLKSIZE
+      TEST (st_blksize);
+#endif
+      TEST (st_blocks);
+      TEST (st_atime);
+      TEST (st_mtime);
+      TEST (st_ctime);
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/io/test-utime.c
===================================================================
--- trunk/src/libctests/glibc/io/test-utime.c	(revision 2036)
+++ trunk/src/libctests/glibc/io/test-utime.c	(revision 2036)
@@ -0,0 +1,137 @@
+/* Copyright (C) 1994,1996,1997,2000,2002,2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <utime.h>
+#include <time.h>
+
+int
+main (int argc, char *argv[])
+{
+  char file[L_tmpnam];
+  struct utimbuf ut;
+  struct stat st;
+  struct stat stnow;
+  time_t now1, now2;
+  int fd;
+
+  if (tmpnam (file) == 0)
+    {
+      perror ("tmpnam");
+      return 1;
+    }
+
+  fd = creat (file, 0666);
+  if (fd < 0)
+    {
+      perror ("creat");
+      return 1;
+    }
+  close (fd);
+
+  /* Test utime with arg */
+  ut.actime = 500000000;
+  ut.modtime = 500000001;
+  if (utime (file, &ut))
+    {
+      perror ("utime");
+      remove (file);
+      return 1;
+    }
+
+  if (stat (file, &st))
+    {
+      perror ("stat");
+      remove (file);
+      return 1;
+    }
+
+  /* Test utime with NULL.
+     Since there's a race condition possible here, we check
+     the time before and after the call to utime.  */
+  now1 = time (NULL);
+  if (now1 == (time_t)-1)
+    {
+      perror ("time");
+      remove (file);
+      return 1;
+    }
+
+  /* The clocks used to set the modification time and that used in the
+     time() call need not be the same.  They need not have the same
+     precision.  Therefore we delay the following operation by one
+     second which makes sure we can compare with second precision.  */
+  sleep (1);
+
+  if (utime (file, NULL))
+    {
+      perror ("utime NULL");
+      remove (file);
+      return 1;
+    }
+
+  sleep (1);
+
+  now2 = time (NULL);
+  if (now2 == (time_t)-1)
+    {
+      perror ("time");
+      remove (file);
+      return 1;
+    }
+
+  if (stat (file, &stnow))
+    {
+      perror ("stat");
+      remove (file);
+      return 1;
+    }
+
+  remove (file);
+
+  if (st.st_mtime != ut.modtime)
+    {
+      printf ("modtime %ld != %ld\n", st.st_mtime, ut.modtime);
+      return 1;
+    }
+
+  if (st.st_atime != ut.actime)
+    {
+      printf ("actime %ld != %ld\n", st.st_atime, ut.actime);
+      return 1;
+    }
+
+  if (stnow.st_mtime < now1 || stnow.st_mtime > now2)
+    {
+      printf ("modtime %ld <%ld >%ld\n", stnow.st_mtime, now1, now2);
+      return 1;
+    }
+
+  if (stnow.st_atime < now1 || stnow.st_atime > now2)
+    {
+      printf ("actime %ld <%ld >%ld\n", stnow.st_atime, now1, now2);
+      return 1;
+    }
+
+  puts ("Test succeeded.");
+  return 0;
+}
Index: trunk/src/libctests/glibc/io/tst-fcntl.c
===================================================================
--- trunk/src/libctests/glibc/io/tst-fcntl.c	(revision 2036)
+++ trunk/src/libctests/glibc/io/tst-fcntl.c	(revision 2036)
@@ -0,0 +1,197 @@
+/* Tests for fcntl.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <paths.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+
+/* Prototype for our test function.  */
+extern void do_prepare (int argc, char *argv[]);
+extern int do_test (int argc, char *argv[]);
+
+/* We have a preparation function.  */
+#define PREPARE do_prepare
+
+#include "../test-skeleton.c"
+
+
+/* Name of the temporary files.  */
+static char *name;
+
+void
+do_prepare (int argc, char *argv[])
+{
+   char name_len;
+
+   name_len = strlen (test_dir);
+   name = malloc (name_len + sizeof ("/fcntlXXXXXX"));
+   mempcpy (mempcpy (name, test_dir, name_len),
+	    "/fcntlXXXXXX", sizeof ("/fcntlXXXXXX"));
+   add_temp_file (name);
+}
+
+
+int
+do_test (int argc, char *argv[])
+{
+  int fd;
+  int fd2;
+  int fd3;
+  struct stat64 st;
+  int val;
+  int result = 0;
+
+  /* Create the temporary file.  */
+  fd = mkstemp (name);
+  if (fd == -1)
+    {
+      printf ("cannot open temporary file: %m\n");
+      return 1;
+    }
+  if (fstat64 (fd, &st) != 0)
+    {
+      printf ("cannot stat test file: %m\n");
+      return 1;
+    }
+  if (! S_ISREG (st.st_mode) || st.st_size != 0)
+    {
+      puts ("file not created correctly");
+      return 1;
+    }
+
+  /* Get the flags with fcntl().  */
+  val = fcntl (fd, F_GETFL);
+  if (val == -1)
+    {
+      printf ("fcntl(fd, F_GETFL) failed: %m\n");
+      result = 1;
+    }
+  else if ((val & O_ACCMODE) != O_RDWR)
+    {
+      puts ("temporary file not opened for read and write");
+      result = 1;
+    }
+
+  /* Set the flags to something else.  */
+  if (fcntl (fd, F_SETFL, O_RDONLY) == -1)
+    {
+      printf ("fcntl(fd, F_SETFL, O_RDONLY) failed: %m\n");
+      result = 1;
+    }
+
+  val = fcntl (fd, F_GETFL);
+  if (val == -1)
+    {
+      printf ("fcntl(fd, F_GETFL) after F_SETFL failed: %m\n");
+      result = 1;
+    }
+  else if ((val & O_ACCMODE) != O_RDWR)
+    {
+      puts ("temporary file access mode changed");
+      result = 1;
+    }
+
+  /* Set the flags to something else.  */
+  if (fcntl (fd, F_SETFL, O_APPEND) == -1)
+    {
+      printf ("fcntl(fd, F_SETFL, O_APPEND) failed: %m\n");
+      result = 1;
+    }
+
+  val = fcntl (fd, F_GETFL);
+  if (val == -1)
+    {
+      printf ("fcntl(fd, F_GETFL) after second F_SETFL failed: %m\n");
+      result = 1;
+    }
+  else if ((val & O_APPEND) == 0)
+    {
+      puts ("O_APPEND not set");
+      result = 1;
+    }
+
+  val = fcntl (fd, F_GETFD);
+  if (val == -1)
+    {
+      printf ("fcntl(fd, F_GETFD) failed: %m\n");
+      result = 1;
+    }
+  else if (fcntl (fd, F_SETFD, val | FD_CLOEXEC) == -1)
+    {
+      printf ("fcntl(fd, F_SETFD, FD_CLOEXEC) failed: %m\n");
+      result = 1;
+    }
+  else
+    {
+      val = fcntl (fd, F_GETFD);
+      if (val == -1)
+	{
+	  printf ("fcntl(fd, F_GETFD) after F_SETFD failed: %m\n");
+	  result = 1;
+	}
+      else if ((val & FD_CLOEXEC) == 0)
+	{
+	  puts ("FD_CLOEXEC not set");
+	  result = 1;
+	}
+    }
+
+  /* Get a number of a free descriptor.  If /dev/null is not available
+     don't continue testing.  */
+  fd2 = open (_PATH_DEVNULL, O_RDWR);
+  if (fd2 == -1)
+    return result;
+  close (fd2);
+
+  fd3 = fcntl (fd, F_DUPFD, fd2 + 1);
+  if (fd3 == -1)
+    {
+      printf ("fcntl(fd, F_DUPFD, %d) failed: %m\n", fd2 + 1);
+      result = 1;
+    }
+  else if (fd3 <= fd2)
+    {
+      printf ("F_DUPFD returned %d which is not larger than %d\n", fd3, fd2);
+      result = 1;
+    }
+
+  if (fd3 != -1)
+    {
+      val = fcntl (fd3, F_GETFD);
+      if (val == -1)
+	{
+	  printf ("fcntl(fd3, F_GETFD) after F_DUPFD failed: %m\n");
+	  result = 1;
+	}
+      else if ((val & FD_CLOEXEC) != 0)
+	{
+	  puts ("FD_CLOEXEC still set");
+	  result = 1;
+	}
+
+      close (fd3);
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/io/tst-getcwd.c
===================================================================
--- trunk/src/libctests/glibc/io/tst-getcwd.c	(revision 2036)
+++ trunk/src/libctests/glibc/io/tst-getcwd.c	(revision 2036)
@@ -0,0 +1,164 @@
+/* Test of getcwd function.
+   Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/param.h>
+
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+  char thepath[4096];	/* Yes, this limits the environment this test
+			   can run it but I honestly don't care about
+			   people which have this problem.  */
+  char *bufs[10];
+  size_t lens[10];
+  size_t sbs;
+  size_t len, i;
+
+  if (getcwd (thepath, sizeof thepath) == NULL)
+    {
+      if (errno == ERANGE)
+	/* The path is too long, skip all tests.  */
+	return 0;
+
+      puts ("getcwd (thepath, sizeof thepath) failed");
+      return 1;
+    }
+  len = strlen (thepath);
+
+  sbs = 1;
+  while (sbs < len + 1)
+    sbs <<= 1;
+
+  for (i = 0; i < 4; ++i)
+    {
+      lens[i] = sbs;
+      bufs[i] = (char *) malloc (sbs);
+    }
+
+  bufs[i] = getcwd (NULL, sbs);
+  lens[i] = sbs;
+  if (bufs[i] == NULL)
+    {
+      puts ("getcwd (NULL, sbs) failed");
+      return 1;
+    }
+  ++i;
+
+  for (; i < 10; sbs >>= 1, ++i)
+    {
+      bufs[i] = (char *) malloc (MAX (1, sbs));
+      lens[i] = sbs;
+    }
+
+  /* Before we test the result write something in the memory to see
+     whether the allocation went right.  */
+  for (i = 0; i < 10; ++i)
+    if (i != 4 && bufs[i] != NULL)
+      memset (bufs[i], '\xff', lens[i]);
+
+  if (strcmp (thepath, bufs[4]) != 0)
+    {
+      printf ("\
+getcwd (NULL, sbs) = \"%s\", getcwd (thepath, sizeof thepath) = \"%s\"\n",
+	      bufs[4], thepath);
+      return 1;
+    }
+
+  /* Now overwrite all buffers to see that getcwd allocated the buffer
+     of right size.  */
+  for (i = 0; i < 10; ++i)
+    memset (bufs[i], i, lens[i]);
+
+  for (i = 0; i < 10; ++i)
+    free (bufs[i]);
+
+  /* Test whether the function signals success despite the buffer
+     being too small.  */
+  if (getcwd (NULL, len) != NULL)
+    {
+      puts ("getcwd (NULL, len) didn't failed");
+      return 1;
+    }
+
+  bufs[0] = malloc (len);
+  bufs[1] = malloc (len);
+  bufs[2] = malloc (len);
+  if (bufs[1] != NULL)
+    {
+      if (getcwd (bufs[1], len) != NULL)
+	{
+	  puts ("getcwd (bufs[1], len) didn't failed");
+	  return 1;
+	}
+      free (bufs[0]);
+      free (bufs[1]);
+      free (bufs[2]);
+    }
+
+  memset (thepath, '\xfe', sizeof (thepath));
+  if (getcwd (thepath, len) != NULL)
+    {
+      puts ("getcwd (thepath, len) didn't failed");
+      return 1;
+    }
+
+  for (i = len; i < sizeof thepath; ++i)
+    if (thepath[i] != '\xfe')
+      {
+	puts ("thepath[i] != '\xfe'");
+	return 1;
+      }
+
+  /* Now test handling of correctly sized buffers.  */
+  bufs[0] = getcwd (NULL, len + 1);
+  if (bufs[0] == NULL)
+    {
+      puts ("getcwd (NULL, len + 1) failed");
+      return 1;
+    }
+  free (bufs[0]);
+
+  memset (thepath, '\xff', sizeof thepath);
+  if (getcwd (thepath, len + 1) == NULL)
+    {
+      puts ("getcwd (thepath, len + 1) failed");
+      return 1;
+    }
+
+  for (i = len + 1; i < sizeof thepath; ++i)
+    if (thepath[i] != '\xff')
+      {
+	printf ("thepath[%zd] != '\xff'\n", i);
+	return 1;
+      }
+
+  puts ("everything OK");
+
+  return 0;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/io/tst-statvfs.c
===================================================================
--- trunk/src/libctests/glibc/io/tst-statvfs.c	(revision 2036)
+++ trunk/src/libctests/glibc/io/tst-statvfs.c	(revision 2036)
@@ -0,0 +1,30 @@
+#include <stdio.h>
+#include <sys/statvfs.h>
+
+
+/* This test cannot detect many errors.  But it will fail if the
+   statvfs is completely hosed and it'll detect a missing export.  So
+   it is better than nothing.  */
+static int
+do_test (int argc, char *argv[])
+{
+  for (int i = 1; i < argc; ++i)
+    {
+      struct statvfs st;
+      if (statvfs (argv[i], &st) != 0)
+        printf ("%s: failed (%m)\n", argv[i]);
+      else
+        printf ("%s: free: %llu, mandatory: %s\n", argv[i],
+                (unsigned long long int) st.f_bfree,
+#ifdef ST_MANDLOCK
+                (st.f_flag & ST_MANDLOCK) ? "yes" : "no"
+#else
+                "no"
+#endif
+                );
+    }
+  return 0;
+}
+
+#define TEST_FUNCTION do_test (argc, argv)
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/libio/Makefile
===================================================================
--- trunk/src/libctests/glibc/libio/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/libio/Makefile	(revision 2036)
@@ -0,0 +1,182 @@
+# Copyright (C) 1995-2002, 2003, 2004 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Specific makefile for libio.
+#
+subdir	:= libio
+
+headers	:= stdio.h libio.h _G_config.h bits/stdio.h bits/stdio-lock.h \
+	   bits/sys_errlist.h bits/stdio2.h
+
+routines	:=							      \
+	filedoalloc iofclose iofdopen iofflush iofgetpos iofgets iofopen      \
+	iofopncook iofputs iofread iofsetpos ioftell wfiledoalloc	      \
+	iofwrite iogetdelim iogetline iogets iopadn iopopen ioputs	      \
+	ioseekoff ioseekpos iosetbuffer iosetvbuf ioungetc		      \
+	iovsprintf iovsscanf						      \
+	iofgetpos64 iofopen64 iofsetpos64				      \
+	fputwc fputwc_u getwc getwc_u getwchar getwchar_u iofgetws iofgetws_u \
+	iofputws iofputws_u iogetwline iowpadn ioungetwc putwc putwc_u	      \
+	putwchar putwchar_u putchar putchar_u fwprintf swprintf vwprintf      \
+	wprintf wscanf fwscanf vwscanf vswprintf iovswscanf swscanf wgenops   \
+	wstrops wfileops iofwide fwide					      \
+									      \
+	clearerr feof ferror fileno fputc freopen fseek getc getchar	      \
+	memstream pclose putc putchar rewind setbuf setlinebuf vasprintf      \
+	iovdprintf vscanf vsnprintf obprintf fcloseall fseeko ftello	      \
+	freopen64 fseeko64 ftello64					      \
+									      \
+	__fbufsize __freading __fwriting __freadable __fwritable __flbf	      \
+	__fpurge __fpending __fsetlocking				      \
+									      \
+	libc_fatal fmemopen
+
+tests = tst_swprintf tst_wprintf tst_swscanf tst_wscanf tst_getwc tst_putwc   \
+	tst_wprintf2 tst-widetext test-fmemopen tst-ext tst-fopenloc	      \
+	tst-fgetws tst-ungetwc1 tst-ungetwc2 tst-swscanf tst-sscanf	      \
+	tst-mmap-setvbuf bug-ungetwc1 bug-ungetwc2 tst-atime tst-eof          \
+	tst-freopen bug-rewind bug-rewind2 bug-ungetc bug-fseek \
+	tst-mmap-eofsync tst-mmap-fflushsync bug-mmap-fflush \
+	tst-mmap2-eofsync tst-mmap-offend bug-fopena+ bug-wfflush \
+	bug-ungetc2 bug-ftell bug-ungetc3 bug-ungetc4
+test-srcs = test-freopen
+
+all: # Make this the default target; it will be defined in Rules.
+
+include ../Makeconfig
+
+ifeq ($(versioning),yes)
+routines += oldiofopen oldiofdopen oldiofclose oldiopopen oldpclose \
+	    oldtmpfile oldiofgetpos oldiofgetpos64 oldiofsetpos	    \
+	    oldiofsetpos64
+endif
+
+ifneq (,$(filter %REENTRANT, $(defines)))
+routines += clearerr_u feof_u ferror_u fputc_u getc_u getchar_u		      \
+	    iofflush_u putc_u putchar_u peekc iofread_u iofwrite_u iofgets_u  \
+	    iofputs_u
+
+CPPFLAGS += -D_IO_MTSAFE_IO
+endif
+
+# Support for exception handling.
+CFLAGS-fileops.c = $(exceptions)
+CFLAGS-fputc.c = $(exceptions)
+CFLAGS-fputwc.c = $(exceptions)
+CFLAGS-freopen64.c = $(exceptions)
+CFLAGS-freopen.c = $(exceptions)
+CFLAGS-fseek.c = $(exceptions)
+CFLAGS-fseeko64.c = $(exceptions)
+CFLAGS-fseeko.c = $(exceptions)
+CFLAGS-ftello64.c = $(exceptions)
+CFLAGS-ftello.c = $(exceptions)
+CFLAGS-fwide.c = $(exceptions)
+CFLAGS-genops.c = $(exceptions)
+CFLAGS-getc.c = $(exceptions)
+CFLAGS-getchar.c = $(exceptions)
+CFLAGS-getwc.c = $(exceptions)
+CFLAGS-getwchar.c = $(exceptions)
+CFLAGS-iofclose.c = $(exceptions)
+CFLAGS-iofflush.c = $(exceptions)
+CFLAGS-iofgetpos64.c = $(exceptions)
+CFLAGS-iofgetpos.c = $(exceptions)
+CFLAGS-iofgets.c = $(exceptions)
+CFLAGS-iofgetws.c = $(exceptions)
+CFLAGS-iofputs.c = $(exceptions)
+CFLAGS-iofputws.c = $(exceptions)
+CFLAGS-iofread.c = $(exceptions)
+CFLAGS-iofsetpos64.c = $(exceptions)
+CFLAGS-iofsetpos.c = $(exceptions)
+CFLAGS-ioftell.c = $(exceptions)
+CFLAGS-iofwrite.c = $(exceptions)
+CFLAGS-iogetdelim.c = $(exceptions)
+CFLAGS-iogetline.c = $(exceptions)
+CFLAGS-iogets.c = $(exceptions)
+CFLAGS-iogetwline.c = $(exceptions)
+CFLAGS-ioputs.c = $(exceptions)
+CFLAGS-ioseekoff.c = $(exceptions)
+CFLAGS-ioseekpos.c = $(exceptions)
+CFLAGS-iosetbuffer.c = $(exceptions)
+CFLAGS-iosetvbuf.c = $(exceptions)
+CFLAGS-ioungetc.c = $(exceptions)
+CFLAGS-ioungetwc.c = $(exceptions)
+CFLAGS-oldfileops.c = $(exceptions)
+CFLAGS-oldiofclose.c = $(exceptions)
+CFLAGS-oldiofgetpos64.c = $(exceptions)
+CFLAGS-oldiofgetpos.c = $(exceptions)
+CFLAGS-oldiofsetpos64.c = $(exceptions)
+CFLAGS-oldiofsetpos.c = $(exceptions)
+CFLAGS-peekc.c = $(exceptions)
+CFLAGS-putc.c = $(exceptions)
+CFLAGS-putchar.c = $(exceptions)
+CFLAGS-putwc.c = $(exceptions)
+CFLAGS-putwchar.c = $(exceptions)
+CFLAGS-rewind.c = $(exceptions)
+CFLAGS-wfileops.c = $(exceptions)
+CFLAGS-wgenops.c = $(exceptions)
+CFLAGS-oldiofopen.c = $(exceptions)
+CFLAGS-iofopen.c = $(exceptions)
+CFLAGS-iofopen64.c = $(exceptions)
+CFLAGS-oldtmpfile.c = $(exceptions)
+# XXX Do we need filedoalloc and wfiledoalloc?  Others?
+
+CFLAGS-tst_putwc.c = -DOBJPFX=\"$(objpfx)\"
+
+tst_wprintf2-ARGS = "Some Text"
+
+tst-widetext-ENV = LOCPATH=$(common-objpfx)localedata LANGUAGE=C
+tst-fopenloc-ENV = LOCPATH=$(common-objpfx)localedata \
+		   MALLOC_TRACE=$(objpfx)tst-fopenloc.mtrace
+tst-fgetws-ENV = LOCPATH=$(common-objpfx)localedata
+tst-ungetwc1-ENV = LOCPATH=$(common-objpfx)localedata
+tst-ungetwc2-ENV = LOCPATH=$(common-objpfx)localedata
+bug-ungetwc2-ENV = LOCPATH=$(common-objpfx)localedata
+tst-swscanf-ENV = LOCPATH=$(common-objpfx)localedata
+bug-ftell-ENV = LOCPATH=$(common-objpfx)localedata
+
+generated = tst-fopenloc.mtrace tst-fopenloc.check
+
+aux	:= fileops genops stdfiles stdio strops
+
+ifeq ($(versioning),yes)
+aux	+= oldfileops oldstdfiles
+endif
+
+shared-only-routines = oldiofopen oldiofdopen oldiofclose oldfileops	\
+		       oldstdfiles oldiopopen oldpclose oldtmpfile	\
+		       oldiofgetpos oldiofgetpos64 oldiofsetpos		\
+		       oldiofsetpos64
+
+distribute := iolibio.h libioP.h strfile.h Banner test-freopen.sh \
+	      fd_to_filename.h
+
+include ../Rules
+
+ifeq (no,$(cross-compiling))
+tests: $(objpfx)test-freopen.out $(objpfx)tst-fopenloc.check
+endif
+
+$(objpfx)test-freopen.out: test-freopen.sh $(objpfx)test-freopen
+	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)'	\
+	$(common-objpfx)libio/
+
+$(objpfx)tst-fopenloc.check: $(objpfx)tst-fopenloc.out
+	cmp ../iconvdata/testdata/ISO-8859-1..UTF8 $(objpfx)tst-fopenloc.out \
+	  > $@
+	$(common-objpfx)malloc/mtrace $(objpfx)tst-fopenloc.mtrace >> $@
Index: trunk/src/libctests/glibc/libio/bug-fopena+.c
===================================================================
--- trunk/src/libctests/glibc/libio/bug-fopena+.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/bug-fopena+.c	(revision 2036)
@@ -0,0 +1,100 @@
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+static int fd;
+static char *fname;
+
+
+static void prepare (void);
+#define PREPARE(argc, argv) prepare ()
+
+
+#define TEST_FUNCTION do_test ()
+static int do_test (void);
+#include "../test-skeleton.c"
+
+
+static void
+prepare (void)
+{
+  fd = create_temp_file ("wrewind.", &fname);
+  if (fd == -1)
+    exit (3);
+}
+
+
+static int
+do_test (void)
+{
+  char buf[100];
+  FILE *fp;
+  int result = 0;
+
+  fp = fdopen (fd, "w");
+  if (fp == NULL)
+    {
+      puts ("cannot create file");
+      exit (1);
+    }
+
+  if (fputs ("one\n", fp) == EOF || fputs ("two\n", fp) == EOF)
+    {
+      puts ("cannot create filec content");
+      exit (1);
+    }
+
+  fclose (fp);
+
+  fp = fopen (fname, "a+");
+  if (fp == NULL)
+    {
+      puts ("cannot fopen a+");
+      exit (1);
+    }
+
+  if (fgets (buf, sizeof (buf), fp) == NULL)
+    {
+      puts ("cannot read after fopen a+");
+      exit (1);
+    }
+
+  if (strcmp (buf, "one\n") != 0)
+    {
+      puts ("read after fopen a+ produced wrong result");
+      result = 1;
+    }
+
+  fclose (fp);
+
+  fd = open (fname, O_RDWR);
+  if (fd == -1)
+    {
+      puts ("open failed");
+      exit (1);
+    }
+
+  fp = fdopen (fd, "a+");
+  if (fp == NULL)
+    {
+      puts ("fopen after open failed");
+      exit (1);
+    }
+
+  if (fgets (buf, sizeof (buf), fp) == NULL)
+    {
+      puts ("cannot read after fdopen a+");
+      exit (1);
+    }
+
+  if (strcmp (buf, "one\n") != 0)
+    {
+      puts ("read after fdopen a+ produced wrong result");
+      result = 1;
+    }
+
+  fclose (fp);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/libio/bug-fseek.c
===================================================================
--- trunk/src/libctests/glibc/libio/bug-fseek.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/bug-fseek.c	(revision 2036)
@@ -0,0 +1,123 @@
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static char *fname;
+
+
+static void do_prepare (void);
+#define PREPARE(argc, argv) do_prepare ()
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#include <test-skeleton.c>
+
+
+static void
+do_prepare (void)
+{
+  static const char pattern[] = "12345678901234567890";
+  int fd = create_temp_file ("bug-fseek.", &fname);
+  if (fd == -1)
+    {
+      printf ("cannot create temporary file: %m\n");
+      exit (1);
+    }
+
+  if (write (fd, pattern, sizeof (pattern)) != sizeof (pattern))
+    {
+      perror ("short write");
+      abort ();
+    }
+  close (fd);
+}
+
+
+
+static int
+do_test (void)
+{
+  FILE *f;
+  int result = 0;
+  char buf[10];
+
+
+  if ((f = fopen (fname, "r")) == (FILE *) NULL)
+    {
+      perror ("fopen(\"r\")");
+    }
+
+  fread (buf, 3, 1, f);
+  errno = 0;
+  if (fseek (f, -10, SEEK_CUR) == 0)
+    {
+      printf ("fseek() for r to before start of file worked!\n");
+      result = 1;
+    }
+  else if (errno != EINVAL)
+    {
+      printf ("\
+fseek() for r to before start of file did not set errno to EINVAL.  \
+Got %d instead\n",
+	 errno);
+      result = 1;
+    }
+
+  fclose (f);
+
+
+  if ((f = fopen (fname, "r+")) == (FILE *) NULL)
+    {
+      perror ("fopen(\"r+\")");
+    }
+
+  fread (buf, 3, 1, f);
+  errno = 0;
+  if (fseek (f, -10, SEEK_CUR) == 0)
+    {
+      printf ("fseek() for r+ to before start of file worked!\n");
+      result = 1;
+    }
+  else if (errno != EINVAL)
+    {
+      printf ("\
+fseek() for r+ to before start of file did not set errno to EINVAL.  \
+Got %d instead\n",
+	 errno);
+      result = 1;
+    }
+
+  fclose (f);
+
+
+  if ((f = fopen (fname, "r+")) == (FILE *) NULL)
+    {
+      perror ("fopen(\"r+\")");
+    }
+
+  fread (buf, 3, 1, f);
+  if (ftell (f) != 3)
+    {
+      puts ("ftell failed");
+      return 1;
+    }
+  errno = 0;
+  if (fseek (f, -10, SEEK_CUR) == 0)
+    {
+      printf ("fseek() for r+ to before start of file worked!\n");
+      result = 1;
+    }
+  else if (errno != EINVAL)
+    {
+      printf ("\
+fseek() for r+ to before start of file did not set errno to EINVAL.  \
+Got %d instead\n",
+	 errno);
+      result = 1;
+    }
+
+  fclose (f);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/libio/bug-ftell.c
===================================================================
--- trunk/src/libctests/glibc/libio/bug-ftell.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/bug-ftell.c	(revision 2036)
@@ -0,0 +1,58 @@
+#include <locale.h>
+#include <stdio.h>
+#include <wchar.h>
+#include <sys/types.h>
+
+
+static int
+do_test (void)
+{
+  if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
+    {
+      puts ("setlocale failed");
+      return 1;
+    }
+
+  FILE *fp = tmpfile ();
+  if (fp == NULL)
+    {
+      puts ("tmpfile failed");
+      return 1;
+    }
+
+  if (fputws (L"hello", fp) == EOF)
+    {
+      puts ("fputws failed");
+      return 1;
+    }
+
+  rewind (fp);
+
+  const wchar_t *cp;
+  unsigned int cnt;
+  for (cp = L"hello", cnt = 1; *cp != L'\0'; ++cp, ++cnt)
+    {
+      wint_t wc = fgetwc (fp);
+      if (wc != (wint_t) *cp)
+	{
+	  printf ("fgetwc failed: got L'%lc', expected L'%lc'\n",
+		  wc, (wint_t) *cp);
+	  return 1;
+	}
+      off_t o = ftello (fp);
+      if (o != cnt)
+	{
+	  printf ("ftello failed: got %lu, expected %u\n",
+		  (unsigned long int) o, cnt);
+	  return 1;
+	}
+      printf ("round %u OK\n", cnt);
+    }
+
+  fclose (fp);
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/libio/bug-mmap-fflush.c
===================================================================
--- trunk/src/libctests/glibc/libio/bug-mmap-fflush.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/bug-mmap-fflush.c	(revision 2036)
@@ -0,0 +1,53 @@
+/* Test for bug in fflush synchronization behavior.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+static char *fname;
+
+static void prepare (void);
+#define PREPARE(argc, argv) prepare ()
+
+
+#define TEST_FUNCTION do_test ()
+static int do_test (void);
+#include "../test-skeleton.c"
+
+
+static void
+prepare (void)
+{
+  int fd = create_temp_file ("bug-mmap-fflush.", &fname);
+  if (fd == -1)
+    exit (3);
+  /* We don't need the descriptor.  */
+  close (fd);
+}
+
+
+static int
+do_test (void)
+{
+  FILE *f;
+  off_t o;
+  char buffer[1024];
+
+  snprintf (buffer, sizeof (buffer), "echo 'From foo@bar.com' > %s", fname);
+  system (buffer);
+  f = fopen (fname, "r");
+  fseek (f, 0, SEEK_END);
+  o = ftello (f);
+  fseek (f, 0, SEEK_SET);
+  fflush (f);
+  snprintf (buffer, sizeof (buffer), "echo 'From bar@baz.edu' >> %s", fname);
+  system (buffer);
+  fseek (f, o, SEEK_SET);
+  if (fgets (buffer, 1024, f) == NULL)
+    exit (1);
+  if (strncmp (buffer, "From ", 5) != 0)
+    exit (1);
+  fclose (f);
+  exit (0);
+}
Index: trunk/src/libctests/glibc/libio/bug-rewind.c
===================================================================
--- trunk/src/libctests/glibc/libio/bug-rewind.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/bug-rewind.c	(revision 2036)
@@ -0,0 +1,73 @@
+#include <stdio.h>
+#include <wchar.h>
+
+#define PASSED  0
+#define	FAILED  3
+
+
+static int fd;
+
+static void prepare (void);
+#define PREPARE(argc, argv) prepare ()
+
+
+#define TEST_FUNCTION do_test ()
+static int do_test (void);
+#include "../test-skeleton.c"
+
+
+static void
+prepare (void)
+{
+  fd = create_temp_file ("wrewind.", NULL);
+  if (fd == -1)
+    exit (3);
+}
+
+
+static int
+do_test (void)
+{
+  FILE *fptr;
+  char arg1;
+  char arg2;
+  int ret1, ret2, result, num;
+
+  ret1 = 0;
+  ret2 = 0;
+
+  fptr = fdopen (fd, "w+");
+  if (fptr == NULL)
+    {
+      printf ("Unable to open file.\n");
+      return 1;
+    }
+
+  if (fwprintf (fptr, L"cderf") <= 0)
+    {
+      printf ("Unable to write to file with fwprintf().\n");
+      fclose (fptr);
+      return 2;
+    }
+
+  rewind (fptr);
+  ret1 = fwscanf (fptr, L"%c%c", &arg1, &arg2);
+
+  rewind (fptr);
+  ret2 = fwscanf (fptr, L"%c%n%c", &arg1, &num, &arg2);
+
+  if (arg2 != 'd')
+    {
+      result = FAILED;
+      printf ("rewind after first fwscanf failed\n");
+    }
+  else
+    {
+      printf ("Passed\n");
+      result = PASSED;
+    }
+
+
+  fclose (fptr);
+  return result;
+}
Index: trunk/src/libctests/glibc/libio/bug-rewind2.c
===================================================================
--- trunk/src/libctests/glibc/libio/bug-rewind2.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/bug-rewind2.c	(revision 2036)
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <wchar.h>
+
+
+static int fd;
+
+static void prepare (void);
+#define PREPARE(argc, argv) prepare ()
+
+
+#define TEST_FUNCTION do_test ()
+static int do_test (void);
+#include "../test-skeleton.c"
+
+
+static void
+prepare (void)
+{
+  fd = create_temp_file ("wrewind2.", NULL);
+  if (fd == -1)
+    exit (3);
+}
+
+
+static int
+do_test (void)
+{
+  wchar_t dummy[10];
+  int ret = 0;
+  FILE *fp;
+  int result = 0;
+
+  fp = fdopen (fd, "w+");
+  if (fp == NULL)
+    {
+      puts ("fopen(""testfile"", ""w+"") returned NULL.");
+      return 1;
+    }
+  else
+    {
+      fwprintf (fp, L"abcd");
+      printf ("current pos = %ld\n", ftell (fp));
+      if (ftell (fp) != 4)
+	result = 1;
+
+      rewind (fp);
+      ret = fwscanf (fp, L"%c", dummy);
+
+      printf ("current pos = %ld\n", ftell (fp));
+      if (ftell (fp) != 1)
+	result = 1;
+
+      rewind (fp);
+      printf ("current pos = %ld\n", ftell (fp));
+      if (ftell (fp) != 0)
+	result = 1;
+
+      fclose (fp);
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/libio/bug-ungetc.c
===================================================================
--- trunk/src/libctests/glibc/libio/bug-ungetc.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/bug-ungetc.c	(revision 2036)
@@ -0,0 +1,61 @@
+/* Test program for ungetc/ftell interaction bug.  */
+
+#include <stdio.h>
+
+static void do_prepare (void);
+#define PREPARE(argc, argv) do_prepare ()
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#include <test-skeleton.c>
+
+static const char pattern[] = "12345";
+static char *temp_file;
+
+static void
+do_prepare (void)
+{
+  int fd = create_temp_file ("bug-ungetc.", &temp_file);
+  if (fd == -1)
+    {
+      printf ("cannot create temporary file: %m\n");
+      exit (1);
+    }
+  write (fd, pattern, sizeof (pattern));
+  close (fd);
+}
+
+static int
+do_test (void)
+{
+  int i;
+  FILE *f;
+  char buf[10];
+  long offset, diff;
+  int result = 0;
+
+  f = fopen (temp_file, "rw");
+
+  rewind (f);
+  for (i = 0; i < 3; i++)
+    printf ("%c\n", getc (f));
+  offset = ftell (f);
+  printf ("offset = %ld\n", offset);
+  if (ungetc ('4', f) != '4')
+    {
+      printf ("ungetc failed\n");
+      abort ();
+    }
+  printf ("offset after ungetc = %ld\n", ftell (f));
+
+  i = fread ((void *) buf, 4, (size_t) 1, f);
+  printf ("read %d (%c), offset = %ld\n", i, buf[0], ftell (f));
+  diff = ftell (f) - offset;
+  if (diff != 3)
+    {
+      printf ("ftell did not update properly.  got %ld, expected 3\n", diff);
+      result = 1;
+    }
+  fclose (f);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/libio/bug-ungetc2.c
===================================================================
--- trunk/src/libctests/glibc/libio/bug-ungetc2.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/bug-ungetc2.c	(revision 2036)
@@ -0,0 +1,98 @@
+#include <stdio.h>
+#include <sys/types.h>
+
+
+static int
+check (FILE *fp, off_t o)
+{
+  int result = 0;
+  if (feof (fp))
+    {
+      puts ("feof !");
+      result = 1;
+    }
+  if (ferror (fp))
+    {
+      puts ("ferror !");
+      result = 1;
+    }
+  if (ftello (fp) != o)
+    {
+      printf ("position = %lu, not %lu\n", (unsigned long int) ftello (fp),
+	      (unsigned long int) o);
+      result = 1;
+    }
+  return result;
+}
+
+
+static int
+do_test (void)
+{
+  FILE *fp = tmpfile ();
+  if (fp == NULL)
+    {
+      puts ("tmpfile failed");
+      return 1;
+    }
+  if (check (fp, 0) != 0)
+    return 1;
+
+  puts ("going to write");
+  if (fputs ("hello", fp) == EOF)
+    {
+      puts ("fputs failed");
+      return 1;
+    }
+  if (check (fp, 5) != 0)
+    return 1;
+
+  puts ("going to rewind");
+  rewind (fp);
+  if (check (fp, 0) != 0)
+    return 1;
+
+  puts ("going to read char");
+  int c = fgetc (fp);
+  if (c != 'h')
+    {
+      printf ("read %c, not %c\n", c, 'h');
+      return 1;
+    }
+  if (check (fp, 1) != 0)
+    return 1;
+
+  puts ("going to put back");
+  if (ungetc (' ', fp) == EOF)
+    {
+      puts ("ungetc failed");
+      return 1;
+    }
+  if (check (fp, 0) != 0)
+    return 1;
+
+  puts ("going to write again");
+  if (fputs ("world", fp) == EOF)
+    {
+      puts ("2nd fputs failed");
+      return 1;
+    }
+  if (check (fp, 5) != 0)
+    return 1;
+
+  puts ("going to rewind again");
+  rewind (fp);
+  if (check (fp, 0) != 0)
+    return 1;
+
+  if (fclose (fp) != 0)
+    {
+      puts ("fclose failed");
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/libio/bug-ungetc3.c
===================================================================
--- trunk/src/libctests/glibc/libio/bug-ungetc3.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/bug-ungetc3.c	(revision 2036)
@@ -0,0 +1,94 @@
+/* Test program for ungetc/ftell interaction bug.  */
+
+#include <stdio.h>
+
+static void do_prepare (void);
+#define PREPARE(argc, argv) do_prepare ()
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
+
+static const char pattern[] = "12345";
+static char *temp_file;
+
+static void
+do_prepare (void)
+{
+  int fd = create_temp_file ("bug-ungetc.", &temp_file);
+  if (fd == -1)
+    {
+      printf ("cannot create temporary file: %m\n");
+      exit (1);
+    }
+  write (fd, pattern, sizeof (pattern));
+  close (fd);
+}
+
+static int
+do_one_test (int mode)
+{
+  FILE *f;
+
+  f = fopen (temp_file, "r");
+  if (f == NULL)
+    {
+      printf ("could not open temporary file: %m\n");
+      return 1;
+    }
+
+  if (mode == 1 && ftell (f) != 0)
+    {
+      printf ("first ftell returned wrong position %ld\n", ftell (f));
+      return 1;
+    }
+
+  if (fgetc (f) != '1' || fgetc (f) != '2')
+    {
+      puts ("fgetc failed");
+      return 1;
+    }
+
+  if (mode == 2 && ftell (f) != 2)
+    {
+      printf ("second ftell returned wrong position %ld\n", ftell (f));
+      return 1;
+    }
+
+  if (ungetc ('6', f) != '6')
+    {
+      puts ("ungetc failed");
+      return 1;
+    }
+
+  if (ftell (f) != 1)
+    {
+      printf ("third ftell returned wrong position %ld\n", ftell (f));
+      return 1;
+    }
+
+  if (fgetc (f) != '6')
+    {
+      puts ("fgetc failed");
+      return 1;
+    }
+
+  if (ftell (f) != 2)
+    {
+      printf ("fourth ftell returned wrong position %ld\n", ftell (f));
+      return 1;
+    }
+
+  fclose (f);
+
+  return 0;
+}
+
+static int
+do_test (void)
+{
+  int mode;
+  for (mode = 0; mode <= 2; mode++)
+    if (do_one_test (mode))
+      return 1;
+  return 0;
+}
Index: trunk/src/libctests/glibc/libio/bug-ungetc4.c
===================================================================
--- trunk/src/libctests/glibc/libio/bug-ungetc4.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/bug-ungetc4.c	(revision 2036)
@@ -0,0 +1,116 @@
+/* Test program for ungetc/fseekpos interaction.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+
+static void do_prepare (void);
+#define PREPARE(argc, argv) do_prepare ()
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
+
+static const char pattern[] = "abcdefghijklmnopqrstuvwxyz";
+static char *temp_file;
+
+static void
+do_prepare (void)
+{
+  int fd = create_temp_file ("bug-ungetc.", &temp_file);
+  if (fd == -1)
+    {
+      printf ("cannot create temporary file: %m\n");
+      exit (1);
+    }
+  write (fd, pattern, sizeof (pattern) - 1);
+  close (fd);
+}
+
+#define TEST_POS 5
+
+static int
+do_one_test (int mode)
+{
+  FILE *f = fopen (temp_file, "r");
+  if (f == NULL)
+    {
+      printf ("%d: could not open temporary file: %m\n", mode);
+      return 1;
+    }
+
+  int i;
+  for (i = 0; i < TEST_POS; ++i)
+    getc (f);
+
+  fpos_t p;
+  if (fgetpos (f, &p) != 0)
+    {
+      printf ("%d: fgetpos failed: %m\n", mode);
+      return 1;
+    }
+
+  if (mode)
+    {
+      if (fseek (f, 0, SEEK_SET) != 0)
+        {
+          printf ("%d: fseek failed: %m\n", mode);
+          return 1;
+        }
+
+      for (i = 0; i < TEST_POS - (mode >= 2); ++i)
+        getc (f);
+    }
+
+  if (mode != 2 && ungetc ('X', f) != 'X')
+    {
+      printf ("%d: ungetc failed\n", mode);
+      return 1;
+    }
+
+  if (mode == 3 && getc (f) != 'X')
+    {
+      printf ("%d: getc after ungetc did not return X\n", mode);
+      return 1;
+    }
+
+  if (fsetpos (f, &p) != 0)
+    {
+      printf ("%d: fsetpos failed: %m\n", mode);
+      return 1;
+    }
+
+  if (getc (f) != pattern[TEST_POS])
+    {
+      printf ("%d: getc did not return %c\n", mode, pattern[TEST_POS]);
+      return 1;
+    }
+
+  fclose (f);
+
+  return 0;
+}
+
+static int
+do_test (void)
+{
+  int mode, ret = 0;
+  for (mode = 0; mode <= 4; mode++)
+    ret |= do_one_test (mode);
+  return ret;
+}
Index: trunk/src/libctests/glibc/libio/bug-ungetwc1.c
===================================================================
--- trunk/src/libctests/glibc/libio/bug-ungetwc1.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/bug-ungetwc1.c	(revision 2036)
@@ -0,0 +1,74 @@
+#define _XOPEN_SOURCE 500
+#include <stdio.h>
+#include <stdlib.h>
+#include <locale.h>
+#include <wchar.h>
+
+const char write_chars[] = "ABC";      /* Characters on testfile. */
+const wint_t unget_wchar = L'A';      /* Ungotten wide character. */
+
+char *fname;
+
+
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+
+#include "../test-skeleton.c"
+
+
+static int
+do_test (void)
+{
+  wint_t wc;
+  FILE *fp;
+  int fd;
+
+  fname = (char *) malloc (strlen (test_dir) + sizeof "/bug-ungetwc1.XXXXXX");
+  if (fname == NULL)
+    {
+      puts ("no memory");
+      return 1;
+    }
+  strcpy (stpcpy (fname, test_dir), "/bug-ungetwc1.XXXXXX");
+  fd = mkstemp (fname);
+  if (fd == -1)
+    {
+      printf ("cannot open temporary file: %m\n");
+      return 1;
+    }
+  add_temp_file (fname);
+
+  setlocale(LC_ALL, "");
+
+  /* Output to the file. */
+  if ((fp = fdopen (fd, "w")) == NULL)
+    {
+      fprintf (stderr, "Cannot make `%s' file\n", fname);
+      exit (EXIT_FAILURE);
+    }
+
+  fprintf (fp, "%s", write_chars);
+  fclose (fp);
+
+  /* Read from the file. */
+  fp = fopen (fname, "r");
+
+  while (!feof (fp))
+    wc = getwc (fp);
+  printf ("\nThe end-of-file indicator is set.\n");
+
+  /* Unget a wide character. */
+  ungetwc (unget_wchar, fp);
+  printf ("< `%lc' is ungotten.\n", unget_wchar);
+
+  /* Check the end-of-file indicator. */
+  if (feof (fp))
+    printf ("The end-of-file indicator is still set.\n");
+  else
+    printf ("The end-of-file flag is cleared.\n");
+
+  fflush (stdout);
+  fclose (fp);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/libio/bug-ungetwc2.c
===================================================================
--- trunk/src/libctests/glibc/libio/bug-ungetwc2.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/bug-ungetwc2.c	(revision 2036)
@@ -0,0 +1,93 @@
+#define _XOPEN_SOURCE 500
+#include <errno.h>
+#include <error.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <locale.h>
+#include <wchar.h>
+
+const char test_locale[] = "de_DE.UTF-8";
+const wchar_t write_wchars[] = {L'A', 0x00C4, L'B', L'\0'};
+                                /* `0x00C4' is A with diaeresis. */
+size_t last_pos = 2;            /* Which character is last one to read. */
+wint_t unget_wchar = L'C';      /* Ungotten ide characters. */
+
+char *fname;
+
+
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+
+#include "../test-skeleton.c"
+
+
+static int
+do_test (void)
+{
+  size_t i;
+  wint_t wc;
+  FILE *fp;
+  int fd;
+
+  fname = (char *) malloc (strlen (test_dir) + sizeof "/bug-ungetwc2.XXXXXX");
+  if (fname == NULL)
+    {
+      puts ("no memory");
+      return 1;
+    }
+  strcpy (stpcpy (fname, test_dir), "/bug-ungetwc2.XXXXXX");
+  fd = mkstemp (fname);
+  if (fd == -1)
+    {
+      printf ("cannot open temporary file: %m\n");
+      return 1;
+    }
+  add_temp_file (fname);
+
+  printf ("\nNote: This program runs on %s locale.\n\n", test_locale);
+
+  if (setlocale (LC_ALL, test_locale) == NULL)
+    {
+      fprintf (stderr, "Cannot use `%s' locale.\n", test_locale);
+      exit (EXIT_FAILURE);
+    }
+
+  /* Output to the file. */
+  if ((fp = fdopen (fd, "w")) == NULL)
+    {
+      setlocale (LC_ALL, "C");
+      fprintf (stderr, "Cannot make `%s' file.\n", fname);
+      exit (EXIT_FAILURE);
+    }
+  fprintf (fp, "%ls", write_wchars);
+  fclose (fp);
+
+  /* Read from the file. */
+  fp = fopen (fname, "r");
+  if (fp == NULL)
+    {
+      setlocale (LC_ALL, "C");
+      error (EXIT_FAILURE, errno, "cannot open %s", fname);
+    }
+
+  printf ("%s is opened.\n", fname);
+
+  for (i = 0; i < last_pos; i++)
+    {
+      wc = getwc (fp);
+      printf ("> `%lc' is gotten.\n", wc);
+    }
+
+  /* Unget a wide character. */
+  ungetwc (unget_wchar, fp);
+  printf ("< `%lc' is ungotten.\n", unget_wchar);
+
+  /* Reget the wide character. */
+  wc = getwc (fp);
+  printf ("> `%lc' is regotten.\n", wc);
+
+  fflush (stdout);
+  fclose (fp);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/libio/bug-wfflush.c
===================================================================
--- trunk/src/libctests/glibc/libio/bug-wfflush.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/bug-wfflush.c	(revision 2036)
@@ -0,0 +1,76 @@
+/* Test program for bug in wide streams.  */
+
+#include <stdio.h>
+#include <wchar.h>
+
+static void do_prepare (void);
+#define PREPARE(argc, argv) do_prepare ()
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#include <test-skeleton.c>
+
+static char *temp_file;
+
+static void
+do_prepare (void)
+{
+  int fd = create_temp_file ("bug-ungetc.", &temp_file);
+  if (fd == -1)
+    {
+      printf ("cannot create temporary file: %m\n");
+      exit (1);
+    }
+  write (fd, "1!", 2);
+  close (fd);
+}
+
+static int
+do_test (void)
+{
+  FILE *f = fopen (temp_file, "r+");
+
+  if (f == NULL)
+    {
+      printf ("fopen: %m\n");
+      return 1;
+    }
+
+#define L_(s) L##s
+  //#define fwscanf fscanf
+  //#define fwprintf fprintf
+
+  int i;
+  if (fwscanf (f, L_("%d!"), &i) != 1)
+    {
+      printf ("fwscanf failed\n");
+      return 1;
+    }
+
+  rewind (f);
+  if (ferror (f))
+    {
+      printf ("rewind: %m\n");
+      return 1;
+    }
+
+  if (fputws (L_("1!"), f) == EOF)
+    {
+      printf ("fputws: %m\n");
+      return 1;
+    }
+
+  if (fflush (f) != 0)
+    {
+      printf ("fflush: %m\n");
+      return 1;
+    }
+
+  if (fclose (f) != 0)
+    {
+      printf ("fclose: %m\n");
+      return 1;
+    }
+
+  puts ("Test succeeded.");
+  return 0;
+}
Index: trunk/src/libctests/glibc/libio/test-fmemopen.c
===================================================================
--- trunk/src/libctests/glibc/libio/test-fmemopen.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/test-fmemopen.c	(revision 2036)
@@ -0,0 +1,40 @@
+/* Test for fmemopen implementation.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Hanno Mueller, kontakt@hanno.de, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+static char buffer[] = "foobar";
+
+#include <stdio.h>
+#include <string.h>
+
+int
+main (void)
+{
+  int ch;
+  FILE *stream;
+
+  stream = fmemopen (buffer, strlen (buffer), "r");
+
+  while ((ch = fgetc (stream)) != EOF)
+    printf ("Got %c\n", ch);
+
+  fclose (stream);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/libio/test-freopen.c
===================================================================
--- trunk/src/libctests/glibc/libio/test-freopen.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/test-freopen.c	(revision 2036)
@@ -0,0 +1,57 @@
+/* Test for freopen implementation.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <mcheck.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <wchar.h>
+
+
+int
+main (int argc, char *argv[])
+{
+  FILE *fp;
+
+  mtrace ();
+
+  if (argc < 2)
+    exit (1);
+
+  fp = fopen (argv[1], "w");
+  if (fp == NULL)
+    {
+      puts ("fopen failed: %m");
+      exit (1);
+    }
+
+  fputs ("Hello world (mb)\n", fp);
+
+  fp = freopen (argv[1], "a+", fp);
+  if (fp == NULL)
+    {
+      puts ("freopen failed: %m");
+      exit (1);
+    }
+
+  fputws (L"Hello world (wc)\n", fp);
+
+  fclose (fp);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/libio/test-freopen.sh
===================================================================
--- trunk/src/libctests/glibc/libio/test-freopen.sh	(revision 2036)
+++ trunk/src/libctests/glibc/libio/test-freopen.sh	(revision 2036)
@@ -0,0 +1,32 @@
+#! /bin/sh
+# Test of freopen.
+# Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+common_objpfx=$1
+run_program_prefix=$2
+objpfx=$3
+
+${run_program_prefix} ${objpfx}test-freopen ${objpfx}test-freopen.out &&
+cmp ${objpfx}test-freopen.out - <<"EOF"
+Hello world (mb)
+Hello world (wc)
+EOF
+
+exit $?
Index: trunk/src/libctests/glibc/libio/tst-atime.c
===================================================================
--- trunk/src/libctests/glibc/libio/tst-atime.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst-atime.c	(revision 2036)
@@ -0,0 +1,121 @@
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/statvfs.h>
+
+
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 5
+#include <test-skeleton.c>
+
+
+static int
+do_test (void)
+{
+  char *buf;
+  int fd;
+  FILE *fp;
+  int ch;
+  struct stat st1;
+  struct stat st2;
+  struct statvfs sv;
+  int e;
+
+  buf = (char *) malloc (strlen (test_dir) + sizeof "/tst-atime.XXXXXX");
+  if (buf == NULL)
+    {
+      printf ("cannot allocate memory: %m\n");
+      return 1;
+    }
+  stpcpy (stpcpy (buf, test_dir), "/tst-atime.XXXXXX");
+
+  fd = mkstemp (buf);
+  if (fd == -1)
+    {
+      printf ("cannot open temporary file: %m\n");
+      return 1;
+    }
+
+#ifdef ST_NOATIME
+  /* Make sure the filesystem doesn't have the noatime option set.  If
+     statvfs is not available just continue.  */
+  e = fstatvfs (fd, &sv);
+  if (e != ENOSYS)
+    {
+      if (e != 0)
+	{
+	  printf ("cannot statvfs '%s': %m\n", buf);
+	  return 1;
+	}
+
+      if ((sv.f_flag & ST_NOATIME) != 0)
+	{
+	  puts ("Bah!  The filesystem is mounted with noatime");
+	  return 0;
+	}
+    }
+#endif
+
+  /* Make sure it gets removed.  */
+  add_temp_file (buf);
+
+  if (write (fd, "some string\n", 12) != 12)
+    {
+      printf ("cannot write temporary file: %m\n");
+      return 1;
+    }
+
+  if (lseek (fd, 0, SEEK_SET) == (off_t) -1)
+    {
+      printf ("cannot reposition temporary file: %m\n");
+      return 1;
+    }
+
+  fp = fdopen (fd, "r");
+  if (fp == NULL)
+    {
+      printf ("cannot create stream: %m\n");
+      return 1;
+    }
+
+  if (fstat (fd, &st1) == -1)
+    {
+      printf ("first stat failed: %m\n");
+      return 1;
+    }
+
+  sleep (2);
+
+  ch = fgetc (fp);
+  if (ch != 's')
+    {
+      printf ("did not read correct character: got '%c', expected 's'\n", ch);
+      return 1;
+    }
+
+  if (fstat (fd, &st2) == -1)
+    {
+      printf ("second stat failed: %m\n");
+      return 1;
+    }
+
+  if (st1.st_atime > st2.st_atime)
+    {
+      puts ("second atime smaller");
+      return 1;
+    }
+  else if (st1.st_atime == st2.st_atime)
+    {
+      puts ("atime has not changed");
+      return 1;
+    }
+
+  fclose (fp);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/libio/tst-eof.c
===================================================================
--- trunk/src/libctests/glibc/libio/tst-eof.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst-eof.c	(revision 2036)
@@ -0,0 +1,75 @@
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static void do_prepare (void);
+#define PREPARE(argc, argv) do_prepare ()
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#include <test-skeleton.c>
+
+
+int fd;
+
+
+static void
+do_prepare (void)
+{
+  fd = create_temp_file ("tst-eof.", NULL);
+  if (fd == -1)
+    {
+      printf ("cannot create temporary file: %m\n");
+      exit (1);
+    }
+}
+
+
+static int
+do_test (void)
+{
+  char buf[40];
+  FILE *fp;
+
+  if (write (fd, "some string\n", 12) != 12)
+    {
+      printf ("cannot write temporary file: %m\n");
+      return 1;
+    }
+
+  if (lseek (fd, 0, SEEK_SET) == (off_t) -1)
+    {
+      printf ("cannot reposition temporary file: %m\n");
+      return 1;
+    }
+
+  fp = fdopen (fd, "r");
+  if (fp == NULL)
+    {
+      printf ("cannot create stream: %m\n");
+      return 1;
+    }
+
+  if (feof (fp))
+    {
+      puts ("EOF set after fdopen");
+      return 1;
+    }
+
+  if (fread (buf, 1, 20, fp) != 12)
+    {
+      puts ("didn't read the correct number of bytes");
+      return 1;
+    }
+
+  if (! feof (fp))
+    {
+      puts ("EOF not set after fread");
+      return 1;
+    }
+
+  fclose (fp);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/libio/tst-ext.c
===================================================================
--- trunk/src/libctests/glibc/libio/tst-ext.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst-ext.c	(revision 2036)
@@ -0,0 +1,141 @@
+#include <stdio_ext.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+int
+main (void)
+{
+  FILE *fp;
+  const char teststring[] = "hello world";
+  char buf[3072];
+  int result = 0;
+  char readbuf[256];
+
+  /* Open a file.  */
+  fp = tmpfile ();
+
+  /* Set a buffer.  */
+  if (setvbuf (fp, buf, _IOFBF, sizeof buf) == EOF)
+    {
+      printf ("setvbuf failed: %m\n");
+      exit (1);
+    }
+
+  /* Get the buffer size.  */
+  if (__fbufsize (fp) != sizeof buf)
+    {
+      printf ("__fbusize() reported a buffer size of %Zd bytes;"
+	      " we installed a buffer with %Zd bytes\n",
+	      __fbufsize (fp), sizeof buf);
+      result = 1;
+    }
+
+  /* Write something and read it back.  */
+  if (fputs (teststring, fp) == EOF)
+    {
+      printf ("writing to new stream failed: %m\n");
+      exit (1);
+    }
+  rewind (fp);
+  if (fgets (readbuf, sizeof readbuf, fp) == NULL)
+    {
+      printf ("reading from new stream failed: %m\n");
+      exit (1);
+    }
+  if (strcmp (readbuf, teststring) != 0)
+    {
+      puts ("not the correct string read");
+      exit (1);
+    }
+
+  /* The file must be opened for reading and writing.  */
+  if (__freading (fp) == 0)
+    {
+      puts ("__freading() reported stream is not last read from");
+      result = 1;
+    }
+  if (__fwriting (fp) != 0)
+    {
+      puts ("__fwriting() reported stream is write-only or last written to");
+      result = 1;
+    }
+  rewind (fp);
+  if (fputs (teststring, fp) == EOF)
+    {
+      printf ("writing(2) to new stream failed: %m\n");
+      exit (1);
+    }
+  if (__fwriting (fp) == 0)
+    {
+      puts ("__fwriting() doe snot reported stream is last written to");
+      result = 1;
+    }
+  if (__freading (fp) != 0)
+    {
+      puts ("__freading() reported stream is last read from");
+      result = 1;
+    }
+
+  if (__freadable (fp) == 0)
+    {
+      puts ("__freading() reported stream is last readable");
+      result = 1;
+    }
+  if (__fwritable (fp) == 0)
+    {
+      puts ("__freading() reported stream is last writable");
+      result = 1;
+    }
+
+  /* The string we wrote above should still be in the buffer.  */
+  if (__fpending (fp) != strlen (teststring))
+    {
+      printf ("__fpending() returned %Zd; expected %Zd\n",
+	      __fpending (fp), strlen (teststring));
+      result = 1;
+    }
+  /* Discard all the output.  */
+  __fpurge (fp);
+  /* And check again.  */
+  if (__fpending (fp) != 0)
+    {
+      printf ("__fpending() returned %Zd; expected 0\n",
+	      __fpending (fp));
+      result = 1;
+    }
+
+
+  /* Find out whether buffer is line buffered.  */
+  if (__flbf (fp) != 0)
+    {
+      puts ("__flbf() reports line buffered but it is fully buffered");
+      result = 1;
+    }
+
+  if (setvbuf (fp, buf, _IOLBF, sizeof buf) == EOF)
+    {
+      printf ("setvbuf(2) failed: %m\n");
+      exit (1);
+    }
+  if (__flbf (fp) == 0)
+    {
+      puts ("__flbf() reports file is not line buffered");
+      result = 1;
+    }
+
+  if (setvbuf (fp, NULL, _IONBF, 0) == EOF)
+    {
+      printf ("setvbuf(3) failed: %m\n");
+      exit (1);
+    }
+  if (__flbf (fp) != 0)
+    {
+      puts ("__flbf() reports line buffered but it is not buffered");
+      result = 1;
+    }
+
+  fclose (fp);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/libio/tst-fgetws.c
===================================================================
--- trunk/src/libctests/glibc/libio/tst-fgetws.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst-fgetws.c	(revision 2036)
@@ -0,0 +1,185 @@
+/* Taken from the Li18nux base test suite.  */
+
+#define _XOPEN_SOURCE 500
+#include <errno.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <wchar.h>
+
+#define WIDE_STR_LEN 32
+
+int
+main (int argc, char *argv[])
+{
+  size_t i;
+  FILE   *fp;
+  wchar_t *ret, wcs[WIDE_STR_LEN];
+  int result = 0;
+  const char il_str1[] = {0xe3, 0x81, '\0'};
+  const char il_str2[] = {'0', '\n', 'A', 'B', 0xe3, 0x81, 'E', '\0'};
+  char name1[] = "/tmp/tst-fgetws.out.XXXXXX";
+  char name2[] = "/tmp/tst-fgetws.out.XXXXXX";
+  int fd;
+
+  puts ("This program runs on de_DE.UTF-8 locale.");
+  if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
+    {
+      fprintf (stderr, "Err: Cannot run on the de_DE.UTF-8 locale");
+      exit (EXIT_FAILURE);
+    }
+
+  /* Make a file `il_str1'. */
+  fd = mkstemp (name1);
+  if (fd == -1)
+    {
+      printf ("cannot open temp file: %m\n");
+      exit (EXIT_FAILURE);
+    }
+  if ((fp = fdopen (fd, "w")) == NULL)
+    {
+      printf ("Can't open %s.\n", argv[1]);
+      exit (EXIT_FAILURE);
+    }
+  fwrite (il_str1, sizeof (char), sizeof (il_str1), fp);
+  fclose (fp);
+
+  /* Make a file `il_str2'. */
+  fd = mkstemp (name2);
+  if (fd == -1)
+    {
+      printf ("cannot open temp file: %m\n");
+      exit (EXIT_FAILURE);
+    }
+  if ((fp = fdopen (fd, "w")) == NULL)
+    {
+      fprintf (stderr, "Can't open %s.\n", argv[1]);
+      exit (EXIT_FAILURE);
+    }
+  fwrite (il_str2, sizeof (char), sizeof (il_str2), fp);
+  fclose (fp);
+
+
+  /* Test for il_str1. */
+  if ((fp = fopen (name1, "r")) == NULL)
+    {
+      fprintf (stderr, "Can't open %s.\n", argv[1]);
+      exit (EXIT_FAILURE);
+    }
+
+  puts ("--");
+  puts ("Read a byte sequence which is invalid as a wide character string.");
+  puts (" bytes: 0xe3, 0x81, '\\0'");
+
+  errno = 0;
+  ret = fgetws (wcs, WIDE_STR_LEN, fp);
+
+  if (ret == NULL)
+    {
+      puts ("Return Value: NULL");
+
+      if (errno == EILSEQ)
+	puts ("errno = EILSEQ");
+      else
+	{
+	  printf ("errno = %d\n", errno);
+	  result = 1;
+	}
+    }
+  else
+    {
+      printf ("Return Value: %p\n", ret);
+      for (i = 0; i < wcslen (wcs) + 1; i++)
+	printf (" wcs[%zd] = %04x", i, (unsigned int)wcs[i]);
+      printf ("\n");
+      result = 1;
+    }
+
+  /* Test for il_str2. */
+  if ((fp = fopen (name2, "r")) == NULL)
+    {
+      fprintf (stderr, "Can't open %s.\n", argv[1]);
+      exit (EXIT_FAILURE);
+    }
+
+  puts ("--");
+  puts ("Read a byte sequence which is invalid as a wide character string.");
+  puts (" bytes: '0', '\\n', 'A', 'B', 0xe3, 0x81, 'c', '\\0'");
+
+  errno = 0;
+  ret = fgetws (wcs, WIDE_STR_LEN, fp);
+
+  if (ret == NULL)
+    {
+      puts ("Return Value: NULL");
+
+      if (errno == EILSEQ)
+	puts ("errno = EILSEQ");
+      else
+	printf ("errno = %d\n", errno);
+
+      result = 1;
+    }
+  else
+    {
+      size_t i;
+
+      printf ("Return Value: %p\n", ret);
+      for (i = 0; i < wcslen (wcs) + 1; i++)
+	printf (" wcs[%zd] = 0x%04x", i, (unsigned int)wcs[i]);
+      printf ("\n");
+
+      for (i = 0; il_str2[i] != '\n'; ++i)
+	if ((wchar_t) il_str2[i] != wcs[i])
+	  {
+	    puts ("read string not correct");
+	    result = 1;
+	    break;
+	  }
+      if (il_str2[i] == '\n')
+	{
+	  if (wcs[i] != L'\n')
+	    {
+	      puts ("newline missing");
+	      result = 1;
+	    }
+	  else if (wcs[i + 1] != L'\0')
+	    {
+	      puts ("read string not NUL-terminated");
+	      result = 1;
+	    }
+	}
+    }
+
+  puts ("\nsecond line");
+  errno = 0;
+  ret = fgetws (wcs, WIDE_STR_LEN, fp);
+
+  if (ret == NULL)
+    {
+      puts ("Return Value: NULL");
+
+      if (errno == EILSEQ)
+	puts ("errno = EILSEQ");
+      else
+	{
+	  printf ("errno = %d\n", errno);
+	  result = 1;
+	}
+    }
+  else
+    {
+      printf ("Return Value: %p\n", ret);
+      for (i = 0; i < wcslen (wcs) + 1; i++)
+	printf (" wcs[%zd] = 0x%04x", i, (unsigned int)wcs[i]);
+      printf ("\n");
+    }
+
+  fclose (fp);
+
+  unlink (name1);
+  unlink (name2);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/libio/tst-fopenloc.c
===================================================================
--- trunk/src/libctests/glibc/libio/tst-fopenloc.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst-fopenloc.c	(revision 2036)
@@ -0,0 +1,62 @@
+/* Test for ,ccs= handling in fopen.
+   Copyright (C) 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 2001.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <locale.h>
+#include <mcheck.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+
+
+static const char inputfile[] = "../iconvdata/testdata/ISO-8859-1";
+
+
+int
+main (void)
+{
+  FILE *fp;
+
+  mtrace ();
+
+  setlocale (LC_ALL, "de_DE.UTF-8");
+
+  fp = fopen (inputfile, "r,ccs=ISO-8859-1");
+  if (fp == NULL)
+    {
+      printf ("cannot open \"%s\": %s\n", inputfile, strerror (errno));
+      exit (1);
+    }
+
+  while (! feof_unlocked (fp))
+    {
+      wchar_t buf[200];
+
+      if (fgetws_unlocked (buf, sizeof (buf) / sizeof (buf[0]), fp) == NULL)
+	break;
+
+      fputws (buf, stdout);
+    }
+
+  fclose (fp);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/libio/tst-freopen.c
===================================================================
--- trunk/src/libctests/glibc/libio/tst-freopen.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst-freopen.c	(revision 2036)
@@ -0,0 +1,103 @@
+/* Test freopen with mmap stdio.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+int
+main (void)
+{
+  char name[] = "/tmp/tst-freopen.XXXXXX";
+  const char * const test = "Let's test freopen.\n";
+  char temp[strlen (test) + 1];
+  int fd = mkstemp (name);
+  FILE *f;
+
+  if (fd == -1)
+    {
+      printf ("%u: cannot open temporary file: %m\n", __LINE__);
+      exit (1);
+    }
+
+  f = fdopen (fd, "w");
+  if (f == NULL)
+    {
+      printf ("%u: cannot fdopen temporary file: %m\n", __LINE__);
+      exit (1);
+    }
+
+  fputs (test, f);
+  fclose (f);
+
+  f = fopen (name, "r");
+  if (f == NULL)
+    {
+      printf ("%u: cannot fopen temporary file: %m\n", __LINE__);
+      exit (1);
+    }
+
+  if (fread (temp, 1, strlen (test), f) != strlen (test))
+    {
+      printf ("%u: couldn't read the file back: %m\n", __LINE__);
+      exit (1);
+    }
+  temp [strlen (test)] = '\0';
+
+  if (strcmp (test, temp))
+    {
+      printf ("%u: read different string than was written:\n%s%s",
+	      __LINE__, test, temp);
+      exit (1);
+    }
+
+  f = freopen (name, "r+", f);
+  if (f == NULL)
+    {
+      printf ("%u: cannot freopen temporary file: %m\n", __LINE__);
+      exit (1);
+    }
+
+  if (fseek (f, 0, SEEK_SET) != 0)
+    {
+      printf ("%u: couldn't fseek to start: %m\n", __LINE__);
+      exit (1);
+    }
+
+  if (fread (temp, 1, strlen (test), f) != strlen (test))
+    {
+      printf ("%u: couldn't read the file back: %m\n", __LINE__);
+      exit (1);
+    }
+  temp [strlen (test)] = '\0';
+
+  if (strcmp (test, temp))
+    {
+      printf ("%u: read different string than was written:\n%s%s",
+	      __LINE__, test, temp);
+      exit (1);
+    }
+
+  fclose (f);
+
+  unlink (name);
+  exit (0);
+}
Index: trunk/src/libctests/glibc/libio/tst-mmap-eofsync.c
===================================================================
--- trunk/src/libctests/glibc/libio/tst-mmap-eofsync.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst-mmap-eofsync.c	(revision 2036)
@@ -0,0 +1,106 @@
+/* Test program for synchronization of stdio state with file after EOF.  */
+
+#include <stdio.h>
+#include <error.h>
+#include <errno.h>
+
+static void do_prepare (void);
+#define PREPARE(argc, argv) do_prepare ()
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#include <test-skeleton.c>
+
+static char *temp_file;
+static int temp_fd;
+
+static char text1[] = "Line the first\n";
+static char text2[] = "Line the second\n";
+
+static void
+do_prepare (void)
+{
+  temp_fd = create_temp_file ("tst-mmap-eofsync.", &temp_file);
+  if (temp_fd == -1)
+    error (1, errno, "cannot create temporary file");
+  else
+    {
+      ssize_t cc = write (temp_fd, text1, sizeof text1 - 1);
+      if (cc != sizeof text1 - 1)
+	error (1, errno, "cannot write to temporary file");
+    }
+}
+
+static int
+do_test (void)
+{
+  FILE *f;
+  char buf[128];
+  int result = 0;
+  int c;
+
+  f = fopen (temp_file, "rm");
+  if (f == NULL)
+    {
+      perror (temp_file);
+      return 1;
+    }
+
+  if (fgets (buf, sizeof buf, f) == NULL)
+    {
+      perror ("fgets");
+      return 1;
+    }
+
+  if (strcmp (buf, text1))
+    {
+      printf ("read \"%s\", expected \"%s\"\n", buf, text1);
+      result = 1;
+    }
+
+  printf ("feof = %d, ferror = %d immediately after fgets\n",
+	  feof (f), ferror (f));
+
+#if 1
+  c = fgetc (f);
+  if (c == EOF)
+    printf ("fgetc -> EOF (feof = %d, ferror = %d)\n",
+	    feof (f), ferror (f));
+  else
+    {
+      printf ("fgetc returned %o (feof = %d, ferror = %d)\n",
+	      c, feof (f), ferror (f));
+      result = 1;
+    }
+#endif
+
+  c = write (temp_fd, text2, sizeof text2 - 1);
+  if (c == sizeof text2 - 1)
+    printf ("wrote more to file\n");
+  else
+    {
+      printf ("wrote %d != %zd (%m)\n", c, sizeof text2 - 1);
+      result = 1;
+    }
+
+  if (fgets (buf, sizeof buf, f) == NULL)
+    {
+      printf ("second fgets fails: feof = %d, ferror = %d (%m)\n",
+	      feof (f), ferror (f));
+      clearerr (f);
+      if (fgets (buf, sizeof buf, f) == NULL)
+	{
+	  printf ("retry fgets fails: feof = %d, ferror = %d (%m)\n",
+		  feof (f), ferror (f));
+	  result = 1;
+	}
+    }
+  if (result == 0 && strcmp (buf, text2))
+    {
+      printf ("second time read \"%s\", expected \"%s\"\n", buf, text2);
+      result = 1;
+    }
+
+  fclose (f);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/libio/tst-mmap-fflushsync.c
===================================================================
--- trunk/src/libctests/glibc/libio/tst-mmap-fflushsync.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst-mmap-fflushsync.c	(revision 2036)
@@ -0,0 +1,99 @@
+/* Test program for synchronization of stdio state with file after fflush.  */
+
+#include <stdio.h>
+#include <error.h>
+#include <errno.h>
+
+static void do_prepare (void);
+#define PREPARE(argc, argv) do_prepare ()
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#include <test-skeleton.c>
+
+static char *temp_file;
+static int temp_fd;
+
+static char text1[] = "Line the first\n";
+static char text2[] = "Line the second\n";
+
+static void
+do_prepare (void)
+{
+  temp_fd = create_temp_file ("tst-mmap-eofsync.", &temp_file);
+  if (temp_fd == -1)
+    error (1, errno, "cannot create temporary file");
+  else
+    {
+      ssize_t cc = write (temp_fd, text1, sizeof text1 - 1);
+      if (cc != sizeof text1 - 1)
+	error (1, errno, "cannot write to temporary file");
+    }
+}
+
+static int
+do_test (void)
+{
+  FILE *f;
+  char buf[128];
+  int result = 0;
+  int c;
+
+  f = fopen (temp_file, "rm");
+  if (f == NULL)
+    {
+      perror (temp_file);
+      return 1;
+    }
+
+  if (fgets (buf, sizeof buf, f) == NULL)
+    {
+      perror ("fgets");
+      return 1;
+    }
+
+  if (strcmp (buf, text1))
+    {
+      printf ("read \"%s\", expected \"%s\"\n", buf, text1);
+      result = 1;
+    }
+
+  printf ("feof = %d, ferror = %d immediately after fgets\n",
+	  feof (f), ferror (f));
+
+  if (fflush (f) != 0)
+    {
+      printf ("fflush failed! %m\n");
+      result = 1;
+    }
+
+  c = write (temp_fd, text2, sizeof text2 - 1);
+  if (c == sizeof text2 - 1)
+    printf ("wrote more to file\n");
+  else
+    {
+      printf ("wrote %d != %zd (%m)\n", c, sizeof text2 - 1);
+      result = 1;
+    }
+
+  if (fgets (buf, sizeof buf, f) == NULL)
+    {
+      printf ("second fgets fails: feof = %d, ferror = %d (%m)\n",
+	      feof (f), ferror (f));
+      clearerr (f);
+      if (fgets (buf, sizeof buf, f) == NULL)
+	{
+	  printf ("retry fgets fails: feof = %d, ferror = %d (%m)\n",
+		  feof (f), ferror (f));
+	  result = 1;
+	}
+    }
+  if (result == 0 && strcmp (buf, text2))
+    {
+      printf ("second time read \"%s\", expected \"%s\"\n", buf, text2);
+      result = 1;
+    }
+
+  fclose (f);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/libio/tst-mmap-offend.c
===================================================================
--- trunk/src/libctests/glibc/libio/tst-mmap-offend.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst-mmap-offend.c	(revision 2036)
@@ -0,0 +1,86 @@
+/* Test case for bug with mmap stdio read past end of file.  */
+
+#include <stdio.h>
+#include <error.h>
+#include <errno.h>
+
+static void do_prepare (void);
+#define PREPARE(argc, argv) do_prepare ()
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#include <test-skeleton.c>
+
+static char *temp_file;
+
+static const char text1[] = "hello\n";
+
+static void
+do_prepare (void)
+{
+  int temp_fd = create_temp_file ("tst-mmap-offend.", &temp_file);
+  if (temp_fd == -1)
+    error (1, errno, "cannot create temporary file");
+  else
+    {
+      ssize_t cc = write (temp_fd, text1, sizeof text1 - 1);
+      if (cc != sizeof text1 - 1)
+	error (1, errno, "cannot write to temporary file");
+    }
+  close (temp_fd);
+}
+
+static int
+do_test (void)
+{
+  unsigned char buffer[8192];
+  int result = 0;
+  FILE *f = fopen (temp_file, "rm");
+  size_t cc;
+
+  if (f == NULL)
+    {
+      perror (temp_file);
+      return 1;
+    }
+
+  cc = fread (buffer, 1, sizeof (buffer), f);
+  printf ("fread %zu: \"%.*s\"\n", cc, (int) cc, buffer);
+  if (cc != sizeof text1 - 1)
+    {
+      perror ("fread");
+      result = 1;
+    }
+
+  if (fseek (f, 2048, SEEK_SET) != 0)
+    {
+      perror ("fseek off end");
+      result = 1;
+    }
+
+  if (fread (buffer, 1, sizeof (buffer), f) != 0
+      || ferror (f) || !feof (f))
+    {
+      printf ("after fread error %d eof %d\n",
+	      ferror (f), feof (f));
+      result = 1;
+    }
+
+  printf ("ftell %ld\n", ftell (f));
+
+  if (fseek (f, 0, SEEK_SET) != 0)
+    {
+      perror ("fseek rewind");
+      result = 1;
+    }
+
+  cc = fread (buffer, 1, sizeof (buffer), f);
+  printf ("fread after rewind %zu: \"%.*s\"\n", cc, (int) cc, buffer);
+  if (cc != sizeof text1 - 1)
+    {
+      perror ("fread after rewind");
+      result = 1;
+    }
+
+  fclose (f);
+  return result;
+}
Index: trunk/src/libctests/glibc/libio/tst-mmap-setvbuf.c
===================================================================
--- trunk/src/libctests/glibc/libio/tst-mmap-setvbuf.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst-mmap-setvbuf.c	(revision 2036)
@@ -0,0 +1,82 @@
+/* Test setvbuf on readonly fopen (using mmap stdio).
+   Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+int main (void)
+{
+  char name[] = "/tmp/tst-mmap-setvbuf.XXXXXX";
+  char buf[4096];
+  const char * const test = "Let's see if mmap stdio works with setvbuf.\n";
+  char temp[strlen (test) + 1];
+  int fd = mkstemp (name);
+  FILE *f;
+
+  if (fd == -1)
+    {
+      printf ("%u: cannot open temporary file: %m\n", __LINE__);
+      exit (1);
+    }
+
+  f = fdopen (fd, "w");
+  if (f == NULL)
+    {
+      printf ("%u: cannot fdopen temporary file: %m\n", __LINE__);
+      exit (1);
+    }
+
+  fputs (test, f);
+  fclose (f);
+
+  f = fopen (name, "rm");
+  if (f == NULL)
+    {
+      printf ("%u: cannot fopen temporary file: %m\n", __LINE__);
+      exit (1);
+    }
+
+  if (setvbuf (f, buf, _IOFBF, sizeof buf))
+    {
+      printf ("%u: setvbuf failed: %m\n", __LINE__);
+      exit (1);
+    }
+
+  if (fread (temp, 1, strlen (test), f) != strlen (test))
+    {
+      printf ("%u: couldn't read the file back: %m\n", __LINE__);
+      exit (1);
+    }
+  temp [strlen (test)] = '\0';
+
+  if (strcmp (test, temp))
+    {
+      printf ("%u: read different string than was written:\n%s%s",
+	      __LINE__, test, temp);
+      exit (1);
+    }
+
+  fclose (f);
+
+  unlink (name);
+  exit (0);
+}
Index: trunk/src/libctests/glibc/libio/tst-mmap2-eofsync.c
===================================================================
--- trunk/src/libctests/glibc/libio/tst-mmap2-eofsync.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst-mmap2-eofsync.c	(revision 2036)
@@ -0,0 +1,137 @@
+/* Test program for synchronization of stdio state with file after EOF.  */
+
+#include <stdio.h>
+#include <error.h>
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+
+static void do_prepare (void);
+#define PREPARE(argc, argv) do_prepare ()
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#include <test-skeleton.c>
+
+static char *temp_file;
+static int temp_fd;
+
+static char *pages;
+
+static void
+do_prepare (void)
+{
+  pages = malloc (getpagesize () * 2);
+  memset (pages, 'a', getpagesize ());
+  memset (pages + getpagesize (), 'b', getpagesize ());
+
+  temp_fd = create_temp_file ("tst-mmap2-eofsync.", &temp_file);
+  if (temp_fd == -1)
+    error (1, errno, "cannot create temporary file");
+  else
+    {
+      ssize_t cc = write (temp_fd, pages, getpagesize ());
+      if (cc != getpagesize ())
+	error (1, errno, "cannot write to temporary file");
+    }
+}
+
+static int
+do_test (void)
+{
+  const size_t pagesize = getpagesize ();
+  FILE *f;
+  char buf[pagesize];
+  int result = 0;
+  int c;
+
+  f = fopen (temp_file, "rm");
+  if (f == NULL)
+    {
+      perror (temp_file);
+      return 1;
+    }
+
+  if (fread (buf, pagesize, 1, f) != 1)
+    {
+      perror ("fread");
+      return 1;
+    }
+
+  if (memcmp (buf, pages, pagesize))
+    {
+      puts ("data mismatch in page 1");
+      result = 1;
+    }
+
+  printf ("feof = %d, ferror = %d immediately after fread\n",
+	  feof (f), ferror (f));
+
+  c = fgetc (f);
+  if (c == EOF)
+    printf ("fgetc -> EOF (feof = %d, ferror = %d)\n",
+	    feof (f), ferror (f));
+  else
+    {
+      printf ("fgetc returned %o (feof = %d, ferror = %d)\n",
+	      c, feof (f), ferror (f));
+      result = 1;
+    }
+
+  c = write (temp_fd, pages + pagesize, pagesize);
+  if (c == (ssize_t) pagesize)
+    printf ("wrote more to file\n");
+  else
+    {
+      printf ("wrote %d != %zd (%m)\n", c, pagesize);
+      result = 1;
+    }
+
+  if (fread (buf, pagesize, 1, f) != 1)
+    {
+      printf ("second fread fails: feof = %d, ferror = %d (%m)\n",
+	      feof (f), ferror (f));
+      clearerr (f);
+      if (fread (buf, pagesize, 1, f) != 1)
+	{
+	  printf ("retry fread fails: feof = %d, ferror = %d (%m)\n",
+		  feof (f), ferror (f));
+	  result = 1;
+	}
+    }
+  if (result == 0 && memcmp (buf, pages + pagesize, pagesize))
+    {
+      puts ("data mismatch in page 2");
+      result = 1;
+    }
+
+  fseek (f, pagesize - 1, SEEK_SET);
+  c = fgetc (f);
+  if (c != 'a')
+    {
+      printf ("fgetc at end of page 1 read '%c' (%m)\n", c);
+      result = 1;
+    }
+
+  if (ftruncate (temp_fd, pagesize) < 0)
+    {
+      printf ("ftruncate failed: %m\n");
+      result = 1;
+    }
+
+  fflush (f);
+
+  c = fgetc (f);
+  if (c == EOF)
+    printf ("after truncate fgetc -> EOF (feof = %d, ferror = %d)\n",
+	    feof (f), ferror (f));
+  else
+    {
+      printf ("after truncate fgetc returned '%c' (feof = %d, ferror = %d)\n",
+	      c, feof (f), ferror (f));
+      result = 1;
+    }
+
+  fclose (f);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/libio/tst-sscanf.c
===================================================================
--- trunk/src/libctests/glibc/libio/tst-sscanf.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst-sscanf.c	(revision 2036)
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <wchar.h>
+
+#define WCS_LENGTH 256
+
+int
+main (void)
+{
+  const char cnv[] ="%l[abc]";
+  const char str[] = "abbcXab";
+  wchar_t wcs[WCS_LENGTH];
+  int result = 0;
+
+  sscanf (str, cnv, wcs);
+  printf ("wcs = \"%ls\"\n", wcs);
+  fflush (stdout);
+  result = wcscmp (wcs, L"abbc") != 0;
+
+  return result;
+}
Index: trunk/src/libctests/glibc/libio/tst-swscanf.c
===================================================================
--- trunk/src/libctests/glibc/libio/tst-swscanf.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst-swscanf.c	(revision 2036)
@@ -0,0 +1,101 @@
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+
+
+static int do_test (const char *loc);
+
+
+int
+main (void)
+{
+  int result;
+
+  result = do_test ("C");
+  result |= do_test ("de_DE.ISO-8859-1");
+  result |= do_test ("de_DE.UTF-8");
+  result |= do_test ("ja_JP.EUC-JP");
+
+  return result;
+}
+
+
+static const struct
+{
+  const wchar_t *fmt;
+  const wchar_t *wfmt;
+  const wchar_t *arg;
+  int retval;
+  const char *res;
+  const wchar_t *wres;
+  int only_C_locale;
+} tests[] =
+  {
+    { L"%[abc]", L"%l[abc]", L"aabbccddaabb", 1 ,"aabbcc", L"aabbcc", 0 },
+    { L"%[^def]", L"%l[^def]", L"aabbccddaabb", 1, "aabbcc", L"aabbcc", 0 },
+    { L"%[^abc]", L"%l[^abc]", L"aabbccddaabb", 0, "", L"", 0 },
+    { L"%[a-c]", L"%l[a-c]", L"aabbccddaabb", 1, "aabbcc", L"aabbcc", 1 },
+    { L"%[^d-f]", L"%l[^d-f]", L"aabbccddaabb", 1, "aabbcc", L"aabbcc", 1 },
+    { L"%[^a-c]", L"%l[^a-c]", L"aabbccddaabb", 0, "", L"", 1 },
+    { L"%[^a-c]", L"%l[^a-c]", L"bbccddaabb", 0, "", L"", 1 }
+  };
+
+
+static int
+do_test (const char *loc)
+{
+  size_t n;
+  int result = 0;
+
+  if (setlocale (LC_ALL, loc) == NULL)
+    {
+      printf ("cannot set locale \"%s\": %m\n", loc);
+      return 1;
+    }
+
+  printf ("\nnew locale: \"%s\"\n", loc);
+
+  for (n = 0; n < sizeof (tests) / sizeof (tests[0]); ++n)
+    {
+      char buf[100];
+      wchar_t wbuf[100];
+
+      if (tests[n].only_C_locale && strcmp (loc, "C") != 0)
+	continue;
+
+      if (swscanf (tests[n].arg, tests[n].fmt, buf) != tests[n].retval)
+	{
+	  printf ("swscanf (\"%S\", \"%S\", ...) failed\n",
+		  tests[n].arg, tests[n].fmt);
+	  result = 1;
+	}
+      else if (tests[n].retval != 0 && strcmp (buf, tests[n].res) != 0)
+	{
+	  printf ("swscanf (\"%S\", \"%S\", ...) return \"%s\", expected \"%s\"\n",
+		  tests[n].arg, tests[n].fmt, buf, tests[n].res);
+	  result = 1;
+	}
+      else
+	printf ("swscanf (\"%S\", \"%S\", ...) OK\n",
+		tests[n].arg, tests[n].fmt);
+
+      if (swscanf (tests[n].arg, tests[n].wfmt, wbuf) != tests[n].retval)
+	{
+	  printf ("swscanf (\"%S\", \"%S\", ...) failed\n",
+		  tests[n].arg, tests[n].wfmt);
+	  result = 1;
+	}
+      else if (tests[n].retval != 0 && wcscmp (wbuf, tests[n].wres) != 0)
+	{
+	  printf ("swscanf (\"%S\", \"%S\", ...) return \"%S\", expected \"%S\"\n",
+		  tests[n].arg, tests[n].wfmt, wbuf, tests[n].wres);
+	  result = 1;
+	}
+      else
+	printf ("swscanf (\"%S\", \"%S\", ...) OK\n",
+		tests[n].arg, tests[n].wfmt);
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/libio/tst-ungetwc1.c
===================================================================
--- trunk/src/libctests/glibc/libio/tst-ungetwc1.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst-ungetwc1.c	(revision 2036)
@@ -0,0 +1,81 @@
+/* Taken from the Li18nux base test suite.  */
+
+#define _XOPEN_SOURCE 500
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <wchar.h>
+
+int
+main (void)
+{
+  FILE *fp;
+  const char *str = "abcdef";
+  wint_t ret, wc, ungetone = 0x00E4;	/* 0x00E4 means `a umlaut'. */
+  char fname[] = "/tmp/tst-ungetwc1.out.XXXXXX";
+  int fd;
+  int result = 0;
+
+  puts ("This program runs on de_DE.UTF-8 locale.");
+  if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
+    {
+      fprintf (stderr, "Err: Cannot run on the de_DE.UTF-8 locale");
+      exit (EXIT_FAILURE);
+    }
+
+  fd = mkstemp (fname);
+  if (fd == -1)
+    {
+      printf ("cannot open temp file: %m\n");
+      exit (EXIT_FAILURE);
+    }
+
+  /* Write some characters to `testfile'. */
+  if ((fp = fdopen (fd, "w")) == NULL)
+    {
+      fprintf (stderr, "Cannot open 'testfile'.");
+      exit (EXIT_FAILURE);
+    }
+  fputs (str, fp);
+  fclose (fp);
+
+  /* Open `testfile'. */
+  if ((fp = fopen (fname, "r")) == NULL)
+    {
+      fprintf (stderr, "Cannot open 'testfile'.");
+      exit (EXIT_FAILURE);
+    }
+
+  /* Unget a character. */
+  ret = ungetwc (ungetone, fp);
+  printf ("Unget a character (0x%04x)\n", (unsigned int) ungetone);
+  fflush (stdout);
+  if (ret == WEOF)
+    {
+      puts ("ungetwc() returns NULL.");
+      exit (EXIT_SUCCESS);
+    }
+
+  /* Reget a character. */
+  wc = getwc (fp);
+  printf ("Reget a character (0x%04x)\n", (unsigned int) wc);
+  fflush (stdout);
+  if (wc == ungetone)
+    {
+      puts ("The ungotten character is equal to the regotten character.");
+      fflush (stdout);
+    }
+  else
+    {
+      puts ("The ungotten character is not equal to the regotten character.");
+      printf ("ungotten one: %04x, regetone: %04x", ungetone, wc);
+      fflush (stdout);
+      result = 1;
+    }
+  fclose (fp);
+
+  unlink (fname);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/libio/tst-ungetwc2.c
===================================================================
--- trunk/src/libctests/glibc/libio/tst-ungetwc2.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst-ungetwc2.c	(revision 2036)
@@ -0,0 +1,81 @@
+/* Taken from the Li18nux base test suite.  */
+
+#define _XOPEN_SOURCE 500
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <wchar.h>
+
+int
+main (void)
+{
+  FILE *fp;
+  const char *str = "abcdef";
+  wint_t ret, wc;
+  char fname[] = "/tmp/tst-ungetwc2.out.XXXXXX";
+  int fd;
+  long int pos;
+  int result = 0;
+
+  puts ("This program runs on de_DE.UTF-8 locale.");
+  if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
+    {
+      fprintf (stderr, "Err: Cannot run on the de_DE.UTF-8 locale\n");
+      exit (EXIT_FAILURE);
+    }
+
+  /* Write some characters to `testfile'. */
+  fd = mkstemp (fname);
+  if (fd == -1)
+    {
+      printf ("cannot open temp file: %m\n");
+      exit (EXIT_FAILURE);
+    }
+  if ((fp = fdopen (fd, "w")) == NULL)
+    {
+      fprintf (stderr, "Cannot open 'testfile'.\n");
+      exit (EXIT_FAILURE);
+    }
+  fputs (str, fp);
+  fclose (fp);
+
+  /* Open `testfile'. */
+  if ((fp = fopen (fname, "r")) == NULL)
+    {
+      fprintf (stderr, "Cannot open 'testfile'.");
+      exit (EXIT_FAILURE);
+    }
+
+  /* Get a character. */
+  wc = getwc (fp);
+  pos = ftell (fp);
+  printf ("After get a character: %ld\n", pos);
+  if (pos != 1)
+    result = 1;
+
+  /* Unget a character. */
+  ret = ungetwc (wc, fp);
+  if (ret == WEOF)
+    {
+      fprintf (stderr, "ungetwc() returns NULL.");
+      exit (EXIT_FAILURE);
+    }
+  pos = ftell (fp);
+  printf ("After unget a character: %ld\n", pos);
+  if (pos != 0)
+    result = 1;
+
+  /* Reget a character. */
+  wc = getwc (fp);
+  pos = ftell (fp);
+  printf ("After reget a character: %ld\n", pos);
+  if (pos != 1)
+    result = 1;
+
+  fclose (fp);
+
+  unlink (fname);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/libio/tst-widetext.c
===================================================================
--- trunk/src/libctests/glibc/libio/tst-widetext.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst-widetext.c	(revision 2036)
@@ -0,0 +1,370 @@
+/* Test program for the wide character stream functions handling larger
+   amounts of text.
+   Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <assert.h>
+#include <iconv.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <wchar.h>
+
+/* Approximate size of the file (must be larger).  */
+#define SIZE 210000
+
+
+int
+main (void)
+{
+  char name[] = "/tmp/widetext.out.XXXXXX";
+  char mbbuf[SIZE];
+  char mb2buf[SIZE];
+  wchar_t wcbuf[SIZE];
+  wchar_t wc2buf[SIZE];
+  size_t mbsize;
+  size_t wcsize;
+  int fd;
+  FILE *fp;
+  size_t n;
+  int res;
+  int status = 0;
+  wchar_t *wcp;
+
+  setlocale (LC_ALL, "de_DE.UTF-8");
+  printf ("locale used: %s\n\n", setlocale (LC_ALL, NULL));
+
+  /* Read the file into memory.  */
+  mbsize = fread (mbbuf, 1, SIZE, stdin);
+  if (mbsize == 0)
+    {
+      printf ("%u: cannot read input file from standard input: %m\n",
+	      __LINE__);
+      exit (1);
+    }
+
+   printf ("INFO: input file has %Zd bytes\n", mbsize);
+
+  /* First convert the text to wide characters.  We use iconv here.  */
+  {
+    iconv_t cd;
+    char *inbuf = mbbuf;
+    size_t inleft = mbsize;
+    char *outbuf = (char *) wcbuf;
+    size_t outleft = sizeof (wcbuf);
+    size_t nonr;
+
+    cd = iconv_open ("WCHAR_T", "UTF-8");
+    if (cd == (iconv_t) -1)
+      {
+	printf ("%u: cannot get iconv descriptor for conversion to UCS4\n",
+		__LINE__);
+	exit (1);
+      }
+
+    /* We must need only one call and there must be no losses.  */
+    nonr = iconv (cd, &inbuf, &inleft, &outbuf, &outleft);
+    if (nonr != 0 && nonr != (size_t) -1)
+      {
+	printf ("%u: iconv performed %Zd nonreversible conversions\n",
+		__LINE__, nonr);
+	exit (1);
+      }
+
+    if  (nonr == (size_t) -1)
+      {
+	printf ("\
+%u: iconv returned with %Zd and errno = %m (inleft: %Zd, outleft: %Zd)\n",
+		__LINE__, nonr, inleft, outleft);
+	exit (1);
+      }
+
+    if (inleft != 0)
+      {
+	printf ("%u: iconv didn't convert all input\n", __LINE__);
+	exit (1);
+      }
+
+    iconv_close (cd);
+
+    if ((sizeof (wcbuf) - outleft) % sizeof (wchar_t) != 0)
+      {
+	printf ("%u: iconv converted not complete wchar_t\n", __LINE__);
+	exit (1);
+      }
+
+    wcsize = (sizeof (wcbuf) - outleft) / sizeof (wchar_t);
+    assert (wcsize + 1 <= SIZE);
+  }
+
+  /* Now that we finished the preparations, run the first test.  We
+     are writing the wide char data out and read it back in.  We write
+     and read single characters.  */
+
+  fd = mkstemp (name);
+  if (fd == -1)
+    {
+      printf ("%u: cannot open temporary file: %m\n", __LINE__);
+      exit (1);
+    }
+
+  unlink (name);
+
+  fp = fdopen (dup (fd), "w");
+  if (fp == NULL)
+    {
+      printf ("%u: fdopen of temp file for writing failed: %m\n", __LINE__);
+      exit (1);
+    }
+
+  for (n = 0; n < wcsize; ++n)
+    {
+      if (fputwc (wcbuf[n], fp) == WEOF)
+	{
+	  printf ("%u: fputwc failed: %m\n", __LINE__);
+	  exit (1);
+	}
+    }
+
+  res = fclose (fp);
+  if (res != 0)
+    {
+      printf ("%u: fclose after single-character writing failed (%d): %m\n",
+	      __LINE__, res);
+      exit (1);
+    }
+
+  lseek (fd, SEEK_SET, 0);
+  fp = fdopen (dup (fd), "r");
+  if (fp == NULL)
+    {
+      printf ("%u: fdopen of temp file for reading failed: %m\n", __LINE__);
+      exit (1);
+    }
+
+  for (n = 0; n < wcsize; ++n)
+    {
+      wint_t wch = fgetwc (fp);
+      if (wch == WEOF)
+	{
+	  printf ("%u: fgetwc failed (idx %Zd): %m\n", __LINE__, n);
+	  exit (1);
+	}
+      wc2buf[n] = wch;
+    }
+
+  /* There should be nothing else.  */
+  if (fgetwc (fp) != WEOF)
+    {
+      printf ("%u: too many characters available with fgetwc\n", __LINE__);
+      status = 1;
+    }
+  else if (wmemcmp (wcbuf, wc2buf, wcsize) != 0)
+    {
+      printf ("%u: buffer read with fgetwc differs\n", __LINE__);
+      status = 1;
+    }
+
+  res = fclose (fp);
+  if (res != 0)
+    {
+      printf ("%u: fclose after single-character reading failed (%d): %m\n",
+	      __LINE__, res);
+      exit (1);
+    }
+
+  /* Just make sure there are no two errors which hide each other, read the
+     file using the `char' functions.  */
+
+  lseek (fd, SEEK_SET, 0);
+  fp = fdopen (fd, "r");
+  if (fp == NULL)
+    {
+      printf ("%u: fdopen of temp file for reading failed: %m\n", __LINE__);
+      exit (1);
+    }
+
+  if (fread (mb2buf, 1, mbsize, fp) != mbsize)
+    {
+      printf ("%u: cannot read all of the temp file\n", __LINE__);
+      status = 1;
+    }
+  else
+    {
+      /* Make sure there is nothing left.  */
+      if (fgetc (fp) != EOF)
+	{
+	  printf ("%u: more input available\n", __LINE__);
+	  status = 1;
+	}
+
+      if (memcmp (mb2buf, mbbuf, mbsize) != 0)
+	{
+	  printf ("%u: buffer written with fputwc differs\n", __LINE__);
+	  status = 1;
+	}
+    }
+
+  res = fclose (fp);
+  if (res != 0)
+    {
+      printf ("%u: fclose after single-character reading failed (%d): %m\n",
+	      __LINE__, res);
+      exit (1);
+    }
+
+  /* Now to reading and writing line-wise.  */
+
+  fd = mkstemp (strcpy (name, "/tmp/widetext.out.XXXXXX"));
+  if (fd == -1)
+    {
+      printf ("%u: cannot open temporary file: %m\n", __LINE__);
+      exit (1);
+    }
+
+  unlink (name);
+
+  fp = fdopen (dup (fd), "w");
+  if (fp == NULL)
+    {
+      printf ("%u: fdopen of temp file for writing failed: %m\n", __LINE__);
+      exit (1);
+    }
+
+  for (wcp = wcbuf; wcp < &wcbuf[wcsize]; )
+    {
+      wchar_t *wendp = wcschr (wcp, L'\n');
+
+      if (wendp != NULL)
+	{
+	  /* Temporarily NUL terminate the line.  */
+	  wchar_t save = wendp[1];
+	  wendp[1] = L'\0';
+
+	  fputws (wcp, fp);
+
+	  wendp[1] = save;
+	  wcp = &wendp[1];
+	}
+      else
+	{
+	  fputws (wcp, fp);
+	  wcp = wcschr (wcp, L'\0');
+	  assert (wcp == &wcbuf[wcsize]);
+	}
+    }
+
+  res = fclose (fp);
+  if (res != 0)
+    {
+      printf ("%u: fclose after line-wise writing failed (%d): %m\n",
+	      __LINE__, res);
+      exit (1);
+    }
+
+  lseek (fd, SEEK_SET, 0);
+  fp = fdopen (dup (fd), "r");
+  if (fp == NULL)
+    {
+      printf ("%u: fdopen of temp file for reading failed: %m\n", __LINE__);
+      exit (1);
+    }
+
+  for (wcp = wc2buf; wcp < &wc2buf[wcsize]; )
+    {
+      if (fgetws (wcp, &wc2buf[wcsize] - wcp + 1, fp) == NULL)
+	{
+	  printf ("%u: short read using fgetws (only %Zd of %Zd)\n",
+		  __LINE__, wcp - wc2buf, wcsize);
+	  status = 1;
+	  break;
+	}
+      wcp = wcschr (wcp, L'\0');
+    }
+
+  if (wcp > &wc2buf[wcsize])
+    {
+      printf ("%u: fgetws read too much\n", __LINE__);
+      status = 1;
+    }
+  else if (fgetwc (fp) != WEOF)
+    {
+      /* There should be nothing else.  */
+      printf ("%u: too many characters available with fgetws\n", __LINE__);
+      status = 1;
+    }
+
+  if (wcp >= &wc2buf[wcsize] && wmemcmp (wcbuf, wc2buf, wcsize) != 0)
+    {
+      printf ("%u: buffer read with fgetws differs\n", __LINE__);
+      status = 1;
+    }
+
+  res = fclose (fp);
+  if (res != 0)
+    {
+      printf ("%u: fclose after single-character reading failed (%d): %m\n",
+	      __LINE__, res);
+      exit (1);
+    }
+
+  /* Just make sure there are no two errors which hide each other, read the
+     file using the `char' functions.  */
+
+  lseek (fd, SEEK_SET, 0);
+  fp = fdopen (fd, "r");
+  if (fp == NULL)
+    {
+      printf ("%u: fdopen of temp file for reading failed: %m\n", __LINE__);
+      exit (1);
+    }
+
+  if (fread (mb2buf, 1, mbsize, fp) != mbsize)
+    {
+      printf ("%u: cannot read all of the temp file\n", __LINE__);
+      status = 1;
+    }
+  else
+    {
+      /* Make sure there is nothing left.  */
+      if (fgetc (fp) != EOF)
+	{
+	  printf ("%u: more input available\n", __LINE__);
+	  status = 1;
+	}
+
+      if (memcmp (mb2buf, mbbuf, mbsize) != 0)
+	{
+	  printf ("%u: buffer written with fputws differs\n", __LINE__);
+	  status = 1;
+	}
+    }
+
+  res = fclose (fp);
+  if (res != 0)
+    {
+      printf ("%u: fclose after single-character reading failed (%d): %m\n",
+	      __LINE__, res);
+      exit (1);
+    }
+
+  return status;
+}
Index: trunk/src/libctests/glibc/libio/tst-widetext.input
===================================================================
--- trunk/src/libctests/glibc/libio/tst-widetext.input	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst-widetext.input	(revision 2036)
@@ -0,0 +1,4014 @@
+
+Full BMP Test File
+------------------
+
+Markus Kuhn <mkuhn@acm.org> -- 2000-07-25
+
+This file contains the UTF-8 sequences of all code positions in the
+ISO 10646-1 Basic Multilingual Plane, except for the C0 and C1 control
+character areas. This corresponds to all codes in the range U+0020 -
+U+007E and U+00A0 - U+FFFF.
+
+NOTE: The ranges U+D800 - U+DFFF (surrogates) and U+FFFE - U+FFFF are
+not supposed to appear in valid UTF-8 files normally and UTF-8
+decoders are allowed to treat them like malformed sequences.
+
+
+Basic Latin (U+0000-U+007F):
+
+ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
+`abcdefghijklmnopqrstuvwxyz{|}~
+
+Latin-1 Supplement (U+0080-U+00FF):
+
+Â Â¡Â¢Â£Â€Â¥ÂŠÂ§ÂšÂ©ÂªÂ«Â¬Â­Â®Â¯Â°Â±Â²Â³ÂŽÂµÂ¶Â·ÂžÂ¹ÂºÂ»ÂŒÂœÂŸÂ¿ÃÃÃÃÃÃ
+ÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃ
+Ã Ã¡Ã¢Ã£Ã€Ã¥ÃŠÃ§ÃšÃ©ÃªÃ«Ã¬Ã­Ã®Ã¯Ã°Ã±Ã²Ã³ÃŽÃµÃ¶Ã·ÃžÃ¹ÃºÃ»ÃŒÃœÃŸÃ¿
+
+Latin Extended-A (U+0100-U+017F):
+
+ÄÄÄÄÄÄ
+ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Ä¡Ä¢Ä£Ä€Ä¥ÄŠÄ§ÄšÄ©ÄªÄ«Ä¬Ä­Ä®Ä¯Ä°Ä±Ä²Ä³ÄŽÄµÄ¶Ä·ÄžÄ¹ÄºÄ»ÄŒÄœÄŸÄ¿
+ÅÅÅÅÅÅ
+ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ Å¡Å¢Å£Å€Å¥ÅŠÅ§ÅšÅ©ÅªÅ«Å¬Å­Å®Å¯Å°Å±Å²Å³ÅŽÅµÅ¶Å·ÅžÅ¹ÅºÅ»ÅŒÅœÅŸÅ¿
+
+Latin Extended-B (U+0180-U+024F):
+
+ÆÆÆÆÆÆ
+ÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆ Æ¡Æ¢Æ£Æ€Æ¥ÆŠÆ§ÆšÆ©ÆªÆ«Æ¬Æ­Æ®Æ¯Æ°Æ±Æ²Æ³ÆŽÆµÆ¶Æ·ÆžÆ¹ÆºÆ»ÆŒÆœÆŸÆ¿
+ÇÇÇÇÇÇ
+ÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇ Ç¡Ç¢Ç£Ç€Ç¥ÇŠÇ§ÇšÇ©ÇªÇ«Ç¬Ç­Ç®Ç¯Ç°Ç±Ç²Ç³ÇŽÇµÇ¶Ç·ÇžÇ¹ÇºÇ»ÇŒÇœÇŸÇ¿
+ÈÈÈÈÈÈ
+ÈÈÈÈÈÈÈÈÈÈÈÈÈÈÈÈÈÈÈÈÈÈÈÈÈÈÈ È¡È¢È£È€È¥ÈŠÈ§ÈšÈ©ÈªÈ«È¬È­È®È¯È°È±È²È³ÈŽÈµÈ¶È·ÈžÈ¹ÈºÈ»ÈŒÈœÈŸÈ¿
+ÉÉÉÉÉÉ
+ÉÉÉÉÉÉÉÉÉÉ
+
+IPA Extensions (U+0250-U+02AF):
+
+ÉÉÉÉÉÉÉÉÉÉÉÉÉÉÉÉÉ É¡É¢É£É€É¥ÉŠÉ§ÉšÉ©ÉªÉ«É¬É­É®É¯É°É±É²É³ÉŽÉµÉ¶É·ÉžÉ¹ÉºÉ»ÉŒÉœÉŸÉ¿ÊÊÊÊÊÊ
+ÊÊÊÊÊÊÊÊÊÊ
+ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ Ê¡Ê¢Ê£Ê€Ê¥ÊŠÊ§ÊšÊ©ÊªÊ«Ê¬Ê­Ê®Ê¯
+
+Spacing Modifier Letters (U+02B0-U+02FF):
+
+Ê°Ê±Ê²Ê³ÊŽÊµÊ¶Ê·ÊžÊ¹ÊºÊ»ÊŒÊœÊŸÊ¿ËËËËËË
+ËËËËËËËËËËËËËËËËËËËËËËËËËËË Ë¡Ë¢Ë£Ë€Ë¥ËŠË§ËšË©ËªË«Ë¬Ë­Ë®Ë¯
+Ë°Ë±Ë²Ë³ËŽËµË¶Ë·ËžË¹ËºË»ËŒËœËŸË¿
+
+Combining Diacritical Marks (U+0300-U+036F):
+
+âÌâÌâÌâÌâÌâÌ
+âÌâÌâÌâÌâÌâÌâÌâÌâÌâÌâÌâÌâÌâÌâÌâÌâÌâÌâÌâÌâÌâÌâÌâÌâÌâÌâÌ âÌ¡âÌ¢âÌ£âÌ€âÌ¥âÌŠâÌ§âÌšâÌ©âÌªâÌ«âÌ¬âÌ­âÌ®âÌ¯âÌ°âÌ±âÌ²âÌ³âÌŽâÌµâÌ¶âÌ·âÌžâÌ¹âÌºâÌ»âÌŒâÌœâÌŸâÌ¿
+âÍâÍâÍâÍâÍâÍ
+âÍâÍâÍâÍâÍâÍâÍâÍâÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍâÍ âÍ¡âÍ¢Í£Í€Í¥ÍŠÍ§ÍšÍ©ÍªÍ«Í¬Í­Í®Í¯
+
+Greek (U+0370-U+03FF):
+
+Í°Í±Í²Í³ÍŽÍµÍ¶Í·ÍžÍ¹ÍºÍ»ÍŒÍœÍŸÍ¿ÎÎÎÎÎÎ
+ÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎÎ Î¡Î¢Î£Î€Î¥ÎŠÎ§ÎšÎ©ÎªÎ«Î¬Î­Î®Î¯
+Î°Î±Î²Î³ÎŽÎµÎ¶Î·ÎžÎ¹ÎºÎ»ÎŒÎœÎŸÎ¿ÏÏÏÏÏÏ
+ÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏ Ï¡Ï¢Ï£Ï€Ï¥ÏŠÏ§ÏšÏ©ÏªÏ«Ï¬Ï­Ï®Ï¯
+Ï°Ï±Ï²Ï³ÏŽÏµÏ¶Ï·ÏžÏ¹ÏºÏ»ÏŒÏœÏŸÏ¿
+
+Cyrillic (U+0400-U+04FF):
+
+ÐÐÐÐÐÐ
+ÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐ Ð¡Ð¢Ð£Ð€Ð¥ÐŠÐ§ÐšÐ©ÐªÐ«Ð¬Ð­Ð®Ð¯Ð°Ð±Ð²Ð³ÐŽÐµÐ¶Ð·ÐžÐ¹ÐºÐ»ÐŒÐœÐŸÐ¿
+ÑÑÑÑÑÑ
+ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ Ñ¡Ñ¢Ñ£Ñ€Ñ¥ÑŠÑ§ÑšÑ©ÑªÑ«Ñ¬Ñ­Ñ®Ñ¯Ñ°Ñ±Ñ²Ñ³ÑŽÑµÑ¶Ñ·ÑžÑ¹ÑºÑ»ÑŒÑœÑŸÑ¿
+ÒÒÒâÒâÒâÒ
+âÒÒ Ò ÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒ Ò¡Ò¢Ò£Ò€Ò¥ÒŠÒ§ÒšÒ©ÒªÒ«Ò¬Ò­Ò®Ò¯Ò°Ò±Ò²Ò³ÒŽÒµÒ¶Ò·ÒžÒ¹ÒºÒ»ÒŒÒœÒŸÒ¿
+ÓÓÓÓÓÓ
+ÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓ Ó¡Ó¢Ó£Ó€Ó¥ÓŠÓ§ÓšÓ©ÓªÓ«Ó¬Ó­Ó®Ó¯Ó°Ó±Ó²Ó³ÓŽÓµÓ¶Ó·ÓžÓ¹ÓºÓ»ÓŒÓœÓŸÓ¿
+
+Free block (U+0500-U+052F):
+
+ÔÔÔÔÔÔ
+ÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔ Ô¡Ô¢Ô£Ô€Ô¥ÔŠÔ§ÔšÔ©ÔªÔ«Ô¬Ô­Ô®Ô¯
+
+Armenian (U+0530-U+058F):
+
+Ô°Ô±Ô²Ô³ÔŽÔµÔ¶Ô·ÔžÔ¹ÔºÔ»ÔŒÔœÔŸÔ¿ÕÕÕÕÕÕ
+ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕ Õ¡Õ¢Õ£Õ€Õ¥ÕŠÕ§ÕšÕ©ÕªÕ«Õ¬Õ­Õ®Õ¯
+Õ°Õ±Õ²Õ³ÕŽÕµÕ¶Õ·ÕžÕ¹ÕºÕ»ÕŒÕœÕŸÕ¿ÖÖÖÖÖÖ
+ÖÖÖÖÖÖÖÖÖÖ
+
+Hebrew (U+0590-U+05FF):
+
+ÖâÖâÖâÖâÖâÖâÖâÖâÖâÖâÖâÖâÖâÖâÖâÖâÖ âÖ¡Ö¢âÖ£âÖ€âÖ¥âÖŠâÖ§âÖšâÖ©âÖªâÖ«âÖ¬âÖ­âÖ®âÖ¯âÖ°âÖ±âÖ²âÖ³âÖŽâÖµâÖ¶âÖ·âÖžâÖ¹ÖºâÖ»âÖŒâÖœÖŸâÖ¿×â×â××â××
+××××××××××
+××××××××××××××××× ×¡×¢×£×€×¥×Š×§×š×©×ª×«×¬×­×®×¯×°×±×²×³×Ž×µ×¶×·×ž×¹×º×»×Œ×œ×Ÿ×¿
+
+Arabic (U+0600-U+06FF):
+
+ØØØØØØ
+ØØØØØØØØØØØØØØØØØØØØØØØØØØØ Ø¡Ø¢Ø£Ø€Ø¥ØŠØ§ØšØ©ØªØ«Ø¬Ø­Ø®Ø¯Ø°Ø±Ø²Ø³ØŽØµØ¶Ø·ØžØ¹ØºØ»ØŒØœØŸØ¿
+ÙÙÙÙÙÙ
+ÙÙÙÙÙâÙâÙâÙâÙâÙâÙâÙâÙâÙâÙâÙÙÙÙÙÙÙÙÙÙÙÙ Ù¡Ù¢Ù£Ù€Ù¥ÙŠÙ§ÙšÙ©ÙªÙ«Ù¬Ù­Ù®Ù¯âÙ°Ù±Ù²Ù³ÙŽÙµÙ¶Ù·ÙžÙ¹ÙºÙ»ÙŒÙœÙŸÙ¿
+ÚÚÚÚÚÚ
+ÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚ Ú¡Ú¢Ú£Ú€Ú¥ÚŠÚ§ÚšÚ©ÚªÚ«Ú¬Ú­Ú®Ú¯Ú°Ú±Ú²Ú³ÚŽÚµÚ¶Ú·ÚžÚ¹ÚºÚ»ÚŒÚœÚŸÚ¿
+ÛÛÛÛÛÛ
+ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛâÛâÛâÛâÛâÛâÛâÛ Û ÛâÛâÛ âÛ¡âÛ¢âÛ£âÛ€Û¥ÛŠâÛ§âÛšÛ©âÛªâÛ«âÛ¬âÛ­Û®Û¯Û°Û±Û²Û³ÛŽÛµÛ¶Û·ÛžÛ¹ÛºÛ»ÛŒÛœÛŸÛ¿
+
+Syriac   (U+0700-U+074F):
+
+ÜÜÜÜÜÜ
+ÜÜÜÜÜÜÜÜÜÜÜâÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ Ü¡Ü¢Ü£Ü€Ü¥ÜŠÜ§ÜšÜ©ÜªÜ«Ü¬Ü­Ü®Ü¯âÜ°âÜ±âÜ²âÜ³âÜŽâÜµâÜ¶âÜ·âÜžâÜ¹âÜºâÜ»âÜŒâÜœâÜŸâÜ¿
+âÝâÝâÝâÝâÝâÝ
+âÝâÝâÝâÝâÝÝÝÝÝÝ
+
+Free block (U+0750-U+077F):
+
+ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ Ý¡Ý¢Ý£Ý€Ý¥ÝŠÝ§ÝšÝ©ÝªÝ«Ý¬Ý­Ý®Ý¯Ý°Ý±Ý²Ý³ÝŽÝµÝ¶Ý·ÝžÝ¹ÝºÝ»ÝŒÝœÝŸÝ¿
+
+Thaana (U+0780-U+07BF):
+
+ÞÞÞÞÞÞ
+ÞÞÞÞÞÞÞÞÞÞÞÞÞÞÞÞÞÞÞÞÞÞÞÞÞÞÞ Þ¡Þ¢Þ£Þ€Þ¥âÞŠâÞ§âÞšâÞ©âÞªâÞ«âÞ¬âÞ­âÞ®âÞ¯âÞ°Þ±Þ²Þ³ÞŽÞµÞ¶Þ·ÞžÞ¹ÞºÞ»ÞŒÞœÞŸÞ¿
+
+Free block (U+07C0-U+08FF):
+
+ßßßßßß
+ßßßßßßßßßßßßßßßßßßßßßßßßßßß ß¡ß¢ß£ß€ß¥ßŠß§ßšß©ßªß«ß¬ß­ß®ß¯ß°ß±ß²ß³ßŽßµß¶ß·ßžß¹ßºß»ßŒßœßŸß¿
+à à à à à à 
+à à à à à à à à à à à à à à à à à à à à à à à à à à à  à ¡à ¢à £à €à ¥à Šà §à šà ©à ªà «à ¬à ­à ®à ¯à °à ±à ²à ³à Žà µà ¶à ·à žà ¹à ºà »à Œà œà Ÿà ¿
+à¡à¡à¡à¡à¡à¡
+à¡à¡à¡à¡à¡à¡à¡à¡à¡à¡à¡à¡à¡à¡à¡à¡à¡à¡à¡à¡à¡à¡à¡à¡à¡à¡à¡ à¡¡à¡¢à¡£à¡€à¡¥à¡Šà¡§à¡šà¡©à¡ªà¡«à¡¬à¡­à¡®à¡¯à¡°à¡±à¡²à¡³à¡Žà¡µà¡¶à¡·à¡žà¡¹à¡ºà¡»à¡Œà¡œà¡Ÿà¡¿
+à¢à¢à¢à¢à¢à¢
+à¢à¢à¢à¢à¢à¢à¢à¢à¢à¢à¢à¢à¢à¢à¢à¢à¢à¢à¢à¢à¢à¢à¢à¢à¢à¢à¢ à¢¡à¢¢à¢£à¢€à¢¥à¢Šà¢§à¢šà¢©à¢ªà¢«à¢¬à¢­à¢®à¢¯à¢°à¢±à¢²à¢³à¢Žà¢µà¢¶à¢·à¢žà¢¹à¢ºà¢»à¢Œà¢œà¢Ÿà¢¿
+à£à£à£à£à£à£
+à£à£à£à£à£à£à£à£à£à£à£à£à£à£à£à£à£à£à£à£à£à£à£à£à£à£à£ à£¡à£¢à££à£€à£¥à£Šà£§à£šà£©à£ªà£«à£¬à£­à£®à£¯à£°à£±à£²à£³à£Žà£µà£¶à£·à£žà£¹à£ºà£»à£Œà£œà£Ÿà£¿
+
+Devanagari (U+0900-U+097F):
+
+à€âà€âà€à€à€à€
+à€à€à€à€à€à€à€à€à€à€à€à€à€à€à€à€à€à€à€à€à€à€à€à€à€à€à€ à€¡à€¢à€£à€€à€¥à€Šà€§à€šà€©à€ªà€«à€¬à€­à€®à€¯à€°à€±à€²à€³à€Žà€µà€¶à€·à€žà€¹à€ºà€»âà€Œà€œà€Ÿà€¿
+à¥âà¥âà¥âà¥âà¥âà¥
+âà¥âà¥âà¥à¥à¥à¥à¥âà¥à¥à¥à¥âà¥âà¥âà¥âà¥à¥à¥à¥à¥à¥à¥à¥à¥à¥à¥à¥à¥ à¥¡âà¥¢âà¥£à¥€à¥¥à¥Šà¥§à¥šà¥©à¥ªà¥«à¥¬à¥­à¥®à¥¯à¥°à¥±à¥²à¥³à¥Žà¥µà¥¶à¥·à¥žà¥¹à¥ºà¥»à¥Œà¥œà¥Ÿà¥¿
+
+Bengali (U+0980-U+09FF):
+
+àŠâàŠàŠàŠàŠàŠ
+àŠàŠàŠàŠàŠàŠàŠàŠàŠàŠàŠàŠàŠàŠàŠàŠàŠàŠàŠàŠàŠàŠàŠàŠàŠàŠàŠ àŠ¡àŠ¢àŠ£àŠ€àŠ¥àŠŠàŠ§àŠšàŠ©àŠªàŠ«àŠ¬àŠ­àŠ®àŠ¯àŠ°àŠ±àŠ²àŠ³àŠŽàŠµàŠ¶àŠ·àŠžàŠ¹àŠºàŠ»âàŠŒàŠœàŠŸàŠ¿
+à§âà§âà§âà§âà§à§
+à§à§à§à§à§à§à§âà§à§à§à§à§à§à§à§à§à§à§à§à§à§à§à§à§à§à§à§ à§¡âà§¢âà§£à§€à§¥à§Šà§§à§šà§©à§ªà§«à§¬à§­à§®à§¯à§°à§±à§²à§³à§Žà§µà§¶à§·à§žà§¹à§ºà§»à§Œà§œà§Ÿà§¿
+
+Gurmukhi (U+0A00-U+0A7F):
+
+àšàšâàšàšàšàš
+àšàšàšàšàšàšàšàšàšàšàšàšàšàšàšàšàšàšàšàšàšàšàšàšàšàšàš àš¡àš¢àš£àš€àš¥àšŠàš§àššàš©àšªàš«àš¬àš­àš®àš¯àš°àš±àš²àš³àšŽàšµàš¶àš·àšžàš¹àšºàš»âàšŒàšœàšŸàš¿
+à©âà©âà©à©à©à©
+à©âà©âà©à©à©âà©âà©âà©à©à©à©à©à©à©à©à©à©à©à©à©à©à©à©à©à©à©à© à©¡à©¢à©£à©€à©¥à©Šà©§à©šà©©à©ªà©«à©¬à©­à©®à©¯âà©°âà©±à©²à©³à©Žà©µà©¶à©·à©žà©¹à©ºà©»à©Œà©œà©Ÿà©¿
+
+Gujarati (U+0A80-U+0AFF):
+
+àªâàªâàªàªàªàª
+àªàªàªàªàªàªàªàªàªàªàªàªàªàªàªàªàªàªàªàªàªàªàªàªàªàªàª àª¡àª¢àª£àª€àª¥àªŠàª§àªšàª©àªªàª«àª¬àª­àª®àª¯àª°àª±àª²àª³àªŽàªµàª¶àª·àªžàª¹àªºàª»âàªŒàªœàªŸàª¿
+à«âà«âà«âà«âà«âà«
+à«âà«âà«à«à«à«à«âà«à«à«à«à«à«à«à«à«à«à«à«à«à«à«à«à«à«à«à« à«¡à«¢à«£à«€à«¥à«Šà«§à«šà«©à«ªà««à«¬à«­à«®à«¯à«°à«±à«²à«³à«Žà«µà«¶à«·à«žà«¹à«ºà«»à«Œà«œà«Ÿà«¿
+
+Oriya (U+0B00-U+0B7F):
+
+à¬âà¬à¬à¬à¬à¬
+à¬à¬à¬à¬à¬à¬à¬à¬à¬à¬à¬à¬à¬à¬à¬à¬à¬à¬à¬à¬à¬à¬à¬à¬à¬à¬à¬ à¬¡à¬¢à¬£à¬€à¬¥à¬Šà¬§à¬šà¬©à¬ªà¬«à¬¬à¬­à¬®à¬¯à¬°à¬±à¬²à¬³à¬Žà¬µà¬¶à¬·à¬žà¬¹à¬ºà¬»âà¬Œà¬œà¬Ÿâà¬¿
+à­âà­âà­âà­à­à­
+à­à­à­à­à­à­à­âà­à­à­à­à­à­à­à­à­âà­à­à­à­à­à­à­à­à­à­à­ à­¡à­¢à­£à­€à­¥à­Šà­§à­šà­©à­ªà­«à­¬à­­à­®à­¯à­°à­±à­²à­³à­Žà­µà­¶à­·à­žà­¹à­ºà­»à­Œà­œà­Ÿà­¿
+
+Tamil (U+0B80-U+0BFF):
+
+à®à®âà®à®à®à®
+à®à®à®à®à®à®à®à®à®à®à®à®à®à®à®à®à®à®à®à®à®à®à®à®à®à®à® à®¡à®¢à®£à®€à®¥à®Šà®§à®šà®©à®ªà®«à®¬à®­à®®à®¯à®°à®±à®²à®³à®Žà®µà®¶à®·à®žà®¹à®ºà®»à®Œà®œà®Ÿà®¿
+âà¯à¯à¯à¯à¯à¯
+à¯à¯à¯à¯à¯à¯à¯âà¯à¯à¯à¯à¯à¯à¯à¯à¯à¯à¯à¯à¯à¯à¯à¯à¯à¯à¯à¯ à¯¡à¯¢à¯£à¯€à¯¥à¯Šà¯§à¯šà¯©à¯ªà¯«à¯¬à¯­à¯®à¯¯à¯°à¯±à¯²à¯³à¯Žà¯µà¯¶à¯·à¯žà¯¹à¯ºà¯»à¯Œà¯œà¯Ÿà¯¿
+
+Telugu (U+0C00-U+0C7F):
+
+à°à°à°à°à°à°
+à°à°à°à°à°à°à°à°à°à°à°à°à°à°à°à°à°à°à°à°à°à°à°à°à°à°à° à°¡à°¢à°£à°€à°¥à°Šà°§à°šà°©à°ªà°«à°¬à°­à°®à°¯à°°à°±à°²à°³à°Žà°µà°¶à°·à°žà°¹à°ºà°»à°Œà°œâà°Ÿâà°¿
+âà±à±à±à±à±à±
+âà±âà±âà±à±âà±âà±âà±âà±à±à±à±à±à±à±à±âà±âà±à±à±à±à±à±à±à±à±à±à± à±¡à±¢à±£à±€à±¥à±Šà±§à±šà±©à±ªà±«à±¬à±­à±®à±¯à±°à±±à±²à±³à±Žà±µà±¶à±·à±žà±¹à±ºà±»à±Œà±œà±Ÿà±¿
+
+Kannada (U+0C80-U+0CFF):
+
+à²à²à²à²à²à²
+à²à²à²à²à²à²à²à²à²à²à²à²à²à²à²à²à²à²à²à²à²à²à²à²à²à²à² à²¡à²¢à²£à²€à²¥à²Šà²§à²šà²©à²ªà²«à²¬à²­à²®à²¯à²°à²±à²²à²³à²Žà²µà²¶à²·à²žà²¹à²ºà²»à²Œà²œà²Ÿâà²¿
+à³à³à³à³à³à³
+âà³à³à³à³à³à³âà³âà³à³à³à³à³à³à³à³à³à³à³à³à³à³à³à³à³à³à³à³ à³¡à³¢à³£à³€à³¥à³Šà³§à³šà³©à³ªà³«à³¬à³­à³®à³¯à³°à³±à³²à³³à³Žà³µà³¶à³·à³žà³¹à³ºà³»à³Œà³œà³Ÿà³¿
+
+Malayalam (U+0D00-U+0D7F):
+
+àŽàŽàŽàŽàŽàŽ
+àŽàŽàŽàŽàŽàŽàŽàŽàŽàŽàŽàŽàŽàŽàŽàŽàŽàŽàŽàŽàŽàŽàŽàŽàŽàŽàŽ àŽ¡àŽ¢àŽ£àŽ€àŽ¥àŽŠàŽ§àŽšàŽ©àŽªàŽ«àŽ¬àŽ­àŽ®àŽ¯àŽ°àŽ±àŽ²àŽ³àŽŽàŽµàŽ¶àŽ·àŽžàŽ¹àŽºàŽ»àŽŒàŽœàŽŸàŽ¿
+àµâàµâàµâàµàµàµ
+àµàµàµàµàµàµàµâàµàµàµàµàµàµàµàµàµàµàµàµàµàµàµàµàµàµàµàµ àµ¡àµ¢àµ£àµ€àµ¥àµŠàµ§àµšàµ©àµªàµ«àµ¬àµ­àµ®àµ¯àµ°àµ±àµ²àµ³àµŽàµµàµ¶àµ·àµžàµ¹àµºàµ»àµŒàµœàµŸàµ¿
+
+Sinhala (U+0D80-U+0DFF):
+
+à¶à¶à¶à¶à¶à¶
+à¶à¶à¶à¶à¶à¶à¶à¶à¶à¶à¶à¶à¶à¶à¶à¶à¶à¶à¶à¶à¶à¶à¶à¶à¶à¶à¶ à¶¡à¶¢à¶£à¶€à¶¥à¶Šà¶§à¶šà¶©à¶ªà¶«à¶¬à¶­à¶®à¶¯à¶°à¶±à¶²à¶³à¶Žà¶µà¶¶à¶·à¶žà¶¹à¶ºà¶»à¶Œà¶œà¶Ÿà¶¿
+à·à·à·à·à·à·
+à·à·à·à·âà·à·à·à·à·à·à·à·âà·âà·âà·à·âà·à·à·à·à·à·à·à·à·à·à· à·¡à·¢à·£à·€à·¥à·Šà·§à·šà·©à·ªà·«à·¬à·­à·®à·¯à·°à·±à·²à·³à·Žà·µà·¶à··à·žà·¹à·ºà·»à·Œà·œà·Ÿà·¿
+
+Thai (U+0E00-U+0E7F):
+
+àžàžàžàžàžàž
+àžàžàžàžàžàžàžàžàžàžàžàžàžàžàžàžàžàžàžàžàžàžàžàžàžàžàž àž¡àž¢àž£àž€àž¥àžŠàž§àžšàž©àžªàž«àž¬àž­àž®àž¯àž°âàž±àž²àž³âàžŽâàžµâàž¶âàž·âàžžâàž¹âàžºàž»àžŒàžœàžŸàž¿
+à¹à¹à¹à¹à¹à¹
+à¹âà¹âà¹âà¹âà¹âà¹âà¹âà¹âà¹à¹à¹à¹à¹à¹à¹à¹à¹à¹à¹à¹à¹à¹à¹à¹à¹à¹à¹ à¹¡à¹¢à¹£à¹€à¹¥à¹Šà¹§à¹šà¹©à¹ªà¹«à¹¬à¹­à¹®à¹¯à¹°à¹±à¹²à¹³à¹Žà¹µà¹¶à¹·à¹žà¹¹à¹ºà¹»à¹Œà¹œà¹Ÿà¹¿
+
+Lao (U+0E80-U+0EFF):
+
+àºàºàºàºàºàº
+àºàºàºàºàºàºàºàºàºàºàºàºàºàºàºàºàºàºàºàºàºàºàºàºàºàºàº àº¡àº¢àº£àº€àº¥àºŠàº§àºšàº©àºªàº«àº¬àº­àº®àº¯àº°âàº±àº²àº³âàºŽâàºµâàº¶âàº·âàºžâàº¹àººâàº»âàºŒàºœàºŸàº¿
+à»à»à»à»à»à»
+à»à»âà»âà»âà»âà»âà»âà»à»à»à»à»à»à»à»à»à»à»à»à»à»à»à»à»à»à»à» à»¡à»¢à»£à»€à»¥à»Šà»§à»šà»©à»ªà»«à»¬à»­à»®à»¯à»°à»±à»²à»³à»Žà»µà»¶à»·à»žà»¹à»ºà»»à»Œà»œà»Ÿà»¿
+
+Tibetan (U+0F00-U+0FFF):
+
+àŒàŒàŒàŒàŒàŒ
+àŒàŒàŒàŒàŒàŒàŒàŒàŒàŒàŒàŒàŒàŒàŒàŒàŒàŒâàŒâàŒàŒàŒàŒàŒàŒàŒàŒ àŒ¡àŒ¢àŒ£àŒ€àŒ¥àŒŠàŒ§àŒšàŒ©àŒªàŒ«àŒ¬àŒ­àŒ®àŒ¯àŒ°àŒ±àŒ²àŒ³àŒŽâàŒµàŒ¶âàŒ·àŒžâàŒ¹àŒºàŒ»àŒŒàŒœàŒŸàŒ¿
+àœàœàœàœàœàœ
+àœàœàœàœàœàœàœàœàœàœàœàœàœàœàœàœàœàœàœàœàœàœàœàœàœàœàœ àœ¡àœ¢àœ£àœ€àœ¥àœŠàœ§àœšàœ©àœªàœ«àœ¬àœ­àœ®àœ¯àœ°âàœ±âàœ²âàœ³âàœŽâàœµâàœ¶âàœ·âàœžâàœ¹âàœºâàœ»âàœŒâàœœâàœŸàœ¿
+âàŸâàŸâàŸâàŸâàŸàŸ
+âàŸâàŸàŸàŸàŸàŸàŸàŸàŸàŸâàŸâàŸâàŸâàŸâàŸâàŸâàŸâàŸàŸâàŸâàŸâàŸâàŸâàŸâàŸâàŸâàŸ âàŸ¡âàŸ¢âàŸ£âàŸ€âàŸ¥âàŸŠâàŸ§âàŸšâàŸ©âàŸªâàŸ«âàŸ¬âàŸ­âàŸ®âàŸ¯âàŸ°âàŸ±âàŸ²âàŸ³âàŸŽâàŸµâàŸ¶âàŸ·âàŸžâàŸ¹âàŸºâàŸ»âàŸŒàŸœàŸŸàŸ¿
+à¿à¿à¿à¿à¿à¿
+âà¿à¿à¿à¿à¿à¿à¿à¿à¿à¿à¿à¿à¿à¿à¿à¿à¿à¿à¿à¿à¿à¿à¿à¿à¿à¿à¿ à¿¡à¿¢à¿£à¿€à¿¥à¿Šà¿§à¿šà¿©à¿ªà¿«à¿¬à¿­à¿®à¿¯à¿°à¿±à¿²à¿³à¿Žà¿µà¿¶à¿·à¿žà¿¹à¿ºà¿»à¿Œà¿œà¿Ÿà¿¿
+
+Myanmar  (U+1000-U+109F):
+
+áááááá
+ááááááááááááááááááááááááááá á¡á¢á£á€á¥áŠá§ášá©áªá«á¬âá­âá®âá¯âá°á±âá²á³áŽáµâá¶âá·ážâá¹áºá»áŒáœáŸá¿
+áááááá
+ááááááááááááááááááâáâáááááááá á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿
+áááááá
+áááááááááááááááááááááááááá
+
+Georgian (U+10A0-U+10FF):
+
+á á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿áááááá
+áááááááááááááááááááááááááá
+á á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿
+
+Hangul Jamo (U+1100-U+11FF):
+
+áááááá
+áááááááááááááááááááááááááá
+á á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿
+á
+á
+á
+á
+á
+á
+
+á
+á
+á
+á
+á
+á
+á
+á
+á
+á
+á
+á
+á
+á
+á
+á
+á
+á
+á
+á
+á
+á
+á
+á
+á
+á
+
+á
+ á
+¡á
+¢á
+£á
+€á
+¥á
+Šá
+§á
+šá
+©á
+ªá
+«á
+¬á
+­á
+®á
+¯á
+°á
+±á
+²á
+³á
+Žá
+µá
+¶á
+·á
+žá
+¹á
+ºá
+»á
+Œá
+œá
+Ÿá
+¿áááááá
+áááááááááááááááááááááááááá
+á á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿áááááá
+áááááááááááááááááááááááááá
+á á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿
+
+Ethiopic (U+1200-U+137F):
+
+áááááá
+ááááááááááááááááááááááááááá á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿
+áááááá
+ááááááááááááááááááááááááááá á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿
+áááááá
+ááááááááááááááááááááááááááá á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿
+áááááá
+ááááááááááááááááááááááááááá á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿
+áááááá
+ááááááááááááááááááááááááááá á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿
+áááááá
+ááááááááááááááááááááááááááá á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿
+
+Free block (U+1380-U+139F):
+
+áááááá
+áááááááááááááááááááááááááá
+
+Cherokee (U+13A0-U+13FF):
+
+á á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿áááááá
+áááááááááááááááááááááááááá
+á á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿
+
+Unified Canadian Aboriginal Syllabics (U+1400-U+167F):
+
+áááááá
+ááááááááááááááááááááááááááá á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿
+áááááá
+ááááááááááááááááááááááááááá á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿
+áááááá
+ááááááááááááááááááááááááááá á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿
+áááááá
+ááááááááááááááááááááááááááá á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿
+áááááá
+ááááááááááááááááááááááááááá á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿
+áááááá
+ááááááááááááááááááááááááááá á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿
+áááááá
+ááááááááááááááááááááááááááá á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿
+áááááá
+ááááááááááááááááááááááááááá á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿
+áááááá
+ááááááááááááááááááááááááááá á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿
+áááááá
+ááááááááááááááááááááááááááá á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿
+
+Ogham (U+1680-U+169F):
+
+áááááá
+áááááááááááááááááááááááááá
+
+Runic (U+16A0-U+16FF):
+
+á á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿áááááá
+áááááááááááááááááááááááááá
+á á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿
+
+Free block (U+1700-U+177F):
+
+áááááá
+ááááááááááááááááááááááááááá á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿
+áááááá
+ááááááááááááááááááááááááááá á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿
+
+Khmer (U+1780-U+17FF):
+
+áááááá
+ááááááááááááááááááááááááááá á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶âá·âážâá¹âáºâá»âáŒâáœáŸá¿
+áááááá
+âáááâáâáâáâáâáâáâáâáâáâáâáááááááááááááá á¡á¢á£á€á¥áŠá§ášá©áªá«á¬á­á®á¯á°á±á²á³áŽáµá¶á·ážá¹áºá»áŒáœáŸá¿
+
+Mongolian (U+1800-U+18AF):
+
+á á á á á á 
+á á á á á á á á á á á á á á á á á á á á á á á á á á á  á ¡á ¢á £á €á ¥á Šá §á šá ©á ªá «á ¬á ­á ®á ¯á °á ±á ²á ³á Žá µá ¶á ·á žá ¹á ºá »á Œá œá Ÿá ¿
+á¡á¡á¡á¡á¡á¡
+á¡á¡á¡á¡á¡á¡á¡á¡á¡á¡á¡á¡á¡á¡á¡á¡á¡á¡á¡á¡á¡á¡á¡á¡á¡á¡á¡ á¡¡á¡¢á¡£á¡€á¡¥á¡Šá¡§á¡šá¡©á¡ªá¡«á¡¬á¡­á¡®á¡¯á¡°á¡±á¡²á¡³á¡Žá¡µá¡¶á¡·á¡žá¡¹á¡ºá¡»á¡Œá¡œá¡Ÿá¡¿
+á¢á¢á¢á¢á¢á¢
+á¢á¢á¢á¢á¢á¢á¢á¢á¢á¢á¢á¢á¢á¢á¢á¢á¢á¢á¢á¢á¢á¢á¢á¢á¢á¢á¢ á¢¡á¢¢á¢£á¢€á¢¥á¢Šá¢§á¢šâá¢©á¢ªá¢«á¢¬á¢­á¢®á¢¯
+
+Free block (U+18B0-U+1DFF):
+
+á¢°á¢±á¢²á¢³á¢Žá¢µá¢¶á¢·á¢žá¢¹á¢ºá¢»á¢Œá¢œá¢Ÿá¢¿á£á£á£á£á£á£
+á£á£á£á£á£á£á£á£á£á£á£á£á£á£á£á£á£á£á£á£á£á£á£á£á£á£á£ á£¡á£¢á££á£€á£¥á£Šá£§á£šá£©á£ªá£«á£¬á£­á£®á£¯
+á£°á£±á£²á£³á£Žá£µá£¶á£·á£žá£¹á£ºá£»á£Œá£œá£Ÿá£¿á€á€á€á€á€á€
+á€á€á€á€á€á€á€á€á€á€á€á€á€á€á€á€á€á€á€á€á€á€á€á€á€á€á€ á€¡á€¢á€£á€€á€¥á€Šá€§á€šá€©á€ªá€«á€¬á€­á€®á€¯
+á€°á€±á€²á€³á€Žá€µá€¶á€·á€žá€¹á€ºá€»á€Œá€œá€Ÿá€¿á¥á¥á¥á¥á¥á¥
+á¥á¥á¥á¥á¥á¥á¥á¥á¥á¥á¥á¥á¥á¥á¥á¥á¥á¥á¥á¥á¥á¥á¥á¥á¥á¥á¥ á¥¡á¥¢á¥£á¥€á¥¥á¥Šá¥§á¥šá¥©á¥ªá¥«á¥¬á¥­á¥®á¥¯
+á¥°á¥±á¥²á¥³á¥Žá¥µá¥¶á¥·á¥žá¥¹á¥ºá¥»á¥Œá¥œá¥Ÿá¥¿áŠáŠáŠáŠáŠáŠ
+áŠáŠáŠáŠáŠáŠáŠáŠáŠáŠáŠáŠáŠáŠáŠáŠáŠáŠáŠáŠáŠáŠáŠáŠáŠáŠáŠ áŠ¡áŠ¢áŠ£áŠ€áŠ¥áŠŠáŠ§áŠšáŠ©áŠªáŠ«áŠ¬áŠ­áŠ®áŠ¯
+áŠ°áŠ±áŠ²áŠ³áŠŽáŠµáŠ¶áŠ·áŠžáŠ¹áŠºáŠ»áŠŒáŠœáŠŸáŠ¿á§á§á§á§á§á§
+á§á§á§á§á§á§á§á§á§á§á§á§á§á§á§á§á§á§á§á§á§á§á§á§á§á§á§ á§¡á§¢á§£á§€á§¥á§Šá§§á§šá§©á§ªá§«á§¬á§­á§®á§¯
+á§°á§±á§²á§³á§Žá§µá§¶á§·á§žá§¹á§ºá§»á§Œá§œá§Ÿá§¿ášášášášášáš
+ášášášášášášášášášášášášášášášášášášášášášášášášášášáš áš¡áš¢áš£áš€áš¥ášŠáš§áššáš©ášªáš«áš¬áš­áš®áš¯
+áš°áš±áš²áš³ášŽášµáš¶áš·ášžáš¹ášºáš»ášŒášœášŸáš¿á©á©á©á©á©á©
+á©á©á©á©á©á©á©á©á©á©á©á©á©á©á©á©á©á©á©á©á©á©á©á©á©á©á© á©¡á©¢á©£á©€á©¥á©Šá©§á©šá©©á©ªá©«á©¬á©­á©®á©¯
+á©°á©±á©²á©³á©Žá©µá©¶á©·á©žá©¹á©ºá©»á©Œá©œá©Ÿá©¿áªáªáªáªáªáª
+áªáªáªáªáªáªáªáªáªáªáªáªáªáªáªáªáªáªáªáªáªáªáªáªáªáªáª áª¡áª¢áª£áª€áª¥áªŠáª§áªšáª©áªªáª«áª¬áª­áª®áª¯
+áª°áª±áª²áª³áªŽáªµáª¶áª·áªžáª¹áªºáª»áªŒáªœáªŸáª¿á«á«á«á«á«á«
+á«á«á«á«á«á«á«á«á«á«á«á«á«á«á«á«á«á«á«á«á«á«á«á«á«á«á« á«¡á«¢á«£á«€á«¥á«Šá«§á«šá«©á«ªá««á«¬á«­á«®á«¯
+á«°á«±á«²á«³á«Žá«µá«¶á«·á«žá«¹á«ºá«»á«Œá«œá«Ÿá«¿á¬á¬á¬á¬á¬á¬
+á¬á¬á¬á¬á¬á¬á¬á¬á¬á¬á¬á¬á¬á¬á¬á¬á¬á¬á¬á¬á¬á¬á¬á¬á¬á¬á¬ á¬¡á¬¢á¬£á¬€á¬¥á¬Šá¬§á¬šá¬©á¬ªá¬«á¬¬á¬­á¬®á¬¯
+á¬°á¬±á¬²á¬³á¬Žá¬µá¬¶á¬·á¬žá¬¹á¬ºá¬»á¬Œá¬œá¬Ÿá¬¿á­á­á­á­á­á­
+á­á­á­á­á­á­á­á­á­á­á­á­á­á­á­á­á­á­á­á­á­á­á­á­á­á­á­ á­¡á­¢á­£á­€á­¥á­Šá­§á­šá­©á­ªá­«á­¬á­­á­®á­¯
+á­°á­±á­²á­³á­Žá­µá­¶á­·á­žá­¹á­ºá­»á­Œá­œá­Ÿá­¿á®á®á®á®á®á®
+á®á®á®á®á®á®á®á®á®á®á®á®á®á®á®á®á®á®á®á®á®á®á®á®á®á®á® á®¡á®¢á®£á®€á®¥á®Šá®§á®šá®©á®ªá®«á®¬á®­á®®á®¯
+á®°á®±á®²á®³á®Žá®µá®¶á®·á®žá®¹á®ºá®»á®Œá®œá®Ÿá®¿á¯á¯á¯á¯á¯á¯
+á¯á¯á¯á¯á¯á¯á¯á¯á¯á¯á¯á¯á¯á¯á¯á¯á¯á¯á¯á¯á¯á¯á¯á¯á¯á¯á¯ á¯¡á¯¢á¯£á¯€á¯¥á¯Šá¯§á¯šá¯©á¯ªá¯«á¯¬á¯­á¯®á¯¯
+á¯°á¯±á¯²á¯³á¯Žá¯µá¯¶á¯·á¯žá¯¹á¯ºá¯»á¯Œá¯œá¯Ÿá¯¿á°á°á°á°á°á°
+á°á°á°á°á°á°á°á°á°á°á°á°á°á°á°á°á°á°á°á°á°á°á°á°á°á°á° á°¡á°¢á°£á°€á°¥á°Šá°§á°šá°©á°ªá°«á°¬á°­á°®á°¯
+á°°á°±á°²á°³á°Žá°µá°¶á°·á°žá°¹á°ºá°»á°Œá°œá°Ÿá°¿á±á±á±á±á±á±
+á±á±á±á±á±á±á±á±á±á±á±á±á±á±á±á±á±á±á±á±á±á±á±á±á±á±á± á±¡á±¢á±£á±€á±¥á±Šá±§á±šá±©á±ªá±«á±¬á±­á±®á±¯
+á±°á±±á±²á±³á±Žá±µá±¶á±·á±žá±¹á±ºá±»á±Œá±œá±Ÿá±¿á²á²á²á²á²á²
+á²á²á²á²á²á²á²á²á²á²á²á²á²á²á²á²á²á²á²á²á²á²á²á²á²á²á² á²¡á²¢á²£á²€á²¥á²Šá²§á²šá²©á²ªá²«á²¬á²­á²®á²¯
+á²°á²±á²²á²³á²Žá²µá²¶á²·á²žá²¹á²ºá²»á²Œá²œá²Ÿá²¿á³á³á³á³á³á³
+á³á³á³á³á³á³á³á³á³á³á³á³á³á³á³á³á³á³á³á³á³á³á³á³á³á³á³ á³¡á³¢á³£á³€á³¥á³Šá³§á³šá³©á³ªá³«á³¬á³­á³®á³¯
+á³°á³±á³²á³³á³Žá³µá³¶á³·á³žá³¹á³ºá³»á³Œá³œá³Ÿá³¿áŽáŽáŽáŽáŽáŽ
+áŽáŽáŽáŽáŽáŽáŽáŽáŽáŽáŽáŽáŽáŽáŽáŽáŽáŽáŽáŽáŽáŽáŽáŽáŽáŽáŽ áŽ¡áŽ¢áŽ£áŽ€áŽ¥áŽŠáŽ§áŽšáŽ©áŽªáŽ«áŽ¬áŽ­áŽ®áŽ¯
+áŽ°áŽ±áŽ²áŽ³áŽŽáŽµáŽ¶áŽ·áŽžáŽ¹áŽºáŽ»áŽŒáŽœáŽŸáŽ¿áµáµáµáµáµáµ
+áµáµáµáµáµáµáµáµáµáµáµáµáµáµáµáµáµáµáµáµáµáµáµáµáµáµáµ áµ¡áµ¢áµ£áµ€áµ¥áµŠáµ§áµšáµ©áµªáµ«áµ¬áµ­áµ®áµ¯
+áµ°áµ±áµ²áµ³áµŽáµµáµ¶áµ·áµžáµ¹áµºáµ»áµŒáµœáµŸáµ¿á¶á¶á¶á¶á¶á¶
+á¶á¶á¶á¶á¶á¶á¶á¶á¶á¶á¶á¶á¶á¶á¶á¶á¶á¶á¶á¶á¶á¶á¶á¶á¶á¶á¶ á¶¡á¶¢á¶£á¶€á¶¥á¶Šá¶§á¶šá¶©á¶ªá¶«á¶¬á¶­á¶®á¶¯
+á¶°á¶±á¶²á¶³á¶Žá¶µá¶¶á¶·á¶žá¶¹á¶ºá¶»á¶Œá¶œá¶Ÿá¶¿á·á·á·á·á·á·
+á·á·á·á·á·á·á·á·á·á·á·á·á·á·á·á·á·á·á·á·á·á·á·á·á·á·á· á·¡á·¢á·£á·€á·¥á·Šá·§á·šá·©á·ªá·«á·¬á·­á·®á·¯
+á·°á·±á·²á·³á·Žá·µá·¶á··á·žá·¹á·ºá·»á·Œá·œá·Ÿá·¿
+
+Latin Extended Additional (U+1E00-U+1EFF):
+
+ážážážážážáž
+ážážážážážážážážážážážážážážážážážážážážážážážážážážáž áž¡áž¢áž£áž€áž¥ážŠáž§ážšáž©ážªáž«áž¬áž­áž®áž¯áž°áž±áž²áž³ážŽážµáž¶áž·ážžáž¹ážºáž»ážŒážœážŸáž¿
+á¹á¹á¹á¹á¹á¹
+á¹á¹á¹á¹á¹á¹á¹á¹á¹á¹á¹á¹á¹á¹á¹á¹á¹á¹á¹á¹á¹á¹á¹á¹á¹á¹á¹ á¹¡á¹¢á¹£á¹€á¹¥á¹Šá¹§á¹šá¹©á¹ªá¹«á¹¬á¹­á¹®á¹¯á¹°á¹±á¹²á¹³á¹Žá¹µá¹¶á¹·á¹žá¹¹á¹ºá¹»á¹Œá¹œá¹Ÿá¹¿
+áºáºáºáºáºáº
+áºáºáºáºáºáºáºáºáºáºáºáºáºáºáºáºáºáºáºáºáºáºáºáºáºáºáº áº¡áº¢áº£áº€áº¥áºŠáº§áºšáº©áºªáº«áº¬áº­áº®áº¯áº°áº±áº²áº³áºŽáºµáº¶áº·áºžáº¹áººáº»áºŒáºœáºŸáº¿
+á»á»á»á»á»á»
+á»á»á»á»á»á»á»á»á»á»á»á»á»á»á»á»á»á»á»á»á»á»á»á»á»á»á» á»¡á»¢á»£á»€á»¥á»Šá»§á»šá»©á»ªá»«á»¬á»­á»®á»¯á»°á»±á»²á»³á»Žá»µá»¶á»·á»žá»¹á»ºá»»á»Œá»œá»Ÿá»¿
+
+Greek Extended (U+1F00-U+1FFF):
+
+áŒáŒáŒáŒáŒáŒ
+áŒáŒáŒáŒáŒáŒáŒáŒáŒáŒáŒáŒáŒáŒáŒáŒáŒáŒáŒáŒáŒáŒáŒáŒáŒáŒáŒ áŒ¡áŒ¢áŒ£áŒ€áŒ¥áŒŠáŒ§áŒšáŒ©áŒªáŒ«áŒ¬áŒ­áŒ®áŒ¯áŒ°áŒ±áŒ²áŒ³áŒŽáŒµáŒ¶áŒ·áŒžáŒ¹áŒºáŒ»áŒŒáŒœáŒŸáŒ¿
+áœáœáœáœáœáœ
+áœáœáœáœáœáœáœáœáœáœáœáœáœáœáœáœáœáœáœáœáœáœáœáœáœáœáœ áœ¡áœ¢áœ£áœ€áœ¥áœŠáœ§áœšáœ©áœªáœ«áœ¬áœ­áœ®áœ¯áœ°áœ±áœ²áœ³áœŽáœµáœ¶áœ·áœžáœ¹áœºáœ»áœŒáœœáœŸáœ¿
+áŸáŸáŸáŸáŸáŸ
+áŸáŸáŸáŸáŸáŸáŸáŸáŸáŸáŸáŸáŸáŸáŸáŸáŸáŸáŸáŸáŸáŸáŸáŸáŸáŸáŸ áŸ¡áŸ¢áŸ£áŸ€áŸ¥áŸŠáŸ§áŸšáŸ©áŸªáŸ«áŸ¬áŸ­áŸ®áŸ¯áŸ°áŸ±áŸ²áŸ³áŸŽáŸµáŸ¶áŸ·áŸžáŸ¹áŸºáŸ»áŸŒáŸœáŸŸáŸ¿
+á¿á¿á¿á¿á¿á¿
+á¿á¿á¿á¿á¿á¿á¿á¿á¿á¿á¿á¿á¿á¿á¿á¿á¿á¿á¿á¿á¿á¿á¿á¿á¿á¿á¿ á¿¡á¿¢á¿£á¿€á¿¥á¿Šá¿§á¿šá¿©á¿ªá¿«á¿¬á¿­á¿®á¿¯á¿°á¿±á¿²á¿³á¿Žá¿µá¿¶á¿·á¿žá¿¹á¿ºá¿»á¿Œá¿œá¿Ÿá¿¿
+
+General Punctuation (U+2000-U+206F):
+
+ââââââ
+âââââââââââââââââââââââââââ â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿
+ââââââ
+âââââââââââââââââââââââââââ â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯
+
+Superscripts and Subscripts (U+2070-U+209F):
+
+â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿ââââââ
+ââââââââââââââââââââââââââ
+
+Currency Symbols (U+20A0-U+20CF):
+
+â â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿ââââââ
+ââââââââââ
+
+Combining Marks for Symbols (U+20D0-U+20FF):
+
+ââââââââââââââââââââââââââ â â â â ââ¡ â¢ â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿
+
+Letterlike Symbols (U+2100-U+214F):
+
+ââââââ
+âââââââââââââââââââââââââââ â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿
+â
+â
+â
+â
+â
+â
+
+â
+â
+â
+â
+â
+â
+â
+â
+â
+â
+
+
+Number Forms (U+2150-U+218F):
+
+â
+â
+â
+â
+â
+â
+â
+â
+â
+â
+â
+â
+â
+â
+â
+â
+â
+ â
+¡â
+¢â
+£â
+€â
+¥â
+Šâ
+§â
+šâ
+©â
+ªâ
+«â
+¬â
+­â
+®â
+¯â
+°â
+±â
+²â
+³â
+Žâ
+µâ
+¶â
+·â
+žâ
+¹â
+ºâ
+»â
+Œâ
+œâ
+Ÿâ
+¿ââââââ
+ââââââââââ
+
+Arrows (U+2190-U+21FF):
+
+âââââââââââââââââ â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿ââââââ
+ââââââââââ
+âââââââââââââââââ â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿
+
+Mathematical Operators (U+2200-U+22FF):
+
+ââââââ
+âââââââââââââââââââââââââââ â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿
+ââââââ
+âââââââââââââââââââââââââââ â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿
+ââââââ
+âââââââââââââââââââââââââââ â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿
+ââââââ
+âââââââââââââââââââââââââââ â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿
+
+Miscellaneous Technical (U+2300-U+23FF):
+
+ââââââ
+âââââââââââââââââââââââââââ â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿
+ââââââ
+âââââââââââââââââââââââââââ â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿
+ââââââ
+âââââââââââââââââââââââââââ â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿
+ââââââ
+âââââââââââââââââââââââââââ â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿
+
+Control Pictures (U+2400-U+243F):
+
+ââââââ
+âââââââââââââââââââââââââââ â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿
+
+Optical Character Recognition (U+2440-U+245F):
+
+ââââââ
+ââââââââââââââââââââââââââ
+
+Enclosed Alphanumerics (U+2460-U+24FF):
+
+â â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿ââââââ
+ââââââââââââââââââââââââââ
+â â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿ââââââ
+ââââââââââââââââââââââââââ
+â â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿
+
+Box Drawing (U+2500-U+257F):
+
+ââââââ
+âââââââââââââââââââââââââââ â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿
+ââââââ
+âââââââââââââââââââââââââââ â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿
+
+Block Elements (U+2580-U+259F):
+
+ââââââ
+ââââââââââââââââââââââââââ
+
+Geometric Shapes (U+25A0-U+25FF):
+
+â â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿ââââââ
+ââââââââââââââââââââââââââ
+â â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿
+
+Miscellaneous Symbols (U+2600-U+26FF):
+
+ââââââ
+âââââââââââââââââââââââââââ â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿
+ââââââ
+âââââââââââââââââââââââââââ â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿
+ââââââ
+âââââââââââââââââââââââââââ â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿
+ââââââ
+âââââââââââââââââââââââââââ â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿
+
+Dingbats (U+2700-U+27BF):
+
+ââââââ
+âââââââââââââââââââââââââââ â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿
+ââââââ
+âââââââââââââââââââââââââââ â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿
+ââââââ
+âââââââââââââââââââââââââââ â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿
+
+Free block (U+27C0-U+27FF):
+
+ââââââ
+âââââââââââââââââââââââââââ â¡â¢â£â€â¥âŠâ§âšâ©âªâ«â¬â­â®â¯â°â±â²â³âŽâµâ¶â·âžâ¹âºâ»âŒâœâŸâ¿
+
+Braille Patterns (U+2800-U+28FF):
+
+â â â â â â 
+â â â â â â â â â â â â â â â â â â â â â â â â â â â  â ¡â ¢â £â €â ¥â Šâ §â šâ ©â ªâ «â ¬â ­â ®â ¯â °â ±â ²â ³â Žâ µâ ¶â ·â žâ ¹â ºâ »â Œâ œâ Ÿâ ¿
+â¡â¡â¡â¡â¡â¡
+â¡â¡â¡â¡â¡â¡â¡â¡â¡â¡â¡â¡â¡â¡â¡â¡â¡â¡â¡â¡â¡â¡â¡â¡â¡â¡â¡ â¡¡â¡¢â¡£â¡€â¡¥â¡Šâ¡§â¡šâ¡©â¡ªâ¡«â¡¬â¡­â¡®â¡¯â¡°â¡±â¡²â¡³â¡Žâ¡µâ¡¶â¡·â¡žâ¡¹â¡ºâ¡»â¡Œâ¡œâ¡Ÿâ¡¿
+â¢â¢â¢â¢â¢â¢
+â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢ â¢¡â¢¢â¢£â¢€â¢¥â¢Šâ¢§â¢šâ¢©â¢ªâ¢«â¢¬â¢­â¢®â¢¯â¢°â¢±â¢²â¢³â¢Žâ¢µâ¢¶â¢·â¢žâ¢¹â¢ºâ¢»â¢Œâ¢œâ¢Ÿâ¢¿
+â£â£â£â£â£â£
+â£â£â£â£â£â£â£â£â£â£â£â£â£â£â£â£â£â£â£â£â£â£â£â£â£â£â£ â£¡â£¢â££â£€â£¥â£Šâ£§â£šâ£©â£ªâ£«â£¬â£­â£®â£¯â£°â£±â£²â£³â£Žâ£µâ£¶â£·â£žâ£¹â£ºâ£»â£Œâ£œâ£Ÿâ£¿
+
+Free block (U+2900-U+2E7F):
+
+â€â€â€â€â€â€
+â€â€â€â€â€â€â€â€â€â€â€â€â€â€â€â€â€â€â€â€â€â€â€â€â€â€â€ â€¡â€¢â€£â€€â€¥â€Šâ€§â€šâ€©â€ªâ€«â€¬â€­â€®â€¯â€°â€±â€²â€³â€Žâ€µâ€¶â€·â€žâ€¹â€ºâ€»â€Œâ€œâ€Ÿâ€¿
+â¥â¥â¥â¥â¥â¥
+â¥â¥â¥â¥â¥â¥â¥â¥â¥â¥â¥â¥â¥â¥â¥â¥â¥â¥â¥â¥â¥â¥â¥â¥â¥â¥â¥ â¥¡â¥¢â¥£â¥€â¥¥â¥Šâ¥§â¥šâ¥©â¥ªâ¥«â¥¬â¥­â¥®â¥¯â¥°â¥±â¥²â¥³â¥Žâ¥µâ¥¶â¥·â¥žâ¥¹â¥ºâ¥»â¥Œâ¥œâ¥Ÿâ¥¿
+âŠâŠâŠâŠâŠâŠ
+âŠâŠâŠâŠâŠâŠâŠâŠâŠâŠâŠâŠâŠâŠâŠâŠâŠâŠâŠâŠâŠâŠâŠâŠâŠâŠâŠ âŠ¡âŠ¢âŠ£âŠ€âŠ¥âŠŠâŠ§âŠšâŠ©âŠªâŠ«âŠ¬âŠ­âŠ®âŠ¯âŠ°âŠ±âŠ²âŠ³âŠŽâŠµâŠ¶âŠ·âŠžâŠ¹âŠºâŠ»âŠŒâŠœâŠŸâŠ¿
+â§â§â§â§â§â§
+â§â§â§â§â§â§â§â§â§â§â§â§â§â§â§â§â§â§â§â§â§â§â§â§â§â§â§ â§¡â§¢â§£â§€â§¥â§Šâ§§â§šâ§©â§ªâ§«â§¬â§­â§®â§¯â§°â§±â§²â§³â§Žâ§µâ§¶â§·â§žâ§¹â§ºâ§»â§Œâ§œâ§Ÿâ§¿
+âšâšâšâšâšâš
+âšâšâšâšâšâšâšâšâšâšâšâšâšâšâšâšâšâšâšâšâšâšâšâšâšâšâš âš¡âš¢âš£âš€âš¥âšŠâš§âššâš©âšªâš«âš¬âš­âš®âš¯âš°âš±âš²âš³âšŽâšµâš¶âš·âšžâš¹âšºâš»âšŒâšœâšŸâš¿
+â©â©â©â©â©â©
+â©â©â©â©â©â©â©â©â©â©â©â©â©â©â©â©â©â©â©â©â©â©â©â©â©â©â© â©¡â©¢â©£â©€â©¥â©Šâ©§â©šâ©©â©ªâ©«â©¬â©­â©®â©¯â©°â©±â©²â©³â©Žâ©µâ©¶â©·â©žâ©¹â©ºâ©»â©Œâ©œâ©Ÿâ©¿
+âªâªâªâªâªâª
+âªâªâªâªâªâªâªâªâªâªâªâªâªâªâªâªâªâªâªâªâªâªâªâªâªâªâª âª¡âª¢âª£âª€âª¥âªŠâª§âªšâª©âªªâª«âª¬âª­âª®âª¯âª°âª±âª²âª³âªŽâªµâª¶âª·âªžâª¹âªºâª»âªŒâªœâªŸâª¿
+â«â«â«â«â«â«
+â«â«â«â«â«â«â«â«â«â«â«â«â«â«â«â«â«â«â«â«â«â«â«â«â«â«â« â«¡â«¢â«£â«€â«¥â«Šâ«§â«šâ«©â«ªâ««â«¬â«­â«®â«¯â«°â«±â«²â«³â«Žâ«µâ«¶â«·â«žâ«¹â«ºâ«»â«Œâ«œâ«Ÿâ«¿
+â¬â¬â¬â¬â¬â¬
+â¬â¬â¬â¬â¬â¬â¬â¬â¬â¬â¬â¬â¬â¬â¬â¬â¬â¬â¬â¬â¬â¬â¬â¬â¬â¬â¬ â¬¡â¬¢â¬£â¬€â¬¥â¬Šâ¬§â¬šâ¬©â¬ªâ¬«â¬¬â¬­â¬®â¬¯â¬°â¬±â¬²â¬³â¬Žâ¬µâ¬¶â¬·â¬žâ¬¹â¬ºâ¬»â¬Œâ¬œâ¬Ÿâ¬¿
+â­â­â­â­â­â­
+â­â­â­â­â­â­â­â­â­â­â­â­â­â­â­â­â­â­â­â­â­â­â­â­â­â­â­ â­¡â­¢â­£â­€â­¥â­Šâ­§â­šâ­©â­ªâ­«â­¬â­­â­®â­¯â­°â­±â­²â­³â­Žâ­µâ­¶â­·â­žâ­¹â­ºâ­»â­Œâ­œâ­Ÿâ­¿
+â®â®â®â®â®â®
+â®â®â®â®â®â®â®â®â®â®â®â®â®â®â®â®â®â®â®â®â®â®â®â®â®â®â® â®¡â®¢â®£â®€â®¥â®Šâ®§â®šâ®©â®ªâ®«â®¬â®­â®®â®¯â®°â®±â®²â®³â®Žâ®µâ®¶â®·â®žâ®¹â®ºâ®»â®Œâ®œâ®Ÿâ®¿
+â¯â¯â¯â¯â¯â¯
+â¯â¯â¯â¯â¯â¯â¯â¯â¯â¯â¯â¯â¯â¯â¯â¯â¯â¯â¯â¯â¯â¯â¯â¯â¯â¯â¯ â¯¡â¯¢â¯£â¯€â¯¥â¯Šâ¯§â¯šâ¯©â¯ªâ¯«â¯¬â¯­â¯®â¯¯â¯°â¯±â¯²â¯³â¯Žâ¯µâ¯¶â¯·â¯žâ¯¹â¯ºâ¯»â¯Œâ¯œâ¯Ÿâ¯¿
+â°â°â°â°â°â°
+â°â°â°â°â°â°â°â°â°â°â°â°â°â°â°â°â°â°â°â°â°â°â°â°â°â°â° â°¡â°¢â°£â°€â°¥â°Šâ°§â°šâ°©â°ªâ°«â°¬â°­â°®â°¯â°°â°±â°²â°³â°Žâ°µâ°¶â°·â°žâ°¹â°ºâ°»â°Œâ°œâ°Ÿâ°¿
+â±â±â±â±â±â±
+â±â±â±â±â±â±â±â±â±â±â±â±â±â±â±â±â±â±â±â±â±â±â±â±â±â±â± â±¡â±¢â±£â±€â±¥â±Šâ±§â±šâ±©â±ªâ±«â±¬â±­â±®â±¯â±°â±±â±²â±³â±Žâ±µâ±¶â±·â±žâ±¹â±ºâ±»â±Œâ±œâ±Ÿâ±¿
+â²â²â²â²â²â²
+â²â²â²â²â²â²â²â²â²â²â²â²â²â²â²â²â²â²â²â²â²â²â²â²â²â²â² â²¡â²¢â²£â²€â²¥â²Šâ²§â²šâ²©â²ªâ²«â²¬â²­â²®â²¯â²°â²±â²²â²³â²Žâ²µâ²¶â²·â²žâ²¹â²ºâ²»â²Œâ²œâ²Ÿâ²¿
+â³â³â³â³â³â³
+â³â³â³â³â³â³â³â³â³â³â³â³â³â³â³â³â³â³â³â³â³â³â³â³â³â³â³ â³¡â³¢â³£â³€â³¥â³Šâ³§â³šâ³©â³ªâ³«â³¬â³­â³®â³¯â³°â³±â³²â³³â³Žâ³µâ³¶â³·â³žâ³¹â³ºâ³»â³Œâ³œâ³Ÿâ³¿
+âŽâŽâŽâŽâŽâŽ
+âŽâŽâŽâŽâŽâŽâŽâŽâŽâŽâŽâŽâŽâŽâŽâŽâŽâŽâŽâŽâŽâŽâŽâŽâŽâŽâŽ âŽ¡âŽ¢âŽ£âŽ€âŽ¥âŽŠâŽ§âŽšâŽ©âŽªâŽ«âŽ¬âŽ­âŽ®âŽ¯âŽ°âŽ±âŽ²âŽ³âŽŽâŽµâŽ¶âŽ·âŽžâŽ¹âŽºâŽ»âŽŒâŽœâŽŸâŽ¿
+âµâµâµâµâµâµ
+âµâµâµâµâµâµâµâµâµâµâµâµâµâµâµâµâµâµâµâµâµâµâµâµâµâµâµ âµ¡âµ¢âµ£âµ€âµ¥âµŠâµ§âµšâµ©âµªâµ«âµ¬âµ­âµ®âµ¯âµ°âµ±âµ²âµ³âµŽâµµâµ¶âµ·âµžâµ¹âµºâµ»âµŒâµœâµŸâµ¿
+â¶â¶â¶â¶â¶â¶
+â¶â¶â¶â¶â¶â¶â¶â¶â¶â¶â¶â¶â¶â¶â¶â¶â¶â¶â¶â¶â¶â¶â¶â¶â¶â¶â¶ â¶¡â¶¢â¶£â¶€â¶¥â¶Šâ¶§â¶šâ¶©â¶ªâ¶«â¶¬â¶­â¶®â¶¯â¶°â¶±â¶²â¶³â¶Žâ¶µâ¶¶â¶·â¶žâ¶¹â¶ºâ¶»â¶Œâ¶œâ¶Ÿâ¶¿
+â·â·â·â·â·â·
+â·â·â·â·â·â·â·â·â·â·â·â·â·â·â·â·â·â·â·â·â·â·â·â·â·â·â· â·¡â·¢â·£â·€â·¥â·Šâ·§â·šâ·©â·ªâ·«â·¬â·­â·®â·¯â·°â·±â·²â·³â·Žâ·µâ·¶â··â·žâ·¹â·ºâ·»â·Œâ·œâ·Ÿâ·¿
+âžâžâžâžâžâž
+âžâžâžâžâžâžâžâžâžâžâžâžâžâžâžâžâžâžâžâžâžâžâžâžâžâžâž âž¡âž¢âž£âž€âž¥âžŠâž§âžšâž©âžªâž«âž¬âž­âž®âž¯âž°âž±âž²âž³âžŽâžµâž¶âž·âžžâž¹âžºâž»âžŒâžœâžŸâž¿
+â¹â¹â¹â¹â¹â¹
+â¹â¹â¹â¹â¹â¹â¹â¹â¹â¹â¹â¹â¹â¹â¹â¹â¹â¹â¹â¹â¹â¹â¹â¹â¹â¹â¹ â¹¡â¹¢â¹£â¹€â¹¥â¹Šâ¹§â¹šâ¹©â¹ªâ¹«â¹¬â¹­â¹®â¹¯â¹°â¹±â¹²â¹³â¹Žâ¹µâ¹¶â¹·â¹žâ¹¹â¹ºâ¹»â¹Œâ¹œâ¹Ÿâ¹¿
+
+CJK Radicals Supplement (U+2E80-U+2EFF):
+
+âºâºâºâºâºâº
+âºâºâºâºâºâºâºâºâºâºâºâºâºâºâºâºâºâºâºâºâºâºâºâºâºâº
+âº âº¡âº¢âº£âº€âº¥âºŠâº§âºšâº©âºªâº«âº¬âº­âº®âº¯âº°âº±âº²âº³âºŽâºµâº¶âº·âºžâº¹âººâº»âºŒâºœâºŸâº¿
+â»â»â»â»â»â»
+â»â»â»â»â»â»â»â»â»â»â»â»â»â»â»â»â»â»â»â»â»â»â»â»â»â»
+â» â»¡â»¢â»£â»€â»¥â»Šâ»§â»šâ»©â»ªâ»«â»¬â»­â»®â»¯â»°â»±â»²â»³â»Žâ»µâ»¶â»·â»žâ»¹â»ºâ»»â»Œâ»œâ»Ÿâ»¿
+
+Kangxi Radicals (U+2F00-U+2FDF):
+
+âŒâŒâŒâŒâŒâŒ
+âŒâŒâŒâŒâŒâŒâŒâŒâŒâŒâŒâŒâŒâŒâŒâŒâŒâŒâŒâŒâŒâŒâŒâŒâŒâŒ
+âŒ âŒ¡âŒ¢âŒ£âŒ€âŒ¥âŒŠâŒ§âŒšâŒ©âŒªâŒ«âŒ¬âŒ­âŒ®âŒ¯âŒ°âŒ±âŒ²âŒ³âŒŽâŒµâŒ¶âŒ·âŒžâŒ¹âŒºâŒ»âŒŒâŒœâŒŸâŒ¿
+âœâœâœâœâœâœ
+âœâœâœâœâœâœâœâœâœâœâœâœâœâœâœâœâœâœâœâœâœâœâœâœâœâœ
+âœ âœ¡âœ¢âœ£âœ€âœ¥âœŠâœ§âœšâœ©âœªâœ«âœ¬âœ­âœ®âœ¯âœ°âœ±âœ²âœ³âœŽâœµâœ¶âœ·âœžâœ¹âœºâœ»âœŒâœœâœŸâœ¿
+âŸâŸâŸâŸâŸâŸ
+âŸâŸâŸâŸâŸâŸâŸâŸâŸâŸâŸâŸâŸâŸâŸâŸâŸâŸâŸâŸâŸâŸâŸâŸâŸâŸ
+âŸ âŸ¡âŸ¢âŸ£âŸ€âŸ¥âŸŠâŸ§âŸšâŸ©âŸªâŸ«âŸ¬âŸ­âŸ®âŸ¯âŸ°âŸ±âŸ²âŸ³âŸŽâŸµâŸ¶âŸ·âŸžâŸ¹âŸºâŸ»âŸŒâŸœâŸŸâŸ¿
+â¿â¿â¿â¿â¿â¿
+â¿â¿â¿â¿â¿â¿â¿â¿â¿â¿â¿â¿â¿â¿â¿â¿â¿â¿â¿â¿â¿â¿â¿â¿â¿â¿
+
+Free block (U+2FE0-U+2FEF):
+
+â¿ â¿¡â¿¢â¿£â¿€â¿¥â¿Šâ¿§â¿šâ¿©â¿ªâ¿«â¿¬â¿­â¿®â¿¯
+
+Ideographic Description Characters (U+2FF0-U+2FFF):
+
+â¿°â¿±â¿²â¿³â¿Žâ¿µâ¿¶â¿·â¿žâ¿¹â¿ºâ¿»â¿Œâ¿œâ¿Ÿâ¿¿
+
+CJK Symbols and Punctuation (U+3000-U+303F):
+
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©âãªâã«âã¬âã­âã®âã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+
+Hiragana (U+3040-U+309F):
+
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+ãããããã
+ãããããããããããããããããããâãâãããããã
+
+Katakana (U+30A0-U+30FF):
+
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+
+Bopomofo (U+3100-U+312F):
+
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯
+
+Hangul Compatibility Jamo (U+3130-U+318F):
+
+ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿ã
+ã
+ã
+ã
+ã
+ã
+
+ã
+ã
+ã
+ã
+ã
+ã
+ã
+ã
+ã
+ã
+
+ã
+ã
+ã
+ã
+ã
+ã
+ã
+ã
+ã
+ã
+ã
+ã
+ã
+ã
+ã
+ã
+ã
+ ã
+¡ã
+¢ã
+£ã
+€ã
+¥ã
+Šã
+§ã
+šã
+©ã
+ªã
+«ã
+¬ã
+­ã
+®ã
+¯
+ã
+°ã
+±ã
+²ã
+³ã
+Žã
+µã
+¶ã
+·ã
+žã
+¹ã
+ºã
+»ã
+Œã
+œã
+Ÿã
+¿ãããããã
+ãããããããããã
+
+Kanbun (U+3190-U+319F):
+
+ãããããããããããããããã
+
+Bopomofo Extended (U+31A0-U+31BF):
+
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+
+Free block (U+31C0-U+31FF):
+
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+
+Enclosed CJK Letters and Months (U+3200-U+32FF):
+
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+
+CJK Compatibility (U+3300-U+33FF):
+
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+
+CJK Unified Ideographs Extension A (U+3400-U+4DB5):
+
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+ãããããã
+ãããããããããããããããããããããããããã
+ã ã¡ã¢ã£ã€ã¥ãŠã§ãšã©ãªã«ã¬ã­ã®ã¯ã°ã±ã²ã³ãŽãµã¶ã·ãžã¹ãºã»ãŒãœãŸã¿
+ã ã ã ã ã ã 
+ã ã ã ã ã ã ã ã ã ã ã ã ã ã ã ã ã ã ã ã ã ã ã ã ã ã 
+ã  ã ¡ã ¢ã £ã €ã ¥ã Šã §ã šã ©ã ªã «ã ¬ã ­ã ®ã ¯ã °ã ±ã ²ã ³ã Žã µã ¶ã ·ã žã ¹ã ºã »ã Œã œã Ÿã ¿
+ã¡ã¡ã¡ã¡ã¡ã¡
+ã¡ã¡ã¡ã¡ã¡ã¡ã¡ã¡ã¡ã¡ã¡ã¡ã¡ã¡ã¡ã¡ã¡ã¡ã¡ã¡ã¡ã¡ã¡ã¡ã¡ã¡
+ã¡ ã¡¡ã¡¢ã¡£ã¡€ã¡¥ã¡Šã¡§ã¡šã¡©ã¡ªã¡«ã¡¬ã¡­ã¡®ã¡¯ã¡°ã¡±ã¡²ã¡³ã¡Žã¡µã¡¶ã¡·ã¡žã¡¹ã¡ºã¡»ã¡Œã¡œã¡Ÿã¡¿
+ã¢ã¢ã¢ã¢ã¢ã¢
+ã¢ã¢ã¢ã¢ã¢ã¢ã¢ã¢ã¢ã¢ã¢ã¢ã¢ã¢ã¢ã¢ã¢ã¢ã¢ã¢ã¢ã¢ã¢ã¢ã¢ã¢
+ã¢ ã¢¡ã¢¢ã¢£ã¢€ã¢¥ã¢Šã¢§ã¢šã¢©ã¢ªã¢«ã¢¬ã¢­ã¢®ã¢¯ã¢°ã¢±ã¢²ã¢³ã¢Žã¢µã¢¶ã¢·ã¢žã¢¹ã¢ºã¢»ã¢Œã¢œã¢Ÿã¢¿
+ã£ã£ã£ã£ã£ã£
+ã£ã£ã£ã£ã£ã£ã£ã£ã£ã£ã£ã£ã£ã£ã£ã£ã£ã£ã£ã£ã£ã£ã£ã£ã£ã£
+ã£ ã£¡ã£¢ã££ã£€ã£¥ã£Šã£§ã£šã£©ã£ªã£«ã£¬ã£­ã£®ã£¯ã£°ã£±ã£²ã£³ã£Žã£µã£¶ã£·ã£žã£¹ã£ºã£»ã£Œã£œã£Ÿã£¿
+ã€ã€ã€ã€ã€ã€
+ã€ã€ã€ã€ã€ã€ã€ã€ã€ã€ã€ã€ã€ã€ã€ã€ã€ã€ã€ã€ã€ã€ã€ã€ã€ã€
+ã€ ã€¡ã€¢ã€£ã€€ã€¥ã€Šã€§ã€šã€©ã€ªã€«ã€¬ã€­ã€®ã€¯ã€°ã€±ã€²ã€³ã€Žã€µã€¶ã€·ã€žã€¹ã€ºã€»ã€Œã€œã€Ÿã€¿
+ã¥ã¥ã¥ã¥ã¥ã¥
+ã¥ã¥ã¥ã¥ã¥ã¥ã¥ã¥ã¥ã¥ã¥ã¥ã¥ã¥ã¥ã¥ã¥ã¥ã¥ã¥ã¥ã¥ã¥ã¥ã¥ã¥
+ã¥ ã¥¡ã¥¢ã¥£ã¥€ã¥¥ã¥Šã¥§ã¥šã¥©ã¥ªã¥«ã¥¬ã¥­ã¥®ã¥¯ã¥°ã¥±ã¥²ã¥³ã¥Žã¥µã¥¶ã¥·ã¥žã¥¹ã¥ºã¥»ã¥Œã¥œã¥Ÿã¥¿
+ãŠãŠãŠãŠãŠãŠ
+ãŠãŠãŠãŠãŠãŠãŠãŠãŠãŠãŠãŠãŠãŠãŠãŠãŠãŠãŠãŠãŠãŠãŠãŠãŠãŠ
+ãŠ ãŠ¡ãŠ¢ãŠ£ãŠ€ãŠ¥ãŠŠãŠ§ãŠšãŠ©ãŠªãŠ«ãŠ¬ãŠ­ãŠ®ãŠ¯ãŠ°ãŠ±ãŠ²ãŠ³ãŠŽãŠµãŠ¶ãŠ·ãŠžãŠ¹ãŠºãŠ»ãŠŒãŠœãŠŸãŠ¿
+ã§ã§ã§ã§ã§ã§
+ã§ã§ã§ã§ã§ã§ã§ã§ã§ã§ã§ã§ã§ã§ã§ã§ã§ã§ã§ã§ã§ã§ã§ã§ã§ã§
+ã§ ã§¡ã§¢ã§£ã§€ã§¥ã§Šã§§ã§šã§©ã§ªã§«ã§¬ã§­ã§®ã§¯ã§°ã§±ã§²ã§³ã§Žã§µã§¶ã§·ã§žã§¹ã§ºã§»ã§Œã§œã§Ÿã§¿
+ãšãšãšãšãšãš
+ãšãšãšãšãšãšãšãšãšãšãšãšãšãšãšãšãšãšãšãšãšãšãšãšãšãš
+ãš ãš¡ãš¢ãš£ãš€ãš¥ãšŠãš§ãššãš©ãšªãš«ãš¬ãš­ãš®ãš¯ãš°ãš±ãš²ãš³ãšŽãšµãš¶ãš·ãšžãš¹ãšºãš»ãšŒãšœãšŸãš¿
+ã©ã©ã©ã©ã©ã©
+ã©ã©ã©ã©ã©ã©ã©ã©ã©ã©ã©ã©ã©ã©ã©ã©ã©ã©ã©ã©ã©ã©ã©ã©ã©ã©
+ã© ã©¡ã©¢ã©£ã©€ã©¥ã©Šã©§ã©šã©©ã©ªã©«ã©¬ã©­ã©®ã©¯ã©°ã©±ã©²ã©³ã©Žã©µã©¶ã©·ã©žã©¹ã©ºã©»ã©Œã©œã©Ÿã©¿
+ãªãªãªãªãªãª
+ãªãªãªãªãªãªãªãªãªãªãªãªãªãªãªãªãªãªãªãªãªãªãªãªãªãª
+ãª ãª¡ãª¢ãª£ãª€ãª¥ãªŠãª§ãªšãª©ãªªãª«ãª¬ãª­ãª®ãª¯ãª°ãª±ãª²ãª³ãªŽãªµãª¶ãª·ãªžãª¹ãªºãª»ãªŒãªœãªŸãª¿
+ã«ã«ã«ã«ã«ã«
+ã«ã«ã«ã«ã«ã«ã«ã«ã«ã«ã«ã«ã«ã«ã«ã«ã«ã«ã«ã«ã«ã«ã«ã«ã«ã«
+ã« ã«¡ã«¢ã«£ã«€ã«¥ã«Šã«§ã«šã«©ã«ªã««ã«¬ã«­ã«®ã«¯ã«°ã«±ã«²ã«³ã«Žã«µã«¶ã«·ã«žã«¹ã«ºã«»ã«Œã«œã«Ÿã«¿
+ã¬ã¬ã¬ã¬ã¬ã¬
+ã¬ã¬ã¬ã¬ã¬ã¬ã¬ã¬ã¬ã¬ã¬ã¬ã¬ã¬ã¬ã¬ã¬ã¬ã¬ã¬ã¬ã¬ã¬ã¬ã¬ã¬
+ã¬ ã¬¡ã¬¢ã¬£ã¬€ã¬¥ã¬Šã¬§ã¬šã¬©ã¬ªã¬«ã¬¬ã¬­ã¬®ã¬¯ã¬°ã¬±ã¬²ã¬³ã¬Žã¬µã¬¶ã¬·ã¬žã¬¹ã¬ºã¬»ã¬Œã¬œã¬Ÿã¬¿
+ã­ã­ã­ã­ã­ã­
+ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­
+ã­ ã­¡ã­¢ã­£ã­€ã­¥ã­Šã­§ã­šã­©ã­ªã­«ã­¬ã­­ã­®ã­¯ã­°ã­±ã­²ã­³ã­Žã­µã­¶ã­·ã­žã­¹ã­ºã­»ã­Œã­œã­Ÿã­¿
+ã®ã®ã®ã®ã®ã®
+ã®ã®ã®ã®ã®ã®ã®ã®ã®ã®ã®ã®ã®ã®ã®ã®ã®ã®ã®ã®ã®ã®ã®ã®ã®ã®
+ã® ã®¡ã®¢ã®£ã®€ã®¥ã®Šã®§ã®šã®©ã®ªã®«ã®¬ã®­ã®®ã®¯ã®°ã®±ã®²ã®³ã®Žã®µã®¶ã®·ã®žã®¹ã®ºã®»ã®Œã®œã®Ÿã®¿
+ã¯ã¯ã¯ã¯ã¯ã¯
+ã¯ã¯ã¯ã¯ã¯ã¯ã¯ã¯ã¯ã¯ã¯ã¯ã¯ã¯ã¯ã¯ã¯ã¯ã¯ã¯ã¯ã¯ã¯ã¯ã¯ã¯
+ã¯ ã¯¡ã¯¢ã¯£ã¯€ã¯¥ã¯Šã¯§ã¯šã¯©ã¯ªã¯«ã¯¬ã¯­ã¯®ã¯¯ã¯°ã¯±ã¯²ã¯³ã¯Žã¯µã¯¶ã¯·ã¯žã¯¹ã¯ºã¯»ã¯Œã¯œã¯Ÿã¯¿
+ã°ã°ã°ã°ã°ã°
+ã°ã°ã°ã°ã°ã°ã°ã°ã°ã°ã°ã°ã°ã°ã°ã°ã°ã°ã°ã°ã°ã°ã°ã°ã°ã°
+ã° ã°¡ã°¢ã°£ã°€ã°¥ã°Šã°§ã°šã°©ã°ªã°«ã°¬ã°­ã°®ã°¯ã°°ã°±ã°²ã°³ã°Žã°µã°¶ã°·ã°žã°¹ã°ºã°»ã°Œã°œã°Ÿã°¿
+ã±ã±ã±ã±ã±ã±
+ã±ã±ã±ã±ã±ã±ã±ã±ã±ã±ã±ã±ã±ã±ã±ã±ã±ã±ã±ã±ã±ã±ã±ã±ã±ã±
+ã± ã±¡ã±¢ã±£ã±€ã±¥ã±Šã±§ã±šã±©ã±ªã±«ã±¬ã±­ã±®ã±¯ã±°ã±±ã±²ã±³ã±Žã±µã±¶ã±·ã±žã±¹ã±ºã±»ã±Œã±œã±Ÿã±¿
+ã²ã²ã²ã²ã²ã²
+ã²ã²ã²ã²ã²ã²ã²ã²ã²ã²ã²ã²ã²ã²ã²ã²ã²ã²ã²ã²ã²ã²ã²ã²ã²ã²
+ã² ã²¡ã²¢ã²£ã²€ã²¥ã²Šã²§ã²šã²©ã²ªã²«ã²¬ã²­ã²®ã²¯ã²°ã²±ã²²ã²³ã²Žã²µã²¶ã²·ã²žã²¹ã²ºã²»ã²Œã²œã²Ÿã²¿
+ã³ã³ã³ã³ã³ã³
+ã³ã³ã³ã³ã³ã³ã³ã³ã³ã³ã³ã³ã³ã³ã³ã³ã³ã³ã³ã³ã³ã³ã³ã³ã³ã³
+ã³ ã³¡ã³¢ã³£ã³€ã³¥ã³Šã³§ã³šã³©ã³ªã³«ã³¬ã³­ã³®ã³¯ã³°ã³±ã³²ã³³ã³Žã³µã³¶ã³·ã³žã³¹ã³ºã³»ã³Œã³œã³Ÿã³¿
+ãŽãŽãŽãŽãŽãŽ
+ãŽãŽãŽãŽãŽãŽãŽãŽãŽãŽãŽãŽãŽãŽãŽãŽãŽãŽãŽãŽãŽãŽãŽãŽãŽãŽ
+ãŽ ãŽ¡ãŽ¢ãŽ£ãŽ€ãŽ¥ãŽŠãŽ§ãŽšãŽ©ãŽªãŽ«ãŽ¬ãŽ­ãŽ®ãŽ¯ãŽ°ãŽ±ãŽ²ãŽ³ãŽŽãŽµãŽ¶ãŽ·ãŽžãŽ¹ãŽºãŽ»ãŽŒãŽœãŽŸãŽ¿
+ãµãµãµãµãµãµ
+ãµãµãµãµãµãµãµãµãµãµãµãµãµãµãµãµãµãµãµãµãµãµãµãµãµãµ
+ãµ ãµ¡ãµ¢ãµ£ãµ€ãµ¥ãµŠãµ§ãµšãµ©ãµªãµ«ãµ¬ãµ­ãµ®ãµ¯ãµ°ãµ±ãµ²ãµ³ãµŽãµµãµ¶ãµ·ãµžãµ¹ãµºãµ»ãµŒãµœãµŸãµ¿
+ã¶ã¶ã¶ã¶ã¶ã¶
+ã¶ã¶ã¶ã¶ã¶ã¶ã¶ã¶ã¶ã¶ã¶ã¶ã¶ã¶ã¶ã¶ã¶ã¶ã¶ã¶ã¶ã¶ã¶ã¶ã¶ã¶
+ã¶ ã¶¡ã¶¢ã¶£ã¶€ã¶¥ã¶Šã¶§ã¶šã¶©ã¶ªã¶«ã¶¬ã¶­ã¶®ã¶¯ã¶°ã¶±ã¶²ã¶³ã¶Žã¶µã¶¶ã¶·ã¶žã¶¹ã¶ºã¶»ã¶Œã¶œã¶Ÿã¶¿
+ã·ã·ã·ã·ã·ã·
+ã·ã·ã·ã·ã·ã·ã·ã·ã·ã·ã·ã·ã·ã·ã·ã·ã·ã·ã·ã·ã·ã·ã·ã·ã·ã·
+ã· ã·¡ã·¢ã·£ã·€ã·¥ã·Šã·§ã·šã·©ã·ªã·«ã·¬ã·­ã·®ã·¯ã·°ã·±ã·²ã·³ã·Žã·µã·¶ã··ã·žã·¹ã·ºã·»ã·Œã·œã·Ÿã·¿
+ãžãžãžãžãžãž
+ãžãžãžãžãžãžãžãžãžãžãžãžãžãžãžãžãžãžãžãžãžãžãžãžãžãž
+ãž ãž¡ãž¢ãž£ãž€ãž¥ãžŠãž§ãžšãž©ãžªãž«ãž¬ãž­ãž®ãž¯ãž°ãž±ãž²ãž³ãžŽãžµãž¶ãž·ãžžãž¹ãžºãž»ãžŒãžœãžŸãž¿
+ã¹ã¹ã¹ã¹ã¹ã¹
+ã¹ã¹ã¹ã¹ã¹ã¹ã¹ã¹ã¹ã¹ã¹ã¹ã¹ã¹ã¹ã¹ã¹ã¹ã¹ã¹ã¹ã¹ã¹ã¹ã¹ã¹
+ã¹ ã¹¡ã¹¢ã¹£ã¹€ã¹¥ã¹Šã¹§ã¹šã¹©ã¹ªã¹«ã¹¬ã¹­ã¹®ã¹¯ã¹°ã¹±ã¹²ã¹³ã¹Žã¹µã¹¶ã¹·ã¹žã¹¹ã¹ºã¹»ã¹Œã¹œã¹Ÿã¹¿
+ãºãºãºãºãºãº
+ãºãºãºãºãºãºãºãºãºãºãºãºãºãºãºãºãºãºãºãºãºãºãºãºãºãº
+ãº ãº¡ãº¢ãº£ãº€ãº¥ãºŠãº§ãºšãº©ãºªãº«ãº¬ãº­ãº®ãº¯ãº°ãº±ãº²ãº³ãºŽãºµãº¶ãº·ãºžãº¹ãººãº»ãºŒãºœãºŸãº¿
+ã»ã»ã»ã»ã»ã»
+ã»ã»ã»ã»ã»ã»ã»ã»ã»ã»ã»ã»ã»ã»ã»ã»ã»ã»ã»ã»ã»ã»ã»ã»ã»ã»
+ã» ã»¡ã»¢ã»£ã»€ã»¥ã»Šã»§ã»šã»©ã»ªã»«ã»¬ã»­ã»®ã»¯ã»°ã»±ã»²ã»³ã»Žã»µã»¶ã»·ã»žã»¹ã»ºã»»ã»Œã»œã»Ÿã»¿
+ãŒãŒãŒãŒãŒãŒ
+ãŒãŒãŒãŒãŒãŒãŒãŒãŒãŒãŒãŒãŒãŒãŒãŒãŒãŒãŒãŒãŒãŒãŒãŒãŒãŒ
+ãŒ ãŒ¡ãŒ¢ãŒ£ãŒ€ãŒ¥ãŒŠãŒ§ãŒšãŒ©ãŒªãŒ«ãŒ¬ãŒ­ãŒ®ãŒ¯ãŒ°ãŒ±ãŒ²ãŒ³ãŒŽãŒµãŒ¶ãŒ·ãŒžãŒ¹ãŒºãŒ»ãŒŒãŒœãŒŸãŒ¿
+ãœãœãœãœãœãœ
+ãœãœãœãœãœãœãœãœãœãœãœãœãœãœãœãœãœãœãœãœãœãœãœãœãœãœ
+ãœ ãœ¡ãœ¢ãœ£ãœ€ãœ¥ãœŠãœ§ãœšãœ©ãœªãœ«ãœ¬ãœ­ãœ®ãœ¯ãœ°ãœ±ãœ²ãœ³ãœŽãœµãœ¶ãœ·ãœžãœ¹ãœºãœ»ãœŒãœœãœŸãœ¿
+ãŸãŸãŸãŸãŸãŸ
+ãŸãŸãŸãŸãŸãŸãŸãŸãŸãŸãŸãŸãŸãŸãŸãŸãŸãŸãŸãŸãŸãŸãŸãŸãŸãŸ
+ãŸ ãŸ¡ãŸ¢ãŸ£ãŸ€ãŸ¥ãŸŠãŸ§ãŸšãŸ©ãŸªãŸ«ãŸ¬ãŸ­ãŸ®ãŸ¯ãŸ°ãŸ±ãŸ²ãŸ³ãŸŽãŸµãŸ¶ãŸ·ãŸžãŸ¹ãŸºãŸ»ãŸŒãŸœãŸŸãŸ¿
+ã¿ã¿ã¿ã¿ã¿ã¿
+ã¿ã¿ã¿ã¿ã¿ã¿ã¿ã¿ã¿ã¿ã¿ã¿ã¿ã¿ã¿ã¿ã¿ã¿ã¿ã¿ã¿ã¿ã¿ã¿ã¿ã¿
+ã¿ ã¿¡ã¿¢ã¿£ã¿€ã¿¥ã¿Šã¿§ã¿šã¿©ã¿ªã¿«ã¿¬ã¿­ã¿®ã¿¯ã¿°ã¿±ã¿²ã¿³ã¿Žã¿µã¿¶ã¿·ã¿žã¿¹ã¿ºã¿»ã¿Œã¿œã¿Ÿã¿¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ä
+ä
+ä
+ä
+ä
+ä
+
+ä
+ä
+ä
+ä
+ä
+ä
+ä
+ä
+ä
+ä
+ä
+ä
+ä
+ä
+ä
+ä
+ä
+ä
+ä
+ä
+ä
+ä
+ä
+ä
+ä
+ä
+
+ä
+ ä
+¡ä
+¢ä
+£ä
+€ä
+¥ä
+Šä
+§ä
+šä
+©ä
+ªä
+«ä
+¬ä
+­ä
+®ä
+¯ä
+°ä
+±ä
+²ä
+³ä
+Žä
+µä
+¶ä
+·ä
+žä
+¹ä
+ºä
+»ä
+Œä
+œä
+Ÿä
+¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ääääää
+ääääääääääääääääääääääääää
+ä ä¡ä¢ä£ä€ä¥äŠä§äšä©äªä«ä¬ä­ä®ä¯ä°ä±ä²ä³äŽäµä¶ä·äžä¹äºä»äŒäœäŸä¿
+ä ä ä ä ä ä 
+ä ä ä ä ä ä ä ä ä ä ä ä ä ä ä ä ä ä ä ä ä ä ä ä ä ä 
+ä  ä ¡ä ¢ä £ä €ä ¥ä Šä §ä šä ©ä ªä «ä ¬ä ­ä ®ä ¯ä °ä ±ä ²ä ³ä Žä µä ¶ä ·ä žä ¹ä ºä »ä Œä œä Ÿä ¿
+ä¡ä¡ä¡ä¡ä¡ä¡
+ä¡ä¡ä¡ä¡ä¡ä¡ä¡ä¡ä¡ä¡ä¡ä¡ä¡ä¡ä¡ä¡ä¡ä¡ä¡ä¡ä¡ä¡ä¡ä¡ä¡ä¡
+ä¡ ä¡¡ä¡¢ä¡£ä¡€ä¡¥ä¡Šä¡§ä¡šä¡©ä¡ªä¡«ä¡¬ä¡­ä¡®ä¡¯ä¡°ä¡±ä¡²ä¡³ä¡Žä¡µä¡¶ä¡·ä¡žä¡¹ä¡ºä¡»ä¡Œä¡œä¡Ÿä¡¿
+ä¢ä¢ä¢ä¢ä¢ä¢
+ä¢ä¢ä¢ä¢ä¢ä¢ä¢ä¢ä¢ä¢ä¢ä¢ä¢ä¢ä¢ä¢ä¢ä¢ä¢ä¢ä¢ä¢ä¢ä¢ä¢ä¢
+ä¢ ä¢¡ä¢¢ä¢£ä¢€ä¢¥ä¢Šä¢§ä¢šä¢©ä¢ªä¢«ä¢¬ä¢­ä¢®ä¢¯ä¢°ä¢±ä¢²ä¢³ä¢Žä¢µä¢¶ä¢·ä¢žä¢¹ä¢ºä¢»ä¢Œä¢œä¢Ÿä¢¿
+ä£ä£ä£ä£ä£ä£
+ä£ä£ä£ä£ä£ä£ä£ä£ä£ä£ä£ä£ä£ä£ä£ä£ä£ä£ä£ä£ä£ä£ä£ä£ä£ä£
+ä£ ä£¡ä£¢ä££ä£€ä£¥ä£Šä£§ä£šä£©ä£ªä£«ä£¬ä£­ä£®ä£¯ä£°ä£±ä£²ä£³ä£Žä£µä£¶ä£·ä£žä£¹ä£ºä£»ä£Œä£œä£Ÿä£¿
+ä€ä€ä€ä€ä€ä€
+ä€ä€ä€ä€ä€ä€ä€ä€ä€ä€ä€ä€ä€ä€ä€ä€ä€ä€ä€ä€ä€ä€ä€ä€ä€ä€
+ä€ ä€¡ä€¢ä€£ä€€ä€¥ä€Šä€§ä€šä€©ä€ªä€«ä€¬ä€­ä€®ä€¯ä€°ä€±ä€²ä€³ä€Žä€µä€¶ä€·ä€žä€¹ä€ºä€»ä€Œä€œä€Ÿä€¿
+ä¥ä¥ä¥ä¥ä¥ä¥
+ä¥ä¥ä¥ä¥ä¥ä¥ä¥ä¥ä¥ä¥ä¥ä¥ä¥ä¥ä¥ä¥ä¥ä¥ä¥ä¥ä¥ä¥ä¥ä¥ä¥ä¥
+ä¥ ä¥¡ä¥¢ä¥£ä¥€ä¥¥ä¥Šä¥§ä¥šä¥©ä¥ªä¥«ä¥¬ä¥­ä¥®ä¥¯ä¥°ä¥±ä¥²ä¥³ä¥Žä¥µä¥¶ä¥·ä¥žä¥¹ä¥ºä¥»ä¥Œä¥œä¥Ÿä¥¿
+äŠäŠäŠäŠäŠäŠ
+äŠäŠäŠäŠäŠäŠäŠäŠäŠäŠäŠäŠäŠäŠäŠäŠäŠäŠäŠäŠäŠäŠäŠäŠäŠäŠ
+äŠ äŠ¡äŠ¢äŠ£äŠ€äŠ¥äŠŠäŠ§äŠšäŠ©äŠªäŠ«äŠ¬äŠ­äŠ®äŠ¯äŠ°äŠ±äŠ²äŠ³äŠŽäŠµäŠ¶äŠ·äŠžäŠ¹äŠºäŠ»äŠŒäŠœäŠŸäŠ¿
+ä§ä§ä§ä§ä§ä§
+ä§ä§ä§ä§ä§ä§ä§ä§ä§ä§ä§ä§ä§ä§ä§ä§ä§ä§ä§ä§ä§ä§ä§ä§ä§ä§
+ä§ ä§¡ä§¢ä§£ä§€ä§¥ä§Šä§§ä§šä§©ä§ªä§«ä§¬ä§­ä§®ä§¯ä§°ä§±ä§²ä§³ä§Žä§µä§¶ä§·ä§žä§¹ä§ºä§»ä§Œä§œä§Ÿä§¿
+äšäšäšäšäšäš
+äšäšäšäšäšäšäšäšäšäšäšäšäšäšäšäšäšäšäšäšäšäšäšäšäšäš
+äš äš¡äš¢äš£äš€äš¥äšŠäš§äššäš©äšªäš«äš¬äš­äš®äš¯äš°äš±äš²äš³äšŽäšµäš¶äš·äšžäš¹äšºäš»äšŒäšœäšŸäš¿
+ä©ä©ä©ä©ä©ä©
+ä©ä©ä©ä©ä©ä©ä©ä©ä©ä©ä©ä©ä©ä©ä©ä©ä©ä©ä©ä©ä©ä©ä©ä©ä©ä©
+ä© ä©¡ä©¢ä©£ä©€ä©¥ä©Šä©§ä©šä©©ä©ªä©«ä©¬ä©­ä©®ä©¯ä©°ä©±ä©²ä©³ä©Žä©µä©¶ä©·ä©žä©¹ä©ºä©»ä©Œä©œä©Ÿä©¿
+äªäªäªäªäªäª
+äªäªäªäªäªäªäªäªäªäªäªäªäªäªäªäªäªäªäªäªäªäªäªäªäªäª
+äª äª¡äª¢äª£äª€äª¥äªŠäª§äªšäª©äªªäª«äª¬äª­äª®äª¯äª°äª±äª²äª³äªŽäªµäª¶äª·äªžäª¹äªºäª»äªŒäªœäªŸäª¿
+ä«ä«ä«ä«ä«ä«
+ä«ä«ä«ä«ä«ä«ä«ä«ä«ä«ä«ä«ä«ä«ä«ä«ä«ä«ä«ä«ä«ä«ä«ä«ä«ä«
+ä« ä«¡ä«¢ä«£ä«€ä«¥ä«Šä«§ä«šä«©ä«ªä««ä«¬ä«­ä«®ä«¯ä«°ä«±ä«²ä«³ä«Žä«µä«¶ä«·ä«žä«¹ä«ºä«»ä«Œä«œä«Ÿä«¿
+ä¬ä¬ä¬ä¬ä¬ä¬
+ä¬ä¬ä¬ä¬ä¬ä¬ä¬ä¬ä¬ä¬ä¬ä¬ä¬ä¬ä¬ä¬ä¬ä¬ä¬ä¬ä¬ä¬ä¬ä¬ä¬ä¬
+ä¬ ä¬¡ä¬¢ä¬£ä¬€ä¬¥ä¬Šä¬§ä¬šä¬©ä¬ªä¬«ä¬¬ä¬­ä¬®ä¬¯ä¬°ä¬±ä¬²ä¬³ä¬Žä¬µä¬¶ä¬·ä¬žä¬¹ä¬ºä¬»ä¬Œä¬œä¬Ÿä¬¿
+ä­ä­ä­ä­ä­ä­
+ä­ä­ä­ä­ä­ä­ä­ä­ä­ä­ä­ä­ä­ä­ä­ä­ä­ä­ä­ä­ä­ä­ä­ä­ä­ä­
+ä­ ä­¡ä­¢ä­£ä­€ä­¥ä­Šä­§ä­šä­©ä­ªä­«ä­¬ä­­ä­®ä­¯ä­°ä­±ä­²ä­³ä­Žä­µä­¶ä­·ä­žä­¹ä­ºä­»ä­Œä­œä­Ÿä­¿
+ä®ä®ä®ä®ä®ä®
+ä®ä®ä®ä®ä®ä®ä®ä®ä®ä®ä®ä®ä®ä®ä®ä®ä®ä®ä®ä®ä®ä®ä®ä®ä®ä®
+ä® ä®¡ä®¢ä®£ä®€ä®¥ä®Šä®§ä®šä®©ä®ªä®«ä®¬ä®­ä®®ä®¯ä®°ä®±ä®²ä®³ä®Žä®µä®¶ä®·ä®žä®¹ä®ºä®»ä®Œä®œä®Ÿä®¿
+ä¯ä¯ä¯ä¯ä¯ä¯
+ä¯ä¯ä¯ä¯ä¯ä¯ä¯ä¯ä¯ä¯ä¯ä¯ä¯ä¯ä¯ä¯ä¯ä¯ä¯ä¯ä¯ä¯ä¯ä¯ä¯ä¯
+ä¯ ä¯¡ä¯¢ä¯£ä¯€ä¯¥ä¯Šä¯§ä¯šä¯©ä¯ªä¯«ä¯¬ä¯­ä¯®ä¯¯ä¯°ä¯±ä¯²ä¯³ä¯Žä¯µä¯¶ä¯·ä¯žä¯¹ä¯ºä¯»ä¯Œä¯œä¯Ÿä¯¿
+ä°ä°ä°ä°ä°ä°
+ä°ä°ä°ä°ä°ä°ä°ä°ä°ä°ä°ä°ä°ä°ä°ä°ä°ä°ä°ä°ä°ä°ä°ä°ä°ä°
+ä° ä°¡ä°¢ä°£ä°€ä°¥ä°Šä°§ä°šä°©ä°ªä°«ä°¬ä°­ä°®ä°¯ä°°ä°±ä°²ä°³ä°Žä°µä°¶ä°·ä°žä°¹ä°ºä°»ä°Œä°œä°Ÿä°¿
+ä±ä±ä±ä±ä±ä±
+ä±ä±ä±ä±ä±ä±ä±ä±ä±ä±ä±ä±ä±ä±ä±ä±ä±ä±ä±ä±ä±ä±ä±ä±ä±ä±
+ä± ä±¡ä±¢ä±£ä±€ä±¥ä±Šä±§ä±šä±©ä±ªä±«ä±¬ä±­ä±®ä±¯ä±°ä±±ä±²ä±³ä±Žä±µä±¶ä±·ä±žä±¹ä±ºä±»ä±Œä±œä±Ÿä±¿
+ä²ä²ä²ä²ä²ä²
+ä²ä²ä²ä²ä²ä²ä²ä²ä²ä²ä²ä²ä²ä²ä²ä²ä²ä²ä²ä²ä²ä²ä²ä²ä²ä²
+ä² ä²¡ä²¢ä²£ä²€ä²¥ä²Šä²§ä²šä²©ä²ªä²«ä²¬ä²­ä²®ä²¯ä²°ä²±ä²²ä²³ä²Žä²µä²¶ä²·ä²žä²¹ä²ºä²»ä²Œä²œä²Ÿä²¿
+ä³ä³ä³ä³ä³ä³
+ä³ä³ä³ä³ä³ä³ä³ä³ä³ä³ä³ä³ä³ä³ä³ä³ä³ä³ä³ä³ä³ä³ä³ä³ä³ä³
+ä³ ä³¡ä³¢ä³£ä³€ä³¥ä³Šä³§ä³šä³©ä³ªä³«ä³¬ä³­ä³®ä³¯ä³°ä³±ä³²ä³³ä³Žä³µä³¶ä³·ä³žä³¹ä³ºä³»ä³Œä³œä³Ÿä³¿
+äŽäŽäŽäŽäŽäŽ
+äŽäŽäŽäŽäŽäŽäŽäŽäŽäŽäŽäŽäŽäŽäŽäŽäŽäŽäŽäŽäŽäŽäŽäŽäŽäŽ
+äŽ äŽ¡äŽ¢äŽ£äŽ€äŽ¥äŽŠäŽ§äŽšäŽ©äŽªäŽ«äŽ¬äŽ­äŽ®äŽ¯äŽ°äŽ±äŽ²äŽ³äŽŽäŽµäŽ¶äŽ·äŽžäŽ¹äŽºäŽ»äŽŒäŽœäŽŸäŽ¿
+äµäµäµäµäµäµ
+äµäµäµäµäµäµäµäµäµäµäµäµäµäµäµäµäµäµäµäµäµäµäµäµäµäµ
+äµ äµ¡äµ¢äµ£äµ€äµ¥äµŠäµ§äµšäµ©äµªäµ«äµ¬äµ­äµ®äµ¯äµ°äµ±äµ²äµ³äµŽäµµäµ¶äµ·äµžäµ¹äµºäµ»äµŒäµœäµŸäµ¿
+ä¶ä¶ä¶ä¶ä¶ä¶
+ä¶ä¶ä¶ä¶ä¶ä¶ä¶ä¶ä¶ä¶ä¶ä¶ä¶ä¶ä¶ä¶ä¶ä¶ä¶ä¶ä¶ä¶ä¶ä¶ä¶ä¶
+ä¶ ä¶¡ä¶¢ä¶£ä¶€ä¶¥ä¶Šä¶§ä¶šä¶©ä¶ªä¶«ä¶¬ä¶­ä¶®ä¶¯ä¶°ä¶±ä¶²ä¶³ä¶Žä¶µ
+
+Free block (U+4DB6-U+4DFF):
+
+ä¶¶ä¶·ä¶žä¶¹ä¶ºä¶»ä¶Œä¶œä¶Ÿä¶¿ä·ä·ä·ä·ä·ä·
+ä·ä·ä·ä·ä·ä·ä·ä·ä·ä·ä·ä·ä·ä·ä·ä·
+ä·ä·ä·ä·ä·ä·ä·ä·ä·ä·ä· ä·¡ä·¢ä·£ä·€ä·¥ä·Šä·§ä·šä·©ä·ªä·«ä·¬ä·­ä·®ä·¯ä·°ä·±ä·²ä·³ä·Žä·µ
+ä·¶ä··ä·žä·¹ä·ºä·»ä·Œä·œä·Ÿä·¿
+
+CJK Unified Ideographs (U+4E00-U+9FFF):
+
+äžäžäžäžäžäž
+äžäžäžäžäžäžäžäžäžäžäžäžäžäžäžäžäžäžäžäžäžäžäžäžäžäž
+äž äž¡äž¢äž£äž€äž¥äžŠäž§äžšäž©äžªäž«äž¬äž­äž®äž¯äž°äž±äž²äž³äžŽäžµäž¶äž·äžžäž¹äžºäž»äžŒäžœäžŸäž¿
+ä¹ä¹ä¹ä¹ä¹ä¹
+ä¹ä¹ä¹ä¹ä¹ä¹ä¹ä¹ä¹ä¹ä¹ä¹ä¹ä¹ä¹ä¹ä¹ä¹ä¹ä¹ä¹ä¹ä¹ä¹ä¹ä¹
+ä¹ ä¹¡ä¹¢ä¹£ä¹€ä¹¥ä¹Šä¹§ä¹šä¹©ä¹ªä¹«ä¹¬ä¹­ä¹®ä¹¯ä¹°ä¹±ä¹²ä¹³ä¹Žä¹µä¹¶ä¹·ä¹žä¹¹ä¹ºä¹»ä¹Œä¹œä¹Ÿä¹¿
+äºäºäºäºäºäº
+äºäºäºäºäºäºäºäºäºäºäºäºäºäºäºäºäºäºäºäºäºäºäºäºäºäº
+äº äº¡äº¢äº£äº€äº¥äºŠäº§äºšäº©äºªäº«äº¬äº­äº®äº¯äº°äº±äº²äº³äºŽäºµäº¶äº·äºžäº¹äººäº»äºŒäºœäºŸäº¿
+ä»ä»ä»ä»ä»ä»
+ä»ä»ä»ä»ä»ä»ä»ä»ä»ä»ä»ä»ä»ä»ä»ä»ä»ä»ä»ä»ä»ä»ä»ä»ä»ä»
+ä» ä»¡ä»¢ä»£ä»€ä»¥ä»Šä»§ä»šä»©ä»ªä»«ä»¬ä»­ä»®ä»¯ä»°ä»±ä»²ä»³ä»Žä»µä»¶ä»·ä»žä»¹ä»ºä»»ä»Œä»œä»Ÿä»¿
+äŒäŒäŒäŒäŒäŒ
+äŒäŒäŒäŒäŒäŒäŒäŒäŒäŒäŒäŒäŒäŒäŒäŒäŒäŒäŒäŒäŒäŒäŒäŒäŒäŒ
+äŒ äŒ¡äŒ¢äŒ£äŒ€äŒ¥äŒŠäŒ§äŒšäŒ©äŒªäŒ«äŒ¬äŒ­äŒ®äŒ¯äŒ°äŒ±äŒ²äŒ³äŒŽäŒµäŒ¶äŒ·äŒžäŒ¹äŒºäŒ»äŒŒäŒœäŒŸäŒ¿
+äœäœäœäœäœäœ
+äœäœäœäœäœäœäœäœäœäœäœäœäœäœäœäœäœäœäœäœäœäœäœäœäœäœ
+äœ äœ¡äœ¢äœ£äœ€äœ¥äœŠäœ§äœšäœ©äœªäœ«äœ¬äœ­äœ®äœ¯äœ°äœ±äœ²äœ³äœŽäœµäœ¶äœ·äœžäœ¹äœºäœ»äœŒäœœäœŸäœ¿
+äŸäŸäŸäŸäŸäŸ
+äŸäŸäŸäŸäŸäŸäŸäŸäŸäŸäŸäŸäŸäŸäŸäŸäŸäŸäŸäŸäŸäŸäŸäŸäŸäŸ
+äŸ äŸ¡äŸ¢äŸ£äŸ€äŸ¥äŸŠäŸ§äŸšäŸ©äŸªäŸ«äŸ¬äŸ­äŸ®äŸ¯äŸ°äŸ±äŸ²äŸ³äŸŽäŸµäŸ¶äŸ·äŸžäŸ¹äŸºäŸ»äŸŒäŸœäŸŸäŸ¿
+ä¿ä¿ä¿ä¿ä¿ä¿
+ä¿ä¿ä¿ä¿ä¿ä¿ä¿ä¿ä¿ä¿ä¿ä¿ä¿ä¿ä¿ä¿ä¿ä¿ä¿ä¿ä¿ä¿ä¿ä¿ä¿ä¿
+ä¿ ä¿¡ä¿¢ä¿£ä¿€ä¿¥ä¿Šä¿§ä¿šä¿©ä¿ªä¿«ä¿¬ä¿­ä¿®ä¿¯ä¿°ä¿±ä¿²ä¿³ä¿Žä¿µä¿¶ä¿·ä¿žä¿¹ä¿ºä¿»ä¿Œä¿œä¿Ÿä¿¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+å
+å
+å
+å
+å
+å
+
+å
+å
+å
+å
+å
+å
+å
+å
+å
+å
+å
+å
+å
+å
+å
+å
+å
+å
+å
+å
+å
+å
+å
+å
+å
+å
+
+å
+ å
+¡å
+¢å
+£å
+€å
+¥å
+Šå
+§å
+šå
+©å
+ªå
+«å
+¬å
+­å
+®å
+¯å
+°å
+±å
+²å
+³å
+Žå
+µå
+¶å
+·å
+žå
+¹å
+ºå
+»å
+Œå
+œå
+Ÿå
+¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+åååååå
+åååååååååååååååååååååååååå
+å å¡å¢å£å€å¥åŠå§åšå©åªå«å¬å­å®å¯å°å±å²å³åŽåµå¶å·åžå¹åºå»åŒåœåŸå¿
+å å å å å å 
+å å å å å å å å å å å å å å å å å å å å å å å å å å 
+å  å ¡å ¢å £å €å ¥å Šå §å šå ©å ªå «å ¬å ­å ®å ¯å °å ±å ²å ³å Žå µå ¶å ·å žå ¹å ºå »å Œå œå Ÿå ¿
+å¡å¡å¡å¡å¡å¡
+å¡å¡å¡å¡å¡å¡å¡å¡å¡å¡å¡å¡å¡å¡å¡å¡å¡å¡å¡å¡å¡å¡å¡å¡å¡å¡
+å¡ å¡¡å¡¢å¡£å¡€å¡¥å¡Šå¡§å¡šå¡©å¡ªå¡«å¡¬å¡­å¡®å¡¯å¡°å¡±å¡²å¡³å¡Žå¡µå¡¶å¡·å¡žå¡¹å¡ºå¡»å¡Œå¡œå¡Ÿå¡¿
+å¢å¢å¢å¢å¢å¢
+å¢å¢å¢å¢å¢å¢å¢å¢å¢å¢å¢å¢å¢å¢å¢å¢å¢å¢å¢å¢å¢å¢å¢å¢å¢å¢
+å¢ å¢¡å¢¢å¢£å¢€å¢¥å¢Šå¢§å¢šå¢©å¢ªå¢«å¢¬å¢­å¢®å¢¯å¢°å¢±å¢²å¢³å¢Žå¢µå¢¶å¢·å¢žå¢¹å¢ºå¢»å¢Œå¢œå¢Ÿå¢¿
+å£å£å£å£å£å£
+å£å£å£å£å£å£å£å£å£å£å£å£å£å£å£å£å£å£å£å£å£å£å£å£å£å£
+å£ å£¡å£¢å££å£€å£¥å£Šå£§å£šå£©å£ªå£«å£¬å£­å£®å£¯å£°å£±å£²å£³å£Žå£µå£¶å£·å£žå£¹å£ºå£»å£Œå£œå£Ÿå£¿
+å€å€å€å€å€å€
+å€å€å€å€å€å€å€å€å€å€å€å€å€å€å€å€å€å€å€å€å€å€å€å€å€å€
+å€ å€¡å€¢å€£å€€å€¥å€Šå€§å€šå€©å€ªå€«å€¬å€­å€®å€¯å€°å€±å€²å€³å€Žå€µå€¶å€·å€žå€¹å€ºå€»å€Œå€œå€Ÿå€¿
+å¥å¥å¥å¥å¥å¥
+å¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¥
+å¥ å¥¡å¥¢å¥£å¥€å¥¥å¥Šå¥§å¥šå¥©å¥ªå¥«å¥¬å¥­å¥®å¥¯å¥°å¥±å¥²å¥³å¥Žå¥µå¥¶å¥·å¥žå¥¹å¥ºå¥»å¥Œå¥œå¥Ÿå¥¿
+åŠåŠåŠåŠåŠåŠ
+åŠåŠåŠåŠåŠåŠåŠåŠåŠåŠåŠåŠåŠåŠåŠåŠåŠåŠåŠåŠåŠåŠåŠåŠåŠåŠ
+åŠ åŠ¡åŠ¢åŠ£åŠ€åŠ¥åŠŠåŠ§åŠšåŠ©åŠªåŠ«åŠ¬åŠ­åŠ®åŠ¯åŠ°åŠ±åŠ²åŠ³åŠŽåŠµåŠ¶åŠ·åŠžåŠ¹åŠºåŠ»åŠŒåŠœåŠŸåŠ¿
+å§å§å§å§å§å§
+å§å§å§å§å§å§å§å§å§å§å§å§å§å§å§å§å§å§å§å§å§å§å§å§å§å§
+å§ å§¡å§¢å§£å§€å§¥å§Šå§§å§šå§©å§ªå§«å§¬å§­å§®å§¯å§°å§±å§²å§³å§Žå§µå§¶å§·å§žå§¹å§ºå§»å§Œå§œå§Ÿå§¿
+åšåšåšåšåšåš
+åšåšåšåšåšåšåšåšåšåšåšåšåšåšåšåšåšåšåšåšåšåšåšåšåšåš
+åš åš¡åš¢åš£åš€åš¥åšŠåš§åššåš©åšªåš«åš¬åš­åš®åš¯åš°åš±åš²åš³åšŽåšµåš¶åš·åšžåš¹åšºåš»åšŒåšœåšŸåš¿
+å©å©å©å©å©å©
+å©å©å©å©å©å©å©å©å©å©å©å©å©å©å©å©å©å©å©å©å©å©å©å©å©å©
+å© å©¡å©¢å©£å©€å©¥å©Šå©§å©šå©©å©ªå©«å©¬å©­å©®å©¯å©°å©±å©²å©³å©Žå©µå©¶å©·å©žå©¹å©ºå©»å©Œå©œå©Ÿå©¿
+åªåªåªåªåªåª
+åªåªåªåªåªåªåªåªåªåªåªåªåªåªåªåªåªåªåªåªåªåªåªåªåªåª
+åª åª¡åª¢åª£åª€åª¥åªŠåª§åªšåª©åªªåª«åª¬åª­åª®åª¯åª°åª±åª²åª³åªŽåªµåª¶åª·åªžåª¹åªºåª»åªŒåªœåªŸåª¿
+å«å«å«å«å«å«
+å«å«å«å«å«å«å«å«å«å«å«å«å«å«å«å«å«å«å«å«å«å«å«å«å«å«
+å« å«¡å«¢å«£å«€å«¥å«Šå«§å«šå«©å«ªå««å«¬å«­å«®å«¯å«°å«±å«²å«³å«Žå«µå«¶å«·å«žå«¹å«ºå«»å«Œå«œå«Ÿå«¿
+å¬å¬å¬å¬å¬å¬
+å¬å¬å¬å¬å¬å¬å¬å¬å¬å¬å¬å¬å¬å¬å¬å¬å¬å¬å¬å¬å¬å¬å¬å¬å¬å¬
+å¬ å¬¡å¬¢å¬£å¬€å¬¥å¬Šå¬§å¬šå¬©å¬ªå¬«å¬¬å¬­å¬®å¬¯å¬°å¬±å¬²å¬³å¬Žå¬µå¬¶å¬·å¬žå¬¹å¬ºå¬»å¬Œå¬œå¬Ÿå¬¿
+å­å­å­å­å­å­
+å­å­å­å­å­å­å­å­å­å­å­å­å­å­å­å­å­å­å­å­å­å­å­å­å­å­
+å­ å­¡å­¢å­£å­€å­¥å­Šå­§å­šå­©å­ªå­«å­¬å­­å­®å­¯å­°å­±å­²å­³å­Žå­µå­¶å­·å­žå­¹å­ºå­»å­Œå­œå­Ÿå­¿
+å®å®å®å®å®å®
+å®å®å®å®å®å®å®å®å®å®å®å®å®å®å®å®å®å®å®å®å®å®å®å®å®å®
+å® å®¡å®¢å®£å®€å®¥å®Šå®§å®šå®©å®ªå®«å®¬å®­å®®å®¯å®°å®±å®²å®³å®Žå®µå®¶å®·å®žå®¹å®ºå®»å®Œå®œå®Ÿå®¿
+å¯å¯å¯å¯å¯å¯
+å¯å¯å¯å¯å¯å¯å¯å¯å¯å¯å¯å¯å¯å¯å¯å¯å¯å¯å¯å¯å¯å¯å¯å¯å¯å¯
+å¯ å¯¡å¯¢å¯£å¯€å¯¥å¯Šå¯§å¯šå¯©å¯ªå¯«å¯¬å¯­å¯®å¯¯å¯°å¯±å¯²å¯³å¯Žå¯µå¯¶å¯·å¯žå¯¹å¯ºå¯»å¯Œå¯œå¯Ÿå¯¿
+å°å°å°å°å°å°
+å°å°å°å°å°å°å°å°å°å°å°å°å°å°å°å°å°å°å°å°å°å°å°å°å°å°
+å° å°¡å°¢å°£å°€å°¥å°Šå°§å°šå°©å°ªå°«å°¬å°­å°®å°¯å°°å°±å°²å°³å°Žå°µå°¶å°·å°žå°¹å°ºå°»å°Œå°œå°Ÿå°¿
+å±å±å±å±å±å±
+å±å±å±å±å±å±å±å±å±å±å±å±å±å±å±å±å±å±å±å±å±å±å±å±å±å±
+å± å±¡å±¢å±£å±€å±¥å±Šå±§å±šå±©å±ªå±«å±¬å±­å±®å±¯å±°å±±å±²å±³å±Žå±µå±¶å±·å±žå±¹å±ºå±»å±Œå±œå±Ÿå±¿
+å²å²å²å²å²å²
+å²å²å²å²å²å²å²å²å²å²å²å²å²å²å²å²å²å²å²å²å²å²å²å²å²å²
+å² å²¡å²¢å²£å²€å²¥å²Šå²§å²šå²©å²ªå²«å²¬å²­å²®å²¯å²°å²±å²²å²³å²Žå²µå²¶å²·å²žå²¹å²ºå²»å²Œå²œå²Ÿå²¿
+å³å³å³å³å³å³
+å³å³å³å³å³å³å³å³å³å³å³å³å³å³å³å³å³å³å³å³å³å³å³å³å³å³
+å³ å³¡å³¢å³£å³€å³¥å³Šå³§å³šå³©å³ªå³«å³¬å³­å³®å³¯å³°å³±å³²å³³å³Žå³µå³¶å³·å³žå³¹å³ºå³»å³Œå³œå³Ÿå³¿
+åŽåŽåŽåŽåŽåŽ
+åŽåŽåŽåŽåŽåŽåŽåŽåŽåŽåŽåŽåŽåŽåŽåŽåŽåŽåŽåŽåŽåŽåŽåŽåŽåŽ
+åŽ åŽ¡åŽ¢åŽ£åŽ€åŽ¥åŽŠåŽ§åŽšåŽ©åŽªåŽ«åŽ¬åŽ­åŽ®åŽ¯åŽ°åŽ±åŽ²åŽ³åŽŽåŽµåŽ¶åŽ·åŽžåŽ¹åŽºåŽ»åŽŒåŽœåŽŸåŽ¿
+åµåµåµåµåµåµ
+åµåµåµåµåµåµåµåµåµåµåµåµåµåµåµåµåµåµåµåµåµåµåµåµåµåµ
+åµ åµ¡åµ¢åµ£åµ€åµ¥åµŠåµ§åµšåµ©åµªåµ«åµ¬åµ­åµ®åµ¯åµ°åµ±åµ²åµ³åµŽåµµåµ¶åµ·åµžåµ¹åµºåµ»åµŒåµœåµŸåµ¿
+å¶å¶å¶å¶å¶å¶
+å¶å¶å¶å¶å¶å¶å¶å¶å¶å¶å¶å¶å¶å¶å¶å¶å¶å¶å¶å¶å¶å¶å¶å¶å¶å¶
+å¶ å¶¡å¶¢å¶£å¶€å¶¥å¶Šå¶§å¶šå¶©å¶ªå¶«å¶¬å¶­å¶®å¶¯å¶°å¶±å¶²å¶³å¶Žå¶µå¶¶å¶·å¶žå¶¹å¶ºå¶»å¶Œå¶œå¶Ÿå¶¿
+å·å·å·å·å·å·
+å·å·å·å·å·å·å·å·å·å·å·å·å·å·å·å·å·å·å·å·å·å·å·å·å·å·
+å· å·¡å·¢å·£å·€å·¥å·Šå·§å·šå·©å·ªå·«å·¬å·­å·®å·¯å·°å·±å·²å·³å·Žå·µå·¶å··å·žå·¹å·ºå·»å·Œå·œå·Ÿå·¿
+åžåžåžåžåžåž
+åžåžåžåžåžåžåžåžåžåžåžåžåžåžåžåžåžåžåžåžåžåžåžåžåžåž
+åž åž¡åž¢åž£åž€åž¥åžŠåž§åžšåž©åžªåž«åž¬åž­åž®åž¯åž°åž±åž²åž³åžŽåžµåž¶åž·åžžåž¹åžºåž»åžŒåžœåžŸåž¿
+å¹å¹å¹å¹å¹å¹
+å¹å¹å¹å¹å¹å¹å¹å¹å¹å¹å¹å¹å¹å¹å¹å¹å¹å¹å¹å¹å¹å¹å¹å¹å¹å¹
+å¹ å¹¡å¹¢å¹£å¹€å¹¥å¹Šå¹§å¹šå¹©å¹ªå¹«å¹¬å¹­å¹®å¹¯å¹°å¹±å¹²å¹³å¹Žå¹µå¹¶å¹·å¹žå¹¹å¹ºå¹»å¹Œå¹œå¹Ÿå¹¿
+åºåºåºåºåºåº
+åºåºåºåºåºåºåºåºåºåºåºåºåºåºåºåºåºåºåºåºåºåºåºåºåºåº
+åº åº¡åº¢åº£åº€åº¥åºŠåº§åºšåº©åºªåº«åº¬åº­åº®åº¯åº°åº±åº²åº³åºŽåºµåº¶åº·åºžåº¹åººåº»åºŒåºœåºŸåº¿
+å»å»å»å»å»å»
+å»å»å»å»å»å»å»å»å»å»å»å»å»å»å»å»å»å»å»å»å»å»å»å»å»å»
+å» å»¡å»¢å»£å»€å»¥å»Šå»§å»šå»©å»ªå»«å»¬å»­å»®å»¯å»°å»±å»²å»³å»Žå»µå»¶å»·å»žå»¹å»ºå»»å»Œå»œå»Ÿå»¿
+åŒåŒåŒåŒåŒåŒ
+åŒåŒåŒåŒåŒåŒåŒåŒåŒåŒåŒåŒåŒåŒåŒåŒåŒåŒåŒåŒåŒåŒåŒåŒåŒåŒ
+åŒ åŒ¡åŒ¢åŒ£åŒ€åŒ¥åŒŠåŒ§åŒšåŒ©åŒªåŒ«åŒ¬åŒ­åŒ®åŒ¯åŒ°åŒ±åŒ²åŒ³åŒŽåŒµåŒ¶åŒ·åŒžåŒ¹åŒºåŒ»åŒŒåŒœåŒŸåŒ¿
+åœåœåœåœåœåœ
+åœåœåœåœåœåœåœåœåœåœåœåœåœåœåœåœåœåœåœåœåœåœåœåœåœåœ
+åœ åœ¡åœ¢åœ£åœ€åœ¥åœŠåœ§åœšåœ©åœªåœ«åœ¬åœ­åœ®åœ¯åœ°åœ±åœ²åœ³åœŽåœµåœ¶åœ·åœžåœ¹åœºåœ»åœŒåœœåœŸåœ¿
+åŸåŸåŸåŸåŸåŸ
+åŸåŸåŸåŸåŸåŸåŸåŸåŸåŸåŸåŸåŸåŸåŸåŸåŸåŸåŸåŸåŸåŸåŸåŸåŸåŸ
+åŸ åŸ¡åŸ¢åŸ£åŸ€åŸ¥åŸŠåŸ§åŸšåŸ©åŸªåŸ«åŸ¬åŸ­åŸ®åŸ¯åŸ°åŸ±åŸ²åŸ³åŸŽåŸµåŸ¶åŸ·åŸžåŸ¹åŸºåŸ»åŸŒåŸœåŸŸåŸ¿
+å¿å¿å¿å¿å¿å¿
+å¿å¿å¿å¿å¿å¿å¿å¿å¿å¿å¿å¿å¿å¿å¿å¿å¿å¿å¿å¿å¿å¿å¿å¿å¿å¿
+å¿ å¿¡å¿¢å¿£å¿€å¿¥å¿Šå¿§å¿šå¿©å¿ªå¿«å¿¬å¿­å¿®å¿¯å¿°å¿±å¿²å¿³å¿Žå¿µå¿¶å¿·å¿žå¿¹å¿ºå¿»å¿Œå¿œå¿Ÿå¿¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+æ
+æ
+æ
+æ
+æ
+æ
+
+æ
+æ
+æ
+æ
+æ
+æ
+æ
+æ
+æ
+æ
+æ
+æ
+æ
+æ
+æ
+æ
+æ
+æ
+æ
+æ
+æ
+æ
+æ
+æ
+æ
+æ
+
+æ
+ æ
+¡æ
+¢æ
+£æ
+€æ
+¥æ
+Šæ
+§æ
+šæ
+©æ
+ªæ
+«æ
+¬æ
+­æ
+®æ
+¯æ
+°æ
+±æ
+²æ
+³æ
+Žæ
+µæ
+¶æ
+·æ
+žæ
+¹æ
+ºæ
+»æ
+Œæ
+œæ
+Ÿæ
+¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+ææææææ
+ææææææææææææææææææææææææææ
+æ æ¡æ¢æ£æ€æ¥æŠæ§æšæ©æªæ«æ¬æ­æ®æ¯æ°æ±æ²æ³æŽæµæ¶æ·æžæ¹æºæ»æŒæœæŸæ¿
+æ æ æ æ æ æ 
+æ æ æ æ æ æ æ æ æ æ æ æ æ æ æ æ æ æ æ æ æ æ æ æ æ æ 
+æ  æ ¡æ ¢æ £æ €æ ¥æ Šæ §æ šæ ©æ ªæ «æ ¬æ ­æ ®æ ¯æ °æ ±æ ²æ ³æ Žæ µæ ¶æ ·æ žæ ¹æ ºæ »æ Œæ œæ Ÿæ ¿
+æ¡æ¡æ¡æ¡æ¡æ¡
+æ¡æ¡æ¡æ¡æ¡æ¡æ¡æ¡æ¡æ¡æ¡æ¡æ¡æ¡æ¡æ¡æ¡æ¡æ¡æ¡æ¡æ¡æ¡æ¡æ¡æ¡
+æ¡ æ¡¡æ¡¢æ¡£æ¡€æ¡¥æ¡Šæ¡§æ¡šæ¡©æ¡ªæ¡«æ¡¬æ¡­æ¡®æ¡¯æ¡°æ¡±æ¡²æ¡³æ¡Žæ¡µæ¡¶æ¡·æ¡žæ¡¹æ¡ºæ¡»æ¡Œæ¡œæ¡Ÿæ¡¿
+æ¢æ¢æ¢æ¢æ¢æ¢
+æ¢æ¢æ¢æ¢æ¢æ¢æ¢æ¢æ¢æ¢æ¢æ¢æ¢æ¢æ¢æ¢æ¢æ¢æ¢æ¢æ¢æ¢æ¢æ¢æ¢æ¢
+æ¢ æ¢¡æ¢¢æ¢£æ¢€æ¢¥æ¢Šæ¢§æ¢šæ¢©æ¢ªæ¢«æ¢¬æ¢­æ¢®æ¢¯æ¢°æ¢±æ¢²æ¢³æ¢Žæ¢µæ¢¶æ¢·æ¢žæ¢¹æ¢ºæ¢»æ¢Œæ¢œæ¢Ÿæ¢¿
+æ£æ£æ£æ£æ£æ£
+æ£æ£æ£æ£æ£æ£æ£æ£æ£æ£æ£æ£æ£æ£æ£æ£æ£æ£æ£æ£æ£æ£æ£æ£æ£æ£
+æ£ æ£¡æ£¢æ££æ£€æ£¥æ£Šæ£§æ£šæ£©æ£ªæ£«æ£¬æ£­æ£®æ£¯æ£°æ£±æ£²æ£³æ£Žæ£µæ£¶æ£·æ£žæ£¹æ£ºæ£»æ£Œæ£œæ£Ÿæ£¿
+æ€æ€æ€æ€æ€æ€
+æ€æ€æ€æ€æ€æ€æ€æ€æ€æ€æ€æ€æ€æ€æ€æ€æ€æ€æ€æ€æ€æ€æ€æ€æ€æ€
+æ€ æ€¡æ€¢æ€£æ€€æ€¥æ€Šæ€§æ€šæ€©æ€ªæ€«æ€¬æ€­æ€®æ€¯æ€°æ€±æ€²æ€³æ€Žæ€µæ€¶æ€·æ€žæ€¹æ€ºæ€»æ€Œæ€œæ€Ÿæ€¿
+æ¥æ¥æ¥æ¥æ¥æ¥
+æ¥æ¥æ¥æ¥æ¥æ¥æ¥æ¥æ¥æ¥æ¥æ¥æ¥æ¥æ¥æ¥æ¥æ¥æ¥æ¥æ¥æ¥æ¥æ¥æ¥æ¥
+æ¥ æ¥¡æ¥¢æ¥£æ¥€æ¥¥æ¥Šæ¥§æ¥šæ¥©æ¥ªæ¥«æ¥¬æ¥­æ¥®æ¥¯æ¥°æ¥±æ¥²æ¥³æ¥Žæ¥µæ¥¶æ¥·æ¥žæ¥¹æ¥ºæ¥»æ¥Œæ¥œæ¥Ÿæ¥¿
+æŠæŠæŠæŠæŠæŠ
+æŠæŠæŠæŠæŠæŠæŠæŠæŠæŠæŠæŠæŠæŠæŠæŠæŠæŠæŠæŠæŠæŠæŠæŠæŠæŠ
+æŠ æŠ¡æŠ¢æŠ£æŠ€æŠ¥æŠŠæŠ§æŠšæŠ©æŠªæŠ«æŠ¬æŠ­æŠ®æŠ¯æŠ°æŠ±æŠ²æŠ³æŠŽæŠµæŠ¶æŠ·æŠžæŠ¹æŠºæŠ»æŠŒæŠœæŠŸæŠ¿
+æ§æ§æ§æ§æ§æ§
+æ§æ§æ§æ§æ§æ§æ§æ§æ§æ§æ§æ§æ§æ§æ§æ§æ§æ§æ§æ§æ§æ§æ§æ§æ§æ§
+æ§ æ§¡æ§¢æ§£æ§€æ§¥æ§Šæ§§æ§šæ§©æ§ªæ§«æ§¬æ§­æ§®æ§¯æ§°æ§±æ§²æ§³æ§Žæ§µæ§¶æ§·æ§žæ§¹æ§ºæ§»æ§Œæ§œæ§Ÿæ§¿
+æšæšæšæšæšæš
+æšæšæšæšæšæšæšæšæšæšæšæšæšæšæšæšæšæšæšæšæšæšæšæšæšæš
+æš æš¡æš¢æš£æš€æš¥æšŠæš§æššæš©æšªæš«æš¬æš­æš®æš¯æš°æš±æš²æš³æšŽæšµæš¶æš·æšžæš¹æšºæš»æšŒæšœæšŸæš¿
+æ©æ©æ©æ©æ©æ©
+æ©æ©æ©æ©æ©æ©æ©æ©æ©æ©æ©æ©æ©æ©æ©æ©æ©æ©æ©æ©æ©æ©æ©æ©æ©æ©
+æ© æ©¡æ©¢æ©£æ©€æ©¥æ©Šæ©§æ©šæ©©æ©ªæ©«æ©¬æ©­æ©®æ©¯æ©°æ©±æ©²æ©³æ©Žæ©µæ©¶æ©·æ©žæ©¹æ©ºæ©»æ©Œæ©œæ©Ÿæ©¿
+æªæªæªæªæªæª
+æªæªæªæªæªæªæªæªæªæªæªæªæªæªæªæªæªæªæªæªæªæªæªæªæªæª
+æª æª¡æª¢æª£æª€æª¥æªŠæª§æªšæª©æªªæª«æª¬æª­æª®æª¯æª°æª±æª²æª³æªŽæªµæª¶æª·æªžæª¹æªºæª»æªŒæªœæªŸæª¿
+æ«æ«æ«æ«æ«æ«
+æ«æ«æ«æ«æ«æ«æ«æ«æ«æ«æ«æ«æ«æ«æ«æ«æ«æ«æ«æ«æ«æ«æ«æ«æ«æ«
+æ« æ«¡æ«¢æ«£æ«€æ«¥æ«Šæ«§æ«šæ«©æ«ªæ««æ«¬æ«­æ«®æ«¯æ«°æ«±æ«²æ«³æ«Žæ«µæ«¶æ«·æ«žæ«¹æ«ºæ«»æ«Œæ«œæ«Ÿæ«¿
+æ¬æ¬æ¬æ¬æ¬æ¬
+æ¬æ¬æ¬æ¬æ¬æ¬æ¬æ¬æ¬æ¬æ¬æ¬æ¬æ¬æ¬æ¬æ¬æ¬æ¬æ¬æ¬æ¬æ¬æ¬æ¬æ¬
+æ¬ æ¬¡æ¬¢æ¬£æ¬€æ¬¥æ¬Šæ¬§æ¬šæ¬©æ¬ªæ¬«æ¬¬æ¬­æ¬®æ¬¯æ¬°æ¬±æ¬²æ¬³æ¬Žæ¬µæ¬¶æ¬·æ¬žæ¬¹æ¬ºæ¬»æ¬Œæ¬œæ¬Ÿæ¬¿
+æ­æ­æ­æ­æ­æ­
+æ­æ­æ­æ­æ­æ­æ­æ­æ­æ­æ­æ­æ­æ­æ­æ­æ­æ­æ­æ­æ­æ­æ­æ­æ­æ­
+æ­ æ­¡æ­¢æ­£æ­€æ­¥æ­Šæ­§æ­šæ­©æ­ªæ­«æ­¬æ­­æ­®æ­¯æ­°æ­±æ­²æ­³æ­Žæ­µæ­¶æ­·æ­žæ­¹æ­ºæ­»æ­Œæ­œæ­Ÿæ­¿
+æ®æ®æ®æ®æ®æ®
+æ®æ®æ®æ®æ®æ®æ®æ®æ®æ®æ®æ®æ®æ®æ®æ®æ®æ®æ®æ®æ®æ®æ®æ®æ®æ®
+æ® æ®¡æ®¢æ®£æ®€æ®¥æ®Šæ®§æ®šæ®©æ®ªæ®«æ®¬æ®­æ®®æ®¯æ®°æ®±æ®²æ®³æ®Žæ®µæ®¶æ®·æ®žæ®¹æ®ºæ®»æ®Œæ®œæ®Ÿæ®¿
+æ¯æ¯æ¯æ¯æ¯æ¯
+æ¯æ¯æ¯æ¯æ¯æ¯æ¯æ¯æ¯æ¯æ¯æ¯æ¯æ¯æ¯æ¯æ¯æ¯æ¯æ¯æ¯æ¯æ¯æ¯æ¯æ¯
+æ¯ æ¯¡æ¯¢æ¯£æ¯€æ¯¥æ¯Šæ¯§æ¯šæ¯©æ¯ªæ¯«æ¯¬æ¯­æ¯®æ¯¯æ¯°æ¯±æ¯²æ¯³æ¯Žæ¯µæ¯¶æ¯·æ¯žæ¯¹æ¯ºæ¯»æ¯Œæ¯œæ¯Ÿæ¯¿
+æ°æ°æ°æ°æ°æ°
+æ°æ°æ°æ°æ°æ°æ°æ°æ°æ°æ°æ°æ°æ°æ°æ°æ°æ°æ°æ°æ°æ°æ°æ°æ°æ°
+æ° æ°¡æ°¢æ°£æ°€æ°¥æ°Šæ°§æ°šæ°©æ°ªæ°«æ°¬æ°­æ°®æ°¯æ°°æ°±æ°²æ°³æ°Žæ°µæ°¶æ°·æ°žæ°¹æ°ºæ°»æ°Œæ°œæ°Ÿæ°¿
+æ±æ±æ±æ±æ±æ±
+æ±æ±æ±æ±æ±æ±æ±æ±æ±æ±æ±æ±æ±æ±æ±æ±æ±æ±æ±æ±æ±æ±æ±æ±æ±æ±
+æ± æ±¡æ±¢æ±£æ±€æ±¥æ±Šæ±§æ±šæ±©æ±ªæ±«æ±¬æ±­æ±®æ±¯æ±°æ±±æ±²æ±³æ±Žæ±µæ±¶æ±·æ±žæ±¹æ±ºæ±»æ±Œæ±œæ±Ÿæ±¿
+æ²æ²æ²æ²æ²æ²
+æ²æ²æ²æ²æ²æ²æ²æ²æ²æ²æ²æ²æ²æ²æ²æ²æ²æ²æ²æ²æ²æ²æ²æ²æ²æ²
+æ² æ²¡æ²¢æ²£æ²€æ²¥æ²Šæ²§æ²šæ²©æ²ªæ²«æ²¬æ²­æ²®æ²¯æ²°æ²±æ²²æ²³æ²Žæ²µæ²¶æ²·æ²žæ²¹æ²ºæ²»æ²Œæ²œæ²Ÿæ²¿
+æ³æ³æ³æ³æ³æ³
+æ³æ³æ³æ³æ³æ³æ³æ³æ³æ³æ³æ³æ³æ³æ³æ³æ³æ³æ³æ³æ³æ³æ³æ³æ³æ³
+æ³ æ³¡æ³¢æ³£æ³€æ³¥æ³Šæ³§æ³šæ³©æ³ªæ³«æ³¬æ³­æ³®æ³¯æ³°æ³±æ³²æ³³æ³Žæ³µæ³¶æ³·æ³žæ³¹æ³ºæ³»æ³Œæ³œæ³Ÿæ³¿
+æŽæŽæŽæŽæŽæŽ
+æŽæŽæŽæŽæŽæŽæŽæŽæŽæŽæŽæŽæŽæŽæŽæŽæŽæŽæŽæŽæŽæŽæŽæŽæŽæŽ
+æŽ æŽ¡æŽ¢æŽ£æŽ€æŽ¥æŽŠæŽ§æŽšæŽ©æŽªæŽ«æŽ¬æŽ­æŽ®æŽ¯æŽ°æŽ±æŽ²æŽ³æŽŽæŽµæŽ¶æŽ·æŽžæŽ¹æŽºæŽ»æŽŒæŽœæŽŸæŽ¿
+æµæµæµæµæµæµ
+æµæµæµæµæµæµæµæµæµæµæµæµæµæµæµæµæµæµæµæµæµæµæµæµæµæµ
+æµ æµ¡æµ¢æµ£æµ€æµ¥æµŠæµ§æµšæµ©æµªæµ«æµ¬æµ­æµ®æµ¯æµ°æµ±æµ²æµ³æµŽæµµæµ¶æµ·æµžæµ¹æµºæµ»æµŒæµœæµŸæµ¿
+æ¶æ¶æ¶æ¶æ¶æ¶
+æ¶æ¶æ¶æ¶æ¶æ¶æ¶æ¶æ¶æ¶æ¶æ¶æ¶æ¶æ¶æ¶æ¶æ¶æ¶æ¶æ¶æ¶æ¶æ¶æ¶æ¶
+æ¶ æ¶¡æ¶¢æ¶£æ¶€æ¶¥æ¶Šæ¶§æ¶šæ¶©æ¶ªæ¶«æ¶¬æ¶­æ¶®æ¶¯æ¶°æ¶±æ¶²æ¶³æ¶Žæ¶µæ¶¶æ¶·æ¶žæ¶¹æ¶ºæ¶»æ¶Œæ¶œæ¶Ÿæ¶¿
+æ·æ·æ·æ·æ·æ·
+æ·æ·æ·æ·æ·æ·æ·æ·æ·æ·æ·æ·æ·æ·æ·æ·æ·æ·æ·æ·æ·æ·æ·æ·æ·æ·
+æ· æ·¡æ·¢æ·£æ·€æ·¥æ·Šæ·§æ·šæ·©æ·ªæ·«æ·¬æ·­æ·®æ·¯æ·°æ·±æ·²æ·³æ·Žæ·µæ·¶æ··æ·žæ·¹æ·ºæ·»æ·Œæ·œæ·Ÿæ·¿
+æžæžæžæžæžæž
+æžæžæžæžæžæžæžæžæžæžæžæžæžæžæžæžæžæžæžæžæžæžæžæžæžæž
+æž æž¡æž¢æž£æž€æž¥æžŠæž§æžšæž©æžªæž«æž¬æž­æž®æž¯æž°æž±æž²æž³æžŽæžµæž¶æž·æžžæž¹æžºæž»æžŒæžœæžŸæž¿
+æ¹æ¹æ¹æ¹æ¹æ¹
+æ¹æ¹æ¹æ¹æ¹æ¹æ¹æ¹æ¹æ¹æ¹æ¹æ¹æ¹æ¹æ¹æ¹æ¹æ¹æ¹æ¹æ¹æ¹æ¹æ¹æ¹
+æ¹ æ¹¡æ¹¢æ¹£æ¹€æ¹¥æ¹Šæ¹§æ¹šæ¹©æ¹ªæ¹«æ¹¬æ¹­æ¹®æ¹¯æ¹°æ¹±æ¹²æ¹³æ¹Žæ¹µæ¹¶æ¹·æ¹žæ¹¹æ¹ºæ¹»æ¹Œæ¹œæ¹Ÿæ¹¿
+æºæºæºæºæºæº
+æºæºæºæºæºæºæºæºæºæºæºæºæºæºæºæºæºæºæºæºæºæºæºæºæºæº
+æº æº¡æº¢æº£æº€æº¥æºŠæº§æºšæº©æºªæº«æº¬æº­æº®æº¯æº°æº±æº²æº³æºŽæºµæº¶æº·æºžæº¹æººæº»æºŒæºœæºŸæº¿
+æ»æ»æ»æ»æ»æ»
+æ»æ»æ»æ»æ»æ»æ»æ»æ»æ»æ»æ»æ»æ»æ»æ»æ»æ»æ»æ»æ»æ»æ»æ»æ»æ»
+æ» æ»¡æ»¢æ»£æ»€æ»¥æ»Šæ»§æ»šæ»©æ»ªæ»«æ»¬æ»­æ»®æ»¯æ»°æ»±æ»²æ»³æ»Žæ»µæ»¶æ»·æ»žæ»¹æ»ºæ»»æ»Œæ»œæ»Ÿæ»¿
+æŒæŒæŒæŒæŒæŒ
+æŒæŒæŒæŒæŒæŒæŒæŒæŒæŒæŒæŒæŒæŒæŒæŒæŒæŒæŒæŒæŒæŒæŒæŒæŒæŒ
+æŒ æŒ¡æŒ¢æŒ£æŒ€æŒ¥æŒŠæŒ§æŒšæŒ©æŒªæŒ«æŒ¬æŒ­æŒ®æŒ¯æŒ°æŒ±æŒ²æŒ³æŒŽæŒµæŒ¶æŒ·æŒžæŒ¹æŒºæŒ»æŒŒæŒœæŒŸæŒ¿
+æœæœæœæœæœæœ
+æœæœæœæœæœæœæœæœæœæœæœæœæœæœæœæœæœæœæœæœæœæœæœæœæœæœ
+æœ æœ¡æœ¢æœ£æœ€æœ¥æœŠæœ§æœšæœ©æœªæœ«æœ¬æœ­æœ®æœ¯æœ°æœ±æœ²æœ³æœŽæœµæœ¶æœ·æœžæœ¹æœºæœ»æœŒæœœæœŸæœ¿
+æŸæŸæŸæŸæŸæŸ
+æŸæŸæŸæŸæŸæŸæŸæŸæŸæŸæŸæŸæŸæŸæŸæŸæŸæŸæŸæŸæŸæŸæŸæŸæŸæŸ
+æŸ æŸ¡æŸ¢æŸ£æŸ€æŸ¥æŸŠæŸ§æŸšæŸ©æŸªæŸ«æŸ¬æŸ­æŸ®æŸ¯æŸ°æŸ±æŸ²æŸ³æŸŽæŸµæŸ¶æŸ·æŸžæŸ¹æŸºæŸ»æŸŒæŸœæŸŸæŸ¿
+æ¿æ¿æ¿æ¿æ¿æ¿
+æ¿æ¿æ¿æ¿æ¿æ¿æ¿æ¿æ¿æ¿æ¿æ¿æ¿æ¿æ¿æ¿æ¿æ¿æ¿æ¿æ¿æ¿æ¿æ¿æ¿æ¿
+æ¿ æ¿¡æ¿¢æ¿£æ¿€æ¿¥æ¿Šæ¿§æ¿šæ¿©æ¿ªæ¿«æ¿¬æ¿­æ¿®æ¿¯æ¿°æ¿±æ¿²æ¿³æ¿Žæ¿µæ¿¶æ¿·æ¿žæ¿¹æ¿ºæ¿»æ¿Œæ¿œæ¿Ÿæ¿¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+ç
+ç
+ç
+ç
+ç
+ç
+
+ç
+ç
+ç
+ç
+ç
+ç
+ç
+ç
+ç
+ç
+ç
+ç
+ç
+ç
+ç
+ç
+ç
+ç
+ç
+ç
+ç
+ç
+ç
+ç
+ç
+ç
+
+ç
+ ç
+¡ç
+¢ç
+£ç
+€ç
+¥ç
+Šç
+§ç
+šç
+©ç
+ªç
+«ç
+¬ç
+­ç
+®ç
+¯ç
+°ç
+±ç
+²ç
+³ç
+Žç
+µç
+¶ç
+·ç
+žç
+¹ç
+ºç
+»ç
+Œç
+œç
+Ÿç
+¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+çççççç
+çççççççççççççççççççççççççç
+ç ç¡ç¢ç£ç€ç¥çŠç§çšç©çªç«ç¬ç­ç®ç¯ç°ç±ç²ç³çŽçµç¶ç·çžç¹çºç»çŒçœçŸç¿
+ç ç ç ç ç ç 
+ç ç ç ç ç ç ç ç ç ç ç ç ç ç ç ç ç ç ç ç ç ç ç ç ç ç 
+ç  ç ¡ç ¢ç £ç €ç ¥ç Šç §ç šç ©ç ªç «ç ¬ç ­ç ®ç ¯ç °ç ±ç ²ç ³ç Žç µç ¶ç ·ç žç ¹ç ºç »ç Œç œç Ÿç ¿
+ç¡ç¡ç¡ç¡ç¡ç¡
+ç¡ç¡ç¡ç¡ç¡ç¡ç¡ç¡ç¡ç¡ç¡ç¡ç¡ç¡ç¡ç¡ç¡ç¡ç¡ç¡ç¡ç¡ç¡ç¡ç¡ç¡
+ç¡ ç¡¡ç¡¢ç¡£ç¡€ç¡¥ç¡Šç¡§ç¡šç¡©ç¡ªç¡«ç¡¬ç¡­ç¡®ç¡¯ç¡°ç¡±ç¡²ç¡³ç¡Žç¡µç¡¶ç¡·ç¡žç¡¹ç¡ºç¡»ç¡Œç¡œç¡Ÿç¡¿
+ç¢ç¢ç¢ç¢ç¢ç¢
+ç¢ç¢ç¢ç¢ç¢ç¢ç¢ç¢ç¢ç¢ç¢ç¢ç¢ç¢ç¢ç¢ç¢ç¢ç¢ç¢ç¢ç¢ç¢ç¢ç¢ç¢
+ç¢ ç¢¡ç¢¢ç¢£ç¢€ç¢¥ç¢Šç¢§ç¢šç¢©ç¢ªç¢«ç¢¬ç¢­ç¢®ç¢¯ç¢°ç¢±ç¢²ç¢³ç¢Žç¢µç¢¶ç¢·ç¢žç¢¹ç¢ºç¢»ç¢Œç¢œç¢Ÿç¢¿
+ç£ç£ç£ç£ç£ç£
+ç£ç£ç£ç£ç£ç£ç£ç£ç£ç£ç£ç£ç£ç£ç£ç£ç£ç£ç£ç£ç£ç£ç£ç£ç£ç£
+ç£ ç£¡ç£¢ç££ç£€ç£¥ç£Šç£§ç£šç£©ç£ªç£«ç£¬ç£­ç£®ç£¯ç£°ç£±ç£²ç£³ç£Žç£µç£¶ç£·ç£žç£¹ç£ºç£»ç£Œç£œç£Ÿç£¿
+ç€ç€ç€ç€ç€ç€
+ç€ç€ç€ç€ç€ç€ç€ç€ç€ç€ç€ç€ç€ç€ç€ç€ç€ç€ç€ç€ç€ç€ç€ç€ç€ç€
+ç€ ç€¡ç€¢ç€£ç€€ç€¥ç€Šç€§ç€šç€©ç€ªç€«ç€¬ç€­ç€®ç€¯ç€°ç€±ç€²ç€³ç€Žç€µç€¶ç€·ç€žç€¹ç€ºç€»ç€Œç€œç€Ÿç€¿
+ç¥ç¥ç¥ç¥ç¥ç¥
+ç¥ç¥ç¥ç¥ç¥ç¥ç¥ç¥ç¥ç¥ç¥ç¥ç¥ç¥ç¥ç¥ç¥ç¥ç¥ç¥ç¥ç¥ç¥ç¥ç¥ç¥
+ç¥ ç¥¡ç¥¢ç¥£ç¥€ç¥¥ç¥Šç¥§ç¥šç¥©ç¥ªç¥«ç¥¬ç¥­ç¥®ç¥¯ç¥°ç¥±ç¥²ç¥³ç¥Žç¥µç¥¶ç¥·ç¥žç¥¹ç¥ºç¥»ç¥Œç¥œç¥Ÿç¥¿
+çŠçŠçŠçŠçŠçŠ
+çŠçŠçŠçŠçŠçŠçŠçŠçŠçŠçŠçŠçŠçŠçŠçŠçŠçŠçŠçŠçŠçŠçŠçŠçŠçŠ
+çŠ çŠ¡çŠ¢çŠ£çŠ€çŠ¥çŠŠçŠ§çŠšçŠ©çŠªçŠ«çŠ¬çŠ­çŠ®çŠ¯çŠ°çŠ±çŠ²çŠ³çŠŽçŠµçŠ¶çŠ·çŠžçŠ¹çŠºçŠ»çŠŒçŠœçŠŸçŠ¿
+ç§ç§ç§ç§ç§ç§
+ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§
+ç§ ç§¡ç§¢ç§£ç§€ç§¥ç§Šç§§ç§šç§©ç§ªç§«ç§¬ç§­ç§®ç§¯ç§°ç§±ç§²ç§³ç§Žç§µç§¶ç§·ç§žç§¹ç§ºç§»ç§Œç§œç§Ÿç§¿
+çšçšçšçšçšçš
+çšçšçšçšçšçšçšçšçšçšçšçšçšçšçšçšçšçšçšçšçšçšçšçšçšçš
+çš çš¡çš¢çš£çš€çš¥çšŠçš§çššçš©çšªçš«çš¬çš­çš®çš¯çš°çš±çš²çš³çšŽçšµçš¶çš·çšžçš¹çšºçš»çšŒçšœçšŸçš¿
+ç©ç©ç©ç©ç©ç©
+ç©ç©ç©ç©ç©ç©ç©ç©ç©ç©ç©ç©ç©ç©ç©ç©ç©ç©ç©ç©ç©ç©ç©ç©ç©ç©
+ç© ç©¡ç©¢ç©£ç©€ç©¥ç©Šç©§ç©šç©©ç©ªç©«ç©¬ç©­ç©®ç©¯ç©°ç©±ç©²ç©³ç©Žç©µç©¶ç©·ç©žç©¹ç©ºç©»ç©Œç©œç©Ÿç©¿
+çªçªçªçªçªçª
+çªçªçªçªçªçªçªçªçªçªçªçªçªçªçªçªçªçªçªçªçªçªçªçªçªçª
+çª çª¡çª¢çª£çª€çª¥çªŠçª§çªšçª©çªªçª«çª¬çª­çª®çª¯çª°çª±çª²çª³çªŽçªµçª¶çª·çªžçª¹çªºçª»çªŒçªœçªŸçª¿
+ç«ç«ç«ç«ç«ç«
+ç«ç«ç«ç«ç«ç«ç«ç«ç«ç«ç«ç«ç«ç«ç«ç«ç«ç«ç«ç«ç«ç«ç«ç«ç«ç«
+ç« ç«¡ç«¢ç«£ç«€ç«¥ç«Šç«§ç«šç«©ç«ªç««ç«¬ç«­ç«®ç«¯ç«°ç«±ç«²ç«³ç«Žç«µç«¶ç«·ç«žç«¹ç«ºç«»ç«Œç«œç«Ÿç«¿
+ç¬ç¬ç¬ç¬ç¬ç¬
+ç¬ç¬ç¬ç¬ç¬ç¬ç¬ç¬ç¬ç¬ç¬ç¬ç¬ç¬ç¬ç¬ç¬ç¬ç¬ç¬ç¬ç¬ç¬ç¬ç¬ç¬
+ç¬ ç¬¡ç¬¢ç¬£ç¬€ç¬¥ç¬Šç¬§ç¬šç¬©ç¬ªç¬«ç¬¬ç¬­ç¬®ç¬¯ç¬°ç¬±ç¬²ç¬³ç¬Žç¬µç¬¶ç¬·ç¬žç¬¹ç¬ºç¬»ç¬Œç¬œç¬Ÿç¬¿
+ç­ç­ç­ç­ç­ç­
+ç­ç­ç­ç­ç­ç­ç­ç­ç­ç­ç­ç­ç­ç­ç­ç­ç­ç­ç­ç­ç­ç­ç­ç­ç­ç­
+ç­ ç­¡ç­¢ç­£ç­€ç­¥ç­Šç­§ç­šç­©ç­ªç­«ç­¬ç­­ç­®ç­¯ç­°ç­±ç­²ç­³ç­Žç­µç­¶ç­·ç­žç­¹ç­ºç­»ç­Œç­œç­Ÿç­¿
+ç®ç®ç®ç®ç®ç®
+ç®ç®ç®ç®ç®ç®ç®ç®ç®ç®ç®ç®ç®ç®ç®ç®ç®ç®ç®ç®ç®ç®ç®ç®ç®ç®
+ç® ç®¡ç®¢ç®£ç®€ç®¥ç®Šç®§ç®šç®©ç®ªç®«ç®¬ç®­ç®®ç®¯ç®°ç®±ç®²ç®³ç®Žç®µç®¶ç®·ç®žç®¹ç®ºç®»ç®Œç®œç®Ÿç®¿
+ç¯ç¯ç¯ç¯ç¯ç¯
+ç¯ç¯ç¯ç¯ç¯ç¯ç¯ç¯ç¯ç¯ç¯ç¯ç¯ç¯ç¯ç¯ç¯ç¯ç¯ç¯ç¯ç¯ç¯ç¯ç¯ç¯
+ç¯ ç¯¡ç¯¢ç¯£ç¯€ç¯¥ç¯Šç¯§ç¯šç¯©ç¯ªç¯«ç¯¬ç¯­ç¯®ç¯¯ç¯°ç¯±ç¯²ç¯³ç¯Žç¯µç¯¶ç¯·ç¯žç¯¹ç¯ºç¯»ç¯Œç¯œç¯Ÿç¯¿
+ç°ç°ç°ç°ç°ç°
+ç°ç°ç°ç°ç°ç°ç°ç°ç°ç°ç°ç°ç°ç°ç°ç°ç°ç°ç°ç°ç°ç°ç°ç°ç°ç°
+ç° ç°¡ç°¢ç°£ç°€ç°¥ç°Šç°§ç°šç°©ç°ªç°«ç°¬ç°­ç°®ç°¯ç°°ç°±ç°²ç°³ç°Žç°µç°¶ç°·ç°žç°¹ç°ºç°»ç°Œç°œç°Ÿç°¿
+ç±ç±ç±ç±ç±ç±
+ç±ç±ç±ç±ç±ç±ç±ç±ç±ç±ç±ç±ç±ç±ç±ç±ç±ç±ç±ç±ç±ç±ç±ç±ç±ç±
+ç± ç±¡ç±¢ç±£ç±€ç±¥ç±Šç±§ç±šç±©ç±ªç±«ç±¬ç±­ç±®ç±¯ç±°ç±±ç±²ç±³ç±Žç±µç±¶ç±·ç±žç±¹ç±ºç±»ç±Œç±œç±Ÿç±¿
+ç²ç²ç²ç²ç²ç²
+ç²ç²ç²ç²ç²ç²ç²ç²ç²ç²ç²ç²ç²ç²ç²ç²ç²ç²ç²ç²ç²ç²ç²ç²ç²ç²
+ç² ç²¡ç²¢ç²£ç²€ç²¥ç²Šç²§ç²šç²©ç²ªç²«ç²¬ç²­ç²®ç²¯ç²°ç²±ç²²ç²³ç²Žç²µç²¶ç²·ç²žç²¹ç²ºç²»ç²Œç²œç²Ÿç²¿
+ç³ç³ç³ç³ç³ç³
+ç³ç³ç³ç³ç³ç³ç³ç³ç³ç³ç³ç³ç³ç³ç³ç³ç³ç³ç³ç³ç³ç³ç³ç³ç³ç³
+ç³ ç³¡ç³¢ç³£ç³€ç³¥ç³Šç³§ç³šç³©ç³ªç³«ç³¬ç³­ç³®ç³¯ç³°ç³±ç³²ç³³ç³Žç³µç³¶ç³·ç³žç³¹ç³ºç³»ç³Œç³œç³Ÿç³¿
+çŽçŽçŽçŽçŽçŽ
+çŽçŽçŽçŽçŽçŽçŽçŽçŽçŽçŽçŽçŽçŽçŽçŽçŽçŽçŽçŽçŽçŽçŽçŽçŽçŽ
+çŽ çŽ¡çŽ¢çŽ£çŽ€çŽ¥çŽŠçŽ§çŽšçŽ©çŽªçŽ«çŽ¬çŽ­çŽ®çŽ¯çŽ°çŽ±çŽ²çŽ³çŽŽçŽµçŽ¶çŽ·çŽžçŽ¹çŽºçŽ»çŽŒçŽœçŽŸçŽ¿
+çµçµçµçµçµçµ
+çµçµçµçµçµçµçµçµçµçµçµçµçµçµçµçµçµçµçµçµçµçµçµçµçµçµ
+çµ çµ¡çµ¢çµ£çµ€çµ¥çµŠçµ§çµšçµ©çµªçµ«çµ¬çµ­çµ®çµ¯çµ°çµ±çµ²çµ³çµŽçµµçµ¶çµ·çµžçµ¹çµºçµ»çµŒçµœçµŸçµ¿
+ç¶ç¶ç¶ç¶ç¶ç¶
+ç¶ç¶ç¶ç¶ç¶ç¶ç¶ç¶ç¶ç¶ç¶ç¶ç¶ç¶ç¶ç¶ç¶ç¶ç¶ç¶ç¶ç¶ç¶ç¶ç¶ç¶
+ç¶ ç¶¡ç¶¢ç¶£ç¶€ç¶¥ç¶Šç¶§ç¶šç¶©ç¶ªç¶«ç¶¬ç¶­ç¶®ç¶¯ç¶°ç¶±ç¶²ç¶³ç¶Žç¶µç¶¶ç¶·ç¶žç¶¹ç¶ºç¶»ç¶Œç¶œç¶Ÿç¶¿
+ç·ç·ç·ç·ç·ç·
+ç·ç·ç·ç·ç·ç·ç·ç·ç·ç·ç·ç·ç·ç·ç·ç·ç·ç·ç·ç·ç·ç·ç·ç·ç·ç·
+ç· ç·¡ç·¢ç·£ç·€ç·¥ç·Šç·§ç·šç·©ç·ªç·«ç·¬ç·­ç·®ç·¯ç·°ç·±ç·²ç·³ç·Žç·µç·¶ç··ç·žç·¹ç·ºç·»ç·Œç·œç·Ÿç·¿
+çžçžçžçžçžçž
+çžçžçžçžçžçžçžçžçžçžçžçžçžçžçžçžçžçžçžçžçžçžçžçžçžçž
+çž çž¡çž¢çž£çž€çž¥çžŠçž§çžšçž©çžªçž«çž¬çž­çž®çž¯çž°çž±çž²çž³çžŽçžµçž¶çž·çžžçž¹çžºçž»çžŒçžœçžŸçž¿
+ç¹ç¹ç¹ç¹ç¹ç¹
+ç¹ç¹ç¹ç¹ç¹ç¹ç¹ç¹ç¹ç¹ç¹ç¹ç¹ç¹ç¹ç¹ç¹ç¹ç¹ç¹ç¹ç¹ç¹ç¹ç¹ç¹
+ç¹ ç¹¡ç¹¢ç¹£ç¹€ç¹¥ç¹Šç¹§ç¹šç¹©ç¹ªç¹«ç¹¬ç¹­ç¹®ç¹¯ç¹°ç¹±ç¹²ç¹³ç¹Žç¹µç¹¶ç¹·ç¹žç¹¹ç¹ºç¹»ç¹Œç¹œç¹Ÿç¹¿
+çºçºçºçºçºçº
+çºçºçºçºçºçºçºçºçºçºçºçºçºçºçºçºçºçºçºçºçºçºçºçºçºçº
+çº çº¡çº¢çº£çº€çº¥çºŠçº§çºšçº©çºªçº«çº¬çº­çº®çº¯çº°çº±çº²çº³çºŽçºµçº¶çº·çºžçº¹çººçº»çºŒçºœçºŸçº¿
+ç»ç»ç»ç»ç»ç»
+ç»ç»ç»ç»ç»ç»ç»ç»ç»ç»ç»ç»ç»ç»ç»ç»ç»ç»ç»ç»ç»ç»ç»ç»ç»ç»
+ç» ç»¡ç»¢ç»£ç»€ç»¥ç»Šç»§ç»šç»©ç»ªç»«ç»¬ç»­ç»®ç»¯ç»°ç»±ç»²ç»³ç»Žç»µç»¶ç»·ç»žç»¹ç»ºç»»ç»Œç»œç»Ÿç»¿
+çŒçŒçŒçŒçŒçŒ
+çŒçŒçŒçŒçŒçŒçŒçŒçŒçŒçŒçŒçŒçŒçŒçŒçŒçŒçŒçŒçŒçŒçŒçŒçŒçŒ
+çŒ çŒ¡çŒ¢çŒ£çŒ€çŒ¥çŒŠçŒ§çŒšçŒ©çŒªçŒ«çŒ¬çŒ­çŒ®çŒ¯çŒ°çŒ±çŒ²çŒ³çŒŽçŒµçŒ¶çŒ·çŒžçŒ¹çŒºçŒ»çŒŒçŒœçŒŸçŒ¿
+çœçœçœçœçœçœ
+çœçœçœçœçœçœçœçœçœçœçœçœçœçœçœçœçœçœçœçœçœçœçœçœçœçœ
+çœ çœ¡çœ¢çœ£çœ€çœ¥çœŠçœ§çœšçœ©çœªçœ«çœ¬çœ­çœ®çœ¯çœ°çœ±çœ²çœ³çœŽçœµçœ¶çœ·çœžçœ¹çœºçœ»çœŒçœœçœŸçœ¿
+çŸçŸçŸçŸçŸçŸ
+çŸçŸçŸçŸçŸçŸçŸçŸçŸçŸçŸçŸçŸçŸçŸçŸçŸçŸçŸçŸçŸçŸçŸçŸçŸçŸ
+çŸ çŸ¡çŸ¢çŸ£çŸ€çŸ¥çŸŠçŸ§çŸšçŸ©çŸªçŸ«çŸ¬çŸ­çŸ®çŸ¯çŸ°çŸ±çŸ²çŸ³çŸŽçŸµçŸ¶çŸ·çŸžçŸ¹çŸºçŸ»çŸŒçŸœçŸŸçŸ¿
+ç¿ç¿ç¿ç¿ç¿ç¿
+ç¿ç¿ç¿ç¿ç¿ç¿ç¿ç¿ç¿ç¿ç¿ç¿ç¿ç¿ç¿ç¿ç¿ç¿ç¿ç¿ç¿ç¿ç¿ç¿ç¿ç¿
+ç¿ ç¿¡ç¿¢ç¿£ç¿€ç¿¥ç¿Šç¿§ç¿šç¿©ç¿ªç¿«ç¿¬ç¿­ç¿®ç¿¯ç¿°ç¿±ç¿²ç¿³ç¿Žç¿µç¿¶ç¿·ç¿žç¿¹ç¿ºç¿»ç¿Œç¿œç¿Ÿç¿¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+è
+è
+è
+è
+è
+è
+
+è
+è
+è
+è
+è
+è
+è
+è
+è
+è
+è
+è
+è
+è
+è
+è
+è
+è
+è
+è
+è
+è
+è
+è
+è
+è
+
+è
+ è
+¡è
+¢è
+£è
+€è
+¥è
+Šè
+§è
+šè
+©è
+ªè
+«è
+¬è
+­è
+®è
+¯è
+°è
+±è
+²è
+³è
+Žè
+µè
+¶è
+·è
+žè
+¹è
+ºè
+»è
+Œè
+œè
+Ÿè
+¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+èèèèèè
+èèèèèèèèèèèèèèèèèèèèèèèèèè
+è è¡è¢è£è€è¥èŠè§èšè©èªè«è¬è­è®è¯è°è±è²è³èŽèµè¶è·èžè¹èºè»èŒèœèŸè¿
+è è è è è è 
+è è è è è è è è è è è è è è è è è è è è è è è è è è 
+è  è ¡è ¢è £è €è ¥è Šè §è šè ©è ªè «è ¬è ­è ®è ¯è °è ±è ²è ³è Žè µè ¶è ·è žè ¹è ºè »è Œè œè Ÿè ¿
+è¡è¡è¡è¡è¡è¡
+è¡è¡è¡è¡è¡è¡è¡è¡è¡è¡è¡è¡è¡è¡è¡è¡è¡è¡è¡è¡è¡è¡è¡è¡è¡è¡
+è¡ è¡¡è¡¢è¡£è¡€è¡¥è¡Šè¡§è¡šè¡©è¡ªè¡«è¡¬è¡­è¡®è¡¯è¡°è¡±è¡²è¡³è¡Žè¡µè¡¶è¡·è¡žè¡¹è¡ºè¡»è¡Œè¡œè¡Ÿè¡¿
+è¢è¢è¢è¢è¢è¢
+è¢è¢è¢è¢è¢è¢è¢è¢è¢è¢è¢è¢è¢è¢è¢è¢è¢è¢è¢è¢è¢è¢è¢è¢è¢è¢
+è¢ è¢¡è¢¢è¢£è¢€è¢¥è¢Šè¢§è¢šè¢©è¢ªè¢«è¢¬è¢­è¢®è¢¯è¢°è¢±è¢²è¢³è¢Žè¢µè¢¶è¢·è¢žè¢¹è¢ºè¢»è¢Œè¢œè¢Ÿè¢¿
+è£è£è£è£è£è£
+è£è£è£è£è£è£è£è£è£è£è£è£è£è£è£è£è£è£è£è£è£è£è£è£è£è£
+è£ è£¡è£¢è££è£€è£¥è£Šè£§è£šè£©è£ªè£«è£¬è£­è£®è£¯è£°è£±è£²è£³è£Žè£µè£¶è£·è£žè£¹è£ºè£»è£Œè£œè£Ÿè£¿
+è€è€è€è€è€è€
+è€è€è€è€è€è€è€è€è€è€è€è€è€è€è€è€è€è€è€è€è€è€è€è€è€è€
+è€ è€¡è€¢è€£è€€è€¥è€Šè€§è€šè€©è€ªè€«è€¬è€­è€®è€¯è€°è€±è€²è€³è€Žè€µè€¶è€·è€žè€¹è€ºè€»è€Œè€œè€Ÿè€¿
+è¥è¥è¥è¥è¥è¥
+è¥è¥è¥è¥è¥è¥è¥è¥è¥è¥è¥è¥è¥è¥è¥è¥è¥è¥è¥è¥è¥è¥è¥è¥è¥è¥
+è¥ è¥¡è¥¢è¥£è¥€è¥¥è¥Šè¥§è¥šè¥©è¥ªè¥«è¥¬è¥­è¥®è¥¯è¥°è¥±è¥²è¥³è¥Žè¥µè¥¶è¥·è¥žè¥¹è¥ºè¥»è¥Œè¥œè¥Ÿè¥¿
+èŠèŠèŠèŠèŠèŠ
+èŠèŠèŠèŠèŠèŠèŠèŠèŠèŠèŠèŠèŠèŠèŠèŠèŠèŠèŠèŠèŠèŠèŠèŠèŠèŠ
+èŠ èŠ¡èŠ¢èŠ£èŠ€èŠ¥èŠŠèŠ§èŠšèŠ©èŠªèŠ«èŠ¬èŠ­èŠ®èŠ¯èŠ°èŠ±èŠ²èŠ³èŠŽèŠµèŠ¶èŠ·èŠžèŠ¹èŠºèŠ»èŠŒèŠœèŠŸèŠ¿
+è§è§è§è§è§è§
+è§è§è§è§è§è§è§è§è§è§è§è§è§è§è§è§è§è§è§è§è§è§è§è§è§è§
+è§ è§¡è§¢è§£è§€è§¥è§Šè§§è§šè§©è§ªè§«è§¬è§­è§®è§¯è§°è§±è§²è§³è§Žè§µè§¶è§·è§žè§¹è§ºè§»è§Œè§œè§Ÿè§¿
+èšèšèšèšèšèš
+èšèšèšèšèšèšèšèšèšèšèšèšèšèšèšèšèšèšèšèšèšèšèšèšèšèš
+èš èš¡èš¢èš£èš€èš¥èšŠèš§èššèš©èšªèš«èš¬èš­èš®èš¯èš°èš±èš²èš³èšŽèšµèš¶èš·èšžèš¹èšºèš»èšŒèšœèšŸèš¿
+è©è©è©è©è©è©
+è©è©è©è©è©è©è©è©è©è©è©è©è©è©è©è©è©è©è©è©è©è©è©è©è©è©
+è© è©¡è©¢è©£è©€è©¥è©Šè©§è©šè©©è©ªè©«è©¬è©­è©®è©¯è©°è©±è©²è©³è©Žè©µè©¶è©·è©žè©¹è©ºè©»è©Œè©œè©Ÿè©¿
+èªèªèªèªèªèª
+èªèªèªèªèªèªèªèªèªèªèªèªèªèªèªèªèªèªèªèªèªèªèªèªèªèª
+èª èª¡èª¢èª£èª€èª¥èªŠèª§èªšèª©èªªèª«èª¬èª­èª®èª¯èª°èª±èª²èª³èªŽèªµèª¶èª·èªžèª¹èªºèª»èªŒèªœèªŸèª¿
+è«è«è«è«è«è«
+è«è«è«è«è«è«è«è«è«è«è«è«è«è«è«è«è«è«è«è«è«è«è«è«è«è«
+è« è«¡è«¢è«£è«€è«¥è«Šè«§è«šè«©è«ªè««è«¬è«­è«®è«¯è«°è«±è«²è«³è«Žè«µè«¶è«·è«žè«¹è«ºè«»è«Œè«œè«Ÿè«¿
+è¬è¬è¬è¬è¬è¬
+è¬è¬è¬è¬è¬è¬è¬è¬è¬è¬è¬è¬è¬è¬è¬è¬è¬è¬è¬è¬è¬è¬è¬è¬è¬è¬
+è¬ è¬¡è¬¢è¬£è¬€è¬¥è¬Šè¬§è¬šè¬©è¬ªè¬«è¬¬è¬­è¬®è¬¯è¬°è¬±è¬²è¬³è¬Žè¬µè¬¶è¬·è¬žè¬¹è¬ºè¬»è¬Œè¬œè¬Ÿè¬¿
+è­è­è­è­è­è­
+è­è­è­è­è­è­è­è­è­è­è­è­è­è­è­è­è­è­è­è­è­è­è­è­è­è­
+è­ è­¡è­¢è­£è­€è­¥è­Šè­§è­šè­©è­ªè­«è­¬è­­è­®è­¯è­°è­±è­²è­³è­Žè­µè­¶è­·è­žè­¹è­ºè­»è­Œè­œè­Ÿè­¿
+è®è®è®è®è®è®
+è®è®è®è®è®è®è®è®è®è®è®è®è®è®è®è®è®è®è®è®è®è®è®è®è®è®
+è® è®¡è®¢è®£è®€è®¥è®Šè®§è®šè®©è®ªè®«è®¬è®­è®®è®¯è®°è®±è®²è®³è®Žè®µè®¶è®·è®žè®¹è®ºè®»è®Œè®œè®Ÿè®¿
+è¯è¯è¯è¯è¯è¯
+è¯è¯è¯è¯è¯è¯è¯è¯è¯è¯è¯è¯è¯è¯è¯è¯è¯è¯è¯è¯è¯è¯è¯è¯è¯è¯
+è¯ è¯¡è¯¢è¯£è¯€è¯¥è¯Šè¯§è¯šè¯©è¯ªè¯«è¯¬è¯­è¯®è¯¯è¯°è¯±è¯²è¯³è¯Žè¯µè¯¶è¯·è¯žè¯¹è¯ºè¯»è¯Œè¯œè¯Ÿè¯¿
+è°è°è°è°è°è°
+è°è°è°è°è°è°è°è°è°è°è°è°è°è°è°è°è°è°è°è°è°è°è°è°è°è°
+è° è°¡è°¢è°£è°€è°¥è°Šè°§è°šè°©è°ªè°«è°¬è°­è°®è°¯è°°è°±è°²è°³è°Žè°µè°¶è°·è°žè°¹è°ºè°»è°Œè°œè°Ÿè°¿
+è±è±è±è±è±è±
+è±è±è±è±è±è±è±è±è±è±è±è±è±è±è±è±è±è±è±è±è±è±è±è±è±è±
+è± è±¡è±¢è±£è±€è±¥è±Šè±§è±šè±©è±ªè±«è±¬è±­è±®è±¯è±°è±±è±²è±³è±Žè±µè±¶è±·è±žè±¹è±ºè±»è±Œè±œè±Ÿè±¿
+è²è²è²è²è²è²
+è²è²è²è²è²è²è²è²è²è²è²è²è²è²è²è²è²è²è²è²è²è²è²è²è²è²
+è² è²¡è²¢è²£è²€è²¥è²Šè²§è²šè²©è²ªè²«è²¬è²­è²®è²¯è²°è²±è²²è²³è²Žè²µè²¶è²·è²žè²¹è²ºè²»è²Œè²œè²Ÿè²¿
+è³è³è³è³è³è³
+è³è³è³è³è³è³è³è³è³è³è³è³è³è³è³è³è³è³è³è³è³è³è³è³è³è³
+è³ è³¡è³¢è³£è³€è³¥è³Šè³§è³šè³©è³ªè³«è³¬è³­è³®è³¯è³°è³±è³²è³³è³Žè³µè³¶è³·è³žè³¹è³ºè³»è³Œè³œè³Ÿè³¿
+èŽèŽèŽèŽèŽèŽ
+èŽèŽèŽèŽèŽèŽèŽèŽèŽèŽèŽèŽèŽèŽèŽèŽèŽèŽèŽèŽèŽèŽèŽèŽèŽèŽ
+èŽ èŽ¡èŽ¢èŽ£èŽ€èŽ¥èŽŠèŽ§èŽšèŽ©èŽªèŽ«èŽ¬èŽ­èŽ®èŽ¯èŽ°èŽ±èŽ²èŽ³èŽŽèŽµèŽ¶èŽ·èŽžèŽ¹èŽºèŽ»èŽŒèŽœèŽŸèŽ¿
+èµèµèµèµèµèµ
+èµèµèµèµèµèµèµèµèµèµèµèµèµèµèµèµèµèµèµèµèµèµèµèµèµèµ
+èµ èµ¡èµ¢èµ£èµ€èµ¥èµŠèµ§èµšèµ©èµªèµ«èµ¬èµ­èµ®èµ¯èµ°èµ±èµ²èµ³èµŽèµµèµ¶èµ·èµžèµ¹èµºèµ»èµŒèµœèµŸèµ¿
+è¶è¶è¶è¶è¶è¶
+è¶è¶è¶è¶è¶è¶è¶è¶è¶è¶è¶è¶è¶è¶è¶è¶è¶è¶è¶è¶è¶è¶è¶è¶è¶è¶
+è¶ è¶¡è¶¢è¶£è¶€è¶¥è¶Šè¶§è¶šè¶©è¶ªè¶«è¶¬è¶­è¶®è¶¯è¶°è¶±è¶²è¶³è¶Žè¶µè¶¶è¶·è¶žè¶¹è¶ºè¶»è¶Œè¶œè¶Ÿè¶¿
+è·è·è·è·è·è·
+è·è·è·è·è·è·è·è·è·è·è·è·è·è·è·è·è·è·è·è·è·è·è·è·è·è·
+è· è·¡è·¢è·£è·€è·¥è·Šè·§è·šè·©è·ªè·«è·¬è·­è·®è·¯è·°è·±è·²è·³è·Žè·µè·¶è··è·žè·¹è·ºè·»è·Œè·œè·Ÿè·¿
+èžèžèžèžèžèž
+èžèžèžèžèžèžèžèžèžèžèžèžèžèžèžèžèžèžèžèžèžèžèžèžèžèž
+èž èž¡èž¢èž£èž€èž¥èžŠèž§èžšèž©èžªèž«èž¬èž­èž®èž¯èž°èž±èž²èž³èžŽèžµèž¶èž·èžžèž¹èžºèž»èžŒèžœèžŸèž¿
+è¹è¹è¹è¹è¹è¹
+è¹è¹è¹è¹è¹è¹è¹è¹è¹è¹è¹è¹è¹è¹è¹è¹è¹è¹è¹è¹è¹è¹è¹è¹è¹è¹
+è¹ è¹¡è¹¢è¹£è¹€è¹¥è¹Šè¹§è¹šè¹©è¹ªè¹«è¹¬è¹­è¹®è¹¯è¹°è¹±è¹²è¹³è¹Žè¹µè¹¶è¹·è¹žè¹¹è¹ºè¹»è¹Œè¹œè¹Ÿè¹¿
+èºèºèºèºèºèº
+èºèºèºèºèºèºèºèºèºèºèºèºèºèºèºèºèºèºèºèºèºèºèºèºèºèº
+èº èº¡èº¢èº£èº€èº¥èºŠèº§èºšèº©èºªèº«èº¬èº­èº®èº¯èº°èº±èº²èº³èºŽèºµèº¶èº·èºžèº¹èººèº»èºŒèºœèºŸèº¿
+è»è»è»è»è»è»
+è»è»è»è»è»è»è»è»è»è»è»è»è»è»è»è»è»è»è»è»è»è»è»è»è»è»
+è» è»¡è»¢è»£è»€è»¥è»Šè»§è»šè»©è»ªè»«è»¬è»­è»®è»¯è»°è»±è»²è»³è»Žè»µè»¶è»·è»žè»¹è»ºè»»è»Œè»œè»Ÿè»¿
+èŒèŒèŒèŒèŒèŒ
+èŒèŒèŒèŒèŒèŒèŒèŒèŒèŒèŒèŒèŒèŒèŒèŒèŒèŒèŒèŒèŒèŒèŒèŒèŒèŒ
+èŒ èŒ¡èŒ¢èŒ£èŒ€èŒ¥èŒŠèŒ§èŒšèŒ©èŒªèŒ«èŒ¬èŒ­èŒ®èŒ¯èŒ°èŒ±èŒ²èŒ³èŒŽèŒµèŒ¶èŒ·èŒžèŒ¹èŒºèŒ»èŒŒèŒœèŒŸèŒ¿
+èœèœèœèœèœèœ
+èœèœèœèœèœèœèœèœèœèœèœèœèœèœèœèœèœèœèœèœèœèœèœèœèœèœ
+èœ èœ¡èœ¢èœ£èœ€èœ¥èœŠèœ§èœšèœ©èœªèœ«èœ¬èœ­èœ®èœ¯èœ°èœ±èœ²èœ³èœŽèœµèœ¶èœ·èœžèœ¹èœºèœ»èœŒèœœèœŸèœ¿
+èŸèŸèŸèŸèŸèŸ
+èŸèŸèŸèŸèŸèŸèŸèŸèŸèŸèŸèŸèŸèŸèŸèŸèŸèŸèŸèŸèŸèŸèŸèŸèŸèŸ
+èŸ èŸ¡èŸ¢èŸ£èŸ€èŸ¥èŸŠèŸ§èŸšèŸ©èŸªèŸ«èŸ¬èŸ­èŸ®èŸ¯èŸ°èŸ±èŸ²èŸ³èŸŽèŸµèŸ¶èŸ·èŸžèŸ¹èŸºèŸ»èŸŒèŸœèŸŸèŸ¿
+è¿è¿è¿è¿è¿è¿
+è¿è¿è¿è¿è¿è¿è¿è¿è¿è¿è¿è¿è¿è¿è¿è¿è¿è¿è¿è¿è¿è¿è¿è¿è¿è¿
+è¿ è¿¡è¿¢è¿£è¿€è¿¥è¿Šè¿§è¿šè¿©è¿ªè¿«è¿¬è¿­è¿®è¿¯è¿°è¿±è¿²è¿³è¿Žè¿µè¿¶è¿·è¿žè¿¹è¿ºè¿»è¿Œè¿œè¿Ÿè¿¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+é
+é
+é
+é
+é
+é
+
+é
+é
+é
+é
+é
+é
+é
+é
+é
+é
+é
+é
+é
+é
+é
+é
+é
+é
+é
+é
+é
+é
+é
+é
+é
+é
+
+é
+ é
+¡é
+¢é
+£é
+€é
+¥é
+Šé
+§é
+šé
+©é
+ªé
+«é
+¬é
+­é
+®é
+¯é
+°é
+±é
+²é
+³é
+Žé
+µé
+¶é
+·é
+žé
+¹é
+ºé
+»é
+Œé
+œé
+Ÿé
+¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+éééééé
+éééééééééééééééééééééééééé
+é é¡é¢é£é€é¥éŠé§éšé©éªé«é¬é­é®é¯é°é±é²é³éŽéµé¶é·éžé¹éºé»éŒéœéŸé¿
+é é é é é é 
+é é é é é é é é é é é é é é é é é é é é é é é é é é 
+é  é ¡é ¢é £é €é ¥é Šé §é šé ©é ªé «é ¬é ­é ®é ¯é °é ±é ²é ³é Žé µé ¶é ·é žé ¹é ºé »é Œé œé Ÿé ¿
+é¡é¡é¡é¡é¡é¡
+é¡é¡é¡é¡é¡é¡é¡é¡é¡é¡é¡é¡é¡é¡é¡é¡é¡é¡é¡é¡é¡é¡é¡é¡é¡é¡
+é¡ é¡¡é¡¢é¡£é¡€é¡¥é¡Šé¡§é¡šé¡©é¡ªé¡«é¡¬é¡­é¡®é¡¯é¡°é¡±é¡²é¡³é¡Žé¡µé¡¶é¡·é¡žé¡¹é¡ºé¡»é¡Œé¡œé¡Ÿé¡¿
+é¢é¢é¢é¢é¢é¢
+é¢é¢é¢é¢é¢é¢é¢é¢é¢é¢é¢é¢é¢é¢é¢é¢é¢é¢é¢é¢é¢é¢é¢é¢é¢é¢
+é¢ é¢¡é¢¢é¢£é¢€é¢¥é¢Šé¢§é¢šé¢©é¢ªé¢«é¢¬é¢­é¢®é¢¯é¢°é¢±é¢²é¢³é¢Žé¢µé¢¶é¢·é¢žé¢¹é¢ºé¢»é¢Œé¢œé¢Ÿé¢¿
+é£é£é£é£é£é£
+é£é£é£é£é£é£é£é£é£é£é£é£é£é£é£é£é£é£é£é£é£é£é£é£é£é£
+é£ é£¡é£¢é££é£€é£¥é£Šé£§é£šé£©é£ªé£«é£¬é£­é£®é£¯é£°é£±é£²é£³é£Žé£µé£¶é£·é£žé£¹é£ºé£»é£Œé£œé£Ÿé£¿
+é€é€é€é€é€é€
+é€é€é€é€é€é€é€é€é€é€é€é€é€é€é€é€é€é€é€é€é€é€é€é€é€é€
+é€ é€¡é€¢é€£é€€é€¥é€Šé€§é€šé€©é€ªé€«é€¬é€­é€®é€¯é€°é€±é€²é€³é€Žé€µé€¶é€·é€žé€¹é€ºé€»é€Œé€œé€Ÿé€¿
+é¥é¥é¥é¥é¥é¥
+é¥é¥é¥é¥é¥é¥é¥é¥é¥é¥é¥é¥é¥é¥é¥é¥é¥é¥é¥é¥é¥é¥é¥é¥é¥é¥
+é¥ é¥¡é¥¢é¥£é¥€é¥¥é¥Šé¥§é¥šé¥©é¥ªé¥«é¥¬é¥­é¥®é¥¯é¥°é¥±é¥²é¥³é¥Žé¥µé¥¶é¥·é¥žé¥¹é¥ºé¥»é¥Œé¥œé¥Ÿé¥¿
+éŠéŠéŠéŠéŠéŠ
+éŠéŠéŠéŠéŠéŠéŠéŠéŠéŠéŠéŠéŠéŠéŠéŠéŠéŠéŠéŠéŠéŠéŠéŠéŠéŠ
+éŠ éŠ¡éŠ¢éŠ£éŠ€éŠ¥éŠŠéŠ§éŠšéŠ©éŠªéŠ«éŠ¬éŠ­éŠ®éŠ¯éŠ°éŠ±éŠ²éŠ³éŠŽéŠµéŠ¶éŠ·éŠžéŠ¹éŠºéŠ»éŠŒéŠœéŠŸéŠ¿
+é§é§é§é§é§é§
+é§é§é§é§é§é§é§é§é§é§é§é§é§é§é§é§é§é§é§é§é§é§é§é§é§é§
+é§ é§¡é§¢é§£é§€é§¥é§Šé§§é§šé§©é§ªé§«é§¬é§­é§®é§¯é§°é§±é§²é§³é§Žé§µé§¶é§·é§žé§¹é§ºé§»é§Œé§œé§Ÿé§¿
+éšéšéšéšéšéš
+éšéšéšéšéšéšéšéšéšéšéšéšéšéšéšéšéšéšéšéšéšéšéšéšéšéš
+éš éš¡éš¢éš£éš€éš¥éšŠéš§éššéš©éšªéš«éš¬éš­éš®éš¯éš°éš±éš²éš³éšŽéšµéš¶éš·éšžéš¹éšºéš»éšŒéšœéšŸéš¿
+é©é©é©é©é©é©
+é©é©é©é©é©é©é©é©é©é©é©é©é©é©é©é©é©é©é©é©é©é©é©é©é©é©
+é© é©¡é©¢é©£é©€é©¥é©Šé©§é©šé©©é©ªé©«é©¬é©­é©®é©¯é©°é©±é©²é©³é©Žé©µé©¶é©·é©žé©¹é©ºé©»é©Œé©œé©Ÿé©¿
+éªéªéªéªéªéª
+éªéªéªéªéªéªéªéªéªéªéªéªéªéªéªéªéªéªéªéªéªéªéªéªéªéª
+éª éª¡éª¢éª£éª€éª¥éªŠéª§éªšéª©éªªéª«éª¬éª­éª®éª¯éª°éª±éª²éª³éªŽéªµéª¶éª·éªžéª¹éªºéª»éªŒéªœéªŸéª¿
+é«é«é«é«é«é«
+é«é«é«é«é«é«é«é«é«é«é«é«é«é«é«é«é«é«é«é«é«é«é«é«é«é«
+é« é«¡é«¢é«£é«€é«¥é«Šé«§é«šé«©é«ªé««é«¬é«­é«®é«¯é«°é«±é«²é«³é«Žé«µé«¶é«·é«žé«¹é«ºé«»é«Œé«œé«Ÿé«¿
+é¬é¬é¬é¬é¬é¬
+é¬é¬é¬é¬é¬é¬é¬é¬é¬é¬é¬é¬é¬é¬é¬é¬é¬é¬é¬é¬é¬é¬é¬é¬é¬é¬
+é¬ é¬¡é¬¢é¬£é¬€é¬¥é¬Šé¬§é¬šé¬©é¬ªé¬«é¬¬é¬­é¬®é¬¯é¬°é¬±é¬²é¬³é¬Žé¬µé¬¶é¬·é¬žé¬¹é¬ºé¬»é¬Œé¬œé¬Ÿé¬¿
+é­é­é­é­é­é­
+é­é­é­é­é­é­é­é­é­é­é­é­é­é­é­é­é­é­é­é­é­é­é­é­é­é­
+é­ é­¡é­¢é­£é­€é­¥é­Šé­§é­šé­©é­ªé­«é­¬é­­é­®é­¯é­°é­±é­²é­³é­Žé­µé­¶é­·é­žé­¹é­ºé­»é­Œé­œé­Ÿé­¿
+é®é®é®é®é®é®
+é®é®é®é®é®é®é®é®é®é®é®é®é®é®é®é®é®é®é®é®é®é®é®é®é®é®
+é® é®¡é®¢é®£é®€é®¥é®Šé®§é®šé®©é®ªé®«é®¬é®­é®®é®¯é®°é®±é®²é®³é®Žé®µé®¶é®·é®žé®¹é®ºé®»é®Œé®œé®Ÿé®¿
+é¯é¯é¯é¯é¯é¯
+é¯é¯é¯é¯é¯é¯é¯é¯é¯é¯é¯é¯é¯é¯é¯é¯é¯é¯é¯é¯é¯é¯é¯é¯é¯é¯
+é¯ é¯¡é¯¢é¯£é¯€é¯¥é¯Šé¯§é¯šé¯©é¯ªé¯«é¯¬é¯­é¯®é¯¯é¯°é¯±é¯²é¯³é¯Žé¯µé¯¶é¯·é¯žé¯¹é¯ºé¯»é¯Œé¯œé¯Ÿé¯¿
+é°é°é°é°é°é°
+é°é°é°é°é°é°é°é°é°é°é°é°é°é°é°é°é°é°é°é°é°é°é°é°é°é°
+é° é°¡é°¢é°£é°€é°¥é°Šé°§é°šé°©é°ªé°«é°¬é°­é°®é°¯é°°é°±é°²é°³é°Žé°µé°¶é°·é°žé°¹é°ºé°»é°Œé°œé°Ÿé°¿
+é±é±é±é±é±é±
+é±é±é±é±é±é±é±é±é±é±é±é±é±é±é±é±é±é±é±é±é±é±é±é±é±é±
+é± é±¡é±¢é±£é±€é±¥é±Šé±§é±šé±©é±ªé±«é±¬é±­é±®é±¯é±°é±±é±²é±³é±Žé±µé±¶é±·é±žé±¹é±ºé±»é±Œé±œé±Ÿé±¿
+é²é²é²é²é²é²
+é²é²é²é²é²é²é²é²é²é²é²é²é²é²é²é²é²é²é²é²é²é²é²é²é²é²
+é² é²¡é²¢é²£é²€é²¥é²Šé²§é²šé²©é²ªé²«é²¬é²­é²®é²¯é²°é²±é²²é²³é²Žé²µé²¶é²·é²žé²¹é²ºé²»é²Œé²œé²Ÿé²¿
+é³é³é³é³é³é³
+é³é³é³é³é³é³é³é³é³é³é³é³é³é³é³é³é³é³é³é³é³é³é³é³é³é³
+é³ é³¡é³¢é³£é³€é³¥é³Šé³§é³šé³©é³ªé³«é³¬é³­é³®é³¯é³°é³±é³²é³³é³Žé³µé³¶é³·é³žé³¹é³ºé³»é³Œé³œé³Ÿé³¿
+éŽéŽéŽéŽéŽéŽ
+éŽéŽéŽéŽéŽéŽéŽéŽéŽéŽéŽéŽéŽéŽéŽéŽéŽéŽéŽéŽéŽéŽéŽéŽéŽéŽ
+éŽ éŽ¡éŽ¢éŽ£éŽ€éŽ¥éŽŠéŽ§éŽšéŽ©éŽªéŽ«éŽ¬éŽ­éŽ®éŽ¯éŽ°éŽ±éŽ²éŽ³éŽŽéŽµéŽ¶éŽ·éŽžéŽ¹éŽºéŽ»éŽŒéŽœéŽŸéŽ¿
+éµéµéµéµéµéµ
+éµéµéµéµéµéµéµéµéµéµéµéµéµéµéµéµéµéµéµéµéµéµéµéµéµéµ
+éµ éµ¡éµ¢éµ£éµ€éµ¥éµŠéµ§éµšéµ©éµªéµ«éµ¬éµ­éµ®éµ¯éµ°éµ±éµ²éµ³éµŽéµµéµ¶éµ·éµžéµ¹éµºéµ»éµŒéµœéµŸéµ¿
+é¶é¶é¶é¶é¶é¶
+é¶é¶é¶é¶é¶é¶é¶é¶é¶é¶é¶é¶é¶é¶é¶é¶é¶é¶é¶é¶é¶é¶é¶é¶é¶é¶
+é¶ é¶¡é¶¢é¶£é¶€é¶¥é¶Šé¶§é¶šé¶©é¶ªé¶«é¶¬é¶­é¶®é¶¯é¶°é¶±é¶²é¶³é¶Žé¶µé¶¶é¶·é¶žé¶¹é¶ºé¶»é¶Œé¶œé¶Ÿé¶¿
+é·é·é·é·é·é·
+é·é·é·é·é·é·é·é·é·é·é·é·é·é·é·é·é·é·é·é·é·é·é·é·é·é·
+é· é·¡é·¢é·£é·€é·¥é·Šé·§é·šé·©é·ªé·«é·¬é·­é·®é·¯é·°é·±é·²é·³é·Žé·µé·¶é··é·žé·¹é·ºé·»é·Œé·œé·Ÿé·¿
+éžéžéžéžéžéž
+éžéžéžéžéžéžéžéžéžéžéžéžéžéžéžéžéžéžéžéžéžéžéžéžéžéž
+éž éž¡éž¢éž£éž€éž¥éžŠéž§éžšéž©éžªéž«éž¬éž­éž®éž¯éž°éž±éž²éž³éžŽéžµéž¶éž·éžžéž¹éžºéž»éžŒéžœéžŸéž¿
+é¹é¹é¹é¹é¹é¹
+é¹é¹é¹é¹é¹é¹é¹é¹é¹é¹é¹é¹é¹é¹é¹é¹é¹é¹é¹é¹é¹é¹é¹é¹é¹é¹
+é¹ é¹¡é¹¢é¹£é¹€é¹¥é¹Šé¹§é¹šé¹©é¹ªé¹«é¹¬é¹­é¹®é¹¯é¹°é¹±é¹²é¹³é¹Žé¹µé¹¶é¹·é¹žé¹¹é¹ºé¹»é¹Œé¹œé¹Ÿé¹¿
+éºéºéºéºéºéº
+éºéºéºéºéºéºéºéºéºéºéºéºéºéºéºéºéºéºéºéºéºéºéºéºéºéº
+éº éº¡éº¢éº£éº€éº¥éºŠéº§éºšéº©éºªéº«éº¬éº­éº®éº¯éº°éº±éº²éº³éºŽéºµéº¶éº·éºžéº¹éººéº»éºŒéºœéºŸéº¿
+é»é»é»é»é»é»
+é»é»é»é»é»é»é»é»é»é»é»é»é»é»é»é»é»é»é»é»é»é»é»é»é»é»
+é» é»¡é»¢é»£é»€é»¥é»Šé»§é»šé»©é»ªé»«é»¬é»­é»®é»¯é»°é»±é»²é»³é»Žé»µé»¶é»·é»žé»¹é»ºé»»é»Œé»œé»Ÿé»¿
+éŒéŒéŒéŒéŒéŒ
+éŒéŒéŒéŒéŒéŒéŒéŒéŒéŒéŒéŒéŒéŒéŒéŒéŒéŒéŒéŒéŒéŒéŒéŒéŒéŒ
+éŒ éŒ¡éŒ¢éŒ£éŒ€éŒ¥éŒŠéŒ§éŒšéŒ©éŒªéŒ«éŒ¬éŒ­éŒ®éŒ¯éŒ°éŒ±éŒ²éŒ³éŒŽéŒµéŒ¶éŒ·éŒžéŒ¹éŒºéŒ»éŒŒéŒœéŒŸéŒ¿
+éœéœéœéœéœéœ
+éœéœéœéœéœéœéœéœéœéœéœéœéœéœéœéœéœéœéœéœéœéœéœéœéœéœ
+éœ éœ¡éœ¢éœ£éœ€éœ¥éœŠéœ§éœšéœ©éœªéœ«éœ¬éœ­éœ®éœ¯éœ°éœ±éœ²éœ³éœŽéœµéœ¶éœ·éœžéœ¹éœºéœ»éœŒéœœéœŸéœ¿
+éŸéŸéŸéŸéŸéŸ
+éŸéŸéŸéŸéŸéŸéŸéŸéŸéŸéŸéŸéŸéŸéŸéŸéŸéŸéŸéŸéŸéŸéŸéŸéŸéŸ
+éŸ éŸ¡éŸ¢éŸ£éŸ€éŸ¥éŸŠéŸ§éŸšéŸ©éŸªéŸ«éŸ¬éŸ­éŸ®éŸ¯éŸ°éŸ±éŸ²éŸ³éŸŽéŸµéŸ¶éŸ·éŸžéŸ¹éŸºéŸ»éŸŒéŸœéŸŸéŸ¿
+é¿é¿é¿é¿é¿é¿
+é¿é¿é¿é¿é¿é¿é¿é¿é¿é¿é¿é¿é¿é¿é¿é¿é¿é¿é¿é¿é¿é¿é¿é¿é¿é¿
+é¿ é¿¡é¿¢é¿£é¿€é¿¥é¿Šé¿§é¿šé¿©é¿ªé¿«é¿¬é¿­é¿®é¿¯é¿°é¿±é¿²é¿³é¿Žé¿µé¿¶é¿·é¿žé¿¹é¿ºé¿»é¿Œé¿œé¿Ÿé¿¿
+
+Yi Syllables (U+A000-U+A48F):
+
+êêêêêê
+êêêêêêêêêêêêêêêêêêêêêêêêêê
+ê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿
+êêêêêê
+êêêêêêêêêêêêêêêêêêêêêêêêêê
+ê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿
+êêêêêê
+êêêêêêêêêêêêêêêêêêêêêêêêêê
+ê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿
+êêêêêê
+êêêêêêêêêêêêêêêêêêêêêêêêêê
+ê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿
+êêêêêê
+êêêêêêêêêêêêêêêêêêêêêêêêêê
+ê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿
+ê
+ê
+ê
+ê
+ê
+ê
+
+ê
+ê
+ê
+ê
+ê
+ê
+ê
+ê
+ê
+ê
+ê
+ê
+ê
+ê
+ê
+ê
+ê
+ê
+ê
+ê
+ê
+ê
+ê
+ê
+ê
+ê
+
+ê
+ ê
+¡ê
+¢ê
+£ê
+€ê
+¥ê
+Šê
+§ê
+šê
+©ê
+ªê
+«ê
+¬ê
+­ê
+®ê
+¯ê
+°ê
+±ê
+²ê
+³ê
+Žê
+µê
+¶ê
+·ê
+žê
+¹ê
+ºê
+»ê
+Œê
+œê
+Ÿê
+¿
+êêêêêê
+êêêêêêêêêêêêêêêêêêêêêêêêêê
+ê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿
+êêêêêê
+êêêêêêêêêêêêêêêêêêêêêêêêêê
+ê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿
+êêêêêê
+êêêêêêêêêêêêêêêêêêêêêêêêêê
+ê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿
+êêêêêê
+êêêêêêêêêêêêêêêêêêêêêêêêêê
+ê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿
+êêêêêê
+êêêêêêêêêêêêêêêêêêêêêêêêêê
+ê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿
+êêêêêê
+êêêêêêêêêêêêêêêêêêêêêêêêêê
+ê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿
+êêêêêê
+êêêêêêêêêêêêêêêêêêêêêêêêêê
+ê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿
+êêêêêê
+êêêêêêêêêêêêêêêêêêêêêêêêêê
+ê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿
+êêêêêê
+êêêêêêêêêêêêêêêêêêêêêêêêêê
+ê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿
+êêêêêê
+êêêêêêêêêêêêêêêêêêêêêêêêêê
+ê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿
+êêêêêê
+êêêêêêêêêêêêêêêêêêêêêêêêêê
+ê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿
+êêêêêê
+êêêêêêêêêêêêêêêêêêêêêêêêêê
+ê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿
+êêêêêê
+êêêêêêêêêê
+
+Yi Radicals (U+A490-U+A4CF):
+
+êêêêêêêêêêêêêêêêê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯
+ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿êêêêêê
+êêêêêêêêêê
+
+Free block (U+A4D0-U+ABFF):
+
+êêêêêêêêêêêêêêêêê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿êêêêêê
+êêêêêêêêêê
+êêêêêêêêêêêêêêêêê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿êêêêêê
+êêêêêêêêêê
+êêêêêêêêêêêêêêêêê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿êêêêêê
+êêêêêêêêêê
+êêêêêêêêêêêêêêêêê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿êêêêêê
+êêêêêêêêêê
+êêêêêêêêêêêêêêêêê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿êêêêêê
+êêêêêêêêêê
+êêêêêêêêêêêêêêêêê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿êêêêêê
+êêêêêêêêêê
+êêêêêêêêêêêêêêêêê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿êêêêêê
+êêêêêêêêêê
+êêêêêêêêêêêêêêêêê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿êêêêêê
+êêêêêêêêêê
+êêêêêêêêêêêêêêêêê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿êêêêêê
+êêêêêêêêêê
+êêêêêêêêêêêêêêêêê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿êêêêêê
+êêêêêêêêêê
+êêêêêêêêêêêêêêêêê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿êêêêêê
+êêêêêêêêêê
+êêêêêêêêêêêêêêêêê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿êêêêêê
+êêêêêêêêêê
+êêêêêêêêêêêêêêêêê ê¡ê¢ê£ê€ê¥êŠê§êšê©êªê«ê¬ê­ê®ê¯ê°ê±ê²ê³êŽêµê¶ê·êžê¹êºê»êŒêœêŸê¿ê ê ê ê ê ê 
+ê ê ê ê ê ê ê ê ê ê 
+ê ê ê ê ê ê ê ê ê ê ê ê ê ê ê ê ê  ê ¡ê ¢ê £ê €ê ¥ê Šê §ê šê ©ê ªê «ê ¬ê ­ê ®ê ¯ê °ê ±ê ²ê ³ê Žê µê ¶ê ·ê žê ¹ê ºê »ê Œê œê Ÿê ¿ê¡ê¡ê¡ê¡ê¡ê¡
+ê¡ê¡ê¡ê¡ê¡ê¡ê¡ê¡ê¡ê¡
+ê¡ê¡ê¡ê¡ê¡ê¡ê¡ê¡ê¡ê¡ê¡ê¡ê¡ê¡ê¡ê¡ê¡ ê¡¡ê¡¢ê¡£ê¡€ê¡¥ê¡Šê¡§ê¡šê¡©ê¡ªê¡«ê¡¬ê¡­ê¡®ê¡¯ê¡°ê¡±ê¡²ê¡³ê¡Žê¡µê¡¶ê¡·ê¡žê¡¹ê¡ºê¡»ê¡Œê¡œê¡Ÿê¡¿ê¢ê¢ê¢ê¢ê¢ê¢
+ê¢ê¢ê¢ê¢ê¢ê¢ê¢ê¢ê¢ê¢
+ê¢ê¢ê¢ê¢ê¢ê¢ê¢ê¢ê¢ê¢ê¢ê¢ê¢ê¢ê¢ê¢ê¢ ê¢¡ê¢¢ê¢£ê¢€ê¢¥ê¢Šê¢§ê¢šê¢©ê¢ªê¢«ê¢¬ê¢­ê¢®ê¢¯ê¢°ê¢±ê¢²ê¢³ê¢Žê¢µê¢¶ê¢·ê¢žê¢¹ê¢ºê¢»ê¢Œê¢œê¢Ÿê¢¿ê£ê£ê£ê£ê£ê£
+ê£ê£ê£ê£ê£ê£ê£ê£ê£ê£
+ê£ê£ê£ê£ê£ê£ê£ê£ê£ê£ê£ê£ê£ê£ê£ê£ê£ ê£¡ê£¢ê££ê£€ê£¥ê£Šê£§ê£šê£©ê£ªê£«ê£¬ê£­ê£®ê£¯ê£°ê£±ê£²ê£³ê£Žê£µê£¶ê£·ê£žê£¹ê£ºê£»ê£Œê£œê£Ÿê£¿ê€ê€ê€ê€ê€ê€
+ê€ê€ê€ê€ê€ê€ê€ê€ê€ê€
+ê€ê€ê€ê€ê€ê€ê€ê€ê€ê€ê€ê€ê€ê€ê€ê€ê€ ê€¡ê€¢ê€£ê€€ê€¥ê€Šê€§ê€šê€©ê€ªê€«ê€¬ê€­ê€®ê€¯ê€°ê€±ê€²ê€³ê€Žê€µê€¶ê€·ê€žê€¹ê€ºê€»ê€Œê€œê€Ÿê€¿ê¥ê¥ê¥ê¥ê¥ê¥
+ê¥ê¥ê¥ê¥ê¥ê¥ê¥ê¥ê¥ê¥
+ê¥ê¥ê¥ê¥ê¥ê¥ê¥ê¥ê¥ê¥ê¥ê¥ê¥ê¥ê¥ê¥ê¥ ê¥¡ê¥¢ê¥£ê¥€ê¥¥ê¥Šê¥§ê¥šê¥©ê¥ªê¥«ê¥¬ê¥­ê¥®ê¥¯ê¥°ê¥±ê¥²ê¥³ê¥Žê¥µê¥¶ê¥·ê¥žê¥¹ê¥ºê¥»ê¥Œê¥œê¥Ÿê¥¿êŠêŠêŠêŠêŠêŠ
+êŠêŠêŠêŠêŠêŠêŠêŠêŠêŠ
+êŠêŠêŠêŠêŠêŠêŠêŠêŠêŠêŠêŠêŠêŠêŠêŠêŠ êŠ¡êŠ¢êŠ£êŠ€êŠ¥êŠŠêŠ§êŠšêŠ©êŠªêŠ«êŠ¬êŠ­êŠ®êŠ¯êŠ°êŠ±êŠ²êŠ³êŠŽêŠµêŠ¶êŠ·êŠžêŠ¹êŠºêŠ»êŠŒêŠœêŠŸêŠ¿ê§ê§ê§ê§ê§ê§
+ê§ê§ê§ê§ê§ê§ê§ê§ê§ê§
+ê§ê§ê§ê§ê§ê§ê§ê§ê§ê§ê§ê§ê§ê§ê§ê§ê§ ê§¡ê§¢ê§£ê§€ê§¥ê§Šê§§ê§šê§©ê§ªê§«ê§¬ê§­ê§®ê§¯ê§°ê§±ê§²ê§³ê§Žê§µê§¶ê§·ê§žê§¹ê§ºê§»ê§Œê§œê§Ÿê§¿êšêšêšêšêšêš
+êšêšêšêšêšêšêšêšêšêš
+êšêšêšêšêšêšêšêšêšêšêšêšêšêšêšêšêš êš¡êš¢êš£êš€êš¥êšŠêš§êššêš©êšªêš«êš¬êš­êš®êš¯êš°êš±êš²êš³êšŽêšµêš¶êš·êšžêš¹êšºêš»êšŒêšœêšŸêš¿ê©ê©ê©ê©ê©ê©
+ê©ê©ê©ê©ê©ê©ê©ê©ê©ê©
+ê©ê©ê©ê©ê©ê©ê©ê©ê©ê©ê©ê©ê©ê©ê©ê©ê© ê©¡ê©¢ê©£ê©€ê©¥ê©Šê©§ê©šê©©ê©ªê©«ê©¬ê©­ê©®ê©¯ê©°ê©±ê©²ê©³ê©Žê©µê©¶ê©·ê©žê©¹ê©ºê©»ê©Œê©œê©Ÿê©¿êªêªêªêªêªêª
+êªêªêªêªêªêªêªêªêªêª
+êªêªêªêªêªêªêªêªêªêªêªêªêªêªêªêªêª êª¡êª¢êª£êª€êª¥êªŠêª§êªšêª©êªªêª«êª¬êª­êª®êª¯êª°êª±êª²êª³êªŽêªµêª¶êª·êªžêª¹êªºêª»êªŒêªœêªŸêª¿ê«ê«ê«ê«ê«ê«
+ê«ê«ê«ê«ê«ê«ê«ê«ê«ê«
+ê«ê«ê«ê«ê«ê«ê«ê«ê«ê«ê«ê«ê«ê«ê«ê«ê« ê«¡ê«¢ê«£ê«€ê«¥ê«Šê«§ê«šê«©ê«ªê««ê«¬ê«­ê«®ê«¯ê«°ê«±ê«²ê«³ê«Žê«µê«¶ê«·ê«žê«¹ê«ºê«»ê«Œê«œê«Ÿê«¿ê¬ê¬ê¬ê¬ê¬ê¬
+ê¬ê¬ê¬ê¬ê¬ê¬ê¬ê¬ê¬ê¬
+ê¬ê¬ê¬ê¬ê¬ê¬ê¬ê¬ê¬ê¬ê¬ê¬ê¬ê¬ê¬ê¬ê¬ ê¬¡ê¬¢ê¬£ê¬€ê¬¥ê¬Šê¬§ê¬šê¬©ê¬ªê¬«ê¬¬ê¬­ê¬®ê¬¯ê¬°ê¬±ê¬²ê¬³ê¬Žê¬µê¬¶ê¬·ê¬žê¬¹ê¬ºê¬»ê¬Œê¬œê¬Ÿê¬¿ê­ê­ê­ê­ê­ê­
+ê­ê­ê­ê­ê­ê­ê­ê­ê­ê­
+ê­ê­ê­ê­ê­ê­ê­ê­ê­ê­ê­ê­ê­ê­ê­ê­ê­ ê­¡ê­¢ê­£ê­€ê­¥ê­Šê­§ê­šê­©ê­ªê­«ê­¬ê­­ê­®ê­¯ê­°ê­±ê­²ê­³ê­Žê­µê­¶ê­·ê­žê­¹ê­ºê­»ê­Œê­œê­Ÿê­¿ê®ê®ê®ê®ê®ê®
+ê®ê®ê®ê®ê®ê®ê®ê®ê®ê®
+ê®ê®ê®ê®ê®ê®ê®ê®ê®ê®ê®ê®ê®ê®ê®ê®ê® ê®¡ê®¢ê®£ê®€ê®¥ê®Šê®§ê®šê®©ê®ªê®«ê®¬ê®­ê®®ê®¯ê®°ê®±ê®²ê®³ê®Žê®µê®¶ê®·ê®žê®¹ê®ºê®»ê®Œê®œê®Ÿê®¿ê¯ê¯ê¯ê¯ê¯ê¯
+ê¯ê¯ê¯ê¯ê¯ê¯ê¯ê¯ê¯ê¯
+ê¯ê¯ê¯ê¯ê¯ê¯ê¯ê¯ê¯ê¯ê¯ê¯ê¯ê¯ê¯ê¯ê¯ ê¯¡ê¯¢ê¯£ê¯€ê¯¥ê¯Šê¯§ê¯šê¯©ê¯ªê¯«ê¯¬ê¯­ê¯®ê¯¯ê¯°ê¯±ê¯²ê¯³ê¯Žê¯µê¯¶ê¯·ê¯žê¯¹ê¯ºê¯»ê¯Œê¯œê¯Ÿê¯¿
+
+Hangul Syllables (U+AC00-U+D7A3):
+
+ê°ê°ê°ê°ê°ê°
+ê°ê°ê°ê°ê°ê°ê°ê°ê°ê°ê°ê°ê°ê°ê°ê°ê°ê°ê°ê°ê°ê°ê°ê°ê°ê°
+ê° ê°¡ê°¢ê°£ê°€ê°¥ê°Šê°§ê°šê°©ê°ªê°«ê°¬ê°­ê°®ê°¯ê°°ê°±ê°²ê°³ê°Žê°µê°¶ê°·ê°žê°¹ê°ºê°»ê°Œê°œê°Ÿê°¿
+ê±ê±ê±ê±ê±ê±
+ê±ê±ê±ê±ê±ê±ê±ê±ê±ê±ê±ê±ê±ê±ê±ê±ê±ê±ê±ê±ê±ê±ê±ê±ê±ê±
+ê± ê±¡ê±¢ê±£ê±€ê±¥ê±Šê±§ê±šê±©ê±ªê±«ê±¬ê±­ê±®ê±¯ê±°ê±±ê±²ê±³ê±Žê±µê±¶ê±·ê±žê±¹ê±ºê±»ê±Œê±œê±Ÿê±¿
+ê²ê²ê²ê²ê²ê²
+ê²ê²ê²ê²ê²ê²ê²ê²ê²ê²ê²ê²ê²ê²ê²ê²ê²ê²ê²ê²ê²ê²ê²ê²ê²ê²
+ê² ê²¡ê²¢ê²£ê²€ê²¥ê²Šê²§ê²šê²©ê²ªê²«ê²¬ê²­ê²®ê²¯ê²°ê²±ê²²ê²³ê²Žê²µê²¶ê²·ê²žê²¹ê²ºê²»ê²Œê²œê²Ÿê²¿
+ê³ê³ê³ê³ê³ê³
+ê³ê³ê³ê³ê³ê³ê³ê³ê³ê³ê³ê³ê³ê³ê³ê³ê³ê³ê³ê³ê³ê³ê³ê³ê³ê³
+ê³ ê³¡ê³¢ê³£ê³€ê³¥ê³Šê³§ê³šê³©ê³ªê³«ê³¬ê³­ê³®ê³¯ê³°ê³±ê³²ê³³ê³Žê³µê³¶ê³·ê³žê³¹ê³ºê³»ê³Œê³œê³Ÿê³¿
+êŽêŽêŽêŽêŽêŽ
+êŽêŽêŽêŽêŽêŽêŽêŽêŽêŽêŽêŽêŽêŽêŽêŽêŽêŽêŽêŽêŽêŽêŽêŽêŽêŽ
+êŽ êŽ¡êŽ¢êŽ£êŽ€êŽ¥êŽŠêŽ§êŽšêŽ©êŽªêŽ«êŽ¬êŽ­êŽ®êŽ¯êŽ°êŽ±êŽ²êŽ³êŽŽêŽµêŽ¶êŽ·êŽžêŽ¹êŽºêŽ»êŽŒêŽœêŽŸêŽ¿
+êµêµêµêµêµêµ
+êµêµêµêµêµêµêµêµêµêµêµêµêµêµêµêµêµêµêµêµêµêµêµêµêµêµ
+êµ êµ¡êµ¢êµ£êµ€êµ¥êµŠêµ§êµšêµ©êµªêµ«êµ¬êµ­êµ®êµ¯êµ°êµ±êµ²êµ³êµŽêµµêµ¶êµ·êµžêµ¹êµºêµ»êµŒêµœêµŸêµ¿
+ê¶ê¶ê¶ê¶ê¶ê¶
+ê¶ê¶ê¶ê¶ê¶ê¶ê¶ê¶ê¶ê¶ê¶ê¶ê¶ê¶ê¶ê¶ê¶ê¶ê¶ê¶ê¶ê¶ê¶ê¶ê¶ê¶
+ê¶ ê¶¡ê¶¢ê¶£ê¶€ê¶¥ê¶Šê¶§ê¶šê¶©ê¶ªê¶«ê¶¬ê¶­ê¶®ê¶¯ê¶°ê¶±ê¶²ê¶³ê¶Žê¶µê¶¶ê¶·ê¶žê¶¹ê¶ºê¶»ê¶Œê¶œê¶Ÿê¶¿
+ê·ê·ê·ê·ê·ê·
+ê·ê·ê·ê·ê·ê·ê·ê·ê·ê·ê·ê·ê·ê·ê·ê·ê·ê·ê·ê·ê·ê·ê·ê·ê·ê·
+ê· ê·¡ê·¢ê·£ê·€ê·¥ê·Šê·§ê·šê·©ê·ªê·«ê·¬ê·­ê·®ê·¯ê·°ê·±ê·²ê·³ê·Žê·µê·¶ê··ê·žê·¹ê·ºê·»ê·Œê·œê·Ÿê·¿
+êžêžêžêžêžêž
+êžêžêžêžêžêžêžêžêžêžêžêžêžêžêžêžêžêžêžêžêžêžêžêžêžêž
+êž êž¡êž¢êž£êž€êž¥êžŠêž§êžšêž©êžªêž«êž¬êž­êž®êž¯êž°êž±êž²êž³êžŽêžµêž¶êž·êžžêž¹êžºêž»êžŒêžœêžŸêž¿
+ê¹ê¹ê¹ê¹ê¹ê¹
+ê¹ê¹ê¹ê¹ê¹ê¹ê¹ê¹ê¹ê¹ê¹ê¹ê¹ê¹ê¹ê¹ê¹ê¹ê¹ê¹ê¹ê¹ê¹ê¹ê¹ê¹
+ê¹ ê¹¡ê¹¢ê¹£ê¹€ê¹¥ê¹Šê¹§ê¹šê¹©ê¹ªê¹«ê¹¬ê¹­ê¹®ê¹¯ê¹°ê¹±ê¹²ê¹³ê¹Žê¹µê¹¶ê¹·ê¹žê¹¹ê¹ºê¹»ê¹Œê¹œê¹Ÿê¹¿
+êºêºêºêºêºêº
+êºêºêºêºêºêºêºêºêºêºêºêºêºêºêºêºêºêºêºêºêºêºêºêºêºêº
+êº êº¡êº¢êº£êº€êº¥êºŠêº§êºšêº©êºªêº«êº¬êº­êº®êº¯êº°êº±êº²êº³êºŽêºµêº¶êº·êºžêº¹êººêº»êºŒêºœêºŸêº¿
+ê»ê»ê»ê»ê»ê»
+ê»ê»ê»ê»ê»ê»ê»ê»ê»ê»ê»ê»ê»ê»ê»ê»ê»ê»ê»ê»ê»ê»ê»ê»ê»ê»
+ê» ê»¡ê»¢ê»£ê»€ê»¥ê»Šê»§ê»šê»©ê»ªê»«ê»¬ê»­ê»®ê»¯ê»°ê»±ê»²ê»³ê»Žê»µê»¶ê»·ê»žê»¹ê»ºê»»ê»Œê»œê»Ÿê»¿
+êŒêŒêŒêŒêŒêŒ
+êŒêŒêŒêŒêŒêŒêŒêŒêŒêŒêŒêŒêŒêŒêŒêŒêŒêŒêŒêŒêŒêŒêŒêŒêŒêŒ
+êŒ êŒ¡êŒ¢êŒ£êŒ€êŒ¥êŒŠêŒ§êŒšêŒ©êŒªêŒ«êŒ¬êŒ­êŒ®êŒ¯êŒ°êŒ±êŒ²êŒ³êŒŽêŒµêŒ¶êŒ·êŒžêŒ¹êŒºêŒ»êŒŒêŒœêŒŸêŒ¿
+êœêœêœêœêœêœ
+êœêœêœêœêœêœêœêœêœêœêœêœêœêœêœêœêœêœêœêœêœêœêœêœêœêœ
+êœ êœ¡êœ¢êœ£êœ€êœ¥êœŠêœ§êœšêœ©êœªêœ«êœ¬êœ­êœ®êœ¯êœ°êœ±êœ²êœ³êœŽêœµêœ¶êœ·êœžêœ¹êœºêœ»êœŒêœœêœŸêœ¿
+êŸêŸêŸêŸêŸêŸ
+êŸêŸêŸêŸêŸêŸêŸêŸêŸêŸêŸêŸêŸêŸêŸêŸêŸêŸêŸêŸêŸêŸêŸêŸêŸêŸ
+êŸ êŸ¡êŸ¢êŸ£êŸ€êŸ¥êŸŠêŸ§êŸšêŸ©êŸªêŸ«êŸ¬êŸ­êŸ®êŸ¯êŸ°êŸ±êŸ²êŸ³êŸŽêŸµêŸ¶êŸ·êŸžêŸ¹êŸºêŸ»êŸŒêŸœêŸŸêŸ¿
+ê¿ê¿ê¿ê¿ê¿ê¿
+ê¿ê¿ê¿ê¿ê¿ê¿ê¿ê¿ê¿ê¿ê¿ê¿ê¿ê¿ê¿ê¿ê¿ê¿ê¿ê¿ê¿ê¿ê¿ê¿ê¿ê¿
+ê¿ ê¿¡ê¿¢ê¿£ê¿€ê¿¥ê¿Šê¿§ê¿šê¿©ê¿ªê¿«ê¿¬ê¿­ê¿®ê¿¯ê¿°ê¿±ê¿²ê¿³ê¿Žê¿µê¿¶ê¿·ê¿žê¿¹ê¿ºê¿»ê¿Œê¿œê¿Ÿê¿¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ë
+ë
+ë
+ë
+ë
+ë
+
+ë
+ë
+ë
+ë
+ë
+ë
+ë
+ë
+ë
+ë
+ë
+ë
+ë
+ë
+ë
+ë
+ë
+ë
+ë
+ë
+ë
+ë
+ë
+ë
+ë
+ë
+
+ë
+ ë
+¡ë
+¢ë
+£ë
+€ë
+¥ë
+Šë
+§ë
+šë
+©ë
+ªë
+«ë
+¬ë
+­ë
+®ë
+¯ë
+°ë
+±ë
+²ë
+³ë
+Žë
+µë
+¶ë
+·ë
+žë
+¹ë
+ºë
+»ë
+Œë
+œë
+Ÿë
+¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ëëëëëë
+ëëëëëëëëëëëëëëëëëëëëëëëëëë
+ë ë¡ë¢ë£ë€ë¥ëŠë§ëšë©ëªë«ë¬ë­ë®ë¯ë°ë±ë²ë³ëŽëµë¶ë·ëžë¹ëºë»ëŒëœëŸë¿
+ë ë ë ë ë ë 
+ë ë ë ë ë ë ë ë ë ë ë ë ë ë ë ë ë ë ë ë ë ë ë ë ë ë 
+ë  ë ¡ë ¢ë £ë €ë ¥ë Šë §ë šë ©ë ªë «ë ¬ë ­ë ®ë ¯ë °ë ±ë ²ë ³ë Žë µë ¶ë ·ë žë ¹ë ºë »ë Œë œë Ÿë ¿
+ë¡ë¡ë¡ë¡ë¡ë¡
+ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡ë¡
+ë¡ ë¡¡ë¡¢ë¡£ë¡€ë¡¥ë¡Šë¡§ë¡šë¡©ë¡ªë¡«ë¡¬ë¡­ë¡®ë¡¯ë¡°ë¡±ë¡²ë¡³ë¡Žë¡µë¡¶ë¡·ë¡žë¡¹ë¡ºë¡»ë¡Œë¡œë¡Ÿë¡¿
+ë¢ë¢ë¢ë¢ë¢ë¢
+ë¢ë¢ë¢ë¢ë¢ë¢ë¢ë¢ë¢ë¢ë¢ë¢ë¢ë¢ë¢ë¢ë¢ë¢ë¢ë¢ë¢ë¢ë¢ë¢ë¢ë¢
+ë¢ ë¢¡ë¢¢ë¢£ë¢€ë¢¥ë¢Šë¢§ë¢šë¢©ë¢ªë¢«ë¢¬ë¢­ë¢®ë¢¯ë¢°ë¢±ë¢²ë¢³ë¢Žë¢µë¢¶ë¢·ë¢žë¢¹ë¢ºë¢»ë¢Œë¢œë¢Ÿë¢¿
+ë£ë£ë£ë£ë£ë£
+ë£ë£ë£ë£ë£ë£ë£ë£ë£ë£ë£ë£ë£ë£ë£ë£ë£ë£ë£ë£ë£ë£ë£ë£ë£ë£
+ë£ ë£¡ë£¢ë££ë£€ë£¥ë£Šë£§ë£šë£©ë£ªë£«ë£¬ë£­ë£®ë£¯ë£°ë£±ë£²ë£³ë£Žë£µë£¶ë£·ë£žë£¹ë£ºë£»ë£Œë£œë£Ÿë£¿
+ë€ë€ë€ë€ë€ë€
+ë€ë€ë€ë€ë€ë€ë€ë€ë€ë€ë€ë€ë€ë€ë€ë€ë€ë€ë€ë€ë€ë€ë€ë€ë€ë€
+ë€ ë€¡ë€¢ë€£ë€€ë€¥ë€Šë€§ë€šë€©ë€ªë€«ë€¬ë€­ë€®ë€¯ë€°ë€±ë€²ë€³ë€Žë€µë€¶ë€·ë€žë€¹ë€ºë€»ë€Œë€œë€Ÿë€¿
+ë¥ë¥ë¥ë¥ë¥ë¥
+ë¥ë¥ë¥ë¥ë¥ë¥ë¥ë¥ë¥ë¥ë¥ë¥ë¥ë¥ë¥ë¥ë¥ë¥ë¥ë¥ë¥ë¥ë¥ë¥ë¥ë¥
+ë¥ ë¥¡ë¥¢ë¥£ë¥€ë¥¥ë¥Šë¥§ë¥šë¥©ë¥ªë¥«ë¥¬ë¥­ë¥®ë¥¯ë¥°ë¥±ë¥²ë¥³ë¥Žë¥µë¥¶ë¥·ë¥žë¥¹ë¥ºë¥»ë¥Œë¥œë¥Ÿë¥¿
+ëŠëŠëŠëŠëŠëŠ
+ëŠëŠëŠëŠëŠëŠëŠëŠëŠëŠëŠëŠëŠëŠëŠëŠëŠëŠëŠëŠëŠëŠëŠëŠëŠëŠ
+ëŠ ëŠ¡ëŠ¢ëŠ£ëŠ€ëŠ¥ëŠŠëŠ§ëŠšëŠ©ëŠªëŠ«ëŠ¬ëŠ­ëŠ®ëŠ¯ëŠ°ëŠ±ëŠ²ëŠ³ëŠŽëŠµëŠ¶ëŠ·ëŠžëŠ¹ëŠºëŠ»ëŠŒëŠœëŠŸëŠ¿
+ë§ë§ë§ë§ë§ë§
+ë§ë§ë§ë§ë§ë§ë§ë§ë§ë§ë§ë§ë§ë§ë§ë§ë§ë§ë§ë§ë§ë§ë§ë§ë§ë§
+ë§ ë§¡ë§¢ë§£ë§€ë§¥ë§Šë§§ë§šë§©ë§ªë§«ë§¬ë§­ë§®ë§¯ë§°ë§±ë§²ë§³ë§Žë§µë§¶ë§·ë§žë§¹ë§ºë§»ë§Œë§œë§Ÿë§¿
+ëšëšëšëšëšëš
+ëšëšëšëšëšëšëšëšëšëšëšëšëšëšëšëšëšëšëšëšëšëšëšëšëšëš
+ëš ëš¡ëš¢ëš£ëš€ëš¥ëšŠëš§ëššëš©ëšªëš«ëš¬ëš­ëš®ëš¯ëš°ëš±ëš²ëš³ëšŽëšµëš¶ëš·ëšžëš¹ëšºëš»ëšŒëšœëšŸëš¿
+ë©ë©ë©ë©ë©ë©
+ë©ë©ë©ë©ë©ë©ë©ë©ë©ë©ë©ë©ë©ë©ë©ë©ë©ë©ë©ë©ë©ë©ë©ë©ë©ë©
+ë© ë©¡ë©¢ë©£ë©€ë©¥ë©Šë©§ë©šë©©ë©ªë©«ë©¬ë©­ë©®ë©¯ë©°ë©±ë©²ë©³ë©Žë©µë©¶ë©·ë©žë©¹ë©ºë©»ë©Œë©œë©Ÿë©¿
+ëªëªëªëªëªëª
+ëªëªëªëªëªëªëªëªëªëªëªëªëªëªëªëªëªëªëªëªëªëªëªëªëªëª
+ëª ëª¡ëª¢ëª£ëª€ëª¥ëªŠëª§ëªšëª©ëªªëª«ëª¬ëª­ëª®ëª¯ëª°ëª±ëª²ëª³ëªŽëªµëª¶ëª·ëªžëª¹ëªºëª»ëªŒëªœëªŸëª¿
+ë«ë«ë«ë«ë«ë«
+ë«ë«ë«ë«ë«ë«ë«ë«ë«ë«ë«ë«ë«ë«ë«ë«ë«ë«ë«ë«ë«ë«ë«ë«ë«ë«
+ë« ë«¡ë«¢ë«£ë«€ë«¥ë«Šë«§ë«šë«©ë«ªë««ë«¬ë«­ë«®ë«¯ë«°ë«±ë«²ë«³ë«Žë«µë«¶ë«·ë«žë«¹ë«ºë«»ë«Œë«œë«Ÿë«¿
+ë¬ë¬ë¬ë¬ë¬ë¬
+ë¬ë¬ë¬ë¬ë¬ë¬ë¬ë¬ë¬ë¬ë¬ë¬ë¬ë¬ë¬ë¬ë¬ë¬ë¬ë¬ë¬ë¬ë¬ë¬ë¬ë¬
+ë¬ ë¬¡ë¬¢ë¬£ë¬€ë¬¥ë¬Šë¬§ë¬šë¬©ë¬ªë¬«ë¬¬ë¬­ë¬®ë¬¯ë¬°ë¬±ë¬²ë¬³ë¬Žë¬µë¬¶ë¬·ë¬žë¬¹ë¬ºë¬»ë¬Œë¬œë¬Ÿë¬¿
+ë­ë­ë­ë­ë­ë­
+ë­ë­ë­ë­ë­ë­ë­ë­ë­ë­ë­ë­ë­ë­ë­ë­ë­ë­ë­ë­ë­ë­ë­ë­ë­ë­
+ë­ ë­¡ë­¢ë­£ë­€ë­¥ë­Šë­§ë­šë­©ë­ªë­«ë­¬ë­­ë­®ë­¯ë­°ë­±ë­²ë­³ë­Žë­µë­¶ë­·ë­žë­¹ë­ºë­»ë­Œë­œë­Ÿë­¿
+ë®ë®ë®ë®ë®ë®
+ë®ë®ë®ë®ë®ë®ë®ë®ë®ë®ë®ë®ë®ë®ë®ë®ë®ë®ë®ë®ë®ë®ë®ë®ë®ë®
+ë® ë®¡ë®¢ë®£ë®€ë®¥ë®Šë®§ë®šë®©ë®ªë®«ë®¬ë®­ë®®ë®¯ë®°ë®±ë®²ë®³ë®Žë®µë®¶ë®·ë®žë®¹ë®ºë®»ë®Œë®œë®Ÿë®¿
+ë¯ë¯ë¯ë¯ë¯ë¯
+ë¯ë¯ë¯ë¯ë¯ë¯ë¯ë¯ë¯ë¯ë¯ë¯ë¯ë¯ë¯ë¯ë¯ë¯ë¯ë¯ë¯ë¯ë¯ë¯ë¯ë¯
+ë¯ ë¯¡ë¯¢ë¯£ë¯€ë¯¥ë¯Šë¯§ë¯šë¯©ë¯ªë¯«ë¯¬ë¯­ë¯®ë¯¯ë¯°ë¯±ë¯²ë¯³ë¯Žë¯µë¯¶ë¯·ë¯žë¯¹ë¯ºë¯»ë¯Œë¯œë¯Ÿë¯¿
+ë°ë°ë°ë°ë°ë°
+ë°ë°ë°ë°ë°ë°ë°ë°ë°ë°ë°ë°ë°ë°ë°ë°ë°ë°ë°ë°ë°ë°ë°ë°ë°ë°
+ë° ë°¡ë°¢ë°£ë°€ë°¥ë°Šë°§ë°šë°©ë°ªë°«ë°¬ë°­ë°®ë°¯ë°°ë°±ë°²ë°³ë°Žë°µë°¶ë°·ë°žë°¹ë°ºë°»ë°Œë°œë°Ÿë°¿
+ë±ë±ë±ë±ë±ë±
+ë±ë±ë±ë±ë±ë±ë±ë±ë±ë±ë±ë±ë±ë±ë±ë±ë±ë±ë±ë±ë±ë±ë±ë±ë±ë±
+ë± ë±¡ë±¢ë±£ë±€ë±¥ë±Šë±§ë±šë±©ë±ªë±«ë±¬ë±­ë±®ë±¯ë±°ë±±ë±²ë±³ë±Žë±µë±¶ë±·ë±žë±¹ë±ºë±»ë±Œë±œë±Ÿë±¿
+ë²ë²ë²ë²ë²ë²
+ë²ë²ë²ë²ë²ë²ë²ë²ë²ë²ë²ë²ë²ë²ë²ë²ë²ë²ë²ë²ë²ë²ë²ë²ë²ë²
+ë² ë²¡ë²¢ë²£ë²€ë²¥ë²Šë²§ë²šë²©ë²ªë²«ë²¬ë²­ë²®ë²¯ë²°ë²±ë²²ë²³ë²Žë²µë²¶ë²·ë²žë²¹ë²ºë²»ë²Œë²œë²Ÿë²¿
+ë³ë³ë³ë³ë³ë³
+ë³ë³ë³ë³ë³ë³ë³ë³ë³ë³ë³ë³ë³ë³ë³ë³ë³ë³ë³ë³ë³ë³ë³ë³ë³ë³
+ë³ ë³¡ë³¢ë³£ë³€ë³¥ë³Šë³§ë³šë³©ë³ªë³«ë³¬ë³­ë³®ë³¯ë³°ë³±ë³²ë³³ë³Žë³µë³¶ë³·ë³žë³¹ë³ºë³»ë³Œë³œë³Ÿë³¿
+ëŽëŽëŽëŽëŽëŽ
+ëŽëŽëŽëŽëŽëŽëŽëŽëŽëŽëŽëŽëŽëŽëŽëŽëŽëŽëŽëŽëŽëŽëŽëŽëŽëŽ
+ëŽ ëŽ¡ëŽ¢ëŽ£ëŽ€ëŽ¥ëŽŠëŽ§ëŽšëŽ©ëŽªëŽ«ëŽ¬ëŽ­ëŽ®ëŽ¯ëŽ°ëŽ±ëŽ²ëŽ³ëŽŽëŽµëŽ¶ëŽ·ëŽžëŽ¹ëŽºëŽ»ëŽŒëŽœëŽŸëŽ¿
+ëµëµëµëµëµëµ
+ëµëµëµëµëµëµëµëµëµëµëµëµëµëµëµëµëµëµëµëµëµëµëµëµëµëµ
+ëµ ëµ¡ëµ¢ëµ£ëµ€ëµ¥ëµŠëµ§ëµšëµ©ëµªëµ«ëµ¬ëµ­ëµ®ëµ¯ëµ°ëµ±ëµ²ëµ³ëµŽëµµëµ¶ëµ·ëµžëµ¹ëµºëµ»ëµŒëµœëµŸëµ¿
+ë¶ë¶ë¶ë¶ë¶ë¶
+ë¶ë¶ë¶ë¶ë¶ë¶ë¶ë¶ë¶ë¶ë¶ë¶ë¶ë¶ë¶ë¶ë¶ë¶ë¶ë¶ë¶ë¶ë¶ë¶ë¶ë¶
+ë¶ ë¶¡ë¶¢ë¶£ë¶€ë¶¥ë¶Šë¶§ë¶šë¶©ë¶ªë¶«ë¶¬ë¶­ë¶®ë¶¯ë¶°ë¶±ë¶²ë¶³ë¶Žë¶µë¶¶ë¶·ë¶žë¶¹ë¶ºë¶»ë¶Œë¶œë¶Ÿë¶¿
+ë·ë·ë·ë·ë·ë·
+ë·ë·ë·ë·ë·ë·ë·ë·ë·ë·ë·ë·ë·ë·ë·ë·ë·ë·ë·ë·ë·ë·ë·ë·ë·ë·
+ë· ë·¡ë·¢ë·£ë·€ë·¥ë·Šë·§ë·šë·©ë·ªë·«ë·¬ë·­ë·®ë·¯ë·°ë·±ë·²ë·³ë·Žë·µë·¶ë··ë·žë·¹ë·ºë·»ë·Œë·œë·Ÿë·¿
+ëžëžëžëžëžëž
+ëžëžëžëžëžëžëžëžëžëžëžëžëžëžëžëžëžëžëžëžëžëžëžëžëžëž
+ëž ëž¡ëž¢ëž£ëž€ëž¥ëžŠëž§ëžšëž©ëžªëž«ëž¬ëž­ëž®ëž¯ëž°ëž±ëž²ëž³ëžŽëžµëž¶ëž·ëžžëž¹ëžºëž»ëžŒëžœëžŸëž¿
+ë¹ë¹ë¹ë¹ë¹ë¹
+ë¹ë¹ë¹ë¹ë¹ë¹ë¹ë¹ë¹ë¹ë¹ë¹ë¹ë¹ë¹ë¹ë¹ë¹ë¹ë¹ë¹ë¹ë¹ë¹ë¹ë¹
+ë¹ ë¹¡ë¹¢ë¹£ë¹€ë¹¥ë¹Šë¹§ë¹šë¹©ë¹ªë¹«ë¹¬ë¹­ë¹®ë¹¯ë¹°ë¹±ë¹²ë¹³ë¹Žë¹µë¹¶ë¹·ë¹žë¹¹ë¹ºë¹»ë¹Œë¹œë¹Ÿë¹¿
+ëºëºëºëºëºëº
+ëºëºëºëºëºëºëºëºëºëºëºëºëºëºëºëºëºëºëºëºëºëºëºëºëºëº
+ëº ëº¡ëº¢ëº£ëº€ëº¥ëºŠëº§ëºšëº©ëºªëº«ëº¬ëº­ëº®ëº¯ëº°ëº±ëº²ëº³ëºŽëºµëº¶ëº·ëºžëº¹ëººëº»ëºŒëºœëºŸëº¿
+ë»ë»ë»ë»ë»ë»
+ë»ë»ë»ë»ë»ë»ë»ë»ë»ë»ë»ë»ë»ë»ë»ë»ë»ë»ë»ë»ë»ë»ë»ë»ë»ë»
+ë» ë»¡ë»¢ë»£ë»€ë»¥ë»Šë»§ë»šë»©ë»ªë»«ë»¬ë»­ë»®ë»¯ë»°ë»±ë»²ë»³ë»Žë»µë»¶ë»·ë»žë»¹ë»ºë»»ë»Œë»œë»Ÿë»¿
+ëŒëŒëŒëŒëŒëŒ
+ëŒëŒëŒëŒëŒëŒëŒëŒëŒëŒëŒëŒëŒëŒëŒëŒëŒëŒëŒëŒëŒëŒëŒëŒëŒëŒ
+ëŒ ëŒ¡ëŒ¢ëŒ£ëŒ€ëŒ¥ëŒŠëŒ§ëŒšëŒ©ëŒªëŒ«ëŒ¬ëŒ­ëŒ®ëŒ¯ëŒ°ëŒ±ëŒ²ëŒ³ëŒŽëŒµëŒ¶ëŒ·ëŒžëŒ¹ëŒºëŒ»ëŒŒëŒœëŒŸëŒ¿
+ëœëœëœëœëœëœ
+ëœëœëœëœëœëœëœëœëœëœëœëœëœëœëœëœëœëœëœëœëœëœëœëœëœëœ
+ëœ ëœ¡ëœ¢ëœ£ëœ€ëœ¥ëœŠëœ§ëœšëœ©ëœªëœ«ëœ¬ëœ­ëœ®ëœ¯ëœ°ëœ±ëœ²ëœ³ëœŽëœµëœ¶ëœ·ëœžëœ¹ëœºëœ»ëœŒëœœëœŸëœ¿
+ëŸëŸëŸëŸëŸëŸ
+ëŸëŸëŸëŸëŸëŸëŸëŸëŸëŸëŸëŸëŸëŸëŸëŸëŸëŸëŸëŸëŸëŸëŸëŸëŸëŸ
+ëŸ ëŸ¡ëŸ¢ëŸ£ëŸ€ëŸ¥ëŸŠëŸ§ëŸšëŸ©ëŸªëŸ«ëŸ¬ëŸ­ëŸ®ëŸ¯ëŸ°ëŸ±ëŸ²ëŸ³ëŸŽëŸµëŸ¶ëŸ·ëŸžëŸ¹ëŸºëŸ»ëŸŒëŸœëŸŸëŸ¿
+ë¿ë¿ë¿ë¿ë¿ë¿
+ë¿ë¿ë¿ë¿ë¿ë¿ë¿ë¿ë¿ë¿ë¿ë¿ë¿ë¿ë¿ë¿ë¿ë¿ë¿ë¿ë¿ë¿ë¿ë¿ë¿ë¿
+ë¿ ë¿¡ë¿¢ë¿£ë¿€ë¿¥ë¿Šë¿§ë¿šë¿©ë¿ªë¿«ë¿¬ë¿­ë¿®ë¿¯ë¿°ë¿±ë¿²ë¿³ë¿Žë¿µë¿¶ë¿·ë¿žë¿¹ë¿ºë¿»ë¿Œë¿œë¿Ÿë¿¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ì
+ì
+ì
+ì
+ì
+ì
+
+ì
+ì
+ì
+ì
+ì
+ì
+ì
+ì
+ì
+ì
+ì
+ì
+ì
+ì
+ì
+ì
+ì
+ì
+ì
+ì
+ì
+ì
+ì
+ì
+ì
+ì
+
+ì
+ ì
+¡ì
+¢ì
+£ì
+€ì
+¥ì
+Šì
+§ì
+šì
+©ì
+ªì
+«ì
+¬ì
+­ì
+®ì
+¯ì
+°ì
+±ì
+²ì
+³ì
+Žì
+µì
+¶ì
+·ì
+žì
+¹ì
+ºì
+»ì
+Œì
+œì
+Ÿì
+¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ìììììì
+ìììììììììììììììììììììììììì
+ì ì¡ì¢ì£ì€ì¥ìŠì§ìšì©ìªì«ì¬ì­ì®ì¯ì°ì±ì²ì³ìŽìµì¶ì·ìžì¹ìºì»ìŒìœìŸì¿
+ì ì ì ì ì ì 
+ì ì ì ì ì ì ì ì ì ì ì ì ì ì ì ì ì ì ì ì ì ì ì ì ì ì 
+ì  ì ¡ì ¢ì £ì €ì ¥ì Šì §ì šì ©ì ªì «ì ¬ì ­ì ®ì ¯ì °ì ±ì ²ì ³ì Žì µì ¶ì ·ì žì ¹ì ºì »ì Œì œì Ÿì ¿
+ì¡ì¡ì¡ì¡ì¡ì¡
+ì¡ì¡ì¡ì¡ì¡ì¡ì¡ì¡ì¡ì¡ì¡ì¡ì¡ì¡ì¡ì¡ì¡ì¡ì¡ì¡ì¡ì¡ì¡ì¡ì¡ì¡
+ì¡ ì¡¡ì¡¢ì¡£ì¡€ì¡¥ì¡Šì¡§ì¡šì¡©ì¡ªì¡«ì¡¬ì¡­ì¡®ì¡¯ì¡°ì¡±ì¡²ì¡³ì¡Žì¡µì¡¶ì¡·ì¡žì¡¹ì¡ºì¡»ì¡Œì¡œì¡Ÿì¡¿
+ì¢ì¢ì¢ì¢ì¢ì¢
+ì¢ì¢ì¢ì¢ì¢ì¢ì¢ì¢ì¢ì¢ì¢ì¢ì¢ì¢ì¢ì¢ì¢ì¢ì¢ì¢ì¢ì¢ì¢ì¢ì¢ì¢
+ì¢ ì¢¡ì¢¢ì¢£ì¢€ì¢¥ì¢Šì¢§ì¢šì¢©ì¢ªì¢«ì¢¬ì¢­ì¢®ì¢¯ì¢°ì¢±ì¢²ì¢³ì¢Žì¢µì¢¶ì¢·ì¢žì¢¹ì¢ºì¢»ì¢Œì¢œì¢Ÿì¢¿
+ì£ì£ì£ì£ì£ì£
+ì£ì£ì£ì£ì£ì£ì£ì£ì£ì£ì£ì£ì£ì£ì£ì£ì£ì£ì£ì£ì£ì£ì£ì£ì£ì£
+ì£ ì£¡ì£¢ì££ì£€ì£¥ì£Šì£§ì£šì£©ì£ªì£«ì£¬ì£­ì£®ì£¯ì£°ì£±ì£²ì£³ì£Žì£µì£¶ì£·ì£žì£¹ì£ºì£»ì£Œì£œì£Ÿì£¿
+ì€ì€ì€ì€ì€ì€
+ì€ì€ì€ì€ì€ì€ì€ì€ì€ì€ì€ì€ì€ì€ì€ì€ì€ì€ì€ì€ì€ì€ì€ì€ì€ì€
+ì€ ì€¡ì€¢ì€£ì€€ì€¥ì€Šì€§ì€šì€©ì€ªì€«ì€¬ì€­ì€®ì€¯ì€°ì€±ì€²ì€³ì€Žì€µì€¶ì€·ì€žì€¹ì€ºì€»ì€Œì€œì€Ÿì€¿
+ì¥ì¥ì¥ì¥ì¥ì¥
+ì¥ì¥ì¥ì¥ì¥ì¥ì¥ì¥ì¥ì¥ì¥ì¥ì¥ì¥ì¥ì¥ì¥ì¥ì¥ì¥ì¥ì¥ì¥ì¥ì¥ì¥
+ì¥ ì¥¡ì¥¢ì¥£ì¥€ì¥¥ì¥Šì¥§ì¥šì¥©ì¥ªì¥«ì¥¬ì¥­ì¥®ì¥¯ì¥°ì¥±ì¥²ì¥³ì¥Žì¥µì¥¶ì¥·ì¥žì¥¹ì¥ºì¥»ì¥Œì¥œì¥Ÿì¥¿
+ìŠìŠìŠìŠìŠìŠ
+ìŠìŠìŠìŠìŠìŠìŠìŠìŠìŠìŠìŠìŠìŠìŠìŠìŠìŠìŠìŠìŠìŠìŠìŠìŠìŠ
+ìŠ ìŠ¡ìŠ¢ìŠ£ìŠ€ìŠ¥ìŠŠìŠ§ìŠšìŠ©ìŠªìŠ«ìŠ¬ìŠ­ìŠ®ìŠ¯ìŠ°ìŠ±ìŠ²ìŠ³ìŠŽìŠµìŠ¶ìŠ·ìŠžìŠ¹ìŠºìŠ»ìŠŒìŠœìŠŸìŠ¿
+ì§ì§ì§ì§ì§ì§
+ì§ì§ì§ì§ì§ì§ì§ì§ì§ì§ì§ì§ì§ì§ì§ì§ì§ì§ì§ì§ì§ì§ì§ì§ì§ì§
+ì§ ì§¡ì§¢ì§£ì§€ì§¥ì§Šì§§ì§šì§©ì§ªì§«ì§¬ì§­ì§®ì§¯ì§°ì§±ì§²ì§³ì§Žì§µì§¶ì§·ì§žì§¹ì§ºì§»ì§Œì§œì§Ÿì§¿
+ìšìšìšìšìšìš
+ìšìšìšìšìšìšìšìšìšìšìšìšìšìšìšìšìšìšìšìšìšìšìšìšìšìš
+ìš ìš¡ìš¢ìš£ìš€ìš¥ìšŠìš§ìššìš©ìšªìš«ìš¬ìš­ìš®ìš¯ìš°ìš±ìš²ìš³ìšŽìšµìš¶ìš·ìšžìš¹ìšºìš»ìšŒìšœìšŸìš¿
+ì©ì©ì©ì©ì©ì©
+ì©ì©ì©ì©ì©ì©ì©ì©ì©ì©ì©ì©ì©ì©ì©ì©ì©ì©ì©ì©ì©ì©ì©ì©ì©ì©
+ì© ì©¡ì©¢ì©£ì©€ì©¥ì©Šì©§ì©šì©©ì©ªì©«ì©¬ì©­ì©®ì©¯ì©°ì©±ì©²ì©³ì©Žì©µì©¶ì©·ì©žì©¹ì©ºì©»ì©Œì©œì©Ÿì©¿
+ìªìªìªìªìªìª
+ìªìªìªìªìªìªìªìªìªìªìªìªìªìªìªìªìªìªìªìªìªìªìªìªìªìª
+ìª ìª¡ìª¢ìª£ìª€ìª¥ìªŠìª§ìªšìª©ìªªìª«ìª¬ìª­ìª®ìª¯ìª°ìª±ìª²ìª³ìªŽìªµìª¶ìª·ìªžìª¹ìªºìª»ìªŒìªœìªŸìª¿
+ì«ì«ì«ì«ì«ì«
+ì«ì«ì«ì«ì«ì«ì«ì«ì«ì«ì«ì«ì«ì«ì«ì«ì«ì«ì«ì«ì«ì«ì«ì«ì«ì«
+ì« ì«¡ì«¢ì«£ì«€ì«¥ì«Šì«§ì«šì«©ì«ªì««ì«¬ì«­ì«®ì«¯ì«°ì«±ì«²ì«³ì«Žì«µì«¶ì«·ì«žì«¹ì«ºì«»ì«Œì«œì«Ÿì«¿
+ì¬ì¬ì¬ì¬ì¬ì¬
+ì¬ì¬ì¬ì¬ì¬ì¬ì¬ì¬ì¬ì¬ì¬ì¬ì¬ì¬ì¬ì¬ì¬ì¬ì¬ì¬ì¬ì¬ì¬ì¬ì¬ì¬
+ì¬ ì¬¡ì¬¢ì¬£ì¬€ì¬¥ì¬Šì¬§ì¬šì¬©ì¬ªì¬«ì¬¬ì¬­ì¬®ì¬¯ì¬°ì¬±ì¬²ì¬³ì¬Žì¬µì¬¶ì¬·ì¬žì¬¹ì¬ºì¬»ì¬Œì¬œì¬Ÿì¬¿
+ì­ì­ì­ì­ì­ì­
+ì­ì­ì­ì­ì­ì­ì­ì­ì­ì­ì­ì­ì­ì­ì­ì­ì­ì­ì­ì­ì­ì­ì­ì­ì­ì­
+ì­ ì­¡ì­¢ì­£ì­€ì­¥ì­Šì­§ì­šì­©ì­ªì­«ì­¬ì­­ì­®ì­¯ì­°ì­±ì­²ì­³ì­Žì­µì­¶ì­·ì­žì­¹ì­ºì­»ì­Œì­œì­Ÿì­¿
+ì®ì®ì®ì®ì®ì®
+ì®ì®ì®ì®ì®ì®ì®ì®ì®ì®ì®ì®ì®ì®ì®ì®ì®ì®ì®ì®ì®ì®ì®ì®ì®ì®
+ì® ì®¡ì®¢ì®£ì®€ì®¥ì®Šì®§ì®šì®©ì®ªì®«ì®¬ì®­ì®®ì®¯ì®°ì®±ì®²ì®³ì®Žì®µì®¶ì®·ì®žì®¹ì®ºì®»ì®Œì®œì®Ÿì®¿
+ì¯ì¯ì¯ì¯ì¯ì¯
+ì¯ì¯ì¯ì¯ì¯ì¯ì¯ì¯ì¯ì¯ì¯ì¯ì¯ì¯ì¯ì¯ì¯ì¯ì¯ì¯ì¯ì¯ì¯ì¯ì¯ì¯
+ì¯ ì¯¡ì¯¢ì¯£ì¯€ì¯¥ì¯Šì¯§ì¯šì¯©ì¯ªì¯«ì¯¬ì¯­ì¯®ì¯¯ì¯°ì¯±ì¯²ì¯³ì¯Žì¯µì¯¶ì¯·ì¯žì¯¹ì¯ºì¯»ì¯Œì¯œì¯Ÿì¯¿
+ì°ì°ì°ì°ì°ì°
+ì°ì°ì°ì°ì°ì°ì°ì°ì°ì°ì°ì°ì°ì°ì°ì°ì°ì°ì°ì°ì°ì°ì°ì°ì°ì°
+ì° ì°¡ì°¢ì°£ì°€ì°¥ì°Šì°§ì°šì°©ì°ªì°«ì°¬ì°­ì°®ì°¯ì°°ì°±ì°²ì°³ì°Žì°µì°¶ì°·ì°žì°¹ì°ºì°»ì°Œì°œì°Ÿì°¿
+ì±ì±ì±ì±ì±ì±
+ì±ì±ì±ì±ì±ì±ì±ì±ì±ì±ì±ì±ì±ì±ì±ì±ì±ì±ì±ì±ì±ì±ì±ì±ì±ì±
+ì± ì±¡ì±¢ì±£ì±€ì±¥ì±Šì±§ì±šì±©ì±ªì±«ì±¬ì±­ì±®ì±¯ì±°ì±±ì±²ì±³ì±Žì±µì±¶ì±·ì±žì±¹ì±ºì±»ì±Œì±œì±Ÿì±¿
+ì²ì²ì²ì²ì²ì²
+ì²ì²ì²ì²ì²ì²ì²ì²ì²ì²ì²ì²ì²ì²ì²ì²ì²ì²ì²ì²ì²ì²ì²ì²ì²ì²
+ì² ì²¡ì²¢ì²£ì²€ì²¥ì²Šì²§ì²šì²©ì²ªì²«ì²¬ì²­ì²®ì²¯ì²°ì²±ì²²ì²³ì²Žì²µì²¶ì²·ì²žì²¹ì²ºì²»ì²Œì²œì²Ÿì²¿
+ì³ì³ì³ì³ì³ì³
+ì³ì³ì³ì³ì³ì³ì³ì³ì³ì³ì³ì³ì³ì³ì³ì³ì³ì³ì³ì³ì³ì³ì³ì³ì³ì³
+ì³ ì³¡ì³¢ì³£ì³€ì³¥ì³Šì³§ì³šì³©ì³ªì³«ì³¬ì³­ì³®ì³¯ì³°ì³±ì³²ì³³ì³Žì³µì³¶ì³·ì³žì³¹ì³ºì³»ì³Œì³œì³Ÿì³¿
+ìŽìŽìŽìŽìŽìŽ
+ìŽìŽìŽìŽìŽìŽìŽìŽìŽìŽìŽìŽìŽìŽìŽìŽìŽìŽìŽìŽìŽìŽìŽìŽìŽìŽ
+ìŽ ìŽ¡ìŽ¢ìŽ£ìŽ€ìŽ¥ìŽŠìŽ§ìŽšìŽ©ìŽªìŽ«ìŽ¬ìŽ­ìŽ®ìŽ¯ìŽ°ìŽ±ìŽ²ìŽ³ìŽŽìŽµìŽ¶ìŽ·ìŽžìŽ¹ìŽºìŽ»ìŽŒìŽœìŽŸìŽ¿
+ìµìµìµìµìµìµ
+ìµìµìµìµìµìµìµìµìµìµìµìµìµìµìµìµìµìµìµìµìµìµìµìµìµìµ
+ìµ ìµ¡ìµ¢ìµ£ìµ€ìµ¥ìµŠìµ§ìµšìµ©ìµªìµ«ìµ¬ìµ­ìµ®ìµ¯ìµ°ìµ±ìµ²ìµ³ìµŽìµµìµ¶ìµ·ìµžìµ¹ìµºìµ»ìµŒìµœìµŸìµ¿
+ì¶ì¶ì¶ì¶ì¶ì¶
+ì¶ì¶ì¶ì¶ì¶ì¶ì¶ì¶ì¶ì¶ì¶ì¶ì¶ì¶ì¶ì¶ì¶ì¶ì¶ì¶ì¶ì¶ì¶ì¶ì¶ì¶
+ì¶ ì¶¡ì¶¢ì¶£ì¶€ì¶¥ì¶Šì¶§ì¶šì¶©ì¶ªì¶«ì¶¬ì¶­ì¶®ì¶¯ì¶°ì¶±ì¶²ì¶³ì¶Žì¶µì¶¶ì¶·ì¶žì¶¹ì¶ºì¶»ì¶Œì¶œì¶Ÿì¶¿
+ì·ì·ì·ì·ì·ì·
+ì·ì·ì·ì·ì·ì·ì·ì·ì·ì·ì·ì·ì·ì·ì·ì·ì·ì·ì·ì·ì·ì·ì·ì·ì·ì·
+ì· ì·¡ì·¢ì·£ì·€ì·¥ì·Šì·§ì·šì·©ì·ªì·«ì·¬ì·­ì·®ì·¯ì·°ì·±ì·²ì·³ì·Žì·µì·¶ì··ì·žì·¹ì·ºì·»ì·Œì·œì·Ÿì·¿
+ìžìžìžìžìžìž
+ìžìžìžìžìžìžìžìžìžìžìžìžìžìžìžìžìžìžìžìžìžìžìžìžìžìž
+ìž ìž¡ìž¢ìž£ìž€ìž¥ìžŠìž§ìžšìž©ìžªìž«ìž¬ìž­ìž®ìž¯ìž°ìž±ìž²ìž³ìžŽìžµìž¶ìž·ìžžìž¹ìžºìž»ìžŒìžœìžŸìž¿
+ì¹ì¹ì¹ì¹ì¹ì¹
+ì¹ì¹ì¹ì¹ì¹ì¹ì¹ì¹ì¹ì¹ì¹ì¹ì¹ì¹ì¹ì¹ì¹ì¹ì¹ì¹ì¹ì¹ì¹ì¹ì¹ì¹
+ì¹ ì¹¡ì¹¢ì¹£ì¹€ì¹¥ì¹Šì¹§ì¹šì¹©ì¹ªì¹«ì¹¬ì¹­ì¹®ì¹¯ì¹°ì¹±ì¹²ì¹³ì¹Žì¹µì¹¶ì¹·ì¹žì¹¹ì¹ºì¹»ì¹Œì¹œì¹Ÿì¹¿
+ìºìºìºìºìºìº
+ìºìºìºìºìºìºìºìºìºìºìºìºìºìºìºìºìºìºìºìºìºìºìºìºìºìº
+ìº ìº¡ìº¢ìº£ìº€ìº¥ìºŠìº§ìºšìº©ìºªìº«ìº¬ìº­ìº®ìº¯ìº°ìº±ìº²ìº³ìºŽìºµìº¶ìº·ìºžìº¹ìººìº»ìºŒìºœìºŸìº¿
+ì»ì»ì»ì»ì»ì»
+ì»ì»ì»ì»ì»ì»ì»ì»ì»ì»ì»ì»ì»ì»ì»ì»ì»ì»ì»ì»ì»ì»ì»ì»ì»ì»
+ì» ì»¡ì»¢ì»£ì»€ì»¥ì»Šì»§ì»šì»©ì»ªì»«ì»¬ì»­ì»®ì»¯ì»°ì»±ì»²ì»³ì»Žì»µì»¶ì»·ì»žì»¹ì»ºì»»ì»Œì»œì»Ÿì»¿
+ìŒìŒìŒìŒìŒìŒ
+ìŒìŒìŒìŒìŒìŒìŒìŒìŒìŒìŒìŒìŒìŒìŒìŒìŒìŒìŒìŒìŒìŒìŒìŒìŒìŒ
+ìŒ ìŒ¡ìŒ¢ìŒ£ìŒ€ìŒ¥ìŒŠìŒ§ìŒšìŒ©ìŒªìŒ«ìŒ¬ìŒ­ìŒ®ìŒ¯ìŒ°ìŒ±ìŒ²ìŒ³ìŒŽìŒµìŒ¶ìŒ·ìŒžìŒ¹ìŒºìŒ»ìŒŒìŒœìŒŸìŒ¿
+ìœìœìœìœìœìœ
+ìœìœìœìœìœìœìœìœìœìœìœìœìœìœìœìœìœìœìœìœìœìœìœìœìœìœ
+ìœ ìœ¡ìœ¢ìœ£ìœ€ìœ¥ìœŠìœ§ìœšìœ©ìœªìœ«ìœ¬ìœ­ìœ®ìœ¯ìœ°ìœ±ìœ²ìœ³ìœŽìœµìœ¶ìœ·ìœžìœ¹ìœºìœ»ìœŒìœœìœŸìœ¿
+ìŸìŸìŸìŸìŸìŸ
+ìŸìŸìŸìŸìŸìŸìŸìŸìŸìŸìŸìŸìŸìŸìŸìŸìŸìŸìŸìŸìŸìŸìŸìŸìŸìŸ
+ìŸ ìŸ¡ìŸ¢ìŸ£ìŸ€ìŸ¥ìŸŠìŸ§ìŸšìŸ©ìŸªìŸ«ìŸ¬ìŸ­ìŸ®ìŸ¯ìŸ°ìŸ±ìŸ²ìŸ³ìŸŽìŸµìŸ¶ìŸ·ìŸžìŸ¹ìŸºìŸ»ìŸŒìŸœìŸŸìŸ¿
+ì¿ì¿ì¿ì¿ì¿ì¿
+ì¿ì¿ì¿ì¿ì¿ì¿ì¿ì¿ì¿ì¿ì¿ì¿ì¿ì¿ì¿ì¿ì¿ì¿ì¿ì¿ì¿ì¿ì¿ì¿ì¿ì¿
+ì¿ ì¿¡ì¿¢ì¿£ì¿€ì¿¥ì¿Šì¿§ì¿šì¿©ì¿ªì¿«ì¿¬ì¿­ì¿®ì¿¯ì¿°ì¿±ì¿²ì¿³ì¿Žì¿µì¿¶ì¿·ì¿žì¿¹ì¿ºì¿»ì¿Œì¿œì¿Ÿì¿¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+í
+í
+í
+í
+í
+í
+
+í
+í
+í
+í
+í
+í
+í
+í
+í
+í
+í
+í
+í
+í
+í
+í
+í
+í
+í
+í
+í
+í
+í
+í
+í
+í
+
+í
+ í
+¡í
+¢í
+£í
+€í
+¥í
+Ší
+§í
+ší
+©í
+ªí
+«í
+¬í
+­í
+®í
+¯í
+°í
+±í
+²í
+³í
+Ží
+µí
+¶í
+·í
+ží
+¹í
+ºí
+»í
+Œí
+œí
+Ÿí
+¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+íííííí
+íííííííííííííííííííííííííí
+í í¡í¢í£
+
+Free block (U+D7A4-U+D7FF):
+
+í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿íííííí
+ííííííííííííííííííííííííííí í¡í¢í£
+í€í¥íŠí§íší©íªí«í¬í­í®í¯í°í±í²í³íŽíµí¶í·íží¹íºí»íŒíœíŸí¿
+
+High Surrogates (U+D800-U+DB7F):
+
+í í í í í í 
+í í í í í í í í í í í í í í í í í í í í í í í í í í í  í ¡í ¢í £í €í ¥í Ší §í ší ©í ªí «í ¬í ­í ®í ¯í °í ±í ²í ³í Ží µí ¶í ·í ží ¹í ºí »í Œí œí Ÿí ¿
+í¡í¡í¡í¡í¡í¡
+í¡í¡í¡í¡í¡í¡í¡í¡í¡í¡í¡í¡í¡í¡í¡í¡í¡í¡í¡í¡í¡í¡í¡í¡í¡í¡í¡ í¡¡í¡¢í¡£í¡€í¡¥í¡Ší¡§í¡ší¡©í¡ªí¡«í¡¬í¡­í¡®í¡¯í¡°í¡±í¡²í¡³í¡Ží¡µí¡¶í¡·í¡ží¡¹í¡ºí¡»í¡Œí¡œí¡Ÿí¡¿
+í¢í¢í¢í¢í¢í¢
+í¢í¢í¢í¢í¢í¢í¢í¢í¢í¢í¢í¢í¢í¢í¢í¢í¢í¢í¢í¢í¢í¢í¢í¢í¢í¢í¢ í¢¡í¢¢í¢£í¢€í¢¥í¢Ší¢§í¢ší¢©í¢ªí¢«í¢¬í¢­í¢®í¢¯í¢°í¢±í¢²í¢³í¢Ží¢µí¢¶í¢·í¢ží¢¹í¢ºí¢»í¢Œí¢œí¢Ÿí¢¿
+í£í£í£í£í£í£
+í£í£í£í£í£í£í£í£í£í£í£í£í£í£í£í£í£í£í£í£í£í£í£í£í£í£í£ í£¡í£¢í££í£€í£¥í£Ší£§í£ší£©í£ªí£«í£¬í£­í£®í£¯í£°í£±í£²í£³í£Ží£µí£¶í£·í£ží£¹í£ºí£»í£Œí£œí£Ÿí£¿
+í€í€í€í€í€í€
+í€í€í€í€í€í€í€í€í€í€í€í€í€í€í€í€í€í€í€í€í€í€í€í€í€í€í€ í€¡í€¢í€£í€€í€¥í€Ší€§í€ší€©í€ªí€«í€¬í€­í€®í€¯í€°í€±í€²í€³í€Ží€µí€¶í€·í€ží€¹í€ºí€»í€Œí€œí€Ÿí€¿
+í¥í¥í¥í¥í¥í¥
+í¥í¥í¥í¥í¥í¥í¥í¥í¥í¥í¥í¥í¥í¥í¥í¥í¥í¥í¥í¥í¥í¥í¥í¥í¥í¥í¥ í¥¡í¥¢í¥£í¥€í¥¥í¥Ší¥§í¥ší¥©í¥ªí¥«í¥¬í¥­í¥®í¥¯í¥°í¥±í¥²í¥³í¥Ží¥µí¥¶í¥·í¥ží¥¹í¥ºí¥»í¥Œí¥œí¥Ÿí¥¿
+íŠíŠíŠíŠíŠíŠ
+íŠíŠíŠíŠíŠíŠíŠíŠíŠíŠíŠíŠíŠíŠíŠíŠíŠíŠíŠíŠíŠíŠíŠíŠíŠíŠíŠ íŠ¡íŠ¢íŠ£íŠ€íŠ¥íŠŠíŠ§íŠšíŠ©íŠªíŠ«íŠ¬íŠ­íŠ®íŠ¯íŠ°íŠ±íŠ²íŠ³íŠŽíŠµíŠ¶íŠ·íŠžíŠ¹íŠºíŠ»íŠŒíŠœíŠŸíŠ¿
+í§í§í§í§í§í§
+í§í§í§í§í§í§í§í§í§í§í§í§í§í§í§í§í§í§í§í§í§í§í§í§í§í§í§ í§¡í§¢í§£í§€í§¥í§Ší§§í§ší§©í§ªí§«í§¬í§­í§®í§¯í§°í§±í§²í§³í§Ží§µí§¶í§·í§ží§¹í§ºí§»í§Œí§œí§Ÿí§¿
+íšíšíšíšíšíš
+íšíšíšíšíšíšíšíšíšíšíšíšíšíšíšíšíšíšíšíšíšíšíšíšíšíšíš íš¡íš¢íš£íš€íš¥íšŠíš§íššíš©íšªíš«íš¬íš­íš®íš¯íš°íš±íš²íš³íšŽíšµíš¶íš·íšžíš¹íšºíš»íšŒíšœíšŸíš¿
+í©í©í©í©í©í©
+í©í©í©í©í©í©í©í©í©í©í©í©í©í©í©í©í©í©í©í©í©í©í©í©í©í©í© í©¡í©¢í©£í©€í©¥í©Ší©§í©ší©©í©ªí©«í©¬í©­í©®í©¯í©°í©±í©²í©³í©Ží©µí©¶í©·í©ží©¹í©ºí©»í©Œí©œí©Ÿí©¿
+íªíªíªíªíªíª
+íªíªíªíªíªíªíªíªíªíªíªíªíªíªíªíªíªíªíªíªíªíªíªíªíªíªíª íª¡íª¢íª£íª€íª¥íªŠíª§íªšíª©íªªíª«íª¬íª­íª®íª¯íª°íª±íª²íª³íªŽíªµíª¶íª·íªžíª¹íªºíª»íªŒíªœíªŸíª¿
+í«í«í«í«í«í«
+í«í«í«í«í«í«í«í«í«í«í«í«í«í«í«í«í«í«í«í«í«í«í«í«í«í«í« í«¡í«¢í«£í«€í«¥í«Ší«§í«ší«©í«ªí««í«¬í«­í«®í«¯í«°í«±í«²í«³í«Ží«µí«¶í«·í«ží«¹í«ºí«»í«Œí«œí«Ÿí«¿
+í¬í¬í¬í¬í¬í¬
+í¬í¬í¬í¬í¬í¬í¬í¬í¬í¬í¬í¬í¬í¬í¬í¬í¬í¬í¬í¬í¬í¬í¬í¬í¬í¬í¬ í¬¡í¬¢í¬£í¬€í¬¥í¬Ší¬§í¬ší¬©í¬ªí¬«í¬¬í¬­í¬®í¬¯í¬°í¬±í¬²í¬³í¬Ží¬µí¬¶í¬·í¬ží¬¹í¬ºí¬»í¬Œí¬œí¬Ÿí¬¿
+í­í­í­í­í­í­
+í­í­í­í­í­í­í­í­í­í­í­í­í­í­í­í­í­í­í­í­í­í­í­í­í­í­í­ í­¡í­¢í­£í­€í­¥í­Ší­§í­ší­©í­ªí­«í­¬í­­í­®í­¯í­°í­±í­²í­³í­Ží­µí­¶í­·í­ží­¹í­ºí­»í­Œí­œí­Ÿí­¿
+
+High Private Use Surrogates (U+DB80-U+DBFF):
+
+í®í®í®í®í®í®
+í®í®í®í®í®í®í®í®í®í®í®í®í®í®í®í®í®í®í®í®í®í®í®í®í®í®í® í®¡í®¢í®£í®€í®¥í®Ší®§í®ší®©í®ªí®«í®¬í®­í®®í®¯í®°í®±í®²í®³í®Ží®µí®¶í®·í®ží®¹í®ºí®»í®Œí®œí®Ÿí®¿
+í¯í¯í¯í¯í¯í¯
+í¯í¯í¯í¯í¯í¯í¯í¯í¯í¯í¯í¯í¯í¯í¯í¯í¯í¯í¯í¯í¯í¯í¯í¯í¯í¯í¯ í¯¡í¯¢í¯£í¯€í¯¥í¯Ší¯§í¯ší¯©í¯ªí¯«í¯¬í¯­í¯®í¯¯í¯°í¯±í¯²í¯³í¯Ží¯µí¯¶í¯·í¯ží¯¹í¯ºí¯»í¯Œí¯œí¯Ÿí¯¿
+
+Low Surrogates (U+DC00-U+DFFF):
+
+í°í°í°í°í°í°
+í°í°í°í°í°í°í°í°í°í°í°í°í°í°í°í°í°í°í°í°í°í°í°í°í°í°í° í°¡í°¢í°£í°€í°¥í°Ší°§í°ší°©í°ªí°«í°¬í°­í°®í°¯í°°í°±í°²í°³í°Ží°µí°¶í°·í°ží°¹í°ºí°»í°Œí°œí°Ÿí°¿
+í±í±í±í±í±í±
+í±í±í±í±í±í±í±í±í±í±í±í±í±í±í±í±í±í±í±í±í±í±í±í±í±í±í± í±¡í±¢í±£í±€í±¥í±Ší±§í±ší±©í±ªí±«í±¬í±­í±®í±¯í±°í±±í±²í±³í±Ží±µí±¶í±·í±ží±¹í±ºí±»í±Œí±œí±Ÿí±¿
+í²í²í²í²í²í²
+í²í²í²í²í²í²í²í²í²í²í²í²í²í²í²í²í²í²í²í²í²í²í²í²í²í²í² í²¡í²¢í²£í²€í²¥í²Ší²§í²ší²©í²ªí²«í²¬í²­í²®í²¯í²°í²±í²²í²³í²Ží²µí²¶í²·í²ží²¹í²ºí²»í²Œí²œí²Ÿí²¿
+í³í³í³í³í³í³
+í³í³í³í³í³í³í³í³í³í³í³í³í³í³í³í³í³í³í³í³í³í³í³í³í³í³í³ í³¡í³¢í³£í³€í³¥í³Ší³§í³ší³©í³ªí³«í³¬í³­í³®í³¯í³°í³±í³²í³³í³Ží³µí³¶í³·í³ží³¹í³ºí³»í³Œí³œí³Ÿí³¿
+íŽíŽíŽíŽíŽíŽ
+íŽíŽíŽíŽíŽíŽíŽíŽíŽíŽíŽíŽíŽíŽíŽíŽíŽíŽíŽíŽíŽíŽíŽíŽíŽíŽíŽ íŽ¡íŽ¢íŽ£íŽ€íŽ¥íŽŠíŽ§íŽšíŽ©íŽªíŽ«íŽ¬íŽ­íŽ®íŽ¯íŽ°íŽ±íŽ²íŽ³íŽŽíŽµíŽ¶íŽ·íŽžíŽ¹íŽºíŽ»íŽŒíŽœíŽŸíŽ¿
+íµíµíµíµíµíµ
+íµíµíµíµíµíµíµíµíµíµíµíµíµíµíµíµíµíµíµíµíµíµíµíµíµíµíµ íµ¡íµ¢íµ£íµ€íµ¥íµŠíµ§íµšíµ©íµªíµ«íµ¬íµ­íµ®íµ¯íµ°íµ±íµ²íµ³íµŽíµµíµ¶íµ·íµžíµ¹íµºíµ»íµŒíµœíµŸíµ¿
+í¶í¶í¶í¶í¶í¶
+í¶í¶í¶í¶í¶í¶í¶í¶í¶í¶í¶í¶í¶í¶í¶í¶í¶í¶í¶í¶í¶í¶í¶í¶í¶í¶í¶ í¶¡í¶¢í¶£í¶€í¶¥í¶Ší¶§í¶ší¶©í¶ªí¶«í¶¬í¶­í¶®í¶¯í¶°í¶±í¶²í¶³í¶Ží¶µí¶¶í¶·í¶ží¶¹í¶ºí¶»í¶Œí¶œí¶Ÿí¶¿
+í·í·í·í·í·í·
+í·í·í·í·í·í·í·í·í·í·í·í·í·í·í·í·í·í·í·í·í·í·í·í·í·í·í· í·¡í·¢í·£í·€í·¥í·Ší·§í·ší·©í·ªí·«í·¬í·­í·®í·¯í·°í·±í·²í·³í·Ží·µí·¶í··í·ží·¹í·ºí·»í·Œí·œí·Ÿí·¿
+ížížížížížíž
+ížížížížížížížížížížížížížížížížížížížížížížížížížížíž íž¡íž¢íž£íž€íž¥ížŠíž§ížšíž©ížªíž«íž¬íž­íž®íž¯íž°íž±íž²íž³ížŽížµíž¶íž·ížžíž¹ížºíž»ížŒížœížŸíž¿
+í¹í¹í¹í¹í¹í¹
+í¹í¹í¹í¹í¹í¹í¹í¹í¹í¹í¹í¹í¹í¹í¹í¹í¹í¹í¹í¹í¹í¹í¹í¹í¹í¹í¹ í¹¡í¹¢í¹£í¹€í¹¥í¹Ší¹§í¹ší¹©í¹ªí¹«í¹¬í¹­í¹®í¹¯í¹°í¹±í¹²í¹³í¹Ží¹µí¹¶í¹·í¹ží¹¹í¹ºí¹»í¹Œí¹œí¹Ÿí¹¿
+íºíºíºíºíºíº
+íºíºíºíºíºíºíºíºíºíºíºíºíºíºíºíºíºíºíºíºíºíºíºíºíºíºíº íº¡íº¢íº£íº€íº¥íºŠíº§íºšíº©íºªíº«íº¬íº­íº®íº¯íº°íº±íº²íº³íºŽíºµíº¶íº·íºžíº¹íººíº»íºŒíºœíºŸíº¿
+í»í»í»í»í»í»
+í»í»í»í»í»í»í»í»í»í»í»í»í»í»í»í»í»í»í»í»í»í»í»í»í»í»í» í»¡í»¢í»£í»€í»¥í»Ší»§í»ší»©í»ªí»«í»¬í»­í»®í»¯í»°í»±í»²í»³í»Ží»µí»¶í»·í»ží»¹í»ºí»»í»Œí»œí»Ÿí»¿
+íŒíŒíŒíŒíŒíŒ
+íŒíŒíŒíŒíŒíŒíŒíŒíŒíŒíŒíŒíŒíŒíŒíŒíŒíŒíŒíŒíŒíŒíŒíŒíŒíŒíŒ íŒ¡íŒ¢íŒ£íŒ€íŒ¥íŒŠíŒ§íŒšíŒ©íŒªíŒ«íŒ¬íŒ­íŒ®íŒ¯íŒ°íŒ±íŒ²íŒ³íŒŽíŒµíŒ¶íŒ·íŒžíŒ¹íŒºíŒ»íŒŒíŒœíŒŸíŒ¿
+íœíœíœíœíœíœ
+íœíœíœíœíœíœíœíœíœíœíœíœíœíœíœíœíœíœíœíœíœíœíœíœíœíœíœ íœ¡íœ¢íœ£íœ€íœ¥íœŠíœ§íœšíœ©íœªíœ«íœ¬íœ­íœ®íœ¯íœ°íœ±íœ²íœ³íœŽíœµíœ¶íœ·íœžíœ¹íœºíœ»íœŒíœœíœŸíœ¿
+íŸíŸíŸíŸíŸíŸ
+íŸíŸíŸíŸíŸíŸíŸíŸíŸíŸíŸíŸíŸíŸíŸíŸíŸíŸíŸíŸíŸíŸíŸíŸíŸíŸíŸ íŸ¡íŸ¢íŸ£íŸ€íŸ¥íŸŠíŸ§íŸšíŸ©íŸªíŸ«íŸ¬íŸ­íŸ®íŸ¯íŸ°íŸ±íŸ²íŸ³íŸŽíŸµíŸ¶íŸ·íŸžíŸ¹íŸºíŸ»íŸŒíŸœíŸŸíŸ¿
+í¿í¿í¿í¿í¿í¿
+í¿í¿í¿í¿í¿í¿í¿í¿í¿í¿í¿í¿í¿í¿í¿í¿í¿í¿í¿í¿í¿í¿í¿í¿í¿í¿í¿ í¿¡í¿¢í¿£í¿€í¿¥í¿Ší¿§í¿ší¿©í¿ªí¿«í¿¬í¿­í¿®í¿¯í¿°í¿±í¿²í¿³í¿Ží¿µí¿¶í¿·í¿ží¿¹í¿ºí¿»í¿Œí¿œí¿Ÿí¿¿
+
+Private Use (U+E000-U+F8FF):
+
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+î
+î
+î
+î
+î
+î
+
+î
+î
+î
+î
+î
+î
+î
+î
+î
+î
+î
+î
+î
+î
+î
+î
+î
+î
+î
+î
+î
+î
+î
+î
+î
+î
+î
+ î
+¡î
+¢î
+£î
+€î
+¥î
+Šî
+§î
+šî
+©î
+ªî
+«î
+¬î
+­î
+®î
+¯î
+°î
+±î
+²î
+³î
+Žî
+µî
+¶î
+·î
+žî
+¹î
+ºî
+»î
+Œî
+œî
+Ÿî
+¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+îîîîîî
+îîîîîîîîîîîîîîîîîîîîîîîîîîî î¡î¢î£î€î¥îŠî§îšî©îªî«î¬î­î®î¯î°î±î²î³îŽîµî¶î·îžî¹îºî»îŒîœîŸî¿
+î î î î î î 
+î î î î î î î î î î î î î î î î î î î î î î î î î î î  î ¡î ¢î £î €î ¥î Šî §î šî ©î ªî «î ¬î ­î ®î ¯î °î ±î ²î ³î Žî µî ¶î ·î žî ¹î ºî »î Œî œî Ÿî ¿
+î¡î¡î¡î¡î¡î¡
+î¡î¡î¡î¡î¡î¡î¡î¡î¡î¡î¡î¡î¡î¡î¡î¡î¡î¡î¡î¡î¡î¡î¡î¡î¡î¡î¡ î¡¡î¡¢î¡£î¡€î¡¥î¡Šî¡§î¡šî¡©î¡ªî¡«î¡¬î¡­î¡®î¡¯î¡°î¡±î¡²î¡³î¡Žî¡µî¡¶î¡·î¡žî¡¹î¡ºî¡»î¡Œî¡œî¡Ÿî¡¿
+î¢î¢î¢î¢î¢î¢
+î¢î¢î¢î¢î¢î¢î¢î¢î¢î¢î¢î¢î¢î¢î¢î¢î¢î¢î¢î¢î¢î¢î¢î¢î¢î¢î¢ î¢¡î¢¢î¢£î¢€î¢¥î¢Šî¢§î¢šî¢©î¢ªî¢«î¢¬î¢­î¢®î¢¯î¢°î¢±î¢²î¢³î¢Žî¢µî¢¶î¢·î¢žî¢¹î¢ºî¢»î¢Œî¢œî¢Ÿî¢¿
+î£î£î£î£î£î£
+î£î£î£î£î£î£î£î£î£î£î£î£î£î£î£î£î£î£î£î£î£î£î£î£î£î£î£ î£¡î£¢î££î£€î£¥î£Šî£§î£šî£©î£ªî£«î£¬î£­î£®î£¯î£°î£±î£²î£³î£Žî£µî£¶î£·î£žî£¹î£ºî£»î£Œî£œî£Ÿî£¿
+î€î€î€î€î€î€
+î€î€î€î€î€î€î€î€î€î€î€î€î€î€î€î€î€î€î€î€î€î€î€î€î€î€î€ î€¡î€¢î€£î€€î€¥î€Šî€§î€šî€©î€ªî€«î€¬î€­î€®î€¯î€°î€±î€²î€³î€Žî€µî€¶î€·î€žî€¹î€ºî€»î€Œî€œî€Ÿî€¿
+î¥î¥î¥î¥î¥î¥
+î¥î¥î¥î¥î¥î¥î¥î¥î¥î¥î¥î¥î¥î¥î¥î¥î¥î¥î¥î¥î¥î¥î¥î¥î¥î¥î¥ î¥¡î¥¢î¥£î¥€î¥¥î¥Šî¥§î¥šî¥©î¥ªî¥«î¥¬î¥­î¥®î¥¯î¥°î¥±î¥²î¥³î¥Žî¥µî¥¶î¥·î¥žî¥¹î¥ºî¥»î¥Œî¥œî¥Ÿî¥¿
+îŠîŠîŠîŠîŠîŠ
+îŠîŠîŠîŠîŠîŠîŠîŠîŠîŠîŠîŠîŠîŠîŠîŠîŠîŠîŠîŠîŠîŠîŠîŠîŠîŠîŠ îŠ¡îŠ¢îŠ£îŠ€îŠ¥îŠŠîŠ§îŠšîŠ©îŠªîŠ«îŠ¬îŠ­îŠ®îŠ¯îŠ°îŠ±îŠ²îŠ³îŠŽîŠµîŠ¶îŠ·îŠžîŠ¹îŠºîŠ»îŠŒîŠœîŠŸîŠ¿
+î§î§î§î§î§î§
+î§î§î§î§î§î§î§î§î§î§î§î§î§î§î§î§î§î§î§î§î§î§î§î§î§î§î§ î§¡î§¢î§£î§€î§¥î§Šî§§î§šî§©î§ªî§«î§¬î§­î§®î§¯î§°î§±î§²î§³î§Žî§µî§¶î§·î§žî§¹î§ºî§»î§Œî§œî§Ÿî§¿
+îšîšîšîšîšîš
+îšîšîšîšîšîšîšîšîšîšîšîšîšîšîšîšîšîšîšîšîšîšîšîšîšîšîš îš¡îš¢îš£îš€îš¥îšŠîš§îššîš©îšªîš«îš¬îš­îš®îš¯îš°îš±îš²îš³îšŽîšµîš¶îš·îšžîš¹îšºîš»îšŒîšœîšŸîš¿
+î©î©î©î©î©î©
+î©î©î©î©î©î©î©î©î©î©î©î©î©î©î©î©î©î©î©î©î©î©î©î©î©î©î© î©¡î©¢î©£î©€î©¥î©Šî©§î©šî©©î©ªî©«î©¬î©­î©®î©¯î©°î©±î©²î©³î©Žî©µî©¶î©·î©žî©¹î©ºî©»î©Œî©œî©Ÿî©¿
+îªîªîªîªîªîª
+îªîªîªîªîªîªîªîªîªîªîªîªîªîªîªîªîªîªîªîªîªîªîªîªîªîªîª îª¡îª¢îª£îª€îª¥îªŠîª§îªšîª©îªªîª«îª¬îª­îª®îª¯îª°îª±îª²îª³îªŽîªµîª¶îª·îªžîª¹îªºîª»îªŒîªœîªŸîª¿
+î«î«î«î«î«î«
+î«î«î«î«î«î«î«î«î«î«î«î«î«î«î«î«î«î«î«î«î«î«î«î«î«î«î« î«¡î«¢î«£î«€î«¥î«Šî«§î«šî«©î«ªî««î«¬î«­î«®î«¯î«°î«±î«²î«³î«Žî«µî«¶î«·î«žî«¹î«ºî«»î«Œî«œî«Ÿî«¿
+î¬î¬î¬î¬î¬î¬
+î¬î¬î¬î¬î¬î¬î¬î¬î¬î¬î¬î¬î¬î¬î¬î¬î¬î¬î¬î¬î¬î¬î¬î¬î¬î¬î¬ î¬¡î¬¢î¬£î¬€î¬¥î¬Šî¬§î¬šî¬©î¬ªî¬«î¬¬î¬­î¬®î¬¯î¬°î¬±î¬²î¬³î¬Žî¬µî¬¶î¬·î¬žî¬¹î¬ºî¬»î¬Œî¬œî¬Ÿî¬¿
+î­î­î­î­î­î­
+î­î­î­î­î­î­î­î­î­î­î­î­î­î­î­î­î­î­î­î­î­î­î­î­î­î­î­ î­¡î­¢î­£î­€î­¥î­Šî­§î­šî­©î­ªî­«î­¬î­­î­®î­¯î­°î­±î­²î­³î­Žî­µî­¶î­·î­žî­¹î­ºî­»î­Œî­œî­Ÿî­¿
+î®î®î®î®î®î®
+î®î®î®î®î®î®î®î®î®î®î®î®î®î®î®î®î®î®î®î®î®î®î®î®î®î®î® î®¡î®¢î®£î®€î®¥î®Šî®§î®šî®©î®ªî®«î®¬î®­î®®î®¯î®°î®±î®²î®³î®Žî®µî®¶î®·î®žî®¹î®ºî®»î®Œî®œî®Ÿî®¿
+î¯î¯î¯î¯î¯î¯
+î¯î¯î¯î¯î¯î¯î¯î¯î¯î¯î¯î¯î¯î¯î¯î¯î¯î¯î¯î¯î¯î¯î¯î¯î¯î¯î¯ î¯¡î¯¢î¯£î¯€î¯¥î¯Šî¯§î¯šî¯©î¯ªî¯«î¯¬î¯­î¯®î¯¯î¯°î¯±î¯²î¯³î¯Žî¯µî¯¶î¯·î¯žî¯¹î¯ºî¯»î¯Œî¯œî¯Ÿî¯¿
+î°î°î°î°î°î°
+î°î°î°î°î°î°î°î°î°î°î°î°î°î°î°î°î°î°î°î°î°î°î°î°î°î°î° î°¡î°¢î°£î°€î°¥î°Šî°§î°šî°©î°ªî°«î°¬î°­î°®î°¯î°°î°±î°²î°³î°Žî°µî°¶î°·î°žî°¹î°ºî°»î°Œî°œî°Ÿî°¿
+î±î±î±î±î±î±
+î±î±î±î±î±î±î±î±î±î±î±î±î±î±î±î±î±î±î±î±î±î±î±î±î±î±î± î±¡î±¢î±£î±€î±¥î±Šî±§î±šî±©î±ªî±«î±¬î±­î±®î±¯î±°î±±î±²î±³î±Žî±µî±¶î±·î±žî±¹î±ºî±»î±Œî±œî±Ÿî±¿
+î²î²î²î²î²î²
+î²î²î²î²î²î²î²î²î²î²î²î²î²î²î²î²î²î²î²î²î²î²î²î²î²î²î² î²¡î²¢î²£î²€î²¥î²Šî²§î²šî²©î²ªî²«î²¬î²­î²®î²¯î²°î²±î²²î²³î²Žî²µî²¶î²·î²žî²¹î²ºî²»î²Œî²œî²Ÿî²¿
+î³î³î³î³î³î³
+î³î³î³î³î³î³î³î³î³î³î³î³î³î³î³î³î³î³î³î³î³î³î³î³î³î³î³ î³¡î³¢î³£î³€î³¥î³Šî³§î³šî³©î³ªî³«î³¬î³­î³®î³¯î³°î³±î³²î³³î³Žî³µî³¶î³·î³žî³¹î³ºî³»î³Œî³œî³Ÿî³¿
+îŽîŽîŽîŽîŽîŽ
+îŽîŽîŽîŽîŽîŽîŽîŽîŽîŽîŽîŽîŽîŽîŽîŽîŽîŽîŽîŽîŽîŽîŽîŽîŽîŽîŽ îŽ¡îŽ¢îŽ£îŽ€îŽ¥îŽŠîŽ§îŽšîŽ©îŽªîŽ«îŽ¬îŽ­îŽ®îŽ¯îŽ°îŽ±îŽ²îŽ³îŽŽîŽµîŽ¶îŽ·îŽžîŽ¹îŽºîŽ»îŽŒîŽœîŽŸîŽ¿
+îµîµîµîµîµîµ
+îµîµîµîµîµîµîµîµîµîµîµîµîµîµîµîµîµîµîµîµîµîµîµîµîµîµîµ îµ¡îµ¢îµ£îµ€îµ¥îµŠîµ§îµšîµ©îµªîµ«îµ¬îµ­îµ®îµ¯îµ°îµ±îµ²îµ³îµŽîµµîµ¶îµ·îµžîµ¹îµºîµ»îµŒîµœîµŸîµ¿
+î¶î¶î¶î¶î¶î¶
+î¶î¶î¶î¶î¶î¶î¶î¶î¶î¶î¶î¶î¶î¶î¶î¶î¶î¶î¶î¶î¶î¶î¶î¶î¶î¶î¶ î¶¡î¶¢î¶£î¶€î¶¥î¶Šî¶§î¶šî¶©î¶ªî¶«î¶¬î¶­î¶®î¶¯î¶°î¶±î¶²î¶³î¶Žî¶µî¶¶î¶·î¶žî¶¹î¶ºî¶»î¶Œî¶œî¶Ÿî¶¿
+î·î·î·î·î·î·
+î·î·î·î·î·î·î·î·î·î·î·î·î·î·î·î·î·î·î·î·î·î·î·î·î·î·î· î·¡î·¢î·£î·€î·¥î·Šî·§î·šî·©î·ªî·«î·¬î·­î·®î·¯î·°î·±î·²î·³î·Žî·µî·¶î··î·žî·¹î·ºî·»î·Œî·œî·Ÿî·¿
+îžîžîžîžîžîž
+îžîžîžîžîžîžîžîžîžîžîžîžîžîžîžîžîžîžîžîžîžîžîžîžîžîžîž îž¡îž¢îž£îž€îž¥îžŠîž§îžšîž©îžªîž«îž¬îž­îž®îž¯îž°îž±îž²îž³îžŽîžµîž¶îž·îžžîž¹îžºîž»îžŒîžœîžŸîž¿
+î¹î¹î¹î¹î¹î¹
+î¹î¹î¹î¹î¹î¹î¹î¹î¹î¹î¹î¹î¹î¹î¹î¹î¹î¹î¹î¹î¹î¹î¹î¹î¹î¹î¹ î¹¡î¹¢î¹£î¹€î¹¥î¹Šî¹§î¹šî¹©î¹ªî¹«î¹¬î¹­î¹®î¹¯î¹°î¹±î¹²î¹³î¹Žî¹µî¹¶î¹·î¹žî¹¹î¹ºî¹»î¹Œî¹œî¹Ÿî¹¿
+îºîºîºîºîºîº
+îºîºîºîºîºîºîºîºîºîºîºîºîºîºîºîºîºîºîºîºîºîºîºîºîºîºîº îº¡îº¢îº£îº€îº¥îºŠîº§îºšîº©îºªîº«îº¬îº­îº®îº¯îº°îº±îº²îº³îºŽîºµîº¶îº·îºžîº¹îººîº»îºŒîºœîºŸîº¿
+î»î»î»î»î»î»
+î»î»î»î»î»î»î»î»î»î»î»î»î»î»î»î»î»î»î»î»î»î»î»î»î»î»î» î»¡î»¢î»£î»€î»¥î»Šî»§î»šî»©î»ªî»«î»¬î»­î»®î»¯î»°î»±î»²î»³î»Žî»µî»¶î»·î»žî»¹î»ºî»»î»Œî»œî»Ÿî»¿
+îŒîŒîŒîŒîŒîŒ
+îŒîŒîŒîŒîŒîŒîŒîŒîŒîŒîŒîŒîŒîŒîŒîŒîŒîŒîŒîŒîŒîŒîŒîŒîŒîŒîŒ îŒ¡îŒ¢îŒ£îŒ€îŒ¥îŒŠîŒ§îŒšîŒ©îŒªîŒ«îŒ¬îŒ­îŒ®îŒ¯îŒ°îŒ±îŒ²îŒ³îŒŽîŒµîŒ¶îŒ·îŒžîŒ¹îŒºîŒ»îŒŒîŒœîŒŸîŒ¿
+îœîœîœîœîœîœ
+îœîœîœîœîœîœîœîœîœîœîœîœîœîœîœîœîœîœîœîœîœîœîœîœîœîœîœ îœ¡îœ¢îœ£îœ€îœ¥îœŠîœ§îœšîœ©îœªîœ«îœ¬îœ­îœ®îœ¯îœ°îœ±îœ²îœ³îœŽîœµîœ¶îœ·îœžîœ¹îœºîœ»îœŒîœœîœŸîœ¿
+îŸîŸîŸîŸîŸîŸ
+îŸîŸîŸîŸîŸîŸîŸîŸîŸîŸîŸîŸîŸîŸîŸîŸîŸîŸîŸîŸîŸîŸîŸîŸîŸîŸîŸ îŸ¡îŸ¢îŸ£îŸ€îŸ¥îŸŠîŸ§îŸšîŸ©îŸªîŸ«îŸ¬îŸ­îŸ®îŸ¯îŸ°îŸ±îŸ²îŸ³îŸŽîŸµîŸ¶îŸ·îŸžîŸ¹îŸºîŸ»îŸŒîŸœîŸŸîŸ¿
+î¿î¿î¿î¿î¿î¿
+î¿î¿î¿î¿î¿î¿î¿î¿î¿î¿î¿î¿î¿î¿î¿î¿î¿î¿î¿î¿î¿î¿î¿î¿î¿î¿î¿ î¿¡î¿¢î¿£î¿€î¿¥î¿Šî¿§î¿šî¿©î¿ªî¿«î¿¬î¿­î¿®î¿¯î¿°î¿±î¿²î¿³î¿Žî¿µî¿¶î¿·î¿žî¿¹î¿ºî¿»î¿Œî¿œî¿Ÿî¿¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ï
+ï
+ï
+ï
+ï
+ï
+
+ï
+ï
+ï
+ï
+ï
+ï
+ï
+ï
+ï
+ï
+ï
+ï
+ï
+ï
+ï
+ï
+ï
+ï
+ï
+ï
+ï
+ï
+ï
+ï
+ï
+ï
+ï
+ ï
+¡ï
+¢ï
+£ï
+€ï
+¥ï
+Šï
+§ï
+šï
+©ï
+ªï
+«ï
+¬ï
+­ï
+®ï
+¯ï
+°ï
+±ï
+²ï
+³ï
+Žï
+µï
+¶ï
+·ï
+žï
+¹ï
+ºï
+»ï
+Œï
+œï
+Ÿï
+¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ïïïïïï
+ïïïïïïïïïïïïïïïïïïïïïïïïïïï ï¡ï¢ï£ï€ï¥ïŠï§ïšï©ïªï«ï¬ï­ï®ï¯ï°ï±ï²ï³ïŽïµï¶ï·ïžï¹ïºï»ïŒïœïŸï¿
+ï ï ï ï ï ï 
+ï ï ï ï ï ï ï ï ï ï ï ï ï ï ï ï ï ï ï ï ï ï ï ï ï ï ï  ï ¡ï ¢ï £ï €ï ¥ï Šï §ï šï ©ï ªï «ï ¬ï ­ï ®ï ¯ï °ï ±ï ²ï ³ï Žï µï ¶ï ·ï žï ¹ï ºï »ï Œï œï Ÿï ¿
+ï¡ï¡ï¡ï¡ï¡ï¡
+ï¡ï¡ï¡ï¡ï¡ï¡ï¡ï¡ï¡ï¡ï¡ï¡ï¡ï¡ï¡ï¡ï¡ï¡ï¡ï¡ï¡ï¡ï¡ï¡ï¡ï¡ï¡ ï¡¡ï¡¢ï¡£ï¡€ï¡¥ï¡Šï¡§ï¡šï¡©ï¡ªï¡«ï¡¬ï¡­ï¡®ï¡¯ï¡°ï¡±ï¡²ï¡³ï¡Žï¡µï¡¶ï¡·ï¡žï¡¹ï¡ºï¡»ï¡Œï¡œï¡Ÿï¡¿
+ï¢ï¢ï¢ï¢ï¢ï¢
+ï¢ï¢ï¢ï¢ï¢ï¢ï¢ï¢ï¢ï¢ï¢ï¢ï¢ï¢ï¢ï¢ï¢ï¢ï¢ï¢ï¢ï¢ï¢ï¢ï¢ï¢ï¢ ï¢¡ï¢¢ï¢£ï¢€ï¢¥ï¢Šï¢§ï¢šï¢©ï¢ªï¢«ï¢¬ï¢­ï¢®ï¢¯ï¢°ï¢±ï¢²ï¢³ï¢Žï¢µï¢¶ï¢·ï¢žï¢¹ï¢ºï¢»ï¢Œï¢œï¢Ÿï¢¿
+ï£ï£ï£ï£ï£ï£
+ï£ï£ï£ï£ï£ï£ï£ï£ï£ï£ï£ï£ï£ï£ï£ï£ï£ï£ï£ï£ï£ï£ï£ï£ï£ï£ï£ ï£¡ï£¢ï££ï£€ï£¥ï£Šï£§ï£šï£©ï£ªï£«ï£¬ï£­ï£®ï£¯ï£°ï£±ï£²ï£³ï£Žï£µï£¶ï£·ï£žï£¹ï£ºï£»ï£Œï£œï£Ÿï£¿
+
+CJK Compatibility Ideographs (U+F900-U+FAFF):
+
+ï€ï€ï€ï€ï€ï€
+ï€ï€ï€ï€ï€ï€ï€ï€ï€ï€ï€ï€ï€ï€ï€ï€ï€ï€ï€ï€ï€ï€ï€ï€ï€ï€
+ï€ ï€¡ï€¢ï€£ï€€ï€¥ï€Šï€§ï€šï€©ï€ªï€«ï€¬ï€­ï€®ï€¯ï€°ï€±ï€²ï€³ï€Žï€µï€¶ï€·ï€žï€¹ï€ºï€»ï€Œï€œï€Ÿï€¿
+ï¥ï¥ï¥ï¥ï¥ï¥
+ï¥ï¥ï¥ï¥ï¥ï¥ï¥ï¥ï¥ï¥ï¥ï¥ï¥ï¥ï¥ï¥ï¥ï¥ï¥ï¥ï¥ï¥ï¥ï¥ï¥ï¥
+ï¥ ï¥¡ï¥¢ï¥£ï¥€ï¥¥ï¥Šï¥§ï¥šï¥©ï¥ªï¥«ï¥¬ï¥­ï¥®ï¥¯ï¥°ï¥±ï¥²ï¥³ï¥Žï¥µï¥¶ï¥·ï¥žï¥¹ï¥ºï¥»ï¥Œï¥œï¥Ÿï¥¿
+ïŠïŠïŠïŠïŠïŠ
+ïŠïŠïŠïŠïŠïŠïŠïŠïŠïŠïŠïŠïŠïŠïŠïŠïŠïŠïŠïŠïŠïŠïŠïŠïŠïŠ
+ïŠ ïŠ¡ïŠ¢ïŠ£ïŠ€ïŠ¥ïŠŠïŠ§ïŠšïŠ©ïŠªïŠ«ïŠ¬ïŠ­ïŠ®ïŠ¯ïŠ°ïŠ±ïŠ²ïŠ³ïŠŽïŠµïŠ¶ïŠ·ïŠžïŠ¹ïŠºïŠ»ïŠŒïŠœïŠŸïŠ¿
+ï§ï§ï§ï§ï§ï§
+ï§ï§ï§ï§ï§ï§ï§ï§ï§ï§ï§ï§ï§ï§ï§ï§ï§ï§ï§ï§ï§ï§ï§ï§ï§ï§
+ï§ ï§¡ï§¢ï§£ï§€ï§¥ï§Šï§§ï§šï§©ï§ªï§«ï§¬ï§­ï§®ï§¯ï§°ï§±ï§²ï§³ï§Žï§µï§¶ï§·ï§žï§¹ï§ºï§»ï§Œï§œï§Ÿï§¿
+ïšïšïšïšïšïš
+ïšïšïšïšïšïšïšïšïšïšïšïšïšïšïšïšïšïšïšïšïšïšïšïšïšïš
+ïš ïš¡ïš¢ïš£ïš€ïš¥ïšŠïš§ïššïš©ïšªïš«ïš¬ïš­ïš®ïš¯ïš°ïš±ïš²ïš³ïšŽïšµïš¶ïš·ïšžïš¹ïšºïš»ïšŒïšœïšŸïš¿
+ï©ï©ï©ï©ï©ï©
+ï©ï©ï©ï©ï©ï©ï©ï©ï©ï©ï©ï©ï©ï©ï©ï©ï©ï©ï©ï©ï©ï©ï©ï©ï©ï©
+ï© ï©¡ï©¢ï©£ï©€ï©¥ï©Šï©§ï©šï©©ï©ªï©«ï©¬ï©­ï©®ï©¯ï©°ï©±ï©²ï©³ï©Žï©µï©¶ï©·ï©žï©¹ï©ºï©»ï©Œï©œï©Ÿï©¿
+ïªïªïªïªïªïª
+ïªïªïªïªïªïªïªïªïªïªïªïªïªïªïªïªïªïªïªïªïªïªïªïªïªïª
+ïª ïª¡ïª¢ïª£ïª€ïª¥ïªŠïª§ïªšïª©ïªªïª«ïª¬ïª­ïª®ïª¯ïª°ïª±ïª²ïª³ïªŽïªµïª¶ïª·ïªžïª¹ïªºïª»ïªŒïªœïªŸïª¿
+ï«ï«ï«ï«ï«ï«
+ï«ï«ï«ï«ï«ï«ï«ï«ï«ï«ï«ï«ï«ï«ï«ï«ï«ï«ï«ï«ï«ï«ï«ï«ï«ï«
+ï« ï«¡ï«¢ï«£ï«€ï«¥ï«Šï«§ï«šï«©ï«ªï««ï«¬ï«­ï«®ï«¯ï«°ï«±ï«²ï«³ï«Žï«µï«¶ï«·ï«žï«¹ï«ºï«»ï«Œï«œï«Ÿï«¿
+
+Alphabetic Presentation Forms (U+FB00-U+FB4F):
+
+ï¬ï¬ï¬ï¬ï¬ï¬
+ï¬ï¬ï¬ï¬ï¬ï¬ï¬ï¬ï¬ï¬ï¬ï¬ï¬ï¬ï¬ï¬ï¬ï¬ï¬ï¬ï¬ï¬ï¬ï¬âï¬ï¬ï¬ ï¬¡ï¬¢ï¬£ï¬€ï¬¥ï¬Šï¬§ï¬šï¬©ï¬ªï¬«ï¬¬ï¬­ï¬®ï¬¯ï¬°ï¬±ï¬²ï¬³ï¬Žï¬µï¬¶ï¬·ï¬žï¬¹ï¬ºï¬»ï¬Œï¬œï¬Ÿï¬¿
+ï­ï­ï­ï­ï­ï­
+ï­ï­ï­ï­ï­ï­ï­ï­ï­ï­
+
+Arabic Presentation Forms-A (U+FB50-U+FDFF):
+
+ï­ï­ï­ï­ï­ï­ï­ï­ï­ï­ï­ï­ï­ï­ï­ï­ï­ ï­¡ï­¢ï­£ï­€ï­¥ï­Šï­§ï­šï­©ï­ªï­«ï­¬ï­­ï­®ï­¯ï­°ï­±ï­²ï­³ï­Žï­µï­¶ï­·ï­žï­¹ï­ºï­»ï­Œï­œï­Ÿï­¿ï®ï®ï®ï®ï®ï®
+ï®ï®ï®ï®ï®ï®ï®ï®ï®ï®
+ï®ï®ï®ï®ï®ï®ï®ï®ï®ï®ï®ï®ï®ï®ï®ï®ï® ï®¡ï®¢ï®£ï®€ï®¥ï®Šï®§ï®šï®©ï®ªï®«ï®¬ï®­ï®®ï®¯ï®°ï®±ï®²ï®³ï®Žï®µï®¶ï®·ï®žï®¹ï®ºï®»ï®Œï®œï®Ÿï®¿ï¯ï¯ï¯ï¯ï¯ï¯
+ï¯ï¯ï¯ï¯ï¯ï¯ï¯ï¯ï¯ï¯
+ï¯ï¯ï¯ï¯ï¯ï¯ï¯ï¯ï¯ï¯ï¯ï¯ï¯ï¯ï¯ï¯ï¯ ï¯¡ï¯¢ï¯£ï¯€ï¯¥ï¯Šï¯§ï¯šï¯©ï¯ªï¯«ï¯¬ï¯­ï¯®ï¯¯ï¯°ï¯±ï¯²ï¯³ï¯Žï¯µï¯¶ï¯·ï¯žï¯¹ï¯ºï¯»ï¯Œï¯œï¯Ÿï¯¿ï°ï°ï°ï°ï°ï°
+ï°ï°ï°ï°ï°ï°ï°ï°ï°ï°
+ï°ï°ï°ï°ï°ï°ï°ï°ï°ï°ï°ï°ï°ï°ï°ï°ï° ï°¡ï°¢ï°£ï°€ï°¥ï°Šï°§ï°šï°©ï°ªï°«ï°¬ï°­ï°®ï°¯ï°°ï°±ï°²ï°³ï°Žï°µï°¶ï°·ï°žï°¹ï°ºï°»ï°Œï°œï°Ÿï°¿ï±ï±ï±ï±ï±ï±
+ï±ï±ï±ï±ï±ï±ï±ï±ï±ï±
+ï±ï±ï±ï±ï±ï±ï±ï±ï±ï±ï±ï±ï±ï±ï±ï±ï± ï±¡ï±¢ï±£ï±€ï±¥ï±Šï±§ï±šï±©ï±ªï±«ï±¬ï±­ï±®ï±¯ï±°ï±±ï±²ï±³ï±Žï±µï±¶ï±·ï±žï±¹ï±ºï±»ï±Œï±œï±Ÿï±¿ï²ï²ï²ï²ï²ï²
+ï²ï²ï²ï²ï²ï²ï²ï²ï²ï²
+ï²ï²ï²ï²ï²ï²ï²ï²ï²ï²ï²ï²ï²ï²ï²ï²ï² ï²¡ï²¢ï²£ï²€ï²¥ï²Šï²§ï²šï²©ï²ªï²«ï²¬ï²­ï²®ï²¯ï²°ï²±ï²²ï²³ï²Žï²µï²¶ï²·ï²žï²¹ï²ºï²»ï²Œï²œï²Ÿï²¿ï³ï³ï³ï³ï³ï³
+ï³ï³ï³ï³ï³ï³ï³ï³ï³ï³
+ï³ï³ï³ï³ï³ï³ï³ï³ï³ï³ï³ï³ï³ï³ï³ï³ï³ ï³¡ï³¢ï³£ï³€ï³¥ï³Šï³§ï³šï³©ï³ªï³«ï³¬ï³­ï³®ï³¯ï³°ï³±ï³²ï³³ï³Žï³µï³¶ï³·ï³žï³¹ï³ºï³»ï³Œï³œï³Ÿï³¿ïŽïŽïŽïŽïŽïŽ
+ïŽïŽïŽïŽïŽïŽïŽïŽïŽïŽ
+ïŽïŽïŽïŽïŽïŽïŽïŽïŽïŽïŽïŽïŽïŽïŽïŽïŽ ïŽ¡ïŽ¢ïŽ£ïŽ€ïŽ¥ïŽŠïŽ§ïŽšïŽ©ïŽªïŽ«ïŽ¬ïŽ­ïŽ®ïŽ¯ïŽ°ïŽ±ïŽ²ïŽ³ïŽŽïŽµïŽ¶ïŽ·ïŽžïŽ¹ïŽºïŽ»ïŽŒïŽœïŽŸïŽ¿ïµïµïµïµïµïµ
+ïµïµïµïµïµïµïµïµïµïµ
+ïµïµïµïµïµïµïµïµïµïµïµïµïµïµïµïµïµ ïµ¡ïµ¢ïµ£ïµ€ïµ¥ïµŠïµ§ïµšïµ©ïµªïµ«ïµ¬ïµ­ïµ®ïµ¯ïµ°ïµ±ïµ²ïµ³ïµŽïµµïµ¶ïµ·ïµžïµ¹ïµºïµ»ïµŒïµœïµŸïµ¿ï¶ï¶ï¶ï¶ï¶ï¶
+ï¶ï¶ï¶ï¶ï¶ï¶ï¶ï¶ï¶ï¶
+ï¶ï¶ï¶ï¶ï¶ï¶ï¶ï¶ï¶ï¶ï¶ï¶ï¶ï¶ï¶ï¶ï¶ ï¶¡ï¶¢ï¶£ï¶€ï¶¥ï¶Šï¶§ï¶šï¶©ï¶ªï¶«ï¶¬ï¶­ï¶®ï¶¯ï¶°ï¶±ï¶²ï¶³ï¶Žï¶µï¶¶ï¶·ï¶žï¶¹ï¶ºï¶»ï¶Œï¶œï¶Ÿï¶¿ï·ï·ï·ï·ï·ï·
+ï·ï·ï·ï·ï·ï·ï·ï·ï·ï·
+ï·ï·ï·ï·ï·ï·ï·ï·ï·ï·ï·ï·ï·ï·ï·ï·ï· ï·¡ï·¢ï·£ï·€ï·¥ï·Šï·§ï·šï·©ï·ªï·«ï·¬ï·­ï·®ï·¯ï·°ï·±ï·²ï·³ï·Žï·µï·¶ï··ï·žï·¹ï·ºï·»ï·Œï·œï·Ÿï·¿
+
+Free block (U+FE00-U+FE1F):
+
+ïžïžïžïžïžïž
+ïžïžïžïžïžïžïžïžïžïžïžïžïžïžïžïžïžïžïžïžïžïžïžïžïžïž
+
+Combining Half Marks (U+FE20-U+FE2F):
+
+âïž âïž¡âïž¢âïž£ïž€ïž¥ïžŠïž§ïžšïž©ïžªïž«ïž¬ïž­ïž®ïž¯
+
+CJK Compatibility Forms (U+FE30-U+FE4F):
+
+ïž°ïž±ïž²ïž³ïžŽïžµïž¶ïž·ïžžïž¹ïžºïž»ïžŒïžœïžŸïž¿ï¹ï¹ï¹ï¹ï¹ï¹
+ï¹ï¹ï¹ï¹ï¹ï¹ï¹ï¹ï¹ï¹
+
+Small Form Variants (U+FE50-U+FE6F):
+
+ï¹ï¹ï¹ï¹ï¹ï¹ï¹ï¹ï¹ï¹ï¹ï¹ï¹ï¹ï¹ï¹ï¹ ï¹¡ï¹¢ï¹£ï¹€ï¹¥ï¹Šï¹§ï¹šï¹©ï¹ªï¹«ï¹¬ï¹­ï¹®ï¹¯
+
+Arabic Presentation Forms-B (U+FE70-U+FEFE):
+
+ï¹°ï¹±ï¹²ï¹³ï¹Žï¹µï¹¶ï¹·ï¹žï¹¹ï¹ºï¹»ï¹Œï¹œï¹Ÿï¹¿ïºïºïºïºïºïº
+ïºïºïºïºïºïºïºïºïºïºïºïºïºïºïºïºïºïºïºïºïºïºïºïºïºïºïº ïº¡ïº¢ïº£ïº€ïº¥ïºŠïº§ïºšïº©ïºªïº«ïº¬ïº­ïº®ïº¯
+ïº°ïº±ïº²ïº³ïºŽïºµïº¶ïº·ïºžïº¹ïººïº»ïºŒïºœïºŸïº¿ï»ï»ï»ï»ï»ï»
+ï»ï»ï»ï»ï»ï»ï»ï»ï»ï»ï»ï»ï»ï»ï»ï»ï»ï»ï»ï»ï»ï»ï»ï»ï»ï»ï» ï»¡ï»¢ï»£ï»€ï»¥ï»Šï»§ï»šï»©ï»ªï»«ï»¬ï»­ï»®ï»¯
+ï»°ï»±ï»²ï»³ï»Žï»µï»¶ï»·ï»žï»¹ï»ºï»»ï»Œï»œï»Ÿ
+
+Specials (U+FEFF-U+FEFF):
+
+ï»¿
+
+Halfwidth and Fullwidth Forms (U+FF00-U+FFEF):
+
+ïŒïŒïŒïŒïŒïŒ
+ïŒïŒïŒïŒïŒïŒïŒïŒïŒïŒïŒïŒïŒïŒïŒïŒïŒïŒïŒïŒïŒïŒïŒïŒïŒïŒ
+ïŒ ïŒ¡ïŒ¢ïŒ£ïŒ€ïŒ¥ïŒŠïŒ§ïŒšïŒ©ïŒªïŒ«ïŒ¬ïŒ­ïŒ®ïŒ¯ïŒ°ïŒ±ïŒ²ïŒ³ïŒŽïŒµïŒ¶ïŒ·ïŒžïŒ¹ïŒºïŒ»ïŒŒïŒœïŒŸïŒ¿
+ïœïœïœïœïœïœ
+ïœïœïœïœïœïœïœïœïœïœïœïœïœïœïœïœïœïœïœïœïœïœïœïœïœïœ
+ïœ ïœ¡ïœ¢ïœ£ïœ€ïœ¥ïœŠïœ§ïœšïœ©ïœªïœ«ïœ¬ïœ­ïœ®ïœ¯ïœ°ïœ±ïœ²ïœ³ïœŽïœµïœ¶ïœ·ïœžïœ¹ïœºïœ»ïœŒïœœïœŸïœ¿ïŸïŸïŸïŸïŸïŸ
+ïŸïŸïŸïŸïŸïŸïŸïŸïŸïŸïŸïŸïŸïŸïŸïŸïŸïŸïŸïŸïŸïŸïŸïŸïŸïŸ
+ïŸ ïŸ¡ïŸ¢ïŸ£ïŸ€ïŸ¥ïŸŠïŸ§ïŸšïŸ©ïŸªïŸ«ïŸ¬ïŸ­ïŸ®ïŸ¯ïŸ°ïŸ±ïŸ²ïŸ³ïŸŽïŸµïŸ¶ïŸ·ïŸžïŸ¹ïŸºïŸ»ïŸŒïŸœïŸŸïŸ¿ï¿ï¿ï¿ï¿ï¿ï¿
+ï¿ï¿ï¿ï¿ï¿ï¿ï¿ï¿ï¿ï¿ï¿ï¿ï¿ï¿ï¿ï¿ï¿ï¿ï¿ï¿ï¿ï¿ï¿ï¿ï¿ï¿
+ï¿ ï¿¡ï¿¢ï¿£ï¿€ï¿¥ï¿Šï¿§ï¿šï¿©ï¿ªï¿«ï¿¬ï¿­ï¿®ï¿¯
+
+Specials (U+FFF0-U+FFFD):
+
+ï¿°ï¿±ï¿²ï¿³ï¿Žï¿µï¿¶ï¿·ï¿žï¿¹ï¿ºï¿»ï¿Œï¿œ
+
+Free block (U+FFFE-U+FFFF):
+
+ï¿Ÿï¿¿
Index: trunk/src/libctests/glibc/libio/tst_getwc.c
===================================================================
--- trunk/src/libctests/glibc/libio/tst_getwc.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst_getwc.c	(revision 2036)
@@ -0,0 +1,42 @@
+/* Simple test of getwc in the C locale.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <wchar.h>
+
+
+int
+main (void)
+{
+  wchar_t buf[100];
+  size_t n = 0;
+
+  wmemset (buf, L'\0', sizeof (buf) / sizeof (buf[0]));
+  while (! feof (stdin) && n < sizeof (buf) - 1)
+    {
+      buf[n] = getwc (stdin);
+      if (buf[n] == WEOF)
+	break;
+      ++n;
+    }
+  buf[n] = L'\0';
+
+  return wcscmp (buf, L"This is a test of getwc\n") != 0;
+}
Index: trunk/src/libctests/glibc/libio/tst_getwc.input
===================================================================
--- trunk/src/libctests/glibc/libio/tst_getwc.input	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst_getwc.input	(revision 2036)
@@ -0,0 +1,1 @@
+This is a test of getwc
Index: trunk/src/libctests/glibc/libio/tst_putwc.c
===================================================================
--- trunk/src/libctests/glibc/libio/tst_putwc.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst_putwc.c	(revision 2036)
@@ -0,0 +1,122 @@
+/* Simple test of putwc in the C locale.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <error.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <wchar.h>
+
+static const char outname[] = OBJPFX "tst_putwc.temp";
+
+/* Prototype for our test function.  */
+int do_test (void);
+#define TEST_FUNCTION do_test ()
+
+/* This defines the `main' function and some more.  */
+#include <test-skeleton.c>
+
+int
+do_test (void)
+{
+  const wchar_t str[] = L"This is a test of putwc\n";
+  wchar_t buf[100];
+  size_t n = 0;
+  FILE *fp;
+  int res = 0;
+
+  add_temp_file (outname);
+
+  fp = fopen (outname, "w+");
+  if (fp == NULL)
+    error (EXIT_FAILURE, errno, "cannot open temporary file");
+
+  for (n = 0; str[n] != L'\0'; ++n)
+    putwc (str[n], fp);
+
+  /* First try reading after rewinding.  */
+  rewind (fp);
+
+  wmemset (buf, L'\0', sizeof (buf) / sizeof (buf[0]));
+  n = 0;
+  while (! feof (fp) && n < sizeof (buf) - 1)
+    {
+      buf[n] = getwc (fp);
+      if (buf[n] == WEOF)
+	break;
+      ++n;
+    }
+  buf[n] = L'\0';
+
+  if (wcscmp (buf, L"This is a test of putwc\n") != 0)
+    {
+      puts ("first comparison failed");
+      res = 1;
+    }
+
+  /* Now close the file, open it again, and read again.  */
+  if (fclose (fp) != 0)
+    {
+      printf ("failure during fclose(): %m");
+      res = 1;
+    }
+
+  fp = fopen (outname, "r");
+  if (fp == NULL)
+    error (EXIT_FAILURE, errno, "cannot reopen file");
+
+  /* We can remove the file now.  */
+  remove (outname);
+
+  wmemset (buf, L'\0', sizeof (buf) / sizeof (buf[0]));
+  n = 0;
+  while (! feof (fp) && n < sizeof (buf) - 1)
+    {
+      buf[n] = getwc (fp);
+      if (buf[n] == WEOF)
+	break;
+      ++n;
+    }
+  buf[n] = L'\0';
+
+  if (wcscmp (buf, L"This is a test of putwc\n") != 0)
+    {
+      puts ("second comparison failed");
+      res = 1;
+    }
+
+  if (fclose (fp) != 0)
+    {
+      puts ("failure during fclose()");
+      res = 1;
+    }
+
+  /* Next test: write a bit more than a few bytes.  */
+  fp = fopen (outname, "w");
+  if (fp == NULL)
+    error (EXIT_FAILURE, errno, "cannot open temporary file");
+
+  for (n = 0; n < 4098; ++n)
+    putwc (n & 255, fp);
+
+  fclose (fp);
+
+  return res;
+}
Index: trunk/src/libctests/glibc/libio/tst_swprintf.c
===================================================================
--- trunk/src/libctests/glibc/libio/tst_swprintf.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst_swprintf.c	(revision 2036)
@@ -0,0 +1,92 @@
+#include <stdio.h>
+#include <wchar.h>
+#include <sys/types.h>
+
+
+static wchar_t buf[100];
+#define nbuf (sizeof (buf) / sizeof (buf[0]))
+static const struct
+{
+  size_t n;
+  const char *str;
+  ssize_t exp;
+} tests[] =
+  {
+    { nbuf, "hello world", 11 },
+    { 0, "hello world", -1 },
+    { 0, "", -1 },
+    { nbuf, "", 0 }
+  };
+
+int
+main (int argc, char *argv[])
+{
+  size_t n;
+  int result = 0;
+
+  puts ("test 1");
+  n = swprintf (buf, nbuf, L"Hello %s", "world");
+  if (n != 11)
+    {
+      printf ("incorrect return value: %zd instead of 11\n", n);
+      result = 1;
+    }
+  else if (wcscmp (buf, L"Hello world") != 0)
+    {
+      printf ("incorrect string: L\"%ls\" instead of L\"Hello world\"\n", buf);
+      result = 1;
+    }
+
+  puts ("test 2");
+  n = swprintf (buf, nbuf, L"Is this >%g< 3.1?", 3.1);
+  if (n != 18)
+    {
+      printf ("incorrect return value: %zd instead of 18\n", n);
+      result = 1;
+    }
+  else if (wcscmp (buf, L"Is this >3.1< 3.1?") != 0)
+    {
+      printf ("incorrect string: L\"%ls\" instead of L\"Is this >3.1< 3.1?\"\n",
+	      buf);
+      result = 1;
+    }
+
+  for (n = 0; n < sizeof (tests) / sizeof (tests[0]); ++n)
+    {
+      ssize_t res = swprintf (buf, tests[n].n, L"%s", tests[n].str);
+
+      if (tests[n].exp < 0 && res >= 0)
+	{
+	  printf ("swprintf (buf, %Zu, L\"%%s\", \"%s\") expected to fail\n",
+		  tests[n].n, tests[n].str);
+	  result = 1;
+	}
+      else if (tests[n].exp >= 0 && tests[n].exp != res)
+	{
+	  printf ("swprintf (buf, %Zu, L\"%%s\", \"%s\") expected to return %Zd, but got %Zd\n",
+		  tests[n].n, tests[n].str, tests[n].exp, res);
+	  result = 1;
+	}
+      else
+	printf ("swprintf (buf, %Zu, L\"%%s\", \"%s\") OK\n",
+		tests[n].n, tests[n].str);
+    }
+
+  if (swprintf (buf, nbuf, L"%.0s", "foo") != 0
+      || wcslen (buf) != 0)
+    {
+      printf ("swprintf (buf, %Zu, L\"%%.0s\", \"foo\") create some output\n",
+	      nbuf);
+      result = 1;
+    }
+
+  if (swprintf (buf, nbuf, L"%.0ls", L"foo") != 0
+      || wcslen (buf) != 0)
+    {
+      printf ("swprintf (buf, %Zu, L\"%%.0ls\", L\"foo\") create some output\n",
+	      nbuf);
+      result = 1;
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/libio/tst_swscanf.c
===================================================================
--- trunk/src/libctests/glibc/libio/tst_swscanf.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst_swscanf.c	(revision 2036)
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+
+int
+main (int argc, char *argv[])
+{
+  const wchar_t in[] = L"7 + 35 is 42";
+  size_t n;
+  int a, b, c;
+  int result = 0;
+  char buf1[20];
+  wchar_t wbuf2[20];
+  char buf3[20];
+  char c4;
+  wchar_t wc5;
+
+  puts ("Test 1");
+  a = b = c = 0;
+  n = swscanf (in, L"%d + %d is %d", &a, &b, &c);
+  if (n != 3 || a + b != c || c != 42)
+    {
+      printf ("*** FAILED, n = %Zu, a = %d, b = %d, c = %d\n", n, a, b, c);
+      result = 1;
+    }
+
+  puts ("Test 2");
+  n = swscanf (L"one two three !!", L"%s %S %s %c%C",
+	       buf1, wbuf2, buf3, &c4, &wc5);
+  if (n != 5 || strcmp (buf1, "one") != 0 || wcscmp (wbuf2, L"two") != 0
+      || strcmp (buf3, "three") != 0 || c4 != '!' || wc5 != L'!')
+    {
+      printf ("*** FAILED, n = %Zu, buf1 = \"%s\", wbuf2 = L\"%S\", buf3 = \"%s\", c4 = '%c', wc5 = L'%C'\n",
+	      n, buf1, wbuf2, buf3, c4, (wint_t) wc5);
+      result = 1;
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/libio/tst_wprintf.c
===================================================================
--- trunk/src/libctests/glibc/libio/tst_wprintf.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst_wprintf.c	(revision 2036)
@@ -0,0 +1,11 @@
+#include <stdio.h>
+#include <wchar.h>
+
+int
+main (int argc, char *argv[])
+{
+  fputws (L"Hello world!\n", stdout);
+  wprintf (L"This %s a %ls string: %d\n", "is", L"mixed", 42);
+  wprintf (L"%Iu\n", 0xfeedbeef);
+  return 0;
+}
Index: trunk/src/libctests/glibc/libio/tst_wprintf2.c
===================================================================
--- trunk/src/libctests/glibc/libio/tst_wprintf2.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst_wprintf2.c	(revision 2036)
@@ -0,0 +1,104 @@
+/* Test case by Yoshito Kawada <KAWADA@jp.ibm.com>.  */
+#include <errno.h>
+#include <error.h>
+#include <fcntl.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <wchar.h>
+
+int
+main (int argc, char *argv[])
+{
+  int a = 3;
+  int fd;
+  char name[] = "/tmp/wprintf.out.XXXXXX";
+  FILE *fp;
+  char buf[100];
+  size_t len;
+  int res = 0;
+
+  fd = mkstemp (name);
+  if (fd == -1)
+    error (EXIT_FAILURE, errno, "cannot open temporary file");
+
+  unlink (name);
+
+  setlocale (LC_ALL, "");
+
+  fp = fdopen (dup (fd), "w");
+  if (fp == NULL)
+    error (EXIT_FAILURE, errno, "fdopen(,\"w\")");
+
+  fwprintf (fp, L"test start");
+  fwprintf (fp, L" int %d\n", a);
+
+  /* String with precision.  */
+  fwprintf (fp, L"1[%6.3s]\n", argv[1]);
+
+  fclose (fp);
+
+  fp = fdopen (dup (fd), "a");
+  if (fp == NULL)
+    error (EXIT_FAILURE, errno, "fdopen(,\"a\")");
+
+  setvbuf (fp, NULL, _IONBF, 0);
+
+  /* fwprintf to unbuffered stream.   */
+  fwprintf (fp, L"hello.\n");
+
+  fclose (fp);
+
+
+  /* Now read it back in.  This time using multibyte functions.  */
+  lseek (fd, SEEK_SET, 0);
+  fp = fdopen (fd, "r");
+  if (fp == NULL)
+    error (EXIT_FAILURE, errno, "fdopen(,\"r\")");
+
+  if (fgets (buf, sizeof buf, fp) != buf)
+    error (EXIT_FAILURE, errno, "first fgets");
+  len = strlen (buf);
+  if (buf[len - 1] == '\n')
+    --len;
+  else
+    {
+      puts ("newline missing after first line");
+      res = 1;
+    }
+  printf ("1st line: \"%.*s\" -> %s\n", (int) len, buf,
+	  strncmp (buf, "test start int 3", len) == 0 ? "OK" : "FAIL");
+  res |= strncmp (buf, "test start int 3", len) != 0;
+
+  if (fgets (buf, sizeof buf, fp) != buf)
+    error (EXIT_FAILURE, errno, "second fgets");
+  len = strlen (buf);
+  if (buf[len - 1] == '\n')
+    --len;
+  else
+    {
+      puts ("newline missing after second line");
+      res = 1;
+    }
+  printf ("2nd line: \"%.*s\" -> %s\n", (int) len, buf,
+	  strncmp (buf, "1[   Som]", len) == 0 ? "OK" : "FAIL");
+  res |= strncmp (buf, "1[   Som]", len) != 0;
+
+  if (fgets (buf, sizeof buf, fp) != buf)
+    error (EXIT_FAILURE, errno, "third fgets");
+  len = strlen (buf);
+  if (buf[len - 1] == '\n')
+    --len;
+  else
+    {
+      puts ("newline missing after third line");
+      res = 1;
+    }
+  printf ("3rd line: \"%.*s\" -> %s\n", (int) len, buf,
+	  strncmp (buf, "hello.", len) == 0 ? "OK" : "FAIL");
+  res |= strncmp (buf, "hello.", len) != 0;
+
+  return res;
+}
Index: trunk/src/libctests/glibc/libio/tst_wscanf.c
===================================================================
--- trunk/src/libctests/glibc/libio/tst_wscanf.c	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst_wscanf.c	(revision 2036)
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+
+int
+main (int argc, char *argv[])
+{
+  int n;
+  int result = 0;
+  char buf1[20];
+  wchar_t wbuf2[20];
+  char c3;
+  wchar_t wc4;
+  int d;
+
+  puts ("Test 1");
+
+  n = wscanf (L"%s %S %c%C %d", buf1, wbuf2, &c3, &wc4, &d);
+
+  if (n != 5 || strcmp (buf1, "Hello") != 0 || wcscmp (wbuf2, L"World") != 0
+      || c3 != '!' || wc4 != L'!' || d != 42)
+    {
+      printf ("*** FAILED, n = %d, buf1 = \"%s\", wbuf2 = L\"%S\", c3 = '%c', wc4 = L'%C', d = %d\n",
+	      n, buf1, wbuf2, c3, (wint_t) wc4, d);
+      result = 1;
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/libio/tst_wscanf.input
===================================================================
--- trunk/src/libctests/glibc/libio/tst_wscanf.input	(revision 2036)
+++ trunk/src/libctests/glibc/libio/tst_wscanf.input	(revision 2036)
@@ -0,0 +1,1 @@
+Hello World !! 42
Index: trunk/src/libctests/glibc/linuxthreads/Examples/Makefile
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/Examples/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/Examples/Makefile	(revision 2036)
@@ -0,0 +1,15 @@
+CC=gcc
+CFLAGS=-g -O -Wall -I.. -D_REENTRANT
+LIBPTHREAD=../libpthread.a
+
+PROGS=ex1 ex2 ex3 ex4 ex5 proxy
+
+all: $(PROGS)
+
+.c:
+	$(CC) $(CFLAGS) -o $* $*.c $(LIBPTHREAD)
+
+$(PROGS):
+
+clean:
+	rm -f $(PROGS)
Index: trunk/src/libctests/glibc/linuxthreads/Examples/tststatic.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/Examples/tststatic.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/Examples/tststatic.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "ex1.c"
Index: trunk/src/libctests/glibc/linuxthreads/Makefile
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/Makefile	(revision 2036)
@@ -0,0 +1,345 @@
+# Copyright (C) 1996-2003, 2004, 2005 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Sub-makefile for linuxthreads portion of the library.
+#
+subdir	:= linuxthreads
+
+all: # Make this the default target; it will be defined in Rules.
+
+linuxthreads-version := $(shell sed -n 's/^.*$(subdir)-\([0-9.]*\).*$$/\1/p' \
+				    Banner)
+libpthread-abi-frozen := GLIBC_2.3.2
+
+headers := pthread.h semaphore.h
+distribute := internals.h queue.h restart.h spinlock.h smp.h tst-signal.sh \
+	      tst-cancel-wrappers.sh libc-tsd.c
+
+routines := forward alloca_cutoff libc-cancellation libc_pthread_init
+shared-only-routines = forward
+
+extra-libs := libpthread
+extra-libs-others := $(extra-libs)
+install-lib-ldscripts := libpthread.so
+
+libpthread-routines := attr cancel condvar join manager mutex ptfork \
+		       ptlongjmp pthread pt-sigsuspend signals specific errno \
+		       lockfile semaphore spinlock rwlock pt-machine \
+		       oldsemaphore events getcpuclockid pspinlock barrier \
+		       ptclock_gettime ptclock_settime sighandler \
+		       pthandles libc-tls-loc pt-allocrtsig \
+		       ptw-write ptw-read ptw-close ptw-fcntl ptw-accept \
+		       ptw-connect ptw-recv ptw-recvfrom ptw-recvmsg \
+		       ptw-send ptw-sendmsg ptw-sendto ptw-fsync ptw-lseek \
+		       ptw-lseek64 ptw-llseek ptw-msync ptw-nanosleep \
+		       ptw-open ptw-open64 ptw-pause ptw-pread ptw-pread64 \
+		       ptw-pwrite ptw-pwrite64 ptw-tcdrain ptw-wait \
+		       ptw-waitpid pt-system old_pthread_atfork pthread_atfork \
+		       ptcleanup
+#		       pthread_setuid pthread_seteuid pthread_setreuid \
+#		       pthread_setresuid \
+#		       pthread_setgid pthread_setegid pthread_setregid \
+#		       pthread_setresgid
+
+# Don't generate deps for calls with no sources.  See sysdeps/unix/Makefile.
+omit-deps = $(unix-syscalls:%=ptw-%)
+
+libpthread-shared-only-routines = pt-allocrtsig
+libpthread-static-only-routines = pthread_atfork
+
+linuxthreads-CPPFLAGS = -DIS_IN_linuxthreads=1
+
+CFLAGS-pthread_atfork.c = -DNOT_IN_libc
+
+nodelete-yes = -Wl,--enable-new-dtags,-z,nodelete
+initfirst-yes = -Wl,--enable-new-dtags,-z,initfirst
+LDFLAGS-pthread.so = $(nodelete-$(have-z-nodelete)) \
+		     $(initfirst-$(have-z-initfirst))
+
+vpath %.c Examples
+
+tst-cancel-ARGS = "$(objpfx)"
+CFLAGS-tst-cancel.c = -fno-inline -fno-inline-functions
+
+include ../Makeconfig
+
+ifeq ($(build-shared),yes)
+
+# Set the `multidir' variable by grabbing the variable from the compiler.
+# We do it once and save the result in a generated makefile.
+-include $(objpfx)multidir.mk
+$(objpfx)multidir.mk: $(common-objpfx)config.make
+	$(make-target-directory)
+	dir=`$(CC) $(CFLAGS) $(CPPFLAGS) -print-multi-directory`; \
+	echo "multidir := $$dir" > $@T
+	mv -f $@T $@
+generated += multidir.mk
+
+crti-objs := crti.o
+crtn-objs := crtn.o
+ifneq (,$(patsubst .,,$(multidir)))
+generated-dirs := $(firstword $(subst /, , $(multidir)))
+crti-objs += $(multidir)/crti.o
+crtn-objs += $(multidir)/crtn.o
+omit-deps += $(multidir)/crti $(multidir)/crtn
+endif
+extra-objs += $(crti-objs) $(crtn-objs)
+omit-deps += crti crtn
+
+CFLAGS-pt-initfini.s = -g0 -fPIC -fno-inline-functions $(fno-unit-at-a-time)
+endif
+
+librt-tests = ex10 ex11 tst-clock1
+tests = ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 $(librt-tests) ex12 ex13 joinrace \
+	tststack $(tests-nodelete-$(have-z-nodelete)) ecmutex ex14 ex15 ex16 \
+	ex17 ex18 tst-cancel tst-context bug-sleep \
+	tst-cancel1 tst-cancel2 tst-cancel3 tst-cancel4 tst-cancel5 \
+	tst-cancel6 tst-cancel7 tst-cancel8 tst-popen tst-popen2 tst-attr1 \
+	tst-stack1 tst-align tst-tsd1
+test-srcs = tst-signal
+# These tests are linked with libc before libpthread
+tests-reverse += tst-cancel5
+
+ifeq ($(build-static),yes)
+tests += tststatic tst-static-locale tst-cancel-static
+tests-static += tststatic tst-static-locale tst-cancel-static
+endif
+
+ifeq (yes,$(build-shared))
+tests-nodelete-yes = unload
+tests += tst-tls1 tst-_res1
+endif
+
+modules-names = tst-_res1mod1 tst-_res1mod2 \
+		tst-tls1mod tst-tls1moda tst-tls1modb tst-tls1modc \
+		tst-tls1modd tst-tls1mode tst-tls1modf
+extra-objs += $(addsuffix .os,$(strip $(modules-names)))
+generated += $(addsuffix .so,$(strip $(modules-names)))
+test-extras += $(modules-names)
+test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(modules-names)))
+
+tst-tls1mod.so-no-z-defs = yes
+tst-tls1moda.so-no-z-defs = yes
+tst-tls1modb.so-no-z-defs = yes
+tst-tls1modc.so-no-z-defs = yes
+tst-tls1modd.so-no-z-defs = yes
+tst-tls1mode.so-no-z-defs = yes
+tst-tls1modf.so-no-z-defs = yes
+
+$(test-modules): $(objpfx)%.so: $(objpfx)%.os $(common-objpfx)shlib.lds
+	$(build-module)
+
+ifeq ($(build-shared),yes)
+# Build all the modules even when not actually running test programs.
+tests: $(test-modules)
+endif
+
+# What we install as libpthread.so for programs to link against is in fact a
+# link script.  It contains references for the various libraries we need.
+# The libpthread.so object is not complete since some functions are only defined
+# in libpthread_nonshared.a.
+# We need to use absolute paths since otherwise local copies (if they exist)
+# of the files are taken by the linker.
+install: $(inst_libdir)/libpthread.so
+$(inst_libdir)/libpthread.so: $(common-objpfx)format.lds \
+			      $(objpfx)libpthread.so$(libpthread.so-version) \
+			      $(inst_libdir)/$(patsubst %,$(libtype.oS),\
+							$(libprefix)pthread) \
+			      $(+force)
+	(echo '/* GNU ld script';\
+	 echo '   Use the shared library, but some functions are only in';\
+	 echo '   the static library, so try that secondarily.  */';\
+	 cat $<; \
+	 echo 'GROUP ( $(slibdir)/libpthread.so$(libpthread.so-version)' \
+	      '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)pthread)'\
+	      ')' \
+	) > $@.new
+	mv -f $@.new $@
+
+
+extra-B-pthread.so = -B$(common-objpfx)linuxthreads/
+$(objpfx)libpthread.so: $(addprefix $(objpfx),$(crti-objs) $(crtn-objs))
+$(objpfx)libpthread.so: +preinit += $(addprefix $(objpfx),$(crti-objs))
+$(objpfx)libpthread.so: +postinit += $(addprefix $(objpfx),$(crtn-objs))
+
+znodelete-yes = -DHAVE_Z_NODELETE
+CFLAGS-mutex.c += -D__NO_WEAK_PTHREAD_ALIASES
+CFLAGS-specific.c += -D__NO_WEAK_PTHREAD_ALIASES
+CFLAGS-pthread.c += -D__NO_WEAK_PTHREAD_ALIASES $(znodelete-$(have-z-nodelete))
+CFLAGS-ptfork.c += -D__NO_WEAK_PTHREAD_ALIASES
+CFLAGS-cancel.c += -D__NO_WEAK_PTHREAD_ALIASES -D_RPC_THREAD_SAFE_
+CFLAGS-unload.c += -DPREFIX=\"$(objpfx)\"
+CFLAGS-mutex.c += $(uses-callbacks)
+CFLAGS-sighandler.c += $(uses-callbacks)
+
+ifeq (yes,$(versioning))
+-include $(common-objpfx)tls.make
+libc-ok-for-link = $(use-thread)
+else
+libc-ok-for-link = yes
+endif
+
+ifeq (no,$(libc-ok-for-link))
+# These hacks are necessary to let us link against a libc.so that exports
+# the symbols _errno, _h_errno, and _res.  Those symbols are accessible
+# in libc at runtime (dynamic linkable), but are not exported at link time
+# so that applications cannot link against them.  However, libpthread.so
+# needs to link against them for its __errno_location et al functions to
+# find the locations that libc's symbols resolve to.  We cannot do this
+# with aliases in libc.so(GLIBC_PRIVATE), because we need to refer to an
+# executable's symbols when it defines them with copy relocs.
+libc-link.so = $(objpfx)libc.so
+
+$(objpfx)libc_pic_lite.a: $(common-objpfx)libc_pic.a
+	cp $< $@T
+	$(AR) d $@T errno.os herrno.os res_libc.os
+	mv -f $@T $@
+
+extra-objs += libc-tsd.os
+$(objpfx)libc_pic_lite.os: $(objpfx)libc_pic_lite.a $(objpfx)libc-tsd.os
+	$(LINK.o) -nostdlib -nostartfiles -r -o $@ \
+		  $(LDFLAGS-c_pic.os) -Wl,-d -Wl,--whole-archive $^
+
+# This trick leaves errno and h_errno undefined.
+libc.so-no-z-defs = yes
+
+$(objpfx)libc.so: $(elfobjdir)/soinit.os \
+		  $(objpfx)libc_pic_lite.os \
+		  $(elfobjdir)/sofini.os \
+		  $(elfobjdir)/interp.os $(elfobjdir)/ld.so
+	$(build-shlib)
+
+generated += libc_pic_lite.a libc_pic_lite.os libc.so libc-tsd.os
+else
+libc-link.so = $(common-objpfx)libc.so
+endif
+
+include ../Rules
+
+# Depend on libc.so so a DT_NEEDED is generated in the shared objects.
+# This ensures they will load libc.so for needed symbols if loaded by
+# a statically-linked program that hasn't already loaded it.
+# Depend on ld.so too to get proper versions of ld.so symbols.
+$(objpfx)libpthread.so: $(libc-link.so) $(common-objpfx)libc_nonshared.a \
+			$(if $(filter yes,$(elf)), $(elfobjdir)/ld.so)
+
+# Make sure we link with the thread library.
+ifeq ($(build-shared),yes)
+$(addprefix $(objpfx), \
+  $(filter-out $(tests-static) $(tests-reverse) unload, \
+    $(tests) $(test-srcs))): $(objpfx)libpthread.so \
+			     $(objpfx)libpthread_nonshared.a
+# $(objpfx)../libc.so is used instead of $(common-objpfx)libc.so,
+# since otherwise libpthread.so comes before libc.so when linking.
+$(addprefix $(objpfx), $(tests-reverse)): \
+  $(objpfx)../libc.so $(objpfx)libpthread.so \
+  $(objpfx)libpthread_nonshared.a
+$(objpfx)../libc.so: $(common-objpfx)libc.so ;
+$(addprefix $(objpfx),$(librt-tests)): $(common-objpfx)rt/librt.so
+$(objpfx)unload: $(common-objpfx)dlfcn/libdl.so
+$(objpfx)unload.out: $(objpfx)libpthread.so $(objpfx)libpthread_nonshared.a
+else
+$(addprefix $(objpfx),$(tests) $(test-srcs)): $(objpfx)libpthread.a
+$(addprefix $(objpfx),$(librt-tests)): $(common-objpfx)rt/librt.a
+endif
+ifeq ($(build-bounded),yes)
+$(tests:%=$(objpfx)%-bp): $(objpfx)libpthread_b.a
+$(librt-tests:%=$(objpfx)%-bp): $(common-objpfx)rt/librt_b.a
+endif
+
+ifeq ($(build-static),yes)
+$(addprefix $(objpfx), $(tests-static)): $(objpfx)libpthread.a
+endif
+
+ifeq ($(build-shared),yes)
+vpath pt-initfini.c $(full_config_sysdirs)
+
+$(objpfx)pt-initfini.s: pt-initfini.c
+	$(compile.c) -S $(CFLAGS-pt-initfini.s) -finhibit-size-directive \
+		$(patsubst -f%,-fno-%,$(exceptions)) -o $@
+
+# We only have one kind of startup code files.  Static binaries and
+# shared libraries are build using the PIC version.
+$(objpfx)crti.S: $(objpfx)pt-initfini.s
+	sed -n -e '1,/@HEADER_ENDS/p' \
+	       -e '/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \
+	       -e '/@TRAILER_BEGINS/,$$p' $< > $@
+$(objpfx)crtn.S: $(objpfx)pt-initfini.s
+	sed -n -e '1,/@HEADER_ENDS/p' \
+	       -e '/@_.*_EPILOG_BEGINS/,/@_.*_EPILOG_ENDS/p' \
+	       -e '/@TRAILER_BEGINS/,$$p' $< > $@
+
+$(objpfx)defs.h: $(objpfx)pt-initfini.s
+	sed -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \
+		$(AWK) -f ../csu/defs.awk > $@
+
+$(objpfx)crti.o: $(objpfx)crti.S $(objpfx)defs.h
+	$(compile.S) -g0 $(ASFLAGS-.os) -o $@
+
+$(objpfx)crtn.o: $(objpfx)crtn.S $(objpfx)defs.h
+	$(compile.S) -g0 $(ASFLAGS-.os) -o $@
+
+ifneq ($(multidir),.)
+$(objpfx)$(multidir):
+	@mkdir -p $(objpfx)$(multidir)
+
+$(objpfx)$(multidir)/crti.o: $(objpfx)crti.o $(objpfx)$(multidir)
+	ln -f $< $@
+
+$(objpfx)$(multidir)/crtn.o: $(objpfx)crtn.o $(objpfx)$(multidir)
+	ln -f $< $@
+endif
+
+generated += crti.S crtn.S defs.h pt-initfini.s libpthread_nonshared.a
+endif
+
+ifeq (yes,$(build-static-nss))
+otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
+             $(resolvobjdir)/libresolv.a
+endif
+
+ifeq (yes,$(build-shared))
+$(objpfx)tst-_res1mod2.so: $(objpfx)tst-_res1mod1.so
+$(objpfx)tst-_res1: $(objpfx)tst-_res1mod2.so $(shared-thread-library)
+
+$(objpfx)tst-tls1: $(objpfx)tst-tls1mod.so $(shared-thread-library)
+
+tests: $(objpfx)tst-tls2.out
+$(objpfx)tst-tls2.out: tst-tls2.sh $(objpfx)tst-tls1 \
+		       $(objpfx)tst-tls1moda.so $(objpfx)tst-tls1modb.so \
+		       $(objpfx)tst-tls1modc.so $(objpfx)tst-tls1modd.so \
+		       $(objpfx)tst-tls1mode.so $(objpfx)tst-tls1modf.so
+	$(SHELL) -e tst-tls2.sh $(common-objpfx) $(elf-objpfx) \
+		    $(rtld-installed-name)
+generated += tst-tls2.out
+endif
+
+ifeq (no,$(cross-compiling))
+ifeq (yes,$(build-shared))
+tests: $(objpfx)tst-signal.out $(objpfx)tst-cancel-wrappers.out
+$(objpfx)tst-signal.out: tst-signal.sh $(objpfx)tst-signal
+	$(SHELL) -e $< $(common-objpfx) > $@
+$(objpfx)tst-cancel-wrappers.out: tst-cancel-wrappers.sh
+	$(SHELL) $< $(common-objpfx)/libc_pic.a \
+		    $(common-objpfx)/libc.a \
+		    $(objpfx)/libpthread_pic.a \
+		    $(objpfx)/libpthread.a > $@
+generated += tst-signal.out tst-cancel-wrappers.out
+endif
+endif
Index: trunk/src/libctests/glibc/linuxthreads/bug-sleep.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/bug-sleep.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/bug-sleep.c	(revision 2036)
@@ -0,0 +1,34 @@
+/* PR libc/4005 */
+#include <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <time.h>
+
+void *
+run_thread (void *a)
+{
+  while (1)
+    {
+      sleep (10);
+    }
+  return 0;
+}
+
+int
+main (void)
+{
+  pthread_t thr;
+  void *result;
+  alarm (4);
+  printf ("Starting thread.\n");
+  pthread_create (&thr, 0, run_thread, 0);
+  sleep (2);
+  printf ("Canceling thread.\n");
+  pthread_cancel (thr);
+  pthread_join (thr, &result);
+  if (result == PTHREAD_CANCELED)
+    printf ("Thread canceled.\n");
+  else
+    printf ("Thread exited.\n");
+  return 0;
+}
Index: trunk/src/libctests/glibc/linuxthreads/sysdeps/pthread/Makefile
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/sysdeps/pthread/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/sysdeps/pthread/Makefile	(revision 2036)
@@ -0,0 +1,14 @@
+ifeq ($(subdir),rt)
+librt-sysdep_routines += timer_routines
+CPPFLAGS += -DBROKEN_THREAD_SIGNALS
+
+ifeq (yes,$(build-shared))
+$(objpfx)tst-timer: $(objpfx)librt.so $(shared-thread-library)
+else
+$(objpfx)tst-timer: $(objpfx)librt.a $(static-thread-library)
+endif
+endif
+
+ifeq ($(subdir),posix)
+CFLAGS-confstr.c += -DLIBPTHREAD_VERSION="\"$(shell sed 's/\(.*\) by .*/\1/' ../linuxthreads/Banner)\""
+endif
Index: trunk/src/libctests/glibc/linuxthreads/sysdeps/pthread/tst-timer.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/sysdeps/pthread/tst-timer.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/sysdeps/pthread/tst-timer.c	(revision 2036)
@@ -0,0 +1,114 @@
+/* Tests for POSIX timer implementation.
+   Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Kaz Kylheku <kaz@ashi.footprints.net>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <time.h>
+#include <unistd.h>
+
+
+static void
+notify_func (union sigval sigval)
+{
+  puts ("notify_func");
+}
+
+
+static void
+signal_func (int sig)
+{
+  static const char text[] = "signal_func\n";
+  signal (sig, signal_func);
+  write (STDOUT_FILENO, text, sizeof text - 1);
+}
+
+static void
+intr_sleep (int sec)
+{
+  struct timespec ts;
+
+  ts.tv_sec = sec;
+  ts.tv_nsec = 0;
+
+  while (nanosleep (&ts, &ts) == -1 && errno == EINTR)
+    ;
+}
+
+#define ZSIGALRM 14
+
+
+int
+main (void)
+{
+  struct timespec ts;
+  timer_t timer_sig, timer_thr1, timer_thr2;
+  int retval;
+  struct sigevent sigev1 =
+  {
+    .sigev_notify = SIGEV_SIGNAL,
+    .sigev_signo = ZSIGALRM
+  };
+  struct sigevent sigev2;
+  struct itimerspec itimer1 = { { 0, 200000000 }, { 0, 200000000 } };
+  struct itimerspec itimer2 = { { 0, 100000000 }, { 0, 500000000 } };
+  struct itimerspec itimer3 = { { 0, 150000000 }, { 0, 300000000 } };
+  struct itimerspec old;
+
+  retval = clock_gettime (CLOCK_REALTIME, &ts);
+
+  sigev2.sigev_notify = SIGEV_THREAD;
+  sigev2.sigev_notify_function = notify_func;
+  sigev2.sigev_notify_attributes = NULL;
+
+  setvbuf (stdout, 0, _IOLBF, 0);
+
+  printf ("clock_gettime returned %d, timespec = { %ld, %ld }\n",
+	  retval, ts.tv_sec, ts.tv_nsec);
+
+  retval = clock_getres (CLOCK_REALTIME, &ts);
+
+  printf ("clock_getres returned %d, timespec = { %ld, %ld }\n",
+	  retval, ts.tv_sec, ts.tv_nsec);
+
+  timer_create (CLOCK_REALTIME, &sigev1, &timer_sig);
+  timer_create (CLOCK_REALTIME, &sigev2, &timer_thr1);
+  timer_create (CLOCK_REALTIME, &sigev2, &timer_thr2);
+
+  timer_settime (timer_thr1, 0, &itimer2, &old);
+  timer_settime (timer_thr2, 0, &itimer3, &old);
+
+  signal (ZSIGALRM, signal_func);
+
+  timer_settime (timer_sig, 0, &itimer1, &old);
+
+  timer_delete (-1);
+
+  intr_sleep (3);
+
+  timer_delete (timer_sig);
+  timer_delete (timer_thr1);
+
+  intr_sleep (3);
+
+  timer_delete (timer_thr2);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/linuxthreads/tst-_res1.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-_res1.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-_res1.c	(revision 2036)
@@ -0,0 +1,69 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* Test whether _res in glibc 2.1.x and earlier (before __res_state()
+   was introduced) works.  Portable programs should never do the
+   dirty things below.  */
+
+#include <pthread.h>
+#include <resolv.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+void *tf (void *resp)
+{
+  if (resp == &_res || resp == __res_state ())
+    abort ();
+  _res.retry = 24;
+  return NULL;
+}
+
+void do_test (struct __res_state *resp)
+{
+  if (resp != &_res || resp != __res_state ())
+    abort ();
+  if (_res.retry != 12)
+    abort ();
+}
+
+int main (void)
+{
+#undef _res
+  extern struct __res_state _res;
+  pthread_t th;
+
+  _res.retry = 12;
+  if (pthread_create (&th, NULL, tf, &_res) != 0)
+    {
+      puts ("create failed");
+      exit (1);
+    }
+
+  do_test (&_res);
+
+  if (pthread_join (th, NULL) != 0)
+    {
+      puts ("join failed");
+      exit (1);
+    }
+
+  do_test (&_res);
+
+  exit (0);
+}
Index: trunk/src/libctests/glibc/linuxthreads/tst-_res1mod1.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-_res1mod1.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-_res1mod1.c	(revision 2036)
@@ -0,0 +1,23 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <resolv.h>
+#undef _res
+
+struct __res_state _res;
Index: trunk/src/libctests/glibc/linuxthreads/tst-_res1mod2.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-_res1mod2.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-_res1mod2.c	(revision 2036)
@@ -0,0 +1,1 @@
+/* Nothing.  */
Index: trunk/src/libctests/glibc/linuxthreads/tst-align.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-align.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-align.c	(revision 2036)
@@ -0,0 +1,71 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <tst-stack-align.h>
+
+static void *
+tf (void *arg)
+{
+  bool ok = true;
+
+  puts ("in thread");
+
+  if (TEST_STACK_ALIGN ())
+    ok = false;
+
+  return ok ? NULL : (void *) -1l;
+}
+
+static int
+do_test (void)
+{
+  bool ok = true;
+
+  puts ("in main");
+
+  if (TEST_STACK_ALIGN ())
+    ok = false;
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      return 1;
+    }
+
+  void *res;
+  if (pthread_join (th, &res) != 0)
+    {
+      puts ("join failed");
+      return 1;
+    }
+
+  if (res != NULL)
+    ok = false;
+
+  return ok ? 0 : 1;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/linuxthreads/tst-attr1.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-attr1.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-attr1.c	(revision 2036)
@@ -0,0 +1,358 @@
+/* pthread_getattr_np test.
+   Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <error.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <stackinfo.h>
+
+static void *
+tf (void *arg)
+{
+  pthread_attr_t a, *ap, a2;
+  int err;
+  void *result = NULL;
+
+  if (arg == NULL)
+    {
+      ap = &a2;
+      err = pthread_attr_init (ap);
+      if (err)
+        {
+          error (0, err, "pthread_attr_init failed");
+          return tf;
+        }
+    }
+  else
+    ap = (pthread_attr_t *) arg;
+
+  err = pthread_getattr_np (pthread_self (), &a);
+  if (err)
+    {
+      error (0, err, "pthread_getattr_np failed");
+      result = tf;
+    }
+
+  int detachstate1, detachstate2;
+  err = pthread_attr_getdetachstate (&a, &detachstate1);
+  if (err)
+    {
+      error (0, err, "pthread_attr_getdetachstate failed");
+      result = tf;
+    }
+  else
+    {
+      err = pthread_attr_getdetachstate (ap, &detachstate2);
+      if (err)
+	{
+	  error (0, err, "pthread_attr_getdetachstate failed");
+	  result = tf;
+	}
+      else if (detachstate1 != detachstate2)
+	{
+	  error (0, 0, "detachstate differs %d != %d",
+		 detachstate1, detachstate2);
+	  result = tf;
+	}
+    }
+
+  void *stackaddr;
+  size_t stacksize;
+  err = pthread_attr_getstack (&a, &stackaddr, &stacksize);
+  if (err)
+    {
+      error (0, err, "pthread_attr_getstack failed");
+      result = tf;
+    }
+  else if ((void *) &a < stackaddr
+	   || (void *) &a >= stackaddr + stacksize)
+    {
+      error (0, 0, "pthread_attr_getstack returned range does not cover thread's stack");
+      result = tf;
+    }
+  else
+    printf ("thread stack %p-%p (0x%zx)\n", stackaddr, stackaddr + stacksize,
+	    stacksize);
+
+  size_t guardsize1, guardsize2;
+  err = pthread_attr_getguardsize (&a, &guardsize1);
+  if (err)
+    {
+      error (0, err, "pthread_attr_getguardsize failed");
+      result = tf;
+    }
+  else
+    {
+      err = pthread_attr_getguardsize (ap, &guardsize2);
+      if (err)
+	{
+	  error (0, err, "pthread_attr_getguardsize failed");
+	  result = tf;
+	}
+      else if (guardsize1 != guardsize2)
+	{
+	  error (0, 0, "guardsize differs %zd != %zd",
+		 guardsize1, guardsize2);
+	  result = tf;
+	}
+      else
+	printf ("thread guardsize %zd\n", guardsize1);
+    }
+
+  int scope1, scope2;
+  err = pthread_attr_getscope (&a, &scope1);
+  if (err)
+    {
+      error (0, err, "pthread_attr_getscope failed");
+      result = tf;
+    }
+  else
+    {
+      err = pthread_attr_getscope (ap, &scope2);
+      if (err)
+	{
+	  error (0, err, "pthread_attr_getscope failed");
+	  result = tf;
+	}
+      else if (scope1 != scope2)
+	{
+	  error (0, 0, "scope differs %d != %d",
+		 scope1, scope2);
+	  result = tf;
+	}
+    }
+
+  err = pthread_attr_destroy (&a);
+  if (err)
+    {
+      error (0, err, "pthread_attr_destroy failed");
+      result = tf;
+    }
+
+  if (ap == &a2)
+    {
+      err = pthread_attr_destroy (ap);
+      if (err)
+	{
+	  error (0, err, "pthread_attr_destroy failed");
+	  result = tf;
+	}
+    }
+
+  return result;
+}
+
+
+static int
+do_test (void)
+{
+  int result = 0;
+  pthread_attr_t a;
+
+  int err = pthread_attr_init (&a);
+  if (err)
+    {
+      error (0, err, "pthread_attr_init failed");
+      result = 1;
+    }
+
+  err = pthread_attr_destroy (&a);
+  if (err)
+    {
+      error (0, err, "pthread_attr_destroy failed");
+      result = 1;
+    }
+
+  err = pthread_getattr_np (pthread_self (), &a);
+  if (err)
+    {
+      error (0, err, "pthread_getattr_np failed");
+      result = 1;
+    }
+
+  int detachstate;
+  err = pthread_attr_getdetachstate (&a, &detachstate);
+  if (err)
+    {
+      error (0, err, "pthread_attr_getdetachstate failed");
+      result = 1;
+    }
+  else if (detachstate != PTHREAD_CREATE_JOINABLE)
+    {
+      error (0, 0, "initial thread not joinable");
+      result = 1;
+    }
+
+  void *stackaddr;
+  size_t stacksize;
+  err = pthread_attr_getstack (&a, &stackaddr, &stacksize);
+  if (err)
+    {
+      error (0, err, "pthread_attr_getstack failed");
+      result = 1;
+    }
+  else if ((void *) &a < stackaddr
+	   || (void *) &a >= stackaddr + stacksize)
+    {
+      error (0, 0, "pthread_attr_getstack returned range does not cover main's stack");
+      result = 1;
+    }
+  else
+    printf ("initial thread stack %p-%p (0x%zx)\n", stackaddr,
+	    stackaddr + stacksize, stacksize);
+
+  size_t guardsize;
+  err = pthread_attr_getguardsize (&a, &guardsize);
+  if (err)
+    {
+      error (0, err, "pthread_attr_getguardsize failed");
+      result = 1;
+    }
+  else if (guardsize != 0)
+    {
+      error (0, 0, "pthread_attr_getguardsize returned %zd != 0",
+	     guardsize);
+      result = 1;
+    }
+
+  int scope;
+  err = pthread_attr_getscope (&a, &scope);
+  if (err)
+    {
+      error (0, err, "pthread_attr_getscope failed");
+      result = 1;
+    }
+  else if (scope != PTHREAD_SCOPE_SYSTEM)
+    {
+      error (0, 0, "pthread_attr_getscope returned %d != PTHREAD_SCOPE_SYSTEM",
+	     scope);
+      result = 1;
+    }
+
+  int inheritsched;
+  err = pthread_attr_getinheritsched (&a, &inheritsched);
+  if (err)
+    {
+      error (0, err, "pthread_attr_getinheritsched failed");
+      result = 1;
+    }
+  else if (inheritsched != PTHREAD_INHERIT_SCHED)
+    {
+      error (0, 0, "pthread_attr_getinheritsched returned %d != PTHREAD_INHERIT_SCHED",
+	     inheritsched);
+      result = 1;
+    }
+
+  err = pthread_attr_destroy (&a);
+  if (err)
+    {
+      error (0, err, "pthread_attr_destroy failed");
+      result = 1;
+    }
+
+  pthread_t th;
+  err = pthread_create (&th, NULL, tf, NULL);
+  if (err)
+    {
+      error (0, err, "pthread_create #1 failed");
+      result = 1;
+    }
+  else
+    {
+      void *ret;
+      err = pthread_join (th, &ret);
+      if (err)
+	{
+	  error (0, err, "pthread_join #1 failed");
+	  result = 1;
+	}
+      else if (ret != NULL)
+        result = 1;
+    }
+
+  err = pthread_attr_init (&a);
+  if (err)
+    {
+      error (0, err, "pthread_attr_init failed");
+      result = 1;
+    }
+
+  err = pthread_create (&th, &a, tf, &a);
+  if (err)
+    {
+      error (0, err, "pthread_create #2 failed");
+      result = 1;
+    }
+  else
+    {
+      void *ret;
+      err = pthread_join (th, &ret);
+      if (err)
+	{
+	  error (0, err, "pthread_join #2 failed");
+	  result = 1;
+	}
+      else if (ret != NULL)
+        result = 1;
+    }
+
+  err = pthread_attr_setguardsize (&a, 16 * sysconf (_SC_PAGESIZE));
+  if (err)
+    {
+      error (0, err, "pthread_attr_setguardsize failed");
+      result = 1;
+    }
+
+  err = pthread_create (&th, &a, tf, &a);
+  if (err)
+    {
+      error (0, err, "pthread_create #3 failed");
+      result = 1;
+    }
+  else
+    {
+      void *ret;
+      err = pthread_join (th, &ret);
+      if (err)
+	{
+	  error (0, err, "pthread_join #3 failed");
+	  result = 1;
+	}
+      else if (ret != NULL)
+        result = 1;
+    }
+
+  err = pthread_attr_destroy (&a);
+  if (err)
+    {
+      error (0, err, "pthread_attr_destroy failed");
+      result = 1;
+    }
+
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/linuxthreads/tst-cancel-static.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-cancel-static.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-cancel-static.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cancel4.c"
Index: trunk/src/libctests/glibc/linuxthreads/tst-cancel-wrappers.sh
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-cancel-wrappers.sh	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-cancel-wrappers.sh	(revision 2036)
@@ -0,0 +1,92 @@
+#! /bin/sh
+# Test whether all cancelable functions are cancelable.
+# Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+# Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+while [ $# -gt 0 ]; do
+  ( nm -P $1; echo 'end[end]:' ) | gawk ' BEGIN {
+C["accept"]=1
+C["close"]=1
+C["connect"]=1
+C["creat"]=1
+C["fcntl"]=1
+C["fsync"]=1
+C["msgrcv"]=1
+C["msgsnd"]=1
+C["msync"]=1
+C["nanosleep"]=1
+C["open"]=1
+C["open64"]=1
+C["pause"]=1
+C["poll"]=1
+C["pread"]=1
+C["pread64"]=1
+C["pselect"]=1
+C["pwrite"]=1
+C["pwrite64"]=1
+C["read"]=1
+C["readv"]=1
+C["recv"]=1
+C["recvfrom"]=1
+C["recvmsg"]=1
+C["select"]=1
+C["send"]=1
+C["sendmsg"]=1
+C["sendto"]=1
+C["sigpause"]=1
+C["sigsuspend"]=1
+C["sigwait"]=1
+C["sigwaitinfo"]=1
+C["system"]=1
+C["tcdrain"]=1
+C["wait"]=1
+C["waitid"]=1
+C["waitpid"]=1
+C["write"]=1
+C["writev"]=1
+C["__xpg_sigpause"]=1
+}
+/:$/ {
+  if (seen)
+    {
+      if (!seen_enable || !seen_disable)
+	{
+	  printf "in '$1'(%s) %s'\''s cancellation missing\n", object, seen
+	  ret = 1
+	}
+    }
+  seen=""
+  seen_enable=""
+  seen_disable=""
+  object=gensub(/^.*\[(.*)\]:$/,"\\1","",$0)
+  next
+}
+{
+  if (C[$1] && $2 ~ /^[TW]$/)
+    seen=$1
+  else if ($1 ~ /^([.]|)__(libc|pthread)_enable_asynccancel$/ && $2 == "U")
+    seen_enable=1
+  else if ($1 ~ /^([.]|)__(libc|pthread)_disable_asynccancel$/ && $2 == "U")
+    seen_disable=1
+}
+END {
+  exit ret
+}' || exit
+  shift
+done
Index: trunk/src/libctests/glibc/linuxthreads/tst-cancel.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-cancel.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-cancel.c	(revision 2036)
@@ -0,0 +1,214 @@
+/* Tests for cancelation handling.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+int fd;
+
+pthread_barrier_t bar;
+
+
+#ifdef NOT_YET
+static void
+cleanup (void *arg)
+{
+  int nr = (int) (long int) arg;
+  char s[30];
+  char *cp = stpcpy (s, "cleanup ");
+  *cp++ = '0' + nr;
+  *cp++ = '\n';
+  __libc_lseek (fd, 0, SEEK_END);
+  __libc_write (fd, s, cp - s);
+}
+
+
+static void *
+t1 (void *arg)
+{
+  pthread_cleanup_push (cleanup, (void *) (long int) 1);
+  return NULL;
+  pthread_cleanup_pop (0);
+}
+
+
+static void
+inner (int a)
+{
+  pthread_cleanup_push (cleanup, (void *) (long int) a);
+  if (a)
+    return;
+  pthread_cleanup_pop (0);
+}
+
+
+static void *
+t2 (void *arg)
+{
+  pthread_cleanup_push (cleanup, (void *) (long int) 2);
+  inner ((int) (long int) arg);
+  return NULL;
+  pthread_cleanup_pop (0);
+}
+#endif
+
+/* This does not work yet.  */
+volatile int cleanupokcnt;
+
+static void
+cleanupok (void *arg)
+{
+  ++cleanupokcnt;
+}
+
+#ifdef NOT_YET
+static void *
+t3 (void *arg)
+{
+  pthread_cleanup_push (cleanupok, (void *) (long int) 4);
+  inner ((int) (long int) arg);
+  pthread_exit (NULL);
+  pthread_cleanup_pop (0);
+}
+#endif
+
+static void
+innerok (int a)
+{
+  pthread_cleanup_push (cleanupok, (void *) (long int) a);
+  pthread_exit (NULL);
+  pthread_cleanup_pop (0);
+}
+
+
+static void *
+t4 (void *arg)
+{
+  pthread_cleanup_push (cleanupok, (void *) (long int) 6);
+  innerok ((int) (long int) arg);
+  pthread_cleanup_pop (0);
+  return NULL;
+}
+
+
+int
+main (int argc, char *argv[])
+{
+  pthread_t td;
+  int err;
+  char *tmp;
+  const char *prefix;
+  const char template[] = "thtstXXXXXX";
+  struct stat64 st;
+  int result = 0;
+
+  prefix = argc > 1 ? argv[1] : "";
+  tmp = (char *) alloca (strlen (prefix) + sizeof template);
+  strcpy (stpcpy (tmp, prefix), template);
+
+  fd = mkstemp (tmp);
+  if (fd == -1)
+    {
+      printf ("cannot create temporary file: %m");
+      exit (1);
+    }
+  unlink (tmp);
+
+  err = pthread_barrier_init (&bar, NULL, 2);
+  if (err != 0 )
+    {
+      printf ("cannot create barrier: %s\n", strerror (err));
+      exit (1);
+    }
+
+#ifdef NOT_YET
+  err = pthread_create (&td, NULL, t1, NULL);
+  if (err != 0)
+    {
+      printf ("cannot create thread t1: %s\n", strerror (err));
+      exit (1);
+    }
+
+  err = pthread_join (td, NULL);
+  if (err != 0)
+    {
+      printf ("cannot join thread: %s\n", strerror (err));
+      exit (1);
+    }
+
+  err = pthread_create (&td, NULL, t2, (void *) 3);
+  if (err != 0)
+    {
+      printf ("cannot create thread t2: %s\n", strerror (err));
+      exit (1);
+    }
+
+  err = pthread_join (td, NULL);
+  if (err != 0)
+    {
+      printf ("cannot join thread: %s\n", strerror (err));
+      exit (1);
+    }
+
+  err = pthread_create (&td, NULL, t3, (void *) 5);
+  if (err != 0)
+    {
+      printf ("cannot create thread t3: %s\n", strerror (err));
+      exit (1);
+    }
+
+  err = pthread_join (td, NULL);
+  if (err != 0)
+    {
+      printf ("cannot join thread: %s\n", strerror (err));
+      exit (1);
+    }
+#endif
+
+  err = pthread_create (&td, NULL, t4, (void *) 7);
+  if (err != 0)
+    {
+      printf ("cannot create thread t4: %s\n", strerror (err));
+      exit (1);
+    }
+
+  err = pthread_join (td, NULL);
+  if (err != 0)
+    {
+      printf ("cannot join thread: %s\n", strerror (err));
+      exit (1);
+    }
+
+  if (fstat64 (fd, &st) < 0)
+    {
+      printf ("cannot stat temporary file: %m\n");
+      result = 1;
+    }
+  else if (st.st_size != 0)
+    {
+      char buf[512];
+      puts ("some cleanup handlers ran:");
+      fflush (stdout);
+      __lseek (fd, 0, SEEK_SET);
+      while (1)
+	{
+	  ssize_t n = read (fd, buf, sizeof buf);
+	  if (n <= 0)
+	    break;
+	  write (STDOUT_FILENO, buf, n);
+	}
+      result = 1;
+    }
+
+  // if (cleanupokcnt != 3)  will be three once t3 runs
+  if (cleanupokcnt != 2)
+    {
+      printf ("cleanupokcnt = %d\n", cleanupokcnt);
+      result = 1;
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/linuxthreads/tst-cancel1.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-cancel1.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-cancel1.c	(revision 2036)
@@ -0,0 +1,150 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+static pthread_mutex_t m1 = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t m2 = PTHREAD_MUTEX_INITIALIZER;
+
+static int cntr;
+
+
+static void
+cleanup (void *arg)
+{
+  if (arg != (void *) 42l)
+    cntr = 42;
+  else
+    cntr = 1;
+}
+
+
+static void *
+tf (void *arg)
+{
+  int err;
+
+  pthread_cleanup_push (cleanup, (void *) 42l);
+
+  err = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+  if (err != 0)
+    {
+      printf ("setcanceltype failed: %s\n", strerror (err));
+      exit (1);
+    }
+
+  err = pthread_mutex_unlock (&m2);
+  if (err != 0)
+    {
+      printf ("child: mutex_unlock failed: %s\n", strerror (err));
+      exit (1);
+    }
+
+  err = pthread_mutex_lock (&m1);
+  if (err != 0)
+    {
+      printf ("child: 1st mutex_lock failed: %s\n", strerror (err));
+      exit (1);
+    }
+
+  /* We should never come here.  */
+
+  pthread_cleanup_pop (0);
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  int err;
+  pthread_t th;
+  int result = 0;
+  void *retval;
+
+  /* Get the mutexes.  */
+  err = pthread_mutex_lock (&m1);
+  if (err != 0)
+    {
+      printf ("parent: 1st mutex_lock failed: %s\n", strerror (err));
+      return 1;
+    }
+  err = pthread_mutex_lock (&m2);
+  if (err != 0)
+    {
+      printf ("parent: 2nd mutex_lock failed: %s\n", strerror (err));
+      return 1;
+    }
+
+  err = pthread_create (&th, NULL, tf, NULL);
+  if (err != 0)
+    {
+      printf ("create failed: %s\n", strerror (err));
+      return 1;
+    }
+
+  err = pthread_mutex_lock (&m2);
+  if (err != 0)
+    {
+      printf ("parent: 3rd mutex_lock failed: %s\n", strerror (err));
+      return 1;
+    }
+
+  err = pthread_cancel (th);
+  if (err != 0)
+    {
+      printf ("cancel failed: %s\n", strerror (err));
+      return 1;
+    }
+
+  err = pthread_join (th, &retval);
+  if (err != 0)
+    {
+      printf ("join failed: %s\n", strerror (err));
+      return 1;
+    }
+
+  if (retval != PTHREAD_CANCELED)
+    {
+      printf ("wrong return value: %p\n", retval);
+      result = 1;
+    }
+
+  if (cntr == 42)
+    {
+      puts ("cleanup handler called with wrong argument");
+      result = 1;
+    }
+  else if (cntr != 1)
+    {
+      puts ("cleanup handling not called");
+      result = 1;
+    }
+
+  return result;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/linuxthreads/tst-cancel2.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-cancel2.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-cancel2.c	(revision 2036)
@@ -0,0 +1,100 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+static int fd[2];
+
+
+static void *
+tf (void *arg)
+{
+  /* The buffer size must be larger than the pipe size so that the
+     write blocks.  */
+  char buf[100000];
+
+  if (write (fd[1], buf, sizeof (buf)) == sizeof (buf))
+    {
+      puts ("write succeeded");
+      return (void *) 1l;
+    }
+
+  return (void *) 42l;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t th;
+  void *r;
+  struct sigaction sa;
+
+  sa.sa_handler = SIG_IGN;
+  sigemptyset (&sa.sa_mask);
+  sa.sa_flags = 0;
+
+  if (sigaction (SIGPIPE, &sa, NULL) != 0)
+    {
+      puts ("sigaction failed");
+      return 1;
+    }
+
+  if (pipe (fd) != 0)
+    {
+      puts ("pipe failed");
+      return 1;
+    }
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      return 1;
+    }
+
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("cancel failed");
+      return 1;
+    }
+
+  /* This will cause the write in the child to return.  */
+  close (fd[0]);
+
+  if (pthread_join (th, &r) != 0)
+    {
+      puts ("join failed");
+      return 1;
+    }
+
+  if (r != PTHREAD_CANCELED)
+    {
+      printf ("result is wrong: expected %p, got %p\n", PTHREAD_CANCELED, r);
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/linuxthreads/tst-cancel3.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-cancel3.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-cancel3.c	(revision 2036)
@@ -0,0 +1,98 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+static int fd[2];
+
+
+static void *
+tf (void *arg)
+{
+  char buf[100];
+
+  if (read (fd[0], buf, sizeof (buf)) == sizeof (buf))
+    {
+      puts ("read succeeded");
+      return (void *) 1l;
+    }
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t th;
+  void *r;
+  struct sigaction sa;
+
+  sa.sa_handler = SIG_IGN;
+  sigemptyset (&sa.sa_mask);
+  sa.sa_flags = 0;
+
+  if (sigaction (SIGPIPE, &sa, NULL) != 0)
+    {
+      puts ("sigaction failed");
+      return 1;
+    }
+
+  if (pipe (fd) != 0)
+    {
+      puts ("pipe failed");
+      return 1;
+    }
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      return 1;
+    }
+
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("cancel failed");
+      return 1;
+    }
+
+  /* This will cause the read in the child to return.  */
+  close (fd[0]);
+
+  if (pthread_join (th, &r) != 0)
+    {
+      puts ("join failed");
+      return 1;
+    }
+
+  if (r != PTHREAD_CANCELED)
+    {
+      puts ("result is wrong");
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/linuxthreads/tst-cancel4.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-cancel4.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-cancel4.c	(revision 2036)
@@ -0,0 +1,469 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* NOTE: this tests functionality beyond POSIX.  POSIX does not allow
+   exit to be called more than once.  */
+
+#include <errno.h>
+#include <limits.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/poll.h>
+#include <sys/select.h>
+#include <sys/uio.h>
+#include <sys/wait.h>
+
+/* The following interfaces are defined to be cancellation points but
+   tests are not yet implemented:
+
+     accept()              aio_suspend()      clock_nanosleep()
+     close()               connect()          creat()
+     fcntl()               fsync()            getmsg()
+     getpmsg()             lockf()            mq_receive()
+     mq_send()             mq_timedreceive()  mq_timedsend()
+     msgrcv()              msgsnd()           msync()
+                           open()             pause()
+                           pread()            pthread_cond_timedwait()
+     pthread_cond_wait()   pthread_join()     pthread_testcancel()
+     putmsg()              putpmsg()          pwrite()
+                                              recv()
+     recvfrom()            recvmsg()
+     sem_timedwait()       sem_wait()         send()
+     sendmsg()             sendto()           sigpause()
+     sigsuspend()          sigtimedwait()     sigwait()
+     sigwaitinfo()                            system()
+     tcdrain()
+
+   Since STREAMS are not supported in the standard Linux kernel there
+   is no need to test the STREAMS related functions.
+*/
+
+/* Pipe descriptors.  */
+static int fds[2];
+
+/* Often used barrier for two threads.  */
+static pthread_barrier_t b2;
+
+
+static void *
+tf_read  (void *arg)
+{
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  char buf[100];
+  ssize_t s = read (fds[0], buf, sizeof (buf));
+
+  printf ("%s: read returns with %zd\n", __FUNCTION__, s);
+
+  exit (1);
+}
+
+
+static void *
+tf_readv  (void *arg)
+{
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  char buf[100];
+  struct iovec iov[1] = { [0] = { .iov_base = buf, .iov_len = sizeof (buf) } };
+  ssize_t s = readv (fds[0], iov, 1);
+
+  printf ("%s: readv returns with %zd\n", __FUNCTION__, s);
+
+  exit (1);
+}
+
+
+static void *
+tf_write  (void *arg)
+{
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  char buf[100000];
+  memset (buf, '\0', sizeof (buf));
+  ssize_t s = write (fds[1], buf, sizeof (buf));
+
+  printf ("%s: write returns with %zd\n", __FUNCTION__, s);
+
+  exit (1);
+}
+
+
+static void *
+tf_writev  (void *arg)
+{
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  char buf[100000];
+  memset (buf, '\0', sizeof (buf));
+  struct iovec iov[1] = { [0] = { .iov_base = buf, .iov_len = sizeof (buf) } };
+  ssize_t s = writev (fds[1], iov, 1);
+
+  printf ("%s: writev returns with %zd\n", __FUNCTION__, s);
+
+  exit (1);
+}
+
+
+static void *
+tf_sleep (void *arg)
+{
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  sleep (1000000);
+
+  printf ("%s: sleep returns\n", __FUNCTION__);
+
+  exit (1);
+}
+
+
+static void *
+tf_usleep (void *arg)
+{
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  usleep ((useconds_t) ULONG_MAX);
+
+  printf ("%s: usleep returns\n", __FUNCTION__);
+
+  exit (1);
+}
+
+
+static void *
+tf_nanosleep (void *arg)
+{
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  struct timespec ts = { .tv_sec = 10000000, .tv_nsec = 0 };
+  while (nanosleep (&ts, &ts) != 0)
+    continue;
+
+  printf ("%s: nanosleep returns\n", __FUNCTION__);
+
+  exit (1);
+}
+
+
+static void *
+tf_select (void *arg)
+{
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  fd_set rfs;
+  FD_ZERO (&rfs);
+  FD_SET (fds[0], &rfs);
+
+  int s = select (fds[0] + 1, &rfs, NULL, NULL, NULL);
+
+  printf ("%s: select returns with %d (%s)\n", __FUNCTION__, s,
+	  strerror (errno));
+
+  exit (1);
+}
+
+
+static void *
+tf_pselect (void *arg)
+{
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  fd_set rfs;
+  FD_ZERO (&rfs);
+  FD_SET (fds[0], &rfs);
+
+  int s = pselect (fds[0] + 1, &rfs, NULL, NULL, NULL, NULL);
+
+  printf ("%s: pselect returns with %d (%s)\n", __FUNCTION__, s,
+	  strerror (errno));
+
+  exit (1);
+}
+
+
+static void *
+tf_poll (void *arg)
+{
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  struct pollfd rfs[1] = { [0] = { .fd = fds[0], .events = POLLIN } };
+
+  int s = poll (rfs, 1, -1);
+
+  printf ("%s: poll returns with %d (%s)\n", __FUNCTION__, s,
+	  strerror (errno));
+
+  exit (1);
+}
+
+
+static void *
+tf_wait (void *arg)
+{
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  pid_t pid = fork ();
+  if (pid == -1)
+    {
+      puts ("fork failed");
+      exit (1);
+    }
+
+  if (pid == 0)
+    {
+      /* Make the program disappear after a while.  */
+      sleep (10);
+      exit (0);
+    }
+
+  int s = wait (NULL);
+
+  printf ("%s: wait returns with %d (%s)\n", __FUNCTION__, s,
+	  strerror (errno));
+
+  exit (1);
+}
+
+
+static void *
+tf_waitpid (void *arg)
+{
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  pid_t pid = fork ();
+  if (pid == -1)
+    {
+      puts ("fork failed");
+      exit (1);
+    }
+
+  if (pid == 0)
+    {
+      /* Make the program disappear after a while.  */
+      sleep (10);
+      exit (0);
+    }
+
+  int s = waitpid (-1, NULL, 0);
+
+  printf ("%s: waitpid returns with %d (%s)\n", __FUNCTION__, s,
+	  strerror (errno));
+
+  exit (1);
+}
+
+
+static void *
+tf_waitid (void *arg)
+{
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  pid_t pid = fork ();
+  if (pid == -1)
+    {
+      puts ("fork failed");
+      exit (1);
+    }
+
+  if (pid == 0)
+    {
+      /* Make the program disappear after a while.  */
+      sleep (10);
+      exit (0);
+    }
+
+#ifndef WEXITED
+# define WEXITED 0
+#endif
+  siginfo_t si;
+  int s = waitid (P_PID, pid, &si, WEXITED);
+
+  printf ("%s: waitid returns with %d (%s)\n", __FUNCTION__, s,
+	  strerror (errno));
+
+  exit (1);
+}
+
+
+static struct
+{
+  void *(*tf) (void *);
+  int nb;
+} tests[] =
+{
+  { tf_read, 2 },
+  { tf_readv, 2 },
+  { tf_select, 2 },
+  { tf_pselect, 2 },
+  { tf_poll, 2 },
+  { tf_write, 2 },
+  { tf_writev, 2},
+  { tf_sleep, 2 },
+  { tf_usleep, 2 },
+  { tf_nanosleep, 2 },
+  { tf_wait, 2 },
+  { tf_waitid, 2 },
+  { tf_waitpid, 2 },
+};
+#define ntest_tf (sizeof (tests) / sizeof (tests[0]))
+
+
+static int
+do_test (void)
+{
+  if (pipe (fds) != 0)
+    {
+      puts ("pipe failed");
+      exit (1);
+    }
+
+  int cnt;
+  for (cnt = 0; cnt < ntest_tf; ++cnt)
+    {
+      printf ("round %d\n", cnt);
+
+      if (pthread_barrier_init (&b2, NULL, tests[cnt].nb) != 0)
+	{
+	  puts ("b2 init failed");
+	  exit (1);
+	}
+
+      pthread_t th;
+      if (pthread_create (&th, NULL, tests[cnt].tf, NULL) != 0)
+	{
+	  printf ("create for round %d test failed\n", cnt);
+	  exit (1);
+	}
+
+      puts ("barrier waits");
+
+      int r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+
+      puts ("nanosleep delay");
+
+      struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 };
+      while (nanosleep (&ts, &ts) != 0)
+	continue;
+
+      if (pthread_cancel (th) != 0)
+	{
+	  printf ("cancel in round %d failed\n", cnt);
+	  exit (1);
+	}
+
+      void *status;
+      if (pthread_join (th, &status) != 0)
+	{
+	  printf ("join in round %d failed\n", cnt);
+	  exit (1);
+	}
+      if (status != PTHREAD_CANCELED)
+	{
+	  printf ("thread in round %d not canceled\n", cnt);
+	  exit (1);
+	}
+      printf ("test %d successful\n", cnt);
+
+      if (pthread_barrier_destroy (&b2) != 0)
+	{
+	  puts ("barrier_destroy failed");
+	  exit (1);
+	}
+    }
+
+  return 0;
+}
+
+#define TIMEOUT 60
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/linuxthreads/tst-cancel5.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-cancel5.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-cancel5.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cancel4.c"
Index: trunk/src/libctests/glibc/linuxthreads/tst-cancel6.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-cancel6.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-cancel6.c	(revision 2036)
@@ -0,0 +1,79 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static void *
+tf (void *arg)
+{
+  char buf[100];
+  fgets (buf, sizeof (buf), arg);
+  /* This call should never return.  */
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  int fd[2];
+  if (pipe (fd) != 0)
+    {
+      puts ("pipe failed");
+      return 1;
+    }
+
+  FILE *fp = fdopen (fd[0], "r");
+  if (fp == NULL)
+    {
+      puts ("fdopen failed");
+      return 1;
+    }
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, fp) != 0)
+    {
+      puts ("pthread_create failed");
+      return 1;
+    }
+
+  sleep (1);
+
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("pthread_cancel failed");
+      return 1;
+    }
+
+  void *r;
+  if (pthread_join (th, &r) != 0)
+    {
+      puts ("pthread_join failed");
+      return 1;
+    }
+
+  return r != PTHREAD_CANCELED;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/linuxthreads/tst-cancel7.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-cancel7.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-cancel7.c	(revision 2036)
@@ -0,0 +1,111 @@
+/* Test for pthread cancellation of mutex blocks.
+   Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+pthread_barrier_t b;
+int value = 0;
+
+static void *
+tf (void *arg)
+{
+  int r = pthread_barrier_wait (&b);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  pthread_mutex_lock (&lock);
+  ++value;
+  pthread_testcancel ();
+  ++value;
+  pthread_mutex_unlock (&lock);
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_mutex_lock (&lock);
+
+  if (pthread_barrier_init (&b, NULL, 2) != 0)
+    {
+      puts ("barrier init failed");
+      return 1;
+    }
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("pthread_create failed");
+      return 1;
+    }
+
+  int r = pthread_barrier_wait (&b);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("pthread_cancel failed");
+      return 1;
+    }
+
+  pthread_mutex_unlock (&lock);
+
+  void *status;
+  if (pthread_join (th, &status) != 0)
+    {
+      puts ("join failed");
+      return 1;
+    }
+
+  if (status != PTHREAD_CANCELED)
+    {
+      puts ("thread not canceled");
+      return 1;
+    }
+
+  if (value == 0)
+    {
+      puts ("thread cancelled in the pthread_mutex_lock call");
+      return 1;
+    }
+
+  if (value != 1)
+    {
+      puts ("thread not cancelled in pthread_testcancel call");
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/linuxthreads/tst-cancel8.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-cancel8.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-cancel8.c	(revision 2036)
@@ -0,0 +1,287 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <error.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/select.h>
+#include <sys/time.h>
+#include <unistd.h>
+
+static void *
+tf (void *arg)
+{
+  return NULL;
+}
+
+static void
+handler (int sig)
+{
+}
+
+static void __attribute__ ((noinline))
+clobber_lots_of_regs (void)
+{
+#define X1(n) long r##n = 10##n; __asm __volatile ("" : "+r" (r##n));
+#define X2(n) X1(n##0) X1(n##1) X1(n##2) X1(n##3) X1(n##4)
+#define X3(n) X2(n##0) X2(n##1) X2(n##2) X2(n##3) X2(n##4)
+  X3(0) X3(1) X3(2) X3(3) X3(4)
+#undef X1
+#define X1(n) __asm __volatile ("" : : "r" (r##n));
+  X3(0) X3(1) X3(2) X3(3) X3(4)
+#undef X1
+#undef X2
+#undef X3
+}
+
+static int
+do_test (void)
+{
+  pthread_t th;
+  int old, rc;
+  int ret = 0;
+  int fd[2];
+
+  rc = pipe (fd);
+  if (rc < 0)
+    error (EXIT_FAILURE, errno, "couldn't create pipe");
+
+  rc = pthread_create (&th, NULL, tf, NULL);
+  if (rc)
+    error (EXIT_FAILURE, rc, "couldn't create thread");
+
+  rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old);
+  if (rc)
+    {
+      error (0, rc, "1st pthread_setcanceltype failed");
+      ret = 1;
+    }
+  if (old != PTHREAD_CANCEL_DEFERRED && old != PTHREAD_CANCEL_ASYNCHRONOUS)
+    {
+      error (0, 0, "1st pthread_setcanceltype returned invalid value %d",
+	     old);
+      ret = 1;
+    }
+
+  clobber_lots_of_regs ();
+  close (fd[0]);
+
+  rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old);
+  if (rc)
+    {
+      error (0, rc, "pthread_setcanceltype after close failed");
+      ret = 1;
+    }
+  if (old != PTHREAD_CANCEL_DEFERRED)
+    {
+      error (0, 0, "pthread_setcanceltype after close returned invalid value %d",
+	     old);
+      ret = 1;
+    }
+
+  clobber_lots_of_regs ();
+  close (fd[1]);
+
+  rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old);
+  if (rc)
+    {
+      error (0, rc, "pthread_setcanceltype after 2nd close failed");
+      ret = 1;
+    }
+  if (old != PTHREAD_CANCEL_ASYNCHRONOUS)
+    {
+      error (0, 0, "pthread_setcanceltype after 2nd close returned invalid value %d",
+	     old);
+      ret = 1;
+    }
+
+  struct sigaction sa = { .sa_handler = handler, .sa_flags = 0 };
+  sigemptyset (&sa.sa_mask);
+  sigaction (SIGALRM, &sa, NULL);
+
+  struct itimerval it;
+  it.it_value.tv_sec = 1;
+  it.it_value.tv_usec = 0;
+  it.it_interval = it.it_value;
+  setitimer (ITIMER_REAL, &it, NULL);
+
+  clobber_lots_of_regs ();
+  pause ();
+
+  memset (&it, 0, sizeof (it));
+  setitimer (ITIMER_REAL, &it, NULL);
+
+  rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old);
+  if (rc)
+    {
+      error (0, rc, "pthread_setcanceltype after pause failed");
+      ret = 1;
+    }
+  if (old != PTHREAD_CANCEL_DEFERRED)
+    {
+      error (0, 0, "pthread_setcanceltype after pause returned invalid value %d",
+	     old);
+      ret = 1;
+    }
+
+  it.it_value.tv_sec = 1;
+  it.it_value.tv_usec = 0;
+  it.it_interval = it.it_value;
+  setitimer (ITIMER_REAL, &it, NULL);
+
+  clobber_lots_of_regs ();
+  pause ();
+
+  memset (&it, 0, sizeof (it));
+  setitimer (ITIMER_REAL, &it, NULL);
+
+  rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old);
+  if (rc)
+    {
+      error (0, rc, "pthread_setcanceltype after 2nd pause failed");
+      ret = 1;
+    }
+  if (old != PTHREAD_CANCEL_ASYNCHRONOUS)
+    {
+      error (0, 0, "pthread_setcanceltype after 2nd pause returned invalid value %d",
+	     old);
+      ret = 1;
+    }
+
+  char fname[] = "/tmp/tst-lt-cancel8-dir-XXXXXX\0foo/bar";
+  char *enddir = strchr (fname, '\0');
+  if (mkdtemp (fname) == NULL)
+    {
+      error (0, errno, "mkdtemp failed");
+      ret = 1;
+    }
+  *enddir = '/';
+
+  clobber_lots_of_regs ();
+  creat (fname, 0400);
+
+  rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old);
+  if (rc)
+    {
+      error (0, rc, "pthread_setcanceltype after creat failed");
+      ret = 1;
+    }
+  if (old != PTHREAD_CANCEL_DEFERRED)
+    {
+      error (0, 0, "pthread_setcanceltype after creat returned invalid value %d",
+	     old);
+      ret = 1;
+    }
+
+  clobber_lots_of_regs ();
+  creat (fname, 0400);
+
+  rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old);
+  if (rc)
+    {
+      error (0, rc, "pthread_setcanceltype after 2nd creat failed");
+      ret = 1;
+    }
+  if (old != PTHREAD_CANCEL_ASYNCHRONOUS)
+    {
+      error (0, 0, "pthread_setcanceltype after 2nd creat returned invalid value %d",
+	     old);
+      ret = 1;
+    }
+
+  clobber_lots_of_regs ();
+  open (fname, O_CREAT, 0400);
+
+  rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old);
+  if (rc)
+    {
+      error (0, rc, "pthread_setcanceltype after open failed");
+      ret = 1;
+    }
+  if (old != PTHREAD_CANCEL_DEFERRED)
+    {
+      error (0, 0, "pthread_setcanceltype after open returned invalid value %d",
+	     old);
+      ret = 1;
+    }
+
+  clobber_lots_of_regs ();
+  open (fname, O_CREAT, 0400);
+
+  rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old);
+  if (rc)
+    {
+      error (0, rc, "pthread_setcanceltype after 2nd open failed");
+      ret = 1;
+    }
+  if (old != PTHREAD_CANCEL_ASYNCHRONOUS)
+    {
+      error (0, 0, "pthread_setcanceltype after 2nd open returned invalid value %d",
+	     old);
+      ret = 1;
+    }
+
+  *enddir = '\0';
+  rmdir (fname);
+
+  clobber_lots_of_regs ();
+  select (-1, NULL, NULL, NULL, NULL);
+
+  rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old);
+  if (rc)
+    {
+      error (0, rc, "pthread_setcanceltype after select failed");
+      ret = 1;
+    }
+  if (old != PTHREAD_CANCEL_DEFERRED)
+    {
+      error (0, 0, "pthread_setcanceltype after select returned invalid value %d",
+	     old);
+      ret = 1;
+    }
+
+  clobber_lots_of_regs ();
+  select (-1, NULL, NULL, NULL, NULL);
+
+  rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old);
+  if (rc)
+    {
+      error (0, rc, "pthread_setcanceltype after 2nd select failed");
+      ret = 1;
+    }
+  if (old != PTHREAD_CANCEL_ASYNCHRONOUS)
+    {
+      error (0, 0, "pthread_setcanceltype after 2nd select returned invalid value %d",
+	     old);
+      ret = 1;
+    }
+
+  pthread_join (th, NULL);
+
+  return ret;
+}
+
+#define TIMEOUT 20
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/linuxthreads/tst-clock1.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-clock1.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-clock1.c	(revision 2036)
@@ -0,0 +1,202 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+
+
+#if defined _POSIX_THREAD_CPUTIME && _POSIX_THREAD_CPUTIME >= 0
+static pthread_barrier_t b2;
+static pthread_barrier_t bN;
+
+
+static void *
+tf (void *arg)
+{
+  int e = pthread_barrier_wait (&b2);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      exit (1);
+    }
+
+  e = pthread_barrier_wait (&bN);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      exit (1);
+    }
+
+  return NULL;
+}
+#endif
+
+
+int
+do_test (void)
+{
+#if defined _POSIX_THREAD_CPUTIME && _POSIX_THREAD_CPUTIME >= 0
+# define N 10
+
+# if _POSIX_THREAD_CPUTIME == 0
+  if (sysconf (_SC_THREAD_CPUTIME) < 0)
+    {
+      puts ("_POSIX_THREAD_CPUTIME option not available");
+      return 0;
+    }
+# endif
+
+  if (pthread_barrier_init (&b2, NULL, 2) != 0
+      || pthread_barrier_init (&bN, NULL, N + 1) != 0)
+    {
+      puts ("barrier_init failed");
+      return 1;
+    }
+
+  struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 };
+  TEMP_FAILURE_RETRY (nanosleep (&ts, &ts));
+
+  pthread_t th[N + 1];
+  clockid_t cl[N + 1];
+# ifndef CLOCK_THREAD_CPUTIME_ID
+  if (pthread_getcpuclockid (pthread_self (), &cl[0]) != 0)
+    {
+      puts ("own pthread_getcpuclockid failed");
+      return 1;
+    }
+# else
+  cl[0] = CLOCK_THREAD_CPUTIME_ID;
+# endif
+
+  pthread_attr_t at;
+
+  if (pthread_attr_init (&at) != 0)
+    {
+      puts ("attr_init failed");
+      return 1;
+    }
+
+  if (pthread_attr_setstacksize (&at, 1 * 1024 * 1024) != 0)
+    {
+      puts ("attr_setstacksize failed");
+      return 1;
+    }
+
+  int i;
+  int e;
+  for (i = 0; i < N; ++i)
+    {
+      if (pthread_create (&th[i], &at, tf, NULL) != 0)
+	{
+	  puts ("create failed");
+	  return 1;
+	}
+
+      e = pthread_barrier_wait (&b2);
+      if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  puts ("barrier_wait failed");
+	  return 1;
+	}
+
+      ts.tv_sec = 0;
+      ts.tv_nsec = 100000000;
+      TEMP_FAILURE_RETRY (nanosleep (&ts, &ts));
+
+      if (pthread_getcpuclockid (th[i], &cl[i + 1]) != 0)
+	{
+	  puts ("pthread_getcpuclockid failed");
+	  return 1;
+	}
+    }
+
+  if (pthread_attr_destroy (&at) != 0)
+    {
+      puts ("attr_destroy failed");
+      return 1;
+    }
+
+  struct timespec t[N + 1];
+  for (i = 0; i < N + 1; ++i)
+    if (clock_gettime (cl[i], &t[i]) != 0)
+      {
+	printf ("clock_gettime round %d failed\n", i);
+	return 1;
+      }
+
+  for (i = 0; i < N; ++i)
+    {
+      struct timespec diff;
+
+      diff.tv_sec = t[i].tv_sec - t[i + 1].tv_sec;
+      diff.tv_nsec = t[i].tv_nsec - t[i + 1].tv_nsec;
+      if (diff.tv_nsec < 0)
+	{
+	  diff.tv_nsec += 1000000000;
+	  --diff.tv_sec;
+	}
+
+      if (diff.tv_sec < 0 || (diff.tv_sec == 0 && diff.tv_nsec < 100000000))
+	{
+	  printf ("\
+difference between thread %d and %d too small (%ld.%09ld)\n",
+		  i, i + 1, (long int) diff.tv_sec, (long int) diff.tv_nsec);
+	  return 1;
+	}
+
+      printf ("diff %d->%d: %ld.%09ld\n",
+	      i, i + 1, (long int) diff.tv_sec, (long int) diff.tv_nsec);
+    }
+
+  ts.tv_sec = 0;
+  ts.tv_nsec = 0;
+  for (i = 0; i < N + 1; ++i)
+    if (clock_settime (cl[i], &ts) != 0)
+      {
+	printf ("clock_settime(%d) round %d failed\n", cl[i], i);
+	return 1;
+      }
+
+  for (i = 0; i < N + 1; ++i)
+    {
+      if (clock_gettime (cl[i], &ts) != 0)
+	{
+	  puts ("clock_gettime failed");
+	  return 1;
+	}
+
+      if (ts.tv_sec > t[i].tv_sec
+	  || (ts.tv_sec == t[i].tv_sec && ts.tv_nsec > t[i].tv_nsec))
+	{
+	  puts ("clock_settime didn't reset clock");
+	  return 1;
+	}
+    }
+#endif
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/linuxthreads/tst-context.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-context.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-context.c	(revision 2036)
@@ -0,0 +1,116 @@
+/* Ack, a hack!  We need to get the proper definition, or lack thereof,
+   for FLOATING_STACKS.  But when !IS_IN_libpthread, this can get defined
+   incidentally by <tls.h>.  So kludge around it.  */
+
+#define IS_IN_libpthread
+#include <tls.h>
+#undef IS_IN_libpthread
+#undef USE___THREAD
+
+#include <errno.h>
+#include <error.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <ucontext.h>
+
+
+#define N	4
+
+#ifdef FLOATING_STACKS
+static char stacks[N][8192];
+static ucontext_t ctx[N][2];
+static volatile int failures;
+
+static void
+fct (long int n)
+{
+  /* Just to use the thread local descriptor.  */
+  printf ("%ld: in %s now\n", n, __FUNCTION__);
+  errno = 0;
+}
+
+static void *
+threadfct (void *arg)
+{
+  int n = (int) (long int) arg;
+
+  if (getcontext (&ctx[n][1]) != 0)
+    {
+      printf ("%d: cannot get context: %m\n", n);
+      exit (1);
+    }
+
+  printf ("%d: %s: before makecontext\n", n, __FUNCTION__);
+
+  ctx[n][1].uc_stack.ss_sp = stacks[n];
+  ctx[n][1].uc_stack.ss_size = 8192;
+  ctx[n][1].uc_link = &ctx[n][0];
+  makecontext (&ctx[n][1], (void (*) (void)) fct, 1, (long int) n);
+
+  printf ("%d: %s: before swapcontext\n", n, __FUNCTION__);
+
+  if (swapcontext (&ctx[n][0], &ctx[n][1]) != 0)
+    {
+      ++failures;
+      printf ("%d: %s: swapcontext failed\n", n, __FUNCTION__);
+    }
+  else
+    printf ("%d: back in %s\n", n, __FUNCTION__);
+
+  return NULL;
+}
+#endif
+
+
+#ifdef FLOATING_STACKS
+static volatile int global;
+#endif
+
+int
+main (void)
+{
+#ifndef FLOATING_STACKS
+  puts ("not supported");
+  return 0;
+#else
+  int n;
+  pthread_t th[N];
+  ucontext_t mctx;
+
+  puts ("making contexts");
+  if (getcontext (&mctx) != 0)
+    {
+      if (errno == ENOSYS)
+	{
+	  puts ("context handling not supported");
+	  exit (0);
+	}
+
+      printf ("%s: getcontext: %m\n", __FUNCTION__);
+      exit (1);
+    }
+
+  /* Play some tricks with this context.  */
+  if (++global == 1)
+    if (setcontext (&mctx) != 0)
+      {
+	printf ("%s: setcontext: %m\n", __FUNCTION__);
+	exit (1);
+      }
+  if (global != 2)
+    {
+      printf ("%s: 'global' not incremented twice\n", __FUNCTION__);
+      exit (1);
+    }
+
+  for (n = 0; n < N; ++n)
+    if (pthread_create (&th[n], NULL, threadfct, (void *) (long int) n) != 0)
+      error (EXIT_FAILURE, errno, "cannot create all threads");
+
+  for (n = 0; n < N; ++n)
+    pthread_join (th[n], NULL);
+
+  return failures;
+#endif
+}
Index: trunk/src/libctests/glibc/linuxthreads/tst-popen.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-popen.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-popen.c	(revision 2036)
@@ -0,0 +1,37 @@
+#include <errno.h>
+#include <error.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+static void *
+dummy (void *x)
+{
+  return NULL;
+}
+
+static char buf[sizeof "something\n"];
+
+static int
+do_test (void)
+{
+  FILE *f;
+  pthread_t p;
+
+  pthread_create (&p, NULL, dummy, NULL);
+  f = popen ("echo something", "r");
+  if (f == NULL)
+    error (EXIT_FAILURE, errno, "popen failed");
+  if (fgets (buf, sizeof (buf), f) == NULL)
+    error (EXIT_FAILURE, 0, "fgets failed");
+  if (strcmp (buf, "something\n"))
+    error (EXIT_FAILURE, 0, "read wrong data");
+  if (pclose (f))
+    error (EXIT_FAILURE, errno, "pclose returned non-zero");
+  exit (0);
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/linuxthreads/tst-popen2.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-popen2.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-popen2.c	(revision 2036)
@@ -0,0 +1,41 @@
+#include <errno.h>
+#include <error.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+static void *
+dummy (void *x)
+{
+  return NULL;
+}
+
+static char buf[sizeof "something\n"];
+
+static int
+do_test (void)
+{
+  FILE *f;
+  pthread_t p;
+  int err;
+
+  f = popen ("echo something", "r");
+  if (f == NULL)
+    error (EXIT_FAILURE, errno, "popen failed");
+  if (fgets (buf, sizeof (buf), f) == NULL)
+    error (EXIT_FAILURE, 0, "fgets failed");
+  if (strcmp (buf, "something\n"))
+    error (EXIT_FAILURE, 0, "read wrong data");
+  if (pclose (f))
+    error (EXIT_FAILURE, errno, "pclose returned non-zero");
+  if ((err = pthread_create (&p, NULL, dummy, NULL)))
+    error (EXIT_FAILURE, err, "pthread_create failed");
+  if ((err = pthread_join (p, NULL)))
+    error (EXIT_FAILURE, err, "pthread_join failed");
+  exit (0);
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/linuxthreads/tst-signal.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-signal.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-signal.c	(revision 2036)
@@ -0,0 +1,64 @@
+/* Test sigaction wrapper.  */
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Schwab <schwab@suse.de>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+
+int
+main (int argc, char *argv[])
+{
+  struct sigaction old_sa, new_sa;
+
+  if (sigaction (SIGHUP, NULL, &old_sa) < 0)
+    {
+      printf ("cannot get signal action for SIGHUP: %m\n");
+      exit (1);
+    }
+
+  if (old_sa.sa_handler != SIG_IGN)
+    {
+      printf ("SIGHUP action should be SIG_IGN, is %p\n",
+	      (void *) old_sa.sa_handler);
+      exit (1);
+    }
+
+  new_sa.sa_handler = SIG_DFL;
+  if (sigaction (SIGHUP, &new_sa, NULL) < 0)
+    {
+      printf ("cannot set signal action for SIGHUP: %m\n");
+      exit (1);
+    }
+
+  if (sigaction (SIGHUP, NULL, &old_sa) < 0)
+    {
+      printf ("cannot get signal action for SIGHUP: %m\n");
+      exit (1);
+    }
+
+  if (old_sa.sa_handler != SIG_DFL)
+    {
+      printf ("SIGHUP action should be SIG_DFL, is %p\n",
+	      (void *) old_sa.sa_handler);
+      exit (1);
+    }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/linuxthreads/tst-signal.sh
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-signal.sh	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-signal.sh	(revision 2036)
@@ -0,0 +1,28 @@
+#! /bin/sh
+# Testing the sigaction wrapper.
+# Copyright (C) 2002 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+common_objpfx=$1; shift
+
+# set up to ignore SIGHUP
+trap '' 1
+
+exec ${common_objpfx}elf/ld.so --library-path $common_objpfx:${common_objpfx}linuxthreads \
+     ${common_objpfx}linuxthreads/tst-signal
Index: trunk/src/libctests/glibc/linuxthreads/tst-stack1.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-stack1.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-stack1.c	(revision 2036)
@@ -0,0 +1,97 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* Test pthread_create/pthread_join with user defined stacks.  */
+
+#include <limits.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+static int seen;
+
+static void *
+tf (void *p)
+{
+  ++seen;
+  return NULL;
+}
+
+#define N 16
+
+static int
+do_test (void)
+{
+  void *stack;
+  int res = posix_memalign (&stack, getpagesize (), N * 4 * PTHREAD_STACK_MIN);
+  if (res)
+    {
+      printf ("malloc failed %s\n", strerror (res));
+      return 1;
+    }
+
+  pthread_attr_t attr;
+  pthread_attr_init (&attr);
+
+  int result = 0;
+  for (int i = 0; i < N; ++i)
+    {
+      res = pthread_attr_setstack (&attr, stack + i * 4 * PTHREAD_STACK_MIN,
+				   4 * PTHREAD_STACK_MIN);
+      if (res)
+	{
+	  printf ("pthread_attr_setstack failed %d\n", res);
+	  result = 1;
+	  continue;
+	}
+
+      /* Create the thread.  */
+      pthread_t th;
+      res = pthread_create (&th, &attr, tf, NULL);
+      if (res)
+	{
+	  printf ("pthread_create failed %d\n", res);
+	  result = 1;
+	}
+      else
+	{
+	  res = pthread_join (th, NULL);
+	  if (res)
+	    {
+	      printf ("pthread_join failed %d\n", res);
+	      result = 1;
+	    }
+	}
+    }
+
+  pthread_attr_destroy (&attr);
+
+  if (seen != N)
+    {
+      printf ("seen %d != %d\n", seen, N);
+      result = 1;
+    }
+
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/linuxthreads/tst-static-locale.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-static-locale.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-static-locale.c	(revision 2036)
@@ -0,0 +1,13 @@
+/* Test that the thread-local locale works right in the main thread
+   when statically linked.  */
+
+#include "../locale/tst-C-locale.c"
+
+#include <pthread.h>
+
+/* This is never called, just here to get pthreads linked in.  */
+void
+useless (void)
+{
+  pthread_create (0, 0, 0, 0);
+}
Index: trunk/src/libctests/glibc/linuxthreads/tst-tls1.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-tls1.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-tls1.c	(revision 2036)
@@ -0,0 +1,91 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* Check alignment, overlapping and layout of TLS variables.  */
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/param.h>
+
+#include "tst-tls1.h"
+
+#ifdef TLS_REGISTER
+
+struct tls_obj tls_registry[64];
+
+static int
+tls_addr_cmp (const void *a, const void *b)
+{
+  if (((struct tls_obj *)a)->addr < ((struct tls_obj *)b)->addr)
+    return -1;
+  if (((struct tls_obj *)a)->addr > ((struct tls_obj *)b)->addr)
+    return 1;
+  return 0;
+}
+
+static int
+do_test (void)
+{
+  size_t cnt, i;
+  int res = 0;
+  uintptr_t min_addr = ~(uintptr_t) 0, max_addr = 0;
+
+  for (cnt = 0; tls_registry[cnt].name; ++cnt);
+
+  qsort (tls_registry, cnt, sizeof (struct tls_obj), tls_addr_cmp);
+
+  for (i = 0; i < cnt; ++i)
+    {
+      printf ("%s = %p, size %zd, align %zd",
+	      tls_registry[i].name, (void *) tls_registry[i].addr,
+	      tls_registry[i].size, tls_registry[i].align);
+      if (tls_registry[i].addr & (tls_registry[i].align - 1))
+	{
+	  fputs (", WRONG ALIGNMENT", stdout);
+	  res = 1;
+	}
+      if (i > 0
+	  && (tls_registry[i - 1].addr + tls_registry[i - 1].size
+	      > tls_registry[i].addr))
+	{
+	  fputs (", ADDRESS OVERLAP", stdout);
+	  res = 1;
+	}
+      puts ("");
+      min_addr = MIN (tls_registry[i].addr, min_addr);
+      max_addr = MAX (tls_registry[i].addr + tls_registry[i].size,
+		      max_addr);
+    }
+
+  if (cnt > 1)
+    printf ("Initial TLS used block size %zd\n",
+	    (size_t) (max_addr - min_addr));
+  return res;
+}
+
+#define TEST_FUNCTION do_test ()
+
+#else
+
+#define TEST_FUNCTION 0
+
+#endif
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/linuxthreads/tst-tls1.h
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-tls1.h	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-tls1.h	(revision 2036)
@@ -0,0 +1,28 @@
+#include <stdint.h>
+#include <stdlib.h>
+#include <tls.h>
+
+#if USE_TLS && HAVE___THREAD
+
+struct tls_obj
+{
+  const char *name;
+  uintptr_t addr;
+  size_t size;
+  size_t align;
+};
+extern struct tls_obj tls_registry[];
+
+#define TLS_REGISTER(x)				\
+static void __attribute__((constructor))	\
+tls_register_##x (void)				\
+{						\
+  size_t i;					\
+  for (i = 0; tls_registry[i].name; ++i);	\
+  tls_registry[i].name = #x;			\
+  tls_registry[i].addr = (uintptr_t) &x;	\
+  tls_registry[i].size = sizeof (x);		\
+  tls_registry[i].align = __alignof__ (x);	\
+}
+
+#endif
Index: trunk/src/libctests/glibc/linuxthreads/tst-tls1mod.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-tls1mod.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-tls1mod.c	(revision 2036)
@@ -0,0 +1,6 @@
+#include <tst-tls1.h>
+
+#ifdef TLS_REGISTER
+/* Ensure tls_registry is exported from the binary.  */
+void *tst_tls1mod attribute_hidden = tls_registry;
+#endif
Index: trunk/src/libctests/glibc/linuxthreads/tst-tls1moda.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-tls1moda.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-tls1moda.c	(revision 2036)
@@ -0,0 +1,6 @@
+#include <tst-tls1.h>
+
+#ifdef TLS_REGISTER
+static __thread char a [32] __attribute__ ((aligned (64)));
+TLS_REGISTER (a)
+#endif
Index: trunk/src/libctests/glibc/linuxthreads/tst-tls1modb.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-tls1modb.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-tls1modb.c	(revision 2036)
@@ -0,0 +1,6 @@
+#include <tst-tls1.h>
+
+#ifdef TLS_REGISTER
+static __thread int b;
+TLS_REGISTER (b)
+#endif
Index: trunk/src/libctests/glibc/linuxthreads/tst-tls1modc.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-tls1modc.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-tls1modc.c	(revision 2036)
@@ -0,0 +1,6 @@
+#include <tst-tls1.h>
+
+#ifdef TLS_REGISTER
+static __thread int c;
+TLS_REGISTER (c)
+#endif
Index: trunk/src/libctests/glibc/linuxthreads/tst-tls1modd.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-tls1modd.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-tls1modd.c	(revision 2036)
@@ -0,0 +1,6 @@
+#include <tst-tls1.h>
+
+#ifdef TLS_REGISTER
+static __thread int d;
+TLS_REGISTER (d)
+#endif
Index: trunk/src/libctests/glibc/linuxthreads/tst-tls1mode.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-tls1mode.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-tls1mode.c	(revision 2036)
@@ -0,0 +1,8 @@
+#include <tst-tls1.h>
+
+#ifdef TLS_REGISTER
+static __thread int e1 = 24;
+static __thread char e2 [32] __attribute__ ((aligned (64)));
+TLS_REGISTER (e1)
+TLS_REGISTER (e2)
+#endif
Index: trunk/src/libctests/glibc/linuxthreads/tst-tls1modf.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-tls1modf.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-tls1modf.c	(revision 2036)
@@ -0,0 +1,9 @@
+#include <tst-tls1.h>
+
+#ifdef TLS_REGISTER
+char tst_tls1modf[60] attribute_hidden = { 26 };
+static __thread int f1 = 24;
+static __thread char f2 [32] __attribute__ ((aligned (64)));
+TLS_REGISTER (f1)
+TLS_REGISTER (f2)
+#endif
Index: trunk/src/libctests/glibc/linuxthreads/tst-tls2.sh
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-tls2.sh	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-tls2.sh	(revision 2036)
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+common_objpfx=$1; shift
+elf_objpfx=$1; shift
+rtld_installed_name=$1; shift
+logfile=$common_objpfx/linuxthreads/tst-tls2.out
+
+# We have to find libc and linuxthreads
+library_path=${common_objpfx}:${common_objpfx}linuxthreads
+tst_tls1="${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+	  ${common_objpfx}/linuxthreads/tst-tls1"
+
+LC_ALL=C
+export LC_ALL
+LANG=C
+export LANG
+
+> $logfile
+fail=0
+
+for aligned in a e f; do
+  echo "preload tst-tls1mod{$aligned,b,c,d}.so" >> $logfile
+  echo "===============" >> $logfile
+  LD_PRELOAD=`echo ${common_objpfx}linuxthreads/tst-tls1mod{$aligned,b,c,d}.so \
+	      | sed 's/:$//;s/: /:/g'` ${tst_tls1} >> $logfile || fail=1
+  echo >> $logfile
+
+  echo "preload tst-tls1mod{b,$aligned,c,d}.so" >> $logfile
+  echo "===============" >> $logfile
+  LD_PRELOAD=`echo ${common_objpfx}linuxthreads/tst-tls1mod{b,$aligned,c,d}.so \
+	      | sed 's/:$//;s/: /:/g'` ${tst_tls1} >> $logfile || fail=1
+  echo >> $logfile
+
+  echo "preload tst-tls1mod{b,c,d,$aligned}.so" >> $logfile
+  echo "===============" >> $logfile
+  LD_PRELOAD=`echo ${common_objpfx}linuxthreads/tst-tls1mod{b,c,d,$aligned}.so \
+	      | sed 's/:$//;s/: /:/g'` ${tst_tls1} >> $logfile || fail=1
+  echo >> $logfile
+done
+
+echo "preload tst-tls1mod{d,a,b,c,e}" >> $logfile
+echo "===============" >> $logfile
+LD_PRELOAD=`echo ${common_objpfx}linuxthreads/tst-tls1mod{d,a,b,c,e}.so \
+	    | sed 's/:$//;s/: /:/g'` ${tst_tls1} >> $logfile || fail=1
+echo >> $logfile
+
+echo "preload tst-tls1mod{d,a,b,e,f}" >> $logfile
+echo "===============" >> $logfile
+LD_PRELOAD=`echo ${common_objpfx}linuxthreads/tst-tls1mod{d,a,b,e,f}.so \
+	    | sed 's/:$//;s/: /:/g'` ${tst_tls1} >> $logfile || fail=1
+echo >> $logfile
+
+exit $fail
Index: trunk/src/libctests/glibc/linuxthreads/tst-tsd1.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tst-tsd1.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tst-tsd1.c	(revision 2036)
@@ -0,0 +1,118 @@
+/* Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <string.h>
+
+
+static int
+do_test (void)
+{
+  pthread_key_t key1;
+  pthread_key_t key2;
+  void *value;
+  int result = 0;
+  int err;
+
+  err = pthread_key_create (&key1, NULL);
+  if (err != 0)
+    {
+      printf ("1st key_create failed: %s\n", strerror (err));
+      return 1;
+    }
+
+  /* Initial value must be NULL.  */
+  value = pthread_getspecific (key1);
+  if (value != NULL)
+    {
+      puts ("1st getspecific != NULL");
+      result = 1;
+    }
+
+  err = pthread_setspecific (key1, (void *) -2l);
+  if (err != 0)
+    {
+      printf ("1st setspecific failed: %s\n", strerror (err));
+      return 1;
+    }
+
+  value = pthread_getspecific (key1);
+  if (value == NULL)
+    {
+      puts ("2nd getspecific == NULL\n");
+      result = 1;
+    }
+  else if (value != (void *) -2l)
+    {
+      puts ("2nd getspecific != -2l\n");
+      result = 1;
+    }
+
+  err = pthread_setspecific (key1, (void *) -3l);
+  if (err != 0)
+    {
+      printf ("2nd setspecific failed: %s\n", strerror (err));
+      return 1;
+    }
+
+  value = pthread_getspecific (key1);
+  if (value == NULL)
+    {
+      puts ("3rd getspecific == NULL\n");
+      result = 1;
+    }
+  else if (value != (void *) -3l)
+    {
+      puts ("3rd getspecific != -2l\n");
+      result = 1;
+    }
+
+  err = pthread_key_delete (key1);
+  if (err != 0)
+    {
+      printf ("key_delete failed: %s\n", strerror (err));
+      result = 1;
+    }
+
+
+  err = pthread_key_create (&key2, NULL);
+  if (err != 0)
+    {
+      printf ("2nd key_create failed: %s\n", strerror (err));
+      return 1;
+    }
+
+  if (key1 != key2)
+    puts ("key1 != key2; no more tests performed");
+  else
+    {
+      value = pthread_getspecific (key2);
+      if (value != NULL)
+	{
+	  puts ("4th getspecific != NULL");
+	  result = 1;
+	}
+    }
+
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/linuxthreads/tststack.c
===================================================================
--- trunk/src/libctests/glibc/linuxthreads/tststack.c	(revision 2036)
+++ trunk/src/libctests/glibc/linuxthreads/tststack.c	(revision 2036)
@@ -0,0 +1,74 @@
+/* Tests for variable stack size handling.
+   Copyright (C) 2000, 2003 Free Software Foundation, Inc.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <limits.h>
+#include <sys/param.h>
+
+static void *f1 (void *);
+static void *f2 (void *);
+
+int
+main (void)
+{
+  pthread_attr_t attr;
+  pthread_t th1 = 0;
+  pthread_t th2 = 0;
+  void *res1;
+  void *res2;
+
+  pthread_attr_init (&attr);
+  if (pthread_attr_setstacksize (&attr, MAX (70*1024, PTHREAD_STACK_MIN)) != 0)
+    {
+      puts ("invalid stack size");
+      return 1;
+    }
+
+  pthread_create (&th1, NULL, f1, NULL);
+  pthread_create (&th2, &attr, f2, NULL);
+
+  pthread_join (th1, &res1);
+  pthread_join (th2, &res2);
+
+  printf ("res1 = %p\n", res1);
+  printf ("res2 = %p\n", res2);
+
+  return res1 != (void *) 1 || res2 != (void *) 2;
+}
+
+static void *
+f1 (void *parm)
+{
+  printf ("This is `%s'\n", __FUNCTION__);
+  fflush (stdout);
+
+  return (void *) 1;
+}
+
+static void *
+f2 (void *parm)
+{
+  printf ("This is `%s'\n", __FUNCTION__);
+  fflush (stdout);
+  sleep (1);
+
+  return (void *) 2;
+}
Index: trunk/src/libctests/glibc/locale/Makefile
===================================================================
--- trunk/src/libctests/glibc/locale/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/locale/Makefile	(revision 2036)
@@ -0,0 +1,114 @@
+# Copyright (C) 1991,1992,1995-2002,2003 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Makefile for locales.
+#
+subdir	:= locale
+
+headers		= locale.h bits/locale.h langinfo.h xlocale.h
+distribute	= localeinfo.h categories.def iso-639.def iso-3166.def \
+		  iso-4217.def weight.h weightwc.h strlen-hash.h elem-hash.h \
+		  indigits.h indigitswc.h outdigits.h outdigitswc.h \
+		  coll-lookup.h C-translit.h.in C-translit.h gen-translit.pl \
+		  locarchive.h hashval.h \
+		  $(addprefix programs/, \
+			      locale.c localedef.c \
+			      $(localedef-modules:=.c) $(locale-modules:=.c) \
+			      $(lib-modules:=.c) config.h simple-hash.h \
+			      charmap-kw.gperf charmap-kw.h locfile-token.h \
+			      locfile-kw.gperf locfile-kw.h linereader.h \
+			      locfile.h charmap.h repertoire.h localedef.h \
+			      3level.h charmap-dir.h locarchive.c)
+routines	= setlocale findlocale loadlocale loadarchive \
+		  localeconv nl_langinfo nl_langinfo_l mb_cur_max \
+		  newlocale duplocale freelocale uselocale
+tests		= tst-C-locale
+categories	= ctype messages monetary numeric time paper name \
+		  address telephone measurement identification collate
+aux		= $(categories:%=lc-%) $(categories:%=C-%) SYS_libc C_name \
+		  xlocale localename global-locale coll-lookup
+others		= localedef locale
+#others-static	= localedef locale
+install-bin	= localedef locale
+extra-objs	= $(localedef-modules:=.o) $(localedef-aux:=.o) \
+		  $(locale-modules:=.o) $(lib-modules:=.o)
+
+extra-libs	= libBrokenLocale
+extra-libs-others = $(extra-libs)
+
+libBrokenLocale-routines = broken_cur_max
+
+subdir-dirs	= programs
+vpath %.c programs ../crypt
+vpath %.h programs
+vpath %.gperf programs
+
+localedef-modules	:= $(categories:%=ld-%) charmap linereader locfile \
+			   repertoire locarchive
+localedef-aux		:= md5
+locale-modules		:= locale-spec
+lib-modules		:= charmap-dir simple-hash xmalloc xstrdup
+
+
+GPERF = gperf
+GPERFFLAGS = -acCgopt -k1,2,5,9,$$ -L ANSI-C
+
+include ../Rules
+
+programs/%-kw.h: programs/%-kw.gperf
+	$(GPERF) $(GPERFFLAGS) -N $(@F:-kw.h=_hash) $< > $@.new
+	mv -f $@.new $@
+
+$(objpfx)localedef: $(localedef-modules:%=$(objpfx)%.o)
+$(objpfx)localedef: $(localedef-aux:%=$(objpfx)%.o)
+$(objpfx)locale: $(locale-modules:%=$(objpfx)%.o)
+$(objpfx)localedef $(objpfx)locale: $(lib-modules:%=$(objpfx)%.o)
+
+C-translit.h: C-translit.h.in gen-translit.pl
+	$(PERL) gen-translit.pl < $< > $@.tmp
+	mv -f $@.tmp $@
+ifeq ($(with-cvs),yes)
+	test ! -d CVS || cvs $(CVSOPTS) commit -mRegenerated $@
+endif
+
+localepath = "$(localedir):$(i18ndir)"
+
+locale-CPPFLAGS := -DLOCALE_PATH='$(localepath)' \
+		   -DLOCALEDIR='"$(localedir)"' \
+		   -DLOCALE_ALIAS_PATH='"$(msgcatdir)"' \
+		   -DCHARMAP_PATH='"$(i18ndir)/charmaps"' \
+		   -DREPERTOIREMAP_PATH='"$(i18ndir)/repertoiremaps"' \
+		   -DLOCSRCDIR='"$(i18ndir)/locales"' -DHAVE_CONFIG_H \
+		   -Iprograms
+
+CFLAGS-charmap.c = -Wno-write-strings -Wno-char-subscripts
+CFLAGS-locfile.c = -Wno-write-strings -Wno-char-subscripts
+CFLAGS-charmap-dir.c = -Wno-write-strings
+
+# This makes sure -DNOT_IN_libc is passed for all these modules.
+cpp-srcs-left := $(addsuffix .c,$(localedef-modules) $(localedef-aux) \
+			        $(locale-modules) $(lib-modules))
+lib := nonlib
+include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
+
+# Depend on libc.so so a DT_NEEDED is generated in the shared objects.
+# This ensures they will load libc.so for needed symbols if loaded by
+# a statically-linked program that hasn't already loaded it.
+$(objpfx)libBrokenLocale.so: $(common-objpfx)libc.so \
+			     $(common-objpfx)libc_nonshared.a
Index: trunk/src/libctests/glibc/locale/tst-C-locale.c
===================================================================
--- trunk/src/libctests/glibc/locale/tst-C-locale.c	(revision 2036)
+++ trunk/src/libctests/glibc/locale/tst-C-locale.c	(revision 2036)
@@ -0,0 +1,498 @@
+/* Tests of C and POSIX locale contents.
+   Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <ctype.h>
+#include <langinfo.h>
+#include <limits.h>
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+#include <wctype.h>
+
+
+static int
+run_test (const char *locname)
+{
+  struct lconv *lc;
+  const char *str;
+  const wchar_t *wstr;
+  int result = 0;
+  locale_t loc;
+
+  /* ISO C stuff.  */
+  lc = localeconv ();
+  if (lc == NULL)
+    {
+      printf ("localeconv failed for locale %s\n", locname);
+      result = 1;
+    }
+  else
+    {
+#define STRTEST(name, exp) \
+      do								      \
+	if (strcmp (lc->name, exp) != 0)				      \
+	  {								      \
+	    printf (#name " in locale %s wrong (is \"%s\", should be \"%s\")\n",\
+		    locname, lc->name, exp);				      \
+	    result = 1;							      \
+	  }								      \
+      while (0)
+      STRTEST (decimal_point, ".");
+      STRTEST (thousands_sep, "");
+      STRTEST (grouping, "");
+      STRTEST (mon_decimal_point, "");
+      STRTEST (mon_thousands_sep, "");
+      STRTEST (mon_grouping, "");
+      STRTEST (positive_sign, "");
+      STRTEST (negative_sign, "");
+      STRTEST (currency_symbol, "");
+      STRTEST (int_curr_symbol, "");
+
+#define CHARTEST(name, exp) \
+      do								      \
+	if (lc->name != exp)						      \
+	  {								      \
+	    printf (#name " in locale %s wrong (is %d, should be %d)\n",      \
+		    locname, lc->name, CHAR_MAX);			      \
+	    result = 1;							      \
+	  }								      \
+      while (0)
+      CHARTEST (frac_digits, CHAR_MAX);
+      CHARTEST (p_cs_precedes, CHAR_MAX);
+      CHARTEST (n_cs_precedes, CHAR_MAX);
+      CHARTEST (p_sep_by_space, CHAR_MAX);
+      CHARTEST (n_sep_by_space, CHAR_MAX);
+      CHARTEST (p_sign_posn, CHAR_MAX);
+      CHARTEST (n_sign_posn, CHAR_MAX);
+      CHARTEST (int_frac_digits, CHAR_MAX);
+      CHARTEST (int_p_cs_precedes, CHAR_MAX);
+      CHARTEST (int_n_cs_precedes, CHAR_MAX);
+      CHARTEST (int_p_sep_by_space, CHAR_MAX);
+      CHARTEST (int_n_sep_by_space, CHAR_MAX);
+      CHARTEST (int_p_sign_posn, CHAR_MAX);
+      CHARTEST (int_n_sign_posn, CHAR_MAX);
+    }
+
+#undef STRTEST
+#define STRTEST(name, exp) \
+  str = nl_langinfo (name);						      \
+  if (strcmp (str, exp) != 0)						      \
+    {									      \
+      printf ("nl_langinfo(" #name ") in locale %s wrong "		      \
+	      "(is \"%s\", should be \"%s\")\n", locname, str, exp);	      \
+      result = 1;							      \
+    }
+#define WSTRTEST(name, exp) \
+  wstr = (wchar_t *) nl_langinfo (name);				      \
+  if (wcscmp (wstr, exp) != 0)						      \
+    {									      \
+      printf ("nl_langinfo(" #name ") in locale %s wrong "		      \
+	      "(is \"%S\", should be \"%S\")\n", locname, wstr, exp);	      \
+      result = 1;							      \
+    }
+
+  /* Unix stuff.  */
+  STRTEST (ABDAY_1, "Sun");
+  STRTEST (ABDAY_2, "Mon");
+  STRTEST (ABDAY_3, "Tue");
+  STRTEST (ABDAY_4, "Wed");
+  STRTEST (ABDAY_5, "Thu");
+  STRTEST (ABDAY_6, "Fri");
+  STRTEST (ABDAY_7, "Sat");
+  STRTEST (DAY_1, "Sunday");
+  STRTEST (DAY_2, "Monday");
+  STRTEST (DAY_3, "Tuesday");
+  STRTEST (DAY_4, "Wednesday");
+  STRTEST (DAY_5, "Thursday");
+  STRTEST (DAY_6, "Friday");
+  STRTEST (DAY_7, "Saturday");
+  STRTEST (ABMON_1, "Jan");
+  STRTEST (ABMON_2, "Feb");
+  STRTEST (ABMON_3, "Mar");
+  STRTEST (ABMON_4, "Apr");
+  STRTEST (ABMON_5, "May");
+  STRTEST (ABMON_6, "Jun");
+  STRTEST (ABMON_7, "Jul");
+  STRTEST (ABMON_8, "Aug");
+  STRTEST (ABMON_9, "Sep");
+  STRTEST (ABMON_10, "Oct");
+  STRTEST (ABMON_11, "Nov");
+  STRTEST (ABMON_12, "Dec");
+  STRTEST (MON_1, "January");
+  STRTEST (MON_2, "February");
+  STRTEST (MON_3, "March");
+  STRTEST (MON_4, "April");
+  STRTEST (MON_5, "May");
+  STRTEST (MON_6, "June");
+  STRTEST (MON_7, "July");
+  STRTEST (MON_8, "August");
+  STRTEST (MON_9, "September");
+  STRTEST (MON_10, "October");
+  STRTEST (MON_11, "November");
+  STRTEST (MON_12, "December");
+  STRTEST (AM_STR, "AM");
+  STRTEST (PM_STR, "PM");
+  STRTEST (D_T_FMT, "%a %b %e %H:%M:%S %Y");
+  STRTEST (D_FMT, "%m/%d/%y");
+  STRTEST (T_FMT, "%H:%M:%S");
+  STRTEST (T_FMT_AMPM, "%I:%M:%S %p");
+  STRTEST (ERA, "");
+  STRTEST (ERA_D_FMT, "");
+  STRTEST (ERA_T_FMT, "");
+  STRTEST (ERA_D_T_FMT, "");
+  STRTEST (ALT_DIGITS, "");
+
+  STRTEST (RADIXCHAR, ".");
+  STRTEST (THOUSEP, "");
+
+  STRTEST (YESEXPR, "^[yY]");
+  STRTEST (NOEXPR, "^[nN]");
+
+  /* Extensions.  */
+  WSTRTEST (_NL_WABDAY_1, L"Sun");
+  WSTRTEST (_NL_WABDAY_2, L"Mon");
+  WSTRTEST (_NL_WABDAY_3, L"Tue");
+  WSTRTEST (_NL_WABDAY_4, L"Wed");
+  WSTRTEST (_NL_WABDAY_5, L"Thu");
+  WSTRTEST (_NL_WABDAY_6, L"Fri");
+  WSTRTEST (_NL_WABDAY_7, L"Sat");
+  WSTRTEST (_NL_WDAY_1, L"Sunday");
+  WSTRTEST (_NL_WDAY_2, L"Monday");
+  WSTRTEST (_NL_WDAY_3, L"Tuesday");
+  WSTRTEST (_NL_WDAY_4, L"Wednesday");
+  WSTRTEST (_NL_WDAY_5, L"Thursday");
+  WSTRTEST (_NL_WDAY_6, L"Friday");
+  WSTRTEST (_NL_WDAY_7, L"Saturday");
+  WSTRTEST (_NL_WABMON_1, L"Jan");
+  WSTRTEST (_NL_WABMON_2, L"Feb");
+  WSTRTEST (_NL_WABMON_3, L"Mar");
+  WSTRTEST (_NL_WABMON_4, L"Apr");
+  WSTRTEST (_NL_WABMON_5, L"May");
+  WSTRTEST (_NL_WABMON_6, L"Jun");
+  WSTRTEST (_NL_WABMON_7, L"Jul");
+  WSTRTEST (_NL_WABMON_8, L"Aug");
+  WSTRTEST (_NL_WABMON_9, L"Sep");
+  WSTRTEST (_NL_WABMON_10, L"Oct");
+  WSTRTEST (_NL_WABMON_11, L"Nov");
+  WSTRTEST (_NL_WABMON_12, L"Dec");
+  WSTRTEST (_NL_WMON_1, L"January");
+  WSTRTEST (_NL_WMON_2, L"February");
+  WSTRTEST (_NL_WMON_3, L"March");
+  WSTRTEST (_NL_WMON_4, L"April");
+  WSTRTEST (_NL_WMON_5, L"May");
+  WSTRTEST (_NL_WMON_6, L"June");
+  WSTRTEST (_NL_WMON_7, L"July");
+  WSTRTEST (_NL_WMON_8, L"August");
+  WSTRTEST (_NL_WMON_9, L"September");
+  WSTRTEST (_NL_WMON_10, L"October");
+  WSTRTEST (_NL_WMON_11, L"November");
+  WSTRTEST (_NL_WMON_12, L"December");
+  WSTRTEST (_NL_WAM_STR, L"AM");
+  WSTRTEST (_NL_WPM_STR, L"PM");
+  WSTRTEST (_NL_WD_T_FMT, L"%a %b %e %H:%M:%S %Y");
+  WSTRTEST (_NL_WD_FMT, L"%m/%d/%y");
+  WSTRTEST (_NL_WT_FMT, L"%H:%M:%S");
+  WSTRTEST (_NL_WT_FMT_AMPM, L"%I:%M:%S %p");
+  WSTRTEST (_NL_WERA_D_FMT, L"");
+  WSTRTEST (_NL_WERA_T_FMT, L"");
+  WSTRTEST (_NL_WERA_D_T_FMT, L"");
+  WSTRTEST (_NL_WALT_DIGITS, L"");
+
+  STRTEST (_DATE_FMT, "%a %b %e %H:%M:%S %Z %Y");
+  WSTRTEST (_NL_W_DATE_FMT, L"%a %b %e %H:%M:%S %Z %Y");
+
+  STRTEST (INT_CURR_SYMBOL, "");
+  STRTEST (CURRENCY_SYMBOL, "");
+  STRTEST (MON_DECIMAL_POINT, "");
+  STRTEST (MON_THOUSANDS_SEP, "");
+  STRTEST (MON_GROUPING, "");
+  STRTEST (POSITIVE_SIGN, "");
+  STRTEST (NEGATIVE_SIGN, "");
+  STRTEST (GROUPING, "");
+
+  STRTEST (YESSTR, "");
+  STRTEST (NOSTR, "");
+
+  /* Test the new locale mechanisms.  */
+  loc = newlocale (LC_ALL_MASK, locname, NULL);
+  if (loc == NULL)
+    {
+      printf ("cannot create locale object for locale %s\n", locname);
+      result = 1;
+    }
+  else
+    {
+      int c;
+
+#undef STRTEST
+#define STRTEST(name, exp) \
+      str = nl_langinfo_l (name, loc);				      \
+      if (strcmp (str, exp) != 0)					      \
+	{								      \
+	  printf ("nl_langinfo_l(" #name ") in locale %s wrong "	      \
+		  "(is \"%s\", should be \"%s\")\n", locname, str, exp);      \
+	  result = 1;							      \
+	}
+#undef WSTRTEST
+#define WSTRTEST(name, exp) \
+      wstr = (wchar_t *) nl_langinfo_l (name, loc);			      \
+      if (wcscmp (wstr, exp) != 0)					      \
+	{								      \
+	  printf ("nl_langinfo_l(" #name ") in locale %s wrong "	      \
+		  "(is \"%S\", should be \"%S\")\n", locname, wstr, exp);     \
+	  result = 1;							      \
+	}
+
+      /* Unix stuff.  */
+      STRTEST (ABDAY_1, "Sun");
+      STRTEST (ABDAY_2, "Mon");
+      STRTEST (ABDAY_3, "Tue");
+      STRTEST (ABDAY_4, "Wed");
+      STRTEST (ABDAY_5, "Thu");
+      STRTEST (ABDAY_6, "Fri");
+      STRTEST (ABDAY_7, "Sat");
+      STRTEST (DAY_1, "Sunday");
+      STRTEST (DAY_2, "Monday");
+      STRTEST (DAY_3, "Tuesday");
+      STRTEST (DAY_4, "Wednesday");
+      STRTEST (DAY_5, "Thursday");
+      STRTEST (DAY_6, "Friday");
+      STRTEST (DAY_7, "Saturday");
+      STRTEST (ABMON_1, "Jan");
+      STRTEST (ABMON_2, "Feb");
+      STRTEST (ABMON_3, "Mar");
+      STRTEST (ABMON_4, "Apr");
+      STRTEST (ABMON_5, "May");
+      STRTEST (ABMON_6, "Jun");
+      STRTEST (ABMON_7, "Jul");
+      STRTEST (ABMON_8, "Aug");
+      STRTEST (ABMON_9, "Sep");
+      STRTEST (ABMON_10, "Oct");
+      STRTEST (ABMON_11, "Nov");
+      STRTEST (ABMON_12, "Dec");
+      STRTEST (MON_1, "January");
+      STRTEST (MON_2, "February");
+      STRTEST (MON_3, "March");
+      STRTEST (MON_4, "April");
+      STRTEST (MON_5, "May");
+      STRTEST (MON_6, "June");
+      STRTEST (MON_7, "July");
+      STRTEST (MON_8, "August");
+      STRTEST (MON_9, "September");
+      STRTEST (MON_10, "October");
+      STRTEST (MON_11, "November");
+      STRTEST (MON_12, "December");
+      STRTEST (AM_STR, "AM");
+      STRTEST (PM_STR, "PM");
+      STRTEST (D_T_FMT, "%a %b %e %H:%M:%S %Y");
+      STRTEST (D_FMT, "%m/%d/%y");
+      STRTEST (T_FMT, "%H:%M:%S");
+      STRTEST (T_FMT_AMPM, "%I:%M:%S %p");
+      STRTEST (ERA, "");
+      STRTEST (ERA_D_FMT, "");
+      STRTEST (ERA_T_FMT, "");
+      STRTEST (ERA_D_T_FMT, "");
+      STRTEST (ALT_DIGITS, "");
+
+      STRTEST (RADIXCHAR, ".");
+      STRTEST (THOUSEP, "");
+
+      STRTEST (YESEXPR, "^[yY]");
+      STRTEST (NOEXPR, "^[nN]");
+
+      /* Extensions.  */
+      WSTRTEST (_NL_WABDAY_1, L"Sun");
+      WSTRTEST (_NL_WABDAY_2, L"Mon");
+      WSTRTEST (_NL_WABDAY_3, L"Tue");
+      WSTRTEST (_NL_WABDAY_4, L"Wed");
+      WSTRTEST (_NL_WABDAY_5, L"Thu");
+      WSTRTEST (_NL_WABDAY_6, L"Fri");
+      WSTRTEST (_NL_WABDAY_7, L"Sat");
+      WSTRTEST (_NL_WDAY_1, L"Sunday");
+      WSTRTEST (_NL_WDAY_2, L"Monday");
+      WSTRTEST (_NL_WDAY_3, L"Tuesday");
+      WSTRTEST (_NL_WDAY_4, L"Wednesday");
+      WSTRTEST (_NL_WDAY_5, L"Thursday");
+      WSTRTEST (_NL_WDAY_6, L"Friday");
+      WSTRTEST (_NL_WDAY_7, L"Saturday");
+      WSTRTEST (_NL_WABMON_1, L"Jan");
+      WSTRTEST (_NL_WABMON_2, L"Feb");
+      WSTRTEST (_NL_WABMON_3, L"Mar");
+      WSTRTEST (_NL_WABMON_4, L"Apr");
+      WSTRTEST (_NL_WABMON_5, L"May");
+      WSTRTEST (_NL_WABMON_6, L"Jun");
+      WSTRTEST (_NL_WABMON_7, L"Jul");
+      WSTRTEST (_NL_WABMON_8, L"Aug");
+      WSTRTEST (_NL_WABMON_9, L"Sep");
+      WSTRTEST (_NL_WABMON_10, L"Oct");
+      WSTRTEST (_NL_WABMON_11, L"Nov");
+      WSTRTEST (_NL_WABMON_12, L"Dec");
+      WSTRTEST (_NL_WMON_1, L"January");
+      WSTRTEST (_NL_WMON_2, L"February");
+      WSTRTEST (_NL_WMON_3, L"March");
+      WSTRTEST (_NL_WMON_4, L"April");
+      WSTRTEST (_NL_WMON_5, L"May");
+      WSTRTEST (_NL_WMON_6, L"June");
+      WSTRTEST (_NL_WMON_7, L"July");
+      WSTRTEST (_NL_WMON_8, L"August");
+      WSTRTEST (_NL_WMON_9, L"September");
+      WSTRTEST (_NL_WMON_10, L"October");
+      WSTRTEST (_NL_WMON_11, L"November");
+      WSTRTEST (_NL_WMON_12, L"December");
+      WSTRTEST (_NL_WAM_STR, L"AM");
+      WSTRTEST (_NL_WPM_STR, L"PM");
+      WSTRTEST (_NL_WD_T_FMT, L"%a %b %e %H:%M:%S %Y");
+      WSTRTEST (_NL_WD_FMT, L"%m/%d/%y");
+      WSTRTEST (_NL_WT_FMT, L"%H:%M:%S");
+      WSTRTEST (_NL_WT_FMT_AMPM, L"%I:%M:%S %p");
+      WSTRTEST (_NL_WERA_D_FMT, L"");
+      WSTRTEST (_NL_WERA_T_FMT, L"");
+      WSTRTEST (_NL_WERA_D_T_FMT, L"");
+      WSTRTEST (_NL_WALT_DIGITS, L"");
+
+      STRTEST (_DATE_FMT, "%a %b %e %H:%M:%S %Z %Y");
+      WSTRTEST (_NL_W_DATE_FMT, L"%a %b %e %H:%M:%S %Z %Y");
+
+      STRTEST (INT_CURR_SYMBOL, "");
+      STRTEST (CURRENCY_SYMBOL, "");
+      STRTEST (MON_DECIMAL_POINT, "");
+      STRTEST (MON_THOUSANDS_SEP, "");
+      STRTEST (MON_GROUPING, "");
+      STRTEST (POSITIVE_SIGN, "");
+      STRTEST (NEGATIVE_SIGN, "");
+      STRTEST (GROUPING, "");
+
+      STRTEST (YESSTR, "");
+      STRTEST (NOSTR, "");
+
+      /* Character class tests.  */
+      for (c = 0; c < 128; ++c)
+	{
+#define CLASSTEST(name) \
+	  if (is##name (c) != is##name##_l (c, loc))			      \
+	    {								      \
+	      printf ("is%s('\\%o') != is%s_l('\\%o')\n",		      \
+		      #name, c, #name, c);				      \
+	      result = 1;						      \
+	    }
+	  CLASSTEST (alnum);
+	  CLASSTEST (alpha);
+	  CLASSTEST (blank);
+	  CLASSTEST (cntrl);
+	  CLASSTEST (digit);
+	  CLASSTEST (lower);
+	  CLASSTEST (graph);
+	  CLASSTEST (print);
+	  CLASSTEST (punct);
+	  CLASSTEST (space);
+	  CLASSTEST (upper);
+	  CLASSTEST (xdigit);
+
+	  /* Character mapping tests.  */
+#define MAPTEST(name) \
+	  if (to##name (c) != to##name##_l (c, loc))			      \
+	    {								      \
+	      printf ("to%s('\\%o') != to%s_l('\\%o'): '\\%o' vs '\\%o'\n", \
+		      #name, c, #name, c,				      \
+		      to##name (c), to##name##_l (c, loc));		      \
+	      result = 1;						      \
+	    }
+	  MAPTEST (lower);
+	  MAPTEST (upper);
+	}
+
+      /* Character class tests, this time for wide characters.  Note that
+	 this only works because we know that the internal encoding is
+	 UCS4.  */
+      for (c = 0; c < 128; ++c)
+	{
+#undef CLASSTEST
+#define CLASSTEST(name) \
+	  if (isw##name (c) != isw##name##_l (c, loc))		      \
+	    {								      \
+	      printf ("isw%s('\\%o') != isw%s_l('\\%o')\n",		      \
+		      #name, c, #name, c);				      \
+	      result = 1;						      \
+	    }
+	  CLASSTEST (alnum);
+	  CLASSTEST (alpha);
+	  CLASSTEST (blank);
+	  CLASSTEST (cntrl);
+	  CLASSTEST (digit);
+	  CLASSTEST (lower);
+	  CLASSTEST (graph);
+	  CLASSTEST (print);
+	  CLASSTEST (punct);
+	  CLASSTEST (space);
+	  CLASSTEST (upper);
+	  CLASSTEST (xdigit);
+
+	  /* Character mapping tests.  Note that
+	     this only works because we know that the internal encoding is
+	     UCS4.  */
+#undef MAPTEST
+#define MAPTEST(name) \
+	  if (tow##name (c) != tow##name##_l (c, loc))		      \
+	    {								      \
+	      printf ("tow%s('\\%o') != tow%s_l('\\%o'): '\\%o' vs '\\%o'\n",\
+		      #name, c, #name, c,				      \
+		      tow##name (c), tow##name##_l (c, loc));		      \
+	      result = 1;						      \
+	    }
+	  MAPTEST (lower);
+	  MAPTEST (upper);
+	}
+
+      freelocale (loc);
+    }
+
+  return result;
+}
+
+
+static int
+do_test (void)
+{
+  int result;
+
+  /* First use the name "C".  */
+  if (setlocale (LC_ALL, "C") == NULL)
+    {
+      puts ("cannot set C locale");
+      result = 1;
+    }
+  else
+    result = run_test ("C");
+
+  /* Then the name "POSIX".  */
+  if (setlocale (LC_ALL, "POSIX") == NULL)
+    {
+      puts ("cannot set POSIX locale");
+      result = 1;
+    }
+  else
+    result |= run_test ("POSIX");
+
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/localedata/Makefile
===================================================================
--- trunk/src/libctests/glibc/localedata/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/Makefile	(revision 2036)
@@ -0,0 +1,293 @@
+# Copyright (C) 1996-2002, 2003 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+# Makefile for installing locale data source files.
+
+subdir := localedata
+
+all: # Make this the default target; it will be defined in Rules.
+
+# List with all available character set descriptions.
+charmaps := $(filter-out $(addprefix charmaps/, CVS RCS SCCS %~), \
+				     $(wildcard charmaps/[A-I]*) \
+				     $(wildcard charmaps/[J-Z]*))
+
+# List with all available character set descriptions.
+locales := $(filter-out $(addprefix locales/, CVS RCS SCCS %~), \
+				    $(wildcard locales/*))
+
+
+subdir-dirs = tests-mbwc
+vpath %.c tests-mbwc
+vpath %.h tests-mbwc
+
+
+test-srcs := collate-test xfrm-test tst-fmon tst-rpmatch tst-trans \
+	     tst-mbswcs1 tst-mbswcs2 tst-mbswcs3 tst-mbswcs4 tst-mbswcs5 \
+	     tst-ctype tst-wctype tst-langinfo tst-numeric
+test-input := de_DE.ISO-8859-1 en_US.ISO-8859-1 da_DK.ISO-8859-1 \
+	      hr_HR.ISO-8859-2 sv_SE.ISO-8859-1 tr_TR.UTF-8
+test-input-data = $(addsuffix .in, $(basename $(test-input)))
+test-output := $(foreach s, .out .xout, \
+			 $(addsuffix $s, $(basename $(test-input))))
+ld-test-names := test1 test2 test3 test4 test5 test6 test7
+ld-test-srcs := $(addprefix tests/,$(addsuffix .cm,$(ld-test-names)) \
+				   $(addsuffix .def,$(ld-test-names)) \
+				   $(addsuffix .ds,test5 test6) \
+				   test6.c trans.def)
+
+fmon-tests = n01y12 n02n40 n10y31 n11y41 n12y11 n20n32 n30y20 n41n00 \
+	     y01y10 y02n22 y22n42 y30y21 y32n31 y40y00 y42n21
+
+generated := $(test-input) $(test-output) sort-test.out tst-locale.out \
+	     tst-mbswcs.out tst-leaks.mtrace mtrace-tst-leaks
+generated-dirs := $(ld-test-names) tt_TT de_DE.437			\
+		  $(addprefix tstfmon_,$(fmon-tests))			\
+
+distribute := CHECKSUMS README SUPPORTED ChangeLog			\
+	      $(charmaps) $(locales)					\
+	      tst-rpmatch.sh tst-locale.sh tst-fmon.sh sort-test.sh	\
+	      tst-fmon.data $(test-input-data) $(ld-test-srcs)		\
+	      th_TH.in cs_CZ.in tst-mbswcs.sh tst-trans.sh tst-ctype.sh \
+	      tst-ctype-de_DE.ISO-8859-1.in				\
+	      tst-numeric.sh tst-numeric.data				\
+	      $(wildcard tests-mbwc/*.[ch])				\
+	      $(addprefix tst-fmon-locales/tstfmon_,$(fmon-tests))	\
+	      gen-locale.sh show-ucs-data.c tst-langinfo.sh		\
+	      tst-wctype.sh tst-wctype.input gen-unicode-ctype.c	\
+	      dump-ctype.c
+
+# Get $(inst_i18ndir) defined.
+include ../Makeconfig
+
+ifeq (no,$(cross-compiling))
+locale_test_suite := tst_iswalnum tst_iswalpha tst_iswcntrl            \
+		     tst_iswctype tst_iswdigit tst_iswgraph            \
+		     tst_iswlower tst_iswprint tst_iswpunct            \
+		     tst_iswspace tst_iswupper tst_iswxdigit tst_mblen \
+		     tst_mbrlen tst_mbrtowc tst_mbsrtowcs tst_mbstowcs \
+		     tst_mbtowc tst_strcoll tst_strfmon tst_strxfrm    \
+		     tst_swscanf tst_towctrans tst_towlower            \
+		     tst_towupper tst_wcrtomb tst_wcscat tst_wcschr    \
+		     tst_wcscmp tst_wcscoll tst_wcscpy tst_wcscspn     \
+		     tst_wcslen tst_wcsncat tst_wcsncmp tst_wcsncpy    \
+		     tst_wcspbrk tst_wcsrtombs tst_wcsspn tst_wcsstr   \
+		     tst_wcstod tst_wcstok tst_wcstombs tst_wcswidth   \
+		     tst_wcsxfrm tst_wctob tst_wctomb tst_wctrans      \
+		     tst_wctype tst_wcwidth
+
+tests = $(locale_test_suite) tst-digits tst-setlocale bug-iconv-trans \
+	tst-leaks tst-mbswcs6 tst-xlocale1 tst-xlocale2 bug-usesetlocale
+ifeq (yes,$(build-shared))
+ifneq (no,$(PERL))
+tests: $(objpfx)mtrace-tst-leaks
+endif
+endif
+endif
+
+# Files to install.
+install-others := $(addprefix $(inst_i18ndir)/, \
+			      $(addsuffix .gz, $(charmaps)) \
+			      $(locales))
+
+include ../Rules
+
+# Install the charmap files in gzipped format.
+$(inst_i18ndir)/charmaps/%.gz: charmaps/% $(+force)
+	$(make-target-directory)
+	rm -f $(@:.gz=) $@
+	$(INSTALL_DATA) $< $(@:.gz=)
+	gzip -9 $(@:.gz=)
+
+# Install the locale source files in the appropriate directory.
+$(inst_i18ndir)/locales/%: locales/% $(+force); $(do-install)
+
+# gcc does not know all the format specifiers we are using here.
+CFLAGS-tst-mbswcs1.c = -Wno-format
+CFLAGS-tst-mbswcs2.c = -Wno-format
+CFLAGS-tst-mbswcs3.c = -Wno-format
+CFLAGS-tst-mbswcs4.c = -Wno-format
+CFLAGS-tst-mbswcs5.c = -Wno-format
+CFLAGS-tst-trans.c = -Wno-format
+
+
+ifeq (no,$(cross-compiling))
+# We have to generate locales
+LOCALES := de_DE.ISO-8859-1 de_DE.UTF-8 en_US.ANSI_X3.4-1968 \
+	   en_US.ISO-8859-1 ja_JP.EUC-JP da_DK.ISO-8859-1 \
+	   hr_HR.ISO-8859-2 sv_SE.ISO-8859-1 ja_JP.SJIS fr_FR.ISO-8859-1 \
+	   vi_VN.TCVN5712-1 nb_NO.ISO-8859-1 nn_NO.ISO-8859-1 \
+	   tr_TR.UTF-8 cs_CZ.UTF-8
+LOCALE_SRCS := $(shell echo "$(LOCALES)"|sed 's/\([^ .]*\)[^ ]*/\1/g')
+CHARMAPS := $(shell echo "$(LOCALES)" | \
+		    sed -e 's/[^ .]*[.]\([^ ]*\)/\1/g' -e s/SJIS/SHIFT_JIS/g)
+CTYPE_FILES = $(addsuffix /LC_CTYPE,$(LOCALES))
+
+generated-dirs += $(LOCALES)
+
+# Dependency for the locale files.  We actually make it depend only on
+# one of the files.
+$(addprefix $(objpfx),$(CTYPE_FILES)): %: \
+  gen-locale.sh $(common-objpfx)locale/localedef Makefile \
+  $(addprefix charmaps/,$(CHARMAPS)) $(addprefix locales/,$(LOCALE_SRCS))
+	@$(SHELL) -e gen-locale.sh $(common-objpfx) '$(built-program-cmd)' $@
+
+$(addsuffix .out,$(addprefix $(objpfx),$(tests))): %: \
+  $(addprefix $(objpfx),$(CTYPE_FILES))
+
+tests: $(objpfx)sort-test.out $(objpfx)tst-fmon.out $(objpfx)tst-locale.out \
+       $(objpfx)tst-rpmatch.out $(objpfx)tst-trans.out \
+       $(objpfx)tst-mbswcs.out $(objpfx)tst-ctype.out $(objpfx)tst-wctype.out \
+       $(objpfx)tst-langinfo.out $(objpfx)tst-numeric.out
+
+$(objpfx)sort-test.out: sort-test.sh $(objpfx)collate-test $(objpfx)xfrm-test \
+		       $(test-input-data) $(addprefix $(objpfx),$(CTYPE_FILES))
+	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' $(test-input) \
+	  > $@
+$(objpfx)tst-fmon.out: tst-fmon.sh $(objpfx)tst-fmon tst-fmon.data \
+		       $(objpfx)sort-test.out \
+		       $(addprefix $(objpfx),$(CTYPE_FILES))
+	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' tst-fmon.data \
+	  > $@
+$(objpfx)tst-numeric.out: tst-numeric.sh $(objpfx)tst-numeric tst-numeric.data \
+		       $(objpfx)sort-test.out \
+		       $(addprefix $(objpfx),$(CTYPE_FILES))
+	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' tst-numeric.data \
+	  > $@
+$(objpfx)tst-locale.out: tst-locale.sh $(common-objpfx)locale/localedef \
+			 $(ld-test-srcs) $(addprefix $(objpfx),$(CTYPE_FILES))
+	$(SHELL) -e $< $(common-objpfx) '$(built-program-cmd)' > $@
+$(objpfx)tst-rpmatch.out: tst-rpmatch.sh $(objpfx)tst-rpmatch \
+			  $(objpfx)tst-fmon.out \
+			  $(addprefix $(objpfx),$(CTYPE_FILES))
+	$(SHELL) -e $< $(common-objpfx) '$(built-program-cmd)' > $@
+$(objpfx)tst-trans.out: tst-trans.sh $(objpfx)tst-trans \
+			$(addprefix $(objpfx),$(CTYPE_FILES))
+	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)'
+$(objpfx)tst-mbswcs.out: tst-mbswcs.sh $(objpfx)tst-mbswcs1 \
+			 $(objpfx)tst-mbswcs2 $(objpfx)tst-mbswcs3 \
+			 $(objpfx)tst-mbswcs4 $(objpfx)tst-mbswcs5 \
+			 $(addprefix $(objpfx),$(CTYPE_FILES))
+	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)'
+$(objpfx)tst-ctype.out: tst-ctype.sh $(objpfx)tst-ctype \
+			$(objpfx)sort-test.out \
+			$(addprefix $(objpfx),$(CTYPE_FILES))
+	$(SHELL) -e $< $(common-objpfx) '$(built-program-cmd)'
+$(objpfx)tst-wctype.out: tst-wctype.sh $(objpfx)tst-wctype \
+			$(objpfx)sort-test.out tst-wctype.input \
+			$(addprefix $(objpfx),$(CTYPE_FILES))
+	$(SHELL) -e $< $(common-objpfx) '$(built-program-cmd)'
+$(objpfx)tst-langinfo.out: tst-langinfo.sh $(objpfx)tst-langinfo \
+			$(objpfx)sort-test.out \
+			$(addprefix $(objpfx),$(CTYPE_FILES))
+	$(SHELL) -e $< $(common-objpfx) '$(built-program-cmd)'
+$(objpfx)tst-digits.out: $(objpfx)tst-locale.out
+$(objpfx)tst-mbswcs6.out: $(addprefix $(objpfx),$(CTYPE_FILES))
+endif
+
+include SUPPORTED
+
+INSTALL-SUPPORTED-LOCALES=$(addprefix install-, $(SUPPORTED-LOCALES))
+
+# Sometimes the whole collection of locale files should be installed.
+LOCALEDEF=I18NPATH=. GCONV_PATH=$(common-objpfx)iconvdata LC_ALL=C \
+$(common-objpfx)elf/ld.so --library-path $(rpath-link) $(common-objpfx)locale/localedef
+install-locales: $(INSTALL-SUPPORTED-LOCALES)
+
+install-locales-dir:
+	$(..)./scripts/mkinstalldirs $(inst_localedir)
+
+$(INSTALL-SUPPORTED-LOCALES): install-locales-dir
+	@locale=`echo $@ | sed -e 's/^install-//'`; \
+	charset=`echo $$locale | sed -e 's,.*/,,'`; \
+	locale=`echo $$locale | sed -e 's,/[^/]*,,'`; \
+	echo -n `echo $$locale | sed 's/\([^.\@]*\).*/\1/'`; \
+	echo -n ".$$charset"; \
+	echo -n `echo $$locale | sed 's/\([^\@]*\)\(\@.*\)*/\2/'`; \
+	echo -n '...'; \
+	input=`echo $$locale | sed 's/\([^.]*\)[^@]*\(.*\)/\1\2/'`; \
+	$(LOCALEDEF) --alias-file=../intl/locale.alias \
+		     -i locales/$$input -c -f charmaps/$$charset \
+		     $(addprefix --prefix=,$(install_root)) $$locale; \
+	echo ' done'; \
+
+# The mbwc-tests need some environment setup to find the locale data files
+TEST_MBWC_ENV:= LOCPATH=$(common-objpfx)localedata
+tst_iswalnum-ENV = $(TEST_MBWC_ENV)
+tst_iswalpha-ENV = $(TEST_MBWC_ENV)
+tst_iswcntrl-ENV = $(TEST_MBWC_ENV)
+tst_iswctype-ENV = $(TEST_MBWC_ENV)
+tst_iswdigit-ENV = $(TEST_MBWC_ENV)
+tst_iswgraph-ENV = $(TEST_MBWC_ENV)
+tst_iswlower-ENV = $(TEST_MBWC_ENV)
+tst_iswprint-ENV = $(TEST_MBWC_ENV)
+tst_iswpunct-ENV = $(TEST_MBWC_ENV)
+tst_iswspace-ENV = $(TEST_MBWC_ENV)
+tst_iswupper-ENV = $(TEST_MBWC_ENV)
+tst_iswxdigit-ENV = $(TEST_MBWC_ENV)
+tst_mblen-ENV = $(TEST_MBWC_ENV)
+tst_mbrlen-ENV = $(TEST_MBWC_ENV)
+tst_mbrtowc-ENV = $(TEST_MBWC_ENV)
+tst_mbsrtowcs-ENV = $(TEST_MBWC_ENV)
+tst_mbstowcs-ENV = $(TEST_MBWC_ENV)
+tst_mbtowc-ENV = $(TEST_MBWC_ENV)
+tst_strcoll-ENV = $(TEST_MBWC_ENV)
+tst_strfmon-ENV = $(TEST_MBWC_ENV)
+tst_strxfrm-ENV = $(TEST_MBWC_ENV)
+tst_swscanf-ENV = $(TEST_MBWC_ENV)
+tst_towctrans-ENV = $(TEST_MBWC_ENV)
+tst_towlower-ENV = $(TEST_MBWC_ENV)
+tst_towupper-ENV = $(TEST_MBWC_ENV)
+tst_wcrtomb-ENV = $(TEST_MBWC_ENV)
+tst_wcscat-ENV = $(TEST_MBWC_ENV)
+tst_wcschr-ENV = $(TEST_MBWC_ENV)
+tst_wcscmp-ENV = $(TEST_MBWC_ENV)
+tst_wcscoll-ENV = $(TEST_MBWC_ENV)
+tst_wcscpy-ENV = $(TEST_MBWC_ENV)
+tst_wcscspn-ENV = $(TEST_MBWC_ENV)
+tst_wcslen-ENV = $(TEST_MBWC_ENV)
+tst_wcsncat-ENV = $(TEST_MBWC_ENV)
+tst_wcsncmp-ENV = $(TEST_MBWC_ENV)
+tst_wcsncpy-ENV = $(TEST_MBWC_ENV)
+tst_wcspbrk-ENV = $(TEST_MBWC_ENV)
+tst_wcsrtombs-ENV = $(TEST_MBWC_ENV)
+tst_wcsspn-ENV = $(TEST_MBWC_ENV)
+tst_wcsstr-ENV = $(TEST_MBWC_ENV)
+tst_wcstod-ENV = $(TEST_MBWC_ENV)
+tst_wcstok-ENV = $(TEST_MBWC_ENV)
+tst_wcstombs-ENV = $(TEST_MBWC_ENV)
+tst_wcswidth-ENV = $(TEST_MBWC_ENV)
+tst_wcsxfrm-ENV = $(TEST_MBWC_ENV)
+tst_wctob-ENV = $(TEST_MBWC_ENV)
+tst_wctomb-ENV = $(TEST_MBWC_ENV)
+tst_wctrans-ENV = $(TEST_MBWC_ENV)
+tst_wctype-ENV = $(TEST_MBWC_ENV)
+tst_wcwidth-ENV = $(TEST_MBWC_ENV)
+tst-digits-ENV = $(TEST_MBWC_ENV)
+tst-mbswcs6-ENV = $(TEST_MBWC_ENV)
+tst-xlocale1-ENV = $(TEST_MBWC_ENV)
+tst-xlocale2-ENV = $(TEST_MBWC_ENV)
+
+tst-setlocale-ENV = LOCPATH=$(common-objpfx)localedata LC_ALL=ja_JP.EUC-JP
+
+bug-iconv-trans-ENV = LOCPATH=$(common-objpfx)localedata
+
+tst-leaks-ENV = MALLOC_TRACE=$(objpfx)tst-leaks.mtrace \
+		LOCPATH=$(common-objpfx)localedata
+$(objpfx)mtrace-tst-leaks: $(objpfx)tst-leaks.out
+	$(common-objpfx)malloc/mtrace $(objpfx)tst-leaks.mtrace > $@
Index: trunk/src/libctests/glibc/localedata/bug-iconv-trans.c
===================================================================
--- trunk/src/libctests/glibc/localedata/bug-iconv-trans.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/bug-iconv-trans.c	(revision 2036)
@@ -0,0 +1,68 @@
+#include <iconv.h>
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+
+int
+main (void)
+{
+  iconv_t cd;
+  const char str[] = "ÄäÖöÜüß";
+  const char expected[] = "AEaeOEoeUEuess";
+  char *inptr = (char *) str;
+  size_t inlen = strlen (str) + 1;
+  char outbuf[500];
+  char *outptr = outbuf;
+  size_t outlen = sizeof (outbuf);
+  int result = 0;
+  size_t n;
+
+  if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
+    {
+      puts ("setlocale failed");
+      return 1;
+    }
+
+  cd = iconv_open ("ANSI_X3.4-1968//TRANSLIT", "ISO-8859-1");
+  if (cd == (iconv_t) -1)
+    {
+      puts ("iconv_open failed");
+      return 1;
+    }
+
+  n = iconv (cd, &inptr, &inlen, &outptr, &outlen);
+  if (n != 7)
+    {
+      if (n == (size_t) -1)
+	printf ("iconv() returned error: %m\n");
+      else
+	printf ("iconv() returned %Zd, expected 7\n", n);
+      result = 1;
+    }
+  if (inlen != 0)
+    {
+      puts ("not all input consumed");
+      result = 1;
+    }
+  else if (inptr - str != strlen (str) + 1)
+    {
+      printf ("inptr wrong, advanced by %td\n", inptr - str);
+      result = 1;
+    }
+  if (memcmp (outbuf, expected, sizeof (expected)) != 0)
+    {
+      printf ("result wrong: \"%.*s\", expected: \"%s\"\n",
+	      (int) (sizeof (outbuf) - outlen), outbuf, expected);
+      result = 1;
+    }
+  else if (outlen != sizeof (outbuf) - sizeof (expected))
+    {
+      printf ("outlen wrong: %Zd, expected %Zd\n", outlen,
+	      sizeof (outbuf) - 15);
+      result = 1;
+    }
+  else
+    printf ("output is \"%s\" which is OK\n", outbuf);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/localedata/bug-usesetlocale.c
===================================================================
--- trunk/src/libctests/glibc/localedata/bug-usesetlocale.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/bug-usesetlocale.c	(revision 2036)
@@ -0,0 +1,38 @@
+/* Test case for setlocale vs uselocale (LC_GLOBAL_LOCALE) bug.  */
+
+#define _GNU_SOURCE 1
+#include <locale.h>
+#include <stdio.h>
+#include <ctype.h>
+
+static int
+do_test (void)
+{
+  __locale_t loc_new, loc_old;
+
+  int first = !!isalpha(0xE4);
+
+  setlocale (LC_ALL, "de_DE");
+
+  int global_de = !!isalpha(0xE4);
+
+  loc_new = newlocale (1 << LC_ALL, "C", 0);
+  loc_old = uselocale (loc_new);
+
+  int used_c = !!isalpha(0xE4);
+
+  uselocale (loc_old);
+
+  int used_global = !!isalpha(0xE4);
+
+  printf ("started %d, after setlocale %d\n", first, global_de);
+  printf ("after uselocale %d, after LC_GLOBAL_LOCALE %d\n",
+	  used_c, used_global);
+
+  freelocale (loc_new);
+  return !(used_c == first && used_global == global_de);
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "test-skeleton.c"
Index: trunk/src/libctests/glibc/localedata/collate-test.c
===================================================================
--- trunk/src/libctests/glibc/localedata/collate-test.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/collate-test.c	(revision 2036)
@@ -0,0 +1,133 @@
+/* Test collation function using real data.
+   Copyright (C) 1997, 1999, 2000, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <ctype.h>
+#include <error.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+struct lines
+{
+  char *key;
+  char *line;
+};
+
+static int xstrcoll (const void *, const void *);
+
+int
+main (int argc, char *argv[])
+{
+  int result = 0;
+  size_t nstrings, nstrings_max;
+  struct lines *strings;
+  char *line = NULL;
+  size_t len = 0;
+  size_t n;
+
+  if (argc < 2)
+    error (1, 0, "usage: %s <random seed>", argv[0]);
+
+  setlocale (LC_ALL, "");
+
+  nstrings_max = 100;
+  nstrings = 0;
+  strings = (struct lines *) malloc (nstrings_max * sizeof (struct lines));
+  if (strings == NULL)
+    {
+      perror (argv[0]);
+      exit (1);
+    }
+
+  while (1)
+    {
+      int l;
+      if (getline (&line, &len, stdin) < 0)
+	break;
+
+      if (nstrings == nstrings_max)
+	{
+	  strings = (struct lines *) realloc (strings,
+					      (nstrings_max *= 2)
+					       * sizeof (*strings));
+	  if (strings == NULL)
+	    {
+	      perror (argv[0]);
+	      exit (1);
+	    }
+	}
+      strings[nstrings].line = strdup (line);
+      l = strcspn (line, ":(;");
+      while (l > 0 && isspace (line[l - 1]))
+	--l;
+      strings[nstrings].key = strndup (line, l);
+      ++nstrings;
+    }
+  free (line);
+
+  /* First shuffle.  */
+  srandom (atoi (argv[1]));
+  for (n = 0; n < 10 * nstrings; ++n)
+    {
+      int r1, r2, r;
+      size_t idx1 = random () % nstrings;
+      size_t idx2 = random () % nstrings;
+      struct lines tmp = strings[idx1];
+      strings[idx1] = strings[idx2];
+      strings[idx2] = tmp;
+
+      /* While we are at it a first little test.  */
+      r1 = strcoll (strings[idx1].key, strings[idx2].key);
+      r2 = strcoll (strings[idx2].key, strings[idx1].key);
+      r = r1 * r2;
+
+      if (r > 0 || (r == 0 && r1 != 0) || (r == 0 && r2 != 0))
+	printf ("`%s' and `%s' collate wrong: %d vs. %d\n",
+		strings[idx1].key, strings[idx2].key, r1, r2);
+    }
+
+  /* Now sort.  */
+  qsort (strings, nstrings, sizeof (struct lines), xstrcoll);
+
+  /* Print the result.  */
+  for (n = 0; n < nstrings; ++n)
+    {
+      fputs (strings[n].line, stdout);
+      free (strings[n].line);
+      free (strings[n].key);
+    }
+  free (strings);
+
+  return result;
+}
+
+
+static int
+xstrcoll (ptr1, ptr2)
+     const void *ptr1;
+     const void *ptr2;
+{
+  const struct lines *l1 = (const struct lines *) ptr1;
+  const struct lines *l2 = (const struct lines *) ptr2;
+
+  return strcoll (l1->key, l2->key);
+}
Index: trunk/src/libctests/glibc/localedata/sort-test.sh
===================================================================
--- trunk/src/libctests/glibc/localedata/sort-test.sh	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/sort-test.sh	(revision 2036)
@@ -0,0 +1,45 @@
+#! /bin/sh
+
+common_objpfx=$1; shift
+run_program_prefix=$1; shift
+lang=$*
+
+id=${PPID:-100}
+here=`pwd`
+
+# Run collation tests.
+status=0
+for l in $lang; do
+  here=0
+  cns=`echo $l | sed 's/\(.*\)[.][^.]*/\1/'`
+  LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}/iconvdata \
+   LC_ALL=$l ${run_program_prefix} \
+   ${common_objpfx}localedata/collate-test $id < $cns.in \
+   > ${common_objpfx}localedata/$cns.out || here=1
+  cmp -s $cns.in ${common_objpfx}localedata/$cns.out || here=1
+  if test $here -eq 0; then
+    echo "$l collate-test OK"
+  else
+    echo "$l collate-test FAIL"
+    diff -u $cns.in ${common_objpfx}localedata/$cns.out | sed 's/^/  /'
+    status=1
+  fi
+
+  LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}/iconvdata \
+   LC_ALL=$l ${run_program_prefix} \
+   ${common_objpfx}localedata/xfrm-test $id < $cns.in \
+   > ${common_objpfx}localedata/$cns.xout || here=1
+  cmp -s $cns.in ${common_objpfx}localedata/$cns.xout || here=1
+  if test $here -eq 0; then
+    echo "$l xfrm-test OK"
+  else
+    echo "$l xfrm-test FAIL"
+    diff -u $cns.in ${common_objpfx}localedata/$cns.xout | sed 's/^/  /'
+    status=1
+  fi
+done
+
+exit $status
+# Local Variables:
+#  mode:shell-script
+# End:
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_isw-funcs.h
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_isw-funcs.h	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_isw-funcs.h	(revision 2036)
@@ -0,0 +1,37 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_isw-funcs.h
+ *
+ *	 ISW*:	int isw* (wint_t wc);
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <wctype.h>
+#include "tst_types.h"
+#include "tgn_locdef.h"
+
+#define TST_ISW_LOC(FUNC, func) \
+	TST_ISW## FUNC	  tst_isw## func ##_loc []
+
+#define TST_ISW_REC(locale, func) \
+	{  Tisw## func,	   TST_LOC_## locale  },
+
+/*
+ *  NOTE:
+ *    Set ret_flg = 1, when a return value is expected to be 0 (FALSE).
+ *    Set ret_flg = 0, when a return value is expected to be non-zero (TRUE).
+ *
+ *    Since the functions return *non*-zero value for TRUE, can't
+ *    compare an actual return value with an expected return value.
+ *    Set the ret_flg=0 for TRUE cases and the tst_isw*() will check
+ *    the non-zero value.
+ *
+ *    { { WEOF }, { 0,1,0 } },
+ *		      | |
+ *		      | ret_val: an expected return value
+ *		      ret_flg: if 1, compare an actual return value with the
+ *			       ret_val; if 0, the test program
+ *			       checks the actual return value.
+ */
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswalnum.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswalnum.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswalnum.c	(revision 2036)
@@ -0,0 +1,192 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_iswalnum.c
+ *
+ *	 ISW*:	int iswalnum (wint_t wc);
+ */
+
+
+#include "dat_isw-funcs.h"
+
+
+TST_ISW_LOC (ALNUM, alnum) = {
+
+    {	TST_ISW_REC (de, alnum)
+	{
+	  {  { 0x0080 }, { 0,1,0 }  },  /* CTRL     */
+	  {  { 0x009F }, { 0,1,0 }  },  /* CTRL     */
+	  {  { 0x00A0 }, { 0,1,0 }  },  /* NB SPACE */
+	  {  { 0x00A1 }, { 0,1,0 }  },  /* UD !     */
+	  {  { 0x00B0 }, { 0,1,0 }  },  /* Degree   */
+	  {  { 0x00B1 }, { 0,1,0 }  },  /* +- sign  */
+	  {  { 0x00B2 }, { 0,1,0 }  },  /* SUP 2    */
+	  {  { 0x00B3 }, { 0,1,0 }  },  /* SUP 3    */
+	  {  { 0x00B4 }, { 0,1,0 }  },  /* ACUTE    */
+	  {  { 0x00B8 }, { 0,1,0 }  },  /* CEDILLA  */
+	  {  { 0x00B9 }, { 0,1,0 }  },  /* SUP 1    */
+	  {  { 0x00BB }, { 0,1,0 }  },  /* >>	      */
+	  {  { 0x00BC }, { 0,1,0 }  },  /* 1/4      */
+	  {  { 0x00BD }, { 0,1,0 }  },  /* 1/2      */
+	  {  { 0x00BE }, { 0,1,0 }  },  /* 3/4      */
+	  {  { 0x00BF }, { 0,1,0 }  },  /* UD ?     */
+	  {  { 0x00C0 }, { 0,0,0 }  },  /* A Grave  */
+	  {  { 0x00D6 }, { 0,0,0 }  },  /* O dia    */
+	  {  { 0x00D7 }, { 0,1,0 }  },  /* multipl. */
+	  {  { 0x00D8 }, { 0,0,0 }  },  /* O stroke */
+	  {  { 0x00DF }, { 0,0,0 }  },  /* small Sh */
+	  {  { 0x00E0 }, { 0,0,0 }  },  /* a grave  */
+	  {  { 0x00F6 }, { 0,0,0 }  },  /* o dia    */
+	  {  { 0x00F7 }, { 0,1,0 }  },  /* division */
+	  {  { 0x00F8 }, { 0,0,0 }  },  /* o stroke */
+	  {  { 0x00FF }, { 0,0,0 }  },  /* y dia    */
+	  {  .is_last = 1 }		  /* last element    */
+	}
+    },
+    {	TST_ISW_REC (de_UTF8, alnum)
+	{
+	  {  { 0x0080 }, { 0,1,0 }  },  /* CTRL     */
+	  {  { 0x009F }, { 0,1,0 }  },  /* CTRL     */
+	  {  { 0x00A0 }, { 0,1,0 }  },  /* NB SPACE */
+	  {  { 0x00A1 }, { 0,1,0 }  },  /* UD !     */
+	  {  { 0x00B0 }, { 0,1,0 }  },  /* Degree   */
+	  {  { 0x00B1 }, { 0,1,0 }  },  /* +- sign  */
+	  {  { 0x00B2 }, { 0,1,0 }  },  /* SUP 2    */
+	  {  { 0x00B3 }, { 0,1,0 }  },  /* SUP 3    */
+	  {  { 0x00B4 }, { 0,1,0 }  },  /* ACUTE    */
+	  {  { 0x00B8 }, { 0,1,0 }  },  /* CEDILLA  */
+	  {  { 0x00B9 }, { 0,1,0 }  },  /* SUP 1    */
+	  {  { 0x00BB }, { 0,1,0 }  },  /* >>	      */
+	  {  { 0x00BC }, { 0,1,0 }  },  /* 1/4      */
+	  {  { 0x00BD }, { 0,1,0 }  },  /* 1/2      */
+	  {  { 0x00BE }, { 0,1,0 }  },  /* 3/4      */
+	  {  { 0x00BF }, { 0,1,0 }  },  /* UD ?     */
+	  {  { 0x00C0 }, { 0,0,0 }  },  /* A Grave  */
+	  {  { 0x00D6 }, { 0,0,0 }  },  /* O dia    */
+	  {  { 0x00D7 }, { 0,1,0 }  },  /* multipl. */
+	  {  { 0x00D8 }, { 0,0,0 }  },  /* O stroke */
+	  {  { 0x00DF }, { 0,0,0 }  },  /* small Sh */
+	  {  { 0x00E0 }, { 0,0,0 }  },  /* a grave  */
+	  {  { 0x00F6 }, { 0,0,0 }  },  /* o dia    */
+	  {  { 0x00F7 }, { 0,1,0 }  },  /* division */
+	  {  { 0x00F8 }, { 0,0,0 }  },  /* o stroke */
+	  {  { 0x00FF }, { 0,0,0 }  },  /* y dia    */
+	  {  .is_last = 1 }		  /* last element    */
+	}
+    },
+    {	TST_ISW_REC (enUS, alnum)
+	{
+	  {  { WEOF   }, { 0,1,0 }  },
+	  {  { 0x0000 }, { 0,1,0 }  },
+	  {  { 0x001F }, { 0,1,0 }  },
+	  {  { 0x0020 }, { 0,1,0 }  },
+	  {  { 0x0021 }, { 0,1,0 }  },
+	  {  { 0x002F }, { 0,1,0 }  },
+	  {  { 0x0030 }, { 0,0,0 }  },
+	  {  { 0x0039 }, { 0,0,0 }  },
+	  {  { 0x003A }, { 0,1,0 }  },
+	  {  { 0x0040 }, { 0,1,0 }  },
+	  {  { 0x0041 }, { 0,0,0 }  },
+	  {  { 0x005A }, { 0,0,0 }  },
+	  {  { 0x005B }, { 0,1,0 }  },
+	  {  { 0x0060 }, { 0,1,0 }  },
+	  {  { 0x0061 }, { 0,0,0 }  },
+	  {  { 0x007A }, { 0,0,0 }  },
+	  {  { 0x007B }, { 0,1,0 }  },
+	  {  { 0x007E }, { 0,1,0 }  },
+	  {  { 0x007F }, { 0,1,0 }  },
+	  {  { 0x0080 }, { 0,1,0 }  },
+	  {  .is_last = 1 }		  /* last element    */
+	}
+    },
+    {	TST_ISW_REC (eucJP, alnum)
+	{
+	  {  { 0x3000 }, { 0,1,0 }  },  /* IDEO. SPACE	*/
+	  {  { 0x3020 }, { 0,1,0 }  },  /* POSTAL MARK FACE	*/
+#ifdef SHOJI_IS_RIGHT
+	  {  { 0x3029 }, { 0,1,0 }  },  /* Hangzhou NUM9	*/
+#else
+	  {  { 0x3029 }, { 0,0,0 }  },  /* Hangzhou NUM9	*/
+#endif
+	  {  { 0x302F }, { 0,1,0 }  },  /* Diacritics(Hangul) */
+	  {  { 0x3037 }, { 0,1,0 }  },  /* Separator Symbol	*/
+	  {  { 0x303F }, { 0,1,0 }  },  /* IDEO. HALF SPACE	*/
+#ifdef SHOJI_IS_RIGHT
+	  {  { 0x3041 }, { 0,1,0 }  },  /* HIRAGANA a		*/
+	  {  { 0x3094 }, { 0,1,0 }  },  /* HIRAGANA u"		*/
+#else
+	  {  { 0x3041 }, { 0,0,0 }  },  /* HIRAGANA a		*/
+	  {  { 0x3094 }, { 0,0,0 }  },  /* HIRAGANA u"		*/
+#endif
+	  {  { 0x3099 }, { 0,1,0 }  },  /* SOUND MARK		*/
+#ifdef SHOJI_IS_RIGHT
+	  {  { 0x309E }, { 0,1,0 }  },  /* ITERATION MARK	*/
+	  {  { 0x30A1 }, { 0,1,0 }  },  /* KATAKANA a		*/
+	  {  { 0x30FA }, { 0,1,0 }  },  /* KATAKANA wo"	*/
+#else
+	  {  { 0x309E }, { 0,0,0 }  },  /* ITERATION MARK	*/
+	  {  { 0x30A1 }, { 0,0,0 }  },  /* KATAKANA a		*/
+	  {  { 0x30FA }, { 0,0,0 }  },  /* KATAKANA wo"	*/
+#endif
+	  {  { 0x30FB }, { 0,1,0 }  },  /* KATAKANA MID.DOT	*/
+#ifdef SHOJI_IS_RIGHT
+	  {  { 0x30FE }, { 0,1,0 }  },  /* KATAKANA ITERATION	*/
+#else
+	  {  { 0x30FE }, { 0,0,0 }  },  /* KATAKANA ITERATION	*/
+#endif
+	  {  { 0x3191 }, { 0,1,0 }  },  /* KANBUN REV.MARK	*/
+	  {  { 0x3243 }, { 0,1,0 }  },  /* IDEO. MARK (reach) */
+	  {  { 0x32CB }, { 0,1,0 }  },  /* IDEO.TEL.SYM.DEC12 */
+	  {  { 0x32FE }, { 0,1,0 }  },  /* MARU KATAKANA wo	*/
+	  {  { 0x33FE }, { 0,1,0 }  },  /* CJK IDEO.TEL.31th	*/
+#ifdef SHOJI_IS_RIGHT
+	  {  { 0x4E00 }, { 0,1,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x4E05 }, { 0,1,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x4E06 }, { 0,1,0 }  },  /* CJK UNI.IDEO.NON-J	*/
+	  {  { 0x4E07 }, { 0,1,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x4FFF }, { 0,1,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x9000 }, { 0,1,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x9006 }, { 0,1,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x9007 }, { 0,1,0 }  },  /* CJK UNI.IDEO.NON-J	*/
+	  {  { 0x9FA4 }, { 0,1,0 }  },  /* CJK UNI.IDEO.NON-J	*/
+	  {  { 0x9FA5 }, { 0,1,0 }  },  /* CJK UNI.IDEO.	*/
+#else
+	  {  { 0x4E00 }, { 0,0,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x4E05 }, { 0,0,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x4E06 }, { 0,0,0 }  },  /* CJK UNI.IDEO.NON-J	*/
+	  {  { 0x4E07 }, { 0,0,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x4FFF }, { 0,0,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x9000 }, { 0,0,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x9006 }, { 0,0,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x9007 }, { 0,0,0 }  },  /* CJK UNI.IDEO.NON-J	*/
+	  {  { 0x9FA4 }, { 0,0,0 }  },  /* CJK UNI.IDEO.NON-J	*/
+	  {  { 0x9FA5 }, { 0,0,0 }  },  /* CJK UNI.IDEO.	*/
+#endif
+	  {  { 0xFE4F }, { 0,1,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0xFF0F }, { 0,1,0 }  },  /* FULL SLASH		*/
+	  {  { 0xFF19 }, { 0,0,0 }  },  /* FULL 9		*/
+	  {  { 0xFF20 }, { 0,1,0 }  },  /* FULL @		*/
+	  {  { 0xFF3A }, { 0,0,0 }  },  /* FULL Z		*/
+	  {  { 0xFF40 }, { 0,1,0 }  },  /* FULL GRAVE ACC.	*/
+	  {  { 0xFF5A }, { 0,0,0 }  },  /* FULL z		*/
+	  {  { 0xFF5E }, { 0,1,0 }  },  /* FULL ~ (tilde)	*/
+	  {  { 0xFF61 }, { 0,1,0 }  },  /* HALF IDEO.STOP. .	*/
+	  {  { 0xFF65 }, { 0,1,0 }  },  /* HALF KATA MID.DOT	*/
+#ifdef SHOJI_IS_RIGHT
+	  {  { 0xFF66 }, { 0,1,0 }  },  /* HALF KATA WO		*/
+	  {  { 0xFF6F }, { 0,1,0 }  },  /* HALF KATA tu		*/
+	  {  { 0xFF70 }, { 0,1,0 }  },  /* HALF KATA PL -	*/
+	  {  { 0xFF71 }, { 0,1,0 }  },  /* HALF KATA A		*/
+	  {  { 0xFF9E }, { 0,1,0 }  },  /* HALF KATA MI		*/
+#else
+	  {  { 0xFF66 }, { 0,0,0 }  },  /* HALF KATA WO		*/
+	  {  { 0xFF6F }, { 0,0,0 }  },  /* HALF KATA tu		*/
+	  {  { 0xFF70 }, { 0,0,0 }  },  /* HALF KATA PL -	*/
+	  {  { 0xFF71 }, { 0,0,0 }  },  /* HALF KATA A		*/
+	  {  { 0xFF9E }, { 0,0,0 }  },  /* HALF KATA MI		*/
+#endif
+	  {  .is_last = 1 }		  /* last element    */
+	}
+    },
+    {	TST_ISW_REC (end, alnum) }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswalpha.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswalpha.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswalpha.c	(revision 2036)
@@ -0,0 +1,165 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_iswalpha.c
+ *
+ *	 ISW*:	int iswalpha (wint_t wc);
+ */
+
+
+#include "dat_isw-funcs.h"
+
+
+TST_ISW_LOC (ALPHA, alpha)  = {
+
+    {	TST_ISW_REC (de, alpha)
+	{
+	  {  { 0x0080 }, { 0,1,0 }  },  /* CTRL     */
+	  {  { 0x009F }, { 0,1,0 }  },  /* CTRL     */
+	  {  { 0x00A0 }, { 0,1,0 }  },  /* NB SPACE */
+	  {  { 0x00A1 }, { 0,1,0 }  },  /* UD !     */
+	  {  { 0x00B0 }, { 0,1,0 }  },  /* Degree   */
+	  {  { 0x00B1 }, { 0,1,0 }  },  /* +- sign  */
+	  {  { 0x00B2 }, { 0,1,0 }  },  /* SUP 2    */
+	  {  { 0x00B3 }, { 0,1,0 }  },  /* SUP 3    */
+	  {  { 0x00B4 }, { 0,1,0 }  },  /* ACUTE    */
+	  {  { 0x00B8 }, { 0,1,0 }  },  /* CEDILLA  */
+	  {  { 0x00B9 }, { 0,1,0 }  },  /* SUP 1    */
+	  {  { 0x00BB }, { 0,1,0 }  },  /* >>	      */
+	  {  { 0x00BC }, { 0,1,0 }  },  /* 1/4      */
+	  {  { 0x00BD }, { 0,1,0 }  },  /* 1/2      */
+	  {  { 0x00BE }, { 0,1,0 }  },  /* 3/4      */
+	  {  { 0x00BF }, { 0,1,0 }  },  /* UD ?     */
+	  {  { 0x00C0 }, { 0,0,0 }  },  /* A Grave  */
+	  {  { 0x00D6 }, { 0,0,0 }  },  /* O dia    */
+	  {  { 0x00D7 }, { 0,1,0 }  },  /* multipl. */
+	  {  { 0x00D8 }, { 0,0,0 }  },  /* O stroke */
+	  {  { 0x00DF }, { 0,0,0 }  },  /* small Sh */
+	  {  { 0x00E0 }, { 0,0,0 }  },  /* a grave  */
+	  {  { 0x00F6 }, { 0,0,0 }  },  /* o dia    */
+	  {  { 0x00F7 }, { 0,1,0 }  },  /* division */
+	  {  { 0x00F8 }, { 0,0,0 }  },  /* o stroke */
+	  {  { 0x00FF }, { 0,0,0 }  },  /* y dia    */
+	  {  .is_last = 1 }		  /* last element    */
+	}
+    },
+    {	TST_ISW_REC (enUS, alpha)
+	{
+	  {  { WEOF   }, { 0,1,0 }  },
+	  {  { 0x0000 }, { 0,1,0 }  },
+	  {  { 0x001F }, { 0,1,0 }  },
+	  {  { 0x0020 }, { 0,1,0 }  },
+	  {  { 0x0021 }, { 0,1,0 }  },
+	  {  { 0x002F }, { 0,1,0 }  },
+	  {  { 0x0030 }, { 0,1,0 }  },
+	  {  { 0x0039 }, { 0,1,0 }  },
+	  {  { 0x003A }, { 0,1,0 }  },
+	  {  { 0x0040 }, { 0,1,0 }  },
+	  {  { 0x0041 }, { 0,0,0 }  },
+	  {  { 0x005A }, { 0,0,0 }  },
+	  {  { 0x005B }, { 0,1,0 }  },
+	  {  { 0x0060 }, { 0,1,0 }  },
+	  {  { 0x0061 }, { 0,0,0 }  },
+	  {  { 0x007A }, { 0,0,0 }  },
+	  {  { 0x007B }, { 0,1,0 }  },
+	  {  { 0x007E }, { 0,1,0 }  },
+	  {  { 0x007F }, { 0,1,0 }  },
+	  {  { 0x0080 }, { 0,1,0 }  },  /* 20 */
+	  {  .is_last = 1 }		  /* last element    */
+	}
+    },
+    {	TST_ISW_REC (eucJP, alpha)
+	{
+	  {  { 0x3000 }, { 0,1,0 }  },  /* IDEO. SPACE	*/
+	  {  { 0x3020 }, { 0,1,0 }  },  /* POSTAL MARK FACE	*/
+#ifdef SHOJI_IS_RIGHT
+	  {  { 0x3029 }, { 0,1,0 }  },  /* Hangzhou NUM9	*/
+#else
+	  {  { 0x3029 }, { 0,0,0 }  },  /* Hangzhou NUM9	*/
+#endif
+	  {  { 0x302F }, { 0,1,0 }  },  /* Diacritics(Hangul) */
+	  {  { 0x3037 }, { 0,1,0 }  },  /* Separator Symbol	*/
+	  {  { 0x303F }, { 0,1,0 }  },  /* IDEO. HALF SPACE	*/
+#ifdef SHOJI_IS_RIGHT
+	  {  { 0x3041 }, { 0,1,0 }  },  /* HIRAGANA a		*/
+	  {  { 0x3094 }, { 0,1,0 }  },  /* HIRAGANA u"		*/
+#else
+	  {  { 0x3041 }, { 0,0,0 }  },  /* HIRAGANA a		*/
+	  {  { 0x3094 }, { 0,0,0 }  },  /* HIRAGANA u"		*/
+#endif
+	  {  { 0x3099 }, { 0,1,0 }  },  /* SOUND MARK		*/
+#ifdef SHOJI_IS_RIGHT
+	  {  { 0x309E }, { 0,1,0 }  },  /* ITERATION MARK	*/
+	  {  { 0x30A1 }, { 0,1,0 }  },  /* KATAKANA a		*/
+	  {  { 0x30FA }, { 0,1,0 }  },  /* KATAKANA wo"		*/
+#else
+	  {  { 0x309E }, { 0,0,0 }  },  /* ITERATION MARK	*/
+	  {  { 0x30A1 }, { 0,0,0 }  },  /* KATAKANA a		*/
+	  {  { 0x30FA }, { 0,0,0 }  },  /* KATAKANA wo"		*/
+#endif
+	  {  { 0x30FB }, { 0,1,0 }  },  /* KATAKANA MID.DOT	*/
+#ifdef SHOJI_IS_RIGHT
+	  {  { 0x30FE }, { 0,1,0 }  },  /* KATAKANA ITERATION	*/
+#else
+	  {  { 0x30FE }, { 0,0,0 }  },  /* KATAKANA ITERATION	*/
+#endif
+	  {  { 0x3191 }, { 0,1,0 }  },  /* KANBUN REV.MARK	*/
+	  {  { 0x3243 }, { 0,1,0 }  },  /* IDEO. MARK (reach) */
+	  {  { 0x32CB }, { 0,1,0 }  },  /* IDEO.TEL.SYM.DEC12 */
+	  {  { 0x32FE }, { 0,1,0 }  },  /* MARU KATAKANA wo	*/
+	  {  { 0x33FE }, { 0,1,0 }  },  /* CJK IDEO.TEL.31th	*/
+#ifdef SHOJI_IS_RIGHT
+	  {  { 0x4E00 }, { 0,1,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x4E05 }, { 0,1,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x4E06 }, { 0,1,0 }  },  /* CJK UNI.IDEO.NON-J	*/
+	  {  { 0x4E07 }, { 0,1,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x4FFF }, { 0,1,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x9000 }, { 0,1,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x9006 }, { 0,1,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x9007 }, { 0,1,0 }  },  /* CJK UNI.IDEO.NON-J	*/
+	  {  { 0x9FA4 }, { 0,1,0 }  },  /* CJK UNI.IDEO.NON-J	*/
+	  {  { 0x9FA5 }, { 0,1,0 }  },  /* CJK UNI.IDEO.	*/
+#else
+	  {  { 0x4E00 }, { 0,0,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x4E05 }, { 0,0,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x4E06 }, { 0,0,0 }  },  /* CJK UNI.IDEO.NON-J	*/
+	  {  { 0x4E07 }, { 0,0,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x4FFF }, { 0,0,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x9000 }, { 0,0,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x9006 }, { 0,0,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x9007 }, { 0,0,0 }  },  /* CJK UNI.IDEO.NON-J	*/
+	  {  { 0x9FA4 }, { 0,0,0 }  },  /* CJK UNI.IDEO.NON-J	*/
+	  {  { 0x9FA5 }, { 0,0,0 }  },  /* CJK UNI.IDEO.	*/
+#endif
+	  {  { 0xFE4F }, { 0,1,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0xFF0F }, { 0,1,0 }  },  /* FULL SLASH		*/
+#ifdef SHOJI_IS_RIGHT
+	  {  { 0xFF19 }, { 0,1,0 }  },  /* FULL 9		*/
+#else
+	  {  { 0xFF19 }, { 0,0,0 }  },  /* FULL 9		*/
+#endif
+	  {  { 0xFF20 }, { 0,1,0 }  },  /* FULL @		*/
+	  {  { 0xFF3A }, { 0,0,0 }  },  /* FULL Z		*/
+	  {  { 0xFF40 }, { 0,1,0 }  },  /* FULL GRAVE ACC.	*/
+	  {  { 0xFF5A }, { 0,0,0 }  },  /* FULL z		*/
+	  {  { 0xFF5E }, { 0,1,0 }  },  /* FULL ~ (tilde)	*/
+	  {  { 0xFF61 }, { 0,1,0 }  },  /* HALF IDEO.STOP. .	*/
+	  {  { 0xFF65 }, { 0,1,0 }  },  /* HALF KATA MID.DOT	*/
+#ifdef SHOJI_IS_RIGHT
+	  {  { 0xFF66 }, { 0,1,0 }  },  /* HALF KATA WO		*/
+	  {  { 0xFF6F }, { 0,1,0 }  },  /* HALF KATA tu		*/
+	  {  { 0xFF70 }, { 0,1,0 }  },  /* HALF KATA PL -	*/
+	  {  { 0xFF71 }, { 0,1,0 }  },  /* HALF KATA A		*/
+	  {  { 0xFF9E }, { 0,1,0 }  },  /* HALF KATA MI		*/
+#else
+	  {  { 0xFF66 }, { 0,0,0 }  },  /* HALF KATA WO		*/
+	  {  { 0xFF6F }, { 0,0,0 }  },  /* HALF KATA tu		*/
+	  {  { 0xFF70 }, { 0,0,0 }  },  /* HALF KATA PL -	*/
+	  {  { 0xFF71 }, { 0,0,0 }  },  /* HALF KATA A		*/
+	  {  { 0xFF9E }, { 0,0,0 }  },  /* HALF KATA MI		*/
+#endif
+	  {  .is_last = 1 }		  /* last element    */
+	}
+    },
+    {	TST_ISW_REC (end, alpha) }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswcntrl.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswcntrl.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswcntrl.c	(revision 2036)
@@ -0,0 +1,121 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_iswcntrl.c
+ *
+ *	 ISW*:	int iswcntrl (wint_t wc);
+ */
+
+
+#include "dat_isw-funcs.h"
+
+
+TST_ISW_LOC (CNTRL, cntrl) = {
+
+    {	TST_ISW_REC (de, cntrl)
+	{
+	  {  { 0x0080 }, { 0,0,0 }  },  /* CTRL     */
+	  {  { 0x009F }, { 0,0,0 }  },  /* CTRL     */
+	  {  { 0x00A0 }, { 0,1,0 }  },  /* NB SPACE */
+	  {  { 0x00A1 }, { 0,1,0 }  },  /* UD !     */
+	  {  { 0x00B0 }, { 0,1,0 }  },  /* Degree   */
+	  {  { 0x00B1 }, { 0,1,0 }  },  /* +- sign  */
+	  {  { 0x00B2 }, { 0,1,0 }  },  /* SUP 2    */
+	  {  { 0x00B3 }, { 0,1,0 }  },  /* SUP 3    */
+	  {  { 0x00B4 }, { 0,1,0 }  },  /* ACUTE    */
+	  {  { 0x00B8 }, { 0,1,0 }  },  /* CEDILLA  */
+	  {  { 0x00B9 }, { 0,1,0 }  },  /* SUP 1    */
+	  {  { 0x00BB }, { 0,1,0 }  },  /* >>	      */
+	  {  { 0x00BC }, { 0,1,0 }  },  /* 1/4      */
+	  {  { 0x00BD }, { 0,1,0 }  },  /* 1/2      */
+	  {  { 0x00BE }, { 0,1,0 }  },  /* 3/4      */
+	  {  { 0x00BF }, { 0,1,0 }  },  /* UD ?     */
+	  {  { 0x00C0 }, { 0,1,0 }  },  /* A Grave  */
+	  {  { 0x00D6 }, { 0,1,0 }  },  /* O dia    */
+	  {  { 0x00D7 }, { 0,1,0 }  },  /* multipl. */
+	  {  { 0x00D8 }, { 0,1,0 }  },  /* O stroke */
+	  {  { 0x00DF }, { 0,1,0 }  },  /* small Sh */
+	  {  { 0x00E0 }, { 0,1,0 }  },  /* a grave  */
+	  {  { 0x00F6 }, { 0,1,0 }  },  /* o dia    */
+	  {  { 0x00F7 }, { 0,1,0 }  },  /* division */
+	  {  { 0x00F8 }, { 0,1,0 }  },  /* o stroke */
+	  {  { 0x00FF }, { 0,1,0 }  },  /* y dia    */
+	  { .is_last = 1 }		  /* Last element.  */
+	}
+    },
+    {	TST_ISW_REC (enUS, cntrl)
+	{
+	  {  { WEOF   }, { 0,1,0 }  },
+	  {  { 0x0000 }, { 0,0,0 }  },
+	  {  { 0x001F }, { 0,0,0 }  },
+	  {  { 0x0020 }, { 0,1,0 }  },
+	  {  { 0x0021 }, { 0,1,0 }  },
+	  {  { 0x002F }, { 0,1,0 }  },
+	  {  { 0x0030 }, { 0,1,0 }  },
+	  {  { 0x0039 }, { 0,1,0 }  },
+	  {  { 0x003A }, { 0,1,0 }  },
+	  {  { 0x0040 }, { 0,1,0 }  },
+	  {  { 0x0041 }, { 0,1,0 }  },
+	  {  { 0x005A }, { 0,1,0 }  },
+	  {  { 0x005B }, { 0,1,0 }  },
+	  {  { 0x0060 }, { 0,1,0 }  },
+	  {  { 0x0061 }, { 0,1,0 }  },
+	  {  { 0x007A }, { 0,1,0 }  },
+	  {  { 0x007B }, { 0,1,0 }  },
+	  {  { 0x007E }, { 0,1,0 }  },
+	  {  { 0x007F }, { 0,0,0 }  },
+	  {  { 0x0080 }, { 0,0,0 }  },
+	  { .is_last = 1 }		  /* Last element.  */
+	}
+    },
+    {	TST_ISW_REC (eucJP, cntrl)
+	{
+	  {  { 0x3000 }, { 0,1,0 }  },  /* IDEO. SPACE	*/
+	  {  { 0x3020 }, { 0,1,0 }  },  /* POSTAL MARK FACE	*/
+	  {  { 0x3029 }, { 0,1,0 }  },  /* Hangzhou NUM9	*/
+	  {  { 0x302F }, { 0,1,0 }  },  /* Diacritics(Hangul) */
+	  {  { 0x3037 }, { 0,1,0 }  },  /* Separator Symbol	*/
+	  {  { 0x303F }, { 0,1,0 }  },  /* IDEO. HALF SPACE	*/
+	  {  { 0x3041 }, { 0,1,0 }  },  /* HIRAGANA a		*/
+	  {  { 0x3094 }, { 0,1,0 }  },  /* HIRAGANA u"	*/
+	  {  { 0x3099 }, { 0,1,0 }  },  /* SOUND MARK		*/
+	  {  { 0x309E }, { 0,1,0 }  },  /* ITERATION MARK	*/
+	  {  { 0x30A1 }, { 0,1,0 }  },  /* KATAKANA a		*/
+	  {  { 0x30FA }, { 0,1,0 }  },  /* KATAKANA wo"	*/
+	  {  { 0x30FB }, { 0,1,0 }  },  /* KATAKANA MID.DOT	*/
+	  {  { 0x30FE }, { 0,1,0 }  },  /* KATAKANA ITERATION */
+	  {  { 0x3191 }, { 0,1,0 }  },  /* KANBUN REV.MARK	*/
+	  {  { 0x3243 }, { 0,1,0 }  },  /* IDEO. MARK (reach) */
+	  {  { 0x32CB }, { 0,1,0 }  },  /* IDEO.TEL.SYM.DEC12 */
+	  {  { 0x32FE }, { 0,1,0 }  },  /* MARU KATAKANA wo	*/
+	  {  { 0x33FE }, { 0,1,0 }  },  /* CJK IDEO.TEL.31th	*/
+	  {  { 0x4E00 }, { 0,1,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x4E05 }, { 0,1,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x4E06 }, { 0,1,0 }  },  /* CJK UNI.IDEO.NON-J */
+	  {  { 0x4E07 }, { 0,1,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x4FFF }, { 0,1,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x9000 }, { 0,1,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x9006 }, { 0,1,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0x9007 }, { 0,1,0 }  },  /* CJK UNI.IDEO.NON-J */
+	  {  { 0x9FA4 }, { 0,1,0 }  },  /* CJK UNI.IDEO.NON-J */
+	  {  { 0x9FA5 }, { 0,1,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0xFE4F }, { 0,1,0 }  },  /* CJK UNI.IDEO.	*/
+	  {  { 0xFF0F }, { 0,1,0 }  },  /* FULL SLASH		*/
+	  {  { 0xFF19 }, { 0,1,0 }  },  /* FULL 9		*/
+	  {  { 0xFF20 }, { 0,1,0 }  },  /* FULL @		*/
+	  {  { 0xFF3A }, { 0,1,0 }  },  /* FULL Z		*/
+	  {  { 0xFF40 }, { 0,1,0 }  },  /* FULL GRAVE ACC.	*/
+	  {  { 0xFF5A }, { 0,1,0 }  },  /* FULL z		*/
+	  {  { 0xFF5E }, { 0,1,0 }  },  /* FULL ~ (tilde)	*/
+	  {  { 0xFF61 }, { 0,1,0 }  },  /* HALF IDEO.STOP. .	*/
+	  {  { 0xFF65 }, { 0,1,0 }  },  /* HALF KATA MID.DOT	*/
+	  {  { 0xFF66 }, { 0,1,0 }  },  /* HALF KATA WO	*/
+	  {  { 0xFF6F }, { 0,1,0 }  },  /* HALF KATA tu	*/
+	  {  { 0xFF70 }, { 0,1,0 }  },  /* HALF KATA PL -	*/
+	  {  { 0xFF71 }, { 0,1,0 }  },  /* HALF KATA A	*/
+	  {  { 0xFF9E }, { 0,1,0 }  },  /* HALF KATA MI	*/
+	  { .is_last = 1 }		  /* Last element.  */
+	}
+    },
+    {	TST_ISW_REC(end, cntrl) }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswctype.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswctype.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswctype.c	(revision 2036)
@@ -0,0 +1,663 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_iswctype.c
+ *
+ *	 ISWCTYPE:  int iswctype( wint_t wc, wctype_t charclass );
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <wctype.h>
+#include "tst_types.h"
+#include "tgn_locdef.h"
+
+/*
+ *  NOTE:
+ *   Set ret_flg = 1, when a return value is expected to be 0 (FALSE).
+ *   Set ret_flg = 0, when a return value is expected to be non-zero (TRUE).
+ *
+ *   Since the functions return *non*-zero value for TRUE, can't
+ *   compare an actual return value with an expected return value.
+ *   Set the ret_flg=0 for TRUE cases and the tst_isw*() will check
+ *   the non-zero value.
+ *
+ * { { WEOF }, { 0,1,0 } },
+ *		   | |
+ *		   | ret_val: an expected return value
+ *		   ret_flg: if 1, compare an actual return value with the
+ *			    ret_val; if 0, the test program checks
+ *			    the actual return value.
+ */
+
+TST_ISWCTYPE tst_iswctype_loc [] = {
+  {
+    { Tiswctype, TST_LOC_de },
+    {
+      {	 { 0x009F, "alnum"  }, { 0,1,0 }  },	   /* CTRL     */
+      {	 { 0x00A0, "alnum"  }, { 0,1,0 }  },	   /* NB SPACE */
+      {	 { 0x00A1, "alnum"  }, { 0,1,0 }  },	   /* UD !     */
+      {	 { 0x00B1, "alnum"  }, { 0,1,0 }  },	   /* +- sign  */
+      {	 { 0x00B3, "alnum"  }, { 0,1,0 }  },	   /* SUP 3    */
+      {	 { 0x00B4, "alnum"  }, { 0,1,0 }  },	   /* ACUTE    */
+      {	 { 0x00BB, "alnum"  }, { 0,1,0 }  },	   /* >>       */
+      {	 { 0x00BE, "alnum"  }, { 0,1,0 }  },	   /* 3/4      */
+      {	 { 0x00BF, "alnum"  }, { 0,1,0 }  },	   /* UD ?     */
+      {	 { 0x00C0, "alnum"  }, { 0,0,0 }  },	   /* A Grave  */
+      {	 { 0x00D6, "alnum"  }, { 0,0,0 }  },	   /* O dia    */
+      {	 { 0x00D7, "alnum"  }, { 0,1,0 }  },	   /* multipl. */
+      {	 { 0x00D8, "alnum"  }, { 0,0,0 }  },	   /* O stroke */
+      {	 { 0x00DF, "alnum"  }, { 0,0,0 }  },	   /* small Sh */
+      {	 { 0x00E0, "alnum"  }, { 0,0,0 }  },	   /* a grave  */
+      {	 { 0x00F6, "alnum"  }, { 0,0,0 }  },	   /* o dia    */
+      {	 { 0x00F7, "alnum"  }, { 0,1,0 }  },	   /* division */
+      {	 { 0x00F8, "alnum"  }, { 0,0,0 }  },	   /* o stroke */
+      {	 { 0x00FF, "alnum"  }, { 0,0,0 }  },	   /* y dia    */
+      {	 { 0x0080, "alpha"  }, { 0,1,0 }  },	   /* CTRL     */
+      {	 { 0x00A0, "alpha"  }, { 0,1,0 }  },	   /* NB SPACE */
+      {	 { 0x00A1, "alpha"  }, { 0,1,0 }  },	   /* UD !     */
+      {	 { 0x00B1, "alpha"  }, { 0,1,0 }  },	   /* +- sign  */
+      {	 { 0x00B4, "alpha"  }, { 0,1,0 }  },	   /* ACUTE    */
+      {	 { 0x00B8, "alpha"  }, { 0,1,0 }  },	   /* CEDILLA  */
+      {	 { 0x00B9, "alpha"  }, { 0,1,0 }  },	   /* SUP 1    */
+      {	 { 0x00BB, "alpha"  }, { 0,1,0 }  },	   /* >>       */
+      {	 { 0x00BE, "alpha"  }, { 0,1,0 }  },	   /* 3/4      */
+      {	 { 0x00BF, "alpha"  }, { 0,1,0 }  },	   /* UD ?     */
+      {	 { 0x00C0, "alpha"  }, { 0,0,0 }  },	   /* A Grave  */
+      {	 { 0x00D6, "alpha"  }, { 0,0,0 }  },	   /* O dia    */
+      {	 { 0x00D7, "alpha"  }, { 0,1,0 }  },	   /* multipl. */
+      {	 { 0x00D8, "alpha"  }, { 0,0,0 }  },	   /* O stroke */
+      {	 { 0x00DF, "alpha"  }, { 0,0,0 }  },	   /* small Sh */
+      {	 { 0x00E0, "alpha"  }, { 0,0,0 }  },	   /* a grave  */
+      {	 { 0x00F6, "alpha"  }, { 0,0,0 }  },	   /* o dia    */
+      {	 { 0x00F7, "alpha"  }, { 0,1,0 }  },	   /* division */
+      {	 { 0x00F8, "alpha"  }, { 0,0,0 }  },	   /* o stroke */
+      {	 { 0x00FF, "alpha"  }, { 0,0,0 }  },	   /* y dia    */
+      {	 { 0x0080, "cntrl"  }, { 0,0,0 }  },	   /* CTRL     */
+      {	 { 0x009F, "cntrl"  }, { 0,0,0 }  },	   /* CTRL     */
+      {	 { 0x00A0, "cntrl"  }, { 0,1,0 }  },	   /* NB SPACE */
+      {	 { 0x00F6, "cntrl"  }, { 0,1,0 }  },	   /* o dia    */
+      {	 { 0x00FF, "cntrl"  }, { 0,1,0 }  },	   /* y dia    */
+      {	 { 0x00B9, "digit"  }, { 0,1,0 }  },	   /* SUP 1    */
+      {	 { 0x00BE, "digit"  }, { 0,1,0 }  },	   /* 3/4      */
+      {	 { 0x009F, "graph"  }, { 0,1,0 }  },	   /* CTRL     */
+#ifdef SHOJI_IS_RIGHT
+      {	 { 0x00A0, "graph"  }, { 0,1,0 }  },	   /* NB SPACE */
+#else
+      {	 { 0x00A0, "graph"  }, { 0,0,0 }  },	   /* NB SPACE */
+#endif
+      {	 { 0x00A1, "graph"  }, { 0,0,0 }  },	   /* UD !     */
+      {	 { 0x00B1, "graph"  }, { 0,0,0 }  },	   /* +- sign  */
+      {	 { 0x00B3, "graph"  }, { 0,0,0 }  },	   /* SUP 3    */
+      {	 { 0x00B4, "graph"  }, { 0,0,0 }  },	   /* ACUTE    */
+      {	 { 0x00BB, "graph"  }, { 0,0,0 }  },	   /* >>       */
+      {	 { 0x00BE, "graph"  }, { 0,0,0 }  },	   /* 3/4      */
+      {	 { 0x00C0, "graph"  }, { 0,0,0 }  },	   /* A Grave  */
+      {	 { 0x00D6, "graph"  }, { 0,0,0 }  },	   /* O dia    */
+      {	 { 0x00D7, "graph"  }, { 0,0,0 }  },	   /* multipl. */
+      {	 { 0x00D8, "graph"  }, { 0,0,0 }  },	   /* O stroke */
+      {	 { 0x00DF, "graph"  }, { 0,0,0 }  },	   /* small Sh */
+      {	 { 0x00F7, "graph"  }, { 0,0,0 }  },	   /* division */
+      {	 { 0x00F8, "graph"  }, { 0,0,0 }  },	   /* o stroke */
+      {	 { 0x00FF, "graph"  }, { 0,0,0 }  },	   /* y dia    */
+      {	 { 0x009F, "print"  }, { 0,1,0 }  },	   /* CTRL     */
+#ifdef SHOJI_IS_RIGHT
+      {	 { 0x00A0, "print"  }, { 0,1,0 }  },	   /* NB SPACE */
+#else
+      {	 { 0x00A0, "print"  }, { 0,0,0 }  },	   /* NB SPACE */
+#endif
+      {	 { 0x00A1, "print"  }, { 0,0,0 }  },	   /* UD !     */
+      {	 { 0x00B1, "print"  }, { 0,0,0 }  },	   /* +- sign  */
+      {	 { 0x00B4, "print"  }, { 0,0,0 }  },	   /* ACUTE    */
+      {	 { 0x00B8, "print"  }, { 0,0,0 }  },	   /* CEDILLA  */
+      {	 { 0x00B9, "print"  }, { 0,0,0 }  },	   /* SUP 1    */
+      {	 { 0x00BB, "print"  }, { 0,0,0 }  },	   /* >>       */
+      {	 { 0x00BE, "print"  }, { 0,0,0 }  },	   /* 3/4      */
+      {	 { 0x00C0, "print"  }, { 0,0,0 }  },	   /* A Grave  */
+      {	 { 0x00DF, "print"  }, { 0,0,0 }  },	   /* small Sh */
+      {	 { 0x00F6, "print"  }, { 0,0,0 }  },	   /* o dia    */
+      {	 { 0x00F7, "print"  }, { 0,0,0 }  },	   /* division */
+      {	 { 0x00F8, "print"  }, { 0,0,0 }  },	   /* o stroke */
+      {	 { 0x00FF, "print"  }, { 0,0,0 }  },	   /* y dia    */
+      {	 { 0x009F, "punct"  }, { 0,1,0 }  },	   /* CTRL     */
+#ifdef SHOJI_IS_RIGHT
+      {	 { 0x00A0, "punct"  }, { 0,1,0 }  },	   /* NB SPACE */
+#else
+      {	 { 0x00A0, "punct"  }, { 0,0,0 }  },	   /* NB SPACE */
+#endif
+      {	 { 0x00A1, "punct"  }, { 0,0,0 }  },	   /* UD !     */
+      {	 { 0x00B0, "punct"  }, { 0,0,0 }  },	   /* Degree   */
+      {	 { 0x00B1, "punct"  }, { 0,0,0 }  },	   /* +- sign  */
+      {	 { 0x00B2, "punct"  }, { 0,0,0 }  },	   /* SUP 2    */
+      {	 { 0x00B3, "punct"  }, { 0,0,0 }  },	   /* SUP 3    */
+      {	 { 0x00B4, "punct"  }, { 0,0,0 }  },	   /* ACUTE    */
+      {	 { 0x00B8, "punct"  }, { 0,0,0 }  },	   /* CEDILLA  */
+      {	 { 0x00B9, "punct"  }, { 0,0,0 }  },	   /* SUP 1    */
+      {	 { 0x00BB, "punct"  }, { 0,0,0 }  },	   /* >>       */
+      {	 { 0x00BC, "punct"  }, { 0,0,0 }  },	   /* 1/4      */
+      {	 { 0x00BD, "punct"  }, { 0,0,0 }  },	   /* 1/2      */
+      {	 { 0x00BE, "punct"  }, { 0,0,0 }  },	   /* 3/4      */
+      {	 { 0x00BF, "punct"  }, { 0,0,0 }  },	   /* UD ?     */
+      {	 { 0x00C0, "punct"  }, { 0,1,0 }  },	   /* A Grave  */
+      {	 { 0x00D7, "punct"  }, { 0,0,0 }  },	   /* multipl. */
+      {	 { 0x00DF, "punct"  }, { 0,1,0 }  },	   /* small Sh */
+      {	 { 0x00F6, "punct"  }, { 0,1,0 }  },	   /* o dia    */
+      {	 { 0x00F7, "punct"  }, { 0,0,0 }  },	   /* division */
+      {	 { 0x00FF, "punct"  }, { 0,1,0 }  },	   /* y dia    */
+      {	 { 0x009F, "space"  }, { 0,1,0 }  },	   /* CTRL     */
+      {	 { 0x00A0, "space"  }, { 0,1,0 }  },	   /* NB SPACE */
+      {	 { 0x00A1, "space"  }, { 0,1,0 }  },	   /* UD !     */
+      {	 { 0x00B1, "space"  }, { 0,1,0 }  },	   /* +- sign  */
+      {	 { 0x00F8, "space"  }, { 0,1,0 }  },	   /* o stroke */
+      {	 { 0x00B3, "lower"  }, { 0,1,0 }  },	   /* SUP 3    */
+      {	 { 0x00B8, "lower"  }, { 0,1,0 }  },	   /* CEDILLA  */
+      {	 { 0x00BE, "lower"  }, { 0,1,0 }  },	   /* 3/4      */
+      {	 { 0x00C0, "lower"  }, { 0,1,0 }  },	   /* A Grave  */
+      {	 { 0x00D6, "lower"  }, { 0,1,0 }  },	   /* O dia    */
+      {	 { 0x00D8, "lower"  }, { 0,1,0 }  },	   /* O stroke */
+      {	 { 0x00DF, "lower"  }, { 0,0,0 }  },	   /* small Sh */
+      {	 { 0x00E0, "lower"  }, { 0,0,0 }  },	   /* a grave  */
+      {	 { 0x00F6, "lower"  }, { 0,0,0 }  },	   /* o dia    */
+      {	 { 0x00F7, "lower"  }, { 0,1,0 }  },	   /* division */
+      {	 { 0x00F8, "lower"  }, { 0,0,0 }  },	   /* o stroke */
+      {	 { 0x00FF, "lower"  }, { 0,0,0 }  },	   /* y dia    */
+      {	 { 0x00B4, "upper"  }, { 0,1,0 }  },	   /* ACUTE    */
+      {	 { 0x00B8, "upper"  }, { 0,1,0 }  },	   /* CEDILLA  */
+      {	 { 0x00B9, "upper"  }, { 0,1,0 }  },	   /* SUP 1    */
+      {	 { 0x00BE, "upper"  }, { 0,1,0 }  },	   /* 3/4      */
+      {	 { 0x00BF, "upper"  }, { 0,1,0 }  },	   /* UD ?     */
+      {	 { 0x00C0, "upper"  }, { 0,0,0 }  },	   /* A Grave  */
+      {	 { 0x00D6, "upper"  }, { 0,0,0 }  },	   /* O dia    */
+      {	 { 0x00D7, "upper"  }, { 0,1,0 }  },	   /* multipl. */
+      {	 { 0x00D8, "upper"  }, { 0,0,0 }  },	   /* O stroke */
+      {	 { 0x00DF, "upper"  }, { 0,1,0 }  },	   /* small Sh */
+      {	 { 0x00FF, "upper"  }, { 0,1,0 }  },	   /* y dia    */
+      {	 { 0x00B9, "xdigit" }, { 0,1,0 }  },	   /* SUP 1    */
+      {	 { 0x00BC, "xdigit" }, { 0,1,0 }  },	   /* 1/4      */
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Tiswctype, TST_LOC_enUS },
+    {
+      {	 { WEOF,   "alnum"  }, { 0,1,0 }  },
+      {	 { 0x0000, "alnum"  }, { 0,1,0 }  },
+      {	 { 0x001F, "alnum"  }, { 0,1,0 }  },
+      {	 { 0x0020, "alnum"  }, { 0,1,0 }  },
+      {	 { 0x0021, "alnum"  }, { 0,1,0 }  },
+      {	 { 0x002F, "alnum"  }, { 0,1,0 }  },
+      {	 { 0x0030, "alnum"  }, { 0,0,0 }  },
+      {	 { 0x0039, "alnum"  }, { 0,0,0 }  },
+      {	 { 0x003A, "alnum"  }, { 0,1,0 }  },
+      {	 { 0x0040, "alnum"  }, { 0,1,0 }  },
+      {	 { 0x0041, "alnum"  }, { 0,0,0 }  },
+      {	 { 0x005A, "alnum"  }, { 0,0,0 }  },
+      {	 { 0x005B, "alnum"  }, { 0,1,0 }  },
+      {	 { 0x0060, "alnum"  }, { 0,1,0 }  },
+      {	 { 0x0061, "alnum"  }, { 0,0,0 }  },
+      {	 { 0x007A, "alnum"  }, { 0,0,0 }  },
+      {	 { 0x007B, "alnum"  }, { 0,1,0 }  },
+      {	 { 0x007E, "alnum"  }, { 0,1,0 }  },
+      {	 { 0x007F, "alnum"  }, { 0,1,0 }  },
+      {	 { 0x0080, "alnum"  }, { 0,1,0 }  },
+      {	 { 0x0000, "alpha"  }, { 0,1,0 }  },
+      {	 { 0x001F, "alpha"  }, { 0,1,0 }  },
+      {	 { 0x0020, "alpha"  }, { 0,1,0 }  },
+      {	 { 0x0021, "alpha"  }, { 0,1,0 }  },
+      {	 { 0x002F, "alpha"  }, { 0,1,0 }  },
+      {	 { 0x0030, "alpha"  }, { 0,1,0 }  },
+      {	 { 0x0039, "alpha"  }, { 0,1,0 }  },
+      {	 { 0x003A, "alpha"  }, { 0,1,0 }  },
+      {	 { 0x0040, "alpha"  }, { 0,1,0 }  },
+      {	 { 0x0041, "alpha"  }, { 0,0,0 }  },
+      {	 { 0x005A, "alpha"  }, { 0,0,0 }  },
+      {	 { 0x005B, "alpha"  }, { 0,1,0 }  },
+      {	 { 0x0060, "alpha"  }, { 0,1,0 }  },
+      {	 { 0x0061, "alpha"  }, { 0,0,0 }  },
+      {	 { 0x007A, "alpha"  }, { 0,0,0 }  },
+      {	 { 0x007B, "alpha"  }, { 0,1,0 }  },
+      {	 { 0x007E, "alpha"  }, { 0,1,0 }  },
+      {	 { 0x007F, "alpha"  }, { 0,1,0 }  },
+      {	 { 0x0080, "alpha"  }, { 0,1,0 }  },
+      {	 { 0x0009, "blank"  }, { 0,0,0 }  },
+      {	 { 0x000B, "blank"  }, { 0,1,0 }  },
+      {	 { 0x0020, "blank"  }, { 0,0,0 }  },
+      {	 { 0x0000, "cntrl"  }, { 0,0,0 }  },
+      {	 { 0x001F, "cntrl"  }, { 0,0,0 }  },
+      {	 { 0x0020, "cntrl"  }, { 0,1,0 }  },
+      {	 { 0x0021, "cntrl"  }, { 0,1,0 }  },
+      {	 { 0x002F, "cntrl"  }, { 0,1,0 }  },
+      {	 { 0x0030, "cntrl"  }, { 0,1,0 }  },
+      {	 { 0x0039, "cntrl"  }, { 0,1,0 }  },
+      {	 { 0x003A, "cntrl"  }, { 0,1,0 }  },
+      {	 { 0x0040, "cntrl"  }, { 0,1,0 }  },
+      {	 { 0x0041, "cntrl"  }, { 0,1,0 }  },
+      {	 { 0x005A, "cntrl"  }, { 0,1,0 }  },
+      {	 { 0x005B, "cntrl"  }, { 0,1,0 }  },
+      {	 { 0x0060, "cntrl"  }, { 0,1,0 }  },
+      {	 { 0x0061, "cntrl"  }, { 0,1,0 }  },
+      {	 { 0x007A, "cntrl"  }, { 0,1,0 }  },
+      {	 { 0x007B, "cntrl"  }, { 0,1,0 }  },
+      {	 { 0x007E, "cntrl"  }, { 0,1,0 }  },
+      {	 { 0x007F, "cntrl"  }, { 0,0,0 }  },
+      {	 { 0x0080, "cntrl"  }, { 0,0,0 }  },
+      {	 { 0x0000, "digit"  }, { 0,1,0 }  },
+      {	 { 0x001F, "digit"  }, { 0,1,0 }  },
+      {	 { 0x0020, "digit"  }, { 0,1,0 }  },
+      {	 { 0x0021, "digit"  }, { 0,1,0 }  },
+      {	 { 0x002F, "digit"  }, { 0,1,0 }  },
+      {	 { 0x0030, "digit"  }, { 0,0,0 }  },
+      {	 { 0x0039, "digit"  }, { 0,0,0 }  },
+      {	 { 0x003A, "digit"  }, { 0,1,0 }  },
+      {	 { 0x0040, "digit"  }, { 0,1,0 }  },
+      {	 { 0x0041, "digit"  }, { 0,1,0 }  },
+      {	 { 0x005A, "digit"  }, { 0,1,0 }  },
+      {	 { 0x005B, "digit"  }, { 0,1,0 }  },
+      {	 { 0x0060, "digit"  }, { 0,1,0 }  },
+      {	 { 0x0061, "digit"  }, { 0,1,0 }  },
+      {	 { 0x007A, "digit"  }, { 0,1,0 }  },
+      {	 { 0x007B, "digit"  }, { 0,1,0 }  },
+      {	 { 0x007E, "digit"  }, { 0,1,0 }  },
+      {	 { 0x007F, "digit"  }, { 0,1,0 }  },
+      {	 { 0x0080, "digit"  }, { 0,1,0 }  },
+      {	 { 0x0000, "graph"  }, { 0,1,0 }  },
+      {	 { 0x001F, "graph"  }, { 0,1,0 }  },
+      {	 { 0x0020, "graph"  }, { 0,1,0 }  },
+      {	 { 0x0021, "graph"  }, { 0,0,0 }  },
+      {	 { 0x002F, "graph"  }, { 0,0,0 }  },
+      {	 { 0x0030, "graph"  }, { 0,0,0 }  },
+      {	 { 0x0039, "graph"  }, { 0,0,0 }  },
+      {	 { 0x003A, "graph"  }, { 0,0,0 }  },
+      {	 { 0x0040, "graph"  }, { 0,0,0 }  },
+      {	 { 0x0041, "graph"  }, { 0,0,0 }  },
+      {	 { 0x005A, "graph"  }, { 0,0,0 }  },
+      {	 { 0x005B, "graph"  }, { 0,0,0 }  },
+      {	 { 0x0060, "graph"  }, { 0,0,0 }  },
+      {	 { 0x0061, "graph"  }, { 0,0,0 }  },
+      {	 { 0x007A, "graph"  }, { 0,0,0 }  },
+      {	 { 0x007B, "graph"  }, { 0,0,0 }  },
+      {	 { 0x007E, "graph"  }, { 0,0,0 }  },
+      {	 { 0x007F, "graph"  }, { 0,1,0 }  },
+      {	 { 0x0080, "graph"  }, { 0,1,0 }  },
+      {	 { 0x0000, "print"  }, { 0,1,0 }  },
+      {	 { 0x001F, "print"  }, { 0,1,0 }  },
+      {	 { 0x0020, "print"  }, { 0,0,0 }  },
+      {	 { 0x0021, "print"  }, { 0,0,0 }  },
+      {	 { 0x002F, "print"  }, { 0,0,0 }  },
+      {	 { 0x0030, "print"  }, { 0,0,0 }  },
+      {	 { 0x0039, "print"  }, { 0,0,0 }  },
+      {	 { 0x003A, "print"  }, { 0,0,0 }  },
+      {	 { 0x0040, "print"  }, { 0,0,0 }  },
+      {	 { 0x0041, "print"  }, { 0,0,0 }  },
+      {	 { 0x005A, "print"  }, { 0,0,0 }  },
+      {	 { 0x005B, "print"  }, { 0,0,0 }  },
+      {	 { 0x0060, "print"  }, { 0,0,0 }  },
+      {	 { 0x0061, "print"  }, { 0,0,0 }  },
+      {	 { 0x007A, "print"  }, { 0,0,0 }  },
+      {	 { 0x007B, "print"  }, { 0,0,0 }  },
+      {	 { 0x007E, "print"  }, { 0,0,0 }  },
+      {	 { 0x007F, "print"  }, { 0,1,0 }  },
+      {	 { 0x0080, "print"  }, { 0,1,0 }  },
+      {	 { 0x0000, "punct"  }, { 0,1,0 }  },
+      {	 { 0x001F, "punct"  }, { 0,1,0 }  },
+      {	 { 0x0020, "punct"  }, { 0,1,0 }  },
+      {	 { 0x0021, "punct"  }, { 0,0,0 }  },
+      {	 { 0x002F, "punct"  }, { 0,0,0 }  },
+      {	 { 0x0030, "punct"  }, { 0,1,0 }  },
+      {	 { 0x0039, "punct"  }, { 0,1,0 }  },
+      {	 { 0x003A, "punct"  }, { 0,0,0 }  },
+      {	 { 0x0040, "punct"  }, { 0,0,0 }  },
+      {	 { 0x0041, "punct"  }, { 0,1,0 }  },
+      {	 { 0x005A, "punct"  }, { 0,1,0 }  },
+      {	 { 0x005B, "punct"  }, { 0,0,0 }  },
+      {	 { 0x0060, "punct"  }, { 0,0,0 }  },
+      {	 { 0x0061, "punct"  }, { 0,1,0 }  },
+      {	 { 0x007A, "punct"  }, { 0,1,0 }  },
+      {	 { 0x007B, "punct"  }, { 0,0,0 }  },
+      {	 { 0x007E, "punct"  }, { 0,0,0 }  },
+      {	 { 0x007F, "punct"  }, { 0,1,0 }  },
+      {	 { 0x0080, "punct"  }, { 0,1,0 }  },
+      {	 { 0x0000, "space"  }, { 0,1,0 }  },
+      {	 { 0x001F, "space"  }, { 0,1,0 }  },
+      {	 { 0x0020, "space"  }, { 0,0,0 }  },
+      {	 { 0x0021, "space"  }, { 0,1,0 }  },
+      {	 { 0x002F, "space"  }, { 0,1,0 }  },
+      {	 { 0x007E, "space"  }, { 0,1,0 }  },
+      {	 { 0x007F, "space"  }, { 0,1,0 }  },
+      {	 { 0x0080, "space"  }, { 0,1,0 }  },
+      {	 { 0x0000, "lower"  }, { 0,1,0 }  },
+      {	 { 0x001F, "lower"  }, { 0,1,0 }  },
+      {	 { 0x0020, "lower"  }, { 0,1,0 }  },
+      {	 { 0x0021, "lower"  }, { 0,1,0 }  },
+      {	 { 0x002F, "lower"  }, { 0,1,0 }  },
+      {	 { 0x0030, "lower"  }, { 0,1,0 }  },
+      {	 { 0x0039, "lower"  }, { 0,1,0 }  },
+      {	 { 0x003A, "lower"  }, { 0,1,0 }  },
+      {	 { 0x0040, "lower"  }, { 0,1,0 }  },
+      {	 { 0x0041, "lower"  }, { 0,1,0 }  },
+      {	 { 0x005A, "lower"  }, { 0,1,0 }  },
+      {	 { 0x005B, "lower"  }, { 0,1,0 }  },
+      {	 { 0x0060, "lower"  }, { 0,1,0 }  },
+      {	 { 0x0061, "lower"  }, { 0,0,0 }  },
+      {	 { 0x007A, "lower"  }, { 0,0,0 }  },
+      {	 { 0x007B, "lower"  }, { 0,1,0 }  },
+      {	 { 0x007E, "lower"  }, { 0,1,0 }  },
+      {	 { 0x007F, "lower"  }, { 0,1,0 }  },
+      {	 { 0x0080, "lower"  }, { 0,1,0 }  },
+      {	 { 0x0000, "upper"  }, { 0,1,0 }  },
+      {	 { 0x001F, "upper"  }, { 0,1,0 }  },
+      {	 { 0x0020, "upper"  }, { 0,1,0 }  },
+      {	 { 0x0021, "upper"  }, { 0,1,0 }  },
+      {	 { 0x002F, "upper"  }, { 0,1,0 }  },
+      {	 { 0x0030, "upper"  }, { 0,1,0 }  },
+      {	 { 0x0039, "upper"  }, { 0,1,0 }  },
+      {	 { 0x003A, "upper"  }, { 0,1,0 }  },
+      {	 { 0x0040, "upper"  }, { 0,1,0 }  },
+      {	 { 0x0041, "upper"  }, { 0,0,0 }  },
+      {	 { 0x005A, "upper"  }, { 0,0,0 }  },
+      {	 { 0x005B, "upper"  }, { 0,1,0 }  },
+      {	 { 0x0060, "upper"  }, { 0,1,0 }  },
+      {	 { 0x0061, "upper"  }, { 0,1,0 }  },
+      {	 { 0x007A, "upper"  }, { 0,1,0 }  },
+      {	 { 0x007B, "upper"  }, { 0,1,0 }  },
+      {	 { 0x007E, "upper"  }, { 0,1,0 }  },
+      {	 { 0x007F, "upper"  }, { 0,1,0 }  },
+      {	 { 0x0080, "upper"  }, { 0,1,0 }  },
+      {	 { 0x0000, "xdigit" }, { 0,1,0 }  },
+      {	 { 0x001F, "xdigit" }, { 0,1,0 }  },
+      {	 { 0x0020, "xdigit" }, { 0,1,0 }  },
+      {	 { 0x0021, "xdigit" }, { 0,1,0 }  },
+      {	 { 0x002F, "xdigit" }, { 0,1,0 }  },
+      {	 { 0x0030, "xdigit" }, { 0,0,0 }  },
+      {	 { 0x0039, "xdigit" }, { 0,0,0 }  },
+      {	 { 0x003A, "xdigit" }, { 0,1,0 }  },
+      {	 { 0x0040, "xdigit" }, { 0,1,0 }  },
+      {	 { 0x0041, "xdigit" }, { 0,0,0 }  },
+      {	 { 0x005A, "xdigit" }, { 0,1,0 }  },
+      {	 { 0x005B, "xdigit" }, { 0,1,0 }  },
+      {	 { 0x0060, "xdigit" }, { 0,1,0 }  },
+      {	 { 0x0061, "xdigit" }, { 0,0,0 }  },
+      {	 { 0x007A, "xdigit" }, { 0,1,0 }  },
+      {	 { 0x007B, "xdigit" }, { 0,1,0 }  },
+      {	 { 0x007E, "xdigit" }, { 0,1,0 }  },
+      {	 { 0x007F, "xdigit" }, { 0,1,0 }  },
+      {	 { 0x0080, "xdigit" }, { 0,1,0 }  },
+      {	 { 0x0061, "xxxxxx" }, { 0,1,0 }  },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Tiswctype, TST_LOC_eucJP },
+    {
+#ifdef SHOJI_IS_RIGHT
+      {	 { 0x3029, "alnum"  }, { 0,1,0 }  },	   /* Hangzhou NUM9	 */
+#else
+      {	 { 0x3029, "alnum"  }, { 0,0,0 }  },	   /* Hangzhou NUM9	 */
+#endif
+      {	 { 0xFE4F, "alnum"  }, { 0,1,0 }  },	   /* CJK UNI.IDEO.	 */
+      {	 { 0xFF19, "alnum"  }, { 0,0,0 }  },	   /* FULL 9		 */
+      {	 { 0xFF20, "alnum"  }, { 0,1,0 }  },	   /* FULL @		 */
+      {	 { 0xFF3A, "alnum"  }, { 0,0,0 }  },	   /* FULL Z		 */
+      {	 { 0xFF40, "alnum"  }, { 0,1,0 }  },	   /* FULL GRAVE ACC.	 */
+      {	 { 0xFF5A, "alnum"  }, { 0,0,0 }  },	   /* FULL z		 */
+#ifdef SHOJI_IS_RIGHT
+      {	 { 0xFF71, "alnum"  }, { 0,1,0 }  },	   /* HALF KATA A	 */
+#else
+      {	 { 0xFF71, "alnum"  }, { 0,0,0 }  },	   /* HALF KATA A	 */
+#endif
+#ifdef SHOJI_IS_RIGHT
+      {	 { 0x3029, "alpha"  }, { 0,1,0 }  },	   /* Hangzhou NUM9	 */
+#else
+      {	 { 0x3029, "alpha"  }, { 0,0,0 }  },	   /* Hangzhou NUM9	 */
+#endif
+      {	 { 0xFE4F, "alpha"  }, { 0,1,0 }  },	   /* CJK UNI.IDEO.	 */
+#ifdef SHOJI_IS_RIGHT
+      {	 { 0xFF19, "alpha"  }, { 0,1,0 }  },	   /* FULL 9		 */
+#else
+      {	 { 0xFF19, "alpha"  }, { 0,0,0 }  },	   /* FULL 9		 */
+#endif
+      {	 { 0xFF20, "alpha"  }, { 0,1,0 }  },	   /* FULL @		 */
+      {	 { 0xFF3A, "alpha"  }, { 0,0,0 }  },	   /* FULL Z		 */
+      {	 { 0xFF40, "alpha"  }, { 0,1,0 }  },	   /* FULL GRAVE ACC.	 */
+      {	 { 0xFF5A, "alpha"  }, { 0,0,0 }  },	   /* FULL z		 */
+#ifdef SHOJI_IS_RIGHT
+      {	 { 0xFF71, "alpha"  }, { 0,1,0 }  },	   /* HALF KATA A	 */
+#else
+      {	 { 0xFF71, "alpha"  }, { 0,0,0 }  },	   /* HALF KATA A	 */
+#endif
+      {	 { 0x0080, "cntrl"  }, { 0,0,0 }  },	   /* CNTRL		 */
+      {	 { 0x3000, "cntrl"  }, { 0,1,0 }  },	   /* IDEO. SPACE	 */
+      {	 { 0x3029, "digit"  }, { 0,1,0 }  },	   /* Hangzhou NUM9	 */
+      {	 { 0x32CB, "digit"  }, { 0,1,0 }  },	   /* IDEO.TEL.SYM.DEC12 */
+      /* 21: */
+      {	 { 0x33FE, "digit"  }, { 0,1,0 }  },	   /* CJK IDEO.TEL.31th	 */
+      {	 { 0xFF19, "digit"  }, { 0,1,0 }  },	   /* FULL 9		 */
+      {	 { 0x3000, "graph"  }, { 0,1,0 }  },	   /* IDEO. SPACE	 */
+#ifdef SHOJI_IS_RIGHT
+      {	 { 0x3020, "graph"  }, { 0,1,0 }  },	   /* POSTAL MARK FACE	 */
+      {	 { 0x3029, "graph"  }, { 0,1,0 }  },	   /* Hangzhou NUM9	 */
+      {	 { 0x302F, "graph"  }, { 0,1,0 }  },	   /* Diacritics(Hangul) */
+      {	 { 0x3037, "graph"  }, { 0,1,0 }  },	   /* Separator Symbol	 */
+      {	 { 0x303F, "graph"  }, { 0,1,0 }  },	   /* IDEO. HALF SPACE	 */
+#else
+      {	 { 0x3020, "graph"  }, { 0,0,0 }  },	   /* POSTAL MARK FACE	 */
+      {	 { 0x3029, "graph"  }, { 0,0,0 }  },	   /* Hangzhou NUM9	 */
+      {	 { 0x302F, "graph"  }, { 0,0,0 }  },	   /* Diacritics(Hangul) */
+      {	 { 0x3037, "graph"  }, { 0,0,0 }  },	   /* Separator Symbol	 */
+      {	 { 0x303F, "graph"  }, { 0,0,0 }  },	   /* IDEO. HALF SPACE	 */
+#endif
+      /* 29: */
+      {	 { 0x3041, "graph"  }, { 0,0,0 }  },	   /* HIRAGANA a	 */
+      /* Non jis: */
+#ifdef SHOJI_IS_RIGHT
+      {	 { 0x3094, "graph"  }, { 0,1,0 }  },	   /* HIRAGANA u"	 */
+#else
+      {	 { 0x3094, "graph"  }, { 0,0,0 }  },	   /* HIRAGANA u"	 */
+#endif
+      /* Non jis: */
+#ifdef SHOJI_IS_RIGHT
+      {	 { 0x3099, "graph"  }, { 0,1,0 }  },	   /* SOUND MARK	 */
+#else
+      {	 { 0x3099, "graph"  }, { 0,0,0 }  },	   /* SOUND MARK	 */
+#endif
+      {	 { 0x309E, "graph"  }, { 0,0,0 }  },	   /* ITERATION MARK	 */
+      /* 33: */
+      {	 { 0x30A1, "graph"  }, { 0,0,0 }  },	   /* KATAKANA a	 */
+      /* Non jis: */
+#ifdef SHOJI_IS_RIGHT
+      {	 { 0x30FA, "graph"  }, { 0,1,0 }  },	   /* KATAKANA wo"	 */
+#else
+      {	 { 0x30FA, "graph"  }, { 0,0,0 }  },	   /* KATAKANA wo"	 */
+#endif
+      {	 { 0x30FB, "graph"  }, { 0,0,0 }  },	   /* KATAKANA MID.DOT	 */
+      {	 { 0x30FE, "graph"  }, { 0,0,0 }  },	   /* KATAKANA ITERATION */
+#ifdef SHOJI_IS_RIGHT
+      {	 { 0x3191, "graph"  }, { 0,1,0 }  },	   /* KANBUN REV.MARK	 */
+      {	 { 0x3243, "graph"  }, { 0,1,0 }  },	   /* IDEO. MARK (reach) */
+      {	 { 0x32CB, "graph"  }, { 0,1,0 }  },	   /* IDEO.TEL.SYM.DEC12 */
+      {	 { 0x32FE, "graph"  }, { 0,1,0 }  },	   /* MARU KATAKANA wo	 */
+      {	 { 0x33FE, "graph"  }, { 0,1,0 }  },	   /* CJK IDEO.TEL.31th	 */
+#else
+      {	 { 0x3191, "graph"  }, { 0,0,0 }  },	   /* KANBUN REV.MARK	 */
+      {	 { 0x3243, "graph"  }, { 0,0,0 }  },	   /* IDEO. MARK (reach) */
+      {	 { 0x32CB, "graph"  }, { 0,0,0 }  },	   /* IDEO.TEL.SYM.DEC12 */
+      {	 { 0x32FE, "graph"  }, { 0,0,0 }  },	   /* MARU KATAKANA wo	 */
+      {	 { 0x33FE, "graph"  }, { 0,0,0 }  },	   /* CJK IDEO.TEL.31th	 */
+#endif
+      {	 { 0x4E00, "graph"  }, { 0,0,0 }  },	   /* CJK UNI.IDEO.	 */
+      {	 { 0x4E05, "graph"  }, { 0,0,0 }  },	   /* CJK UNI.IDEO.	 */
+#ifdef SHOJI_IS_RIGHT
+      {	 { 0x4E06, "graph"  }, { 0,1,0 }  },	   /* CJK UNI.IDEO.NON-J */
+#else
+      {	 { 0x4E06, "graph"  }, { 0,0,0 }  },	   /* CJK UNI.IDEO.NON-J */
+#endif
+      {	 { 0x4E07, "graph"  }, { 0,0,0 }  },	   /* CJK UNI.IDEO.	 */
+      {	 { 0x4FFF, "graph"  }, { 0,0,0 }  },	   /* CJK UNI.IDEO.	 */
+      {	 { 0x9000, "graph"  }, { 0,0,0 }  },	   /* CJK UNI.IDEO.	 */
+      {	 { 0x9006, "graph"  }, { 0,0,0 }  },	   /* CJK UNI.IDEO.	 */
+#ifdef SHOJI_IS_RIGHT
+      {	 { 0x9007, "graph"  }, { 0,1,0 }  },	   /* CJK UNI.IDEO.NON-J */
+      {	 { 0x9FA4, "graph"  }, { 0,1,0 }  },	   /* CJK UNI.IDEO.NON-J */
+#else
+      {	 { 0x9007, "graph"  }, { 0,0,0 }  },	   /* CJK UNI.IDEO.NON-J */
+      {	 { 0x9FA4, "graph"  }, { 0,0,0 }  },	   /* CJK UNI.IDEO.NON-J */
+#endif
+      /* 51 */
+      {	 { 0x9FA5, "graph"  }, { 0,0,0 }  },	   /* CJK UNI.IDEO.	 */
+      /* Non jis: */
+#ifdef SHOJI_IS_RIGHT
+      {	 { 0xFE4F, "graph"  }, { 0,1,0 }  },	   /* CJK UNI.IDEO.	 */
+#else
+      {	 { 0xFE4F, "graph"  }, { 0,0,0 }  },	   /* CJK UNI.IDEO.	 */
+#endif
+      {	 { 0xFF0F, "graph"  }, { 0,0,0 }  },	   /* FULL SLASH	 */
+      {	 { 0xFF19, "graph"  }, { 0,0,0 }  },	   /* FULL 9		 */
+      {	 { 0xFF20, "graph"  }, { 0,0,0 }  },	   /* FULL @		 */
+      {	 { 0xFF3A, "graph"  }, { 0,0,0 }  },	   /* FULL Z		 */
+      {	 { 0xFF40, "graph"  }, { 0,0,0 }  },	   /* FULL GRAVE ACC.	 */
+      {	 { 0xFF5A, "graph"  }, { 0,0,0 }  },	   /* FULL z		 */
+      {	 { 0xFF5E, "graph"  }, { 0,0,0 }  },	   /* FULL ~ (tilde)	 */
+      {	 { 0xFF61, "graph"  }, { 0,0,0 }  },	   /* HALF IDEO.STOP. .	 */
+      {	 { 0xFF65, "graph"  }, { 0,0,0 }  },	   /* HALF KATA MID.DOT	 */
+      {	 { 0xFF66, "graph"  }, { 0,0,0 }  },	   /* HALF KATA WO	 */
+      {	 { 0xFF6F, "graph"  }, { 0,0,0 }  },	   /* HALF KATA tu	 */
+      {	 { 0xFF70, "graph"  }, { 0,0,0 }  },	   /* HALF KATA PL -	 */
+      {	 { 0xFF71, "graph"  }, { 0,0,0 }  },	   /* HALF KATA A	 */
+      {	 { 0xFF9E, "graph"  }, { 0,0,0 }  },	   /* HALF KATA MI	 */
+      {	 { 0x3000, "print"  }, { 0,0,0 }  },	   /* IDEO. SPACE	 */
+#ifdef SHOJI_IS_RIGHT
+      {	 { 0x3020, "print"  }, { 0,1,0 }  },	   /* POSTAL MARK FACE	 */
+      {	 { 0x3029, "print"  }, { 0,1,0 }  },	   /* Hangzhou NUM9	 */
+      {	 { 0x302F, "print"  }, { 0,1,0 }  },	   /* Diacritics(Hangul) */
+      {	 { 0x3037, "print"  }, { 0,1,0 }  },	   /* Separator Symbol	 */
+#else
+      {	 { 0x3020, "print"  }, { 0,0,0 }  },	   /* POSTAL MARK FACE	 */
+      {	 { 0x3029, "print"  }, { 0,0,0 }  },	   /* Hangzhou NUM9	 */
+      {	 { 0x302F, "print"  }, { 0,0,0 }  },	   /* Diacritics(Hangul) */
+      {	 { 0x3037, "print"  }, { 0,0,0 }  },	   /* Separator Symbol	 */
+#endif
+      {	 { 0x4E00, "print"  }, { 0,0,0 }  },	   /* CJK UNI.IDEO.	 */
+      {	 { 0x4E05, "print"  }, { 0,0,0 }  },	   /* CJK UNI.IDEO.	 */
+#ifdef SHOJI_IS_RIGHT
+      {	 { 0x4E06, "print"  }, { 0,1,0 }  },	   /* CJK UNI.IDEO.NON-J */
+#else
+      {	 { 0x4E06, "print"  }, { 0,0,0 }  },	   /* CJK UNI.IDEO.NON-J */
+#endif
+      {	 { 0x4E07, "print"  }, { 0,0,0 }  },	   /* CJK UNI.IDEO.	 */
+      {	 { 0x4FFF, "print"  }, { 0,0,0 }  },	   /* CJK UNI.IDEO.	 */
+      {	 { 0x9000, "print"  }, { 0,0,0 }  },	   /* CJK UNI.IDEO.	 */
+      {	 { 0x9006, "print"  }, { 0,0,0 }  },	   /* CJK UNI.IDEO.	 */
+#ifdef SHOJI_IS_RIGHT
+      {	 { 0x9007, "print"  }, { 0,1,0 }  },	   /* CJK UNI.IDEO.NON-J */
+      {	 { 0x9FA4, "print"  }, { 0,1,0 }  },	   /* CJK UNI.IDEO.NON-J */
+#else
+      {	 { 0x9007, "print"  }, { 0,0,0 }  },	   /* CJK UNI.IDEO.NON-J */
+      {	 { 0x9FA4, "print"  }, { 0,0,0 }  },	   /* CJK UNI.IDEO.NON-J */
+#endif
+      /* 81: */
+      {	 { 0x9FA5, "print"  }, { 0,0,0 }  },	   /* CJK UNI.IDEO.	 */
+      /* Non jis: */
+#ifdef SHOJI_IS_RIGHT
+      {	 { 0xFE4F, "print"  }, { 0,1,0 }  },	   /* CJK UNI.IDEO.	 */
+#else
+      {	 { 0xFE4F, "print"  }, { 0,0,0 }  },	   /* CJK UNI.IDEO.	 */
+#endif
+      {	 { 0x3000, "punct"  }, { 0,1,0 }  },	   /* IDEO. SPACE	 */
+#ifdef SHOJI_IS_RIGHT
+      {	 { 0x3020, "punct"  }, { 0,1,0 }  },	   /* POSTAL MARK FACE	 */
+      {	 { 0x302F, "punct"  }, { 0,1,0 }  },	   /* Diacritics(Hangul) */
+      {	 { 0x3037, "punct"  }, { 0,1,0 }  },	   /* FEED Separator	 */
+      {	 { 0x303F, "punct"  }, { 0,1,0 }  },	   /* IDEO. HALF SPACE	 */
+#else
+      {	 { 0x3020, "punct"  }, { 0,0,0 }  },	   /* POSTAL MARK FACE	 */
+      {	 { 0x302F, "punct"  }, { 0,0,0 }  },	   /* Diacritics(Hangul) */
+      {	 { 0x3037, "punct"  }, { 0,0,0 }  },	   /* FEED Separator	 */
+      {	 { 0x303F, "punct"  }, { 0,0,0 }  },	   /* IDEO. HALF SPACE	 */
+#endif
+      {	 { 0x3041, "punct"  }, { 0,1,0 }  },	   /* HIRAGANA a	 */
+      {	 { 0x3094, "punct"  }, { 0,1,0 }  },	   /* HIRAGANA u"	 */
+      /* 90: */
+#ifdef SHOJI_IS_RIGHT
+      {	 { 0x3099, "punct"  }, { 0,1,0 }  },	   /* SOUND MARK	 */
+#else
+      {	 { 0x3099, "punct"  }, { 0,0,0 }  },	   /* SOUND MARK	 */
+#endif
+      {	 { 0x309E, "punct"  }, { 0,1,0 }  },	   /* ITERATION MARK	 */
+      {	 { 0x30A1, "punct"  }, { 0,1,0 }  },	   /* KATAKANA a	 */
+      {	 { 0x30FA, "punct"  }, { 0,1,0 }  },	   /* KATAKANA wo"	 */
+      {	 { 0x30FB, "punct"  }, { 0,0,0 }  },	   /* KATAKANA MID.DOT	 */
+      /* 95: */
+      {	 { 0x30FE, "punct"  }, { 0,1,0 }  },	   /* KATAKANA ITERATION */
+#ifdef SHOJI_IS_RIGHT
+      {	 { 0x3191, "punct"  }, { 0,1,0 }  },	   /* KANBUN REV.MARK	 */
+      {	 { 0x3243, "punct"  }, { 0,1,0 }  },	   /* IDEO. MARK (reach) */
+      {	 { 0x32CB, "punct"  }, { 0,1,0 }  },	   /* IDEO.TEL.SYM.DEC12 */
+      {	 { 0x32FE, "punct"  }, { 0,1,0 }  },	   /* MARU KATAKANA wo	 */
+      {	 { 0x33FE, "punct"  }, { 0,1,0 }  },	   /* CJK IDEO.TEL.31th	 */
+#else
+      {	 { 0x3191, "punct"  }, { 0,0,0 }  },	   /* KANBUN REV.MARK	 */
+      {	 { 0x3243, "punct"  }, { 0,0,0 }  },	   /* IDEO. MARK (reach) */
+      {	 { 0x32CB, "punct"  }, { 0,0,0 }  },	   /* IDEO.TEL.SYM.DEC12 */
+      {	 { 0x32FE, "punct"  }, { 0,0,0 }  },	   /* MARU KATAKANA wo	 */
+      {	 { 0x33FE, "punct"  }, { 0,0,0 }  },	   /* CJK IDEO.TEL.31th	 */
+#endif
+      {	 { 0x9007, "punct"  }, { 0,1,0 }  },	   /* CJK UNI.IDEO.NON-J */
+      {	 { 0x9FA4, "punct"  }, { 0,1,0 }  },	   /* CJK UNI.IDEO.NON-J */
+      {	 { 0x9FA5, "punct"  }, { 0,1,0 }  },	   /* CJK UNI.IDEO.	 */
+      {	 { 0xFF0F, "punct"  }, { 0,0,0 }  },	   /* FULL SLASH	 */
+      /* 105: */
+      {	 { 0xFF19, "punct"  }, { 0,1,0 }  },	   /* FULL 9		 */
+      {	 { 0xFF20, "punct"  }, { 0,0,0 }  },	   /* FULL @		 */
+      {	 { 0xFF3A, "punct"  }, { 0,1,0 }  },	   /* FULL Z		 */
+      {	 { 0xFF40, "punct"  }, { 0,0,0 }  },	   /* FULL GRAVE ACC.	 */
+      {	 { 0xFF5A, "punct"  }, { 0,1,0 }  },	   /* FULL z		 */
+      {	 { 0xFF5E, "punct"  }, { 0,0,0 }  },	   /* FULL ~ (tilde)	 */
+      {	 { 0xFF61, "punct"  }, { 0,0,0 }  },	   /* HALF IDEO.STOP. .	 */
+      {	 { 0xFF65, "punct"  }, { 0,0,0 }  },	   /* HALF KATA MID.DOT	 */
+      {	 { 0xFF70, "punct"  }, { 0,1,0 }  },	   /* HALF KATA PL -	 */
+      {	 { 0xFF9E, "punct"  }, { 0,1,0 }  },	   /* HALF KATA MI	 */
+      /* 115: */
+      {	 { 0x3000, "space"  }, { 0,0,0 }  },	   /* IDEO. SPACE	 */
+      {	 { 0x303F, "space"  }, { 0,1,0 }  },	   /* IDEO. HALF SPACE	 */
+      {	 { 0x3041, "lower"  }, { 0,1,0 }  },	   /* HIRAGANA a	 */
+      {	 { 0x3094, "lower"  }, { 0,1,0 }  },	   /* HIRAGANA u"	 */
+      {	 { 0x30A1, "lower"  }, { 0,1,0 }  },	   /* KATAKANA a	 */
+      {	 { 0x30FA, "lower"  }, { 0,1,0 }  },	   /* KATAKANA wo"	 */
+      {	 { 0xFF66, "lower"  }, { 0,1,0 }  },	   /* HALF KATA WO	 */
+      {	 { 0xFF6F, "lower"  }, { 0,1,0 }  },	   /* HALF KATA tu	 */
+      {	 { 0xFF70, "lower"  }, { 0,1,0 }  },	   /* HALF KATA PL -	 */
+      /* 124: */
+      {	 { 0xFF71, "lower"  }, { 0,1,0 }  },	   /* HALF KATA A	 */
+      {	 { 0xFF9E, "lower"  }, { 0,1,0 }  },	   /* HALF KATA MI	 */
+      {	 { 0xFF71, "upper"  }, { 0,1,0 }  },	   /* HALF KATA A	 */
+      {	 { 0xFF19, "xdigit" }, { 0,1,0 }  },	   /* FULL 9		 */
+      {	 { 0x3000, "jspace" }, { 0,0,0 }  },	   /* IDEO. SPACE	 */
+      /* Non jis? */
+      {	 { 0x303F, "jspace" }, { 0,1,0 }  },	   /* IDEO.HALF SPACE	 */
+      {	 { 0xFF19, "jdigit" }, { 0,0,0 }  },	   /* FULL 9		 */
+      {	 { 0x3041, "jhira"  }, { 0,0,0 }  },	   /* HIRAGANA a	 */
+      {	 { 0x3094, "jhira"  }, { 0,1,0 }  },	   /* HIRAGANA u"	 */
+      {	 { 0x30A1, "jkata"  }, { 0,0,0 }  },	   /* KATAKANA a	 */
+      /* Non jis: */
+      {	 { 0x30FA, "jkata"  }, { 0,1,0 }  },	   /* KATAKANA wo"	 */
+      {	 { 0xFF66, "jkata"  }, { 0,0,0 }  },	   /* HALF KATA WO	 */
+      {	 { 0xFF6F, "jkata"  }, { 0,0,0 }  },	   /* HALF KATA tu	 */
+      {	 { 0x4E05, "jkanji" }, { 0,0,0 }  },	   /* CJK UNI.IDEO.	 */
+#ifdef SHOJI_IS_RIGHT
+      /* <NO_WAIVER>: */
+      {	 { 0x4E06, "jkanji" }, { 0,1,1 }  },	   /* CJK UNI.IDEO.NON-J */
+#else
+      /* XXX This character does not exist in EUC-JP.  */
+      {	 { 0x4E06, "jkanji" }, { 0,1,0 }  },	   /* CJK UNI.IDEO.NON-J */
+#endif
+      {	 { 0x4E07, "jkanji" }, { 0,0,0 }  },	   /* CJK UNI.IDEO.	 */
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Tiswctype, TST_LOC_end }
+  }
+};
+
+
+/* dat_isw-funcs.c */
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswdigit.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswdigit.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswdigit.c	(revision 2036)
@@ -0,0 +1,121 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_iswdigit.c
+ *
+ *	 ISW*:	int iswdigit (wint_t wc);
+ */
+
+
+#include "dat_isw-funcs.h"
+
+
+TST_ISW_LOC (DIGIT, digit) = {
+
+  {   TST_ISW_REC (de, digit)
+      {
+	{  { 0x0080 }, { 0,1,0 }  },	/* CTRL	    */
+	{  { 0x009F }, { 0,1,0 }  },	/* CTRL	    */
+	{  { 0x00A0 }, { 0,1,0 }  },	/* NB SPACE */
+	{  { 0x00A1 }, { 0,1,0 }  },	/* UD !	    */
+	{  { 0x00B0 }, { 0,1,0 }  },	/* Degree   */
+	{  { 0x00B1 }, { 0,1,0 }  },	/* +- sign  */
+	{  { 0x00B2 }, { 0,1,0 }  },	/* SUP 2    */
+	{  { 0x00B3 }, { 0,1,0 }  },	/* SUP 3    */
+	{  { 0x00B4 }, { 0,1,0 }  },	/* ACUTE    */
+	{  { 0x00B8 }, { 0,1,0 }  },	/* CEDILLA  */
+	{  { 0x00B9 }, { 0,1,0 }  },	/* SUP 1    */
+	{  { 0x00BB }, { 0,1,0 }  },	/* >>	    */
+	{  { 0x00BC }, { 0,1,0 }  },	/* 1/4	    */
+	{  { 0x00BD }, { 0,1,0 }  },	/* 1/2	    */
+	{  { 0x00BE }, { 0,1,0 }  },	/* 3/4	    */
+	{  { 0x00BF }, { 0,1,0 }  },	/* UD ?	    */
+	{  { 0x00C0 }, { 0,1,0 }  },	/* A Grave  */
+	{  { 0x00D6 }, { 0,1,0 }  },	/* O dia    */
+	{  { 0x00D7 }, { 0,1,0 }  },	/* multipl. */
+	{  { 0x00D8 }, { 0,1,0 }  },	/* O stroke */
+	{  { 0x00DF }, { 0,1,0 }  },	/* small Sh */
+	{  { 0x00E0 }, { 0,1,0 }  },	/* a grave  */
+	{  { 0x00F6 }, { 0,1,0 }  },	/* o dia    */
+	{  { 0x00F7 }, { 0,1,0 }  },	/* division */
+	{  { 0x00F8 }, { 0,1,0 }  },	/* o stroke */
+	{  { 0x00FF }, { 0,1,0 }  },	/* y dia    */
+	{ .is_last = 1 }		/* Last element.  */
+      }
+  },
+  {   TST_ISW_REC (enUS, digit)
+      {
+	{  { WEOF   }, { 0,1,0 }  },
+	{  { 0x0000 }, { 0,1,0 }  },
+	{  { 0x001F }, { 0,1,0 }  },
+	{  { 0x0020 }, { 0,1,0 }  },
+	{  { 0x0021 }, { 0,1,0 }  },
+	{  { 0x002F }, { 0,1,0 }  },
+	{  { 0x0030 }, { 0,0,0 }  },
+	{  { 0x0039 }, { 0,0,0 }  },
+	{  { 0x003A }, { 0,1,0 }  },
+	{  { 0x0040 }, { 0,1,0 }  },
+	{  { 0x0041 }, { 0,1,0 }  },
+	{  { 0x005A }, { 0,1,0 }  },
+	{  { 0x005B }, { 0,1,0 }  },
+	{  { 0x0060 }, { 0,1,0 }  },
+	{  { 0x0061 }, { 0,1,0 }  },
+	{  { 0x007A }, { 0,1,0 }  },
+	{  { 0x007B }, { 0,1,0 }  },
+	{  { 0x007E }, { 0,1,0 }  },
+	{  { 0x007F }, { 0,1,0 }  },
+	{  { 0x0080 }, { 0,1,0 }  },
+	{ .is_last = 1 }		/* Last element.  */
+      }
+  },
+  {   TST_ISW_REC (eucJP, digit)
+      {
+	{  { 0x3000 }, { 0,1,0 }  },	/* IDEO. SPACE	      */
+	{  { 0x3020 }, { 0,1,0 }  },	/* POSTAL MARK FACE   */
+	{  { 0x3029 }, { 0,1,0 }  },	/* Hangzhou NUM9      */
+	{  { 0x302F }, { 0,1,0 }  },	/* Diacritics(Hangul) */
+	{  { 0x3037 }, { 0,1,0 }  },	/* Separator Symbol   */
+	{  { 0x303F }, { 0,1,0 }  },	/* IDEO. HALF SPACE   */
+	{  { 0x3041 }, { 0,1,0 }  },	/* HIRAGANA a	      */
+	{  { 0x3094 }, { 0,1,0 }  },	/* HIRAGANA u"	      */
+	{  { 0x3099 }, { 0,1,0 }  },	/* SOUND MARK	      */
+	{  { 0x309E }, { 0,1,0 }  },	/* ITERATION MARK     */
+	{  { 0x30A1 }, { 0,1,0 }  },	/* KATAKANA a	      */
+	{  { 0x30FA }, { 0,1,0 }  },	/* KATAKANA wo"	      */
+	{  { 0x30FB }, { 0,1,0 }  },	/* KATAKANA MID.DOT   */
+	{  { 0x30FE }, { 0,1,0 }  },	/* KATAKANA ITERATION */
+	{  { 0x3191 }, { 0,1,0 }  },	/* KANBUN REV.MARK    */
+	{  { 0x3243 }, { 0,1,0 }  },	/* IDEO. MARK (reach) */
+	{  { 0x32CB }, { 0,1,0 }  },	/* IDEO.TEL.SYM.DEC12 */
+	{  { 0x32FE }, { 0,1,0 }  },	/* MARU KATAKANA wo   */
+	{  { 0x33FE }, { 0,1,0 }  },	/* CJK IDEO.TEL.31th  */
+	{  { 0x4E00 }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x4E05 }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x4E06 }, { 0,1,0 }  },	/* CJK UNI.IDEO.NON-J */
+	{  { 0x4E07 }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x4FFF }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x9000 }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x9006 }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x9007 }, { 0,1,0 }  },	/* CJK UNI.IDEO.NON-J */
+	{  { 0x9FA4 }, { 0,1,0 }  },	/* CJK UNI.IDEO.NON-J */
+	{  { 0x9FA5 }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0xFE4F }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0xFF0F }, { 0,1,0 }  },	/* FULL SLASH	      */
+	{  { 0xFF19 }, { 0,1,0 }  },	/* FULL 9	      */
+	{  { 0xFF20 }, { 0,1,0 }  },	/* FULL @	      */
+	{  { 0xFF3A }, { 0,1,0 }  },	/* FULL Z	      */
+	{  { 0xFF40 }, { 0,1,0 }  },	/* FULL GRAVE ACC.    */
+	{  { 0xFF5A }, { 0,1,0 }  },	/* FULL z	      */
+	{  { 0xFF5E }, { 0,1,0 }  },	/* FULL ~ (tilde)     */
+	{  { 0xFF61 }, { 0,1,0 }  },	/* HALF IDEO.STOP. .  */
+	{  { 0xFF65 }, { 0,1,0 }  },	/* HALF KATA MID.DOT  */
+	{  { 0xFF66 }, { 0,1,0 }  },	/* HALF KATA WO	      */
+	{  { 0xFF6F }, { 0,1,0 }  },	/* HALF KATA tu	      */
+	{  { 0xFF70 }, { 0,1,0 }  },	/* HALF KATA PL -     */
+	{  { 0xFF71 }, { 0,1,0 }  },	/* HALF KATA A	      */
+	{  { 0xFF9E }, { 0,1,0 }  },	/* HALF KATA MI	      */
+	{ .is_last = 1 }		/* Last element.  */
+      }
+  },
+  {   TST_ISW_REC (end, digit) }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswgraph.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswgraph.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswgraph.c	(revision 2036)
@@ -0,0 +1,163 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_iswgraph.c
+ *
+ *	 ISW*:	int iswgraph (wint_t wc);
+ */
+
+
+#include "dat_isw-funcs.h"
+
+
+TST_ISW_LOC (GRAPH, graph) = {
+
+  {   TST_ISW_REC (de, graph)
+      {
+	{  { 0x0080 }, { 0,1,0 }  },	/* CTRL	    */
+	{  { 0x009F }, { 0,1,0 }  },	/* CTRL	    */
+#ifdef SHOJI_IS_RIGHT
+	{  { 0x00A0 }, { 0,1,0 }  },	/* NB SPACE */
+#else
+	{  { 0x00A0 }, { 0,0,0 }  },	/* NB SPACE */
+#endif
+	{  { 0x00A1 }, { 0,0,0 }  },	/* UD !	    */
+	{  { 0x00B0 }, { 0,0,0 }  },	/* Degree   */
+	{  { 0x00B1 }, { 0,0,0 }  },	/* +- sign  */
+	{  { 0x00B2 }, { 0,0,0 }  },	/* SUP 2    */
+	{  { 0x00B3 }, { 0,0,0 }  },	/* SUP 3    */
+	{  { 0x00B4 }, { 0,0,0 }  },	/* ACUTE    */
+	{  { 0x00B8 }, { 0,0,0 }  },	/* CEDILLA  */
+	{  { 0x00B9 }, { 0,0,0 }  },	/* SUP 1    */
+	{  { 0x00BB }, { 0,0,0 }  },	/* >>	    */
+	{  { 0x00BC }, { 0,0,0 }  },	/* 1/4	    */
+	{  { 0x00BD }, { 0,0,0 }  },	/* 1/2	    */
+	{  { 0x00BE }, { 0,0,0 }  },	/* 3/4	    */
+	{  { 0x00BF }, { 0,0,0 }  },	/* UD ?	    */
+	{  { 0x00C0 }, { 0,0,0 }  },	/* A Grave  */
+	{  { 0x00D6 }, { 0,0,0 }  },	/* O dia    */
+	{  { 0x00D7 }, { 0,0,0 }  },	/* multipl. */
+	{  { 0x00D8 }, { 0,0,0 }  },	/* O stroke */
+	{  { 0x00DF }, { 0,0,0 }  },	/* small Sh */
+	{  { 0x00E0 }, { 0,0,0 }  },	/* a grave  */
+	{  { 0x00F6 }, { 0,0,0 }  },	/* o dia    */
+	{  { 0x00F7 }, { 0,0,0 }  },	/* division */
+	{  { 0x00F8 }, { 0,0,0 }  },	/* o stroke */
+	{  { 0x00FF }, { 0,0,0 }  },	/* y dia    */
+	{ .is_last = 1 }		/* Last element.  */
+      }
+  },
+  {   TST_ISW_REC (enUS, graph)
+      {
+	{  { WEOF   }, { 0,1,0 }  },
+	{  { 0x0000 }, { 0,1,0 }  },
+	{  { 0x001F }, { 0,1,0 }  },
+	{  { 0x0020 }, { 0,1,0 }  },
+	{  { 0x0021 }, { 0,0,0 }  },
+	{  { 0x002F }, { 0,0,0 }  },
+	{  { 0x0030 }, { 0,0,0 }  },
+	{  { 0x0039 }, { 0,0,0 }  },
+	{  { 0x003A }, { 0,0,0 }  },
+	{  { 0x0040 }, { 0,0,0 }  },
+	{  { 0x0041 }, { 0,0,0 }  },
+	{  { 0x005A }, { 0,0,0 }  },
+	{  { 0x005B }, { 0,0,0 }  },
+	{  { 0x0060 }, { 0,0,0 }  },
+	{  { 0x0061 }, { 0,0,0 }  },
+	{  { 0x007A }, { 0,0,0 }  },
+	{  { 0x007B }, { 0,0,0 }  },
+	{  { 0x007E }, { 0,0,0 }  },
+	{  { 0x007F }, { 0,1,0 }  },
+	{  { 0x0080 }, { 0,1,0 }  }, /* 20 */
+	{ .is_last = 1 }		/* Last element.  */
+      }
+  },
+  {   TST_ISW_REC( eucJP, graph )
+      {
+	{  { 0x3000 }, { 0,1,0 }  },	/* IDEO. SPACE	      */
+#ifdef SHOJI_IS_RIGHT
+	{  { 0x3020 }, { 0,1,0 }  },	/* POSTAL MARK FACE   */
+	{  { 0x3029 }, { 0,1,0 }  },	/* Hangzhou NUM9      */
+	{  { 0x302F }, { 0,1,0 }  },	/* Diacritics(Hangul) */
+	{  { 0x3037 }, { 0,1,0 }  },	/* Separator Symbol   */
+	{  { 0x303F }, { 0,1,0 }  },	/* IDEO. HALF SPACE   */
+#else
+	{  { 0x3020 }, { 0,0,0 }  },	/* POSTAL MARK FACE   */
+	{  { 0x3029 }, { 0,0,0 }  },	/* Hangzhou NUM9      */
+	{  { 0x302F }, { 0,0,0 }  },	/* Diacritics(Hangul) */
+	{  { 0x3037 }, { 0,0,0 }  },	/* Separator Symbol   */
+	{  { 0x303F }, { 0,0,0 }  },	/* IDEO. HALF SPACE   */
+#endif
+	{  { 0x3041 }, { 0,0,0 }  },	/* HIRAGANA a	      */
+#ifdef SHOJI_IS_RIGHT
+	{  { 0x3094 }, { 0,1,0 }  },	/* HIRAGANA u"	      */  /* non jis */
+	{  { 0x3099 }, { 0,1,0 }  },	/* SOUND MARK	      */
+#else
+	{  { 0x3094 }, { 0,0,0 }  },	/* HIRAGANA u"	      */  /* non jis */
+	{  { 0x3099 }, { 0,0,0 }  },	/* SOUND MARK	      */
+#endif
+	{  { 0x309E }, { 0,0,0 }  },	/* ITERATION MARK     */  /* 10 */
+	{  { 0x30A1 }, { 0,0,0 }  },	/* KATAKANA a	      */
+#ifdef SHOJI_IS_RIGHT
+	{  { 0x30FA }, { 0,1,0 }  },	/* KATAKANA wo"	      */  /* non jis */
+#else
+	{  { 0x30FA }, { 0,0,0 }  },	/* KATAKANA wo"	      */  /* non jis */
+#endif
+	{  { 0x30FB }, { 0,0,0 }  },	/* KATAKANA MID.DOT   */
+	{  { 0x30FE }, { 0,0,0 }  },	/* KATAKANA ITERATION */
+#ifdef SHOJI_IS_RIGHT
+	{  { 0x3191 }, { 0,1,0 }  },	/* KANBUN REV.MARK    */
+	{  { 0x3243 }, { 0,1,0 }  },	/* IDEO. MARK (reach) */
+	{  { 0x32CB }, { 0,1,0 }  },	/* IDEO.TEL.SYM.DEC12 */
+	{  { 0x32FE }, { 0,1,0 }  },	/* MARU KATAKANA wo   */
+	{  { 0x33FE }, { 0,1,0 }  },	/* CJK IDEO.TEL.31th  */
+#else
+	{  { 0x3191 }, { 0,0,0 }  },	/* KANBUN REV.MARK    */
+	{  { 0x3243 }, { 0,0,0 }  },	/* IDEO. MARK (reach) */
+	{  { 0x32CB }, { 0,0,0 }  },	/* IDEO.TEL.SYM.DEC12 */
+	{  { 0x32FE }, { 0,0,0 }  },	/* MARU KATAKANA wo   */
+	{  { 0x33FE }, { 0,0,0 }  },	/* CJK IDEO.TEL.31th  */
+#endif
+	{  { 0x4E00 }, { 0,0,0 }  },	/* CJK UNI.IDEO.      */  /* 20 */
+	{  { 0x4E05 }, { 0,0,0 }  },	/* CJK UNI.IDEO.      */
+#ifdef SHOJI_IS_RIGHT
+	{  { 0x4E06 }, { 0,1,0 }  },	/* CJK UNI.IDEO.NON-J */
+#else
+	{  { 0x4E06 }, { 0,0,0 }  },	/* CJK UNI.IDEO.NON-J */
+#endif
+	{  { 0x4E07 }, { 0,0,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x4FFF }, { 0,0,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x9000 }, { 0,0,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x9006 }, { 0,0,0 }  },	/* CJK UNI.IDEO.      */
+#ifdef SHOJI_IS_RIGHT
+	{  { 0x9007 }, { 0,1,0 }  },	/* CJK UNI.IDEO.NON-J */
+	{  { 0x9FA4 }, { 0,1,0 }  },	/* CJK UNI.IDEO.NON-J */
+#else
+	{  { 0x9007 }, { 0,0,0 }  },	/* CJK UNI.IDEO.NON-J */
+	{  { 0x9FA4 }, { 0,0,0 }  },	/* CJK UNI.IDEO.NON-J */
+#endif
+	{  { 0x9FA5 }, { 0,0,0 }  },	/* CJK UNI.IDEO.      */
+#ifdef SHOJI_IS_RIGHT
+	{  { 0xFE4F }, { 0,1,0 }  },	/* CJK Wave Low Line  */  /* 30 */
+#else
+	{  { 0xFE4F }, { 0,0,0 }  },	/* CJK Wave Low Line  */  /* 30 */
+#endif
+	{  { 0xFF0F }, { 0,0,0 }  },	/* FULL SLASH	      */
+	{  { 0xFF19 }, { 0,0,0 }  },	/* FULL 9	      */
+	{  { 0xFF20 }, { 0,0,0 }  },	/* FULL @	      */
+	{  { 0xFF3A }, { 0,0,0 }  },	/* FULL Z	      */
+	{  { 0xFF40 }, { 0,0,0 }  },	/* FULL GRAVE ACC.    */
+	{  { 0xFF5A }, { 0,0,0 }  },	/* FULL z	      */
+	{  { 0xFF5E }, { 0,0,0 }  },	/* FULL ~ (tilde)     */
+	{  { 0xFF61 }, { 0,0,0 }  },	/* HALF IDEO.STOP. .  */
+	{  { 0xFF65 }, { 0,0,0 }  },	/* HALF KATA MID.DOT  */
+	{  { 0xFF66 }, { 0,0,0 }  },	/* HALF KATA WO	      */
+	{  { 0xFF6F }, { 0,0,0 }  },	/* HALF KATA tu	      */
+	{  { 0xFF70 }, { 0,0,0 }  },	/* HALF KATA PL -     */
+	{  { 0xFF71 }, { 0,0,0 }  },	/* HALF KATA A	      */
+	{  { 0xFF9E }, { 0,0,0 }  },	/* HALF KATA MI	      */
+	{ .is_last = 1 }		/* Last element.  */
+      }
+  },
+  {   TST_ISW_REC (end, graph) }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswlower.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswlower.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswlower.c	(revision 2036)
@@ -0,0 +1,92 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_iswlower.c
+ *
+ *	 ISW*:	int iswlower (wint_t wc);
+ */
+
+
+#include "dat_isw-funcs.h"
+
+
+TST_ISW_LOC (LOWER, lower) = {
+
+  {   TST_ISW_REC (de, lower)
+      {
+	{  { 0x0080 }, { 0,1,0 }  },	/* CTRL	    */
+	{  { 0x009F }, { 0,1,0 }  },	/* CTRL	    */
+	{  { 0x00A0 }, { 0,1,0 }  },	/* NB SPACE */
+	{  { 0x00A1 }, { 0,1,0 }  },	/* UD !	    */
+	{  { 0x00B0 }, { 0,1,0 }  },	/* Degree   */
+	{  { 0x00B1 }, { 0,1,0 }  },	/* +- sign  */
+	{  { 0x00B2 }, { 0,1,0 }  },	/* SUP 2    */
+	{  { 0x00B3 }, { 0,1,0 }  },	/* SUP 3    */
+	{  { 0x00B4 }, { 0,1,0 }  },	/* ACUTE    */
+	{  { 0x00B8 }, { 0,1,0 }  },	/* CEDILLA  */
+	{  { 0x00B9 }, { 0,1,0 }  },	/* SUP 1    */
+	{  { 0x00BB }, { 0,1,0 }  },	/* >>	    */
+	{  { 0x00BC }, { 0,1,0 }  },	/* 1/4	    */
+	{  { 0x00BD }, { 0,1,0 }  },	/* 1/2	    */
+	{  { 0x00BE }, { 0,1,0 }  },	/* 3/4	    */
+	{  { 0x00BF }, { 0,1,0 }  },	/* UD ?	    */
+	{  { 0x00C0 }, { 0,1,0 }  },	/* A Grave  */
+	{  { 0x00D6 }, { 0,1,0 }  },	/* O dia    */
+	{  { 0x00D7 }, { 0,1,0 }  },	/* multipl. */
+	{  { 0x00D8 }, { 0,1,0 }  },	/* O stroke */
+	{  { 0x00DF }, { 0,0,0 }  },	/* small Sh */
+	{  { 0x00E0 }, { 0,0,0 }  },	/* a grave  */
+	{  { 0x00F6 }, { 0,0,0 }  },	/* o dia    */
+	{  { 0x00F7 }, { 0,1,0 }  },	/* division */
+	{  { 0x00F8 }, { 0,0,0 }  },	/* o stroke */
+	{  { 0x00FF }, { 0,0,0 }  },	/* y dia    */
+	{ .is_last = 1 }		/* Last element.  */
+      }
+  },
+  {   TST_ISW_REC (enUS, lower)
+      {
+	{  { WEOF   }, { 0,1,0 }  },
+	{  { 0x0000 }, { 0,1,0 }  },
+	{  { 0x001F }, { 0,1,0 }  },
+	{  { 0x0020 }, { 0,1,0 }  },
+	{  { 0x0021 }, { 0,1,0 }  },
+	{  { 0x002F }, { 0,1,0 }  },
+	{  { 0x0030 }, { 0,1,0 }  },
+	{  { 0x0039 }, { 0,1,0 }  },
+	{  { 0x003A }, { 0,1,0 }  },
+	{  { 0x0040 }, { 0,1,0 }  },
+	{  { 0x0041 }, { 0,1,0 }  },
+	{  { 0x005A }, { 0,1,0 }  },
+	{  { 0x005B }, { 0,1,0 }  },
+	{  { 0x0060 }, { 0,1,0 }  },
+	{  { 0x0061 }, { 0,0,0 }  },
+	{  { 0x007A }, { 0,0,0 }  },
+	{  { 0x007B }, { 0,1,0 }  },
+	{  { 0x007E }, { 0,1,0 }  },
+	{  { 0x007F }, { 0,1,0 }  },
+	{  { 0x0080 }, { 0,1,0 }  },
+	{ .is_last = 1 }		/* Last element.  */
+      }
+  },
+  {   TST_ISW_REC (eucJP, lower)
+      {
+	{  { 0x3000 }, { 0,1,0 }  },	/* IDEO. SPACE	      */
+	{  { 0x303F }, { 0,1,0 }  },	/* IDEO. HALF SPACE   */
+	{  { 0x3041 }, { 0,1,0 }  },	/* HIRAGANA a	      */
+	{  { 0x3094 }, { 0,1,0 }  },	/* HIRAGANA u"	      */
+	{  { 0x3099 }, { 0,1,0 }  },	/* SOUND MARK	      */
+	{  { 0x309E }, { 0,1,0 }  },	/* ITERATION MARK     */
+	{  { 0x30A1 }, { 0,1,0 }  },	/* KATAKANA a	      */
+	{  { 0x30FA }, { 0,1,0 }  },	/* KATAKANA wo"	      */
+	{  { 0xFF3A }, { 0,1,0 }  },	/* FULL Z	      */
+	{  { 0xFF40 }, { 0,1,0 }  },	/* FULL GRAVE ACC.    */
+	{  { 0xFF5A }, { 0,0,0 }  },	/* FULL z	      */
+	{  { 0xFF6F }, { 0,1,0 }  },	/* HALF KATA tu	      */
+	{  { 0xFF71 }, { 0,1,0 }  },	/* HALF KATA A	      */
+	{  { 0xFF9E }, { 0,1,0 }  },	/* HALF KATA MI	      */
+	{ .is_last = 1 }		/* Last element.  */
+      }
+  },
+  {   TST_ISW_REC (end, lower) }
+
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswprint.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswprint.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswprint.c	(revision 2036)
@@ -0,0 +1,166 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *       FILE:  dat_iswprint.c
+ *
+ *       ISW*:  int iswprint (wint_t wc);
+ */
+
+
+#include "dat_isw-funcs.h"
+
+
+TST_ISW_LOC (PRINT, print) = {
+
+  {   TST_ISW_REC (de, print)
+      {
+	{  { 0x0080 }, { 0,1,0 }  },  /* CTRL     */
+	{  { 0x009F }, { 0,1,0 }  },  /* CTRL     */
+#ifdef SHOJI_IS_RIGHT
+	{  { 0x00A0 }, { 0,1,0 }  },  /* NB SPACE */
+#else
+	{  { 0x00A0 }, { 0,0,0 }  },  /* NB SPACE */
+#endif
+	{  { 0x00A1 }, { 0,0,0 }  },  /* UD !     */
+	{  { 0x00B0 }, { 0,0,0 }  },  /* Degree   */
+	{  { 0x00B1 }, { 0,0,0 }  },  /* +- sign  */
+	{  { 0x00B2 }, { 0,0,0 }  },  /* SUP 2    */
+	{  { 0x00B3 }, { 0,0,0 }  },  /* SUP 3    */
+	{  { 0x00B4 }, { 0,0,0 }  },  /* ACUTE    */
+	{  { 0x00B8 }, { 0,0,0 }  },  /* CEDILLA  */
+	{  { 0x00B9 }, { 0,0,0 }  },  /* SUP 1    */
+	{  { 0x00BB }, { 0,0,0 }  },  /* >>       */
+	{  { 0x00BC }, { 0,0,0 }  },  /* 1/4      */
+	{  { 0x00BD }, { 0,0,0 }  },  /* 1/2      */
+	{  { 0x00BE }, { 0,0,0 }  },  /* 3/4      */
+	{  { 0x00BF }, { 0,0,0 }  },  /* UD ?     */
+	{  { 0x00C0 }, { 0,0,0 }  },  /* A Grave  */
+	{  { 0x00D6 }, { 0,0,0 }  },  /* O dia    */
+	{  { 0x00D7 }, { 0,0,0 }  },  /* multipl. */
+	{  { 0x00D8 }, { 0,0,0 }  },  /* O stroke */
+	{  { 0x00DF }, { 0,0,0 }  },  /* small Sh */
+	{  { 0x00E0 }, { 0,0,0 }  },  /* a grave  */
+	{  { 0x00F6 }, { 0,0,0 }  },  /* o dia    */
+	{  { 0x00F7 }, { 0,0,0 }  },  /* division */
+	{  { 0x00F8 }, { 0,0,0 }  },  /* o stroke */
+	{  { 0x00FF }, { 0,0,0 }  },  /* y dia    */
+	{ .is_last = 1 }		/* Last element.  */
+      }
+  },
+  {   TST_ISW_REC (enUS, print)
+      {
+	{  { WEOF   }, { 0,1,0 }  }, /* 01 */
+	{  { 0x0000 }, { 0,1,0 }  },
+	{  { 0x001F }, { 0,1,0 }  },
+	{  { 0x0020 }, { 0,0,0 }  },
+	{  { 0x0021 }, { 0,0,0 }  },
+	{  { 0x002F }, { 0,0,0 }  },
+	{  { 0x0030 }, { 0,0,0 }  },
+	{  { 0x0039 }, { 0,0,0 }  },
+	{  { 0x003A }, { 0,0,0 }  },
+	{  { 0x0040 }, { 0,0,0 }  },
+	{  { 0x0041 }, { 0,0,0 }  },
+	{  { 0x005A }, { 0,0,0 }  },
+	{  { 0x005B }, { 0,0,0 }  },
+	{  { 0x0060 }, { 0,0,0 }  },
+	{  { 0x0061 }, { 0,0,0 }  },
+	{  { 0x007A }, { 0,0,0 }  },
+	{  { 0x007B }, { 0,0,0 }  },
+	{  { 0x007E }, { 0,0,0 }  },
+	{  { 0x007F }, { 0,1,0 }  },
+	{  { 0x0080 }, { 0,1,0 }  }, /* 20 */
+#ifdef NO_WAIVER
+	{  { 0x3042 }, { 0,1,0 }  }, /* <WAIVER> */
+#endif
+	{ .is_last = 1 }		/* Last element.  */
+      }
+  },
+  {   TST_ISW_REC (eucJP, print)
+      {
+	{  { 0x3000 }, { 0,0,0 }  },  /* IDEO. SPACE        */
+#ifdef SHOJI_IS_RIGHT
+	{  { 0x3020 }, { 0,1,0 }  },  /* POSTAL MARK FACE   */
+	{  { 0x3029 }, { 0,1,0 }  },  /* Hangzhou NUM9      */
+	{  { 0x302F }, { 0,1,0 }  },  /* Diacritics(Hangul) */
+	{  { 0x3037 }, { 0,1,0 }  },  /* Separator Symbol   */
+	{  { 0x303F }, { 0,1,0 }  },  /* IDEO. HALF SPACE   */
+#else
+	{  { 0x3020 }, { 0,0,0 }  },  /* POSTAL MARK FACE   */
+	{  { 0x3029 }, { 0,0,0 }  },  /* Hangzhou NUM9      */
+	{  { 0x302F }, { 0,0,0 }  },  /* Diacritics(Hangul) */
+	{  { 0x3037 }, { 0,0,0 }  },  /* Separator Symbol   */
+	{  { 0x303F }, { 0,0,0 }  },  /* IDEO. HALF SPACE   */
+#endif
+	{  { 0x3041 }, { 0,0,0 }  },  /* HIRAGANA a         */
+#ifdef SHOJI_IS_RIGHT
+	{  { 0x3094 }, { 0,1,0 }  },  /* HIRAGANA u"        */  /* non jis */
+	{  { 0x3099 }, { 0,1,0 }  },  /* SOUND MARK         */
+#else
+	{  { 0x3094 }, { 0,0,0 }  },  /* HIRAGANA u"        */  /* non jis */
+	{  { 0x3099 }, { 0,0,0 }  },  /* SOUND MARK         */
+#endif
+	{  { 0x309E }, { 0,0,0 }  },  /* ITERATION MARK     */  /* 10 */
+	{  { 0x30A1 }, { 0,0,0 }  },  /* KATAKANA a         */
+#ifdef SHOJI_IS_RIGHT
+	{  { 0x30FA }, { 0,1,0 }  },  /* KATAKANA wo"       */  /* non jis */
+#else
+	{  { 0x30FA }, { 0,0,0 }  },  /* KATAKANA wo"       */  /* non jis */
+#endif
+	{  { 0x30FB }, { 0,0,0 }  },  /* KATAKANA MID.DOT   */
+	{  { 0x30FE }, { 0,0,0 }  },  /* KATAKANA ITERATION */
+#ifdef SHOJI_IS_RIGHT
+	{  { 0x3191 }, { 0,1,0 }  },  /* KANBUN REV.MARK    */
+	{  { 0x3243 }, { 0,1,0 }  },  /* IDEO. MARK (reach) */
+	{  { 0x32CB }, { 0,1,0 }  },  /* IDEO.TEL.SYM.DEC12 */
+	{  { 0x32FE }, { 0,1,0 }  },  /* MARU KATAKANA wo   */
+	{  { 0x33FE }, { 0,1,0 }  },  /* CJK IDEO.TEL.31th  */
+#else
+	{  { 0x3191 }, { 0,0,0 }  },  /* KANBUN REV.MARK    */
+	{  { 0x3243 }, { 0,0,0 }  },  /* IDEO. MARK (reach) */
+	{  { 0x32CB }, { 0,0,0 }  },  /* IDEO.TEL.SYM.DEC12 */
+	{  { 0x32FE }, { 0,0,0 }  },  /* MARU KATAKANA wo   */
+	{  { 0x33FE }, { 0,0,0 }  },  /* CJK IDEO.TEL.31th  */
+#endif
+	{  { 0x4E00 }, { 0,0,0 }  },  /* CJK UNI.IDEO.      */  /* 20 */
+	{  { 0x4E05 }, { 0,0,0 }  },  /* CJK UNI.IDEO.      */
+#ifdef SHOJI_IS_RIGHT
+	{  { 0x4E06 }, { 0,1,0 }  },  /* CJK UNI.IDEO.NON-J */
+#else
+	{  { 0x4E06 }, { 0,0,0 }  },  /* CJK UNI.IDEO.NON-J */
+#endif
+	{  { 0x4E07 }, { 0,0,0 }  },  /* CJK UNI.IDEO.      */
+	{  { 0x4FFF }, { 0,0,0 }  },  /* CJK UNI.IDEO.      */
+	{  { 0x9000 }, { 0,0,0 }  },  /* CJK UNI.IDEO.      */
+	{  { 0x9006 }, { 0,0,0 }  },  /* CJK UNI.IDEO.      */
+#ifdef SHOJI_IS_RIGHT
+	{  { 0x9007 }, { 0,1,0 }  },  /* CJK UNI.IDEO.NON-J */
+	{  { 0x9FA4 }, { 0,1,0 }  },  /* CJK UNI.IDEO.NON-J */
+#else
+	{  { 0x9007 }, { 0,0,0 }  },  /* CJK UNI.IDEO.NON-J */
+	{  { 0x9FA4 }, { 0,0,0 }  },  /* CJK UNI.IDEO.NON-J */
+#endif
+	{  { 0x9FA5 }, { 0,0,0 }  },  /* CJK UNI.IDEO.      */
+#ifdef SHOJI_IS_RIGHT
+	{  { 0xFE4F }, { 0,1,0 }  },  /* WAVE LOW LINE      */  /* 30 */
+#else
+	{  { 0xFE4F }, { 0,0,0 }  },  /* WAVE LOW LINE      */  /* 30 */
+#endif
+	{  { 0xFF0F }, { 0,0,0 }  },  /* FULL SLASH         */
+	{  { 0xFF19 }, { 0,0,0 }  },  /* FULL 9             */
+	{  { 0xFF20 }, { 0,0,0 }  },  /* FULL @             */
+	{  { 0xFF3A }, { 0,0,0 }  },  /* FULL Z             */
+	{  { 0xFF40 }, { 0,0,0 }  },  /* FULL GRAVE ACC.    */
+	{  { 0xFF5A }, { 0,0,0 }  },  /* FULL z             */
+	{  { 0xFF5E }, { 0,0,0 }  },  /* FULL ~ (tilde)     */
+	{  { 0xFF61 }, { 0,0,0 }  },  /* HALF IDEO.STOP. .  */
+	{  { 0xFF65 }, { 0,0,0 }  },  /* HALF KATA MID.DOT  */
+	{  { 0xFF66 }, { 0,0,0 }  },  /* HALF KATA WO       */  /* 40 */
+	{  { 0xFF6F }, { 0,0,0 }  },  /* HALF KATA tu       */
+	{  { 0xFF70 }, { 0,0,0 }  },  /* HALF KATA PL -     */
+	{  { 0xFF71 }, { 0,0,0 }  },  /* HALF KATA A        */
+	{  { 0xFF9E }, { 0,0,0 }  },  /* HALF KATA MI       */
+	{ .is_last = 1 }		/* Last element.  */
+      }
+  },
+  {   TST_ISW_REC (end, print) }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswpunct.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswpunct.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswpunct.c	(revision 2036)
@@ -0,0 +1,151 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_iswpunct.c
+ *
+ *	 ISW*:	int iswpunct (wint_t wc);
+ */
+
+
+#include "dat_isw-funcs.h"
+
+
+TST_ISW_LOC (PUNCT, punct) = {
+
+  {   TST_ISW_REC (de, punct)
+      {
+	{  { 0x0080 }, { 0,1,0 }  },	/* CTRL	    */
+	{  { 0x009F }, { 0,1,0 }  },	/* CTRL	    */
+#ifdef SHOJI_IS_RIGHT
+	{  { 0x00A0 }, { 0,1,0 }  },	/* NB SPACE */
+#else
+	{  { 0x00A0 }, { 0,0,0 }  },	/* NB SPACE */
+#endif
+	{  { 0x00A1 }, { 0,0,0 }  },	/* UD !	    */
+	{  { 0x00B0 }, { 0,0,0 }  },	/* Degree   */
+	{  { 0x00B1 }, { 0,0,0 }  },	/* +- sign  */
+	{  { 0x00B2 }, { 0,0,0 }  },	/* SUP 2    */
+	{  { 0x00B3 }, { 0,0,0 }  },	/* SUP 3    */
+	{  { 0x00B4 }, { 0,0,0 }  },	/* ACUTE    */
+	{  { 0x00B8 }, { 0,0,0 }  },	/* CEDILLA  */
+	{  { 0x00B9 }, { 0,0,0 }  },	/* SUP 1    */
+	{  { 0x00BB }, { 0,0,0 }  },	/* >>	    */
+	{  { 0x00BC }, { 0,0,0 }  },	/* 1/4	    */
+	{  { 0x00BD }, { 0,0,0 }  },	/* 1/2	    */
+	{  { 0x00BE }, { 0,0,0 }  },	/* 3/4	    */
+	{  { 0x00BF }, { 0,0,0 }  },	/* UD ?	    */
+	{  { 0x00C0 }, { 0,1,0 }  },	/* A Grave  */
+	{  { 0x00D6 }, { 0,1,0 }  },	/* O dia    */
+	{  { 0x00D7 }, { 0,0,0 }  },	/* multipl. */
+	{  { 0x00D8 }, { 0,1,0 }  },	/* O stroke */
+	{  { 0x00DF }, { 0,1,0 }  },	/* small Sh */
+	{  { 0x00E0 }, { 0,1,0 }  },	/* a grave  */
+	{  { 0x00F6 }, { 0,1,0 }  },	/* o dia    */
+	{  { 0x00F7 }, { 0,0,0 }  },	/* division */
+	{  { 0x00F8 }, { 0,1,0 }  },	/* o stroke */
+	{  { 0x00FF }, { 0,1,0 }  },	/* y dia    */
+	{ .is_last = 1 }		/* Last element.  */
+      }
+  },
+  {   TST_ISW_REC (enUS, punct)
+      {
+	{  { WEOF   }, { 0,1,0 }  }, /* 01 */
+	{  { 0x0000 }, { 0,1,0 }  },
+	{  { 0x001F }, { 0,1,0 }  },
+	{  { 0x0020 }, { 0,1,0 }  },
+	{  { 0x0021 }, { 0,0,0 }  },
+	{  { 0x002F }, { 0,0,0 }  },
+	{  { 0x0030 }, { 0,1,0 }  },
+	{  { 0x0039 }, { 0,1,0 }  },
+	{  { 0x003A }, { 0,0,0 }  },
+	{  { 0x0040 }, { 0,0,0 }  },
+	{  { 0x0041 }, { 0,1,0 }  },
+	{  { 0x005A }, { 0,1,0 }  },
+	{  { 0x005B }, { 0,0,0 }  },
+	{  { 0x0060 }, { 0,0,0 }  },
+	{  { 0x0061 }, { 0,1,0 }  },
+	{  { 0x007A }, { 0,1,0 }  },
+	{  { 0x007B }, { 0,0,0 }  },
+	{  { 0x007E }, { 0,0,0 }  },
+	{  { 0x007F }, { 0,1,0 }  },
+	{  { 0x0080 }, { 0,1,0 }  }, /* 20 */
+	{ .is_last = 1 }		/* Last element.  */
+      }
+  },
+  {   TST_ISW_REC (eucJP, punct)
+      {
+	{  { 0x3000 }, { 0,1,0 }  },	/* IDEO. SPACE	      */
+#ifdef SHOJI_IS_RIGHT
+	{  { 0x3020 }, { 0,1,0 }  },	/* POSTAL MARK FACE   */
+#else
+	{  { 0x3020 }, { 0,0,0 }  },	/* POSTAL MARK FACE   */
+#endif
+	{  { 0x3029 }, { 0,1,0 }  },	/* Hangzhou NUM9      */
+#ifdef SHOJI_IS_RIGHT
+	{  { 0x302F }, { 0,1,0 }  },	/* Diacritics(Hangul) */
+	{  { 0x3037 }, { 0,1,0 }  },	/* Separator Symbol   */
+	{  { 0x303F }, { 0,1,0 }  },	/* IDEO. HALF SPACE   */
+#else
+	{  { 0x302F }, { 0,0,0 }  },	/* Diacritics(Hangul) */
+	{  { 0x3037 }, { 0,0,0 }  },	/* Separator Symbol   */
+	{  { 0x303F }, { 0,0,0 }  },	/* IDEO. HALF SPACE   */
+#endif
+	{  { 0x3041 }, { 0,1,0 }  },	/* HIRAGANA a	      */
+	{  { 0x3094 }, { 0,1,0 }  },	/* HIRAGANA u"	      */
+#ifdef SHOJI_IS_RIGHT
+	{  { 0x3099 }, { 0,1,0 }  },	/* SOUND MARK	      */
+#else
+	{  { 0x3099 }, { 0,0,0 }  },	/* SOUND MARK	      */
+#endif
+	{  { 0x309E }, { 0,1,0 }  },	/* ITERATION MARK     */  /* 10 */
+	{  { 0x30A1 }, { 0,1,0 }  },	/* KATAKANA a	      */
+	{  { 0x30FA }, { 0,1,0 }  },	/* KATAKANA wo"	      */
+	{  { 0x30FB }, { 0,0,0 }  },	/* KATAKANA MID.DOT   */
+	{  { 0x30FE }, { 0,1,0 }  },	/* KATAKANA ITERATION */
+#ifdef SHOJI_IS_RIGHT
+	{  { 0x3191 }, { 0,1,0 }  },	/* KANBUN REV.MARK    */
+	{  { 0x3243 }, { 0,1,0 }  },	/* IDEO. MARK (reach) */
+	{  { 0x32CB }, { 0,1,0 }  },	/* IDEO.TEL.SYM.DEC12 */
+	{  { 0x32FE }, { 0,1,0 }  },	/* MARU KATAKANA wo   */
+	{  { 0x33FE }, { 0,1,0 }  },	/* CJK IDEO.TEL.31th  */
+#else
+	{  { 0x3191 }, { 0,0,0 }  },	/* KANBUN REV.MARK    */
+	{  { 0x3243 }, { 0,0,0 }  },	/* IDEO. MARK (reach) */
+	{  { 0x32CB }, { 0,0,0 }  },	/* IDEO.TEL.SYM.DEC12 */
+	{  { 0x32FE }, { 0,0,0 }  },	/* MARU KATAKANA wo   */
+	{  { 0x33FE }, { 0,0,0 }  },	/* CJK IDEO.TEL.31th  */
+#endif
+	{  { 0x4E00 }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */  /* 20 */
+	{  { 0x4E05 }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x4E06 }, { 0,1,0 }  },	/* CJK UNI.IDEO.NON-J */
+	{  { 0x4E07 }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x4FFF }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x9000 }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x9006 }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x9007 }, { 0,1,0 }  },	/* CJK UNI.IDEO.NON-J */
+	{  { 0x9FA4 }, { 0,1,0 }  },	/* CJK UNI.IDEO.NON-J */
+	{  { 0x9FA5 }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+#ifdef SHOJI_IS_RIGHT
+	{  { 0xFE4F }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */  /* 30 */
+#else
+	{  { 0xFE4F }, { 0,0,0 }  },	/* CJK UNI.IDEO.      */  /* 30 */
+#endif
+	{  { 0xFF0F }, { 0,0,0 }  },	/* FULL SLASH	      */
+	{  { 0xFF19 }, { 0,1,0 }  },	/* FULL 9	      */
+	{  { 0xFF20 }, { 0,0,0 }  },	/* FULL @	      */
+	{  { 0xFF3A }, { 0,1,0 }  },	/* FULL Z	      */
+	{  { 0xFF40 }, { 0,0,0 }  },	/* FULL GRAVE ACC.    */
+	{  { 0xFF5A }, { 0,1,0 }  },	/* FULL z	      */
+	{  { 0xFF5E }, { 0,0,0 }  },	/* FULL ~ (tilde)     */
+	{  { 0xFF61 }, { 0,0,0 }  },	/* HALF IDEO.STOP. .  */
+	{  { 0xFF65 }, { 0,0,0 }  },	/* HALF KATA MID.DOT  */
+	{  { 0xFF66 }, { 0,1,0 }  },	/* HALF KATA WO	      */  /* 40 */
+	{  { 0xFF6F }, { 0,1,0 }  },	/* HALF KATA tu	      */
+	{  { 0xFF70 }, { 0,1,0 }  },	/* HALF KATA PL -     */
+	{  { 0xFF71 }, { 0,1,0 }  },	/* HALF KATA A	      */
+	{  { 0xFF9E }, { 0,1,0 }  },	/* HALF KATA MI	      */
+	{ .is_last = 1 }		/* Last element.  */
+      }
+  },
+  {   TST_ISW_REC (end, punct) }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswspace.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswspace.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswspace.c	(revision 2036)
@@ -0,0 +1,125 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_iswspace.c
+ *
+ *	 ISW*:	int iswspace (wint_t wc);
+ */
+
+
+#include "dat_isw-funcs.h"
+
+
+TST_ISW_LOC (SPACE, space) = {
+
+  {   TST_ISW_REC (de, space)
+      {
+	{  { 0x0080 }, { 0,1,0 }  },	/* CTRL	    */
+	{  { 0x009F }, { 0,1,0 }  },	/* CTRL	    */
+	{  { 0x00A0 }, { 0,1,0 }  },	/* NB SPACE */
+	{  { 0x00A1 }, { 0,1,0 }  },	/* UD !	    */
+	{  { 0x00B0 }, { 0,1,0 }  },	/* Degree   */
+	{  { 0x00B1 }, { 0,1,0 }  },	/* +- sign  */
+	{  { 0x00B2 }, { 0,1,0 }  },	/* SUP 2    */
+	{  { 0x00B3 }, { 0,1,0 }  },	/* SUP 3    */
+	{  { 0x00B4 }, { 0,1,0 }  },	/* ACUTE    */
+	{  { 0x00B8 }, { 0,1,0 }  },	/* CEDILLA  */
+	{  { 0x00B9 }, { 0,1,0 }  },	/* SUP 1    */
+	{  { 0x00BB }, { 0,1,0 }  },	/* >>	    */
+	{  { 0x00BC }, { 0,1,0 }  },	/* 1/4	    */
+	{  { 0x00BD }, { 0,1,0 }  },	/* 1/2	    */
+	{  { 0x00BE }, { 0,1,0 }  },	/* 3/4	    */
+	{  { 0x00BF }, { 0,1,0 }  },	/* UD ?	    */
+	{  { 0x00C0 }, { 0,1,0 }  },	/* A Grave  */
+	{  { 0x00D6 }, { 0,1,0 }  },	/* O dia    */
+	{  { 0x00D7 }, { 0,1,0 }  },	/* multipl. */
+	{  { 0x00D8 }, { 0,1,0 }  },	/* O stroke */
+	{  { 0x00DF }, { 0,1,0 }  },	/* small Sh */
+	{  { 0x00E0 }, { 0,1,0 }  },	/* a grave  */
+	{  { 0x00F6 }, { 0,1,0 }  },	/* o dia    */
+	{  { 0x00F7 }, { 0,1,0 }  },	/* division */
+	{  { 0x00F8 }, { 0,1,0 }  },	/* o stroke */
+	{  { 0x00FF }, { 0,1,0 }  },	/* y dia    */
+	{ .is_last = 1 }		/* Last element.  */
+      }
+  },
+  {   TST_ISW_REC (enUS, space)
+      {
+	{  { WEOF   }, { 0,1,0 }  },
+	{  { 0x0000 }, { 0,1,0 }  },
+	{  { 0x0008 }, { 0,1,0 }  },
+	{  { 0x0009 }, { 0,0,0 }  },
+	{  { 0x000D }, { 0,0,0 }  },
+	{  { 0x000E }, { 0,1,0 }  },
+	{  { 0x001F }, { 0,1,0 }  },
+	{  { 0x0020 }, { 0,0,0 }  },
+	{  { 0x0021 }, { 0,1,0 }  },
+	{  { 0x002F }, { 0,1,0 }  },
+	{  { 0x0030 }, { 0,1,0 }  },
+	{  { 0x0039 }, { 0,1,0 }  },
+	{  { 0x003A }, { 0,1,0 }  },
+	{  { 0x0040 }, { 0,1,0 }  },
+	{  { 0x0041 }, { 0,1,0 }  },
+	{  { 0x005A }, { 0,1,0 }  },
+	{  { 0x005B }, { 0,1,0 }  },
+	{  { 0x0060 }, { 0,1,0 }  },
+	{  { 0x0061 }, { 0,1,0 }  },
+	{  { 0x007A }, { 0,1,0 }  }, /* 20 */
+	{  { 0x007B }, { 0,1,0 }  },
+	{  { 0x007E }, { 0,1,0 }  },
+	{  { 0x007F }, { 0,1,0 }  },
+	{  { 0x0080 }, { 0,1,0 }  },
+	{ .is_last = 1 }		/* Last element.  */
+      }
+  },
+  {   TST_ISW_REC (eucJP, space)
+      {
+	{  { 0x3000 }, { 0,0,0 }  },	/* IDEO. SPACE	      */
+	{  { 0x3020 }, { 0,1,0 }  },	/* POSTAL MARK FACE   */
+	{  { 0x3029 }, { 0,1,0 }  },	/* Hangzhou NUM9      */
+	{  { 0x302F }, { 0,1,0 }  },	/* Diacritics(Hangul) */
+	{  { 0x3037 }, { 0,1,0 }  },	/* Separator Symbol   */
+	{  { 0x303F }, { 0,1,0 }  },	/* IDEO. HALF SPACE   */  /* No JIS */
+	{  { 0x3041 }, { 0,1,0 }  },	/* HIRAGANA a	      */
+	{  { 0x3094 }, { 0,1,0 }  },	/* HIRAGANA u"	      */
+	{  { 0x3099 }, { 0,1,0 }  },	/* SOUND MARK	      */
+	{  { 0x309E }, { 0,1,0 }  },	/* ITERATION MARK     */
+	{  { 0x30A1 }, { 0,1,0 }  },	/* KATAKANA a	      */
+	{  { 0x30FA }, { 0,1,0 }  },	/* KATAKANA wo"	      */
+	{  { 0x30FB }, { 0,1,0 }  },	/* KATAKANA MID.DOT   */
+	{  { 0x30FE }, { 0,1,0 }  },	/* KATAKANA ITERATION */
+	{  { 0x3191 }, { 0,1,0 }  },	/* KANBUN REV.MARK    */
+	{  { 0x3243 }, { 0,1,0 }  },	/* IDEO. MARK (reach) */
+	{  { 0x32CB }, { 0,1,0 }  },	/* IDEO.TEL.SYM.DEC12 */
+	{  { 0x32FE }, { 0,1,0 }  },	/* MARU KATAKANA wo   */
+	{  { 0x33FE }, { 0,1,0 }  },	/* CJK IDEO.TEL.31th  */
+	{  { 0x4E00 }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x4E05 }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x4E06 }, { 0,1,0 }  },	/* CJK UNI.IDEO.NON-J */
+	{  { 0x4E07 }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x4FFF }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x9000 }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x9006 }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x9007 }, { 0,1,0 }  },	/* CJK UNI.IDEO.NON-J */
+	{  { 0x9FA4 }, { 0,1,0 }  },	/* CJK UNI.IDEO.NON-J */
+	{  { 0x9FA5 }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0xFE4F }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0xFF0F }, { 0,1,0 }  },	/* FULL SLASH	      */
+	{  { 0xFF19 }, { 0,1,0 }  },	/* FULL 9	      */
+	{  { 0xFF20 }, { 0,1,0 }  },	/* FULL @	      */
+	{  { 0xFF3A }, { 0,1,0 }  },	/* FULL Z	      */
+	{  { 0xFF40 }, { 0,1,0 }  },	/* FULL GRAVE ACC.    */
+	{  { 0xFF5A }, { 0,1,0 }  },	/* FULL z	      */
+	{  { 0xFF5E }, { 0,1,0 }  },	/* FULL ~ (tilde)     */
+	{  { 0xFF61 }, { 0,1,0 }  },	/* HALF IDEO.STOP. .  */
+	{  { 0xFF65 }, { 0,1,0 }  },	/* HALF KATA MID.DOT  */
+	{  { 0xFF66 }, { 0,1,0 }  },	/* HALF KATA WO	      */
+	{  { 0xFF6F }, { 0,1,0 }  },	/* HALF KATA tu	      */
+	{  { 0xFF70 }, { 0,1,0 }  },	/* HALF KATA PL -     */
+	{  { 0xFF71 }, { 0,1,0 }  },	/* HALF KATA A	      */
+	{  { 0xFF9E }, { 0,1,0 }  },	/* HALF KATA MI	      */
+	{ .is_last = 1 }		/* Last element.  */
+      }
+  },
+  {   TST_ISW_REC (end, space) }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswupper.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswupper.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswupper.c	(revision 2036)
@@ -0,0 +1,90 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_iswupper.c
+ *
+ *	 ISW*:	int iswupper (wint_t wc);
+ */
+
+
+#include "dat_isw-funcs.h"
+
+
+TST_ISW_LOC (UPPER, upper) = {
+
+  {   TST_ISW_REC (de, upper)
+      {
+	{  { 0x0080 }, { 0,1,0 }  },	/* CTRL	    */
+	{  { 0x009F }, { 0,1,0 }  },	/* CTRL	    */
+	{  { 0x00A0 }, { 0,1,0 }  },	/* NB SPACE */
+	{  { 0x00A1 }, { 0,1,0 }  },	/* UD !	    */
+	{  { 0x00B0 }, { 0,1,0 }  },	/* Degree   */
+	{  { 0x00B1 }, { 0,1,0 }  },	/* +- sign  */
+	{  { 0x00B2 }, { 0,1,0 }  },	/* SUP 2    */
+	{  { 0x00B3 }, { 0,1,0 }  },	/* SUP 3    */
+	{  { 0x00B4 }, { 0,1,0 }  },	/* ACUTE    */
+	{  { 0x00B8 }, { 0,1,0 }  },	/* CEDILLA  */
+	{  { 0x00B9 }, { 0,1,0 }  },	/* SUP 1    */
+	{  { 0x00BB }, { 0,1,0 }  },	/* >>	    */
+	{  { 0x00BC }, { 0,1,0 }  },	/* 1/4	    */
+	{  { 0x00BD }, { 0,1,0 }  },	/* 1/2	    */
+	{  { 0x00BE }, { 0,1,0 }  },	/* 3/4	    */
+	{  { 0x00BF }, { 0,1,0 }  },	/* UD ?	    */
+	{  { 0x00C0 }, { 0,0,0 }  },	/* A Grave  */
+	{  { 0x00D6 }, { 0,0,0 }  },	/* O dia    */
+	{  { 0x00D7 }, { 0,1,0 }  },	/* multipl. */
+	{  { 0x00D8 }, { 0,0,0 }  },	/* O stroke */
+	{  { 0x00DF }, { 0,1,0 }  },	/* small Sh */
+	{  { 0x00E0 }, { 0,1,0 }  },	/* a grave  */
+	{  { 0x00F6 }, { 0,1,0 }  },	/* o dia    */
+	{  { 0x00F7 }, { 0,1,0 }  },	/* division */
+	{  { 0x00F8 }, { 0,1,0 }  },	/* o stroke */
+	{  { 0x00FF }, { 0,1,0 }  },	/* y dia    */
+	{ .is_last = 1 }		/* Last entry.	*/
+      }
+  },
+  {   TST_ISW_REC (enUS, upper)
+      {
+	{  { WEOF   }, { 0,1,0 }  },
+	{  { 0x0000 }, { 0,1,0 }  },
+	{  { 0x001F }, { 0,1,0 }  },
+	{  { 0x0020 }, { 0,1,0 }  },
+	{  { 0x0021 }, { 0,1,0 }  },
+	{  { 0x002F }, { 0,1,0 }  },
+	{  { 0x0030 }, { 0,1,0 }  },
+	{  { 0x0039 }, { 0,1,0 }  },
+	{  { 0x003A }, { 0,1,0 }  },
+	{  { 0x0040 }, { 0,1,0 }  },
+	{  { 0x0041 }, { 0,0,0 }  },
+	{  { 0x005A }, { 0,0,0 }  },
+	{  { 0x005B }, { 0,1,0 }  },
+	{  { 0x0060 }, { 0,1,0 }  },
+	{  { 0x0061 }, { 0,1,0 }  },
+	{  { 0x007A }, { 0,1,0 }  },
+	{  { 0x007B }, { 0,1,0 }  },
+	{  { 0x007E }, { 0,1,0 }  },
+	{  { 0x007F }, { 0,1,0 }  },
+	{  { 0x0080 }, { 0,1,0 }  },
+	{ .is_last = 1 }		/* Last entry.  */
+      }
+  },
+  {   TST_ISW_REC (eucJP, upper)
+      {
+	{  { 0x3041 }, { 0,1,0 }  },	/* HIRAGANA a	      */
+	{  { 0x3094 }, { 0,1,0 }  },	/* HIRAGANA u"	      */
+	{  { 0x30A1 }, { 0,1,0 }  },	/* KATAKANA a	      */
+	{  { 0x30FA }, { 0,1,0 }  },	/* KATAKANA wo"	      */
+	{  { 0xFF19 }, { 0,1,0 }  },	/* FULL 9	      */
+	{  { 0xFF20 }, { 0,1,0 }  },	/* FULL @	      */
+	{  { 0xFF3A }, { 0,0,0 }  },	/* FULL Z	      */
+	{  { 0xFF40 }, { 0,1,0 }  },	/* FULL GRAVE ACC.    */
+	{  { 0xFF5A }, { 0,1,0 }  },	/* FULL z	      */
+	{  { 0xFF66 }, { 0,1,0 }  },	/* HALF KATA WO	      */
+	{  { 0xFF6F }, { 0,1,0 }  },	/* HALF KATA tu	      */
+	{  { 0xFF71 }, { 0,1,0 }  },	/* HALF KATA A	      */
+	{  { 0xFF9E }, { 0,1,0 }  },	/* HALF KATA MI	      */
+	{ .is_last = 1 }		/* Last entry.	*/
+      }
+  },
+  {   TST_ISW_REC (end, upper) }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswxdigit.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswxdigit.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_iswxdigit.c	(revision 2036)
@@ -0,0 +1,121 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_iswxdigit.c
+ *
+ *	 ISW*:	int iswxdigit (wint_t wc);
+ */
+
+
+#include "dat_isw-funcs.h"
+
+
+TST_ISW_LOC (XDIGIT, xdigit) = {
+
+  {   TST_ISW_REC (de, xdigit)
+      {
+	{  { 0x0080 }, { 0,1,0 }  },	/* CTRL	    */
+	{  { 0x009F }, { 0,1,0 }  },	/* CTRL	    */
+	{  { 0x00A0 }, { 0,1,0 }  },	/* NB SPACE */
+	{  { 0x00A1 }, { 0,1,0 }  },	/* UD !	    */
+	{  { 0x00B0 }, { 0,1,0 }  },	/* Degree   */
+	{  { 0x00B1 }, { 0,1,0 }  },	/* +- sign  */
+	{  { 0x00B2 }, { 0,1,0 }  },	/* SUP 2    */
+	{  { 0x00B3 }, { 0,1,0 }  },	/* SUP 3    */
+	{  { 0x00B4 }, { 0,1,0 }  },	/* ACUTE    */
+	{  { 0x00B8 }, { 0,1,0 }  },	/* CEDILLA  */
+	{  { 0x00B9 }, { 0,1,0 }  },	/* SUP 1    */
+	{  { 0x00BB }, { 0,1,0 }  },	/* >>	    */
+	{  { 0x00BC }, { 0,1,0 }  },	/* 1/4	    */
+	{  { 0x00BD }, { 0,1,0 }  },	/* 1/2	    */
+	{  { 0x00BE }, { 0,1,0 }  },	/* 3/4	    */
+	{  { 0x00BF }, { 0,1,0 }  },	/* UD ?	    */
+	{  { 0x00C0 }, { 0,1,0 }  },	/* A Grave  */
+	{  { 0x00D6 }, { 0,1,0 }  },	/* O dia    */
+	{  { 0x00D7 }, { 0,1,0 }  },	/* multipl. */
+	{  { 0x00D8 }, { 0,1,0 }  },	/* O stroke */
+	{  { 0x00DF }, { 0,1,0 }  },	/* small Sh */
+	{  { 0x00E0 }, { 0,1,0 }  },	/* a grave  */
+	{  { 0x00F6 }, { 0,1,0 }  },	/* o dia    */
+	{  { 0x00F7 }, { 0,1,0 }  },	/* division */
+	{  { 0x00F8 }, { 0,1,0 }  },	/* o stroke */
+	{  { 0x00FF }, { 0,1,0 }  },	/* y dia    */
+	{ .is_last = 1 }		/* Last element.  */
+      }
+  },
+  {   TST_ISW_REC( enUS, xdigit )
+      {
+	{  { WEOF   }, { 0,1,0 }  },
+	{  { 0x0000 }, { 0,1,0 }  },
+	{  { 0x001F }, { 0,1,0 }  },
+	{  { 0x0020 }, { 0,1,0 }  },
+	{  { 0x0021 }, { 0,1,0 }  },
+	{  { 0x002F }, { 0,1,0 }  },
+	{  { 0x0030 }, { 0,0,0 }  },
+	{  { 0x0039 }, { 0,0,0 }  },
+	{  { 0x003A }, { 0,1,0 }  },
+	{  { 0x0040 }, { 0,1,0 }  },
+	{  { 0x0041 }, { 0,0,0 }  },
+	{  { 0x005A }, { 0,1,0 }  },
+	{  { 0x005B }, { 0,1,0 }  },
+	{  { 0x0060 }, { 0,1,0 }  },
+	{  { 0x0061 }, { 0,0,0 }  },
+	{  { 0x007A }, { 0,1,0 }  },
+	{  { 0x007B }, { 0,1,0 }  },
+	{  { 0x007E }, { 0,1,0 }  },
+	{  { 0x007F }, { 0,1,0 }  },
+	{  { 0x0080 }, { 0,1,0 }  },
+	{ .is_last = 1 }		/* Last element.  */
+      }
+  },
+  {   TST_ISW_REC( eucJP, xdigit )
+      {
+	{  { 0x3000 }, { 0,1,0 }  },	/* IDEO. SPACE	      */
+	{  { 0x3020 }, { 0,1,0 }  },	/* POSTAL MARK FACE   */
+	{  { 0x3029 }, { 0,1,0 }  },	/* Hangzhou NUM9      */
+	{  { 0x302F }, { 0,1,0 }  },	/* Diacritics(Hangul) */
+	{  { 0x3037 }, { 0,1,0 }  },	/* Separator Symbol   */
+	{  { 0x303F }, { 0,1,0 }  },	/* IDEO. HALF SPACE   */
+	{  { 0x3041 }, { 0,1,0 }  },	/* HIRAGANA a	      */
+	{  { 0x3094 }, { 0,1,0 }  },	/* HIRAGANA u"	      */
+	{  { 0x3099 }, { 0,1,0 }  },	/* SOUND MARK	      */
+	{  { 0x309E }, { 0,1,0 }  },	/* ITERATION MARK     */
+	{  { 0x30A1 }, { 0,1,0 }  },	/* KATAKANA a	      */
+	{  { 0x30FA }, { 0,1,0 }  },	/* KATAKANA wo"	      */
+	{  { 0x30FB }, { 0,1,0 }  },	/* KATAKANA MID.DOT   */
+	{  { 0x30FE }, { 0,1,0 }  },	/* KATAKANA ITERATION */
+	{  { 0x3191 }, { 0,1,0 }  },	/* KANBUN REV.MARK    */
+	{  { 0x3243 }, { 0,1,0 }  },	/* IDEO. MARK (reach) */
+	{  { 0x32CB }, { 0,1,0 }  },	/* IDEO.TEL.SYM.DEC12 */
+	{  { 0x32FE }, { 0,1,0 }  },	/* MARU KATAKANA wo   */
+	{  { 0x33FE }, { 0,1,0 }  },	/* CJK IDEO.TEL.31th  */
+	{  { 0x4E00 }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x4E05 }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x4E06 }, { 0,1,0 }  },	/* CJK UNI.IDEO.NON-J */
+	{  { 0x4E07 }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x4FFF }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x9000 }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x9006 }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0x9007 }, { 0,1,0 }  },	/* CJK UNI.IDEO.NON-J */
+	{  { 0x9FA4 }, { 0,1,0 }  },	/* CJK UNI.IDEO.NON-J */
+	{  { 0x9FA5 }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0xFE4F }, { 0,1,0 }  },	/* CJK UNI.IDEO.      */
+	{  { 0xFF0F }, { 0,1,0 }  },	/* FULL SLASH	      */
+	{  { 0xFF19 }, { 0,1,0 }  },	/* FULL 9	      */
+	{  { 0xFF20 }, { 0,1,0 }  },	/* FULL @	      */
+	{  { 0xFF3A }, { 0,1,0 }  },	/* FULL Z	      */
+	{  { 0xFF40 }, { 0,1,0 }  },	/* FULL GRAVE ACC.    */
+	{  { 0xFF5A }, { 0,1,0 }  },	/* FULL z	      */
+	{  { 0xFF5E }, { 0,1,0 }  },	/* FULL ~ (tilde)     */
+	{  { 0xFF61 }, { 0,1,0 }  },	/* HALF IDEO.STOP. .  */
+	{  { 0xFF65 }, { 0,1,0 }  },	/* HALF KATA MID.DOT  */
+	{  { 0xFF66 }, { 0,1,0 }  },	/* HALF KATA WO	      */
+	{  { 0xFF6F }, { 0,1,0 }  },	/* HALF KATA tu	      */
+	{  { 0xFF70 }, { 0,1,0 }  },	/* HALF KATA PL -     */
+	{  { 0xFF71 }, { 0,1,0 }  },	/* HALF KATA A	      */
+	{  { 0xFF9E }, { 0,1,0 }  },	/* HALF KATA MI	      */
+	{ .is_last = 1 }		/* Last element.  */
+      }
+  },
+  {   TST_ISW_REC (end, xdigit) }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_mblen.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_mblen.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_mblen.c	(revision 2036)
@@ -0,0 +1,115 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_mblen.c
+ *
+ *	 MBLEN:	 int mblen (char *s, size_t n);
+ */
+
+
+/*
+ *  NOTE:
+ *	  int  mblen (char *s, size_t n);
+ *
+ *	  where	     n: a maximum number of bytes
+ *
+ *	  return - the number of bytes
+ *
+ *  CAUTION:
+ *
+ *	 o When you feed a null pointer for a string (s) to the function,
+ *	   set s_flg=0 instead of putting just a 'NULL' there.
+ *	   Even if you set a 'NULL', it doens't mean a NULL pointer.
+ *
+ *	 o When s is a null pointer, the function checks state dependency.
+ *
+ *	       state-dependent encoding	     - return  NON-zero
+ *	       state-independent encoding    - return  0
+ *
+ *	   If state-dependent encoding is expected, set
+ *
+ *	       s_flg = 0,  ret_flg = 0,	 ret_val = +1
+ *
+ *	   If state-independent encoding is expected, set
+ *
+ *	       s_flg = 0,  ret_flg = 0,	 ret_val = 0
+ *
+ *
+ *	   When you set ret_flg=1, the test program simply compares an
+ *	   actual return value with an expected value. You can check
+ *	   state-independent case (return value is 0) in that way, but
+ *	   you can not check state-dependent case. So when you check
+ *	   state- dependency in this test function: tst_mblen(), set
+ *	   ret_flg=0 always. It's a special case, and the test
+ *	   function takes care of it.
+ *
+ *	       s_flg=0		 ret_flg=0
+ *	       |		 |
+ *	     { 0, 0 },	 { 0, 0, 0,  x }
+ *		  |		     |
+ *		  not used	     ret_val: 0/+1
+ *				     (expected val) */
+
+
+TST_MBLEN tst_mblen_loc [] = {
+  {
+    { Tmblen, TST_LOC_de },
+    {
+      /* 01: a character.  */
+      {	 { 1, "\300",	   USE_MBCURMAX }, { 0,	1,  1 }	 },
+      /* 02: a character.  */
+      {	 { 1, "\309",	   USE_MBCURMAX }, { 0,	1,  1 }	 },
+      /* 03: a character + an invalid byte.  */
+      {	 { 1, "Z\204",	   USE_MBCURMAX }, { 0,	1, +1 }	 },
+      /* 04: control/invalid characters.  */
+      {	 { 1, "\177\000",  USE_MBCURMAX }, { 0,	1, +1 }	 },
+      /* 05: a null string.  */
+      {	 { 1, "",	   USE_MBCURMAX }, { 0,	1,  0 }	 },
+      /* 06: a null pointer.  */
+      {	 { 0, "",	   USE_MBCURMAX }, { 0,	0,  0 }	 },
+      /* Last element.	*/
+      {	 .is_last = 1 }
+    }
+  },
+  {
+    { Tmblen, TST_LOC_enUS },
+    {
+      /* 01: a character.  */
+      {	 { 1, "A",	   USE_MBCURMAX }, { 0,	1,  1 }	 },
+      /* 02: a character.  */
+      {	 { 1, "a",	   USE_MBCURMAX }, { 0,	1,  1 }	 },
+      /* 03: a character + an invalid byte.  */
+      {	 { 1, "Z\204",	   USE_MBCURMAX }, { 0,	1, +1 }	 },
+      /* 04: control/invalid characters.  */ 
+      {	 { 1, "\177\000",  USE_MBCURMAX }, { 0,	1, +1 }	 },
+      /* 05: a null string.  */		     
+      {	 { 1, "",	   USE_MBCURMAX }, { 0,	1,  0 }	 },
+      /* 06: a null pointer.  */	     
+      {	 { 0, "",	   USE_MBCURMAX }, { 0,	0,  0 }	 },
+      /* Last element.	*/
+      {	 .is_last = 1 }
+    }
+  },
+  {
+    { Tmblen, TST_LOC_eucJP },
+    {
+      /* 01: a character.  */
+      {	 { 1, "\264\301",	   USE_MBCURMAX }, { 0, 1,  2 }	 },
+      /* 02: a character.  */			     
+      {	 { 1, "\216\261",	   USE_MBCURMAX }, { 0, 1,  2 }  },
+      /* 03: a character + an invalid byte.  */	     
+      {	 { 1, "\260\241\200",	   USE_MBCURMAX }, { 0, 1,  2 }	 },
+      /* 04: control/invalid characters.  */
+      {	 { 1, "\377\202",  USE_MBCURMAX }, { EILSEQ, 1, -1 }	 },
+      /* 05: a null string.  */		     
+      {	 { 1, "",	   USE_MBCURMAX }, { 0,	1,  0 }	 },
+      /* 06: a null pointer.  */	     
+      {	 { 0, "",	   USE_MBCURMAX }, { 0,	0,  0 }	 },
+      /* Last element.	*/
+      {	 .is_last = 1 }
+    }
+  },
+  {
+    { Tmblen, TST_LOC_end}
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_mbrlen.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_mbrlen.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_mbrlen.c	(revision 2036)
@@ -0,0 +1,159 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_mbrlen.c
+ *
+ *	 MBRLEN:  size_t mbrlen (const char *s, size_t n, mbstate_t *ps);
+ */
+
+/*
+ *  NOTE:
+ *	  (1) A mbstate object is initialized for
+ *	      every new data record by the test program.
+ *
+ *	  (2) USE_MBCURMAX is defined as a value of 99.
+ *
+ */
+
+
+TST_MBRLEN tst_mbrlen_loc [] = {
+  {
+    { Tmbrlen, TST_LOC_de },
+    {
+      { /*----------------- #01 -----------------*/
+	{
+	  {
+	    { 1, "",	   0,		   0, 0 },
+	    { 1, "",	   1,		   0, 0 },
+	    { 1, "\300",	   USE_MBCURMAX,   0, 0 },
+	  }
+	},
+	{
+	  {
+	    { 0,		1,  0,		     },
+	    { 0,		1,  0,		     },
+	    { 0,		1,  1,		     },
+	  }
+	}
+      },
+      { /*----------------- #02 -----------------*/
+	{
+	  {
+	    { 1, "\300\001",   0,		   0, 0 },
+	    { 1, "\300\001",   1,		   0, 0 },
+	    { 1, "\317\001",   USE_MBCURMAX,   0, 0 },
+	  }
+	},
+	{
+	  {
+	    { 0,		1,  0,		     },
+	    { 0,		1,  1,		     },
+	    { 0,		1,  1,		     },
+	  }
+	}
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Tmbrlen, TST_LOC_enUS },
+    {
+      { /*----------------- #01 -----------------*/
+	{
+	  {
+	    { 1, "A",	   0,		   0, 0 },
+	    { 1, "A",	   1,		   0, 0 },
+	    { 1, "A",	   USE_MBCURMAX,   0, 0 },
+	  }
+	},
+	{
+	  {
+	    { 0,		1,  0,		     },
+	    { 0,		1,  1,		     },
+	    { 0,		1,  1,		     },
+	  }
+	}
+      },
+      { /*----------------- #02 -----------------*/
+	{
+	  {
+	    { 1, "\317\001",   0,		   1, 0 },
+	    { 1, "\317\001",   1,		   1, 0 },
+	    { 1, "\317\001",   USE_MBCURMAX,   1, 0 },
+	  }
+	},
+	{
+	  {
+	    { 0,		1,  0,		     },
+	    { EILSEQ,	1, -1,		     },
+	    { EILSEQ,	1, -1,		     },
+	  }
+	}
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Tmbrlen, TST_LOC_eucJP },
+    {
+      { /*----------------- #01 -----------------*/
+	{
+	  {
+	    { 1, "\317\302",   1,		   1, 1 },
+	    { 0, "",	       0,		   1, 0 },
+	    { 1, "\317\302",   USE_MBCURMAX,	   1, 1 },
+	  }
+	},
+	{
+	  {
+	    { 0,		1, -2,		     },
+	    { 0,		1, -1,		     },
+	    { 0,		1,  2,		     },
+	  }
+	}
+      },
+      { /*----------------- #02 -----------------*/
+	{
+	  {
+	    { 1, "\317",	   1,		   1, 0 },
+	    { 1, "\302",	   1,		   1, 0 },
+	    { 1, "\317\302",   USE_MBCURMAX,   0, 0 },
+	  }
+	},
+	{
+	  {
+	    { 0,		1, -2,		     },
+#ifdef SHOJI_IS_RIGHT
+	    { 0,		1, +2,		     },
+#else
+	    /* XXX ISO C explicitly says that the return value does not
+	       XXX reflect the bytes contained in the state.  */
+	    { 0,		1, +1,		     },
+#endif
+	    { 0,		1,  2,		     },
+	  }
+	}
+      },
+      { /*----------------- #03 -----------------*/
+	{
+	  {
+	    { 1, "\216\217",   0,		   0, 0 },
+	    { 1, "\216\217",   1,		   0, 0 },
+	    { 1, "\216\217",   USE_MBCURMAX,   0, 0 },
+	  }
+	},
+	{
+	  {
+	    { 0,		1,  0,		     },
+	    { 0,		1, -2,		     },
+	    { EILSEQ,	1, -1,		     },
+	  }
+	}
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Tmbrlen, TST_LOC_end }
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_mbrtowc.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_mbrtowc.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_mbrtowc.c	(revision 2036)
@@ -0,0 +1,140 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_mbrtowc.c
+ *
+ *	 MBTOWC:  size_t mbrtowc (wchar_t *pwc, char *s, size_t n,
+ *				  mbstate_t *ps);
+ */
+
+#include <limits.h>
+
+/* Note:
+	assumes	 en_US = en_US.ascii
+*/
+
+
+
+
+TST_MBRTOWC tst_mbrtowc_loc [] = {
+  {
+    { Tmbrtowc, TST_LOC_de },
+    {
+      { /*----------------- #01 -----------------*/
+	{
+	  {
+	    { 1, 1, "ÄÖÜ",	   1,		 0, 0 },
+	    { 1, 1, "ÄÖÜ",	   2,		 0, 0 },
+	    { 1, 1, "ÄÖÜ",	   USE_MBCURMAX, 0, 0 },
+	  }
+	},
+	{
+	  {
+	    { 0,  1,  1,   0x00C4 },
+	    { 0,  1,  1,   0x00C4 },
+	    { 0,  1,  1,   0x00C4 },
+	  }
+	}
+      },
+      { /*----------------- #02 -----------------*/
+	{
+	  {
+	    { 1, 1, "ÄÖÜ",	    1,		  0, 0 },
+	    { 1, 1, "ÄÖÜ",	    2,		  0, 0 },
+	    { 1, 1, "ÄÖÜ",	    USE_MBCURMAX, 0, 0 },
+	  }
+	},
+	{
+	  {
+	    { 0,  1,  1,   0x00C4 },
+	    { 0,  1,  1,   0x00C4 },
+	    { 0,  1,  1,   0x00C4 },
+	  }
+	}
+      },
+      { .is_last = 1 }
+    }
+  },
+#if 0
+  /* XXX: These tests don't make sense to me.  */
+  {
+    { Tmbrtowc, TST_LOC_enUS },
+    {
+      { /*----------------- #01 -----------------*/
+	{
+	  {
+	    { 1, 1, "ÄÖÜ",	    1,		  0, 0 },
+	    { 1, 1, "ÄÖÜ",	    2,		  0, 0 },
+	    { 1, 1, "ÄÖÜ",	    USE_MBCURMAX, 0, 0 },
+	  }
+	},
+	{
+	  {
+	    { 0,  1,  1,   0x00C4 },
+	    { 0,  1,  1,   0x00C4 },
+	    { 0,  1,  1,   0x00C4 },
+	  }
+	}
+      },
+      { /*----------------- #02 -----------------*/
+	{
+	  {
+	    { 1, 1, "ÄÖÜ",	    1,		  0, 0 },
+	    { 1, 1, "ÄÖÜ",	    2,		  0, 0 },
+	    { 1, 1, "ÄÖÜ",	    USE_MBCURMAX, 0, 0 },
+	  }
+	},
+	{
+	  {
+	    { 0,  1,  1,   0x00C4 },
+	    { 0,  1,  1,   0x00C4 },
+	    { 0,  1,  1,   0x00C4 },
+	  }
+	}
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Tmbrtowc, TST_LOC_eucJP },
+    {
+      { /*----------------- #01 -----------------*/
+	{
+	  {
+	    { 1, 1, "ÄÖÜ",	    1,		  0, 0 },
+	    { 1, 1, "ÄÖÜ",	    2,		  0, 0 },
+	    { 1, 1, "ÄÖÜ",	    USE_MBCURMAX, 0, 0 },
+	  }
+	},
+	{
+	  {
+	    { 0,  1,  1,   0x00C4 },
+	    { 0,  1,  1,   0x00C4 },
+	    { 0,  1,  1,   0x00C4 },
+	  }
+	}
+      },
+      { /*----------------- #02 -----------------*/
+	{
+	  {
+	    { 1, 1, "ÄÖÜ",	    1,		  0, 0 },
+	    { 1, 1, "ÄÖÜ",	    2,		  0, 0 },
+	    { 1, 1, "ÄÖÜ",	    USE_MBCURMAX, 0, 0 },
+	  }
+	},
+	{
+	  {
+	    { 0,  1,  1,   0x00C4 },
+	    { 0,  1,  1,   0x00C4 },
+	    { 0,  1,  1,   0x00C4 },
+	  }
+	}
+      },
+      { .is_last = 1 }
+    }
+  },
+#endif
+  {
+    { Tmbrtowc, TST_LOC_end }
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_mbsrtowcs.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_mbsrtowcs.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_mbsrtowcs.c	(revision 2036)
@@ -0,0 +1,137 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_mbsrtowcs.c
+ *
+ *	 MBSRTOWCS:  size_t mbsrtowcs (wchar_t *ws, char **s, size_t n,
+ *				       mbstate_t *ps);
+ */
+
+
+TST_MBSRTOWCS tst_mbsrtowcs_loc [] = {
+  {
+    { Tmbsrtowcs, TST_LOC_de },
+    {
+      { /*----------------- #01 -----------------*/
+	{
+	  {
+	    { 1,  "üäö",	    4,			 0,0 },
+	    { 1,  "üäö",	    3,			 0,0 },
+	    { 1,  "üäö",	    2,			 0,0 },
+	  }
+	},
+	{
+	  {
+	    { 0,1,3, { 0x00FC,0x00E4,0x00F6,0x0000 }	     },
+	    { 0,1,3, { 0x00FC,0x00E4,0x00F6,0x0000 }	     },
+	    { 0,1,2, { 0x00FC,0x00E4,0x00F6,0x0000 }	     },
+	  }
+	}
+      },
+      { /*----------------- #02 -----------------*/
+	{
+	  {
+	    { 1,  "üäö",	    4,			 0,0 },
+	    { 1,  "",		    1,			 0,0 },
+	    { 0,  "üäö",	    4,			 0,0 },
+	  }
+	},
+	{
+	  {
+	    { 0,1,3, { 0x00FC,0x00E4,0x00F6,0x0000 }	     },
+	    { 0,1,0, { 0x0000 }			     },
+	    { 0,1,3, { 0x0000 }			     },
+	  }
+	}
+      },
+      { /*----------------- END -----------------*/
+	.is_last = 1
+      }
+    }
+  },
+
+  {
+    { Tmbsrtowcs, TST_LOC_enUS },
+    {
+      { /*----------------- #01 -----------------*/
+	{
+	  {
+	    { 1,  "ABC",	    4,			 0,0 },
+	    { 1,  "ABC",	    3,			 0,0 },
+	    { 1,  "ABC",	    2,			 0,0 },
+	  }
+	},
+	{
+	  {
+	    { 0,1,3, { 0x0041,0x0042,0x0043,0x0000 }	     },
+	    { 0,1,3, { 0x0041,0x0042,0x0043,0x0000 }	     },
+	    { 0,1,2, { 0x0041,0x0042,0x0043,0x0000 }	     },
+	  }
+	}
+      },
+      { /*----------------- #02 -----------------*/
+	{
+	  {
+	    { 1,  "ABC",	    4,			 0,0 },
+	    { 1,  "",		    1,			 0,0 },
+	    { 0,  "ABC",	    4,			 0,0 },
+	  }
+	},
+	{
+	  {
+	    { 0,1,3, { 0x0041,0x0042,0x0043,0x0000 }	     },
+	    { 0,1,0, { 0x0000 }			     },
+	    { 0,1,3, { 0x0000 }			     },
+	  }
+	}
+      },
+      { /*----------------- END -----------------*/
+	.is_last = 1
+      }
+    }
+  },
+
+  {
+    { Tmbsrtowcs, TST_LOC_eucJP },
+    {
+      { /*----------------- #01 -----------------*/
+	{
+	  {
+	    { 1,  "\244\242\244\244\244\246ABC",      7, 0,0 },
+	    { 1,  "\244\242\244\244\244\246ABC",      6, 0,0 },
+	    { 1,  "\244\242\244\244\244\246ABC",      4, 0,0 },
+	  }
+	},
+	{
+	  {
+	    { 0,1,6, { 0x3042,0x3044,0x3046,0x0041,0x0042,0x0043,0x0000 }},
+	    { 0,1,6, { 0x3042,0x3044,0x3046,0x0041,0x0042,0x0043,0x0000 }},
+	    { 0,1,4, { 0x3042,0x3044,0x3046,0x0041,0x0000 }		   },
+	  }
+	}
+      },
+      { /*----------------- #02 -----------------*/
+	{
+	  {
+	    { 1,  "\244\242\244\244\244\246ABC",      7, 0,0 },
+	    { 1,  "",		      1, 0,0 },
+	    { 0,  "\244\242\244\244\244\246ABC",      7, 0,0 },
+	  }
+	},
+	{
+	  {
+	    { 0,1,6, { 0x3042,0x3044,0x3046,0x0041,0x0042,0x0043,0x0000 }},
+	    { 0,1,0, { 0x0000 }					   },
+	    { 0,1,6, { 0x0000 }					   },
+	  }
+	}
+      },
+      { /*----------------- END -----------------*/
+	.is_last = 1
+      }
+    }
+  },
+  {
+    { Tmbsrtowcs, TST_LOC_end }
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_mbstowcs.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_mbstowcs.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_mbstowcs.c	(revision 2036)
@@ -0,0 +1,139 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_mbstowcs.c
+ *
+ *	 MBSTOWCS:  size_t  mbstowcs (wchar_t *ws, char *s, size_t n);
+ */
+
+#include <limits.h>
+
+TST_MBSTOWCS tst_mbstowcs_loc [] = {
+  {
+    { Tmbstowcs, TST_LOC_de },
+    {
+      { /*----------------- #01 -----------------*/
+	{
+	  {
+	    { 1,  1, "ABC",		   4			 },
+	    { 1,  1, "ABC",		   3			 },
+	    { 1,  1, "ABC",		   2			 },
+	  }
+	},
+	{
+	  {
+	    { 0,1,3, { 0x0041,0x0042,0x0043,0x0000 }	 },
+	    { 0,1,3, { 0x0041,0x0042,0x0043,0x0000 }	 },
+	    { 0,1,2, { 0x0041,0x0042,0x0043,0x0000 }	 },
+	  }
+	}
+      },
+      { /*----------------- #02 -----------------*/
+	{
+	  {
+	    { 1,  1, "ABC",		   4			 },
+	    { 1,  1, "",		   1			 },
+	    { 0,  1, "ABC",		   4			 },
+	  }
+	},
+	{
+	  {
+	    { 0,1,3, { 0x0041,0x0042,0x0043,0x0000 }	 },
+	    { 0,1,0, { 0x0000 }				 },
+	    { 0,1,3, { 0x0000 }				 },
+	  }
+	}
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Tmbstowcs, TST_LOC_enUS },
+    {
+      { /*----------------- #01 -----------------*/
+	{
+	  {
+	    { 1,  1, "ABC",		   4			 },
+	    { 1,  1, "ABC",		   3			 },
+	    { 1,  1, "ABC",		   2			 },
+	  }
+	},
+	{
+	  {
+	    { 0,1,3, { 0x0041,0x0042,0x0043,0x0000 }	 },
+	    { 0,1,3, { 0x0041,0x0042,0x0043,0x0000 }	 },
+	    { 0,1,2, { 0x0041,0x0042,0x0043,0x0000 }	 },
+	  }
+	}
+      },
+      { /*----------------- #02 -----------------*/
+	{
+	  {
+	    { 1,  1, "ABC",		   4			 },
+	    { 1,  1, "",		   1			 },
+	    { 0,  1, "ABC",		   4			 },
+	  }
+	},
+	{
+	  {
+	    { 0,1,3, { 0x0041,0x0042,0x0043,0x0000 }	 },
+	    { 0,1,0, { 0x0000 }				 },
+	    { 0,1,3, { 0x0000 }				 },
+	  }
+	}
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Tmbstowcs, TST_LOC_eucJP },
+    {
+      { /*----------------- #01 -----------------*/
+	{
+	  {
+	    { 1,  1, "\244\242\244\244\244\246ABC",      7 },
+	    { 1,  1, "\244\242\244\244\244\246ABC",      6 },
+	    { 1,  1, "\244\242\244\244\244\246ABC",      4 },
+	  }
+	},
+	{
+	  {
+	    { 0,1,6, { 0x3042,0x3044,0x3046,0x0041,0x0042,0x0043,0x0000 }},
+	    { 0,1,6, { 0x3042,0x3044,0x3046,0x0041,0x0042,0x0043,0x0000 }},
+	    { 0,1,4, { 0x3042,0x3044,0x3046,0x0041,0x0000 }		 },
+	  }
+	}
+      },
+      { /*----------------- #02 -----------------*/
+	{
+	  {
+#ifdef SHOJI_IS_RIGHT
+	    /* XXX I really don't understand the first and third line.
+	       the result of the first line is the same as the first
+	       in the last test (i.e., returns 6).  Also, the third
+	       test will simply convert everything.  */
+	    { 1,  1, "\244\242\244\244\244\246ABC",      7 },
+	    { 1,  1, "",                                 1 },
+	    { 0,  1, "\244\242\244\244\244\246ABC",      7 },
+#else
+	    { 1,  1, "\244\242\244\244\244\246ABC",      4 },
+	    { 1,  1, "",                                 1 },
+	    { 0,  1, "\244\242\244\244\244\246ABC",      0 },
+#endif
+	  }
+	},
+	{
+	  {
+	    { 0,1,4, { 0x3042,0x3044,0x3046,0x0041,0x0000 }		 },
+	    { 0,1,0, { 0x0000 }					 },
+	    { 0,1,6, { 0x0000 }					 },
+	  }
+	}
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Tmbstowcs, TST_LOC_end }
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_mbtowc.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_mbtowc.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_mbtowc.c	(revision 2036)
@@ -0,0 +1,341 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_mbtowc.c
+ *
+ *	 MBTOWC:  int  mbtowc (wchar_t *wp, char *s, size_t n);
+ */
+
+/*  NOTE:
+ *
+ *	 int  mbtowc (wchar_t *wp, char *s, size_t n);
+ *
+ *	 where	     n: a maximum number of bytes
+ *		return: the number of bytes
+ *
+ *
+ *	  o When you feed a null pointer for a string (s) to the function,
+ *	    set s_flg=0 instead of putting just a 'NULL' there.
+ *	    Even if you put a 'NULL', it means a null string as well as "".
+ *
+ *	  o When s is a null pointer, the function checks state dependency.
+ *
+ *		state-dependent encoding      - return	NON-zero
+ *		state-independent encoding    - return	0
+ *
+ *	    If state-dependent encoding is expected, set
+ *
+ *		s_flg = 0,  ret_flg = 0,  ret_val = +1
+ *
+ *	    If state-independent encoding is expected, set
+ *
+ *		s_flg = 0,  ret_flg = 0,  ret_val = 0
+ *
+ *
+ *	    When you set ret_flg=1, the test program simply compares
+ *	    an actual return value with an expected value. You can
+ *	    check state-independent case (return value is 0) in that
+ *	    way, but you can not check state-dependent case. So when
+ *	    you check state- dependency in this test function:
+ *	    tst_mbtowc(), set ret_flg=0 always. It's a special case
+ *	    and the test function takes care of it.
+ *
+ *			  w_flg
+ *			  |	s: (a null string; can't be (char *)NULL)
+ *			  |	|
+ *	       input.	{ 1, 0, (char)NULL, MB_LEN_MAX	},
+ *			     |
+ *			     s_flg=0: makes _s_ a null pointer.
+ *
+ *	       expect	{ 0,0,0,x,     0x0000	  },
+ *			      | |
+ *			      | ret_val: 0/+1
+ *			      ret_flg=0
+ *
+ *
+ *    Test data for State dependent encodings:
+ *
+ *	  mbtowc( NULL, NULL, 0 );	 ... first  data
+ *	  mbtowc( &wc,	s1,  n1 );	 ... second data
+ *	  mbtowc( &wc,	s2,  n2 );	 ... third  data
+ * */
+
+#include <limits.h>
+
+TST_MBTOWC tst_mbtowc_loc [] = {
+  {
+    { Tmbtowc, TST_LOC_de },
+    {
+      { /*----------------- #01 -----------------*/
+	{
+	  {
+	    { 1, 1, "\xfc\xe4\xf6",	    1	       },
+	    { 1, 1, "\xfc\xe4\xf6",	    2	       },
+	    { 1, 1, "\xfc\xe4\xf6",	    MB_LEN_MAX },
+	  }
+	},
+	{
+	  {
+	    { 0,  1,  1,   0x00FC },
+	    { 0,  1,  1,   0x00FC },
+	    { 0,  1,  1,   0x00FC },
+	  }
+	}
+      },
+      { /*----------------- #02 -----------------*/
+	{
+	  {
+	    { 1, 1, "\177",	    MB_LEN_MAX },
+	    { 1, 1, "\200",	    MB_LEN_MAX },
+	    { 1, 1, "\201",	    MB_LEN_MAX },
+	  }
+	},
+	{
+	  {
+	    { 0,  1,  1,   0x007F },
+	    { 0,  1,  1,   0x0080 },
+	    { 0,  1,  1,   0x0081 },
+	  }
+	}
+      },
+      { /*----------------- #03 -----------------*/
+	{
+	  {
+	    { 1, 1, "",			    MB_LEN_MAX },
+	    { 0, 1, "\xfc\xe4\xf6",	    1	       },
+	    { 0, 1, "\xfc\xe4\xf6",	    2	       },
+	  }
+	},
+	{
+	  {
+	    { 0,  1,  0,   0x0000 },
+	    { 0,  1,  1,   0x0000 },
+	    { 0,  1,  1,   0x0000 },
+	  }
+	}
+      },
+      { /*----------------- #04 -----------------*/
+	{
+	  {
+	    { 0, 1, "\xfc\xe4\xf6",	    MB_LEN_MAX },
+	    { 0, 1, "\177",		    MB_LEN_MAX },
+	    { 0, 1, "",	 		   MB_LEN_MAX },
+	  }
+	},
+	{
+	  {
+	    { 0,  1,  1,   0x0000 },
+	    { 0,  1,  1,   0x0000 },
+	    { 0,  1,  0,   0x0000 },
+	  }
+	}
+      },
+      { /*----------------- #05 -----------------*/
+	{
+	  {
+	    { 0, 1, "\xfc\xe4\xf6",	MB_LEN_MAX },
+	    { 0, 1, "\177",	   	MB_LEN_MAX },
+	    { 0, 0, (char)NULL, 	MB_LEN_MAX },
+	  }
+	},
+	{
+	  {
+	    { 0,  1,  1,   0x0000 },
+	    { 0,  1,  1,   0x0000 },
+	    { 0,  0,  0,   0x0000 },
+	  }
+	}
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Tmbtowc, TST_LOC_enUS },
+    {
+      { /*----------------- #01 -----------------*/
+	{
+	  {
+	    { 1, 1, "ABC",	    1	       },
+	    { 1, 1, "ABC",	    2	       },
+	    { 1, 1, "ABC",	    MB_LEN_MAX },
+	  }
+	},
+	{
+	  {
+	    { 0,  1,  1,   0x0041 },
+	    { 0,  1,  1,   0x0041 },
+	    { 0,  1,  1,   0x0041 },
+	  }
+	}
+      },
+      { /*----------------- #02 -----------------*/
+	{
+	  {
+	    { 1, 1, "\177",	    MB_LEN_MAX },
+	    { 1, 1, "\200",	    MB_LEN_MAX },
+	    { 1, 1, "\201",	    MB_LEN_MAX },
+	  }
+	},
+	{
+	  {
+	    { 0,  1,  1,   0x007F },
+	    { EILSEQ,  1, -1,   0x0000 },
+	    { EILSEQ,  1, -1,   0x0000 },
+	  }
+	}
+      },
+      { /*----------------- #03 -----------------*/
+	{
+	  {
+	    { 1, 1, "",	    MB_LEN_MAX },
+	    { 0, 1, "ABC",	    1	       },
+	    { 0, 1, "ABC",	    2	       },
+	  }
+	},
+	{
+	  {
+	    { 0,  1,  0,   0x0000 },
+	    { 0,  1,  1,   0x0000 },
+	    { 0,  1,  1,   0x0000 },
+	  }
+	}
+      },
+      { /*----------------- #04 -----------------*/
+	{
+	  {
+	    { 0, 1, "ABC",	    MB_LEN_MAX },
+	    { 0, 1, "\177",	    MB_LEN_MAX },
+	    { 0, 1, "",	    MB_LEN_MAX },
+	  }
+	},
+	{
+	  {
+	    { 0,  1,  1,   0x0000 },
+	    { 0,  1,  1,   0x0000 },
+	    { 0,  1,  0,   0x0000 },
+	  }
+	}
+      },
+      { /*----------------- #05 -----------------*/
+	{
+	  {
+	    { 0, 1, "ABC",	    MB_LEN_MAX },
+	    { 0, 1, "\177",	    MB_LEN_MAX },
+	    { 0, 0, (char)NULL, MB_LEN_MAX },
+	  }
+	},
+	{
+	  {
+	    { 0,  1,  1,   0x0000 },
+	    { 0,  1,  1,   0x0000 },
+	    { 0,  0,  0,   0x0000 },
+	  }
+	}
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Tmbtowc, TST_LOC_eucJP },
+    {
+      { /*----------------- #01 -----------------*/
+	{
+	  {
+	    { 1, 1, "\244\242A",      1          },
+	    { 1, 1, "\244\242A",      2          },
+	    { 1, 1, "\244\242A",      MB_LEN_MAX },
+	  }
+	},
+	{
+	  {
+#ifdef SHOJI_IS_RIGHT
+	    { EILSEQ,  1, -1,   0x0000 },
+#else
+	    /* XXX EILSEQ was introduced in ISO C99.  */
+	    { 0,	  1, -1,   0x0000 },
+#endif
+	    { 0,       1,  2,   0x3042 },
+	    { 0,       1,  2,   0x3042 },
+	  }
+	}
+      },
+      { /*----------------- #02 -----------------*/
+	{
+	  {
+	    { 1, 1, "\177\244\242",   MB_LEN_MAX },
+	    { 1, 1, "\377\244\242",   MB_LEN_MAX },
+	    { 1, 1, "\201\244\242",   MB_LEN_MAX },
+	  }
+	},
+	{
+	  {
+	    { 0,  1, +1,   0x007F },
+#ifdef SHOJI_IS_RIGHT
+	    { EILSEQ,  1, -1,   0x0000 },
+#else
+	    { 0,  1, -1,   0x0000 },
+#endif
+	    { 0,  1, +1,   0x0081 },
+	  }
+	}
+      },
+      { /*----------------- #03 -----------------*/
+	{
+	  {
+	    { 1, 1, "",         MB_LEN_MAX },
+	    { 0, 1, "\244\242A",      1          },
+	    { 0, 1, "\244\242A",      2          },
+	  }
+	},
+	{
+	  {
+	    { 0,  1,  0,   0x0000 },
+#ifdef SHOJI_IS_RIGHT
+	    { EILSEQ,  1, -1,   0x0000 },
+#else
+	    /* XXX EILSEQ was introduced in ISO C99.  */
+	    { 0,       1, -1,   0x0000 },
+#endif
+	    { 0,  1,  2,   0x0000 },
+	  }
+	}
+      },
+      { /*----------------- #04 -----------------*/
+	{
+	  {
+	    { 0, 1, "\244\242A",      MB_LEN_MAX },
+	    { 0, 1, "\177\244\242",   MB_LEN_MAX },
+	    { 0, 1, "",         MB_LEN_MAX },
+	  }
+	},
+	{
+	  {
+	    { 0,  1,  2,   0x0000 },
+	    { 0,  1, +1,   0x0000 },
+	    { 0,  1,  0,   0x0000 },
+	  }
+	}
+      },
+      { /*----------------- #05 -----------------*/
+	{
+	  {
+	    { 0, 1, "\244\242A",      MB_LEN_MAX },
+	    { 0, 1, "\177\244\242",   MB_LEN_MAX },
+	    { 0, 0, (char)NULL, MB_LEN_MAX },
+	  }
+	},
+	{
+	  {
+	    { 0,  1,  2,   0x0000 },
+	    { 0,  1, +1,   0x0000 },
+	    { 0,  0,  0,   0x0000 },
+	  }
+	}
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Tmbtowc, TST_LOC_end }
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_strcoll.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_strcoll.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_strcoll.c	(revision 2036)
@@ -0,0 +1,162 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE: dat_strcoll.c
+ *
+ *	 STRCOLL:  int strcoll (const char *s1, const char *s2);
+ */
+
+/*
+   NOTE:
+
+   If a return value is expected to be 0, set ret_flg=1 and the
+   expected value = 0.	If a return value is expected to be a
+   positive/negative value, set ret_flg=0, and set the expected value
+   = +1/-1.
+   There is inconsistensy between tst_strcoll() and tst_wcscoll()(it
+   has cmp_flg) for input data. I'll fix it.
+
+   Assuming en_US to be en_US.ascii. (maybe, should be iso8859-1).
+
+
+
+   ASCII CODE  : A,B,C, ...  , a, b, c, ...	 B,a:-1	  a,B:+1
+   DICTIONARY : A,a,B,b,C,c,....  a,B:-1 B,a:+1 */
+
+TST_STRCOLL tst_strcoll_loc [] = {
+  {
+    { Tstrcoll, TST_LOC_de },
+    {
+      { /*input.*/ { "ÄBCDEFG", "ÄBCDEFG"	      },  /* #1 */
+	/*expect*/ { 0,1,0,			      },
+      },
+      { /*input.*/ { "XX Ä XX", "XX B XX"	      },  /* #2 */
+	/*expect*/ { 0,0,-1,			      },
+      },
+      { /*input.*/ { "XX B XX", "XX Ä XX"	      },  /* #3 */
+	/*expect*/ { 0,0,+1,			      },
+      },
+      { /*input.*/ { "B",	"a"		      },  /* #4 */
+	/*expect*/ { 0,0,+1,			      },
+      },
+      { /*input.*/ { "a",	"B"		      },  /* #5 */
+	/*expect*/ { 0,0,-1,			      },
+      },
+      { /*input.*/ { "b",	"A"		      },  /* #6 */
+	/*expect*/ { 0,0,+1,			      },
+      },
+      { /*input.*/ { "A",	"b"		      },  /* #7 */
+	/*expect*/ { 0,0,-1,			      },
+      },
+      { /*input.*/ { "ä",	"B"		      },  /* #8 */
+	/*expect*/ { 0,0,-1,			      },
+      },
+      { /*input.*/ { "B",	"ä"		      },  /* #9 */
+	/*expect*/ { 0,0,+1,			      },
+      },
+      { .is_last = 1 } /* Last element.  */
+    }
+  },
+  {
+    { Tstrcoll, TST_LOC_enUS },
+    {
+      { /*input.*/ { "ABCDEFG", "ABCDEFG"	      },  /* #1 */
+	/*expect*/ { 0,1,0,			      },
+      },
+      { /*input.*/ { "XX a XX", "XX B XX"	      },  /* #2 */
+	/*expect*/ { 0,0,-1,			      },
+      },
+      { /*input.*/ { "XX B XX", "XX a XX"	      },  /* #3 */
+	/*expect*/ { 0,0,+1,			      },
+      },
+      {
+	/* <WAIVER> */
+	/*input.*/ { "B",	"a"		      },  /* #4 */
+#ifdef SHOJI_IS_RIGHT
+	/*expect*/ { 0,0,-1,			      },
+#else
+		   /* XXX We are not testing the C locale.  */
+	/*expect*/ { 0,0,+1,			      },
+#endif
+      },
+      {
+	/* <WAIVER> */
+	/*input.*/ { "a",	"B"		      },  /* #5 */
+#ifdef SHOJI_IS_RIGHT
+	/*expect*/ { 0,0,+1,			      },
+#else
+		   /* XXX We are not testing the C locale.  */
+	/*expect*/ { 0,0,-1,			      },
+#endif
+      },
+      { /*input.*/ { "b",	"A"		      },  /* #6 */
+	/*expect*/ { 0,0,+1,			      },
+      },
+      { /*input.*/ { "A",	"b"		      },  /* #7 */
+	/*expect*/ { 0,0,-1,			      },
+      },
+#ifdef NO_WAIVER
+      /* XXX I do not yet know whether strcoll really should reject
+	 characters outside the multibyte character range.  */
+      {
+	/* #8 */  /* <WAIVER> */
+	/*input.*/ { "\244\242\244\244\244\246\244\250\244\252", "ABCDEFG" },
+	/*expect*/ { EINVAL,0,0,		      },
+      },
+      {
+	/* #9 */  /* <WAIVER> */
+	/*input.*/ { "ABCZEFG", "\244\242\244\244\244\246\244\250\244\252" },
+	/*expect*/ { EINVAL,0,0,		      },
+      },
+#endif
+      { .is_last = 1 } /* Last element.  */
+    }
+  },
+  {
+    { Tstrcoll, TST_LOC_eucJP },
+    {
+      { /*input.*/ { "\244\242\244\244\244\246\244\250\244\252",
+		     "\244\242\244\244\244\246\244\250\244\252" },  /* #1 */
+	/*expect*/ { 0,1,0,			      },
+      },
+      { /*input.*/ { "\244\242\244\244\244\246\244\250\244\252",
+		     "\244\242\244\244\244\363\244\250\244\252" },  /* #2 */
+	/*expect*/ { 0,0,-1,			      },
+      },
+      { /*input.*/ { "\244\242\244\244\244\363\244\250\244\252",
+		     "\244\242\244\244\244\246\244\250\244\252" },  /* #3 */
+	/*expect*/ { 0,0,+1,			      },
+      },
+      { /*input.*/ { "B",	"a"		      },  /* #4 */
+	/*expect*/ { 0,0,-1,			      },
+      },
+      { /*input.*/ { "a",	"B"		      },  /* #5 */
+	/*expect*/ { 0,0,+1,			      },
+      },
+      { /*input.*/ { "b",	"A"		      },  /* #6 */
+	/*expect*/ { 0,0,+1,			      },
+      },
+      { /*input.*/ { "A",	"b"		      },  /* #7 */
+	/*expect*/ { 0,0,-1,			      },
+      },
+#ifdef NO_WAIVER
+      /* XXX I do not yet know whether strcoll really should reject
+	 characters outside the multibyte character range.  */
+      {
+	/* <WAIVER> */
+	/*input.*/ { "\200\216\217", "ABCDEFG"	      },  /* #8 */
+	/*expect*/ { EINVAL,0,0,		      },
+      },
+      {
+	/* <WAIVER> */
+	/*input.*/ { "ABCZEFG", "\200\216\217"	      },  /* #9 */
+	/*expect*/ { EINVAL,0,0,		      },
+      },
+#endif
+      { .is_last = 1 } /* Last element.  */
+    }
+  },
+  {
+    { Tstrcoll, TST_LOC_end }
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_strfmon.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_strfmon.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_strfmon.c	(revision 2036)
@@ -0,0 +1,264 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN CLIBRARY
+ *
+ *	 FILE:	dat_strfmon.c
+ *
+ *	 STRFMON:  size_t strfmon (char *buf, size_t nbyte, char *fmt, ... );
+ */
+
+/*
+ *  NOTE:
+ *
+ *  The buffer size should be enough to contain a string including a
+ *  null char.
+ *  Returns the number of bytes of the string (NOT including a null char).
+ */
+
+TST_STRFMON tst_strfmon_loc [] = {
+  {
+    { Tstrfmon, TST_LOC_de },
+    {
+      {
+	/* #01 */
+	/*inp*/ { 24, "%n %% %i",	     123.00			},
+	/*exp*/ { 0,1,23,		     "123,00 EUR % 123,00 EUR"	},
+      },
+      {
+	/* #02 */
+	/*inp*/ { 24, "%n %% %i",	     123.00			},
+	/*exp*/ { 0,1,23,		     "123,00 EUR % 123,00 EUR"	},
+      },
+      {
+	/* #03 */
+	/*inp*/ { 23, "%n %% %i",	     123.00			},
+	/*exp*/ { E2BIG,1,-1,	     ""					},
+      },
+      {
+	/* #04 */
+	/*inp*/ { 31, "%n|%i",	     1234.561				},
+	/*exp*/ { 0,1,25,		     "1.234,56 EUR|1.234,56 EUR"},
+      },
+      {
+	/* #05 */
+	/*inp*/ { 33, "%n|%i",	    -1234.561				},
+	/*exp*/ { 0,1,27,		     "-1.234,56 EUR|-1.234,56 EUR"},
+      },
+      {
+	/* #06 */
+	/*inp*/ { 33, "%13n|%12i",	     1234.561			},
+	/*exp*/ { 0,1,26,		     " 1.234,56 EUR|1.234,56 EUR"},
+      },
+      {
+	/* #07 */
+	/*inp*/ { 33, "%12n|%12i",	    -1234.561			},
+	/*exp*/ { 0,1,27,		     "-1.234,56 EUR|-1.234,56 EUR"},
+      },
+      {
+	/* #08 */
+	/*inp*/ { 33, "%#5n|%#5i",	     1234.561			},
+	/*exp*/ { 0,1,29,		     "  1.234,56 EUR|  1.234,56 EUR"},
+      },
+      {
+	/* #09 */
+	/*inp*/ { 33, "%#5n|%#5i",	    -1234.561			},
+	/*exp*/ { 0,1,29,		     "- 1.234,56 EUR|- 1.234,56 EUR"},
+      },
+      {
+	/* #10 */
+	/*inp*/ { 33, "%=*#5n|%=*#5i",	 1234.561			},
+	/*exp*/ { 0,1,29,		     " *1.234,56 EUR| *1.234,56 EUR"},
+      },
+      {
+	/* #11 */
+	/*inp*/ { 33, "%=0#5n|%=0#5i",	-1234.561			},
+	/*exp*/ { 0,1,29,		     "-01.234,56 EUR|-01.234,56 EUR"},
+      },
+      {
+	/* #12 */
+	/*inp*/ { 33, "%^#5n|%^#5i",	-1234.561			},
+	/*exp*/ { 0,1,27,		     "- 1234,56 EUR|- 1234,56 EUR"},
+      },
+      {
+	/* #13 */
+	/*inp*/ { 33, "%#5.0n|%#5.0i",	 1234.444			},
+	/*exp*/ { 0,1,23,		     "  1.234 EUR|  1.234 EUR"	},
+      },
+      {
+	/* #14 */
+	/*inp*/ { 33, "%#5.0n|%#5.4i",	-1234.555			},
+	/*exp*/ { 0,1,28,		     "- 1.235 EUR|- 1.234,5550 EUR"},
+      },
+      {
+	/* #15 */
+	/*inp*/ { 33, "%(#5n|%!(#5i",	-1234.561			},
+	/*exp*/ { 0,1,27,		     "( 1.234,56 EUR)|( 1.234,56)"},
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Tstrfmon, TST_LOC_enUS },
+    {
+      {
+	/* #01 */
+	/*inp*/ { 22, "%n %% %i",	     123.00			},
+	/*exp*/ { 0,1,20,		     "$123.00 % USD 123.00"	},
+      },
+      {
+	/* #02 */
+	/*inp*/ { 21, "%n %% %i",	     123.00			},
+	/*exp*/ { 0,1,20,		     "$123.00 % USD 123.00"	},
+      },
+      {
+	/* #03 */
+	/*inp*/ { 20, "%n %% %i",	     123.00			},
+	/*exp*/ { E2BIG,1,-1,	     ""					},
+      },
+      {
+	/* #04 */
+	/*inp*/ { 30, "%n|%i",	     1234.561				},
+	/*exp*/ { 0,1,22,		     "$1,234.56|USD 1,234.56"	},
+      },
+      {
+	/* #05 */
+	/*inp*/ { 32, "%n|%i",	    -1234.561				},
+	/*exp*/ { 0,1,24,		     "-$1,234.56|-USD 1,234.56"	},
+      },
+      {
+	/* #06 */
+	/*inp*/ { 30, "%12n|%12i",	     1234.561			},
+	/*exp*/ { 0,1,25,		     "   $1,234.56|USD 1,234.56"},
+      },
+      {
+	/* #07 */
+	/*inp*/ { 32, "%12n|%12i",	    -1234.561			},
+	/*exp*/ { 0,1,26,		     "  -$1,234.56|-USD 1,234.56"},
+      },
+      {
+	/* #08 */
+	/*inp*/ { 32, "%#5n|%#5i",	     1234.561			},
+	/*exp*/ { 0,1,26,		     " $ 1,234.56| USD  1,234.56"},
+      },
+      {
+	/* #09 */
+	/*inp*/ { 32, "%#5n|%#5i",	    -1234.561			},
+	/*exp*/ { 0,1,26,		     "-$ 1,234.56|-USD  1,234.56"},
+      },
+      {
+	/* #10 */
+	/*inp*/ { 32, "%=*#5n|%=*#5i",	 1234.561			},
+	/*exp*/ { 0,1,26,		     " $*1,234.56| USD *1,234.56"},
+      },
+      {
+	/* #11 */
+	/*inp*/ { 32, "%=0#5n|%=0#5i",	-1234.561			},
+	/*exp*/ { 0,1,26,		     "-$01,234.56|-USD 01,234.56"},
+      },
+      {
+	/* #12 */
+	/*inp*/ { 32, "%^#5n|%^#5i",	-1234.561			},
+	/*exp*/ { 0,1,24,		     "-$ 1234.56|-USD  1234.56"	},
+      },
+      {
+	/* #13 */
+	/*inp*/ { 32, "%#5.0n|%#5.0i",	 1234.444			},
+	/*exp*/ { 0,1,20,		     " $ 1,234| USD  1,234"	},
+      },
+      {
+	/* #14 */
+	/*inp*/ { 32, "%#5.0n|%#5.4i",	-1234.555			},
+	/*exp*/ { 0,1,25,		     "-$ 1,235|-USD  1,234.5550"},
+      },
+      {
+	/* #15 */
+	/*inp*/ { 32, "%(#5n|%!(#5i",	-1234.561			},
+	/*exp*/ { 0,1,24,		     "($ 1,234.56)|( 1,234.56)"	},
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Tstrfmon, TST_LOC_eucJP },
+    {
+      {
+	/* #01 */
+	/*inp*/ { 17, "%n %% %i",	 123.00				   },
+	/*exp*/ { 0,1,15,		 "\241\357123 % JPY 123"	   },
+      },
+      {
+	/* #02 */
+	/*inp*/ { 16, "%n %% %i",	 123.00				   },
+	/*exp*/ { 0,1,15,		 "\241\357123 % JPY 123"	   },
+      },
+      {
+	/* #03 */
+	/*inp*/ { 15, "%n %% %i",	 123.00				   },
+	/*exp*/ { E2BIG,1,-1,		 ""				   },
+      },
+      {
+	/* #04 */
+	/*inp*/ { 30, "%n|%i",		 1234.561			   },
+	/*exp*/ { 0,1,17,		 "\241\3571,235|JPY 1,235"	   },
+      },
+      {
+	/* #05 */
+	/*inp*/ { 32, "%n|%i",		-1234.561			   },
+	/*exp*/ { 0,1,19,		 "\241\357-1,235|JPY -1,235"	   },
+      },
+      {
+	/* #06 */
+	/*inp*/ { 32, "%12n|%12i",	 1234.561			   },
+	/*exp*/ { 0,1,25,		 "     \241\3571,235|   JPY 1,235" },
+      },
+      {
+	/* #07 */
+	/*inp*/ { 32, "%12n|%12i",	-1234.561			   },
+	/*exp*/ { 0,1,25,		 "    \241\357-1,235|  JPY -1,235" },
+      },
+      {
+	/* #08 */
+	/*inp*/ { 32, "%#5n|%#5i",	 1234.561			   },
+	/*exp*/ { 0,1,21,		 " \241\357 1,235| JPY  1,235"	   },
+      },
+      {
+	/* #09 */
+	/*inp*/ { 32, "%#5n|%#5i",	-1234.561			   },
+	/*exp*/ { 0,1,21,		 "\241\357- 1,235|JPY - 1,235"	   },
+      },
+      {
+	/* #10 */
+	/*inp*/ { 32, "%=*#5n|%=*#5i",	 1234.561			   },
+	/*exp*/ { 0,1,21,		 " \241\357*1,235| JPY *1,235"	   },
+      },
+      {
+	/* #11 */
+	/*inp*/ { 32, "%=0#5n|%=0#5i",	-1234.561			   },
+	/*exp*/ { 0,1,21,		 "\241\357-01,235|JPY -01,235"	   },
+      },
+      {
+	/* #12 */
+	/*inp*/ { 32, "%^#5n|%^#5i",	-1234.561			   },
+	/*exp*/ { 0,1,19,		 "\241\357- 1235|JPY - 1235"	   },
+      },
+      {
+	/* #13 */
+	/*inp*/ { 32, "%#5.0n|%#5.0i",	 1234.444			   },
+	/*exp*/ { 0,1,21,		 " \241\357 1,234| JPY  1,234"	   },
+      },
+      {
+	/* #14 */
+	/*inp*/ { 32, "%#5.0n|%#5.4i",	-1234.555			   },
+	/*exp*/ { 0,1,26,		 "\241\357- 1,235|JPY - 1,234.5550"},
+      },
+      {
+	/* #15 */
+	/*inp*/ { 32, "%(#5n|%!(#5i",	-1234.561			   },
+	/*exp*/ { 0,1,19,		 "(\241\357 1,235)|( 1,235)"	   },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Tstrfmon, TST_LOC_end }
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_strxfrm.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_strxfrm.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_strxfrm.c	(revision 2036)
@@ -0,0 +1,117 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN CLIBRARY
+ *
+ *	 FILE:	dat_strxfrm.c
+ *
+ *	 STRXFRM:  size_t strxfrm (char *s1, const char s2, size_t n);
+ */
+
+
+/*
+ *  NOTE:
+ *
+ *  Return value and errno value are checked only for 2nd string:
+ *  org2[]; n1 and n2 don't mean bytes to be translated.
+ *  It means a buffer size including a null character.
+ *  Results of this test depens on results of strcoll().
+ *  If you got errors, check both test results.
+ *
+ *  The buffer size should be enough to contain a string including a
+ *  null char.	Returns the number of bytes of the string (NOT
+ *  including a null char).
+ */
+
+
+
+TST_STRXFRM tst_strxfrm_loc [] = {
+  {
+    { Tstrxfrm, TST_LOC_de },
+    {
+      { /*inp*/ { "\xf6\xc4\xe4\xfc", "\xf6\xc4\xe4\xfc", 17, 17 },  /* #01 */
+	/*exp*/ { 0,0,0,			   },
+      },
+      { /*inp*/ { "aA", "Aa",	    10, 10 },  /* #02 */
+	/*exp*/ { 0,0,0 ,			   },
+      },
+      { /*inp*/ { "Aa", "aA",	    10, 10 },  /* #03 */
+	/*exp*/ { 0,0,0,			   },
+      },
+      { /*inp*/ { "abc", "",	    13, 13 },  /* #04 */
+	/*exp*/ { 0,0,0,			   },
+      },
+      { /*inp*/ { "a", "B",		     7,	 7 },  /* #05 */
+	/*exp*/ { 0,0,0,			   },
+      },
+      { /*inp*/ { "B", "a",		     7,	 7 },  /* #06 */
+	/*exp*/ { 0,0,0,			   },
+      },
+      {
+	/* hiragana == latin1 */
+	/*inp*/ { "abc", "\244\241\244\242",  13,  9 },	 /* #07 */
+	/*exp*/ { 0,0,0,		       },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Tstrxfrm, TST_LOC_enUS },
+    {
+      { /*inp*/ { "abcd", "abcd",	    17, 17 },  /* #01 */
+	/*exp*/ { 0,0,0,			   },
+      },
+      { /*inp*/ { "aA", "Aa",	    10, 10 },  /* #02 */
+	/*exp*/ { 0,0,0 ,			   },
+      },
+      { /*inp*/ { "Aa", "aA",	    10, 10 },  /* #03 */
+	/*exp*/ { 0,0,0,			   },
+      },
+      { /*inp*/ { "abc", "",	    13, 13 },  /* #04 */
+	/*exp*/ { 0,0,0,			   },
+      },
+      { /*inp*/ { "a", "B",		     7,	 7 },  /* #05 */
+	/*exp*/ { 0,0,0,			   },
+      },
+      { /*inp*/ { "B", "a",		     7,	 7 },  /* #06 */
+	/*exp*/ { 0,0,0,			   },
+      },
+#ifdef NO_WAIVER
+      {
+	/* <WAIVER> */
+	/*inp*/ { "abc", "\244\241\244\242",  13,  9 },	 /* #07 */
+	/*exp*/ { EINVAL,0,0,		       },
+      },
+#endif
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Tstrxfrm, TST_LOC_eucJP },	 /* ??? */
+    {
+      {
+	/* #01 */
+	/*inp*/ { "\244\242\244\241",  "\244\241\244\242",   5,	 5 },
+	/*exp*/ { 0,0,0,		       },
+      },
+      {
+	/* #02 */
+	/*inp*/ { "\244\241\244\242",  "\244\242\244\241",   5,	 5 },
+	/*exp*/ { 0,0,0,		       },
+      },
+      {
+	/* #03 */
+	/*inp*/ { "\244\242\216\261",  "\216\261\244\242",   5,	 5 },
+	/*exp*/ { 0,0,0,		       },
+      },
+#ifdef NO_WAIVER
+      {
+	/*inp*/ { "AAA", "\216\217",	 5,  5 },  /* #04 */ /* <WAIVER> */
+	/*exp*/ { EINVAL,0,0,		       },
+      },
+#endif
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Tstrxfrm, TST_LOC_end }
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_swscanf.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_swscanf.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_swscanf.c	(revision 2036)
@@ -0,0 +1,181 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN CLIBRARY
+ *
+ *	 FILE:	dat_swscanf.c
+ *
+ *	 SWSCANF:  int	swscanf (const wchar_t *s, const wchar_t *fmt, ...);
+ */
+
+
+#include <errno.h>
+#include <stdlib.h>
+#include "tst_types.h"
+#include "tgn_locdef.h"
+
+
+TST_SWSCANF tst_swscanf_loc [] =
+{
+  {
+    { Tswscanf, TST_LOC_de },
+    {
+      /*------------------------ 01 -----------------------*/
+      { { {
+	0x002D, 0x0031,		0x003A,	   /* %d: -1   */
+	0x0032,			0x003A,	   /* %u:  2   */
+	0x0033, 0x002C, 0x0033, 0x003A,	   /* %f:  3.3 */
+	0x00E4,			0x003A,	   /* %c: 'ä'  */
+	0x00C4, 0x00DC, 0x0000, 0x0000,	   /* %s: "ÄÜ" */
+      },
+	  L"%d:%u:%f:%c:%s", 0
+      },
+	{ /* The fields are: err_val, ret_flag, ret_val,
+	     val_int, val_uns, val_flt, val_c, val_s, val_S.  */
+	  0,1,5,
+	  -1, 2, 3.3, 'ä', "ÄÜ", { 0x0000, },
+	},
+      },
+      /*------------------------ 02 -----------------------*/
+      { { {
+	0x00E4, 0x00C4, 0x0000		       /* "äÄ" */
+      },
+	  L"%lc", 'C'
+      },
+	{ 0,1,1,
+	  0,0,0,0,"", { 0x00E4, 0x0000 },
+	},
+      },
+      /*------------------------ 03 -----------------------*/
+      { { {
+	0x00E4, 0x00C4, 0x0000		       /* "äÄ" */
+      },
+	  L"%ls", 'S'
+      },
+	{ 0,1,1,
+	  0,0,0,0,"", { 0x00E4, 0x00C4, 0x0000 },
+	},
+      },
+      /*------------------------ 04 -----------------------*/
+      /* <NO_WAIVER> x 2 */
+      { { {
+	0x00E4, 0x00C4, 0x0000		       /* "äÄ" */
+      },
+	  L"1%d:2%d:3%d:4%d:5%d:6%d:7%d:8%d:9%d", 0
+      },
+#ifdef SHOJI_IS_RIGHT
+	{ 1,EINVAL,1,WEOF,
+	  0,0,0,0,"", { 0x0000 },
+#else
+	{ 0,1,0,
+	  0,0,0,0,"", { 0x0000 },
+#endif
+	},
+      },
+      /*---------------------------------------------------*/
+      { .is_last = 1}	/* Last element.  */
+    }
+  },
+  {
+    { Tswscanf, TST_LOC_enUS },
+    {
+      /*------------------------ 01 -----------------------*/
+      { { { 0x002D, 0x0031,					    0x003A,
+	    0x0032,						    0x003A,
+	    0x0035, 0x0034, 0x002E, 0x0033, 0x0045, 0x002D, 0x0031, 0x003A,
+	    0x0041,						    0x003A,
+	    0x0061, 0x0062, 0x0000,				    0x0000,
+      },
+	  L"%d:%u:%f:%c:%s", 0
+      },
+	{ 0,1,5,
+	  -1, 2, 5.43, 'A', "ab", { 0x0000 },
+	},
+      },
+      /*------------------------ 02 -----------------------*/
+      /* <NO_WAIVER> x 2 */
+      { { {
+	0x0063, 0x0064, 0x0000
+      },
+	  L"%C", 'C'
+      },
+	{ 0,1,1,
+	  0,0,0,0,"", { 0x0063, 0x0000 },
+	},
+      },
+      /*------------------------ 03 -----------------------*/
+      { { {
+	0x0063, 0x0064, 0x0000
+      },
+	  L"%S", 'S'
+      },
+	{ 0,1,1,
+	  0,0,0,0,"", { 0x0063, 0x0064, 0x0000 },
+	},
+      },
+      /*---------------------------------------------------*/
+      { .is_last = 1}	/* Last element.  */
+    }
+  },
+  {
+    { Tswscanf, TST_LOC_eucJP },
+    {
+      /*------------------------ 01 -----------------------*/
+      { { { 0x002D, 0x0031,	    0x003A,
+	    0x0032,		    0x003A,
+	    0x0033, 0x002E, 0x0033, 0x003A,
+	    0x0062,		    0x003A,
+	    0x0061, 0x0062, 0x0000, 0x0000,
+      },
+	  L"%d:%u:%f:%c:%s", 0
+      },
+	{ 0,1,5,
+	  -1, 2, 3.3, 'b', "ab", { 0x0000 }
+	},
+      },
+      /*------------------------ 02 -----------------------*/
+      { { {
+	0x30A2, 0x30A4, 0x0000
+      },
+	  L"%ls", 'S'
+      },
+	{ 0,1,1,
+	  0,0,0,0,"", { 0x30A2, 0x30A4, 0x0000 }
+	},
+      },
+      /*------------------------ 03 -----------------------*/
+      { { {
+	0x0031,			0x003A,
+	0x0030,			0x003A,
+	0x0033, 0x002E, 0x0039, 0x003A,
+	0x0061,			0x003A,
+	0x0063, 0x0064, 0x0000, 0x0000,
+      },
+	  L"%2$d:%1$u:%3$f:%4$c:%5$s", 0
+      },
+	{ 0,1,5,
+	  0, 1, 3.9, 'a', "cd", { 0x0000 }
+	},
+      },
+#ifdef SHOJI_IS_RIGHT
+      /* XXX This test does not make sense.  The format string is
+	 L"\x1\x2\x25\x53" and it is supposed to match the words
+	 0x30A2, 0x30A4, 0x0001.  */
+      /*------------------------ 04 -----------------------*/
+      /* <NO_WAIVER> x 2 */
+      { { {
+	0x30A2, 0x30A4, 0x0001, 0x0000
+      },
+	  { 0x0001,0x0002,0x0025,0x0053,0x0000 }, 'S'
+      },
+	{ EILSEQ,1,EOF,
+	  0,0,0,0,"", { 0x0000 }
+	},
+      },
+#endif
+      /*---------------------------------------------------*/
+      { .is_last = 1}	/* Last element.  */
+    }
+  },
+  {
+    { Tswscanf, TST_LOC_end }
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_tow-funcs.h
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_tow-funcs.h	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_tow-funcs.h	(revision 2036)
@@ -0,0 +1,24 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *       FILE:  dat_tow-funcs.h
+ *
+ *       ISW*:  int tow*( wint_t wc );
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <wctype.h>
+#include "tst_types.h"
+#include "tgn_locdef.h"
+
+#define TST_TOW_LOC(FUNC, func) \
+        TST_TOW## FUNC    tst_tow## func ##_loc[]
+
+#define TST_TOW_REC(locale, func) \
+        {  Ttow## func,    TST_LOC_## locale },
+
+/*
+ *  NOTE:
+ *        need more test data!
+ */
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_towctrans.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_towctrans.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_towctrans.c	(revision 2036)
@@ -0,0 +1,93 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_towctrans.c
+ *
+ *	 TOWCTRANS:  wint_t towctrans (wint_t wc, wctrans_t charclass);
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <wctype.h>
+#include "tst_types.h"
+#include "tgn_locdef.h"
+
+/*
+ *  NOTE:
+ *    Set ret_flg = 1, when a return value is expected to be 0 (FALSE).
+ *    Set ret_flg = 0, when a return value is expected to be non-zero (TRUE).
+ *
+ *    Since the functions return *non*-zero value for TRUE, can't
+ *    compare an actual return value with an expected return value.
+ *    Set the ret_flg=0 for TRUE cases and the tst_isw*() will check
+ *    the non-zero value.
+ *
+ *  { { WEOF }, { 0,0,1,0 } },
+ *		      | |
+ *		      | ret_val: an expected return value
+ *		      ret_flg: if 1, compare an actual return value with the
+ *			       ret_val; if 0, the test program checks
+ *			       the actual return value.
+ *
+ *    CAUTION: if a charclass is invalid, the test function gives
+ *    towctrans() an invalid wctrans object instead of a return value
+ *    from wctrans() which is supposed to be 0.
+ */
+
+TST_TOWCTRANS tst_towctrans_loc [] = {
+  {
+    { Ttowctrans, TST_LOC_C },
+    {
+#ifdef SHOJI_IS_RIGHT
+      {	 { 0x0010, "xxxxxxx" }, { EINVAL,1,0x0010 }  },
+#else				  
+      {	 { 0x0010, "xxxxxxx" }, { 0,     1,0x0010 }  },
+#endif				  
+      {	 { 0x007F, "tolower" }, { 0,	   1,0x007F }  },
+      {	 { 0x0061, "toupper" }, { 0,	   1,0x0041 }  },
+      {	 { 0x0041, "tolower" }, { 0,	   1,0x0061 }  },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Ttowctrans, TST_LOC_de },
+    {
+#ifdef SHOJI_IS_RIGHT
+      {	 { 0x0010, "tojkata" }, { EINVAL,1,0x0010 }  },
+#else				  
+      {	 { 0x0010, "tojkata" }, { 0,     1,0x0010 }  },
+#endif				  
+      {	 { 0x0080, "tolower" }, { 0,	   1,0x0080 }  },
+      {	 { 0x00EC, "toupper" }, { 0,	   1,0x00CC }  },
+      {	 { 0x00CC, "tolower" }, { 0,	   1,0x00EC }  },
+      { .is_last = 1 }		  
+    }				  
+  },				  
+  {				  
+    { Ttowctrans, TST_LOC_enUS }, 
+    {				  
+#ifdef SHOJI_IS_RIGHT		  
+      {	 { 0x0010, "xxxxxxx" }, { EINVAL,1,0x0010 }  },
+#else				  
+      {	 { 0x0010, "xxxxxxx" }, { 0,     1,0x0010 }  },
+#endif				  
+      {	 { 0x007F, "tolower" }, { 0,	   1,0x007F }  },
+      {	 { 0x0061, "toupper" }, { 0,	   1,0x0041 }  },
+      {	 { 0x0041, "tolower" }, { 0,	   1,0x0061 }  },
+      { .is_last = 1 }		  
+    }				  
+  },				  
+  {				  
+    { Ttowctrans, TST_LOC_eucJP },
+    {				  
+      {	 { 0xFF21, "tolower" }, { 0,	   1,0xFF41 }  },
+      {	 { 0xFF41, "toupper" }, { 0,	   1,0xFF21 }  },
+      {	 { 0x30A1, "tojhira" }, { 0,	   1,0x3041 }  },
+      {	 { 0x3041, "tojkata" }, { 0,	   1,0x30A1 }  },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Ttowctrans, TST_LOC_end }
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_towlower.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_towlower.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_towlower.c	(revision 2036)
@@ -0,0 +1,43 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_towlower.c
+ *
+ *	 ISW*:	int towlower (wint_t wc);
+ */
+
+
+#include "dat_tow-funcs.h"
+
+
+TST_TOW_LOC (LOWER, lower) = {
+
+  {   TST_TOW_REC (de, lower)
+      {
+	{  { WEOF   }, { 0,  1, (wint_t)-1 }	},
+	{  { 0x0080 }, { 0,  1, 0x0080     }	},
+	{  { 0x00CC }, { 0,  1, 0x00EC     }	},
+	{  { 0x00EC }, { 0,  1, 0x00EC     }	},
+	{ .is_last = 1 } /* Last element.	 */
+      }
+  },
+  {   TST_TOW_REC (enUS, lower)
+      {
+	{  { WEOF   }, { 0,  1, (wint_t)-1 }	},
+	{  { 0x007F }, { 0,  1, 0x007F     }	},
+	{  { 0x0041 }, { 0,  1, 0x0061     }	},
+	{  { 0x0061 }, { 0,  1, 0x0061     }	},
+	{ .is_last = 1 } /* Last element.	 */
+      }
+  },
+  {   TST_TOW_REC (eucJP, lower)
+      {
+	{  { 0x007F }, { 0,  1, 0x007F     }	},
+	{  { 0x0080 }, { 0,  1, 0x0080     }	},
+	{  { 0xFF21 }, { 0,  1, 0xFF41     }	},
+	{  { 0xFF41 }, { 0,  1, 0xFF41     }	},
+	{ .is_last = 1 } /* Last element.	 */
+      }
+  },
+  {   TST_TOW_REC (end, lower) }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_towupper.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_towupper.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_towupper.c	(revision 2036)
@@ -0,0 +1,43 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_towupper.c
+ *
+ *	 ISW*:	int towupper (wint_t wc);
+ */
+
+
+#include "dat_tow-funcs.h"
+
+
+TST_TOW_LOC (UPPER, upper) = {
+
+  {   TST_TOW_REC (de, upper)
+      {
+	{  { WEOF   }, { 0,  1, (wint_t)-1 }	},
+	{  { 0x0080 }, { 0,  1, 0x0080     }	},
+	{  { 0x00EC }, { 0,  1, 0x00CC     }	},
+	{  { 0x00CC }, { 0,  1, 0x00CC     }	},
+	{ .is_last = 1 } /* Last element.	 */
+      }
+  },
+  {   TST_TOW_REC (enUS, upper)
+      {
+	{  { WEOF   }, { 0,  1, (wint_t)-1 }	},
+	{  { 0x0080 }, { 0,  1, 0x0080     }	},
+	{  { 0x0041 }, { 0,  1, 0x0041     }	},
+	{  { 0x0061 }, { 0,  1, 0x0041     }	},
+	{ .is_last = 1 } /* Last element.	 */
+      }
+  },
+  {   TST_TOW_REC (eucJP, upper)
+      {
+	{  { WEOF   }, { 0,  1, (wint_t)-1 }	},
+	{  { 0x007F }, { 0,  1, 0x007F     }	},
+	{  { 0xFF41 }, { 0,  1, 0xFF21     }	},
+	{  { 0xFF21 }, { 0,  1, 0xFF21     }	},
+	{ .is_last = 1 } /* Last element.	 */
+      }
+  },
+  {   TST_TOW_REC (end, upper) }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcrtomb.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcrtomb.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcrtomb.c	(revision 2036)
@@ -0,0 +1,93 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_wcrtomb.c
+ *
+ *	 WCRTOMB:  intwcrtomb (char *s, wchar_t wc, mbstate_t *ps);
+ *
+ */
+
+TST_WCRTOMB tst_wcrtomb_loc [] = {
+  {
+    { Twcrtomb, TST_LOC_de },
+    {
+      /* #01 : normal case			       */
+      { /*input.*/ { 1,		 0x00FC,   0,0 },
+	/*expect*/ { 0,	   1,1,	 "ü"	       },
+      },
+      /* #02 : normal case			       */
+      { /*input.*/ { 1,		 0x00D6,   0,0 },
+	/*expect*/ { 0,	   1,1,	 "Ö"	       },
+      },
+      /* #03 : error case			       */
+      { /*input.*/ { 1,		 0xFFA1,   0,0 },
+	/*expect*/ {  EILSEQ,1,-1, ""	       },
+      },
+      /* #04 :				       */
+      { /*input.*/ { 0,		 0x0041,   0,0 },
+	/*expect*/ { 0,	   1,1,	 ""	       },
+      },
+      /* #05 :				       */
+      { /*input.*/ { 0,		 0x0092,   0,0 },
+	/*expect*/ { 0,	   1,1,	 ""	       },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcrtomb, TST_LOC_enUS },
+    {
+      /* #01 : normal case			       */
+      { /*input.*/ { 1,		 0x0041,   0,0 },
+	/*expect*/ { 0,	   1,1,	 "A"	       },
+      },
+      /* #02 : normal case			       */
+      { /*input.*/ { 1,		 0x0042,   0,0 },
+	/*expect*/ { 0,	   1,1,	 "B"	       },
+      },
+      /* #03 : error case			       */
+      /* <WAIVER> x 2 */
+      { /*input.*/ { 1,		 0x0092,   0,0 },  /* assume ascii */
+	/*expect*/ {  EILSEQ,1,-1, ""	       },
+      },
+      /* #04 :				       */
+      { /*input.*/ { 0,		 0x0041,   0,0 },
+	/*expect*/ { 0,	   1,1,	 ""	       },
+      },
+      /* #05 :				       */
+      { /*input.*/ { 0,		 0x0092,   0,0 },
+	/*expect*/ { 0,	   1,1,	 ""	       },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcrtomb, TST_LOC_eucJP },
+    {
+      /* #01 : normal case			       */
+      { /*input.*/ { 1,		 0x3042,   0,0 },
+	/*expect*/ { 0,      1,2,  "\244\242"	   },
+      },
+      /* #02 : normal case			       */
+      { /*input.*/ { 1,		 0x3044,   0,0 },
+	/*expect*/ { 0,      1,2,  "\244\244"	   },
+      },
+      /* #03 : normal case			       */
+      { /*input.*/ { 1,		 0x008E,   0,0 },
+	/*expect*/ { EILSEQ, 1,-1, ""	       },
+      },
+      /* #04 :				       */
+      { /*input.*/ { 0,		 0x3042,   0,0 },
+	/*expect*/ { 0,	   0,0,	 ""	       },
+      },
+      /* #05 :				       */
+      { /*input.*/ { 0,		 0x008E,   0,0 },
+	/*expect*/ { 0,	   0,0,	 ""	       },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcrtomb, TST_LOC_end }
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcscat.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcscat.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcscat.c	(revision 2036)
@@ -0,0 +1,112 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_wcscat.c
+ *
+ *	 WCSCAT:  wchar_t *wcscat (wchar_t *ws1, wchar_t *ws2)
+ */
+
+/* NOTE:
+   Since this is not a locale sensitive function,
+   it doesn't make sense to test the function on some
+   locales. Better make different test cases for each locale ...
+   (Also some wc* functions are not locale sensitive.)
+*/
+
+
+TST_WCSCAT tst_wcscat_loc [] = {
+
+  {
+    {Twcscat, TST_LOC_de},
+    {
+      /* 1 */
+      {{{ 0x00C1,0x00C2,0x0000	},
+	{			0x00C3,0x00C4,0x0000 }, },
+       {   0,	0,    0,
+	   { 0x00C1,0x00C2,0x00C3,0x00C4,0x0000 }	},
+      },
+      /* 2 */
+      {{{ 0x0001,0x0002,0x0000	},
+	{			0x0003,0x0004,0x0000 }, },
+       {   0,	0,    0,
+	   { 0x0001,0x0002,0x0003,0x0004,0x0000 }	},
+      },
+      /* 3 */
+      {{{ 0x0000		  },
+	{			0x00C3,0x00C4,0x0000 }, },
+       {   0,	0,    0,
+	   {		0x00C3,0x00C4,0x0000 }	},
+      },
+      /* 4 */
+      {{{ 0x0001,0xFFFF,0x0000	},
+	{			0x0080,0x0090,0x0000 }, },
+       {   0,	0,    0,
+	   { 0x0001,0xFFFF,0x0080,0x0090,0x0000 }	},
+      },
+      {.is_last = 1}
+    }
+  },
+  {
+    {Twcscat, TST_LOC_enUS},
+    {
+      /* 1 */
+      {{{ 0x0041,0x0042,0x0000	},
+	{		  0x0043,0x0044,0x0000 }, },
+       {   0,	  0,	0,
+	   { 0x0041,0x0042,0x0043,0x0044,0x0000 }  },
+      },
+      /* 2 */
+      {{{ 0x0001,0x0002,0x0000	},
+	{		  0x0003,0x0004,0x0000 }, },
+       {   0,	  0,	0,
+	   { 0x0001,0x0002,0x0003,0x0004,0x0000 }  },
+      },
+      /* 3 */
+      {{{ 0x0000		    },
+	{		  0x0043,0x0044,0x0000 }, },
+       {   0,	  0,	0,
+	   {		  0x0043,0x0044,0x0000 }  },
+      },
+      /* 4 */
+      {{{ 0x0001,0xFFFF,0x0000	},
+	{		  0x0080,0x0090,0x0000 }, },
+       {   0,	  0,	0,
+	   { 0x0001,0xFFFF,0x0080,0x0090,0x0000 }  },
+      },
+      {.is_last = 1}
+    }
+  },
+  {
+    {Twcscat, TST_LOC_eucJP},
+    {
+      /* 1 */
+      {{{ 0x30A2,0x74E0,0x0000	},
+	{			0xFF71,0x0041,0x0000 }, },
+       {   0,	0,    0,
+	   { 0x30A2,0x74E0,0xFF71,0x0041,0x0000 }	},
+      },
+      /* 2 */
+      {{{ 0x0001,0x0002,0x0000	},
+	{			0x0003,0x0004,0x0000 }, },
+       {   0,	0,    0,
+	   { 0x0001,0x0002,0x0003,0x0004,0x0000 }	},
+      },
+      /* 3 */
+      {{{ 0x30A2,0xFF71,0x0000	},
+	{			0x0000		     }, },
+       {   0,	0,    0,
+	   { 0x30A2,0xFF71,0x0000		     }	},
+      },
+      /* 4 */
+      {{{ 0x0001,0xFFFF,0x0000	},
+	{			0x0080,0x0090,0x0000 }, },
+       {   0,	0,    0,
+	   { 0x0001,0xFFFF,0x0080,0x0090,0x0000 }	},
+      },
+      {.is_last = 1}
+    }
+  },
+  {
+    {Twcscat, TST_LOC_end}
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcschr.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcschr.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcschr.c	(revision 2036)
@@ -0,0 +1,90 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_wcschr.c
+ *
+ *	 WCSCHR:  wchar_t  *wcschr (const wchar_t *ws, wchar_t wc);
+ */
+
+TST_WCSCHR tst_wcschr_loc [] = {
+
+    {	{ Twcschr, TST_LOC_de },
+	{
+	  { /*input.*/ { { 0x00C1,0x00C2,0x00C3,0x0000 }, 0x00C0 },  /* #1 */
+	    /*expect*/ { 0,1,(wchar_t *)NULL },
+	  },
+	  { /*input.*/ { { 0x00C1,0x00C2,0x00C3,0x0000 }, 0x00C1 },  /* #2 */
+	    /*expect*/ { 0,0,0 },
+	  },
+	  { /*input.*/ { { 0x00C1,0x00C2,0x00C3,0x0000 }, 0x00C2 },  /* #3 */
+	    /*expect*/ { 0,0,0 },
+	  },
+	  { /*input.*/ { { 0x00C1,0x00C2,0x00C3,0x0000 }, 0x00C3 },  /* #4 */
+	    /*expect*/ { 0,0,0 },
+	  },
+	  { /*input.*/ { { 0x00C1,0x00C2,0x00C3,0x0000 }, 0x0000 },  /* #5 */
+	    /*expect*/ { 0,0,0 },
+	  },
+	  { /*input.*/ { { 0x0000,0x00C2,0x00C3,0x0000 }, 0x00C1 },  /* #6 */
+	    /*expect*/ { 0,1,(wchar_t *)NULL },
+	  },
+	  { /*input.*/ { { 0x0000,0x00C2,0x00C3,0x0000 }, 0x0000 },  /* #7 */
+	    /*expect*/ { 0,0,0 },
+	  },
+	  { .is_last = 1 }
+	}
+    },
+    {	{ Twcschr, TST_LOC_enUS },
+	{
+	  { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 }, 0x0040 },  /* #1 */
+	    /*expect*/ { 0,1,(wchar_t *)NULL },
+	  },
+	  { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 }, 0x0041 },  /* #2 */
+	    /*expect*/ { 0,0,0 },
+	  },
+	  { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 }, 0x0042 },  /* #3 */
+	    /*expect*/ { 0,0,0 },
+	  },
+	  { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 }, 0x0043 },  /* #4 */
+	    /*expect*/ { 0,0,0 },
+	  },
+	  { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 }, 0x0000 },  /* #5 */
+	    /*expect*/ { 0,0,0 },
+	  },
+	  { /*input.*/ { { 0x0000,0x0042,0x0043,0x0000 }, 0x0041 },  /* #6 */
+	    /*expect*/ { 0,1,(wchar_t *)NULL },
+	  },
+	  { /*input.*/ { { 0x0000,0x0042,0x0043,0x0000 }, 0x0000 },  /* #7 */
+	    /*expect*/ { 0,0,0 },
+	  },
+	  { .is_last = 1 }
+	}
+    },
+    {	{ Twcschr, TST_LOC_eucJP },
+	{
+	  { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 }, 0x3040 },  /* #1 */
+	    /*expect*/ { 0,1,(wchar_t *)NULL },
+	  },
+	  { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 }, 0x3041 },  /* #2 */
+	    /*expect*/ { 0,0,0 },
+	  },
+	  { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 }, 0x3042 },  /* #3 */
+	    /*expect*/ { 0,0,0 },
+	  },
+	  { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 }, 0x3043 },  /* #4 */
+	    /*expect*/ { 0,0,0 },
+	  },
+	  { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 }, 0x0000 },  /* #5 */
+	    /*expect*/ { 0,0,0 },
+	  },
+	  { /*input.*/ { { 0x0000,0x3042,0x3043,0x0000 }, 0x3041 },  /* #6 */
+	    /*expect*/ { 0,1,(wchar_t *)NULL },
+	  },
+	  { /*input.*/ { { 0x0000,0x3042,0x3043,0x0000 }, 0x0000 },  /* #7 */
+	    /*expect*/ { 0,0,0 },
+	  },
+	  { .is_last = 1 }
+	}
+    },
+    {	{ Twcschr, TST_LOC_end } }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcscmp.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcscmp.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcscmp.c	(revision 2036)
@@ -0,0 +1,133 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE: dat_wcscmp.c
+ *
+ *	 WCSCMP:  int  wcscmp (const wchar_t *ws1, const wchar_t *ws2);
+ */
+
+/* NOTE:
+	This is not a locale sensitive function and
+	it may not make sence testing it for each locale ...
+*/
+
+
+TST_WCSCMP tst_wcscmp_loc [] = {
+  {
+    { Twcscmp, TST_LOC_de },
+    {
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     { 0x00D1,0x00D2,0x00D3,0x0000 }, },  /* #1 */
+	/*expect*/ { 0,1,0,			  },
+      },
+      { /*input.*/ { { 0x0000,0x00D1,0x00D3,0x0000 },
+		     { 0x0000,0x00D2,0x00D3,0x0000 }, },  /* #2 */
+	/*expect*/ { 0,1,0,			  },
+      },
+      { /*input.*/ { { 0x00D1,0x00D1,0x00D3,0x0000 },
+		     { 0x0000,0x00D2,0x00D3,0x0000 }, },  /* #3 */
+	/*expect*/ { 0,1,1,			  },
+      },
+      { /*input.*/ { { 0x0000,0x00D2,0x00D3,0x0000 },
+		     { 0x00D1,0x00D1,0x00D3,0x0000 }, },  /* #4 */
+	/*expect*/ { 0,1,-1,			  },
+      },
+      { /*input.*/ { { 0x00D1,0x00D5,0x00D3,0x0000 },
+		     { 0x00D1,0x00D2,0x00D3,0x0000 }, },  /* #5 */
+	/*expect*/ { 0,1,1,			  },
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     { 0x00D1,0x00D2,0x00D9,0x0000 }, },  /* #6 */
+	/*expect*/ { 0,1,-1,			  },
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x0000	       },
+		     { 0x00D1,0x00D2,0x00D9,0x0000 }, },  /* #7 */
+	/*expect*/ { 0,1,-1,			  },
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D9,0x0000 },
+		     { 0x00D1,0x00D2,0x0000	       }, },  /* #8 */
+	/*expect*/ { 0,1,1,			  },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcscmp, TST_LOC_enUS },
+    {
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     { 0x0041,0x0042,0x0043,0x0000 }, },  /* #1 */
+	/*expect*/ { 0,1,0,			  },
+      },
+      { /*input.*/ { { 0x0000,0x0041,0x0043,0x0000 },
+		     { 0x0000,0x0042,0x0043,0x0000 }, },  /* #2 */
+	/*expect*/ { 0,1,0,			  },
+      },
+      { /*input.*/ { { 0x0041,0x0041,0x0043,0x0000 },
+		     { 0x0000,0x0042,0x0043,0x0000 }, },  /* #3 */
+	/*expect*/ { 0,1,1,			  },
+      },
+      { /*input.*/ { { 0x0000,0x0042,0x0043,0x0000 },
+		     { 0x0041,0x0041,0x0043,0x0000 }, },  /* #4 */
+	/*expect*/ { 0,1,-1,			  },
+      },
+      { /*input.*/ { { 0x0041,0x0045,0x0043,0x0000 },
+		     { 0x0041,0x0042,0x0043,0x0000 }, },  /* #5 */
+	/*expect*/ { 0,1,1,			  },
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     { 0x0041,0x0042,0x0049,0x0000 }, },  /* #6 */
+	/*expect*/ { 0,1,-1,			  },
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0000	       },
+		     { 0x0041,0x0042,0x0049,0x0000 }, },  /* #7 */
+	/*expect*/ { 0,1,-1,			  },
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0049,0x0000 },
+		     { 0x0041,0x0042,0x0000	       }, },  /* #8 */
+	/*expect*/ { 0,1,1,			  },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcscmp, TST_LOC_eucJP},
+    {
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     { 0x3041,0x3042,0x3043,0x0000 }, },  /* #1 */
+	/*expect*/ { 0,1,0,			  },
+      },
+      { /*input.*/ { { 0x0000,0x3041,0x3043,0x0000 },
+		     { 0x0000,0x3042,0x3043,0x0000 }, },  /* #2 */
+	/*expect*/ { 0,1,0,			  },
+      },
+      { /*input.*/ { { 0x3041,0x3041,0x3043,0x0000 },
+		     { 0x0000,0x3042,0x3043,0x0000 }, },  /* #3 */
+	/*expect*/ { 0,1,1,			  },
+      },
+      { /*input.*/ { { 0x0000,0x3042,0x3043,0x0000 },
+		     { 0x3041,0x3041,0x3043,0x0000 }, },  /* #4 */
+	/*expect*/ { 0,1,-1,			  },
+      },
+      { /*input.*/ { { 0x3041,0x3045,0x3043,0x0000 },
+		     { 0x3041,0x3042,0x3043,0x0000 }, },  /* #5 */
+	/*expect*/ { 0,1,1,			  },
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     { 0x3041,0x3042,0x3049,0x0000 }, },  /* #6 */
+	/*expect*/ { 0,1,-1,			  },
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x0000	       },
+		     { 0x3041,0x3042,0x3049,0x0000 }, },  /* #7 */
+	/*expect*/ { 0,1,-1,			  },
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3049,0x0000 },
+		     { 0x3041,0x3042,0x0000	       }, },  /* #8 */
+	/*expect*/ { 0,1,1,			  },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcschr, TST_LOC_end}
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcscoll.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcscoll.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcscoll.c	(revision 2036)
@@ -0,0 +1,206 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE: dat_wcscoll.c
+ *
+ *	 WCSCOLL:  int	wcscoll (const wchar_t *ws1, const wchar_t *ws2);
+ */
+
+/*
+ *  CAUTION:
+ *	     When LC_COLLATE (or LC_ALL) is set for ja_JP.EUC,
+ *	     wcscoll() core-dumps for big values such as 0x3041
+ *	     (0x0041 is okay) in glibc 2.1.2.
+ *
+ *  NOTE:
+ *    a) When 0 is expected as a return value, set ret_flg=1.
+ *	 - the return value is compared with an expected value: ret_val.
+ *    b) When a positive value is expected as a return value,
+ *	 set ret_flg=0 and set cmp_flg=+1.
+ *	 - the return value is not compared with the expected value
+ *	   (can not be compared); instead, the test program checks
+ *	   if the return value is positive when cmp_flg=+1.
+ *    c) When a negative value is expected as a return value,
+ *	 ......
+ *    d) When data contains invalid values, set err_val to the expected errno.
+ *	 Set ret_flg=0 and cmp_flg=0 so that it doesn't compare
+ *	 the return value with an expected value or doesn't check
+ *	 the sign of the return value.
+ *
+ *
+ *	     -------------------------------------------
+ *	     CASE  err_val   ret_flg  ret_val	 cmp_flg
+ *	     -------------------------------------------
+ *	      a)      0	 1	  0	    0
+ *	      b)      0	 0	  0	   +1
+ *	      c)      0	 0	  0	   -1
+ *	      d)    EINVAL	 0	  0	    0
+ *	     -------------------------------------------
+ */
+
+
+TST_WCSCOLL tst_wcscoll_loc [] = {
+
+    {	{ Twcscoll, TST_LOC_de },
+	{
+	  { /*input.*/ { { 0x00E1,0x00E2,0x00E3,0x0000 },
+			 { 0x00E1,0x00E2,0x00E3,0x0000 }, },  /* #1 */
+	    /*expect*/ { 0,1,0, 0,			  },
+	  },
+	  { /*input.*/ { { 0x0000,0x00E1,0x00E3,0x0000 },
+			 { 0x0000,0x00E2,0x00E3,0x0000 }, },  /* #2 */
+	    /*expect*/ { 0,1,0, 0,			  },
+	  },
+	  { /*input.*/ { { 0x00E1,0x00E1,0x00E3,0x0000 },
+			 { 0x0000,0x00E2,0x00E3,0x0000 }, },  /* #3 */
+	    /*expect*/ { 0,0,0, +1,			  },
+	  },
+	  { /*input.*/ { { 0x0000,0x00E2,0x00E3,0x0000 },
+			 { 0x00E1,0x00E1,0x00E3,0x0000 }, },  /* #4 */
+	    /*expect*/ { 0,0,0, -1,			  },
+	  },
+	  { /*input.*/ { { 0x00E1,0x0042,0x00E3,0x0000 },
+			 { 0x00E1,0x0061,0x00E3,0x0000 }, },  /* #5 */
+	    /*expect*/ { 0,0,0, +1,			  },
+	  },
+	  { /*input.*/ { { 0x00E1,0x0061,0x00E3,0x0000 },
+			 { 0x00E1,0x0042,0x00E3,0x0000 }, },  /* #6 */
+	    /*expect*/ { 0,0,0, -1,			  },
+	  },
+	  { /*input.*/ { { 0x00E1,0x00E2,0x0000	       },
+			 { 0x00E1,0x00E2,0x00E9,0x0000 }, },  /* #7 */
+	    /*expect*/ { 0,0,0, -1,			  },
+	  },
+	  { /*input.*/ { { 0x00E1,0x00E2,0x00E9,0x0000 },
+			 { 0x00E1,0x00E2,0x0000	       }, },  /* #8 */
+	    /*expect*/ { 0,0,0, +1,			  },
+	  },
+	  { /*input.*/ { { 0x00E1,0x0092,0x00E9,0x0000 },
+			 { 0x00E1,0x008E,0x00E9,0x0000 }, },  /* #9 */
+	    /*expect*/ { 0,0,0, +1,		       },
+	  },
+	  { /*input.*/ { { 0x00E1,0x008E,0x00E9,0x0000 },
+			 { 0x00E1,0x0092,0x00E9,0x0000 }, },  /* #10 */
+	    /*expect*/ { 0,0,0, -1,		       },
+	  },
+	  { .is_last = 1 }
+	}
+    },
+    {	{ Twcscoll, TST_LOC_enUS },
+	{
+	  { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+			 { 0x0041,0x0042,0x0043,0x0000 }, },  /* #1 */
+	    /*expect*/ { 0,1,0, 0,			  },
+	  },
+	  { /*input.*/ { { 0x0000,0x0041,0x0043,0x0000 },
+			 { 0x0000,0x0042,0x0043,0x0000 }, },  /* #2 */
+	    /*expect*/ { 0,1,0, 0,			  },
+	  },
+	  { /*input.*/ { { 0x0041,0x0041,0x0043,0x0000 },
+			 { 0x0000,0x0042,0x0043,0x0000 }, },  /* #3 */
+	    /*expect*/ { 0,0,0, +1,			  },
+	  },
+	  { /*input.*/ { { 0x0000,0x0042,0x0043,0x0000 },
+			 { 0x0041,0x0041,0x0043,0x0000 }, },  /* #4 */
+	    /*expect*/ { 0,0,0, -1,			  },
+	  },
+#ifdef SHOJI_IS_RIGHT
+	  /* <WAIVER> */ /* assume ascii */
+	  { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+			 { 0x0041,0x0061,0x0043,0x0000 }, },  /* #5 */
+	    /*expect*/ { 0,0,0, -1,			  },
+	  },
+	  /* <WAIVER> */ /* assume ascii */
+	  { /*input.*/ { { 0x0041,0x0061,0x0043,0x0000 },
+			 { 0x0041,0x0042,0x0043,0x0000 }, },  /* #6 */
+	    /*expect*/ { 0,0,0, +1,			  },
+	  },
+#else
+	  /* XXX Correct order is lowercase before uppercase.  */
+	  { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+			 { 0x0041,0x0061,0x0043,0x0000 }, },  /* #5 */
+	    /*expect*/ { 0,0,0, +1,			  },
+	  },
+	  { /*input.*/ { { 0x0041,0x0061,0x0043,0x0000 },
+			 { 0x0041,0x0042,0x0043,0x0000 }, },  /* #6 */
+	    /*expect*/ { 0,0,0, -1,			  },
+	  },
+#endif
+	  { /*input.*/ { { 0x0041,0x0042,0x0000	       },
+			 { 0x0041,0x0042,0x0049,0x0000 }, },  /* #7 */
+	    /*expect*/ { 0,0,0, -1,			  },
+	  },
+	  { /*input.*/ { { 0x0041,0x0042,0x0049,0x0000 },
+			 { 0x0041,0x0042,0x0000	       }, },  /* #8 */
+	    /*expect*/ { 0,0,0, +1,			  },
+	  },
+#ifdef SHOJI_IS_RIGHT
+	  { /*input.*/ { { 0x0041,0x0092,0x0049,0x0000 },
+			 { 0x0041,0x008E,0x0049,0x0000 }, },  /* #9 */
+	    /*expect*/ { 0,0,0, +1,		       },
+	  },
+	  { /*input.*/ { { 0x0041,0x008E,0x0049,0x0000 },
+			 { 0x0041,0x0092,0x0049,0x0000 }, },  /* #10 */
+	    /*expect*/ { 0,0,0, -1,		       },
+	  },
+#else
+	  /* Do not assume position of character out of range.  */
+	  { /*input.*/ { { 0x0041,0x0092,0x0049,0x0000 },
+			 { 0x0041,0x008E,0x0049,0x0000 }, },  /* #9 */
+	    /*expect*/ { 0,0,0, 0,		       },
+	  },
+	  { /*input.*/ { { 0x0041,0x008E,0x0049,0x0000 },
+			 { 0x0041,0x0092,0x0049,0x0000 }, },  /* #10 */
+	    /*expect*/ { 0,0,0, 0,		       },
+	  },
+#endif
+	  { .is_last = 1 }
+	}
+    },
+    {	{ Twcscoll, TST_LOC_eucJP },
+	{
+	  { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+			 { 0x3041,0x3042,0x3043,0x0000 }, },  /* #1 */
+	    /*expect*/ { 0,1,0, 0,			  },
+	  },
+	  { /*input.*/ { { 0x0000,0x3041,0x3043,0x0000 },
+			 { 0x0000,0x3042,0x3043,0x0000 }, },  /* #2 */
+	    /*expect*/ { 0,1,0, 0,			  },
+	  },
+	  { /*input.*/ { { 0x3041,0x3041,0x3043,0x0000 },
+			 { 0x0000,0x3042,0x3043,0x0000 }, },  /* #3 */
+	    /*expect*/ { 0,0,0, +1,			  },
+	  },
+	  { /*input.*/ { { 0x0000,0x3042,0x3043,0x0000 },
+			 { 0x3041,0x3041,0x3043,0x0000 }, },  /* #4 */
+	    /*expect*/ { 0,0,0, -1,			  },
+	  },
+	  { /*input.*/ { { 0x3041,0x0042,0x3043,0x0000 },
+			 { 0x3041,0x0061,0x3043,0x0000 }, },  /* #5 */
+	    /*expect*/ { 0,0,0, -1,			  },
+	  },
+	  { /*input.*/ { { 0x3041,0x0061,0x3043,0x0000 },
+			 { 0x3041,0x0042,0x3043,0x0000 }, },  /* #6 */
+	    /*expect*/ { 0,0,0, +1,			  },
+	  },
+	  { /*input.*/ { { 0x3041,0x3042,0xFF71,0x0000 },
+			 { 0x3041,0x3042,0x30A2,0x0000 }, },  /* #7 */
+	    /*expect*/ { 0,0,0, -1,			  },
+	  },
+	  { /*input.*/ { { 0x3041,0x3042,0x30A2,0x0000 },
+			 { 0x3041,0x3042,0xFF71,0x0000 }, },  /* #8 */
+	    /*expect*/ { 0,0,0, +1,			  },
+	  },
+	  { /*input.*/ { { 0x30FF,0x3092,0x3049,0x0000 },
+			 { 0x3041,0x308E,0x3049,0x0000 }, },  /* #9 */
+	    /*expect*/ { 0,0,0, -1,		       },
+	  },
+	  { /*input.*/ { { 0x3041,0x308E,0x3049,0x0000 },
+			 { 0x30FF,0x3092,0x3049,0x0000 }, },  /* #10 */
+	    /*expect*/ { 0,0,0, +1,		       },
+	  },
+	  { .is_last = 1 }
+	}
+    },
+    {	{ Twcscoll, TST_LOC_end } }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcscpy.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcscpy.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcscpy.c	(revision 2036)
@@ -0,0 +1,40 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_wcscpy.c
+ *
+ *	 WCSCPY:  wchar_t *wcscpy (wchar_t *ws1, const wchar_t *ws2);
+ */
+
+TST_WCSCPY tst_wcscpy_loc [] = {
+
+    {	{ Twcscpy, TST_LOC_de },
+	{
+	    { {		  { 0x00F1,0x00F2,0x00F3,0x0000	 }, },	   /* 1 */
+	      {	 0,0,0,   { 0x00F1,0x00F2,0x00F3,0x0000, }  }, },
+	    { {		  { 0x0000,0x00F2,0x00F3,0x0000	 }, },	   /* 2 */
+	      {	 0,0,0,   { 0x0000,			 }  }, },
+	    { .is_last = 1 }
+	}
+    },
+    {	{ Twcscpy, TST_LOC_enUS },
+	{
+	    { {		  { 0x0041,0x0082,0x0043,0x0000	 }, },	   /* 1 */
+	      {	 0,0,0,   { 0x0041,0x0082,0x0043,0x0000, }  }, },
+	    { {		  { 0x0000,0x0082,0x0043,0x0000	 }, },	   /* 2 */
+	      {	 0,0,0,   { 0x0000,			 }  }, },
+	    { .is_last = 1 }
+	}
+    },
+    {	{ Twcscpy, TST_LOC_eucJP },
+	{
+	    { {		  { 0x3041,0x0092,0x3043,0x0000	 }, },	   /* 1 */
+	      {	 0,0,0,   { 0x3041,0x0092,0x3043,0x0000, }  }, },
+	    { {		  { 0x0000,0x0092,0x3043,0x0000	 }, },	   /* 2 */
+	      {	 0,0,0,   { 0x0000,			 }  }, },
+	    { .is_last = 1 }
+	}
+    },
+    {	{ Twcscpy, TST_LOC_end }}
+
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcscspn.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcscspn.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcscspn.c	(revision 2036)
@@ -0,0 +1,160 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_wcscspn.c
+ *
+ *	 WCSCSPN:  size_t wcscspn (const wchar_t *ws1, const wchar_t *ws2);
+ */
+
+
+TST_WCSCSPN tst_wcscspn_loc [] = {
+
+    {	{ Twcscspn, TST_LOC_de },
+	{
+	  { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+			 { 0x00D1,0x0000	       }, },  /* #1 */
+	    /*expect*/ { 0,1,0,			  },
+	  },
+	  { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+			 {	  0x00D2,0x0000	       }, },  /* #2 */
+	    /*expect*/ { 0,1,1,			  },
+	  },
+	  { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+			 {		 0x00D3,0x0000 }, },  /* #3 */
+	    /*expect*/ { 0,1,2,			  },
+	  },
+	  { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+			 {	  0x00D2,0x00D3,0x0000 }, },  /* #4 */
+	    /*expect*/ { 0,1,1,			  },
+	  },
+	  { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+			 { 0x00D2,0x00D3,0x00D4,0x0000 }, },  /* #5 */
+	    /*expect*/ { 0,1,1,			  },
+	  },
+	  { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+			 { 0x00D3,0x00D4,0x00D5,0x0000 }, },  /* #6 */
+	    /*expect*/ { 0,1,2,			  },
+	  },
+	  { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+			 { 0x00D1,0x00D2,0x00D3,0x0000 }, },  /* #7 */
+	    /*expect*/ { 0,1,0,			  },
+	  },
+	  { /*input.*/ { { 0x0000,0x00D2,0x00D3,0x0000 },
+			 { 0x00D2,0x000		       }, },  /* #8 */
+	    /*expect*/ { 0,1,0,			  },
+	  },
+	  { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+			 { 0x0000,0x00D2,0x00D3,0x0000 }, },  /* #9 */
+	    /*expect*/ { 0,1,3,			  },
+	  },
+	  { /*input.*/ { { 0x00D1,0x00D2,0x0000	       },
+			 { 0x00D1,0x00D2,0x00D3,0x0000 }, },  /* #10 */
+	    /*expect*/ { 0,1,0,			  },
+	  },
+	  { /*input.*/ { { 0x00D1,0x00D2,0x0000	       },
+			 { 0x00D1,0x00D3,0x00D4,0x0000 }, },  /* #11 */
+	    /*expect*/ { 0,1,0,			  },
+	  },
+	  { .is_last = 1 }
+	}
+    },
+    {	{ Twcscspn, TST_LOC_enUS },
+	{
+	  { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+			 { 0x0041,0x0000	       }, },  /* #1 */
+	    /*expect*/ { 0,1,0,			  },
+	  },
+	  { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+			 {	  0x0042,0x0000	       }, },  /* #2 */
+	    /*expect*/ { 0,1,1,			  },
+	  },
+	  { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+			 {		 0x0043,0x0000 }, },  /* #3 */
+	    /*expect*/ { 0,1,2,			  },
+	  },
+	  { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+			 {	  0x0042,0x0043,0x0000 }, },  /* #4 */
+	    /*expect*/ { 0,1,1,			  },
+	  },
+	  { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+			 { 0x0042,0x0043,0x0044,0x0000 }, },  /* #5 */
+	    /*expect*/ { 0,1,1,			  },
+	  },
+	  { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+			 { 0x0043,0x0044,0x0045,0x0000 }, },  /* #6 */
+	    /*expect*/ { 0,1,2,			  },
+	  },
+	  { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+			 { 0x0041,0x0042,0x0043,0x0000 }, },  /* #7 */
+	    /*expect*/ { 0,1,0,			  },
+	  },
+	  { /*input.*/ { { 0x0000,0x0042,0x0043,0x0000 },
+			 { 0x0042,0x000		       }, },  /* #8 */
+	    /*expect*/ { 0,1,0,			  },
+	  },
+	  { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+			 { 0x0000,0x0042,0x0043,0x0000 }, },  /* #9 */
+	    /*expect*/ { 0,1,3,			  },
+	  },
+	  { /*input.*/ { { 0x0041,0x0042,0x0000	       },
+			 { 0x0041,0x0042,0x0043,0x0000 }, },  /* #10 */
+	    /*expect*/ { 0,1,0,			  },
+	  },
+	  { /*input.*/ { { 0x0041,0x0042,0x0000	       },
+			 { 0x0041,0x0043,0x0044,0x0000 }, },  /* #11 */
+	    /*expect*/ { 0,1,0,			  },
+	  },
+	  { .is_last = 1 }
+	}
+    },
+    {	{ Twcscspn, TST_LOC_eucJP },
+	{
+	  { /*input.*/ { { 0x3041,0x3042,0x0043,0x0000 },
+			 { 0x3041,0x0000	       }, },  /* #1 */
+	    /*expect*/ { 0,1,0,			  },
+	  },
+	  { /*input.*/ { { 0x3041,0x3042,0x0043,0x0000 },
+			 {	  0x3042,0x0000	       }, },  /* #2 */
+	    /*expect*/ { 0,1,1,			  },
+	  },
+	  { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+			 {		 0x3043,0x0000 }, },  /* #3 */
+	    /*expect*/ { 0,1,2,			  },
+	  },
+	  { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+			 {	  0x3042,0x3043,0x0000 }, },  /* #4 */
+	    /*expect*/ { 0,1,1,			  },
+	  },
+	  { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+			 { 0x3042,0x3043,0x3044,0x0000 }, },  /* #5 */
+	    /*expect*/ { 0,1,1,			  },
+	  },
+	  { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+			 { 0x3043,0x3044,0x3045,0x0000 }, },  /* #6 */
+	    /*expect*/ { 0,1,2,			  },
+	  },
+	  { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+			 { 0x3041,0x3042,0x3043,0x0000 }, },  /* #7 */
+	    /*expect*/ { 0,1,0,			  },
+	  },
+	  { /*input.*/ { { 0x0000,0x3042,0x3043,0x0000 },
+			 { 0x3042,0x0000	       }, },  /* #8 */
+	    /*expect*/ { 0,1,0,			  },
+	  },
+	  { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+			 { 0x0000,0x3042,0x3043,0x0000 }, },  /* #9 */
+	    /*expect*/ { 0,1,3,			  },
+	  },
+	  { /*input.*/ { { 0x3041,0x3042,0x0000	       },
+			 { 0x3041,0x3042,0x3043,0x0000 }, },  /* #10 */
+	    /*expect*/ { 0,1,0,			  },
+	  },
+	  { /*input.*/ { { 0x3041,0x3042,0x0000	       },
+			 { 0x3041,0x3043,0x3044,0x0000 }, },  /* #11 */
+	    /*expect*/ { 0,1,0,			  },
+	  },
+	  { .is_last = 1 }
+	}
+    },
+    {	{ Twcscspn, TST_LOC_end }}
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcslen.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcslen.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcslen.c	(revision 2036)
@@ -0,0 +1,58 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN CLIBRARY
+ *
+ *       FILE:  dat_wcslen.c
+ *
+ *       WCSLEN:  size_t wcslen (const wchar_t *ws);
+ */
+
+
+/*
+ *  NOTE:
+ *
+ *      a header in each expected data:
+ *
+ *         int  err_val;  ... expected value for errno
+ *        <typ> ret_flg; ... set ret_flg=1 to compare an expected
+ *                           value with an actual value
+ *        <typ> ret_val; ... expected value for return
+ */
+
+
+TST_WCSLEN tst_wcslen_loc [] = {
+
+  {   { Twcslen, TST_LOC_de },
+      {
+	{ /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 } },  /* #01 */
+	  /*expect*/ { 0,1,3,                        },
+	},
+	{ /*input.*/ { { 0x0000 }                      },  /* #02 */
+	  /*expect*/ { 0,1,0,                        },
+	},
+	{ .is_last = 1 }
+      }
+  },
+  {   { Twcslen, TST_LOC_enUS },
+      {
+	{ /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 } },  /* #01 */
+	  /*expect*/ { 0,1,3,                        },
+	},
+	{ /*input.*/ { { 0x0000 }                      },  /* #02 */
+	  /*expect*/ { 0,1,0,                        },
+	},
+	{ .is_last = 1 }
+      }
+  },
+  {   { Twcslen, TST_LOC_eucJP },
+      {
+	{ /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 } },  /* #01 */
+	  /*expect*/ { 0,1,3,                        },
+	},
+	{ /*input.*/ { { 0x0000 }                      },  /* #02 */
+	  /*expect*/ { 0,1,0,                        },
+	},
+	{ .is_last = 1 }
+      }
+  },
+  {   { Twcslen, TST_LOC_end }}
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcsncat.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcsncat.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcsncat.c	(revision 2036)
@@ -0,0 +1,154 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_wcsncat.c
+ *
+ *	 WCSNCAT:  wchar_t *wcsncat (wchar_t *ws1, wchar_t *ws2, size_t n);
+ */
+
+
+/*
+ *  Note:
+ *	  A terminating null wide chararacter is always appended to
+ *	  the result: ws1.
+ *
+ */
+
+
+TST_WCSNCAT tst_wcsncat_loc [] = {
+  {
+    {Twcsncat, TST_LOC_de},
+    {
+      /* 1 */
+      {
+	/* Input: */
+	{{ 0x00D1,0x00D2,0x0000	 },
+	 {		    0x00D3,0x00D4,0x0000 }, 3 },
+	/* Expect: */
+	{   0,	0,    0,
+	    { 0x00D1,0x00D2,0x00D3,0x00D4,0x0000 }    },
+      },
+      /* 2 */
+      {{{ 0x00D1,0x00D2,0x0000	},
+	{		   0x00D3,0x00D4,0x0000 }, 2 },
+       {   0,    0,    0,
+	   { 0x00D1,0x00D2,0x00D3,0x00D4,0x0000 }    },
+      },
+      /* 3 */
+      {{{ 0x00E1,0x00E2,0x0000	},
+	{		   0x00E3,0x00E4,0x0000 }, 1 },
+       {   0,    0,    0,
+	   { 0x00E1,0x00E2,0x00E3,0x0000	}    },
+      },
+      /* 4 */
+      {{{ 0x00E1,0x00E2,0x0000	},
+	{		   0x00E3,0x00E4,0x0000 }, 0 },
+       {   0,    0,    0,
+	   { 0x00E1,0x00E2,0x0000		}    },
+      },
+      /* 5 */
+      {{{ 0x0000		},
+	{		   0x00D3,0x00D4,0x0000 }, 3 },
+       {   0,    0,    0,
+	   {		   0x00D3,0x00D4,0x0000 }    },
+      },
+      /* 6 */
+      {{{ 0x00E1,0x00E2,0x0000	},
+	{		   0x0000		}, 3 },
+       {   0,    0,    0,
+	   { 0x00E1,0x00E2,0x0000		}    },
+      },
+      {.is_last = 1}
+    }
+  },
+  {
+    {Twcsncat, TST_LOC_enUS},
+    {
+      /* 1 */
+      {
+	/* Input:  */
+	{{ 0x0041,0x0042,0x0000	 },
+	 {		    0x0043,0x0044,0x0000 }, 3 },
+	/* Expect:  */
+	{   0,	0,    0,
+	    { 0x0041,0x0042,0x0043,0x0044,0x0000 }    },
+      },
+      /* 2 */
+      {{{ 0x0041,0x0042,0x0000	},
+	{		   0x0043,0x0044,0x0000 }, 2 },
+       {   0,    0,    0,
+	   { 0x0041,0x0042,0x0043,0x0044,0x0000 }    },
+      },
+      /* 3 */
+      {{{ 0x0051,0x0052,0x0000	},
+	{		   0x0053,0x0054,0x0000 }, 1 },
+       {   0,    0,    0,
+	   { 0x0051,0x0052,0x0053,0x0000	}    },
+      },
+      /* 4 */
+      {{{ 0x0051,0x0052,0x0000	},
+	{		   0x0053,0x0054,0x0000 }, 0 },
+       {   0,    0,    0,
+	   { 0x0051,0x0052,0x0000		}    },
+      },
+      /* 5 */
+      {{{ 0x0000		},
+	{		   0x0043,0x0044,0x0000 }, 3 },
+       {   0,    0,    0,
+	   {		   0x0043,0x0044,0x0000 }    },
+      },
+      /* 6 */
+      {{{ 0x0051,0x0052,0x0000	},
+	{		   0x0000		}, 3 },
+       {   0,    0,    0,
+	   { 0x0051,0x0052,0x0000		}    },
+      },
+      {.is_last = 1}
+    }
+  },
+  {
+    {Twcsncat, TST_LOC_eucJP},
+    {
+      /* 1 */
+      {{{ 0x3041,0x3042,0x0000	},
+	{		   0x3043,0x3044,0x0000 }, 3 },
+       {   0,    0,    0,
+	   { 0x3041,0x3042,0x3043,0x3044,0x0000 }    },
+      },
+      /* 2 */
+      {{{ 0x30A2,0x30A3,0x0000	},
+	{		   0xFF71,0xFF72,0x0000 }, 2 },
+       {   0,    0,    0,
+	   { 0x30A2,0x30A3,0xFF71,0xFF72,0x0000 }    },
+      },
+      /* 3 */
+      {{{ 0x3051,0x3052,0x0000	},
+	{		   0x3053,0x3054,0x0000 }, 1 },
+       {   0,    0,    0,
+	   { 0x3051,0x3052,0x3053,0x0000	}    },
+      },
+      /* 4 */
+      {{{ 0x3051,0x3052,0x0000	},
+	{		   0x3053,0x3054,0x0000 }, 0 },
+       {   0,    0,    0,
+	   { 0x3051,0x3052,0x0000		}    },
+      },
+      /* 5 */
+      {{{ 0x0000		},
+	{		   0x3043,0x3044,0x0000 }, 3 },
+       {   0,    0,    0,
+	   {		   0x3043,0x3044,0x0000 }    },
+      },
+      /* 6 */
+      {{{ 0x3051,0x3052,0x0000	},
+	{		   0x0000		}, 3 },
+       {   0,    0,    0,
+	   { 0x3051,0x3052,0x0000		}    },
+      },
+      {.is_last = 1}
+    }
+  },
+  {
+    {Twcsncat, TST_LOC_end}
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcsncmp.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcsncmp.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcsncmp.c	(revision 2036)
@@ -0,0 +1,140 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_wcsncmp.c
+ *
+ *	 WCSNCMP:  int wcsncmp (const wchar_t *ws1, const wchar_t *ws2,
+ *				size_t n);
+ */
+
+TST_WCSNCMP tst_wcsncmp_loc [] = {
+  {
+    { Twcsncmp, TST_LOC_de },
+    {
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     { 0x00D1,0x00D2,0x00D3,0x0000 }, 4 },  /* #01 */
+	/*expect*/ { 0,1,0,				},
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     { 0x00D1,0x00D2,0x00D3,0x0000 }, 3 },  /* #02 */
+	/*expect*/ { 0,1,0,				},
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D1,0x0000 },
+		     { 0x00D1,0x00D2,0x00D3,0x0000 }, 2 },  /* #03 */
+	/*expect*/ { 0,1,0,				},
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     { 0x00D0,0x00D2,0x00D3,0x0000 }, 0 },  /* #04 */
+	/*expect*/ { 0,1,0,				},
+      },
+      { /*input.*/ { { 0x0000,0x00D2,0x00D3,0x0000 },
+		     { 0x0000,0x00D2,0x00D1,0x0000 }, 3 },  /* #05 */
+	/*expect*/ { 0,1,0,				},
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     { 0x0000,0x00D2,0x00D3,0x0000 }, 3 },  /* #06 */
+	/*expect*/ { 0,1,0x00D1,			},
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     { 0x00D1,0x00D2,0x00D9,0x0000 }, 2 },  /* #07 */
+	/*expect*/ { 0,1,0,				},
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     { 0x00D1,0x00D2,0x00D9,0x0000 }, 3 },  /* #08 */
+	/*expect*/ { 0,1,-0x0006,			},
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     { 0x00D1,0x00D2,0x0000	   }, 4 },  /* #09 */
+	/*expect*/ { 0,1,0x00D3,			},
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcsncmp, TST_LOC_enUS },
+    {
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     { 0x0041,0x0042,0x0043,0x0000 }, 4 },  /* #01 */
+	/*expect*/ { 0,1,0,				},
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     { 0x0041,0x0042,0x0043,0x0000 }, 3 },  /* #02 */
+	/*expect*/ { 0,1,0,				},
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0041,0x0000 },
+		     { 0x0041,0x0042,0x0043,0x0000 }, 2 },  /* #03 */
+	/*expect*/ { 0,1,0,				},
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     { 0x0040,0x0042,0x0043,0x0000 }, 0 },  /* #04 */
+	/*expect*/ { 0,1,0,				},
+      },
+      { /*input.*/ { { 0x0000,0x0042,0x0043,0x0000 },
+		     { 0x0000,0x0042,0x0041,0x0000 }, 3 },  /* #05 */
+	/*expect*/ { 0,1,0,				},
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     { 0x0000,0x0042,0x0043,0x0000 }, 3 },  /* #06 */
+	/*expect*/ { 0,1,0x0041,			},
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     { 0x0041,0x0042,0x0049,0x0000 }, 2 },  /* #07 */
+	/*expect*/ { 0,1,0,				},
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     { 0x0041,0x0042,0x0049,0x0000 }, 3 },  /* #08 */
+	/*expect*/ { 0,1,-0x0006,			},
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     { 0x0041,0x0042,0x0000	   }, 4 },  /* #09 */
+	/*expect*/ { 0,1,0x0043,			},
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcsncmp, TST_LOC_eucJP },
+    {
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     { 0x3041,0x3042,0x3043,0x0000 }, 4 },  /* #01 */
+	/*expect*/ { 0,1,0,				},
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     { 0x3041,0x3042,0x3043,0x0000 }, 3 },  /* #02 */
+	/*expect*/ { 0,1,0,				},
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3041,0x0000 },
+		     { 0x3041,0x3042,0x3043,0x0000 }, 2 },  /* #03 */
+	/*expect*/ { 0,1,0,				},
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     { 0x3040,0x3042,0x3043,0x0000 }, 0 },  /* #04 */
+	/*expect*/ { 0,1,0,				},
+      },
+      { /*input.*/ { { 0x0000,0x3042,0x3043,0x0000 },
+		     { 0x0000,0x3042,0x3041,0x0000 }, 3 },  /* #05 */
+	/*expect*/ { 0,1,0,				},
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     { 0x0000,0x3042,0x3043,0x0000 }, 3 },  /* #06 */
+	/*expect*/ { 0,1,0x3041,			},
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     { 0x3041,0x3042,0x3049,0x0000 }, 2 },  /* #07 */
+	/*expect*/ { 0,1,0,				},
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     { 0x3041,0x3042,0x3049,0x0000 }, 3 },  /* #08 */
+	/*expect*/ { 0,1,-0x0006,			},
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     { 0x3041,0x3042,0x0000	   }, 4 },  /* #09 */
+	/*expect*/ { 0,1,0x3043,			},
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcsncmp, TST_LOC_end }
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcsncpy.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcsncpy.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcsncpy.c	(revision 2036)
@@ -0,0 +1,115 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *       FILE:  dat_wcsncpy.c
+ *
+ *       WCSNCPY:  wchar_t *wcsncpy (wchar_t *ws1, const wchar_t *ws2,
+ *                                   size_t n);
+ */
+
+
+/* Note:
+ *
+ *       An initial value of ws1 in the test program is defined as:
+ *
+ *       #define WCSNUM_NCPY 7
+ *       wchar_t ws1 [WCSSIZE] = { 0x9999, 0x9999, 0x9999, 0x9999,
+ *                                 0x9999, 0x9999, 0x0000 };
+ * */
+
+
+TST_WCSNCPY tst_wcsncpy_loc [] = {
+  {
+    {Twcsncpy, TST_LOC_de},
+    {
+      /* 1 */
+      {{           { 0x00D1,0x00D2,0x00D3,0x0000                      }, 6 },
+       {    0,0,0, { 0x00D1,0x00D2,0x00D3,0x0000,0x0000,0x0000,0x0000 }    },
+      },
+      /* 2 */
+      {{           { 0x00D1,0x00D2,0x00D3,0x0000                      }, 5 },
+       {    0,0,0, { 0x00D1,0x00D2,0x00D3,0x0000,0x0000,0x9999,0x0000 }    },
+      },
+      /* 3 */
+      {{           { 0x00D1,0x00D2,0x00D3,0x0000                      }, 3 },
+       {    0,0,0, { 0x00D1,0x00D2,0x00D3,0x9999,0x9999,0x9999,0x0000 }    },
+      },
+      /* 4 */
+      {{           { 0x00D1,0x00D2,0x00D3,0x0000                      }, 2 },
+       {    0,0,0, { 0x00D1,0x00D2,0x9999,0x9999,0x9999,0x9999,0x0000 }    },
+      },
+      /* 5 */
+      {{           { 0x00D1,0x00D2,0x00D3,0x0000                      }, 0 },
+       {    0,0,0, { 0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x0000 }    },
+      },
+      /* 6 */
+      {{           { 0x0000,0x00D2,0x00D3,0x0000                      }, 3 },
+       {    0,0,0, { 0x0000,0x0000,0x0000,0x9999,0x9999,0x9999,0x0000 }    },
+      },
+      {.is_last = 1}
+    }
+  },
+  {
+    {Twcsncpy, TST_LOC_enUS},
+    {
+      /* 1 */
+      {{           { 0x0041,0x0042,0x0043,0x0000                      }, 6 },
+       {    0,0,0, { 0x0041,0x0042,0x0043,0x0000,0x0000,0x0000,0x0000 }    },
+      },
+      /* 2 */
+      {{           { 0x0041,0x0042,0x0043,0x0000                      }, 5 },
+       {    0,0,0, { 0x0041,0x0042,0x0043,0x0000,0x0000,0x9999,0x0000 }    },
+      },
+      /* 3 */
+      {{           { 0x0041,0x0042,0x0043,0x0000                      }, 3 },
+       {    0,0,0, { 0x0041,0x0042,0x0043,0x9999,0x9999,0x9999,0x0000 }    },
+      },
+      /* 4 */
+      {{           { 0x0041,0x0042,0x0043,0x0000                      }, 2 },
+       {    0,0,0, { 0x0041,0x0042,0x9999,0x9999,0x9999,0x9999,0x0000 }    },
+      },
+      /* 5 */
+      {{           { 0x0041,0x0042,0x0043,0x0000                      }, 0 },
+       {    0,0,0, { 0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x0000 }    },
+      },
+      /* 6 */
+      {{           { 0x0000,0x0042,0x0043,0x0000                      }, 3 },
+       {    0,0,0, { 0x0000,0x0000,0x0000,0x9999,0x9999,0x9999,0x0000 }    },
+      },
+      {.is_last = 1}
+    }
+  },
+  {
+    {Twcsncpy, TST_LOC_eucJP},
+    {
+      /* 1 */
+      {{           { 0x3041,0x3042,0x3043,0x0000                      }, 6 },
+       {    0,0,0, { 0x3041,0x3042,0x3043,0x0000,0x0000,0x0000,0x0000 }    },
+      },
+      /* 2 */
+      {{           { 0x3041,0x3042,0x3043,0x0000                      }, 5 },
+       {    0,0,0, { 0x3041,0x3042,0x3043,0x0000,0x0000,0x9999,0x0000 }    },
+      },
+      /* 3 */
+      {{           { 0x3041,0x3042,0x3043,0x0000                      }, 3 },
+       {    0,0,0, { 0x3041,0x3042,0x3043,0x9999,0x9999,0x9999,0x0000 }    },
+      },
+      /* 4 */
+      {{           { 0x3041,0x3042,0x3043,0x0000                      }, 2 },
+       {    0,0,0, { 0x3041,0x3042,0x9999,0x9999,0x9999,0x9999,0x0000 }    },
+      },
+      /* 5 */
+      {{           { 0x3041,0x3042,0x3043,0x0000                      }, 0 },
+       {    0,0,0, { 0x9999,0x9999,0x9999,0x9999,0x9999,0x9999,0x0000 }    },
+      },
+      /* 6 */
+      {{           { 0x0000,0x3042,0x3043,0x0000                      }, 3 },
+       {    0,0,0, { 0x0000,0x0000,0x0000,0x9999,0x9999,0x9999,0x0000 }    },
+      },
+      {.is_last = 1}
+    }
+  },
+  {
+    {Twcsncpy, TST_LOC_end}
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcspbrk.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcspbrk.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcspbrk.c	(revision 2036)
@@ -0,0 +1,172 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_wcspbrk.c
+ *
+ *	 WCSSTR:  wchar_t *wcspbrk (const wchar_t *ws1, const wchar_t *ws2);
+ */
+
+
+/*
+ * NOTE:
+ *	 This is not a locale sensitive function.
+ *	 So those data in each locale doesn't make sense
+ *	 ... (redundant test cases)
+ */
+
+
+TST_WCSPBRK tst_wcspbrk_loc [] = {
+  {
+    { Twcspbrk, TST_LOC_de },
+    {
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     { 0x00D1,0x0000		   }, },  /* #01 */
+	/*expect*/ { 0,0,0,		    0x00D1    },
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     {	      0x00D2,0x0000	   }, },  /* #02 */
+	/*expect*/ { 0,0,0,		    0x00D2    },
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     {		     0x00D3,0x0000 }, },  /* #03 */
+	/*expect*/ { 0,0,0,		    0x00D3    },
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     { 0x00D1,0x00D2,0x0000	   }, },  /* #04 */
+	/*expect*/ { 0,0,0,		    0x00D1    },
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     {	      0x00D2,0x00D3,0x0000 }, },  /* #05 */
+	/*expect*/ { 0,0,0,		    0x00D2    },
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     { 0x00D1,0x00D2,0x00D3,0x0000 }, },  /* #06 */
+	/*expect*/ { 0,0,0,		    0x00D1    },
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     { 0x00D0,0x00D4,0x00D5,0x0000 }, },  /* #07 */
+	/*expect*/ { 0,1,(wchar_t *)NULL, 0x0000    },
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     { 0x00D5,0x00D0,0x00D4,0x0000 }, },  /* #08 */
+	/*expect*/ { 0,1,(wchar_t *)NULL, 0x0000    },
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     { 0x0000			   }, },  /* #09 */
+	/*expect*/ { 0,1,(wchar_t *)NULL, 0x0000    },
+      },
+      { /*input.*/ { { 0x0000,0x00D2,0x00D3,0x0000 },
+		     { 0x00D1,0x0000		   }, },  /* #10 */
+	/*expect*/ { 0,1,(wchar_t *)NULL, 0x0000    },
+      },
+      { /*input.*/ { { 0x0000,0x00D2,0x00D3,0x0000 },
+		     { 0x0000			   }, },  /* #11 */
+	/*expect*/ { 0,1,(wchar_t *)NULL, 0x0000    },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcspbrk, TST_LOC_enUS },
+    {
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     { 0x0041,0x0000		   }, },  /* #01 */
+	/*expect*/ { 0,0,0,		    0x0041    },
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     {	      0x0042,0x0000	   }, },  /* #02 */
+	/*expect*/ { 0,0,0,		    0x0042    },
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     {		     0x0043,0x0000 }, },  /* #03 */
+	/*expect*/ { 0,0,0,		    0x0043    },
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     { 0x0041,0x0042,0x0000	   }, },  /* #04 */
+	/*expect*/ { 0,0,0,		    0x0041    },
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     {	      0x0042,0x0043,0x0000 }, },  /* #05 */
+	/*expect*/ { 0,0,0,		    0x0042    },
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     { 0x0041,0x0042,0x0043,0x0000 }, },  /* #06 */
+	/*expect*/ { 0,0,0,		    0x0041    },
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     { 0x0040,0x0044,0x0045,0x0000 }, },  /* #07 */
+	/*expect*/ { 0,1,(wchar_t *)NULL, 0x0000    },
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     { 0x0045,0x0040,0x0044,0x0000 }, },  /* #08 */
+	/*expect*/ { 0,1,(wchar_t *)NULL, 0x0000    },
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     { 0x0000			   }, },  /* #09 */
+	/*expect*/ { 0,1,(wchar_t *)NULL, 0x0000    },
+      },
+      { /*input.*/ { { 0x0000,0x0042,0x0043,0x0000 },
+		     { 0x0041,0x0000		   }, },  /* #10 */
+	/*expect*/ { 0,1,(wchar_t *)NULL, 0x0000    },
+      },
+      { /*input.*/ { { 0x0000,0x0042,0x0043,0x0000 },
+		     { 0x0000			   }, },  /* #11 */
+	/*expect*/ { 0,1,(wchar_t *)NULL, 0x0000    },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcspbrk, TST_LOC_eucJP },
+    {
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     { 0x3041,0x0000		   }, },  /* #01 */
+	/*expect*/ { 0,0,0,		    0x3041    },
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     {	      0x3042,0x0000	   }, },  /* #02 */
+	/*expect*/ { 0,0,0,		    0x3042    },
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     {		     0x3043,0x0000 }, },  /* #03 */
+	/*expect*/ { 0,0,0,		    0x3043    },
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     { 0x3041,0x3042,0x0000	   }, },  /* #04 */
+	/*expect*/ { 0,0,0,		    0x3041    },
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     {	      0x3042,0x3043,0x0000 }, },  /* #05 */
+	/*expect*/ { 0,0,0,		    0x3042    },
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     { 0x3041,0x3042,0x3043,0x0000 }, },  /* #06 */
+	/*expect*/ { 0,0,0,		    0x3041    },
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     { 0x3042,0x3043,0x3044,0x0000 }, },  /* #07 */
+	/*expect*/ { 0,0,0, 0x3042		      },
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     { 0x3040,0x3041,0x3042,0x0000 }, },  /* #08 */
+	/*expect*/ { 0,0,0, 0x3041		      },
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     { 0x0000			   }, },  /* #09 */
+	/*expect*/ { 0,1,(wchar_t *)NULL, 0x0000    },
+      },
+      { /*input.*/ { { 0x0000,0x3042,0x3043,0x0000 },
+		     { 0x3041,0x0000		   }, },  /* #10 */
+	/*expect*/ { 0,1,(wchar_t *)NULL, 0x0000    },
+      },
+      { /*input.*/ { { 0x0000,0x3042,0x3043,0x0000 },
+		     { 0x0000			   }, },  /* #11 */
+	/*expect*/ { 0,1,(wchar_t *)NULL, 0x0000    },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcspbrk, TST_LOC_end }
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcsrtombs.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcsrtombs.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcsrtombs.c	(revision 2036)
@@ -0,0 +1,207 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_wcsrtombs.c
+ *
+ *	 WCSTOMBS:  size_t wcsrtombs (char *s, const wchar_t **ws,
+ *				      size_t n, mbstate *ps)
+ */
+
+
+/*
+ *  CAUTION:
+ *	     Do not use a value 0x01 for string data. The test program
+ *	     uses it.
+ *
+ */
+
+
+TST_WCSRTOMBS tst_wcsrtombs_loc [] = {
+  {
+    { Twcsrtombs, TST_LOC_de },
+    {
+      /* #01 : Any chars including a null char should not be stored in s.  */
+      { /*input.*/ { 1,1,	{ 0x00C4,0x00D6,0x00DC,0x0000 }, 0, 0, 0},
+	/*expect*/ { 0,1,0,	 ""					},
+      },
+      /* #02 : Only one chars should be stored in s. No null termination.  */
+      { /*input.*/ { 1,1,	{ 0x00C4,0x00D6,0x00DC,0x0000 }, 1, 0, 0 },
+	/*expect*/ { 0,1,1,	 "Ä"					 },
+      },
+      /* #03 : Only two chars should be stored in s. No null termination.  */
+      { /*input.*/ { 1,1,	{ 0x00C4,0x00D6,0x00DC,0x0000 }, 2, 0, 0 },
+	/*expect*/ { 0,1,2,	 "ÄÖ"					 },
+      },
+      /* #04 : Only three chars should be stored in s. No null
+	       termination.  */
+      { /*input.*/ { 1,1,	{ 0x00C4,0x00D6,0x00DC,0x0000 }, 3, 0, 0 },
+	/*expect*/ { 0,1,3,	 "ÄÖÜ"					 },
+      },
+      /* #05 : Only three chars should be stored in s with a null
+	       termination. */
+      { /*input.*/ { 1,1,	{ 0x00C4,0x00D6,0x00DC,0x0000 }, 4, 0, 0 },
+	/*expect*/ { 0,1,3,	 "ÄÖÜ"					 },
+      },
+      /* #06 : Only three chars should be stored in s with a null
+	       termination. */
+      { /*input.*/ { 1,1,	{ 0x00C4,0x00D6,0x00DC,0x0000 }, 5, 0, 0 },
+	/*expect*/ { 0,1,3,	 "ÄÖÜ"					 },
+      },
+      /* #07 : Invalid mb sequence. No chars should be stored in s.  */
+      { /*input.*/ { 1,1,	{ 0x0201,0x0221,0x0000,0x0000 }, 2, 0, 0 },
+	/*expect*/ { EILSEQ,1,(size_t)-1,	 ""			 },
+      },
+      /* #08 : s is a null pointer, no chars should be stored in s.  */
+      { /*input.*/ { 0,1,	{ 0x00C4,0x00D6,0x00DC,0x0000 }, 0, 0, 0 },
+	/*expect*/ { 0,1,3,	 ""					 },
+      },
+      /* #09 : s is a null pointer, no chars should be stored in s.  */
+      { /*input.*/ { 0,1,	{ 0x00C4,0x00D6,0x00DC,0x0000 }, 1, 0, 0 },
+	/*expect*/ { 0,1,3,	 ""					 },
+      },
+      /* #10 : s is a null pointer, no chars should be stored in s.  */
+      { /*input.*/ { 0,1,	{ 0x00C4,0x00D6,0x00DC,0x0000 }, 5, 0, 0 },
+	/*expect*/ { 0,1,3,	 ""					 },
+      },
+      /* #11 : s is a null pointer. No chars should be stored in s.  */
+      { /*input.*/ { 0,1,	{ 0x0201,0x0221,0x0000,0x0000 }, 5, 0, 0 },
+	/*expect*/ { EILSEQ,1,(size_t)-1,	 ""			 },
+      },
+      /* #12 : ws is a null wc string, no chars should be stored in s.  */
+      { /*input.*/ { 1,1,	{ 0x0000 },			 5, 0, 0 },
+	/*expect*/ { 0,1,0,	 ""					 },
+      },
+      /* #13 : s is a null pointer, no chars should be stored in s.  */
+      { /*input.*/ { 0,1,	{ 0x0000 },			 5, 0, 0 },
+	/*expect*/ { 0,1,0,	 ""					 },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcsrtombs, TST_LOC_enUS },
+    {
+      /* #01 : Any chars including a null char should not be stored in s.  */
+      { /*input.*/ { 1,1,	{ 0x0041,0x0042,0x0043,0x0000 }, 0, 0, 0 },
+	/*expect*/ { 0,1,0,	 ""					 },
+      },
+      /* #02 : Only one chars should be stored in s. No null termination.  */
+      { /*input.*/ { 1,1,	{ 0x0041,0x0042,0x0043,0x0000 }, 1, 0, 0 },
+	/*expect*/ { 0,1,1,	 "A"					 },
+      },
+      /* #03 : Only two chars should be stored in s. No null termination. */
+      { /*input.*/ { 1,1,	{ 0x0041,0x0042,0x0043,0x0000 }, 2, 0, 0 },
+	/*expect*/ { 0,1,2,	 "AB"					 },
+      },
+      /* #04 : Only three chars should be stored in s. No null
+	       termination.  */
+      { /*input.*/ { 1,1,	{ 0x0041,0x0042,0x0043,0x0000 }, 3, 0, 0 },
+	/*expect*/ { 0,1,3,	 "ABC"					 },
+      },
+      /* #05 : Only three chars should be stored in s with a null
+	       termination. */
+      { /*input.*/ { 1,1,	{ 0x0041,0x0042,0x0043,0x0000 }, 4, 0, 0 },
+	/*expect*/ { 0,1,3,	 "ABC"					 },
+      },
+      /* #06 : Only three chars should be stored in s with a null
+	       termination. */
+      { /*input.*/ { 1,1,	{ 0x0041,0x0042,0x0043,0x0000 }, 5, 0, 0 },
+	/*expect*/ { 0,1,3,	 "ABC"					 },
+      },
+      /* #07 : Invalid mb sequence. No chars should be stored in s.  */
+      { /*input.*/ { 1,1,	{ 0x0201,0x0221,0x0000,0x0000 }, 2, 0, 0 },
+	/*expect*/ { EILSEQ,1,(size_t)-1,	 ""					},
+      },
+      /* #08 : s is a null pointer, no chars should be stored in s.  */
+      { /*input.*/ { 0,1,	{ 0x0041,0x0042,0x0043,0x0000 }, 0, 0, 0 },
+	/*expect*/ { 0,1,3,	 ""					 },
+      },
+      /* #09 : s is a null pointer, no chars should be stored in s.  */
+      { /*input.*/ { 0,1,	{ 0x0041,0x0042,0x0043,0x0000 }, 1, 0, 0 },
+	/*expect*/ { 0,1,3,	 ""					 },
+      },
+      /* #10 : s is a null pointer, no chars should be stored in s.  */
+      { /*input.*/ { 0,1,	{ 0x0041,0x0042,0x0043,0x0000 }, 5, 0, 0 },
+	/*expect*/ { 0,1,3,	 ""					 },
+      },
+      /* #11 : s is a null pointer. No chars should be stored in s.  */
+      { /*input.*/ { 0,1,	{ 0x0201,0x0221,0x0000,0x0000 }, 5, 0, 0 },
+	/*expect*/ { EILSEQ,1,(size_t)-1,	 ""			 },
+      },
+      /* #12 : ws is a null wc string, no chars should be stored in s.  */
+      { /*input.*/ { 1,1,	{ 0x0000 },			 5, 0, 0 },
+	/*expect*/ { 0,1,0,	 ""					 },
+      },
+      /* #13 : s is a null pointer, no chars should be stored in s.  */
+      { /*input.*/ { 0,1,	{ 0x0000 },			 5, 0, 0 },
+	/*expect*/ { 0,1,0,	 ""					 },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcsrtombs, TST_LOC_eucJP },
+    {
+
+      /* #01 : Any chars including a null char should not be stored in s.  */
+      { /*input.*/ { 1,1,	{ 0x3042,0x3044,0xFF73,0x0000 }, 0, 0, 0 },
+	/*expect*/ { 0,1,0,	 ""					 },
+      },
+      /* #02 : Only one chars should be stored in s. No null termination.  */
+      { /*input.*/ { 1,1,	{ 0x3042,0x3044,0xFF73,0x0000 }, 2, 0, 0 },
+	/*expect*/ { 0,1,2,	    "\244\242"				 },
+      },
+      /* #03 : Only two chars should be stored in s. No null termination.  */
+      { /*input.*/ { 1,1,	{ 0x3042,0x3044,0xFF73,0x0000 }, 4, 0, 0 },
+	/*expect*/ { 0,1,4,	    "\244\242\244\244"			 },
+      },
+      /* #04 : Only three chars should be stored in s. No null
+	       termination.  */
+      { /*input.*/ { 1,1,	{ 0x3042,0x3044,0xFF73,0x0000 }, 6, 0, 0 },
+	/*expect*/ { 0,1,6,	    "\244\242\244\244\216\263"		 },
+      },
+      /* #05 : Only three chars should be stored in s with a null
+	       termination. */
+      { /*input.*/ { 1,1,	{ 0x3042,0x3044,0xFF73,0x0000 }, 7, 0, 0 },
+	/*expect*/ { 0,1,6,	    "\244\242\244\244\216\263"		 },
+      },
+      /* #06 : Only three chars should be stored in s with a null
+	       termination. */
+      { /*input.*/ { 1,1,	{ 0x3042,0x3044,0xFF73,0x0000 }, 8, 0, 0 },
+	/*expect*/ { 0,1,6,	    "\244\242\244\244\216\263"		 },
+      },
+      /* #07 : Invalid mb sequence. No chars should be stored in s.  */
+      { /*input.*/ { 1,1,	{ 0x0201,0x0221,0x0000,0x0000 }, 2, 0, 0 },
+	/*expect*/ { EILSEQ,1,-1, ""					 },
+      },
+      /* #08 : s is a null pointer, no chars should be stored in s.  */
+      { /*input.*/ { 0,1,	{ 0x3042,0x3044,0xFF73,0x0000 }, 0, 0, 0 },
+	/*expect*/ { 0,1,6,	 ""					 },
+      },
+      /* #09 : s is a null pointer, no chars should be stored in s.  */
+      { /*input.*/ { 0,1,	{ 0x3042,0x3044,0xFF73,0x0000 }, 1, 0, 0 },
+	/*expect*/ { 0,1,6,	 ""					 },
+      },
+      /* #10 : s is a null pointer, no chars should be stored in s.  */
+      { /*input.*/ { 0,1,	{ 0x3042,0x3044,0xFF73,0x0000 }, 8, 0, 0 },
+	/*expect*/ { 0,1,6,	 ""					 },
+      },
+      /* #11 : s is a null pointer. No chars should be stored in s.  */
+      { /*input.*/ { 0,1,	{ 0x0201,0x0221,0x0000,0x0000 }, 5, 0, 0 },
+	/*expect*/ { EILSEQ,1,(size_t)-1,	 ""			 },
+      },
+      /* #12 : ws is a null wc string, no chars should be stored in s.  */
+      { /*input.*/ { 1,1,	{ 0x0000 },			 5, 0, 0 },
+	/*expect*/ { 0,1,0,	 ""					 },
+      },
+      /* #13 : s is a null pointer, no chars should be stored in s.  */
+      { /*input.*/ { 0,1,	{ 0x0000 },			 5, 0, 0 },
+	/*expect*/ { 0,1,0,	 ""					 },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcsrtombs, TST_LOC_end }
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcsspn.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcsspn.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcsspn.c	(revision 2036)
@@ -0,0 +1,175 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_wcsspn.c
+ *
+ *	 WCSSPN:  size_t wcsspn (const wchar_t *ws1, const wchar_t *ws2);
+ */
+
+TST_WCSSPN tst_wcsspn_loc [] = {
+    {
+      { Twcsspn, TST_LOC_de },
+      {
+	{ /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		       { 0x00D1,0x0000		     }, },  /* #01 */
+	  /*expect*/ { 0,1,1,				},
+	},
+	{ /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		       {	0x00D2,0x0000	     }, },  /* #02 */
+	  /*expect*/ { 0,1,0,				},
+	},
+	{ /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		       {	       0x00D3,0x0000 }, },  /* #03 */
+	  /*expect*/ { 0,1,0,				},
+	},
+	{ /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		       {	       0x00D4,0x0000 }, },  /* #04 */
+	  /*expect*/ { 0,1,0,				},
+	},
+	{ /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		       {	0x00D2,0x00D3,0x0000 }, },  /* #05 */
+	  /*expect*/ { 0,1,0,				},
+	},
+	{ /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		       {	0x00D3,0x00D4,0x0000 }, },  /* #06 */
+	  /*expect*/ { 0,1,0,				},
+	},
+	{ /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		       { 0x00D1,0x00D2,0x00D3,0x0000 }, },  /* #07 */
+	  /*expect*/ { 0,1,3,				},
+	},
+	{ /*input.*/ { { 0x00D1,0x00D2,0x0000	     },
+		       { 0x00D1,0x00D2,0x00D3,0x0000 }, },  /* #08 */
+	  /*expect*/ { 0,1,2,				},
+	},
+	{ /*input.*/ { { 0x0000,0x00D2,0x00D3,0x0000 },
+		       { 0x00D2,0x0000		     }, },  /* #09 */
+	  /*expect*/ { 0,1,0,				},
+	},
+	{ /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		       { 0x0000,0x00D2,0x0000	     }, },  /* #10 */
+	  /*expect*/ { 0,1,0,				},
+	},
+	{ /*input.*/ { { 0x0000,0x00D2,0x00D3,0x0000 },
+		       { 0x0000,0x00D2,0x0000	     }, },  /* #11 */
+	  /*expect*/ { 0,1,0,				},
+	},
+	{ /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		       { 0x00D2,0x00D1,0x0000	     }, },  /* #12 */
+	  /*expect*/ { 0,1,2,				},
+	},
+	{ .is_last = 1 }
+      }
+    },
+    {
+      { Twcsspn, TST_LOC_enUS },
+      {
+	{ /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		       { 0x0041,0x0000		     }, },  /* #01 */
+	  /*expect*/ { 0,1,1,				},
+	},
+	{ /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		       {	0x0042,0x0000	     }, },  /* #02 */
+	  /*expect*/ { 0,1,0,				},
+	},
+	{ /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		       {	       0x0043,0x0000 }, },  /* #03 */
+	  /*expect*/ { 0,1,0,				},
+	},
+	{ /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		       {	       0x0044,0x0000 }, },  /* #04 */
+	  /*expect*/ { 0,1,0,				},
+	},
+	{ /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		       {	0x0042,0x0043,0x0000 }, },  /* #05 */
+	  /*expect*/ { 0,1,0,				},
+	},
+	{ /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		       {	0x0043,0x0044,0x0000 }, },  /* #06 */
+	  /*expect*/ { 0,1,0,				},
+	},
+	{ /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		       { 0x0041,0x0042,0x0043,0x0000 }, },  /* #07 */
+	  /*expect*/ { 0,1,3,				},
+	},
+	{ /*input.*/ { { 0x0041,0x0042,0x0000	     },
+		       { 0x0041,0x0042,0x0043,0x0000 }, },  /* #08 */
+	  /*expect*/ { 0,1,2,				},
+	},
+	{ /*input.*/ { { 0x0000,0x0042,0x0043,0x0000 },
+		       { 0x0042,0x0000		     }, },  /* #09 */
+	  /*expect*/ { 0,1,0,				},
+	},
+	{ /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		       { 0x0000,0x0042,0x0000	     }, },  /* #10 */
+	  /*expect*/ { 0,1,0,				},
+	},
+	{ /*input.*/ { { 0x0000,0x0042,0x0043,0x0000 },
+		       { 0x0000,0x0042,0x0000	     }, },  /* #11 */
+	  /*expect*/ { 0,1,0,				},
+	},
+	{ /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		       { 0x0042,0x0041,0x0000	     }, },  /* #12 */
+	  /*expect*/ { 0,1,2,				},
+	},
+	{ .is_last = 1 }
+      }
+    },
+    {
+      { Twcsspn, TST_LOC_eucJP },
+      {
+	{ /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		       { 0x3041,0x0000		     }, },  /* #1 */
+	  /*expect*/ { 0,1,1,				},
+	},
+	{ /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		       {	0x3042,0x0000	     }, },  /* #2 */
+	  /*expect*/ { 0,1,0,				},
+	},
+	{ /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		       {	       0x3043,0x0000 }, },  /* #3 */
+	  /*expect*/ { 0,1,0,				},
+	},
+	{ /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		       {	       0x3044,0x0000 }, },  /* #4 */
+	  /*expect*/ { 0,1,0,				},
+	},
+	{ /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		       {	0x3042,0x3043,0x0000 }, },  /* #5 */
+	  /*expect*/ { 0,1,0,				},
+	},
+	{ /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		       {	0x3043,0x3044,0x0000 }, },  /* #6 */
+	  /*expect*/ { 0,1,0,				},
+	},
+	{ /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		       { 0x3041,0x3042,0x3043,0x0000 }, },  /* #7 */
+	  /*expect*/ { 0,1,3,				},
+	},
+	{ /*input.*/ { { 0x3041,0x3042,0x0000	     },
+		       { 0x3041,0x3042,0x3043,0x0000 }, },  /* #8 */
+	  /*expect*/ { 0,1,2,				},
+	},
+	{ /*input.*/ { { 0x0000,0x3042,0x3043,0x0000 },
+		       { 0x3042,0x0000		     }, },  /* #9 */
+	  /*expect*/ { 0,1,0,				},
+	},
+	{ /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		       { 0x0000,0x3042,0x0000	     }, },  /* #10 */
+	  /*expect*/ { 0,1,0,				},
+	},
+	{ /*input.*/ { { 0x0000,0x3042,0x3043,0x0000 },
+		       { 0x0000,0x3042,0x0000	     }, },  /* #11 */
+	  /*expect*/ { 0,1,0,				},
+	},
+	{ /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		       { 0x3042,0x3041,0x0000	     }, },  /* #12 */
+	  /*expect*/ { 0,1,2,				},
+	},
+	{ .is_last = 1 }
+      }
+    },
+    {
+      { Twcsspn, TST_LOC_end }
+    }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcsstr.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcsstr.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcsstr.c	(revision 2036)
@@ -0,0 +1,171 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_wcsstr.c
+ *
+ *	 WCSSTR:  wchar_t *wcsstr (const wchar_t *ws1, const wchar_t *ws2);
+ */
+
+/*
+ * NOTE:
+ *	 This is not a locale sensitive function.
+ *	 So those data in each locale doesn't make sense ...
+ *	 (redundant test cases)
+ */
+
+
+TST_WCSSTR tst_wcsstr_loc [] = {
+  {
+    { Twcsstr, TST_LOC_de },
+    {
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     { 0x00D1,0x0000		   }, },  /* #01 */
+	/*expect*/ { 0,0,0,			      },
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     {	      0x00D2,0x0000	   }, },  /* #02 */
+	/*expect*/ { 0,0,0,			      },
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     {		     0x00D3,0x0000 }, },  /* #03 */
+	/*expect*/ { 0,0,0,			      },
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     { 0x00D1,0x00D2,0x0000	   }, },  /* #04 */
+	/*expect*/ { 0,0,0,			      },
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     {	      0x00D2,0x00D3,0x0000 }, },  /* #05 */
+	/*expect*/ { 0,0,0,			      },
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     { 0x00D1,0x00D2,0x00D3,0x0000 }, },  /* #06 */
+	/*expect*/ { 0,0,0,			      },
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     { 0x00D2,0x00D3,0x00D4,0x0000 }, },  /* #07 */
+	/*expect*/ { 0,1,(wchar_t *)NULL,	      },
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     { 0x00D0,0x00D1,0x00D2,0x0000 }, },  /* #08 */
+	/*expect*/ { 0,1,(wchar_t *)NULL,	      },
+      },
+      { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 },
+		     { 0x0000			   }, },  /* #09 */
+	/*expect*/ { 0,0,0,			      },
+      },
+      { /*input.*/ { { 0x0000,0x00D2,0x00D3,0x0000 },
+		     { 0x00D1,0x0000		   }, },  /* #10 */
+	/*expect*/ { 0,1,(wchar_t *)NULL,	      },
+      },
+      { /*input.*/ { { 0x0000,0x00D2,0x00D3,0x0000 },
+		     { 0x0000			   }, },  /* #11 */
+	/*expect*/ { 0,0,0,			      },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcsstr, TST_LOC_enUS },
+    {
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     { 0x0041,0x0000		   }, },  /* #01 */
+	/*expect*/ { 0,0,0,			      },
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     {	      0x0042,0x0000	   }, },  /* #02 */
+	/*expect*/ { 0,0,0,			      },
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     {		     0x0043,0x0000 }, },  /* #03 */
+	/*expect*/ { 0,0,0,			      },
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     { 0x0041,0x0042,0x0000	   }, },  /* #04 */
+	/*expect*/ { 0,0,0,			      },
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     {	      0x0042,0x0043,0x0000 }, },  /* #05 */
+	/*expect*/ { 0,0,0,			      },
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     { 0x0041,0x0042,0x0043,0x0000 }, },  /* #06 */
+	/*expect*/ { 0,0,0,			      },
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     { 0x0042,0x0043,0x0044,0x0000 }, },  /* #07 */
+	/*expect*/ { 0,1,(wchar_t *)NULL,	      },
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     { 0x0040,0x0041,0x0042,0x0000 }, },  /* #08 */
+	/*expect*/ { 0,1,(wchar_t *)NULL,	      },
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
+		     { 0x0000			   }, },  /* #09 */
+	/*expect*/ { 0,0,0,			      },
+      },
+      { /*input.*/ { { 0x0000,0x0042,0x0043,0x0000 },
+		     { 0x0041,0x0000		   }, },  /* #10 */
+	/*expect*/ { 0,1,(wchar_t *)NULL,	      },
+      },
+      { /*input.*/ { { 0x0000,0x0042,0x0043,0x0000 },
+		     { 0x0000			   }, },  /* #11 */
+	/*expect*/ { 0,0,0,			      },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcsstr, TST_LOC_eucJP },
+    {
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     { 0x3041,0x0000		   }, },  /* #01 */
+	/*expect*/ { 0,0,0,			      },
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     {	      0x3042,0x0000	   }, },  /* #02 */
+	/*expect*/ { 0,0,0,			      },
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     {		     0x3043,0x0000 }, },  /* #03 */
+	/*expect*/ { 0,0,0,			      },
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     { 0x3041,0x3042,0x0000	   }, },  /* #04 */
+	/*expect*/ { 0,0,0,			      },
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     {	      0x3042,0x3043,0x0000 }, },  /* #05 */
+	/*expect*/ { 0,0,0,			      },
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     { 0x3041,0x3042,0x3043,0x0000 }, },  /* #06 */
+	/*expect*/ { 0,0,0,			      },
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     { 0x3042,0x3043,0x3044,0x0000 }, },  /* #07 */
+	/*expect*/ { 0,1,(wchar_t *)NULL,	      },
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     { 0x3040,0x3041,0x3042,0x0000 }, },  /* #08 */
+	/*expect*/ { 0,1,(wchar_t *)NULL,	      },
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
+		     { 0x0000			   }, },  /* #09 */
+	/*expect*/ { 0,0,0,			      },
+      },
+      { /*input.*/ { { 0x0000,0x3042,0x3043,0x0000 },
+		     { 0x3041,0x0000		   }, },  /* #10 */
+	/*expect*/ { 0,1,(wchar_t *)NULL,	      },
+      },
+      { /*input.*/ { { 0x0000,0x3042,0x3043,0x0000 },
+		     { 0x0000			   }, },  /* #11 */
+	/*expect*/ { 0,0,0,			      },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcsstr, TST_LOC_end }
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcstod.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcstod.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcstod.c	(revision 2036)
@@ -0,0 +1,74 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN CLIBRARY
+ *
+ *	 FILE:	dat_wcstod.c
+ *
+ *	 WCSTOD:  double wcstod (const wchar_t *np, wchar_t **endp);
+ */
+
+
+/*
+ *  NOTE:
+ *	  need more test data!
+ *
+ */
+
+
+TST_WCSTOD tst_wcstod_loc [] = {
+  {
+    { Twcstod, TST_LOC_de },
+    {
+      {
+	/*01*/
+	/*I*/
+	{{ 0x0030,0x0030,0x0030,0x002C,0x0030,0x0030,0x0030,0x0030,0x0000 }},
+	/*E*/
+	{ 0,1,0.0,	       0.0,				  0x0000   }
+      },
+      {
+	/*02*/
+	/*I*/
+	{{ 0x0031,0x0032,0x0033,0x002C,0x0034,0x0035,0x0036,0x0040,0x0000 }},
+	/*E*/
+	{ 0,1,123.456,	       123.456,			   0x0040  }
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcstod, TST_LOC_enUS },
+    {
+      {
+	/*01*/
+	/*I*/
+	{{ 0x0030,0x0030,0x0030,0x002E,0x0030,0x0030,0x0030,0x0030,0x0000 }},
+	/*E*/
+	{ 0,1,0.0,	       0.0,				  0x0000   }
+      },
+      {
+	/*02*/
+	/*I*/
+	{{ 0x0031,0x0032,0x0033,0x002E,0x0034,0x0035,0x0036,0x0040,0x0000 }},
+	/*E*/
+	{ 0,1,123.456,	       123.456,			   0x0040  }
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcstod, TST_LOC_eucJP },
+    {
+      {
+	/*01*/
+	/*I*/
+	{{ 0x0031,0x0032,0x0033,0x002E,0x0034,0x0035,0x0036,0x0040,0x0000 }},
+	/*E*/
+	{ 0,1,123.456,	       123.456,			   0x0040  }
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcstod, TST_LOC_end }
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcstok.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcstok.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcstok.c	(revision 2036)
@@ -0,0 +1,134 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN CLIBRARY
+ *
+ *	 FILE:	dat_wcstok.c
+ *
+ *	 WCSTOK: wchar_t *wcstok (wchar_t *ws, const wchar_t *dlm,
+ *				  wchar_t **pt);
+ */
+
+/*
+ *  NOTE:
+ *	  need more test data!
+ *	  locale insensitive function...
+ */
+
+
+
+
+TST_WCSTOK tst_wcstok_loc [] = {
+  {
+    { Twcstok, TST_LOC_de },
+    {
+      {
+	{
+	  {
+	    { 1, { 0x00D1,0x00D2,0x00D3,0x00D4,0x00D5,0x00D6,0x00D7,0x00D8,
+		   0x00D9,0x0000 },
+	      {	       0x00D3,0x00D2,	    0x00D5 }
+	    },
+	    { 0, { 0x00D1,0x00D2,0x00D3,0x00D4,0x00D5,0x00D6,0x00D7,0x00D8,
+		   0x00D9,0x0000 },
+	      {	       0x00D3,0x00D2,	    0x00D5 }
+	    },
+	    { 0, { 0x00D1,0x00D2,0x00D3,0x00D4,0x00D5,0x00D6,0x00D7,0x00D8,
+		   0x00D9,0x0000 },
+	      {	       0x00D3,0x00D2,	    0x00D5 }
+	    },
+	  }
+	},
+	{
+	  {
+	    { 0, 0,0,
+	      { 0x00D1,0x0000 }
+	    },
+	    { 0, 0,0,
+	      {			     0x00D4,0x0000 }
+	    },
+	    { 0, 0,0,
+	      { 0x00D6,0x00D7,0x00D8,0x00D9,0x0000 }
+	    },
+	  }
+	}
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcstok, TST_LOC_enUS },
+    {
+      {
+	{
+	  {
+	    { 1, { 0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047,0x0048,
+		   0x0049,0x0000 },
+	      {	       0x0043,0x0042,	    0x0045 }
+	    },
+	    { 0, { 0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047,0x0048,
+		   0x0049,0x0000 },
+	      {	       0x0043,0x0042,	    0x0045 }
+	    },
+	    { 0, { 0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047,0x0048,
+		   0x0049,0x0000 },
+	      {	       0x0043,0x0042,	    0x0045 }
+	    },
+	  }
+	},
+	{
+	  {
+	    { 0, 0,0,
+	      { 0x0041,0x0000 }
+	    },
+	    { 0, 0,0,
+	      {			     0x0044,0x0000 }
+	    },
+	    { 0, 0,0,
+	      { 0x0046,0x0047,0x0048,0x0049,0x0000 }
+	    },
+	  }
+	}
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcstok, TST_LOC_eucJP },
+    {
+      {
+	{
+	  {
+	    { 1, { 0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047,0x0048,
+		   0x0049,0x0000 },
+	      {	       0x0043,0x0042,	    0x0045 }
+	    },
+	    { 0, { 0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047,0x0048,
+		   0x0049,0x0000 },
+	      {	       0x0043,0x0042,	    0x0045 }
+	    },
+	    { 0, { 0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047,0x0048,
+		   0x0049,0x0000 },
+	      {	       0x0043,0x0042,	    0x0045 }
+	    },
+	  }
+	},
+	{
+	  {
+	    { 0, 0,0,
+	      { 0x0041,0x0000 }
+	    },
+	    { 0, 0,0,
+	      {			     0x0044,0x0000 }
+	    },
+	    { 0, 0,0,
+	      { 0x0046,0x0047,0x0048,0x0049,0x0000 }
+	    },
+	  }
+	}
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcstok, TST_LOC_end }
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcstombs.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcstombs.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcstombs.c	(revision 2036)
@@ -0,0 +1,206 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_wcstombs.c
+ *
+ *	 WCSTOMBS:  size_t wcstombs (char *s, const wchar_t *ws, size_t n)
+ */
+
+
+/*
+ *  CAUTION:
+ *	     Do not use a value 0x01 for string data. The test program
+ *	     uses it.
+ *
+ */
+
+
+TST_WCSTOMBS tst_wcstombs_loc [] = {
+  {
+    { Twcstombs, TST_LOC_de },
+    {
+      /* #01 : Any chars including a null char should not be stored in s.  */
+      { /*input.*/ { 1,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 }, 0 },
+	/*expect*/ { 0,1,0,	 ""					  },
+      },
+      /* #02 : Only one chars should be stored in s. No null termination.  */
+      { /*input.*/ { 1,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 },	1 },
+	/*expect*/ { 0,1,1,	 "Ä"					  },
+      },
+      /* #03 : Only two chars should be stored in s. No null termination.  */
+      { /*input.*/ { 1,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 },	2 },
+	/*expect*/ { 0,1,2,	 "ÄÖ"					  },
+      },
+      /* #04 : Only three chars should be stored in s. No null
+	       termination.  */
+      { /*input.*/ { 1,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 },	3 },
+	/*expect*/ { 0,1,3,	 "ÄÖÜ"					  },
+      },
+      /* #05 : Only three chars should be stored in s with a null
+	       termination.  */
+      { /*input.*/ { 1,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 },	4 },
+	/*expect*/ { 0,1,3,	 "ÄÖÜ"					  },
+      },
+      /* #06 : Only three chars should be stored in s with a null
+	       termination.  */
+      { /*input.*/ { 1,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 },	5 },
+	/*expect*/ { 0,1,3,	 "ÄÖÜ"					  },
+      },
+      /* #07 : Invalid mb sequence. No chars should be stored in s. */
+      { /*input.*/ { 1,1,	       { 0x0201,0x0221,0x0000,0x0000 },	2 },
+	/*expect*/ { EILSEQ,1,(size_t)-1,	 ""			  },
+      },
+      /* #08 : s is a null pointer, no chars should be stored in s.  */
+      { /*input.*/ { 0,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 }, 0 },
+	/*expect*/ { 0,1,3,	 ""					  },
+      },
+      /* #09 : s is a null pointer, no chars should be stored in s.  */
+      { /*input.*/ { 0,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 }, 1 },
+	/*expect*/ { 0,1,3,	 ""					  },
+      },
+      /* #10 : s is a null pointer, no chars should be stored in s.  */
+      { /*input.*/ { 0,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 }, 5 },
+	/*expect*/ { 0,1,3,	 ""					  },
+      },
+      /* #11 : s is a null pointer. No chars should be stored in s.  */
+      { /*input.*/ { 0,1,	       { 0x0201,0x0221,0x0000,0x0000 }, 5 },
+	/*expect*/ { EILSEQ,1,(size_t)-1,	 ""			  },
+      },
+      /* #12 : ws is a null wc string, no chars should be stored in s.  */
+      { /*input.*/ { 1,1,	       { 0x0000 },			5 },
+	/*expect*/ { 0,1,0,	 ""					  },
+      },
+      /* #13 : s is a null pointer, no chars should be stored in s.  */
+      { /*input.*/ { 0,1,	       { 0x0000 },			5 },
+	/*expect*/ { 0,1,0,	 ""					  },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcstombs, TST_LOC_enUS },
+    {
+      /* #01 : Any chars including a null char should not be stored in s.  */
+      { /*input.*/ { 1,1,	       { 0x00C4,0x0042,0x0043,0x0000 },	0  },
+	/*expect*/ { 0,1,0,	 ""					   },
+      },
+      /* #02 : Only one chars should be stored in s. No null termination.  */
+      { /*input.*/ { 1,1,	       { 0x0041,0x0042,0x0043,0x0000 }, 1  },
+	/*expect*/ { 0,1,1,	 "A"					   },
+      },
+      /* #03 : Only two chars should be stored in s. No null termination.  */
+      { /*input.*/ { 1,1,	       { 0x0041,0x0042,0x0043,0x0000 }, 2  },
+	/*expect*/ { 0,1,2,	 "AB"					   },
+      },
+      /* #04 : Only three chars should be stored in s. No null
+	       termination.  */
+      { /*input.*/ { 1,1,	       { 0x0041,0x0042,0x0043,0x0000 }, 3  },
+	/*expect*/ { 0,1,3,	 "ABC"					   },
+      },
+      /* #05 : Only three chars should be stored in s with a null
+	       termination.  */
+      { /*input.*/ { 1,1,	       { 0x0041,0x0042,0x0043,0x0000 }, 4  },
+	/*expect*/ { 0,1,3,	 "ABC"					   },
+      },
+      /* #06 : Only three chars should be stored in s with a null
+	       termination.  */
+      { /*input.*/ { 1,1,	       { 0x0041,0x0042,0x0043,0x0000 }, 5  },
+	/*expect*/ { 0,1,3,	 "ABC"					   },
+      },
+      /* #07 : Invalid mb sequence. No chars should be stored in s.  */
+      { /*input.*/ { 1,1,	       { 0x0201,0x0221,0x0000,0x0000 }, 2  },
+	/*expect*/ { EILSEQ,1,(size_t)-1,	 ""			   },
+      },
+      /* #08 : s is a null pointer, no chars should be stored in s.  */
+      { /*input.*/ { 0,1,	       { 0x0041,0x0042,0x0043,0x0000 }, 0  },
+	/*expect*/ { 0,1,3,	 ""					   },
+      },
+      /* #09 : s is a null pointer, no chars should be stored in s.  */
+      { /*input.*/ { 0,1,	       { 0x0041,0x0042,0x0043,0x0000 }, 1  },
+	/*expect*/ { 0,1,3,	 ""					   },
+      },
+      /* #10 : s is a null pointer, no chars should be stored in s.  */
+      { /*input.*/ { 0,1,	       { 0x0041,0x0042,0x0043,0x0000 }, 5  },
+	/*expect*/ { 0,1,3,	 ""					   },
+      },
+      /* #11 : s is a null pointer. No chars should be stored in s.  */
+      { /*input.*/ { 0,1,	       { 0x0201,0x0221,0x0000,0x0000 }, 5  },
+	/*expect*/ { EILSEQ,1,(size_t)-1,	 ""			   },
+      },
+      /* #12 : ws is a null wc string, no chars should be stored in s.  */
+      { /*input.*/ { 1,1,	       { 0x0000 },			5, },
+	/*expect*/ { 0,1,0,	 ""			                   },
+      },
+      /* #13 : s is a null pointer, no chars should be stored in s.  */
+      { /*input.*/ { 0,1,	       { 0x0000 },			5  },
+	/*expect*/ { 0,1,0,	 ""					   },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcstombs, TST_LOC_eucJP },
+    {
+
+      /* #01 : Any chars including a null char should not be stored in s.  */
+      { /*input.*/ { 1,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 0  },
+	/*expect*/ { 0,1,0,	 ""					   },
+      },
+      /* #02 : Only one chars should be stored in s. No null termination.  */
+      { /*input.*/ { 1,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 2  },
+	/*expect*/ { 0,1,2,	     "\244\242"				   },
+      },
+      /* #03 : Only two chars should be stored in s. No null termination.  */
+      { /*input.*/ { 1,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 4  },
+	/*expect*/ { 0,1,4,	     "\244\242\244\244"			   },
+      },
+      /* #04 : Only three chars should be stored in s. No null
+	       termination.  */
+      { /*input.*/ { 1,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 6  },
+	/*expect*/ { 0,1,6,	     "\244\242\244\244\216\263"		   },
+      },
+      /* #05 : Only three chars should be stored in s with a null
+	       termination.  */
+      { /*input.*/ { 1,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 7  },
+	/*expect*/ { 0,1,6,	     "\244\242\244\244\216\263"		   },
+      },
+      /* #06 : Only three chars should be stored in s with a null
+	       termination.  */
+      { /*input.*/ { 1,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 8  },
+	/*expect*/ { 0,1,6,	     "\244\242\244\244\216\263"		   },
+      },
+      /* #07 : Invalid mb sequence. No chars should be stored in s.  */
+      { /*input.*/ { 1,1,	       { 0x0201,0x0221,0x0000,0x0000 }, 2  },
+	/*expect*/ { EILSEQ,1,-1,	 ""				   },
+      },
+      /* #08 : s is a null pointer, no chars should be stored in s.  */
+      { /*input.*/ { 0,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 0  },
+	/*expect*/ { 0,1,6,	 ""					   },
+      },
+      /* #09 : s is a null pointer, no chars should be stored in s.  */
+      { /*input.*/ { 0,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 1  },
+	/*expect*/ { 0,1,6,	 ""					   },
+      },
+      /* #10 : s is a null pointer, no chars should be stored in s.  */
+      { /*input.*/ { 0,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 8  },
+	/*expect*/ { 0,1,6,	 ""					   },
+      },
+      /* #11 : s is a null pointer. No chars should be stored in s.  */
+      { /*input.*/ { 0,1,	       { 0x0201,0x0221,0x0000,0x0000 }, 5  },
+	/*expect*/ { EILSEQ,1,(size_t)-1,	 ""			   },
+      },
+      /* #12 : ws is a null wc string, no chars should be stored in s.  */
+      { /*input.*/ { 1,1,	       { 0x0000 },			5  },
+	/*expect*/ { 0,1,0,	 ""					   },
+      },
+      /* #13 : s is a null pointer, no chars should be stored in s.  */
+      { /*input.*/ { 0,1,	       { 0x0000 },			5  },
+	/*expect*/ { 0,1,0,	 ""					   },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcstombs, TST_LOC_end }
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcswidth.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcswidth.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcswidth.c	(revision 2036)
@@ -0,0 +1,241 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_wcswidth.c
+ *
+ *	 WCSWIDTH:  int	 wcswidth (const wchar_t *ws, size_t n);
+ */
+
+TST_WCSWIDTH tst_wcswidth_loc [] = {
+  {
+    { Twcswidth, TST_LOC_de },
+    {
+      { /*input.*/ { { 0x00C1,0x00C2,0x00C3,0x0000 },	 0 },  /* 01 */
+	/*expect*/ { 0,1,0				   },
+      },
+      { /*input.*/ { { 0x00C1,0x00C2,0x00C3,0x0000 },	 1 },  /* 02 */
+	/*expect*/ { 0,1,1				   },
+      },
+      { /*input.*/ { { 0x00C1,0x00C2,0x00C3,0x0000 },	 2 },  /* 03 */
+	/*expect*/ { 0,1,2				   },
+      },
+      { /*input.*/ { { 0x00C1,0x00C2,0x00C3,0x0000 },	 3 },  /* 04 */
+	/*expect*/ { 0,1,3				   },
+      },
+      { /*input.*/ { { 0x00C1,0x00C2,0x00C3,0x0000 },	 4 },  /* 05 */
+	/*expect*/ { 0,1,3				   },
+      },
+      { /*input.*/ { { 0x0000 },			 1 },  /* 06 */
+	/*expect*/ { 0,1,0				   },
+      },
+      { /*input.*/ { { 0x00C1,0x0001,0x0000 },		 2 },  /* 07 */
+	/*expect*/ { 0,1,-1				   },
+      },
+      { /*input.*/ { { 0x00C1,0x0001,0x0000 },		 1 },  /* 08 */
+	/*expect*/ { 0,1,1				   },
+      },
+      { /*input.*/ { { 0x00C1,0x0001,0x0000 },		 2 },  /* 09 */
+	/*expect*/ { 0,1,-1				   },
+      },
+      { /*input.*/ { { 0x00C1,0x0092,0x0000 },		 2 },  /* 10 */
+	/*expect*/ { 0,1,-1				   },
+      },
+      { /*input.*/ { { 0x00C1,0x0020,0x0000 },		 2 },  /* 11 */
+	/*expect*/ { 0,1,2				   },
+      },
+      { /*input.*/ { { 0x00C1,0x0021,0x0000 },		 2 },  /* 12 */
+	/*expect*/ { 0,1,2				   },
+      },
+      { /*input.*/ { { 0x00C1,0x007E,0x0000 },		 2 },  /* 13 */
+	/*expect*/ { 0,1,2				   },
+      },
+      { /*input.*/ { { 0x00C1,0x007F,0x0000 },		 2 },  /* 14 */
+	/*expect*/ { 0,1,-1				   },
+      },
+      { /*input.*/ { { 0x00C1,0x0080,0x0000 },		 2 },  /* 15 */
+	/*expect*/ { 0,1,-1				   },
+      },
+      { /*input.*/ { { 0x00C1,0x00A0,0x0000 },		 2 },  /* 16 */
+#ifdef SHOJI_IS_RIGHT
+	/*expect*/ { 0,1,-1				   },
+#else
+	/*expect*/ { 0,1,2				   },
+#endif
+      },
+      { /*input.*/ { { 0x00C1,0x00A1,0x0000 },		 2 },  /* 17 */
+	/*expect*/ { 0,1,2				   },
+      },
+      { /*input.*/ { { 0x00C1,0x00FF,0x0000 },		 2 },  /* 18 */
+	/*expect*/ { 0,1,2				   },
+      },
+      { /*input.*/ { { 0x00C1,0x3042,0x0000 },		 2 },  /* 19 */
+	/*expect*/ { 0,1,-1				   },
+      },
+      { /*input.*/ { { 0x00C1,0x3044,0x0000 },		 2 },  /* 20 */
+	/*expect*/ { 0,1,-1				   },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcswidth, TST_LOC_enUS },
+    {
+      { /*input.*/ { { 0x0041,0x0042,0x00C3,0x0000 },	 0 },  /* 01 */
+	/*expect*/ { 0,1,0				   },
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x00C3,0x0000 },	 1 },  /* 02 */
+	/*expect*/ { 0,1,1				   },
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x00C3,0x0000 },	 2 },  /* 03 */
+	/*expect*/ { 0,1,2				   },
+      },
+#ifdef SHOJI_IS_RIGHT
+      { /*input.*/ { { 0x0041,0x0042,0x00C3,0x0000 },	 3 },  /* 04 */
+	/*expect*/ { 0,1,3				   },
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x00C3,0x0000 },	 4 },  /* 05 */
+	/*expect*/ { 0,1,3				   },
+      },
+#else
+      { /*input.*/ { { 0x0041,0x0042,0x00C3,0x0000 },	 3 },  /* 04 */
+	/*expect*/ { 0,1,-1				   },
+      },
+      { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },	 4 },  /* 05 */
+	/*expect*/ { 0,1,3				   },
+      },
+#endif
+      { /*input.*/ { { 0x0000 },			 1 },  /* 06 */
+	/*expect*/ { 0,1,0				   },
+      },
+      { /*input.*/ { { 0x0041,0x0001,0x0000 },		 2 },  /* 07 */
+	/*expect*/ { 0,1,-1				   },
+      },
+      { /*input.*/ { { 0x0041,0x0001,0x0000 },		 1 },  /* 08 */
+	/*expect*/ { 0,1,1				   },
+      },
+      { /*input.*/ { { 0x0041,0x0001,0x0000 },		 2 },  /* 09 */
+	/*expect*/ { 0,1,-1				   },
+      },
+      { /*input.*/ { { 0x0041,0x0092,0x0000 },		 2 },  /* 10 */
+	/*expect*/ { 0,1,-1				   },
+      },
+      { /*input.*/ { { 0x0041,0x0020,0x0000 },		 2 },  /* 11 */
+	/*expect*/ { 0,1,2				   },
+      },
+      { /*input.*/ { { 0x0041,0x0021,0x0000 },		 2 },  /* 12 */
+	/*expect*/ { 0,1,2				   },
+      },
+      { /*input.*/ { { 0x0041,0x007E,0x0000 },		 2 },  /* 13 */
+	/*expect*/ { 0,1,2				   },
+      },
+      { /*input.*/ { { 0x0041,0x007F,0x0000 },		 2 },  /* 14 */
+	/*expect*/ { 0,1,-1				   },
+      },
+      { /*input.*/ { { 0x0041,0x0080,0x0000 },		 2 },  /* 15 */
+	/*expect*/ { 0,1,-1				   },
+      },
+      { /*input.*/ { { 0x0041,0x00A0,0x0000 },		 2 },  /* 16 */
+	/*expect*/ { 0,1,-1				   },
+      },
+#ifdef SHOJI_IS_RIGHT
+      { /*input.*/ { { 0x0041,0x00A1,0x0000 },		 2 },  /* 17 */
+	/*expect*/ { 0,1,2				   },
+      },
+      { /*input.*/ { { 0x0041,0x00FF,0x0000 },		 2 },  /* 18 */
+	/*expect*/ { 0,1,2				   },
+      },
+#else
+      { /*input.*/ { { 0x0041,0x007E,0x0000 },		 2 },  /* 17 */
+	/*expect*/ { 0,1,2				   },
+      },
+      { /*input.*/ { { 0x0041,0x0020,0x0000 },		 2 },  /* 18 */
+	/*expect*/ { 0,1,2				   },
+      },
+#endif
+      { /*input.*/ { { 0x0041,0x3042,0x0000 },		 2 },  /* 19 */
+	/*expect*/ { 0,1,-1				   },
+      },
+      { /*input.*/ { { 0x0041,0x3044,0x0000 },		 2 },  /* 20 */
+	/*expect*/ { 0,1,-1				   },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcswidth, TST_LOC_eucJP },
+    {
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },	 0 },  /* 01 */
+	/*expect*/ { 0,1,0				   },
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },	 1 },  /* 02 */
+	/*expect*/ { 0,1,2				   },
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },	 2 },  /* 03 */
+	/*expect*/ { 0,1,4				   },
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },	 3 },  /* 04 */
+	/*expect*/ { 0,1,6				   },
+      },
+      { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },	 4 },  /* 05 */
+	/*expect*/ { 0,1,6				   },
+      },
+      { /*input.*/ { { 0x0000 },			 1 },  /* 06 */
+	/*expect*/ { 0,1,0				   },
+      },
+      { /*input.*/ { { 0x008E,0x0001,0x0000 },		 2 },  /* 07 */
+	/*expect*/ { 0,1,-1				   },
+      },
+      { /*input.*/ { { 0x3041,0x008E,0x0000 },		 1 },  /* 08 */
+	/*expect*/ { 0,1,2				   },
+      },
+      { /*input.*/ { { 0x3041,0x008E,0x0000 },		 2 },  /* 09 */
+	/*expect*/ { 0,1,-1				   },
+      },
+      { /*input.*/ { { 0x3041,0x0001,0x0000 },		 2 },  /* 10 */
+	/*expect*/ { 0,1,-1				   },
+      },
+      { /*input.*/ { { 0x3041,0x3000,0x0000 },		 2 },  /* 11 */
+	/*expect*/ { 0,1,4				   },
+      },
+      { /*input.*/ { { 0x0041,0x0021,0x0000 },		 2 },  /* 12 */
+	/*expect*/ { 0,1,2				   },
+      },
+      { /*input.*/ { { 0x0041,0x007E,0x0000 },		 2 },  /* 13 */
+	/*expect*/ { 0,1,2				   },
+      },
+      { /*input.*/ { { 0x0041,0x007F,0x0000 },		 2 },  /* 14 */
+	/*expect*/ { 0,1,-1				   },
+      },
+      { /*input.*/ { { 0x0041,0x0080,0x0000 },		 2 },  /* 15 */
+	/*expect*/ { 0,1,-1				   },
+      },
+      { /*input.*/ { { 0x0041,0x00A0,0x0000 },		 2 },  /* 16 */
+	/*expect*/ { 0,1,-1				   },
+      },
+#ifdef NO_WAIVER
+      /* <NO_WAIVER> */	 /* returns 3 */
+      { /*input.*/ { { 0x0041,0x00A1,0x0000 },		 2 },  /* 17 */
+	/*expect*/ { 0,1,-1				   },
+      },
+#else
+      /* XXX U00A1 is valid -> /x8f/xa2/xc4 in JIS X 0212 */
+      { /*input.*/ { { 0x0041,0x00A1,0x0000 },		 2 },  /* 17 */
+	/*expect*/ { 0,1,3				   },
+      },
+#endif
+      { /*input.*/ { { 0x0041,0xFF71,0x0000 },		 2 },  /* 18 */
+	/*expect*/ { 0,1,2				   },
+      },
+      { /*input.*/ { { 0x0041,0x3042,0x0000 },		 2 },  /* 19 */
+	/*expect*/ { 0,1,3				   },
+      },
+      { /*input.*/ { { 0x0041,0x3044,0x0000 },		 2 },  /* 20 */
+	/*expect*/ { 0,1,3				   },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcswidth, TST_LOC_end }
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcsxfrm.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcsxfrm.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcsxfrm.c	(revision 2036)
@@ -0,0 +1,98 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN CLIBRARY
+ *
+ *	 FILE:	dat_wcsxfrm.c
+ *
+ *	 WCSXFRM:  size_t  wcsxfrm (char *s1, const char s2, size_t n);
+ */
+
+/*
+ *  NOTE:
+ *
+ *  Return value and errno value are checked only for 2nd string:
+ *  org2[]; n1 and n2 don't mean bytes to be translated.
+ *  It means a buffer size including a null character.
+ *  Results of this test depens on results of wcscoll().
+ *  If you got errors, check both test results.
+ */
+
+
+TST_WCSXFRM tst_wcsxfrm_loc [] = {
+
+  {
+    { Twcsxfrm, TST_LOC_de },
+    {
+      { /*inp*/ { { 0x00C1,0x0000 }, { 0x00C1,0x0000 }, 7, 7 },	 /* #01 */
+	/*exp*/ {   0,	       0,0,		     },
+      },
+      { /*inp*/ { { 0x0042,0x0000 }, { 0x0061,0x0000 }, 7, 7 },	 /* #02 */
+	/*exp*/ {   0,	       0,0,		     },
+      },
+      { /*inp*/ { { 0x0061,0x0000 }, { 0x0042,0x0000 }, 7, 7 },	 /* #03 */
+	/*exp*/ {   0,	       0,0,		     },
+      },
+      { /*inp*/ { { 0x00E4,0x0000 }, { 0x00DC,0x0000 }, 7, 7 },	 /* #04 */
+	/*exp*/ {   0,	       0,0,		     },
+      },
+      { /*inp*/ { { 0x00DC,0x0000 }, { 0x00E4,0x0000 }, 7, 7 },	 /* #05 */
+	/*exp*/ {   0,	       0,0,		     },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcsxfrm, TST_LOC_enUS },
+    {
+      { /*inp*/ { { 0x0041,0x0000 }, { 0x0041,0x0000 }, 7, 7 },	 /* #01 */
+	/*exp*/ {   0,	       0,0,		     },
+      },
+      { /*inp*/ { { 0x0042,0x0000 }, { 0x0061,0x0000 }, 7, 7 },	 /* #02 */
+	/*exp*/ {   0,	       0,0,		     },
+      },
+      { /*inp*/ { { 0x0061,0x0000 }, { 0x0042,0x0000 }, 7, 7 },	 /* #03 */
+	/*exp*/ {   0,	       0,0,		     },
+      },
+      { /*inp*/ { { 0x0000,0x0000 }, { 0x0000,0x0000 }, 7, 7 },	 /* #04 */
+	/*exp*/ {   0,	       0,0,		     },
+      },
+#ifdef NO_WAIVER
+      { /* <WAIVER> x 2 */
+	/*inp*/ { { 0x3061,0x0000 }, { 0xFF42,0x0000 }, 7, 7 },	 /* #05 */
+	/* <WAIVER>	*/
+	/*exp*/ {   EINVAL,	       1,(size_t)-1,	     },
+      },
+#endif
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcsxfrm, TST_LOC_eucJP },	     /* need more test data ! */
+    {
+      { /*inp*/ { { 0x3041,0x0000 }, { 0x3041,0x0000 }, 7, 7 },	 /* #01 */
+	/*exp*/ {   0,	       0,0,		     },
+      },
+      { /*inp*/ { { 0x0042,0x0000 }, { 0x0061,0x0000 }, 7, 7 },	 /* #02 */
+	/*exp*/ {   0,	       0,0,		     },
+      },
+      { /*inp*/ { { 0x0061,0x0000 }, { 0x0042,0x0000 }, 7, 7 },	 /* #03 */
+	/*exp*/ {   0,	       0,0,		     },
+      },
+      { /*inp*/ { { 0x30A2,0x0000 }, { 0xFF71,0x0000 }, 7, 7 },	 /* #04 */
+	/*exp*/ {   0,	       0,0,		     },
+      },
+      { /*inp*/ { { 0xFF71,0x0000 }, { 0x30A2,0x0000 }, 7, 7 },	 /* #05 */
+	/*exp*/ {   0,	       0,0,		     },
+      },
+#ifdef NO_WAIVER
+      /* <WAIVER> x 2 */
+      { /*inp*/ { { 0x008E,0x0000 }, { 0x008F,0x0000 }, 7, 7 },	 /* #06 */
+	/*exp*/ {   EINVAL,	       1,(size_t)-1,	     },
+      },
+#endif
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twcsxfrm, TST_LOC_end }
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wctob.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wctob.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wctob.c	(revision 2036)
@@ -0,0 +1,53 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_wctob.c
+ *
+ *	 ISW*:	int wctob( wint_t wc );
+ */
+
+
+TST_WCTOB tst_wctob_loc [] = {
+
+    {	{ Twctob, TST_LOC_de },
+	{
+	  {  { WEOF   }, { 0,	 1, EOF	       }  },
+	  {  { 0x0020 }, { 0,	 1, 0x20       }  },
+	  {  { 0x0061 }, { 0,	 1, 0x61       }  },
+	  {  { 0x0080 }, { 0,	 1, 0x80       }  },
+	  {  { 0x00C4 }, { 0,	 1, 0xC4       }  },
+	  {  { 0x30C4 }, { 0,	 1, EOF	       }  },
+	  {  .is_last = 1 } /* Last element.  */
+	}
+    },
+    {	{ Twctob, TST_LOC_enUS },
+	{
+	  {  { WEOF   }, { 0,	 1, EOF	       }  },
+	  {  { 0x0020 }, { 0,	 1, 0x20       }  },
+	  {  { 0x0061 }, { 0,	 1, 0x61       }  },
+#ifdef SHOJI_IS_RIGHT
+	  {  { 0x0080 }, { 0,	 1, 0x80       }  },
+	  {  { 0x00C4 }, { 0,	 1, 0xC4       }  },
+#else
+	  /* XXX These are no valid characters.  */
+	  {  { 0x0080 }, { 0,	 1, EOF        }  },
+	  {  { 0x00C4 }, { 0,	 1, EOF        }  },
+#endif
+	  {  { 0x30C4 }, { 0,	 1, EOF	       }  },
+	  {  .is_last = 1 } /* Last element.  */
+	}
+    },
+    {	{ Twctob, TST_LOC_eucJP },
+	{
+	  {  { WEOF   }, { 0,	 1, EOF	       }  },
+	  {  { 0x0020 }, { 0,	 1, 0x20       }  },
+	  {  { 0x0061 }, { 0,	 1, 0x61       }  },
+	  {  { 0x0080 }, { 0,	 1, 0x80       }  },
+	  {  { 0x00FF }, { 0,	 1, EOF        }  },
+	  {  { 0x00C4 }, { 0,	 1, EOF	       }  },
+	  {  { 0x30C4 }, { 0,	 1, EOF	       }  },
+	  {  .is_last = 1 } /* Last element.  */
+	}
+    },
+    {	{ Twctob, TST_LOC_end } }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wctomb.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wctomb.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wctomb.c	(revision 2036)
@@ -0,0 +1,139 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_wctomb.c
+ *
+ *	 WCTOMB:  int wctomb (char *s, wchar_t wc)
+ */
+
+
+/*
+ *  FUNCTION:
+ *
+ *	  int  wctomb (char *s, wchar_t wc);
+ *
+ *	       return: the number of bytes
+ *
+ *  NOTE:
+ *
+ *	 o When you feed a null pointer for a string (s) to the function,
+ *	   set s_flg=0 instead of putting just a 'NULL' there.
+ *	   Even if you put a 'NULL', it means a null string as well as "".
+ *
+ *	 o When s is a null pointer, the function checks state dependency.
+ *
+ *	       state-dependent encoding	     - return  NON-zero
+ *	       state-independent encoding    - return  0
+ *
+ *	   If state-dependent encoding is expected, set
+ *
+ *	       s_flg = 0,  ret_flg = 0,	 ret_val = +1
+ *
+ *	   If state-independent encoding is expected, set
+ *
+ *	       s_flg = 0,  ret_flg = 0,	 ret_val = 0
+ *
+ *
+ *	   When you set ret_flg=1, the test program simply compares an
+ *	   actual return value with an expected value. You can check
+ *	   state-independent case (return value is 0) in that way, but
+ *	   you can not check state-dependent case. So when you check
+ *	   state- dependency in this test function: tst_wctomb(), set
+ *	   ret_flg=0 always. It's a special case, and the test
+ *	   function takes care of it.
+ *
+ *	      Input	  Expect
+ *
+ *		s_flg=0		  ret_flg=0
+ *		|		  |
+ *	      { 0, 0 },	  { 0, 0, 0,  x,  "" }
+ *		   |		      |
+ *		   not used	      ret_val: 0/+1
+ * (expected val)
+ */
+
+
+TST_WCTOMB tst_wctomb_loc [] = {
+  {
+    { Twctomb, TST_LOC_de },
+    {
+      /* #01 : normal case		   */
+      { /*input.*/ { 1,	   0x00C4  },
+	/*expect*/ { 0,1,1,  "Ä"	   },
+      },
+      /* #02 : normal case		   */
+      { /*input.*/ { 1,	   0x00DC  },
+	/*expect*/ { 0,1,1,  "Ü"	   },
+      },
+      /* #03 : normal case		   */
+      { /*input.*/ { 1,	   0x0092  },
+	/*expect*/ { 0,1,1,  "\222"  },
+      },
+      /* #04 : error case		   */
+      { /*input.*/ { 1,	   0x3041  },
+	/*expect*/ { 0,1,-1, ""	   },
+      },
+      /* #05 : state dependency	   */
+      { /*input.*/ { 0,	   0x0000  },
+	/*expect*/ { 0,0,0,  ""	   },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twctomb, TST_LOC_enUS },
+    {
+      /* #01 : normal case		   */
+      { /*input.*/ { 1,	   0x0041  },
+	/*expect*/ { 0,1,1,  "A"	   },
+      },
+      /* #02 : normal case		   */
+      { /*input.*/ { 1,	   0x0042  },
+	/*expect*/ { 0,1,1,  "B"	   },
+      },
+      /* #03 : error case		   */
+      /* <WAIVER> */
+      { /*input.*/ { 1,	   0x00C4  },
+	/*expect*/ { 0,1,-1, ""	   },
+      },
+      /* #04 : error case		   */
+      { /*input.*/ { 1,	   0x30A4  },
+	/*expect*/ { 0,1,-1, ""	   },
+      },
+      /* #05 : state dependency	   */
+      { /*input.*/ { 0,	   0x0000  },
+	/*expect*/ { 0,0,0,  ""	   },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twctomb, TST_LOC_eucJP },
+    {
+      /* #01 : normal case		   */
+      { /*input.*/ { 1,	   0x3042  },
+	/*expect*/ { 0,1,2,  "\244\242"   },
+      },
+      /* #02 : normal case		   */
+      { /*input.*/ { 1,	   0x3044  },
+	/*expect*/ { 0,1,2,  "\244\244"   },
+      },
+      /* #03 : normal case		   */
+      { /*input.*/ { 1,	   0x008E  },
+	/*expect*/ { 0,1,-1, ""	   },
+      },
+      /* #04 : jisX0212		   */
+      { /*input.*/ { 1,	   0x00C4	  },
+	/*expect*/ { 0,1,3,  "\217\252\243" }, /* jisx0210  returns 3 */
+      },
+      /* #05 : state dependency	   */
+      { /*input.*/ { 0,	   0x008E  },
+	/*expect*/ { 0,0,0,  ""	   },
+      },
+      { .is_last = 1 }
+    }
+  },
+  {
+    { Twctomb, TST_LOC_end }
+  }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wctrans.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wctrans.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wctrans.c	(revision 2036)
@@ -0,0 +1,95 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN CLIBRARY
+ *
+ *       FILE:  dat_wctrans.c
+ *
+ *       WCTRANS:  wctrans_t  wctrans( const char *charclass );
+ */
+
+/*
+ *  NOTE:
+ *        When a return value is expected to be 0 (false),
+ *        set ret_flg=1 and set ret_val=0.
+ *        Otherwise just set ret_flg=0.
+ */
+
+
+TST_WCTRANS tst_wctrans_loc [] = {
+
+    {   { Twctrans, TST_LOC_de },
+        {
+          { /*inp*/ { ""               },  /* #1 */
+            /*exp*/ { 0,1,0,         },
+          },
+          { /*inp*/ { "upper"          },  /* #2 */
+            /*exp*/ { 0,1,0,         },
+          },
+          { /*inp*/ { "lower"          },  /* #3 */
+            /*exp*/ { 0,1,0,         },
+          },
+          { /*inp*/ { "toupper"        },  /* #4 */
+            /*exp*/ { 0,0,0,         },
+          },
+          { /*inp*/ { "tolower"        },  /* #5 */
+            /*exp*/ { 0,0,0,         },
+          },
+          { /*inp*/ { "xxxxx"          },  /* #6 */
+            /*exp*/ { 0,1,0,         },
+          },
+	  { .is_last = 1 }
+        }
+    },
+    {   { Twctrans, TST_LOC_enUS },
+        {
+          { /*inp*/ { ""               },  /* #1 */
+            /*exp*/ { 0,1,0,         },
+          },
+          { /*inp*/ { "upper"          },  /* #2 */
+            /*exp*/ { 0,1,0,         },
+          },
+          { /*inp*/ { "lower"          },  /* #3 */
+            /*exp*/ { 0,1,0,         },
+          },
+          { /*inp*/ { "toupper"        },  /* #4 */
+            /*exp*/ { 0,0,0,         },
+          },
+          { /*inp*/ { "tolower"        },  /* #5 */
+            /*exp*/ { 0,0,0,         },
+          },
+          { /*inp*/ { "xxxxx"          },  /* #6 */
+            /*exp*/ { 0,1,0,         },
+          },
+	  { .is_last = 1 }
+        }
+    },
+    {   { Twctrans, TST_LOC_eucJP },
+        {
+          { /*inp*/ { ""               },  /* #1 */
+            /*exp*/ { 0,1,0,         },
+          },
+          { /*inp*/ { "upper"          },  /* #2 */
+            /*exp*/ { 0,1,0,         },
+          },
+          { /*inp*/ { "lower"          },  /* #3 */
+            /*exp*/ { 0,1,0,         },
+          },
+          { /*inp*/ { "toupper"        },  /* #4 */
+            /*exp*/ { 0,0,0,         },
+          },
+          { /*inp*/ { "tolower"        },  /* #5 */
+            /*exp*/ { 0,0,0,         },
+          },
+          { /*inp*/ { "xxxxx"          },  /* #6 */
+            /*exp*/ { 0,1,0,         },
+          },
+          { /*inp*/ { "tojhira"        },  /* #7 */
+            /*exp*/ { 0,0,0,         },
+          },
+          { /*inp*/ { "tojkata"        },  /* #8 */
+            /*exp*/ { 0,0,0,         },
+          },
+	  { .is_last = 1 }
+        }
+    },
+    {   { Twctrans, TST_LOC_end }}
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wctype.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wctype.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wctype.c	(revision 2036)
@@ -0,0 +1,185 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN CLIBRARY
+ *
+ *	 FILE:	dat_wctype.c
+ *
+ *	 WCTYPE:  wctype_t  wctype( const char *class );
+ */
+
+/*
+ *  NOTE:
+ *	  When a return value is expected to be 0 (false),
+ *	  set ret_flg=1 and set ret_val=0.
+ *	  Otherwise just set ret_flg=0.
+ */
+
+
+TST_WCTYPE tst_wctype_loc [] = {
+
+    {	{ Twctype, TST_LOC_de },
+	{
+	  { /*inp*/ { "alnum"	       },  /* #01 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "alpha"	       },  /* #02 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "cntrl"	       },  /* #03 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "digit"	       },  /* #04 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "graph"	       },  /* #05 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "lower"	       },  /* #06 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "print"	       },  /* #07 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "punct"	       },  /* #08 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "space"	       },  /* #09 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "upper"	       },  /* #10 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "xdigit"	       },  /* #11 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { ""	       },  /* #12 */
+	    /*exp*/ { 0,1,0,	       },
+	  },
+	  { /*inp*/ { "ideograph"      },  /* #13 */
+	    /*exp*/ { 0,1,0,	       },
+	  },
+	  { /*inp*/ { "english"	       },  /* #14 */
+	    /*exp*/ { 0,1,0,	       },
+	  },
+	  { /*inp*/ { "ascii"	       },  /* #15 */
+	    /*exp*/ { 0,1,0,	       },
+	  },
+	  { /*inp*/ { "special"	       },  /* #16 */
+	    /*exp*/ { 0,1,0,	       },
+	  },
+	  { .is_last = 1 }
+	}
+    },
+    {	{ Twctype, TST_LOC_enUS },
+	{
+	  { /*inp*/ { "alnum"	       },  /* #01 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "alpha"	       },  /* #02 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "cntrl"	       },  /* #03 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "digit"	       },  /* #04 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "graph"	       },  /* #05 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "lower"	       },  /* #06 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "print"	       },  /* #07 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "punct"	       },  /* #08 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "space"	       },  /* #09 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "upper"	       },  /* #10 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "xdigit"	       },  /* #11 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { ""	       },  /* #12 */
+	    /*exp*/ { 0,1,0,	       },
+	  },
+	  { /*inp*/ { "ideograph"      },  /* #13 */
+	    /*exp*/ { 0,1,0,	       },
+	  },
+	  { /*inp*/ { "english"	       },  /* #14 */
+	    /*exp*/ { 0,1,0,	       },
+	  },
+	  { /*inp*/ { "ascii"	       },  /* #15 */
+	    /*exp*/ { 0,1,0,	       },
+	  },
+	  { /*inp*/ { "special"	       },  /* #16 */
+	    /*exp*/ { 0,1,0,	       },
+	  },
+	  { .is_last = 1 }
+	}
+    },
+    {	{ Twctype, TST_LOC_eucJP },
+	{
+	  { /*inp*/ { "alnum"	       },  /* #01 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "alpha"	       },  /* #02 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "cntrl"	       },  /* #03 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "digit"	       },  /* #04 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "graph"	       },  /* #05 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "lower"	       },  /* #06 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "print"	       },  /* #07 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "punct"	       },  /* #08 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "space"	       },  /* #09 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "upper"	       },  /* #10 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "xdigit"	       },  /* #11 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "ideogram"       },  /* #12 */
+	    /*exp*/ { 0,1,0,	       },
+	  },
+	  { /*inp*/ { "phonogram"      },  /* #13 */
+	    /*exp*/ { 0,1,0,	       },
+	  },
+	  { /*inp*/ { "jspace"	       },  /* #14 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "jhira"	       },  /* #15 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "jkata"	       },  /* #16 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "jkanji"	       },  /* #17 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { /*inp*/ { "jdigit"	       },  /* #18 */
+	    /*exp*/ { 0,0,0,	       },
+	  },
+	  { .is_last = 1 }
+	}
+    },
+    {	{ Twctype, TST_LOC_end }}
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcwidth.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcwidth.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/dat_wcwidth.c	(revision 2036)
@@ -0,0 +1,110 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_wcwidth.c
+ *
+ *	 WCWIDTH:  int wcwidth (wchar_t wc);
+ */
+
+TST_WCWIDTH tst_wcwidth_loc [] = {
+    {
+      { Twcwidth, TST_LOC_de },
+      {
+	{ /*inp*/ { 0x0000		     },	 /* #01 */
+	  /*exp*/ { 0,	1,0,	     },
+	},
+	{ /*inp*/ { 0x0020		     },	 /* #02 */
+	  /*exp*/ { 0,	1,1,	     },
+	},
+	{ /*inp*/ { 0x007F		     },	 /* #03 */
+	  /*exp*/ { 0,	1,-1,	     },
+	},
+	{ /*inp*/ { 0x0080		     },	 /* #04 */
+	  /*exp*/ { 0,	1,-1,	     },
+	},
+	{ /*inp*/ { 0x00A1		     },	 /* #05 */
+	  /*exp*/ { 0,	1,1,	     },
+	},
+	{ /*inp*/ { 0x00C1		     },	 /* #06 */
+	  /*exp*/ { 0,	1,1,	     },
+	},
+#ifdef SHOJI_IS_RIGHT
+	/* <WAIVER> */	/* CHECK : wint_t */
+	{ /*inp*/ { 0x3041		     },	 /* #07 */
+	  /*exp*/ { 0,	1,0,	     },
+	},
+#else
+	{ /*inp*/ { 0x3041		     },	 /* #07 */
+	  /*exp*/ { 0,	1,EOF,	     },
+	},
+#endif
+	{ .is_last = 1 }
+      }
+    },
+    {
+      { Twcwidth, TST_LOC_enUS },
+      {
+	{ /*inp*/ { 0x0000		     },	 /* #01 */
+	  /*exp*/ { 0,	1,0,	     },
+	},
+	{ /*inp*/ { 0x0020		     },	 /* #02 */
+	  /*exp*/ { 0,	1,1,	     },
+	},
+	{ /*inp*/ { 0x007F		     },	 /* #03 */
+	  /*exp*/ { 0,	1,-1,	     },
+	},
+	{ /*inp*/ { 0x0080		     },	 /* #04 */
+	  /*exp*/ { 0,	1,-1,	     },
+	},
+	{ /*inp*/ { 0x00A1		     },	 /* #05 */
+	  /*exp*/ { 0,	1,-1,	     },
+	},
+	{ /*inp*/ { 0x00C1		     },	 /* #06 */
+	  /*exp*/ { 0,	1,-1,	     },
+	},
+	{ /*inp*/ { 0x3041		     },	 /* #07 */
+	  /*exp*/ { 0,	1,-1,	     },
+	},
+	{ .is_last = 1 }
+      }
+    },
+    {
+      { Twcwidth, TST_LOC_eucJP },
+      {
+	{ /*inp*/ { 0x0000		     },	 /* #01 */
+	  /*exp*/ { 0,	1,0,	     },
+	},
+	{ /*inp*/ { 0x0020		     },	 /* #02 */
+	  /*exp*/ { 0,	1,1,	     },
+	},
+	{ /*inp*/ { 0x007F		     },	 /* #03 */
+	  /*exp*/ { 0,	1,-1,	     },
+	},
+	{ /*inp*/ { 0x0080		     },	 /* #04 */
+	  /*exp*/ { 0,	1,-1,	     },
+	},
+#ifdef SHOJI_IS_RIGHT
+	/* <NO_WAIVER> */
+	{ /*inp*/ { 0x00A1		     },	 /* #05 */
+	  /*exp*/ { 0,	1,0,	     },
+	},
+#else
+	/* XXX U00A1 is a valid character in EUC-JP.  */
+	{ /*inp*/ { 0x00A1		     },	 /* #05 */
+	  /*exp*/ { 0,	1,2,	     },
+	},
+#endif
+	/* jisx0212 */
+	{ /*inp*/ { 0x00C1		     },	 /* #06 */
+	  /*exp*/ { 0,	1,2,	     },
+	},
+	{ /*inp*/ { 0x3041		     },	 /* #07 */
+	  /*exp*/ { 0,	1,2,	     },
+	},
+	{ .is_last = 1 }
+      }
+    },
+    {
+      { Twcwidth, TST_LOC_end }
+    }
+};
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tgn_funcdef.h
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tgn_funcdef.h	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tgn_funcdef.h	(revision 2036)
@@ -0,0 +1,160 @@
+#ifndef TGN_FUNCDEF_H
+#define TGN_FUNCDEF_H
+
+/* Unique number for each test.  */
+#define	 Tiswalnum		1
+#define	 Tiswalpha		2
+#define	 Tiswcntrl		3
+#define	 Tiswctype		4
+#define	 Tiswdigit		5
+#define	 Tiswgraph		6
+#define	 Tiswlower		7
+#define	 Tiswprint		8
+#define	 Tiswpunct		9
+#define	 Tiswspace		10
+#define	 Tiswupper		11
+#define	 Tiswxdigit		12
+#define	 Tmblen			13
+#define	 Tmbrlen		14
+#define	 Tmbrtowc		15
+#define	 Tmbsrtowcs		16
+#define	 Tmbstowcs		17
+#define	 Tmbtowc		18
+#define	 Tstrcoll		19
+#define	 Tstrfmon		20
+#define	 Tstrxfrm		21
+#define	 Tswscanf		22
+#define	 Ttowctrans		23
+#define	 Ttowlower		24
+#define	 Ttowupper		25
+#define	 Twcrtomb		26
+#define	 Twcscat		27
+#define	 Twcschr		28
+#define	 Twcscmp		29
+#define	 Twcscoll		30
+#define	 Twcscpy		31
+#define	 Twcscspn		32
+#define	 Twcslen		33
+#define	 Twcsncat		34
+#define	 Twcsncmp		35
+#define	 Twcsncpy		36
+#define	 Twcspbrk		37
+#define	 Twcsrtombs		38
+#define	 Twcsspn		39
+#define	 Twcsstr		40
+#define	 Twcstod		41
+#define	 Twcstok		42
+#define	 Twcstombs		43
+#define	 Twcswidth		44
+#define	 Twcsxfrm		45
+#define	 Twctob			46
+#define	 Twctomb		47
+#define	 Twctrans		48
+#define	 Twctype		49
+#define	 Twcwidth		50
+
+/* Name of each test.  */
+#define	 S_ISWALNUM	"iswalnum"
+#define	 S_ISWALPHA	"iswalpha"
+#define	 S_ISWCNTRL	"iswcntrl"
+#define	 S_ISWCTYPE	"iswctype"
+#define	 S_ISWDIGIT	"iswdigit"
+#define	 S_ISWGRAPH	"iswgraph"
+#define	 S_ISWLOWER	"iswlower"
+#define	 S_ISWPRINT	"iswprint"
+#define	 S_ISWPUNCT	"iswpunct"
+#define	 S_ISWSPACE	"iswspace"
+#define	 S_ISWUPPER	"iswupper"
+#define	 S_ISWXDIGIT	"iswxdigit"
+#define	 S_MBLEN	"mblen"
+#define	 S_MBRLEN	"mbrlen"
+#define	 S_MBRTOWC	"mbrtowc"
+#define	 S_MBSRTOWCS	"mbsrtowcs"
+#define	 S_MBSTOWCS	"mbstowcs"
+#define	 S_MBTOWC	"mbtowc"
+#define	 S_STRCOLL	"strcoll"
+#define	 S_STRFMON	"strfmon"
+#define	 S_STRXFRM	"strxfrm"
+#define	 S_SWSCANF	"swscanf"
+#define	 S_TOWCTRANS	"towctrans"
+#define	 S_TOWLOWER	"towlower"
+#define	 S_TOWUPPER	"towupper"
+#define	 S_WCRTOMB	"wcrtomb"
+#define	 S_WCSCAT	"wcscat"
+#define	 S_WCSCHR	"wcschr"
+#define	 S_WCSCMP	"wcscmp"
+#define	 S_WCSCOLL	"wcscoll"
+#define	 S_WCSCPY	"wcscpy"
+#define	 S_WCSCSPN	"wcscspn"
+#define	 S_WCSLEN	"wcslen"
+#define	 S_WCSNCAT	"wcsncat"
+#define	 S_WCSNCMP	"wcsncmp"
+#define	 S_WCSNCPY	"wcsncpy"
+#define	 S_WCSPBRK	"wcspbrk"
+#define	 S_WCSRTOMBS	"wcsrtombs"
+#define	 S_WCSSPN	"wcsspn"
+#define	 S_WCSSTR	"wcsstr"
+#define	 S_WCSTOD	"wcstod"
+#define	 S_WCSTOK	"wcstok"
+#define	 S_WCSTOMBS	"wcstombs"
+#define	 S_WCSWIDTH	"wcswidth"
+#define	 S_WCSXFRM	"wcsxfrm"
+#define	 S_WCTOB	"wctob"
+#define	 S_WCTOMB	"wctomb"
+#define	 S_WCTRANS	"wctrans"
+#define	 S_WCTYPE	"wctype"
+#define	 S_WCWIDTH	"wcwidth"
+
+/* Prototypes for test functions.  */
+extern int tst_iswalnum (FILE *, int);
+extern int tst_iswalpha (FILE *, int);
+extern int tst_iswcntrl (FILE *, int);
+extern int tst_iswctype (FILE *, int);
+extern int tst_iswdigit (FILE *, int);
+extern int tst_iswgraph (FILE *, int);
+extern int tst_iswlower (FILE *, int);
+extern int tst_iswprint (FILE *, int);
+extern int tst_iswpunct (FILE *, int);
+extern int tst_iswspace (FILE *, int);
+extern int tst_iswupper (FILE *, int);
+extern int tst_iswxdigit (FILE *, int);
+extern int tst_mblen (FILE *, int);
+extern int tst_mbrlen (FILE *, int);
+extern int tst_mbrtowc (FILE *, int);
+extern int tst_mbsrtowcs (FILE *, int);
+extern int tst_mbstowcs (FILE *, int);
+extern int tst_mbtowc (FILE *, int);
+extern int tst_strcoll (FILE *, int);
+extern int tst_strfmon (FILE *, int);
+extern int tst_strxfrm (FILE *, int);
+extern int tst_swscanf (FILE *, int);
+extern int tst_towctrans (FILE *, int);
+extern int tst_towlower (FILE *, int);
+extern int tst_towupper (FILE *, int);
+extern int tst_wcrtomb (FILE *, int);
+extern int tst_wcscat (FILE *, int);
+extern int tst_wcschr (FILE *, int);
+extern int tst_wcscmp (FILE *, int);
+extern int tst_wcscoll (FILE *, int);
+extern int tst_wcscpy (FILE *, int);
+extern int tst_wcscspn (FILE *, int);
+extern int tst_wcslen (FILE *, int);
+extern int tst_wcsncat (FILE *, int);
+extern int tst_wcsncmp (FILE *, int);
+extern int tst_wcsncpy (FILE *, int);
+extern int tst_wcspbrk (FILE *, int);
+extern int tst_wcsrtombs (FILE *, int);
+extern int tst_wcsspn (FILE *, int);
+extern int tst_wcsstr (FILE *, int);
+extern int tst_wcstod (FILE *, int);
+extern int tst_wcstok (FILE *, int);
+extern int tst_wcstombs (FILE *, int);
+extern int tst_wcswidth (FILE *, int);
+extern int tst_wcsxfrm (FILE *, int);
+extern int tst_wctob (FILE *, int);
+extern int tst_wctomb (FILE *, int);
+extern int tst_wctrans (FILE *, int);
+extern int tst_wctype (FILE *, int);
+extern int tst_wcwidth (FILE *, int);
+
+#endif /* TGN_FUNCDEF_H */
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tgn_locdef.h
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tgn_locdef.h	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tgn_locdef.h	(revision 2036)
@@ -0,0 +1,24 @@
+#ifndef TGN_LOCDEF_H
+#define TGN_LOCDEF_H
+
+/* Defines for all locales used in the suite.  */
+
+/* POSIX C locale.  */
+#define TST_LOC_C	"C"
+
+/* German locale with ISO-8859-1.  */
+#define TST_LOC_de	"de_DE.ISO-8859-1"
+
+/* For US we use ANSI_X3.4-1968 (ASCII).  */
+#define TST_LOC_enUS	"en_US.ANSI_X3.4-1968"
+
+/* Japanese locale with EUC-JP.  */
+#define TST_LOC_eucJP	"ja_JP.EUC-JP"
+
+/* German locale with UTF-8.  */
+#define TST_LOC_de_UTF8	"de_DE.UTF-8"
+
+/* End marker - must appear in each table as last entry.  */
+#define	TST_LOC_end	"lastEntry"
+
+#endif /* TGN_LOCDEF_H */
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tsp_common.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tsp_common.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tsp_common.c	(revision 2036)
@@ -0,0 +1,64 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *  Main driver
+ */
+
+
+#define TST_FUNCTION_CALL(func) _TST_FUNCTION_CALL(func)
+#define _TST_FUNCTION_CALL(func) tst ##_## func
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <locale.h>
+#include <errno.h>
+#include <signal.h>
+
+#include "tst_types.h"
+#include "tgn_locdef.h"
+
+
+int
+main (int argc, char *argv[])
+{
+  int ret;
+  int debug;
+
+  debug = argc > 1 ? atoi (argv[1]) : 0;
+
+  if (debug)
+    {
+      fprintf (stdout, "\nTST_MBWC ===> %s ...\n", argv[0]);
+    }
+  ret = TST_FUNCTION_CALL (TST_FUNCTION) (stdout, debug);
+
+  return (ret != 0);
+}
+
+#define	 MAX_RESULT_REC	 132
+char result_rec[MAX_RESULT_REC];
+
+
+int
+result (FILE * fp, char res, const char *func, const char *loc, int rec_no,
+	int seq_no, int case_no, const char *msg)
+{
+  if (fp == NULL
+      || strlen (func) + strlen (loc) + strlen (msg) + 32 > MAX_RESULT_REC)
+    {
+      fprintf (stderr,
+	       "Warning: result(): can't write the result: %s:%s:%d:%d:%s\n",
+	       func, loc, rec_no, case_no, msg);
+      return 0;
+    }
+
+  sprintf (result_rec, "%s:%s:%d:%d:%d:%c:%s\n", func, loc, rec_no, seq_no,
+	   case_no, res, msg);
+
+  if (fputs (result_rec, fp) == EOF)
+    {
+      return 0;
+    }
+
+  return 1;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_funcs.h
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_funcs.h	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_funcs.h	(revision 2036)
@@ -0,0 +1,272 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	tst_funcs.h
+ *
+ *	 Definitions of macros
+ */
+
+
+#ifndef TST_FUNCS_H
+#define TST_FUNCS_H
+
+#define C_SUCCESS	   'S'	/* test case test passed		 */
+#define C_FAILURE	   'F'	/* test case failed			 */
+#define C_IGNORED	   'I'	/* test case/result ignored (not tested) */
+#define C_INVALID	   'D'	/* test data may be wrong		 */
+#define C_LOCALES	   'L'	/* can't set locale (skip)		 */
+
+
+extern int result (FILE * fp, char res, const char *func, const char *loc,
+		   int rec_no, int seq_num, int case_no, const char *msg);
+
+#define Result(C, S, E, M) \
+  result (fp, (C), (S), locale, rec+1, seq_num+1, (E), (M))
+
+#define CASE_0	  0
+#define CASE_1	  1
+#define CASE_2	  2
+#define CASE_3	  3
+#define CASE_4	  4
+#define CASE_5	  5
+#define CASE_6	  6
+#define CASE_7	  7
+#define CASE_8	  8
+#define CASE_9	  9
+
+#define MS_PASSED "PASSED"
+#define MS_SPACE  "	 "
+#define MS_FAILED "	 "
+#define MS_NOTEST "NOTEST"
+#define MS_ABORTU "ABEND0"
+#define MS_ABORT  "ABEND1"
+
+#define MK_PASSED 0x00
+#define MK_SPACE  0x01
+#define MK_NOTEST 0x02
+#define MK_ABORTU 0x04
+#define MK_ABORT  0x08
+
+
+
+/* ------------------ COMMON MACROS ------------------ */
+
+#define TST_ABS(x)  (((x) > 0) ? (x) : -(x))
+
+#define TMD_ERRET(_type_)   int	  err_val; \
+			    int	  ret_flg; \
+			    _type_ ret_val
+
+#define TMD_RECHEAD(_FUNC_)				      \
+									 \
+			      typedef struct {				 \
+				  TIN_##_FUNC_##_REC  input;		 \
+				  TEX_##_FUNC_##_REC  expect;		 \
+				  int is_last;				 \
+			      }	  TST_##_FUNC_##_REC;			 \
+			      typedef struct {				 \
+				  TST_HEAD	      hd;		 \
+				  TST_##_FUNC_##_REC  rec[ MAX_LOC_TEST ]; \
+			      }	  TST_##_FUNC_
+
+#define TST_FTYP(func)		tst_##func##_loc
+#define TST_HEAD(func)		tst_##func##_loc[ loc ].hd
+#define TST_INPUT(func)		tst_##func##_loc[ loc ].rec[ rec ].input
+#define TST_EXPECT(func)	tst_##func##_loc[ loc ].rec[ rec ].expect
+#define TST_INPUT_SEQ(func) \
+	tst_##func##_loc[ loc ].rec[ rec ].input.seq[ seq_num ]
+#define TST_EXPECT_SEQ(func) \
+	tst_##func##_loc[ loc ].rec[ rec ].expect.seq[ seq_num ]
+#define TST_IS_LAST(func) \
+	tst_##func##_loc[ loc ].rec[ rec ].is_last
+
+
+#define TST_DECL_VARS(_type_)				\
+	int   loc, rec, err_count = 0;			\
+	int   warn_count __attribute__ ((unused));	\
+	int   func_id, seq_num = 0;			\
+	const char *locale;				\
+	int   err_exp, ret_flg;				\
+	int errno_save = 0;				\
+	_type_ ret_exp;					\
+	_type_ ret
+
+#define TST_DO_TEST(o_func) \
+	for (loc = 0; strcmp (TST_HEAD (o_func).locale, TST_LOC_end); ++loc)
+
+
+#define TST_HEAD_LOCALE(ofunc, s_func) \
+  func_id = TST_HEAD (ofunc).func_id;					      \
+  locale  = TST_HEAD (ofunc).locale;					      \
+  if (setlocale (LC_ALL, locale) == NULL)				      \
+    {									      \
+      fprintf (stderr, "Warning : can't set locale: %s\nskipping ...\n",      \
+	       locale);							      \
+      result (fp, C_LOCALES, s_func, locale, 0, 0, 0, "can't set locale");    \
+      ++err_count;							      \
+      continue;								      \
+    }
+
+#define TST_DO_REC(ofunc) \
+	for (rec=0; !TST_IS_LAST (ofunc); ++rec)
+
+#define TST_DO_SEQ(_count_) \
+	for (seq_num=0; seq_num < _count_; seq_num++)
+
+#define TST_GET_ERRET(_ofunc_)			\
+	err_exp = TST_EXPECT (_ofunc_).err_val; \
+	ret_flg = TST_EXPECT (_ofunc_).ret_flg; \
+	ret_exp = TST_EXPECT (_ofunc_).ret_val
+
+#define TST_GET_ERRET_SEQ(_ofunc_)		    \
+	err_exp = TST_EXPECT_SEQ (_ofunc_).err_val; \
+	ret_flg = TST_EXPECT_SEQ (_ofunc_).ret_flg; \
+	ret_exp = TST_EXPECT_SEQ (_ofunc_).ret_val
+
+#define TST_CLEAR_ERRNO \
+	errno = 0
+
+#define TST_SAVE_ERRNO \
+	errno_save = errno
+
+/* Test value of ret and of errno if it should have a value.  */
+#define TST_IF_RETURN(_s_func_) \
+  if (err_exp != 0)							      \
+    {									      \
+      if (errno_save == err_exp)					      \
+	{								      \
+	  result (fp, C_SUCCESS, _s_func_, locale, rec+1, seq_num+1, 1,	      \
+		  MS_PASSED);						      \
+	}								      \
+      else								      \
+	{								      \
+	  err_count++;							      \
+	  result (fp, C_FAILURE, _s_func_, locale, rec+1, seq_num+1, 1,	      \
+		  "the value of errno is different from an expected value");  \
+	}								      \
+    }									      \
+									      \
+  if (ret_flg == 1)							      \
+    {									      \
+      if (ret == ret_exp)						      \
+	{								      \
+	  result (fp, C_SUCCESS, _s_func_, locale, rec+1, seq_num+1, 2,	      \
+		  MS_PASSED);						      \
+	}								      \
+      else								      \
+	{								      \
+	  err_count++;							      \
+	  result (fp, C_FAILURE, _s_func_, locale, rec+1, seq_num+1, 2,	      \
+		  "the return value is different from an expected value");    \
+	}								      \
+    }									      \
+  else
+
+#define TEX_ERRET_REC(_type_)			\
+	struct {				\
+	    TMD_ERRET (_type_);			\
+	}
+
+#define TEX_ERRET_REC_SEQ(_type_, _count_)	\
+	struct {				\
+	    struct {				\
+		TMD_ERRET (_type_);		\
+	    } seq[ _count_ ];			\
+	}
+
+
+
+/* ------------------ FUNCTION: ISW*() ------------------- */
+
+#define TST_ISW_STRUCT(_FUNC_, _func_)			\
+	typedef						\
+	struct {					\
+	    wint_t   wc;				\
+	} TIN_ISW##_FUNC_##_REC;			\
+	typedef						\
+	TEX_ERRET_REC (int)   TEX_ISW##_FUNC_##_REC;	\
+	TMD_RECHEAD (ISW##_FUNC_)
+
+#define TST_FUNC_ISW(_FUNC_, _func_) \
+int									      \
+tst_isw##_func_ (FILE *fp, int debug_flg)				      \
+{									      \
+  TST_DECL_VARS(int);							      \
+  wint_t wc;								      \
+  TST_DO_TEST (isw##_func_)						      \
+    {									      \
+      TST_HEAD_LOCALE (isw##_func_, S_ISW##_FUNC_);			      \
+      TST_DO_REC(isw##_func_)						      \
+	{								      \
+	  TST_GET_ERRET (isw##_func_);					      \
+	  wc = TST_INPUT (isw##_func_).wc;				      \
+	  ret = isw##_func_ (wc);					      \
+	  if (debug_flg)						      \
+	    {								      \
+	      fprintf (stdout, "isw*() [ %s : %d ] ret = %d\n", locale,	      \
+		       rec+1, ret);					      \
+	    }								      \
+									      \
+	  TST_IF_RETURN (S_ISW##_FUNC_)					      \
+	    {								      \
+	      if (ret != 0)						      \
+		{							      \
+		  result (fp, C_SUCCESS, S_ISW##_FUNC_, locale, rec+1,	      \
+			  seq_num+1, 3, MS_PASSED);			      \
+		}							      \
+	      else							      \
+		{							      \
+		  err_count++;						      \
+		  result (fp, C_FAILURE, S_ISW##_FUNC_, locale, rec+1,	      \
+			  seq_num+1, 3,					      \
+			  "the function returned 0, but should be non-zero"); \
+		}							      \
+	    }								      \
+	}								      \
+    }									      \
+									      \
+  return err_count;							      \
+}
+
+
+
+/* ------------------ FUNCTION: TOW*() ------------------ */
+
+#define TST_TOW_STRUCT(_FUNC_, _func_)			\
+	typedef						\
+	struct {					\
+	    wint_t   wc;				\
+	} TIN_TOW##_FUNC_##_REC;			\
+	typedef						\
+	TEX_ERRET_REC (wint_t)	TEX_TOW##_FUNC_##_REC;	\
+	TMD_RECHEAD (TOW##_FUNC_)
+
+#define TST_FUNC_TOW(_FUNC_, _func_)					\
+int									\
+tst_tow##_func_ (FILE *fp, int debug_flg)				\
+{									\
+  TST_DECL_VARS (wint_t);						\
+  wint_t wc;								\
+  TST_DO_TEST (tow##_func_)						\
+    {									\
+      TST_HEAD_LOCALE (tow##_func_, S_TOW##_FUNC_);			\
+      TST_DO_REC (tow##_func_)						\
+	{								\
+	  TST_GET_ERRET (tow##_func_);					\
+	  wc = TST_INPUT (tow##_func_).wc;				\
+	  ret = tow##_func_ (wc);					\
+	  if (debug_flg)						\
+	    {								\
+	      fprintf (stdout, "tow*() [ %s : %d ] ret = 0x%x\n",	\
+		       locale, rec+1, ret);				\
+	    }								\
+									\
+	  TST_IF_RETURN (S_TOW##_FUNC_) { };				\
+	}								\
+    }									\
+									\
+  return err_count;							\
+}
+
+
+#endif /* TST_FUNCS_H */
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswalnum.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswalnum.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswalnum.c	(revision 2036)
@@ -0,0 +1,10 @@
+/*
+  ISWALNUM: int iswalnum (wint_t wc)
+*/
+
+#define TST_FUNCTION iswalnum
+
+#include "tsp_common.c"
+#include "dat_iswalnum.c"
+
+TST_FUNC_ISW (ALNUM, alnum);
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswalpha.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswalpha.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswalpha.c	(revision 2036)
@@ -0,0 +1,10 @@
+/*
+  ISWALPHA: int iswalpha (wint_t wc);
+*/
+
+#define TST_FUNCTION iswalpha
+
+#include "tsp_common.c"
+#include "dat_iswalpha.c"
+
+TST_FUNC_ISW (ALPHA, alpha);
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswcntrl.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswcntrl.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswcntrl.c	(revision 2036)
@@ -0,0 +1,10 @@
+/*
+  ISWCNTRL: int iswcntrl (wint_t wc);
+*/
+
+#define TST_FUNCTION iswcntrl
+
+#include "tsp_common.c"
+#include "dat_iswcntrl.c"
+
+TST_FUNC_ISW (CNTRL, cntrl);
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswctype.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswctype.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswctype.c	(revision 2036)
@@ -0,0 +1,53 @@
+/*
+  ISWCTYPE: int iswctype (wint_t wc, wctype_t desc);
+*/
+
+#define TST_FUNCTION iswctype
+
+#include "tsp_common.c"
+#include "dat_iswctype.c"
+
+
+int
+tst_iswctype (FILE *fp, int debug_flg)
+{
+  TST_DECL_VARS (int);
+  wint_t wc;
+  const char *ts;
+
+  TST_DO_TEST (iswctype)
+    {
+      TST_HEAD_LOCALE (iswctype, S_ISWCTYPE);
+      TST_DO_REC (iswctype)
+	{
+	  TST_GET_ERRET (iswctype);
+	  wc = TST_INPUT (iswctype).wc;
+	  ts = TST_INPUT (iswctype).ts;
+	  ret = iswctype (wc, wctype (ts));
+	  TST_SAVE_ERRNO;
+	  if (debug_flg)
+	    {
+	      fprintf (stdout, "iswctype() [ %s : %d ] ret = %d\n",
+		       locale, rec+1, ret);
+	    }
+
+	  TST_IF_RETURN (S_ISWCTYPE)
+	    {
+	      if (ret != 0)
+		{
+		  result (fp, C_SUCCESS, S_ISWCTYPE, locale, rec+1,
+			  seq_num+1, 3, MS_PASSED);
+		}
+	      else
+		{
+		  err_count++;
+		  result (fp, C_FAILURE, S_ISWCTYPE, locale, rec+1,
+			  seq_num+1, 3,
+			  "the function returned 0, but should be non-zero");
+		}
+	    }
+	}
+    }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswdigit.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswdigit.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswdigit.c	(revision 2036)
@@ -0,0 +1,11 @@
+/*
+  ISWDIGIT: int iswdigit (wint_t wc);
+*/
+
+
+#define TST_FUNCTION iswdigit
+
+#include "tsp_common.c"
+#include "dat_iswdigit.c"
+
+TST_FUNC_ISW (DIGIT, digit);
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswgraph.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswgraph.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswgraph.c	(revision 2036)
@@ -0,0 +1,10 @@
+/*
+  ISWGRAPH: int iswgraph (wint_t wc);
+*/
+
+#define TST_FUNCTION iswgraph
+
+#include "tsp_common.c"
+#include "dat_iswgraph.c"
+
+TST_FUNC_ISW (GRAPH, graph);
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswlower.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswlower.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswlower.c	(revision 2036)
@@ -0,0 +1,10 @@
+/*
+  ISWLOWER: int iswlower (wint_t wc);
+*/
+
+#define TST_FUNCTION iswlower
+
+#include "tsp_common.c"
+#include "dat_iswlower.c"
+
+TST_FUNC_ISW (LOWER, lower);
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswprint.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswprint.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswprint.c	(revision 2036)
@@ -0,0 +1,10 @@
+/*
+  ISWPRINT: int iswprint (wint_t wc);
+*/
+
+#define TST_FUNCTION iswprint
+
+#include "tsp_common.c"
+#include "dat_iswprint.c"
+
+TST_FUNC_ISW (PRINT, print);
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswpunct.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswpunct.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswpunct.c	(revision 2036)
@@ -0,0 +1,10 @@
+/*
+  ISWPUNCT: int iswpunct (wint_t wc);
+*/
+
+#define TST_FUNCTION iswpunct
+
+#include "tsp_common.c"
+#include "dat_iswpunct.c"
+
+TST_FUNC_ISW (PUNCT, punct);
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswspace.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswspace.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswspace.c	(revision 2036)
@@ -0,0 +1,10 @@
+/*
+  ISWSPACE: int iswspace (wint_t wc);
+*/
+
+#define TST_FUNCTION iswspace
+
+#include "tsp_common.c"
+#include "dat_iswspace.c"
+
+TST_FUNC_ISW (SPACE, space);
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswupper.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswupper.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswupper.c	(revision 2036)
@@ -0,0 +1,10 @@
+/*
+  ISWUPPER: int iswupper (wint_t wc);
+*/
+
+#define TST_FUNCTION iswupper
+
+#include "tsp_common.c"
+#include "dat_iswupper.c"
+
+TST_FUNC_ISW (UPPER, upper);
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswxdigit.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswxdigit.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_iswxdigit.c	(revision 2036)
@@ -0,0 +1,10 @@
+/*
+  ISWXDIGIT: int iswxdigit (wint_t wc);
+*/
+
+#define TST_FUNCTION iswxdigit
+
+#include "tsp_common.c"
+#include "dat_iswxdigit.c"
+
+TST_FUNC_ISW (XDIGIT, xdigit);
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_mblen.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_mblen.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_mblen.c	(revision 2036)
@@ -0,0 +1,85 @@
+/*
+  MBLEN: int mblen (char *s, size_t n)
+*/
+
+#define TST_FUNCTION mblen
+
+#include "tsp_common.c"
+#include "dat_mblen.c"
+
+int
+tst_mblen (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (int);
+  char s_flg;
+  const char *s_in;
+  size_t n;
+
+  TST_DO_TEST (mblen)
+  {
+    TST_HEAD_LOCALE (mblen, S_MBLEN);
+    TST_DO_REC (mblen)
+    {
+      TST_GET_ERRET (mblen);
+      s_flg = TST_INPUT (mblen).s_flg;
+      s_in = TST_INPUT (mblen).s;
+      n = TST_INPUT (mblen).n;
+
+      if (s_flg == 0)
+	{
+	  s_in = NULL;
+	}
+
+      if (n == USE_MBCURMAX)
+	{
+	  n = MB_CUR_MAX;
+	}
+
+      TST_CLEAR_ERRNO;
+      ret = mblen (s_in, n);
+      TST_SAVE_ERRNO;
+
+      TST_IF_RETURN (S_MBLEN)
+      {
+	if (s_in == NULL)
+	  {			/* state dependency */
+	    if (ret_exp == +1)
+	      {			/* state-dependent  */
+		if (ret != 0)
+		  {
+		    /* non-zero: state-dependent encoding */
+		    Result (C_SUCCESS, S_MBLEN, CASE_3, MS_PASSED);
+		  }
+		else
+		  {
+		    err_count++;
+		    Result (C_FAILURE, S_MBLEN, CASE_3,
+			    "should be state-dependent encoding, "
+			    "but the return value shows it is"
+			    " state-independent");
+		  }
+	      }
+
+	    if (ret_exp == 0)
+	      {			/* state-independent */
+		if (ret == 0)
+		  {
+		    /* non-zero: state-dependent encoding */
+		    Result (C_SUCCESS, S_MBLEN, CASE_3, MS_PASSED);
+		  }
+		else
+		  {
+		    err_count++;
+		    Result (C_FAILURE, S_MBLEN, CASE_3,
+			    "should be state-independent encoding, "
+			    "but the return value shows it is"
+			    " state-dependent");
+		  }
+	      }
+	  }
+      }
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_mbrlen.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_mbrlen.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_mbrlen.c	(revision 2036)
@@ -0,0 +1,82 @@
+/*
+  MBRLEN: size_t mbrlen (char *s, size_t n, mbstate_t *ps)
+*/
+
+#define TST_FUNCTION mbrlen
+
+#include "tsp_common.c"
+#include "dat_mbrlen.c"
+
+
+int
+tst_mbrlen (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (size_t);
+  char s_flg;
+  const char *s_in;
+  size_t n;
+  char t_flg;
+  char t_ini;
+  static mbstate_t s = { 0 };
+  mbstate_t *ps;
+
+  TST_DO_TEST (mbrlen)
+  {
+    TST_HEAD_LOCALE (mbrlen, S_MBRLEN);
+    TST_DO_REC (mbrlen)
+    {
+      if (mbrlen (NULL, 0, &s) != 0)
+	{
+	  err_count++;
+	  Result (C_FAILURE, S_MBRLEN, CASE_3,
+		  "Initialization (external mbstate object) failed "
+		  "- skipped this test case.");
+	  continue;
+	}
+
+      TST_DO_SEQ (MBRLEN_SEQNUM)
+      {
+	TST_GET_ERRET_SEQ (mbrlen);
+	s_flg = TST_INPUT_SEQ (mbrlen).s_flg;
+	s_in = TST_INPUT_SEQ (mbrlen).s;
+	n = TST_INPUT_SEQ (mbrlen).n;
+	t_flg = TST_INPUT_SEQ (mbrlen).t_flg;
+	t_ini = TST_INPUT_SEQ (mbrlen).t_init;
+	if (s_flg == 0)
+	  {
+	    s_in = NULL;
+	  }
+
+	if (n == USE_MBCURMAX)	/* rewrite tst_mblen() like this */
+	  {
+	    n = MB_CUR_MAX;
+	  }
+
+	ps = (t_flg == 0) ? NULL : &s;
+
+	if (t_ini != 0)
+	  {
+	    memset (&s, 0, sizeof (s));
+	    mbrlen (NULL, 0, NULL);
+	  }
+
+	TST_CLEAR_ERRNO;
+	ret = mbrlen (s_in, n, ps);
+	TST_SAVE_ERRNO;
+
+	if (debug_flg)
+	  {
+	    fprintf (stdout, "mbrlen() [ %s : %d : %d ] ret = %zd\n",
+		     locale, rec + 1, seq_num + 1, ret);
+	    fprintf (stdout, "			   errno = %d\n", errno_save);
+	  }
+
+	TST_IF_RETURN (S_MBRLEN)
+	{
+	};
+      }
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_mbrtowc.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_mbrtowc.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_mbrtowc.c	(revision 2036)
@@ -0,0 +1,103 @@
+/*
+  MBRTOWC: size_t mbrtowc (wchar_t *pwc, const char *s, size_t n,
+			   mbstate_t *ps)
+*/
+
+#define TST_FUNCTION mbrtowc
+
+#include "tsp_common.c"
+#include "dat_mbrtowc.c"
+
+
+int
+tst_mbrtowc (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (size_t);
+  char w_flg, s_flg;
+  char *s;
+  size_t n;
+  char t_flg, t_ini;
+  static mbstate_t t = { 0 };
+  mbstate_t *pt;
+  wchar_t wc, *pwc, wc_ex;
+
+  TST_DO_TEST (mbrtowc)
+  {
+    TST_HEAD_LOCALE (mbrtowc, S_MBRTOWC);
+    TST_DO_REC (mbrtowc)
+    {
+      if (mbrtowc (NULL, "", 0, &t) != 0)
+	{
+	  err_count++;
+	  Result (C_FAILURE, S_MBRTOWC, CASE_3,
+		  "Initialization failed - skipping this test case.");
+	  continue;
+	}
+
+      TST_DO_SEQ (MBRTOWC_SEQNUM)
+      {
+	TST_GET_ERRET_SEQ (mbrtowc);
+	w_flg = TST_INPUT_SEQ (mbrtowc).w_flg;
+	s_flg = TST_INPUT_SEQ (mbrtowc).s_flg;
+	s = TST_INPUT_SEQ (mbrtowc).s;
+	n = TST_INPUT_SEQ (mbrtowc).n;
+	t_flg = TST_INPUT_SEQ (mbrtowc).t_flg;
+	t_ini = TST_INPUT_SEQ (mbrtowc).t_init;
+	pwc = (w_flg == 0) ? NULL : &wc;
+
+	if (s_flg == 0)
+	  {
+	    s = NULL;
+	  }
+
+	if (n == USE_MBCURMAX)
+	  {
+	    n = MB_CUR_MAX;
+	  }
+
+	pt = (t_flg == 0) ? NULL : &t;
+#if 0
+	if (t_ini != 0)
+	  {
+	    memset (&t, 0, sizeof (t));
+	  }
+#endif
+	TST_CLEAR_ERRNO;
+	ret = mbrtowc (pwc, s, n, pt);
+	TST_SAVE_ERRNO;
+
+	if (debug_flg)
+	  {
+	    fprintf (stdout, "mbrtowc() [ %s : %d : %d ] ret = %zd\n",
+		     locale, rec + 1, seq_num + 1, ret);
+	    fprintf (stdout, "			    errno = %hd\n",
+		     errno_save);
+	  }
+
+	TST_IF_RETURN (S_MBRTOWC)
+	{
+	};
+
+	if (pwc == NULL || s == NULL || ret == (size_t) - 1
+	    || ret == (size_t) - 2)
+	  {
+	    continue;
+	  }
+
+	wc_ex = TST_EXPECT_SEQ (mbrtowc).wc;
+	if (wc_ex == wc)
+	  {
+	    Result (C_SUCCESS, S_MBRTOWC, CASE_4, MS_PASSED);
+	  }
+	else
+	  {
+	    err_count++;
+	    Result (C_FAILURE, S_MBRTOWC, CASE_4,
+		    "converted wc is different from an expected wc");
+	  }
+      }
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_mbsrtowcs.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_mbsrtowcs.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_mbsrtowcs.c	(revision 2036)
@@ -0,0 +1,109 @@
+/*
+  MBSRTOWCS: size_t mbsrtowcs (wchar_t *ws, const char **s, size_t n,
+			       mbstate_t *ps)
+*/
+
+#define TST_FUNCTION mbsrtowcs
+
+#include "tsp_common.c"
+#include "dat_mbsrtowcs.c"
+
+int
+tst_mbsrtowcs (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (size_t);
+  char w_flg;
+  const char *s, *p;
+  size_t n;
+  char t_flg, t_ini;
+  static mbstate_t t = { 0 };
+  mbstate_t *pt;
+  wchar_t ws[WCSSIZE], *ws_ex, *wp;
+  int err, i;
+
+  TST_DO_TEST (mbsrtowcs)
+  {
+    TST_HEAD_LOCALE (mbsrtowcs, S_MBSRTOWCS);
+    TST_DO_REC (mbsrtowcs)
+    {
+      s = "";
+      if (mbsrtowcs (NULL, &s, 0, &t) != 0)
+	{
+	  err_count++;
+	  Result (C_FAILURE, S_MBSRTOWCS, CASE_3,
+		  "Initialization failed - skipping this test case.");
+	  continue;
+	}
+
+      TST_DO_SEQ (MBSRTOWCS_SEQNUM)
+      {
+	TST_GET_ERRET_SEQ (mbsrtowcs);
+	w_flg = TST_INPUT_SEQ (mbsrtowcs).w_flg;
+	p = s = TST_INPUT_SEQ (mbsrtowcs).s;
+	n = TST_INPUT_SEQ (mbsrtowcs).n;
+	t_flg = TST_INPUT_SEQ (mbsrtowcs).t_flg;
+	t_ini = TST_INPUT_SEQ (mbsrtowcs).t_init;
+	wp = (w_flg == 0) ? NULL : ws;
+
+	if (n == USE_MBCURMAX)
+	  {
+	    n = MB_CUR_MAX;
+	  }
+
+	pt = (t_flg == 0) ? NULL : &t;
+
+	if (t_ini != 0)
+	  {
+	    memset (&t, 0, sizeof (t));
+	  }
+
+	TST_CLEAR_ERRNO;
+	ret = mbsrtowcs (wp, &p, n, pt);
+	TST_SAVE_ERRNO;
+
+	if (debug_flg)
+	  {
+	    fprintf (stderr, "mbsrtowcs: [ %d ] : ret = %zd\n", rec + 1, ret);
+	  }
+
+	TST_IF_RETURN (S_MBSRTOWCS)
+	{
+	};
+
+	if (wp == NULL || ret == (size_t) - 1 || ret == (size_t) - 2)
+	  {
+	    continue;
+	  }
+
+	ws_ex = TST_EXPECT_SEQ (mbsrtowcs).ws;
+	for (err = 0, i = 0; i < ret; i++)
+	  {
+	    if (debug_flg)
+	      {
+		fprintf (stderr,
+			 "mbsrtowcs: ws[%d] => 0x%lx : 0x%lx <= ws_ex[%d]\n",
+			 i, (unsigned long int) ws[i],
+			 (unsigned long int) ws_ex[i], i);
+	      }
+
+	    if (ws[i] != ws_ex[i])
+	      {
+		err++;
+		err_count++;
+		Result (C_FAILURE, S_MBSRTOWCS, CASE_4,
+			"the converted wc string has "
+			"different value from an expected string");
+		break;
+	      }
+	  }
+
+	if (!err)
+	  {
+	    Result (C_SUCCESS, S_MBSRTOWCS, CASE_4, MS_PASSED);
+	  }
+      }
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_mbstowcs.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_mbstowcs.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_mbstowcs.c	(revision 2036)
@@ -0,0 +1,98 @@
+/*
+  MBSTOWCS: size_t mbstowcs (wchar_t *ws, char *s, size_t n)
+*/
+
+#define TST_FUNCTION mbstowcs
+
+#include "tsp_common.c"
+#include "dat_mbstowcs.c"
+
+int
+tst_mbstowcs (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (size_t);
+  char w_flg, s_flg;
+  const char *s;
+  size_t n;
+  wchar_t ws[WCSSIZE], *ws_ex, *wp;
+  int err, i;
+
+  TST_DO_TEST (mbstowcs)
+  {
+    TST_HEAD_LOCALE (mbstowcs, S_MBSTOWCS);
+    TST_DO_REC (mbstowcs)
+    {
+      if (mbstowcs (NULL, "", 0) != 0)
+	{
+	  err_count++;
+	  Result (C_FAILURE, S_MBSTOWCS, CASE_3,
+		  "Initialization failed - skipping this test case.");
+	  continue;
+	}
+
+      TST_DO_SEQ (MBSTOWCS_SEQNUM)
+      {
+	TST_GET_ERRET_SEQ (mbstowcs);
+	w_flg = TST_INPUT_SEQ (mbstowcs).w_flg;
+	s_flg = TST_INPUT_SEQ (mbstowcs).s_flg;
+	n = TST_INPUT_SEQ (mbstowcs).n;
+
+	if (s_flg == 0)
+	  s = NULL;
+	else
+	  s = TST_INPUT_SEQ (mbstowcs).s;
+
+
+	wp = (wchar_t *) ((w_flg == 0) ? NULL : ws);
+
+	TST_CLEAR_ERRNO;
+	ret = mbstowcs (wp, s, n);
+	TST_SAVE_ERRNO;
+
+	if (debug_flg)
+	  {
+	    fprintf (stderr, "mbstowcs: ret = %zd\n", ret);
+	  }
+
+	TST_IF_RETURN (S_MBSTOWCS)
+	{
+	};
+
+	if (s == NULL || wp == NULL || ret == (size_t) - 1)
+	  {
+	    continue;
+	  }
+
+	ws_ex = TST_EXPECT_SEQ (mbstowcs).ws;
+
+	for (err = 0, i = 0; i < ret; i++)
+	  {
+	    if (debug_flg)
+	      {
+		fprintf (stderr,
+			 "mbstowcs: ws[%d] => 0x%lx : 0x%lx <= ws_ex[%d]\n",
+			 i, (unsigned long int) ws[i],
+			 (unsigned long int) ws_ex[i], i);
+	      }
+
+	    if (ws[i] != ws_ex[i])
+	      {
+		err++;
+		err_count++;
+		Result (C_FAILURE, S_MBSTOWCS, CASE_4,
+			"the converted wc string has "
+			"different value from an expected string");
+		break;
+	      }
+	  }
+
+	if (!err)
+	  {
+	    Result (C_SUCCESS, S_MBSTOWCS, CASE_4, MS_PASSED);
+	  }
+      }
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_mbtowc.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_mbtowc.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_mbtowc.c	(revision 2036)
@@ -0,0 +1,130 @@
+/*
+  MBTOWC: int mbtowc (wchar_t *wc, char *s, size_t n)
+*/
+
+#define TST_FUNCTION mbtowc
+
+#include "tsp_common.c"
+#include "dat_mbtowc.c"
+
+
+int
+tst_mbtowc (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (int);
+  char w_flg, s_flg;
+  const char *s_in;
+  size_t n;
+  wchar_t wc, wc_ex, *wp;
+
+  TST_DO_TEST (mbtowc)
+  {
+    TST_HEAD_LOCALE (mbtowc, S_MBTOWC);
+    TST_DO_REC (mbtowc)
+    {
+      if (mbstowcs (NULL, "", 0) != 0)
+	{
+	  err_count++;
+	  Result (C_FAILURE, S_MBSTOWCS, CASE_3,
+		  "Initialization failed - skipping this test case.");
+	  continue;
+	}
+
+      TST_DO_SEQ (MBTOWC_SEQNUM)
+      {
+	TST_GET_ERRET_SEQ (mbtowc);
+	w_flg = TST_INPUT_SEQ (mbtowc).w_flg;
+	s_flg = TST_INPUT_SEQ (mbtowc).s_flg;
+	n = TST_INPUT_SEQ (mbtowc).n;
+
+	if (n == USE_MBCURMAX)
+	  {
+	    n = MB_CUR_MAX;
+	  }
+
+	if (s_flg == 0)
+	  s_in = NULL;
+	else
+	  s_in = TST_INPUT_SEQ (mbtowc).s;
+
+	wp = (wchar_t *) ((w_flg == 0) ? NULL : &wc);
+
+	/* XXX Clear the internal state.  We should probably have
+	   a flag for this.  */
+	mbtowc (NULL, NULL, 0);
+
+	TST_CLEAR_ERRNO;
+	ret = mbtowc (wp, s_in, n);
+	TST_SAVE_ERRNO;
+
+	if (debug_flg)
+	  {
+	    fprintf (stdout, "mbtowc() [ %s : %d ] ret = %d\n", locale,
+		     rec + 1, ret);
+	    fprintf (stdout, "			   errno      = %d\n",
+		     errno_save);
+	  }
+
+	TST_IF_RETURN (S_MBTOWC)
+	{
+	  if (s_in == NULL)
+	    {			/* state dependency */
+	      if (ret_exp == +1)
+		{		/* state-dependent  */
+		  if (ret != 0)
+		    {
+		      /* Non-zero: state-dependent encoding.  */
+		      Result (C_SUCCESS, S_MBTOWC, CASE_3, MS_PASSED);
+		    }
+		  else
+		    {
+		      err_count++;
+		      Result (C_FAILURE, S_MBTOWC, CASE_3,
+			      "should be state-dependent encoding, "
+			      "but a return value shows it is "
+			      "state-independent");
+		    }
+		}
+
+	      if (ret_exp == 0)
+		{		/* state-independent */
+		  if (ret == 0)
+		    {
+		      /* Non-zero: state-dependent encoding.  */
+		      Result (C_SUCCESS, S_MBTOWC, CASE_3, MS_PASSED);
+		    }
+		  else
+		    {
+		      err_count++;
+		      Result (C_FAILURE, S_MBTOWC, CASE_3,
+			      "should be state-independent encoding, "
+			      "but a return value shows it is "
+			      "state-dependent");
+		    }
+		}
+	    }
+	}
+
+	if ((wp == NULL || s_in == NULL || s_in[0] == 0) || ret <= 0)
+	  {
+	    continue;
+	  }
+
+	wc_ex = TST_EXPECT_SEQ (mbtowc).wc;
+
+	if (wc_ex == wc)
+	  {
+	    Result (C_SUCCESS, S_MBTOWC, CASE_4, MS_PASSED);
+	  }
+	else
+	  {
+	    err_count++;
+	    Result (C_FAILURE, S_MBTOWC, CASE_4,
+		    "converted wc is different from an expected wc");
+	  }
+      }
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_strcoll.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_strcoll.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_strcoll.c	(revision 2036)
@@ -0,0 +1,87 @@
+/*
+  STRCOLL: int strcoll (const char *s1, const char *s2)
+*/
+
+#define TST_FUNCTION strcoll
+
+#include "tsp_common.c"
+#include "dat_strcoll.c"
+
+int
+tst_strcoll (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (int);
+  const char *s1, *s2;
+
+  TST_DO_TEST (strcoll)
+  {
+    TST_HEAD_LOCALE (strcoll, S_STRCOLL);
+    TST_DO_REC (strcoll)
+    {
+      TST_GET_ERRET (strcoll);
+      s1 = TST_INPUT (strcoll).s1;
+      s2 = TST_INPUT (strcoll).s2;
+
+      TST_CLEAR_ERRNO;
+      ret = strcoll (s1, s2);
+      TST_SAVE_ERRNO;
+
+      if (debug_flg)
+	{
+	  fprintf (stdout, "strcoll() [ %s : %d ] ret = %d\n", locale,
+		   rec + 1, ret);
+	  fprintf (stdout, "			    errno = %d\n",
+		   errno_save);
+	  fprintf (stdout, "			    LC_COLLATE = %s\n",
+		   (setlocale (LC_COLLATE, NULL)) ? setlocale (LC_COLLATE,
+							       NULL) : "");
+	}
+
+      TST_IF_RETURN (S_STRCOLL)
+      {
+	if (ret_exp == +1)
+	  {
+	    if (ret > 0)
+	      {
+		Result (C_SUCCESS, S_STRCOLL, CASE_3, MS_PASSED);
+	      }
+	    else
+	      {
+		err_count++;
+		Result (C_FAILURE, S_STRCOLL, CASE_3,
+			"the return value should be greater than 0,"
+			" but is not ...");
+	      }
+	  }
+	else if (ret_exp == -1)
+	  {
+	    if (ret < 0)
+	      {
+		Result (C_SUCCESS, S_STRCOLL, CASE_3, MS_PASSED);
+	      }
+	    else
+	      {
+		err_count++;
+		Result (C_FAILURE, S_STRCOLL, CASE_3,
+			"the return value should less than 0, but not ...");
+	      }
+	  }
+	else if (ret_exp != 0)
+	  {
+	    if (debug_flg)
+	      {
+		fprintf (stderr, "*** Warning *** : tst_strcoll : "
+			 "(check the test data); should set ret_flg=1"
+			 " to check a return value");
+	      }
+
+	    warn_count++;
+	    Result (C_INVALID, S_WCSCHR, CASE_3, "(check the test data); "
+		    "should set ret_flg=1 to check a return value");
+	  }
+      }
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_strfmon.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_strfmon.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_strfmon.c	(revision 2036)
@@ -0,0 +1,74 @@
+/*
+  STRFMON: size_t strfmon (char *buf, size_t nbyte, const char *fmt, ...)
+*/
+
+#define TST_FUNCTION strfmon
+
+#include "tsp_common.c"
+#include "dat_strfmon.c"
+#include <monetary.h>
+
+int
+tst_strfmon (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (size_t);
+  char buf[MONSIZE], *mon;
+  size_t nbt;
+  char *fmt;
+  double val;
+
+  TST_DO_TEST (strfmon)
+  {
+    TST_HEAD_LOCALE (strfmon, S_STRFMON);
+    TST_DO_REC (strfmon)
+    {
+      TST_GET_ERRET (strfmon);
+      nbt = TST_INPUT (strfmon).nbytes;
+      fmt = TST_INPUT (strfmon).fmt;
+      val = TST_INPUT (strfmon).val;
+      memset (buf, 0, MONSIZE);
+      if (nbt > MONSIZE)
+	{
+	  err_count++;
+	  Result (C_FAILURE, S_STRFMON, CASE_3, "buffer too small in test");
+	  continue;
+	}
+
+      TST_CLEAR_ERRNO;
+      ret = strfmon (buf, nbt, fmt, val, val, val);
+      TST_SAVE_ERRNO;
+
+      if (debug_flg)		/* seems fprintf doesn't update the errno */
+	{
+	  fprintf (stdout, "strfmon() [ %s : %d ]\n", locale, rec + 1);
+	  fprintf (stdout, "	  : err = %d | %s\n", errno_save,
+		   strerror (errno));
+	  fprintf (stdout, "	  : ret = %zd; \t fmt = |%s|\n", ret, fmt);
+	  fprintf (stdout, "	  : buf = |%s|\n\n", buf);
+	}
+
+      TST_IF_RETURN (S_STRFMON)
+      {
+      };
+      if (errno != 0 || ret == -1)
+	{
+	  continue;
+	}
+
+      mon = TST_EXPECT (strfmon).mon;
+
+      if (!strcmp (buf, mon))
+	{
+	  Result (C_SUCCESS, S_STRFMON, CASE_3, MS_PASSED);
+	}
+      else
+	{
+	  err_count++;
+	  Result (C_FAILURE, S_STRFMON, CASE_3, "the formatted string is "
+		  "different from an expected result");
+	}
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_strxfrm.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_strxfrm.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_strxfrm.c	(revision 2036)
@@ -0,0 +1,136 @@
+/*
+  STRXFRM: size_t strxfrm (char *s1, const char *s2, size_t n)
+*/
+
+#define TST_FUNCTION strxfrm
+
+#include "tsp_common.c"
+#include "dat_strxfrm.c"
+
+
+int
+tst_strxfrm (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (size_t);
+  const char *org1, *org2;
+  char frm1[MBSSIZE], frm2[MBSSIZE];
+  size_t n1, n2;
+  int ret_coll, ret_cmp;
+
+  TST_DO_TEST (strxfrm)
+  {
+    TST_HEAD_LOCALE (strxfrm, S_STRXFRM);
+    TST_DO_REC (strxfrm)
+    {
+      TST_GET_ERRET (strxfrm);
+      org1 = TST_INPUT (strxfrm).org1;
+      org2 = TST_INPUT (strxfrm).org2;
+      n1 = TST_INPUT (strxfrm).n1;
+      n2 = TST_INPUT (strxfrm).n2;
+
+      if (n1 < 0 || sizeof (frm1) < n1 || sizeof (frm2) < n2)
+	{
+	  warn_count++;
+	  Result (C_IGNORED, S_STRXFRM, CASE_9,
+		  "input data n1 or n2 is invalid");
+	  continue;
+	}
+
+      /* An errno and a return value are checked
+	 only for 2nd strxfrm() call.
+	 A result of 1st call is used for comparing
+	 those 2 values by using strcmp().
+      */
+
+      /*-- First call --*/
+
+      TST_CLEAR_ERRNO;
+      ret = strxfrm (frm1, org1, n1);
+      TST_SAVE_ERRNO;
+
+      if (debug_flg)
+	{
+	  fprintf (stdout, "strxfrm() [ %s : %d ] ( 1st call )\n", locale,
+		   rec + 1);
+	  fprintf (stdout, "	  : err = %d | %s\n", errno_save,
+		   strerror (errno));
+	  fprintf (stdout, "	  : ret = %zu\n", ret);
+	  fprintf (stdout, "	  : org = %s\n", org1);
+	}
+
+      if (ret >= n1 || errno != 0)
+	{
+	  warn_count++;
+	  Result (C_INVALID, S_STRXFRM, CASE_8,
+		  "got an error in fist strxfrm() call");
+	  continue;
+	}
+
+      /*-- Second call --*/
+
+      TST_CLEAR_ERRNO;
+      ret = strxfrm (((n2 == 0) ? NULL : frm2), org2, n2);
+      TST_SAVE_ERRNO;
+
+      if (debug_flg)
+	{
+	  fprintf (stderr, "	  ..............( 2nd call )\n");
+	  fprintf (stdout, "	  : err = %d | %s\n", errno,
+		   strerror (errno));
+	  fprintf (stdout, "	  : ret = %zu\n", ret);
+	  fprintf (stdout, "	  : org = %s\n", org2);
+	}
+
+      TST_IF_RETURN (S_STRXFRM)
+      {
+      };
+
+      if (n2 == 0 || ret >= n2 || errno != 0)
+	{
+#if 0
+	  warn_count++;
+	  Result (C_IGNORED, S_STRXFRM, CASE_7, "did not get a result");
+#endif
+	  continue;
+	}
+
+      /*-- strcoll & strcmp --*/
+
+      TST_CLEAR_ERRNO;
+      /* Depends on strcoll() ... not good though ... */
+      ret_coll = strcoll (org1, org2);
+
+      if (errno != 0)
+	{
+	  /* bug * bug may get correct results ...	  */
+	  warn_count++;
+	  Result (C_INVALID, S_STRXFRM, CASE_6,
+		  "got an error in strcoll() call");
+	  continue;
+	}
+
+      ret_cmp = strcmp (frm1, frm2);
+
+      if ((ret_coll == 0 && ret_cmp == 0)
+	  || (ret_coll < 0 && ret_cmp < 0) || (ret_coll > 0 && ret_cmp > 0))
+	{
+	  Result (C_SUCCESS, S_STRXFRM, CASE_3,
+		  MS_PASSED "(depends on strcoll & strcmp)");
+	}
+      else
+	{
+	  err_count++;
+	  Result (C_FAILURE, S_STRXFRM, CASE_3,
+		  "results from strcoll & strcmp() do not match");
+	}
+
+      if (debug_flg)
+	{
+	  fprintf (stdout, ".......... strcoll = %d <-> %d = strcmp\n",
+		   ret_coll, ret_cmp);
+	}
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_swscanf.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_swscanf.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_swscanf.c	(revision 2036)
@@ -0,0 +1,137 @@
+/*
+  SWSCANF: int swscanf (const wchar_t *ws, const wchar_t *fmt, ...);
+*/
+
+#define TST_FUNCTION swscanf
+
+#include "tsp_common.c"
+#include "dat_swscanf.c"
+
+int
+tst_swscanf (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (int);
+  wchar_t *ws;
+  wchar_t *fmt;
+  int val_int1;
+  unsigned val_int2;
+  float val_flt;
+  char val_c;
+  char val_s[MBSSIZE * 3];
+  wchar_t val_S[WCSSIZE * 3], *exp_S;
+  int i;
+
+  TST_DO_TEST (swscanf)
+  {
+    TST_HEAD_LOCALE (swscanf, S_SWSCANF);
+    TST_DO_REC (swscanf)
+    {
+      TST_GET_ERRET (swscanf);
+      ws = TST_INPUT (swscanf).ws;
+      fmt = TST_INPUT (swscanf).fmt;
+      val_int1 = val_int2 = val_flt = val_c = 0;
+      memset (val_s, 0, sizeof (val_s));
+      memset (val_S, 0, sizeof (val_S));
+
+      TST_CLEAR_ERRNO;
+
+      if (TST_INPUT (swscanf).wch)
+	{
+	  ret = swscanf (ws, fmt, val_S);
+	}
+      else
+	{
+	  ret =
+	    swscanf (ws, fmt, &val_int1, &val_int2, &val_flt, &val_c, val_s);
+	}
+
+      TST_SAVE_ERRNO;
+
+      if (debug_flg)
+	{			/* seems fprintf doesn't update errno */
+	  fprintf (stdout, "swscanf() [ %s : %d ] ret = %d\n", locale,
+		   rec + 1, ret);
+	  fprintf (stdout, "			    errno   = %d\n",
+		   errno_save);
+	  fprintf (stdout, "			    collate = %s\n",
+		   (setlocale (LC_COLLATE, NULL)) ? setlocale (LC_COLLATE,
+							       NULL) : "");
+
+	  if (TST_INPUT (swscanf).wch)
+	    {
+	      fprintf (stdout, "			val_S[ 0 ] = 0x%lx\n",
+		       (unsigned long int) val_S[0]);
+	    }
+	  else
+	    {
+	      fprintf (stdout, "			val_int1   = %d\n",
+		       val_int1);
+	      fprintf (stdout, "			val_int2   = %d\n",
+		       val_int2);
+	      fprintf (stdout, "			val_flt	   = %f\n",
+		       val_flt);
+	      fprintf (stdout, "			val_c	   = %c\n",
+		       val_c);
+	      fprintf (stdout, "			val_s	   = %s\n",
+		       val_s);
+	    }
+	}
+
+      TST_IF_RETURN (S_SWSCANF)
+      {
+      };
+
+      if (errno == 0 && TST_INPUT (swscanf).wch)
+	{
+	  for (exp_S = TST_EXPECT (swscanf).val_S, i = 0; i < WCSSIZE * 3;
+	       i++)
+	    {
+	      if (val_S[i] == L'\0' || exp_S[i] == L'\0')
+		{
+		  if (val_S[i] != exp_S[i] && TST_INPUT (swscanf).wch == 'C')
+		    {
+		      err_count++;
+		      Result (C_FAILURE, S_SWSCANF, CASE_4,
+			      "the converted wide-char string is different"
+			      " from an expected value.");
+		    }
+		  break;
+		}
+
+	      if (val_S[i] != exp_S[i])
+		{
+		  err_count++;
+		  Result (C_FAILURE, S_SWSCANF, CASE_4,
+			  "the converted wide-char string is different from"
+			  " an expected value.");
+		  break;
+		}
+	      else
+		{
+		  Result (C_SUCCESS, S_SWSCANF, CASE_4, MS_PASSED);
+		}
+	    }
+	}
+
+      if (errno == 0 && !TST_INPUT (swscanf).wch)
+	{
+	  if (val_int1 != TST_EXPECT (swscanf).val_int ||
+	      val_int2 != TST_EXPECT (swscanf).val_uns ||
+	      val_flt != TST_EXPECT (swscanf).val_flt ||
+	      val_c != TST_EXPECT (swscanf).val_c ||
+	      strcmp (val_s, TST_EXPECT (swscanf).val_s))
+	    {
+	      err_count++;
+	      Result (C_FAILURE, S_SWSCANF, CASE_3,
+		      "the converted values are different from expected values.");
+	    }
+	  else
+	    {
+	      Result (C_SUCCESS, S_SWSCANF, CASE_3, MS_PASSED);
+	    }
+	}
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_towctrans.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_towctrans.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_towctrans.c	(revision 2036)
@@ -0,0 +1,82 @@
+/*
+  TOWCTRANS: wint_t towctrans (wint_t wc, wctrans_t desc);
+*/
+
+#define TST_FUNCTION towctrans
+
+#include "tsp_common.c"
+#include "dat_towctrans.c"
+
+
+int
+tst_towctrans (FILE *fp, int debug_flg)
+{
+  TST_DECL_VARS (wint_t);
+  wint_t wc;
+  const char *ts;
+#if SHOJI_IS_RIGHT
+  int dummy=0;
+#endif
+  wctrans_t wto;
+
+  TST_DO_TEST (towctrans)
+    {
+      TST_HEAD_LOCALE (towctrans, S_TOWCTRANS);
+      TST_DO_REC (towctrans)
+	{
+	  TST_GET_ERRET (towctrans);
+	  wc = TST_INPUT (towctrans).wc;
+	  ts = TST_INPUT (towctrans).ts;
+
+#if SHOJI_IS_RIGHT
+	  if ((wto = wctrans (ts)) == (wctrans_t) 0)
+	    {
+#if 0
+	      result (fp, C_IGNORED, S_TOWCTRANS, locale, rec+1, seq_num+1, 3,
+		      "Skip this data because the wctrans object is not invalid.");
+	      warn_count++;
+	      continue;
+#else
+	      wto = &dummy;	/* not good ... */
+#endif
+	      if (debug_flg)
+		{
+		  fprintf (stdout, "towctrans() ------ wctrans() returnd 0.\n");
+		}
+	    }
+#else
+	  wto = wctrans (ts);
+#endif
+
+	  TST_CLEAR_ERRNO;
+	  ret = towctrans (wc, wto);
+	  TST_SAVE_ERRNO;
+
+	  if (debug_flg)
+	    {
+	      fprintf (stdout, "towctrans() [ %s : %d ] ret = 0x%x\n",
+		       locale, rec+1, ret);
+	      fprintf (stdout, "		      errno = %d\n",
+		       errno_save);
+	    }
+
+	  TST_IF_RETURN (S_TOWCTRANS)
+	    {
+	      if (ret != 0)
+		{
+		  result (fp, C_SUCCESS, S_TOWCTRANS, locale, rec+1,
+			  seq_num+1, 3, MS_PASSED);
+		}
+	      else
+		{
+		  err_count++;
+		  result (fp, C_FAILURE, S_TOWCTRANS, locale, rec+1,
+			  seq_num+1, 3,
+			  "the function returned 0, but should be non-zero");
+		}
+	    }
+	}
+    }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_towlower.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_towlower.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_towlower.c	(revision 2036)
@@ -0,0 +1,11 @@
+/*
+  TOWLOWER: int towlower (wint_t wc);
+*/
+
+#define TST_FUNCTION towlower
+
+#include "tsp_common.c"
+#include "dat_towlower.c"
+
+
+TST_FUNC_TOW (LOWER, lower);
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_towupper.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_towupper.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_towupper.c	(revision 2036)
@@ -0,0 +1,10 @@
+/*
+  TOWUPPER: int towupper (wint_t wc);
+*/
+
+#define TST_FUNCTION towupper
+
+#include "tsp_common.c"
+#include "dat_towupper.c"
+
+TST_FUNC_TOW (UPPER, upper);
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_types.h
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_types.h	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_types.h	(revision 2036)
@@ -0,0 +1,729 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	tst_types.h
+ *
+ *	 Definitions of data types for each test function
+ */
+
+
+#ifndef TST_TYPES_H
+#define TST_TYPES_H
+
+#include <stdio.h>
+#include <wchar.h>
+#include <wctype.h>
+#include "tst_funcs.h"
+#include "tgn_funcdef.h"
+
+#define MBSSIZE		   24
+#define WCSSIZE		   12
+#define MONFMTSIZE	   16
+#define MONSIZE		   64
+#define USE_MBCURMAX	   99	/* well, but ... */
+#define TST_DBL_EPS	   2.22153e-16
+#define WCSTOK_SEQNUM	   3
+#define MBLEN_SEQNUM	   3
+#define MBTOWC_SEQNUM	   3
+#define MBSTOWCS_SEQNUM	   3
+#define WCTOMB_SEQNUM	   3
+#define WCSTOMBS_SEQNUM	   3
+#define MBRLEN_SEQNUM	   3
+#define MBRTOWC_SEQNUM	   3
+#define MBSRTOWCS_SEQNUM   3
+#define WCRTOMB_SEQNUM	   3
+#define WCSRTOMBS_SEQNUM   3
+
+/* Maximum numbers of test in one of the _loc arrays.  */
+#define MAX_LOC_TEST		300
+
+
+/*----------------------------------------------------------------------*/
+/*  FUNCTION								*/
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+  char *func_str;
+  int func_id;
+}
+TST_FID;
+
+typedef struct
+{
+  int func_id;
+  const char *locale;
+}
+TST_HEAD;
+
+typedef struct
+{
+  TST_HEAD *head;
+}
+TST_FUNCS;
+
+
+/*----------------------------------------------------------------------*/
+/*  ISW*: int isw* (wchar_t wc)						*/
+/*----------------------------------------------------------------------*/
+
+TST_ISW_STRUCT (ALNUM, alnum);
+TST_ISW_STRUCT (ALPHA, alpha);
+TST_ISW_STRUCT (CNTRL, cntrl);
+TST_ISW_STRUCT (DIGIT, digit);
+TST_ISW_STRUCT (GRAPH, graph);
+TST_ISW_STRUCT (LOWER, lower);
+TST_ISW_STRUCT (PRINT, print);
+TST_ISW_STRUCT (PUNCT, punct);
+TST_ISW_STRUCT (SPACE, space);
+TST_ISW_STRUCT (UPPER, upper);
+TST_ISW_STRUCT (XDIGIT, xdigit);
+
+typedef struct
+{
+  wint_t wc;
+  const char *ts;
+}
+TIN_ISWCTYPE_REC;
+
+typedef
+TEX_ERRET_REC (int)
+  TEX_ISWCTYPE_REC;
+TMD_RECHEAD (ISWCTYPE);
+
+
+/*----------------------------------------------------------------------*/
+/*  MBLEN: int mblen (const char *s, size_t n)				*/
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+  char s_flg;
+  char s[MBSSIZE];
+  size_t n;
+}
+TIN_MBLEN_REC;
+
+typedef TEX_ERRET_REC (int) TEX_MBLEN_REC;
+TMD_RECHEAD (MBLEN);
+
+
+/*----------------------------------------------------------------------*/
+/*  MBRLEN: size_t mbrlen (const char *s, size_t n, mbstate_t *ps)	*/
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+  struct
+  {
+    int s_flg;
+    char s[MBSSIZE];
+    size_t n;
+    int t_flg;
+    int t_init;
+  }
+  seq[WCSTOK_SEQNUM];
+}
+TIN_MBRLEN_REC;
+
+typedef TEX_ERRET_REC_SEQ (size_t, MBRLEN_SEQNUM) TEX_MBRLEN_REC;
+TMD_RECHEAD (MBRLEN);
+
+
+/*----------------------------------------------------------------------*/
+/*  MBRTOWC: size_t mbrtowc (wchar_t *pwc, const char *s, size_t n,	*/
+/*			     mbstate_t *ps)				*/
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+  struct
+  {
+    int w_flg;
+    int s_flg;
+    char s[MBSSIZE];
+    size_t n;
+    int t_flg;
+    int t_init;
+  }
+  seq[MBRTOWC_SEQNUM];
+}
+TIN_MBRTOWC_REC;
+
+typedef struct
+{
+  struct
+  {
+    TMD_ERRET (size_t);
+    wchar_t wc;
+  }
+  seq[MBRTOWC_SEQNUM];
+}
+TEX_MBRTOWC_REC;
+
+TMD_RECHEAD (MBRTOWC);
+
+
+/*----------------------------------------------------------------------*/
+/*  MBSRTOWCS: size_t mbsrtowcs (wchar_t *ws, const char **s, size_t n, */
+/*				 mbstate_t *ps )			*/
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+  struct
+  {
+    int w_flg;
+    char s[MBSSIZE];
+    size_t n;
+    int t_flg;
+    int t_init;
+  }
+  seq[MBSRTOWCS_SEQNUM];
+}
+TIN_MBSRTOWCS_REC;
+
+typedef struct
+{
+  struct
+  {
+    TMD_ERRET (size_t);
+    wchar_t ws[WCSSIZE];
+  }
+  seq[MBSRTOWCS_SEQNUM];
+}
+TEX_MBSRTOWCS_REC;
+
+TMD_RECHEAD (MBSRTOWCS);
+
+
+/*----------------------------------------------------------------------*/
+/*  MBSTOWCS: size_t mbstowcs (wchar_t *ws, const char *s, size_t n)	*/
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+  struct
+  {
+    int w_flg;
+    int s_flg;
+    const char *s;
+    size_t n;
+  }
+  seq[MBSTOWCS_SEQNUM];
+}
+TIN_MBSTOWCS_REC;
+
+typedef TEX_MBSRTOWCS_REC TEX_MBSTOWCS_REC;
+/* MBSRTOWCS_SEQNUM == MBSTOWCS_SEQNUM */
+TMD_RECHEAD (MBSTOWCS);
+
+
+/*----------------------------------------------------------------------*/
+/*  MBTOWC: int mbtowc (wchar_t *wc, const char *s, size_t n)		*/
+/*----------------------------------------------------------------------*/
+
+typedef TIN_MBSTOWCS_REC TIN_MBTOWC_REC;
+/* MBTOWC_SEQNUM == MBSTOWCS_SEQNUM */
+
+typedef struct
+{
+  struct
+  {
+    TMD_ERRET (int);
+    wchar_t wc;
+  }
+  seq[MBTOWC_SEQNUM];
+}
+TEX_MBTOWC_REC;
+
+TMD_RECHEAD (MBTOWC);
+
+
+/*----------------------------------------------------------------------*/
+/*  STRCOLL: int strcoll (const char *s1, const char *s2)		*/
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+  char s1[MBSSIZE];
+  char s2[MBSSIZE];
+}
+TIN_STRCOLL_REC;
+
+typedef TEX_ERRET_REC (int) TEX_STRCOLL_REC;
+TMD_RECHEAD (STRCOLL);
+
+
+/*----------------------------------------------------------------------*/
+/*  STRFMON: size_t strfmon (char *buf, size_t nbytes,			*/
+/*			     const char *fmt, ... )			*/
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+  int nbytes;
+  char fmt[MONFMTSIZE];
+  double val;
+}
+TIN_STRFMON_REC;
+
+typedef struct
+{
+  TMD_ERRET (size_t);
+  char mon[MONSIZE];
+}
+TEX_STRFMON_REC;
+
+TMD_RECHEAD (STRFMON);
+
+
+/*----------------------------------------------------------------------*/
+/*  STRXFRM: size_t strxfrm (char *s1, const char *s2, size_t n)	*/
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+  char org1[MBSSIZE];
+  char org2[MBSSIZE];
+  size_t n1, n2;
+}
+TIN_STRXFRM_REC;
+
+typedef TEX_ERRET_REC (size_t) TEX_STRXFRM_REC;	/* only for org2[] */
+TMD_RECHEAD (STRXFRM);
+
+
+/*----------------------------------------------------------------------*/
+/*  SWSCANF: int swscanf (const wchar_t *ws, const wchar_t *fmt, ...)	*/
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+  wchar_t ws[WCSSIZE * 3];
+  wchar_t fmt[WCSSIZE * 3];
+  int wch;
+}
+TIN_SWSCANF_REC;
+
+typedef struct
+{
+  TMD_ERRET (int);
+  int val_int;		/* %d */
+  unsigned val_uns;	/* %u */
+  float val_flt;		/* %f */
+  int val_c;		/* %c */
+  char val_s[MBSSIZE * 2];	/* %s */
+  wchar_t val_S[WCSSIZE * 2];	/* %lc, %ls, %C, %S */
+}
+TEX_SWSCANF_REC;
+
+TMD_RECHEAD (SWSCANF);
+
+
+/*----------------------------------------------------------------------*/
+/*  TOWCTRANS: wint_t towctrans (wint_t wc, wctrans_t desc)		*/
+/*----------------------------------------------------------------------*/
+
+typedef TIN_ISWCTYPE_REC TIN_TOWCTRANS_REC;
+typedef TEX_ERRET_REC (wint_t) TEX_TOWCTRANS_REC;
+TMD_RECHEAD (TOWCTRANS);
+
+
+/*----------------------------------------------------------------------*/
+/*  TOW*ER: wint_t tow*er (wint_t wc)					*/
+/*----------------------------------------------------------------------*/
+
+TST_TOW_STRUCT (LOWER, lower);
+TST_TOW_STRUCT (UPPER, upper);
+
+
+/*----------------------------------------------------------------------*/
+/*  WCRTOMB: wchar_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps)	*/
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+  int s_flg;
+  wchar_t wc;
+  int t_flg;
+  int t_init;
+}
+TIN_WCRTOMB_REC;
+
+typedef struct
+{
+  TMD_ERRET (wchar_t);
+  char s[MBSSIZE];
+}
+TEX_WCRTOMB_REC;
+
+TMD_RECHEAD (WCRTOMB);
+
+
+/*----------------------------------------------------------------------*/
+/*  WCSCAT: wchar_t *wcscat (wchar_t *ws1, wchar_t *ws2)		*/
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+  wchar_t ws1[WCSSIZE];
+  wchar_t ws2[WCSSIZE];
+}
+TIN_WCSCAT_REC;
+
+typedef struct
+{
+  TMD_ERRET (wchar_t *);
+  wchar_t ws[WCSSIZE];
+}
+TEX_WCSCAT_REC;
+
+TMD_RECHEAD (WCSCAT);
+
+
+/*----------------------------------------------------------------------*/
+/*  WCSCHR: wchar_t *wcschr (wchar_t *ws, wchar_t wc);			*/
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+  wchar_t ws[WCSSIZE];
+  wchar_t wc;
+}
+TIN_WCSCHR_REC;
+
+typedef TEX_ERRET_REC (wchar_t *) TEX_WCSCHR_REC;
+TMD_RECHEAD (WCSCHR);
+
+
+/*----------------------------------------------------------------------*/
+/*  WCSCMP: int wcscmp (const wchar_t *ws1, const wchar_t *ws2)		*/
+/*----------------------------------------------------------------------*/
+
+typedef TIN_WCSCAT_REC TIN_WCSCMP_REC;
+typedef TEX_ERRET_REC (int) TEX_WCSCMP_REC;
+TMD_RECHEAD (WCSCMP);
+
+
+/*----------------------------------------------------------------------*/
+/*  WCSCOLL: int wcscoll (const wchar_t *ws1, const wchar_t *ws2)	*/
+/*----------------------------------------------------------------------*/
+
+typedef TIN_WCSCMP_REC TIN_WCSCOLL_REC;
+typedef struct
+{
+  TMD_ERRET (int);
+  int cmp_flg;
+}
+TEX_WCSCOLL_REC;
+TMD_RECHEAD (WCSCOLL);
+
+
+/*----------------------------------------------------------------------*/
+/*  WCSCPY: wchar_t *wcscpy (wchar_t *ws1, const wchar_t *ws2)		*/
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+  wchar_t ws[WCSSIZE];	/* ws2: original string */
+}
+TIN_WCSCPY_REC;
+
+typedef TEX_WCSCAT_REC TEX_WCSCPY_REC;
+TMD_RECHEAD (WCSCPY);
+
+
+/*----------------------------------------------------------------------*/
+/*  WCSCSPN: size_t wcscspn (const wchar_t *ws1, const wchar_t *ws2)	*/
+/*----------------------------------------------------------------------*/
+
+typedef TIN_WCSCAT_REC TIN_WCSCSPN_REC;
+typedef TEX_ERRET_REC (size_t) TEX_WCSCSPN_REC;
+TMD_RECHEAD (WCSCSPN);
+
+
+/*----------------------------------------------------------------------*/
+/*  WCSLEN: size_t wcslen (const wchar_t *ws)				*/
+/*----------------------------------------------------------------------*/
+
+typedef TIN_WCSCPY_REC TIN_WCSLEN_REC;
+typedef TEX_ERRET_REC (size_t) TEX_WCSLEN_REC;
+TMD_RECHEAD (WCSLEN);
+
+
+/*----------------------------------------------------------------------*/
+/*  WCSNCAT: wchar_t *wcsncat (wchar_t *ws1, const wchar_t *ws2,	*/
+/*			       size_t n)				*/
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+  wchar_t ws1[WCSSIZE];
+  wchar_t ws2[WCSSIZE];
+  size_t n;
+}
+TIN_WCSNCAT_REC;
+
+typedef TEX_WCSCAT_REC TEX_WCSNCAT_REC;
+TMD_RECHEAD (WCSNCAT);
+
+
+/*----------------------------------------------------------------------*/
+/*  WCSNCMP: int *wcsncmp (const wchar_t *ws1, const wchar_t *ws2,	*/
+/*			   size_t n)					*/
+/*----------------------------------------------------------------------*/
+
+typedef TIN_WCSNCAT_REC TIN_WCSNCMP_REC;
+typedef TEX_ERRET_REC (int) TEX_WCSNCMP_REC;
+TMD_RECHEAD (WCSNCMP);
+
+
+/*----------------------------------------------------------------------*/
+/*  WCSNCPY: wchar_t *wcsncpy (wchar_t *ws1, const wchar_t *ws2,	*/
+/*			       size_t n)				*/
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+  wchar_t ws[WCSSIZE];	/* ws2: original string */
+  size_t n;
+}
+TIN_WCSNCPY_REC;
+
+typedef TEX_WCSCPY_REC TEX_WCSNCPY_REC;
+TMD_RECHEAD (WCSNCPY);
+
+
+/*----------------------------------------------------------------------*/
+/*  WCSPBRK: wchar_t *wcspbrk (const wchar_t *ws1, const wchar_t *ws2)	*/
+/*----------------------------------------------------------------------*/
+
+typedef TIN_WCSCSPN_REC TIN_WCSPBRK_REC;
+
+typedef struct
+{
+  TMD_ERRET (wchar_t *);
+  wchar_t wc;
+}
+TEX_WCSPBRK_REC;
+
+TMD_RECHEAD (WCSPBRK);
+
+
+/*----------------------------------------------------------------------*/
+/*  WCSRTOMBS: size_t wcsrtombs (char *s, const wchar_t **ws, size_t n, */
+/*				 mbstate_t *ps)				*/
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+  int s_flg;
+  int w_flg;		/* don't need this */
+  wchar_t ws[WCSSIZE];
+  size_t n;
+  int t_flg;
+  int t_init;
+}
+TIN_WCSRTOMBS_REC;
+
+typedef struct
+{
+  TMD_ERRET (size_t);
+  char s[MBSSIZE];
+}
+TEX_WCSRTOMBS_REC;
+
+TMD_RECHEAD (WCSRTOMBS);
+
+
+/*----------------------------------------------------------------------*/
+/*  WCSSPN: size_t wcsspn (const wchar_t *ws1, const wchar_t *ws2)	*/
+/*----------------------------------------------------------------------*/
+
+typedef TIN_WCSCSPN_REC TIN_WCSSPN_REC;
+typedef TEX_WCSCSPN_REC TEX_WCSSPN_REC;
+TMD_RECHEAD (WCSSPN);
+
+
+/*----------------------------------------------------------------------*/
+/*  WCSSTR: wchar_t *wcsstr (const wchar_t *ws1, const wchar_t *ws2)	*/
+/*----------------------------------------------------------------------*/
+
+typedef TIN_WCSCSPN_REC TIN_WCSSTR_REC;
+typedef TEX_ERRET_REC (wchar_t *) TEX_WCSSTR_REC;
+TMD_RECHEAD (WCSSTR);
+
+
+/*----------------------------------------------------------------------*/
+/*  WCSTOD: double wcstod (const wchar_t *np, wchar_t **endp)		*/
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+  wchar_t np[WCSSIZE];
+}
+TIN_WCSTOD_REC;
+
+typedef struct
+{
+  TMD_ERRET (double);
+  double val;
+  wchar_t fwc;
+}
+TEX_WCSTOD_REC;
+
+TMD_RECHEAD (WCSTOD);
+
+
+/*----------------------------------------------------------------------*/
+/*  WCSTOK: wchar_t *wcstok (wchar_t *ws, const wchar_t *dlm,		*/
+/*			     wchar_t **pt)				*/
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+  struct
+  {
+    int w_flg;
+    wchar_t ws[WCSSIZE];
+    wchar_t dt[WCSSIZE];	/* delimiter */
+  }
+  seq[WCSTOK_SEQNUM];
+}
+TIN_WCSTOK_REC;
+
+typedef struct
+{
+  struct
+  {
+    TMD_ERRET (wchar_t *);
+    wchar_t ws[WCSSIZE];
+  }
+  seq[WCSTOK_SEQNUM];
+}
+TEX_WCSTOK_REC;
+
+TMD_RECHEAD (WCSTOK);
+
+
+/*----------------------------------------------------------------------*/
+/*  WCSTOMBS: size_t wcstombs (char s, const wchar_t *ws, size_t n)	*/
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+  int s_flg;
+  int w_flg;		/* currently we don't need it. */
+  wchar_t ws[WCSSIZE];
+  size_t n;
+}
+TIN_WCSTOMBS_REC;
+
+typedef struct
+{
+  TMD_ERRET (size_t);
+  char s[MBSSIZE];
+}
+TEX_WCSTOMBS_REC;
+
+TMD_RECHEAD (WCSTOMBS);
+
+
+/*----------------------------------------------------------------------*/
+/*  WCSWIDTH: int wcswidth (const wchar_t *ws, size_t n)		*/
+/*----------------------------------------------------------------------*/
+
+typedef TIN_WCSNCPY_REC TIN_WCSWIDTH_REC;
+typedef TEX_ERRET_REC (int) TEX_WCSWIDTH_REC;
+TMD_RECHEAD (WCSWIDTH);
+
+
+/*----------------------------------------------------------------------*/
+/*  WCSXFRM: size_t wcsxfrm (wchar_t *ws1, const wchar_t *ws2, size_t n)*/
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+  wchar_t org1[WCSSIZE];
+  wchar_t org2[WCSSIZE];
+  int n1, n2;
+}
+TIN_WCSXFRM_REC;
+
+typedef TEX_ERRET_REC (size_t) TEX_WCSXFRM_REC;	/* only for org2[] */
+TMD_RECHEAD (WCSXFRM);
+
+
+/*----------------------------------------------------------------------*/
+/*  WCTOB: int wctob (wint_t wc)					*/
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+  wint_t wc;
+}
+TIN_WCTOB_REC;
+
+typedef TEX_ERRET_REC (int) TEX_WCTOB_REC;
+TMD_RECHEAD (WCTOB);
+
+
+/*----------------------------------------------------------------------*/
+/*  WCTOMB: int wctomb (char *s, wchar_t wc)				*/
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+  int s_flg;
+  wchar_t wc;
+}
+TIN_WCTOMB_REC;
+
+typedef struct
+{
+  TMD_ERRET (int);
+  char s[MBSSIZE];
+}
+TEX_WCTOMB_REC;
+
+TMD_RECHEAD (WCTOMB);
+
+
+/*----------------------------------------------------------------------*/
+/*  WCTRANS: wctrans_t wctrans (const char *charclass)			*/
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+  char class[MBSSIZE];
+}
+TIN_WCTRANS_REC;
+
+typedef TEX_ERRET_REC (wctrans_t) TEX_WCTRANS_REC;
+TMD_RECHEAD (WCTRANS);
+
+
+/*----------------------------------------------------------------------*/
+/*  WCTYPE: wctype_t wctype (const char *class)				*/
+/*----------------------------------------------------------------------*/
+
+typedef TIN_WCTRANS_REC TIN_WCTYPE_REC;
+typedef TEX_ERRET_REC (wctype_t) TEX_WCTYPE_REC;
+TMD_RECHEAD (WCTYPE);
+
+
+/*----------------------------------------------------------------------*/
+/*  WCWIDTH: int wcwidth (wchar_t wc)					*/
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+  wchar_t wc;
+}
+TIN_WCWIDTH_REC;
+
+typedef TEX_ERRET_REC (int) TEX_WCWIDTH_REC;
+TMD_RECHEAD (WCWIDTH);
+
+#endif /* TST_TYPES_H */
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcrtomb.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcrtomb.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcrtomb.c	(revision 2036)
@@ -0,0 +1,79 @@
+/*
+  WCRTOMB: wchar_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
+*/
+
+#define TST_FUNCTION wcrtomb
+
+#include "tsp_common.c"
+#include "dat_wcrtomb.c"
+
+
+int
+tst_wcrtomb (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (wchar_t);
+  wchar_t wc;
+  char s[MBSSIZE], *s_in, *s_ex;
+  char t_flg, t_ini;
+  static mbstate_t t = { 0 };
+  mbstate_t *pt;
+  int err, i;
+
+  TST_DO_TEST (wcrtomb)
+  {
+    TST_HEAD_LOCALE (wcrtomb, S_WCRTOMB);
+    TST_DO_REC (wcrtomb)
+    {
+      TST_GET_ERRET (wcrtomb);
+      s_in = ((TST_INPUT (wcrtomb).s_flg) == 0) ? (char *) NULL : s;
+      wc = TST_INPUT (wcrtomb).wc;
+      t_flg = TST_INPUT (wcrtomb).t_flg;
+      t_ini = TST_INPUT (wcrtomb).t_init;
+      pt = (t_flg == 0) ? NULL : &t;
+
+      if (t_ini != 0)
+	{
+	  memset (&t, 0, sizeof (t));
+	}
+
+      TST_CLEAR_ERRNO;
+      ret = wcrtomb (s_in, wc, pt);
+      TST_SAVE_ERRNO;
+
+      if (debug_flg)
+	{
+	  fprintf (stdout, "wcrtomb() [ %s : %d ] ret = %lu\n", locale,
+		   rec + 1, (unsigned long int) ret);
+	  fprintf (stdout, "			errno = %d\n", errno_save);
+	}
+
+      TST_IF_RETURN (S_WCRTOMB)
+      {
+      };
+
+      s_ex = TST_EXPECT (wcrtomb).s;
+
+      if (s_in)
+	{
+	  for (i = 0, err = 0; *(s_ex + i) != 0 && i < MBSSIZE; i++)
+	    {
+	      if (s_in[i] != s_ex[i])
+		{
+		  err++;
+		  err_count++;
+		  Result (C_FAILURE, S_WCRTOMB, CASE_4,
+			  "copied string is different from an "
+			  "expected string");
+		  break;
+		}
+	    }
+	  if (!err)
+	    {
+	      Result (C_SUCCESS, S_WCRTOMB, CASE_4, MS_PASSED);
+	    }
+	}
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcscat.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcscat.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcscat.c	(revision 2036)
@@ -0,0 +1,78 @@
+/*
+  WCSCAT: wchar_t *wcscat (wchar_t *ws1, const wchar_t *ws2);
+*/
+
+#define TST_FUNCTION wcscat
+
+#include "tsp_common.c"
+#include "dat_wcscat.c"
+
+int
+tst_wcscat (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (wchar_t *);
+  wchar_t *ws1, *ws2, *ws_ex;
+  int i, err;
+
+  TST_DO_TEST (wcscat)
+  {
+    TST_HEAD_LOCALE (wcscat, S_WCSCAT);
+    TST_DO_REC (wcscat)
+    {
+      TST_GET_ERRET (wcscat);
+      ws1 = TST_INPUT (wcscat).ws1;	/* external value: size WCSSIZE */
+      ws2 = TST_INPUT (wcscat).ws2;
+
+      TST_CLEAR_ERRNO;
+      ret = wcscat (ws1, ws2);
+      TST_SAVE_ERRNO;
+
+      TST_IF_RETURN (S_WCSCAT)
+      {
+	if (ret == ws1)
+	  {
+	    Result (C_SUCCESS, S_WCSCAT, CASE_3, MS_PASSED);
+	  }
+	else
+	  {
+	    err_count++;
+	    Result (C_FAILURE, S_WCSCAT, CASE_3,
+		    "the return address may not be correct");
+	  }
+      }
+
+      /* function specific test cases here */
+
+      if (ret == ws1)
+	{
+	  ws_ex = TST_EXPECT (wcscat).ws;
+	  for (err = 0, i = 0;
+	       (ws1[i] != 0L || ws_ex[i] != 0L) && i < WCSSIZE; i++)
+	    {
+	      if (debug_flg)
+		{
+		  fprintf (stdout, "tst_wcscat() : ws1[%d] = 0x%lx\n", i,
+			   (unsigned long int) ws1[i]);
+		}
+
+	      if (ws1[i] != ws_ex[i])
+		{
+		  err++;
+		  err_count++;
+		  Result (C_FAILURE, S_WCSCAT, CASE_4,
+			  "concatinated string is different from an "
+			  "expected string");
+		  break;
+		}
+	    }
+
+	  if (!err)
+	    {
+	      Result (C_SUCCESS, S_WCSCAT, CASE_4, MS_PASSED);
+	    }
+	}
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcschr.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcschr.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcschr.c	(revision 2036)
@@ -0,0 +1,70 @@
+/*
+  WCSCHR: wchar_t *wcschr (wchar_t *ws, wchar_t wc);
+*/
+
+#define TST_FUNCTION wcschr
+
+#include "tsp_common.c"
+#include "dat_wcschr.c"
+
+int
+tst_wcschr (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (wchar_t *);
+  wchar_t *ws, wc;
+
+  TST_DO_TEST (wcschr)
+  {
+    TST_HEAD_LOCALE (wcschr, S_WCSCHR);
+    TST_DO_REC (wcschr)
+    {
+      TST_GET_ERRET (wcschr);
+      ws = TST_INPUT (wcschr).ws;	/* external value: size WCSSIZE */
+      wc = TST_INPUT (wcschr).wc;
+      ret = wcschr (ws, wc);
+
+      if (debug_flg)
+	{
+	  if (ret)
+	    {
+	      fprintf (stderr, "wcschr: ret = 0x%lx\n",
+		       (unsigned long int) *ret);
+	    }
+	  else
+	    {
+	      fprintf (stderr, "wcschr: ret = NULL pointer\n");
+	    }
+	}
+
+      TST_IF_RETURN (S_WCSCHR)
+      {
+	if (ret == NULL)
+	  {
+	    if (debug_flg)
+	      {
+		fprintf (stderr, "*** Warning *** tst_wcschr: "
+			 "set ret_flg=1 to check NULL return value\n");
+	      }
+
+	    warn_count++;
+	    Result (C_INVALID, S_WCSCHR, CASE_3, "(check the test data) "
+		    "set ret_flg=1 to check NULL return value");
+	    continue;
+	  }
+
+	if (*ret == wc)
+	  {
+	    Result (C_SUCCESS, S_WCSCHR, CASE_3, MS_PASSED);
+	  }
+	else
+	  {
+	    err_count++;
+	    Result (C_FAILURE, S_WCSCHR, CASE_3,
+		    "the returned address of the string seems to be wrong");
+	  }
+      }
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcscmp.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcscmp.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcscmp.c	(revision 2036)
@@ -0,0 +1,40 @@
+/*
+  WCSCMP: int wcscmp (const wchar_t *ws1, const wchar_t *ws2);
+*/
+
+#define TST_FUNCTION wcscmp
+
+#include "tsp_common.c"
+#include "dat_wcscmp.c"
+
+
+int
+tst_wcscmp (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (int);
+  wchar_t *ws1, *ws2;
+
+  TST_DO_TEST (wcscmp)
+  {
+    TST_HEAD_LOCALE (wcscmp, S_WCSCMP);
+    TST_DO_REC (wcscmp)
+    {
+      TST_GET_ERRET (wcscmp);
+      ws1 = TST_INPUT (wcscmp).ws1;
+      ws2 = TST_INPUT (wcscmp).ws2;
+      ret = wcscmp (ws1, ws2);
+      ret = (ret > 0 ? 1 : ret < 0 ? -1 : 0);
+
+      if (debug_flg)
+	{
+	  fprintf (stderr, "tst_wcscmp: ret = %d\n", ret);
+	}
+
+      TST_IF_RETURN (S_WCSCMP)
+      {
+      };
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcscoll.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcscoll.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcscoll.c	(revision 2036)
@@ -0,0 +1,76 @@
+/*
+  WCSCOLL: int wcscoll (const wchar_t *ws1, const wchar_t *ws2);
+*/
+
+#define TST_FUNCTION wcscoll
+
+#include "tsp_common.c"
+#include "dat_wcscoll.c"
+
+int
+tst_wcscoll (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (int);
+  wchar_t *ws1, *ws2;
+  int cmp;
+
+  TST_DO_TEST (wcscoll)
+  {
+    TST_HEAD_LOCALE (wcscoll, S_WCSCOLL);
+    TST_DO_REC (wcscoll)
+    {
+      TST_GET_ERRET (wcscoll);
+      ws1 = TST_INPUT (wcscoll).ws1;	/* external value: size WCSSIZE */
+      ws2 = TST_INPUT (wcscoll).ws2;
+
+      TST_CLEAR_ERRNO;
+      ret = wcscoll (ws1, ws2);
+      TST_SAVE_ERRNO;
+
+      if (debug_flg)
+	{
+	  fprintf (stderr, "tst_wcscoll: ret = %d\n", ret);
+	}
+
+      cmp = TST_EXPECT (wcscoll).cmp_flg;
+      TST_IF_RETURN (S_WCSCOLL)
+      {
+	if (cmp != 0)
+	  {
+	    if ((cmp == 1 && ret > 0) || (cmp == -1 && ret < 0))
+	      {
+		Result (C_SUCCESS, S_WCSCOLL, CASE_3, MS_PASSED);
+	      }
+	    else
+	      {
+		err_count++;
+		if (cmp == 1)
+		  {
+		    if (ret == 0)
+		      Result (C_FAILURE, S_WCSCOLL, CASE_3,
+			      "the return value should be positive"
+			      " but it's zero.");
+		    else
+		      Result (C_FAILURE, S_WCSCOLL, CASE_3,
+			      "the return value should be positive"
+			      " but it's negative.");
+		  }
+		else
+		  {
+		    if (ret == 0)
+		      Result (C_FAILURE, S_WCSCOLL, CASE_3,
+			      "the return value should be negative"
+			      " but it's zero.");
+		    else
+		      Result (C_FAILURE, S_WCSCOLL, CASE_3,
+			      "the return value should be negative"
+			      " but it's positive.");
+		  }
+	      }
+	  }
+      }
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcscpy.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcscpy.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcscpy.c	(revision 2036)
@@ -0,0 +1,85 @@
+/*-------------------------------------------------------------------------------------*/
+/* WCSCPY: wchar_t *wcscpy( wchar_t *ws1, const wchar_t *ws2 )			       */
+/*-------------------------------------------------------------------------------------*/
+#define TST_FUNCTION wcscpy
+
+#include "tsp_common.c"
+#include "dat_wcscpy.c"
+
+int
+tst_wcscpy (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (wchar_t *);
+  wchar_t ws1[WCSSIZE], *ws2, *ws_ex;
+  int err, i;
+
+  TST_DO_TEST (wcscpy)
+  {
+    TST_HEAD_LOCALE (wcscpy, S_WCSCPY);
+    TST_DO_REC (wcscpy)
+    {
+      TST_GET_ERRET (wcscpy);
+      ws2 = TST_INPUT (wcscpy).ws;	/* external value: size WCSSIZE */
+      ret = wcscpy (ws1, ws2);
+
+      TST_IF_RETURN (S_WCSCPY)
+      {
+	if (ret == ws1)
+	  {
+	    Result (C_SUCCESS, S_WCSCPY, CASE_3, MS_PASSED);
+	  }
+	else
+	  {
+	    err_count++;
+	    Result (C_FAILURE, S_WCSCPY, CASE_3,
+		    "the return address may not be correct");
+	  }
+      }
+
+      if (ret == ws1)
+	{
+	  ws_ex = TST_EXPECT (wcscpy).ws;
+
+	  for (err = 0, i = 0;
+	       (ws1[i] != 0L || ws_ex[i] != 0L) && i < WCSSIZE; i++)
+	    {
+	      if (debug_flg)
+		{
+		  fprintf (stderr,
+			   "ws1[ %d ] = 0x%lx <-> wx_ex[ %d ] = 0x%lx\n", i,
+			   (unsigned long int) ws1[i], i,
+			   (unsigned long int) ws_ex[i]);
+		}
+
+	      if (ws1[i] != ws_ex[i])
+		{
+		  err++;
+		  err_count++;
+		  Result (C_FAILURE, S_WCSCPY, CASE_4,
+			  "copied string is different from an"
+			  " expected string");
+		  break;
+		}
+	    }
+
+	  if (!err)
+	    {
+	      Result (C_SUCCESS, S_WCSCPY, CASE_4, MS_PASSED);
+	    }
+
+	  if (ws1[i] == 0L)
+	    {
+	      Result (C_SUCCESS, S_WCSCPY, CASE_5, MS_PASSED);
+	    }
+	  else
+	    {
+	      err_count++;
+	      Result (C_FAILURE, S_WCSCPY, CASE_5,
+		      "copied string is not null-terminated");
+	    }
+	}
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcscspn.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcscspn.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcscspn.c	(revision 2036)
@@ -0,0 +1,38 @@
+/*
+  WCSCSPN: size_t wcscspn (const wchar_t *ws1, const wchar_t *ws2);
+*/
+
+#define TST_FUNCTION wcscspn
+
+#include "tsp_common.c"
+#include "dat_wcscspn.c"
+
+int
+tst_wcscspn (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (size_t);
+  wchar_t *ws1, *ws2;
+
+  TST_DO_TEST (wcscspn)
+  {
+    TST_HEAD_LOCALE (wcscspn, S_WCSCSPN);
+    TST_DO_REC (wcscspn)
+    {
+      TST_GET_ERRET (wcscspn);
+      ws1 = TST_INPUT (wcscspn).ws1;
+      ws2 = TST_INPUT (wcscspn).ws2;	/* external value: size WCSSIZE */
+      ret = wcscspn (ws1, ws2);
+
+      if (debug_flg)
+	{
+	  fprintf (stderr, "wcscspn: ret = %zu\n", ret);
+	}
+
+      TST_IF_RETURN (S_WCSCSPN)
+      {
+      };
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcslen.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcslen.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcslen.c	(revision 2036)
@@ -0,0 +1,31 @@
+/*
+  WCSLEN: size_t wcslen (const wchar_t *ws);
+*/
+
+#define TST_FUNCTION wcslen
+
+#include "tsp_common.c"
+#include "dat_wcslen.c"
+
+int
+tst_wcslen (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (size_t);
+  wchar_t *ws;
+
+  TST_DO_TEST (wcslen)
+  {
+    TST_HEAD_LOCALE (wcslen, S_WCSLEN);
+    TST_DO_REC (wcslen)
+    {
+      TST_GET_ERRET (wcslen);
+      ws = TST_INPUT (wcslen).ws;
+      ret = wcslen (ws);
+      TST_IF_RETURN (S_WCSLEN)
+      {
+      };
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcsncat.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcsncat.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcsncat.c	(revision 2036)
@@ -0,0 +1,75 @@
+/*
+  WCSNCAT: wchar_t *wcsncat (wchar_t *ws1, const wchar_t *ws2, size_t n);
+*/
+
+#define TST_FUNCTION wcsncat
+
+#include "tsp_common.c"
+#include "dat_wcsncat.c"
+
+int
+tst_wcsncat (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (wchar_t *);
+  wchar_t *ws1, *ws2, *ws_ex;
+  int n, i, err;
+
+  TST_DO_TEST (wcsncat)
+  {
+    TST_HEAD_LOCALE (wcsncat, S_WCSNCAT);
+    TST_DO_REC (wcsncat)
+    {
+      TST_GET_ERRET (wcsncat);
+      ws1 = TST_INPUT (wcsncat).ws1;	/* external value: size WCSSIZE */
+      ws2 = TST_INPUT (wcsncat).ws2;
+      n = TST_INPUT (wcsncat).n;
+      ret = wcsncat (ws1, ws2, n);
+
+      TST_IF_RETURN (S_WCSNCAT)
+      {
+	if (ret == ws1)
+	  {
+	    Result (C_SUCCESS, S_WCSNCAT, CASE_3, MS_PASSED);
+	  }
+	else
+	  {
+	    err_count++;
+	    Result (C_FAILURE, S_WCSNCAT, CASE_3,
+		    "the return address may not be correct");
+	  }
+      }
+
+      if (ret == ws1)
+	{
+	  ws_ex = TST_EXPECT (wcsncat).ws;
+
+	  for (err = 0, i = 0;
+	       (ws1[i] != 0L || ws_ex[i] != 0L) && i < WCSSIZE; i++)
+	    {
+	      if (debug_flg)
+		{
+		  fprintf (stderr, "ws1[%d] = 0x%lx\n", i,
+			   (unsigned long int) ws1[i]);
+		}
+
+	      if (ws1[i] != ws_ex[i])
+		{
+		  err++;
+		  err_count++;
+		  Result (C_FAILURE, S_WCSNCAT, CASE_4,
+			  "the concatinated string has "
+			  "different value from an expected string");
+		  break;
+		}
+	    }
+
+	  if (!err)
+	    {
+	      Result (C_SUCCESS, S_WCSNCAT, CASE_4, MS_PASSED);
+	    }
+	}
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcsncmp.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcsncmp.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcsncmp.c	(revision 2036)
@@ -0,0 +1,40 @@
+/*-------------------------------------------------------------------------------------*/
+/* WCSNCMP: int wcsncmp( const wchar_t *ws1, const wchar_t *ws2, size_t n )	       */
+/*-------------------------------------------------------------------------------------*/
+
+#define TST_FUNCTION wcsncmp
+
+#include "tsp_common.c"
+#include "dat_wcsncmp.c"
+
+int
+tst_wcsncmp (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (int);
+  wchar_t *ws1, *ws2;
+  size_t n;
+
+  TST_DO_TEST (wcsncmp)
+  {
+    TST_HEAD_LOCALE (wcsncmp, S_WCSNCMP);
+    TST_DO_REC (wcsncmp)
+    {
+      TST_GET_ERRET (wcsncmp);
+      ws1 = TST_INPUT (wcsncmp).ws1;	/* external value: size WCSSIZE */
+      ws2 = TST_INPUT (wcsncmp).ws2;
+      n = TST_INPUT (wcsncmp).n;
+      ret = wcsncmp (ws1, ws2, n);
+
+      if (debug_flg)
+	{
+	  fprintf (stderr, "tst_wcsncmp: ret = %d, 0x%x\n", ret, ret);
+	}
+
+      TST_IF_RETURN (S_WCSNCMP)
+      {
+      };
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcsncpy.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcsncpy.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcsncpy.c	(revision 2036)
@@ -0,0 +1,93 @@
+/*
+  WCSNCPY: wchar_t *wcsncpy (wchar_t *ws1, const wchar_t *ws2, size_t n);
+*/
+
+#define TST_FUNCTION wcsncpy
+
+#include "tsp_common.c"
+#include "dat_wcsncpy.c"
+
+#define WCSNUM_NCPY 7
+
+int
+tst_wcsncpy (FILE *fp, int debug_flg)
+{
+  TST_DECL_VARS (wchar_t *);
+  wchar_t ws1[WCSSIZE] =
+    { 0x9999, 0x9999, 0x9999, 0x9999, 0x9999, 0x9999, 0x0000 };
+  wchar_t *ws2, *ws_ex;
+  int err, i;
+  size_t n;
+
+  TST_DO_TEST (wcsncpy)
+  {
+    TST_HEAD_LOCALE (wcsncpy, S_WCSNCPY);
+    TST_DO_REC (wcsncpy)
+    {
+      TST_GET_ERRET (wcsncpy);
+
+      for (n = 0; n < WCSNUM_NCPY - 1; ++n)
+	{
+	  ws1[n] = 0x9999;
+	}
+
+      ws1[n] = 0;
+      ws2 = TST_INPUT (wcsncpy).ws;	/* external value: size WCSSIZE */
+      n = TST_INPUT (wcsncpy).n;
+      ret = wcsncpy (ws1, ws2, n);
+
+      TST_IF_RETURN (S_WCSNCPY)
+      {
+	if (ret == ws1)
+	  {
+	    Result (C_SUCCESS, S_WCSNCPY, CASE_3, MS_PASSED);
+	  }
+	else
+	  {
+	    err_count++;
+	    Result (C_FAILURE, S_WCSNCPY, CASE_3,
+		    "the return address may not be correct");
+	  }
+      }
+
+      if (ret == ws1)
+	{
+	  if (debug_flg)
+	    {
+	      fprintf (stderr, "\nwcsncpy: n = %zu\n\n", n);
+	    }
+
+	  ws_ex = TST_EXPECT (wcsncpy).ws;
+
+	  for (err = 0, i = 0; i < WCSNUM_NCPY && i < WCSSIZE; i++)
+	    {
+	      if (debug_flg)
+		fprintf (stderr,
+			 "wcsncpy: ws1[ %d ] = 0x%lx <-> wx_ex[ %d ] = 0x%lx\n",
+			 i, (unsigned long int) ws1[i], i,
+			 (unsigned long int) ws_ex[i]);
+
+	      if (ws1[i] != ws_ex[i])
+		{
+		  err++;
+		  err_count++;
+		  Result (C_FAILURE, S_WCSNCPY, CASE_4,
+			  "copied string is different from an "
+			  "expected string");
+		  break;
+		}
+	    }
+
+	  if (!err)
+	    {
+	      Result (C_SUCCESS, S_WCSNCPY, CASE_4, MS_PASSED);
+	    }
+
+	  /* A null terminate character is not supposed to be copied
+	     unless (num chars of ws2)<n. */
+	}
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcspbrk.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcspbrk.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcspbrk.c	(revision 2036)
@@ -0,0 +1,80 @@
+/*
+  WCSPBRK: wchar_t *wcspbrk (const wchar_t *ws1, const wchar_t *ws2);
+*/
+
+#define TST_FUNCTION wcspbrk
+
+#include "tsp_common.c"
+#include "dat_wcspbrk.c"
+
+int
+tst_wcspbrk (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (wchar_t *);
+  wchar_t *ws1, *ws2;
+  int err;
+  wchar_t wc_ex;
+
+  TST_DO_TEST (wcspbrk)
+  {
+    TST_HEAD_LOCALE (wcspbrk, S_WCSPBRK);
+    TST_DO_REC (wcspbrk)
+    {
+      TST_GET_ERRET (wcspbrk);
+      ws1 = TST_INPUT (wcspbrk).ws1;
+      ws2 = TST_INPUT (wcspbrk).ws2;
+
+      ret = wcspbrk (ws1, ws2);
+
+      if (debug_flg)
+	{
+	  fprintf (stdout, "wcspbrk() [ %s : %d ] ret = %s\n", locale,
+		   rec + 1, (ret == NULL) ? "null" : "not null");
+	  if (ret)
+	    fprintf (stderr,
+		     "			      ret[0] = 0x%lx : 0x%lx = ws2[0]\n",
+		     (unsigned long int) ret[0], (unsigned long int) ws2[0]);
+	}
+
+      TST_IF_RETURN (S_WCSPBRK)
+      {
+	if (ws2[0] == 0)
+	  {
+	    if (ret == ws1)
+	      {
+		Result (C_SUCCESS, S_WCSPBRK, CASE_3, MS_PASSED);
+	      }
+	    else
+	      {
+		err_count++;
+		Result (C_FAILURE, S_WCSPBRK, CASE_3,
+			"return address is not same address as ws1");
+	      }
+
+	    continue;
+	  }
+
+	wc_ex = TST_EXPECT (wcspbrk).wc;
+
+	if (debug_flg)
+	  fprintf (stdout,
+		   "			    *ret = 0x%lx <-> 0x%lx = wc_ex\n",
+		   (unsigned long int) *ret, (unsigned long int) wc_ex);
+
+	if (*ret != wc_ex)
+	  {
+	    err++;
+	    err_count++;
+	    Result (C_FAILURE, S_WCSPBRK, CASE_4, "the pointed wc is "
+		    "different from an expected wc");
+	  }
+	else
+	  {
+	    Result (C_SUCCESS, S_WCSPBRK, CASE_4, MS_PASSED);
+	  }
+      }
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcsrtombs.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcsrtombs.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcsrtombs.c	(revision 2036)
@@ -0,0 +1,127 @@
+/*
+  WCSRTOMBS: size_t wcsrtombs (char *s, const wchar_t **ws, size_t n,
+			       mbstate_t *ps)
+*/
+
+#define TST_FUNCTION wcsrtombs
+
+#include "tsp_common.c"
+#include "dat_wcsrtombs.c"
+
+#define MARK_VAL 0x01
+
+int
+tst_wcsrtombs (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (size_t);
+  char s_flg, n;
+  const wchar_t *ws, *wp;
+  char s[MBSSIZE], *s_in;
+  char t_flg, t_ini;
+  static mbstate_t t = { 0 };
+  mbstate_t *pt;
+  int err, i;
+  char *s_ex;
+
+  TST_DO_TEST (wcsrtombs)
+  {
+    TST_HEAD_LOCALE (wcsrtombs, S_WCSRTOMBS);
+    TST_DO_REC (wcsrtombs)
+    {
+      TST_GET_ERRET (wcsrtombs);
+      memset (s, MARK_VAL, MBSSIZE);
+
+      s_flg = TST_INPUT (wcsrtombs).s_flg;
+      s_in = (s_flg == 1) ? s : (char *) NULL;
+      wp = ws = TST_INPUT (wcsrtombs).ws;
+      n = TST_INPUT (wcsrtombs).n;
+      t_flg = TST_INPUT (wcsrtombs).t_flg;
+      t_ini = TST_INPUT (wcsrtombs).t_init;
+      pt = (t_flg == 0) ? NULL : &t;
+
+      if (t_ini != 0)
+	{
+	  memset (&t, 0, sizeof (t));
+	}
+
+      TST_CLEAR_ERRNO;
+      ret = wcsrtombs (s_in, &wp, n, pt);
+      TST_SAVE_ERRNO;
+
+      if (debug_flg)
+	{
+	  fprintf (stderr, "wcsrtombs: ret	= %zu\n", ret);
+	}
+
+      TST_IF_RETURN (S_WCSRTOMBS)
+      {
+      };
+
+      if (s_in != NULL && ret != (size_t) - 1)
+	{
+	  /* No definition for s, when error occurs.  */
+	  s_ex = TST_EXPECT (wcsrtombs).s;
+
+	  for (err = 0, i = 0; i <= ret && i < MBSSIZE; i++)
+	    {
+	      if (debug_flg)
+		{
+		  fprintf (stderr,
+			   "	: s[%d] = 0x%hx <-> 0x%hx = s_ex[%d]\n", i,
+			   s[i], s_ex[i], i);
+		}
+
+	      if (i == ret && ret == n)	/* no null termination */
+		{
+		  if (s[i] == MARK_VAL)
+		    {
+		      Result (C_SUCCESS, S_WCSRTOMBS, CASE_4, MS_PASSED);
+		    }
+		  else
+		    {
+		      err_count++;
+		      Result (C_FAILURE, S_WCSRTOMBS, CASE_4,
+			      "should not be null terminated "
+			      "(it may be a null char), but it is");
+		    }
+
+		  break;
+		}
+
+	      if (i == ret && ret < n)	/* null termination */
+		{
+		  if (s[i] == 0)
+		    {
+		      Result (C_SUCCESS, S_WCSRTOMBS, CASE_5, MS_PASSED);
+		    }
+		  else
+		    {
+		      err_count++;
+		      Result (C_FAILURE, S_WCSRTOMBS, CASE_5,
+			      "should be null terminated, but it is not");
+		    }
+
+		  break;
+		}
+
+	      if (s[i] != s_ex[i])
+		{
+		  err++;
+		  err_count++;
+		  Result (C_FAILURE, S_WCSRTOMBS, CASE_6,
+			  "converted string is different from an"
+			  " expected string");
+		  break;
+		}
+	    }
+
+	  if (!err)
+	    {
+	      Result (C_SUCCESS, S_WCSRTOMBS, CASE_6, MS_PASSED);
+	    }
+	}
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcsspn.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcsspn.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcsspn.c	(revision 2036)
@@ -0,0 +1,38 @@
+/*
+  WCSSPN: size_t wcsspn (const wchar_t *ws1, const wchar_t *ws2);
+*/
+
+#define TST_FUNCTION wcsspn
+
+#include "tsp_common.c"
+#include "dat_wcsspn.c"
+
+int
+tst_wcsspn (FILE *fp, int debug_flg)
+{
+  TST_DECL_VARS (size_t);
+  wchar_t *ws1, *ws2;
+
+  TST_DO_TEST (wcsspn)
+  {
+    TST_HEAD_LOCALE (wcsspn, S_WCSSPN);
+    TST_DO_REC (wcsspn)
+    {
+      TST_GET_ERRET (wcsspn);
+      ws1 = TST_INPUT (wcsspn).ws1;
+      ws2 = TST_INPUT (wcsspn).ws2;	/* external value: size WCSSIZE */
+      ret = wcsspn (ws1, ws2);
+
+      if (debug_flg)
+	{
+	  fprintf (stderr, "wcsspn: ret = %zu\n", ret);
+	}
+
+      TST_IF_RETURN (S_WCSSPN)
+      {
+      };
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcsstr.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcsstr.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcsstr.c	(revision 2036)
@@ -0,0 +1,86 @@
+/*
+  WCSSTR: wchar_t *wcsstr (const wchar_t *ws1, const wchar_t *ws2);
+*/
+
+#define TST_FUNCTION wcsstr
+
+#include "tsp_common.c"
+#include "dat_wcsstr.c"
+
+int
+tst_wcsstr (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (wchar_t *);
+  wchar_t *ws1, *ws2;
+  int err, i;
+
+  TST_DO_TEST (wcsstr)
+  {
+    TST_HEAD_LOCALE (wcsstr, S_WCSSTR);
+    TST_DO_REC (wcsstr)
+    {
+      TST_GET_ERRET (wcsstr);
+      ws1 = TST_INPUT (wcsstr).ws1;
+      ws2 = TST_INPUT (wcsstr).ws2;	/* external value: size WCSSIZE */
+      ret = wcsstr (ws1, ws2);
+
+      if (debug_flg)
+	{
+	  fprintf (stderr, "wcsstr: %d : ret = %s\n", rec + 1,
+		   (ret == NULL) ? "null" : "not null");
+	  if (ret)
+	    {
+	      fprintf (stderr,
+		       "	ret[ 0 ] = 0x%lx <-> 0x%lx = ws2[ 0 ]\n",
+		       (unsigned long int) ret[0], (unsigned long int) ws2[0]);
+	    }
+	}
+
+      TST_IF_RETURN (S_WCSSTR)
+      {
+	if (ws2[0] == 0)
+	  {
+	    if (ret == ws1)
+	      {
+		Result (C_SUCCESS, S_WCSSTR, CASE_3, MS_PASSED);
+	      }
+	    else
+	      {
+		err_count++;
+		Result (C_FAILURE, S_WCSSTR, CASE_3,
+			"return address is not same address as ws1");
+	      }
+
+	    continue;
+	  }
+
+	for (i = 0, err = 0; *(ws2 + i) != 0 && i < WCSSIZE; i++)
+	  {
+	    if (debug_flg)
+	      {
+		fprintf (stderr,
+			 "	: ret[ %d ] = 0x%lx <-> 0x%lx = ws2[ %d ]\n",
+			 i, (unsigned long int) ret[i],
+			 (unsigned long int) ws2[i], i);
+	      }
+
+	    if (ret[i] != ws2[i])
+	      {
+		err++;
+		err_count++;
+		Result (C_FAILURE, S_WCSSTR, CASE_4, "pointed sub-string is "
+			"different from an expected sub-string");
+		break;
+	      }
+	  }
+
+	if (!err)
+	  {
+	    Result (C_SUCCESS, S_WCSSTR, CASE_4, MS_PASSED);
+	  }
+      }
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcstod.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcstod.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcstod.c	(revision 2036)
@@ -0,0 +1,69 @@
+/*
+  WCSTOD: double wcstod (wchar_t *np, const wchar_t **endp);
+*/
+
+#define TST_FUNCTION wcstod
+
+#include "tsp_common.c"
+#include "dat_wcstod.c"
+
+int
+tst_wcstod (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (double);
+  wchar_t *np, *endp, fwc;
+  double val;
+
+  TST_DO_TEST (wcstod)
+  {
+    TST_HEAD_LOCALE (wcstod, S_WCSTOD);
+    TST_DO_REC (wcstod)
+    {
+      TST_GET_ERRET (wcstod);
+      np = TST_INPUT (wcstod).np;
+
+      TST_CLEAR_ERRNO;
+      ret = wcstod (np, &endp);
+      TST_SAVE_ERRNO;
+
+      if (debug_flg)
+	{
+	  fprintf (stdout, "wcstod() [ %s : %d ] ret  = %f\n", locale,
+		   rec + 1, ret);
+	  fprintf (stdout, "			  *endp = 0x%lx\n",
+		   (unsigned long int) *endp);
+	}
+
+      TST_IF_RETURN (S_WCSTOD)
+      {
+	if (ret != 0)
+	  {
+	    val = ret - TST_EXPECT (wcstod).val;
+	    if (TST_ABS (val) < TST_DBL_EPS)
+	      {
+		Result (C_SUCCESS, S_WCSTOD, CASE_3, MS_PASSED);
+	      }
+	    else
+	      {
+		err_count++;
+		Result (C_FAILURE, S_WCSTOD, CASE_3, "return value is wrong");
+	      }
+	  }
+      }
+
+      fwc = TST_EXPECT (wcstod).fwc;
+
+      if (fwc == *endp)
+	{
+	  Result (C_SUCCESS, S_WCSTOD, CASE_4, MS_PASSED);
+	}
+      else
+	{
+	  err_count++;
+	  Result (C_FAILURE, S_WCSTOD, CASE_4, "a final wc is wrong.");
+	}
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcstok.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcstok.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcstok.c	(revision 2036)
@@ -0,0 +1,96 @@
+/*
+  WCSTOK: wchar_t *wcstok (wchar_t *ws, const wchar_t *dlm, wchar_t **pt);
+*/
+
+
+#define TST_FUNCTION wcstok
+
+#include "tsp_common.c"
+#include "dat_wcstok.c"
+
+int
+tst_wcstok (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (wchar_t *);
+  char w_flg;
+  wchar_t *ws;
+  wchar_t *dt, *pt;
+  wchar_t *ws_ex;
+  int err, i;
+
+  TST_DO_TEST (wcstok)
+  {
+    TST_HEAD_LOCALE (wcstok, S_WCSTOK);
+    TST_DO_REC (wcstok)
+    {
+      TST_DO_SEQ (WCSTOK_SEQNUM)
+      {
+	TST_GET_ERRET_SEQ (wcstok);
+	w_flg = TST_INPUT_SEQ (wcstok).w_flg;
+	ws = (w_flg) ? TST_INPUT_SEQ (wcstok).ws : NULL;
+	dt = TST_INPUT_SEQ (wcstok).dt;
+
+	ret = wcstok (ws, dt, &pt);
+
+	if (debug_flg)
+	  {
+	    fprintf (stdout, "wcstok() [ %s : %d : %d ] *ret  = 0x%lx\n",
+		     locale, rec + 1, seq_num + 1, (unsigned long int) *ret);
+	    if (pt && *pt)
+	      {
+		fprintf (stdout, "			 *pt   = 0x%lx\n",
+			 (unsigned long int) *pt);
+	      }
+	  }
+
+	TST_IF_RETURN (S_WCSTOK)
+	{
+	};
+
+	if (ret != NULL)
+	  {
+	    ws_ex = TST_EXPECT_SEQ (wcstok).ws;
+
+	    /* XXX: REVISIT : insufficient conditions */
+	    for (err = 0, i = 0; i < WCSSIZE; i++)
+	      {
+		if (ret[i] == L'\0' && ws_ex[i] == L'\0')
+		  {
+		    break;
+		  }
+
+		if (debug_flg)
+		  {
+		    fprintf (stderr,
+			     "			      ret[%d] = 0x%lx <-> "
+			     "0x%lx = ws_ex[%d]\n",
+			     i, (unsigned long int) ret[i],
+			     (unsigned long int) ws_ex[i], i);
+		  }
+
+		if (ret[i] != ws_ex[i])
+		  {
+		    err++;
+		    err_count++;
+		    Result (C_FAILURE, S_WCSTOK, CASE_3,
+			    "the token is different from an expected string");
+		    break;
+		  }
+
+		if (ret[i] == L'\0' || ws_ex[i] == L'\0')
+		  {
+		    break;
+		  }
+	      }
+
+	    if (!err)
+	      {
+		Result (C_SUCCESS, S_WCSTOK, CASE_3, MS_PASSED);
+	      }
+	  }
+      }
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcstombs.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcstombs.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcstombs.c	(revision 2036)
@@ -0,0 +1,115 @@
+/*
+  WCSTOMBS: size_t wcstombs (char *s, const wchar_t *ws, size_t n)
+*/
+
+#define TST_FUNCTION wcstombs
+
+#include "tsp_common.c"
+#include "dat_wcstombs.c"
+
+#define MARK_VAL 0x01
+
+int
+tst_wcstombs (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (size_t);
+  char s_flg, n;
+  wchar_t *ws;
+  char s[MBSSIZE], *s_in;
+  int err, i;
+  char *s_ex;
+
+  TST_DO_TEST (wcstombs)
+  {
+    TST_HEAD_LOCALE (wcstombs, S_WCSTOMBS);
+    TST_DO_REC (wcstombs)
+    {
+      TST_GET_ERRET (wcstombs);
+      memset (s, MARK_VAL, MBSSIZE);
+
+      s_flg = TST_INPUT (wcstombs).s_flg;
+      s_in = (s_flg == 1) ? s : (char *) NULL;
+      ws = TST_INPUT (wcstombs).ws;
+      n = TST_INPUT (wcstombs).n;
+
+      TST_CLEAR_ERRNO;
+      ret = wcstombs (s_in, ws, n);
+      TST_SAVE_ERRNO;
+
+      if (debug_flg)
+	{
+	  fprintf (stdout, "wcstombs: ret  = %zu\n", ret);
+	}
+
+      TST_IF_RETURN (S_WCSTOMBS)
+      {
+      };
+
+      if (s_in != NULL && ret != (size_t) - 1)
+	{
+	  /* No definition for s, when error occurs.  */
+	  s_ex = TST_EXPECT (wcstombs).s;
+
+	  for (err = 0, i = 0; i <= ret && i < MBSSIZE; i++)
+	    {
+	      if (debug_flg)
+		{
+		  fprintf (stdout,
+			   "	: s[%d] = 0x%hx <-> 0x%hx = s_ex[%d]\n", i,
+			   s[i], s_ex[i], i);
+		}
+
+	      if (i == ret && ret == n)	/* no null termination */
+		{
+		  if (s[i] == MARK_VAL)
+		    {
+		      Result (C_SUCCESS, S_WCSTOMBS, CASE_4, MS_PASSED);
+		    }
+		  else
+		    {
+		      err_count++;
+		      Result (C_FAILURE, S_WCSTOMBS, CASE_4,
+			      "should not be null terminated "
+			      "(it may be a null char), but it is");
+		    }
+
+		  break;
+		}
+
+	      if (i == ret && ret < n)	/* null termination */
+		{
+		  if (s[i] == 0)
+		    {
+		      Result (C_SUCCESS, S_WCSTOMBS, CASE_5, MS_PASSED);
+		    }
+		  else
+		    {
+		      err_count++;
+		      Result (C_FAILURE, S_WCSTOMBS, CASE_5,
+			      "should be null terminated, but it is not");
+		    }
+
+		  break;
+		}
+
+	      if (s[i] != s_ex[i])
+		{
+		  err++;
+		  err_count++;
+		  Result (C_FAILURE, S_WCSTOMBS, CASE_6,
+			  "converted string is different from an "
+			  "expected string");
+		  break;
+		}
+	    }
+
+	  if (!err)
+	    {
+	      Result (C_SUCCESS, S_WCSTOMBS, CASE_6, MS_PASSED);
+	    }
+	}
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcswidth.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcswidth.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcswidth.c	(revision 2036)
@@ -0,0 +1,39 @@
+/*
+  WCSWIDTH: int wcswidth (const wchar_t *ws, size_t n);
+*/
+
+#define TST_FUNCTION wcswidth
+
+#include "tsp_common.c"
+#include "dat_wcswidth.c"
+
+int
+tst_wcswidth (FILE *fp, int debug_flg)
+{
+  TST_DECL_VARS (int);
+  wchar_t *ws;
+  int n;
+
+  TST_DO_TEST (wcswidth)
+  {
+    TST_HEAD_LOCALE (wcswidth, S_WCSWIDTH);
+    TST_DO_REC (wcswidth)
+    {
+      TST_GET_ERRET (wcswidth);
+      ws = TST_INPUT (wcswidth).ws;
+      n = TST_INPUT (wcswidth).n;
+      ret = wcswidth (ws, n);
+
+      if (debug_flg)
+	{
+	  fprintf (stderr, "wcswidth: [ %d ] : ret = %d\n", rec + 1, ret);
+	}
+
+      TST_IF_RETURN (S_WCSWIDTH)
+      {
+      };
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcsxfrm.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcsxfrm.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcsxfrm.c	(revision 2036)
@@ -0,0 +1,122 @@
+/*
+  WCSXFRM: size_t wcsxfrm (wchar_t *ws1, const wchar_t *ws2, size_t n);
+*/
+
+#define TST_FUNCTION wcsxfrm
+
+#include "tsp_common.c"
+#include "dat_wcsxfrm.c"
+
+int
+tst_wcsxfrm (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (size_t);
+  wchar_t *org1, *org2;
+  wchar_t frm1[MBSSIZE], frm2[MBSSIZE];
+  size_t n1, n2;
+  int ret_coll, ret_cmp;
+
+  TST_DO_TEST (wcsxfrm)
+  {
+    TST_HEAD_LOCALE (wcsxfrm, S_WCSXFRM);
+    TST_DO_REC (wcsxfrm)
+    {
+      TST_GET_ERRET (wcsxfrm);
+      org1 = TST_INPUT (wcsxfrm).org1;
+      org2 = TST_INPUT (wcsxfrm).org2;
+      n1 = TST_INPUT (wcsxfrm).n1;
+      n2 = TST_INPUT (wcsxfrm).n2;
+      if (n1 < 0 || sizeof (frm1) < n1 || sizeof (frm2) < n2)
+	{
+	  warn_count++;
+	  Result (C_IGNORED, S_WCSXFRM, CASE_9,
+		  "input data n1 or n2 is invalid");
+	  continue;
+	}
+
+      /* an errno and a return value are checked
+	 only for 2nd wcsxfrm() call.
+	 A result of 1st call is used to compare
+	 those 2 values by using wcscmp().
+       */
+
+      TST_CLEAR_ERRNO;
+      ret = wcsxfrm (frm1, org1, n1);	/* First call */
+      TST_SAVE_ERRNO;
+
+      if (debug_flg)
+	{
+	  fprintf (stdout, "tst_wcsxfrm() : REC = %d\n", rec + 1);
+	  fprintf (stdout, "tst_wcsxfrm() : 1st ret = %zu\n", ret);
+	}
+
+      if (ret == -1 || ret >= n1 || errno_save != 0)
+	{
+	  warn_count++;
+	  Result (C_INVALID, S_WCSXFRM, CASE_8,
+		  "got an error in fist wcsxfrm() call");
+	  continue;
+	}
+
+      TST_CLEAR_ERRNO;
+      /* Second call */
+      ret = wcsxfrm (((n2 == 0) ? NULL : frm2), org2, n2);
+      TST_SAVE_ERRNO;
+
+      TST_IF_RETURN (S_WCSXFRM)
+      {
+      };
+
+      if (n2 == 0 || ret >= n2 || errno != 0)
+	{
+#if 0
+	  warn_count++;
+	  Result (C_IGNORED, S_WCSXFRM, CASE_7, "did not get a result");
+#endif
+	  continue;
+	}
+
+      if (debug_flg)
+	{
+	  fprintf (stdout, "tst_wcsxfrm() : 2nd ret = %zu\n", ret);
+	}
+
+      /* wcscoll() */
+      TST_CLEAR_ERRNO;
+      /* depends on wcscoll() ... not good though ... */
+      ret_coll = wcscoll (org1, org2);
+      TST_SAVE_ERRNO;
+
+      if (errno != 0)		/* bugs * bugs may got correct results ... */
+	{
+	  warn_count++;
+	  Result (C_INVALID, S_WCSXFRM, CASE_6,
+		  "got an error in wcscoll() call");
+	  continue;
+	}
+      /* wcscmp() */
+      ret_cmp = wcscmp (frm1, frm2);
+
+      if ((ret_coll == ret_cmp) || (ret_coll > 0 && ret_cmp > 0)
+	  || (ret_coll < 0 && ret_cmp < 0))
+	{
+	  Result (C_SUCCESS, S_WCSXFRM, CASE_3,
+		  MS_PASSED " (depends on wcscoll & wcscmp)");
+	}
+      else
+	{
+	  err_count++;
+	  Result (C_FAILURE, S_WCSXFRM, CASE_3,
+		  "results from wcscoll & wcscmp() do not match");
+	}
+
+      if (debug_flg)
+	{
+	  fprintf (stdout, "tst_wcsxfrm() : coll = %d <-> %d = cmp\n",
+		   ret_coll, ret_cmp);
+	}
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wctob.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wctob.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wctob.c	(revision 2036)
@@ -0,0 +1,37 @@
+/*-------------------------------------------------------------------------------------*/
+/* WCTOB: int wctob( wint_t wc )						       */
+/*-------------------------------------------------------------------------------------*/
+
+#define TST_FUNCTION wctob
+
+#include "tsp_common.c"
+#include "dat_wctob.c"
+
+int
+tst_wctob (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (int);
+  wchar_t wc;
+
+  TST_DO_TEST (wctob)
+  {
+    TST_HEAD_LOCALE (wctob, S_WCTOB);
+    TST_DO_REC (wctob)
+    {
+      TST_GET_ERRET (wctob);
+      wc = TST_INPUT (wctob).wc;
+      ret = wctob (wc);
+
+      if (debug_flg)
+	{
+	  fprintf (stderr, "tst_wctob : [ %d ] ret = %d\n", rec + 1, ret);
+	}
+
+      TST_IF_RETURN (S_WCTOB)
+      {
+      };
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wctomb.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wctomb.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wctomb.c	(revision 2036)
@@ -0,0 +1,99 @@
+/*
+  WCTOMB: int wctomb (char *s, wchar_t wc)
+*/
+
+#define TST_FUNCTION wctomb
+
+#include "tsp_common.c"
+#include "dat_wctomb.c"
+
+int
+tst_wctomb (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (int);
+  wchar_t wc;
+  char s[MBSSIZE], *s_in, *s_ex;
+  int err, i;
+
+  TST_DO_TEST (wctomb)
+  {
+    TST_HEAD_LOCALE (wctomb, S_WCTOMB);
+    TST_DO_REC (wctomb)
+    {
+      TST_GET_ERRET (wctomb);
+      wc = TST_INPUT (wctomb).wc;
+      s_in = ((TST_INPUT (wctomb).s_flg) == 0) ? (char *) NULL : s;
+      ret = wctomb (s_in, wc);
+
+      if (debug_flg)
+	{
+	  fprintf (stdout, "wctomb() [ %s : %d ] ret  = %d\n", locale,
+		   rec + 1, ret);
+	}
+
+      TST_IF_RETURN (S_WCTOMB)
+      {
+	if (s_in == NULL)	/* state dependency */
+	  {
+	    if (ret_exp == +1)	/* state-dependent  */
+	      {
+		if (ret != 0)
+		  {
+		    /* Non-zero means state-dependent encoding.	 */
+		    Result (C_SUCCESS, S_WCTOMB, CASE_3, MS_PASSED);
+		  }
+		else
+		  {
+		    err_count++;
+		    Result (C_FAILURE, S_WCTOMB, CASE_3,
+			    "should be state-dependent encoding, "
+			    "but a return value shows it is "
+			    "state-independent");
+		  }
+	      }
+
+	    if (ret_exp == 0)	/* state-independent */
+	      {
+		if (ret == 0)
+		  {
+		    /* Non-zero means state-dependent encoding.	 */
+		    Result (C_SUCCESS, S_WCTOMB, CASE_3, MS_PASSED);
+		  }
+		else
+		  {
+		    err_count++;
+		    Result (C_FAILURE, S_WCTOMB, CASE_3,
+			    "should be state-independent encoding, "
+			    "but a return value shows it is state-dependent");
+		  }
+	      }
+	  }
+      }
+
+      s_ex = TST_EXPECT (wctomb).s;
+
+      if (s_in)
+	{
+	  for (i = 0, err = 0; *(s_ex + i) != 0 && i < MBSSIZE; i++)
+	    {
+	      if (s_in[i] != s_ex[i])
+		{
+		  err++;
+		  err_count++;
+		  Result (C_FAILURE, S_WCTOMB, CASE_4,
+			  "copied string is different from an"
+			  " expected string");
+		  break;
+		}
+	    }
+
+	  if (!err)
+	    {
+	      Result (C_SUCCESS, S_WCTOMB, CASE_4, MS_PASSED);
+	    }
+	}
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wctrans.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wctrans.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wctrans.c	(revision 2036)
@@ -0,0 +1,52 @@
+/*
+  WCTRANS: wctrans_t wctrans (const char *charclass);
+*/
+
+#define TST_FUNCTION wctrans
+
+#include "tsp_common.c"
+#include "dat_wctrans.c"
+
+int
+tst_wctrans (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (wctrans_t);
+  char *class;
+
+  TST_DO_TEST (wctrans)
+  {
+    TST_HEAD_LOCALE (wctrans, S_WCTRANS);
+    TST_DO_REC (wctrans)
+    {
+      TST_GET_ERRET (wctrans);
+      class = TST_INPUT (wctrans).class;
+
+      TST_CLEAR_ERRNO;
+      ret = wctrans (class);
+      TST_SAVE_ERRNO;
+
+      if (debug_flg)
+	{
+	  fprintf (stderr, "tst_wctrans : [ %d ] ret = %ld\n", rec + 1,
+		   (long int) ret);
+	  fprintf (stderr, "		       errno = %d\n", errno_save);
+	}
+
+      TST_IF_RETURN (S_WCTRANS)
+      {
+	if (ret != 0)
+	  {
+	    Result (C_SUCCESS, S_WCTYPE, CASE_3, MS_PASSED);
+	  }
+	else
+	  {
+	    err_count++;
+	    Result (C_FAILURE, S_WCTYPE, CASE_3,
+		    "should return non-0, but returned 0");
+	  }
+      }
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wctype.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wctype.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wctype.c	(revision 2036)
@@ -0,0 +1,48 @@
+/*
+  WCTYPE: wctype_t wctype (const char *class);
+*/
+
+
+#define TST_FUNCTION wctype
+
+#include "tsp_common.c"
+#include "dat_wctype.c"
+
+int
+tst_wctype (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (wctype_t);
+  char *class;
+
+  TST_DO_TEST (wctype)
+  {
+    TST_HEAD_LOCALE (wctype, S_WCTYPE);
+    TST_DO_REC (wctype)
+    {
+      TST_GET_ERRET (wctype);
+      class = TST_INPUT (wctype).class;
+      ret = wctype (class);
+
+      if (debug_flg)
+	{
+	  fprintf (stderr, "tst_wctype : [ %d ] ret = %ld\n", rec + 1, ret);
+	}
+
+      TST_IF_RETURN (S_WCTYPE)
+      {
+	if (ret != 0)
+	  {
+	    Result (C_SUCCESS, S_WCTYPE, CASE_3, MS_PASSED);
+	  }
+	else
+	  {
+	    err_count++;
+	    Result (C_FAILURE, S_WCTYPE, CASE_3,
+		    "should return non-0, but returned 0");
+	  }
+      }
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcwidth.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcwidth.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests-mbwc/tst_wcwidth.c	(revision 2036)
@@ -0,0 +1,38 @@
+/*
+  WCWIDTH: int wcwidth (wchar_t wc);
+*/
+
+#define TST_FUNCTION wcwidth
+
+#include "tsp_common.c"
+#include "dat_wcwidth.c"
+
+int
+tst_wcwidth (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (int);
+  wchar_t wc;
+
+  TST_DO_TEST (wcwidth)
+  {
+    TST_HEAD_LOCALE (wcwidth, S_WCWIDTH);
+    TST_DO_REC (wcwidth)
+    {
+      TST_GET_ERRET (wcwidth);
+      wc = TST_INPUT (wcwidth).wc;
+      ret = wcwidth (wc);
+
+      if (debug_flg)
+	{
+	  fprintf (stdout, "wcwidth() [ %s : %d ] ret  = %d\n", locale,
+		   rec + 1, ret);
+	}
+
+      TST_IF_RETURN (S_WCWIDTH)
+      {
+      }
+    }
+  }
+
+  return err_count;
+}
Index: trunk/src/libctests/glibc/localedata/tests/test1.cm
===================================================================
--- trunk/src/libctests/glibc/localedata/tests/test1.cm	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests/test1.cm	(revision 2036)
@@ -0,0 +1,82 @@
+<code_set_name> BIG5
+<comment_char> %
+<escape_char> /
+<mb_cur_max>  2
+<mb_cur_min>  1
+CHARMAP
+<A>                    /x41
+<B>                    /x42
+<C>                    /x43
+<D>                    /x44
+<E>                    /x45
+<F>                    /x46
+<G>                    /x47
+<H>                    /x48
+<I>                    /x49
+<J>                    /x4A
+<K>                    /x4B
+<L>                    /x4C
+<M>                    /x4D
+<N>                    /x4E
+<O>                    /x4F
+<P>                    /x50
+<Q>                    /x51
+<R>                    /x52
+<S>                    /x53
+<T>                    /x54
+<U>                    /x55
+<V>                    /x56
+<W>                    /x57
+<X>                    /x58
+<Y>                    /x59
+<Z>                    /x5A
+
+<a>                    /x61
+<b>                    /x62
+<c>                    /x63
+<d>                    /x64
+<e>                    /x65
+<f>                    /x66
+<g>                    /x67
+<h>                    /x68
+<i>                    /x69
+<j>                    /x6a
+<k>                    /x6b
+<l>                    /x6c
+<m>                    /x6d
+<n>                    /x6e
+<o>                    /x6f
+<p>                    /x70
+<q>                    /x71
+<r>                    /x72
+<s>                    /x73
+<t>                    /x74
+<u>                    /x75
+<v>                    /x76
+<w>                    /x77
+<x>                    /x78
+<y>                    /x79
+<z>                    /x7a
+<SP>			/x20
+<space>			/x20
+<0>                    /x30
+<1>                    /x31
+<2>                    /x32
+<3>                    /x33
+<4>                    /x34
+<5>                    /x35
+<6>                    /x36
+<7>                    /x37
+<8>                    /x38
+<9>                    /x39
+
+<period>               /x2e
+<colon>                /x3a
+<percent-sign>         /x25
+<slash>                /x2f
+<circumflex>           /x5e
+<left-square-bracket>  /x5b
+<right-square-bracket> /x5d
+
+<B1>...<B3>	/xa1/x40
+END CHARMAP
Index: trunk/src/libctests/glibc/localedata/tests/test1.def
===================================================================
--- trunk/src/libctests/glibc/localedata/tests/test1.def	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests/test1.def	(revision 2036)
@@ -0,0 +1,9 @@
+LC_CTYPE
+
+upper	<A>
+lower   <a>
+space	<SP>
+blank	<SP>
+alpha	<A>;<a>;<b1>..<b3>
+
+END LC_CTYPE
Index: trunk/src/libctests/glibc/localedata/tests/test2.cm
===================================================================
--- trunk/src/libctests/glibc/localedata/tests/test2.cm	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests/test2.cm	(revision 2036)
@@ -0,0 +1,82 @@
+<code_set_name> BIG5
+<comment_char> %
+<escape_char> /
+<mb_cur_max>  2
+<mb_cur_min>  1
+CHARMAP
+<A>                    /x41
+<B>                    /x42
+<C>                    /x43
+<D>                    /x44
+<E>                    /x45
+<F>                    /x46
+<G>                    /x47
+<H>                    /x48
+<I>                    /x49
+<J>                    /x4A
+<K>                    /x4B
+<L>                    /x4C
+<M>                    /x4D
+<N>                    /x4E
+<O>                    /x4F
+<P>                    /x50
+<Q>                    /x51
+<R>                    /x52
+<S>                    /x53
+<T>                    /x54
+<U>                    /x55
+<V>                    /x56
+<W>                    /x57
+<X>                    /x58
+<Y>                    /x59
+<Z>                    /x5A
+
+<a>                    /x61
+<b>                    /x62
+<c>                    /x63
+<d>                    /x64
+<e>                    /x65
+<f>                    /x66
+<g>                    /x67
+<h>                    /x68
+<i>                    /x69
+<j>                    /x6a
+<k>                    /x6b
+<l>                    /x6c
+<m>                    /x6d
+<n>                    /x6e
+<o>                    /x6f
+<p>                    /x70
+<q>                    /x71
+<r>                    /x72
+<s>                    /x73
+<t>                    /x74
+<u>                    /x75
+<v>                    /x76
+<w>                    /x77
+<x>                    /x78
+<y>                    /x79
+<z>                    /x7a
+<SP>			/x20
+<space>			/x20
+<0>                    /x30
+<1>                    /x31
+<2>                    /x32
+<3>                    /x33
+<4>                    /x34
+<5>                    /x35
+<6>                    /x36
+<7>                    /x37
+<8>                    /x38
+<9>                    /x39
+
+<period>               /x2e
+<colon>                /x3a
+<percent-sign>         /x25
+<slash>                /x2f
+<circumflex>           /x5e
+<left-square-bracket>  /x5b
+<right-square-bracket> /x5d
+
+<b01>...<b03>	/xa1/x40
+END CHARMAP
Index: trunk/src/libctests/glibc/localedata/tests/test2.def
===================================================================
--- trunk/src/libctests/glibc/localedata/tests/test2.def	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests/test2.def	(revision 2036)
@@ -0,0 +1,9 @@
+LC_CTYPE
+
+upper	<A>
+lower   <a>
+space	<SP>
+blank	<SP>
+alpha	<A>;<a>;<b01>..<b03>
+
+END LC_CTYPE
Index: trunk/src/libctests/glibc/localedata/tests/test3.cm
===================================================================
--- trunk/src/libctests/glibc/localedata/tests/test3.cm	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests/test3.cm	(revision 2036)
@@ -0,0 +1,82 @@
+<code_set_name> BIG5
+<comment_char> %
+<escape_char> /
+<mb_cur_max>  2
+<mb_cur_min>  1
+CHARMAP
+<A>                    /x41
+<B>                    /x42
+<C>                    /x43
+<D>                    /x44
+<E>                    /x45
+<F>                    /x46
+<G>                    /x47
+<H>                    /x48
+<I>                    /x49
+<J>                    /x4A
+<K>                    /x4B
+<L>                    /x4C
+<M>                    /x4D
+<N>                    /x4E
+<O>                    /x4F
+<P>                    /x50
+<Q>                    /x51
+<R>                    /x52
+<S>                    /x53
+<T>                    /x54
+<U>                    /x55
+<V>                    /x56
+<W>                    /x57
+<X>                    /x58
+<Y>                    /x59
+<Z>                    /x5A
+
+<a>                    /x61
+<b>                    /x62
+<c>                    /x63
+<d>                    /x64
+<e>                    /x65
+<f>                    /x66
+<g>                    /x67
+<h>                    /x68
+<i>                    /x69
+<j>                    /x6a
+<k>                    /x6b
+<l>                    /x6c
+<m>                    /x6d
+<n>                    /x6e
+<o>                    /x6f
+<p>                    /x70
+<q>                    /x71
+<r>                    /x72
+<s>                    /x73
+<t>                    /x74
+<u>                    /x75
+<v>                    /x76
+<w>                    /x77
+<x>                    /x78
+<y>                    /x79
+<z>                    /x7a
+<SP>			/x20
+<space>			/x20
+<0>                    /x30
+<1>                    /x31
+<2>                    /x32
+<3>                    /x33
+<4>                    /x34
+<5>                    /x35
+<6>                    /x36
+<7>                    /x37
+<8>                    /x38
+<9>                    /x39
+
+<period>               /x2e
+<colon>                /x3a
+<percent-sign>         /x25
+<slash>                /x2f
+<circumflex>           /x5e
+<left-square-bracket>  /x5b
+<right-square-bracket> /x5d
+
+<b1>...<b3>	/xa1/x40
+END CHARMAP
Index: trunk/src/libctests/glibc/localedata/tests/test3.def
===================================================================
--- trunk/src/libctests/glibc/localedata/tests/test3.def	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests/test3.def	(revision 2036)
@@ -0,0 +1,9 @@
+LC_CTYPE
+
+upper	<A>
+lower   <a>
+space	<SP>
+blank	<SP>
+alpha	<A>;<a>;<b1>..<b3>
+
+END LC_CTYPE
Index: trunk/src/libctests/glibc/localedata/tests/test4.cm
===================================================================
--- trunk/src/libctests/glibc/localedata/tests/test4.cm	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests/test4.cm	(revision 2036)
@@ -0,0 +1,87 @@
+<code_set_name> BIG5
+<escape_char> /
+<mb_cur_max>  2
+<mb_cur_min>  1
+CHARMAP
+<b0101>...<b0103>       /xa1/x40
+<B0101>...<B0103>       /xa1/xa1
+<b0901>...<b0903>       /xa1/x40
+<B0901>...<B0903>       /xa1/xa1
+<b1001>...<b1003>       /xaa/x40
+<B1001>...<B1003>       /xaa/xa1
+
+<A>                    /x41
+<B>                    /x42
+<C>                    /x43
+<D>                    /x44
+<E>                    /x45
+<F>                    /x46
+<G>                    /x47
+<H>                    /x48
+<I>                    /x49
+<J>                    /x4A
+<K>                    /x4B
+<L>                    /x4C
+<M>                    /x4D
+<N>                    /x4E
+<O>                    /x4F
+<P>                    /x50
+<Q>                    /x51
+<R>                    /x52
+<S>                    /x53
+<T>                    /x54
+<U>                    /x55
+<V>                    /x56
+<W>                    /x57
+<X>                    /x58
+<Y>                    /x59
+<Z>                    /x5A
+
+<a>                    /x61
+<b>                    /x62
+<c>                    /x63
+<d>                    /x64
+<e>                    /x65
+<f>                    /x66
+<g>                    /x67
+<h>                    /x68
+<i>                    /x69
+<j>                    /x6a
+<k>                    /x6b
+<l>                    /x6c
+<m>                    /x6d
+<n>                    /x6e
+<o>                    /x6f
+<p>                    /x70
+<q>                    /x71
+<r>                    /x72
+<s>                    /x73
+<t>                    /x74
+<u>                    /x75
+<v>                    /x76
+<w>                    /x77
+<x>                    /x78
+<y>                    /x79
+<z>                    /x7a
+<SP>			/x20
+<space>			/x20
+<0>                    /x30
+<1>                    /x31
+<2>                    /x32
+<3>                    /x33
+<4>                    /x34
+<5>                    /x35
+<6>                    /x36
+<7>                    /x37
+<8>                    /x38
+<9>                    /x39
+
+<period>               /x2e
+<colon>                /x3a
+<percent-sign>         /x25
+<slash>                /x2f
+<circumflex>           /x5e
+<left-square-bracket>  /x5b
+<right-square-bracket> /x5d
+
+END CHARMAP
Index: trunk/src/libctests/glibc/localedata/tests/test4.def
===================================================================
--- trunk/src/libctests/glibc/localedata/tests/test4.def	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests/test4.def	(revision 2036)
@@ -0,0 +1,7 @@
+LC_COLLATE
+order_start forward
+<b1001>
+<B1001>
+UNDEFINED       IGNORE
+order_end
+END LC_COLLATE
Index: trunk/src/libctests/glibc/localedata/tests/test5.cm
===================================================================
--- trunk/src/libctests/glibc/localedata/tests/test5.cm	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests/test5.cm	(revision 2036)
@@ -0,0 +1,89 @@
+<code_set_name> test5
+<comment_char> %
+<escape_char> /
+<mb_cur_max> 2
+<mb_cur_min> 1
+CHARMAP
+<k0101>...<k0194>       /xa1/xa1
+<k0201>...<k0294>       /xa2/xa1
+<k1601>...<k1694>       /xa3/xa1
+<k1701>...<k1794>       /xa4/xa1
+<k4001>...<k4094>       /xa5/xa1
+<k5001>...<k5094>       /xa6/xa1
+<k6001>...<k6094>       /xa7/xa1
+
+<A>                    /x41
+<B>                    /x42
+<C>                    /x43
+<D>                    /x44
+<E>                    /x45
+<F>                    /x46
+<G>                    /x47
+<H>                    /x48
+<I>                    /x49
+<J>                    /x4A
+<K>                    /x4B
+<L>                    /x4C
+<M>                    /x4D
+<N>                    /x4E
+<O>                    /x4F
+<P>                    /x50
+<Q>                    /x51
+<R>                    /x52
+<S>                    /x53
+<T>                    /x54
+<U>                    /x55
+<V>                    /x56
+<W>                    /x57
+<X>                    /x58
+<Y>                    /x59
+<Z>                    /x5A
+
+<a>                    /x61
+<b>                    /x62
+<c>                    /x63
+<d>                    /x64
+<e>                    /x65
+<f>                    /x66
+<g>                    /x67
+<h>                    /x68
+<i>                    /x69
+<j>                    /x6a
+<k>                    /x6b
+<l>                    /x6c
+<m>                    /x6d
+<n>                    /x6e
+<o>                    /x6f
+<p>                    /x70
+<q>                    /x71
+<r>                    /x72
+<s>                    /x73
+<t>                    /x74
+<u>                    /x75
+<v>                    /x76
+<w>                    /x77
+<x>                    /x78
+<y>                    /x79
+<z>                    /x7a
+<SP>			/x20
+<space>			/x20
+<0>                    /x30
+<1>                    /x31
+<2>                    /x32
+<3>                    /x33
+<4>                    /x34
+<5>                    /x35
+<6>                    /x36
+<7>                    /x37
+<8>                    /x38
+<9>                    /x39
+
+<period>               /x2e
+<colon>                /x3a
+<percent-sign>         /x25
+<slash>                /x2f
+<circumflex>           /x5e
+<left-square-bracket>  /x5b
+<right-square-bracket> /x5d
+
+END CHARMAP
Index: trunk/src/libctests/glibc/localedata/tests/test5.def
===================================================================
--- trunk/src/libctests/glibc/localedata/tests/test5.def	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests/test5.def	(revision 2036)
@@ -0,0 +1,36 @@
+escape_char /
+comment_char %
+
+LC_TIME
+
+abday    "<k0101><k0102><k0103>";"<k0101><k0102><k0103>";/
+         "<k4001><k4002><k4003>";"<k4001><k4002><k4003>";/
+         "<k5001><k5002><k5003>";"<k5001><k5002><k5003>";/
+         "<k6001><k6002><k6003>"
+day      "<k6001><k6002><k6003>";/
+         "<k6001><k6002><k6003>";/
+         "<k6001><k6002><k6003>";/
+         "<k6001><k6002><k6003>";/
+         "<k6001><k6002><k6003>";/
+         "<k6001><k6002><k6003>";/
+         "<k6001><k6002><k6003>"
+abmon    "<k6001>";"<k6001>";/
+        "<k6001>";"<k6001>";/
+        "<k6001>";"<k6001>";/
+        "<k6001>";"<k6001>";/
+        "<k6001>";"<k6001>";/
+        "<k6001>";"<k6001>"
+mon    "<k6001>";"<k6001>";/
+        "<k6001>";"<k6001>";/
+        "<k6001>";"<k6001>";/
+        "<k6001>";"<k6001>";/
+        "<k6001>";"<k6001>";/
+        "<k6001>";"<k6001>"
+
+d_t_fmt ""
+d_fmt   ""
+t_fmt   ""
+am_pm   "<k6001><k5002>";"<k5002><k4036>"
+t_fmt_ampm ""
+
+END LC_TIME
Index: trunk/src/libctests/glibc/localedata/tests/test5.ds
===================================================================
--- trunk/src/libctests/glibc/localedata/tests/test5.ds	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests/test5.ds	(revision 2036)
@@ -0,0 +1,24 @@
+escape_char /
+<k0101>		<UAC00>
+<k0102>		<UAC01>
+<k0103>		<UAC02>
+<k4001>		<U2170>
+<k4002>		<U2171>
+<k4003>		<U2172>
+<k4036>		<U0394>
+<k5001>		<U2500>
+<k5002>		<U2502>
+<k5003>		<U250C>
+<k6001>		<U3395>
+<k6002>		<U3396>
+<k6003>		<U3397>
+<0>		<U0030>
+<1>		<U0031>
+<2>		<U0032>
+<3>		<U0033>
+<4>		<U0034>
+<5>		<U0035>
+<6>		<U0036>
+<7>		<U0037>
+<8>		<U0038>
+<9>		<U0039>
Index: trunk/src/libctests/glibc/localedata/tests/test6.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tests/test6.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests/test6.c	(revision 2036)
@@ -0,0 +1,138 @@
+/* Test program for character classes and mappings.
+   Copyright (C) 1999 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <ctype.h>
+#include <locale.h>
+#include <wchar.h>
+
+
+int
+main (void)
+{
+  const char lower[] = "abcdefghijklmnopqrstuvwxyz";
+  const char upper[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+#define LEN (sizeof (upper) - 1)
+  const wchar_t wlower[] = L"abcdefghijklmnopqrstuvwxyz";
+  const wchar_t wupper[] = L"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+  int i;
+  int result = 0;
+
+  setlocale (LC_ALL, "test6");
+
+  for (i = 0; i < LEN; ++i)
+    {
+      /* Test basic table handling (basic == not more than 256 characters).
+	 The charmaps swaps the normal lower-upper case meaning of the
+	 ASCII characters used in the source code while the Unicode mapping
+	 in the repertoire map has the normal correspondants.  This test
+	 shows the independence of the tables for `char' and `wchar_t'
+	 characters.  */
+
+      if (islower (lower[i]))
+	{
+	  printf ("islower ('%c') false\n", lower[i]);
+	  result = 1;
+	}
+      if (! isupper (lower[i]))
+	{
+	  printf ("isupper ('%c') false\n", lower[i]);
+	  result = 1;
+	}
+
+      if (! islower (upper[i]))
+	{
+	  printf ("islower ('%c') false\n", upper[i]);
+	  result = 1;
+	}
+      if (isupper (upper[i]))
+	{
+	  printf ("isupper ('%c') false\n", upper[i]);
+	  result = 1;
+	}
+
+      if (toupper (lower[i]) != lower[i])
+	{
+	  printf ("toupper ('%c') false\n", lower[i]);
+	  result = 1;
+	}
+      if (tolower (lower[i]) != upper[i])
+	{
+	  printf ("tolower ('%c') false\n", lower[i]);
+	  result = 1;
+	}
+
+      if (tolower (upper[i]) != upper[i])
+	{
+	  printf ("tolower ('%c') false\n", upper[i]);
+	  result = 1;
+	}
+      if (toupper (upper[i]) != lower[i])
+	{
+	  printf ("toupper ('%c') false\n", upper[i]);
+	  result = 1;
+	}
+
+      if (iswlower (wupper[i]))
+	{
+	  printf ("iswlower (L'%c') false\n", upper[i]);
+	  result = 1;
+	}
+      if (! iswupper (wupper[i]))
+	{
+	  printf ("iswupper (L'%c') false\n", upper[i]);
+	  result = 1;
+	}
+
+      if (iswupper (wlower[i]))
+	{
+	  printf ("iswupper (L'%c') false\n", lower[i]);
+	  result = 1;
+	}
+      if (! iswlower (wlower[i]))
+	{
+	  printf ("iswlower (L'%c') false\n", lower[i]);
+	  result = 1;
+	}
+
+      if (towupper (wlower[i]) != wupper[i])
+	{
+	  printf ("towupper ('%c') false\n", lower[i]);
+	  result = 1;
+	}
+      if (towlower (wlower[i]) != wlower[i])
+	{
+	  printf ("towlower ('%c') false\n", lower[i]);
+	  result = 1;
+	}
+
+      if (towlower (wupper[i]) != wlower[i])
+	{
+	  printf ("towlower ('%c') false\n", upper[i]);
+	  result = 1;
+	}
+      if (towupper (wupper[i]) != wupper[i])
+	{
+	  printf ("towupper ('%c') false\n", upper[i]);
+	  result = 1;
+	}
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/localedata/tests/test6.cm
===================================================================
--- trunk/src/libctests/glibc/localedata/tests/test6.cm	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests/test6.cm	(revision 2036)
@@ -0,0 +1,93 @@
+<code_set_name> test6
+
+CHARMAP
+<tab>                  \x09
+<newline>              \x0A
+<vertical-tab>         \x0B
+<form-feed>            \x0C
+<carriage-return>      \x0D
+<SP>                   \x20
+<space>                \x20
+<!>                    \x21
+<">                    \x22
+<%>                    \x25
+<&>                    \x26
+<'>                    \x27
+<(>                    \x28
+<)>                    \x29
+<*>                    \x2A
+<+>                    \x2B
+<,>                    \x2C
+<->                    \x2D
+<.>                    \x2E
+<\\>                   \x2F
+<0>                    \x30
+<1>                    \x31
+<2>                    \x32
+<3>                    \x33
+<4>                    \x34
+<5>                    \x35
+<6>                    \x36
+<7>                    \x37
+<8>                    \x38
+<9>                    \x39
+<:>                    \x3A
+<;>                    \x3B
+<<>                    \x3C
+<=>                    \x3D
+<\>>                   \x3E
+<?>                    \x3F
+<a>                    \x41
+<b>                    \x42
+<c>                    \x43
+<d>                    \x44
+<e>                    \x45
+<f>                    \x46
+<g>                    \x47
+<h>                    \x48
+<i>                    \x49
+<j>                    \x4A
+<k>                    \x4B
+<l>                    \x4C
+<m>                    \x4D
+<n>                    \x4E
+<o>                    \x4F
+<p>                    \x50
+<q>                    \x51
+<r>                    \x52
+<s>                    \x53
+<t>                    \x54
+<u>                    \x55
+<v>                    \x56
+<w>                    \x57
+<x>                    \x58
+<y>                    \x59
+<z>                    \x5A
+<_>                    \x5F
+<A>                    \x61
+<B>                    \x62
+<C>                    \x63
+<D>                    \x64
+<E>                    \x65
+<F>                    \x66
+<G>                    \x67
+<H>                    \x68
+<I>                    \x69
+<J>                    \x6A
+<K>                    \x6B
+<L>                    \x6C
+<M>                    \x6D
+<N>                    \x6E
+<O>                    \x6F
+<P>                    \x70
+<Q>                    \x71
+<R>                    \x72
+<S>                    \x73
+<T>                    \x74
+<U>                    \x75
+<V>                    \x76
+<W>                    \x77
+<X>                    \x78
+<Y>                    \x79
+<Z>                    \x7A
+END CHARMAP
Index: trunk/src/libctests/glibc/localedata/tests/test6.def
===================================================================
--- trunk/src/libctests/glibc/localedata/tests/test6.def	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests/test6.def	(revision 2036)
@@ -0,0 +1,20 @@
+LC_CTYPE
+
+lower <a>;<b>;<c>;<d>;<e>;<f>;<g>;<h>;<i>;<j>;<k>;<l>;<m>;<n>;<o>;<p>;<q>; \
+      <r>;<s>;<t>;<u>;<v>;<w>;<x>;<y>;<z>
+upper <A>;<B>;<C>;<D>;<E>;<F>;<G>;<H>;<I>;<J>;<K>;<L>;<M>;<N>;<O>;<P>;<Q>; \
+      <R>;<S>;<T>;<U>;<V>;<W>;<X>;<Y>;<Z>
+
+tolower (<A>,<a>);(<B>,<b>);(<C>,<c>);(<D>,<d>);(<E>,<e>);(<F>,<f>); \
+        (<G>,<g>);(<H>,<h>);(<I>,<i>);(<J>,<j>);(<K>,<k>);(<L>,<l>); \
+        (<M>,<m>);(<N>,<n>);(<O>,<o>);(<P>,<p>);(<Q>,<q>);(<R>,<r>); \
+        (<S>,<s>);(<T>,<t>);(<U>,<u>);(<V>,<v>);(<W>,<w>);(<X>,<x>); \
+        (<Y>,<y>);(<Z>,<z>)
+
+toupper (<a>,<A>);(<b>,<B>);(<c>,<C>);(<d>,<D>);(<e>,<E>);(<f>,<F>); \
+        (<g>,<G>);(<h>,<H>);(<i>,<I>);(<j>,<J>);(<k>,<K>);(<l>,<L>); \
+        (<m>,<M>);(<n>,<N>);(<o>,<O>);(<p>,<P>);(<q>,<Q>);(<r>,<R>); \
+        (<s>,<S>);(<t>,<T>);(<u>,<U>);(<v>,<V>);(<w>,<W>);(<x>,<X>); \
+        (<y>,<Y>);(<z>,<Z>)
+
+END LC_CTYPE
Index: trunk/src/libctests/glibc/localedata/tests/test6.ds
===================================================================
--- trunk/src/libctests/glibc/localedata/tests/test6.ds	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests/test6.ds	(revision 2036)
@@ -0,0 +1,113 @@
+<tab>                  <U0009> HORIZONTAL TABULATION
+<newline>              <U000A> LINE FEED
+<vertical-tab>         <U000B> VERTICAL TABULATION
+<form-feed>            <U000C> FORM FEED
+<carriage-return>      <U000D> CARRIAGE RETURN
+<SP>                   <U0020> SPACE
+<space>                <U0020> SPACE
+<!>                    <U0021> EXCLAMATION MARK
+<">                    <U0022> QUOTATION MARK
+<Nb>                   <U0023> NUMBER SIGN
+<DO>                   <U0024> DOLLAR SIGN
+<!S>                   <U0024> DOLLAR SIGN
+<%>                    <U0025> PERCENT SIGN
+<&>                    <U0026> AMPERSAND
+<'>                    <U0027> APOSTROPHE
+<(>                    <U0028> LEFT PARENTHESIS
+<)>                    <U0029> RIGHT PARENTHESIS
+<*>                    <U002A> ASTERISK
+<+>                    <U002B> PLUS SIGN
+<,>                    <U002C> COMMA
+<->                    <U002D> HYPHEN-MINUS
+<.>                    <U002E> FULL STOP
+</>                    <U002F> SOLIDUS
+<0>                    <U0030> DIGIT ZERO
+<1>                    <U0031> DIGIT ONE
+<2>                    <U0032> DIGIT TWO
+<3>                    <U0033> DIGIT THREE
+<4>                    <U0034> DIGIT FOUR
+<5>                    <U0035> DIGIT FIVE
+<6>                    <U0036> DIGIT SIX
+<7>                    <U0037> DIGIT SEVEN
+<8>                    <U0038> DIGIT EIGHT
+<9>                    <U0039> DIGIT NINE
+<:>                    <U003A> COLON
+<;>                    <U003B> SEMICOLON
+<<>                    <U003C> LESS-THAN SIGN
+<=>                    <U003D> EQUALS SIGN
+<\>>                   <U003E> GREATER-THAN SIGN
+<?>                    <U003F> QUESTION MARK
+<@>                    <U0040> COMMERCIAL AT
+<A>                    <U0041> LATIN CAPITAL LETTER A
+<B>                    <U0042> LATIN CAPITAL LETTER B
+<C>                    <U0043> LATIN CAPITAL LETTER C
+<D>                    <U0044> LATIN CAPITAL LETTER D
+<E>                    <U0045> LATIN CAPITAL LETTER E
+<F>                    <U0046> LATIN CAPITAL LETTER F
+<G>                    <U0047> LATIN CAPITAL LETTER G
+<H>                    <U0048> LATIN CAPITAL LETTER H
+<I>                    <U0049> LATIN CAPITAL LETTER I
+<J>                    <U004A> LATIN CAPITAL LETTER J
+<K>                    <U004B> LATIN CAPITAL LETTER K
+<L>                    <U004C> LATIN CAPITAL LETTER L
+<M>                    <U004D> LATIN CAPITAL LETTER M
+<N>                    <U004E> LATIN CAPITAL LETTER N
+<O>                    <U004F> LATIN CAPITAL LETTER O
+<P>                    <U0050> LATIN CAPITAL LETTER P
+<Q>                    <U0051> LATIN CAPITAL LETTER Q
+<R>                    <U0052> LATIN CAPITAL LETTER R
+<S>                    <U0053> LATIN CAPITAL LETTER S
+<T>                    <U0054> LATIN CAPITAL LETTER T
+<U>                    <U0055> LATIN CAPITAL LETTER U
+<V>                    <U0056> LATIN CAPITAL LETTER V
+<W>                    <U0057> LATIN CAPITAL LETTER W
+<X>                    <U0058> LATIN CAPITAL LETTER X
+<Y>                    <U0059> LATIN CAPITAL LETTER Y
+<Z>                    <U005A> LATIN CAPITAL LETTER Z
+<<(>                   <U005B> LEFT SQUARE BRACKET
+<left-square-bracket>  <U005B> LEFT SQUARE BRACKET
+<//>                 <U005C> REVERSE SOLIDUS
+<backslash>            <U005C> REVERSE SOLIDUS
+<reverse-solidus>      <U005C> REVERSE SOLIDUS
+<)\>>                  <U005D> RIGHT SQUARE BRACKET
+<right-square-bracket> <U005D> RIGHT SQUARE BRACKET
+<'\>>                  <U005E> CIRCUMFLEX ACCENT
+<circumflex>           <U005E> CIRCUMFLEX ACCENT
+<circumflex-accent>    <U005E> CIRCUMFLEX ACCENT
+<_>                    <U005F> LOW LINE
+<low-line>             <U005F> LOW LINE
+<underscore>           <U005F> LOW LINE
+<'!>                   <U0060> GRAVE ACCENT
+<grave-accent>         <U0060> GRAVE ACCENT
+<a>                    <U0061> LATIN SMALL LETTER A
+<b>                    <U0062> LATIN SMALL LETTER B
+<c>                    <U0063> LATIN SMALL LETTER C
+<d>                    <U0064> LATIN SMALL LETTER D
+<e>                    <U0065> LATIN SMALL LETTER E
+<f>                    <U0066> LATIN SMALL LETTER F
+<g>                    <U0067> LATIN SMALL LETTER G
+<h>                    <U0068> LATIN SMALL LETTER H
+<i>                    <U0069> LATIN SMALL LETTER I
+<j>                    <U006A> LATIN SMALL LETTER J
+<k>                    <U006B> LATIN SMALL LETTER K
+<l>                    <U006C> LATIN SMALL LETTER L
+<m>                    <U006D> LATIN SMALL LETTER M
+<n>                    <U006E> LATIN SMALL LETTER N
+<o>                    <U006F> LATIN SMALL LETTER O
+<p>                    <U0070> LATIN SMALL LETTER P
+<q>                    <U0071> LATIN SMALL LETTER Q
+<r>                    <U0072> LATIN SMALL LETTER R
+<s>                    <U0073> LATIN SMALL LETTER S
+<t>                    <U0074> LATIN SMALL LETTER T
+<u>                    <U0075> LATIN SMALL LETTER U
+<v>                    <U0076> LATIN SMALL LETTER V
+<w>                    <U0077> LATIN SMALL LETTER W
+<x>                    <U0078> LATIN SMALL LETTER X
+<y>                    <U0079> LATIN SMALL LETTER Y
+<z>                    <U007A> LATIN SMALL LETTER Z
+<(!>                   <U007B> LEFT CURLY BRACKET
+<!!>                   <U007C> VERTICAL LINE
+<vertical-line>        <U007C> VERTICAL LINE
+<!)>                   <U007D> RIGHT CURLY BRACKET
+<'?>                   <U007E> TILDE
+<DT>                   <U007F> DELETE
Index: trunk/src/libctests/glibc/localedata/tests/test7.cm
===================================================================
--- trunk/src/libctests/glibc/localedata/tests/test7.cm	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests/test7.cm	(revision 2036)
@@ -0,0 +1,86 @@
+<code_set_name> UTF-8
+<mb_cur_min> 1
+<mb_cur_max> 3
+
+CHARMAP
+<U0009>                \x09
+<U000A>                \x0a
+<U000B>                \x0b
+<U000C>                \x0c
+<U000D>                \x0d
+<U0020>                \x20
+<U002C>                \x2c
+<U002E>                \x2e
+<U0030>                \x30
+<U0031>                \x31
+<U0032>                \x32
+<U0033>                \x33
+<U0034>                \x34
+<U0035>                \x35
+<U0036>                \x36
+<U0037>                \x37
+<U0038>                \x38
+<U0039>                \x39
+<U0041>                \x41
+<U0042>                \x42
+<U0043>                \x43
+<U0044>                \x44
+<U0045>                \x45
+<U0046>                \x46
+<U0047>                \x47
+<U0048>                \x48
+<U0049>                \x49
+<U004A>                \x4a
+<U004B>                \x4b
+<U004C>                \x4c
+<U004D>                \x4d
+<U004E>                \x4e
+<U004F>                \x4f
+<U0050>                \x50
+<U0051>                \x51
+<U0052>                \x52
+<U0053>                \x53
+<U0054>                \x54
+<U0055>                \x55
+<U0056>                \x56
+<U0057>                \x57
+<U0058>                \x58
+<U0059>                \x59
+<U005A>                \x5a
+<U0061>                \x61
+<U0062>                \x62
+<U0063>                \x63
+<U0064>                \x64
+<U0065>                \x65
+<U0066>                \x66
+<U0067>                \x67
+<U0068>                \x68
+<U0069>                \x69
+<U006A>                \x6A
+<U006B>                \x6B
+<U006C>                \x6C
+<U006D>                \x6D
+<U006E>                \x6E
+<U006F>                \x6F
+<U0070>                \x70
+<U0071>                \x71
+<U0072>                \x72
+<U0073>                \x73
+<U0074>                \x74
+<U0075>                \x75
+<U0076>                \x76
+<U0077>                \x77
+<U0078>                \x78
+<U0079>                \x79
+<U007A>                \x7A
+<U2080>                \xe2\x82\x80
+<U2081>                \xe2\x82\x81
+<U2082>                \xe2\x82\x82
+<U2083>                \xe2\x82\x83
+<U2084>                \xe2\x82\x84
+<U2085>                \xe2\x82\x85
+<U2086>                \xe2\x82\x86
+<U2087>                \xe2\x82\x87
+<U2088>                \xe2\x82\x88
+<U2089>                \xe2\x82\x89
+END CHARMAP
Index: trunk/src/libctests/glibc/localedata/tests/test7.def
===================================================================
--- trunk/src/libctests/glibc/localedata/tests/test7.def	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests/test7.def	(revision 2036)
@@ -0,0 +1,25 @@
+LC_CTYPE
+lower <U0061>;<U0062>;<U0063>;<U0064>;<U0065>;<U0066>;<U0067>;<U0068>;\
+      <U0069>;<U006A>;<U006B>;<U006C>;<U006D>;<U006E>;<U006F>;<U0070>;\
+      <U0071>;<U0072>;<U0073>;<U0074>;<U0075>;<U0076>;<U0077>;<U0078>;\
+      <U0079>;<U007A>
+
+upper <U0041>;<U0042>;<U0043>;<U0044>;<U0045>;<U0046>;<U0047>;<U0048>;\
+      <U0049>;<U004A>;<U004B>;<U004C>;<U004D>;<U004E>;<U004F>;<U0050>;\
+      <U0051>;<U0052>;<U0053>;<U0054>;<U0055>;<U0056>;<U0057>;<U0058>;\
+      <U0059>;<U005A>
+
+digit <U0030>;<U0031>;<U0032>;<U0033>;<U0034>;\
+      <U0035>;<U0036>;<U0037>;<U0038>;<U0039>;\
+      <U2080>;<U2081>;<U2082>;<U2083>;<U2084>;\
+      <U2085>;<U2086>;<U2087>;<U2088>;<U2089>
+
+outdigit <U2080>;<U2081>;<U2082>;<U2083>;<U2084>;\
+         <U2085>;<U2086>;<U2087>;<U2088>;<U2089>
+END LC_CTYPE
+
+LC_NUMERIC
+decimal_point   "<U002E>"
+thousands_sep   "<U002C>"
+grouping        3;3
+END LC_NUMERIC
Index: trunk/src/libctests/glibc/localedata/tests/trans.def
===================================================================
--- trunk/src/libctests/glibc/localedata/tests/trans.def	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tests/trans.def	(revision 2036)
@@ -0,0 +1,161 @@
+escape_char /
+comment_char %
+
+LC_CTYPE
+
+digit   <U0030>;<U0031>;<U0032>;<U0033>;<U0034>;/
+        <U0035>;<U0036>;<U0037>;<U0038>;<U0039>
+
+xdigit  <U0030>;<U0031>;<U0032>;<U0033>;<U0034>;/
+        <U0035>;<U0036>;<U0037>;<U0038>;<U0039>;/
+        <U0041>;<U0042>;<U0043>;<U0044>;<U0045>;<U0046>;/
+        <U0061>;<U0062>;<U0063>;<U0064>;<U0065>;<U0066>
+
+blank   <U0020>;<U0009>;<U00A0>
+
+space   <U0020>;<U000A>;<U000B>;<U000C>;/
+        <U000D>;<U0009>;<U00A0>
+
+upper   <U0041>;<U0042>;<U0043>;<U0044>;<U0045>;<U0046>;<U0047>;/
+        <U0048>;<U0049>;<U004A>;<U004B>;<U004C>;<U004D>;<U004E>;/
+        <U004F>;<U0050>;<U0051>;<U0052>;<U0053>;<U0054>;<U0055>;/
+        <U0056>;<U0057>;<U0058>;<U0059>;<U005A>
+
+lower   <U0061>;<U0062>;<U0063>;<U0064>;<U0065>;<U0066>;<U0067>;/
+        <U0068>;<U0069>;<U006A>;<U006B>;<U006C>;<U006D>;<U006E>;/
+        <U006F>;<U0070>;<U0071>;<U0072>;<U0073>;<U0074>;<U0075>;/
+        <U0076>;<U0077>;<U0078>;<U0079>;<U007A>
+
+alpha   <U0041>;<U0042>;<U0043>;<U0044>;<U0045>;<U0046>;<U0047>;/
+        <U0048>;<U0049>;<U004A>;<U004B>;<U004C>;<U004D>;<U004E>;/
+        <U004F>;<U0050>;<U0051>;<U0052>;<U0053>;<U0054>;<U0055>;/
+        <U0056>;<U0057>;<U0058>;<U0059>;<U005A>;<U0061>;<U0062>;/
+        <U0063>;<U0064>;<U0065>;<U0066>;<U0067>;<U0068>;<U0069>;/
+        <U006A>;<U006B>;<U006C>;<U006D>;<U006E>;<U006F>;<U0070>;/
+        <U0071>;<U0072>;<U0073>;<U0074>;<U0075>;<U0076>;<U0077>;/
+        <U0078>;<U0079>;<U007A>
+
+cntrl   <U0000>;<U0001>;<U0002>;<U0003>;<U0004>;<U0005>;/
+        <U0006>;<U0007>;<U0008>;<U0009>;<U000A>;<U000B>;/
+        <U000C>;<U000D>;<U000E>;<U000F>;<U0010>;<U0011>;/
+        <U0012>;<U0013>;<U0014>;<U0015>;<U0016>;<U0017>;/
+        <U0018>;<U0019>;<U001A>;<U001B>;<U001C>;<U001D>;/
+        <U001E>;<U001F>;<U007F>;<U0080>;<U0081>;<U0082>;/
+        <U0083>;<U0084>;<U0085>;<U0086>;<U0087>;<U0088>;/
+        <U0089>;<U008A>;<U008B>;<U008C>;<U008D>;<U008E>;/
+        <U008F>;<U0090>;<U0091>;<U0092>;<U0093>;<U0094>;/
+        <U0095>;<U0096>;<U0097>;<U0098>;<U0099>;<U009A>;/
+        <U009B>;<U009C>;<U009D>;<U009E>;<U009F>
+
+punct   <U0021>;<U0022>;<U0023>;<U0024>;<U0025>;<U0026>;<U0027>;/
+        <U0028>;<U0029>;<U002A>;<U002B>;<U002C>;<U002D>;<U002E>;/
+        <U002F>;<U003A>;<U003B>;<U003C>;<U003D>;<U003E>;<U003F>;/
+        <U0040>;<U005B>;<U005C>;<U005D>;<U005E>
+
+tolower (<U0041>,<U0061>);/
+        (<U0042>,<U0062>);/
+        (<U0043>,<U0063>);/
+        (<U0044>,<U0064>);/
+        (<U0045>,<U0065>);/
+        (<U0046>,<U0066>);/
+        (<U0047>,<U0067>);/
+        (<U0048>,<U0068>);/
+        (<U0049>,<U0069>);/
+        (<U004A>,<U006A>);/
+        (<U004B>,<U006B>);/
+        (<U004C>,<U006C>);/
+        (<U004D>,<U006D>);/
+        (<U004E>,<U006E>);/
+        (<U004F>,<U006F>);/
+        (<U0050>,<U0070>);/
+        (<U0051>,<U0071>);/
+        (<U0052>,<U0072>);/
+        (<U0053>,<U0073>);/
+        (<U0054>,<U0074>);/
+        (<U0055>,<U0075>);/
+        (<U0056>,<U0076>);/
+        (<U0057>,<U0077>);/
+        (<U0058>,<U0078>);/
+        (<U0059>,<U0079>);/
+        (<U005A>,<U007A>)
+
+toupper (<U0061>,<U0041>);/
+        (<U0062>,<U0042>);/
+        (<U0063>,<U0043>);/
+        (<U0064>,<U0044>);/
+        (<U0065>,<U0045>);/
+        (<U0066>,<U0046>);/
+        (<U0067>,<U0047>);/
+        (<U0068>,<U0048>);/
+        (<U0069>,<U0049>);/
+        (<U006A>,<U004A>);/
+        (<U006B>,<U004B>);/
+        (<U006C>,<U004C>);/
+        (<U006D>,<U004D>);/
+        (<U006E>,<U004E>);/
+        (<U006F>,<U004F>);/
+        (<U0070>,<U0050>);/
+        (<U0071>,<U0051>);/
+        (<U0072>,<U0052>);/
+        (<U0073>,<U0053>);/
+        (<U0074>,<U0054>);/
+        (<U0075>,<U0055>);/
+        (<U0076>,<U0056>);/
+        (<U0077>,<U0057>);/
+        (<U0078>,<U0058>);/
+        (<U0079>,<U0059>);/
+        (<U007A>,<U005A>)
+
+charconv test
+
+test (<U0041>,<U0042>);(<U0042>,<U0043>)
+
+outdigit <U0061>;<U0062>;<U0063>;<U0064>;<U0065>;<U0066>;<U0067>;<U0068>;<U0069>;<U006A>
+
+END LC_CTYPE
+
+LC_COLLATE
+copy "en_US"
+END LC_COLLATE
+
+LC_TIME
+copy "en_US"
+END LC_TIME
+
+LC_NUMERIC
+copy "en_US"
+END LC_NUMERIC
+
+LC_MONETARY
+copy "en_US"
+END LC_MONETARY
+
+LC_MESSAGES
+copy "en_US"
+END LC_MESSAGES
+
+LC_PAPER
+height 297
+width 210
+END LC_PAPER
+
+LC_NAME
+name_fmt    "<U0025><U0070><U0025><U0074><U0025><U0067><U0025><U0074><U0025><U006D><U0025><U0074><U0025><U0066>"
+END LC_NAME
+
+LC_ADDRESS
+postal_fmt    "<U0025><U0061><U0025><U004E><U0025><U0066><U0025><U004E><U0025><U0064><U0025><U004E><U0025><U0062><U0025><U004E><U0025>/
+<U0025><U0073><U0020><U0025><U0068><U0020><U0025><U0065><U0020><U0025><U0072><U0025><U004E>/
+<U0025><U0043><U002D><U0025><U007A><U0020><U0025><U0054><U0025><U004E><U0025><U0063><U0025><U004E>"
+END LC_ADDRESS
+
+LC_TELEPHONE
+tel_int_fmt    "<U002B><U0025><U0063><U0020><U0025><U0061><U0020><U0025><U006C>"
+END LC_TELEPHONE
+
+LC_MEASUREMENT
+measurement    1
+END LC_MEASUREMENT
+
+LC_IDENTIFICATION
+END LC_IDENTIFICATION
Index: trunk/src/libctests/glibc/localedata/tst-ctype-de_DE.ISO-8859-1.in
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-ctype-de_DE.ISO-8859-1.in	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-ctype-de_DE.ISO-8859-1.in	(revision 2036)
@@ -0,0 +1,56 @@
+lower    ¡¢£€¥Š§š©ª«¬­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ
+        000000000000000000000100000000000000000000000000
+lower   ÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
+        000000000000000111111111111111111111111011111111
+upper    ¡¢£€¥Š§š©ª«¬­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ
+        000000000000000000000000000000001111111111111111
+upper   ÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
+        111111101111111000000000000000000000000000000000
+alpha    ¡¢£€¥Š§š©ª«¬­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ
+        000000000010000000000100001000001111111111111111
+alpha   ÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
+        111111101111111111111111111111111111111011111111
+digit    ¡¢£€¥Š§š©ª«¬­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ
+        000000000000000000000000000000000000000000000000
+digit   ÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
+        000000000000000000000000000000000000000000000000
+xdigit   ¡¢£€¥Š§š©ª«¬­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ
+        000000000000000000000000000000000000000000000000
+xdigit  ÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
+        000000000000000000000000000000000000000000000000
+space    ¡¢£€¥Š§š©ª«¬­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ
+        000000000000000000000000000000000000000000000000
+space   ÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
+        000000000000000000000000000000000000000000000000
+print    ¡¢£€¥Š§š©ª«¬­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ
+        111111111111111111111111111111111111111111111111
+print   ÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
+        111111111111111111111111111111111111111111111111
+graph    ¡¢£€¥Š§š©ª«¬­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ
+        111111111111111111111111111111111111111111111111
+graph   ÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
+        111111111111111111111111111111111111111111111111
+blank    ¡¢£€¥Š§š©ª«¬­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ
+        000000000000000000000000000000000000000000000000
+blank   ÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
+        000000000000000000000000000000000000000000000000
+cntrl    ¡¢£€¥Š§š©ª«¬­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ
+        000000000000000000000000000000000000000000000000
+cntrl   ÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
+        000000000000000000000000000000000000000000000000
+punct    ¡¢£€¥Š§š©ª«¬­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ
+        111111111101111111111011110111110000000000000000
+punct   ÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
+        000000010000000000000000000000000000000100000000
+alnum    ¡¢£€¥Š§š©ª«¬­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ
+        000000000010000000000100001000001111111111111111
+alnum   ÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
+        111111101111111111111111111111111111111011111111
+tolower  ¡¢£€¥Š§š©ª«¬­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ
+         ¡¢£€¥Š§š©ª«¬­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿àáâãäåæçèéêëìíîï
+tolower ÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
+        ðñòóôõö×øùúûüýþßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
+toupper  ¡¢£€¥Š§š©ª«¬­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ
+         ¡¢£€¥Š§š©ª«¬­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ
+toupper ÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
+        ÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ÷ØÙÚÛÜÝÞÿ
Index: trunk/src/libctests/glibc/localedata/tst-ctype.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-ctype.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-ctype.c	(revision 2036)
@@ -0,0 +1,450 @@
+/* Copyright (C) 2000,02 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.org>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <ctype.h>
+#include <locale.h>
+#include <langinfo.h>
+#include <stdio.h>
+#include <string.h>
+
+
+static const char lower[] = "abcdefghijklmnopqrstuvwxyz";
+static const char upper[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+static const char digits[] = "0123456789";
+static const char cntrl[] = "\
+\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\
+\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f ";
+
+
+static struct classes
+{
+  const char *name;
+  int mask;
+} classes[] =
+{
+#define ENTRY(name) { #name, _IS##name }
+  ENTRY (upper),
+  ENTRY (lower),
+  ENTRY (alpha),
+  ENTRY (digit),
+  ENTRY (xdigit),
+  ENTRY (space),
+  ENTRY (print),
+  ENTRY (graph),
+  ENTRY (blank),
+  ENTRY (cntrl),
+  ENTRY (punct),
+  ENTRY (alnum)
+};
+#define nclasses (sizeof (classes) / sizeof (classes[0]))
+
+
+#define FAIL(str, args...) \
+  {									      \
+    printf ("      " str "\n", ##args);					      \
+    ++errors;								      \
+  }
+
+
+int
+main (void)
+{
+  const char *cp;
+  const char *cp2;
+  int errors = 0;
+  char *inpline = NULL;
+  size_t inplinelen = 0;
+  char *resline = NULL;
+  size_t reslinelen = 0;
+  size_t n;
+  const unsigned short int *__ctype_b;
+
+  setlocale (LC_ALL, "");
+
+  printf ("Testing the ctype data of the `%s' locale\n",
+	  setlocale (LC_CTYPE, NULL));
+
+  __ctype_b = ((const unsigned short *) nl_langinfo (_NL_CTYPE_CLASS)) + 128;
+
+#if 0
+  /* Just for debugging.  */
+
+  /* Contents of the class array.  */
+  printf ("\
+upper = %04x  lower = %04x  alpha = %04x  digit = %04x  xdigit = %04x\n\
+space = %04x  print = %04x  graph = %04x  blank = %04x  cntrl  = %04x\n\
+punct = %04x  alnum = %04x\n",
+	  _ISupper, _ISlower, _ISalpha, _ISdigit, _ISxdigit,
+	  _ISspace, _ISprint, _ISgraph, _ISblank, _IScntrl,
+	  _ISpunct, _ISalnum);
+
+  while (n < 256)
+    {
+      if (n % 8 == 0)
+	printf ("%02x: ", n);
+      printf ("%04x%s", __ctype_b[n], (n + 1) % 8 == 0 ? "\n" : " ");
+      ++n;
+    }
+#endif
+
+  puts ("  Test of ASCII character range\n    special NUL byte handling");
+  if (isupper ('\0'))
+    FAIL ("isupper ('\\0') is true");
+  if (islower ('\0'))
+    FAIL ("islower ('\\0') is true");
+  if (isalpha ('\0'))
+    FAIL ("isalpha ('\\0') is true");
+  if (isdigit ('\0'))
+    FAIL ("isdigit ('\\0') is true");
+  if (isxdigit ('\0'))
+    FAIL ("isxdigit ('\\0') is true");
+  if (isspace ('\0'))
+    FAIL ("isspace ('\\0') is true");
+  if (isprint ('\0'))
+    FAIL ("isprint ('\\0') is true");
+  if (isgraph ('\0'))
+    FAIL ("isgraph ('\\0') is true");
+  if (isblank ('\0'))
+    FAIL ("isblank ('\\0') is true");
+  if (! iscntrl ('\0'))
+    FAIL ("iscntrl ('\\0') not true");
+  if (ispunct ('\0'))
+    FAIL ("ispunct ('\\0') is true");
+  if (isalnum ('\0'))
+    FAIL ("isalnum ('\\0') is true");
+
+  puts ("    islower()");
+  for (cp = lower; *cp != '\0'; ++cp)
+    if (! islower (*cp))
+      FAIL ("islower ('%c') not true", *cp);
+  for (cp = upper; *cp != '\0'; ++cp)
+    if (islower (*cp))
+      FAIL ("islower ('%c') is true", *cp);
+  for (cp = digits; *cp != '\0'; ++cp)
+    if (islower (*cp))
+      FAIL ("islower ('%c') is true", *cp);
+  for (cp = cntrl; *cp != '\0'; ++cp)
+    if (islower (*cp))
+      FAIL ("islower ('\\x%02x') is true", *cp);
+
+  puts ("    isupper()");
+  for (cp = lower; *cp != '\0'; ++cp)
+    if (isupper (*cp))
+      FAIL ("isupper ('%c') is true", *cp);
+  for (cp = upper; *cp != '\0'; ++cp)
+    if (! isupper (*cp))
+      FAIL ("isupper ('%c') not true", *cp);
+  for (cp = digits; *cp != '\0'; ++cp)
+    if (isupper (*cp))
+      FAIL ("isupper ('%c') is true", *cp);
+  for (cp = cntrl; *cp != '\0'; ++cp)
+    if (isupper (*cp))
+      FAIL ("isupper ('\\x%02x') is true", *cp);
+
+  puts ("    isalpha()");
+  for (cp = lower; *cp != '\0'; ++cp)
+    if (! isalpha (*cp))
+      FAIL ("isalpha ('%c') not true", *cp);
+  for (cp = upper; *cp != '\0'; ++cp)
+    if (! isalpha (*cp))
+      FAIL ("isalpha ('%c') not true", *cp);
+  for (cp = digits; *cp != '\0'; ++cp)
+    if (isalpha (*cp))
+      FAIL ("isalpha ('%c') is true", *cp);
+  for (cp = cntrl; *cp != '\0'; ++cp)
+    if (isalpha (*cp))
+      FAIL ("isalpha ('\\x%02x') is true", *cp);
+
+  puts ("    isdigit()");
+  for (cp = lower; *cp != '\0'; ++cp)
+    if (isdigit (*cp))
+      FAIL ("isdigit ('%c') is true", *cp);
+  for (cp = upper; *cp != '\0'; ++cp)
+    if (isdigit (*cp))
+      FAIL ("isdigit ('%c') is true", *cp);
+  for (cp = digits; *cp != '\0'; ++cp)
+    if (! isdigit (*cp))
+      FAIL ("isdigit ('%c') not true", *cp);
+  for (cp = cntrl; *cp != '\0'; ++cp)
+    if (isdigit (*cp))
+      FAIL ("isdigit ('\\x%02x') is true", *cp);
+
+  puts ("    isxdigit()");
+  for (cp = lower; *cp != '\0'; ++cp)
+    if ((! isxdigit (*cp) && cp - lower < 6)
+	|| (isxdigit (*cp) && cp - lower >= 6))
+      FAIL ("isxdigit ('%c') %s true", *cp, cp - upper < 6 ? "not" : "is");
+  for (cp = upper; *cp != '\0'; ++cp)
+    if ((! isxdigit (*cp) && cp - upper < 6)
+	|| (isxdigit (*cp) && cp - upper >= 6))
+      FAIL ("isxdigit ('%c') %s true", *cp, cp - upper < 6 ? "not" : "is");
+  for (cp = digits; *cp != '\0'; ++cp)
+    if (! isxdigit (*cp))
+      FAIL ("isxdigit ('%c') not true", *cp);
+  for (cp = cntrl; *cp != '\0'; ++cp)
+    if (isxdigit (*cp))
+      FAIL ("isxdigit ('\\x%02x') is true", *cp);
+
+  puts ("    isspace()");
+  for (cp = lower; *cp != '\0'; ++cp)
+    if (isspace (*cp))
+      FAIL ("isspace ('%c') is true", *cp);
+  for (cp = upper; *cp != '\0'; ++cp)
+    if (isspace (*cp))
+      FAIL ("isspace ('%c') is true", *cp);
+  for (cp = digits; *cp != '\0'; ++cp)
+    if (isspace (*cp))
+      FAIL ("isspace ('%c') is true", *cp);
+  for (cp = cntrl; *cp != '\0'; ++cp)
+    if ((isspace (*cp) && ((*cp < '\x09' || *cp > '\x0d') && *cp != ' '))
+	|| (! isspace (*cp)
+	    && ((*cp >= '\x09' && *cp <= '\x0d') || *cp == ' ')))
+      FAIL ("isspace ('\\x%02x') %s true", *cp,
+	    (*cp < '\x09' || *cp > '\x0d') ? "is" : "not");
+
+  puts ("    isprint()");
+  for (cp = lower; *cp != '\0'; ++cp)
+    if (! isprint (*cp))
+      FAIL ("isprint ('%c') not true", *cp);
+  for (cp = upper; *cp != '\0'; ++cp)
+    if (! isprint (*cp))
+      FAIL ("isprint ('%c') not true", *cp);
+  for (cp = digits; *cp != '\0'; ++cp)
+    if (! isprint (*cp))
+      FAIL ("isprint ('%c') not true", *cp);
+  for (cp = cntrl; *cp != '\0'; ++cp)
+    if ((isprint (*cp) && *cp != ' ')
+	|| (! isprint (*cp) && *cp == ' '))
+      FAIL ("isprint ('\\x%02x') is true", *cp);
+
+  puts ("    isgraph()");
+  for (cp = lower; *cp != '\0'; ++cp)
+    if (! isgraph (*cp))
+      FAIL ("isgraph ('%c') not true", *cp);
+  for (cp = upper; *cp != '\0'; ++cp)
+    if (! isgraph (*cp))
+      FAIL ("isgraph ('%c') not true", *cp);
+  for (cp = digits; *cp != '\0'; ++cp)
+    if (! isgraph (*cp))
+      FAIL ("isgraph ('%c') not true", *cp);
+  for (cp = cntrl; *cp != '\0'; ++cp)
+    if (isgraph (*cp))
+      FAIL ("isgraph ('\\x%02x') is true", *cp);
+
+  puts ("    isblank()");
+  for (cp = lower; *cp != '\0'; ++cp)
+    if (isblank (*cp))
+      FAIL ("isblank ('%c') is true", *cp);
+  for (cp = upper; *cp != '\0'; ++cp)
+    if (isblank (*cp))
+      FAIL ("isblank ('%c') is true", *cp);
+  for (cp = digits; *cp != '\0'; ++cp)
+    if (isblank (*cp))
+      FAIL ("isblank ('%c') is true", *cp);
+  for (cp = cntrl; *cp != '\0'; ++cp)
+    if ((isblank (*cp) && *cp != '\x09' && *cp != ' ')
+	|| (! isblank (*cp) && (*cp == '\x09' || *cp == ' ')))
+      FAIL ("isblank ('\\x%02x') %s true", *cp, *cp != '\x09' ? "is" : "not");
+
+  puts ("    iscntrl()");
+  for (cp = lower; *cp != '\0'; ++cp)
+    if (iscntrl (*cp))
+      FAIL ("iscntrl ('%c') is true", *cp);
+  for (cp = upper; *cp != '\0'; ++cp)
+    if (iscntrl (*cp))
+      FAIL ("iscntrl ('%c') is true", *cp);
+  for (cp = digits; *cp != '\0'; ++cp)
+    if (iscntrl (*cp))
+      FAIL ("iscntrl ('%c') is true", *cp);
+  for (cp = cntrl; *cp != '\0'; ++cp)
+    if ((iscntrl (*cp) && *cp == ' ')
+	|| (! iscntrl (*cp) && *cp != ' '))
+      FAIL ("iscntrl ('\\x%02x') not true", *cp);
+
+  puts ("    ispunct()");
+  for (cp = lower; *cp != '\0'; ++cp)
+    if (ispunct (*cp))
+      FAIL ("ispunct ('%c') is true", *cp);
+  for (cp = upper; *cp != '\0'; ++cp)
+    if (ispunct (*cp))
+      FAIL ("ispunct ('%c') is true", *cp);
+  for (cp = digits; *cp != '\0'; ++cp)
+    if (ispunct (*cp))
+      FAIL ("ispunct ('%c') is true", *cp);
+  for (cp = cntrl; *cp != '\0'; ++cp)
+    if (ispunct (*cp))
+      FAIL ("ispunct ('\\x%02x') is true", *cp);
+
+  puts ("    isalnum()");
+  for (cp = lower; *cp != '\0'; ++cp)
+    if (! isalnum (*cp))
+      FAIL ("isalnum ('%c') not true", *cp);
+  for (cp = upper; *cp != '\0'; ++cp)
+    if (! isalnum (*cp))
+      FAIL ("isalnum ('%c') not true", *cp);
+  for (cp = digits; *cp != '\0'; ++cp)
+    if (! isalnum (*cp))
+      FAIL ("isalnum ('%c') not true", *cp);
+  for (cp = cntrl; *cp != '\0'; ++cp)
+    if (isalnum (*cp))
+      FAIL ("isalnum ('\\x%02x') is true", *cp);
+
+
+  puts ("    tolower()");
+  for (cp = lower; *cp != '\0'; ++cp)
+    if (tolower (*cp) != *cp)
+      FAIL ("tolower ('%c') != '%c'", *cp, *cp);
+  for (cp = upper, cp2 = lower; *cp != '\0'; ++cp, ++cp2)
+    if (tolower (*cp) != *cp2)
+      FAIL ("tolower ('%c') != '%c'", *cp, *cp2);
+  for (cp = digits; *cp != '\0'; ++cp)
+    if (tolower (*cp) != *cp)
+      FAIL ("tolower ('%c') != '%c'", *cp, *cp);
+  for (cp = cntrl; *cp != '\0'; ++cp)
+    if (tolower (*cp) != *cp)
+      FAIL ("tolower ('\\x%02x') != '\\x%02x'", *cp, *cp);
+
+  puts ("    toupper()");
+  for (cp = lower, cp2 = upper; *cp != '\0'; ++cp, ++cp2)
+    if (toupper (*cp) != *cp2)
+      FAIL ("toupper ('%c') != '%c'", *cp, *cp2);
+  for (cp = upper; *cp != '\0'; ++cp)
+    if (toupper (*cp) != *cp)
+      FAIL ("toupper ('%c') != '%c'", *cp, *cp);
+  for (cp = digits; *cp != '\0'; ++cp)
+    if (toupper (*cp) != *cp)
+      FAIL ("toupper ('%c') != '%c'", *cp, *cp);
+  for (cp = cntrl; *cp != '\0'; ++cp)
+    if (toupper (*cp) != *cp)
+      FAIL ("toupper ('\\x%02x') != '\\x%02x'", *cp, *cp);
+
+
+  /* Now some locale specific tests.  */
+  while (! feof (stdin))
+    {
+      unsigned char *inp;
+      unsigned char *resp;
+
+      if (getline (&inpline, &inplinelen, stdin) <= 0
+	  || getline (&resline, &reslinelen, stdin) <= 0)
+	break;
+
+      inp = strchr (inpline, '\n');
+      if (inp != NULL)
+	*inp = '\0';
+      resp = strchr (resline, '\n');
+      if (resp != NULL)
+	*resp = '\0';
+
+      inp = inpline;
+      while (*inp != ' ' && *inp != '\t' && *inp && *inp != '\n'
+	     && *inp != '\0')
+	++inp;
+
+      if (*inp == '\0')
+	{
+	  printf ("line \"%s\" is without content\n", inpline);
+	  continue;
+	}
+      *inp++ = '\0';
+      while (*inp == ' ' || *inp == '\t')
+	++inp;
+
+      /* Try all classes.  */
+      for (n = 0; n < nclasses; ++n)
+	if (strcmp (inpline, classes[n].name) == 0)
+	  break;
+
+      resp = resline;
+      while (*resp == ' ' || *resp == '\t')
+	++resp;
+
+      if (strlen (inp) != strlen (resp))
+	{
+	  printf ("lines \"%.20s\"... and \"%.20s\" have not the same length\n",
+		  inp, resp);
+	  continue;
+	}
+
+      if (n < nclasses)
+	{
+	  if (strspn (resp, "01") != strlen (resp))
+	    {
+	      printf ("result string \"%s\" malformed\n", resp);
+	      continue;
+	    }
+
+	  printf ("  Locale-specific tests for `%s'\n", inpline);
+
+	  while (*inp != '\0' && *inp != '\n')
+	    {
+	      if (((__ctype_b[(unsigned int) *inp] & classes[n].mask) != 0)
+		  != (*resp != '0'))
+		{
+		  printf ("    is%s('%c' = '\\x%02x') %s true\n", inpline,
+			  *inp, *inp, *resp == '1' ? "not" : "is");
+		  ++errors;
+		}
+	      ++inp;
+	      ++resp;
+	    }
+	}
+      else if (strcmp (inpline, "tolower") == 0)
+	{
+	  while (*inp != '\0')
+	    {
+	      if (tolower (*inp) != *resp)
+		{
+		  printf ("    tolower('%c' = '\\x%02x') != '%c'\n",
+			  *inp, *inp, *resp);
+		  ++errors;
+		}
+	      ++inp;
+	      ++resp;
+	    }
+	}
+      else if (strcmp (inpline, "toupper") == 0)
+	{
+	  while (*inp != '\0')
+	    {
+	      if (toupper (*inp) != *resp)
+		{
+		  printf ("    toupper('%c' = '\\x%02x') != '%c'\n",
+			  *inp, *inp, *resp);
+		  ++errors;
+		}
+	      ++inp;
+	      ++resp;
+	    }
+	}
+      else
+	printf ("\"%s\": unknown class or map\n", inpline);
+    }
+
+
+  if (errors != 0)
+    {
+      printf ("  %d error%s for `%s' locale\n\n\n", errors,
+	      errors == 1 ? "" : "s", setlocale (LC_ALL, NULL));
+      return 1;
+    }
+
+  printf ("  No errors for `%s' locale\n\n\n", setlocale (LC_ALL, NULL));
+  return 0;
+}
Index: trunk/src/libctests/glibc/localedata/tst-ctype.sh
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-ctype.sh	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-ctype.sh	(revision 2036)
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Testing the implementation of the isxxx() and toxxx() functions.
+# Copyright (C) 2000 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+common_objpfx=$1; shift
+tst_ctype=$1; shift
+status=0
+
+# Run the test programs.
+rm -f ${common_objpfx}localedata/tst-ctype.out
+for loc in C de_DE.ISO-8859-1 de_DE.UTF-8 en_US.ANSI_X3.4-1968 ja_JP.EUC-JP; do
+  if test -f tst-ctype-$loc.in; then
+    input=tst-ctype-$loc.in
+  else
+    input=/dev/null
+  fi
+  LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
+  LC_ALL=$loc ${tst_ctype} < $input \
+    >> ${common_objpfx}localedata/tst-ctype.out || status=1
+done
+
+exit $status
Index: trunk/src/libctests/glibc/localedata/tst-digits.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-digits.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-digits.c	(revision 2036)
@@ -0,0 +1,249 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.org>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <ctype.h>
+#include <langinfo.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <wchar.h>
+#include <wctype.h>
+#include <sys/types.h>
+
+
+#define ZERO  "\xe2\x82\x80"
+#define ONE   "\xe2\x82\x81"
+#define TWO   "\xe2\x82\x82"
+#define THREE "\xe2\x82\x83"
+#define FOUR  "\xe2\x82\x84"
+#define FIVE  "\xe2\x82\x85"
+#define SIX   "\xe2\x82\x86"
+#define SEVEN "\xe2\x82\x87"
+#define EIGHT "\xe2\x82\x88"
+#define NINE  "\xe2\x82\x89"
+
+static struct printf_int_test
+{
+  int n;
+  const char *format;
+  const char *expected;
+} printf_int_tests[] =
+{
+  {       0, "%I'10d", "       " ZERO },
+  {       1, "%I'10d", "       " ONE },
+  {       2, "%I'10d", "       " TWO },
+  {       3, "%I'10d", "       " THREE },
+  {       4, "%I'10d", "       " FOUR },
+  {       5, "%I'10d", "       " FIVE },
+  {       6, "%I'10d", "       " SIX },
+  {       7, "%I'10d", "       " SEVEN },
+  {       8, "%I'10d", "       " EIGHT },
+  {       9, "%I'10d", "       " NINE },
+  {      11, "%I'10d", "    " ONE ONE },
+  {      12, "%I'10d", "    " ONE TWO },
+  {     123, "%I10d",  " " ONE TWO THREE },
+  {     123, "%I'10d", " " ONE TWO THREE },
+  {    1234, "%I10d",  ONE TWO THREE FOUR },
+  {    1234, "%I'10d", ONE "," TWO THREE FOUR },
+  {   12345, "%I'10d", ONE TWO "," THREE FOUR FIVE },
+  {  123456, "%I'10d", ONE TWO THREE "," FOUR FIVE SIX },
+  { 1234567, "%I'10d", ONE "," TWO THREE FOUR "," FIVE SIX SEVEN }
+};
+#define nprintf_int_tests \
+  (sizeof (printf_int_tests) / sizeof (printf_int_tests[0]))
+
+#define WZERO  L"\x2080"
+#define WONE   L"\x2081"
+#define WTWO   L"\x2082"
+#define WTHREE L"\x2083"
+#define WFOUR  L"\x2084"
+#define WFIVE  L"\x2085"
+#define WSIX   L"\x2086"
+#define WSEVEN L"\x2087"
+#define WEIGHT L"\x2088"
+#define WNINE  L"\x2089"
+
+static struct wprintf_int_test
+{
+  int n;
+  const wchar_t *format;
+  const wchar_t *expected;
+} wprintf_int_tests[] =
+{
+  {       0, L"%I'10d", L"         " WZERO },
+  {       1, L"%I'10d", L"         " WONE },
+  {       2, L"%I'10d", L"         " WTWO },
+  {       3, L"%I'10d", L"         " WTHREE },
+  {       4, L"%I'10d", L"         " WFOUR },
+  {       5, L"%I'10d", L"         " WFIVE },
+  {       6, L"%I'10d", L"         " WSIX },
+  {       7, L"%I'10d", L"         " WSEVEN },
+  {       8, L"%I'10d", L"         " WEIGHT },
+  {       9, L"%I'10d", L"         " WNINE },
+  {      11, L"%I'10d", L"        " WONE WONE },
+  {      12, L"%I'10d", L"        " WONE WTWO },
+  {     123, L"%I10d",  L"       " WONE WTWO WTHREE },
+  {     123, L"%I'10d", L"       " WONE WTWO WTHREE },
+  {    1234, L"%I10d",  L"      " WONE WTWO WTHREE WFOUR },
+  {    1234, L"%I'10d", L"     " WONE L"," WTWO WTHREE WFOUR },
+  {   12345, L"%I'10d", L"    " WONE WTWO L"," WTHREE WFOUR WFIVE },
+  {  123456, L"%I'10d", L"   " WONE WTWO WTHREE L"," WFOUR WFIVE WSIX },
+  { 1234567, L"%I'10d", L" " WONE L"," WTWO WTHREE WFOUR L"," WFIVE WSIX WSEVEN }
+};
+#define nwprintf_int_tests \
+  (sizeof (wprintf_int_tests) / sizeof (wprintf_int_tests[0]))
+
+
+int
+main (void)
+{
+  int cnt;
+  int failures;
+  int status;
+
+  if (setlocale (LC_ALL, "test7") == NULL)
+    {
+      puts ("cannot set locale `test7'");
+      exit (1);
+    }
+  printf ("CODESET = \"%s\"\n", nl_langinfo (CODESET));
+
+  /* First: printf tests.  */
+  failures = 0;
+  for (cnt = 0; cnt < (int) nprintf_int_tests; ++cnt)
+    {
+      char buf[100];
+      ssize_t n;
+
+      n = snprintf (buf, sizeof buf, printf_int_tests[cnt].format,
+		    printf_int_tests[cnt].n);
+
+      printf ("%3d: got \"%s\", expected \"%s\"",
+	      cnt, buf, printf_int_tests[cnt].expected);
+
+      if (n != (ssize_t) strlen (printf_int_tests[cnt].expected)
+	  || strcmp (buf, printf_int_tests[cnt].expected) != 0)
+	{
+	  puts ("  -> FAILED");
+	  ++failures;
+	}
+      else
+	puts ("  -> OK");
+    }
+
+  printf ("%d failures in printf tests\n", failures);
+  status = failures != 0;
+
+  /* wprintf tests.  */
+  failures = 0;
+  for (cnt = 0; cnt < (int) nwprintf_int_tests; ++cnt)
+    {
+      wchar_t buf[100];
+      ssize_t n;
+
+      n = swprintf (buf, sizeof buf / sizeof (buf[0]),
+		    wprintf_int_tests[cnt].format,
+		    wprintf_int_tests[cnt].n);
+
+      printf ("%3d: got \"%ls\", expected \"%ls\"",
+	      cnt, buf, wprintf_int_tests[cnt].expected);
+
+      if (n != (ssize_t) wcslen (wprintf_int_tests[cnt].expected)
+	  || wcscmp (buf, wprintf_int_tests[cnt].expected) != 0)
+	{
+	  puts ("  -> FAILED");
+	  ++failures;
+	}
+      else
+	puts ("  -> OK");
+    }
+
+  printf ("%d failures in wprintf tests\n", failures);
+  status = failures != 0;
+
+  /* ctype tests.  This makes sure that the multibyte chracter digit
+     representations are not handle in this table.  */
+  failures = 0;
+  for (cnt = 0; cnt < 256; ++cnt)
+    if (cnt >= '0' && cnt <= '9')
+      {
+	if (! isdigit (cnt))
+	  {
+	    printf ("isdigit ('%c') == 0\n", cnt);
+	    ++failures;
+	  }
+      }
+    else
+      {
+	if (isdigit (cnt))
+	  {
+	    printf ("isdigit (%d) != 0\n", cnt);
+	    ++failures;
+	  }
+      }
+
+  printf ("%d failures in ctype tests\n", failures);
+  status = failures != 0;
+
+  /* wctype tests.  This makes sure the second set of digits is also
+     recorded.  */
+  failures = 0;
+  for (cnt = 0; cnt < 256; ++cnt)
+    if (cnt >= '0' && cnt <= '9')
+      {
+	if (! iswdigit (cnt))
+	  {
+	    printf ("iswdigit (L'%c') == 0\n", cnt);
+	    ++failures;
+	  }
+      }
+    else
+      {
+	if (iswdigit (cnt))
+	  {
+	    printf ("iswdigit (%d) != 0\n", cnt);
+	    ++failures;
+	  }
+      }
+
+  for (cnt = 0x2070; cnt < 0x2090; ++cnt)
+    if (cnt >= 0x2080 && cnt <= 0x2089)
+      {
+	if (! iswdigit (cnt))
+	  {
+	    printf ("iswdigit (U%04X) == 0\n", cnt);
+	    ++failures;
+	  }
+      }
+    else
+      {
+	if (iswdigit (cnt))
+	  {
+	    printf ("iswdigit (U%04X) != 0\n", cnt);
+	    ++failures;
+	  }
+      }
+
+  printf ("%d failures in wctype tests\n", failures);
+  status = failures != 0;
+
+  return status;
+}
Index: trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_n01y12
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_n01y12	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_n01y12	(revision 2036)
@@ -0,0 +1,32 @@
+# One of a set of test locales for strfmon()
+
+# The six characters after the "_" in the locale name indicate
+# the last six LC_MONETARY values below.
+
+LC_CTYPE
+copy "POSIX"
+END LC_CTYPE
+
+LC_MONETARY
+int_curr_symbol         "<U0055><U0053><U0043><U0020>"
+currency_symbol         "<U0024>"
+mon_decimal_point       "<U002E>"
+mon_thousands_sep       "<U002C>"
+mon_grouping            3;3
+positive_sign           "<U002B>"
+negative_sign           "<U002D>"
+int_frac_digits         2
+frac_digits             2
+p_cs_precedes           0
+p_sign_posn             0
+p_sep_by_space          1
+n_cs_precedes           1
+n_sign_posn             1
+n_sep_by_space          2
+int_p_cs_precedes       0
+int_p_sign_posn         0
+int_p_sep_by_space      1
+int_n_cs_precedes       1
+int_n_sign_posn         1
+int_n_sep_by_space      2
+END LC_MONETARY
Index: trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_n02n40
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_n02n40	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_n02n40	(revision 2036)
@@ -0,0 +1,32 @@
+# One of a set of test locales for strfmon()
+
+# The six characters after the "_" in the locale name indicate
+# the last six LC_MONETARY values below.
+
+LC_CTYPE
+copy "POSIX"
+END LC_CTYPE
+
+LC_MONETARY
+int_curr_symbol         "<U0055><U0053><U0043><U0020>"
+currency_symbol         "<U0024>"
+mon_decimal_point       "<U002E>"
+mon_thousands_sep       "<U002C>"
+mon_grouping            3;3
+positive_sign           "<U002B>"
+negative_sign           "<U002D>"
+int_frac_digits         2
+frac_digits             2
+p_cs_precedes           0
+p_sign_posn             0
+p_sep_by_space          2
+n_cs_precedes           0
+n_sign_posn             4
+n_sep_by_space          0
+int_p_cs_precedes       0
+int_p_sign_posn         0
+int_p_sep_by_space      2
+int_n_cs_precedes       0
+int_n_sign_posn         4
+int_n_sep_by_space      0
+END LC_MONETARY
Index: trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_n10y31
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_n10y31	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_n10y31	(revision 2036)
@@ -0,0 +1,32 @@
+# One of a set of test locales for strfmon()
+
+# The six characters after the "_" in the locale name indicate
+# the last six LC_MONETARY values below.
+
+LC_CTYPE
+copy "POSIX"
+END LC_CTYPE
+
+LC_MONETARY
+int_curr_symbol         "<U0055><U0053><U0043><U0020>"
+currency_symbol         "<U0024>"
+mon_decimal_point       "<U002E>"
+mon_thousands_sep       "<U002C>"
+mon_grouping            3;3
+positive_sign           "<U002B>"
+negative_sign           "<U002D>"
+int_frac_digits         2
+frac_digits             2
+p_cs_precedes           0
+p_sign_posn             1
+p_sep_by_space          0
+n_cs_precedes           1
+n_sign_posn             3
+n_sep_by_space          1
+int_p_cs_precedes       0
+int_p_sign_posn         1
+int_p_sep_by_space      0
+int_n_cs_precedes       1
+int_n_sign_posn         3
+int_n_sep_by_space      1
+END LC_MONETARY
Index: trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_n11y41
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_n11y41	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_n11y41	(revision 2036)
@@ -0,0 +1,32 @@
+# One of a set of test locales for strfmon()
+
+# The six characters after the "_" in the locale name indicate
+# the last six LC_MONETARY values below.
+
+LC_CTYPE
+copy "POSIX"
+END LC_CTYPE
+
+LC_MONETARY
+int_curr_symbol         "<U0055><U0053><U0043><U0020>"
+currency_symbol         "<U0024>"
+mon_decimal_point       "<U002E>"
+mon_thousands_sep       "<U002C>"
+mon_grouping            3;3
+positive_sign           "<U002B>"
+negative_sign           "<U002D>"
+int_frac_digits         2
+frac_digits             2
+p_cs_precedes           0
+p_sign_posn             1
+p_sep_by_space          1
+n_cs_precedes           1
+n_sign_posn             4
+n_sep_by_space          1
+int_p_cs_precedes       0
+int_p_sign_posn         1
+int_p_sep_by_space      1
+int_n_cs_precedes       1
+int_n_sign_posn         4
+int_n_sep_by_space      1
+END LC_MONETARY
Index: trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_n12y11
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_n12y11	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_n12y11	(revision 2036)
@@ -0,0 +1,32 @@
+# One of a set of test locales for strfmon()
+
+# The six characters after the "_" in the locale name indicate
+# the last six LC_MONETARY values below.
+
+LC_CTYPE
+copy "POSIX"
+END LC_CTYPE
+
+LC_MONETARY
+int_curr_symbol         "<U0055><U0053><U0043><U0020>"
+currency_symbol         "<U0024>"
+mon_decimal_point       "<U002E>"
+mon_thousands_sep       "<U002C>"
+mon_grouping            3;3
+positive_sign           "<U002B>"
+negative_sign           "<U002D>"
+int_frac_digits         2
+frac_digits             2
+p_cs_precedes           0
+p_sign_posn             1
+p_sep_by_space          2
+n_cs_precedes           1
+n_sign_posn             1
+n_sep_by_space          1
+int_p_cs_precedes       0
+int_p_sign_posn         1
+int_p_sep_by_space      2
+int_n_cs_precedes       1
+int_n_sign_posn         1
+int_n_sep_by_space      1
+END LC_MONETARY
Index: trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_n20n32
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_n20n32	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_n20n32	(revision 2036)
@@ -0,0 +1,32 @@
+# One of a set of test locales for strfmon()
+
+# The six characters after the "_" in the locale name indicate
+# the last six LC_MONETARY values below.
+
+LC_CTYPE
+copy "POSIX"
+END LC_CTYPE
+
+LC_MONETARY
+int_curr_symbol         "<U0055><U0053><U0043><U0020>"
+currency_symbol         "<U0024>"
+mon_decimal_point       "<U002E>"
+mon_thousands_sep       "<U002C>"
+mon_grouping            3;3
+positive_sign           "<U002B>"
+negative_sign           "<U002D>"
+int_frac_digits         2
+frac_digits             2
+p_cs_precedes           0
+p_sign_posn             2
+p_sep_by_space          0
+n_cs_precedes           0
+n_sign_posn             3
+n_sep_by_space          2
+int_p_cs_precedes       0
+int_p_sign_posn         2
+int_p_sep_by_space      0
+int_n_cs_precedes       0
+int_n_sign_posn         3
+int_n_sep_by_space      2
+END LC_MONETARY
Index: trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_n30y20
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_n30y20	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_n30y20	(revision 2036)
@@ -0,0 +1,32 @@
+# One of a set of test locales for strfmon()
+
+# The six characters after the "_" in the locale name indicate
+# the last six LC_MONETARY values below.
+
+LC_CTYPE
+copy "POSIX"
+END LC_CTYPE
+
+LC_MONETARY
+int_curr_symbol         "<U0055><U0053><U0043><U0020>"
+currency_symbol         "<U0024>"
+mon_decimal_point       "<U002E>"
+mon_thousands_sep       "<U002C>"
+mon_grouping            3;3
+positive_sign           "<U002B>"
+negative_sign           "<U002D>"
+int_frac_digits         2
+frac_digits             2
+p_cs_precedes           0
+p_sign_posn             3
+p_sep_by_space          0
+n_cs_precedes           1
+n_sign_posn             2
+n_sep_by_space          0
+int_p_cs_precedes       0
+int_p_sign_posn         3
+int_p_sep_by_space      0
+int_n_cs_precedes       1
+int_n_sign_posn         2
+int_n_sep_by_space      0
+END LC_MONETARY
Index: trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_n41n00
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_n41n00	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_n41n00	(revision 2036)
@@ -0,0 +1,32 @@
+# One of a set of test locales for strfmon()
+
+# The six characters after the "_" in the locale name indicate
+# the last six LC_MONETARY values below.
+
+LC_CTYPE
+copy "POSIX"
+END LC_CTYPE
+
+LC_MONETARY
+int_curr_symbol         "<U0055><U0053><U0043><U0020>"
+currency_symbol         "<U0024>"
+mon_decimal_point       "<U002E>"
+mon_thousands_sep       "<U002C>"
+mon_grouping            3;3
+positive_sign           "<U002B>"
+negative_sign           "<U002D>"
+int_frac_digits         2
+frac_digits             2
+p_cs_precedes           0
+p_sign_posn             4
+p_sep_by_space          1
+n_cs_precedes           0
+n_sign_posn             0
+n_sep_by_space          0
+int_p_cs_precedes       0
+int_p_sign_posn         4
+int_p_sep_by_space      1
+int_n_cs_precedes       0
+int_n_sign_posn         0
+int_n_sep_by_space      0
+END LC_MONETARY
Index: trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_y01y10
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_y01y10	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_y01y10	(revision 2036)
@@ -0,0 +1,32 @@
+# One of a set of test locales for strfmon()
+
+# The six characters after the "_" in the locale name indicate
+# the last six LC_MONETARY values below.
+
+LC_CTYPE
+copy "POSIX"
+END LC_CTYPE
+
+LC_MONETARY
+int_curr_symbol         "<U0055><U0053><U0043><U0020>"
+currency_symbol         "<U0024>"
+mon_decimal_point       "<U002E>"
+mon_thousands_sep       "<U002C>"
+mon_grouping            3;3
+positive_sign           "<U002B>"
+negative_sign           "<U002D>"
+int_frac_digits         2
+frac_digits             2
+p_cs_precedes           1
+p_sign_posn             0
+p_sep_by_space          1
+n_cs_precedes           1
+n_sign_posn             1
+n_sep_by_space          0
+int_p_cs_precedes       1
+int_p_sign_posn         0
+int_p_sep_by_space      1
+int_n_cs_precedes       1
+int_n_sign_posn         1
+int_n_sep_by_space      0
+END LC_MONETARY
Index: trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_y02n22
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_y02n22	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_y02n22	(revision 2036)
@@ -0,0 +1,32 @@
+# One of a set of test locales for strfmon()
+
+# The six characters after the "_" in the locale name indicate
+# the last six LC_MONETARY values below.
+
+LC_CTYPE
+copy "POSIX"
+END LC_CTYPE
+
+LC_MONETARY
+int_curr_symbol         "<U0055><U0053><U0043><U0020>"
+currency_symbol         "<U0024>"
+mon_decimal_point       "<U002E>"
+mon_thousands_sep       "<U002C>"
+mon_grouping            3;3
+positive_sign           ""
+negative_sign           "<U004F><U002F><U0044>"
+int_frac_digits         2
+frac_digits             2
+p_cs_precedes           1
+p_sign_posn             0
+p_sep_by_space          2
+n_cs_precedes           0
+n_sign_posn             2
+n_sep_by_space          2
+int_p_cs_precedes       1
+int_p_sign_posn         0
+int_p_sep_by_space      2
+int_n_cs_precedes       0
+int_n_sign_posn         2
+int_n_sep_by_space      2
+END LC_MONETARY
Index: trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_y22n42
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_y22n42	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_y22n42	(revision 2036)
@@ -0,0 +1,32 @@
+# One of a set of test locales for strfmon()
+
+# The six characters after the "_" in the locale name indicate
+# the last six LC_MONETARY values below.
+
+LC_CTYPE
+copy "POSIX"
+END LC_CTYPE
+
+LC_MONETARY
+int_curr_symbol         "<U0055><U0053><U0043><U0020>"
+currency_symbol         "<U0024>"
+mon_decimal_point       "<U002E>"
+mon_thousands_sep       "<U002C>"
+mon_grouping            3;3
+positive_sign           "<U002B>"
+negative_sign           "<U002D>"
+int_frac_digits         2
+frac_digits             2
+p_cs_precedes           1
+p_sign_posn             2
+p_sep_by_space          2
+n_cs_precedes           0
+n_sign_posn             4
+n_sep_by_space          2
+int_p_cs_precedes       1
+int_p_sign_posn         2
+int_p_sep_by_space      2
+int_n_cs_precedes       0
+int_n_sign_posn         4
+int_n_sep_by_space      2
+END LC_MONETARY
Index: trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_y30y21
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_y30y21	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_y30y21	(revision 2036)
@@ -0,0 +1,32 @@
+# One of a set of test locales for strfmon()
+
+# The six characters after the "_" in the locale name indicate
+# the last six LC_MONETARY values below.
+
+LC_CTYPE
+copy "POSIX"
+END LC_CTYPE
+
+LC_MONETARY
+int_curr_symbol         "<U0055><U0053><U0043><U0020>"
+currency_symbol         "<U0024>"
+mon_decimal_point       "<U002E>"
+mon_thousands_sep       "<U002C>"
+mon_grouping            3;3
+positive_sign           "<U002B>"
+negative_sign           "<U002D>"
+int_frac_digits         2
+frac_digits             2
+p_cs_precedes           1
+p_sign_posn             3
+p_sep_by_space          0
+n_cs_precedes           1
+n_sign_posn             2
+n_sep_by_space          1
+int_p_cs_precedes       1
+int_p_sign_posn         3
+int_p_sep_by_space      0
+int_n_cs_precedes       1
+int_n_sign_posn         2
+int_n_sep_by_space      1
+END LC_MONETARY
Index: trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_y32n31
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_y32n31	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_y32n31	(revision 2036)
@@ -0,0 +1,32 @@
+# One of a set of test locales for strfmon()
+
+# The six characters after the "_" in the locale name indicate
+# the last six LC_MONETARY values below.
+
+LC_CTYPE
+copy "POSIX"
+END LC_CTYPE
+
+LC_MONETARY
+int_curr_symbol         "<U0055><U0053><U0043><U0020>"
+currency_symbol         "<U0024>"
+mon_decimal_point       "<U002E>"
+mon_thousands_sep       "<U002C>"
+mon_grouping            3;3
+positive_sign           "<U002B>"
+negative_sign           "<U002D>"
+int_frac_digits         2
+frac_digits             2
+p_cs_precedes           1
+p_sign_posn             3
+p_sep_by_space          2
+n_cs_precedes           0
+n_sign_posn             3
+n_sep_by_space          1
+int_p_cs_precedes       1
+int_p_sign_posn         3
+int_p_sep_by_space      2
+int_n_cs_precedes       0
+int_n_sign_posn         3
+int_n_sep_by_space      1
+END LC_MONETARY
Index: trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_y40y00
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_y40y00	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_y40y00	(revision 2036)
@@ -0,0 +1,32 @@
+# One of a set of test locales for strfmon()
+
+# The six characters after the "_" in the locale name indicate
+# the last six LC_MONETARY values below.
+
+LC_CTYPE
+copy "POSIX"
+END LC_CTYPE
+
+LC_MONETARY
+int_curr_symbol         "<U0055><U0053><U0043><U0020>"
+currency_symbol         "<U0024>"
+mon_decimal_point       "<U002E>"
+mon_thousands_sep       "<U002C>"
+mon_grouping            3;3
+positive_sign           "<U002B>"
+negative_sign           "<U002D>"
+int_frac_digits         2
+frac_digits             2
+p_cs_precedes           1
+p_sign_posn             4
+p_sep_by_space          0
+n_cs_precedes           1
+n_sign_posn             0
+n_sep_by_space          0
+int_p_cs_precedes       1
+int_p_sign_posn         4
+int_p_sep_by_space      0
+int_n_cs_precedes       1
+int_n_sign_posn         0
+int_n_sep_by_space      0
+END LC_MONETARY
Index: trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_y42n21
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_y42n21	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-fmon-locales/tstfmon_y42n21	(revision 2036)
@@ -0,0 +1,32 @@
+# One of a set of test locales for strfmon()
+
+# The six characters after the "_" in the locale name indicate
+# the last six LC_MONETARY values below.
+
+LC_CTYPE
+copy "POSIX"
+END LC_CTYPE
+
+LC_MONETARY
+int_curr_symbol         "<U0055><U0053><U0043><U0020>"
+currency_symbol         "<U0024>"
+mon_decimal_point       "<U002E>"
+mon_thousands_sep       "<U002C>"
+mon_grouping            3;3
+positive_sign           "<U002B>"
+negative_sign           "<U002D>"
+int_frac_digits         2
+frac_digits             2
+p_cs_precedes           1
+p_sign_posn             4
+p_sep_by_space          2
+n_cs_precedes           0
+n_sign_posn             2
+n_sep_by_space          1
+int_p_cs_precedes       1
+int_p_sign_posn         4
+int_p_sep_by_space      2
+int_n_cs_precedes       0
+int_n_sign_posn         2
+int_n_sep_by_space      1
+END LC_MONETARY
Index: trunk/src/libctests/glibc/localedata/tst-fmon.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-fmon.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-fmon.c	(revision 2036)
@@ -0,0 +1,68 @@
+/* Testing the implementation of strfmon(3).
+   Copyright (C) 1996, 1997, 2000, 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jochen Hein <jochen.hein@delphi.central.de>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <locale.h>
+#include <monetary.h>
+#include <string.h>
+#include <stdlib.h>
+
+/*
+  test-strfmon gets called with three parameters:
+   - the locale
+   - the format-string to be used
+   - the actual number to be formatted
+   - the expected string
+   If the test passes, test-strfmon terminates with returncode 0,
+   otherwise with 1
+*/
+#define EXIT_SUCCESS 0
+#define EXIT_FAILURE 1
+#define EXIT_SETLOCALE 2
+#define EXIT_STRFMON 3
+
+int
+main (int argc, char *argv[])
+{
+  char *s = malloc (201);
+
+  if (setlocale (LC_MONETARY, argv[1]) == NULL)
+    {
+      fprintf (stderr, "setlocale(LC_MONETARY, \"%s\"): %m\n", argv[1]);
+      exit (EXIT_SETLOCALE);
+    }
+
+  if (strfmon (s, 200, argv[2], (double) atof (argv[3])) == -1)
+    {
+      perror ("strfmon");
+      exit (EXIT_STRFMON);
+    }
+
+  if (strcmp (s, argv[4]) != 0)
+    {
+      printf ("\
+Locale: \"%s\" Format: \"%s\" Value: \"%s\" Received: \"%s\" Expected: \"%s\" => %s\n",
+	      argv[1], argv[2], argv[3], s, argv[4],
+	      strcmp (s, argv[4]) != 0 ? "false" : "correct");
+      exit (EXIT_FAILURE);
+    }
+
+  return EXIT_SUCCESS;
+}
Index: trunk/src/libctests/glibc/localedata/tst-fmon.data
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-fmon.data	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-fmon.data	(revision 2036)
@@ -0,0 +1,354 @@
+# Test data for test-strfmon, which checks it's implementation in glibc
+# Copyright (C) 1996, 1997, 2000, 2002, 2003 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+# Contributed by Jochen Hein <jochen.hein@delphi.central.de>, 1997.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+# The format of this file is pretty simple: Each line contains a test
+# for strfmon.  Fields are separated by TABs.  Lines that start with a
+# '#' are comments and are ignored.
+#
+# Field Description
+# #1    locale which is to be checked
+# #2    format string which is fed into strfmon
+# #3    double value that is used for formatting
+# #4    the expected result (may contain trailing spaces!)
+#       This field might be enclosed with "" to make it easier to see
+#       the white space
+#
+# First the implementation without any locale-dependent data
+# - no currency symbol is printed, formatting is somewhat standard
+C			%n	1.23		1.23
+C			%n	-1.23		-1.23
+C			%n	0		0.00
+C			%%	0		%
+C			*%n*	1.23		*1.23*
+C			%9n	1.23		     1.23
+C			%9n	-1.23		    -1.23
+C			%#9n	1.23		         1.23
+C			%#9n	-1.23		-        1.23
+C			%=*#9n	1.23		 ********1.23
+C			%=*#9n	-1.23		-********1.23
+C			%-14#5.4n	1.23	"     1.2300   "
+C			%-14#5.4n	-1.23	"-    1.2300   "
+C			%-14#5.4n	123.45	"   123.4500   "
+C			%-14#5.4n	123456	" 123456.0000  "
+#
+# check both the german locale and strfmon with that data
+#
+de_DE.ISO-8859-1	%n	1.23		1,23 EUR
+de_DE.ISO-8859-1	%n	-1.23		-1,23 EUR
+de_DE.ISO-8859-1	%n	1234.56		1.234,56 EUR
+de_DE.ISO-8859-1	%12n	123.45		  123,45 EUR
+de_DE.ISO-8859-1	%12n	-123.45		 -123,45 EUR
+de_DE.ISO-8859-1	%12n	3456.781	3.456,78 EUR
+de_DE.ISO-8859-1	%^n	1234.56		1234,56 EUR
+de_DE.ISO-8859-1	%+n	1234.56		1.234,56 EUR
+de_DE.ISO-8859-1	%+n	-1234.56	-1.234,56 EUR
+de_DE.ISO-8859-1	%(n	1234.56		1.234,56 EUR
+de_DE.ISO-8859-1	%(n	-1234.56	(1.234,56 EUR)
+de_DE.ISO-8859-1	%^n	1234.56		1234,56 EUR
+de_DE.ISO-8859-1	%i	1.23		1,23 EUR
+de_DE.ISO-8859-1	%i	-1.23		-1,23 EUR
+de_DE.ISO-8859-1	%i	1234.56		1.234,56 EUR
+de_DE.ISO-8859-1	%^i	1234.56		1234,56 EUR
+de_DE.ISO-8859-1	%+i	1234.56		1.234,56 EUR
+de_DE.ISO-8859-1	%+i	-1234.56	-1.234,56 EUR
+de_DE.ISO-8859-1	%(i	1234.56		1.234,56 EUR
+de_DE.ISO-8859-1	%(i	-1234.56	(1.234,56 EUR)
+de_DE.ISO-8859-1	%^i	1234.56		1234,56 EUR
+de_DE.ISO-8859-1	%#5n	123.45		    123,45 EUR
+de_DE.ISO-8859-1	%#5n	-123.45		-   123,45 EUR
+de_DE.ISO-8859-1	%#5n	3456.781	  3.456,78 EUR
+de_DE.ISO-8859-1	%=*#5n	123.45		 ***123,45 EUR
+de_DE.ISO-8859-1	%=*#5n	-123.45		-***123,45 EUR
+de_DE.ISO-8859-1	%=*#5n	3456.781	 *3.456,78 EUR
+de_DE.ISO-8859-1	%=0#5n	123.45		 000123,45 EUR
+de_DE.ISO-8859-1	%=0#5n	-123.45		-000123,45 EUR
+de_DE.ISO-8859-1	%=0#5n	3456.781	 03.456,78 EUR
+de_DE.ISO-8859-1	%^#5n	123.45		   123,45 EUR
+de_DE.ISO-8859-1	%^#5n	-123.45		-  123,45 EUR
+de_DE.ISO-8859-1	%^#5n	3456.781	  3456,78 EUR
+de_DE.ISO-8859-1	%^#5.0n	123.45		   123 EUR
+de_DE.ISO-8859-1	%^#5.0n	-123.45		-  123 EUR
+de_DE.ISO-8859-1	%^#5.0n	3456.781	  3457 EUR
+de_DE.ISO-8859-1	%^#5.4n	123.45		   123,4500 EUR
+de_DE.ISO-8859-1	%^#5.4n	-123.45		-  123,4500 EUR
+de_DE.ISO-8859-1	%^#5.4n	3456.781	  3456,7810 EUR
+de_DE.ISO-8859-1	%(#5n	123.45		    123,45 EUR
+de_DE.ISO-8859-1	%(#5n	-123.45		(   123,45 EUR)
+de_DE.ISO-8859-1	%(#5n	3456.781	  3.456,78 EUR
+de_DE.ISO-8859-1	%!(#5n	123.45		    123,45
+de_DE.ISO-8859-1	%!(#5n	-123.45		(   123,45)
+de_DE.ISO-8859-1	%!(#5n	3456.781	  3.456,78
+#
+# check both the en_US locale and strfmon with that data
+# a lot of this checks are created from a strfmon(3) man-page.
+#
+en_US.ISO-8859-1	%n	123.45		$123.45
+en_US.ISO-8859-1	%n	-123.45		-$123.45
+en_US.ISO-8859-1	%n	3456.781	$3,456.78
+en_US.ISO-8859-1	%i	123.45		USD 123.45
+en_US.ISO-8859-1	%i	-123.45		-USD 123.45
+en_US.ISO-8859-1	%i	3456.781	USD 3,456.78
+en_US.ISO-8859-1	%11n	123.45		    $123.45
+en_US.ISO-8859-1	%11n	-123.45		   -$123.45
+en_US.ISO-8859-1	%11n	3456.781	  $3,456.78
+en_US.ISO-8859-1	%=*#5n	123.45		 $***123.45
+en_US.ISO-8859-1	%=*#5n	-123.45		-$***123.45
+en_US.ISO-8859-1	%=*#5n	3456.781	 $*3,456.78
+en_US.ISO-8859-1	%=0#5n	123.45		 $000123.45
+en_US.ISO-8859-1	%=0#5n	-123.45		-$000123.45
+en_US.ISO-8859-1	%=0#5n	3456.781	 $03,456.78
+en_US.ISO-8859-1	%^#5n	123.45		 $  123.45
+en_US.ISO-8859-1	%^#5n	-123.45		-$  123.45
+en_US.ISO-8859-1	%^#5n	3456.781	 $ 3456.78
+en_US.ISO-8859-1	%^#5.0n	123.45		 $  123
+en_US.ISO-8859-1	%^#5.0n	-123.45		-$  123
+en_US.ISO-8859-1	%^#5.0n	3456.781	 $ 3457
+en_US.ISO-8859-1	%^#5.4n	123.45		 $  123.4500
+en_US.ISO-8859-1	%^#5.4n	-123.45		-$  123.4500
+en_US.ISO-8859-1	%^#5.4n	3456.781	 $ 3456.7810
+en_US.ISO-8859-1	%(#5n	123.45		 $   123.45
+en_US.ISO-8859-1	%(#5n	-123.45		($   123.45)
+en_US.ISO-8859-1	%(#5n	3456.781	 $ 3,456.78
+en_US.ISO-8859-1	%!(#5n	123.45		    123.45
+en_US.ISO-8859-1	%!(#5n	-123.45		(   123.45)
+en_US.ISO-8859-1	%!(#5n	3456.781	  3,456.78
+en_US.ISO-8859-1	%#5n	123.45		 $   123.45
+en_US.ISO-8859-1	%#5n	-123.45		-$   123.45
+en_US.ISO-8859-1	%#5n	3456.781	 $ 3,456.78
+#
+# check all cs_precedes/sign_posn/sep_by_space combinations using
+# special test locales.  The six characters after the "_" indicate
+# these three values for positive and then negative quantities.
+#
+tstfmon_n01y12		%n	123.45		123.45 $
+tstfmon_n01y12		%n	-123.45		- $123.45
+tstfmon_n01y12		%11n	123.45		   123.45 $
+tstfmon_n01y12		%11n	-123.45		  - $123.45
+tstfmon_n01y12		%^=*#5n	123.45		   **123.45 $
+tstfmon_n01y12		%^=*#5n	-123.45		- $**123.45
+#
+tstfmon_n02n40		%n	123.45		123.45$
+tstfmon_n02n40		%n	-123.45		123.45$-
+tstfmon_n02n40		%11n	123.45		    123.45$
+tstfmon_n02n40		%11n	-123.45		   123.45$-
+tstfmon_n02n40		%^=*#5n	123.45		**123.45$
+tstfmon_n02n40		%^=*#5n	-123.45		**123.45$-
+#
+tstfmon_n10y31		%n	123.45		+123.45$
+tstfmon_n10y31		%n	-123.45		-$ 123.45
+tstfmon_n10y31		%11n	123.45		   +123.45$
+tstfmon_n10y31		%11n	-123.45		  -$ 123.45
+tstfmon_n10y31		%^=*#5n	123.45		  +**123.45$
+tstfmon_n10y31		%^=*#5n	-123.45		-$ **123.45
+#
+tstfmon_n11y41		%n	123.45		+123.45 $
+tstfmon_n11y41		%n	-123.45		$- 123.45
+tstfmon_n11y41		%11n	123.45		  +123.45 $
+tstfmon_n11y41		%11n	-123.45		  $- 123.45
+tstfmon_n11y41		%^=*#5n	123.45		  +**123.45 $
+tstfmon_n11y41		%^=*#5n	-123.45		$- **123.45
+#
+tstfmon_n12y11		%n	123.45		+123.45$
+tstfmon_n12y11		%n	-123.45		-$ 123.45
+tstfmon_n12y11		%11n	123.45		   +123.45$
+tstfmon_n12y11		%11n	-123.45		  -$ 123.45
+tstfmon_n12y11		%^=*#5n	123.45		  +**123.45$
+tstfmon_n12y11		%^=*#5n	-123.45		-$ **123.45
+#
+tstfmon_n20n32		%n	123.45		123.45$+
+tstfmon_n20n32		%n	-123.45		123.45- $
+tstfmon_n20n32		%11n	123.45		   123.45$+
+tstfmon_n20n32		%11n	-123.45		  123.45- $
+tstfmon_n20n32		%^=*#5n	123.45		**123.45$+
+tstfmon_n20n32		%^=*#5n	-123.45		**123.45- $
+#
+tstfmon_n30y20		%n	123.45		123.45+$
+tstfmon_n30y20		%n	-123.45		$123.45-
+tstfmon_n30y20		%11n	123.45		   123.45+$
+tstfmon_n30y20		%11n	-123.45		   $123.45-
+tstfmon_n30y20		%^=*#5n	123.45		 **123.45+$
+tstfmon_n30y20		%^=*#5n	-123.45		$**123.45-
+#
+tstfmon_n41n00		%n	123.45		123.45 $+
+tstfmon_n41n00		%n	-123.45		(123.45$)
+tstfmon_n41n00		%11n	123.45		  123.45 $+
+tstfmon_n41n00		%11n	-123.45		  (123.45$)
+tstfmon_n41n00		%^=*#5n	123.45		 **123.45 $+
+tstfmon_n41n00		%^=*#5n	-123.45		(**123.45$)
+#
+tstfmon_y01y10		%n	123.45		$ 123.45
+tstfmon_y01y10		%n	-123.45		-$123.45
+tstfmon_y01y10		%11n	123.45		   $ 123.45
+tstfmon_y01y10		%11n	-123.45		   -$123.45
+tstfmon_y01y10		%^=*#5n	123.45		$ **123.45
+tstfmon_y01y10		%^=*#5n	-123.45		-$**123.45
+#
+tstfmon_y02n22		%n	123.45		$123.45
+tstfmon_y02n22		%n	-123.45		123.45$ O/D
+tstfmon_y02n22		%12n	123.45		     $123.45
+tstfmon_y02n22		%12n	-123.45		 123.45$ O/D
+tstfmon_y02n22		%^=*#5n	123.45		$**123.45
+tstfmon_y02n22		%^=*#5n	-123.45		 **123.45$ O/D
+#
+tstfmon_y22n42		%n	123.45		$123.45+
+tstfmon_y22n42		%n	-123.45		123.45$ -
+tstfmon_y22n42		%11n	123.45		   $123.45+
+tstfmon_y22n42		%11n	-123.45		  123.45$ -
+tstfmon_y22n42		%^=*#5n	123.45		$**123.45+
+tstfmon_y22n42		%^=*#5n	-123.45		 **123.45$ -
+#
+tstfmon_y30y21		%n	123.45		+$123.45
+tstfmon_y30y21		%n	-123.45		$ 123.45-
+tstfmon_y30y21		%11n	123.45		   +$123.45
+tstfmon_y30y21		%11n	-123.45		  $ 123.45-
+tstfmon_y30y21		%^=*#5n	123.45		+$**123.45
+tstfmon_y30y21		%^=*#5n	-123.45		$ **123.45-
+#
+tstfmon_y32n31		%n	123.45		+ $123.45
+tstfmon_y32n31		%n	-123.45		123.45 -$
+tstfmon_y32n31		%11n	123.45		  + $123.45
+tstfmon_y32n31		%11n	-123.45		  123.45 -$
+tstfmon_y32n31		%^=*#5n	123.45		+ $**123.45
+tstfmon_y32n31		%^=*#5n	-123.45		   **123.45 -$
+#
+tstfmon_y40y00		%n	123.45		$+123.45
+tstfmon_y40y00		%n	-123.45		($123.45)
+tstfmon_y40y00		%11n	123.45		   $+123.45
+tstfmon_y40y00		%11n	-123.45		  ($123.45)
+tstfmon_y40y00		%^=*#5n	123.45		$+**123.45
+tstfmon_y40y00		%^=*#5n	-123.45		($**123.45)
+#
+tstfmon_y42n21		%n	123.45		$ +123.45
+tstfmon_y42n21		%n	-123.45		123.45 $-
+tstfmon_y42n21		%11n	123.45		  $ +123.45
+tstfmon_y42n21		%11n	-123.45		  123.45 $-
+tstfmon_y42n21		%^=*#5n	123.45		$ +**123.45
+tstfmon_y42n21		%^=*#5n	-123.45		   **123.45 $-
+#
+# check all int_cs_precedes/int_sign_posn/int_sep_by_space
+# combinations using special test locales.  The six characters after
+# the "_" indicate these three values for positive and then negative
+# quantities.
+#
+tstfmon_n01y12		%i	123.45		"123.45 USC"
+tstfmon_n01y12		%i	-123.45		"- USC123.45"
+tstfmon_n01y12		%13i	123.45		"   123.45 USC"
+tstfmon_n01y12		%13i	-123.45		"  - USC123.45"
+tstfmon_n01y12		%^=*#5i	123.45		"     **123.45 USC"
+tstfmon_n01y12		%^=*#5i	-123.45		"- USC**123.45"
+#
+tstfmon_n02n40		%i	123.45		"123.45USC"
+tstfmon_n02n40		%i	-123.45		"123.45USC-"
+tstfmon_n02n40		%13i	123.45		"    123.45USC"
+tstfmon_n02n40		%13i	-123.45		"   123.45USC-"
+tstfmon_n02n40		%^=*#5i	123.45		"**123.45USC"
+tstfmon_n02n40		%^=*#5i	-123.45		"**123.45USC-"
+#
+tstfmon_n10y31		%i	123.45		"+123.45USC"
+tstfmon_n10y31		%i	-123.45		"-USC 123.45"
+tstfmon_n10y31		%13i	123.45		"   +123.45USC"
+tstfmon_n10y31		%13i	-123.45		"  -USC 123.45"
+tstfmon_n10y31		%^=*#5i	123.45		"    +**123.45USC"
+tstfmon_n10y31		%^=*#5i	-123.45		"-USC **123.45"
+#
+tstfmon_n11y41		%i	123.45		"+123.45 USC"
+tstfmon_n11y41		%i	-123.45		"USC- 123.45"
+tstfmon_n11y41		%13i	123.45		"  +123.45 USC"
+tstfmon_n11y41		%13i	-123.45		"  USC- 123.45"
+tstfmon_n11y41		%^=*#5i	123.45		"    +**123.45 USC"
+tstfmon_n11y41		%^=*#5i	-123.45		"USC- **123.45"
+#
+tstfmon_n12y11		%i	123.45		"+123.45USC"
+tstfmon_n12y11		%i	-123.45		"-USC 123.45"
+tstfmon_n12y11		%13i	123.45		"   +123.45USC"
+tstfmon_n12y11		%13i	-123.45		"  -USC 123.45"
+tstfmon_n12y11		%^=*#5i	123.45		"    +**123.45USC"
+tstfmon_n12y11		%^=*#5i	-123.45		"-USC **123.45"
+#
+tstfmon_n20n32		%i	123.45		"123.45USC+"
+tstfmon_n20n32		%i	-123.45		"123.45- USC"
+tstfmon_n20n32		%13i	123.45		"   123.45USC+"
+tstfmon_n20n32		%13i	-123.45		"  123.45- USC"
+tstfmon_n20n32		%^=*#5i	123.45		"**123.45USC+"
+tstfmon_n20n32		%^=*#5i	-123.45		"**123.45- USC"
+#
+tstfmon_n30y20		%i	123.45		"123.45+USC"
+tstfmon_n30y20		%i	-123.45		"USC123.45-"
+tstfmon_n30y20		%13i	123.45		"   123.45+USC"
+tstfmon_n30y20		%13i	-123.45		"   USC123.45-"
+tstfmon_n30y20		%^=*#5i	123.45		"   **123.45+USC"
+tstfmon_n30y20		%^=*#5i	-123.45		"USC**123.45-"
+#
+tstfmon_n41n00		%i	123.45		"123.45 USC+"
+tstfmon_n41n00		%i	-123.45		"(123.45USC)"
+tstfmon_n41n00		%13i	123.45		"  123.45 USC+"
+tstfmon_n41n00		%13i	-123.45		"  (123.45USC)"
+tstfmon_n41n00		%^=*#5i	123.45		" **123.45 USC+"
+tstfmon_n41n00		%^=*#5i	-123.45		"(**123.45USC)"
+#
+tstfmon_y01y10		%i	123.45		"USC 123.45"
+tstfmon_y01y10		%i	-123.45		"-USC123.45"
+tstfmon_y01y10		%13i	123.45		"   USC 123.45"
+tstfmon_y01y10		%13i	-123.45		"   -USC123.45"
+tstfmon_y01y10		%^=*#5i	123.45		"USC **123.45"
+tstfmon_y01y10		%^=*#5i	-123.45		"-USC**123.45"
+#
+tstfmon_y02n22		%i	123.45		"USC123.45"
+tstfmon_y02n22		%i	-123.45		"123.45USC O/D"
+tstfmon_y02n22		%12i	123.45		"   USC123.45"
+tstfmon_y02n22		%12i	-123.45		"123.45USC O/D"
+tstfmon_y02n22		%^=*#5i	123.45		"USC**123.45"
+tstfmon_y02n22		%^=*#5i	-123.45		"   **123.45USC O/D"
+#
+tstfmon_y22n42		%i	123.45		"USC123.45+"
+tstfmon_y22n42		%i	-123.45		"123.45USC -"
+tstfmon_y22n42		%13i	123.45		"   USC123.45+"
+tstfmon_y22n42		%13i	-123.45		"  123.45USC -"
+tstfmon_y22n42		%^=*#5i	123.45		"USC**123.45+"
+tstfmon_y22n42		%^=*#5i	-123.45		"   **123.45USC -"
+#
+tstfmon_y30y21		%i	123.45		"+USC123.45"
+tstfmon_y30y21		%i	-123.45		"USC 123.45-"
+tstfmon_y30y21		%13i	123.45		"   +USC123.45"
+tstfmon_y30y21		%13i	-123.45		"  USC 123.45-"
+tstfmon_y30y21		%^=*#5i	123.45		"+USC**123.45"
+tstfmon_y30y21		%^=*#5i	-123.45		"USC **123.45-"
+#
+tstfmon_y32n31		%i	123.45		"+ USC123.45"
+tstfmon_y32n31		%i	-123.45		"123.45 -USC"
+tstfmon_y32n31		%13i	123.45		"  + USC123.45"
+tstfmon_y32n31		%13i	-123.45		"  123.45 -USC"
+tstfmon_y32n31		%^=*#5i	123.45		"+ USC**123.45"
+tstfmon_y32n31		%^=*#5i	-123.45		"     **123.45 -USC"
+#
+tstfmon_y40y00		%i	123.45		"USC+123.45"
+tstfmon_y40y00		%i	-123.45		"(USC123.45)"
+tstfmon_y40y00		%13i	123.45		"   USC+123.45"
+tstfmon_y40y00		%13i	-123.45		"  (USC123.45)"
+tstfmon_y40y00		%^=*#5i	123.45		"USC+**123.45"
+tstfmon_y40y00		%^=*#5i	-123.45		"(USC**123.45)"
+#
+tstfmon_y42n21		%i	123.45		"USC +123.45"
+tstfmon_y42n21		%i	-123.45		"123.45 USC-"
+tstfmon_y42n21		%13i	123.45		"  USC +123.45"
+tstfmon_y42n21		%13i	-123.45		"  123.45 USC-"
+tstfmon_y42n21		%^=*#5i	123.45		"USC +**123.45"
+tstfmon_y42n21		%^=*#5i	-123.45		"     **123.45 USC-"
Index: trunk/src/libctests/glibc/localedata/tst-fmon.sh
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-fmon.sh	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-fmon.sh	(revision 2036)
@@ -0,0 +1,59 @@
+#! /bin/sh
+# Testing the implementation of strfmon(3).
+# Copyright (C) 1996-1998, 2000, 2003, 2004 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+# Contributed by Jochen Hein <jochen.hein@delphi.central.de>, 1997.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+common_objpfx=$1
+run_program_prefix=$2
+datafile=$3
+
+here=`pwd`
+
+lang=`sed -e '/^#/d' -e '/^$/d' -e '/^C	/d' -e '/^tstfmon/d' -e 's/^\([^	]*\).*/\1/' $datafile | sort | uniq`
+
+# Generate data files.
+for cns in `cd ./tst-fmon-locales && ls tstfmon_*`; do
+    cn=tst-fmon-locales/$cns
+    fn=charmaps/ISO-8859-1
+    I18NPATH=. GCONV_PATH=${common_objpfx}iconvdata \
+    LOCPATH=${common_objpfx}localedata LC_ALL=C LANGUAGE=C \
+    ${run_program_prefix} ${common_objpfx}locale/localedef \
+    --quiet -i $cn -f $fn ${common_objpfx}localedata/$cns
+done
+
+# Run the tests.
+errcode=0
+# There's a TAB for IFS
+while IFS="	" read locale format value expect; do
+    case "$locale" in '#'*) continue ;; esac
+    if [ -n "$format" ]; then
+	expect=`echo "$expect" | sed 's/^\"\(.*\)\"$/\1/'`
+	LOCPATH=${common_objpfx}localedata \
+	GCONV_PATH=${common_objpfx}/iconvdata \
+	${run_program_prefix} ${common_objpfx}localedata/tst-fmon \
+	"$locale" "$format" "$value" "$expect" ||
+	errcode=$?
+    fi
+done < $datafile
+
+exit $errcode
+# Local Variables:
+#  mode:shell-script
+# End:
Index: trunk/src/libctests/glibc/localedata/tst-langinfo.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-langinfo.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-langinfo.c	(revision 2036)
@@ -0,0 +1,284 @@
+/* Test program for nl_langinfo() function.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <langinfo.h>
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+
+
+struct map
+{
+  const char *str;
+  int val;
+} map[] =
+{
+#define VAL(name) { #name, name }
+  VAL (ABDAY_1),
+  VAL (ABDAY_2),
+  VAL (ABDAY_3),
+  VAL (ABDAY_4),
+  VAL (ABDAY_5),
+  VAL (ABDAY_6),
+  VAL (ABDAY_7),
+  VAL (ABMON_1),
+  VAL (ABMON_10),
+  VAL (ABMON_11),
+  VAL (ABMON_12),
+  VAL (ABMON_2),
+  VAL (ABMON_3),
+  VAL (ABMON_4),
+  VAL (ABMON_5),
+  VAL (ABMON_6),
+  VAL (ABMON_7),
+  VAL (ABMON_8),
+  VAL (ABMON_9),
+  VAL (ALT_DIGITS),
+  VAL (AM_STR),
+  VAL (CRNCYSTR),
+  VAL (CURRENCY_SYMBOL),
+  VAL (DAY_1),
+  VAL (DAY_2),
+  VAL (DAY_3),
+  VAL (DAY_4),
+  VAL (DAY_5),
+  VAL (DAY_6),
+  VAL (DAY_7),
+  VAL (DECIMAL_POINT),
+  VAL (D_FMT),
+  VAL (D_T_FMT),
+  VAL (ERA),
+  VAL (ERA_D_FMT),
+  VAL (ERA_D_T_FMT),
+  VAL (ERA_T_FMT),
+  VAL (ERA_YEAR),
+  VAL (FRAC_DIGITS),
+  VAL (GROUPING),
+  VAL (INT_CURR_SYMBOL),
+  VAL (INT_FRAC_DIGITS),
+  VAL (MON_1),
+  VAL (MON_10),
+  VAL (MON_11),
+  VAL (MON_12),
+  VAL (MON_2),
+  VAL (MON_3),
+  VAL (MON_4),
+  VAL (MON_5),
+  VAL (MON_6),
+  VAL (MON_7),
+  VAL (MON_8),
+  VAL (MON_9),
+  VAL (MON_DECIMAL_POINT),
+  VAL (MON_GROUPING),
+  VAL (MON_THOUSANDS_SEP),
+  VAL (NEGATIVE_SIGN),
+  VAL (NOEXPR),
+  VAL (NOSTR),
+  VAL (N_CS_PRECEDES),
+  VAL (N_SEP_BY_SPACE),
+  VAL (N_SIGN_POSN),
+  VAL (PM_STR),
+  VAL (POSITIVE_SIGN),
+  VAL (P_CS_PRECEDES),
+  VAL (P_SEP_BY_SPACE),
+  VAL (P_SIGN_POSN),
+  VAL (RADIXCHAR),
+  VAL (THOUSANDS_SEP),
+  VAL (THOUSEP),
+  VAL (T_FMT),
+  VAL (T_FMT_AMPM),
+  VAL (YESEXPR),
+  VAL (YESSTR)
+};
+
+
+static int
+map_paramstr (const char *str)
+{
+  int low = 0;
+  int high = sizeof (map) / sizeof (map[0]);
+
+  while (low < high)
+    {
+      int med = (low + high) / 2;
+      int cmpres;
+
+      cmpres = strcmp (str, map[med].str);
+      if (cmpres == 0)
+	return map[med].val;
+      else if (cmpres > 0)
+	low = med + 1;
+      else
+	high = med;
+    }
+
+  return -1;
+}
+
+
+#ifdef DEBUG
+# define REASON(str) printf ("\"%s\" ignored: %s\n", buf, str)
+#else
+# define REASON(str)
+#endif
+
+int
+main (void)
+{
+  int result = 0;
+
+  while (! feof (stdin))
+    {
+      char buf[1000];
+      char *rp;
+      char *locale;
+      char *paramstr;
+      char *expected;
+      char *actual;
+      int param;
+
+      if (fgets (buf, sizeof (buf), stdin) == NULL)
+	break;
+
+      /* Split the fields.   There are three is them:
+	 1. locale
+	 2. langinfo() parameter
+	 3. expected result; this can be a string with white space etc.
+      */
+      rp = buf;
+      while (*rp == ' ' || *rp == '\t')
+	++rp;
+
+      if  (*rp == '#')
+	{
+	  /* It's a comment line.  Ignore it.  */
+	  REASON ("comment");
+	  continue;
+	}
+      locale = rp;
+
+      while (*rp != '\0' && *rp != ' ' && *rp != '\t' && *rp != '\n')
+	++rp;
+      if (*rp == '\0' || *rp == '\n')
+	{
+	  /* Incomplete line.  */
+	  REASON ("incomplete line");
+	  continue;
+	}
+      *rp++ = '\0';
+
+      while (*rp == ' ' || *rp == '\t')
+	++rp;
+      paramstr = rp;
+
+      while (*rp != '\0' && *rp != ' ' && *rp != '\t' && *rp != '\n')
+	++rp;
+      if (*rp == '\0' || *rp == '\n')
+	{
+	  /* Incomplete line.  */
+	  REASON ("incomplete line");
+	  continue;
+	}
+      *rp++ = '\0';
+
+      while (*rp == ' ' || *rp == '\t')
+	++rp;
+
+      if (*rp == '"')
+	{
+	  char *wp;
+
+	  expected = wp = ++rp;
+	  while (*rp != '"' && *rp != '\n' && *rp != '\0')
+	    {
+	      if (*rp == '\\')
+		{
+		  ++rp;
+		  if (*rp == '\0')
+		    break;
+		  if (*rp >= '0' && *rp <= '9')
+		    {
+		      int val = *rp - '0';
+		      if (rp[1] >= '0' && rp[1] <= '9')
+			{
+			  ++rp;
+			  val *= 10;
+			  val += *rp - '0';
+			  if (rp[1] >= '0' && rp[1] <= '9')
+			    {
+			      ++rp;
+			      val *= 10;
+			      val += *rp - '0';
+			    }
+			}
+		      *rp = val;
+		    }
+		}
+	      *wp++ = *rp++;
+	    }
+
+	  if (*rp != '"')
+	    {
+	      REASON ("missing '\"'");
+	      continue;
+	    }
+
+	  *wp = '\0';
+	}
+      else
+	{
+	  expected = rp;
+	  while (*rp != '\0' && *rp != '\n')
+	    ++rp;
+	  *rp = '\0';
+	}
+
+      param = map_paramstr (paramstr);
+      if (param == -1)
+	{
+	  /* Invalid parameter.  */
+	  REASON ("invalid parameter");
+	  continue;
+	}
+
+      /* Set the locale and check whether it worked.  */
+      printf ("LC_ALL=%s nl_langinfo(%s)", locale, paramstr);
+      setlocale (LC_ALL, locale);
+      if (strcmp (locale, setlocale (LC_ALL, NULL)) != 0)
+	{
+	  puts (": failed to set locale");
+	  result = 1;
+	  continue;
+	}
+
+      actual = nl_langinfo (param);
+      printf (" = \"%s\", ", actual);
+
+      if (strcmp (actual, expected) == 0)
+	puts ("OK");
+      else
+	{
+	  printf ("FAILED (expected: %s)\n", expected);
+	  result = 1;
+	}
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/localedata/tst-langinfo.sh
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-langinfo.sh	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-langinfo.sh	(revision 2036)
@@ -0,0 +1,347 @@
+#! /bin/sh
+# Test nl_langinfo.
+# Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+common_objpfx=$1
+run_program_prefix=$2
+
+# Run the test program.
+cat <<"EOF" |
+# Only decimal numerical escape sequences allowed in strings.
+C                    ABDAY_1     Sun
+C                    ABDAY_2     Mon
+C                    ABDAY_3     Tue
+C                    ABDAY_4     Wed
+C                    ABDAY_5     Thu
+C                    ABDAY_6     Fri
+C                    ABDAY_7     Sat
+C                    DAY_1       Sunday
+C                    DAY_2       Monday
+C                    DAY_3       Tuesday
+C                    DAY_4       Wednesday
+C                    DAY_5       Thursday
+C                    DAY_6       Friday
+C                    DAY_7       Saturday
+C                    ABMON_1     Jan
+C                    ABMON_2     Feb
+C                    ABMON_3     Mar
+C                    ABMON_4     Apr
+C                    ABMON_5     May
+C                    ABMON_6     Jun
+C                    ABMON_7     Jul
+C                    ABMON_8     Aug
+C                    ABMON_9     Sep
+C                    ABMON_10    Oct
+C                    ABMON_11    Nov
+C                    ABMON_12    Dec
+C                    MON_1       January
+C                    MON_2       February
+C                    MON_3       March
+C                    MON_4       April
+C                    MON_5       May
+C                    MON_6       June
+C                    MON_7       July
+C                    MON_8       August
+C                    MON_9       September
+C                    MON_10      October
+C                    MON_11      November
+C                    MON_12      December
+C                    AM_STR      AM
+C                    PM_STR      PM
+C                    D_T_FMT     "%a %b %e %H:%M:%S %Y"
+C                    D_FMT       "%m/%d/%y"
+C                    T_FMT       "%H:%M:%S"
+C                    T_FMT_AMPM  "%I:%M:%S %p"
+C                    ABDAY_1     Sun
+C                    ABDAY_2     Mon
+C                    ABDAY_3     Tue
+C                    ABDAY_4     Wed
+C                    ABDAY_5     Thu
+C                    ABDAY_6     Fri
+C                    ABDAY_7     Sat
+C                    DAY_1       Sunday
+C                    DAY_2       Monday
+C                    DAY_3       Tuesday
+C                    DAY_4       Wednesday
+C                    DAY_5       Thursday
+C                    DAY_6       Friday
+C                    DAY_7       Saturday
+C                    RADIXCHAR   .
+C                    THOUSEP     ""
+C                    YESEXPR     ^[yY]
+C                    NOEXPR      ^[nN]
+en_US.ANSI_X3.4-1968 ABMON_1     Jan
+en_US.ANSI_X3.4-1968 ABMON_2     Feb
+en_US.ANSI_X3.4-1968 ABMON_3     Mar
+en_US.ANSI_X3.4-1968 ABMON_4     Apr
+en_US.ANSI_X3.4-1968 ABMON_5     May
+en_US.ANSI_X3.4-1968 ABMON_6     Jun
+en_US.ANSI_X3.4-1968 ABMON_7     Jul
+en_US.ANSI_X3.4-1968 ABMON_8     Aug
+en_US.ANSI_X3.4-1968 ABMON_9     Sep
+en_US.ANSI_X3.4-1968 ABMON_10    Oct
+en_US.ANSI_X3.4-1968 ABMON_11    Nov
+en_US.ANSI_X3.4-1968 ABMON_12    Dec
+en_US.ANSI_X3.4-1968 MON_1       January
+en_US.ANSI_X3.4-1968 MON_2       February
+en_US.ANSI_X3.4-1968 MON_3       March
+en_US.ANSI_X3.4-1968 MON_4       April
+en_US.ANSI_X3.4-1968 MON_5       May
+en_US.ANSI_X3.4-1968 MON_6       June
+en_US.ANSI_X3.4-1968 MON_7       July
+en_US.ANSI_X3.4-1968 MON_8       August
+en_US.ANSI_X3.4-1968 MON_9       September
+en_US.ANSI_X3.4-1968 MON_10      October
+en_US.ANSI_X3.4-1968 MON_11      November
+en_US.ANSI_X3.4-1968 MON_12      December
+en_US.ANSI_X3.4-1968 AM_STR      AM
+en_US.ANSI_X3.4-1968 PM_STR      PM
+en_US.ANSI_X3.4-1968 D_T_FMT     "%a %d %b %Y %r %Z"
+en_US.ANSI_X3.4-1968 D_FMT       "%m/%d/%Y"
+en_US.ANSI_X3.4-1968 T_FMT       "%r"
+en_US.ANSI_X3.4-1968 T_FMT_AMPM  "%I:%M:%S %p"
+en_US.ANSI_X3.4-1968 RADIXCHAR   .
+en_US.ANSI_X3.4-1968 THOUSEP     ,
+en_US.ANSI_X3.4-1968 YESEXPR     ^[yY].*
+en_US.ANSI_X3.4-1968 NOEXPR      ^[nN].*
+en_US.ISO-8859-1     ABMON_1     Jan
+en_US.ISO-8859-1     ABMON_2     Feb
+en_US.ISO-8859-1     ABMON_3     Mar
+en_US.ISO-8859-1     ABMON_4     Apr
+en_US.ISO-8859-1     ABMON_5     May
+en_US.ISO-8859-1     ABMON_6     Jun
+en_US.ISO-8859-1     ABMON_7     Jul
+en_US.ISO-8859-1     ABMON_8     Aug
+en_US.ISO-8859-1     ABMON_9     Sep
+en_US.ISO-8859-1     ABMON_10    Oct
+en_US.ISO-8859-1     ABMON_11    Nov
+en_US.ISO-8859-1     ABMON_12    Dec
+en_US.ISO-8859-1     MON_1       January
+en_US.ISO-8859-1     MON_2       February
+en_US.ISO-8859-1     MON_3       March
+en_US.ISO-8859-1     MON_4       April
+en_US.ISO-8859-1     MON_5       May
+en_US.ISO-8859-1     MON_6       June
+en_US.ISO-8859-1     MON_7       July
+en_US.ISO-8859-1     MON_8       August
+en_US.ISO-8859-1     MON_9       September
+en_US.ISO-8859-1     MON_10      October
+en_US.ISO-8859-1     MON_11      November
+en_US.ISO-8859-1     MON_12      December
+en_US.ISO-8859-1     AM_STR      AM
+en_US.ISO-8859-1     PM_STR      PM
+en_US.ISO-8859-1     D_T_FMT     "%a %d %b %Y %r %Z"
+en_US.ISO-8859-1     D_FMT       "%m/%d/%Y"
+en_US.ISO-8859-1     T_FMT       "%r"
+en_US.ISO-8859-1     T_FMT_AMPM  "%I:%M:%S %p"
+en_US.ISO-8859-1     RADIXCHAR   .
+en_US.ISO-8859-1     THOUSEP     ,
+en_US.ISO-8859-1     YESEXPR     ^[yY].*
+en_US.ISO-8859-1     NOEXPR      ^[nN].*
+de_DE.ISO-8859-1     ABDAY_1     So
+de_DE.ISO-8859-1     ABDAY_2     Mo
+de_DE.ISO-8859-1     ABDAY_3     Di
+de_DE.ISO-8859-1     ABDAY_4     Mi
+de_DE.ISO-8859-1     ABDAY_5     Do
+de_DE.ISO-8859-1     ABDAY_6     Fr
+de_DE.ISO-8859-1     ABDAY_7     Sa
+de_DE.ISO-8859-1     DAY_1       Sonntag
+de_DE.ISO-8859-1     DAY_2       Montag
+de_DE.ISO-8859-1     DAY_3       Dienstag
+de_DE.ISO-8859-1     DAY_4       Mittwoch
+de_DE.ISO-8859-1     DAY_5       Donnerstag
+de_DE.ISO-8859-1     DAY_6       Freitag
+de_DE.ISO-8859-1     DAY_7       Samstag
+de_DE.ISO-8859-1     ABMON_1     Jan
+de_DE.ISO-8859-1     ABMON_2     Feb
+de_DE.ISO-8859-1     ABMON_3     Mär
+de_DE.ISO-8859-1     ABMON_4     Apr
+de_DE.ISO-8859-1     ABMON_5     Mai
+de_DE.ISO-8859-1     ABMON_6     Jun
+de_DE.ISO-8859-1     ABMON_7     Jul
+de_DE.ISO-8859-1     ABMON_8     Aug
+de_DE.ISO-8859-1     ABMON_9     Sep
+de_DE.ISO-8859-1     ABMON_10    Okt
+de_DE.ISO-8859-1     ABMON_11    Nov
+de_DE.ISO-8859-1     ABMON_12    Dez
+de_DE.ISO-8859-1     MON_1       Januar
+de_DE.ISO-8859-1     MON_2       Februar
+de_DE.ISO-8859-1     MON_3       März
+de_DE.ISO-8859-1     MON_4       April
+de_DE.ISO-8859-1     MON_5       Mai
+de_DE.ISO-8859-1     MON_6       Juni
+de_DE.ISO-8859-1     MON_7       Juli
+de_DE.ISO-8859-1     MON_8       August
+de_DE.ISO-8859-1     MON_9       September
+de_DE.ISO-8859-1     MON_10      Oktober
+de_DE.ISO-8859-1     MON_11      November
+de_DE.ISO-8859-1     MON_12      Dezember
+de_DE.ISO-8859-1     D_T_FMT     "%a %d %b %Y %T %Z"
+de_DE.ISO-8859-1     D_FMT       "%d.%m.%Y"
+de_DE.ISO-8859-1     T_FMT       "%T"
+de_DE.ISO-8859-1     RADIXCHAR   ,
+de_DE.ISO-8859-1     THOUSEP     .
+de_DE.ISO-8859-1     YESEXPR     ^[jJyY].*
+de_DE.ISO-8859-1     NOEXPR      ^[nN].*
+de_DE.UTF-8          ABDAY_1     So
+de_DE.UTF-8          ABDAY_2     Mo
+de_DE.UTF-8          ABDAY_3     Di
+de_DE.UTF-8          ABDAY_4     Mi
+de_DE.UTF-8          ABDAY_5     Do
+de_DE.UTF-8          ABDAY_6     Fr
+de_DE.UTF-8          ABDAY_7     Sa
+de_DE.UTF-8          DAY_1       Sonntag
+de_DE.UTF-8          DAY_2       Montag
+de_DE.UTF-8          DAY_3       Dienstag
+de_DE.UTF-8          DAY_4       Mittwoch
+de_DE.UTF-8          DAY_5       Donnerstag
+de_DE.UTF-8          DAY_6       Freitag
+de_DE.UTF-8          DAY_7       Samstag
+de_DE.UTF-8          ABMON_1     Jan
+de_DE.UTF-8          ABMON_2     Feb
+de_DE.UTF-8          ABMON_3     MÃ€r
+de_DE.UTF-8          ABMON_4     Apr
+de_DE.UTF-8          ABMON_5     Mai
+de_DE.UTF-8          ABMON_6     Jun
+de_DE.UTF-8          ABMON_7     Jul
+de_DE.UTF-8          ABMON_8     Aug
+de_DE.UTF-8          ABMON_9     Sep
+de_DE.UTF-8          ABMON_10    Okt
+de_DE.UTF-8          ABMON_11    Nov
+de_DE.UTF-8          ABMON_12    Dez
+de_DE.UTF-8          MON_1       Januar
+de_DE.UTF-8          MON_2       Februar
+de_DE.UTF-8          MON_3       MÃ€rz
+de_DE.UTF-8          MON_4       April
+de_DE.UTF-8          MON_5       Mai
+de_DE.UTF-8          MON_6       Juni
+de_DE.UTF-8          MON_7       Juli
+de_DE.UTF-8          MON_8       August
+de_DE.UTF-8          MON_9       September
+de_DE.UTF-8          MON_10      Oktober
+de_DE.UTF-8          MON_11      November
+de_DE.UTF-8          MON_12      Dezember
+de_DE.UTF-8          D_T_FMT     "%a %d %b %Y %T %Z"
+de_DE.UTF-8          D_FMT       "%d.%m.%Y"
+de_DE.UTF-8          T_FMT       "%T"
+de_DE.UTF-8          RADIXCHAR   ,
+de_DE.UTF-8          THOUSEP     .
+de_DE.UTF-8          YESEXPR     ^[jJyY].*
+de_DE.UTF-8          NOEXPR      ^[nN].*
+fr_FR.ISO-8859-1     ABDAY_1     dim
+fr_FR.ISO-8859-1     ABDAY_2     lun
+fr_FR.ISO-8859-1     ABDAY_3     mar
+fr_FR.ISO-8859-1     ABDAY_4     mer
+fr_FR.ISO-8859-1     ABDAY_5     jeu
+fr_FR.ISO-8859-1     ABDAY_6     ven
+fr_FR.ISO-8859-1     ABDAY_7     sam
+fr_FR.ISO-8859-1     DAY_1       dimanche
+fr_FR.ISO-8859-1     DAY_2       lundi
+fr_FR.ISO-8859-1     DAY_3       mardi
+fr_FR.ISO-8859-1     DAY_4       mercredi
+fr_FR.ISO-8859-1     DAY_5       jeudi
+fr_FR.ISO-8859-1     DAY_6       vendredi
+fr_FR.ISO-8859-1     DAY_7       samedi
+fr_FR.ISO-8859-1     ABMON_1     jan
+fr_FR.ISO-8859-1     ABMON_2     fév
+fr_FR.ISO-8859-1     ABMON_3     mar
+fr_FR.ISO-8859-1     ABMON_4     avr
+fr_FR.ISO-8859-1     ABMON_5     mai
+fr_FR.ISO-8859-1     ABMON_6     jun
+fr_FR.ISO-8859-1     ABMON_7     jui
+fr_FR.ISO-8859-1     ABMON_8     aoû
+fr_FR.ISO-8859-1     ABMON_9     sep
+fr_FR.ISO-8859-1     ABMON_10    oct
+fr_FR.ISO-8859-1     ABMON_11    nov
+fr_FR.ISO-8859-1     ABMON_12    déc
+fr_FR.ISO-8859-1     MON_1       janvier
+fr_FR.ISO-8859-1     MON_2       février
+fr_FR.ISO-8859-1     MON_3       mars
+fr_FR.ISO-8859-1     MON_4       avril
+fr_FR.ISO-8859-1     MON_5       mai
+fr_FR.ISO-8859-1     MON_6       juin
+fr_FR.ISO-8859-1     MON_7       juillet
+fr_FR.ISO-8859-1     MON_8       août
+fr_FR.ISO-8859-1     MON_9       septembre
+fr_FR.ISO-8859-1     MON_10      octobre
+fr_FR.ISO-8859-1     MON_11      novembre
+fr_FR.ISO-8859-1     MON_12      décembre
+fr_FR.ISO-8859-1     D_T_FMT     "%a %d %b %Y %T %Z"
+fr_FR.ISO-8859-1     D_FMT       "%d.%m.%Y"
+fr_FR.ISO-8859-1     T_FMT       "%T"
+fr_FR.ISO-8859-1     RADIXCHAR   ,
+fr_FR.ISO-8859-1     THOUSEP     ""
+fr_FR.ISO-8859-1     YESEXPR     ^[oOyY].*
+fr_FR.ISO-8859-1     NOEXPR      ^[nN].*
+ja_JP.EUC-JP         ABDAY_1     Æü
+ja_JP.EUC-JP         ABDAY_2     ·î
+ja_JP.EUC-JP         ABDAY_3     ²Ð
+ja_JP.EUC-JP         ABDAY_4     ¿å
+ja_JP.EUC-JP         ABDAY_5     ÌÚ
+ja_JP.EUC-JP         ABDAY_6     ¶â
+ja_JP.EUC-JP         ABDAY_7     ÅÚ
+ja_JP.EUC-JP         DAY_1       ÆüÍËÆü
+ja_JP.EUC-JP         DAY_2       ·îÍËÆü
+ja_JP.EUC-JP         DAY_3       ²ÐÍËÆü
+ja_JP.EUC-JP         DAY_4       ¿åÍËÆü
+ja_JP.EUC-JP         DAY_5       ÌÚÍËÆü
+ja_JP.EUC-JP         DAY_6       ¶âÍËÆü
+ja_JP.EUC-JP         DAY_7       ÅÚÍËÆü
+ja_JP.EUC-JP         ABMON_1     " 1·î"
+ja_JP.EUC-JP         ABMON_2     " 2·î"
+ja_JP.EUC-JP         ABMON_3     " 3·î"
+ja_JP.EUC-JP         ABMON_4     " 4·î"
+ja_JP.EUC-JP         ABMON_5     " 5·î"
+ja_JP.EUC-JP         ABMON_6     " 6·î"
+ja_JP.EUC-JP         ABMON_7     " 7·î"
+ja_JP.EUC-JP         ABMON_8     " 8·î"
+ja_JP.EUC-JP         ABMON_9     " 9·î"
+ja_JP.EUC-JP         ABMON_10    "10·î"
+ja_JP.EUC-JP         ABMON_11    "11·î"
+ja_JP.EUC-JP         ABMON_12    "12·î"
+ja_JP.EUC-JP         MON_1       "1·î"
+ja_JP.EUC-JP         MON_2       "2·î"
+ja_JP.EUC-JP         MON_3       "3·î"
+ja_JP.EUC-JP         MON_4       "4·î"
+ja_JP.EUC-JP         MON_5       "5·î"
+ja_JP.EUC-JP         MON_6       "6·î"
+ja_JP.EUC-JP         MON_7       "7·î"
+ja_JP.EUC-JP         MON_8       "8·î"
+ja_JP.EUC-JP         MON_9       "9·î"
+ja_JP.EUC-JP         MON_10      "10·î"
+ja_JP.EUC-JP         MON_11      "11·î"
+ja_JP.EUC-JP         MON_12      "12·î"
+ja_JP.EUC-JP         T_FMT_AMPM  "%p%I»þ%MÊ¬%SÉÃ"
+ja_JP.EUC-JP         ERA_D_FMT   "%EY%m·î%dÆü"
+ja_JP.EUC-JP         ERA_D_T_FMT "%EY%m·î%dÆü %H»þ%MÊ¬%SÉÃ"
+ja_JP.EUC-JP         RADIXCHAR   .
+ja_JP.EUC-JP         THOUSEP     ,
+ja_JP.EUC-JP         YESEXPR     ^([yY£ù£Ù]|€Ï€€|¥Ï¥€)
+ja_JP.EUC-JP         NOEXPR      ^([nN£î£Î]|€€€€€š|¥€¥€¥š)
+# Is CRNCYSTR supposed to be the national or international sign?
+# ja_JP.EUC-JP         CRNCYSTR    JPY
+ja_JP.EUC-JP         CODESET     EUC-JP
+EOF
+LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
+LC_ALL=tt_TT ${run_program_prefix} \
+  ${common_objpfx}localedata/tst-langinfo \
+    > ${common_objpfx}localedata/tst-langinfo.out
+
+exit $?
Index: trunk/src/libctests/glibc/localedata/tst-leaks.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-leaks.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-leaks.c	(revision 2036)
@@ -0,0 +1,18 @@
+#include <locale.h>
+#include <mcheck.h>
+
+int
+main (void)
+{
+  int cnt;
+
+  mtrace ();
+
+  for (cnt = 0; cnt < 100; ++cnt)
+    {
+      setlocale (LC_ALL, "de_DE.ISO-8859-1");
+      setlocale (LC_ALL, "de_DE.UTF-8");
+    }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/localedata/tst-locale.sh
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-locale.sh	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-locale.sh	(revision 2036)
@@ -0,0 +1,62 @@
+#! /bin/sh
+# Testing the implementation of localedata.
+# Copyright (C) 1998, 2000 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+# Contributed by Andreas Jaeger, <aj@arthur.rhein-neckar.de>, 1998.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+common_objpfx=$1; shift
+localedef=$1; shift
+
+test_locale ()
+{
+    charmap=$1
+    input=$2
+    out=$3
+    rep=$4
+    if test $rep; then
+      rep="--repertoire-map $rep"
+    fi
+    I18NPATH=. GCONV_PATH=${common_objpfx}iconvdata \
+    LOCPATH=${common_objpfx}localedata LC_ALL=C LANGUAGE=C \
+    ${localedef} --quiet -c -f $charmap -i $input \
+      ${rep} ${common_objpfx}localedata/$out
+
+    if [ $? -ne 0 ]; then
+	echo "Charmap: \"${charmap}\" Inputfile: \"${input}\"" \
+	     "Outputdir: \"${out}\" failed"
+	exit 1
+    else
+	echo "locale $out generated succesfully"
+    fi
+}
+
+test_locale IBM437 de_DE de_DE.437
+test_locale tests/test1.cm tests/test1.def test1
+test_locale tests/test2.cm tests/test2.def test2
+test_locale tests/test3.cm tests/test3.def test3
+test_locale tests/test4.cm tests/test4.def test4
+test_locale tests/test5.cm tests/test5.def test5 tests/test5.ds
+test_locale tests/test6.cm tests/test6.def test6 tests/test6.ds
+test_locale tests/test7.cm tests/test7.def test7
+
+exit 0
+
+# Local Variables:
+#  mode:shell-script
+# End:
Index: trunk/src/libctests/glibc/localedata/tst-mbswcs.sh
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-mbswcs.sh	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-mbswcs.sh	(revision 2036)
@@ -0,0 +1,48 @@
+#! /bin/sh
+# Testing the implementation of the mb*towc*() and wc*tomb*() functions.
+# Copyright (C) 2000 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+common_objpfx=$1; shift
+run_program_prefix=$1; shift
+
+status=0
+
+# Run the test programs.
+LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
+${run_program_prefix} ${common_objpfx}localedata/tst-mbswcs1 \
+  > ${common_objpfx}localedata/tst-mbswcs.out || status=1
+
+LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
+${run_program_prefix} ${common_objpfx}localedata/tst-mbswcs2 \
+  >> ${common_objpfx}localedata/tst-mbswcs.out || status=1
+
+LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
+${run_program_prefix} ${common_objpfx}localedata/tst-mbswcs3 \
+  >> ${common_objpfx}localedata/tst-mbswcs.out || status=1
+
+LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
+${run_program_prefix} ${common_objpfx}localedata/tst-mbswcs4 \
+  >> ${common_objpfx}localedata/tst-mbswcs.out || status=1
+
+LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
+${run_program_prefix} ${common_objpfx}localedata/tst-mbswcs5 \
+  >> ${common_objpfx}localedata/tst-mbswcs.out || status=1
+
+exit $status
Index: trunk/src/libctests/glibc/localedata/tst-mbswcs1.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-mbswcs1.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-mbswcs1.c	(revision 2036)
@@ -0,0 +1,63 @@
+/* Test restarting behaviour of mbrtowc.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Bruno Haible <haible@ilog.fr>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+#include <locale.h>
+
+#define show(expr, nexp, wcexp) \
+  n = expr;								  \
+  printf (#expr " -> %Zd", n);						  \
+  printf (", wc = %lu", (unsigned long int) wc);			  \
+  if (n != (size_t) nexp || wc != wcexp)				  \
+    {									  \
+      printf (", expected %Zd and %lu", nexp, (unsigned long int) wcexp); \
+      result = 1;							  \
+    }									  \
+  putc ('\n', stdout)
+
+int
+main (void)
+{
+  unsigned char buf[6] = { 0x25,  0xe2, 0x82, 0xac,  0xce, 0xbb };
+  mbstate_t state;
+  wchar_t wc = 42;
+  size_t n;
+  int result = 0;
+  const char *used_locale;
+
+  setlocale (LC_CTYPE, "de_DE.UTF-8");
+  /* Double check.  */
+  used_locale = setlocale (LC_CTYPE, NULL);
+  printf ("used locale: \"%s\"\n", used_locale);
+  result = strcmp (used_locale, "de_DE.UTF-8");
+
+  memset (&state, '\0', sizeof (state));
+
+  show (mbrtowc (&wc, buf + 0, 1, &state), 1, 37);
+  show (mbrtowc (&wc, buf + 1, 1, &state), -2, 37);
+  show (mbrtowc (&wc, buf + 2, 3, &state), 2, 8364);
+  show (mbrtowc (&wc, buf + 4, 1, &state), -2, 8364);
+  show (mbrtowc (&wc, buf + 5, 1, &state), 1, 955);
+  show (mbrtowc (&wc, buf + 5, 1, &state), -1, 955);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/localedata/tst-mbswcs2.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-mbswcs2.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-mbswcs2.c	(revision 2036)
@@ -0,0 +1,65 @@
+/* Test restarting behaviour of mbsnrtowcs.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Bruno Haible <haible@ilog.fr>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+#include <locale.h>
+
+#define show(expr, nexp, wcexp, end) \
+  n = expr;								\
+  printf (#expr " -> %Zd", n);						\
+  printf (", wc = %lu, src = buf+%d", (unsigned long int) wc,		\
+	  src - (const char *) buf);					\
+  if (n != (size_t) nexp || wc != wcexp || src != (const char *) (end))	\
+    {									\
+      printf (", expected %Zd and %lu and buf+%d", nexp,		\
+	      (unsigned long int) wcexp, (end) - buf);			\
+      result = 1;							\
+    }									\
+  putc ('\n', stdout)
+
+int
+main (void)
+{
+  unsigned char buf[6] = { 0x25,  0xe2, 0x82, 0xac,  0xce, 0xbb };
+  mbstate_t state;
+  const char *src;
+  wchar_t wc = 42;
+  size_t n;
+  int result = 0;
+  const char *used_locale;
+
+  setlocale (LC_CTYPE,"de_DE.UTF-8");
+  /* Double check.  */
+  used_locale = setlocale (LC_CTYPE, NULL);
+  printf ("used locale: \"%s\"\n", used_locale);
+  result = strcmp (used_locale, "de_DE.UTF-8");
+
+  memset (&state, '\0', sizeof (state));
+
+  src = (const char *) buf;
+  show (mbsnrtowcs (&wc, &src, 1, 1, &state), 1, 37, buf + 1);
+  show (mbsnrtowcs (&wc, &src, 3, 1, &state), 1, 8364, buf + 4);
+  show (mbsnrtowcs (&wc, &src, 1, 1, &state), 0, 8364, buf + 5);
+  show (mbsnrtowcs (&wc, &src, 1, 1, &state), 1, 955, buf + 6);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/localedata/tst-mbswcs3.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-mbswcs3.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-mbswcs3.c	(revision 2036)
@@ -0,0 +1,76 @@
+/* Test restarting behaviour of wcsrtombs.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Bruno Haible <haible@ilog.fr>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+#include <locale.h>
+
+#define show(expr, nexp, srcexp, bufexp) \
+  {									\
+    size_t res = expr;							\
+    printf (#expr " -> %Zd", res);					\
+    dst += res;								\
+    printf (", src = srcbuf+%td, dst = buf+%td",			\
+	    src - srcbuf, dst - (char *) buf);				\
+    if (res != nexp || src != (srcexp) || dst != (char *) (bufexp))	\
+      {									\
+	printf (", expected %Zd and srcbuf+%td and buf+%td", nexp,	\
+		(srcexp) - srcbuf, (bufexp) - (unsigned char *) buf);	\
+	result = 1;							\
+      }									\
+    putc ('\n', stdout);						\
+  }
+
+int
+main (void)
+{
+  unsigned char buf[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+  const unsigned char bufcheck[6] = { 0x25, 0xe2, 0x82, 0xac, 0xce, 0xbb };
+  const wchar_t srcbuf[4] = { 0x25, 0x20ac, 0x03bb, 0 };
+  mbstate_t state;
+  const wchar_t *src;
+  char *dst;
+  int result = 0;
+  const char *used_locale;
+
+  setlocale (LC_CTYPE, "de_DE.UTF-8");
+  /* Double check.  */
+  used_locale = setlocale (LC_CTYPE, NULL);
+  printf ("used locale: \"%s\"\n", used_locale);
+  result = strcmp (used_locale, "de_DE.UTF-8");
+
+  memset (&state, '\0', sizeof (state));
+
+  src = srcbuf;
+  dst = (char *) buf;
+  show (wcsrtombs (dst, &src, 1, &state), 1, srcbuf + 1, buf + 1);
+  show (wcsrtombs (dst, &src, 1, &state), 0, srcbuf + 1, buf + 1);
+  show (wcsrtombs (dst, &src, 4, &state), 3, srcbuf + 2, buf + 4);
+  show (wcsrtombs (dst, &src, 2, &state), 2, srcbuf + 3, buf + 6);
+
+  if (memcmp (buf, bufcheck, 6))
+    {
+      puts ("wrong results");
+      result = 1;
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/localedata/tst-mbswcs4.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-mbswcs4.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-mbswcs4.c	(revision 2036)
@@ -0,0 +1,63 @@
+/* Test restarting behaviour of mbsrtowcs.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+#include <locale.h>
+
+#define show(expr, nexp, wcexp, end) \
+  n = expr;								\
+  printf (#expr " -> %Zd", n);						\
+  printf (", wc = %lu, src = buf+%d", (unsigned long int) wc,		\
+	  src - (const char *) buf);					\
+  if (n != (size_t) nexp || wc != wcexp || src != (const char *) (end))	\
+    {									\
+      printf (", expected %Zd and %lu and buf+%d", nexp,		\
+	      (unsigned long int) wcexp, (end) - buf);			\
+      result = 1;							\
+    }									\
+  putc ('\n', stdout)
+
+int
+main (void)
+{
+  unsigned char buf[6] = { 0x25,  0xe2, 0x82, 0xac,  0xce, 0xbb };
+  mbstate_t state;
+  const char *src;
+  wchar_t wc = 42;
+  size_t n;
+  int result = 0;
+  const char *used_locale;
+
+  setlocale (LC_CTYPE,"de_DE.UTF-8");
+  /* Double check.  */
+  used_locale = setlocale (LC_CTYPE, NULL);
+  printf ("used locale: \"%s\"\n", used_locale);
+  result = strcmp (used_locale, "de_DE.UTF-8");
+
+  memset (&state, '\0', sizeof (state));
+
+  src = (const char *) buf;
+  show (mbsrtowcs (&wc, &src, 1, &state), 1, 37, buf + 1);
+  show (mbsrtowcs (&wc, &src, 1, &state), 1, 8364, buf + 4);
+  show (mbsrtowcs (&wc, &src, 1, &state), 1, 955, buf + 6);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/localedata/tst-mbswcs5.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-mbswcs5.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-mbswcs5.c	(revision 2036)
@@ -0,0 +1,75 @@
+/* Test restarting behaviour of wcrtomb.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Bruno Haible <haible@ilog.fr>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+#include <locale.h>
+
+#define show(expr, nexp, bufexp) \
+  {									\
+    size_t res = expr;							\
+    printf (#expr " -> %Zd", res);					\
+    dst += res;								\
+    printf (", dst = buf+%td", dst - (char *) buf);			\
+    if (res != nexp || dst != (char *) (bufexp))			\
+      {									\
+	printf (", expected %Zd and buf+%td", nexp,			\
+		(bufexp) - (unsigned char *) buf);			\
+	result = 1;							\
+      }									\
+    putc ('\n', stdout);						\
+  }
+
+int
+main (void)
+{
+  unsigned char buf[7] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+  const unsigned char bufcheck[7] = { 0x25, 0xe2, 0x82, 0xac, 0xce, 0xbb, 0 };
+  const wchar_t srcbuf[4] = { 0x25, 0x20ac, 0x03bb, 0 };
+  mbstate_t state;
+  const wchar_t *src;
+  char *dst;
+  int result = 0;
+  const char *used_locale;
+
+  setlocale (LC_CTYPE, "de_DE.UTF-8");
+  /* Double check.  */
+  used_locale = setlocale (LC_CTYPE, NULL);
+  printf ("used locale: \"%s\"\n", used_locale);
+  result = strcmp (used_locale, "de_DE.UTF-8");
+
+  memset (&state, '\0', sizeof (state));
+
+  src = srcbuf;
+  dst = (char *) buf;
+  show (wcrtomb (dst, *src++, &state), 1, buf + 1);
+  show (wcrtomb (dst, *src++, &state), 3, buf + 4);
+  show (wcrtomb (dst, *src++, &state), 2, buf + 6);
+  show (wcrtomb (dst, *src, &state), 1, buf + 7);
+
+  if (memcmp (buf, bufcheck, 7))
+    {
+      puts ("wrong results");
+      result = 1;
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/localedata/tst-mbswcs6.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-mbswcs6.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-mbswcs6.c	(revision 2036)
@@ -0,0 +1,74 @@
+/* Test for invalid input to wcrtomb.
+   Copyright (C) 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+
+
+static int
+do_test (const char *loc)
+{
+  char buf[100];
+  size_t n;
+  mbstate_t state;
+  const char *nloc;
+  int res;
+
+  nloc = setlocale (LC_ALL, loc);
+  if (nloc == NULL)
+    {
+      printf ("could not set locale \"%s\"\n", loc);
+      return 1;
+    }
+  printf ("new locale: %s\n", nloc);
+
+  memset (&state, '\0', sizeof (state));
+  errno = 0;
+  n = wcrtomb (buf, (wchar_t) -15l, &state);
+
+  printf ("n = %zd, errno = %d (%s)\n", n, errno, strerror (errno));
+
+  res = n != (size_t) -1 || errno != EILSEQ;
+  if (res)
+    puts ("*** FAIL");
+  putchar ('\n');
+
+  return res;
+}
+
+
+int
+main (void)
+{
+  int res;
+
+  res = do_test ("C");
+  res |= do_test ("de_DE.ISO-8859-1");
+  res |= do_test ("de_DE.UTF-8");
+  res |= do_test ("en_US.ANSI_X3.4-1968");
+  res |= do_test ("ja_JP.EUC-JP");
+  res |= do_test ("hr_HR.ISO-8859-2");
+  //res |= do_test ("ru_RU.KOI8-R");
+
+  return res;
+}
Index: trunk/src/libctests/glibc/localedata/tst-numeric.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-numeric.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-numeric.c	(revision 2036)
@@ -0,0 +1,74 @@
+/* Testing the implementation of LC_NUMERIC and snprintf().
+   Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Petter Reinholdtsen <pere@hungry.com>, 2003
+
+   Based on tst-fmon.c by Jochen Hein <jochen.hein@delphi.central.de>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <locale.h>
+#include <string.h>
+#include <stdlib.h>
+
+/*
+  test-numeric gets called with three parameters:
+   - the locale
+   - the format-string to be used
+   - the actual number to be formatted
+   - the expected string
+   If the test passes, test-numeric terminates with returncode 0,
+   otherwise with 1
+*/
+#define EXIT_SUCCESS 0
+#define EXIT_FAILURE 1
+#define EXIT_SETLOCALE 2
+#define EXIT_SNPRINTF 3
+
+int
+main (int argc, char *argv[])
+{
+  char *s = malloc (201);
+  double val;
+
+  /* Make sure to read the value before setting of the locale, as
+     strtod() is locale-dependent. */
+  val = strtod (argv[3], NULL);
+
+  if (setlocale (LC_ALL, argv[1]) == NULL)
+    {
+      fprintf (stderr, "setlocale(LC_ALL, \"%s\"): %m\n", argv[1]);
+      exit (EXIT_SETLOCALE);
+    }
+
+  if (snprintf (s, 200, argv[2], val) == -1)
+    {
+      perror ("snprintf");
+      exit (EXIT_SNPRINTF);
+    }
+
+  if (strcmp (s, argv[4]) != 0)
+    {
+      printf ("\
+locale: \"%s\", format: \"%s\", expected: \"%s\", got: \"%s\" => %s\n",
+	      argv[1], argv[2], argv[4], s,
+	      strcmp (s, argv[4]) != 0 ? "false" : "correct");
+      exit (EXIT_FAILURE);
+    }
+
+  return EXIT_SUCCESS;
+}
Index: trunk/src/libctests/glibc/localedata/tst-numeric.data
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-numeric.data	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-numeric.data	(revision 2036)
@@ -0,0 +1,47 @@
+# Test data for tst-nomeric, which checks it's implementation in glibc
+# Copyright (C) 2003 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+# Contributed by Petter Reinholdtsen <pere@hungry.com>, 2003
+# Based on code by Jochen Hein <jochen.hein@delphi.central.de>, 1997.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+# The format of this file is pretty simple: Each line contains a test
+# for strfmon.  Fields are separated by TABs.  Lines that start with a
+# '#' are comments and are ignored.
+#
+# Field Description
+# #1    locale which is to be checked
+# #2    format string which is fed into snprintf
+# #3    double value that is used for formatting
+# #4    the expected result (may contain trailing spaces!)
+#
+# First the implementation without any locale-dependent data
+C	%g	1.23	1.23
+C	%g	-1.23	-1.23
+C	%g	0	0
+C	%%	0	%
+C	%'g	123.45	123.45
+C	%'g	-123.45	-123.45
+C	*%g*	1.23	*1.23*
+C	%9g	1.23	     1.23
+C	%9g	-1.23	    -1.23
+#
+# Locale-dependent test.
+#
+nn_NO.ISO-8859-1	%'g	123.45	123,45
+nn_NO.ISO-8859-1	%'g	-123.45	-123,45
Index: trunk/src/libctests/glibc/localedata/tst-numeric.sh
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-numeric.sh	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-numeric.sh	(revision 2036)
@@ -0,0 +1,51 @@
+#! /bin/sh
+# Testing the implementation of LC_NUMERIC and snprintf(3).
+# Copyright (C) 1996, 1997, 1998, 2000, 2003 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+# Contributed by Jochen Hein <jochen.hein@delphi.central.de>, 1997.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+common_objpfx=$1
+run_program_prefix=$2
+datafile=$3
+
+# Run the tests.
+errcode=0
+# There's a TAB for IFS
+while IFS="	" read locale format value expect; do
+    case "$locale" in '#'*) continue ;; esac
+    if [ -n "$format" ]; then
+	if LOCPATH=${common_objpfx}localedata \
+	    GCONV_PATH=${common_objpfx}/iconvdata \
+	    ${run_program_prefix} ${common_objpfx}localedata/tst-numeric \
+	    "$locale" "$format" "$value" "$expect"
+	then
+	    echo "Locale: \"${locale}\" Format: \"${format}\"" \
+		 "Value: \"${value}\" Expect: \"${expect}\"  passed"
+	else
+	    errcode=$?
+	    echo "Locale: \"${locale}\" Format: \"${format}\"" \
+		 "Value: \"${value}\" Expect: \"${expect}\"    failed"
+	fi
+    fi
+done < $datafile
+
+exit $errcode
+# Local Variables:
+#  mode:shell-script
+# End:
Index: trunk/src/libctests/glibc/localedata/tst-rpmatch.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-rpmatch.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-rpmatch.c	(revision 2036)
@@ -0,0 +1,37 @@
+/* Test program for rpmatch function.
+   Copyright (C) 1998, 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jochen Hein <jochen.hein@delphi.central.de>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main (int argc, char* argv[])
+{
+  setlocale (LC_ALL, argv[1]);
+
+  if (rpmatch (argv[2]) != atol (argv[3]))
+    {
+      fprintf (stderr,"Failed: Locale %s, String %s, Exp: %s, got %d\n",
+	       argv[1], argv[2], argv[3], rpmatch (argv[2]));
+      exit (EXIT_FAILURE);
+    }
+  return EXIT_SUCCESS;
+}
Index: trunk/src/libctests/glibc/localedata/tst-rpmatch.sh
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-rpmatch.sh	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-rpmatch.sh	(revision 2036)
@@ -0,0 +1,59 @@
+#! /bin/sh -f
+#
+# Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+# This file is part of the GNU C Library and contains tests for
+# the rpmatch(3)-implementation.
+# contributed by Jochen Hein <jochen.hein@delphi.central.de>
+
+# 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 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+common_objpfx=$1
+tst_rpmatch=$2
+
+rc=0
+while IFS=\& read locale string result dummy; do
+    if [ "$locale" != "#" ]; then
+	LOCPATH=${common_objpfx}localedata \
+	GCONV_PATH=${common_objpfx}/iconvdata \
+	${tst_rpmatch} $locale $string $result \
+	|| { echo "$locale $string $result  FAILED"; exit 1; }
+    fi
+done <<EOF
+#& These are the tests for rpmatch in glibc.  Each line contains one test,
+#& comments start with #& in the first column.  The fields are separated
+#& by ampersand signs and contain: the locale, the string, the expected
+#& return value of rpmatch(3).  If the test fails, test-rpmatch prints
+#& all these informations
+C&Yes&1
+C&yes&1
+C&YES&1
+C&YeS&1
+C&YEs&1
+C&yEs&1
+C&yES&1
+C&yeS&1
+C&No&0
+C&no&0
+#& Uh, that's nonsense
+C&nonsens&0
+C&Error&-1
+de_DE.ISO-8859-1&Yes&1
+de_DE.ISO-8859-1&Ja&1
+de_DE.ISO-8859-1&Jammerschade&1
+de_DE.ISO-8859-1&dejavu&-1
+de_DE.ISO-8859-1&Nein&0
+de_DE.ISO-8859-1&Fehler&-1
+de_DE.ISO-8859-1&jein&1
+EOF
Index: trunk/src/libctests/glibc/localedata/tst-setlocale.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-setlocale.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-setlocale.c	(revision 2036)
@@ -0,0 +1,25 @@
+/* Test case by Jakub Jelinek <jakub@redhat.com>.  */
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+
+int
+main (void)
+{
+  char q[30];
+  char *s;
+
+  setlocale (LC_ALL, "");
+  printf ("after setlocale (LC_ALL, \"\"): %s\n", setlocale(LC_NUMERIC, NULL));
+
+  strcpy (q, "de_DE.UTF-8");
+  setlocale (LC_NUMERIC, q);
+  printf ("after setlocale (LC_NUMERIC, \"%s\"): %s\n",
+	  q, setlocale(LC_NUMERIC, NULL));
+
+  strcpy (q, "de_DE.ISO-8859-1");
+  s = setlocale (LC_NUMERIC, NULL);
+  printf ("after overwriting string: %s\n", s);
+
+  return strcmp (s, "de_DE.UTF-8") != 0;
+}
Index: trunk/src/libctests/glibc/localedata/tst-trans.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-trans.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-trans.c	(revision 2036)
@@ -0,0 +1,71 @@
+/* Test program for user-defined character maps.
+   Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+#include <wctype.h>
+
+int
+main (void)
+{
+  char buf[30];
+  wchar_t wbuf[30];
+  wctrans_t t;
+  wint_t wch;
+  int errors = 0;
+  int len;
+
+  setlocale (LC_ALL, "");
+
+  t = wctrans ("test");
+  if (t == (wctrans_t) 0)
+    {
+      puts ("locale data files probably not loaded");
+      exit (1);
+    }
+
+  wch = towctrans (L'A', t);
+  printf ("towctrans (L'A', t) = %c\n", wch);
+  if (wch != L'B')
+    errors = 1;
+
+  wch = towctrans (L'B', t);
+  printf ("towctrans (L'B', t) = %c\n", wch);
+  if (wch != L'C')
+    errors = 1;
+
+  /* Test the output digit handling.  */
+  swprintf (wbuf, sizeof (wbuf) / sizeof (wbuf[0]), L"%Id", 0x499602D2);
+  errors |= wcscmp (wbuf, L"bcdefghija") != 0;
+  len = wcslen (wbuf);
+  errors |= len != 10;
+  printf ("len = %d, wbuf = L\"%ls\"\n", len, wbuf);
+
+  snprintf (buf, sizeof buf, "%Id", 0x499602D2);
+  errors |= strcmp (buf, "bcdefghija") != 0;
+  len = strlen (buf);
+  errors |= len != 10;
+  printf ("len = %d, buf = \"%s\"\n", len, buf);
+
+  return errors;
+}
Index: trunk/src/libctests/glibc/localedata/tst-trans.sh
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-trans.sh	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-trans.sh	(revision 2036)
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Test character mapping definitions.
+# Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+common_objpfx=$1
+run_program_prefix=$2
+
+# Generate the necessary locale data.
+I18NPATH=. GCONV_PATH=${common_objpfx}/iconvdata \
+${run_program_prefix} \
+${common_objpfx}locale/localedef --quiet \
+-i tests/trans.def -f charmaps/ISO-8859-1 \
+${common_objpfx}localedata/tt_TT ||
+exit 1
+
+# Run the test program.
+LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
+LC_ALL=tt_TT ${run_program_prefix} \
+${common_objpfx}localedata/tst-trans > ${common_objpfx}localedata/tst-trans.out
+
+exit $?
Index: trunk/src/libctests/glibc/localedata/tst-wctype.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-wctype.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-wctype.c	(revision 2036)
@@ -0,0 +1,144 @@
+/* Test program for iswctype() function in ja_JP locale.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <error.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <wchar.h>
+#include <wctype.h>
+
+int
+main (void)
+{
+  wctype_t wct;
+  wchar_t buf[1000];
+  int result = 1;
+
+  setlocale (LC_ALL, "");
+  wprintf (L"locale = %s\n", setlocale (LC_CTYPE, NULL));
+
+  wct = wctype ("jhira");
+  if (wct == 0)
+    error (EXIT_FAILURE, 0, "jhira: no such character class");
+
+  if (fgetws (buf, sizeof (buf) / sizeof (buf[0]), stdin) != NULL)
+    {
+      int n;
+
+      wprintf (L"buf[] = \"%ls\"\n", buf);
+
+      result = 0;
+
+      for (n = 0; buf[n] != L'\0'; ++n)
+	{
+	  wprintf (L"jhira(U%04lx = %lc) = %d\n", (long) buf[n], buf[n],
+		   iswctype (buf[n], wct));
+	  result |= ((buf[n] < 0xff && iswctype (buf[n], wct))
+		     || (buf[n] > 0xff && !iswctype (buf[n], wct)));
+	}
+    }
+
+  wct = wctype ("jkata");
+  if (wct == 0)
+    error (EXIT_FAILURE, 0, "jkata: no such character class");
+
+  if (fgetws (buf, sizeof (buf) / sizeof (buf[0]), stdin) != NULL)
+    {
+      int n;
+
+      wprintf (L"buf[] = \"%ls\"\n", buf);
+
+      result = 0;
+
+      for (n = 0; buf[n] != L'\0'; ++n)
+	{
+	  wprintf (L"jkata(U%04lx = %lc) = %d\n", (long) buf[n], buf[n],
+		   iswctype (buf[n], wct));
+	  result |= ((buf[n] < 0xff && iswctype (buf[n], wct))
+		     || (buf[n] > 0xff && !iswctype (buf[n], wct)));
+	}
+    }
+
+  wct = wctype ("jdigit");
+  if (wct == 0)
+    error (EXIT_FAILURE, 0, "jdigit: no such character class");
+
+  if (fgetws (buf, sizeof (buf) / sizeof (buf[0]), stdin) != NULL)
+    {
+      int n;
+
+      wprintf (L"buf[] = \"%ls\"\n", buf);
+
+      result = 0;
+
+      for (n = 0; buf[n] != L'\0'; ++n)
+	{
+	  wprintf (L"jdigit(U%04lx = %lc) = %d\n", (long) buf[n], buf[n],
+		   iswctype (buf[n], wct));
+	  result |= ((buf[n] < 0xff && iswctype (buf[n], wct))
+		     || (buf[n] > 0xff && !iswctype (buf[n], wct)));
+	}
+    }
+
+  wct = wctype ("jspace");
+  if (wct == 0)
+    error (EXIT_FAILURE, 0, "jspace: no such character class");
+
+  if (fgetws (buf, sizeof (buf) / sizeof (buf[0]), stdin) != NULL)
+    {
+      int n;
+
+      wprintf (L"buf[] = \"%ls\"\n", buf);
+
+      result = 0;
+
+      for (n = 0; buf[n] != L'\0'; ++n)
+	{
+	  wprintf (L"jspace(U%04lx = %lc) = %d\n", (long) buf[n], buf[n],
+		   iswctype (buf[n], wct));
+	  result |= ((buf[n] < 0xff && iswctype (buf[n], wct))
+		     || (buf[n] > 0xff && !iswctype (buf[n], wct)));
+	}
+    }
+
+  wct = wctype ("jkanji");
+  if (wct == 0)
+    error (EXIT_FAILURE, 0, "jkanji: no such character class");
+
+  if (fgetws (buf, sizeof (buf) / sizeof (buf[0]), stdin) != NULL)
+    {
+      int n;
+
+      wprintf (L"buf[] = \"%ls\"\n", buf);
+
+      result = 0;
+
+      for (n = 0; buf[n] != L'\0'; ++n)
+	{
+	  wprintf (L"jkanji(U%04lx = %lc) = %d\n", (long) buf[n], buf[n],
+		   iswctype (buf[n], wct));
+	  result |= ((buf[n] < 0xff && iswctype (buf[n], wct))
+		     || (buf[n] > 0xff && !iswctype (buf[n], wct)));
+	}
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/localedata/tst-wctype.input
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-wctype.input	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-wctype.input	(revision 2036)
@@ -0,0 +1,5 @@
+€¡€¢€£€€€¥€Š€§€š€©€ª€«€¬€­€®€¯€°€±€²€³€Ž€µ€¶€·€ž€¹€ºabcdefghjklmnoprrstuvwxyz
+¥¡¥¢¥£¥€¥¥¥Š¥§¥š¥©¥ª¥«¥¬¥­¥®¥¯¥°¥±¥²¥³¥Ž¥µ¥¶¥·¥ž¥¹¥ºabcdefghjklmnoprrstuvwxyz
+£°£±£²£³£Ž£µ£¶£·£ž£¹0123456789
+¡¡ a
+°¡°¢°£°€°¥°Š°§°š°©°ª°«°¬°­°®°¯°°°±°²°³°Ž°µ°¶°·°ž°¹°ºabcdefghjklmnoprrstuvwxyz
Index: trunk/src/libctests/glibc/localedata/tst-wctype.sh
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-wctype.sh	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-wctype.sh	(revision 2036)
@@ -0,0 +1,31 @@
+#! /bin/sh
+# Test locale-define character classes.
+# Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+common_objpfx=$1
+run_program_prefix=$2
+
+# Run the test program.
+LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
+LC_ALL=ja_JP.EUC-JP ${run_program_prefix} \
+  ${common_objpfx}localedata/tst-wctype < tst-wctype.input \
+    > ${common_objpfx}localedata/tst-wctype.out
+
+exit $?
Index: trunk/src/libctests/glibc/localedata/tst-xlocale1.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-xlocale1.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-xlocale1.c	(revision 2036)
@@ -0,0 +1,75 @@
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+
+
+static struct
+{
+  const char *locale;
+  const char *str1;
+  const char *str2;
+  int result;
+} tests[] =
+  {
+    { "C", "TRANSLIT", "translit", 0 },
+    { "de_DE.ISO-8859-1", "TRANSLIT", "translit", 0 },
+    { "de_DE.ISO-8859-1", "TRANSLIT", "trÄnslit", -1 },
+    { "de_DE.UTF-8", "TRANSLIT", "translit", 0 },
+    { "de_DE.ISO-8859-1", "ä", "Ä", 1 }
+  };
+#define ntests (sizeof (tests) / sizeof (tests[0]))
+
+
+int
+main (void)
+{
+  size_t cnt;
+  int result = 0;
+  locale_t loc = newlocale (1 << LC_ALL, "C", NULL);
+
+  for (cnt = 0; cnt < ntests; ++cnt)
+    {
+      int r;
+
+      if (setlocale (LC_ALL, tests[cnt].locale) == NULL)
+	{
+	  printf ("cannot set locale \"%s\": %m\n", tests[cnt].locale);
+	  result = 1;
+	  continue;
+	}
+
+      printf ("\nstrcasecmp_l (\"%s\", \"%s\", loc)\n",
+	      tests[cnt].str1, tests[cnt].str2);
+
+      r = strcasecmp_l (tests[cnt].str1, tests[cnt].str2, loc);
+      if (tests[cnt].result == 0)
+	{
+	  if (r != 0)
+	    {
+	      printf ("\"%s\" and \"%s\" expected to be the same, result %d\n",
+		      tests[cnt].str1, tests[cnt].str2, r);
+	      result = 1;
+	    }
+	}
+      else if (tests[cnt].result < 0)
+	{
+	  if (r >= 0)
+	    {
+	      printf ("\"%s\" expected to be smaller than \"%s\", result %d\n",
+		      tests[cnt].str1, tests[cnt].str2, r);
+	      result = 1;
+	    }
+	}
+      else
+	{
+	  if (r <= 0)
+	    {
+	      printf ("\"%s\" expected to be larger than \"%s\", result %d\n",
+		      tests[cnt].str1, tests[cnt].str2, r);
+	      result = 1;
+	    }
+	}
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/localedata/tst-xlocale2.c
===================================================================
--- trunk/src/libctests/glibc/localedata/tst-xlocale2.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/tst-xlocale2.c	(revision 2036)
@@ -0,0 +1,64 @@
+#include <ctype.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static int do_test (__locale_t l);
+
+int
+main (void)
+{
+  locale_t l;
+  locale_t l2;
+  int result;
+
+  l = newlocale (1 << LC_ALL, "de_DE.ISO-8859-1", NULL);
+  if (l == NULL)
+    {
+      printf ("newlocale failed: %m\n");
+      exit (EXIT_FAILURE);
+    }
+  puts ("Running tests of created locale");
+  result = do_test (l);
+
+  l2 = duplocale (l);
+  if (l2 == NULL)
+    {
+      printf ("duplocale failed: %m\n");
+      exit (EXIT_FAILURE);
+    }
+  freelocale (l);
+  puts ("Running tests of duplicated locale");
+  result |= do_test (l2);
+
+  return result;
+}
+
+
+static const char str[] = "0123456789abcdef ABCDEF ghijklmnopqrstuvwxyzäÄöÖüÜ";
+static const char exd[] = "11111111110000000000000000000000000000000000000000";
+static const char exa[] = "00000000001111110111111011111111111111111111111111";
+static const char exx[] = "11111111111111110111111000000000000000000000000000";
+
+
+static int
+do_test (locale_t l)
+{
+  int result = 0;
+size_t n;
+
+#define DO_TEST(TEST, RES) \
+  for (n = 0; n < sizeof (str) - 1; ++n)				      \
+    if ('0' + (TEST (str[n], l) != 0) != RES[n])			      \
+      {									      \
+	printf ("%s(%c) failed\n", #TEST, str[n]);			      \
+	result = 1;							      \
+      }
+
+  DO_TEST (isdigit_l, exd);
+  DO_TEST (isalpha_l, exa);
+  DO_TEST (isxdigit_l, exx);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/localedata/xfrm-test.c
===================================================================
--- trunk/src/libctests/glibc/localedata/xfrm-test.c	(revision 2036)
+++ trunk/src/libctests/glibc/localedata/xfrm-test.c	(revision 2036)
@@ -0,0 +1,144 @@
+/* Test collation function via transformation using real data.
+   Copyright (C) 1997, 1998, 2000, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <ctype.h>
+#include <error.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+struct lines
+{
+  char *xfrm;
+  char *line;
+};
+
+static int xstrcmp (const void *, const void *);
+
+int
+main (int argc, char *argv[])
+{
+  int result = 0;
+  size_t nstrings, nstrings_max;
+  struct lines *strings;
+  char *line = NULL;
+  size_t len = 0;
+  size_t n;
+
+  if (argc < 2)
+    error (1, 0, "usage: %s <random seed>", argv[0]);
+
+  setlocale (LC_ALL, "");
+
+  nstrings_max = 100;
+  nstrings = 0;
+  strings = (struct lines *) malloc (nstrings_max * sizeof (struct lines));
+  if (strings == NULL)
+    {
+      perror (argv[0]);
+      exit (1);
+    }
+
+  while (1)
+    {
+      char saved, *newp;
+      int needed;
+      int l;
+      if (getline (&line, &len, stdin) < 0)
+	break;
+
+      if (nstrings == nstrings_max)
+	{
+	  strings = (struct lines *) realloc (strings,
+					      (nstrings_max *= 2)
+					       * sizeof (*strings));
+	  if (strings == NULL)
+	    {
+	      perror (argv[0]);
+	      exit (1);
+	    }
+	}
+      strings[nstrings].line = strdup (line);
+      l = strcspn (line, ":(;");
+      while (l > 0 && isspace (line[l - 1]))
+	--l;
+
+      saved = line[l];
+      line[l] = '\0';
+      needed = strxfrm (NULL, line, 0);
+      newp = malloc (needed + 1);
+      strxfrm (newp, line, needed + 1);
+      strings[nstrings].xfrm = newp;
+      line[l] = saved;
+      ++nstrings;
+    }
+  free (line);
+
+  /* First shuffle.  */
+  srandom (atoi (argv[1]));
+  for (n = 0; n < 10 * nstrings; ++n)
+    {
+      int r1, r2, r;
+      size_t idx1 = random () % nstrings;
+      size_t idx2 = random () % nstrings;
+      struct lines tmp = strings[idx1];
+      strings[idx1] = strings[idx2];
+      strings[idx2] = tmp;
+
+      /* While we are at it a first little test.  */
+      r1 = strcmp (strings[idx1].xfrm, strings[idx2].xfrm);
+      r2 = strcmp (strings[idx2].xfrm, strings[idx1].xfrm);
+      r = -(r1 ^ r2);
+      if (r)
+	r /= abs (r1 ^ r2);
+
+      if (r < 0 || (r == 0 && (r1 != 0 || r2 != 0))
+	  || (r > 0 && (r1 ^ r2) >= 0))
+	printf ("collate wrong: %d vs. %d\n", r1, r2);
+    }
+
+  /* Now sort.  */
+  qsort (strings, nstrings, sizeof (struct lines), xstrcmp);
+
+  /* Print the result.  */
+  for (n = 0; n < nstrings; ++n)
+    {
+      fputs (strings[n].line, stdout);
+      free (strings[n].line);
+      free (strings[n].xfrm);
+    }
+  free (strings);
+
+  return result;
+}
+
+
+static int
+xstrcmp (ptr1, ptr2)
+     const void *ptr1;
+     const void *ptr2;
+{
+  const struct lines *l1 = (const struct lines *) ptr1;
+  const struct lines *l2 = (const struct lines *) ptr2;
+
+  return strcmp (l1->xfrm, l2->xfrm);
+}
Index: trunk/src/libctests/glibc/login/Makefile
===================================================================
--- trunk/src/libctests/glibc/login/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/login/Makefile	(revision 2036)
@@ -0,0 +1,65 @@
+# Copyright (C) 1996-1998,2000-2002,2003 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Sub-makefile for login portion of the library.
+#
+
+subdir	:= login
+
+headers	:= utmp.h bits/utmp.h lastlog.h pty.h
+
+routines := getutent getutent_r getutid getutline getutid_r getutline_r \
+	    utmp_file utmpname updwtmp getpt grantpt unlockpt ptsname
+
+CFLAGS-grantpt.c = -DLIBEXECDIR='"$(libexecdir)"'
+
+others = utmpdump pt_chown
+install-others = $(inst_libexecdir)/pt_chown
+
+distribute := utmp-private.h utmp-equal.h pty-private.h
+
+subdir-dirs = programs
+vpath %.c programs
+
+tests := tst-utmp tst-utmpx tst-grantpt
+
+# Build the -lutil library with these extra functions.
+extra-libs      := libutil
+extra-libs-others := $(extra-libs)
+
+libutil-routines:= login login_tty logout logwtmp openpty forkpty
+
+include ../Rules
+
+CFLAGS-getpt.c = -fexceptions
+
+ifeq (yes,$(build-static-nss))
+otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
+	     $(resolvobjdir)/libresolv.a $(common-objpfx)libc.a
+endif
+
+# pt_chown needs to be setuid root.
+$(inst_libexecdir)/pt_chown: $(objpfx)pt_chown $(+force)
+	$(make-target-directory)
+	-$(INSTALL_PROGRAM) -m 4755 -o root $< $@
+
+# Depend on libc.so so a DT_NEEDED is generated in the shared objects.
+# This ensures they will load libc.so for needed symbols if loaded by
+# a statically-linked program that hasn't already loaded it.
+$(objpfx)libutil.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a
Index: trunk/src/libctests/glibc/login/tst-grantpt.c
===================================================================
--- trunk/src/libctests/glibc/login/tst-grantpt.c	(revision 2036)
+++ trunk/src/libctests/glibc/login/tst-grantpt.c	(revision 2036)
@@ -0,0 +1,78 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+
+static int
+test_ebadf (void)
+{
+  int fd, ret, err;
+
+  fd = posix_openpt (O_RDWR);
+  if (fd == -1)
+    {
+      printf ("posix_openpt(O_RDWR) failed\nerrno %d (%s)\n",
+	      errno, strerror (errno));
+      /* We don't fail because of this; maybe the system does not have
+	 SUS pseudo terminals.  */
+      return 0;
+    }
+  unlockpt (fd);
+  close (fd);
+
+  ret = grantpt (fd);
+  err = errno;
+  if (ret != -1 || err != EBADF)
+    {
+      printf ("grantpt(): expected: return = %d, errno = %d\n", -1, EBADF);
+      printf ("           got: return = %d, errno = %d\n", ret, err);
+      return 1;
+    }
+  return 0;
+}
+
+static int
+test_einval (void)
+{
+  int fd, ret, err;
+  const char file[] = "./grantpt-einval";
+
+  fd = open (file, O_RDWR | O_CREAT);
+  if (fd == -1)
+    {
+      printf ("open(\"%s\", O_RDWR) failed\nerrno %d (%s)\n",
+	      file, errno, strerror (errno));
+      return 0;
+    }
+  unlink (file);
+
+  ret = grantpt (fd);
+  err = errno;
+  if (ret != -1 || err != EINVAL)
+    {
+      printf ("grantpt(): expected: return = %d, errno = %d\n", -1, EINVAL);
+      printf ("           got: return = %d, errno = %d\n", ret, err);
+      ret = 1;
+    }
+  else
+    ret = 0;
+
+  close (fd);
+
+  return ret;
+}
+
+int
+main (void)
+{
+  int result = 0;
+
+  result += test_ebadf ();
+  result += test_einval ();
+
+  return result;
+}
Index: trunk/src/libctests/glibc/login/tst-utmp.c
===================================================================
--- trunk/src/libctests/glibc/login/tst-utmp.c	(revision 2036)
+++ trunk/src/libctests/glibc/login/tst-utmp.c	(revision 2036)
@@ -0,0 +1,404 @@
+/* Tests for UTMP functions.
+   Copyright (C) 1998, 2001-2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <error.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <time.h>
+
+#ifdef UTMPX
+# include <utmpx.h>
+# define utmp utmpx
+# define utmpname utmpxname
+# define setutent setutxent
+# define getutent getutxent
+# define endutent endutxent
+# define getutline getutxline
+# define getutid getutxid
+# define pututline pututxline
+#else
+# include <utmp.h>
+#endif
+
+
+#if _HAVE_UT_TYPE || defined UTMPX
+
+/* Prototype for our test function.  */
+static int do_test (int argc, char *argv[]);
+
+/* We have a preparation function.  */
+static void do_prepare (int argc, char *argv[]);
+#define PREPARE do_prepare
+
+/* This defines the `main' function and some more.  */
+#include <test-skeleton.c>
+
+
+/* These are for the temporary file we generate.  */
+char *name;
+int fd;
+
+static void
+do_prepare (int argc, char *argv[])
+{
+  size_t name_len;
+
+  name_len = strlen (test_dir);
+  name = malloc (name_len + sizeof ("/utmpXXXXXX"));
+  mempcpy (mempcpy (name, test_dir, name_len),
+	   "/utmpXXXXXX", sizeof ("/utmpXXXXXX"));
+  add_temp_file (name);
+
+  /* Open our test file.  */
+  fd = mkstemp (name);
+  if (fd == -1)
+    error (EXIT_FAILURE, errno, "cannot open test file `%s'", name);
+}
+
+struct utmp entry[] =
+{
+#if _HAVE_UT_TV || defined UTMPX
+#define UT(a)  .ut_tv = { .tv_sec = (a)}
+#else
+#define UT(a)  .ut_time = (a)
+#endif
+
+  { .ut_type = BOOT_TIME, .ut_pid = 1, UT(1000) },
+  { .ut_type = RUN_LVL, .ut_pid = 1, UT(2000) },
+  { .ut_type = INIT_PROCESS, .ut_pid = 5, .ut_id = "si", UT(3000) },
+  { .ut_type = LOGIN_PROCESS, .ut_pid = 23, .ut_line = "tty1", .ut_id = "1",
+    .ut_user = "LOGIN", UT(4000) },
+  { .ut_type = USER_PROCESS, .ut_pid = 24, .ut_line = "tty2", .ut_id = "2",
+    .ut_user = "albert", UT(8000) },
+  { .ut_type = USER_PROCESS, .ut_pid = 196, .ut_line = "ttyp0", .ut_id = "p0",
+    .ut_user = "niels", UT(10000) },
+  { .ut_type = DEAD_PROCESS, .ut_line = "ttyp1", .ut_id = "p1", UT(16000) },
+  { .ut_type = EMPTY },
+  { .ut_type = EMPTY }
+};
+int num_entries = sizeof entry / sizeof (struct utmp);
+
+time_t entry_time = 20000;
+pid_t entry_pid = 234;
+
+static int
+do_init (void)
+{
+  int n;
+
+  setutent ();
+
+  for (n = 0; n < num_entries; n++)
+    {
+      if (pututline (&entry[n]) == NULL)
+	{
+	  error (0, errno, "cannot write UTMP entry");
+	  return 1;
+	}
+    }
+
+  endutent ();
+
+  return 0;
+}
+
+
+static int
+do_check (void)
+{
+  struct utmp *ut;
+  int n;
+
+  setutent ();
+
+  n = 0;
+  while ((ut = getutent ()))
+    {
+      if (n < num_entries &&
+	  memcmp (ut, &entry[n], sizeof (struct utmp)))
+	{
+	  error (0, 0, "UTMP entry does not match");
+	  return 1;
+	}
+
+      n++;
+    }
+
+  if (n != num_entries)
+    {
+      error (0, 0, "number of UTMP entries is incorrect");
+      return 1;
+    }
+
+  endutent ();
+
+  return 0;
+}
+
+static int
+simulate_login (const char *line, const char *user)
+{
+  int n;
+
+  for (n = 0; n < num_entries; n++)
+    {
+      if (strcmp (line, entry[n].ut_line) == 0 ||
+	  entry[n].ut_type == DEAD_PROCESS)
+	{
+	  if (entry[n].ut_pid == DEAD_PROCESS)
+	    entry[n].ut_pid = (entry_pid += 27);
+	  entry[n].ut_type = USER_PROCESS;
+	  strncpy (entry[n].ut_user, user, sizeof (entry[n].ut_user));
+#if _HAVE_UT_TV - 0 || defined UTMPX
+	  entry[n].ut_tv.tv_sec = (entry_time += 1000);
+#else
+          entry[n].ut_time = (entry_time += 1000);
+#endif
+	  setutent ();
+
+	  if (pututline (&entry[n]) == NULL)
+	    {
+	      error (0, errno, "cannot write UTMP entry");
+	      return 1;
+	    }
+
+	  endutent ();
+
+	  return 0;
+	}
+    }
+
+  error (0, 0, "no entries available");
+  return 1;
+}
+
+static int
+simulate_logout (const char *line)
+{
+  int n;
+
+  for (n = 0; n < num_entries; n++)
+    {
+      if (strcmp (line, entry[n].ut_line) == 0)
+	{
+	  entry[n].ut_type = DEAD_PROCESS;
+	  strncpy (entry[n].ut_user, "", sizeof (entry[n].ut_user));
+#if _HAVE_UT_TV - 0 || defined UTMPX
+          entry[n].ut_tv.tv_sec = (entry_time += 1000);
+#else
+          entry[n].ut_time = (entry_time += 1000);
+#endif
+	  setutent ();
+
+	  if (pututline (&entry[n]) == NULL)
+	    {
+	      error (0, errno, "cannot write UTMP entry");
+	      return 1;
+	    }
+
+	  endutent ();
+
+	  return 0;
+	}
+    }
+
+  error (0, 0, "no entry found for `%s'", line);
+  return 1;
+}
+
+static int
+check_login (const char *line)
+{
+  struct utmp *up;
+  struct utmp ut;
+  int n;
+
+  setutent ();
+
+  strcpy (ut.ut_line, line);
+  up = getutline (&ut);
+  if (up == NULL)
+    {
+      error (0, errno, "cannot get entry for line `%s'", line);
+      return 1;
+    }
+
+  endutent ();
+
+  for (n = 0; n < num_entries; n++)
+    {
+      if (strcmp (line, entry[n].ut_line) == 0)
+	{
+	  if (memcmp (up, &entry[n], sizeof (struct utmp)))
+	    {
+	      error (0, 0, "UTMP entry does not match");
+	      return 1;
+	    }
+
+	  return 0;
+	}
+    }
+
+  error (0, 0, "bogus entry for line `%s'", line);
+  return 1;
+}
+
+static int
+check_logout (const char *line)
+{
+  struct utmp ut;
+
+  setutent ();
+
+  strcpy (ut.ut_line, line);
+  if (getutline (&ut) != NULL)
+    {
+      error (0, 0, "bogus login entry for `%s'", line);
+      return 1;
+    }
+
+  endutent ();
+
+  return 0;
+}
+
+static int
+check_id (const char *id)
+{
+  struct utmp *up;
+  struct utmp ut;
+  int n;
+
+  setutent ();
+
+  ut.ut_type = USER_PROCESS;
+  strcpy (ut.ut_id, id);
+  up = getutid (&ut);
+  if (up == NULL)
+    {
+      error (0, errno, "cannot get entry for ID `%s'", id);
+      return 1;
+    }
+
+  endutent ();
+
+  for (n = 0; n < num_entries; n++)
+    {
+      if (strcmp (id, entry[n].ut_id) == 0)
+	{
+	  if (memcmp (up, &entry[n], sizeof (struct utmp)))
+	    {
+	      error (0, 0, "UTMP entry does not match");
+	      return 1;
+	    }
+
+	  return 0;
+	}
+    }
+
+  error (0, 0, "bogus entry for ID `%s'", id);
+  return 1;
+}
+
+static int
+check_type (int type)
+{
+  struct utmp *up;
+  struct utmp ut;
+  int n;
+
+  setutent ();
+
+  ut.ut_type = type;
+  up = getutid (&ut);
+  if (up == NULL)
+    {
+      error (0, errno, "cannot get entry for type `%d'", type);
+      return 1;
+    }
+
+  endutent ();
+
+  for (n = 0; n < num_entries; n++)
+    {
+      if (type == entry[n].ut_type)
+	{
+	  if (memcmp (up, &entry[n], sizeof (struct utmp)))
+	    {
+	      error (0, 0, "UTMP entry does not match");
+	      return 1;
+	    }
+
+	  return 0;
+	}
+    }
+
+  error (0, 0, "bogus entry for type `%d'", type);
+  return 1;
+}
+
+static int
+do_test (int argc, char *argv[])
+{
+  int result = 0;
+
+  utmpname (name);
+
+  result |= do_init ();
+  result |= do_check ();
+
+  result |= simulate_login ("tty1", "erwin");
+  result |= do_check ();
+
+  result |= simulate_login ("ttyp1", "paul");
+  result |= do_check ();
+
+  result |= simulate_logout ("tty2");
+  result |= do_check ();
+
+  result |= simulate_logout ("ttyp0");
+  result |= do_check ();
+
+  result |= simulate_login ("ttyp2", "richard");
+  result |= do_check ();
+
+  result |= check_login ("tty1");
+  result |= check_logout ("ttyp0");
+  result |= check_id ("p1");
+  result |= check_id ("2");
+  result |= check_id ("si");
+  result |= check_type (BOOT_TIME);
+  result |= check_type (RUN_LVL);
+
+  return result;
+}
+
+#else
+
+/* No field 'ut_type' in struct utmp.  */
+int
+main ()
+{
+  return 0;
+}
+
+#endif
Index: trunk/src/libctests/glibc/login/tst-utmpx.c
===================================================================
--- trunk/src/libctests/glibc/login/tst-utmpx.c	(revision 2036)
+++ trunk/src/libctests/glibc/login/tst-utmpx.c	(revision 2036)
@@ -0,0 +1,2 @@
+#define UTMPX
+#include "tst-utmp.c"
Index: trunk/src/libctests/glibc/malloc/Makefile
===================================================================
--- trunk/src/libctests/glibc/malloc/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/malloc/Makefile	(revision 2036)
@@ -0,0 +1,146 @@
+# Copyright (C) 1991-1999, 2000, 2001, 2002, 2003, 2005
+# Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Makefile for malloc routines
+#
+subdir	:= malloc
+
+all:
+
+dist-headers := malloc.h
+headers := $(dist-headers) obstack.h mcheck.h
+tests := mallocbug tst-malloc tst-valloc tst-calloc tst-obstack \
+	 tst-mallocstate tst-mcheck
+test-srcs = tst-mtrace
+
+distribute = thread-m.h mtrace.pl mcheck-init.c stackinfo.h memusage.h \
+	     memusage.sh memusagestat.c tst-mtrace.sh arena.c hooks.c
+
+# Things which get pasted together into gmalloc.c.
+gmalloc-routines := malloc morecore
+# Things to include in the standalone distribution.
+dist-routines = $(gmalloc-routines) mcheck mtrace
+routines = $(dist-routines) obstack
+
+install-lib := libmcheck.a
+non-lib.a := libmcheck.a
+
+# Additional library.
+extra-libs = libmemusage
+extra-libs-others = $(extra-libs)
+
+libmemusage-routines = memusage
+libmemusage-inhibit-o = $(filter-out .os,$(object-suffixes))
+
+# These should be removed by `make clean'.
+extra-objs = mcheck-init.o libmcheck.a
+
+# Include the cleanup handler.
+aux := set-freeres thread-freeres
+
+include ../Makeconfig
+
+CPPFLAGS-memusagestat = -DNOT_IN_libc
+
+# The Perl script to analyze the output of the mtrace functions.
+ifneq ($(PERL),no)
+install-bin-script = mtrace
+generated = mtrace
+
+# The Perl script will print addresses and to do this nicely we must know
+# whether we are on a 32 or 64 bit machine.
+ifneq ($(findstring wordsize-32,$(config-sysdirs)),)
+address-width=10
+else
+address-width=18
+endif
+endif
+
+# Unless we get a test for the availability of libgd which also works
+# for cross-compiling we disable the memusagestat generation in this
+# situation.
+ifneq ($(cross-compiling),yes)
+# If the gd library is available we build the `memusagestat' program.
+ifneq ($(LIBGD),no)
+install-bin = memusagestat
+install-bin-script += memusage
+generated += memusagestat memusage
+extra-objs += memusagestat.o
+
+# The configure.in check for libgd and its headers did not use $SYSINCLUDES.
+# The directory specified by --with-headers usually contains only the basic
+# kernel interface headers, not something like libgd.  So the simplest thing
+# is to presume that the standard system headers will be ok for this file.
+$(objpfx)memusagestat.o: sysincludes = # nothing
+endif
+endif
+
+# Another goal which can be used to override the configure decision.
+.PHONY: do-memusagestat
+do-memusagestat: $(objpfx)memusagestat
+
+memusagestat-modules = memusagestat
+$(objpfx)memusagestat: $(memusagestat-modules:%=$(objpfx)%.o)
+	$(LINK.o) -o $@ $^ $(libgd-LDFLAGS) -lgd -lpng -lz -lm
+
+include ../Rules
+
+CFLAGS-mcheck-init.c = $(PIC-ccflag)
+
+$(objpfx)libmcheck.a: $(objpfx)mcheck-init.o
+	-rm -f $@
+	$(patsubst %/,cd % &&,$(objpfx)) \
+	$(LN_S) $(<F) $(@F)
+
+lib: $(objpfx)libmcheck.a
+
+ifeq (no,$(cross-compiling))
+ifeq (yes,$(build-shared))
+ifneq ($(PERL),no)
+tests: $(objpfx)tst-mtrace.out
+$(objpfx)tst-mtrace.out: tst-mtrace.sh $(objpfx)tst-mtrace
+	$(SHELL) -e $< $(common-objpfx)
+endif
+endif
+endif
+
+tst-mcheck-ENV = MALLOC_CHECK_=3
+
+# Uncomment this for test releases.  For public releases it is too expensive.
+#CPPFLAGS-malloc.o += -DMALLOC_DEBUG=1
+
+$(objpfx)mtrace: mtrace.pl
+	rm -f $@.new
+	sed -e 's|@PERL@|$(PERL)|' -e 's|@XXX@|$(address-width)|' \
+	    -e 's|@VERSION@|$(version)|' $^ > $@.new \
+	&& rm -f $@ && mv $@.new $@ && chmod +x $@
+
+$(objpfx)memusage: memusage.sh
+	rm -f $@.new
+	sed -e 's|@BASH@|$(BASH)|' -e 's|@VERSION@|$(version)|' \
+	    -e 's|@SLIBDIR@|$(slibdir)|' -e 's|@BINDIR@|$(bindir)|' $^ > $@.new \
+	&& rm -f $@ && mv $@.new $@ && chmod +x $@
+
+
+# The implementation uses `dlsym'
+$(objpfx)libmemusage.so: $(common-objpfx)dlfcn/libdl.so
+
+# Extra dependencies
+$(foreach o,$(all-object-suffixes),$(objpfx)malloc$(o)): arena.c hooks.c
Index: trunk/src/libctests/glibc/malloc/tst-calloc.c
===================================================================
--- trunk/src/libctests/glibc/malloc/tst-calloc.c	(revision 2036)
+++ trunk/src/libctests/glibc/malloc/tst-calloc.c	(revision 2036)
@@ -0,0 +1,126 @@
+/* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <error.h>
+#include <limits.h>
+#include <malloc.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+
+/* Number of samples per size.  */
+#define N 50000
+
+
+static void
+fixed_test (int size)
+{
+  char *ptrs[N];
+  int i;
+
+  for (i = 0; i < N; ++i)
+    {
+      int j;
+
+      ptrs[i] = (char *) calloc (1, size);
+
+      if (ptrs[i] == NULL)
+	break;
+
+      for (j = 0; j < size; ++j)
+	{
+	  if (ptrs[i][j] != '\0')
+	    error (EXIT_FAILURE, 0,
+		   "byte not cleared (size %d, element %d, byte %d)",
+		   size, i, j);
+	  ptrs[i][j] = '\xff';
+	}
+    }
+
+  while (i-- > 0)
+    free (ptrs[i]);
+}
+
+
+static void
+random_test (void)
+{
+  char *ptrs[N];
+  int i;
+
+  for (i = 0; i < N; ++i)
+    {
+      int j;
+      int n = 1 + random () % 10;
+      int elem = 1 + random () % 100;
+      int size = n * elem;
+
+      ptrs[i] = (char *) calloc (n, elem);
+
+      if (ptrs[i] == NULL)
+	break;
+
+      for (j = 0; j < size; ++j)
+	{
+	  if (ptrs[i][j] != '\0')
+	    error (EXIT_FAILURE, 0,
+		   "byte not cleared (size %d, element %d, byte %d)",
+		   size, i, j);
+	  ptrs[i][j] = '\xff';
+	}
+    }
+
+  while (i-- > 0)
+    free (ptrs[i]);
+}
+
+
+static void
+null_test (void)
+{
+  /* If the size is 0 the result is implementation defined.  Just make
+     sure the program doesn't crash.  */
+  calloc (0, 0);
+  calloc (0, UINT_MAX);
+  calloc (UINT_MAX, 0);
+  calloc (0, ~((size_t) 0));
+  calloc (~((size_t) 0), 0);
+}
+
+
+int
+main (void)
+{
+  /* We are allocating blocks with `calloc' and check whether every
+     block is completely cleared.  We first try this for some fixed
+     times and then with random size.  */
+  fixed_test (15);
+  fixed_test (5);
+  fixed_test (17);
+  fixed_test (6);
+  fixed_test (31);
+  fixed_test (96);
+
+  random_test ();
+
+  null_test ();
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/malloc/tst-malloc.c
===================================================================
--- trunk/src/libctests/glibc/malloc/tst-malloc.c	(revision 2036)
+++ trunk/src/libctests/glibc/malloc/tst-malloc.c	(revision 2036)
@@ -0,0 +1,68 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@arthur.rhein-neckar.de>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <malloc.h>
+#include <stdio.h>
+
+static int errors = 0;
+
+static void
+merror (const char *msg)
+{
+  ++errors;
+  printf ("Error: %s\n", msg);
+}
+
+int
+main (void)
+{
+  void *p;
+  int save;
+
+  errno = 0;
+
+  p = malloc (-1);
+  save = errno;
+
+  if (p != NULL)
+    merror ("malloc (-1) succeeded.");
+
+  if (p == NULL && save != ENOMEM)
+    merror ("errno is not set correctly");
+
+  p = malloc (10);
+  if (p == NULL)
+    merror ("malloc (10) failed.");
+
+  /* realloc (p, 0) == free (p).  */
+  p = realloc (p, 0);
+  if (p != NULL)
+    merror ("realloc (p, 0) failed.");
+
+  p = malloc (0);
+  if (p == NULL)
+    merror ("malloc (0) failed.");
+
+  p = realloc (p, 0);
+  if (p != NULL)
+    merror ("realloc (p, 0) failed.");
+
+  return errors != 0;
+}
Index: trunk/src/libctests/glibc/malloc/tst-mallocstate.c
===================================================================
--- trunk/src/libctests/glibc/malloc/tst-mallocstate.c	(revision 2036)
+++ trunk/src/libctests/glibc/malloc/tst-mallocstate.c	(revision 2036)
@@ -0,0 +1,82 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Wolfram Gloger <wg@malloc.de>, 2001.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <stdio.h>
+#include "malloc.h"
+
+static int errors = 0;
+
+static void
+merror (const char *msg)
+{
+  ++errors;
+  printf ("Error: %s\n", msg);
+}
+
+int
+main (void)
+{
+  void *p1, *p2;
+  void *save_state;
+  long i;
+
+  errno = 0;
+
+  p1 = malloc (10);
+  if (p1 == NULL)
+    merror ("malloc (10) failed.");
+
+  p2 = malloc (20);
+  if (p2 == NULL)
+    merror ("malloc (20) failed.");
+
+  free (malloc (10));
+
+  for (i=0; i<100; ++i)
+    {
+      save_state = malloc_get_state ();
+      if (save_state == NULL)
+	{
+	  merror ("malloc_get_state () failed.");
+	  break;
+	}
+      /*free (malloc (10)); This could change the top chunk! */
+      malloc_set_state (save_state);
+      p1 = realloc (p1, i*4 + 4);
+      if (p1 == NULL)
+	merror ("realloc (i*4) failed.");
+      free (save_state);
+    }
+
+  p1 = realloc (p1, 40);
+  free (p2);
+  p2 = malloc (10);
+  if (p2 == NULL)
+    merror ("malloc (10) failed.");
+  free (p1);
+
+  return errors != 0;
+}
+
+/*
+ * Local variables:
+ * c-basic-offset: 2
+ * End:
+ */
Index: trunk/src/libctests/glibc/malloc/tst-mcheck.c
===================================================================
--- trunk/src/libctests/glibc/malloc/tst-mcheck.c	(revision 2036)
+++ trunk/src/libctests/glibc/malloc/tst-mcheck.c	(revision 2036)
@@ -0,0 +1,91 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2005.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static int errors = 0;
+
+static void
+merror (const char *msg)
+{
+  ++errors;
+  printf ("Error: %s\n", msg);
+}
+
+int
+main (void)
+{
+  void *p, *q;
+
+  errno = 0;
+
+  p = malloc (-1);
+
+  if (p != NULL)
+    merror ("malloc (-1) succeeded.");
+  else if (errno != ENOMEM)
+    merror ("errno is not set correctly.");
+
+  p = malloc (10);
+  if (p == NULL)
+    merror ("malloc (10) failed.");
+
+  p = realloc (p, 0);
+  if (p != NULL)
+    merror ("realloc (p, 0) failed.");
+
+  p = malloc (0);
+  if (p == NULL)
+    merror ("malloc (0) failed.");
+
+  p = realloc (p, 0);
+  if (p != NULL)
+    merror ("realloc (p, 0) failed.");
+
+  q = malloc (256);
+  if (q == NULL)
+    merror ("malloc (256) failed.");
+
+  p = malloc (512);
+  if (p == NULL)
+    merror ("malloc (512) failed.");
+
+  if (realloc (p, -256) != NULL)
+    merror ("realloc (p, -256) succeeded.");
+  else if (errno != ENOMEM)
+    merror ("errno is not set correctly.");
+
+  free (p);
+
+  p = malloc (512);
+  if (p == NULL)
+    merror ("malloc (512) failed.");
+
+  if (realloc (p, -1) != NULL)
+    merror ("realloc (p, -1) succeeded.");
+  else if (errno != ENOMEM)
+    merror ("errno is not set correctly.");
+
+  free (p);
+  free (q);
+
+  return errors != 0;
+}
Index: trunk/src/libctests/glibc/malloc/tst-mtrace.c
===================================================================
--- trunk/src/libctests/glibc/malloc/tst-mtrace.c	(revision 2036)
+++ trunk/src/libctests/glibc/malloc/tst-mtrace.c	(revision 2036)
@@ -0,0 +1,103 @@
+/* Test program for mtrace.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <mcheck.h>
+#include <paths.h>
+#include <search.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+static void print (const void *node, VISIT value, int level);
+
+/* Used for several purposes.  */
+static FILE *fp;
+
+
+int
+main (void)
+{
+  void *root = NULL;
+  size_t linelen = 0;
+  char *line = NULL;
+
+  /* Enable memory usage tracing.  */
+  mtrace ();
+
+  /* Perform some operations which definitely will allocate some
+     memory.  */
+  fp = fopen (__FILE__, "r");
+  if (fp == NULL)
+    /* Shouldn't happen since this program is executed in the source
+       directory.  */
+    abort ();
+
+  while (!feof (fp))
+    {
+      char **p;
+      char *copy;
+      ssize_t n = getline (&line, &linelen, fp);
+
+      if (n < 0)
+	break;
+
+      if (n == 0)
+	continue;
+
+      copy = strdup (line);
+      if (copy == NULL)
+	abort ();
+
+      p = (char **) tsearch (copy, &root,
+			     (int (*) (const void *, const void *)) strcmp);
+      if (*p != copy)
+	/* This line wasn't added.  */
+	free (copy);
+    }
+
+  fclose (fp);
+
+  fp = fopen (_PATH_DEVNULL, "w");
+  if (fp != NULL)
+    {
+      /* Write something through stdout.  */
+      twalk (root, print);
+
+      fclose (fp);
+    }
+
+  /* Free everything.  */
+  tdestroy (root, free);
+
+  /* Also the line buffer.  */
+  free (line);
+
+  /* That's it.  */
+  return 0;
+}
+
+
+static void
+print (const void *node, VISIT value, int level)
+{
+  static int cnt;
+  if (value == postorder || value == leaf)
+    fprintf (fp, "%3d: %s", ++cnt, *(const char **) node);
+}
Index: trunk/src/libctests/glibc/malloc/tst-mtrace.sh
===================================================================
--- trunk/src/libctests/glibc/malloc/tst-mtrace.sh	(revision 2036)
+++ trunk/src/libctests/glibc/malloc/tst-mtrace.sh	(revision 2036)
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Testing the mtrace function.
+# Copyright (C) 2000 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+common_objpfx=$1; shift
+
+status=0
+trap "rm -f ${common_objpfx}malloc/tst-mtrace.leak; exit 1" 1 2 15
+
+MALLOC_TRACE=${common_objpfx}malloc/tst-mtrace.leak \
+LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
+${common_objpfx}elf/ld.so --library-path $common_objpfx \
+  ${common_objpfx}malloc/tst-mtrace || status=1
+
+if test $status -eq 0 && test -f ${common_objpfx}malloc/mtrace; then
+  ${common_objpfx}malloc/mtrace ${common_objpfx}malloc/tst-mtrace \
+    ${common_objpfx}malloc/tst-mtrace.leak \
+    > ${common_objpfx}malloc/tst-mtrace.out|| status=1
+fi
+
+rm -f ${common_objpfx}malloc/tst-mtrace.leak
+
+exit $status
Index: trunk/src/libctests/glibc/malloc/tst-obstack.c
===================================================================
--- trunk/src/libctests/glibc/malloc/tst-obstack.c	(revision 2036)
+++ trunk/src/libctests/glibc/malloc/tst-obstack.c	(revision 2036)
@@ -0,0 +1,64 @@
+/* Test case by Alexandre Duret-Lutz <duret_g@epita.fr>.  */
+#include <obstack.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define obstack_chunk_alloc verbose_malloc
+#define obstack_chunk_free verbose_free
+#define ALIGN_BOUNDARY 64
+#define ALIGN_MASK (ALIGN_BOUNDARY - 1)
+#define OBJECT_SIZE 1000
+
+static void *
+verbose_malloc (size_t size)
+{
+  void *buf = malloc (size);
+  printf ("malloc (%zu) => %p\n", size, buf);
+  return buf;
+}
+
+static void
+verbose_free (void *buf)
+{
+  free (buf);
+  printf ("free (%p)\n", buf);
+}
+
+int
+main (void)
+{
+  int result = 0;
+  int align = 2;
+
+  while (align <= 64)
+    {
+      struct obstack obs;
+      int i;
+      int align_mask = align - 1;
+
+      printf ("\n Alignment mask: %d\n", align_mask);
+
+      obstack_init (&obs);
+      obstack_alignment_mask (&obs) = align_mask;
+      /* finish an empty object to take alignment into account */
+      obstack_finish (&obs);
+
+      /* let's allocate some objects and print their addresses */
+      for (i = 15; i > 0; --i)
+	{
+	  void *obj = obstack_alloc (&obs, OBJECT_SIZE);
+
+	  printf ("obstack_alloc (%u) => %p \t%s\n", OBJECT_SIZE, obj,
+		  ((uintptr_t) obj & align_mask) ? "(not aligned)" : "");
+	  result |= ((uintptr_t) obj & align_mask) != 0;
+	}
+
+      /* clean up */
+      obstack_free (&obs, 0);
+
+      align <<= 1;
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/malloc/tst-valloc.c
===================================================================
--- trunk/src/libctests/glibc/malloc/tst-valloc.c	(revision 2036)
+++ trunk/src/libctests/glibc/malloc/tst-valloc.c	(revision 2036)
@@ -0,0 +1,23 @@
+/* Test case by Stephen Tweedie <sct@redhat.com>.  */
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main (void)
+{
+  char *p;
+  int pagesize = getpagesize ();
+  int i;
+
+  p = valloc (pagesize);
+  i = (long int) p;
+
+  if ((i & (pagesize-1)) != 0)
+    {
+      fprintf (stderr, "Alignment problem: valloc returns %p\n", p);
+      exit (1);
+    }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/math/Makefile
===================================================================
--- trunk/src/libctests/glibc/math/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/math/Makefile	(revision 2036)
@@ -0,0 +1,204 @@
+# Copyright (C) 1996-2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+# Makefile for the math library.
+
+subdir		:= math
+
+# Installed header files.
+headers		:= math.h bits/mathcalls.h bits/mathinline.h bits/huge_val.h \
+		   bits/huge_valf.h bits/huge_vall.h bits/inf.h bits/nan.h \
+		   fpu_control.h complex.h bits/cmathcalls.h fenv.h \
+		   bits/fenv.h bits/fenvinline.h bits/mathdef.h tgmath.h
+
+# Internal header files.
+distribute	:= math_ldbl.h math_private.h machine/asm.h
+
+# FPU support code.
+aux		:= setfpucw fpu_control
+
+# Build the -lm library.
+
+extra-libs	:= libm
+extra-libs-others = $(extra-libs)
+
+libm-support = k_standard s_lib_version s_matherr s_signgam		\
+	       fclrexcpt fgetexcptflg fraiseexcpt fsetexcptflg		\
+	       ftestexcept fegetround fesetround fegetenv feholdexcpt	\
+	       fesetenv feupdateenv t_exp fedisblxcpt feenablxcpt	\
+	       fegetexcept
+libm-calls = e_acos e_acosh e_asin e_atan2 e_atanh e_cosh e_exp e_fmod	\
+	     e_hypot e_j0 e_j1 e_jn e_lgamma_r e_log e_log10 e_pow	\
+	     e_rem_pio2 e_remainder e_scalb e_sinh e_sqrt e_gamma_r	\
+	     k_cos k_rem_pio2 k_sin k_tan s_asinh s_atan s_cbrt		\
+	     s_ceil s_cos s_erf s_expm1 s_fabs				\
+	     s_floor s_ilogb s_log1p s_logb				\
+	     s_nextafter s_nexttoward s_rint s_scalbln			\
+	     s_significand s_sin s_tan s_tanh w_acos w_acosh w_asin	\
+	     w_atan2 w_atanh w_cosh w_drem w_exp w_exp2 w_exp10 w_fmod	\
+	     w_tgamma w_hypot w_j0 w_j1 w_jn w_lgamma w_lgamma_r	\
+	     w_log w_log10 w_pow w_remainder w_scalb w_sinh w_sqrt	\
+	     s_fpclassify s_fmax s_fmin s_fdim s_nan s_trunc		\
+	     s_remquo e_log2 e_exp2 s_round s_nearbyint s_sincos	\
+	     conj cimag creal cabs carg s_cexp s_csinh s_ccosh s_clog	\
+	     s_catan s_casin s_ccos s_csin s_ctan s_ctanh s_cacos	\
+	     s_casinh s_cacosh s_catanh s_csqrt s_cpow s_cproj s_clog10 \
+	     s_fma s_lrint s_llrint s_lround s_llround e_exp10 w_log2	\
+	     $(calls:s_%=m_%)
+
+include ../Makeconfig
+
+dbl-only-routines := branred doasin dosincos halfulp mpa mpatan2	\
+		     mpatan mpexp mplog mpsqrt mptan sincos32 slowexp	\
+		     slowpow
+libm-routines = $(strip $(libm-support) $(libm-calls) \
+			$(patsubst %_rf,%f_r,$(libm-calls:=f))	\
+			$(long-m-$(long-double-fcts))) \
+		$(dbl-only-routines)
+long-m-routines = $(patsubst %_rl,%l_r,$(libm-calls:=l))
+long-m-support = t_sincosl k_sincosl
+long-m-yes = $(long-m-routines) $(long-m-support)
+
+# These functions are in libc instead of libm because __printf_fp
+# calls them, so any program using printf will need them linked in,
+# and we don't want to have to link every program with -lm.
+# In libm-calls (above), list m_foo in place of s_foo for any
+# routine that should be compiled separately for its libc and libm versions.
+calls = s_isinf s_isnan s_finite s_copysign s_modf s_scalbn s_frexp s_ldexp \
+	s_signbit
+generated += $(foreach s,.c .S l.c l.S f.c f.S,$(calls:s_%=m_%$s))
+routines = $(calls) $(calls:=f) $(long-c-$(long-double-fcts))
+long-c-yes = $(calls:=l)
+distribute += $(filter-out $(generated),$(long-m-yes:=.c) $(long-c-yes:=.c))
+
+# Rules for the test suite.
+tests = test-matherr test-fenv atest-exp atest-sincos atest-exp2 basic-test \
+	test-misc test-fpucw tst-definitions test-tgmath test-tgmath-ret \
+	bug-nextafter bug-nexttoward bug-tgmath1
+# We do the `long double' tests only if this data type is available and
+# distinct from `double'.
+test-longdouble-yes = test-ldouble test-ildoubl
+distribute += $(test-longdouble-yes:=.c)
+
+ifneq (no,$(PERL))
+libm-tests = test-float test-double $(test-longdouble-$(long-double-fcts)) \
+	test-ifloat test-idouble
+libm-tests.o = $(addsuffix .o,$(libm-tests))
+
+tests += $(libm-tests)
+libm-tests-generated = libm-test-ulps.h libm-test.c
+generated += $(libm-tests-generated) libm-test.stmp
+
+# This is needed for dependencies
+before-compile += $(objpfx)libm-test.c
+
+ulps-file = $(firstword $(wildcard $(config-sysdirs:%=$(..)%/libm-test-ulps)))
+
+$(addprefix $(objpfx), $(libm-tests-generated)): $(objpfx)libm-test.stmp
+
+$(objpfx)libm-test.stmp: $(ulps-file) libm-test.inc gen-libm-test.pl
+	$(make-target-directory)
+	$(PERL) gen-libm-test.pl -u $< -o "$(objpfx)"
+	@echo > $@
+
+$(objpfx)test-float.o: $(objpfx)libm-test.stmp
+$(objpfx)test-ifloat.o: $(objpfx)libm-test.stmp
+$(objpfx)test-double.o: $(objpfx)libm-test.stmp
+$(objpfx)test-idouble.o: $(objpfx)libm-test.stmp
+$(objpfx)test-ldouble.o: $(objpfx)libm-test.stmp
+$(objpfx)test-ildoubl.o: $(objpfx)libm-test.stmp
+endif
+
+CFLAGS-test-float.c = -fno-inline -ffloat-store -fno-builtin
+CFLAGS-test-double.c = -fno-inline -ffloat-store -fno-builtin
+CFLAGS-test-ldouble.c = -fno-inline -ffloat-store -fno-builtin
+CFLAGS-test-tgmath.c = -fno-builtin
+CFLAGS-test-tgmath-ret.c = -fno-builtin
+CPPFLAGS-test-ifloat.c = -U__LIBC_INTERNAL_MATH_INLINES -D__FAST_MATH__ \
+			 -DTEST_FAST_MATH -fno-builtin
+CPPFLAGS-test-idouble.c = -U__LIBC_INTERNAL_MATH_INLINES -D__FAST_MATH__ \
+			 -DTEST_FAST_MATH -fno-builtin
+CPPFLAGS-test-ildoubl.c = -U__LIBC_INTERNAL_MATH_INLINES -D__FAST_MATH__ \
+			  -DTEST_FAST_MATH -fno-builtin
+
+distribute += libm-test.inc gen-libm-test.pl README.libm-test
+
+
+# The -lieee module sets the _LIB_VERSION_ switch to IEEE mode
+# for error handling in the -lm functions.
+install-lib += libieee.a
+non-lib.a += libieee.a
+extra-objs += libieee.a ieee-math.o
+distribute += ieee-math.c
+
+include ../Rules
+
+
+# This file defines the default _LIB_VERSION variable that controls
+# the error return conventions for the math functions.
+CPPFLAGS-s_lib_version.c := -D_POSIX_MODE
+
+# We don't want the fdlibm code to use the inline math functions,
+# only the fdlibm code.
+math-CPPFLAGS += -D__NO_MATH_INLINES -D__LIBC_INTERNAL_MATH_INLINES
+
+ifneq ($(long-double-fcts),yes)
+# The `double' and `long double' types are the same on this machine.
+# We won't compile the `long double' code at all.  Tell the `double' code
+# to define aliases for the `FUNCl' names.  To avoid type conflicts in
+# defining those aliases, tell <math.h> to declare the `FUNCl' names with
+# `double' instead of `long double'.
+math-CPPFLAGS += -DNO_LONG_DOUBLE -D_Mlong_double_=double
+endif
+
+# The fdlibm code generates a lot of these warnings but is otherwise clean.
+override CFLAGS += -Wno-uninitialized
+
+# The -lieee library is actually an object file.
+# The module just defines the _LIB_VERSION_ variable.
+# It's not a library to make sure it is linked in instead of s_lib_version.o.
+$(objpfx)libieee.a: $(objpfx)ieee-math.o
+	rm -f $@
+	$(patsubst %/,cd % &&,$(objpfx)) \
+	$(LN_S) $(<F) $(@F)
+
+ifeq ($(build-shared),yes)
+$(addprefix $(objpfx),$(tests)): $(objpfx)libm.so$(libm.so-version)
+else
+$(addprefix $(objpfx),$(tests)): $(objpfx)libm.a
+endif
+ifeq ($(build-bounded),yes)
+$(tests:%=$(objpfx)%-bp): $(objpfx)libm_b.a
+endif
+
+ifeq ($(build-static),yes)
+o = .o
+else
+o = .os
+endif
+gmp-objs = $(patsubst %,$(common-objpfx)stdlib/%$o,\
+		      add_n sub_n cmp addmul_1 mul_1 mul_n divmod_1 \
+		      lshift rshift mp_clz_tab udiv_qrnnd inlines)
+$(objpfx)atest-exp: $(gmp-objs)
+$(objpfx)atest-sincos: $(gmp-objs)
+$(objpfx)atest-exp2: $(gmp-objs)
+
+# Depend on libc.so so a DT_NEEDED is generated in the shared objects.
+# This ensures they will load libc.so for needed symbols if loaded by
+# a statically-linked program that hasn't already loaded it.
+$(objpfx)libm.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a
Index: trunk/src/libctests/glibc/math/README.libm-test
===================================================================
--- trunk/src/libctests/glibc/math/README.libm-test	(revision 2036)
+++ trunk/src/libctests/glibc/math/README.libm-test	(revision 2036)
@@ -0,0 +1,107 @@
+README for libm-test math test suite
+====================================
+
+The libm-test math test suite tests a number of function points of
+math functions in the GNU C library.  The following sections contain a
+brief overview.  Please note that the test drivers and the Perl script
+"gen-libm-test.pl" have some options.  A full list of options is
+available with --help (for the test drivers) and -h for
+"gen-libm-test.pl".
+
+
+What is tested?
+===============
+The tests just evaluate the functions at specified points and compare
+the results with precomputed values and the requirements of the ISO
+C99 standard.
+
+Besides testing the special values mandated by IEEE 754 (infinities,
+NaNs and minus zero), some more or less random values are tested.
+
+Files that are part of libm-test
+================================
+
+The main file is "libm-test.inc".  It is platform and floating point
+format independent.  The file must be preprocessed by the Perl script
+"gen-libm-test.pl".  The results are "libm-test.c" and a file
+"libm-test-ulps.h" with platform specific deltas.
+
+The test drivers test-double.c, test-float.c, test-ldouble.c test the
+normal double, float and long double implementation of libm.  The test
+drivers with an i in it (test-idouble.c, test-ifloat.c,
+test-ildoubl.c) test the corresponding inline functions (where
+available - otherwise they also test the real functions in libm).
+
+"gen-libm-test.pl" needs a platform specific files with ULPs (Units of
+Last Precision).  The file is called "libm-test-ulps" and lives in
+platform specific sysdep directory.
+
+How can I generate "libm-test-ulps"?
+====================================
+
+The test drivers have an option "-u" to output an unsorted list of all
+epsilons that the functions have.  The output can be read in directly
+but it's better to pretty print it first.  "gen-libm-test.pl"  has an option
+to generate a pretty-printed and sorted new ULPs file from the output
+of the test drivers.
+
+To generate a new "libm-test-ulps" file, first remove "ULPs" file in the
+current directory, then you can execute for example:
+test-double -u --ignore-max-ulp=yes
+This generates a file "ULPs" with all double ULPs in it, ignoring any
+previous calculated ULPs.
+Now generate the ULPs for all other formats, the tests will be appending
+the data to the "ULPs" file.  As final step run "gen-libm-test.pl" with the
+file as input and ask to generate a pretty printed output in the file "NewUlps":
+  gen-libm-test.pl -u ULPs -n
+
+Now you can rename "NewUlps" to "libm-test-ulps" and move it into
+sysdeps.
+
+Contents of libm-test-ulps
+==========================
+Since libm-test-ulps can be generated automatically, just a few
+notes.  The file contains lines for single tests, like:
+Test "cos (pi/2) == 0":
+float:  1
+
+and lines for maximal errors of single functions, like:
+Function "yn":
+idouble:  6.0000
+
+The keywords are float, ifloat, double, idouble, ldouble and ildouble
+(the prefix i stands for inline).  You can also specify known
+failures, e.g.:
+
+Test "cos (pi/2) == 0":
+float:  1
+float: fail
+
+Adding tests to libm-test.inc
+=============================
+
+The tests are evaluated by a set of special test macros.  The macros
+start with "TEST_" followed by a specification the input values, an
+underscore and a specification of the output values.  As an example,
+the test macro for a function with input of type FLOAT (FLOAT is
+either float, double, long double) and output of type FLOAT is
+"TEST_f_f".  The macro's parameter are the name of the function, the
+input parameter, output parameter and optionally one exception
+parameter.
+
+The accepted parameter types are:
+- "f" for FLOAT
+- "b" for boolean - just tests if the output parameter evaluates to 0
+  or 1 (only for output).
+- "c" for complex.  This parameter needs two values, first the real,
+  then the imaginary part.
+- "i" for int.
+- "l" for long int.
+- "L" for long long int.
+- "F" for the address of a FLOAT (only as input parameter)
+- "I" for the address of an int (only as input parameter)
+
+Some functions need special handling.  For example gamma sets the
+global variable signgam and frexp takes an argument to &int.  This
+special treatment is coded in "gen-libm-test.pl" and used while
+parsing "libm-test.inc".
Index: trunk/src/libctests/glibc/math/atest-exp.c
===================================================================
--- trunk/src/libctests/glibc/math/atest-exp.c	(revision 2036)
+++ trunk/src/libctests/glibc/math/atest-exp.c	(revision 2036)
@@ -0,0 +1,191 @@
+/* Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Geoffrey Keating <Geoff.Keating@anu.edu.au>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <math.h>
+#include <gmp.h>
+#include <string.h>
+#include <limits.h>
+#include <assert.h>
+
+#define PRINT_ERRORS 0
+
+#define TOL 80
+#define N2 17
+#define FRAC (32*4)
+
+#define mpbpl (CHAR_BIT * sizeof (mp_limb_t))
+#define SZ (FRAC / mpbpl + 1)
+typedef mp_limb_t mp1[SZ], mp2[SZ * 2];
+
+/* This string has 101 hex digits.  */
+static const char exp1[102] = "2" /* point */
+"b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a7"
+"84d9045190cfef324e7738926cfbe5f4bf8d8d8c31d763da07";
+static const char hexdig[] = "0123456789abcdef";
+
+static void
+print_mpn_hex (const mp_limb_t *x, unsigned size)
+{
+   char value[size + 1];
+   unsigned i;
+   const unsigned final = (size * 4 > SZ * mpbpl) ? SZ * mpbpl / 4 : size;
+
+   memset (value, '0', size);
+
+   for (i = 0; i < final ; i++)
+     value[size - 1 - i] = hexdig[x[i * 4 / mpbpl] >> (i * 4) % mpbpl & 0xf];
+
+   value[size] = '\0';
+   fputs (value, stdout);
+}
+
+static void
+exp_mpn (mp1 ex, mp1 x)
+{
+   unsigned n;
+   mp1 xp;
+   mp2 tmp;
+   mp_limb_t chk, round;
+   mp1 tol;
+
+   memset (xp, 0, sizeof (mp1));
+   memset (ex, 0, sizeof (mp1));
+   xp[FRAC / mpbpl] = (mp_limb_t)1 << FRAC % mpbpl;
+   memset (tol,0, sizeof (mp1));
+   tol[(FRAC - TOL) / mpbpl] = (mp_limb_t)1 << (FRAC - TOL) % mpbpl;
+
+   n = 0;
+
+   do
+     {
+       /* Calculate sum(x^n/n!) until the next term is sufficiently small.  */
+
+       mpn_mul_n (tmp, xp, x, SZ);
+       assert (tmp[SZ * 2 - 1] == 0);
+       if (n > 0)
+	 round = mpn_divmod_1 (xp, tmp + FRAC / mpbpl, SZ, n);
+       chk = mpn_add_n (ex, ex, xp, SZ);
+       assert (chk == 0);
+       n++;
+       assert (n < 80); /* Catch too-high TOL.  */
+     }
+   while (n < 10 || mpn_cmp (xp, tol, SZ) >= 0);
+}
+
+static int
+mpn_bitsize(const mp_limb_t *SRC_PTR, mp_size_t SIZE)
+{
+   int i, j;
+   for (i = SIZE - 1; i > 0; i--)
+     if (SRC_PTR[i] != 0)
+       break;
+   for (j = mpbpl - 1; j >= 0; j--)
+     if ((SRC_PTR[i] & (mp_limb_t)1 << j) != 0)
+       break;
+
+   return i * mpbpl + j;
+}
+
+int
+main (void)
+{
+   mp1 ex, x, xt, e2, e3;
+   int i;
+   int errors = 0;
+   int failures = 0;
+   mp1 maxerror;
+   int maxerror_s = 0;
+   const double sf = pow (2, mpbpl);
+
+   /* assert (mpbpl == mp_bits_per_limb); */
+   assert (FRAC / mpbpl * mpbpl == FRAC);
+
+   memset (maxerror, 0, sizeof (mp1));
+   memset (xt, 0, sizeof (mp1));
+   xt[(FRAC - N2) / mpbpl] = (mp_limb_t)1 << (FRAC - N2) % mpbpl;
+
+   for (i = 0; i < 1 << N2; i++)
+   {
+      int e2s, e3s, j;
+      double de2;
+
+      mpn_mul_1 (x,xt,SZ,i);
+      exp_mpn (ex, x);
+      de2 = exp (i / (double) (1 << N2));
+      for (j = SZ-1; j >= 0; j--)
+	{
+	  e2[j] = (mp_limb_t) de2;
+	  de2 = (de2 - e2[j]) * sf;
+	}
+      if (mpn_cmp (ex,e2,SZ) >= 0)
+	mpn_sub_n (e3,ex,e2,SZ);
+      else
+	mpn_sub_n (e3,e2,ex,SZ);
+
+      e2s = mpn_bitsize (e2,SZ);
+      e3s = mpn_bitsize (e3,SZ);
+      if (e3s >= 0 && e2s - e3s < 54)
+	{
+#if PRINT_ERRORS
+	  printf ("%06x ", i * (0x100000 / (1 << N2)));
+	  print_mpn_hex (ex, (FRAC / 4) + 1);
+	  fputs ("\n       ",stdout);
+	  print_mpn_hex (e2, (FRAC / 4) + 1);
+	  printf ("\n %c     ",
+		  e2s - e3s < 54 ? e2s - e3s == 53 ? 'e' : 'F' : 'P');
+	  print_mpn_hex (e3, (FRAC / 4) + 1);
+	  putchar ('\n');
+#endif
+	 errors += (e2s - e3s == 53);
+	 failures += (e2s - e3s < 53);
+	}
+      if (e3s >= maxerror_s
+	  && mpn_cmp (e3, maxerror, SZ) > 0)
+	{
+	  memcpy (maxerror, e3, sizeof (mp1));
+	  maxerror_s = e3s;
+	}
+   }
+
+   /* Check exp_mpn against precomputed value of exp(1).  */
+   memset (x, '\0', sizeof (mp1));
+   x[FRAC / mpbpl] = (mp_limb_t)1 << FRAC % mpbpl;
+   exp_mpn (ex, x);
+
+   memset (e2, '\0', sizeof (mp1));
+   for (i = -1; i < 100 && i < FRAC / 4; i++)
+     e2[(FRAC - i * 4 - 4) / mpbpl] |= ((strchr (hexdig, exp1[i + 1]) - hexdig)
+					<< (FRAC - i * 4 - 4) % mpbpl);
+
+   if (mpn_cmp (ex, e2, SZ) >= 0)
+     mpn_sub_n (e3, ex, e2, SZ);
+   else
+     mpn_sub_n (e3, e2, ex, SZ);
+
+   printf ("%d failures; %d errors; error rate %0.2f%%\n", failures, errors,
+	   errors * 100.0 / (double) (1 << N2));
+   fputs ("maximum error:   ", stdout);
+   print_mpn_hex (maxerror, (FRAC / 4) + 1);
+   fputs ("\nerror in exp(1): ", stdout);
+   print_mpn_hex (e3, (FRAC / 4) + 1);
+   putchar ('\n');
+
+   return failures == 0 ? 0 : 1;
+}
Index: trunk/src/libctests/glibc/math/atest-exp2.c
===================================================================
--- trunk/src/libctests/glibc/math/atest-exp2.c	(revision 2036)
+++ trunk/src/libctests/glibc/math/atest-exp2.c	(revision 2036)
@@ -0,0 +1,240 @@
+/* Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Geoffrey Keating <Geoff.Keating@anu.edu.au>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <math.h>
+#include <gmp.h>
+#include <string.h>
+#include <limits.h>
+#include <assert.h>
+#include <stdlib.h>
+
+#define PRINT_ERRORS 0
+
+#define TOL 80
+#define N2 18
+#define FRAC (32*4)
+
+#define mpbpl (CHAR_BIT * sizeof (mp_limb_t))
+#define SZ (FRAC / mpbpl + 1)
+typedef mp_limb_t mp1[SZ], mp2[SZ * 2];
+
+/* This string has 101 hex digits.  */
+static const char exp1[102] = "2" /* point */
+"b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a7"
+"84d9045190cfef324e7738926cfbe5f4bf8d8d8c31d763da07";
+static const char exp_m1[102] = "0" /* point */
+"5e2d58d8b3bcdf1abadec7829054f90dda9805aab56c773330"
+"24b9d0a507daedb16400bf472b4215b8245b669d90d27a5aea";
+
+static const char hexdig[] = "0123456789abcdef";
+
+static void
+print_mpn_fp (const mp_limb_t *x, unsigned int dp, unsigned int base)
+{
+   unsigned int i;
+   mp1 tx;
+
+   memcpy (tx, x, sizeof (mp1));
+   if (base == 16)
+     fputs ("0x", stdout);
+   assert (x[SZ-1] < base);
+   fputc (hexdig[x[SZ - 1]], stdout);
+   fputc ('.', stdout);
+   for (i = 0; i < dp; i++)
+     {
+       tx[SZ - 1] = 0;
+       mpn_mul_1 (tx, tx, SZ, base);
+       assert (tx[SZ - 1] < base);
+       fputc (hexdig[tx[SZ - 1]], stdout);
+     }
+}
+
+static void
+read_mpn_hex(mp_limb_t *x, const char *str)
+{
+  int i;
+
+  memset (x, 0, sizeof (mp1));
+  for (i = -1; i < 100 && i < FRAC / 4; ++i)
+    x[(FRAC - i * 4 - 4) / mpbpl] |= ((strchr (hexdig, str[i + 1]) - hexdig)
+				      << (FRAC - i * 4 - 4) % mpbpl);
+}
+
+static mp_limb_t *get_log2(void) __attribute__((const));
+static mp_limb_t *
+get_log2(void)
+{
+  static mp1 log2_m;
+  static int log2_m_inited = 0;
+  static const char log2[102] = "0" /* point */
+    "b17217f7d1cf79abc9e3b39803f2f6af40f343267298b62d8a"
+    "0d175b8baafa2be7b876206debac98559552fb4afa1b10ed2e";
+
+  if (!log2_m_inited)
+    {
+      read_mpn_hex (log2_m, log2);
+      log2_m_inited = 1;
+    }
+  return log2_m;
+}
+
+/* Compute e^x.  */
+static void
+exp_mpn (mp1 ex, mp1 x)
+{
+   unsigned int n;
+   mp1 xp;
+   mp2 tmp;
+   mp_limb_t chk, round;
+   mp1 tol;
+
+   memset (xp, 0, sizeof (mp1));
+   memset (ex, 0, sizeof (mp1));
+   xp[FRAC / mpbpl] = (mp_limb_t)1 << FRAC % mpbpl;
+   memset (tol, 0, sizeof (mp1));
+   tol[(FRAC - TOL) / mpbpl] = (mp_limb_t)1 << (FRAC - TOL) % mpbpl;
+
+   n = 0;
+
+   do
+     {
+       /* Calculate sum(x^n/n!) until the next term is sufficiently small.  */
+
+       mpn_mul_n (tmp, xp, x, SZ);
+       assert(tmp[SZ * 2 - 1] == 0);
+       if (n > 0)
+	 round = mpn_divmod_1 (xp, tmp + FRAC / mpbpl, SZ, n);
+       chk = mpn_add_n (ex, ex, xp, SZ);
+       assert (chk == 0);
+       ++n;
+       assert (n < 80); /* Catch too-high TOL.  */
+     }
+   while (n < 10 || mpn_cmp (xp, tol, SZ) >= 0);
+}
+
+/* Calculate 2^x.  */
+static void
+exp2_mpn (mp1 ex, mp1 x)
+{
+  mp2 tmp;
+  mpn_mul_n (tmp, x, get_log2 (), SZ);
+  assert(tmp[SZ * 2 - 1] == 0);
+  exp_mpn (ex, tmp + FRAC / mpbpl);
+}
+
+
+static int
+mpn_bitsize(const mp_limb_t *SRC_PTR, mp_size_t SIZE)
+{
+  int i, j;
+  for (i = SIZE - 1; i > 0; --i)
+    if (SRC_PTR[i] != 0)
+      break;
+  for (j = mpbpl - 1; j >= 0; --j)
+    if ((SRC_PTR[i] & (mp_limb_t)1 << j) != 0)
+      break;
+
+  return i * mpbpl + j;
+}
+
+int
+main (void)
+{
+  mp1 ex, x, xt, e2, e3;
+  int i;
+  int errors = 0;
+  int failures = 0;
+  mp1 maxerror;
+  int maxerror_s = 0;
+  const double sf = pow (2, mpbpl);
+
+  /* assert(mpbpl == mp_bits_per_limb); */
+  assert(FRAC / mpbpl * mpbpl == FRAC);
+
+  memset (maxerror, 0, sizeof (mp1));
+  memset (xt, 0, sizeof (mp1));
+  xt[(FRAC - N2) / mpbpl] = (mp_limb_t)1 << (FRAC - N2) % mpbpl;
+
+  for (i = 0; i < (1 << N2); ++i)
+    {
+      int e2s, e3s, j;
+      double de2;
+
+      mpn_mul_1 (x, xt, SZ, i);
+      exp2_mpn (ex, x);
+      de2 = exp2 (i / (double) (1 << N2));
+      for (j = SZ - 1; j >= 0; --j)
+	{
+	  e2[j] = (mp_limb_t) de2;
+	  de2 = (de2 - e2[j]) * sf;
+	}
+      if (mpn_cmp (ex, e2, SZ) >= 0)
+	mpn_sub_n (e3, ex, e2, SZ);
+      else
+	mpn_sub_n (e3, e2, ex, SZ);
+
+      e2s = mpn_bitsize (e2, SZ);
+      e3s = mpn_bitsize (e3, SZ);
+      if (e3s >= 0 && e2s - e3s < 54)
+	{
+#if PRINT_ERRORS
+	  printf ("%06x ", i * (0x100000 / (1 << N2)));
+	  print_mpn_fp (ex, (FRAC / 4) + 1, 16);
+	  putchar ('\n');
+	  fputs ("       ",stdout);
+	  print_mpn_fp (e2, (FRAC / 4) + 1, 16);
+	  putchar ('\n');
+	  printf (" %c     ",
+		  e2s - e3s < 54 ? e2s - e3s == 53 ? 'e' : 'F' : 'P');
+	  print_mpn_fp (e3, (FRAC / 4) + 1, 16);
+	  putchar ('\n');
+#endif
+	  errors += (e2s - e3s == 53);
+	  failures += (e2s - e3s < 53);
+	}
+      if (e3s >= maxerror_s
+	  && mpn_cmp (e3, maxerror, SZ) > 0)
+	{
+	  memcpy (maxerror, e3, sizeof (mp1));
+	  maxerror_s = e3s;
+	}
+    }
+
+  /* Check exp_mpn against precomputed value of exp(1).  */
+  memset (x, 0, sizeof (mp1));
+  x[FRAC / mpbpl] = (mp_limb_t)1 << FRAC % mpbpl;
+  exp_mpn (ex, x);
+  read_mpn_hex (e2, exp1);
+  if (mpn_cmp (ex, e2, SZ) >= 0)
+    mpn_sub_n (e3, ex, e2, SZ);
+  else
+    mpn_sub_n (e3, e2, ex, SZ);
+
+  printf ("%d failures; %d errors; error rate %0.2f%%\n", failures, errors,
+	  errors * 100.0 / (double) (1 << N2));
+  fputs ("maximum error:   ", stdout);
+  print_mpn_fp (maxerror, (FRAC / 4) + 1, 16);
+  putchar ('\n');
+  fputs ("error in exp(1): ", stdout);
+  print_mpn_fp (e3, (FRAC / 4) + 1, 16);
+  putchar ('\n');
+
+  return failures == 0 ? 0 : 1;
+}
Index: trunk/src/libctests/glibc/math/atest-sincos.c
===================================================================
--- trunk/src/libctests/glibc/math/atest-sincos.c	(revision 2036)
+++ trunk/src/libctests/glibc/math/atest-sincos.c	(revision 2036)
@@ -0,0 +1,275 @@
+/* Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Geoffrey Keating <Geoff.Keating@anu.edu.au>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <math.h>
+#include <gmp.h>
+#include <string.h>
+#include <limits.h>
+#include <assert.h>
+
+#define PRINT_ERRORS 0
+
+#define N 0
+#define N2 20
+#define FRAC (32 * 4)
+
+#define mpbpl (CHAR_BIT * sizeof (mp_limb_t))
+#define SZ (FRAC / mpbpl + 1)
+typedef mp_limb_t mp1[SZ], mp2[SZ * 2];
+
+/* These strings have exactly 100 hex digits in them.  */
+static const char sin1[101] =
+"d76aa47848677020c6e9e909c50f3c3289e511132f518b4def"
+"b6ca5fd6c649bdfb0bd9ff1edcd4577655b5826a3d3b50c264";
+static const char cos1[101] =
+"8a51407da8345c91c2466d976871bd29a2373a894f96c3b7f2"
+"300240b760e6fa96a94430a52d0e9e43f3450e3b8ff99bc934";
+static const char hexdig[] = "0123456789abcdef";
+
+static void
+print_mpn_hex (const mp_limb_t *x, unsigned size)
+{
+   char value[size + 1];
+   unsigned i;
+   const unsigned final = (size * 4 > SZ * mpbpl) ? SZ * mpbpl / 4 : size;
+
+   memset (value, '0', size);
+
+   for (i = 0; i < final ; i++)
+     value[size-1-i] = hexdig[x[i * 4 / mpbpl] >> (i * 4) % mpbpl & 0xf];
+
+   value[size] = '\0';
+   fputs (value, stdout);
+}
+
+static void
+sincosx_mpn (mp1 si, mp1 co, mp1 xx, mp1 ix)
+{
+   int i;
+   mp2 s[4], c[4];
+   mp1 tmp, x;
+   mp_limb_t chk, round;
+
+   if (ix == NULL)
+     {
+       memset (si, 0, sizeof (mp1));
+       memset (co, 0, sizeof (mp1));
+       co[SZ-1] = 1;
+       memcpy (x, xx, sizeof (mp1));
+     }
+   else
+      mpn_sub_n (x, xx, ix, SZ);
+
+   for (i = 0; i < 1 << N; i++)
+     {
+#define add_shift_mulh(d,x,s1,s2,sh,n) \
+       /* d = (n ? -1 : 1) * (s1 + (s2>>sh)) * x / (1>>N); */		      \
+      do { 								      \
+	 if (s2 != NULL) {						      \
+	    if (sh > 0) {						      \
+	       assert (sh < mpbpl);					      \
+	       mpn_lshift (tmp, s1, SZ, sh);				      \
+	       chk = (n ? mpn_sub_n : mpn_add_n)(tmp,tmp,s2+FRAC/mpbpl,SZ);   \
+	    } else							      \
+	       chk = (n ? mpn_sub_n : mpn_add_n)(tmp,s1,s2+FRAC/mpbpl,SZ);    \
+	    /* assert(chk == 0); */					      \
+	    mpn_mul_n(d,tmp,x,SZ);					      \
+	 } else 							      \
+	    mpn_mul_n(d,s1,x,SZ);					      \
+	 /* assert(d[SZ*2-1] == 0); */					      \
+	 assert(N+sh < mpbpl);						      \
+	 if (N+sh > 0) mpn_rshift(d,d,2*SZ,N+sh);			      \
+      } while(0)
+#define summ(d,ss,s,n) \
+      /* d = ss +/- (s[0]+2*s[1]+2*s[2]+s[3])/6; */			      \
+      do { 								      \
+	 chk = mpn_add_n(tmp,s[1]+FRAC/mpbpl,s[2]+FRAC/mpbpl,SZ);	      \
+	 mpn_lshift(tmp,tmp,SZ,1);					      \
+	 chk |= mpn_add_n(tmp,tmp,s[0]+FRAC/mpbpl,SZ);			      \
+	 chk |= mpn_add_n(tmp,tmp,s[3]+FRAC/mpbpl,SZ);			      \
+	 round = mpn_divmod_1(tmp,tmp,SZ,6);				      \
+	 /* chk |= mpn_add_1(tmp,tmp,SZ, (round > 3) ); */		      \
+         chk |= (n ? mpn_sub_n : mpn_add_n)(d,ss,tmp,SZ);		      \
+	 /* assert(chk == 0); */					      \
+      } while (0)
+
+      add_shift_mulh (s[0], x, co, NULL, 0, 0); /* s0 = h * c; */
+      add_shift_mulh (c[0], x, si, NULL, 0, 0); /* c0 = h * s; */
+      add_shift_mulh (s[1], x, co, c[0], 1, 1); /* s1 = h * (c - c0/2); */
+      add_shift_mulh (c[1], x, si, s[0], 1, 0); /* c1 = h * (s + s0/2); */
+      add_shift_mulh (s[2], x, co, c[1], 1, 1); /* s2 = h * (c - c1/2); */
+      add_shift_mulh (c[2], x, si, s[1], 1, 0); /* c2 = h * (s + s1/2); */
+      add_shift_mulh (s[3], x, co, c[2], 0, 1); /* s3 = h * (c - c2); */
+      add_shift_mulh (c[3], x, si, s[2], 0, 0); /* c3 = h * (s + s2); */
+      summ (si, si, s, 0);        /* s = s + (s0+2*s1+2*s2+s3)/6; */
+      summ (co, co, c, 1);        /* c = c - (c0+2*c1+2*c2+c3)/6; */
+   }
+#undef add_shift_mulh
+#undef summ
+}
+
+static int
+mpn_bitsize (const mp_limb_t *SRC_PTR, mp_size_t SIZE)
+{
+   int i, j;
+   for (i = SIZE - 1; i > 0; i--)
+     if (SRC_PTR[i] != 0)
+       break;
+   for (j = mpbpl - 1; j >= 0; j--)
+     if ((SRC_PTR[i] & (mp_limb_t)1 << j) != 0)
+       break;
+
+   return i * mpbpl + j;
+}
+
+int
+main (void)
+{
+  mp1 si, co, x, ox, xt, s2, c2, s3, c3;
+  int i;
+  int sin_errors = 0, cos_errors = 0;
+  int sin_failures = 0, cos_failures = 0;
+  mp1 sin_maxerror, cos_maxerror;
+  int sin_maxerror_s = 0, cos_maxerror_s = 0;
+  const double sf = pow (2, mpbpl);
+
+  /* assert(mpbpl == mp_bits_per_limb);  */
+  assert(FRAC / mpbpl * mpbpl == FRAC);
+
+  memset (sin_maxerror, 0, sizeof (mp1));
+  memset (cos_maxerror, 0, sizeof (mp1));
+  memset (xt, 0, sizeof (mp1));
+  xt[(FRAC - N2) / mpbpl] = (mp_limb_t)1 << (FRAC - N2) % mpbpl;
+
+  for (i = 0; i < 1 << N2; i++)
+    {
+      int s2s, s3s, c2s, c3s, j;
+      double ds2,dc2;
+
+      mpn_mul_1 (x, xt, SZ, i);
+      sincosx_mpn (si, co, x, i == 0 ? NULL : ox);
+      memcpy (ox, x, sizeof (mp1));
+      ds2 = sin (i / (double) (1 << N2));
+      dc2 = cos (i / (double) (1 << N2));
+      for (j = SZ-1; j >= 0; j--)
+	{
+	  s2[j] = (mp_limb_t) ds2;
+	  ds2 = (ds2 - s2[j]) * sf;
+	  c2[j] = (mp_limb_t) dc2;
+	  dc2 = (dc2 - c2[j]) * sf;
+	}
+      if (mpn_cmp (si, s2, SZ) >= 0)
+	mpn_sub_n (s3, si, s2, SZ);
+      else
+	mpn_sub_n (s3, s2, si, SZ);
+      if (mpn_cmp (co, c2, SZ) >= 0)
+	mpn_sub_n (c3, co, c2, SZ);
+      else
+	mpn_sub_n (c3, c2, co, SZ);
+
+      s2s = mpn_bitsize (s2, SZ);
+      s3s = mpn_bitsize (s3, SZ);
+      c2s = mpn_bitsize (c2, SZ);
+      c3s = mpn_bitsize (c3, SZ);
+      if ((s3s >= 0 && s2s - s3s < 54)
+	  || (c3s >= 0 && c2s - c3s < 54)
+	  || 0)
+	{
+#if PRINT_ERRORS
+	  printf ("%06x ", i * (0x100000 / (1 << N2)));
+	  print_mpn_hex(si, (FRAC / 4) + 1);
+	  putchar (' ');
+	  print_mpn_hex (co, (FRAC / 4) + 1);
+	  putchar ('\n');
+	  fputs ("       ", stdout);
+	  print_mpn_hex (s2, (FRAC / 4) + 1);
+	  putchar (' ');
+	  print_mpn_hex (c2, (FRAC / 4) + 1);
+	  putchar ('\n');
+	  printf (" %c%c    ",
+		  s3s >= 0 && s2s-s3s < 54 ? s2s - s3s == 53 ? 'e' : 'F' : 'P',
+		  c3s >= 0 && c2s-c3s < 54 ? c2s - c3s == 53 ? 'e' : 'F' : 'P');
+	  print_mpn_hex (s3, (FRAC / 4) + 1);
+	  putchar (' ');
+	  print_mpn_hex (c3, (FRAC / 4) + 1);
+	  putchar ('\n');
+#endif
+	  sin_errors += s2s - s3s == 53;
+	  cos_errors += c2s - c3s == 53;
+	  sin_failures += s2s - s3s < 53;
+	  cos_failures += c2s - c3s < 53;
+	}
+      if (s3s >= sin_maxerror_s
+	  && mpn_cmp (s3, sin_maxerror, SZ) > 0)
+	{
+	  memcpy (sin_maxerror, s3, sizeof (mp1));
+	  sin_maxerror_s = s3s;
+	}
+      if (c3s >= cos_maxerror_s
+	  && mpn_cmp (c3, cos_maxerror, SZ) > 0)
+	{
+	  memcpy (cos_maxerror, c3, sizeof (mp1));
+	  cos_maxerror_s = c3s;
+	}
+    }
+
+   /* Check Range-Kutta against precomputed values of sin(1) and cos(1).  */
+   memset (x, 0, sizeof (mp1));
+   x[FRAC / mpbpl] = (mp_limb_t)1 << FRAC % mpbpl;
+   sincosx_mpn (si, co, x, ox);
+
+   memset (s2, 0, sizeof (mp1));
+   memset (c2, 0, sizeof (mp1));
+   for (i = 0; i < 100 && i < FRAC / 4; i++)
+     {
+       s2[(FRAC - i * 4 - 4) / mpbpl] |= ((strchr (hexdig, sin1[i]) - hexdig)
+					  << (FRAC - i * 4 - 4) % mpbpl);
+       c2[(FRAC - i * 4 - 4) / mpbpl] |= ((strchr (hexdig, cos1[i]) - hexdig)
+					  << (FRAC - i * 4 - 4) % mpbpl);
+     }
+
+   if (mpn_cmp (si, s2, SZ) >= 0)
+     mpn_sub_n (s3, si, s2, SZ);
+   else
+     mpn_sub_n (s3, s2, si, SZ);
+   if (mpn_cmp (co, c2, SZ) >= 0)
+      mpn_sub_n (c3, co, c2, SZ);
+   else
+     mpn_sub_n (c3, c2, co, SZ);
+
+   printf ("sin:\n");
+   printf ("%d failures; %d errors; error rate %0.2f%%\n",
+	   sin_failures, sin_errors, sin_errors * 100.0 / (double) (1 << N2));
+   fputs ("maximum error:   ", stdout);
+   print_mpn_hex (sin_maxerror, (FRAC / 4) + 1);
+   fputs ("\nerror in sin(1): ", stdout);
+   print_mpn_hex (s3, (FRAC / 4) + 1);
+
+   fputs ("\n\ncos:\n", stdout);
+   printf ("%d failures; %d errors; error rate %0.2f%%\n",
+	   cos_failures, cos_errors, cos_errors * 100.0 / (double) (1 << N2));
+   fputs ("maximum error:   ", stdout);
+   print_mpn_hex (cos_maxerror, (FRAC / 4) + 1);
+   fputs ("\nerror in cos(1): ", stdout);
+   print_mpn_hex (c3, (FRAC / 4) + 1);
+   putchar ('\n');
+
+   return (sin_failures == 0 && cos_failures == 0) ? 0 : 1;
+}
Index: trunk/src/libctests/glibc/math/basic-test.c
===================================================================
--- trunk/src/libctests/glibc/math/basic-test.c	(revision 2036)
+++ trunk/src/libctests/glibc/math/basic-test.c	(revision 2036)
@@ -0,0 +1,123 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@suse.de>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <math.h>
+#include <float.h>
+#include <stdio.h>
+
+static int errors = 0;
+
+
+static void
+check (const char *testname, int result)
+{
+  if (!result) {
+    printf ("Failure: %s\n", testname);
+    errors++;
+  }
+}
+
+#define TEST_FUNC(NAME, FLOAT, NANFUNC, EPSILON, HUGEVAL) \
+static void								      \
+NAME (void)								      \
+{									      \
+  /* Variables are declared volatile to forbid some compiler		      \
+     optimizations.  */							      \
+  volatile FLOAT Inf_var, NaN_var, zero_var, one_var;			      \
+  FLOAT x1, x2;								      \
+									      \
+  zero_var = 0.0;							      \
+  one_var = 1.0;							      \
+  NaN_var = zero_var/zero_var;						      \
+  Inf_var = one_var / zero_var;						      \
+									      \
+  (void) &zero_var;							      \
+  (void) &one_var;							      \
+  (void) &NaN_var;							      \
+  (void) &Inf_var;							      \
+									      \
+									      \
+  check (#FLOAT " isinf (inf) == 1", isinf (Inf_var) == 1);		      \
+  check (#FLOAT " isinf (-inf) == -1", isinf (-Inf_var) == -1);		      \
+  check (#FLOAT " !isinf (1)", !(isinf (one_var)));			      \
+  check (#FLOAT " !isinf (NaN)", !(isinf (NaN_var)));			      \
+									      \
+  check (#FLOAT " isnan (NaN)", isnan (NaN_var));			      \
+  check (#FLOAT " isnan (-NaN)", isnan (-NaN_var));			      \
+  check (#FLOAT " !isnan (1)", !(isnan (one_var)));			      \
+  check (#FLOAT " !isnan (inf)", !(isnan (Inf_var)));			      \
+									      \
+  check (#FLOAT " inf == inf", Inf_var == Inf_var);			      \
+  check (#FLOAT " -inf == -inf", -Inf_var == -Inf_var);			      \
+  check (#FLOAT " inf != -inf", Inf_var != -Inf_var);			      \
+  check (#FLOAT " NaN != NaN", NaN_var != NaN_var);			      \
+									      \
+  /*									      \
+     the same tests but this time with NAN from <bits/nan.h>		      \
+     NAN is a double const						      \
+   */									      \
+  check (#FLOAT " isnan (NAN)", isnan (NAN));				      \
+  check (#FLOAT " isnan (-NAN)", isnan (-NAN));				      \
+  check (#FLOAT " !isinf (NAN)", !(isinf (NAN)));			      \
+  check (#FLOAT " !isinf (-NAN)", !(isinf (-NAN)));			      \
+  check (#FLOAT " NAN != NAN", NAN != NAN);				      \
+									      \
+  /*									      \
+     And again with the value returned by the `nan' function.		      \
+   */									      \
+  check (#FLOAT " isnan (NAN)", isnan (NANFUNC ("")));			      \
+  check (#FLOAT " isnan (-NAN)", isnan (-NANFUNC ("")));		      \
+  check (#FLOAT " !isinf (NAN)", !(isinf (NANFUNC (""))));		      \
+  check (#FLOAT " !isinf (-NAN)", !(isinf (-NANFUNC (""))));		      \
+  check (#FLOAT " NAN != NAN", NANFUNC ("") != NANFUNC (""));		      \
+									      \
+  /* test if EPSILON is ok */						      \
+  x1 = 1.0;								      \
+  x2 = x1 + EPSILON;							      \
+  check (#FLOAT " 1 != 1+EPSILON", x1 != x2);				      \
+									      \
+  x1 = 1.0;								      \
+  x2 = x1 - EPSILON;							      \
+  check (#FLOAT " 1 != 1-EPSILON", x1 != x2);				      \
+									      \
+  /* test if HUGE_VALx is ok */						      \
+  x1 = HUGEVAL;								      \
+  check (#FLOAT " isinf (HUGE_VALx) == +1", isinf (x1) == +1);		      \
+  x1 = - HUGEVAL;							      \
+  check (#FLOAT " isinf (-HUGE_VALx) == -1", isinf (x1) == -1);		      \
+}
+
+TEST_FUNC (float_test, float, nanf, FLT_EPSILON, HUGE_VALF)
+TEST_FUNC (double_test, double, nan, DBL_EPSILON, HUGE_VAL)
+#ifndef NO_LONG_DOUBLE
+TEST_FUNC (ldouble_test, long double, nanl, LDBL_EPSILON, HUGE_VALL)
+#endif
+
+int
+main (void)
+{
+  float_test ();
+  double_test ();
+
+#ifndef NO_LONG_DOUBLE
+  ldouble_test ();
+#endif
+
+  return errors != 0;
+}
Index: trunk/src/libctests/glibc/math/bug-nextafter.c
===================================================================
--- trunk/src/libctests/glibc/math/bug-nextafter.c	(revision 2036)
+++ trunk/src/libctests/glibc/math/bug-nextafter.c	(revision 2036)
@@ -0,0 +1,63 @@
+#include <fenv.h>
+#include <math.h>
+#include <float.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+int
+main (void)
+{
+  int result = 0;
+
+  float i = INFINITY;
+  float m = FLT_MAX;
+  feclearexcept (FE_ALL_EXCEPT);
+  if (nextafterf (m, i) != i)
+    {
+      puts ("nextafterf+ failed");
+      ++result;
+    }
+  if (fetestexcept (FE_OVERFLOW) == 0)
+    {
+      puts ("nextafterf+ did not overflow");
+      ++result;
+    }
+  feclearexcept (FE_ALL_EXCEPT);
+  if (nextafterf (-m, -i) != -i)
+    {
+      puts ("nextafterf- failed");
+      ++result;
+    }
+  if (fetestexcept (FE_OVERFLOW) == 0)
+    {
+      puts ("nextafterf- did not overflow");
+      ++result;
+    }
+
+  double di = INFINITY;
+  double dm = DBL_MAX;
+  feclearexcept (FE_ALL_EXCEPT);
+  if (nextafter (dm, di) != di)
+    {
+      puts ("nextafter+ failed");
+      ++result;
+    }
+  if (fetestexcept (FE_OVERFLOW) == 0)
+    {
+      puts ("nextafter+ did not overflow");
+      ++result;
+    }
+  feclearexcept (FE_ALL_EXCEPT);
+  if (nextafter (-dm, -di) != -di)
+    {
+      puts ("nextafter failed");
+      ++result;
+    }
+  if (fetestexcept (FE_OVERFLOW) == 0)
+    {
+      puts ("nextafter- did not overflow");
+      ++result;
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/math/bug-nexttoward.c
===================================================================
--- trunk/src/libctests/glibc/math/bug-nexttoward.c	(revision 2036)
+++ trunk/src/libctests/glibc/math/bug-nexttoward.c	(revision 2036)
@@ -0,0 +1,65 @@
+#include <fenv.h>
+#include <math.h>
+#include <float.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+int
+main (void)
+{
+  int result = 0;
+
+  long double tl = (long double) FLT_MAX + 0x1.0p128L;
+  float fi = INFINITY;
+  float m = FLT_MAX;
+  feclearexcept (FE_ALL_EXCEPT);
+  if (nexttowardf (m, tl) != fi)
+    {
+      puts ("nexttowardf+ failed");
+      ++result;
+    }
+  if (fetestexcept (FE_OVERFLOW) == 0)
+    {
+      puts ("nexttowardf+ did not overflow");
+      ++result;
+    }
+  feclearexcept (FE_ALL_EXCEPT);
+  if (nexttowardf (-m, -tl) != -fi)
+    {
+      puts ("nexttowardf- failed");
+      ++result;
+    }
+  if (fetestexcept (FE_OVERFLOW) == 0)
+    {
+      puts ("nexttowardf- did not overflow");
+      ++result;
+    }
+
+  tl = (long double) DBL_MAX + 1.0e305L;
+  double di = INFINITY;
+  double dm = DBL_MAX;
+  feclearexcept (FE_ALL_EXCEPT);
+  if (nexttoward (dm, tl) != di)
+    {
+      puts ("nexttoward+ failed");
+      ++result;
+    }
+  if (fetestexcept (FE_OVERFLOW) == 0)
+    {
+      puts ("nexttoward+ did not overflow");
+      ++result;
+    }
+  feclearexcept (FE_ALL_EXCEPT);
+  if (nexttoward (-dm, -tl) != -di)
+    {
+      puts ("nexttoward- failed");
+      ++result;
+    }
+  if (fetestexcept (FE_OVERFLOW) == 0)
+    {
+      puts ("nexttoward- did not overflow");
+      ++result;
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/math/bug-tgmath1.c
===================================================================
--- trunk/src/libctests/glibc/math/bug-tgmath1.c	(revision 2036)
+++ trunk/src/libctests/glibc/math/bug-tgmath1.c	(revision 2036)
@@ -0,0 +1,47 @@
+#include <stdio.h>
+#include <tgmath.h>
+
+
+int
+main (void)
+{
+  int retval = 0;
+
+#define TEST(expr, res) \
+  if (sizeof (expr) != res)						      \
+    {									      \
+      printf ("sizeof(%s) == %zu, expected %zu\n", #expr,		      \
+	      sizeof (expr), (size_t) (res));				      \
+      retval = 1;								      \
+    }
+
+  TEST (creal (1.0), sizeof (double));
+  TEST (creal (1.0 + 1.0i), sizeof (double));
+  TEST (creal (1.0l), sizeof (long double));
+  TEST (creal (1.0l + 1.0li), sizeof (long double));
+  TEST (creal (1.0f), sizeof (float));
+  TEST (creal (1.0f + 1.0fi), sizeof (float));
+
+  TEST (cimag (1.0), sizeof (double));
+  TEST (cimag (1.0 + 1.0i), sizeof (double));
+  TEST (cimag (1.0l), sizeof (long double));
+  TEST (cimag (1.0l + 1.0li), sizeof (long double));
+  TEST (cimag (1.0f), sizeof (float));
+  TEST (cimag (1.0f + 1.0fi), sizeof (float));
+
+  TEST (fabs (1.0), sizeof (double));
+  TEST (fabs (1.0 + 1.0i), sizeof (double));
+  TEST (fabs (1.0l), sizeof (long double));
+  TEST (fabs (1.0l + 1.0li), sizeof (long double));
+  TEST (fabs (1.0f), sizeof (float));
+  TEST (fabs (1.0f + 1.0fi), sizeof (float));
+
+  TEST (carg (1.0), sizeof (double));
+  TEST (carg (1.0 + 1.0i), sizeof (double));
+  TEST (carg (1.0l), sizeof (long double));
+  TEST (carg (1.0l + 1.0li), sizeof (long double));
+  TEST (carg (1.0f), sizeof (float));
+  TEST (carg (1.0f + 1.0fi), sizeof (float));
+
+  return retval;
+}
Index: trunk/src/libctests/glibc/math/gen-libm-test.pl
===================================================================
--- trunk/src/libctests/glibc/math/gen-libm-test.pl	(revision 2036)
+++ trunk/src/libctests/glibc/math/gen-libm-test.pl	(revision 2036)
@@ -0,0 +1,738 @@
+#!/usr/bin/perl -w
+# Copyright (C) 1999 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+# Contributed by Andreas Jaeger <aj@suse.de>, 1999.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+# This file needs to be tidied up
+# Note that functions and tests share the same namespace.
+
+# Information about tests are stored in: %results
+# $results{$test}{"kind"} is either "fct" or "test" and flags whether this
+# is a maximal error of a function or a single test.
+# $results{$test}{"type"} is the result type, e.g. normal or complex.
+# $results{$test}{"has_ulps"} is set if deltas exist.
+# $results{$test}{"has_fails"} is set if exptected failures exist.
+# In the following description $type and $float are:
+# - $type is either "normal", "real" (for the real part of a complex number)
+#   or "imag" (for the imaginary part # of a complex number).
+# - $float is either of float, ifloat, double, idouble, ldouble, ildouble;
+#   It represents the underlying floating point type (float, double or long
+#   double) and if inline functions (the leading i stands for inline)
+#   are used.
+# $results{$test}{$type}{"fail"}{$float} is defined and has a 1 if
+# the test is expected to fail
+# $results{$test}{$type}{"ulp"}{$float} is defined and has a delta as value
+
+
+use Getopt::Std;
+
+use strict;
+
+use vars qw ($input $output);
+use vars qw (%results);
+use vars qw (@tests @functions);
+use vars qw ($count);
+use vars qw (%beautify @all_floats);
+use vars qw ($output_dir $ulps_file);
+
+# all_floats is sorted and contains all recognised float types
+@all_floats = ('double', 'float', 'idouble',
+	       'ifloat', 'ildouble', 'ldouble');
+
+%beautify =
+  ( "minus_zero" => "-0",
+    "plus_zero" => "+0",
+    "minus_infty" => "-inf",
+    "plus_infty" => "inf",
+    "nan_value" => "NaN",
+    "M_El" => "e",
+    "M_E2l" => "e^2",
+    "M_E3l" => "e^3",
+    "M_LOG10El", "log10(e)",
+    "M_PIl" => "pi",
+    "M_PI_34l" => "3/4 pi",
+    "M_PI_2l" => "pi/2",
+    "M_PI_4l" => "pi/4",
+    "M_PI_6l" => "pi/6",
+    "M_PI_34_LOG10El" => "3/4 pi*log10(e)",
+    "M_PI_LOG10El" => "pi*log10(e)",
+    "M_PI2_LOG10El" => "pi/2*log10(e)",
+    "M_PI4_LOG10El" => "pi/4*log10(e)",
+    "M_LOG_SQRT_PIl" => "log(sqrt(pi))",
+    "M_LOG_2_SQRT_PIl" => "log(2*sqrt(pi))",
+    "M_2_SQRT_PIl" => "2 sqrt (pi)",
+    "M_SQRT_PIl" => "sqrt (pi)",
+    "INVALID_EXCEPTION" => "invalid exception",
+    "DIVIDE_BY_ZERO_EXCEPTION" => "division by zero exception",
+    "INVALID_EXCEPTION_OK" => "invalid exception allowed",
+    "DIVIDE_BY_ZERO_EXCEPTION_OK" => "division by zero exception allowed",
+    "EXCEPTIONS_OK" => "exceptions allowed",
+    "IGNORE_ZERO_INF_SIGN" => "sign of zero/inf not specified",
+"INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN" => "invalid exception and sign of zero/inf not specified"
+  );
+
+
+# get Options
+# Options:
+# u: ulps-file
+# h: help
+# o: output-directory
+# n: generate new ulps file
+use vars qw($opt_u $opt_h $opt_o $opt_n);
+getopts('u:o:nh');
+
+$ulps_file = 'libm-test-ulps';
+$output_dir = '';
+
+if ($opt_h) {
+  print "Usage: gen-libm-test.pl [OPTIONS]\n";
+  print " -h         print this help, then exit\n";
+  print " -o DIR     directory where generated files will be placed\n";
+  print " -n         only generate sorted file NewUlps from libm-test-ulps\n";
+  print " -u FILE    input file with ulps\n";
+  exit 0;
+}
+
+$ulps_file = $opt_u if ($opt_u);
+$output_dir = $opt_o if ($opt_o);
+
+$input = "libm-test.inc";
+$output = "${output_dir}libm-test.c";
+
+$count = 0;
+
+&parse_ulps ($ulps_file);
+&generate_testfile ($input, $output) unless ($opt_n);
+&output_ulps ("${output_dir}libm-test-ulps.h", $ulps_file) unless ($opt_n);
+&print_ulps_file ("${output_dir}NewUlps") if ($opt_n);
+
+# Return a nicer representation
+sub beautify {
+  my ($arg) = @_;
+  my ($tmp);
+
+  if (exists $beautify{$arg}) {
+    return $beautify{$arg};
+  }
+  if ($arg =~ /^-/) {
+    $tmp = $arg;
+    $tmp =~ s/^-//;
+    if (exists $beautify{$tmp}) {
+      return '-' . $beautify{$tmp};
+    }
+  }
+  if ($arg =~ /[0-9]L$/) {
+    $arg =~ s/L$//;
+  }
+  return $arg;
+}
+
+# Return a nicer representation of a complex number
+sub build_complex_beautify {
+  my ($r, $i) = @_;
+  my ($str1, $str2);
+
+  $str1 = &beautify ($r);
+  $str2 = &beautify ($i);
+  if ($str2 =~ /^-/) {
+    $str2 =~ s/^-//;
+    $str1 .= ' - ' . $str2;
+  } else {
+    $str1 .= ' + ' . $str2;
+  }
+  $str1 .= ' i';
+  return $str1;
+}
+
+# Return name of a variable
+sub get_variable {
+  my ($number) = @_;
+
+  return "x" if ($number == 1);
+  return "y" if ($number == 2);
+  return "z" if ($number == 3);
+  # return x1,x2,...
+  $number =-3;
+  return "x$number";
+}
+
+# Add a new test to internal data structures and fill in the
+# ulps, failures and exception information for the C line.
+sub new_test {
+  my ($test, $exception) = @_;
+  my $rest;
+
+  # Add ulp, xfail
+  if (exists $results{$test}{'has_ulps'}) {
+    $rest = ", DELTA$count";
+  } else {
+    $rest = ', 0';
+  }
+  if (exists $results{$test}{'has_fails'}) {
+    $rest .= ", FAIL$count";
+  } else {
+    $rest .= ', 0';
+  }
+  if (defined $exception) {
+    $rest .= ", $exception";
+  } else {
+    $rest .= ', 0';
+  }
+  $rest .= ");\n";
+  # We must increment here to keep @tests and count in sync
+  push @tests, $test;
+  ++$count;
+  return $rest;
+}
+
+# Treat some functions especially.
+# Currently only sincos needs extra treatment.
+sub special_functions {
+  my ($file, $args) = @_;
+  my (@args, $str, $test, $cline);
+
+  @args = split /,\s*/, $args;
+
+  unless ($args[0] =~ /sincos/) {
+    die ("Don't know how to handle $args[0] extra.");
+  }
+  print $file "  FUNC (sincos) ($args[1], &sin_res, &cos_res);\n";
+
+  $str = 'sincos (' . &beautify ($args[1]) . ', &sin_res, &cos_res)';
+  # handle sin
+  $test = $str . ' puts ' . &beautify ($args[2]) . ' in sin_res';
+  if ($#args == 4) {
+    $test .= " plus " . &beautify ($args[4]);
+  }
+
+  $cline = "  check_float (\"$test\", sin_res, $args[2]";
+  $cline .= &new_test ($test, $args[4]);
+  print $file $cline;
+
+  # handle cos
+  $test = $str . ' puts ' . &beautify ($args[3]) . ' in cos_res';
+  $cline = "  check_float (\"$test\", cos_res, $args[3]";
+  # only tests once for exception
+  $cline .= &new_test ($test, undef);
+  print $file $cline;
+}
+
+# Parse the arguments to TEST_x_y
+sub parse_args {
+  my ($file, $descr, $args) = @_;
+  my (@args, $str, $descr_args, $descr_res, @descr);
+  my ($current_arg, $cline, $i);
+  my ($pre, $post, @special);
+  my ($extra_var, $call, $c_call);
+
+  if ($descr eq 'extra') {
+    &special_functions ($file, $args);
+    return;
+  }
+  ($descr_args, $descr_res) = split /_/,$descr, 2;
+
+  @args = split /,\s*/, $args;
+
+  $call = "$args[0] (";
+
+  # Generate first the string that's shown to the user
+  $current_arg = 1;
+  $extra_var = 0;
+  @descr = split //,$descr_args;
+  for ($i = 0; $i <= $#descr; $i++) {
+    if ($i >= 1) {
+      $call .= ', ';
+    }
+    # FLOAT, int, long int, long long int
+    if ($descr[$i] =~ /f|i|l|L/) {
+      $call .= &beautify ($args[$current_arg]);
+      ++$current_arg;
+      next;
+    }
+    # &FLOAT, &int - argument is added here
+    if ($descr[$i] =~ /F|I/) {
+      ++$extra_var;
+      $call .= '&' . &get_variable ($extra_var);
+      next;
+    }
+    # complex
+    if ($descr[$i] eq 'c') {
+      $call .= &build_complex_beautify ($args[$current_arg], $args[$current_arg+1]);
+      $current_arg += 2;
+      next;
+    }
+
+    die ("$descr[$i] is unknown");
+  }
+  $call .= ')';
+  $str = "$call == ";
+
+  # Result
+  @descr = split //,$descr_res;
+  foreach (@descr) {
+    if ($_ =~ /f|i|l|L/) {
+      $str .= &beautify ($args[$current_arg]);
+      ++$current_arg;
+    } elsif ($_ eq 'c') {
+      $str .= &build_complex_beautify ($args[$current_arg], $args[$current_arg+1]);
+      $current_arg += 2;
+    } elsif ($_ eq 'b') {
+      # boolean
+      $str .= ($args[$current_arg] == 0) ? "false" : "true";
+      ++$current_arg;
+    } elsif ($_ eq '1') {
+      ++$current_arg;
+    } else {
+      die ("$_ is unknown");
+    }
+  }
+  # consistency check
+  if ($current_arg == $#args) {
+    die ("wrong number of arguments")
+      unless ($args[$current_arg] =~ /EXCEPTION|IGNORE_ZERO_INF_SIGN/);
+  } elsif ($current_arg < $#args) {
+    die ("wrong number of arguments");
+  } elsif ($current_arg > ($#args+1)) {
+    die ("wrong number of arguments");
+  }
+
+
+  # check for exceptions
+  if ($current_arg <= $#args) {
+    $str .= " plus " . &beautify ($args[$current_arg]);
+  }
+
+  # Put the C program line together
+  # Reset some variables to start again
+  $current_arg = 1;
+  $extra_var = 0;
+  if (substr($descr_res,0,1) eq 'f') {
+    $cline = 'check_float'
+  } elsif (substr($descr_res,0,1) eq 'b') {
+    $cline = 'check_bool';
+  } elsif (substr($descr_res,0,1) eq 'c') {
+    $cline = 'check_complex';
+  } elsif (substr($descr_res,0,1) eq 'i') {
+    $cline = 'check_int';
+  } elsif (substr($descr_res,0,1) eq 'l') {
+    $cline = 'check_long';
+  } elsif (substr($descr_res,0,1) eq 'L') {
+    $cline = 'check_longlong';
+  }
+  # Special handling for some macros:
+  $cline .= " (\"$str\", ";
+  if ($args[0] =~ /fpclassify|isnormal|isfinite|signbit/) {
+    $c_call = "$args[0] (";
+  } else {
+    $c_call = " FUNC($args[0]) (";
+  }
+  @descr = split //,$descr_args;
+  for ($i=0; $i <= $#descr; $i++) {
+    if ($i >= 1) {
+      $c_call .= ', ';
+    }
+    # FLOAT, int, long int, long long int
+    if ($descr[$i] =~ /f|i|l|L/) {
+      $c_call .= $args[$current_arg];
+      $current_arg++;
+      next;
+    }
+    # &FLOAT, &int
+    if ($descr[$i] =~ /F|I/) {
+      ++$extra_var;
+      $c_call .= '&' . &get_variable ($extra_var);
+      next;
+    }
+    # complex
+    if ($descr[$i] eq 'c') {
+      $c_call .= "BUILD_COMPLEX ($args[$current_arg], $args[$current_arg+1])";
+      $current_arg += 2;
+      next;
+    }
+  }
+  $c_call .= ')';
+  $cline .= "$c_call, ";
+
+  @descr = split //,$descr_res;
+  foreach (@descr) {
+    if ($_ =~ /b|f|i|l|L/ ) {
+      $cline .= $args[$current_arg];
+      $current_arg++;
+    } elsif ($_ eq 'c') {
+      $cline .= "BUILD_COMPLEX ($args[$current_arg], $args[$current_arg+1])";
+      $current_arg += 2;
+    } elsif ($_ eq '1') {
+      push @special, $args[$current_arg];
+      ++$current_arg;
+    }
+  }
+  # Add ulp, xfail
+  $cline .= &new_test ($str, ($current_arg <= $#args) ? $args[$current_arg] : undef);
+
+  # special treatment for some functions
+  if ($args[0] eq 'frexp') {
+    if (defined $special[0] && $special[0] ne "IGNORE") {
+      my ($str) = "$call sets x to $special[0]";
+      $post = "  check_int (\"$str\", x, $special[0]";
+      $post .= &new_test ($str, undef);
+    }
+  } elsif ($args[0] eq 'gamma' || $args[0] eq 'lgamma') {
+    $pre = "  signgam = 0;\n";
+    if (defined $special[0] && $special[0] ne "IGNORE") {
+      my ($str) = "$call sets signgam to $special[0]";
+      $post = "  check_int (\"$str\", signgam, $special[0]";
+      $post .= &new_test ($str, undef);
+    }
+  } elsif ($args[0] eq 'modf') {
+    if (defined $special[0] && $special[0] ne "IGNORE") {
+      my ($str) = "$call sets x to $special[0]";
+      $post = "  check_float (\"$str\", x, $special[0]";
+      $post .= &new_test ($str, undef);
+    }
+  } elsif ($args[0] eq 'remquo') {
+    if (defined $special[0] && $special[0] ne "IGNORE") {
+      my ($str) = "$call sets x to $special[0]";
+      $post = "  check_int (\"$str\", x, $special[0]";
+      $post .= &new_test ($str, undef);
+    }
+  }
+
+  print $file $pre if (defined $pre);
+
+  print $file "  $cline";
+
+  print $file $post if (defined $post);
+}
+
+# Generate libm-test.c
+sub generate_testfile {
+  my ($input, $output) = @_;
+  my ($lasttext);
+  my (@args, $i, $str);
+
+  open INPUT, $input or die ("Can't open $input: $!");
+  open OUTPUT, ">$output" or die ("Can't open $output: $!");
+
+  # Replace the special macros
+  while (<INPUT>) {
+
+    # TEST_...
+    if (/^\s*TEST_/) {
+      my ($descr, $args);
+      chop;
+      ($descr, $args) = ($_ =~ /TEST_(\w+)\s*\((.*)\)/);
+      &parse_args (\*OUTPUT, $descr, $args);
+      next;
+    }
+    # START (function)
+    if (/START/) {
+      print OUTPUT "  init_max_error ();\n";
+      next;
+    }
+    # END (function)
+    if (/END/) {
+      my ($fct, $line, $type);
+      if (/complex/) {
+	s/,\s*complex\s*//;
+	$type = 'complex';
+      } else {
+	$type = 'normal';
+      }
+      ($fct) = ($_ =~ /END\s*\((.*)\)/);
+      if ($type eq 'complex') {
+	$line = "  print_complex_max_error (\"$fct\", ";
+      } else {
+	$line = "  print_max_error (\"$fct\", ";
+      }
+      if (exists $results{$fct}{'has_ulps'}) {
+	$line .= "DELTA$fct";
+      } else {
+	$line .= '0';
+      }
+      if (exists $results{$fct}{'has_fails'}) {
+	$line .= ", FAIL$fct";
+      } else {
+	$line .= ', 0';
+      }
+      $line .= ");\n";
+      print OUTPUT $line;
+      push @functions, $fct;
+      next;
+    }
+    print OUTPUT;
+  }
+  close INPUT;
+  close OUTPUT;
+}
+
+
+
+# Parse ulps file
+sub parse_ulps {
+  my ($file) = @_;
+  my ($test, $type, $float, $eps, $kind);
+
+  # $type has the following values:
+  # "normal": No complex variable
+  # "real": Real part of complex result
+  # "imag": Imaginary part of complex result
+  open ULP, $file  or die ("Can't open $file: $!");
+  while (<ULP>) {
+    chop;
+    # ignore comments and empty lines
+    next if /^#/;
+    next if /^\s*$/;
+    if (/^Test/) {
+      if (/Real part of:/) {
+	s/Real part of: //;
+	$type = 'real';
+      } elsif (/Imaginary part of:/) {
+	s/Imaginary part of: //;
+	$type = 'imag';
+      } else {
+	$type = 'normal';
+      }
+      s/^.+\"(.*)\".*$/$1/;
+      $test = $_;
+      $kind = 'test';
+      next;
+    }
+    if (/^Function: /) {
+      if (/Real part of/) {
+	s/Real part of //;
+	$type = 'real';
+      } elsif (/Imaginary part of/) {
+	s/Imaginary part of //;
+	$type = 'imag';
+      } else {
+	$type = 'normal';
+      }
+      ($test) = ($_ =~ /^Function:\s*\"([a-zA-Z0-9_]+)\"/);
+      $kind = 'fct';
+      next;
+    }
+    if (/^i?(float|double|ldouble):/) {
+      ($float, $eps) = split /\s*:\s*/,$_,2;
+
+      if ($eps eq 'fail') {
+	$results{$test}{$type}{'fail'}{$float} = 1;
+	$results{$test}{'has_fails'} = 1;
+      } elsif ($eps eq "0") {
+	# ignore
+	next;
+      } else {
+	$results{$test}{$type}{'ulp'}{$float} = $eps;
+	$results{$test}{'has_ulps'} = 1;
+      }
+      if ($type =~ /^real|imag$/) {
+	$results{$test}{'type'} = 'complex';
+      } elsif ($type eq 'normal') {
+	$results{$test}{'type'} = 'normal';
+      }
+      $results{$test}{'kind'} = $kind;
+      next;
+    }
+    print "Skipping unknown entry: `$_'\n";
+  }
+  close ULP;
+}
+
+
+# Clean up a floating point number
+sub clean_up_number {
+  my ($number) = @_;
+
+  # Remove trailing zeros
+  $number =~ s/0+$//;
+  $number =~ s/\.$//;
+  return $number;
+}
+
+# Output a file which can be read in as ulps file.
+sub print_ulps_file {
+  my ($file) = @_;
+  my ($test, $type, $float, $eps, $fct, $last_fct);
+
+  $last_fct = '';
+  open NEWULP, ">$file" or die ("Can't open $file: $!");
+  print NEWULP "# Begin of automatic generation\n";
+  # first the function calls
+  foreach $test (sort keys %results) {
+    next if ($results{$test}{'kind'} ne 'test');
+    foreach $type ('real', 'imag', 'normal') {
+      if (exists $results{$test}{$type}) {
+	if (defined $results{$test}) {
+	  ($fct) = ($test =~ /^(\w+)\s/);
+	  if ($fct ne $last_fct) {
+	    $last_fct = $fct;
+	    print NEWULP "\n# $fct\n";
+	  }
+	}
+	if ($type eq 'normal') {
+	  print NEWULP "Test \"$test\":\n";
+	} elsif ($type eq 'real') {
+	  print NEWULP "Test \"Real part of: $test\":\n";
+	} elsif ($type eq 'imag') {
+	  print NEWULP "Test \"Imaginary part of: $test\":\n";
+	}
+	foreach $float (@all_floats) {
+	  if (exists $results{$test}{$type}{'ulp'}{$float}) {
+	    print NEWULP "$float: ",
+	    &clean_up_number ($results{$test}{$type}{'ulp'}{$float}),
+	    "\n";
+	  }
+	  if (exists $results{$test}{$type}{'fail'}{$float}) {
+	    print NEWULP "$float: fail\n";
+	  }
+	}
+      }
+    }
+  }
+  print NEWULP "\n# Maximal error of functions:\n";
+
+  foreach $fct (sort keys %results) {
+    next if ($results{$fct}{'kind'} ne 'fct');
+    foreach $type ('real', 'imag', 'normal') {
+      if (exists $results{$fct}{$type}) {
+	if ($type eq 'normal') {
+	  print NEWULP "Function: \"$fct\":\n";
+	} elsif ($type eq 'real') {
+	  print NEWULP "Function: Real part of \"$fct\":\n";
+	} elsif ($type eq 'imag') {
+	  print NEWULP "Function: Imaginary part of \"$fct\":\n";
+	}
+	foreach $float (@all_floats) {
+	  if (exists $results{$fct}{$type}{'ulp'}{$float}) {
+	    print NEWULP "$float: ",
+	    &clean_up_number ($results{$fct}{$type}{'ulp'}{$float}),
+	    "\n";
+	  }
+	  if (exists $results{$fct}{$type}{'fail'}{$float}) {
+	    print NEWULP "$float: fail\n";
+	  }
+	}
+	print NEWULP "\n";
+      }
+    }
+  }
+  print NEWULP "# end of automatic generation\n";
+  close NEWULP;
+}
+
+sub get_ulps {
+  my ($test, $type, $float) = @_;
+
+  if ($type eq 'complex') {
+    my ($res);
+    # Return 0 instead of BUILD_COMPLEX (0,0)
+    if (!exists $results{$test}{'real'}{'ulp'}{$float} &&
+	!exists $results{$test}{'imag'}{'ulp'}{$float}) {
+      return "0";
+    }
+    $res = 'BUILD_COMPLEX (';
+    $res .= (exists $results{$test}{'real'}{'ulp'}{$float}
+	     ? $results{$test}{'real'}{'ulp'}{$float} : "0");
+    $res .= ', ';
+    $res .= (exists $results{$test}{'imag'}{'ulp'}{$float}
+	     ? $results{$test}{'imag'}{'ulp'}{$float} : "0");
+    $res .= ')';
+    return $res;
+  }
+  return (exists $results{$test}{'normal'}{'ulp'}{$float}
+	  ? $results{$test}{'normal'}{'ulp'}{$float} : "0");
+}
+
+sub get_failure {
+  my ($test, $type, $float) = @_;
+  if ($type eq 'complex') {
+    # return x,y
+    my ($res);
+    # Return 0 instead of BUILD_COMPLEX_INT (0,0)
+    if (!exists $results{$test}{'real'}{'ulp'}{$float} &&
+	!exists $results{$test}{'imag'}{'ulp'}{$float}) {
+      return "0";
+    }
+    $res = 'BUILD_COMPLEX_INT (';
+    $res .= (exists $results{$test}{'real'}{'fail'}{$float}
+	     ? $results{$test}{'real'}{'fail'}{$float} : "0");
+    $res .= ', ';
+    $res .= (exists $results{$test}{'imag'}{'fail'}{$float}
+	     ? $results{$test}{'imag'}{'fail'}{$float} : "0");
+    $res .= ')';
+    return $res;
+  }
+  return (exists $results{$test}{'normal'}{'fail'}{$float}
+	  ? $results{$test}{'normal'}{'fail'}{$float} : "0");
+
+}
+
+# Output the defines for a single test
+sub output_test {
+  my ($file, $test, $name) = @_;
+  my ($ldouble, $double, $float, $ildouble, $idouble, $ifloat);
+  my ($type);
+
+  # Do we have ulps/failures?
+  if (!exists $results{$test}{'type'}) {
+    return;
+  }
+  $type = $results{$test}{'type'};
+  if (exists $results{$test}{'has_ulps'}) {
+    # XXX use all_floats (change order!)
+    $ldouble = &get_ulps ($test, $type, "ldouble");
+    $double = &get_ulps ($test, $type, "double");
+    $float = &get_ulps ($test, $type, "float");
+    $ildouble = &get_ulps ($test, $type, "ildouble");
+    $idouble = &get_ulps ($test, $type, "idouble");
+    $ifloat = &get_ulps ($test, $type, "ifloat");
+    print $file "#define DELTA$name CHOOSE($ldouble, $double, $float, $ildouble, $idouble, $ifloat)\t/* $test  */\n";
+  }
+
+  if (exists $results{$test}{'has_fails'}) {
+    $ldouble = &get_failure ($test, "ldouble");
+    $double = &get_failure ($test, "double");
+    $float = &get_failure ($test, "float");
+    $ildouble = &get_failure ($test, "ildouble");
+    $idouble = &get_failure ($test, "idouble");
+    $ifloat = &get_failure ($test, "ifloat");
+    print $file "#define FAIL$name CHOOSE($ldouble, $double, $float $ildouble, $idouble, $ifloat)\t/* $test  */\n";
+  }
+}
+
+# Print include file
+sub output_ulps {
+  my ($file, $ulps_filename) = @_;
+  my ($i, $fct);
+
+  open ULP, ">$file" or die ("Can't open $file: $!");
+
+  print ULP "/* This file is automatically generated\n";
+  print ULP "   from $ulps_filename with gen-libm-test.pl.\n";
+  print ULP "   Don't change it - change instead the master files.  */\n\n";
+
+  print ULP "\n/* Maximal error of functions.  */\n";
+  foreach $fct (@functions) {
+    output_test (\*ULP, $fct, $fct);
+  }
+
+  print ULP "\n/* Error of single function calls.  */\n";
+  for ($i = 0; $i < $count; $i++) {
+    output_test (\*ULP, $tests[$i], $i);
+  }
+  close ULP;
+}
Index: trunk/src/libctests/glibc/math/libm-test.inc
===================================================================
--- trunk/src/libctests/glibc/math/libm-test.inc	(revision 2036)
+++ trunk/src/libctests/glibc/math/libm-test.inc	(revision 2036)
@@ -0,0 +1,4754 @@
+/* Copyright (C) 1997-2002, 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@suse.de>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* Part of testsuite for libm.
+
+   This file is processed by a perl script.  The resulting file has to
+   be included by a master file that defines:
+
+   Makros:
+   FUNC(function): converts general function name (like cos) to
+   name with correct suffix (e.g. cosl or cosf)
+   MATHCONST(x):   like FUNC but for constants (e.g convert 0.0 to 0.0L)
+   FLOAT:	   floating point type to test
+   - TEST_MSG:	   informal message to be displayed
+   CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat):
+   chooses one of the parameters as delta for testing
+   equality
+   PRINTF_EXPR	   Floating point conversion specification to print a variable
+   of type FLOAT with printf.  PRINTF_EXPR just contains
+   the specifier, not the percent and width arguments,
+   e.g. "f".
+   PRINTF_XEXPR	   Like PRINTF_EXPR, but print in hexadecimal format.
+   PRINTF_NEXPR Like PRINTF_EXPR, but print nice.  */
+
+/* This testsuite has currently tests for:
+   acos, acosh, asin, asinh, atan, atan2, atanh,
+   cbrt, ceil, copysign, cos, cosh, erf, erfc, exp, exp10, exp2, expm1,
+   fabs, fdim, floor, fma, fmax, fmin, fmod, fpclassify,
+   frexp, gamma, hypot,
+   ilogb, isfinite, isinf, isnan, isnormal,
+   isless, islessequal, isgreater, isgreaterequal, islessgreater, isunordered,
+   j0, j1, jn,
+   ldexp, lgamma, log, log10, log1p, log2, logb,
+   modf, nearbyint, nextafter,
+   pow, remainder, remquo, rint, lrint, llrint,
+   round, lround, llround,
+   scalb, scalbn, scalbln, signbit, sin, sincos, sinh, sqrt, tan, tanh, tgamma, trunc,
+   y0, y1, yn, significand
+
+   and for the following complex math functions:
+   cabs, cacos, cacosh, carg, casin, casinh, catan, catanh,
+   ccos, ccosh, cexp, clog, cpow, cproj, csin, csinh, csqrt, ctan, ctanh.
+
+   At the moment the following functions aren't tested:
+   drem, nan
+
+   Parameter handling is primitive in the moment:
+   --verbose=[0..3] for different levels of output:
+   0: only error count
+   1: basic report on failed tests (default)
+   2: full report on all tests
+   -v for full output (equals --verbose=3)
+   -u for generation of an ULPs file
+ */
+
+/* "Philosophy":
+
+   This suite tests some aspects of the correct implementation of
+   mathematical functions in libm.  Some simple, specific parameters
+   are tested for correctness but there's no exhaustive
+   testing.  Handling of specific inputs (e.g. infinity, not-a-number)
+   is also tested.  Correct handling of exceptions is checked
+   against.  These implemented tests should check all cases that are
+   specified in ISO C99.
+
+   Exception testing: At the moment only divide-by-zero and invalid
+   exceptions are tested.  Overflow/underflow and inexact exceptions
+   aren't checked at the moment.
+
+   NaN values: There exist signalling and quiet NaNs.  This implementation
+   only uses quiet NaN as parameter but does not differenciate
+   between the two kinds of NaNs as result.
+
+   Inline functions: Inlining functions should give an improvement in
+   speed - but not in precission.  The inlined functions return
+   reasonable values for a reasonable range of input values.  The
+   result is not necessarily correct for all values and exceptions are
+   not correctly raised in all cases.  Problematic input and return
+   values are infinity, not-a-number and minus zero.  This suite
+   therefore does not check these specific inputs and the exception
+   handling for inlined mathematical functions - just the "reasonable"
+   values are checked.
+
+   Beware: The tests might fail for any of the following reasons:
+   - Tests are wrong
+   - Functions are wrong
+   - Floating Point Unit not working properly
+   - Compiler has errors
+
+   With e.g. gcc 2.7.2.2 the test for cexp fails because of a compiler error.
+
+
+   To Do: All parameter should be numbers that can be represented as
+   exact floating point values.  Currently some values cannot be
+   represented exactly and therefore the result is not the expected
+   result.  For this we will use 36 digits so that numbers can be
+   represented exactly.  */
+
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE
+#endif
+
+#include "libm-test-ulps.h"
+#include <complex.h>
+#include <math.h>
+#include <float.h>
+#include <fenv.h>
+#include <limits.h>
+
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <argp.h>
+
+/* Possible exceptions */
+#define NO_EXCEPTION			0x0
+#define INVALID_EXCEPTION		0x1
+#define DIVIDE_BY_ZERO_EXCEPTION	0x2
+/* The next flags signals that those exceptions are allowed but not required.   */
+#define INVALID_EXCEPTION_OK		0x4
+#define DIVIDE_BY_ZERO_EXCEPTION_OK	0x8
+#define EXCEPTIONS_OK INVALID_EXCEPTION_OK+DIVIDE_BY_ZERO_EXCEPTION_OK
+/* Some special test flags, passed togther with exceptions.  */
+#define IGNORE_ZERO_INF_SIGN		0x10
+
+/* Various constants (we must supply them precalculated for accuracy).  */
+#define M_PI_6l			.52359877559829887307710723054658383L
+#define M_E2l			7.389056098930650227230427460575008L
+#define M_E3l			20.085536923187667740928529654581719L
+#define M_2_SQRT_PIl		3.5449077018110320545963349666822903L	/* 2 sqrt (M_PIl)  */
+#define M_SQRT_PIl		1.7724538509055160272981674833411451L	/* sqrt (M_PIl)  */
+#define M_LOG_SQRT_PIl		0.57236494292470008707171367567652933L	/* log(sqrt(M_PIl))  */
+#define M_LOG_2_SQRT_PIl	1.265512123484645396488945797134706L	/* log(2*sqrt(M_PIl))  */
+#define M_PI_34l		(M_PIl - M_PI_4l)		/* 3*pi/4 */
+#define M_PI_34_LOG10El		(M_PIl - M_PI_4l) * M_LOG10El
+#define M_PI2_LOG10El		M_PI_2l * M_LOG10El
+#define M_PI4_LOG10El		M_PI_4l * M_LOG10El
+#define M_PI_LOG10El		M_PIl * M_LOG10El
+
+static FILE *ulps_file;	/* File to document difference.  */
+static int output_ulps;	/* Should ulps printed?  */
+
+static int noErrors;	/* number of errors */
+static int noTests;	/* number of tests (without testing exceptions) */
+static int noExcTests;	/* number of tests for exception flags */
+static int noXFails;	/* number of expected failures.  */
+static int noXPasses;	/* number of unexpected passes.  */
+
+static int verbose;
+static int output_max_error;	/* Should the maximal errors printed?  */
+static int output_points;	/* Should the single function results printed?  */
+static int ignore_max_ulp;	/* Should we ignore max_ulp?  */
+
+static FLOAT minus_zero, plus_zero;
+static FLOAT plus_infty, minus_infty, nan_value, max_value, min_value;
+
+static FLOAT max_error, real_max_error, imag_max_error;
+
+
+#define BUILD_COMPLEX(real, imag) \
+  ({ __complex__ FLOAT __retval;					      \
+     __real__ __retval = (real);					      \
+     __imag__ __retval = (imag);					      \
+     __retval; })
+
+#define BUILD_COMPLEX_INT(real, imag) \
+  ({ __complex__ int __retval;						      \
+     __real__ __retval = (real);					      \
+     __imag__ __retval = (imag);					      \
+     __retval; })
+
+
+#define MANT_DIG CHOOSE ((LDBL_MANT_DIG-1), (DBL_MANT_DIG-1), (FLT_MANT_DIG-1),  \
+                         (LDBL_MANT_DIG-1), (DBL_MANT_DIG-1), (FLT_MANT_DIG-1))
+
+static void
+init_max_error (void)
+{
+  max_error = 0;
+  real_max_error = 0;
+  imag_max_error = 0;
+  feclearexcept (FE_ALL_EXCEPT);
+}
+
+static void
+set_max_error (FLOAT current, FLOAT *curr_max_error)
+{
+  if (current > *curr_max_error)
+    *curr_max_error = current;
+}
+
+
+/* Should the message print to screen?  This depends on the verbose flag,
+   and the test status.  */
+static int
+print_screen (int ok, int xfail)
+{
+  if (output_points
+      && (verbose > 1
+	  || (verbose == 1 && ok == xfail)))
+    return 1;
+  return 0;
+}
+
+
+/* Should the message print to screen?  This depends on the verbose flag,
+   and the test status.  */
+static int
+print_screen_max_error (int ok, int xfail)
+{
+  if (output_max_error
+      && (verbose > 1
+	  || ((verbose == 1) && (ok == xfail))))
+    return 1;
+  return 0;
+}
+
+/* Update statistic counters.  */
+static void
+update_stats (int ok, int xfail)
+{
+  ++noTests;
+  if (ok && xfail)
+    ++noXPasses;
+  else if (!ok && xfail)
+    ++noXFails;
+  else if (!ok && !xfail)
+    ++noErrors;
+}
+
+static void
+print_ulps (const char *test_name, FLOAT ulp)
+{
+  if (output_ulps)
+    {
+      fprintf (ulps_file, "Test \"%s\":\n", test_name);
+      fprintf (ulps_file, "%s: %.0" PRINTF_NEXPR "\n",
+	       CHOOSE("ldouble", "double", "float",
+		      "ildouble", "idouble", "ifloat"),
+	       FUNC(ceil) (ulp));
+    }
+}
+
+static void
+print_function_ulps (const char *function_name, FLOAT ulp)
+{
+  if (output_ulps)
+    {
+      fprintf (ulps_file, "Function: \"%s\":\n", function_name);
+      fprintf (ulps_file, "%s: %.0" PRINTF_NEXPR "\n",
+	       CHOOSE("ldouble", "double", "float",
+		      "ildouble", "idouble", "ifloat"),
+	       FUNC(ceil) (ulp));
+    }
+}
+
+
+static void
+print_complex_function_ulps (const char *function_name, FLOAT real_ulp,
+			     FLOAT imag_ulp)
+{
+  if (output_ulps)
+    {
+      if (real_ulp != 0.0)
+	{
+	  fprintf (ulps_file, "Function: Real part of \"%s\":\n", function_name);
+	  fprintf (ulps_file, "%s: %.0" PRINTF_NEXPR "\n",
+		   CHOOSE("ldouble", "double", "float",
+			  "ildouble", "idouble", "ifloat"),
+		   FUNC(ceil) (real_ulp));
+	}
+      if (imag_ulp != 0.0)
+	{
+	  fprintf (ulps_file, "Function: Imaginary part of \"%s\":\n", function_name);
+	  fprintf (ulps_file, "%s: %.0" PRINTF_NEXPR "\n",
+		   CHOOSE("ldouble", "double", "float",
+			  "ildouble", "idouble", "ifloat"),
+		   FUNC(ceil) (imag_ulp));
+	}
+
+
+    }
+}
+
+
+
+/* Test if Floating-Point stack hasn't changed */
+static void
+fpstack_test (const char *test_name)
+{
+#ifdef i386
+  static int old_stack;
+  int sw;
+
+  asm ("fnstsw" : "=a" (sw));
+  sw >>= 11;
+  sw &= 7;
+
+  if (sw != old_stack)
+    {
+      printf ("FP-Stack wrong after test %s (%d, should be %d)\n",
+	      test_name, sw, old_stack);
+      ++noErrors;
+      old_stack = sw;
+    }
+#endif
+}
+
+
+static void
+print_max_error (const char *func_name, FLOAT allowed, int xfail)
+{
+  int ok = 0;
+
+  if (max_error == 0.0 || (max_error <= allowed && !ignore_max_ulp))
+    {
+      ok = 1;
+    }
+
+  if (!ok)
+    print_function_ulps (func_name, max_error);
+
+
+  if (print_screen_max_error (ok, xfail))
+    {
+      printf ("Maximal error of `%s'\n", func_name);
+      printf (" is      : %.0" PRINTF_NEXPR " ulp\n", FUNC(ceil) (max_error));
+      printf (" accepted: %.0" PRINTF_NEXPR " ulp\n", FUNC(ceil) (allowed));
+    }
+
+  update_stats (ok, xfail);
+}
+
+
+static void
+print_complex_max_error (const char *func_name, __complex__ FLOAT allowed,
+			 __complex__ int xfail)
+{
+  int ok = 0;
+
+  if ((real_max_error == 0 && imag_max_error == 0)
+      || (real_max_error <= __real__ allowed
+	  && imag_max_error <= __imag__ allowed
+	  && !ignore_max_ulp))
+    {
+      ok = 1;
+    }
+
+  if (!ok)
+    print_complex_function_ulps (func_name, real_max_error, imag_max_error);
+
+
+  if (print_screen_max_error (ok, xfail))
+    {
+      printf ("Maximal error of real part of: %s\n", func_name);
+      printf (" is      : %.0" PRINTF_NEXPR " ulp\n",
+	      FUNC(ceil) (real_max_error));
+      printf (" accepted: %.0" PRINTF_NEXPR " ulp\n",
+	      FUNC(ceil) (__real__ allowed));
+      printf ("Maximal error of imaginary part of: %s\n", func_name);
+      printf (" is      : %.0" PRINTF_NEXPR " ulp\n",
+	      FUNC(ceil) (imag_max_error));
+      printf (" accepted: %.0" PRINTF_NEXPR " ulp\n",
+	      FUNC(ceil) (__imag__ allowed));
+    }
+
+  update_stats (ok, xfail);
+}
+
+
+/* Test whether a given exception was raised.  */
+static void
+test_single_exception (const char *test_name,
+		       int exception,
+		       int exc_flag,
+		       int fe_flag,
+		       const char *flag_name)
+{
+#ifndef TEST_INLINE
+  int ok = 1;
+  if (exception & exc_flag)
+    {
+      if (fetestexcept (fe_flag))
+	{
+	  if (print_screen (1, 0))
+	    printf ("Pass: %s: Exception \"%s\" set\n", test_name, flag_name);
+	}
+      else
+	{
+	  ok = 0;
+	  if (print_screen (0, 0))
+	    printf ("Failure: %s: Exception \"%s\" not set\n",
+		    test_name, flag_name);
+	}
+    }
+  else
+    {
+      if (fetestexcept (fe_flag))
+	{
+	  ok = 0;
+	  if (print_screen (0, 0))
+	    printf ("Failure: %s: Exception \"%s\" set\n",
+		    test_name, flag_name);
+	}
+      else
+	{
+	  if (print_screen (1, 0))
+	    printf ("%s: Exception \"%s\" not set\n", test_name,
+		    flag_name);
+	}
+    }
+  if (!ok)
+    ++noErrors;
+
+#endif
+}
+
+
+/* Test whether exceptions given by EXCEPTION are raised.  Ignore thereby
+   allowed but not required exceptions.
+*/
+static void
+test_exceptions (const char *test_name, int exception)
+{
+  ++noExcTests;
+#ifdef FE_DIVBYZERO
+  if ((exception & DIVIDE_BY_ZERO_EXCEPTION_OK) == 0)
+    test_single_exception (test_name, exception,
+			   DIVIDE_BY_ZERO_EXCEPTION, FE_DIVBYZERO,
+			   "Divide by zero");
+#endif
+#ifdef FE_INVALID
+  if ((exception & INVALID_EXCEPTION_OK) == 0)
+    test_single_exception (test_name, exception, INVALID_EXCEPTION, FE_INVALID,
+			 "Invalid operation");
+#endif
+  feclearexcept (FE_ALL_EXCEPT);
+}
+
+
+static void
+check_float_internal (const char *test_name, FLOAT computed, FLOAT expected,
+		      FLOAT max_ulp, int xfail, int exceptions,
+		      FLOAT *curr_max_error)
+{
+  int ok = 0;
+  int print_diff = 0;
+  FLOAT diff = 0;
+  FLOAT ulp = 0;
+
+  test_exceptions (test_name, exceptions);
+  if (isnan (computed) && isnan (expected))
+    ok = 1;
+  else if (isinf (computed) && isinf (expected))
+    {
+      /* Test for sign of infinities.  */
+      if ((exceptions & IGNORE_ZERO_INF_SIGN) == 0
+	  && signbit (computed) != signbit (expected))
+	{
+	  ok = 0;
+	  printf ("infinity has wrong sign.\n");
+	}
+      else
+	ok = 1;
+    }
+  /* Don't calc ulp for NaNs or infinities.  */
+  else if (isinf (computed) || isnan (computed) || isinf (expected) || isnan (expected))
+    ok = 0;
+  else
+    {
+      diff = FUNC(fabs) (computed - expected);
+      /* ilogb (0) isn't allowed.  */
+      if (expected == 0.0)
+	ulp = diff / FUNC(ldexp) (1.0, - MANT_DIG);
+      else
+	ulp = diff / FUNC(ldexp) (1.0, FUNC(ilogb) (expected) - MANT_DIG);
+      set_max_error (ulp, curr_max_error);
+      print_diff = 1;
+      if ((exceptions & IGNORE_ZERO_INF_SIGN) == 0
+	  && computed == 0.0 && expected == 0.0
+	  && signbit(computed) != signbit (expected))
+	ok = 0;
+      else if (ulp == 0.0 || (ulp <= max_ulp && !ignore_max_ulp))
+	ok = 1;
+      else
+	{
+	  ok = 0;
+	  print_ulps (test_name, ulp);
+	}
+
+    }
+  if (print_screen (ok, xfail))
+    {
+      if (!ok)
+	printf ("Failure: ");
+      printf ("Test: %s\n", test_name);
+      printf ("Result:\n");
+      printf (" is:         % .20" PRINTF_EXPR "  % .20" PRINTF_XEXPR "\n",
+	      computed, computed);
+      printf (" should be:  % .20" PRINTF_EXPR "  % .20" PRINTF_XEXPR "\n",
+	      expected, expected);
+      if (print_diff)
+	{
+	  printf (" difference: % .20" PRINTF_EXPR "  % .20" PRINTF_XEXPR
+		  "\n", diff, diff);
+	  printf (" ulp       : % .4" PRINTF_NEXPR "\n", ulp);
+	  printf (" max.ulp   : % .4" PRINTF_NEXPR "\n", max_ulp);
+	}
+    }
+  update_stats (ok, xfail);
+
+  fpstack_test (test_name);
+}
+
+
+static void
+check_float (const char *test_name, FLOAT computed, FLOAT expected,
+	     FLOAT max_ulp, int xfail, int exceptions)
+{
+  check_float_internal (test_name, computed, expected, max_ulp, xfail,
+			exceptions, &max_error);
+}
+
+
+static void
+check_complex (const char *test_name, __complex__ FLOAT computed,
+	       __complex__ FLOAT expected,
+	       __complex__ FLOAT max_ulp, __complex__ int xfail,
+	       int exception)
+{
+  FLOAT part_comp, part_exp, part_max_ulp;
+  int part_xfail;
+  char str[200];
+
+  sprintf (str, "Real part of: %s", test_name);
+  part_comp = __real__ computed;
+  part_exp = __real__ expected;
+  part_max_ulp = __real__ max_ulp;
+  part_xfail = __real__ xfail;
+
+  check_float_internal (str, part_comp, part_exp, part_max_ulp, part_xfail,
+			exception, &real_max_error);
+
+  sprintf (str, "Imaginary part of: %s", test_name);
+  part_comp = __imag__ computed;
+  part_exp = __imag__ expected;
+  part_max_ulp = __imag__ max_ulp;
+  part_xfail = __imag__ xfail;
+
+  /* Don't check again for exceptions, just pass through the
+     zero/inf sign test.  */
+  check_float_internal (str, part_comp, part_exp, part_max_ulp, part_xfail,
+			exception & IGNORE_ZERO_INF_SIGN,
+			&imag_max_error);
+}
+
+
+/* Check that computed and expected values are equal (int values).  */
+static void
+check_int (const char *test_name, int computed, int expected, int max_ulp,
+	   int xfail, int exceptions)
+{
+  int diff = computed - expected;
+  int ok = 0;
+
+  test_exceptions (test_name, exceptions);
+  noTests++;
+  if (abs (diff) <= max_ulp)
+    ok = 1;
+
+  if (!ok)
+    print_ulps (test_name, diff);
+
+  if (print_screen (ok, xfail))
+    {
+      if (!ok)
+	printf ("Failure: ");
+      printf ("Test: %s\n", test_name);
+      printf ("Result:\n");
+      printf (" is:         %d\n", computed);
+      printf (" should be:  %d\n", expected);
+    }
+
+  update_stats (ok, xfail);
+  fpstack_test (test_name);
+}
+
+
+/* Check that computed and expected values are equal (long int values).  */
+static void
+check_long (const char *test_name, long int computed, long int expected,
+	    long int max_ulp, int xfail, int exceptions)
+{
+  long int diff = computed - expected;
+  int ok = 0;
+
+  test_exceptions (test_name, exceptions);
+  noTests++;
+  if (labs (diff) <= max_ulp)
+    ok = 1;
+
+  if (!ok)
+    print_ulps (test_name, diff);
+
+  if (print_screen (ok, xfail))
+    {
+      if (!ok)
+	printf ("Failure: ");
+      printf ("Test: %s\n", test_name);
+      printf ("Result:\n");
+      printf (" is:         %ld\n", computed);
+      printf (" should be:  %ld\n", expected);
+    }
+
+  update_stats (ok, xfail);
+  fpstack_test (test_name);
+}
+
+
+/* Check that computed value is true/false.  */
+static void
+check_bool (const char *test_name, int computed, int expected,
+	    long int max_ulp, int xfail, int exceptions)
+{
+  int ok = 0;
+
+  test_exceptions (test_name, exceptions);
+  noTests++;
+  if ((computed == 0) == (expected == 0))
+    ok = 1;
+
+  if (print_screen (ok, xfail))
+    {
+      if (!ok)
+	printf ("Failure: ");
+      printf ("Test: %s\n", test_name);
+      printf ("Result:\n");
+      printf (" is:         %d\n", computed);
+      printf (" should be:  %d\n", expected);
+    }
+
+  update_stats (ok, xfail);
+  fpstack_test (test_name);
+}
+
+
+/* check that computed and expected values are equal (long int values) */
+static void
+check_longlong (const char *test_name, long long int computed,
+		long long int expected,
+		long long int max_ulp, int xfail,
+		int exceptions)
+{
+  long long int diff = computed - expected;
+  int ok = 0;
+
+  test_exceptions (test_name, exceptions);
+  noTests++;
+  if (llabs (diff) <= max_ulp)
+    ok = 1;
+
+  if (!ok)
+    print_ulps (test_name, diff);
+
+  if (print_screen (ok, xfail))
+    {
+      if (!ok)
+	printf ("Failure:");
+      printf ("Test: %s\n", test_name);
+      printf ("Result:\n");
+      printf (" is:         %lld\n", computed);
+      printf (" should be:  %lld\n", expected);
+    }
+
+  update_stats (ok, xfail);
+  fpstack_test (test_name);
+}
+
+
+
+/* This is to prevent messages from the SVID libm emulation.  */
+int
+matherr (struct exception *x __attribute__ ((unused)))
+{
+  return 1;
+}
+
+
+/****************************************************************************
+  Tests for single functions of libm.
+  Please keep them alphabetically sorted!
+****************************************************************************/
+
+static void
+acos_test (void)
+{
+  errno = 0;
+  FUNC(acos) (0);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (acos);
+
+  TEST_f_f (acos, plus_infty, nan_value, INVALID_EXCEPTION);
+  TEST_f_f (acos, minus_infty, nan_value, INVALID_EXCEPTION);
+  TEST_f_f (acos, nan_value, nan_value);
+
+  /* |x| > 1: */
+  TEST_f_f (acos, 1.125L, nan_value, INVALID_EXCEPTION);
+  TEST_f_f (acos, -1.125L, nan_value, INVALID_EXCEPTION);
+
+  TEST_f_f (acos, 0, M_PI_2l);
+  TEST_f_f (acos, minus_zero, M_PI_2l);
+  TEST_f_f (acos, 1, 0);
+  TEST_f_f (acos, -1, M_PIl);
+  TEST_f_f (acos, 0.5, M_PI_6l*2.0);
+  TEST_f_f (acos, -0.5, M_PI_6l*4.0);
+  TEST_f_f (acos, 0.75L, 0.722734247813415611178377352641333362L);
+  TEST_f_f (acos, 2e-17L, 1.57079632679489659923132169163975144L);
+  TEST_f_f (acos, 0.0625L, 1.50825556499840522843072005474337068L);
+  END (acos);
+}
+
+static void
+acosh_test (void)
+{
+  errno = 0;
+  FUNC(acosh) (7);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (acosh);
+
+  TEST_f_f (acosh, plus_infty, plus_infty);
+  TEST_f_f (acosh, minus_infty, nan_value, INVALID_EXCEPTION);
+
+  /* x < 1:  */
+  TEST_f_f (acosh, -1.125L, nan_value, INVALID_EXCEPTION);
+
+  TEST_f_f (acosh, 1, 0);
+  TEST_f_f (acosh, 7, 2.63391579384963341725009269461593689L);
+
+  END (acosh);
+}
+
+static void
+asin_test (void)
+{
+  errno = 0;
+  FUNC(asin) (0);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (asin);
+
+  TEST_f_f (asin, plus_infty, nan_value, INVALID_EXCEPTION);
+  TEST_f_f (asin, minus_infty, nan_value, INVALID_EXCEPTION);
+  TEST_f_f (asin, nan_value, nan_value);
+
+  /* asin x == NaN plus invalid exception for |x| > 1.  */
+  TEST_f_f (asin, 1.125L, nan_value, INVALID_EXCEPTION);
+  TEST_f_f (asin, -1.125L, nan_value, INVALID_EXCEPTION);
+
+  TEST_f_f (asin, 0, 0);
+  TEST_f_f (asin, minus_zero, minus_zero);
+  TEST_f_f (asin, 0.5, M_PI_6l);
+  TEST_f_f (asin, -0.5, -M_PI_6l);
+  TEST_f_f (asin, 1.0, M_PI_2l);
+  TEST_f_f (asin, -1.0, -M_PI_2l);
+  TEST_f_f (asin, 0.75L, 0.848062078981481008052944338998418080L);
+
+  END (asin);
+}
+
+static void
+asinh_test (void)
+{
+  errno = 0;
+  FUNC(asinh) (0.7L);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (asinh);
+
+  TEST_f_f (asinh, 0, 0);
+  TEST_f_f (asinh, minus_zero, minus_zero);
+#ifndef TEST_INLINE
+  TEST_f_f (asinh, plus_infty, plus_infty);
+  TEST_f_f (asinh, minus_infty, minus_infty);
+#endif
+  TEST_f_f (asinh, nan_value, nan_value);
+  TEST_f_f (asinh, 0.75L, 0.693147180559945309417232121458176568L);
+
+  END (asinh);
+}
+
+static void
+atan_test (void)
+{
+  errno = 0;
+  FUNC(atan) (0);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (atan);
+
+  TEST_f_f (atan, 0, 0);
+  TEST_f_f (atan, minus_zero, minus_zero);
+
+  TEST_f_f (atan, plus_infty, M_PI_2l);
+  TEST_f_f (atan, minus_infty, -M_PI_2l);
+  TEST_f_f (atan, nan_value, nan_value);
+
+  TEST_f_f (atan, 1, M_PI_4l);
+  TEST_f_f (atan, -1, -M_PI_4l);
+
+  TEST_f_f (atan, 0.75L, 0.643501108793284386802809228717322638L);
+
+  END (atan);
+}
+
+
+
+static void
+atanh_test (void)
+{
+  errno = 0;
+  FUNC(atanh) (0.7L);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (atanh);
+
+
+  TEST_f_f (atanh, 0, 0);
+  TEST_f_f (atanh, minus_zero, minus_zero);
+
+  TEST_f_f (atanh, 1, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+  TEST_f_f (atanh, -1, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+  TEST_f_f (atanh, nan_value, nan_value);
+
+  /* atanh (x) == NaN plus invalid exception if |x| > 1.  */
+  TEST_f_f (atanh, 1.125L, nan_value, INVALID_EXCEPTION);
+  TEST_f_f (atanh, -1.125L, nan_value, INVALID_EXCEPTION);
+
+  TEST_f_f (atanh, 0.75L, 0.972955074527656652552676371721589865L);
+
+  END (atanh);
+}
+
+static void
+atan2_test (void)
+{
+  errno = 0;
+  FUNC(atan2) (-0, 1);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (atan2);
+
+  /* atan2 (0,x) == 0 for x > 0.  */
+  TEST_ff_f (atan2, 0, 1, 0);
+
+  /* atan2 (-0,x) == -0 for x > 0.  */
+  TEST_ff_f (atan2, minus_zero, 1, minus_zero);
+
+  TEST_ff_f (atan2, 0, 0, 0);
+  TEST_ff_f (atan2, minus_zero, 0, minus_zero);
+
+  /* atan2 (+0,x) == +pi for x < 0.  */
+  TEST_ff_f (atan2, 0, -1, M_PIl);
+
+  /* atan2 (-0,x) == -pi for x < 0.  */
+  TEST_ff_f (atan2, minus_zero, -1, -M_PIl);
+
+  TEST_ff_f (atan2, 0, minus_zero, M_PIl);
+  TEST_ff_f (atan2, minus_zero, minus_zero, -M_PIl);
+
+  /* atan2 (y,+0) == pi/2 for y > 0.  */
+  TEST_ff_f (atan2, 1, 0, M_PI_2l);
+
+  /* atan2 (y,-0) == pi/2 for y > 0.  */
+  TEST_ff_f (atan2, 1, minus_zero, M_PI_2l);
+
+  /* atan2 (y,+0) == -pi/2 for y < 0.  */
+  TEST_ff_f (atan2, -1, 0, -M_PI_2l);
+
+  /* atan2 (y,-0) == -pi/2 for y < 0.  */
+  TEST_ff_f (atan2, -1, minus_zero, -M_PI_2l);
+
+  /* atan2 (y,inf) == +0 for finite y > 0.  */
+  TEST_ff_f (atan2, 1, plus_infty, 0);
+
+  /* atan2 (y,inf) == -0 for finite y < 0.  */
+  TEST_ff_f (atan2, -1, plus_infty, minus_zero);
+
+  /* atan2(+inf, x) == pi/2 for finite x.  */
+  TEST_ff_f (atan2, plus_infty, -1, M_PI_2l);
+
+  /* atan2(-inf, x) == -pi/2 for finite x.  */
+  TEST_ff_f (atan2, minus_infty, 1, -M_PI_2l);
+
+  /* atan2 (y,-inf) == +pi for finite y > 0.  */
+  TEST_ff_f (atan2, 1, minus_infty, M_PIl);
+
+  /* atan2 (y,-inf) == -pi for finite y < 0.  */
+  TEST_ff_f (atan2, -1, minus_infty, -M_PIl);
+
+  TEST_ff_f (atan2, plus_infty, plus_infty, M_PI_4l);
+  TEST_ff_f (atan2, minus_infty, plus_infty, -M_PI_4l);
+  TEST_ff_f (atan2, plus_infty, minus_infty, M_PI_34l);
+  TEST_ff_f (atan2, minus_infty, minus_infty, -M_PI_34l);
+  TEST_ff_f (atan2, nan_value, nan_value, nan_value);
+
+  TEST_ff_f (atan2, 0.75L, 1, 0.643501108793284386802809228717322638L);
+  TEST_ff_f (atan2, -0.75L, 1.0L, -0.643501108793284386802809228717322638L);
+  TEST_ff_f (atan2, 0.75L, -1.0L, 2.49809154479650885165983415456218025L);
+  TEST_ff_f (atan2, -0.75L, -1.0L, -2.49809154479650885165983415456218025L);
+  TEST_ff_f (atan2, 0.390625L, .00029L, 1.57005392693128974780151246612928941L);
+  TEST_ff_f (atan2, 1.390625L, 0.9296875L, 0.981498387184244311516296577615519772L);
+
+  TEST_ff_f (atan2, -0.00756827042671106339L, -.001792735857538728036L, -1.80338464113663849327153994379639112L);
+
+  END (atan2);
+}
+
+static void
+cabs_test (void)
+{
+  errno = 0;
+  FUNC(cabs) (BUILD_COMPLEX (0.7L, 12.4L));
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (cabs);
+
+  /* cabs (x + iy) is specified as hypot (x,y) */
+
+  /* cabs (+inf + i x) == +inf.  */
+  TEST_c_f (cabs, plus_infty, 1.0, plus_infty);
+  /* cabs (-inf + i x) == +inf.  */
+  TEST_c_f (cabs, minus_infty, 1.0, plus_infty);
+
+  TEST_c_f (cabs, minus_infty, nan_value, plus_infty);
+  TEST_c_f (cabs, minus_infty, nan_value, plus_infty);
+
+  TEST_c_f (cabs, nan_value, nan_value, nan_value);
+
+  /* cabs (x,y) == cabs (y,x).  */
+  TEST_c_f (cabs, 0.75L, 12.390625L, 12.4133028598606664302388810868156657L);
+  /* cabs (x,y) == cabs (-x,y).  */
+  TEST_c_f (cabs, -12.390625L, 0.75L, 12.4133028598606664302388810868156657L);
+  /* cabs (x,y) == cabs (-y,x).  */
+  TEST_c_f (cabs, -0.75L, 12.390625L, 12.4133028598606664302388810868156657L);
+  /* cabs (x,y) == cabs (-x,-y).  */
+  TEST_c_f (cabs, -12.390625L, -0.75L, 12.4133028598606664302388810868156657L);
+  /* cabs (x,y) == cabs (-y,-x).  */
+  TEST_c_f (cabs, -0.75L, -12.390625L, 12.4133028598606664302388810868156657L);
+  /* cabs (x,0) == fabs (x).  */
+  TEST_c_f (cabs, -0.75L, 0, 0.75L);
+  TEST_c_f (cabs, 0.75L, 0, 0.75L);
+  TEST_c_f (cabs, -1.0L, 0, 1.0L);
+  TEST_c_f (cabs, 1.0L, 0, 1.0L);
+  TEST_c_f (cabs, -5.7e7L, 0, 5.7e7L);
+  TEST_c_f (cabs, 5.7e7L, 0, 5.7e7L);
+
+  TEST_c_f (cabs, 0.75L, 1.25L, 1.45773797371132511771853821938639577L);
+
+  END (cabs);
+}
+
+
+static void
+cacos_test (void)
+{
+  errno = 0;
+  FUNC(cacos) (BUILD_COMPLEX (0.7L, 1.2L));
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (cacos);
+
+
+  TEST_c_c (cacos, 0, 0, M_PI_2l, minus_zero);
+  TEST_c_c (cacos, minus_zero, 0, M_PI_2l, minus_zero);
+  TEST_c_c (cacos, minus_zero, minus_zero, M_PI_2l, 0.0);
+  TEST_c_c (cacos, 0, minus_zero, M_PI_2l, 0.0);
+
+  TEST_c_c (cacos, minus_infty, plus_infty, M_PI_34l, minus_infty);
+  TEST_c_c (cacos, minus_infty, minus_infty, M_PI_34l, plus_infty);
+
+  TEST_c_c (cacos, plus_infty, plus_infty, M_PI_4l, minus_infty);
+  TEST_c_c (cacos, plus_infty, minus_infty, M_PI_4l, plus_infty);
+
+  TEST_c_c (cacos, -10.0, plus_infty, M_PI_2l, minus_infty);
+  TEST_c_c (cacos, -10.0, minus_infty, M_PI_2l, plus_infty);
+  TEST_c_c (cacos, 0, plus_infty, M_PI_2l, minus_infty);
+  TEST_c_c (cacos, 0, minus_infty, M_PI_2l, plus_infty);
+  TEST_c_c (cacos, 0.1L, plus_infty, M_PI_2l, minus_infty);
+  TEST_c_c (cacos, 0.1L, minus_infty, M_PI_2l, plus_infty);
+
+  TEST_c_c (cacos, minus_infty, 0, M_PIl, minus_infty);
+  TEST_c_c (cacos, minus_infty, minus_zero, M_PIl, plus_infty);
+  TEST_c_c (cacos, minus_infty, 100, M_PIl, minus_infty);
+  TEST_c_c (cacos, minus_infty, -100, M_PIl, plus_infty);
+
+  TEST_c_c (cacos, plus_infty, 0, 0.0, minus_infty);
+  TEST_c_c (cacos, plus_infty, minus_zero, 0.0, plus_infty);
+  TEST_c_c (cacos, plus_infty, 0.5, 0.0, minus_infty);
+  TEST_c_c (cacos, plus_infty, -0.5, 0.0, plus_infty);
+
+  TEST_c_c (cacos, plus_infty, nan_value, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (cacos, minus_infty, nan_value, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
+
+  TEST_c_c (cacos, 0, nan_value, M_PI_2l, nan_value);
+  TEST_c_c (cacos, minus_zero, nan_value, M_PI_2l, nan_value);
+
+  TEST_c_c (cacos, nan_value, plus_infty, nan_value, minus_infty);
+  TEST_c_c (cacos, nan_value, minus_infty, nan_value, plus_infty);
+
+  TEST_c_c (cacos, 10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (cacos, -10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (cacos, nan_value, 0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (cacos, nan_value, -0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (cacos, nan_value, nan_value, nan_value, nan_value);
+
+  TEST_c_c (cacos, 0.75L, 1.25L, 1.11752014915610270578240049553777969L, -1.13239363160530819522266333696834467L);
+  TEST_c_c (cacos, -2, -3, 2.1414491111159960199416055713254211L, 1.9833870299165354323470769028940395L);
+
+  END (cacos, complex);
+}
+
+static void
+cacosh_test (void)
+{
+  errno = 0;
+  FUNC(cacosh) (BUILD_COMPLEX (0.7L, 1.2L));
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (cacosh);
+
+
+  TEST_c_c (cacosh, 0, 0, 0.0, M_PI_2l);
+  TEST_c_c (cacosh, minus_zero, 0, 0.0, M_PI_2l);
+  TEST_c_c (cacosh, 0, minus_zero, 0.0, -M_PI_2l);
+  TEST_c_c (cacosh, minus_zero, minus_zero, 0.0, -M_PI_2l);
+  TEST_c_c (cacosh, minus_infty, plus_infty, plus_infty, M_PI_34l);
+  TEST_c_c (cacosh, minus_infty, minus_infty, plus_infty, -M_PI_34l);
+
+  TEST_c_c (cacosh, plus_infty, plus_infty, plus_infty, M_PI_4l);
+  TEST_c_c (cacosh, plus_infty, minus_infty, plus_infty, -M_PI_4l);
+
+  TEST_c_c (cacosh, -10.0, plus_infty, plus_infty, M_PI_2l);
+  TEST_c_c (cacosh, -10.0, minus_infty, plus_infty, -M_PI_2l);
+  TEST_c_c (cacosh, 0, plus_infty, plus_infty, M_PI_2l);
+  TEST_c_c (cacosh, 0, minus_infty, plus_infty, -M_PI_2l);
+  TEST_c_c (cacosh, 0.1L, plus_infty, plus_infty, M_PI_2l);
+  TEST_c_c (cacosh, 0.1L, minus_infty, plus_infty, -M_PI_2l);
+
+  TEST_c_c (cacosh, minus_infty, 0, plus_infty, M_PIl);
+  TEST_c_c (cacosh, minus_infty, minus_zero, plus_infty, -M_PIl);
+  TEST_c_c (cacosh, minus_infty, 100, plus_infty, M_PIl);
+  TEST_c_c (cacosh, minus_infty, -100, plus_infty, -M_PIl);
+
+  TEST_c_c (cacosh, plus_infty, 0, plus_infty, 0.0);
+  TEST_c_c (cacosh, plus_infty, minus_zero, plus_infty, minus_zero);
+  TEST_c_c (cacosh, plus_infty, 0.5, plus_infty, 0.0);
+  TEST_c_c (cacosh, plus_infty, -0.5, plus_infty, minus_zero);
+
+  TEST_c_c (cacosh, plus_infty, nan_value, plus_infty, nan_value);
+  TEST_c_c (cacosh, minus_infty, nan_value, plus_infty, nan_value);
+
+  TEST_c_c (cacosh, 0, nan_value, nan_value, nan_value);
+  TEST_c_c (cacosh, minus_zero, nan_value, nan_value, nan_value);
+
+  TEST_c_c (cacosh, nan_value, plus_infty, plus_infty, nan_value);
+  TEST_c_c (cacosh, nan_value, minus_infty, plus_infty, nan_value);
+
+  TEST_c_c (cacosh, 10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (cacosh, -10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (cacosh, nan_value, 0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (cacosh, nan_value, -0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (cacosh, nan_value, nan_value, nan_value, nan_value);
+
+  TEST_c_c (cacosh, 0.75L, 1.25L, 1.13239363160530819522266333696834467L, 1.11752014915610270578240049553777969L);
+  TEST_c_c (cacosh, -2, -3, -1.9833870299165354323470769028940395L, 2.1414491111159960199416055713254211L);
+
+  END (cacosh, complex);
+}
+
+
+static void
+carg_test (void)
+{
+  START (carg);
+
+  /* carg (x + iy) is specified as atan2 (y, x) */
+
+  /* carg (x + i 0) == 0 for x > 0.  */
+  TEST_c_f (carg, 2.0, 0, 0);
+  /* carg (x - i 0) == -0 for x > 0.  */
+  TEST_c_f (carg, 2.0, minus_zero, minus_zero);
+
+  TEST_c_f (carg, 0, 0, 0);
+  TEST_c_f (carg, 0, minus_zero, minus_zero);
+
+  /* carg (x + i 0) == +pi for x < 0.  */
+  TEST_c_f (carg, -2.0, 0, M_PIl);
+
+  /* carg (x - i 0) == -pi for x < 0.  */
+  TEST_c_f (carg, -2.0, minus_zero, -M_PIl);
+
+  TEST_c_f (carg, minus_zero, 0, M_PIl);
+  TEST_c_f (carg, minus_zero, minus_zero, -M_PIl);
+
+  /* carg (+0 + i y) == pi/2 for y > 0.  */
+  TEST_c_f (carg, 0, 2.0, M_PI_2l);
+
+  /* carg (-0 + i y) == pi/2 for y > 0.  */
+  TEST_c_f (carg, minus_zero, 2.0, M_PI_2l);
+
+  /* carg (+0 + i y) == -pi/2 for y < 0.  */
+  TEST_c_f (carg, 0, -2.0, -M_PI_2l);
+
+  /* carg (-0 + i y) == -pi/2 for y < 0.  */
+  TEST_c_f (carg, minus_zero, -2.0, -M_PI_2l);
+
+  /* carg (inf + i y) == +0 for finite y > 0.  */
+  TEST_c_f (carg, plus_infty, 2.0, 0);
+
+  /* carg (inf + i y) == -0 for finite y < 0.  */
+  TEST_c_f (carg, plus_infty, -2.0, minus_zero);
+
+  /* carg(x + i inf) == pi/2 for finite x.  */
+  TEST_c_f (carg, 10.0, plus_infty, M_PI_2l);
+
+  /* carg(x - i inf) == -pi/2 for finite x.  */
+  TEST_c_f (carg, 10.0, minus_infty, -M_PI_2l);
+
+  /* carg (-inf + i y) == +pi for finite y > 0.  */
+  TEST_c_f (carg, minus_infty, 10.0, M_PIl);
+
+  /* carg (-inf + i y) == -pi for finite y < 0.  */
+  TEST_c_f (carg, minus_infty, -10.0, -M_PIl);
+
+  TEST_c_f (carg, plus_infty, plus_infty, M_PI_4l);
+
+  TEST_c_f (carg, plus_infty, minus_infty, -M_PI_4l);
+
+  TEST_c_f (carg, minus_infty, plus_infty, 3 * M_PI_4l);
+
+  TEST_c_f (carg, minus_infty, minus_infty, -3 * M_PI_4l);
+
+  TEST_c_f (carg, nan_value, nan_value, nan_value);
+
+  END (carg);
+}
+
+static void
+casin_test (void)
+{
+  errno = 0;
+  FUNC(casin) (BUILD_COMPLEX (0.7L, 1.2L));
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (casin);
+
+  TEST_c_c (casin, 0, 0, 0.0, 0.0);
+  TEST_c_c (casin, minus_zero, 0, minus_zero, 0.0);
+  TEST_c_c (casin, 0, minus_zero, 0.0, minus_zero);
+  TEST_c_c (casin, minus_zero, minus_zero, minus_zero, minus_zero);
+
+  TEST_c_c (casin, plus_infty, plus_infty, M_PI_4l, plus_infty);
+  TEST_c_c (casin, plus_infty, minus_infty, M_PI_4l, minus_infty);
+  TEST_c_c (casin, minus_infty, plus_infty, -M_PI_4l, plus_infty);
+  TEST_c_c (casin, minus_infty, minus_infty, -M_PI_4l, minus_infty);
+
+  TEST_c_c (casin, -10.0, plus_infty, minus_zero, plus_infty);
+  TEST_c_c (casin, -10.0, minus_infty, minus_zero, minus_infty);
+  TEST_c_c (casin, 0, plus_infty, 0.0, plus_infty);
+  TEST_c_c (casin, 0, minus_infty, 0.0, minus_infty);
+  TEST_c_c (casin, minus_zero, plus_infty, minus_zero, plus_infty);
+  TEST_c_c (casin, minus_zero, minus_infty, minus_zero, minus_infty);
+  TEST_c_c (casin, 0.1L, plus_infty, 0.0, plus_infty);
+  TEST_c_c (casin, 0.1L, minus_infty, 0.0, minus_infty);
+
+  TEST_c_c (casin, minus_infty, 0, -M_PI_2l, plus_infty);
+  TEST_c_c (casin, minus_infty, minus_zero, -M_PI_2l, minus_infty);
+  TEST_c_c (casin, minus_infty, 100, -M_PI_2l, plus_infty);
+  TEST_c_c (casin, minus_infty, -100, -M_PI_2l, minus_infty);
+
+  TEST_c_c (casin, plus_infty, 0, M_PI_2l, plus_infty);
+  TEST_c_c (casin, plus_infty, minus_zero, M_PI_2l, minus_infty);
+  TEST_c_c (casin, plus_infty, 0.5, M_PI_2l, plus_infty);
+  TEST_c_c (casin, plus_infty, -0.5, M_PI_2l, minus_infty);
+
+  TEST_c_c (casin, nan_value, plus_infty, nan_value, plus_infty);
+  TEST_c_c (casin, nan_value, minus_infty, nan_value, minus_infty);
+
+  TEST_c_c (casin, 0.0, nan_value, 0.0, nan_value);
+  TEST_c_c (casin, minus_zero, nan_value, minus_zero, nan_value);
+
+  TEST_c_c (casin, plus_infty, nan_value, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (casin, minus_infty, nan_value, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
+
+  TEST_c_c (casin, nan_value, 10.5, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (casin, nan_value, -10.5, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (casin, 0.75, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (casin, -0.75, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (casin, nan_value, nan_value, nan_value, nan_value);
+
+  TEST_c_c (casin, 0.75L, 1.25L, 0.453276177638793913448921196101971749L, 1.13239363160530819522266333696834467L);
+  TEST_c_c (casin, -2, -3, -0.57065278432109940071028387968566963L, -1.9833870299165354323470769028940395L);
+
+  END (casin, complex);
+}
+
+
+static void
+casinh_test (void)
+{
+  errno = 0;
+  FUNC(casinh) (BUILD_COMPLEX (0.7L, 1.2L));
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (casinh);
+
+  TEST_c_c (casinh, 0, 0, 0.0, 0.0);
+  TEST_c_c (casinh, minus_zero, 0, minus_zero, 0);
+  TEST_c_c (casinh, 0, minus_zero, 0.0, minus_zero);
+  TEST_c_c (casinh, minus_zero, minus_zero, minus_zero, minus_zero);
+
+  TEST_c_c (casinh, plus_infty, plus_infty, plus_infty, M_PI_4l);
+  TEST_c_c (casinh, plus_infty, minus_infty, plus_infty, -M_PI_4l);
+  TEST_c_c (casinh, minus_infty, plus_infty, minus_infty, M_PI_4l);
+  TEST_c_c (casinh, minus_infty, minus_infty, minus_infty, -M_PI_4l);
+
+  TEST_c_c (casinh, -10.0, plus_infty, minus_infty, M_PI_2l);
+  TEST_c_c (casinh, -10.0, minus_infty, minus_infty, -M_PI_2l);
+  TEST_c_c (casinh, 0, plus_infty, plus_infty, M_PI_2l);
+  TEST_c_c (casinh, 0, minus_infty, plus_infty, -M_PI_2l);
+  TEST_c_c (casinh, minus_zero, plus_infty, minus_infty, M_PI_2l);
+  TEST_c_c (casinh, minus_zero, minus_infty, minus_infty, -M_PI_2l);
+  TEST_c_c (casinh, 0.1L, plus_infty, plus_infty, M_PI_2l);
+  TEST_c_c (casinh, 0.1L, minus_infty, plus_infty, -M_PI_2l);
+
+  TEST_c_c (casinh, minus_infty, 0, minus_infty, 0.0);
+  TEST_c_c (casinh, minus_infty, minus_zero, minus_infty, minus_zero);
+  TEST_c_c (casinh, minus_infty, 100, minus_infty, 0.0);
+  TEST_c_c (casinh, minus_infty, -100, minus_infty, minus_zero);
+
+  TEST_c_c (casinh, plus_infty, 0, plus_infty, 0.0);
+  TEST_c_c (casinh, plus_infty, minus_zero, plus_infty, minus_zero);
+  TEST_c_c (casinh, plus_infty, 0.5, plus_infty, 0.0);
+  TEST_c_c (casinh, plus_infty, -0.5, plus_infty, minus_zero);
+
+  TEST_c_c (casinh, plus_infty, nan_value, plus_infty, nan_value);
+  TEST_c_c (casinh, minus_infty, nan_value, minus_infty, nan_value);
+
+  TEST_c_c (casinh, nan_value, 0, nan_value, 0.0);
+  TEST_c_c (casinh, nan_value, minus_zero, nan_value, minus_zero);
+
+  TEST_c_c (casinh, nan_value, plus_infty, plus_infty, nan_value, IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (casinh, nan_value, minus_infty, plus_infty, nan_value, IGNORE_ZERO_INF_SIGN);
+
+  TEST_c_c (casinh, 10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (casinh, -10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (casinh, nan_value, 0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (casinh, -0.75, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (casinh, nan_value, nan_value, nan_value, nan_value);
+
+  TEST_c_c (casinh, 0.75L, 1.25L, 1.03171853444778027336364058631006594L, 0.911738290968487636358489564316731207L);
+  TEST_c_c (casinh, -2, -3, -1.9686379257930962917886650952454982L, -0.96465850440760279204541105949953237L);
+
+  END (casinh, complex);
+}
+
+
+static void
+catan_test (void)
+{
+  errno = 0;
+  FUNC(catan) (BUILD_COMPLEX (0.7L, 1.2L));
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (catan);
+
+  TEST_c_c (catan, 0, 0, 0, 0);
+  TEST_c_c (catan, minus_zero, 0, minus_zero, 0);
+  TEST_c_c (catan, 0, minus_zero, 0, minus_zero);
+  TEST_c_c (catan, minus_zero, minus_zero, minus_zero, minus_zero);
+
+  TEST_c_c (catan, plus_infty, plus_infty, M_PI_2l, 0);
+  TEST_c_c (catan, plus_infty, minus_infty, M_PI_2l, minus_zero);
+  TEST_c_c (catan, minus_infty, plus_infty, -M_PI_2l, 0);
+  TEST_c_c (catan, minus_infty, minus_infty, -M_PI_2l, minus_zero);
+
+
+  TEST_c_c (catan, plus_infty, -10.0, M_PI_2l, minus_zero);
+  TEST_c_c (catan, minus_infty, -10.0, -M_PI_2l, minus_zero);
+  TEST_c_c (catan, plus_infty, minus_zero, M_PI_2l, minus_zero);
+  TEST_c_c (catan, minus_infty, minus_zero, -M_PI_2l, minus_zero);
+  TEST_c_c (catan, plus_infty, 0.0, M_PI_2l, 0);
+  TEST_c_c (catan, minus_infty, 0.0, -M_PI_2l, 0);
+  TEST_c_c (catan, plus_infty, 0.1L, M_PI_2l, 0);
+  TEST_c_c (catan, minus_infty, 0.1L, -M_PI_2l, 0);
+
+  TEST_c_c (catan, 0.0, minus_infty, M_PI_2l, minus_zero);
+  TEST_c_c (catan, minus_zero, minus_infty, -M_PI_2l, minus_zero);
+  TEST_c_c (catan, 100.0, minus_infty, M_PI_2l, minus_zero);
+  TEST_c_c (catan, -100.0, minus_infty, -M_PI_2l, minus_zero);
+
+  TEST_c_c (catan, 0.0, plus_infty, M_PI_2l, 0);
+  TEST_c_c (catan, minus_zero, plus_infty, -M_PI_2l, 0);
+  TEST_c_c (catan, 0.5, plus_infty, M_PI_2l, 0);
+  TEST_c_c (catan, -0.5, plus_infty, -M_PI_2l, 0);
+
+  TEST_c_c (catan, nan_value, 0.0, nan_value, 0);
+  TEST_c_c (catan, nan_value, minus_zero, nan_value, minus_zero);
+
+  TEST_c_c (catan, nan_value, plus_infty, nan_value, 0);
+  TEST_c_c (catan, nan_value, minus_infty, nan_value, minus_zero);
+
+  TEST_c_c (catan, 0.0, nan_value, nan_value, nan_value);
+  TEST_c_c (catan, minus_zero, nan_value, nan_value, nan_value);
+
+  TEST_c_c (catan, plus_infty, nan_value, M_PI_2l, 0, IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (catan, minus_infty, nan_value, -M_PI_2l, 0, IGNORE_ZERO_INF_SIGN);
+
+  TEST_c_c (catan, nan_value, 10.5, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (catan, nan_value, -10.5, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (catan, 0.75, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (catan, -0.75, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (catan, nan_value, nan_value, nan_value, nan_value);
+
+  TEST_c_c (catan, 0.75L, 1.25L, 1.10714871779409050301706546017853704L, 0.549306144334054845697622618461262852L);
+  TEST_c_c (catan, -2, -3, -1.4099210495965755225306193844604208L, -0.22907268296853876629588180294200276L);
+
+  END (catan, complex);
+}
+
+static void
+catanh_test (void)
+{
+  errno = 0;
+  FUNC(catanh) (BUILD_COMPLEX (0.7L, 1.2L));
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (catanh);
+
+  TEST_c_c (catanh, 0, 0, 0.0, 0.0);
+  TEST_c_c (catanh, minus_zero, 0, minus_zero, 0.0);
+  TEST_c_c (catanh, 0, minus_zero, 0.0, minus_zero);
+  TEST_c_c (catanh, minus_zero, minus_zero, minus_zero, minus_zero);
+
+  TEST_c_c (catanh, plus_infty, plus_infty, 0.0, M_PI_2l);
+  TEST_c_c (catanh, plus_infty, minus_infty, 0.0, -M_PI_2l);
+  TEST_c_c (catanh, minus_infty, plus_infty, minus_zero, M_PI_2l);
+  TEST_c_c (catanh, minus_infty, minus_infty, minus_zero, -M_PI_2l);
+
+  TEST_c_c (catanh, -10.0, plus_infty, minus_zero, M_PI_2l);
+  TEST_c_c (catanh, -10.0, minus_infty, minus_zero, -M_PI_2l);
+  TEST_c_c (catanh, minus_zero, plus_infty, minus_zero, M_PI_2l);
+  TEST_c_c (catanh, minus_zero, minus_infty, minus_zero, -M_PI_2l);
+  TEST_c_c (catanh, 0, plus_infty, 0.0, M_PI_2l);
+  TEST_c_c (catanh, 0, minus_infty, 0.0, -M_PI_2l);
+  TEST_c_c (catanh, 0.1L, plus_infty, 0.0, M_PI_2l);
+  TEST_c_c (catanh, 0.1L, minus_infty, 0.0, -M_PI_2l);
+
+  TEST_c_c (catanh, minus_infty, 0, minus_zero, M_PI_2l);
+  TEST_c_c (catanh, minus_infty, minus_zero, minus_zero, -M_PI_2l);
+  TEST_c_c (catanh, minus_infty, 100, minus_zero, M_PI_2l);
+  TEST_c_c (catanh, minus_infty, -100, minus_zero, -M_PI_2l);
+
+  TEST_c_c (catanh, plus_infty, 0, 0.0, M_PI_2l);
+  TEST_c_c (catanh, plus_infty, minus_zero, 0.0, -M_PI_2l);
+  TEST_c_c (catanh, plus_infty, 0.5, 0.0, M_PI_2l);
+  TEST_c_c (catanh, plus_infty, -0.5, 0.0, -M_PI_2l);
+
+  TEST_c_c (catanh, 0, nan_value, 0.0, nan_value);
+  TEST_c_c (catanh, minus_zero, nan_value, minus_zero, nan_value);
+
+  TEST_c_c (catanh, plus_infty, nan_value, 0.0, nan_value);
+  TEST_c_c (catanh, minus_infty, nan_value, minus_zero, nan_value);
+
+  TEST_c_c (catanh, nan_value, 0, nan_value, nan_value);
+  TEST_c_c (catanh, nan_value, minus_zero, nan_value, nan_value);
+
+  TEST_c_c (catanh, nan_value, plus_infty, 0.0, M_PI_2l, IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (catanh, nan_value, minus_infty, 0.0, -M_PI_2l, IGNORE_ZERO_INF_SIGN);
+
+  TEST_c_c (catanh, 10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (catanh, -10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (catanh, nan_value, 0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (catanh, nan_value, -0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (catanh, nan_value, nan_value, nan_value, nan_value);
+
+  TEST_c_c (catanh, 0.75L, 1.25L, 0.261492138795671927078652057366532140L, 0.996825126463918666098902241310446708L);
+  TEST_c_c (catanh, -2, -3, -0.14694666622552975204743278515471595L, -1.3389725222944935611241935759091443L);
+
+  END (catanh, complex);
+}
+
+static void
+cbrt_test (void)
+{
+  errno = 0;
+  FUNC(cbrt) (8);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (cbrt);
+
+  TEST_f_f (cbrt, 0.0, 0.0);
+  TEST_f_f (cbrt, minus_zero, minus_zero);
+
+  TEST_f_f (cbrt, plus_infty, plus_infty);
+  TEST_f_f (cbrt, minus_infty, minus_infty);
+  TEST_f_f (cbrt, nan_value, nan_value);
+
+  TEST_f_f (cbrt, -0.001L, -0.1L);
+  TEST_f_f (cbrt, 8, 2);
+  TEST_f_f (cbrt, -27.0, -3.0);
+  TEST_f_f (cbrt, 0.9921875L, 0.997389022060725270579075195353955217L);
+  TEST_f_f (cbrt, 0.75L, 0.908560296416069829445605878163630251L);
+
+  END (cbrt);
+}
+
+
+static void
+ccos_test (void)
+{
+  errno = 0;
+  FUNC(ccos) (BUILD_COMPLEX (0, 0));
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (ccos);
+
+  TEST_c_c (ccos, 0.0, 0.0, 1.0, minus_zero);
+  TEST_c_c (ccos, minus_zero, 0.0, 1.0, 0.0);
+  TEST_c_c (ccos, 0.0, minus_zero, 1.0, 0.0);
+  TEST_c_c (ccos, minus_zero, minus_zero, 1.0, minus_zero);
+
+  TEST_c_c (ccos, plus_infty, 0.0, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (ccos, plus_infty, minus_zero, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (ccos, minus_infty, 0.0, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (ccos, minus_infty, minus_zero, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+
+  TEST_c_c (ccos, 0.0, plus_infty, plus_infty, minus_zero);
+  TEST_c_c (ccos, 0.0, minus_infty, plus_infty, 0.0);
+  TEST_c_c (ccos, minus_zero, plus_infty, plus_infty, 0.0);
+  TEST_c_c (ccos, minus_zero, minus_infty, plus_infty, minus_zero);
+
+  TEST_c_c (ccos, plus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ccos, minus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ccos, plus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ccos, minus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
+
+  TEST_c_c (ccos, 4.625, plus_infty, minus_infty, plus_infty);
+  TEST_c_c (ccos, 4.625, minus_infty, minus_infty, minus_infty);
+  TEST_c_c (ccos, -4.625, plus_infty, minus_infty, minus_infty);
+  TEST_c_c (ccos, -4.625, minus_infty, minus_infty, plus_infty);
+
+  TEST_c_c (ccos, plus_infty, 6.75, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ccos, plus_infty, -6.75, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ccos, minus_infty, 6.75, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ccos, minus_infty, -6.75, nan_value, nan_value, INVALID_EXCEPTION);
+
+  TEST_c_c (ccos, nan_value, 0.0, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (ccos, nan_value, minus_zero, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
+
+  TEST_c_c (ccos, nan_value, plus_infty, plus_infty, nan_value);
+  TEST_c_c (ccos, nan_value, minus_infty, plus_infty, nan_value);
+
+  TEST_c_c (ccos, nan_value, 9.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (ccos, nan_value, -9.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (ccos, 0.0, nan_value, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (ccos, minus_zero, nan_value, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
+
+  TEST_c_c (ccos, 10.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (ccos, -10.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (ccos, plus_infty, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (ccos, minus_infty, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (ccos, nan_value, nan_value, nan_value, nan_value);
+
+  TEST_c_c (ccos, 0.75L, 1.25L, 1.38173873063425888530729933139078645L, -1.09193013555397466170919531722024128L);
+  TEST_c_c (ccos, -2, -3, -4.18962569096880723013255501961597373L, -9.10922789375533659797919726277886212L);
+
+  END (ccos, complex);
+}
+
+
+static void
+ccosh_test (void)
+{
+  errno = 0;
+  FUNC(ccosh) (BUILD_COMPLEX (0.7L, 1.2L));
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (ccosh);
+
+  TEST_c_c (ccosh, 0.0, 0.0, 1.0, 0.0);
+  TEST_c_c (ccosh, minus_zero, 0.0, 1.0, minus_zero);
+  TEST_c_c (ccosh, 0.0, minus_zero, 1.0, minus_zero);
+  TEST_c_c (ccosh, minus_zero, minus_zero, 1.0, 0.0);
+
+  TEST_c_c (ccosh, 0.0, plus_infty, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (ccosh, minus_zero, plus_infty, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (ccosh, 0.0, minus_infty, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (ccosh, minus_zero, minus_infty, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+
+  TEST_c_c (ccosh, plus_infty, 0.0, plus_infty, 0.0);
+  TEST_c_c (ccosh, minus_infty, 0.0, plus_infty, minus_zero);
+  TEST_c_c (ccosh, plus_infty, minus_zero, plus_infty, minus_zero);
+  TEST_c_c (ccosh, minus_infty, minus_zero, plus_infty, 0.0);
+
+  TEST_c_c (ccosh, plus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ccosh, minus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ccosh, plus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ccosh, minus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
+
+  TEST_c_c (ccosh, plus_infty, 4.625, minus_infty, minus_infty);
+  TEST_c_c (ccosh, minus_infty, 4.625, minus_infty, plus_infty);
+  TEST_c_c (ccosh, plus_infty, -4.625, minus_infty, plus_infty);
+  TEST_c_c (ccosh, minus_infty, -4.625, minus_infty, minus_infty);
+
+  TEST_c_c (ccosh, 6.75, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ccosh, -6.75, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ccosh, 6.75, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ccosh, -6.75, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+
+  TEST_c_c (ccosh, 0.0, nan_value, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (ccosh, minus_zero, nan_value, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
+
+  TEST_c_c (ccosh, plus_infty, nan_value, plus_infty, nan_value);
+  TEST_c_c (ccosh, minus_infty, nan_value, plus_infty, nan_value);
+
+  TEST_c_c (ccosh, 9.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (ccosh, -9.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (ccosh, nan_value, 0.0, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (ccosh, nan_value, minus_zero, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
+
+  TEST_c_c (ccosh, nan_value, 10.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (ccosh, nan_value, -10.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (ccosh, nan_value, plus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (ccosh, nan_value, minus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (ccosh, nan_value, nan_value, nan_value, nan_value);
+
+  TEST_c_c (ccosh, 0.75L, 1.25L, 0.408242591877968807788852146397499084L, 0.780365930845853240391326216300863152L);
+
+  TEST_c_c (ccosh, -2, -3, -3.72454550491532256547397070325597253L, 0.511822569987384608834463849801875634L);
+
+  END (ccosh, complex);
+}
+
+
+static void
+ceil_test (void)
+{
+  START (ceil);
+
+  TEST_f_f (ceil, 0.0, 0.0);
+  TEST_f_f (ceil, minus_zero, minus_zero);
+  TEST_f_f (ceil, plus_infty, plus_infty);
+  TEST_f_f (ceil, minus_infty, minus_infty);
+  TEST_f_f (ceil, nan_value, nan_value);
+
+  TEST_f_f (ceil, M_PIl, 4.0);
+  TEST_f_f (ceil, -M_PIl, -3.0);
+  TEST_f_f (ceil, 0.25, 1.0);
+  TEST_f_f (ceil, -0.25, minus_zero);
+
+  END (ceil);
+}
+
+
+static void
+cexp_test (void)
+{
+  errno = 0;
+  FUNC(cexp) (BUILD_COMPLEX (0, 0));
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (cexp);
+
+  TEST_c_c (cexp, plus_zero, plus_zero, 1, 0.0);
+  TEST_c_c (cexp, minus_zero, plus_zero, 1, 0.0);
+  TEST_c_c (cexp, plus_zero, minus_zero, 1, minus_zero);
+  TEST_c_c (cexp, minus_zero, minus_zero, 1, minus_zero);
+
+  TEST_c_c (cexp, plus_infty, plus_zero, plus_infty, 0.0);
+  TEST_c_c (cexp, plus_infty, minus_zero, plus_infty, minus_zero);
+
+  TEST_c_c (cexp, minus_infty, plus_zero, 0.0, 0.0);
+  TEST_c_c (cexp, minus_infty, minus_zero, 0.0, minus_zero);
+
+  TEST_c_c (cexp, 0.0, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (cexp, minus_zero, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+
+  TEST_c_c (cexp, 0.0, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (cexp, minus_zero, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+
+  TEST_c_c (cexp, 100.0, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (cexp, -100.0, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+
+  TEST_c_c (cexp, 100.0, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (cexp, -100.0, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+
+  TEST_c_c (cexp, minus_infty, 2.0, minus_zero, 0.0);
+  TEST_c_c (cexp, minus_infty, 4.0, minus_zero, minus_zero);
+  TEST_c_c (cexp, plus_infty, 2.0, minus_infty, plus_infty);
+  TEST_c_c (cexp, plus_infty, 4.0, minus_infty, minus_infty);
+
+  TEST_c_c (cexp, plus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (cexp, plus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+
+  TEST_c_c (cexp, minus_infty, plus_infty, 0.0, 0.0, IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (cexp, minus_infty, minus_infty, 0.0, minus_zero, IGNORE_ZERO_INF_SIGN);
+
+  TEST_c_c (cexp, minus_infty, nan_value, 0, 0, IGNORE_ZERO_INF_SIGN);
+
+  TEST_c_c (cexp, plus_infty, nan_value, plus_infty, nan_value);
+
+  TEST_c_c (cexp, nan_value, 0.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (cexp, nan_value, 1.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (cexp, nan_value, plus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (cexp, 0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (cexp, 1, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (cexp, nan_value, nan_value, nan_value, nan_value);
+
+  TEST_c_c (cexp, 0.75L, 1.25L, 0.667537446429131586942201977015932112L, 2.00900045494094876258347228145863909L);
+  TEST_c_c (cexp, -2.0, -3.0, -0.13398091492954261346140525546115575L, -0.019098516261135196432576240858800925L);
+
+  END (cexp, complex);
+}
+
+
+static void
+cimag_test (void)
+{
+  START (cimag);
+  TEST_c_f (cimag, 1.0, 0.0, 0.0);
+  TEST_c_f (cimag, 1.0, minus_zero, minus_zero);
+  TEST_c_f (cimag, 1.0, nan_value, nan_value);
+  TEST_c_f (cimag, nan_value, nan_value, nan_value);
+  TEST_c_f (cimag, 1.0, plus_infty, plus_infty);
+  TEST_c_f (cimag, 1.0, minus_infty, minus_infty);
+  TEST_c_f (cimag, 2.0, 3.0, 3.0);
+
+  END (cimag);
+}
+
+static void
+clog_test (void)
+{
+  errno = 0;
+  FUNC(clog) (BUILD_COMPLEX (-2, -3));
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (clog);
+
+  TEST_c_c (clog, minus_zero, 0, minus_infty, M_PIl, DIVIDE_BY_ZERO_EXCEPTION);
+  TEST_c_c (clog, minus_zero, minus_zero, minus_infty, -M_PIl, DIVIDE_BY_ZERO_EXCEPTION);
+
+  TEST_c_c (clog, 0, 0, minus_infty, 0.0, DIVIDE_BY_ZERO_EXCEPTION);
+  TEST_c_c (clog, 0, minus_zero, minus_infty, minus_zero, DIVIDE_BY_ZERO_EXCEPTION);
+
+  TEST_c_c (clog, minus_infty, plus_infty, plus_infty, M_PI_34l);
+  TEST_c_c (clog, minus_infty, minus_infty, plus_infty, -M_PI_34l);
+
+  TEST_c_c (clog, plus_infty, plus_infty, plus_infty, M_PI_4l);
+  TEST_c_c (clog, plus_infty, minus_infty, plus_infty, -M_PI_4l);
+
+  TEST_c_c (clog, 0, plus_infty, plus_infty, M_PI_2l);
+  TEST_c_c (clog, 3, plus_infty, plus_infty, M_PI_2l);
+  TEST_c_c (clog, minus_zero, plus_infty, plus_infty, M_PI_2l);
+  TEST_c_c (clog, -3, plus_infty, plus_infty, M_PI_2l);
+  TEST_c_c (clog, 0, minus_infty, plus_infty, -M_PI_2l);
+  TEST_c_c (clog, 3, minus_infty, plus_infty, -M_PI_2l);
+  TEST_c_c (clog, minus_zero, minus_infty, plus_infty, -M_PI_2l);
+  TEST_c_c (clog, -3, minus_infty, plus_infty, -M_PI_2l);
+
+  TEST_c_c (clog, minus_infty, 0, plus_infty, M_PIl);
+  TEST_c_c (clog, minus_infty, 1, plus_infty, M_PIl);
+  TEST_c_c (clog, minus_infty, minus_zero, plus_infty, -M_PIl);
+  TEST_c_c (clog, minus_infty, -1, plus_infty, -M_PIl);
+
+  TEST_c_c (clog, plus_infty, 0, plus_infty, 0.0);
+  TEST_c_c (clog, plus_infty, 1, plus_infty, 0.0);
+  TEST_c_c (clog, plus_infty, minus_zero, plus_infty, minus_zero);
+  TEST_c_c (clog, plus_infty, -1, plus_infty, minus_zero);
+
+  TEST_c_c (clog, plus_infty, nan_value, plus_infty, nan_value);
+  TEST_c_c (clog, minus_infty, nan_value, plus_infty, nan_value);
+
+  TEST_c_c (clog, nan_value, plus_infty, plus_infty, nan_value);
+  TEST_c_c (clog, nan_value, minus_infty, plus_infty, nan_value);
+
+  TEST_c_c (clog, 0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (clog, 3, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (clog, minus_zero, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (clog, -3, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (clog, nan_value, 0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (clog, nan_value, 5, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (clog, nan_value, minus_zero, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (clog, nan_value, -5, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (clog, nan_value, nan_value, nan_value, nan_value);
+
+  TEST_c_c (clog, 0.75L, 1.25L, 0.376885901188190075998919126749298416L, 1.03037682652431246378774332703115153L);
+  TEST_c_c (clog, -2, -3, 1.2824746787307683680267437207826593L, -2.1587989303424641704769327722648368L);
+
+  END (clog, complex);
+}
+
+
+static void
+clog10_test (void)
+{
+  errno = 0;
+  FUNC(clog10) (BUILD_COMPLEX (0.7L, 1.2L));
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (clog10);
+
+  TEST_c_c (clog10, minus_zero, 0, minus_infty, M_PIl, DIVIDE_BY_ZERO_EXCEPTION);
+  TEST_c_c (clog10, minus_zero, minus_zero, minus_infty, -M_PIl, DIVIDE_BY_ZERO_EXCEPTION);
+
+  TEST_c_c (clog10, 0, 0, minus_infty, 0.0, DIVIDE_BY_ZERO_EXCEPTION);
+  TEST_c_c (clog10, 0, minus_zero, minus_infty, minus_zero, DIVIDE_BY_ZERO_EXCEPTION);
+
+  TEST_c_c (clog10, minus_infty, plus_infty, plus_infty, M_PI_34_LOG10El);
+
+  TEST_c_c (clog10, plus_infty, plus_infty, plus_infty, M_PI4_LOG10El);
+  TEST_c_c (clog10, plus_infty, minus_infty, plus_infty, -M_PI4_LOG10El);
+
+  TEST_c_c (clog10, 0, plus_infty, plus_infty, M_PI2_LOG10El);
+  TEST_c_c (clog10, 3, plus_infty, plus_infty, M_PI2_LOG10El);
+  TEST_c_c (clog10, minus_zero, plus_infty, plus_infty, M_PI2_LOG10El);
+  TEST_c_c (clog10, -3, plus_infty, plus_infty, M_PI2_LOG10El);
+  TEST_c_c (clog10, 0, minus_infty, plus_infty, -M_PI2_LOG10El);
+  TEST_c_c (clog10, 3, minus_infty, plus_infty, -M_PI2_LOG10El);
+  TEST_c_c (clog10, minus_zero, minus_infty, plus_infty, -M_PI2_LOG10El);
+  TEST_c_c (clog10, -3, minus_infty, plus_infty, -M_PI2_LOG10El);
+
+  TEST_c_c (clog10, minus_infty, 0, plus_infty, M_PI_LOG10El);
+  TEST_c_c (clog10, minus_infty, 1, plus_infty, M_PI_LOG10El);
+  TEST_c_c (clog10, minus_infty, minus_zero, plus_infty, -M_PI_LOG10El);
+  TEST_c_c (clog10, minus_infty, -1, plus_infty, -M_PI_LOG10El);
+
+  TEST_c_c (clog10, plus_infty, 0, plus_infty, 0.0);
+  TEST_c_c (clog10, plus_infty, 1, plus_infty, 0.0);
+  TEST_c_c (clog10, plus_infty, minus_zero, plus_infty, minus_zero);
+  TEST_c_c (clog10, plus_infty, -1, plus_infty, minus_zero);
+
+  TEST_c_c (clog10, plus_infty, nan_value, plus_infty, nan_value);
+  TEST_c_c (clog10, minus_infty, nan_value, plus_infty, nan_value);
+
+  TEST_c_c (clog10, nan_value, plus_infty, plus_infty, nan_value);
+  TEST_c_c (clog10, nan_value, minus_infty, plus_infty, nan_value);
+
+  TEST_c_c (clog10, 0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (clog10, 3, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (clog10, minus_zero, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (clog10, -3, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (clog10, nan_value, 0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (clog10, nan_value, 5, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (clog10, nan_value, minus_zero, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (clog10, nan_value, -5, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (clog10, nan_value, nan_value, nan_value, nan_value);
+
+  TEST_c_c (clog10, 0.75L, 1.25L, 0.163679467193165171449476605077428975L, 0.447486970040493067069984724340855636L);
+  TEST_c_c (clog10, -2, -3, 0.556971676153418384603252578971164214L, -0.937554462986374708541507952140189646L);
+
+  END (clog10, complex);
+}
+
+
+static void
+conj_test (void)
+{
+  START (conj);
+  TEST_c_c (conj, 0.0, 0.0, 0.0, minus_zero);
+  TEST_c_c (conj, 0.0, minus_zero, 0.0, 0.0);
+  TEST_c_c (conj, nan_value, nan_value, nan_value, nan_value);
+  TEST_c_c (conj, plus_infty, minus_infty, plus_infty, plus_infty);
+  TEST_c_c (conj, plus_infty, plus_infty, plus_infty, minus_infty);
+  TEST_c_c (conj, 1.0, 2.0, 1.0, -2.0);
+  TEST_c_c (conj, 3.0, -4.0, 3.0, 4.0);
+
+  END (conj, complex);
+}
+
+
+static void
+copysign_test (void)
+{
+  START (copysign);
+
+  TEST_ff_f (copysign, 0, 4, 0);
+  TEST_ff_f (copysign, 0, -4, minus_zero);
+  TEST_ff_f (copysign, minus_zero, 4, 0);
+  TEST_ff_f (copysign, minus_zero, -4, minus_zero);
+
+  TEST_ff_f (copysign, plus_infty, 0, plus_infty);
+  TEST_ff_f (copysign, plus_infty, minus_zero, minus_infty);
+  TEST_ff_f (copysign, minus_infty, 0, plus_infty);
+  TEST_ff_f (copysign, minus_infty, minus_zero, minus_infty);
+
+  TEST_ff_f (copysign, 0, plus_infty, 0);
+  TEST_ff_f (copysign, 0, minus_zero, minus_zero);
+  TEST_ff_f (copysign, minus_zero, plus_infty, 0);
+  TEST_ff_f (copysign, minus_zero, minus_zero, minus_zero);
+
+  /* XXX More correctly we would have to check the sign of the NaN.  */
+  TEST_ff_f (copysign, nan_value, 0, nan_value);
+  TEST_ff_f (copysign, nan_value, minus_zero, nan_value);
+  TEST_ff_f (copysign, -nan_value, 0, nan_value);
+  TEST_ff_f (copysign, -nan_value, minus_zero, nan_value);
+
+  END (copysign);
+}
+
+
+static void
+cos_test (void)
+{
+  errno = 0;
+  FUNC(cos) (0);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (cos);
+
+  TEST_f_f (cos, 0, 1);
+  TEST_f_f (cos, minus_zero, 1);
+  TEST_f_f (cos, plus_infty, nan_value, INVALID_EXCEPTION);
+  TEST_f_f (cos, minus_infty, nan_value, INVALID_EXCEPTION);
+  TEST_f_f (cos, nan_value, nan_value);
+
+  TEST_f_f (cos, M_PI_6l * 2.0, 0.5);
+  TEST_f_f (cos, M_PI_6l * 4.0, -0.5);
+  TEST_f_f (cos, M_PI_2l, 0);
+
+  TEST_f_f (cos, 0.75L, 0.731688868873820886311838753000084544L);
+
+#ifdef TEST_DOUBLE
+  TEST_f_f (cos, 0.80190127184058835, 0.69534156199418473);
+#endif
+
+  END (cos);
+}
+
+
+static void
+cosh_test (void)
+{
+  errno = 0;
+  FUNC(cosh) (0.7L);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (cosh);
+  TEST_f_f (cosh, 0, 1);
+  TEST_f_f (cosh, minus_zero, 1);
+
+#ifndef TEST_INLINE
+  TEST_f_f (cosh, plus_infty, plus_infty);
+  TEST_f_f (cosh, minus_infty, plus_infty);
+#endif
+  TEST_f_f (cosh, nan_value, nan_value);
+
+  TEST_f_f (cosh, 0.75L, 1.29468328467684468784170818539018176L);
+
+  END (cosh);
+}
+
+
+static void
+cpow_test (void)
+{
+  errno = 0;
+  FUNC(cpow) (BUILD_COMPLEX (1, 0), BUILD_COMPLEX (0, 0));
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (cpow);
+
+  TEST_cc_c (cpow, 1, 0, 0, 0, 1.0, 0.0);
+  TEST_cc_c (cpow, 2, 0, 10, 0, 1024.0, 0.0);
+
+  TEST_cc_c (cpow, M_El, 0, 0, 2 * M_PIl, 1.0, 0.0);
+  TEST_cc_c (cpow, 2, 3, 4, 0, -119.0, -120.0);
+
+  TEST_cc_c (cpow, nan_value, nan_value, nan_value, nan_value, nan_value, nan_value);
+
+  TEST_cc_c (cpow, 0.75L, 1.25L, 0.75L, 1.25L, 0.117506293914473555420279832210420483L, 0.346552747708338676483025352060418001L);
+  TEST_cc_c (cpow, 0.75L, 1.25L, 1.0L, 1.0L, 0.0846958290317209430433805274189191353L, 0.513285749182902449043287190519090481L);
+  TEST_cc_c (cpow, 0.75L, 1.25L, 1.0L, 0.0L, 0.75L, 1.25L);
+  TEST_cc_c (cpow, 0.75L, 1.25L, 0.0L, 1.0L, 0.331825439177608832276067945276730566L, 0.131338600281188544930936345230903032L);
+
+  END (cpow, complex);
+}
+
+
+static void
+cproj_test (void)
+{
+  START (cproj);
+  TEST_c_c (cproj, 0.0, 0.0, 0.0, 0.0);
+  TEST_c_c (cproj, minus_zero, minus_zero, minus_zero, minus_zero);
+  TEST_c_c (cproj, 0.0, minus_zero, 0.0, minus_zero);
+  TEST_c_c (cproj, minus_zero, 0.0, minus_zero, 0.0);
+
+  TEST_c_c (cproj, nan_value, nan_value, nan_value, nan_value);
+
+  TEST_c_c (cproj, plus_infty, plus_infty, plus_infty, 0.0);
+  TEST_c_c (cproj, plus_infty, minus_infty, plus_infty, minus_zero);
+  TEST_c_c (cproj, minus_infty, plus_infty, plus_infty, 0.0);
+  TEST_c_c (cproj, minus_infty, minus_infty, plus_infty, minus_zero);
+
+  TEST_c_c (cproj, 1.0, 0.0, 1.0, 0.0);
+  TEST_c_c (cproj, 2.0, 3.0, 0.2857142857142857142857142857142857L, 0.42857142857142857142857142857142855L);
+
+  END (cproj, complex);
+}
+
+
+static void
+creal_test (void)
+{
+  START (creal);
+  TEST_c_f (creal, 0.0, 1.0, 0.0);
+  TEST_c_f (creal, minus_zero, 1.0, minus_zero);
+  TEST_c_f (creal, nan_value, 1.0, nan_value);
+  TEST_c_f (creal, nan_value, nan_value, nan_value);
+  TEST_c_f (creal, plus_infty, 1.0, plus_infty);
+  TEST_c_f (creal, minus_infty, 1.0, minus_infty);
+  TEST_c_f (creal, 2.0, 3.0, 2.0);
+
+  END (creal);
+}
+
+static void
+csin_test (void)
+{
+  errno = 0;
+  FUNC(csin) (BUILD_COMPLEX (0.7L, 1.2L));
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (csin);
+
+  TEST_c_c (csin, 0.0, 0.0, 0.0, 0.0);
+  TEST_c_c (csin, minus_zero, 0.0, minus_zero, 0.0);
+  TEST_c_c (csin, 0.0, minus_zero, 0, minus_zero);
+  TEST_c_c (csin, minus_zero, minus_zero, minus_zero, minus_zero);
+
+  TEST_c_c (csin, 0.0, plus_infty, 0.0, plus_infty);
+  TEST_c_c (csin, minus_zero, plus_infty, minus_zero, plus_infty);
+  TEST_c_c (csin, 0.0, minus_infty, 0.0, minus_infty);
+  TEST_c_c (csin, minus_zero, minus_infty, minus_zero, minus_infty);
+
+  TEST_c_c (csin, plus_infty, 0.0, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (csin, minus_infty, 0.0, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (csin, plus_infty, minus_zero, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (csin, minus_infty, minus_zero, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+
+  TEST_c_c (csin, plus_infty, plus_infty, nan_value, plus_infty, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (csin, minus_infty, plus_infty, nan_value, plus_infty, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (csin, plus_infty, minus_infty, nan_value, plus_infty, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (csin, minus_infty, minus_infty, nan_value, plus_infty, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+
+  TEST_c_c (csin, plus_infty, 6.75, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (csin, plus_infty, -6.75, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (csin, minus_infty, 6.75, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (csin, minus_infty, -6.75,  nan_value, nan_value, INVALID_EXCEPTION);
+
+  TEST_c_c (csin, 4.625, plus_infty, minus_infty, minus_infty);
+  TEST_c_c (csin, 4.625, minus_infty, minus_infty, plus_infty);
+  TEST_c_c (csin, -4.625, plus_infty, plus_infty, minus_infty);
+  TEST_c_c (csin, -4.625, minus_infty, plus_infty, plus_infty);
+
+  TEST_c_c (csin, nan_value, 0.0, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (csin, nan_value, minus_zero, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
+
+  TEST_c_c (csin, nan_value, plus_infty, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (csin, nan_value, minus_infty, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
+
+  TEST_c_c (csin, nan_value, 9.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (csin, nan_value, -9.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (csin, 0.0, nan_value, 0.0, nan_value);
+  TEST_c_c (csin, minus_zero, nan_value, minus_zero, nan_value);
+
+  TEST_c_c (csin, 10.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (csin, nan_value, -10.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (csin, plus_infty, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (csin, minus_infty, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (csin, nan_value, nan_value, nan_value, nan_value);
+
+  TEST_c_c (csin, 0.75L, 1.25L, 1.28722291002649188575873510790565441L, 1.17210635989270256101081285116138863L);
+  TEST_c_c (csin, -2, -3, -9.15449914691142957346729954460983256L, 4.16890695996656435075481305885375484L);
+
+  END (csin, complex);
+}
+
+
+static void
+csinh_test (void)
+{
+  errno = 0;
+  FUNC(csinh) (BUILD_COMPLEX (0.7L, 1.2L));
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (csinh);
+
+  TEST_c_c (csinh, 0.0, 0.0, 0.0, 0.0);
+  TEST_c_c (csinh, minus_zero, 0.0, minus_zero, 0.0);
+  TEST_c_c (csinh, 0.0, minus_zero, 0.0, minus_zero);
+  TEST_c_c (csinh, minus_zero, minus_zero, minus_zero, minus_zero);
+
+  TEST_c_c (csinh, 0.0, plus_infty, 0.0, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (csinh, minus_zero, plus_infty, 0.0, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (csinh, 0.0, minus_infty, 0.0, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (csinh, minus_zero, minus_infty, 0.0, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+
+  TEST_c_c (csinh, plus_infty, 0.0, plus_infty, 0.0);
+  TEST_c_c (csinh, minus_infty, 0.0, minus_infty, 0.0);
+  TEST_c_c (csinh, plus_infty, minus_zero, plus_infty, minus_zero);
+  TEST_c_c (csinh, minus_infty, minus_zero, minus_infty, minus_zero);
+
+  TEST_c_c (csinh, plus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (csinh, minus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (csinh, plus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (csinh, minus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+
+  TEST_c_c (csinh, plus_infty, 4.625, minus_infty, minus_infty);
+  TEST_c_c (csinh, minus_infty, 4.625, plus_infty, minus_infty);
+  TEST_c_c (csinh, plus_infty, -4.625, minus_infty, plus_infty);
+  TEST_c_c (csinh, minus_infty, -4.625, plus_infty, plus_infty);
+
+  TEST_c_c (csinh, 6.75, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (csinh, -6.75, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (csinh, 6.75, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (csinh, -6.75, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+
+  TEST_c_c (csinh, 0.0, nan_value, 0.0, nan_value, IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (csinh, minus_zero, nan_value, 0.0, nan_value, IGNORE_ZERO_INF_SIGN);
+
+  TEST_c_c (csinh, plus_infty, nan_value, plus_infty, nan_value, IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (csinh, minus_infty, nan_value, plus_infty, nan_value, IGNORE_ZERO_INF_SIGN);
+
+  TEST_c_c (csinh, 9.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (csinh, -9.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (csinh, nan_value, 0.0, nan_value, 0.0);
+  TEST_c_c (csinh, nan_value, minus_zero, nan_value, minus_zero);
+
+  TEST_c_c (csinh, nan_value, 10.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (csinh, nan_value, -10.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (csinh, nan_value, plus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (csinh, nan_value, minus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (csinh, nan_value, nan_value, nan_value, nan_value);
+
+  TEST_c_c (csinh, 0.75L, 1.25L, 0.259294854551162779153349830618433028L, 1.22863452409509552219214606515777594L);
+  TEST_c_c (csinh, -2, -3, 3.59056458998577995201256544779481679L, -0.530921086248519805267040090660676560L);
+
+  END (csinh, complex);
+}
+
+
+static void
+csqrt_test (void)
+{
+  errno = 0;
+  FUNC(csqrt) (BUILD_COMPLEX (-1, 0));
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (csqrt);
+
+  TEST_c_c (csqrt, 0, 0, 0.0, 0.0);
+  TEST_c_c (csqrt, 0, minus_zero, 0, minus_zero);
+  TEST_c_c (csqrt, minus_zero, 0, 0.0, 0.0);
+  TEST_c_c (csqrt, minus_zero, minus_zero, 0.0, minus_zero);
+
+  TEST_c_c (csqrt, minus_infty, 0, 0.0, plus_infty);
+  TEST_c_c (csqrt, minus_infty, 6, 0.0, plus_infty);
+  TEST_c_c (csqrt, minus_infty, minus_zero, 0.0, minus_infty);
+  TEST_c_c (csqrt, minus_infty, -6, 0.0, minus_infty);
+
+  TEST_c_c (csqrt, plus_infty, 0, plus_infty, 0.0);
+  TEST_c_c (csqrt, plus_infty, 6, plus_infty, 0.0);
+  TEST_c_c (csqrt, plus_infty, minus_zero, plus_infty, minus_zero);
+  TEST_c_c (csqrt, plus_infty, -6, plus_infty, minus_zero);
+
+  TEST_c_c (csqrt, 0, plus_infty, plus_infty, plus_infty);
+  TEST_c_c (csqrt, 4, plus_infty, plus_infty, plus_infty);
+  TEST_c_c (csqrt, plus_infty, plus_infty, plus_infty, plus_infty);
+  TEST_c_c (csqrt, minus_zero, plus_infty, plus_infty, plus_infty);
+  TEST_c_c (csqrt, -4, plus_infty, plus_infty, plus_infty);
+  TEST_c_c (csqrt, minus_infty, plus_infty, plus_infty, plus_infty);
+  TEST_c_c (csqrt, 0, minus_infty, plus_infty, minus_infty);
+  TEST_c_c (csqrt, 4, minus_infty, plus_infty, minus_infty);
+  TEST_c_c (csqrt, plus_infty, minus_infty, plus_infty, minus_infty);
+  TEST_c_c (csqrt, minus_zero, minus_infty, plus_infty, minus_infty);
+  TEST_c_c (csqrt, -4, minus_infty, plus_infty, minus_infty);
+  TEST_c_c (csqrt, minus_infty, minus_infty, plus_infty, minus_infty);
+
+  TEST_c_c (csqrt, minus_infty, nan_value, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
+
+  TEST_c_c (csqrt, plus_infty, nan_value, plus_infty, nan_value);
+
+  TEST_c_c (csqrt, 0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (csqrt, 1, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (csqrt, minus_zero, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (csqrt, -1, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (csqrt, nan_value, 0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (csqrt, nan_value, 8, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (csqrt, nan_value, minus_zero, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (csqrt, nan_value, -8, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (csqrt, nan_value, nan_value, nan_value, nan_value);
+
+  TEST_c_c (csqrt, 16.0, -30.0, 5.0, -3.0);
+  TEST_c_c (csqrt, -1, 0, 0.0, 1.0);
+  TEST_c_c (csqrt, 0, 2, 1.0, 1.0);
+  TEST_c_c (csqrt, 119, 120, 12.0, 5.0);
+  TEST_c_c (csqrt, 0.75L, 1.25L, 1.05065169626078392338656675760808326L, 0.594868882070379067881984030639932657L);
+  TEST_c_c (csqrt, -2, -3, 0.89597747612983812471573375529004348L, -1.6741492280355400404480393008490519L);
+  TEST_c_c (csqrt, -2, 3, 0.89597747612983812471573375529004348L, 1.6741492280355400404480393008490519L);
+
+  END (csqrt, complex);
+}
+
+static void
+ctan_test (void)
+{
+  errno = 0;
+  FUNC(ctan) (BUILD_COMPLEX (0.7L, 1.2L));
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (ctan);
+
+  TEST_c_c (ctan, 0, 0, 0.0, 0.0);
+  TEST_c_c (ctan, 0, minus_zero, 0.0, minus_zero);
+  TEST_c_c (ctan, minus_zero, 0, minus_zero, 0.0);
+  TEST_c_c (ctan, minus_zero, minus_zero, minus_zero, minus_zero);
+
+  TEST_c_c (ctan, 0, plus_infty, 0.0, 1.0);
+  TEST_c_c (ctan, 1, plus_infty, 0.0, 1.0);
+  TEST_c_c (ctan, minus_zero, plus_infty, minus_zero, 1.0);
+  TEST_c_c (ctan, -1, plus_infty, minus_zero, 1.0);
+
+  TEST_c_c (ctan, 0, minus_infty, 0.0, -1.0);
+  TEST_c_c (ctan, 1, minus_infty, 0.0, -1.0);
+  TEST_c_c (ctan, minus_zero, minus_infty, minus_zero, -1.0);
+  TEST_c_c (ctan, -1, minus_infty, minus_zero, -1.0);
+
+  TEST_c_c (ctan, plus_infty, 0, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ctan, plus_infty, 2, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ctan, minus_infty, 0, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ctan, minus_infty, 2, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ctan, plus_infty, minus_zero, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ctan, plus_infty, -2, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ctan, minus_infty, minus_zero, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ctan, minus_infty, -2, nan_value, nan_value, INVALID_EXCEPTION);
+
+  TEST_c_c (ctan, nan_value, plus_infty, 0.0, 1.0, IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (ctan, nan_value, minus_infty, 0.0, -1.0, IGNORE_ZERO_INF_SIGN);
+
+  TEST_c_c (ctan, 0, nan_value, 0.0, nan_value);
+  TEST_c_c (ctan, minus_zero, nan_value, minus_zero, nan_value);
+
+  TEST_c_c (ctan, 0.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (ctan, -4.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (ctan, nan_value, 0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (ctan, nan_value, 5, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (ctan, nan_value, minus_zero, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (ctan, nan_value, -0.25, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (ctan, nan_value, nan_value, nan_value, nan_value);
+
+  TEST_c_c (ctan, 0.75L, 1.25L, 0.160807785916206426725166058173438663L, 0.975363285031235646193581759755216379L);
+  TEST_c_c (ctan, -2, -3, 0.376402564150424829275122113032269084e-2L, -1.00323862735360980144635859782192726L);
+
+  END (ctan, complex);
+}
+
+
+static void
+ctanh_test (void)
+{
+  errno = 0;
+  FUNC(ctanh) (BUILD_COMPLEX (0, 0));
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (ctanh);
+
+  TEST_c_c (ctanh, 0, 0, 0.0, 0.0);
+  TEST_c_c (ctanh, 0, minus_zero, 0.0, minus_zero);
+  TEST_c_c (ctanh, minus_zero, 0, minus_zero, 0.0);
+  TEST_c_c (ctanh, minus_zero, minus_zero, minus_zero, minus_zero);
+
+  TEST_c_c (ctanh, plus_infty, 0, 1.0, 0.0);
+  TEST_c_c (ctanh, plus_infty, 1, 1.0, 0.0);
+  TEST_c_c (ctanh, plus_infty, minus_zero, 1.0, minus_zero);
+  TEST_c_c (ctanh, plus_infty, -1, 1.0, minus_zero);
+  TEST_c_c (ctanh, minus_infty, 0, -1.0, 0.0);
+  TEST_c_c (ctanh, minus_infty, 1, -1.0, 0.0);
+  TEST_c_c (ctanh, minus_infty, minus_zero, -1.0, minus_zero);
+  TEST_c_c (ctanh, minus_infty, -1, -1.0, minus_zero);
+
+  TEST_c_c (ctanh, 0, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ctanh, 2, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ctanh, 0, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ctanh, 2, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ctanh, minus_zero, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ctanh, -2, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ctanh, minus_zero, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_c_c (ctanh, -2, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+
+  TEST_c_c (ctanh, plus_infty, nan_value, 1.0, 0.0, IGNORE_ZERO_INF_SIGN);
+  TEST_c_c (ctanh, minus_infty, nan_value, -1.0, 0.0, IGNORE_ZERO_INF_SIGN);
+
+  TEST_c_c (ctanh, nan_value, 0, nan_value, 0.0);
+  TEST_c_c (ctanh, nan_value, minus_zero, nan_value, minus_zero);
+
+  TEST_c_c (ctanh, nan_value, 0.5, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (ctanh, nan_value, -4.5, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (ctanh, 0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (ctanh, 5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (ctanh, minus_zero, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_c_c (ctanh, -0.25, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+  TEST_c_c (ctanh, nan_value, nan_value, nan_value, nan_value);
+
+  TEST_c_c (ctanh, 0, M_PI_4l, 0.0, 1.0);
+
+  TEST_c_c (ctanh, 0.75L, 1.25L, 1.37260757053378320258048606571226857L, 0.385795952609750664177596760720790220L);
+  TEST_c_c (ctanh, -2, -3, -0.965385879022133124278480269394560686L, 0.988437503832249372031403430350121098e-2L);
+
+  END (ctanh, complex);
+}
+
+
+static void
+erf_test (void)
+{
+  errno = 0;
+  FUNC(erf) (0);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (erf);
+
+  TEST_f_f (erf, 0, 0);
+  TEST_f_f (erf, minus_zero, minus_zero);
+  TEST_f_f (erf, plus_infty, 1);
+  TEST_f_f (erf, minus_infty, -1);
+  TEST_f_f (erf, nan_value, nan_value);
+
+  TEST_f_f (erf, 0.125L, 0.140316204801333817393029446521623398L);
+  TEST_f_f (erf, 0.75L, 0.711155633653515131598937834591410777L);
+  TEST_f_f (erf, 1.25L, 0.922900128256458230136523481197281140L);
+  TEST_f_f (erf, 2.0L, 0.995322265018952734162069256367252929L);
+  TEST_f_f (erf, 4.125L, 0.999999994576599200434933994687765914L);
+  TEST_f_f (erf, 27.0L, 1.0L);
+
+  END (erf);
+}
+
+
+static void
+erfc_test (void)
+{
+  errno = 0;
+  FUNC(erfc) (0);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (erfc);
+
+  TEST_f_f (erfc, plus_infty, 0.0);
+  TEST_f_f (erfc, minus_infty, 2.0);
+  TEST_f_f (erfc, 0.0, 1.0);
+  TEST_f_f (erfc, minus_zero, 1.0);
+  TEST_f_f (erfc, nan_value, nan_value);
+
+  TEST_f_f (erfc, 0.125L, 0.859683795198666182606970553478376602L);
+  TEST_f_f (erfc, 0.75L, 0.288844366346484868401062165408589223L);
+  TEST_f_f (erfc, 1.25L, 0.0770998717435417698634765188027188596L);
+  TEST_f_f (erfc, 2.0L, 0.00467773498104726583793074363274707139L);
+  TEST_f_f (erfc, 4.125L, 0.542340079956506600531223408575531062e-8L);
+#ifdef TEST_LDOUBLE
+  /* The result can only be represented in long double.  */
+  TEST_f_f (erfc, 27.0L, 0.523704892378925568501606768284954709e-318L);
+#endif
+
+  END (erfc);
+}
+
+
+static void
+exp_test (void)
+{
+  errno = 0;
+  FUNC(exp) (0);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (exp);
+
+  TEST_f_f (exp, 0, 1);
+  TEST_f_f (exp, minus_zero, 1);
+
+#ifndef TEST_INLINE
+  TEST_f_f (exp, plus_infty, plus_infty);
+  TEST_f_f (exp, minus_infty, 0);
+#endif
+  TEST_f_f (exp, nan_value, nan_value);
+  TEST_f_f (exp, 1, M_El);
+
+  TEST_f_f (exp, 2, M_E2l);
+  TEST_f_f (exp, 3, M_E3l);
+  TEST_f_f (exp, 0.75L, 2.11700001661267466854536981983709561L);
+  TEST_f_f (exp, 50.0L, 5184705528587072464087.45332293348538L);
+#ifdef TEST_LDOUBLE
+  /* The result can only be represented in long double.  */
+  TEST_f_f (exp, 1000.0L, 0.197007111401704699388887935224332313e435L);
+#endif
+
+  END (exp);
+}
+
+
+static void
+exp10_test (void)
+{
+  errno = 0;
+  FUNC(exp10) (0);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (exp10);
+
+  TEST_f_f (exp10, 0, 1);
+  TEST_f_f (exp10, minus_zero, 1);
+
+  TEST_f_f (exp10, plus_infty, plus_infty);
+  TEST_f_f (exp10, minus_infty, 0);
+  TEST_f_f (exp10, nan_value, nan_value);
+  TEST_f_f (exp10, 3, 1000);
+  TEST_f_f (exp10, -1, 0.1L);
+  TEST_f_f (exp10, 1e6, plus_infty);
+  TEST_f_f (exp10, -1e6, 0);
+  TEST_f_f (exp10, 0.75L, 5.62341325190349080394951039776481231L);
+
+  END (exp10);
+}
+
+
+static void
+exp2_test (void)
+{
+  errno = 0;
+  FUNC(exp2) (0);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (exp2);
+
+  TEST_f_f (exp2, 0, 1);
+  TEST_f_f (exp2, minus_zero, 1);
+  TEST_f_f (exp2, plus_infty, plus_infty);
+  TEST_f_f (exp2, minus_infty, 0);
+  TEST_f_f (exp2, nan_value, nan_value);
+
+  TEST_f_f (exp2, 10, 1024);
+  TEST_f_f (exp2, -1, 0.5);
+  TEST_f_f (exp2, 1e6, plus_infty);
+  TEST_f_f (exp2, -1e6, 0);
+  TEST_f_f (exp2, 0.75L, 1.68179283050742908606225095246642979L);
+
+  END (exp2);
+}
+
+
+static void
+expm1_test (void)
+{
+  errno = 0;
+  FUNC(expm1) (0);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (expm1);
+
+  TEST_f_f (expm1, 0, 0);
+  TEST_f_f (expm1, minus_zero, minus_zero);
+
+#ifndef TEST_INLINE
+  TEST_f_f (expm1, plus_infty, plus_infty);
+  TEST_f_f (expm1, minus_infty, -1);
+#endif
+  TEST_f_f (expm1, nan_value, nan_value);
+
+  TEST_f_f (expm1, 1, M_El - 1.0);
+  TEST_f_f (expm1, 0.75L, 1.11700001661267466854536981983709561L);
+
+  END (expm1);
+}
+
+
+static void
+fabs_test (void)
+{
+  START (fabs);
+
+  TEST_f_f (fabs, 0, 0);
+  TEST_f_f (fabs, minus_zero, 0);
+
+  TEST_f_f (fabs, plus_infty, plus_infty);
+  TEST_f_f (fabs, minus_infty, plus_infty);
+  TEST_f_f (fabs, nan_value, nan_value);
+
+  TEST_f_f (fabs, 38.0, 38.0);
+  TEST_f_f (fabs, -M_El, M_El);
+
+  END (fabs);
+}
+
+
+static void
+fdim_test (void)
+{
+  START (fdim);
+
+  TEST_ff_f (fdim, 0, 0, 0);
+  TEST_ff_f (fdim, 9, 0, 9);
+  TEST_ff_f (fdim, 0, 9, 0);
+  TEST_ff_f (fdim, -9, 0, 0);
+  TEST_ff_f (fdim, 0, -9, 9);
+
+  TEST_ff_f (fdim, plus_infty, 9, plus_infty);
+  TEST_ff_f (fdim, plus_infty, -9, plus_infty);
+  TEST_ff_f (fdim, minus_infty, 9, 0);
+  TEST_ff_f (fdim, minus_infty, -9, 0);
+  TEST_ff_f (fdim, 9, minus_infty, plus_infty);
+  TEST_ff_f (fdim, -9, minus_infty, plus_infty);
+  TEST_ff_f (fdim, 9, plus_infty, 0);
+  TEST_ff_f (fdim, -9, plus_infty, 0);
+
+  TEST_ff_f (fdim, 0, nan_value, nan_value);
+  TEST_ff_f (fdim, 9, nan_value, nan_value);
+  TEST_ff_f (fdim, -9, nan_value, nan_value);
+  TEST_ff_f (fdim, nan_value, 9, nan_value);
+  TEST_ff_f (fdim, nan_value, -9, nan_value);
+  TEST_ff_f (fdim, plus_infty, nan_value, nan_value);
+  TEST_ff_f (fdim, minus_infty, nan_value, nan_value);
+  TEST_ff_f (fdim, nan_value, plus_infty, nan_value);
+  TEST_ff_f (fdim, nan_value, minus_infty, nan_value);
+  TEST_ff_f (fdim, nan_value, nan_value, nan_value);
+
+  TEST_ff_f (fdim, plus_infty, plus_infty, 0);
+
+  END (fdim);
+}
+
+
+static void
+floor_test (void)
+{
+  START (floor);
+
+  TEST_f_f (floor, 0.0, 0.0);
+  TEST_f_f (floor, minus_zero, minus_zero);
+  TEST_f_f (floor, plus_infty, plus_infty);
+  TEST_f_f (floor, minus_infty, minus_infty);
+  TEST_f_f (floor, nan_value, nan_value);
+
+  TEST_f_f (floor, M_PIl, 3.0);
+  TEST_f_f (floor, -M_PIl, -4.0);
+
+  TEST_f_f (floor, 0.25, 0.0);
+  TEST_f_f (floor, -0.25, -1.0);
+
+  END (floor);
+}
+
+
+static void
+fma_test (void)
+{
+  START (fma);
+
+  TEST_fff_f (fma, 1.0, 2.0, 3.0, 5.0);
+  TEST_fff_f (fma, nan_value, 2.0, 3.0, nan_value);
+  TEST_fff_f (fma, 1.0, nan_value, 3.0, nan_value);
+  TEST_fff_f (fma, 1.0, 2.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_fff_f (fma, plus_infty, 0.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_fff_f (fma, minus_infty, 0.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_fff_f (fma, 0.0, plus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_fff_f (fma, 0.0, minus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
+  TEST_fff_f (fma, plus_infty, 0.0, 1.0, nan_value, INVALID_EXCEPTION);
+  TEST_fff_f (fma, minus_infty, 0.0, 1.0, nan_value, INVALID_EXCEPTION);
+  TEST_fff_f (fma, 0.0, plus_infty, 1.0, nan_value, INVALID_EXCEPTION);
+  TEST_fff_f (fma, 0.0, minus_infty, 1.0, nan_value, INVALID_EXCEPTION);
+
+  TEST_fff_f (fma, plus_infty, plus_infty, minus_infty, nan_value, INVALID_EXCEPTION);
+  TEST_fff_f (fma, minus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
+  TEST_fff_f (fma, plus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
+  TEST_fff_f (fma, minus_infty, minus_infty, minus_infty, nan_value, INVALID_EXCEPTION);
+
+  TEST_fff_f (fma, 1.25L, 0.75L, 0.0625L, 1.0L);
+
+  END (fma);
+}
+
+
+static void
+fmax_test (void)
+{
+  START (fmax);
+
+  TEST_ff_f (fmax, 0, 0, 0);
+  TEST_ff_f (fmax, minus_zero, minus_zero, minus_zero);
+  TEST_ff_f (fmax, 9, 0, 9);
+  TEST_ff_f (fmax, 0, 9, 9);
+  TEST_ff_f (fmax, -9, 0, 0);
+  TEST_ff_f (fmax, 0, -9, 0);
+
+  TEST_ff_f (fmax, plus_infty, 9, plus_infty);
+  TEST_ff_f (fmax, 0, plus_infty, plus_infty);
+  TEST_ff_f (fmax, -9, plus_infty, plus_infty);
+  TEST_ff_f (fmax, plus_infty, -9, plus_infty);
+
+  TEST_ff_f (fmax, minus_infty, 9, 9);
+  TEST_ff_f (fmax, minus_infty, -9, -9);
+  TEST_ff_f (fmax, 9, minus_infty, 9);
+  TEST_ff_f (fmax, -9, minus_infty, -9);
+
+  TEST_ff_f (fmax, 0, nan_value, 0);
+  TEST_ff_f (fmax, 9, nan_value, 9);
+  TEST_ff_f (fmax, -9, nan_value, -9);
+  TEST_ff_f (fmax, nan_value, 0, 0);
+  TEST_ff_f (fmax, nan_value, 9, 9);
+  TEST_ff_f (fmax, nan_value, -9, -9);
+  TEST_ff_f (fmax, plus_infty, nan_value, plus_infty);
+  TEST_ff_f (fmax, minus_infty, nan_value, minus_infty);
+  TEST_ff_f (fmax, nan_value, plus_infty, plus_infty);
+  TEST_ff_f (fmax, nan_value, minus_infty, minus_infty);
+  TEST_ff_f (fmax, nan_value, nan_value, nan_value);
+
+  END (fmax);
+}
+
+
+static void
+fmin_test (void)
+{
+  START (fmin);
+
+  TEST_ff_f (fmin, 0, 0, 0);
+  TEST_ff_f (fmin, minus_zero, minus_zero, minus_zero);
+  TEST_ff_f (fmin, 9, 0, 0);
+  TEST_ff_f (fmin, 0, 9, 0);
+  TEST_ff_f (fmin, -9, 0, -9);
+  TEST_ff_f (fmin, 0, -9, -9);
+
+  TEST_ff_f (fmin, plus_infty, 9, 9);
+  TEST_ff_f (fmin, 9, plus_infty, 9);
+  TEST_ff_f (fmin, plus_infty, -9, -9);
+  TEST_ff_f (fmin, -9, plus_infty, -9);
+  TEST_ff_f (fmin, minus_infty, 9, minus_infty);
+  TEST_ff_f (fmin, minus_infty, -9, minus_infty);
+  TEST_ff_f (fmin, 9, minus_infty, minus_infty);
+  TEST_ff_f (fmin, -9, minus_infty, minus_infty);
+
+  TEST_ff_f (fmin, 0, nan_value, 0);
+  TEST_ff_f (fmin, 9, nan_value, 9);
+  TEST_ff_f (fmin, -9, nan_value, -9);
+  TEST_ff_f (fmin, nan_value, 0, 0);
+  TEST_ff_f (fmin, nan_value, 9, 9);
+  TEST_ff_f (fmin, nan_value, -9, -9);
+  TEST_ff_f (fmin, plus_infty, nan_value, plus_infty);
+  TEST_ff_f (fmin, minus_infty, nan_value, minus_infty);
+  TEST_ff_f (fmin, nan_value, plus_infty, plus_infty);
+  TEST_ff_f (fmin, nan_value, minus_infty, minus_infty);
+  TEST_ff_f (fmin, nan_value, nan_value, nan_value);
+
+  END (fmin);
+}
+
+
+static void
+fmod_test (void)
+{
+  errno = 0;
+  FUNC(fmod) (6.5, 2.3L);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (fmod);
+
+  /* fmod (+0, y) == +0 for y != 0.  */
+  TEST_ff_f (fmod, 0, 3, 0);
+
+  /* fmod (-0, y) == -0 for y != 0.  */
+  TEST_ff_f (fmod, minus_zero, 3, minus_zero);
+
+  /* fmod (+inf, y) == NaN plus invalid exception.  */
+  TEST_ff_f (fmod, plus_infty, 3, nan_value, INVALID_EXCEPTION);
+  /* fmod (-inf, y) == NaN plus invalid exception.  */
+  TEST_ff_f (fmod, minus_infty, 3, nan_value, INVALID_EXCEPTION);
+  /* fmod (x, +0) == NaN plus invalid exception.  */
+  TEST_ff_f (fmod, 3, 0, nan_value, INVALID_EXCEPTION);
+  /* fmod (x, -0) == NaN plus invalid exception.  */
+  TEST_ff_f (fmod, 3, minus_zero, nan_value, INVALID_EXCEPTION);
+
+  /* fmod (x, +inf) == x for x not infinite.  */
+  TEST_ff_f (fmod, 3.0, plus_infty, 3.0);
+  /* fmod (x, -inf) == x for x not infinite.  */
+  TEST_ff_f (fmod, 3.0, minus_infty, 3.0);
+
+  TEST_ff_f (fmod, nan_value, nan_value, nan_value);
+
+  TEST_ff_f (fmod, 6.5, 2.25L, 2.0L);
+  TEST_ff_f (fmod, -6.5, 2.25L, -2.0L);
+  TEST_ff_f (fmod, 6.5, -2.25L, 2.0L);
+  TEST_ff_f (fmod, -6.5, -2.25L, -2.0L);
+
+  END (fmod);
+}
+
+
+static void
+fpclassify_test (void)
+{
+  START (fpclassify);
+
+  TEST_f_i (fpclassify, nan_value, FP_NAN);
+  TEST_f_i (fpclassify, plus_infty, FP_INFINITE);
+  TEST_f_i (fpclassify, minus_infty, FP_INFINITE);
+  TEST_f_i (fpclassify, plus_zero, FP_ZERO);
+  TEST_f_i (fpclassify, minus_zero, FP_ZERO);
+  TEST_f_i (fpclassify, 1000, FP_NORMAL);
+
+  END (fpclassify);
+}
+
+
+static void
+frexp_test (void)
+{
+  int x;
+
+  START (frexp);
+
+  TEST_fI_f1 (frexp, plus_infty, plus_infty, IGNORE);
+  TEST_fI_f1 (frexp, minus_infty, minus_infty, IGNORE);
+  TEST_fI_f1 (frexp, nan_value, nan_value, IGNORE);
+
+  TEST_fI_f1 (frexp, 0.0, 0.0, 0.0);
+  TEST_fI_f1 (frexp, minus_zero, minus_zero, 0.0);
+
+  TEST_fI_f1 (frexp, 12.8L, 0.8L, 4);
+  TEST_fI_f1 (frexp, -27.34L, -0.854375L, 5);
+
+  END (frexp);
+}
+
+
+static void
+gamma_test (void)
+{
+  errno = 0;
+  FUNC(gamma) (1);
+
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+  feclearexcept (FE_ALL_EXCEPT);
+
+  START (gamma);
+
+  TEST_f_f (gamma, plus_infty, plus_infty);
+  TEST_f_f (gamma, 0, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+  TEST_f_f (gamma, -3, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+  TEST_f_f (gamma, minus_infty, plus_infty);
+  TEST_f_f (gamma, nan_value, nan_value);
+
+  TEST_f_f1 (gamma, 1, 0, 1);
+  TEST_f_f1 (gamma, 3, M_LN2l, 1);
+
+  TEST_f_f1 (gamma, 0.5, M_LOG_SQRT_PIl, 1);
+  TEST_f_f1 (gamma, -0.5, M_LOG_2_SQRT_PIl, -1);
+
+  END (gamma);
+}
+
+static void
+hypot_test (void)
+{
+  errno = 0;
+  FUNC(hypot) (0.7L, 12.4L);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (hypot);
+
+  TEST_ff_f (hypot, plus_infty, 1, plus_infty, IGNORE_ZERO_INF_SIGN);
+  TEST_ff_f (hypot, minus_infty, 1, plus_infty, IGNORE_ZERO_INF_SIGN);
+
+#ifndef TEST_INLINE
+  TEST_ff_f (hypot, plus_infty, nan_value, plus_infty);
+  TEST_ff_f (hypot, minus_infty, nan_value, plus_infty);
+  TEST_ff_f (hypot, nan_value, plus_infty, plus_infty);
+  TEST_ff_f (hypot, nan_value, minus_infty, plus_infty);
+#endif
+
+  TEST_ff_f (hypot, nan_value, nan_value, nan_value);
+
+  /* hypot (x,y) == hypot (+-x, +-y)  */
+  TEST_ff_f (hypot, 0.7L, 12.4L, 12.419742348374220601176836866763271L);
+  TEST_ff_f (hypot, -0.7L, 12.4L, 12.419742348374220601176836866763271L);
+  TEST_ff_f (hypot, 0.7L, -12.4L, 12.419742348374220601176836866763271L);
+  TEST_ff_f (hypot, -0.7L, -12.4L, 12.419742348374220601176836866763271L);
+  TEST_ff_f (hypot, 12.4L, 0.7L, 12.419742348374220601176836866763271L);
+  TEST_ff_f (hypot, -12.4L, 0.7L, 12.419742348374220601176836866763271L);
+  TEST_ff_f (hypot, 12.4L, -0.7L, 12.419742348374220601176836866763271L);
+  TEST_ff_f (hypot, -12.4L, -0.7L, 12.419742348374220601176836866763271L);
+
+  /*  hypot (x,0) == fabs (x)  */
+  TEST_ff_f (hypot, 0.75L, 0, 0.75L);
+  TEST_ff_f (hypot, -0.75L, 0, 0.75L);
+  TEST_ff_f (hypot, -5.7e7, 0, 5.7e7L);
+
+  TEST_ff_f (hypot, 0.75L, 1.25L, 1.45773797371132511771853821938639577L);
+
+  END (hypot);
+}
+
+
+static void
+ilogb_test (void)
+{
+  START (ilogb);
+
+  TEST_f_i (ilogb, 1, 0);
+  TEST_f_i (ilogb, M_El, 1);
+  TEST_f_i (ilogb, 1024, 10);
+  TEST_f_i (ilogb, -2000, 10);
+
+  /* XXX We have a problem here: the standard does not tell us whether
+     exceptions are allowed/required.  ignore them for now.  */
+
+  TEST_f_i (ilogb, 0.0, FP_ILOGB0, EXCEPTIONS_OK);
+  TEST_f_i (ilogb, nan_value, FP_ILOGBNAN, EXCEPTIONS_OK);
+  TEST_f_i (ilogb, plus_infty, INT_MAX, EXCEPTIONS_OK);
+  TEST_f_i (ilogb, minus_infty, INT_MAX, EXCEPTIONS_OK);
+
+  END (ilogb);
+}
+
+static void
+isfinite_test (void)
+{
+  START (isfinite);
+
+  TEST_f_b (isfinite, 0, 1);
+  TEST_f_b (isfinite, minus_zero, 1);
+  TEST_f_b (isfinite, 10, 1);
+  TEST_f_b (isfinite, plus_infty, 0);
+  TEST_f_b (isfinite, minus_infty, 0);
+  TEST_f_b (isfinite, nan_value, 0);
+
+  END (isfinite);
+}
+
+static void
+isnormal_test (void)
+{
+  START (isnormal);
+
+  TEST_f_b (isnormal, 0, 0);
+  TEST_f_b (isnormal, minus_zero, 0);
+  TEST_f_b (isnormal, 10, 1);
+  TEST_f_b (isnormal, plus_infty, 0);
+  TEST_f_b (isnormal, minus_infty, 0);
+  TEST_f_b (isnormal, nan_value, 0);
+
+  END (isnormal);
+}
+
+static void
+j0_test (void)
+{
+  FLOAT s, c;
+  errno = 0;
+  FUNC (sincos) (0, &s, &c);
+  if (errno == ENOSYS)
+    /* Required function not implemented.  */
+    return;
+  FUNC(j0) (0);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (j0);
+
+  /* j0 is the Bessel function of the first kind of order 0 */
+  TEST_f_f (j0, nan_value, nan_value);
+  TEST_f_f (j0, plus_infty, 0);
+  TEST_f_f (j0, -1.0, 0.765197686557966551449717526102663221L);
+  TEST_f_f (j0, 0.0, 1.0);
+  TEST_f_f (j0, 0.125L, 0.996097563041985204620768999453174712L);
+  TEST_f_f (j0, 0.75L, 0.864242275166648623555731103820923211L);
+  TEST_f_f (j0, 1.0, 0.765197686557966551449717526102663221L);
+  TEST_f_f (j0, 1.5, 0.511827671735918128749051744283411720L);
+  TEST_f_f (j0, 2.0, 0.223890779141235668051827454649948626L);
+  TEST_f_f (j0, 8.0, 0.171650807137553906090869407851972001L);
+  TEST_f_f (j0, 10.0, -0.245935764451348335197760862485328754L);
+  TEST_f_f (j0, 4.0, -3.9714980986384737228659076845169804197562E-1L);
+  TEST_f_f (j0, -4.0, -3.9714980986384737228659076845169804197562E-1L);
+
+  END (j0);
+}
+
+
+static void
+j1_test (void)
+{
+  FLOAT s, c;
+  errno = 0;
+  FUNC (sincos) (0, &s, &c);
+  if (errno == ENOSYS)
+    /* Required function not implemented.  */
+    return;
+  FUNC(j1) (0);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  /* j1 is the Bessel function of the first kind of order 1 */
+
+  START (j1);
+
+  TEST_f_f (j1, nan_value, nan_value);
+  TEST_f_f (j1, plus_infty, 0);
+
+  TEST_f_f (j1, -1.0, -0.440050585744933515959682203718914913L);
+  TEST_f_f (j1, 0.0, 0.0);
+  TEST_f_f (j1, 0.125L, 0.0623780091344946810942311355879361177L);
+  TEST_f_f (j1, 0.75L, 0.349243602174862192523281016426251335L);
+  TEST_f_f (j1, 1.0, 0.440050585744933515959682203718914913L);
+  TEST_f_f (j1, 1.5, 0.557936507910099641990121213156089400L);
+  TEST_f_f (j1, 2.0, 0.576724807756873387202448242269137087L);
+  TEST_f_f (j1, 8.0, 0.234636346853914624381276651590454612L);
+  TEST_f_f (j1, 10.0, 0.0434727461688614366697487680258592883L);
+
+  END (j1);
+}
+
+static void
+jn_test (void)
+{
+  FLOAT s, c;
+  errno = 0;
+  FUNC (sincos) (0, &s, &c);
+  if (errno == ENOSYS)
+    /* Required function not implemented.  */
+    return;
+  FUNC(jn) (1, 1);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  /* jn is the Bessel function of the first kind of order n.  */
+  START (jn);
+
+  /* jn (0, x) == j0 (x)  */
+  TEST_ff_f (jn, 0, nan_value, nan_value);
+  TEST_ff_f (jn, 0, plus_infty, 0);
+  TEST_ff_f (jn, 0, -1.0, 0.765197686557966551449717526102663221L);
+  TEST_ff_f (jn, 0, 0.0, 1.0);
+  TEST_ff_f (jn, 0, 0.125L, 0.996097563041985204620768999453174712L);
+  TEST_ff_f (jn, 0, 0.75L, 0.864242275166648623555731103820923211L);
+  TEST_ff_f (jn, 0, 1.0, 0.765197686557966551449717526102663221L);
+  TEST_ff_f (jn, 0, 1.5, 0.511827671735918128749051744283411720L);
+  TEST_ff_f (jn, 0, 2.0, 0.223890779141235668051827454649948626L);
+  TEST_ff_f (jn, 0, 8.0, 0.171650807137553906090869407851972001L);
+  TEST_ff_f (jn, 0, 10.0, -0.245935764451348335197760862485328754L);
+  TEST_ff_f (jn, 0, 4.0, -3.9714980986384737228659076845169804197562E-1L);
+  TEST_ff_f (jn, 0, -4.0, -3.9714980986384737228659076845169804197562E-1L);
+
+  /* jn (1, x) == j1 (x)  */
+  TEST_ff_f (jn, 1, nan_value, nan_value);
+  TEST_ff_f (jn, 1, plus_infty, 0);
+  TEST_ff_f (jn, 1, -1.0, -0.440050585744933515959682203718914913L);
+  TEST_ff_f (jn, 1, 0.0, 0.0);
+  TEST_ff_f (jn, 1, 0.125L, 0.0623780091344946810942311355879361177L);
+  TEST_ff_f (jn, 1, 0.75L, 0.349243602174862192523281016426251335L);
+  TEST_ff_f (jn, 1, 1.0, 0.440050585744933515959682203718914913L);
+  TEST_ff_f (jn, 1, 1.5, 0.557936507910099641990121213156089400L);
+  TEST_ff_f (jn, 1, 2.0, 0.576724807756873387202448242269137087L);
+  TEST_ff_f (jn, 1, 8.0, 0.234636346853914624381276651590454612L);
+  TEST_ff_f (jn, 1, 10.0, 0.0434727461688614366697487680258592883L);
+
+  /* jn (3, x)  */
+  TEST_ff_f (jn, 3, nan_value, nan_value);
+  TEST_ff_f (jn, 3, plus_infty, 0);
+
+  TEST_ff_f (jn, 3, -1.0, -0.0195633539826684059189053216217515083L);
+  TEST_ff_f (jn, 3, 0.0, 0.0);
+  TEST_ff_f (jn, 3, 0.125L, 0.406503832554912875023029337653442868e-4L);
+  TEST_ff_f (jn, 3, 0.75L, 0.848438342327410884392755236884386804e-2L);
+  TEST_ff_f (jn, 3, 1.0, 0.0195633539826684059189053216217515083L);
+  TEST_ff_f (jn, 3, 2.0, 0.128943249474402051098793332969239835L);
+  TEST_ff_f (jn, 3, 10.0, 0.0583793793051868123429354784103409563L);
+
+  /*  jn (10, x)  */
+  TEST_ff_f (jn, 10, nan_value, nan_value);
+  TEST_ff_f (jn, 10, plus_infty, 0);
+
+  TEST_ff_f (jn, 10, -1.0, 0.263061512368745320699785368779050294e-9L);
+  TEST_ff_f (jn, 10, 0.0, 0.0);
+  TEST_ff_f (jn, 10, 0.125L, 0.250543369809369890173993791865771547e-18L);
+  TEST_ff_f (jn, 10, 0.75L, 0.149621713117596814698712483621682835e-10L);
+  TEST_ff_f (jn, 10, 1.0, 0.263061512368745320699785368779050294e-9L);
+  TEST_ff_f (jn, 10, 2.0, 0.251538628271673670963516093751820639e-6L);
+  TEST_ff_f (jn, 10, 10.0, 0.207486106633358857697278723518753428L);
+
+  END (jn);
+}
+
+
+static void
+ldexp_test (void)
+{
+  TEST_ff_f (ldexp, 0, 0, 0);
+  TEST_ff_f (ldexp, minus_zero, 0, minus_zero);
+
+  TEST_ff_f (ldexp, plus_infty, 1, plus_infty);
+  TEST_ff_f (ldexp, minus_infty, 1, minus_infty);
+  TEST_ff_f (ldexp, nan_value, 1, nan_value);
+
+  TEST_ff_f (ldexp, 0.8L, 4, 12.8L);
+  TEST_ff_f (ldexp, -0.854375L, 5, -27.34L);
+
+  /* ldexp (x, 0) == x.  */
+  TEST_ff_f (ldexp, 1.0L, 0L, 1.0L);
+}
+
+
+static void
+lgamma_test (void)
+{
+  errno = 0;
+  FUNC(lgamma) (0);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+  feclearexcept (FE_ALL_EXCEPT);
+
+  START (lgamma);
+
+  TEST_f_f (lgamma, plus_infty, plus_infty);
+  TEST_f_f (lgamma, 0, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+  TEST_f_f (lgamma, nan_value, nan_value);
+
+  /* lgamma (x) == +inf plus divide by zero exception for integer x <= 0.  */
+  TEST_f_f (lgamma, -3, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+  TEST_f_f (lgamma, minus_infty, plus_infty);
+
+  TEST_f_f1 (lgamma, 1, 0, 1);
+
+  TEST_f_f1 (lgamma, 3, M_LN2l, 1);
+
+  TEST_f_f1 (lgamma, 0.5, M_LOG_SQRT_PIl, 1);
+  TEST_f_f1 (lgamma, -0.5, M_LOG_2_SQRT_PIl, -1);
+  TEST_f_f1 (lgamma, 0.7L, 0.260867246531666514385732417016759578L, 1);
+  TEST_f_f1 (lgamma, 1.2L, -0.853740900033158497197028392998854470e-1L, 1);
+
+  END (lgamma);
+}
+
+
+static void
+lrint_test (void)
+{
+  /* XXX this test is incomplete.  We need to have a way to specifiy
+     the rounding method and test the critical cases.  So far, only
+     unproblematic numbers are tested.  */
+
+  START (lrint);
+
+  TEST_f_l (lrint, 0.0, 0);
+  TEST_f_l (lrint, minus_zero, 0);
+  TEST_f_l (lrint, 0.2L, 0);
+  TEST_f_l (lrint, -0.2L, 0);
+
+  TEST_f_l (lrint, 1.4L, 1);
+  TEST_f_l (lrint, -1.4L, -1);
+
+  TEST_f_l (lrint, 8388600.3L, 8388600);
+  TEST_f_l (lrint, -8388600.3L, -8388600);
+
+  TEST_f_l (lrint, 1071930.0008, 1071930);
+#ifndef TEST_FLOAT
+  TEST_f_l (lrint, 1073741824.01, 1073741824);
+# if LONG_MAX > 281474976710656
+  TEST_f_l (lrint, 281474976710656.025, 281474976710656);
+# endif
+#endif
+
+  END (lrint);
+}
+
+
+static void
+llrint_test (void)
+{
+  /* XXX this test is incomplete.  We need to have a way to specifiy
+     the rounding method and test the critical cases.  So far, only
+     unproblematic numbers are tested.  */
+
+  START (llrint);
+
+  TEST_f_L (llrint, 0.0, 0);
+  TEST_f_L (llrint, minus_zero, 0);
+  TEST_f_L (llrint, 0.2L, 0);
+  TEST_f_L (llrint, -0.2L, 0);
+
+  TEST_f_L (llrint, 1.4L, 1);
+  TEST_f_L (llrint, -1.4L, -1);
+
+  TEST_f_L (llrint, 8388600.3L, 8388600);
+  TEST_f_L (llrint, -8388600.3L, -8388600);
+
+  TEST_f_l (llrint, 1071930.0008, 1071930);
+
+  /* Test boundary conditions.  */
+  /* 0x1FFFFF */
+  TEST_f_L (llrint, 2097151.0,2097151LL);
+  /* 0x800000 */
+  TEST_f_L (llrint, 8388608.0, 8388608LL);
+  /* 0x1000000 */
+  TEST_f_L (llrint, 16777216.0, 16777216LL);
+  /* 0x20000000000 */
+  TEST_f_L (llrint, 2199023255552.0, 2199023255552LL);
+  /* 0x40000000000 */
+  TEST_f_L (llrint, 4398046511104.0, 4398046511104LL);
+  /* 0x1000000000000 */
+  TEST_f_L (llrint, 281474976710656.0, 281474976710656LL);
+  /* 0x10000000000000 */
+  TEST_f_L (llrint, 4503599627370496.0, 4503599627370496LL);
+  /* 0x10000080000000 */
+  TEST_f_L (llrint, 4503601774854144.0, 4503601774854144LL);
+  /* 0x20000000000000 */
+  TEST_f_L (llrint, 9007199254740992.0, 9007199254740992LL);
+  /* 0x80000000000000 */
+  TEST_f_L (llrint, 36028797018963968.0, 36028797018963968LL);
+  /* 0x100000000000000 */
+  TEST_f_L (llrint, 72057594037927936.0, 72057594037927936LL);
+
+  END (llrint);
+}
+
+
+static void
+log_test (void)
+{
+  errno = 0;
+  FUNC(log) (1);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+  START (log);
+
+  TEST_f_f (log, 0, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+  TEST_f_f (log, minus_zero, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+
+  TEST_f_f (log, 1, 0);
+
+  TEST_f_f (log, -1, nan_value, INVALID_EXCEPTION);
+  TEST_f_f (log, plus_infty, plus_infty);
+
+  TEST_f_f (log, M_El, 1);
+  TEST_f_f (log, 1.0 / M_El, -1);
+  TEST_f_f (log, 2, M_LN2l);
+  TEST_f_f (log, 10, M_LN10l);
+  TEST_f_f (log, 0.75L, -0.287682072451780927439219005993827432L);
+
+  END (log);
+}
+
+
+static void
+log10_test (void)
+{
+  errno = 0;
+  FUNC(log10) (1);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (log10);
+
+  TEST_f_f (log10, 0, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+  TEST_f_f (log10, minus_zero, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+
+  TEST_f_f (log10, 1, 0);
+
+  /* log10 (x) == NaN plus invalid exception if x < 0.  */
+  TEST_f_f (log10, -1, nan_value, INVALID_EXCEPTION);
+
+  TEST_f_f (log10, plus_infty, plus_infty);
+  TEST_f_f (log10, nan_value, nan_value);
+
+  TEST_f_f (log10, 0.1L, -1);
+  TEST_f_f (log10, 10.0, 1);
+  TEST_f_f (log10, 100.0, 2);
+  TEST_f_f (log10, 10000.0, 4);
+  TEST_f_f (log10, M_El, M_LOG10El);
+  TEST_f_f (log10, 0.75L, -0.124938736608299953132449886193870744L);
+
+  END (log10);
+}
+
+
+static void
+log1p_test (void)
+{
+  errno = 0;
+  FUNC(log1p) (0);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (log1p);
+
+  TEST_f_f (log1p, 0, 0);
+  TEST_f_f (log1p, minus_zero, minus_zero);
+
+  TEST_f_f (log1p, -1, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+  TEST_f_f (log1p, -2, nan_value, INVALID_EXCEPTION);
+
+  TEST_f_f (log1p, plus_infty, plus_infty);
+  TEST_f_f (log1p, nan_value, nan_value);
+
+  TEST_f_f (log1p, M_El - 1.0, 1);
+
+  TEST_f_f (log1p, -0.25L, -0.287682072451780927439219005993827432L);
+  TEST_f_f (log1p, -0.875, -2.07944154167983592825169636437452970L);
+
+  END (log1p);
+}
+
+
+static void
+log2_test (void)
+{
+  errno = 0;
+  FUNC(log2) (1);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (log2);
+
+  TEST_f_f (log2, 0, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+  TEST_f_f (log2, minus_zero, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+
+  TEST_f_f (log2, 1, 0);
+
+  TEST_f_f (log2, -1, nan_value, INVALID_EXCEPTION);
+
+  TEST_f_f (log2, plus_infty, plus_infty);
+  TEST_f_f (log2, nan_value, nan_value);
+
+  TEST_f_f (log2, M_El, M_LOG2El);
+  TEST_f_f (log2, 2.0, 1);
+  TEST_f_f (log2, 16.0, 4);
+  TEST_f_f (log2, 256.0, 8);
+  TEST_f_f (log2, 0.75L, -.415037499278843818546261056052183492L);
+
+  END (log2);
+}
+
+
+static void
+logb_test (void)
+{
+  START (logb);
+
+  TEST_f_f (logb, plus_infty, plus_infty);
+  TEST_f_f (logb, minus_infty, plus_infty);
+
+  TEST_f_f (logb, 0, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+
+  TEST_f_f (logb, minus_zero, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+  TEST_f_f (logb, nan_value, nan_value);
+
+  TEST_f_f (logb, 1, 0);
+  TEST_f_f (logb, M_El, 1);
+  TEST_f_f (logb, 1024, 10);
+  TEST_f_f (logb, -2000, 10);
+
+  END (logb);
+}
+
+
+static void
+lround_test (void)
+{
+  START (lround);
+
+  TEST_f_l (lround, 0, 0);
+  TEST_f_l (lround, minus_zero, 0);
+  TEST_f_l (lround, 0.2L, 0.0);
+  TEST_f_l (lround, -0.2L, 0);
+  TEST_f_l (lround, 0.5, 1);
+  TEST_f_l (lround, -0.5, -1);
+  TEST_f_l (lround, 0.8L, 1);
+  TEST_f_l (lround, -0.8L, -1);
+  TEST_f_l (lround, 1.5, 2);
+  TEST_f_l (lround, -1.5, -2);
+  TEST_f_l (lround, 22514.5, 22515);
+  TEST_f_l (lround, -22514.5, -22515);
+  TEST_f_l (lround, 1071930.0008, 1071930);
+#ifndef TEST_FLOAT
+  TEST_f_l (lround, 1073741824.01, 1073741824);
+# if LONG_MAX > 281474976710656
+  TEST_f_l (lround, 281474976710656.025, 281474976710656);
+# endif
+  TEST_f_l (lround, 2097152.5, 2097153);
+  TEST_f_l (lround, -2097152.5, -2097153);
+#endif
+  END (lround);
+}
+
+
+static void
+llround_test (void)
+{
+  START (llround);
+
+  TEST_f_L (llround, 0, 0);
+  TEST_f_L (llround, minus_zero, 0);
+  TEST_f_L (llround, 0.2L, 0.0);
+  TEST_f_L (llround, -0.2L, 0);
+  TEST_f_L (llround, 0.5, 1);
+  TEST_f_L (llround, -0.5, -1);
+  TEST_f_L (llround, 0.8L, 1);
+  TEST_f_L (llround, -0.8L, -1);
+  TEST_f_L (llround, 1.5, 2);
+  TEST_f_L (llround, -1.5, -2);
+  TEST_f_L (llround, 22514.5, 22515);
+  TEST_f_L (llround, -22514.5, -22515);
+  TEST_f_l (llround, 1071930.0008, 1071930);
+#ifndef TEST_FLOAT
+  TEST_f_L (llround, 2097152.5, 2097153);
+  TEST_f_L (llround, -2097152.5, -2097153);
+  TEST_f_L (llround, 34359738368.5, 34359738369ll);
+  TEST_f_L (llround, -34359738368.5, -34359738369ll);
+#endif
+
+  /* Test boundary conditions.  */
+  /* 0x1FFFFF */
+  TEST_f_L (llround, 2097151.0, 2097151LL);
+  /* 0x800000 */
+  TEST_f_L (llround, 8388608.0, 8388608LL);
+  /* 0x1000000 */
+  TEST_f_L (llround, 16777216.0, 16777216LL);
+  /* 0x20000000000 */
+  TEST_f_L (llround, 2199023255552.0, 2199023255552LL);
+  /* 0x40000000000 */
+  TEST_f_L (llround, 4398046511104.0, 4398046511104LL);
+  /* 0x1000000000000 */
+  TEST_f_L (llround, 281474976710656.0, 281474976710656LL);
+  /* 0x10000000000000 */
+  TEST_f_L (llround, 4503599627370496.0, 4503599627370496LL);
+  /* 0x10000080000000 */
+  TEST_f_L (llround, 4503601774854144.0, 4503601774854144LL);
+  /* 0x20000000000000 */
+  TEST_f_L (llround, 9007199254740992.0, 9007199254740992LL);
+  /* 0x80000000000000 */
+  TEST_f_L (llround, 36028797018963968.0, 36028797018963968LL);
+  /* 0x100000000000000 */
+  TEST_f_L (llround, 72057594037927936.0, 72057594037927936LL);
+
+#ifndef TEST_FLOAT
+  /* 0x100000000 */
+  TEST_f_L (llround, 4294967295.5, 4294967296LL);
+  /* 0x200000000 */
+  TEST_f_L (llround, 8589934591.5, 8589934592LL);
+#endif
+
+  END (llround);
+}
+
+static void
+modf_test (void)
+{
+  FLOAT x;
+
+  START (modf);
+
+  TEST_fF_f1 (modf, plus_infty, 0, plus_infty);
+  TEST_fF_f1 (modf, minus_infty, minus_zero, minus_infty);
+  TEST_fF_f1 (modf, nan_value, nan_value, nan_value);
+  TEST_fF_f1 (modf, 0, 0, 0);
+  TEST_fF_f1 (modf, 1.5, 0.5, 1);
+  TEST_fF_f1 (modf, 2.5, 0.5, 2);
+  TEST_fF_f1 (modf, -2.5, -0.5, -2);
+  TEST_fF_f1 (modf, 20, 0, 20);
+  TEST_fF_f1 (modf, 21, 0, 21);
+  TEST_fF_f1 (modf, 89.5, 0.5, 89);
+
+  END (modf);
+}
+
+
+static void
+nearbyint_test (void)
+{
+  START (nearbyint);
+
+  TEST_f_f (nearbyint, 0.0, 0.0);
+  TEST_f_f (nearbyint, minus_zero, minus_zero);
+  TEST_f_f (nearbyint, plus_infty, plus_infty);
+  TEST_f_f (nearbyint, minus_infty, minus_infty);
+  TEST_f_f (nearbyint, nan_value, nan_value);
+
+  /* Default rounding mode is round to nearest.  */
+  TEST_f_f (nearbyint, 0.5, 0.0);
+  TEST_f_f (nearbyint, 1.5, 2.0);
+  TEST_f_f (nearbyint, -0.5, minus_zero);
+  TEST_f_f (nearbyint, -1.5, -2.0);
+
+  END (nearbyint);
+}
+
+static void
+nextafter_test (void)
+{
+
+  START (nextafter);
+
+  TEST_ff_f (nextafter, 0, 0, 0);
+  TEST_ff_f (nextafter, minus_zero, 0, 0);
+  TEST_ff_f (nextafter, 0, minus_zero, minus_zero);
+  TEST_ff_f (nextafter, minus_zero, minus_zero, minus_zero);
+
+  TEST_ff_f (nextafter, 9, 9, 9);
+  TEST_ff_f (nextafter, -9, -9, -9);
+  TEST_ff_f (nextafter, plus_infty, plus_infty, plus_infty);
+  TEST_ff_f (nextafter, minus_infty, minus_infty, minus_infty);
+
+  TEST_ff_f (nextafter, nan_value, 1.1L, nan_value);
+  TEST_ff_f (nextafter, 1.1L, nan_value, nan_value);
+  TEST_ff_f (nextafter, nan_value, nan_value, nan_value);
+
+  FLOAT fltmax = CHOOSE (LDBL_MAX, DBL_MAX, FLT_MAX,
+			 LDBL_MAX, DBL_MAX, FLT_MAX);
+  TEST_ff_f (nextafter, fltmax, plus_infty, plus_infty);
+  TEST_ff_f (nextafter, -fltmax, minus_infty, minus_infty);
+
+#ifdef TEST_LDOUBLE
+  // XXX Enable once gcc is fixed.
+  //TEST_ff_f (nextafter, 0x0.00000040000000000000p-16385L, -0.1L, 0x0.0000003ffffffff00000p-16385L);
+#endif
+
+  /* XXX We need the hexadecimal FP number representation here for further
+     tests.  */
+
+  END (nextafter);
+}
+
+
+static void
+nexttoward_test (void)
+{
+  START (nexttoward);
+  TEST_ff_f (nexttoward, 0, 0, 0);
+  TEST_ff_f (nexttoward, minus_zero, 0, 0);
+  TEST_ff_f (nexttoward, 0, minus_zero, minus_zero);
+  TEST_ff_f (nexttoward, minus_zero, minus_zero, minus_zero);
+
+  TEST_ff_f (nexttoward, 9, 9, 9);
+  TEST_ff_f (nexttoward, -9, -9, -9);
+  TEST_ff_f (nexttoward, plus_infty, plus_infty, plus_infty);
+  TEST_ff_f (nexttoward, minus_infty, minus_infty, minus_infty);
+
+  TEST_ff_f (nexttoward, nan_value, 1.1L, nan_value);
+  TEST_ff_f (nexttoward, 1.1L, nan_value, nan_value);
+  TEST_ff_f (nexttoward, nan_value, nan_value, nan_value);
+
+  /* XXX We need the hexadecimal FP number representation here for further
+     tests.  */
+
+  END (nexttoward);
+}
+
+
+static void
+pow_test (void)
+{
+
+  errno = 0;
+  FUNC(pow) (0, 0);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (pow);
+
+  TEST_ff_f (pow, 0, 0, 1);
+  TEST_ff_f (pow, 0, minus_zero, 1);
+  TEST_ff_f (pow, minus_zero, 0, 1);
+  TEST_ff_f (pow, minus_zero, minus_zero, 1);
+
+  TEST_ff_f (pow, 10, 0, 1);
+  TEST_ff_f (pow, 10, minus_zero, 1);
+  TEST_ff_f (pow, -10, 0, 1);
+  TEST_ff_f (pow, -10, minus_zero, 1);
+
+  TEST_ff_f (pow, nan_value, 0, 1);
+  TEST_ff_f (pow, nan_value, minus_zero, 1);
+
+
+#ifndef TEST_INLINE
+  TEST_ff_f (pow, 1.1L, plus_infty, plus_infty);
+  TEST_ff_f (pow, plus_infty, plus_infty, plus_infty);
+  TEST_ff_f (pow, -1.1L, plus_infty, plus_infty);
+  TEST_ff_f (pow, minus_infty, plus_infty, plus_infty);
+
+  TEST_ff_f (pow, 0.9L, plus_infty, 0);
+  TEST_ff_f (pow, 1e-7L, plus_infty, 0);
+  TEST_ff_f (pow, -0.9L, plus_infty, 0);
+  TEST_ff_f (pow, -1e-7L, plus_infty, 0);
+
+  TEST_ff_f (pow, 1.1L, minus_infty, 0);
+  TEST_ff_f (pow, plus_infty, minus_infty, 0);
+  TEST_ff_f (pow, -1.1L, minus_infty, 0);
+  TEST_ff_f (pow, minus_infty, minus_infty, 0);
+
+  TEST_ff_f (pow, 0.9L, minus_infty, plus_infty);
+  TEST_ff_f (pow, 1e-7L, minus_infty, plus_infty);
+  TEST_ff_f (pow, -0.9L, minus_infty, plus_infty);
+  TEST_ff_f (pow, -1e-7L, minus_infty, plus_infty);
+
+  TEST_ff_f (pow, plus_infty, 1e-7L, plus_infty);
+  TEST_ff_f (pow, plus_infty, 1, plus_infty);
+  TEST_ff_f (pow, plus_infty, 1e7L, plus_infty);
+
+  TEST_ff_f (pow, plus_infty, -1e-7L, 0);
+  TEST_ff_f (pow, plus_infty, -1, 0);
+  TEST_ff_f (pow, plus_infty, -1e7L, 0);
+
+  TEST_ff_f (pow, minus_infty, 1, minus_infty);
+  TEST_ff_f (pow, minus_infty, 11, minus_infty);
+  TEST_ff_f (pow, minus_infty, 1001, minus_infty);
+
+  TEST_ff_f (pow, minus_infty, 2, plus_infty);
+  TEST_ff_f (pow, minus_infty, 12, plus_infty);
+  TEST_ff_f (pow, minus_infty, 1002, plus_infty);
+  TEST_ff_f (pow, minus_infty, 0.1L, plus_infty);
+  TEST_ff_f (pow, minus_infty, 1.1L, plus_infty);
+  TEST_ff_f (pow, minus_infty, 11.1L, plus_infty);
+  TEST_ff_f (pow, minus_infty, 1001.1L, plus_infty);
+
+  TEST_ff_f (pow, minus_infty, -1, minus_zero);
+  TEST_ff_f (pow, minus_infty, -11, minus_zero);
+  TEST_ff_f (pow, minus_infty, -1001, minus_zero);
+
+  TEST_ff_f (pow, minus_infty, -2, 0);
+  TEST_ff_f (pow, minus_infty, -12, 0);
+  TEST_ff_f (pow, minus_infty, -1002, 0);
+  TEST_ff_f (pow, minus_infty, -0.1L, 0);
+  TEST_ff_f (pow, minus_infty, -1.1L, 0);
+  TEST_ff_f (pow, minus_infty, -11.1L, 0);
+  TEST_ff_f (pow, minus_infty, -1001.1L, 0);
+#endif
+
+  TEST_ff_f (pow, nan_value, nan_value, nan_value);
+  TEST_ff_f (pow, 0, nan_value, nan_value);
+  TEST_ff_f (pow, 1, nan_value, 1);
+  TEST_ff_f (pow, -1, nan_value, nan_value);
+  TEST_ff_f (pow, nan_value, 1, nan_value);
+  TEST_ff_f (pow, nan_value, -1, nan_value);
+
+  /* pow (x, NaN) == NaN.  */
+  TEST_ff_f (pow, 3.0, nan_value, nan_value);
+
+  TEST_ff_f (pow, 1, plus_infty, 1);
+  TEST_ff_f (pow, -1, plus_infty, 1);
+  TEST_ff_f (pow, 1, minus_infty, 1);
+  TEST_ff_f (pow, -1, minus_infty, 1);
+  TEST_ff_f (pow, 1, 1, 1);
+  TEST_ff_f (pow, 1, -1, 1);
+  TEST_ff_f (pow, 1, 1.25, 1);
+  TEST_ff_f (pow, 1, -1.25, 1);
+  TEST_ff_f (pow, 1, 0x1p62L, 1);
+  TEST_ff_f (pow, 1, 0x1p63L, 1);
+  TEST_ff_f (pow, 1, 0x1p64L, 1);
+  TEST_ff_f (pow, 1, 0x1p72L, 1);
+
+  /* pow (x, +-0) == 1.  */
+  TEST_ff_f (pow, plus_infty, 0, 1);
+  TEST_ff_f (pow, plus_infty, minus_zero, 1);
+  TEST_ff_f (pow, minus_infty, 0, 1);
+  TEST_ff_f (pow, minus_infty, minus_zero, 1);
+  TEST_ff_f (pow, 32.75L, 0, 1);
+  TEST_ff_f (pow, 32.75L, minus_zero, 1);
+  TEST_ff_f (pow, -32.75L, 0, 1);
+  TEST_ff_f (pow, -32.75L, minus_zero, 1);
+  TEST_ff_f (pow, 0x1p72L, 0, 1);
+  TEST_ff_f (pow, 0x1p72L, minus_zero, 1);
+  TEST_ff_f (pow, 0x1p-72L, 0, 1);
+  TEST_ff_f (pow, 0x1p-72L, minus_zero, 1);
+
+  TEST_ff_f (pow, -0.1L, 1.1L, nan_value, INVALID_EXCEPTION);
+  TEST_ff_f (pow, -0.1L, -1.1L, nan_value, INVALID_EXCEPTION);
+  TEST_ff_f (pow, -10.1L, 1.1L, nan_value, INVALID_EXCEPTION);
+  TEST_ff_f (pow, -10.1L, -1.1L, nan_value, INVALID_EXCEPTION);
+
+  TEST_ff_f (pow, 0, -1, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+  TEST_ff_f (pow, 0, -11, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+  TEST_ff_f (pow, minus_zero, -1, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+  TEST_ff_f (pow, minus_zero, -11, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+
+  TEST_ff_f (pow, 0, -2, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+  TEST_ff_f (pow, 0, -11.1L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+  TEST_ff_f (pow, minus_zero, -2, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+  TEST_ff_f (pow, minus_zero, -11.1L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+
+  TEST_ff_f (pow, 0x1p72L, 0x1p72L, plus_infty);
+  TEST_ff_f (pow, 10, -0x1p72L, 0);
+  TEST_ff_f (pow, max_value, max_value, plus_infty);
+  TEST_ff_f (pow, 10, -max_value, 0);
+
+  TEST_ff_f (pow, 0, 1, 0);
+  TEST_ff_f (pow, 0, 11, 0);
+
+  TEST_ff_f (pow, minus_zero, 1, minus_zero);
+  TEST_ff_f (pow, minus_zero, 11, minus_zero);
+
+
+  TEST_ff_f (pow, 0, 2, 0);
+  TEST_ff_f (pow, 0, 11.1L, 0);
+
+
+  TEST_ff_f (pow, minus_zero, 2, 0);
+  TEST_ff_f (pow, minus_zero, 11.1L, 0);
+  TEST_ff_f (pow, 0, plus_infty, 0);
+  TEST_ff_f (pow, minus_zero, plus_infty, 0);
+
+#ifndef TEST_INLINE
+  /* pow (x, +inf) == +inf for |x| > 1.  */
+  TEST_ff_f (pow, 1.5, plus_infty, plus_infty);
+
+  /* pow (x, +inf) == +0 for |x| < 1.  */
+  TEST_ff_f (pow, 0.5, plus_infty, 0.0);
+
+  /* pow (x, -inf) == +0 for |x| > 1.  */
+  TEST_ff_f (pow, 1.5, minus_infty, 0.0);
+
+  /* pow (x, -inf) == +inf for |x| < 1.  */
+  TEST_ff_f (pow, 0.5, minus_infty, plus_infty);
+#endif
+
+  /* pow (+inf, y) == +inf for y > 0.  */
+  TEST_ff_f (pow, plus_infty, 2, plus_infty);
+
+  /* pow (+inf, y) == +0 for y < 0.  */
+  TEST_ff_f (pow, plus_infty, -1, 0.0);
+
+  /* pow (-inf, y) == -inf for y an odd integer > 0.  */
+  TEST_ff_f (pow, minus_infty, 27, minus_infty);
+
+  /* pow (-inf, y) == +inf for y > 0 and not an odd integer.  */
+  TEST_ff_f (pow, minus_infty, 28, plus_infty);
+
+  /* pow (-inf, y) == -0 for y an odd integer < 0. */
+  TEST_ff_f (pow, minus_infty, -3, minus_zero);
+  /* pow (-inf, y) == +0 for y < 0 and not an odd integer.  */
+  TEST_ff_f (pow, minus_infty, -2.0, 0.0);
+
+  /* pow (+0, y) == +0 for y an odd integer > 0.  */
+  TEST_ff_f (pow, 0.0, 27, 0.0);
+
+  /* pow (-0, y) == -0 for y an odd integer > 0.  */
+  TEST_ff_f (pow, minus_zero, 27, minus_zero);
+
+  /* pow (+0, y) == +0 for y > 0 and not an odd integer.  */
+  TEST_ff_f (pow, 0.0, 4, 0.0);
+
+  /* pow (-0, y) == +0 for y > 0 and not an odd integer.  */
+  TEST_ff_f (pow, minus_zero, 4, 0.0);
+
+  TEST_ff_f (pow, 16, 0.25L, 2);
+  TEST_ff_f (pow, 0x1p64L, 0.125L, 256);
+  TEST_ff_f (pow, 2, 4, 16);
+  TEST_ff_f (pow, 256, 8, 0x1p64L);
+
+  TEST_ff_f (pow, 0.75L, 1.25L, 0.697953644326574699205914060237425566L);
+
+#if defined TEST_DOUBLE || defined TEST_LDOUBLE
+  TEST_ff_f (pow, -7.49321e+133, -9.80818e+16, 0);
+#endif
+
+  END (pow);
+}
+
+static void
+remainder_test (void)
+{
+  errno = 0;
+  FUNC(remainder) (1.625, 1.0);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (remainder);
+
+  TEST_ff_f (remainder, 1, 0, nan_value, INVALID_EXCEPTION);
+  TEST_ff_f (remainder, 1, minus_zero, nan_value, INVALID_EXCEPTION);
+  TEST_ff_f (remainder, plus_infty, 1, nan_value, INVALID_EXCEPTION);
+  TEST_ff_f (remainder, minus_infty, 1, nan_value, INVALID_EXCEPTION);
+  TEST_ff_f (remainder, nan_value, nan_value, nan_value);
+
+  TEST_ff_f (remainder, 1.625, 1.0, -0.375);
+  TEST_ff_f (remainder, -1.625, 1.0, 0.375);
+  TEST_ff_f (remainder, 1.625, -1.0, -0.375);
+  TEST_ff_f (remainder, -1.625, -1.0, 0.375);
+  TEST_ff_f (remainder, 5.0, 2.0, 1.0);
+  TEST_ff_f (remainder, 3.0, 2.0, -1.0);
+
+  END (remainder);
+}
+
+static void
+remquo_test (void)
+{
+  /* x is needed.  */
+  int x;
+
+  errno = 0;
+  FUNC(remquo) (1.625, 1.0, &x);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (remquo);
+
+  TEST_ffI_f1 (remquo, 1, 0, nan_value, IGNORE, INVALID_EXCEPTION);
+  TEST_ffI_f1 (remquo, 1, minus_zero, nan_value, IGNORE, INVALID_EXCEPTION);
+  TEST_ffI_f1 (remquo, plus_infty, 1, nan_value, IGNORE, INVALID_EXCEPTION);
+  TEST_ffI_f1 (remquo, minus_infty, 1, nan_value, IGNORE, INVALID_EXCEPTION);
+  TEST_ffI_f1 (remquo, nan_value, nan_value, nan_value, IGNORE);
+
+  TEST_ffI_f1 (remquo, 1.625, 1.0, -0.375, 2);
+  TEST_ffI_f1 (remquo, -1.625, 1.0, 0.375, -2);
+  TEST_ffI_f1 (remquo, 1.625, -1.0, -0.375, -2);
+  TEST_ffI_f1 (remquo, -1.625, -1.0, 0.375, 2);
+
+  TEST_ffI_f1 (remquo, 5, 2, 1, 2);
+  TEST_ffI_f1 (remquo, 3, 2, -1, 2);
+
+  END (remquo);
+}
+
+static void
+rint_test (void)
+{
+  START (rint);
+
+  TEST_f_f (rint, 0.0, 0.0);
+  TEST_f_f (rint, minus_zero, minus_zero);
+  TEST_f_f (rint, plus_infty, plus_infty);
+  TEST_f_f (rint, minus_infty, minus_infty);
+
+  /* Default rounding mode is round to even.  */
+  TEST_f_f (rint, 0.5, 0.0);
+  TEST_f_f (rint, 1.5, 2.0);
+  TEST_f_f (rint, 2.5, 2.0);
+  TEST_f_f (rint, 3.5, 4.0);
+  TEST_f_f (rint, 4.5, 4.0);
+  TEST_f_f (rint, -0.5, -0.0);
+  TEST_f_f (rint, -1.5, -2.0);
+  TEST_f_f (rint, -2.5, -2.0);
+  TEST_f_f (rint, -3.5, -4.0);
+  TEST_f_f (rint, -4.5, -4.0);
+
+  END (rint);
+}
+
+static void
+rint_test_tonearest (void)
+{
+  int save_round_mode;
+  START (rint_tonearest);
+
+  save_round_mode = fegetround();
+
+  if (!fesetround (FE_TONEAREST))
+  {
+    TEST_f_f (rint, 2.0, 2.0);
+    TEST_f_f (rint, 1.5, 2.0);
+    TEST_f_f (rint, 1.0, 1.0);
+    TEST_f_f (rint, 0.5, 0.0);
+    TEST_f_f (rint, 0.0, 0.0);
+    TEST_f_f (rint, minus_zero, minus_zero);
+    TEST_f_f (rint, -0.5, -0.0);
+    TEST_f_f (rint, -1.0, -1.0);
+    TEST_f_f (rint, -1.5, -2.0);
+    TEST_f_f (rint, -2.0, -2.0);
+  }
+
+  fesetround(save_round_mode);
+
+  END (rint_tonearest);
+}
+
+static void
+rint_test_towardzero (void)
+{
+  int save_round_mode;
+  START (rint_towardzero);
+
+  save_round_mode = fegetround();
+
+  if (!fesetround (FE_TOWARDZERO))
+  {
+    TEST_f_f (rint, 2.0, 2.0);
+    TEST_f_f (rint, 1.5, 1.0);
+    TEST_f_f (rint, 1.0, 1.0);
+    TEST_f_f (rint, 0.5, 0.0);
+    TEST_f_f (rint, 0.0, 0.0);
+    TEST_f_f (rint, minus_zero, minus_zero);
+    TEST_f_f (rint, -0.5, -0.0);
+    TEST_f_f (rint, -1.0, -1.0);
+    TEST_f_f (rint, -1.5, -1.0);
+    TEST_f_f (rint, -2.0, -2.0);
+  }
+
+  fesetround(save_round_mode);
+
+  END (rint_towardzero);
+}
+
+static void
+rint_test_downward (void)
+{
+  int save_round_mode;
+  START (rint_downward);
+
+  save_round_mode = fegetround();
+
+  if (!fesetround (FE_DOWNWARD))
+  {
+    TEST_f_f (rint, 2.0, 2.0);
+    TEST_f_f (rint, 1.5, 1.0);
+    TEST_f_f (rint, 1.0, 1.0);
+    TEST_f_f (rint, 0.5, 0.0);
+    TEST_f_f (rint, 0.0, 0.0);
+    TEST_f_f (rint, minus_zero, minus_zero);
+    TEST_f_f (rint, -0.5, -1.0);
+    TEST_f_f (rint, -1.0, -1.0);
+    TEST_f_f (rint, -1.5, -2.0);
+    TEST_f_f (rint, -2.0, -2.0);
+  }
+
+  fesetround(save_round_mode);
+
+  END (rint_downward);
+}
+
+static void
+rint_test_upward (void)
+{
+  int save_round_mode;
+  START (rint_upward);
+
+  save_round_mode = fegetround();
+
+  if (!fesetround (FE_UPWARD))
+  {
+    TEST_f_f (rint, 2.0, 2.0);
+    TEST_f_f (rint, 1.5, 2.0);
+    TEST_f_f (rint, 1.0, 1.0);
+    TEST_f_f (rint, 0.5, 1.0);
+    TEST_f_f (rint, 0.0, 0.0);
+    TEST_f_f (rint, minus_zero, minus_zero);
+    TEST_f_f (rint, -0.5, -0.0);
+    TEST_f_f (rint, -1.0, -1.0);
+    TEST_f_f (rint, -1.5, -1.0);
+    TEST_f_f (rint, -2.0, -2.0);
+  }
+
+  fesetround(save_round_mode);
+
+  END (rint_upward);
+}
+
+static void
+round_test (void)
+{
+  START (round);
+
+  TEST_f_f (round, 0, 0);
+  TEST_f_f (round, minus_zero, minus_zero);
+  TEST_f_f (round, 0.2L, 0.0);
+  TEST_f_f (round, -0.2L, minus_zero);
+  TEST_f_f (round, 0.5, 1.0);
+  TEST_f_f (round, -0.5, -1.0);
+  TEST_f_f (round, 0.8L, 1.0);
+  TEST_f_f (round, -0.8L, -1.0);
+  TEST_f_f (round, 1.5, 2.0);
+  TEST_f_f (round, -1.5, -2.0);
+  TEST_f_f (round, 2097152.5, 2097153);
+  TEST_f_f (round, -2097152.5, -2097153);
+
+  END (round);
+}
+
+
+static void
+scalb_test (void)
+{
+
+  START (scalb);
+
+  TEST_ff_f (scalb, 2.0, 0.5, nan_value, INVALID_EXCEPTION);
+  TEST_ff_f (scalb, 3.0, -2.5, nan_value, INVALID_EXCEPTION);
+
+  TEST_ff_f (scalb, 0, nan_value, nan_value);
+  TEST_ff_f (scalb, 1, nan_value, nan_value);
+
+  TEST_ff_f (scalb, 1, 0, 1);
+  TEST_ff_f (scalb, -1, 0, -1);
+
+  TEST_ff_f (scalb, 0, plus_infty, nan_value, INVALID_EXCEPTION);
+  TEST_ff_f (scalb, minus_zero, plus_infty, nan_value, INVALID_EXCEPTION);
+
+  TEST_ff_f (scalb, 0, 2, 0);
+  TEST_ff_f (scalb, minus_zero, -4, minus_zero);
+  TEST_ff_f (scalb, 0, 0, 0);
+  TEST_ff_f (scalb, minus_zero, 0, minus_zero);
+  TEST_ff_f (scalb, 0, -1, 0);
+  TEST_ff_f (scalb, minus_zero, -10, minus_zero);
+  TEST_ff_f (scalb, 0, minus_infty, 0);
+  TEST_ff_f (scalb, minus_zero, minus_infty, minus_zero);
+
+  TEST_ff_f (scalb, plus_infty, -1, plus_infty);
+  TEST_ff_f (scalb, minus_infty, -10, minus_infty);
+  TEST_ff_f (scalb, plus_infty, 0, plus_infty);
+  TEST_ff_f (scalb, minus_infty, 0, minus_infty);
+  TEST_ff_f (scalb, plus_infty, 2, plus_infty);
+  TEST_ff_f (scalb, minus_infty, 100, minus_infty);
+
+  TEST_ff_f (scalb, 0.1L, minus_infty, 0.0);
+  TEST_ff_f (scalb, -0.1L, minus_infty, minus_zero);
+
+  TEST_ff_f (scalb, 1, plus_infty, plus_infty);
+  TEST_ff_f (scalb, -1, plus_infty, minus_infty);
+  TEST_ff_f (scalb, plus_infty, plus_infty, plus_infty);
+  TEST_ff_f (scalb, minus_infty, plus_infty, minus_infty);
+
+  TEST_ff_f (scalb, plus_infty, minus_infty, nan_value, INVALID_EXCEPTION);
+  TEST_ff_f (scalb, minus_infty, minus_infty, nan_value, INVALID_EXCEPTION);
+
+  TEST_ff_f (scalb, nan_value, 1, nan_value);
+  TEST_ff_f (scalb, 1, nan_value, nan_value);
+  TEST_ff_f (scalb, nan_value, 0, nan_value);
+  TEST_ff_f (scalb, 0, nan_value, nan_value);
+  TEST_ff_f (scalb, nan_value, plus_infty, nan_value);
+  TEST_ff_f (scalb, plus_infty, nan_value, nan_value);
+  TEST_ff_f (scalb, nan_value, nan_value, nan_value);
+
+  TEST_ff_f (scalb, 0.8L, 4, 12.8L);
+  TEST_ff_f (scalb, -0.854375L, 5, -27.34L);
+
+  END (scalb);
+}
+
+
+static void
+scalbn_test (void)
+{
+
+  START (scalbn);
+
+  TEST_fi_f (scalbn, 0, 0, 0);
+  TEST_fi_f (scalbn, minus_zero, 0, minus_zero);
+
+  TEST_fi_f (scalbn, plus_infty, 1, plus_infty);
+  TEST_fi_f (scalbn, minus_infty, 1, minus_infty);
+  TEST_fi_f (scalbn, nan_value, 1, nan_value);
+
+  TEST_fi_f (scalbn, 0.8L, 4, 12.8L);
+  TEST_fi_f (scalbn, -0.854375L, 5, -27.34L);
+
+  TEST_fi_f (scalbn, 1, 0L, 1);
+
+  END (scalbn);
+}
+
+
+static void
+scalbln_test (void)
+{
+
+  START (scalbln);
+
+  TEST_fl_f (scalbln, 0, 0, 0);
+  TEST_fl_f (scalbln, minus_zero, 0, minus_zero);
+
+  TEST_fl_f (scalbln, plus_infty, 1, plus_infty);
+  TEST_fl_f (scalbln, minus_infty, 1, minus_infty);
+  TEST_fl_f (scalbln, nan_value, 1, nan_value);
+
+  TEST_fl_f (scalbln, 0.8L, 4, 12.8L);
+  TEST_fl_f (scalbln, -0.854375L, 5, -27.34L);
+
+  TEST_fl_f (scalbln, 1, 0L, 1);
+
+  END (scalbn);
+}
+
+
+static void
+signbit_test (void)
+{
+
+  START (signbit);
+
+  TEST_f_b (signbit, 0, 0);
+  TEST_f_b (signbit, minus_zero, 1);
+  TEST_f_b (signbit, plus_infty, 0);
+  TEST_f_b (signbit, minus_infty, 1);
+
+  /* signbit (x) != 0 for x < 0.  */
+  TEST_f_b (signbit, -1, 1);
+  /* signbit (x) == 0 for x >= 0.  */
+  TEST_f_b (signbit, 1, 0);
+
+  END (signbit);
+}
+
+
+static void
+sin_test (void)
+{
+  errno = 0;
+  FUNC(sin) (0);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (sin);
+
+  TEST_f_f (sin, 0, 0);
+  TEST_f_f (sin, minus_zero, minus_zero);
+  TEST_f_f (sin, plus_infty, nan_value, INVALID_EXCEPTION);
+  TEST_f_f (sin, minus_infty, nan_value, INVALID_EXCEPTION);
+  TEST_f_f (sin, nan_value, nan_value);
+
+  TEST_f_f (sin, M_PI_6l, 0.5);
+  TEST_f_f (sin, -M_PI_6l, -0.5);
+  TEST_f_f (sin, M_PI_2l, 1);
+  TEST_f_f (sin, -M_PI_2l, -1);
+  TEST_f_f (sin, 0.75L, 0.681638760023334166733241952779893935L);
+
+#ifdef TEST_DOUBLE
+  TEST_f_f (sin, 0.80190127184058835, 0.71867942238767868);
+#endif
+
+  END (sin);
+
+}
+
+
+static void
+sincos_test (void)
+{
+  FLOAT sin_res, cos_res;
+
+  errno = 0;
+  FUNC(sincos) (0, &sin_res, &cos_res);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (sincos);
+
+  /* sincos is treated differently because it returns void.  */
+  TEST_extra (sincos, 0, 0, 1);
+
+  TEST_extra (sincos, minus_zero, minus_zero, 1);
+  TEST_extra (sincos, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_extra (sincos, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+  TEST_extra (sincos, nan_value, nan_value, nan_value);
+
+  TEST_extra (sincos, M_PI_2l, 1, 0);
+  TEST_extra (sincos, M_PI_6l, 0.5, 0.86602540378443864676372317075293616L);
+  TEST_extra (sincos, M_PI_6l*2.0, 0.86602540378443864676372317075293616L, 0.5);
+  TEST_extra (sincos, 0.75L, 0.681638760023334166733241952779893935L, 0.731688868873820886311838753000084544L);
+
+#ifdef TEST_DOUBLE
+  TEST_extra (sincos, 0.80190127184058835, 0.71867942238767868, 0.69534156199418473);
+#endif
+
+  END (sincos);
+}
+
+static void
+sinh_test (void)
+{
+  errno = 0;
+  FUNC(sinh) (0.7L);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (sinh);
+  TEST_f_f (sinh, 0, 0);
+  TEST_f_f (sinh, minus_zero, minus_zero);
+
+#ifndef TEST_INLINE
+  TEST_f_f (sinh, plus_infty, plus_infty);
+  TEST_f_f (sinh, minus_infty, minus_infty);
+#endif
+  TEST_f_f (sinh, nan_value, nan_value);
+
+  TEST_f_f (sinh, 0.75L, 0.822316731935829980703661634446913849L);
+  TEST_f_f (sinh, 0x8p-32L, 1.86264514923095703232705808926175479e-9L);
+
+  END (sinh);
+}
+
+static void
+sqrt_test (void)
+{
+  errno = 0;
+  FUNC(sqrt) (1);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (sqrt);
+
+  TEST_f_f (sqrt, 0, 0);
+  TEST_f_f (sqrt, nan_value, nan_value);
+  TEST_f_f (sqrt, plus_infty, plus_infty);
+
+  TEST_f_f (sqrt, minus_zero, minus_zero);
+
+  /* sqrt (x) == NaN plus invalid exception for x < 0.  */
+  TEST_f_f (sqrt, -1, nan_value, INVALID_EXCEPTION);
+  TEST_f_f (sqrt, minus_infty, nan_value, INVALID_EXCEPTION);
+  TEST_f_f (sqrt, nan_value, nan_value);
+
+  TEST_f_f (sqrt, 2209, 47);
+  TEST_f_f (sqrt, 4, 2);
+  TEST_f_f (sqrt, 2, M_SQRT2l);
+  TEST_f_f (sqrt, 0.25, 0.5);
+  TEST_f_f (sqrt, 6642.25, 81.5);
+  TEST_f_f (sqrt, 15190.5625L, 123.25L);
+  TEST_f_f (sqrt, 0.75L, 0.866025403784438646763723170752936183L);
+
+  END (sqrt);
+}
+
+
+static void
+tan_test (void)
+{
+  errno = 0;
+  FUNC(tan) (0);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (tan);
+
+  TEST_f_f (tan, 0, 0);
+  TEST_f_f (tan, minus_zero, minus_zero);
+  TEST_f_f (tan, plus_infty, nan_value, INVALID_EXCEPTION);
+  TEST_f_f (tan, minus_infty, nan_value, INVALID_EXCEPTION);
+  TEST_f_f (tan, nan_value, nan_value);
+
+  TEST_f_f (tan, M_PI_4l, 1);
+  TEST_f_f (tan, 0.75L, 0.931596459944072461165202756573936428L);
+
+  END (tan);
+}
+
+static void
+tanh_test (void)
+{
+  errno = 0;
+  FUNC(tanh) (0.7L);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (tanh);
+
+  TEST_f_f (tanh, 0, 0);
+  TEST_f_f (tanh, minus_zero, minus_zero);
+
+#ifndef TEST_INLINE
+  TEST_f_f (tanh, plus_infty, 1);
+  TEST_f_f (tanh, minus_infty, -1);
+#endif
+  TEST_f_f (tanh, nan_value, nan_value);
+
+  TEST_f_f (tanh, 0.75L, 0.635148952387287319214434357312496495L);
+  TEST_f_f (tanh, -0.75L, -0.635148952387287319214434357312496495L);
+
+  TEST_f_f (tanh, 1.0L, 0.7615941559557648881194582826047935904L);
+  TEST_f_f (tanh, -1.0L, -0.7615941559557648881194582826047935904L);
+
+  /* 2^-57  */
+  TEST_f_f (tanh, 0x1p-57L, 6.938893903907228377647697925567626953125e-18L);
+
+  END (tanh);
+}
+
+static void
+tgamma_test (void)
+{
+  errno = 0;
+  FUNC(tgamma) (1);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+  feclearexcept (FE_ALL_EXCEPT);
+
+  START (tgamma);
+
+  TEST_f_f (tgamma, plus_infty, plus_infty);
+  TEST_f_f (tgamma, 0, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+  TEST_f_f (tgamma, minus_zero, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+  /* tgamma (x) == NaN plus invalid exception for integer x <= 0.  */
+  TEST_f_f (tgamma, -2, nan_value, INVALID_EXCEPTION);
+  TEST_f_f (tgamma, minus_infty, nan_value, INVALID_EXCEPTION);
+  TEST_f_f (tgamma, nan_value, nan_value);
+
+  TEST_f_f (tgamma, 0.5, M_SQRT_PIl);
+  TEST_f_f (tgamma, -0.5, -M_2_SQRT_PIl);
+
+  TEST_f_f (tgamma, 1, 1);
+  TEST_f_f (tgamma, 4, 6);
+
+  TEST_f_f (tgamma, 0.7L, 1.29805533264755778568117117915281162L);
+  TEST_f_f (tgamma, 1.2L, 0.918168742399760610640951655185830401L);
+
+  END (tgamma);
+}
+
+
+static void
+trunc_test (void)
+{
+  START (trunc);
+
+  TEST_f_f (trunc, plus_infty, plus_infty);
+  TEST_f_f (trunc, minus_infty, minus_infty);
+  TEST_f_f (trunc, nan_value, nan_value);
+
+  TEST_f_f (trunc, 0, 0);
+  TEST_f_f (trunc, minus_zero, minus_zero);
+  TEST_f_f (trunc, 0.625, 0);
+  TEST_f_f (trunc, -0.625, minus_zero);
+  TEST_f_f (trunc, 1, 1);
+  TEST_f_f (trunc, -1, -1);
+  TEST_f_f (trunc, 1.625, 1);
+  TEST_f_f (trunc, -1.625, -1);
+
+  TEST_f_f (trunc, 1048580.625L, 1048580L);
+  TEST_f_f (trunc, -1048580.625L, -1048580L);
+
+  TEST_f_f (trunc, 8388610.125L, 8388610.0L);
+  TEST_f_f (trunc, -8388610.125L, -8388610.0L);
+
+  TEST_f_f (trunc, 4294967296.625L, 4294967296.0L);
+  TEST_f_f (trunc, -4294967296.625L, -4294967296.0L);
+
+
+  END (trunc);
+}
+
+static void
+y0_test (void)
+{
+  FLOAT s, c;
+  errno = 0;
+  FUNC (sincos) (0, &s, &c);
+  if (errno == ENOSYS)
+    /* Required function not implemented.  */
+    return;
+  FUNC(y0) (1);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  /* y0 is the Bessel function of the second kind of order 0 */
+  START (y0);
+
+  TEST_f_f (y0, -1.0, minus_infty, INVALID_EXCEPTION);
+  TEST_f_f (y0, 0.0, minus_infty);
+  TEST_f_f (y0, nan_value, nan_value);
+  TEST_f_f (y0, plus_infty, 0);
+
+  TEST_f_f (y0, 0.125L, -1.38968062514384052915582277745018693L);
+  TEST_f_f (y0, 0.75L, -0.137172769385772397522814379396581855L);
+  TEST_f_f (y0, 1.0, 0.0882569642156769579829267660235151628L);
+  TEST_f_f (y0, 1.5, 0.382448923797758843955068554978089862L);
+  TEST_f_f (y0, 2.0, 0.510375672649745119596606592727157873L);
+  TEST_f_f (y0, 8.0, 0.223521489387566220527323400498620359L);
+  TEST_f_f (y0, 10.0, 0.0556711672835993914244598774101900481L);
+
+  END (y0);
+}
+
+
+static void
+y1_test (void)
+{
+  FLOAT s, c;
+  errno = 0;
+  FUNC (sincos) (0, &s, &c);
+  if (errno == ENOSYS)
+    /* Required function not implemented.  */
+    return;
+  FUNC(y1) (1);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  /* y1 is the Bessel function of the second kind of order 1 */
+  START (y1);
+
+  TEST_f_f (y1, -1.0, minus_infty, INVALID_EXCEPTION);
+  TEST_f_f (y1, 0.0, minus_infty);
+  TEST_f_f (y1, plus_infty, 0);
+  TEST_f_f (y1, nan_value, nan_value);
+
+  TEST_f_f (y1, 0.125L, -5.19993611253477499595928744876579921L);
+  TEST_f_f (y1, 0.75L, -1.03759455076928541973767132140642198L);
+  TEST_f_f (y1, 1.0, -0.781212821300288716547150000047964821L);
+  TEST_f_f (y1, 1.5, -0.412308626973911295952829820633445323L);
+  TEST_f_f (y1, 2.0, -0.107032431540937546888370772277476637L);
+  TEST_f_f (y1, 8.0, -0.158060461731247494255555266187483550L);
+  TEST_f_f (y1, 10.0, 0.249015424206953883923283474663222803L);
+
+  END (y1);
+}
+
+
+static void
+yn_test (void)
+{
+  FLOAT s, c;
+  errno = 0;
+  FUNC (sincos) (0, &s, &c);
+  if (errno == ENOSYS)
+    /* Required function not implemented.  */
+    return;
+  FUNC(yn) (1, 1);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  /* yn is the Bessel function of the second kind of order n */
+  START (yn);
+
+  /* yn (0, x) == y0 (x)  */
+  TEST_ff_f (yn, 0, -1.0, minus_infty, INVALID_EXCEPTION);
+  TEST_ff_f (yn, 0, 0.0, minus_infty);
+  TEST_ff_f (yn, 0, nan_value, nan_value);
+  TEST_ff_f (yn, 0, plus_infty, 0);
+
+  TEST_ff_f (yn, 0, 0.125L, -1.38968062514384052915582277745018693L);
+  TEST_ff_f (yn, 0, 0.75L, -0.137172769385772397522814379396581855L);
+  TEST_ff_f (yn, 0, 1.0, 0.0882569642156769579829267660235151628L);
+  TEST_ff_f (yn, 0, 1.5, 0.382448923797758843955068554978089862L);
+  TEST_ff_f (yn, 0, 2.0, 0.510375672649745119596606592727157873L);
+  TEST_ff_f (yn, 0, 8.0, 0.223521489387566220527323400498620359L);
+  TEST_ff_f (yn, 0, 10.0, 0.0556711672835993914244598774101900481L);
+
+  /* yn (1, x) == y1 (x)  */
+  TEST_ff_f (yn, 1, -1.0, minus_infty, INVALID_EXCEPTION);
+  TEST_ff_f (yn, 1, 0.0, minus_infty);
+  TEST_ff_f (yn, 1, plus_infty, 0);
+  TEST_ff_f (yn, 1, nan_value, nan_value);
+
+  TEST_ff_f (yn, 1, 0.125L, -5.19993611253477499595928744876579921L);
+  TEST_ff_f (yn, 1, 0.75L, -1.03759455076928541973767132140642198L);
+  TEST_ff_f (yn, 1, 1.0, -0.781212821300288716547150000047964821L);
+  TEST_ff_f (yn, 1, 1.5, -0.412308626973911295952829820633445323L);
+  TEST_ff_f (yn, 1, 2.0, -0.107032431540937546888370772277476637L);
+  TEST_ff_f (yn, 1, 8.0, -0.158060461731247494255555266187483550L);
+  TEST_ff_f (yn, 1, 10.0, 0.249015424206953883923283474663222803L);
+
+  /* yn (3, x)  */
+  TEST_ff_f (yn, 3, plus_infty, 0);
+  TEST_ff_f (yn, 3, nan_value, nan_value);
+
+  TEST_ff_f (yn, 3, 0.125L, -2612.69757350066712600220955744091741L);
+  TEST_ff_f (yn, 3, 0.75L, -12.9877176234475433186319774484809207L);
+  TEST_ff_f (yn, 3, 1.0, -5.82151760596472884776175706442981440L);
+  TEST_ff_f (yn, 3, 2.0, -1.12778377684042778608158395773179238L);
+  TEST_ff_f (yn, 3, 10.0, -0.251362657183837329779204747654240998L);
+
+  /* yn (10, x)  */
+  TEST_ff_f (yn, 10, plus_infty, 0);
+  TEST_ff_f (yn, 10, nan_value, nan_value);
+
+  TEST_ff_f (yn, 10, 0.125L, -127057845771019398.252538486899753195L);
+  TEST_ff_f (yn, 10, 0.75L, -2133501638.90573424452445412893839236L);
+  TEST_ff_f (yn, 10, 1.0, -121618014.278689189288130426667971145L);
+  TEST_ff_f (yn, 10, 2.0, -129184.542208039282635913145923304214L);
+  TEST_ff_f (yn, 10, 10.0, -0.359814152183402722051986577343560609L);
+
+  END (yn);
+
+}
+
+
+static void
+significand_test (void)
+{
+  /* significand returns the mantissa of the exponential representation.  */
+  START (significand);
+
+  TEST_f_f (significand, 4.0, 1.0);
+  TEST_f_f (significand, 6.0, 1.5);
+  TEST_f_f (significand, 8.0, 1.0);
+
+  END (significand);
+}
+
+
+static void
+initialize (void)
+{
+  fpstack_test ("start *init*");
+  plus_zero = 0.0;
+  nan_value = plus_zero / plus_zero;	/* Suppress GCC warning */
+
+  minus_zero = FUNC(copysign) (0.0, -1.0);
+  plus_infty = CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF,
+		       HUGE_VALL, HUGE_VAL, HUGE_VALF);
+  minus_infty = CHOOSE (-HUGE_VALL, -HUGE_VAL, -HUGE_VALF,
+			-HUGE_VALL, -HUGE_VAL, -HUGE_VALF);
+  max_value = CHOOSE (LDBL_MAX, DBL_MAX, FLT_MAX,
+		      LDBL_MAX, DBL_MAX, FLT_MAX);
+  min_value = CHOOSE (LDBL_MIN, DBL_MIN, FLT_MIN,
+		      LDBL_MIN, DBL_MIN, FLT_MIN);
+
+  (void) &plus_zero;
+  (void) &nan_value;
+  (void) &minus_zero;
+  (void) &plus_infty;
+  (void) &minus_infty;
+  (void) &max_value;
+  (void) &min_value;
+
+  /* Clear all exceptions.  From now on we must not get random exceptions.  */
+  feclearexcept (FE_ALL_EXCEPT);
+
+  /* Test to make sure we start correctly.  */
+  fpstack_test ("end *init*");
+}
+
+/* Definitions of arguments for argp functions.  */
+static const struct argp_option options[] =
+{
+  { "verbose", 'v', "NUMBER", 0, "Level of verbosity (0..3)"},
+  { "ulps-file", 'u', NULL, 0, "Output ulps to file ULPs"},
+  { "no-max-error", 'f', NULL, 0,
+    "Don't output maximal errors of functions"},
+  { "no-points", 'p', NULL, 0,
+    "Don't output results of functions invocations"},
+  { "ignore-max-ulp", 'i', "yes/no", 0,
+    "Ignore given maximal errors"},
+  { NULL, 0, NULL, 0, NULL }
+};
+
+/* Short description of program.  */
+static const char doc[] = "Math test suite: " TEST_MSG ;
+
+/* Prototype for option handler.  */
+static error_t parse_opt (int key, char *arg, struct argp_state *state);
+
+/* Data structure to communicate with argp functions.  */
+static struct argp argp =
+{
+  options, parse_opt, NULL, doc,
+};
+
+
+/* Handle program arguments.  */
+static error_t
+parse_opt (int key, char *arg, struct argp_state *state)
+{
+  switch (key)
+    {
+    case 'f':
+      output_max_error = 0;
+      break;
+    case 'i':
+      if (strcmp (arg, "yes") == 0)
+	ignore_max_ulp = 1;
+      else if (strcmp (arg, "no") == 0)
+	ignore_max_ulp = 0;
+      break;
+    case 'p':
+      output_points = 0;
+      break;
+    case 'u':
+      output_ulps = 1;
+      break;
+    case 'v':
+      if (optarg)
+	verbose = (unsigned int) strtoul (optarg, NULL, 0);
+      else
+	verbose = 3;
+      break;
+    default:
+      return ARGP_ERR_UNKNOWN;
+    }
+  return 0;
+}
+
+#if 0
+/* function to check our ulp calculation.  */
+void
+check_ulp (void)
+{
+  int i;
+
+  FLOAT u, diff, ulp;
+  /* This gives one ulp.  */
+  u = FUNC(nextafter) (10, 20);
+  check_equal (10.0, u, 1, &diff, &ulp);
+  printf ("One ulp: % .4" PRINTF_NEXPR "\n", ulp);
+
+  /* This gives one more ulp.  */
+  u = FUNC(nextafter) (u, 20);
+  check_equal (10.0, u, 2, &diff, &ulp);
+  printf ("two ulp: % .4" PRINTF_NEXPR "\n", ulp);
+
+  /* And now calculate 100 ulp.  */
+  for (i = 2; i < 100; i++)
+    u = FUNC(nextafter) (u, 20);
+  check_equal (10.0, u, 100, &diff, &ulp);
+  printf ("100 ulp: % .4" PRINTF_NEXPR "\n", ulp);
+}
+#endif
+
+int
+main (int argc, char **argv)
+{
+
+  int remaining;
+
+  verbose = 1;
+  output_ulps = 0;
+  output_max_error = 1;
+  output_points = 1;
+  /* XXX set to 0 for releases.  */
+  ignore_max_ulp = 0;
+
+  /* Parse and process arguments.  */
+  argp_parse (&argp, argc, argv, 0, &remaining, NULL);
+
+  if (remaining != argc)
+    {
+      fprintf (stderr, "wrong number of arguments");
+      argp_help (&argp, stdout, ARGP_HELP_SEE, program_invocation_short_name);
+      exit (EXIT_FAILURE);
+    }
+
+  if (output_ulps)
+    {
+      ulps_file = fopen ("ULPs", "a");
+      if (ulps_file == NULL)
+	{
+	  perror ("can't open file `ULPs' for writing: ");
+	  exit (1);
+	}
+    }
+
+
+  initialize ();
+  printf (TEST_MSG);
+
+#if 0
+  check_ulp ();
+#endif
+
+  /* Keep the tests a wee bit ordered (according to ISO C99).  */
+  /* Classification macros:  */
+  fpclassify_test ();
+  isfinite_test ();
+  isnormal_test ();
+  signbit_test ();
+
+  /* Trigonometric functions:  */
+  acos_test ();
+  asin_test ();
+  atan_test ();
+  atan2_test ();
+  cos_test ();
+  sin_test ();
+  sincos_test ();
+  tan_test ();
+
+  /* Hyperbolic functions:  */
+  acosh_test ();
+  asinh_test ();
+  atanh_test ();
+  cosh_test ();
+  sinh_test ();
+  tanh_test ();
+
+  /* Exponential and logarithmic functions:  */
+  exp_test ();
+  exp10_test ();
+  exp2_test ();
+  expm1_test ();
+  frexp_test ();
+  ldexp_test ();
+  log_test ();
+  log10_test ();
+  log1p_test ();
+  log2_test ();
+  logb_test ();
+  modf_test ();
+  ilogb_test ();
+  scalb_test ();
+  scalbn_test ();
+  scalbln_test ();
+  significand_test ();
+
+  /* Power and absolute value functions:  */
+  cbrt_test ();
+  fabs_test ();
+  hypot_test ();
+  pow_test ();
+  sqrt_test ();
+
+  /* Error and gamma functions:  */
+  erf_test ();
+  erfc_test ();
+  gamma_test ();
+  lgamma_test ();
+  tgamma_test ();
+
+  /* Nearest integer functions:  */
+  ceil_test ();
+  floor_test ();
+  nearbyint_test ();
+  rint_test ();
+  rint_test_tonearest ();
+  rint_test_towardzero ();
+  rint_test_downward ();
+  rint_test_upward ();
+  lrint_test ();
+  llrint_test ();
+  round_test ();
+  lround_test ();
+  llround_test ();
+  trunc_test ();
+
+  /* Remainder functions:  */
+  fmod_test ();
+  remainder_test ();
+  remquo_test ();
+
+  /* Manipulation functions:  */
+  copysign_test ();
+  nextafter_test ();
+  nexttoward_test ();
+
+  /* maximum, minimum and positive difference functions */
+  fdim_test ();
+  fmax_test ();
+  fmin_test ();
+
+  /* Multiply and add:  */
+  fma_test ();
+
+  /* Complex functions:  */
+  cabs_test ();
+  cacos_test ();
+  cacosh_test ();
+  carg_test ();
+  casin_test ();
+  casinh_test ();
+  catan_test ();
+  catanh_test ();
+  ccos_test ();
+  ccosh_test ();
+  cexp_test ();
+  cimag_test ();
+  clog10_test ();
+  clog_test ();
+  conj_test ();
+  cpow_test ();
+  cproj_test ();
+  creal_test ();
+  csin_test ();
+  csinh_test ();
+  csqrt_test ();
+  ctan_test ();
+  ctanh_test ();
+
+  /* Bessel functions:  */
+  j0_test ();
+  j1_test ();
+  jn_test ();
+  y0_test ();
+  y1_test ();
+  yn_test ();
+
+  if (output_ulps)
+    fclose (ulps_file);
+
+  printf ("\nTest suite completed:\n");
+  printf ("  %d test cases plus %d tests for exception flags executed.\n",
+	  noTests, noExcTests);
+  if (noXFails)
+    printf ("  %d expected failures occurred.\n", noXFails);
+  if (noXPasses)
+    printf ("  %d unexpected passes occurred.\n", noXPasses);
+  if (noErrors)
+    {
+      printf ("  %d errors occurred.\n", noErrors);
+      return 1;
+    }
+  printf ("  All tests passed successfully.\n");
+
+  return 0;
+}
+
+/*
+ * Local Variables:
+ * mode:c
+ * End:
+ */
Index: trunk/src/libctests/glibc/math/test-double.c
===================================================================
--- trunk/src/libctests/glibc/math/test-double.c	(revision 2036)
+++ trunk/src/libctests/glibc/math/test-double.c	(revision 2036)
@@ -0,0 +1,34 @@
+/* Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@suse.de>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define FUNC(function) function
+#define FLOAT double
+#define TEST_MSG "testing double (without inline functions)\n"
+#define MATHCONST(x) x
+#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cdouble
+#define PRINTF_EXPR "e"
+#define PRINTF_XEXPR "a"
+#define PRINTF_NEXPR "f"
+#define TEST_DOUBLE 1
+
+#ifndef __NO_MATH_INLINES
+# define __NO_MATH_INLINES
+#endif
+
+#include "libm-test.c"
Index: trunk/src/libctests/glibc/math/test-fenv.c
===================================================================
--- trunk/src/libctests/glibc/math/test-fenv.c	(revision 2036)
+++ trunk/src/libctests/glibc/math/test-fenv.c	(revision 2036)
@@ -0,0 +1,665 @@
+/* Copyright (C) 1997, 1998, 2000, 2001, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@suse.de> and
+   Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* Tests for ISO C99 7.6: Floating-point environment  */
+
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE
+#endif
+
+#include <complex.h>
+#include <math.h>
+#include <float.h>
+#include <fenv.h>
+
+#include <errno.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/wait.h>
+#include <sys/resource.h>
+
+/*
+  Since not all architectures might define all exceptions, we define
+  a private set and map accordingly.
+*/
+#define NO_EXC 0
+#define INEXACT_EXC 0x1
+#define DIVBYZERO_EXC 0x2
+#define UNDERFLOW_EXC 0x04
+#define OVERFLOW_EXC 0x08
+#define INVALID_EXC 0x10
+#define ALL_EXC \
+        (INEXACT_EXC | DIVBYZERO_EXC | UNDERFLOW_EXC | OVERFLOW_EXC | \
+         INVALID_EXC)
+
+static int count_errors;
+
+/* Test whether a given exception was raised.  */
+static void
+test_single_exception (short int exception,
+                       short int exc_flag,
+                       fexcept_t fe_flag,
+                       const char *flag_name)
+{
+  if (exception & exc_flag)
+    {
+      if (fetestexcept (fe_flag))
+        printf ("  Pass: Exception \"%s\" is set\n", flag_name);
+      else
+        {
+          printf ("  Fail: Exception \"%s\" is not set\n", flag_name);
+          ++count_errors;
+        }
+    }
+  else
+    {
+      if (fetestexcept (fe_flag))
+        {
+          printf ("  Fail: Exception \"%s\" is set\n", flag_name);
+          ++count_errors;
+        }
+      else
+        {
+          printf ("  Pass: Exception \"%s\" is not set\n", flag_name);
+        }
+    }
+}
+
+static void
+test_exceptions (const char *test_name, short int exception,
+		 int ignore_inexact)
+{
+  printf ("Test: %s\n", test_name);
+#ifdef FE_DIVBYZERO
+  test_single_exception (exception, DIVBYZERO_EXC, FE_DIVBYZERO,
+                         "DIVBYZERO");
+#endif
+#ifdef FE_INVALID
+  test_single_exception (exception, INVALID_EXC, FE_INVALID,
+                         "INVALID");
+#endif
+#ifdef FE_INEXACT
+  if (!ignore_inexact)
+    test_single_exception (exception, INEXACT_EXC, FE_INEXACT,
+			   "INEXACT");
+#endif
+#ifdef FE_UNDERFLOW
+  test_single_exception (exception, UNDERFLOW_EXC, FE_UNDERFLOW,
+                         "UNDERFLOW");
+#endif
+#ifdef FE_OVERFLOW
+  test_single_exception (exception, OVERFLOW_EXC, FE_OVERFLOW,
+                         "OVERFLOW");
+#endif
+}
+
+static void
+print_rounding (int rounding)
+{
+
+  switch (rounding)
+    {
+#ifdef FE_TONEAREST
+    case FE_TONEAREST:
+      printf ("TONEAREST");
+      break;
+#endif
+#ifdef FE_UPWARD
+    case FE_UPWARD:
+      printf ("UPWARD");
+      break;
+#endif
+#ifdef FE_DOWNWARD
+    case FE_DOWNWARD:
+      printf ("DOWNWARD");
+      break;
+#endif
+#ifdef FE_TOWARDZERO
+    case FE_TOWARDZERO:
+      printf ("TOWARDZERO");
+      break;
+#endif
+    }
+  printf (".\n");
+}
+
+
+static void
+test_rounding (const char *test_name, int rounding_mode)
+{
+  int curr_rounding = fegetround ();
+
+  printf ("Test: %s\n", test_name);
+  if (curr_rounding == rounding_mode)
+    {
+      printf ("  Pass: Rounding mode is ");
+      print_rounding (curr_rounding);
+    }
+  else
+    {
+      ++count_errors;
+      printf ("  Fail: Rounding mode is ");
+      print_rounding (curr_rounding);
+    }
+}
+
+
+static void
+set_single_exc (const char *test_name, int fe_exc, fexcept_t exception)
+{
+  char str[200];
+  /* The standard allows the inexact exception to be set together with the
+     underflow and overflow exceptions.  So ignore the inexact flag if the
+     others are raised.  */
+  int ignore_inexact = (fe_exc & (UNDERFLOW_EXC | OVERFLOW_EXC)) != 0;
+
+  strcpy (str, test_name);
+  strcat (str, ": set flag, with rest not set");
+  feclearexcept (FE_ALL_EXCEPT);
+  feraiseexcept (exception);
+  test_exceptions (str, fe_exc, ignore_inexact);
+
+  strcpy (str, test_name);
+  strcat (str, ": clear flag, rest also unset");
+  feclearexcept (exception);
+  test_exceptions (str, NO_EXC, ignore_inexact);
+
+  strcpy (str, test_name);
+  strcat (str, ": set flag, with rest set");
+  feraiseexcept (FE_ALL_EXCEPT ^ exception);
+  feraiseexcept (exception);
+  test_exceptions (str, ALL_EXC, 0);
+
+  strcpy (str, test_name);
+  strcat (str, ": clear flag, leave rest set");
+  feclearexcept (exception);
+  test_exceptions (str, ALL_EXC ^ fe_exc, 0);
+}
+
+static void
+fe_tests (void)
+{
+  /* clear all exceptions and test if all are cleared */
+  feclearexcept (FE_ALL_EXCEPT);
+  test_exceptions ("feclearexcept (FE_ALL_EXCEPT) clears all exceptions",
+                   NO_EXC, 0);
+
+  /* raise all exceptions and test if all are raised */
+  feraiseexcept (FE_ALL_EXCEPT);
+  test_exceptions ("feraiseexcept (FE_ALL_EXCEPT) raises all exceptions",
+                   ALL_EXC, 0);
+  feclearexcept (FE_ALL_EXCEPT);
+
+#ifdef FE_DIVBYZERO
+  set_single_exc ("Set/Clear FE_DIVBYZERO", DIVBYZERO_EXC, FE_DIVBYZERO);
+#endif
+#ifdef FE_INVALID
+  set_single_exc ("Set/Clear FE_INVALID", INVALID_EXC, FE_INVALID);
+#endif
+#ifdef FE_INEXACT
+  set_single_exc ("Set/Clear FE_INEXACT", INEXACT_EXC, FE_INEXACT);
+#endif
+#ifdef FE_UNDERFLOW
+  set_single_exc ("Set/Clear FE_UNDERFLOW", UNDERFLOW_EXC, FE_UNDERFLOW);
+#endif
+#ifdef FE_OVERFLOW
+  set_single_exc ("Set/Clear FE_OVERFLOW", OVERFLOW_EXC, FE_OVERFLOW);
+#endif
+}
+
+/* Test that program aborts with no masked interrupts */
+static void
+feenv_nomask_test (const char *flag_name, int fe_exc)
+{
+#if defined FE_NOMASK_ENV
+  int status;
+  pid_t pid;
+  fenv_t saved;
+
+  fegetenv (&saved);
+  errno = 0;
+  fesetenv (FE_NOMASK_ENV);
+  status = errno;
+  fesetenv (&saved);
+  if (status == ENOSYS)
+    {
+      printf ("Test: not testing FE_NOMASK_ENV, it isn't implemented.\n");
+      return;
+    }
+
+  printf ("Test: after fesetenv (FE_NOMASK_ENV) processes will abort\n");
+  printf ("      when feraiseexcept (%s) is called.\n", flag_name);
+  pid = fork ();
+  if (pid == 0)
+    {
+#ifdef RLIMIT_CORE
+      /* Try to avoid dumping core.  */
+      struct rlimit core_limit;
+      core_limit.rlim_cur = 0;
+      core_limit.rlim_max = 0;
+      setrlimit (RLIMIT_CORE, &core_limit);
+#endif
+
+      fesetenv (FE_NOMASK_ENV);
+      feraiseexcept (fe_exc);
+      exit (2);
+    }
+  else if (pid < 0)
+    {
+      if (errno != ENOSYS)
+	{
+	  printf ("  Fail: Could not fork.\n");
+	  ++count_errors;
+	}
+      else
+	printf ("  `fork' not implemented, test ignored.\n");
+    }
+  else {
+    if (waitpid (pid, &status, 0) != pid)
+      {
+	printf ("  Fail: waitpid call failed.\n");
+	++count_errors;
+      }
+    else if (WIFSIGNALED (status) && WTERMSIG (status) == SIGFPE)
+      printf ("  Pass: Process received SIGFPE.\n");
+    else
+      {
+	printf ("  Fail: Process didn't receive signal and exited with status %d.\n",
+		status);
+	++count_errors;
+      }
+  }
+#endif
+}
+
+/* Test that program doesn't abort with default environment */
+static void
+feenv_mask_test (const char *flag_name, int fe_exc)
+{
+  int status;
+  pid_t pid;
+
+  printf ("Test: after fesetenv (FE_DFL_ENV) processes will not abort\n");
+  printf ("      when feraiseexcept (%s) is called.\n", flag_name);
+  pid = fork ();
+  if (pid == 0)
+    {
+#ifdef RLIMIT_CORE
+      /* Try to avoid dumping core.  */
+      struct rlimit core_limit;
+      core_limit.rlim_cur = 0;
+      core_limit.rlim_max = 0;
+      setrlimit (RLIMIT_CORE, &core_limit);
+#endif
+
+      fesetenv (FE_DFL_ENV);
+      feraiseexcept (fe_exc);
+      exit (2);
+    }
+  else if (pid < 0)
+    {
+      if (errno != ENOSYS)
+	{
+	  printf ("  Fail: Could not fork.\n");
+	  ++count_errors;
+	}
+      else
+	printf ("  `fork' not implemented, test ignored.\n");
+    }
+  else {
+    if (waitpid (pid, &status, 0) != pid)
+      {
+	printf ("  Fail: waitpid call failed.\n");
+	++count_errors;
+      }
+    else if (WIFEXITED (status) && WEXITSTATUS (status) == 2)
+      printf ("  Pass: Process exited normally.\n");
+    else
+      {
+	printf ("  Fail: Process exited abnormally with status %d.\n",
+		status);
+	++count_errors;
+      }
+  }
+}
+
+/* Test that program aborts with no masked interrupts */
+static void
+feexcp_nomask_test (const char *flag_name, int fe_exc)
+{
+  int status;
+  pid_t pid;
+
+  printf ("Test: after fedisableexcept (%s) processes will abort\n",
+	  flag_name);
+  printf ("      when feraiseexcept (%s) is called.\n", flag_name);
+  pid = fork ();
+  if (pid == 0)
+    {
+#ifdef RLIMIT_CORE
+      /* Try to avoid dumping core.  */
+      struct rlimit core_limit;
+      core_limit.rlim_cur = 0;
+      core_limit.rlim_max = 0;
+      setrlimit (RLIMIT_CORE, &core_limit);
+#endif
+
+      fedisableexcept (FE_ALL_EXCEPT);
+      feenableexcept (fe_exc);
+      feraiseexcept (fe_exc);
+      exit (2);
+    }
+  else if (pid < 0)
+    {
+      if (errno != ENOSYS)
+	{
+	  printf ("  Fail: Could not fork.\n");
+	  ++count_errors;
+	}
+      else
+	printf ("  `fork' not implemented, test ignored.\n");
+    }
+  else {
+    if (waitpid (pid, &status, 0) != pid)
+      {
+	printf ("  Fail: waitpid call failed.\n");
+	++count_errors;
+      }
+    else if (WIFSIGNALED (status) && WTERMSIG (status) == SIGFPE)
+      printf ("  Pass: Process received SIGFPE.\n");
+    else
+      {
+	printf ("  Fail: Process didn't receive signal and exited with status %d.\n",
+		status);
+	++count_errors;
+      }
+  }
+}
+
+/* Test that program doesn't abort with exception.  */
+static void
+feexcp_mask_test (const char *flag_name, int fe_exc)
+{
+  int status;
+  int exception;
+  pid_t pid;
+
+  printf ("Test: after fedisableexcept (%s) processes will not abort\n",
+	  flag_name);
+  printf ("      when feraiseexcept (%s) is called.\n", flag_name);
+  pid = fork ();
+  if (pid == 0)
+    {
+#ifdef RLIMIT_CORE
+      /* Try to avoid dumping core.  */
+      struct rlimit core_limit;
+      core_limit.rlim_cur = 0;
+      core_limit.rlim_max = 0;
+      setrlimit (RLIMIT_CORE, &core_limit);
+#endif
+      feenableexcept (FE_ALL_EXCEPT);
+      exception = fe_exc;
+#ifdef FE_INEXACT
+      /* The standard allows the inexact exception to be set together with the
+	 underflow and overflow exceptions.  So add FE_INEXACT to the set of
+	 exceptions to be disabled if we will be raising underflow or
+	 overflow.  */
+# ifdef FE_OVERFLOW
+      if (fe_exc & FE_OVERFLOW)
+	exception |= FE_INEXACT;
+# endif
+# ifdef FE_UNDERFLOW
+      if (fe_exc & FE_UNDERFLOW)
+	exception |= FE_INEXACT;
+# endif
+#endif
+      fedisableexcept (exception);
+      feraiseexcept (fe_exc);
+      exit (2);
+    }
+  else if (pid < 0)
+    {
+      if (errno != ENOSYS)
+	{
+	  printf ("  Fail: Could not fork.\n");
+	  ++count_errors;
+	}
+      else
+	printf ("  `fork' not implemented, test ignored.\n");
+    }
+  else {
+    if (waitpid (pid, &status, 0) != pid)
+      {
+	printf ("  Fail: waitpid call failed.\n");
+	++count_errors;
+      }
+    else if (WIFEXITED (status) && WEXITSTATUS (status) == 2)
+      printf ("  Pass: Process exited normally.\n");
+    else
+      {
+	printf ("  Fail: Process exited abnormally with status %d.\n",
+		status);
+	++count_errors;
+      }
+  }
+}
+
+
+/* Tests for feenableexcept/fedisableexcept/fegetexcept.  */
+static void
+feenable_test (const char *flag_name, int fe_exc)
+{
+  int excepts;
+
+
+  printf ("Tests for feenableexcepts etc. with flag %s\n", flag_name);
+
+  /* First disable all exceptions.  */
+  if (fedisableexcept (FE_ALL_EXCEPT) == -1)
+    {
+      printf ("Test: fedisableexcept (FE_ALL_EXCEPT) failed\n");
+      ++count_errors;
+      /* If this fails, the other tests don't make sense.  */
+      return;
+    }
+  excepts = fegetexcept ();
+  if (excepts != 0)
+    {
+      printf ("Test: fegetexcept (%s) failed, return should be 0, is %d\n",
+	      flag_name, excepts);
+      ++count_errors;
+    }
+
+  excepts = feenableexcept (fe_exc);
+  if (excepts == -1)
+    {
+      printf ("Test: feenableexcept (%s) failed\n", flag_name);
+      ++count_errors;
+      return;
+    }
+  if (excepts != 0)
+    {
+      printf ("Test: feenableexcept (%s) failed, return should be 0, is %x\n",
+	      flag_name, excepts);
+      ++count_errors;
+    }
+
+  excepts = fegetexcept ();
+  if (excepts != fe_exc)
+    {
+      printf ("Test: fegetexcept (%s) failed, return should be 0x%x, is 0x%x\n",
+	      flag_name, fe_exc, excepts);
+      ++count_errors;
+    }
+
+  /* And now disable the exception again.  */
+  excepts = fedisableexcept (fe_exc);
+  if (excepts == -1)
+    {
+      printf ("Test: fedisableexcept (%s) failed\n", flag_name);
+      ++count_errors;
+      return;
+    }
+  if (excepts != fe_exc)
+    {
+      printf ("Test: fedisableexcept (%s) failed, return should be 0x%x, is 0x%x\n",
+	      flag_name, fe_exc, excepts);
+      ++count_errors;
+    }
+
+  excepts = fegetexcept ();
+  if (excepts != 0)
+    {
+      printf ("Test: fegetexcept (%s) failed, return should be 0, is 0x%x\n",
+	      flag_name, excepts);
+      ++count_errors;
+    }
+
+  /* Now the other way round: Enable all exceptions and disable just this one.  */
+  if (feenableexcept (FE_ALL_EXCEPT) == -1)
+    {
+      printf ("Test: feenableexcept (FE_ALL_EXCEPT) failed\n");
+      ++count_errors;
+      /* If this fails, the other tests don't make sense.  */
+      return;
+    }
+
+  excepts = fegetexcept ();
+  if (excepts != FE_ALL_EXCEPT)
+    {
+      printf ("Test: fegetexcept (%s) failed, return should be 0x%x, is 0x%x\n",
+	      flag_name, FE_ALL_EXCEPT, excepts);
+      ++count_errors;
+    }
+
+  excepts = fedisableexcept (fe_exc);
+  if (excepts == -1)
+    {
+      printf ("Test: fedisableexcept (%s) failed\n", flag_name);
+      ++count_errors;
+      return;
+    }
+  if (excepts != FE_ALL_EXCEPT)
+    {
+      printf ("Test: fedisableexcept (%s) failed, return should be 0, is 0x%x\n",
+	      flag_name, excepts);
+      ++count_errors;
+    }
+
+  excepts = fegetexcept ();
+  if (excepts != (FE_ALL_EXCEPT & ~fe_exc))
+    {
+      printf ("Test: fegetexcept (%s) failed, return should be 0x%x, is 0x%x\n",
+	      flag_name, (FE_ALL_EXCEPT & ~fe_exc), excepts);
+      ++count_errors;
+    }
+
+  /* And now enable the exception again.  */
+  excepts = feenableexcept (fe_exc);
+  if (excepts == -1)
+    {
+      printf ("Test: feenableexcept (%s) failed\n", flag_name);
+      ++count_errors;
+      return;
+    }
+  if (excepts != (FE_ALL_EXCEPT & ~fe_exc))
+    {
+      printf ("Test: feenableexcept (%s) failed, return should be 0, is 0x%x\n",
+	      flag_name, excepts);
+      ++count_errors;
+    }
+
+  excepts = fegetexcept ();
+  if (excepts != FE_ALL_EXCEPT)
+    {
+      printf ("Test: fegetexcept (%s) failed, return should be 0x%x, is 0x%x\n",
+	      flag_name, FE_ALL_EXCEPT, excepts);
+      ++count_errors;
+    }
+  feexcp_nomask_test (flag_name, fe_exc);
+  feexcp_mask_test (flag_name, fe_exc);
+
+}
+
+
+static void
+fe_single_test (const char *flag_name, int fe_exc)
+{
+  feenv_nomask_test (flag_name, fe_exc);
+  feenv_mask_test (flag_name, fe_exc);
+  feenable_test (flag_name, fe_exc);
+}
+
+
+static void
+feenv_tests (void)
+{
+  /* We might have some exceptions still set.  */
+  feclearexcept (FE_ALL_EXCEPT);
+
+#ifdef FE_DIVBYZERO
+  fe_single_test ("FE_DIVBYZERO", FE_DIVBYZERO);
+#endif
+#ifdef FE_INVALID
+  fe_single_test ("FE_INVALID", FE_INVALID);
+#endif
+#ifdef FE_INEXACT
+  fe_single_test ("FE_INEXACT", FE_INEXACT);
+#endif
+#ifdef FE_UNDERFLOW
+  fe_single_test ("FE_UNDERFLOW", FE_UNDERFLOW);
+#endif
+#ifdef FE_OVERFLOW
+  fe_single_test ("FE_OVERFLOW", FE_OVERFLOW);
+#endif
+  fesetenv (FE_DFL_ENV);
+}
+
+
+/* IEC 559 and ISO C99 define a default startup environment */
+static void
+initial_tests (void)
+{
+  test_exceptions ("Initially all exceptions should be cleared",
+                   NO_EXC, 0);
+#ifdef FE_TONEAREST
+  test_rounding ("Rounding direction should be initalized to nearest",
+                 FE_TONEAREST);
+#endif
+}
+
+int
+main (void)
+{
+  initial_tests ();
+  fe_tests ();
+  feenv_tests ();
+
+  if (count_errors)
+    {
+      printf ("\n%d errors occurred.\n", count_errors);
+      exit (1);
+    }
+  printf ("\n All tests passed successfully.\n");
+  return 0;
+}
Index: trunk/src/libctests/glibc/math/test-float.c
===================================================================
--- trunk/src/libctests/glibc/math/test-float.c	(revision 2036)
+++ trunk/src/libctests/glibc/math/test-float.c	(revision 2036)
@@ -0,0 +1,34 @@
+/* Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@suse.de>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define FUNC(function) function ## f
+#define FLOAT float
+#define TEST_MSG "testing float (without inline functions)\n"
+#define MATHCONST(x) x
+#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cfloat
+#define PRINTF_EXPR "e"
+#define PRINTF_XEXPR "a"
+#define PRINTF_NEXPR "f"
+#define TEST_FLOAT 1
+
+#ifndef __NO_MATH_INLINES
+# define __NO_MATH_INLINES
+#endif
+
+#include "libm-test.c"
Index: trunk/src/libctests/glibc/math/test-fpucw.c
===================================================================
--- trunk/src/libctests/glibc/math/test-fpucw.c	(revision 2036)
+++ trunk/src/libctests/glibc/math/test-fpucw.c	(revision 2036)
@@ -0,0 +1,43 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@suse.de>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <fpu_control.h>
+#include <stdio.h>
+
+int
+main (void)
+{
+#ifdef _FPU_GETCW
+/* Some architectures don't have _FPU_GETCW (e.g. Linux/Alpha).  */
+  fpu_control_t cw;
+
+  _FPU_GETCW (cw);
+
+  cw &= ~_FPU_RESERVED;
+
+  if (cw != (_FPU_DEFAULT & ~_FPU_RESERVED))
+    printf ("control word is 0x%lx but should be 0x%lx.\n",
+	    (long int) cw, (long int) (_FPU_DEFAULT & ~_FPU_RESERVED));
+
+  return cw != (_FPU_DEFAULT & ~_FPU_RESERVED);
+
+#else
+  return 0;
+#endif
+}
Index: trunk/src/libctests/glibc/math/test-idouble.c
===================================================================
--- trunk/src/libctests/glibc/math/test-idouble.c	(revision 2036)
+++ trunk/src/libctests/glibc/math/test-idouble.c	(revision 2036)
@@ -0,0 +1,35 @@
+/* Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@suse.de>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define FUNC(function) function
+#define FLOAT double
+#define TEST_MSG "testing double (inline functions)\n"
+#define MATHCONST(x) x
+#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cinlinedouble
+#define PRINTF_EXPR "e"
+#define PRINTF_XEXPR "a"
+#define PRINTF_NEXPR "f"
+#define TEST_DOUBLE 1
+#define TEST_INLINE
+
+#ifdef __NO_MATH_INLINES
+# undef __NO_MATH_INLINES
+#endif
+
+#include "libm-test.c"
Index: trunk/src/libctests/glibc/math/test-ifloat.c
===================================================================
--- trunk/src/libctests/glibc/math/test-ifloat.c	(revision 2036)
+++ trunk/src/libctests/glibc/math/test-ifloat.c	(revision 2036)
@@ -0,0 +1,35 @@
+/* Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@suse.de>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define FUNC(function) function ## f
+#define FLOAT float
+#define TEST_MSG "testing float (inline functions)\n"
+#define MATHCONST(x) x
+#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cinlinefloat
+#define PRINTF_EXPR "e"
+#define PRINTF_XEXPR "a"
+#define PRINTF_NEXPR "f"
+#define TEST_FLOAT 1
+#define TEST_INLINE 1
+
+#ifdef __NO_MATH_INLINES
+# undef __NO_MATH_INLINES
+#endif
+
+#include "libm-test.c"
Index: trunk/src/libctests/glibc/math/test-ildoubl.c
===================================================================
--- trunk/src/libctests/glibc/math/test-ildoubl.c	(revision 2036)
+++ trunk/src/libctests/glibc/math/test-ildoubl.c	(revision 2036)
@@ -0,0 +1,35 @@
+/* Copyright (C) 1997, 1999, 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@suse.de>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define FUNC(function) function##l
+#define FLOAT long double
+#define TEST_MSG "testing long double (inline functions)\n"
+#define MATHCONST(x) x##L
+#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cinlinelongdouble
+#define PRINTF_EXPR "Le"
+#define PRINTF_XEXPR "La"
+#define PRINTF_NEXPR "Lf"
+#define TEST_INLINE
+#define TEST_LDOUBLE 1
+
+#ifdef __NO_MATH_INLINES
+# undef __NO_MATH_INLINES
+#endif
+
+#include "libm-test.c"
Index: trunk/src/libctests/glibc/math/test-ldouble.c
===================================================================
--- trunk/src/libctests/glibc/math/test-ldouble.c	(revision 2036)
+++ trunk/src/libctests/glibc/math/test-ldouble.c	(revision 2036)
@@ -0,0 +1,34 @@
+/* Copyright (C) 1997, 1999, 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@suse.de>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define FUNC(function) function##l
+#define FLOAT long double
+#define TEST_MSG "testing long double (without inline functions)\n"
+#define MATHCONST(x) x##L
+#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Clongdouble
+#define PRINTF_EXPR "Le"
+#define PRINTF_XEXPR "La"
+#define PRINTF_NEXPR "Lf"
+#define TEST_LDOUBLE 1
+
+#ifndef __NO_MATH_INLINES
+# define __NO_MATH_INLINES
+#endif
+
+#include "libm-test.c"
Index: trunk/src/libctests/glibc/math/test-matherr.c
===================================================================
--- trunk/src/libctests/glibc/math/test-matherr.c	(revision 2036)
+++ trunk/src/libctests/glibc/math/test-matherr.c	(revision 2036)
@@ -0,0 +1,23 @@
+#undef _SVID_SOURCE
+#define _SVID_SOURCE
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static int fail = 1;
+
+int
+matherr (struct exception *s)
+{
+  printf ("matherr is working\n");
+  fail = 0;
+  return 1;
+}
+
+int
+main (void)
+{
+  _LIB_VERSION = _SVID_;
+  acos (2.0);
+  return fail;
+}
Index: trunk/src/libctests/glibc/math/test-misc.c
===================================================================
--- trunk/src/libctests/glibc/math/test-misc.c	(revision 2036)
+++ trunk/src/libctests/glibc/math/test-misc.c	(revision 2036)
@@ -0,0 +1,1187 @@
+/* Miscellaneous tests which don't fit anywhere else.
+   Copyright (C) 2000, 2001, 2004, 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <fenv.h>
+#include <float.h>
+#include <ieee754.h>
+#include <math.h>
+#include <stdio.h>
+#include <string.h>
+
+
+int
+main (void)
+{
+  int result = 0;
+
+#ifndef NO_LONG_DOUBLE
+  {
+    long double x = 0x100000001ll + (long double) 0.5;
+    long double q;
+    long double r;
+
+    r = modfl (x, &q);
+    if (q != (long double) 0x100000001ll || r != 0.5)
+      {
+	printf ("modfl (%Lg, ...) failed\n", x);
+	result = 1;
+      }
+  }
+
+# if __GNUC__ >= 3 || __GNUC_MINOR__ >= 96
+  {
+    long double x;
+    long double m;
+    long double r;
+    int e;
+    int i;
+
+#  if LDBL_MANT_DIG == 64
+    m = 0xf.fffffffffffffffp-4L;
+#  elif LDBL_MANT_DIG == 106
+    /* This has to match the mantissa of LDBL_MAX which actually does have a
+       missing bit in the middle.  */
+    m = 0x1.fffffffffffff7ffffffffffff8p-1L;
+#  elif LDBL_MANT_DIG == 113
+    m = 0x1.ffffffffffffffffffffffffffffp-1L;
+#  else
+#   error "Please adjust"
+#  endif
+
+    for (i = LDBL_MAX_EXP, x = LDBL_MAX; i >= LDBL_MIN_EXP; --i, x /= 2.0L)
+      {
+	printf ("2^%d: ", i);
+
+	r = frexpl (x, &e);
+	if (r != m)
+	  {
+	    printf ("mantissa incorrect: %.20La\n", r);
+	    result = 1;
+	    continue;
+	  }
+	if (e != i)
+	  {
+	    printf ("exponent wrong %d (%.20Lg)\n", e, x);
+	    result = 1;
+	    continue;
+	  }
+	puts ("ok");
+      }
+
+    for (i = LDBL_MIN_EXP, x = LDBL_MIN; i >= LDBL_MIN_EXP - LDBL_MANT_DIG + 1;
+	 --i, x /= 2.0L)
+      {
+        printf ("2^%d: ", i);
+
+        r = frexpl (x, &e);
+        if (r != 0.5L)
+          {
+            printf ("mantissa incorrect: %.20La\n", r);
+            result = 1;
+            continue;
+          }
+        if (e != i)
+          {
+            printf ("exponent wrong %d (%.20Lg)\n", e, x);
+            result = 1;
+            continue;
+          }
+        puts ("ok");
+      }
+
+  }
+# endif
+
+#if 0
+  {
+    int e;
+    long double r = frexpl (LDBL_MIN * LDBL_EPSILON, &e);
+
+    if (r != 0.5)
+      {
+	printf ("frexpl (LDBL_MIN * LDBL_EPSILON, ...): mantissa wrong: %Lg\n",
+		r);
+	result = 1;
+      }
+    else if (e != -16444)
+      {
+	printf ("frexpl (LDBL_MIN * LDBL_EPSILON, ...): exponent wrong: %d\n",
+		e);
+	result = 1;
+      }
+  }
+#endif
+#endif
+
+  {
+    double x = 0x100000001ll + (double) 0.5;
+    double q;
+    double r;
+
+    r = modf (x, &q);
+    if (q != (double) 0x100000001ll || r != 0.5)
+      {
+	printf ("modf (%g, ...) failed\n", x);
+	result = 1;
+      }
+  }
+
+  {
+    union ieee754_float v1;
+    union ieee754_float v2;
+    float f;
+
+    v1.f = f = FLT_MIN;
+    if (fpclassify (f) != FP_NORMAL)
+      {
+	printf ("fpclassify (FLT_MIN) failed: %d\n", fpclassify (f));
+	result = 1;
+      }
+    f = nextafterf (f, FLT_MIN / 2.0f);
+    if (fpclassify (f) != FP_SUBNORMAL)
+      {
+	printf ("fpclassify (FLT_MIN-epsilon) failed: %d\n", fpclassify (f));
+	result = 1;
+      }
+    v2.f = f = nextafterf (f, FLT_MIN);
+    if (fpclassify (f) != FP_NORMAL)
+      {
+	printf ("fpclassify (FLT_MIN-epsilon+epsilon) failed: %d\n",
+		fpclassify (f));
+	result = 1;
+      }
+
+    if (v1.ieee.mantissa != v2.ieee.mantissa)
+      {
+	printf ("FLT_MIN: mantissa differs: %8x vs %8x\n",
+		v1.ieee.mantissa, v2.ieee.mantissa);
+	result = 1;
+      }
+    if (v1.ieee.exponent != v2.ieee.exponent)
+      {
+	printf ("FLT_MIN: exponent differs: %4x vs %4x\n",
+		v1.ieee.exponent, v2.ieee.exponent);
+	result = 1;
+      }
+    if (v1.ieee.negative != v2.ieee.negative)
+      {
+	printf ("FLT_MIN: negative differs: %d vs %d\n",
+		v1.ieee.negative, v2.ieee.negative);
+	result = 1;
+      }
+
+    v1.f = f = -FLT_MIN;
+    if (fpclassify (f) != FP_NORMAL)
+      {
+	printf ("fpclassify (-FLT_MIN) failed: %d\n", fpclassify (f));
+	result = 1;
+      }
+    f = nextafterf (f, -FLT_MIN / 2.0f);
+    if (fpclassify (f) != FP_SUBNORMAL)
+      {
+	printf ("fpclassify (-FLT_MIN-epsilon) failed: %d\n", fpclassify (f));
+	result = 1;
+      }
+    v2.f = f = nextafterf (f, -FLT_MIN);
+    if (fpclassify (f) != FP_NORMAL)
+      {
+	printf ("fpclassify (-FLT_MIN-epsilon+epsilon) failed: %d\n",
+		fpclassify (f));
+	result = 1;
+      }
+
+    if (v1.ieee.mantissa != v2.ieee.mantissa)
+      {
+	printf ("-FLT_MIN: mantissa differs: %8x vs %8x\n",
+		v1.ieee.mantissa, v2.ieee.mantissa);
+	result = 1;
+      }
+    if (v1.ieee.exponent != v2.ieee.exponent)
+      {
+	printf ("-FLT_MIN: exponent differs: %4x vs %4x\n",
+		v1.ieee.exponent, v2.ieee.exponent);
+	result = 1;
+      }
+    if (v1.ieee.negative != v2.ieee.negative)
+      {
+	printf ("-FLT_MIN: negative differs: %d vs %d\n",
+		v1.ieee.negative, v2.ieee.negative);
+	result = 1;
+      }
+
+    f = FLT_MAX;
+    if (fpclassify (f) != FP_NORMAL)
+      {
+	printf ("fpclassify (FLT_MAX) failed: %d\n", fpclassify (f));
+	result = 1;
+      }
+    f = nextafterf (f, INFINITY);
+    if (fpclassify (f) != FP_INFINITE)
+      {
+	printf ("fpclassify (FLT_MAX+epsilon) failed: %d\n", fpclassify (f));
+	result = 1;
+      }
+
+    f = -FLT_MAX;
+    if (fpclassify (f) != FP_NORMAL)
+      {
+	printf ("fpclassify (-FLT_MAX) failed: %d\n", fpclassify (f));
+	result = 1;
+      }
+    f = nextafterf (f, -INFINITY);
+    if (fpclassify (f) != FP_INFINITE)
+      {
+	printf ("fpclassify (-FLT_MAX-epsilon) failed: %d\n", fpclassify (f));
+	result = 1;
+      }
+
+    v1.f = f = 0.0625;
+    f = nextafterf (f, 0.0);
+    v2.f = f = nextafterf (f, 1.0);
+
+    if (v1.ieee.mantissa != v2.ieee.mantissa)
+      {
+	printf ("0.0625f down: mantissa differs: %8x vs %8x\n",
+		v1.ieee.mantissa, v2.ieee.mantissa);
+	result = 1;
+      }
+    if (v1.ieee.exponent != v2.ieee.exponent)
+      {
+	printf ("0.0625f down: exponent differs: %4x vs %4x\n",
+		v1.ieee.exponent, v2.ieee.exponent);
+	result = 1;
+      }
+    if (v1.ieee.negative != v2.ieee.negative)
+      {
+	printf ("0.0625f down: negative differs: %d vs %d\n",
+		v1.ieee.negative, v2.ieee.negative);
+	result = 1;
+      }
+
+    v1.f = f = 0.0625;
+    f = nextafterf (f, 1.0);
+    v2.f = f = nextafterf (f, 0.0);
+
+    if (v1.ieee.mantissa != v2.ieee.mantissa)
+      {
+	printf ("0.0625f up: mantissa differs: %8x vs %8x\n",
+		v1.ieee.mantissa, v2.ieee.mantissa);
+	result = 1;
+      }
+    if (v1.ieee.exponent != v2.ieee.exponent)
+      {
+	printf ("0.0625f up: exponent differs: %4x vs %4x\n",
+		v1.ieee.exponent, v2.ieee.exponent);
+	result = 1;
+      }
+    if (v1.ieee.negative != v2.ieee.negative)
+      {
+	printf ("0.0625f up: negative differs: %d vs %d\n",
+		v1.ieee.negative, v2.ieee.negative);
+	result = 1;
+      }
+
+    v1.f = f = -0.0625;
+    f = nextafterf (f, 0.0);
+    v2.f = f = nextafterf (f, -1.0);
+
+    if (v1.ieee.mantissa != v2.ieee.mantissa)
+      {
+	printf ("-0.0625f up: mantissa differs: %8x vs %8x\n",
+		v1.ieee.mantissa, v2.ieee.mantissa);
+	result = 1;
+      }
+    if (v1.ieee.exponent != v2.ieee.exponent)
+      {
+	printf ("-0.0625f up: exponent differs: %4x vs %4x\n",
+		v1.ieee.exponent, v2.ieee.exponent);
+	result = 1;
+      }
+    if (v1.ieee.negative != v2.ieee.negative)
+      {
+	printf ("-0.0625f up: negative differs: %d vs %d\n",
+		v1.ieee.negative, v2.ieee.negative);
+	result = 1;
+      }
+
+    v1.f = f = -0.0625;
+    f = nextafterf (f, -1.0);
+    v2.f = f = nextafterf (f, 0.0);
+
+    if (v1.ieee.mantissa != v2.ieee.mantissa)
+      {
+	printf ("-0.0625f down: mantissa differs: %8x vs %8x\n",
+		v1.ieee.mantissa, v2.ieee.mantissa);
+	result = 1;
+      }
+    if (v1.ieee.exponent != v2.ieee.exponent)
+      {
+	printf ("-0.0625f down: exponent differs: %4x vs %4x\n",
+		v1.ieee.exponent, v2.ieee.exponent);
+	result = 1;
+      }
+    if (v1.ieee.negative != v2.ieee.negative)
+      {
+	printf ("-0.0625f down: negative differs: %d vs %d\n",
+		v1.ieee.negative, v2.ieee.negative);
+	result = 1;
+      }
+
+    v1.f = f = 0.0f;
+    f = nextafterf (f, 1.0);
+    v2.f = nextafterf (f, -1.0);
+
+    if (v1.ieee.mantissa != v2.ieee.mantissa)
+      {
+	printf ("0.0f up: mantissa differs: %8x vs %8x\n",
+		v1.ieee.mantissa, v2.ieee.mantissa);
+	result = 1;
+      }
+    if (v1.ieee.exponent != v2.ieee.exponent)
+      {
+	printf ("0.0f up: exponent differs: %4x vs %4x\n",
+		v1.ieee.exponent, v2.ieee.exponent);
+	result = 1;
+      }
+    if (0 != v2.ieee.negative)
+      {
+	printf ("0.0f up: negative differs: 0 vs %d\n",
+		v2.ieee.negative);
+	result = 1;
+      }
+
+    v1.f = f = 0.0f;
+    f = nextafterf (f, -1.0);
+    v2.f = nextafterf (f, 1.0);
+
+    if (v1.ieee.mantissa != v2.ieee.mantissa)
+      {
+	printf ("0.0f down: mantissa differs: %8x vs %8x\n",
+		v1.ieee.mantissa, v2.ieee.mantissa);
+	result = 1;
+      }
+    if (v1.ieee.exponent != v2.ieee.exponent)
+      {
+	printf ("0.0f down: exponent differs: %4x vs %4x\n",
+		v1.ieee.exponent, v2.ieee.exponent);
+	result = 1;
+      }
+    if (1 != v2.ieee.negative)
+      {
+	printf ("0.0f down: negative differs: 1 vs %d\n",
+		v2.ieee.negative);
+	result = 1;
+      }
+
+    if (nextafterf (0.0f, INFINITY) != nextafterf (0.0f, 1.0f)
+        || nextafterf (-0.0f, INFINITY) != nextafterf (-0.0f, 1.0f)
+        || nextafterf (0.0f, -INFINITY) != nextafterf (0.0f, -1.0f)
+        || nextafterf (-0.0f, -INFINITY) != nextafterf (-0.0f, -1.0f))
+      {
+	printf ("nextafterf (+-0, +-Inf) != nextafterf (+-0, +-1)\n");
+	result = 1;
+      }
+
+    if (nexttowardf (0.0f, INFINITY) != nexttowardf (0.0f, 1.0f)
+        || nexttowardf (-0.0f, INFINITY) != nexttowardf (-0.0f, 1.0f)
+        || nexttowardf (0.0f, -INFINITY) != nexttowardf (0.0f, -1.0f)
+        || nexttowardf (-0.0f, -INFINITY) != nexttowardf (-0.0f, -1.0f))
+      {
+	printf ("nexttowardf (+-0, +-Inf) != nexttowardf (+-0, +-1)\n");
+	result = 1;
+      }
+  }
+
+  {
+    union ieee754_double v1;
+    union ieee754_double v2;
+    double d;
+
+    v1.d = d = DBL_MIN;
+    if (fpclassify (d) != FP_NORMAL)
+      {
+	printf ("fpclassify (DBL_MIN) failed: %d\n", fpclassify (d));
+	result = 1;
+      }
+    d = nextafter (d, DBL_MIN / 2.0);
+    if (fpclassify (d) != FP_SUBNORMAL)
+      {
+	printf ("fpclassify (DBL_MIN-epsilon) failed: %d\n", fpclassify (d));
+	result = 1;
+      }
+    v2.d = d = nextafter (d, DBL_MIN);
+    if (fpclassify (d) != FP_NORMAL)
+      {
+	printf ("fpclassify (DBL_MIN-epsilon+epsilon) failed: %d\n",
+		fpclassify (d));
+	result = 1;
+      }
+
+    if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
+      {
+	printf ("DBL_MIN: mantissa0 differs: %8x vs %8x\n",
+		v1.ieee.mantissa0, v2.ieee.mantissa0);
+	result = 1;
+      }
+    if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
+      {
+	printf ("DBL_MIN: mantissa1 differs: %8x vs %8x\n",
+		v1.ieee.mantissa1, v2.ieee.mantissa1);
+	result = 1;
+      }
+    if (v1.ieee.exponent != v2.ieee.exponent)
+      {
+	printf ("DBL_MIN: exponent differs: %4x vs %4x\n",
+		v1.ieee.exponent, v2.ieee.exponent);
+	result = 1;
+      }
+    if (v1.ieee.negative != v2.ieee.negative)
+      {
+	printf ("DBL_MIN: negative differs: %d vs %d\n",
+		v1.ieee.negative, v2.ieee.negative);
+	result = 1;
+      }
+
+    v1.d = d = -DBL_MIN;
+    if (fpclassify (d) != FP_NORMAL)
+      {
+	printf ("fpclassify (-DBL_MIN) failed: %d\n", fpclassify (d));
+	result = 1;
+      }
+    d = nextafter (d, -DBL_MIN / 2.0);
+    if (fpclassify (d) != FP_SUBNORMAL)
+      {
+	printf ("fpclassify (-DBL_MIN-epsilon) failed: %d\n", fpclassify (d));
+	result = 1;
+      }
+    v2.d = d = nextafter (d, -DBL_MIN);
+    if (fpclassify (d) != FP_NORMAL)
+      {
+	printf ("fpclassify (-DBL_MIN-epsilon+epsilon) failed: %d\n",
+		fpclassify (d));
+	result = 1;
+      }
+
+    if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
+      {
+	printf ("-DBL_MIN: mantissa0 differs: %8x vs %8x\n",
+		v1.ieee.mantissa0, v2.ieee.mantissa0);
+	result = 1;
+      }
+    if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
+      {
+	printf ("-DBL_MIN: mantissa1 differs: %8x vs %8x\n",
+		v1.ieee.mantissa1, v2.ieee.mantissa1);
+	result = 1;
+      }
+    if (v1.ieee.exponent != v2.ieee.exponent)
+      {
+	printf ("-DBL_MIN: exponent differs: %4x vs %4x\n",
+		v1.ieee.exponent, v2.ieee.exponent);
+	result = 1;
+      }
+    if (v1.ieee.negative != v2.ieee.negative)
+      {
+	printf ("-DBL_MIN: negative differs: %d vs %d\n",
+		v1.ieee.negative, v2.ieee.negative);
+	result = 1;
+      }
+
+    d = DBL_MAX;
+    if (fpclassify (d) != FP_NORMAL)
+      {
+	printf ("fpclassify (DBL_MAX) failed: %d\n", fpclassify (d));
+	result = 1;
+      }
+    d = nextafter (d, INFINITY);
+    if (fpclassify (d) != FP_INFINITE)
+      {
+	printf ("fpclassify (DBL_MAX+epsilon) failed: %d\n", fpclassify (d));
+	result = 1;
+      }
+
+    d = -DBL_MAX;
+    if (fpclassify (d) != FP_NORMAL)
+      {
+	printf ("fpclassify (-DBL_MAX) failed: %d\n", fpclassify (d));
+	result = 1;
+      }
+    d = nextafter (d, -INFINITY);
+    if (fpclassify (d) != FP_INFINITE)
+      {
+	printf ("fpclassify (-DBL_MAX-epsilon) failed: %d\n", fpclassify (d));
+	result = 1;
+      }
+
+    v1.d = d = 0.0625;
+    d = nextafter (d, 0.0);
+    v2.d = d = nextafter (d, 1.0);
+
+    if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
+      {
+	printf ("0.0625 down: mantissa0 differs: %8x vs %8x\n",
+		v1.ieee.mantissa0, v2.ieee.mantissa0);
+	result = 1;
+      }
+    if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
+      {
+	printf ("0.0625 down: mantissa1 differs: %8x vs %8x\n",
+		v1.ieee.mantissa1, v2.ieee.mantissa1);
+	result = 1;
+      }
+    if (v1.ieee.exponent != v2.ieee.exponent)
+      {
+	printf ("0.0625 down: exponent differs: %4x vs %4x\n",
+		v1.ieee.exponent, v2.ieee.exponent);
+	result = 1;
+      }
+    if (v1.ieee.negative != v2.ieee.negative)
+      {
+	printf ("0.0625 down: negative differs: %d vs %d\n",
+		v1.ieee.negative, v2.ieee.negative);
+	result = 1;
+      }
+
+    v1.d = d = 0.0625;
+    d = nextafter (d, 1.0);
+    v2.d = d = nextafter (d, 0.0);
+
+    if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
+      {
+	printf ("0.0625 up: mantissa0 differs: %8x vs %8x\n",
+		v1.ieee.mantissa0, v2.ieee.mantissa0);
+	result = 1;
+      }
+    if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
+      {
+	printf ("0.0625 up: mantissa1 differs: %8x vs %8x\n",
+		v1.ieee.mantissa1, v2.ieee.mantissa1);
+	result = 1;
+      }
+    if (v1.ieee.exponent != v2.ieee.exponent)
+      {
+	printf ("0.0625 up: exponent differs: %4x vs %4x\n",
+		v1.ieee.exponent, v2.ieee.exponent);
+	result = 1;
+      }
+    if (v1.ieee.negative != v2.ieee.negative)
+      {
+	printf ("0.0625 up: negative differs: %d vs %d\n",
+		v1.ieee.negative, v2.ieee.negative);
+	result = 1;
+      }
+
+    v1.d = d = -0.0625;
+    d = nextafter (d, 0.0);
+    v2.d = d = nextafter (d, -1.0);
+
+    if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
+      {
+	printf ("-0.0625 up: mantissa0 differs: %8x vs %8x\n",
+		v1.ieee.mantissa0, v2.ieee.mantissa0);
+	result = 1;
+      }
+    if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
+      {
+	printf ("-0.0625 up: mantissa1 differs: %8x vs %8x\n",
+		v1.ieee.mantissa1, v2.ieee.mantissa1);
+	result = 1;
+      }
+    if (v1.ieee.exponent != v2.ieee.exponent)
+      {
+	printf ("-0.0625 up: exponent differs: %4x vs %4x\n",
+		v1.ieee.exponent, v2.ieee.exponent);
+	result = 1;
+      }
+    if (v1.ieee.negative != v2.ieee.negative)
+      {
+	printf ("-0.0625 up: negative differs: %d vs %d\n",
+		v1.ieee.negative, v2.ieee.negative);
+	result = 1;
+      }
+
+    v1.d = d = -0.0625;
+    d = nextafter (d, -1.0);
+    v2.d = d = nextafter (d, 0.0);
+
+    if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
+      {
+	printf ("-0.0625 down: mantissa0 differs: %8x vs %8x\n",
+		v1.ieee.mantissa0, v2.ieee.mantissa0);
+	result = 1;
+      }
+    if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
+      {
+	printf ("-0.0625 down: mantissa1 differs: %8x vs %8x\n",
+		v1.ieee.mantissa1, v2.ieee.mantissa1);
+	result = 1;
+      }
+    if (v1.ieee.exponent != v2.ieee.exponent)
+      {
+	printf ("-0.0625 down: exponent differs: %4x vs %4x\n",
+		v1.ieee.exponent, v2.ieee.exponent);
+	result = 1;
+      }
+    if (v1.ieee.negative != v2.ieee.negative)
+      {
+	printf ("-0.0625 down: negative differs: %d vs %d\n",
+		v1.ieee.negative, v2.ieee.negative);
+	result = 1;
+      }
+
+    v1.d = d = 0.0;
+    d = nextafter (d, 1.0);
+    v2.d = nextafter (d, -1.0);
+
+    if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
+      {
+	printf ("0.0 up: mantissa0 differs: %8x vs %8x\n",
+		v1.ieee.mantissa0, v2.ieee.mantissa0);
+	result = 1;
+      }
+    if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
+      {
+	printf ("0.0 up: mantissa1 differs: %8x vs %8x\n",
+		v1.ieee.mantissa1, v2.ieee.mantissa1);
+	result = 1;
+      }
+    if (v1.ieee.exponent != v2.ieee.exponent)
+      {
+	printf ("0.0 up: exponent differs: %4x vs %4x\n",
+		v1.ieee.exponent, v2.ieee.exponent);
+	result = 1;
+      }
+    if (0 != v2.ieee.negative)
+      {
+	printf ("0.0 up: negative differs: 0 vs %d\n",
+		v2.ieee.negative);
+	result = 1;
+      }
+
+    v1.d = d = 0.0;
+    d = nextafter (d, -1.0);
+    v2.d = nextafter (d, 1.0);
+
+    if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
+      {
+	printf ("0.0 down: mantissa0 differs: %8x vs %8x\n",
+		v1.ieee.mantissa0, v2.ieee.mantissa0);
+	result = 1;
+      }
+    if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
+      {
+	printf ("0.0 down: mantissa1 differs: %8x vs %8x\n",
+		v1.ieee.mantissa1, v2.ieee.mantissa1);
+	result = 1;
+      }
+    if (v1.ieee.exponent != v2.ieee.exponent)
+      {
+	printf ("0.0 down: exponent differs: %4x vs %4x\n",
+		v1.ieee.exponent, v2.ieee.exponent);
+	result = 1;
+      }
+    if (1 != v2.ieee.negative)
+      {
+	printf ("0.0 down: negative differs: 1 vs %d\n",
+		v2.ieee.negative);
+	result = 1;
+      }
+
+    if (nextafter (0.0, INFINITY) != nextafter (0.0, 1.0)
+        || nextafter (-0.0, INFINITY) != nextafter (-0.0, 1.0)
+        || nextafter (0.0, -INFINITY) != nextafter (0.0, -1.0)
+        || nextafter (-0.0, -INFINITY) != nextafter (-0.0, -1.0))
+      {
+	printf ("nextafter (+-0, +-Inf) != nextafter (+-0, +-1)\n");
+	result = 1;
+      }
+
+    if (nexttoward (0.0, INFINITY) != nexttoward (0.0, 1.0)
+        || nexttoward (-0.0, INFINITY) != nexttoward (-0.0, 1.0)
+        || nexttoward (0.0, -INFINITY) != nexttoward (0.0, -1.0)
+        || nexttoward (-0.0, -INFINITY) != nexttoward (-0.0, -1.0))
+      {
+	printf ("nexttoward (+-0, +-Inf) != nexttoward (+-0, +-1)\n");
+	result = 1;
+      }
+  }
+
+#ifndef NO_LONG_DOUBLE
+  {
+    union ieee854_long_double v1;
+    union ieee854_long_double v2;
+    long double ld;
+
+    v1.d = ld = LDBL_MIN;
+    if (fpclassify (ld) != FP_NORMAL)
+      {
+	printf ("fpclassify (LDBL_MIN) failed: %d\n", fpclassify (ld));
+	result = 1;
+      }
+    ld = nextafterl (ld, LDBL_MIN / 2.0);
+    if (fpclassify (ld) != FP_SUBNORMAL)
+      {
+	printf ("fpclassify (LDBL_MIN-epsilon) failed: %d (%La)\n",
+		fpclassify (ld), ld);
+	result = 1;
+      }
+    v2.d = ld = nextafterl (ld, LDBL_MIN);
+    if (fpclassify (ld) != FP_NORMAL)
+      {
+	printf ("fpclassify (LDBL_MIN-epsilon+epsilon) failed: %d (%La)\n",
+		fpclassify (ld), ld);
+	result = 1;
+      }
+
+    if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
+      {
+	printf ("LDBL_MIN: mantissa0 differs: %8x vs %8x\n",
+		v1.ieee.mantissa0, v2.ieee.mantissa0);
+	result = 1;
+      }
+    if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
+      {
+	printf ("LDBL_MIN: mantissa1 differs: %8x vs %8x\n",
+		v1.ieee.mantissa1, v2.ieee.mantissa1);
+	result = 1;
+      }
+    if (v1.ieee.exponent != v2.ieee.exponent)
+      {
+	printf ("LDBL_MIN: exponent differs: %4x vs %4x\n",
+		v1.ieee.exponent, v2.ieee.exponent);
+	result = 1;
+      }
+    if (v1.ieee.negative != v2.ieee.negative)
+      {
+	printf ("LDBL_MIN: negative differs: %d vs %d\n",
+		v1.ieee.negative, v2.ieee.negative);
+	result = 1;
+      }
+
+    v1.d = ld = -LDBL_MIN;
+    if (fpclassify (ld) != FP_NORMAL)
+      {
+	printf ("fpclassify (-LDBL_MIN) failed: %d\n", fpclassify (ld));
+	result = 1;
+      }
+    ld = nextafterl (ld, -LDBL_MIN / 2.0);
+    if (fpclassify (ld) != FP_SUBNORMAL)
+      {
+	printf ("fpclassify (-LDBL_MIN-epsilon) failed: %d (%La)\n",
+		fpclassify (ld), ld);
+	result = 1;
+      }
+    v2.d = ld = nextafterl (ld, -LDBL_MIN);
+    if (fpclassify (ld) != FP_NORMAL)
+      {
+	printf ("fpclassify (-LDBL_MIN-epsilon+epsilon) failed: %d (%La)\n",
+		fpclassify (ld), ld);
+	result = 1;
+      }
+
+    if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
+      {
+	printf ("-LDBL_MIN: mantissa0 differs: %8x vs %8x\n",
+		v1.ieee.mantissa0, v2.ieee.mantissa0);
+	result = 1;
+      }
+    if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
+      {
+	printf ("-LDBL_MIN: mantissa1 differs: %8x vs %8x\n",
+		v1.ieee.mantissa1, v2.ieee.mantissa1);
+	result = 1;
+      }
+    if (v1.ieee.exponent != v2.ieee.exponent)
+      {
+	printf ("-LDBL_MIN: exponent differs: %4x vs %4x\n",
+		v1.ieee.exponent, v2.ieee.exponent);
+	result = 1;
+      }
+    if (v1.ieee.negative != v2.ieee.negative)
+      {
+	printf ("-LDBL_MIN: negative differs: %d vs %d\n",
+		v1.ieee.negative, v2.ieee.negative);
+	result = 1;
+      }
+
+    ld = LDBL_MAX;
+    if (fpclassify (ld) != FP_NORMAL)
+      {
+	printf ("fpclassify (LDBL_MAX) failed: %d\n", fpclassify (ld));
+	result = 1;
+      }
+    ld = nextafterl (ld, INFINITY);
+    if (fpclassify (ld) != FP_INFINITE)
+      {
+	printf ("fpclassify (LDBL_MAX+epsilon) failed: %d\n", fpclassify (ld));
+	result = 1;
+      }
+
+    ld = -LDBL_MAX;
+    if (fpclassify (ld) != FP_NORMAL)
+      {
+	printf ("fpclassify (-LDBL_MAX) failed: %d\n", fpclassify (ld));
+	result = 1;
+      }
+    ld = nextafterl (ld, -INFINITY);
+    if (fpclassify (ld) != FP_INFINITE)
+      {
+	printf ("fpclassify (-LDBL_MAX-epsilon) failed: %d\n",
+		fpclassify (ld));
+	result = 1;
+      }
+
+    v1.d = ld = 0.0625;
+    ld = nextafterl (ld, 0.0);
+    v2.d = ld = nextafterl (ld, 1.0);
+
+    if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
+      {
+	printf ("0.0625L down: mantissa0 differs: %8x vs %8x\n",
+		v1.ieee.mantissa0, v2.ieee.mantissa0);
+	result = 1;
+      }
+    if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
+      {
+	printf ("0.0625L down: mantissa1 differs: %8x vs %8x\n",
+		v1.ieee.mantissa1, v2.ieee.mantissa1);
+	result = 1;
+      }
+    if (v1.ieee.exponent != v2.ieee.exponent)
+      {
+	printf ("0.0625L down: exponent differs: %4x vs %4x\n",
+		v1.ieee.exponent, v2.ieee.exponent);
+	result = 1;
+      }
+    if (v1.ieee.negative != v2.ieee.negative)
+      {
+	printf ("0.0625L down: negative differs: %d vs %d\n",
+		v1.ieee.negative, v2.ieee.negative);
+	result = 1;
+      }
+
+    v1.d = ld = 0.0625;
+    ld = nextafterl (ld, 1.0);
+    v2.d = ld = nextafterl (ld, 0.0);
+
+    if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
+      {
+	printf ("0.0625L up: mantissa0 differs: %8x vs %8x\n",
+		v1.ieee.mantissa0, v2.ieee.mantissa0);
+	result = 1;
+      }
+    if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
+      {
+	printf ("0.0625L up: mantissa1 differs: %8x vs %8x\n",
+		v1.ieee.mantissa1, v2.ieee.mantissa1);
+	result = 1;
+      }
+    if (v1.ieee.exponent != v2.ieee.exponent)
+      {
+	printf ("0.0625L up: exponent differs: %4x vs %4x\n",
+		v1.ieee.exponent, v2.ieee.exponent);
+	result = 1;
+      }
+    if (v1.ieee.negative != v2.ieee.negative)
+      {
+	printf ("0.0625L up: negative differs: %d vs %d\n",
+		v1.ieee.negative, v2.ieee.negative);
+	result = 1;
+      }
+
+    v1.d = ld = -0.0625;
+    ld = nextafterl (ld, 0.0);
+    v2.d = ld = nextafterl (ld, -1.0);
+
+    if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
+      {
+	printf ("-0.0625L up: mantissa0 differs: %8x vs %8x\n",
+		v1.ieee.mantissa0, v2.ieee.mantissa0);
+	result = 1;
+      }
+    if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
+      {
+	printf ("-0.0625L up: mantissa1 differs: %8x vs %8x\n",
+		v1.ieee.mantissa1, v2.ieee.mantissa1);
+	result = 1;
+      }
+    if (v1.ieee.exponent != v2.ieee.exponent)
+      {
+	printf ("-0.0625L up: exponent differs: %4x vs %4x\n",
+		v1.ieee.exponent, v2.ieee.exponent);
+	result = 1;
+      }
+    if (v1.ieee.negative != v2.ieee.negative)
+      {
+	printf ("-0.0625L up: negative differs: %d vs %d\n",
+		v1.ieee.negative, v2.ieee.negative);
+	result = 1;
+      }
+
+    v1.d = ld = -0.0625;
+    ld = nextafterl (ld, -1.0);
+    v2.d = ld = nextafterl (ld, 0.0);
+
+    if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
+      {
+	printf ("-0.0625L down: mantissa0 differs: %8x vs %8x\n",
+		v1.ieee.mantissa0, v2.ieee.mantissa0);
+	result = 1;
+      }
+    if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
+      {
+	printf ("-0.0625L down: mantissa1 differs: %8x vs %8x\n",
+		v1.ieee.mantissa1, v2.ieee.mantissa1);
+	result = 1;
+      }
+    if (v1.ieee.exponent != v2.ieee.exponent)
+      {
+	printf ("-0.0625L down: exponent differs: %4x vs %4x\n",
+		v1.ieee.exponent, v2.ieee.exponent);
+	result = 1;
+      }
+    if (v1.ieee.negative != v2.ieee.negative)
+      {
+	printf ("-0.0625L down: negative differs: %d vs %d\n",
+		v1.ieee.negative, v2.ieee.negative);
+	result = 1;
+      }
+
+    v1.d = ld = 0.0;
+    ld = nextafterl (ld, 1.0);
+    v2.d = nextafterl (ld, -1.0);
+
+    if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
+      {
+	printf ("0.0L up: mantissa0 differs: %8x vs %8x\n",
+		v1.ieee.mantissa0, v2.ieee.mantissa0);
+	result = 1;
+      }
+    if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
+      {
+	printf ("0.0L up: mantissa1 differs: %8x vs %8x\n",
+		v1.ieee.mantissa1, v2.ieee.mantissa1);
+	result = 1;
+      }
+    if (v1.ieee.exponent != v2.ieee.exponent)
+      {
+	printf ("0.0L up: exponent differs: %4x vs %4x\n",
+		v1.ieee.exponent, v2.ieee.exponent);
+	result = 1;
+      }
+    if (0 != v2.ieee.negative)
+      {
+	printf ("0.0L up: negative differs: 0 vs %d\n",
+		v2.ieee.negative);
+	result = 1;
+      }
+
+    v1.d = ld = 0.0;
+    ld = nextafterl (ld, -1.0);
+    v2.d = nextafterl (ld, 1.0);
+
+    if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
+      {
+	printf ("0.0L down: mantissa0 differs: %8x vs %8x\n",
+		v1.ieee.mantissa0, v2.ieee.mantissa0);
+	result = 1;
+      }
+    if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
+      {
+	printf ("0.0L down: mantissa1 differs: %8x vs %8x\n",
+		v1.ieee.mantissa1, v2.ieee.mantissa1);
+	result = 1;
+      }
+    if (v1.ieee.exponent != v2.ieee.exponent)
+      {
+	printf ("0.0L down: exponent differs: %4x vs %4x\n",
+		v1.ieee.exponent, v2.ieee.exponent);
+	result = 1;
+      }
+    if (1 != v2.ieee.negative)
+      {
+	printf ("0.0L down: negative differs: 1 vs %d\n",
+		v2.ieee.negative);
+	result = 1;
+      }
+
+    if (nextafterl (0.0, INFINITY) != nextafterl (0.0, 1.0)
+        || nextafterl (-0.0, INFINITY) != nextafterl (-0.0, 1.0)
+        || nextafterl (0.0, -INFINITY) != nextafterl (0.0, -1.0)
+        || nextafterl (-0.0, -INFINITY) != nextafterl (-0.0, -1.0))
+      {
+	printf ("nextafterl (+-0, +-Inf) != nextafterl (+-0, +-1)\n");
+	result = 1;
+      }
+
+    if (nexttowardl (0.0L, INFINITY) != nexttowardl (0.0L, 1.0L)
+        || nexttowardl (-0.0L, INFINITY) != nexttowardl (-0.0L, 1.0L)
+        || nexttowardl (0.0L, -INFINITY) != nexttowardl (0.0L, -1.0L)
+        || nexttowardl (-0.0L, -INFINITY) != nexttowardl (-0.0L, -1.0L))
+      {
+	printf ("nexttowardl (+-0, +-Inf) != nexttowardl (+-0, +-1)\n");
+	result = 1;
+      }
+  }
+#endif
+
+  if (! isnormal (FLT_MIN))
+    {
+      puts ("isnormal (FLT_MIN) failed");
+      result = 1;
+    }
+  if (! isnormal (DBL_MIN))
+    {
+      puts ("isnormal (DBL_MIN) failed");
+      result = 1;
+    }
+#ifndef NO_LONG_DOUBLE
+  if (! isnormal (LDBL_MIN))
+    {
+      puts ("isnormal (LDBL_MIN) failed");
+      result = 1;
+    }
+#endif
+
+#ifdef __i386__
+  /* This is a test for the strange long doubles in x86 FPUs.  */
+  {
+    union
+    {
+      char b[10];
+      long double d;
+    } u =
+      { .b = { 0, 0, 0, 0, 0, 0, 0, 0x80, 0, 0 } };
+
+    if (fpclassify (u.d) != FP_NORMAL)
+      {
+	printf ("fpclassify (0x00008000000000000000) failed: %d (%Lg)\n",
+		fpclassify (u.d), u.d);
+	result = 1;
+      }
+  }
+
+  /* Special NaNs in x86 long double.  Test for scalbl.  */
+  {
+    union
+    {
+      char b[10];
+      long double d;
+    } u =
+      { .b = { 0, 1, 0, 0, 0, 0, 0, 0xc0, 0xff, 0x7f } };
+    long double r;
+
+    r = scalbl (u.d, 0.0);
+    if (!isnan (r))
+      {
+	puts ("scalbl(NaN, 0) does not return NaN");
+	result = 1;
+      }
+    else if (memcmp (&r, &u.d, sizeof (double)) != 0)
+      {
+	puts ("scalbl(NaN, 0) does not return the same NaN");
+	result = 1;
+      }
+  }
+#endif
+
+#ifndef NO_LONG_DOUBLE
+  {
+    long double r;
+
+    feclearexcept (FE_ALL_EXCEPT);
+    r = scalbl (LDBL_MIN, 2147483647);
+    if (! isinf (r))
+      {
+	puts ("scalbl (LDBL_MIN, 2147483647) does not return Inf");
+	result = 1;
+      }
+    else if (signbit (r) != 0)
+      {
+	puts ("scalbl (LDBL_MIN, 2147483647) returns -Inf");
+	result = 1;
+      }
+    else if (fetestexcept (FE_UNDERFLOW))
+      {
+	puts ("scalbl(NaN, 0) raises underflow exception");
+	result = 1;
+      }
+
+    feclearexcept (FE_ALL_EXCEPT);
+    r = scalbl (LDBL_MAX, -2147483647);
+    if (r != 0.0)
+      {
+	puts ("scalbl (LDBL_MAX, -2147483647) does not return 0");
+	result = 1;
+      }
+    else if (signbit (r) != 0)
+      {
+	puts ("scalbl (LDBL_MAX, -2147483647) returns -Inf");
+	result = 1;
+      }
+    else if (fetestexcept (FE_OVERFLOW))
+      {
+	puts ("scalbl(NaN, 0) raises overflow exception");
+	result = 1;
+      }
+  }
+#endif
+
+  /* The tests here are very similar to tests earlier in this file,
+     the important difference is just that there are no intervening
+     union variables that cause some GCC versions to hide possible
+     bugs in nextafter* implementation.  */
+  if (nextafterf (nextafterf (FLT_MIN, FLT_MIN / 2.0), FLT_MIN) != FLT_MIN)
+    {
+      puts ("nextafterf FLT_MIN test failed");
+      result = 1;
+    }
+  if (nextafterf (nextafterf (-FLT_MIN, -FLT_MIN / 2.0), -FLT_MIN)
+      != -FLT_MIN)
+    {
+      puts ("nextafterf -FLT_MIN test failed");
+      result = 1;
+    }
+  if (nextafter (nextafter (DBL_MIN, DBL_MIN / 2.0), DBL_MIN) != DBL_MIN)
+    {
+      puts ("nextafter DBL_MIN test failed");
+      result = 1;
+    }
+  if (nextafter (nextafter (-DBL_MIN, -DBL_MIN / 2.0), -DBL_MIN) != -DBL_MIN)
+    {
+      puts ("nextafter -DBL_MIN test failed");
+      result = 1;
+    }
+#ifndef NO_LONG_DOUBLE
+  if (nextafterl (nextafterl (LDBL_MIN, LDBL_MIN / 2.0), LDBL_MIN)
+      != LDBL_MIN)
+    {
+      puts ("nextafterl LDBL_MIN test failed");
+      result = 1;
+    }
+  if (nextafterl (nextafterl (-LDBL_MIN, -LDBL_MIN / 2.0), -LDBL_MIN)
+      != -LDBL_MIN)
+    {
+      puts ("nextafterl -LDBL_MIN test failed");
+      result = 1;
+    }
+#endif
+
+  return result;
+}
Index: trunk/src/libctests/glibc/math/test-tgmath-ret.c
===================================================================
--- trunk/src/libctests/glibc/math/test-tgmath-ret.c	(revision 2036)
+++ trunk/src/libctests/glibc/math/test-tgmath-ret.c	(revision 2036)
@@ -0,0 +1,85 @@
+/* Test compilation of tgmath macros.
+   Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@suse.de>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <math.h>
+#include <complex.h>
+#include <tgmath.h>
+#include <stdio.h>
+
+static float fx;
+static double dx;
+static long double lx;
+static int errors = 0;
+
+static void
+our_error (const char *c)
+{
+  puts (c);
+  ++errors;
+}
+
+/* First function where the return type is constant.  */
+
+#define CHECK_RET_CONST_TYPE(func, rettype, arg, name) \
+  if (sizeof (func (arg)) != sizeof (rettype))				      \
+    our_error ("Return size of " #func " is wrong with " #name " argument");
+
+#define CHECK_RET_CONST_FLOAT(func, rettype) \
+  CHECK_RET_CONST_TYPE (func, rettype, fx, float)
+#define CHECK_RET_CONST_DOUBLE(func, rettype) \
+  CHECK_RET_CONST_TYPE (func, rettype, dx, double)
+#ifdef NO_LONG_DOUBLE
+# define CHECK_RET_CONST_LDOUBLE(func, rettype)
+#else
+# define CHECK_RET_CONST_LDOUBLE(func, rettype) \
+  CHECK_RET_CONST_TYPE (func, rettype, lx, long double)
+#endif
+
+#define CHECK_RET_CONST(func, rettype) \
+static void								      \
+check_return_ ##func (void)						      \
+{									      \
+  CHECK_RET_CONST_FLOAT (func, rettype)					      \
+  CHECK_RET_CONST_DOUBLE (func, rettype)				      \
+  CHECK_RET_CONST_LDOUBLE (func, rettype)				      \
+}
+
+CHECK_RET_CONST(ilogb, int)
+CHECK_RET_CONST(lrint, long)
+CHECK_RET_CONST(lround, long)
+CHECK_RET_CONST(llrint, long long)
+CHECK_RET_CONST(llround, long long)
+
+static int
+do_test (void)
+{
+  check_return_ilogb ();
+  check_return_lrint ();
+  check_return_lround ();
+  check_return_llrint ();
+  check_return_llround ();
+
+  printf ("%Zd\n", sizeof(carg (lx)));
+
+  return errors != 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/math/test-tgmath.c
===================================================================
--- trunk/src/libctests/glibc/math/test-tgmath.c	(revision 2036)
+++ trunk/src/libctests/glibc/math/test-tgmath.c	(revision 2036)
@@ -0,0 +1,678 @@
+/* Test compilation of tgmath macros.
+   Copyright (C) 2001, 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com> and
+   Ulrich Drepper <drepper@redhat.com>, 2001.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef HAVE_MAIN
+#undef __NO_MATH_INLINES
+#define __NO_MATH_INLINES 1
+#include <math.h>
+#include <stdio.h>
+#include <tgmath.h>
+
+//#define DEBUG
+
+static void compile_test (void);
+static void compile_testf (void);
+#ifndef NO_LONG_DOUBLE
+static void compile_testl (void);
+#endif
+
+float fx;
+double dx;
+long double lx;
+
+int count_double;
+int count_float;
+int count_ldouble;
+
+#define NCALLS     115
+#define NCALLS_INT 4
+
+int
+main (void)
+{
+  int result = 0;
+
+  count_float = count_double = count_ldouble = 0;
+  compile_test ();
+  if (count_float != 0)
+    {
+      puts ("float function called for double test");
+      result = 1;
+    }
+  if (count_ldouble != 0)
+    {
+      puts ("long double function called for double test");
+      result = 1;
+    }
+  if (count_double < NCALLS + NCALLS_INT)
+    {
+      printf ("double functions not called often enough (%d)\n",
+	      count_double);
+      result = 1;
+    }
+  else if (count_double > NCALLS + NCALLS_INT)
+    {
+      printf ("double functions called too often (%d)\n",
+	      count_double);
+      result = 1;
+    }
+
+  count_float = count_double = count_ldouble = 0;
+  compile_testf ();
+  if (count_double != 0)
+    {
+      puts ("double function called for float test");
+      result = 1;
+    }
+  if (count_ldouble != 0)
+    {
+      puts ("long double function called for float test");
+      result = 1;
+    }
+  if (count_float < NCALLS)
+    {
+      printf ("float functions not called often enough (%d)\n", count_float);
+      result = 1;
+    }
+  else if (count_float > NCALLS)
+    {
+      printf ("float functions called too often (%d)\n",
+	      count_double);
+      result = 1;
+    }
+
+#ifndef NO_LONG_DOUBLE
+  count_float = count_double = count_ldouble = 0;
+  compile_testl ();
+  if (count_float != 0)
+    {
+      puts ("float function called for long double test");
+      result = 1;
+    }
+  if (count_double != 0)
+    {
+      puts ("double function called for long double test");
+      result = 1;
+    }
+  if (count_ldouble < NCALLS)
+    {
+      printf ("long double functions not called often enough (%d)\n",
+	      count_ldouble);
+      result = 1;
+    }
+  else if (count_ldouble > NCALLS)
+    {
+      printf ("long double functions called too often (%d)\n",
+	      count_double);
+      result = 1;
+    }
+#endif
+
+  return result;
+}
+
+/* Now generate the three functions.  */
+#define HAVE_MAIN
+
+#define F(name) name
+#define TYPE double
+#define TEST_INT 1
+#define x dx
+#define count count_double
+#include "test-tgmath.c"
+
+#define F(name) name##f
+#define TYPE float
+#define x fx
+#define count count_float
+#include "test-tgmath.c"
+
+#ifndef NO_LONG_DOUBLE
+#define F(name) name##l
+#define TYPE long double
+#define x lx
+#define count count_ldouble
+#include "test-tgmath.c"
+#endif
+
+#else
+
+#ifdef DEBUG
+#define P() puts (__FUNCTION__)
+#else
+#define P()
+#endif
+
+static void
+F(compile_test) (void)
+{
+  TYPE a, b, c = 1.0;
+  int i;
+  long int j;
+  long long int k;
+
+  a = cos (cos (x));
+  b = acos (acos (a));
+  a = sin (sin (x));
+  b = asin (asin (a));
+  a = tan (tan (x));
+  b = atan (atan (a));
+  c = atan2 (atan2 (a, c), atan2 (b, x));
+  a = cosh (cosh (x));
+  b = acosh (acosh (a));
+  a = sinh (sinh (x));
+  b = asinh (asinh (a));
+  a = tanh (tanh (x));
+  b = atanh (atanh (a));
+  a = exp (exp (x));
+  b = log (log (a));
+  a = log10 (log10 (x));
+  b = ldexp (ldexp (a, 1), 5);
+  a = frexp (frexp (x, &i), &i);
+  b = expm1 (expm1 (a));
+  a = log1p (log1p (x));
+  b = logb (logb (a));
+  a = exp2 (exp2 (x));
+  b = log2 (log2 (a));
+  a = pow (pow (x, a), pow (c, b));
+  b = sqrt (sqrt (a));
+  a = hypot (hypot (x, b), hypot (c, a));
+  b = cbrt (cbrt (a));
+  a = ceil (ceil (x));
+  b = fabs (fabs (a));
+  a = floor (floor (x));
+  b = fmod (fmod (a, b), fmod (c, x));
+  a = nearbyint (nearbyint (x));
+  b = round (round (a));
+  a = trunc (trunc (x));
+  b = remquo (remquo (a, b, &i), remquo (c, x, &i), &i);
+  j = lrint (x) + lround (a);
+  k = llrint (b) + llround (c);
+  a = erf (erf (x));
+  b = erfc (erfc (a));
+  a = tgamma (tgamma (x));
+  b = lgamma (lgamma (a));
+  a = rint (rint (x));
+  b = nextafter (nextafter (a, b), nextafter (c, x));
+  a = nexttoward (nexttoward (x, a), c);
+  b = remainder (remainder (a, b), remainder (c, x));
+  a = scalb (scalb (x, a), (TYPE) (6));
+  k = scalbn (a, 7) + scalbln (c, 10l);
+  i = ilogb (x);
+  a = fdim (fdim (x, a), fdim (c, b));
+  b = fmax (fmax (a, x), fmax (c, b));
+  a = fmin (fmin (x, a), fmin (c, b));
+  b = fma (sin (a), sin (x), sin (c));
+
+#ifdef TEST_INT
+  a = atan2 (i, b);
+  b = remquo (i, a, &i);
+  c = fma (i, b, i);
+  a = pow (i, c);
+#endif
+}
+#undef x
+
+
+TYPE
+(F(cos)) (TYPE x)
+{
+  ++count;
+  return x;
+}
+
+TYPE
+(F(acos)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(sin)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(asin)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(tan)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(atan)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(atan2)) (TYPE x, TYPE y)
+{
+  ++count;
+  P();
+  return x + y;
+}
+
+TYPE
+(F(cosh)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(acosh)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(sinh)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(asinh)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(tanh)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(atanh)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(exp)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(log)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(log10)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(ldexp)) (TYPE x, int y)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(frexp)) (TYPE x, int *y)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(expm1)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(log1p)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(logb)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(exp2)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(log2)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(pow)) (TYPE x, TYPE y)
+{
+  ++count;
+  P();
+  return x + y;
+}
+
+TYPE
+(F(sqrt)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(hypot)) (TYPE x, TYPE y)
+{
+  ++count;
+  P();
+  return x + y;
+}
+
+TYPE
+(F(cbrt)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(ceil)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(fabs)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(floor)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(fmod)) (TYPE x, TYPE y)
+{
+  ++count;
+  P();
+  return x + y;
+}
+
+TYPE
+(F(nearbyint)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(round)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(trunc)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(remquo)) (TYPE x, TYPE y, int *i)
+{
+  ++count;
+  P();
+  return x + y;
+}
+
+long int
+(F(lrint)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+long int
+(F(lround)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+long long int
+(F(llrint)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+long long int
+(F(llround)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(erf)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(erfc)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(tgamma)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(lgamma)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(rint)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(nextafter)) (TYPE x, TYPE y)
+{
+  ++count;
+  P();
+  return x + y;
+}
+
+TYPE
+(F(nexttoward)) (TYPE x, long double y)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(remainder)) (TYPE x, TYPE y)
+{
+  ++count;
+  P();
+  return x + y;
+}
+
+TYPE
+(F(scalb)) (TYPE x, TYPE y)
+{
+  ++count;
+  P();
+  return x + y;
+}
+
+TYPE
+(F(scalbn)) (TYPE x, int y)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(scalbln)) (TYPE x, long int y)
+{
+  ++count;
+  P();
+  return x;
+}
+
+int
+(F(ilogb)) (TYPE x)
+{
+  ++count;
+  P();
+  return x;
+}
+
+TYPE
+(F(fdim)) (TYPE x, TYPE y)
+{
+  ++count;
+  P();
+  return x + y;
+}
+
+TYPE
+(F(fmin)) (TYPE x, TYPE y)
+{
+  ++count;
+  P();
+  return x + y;
+}
+
+TYPE
+(F(fmax)) (TYPE x, TYPE y)
+{
+  ++count;
+  P();
+  return x + y;
+}
+
+TYPE
+(F(fma)) (TYPE x, TYPE y, TYPE z)
+{
+  ++count;
+  P();
+  return x + y + z;
+}
+
+#undef F
+#undef TYPE
+#undef count
+#undef TEST_INT
+#endif
Index: trunk/src/libctests/glibc/math/tst-definitions.c
===================================================================
--- trunk/src/libctests/glibc/math/tst-definitions.c	(revision 2036)
+++ trunk/src/libctests/glibc/math/tst-definitions.c	(revision 2036)
@@ -0,0 +1,47 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <limits.h>
+#include <math.h>
+#include <stdio.h>
+
+
+int
+main (void)
+{
+  int result = 0;
+
+  if (FP_ILOGB0 != INT_MIN && FP_ILOGB0 != -INT_MAX)
+    {
+      puts ("FP_ILOGB0 has no valid value");
+      result = 1;
+    }
+  else
+    puts ("FP_ILOGB0 value is OK");
+
+  if (FP_ILOGBNAN != INT_MIN && FP_ILOGBNAN != INT_MAX)
+    {
+      puts ("FP_ILOBNAN has no valid value");
+      result = 1;
+    }
+  else
+    puts ("FP_ILOGBNAN value is OK");
+
+  return result;
+}
Index: trunk/src/libctests/glibc/misc/Makefile
===================================================================
--- trunk/src/libctests/glibc/misc/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/misc/Makefile	(revision 2036)
@@ -0,0 +1,108 @@
+# Copyright (C) 1991-2002, 2003, 2004 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Sub-makefile for misc portion of the library.
+#
+
+subdir	:= misc
+
+headers	:= sys/uio.h bits/uio.h sys/ioctl.h bits/ioctls.h bits/ioctl-types.h \
+	   sys/ptrace.h sys/file.h sys/dir.h sys/cdefs.h \
+	   ar.h a.out.h libgen.h stab.h bits/stab.def sgtty.h \
+	   ttyent.h syslog.h sys/syslog.h paths.h sys/reboot.h \
+	   sys/mman.h sys/param.h fstab.h mntent.h search.h err.h error.h \
+	   sys/queue.h sysexits.h syscall.h sys/syscall.h sys/swap.h \
+	   sys/select.h ustat.h sys/ustat.h bits/ustat.h sys/sysinfo.h \
+	   regexp.h bits/select.h bits/mman.h sys/xattr.h
+
+routines := brk sbrk sstk ioctl \
+	    readv writev \
+	    setreuid setregid \
+	    seteuid setegid \
+	    getpagesize \
+	    getdtsz \
+	    gethostname sethostname getdomain setdomain \
+	    select pselect \
+	    acct chroot fsync sync fdatasync reboot \
+	    gethostid sethostid \
+	    revoke vhangup \
+	    swapon swapoff mktemp mkstemp mkstemp64 mkdtemp \
+	    ualarm usleep \
+	    gtty stty \
+	    ptrace \
+	    fstab mntent mntent_r \
+	    utimes lutimes futimes \
+	    truncate ftruncate truncate64 ftruncate64 \
+	    chflags fchflags \
+	    insremque getttyent getusershell getpass ttyslot \
+	    syslog syscall daemon \
+	    mmap mmap64 munmap mprotect msync madvise mincore remap_file_pages\
+	    mlock munlock mlockall munlockall \
+	    efgcvt efgcvt_r qefgcvt qefgcvt_r \
+	    hsearch hsearch_r tsearch lsearch \
+	    err error ustat \
+	    getsysstats dirname regexp \
+	    getloadavg getclktck \
+	    fgetxattr flistxattr fremovexattr fsetxattr getxattr \
+	    listxattr lgetxattr llistxattr lremovexattr lsetxattr \
+	    removexattr setxattr
+
+distribute := device-nrs.h
+
+include ../Makeconfig
+
+aux := init-misc
+ifeq ($(build-static),yes)
+install-lib := libbsd-compat.a libg.a
+endif
+gpl2lgpl := error.c error.h
+
+tests := tst-dirname tst-tsearch tst-fdset tst-efgcvt tst-mntent tst-hsearch
+
+CFLAGS-tsearch.c = $(uses-callbacks)
+CFLAGS-lsearch.c = $(uses-callbacks)
+CFLAGS-pselect.c = -fexceptions
+CFLAGS-readv.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-writev.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-usleep.c = -fexceptions
+CFLAGS-syslog.c = -fexceptions
+CFLAGS-error.c = -fexceptions
+CFLAGS-getpass.c = -fexceptions
+CFLAGS-mkstemp.c = -fexceptions
+CFLAGS-mkstemp64.c = -fexceptions
+CFLAGS-getsysstats.c = -fexceptions
+CFLAGS-getusershell.c = -fexceptions
+CFLAGS-err.c = -fexceptions
+CFLAGS-tst-tsearch.c = $(stack-align-test-flags)
+CFLAGS-mntent_r.c = -D_IO_MTSAFE_IO
+
+include ../Rules
+
+$(objpfx)libbsd-compat.a: $(dep-dummy-lib); $(make-dummy-lib)
+$(objpfx)libg.a: $(dep-dummy-lib); $(make-dummy-lib)
+
+ifeq ($(build-shared),yes)
+$(objpfx)tst-tsearch: $(common-objpfx)math/libm.so$(libm.so-version)
+else
+$(objpfx)tst-tsearch: $(common-objpfx)math/libm.a
+endif
+
+ifeq ($(build-bounded),yes)
+$(objpfx)tst-tsearch-bp: $(common-objpfx)math/libm_b.a
+endif
Index: trunk/src/libctests/glibc/misc/tst-dirname.c
===================================================================
--- trunk/src/libctests/glibc/misc/tst-dirname.c	(revision 2036)
+++ trunk/src/libctests/glibc/misc/tst-dirname.c	(revision 2036)
@@ -0,0 +1,70 @@
+/* Test program for dirname function a la XPG.
+   Copyright (C) 1996, 2000, 2001, 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define _GNU_SOURCE	1
+#include <libgen.h>
+#include <stdio.h>
+#include <string.h>
+
+
+static int
+test (const char *input, const char *result)
+{
+  int retval;
+  char *cp;
+  cp = strdupa (input);
+  cp = dirname (cp);
+  retval = strcmp (cp, result);
+  if (retval)
+    printf ("dirname(\"%s\") should be \"%s\", but is \"%s\"\n",
+	    input, result, cp);
+  return retval;
+}
+
+int
+main (void)
+{
+  int result = 0;
+
+  /* These are the examples given in XPG4.2.  */
+  result |= test ("/usr/lib", "/usr");
+  result |= test ("/usr/", "/");
+  result |= test ("usr", ".");
+  result |= test ("/", "/");
+  result |= test (".", ".");
+  result |= test ("..", ".");
+
+  /* Some more tests.   */
+  result |= test ("/usr/lib/", "/usr");
+  result |= test ("/usr", "/");
+  result |= test ("a//", ".");
+  result |= test ("a////", ".");
+  result |= test ("////usr", "/");
+  result |= test ("////usr//", "/");
+  result |= test ("//usr", "//");
+  result |= test ("//usr//", "//");
+  result |= test ("//", "//");
+
+  /* Other Unix implementations behave like this.  */
+  result |= test ("x///y", "x");
+  result |= test ("x/////y", "x");
+
+  return result != 0;
+}
Index: trunk/src/libctests/glibc/misc/tst-efgcvt.c
===================================================================
--- trunk/src/libctests/glibc/misc/tst-efgcvt.c	(revision 2036)
+++ trunk/src/libctests/glibc/misc/tst-efgcvt.c	(revision 2036)
@@ -0,0 +1,214 @@
+/* Copyright (C) 1998, 1999, 2000, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE	1
+#endif
+
+#include <float.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int error_count;
+
+typedef struct
+{
+  double value;
+  int ndigit;
+  int decpt;
+  char result[30];
+} testcase;
+
+typedef char * ((*efcvt_func) (double, int, int *, int *));
+
+typedef int ((*efcvt_r_func) (double, int, int *, int *, char *, size_t));
+
+
+static testcase ecvt_tests[] =
+{
+  { 0.0, 0, 1, "" },
+  { 10.0, 0, 2, "" },
+  { 10.0, 1, 2, "1" },
+  { 10.0, 5, 2, "10000" },
+  { -12.0, 5, 2, "12000" },
+  { 0.2, 4, 0, "2000" },
+  { 0.02, 4, -1, "2000" },
+  { 5.5, 1, 1, "6" },
+  { 1.0, -1, 1, "" },
+  { 0.01, 2, -1, "10" },
+  { 100.0, -2, 3, "" },
+  { 100.0, -5, 3, "" },
+  { 100.0, -4, 3, "" },
+  { 100.01, -4, 3, "" },
+  { 123.01, -4, 3, "" },
+  { 126.71, -4, 3, "" },
+  { 0.0, 4, 1, "0000" },
+#if DBL_MANT_DIG == 53
+  { 0x1p-1074, 3, -323, "494" },
+  { -0x1p-1074, 3, -323, "494" },
+#endif
+  /* -1.0 is end marker.  */
+  { -1.0, 0, 0, "" }
+};
+
+static testcase fcvt_tests[] =
+{
+  { 0.0, 0, 1, "0" },
+  { 10.0, 0, 2, "10" },
+  { 10.0, 1, 2, "100" },
+  { 10.0, 4, 2, "100000" },
+  { -12.0, 5, 2, "1200000" },
+  { 0.2, 4, 0, "2000" },
+  { 0.02, 4, -1, "200" },
+  { 5.5, 1, 1, "55" },
+  { 5.5, 0, 1, "6" },
+  { 0.01, 2, -1, "1" },
+  { 100.0, -2, 3, "100" },
+  { 100.0, -5, 3, "100" },
+  { 100.0, -4, 3, "100" },
+  { 100.01, -4, 3, "100" },
+  { 123.01, -4, 3, "100" },
+  { 126.71, -4, 3, "100" },
+  { 322.5, 16, 3, "3225000000000000000" },
+  /* -1.0 is end marker.  */
+  { -1.0, 0, 0, "" }
+};
+
+static void
+output_error (const char *name, double value, int ndigit,
+	      const char *exp_p, int exp_decpt, int exp_sign,
+	      char *res_p, int res_decpt, int res_sign)
+{
+  printf ("%s returned wrong result for value: %f, ndigits: %d\n",
+	  name, value, ndigit);
+  printf ("Result was p: \"%s\", decpt: %d, sign: %d\n",
+	  res_p, res_decpt, res_sign);
+  printf ("Should be  p: \"%s\", decpt: %d, sign: %d\n",
+	  exp_p, exp_decpt, exp_sign);
+  ++error_count;
+}
+
+
+static void
+output_r_error (const char *name, double value, int ndigit,
+		const char *exp_p, int exp_decpt, int exp_sign, int exp_return,
+		char *res_p, int res_decpt, int res_sign, int res_return)
+{
+  printf ("%s returned wrong result for value: %f, ndigits: %d\n",
+	  name, value, ndigit);
+  printf ("Result was buf: \"%s\", decpt: %d, sign: %d return value: %d\n",
+	  res_p, res_decpt, res_sign, res_return);
+  printf ("Should be  buf: \"%s\", decpt: %d, sign: %d\n",
+	  exp_p, exp_decpt, exp_sign);
+  ++error_count;
+}
+
+static void
+test (testcase tests[], efcvt_func efcvt, const char *name)
+{
+  int no = 0;
+  int decpt, sign;
+  char *p;
+
+  while (tests[no].value != -1.0)
+    {
+      p = efcvt (tests[no].value, tests[no].ndigit, &decpt, &sign);
+      if (decpt != tests[no].decpt
+	  || sign != (tests[no].value < 0)
+	  || strcmp (p, tests[no].result) != 0)
+	output_error (name, tests[no].value, tests[no].ndigit,
+		      tests[no].result, tests[no].decpt,
+		      (tests[no].value < 0),
+		      p, decpt, sign);
+      ++no;
+    }
+}
+
+static void
+test_r (testcase tests[], efcvt_r_func efcvt_r, const char *name)
+{
+  int no = 0;
+  int decpt, sign, res;
+  char buf [1024];
+
+
+  while (tests[no].value != -1.0)
+    {
+      res = efcvt_r (tests[no].value, tests[no].ndigit, &decpt, &sign,
+		     buf, sizeof (buf));
+      if (res != 0
+	  || decpt != tests[no].decpt
+	  || sign != (tests[no].value < 0)
+	  || strcmp (buf, tests[no].result) != 0)
+	output_r_error (name, tests[no].value, tests[no].ndigit,
+			tests[no].result, tests[no].decpt, 0,
+			(tests[no].value < 0),
+			buf, decpt, sign, res);
+      ++no;
+    }
+}
+
+static void
+special (void)
+{
+  int decpt, sign, res;
+  char *p;
+  char buf [1024];
+
+  p = ecvt (NAN, 10, &decpt, &sign);
+  if (sign != 0 || strcmp (p, "nan") != 0)
+    output_error ("ecvt", NAN, 10, "nan", 0, 0, p, decpt, sign);
+
+  p = ecvt (INFINITY, 10, &decpt, &sign);
+  if (sign != 0 || strcmp (p, "inf") != 0)
+    output_error ("ecvt", NAN, 10, "inf", 0, 0, p, decpt, sign);
+
+  /* Simply make sure these calls with large NDIGITs don't crash.  */
+  (void) ecvt (123.456, 10000, &decpt, &sign);
+  (void) fcvt (123.456, 10000, &decpt, &sign);
+
+  /* Some tests for for the reentrant functions.  */
+  /* Use a too small buffer.  */
+  res = ecvt_r (123.456, 10, &decpt, &sign, buf, 1);
+  if (res == 0)
+    {
+      printf ("ecvt_r with a too small buffer was succesful.\n");
+      ++error_count;
+    }
+  res = fcvt_r (123.456, 10, &decpt, &sign, buf, 1);
+  if (res == 0)
+    {
+      printf ("fcvt_r with a too small buffer was succesful.\n");
+      ++error_count;
+    }
+}
+
+
+int
+main (void)
+{
+  test (ecvt_tests, ecvt, "ecvt");
+  test (fcvt_tests, fcvt, "fcvt");
+  test_r (ecvt_tests, ecvt_r, "ecvt_r");
+  test_r (fcvt_tests, fcvt_r, "fcvt_r");
+  special ();
+
+  return error_count;
+}
Index: trunk/src/libctests/glibc/misc/tst-fdset.c
===================================================================
--- trunk/src/libctests/glibc/misc/tst-fdset.c	(revision 2036)
+++ trunk/src/libctests/glibc/misc/tst-fdset.c	(revision 2036)
@@ -0,0 +1,65 @@
+/* Test FD* macros.
+   Copyright (C) 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Robert Bihlmeyer <robbe@orcus.priv.at>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <sys/types.h>
+
+int
+main (void)
+{
+  int retval = 0;
+  int i;
+  fd_set set;
+
+  FD_ZERO (&set);
+  for (i=0; i < FD_SETSIZE; ++i)
+    {
+      printf ("%d =>  check:", i);
+      if (FD_ISSET (i, &set) == 0)
+	fputs ("ok", stdout);
+      else
+	{
+	  fputs ("nok", stdout);
+	  retval = 1;
+	}
+      fputs (", set", stdout);
+      FD_SET (i, &set);
+      fputs (", check:", stdout);
+      if (FD_ISSET (i, &set))
+	fputs ("ok", stdout);
+      else
+	{
+	  fputs ("nok", stdout);
+	  retval = 1;
+	}
+      fputs (", clear", stdout);
+      FD_CLR (i, &set);
+      fputs (", check:", stdout);
+      if (FD_ISSET (i, &set) == 0)
+	puts ("ok");
+      else
+	{
+	  puts ("nok");
+	  retval = 1;
+	}
+    }
+
+  return retval;
+}
Index: trunk/src/libctests/glibc/misc/tst-hsearch.c
===================================================================
--- trunk/src/libctests/glibc/misc/tst-hsearch.c	(revision 2036)
+++ trunk/src/libctests/glibc/misc/tst-hsearch.c	(revision 2036)
@@ -0,0 +1,31 @@
+#include <search.h>
+#include <stdio.h>
+
+int
+main (void)
+{
+  int a = 1;
+  int b = 2;
+  ENTRY i;
+  ENTRY *e;
+
+  if (hcreate (20) == 0)
+    {
+      puts ("hcreate failed");
+      return 1;
+    }
+
+  i.key = (char *) "one";
+  i.data = &a;
+  if (hsearch (i, ENTER) == NULL)
+    return 1;
+
+  i.key = (char *) "one";
+  i.data = &b;
+  e = hsearch (i, ENTER);
+  printf ("e.data = %d\n", *(int *) e->data);
+  if (*(int *) e->data != 1)
+    return 1;
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/misc/tst-mntent.c
===================================================================
--- trunk/src/libctests/glibc/misc/tst-mntent.c	(revision 2036)
+++ trunk/src/libctests/glibc/misc/tst-mntent.c	(revision 2036)
@@ -0,0 +1,79 @@
+/* Test case by Horst von Brand <vonbrand@sleipnir.valparaiso.cl>
+   and Ulrich Drepper <drepper@cygnus.com>.  */
+#include <mntent.h>
+#include <stdio.h>
+#include <string.h>
+
+
+int
+main (int argc, char *argv[])
+{
+  int result = 0;
+  struct mntent mef;
+  struct mntent *mnt = &mef;
+  FILE *fp;
+
+  mef.mnt_fsname = strdupa ("/dev/hda1");
+  mef.mnt_dir = strdupa ("/some dir");
+  mef.mnt_type = strdupa ("ext2");
+  mef.mnt_opts = strdupa ("defaults");
+  mef.mnt_freq = 1;
+  mef.mnt_passno = 2;
+
+  if (hasmntopt (mnt, "defaults"))
+    printf ("Found!\n");
+  else
+    {
+      printf ("Didn't find it\n");
+      result = 1;
+    }
+
+  fp = tmpfile ();
+  if (fp == NULL)
+    {
+      printf ("Cannot open temporary file: %m\n");
+      result = 1;
+    }
+  else
+    {
+      char buf[1024];
+
+      /* Write the name entry.  */
+      addmntent (fp, &mef);
+
+      /* Prepare for reading.  */
+      rewind (fp);
+
+      /* First, read it raw.  */
+      if (fgets (buf, sizeof (buf), fp) == NULL)
+	{
+	  printf ("Cannot read temporary file: %m");
+	  result = 1;
+	}
+      else
+	if (strcmp (buf, "/dev/hda1 /some\\040dir ext2 defaults 1 2\n") != 0)
+	  {
+	    puts ("Raw file data not correct");
+	    result = 1;
+	  }
+
+      /* Prepare for reading, part II.  */
+      rewind (fp);
+
+      /* Now read it cooked.  */
+      mnt = getmntent (fp);
+
+      if (strcmp (mnt->mnt_fsname, "/dev/hda1") != 0
+	  || strcmp (mnt->mnt_dir, "/some dir") != 0
+	  || strcmp (mnt->mnt_type, "ext2") != 0
+	  || strcmp (mnt->mnt_opts, "defaults") != 0
+	  || mnt->mnt_freq != 1
+	  || mnt->mnt_passno != 2)
+	{
+	  puts ("Error while reading written entry back in");
+	  result = 1;
+	}
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/misc/tst-tsearch.c
===================================================================
--- trunk/src/libctests/glibc/misc/tst-tsearch.c	(revision 2036)
+++ trunk/src/libctests/glibc/misc/tst-tsearch.c	(revision 2036)
@@ -0,0 +1,353 @@
+/* Test program for tsearch et al.
+   Copyright (C) 1997, 2000, 2001, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE	1
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <search.h>
+#include <tst-stack-align.h>
+
+#define SEED 0
+#define BALANCED 1
+#define PASSES 100
+
+#if BALANCED
+#include <math.h>
+#define SIZE 1000
+#else
+#define SIZE 100
+#endif
+
+enum order
+{
+  ascending,
+  descending,
+  randomorder
+};
+
+enum action
+{
+  build,
+  build_and_del,
+  delete,
+  find
+};
+
+/* Set to 1 if a test is flunked.  */
+static int error = 0;
+
+/* The keys we add to the tree.  */
+static int x[SIZE];
+
+/* Pointers into the key array, possibly permutated, to define an order
+   for insertion/removal.  */
+static int y[SIZE];
+
+/* Flags set for each element visited during a tree walk.  */
+static int z[SIZE];
+
+/* Depths for all the elements, to check that the depth is constant for
+   all three visits.  */
+static int depths[SIZE];
+
+/* Maximum depth during a tree walk.  */
+static int max_depth;
+
+static int stack_align_check[2];
+
+/* Compare two keys.  */
+static int
+cmp_fn (const void *a, const void *b)
+{
+  if (!stack_align_check[0])
+    stack_align_check[0] = TEST_STACK_ALIGN () ? -1 : 1;
+  return *(const int *) a - *(const int *) b;
+}
+
+/* Permute an array of integers.  */
+static void
+memfry (int *string)
+{
+  int i;
+
+  for (i = 0; i < SIZE; ++i)
+    {
+      int32_t j;
+      int c;
+
+      j = random () % SIZE;
+
+      c = string[i];
+      string[i] = string[j];
+      string[j] = c;
+    }
+}
+
+static void
+walk_action (const void *nodep, const VISIT which, const int depth)
+{
+  int key = **(int **) nodep;
+
+  if (!stack_align_check[1])
+    stack_align_check[1] = TEST_STACK_ALIGN () ? -1 : 1;
+
+  if (depth > max_depth)
+    max_depth = depth;
+  if (which == leaf || which == preorder)
+    {
+      ++z[key];
+      depths[key] = depth;
+    }
+  else
+    {
+      if (depths[key] != depth)
+	{
+	  fputs ("Depth for one element is not constant during tree walk.\n",
+		 stdout);
+	}
+    }
+}
+
+static void
+walk_tree (void *root, int expected_count)
+{
+  int i;
+
+  memset (z, 0, sizeof z);
+  max_depth = 0;
+
+  twalk (root, walk_action);
+  for (i = 0; i < expected_count; ++i)
+    if (z[i] != 1)
+      {
+	fputs ("Node was not visited.\n", stdout);
+	error = 1;
+      }
+
+#if BALANCED
+  if (max_depth > log (expected_count) * 2 + 2)
+#else
+  if (max_depth > expected_count)
+#endif
+    {
+      fputs ("Depth too large during tree walk.\n", stdout);
+      error = 1;
+    }
+}
+
+/* Perform an operation on a tree.  */
+static void
+mangle_tree (enum order how, enum action what, void **root, int lag)
+{
+  int i;
+
+  if (how == randomorder)
+    {
+      for (i = 0; i < SIZE; ++i)
+	y[i] = i;
+      memfry (y);
+    }
+
+  for (i = 0; i < SIZE + lag; ++i)
+    {
+      void *elem;
+      int j, k;
+
+      switch (how)
+	{
+	case randomorder:
+	  if (i >= lag)
+	    k = y[i - lag];
+	  else
+	    /* Ensure that the array index is within bounds.  */
+	    k = y[(SIZE - i - 1 + lag) % SIZE];
+	  j = y[i % SIZE];
+	  break;
+
+	case ascending:
+	  k = i - lag;
+	  j = i;
+	  break;
+
+	case descending:
+	  k = SIZE - i - 1 + lag;
+	  j = SIZE - i - 1;
+	  break;
+
+	default:
+	  /* This never should happen, but gcc isn't smart enough to
+	     recognize it.  */
+	  abort ();
+	}
+
+      switch (what)
+	{
+	case build_and_del:
+	case build:
+	  if (i < SIZE)
+	    {
+	      if (tfind (x + j, (void *const *) root, cmp_fn) != NULL)
+		{
+		  fputs ("Found element which is not in tree yet.\n", stdout);
+		  error = 1;
+		}
+	      elem = tsearch (x + j, root, cmp_fn);
+	      if (elem == 0
+		  || tfind (x + j, (void *const *) root, cmp_fn) == NULL)
+		{
+		  fputs ("Couldn't find element after it was added.\n",
+			 stdout);
+		  error = 1;
+		}
+	    }
+
+	  if (what == build || i < lag)
+	    break;
+
+	  j = k;
+	  /* fall through */
+
+	case delete:
+	  elem = tfind (x + j, (void *const *) root, cmp_fn);
+	  if (elem == NULL || tdelete (x + j, root, cmp_fn) == NULL)
+	    {
+	      fputs ("Error deleting element.\n", stdout);
+	      error = 1;
+	    }
+	  break;
+
+	case find:
+	  if (tfind (x + j, (void *const *) root, cmp_fn) == NULL)
+	    {
+	      fputs ("Couldn't find element after it was added.\n", stdout);
+	      error = 1;
+	    }
+	  break;
+
+	}
+    }
+}
+
+
+int
+main (int argc, char **argv)
+{
+  int total_error = 0;
+  static char state[8] = { 1, 2, 3, 4, 5, 6, 7, 8 };
+  void *root = NULL;
+  int i, j;
+
+  initstate (SEED, state, 8);
+
+  for (i = 0; i < SIZE; ++i)
+    x[i] = i;
+
+  /* Do this loop several times to get different permutations for the
+     random case.  */
+  fputs ("Series I\n", stdout);
+  for (i = 0; i < PASSES; ++i)
+    {
+      fprintf (stdout, "Pass %d... ", i + 1);
+      fflush (stdout);
+      error = 0;
+
+      mangle_tree (ascending, build, &root, 0);
+      mangle_tree (ascending, find, &root, 0);
+      mangle_tree (descending, find, &root, 0);
+      mangle_tree (randomorder, find, &root, 0);
+      walk_tree (root, SIZE);
+      mangle_tree (ascending, delete, &root, 0);
+
+      mangle_tree (ascending, build, &root, 0);
+      walk_tree (root, SIZE);
+      mangle_tree (descending, delete, &root, 0);
+
+      mangle_tree (ascending, build, &root, 0);
+      walk_tree (root, SIZE);
+      mangle_tree (randomorder, delete, &root, 0);
+
+      mangle_tree (descending, build, &root, 0);
+      mangle_tree (ascending, find, &root, 0);
+      mangle_tree (descending, find, &root, 0);
+      mangle_tree (randomorder, find, &root, 0);
+      walk_tree (root, SIZE);
+      mangle_tree (descending, delete, &root, 0);
+
+      mangle_tree (descending, build, &root, 0);
+      walk_tree (root, SIZE);
+      mangle_tree (descending, delete, &root, 0);
+
+      mangle_tree (descending, build, &root, 0);
+      walk_tree (root, SIZE);
+      mangle_tree (randomorder, delete, &root, 0);
+
+      mangle_tree (randomorder, build, &root, 0);
+      mangle_tree (ascending, find, &root, 0);
+      mangle_tree (descending, find, &root, 0);
+      mangle_tree (randomorder, find, &root, 0);
+      walk_tree (root, SIZE);
+      mangle_tree (randomorder, delete, &root, 0);
+
+      for (j = 1; j < SIZE; j *= 2)
+	{
+	  mangle_tree (randomorder, build_and_del, &root, j);
+	}
+
+      fputs (error ? " failed!\n" : " ok.\n", stdout);
+      total_error |= error;
+    }
+
+  fputs ("Series II\n", stdout);
+  for (i = 1; i < SIZE; i *= 2)
+    {
+      fprintf (stdout, "For size %d... ", i);
+      fflush (stdout);
+      error = 0;
+
+      mangle_tree (ascending, build_and_del, &root, i);
+      mangle_tree (descending, build_and_del, &root, i);
+      mangle_tree (ascending, build_and_del, &root, i);
+      mangle_tree (descending, build_and_del, &root, i);
+      mangle_tree (ascending, build_and_del, &root, i);
+      mangle_tree (descending, build_and_del, &root, i);
+      mangle_tree (ascending, build_and_del, &root, i);
+      mangle_tree (descending, build_and_del, &root, i);
+
+      fputs (error ? " failed!\n" : " ok.\n", stdout);
+      total_error |= error;
+    }
+
+  for (i = 0; i < 2; ++i)
+    if (stack_align_check[i] == 0)
+      {
+        printf ("stack alignment check %d not run\n", i);
+        total_error |= 1;
+      }
+    else if (stack_align_check[i] != 1)
+      {
+        printf ("stack insufficiently aligned in check %d\n", i);
+        total_error |= 1;
+      }
+
+  return total_error;
+}
Index: trunk/src/libctests/glibc/nptl/Makefile
===================================================================
--- trunk/src/libctests/glibc/nptl/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/Makefile	(revision 2036)
@@ -0,0 +1,592 @@
+# Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Sub-makefile for NPTL portion of the library.
+#
+subdir	:= nptl
+
+headers := pthread.h semaphore.h bits/semaphore.h
+
+extra-libs := libpthread
+extra-libs-others := $(extra-libs)
+install-lib-ldscripts := libpthread.so
+
+routines = alloca_cutoff forward libc-lowlevellock libc-cancellation
+shared-only-routines = forward
+
+libpthread-routines = init vars events version \
+		      pthread_create pthread_exit pthread_detach \
+		      pthread_join pthread_tryjoin pthread_timedjoin \
+		      pthread_self pthread_equal pthread_yield \
+		      pthread_getconcurrency pthread_setconcurrency \
+		      pthread_getschedparam pthread_setschedparam \
+		      pthread_setschedprio \
+		      pthread_attr_init pthread_attr_destroy \
+		      pthread_attr_getdetachstate pthread_attr_setdetachstate \
+		      pthread_attr_getguardsize pthread_attr_setguardsize \
+		      pthread_attr_getschedparam pthread_attr_setschedparam \
+		      pthread_attr_getschedpolicy pthread_attr_setschedpolicy \
+		      pthread_attr_getinheritsched \
+		      pthread_attr_setinheritsched \
+		      pthread_attr_getscope pthread_attr_setscope \
+		      pthread_attr_getstackaddr pthread_attr_setstackaddr \
+		      pthread_attr_getstacksize pthread_attr_setstacksize \
+		      pthread_attr_getstack pthread_attr_setstack \
+		      pthread_getattr_np \
+		      pthread_mutex_init pthread_mutex_destroy \
+		      pthread_mutex_lock pthread_mutex_trylock \
+		      pthread_mutex_timedlock pthread_mutex_unlock \
+		      pthread_mutexattr_init pthread_mutexattr_destroy \
+		      pthread_mutexattr_getpshared \
+		      pthread_mutexattr_setpshared \
+		      pthread_mutexattr_gettype pthread_mutexattr_settype \
+		      pthread_rwlock_init pthread_rwlock_destroy \
+		      pthread_rwlock_rdlock pthread_rwlock_timedrdlock \
+		      pthread_rwlock_wrlock pthread_rwlock_timedwrlock \
+		      pthread_rwlock_tryrdlock pthread_rwlock_trywrlock \
+		      pthread_rwlock_unlock \
+		      pthread_rwlockattr_init pthread_rwlockattr_destroy \
+		      pthread_rwlockattr_getpshared \
+		      pthread_rwlockattr_setpshared \
+		      pthread_rwlockattr_getkind_np \
+		      pthread_rwlockattr_setkind_np \
+		      pthread_cond_init pthread_cond_destroy \
+		      pthread_cond_wait pthread_cond_timedwait \
+		      pthread_cond_signal pthread_cond_broadcast \
+		      old_pthread_cond_init old_pthread_cond_destroy \
+		      old_pthread_cond_wait old_pthread_cond_timedwait \
+		      old_pthread_cond_signal old_pthread_cond_broadcast \
+		      pthread_condattr_init pthread_condattr_destroy \
+		      pthread_condattr_getpshared pthread_condattr_setpshared \
+		      pthread_condattr_getclock pthread_condattr_setclock \
+		      pthread_spin_init pthread_spin_destroy \
+		      pthread_spin_lock pthread_spin_trylock \
+		      pthread_spin_unlock \
+		      pthread_barrier_init pthread_barrier_destroy \
+		      pthread_barrier_wait \
+		      pthread_barrierattr_init pthread_barrierattr_destroy \
+		      pthread_barrierattr_getpshared \
+		      pthread_barrierattr_setpshared \
+		      pthread_key_create pthread_key_delete \
+		      pthread_getspecific pthread_setspecific \
+		      pthread_sigmask pthread_kill \
+		      pthread_cancel pthread_testcancel \
+		      pthread_setcancelstate pthread_setcanceltype \
+		      pthread_once \
+		      old_pthread_atfork pthread_atfork \
+		      pthread_getcpuclockid \
+		      pthread_clock_gettime pthread_clock_settime \
+		      sem_init sem_destroy \
+		      sem_open sem_close sem_unlink \
+		      sem_getvalue \
+		      sem_wait sem_trywait sem_timedwait sem_post \
+		      cleanup cleanup_defer cleanup_compat \
+		      cleanup_defer_compat unwind \
+		      pt-longjmp pt-cleanup\
+		      cancellation \
+		      lowlevellock \
+		      pt-vfork \
+		      ptw-write ptw-read ptw-close ptw-fcntl ptw-accept \
+		      ptw-connect ptw-recv ptw-recvfrom ptw-recvmsg ptw-send \
+		      ptw-sendmsg ptw-sendto ptw-fsync ptw-lseek ptw-llseek \
+		      ptw-msync ptw-nanosleep ptw-open ptw-open64 ptw-pause \
+		      ptw-pread ptw-pread64 ptw-pwrite ptw-pwrite64 \
+		      ptw-tcdrain ptw-wait ptw-waitpid ptw-msgrcv ptw-msgsnd \
+		      ptw-sigwait \
+		      pt-raise pt-system \
+		      flockfile ftrylockfile funlockfile \
+		      sigaction \
+		      herrno res pt-allocrtsig \
+		      pthread_kill_other_threads \
+		      pthread_getaffinity pthread_setaffinity \
+		      pthread_attr_getaffinity pthread_attr_setaffinity \
+		      cleanup_routine unwind-forcedunwind
+#		      pthread_setuid pthread_seteuid pthread_setreuid \
+#		      pthread_setresuid \
+#		      pthread_setgid pthread_setegid pthread_setregid \
+#		      pthread_setresgid
+
+libpthread-shared-only-routines = version pt-allocrtsig unwind-forcedunwind
+libpthread-static-only-routines = pthread_atfork
+
+CFLAGS-pthread_atfork.c = -DNOT_IN_libc
+
+# Since cancellation handling is in large parts handled using exceptions
+# we have to compile some files with exception handling enabled, some
+# even with asynchronous unwind tables.
+
+# init.c contains sigcancel_handler().
+CFLAGS-init.c = -fexceptions -fasynchronous-unwind-tables
+# The unwind code itself,
+CFLAGS-unwind.c = -fexceptions
+CFLAGS-unwind-forcedunwind.c = -fexceptions -fasynchronous-unwind-tables
+
+# The following three functions must be async-cancel safe.
+CFLAGS-pthread_cancel.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-pthread_setcancelstate.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-pthread_setcanceltype.c = -fexceptions -fasynchronous-unwind-tables
+
+# These are internal functions which similar functionality as setcancelstate
+# and setcanceltype.
+CFLAGS-cancellation.c = -fasynchronous-unwind-tables
+CFLAGS-libc-cancellation.c = -fasynchronous-unwind-tables
+
+# Calling pthread_exit() must cause the registered cancel handlers to
+# be executed.  Therefore exceptions have to be thrown through this
+# function.
+CFLAGS-pthread_exit.c = -fexceptions
+
+# Among others, __pthread_unwind is forwarded.  This function must handle
+# exceptions.
+CFLAGS-forward.c = -fexceptions
+
+# The following are cancellation points.  Some of the functions can
+# block and therefore temporarily enable asynchronous cancellation.
+# Those must be compiled asynchronous unwind tables.
+CFLAGS-pthread_testcancel.c = -fexceptions
+CFLAGS-pthread_join.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-pthread_timedjoin.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-pthread_once.c = $(uses-callbacks) -fexceptions \
+			-fasynchronous-unwind-tables
+CFLAGS-pthread_cond_wait.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-pthread_cond_timedwait.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-sem_wait.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-sem_timedwait.c = -fexceptions -fasynchronous-unwind-tables
+
+# These are the function wrappers we have to duplicate here.
+CFLAGS-fcntl.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-lockf.c = -fexceptions
+CFLAGS-pread.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-pread64.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-pwrite.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-pwrite64.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-wait.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-waitpid.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-sigwait.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-msgrcv.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-msgsnd.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-tcdrain.c = -fexceptions -fasynchronous-unwind-tables
+
+CFLAGS-pt-system.c = -fexceptions
+
+# Don't generate deps for calls with no sources.  See sysdeps/unix/Makefile.
+omit-deps = $(unix-syscalls:%=ptw-%)
+
+
+tests = tst-attr1 tst-attr2 tst-attr3 \
+	tst-mutex1 tst-mutex2 tst-mutex3 tst-mutex4 tst-mutex5 tst-mutex6 \
+	tst-mutex7 tst-mutex8 tst-mutex9 tst-mutex5a tst-mutex7a \
+	tst-spin1 tst-spin2 tst-spin3 \
+	tst-cond1 tst-cond2 tst-cond3 tst-cond4 tst-cond5 tst-cond6 tst-cond7 \
+	tst-cond8 tst-cond9 tst-cond10 tst-cond11 tst-cond12 tst-cond13 \
+	tst-cond14 tst-cond15 tst-cond16 tst-cond17 tst-cond18 tst-cond19 \
+	tst-cond20 tst-cond21 \
+	tst-rwlock1 tst-rwlock2 tst-rwlock3 tst-rwlock4 tst-rwlock5 \
+	tst-rwlock6 tst-rwlock7 tst-rwlock8 tst-rwlock9 tst-rwlock10 \
+	tst-rwlock11 tst-rwlock12 tst-rwlock13 tst-rwlock14 \
+	tst-once1 tst-once2 tst-once3 tst-once4 \
+	tst-key1 tst-key2 tst-key3 tst-key4 \
+	tst-sem1 tst-sem2 tst-sem3 tst-sem4 tst-sem5 tst-sem6 tst-sem7 \
+	tst-sem8 tst-sem9 \
+	tst-barrier1 tst-barrier2 tst-barrier3 tst-barrier4 \
+	tst-align tst-align2 \
+	tst-basic1 tst-basic2 tst-basic3 tst-basic4 tst-basic5 tst-basic6 \
+	tst-kill1 tst-kill2 tst-kill3 tst-kill4 tst-kill5 tst-kill6 \
+	tst-raise1 \
+	tst-join1 tst-join2 tst-join3 tst-join4 tst-join5 \
+	tst-detach1 \
+	tst-eintr1 tst-eintr2 tst-eintr3 tst-eintr4 tst-eintr5 \
+	tst-tsd1 tst-tsd2 tst-tsd3 tst-tsd4 tst-tsd5 \
+	tst-tls1 tst-tls2 \
+	tst-fork1 tst-fork2 tst-fork3 tst-fork4 \
+	tst-atfork1 \
+	tst-cancel1 tst-cancel2 tst-cancel3 tst-cancel4 tst-cancel5 \
+	tst-cancel6 tst-cancel7 tst-cancel8 tst-cancel9 tst-cancel10 \
+	tst-cancel11 tst-cancel12 tst-cancel13 tst-cancel14 tst-cancel15 \
+	tst-cancel16 tst-cancel17 tst-cancel18 tst-cancel19 tst-cancel20 \
+	tst-cancel21 tst-cancel22 tst-cancel23 \
+	tst-cleanup0 tst-cleanup1 tst-cleanup2 tst-cleanup3 tst-cleanup4 \
+	tst-flock1 tst-flock2 \
+	tst-signal1 tst-signal2 tst-signal3 tst-signal4 tst-signal5 \
+	tst-signal6 \
+	tst-exec1 tst-exec2 tst-exec3 tst-exec4 \
+	tst-exit1 tst-exit2 tst-exit3 \
+	tst-stdio1 tst-stdio2 \
+	tst-stack1 tst-stack2 tst-stack3 \
+	tst-unload \
+	tst-dlsym1 \
+	tst-sysconf \
+	tst-locale1 tst-locale2 \
+	tst-umask1 \
+	tst-popen1 \
+	tst-clock1 \
+	tst-context1 \
+	tst-sched1 \
+	tst-backtrace1 \
+	tst-oddstacklimit \
+	tst-vfork1 tst-vfork2 tst-vfork1x tst-vfork2x \
+	tst-getpid1 tst-getpid2
+xtests = tst-setuid1 tst-setuid1-static
+
+# Files which must not be linked with libpthread.
+tests-nolibpthread = tst-unload
+
+# This sets the stack resource limit to 1023kb, which is not a multiple
+# of the page size since every architecture's page size is > 1k.
+tst-oddstacklimit-ENV = ; ulimit -s 1023;
+
+distribute = eintr.c tst-cleanup4aux.c
+
+gen-as-const-headers = pthread-errnos.sym
+
+LDFLAGS-pthread.so = -Wl,--enable-new-dtags,-z,nodelete,-z,initfirst
+
+
+include ../Makeconfig
+
+ifeq ($(have-forced-unwind),yes)
+tests += tst-cancelx2 tst-cancelx3 tst-cancelx4 tst-cancelx5 \
+	 tst-cancelx6 tst-cancelx7 tst-cancelx8 tst-cancelx9 tst-cancelx10 \
+	 tst-cancelx11 tst-cancelx12 tst-cancelx13 tst-cancelx14 tst-cancelx15 \
+	 tst-cancelx16 tst-cancelx17 tst-cancelx18 tst-cancelx20 tst-cancelx21 \
+	 tst-cleanupx0 tst-cleanupx1 tst-cleanupx2 tst-cleanupx3 tst-cleanupx4 \
+	 tst-oncex3 tst-oncex4
+endif
+ifeq ($(build-shared),yes)
+tests += tst-atfork2 tst-tls3 tst-tls4 tst-tls5 tst-_res1 tst-fini1
+tests-nolibpthread += tst-fini1
+ifeq ($(have-z-execstack),yes)
+tests += tst-execstack
+endif
+endif
+
+modules-names = tst-atfork2mod tst-tls3mod tst-tls4moda tst-tls4modb \
+		tst-tls5mod tst-tls5moda tst-tls5modb tst-tls5modc \
+		tst-tls5modd tst-tls5mode tst-tls5modf \
+		tst-_res1mod1 tst-_res1mod2 tst-execstack-mod tst-fini1mod
+extra-objs += $(addsuffix .os,$(strip $(modules-names))) tst-cleanup4aux.o
+test-extras += $(modules-names)
+test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(modules-names)))
+
+tst-atfork2mod.so-no-z-defs = yes
+tst-tls3mod.so-no-z-defs = yes
+tst-tls5mod.so-no-z-defs = yes
+tst-tls5moda.so-no-z-defs = yes
+tst-tls5modb.so-no-z-defs = yes
+tst-tls5modc.so-no-z-defs = yes
+tst-tls5modd.so-no-z-defs = yes
+tst-tls5mode.so-no-z-defs = yes
+tst-tls5modf.so-no-z-defs = yes
+
+$(test-modules): $(objpfx)%.so: $(objpfx)%.os $(common-objpfx)shlib.lds
+	$(build-module)
+
+ifeq ($(build-shared),yes)
+# Build all the modules even when not actually running test programs.
+tests: $(test-modules)
+endif
+
+ifeq ($(build-shared),yes)
+
+# Set the `multidir' variable by grabbing the variable from the compiler.
+# We do it once and save the result in a generated makefile.
+-include $(objpfx)multidir.mk
+$(objpfx)multidir.mk: $(common-objpfx)config.make
+	$(make-target-directory)
+	dir=`$(CC) $(CFLAGS) $(CPPFLAGS) -print-multi-directory`; \
+	echo "multidir := $$dir" > $@T
+	mv -f $@T $@
+
+crti-objs := crti.o
+crtn-objs := crtn.o
+ifneq (,$(patsubst .,,$(multidir)))
+generated-dirs := $(firstword $(subst /, , $(multidir)))
+crti-objs += $(multidir)/crti.o
+crtn-objs += $(multidir)/crtn.o
+omit-deps += $(multidir)/crti $(multidir)/crtn
+$(objpfx)$(multidir):
+	mkdir $@
+endif
+extra-objs += $(crti-objs) $(crtn-objs)
+omit-deps += crti crtn
+
+CFLAGS-pt-initfini.s = -g0 -fPIC -fno-inline-functions $(fno-unit-at-a-time)
+endif
+
+CFLAGS-flockfile.c = -D_IO_MTSAFE_IO
+CFLAGS-ftrylockfile.c = -D_IO_MTSAFE_IO
+CFLAGS-funlockfile.c = -D_IO_MTSAFE_IO
+
+link-libc-static := $(common-objpfx)libc.a $(static-gnulib) \
+		    $(common-objpfx)libc.a
+
+ifeq ($(build-static),yes)
+tests-static += tst-locale1 tst-locale2
+xtests-static += tst-setuid1-static
+endif
+# These tests are linked with libc before libpthread
+tests-reverse += tst-cancel5 tst-cancel23 tst-vfork1x tst-vfork2x
+
+include ../Rules
+
+ifeq (yes,$(build-shared))
+# Make sure these things are built in the `make lib' pass so they can be used
+# to run programs during the `make others' pass.
+lib-noranlib: $(addprefix $(objpfx),$(extra-objs))
+
+# What we install as libpthread.so for programs to link against is in fact a
+# link script.  It contains references for the various libraries we need.
+# The libpthread.so object is not complete since some functions are only
+# defined in libpthread_nonshared.a.
+# We need to use absolute paths since otherwise local copies (if they exist)
+# of the files are taken by the linker.
+install: $(inst_libdir)/libpthread.so
+
+$(inst_libdir)/libpthread.so: $(common-objpfx)format.lds \
+			      $(objpfx)libpthread.so$(libpthread.so-version) \
+			      $(inst_libdir)/$(patsubst %,$(libtype.oS),\
+							$(libprefix)pthread) \
+			      $(+force)
+	(echo '/* GNU ld script';\
+	 echo '   Use the shared library, but some functions are only in';\
+	 echo '   the static library, so try that secondarily.  */';\
+	 cat $<; \
+	 echo 'GROUP ( $(slibdir)/libpthread.so$(libpthread.so-version)' \
+	      '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)pthread)'\
+	      ')' \
+	) > $@.new
+	mv -f $@.new $@
+endif
+
+
+# 'pthread_self' is a simple memory or register load.  Setting up the
+# stack frame is more work than the actual operation.  Disable the
+# frame creation entirely.  This will help applications which call the
+# function frequently to get a thread-specific handle.
+CFLAGS-pthread_self.os += -fomit-frame-pointer
+
+# Run the cancellation and cleanup tests also for the modern, exception-based
+# implementation.  For this we have to pass the -fexceptions parameter.
+CFLAGS-tst-cancelx2.c += -fexceptions
+CFLAGS-tst-cancelx3.c += -fexceptions
+CFLAGS-tst-cancelx4.c += -fexceptions
+CFLAGS-tst-cancelx5.c += -fexceptions
+CFLAGS-tst-cancelx6.c += -fexceptions
+CFLAGS-tst-cancelx7.c += -fexceptions
+CFLAGS-tst-cancelx8.c += -fexceptions
+CFLAGS-tst-cancelx9.c += -fexceptions
+CFLAGS-tst-cancelx10.c += -fexceptions
+CFLAGS-tst-cancelx11.c += -fexceptions
+CFLAGS-tst-cancelx12.c += -fexceptions
+CFLAGS-tst-cancelx13.c += -fexceptions
+CFLAGS-tst-cancelx14.c += -fexceptions
+CFLAGS-tst-cancelx15.c += -fexceptions
+CFLAGS-tst-cancelx16.c += -fexceptions
+CFLAGS-tst-cancelx17.c += -fexceptions
+CFLAGS-tst-cancelx18.c += -fexceptions
+CFLAGS-tst-cancelx20.c += -fexceptions -fasynchronous-unwind-tables
+CFLAGS-tst-cancelx21.c += -fexceptions -fasynchronous-unwind-tables
+CFLAGS-tst-cleanupx0.c += -fexceptions -fasynchronous-unwind-tables
+CFLAGS-tst-cleanupx1.c += -fexceptions -fasynchronous-unwind-tables
+CFLAGS-tst-cleanupx2.c += -fexceptions
+CFLAGS-tst-cleanupx3.c += -fexceptions
+CFLAGS-tst-cleanupx4.c += -fexceptions
+CFLAGS-tst-oncex3.c += -fexceptions
+CFLAGS-tst-oncex4.c += -fexceptions
+CFLAGS-tst-align.c += $(stack-align-test-flags)
+
+tst-cancel7-ARGS = --command "$(built-program-cmd)"
+tst-cancelx7-ARGS = $(tst-cancel7-ARGS)
+tst-umask1-ARGS = $(objpfx)tst-umask1.temp
+
+$(objpfx)tst-atfork2: $(libdl) $(shared-thread-library)
+LDFLAGS-tst-atfork2 = -rdynamic
+tst-atfork2-ENV = MALLOC_TRACE=$(objpfx)tst-atfork2.mtrace
+$(objpfx)tst-atfork2mod.so: $(shared-thread-library)
+
+tests: $(objpfx)tst-stack3-mem
+tst-stack3-ENV = MALLOC_TRACE=$(objpfx)tst-stack3.mtrace
+$(objpfx)tst-stack3-mem: $(objpfx)tst-stack3.out
+	$(common-objpfx)malloc/mtrace $(objpfx)tst-stack3.mtrace > $@
+generated += tst-stack3-mem tst-stack3.mtrace
+
+$(objpfx)tst-cleanup4: $(objpfx)tst-cleanup4aux.o $(shared-thread-library)
+$(objpfx)tst-cleanupx4: $(objpfx)tst-cleanup4aux.o $(shared-thread-library)
+
+$(objpfx)tst-tls3: $(libdl) $(shared-thread-library)
+LDFLAGS-tst-tls3 = -rdynamic
+$(objpfx)tst-tls3.out: $(objpfx)tst-tls3mod.so
+$(objpfx)tst-tls3mod.so: $(shared-thread-library)
+
+$(objpfx)tst-tls4: $(libdl) $(shared-thread-library)
+$(objpfx)tst-tls4.out: $(objpfx)tst-tls4moda.so $(objpfx)tst-tls4modb.so
+
+$(objpfx)tst-tls5: $(objpfx)tst-tls5mod.so $(shared-thread-library)
+LDFLAGS-tst-tls5mod.so = -Wl,-soname,tst-tls5mod.so
+
+ifeq ($(build-shared),yes)
+tests: $(objpfx)tst-tls6.out
+$(objpfx)tst-tls6.out: tst-tls6.sh $(objpfx)tst-tls5 \
+		       $(objpfx)tst-tls5moda.so $(objpfx)tst-tls5modb.so \
+		       $(objpfx)tst-tls5modc.so $(objpfx)tst-tls5modd.so \
+		       $(objpfx)tst-tls5mode.so $(objpfx)tst-tls5modf.so
+	$(SHELL) -e tst-tls6.sh $(common-objpfx) $(elf-objpfx) \
+		    $(rtld-installed-name)
+endif
+
+$(objpfx)tst-dlsym1: $(libdl) $(shared-thread-library)
+
+$(objpfx)tst-fini1: $(shared-thread-library) $(objpfx)tst-fini1mod.so
+
+ifeq (yes,$(build-shared))
+$(objpfx)tst-cond11: $(common-objpfx)rt/librt.so
+$(objpfx)tst-cond19: $(common-objpfx)rt/librt.so
+$(objpfx)tst-cancel17: $(common-objpfx)rt/librt.so
+$(objpfx)tst-cancelx17: $(common-objpfx)rt/librt.so
+$(objpfx)tst-cancel18: $(common-objpfx)rt/librt.so
+$(objpfx)tst-cancelx18: $(common-objpfx)rt/librt.so
+$(objpfx)tst-clock2: $(common-objpfx)rt/librt.so
+$(objpfx)tst-rwlock14: $(common-objpfx)rt/librt.so
+$(objpfx)tst-_res1mod2.so: $(objpfx)tst-_res1mod1.so
+LDFLAGS-tst-_res1mod1.so = -Wl,-soname,tst-_res1mod1.so
+LDFLAGS-tst-_res1mod2.so = -Wl,-soname,tst-_res1mod2.so
+$(objpfx)tst-_res1: $(objpfx)tst-_res1mod2.so $(shared-thread-library)
+else
+$(objpfx)tst-cond11: $(common-objpfx)rt/librt.a
+$(objpfx)tst-cond19: $(common-objpfx)rt/librt.a
+$(objpfx)tst-cancel17: $(common-objpfx)rt/librt.a
+$(objpfx)tst-cancelx17: $(common-objpfx)rt/librt.a
+$(objpfx)tst-cancel18: $(common-objpfx)rt/librt.a
+$(objpfx)tst-cancelx18: $(common-objpfx)rt/librt.a
+$(objpfx)tst-clock2: $(common-objpfx)rt/librt.a
+$(objpfx)tst-rwlock14: $(common-objpfx)rt/librt.a
+endif
+
+extra-B-pthread.so = -B$(common-objpfx)nptl/
+$(objpfx)libpthread.so: $(addprefix $(objpfx),$(crti-objs) $(crtn-objs))
+$(objpfx)libpthread.so: +preinit += $(addprefix $(objpfx),$(crti-objs))
+$(objpfx)libpthread.so: +postinit += $(addprefix $(objpfx),$(crtn-objs))
+
+# Depend on libc.so so a DT_NEEDED is generated in the shared objects.
+# This ensures they will load libc.so for needed symbols if loaded by
+# a statically-linked program that hasn't already loaded it.
+# Depend on ld.so too to get proper versions of ld.so symbols.
+$(objpfx)libpthread.so: $(common-objpfx)libc.so \
+			$(common-objpfx)libc_nonshared.a \
+			$(if $(filter yes,$(elf)), $(elfobjdir)/ld.so)
+
+# Make sure we link with the thread library.
+ifeq ($(build-shared),yes)
+$(addprefix $(objpfx), \
+  $(filter-out $(tests-static) $(xtests-static) $(tests-reverse) \
+    $(tests-nolibpthread), \
+    $(tests) $(xtests) $(test-srcs))): $(objpfx)libpthread.so \
+				       $(objpfx)libpthread_nonshared.a
+$(objpfx)tst-unload: $(common-objpfx)dlfcn/libdl.so
+# $(objpfx)../libc.so is used instead of $(common-objpfx)libc.so,
+# since otherwise libpthread.so comes before libc.so when linking.
+$(addprefix $(objpfx), $(tests-reverse)): \
+  $(objpfx)../libc.so $(objpfx)libpthread.so \
+  $(objpfx)libpthread_nonshared.a
+$(objpfx)../libc.so: $(common-objpfx)libc.so ;
+$(addprefix $(objpfx),$(tests-static) $(xtests-static)): $(objpfx)libpthread.a
+
+$(objpfx)tst-atfork2.out: $(objpfx)tst-atfork2mod.so
+else
+$(addprefix $(objpfx),$(tests) $(test-srcs)): $(objpfx)libpthread.a
+endif
+
+ifeq ($(build-shared),yes)
+vpath pt-initfini.c $(full_config_sysdirs)
+
+$(objpfx)pt-initfini.s: pt-initfini.c
+	$(compile.c) -S $(CFLAGS-pt-initfini.s) -finhibit-size-directive \
+		$(patsubst -f%,-fno-%,$(exceptions)) -o $@
+
+$(objpfx)tst-cleanup0.out: /dev/null $(objpfx)tst-cleanup0
+	$(make-test-out) 2>&1 | cmp - tst-cleanup0.expect >& $@
+
+# We only have one kind of startup code files.  Static binaries and
+# shared libraries are build using the PIC version.
+$(objpfx)crti.S: $(objpfx)pt-initfini.s
+	sed -n -e '1,/@HEADER_ENDS/p' \
+	       -e '/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \
+	       -e '/@TRAILER_BEGINS/,$$p' $< > $@
+$(objpfx)crtn.S: $(objpfx)pt-initfini.s
+	sed -n -e '1,/@HEADER_ENDS/p' \
+	       -e '/@_.*_EPILOG_BEGINS/,/@_.*_EPILOG_ENDS/p' \
+	       -e '/@TRAILER_BEGINS/,$$p' $< > $@
+
+$(objpfx)defs.h: $(objpfx)pt-initfini.s
+	sed -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \
+		$(AWK) -f ../csu/defs.awk > $@
+
+$(objpfx)crti.o: $(objpfx)crti.S $(objpfx)defs.h
+	$(compile.S) -g0 $(ASFLAGS-.os) -o $@
+
+$(objpfx)crtn.o: $(objpfx)crtn.S $(objpfx)defs.h
+	$(compile.S) -g0 $(ASFLAGS-.os) -o $@
+
+ifneq ($(multidir),.)
+$(objpfx)$(multidir)/crti.o: $(objpfx)crti.o $(objpfx)$(multidir)/
+	ln -f $< $@
+
+$(objpfx)$(multidir)/crtn.o: $(objpfx)crtn.o $(objpfx)$(multidir)/
+	ln -f $< $@
+endif
+
+generated += crti.S crtn.S defs.h pt-initfini.s  libpthread_nonshared.a \
+	     multidir.mk tst-atfork2.mtrace tst-cancel-wrappers.out \
+	     tst-tls6.out
+
+generated += $(objpfx)tst-atfork2.mtrace \
+	     $(addsuffix .so,$(strip $(modules-names)))
+
+$(objpfx)version.d: $(objpfx)banner.h
+$(objpfx)version.os: $(objpfx)banner.h
+$(objpfx)banner.h: Banner
+	sed 's/\(.*\)/"\1\\n"/' $< > $@
+generated += banner.h
+# Give libpthread.so an entry point and make it directly runnable itself.
+LDFLAGS-pthread.so += -e __nptl_main
+endif
+
+ifeq (no,$(cross-compiling))
+ifeq (yes,$(build-shared))
+tests: $(objpfx)tst-cancel-wrappers.out
+$(objpfx)tst-cancel-wrappers.out: tst-cancel-wrappers.sh
+	$(SHELL) $< $(common-objpfx)libc_pic.a \
+		    $(common-objpfx)libc.a \
+		    $(objpfx)libpthread_pic.a \
+		    $(objpfx)libpthread.a > $@
+endif
+endif
+
+tst-exec4-ARGS = $(built-program-cmd)
+
+$(objpfx)tst-execstack: $(libdl)
+$(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
+LDFLAGS-tst-execstack = -Wl,-z,noexecstack
+
+$(objpfx)tst-fini1mod.so: $(shared-thread-library)
+
+# The tests here better do not run in parallel
+ifneq ($(filter %tests,$(MAKECMDGOALS)),)
+.NOTPARALLEL:
+endif
Index: trunk/src/libctests/glibc/nptl/TODO-testing
===================================================================
--- trunk/src/libctests/glibc/nptl/TODO-testing	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/TODO-testing	(revision 2036)
@@ -0,0 +1,20 @@
+pthread_attr_setguardsize
+
+  test effectiveness
+
+pthread_attr_[sg]etschedparam
+
+  what to test?
+
+pthread_attr_[sg]etstack
+
+  some more tests needed
+
+pthread_getcpuclockid
+
+  check that value is reset -> rt subdir
+
+pthread_getschedparam
+pthread_setschedparam
+
+  what to test?
Index: trunk/src/libctests/glibc/nptl/allocatestack.c
===================================================================
--- trunk/src/libctests/glibc/nptl/allocatestack.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/allocatestack.c	(revision 2036)
@@ -0,0 +1,947 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <assert.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdint.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/param.h>
+#include <dl-sysdep.h>
+#include <tls.h>
+#include <lowlevellock.h>
+
+
+#ifndef NEED_SEPARATE_REGISTER_STACK
+
+/* Most architectures have exactly one stack pointer.  Some have more.  */
+# define STACK_VARIABLES void *stackaddr
+
+/* How to pass the values to the 'create_thread' function.  */
+# define STACK_VARIABLES_ARGS stackaddr
+
+/* How to declare function which gets there parameters.  */
+# define STACK_VARIABLES_PARMS void *stackaddr
+
+/* How to declare allocate_stack.  */
+# define ALLOCATE_STACK_PARMS void **stack
+
+/* This is how the function is called.  We do it this way to allow
+   other variants of the function to have more parameters.  */
+# define ALLOCATE_STACK(attr, pd) allocate_stack (attr, pd, &stackaddr)
+
+#else
+
+/* We need two stacks.  The kernel will place them but we have to tell
+   the kernel about the size of the reserved address space.  */
+# define STACK_VARIABLES void *stackaddr; size_t stacksize
+
+/* How to pass the values to the 'create_thread' function.  */
+# define STACK_VARIABLES_ARGS stackaddr, stacksize
+
+/* How to declare function which gets there parameters.  */
+# define STACK_VARIABLES_PARMS void *stackaddr, size_t stacksize
+
+/* How to declare allocate_stack.  */
+# define ALLOCATE_STACK_PARMS void **stack, size_t *stacksize
+
+/* This is how the function is called.  We do it this way to allow
+   other variants of the function to have more parameters.  */
+# define ALLOCATE_STACK(attr, pd) \
+  allocate_stack (attr, pd, &stackaddr, &stacksize)
+
+#endif
+
+
+/* Default alignment of stack.  */
+#ifndef STACK_ALIGN
+# define STACK_ALIGN __alignof__ (long double)
+#endif
+
+/* Default value for minimal stack size after allocating thread
+   descriptor and guard.  */
+#ifndef MINIMAL_REST_STACK
+# define MINIMAL_REST_STACK	4096
+#endif
+
+
+/* Let the architecture add some flags to the mmap() call used to
+   allocate stacks.  */
+#ifndef ARCH_MAP_FLAGS
+# define ARCH_MAP_FLAGS 0
+#endif
+
+/* This yields the pointer that TLS support code calls the thread pointer.  */
+#if TLS_TCB_AT_TP
+# define TLS_TPADJ(pd) (pd)
+#elif TLS_DTV_AT_TP
+# define TLS_TPADJ(pd) ((struct pthread *)((char *) (pd) + TLS_PRE_TCB_SIZE))
+#endif
+
+/* Cache handling for not-yet free stacks.  */
+
+/* Maximum size in kB of cache.  */
+static size_t stack_cache_maxsize = 40 * 1024 * 1024; /* 40MiBi by default.  */
+static size_t stack_cache_actsize;
+
+/* Mutex protecting this variable.  */
+static lll_lock_t stack_cache_lock = LLL_LOCK_INITIALIZER;
+
+/* List of queued stack frames.  */
+static LIST_HEAD (stack_cache);
+
+/* List of the stacks in use.  */
+static LIST_HEAD (stack_used);
+
+/* List of the threads with user provided stacks in use.  No need to
+   initialize this, since it's done in __pthread_initialize_minimal.  */
+list_t __stack_user __attribute__ ((nocommon));
+hidden_data_def (__stack_user)
+
+#if COLORING_INCREMENT != 0
+/* Number of threads created.  */
+static unsigned int nptl_ncreated;
+#endif
+
+
+/* Check whether the stack is still used or not.  */
+#define FREE_P(descr) ((descr)->tid <= 0)
+
+
+/* We create a double linked list of all cache entries.  Double linked
+   because this allows removing entries from the end.  */
+
+
+/* Get a stack frame from the cache.  We have to match by size since
+   some blocks might be too small or far too large.  */
+static struct pthread *
+get_cached_stack (size_t *sizep, void **memp)
+{
+  size_t size = *sizep;
+  struct pthread *result = NULL;
+  list_t *entry;
+
+  lll_lock (stack_cache_lock);
+
+  /* Search the cache for a matching entry.  We search for the
+     smallest stack which has at least the required size.  Note that
+     in normal situations the size of all allocated stacks is the
+     same.  As the very least there are only a few different sizes.
+     Therefore this loop will exit early most of the time with an
+     exact match.  */
+  list_for_each (entry, &stack_cache)
+    {
+      struct pthread *curr;
+
+      curr = list_entry (entry, struct pthread, list);
+      if (FREE_P (curr) && curr->stackblock_size >= size)
+	{
+	  if (curr->stackblock_size == size)
+	    {
+	      result = curr;
+	      break;
+	    }
+
+	  if (result == NULL
+	      || result->stackblock_size > curr->stackblock_size)
+	    result = curr;
+	}
+    }
+
+  if (__builtin_expect (result == NULL, 0)
+      /* Make sure the size difference is not too excessive.  In that
+	 case we do not use the block.  */
+      || __builtin_expect (result->stackblock_size > 4 * size, 0))
+    {
+      /* Release the lock.  */
+      lll_unlock (stack_cache_lock);
+
+      return NULL;
+    }
+
+  /* Dequeue the entry.  */
+  list_del (&result->list);
+
+  /* And add to the list of stacks in use.  */
+  list_add (&result->list, &stack_used);
+
+  /* And decrease the cache size.  */
+  stack_cache_actsize -= result->stackblock_size;
+
+  /* Release the lock early.  */
+  lll_unlock (stack_cache_lock);
+
+  /* Report size and location of the stack to the caller.  */
+  *sizep = result->stackblock_size;
+  *memp = result->stackblock;
+
+  /* Cancellation handling is back to the default.  */
+  result->cancelhandling = 0;
+  result->cleanup = NULL;
+
+  /* No pending event.  */
+  result->nextevent = NULL;
+
+  /* Clear the DTV.  */
+  dtv_t *dtv = GET_DTV (TLS_TPADJ (result));
+  memset (dtv, '\0', (dtv[-1].counter + 1) * sizeof (dtv_t));
+
+  /* Re-initialize the TLS.  */
+  _dl_allocate_tls_init (TLS_TPADJ (result));
+
+  return result;
+}
+
+
+/* Add a stack frame which is not used anymore to the stack.  Must be
+   called with the cache lock held.  */
+static inline void
+__attribute ((always_inline))
+queue_stack (struct pthread *stack)
+{
+  /* We unconditionally add the stack to the list.  The memory may
+     still be in use but it will not be reused until the kernel marks
+     the stack as not used anymore.  */
+  list_add (&stack->list, &stack_cache);
+
+  stack_cache_actsize += stack->stackblock_size;
+  if (__builtin_expect (stack_cache_actsize > stack_cache_maxsize, 0))
+    {
+      /* We reduce the size of the cache.  Remove the last entries
+	 until the size is below the limit.  */
+      list_t *entry;
+      list_t *prev;
+
+      /* Search from the end of the list.  */
+      list_for_each_prev_safe (entry, prev, &stack_cache)
+	{
+	  struct pthread *curr;
+
+	  curr = list_entry (entry, struct pthread, list);
+	  if (FREE_P (curr))
+	    {
+	      /* Unlink the block.  */
+	      list_del (entry);
+
+	      /* Account for the freed memory.  */
+	      stack_cache_actsize -= curr->stackblock_size;
+
+	      /* Free the memory associated with the ELF TLS.  */
+	      _dl_deallocate_tls (TLS_TPADJ (curr), false);
+
+	      /* Remove this block.  This should never fail.  If it
+		 does something is really wrong.  */
+	      if (munmap (curr->stackblock, curr->stackblock_size) != 0)
+		abort ();
+
+	      /* Maybe we have freed enough.  */
+	      if (stack_cache_actsize <= stack_cache_maxsize)
+		break;
+	    }
+	}
+    }
+}
+
+
+static int
+internal_function
+change_stack_perm (struct pthread *pd
+#ifdef NEED_SEPARATE_REGISTER_STACK
+		   , size_t pagemask
+#endif
+		   )
+{
+#ifdef NEED_SEPARATE_REGISTER_STACK
+  void *stack = (pd->stackblock
+		 + (((((pd->stackblock_size - pd->guardsize) / 2)
+		      & pagemask) + pd->guardsize) & pagemask));
+  size_t len = pd->stackblock + pd->stackblock_size - stack;
+#else
+  void *stack = pd->stackblock + pd->guardsize;
+  size_t len = pd->stackblock_size - pd->guardsize;
+#endif
+  if (mprotect (stack, len, PROT_READ | PROT_WRITE | PROT_EXEC) != 0)
+    return errno;
+
+  return 0;
+}
+
+
+static int
+allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
+		ALLOCATE_STACK_PARMS)
+{
+  struct pthread *pd;
+  size_t size;
+  size_t pagesize_m1 = __getpagesize () - 1;
+  void *stacktop;
+
+  assert (attr != NULL);
+  assert (powerof2 (pagesize_m1 + 1));
+  assert (TCB_ALIGNMENT >= STACK_ALIGN);
+
+  /* Get the stack size from the attribute if it is set.  Otherwise we
+     use the default we determined at start time.  */
+  size = attr->stacksize ?: __default_stacksize;
+
+  /* Get memory for the stack.  */
+  if (__builtin_expect (attr->flags & ATTR_FLAG_STACKADDR, 0))
+    {
+      uintptr_t adj;
+
+      /* If the user also specified the size of the stack make sure it
+	 is large enough.  */
+      if (attr->stacksize != 0
+	  && attr->stacksize < (__static_tls_size + MINIMAL_REST_STACK))
+	return EINVAL;
+
+      /* Adjust stack size for alignment of the TLS block.  */
+#if TLS_TCB_AT_TP
+      adj = ((uintptr_t) attr->stackaddr - TLS_TCB_SIZE)
+	    & __static_tls_align_m1;
+      assert (size > adj + TLS_TCB_SIZE);
+#elif TLS_DTV_AT_TP
+      adj = ((uintptr_t) attr->stackaddr - __static_tls_size)
+	    & __static_tls_align_m1;
+      assert (size > adj);
+#endif
+
+      /* The user provided some memory.  Let's hope it matches the
+	 size...  We do not allocate guard pages if the user provided
+	 the stack.  It is the user's responsibility to do this if it
+	 is wanted.  */
+#if TLS_TCB_AT_TP
+      pd = (struct pthread *) ((uintptr_t) attr->stackaddr
+			       - TLS_TCB_SIZE - adj);
+#elif TLS_DTV_AT_TP
+      pd = (struct pthread *) (((uintptr_t) attr->stackaddr
+			        - __static_tls_size - adj)
+			       - TLS_PRE_TCB_SIZE);
+#endif
+
+      /* The user provided stack memory needs to be cleared.  */
+      memset (pd, '\0', sizeof (struct pthread));
+
+      /* The first TSD block is included in the TCB.  */
+      pd->specific[0] = pd->specific_1stblock;
+
+      /* Remember the stack-related values.  */
+      pd->stackblock = (char *) attr->stackaddr - size;
+      pd->stackblock_size = size;
+
+      /* This is a user-provided stack.  It will not be queued in the
+	 stack cache nor will the memory (except the TLS memory) be freed.  */
+      pd->user_stack = true;
+
+      /* This is at least the second thread.  */
+      pd->header.multiple_threads = 1;
+#ifndef TLS_MULTIPLE_THREADS_IN_TCB
+      __pthread_multiple_threads = *__libc_multiple_threads_ptr = 1;
+#endif
+
+#ifdef NEED_DL_SYSINFO
+      /* Copy the sysinfo value from the parent.  */
+      THREAD_SYSINFO(pd) = THREAD_SELF_SYSINFO;
+#endif
+
+      /* The process ID is also the same as that of the caller.  */
+      pd->pid = THREAD_GETMEM (THREAD_SELF, pid);
+
+      /* Allocate the DTV for this thread.  */
+      if (_dl_allocate_tls (TLS_TPADJ (pd)) == NULL)
+	{
+	  /* Something went wrong.  */
+	  assert (errno == ENOMEM);
+	  return EAGAIN;
+	}
+
+
+      /* Prepare to modify global data.  */
+      lll_lock (stack_cache_lock);
+
+      /* And add to the list of stacks in use.  */
+      list_add (&pd->list, &__stack_user);
+
+      lll_unlock (stack_cache_lock);
+    }
+  else
+    {
+      /* Allocate some anonymous memory.  If possible use the cache.  */
+      size_t guardsize;
+      size_t reqsize;
+      void *mem;
+      const int prot = (PROT_READ | PROT_WRITE
+			| ((GL(dl_stack_flags) & PF_X) ? PROT_EXEC : 0));
+
+#if COLORING_INCREMENT != 0
+      /* Add one more page for stack coloring.  Don't do it for stacks
+	 with 16 times pagesize or larger.  This might just cause
+	 unnecessary misalignment.  */
+      if (size <= 16 * pagesize_m1)
+	size += pagesize_m1 + 1;
+#endif
+
+      /* Adjust the stack size for alignment.  */
+      size &= ~__static_tls_align_m1;
+      assert (size != 0);
+
+      /* Make sure the size of the stack is enough for the guard and
+	 eventually the thread descriptor.  */
+      guardsize = (attr->guardsize + pagesize_m1) & ~pagesize_m1;
+      if (__builtin_expect (size < (guardsize + __static_tls_size
+				    + MINIMAL_REST_STACK + pagesize_m1 + 1),
+			    0))
+	/* The stack is too small (or the guard too large).  */
+	return EINVAL;
+
+      /* Try to get a stack from the cache.  */
+      reqsize = size;
+      pd = get_cached_stack (&size, &mem);
+      if (pd == NULL)
+	{
+	  /* To avoid aliasing effects on a larger scale than pages we
+	     adjust the allocated stack size if necessary.  This way
+	     allocations directly following each other will not have
+	     aliasing problems.  */
+#if MULTI_PAGE_ALIASING != 0
+	  if ((size % MULTI_PAGE_ALIASING) == 0)
+	    size += pagesize_m1 + 1;
+#endif
+
+	  mem = mmap (NULL, size, prot,
+		      MAP_PRIVATE | MAP_ANONYMOUS | ARCH_MAP_FLAGS, -1, 0);
+
+	  if (__builtin_expect (mem == MAP_FAILED, 0))
+	    {
+#ifdef ARCH_RETRY_MMAP
+	      mem = ARCH_RETRY_MMAP (size);
+	      if (__builtin_expect (mem == MAP_FAILED, 0))
+#endif
+		return errno;
+	    }
+
+	  /* SIZE is guaranteed to be greater than zero.
+	     So we can never get a null pointer back from mmap.  */
+	  assert (mem != NULL);
+
+#if COLORING_INCREMENT != 0
+	  /* Atomically increment NCREATED.  */
+	  unsigned int ncreated = atomic_increment_val (&nptl_ncreated);
+
+	  /* We chose the offset for coloring by incrementing it for
+	     every new thread by a fixed amount.  The offset used
+	     module the page size.  Even if coloring would be better
+	     relative to higher alignment values it makes no sense to
+	     do it since the mmap() interface does not allow us to
+	     specify any alignment for the returned memory block.  */
+	  size_t coloring = (ncreated * COLORING_INCREMENT) & pagesize_m1;
+
+	  /* Make sure the coloring offsets does not disturb the alignment
+	     of the TCB and static TLS block.  */
+	  if (__builtin_expect ((coloring & __static_tls_align_m1) != 0, 0))
+	    coloring = (((coloring + __static_tls_align_m1)
+			 & ~(__static_tls_align_m1))
+			& ~pagesize_m1);
+#else
+	  /* Unless specified we do not make any adjustments.  */
+# define coloring 0
+#endif
+
+	  /* Place the thread descriptor at the end of the stack.  */
+#if TLS_TCB_AT_TP
+	  pd = (struct pthread *) ((char *) mem + size - coloring) - 1;
+#elif TLS_DTV_AT_TP
+	  pd = (struct pthread *) ((((uintptr_t) mem + size - coloring
+				    - __static_tls_size)
+				    & ~__static_tls_align_m1)
+				   - TLS_PRE_TCB_SIZE);
+#endif
+
+	  /* Remember the stack-related values.  */
+	  pd->stackblock = mem;
+	  pd->stackblock_size = size;
+
+	  /* We allocated the first block thread-specific data array.
+	     This address will not change for the lifetime of this
+	     descriptor.  */
+	  pd->specific[0] = pd->specific_1stblock;
+
+	  /* This is at least the second thread.  */
+	  pd->header.multiple_threads = 1;
+#ifndef TLS_MULTIPLE_THREADS_IN_TCB
+	  __pthread_multiple_threads = *__libc_multiple_threads_ptr = 1;
+#endif
+
+#ifdef NEED_DL_SYSINFO
+	  /* Copy the sysinfo value from the parent.  */
+	  THREAD_SYSINFO(pd) = THREAD_SELF_SYSINFO;
+#endif
+
+	  /* The process ID is also the same as that of the caller.  */
+	  pd->pid = THREAD_GETMEM (THREAD_SELF, pid);
+
+	  /* Allocate the DTV for this thread.  */
+	  if (_dl_allocate_tls (TLS_TPADJ (pd)) == NULL)
+	    {
+	      /* Something went wrong.  */
+	      assert (errno == ENOMEM);
+
+	      /* Free the stack memory we just allocated.  */
+	      (void) munmap (mem, size);
+
+	      return EAGAIN;
+	    }
+
+
+	  /* Prepare to modify global data.  */
+	  lll_lock (stack_cache_lock);
+
+	  /* And add to the list of stacks in use.  */
+	  list_add (&pd->list, &stack_used);
+
+	  lll_unlock (stack_cache_lock);
+
+
+	  /* There might have been a race.  Another thread might have
+	     caused the stacks to get exec permission while this new
+	     stack was prepared.  Detect if this was possible and
+	     change the permission if necessary.  */
+	  if (__builtin_expect ((GL(dl_stack_flags) & PF_X) != 0
+				&& (prot & PROT_EXEC) == 0, 0))
+	    {
+	      int err = change_stack_perm (pd
+#ifdef NEED_SEPARATE_REGISTER_STACK
+					   , ~pagesize_m1
+#endif
+					   );
+	      if (err != 0)
+		{
+		  /* Free the stack memory we just allocated.  */
+		  (void) munmap (mem, size);
+
+		  return err;
+		}
+	    }
+
+
+	  /* Note that all of the stack and the thread descriptor is
+	     zeroed.  This means we do not have to initialize fields
+	     with initial value zero.  This is specifically true for
+	     the 'tid' field which is always set back to zero once the
+	     stack is not used anymore and for the 'guardsize' field
+	     which will be read next.  */
+	}
+
+      /* Create or resize the guard area if necessary.  */
+      if (__builtin_expect (guardsize > pd->guardsize, 0))
+	{
+#ifdef NEED_SEPARATE_REGISTER_STACK
+	  char *guard = mem + (((size - guardsize) / 2) & ~pagesize_m1);
+#else
+	  char *guard = mem;
+#endif
+	  if (mprotect (guard, guardsize, PROT_NONE) != 0)
+	    {
+	      int err;
+	    mprot_error:
+	      err = errno;
+
+	      lll_lock (stack_cache_lock);
+
+	      /* Remove the thread from the list.  */
+	      list_del (&pd->list);
+
+	      lll_unlock (stack_cache_lock);
+
+	      /* Get rid of the TLS block we allocated.  */
+	      _dl_deallocate_tls (TLS_TPADJ (pd), false);
+
+	      /* Free the stack memory regardless of whether the size
+		 of the cache is over the limit or not.  If this piece
+		 of memory caused problems we better do not use it
+		 anymore.  Uh, and we ignore possible errors.  There
+		 is nothing we could do.  */
+	      (void) munmap (mem, size);
+
+	      return err;
+	    }
+
+	  pd->guardsize = guardsize;
+	}
+      else if (__builtin_expect (pd->guardsize - guardsize > size - reqsize,
+				 0))
+	{
+	  /* The old guard area is too large.  */
+
+#ifdef NEED_SEPARATE_REGISTER_STACK
+	  char *guard = mem + (((size - guardsize) / 2) & ~pagesize_m1);
+	  char *oldguard = mem + (((size - pd->guardsize) / 2) & ~pagesize_m1);
+
+	  if (oldguard < guard
+	      && mprotect (oldguard, guard - oldguard, prot) != 0)
+	    goto mprot_error;
+
+	  if (mprotect (guard + guardsize,
+			oldguard + pd->guardsize - guard - guardsize,
+			prot) != 0)
+	    goto mprot_error;
+#else
+	  if (mprotect ((char *) mem + guardsize, pd->guardsize - guardsize,
+			prot) != 0)
+	    goto mprot_error;
+#endif
+
+	  pd->guardsize = guardsize;
+	}
+      /* The pthread_getattr_np() calls need to get passed the size
+	 requested in the attribute, regardless of how large the
+	 actually used guardsize is.  */
+      pd->reported_guardsize = guardsize;
+    }
+
+  /* Initialize the lock.  We have to do this unconditionally since the
+     stillborn thread could be canceled while the lock is taken.  */
+  pd->lock = LLL_LOCK_INITIALIZER;
+
+  /* We place the thread descriptor at the end of the stack.  */
+  *pdp = pd;
+
+#if TLS_TCB_AT_TP
+  /* The stack begins before the TCB and the static TLS block.  */
+  stacktop = ((char *) (pd + 1) - __static_tls_size);
+#elif TLS_DTV_AT_TP
+  stacktop = (char *) (pd - 1);
+#endif
+
+#ifdef NEED_SEPARATE_REGISTER_STACK
+  *stack = pd->stackblock;
+  *stacksize = stacktop - *stack;
+#else
+  *stack = stacktop;
+#endif
+
+  return 0;
+}
+
+
+void
+internal_function
+__deallocate_stack (struct pthread *pd)
+{
+  lll_lock (stack_cache_lock);
+
+  /* Remove the thread from the list of threads with user defined
+     stacks.  */
+  list_del (&pd->list);
+
+  /* Not much to do.  Just free the mmap()ed memory.  Note that we do
+     not reset the 'used' flag in the 'tid' field.  This is done by
+     the kernel.  If no thread has been created yet this field is
+     still zero.  */
+  if (__builtin_expect (! pd->user_stack, 1))
+    (void) queue_stack (pd);
+  else
+    /* Free the memory associated with the ELF TLS.  */
+    _dl_deallocate_tls (TLS_TPADJ (pd), false);
+
+  lll_unlock (stack_cache_lock);
+}
+
+
+int
+internal_function
+__make_stacks_executable (void **stack_endp)
+{
+  /* First the main thread's stack.  */
+  int err = _dl_make_stack_executable (stack_endp);
+  if (err != 0)
+    return err;
+
+#ifdef NEED_SEPARATE_REGISTER_STACK
+  const size_t pagemask = ~(__getpagesize () - 1);
+#endif
+
+  lll_lock (stack_cache_lock);
+
+  list_t *runp;
+  list_for_each (runp, &stack_used)
+    {
+      err = change_stack_perm (list_entry (runp, struct pthread, list)
+#ifdef NEED_SEPARATE_REGISTER_STACK
+			       , pagemask
+#endif
+			       );
+      if (err != 0)
+	break;
+    }
+
+  /* Also change the permission for the currently unused stacks.  This
+     might be wasted time but better spend it here than adding a check
+     in the fast path.  */
+  if (err == 0)
+    list_for_each (runp, &stack_cache)
+      {
+	err = change_stack_perm (list_entry (runp, struct pthread, list)
+#ifdef NEED_SEPARATE_REGISTER_STACK
+				 , pagemask
+#endif
+				 );
+	if (err != 0)
+	  break;
+      }
+
+  lll_unlock (stack_cache_lock);
+
+  return err;
+}
+
+
+/* In case of a fork() call the memory allocation in the child will be
+   the same but only one thread is running.  All stacks except that of
+   the one running thread are not used anymore.  We have to recycle
+   them.  */
+void
+__reclaim_stacks (void)
+{
+  struct pthread *self = (struct pthread *) THREAD_SELF;
+
+  /* No locking necessary.  The caller is the only stack in use.  */
+
+  /* Mark all stacks except the still running one as free.  */
+  list_t *runp;
+  list_for_each (runp, &stack_used)
+    {
+      struct pthread *curp;
+
+      curp = list_entry (runp, struct pthread, list);
+      if (curp != self)
+	{
+	  /* This marks the stack as free.  */
+	  curp->tid = 0;
+
+	  /* The PID field must be initialized for the new process.  */
+	  curp->pid = self->pid;
+
+	  /* Account for the size of the stack.  */
+	  stack_cache_actsize += curp->stackblock_size;
+	}
+    }
+
+  /* Add the stack of all running threads to the cache.  */
+  list_splice (&stack_used, &stack_cache);
+
+  /* Remove the entry for the current thread to from the cache list
+     and add it to the list of running threads.  Which of the two
+     lists is decided by the user_stack flag.  */
+  list_del (&self->list);
+
+  /* Re-initialize the lists for all the threads.  */
+  INIT_LIST_HEAD (&stack_used);
+  INIT_LIST_HEAD (&__stack_user);
+
+  if (__builtin_expect (THREAD_GETMEM (self, user_stack), 0))
+    list_add (&self->list, &__stack_user);
+  else
+    list_add (&self->list, &stack_used);
+
+  /* There is one thread running.  */
+  __nptl_nthreads = 1;
+
+  /* Initialize the lock.  */
+  stack_cache_lock = LLL_LOCK_INITIALIZER;
+}
+
+
+#if HP_TIMING_AVAIL
+# undef __find_thread_by_id
+/* Find a thread given the thread ID.  */
+attribute_hidden
+struct pthread *
+__find_thread_by_id (pid_t tid)
+{
+  struct pthread *result = NULL;
+
+  lll_lock (stack_cache_lock);
+
+  /* Iterate over the list with system-allocated threads first.  */
+  list_t *runp;
+  list_for_each (runp, &stack_used)
+    {
+      struct pthread *curp;
+
+      curp = list_entry (runp, struct pthread, list);
+
+      if (curp->tid == tid)
+	{
+	  result = curp;
+	  goto out;
+	}
+    }
+
+  /* Now the list with threads using user-allocated stacks.  */
+  list_for_each (runp, &__stack_user)
+    {
+      struct pthread *curp;
+
+      curp = list_entry (runp, struct pthread, list);
+
+      if (curp->tid == tid)
+	{
+	  result = curp;
+	  goto out;
+	}
+    }
+
+ out:
+  lll_unlock (stack_cache_lock);
+
+  return result;
+}
+#endif
+
+int
+attribute_hidden
+__nptl_setxid (struct xid_command *cmdp)
+{
+  int result;
+  lll_lock (stack_cache_lock);
+
+  __xidcmd = cmdp;
+  cmdp->cntr = 0;
+
+  INTERNAL_SYSCALL_DECL (err);
+
+  struct pthread *self = THREAD_SELF;
+
+  /* Iterate over the list with system-allocated threads first.  */
+  list_t *runp;
+  list_for_each (runp, &stack_used)
+    {
+      struct pthread *t = list_entry (runp, struct pthread, list);
+      if (t != self)
+	{
+	  int val;
+#if __ASSUME_TGKILL
+	  val = INTERNAL_SYSCALL (tgkill, err, 3,
+				  THREAD_GETMEM (THREAD_SELF, pid),
+				  t->tid, SIGSETXID);
+#else
+# ifdef __NR_tgkill
+	  val = INTERNAL_SYSCALL (tgkill, err, 3,
+				  THREAD_GETMEM (THREAD_SELF, pid),
+				  t->tid, SIGSETXID);
+	  if (INTERNAL_SYSCALL_ERROR_P (val, err)
+	      && INTERNAL_SYSCALL_ERRNO (val, err) == ENOSYS)
+# endif
+	    val = INTERNAL_SYSCALL (tkill, err, 2, t->tid, SIGSETXID);
+#endif
+
+	  if (!INTERNAL_SYSCALL_ERROR_P (val, err))
+	    atomic_increment (&cmdp->cntr);
+	}
+    }
+
+  /* Now the list with threads using user-allocated stacks.  */
+  list_for_each (runp, &__stack_user)
+    {
+      struct pthread *t = list_entry (runp, struct pthread, list);
+      if (t != self)
+	{
+	  int val;
+#if __ASSUME_TGKILL
+	  val = INTERNAL_SYSCALL (tgkill, err, 3,
+				  THREAD_GETMEM (THREAD_SELF, pid),
+				  t->tid, SIGSETXID);
+#else
+# ifdef __NR_tgkill
+	  val = INTERNAL_SYSCALL (tgkill, err, 3,
+				  THREAD_GETMEM (THREAD_SELF, pid),
+				  t->tid, SIGSETXID);
+	  if (INTERNAL_SYSCALL_ERROR_P (val, err)
+	      && INTERNAL_SYSCALL_ERRNO (val, err) == ENOSYS)
+# endif
+	    val = INTERNAL_SYSCALL (tkill, err, 2, t->tid, SIGSETXID);
+#endif
+
+	  if (!INTERNAL_SYSCALL_ERROR_P (val, err))
+	    atomic_increment (&cmdp->cntr);
+	}
+    }
+
+  int cur = cmdp->cntr;
+  while (cur != 0)
+    {
+      lll_futex_wait (&cmdp->cntr, cur);
+      cur = cmdp->cntr;
+    }
+
+  /* This must be last, otherwise the current thread might not have
+     permissions to send SIGSETXID syscall to the other threads.  */
+  result = INTERNAL_SYSCALL_NCS (cmdp->syscall_no, err, 3,
+				 cmdp->id[0], cmdp->id[1], cmdp->id[2]);
+  if (INTERNAL_SYSCALL_ERROR_P (result, err))
+    {
+      __set_errno (INTERNAL_SYSCALL_ERRNO (result, err));
+      result = -1;
+    }
+
+  lll_unlock (stack_cache_lock);
+  return result;
+}
+
+static inline void __attribute__((always_inline))
+init_one_static_tls (struct pthread *curp, struct link_map *map)
+{
+  dtv_t *dtv = GET_DTV (TLS_TPADJ (curp));
+# if TLS_TCB_AT_TP
+  void *dest = (char *) curp - map->l_tls_offset;
+# elif TLS_DTV_AT_TP
+  void *dest = (char *) curp + map->l_tls_offset + TLS_PRE_TCB_SIZE;
+# else
+#  error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
+# endif
+
+  /* Fill in the DTV slot so that a later LD/GD access will find it.  */
+  dtv[map->l_tls_modid].pointer.val = dest;
+  dtv[map->l_tls_modid].pointer.is_static = true;
+
+  /* Initialize the memory.  */
+  memset (__mempcpy (dest, map->l_tls_initimage, map->l_tls_initimage_size),
+	  '\0', map->l_tls_blocksize - map->l_tls_initimage_size);
+}
+
+void
+attribute_hidden
+__pthread_init_static_tls (struct link_map *map)
+{
+  lll_lock (stack_cache_lock);
+
+  /* Iterate over the list with system-allocated threads first.  */
+  list_t *runp;
+  list_for_each (runp, &stack_used)
+    init_one_static_tls (list_entry (runp, struct pthread, list), map);
+
+  /* Now the list with threads using user-allocated stacks.  */
+  list_for_each (runp, &__stack_user)
+    init_one_static_tls (list_entry (runp, struct pthread, list), map);
+
+  lll_unlock (stack_cache_lock);
+}
Index: trunk/src/libctests/glibc/nptl/pthread_attr_getstack.c
===================================================================
--- trunk/src/libctests/glibc/nptl/pthread_attr_getstack.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/pthread_attr_getstack.c	(revision 2036)
@@ -0,0 +1,41 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <assert.h>
+#include "pthreadP.h"
+
+
+int
+__pthread_attr_getstack (attr, stackaddr, stacksize)
+     const pthread_attr_t *attr;
+     void **stackaddr;
+     size_t *stacksize;
+{
+  struct pthread_attr *iattr;
+
+  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+  iattr = (struct pthread_attr *) attr;
+
+  /* Store the result.  */
+  *stackaddr = (char *) iattr->stackaddr - iattr->stacksize;
+  *stacksize = iattr->stacksize;
+
+  return 0;
+}
+strong_alias (__pthread_attr_getstack, pthread_attr_getstack)
Index: trunk/src/libctests/glibc/nptl/pthread_attr_getstackaddr.c
===================================================================
--- trunk/src/libctests/glibc/nptl/pthread_attr_getstackaddr.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/pthread_attr_getstackaddr.c	(revision 2036)
@@ -0,0 +1,45 @@
+/* Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <assert.h>
+#include <errno.h>
+#include "pthreadP.h"
+
+
+int
+__pthread_attr_getstackaddr (attr, stackaddr)
+     const pthread_attr_t *attr;
+     void **stackaddr;
+{
+  struct pthread_attr *iattr;
+
+  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+  iattr = (struct pthread_attr *) attr;
+
+  /* Some code assumes this function to work even if no stack address
+     has been set.  Let them figure it out for themselves what the
+     value means.  Simply store the result.  */
+  *stackaddr = iattr->stackaddr;
+
+  return 0;
+}
+strong_alias (__pthread_attr_getstackaddr, pthread_attr_getstackaddr)
+
+link_warning (pthread_attr_getstackaddr,
+              "the use of `pthread_attr_getstackaddr' is deprecated, use `pthread_attr_getstack'")
Index: trunk/src/libctests/glibc/nptl/pthread_attr_getstacksize.c
===================================================================
--- trunk/src/libctests/glibc/nptl/pthread_attr_getstacksize.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/pthread_attr_getstacksize.c	(revision 2036)
@@ -0,0 +1,40 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <assert.h>
+#include "pthreadP.h"
+
+
+int
+__pthread_attr_getstacksize (attr, stacksize)
+     const pthread_attr_t *attr;
+     size_t *stacksize;
+{
+  struct pthread_attr *iattr;
+
+  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+  iattr = (struct pthread_attr *) attr;
+
+  /* If the user has not set a stack size we return what the system
+     will use as the default.  */
+  *stacksize = iattr->stacksize ?: __default_stacksize;
+
+  return 0;
+}
+strong_alias (__pthread_attr_getstacksize, pthread_attr_getstacksize)
Index: trunk/src/libctests/glibc/nptl/pthread_attr_setstack.c
===================================================================
--- trunk/src/libctests/glibc/nptl/pthread_attr_setstack.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/pthread_attr_setstack.c	(revision 2036)
@@ -0,0 +1,89 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include "pthreadP.h"
+
+
+int
+__pthread_attr_setstack (attr, stackaddr, stacksize)
+     pthread_attr_t *attr;
+     void *stackaddr;
+     size_t stacksize;
+{
+  struct pthread_attr *iattr;
+
+  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+  iattr = (struct pthread_attr *) attr;
+
+  /* Catch invalid sizes.  */
+  if (stacksize < PTHREAD_STACK_MIN)
+    return EINVAL;
+
+#ifdef EXTRA_PARAM_CHECKS
+  EXTRA_PARAM_CHECKS;
+#endif
+
+  iattr->stacksize = stacksize;
+  iattr->stackaddr = (char *) stackaddr + stacksize;
+  iattr->flags |= ATTR_FLAG_STACKADDR;
+
+  return 0;
+}
+
+#if PTHREAD_STACK_MIN == 16384
+strong_alias (__pthread_attr_setstack, pthread_attr_setstack)
+#else
+# include <shlib-compat.h>
+versioned_symbol (libpthread, __pthread_attr_setstack, pthread_attr_setstack,
+		  GLIBC_2_3_3);
+
+# if SHLIB_COMPAT(libpthread, GLIBC_2_2, GLIBC_2_3_3)
+
+int
+__old_pthread_attr_setstack (pthread_attr_t *attr, void *stackaddr,
+			     size_t stacksize)
+{
+  struct pthread_attr *iattr;
+
+  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+  iattr = (struct pthread_attr *) attr;
+
+  /* Catch invalid sizes.  */
+  if (stacksize < 16384)
+    return EINVAL;
+
+# ifdef EXTRA_PARAM_CHECKS
+  EXTRA_PARAM_CHECKS;
+# endif
+
+  iattr->stacksize = stacksize;
+  iattr->stackaddr = (char *) stackaddr + stacksize;
+  iattr->flags |= ATTR_FLAG_STACKADDR;
+
+  return 0;
+}
+
+compat_symbol (libpthread, __old_pthread_attr_setstack, pthread_attr_setstack,
+	       GLIBC_2_2);
+# endif
+
+#endif
Index: trunk/src/libctests/glibc/nptl/pthread_attr_setstackaddr.c
===================================================================
--- trunk/src/libctests/glibc/nptl/pthread_attr_setstackaddr.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/pthread_attr_setstackaddr.c	(revision 2036)
@@ -0,0 +1,47 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <assert.h>
+#include <errno.h>
+#include "pthreadP.h"
+
+
+int
+__pthread_attr_setstackaddr (attr, stackaddr)
+     pthread_attr_t *attr;
+     void *stackaddr;
+{
+  struct pthread_attr *iattr;
+
+#ifdef EXTRA_PARAM_CHECKS
+  EXTRA_PARAM_CHECKS;
+#endif
+
+  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+  iattr = (struct pthread_attr *) attr;
+
+  iattr->stackaddr = stackaddr;
+  iattr->flags |= ATTR_FLAG_STACKADDR;
+
+  return 0;
+}
+strong_alias (__pthread_attr_setstackaddr, pthread_attr_setstackaddr)
+
+link_warning (pthread_attr_setstackaddr,
+              "the use of `pthread_attr_setstackaddr' is deprecated, use `pthread_attr_setstack'")
Index: trunk/src/libctests/glibc/nptl/pthread_attr_setstacksize.c
===================================================================
--- trunk/src/libctests/glibc/nptl/pthread_attr_setstacksize.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/pthread_attr_setstacksize.c	(revision 2036)
@@ -0,0 +1,75 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include "pthreadP.h"
+
+
+int
+__pthread_attr_setstacksize (attr, stacksize)
+     pthread_attr_t *attr;
+     size_t stacksize;
+{
+  struct pthread_attr *iattr;
+
+  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+  iattr = (struct pthread_attr *) attr;
+
+  /* Catch invalid sizes.  */
+  if (stacksize < PTHREAD_STACK_MIN)
+    return EINVAL;
+
+  iattr->stacksize = stacksize;
+
+  return 0;
+}
+
+#if PTHREAD_STACK_MIN == 16384
+strong_alias (__pthread_attr_setstacksize, pthread_attr_setstacksize)
+#else
+# include <shlib-compat.h>
+versioned_symbol (libpthread, __pthread_attr_setstacksize,
+		  pthread_attr_setstacksize, GLIBC_2_3_3);
+
+# if SHLIB_COMPAT(libpthread, GLIBC_2_1, GLIBC_2_3_3)
+
+int
+__old_pthread_attr_setstacksize (pthread_attr_t *attr, size_t stacksize)
+{
+  struct pthread_attr *iattr;
+
+  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+  iattr = (struct pthread_attr *) attr;
+
+  /* Catch invalid sizes.  */
+  if (stacksize < 16384)
+    return EINVAL;
+
+  iattr->stacksize = stacksize;
+
+  return 0;
+}
+
+compat_symbol (libpthread, __old_pthread_attr_setstacksize,
+	       pthread_attr_setstacksize, GLIBC_2_1);
+# endif
+
+#endif
Index: trunk/src/libctests/glibc/nptl/pthread_testcancel.c
===================================================================
--- trunk/src/libctests/glibc/nptl/pthread_testcancel.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/pthread_testcancel.c	(revision 2036)
@@ -0,0 +1,28 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdlib.h>
+#include "pthreadP.h"
+
+
+void
+pthread_testcancel (void)
+{
+  CANCELLATION_P (THREAD_SELF);
+}
Index: trunk/src/libctests/glibc/nptl/sysdeps/pthread/Makefile
===================================================================
--- trunk/src/libctests/glibc/nptl/sysdeps/pthread/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/sysdeps/pthread/Makefile	(revision 2036)
@@ -0,0 +1,52 @@
+# Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+# Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+ifeq ($(subdir),csu)
+CFLAGS-libc-start.c += -I../nptl
+routines += unwind-resume
+shared-only-routines += unwind-resume
+CFLAGS-unwind-resume.c += -fexceptions -fasynchronous-unwind-tables
+endif
+
+ifeq ($(subdir),nptl)
+libpthread-sysdep_routines += errno-loc
+endif
+
+ifeq ($(subdir),rt)
+librt-sysdep_routines += timer_routines librt-cancellation rt-unwind-resume
+librt-shared-only-routines += rt-unwind-resume
+CPPFLAGS-timer_routines.c = -I../nptl
+CFLAGS-librt-cancellation.c += -fexceptions -fasynchronous-unwind-tables
+CFLAGS-rt-unwind-resume.c += -fexceptions -fasynchronous-unwind-tables
+
+ifeq (yes,$(build-shared))
+$(objpfx)tst-timer: $(objpfx)librt.so $(shared-thread-library)
+else
+$(objpfx)tst-timer: $(objpfx)librt.a $(static-thread-library)
+endif
+
+ifeq ($(have-forced-unwind),yes)
+tests += tst-mqueue8x
+CFLAGS-tst-mqueue8x.c += -fexceptions
+endif
+endif
+
+ifeq ($(subdir),posix)
+CFLAGS-confstr.c += -DLIBPTHREAD_VERSION='"NPTL $(version)"'
+endif
Index: trunk/src/libctests/glibc/nptl/sysdeps/pthread/tst-mqueue8x.c
===================================================================
--- trunk/src/libctests/glibc/nptl/sysdeps/pthread/tst-mqueue8x.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/sysdeps/pthread/tst-mqueue8x.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include <rt/tst-mqueue8.c>
Index: trunk/src/libctests/glibc/nptl/sysdeps/pthread/tst-timer.c
===================================================================
--- trunk/src/libctests/glibc/nptl/sysdeps/pthread/tst-timer.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/sysdeps/pthread/tst-timer.c	(revision 2036)
@@ -0,0 +1,159 @@
+/* Tests for POSIX timer implementation.
+   Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Kaz Kylheku <kaz@ashi.footprints.net>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <time.h>
+#include <unistd.h>
+
+
+static void
+notify_func1 (union sigval sigval)
+{
+  puts ("notify_func1");
+}
+
+
+static void
+notify_func2 (union sigval sigval)
+{
+  puts ("notify_func2");
+}
+
+
+static void
+signal_func (int sig)
+{
+  static const char text[] = "signal_func\n";
+  signal (sig, signal_func);
+  write (STDOUT_FILENO, text, sizeof text - 1);
+}
+
+static void
+intr_sleep (int sec)
+{
+  struct timespec ts;
+
+  ts.tv_sec = sec;
+  ts.tv_nsec = 0;
+
+  while (nanosleep (&ts, &ts) == -1 && errno == EINTR)
+    ;
+}
+
+#define ZSIGALRM 14
+
+
+int
+main (void)
+{
+  struct timespec ts;
+  timer_t timer_sig, timer_thr1, timer_thr2;
+  int retval;
+  struct sigevent sigev1 =
+  {
+    .sigev_notify = SIGEV_SIGNAL,
+    .sigev_signo = ZSIGALRM
+  };
+  struct sigevent sigev2;
+  struct itimerspec itimer1 = { { 0, 200000000 }, { 0, 200000000 } };
+  struct itimerspec itimer2 = { { 0, 100000000 }, { 0, 500000000 } };
+  struct itimerspec itimer3 = { { 0, 150000000 }, { 0, 300000000 } };
+  struct itimerspec old;
+
+  retval = clock_gettime (CLOCK_REALTIME, &ts);
+
+  sigev2.sigev_notify = SIGEV_THREAD;
+  sigev2.sigev_notify_function = notify_func1;
+  sigev2.sigev_notify_attributes = NULL;
+  /* It is unnecessary to do the following but to set a good example
+     we do it anyhow.  */
+  sigev2.sigev_value.sival_ptr = NULL;
+
+  setvbuf (stdout, 0, _IOLBF, 0);
+
+  printf ("clock_gettime returned %d, timespec = { %ld, %ld }\n",
+	  retval, ts.tv_sec, ts.tv_nsec);
+
+  retval = clock_getres (CLOCK_REALTIME, &ts);
+
+  printf ("clock_getres returned %d, timespec = { %ld, %ld }\n",
+	  retval, ts.tv_sec, ts.tv_nsec);
+
+  if (timer_create (CLOCK_REALTIME, &sigev1, &timer_sig) != 0)
+    {
+      printf ("timer_create for timer_sig failed: %m\n");
+      exit (1);
+    }
+  if (timer_create (CLOCK_REALTIME, &sigev2, &timer_thr1) != 0)
+    {
+      printf ("timer_create for timer_thr1 failed: %m\n");
+      exit (1);
+    }
+  sigev2.sigev_notify_function = notify_func2;
+  if (timer_create (CLOCK_REALTIME, &sigev2, &timer_thr2) != 0)
+    {
+      printf ("timer_create for timer_thr2 failed: %m\n");
+      exit (1);
+    }
+
+  if (timer_settime (timer_thr1, 0, &itimer2, &old) != 0)
+    {
+      printf ("timer_settime for timer_thr1 failed: %m\n");
+      exit (1);
+    }
+  if (timer_settime (timer_thr2, 0, &itimer3, &old) != 0)
+    {
+      printf ("timer_settime for timer_thr2 failed: %m\n");
+      exit (1);
+    }
+
+  signal (ZSIGALRM, signal_func);
+
+  if (timer_settime (timer_sig, 0, &itimer1, &old) != 0)
+    {
+      printf ("timer_settime for timer_sig failed: %m\n");
+      exit (1);
+    }
+
+  intr_sleep (3);
+
+  if (timer_delete (timer_sig) != 0)
+    {
+      printf ("timer_delete for timer_sig failed: %m\n");
+      exit (1);
+    }
+  if (timer_delete (timer_thr1) != 0)
+    {
+      printf ("timer_delete for timer_thr1 failed: %m\n");
+      exit (1);
+    }
+
+  intr_sleep (3);
+
+  if (timer_delete (timer_thr2) != 0)
+    {
+      printf ("timer_delete for timer_thr2 failed: %m\n");
+      exit (1);
+    }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/nptl/tst-_res1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-_res1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-_res1.c	(revision 2036)
@@ -0,0 +1,69 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* Test whether _res in glibc 2.1.x and earlier (before __res_state()
+   was introduced) works.  Portable programs should never do the
+   dirty things below.  */
+
+#include <pthread.h>
+#include <resolv.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+void *tf (void *resp)
+{
+  if (resp == &_res || resp == __res_state ())
+    abort ();
+  _res.retry = 24;
+  return NULL;
+}
+
+void do_test (struct __res_state *resp)
+{
+  if (resp != &_res || resp != __res_state ())
+    abort ();
+  if (_res.retry != 12)
+    abort ();
+}
+
+int main (void)
+{
+#undef _res
+  extern struct __res_state _res;
+  pthread_t th;
+
+  _res.retry = 12;
+  if (pthread_create (&th, NULL, tf, &_res) != 0)
+    {
+      puts ("create failed");
+      exit (1);
+    }
+
+  do_test (&_res);
+
+  if (pthread_join (th, NULL) != 0)
+    {
+      puts ("join failed");
+      exit (1);
+    }
+
+  do_test (&_res);
+
+  exit (0);
+}
Index: trunk/src/libctests/glibc/nptl/tst-_res1mod1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-_res1mod1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-_res1mod1.c	(revision 2036)
@@ -0,0 +1,23 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <resolv.h>
+#undef _res
+
+struct __res_state _res;
Index: trunk/src/libctests/glibc/nptl/tst-_res1mod2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-_res1mod2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-_res1mod2.c	(revision 2036)
@@ -0,0 +1,1 @@
+/* Nothing.  */
Index: trunk/src/libctests/glibc/nptl/tst-align.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-align.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-align.c	(revision 2036)
@@ -0,0 +1,71 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <tst-stack-align.h>
+
+static void *
+tf (void *arg)
+{
+  bool ok = true;
+
+  puts ("in thread");
+
+  if (TEST_STACK_ALIGN ())
+    ok = false;
+
+  return ok ? NULL : (void *) -1l;
+}
+
+static int
+do_test (void)
+{
+  bool ok = true;
+
+  puts ("in main");
+
+  if (TEST_STACK_ALIGN ())
+    ok = false;
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      return 1;
+    }
+
+  void *res;
+  if (pthread_join (th, &res) != 0)
+    {
+      puts ("join failed");
+      return 1;
+    }
+
+  if (res != NULL)
+    ok = false;
+
+  return ok ? 0 : 1;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-align2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-align2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-align2.c	(revision 2036)
@@ -0,0 +1,87 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sched.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <tst-stack-align.h>
+
+static int
+f (void *arg)
+{
+  bool ok = true;
+
+  if (TEST_STACK_ALIGN ())
+    ok = false;
+
+  return ok ? 0 : 1;
+}
+
+static int
+do_test (void)
+{
+  bool ok = true;
+
+  puts ("in main");
+
+  if (TEST_STACK_ALIGN ())
+    ok = false;
+
+#ifdef __ia64__
+  extern int __clone2 (int (*__fn) (void *__arg), void *__child_stack_base,
+		       size_t __child_stack_size, int __flags,
+		       void *__arg, ...);
+  char st[256 * 1024];
+  pid_t p = __clone2 (f, st, sizeof (st), 0, 0);
+#else
+  char st[128 * 1024];
+  pid_t p = clone (f, st + sizeof (st), 0, 0);
+#endif
+  if (p == -1)
+    {
+      printf("clone failed: %m\n");
+      return 1;
+    }
+
+  int e;
+  if (waitpid (p, &e, __WCLONE) != p)
+    {
+      puts ("waitpid failed");
+      kill (p, SIGKILL);
+      return 1;
+    }
+  if (!WIFEXITED (e))
+    {
+      if (WIFSIGNALED (e))
+	printf ("died from signal %s\n", strsignal (WTERMSIG (e)));
+      else
+	puts ("did not terminate correctly");
+      return 1;
+    }
+  if (WEXITSTATUS (e) != 0)
+    ok = false;
+
+  return ok ? 0 : 1;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-atfork1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-atfork1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-atfork1.c	(revision 2036)
@@ -0,0 +1,121 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+
+static int val;
+
+
+static void
+prepare1 (void)
+{
+  val *= 2;
+}
+
+static void
+prepare2 (void)
+{
+  ++val;
+}
+
+static void
+parent1 (void)
+{
+  val += 4;
+}
+
+static void
+parent2 (void)
+{
+  val *= 4;
+}
+
+static void
+child1 (void)
+{
+  val += 8;
+}
+
+static void
+child2 (void)
+{
+  val *= 8;
+}
+
+
+static int
+do_test (void)
+{
+  pid_t pid;
+  int status = 0;
+
+  if (pthread_atfork (prepare1, parent1, child1) != 0)
+    {
+      puts ("1st atfork failed");
+      exit (1);
+    }
+  if (pthread_atfork (prepare2, parent2, child2) != 0)
+    {
+      puts ("2nd atfork failed");
+      exit (1);
+    }
+
+  pid = fork ();
+  if (pid == -1)
+    {
+      puts ("fork failed");
+      exit (1);
+    }
+
+  if (pid != 0)
+    {
+      /* Parent.  */
+      if (val != 24)
+	{
+	  printf ("expected val=%d, got %d\n", 24, val);
+	  exit (1);
+	}
+
+      if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
+	{
+	  puts ("waitpid failed");
+	  exit (1);
+	}
+    }
+  else
+    {
+      /* Child.  */
+      if (val != 80)
+	{
+	  printf ("expected val=%d, got %d\n", 80, val);
+	  exit (2);
+	}
+    }
+
+  return status;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-atfork2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-atfork2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-atfork2.c	(revision 2036)
@@ -0,0 +1,159 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <dlfcn.h>
+#include <errno.h>
+#include <mcheck.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+
+/* Must be exported.  */
+int val;
+
+static void
+prepare (void)
+{
+  val *= 2;
+}
+
+static void
+parent (void)
+{
+  val += 4;
+}
+
+static void
+child (void)
+{
+  val += 8;
+}
+
+
+static int
+do_test (void)
+{
+  mtrace ();
+
+  if (pthread_atfork (prepare, parent, child) != 0)
+    {
+      puts ("do_test: atfork failed");
+      exit (1);
+    }
+
+  void *h = dlopen ("tst-atfork2mod.so", RTLD_LAZY);
+  if (h == NULL)
+    {
+      printf ("dlopen failed: %s\n", dlerror ());
+      exit (1);
+    }
+
+  /* First trial of fork.  */
+  pid_t pid = fork ();
+  if (pid == -1)
+    {
+      puts ("1st fork failed");
+      exit (1);
+    }
+
+  if (pid == 0)
+    {
+      /* Child.  */
+      if (val != 80)
+	{
+	  printf ("1st: expected val=%d, got %d\n", 80, val);
+	  exit (2);
+	}
+
+      exit (0);
+    }
+
+  /* Parent.  */
+  if (val != 24)
+    {
+      printf ("1st: expected val=%d, got %d\n", 24, val);
+      exit (1);
+    }
+
+  int status;
+  if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
+    {
+      puts ("1st waitpid failed");
+      exit (1);
+    }
+
+  if (status != 0)
+    exit (status);
+
+  puts ("unloading now");
+
+  /* Unload the module.  */
+  if (dlclose (h) != 0)
+    {
+      puts ("dlclose failed");
+      exit (1);
+    }
+
+  puts ("2nd fork");
+
+  /* Second fork trial.   */
+  val = 1;
+  pid = fork ();
+  if (pid == -1)
+    {
+      puts ("2nd fork failed");
+      exit (1);
+    }
+
+  if (pid == 0)
+    {
+      /* Child.  */
+      if (val != 10)
+	{
+	  printf ("2nd: expected val=%d, got %d\n", 10, val);
+	  exit (3);
+	}
+
+      exit (0);
+    }
+
+  /* Parent.  */
+  if (val != 6)
+    {
+      printf ("2nd: expected val=%d, got %d\n", 6, val);
+      exit (1);
+    }
+
+  if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
+    {
+      puts ("2nd waitpid failed");
+      exit (1);
+    }
+
+  if (status != 0)
+    exit (status);
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-atfork2mod.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-atfork2mod.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-atfork2mod.c	(revision 2036)
@@ -0,0 +1,58 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+extern int val;
+
+
+static void
+prepare (void)
+{
+  ++val;
+}
+
+static void
+parent (void)
+{
+  val *= 4;
+}
+
+static void
+child (void)
+{
+  val *= 8;
+}
+
+static void
+__attribute__ ((constructor))
+init (void)
+{
+  extern void *__dso_handle;
+  printf ("dsohandle = %p\n", __dso_handle);
+
+  if (pthread_atfork (prepare, parent, child) != 0)
+    {
+      puts ("init: atfork failed");
+      exit (1);
+    }
+}
Index: trunk/src/libctests/glibc/nptl/tst-attr1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-attr1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-attr1.c	(revision 2036)
@@ -0,0 +1,306 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+int
+do_test (void)
+{
+  int i;
+  pthread_attr_t a;
+
+  if (pthread_attr_init (&a) != 0)
+    {
+      puts ("attr_init failed");
+      exit (1);
+    }
+
+  pthread_mutexattr_t ma;
+
+  if (pthread_mutexattr_init (&ma) != 0)
+    {
+      puts ("mutexattr_init failed");
+      exit (1);
+    }
+
+  pthread_rwlockattr_t rwa;
+
+  if (pthread_rwlockattr_init (&rwa) != 0)
+    {
+      puts ("rwlockattr_init failed");
+      exit (1);
+    }
+
+  /* XXX Remove if default value is clear.  */
+  pthread_attr_setinheritsched (&a, PTHREAD_INHERIT_SCHED);
+  pthread_attr_setschedpolicy (&a, SCHED_OTHER);
+  pthread_attr_setscope (&a, PTHREAD_SCOPE_SYSTEM);
+
+  for (i = 0; i < 10000; ++i)
+    {
+      long int r = random ();
+
+      if (r != PTHREAD_CREATE_DETACHED && r != PTHREAD_CREATE_JOINABLE)
+	{
+	  int e = pthread_attr_setdetachstate (&a, r);
+
+	  if (e == 0)
+	    {
+	      printf ("attr_setdetachstate with value %ld succeeded\n", r);
+	      exit (1);
+	    }
+	  if (e != EINVAL)
+	    {
+	      puts ("attr_setdetachstate didn't return EINVAL");
+	      exit (1);
+	    }
+
+	  int s;
+	  if (pthread_attr_getdetachstate (&a, &s) != 0)
+	    {
+	      puts ("attr_getdetachstate failed");
+	      exit (1);
+	    }
+
+	  if (s != PTHREAD_CREATE_JOINABLE)
+	    {
+	      printf ("\
+detach state changed to %d by invalid setdetachstate call\n", s);
+	      exit (1);
+	    }
+	}
+
+      if (r != PTHREAD_INHERIT_SCHED && r != PTHREAD_EXPLICIT_SCHED)
+	{
+	  int e = pthread_attr_setinheritsched (&a, r);
+
+	  if (e == 0)
+	    {
+	      printf ("attr_setinheritsched with value %ld succeeded\n", r);
+	      exit (1);
+	    }
+	  if (e != EINVAL)
+	    {
+	      puts ("attr_setinheritsched didn't return EINVAL");
+	      exit (1);
+	    }
+
+	  int s;
+	  if (pthread_attr_getinheritsched (&a, &s) != 0)
+	    {
+	      puts ("attr_getinheritsched failed");
+	      exit (1);
+	    }
+
+	  if (s != PTHREAD_INHERIT_SCHED)
+	    {
+	      printf ("\
+inheritsched changed to %d by invalid setinheritsched call\n", s);
+	      exit (1);
+	    }
+	}
+
+      if (r != SCHED_OTHER && r != SCHED_RR && r != SCHED_FIFO)
+	{
+	  int e = pthread_attr_setschedpolicy (&a, r);
+
+	  if (e == 0)
+	    {
+	      printf ("attr_setschedpolicy with value %ld succeeded\n", r);
+	      exit (1);
+	    }
+	  if (e != EINVAL)
+	    {
+	      puts ("attr_setschedpolicy didn't return EINVAL");
+	      exit (1);
+	    }
+
+	  int s;
+	  if (pthread_attr_getschedpolicy (&a, &s) != 0)
+	    {
+	      puts ("attr_getschedpolicy failed");
+	      exit (1);
+	    }
+
+	  if (s != SCHED_OTHER)
+	    {
+	      printf ("\
+schedpolicy changed to %d by invalid setschedpolicy call\n", s);
+	      exit (1);
+	    }
+	}
+
+      if (r != PTHREAD_SCOPE_SYSTEM && r != PTHREAD_SCOPE_PROCESS)
+	{
+	  int e = pthread_attr_setscope (&a, r);
+
+	  if (e == 0)
+	    {
+	      printf ("attr_setscope with value %ld succeeded\n", r);
+	      exit (1);
+	    }
+	  if (e != EINVAL)
+	    {
+	      puts ("attr_setscope didn't return EINVAL");
+	      exit (1);
+	    }
+
+	  int s;
+	  if (pthread_attr_getscope (&a, &s) != 0)
+	    {
+	      puts ("attr_getscope failed");
+	      exit (1);
+	    }
+
+	  if (s != PTHREAD_SCOPE_SYSTEM)
+	    {
+	      printf ("\
+contentionscope changed to %d by invalid setscope call\n", s);
+	      exit (1);
+	    }
+	}
+
+      if (r != PTHREAD_PROCESS_PRIVATE && r != PTHREAD_PROCESS_SHARED)
+	{
+	  int e = pthread_mutexattr_setpshared (&ma, r);
+
+	  if (e == 0)
+	    {
+	      printf ("mutexattr_setpshared with value %ld succeeded\n", r);
+	      exit (1);
+	    }
+	  if (e != EINVAL)
+	    {
+	      puts ("mutexattr_setpshared didn't return EINVAL");
+	      exit (1);
+	    }
+
+	  int s;
+	  if (pthread_mutexattr_getpshared (&ma, &s) != 0)
+	    {
+	      puts ("mutexattr_getpshared failed");
+	      exit (1);
+	    }
+
+	  if (s != PTHREAD_PROCESS_PRIVATE)
+	    {
+	      printf ("\
+pshared changed to %d by invalid mutexattr_setpshared call\n", s);
+	      exit (1);
+	    }
+
+	  e = pthread_rwlockattr_setpshared (&rwa, r);
+
+	  if (e == 0)
+	    {
+	      printf ("rwlockattr_setpshared with value %ld succeeded\n", r);
+	      exit (1);
+	    }
+	  if (e != EINVAL)
+	    {
+	      puts ("rwlockattr_setpshared didn't return EINVAL");
+	      exit (1);
+	    }
+
+	  if (pthread_rwlockattr_getpshared (&rwa, &s) != 0)
+	    {
+	      puts ("rwlockattr_getpshared failed");
+	      exit (1);
+	    }
+
+	  if (s != PTHREAD_PROCESS_PRIVATE)
+	    {
+	      printf ("\
+pshared changed to %d by invalid rwlockattr_setpshared call\n", s);
+	      exit (1);
+	    }
+	}
+
+      if (r != PTHREAD_CANCEL_ENABLE && r != PTHREAD_CANCEL_DISABLE)
+	{
+	  int e = pthread_setcancelstate (r, NULL);
+
+	  if (e == 0)
+	    {
+	      printf ("setcancelstate with value %ld succeeded\n", r);
+	      exit (1);
+	    }
+
+	  if (e != EINVAL)
+	    {
+	      puts ("setcancelstate didn't return EINVAL");
+	      exit (1);
+	    }
+
+	  int s;
+	  if (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, &s) != 0)
+	    {
+	      puts ("setcancelstate failed for PTHREAD_CANCEL_ENABLE");
+	      exit (1);
+	    }
+
+	  if (s != PTHREAD_CANCEL_ENABLE)
+	    {
+	      puts ("invalid setcancelstate changed state");
+	      exit (1);
+	    }
+	}
+
+      if (r != PTHREAD_CANCEL_DEFERRED && r != PTHREAD_CANCEL_ASYNCHRONOUS)
+	{
+	  int e = pthread_setcanceltype (r, NULL);
+
+	  if (e == 0)
+	    {
+	      printf ("setcanceltype with value %ld succeeded\n", r);
+	      exit (1);
+	    }
+
+	  if (e != EINVAL)
+	    {
+	      puts ("setcanceltype didn't return EINVAL");
+	      exit (1);
+	    }
+
+	  int s;
+	  if (pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &s) != 0)
+	    {
+	      puts ("setcanceltype failed for PTHREAD_CANCEL_DEFERRED");
+	      exit (1);
+	    }
+
+	  if (s != PTHREAD_CANCEL_DEFERRED)
+	    {
+	      puts ("invalid setcanceltype changed state");
+	      exit (1);
+	    }
+	}
+    }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-attr2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-attr2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-attr2.c	(revision 2036)
@@ -0,0 +1,317 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+int
+do_test (void)
+{
+  pthread_attr_t a;
+
+  if (pthread_attr_init (&a) != 0)
+    {
+      puts ("attr_init failed");
+      exit (1);
+    }
+
+  /* Check default value of detach state.  */
+  int s;
+  if (pthread_attr_getdetachstate (&a, &s) != 0)
+    {
+      puts ("1st attr_getdestachstate failed");
+      exit (1);
+    }
+  if (s != PTHREAD_CREATE_JOINABLE)
+    {
+      printf ("\
+default detach state wrong: %d, expected %d (PTHREAD_CREATE_JOINABLE)\n",
+	      s, PTHREAD_CREATE_JOINABLE);
+      exit (1);
+    }
+
+  int e = pthread_attr_setdetachstate (&a, PTHREAD_CREATE_DETACHED);
+  if (e != 0)
+    {
+      puts ("1st attr_setdetachstate failed");
+      exit (1);
+    }
+  if (pthread_attr_getdetachstate (&a, &s) != 0)
+    {
+      puts ("2nd attr_getdestachstate failed");
+      exit (1);
+    }
+  if (s != PTHREAD_CREATE_DETACHED)
+    {
+      puts ("PTHREAD_CREATE_DETACHED set, but not given back");
+      exit (1);
+    }
+
+  e = pthread_attr_setdetachstate (&a, PTHREAD_CREATE_JOINABLE);
+  if (e != 0)
+    {
+      puts ("2nd attr_setdetachstate failed");
+      exit (1);
+    }
+  if (pthread_attr_getdetachstate (&a, &s) != 0)
+    {
+      puts ("3rd attr_getdestachstate failed");
+      exit (1);
+    }
+  if (s != PTHREAD_CREATE_JOINABLE)
+    {
+      puts ("PTHREAD_CREATE_JOINABLE set, but not given back");
+      exit (1);
+    }
+
+
+  size_t g;
+  if (pthread_attr_getguardsize (&a, &g) != 0)
+    {
+      puts ("1st attr_getguardsize failed");
+      exit (1);
+    }
+  if (g != (size_t) sysconf (_SC_PAGESIZE))
+    {
+      printf ("default guardsize %zu, expected %ld (PAGESIZE)\n",
+	      g, sysconf (_SC_PAGESIZE));
+      exit (1);
+    }
+
+  e = pthread_attr_setguardsize (&a, 0);
+  if (e != 0)
+    {
+      puts ("1st attr_setguardsize failed");
+      exit (1);
+    }
+  if (pthread_attr_getguardsize (&a, &g) != 0)
+    {
+      puts ("2nd attr_getguardsize failed");
+      exit (1);
+    }
+  if (g != 0)
+    {
+      printf ("guardsize set to zero but %zu returned\n", g);
+      exit (1);
+    }
+
+  e = pthread_attr_setguardsize (&a, 1);
+  if (e != 0)
+    {
+      puts ("2nd attr_setguardsize failed");
+      exit (1);
+    }
+  if (pthread_attr_getguardsize (&a, &g) != 0)
+    {
+      puts ("3rd attr_getguardsize failed");
+      exit (1);
+    }
+  if (g != 1)
+    {
+      printf ("guardsize set to 1 but %zu returned\n", g);
+      exit (1);
+    }
+
+
+  if (pthread_attr_getinheritsched (&a, &s) != 0)
+    {
+      puts ("1st attr_getinheritsched failed");
+      exit (1);
+    }
+  /* XXX What is the correct default value.  */
+  if (s != PTHREAD_INHERIT_SCHED && s != PTHREAD_EXPLICIT_SCHED)
+    {
+      puts ("incorrect default value for inheritsched");
+      exit (1);
+    }
+
+  e = pthread_attr_setinheritsched (&a, PTHREAD_EXPLICIT_SCHED);
+  if (e != 0)
+    {
+      puts ("1st attr_setinheritsched failed");
+      exit (1);
+    }
+  if (pthread_attr_getinheritsched (&a, &s) != 0)
+    {
+      puts ("2nd attr_getinheritsched failed");
+      exit (1);
+    }
+  if (s != PTHREAD_EXPLICIT_SCHED)
+    {
+      printf ("inheritsched set to PTHREAD_EXPLICIT_SCHED, but got %d\n", s);
+      exit (1);
+    }
+
+  e = pthread_attr_setinheritsched (&a, PTHREAD_INHERIT_SCHED);
+  if (e != 0)
+    {
+      puts ("2nd attr_setinheritsched failed");
+      exit (1);
+    }
+  if (pthread_attr_getinheritsched (&a, &s) != 0)
+    {
+      puts ("3rd attr_getinheritsched failed");
+      exit (1);
+    }
+  if (s != PTHREAD_INHERIT_SCHED)
+    {
+      printf ("inheritsched set to PTHREAD_INHERIT_SCHED, but got %d\n", s);
+      exit (1);
+    }
+
+
+  if (pthread_attr_getschedpolicy (&a, &s) != 0)
+    {
+      puts ("1st attr_getschedpolicy failed");
+      exit (1);
+    }
+  /* XXX What is the correct default value.  */
+  if (s != SCHED_OTHER && s != SCHED_FIFO && s != SCHED_RR)
+    {
+      puts ("incorrect default value for schedpolicy");
+      exit (1);
+    }
+
+  e = pthread_attr_setschedpolicy (&a, SCHED_RR);
+  if (e != 0)
+    {
+      puts ("1st attr_setschedpolicy failed");
+      exit (1);
+    }
+  if (pthread_attr_getschedpolicy (&a, &s) != 0)
+    {
+      puts ("2nd attr_getschedpolicy failed");
+      exit (1);
+    }
+  if (s != SCHED_RR)
+    {
+      printf ("schedpolicy set to SCHED_RR, but got %d\n", s);
+      exit (1);
+    }
+
+  e = pthread_attr_setschedpolicy (&a, SCHED_FIFO);
+  if (e != 0)
+    {
+      puts ("2nd attr_setschedpolicy failed");
+      exit (1);
+    }
+  if (pthread_attr_getschedpolicy (&a, &s) != 0)
+    {
+      puts ("3rd attr_getschedpolicy failed");
+      exit (1);
+    }
+  if (s != SCHED_FIFO)
+    {
+      printf ("schedpolicy set to SCHED_FIFO, but got %d\n", s);
+      exit (1);
+    }
+
+  e = pthread_attr_setschedpolicy (&a, SCHED_OTHER);
+  if (e != 0)
+    {
+      puts ("3rd attr_setschedpolicy failed");
+      exit (1);
+    }
+  if (pthread_attr_getschedpolicy (&a, &s) != 0)
+    {
+      puts ("4th attr_getschedpolicy failed");
+      exit (1);
+    }
+  if (s != SCHED_OTHER)
+    {
+      printf ("schedpolicy set to SCHED_OTHER, but got %d\n", s);
+      exit (1);
+    }
+
+
+  if (pthread_attr_getscope (&a, &s) != 0)
+    {
+      puts ("1st attr_getscope failed");
+      exit (1);
+    }
+  /* XXX What is the correct default value.  */
+  if (s != PTHREAD_SCOPE_SYSTEM && s != PTHREAD_SCOPE_PROCESS)
+    {
+      puts ("incorrect default value for contentionscope");
+      exit (1);
+    }
+
+  e = pthread_attr_setscope (&a, PTHREAD_SCOPE_PROCESS);
+  if (e != ENOTSUP)
+    {
+      if (e != 0)
+	{
+	  puts ("1st attr_setscope failed");
+	  exit (1);
+	}
+      if (pthread_attr_getscope (&a, &s) != 0)
+	{
+	  puts ("2nd attr_getscope failed");
+	  exit (1);
+	}
+      if (s != PTHREAD_SCOPE_PROCESS)
+	{
+	  printf ("\
+contentionscope set to PTHREAD_SCOPE_PROCESS, but got %d\n", s);
+	  exit (1);
+	}
+    }
+
+  e = pthread_attr_setscope (&a, PTHREAD_SCOPE_SYSTEM);
+  if (e != 0)
+    {
+      puts ("2nd attr_setscope failed");
+      exit (1);
+    }
+  if (pthread_attr_getscope (&a, &s) != 0)
+    {
+      puts ("3rd attr_getscope failed");
+      exit (1);
+    }
+  if (s != PTHREAD_SCOPE_SYSTEM)
+    {
+      printf ("contentionscope set to PTHREAD_SCOPE_SYSTEM, but got %d\n", s);
+      exit (1);
+    }
+
+  char buf[1];
+  e = pthread_attr_setstack (&a, buf, 1);
+  if (e != EINVAL)
+    {
+      puts ("setstack with size 1 did not produce EINVAL");
+      exit (1);
+    }
+
+  e = pthread_attr_setstacksize (&a, 1);
+  if (e != EINVAL)
+    {
+      puts ("setstacksize with size 1 did not produce EINVAL");
+      exit (1);
+    }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-attr3.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-attr3.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-attr3.c	(revision 2036)
@@ -0,0 +1,422 @@
+/* pthread_getattr_np test.
+   Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <error.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <stackinfo.h>
+
+static void *
+tf (void *arg)
+{
+  pthread_attr_t a, *ap, a2;
+  int err;
+  void *result = NULL;
+
+  if (arg == NULL)
+    {
+      ap = &a2;
+      err = pthread_attr_init (ap);
+      if (err)
+        {
+          error (0, err, "pthread_attr_init failed");
+          return tf;
+        }
+    }
+  else
+    ap = (pthread_attr_t *) arg;
+
+  err = pthread_getattr_np (pthread_self (), &a);
+  if (err)
+    {
+      error (0, err, "pthread_getattr_np failed");
+      result = tf;
+    }
+
+  int detachstate1, detachstate2;
+  err = pthread_attr_getdetachstate (&a, &detachstate1);
+  if (err)
+    {
+      error (0, err, "pthread_attr_getdetachstate failed");
+      result = tf;
+    }
+  else
+    {
+      err = pthread_attr_getdetachstate (ap, &detachstate2);
+      if (err)
+	{
+	  error (0, err, "pthread_attr_getdetachstate failed");
+	  result = tf;
+	}
+      else if (detachstate1 != detachstate2)
+	{
+	  error (0, 0, "detachstate differs %d != %d",
+		 detachstate1, detachstate2);
+	  result = tf;
+	}
+    }
+
+  void *stackaddr;
+  size_t stacksize;
+  err = pthread_attr_getstack (&a, &stackaddr, &stacksize);
+  if (err)
+    {
+      error (0, err, "pthread_attr_getstack failed");
+      result = tf;
+    }
+  else if ((void *) &a < stackaddr
+	   || (void *) &a >= stackaddr + stacksize)
+    {
+      error (0, 0, "pthread_attr_getstack returned range does not cover thread's stack");
+      result = tf;
+    }
+  else
+    printf ("thread stack %p-%p (0x%zx)\n", stackaddr, stackaddr + stacksize,
+	    stacksize);
+
+  size_t guardsize1, guardsize2;
+  err = pthread_attr_getguardsize (&a, &guardsize1);
+  if (err)
+    {
+      error (0, err, "pthread_attr_getguardsize failed");
+      result = tf;
+    }
+  else
+    {
+      err = pthread_attr_getguardsize (ap, &guardsize2);
+      if (err)
+	{
+	  error (0, err, "pthread_attr_getguardsize failed");
+	  result = tf;
+	}
+      else if (guardsize1 != guardsize2)
+	{
+	  error (0, 0, "guardsize differs %zd != %zd",
+		 guardsize1, guardsize2);
+	  result = tf;
+	}
+      else
+	printf ("thread guardsize %zd\n", guardsize1);
+    }
+
+  int scope1, scope2;
+  err = pthread_attr_getscope (&a, &scope1);
+  if (err)
+    {
+      error (0, err, "pthread_attr_getscope failed");
+      result = tf;
+    }
+  else
+    {
+      err = pthread_attr_getscope (ap, &scope2);
+      if (err)
+	{
+	  error (0, err, "pthread_attr_getscope failed");
+	  result = tf;
+	}
+      else if (scope1 != scope2)
+	{
+	  error (0, 0, "scope differs %d != %d",
+		 scope1, scope2);
+	  result = tf;
+	}
+    }
+
+  int inheritsched1, inheritsched2;
+  err = pthread_attr_getinheritsched (&a, &inheritsched1);
+  if (err)
+    {
+      error (0, err, "pthread_attr_getinheritsched failed");
+      result = tf;
+    }
+  else
+    {
+      err = pthread_attr_getinheritsched (ap, &inheritsched2);
+      if (err)
+	{
+	  error (0, err, "pthread_attr_getinheritsched failed");
+	  result = tf;
+	}
+      else if (inheritsched1 != inheritsched2)
+	{
+	  error (0, 0, "inheritsched differs %d != %d",
+		 inheritsched1, inheritsched2);
+	  result = tf;
+	}
+    }
+
+  cpu_set_t c1, c2;
+  err = pthread_getaffinity_np (pthread_self (), sizeof (c1), &c1);
+  if (err == 0)
+    {
+      err = pthread_attr_getaffinity_np (&a, sizeof (c2), &c2);
+      if (err)
+	{
+	  error (0, err, "pthread_attr_getaffinity_np failed");
+	  result = tf;
+	}
+      else if (memcmp (&c1, &c2, sizeof (c1)))
+	{
+	  error (0, 0, "pthread_attr_getaffinity_np returned different CPU mask than pthread_getattr_np");
+	  result = tf;
+	}
+    }
+
+  err = pthread_attr_destroy (&a);
+  if (err)
+    {
+      error (0, err, "pthread_attr_destroy failed");
+      result = tf;
+    }
+
+  if (ap == &a2)
+    {
+      err = pthread_attr_destroy (ap);
+      if (err)
+	{
+	  error (0, err, "pthread_attr_destroy failed");
+	  result = tf;
+	}
+    }
+
+  return result;
+}
+
+
+static int
+do_test (void)
+{
+  int result = 0;
+  pthread_attr_t a;
+  cpu_set_t c1, c2;
+
+  int err = pthread_attr_init (&a);
+  if (err)
+    {
+      error (0, err, "pthread_attr_init failed");
+      result = 1;
+    }
+
+  err = pthread_attr_getaffinity_np (&a, sizeof (c1), &c1);
+  if (err && err != ENOSYS)
+    {
+      error (0, err, "pthread_attr_getaffinity_np failed");
+      result = 1;
+    }
+
+  err = pthread_attr_destroy (&a);
+  if (err)
+    {
+      error (0, err, "pthread_attr_destroy failed");
+      result = 1;
+    }
+
+  err = pthread_getattr_np (pthread_self (), &a);
+  if (err)
+    {
+      error (0, err, "pthread_getattr_np failed");
+      result = 1;
+    }
+
+  int detachstate;
+  err = pthread_attr_getdetachstate (&a, &detachstate);
+  if (err)
+    {
+      error (0, err, "pthread_attr_getdetachstate failed");
+      result = 1;
+    }
+  else if (detachstate != PTHREAD_CREATE_JOINABLE)
+    {
+      error (0, 0, "initial thread not joinable");
+      result = 1;
+    }
+
+  void *stackaddr;
+  size_t stacksize;
+  err = pthread_attr_getstack (&a, &stackaddr, &stacksize);
+  if (err)
+    {
+      error (0, err, "pthread_attr_getstack failed");
+      result = 1;
+    }
+  else if ((void *) &a < stackaddr
+	   || (void *) &a >= stackaddr + stacksize)
+    {
+      error (0, 0, "pthread_attr_getstack returned range does not cover main's stack");
+      result = 1;
+    }
+  else
+    printf ("initial thread stack %p-%p (0x%zx)\n", stackaddr,
+	    stackaddr + stacksize, stacksize);
+
+  size_t guardsize;
+  err = pthread_attr_getguardsize (&a, &guardsize);
+  if (err)
+    {
+      error (0, err, "pthread_attr_getguardsize failed");
+      result = 1;
+    }
+  else if (guardsize != 0)
+    {
+      error (0, 0, "pthread_attr_getguardsize returned %zd != 0",
+	     guardsize);
+      result = 1;
+    }
+
+  int scope;
+  err = pthread_attr_getscope (&a, &scope);
+  if (err)
+    {
+      error (0, err, "pthread_attr_getscope failed");
+      result = 1;
+    }
+  else if (scope != PTHREAD_SCOPE_SYSTEM)
+    {
+      error (0, 0, "pthread_attr_getscope returned %d != PTHREAD_SCOPE_SYSTEM",
+	     scope);
+      result = 1;
+    }
+
+  int inheritsched;
+  err = pthread_attr_getinheritsched (&a, &inheritsched);
+  if (err)
+    {
+      error (0, err, "pthread_attr_getinheritsched failed");
+      result = 1;
+    }
+  else if (inheritsched != PTHREAD_INHERIT_SCHED)
+    {
+      error (0, 0, "pthread_attr_getinheritsched returned %d != PTHREAD_INHERIT_SCHED",
+	     inheritsched);
+      result = 1;
+    }
+
+  err = pthread_getaffinity_np (pthread_self (), sizeof (c1), &c1);
+  if (err == 0)
+    {
+      err = pthread_attr_getaffinity_np (&a, sizeof (c2), &c2);
+      if (err)
+	{
+	  error (0, err, "pthread_attr_getaffinity_np failed");
+	  result = 1;
+	}
+      else if (memcmp (&c1, &c2, sizeof (c1)))
+	{
+	  error (0, 0, "pthread_attr_getaffinity_np returned different CPU mask than pthread_getattr_np");
+	  result = 1;
+	}
+    }
+
+  err = pthread_attr_destroy (&a);
+  if (err)
+    {
+      error (0, err, "pthread_attr_destroy failed");
+      result = 1;
+    }
+
+  pthread_t th;
+  err = pthread_create (&th, NULL, tf, NULL);
+  if (err)
+    {
+      error (0, err, "pthread_create #1 failed");
+      result = 1;
+    }
+  else
+    {
+      void *ret;
+      err = pthread_join (th, &ret);
+      if (err)
+	{
+	  error (0, err, "pthread_join #1 failed");
+	  result = 1;
+	}
+      else if (ret != NULL)
+        result = 1;
+    }
+
+  err = pthread_attr_init (&a);
+  if (err)
+    {
+      error (0, err, "pthread_attr_init failed");
+      result = 1;
+    }
+
+  err = pthread_create (&th, &a, tf, &a);
+  if (err)
+    {
+      error (0, err, "pthread_create #2 failed");
+      result = 1;
+    }
+  else
+    {
+      void *ret;
+      err = pthread_join (th, &ret);
+      if (err)
+	{
+	  error (0, err, "pthread_join #2 failed");
+	  result = 1;
+	}
+      else if (ret != NULL)
+        result = 1;
+    }
+
+  err = pthread_attr_setguardsize (&a, 16 * sysconf (_SC_PAGESIZE));
+  if (err)
+    {
+      error (0, err, "pthread_attr_setguardsize failed");
+      result = 1;
+    }
+
+  err = pthread_create (&th, &a, tf, &a);
+  if (err)
+    {
+      error (0, err, "pthread_create #3 failed");
+      result = 1;
+    }
+  else
+    {
+      void *ret;
+      err = pthread_join (th, &ret);
+      if (err)
+	{
+	  error (0, err, "pthread_join #3 failed");
+	  result = 1;
+	}
+      else if (ret != NULL)
+        result = 1;
+    }
+
+  err = pthread_attr_destroy (&a);
+  if (err)
+    {
+      error (0, err, "pthread_attr_destroy failed");
+      result = 1;
+    }
+
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-backtrace1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-backtrace1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-backtrace1.c	(revision 2036)
@@ -0,0 +1,86 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <execinfo.h>
+#include <pthread.h>
+#include <stdio.h>
+
+#define BT_SIZE 64
+void *bt_array[BT_SIZE];
+int bt_cnt;
+
+int
+do_bt (void)
+{
+  bt_cnt = backtrace (bt_array, BT_SIZE);
+  return 56;
+}
+
+int
+call_do_bt (void)
+{
+  return do_bt () + 1;
+}
+
+void *
+tf (void *arg)
+{
+  if (call_do_bt () != 57)
+    return (void *) 1L;
+  return NULL;
+}
+
+int
+do_test (void)
+{
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, NULL))
+    {
+      puts ("create failed");
+      return 1;
+    }
+
+  void *res;
+  if (pthread_join (th, &res))
+    {
+      puts ("join failed");
+      return 1;
+    }
+
+  if (res != NULL)
+    {
+      puts ("thread failed");
+      return 1;
+    }
+
+  char **text = backtrace_symbols (bt_array, bt_cnt);
+  if (text == NULL)
+    {
+      puts ("backtrace_symbols failed");
+      return 1;
+    }
+
+  for (int i = 0; i < bt_cnt; ++i)
+    puts (text[i]);
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-barrier1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-barrier1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-barrier1.c	(revision 2036)
@@ -0,0 +1,71 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+
+
+static int
+do_test (void)
+{
+  pthread_barrier_t b;
+  int e;
+  int cnt;
+
+  e = pthread_barrier_init (&b, NULL, 0);
+  if (e == 0)
+    {
+      puts ("barrier_init with count 0 succeeded");
+      return 1;
+    }
+  if (e != EINVAL)
+    {
+      puts ("barrier_init with count 0 didn't return EINVAL");
+      return 1;
+    }
+
+  if (pthread_barrier_init (&b, NULL, 1) != 0)
+    {
+      puts ("real barrier_init failed");
+      return 1;
+    }
+
+  for (cnt = 0; cnt < 10; ++cnt)
+    {
+      e = pthread_barrier_wait (&b);
+
+      if (e != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  puts ("barrier_wait didn't return PTHREAD_BARRIER_SERIAL_THREAD");
+	  return 1;
+	}
+    }
+
+  if (pthread_barrier_destroy (&b) != 0)
+    {
+      puts ("barrier_destroy failed");
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-barrier2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-barrier2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-barrier2.c	(revision 2036)
@@ -0,0 +1,185 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+
+static int
+do_test (void)
+{
+  size_t ps = sysconf (_SC_PAGESIZE);
+  char tmpfname[] = "/tmp/tst-barrier2.XXXXXX";
+  char data[ps];
+  void *mem;
+  int fd;
+  pthread_barrier_t *b;
+  pthread_barrierattr_t a;
+  pid_t pid;
+  int serials = 0;
+  int cnt;
+  int status;
+  int p;
+
+  fd = mkstemp (tmpfname);
+  if (fd == -1)
+    {
+      printf ("cannot open temporary file: %m\n");
+      return 1;
+    }
+
+  /* Make sure it is always removed.  */
+  unlink (tmpfname);
+
+  /* Create one page of data.  */
+  memset (data, '\0', ps);
+
+  /* Write the data to the file.  */
+  if (write (fd, data, ps) != (ssize_t) ps)
+    {
+      puts ("short write");
+      return 1;
+    }
+
+  mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+  if (mem == MAP_FAILED)
+    {
+      printf ("mmap failed: %m\n");
+      return 1;
+    }
+
+  b = (pthread_barrier_t *) (((uintptr_t) mem + __alignof (pthread_barrier_t))
+			     & ~(__alignof (pthread_barrier_t) - 1));
+
+  if (pthread_barrierattr_init (&a) != 0)
+    {
+      puts ("barrierattr_init failed");
+      return 1;
+    }
+
+  if (pthread_barrierattr_getpshared (&a, &p) != 0)
+    {
+      puts ("1st barrierattr_getpshared failed");
+      return 1;
+    }
+
+  if (p != PTHREAD_PROCESS_PRIVATE)
+    {
+      puts ("default pshared value wrong");
+      return 1;
+    }
+
+  if (pthread_barrierattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0)
+    {
+      puts ("barrierattr_setpshared failed");
+      return 1;
+    }
+
+  if (pthread_barrierattr_getpshared (&a, &p) != 0)
+    {
+      puts ("2nd barrierattr_getpshared failed");
+      return 1;
+    }
+
+  if (p != PTHREAD_PROCESS_SHARED)
+    {
+      puts ("pshared value after setpshared call wrong");
+      return 1;
+    }
+
+  if (pthread_barrier_init (b, &a, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      return 1;
+    }
+
+  if (pthread_barrierattr_destroy (&a) != 0)
+    {
+      puts ("barrierattr_destroy failed");
+      return 1;
+    }
+
+  puts ("going to fork now");
+  pid = fork ();
+  if (pid == -1)
+    {
+      puts ("fork failed");
+      return 1;
+    }
+
+  /* Just to be sure we don't hang forever.  */
+  alarm (4);
+
+#define N 30
+  for (cnt = 0; cnt < N; ++cnt)
+    {
+      int e;
+
+      e = pthread_barrier_wait (b);
+      if (e == PTHREAD_BARRIER_SERIAL_THREAD)
+	++serials;
+      else if (e != 0)
+	{
+	  printf ("%s: barrier_wait returned value %d != 0 and PTHREAD_BARRIER_SERIAL_THREAD\n",
+		  pid == 0 ? "child" : "parent", e);
+	  return 1;
+	}
+    }
+
+  alarm (0);
+
+  printf ("%s: was %d times the serial thread\n",
+	  pid == 0 ? "child" : "parent", serials);
+
+  if (pid == 0)
+    /* The child.  Pass the number of times we had the serializing
+       thread back to the parent.  */
+    exit (serials);
+
+  if (waitpid (pid, &status, 0) != pid)
+    {
+      puts ("waitpid failed");
+      return 1;
+    }
+
+  if (!WIFEXITED (status))
+    {
+      puts ("child exited abnormally");
+      return 1;
+    }
+
+  if (WEXITSTATUS (status) + serials != N)
+    {
+      printf ("total number of serials is %d, expected %d\n",
+	      WEXITSTATUS (status) + serials, N);
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-barrier3.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-barrier3.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-barrier3.c	(revision 2036)
@@ -0,0 +1,154 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* Test of POSIX barriers.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define NTHREADS 20
+
+#define ROUNDS 20
+
+static pthread_barrier_t barriers[NTHREADS];
+
+static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+static int counters[NTHREADS];
+static int serial[NTHREADS];
+
+static void *
+worker (void *arg)
+{
+  void *result = NULL;
+  int nr = (long int) arg;
+  int i;
+
+  for (i = 0; i < ROUNDS; ++i)
+    {
+      int j;
+      int retval;
+
+      if (nr == 0)
+	{
+	  memset (counters, '\0', sizeof (counters));
+	  memset (serial, '\0', sizeof (serial));
+	}
+
+      retval = pthread_barrier_wait (&barriers[NTHREADS - 1]);
+      if (retval != 0 && retval != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("thread %d failed to wait for all the others\n", nr);
+	  result = (void *) 1;
+	}
+
+      for (j = nr; j < NTHREADS; ++j)
+	{
+	  /* Increment the counter for this round.  */
+	  pthread_mutex_lock (&lock);
+	  ++counters[j];
+	  pthread_mutex_unlock (&lock);
+
+	  /* Wait for the rest.  */
+	  retval = pthread_barrier_wait (&barriers[j]);
+
+	  /* Test the result.  */
+	  if (nr == 0 && counters[j] != j + 1)
+	    {
+	      printf ("barrier in round %d released but count is %d\n",
+		      j, counters[j]);
+	      result = (void *) 1;
+	    }
+
+	  if (retval != 0)
+	    {
+	      if (retval != PTHREAD_BARRIER_SERIAL_THREAD)
+		{
+		  printf ("thread %d in round %d has nonzero return value != PTHREAD_BARRIER_SERIAL_THREAD\n",
+			  nr, j);
+		  result = (void *) 1;
+		}
+	      else
+		{
+		  pthread_mutex_lock (&lock);
+		  ++serial[j];
+		  pthread_mutex_unlock (&lock);
+		}
+	    }
+
+	  /* Wait for the rest again.  */
+	  retval = pthread_barrier_wait (&barriers[j]);
+
+	  /* Now we can check whether exactly one thread was serializing.  */
+	  if (nr == 0 && serial[j] != 1)
+	    {
+	      printf ("not exactly one serial thread in round %d\n", j);
+	      result = (void *) 1;
+	    }
+	}
+    }
+
+  return result;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 60
+static int
+do_test (void)
+{
+  pthread_t threads[NTHREADS];
+  int i;
+  void *res;
+  int result = 0;
+
+  /* Initialized the barrier variables.  */
+  for (i = 0; i < NTHREADS; ++i)
+    if (pthread_barrier_init (&barriers[i], NULL, i + 1) != 0)
+      {
+	printf ("Failed to initialize barrier %d\n", i);
+	exit (1);
+      }
+
+  /* Start the threads.  */
+  for (i = 0; i < NTHREADS; ++i)
+    if (pthread_create (&threads[i], NULL, worker, (void *) (long int) i) != 0)
+      {
+	printf ("Failed to start thread %d\n", i);
+	exit (1);
+      }
+
+  /* And wait for them.  */
+  for (i = 0; i < NTHREADS; ++i)
+    if (pthread_join (threads[i], &res) != 0 || res != NULL)
+      {
+	printf ("thread %d returned a failure\n", i);
+	result = 1;
+      }
+    else
+      printf ("joined threads %d\n", i);
+
+  if (result == 0)
+    puts ("all OK");
+
+  return result;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-barrier4.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-barrier4.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-barrier4.c	(revision 2036)
@@ -0,0 +1,121 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* This is a test for behavior not guaranteed by POSIX.  */
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+
+
+static pthread_barrier_t b1;
+static pthread_barrier_t b2;
+
+
+#define N 20
+
+static void *
+tf (void *arg)
+{
+  int round = 0;
+
+  while (round++ < 30)
+    {
+      if (pthread_barrier_wait (&b1) == PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  pthread_barrier_destroy (&b1);
+	  if (pthread_barrier_init (&b1, NULL, N) != 0)
+	    {
+	      puts ("tf: 1st barrier_init failed");
+	      exit (1);
+	    }
+	}
+
+      if (pthread_barrier_wait (&b2) == PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  pthread_barrier_destroy (&b2);
+	  if (pthread_barrier_init (&b2, NULL, N) != 0)
+	    {
+	      puts ("tf: 2nd barrier_init failed");
+	      exit (1);
+	    }
+	}
+    }
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_attr_t at;
+  int cnt;
+
+  if (pthread_attr_init (&at) != 0)
+    {
+      puts ("attr_init failed");
+      return 1;
+    }
+
+  if (pthread_attr_setstacksize (&at, 1 * 1024 * 1024) != 0)
+    {
+      puts ("attr_setstacksize failed");
+      return 1;
+    }
+
+  if (pthread_barrier_init (&b1, NULL, N) != 0)
+    {
+      puts ("1st barrier_init failed");
+      return 1;
+    }
+
+  if (pthread_barrier_init (&b2, NULL, N) != 0)
+    {
+      puts ("2nd barrier_init failed");
+      return 1;
+    }
+
+  pthread_t th[N - 1];
+  for (cnt = 0; cnt < N - 1; ++cnt)
+    if (pthread_create (&th[cnt], &at, tf, NULL) != 0)
+      {
+	puts ("pthread_create failed");
+	return 1;
+      }
+
+  if (pthread_attr_destroy (&at) != 0)
+    {
+      puts ("attr_destroy failed");
+      return 1;
+    }
+
+  tf (NULL);
+
+  for (cnt = 0; cnt < N - 1; ++cnt)
+    if (pthread_join (th[cnt], NULL) != 0)
+      {
+	puts ("pthread_join failed");
+	return 1;
+      }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-basic1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-basic1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-basic1.c	(revision 2036)
@@ -0,0 +1,82 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+
+static pid_t pid;
+
+static void *
+tf (void *a)
+{
+  if (getpid () != pid)
+    {
+      write (2, "pid mismatch\n", 13);
+      _exit (1);
+    }
+
+  return a;
+}
+
+
+int
+do_test (void)
+{
+  pid = getpid ();
+
+#define N 2
+  pthread_t t[N];
+  int i;
+
+  for (i = 0; i < N; ++i)
+    if (pthread_create (&t[i], NULL, tf, (void *) (long int) (i + 1)) != 0)
+      {
+	write (2, "create failed\n", 14);
+	_exit (1);
+      }
+    else
+      printf ("created thread %d\n", i);
+
+  for (i = 0; i < N; ++i)
+    {
+      void *r;
+      int e;
+      if ((e = pthread_join (t[i], &r)) != 0)
+	{
+	  printf ("join failed: %d\n", e);
+	  _exit (1);
+	}
+      else if (r != (void *) (long int) (i + 1))
+	{
+	  write (2, "result wrong\n", 13);
+	  _exit (1);
+	}
+      else
+	printf ("joined thread %d\n", i);
+    }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-basic2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-basic2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-basic2.c	(revision 2036)
@@ -0,0 +1,121 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+#define N 20
+
+static pthread_t th[N];
+static pthread_mutex_t lock[N];
+
+
+static void *tf (void *a)
+{
+  uintptr_t idx = (uintptr_t) a;
+
+  pthread_mutex_lock (&lock[idx]);
+
+  return pthread_equal (pthread_self (), th[idx]) ? NULL : (void *) 1l;
+}
+
+
+int
+do_test (void)
+{
+  if (pthread_equal (pthread_self (), pthread_self ()) == 0)
+    {
+      puts ("pthread_equal (pthread_self (), pthread_self ()) failed");
+      exit (1);
+    }
+
+  pthread_attr_t at;
+
+  if (pthread_attr_init (&at) != 0)
+    {
+      puts ("attr_init failed");
+      return 1;
+    }
+
+  if (pthread_attr_setstacksize (&at, 1 * 1024 * 1024) != 0)
+    {
+      puts ("attr_setstacksize failed");
+      return 1;
+    }
+
+  int i;
+  for (i = 0; i < N; ++i)
+    {
+      if (pthread_mutex_init (&lock[i], NULL) != 0)
+	{
+	  puts ("mutex_init failed");
+	  exit (1);
+	}
+
+      if (pthread_mutex_lock (&lock[i]) != 0)
+	{
+	  puts ("mutex_lock failed");
+	  exit (1);
+	}
+
+      if (pthread_create (&th[i], &at, tf, (void *) (long int) i) != 0)
+	{
+	  puts ("create failed");
+	  exit (1);
+	}
+
+      if (pthread_mutex_unlock (&lock[i]) != 0)
+	{
+	  puts ("mutex_unlock failed");
+	  exit (1);
+	}
+
+      printf ("created thread %d\n", i);
+    }
+
+  if (pthread_attr_destroy (&at) != 0)
+    {
+      puts ("attr_destroy failed");
+      return 1;
+    }
+
+  int result = 0;
+  for (i = 0; i < N; ++i)
+    {
+      void *r;
+      int e;
+      if ((e = pthread_join (th[i], &r)) != 0)
+	{
+	  printf ("join failed: %d\n", e);
+	  _exit (1);
+	}
+      else if (r != NULL)
+	result = 1;
+    }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-basic3.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-basic3.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-basic3.c	(revision 2036)
@@ -0,0 +1,87 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static int nrunning = 1;
+
+
+static void
+final_test (void)
+{
+  puts ("final_test has been called");
+
+#define THE_SIGNAL SIGUSR1
+  kill (getpid (), SIGUSR1);
+}
+
+
+static void *
+tf (void *a)
+{
+  if (pthread_join ((pthread_t) a, NULL) != 0)
+    {
+      printf ("join failed while %d are running\n", nrunning);
+      _exit (1);
+    }
+
+  printf ("%2d left\n", --nrunning);
+
+  return NULL;
+}
+
+
+int
+do_test (void)
+{
+#define N 20
+  pthread_t t[N];
+  pthread_t last = pthread_self ();
+  int i;
+
+  atexit (final_test);
+
+  printf ("starting %d + 1 threads\n", N);
+  for (i = 0; i < N; ++i)
+    {
+      if (pthread_create (&t[i], NULL, tf, (void *) last) != 0)
+	{
+	  puts ("create failed");
+	  _exit (1);
+	}
+
+      ++nrunning;
+
+      last = t[i];
+    }
+
+  printf ("%2d left\n", --nrunning);
+
+  pthread_exit (NULL);
+}
+
+
+#define EXPECTED_SIGNAL THE_SIGNAL
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-basic4.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-basic4.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-basic4.c	(revision 2036)
@@ -0,0 +1,101 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+
+static void
+final_test (void)
+{
+  puts ("final_test has been called");
+
+#define THE_SIGNAL SIGUSR1
+  kill (getpid (), SIGUSR1);
+}
+
+
+static void *
+tf (void *a)
+{
+  pid_t pid = fork ();
+  if (pid == -1)
+    {
+      puts ("fork failed");
+      exit (1);
+    }
+
+  if (pid == 0)
+    {
+      atexit (final_test);
+
+      pthread_exit (NULL);
+    }
+
+  int r;
+  int e = TEMP_FAILURE_RETRY (waitpid (pid, &r, 0));
+  if (e != pid)
+    {
+      puts ("waitpid failed");
+      exit (1);
+    }
+
+  if (! WIFSIGNALED (r))
+    {
+      puts ("child not signled");
+      exit (1);
+    }
+
+  if (WTERMSIG (r) != THE_SIGNAL)
+    {
+      puts ("child's termination signal wrong");
+      exit (1);
+    }
+
+  return NULL;
+}
+
+
+int
+do_test (void)
+{
+  pthread_t th;
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      _exit (1);
+    }
+
+  if (pthread_join (th, NULL) != 0)
+    {
+      puts ("join failed");
+      exit (1);
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-basic5.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-basic5.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-basic5.c	(revision 2036)
@@ -0,0 +1,74 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+
+int
+do_test (void)
+{
+  int c = pthread_getconcurrency ();
+  if (c != 0)
+    {
+      puts ("initial concurrencylevel wrong");
+      exit (1);
+    }
+
+  if (pthread_setconcurrency (1) != 0)
+    {
+      puts ("setconcurrency failed");
+      exit (1);
+    }
+
+  c = pthread_getconcurrency ();
+  if (c != 1)
+    {
+      puts ("getconcurrency didn't return the value previous set");
+      exit (1);
+    }
+
+  int e = pthread_setconcurrency (-1);
+  if (e == 0)
+    {
+      puts ("setconcurrency of negative value didn't failed");
+      exit (1);
+    }
+  if (e != EINVAL)
+    {
+      puts ("setconcurrency didn't return EINVAL for negative value");
+      exit (1);
+    }
+
+  c = pthread_getconcurrency ();
+  if (c != 1)
+    {
+      puts ("invalid getconcurrency changed level");
+      exit (1);
+    }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-basic6.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-basic6.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-basic6.c	(revision 2036)
@@ -0,0 +1,132 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static char *p;
+
+static pthread_barrier_t b;
+#define BT \
+  e = pthread_barrier_wait (&b);					      \
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)			      \
+    {									      \
+      puts ("barrier_wait failed");					      \
+      exit (1);								      \
+    }
+
+
+static void *
+tf (void *a)
+{
+  int e;
+
+  BT;
+
+  char *p2 = getcwd (NULL, 0);
+  if (p2 == NULL)
+    {
+      puts ("2nd getcwd failed");
+      exit (1);
+    }
+
+  if (strcmp (p, p2) != 0)
+    {
+      printf ("initial cwd mismatch: \"%s\" vs \"%s\"\n", p, p2);
+      exit (1);
+    }
+
+  free (p);
+  free (p2);
+
+  if (chdir ("..") != 0)
+    {
+      puts ("chdir failed");
+      exit (1);
+    }
+
+  p = getcwd (NULL, 0);
+  if (p == NULL)
+    {
+      puts ("getcwd failed");
+      exit (1);
+    }
+
+  return a;
+}
+
+
+int
+do_test (void)
+{
+  if (pthread_barrier_init (&b, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      exit (1);
+    }
+
+  p = getcwd (NULL, 0);
+  if (p == NULL)
+    {
+      puts ("getcwd failed");
+      exit (1);
+    }
+
+  int e;
+  BT;
+
+  if (pthread_join (th, NULL) != 0)
+    {
+      puts ("join failed");
+      exit (1);
+    }
+
+  char *p2 = getcwd (NULL, 0);
+  if (p2 == NULL)
+    {
+      puts ("2nd getcwd failed");
+      exit (1);
+    }
+
+  if (strcmp (p, p2) != 0)
+    {
+      printf ("cwd after chdir mismatch: \"%s\" vs \"%s\"\n", p, p2);
+      exit (1);
+    }
+
+  free (p);
+  free (p2);
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancel-wrappers.sh
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancel-wrappers.sh	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancel-wrappers.sh	(revision 2036)
@@ -0,0 +1,92 @@
+#! /bin/sh
+# Test whether all cancelable functions are cancelable.
+# Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+# Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+while [ $# -gt 0 ]; do
+  ( nm -P $1; echo 'end[end]:' ) | gawk ' BEGIN {
+C["accept"]=1
+C["close"]=1
+C["connect"]=1
+C["creat"]=1
+C["fcntl"]=1
+C["fsync"]=1
+C["msgrcv"]=1
+C["msgsnd"]=1
+C["msync"]=1
+C["nanosleep"]=1
+C["open"]=1
+C["open64"]=1
+C["pause"]=1
+C["poll"]=1
+C["pread"]=1
+C["pread64"]=1
+C["pselect"]=1
+C["pwrite"]=1
+C["pwrite64"]=1
+C["read"]=1
+C["readv"]=1
+C["recv"]=1
+C["recvfrom"]=1
+C["recvmsg"]=1
+C["select"]=1
+C["send"]=1
+C["sendmsg"]=1
+C["sendto"]=1
+C["sigpause"]=1
+C["sigsuspend"]=1
+C["sigwait"]=1
+C["sigwaitinfo"]=1
+C["system"]=1
+C["tcdrain"]=1
+C["wait"]=1
+C["waitid"]=1
+C["waitpid"]=1
+C["write"]=1
+C["writev"]=1
+C["__xpg_sigpause"]=1
+}
+/:$/ {
+  if (seen)
+    {
+      if (!seen_enable || !seen_disable)
+	{
+	  printf "in '$1'(%s) %s'\''s cancellation missing\n", object, seen
+	  ret = 1
+	}
+    }
+  seen=""
+  seen_enable=""
+  seen_disable=""
+  object=gensub(/^.*\[(.*)\]:$/,"\\1","",$0)
+  next
+}
+{
+  if (C[$1] && $2 ~ /^[TW]$/)
+    seen=$1
+  else if ($1 ~ /^([.]|)__(libc|pthread)_enable_asynccancel$/ && $2 == "U")
+    seen_enable=1
+  else if ($1 ~ /^([.]|)__(libc|pthread)_disable_asynccancel$/ && $2 == "U")
+    seen_disable=1
+}
+END {
+  exit ret
+}' || exit
+  shift
+done
Index: trunk/src/libctests/glibc/nptl/tst-cancel1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancel1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancel1.c	(revision 2036)
@@ -0,0 +1,163 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+static pthread_mutex_t m1 = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t m2 = PTHREAD_MUTEX_INITIALIZER;
+
+static int cntr;
+
+
+static void
+cleanup (void *arg)
+{
+  if (arg != (void *) 42l)
+    cntr = 42;
+  else
+    cntr = 1;
+}
+
+
+static void *
+tf (void *arg)
+{
+  /* Ignore all signals.  This must not have any effect on delivering
+     the cancellation signal.  */
+  sigset_t ss;
+
+  sigfillset (&ss);
+
+  if (pthread_sigmask (SIG_BLOCK, &ss, NULL) != 0)
+    {
+      puts ("pthread_sigmask failed");
+      exit (1);
+    }
+
+  pthread_cleanup_push (cleanup, (void *) 42l);
+
+  int err = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+  if (err != 0)
+    {
+      printf ("setcanceltype failed: %s\n", strerror (err));
+      exit (1);
+    }
+  /* The following code is not standard compliant: the mutex functions
+     must not be called with asynchronous cancellation enabled.  */
+
+  err = pthread_mutex_unlock (&m2);
+  if (err != 0)
+    {
+      printf ("child: mutex_unlock failed: %s\n", strerror (err));
+      exit (1);
+    }
+
+  err = pthread_mutex_lock (&m1);
+  if (err != 0)
+    {
+      printf ("child: 1st mutex_lock failed: %s\n", strerror (err));
+      exit (1);
+    }
+
+  /* We should never come here.  */
+
+  pthread_cleanup_pop (0);
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  int err;
+  pthread_t th;
+  int result = 0;
+  void *retval;
+
+  /* Get the mutexes.  */
+  err = pthread_mutex_lock (&m1);
+  if (err != 0)
+    {
+      printf ("parent: 1st mutex_lock failed: %s\n", strerror (err));
+      return 1;
+    }
+  err = pthread_mutex_lock (&m2);
+  if (err != 0)
+    {
+      printf ("parent: 2nd mutex_lock failed: %s\n", strerror (err));
+      return 1;
+    }
+
+  err = pthread_create (&th, NULL, tf, NULL);
+  if (err != 0)
+    {
+      printf ("create failed: %s\n", strerror (err));
+      return 1;
+    }
+
+  err = pthread_mutex_lock (&m2);
+  if (err != 0)
+    {
+      printf ("parent: 3rd mutex_lock failed: %s\n", strerror (err));
+      return 1;
+    }
+
+  err = pthread_cancel (th);
+  if (err != 0)
+    {
+      printf ("cancel failed: %s\n", strerror (err));
+      return 1;
+    }
+
+  err = pthread_join (th, &retval);
+  if (err != 0)
+    {
+      printf ("join failed: %s\n", strerror (err));
+      return 1;
+    }
+
+  if (retval != PTHREAD_CANCELED)
+    {
+      printf ("wrong return value: %p\n", retval);
+      result = 1;
+    }
+
+  if (cntr == 42)
+    {
+      puts ("cleanup handler called with wrong argument");
+      result = 1;
+    }
+  else if (cntr != 1)
+    {
+      puts ("cleanup handling not called");
+      result = 1;
+    }
+
+  return result;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancel10.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancel10.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancel10.c	(revision 2036)
@@ -0,0 +1,126 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+static void
+cleanup (void *arg)
+{
+  /* Just for fun.  */
+  if (pthread_cancel (pthread_self ()) != 0)
+    {
+      puts ("cleanup: cancel failed");
+      exit (1);
+    }
+
+  printf ("cleanup for %ld\n", (long int) arg);
+}
+
+
+static void *
+tf (void *arg)
+{
+  long int n = (long int) arg;
+
+  pthread_cleanup_push (cleanup, arg);
+
+  if (pthread_setcanceltype ((n & 1) == 0
+			     ? PTHREAD_CANCEL_DEFERRED
+			     : PTHREAD_CANCEL_ASYNCHRONOUS, NULL) != 0)
+    {
+      puts ("setcanceltype failed");
+      exit (1);
+    }
+
+  if (pthread_cancel (pthread_self ()) != 0)
+    {
+      puts ("cancel failed");
+      exit (1);
+    }
+
+  pthread_testcancel ();
+
+  /* We should never come here.  */
+
+  pthread_cleanup_pop (0);
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_attr_t at;
+
+  if (pthread_attr_init (&at) != 0)
+    {
+      puts ("attr_init failed");
+      return 1;
+    }
+
+  if (pthread_attr_setstacksize (&at, 1 * 1024 * 1024) != 0)
+    {
+      puts ("attr_setstacksize failed");
+      return 1;
+    }
+
+#define N 20
+  int i;
+  pthread_t th[N];
+
+  for (i = 0; i < N; ++i)
+    if (pthread_create (&th[i], &at, tf, (void *) (long int) i) != 0)
+      {
+	puts ("create failed");
+	exit (1);
+      }
+
+  if (pthread_attr_destroy (&at) != 0)
+    {
+      puts ("attr_destroy failed");
+      return 1;
+    }
+
+  for (i = 0; i < N; ++i)
+    {
+      void *r;
+      if (pthread_join (th[i], &r) != 0)
+	{
+	  puts ("join failed");
+	  exit (1);
+	}
+
+      if (r != PTHREAD_CANCELED)
+	{
+	  puts ("thread not canceled");
+	  exit (1);
+	}
+    }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancel11.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancel11.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancel11.c	(revision 2036)
@@ -0,0 +1,123 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static pthread_barrier_t bar;
+static int fd[2];
+
+
+static void
+cleanup (void *arg)
+{
+  static int ncall;
+
+  if (++ncall != 1)
+    {
+      puts ("second call to cleanup");
+      exit (1);
+    }
+
+  printf ("cleanup call #%d\n", ncall);
+}
+
+
+static void *
+tf (void *arg)
+{
+  pthread_cleanup_push (cleanup, NULL);
+
+  int e = pthread_barrier_wait (&bar);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("tf: 1st barrier_wait failed");
+      exit (1);
+    }
+
+  /* This call should block and be cancelable.  */
+  char buf[20];
+  read (fd[0], buf, sizeof (buf));
+
+  pthread_cleanup_pop (0);
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t th;
+
+  if (pthread_barrier_init (&bar, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  if (pipe (fd) != 0)
+    {
+      puts ("pipe failed");
+      exit (1);
+    }
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      exit (1);
+    }
+
+  int e = pthread_barrier_wait (&bar);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("1st barrier_wait failed");
+      exit (1);
+    }
+
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("1st cancel failed");
+      exit (1);
+    }
+
+  void *r;
+  if (pthread_join (th, &r) != 0)
+    {
+      puts ("join failed");
+      exit (1);
+    }
+
+  if (r != PTHREAD_CANCELED)
+    {
+      puts ("thread not canceled");
+      exit (1);
+    }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancel12.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancel12.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancel12.c	(revision 2036)
@@ -0,0 +1,127 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static pthread_barrier_t bar;
+static sem_t sem;
+
+
+static void
+cleanup (void *arg)
+{
+  static int ncall;
+
+  if (++ncall != 1)
+    {
+      puts ("second call to cleanup");
+      exit (1);
+    }
+
+  printf ("cleanup call #%d\n", ncall);
+}
+
+
+static void *
+tf (void *arg)
+{
+  pthread_cleanup_push (cleanup, NULL);
+
+  int e = pthread_barrier_wait (&bar);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("tf: 1st barrier_wait failed");
+      exit (1);
+    }
+
+  /* This call should block and be cancelable.  */
+  sem_wait (&sem);
+
+  pthread_cleanup_pop (0);
+
+  puts ("sem_wait returned");
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t th;
+
+  if (pthread_barrier_init (&bar, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  if (sem_init (&sem, 0, 1) != 0)
+    {
+      puts ("sem_init failed");
+      exit (1);
+    }
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      exit (1);
+    }
+
+  /* Check whether cancellation is honored even before sem_wait does
+     anything.  */
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("1st cancel failed");
+      exit (1);
+    }
+
+  int e = pthread_barrier_wait (&bar);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("1st barrier_wait failed");
+      exit (1);
+    }
+
+  void *r;
+  if (pthread_join (th, &r) != 0)
+    {
+      puts ("join failed");
+      exit (1);
+    }
+
+  if (r != PTHREAD_CANCELED)
+    {
+      puts ("thread not canceled");
+      exit (1);
+    }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancel13.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancel13.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancel13.c	(revision 2036)
@@ -0,0 +1,129 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static pthread_barrier_t bar;
+static sem_t sem;
+
+
+static void
+cleanup (void *arg)
+{
+  static int ncall;
+
+  if (++ncall != 1)
+    {
+      puts ("second call to cleanup");
+      exit (1);
+    }
+
+  printf ("cleanup call #%d\n", ncall);
+}
+
+
+static void *
+tf (void *arg)
+{
+  pthread_cleanup_push (cleanup, NULL);
+
+  int e = pthread_barrier_wait (&bar);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("tf: 1st barrier_wait failed");
+      exit (1);
+    }
+
+  /* This call should block and be cancelable.  */
+  sem_wait (&sem);
+
+  pthread_cleanup_pop (0);
+
+  puts ("sem_wait returned");
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t th;
+
+  if (pthread_barrier_init (&bar, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  if (sem_init (&sem, 0, 0) != 0)
+    {
+      puts ("sem_init failed");
+      exit (1);
+    }
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      exit (1);
+    }
+
+  int e = pthread_barrier_wait (&bar);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("1st barrier_wait failed");
+      exit (1);
+    }
+
+  /* Give the child a chance to go to sleep in sem_wait.  */
+  sleep (1);
+
+  /* Check whether cancellation is honored when waiting in sem_wait.  */
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("1st cancel failed");
+      exit (1);
+    }
+
+  void *r;
+  if (pthread_join (th, &r) != 0)
+    {
+      puts ("join failed");
+      exit (1);
+    }
+
+  if (r != PTHREAD_CANCELED)
+    {
+      puts ("thread not canceled");
+      exit (1);
+    }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancel14.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancel14.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancel14.c	(revision 2036)
@@ -0,0 +1,136 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static pthread_barrier_t bar;
+static sem_t sem;
+
+
+static void
+cleanup (void *arg)
+{
+  static int ncall;
+
+  if (++ncall != 1)
+    {
+      puts ("second call to cleanup");
+      exit (1);
+    }
+
+  printf ("cleanup call #%d\n", ncall);
+}
+
+
+static void *
+tf (void *arg)
+{
+  pthread_cleanup_push (cleanup, NULL);
+
+  int e = pthread_barrier_wait (&bar);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("tf: 1st barrier_wait failed");
+      exit (1);
+    }
+
+  struct timeval tv;
+  (void) gettimeofday (&tv, NULL);
+
+  struct timespec ts;
+  TIMEVAL_TO_TIMESPEC (&tv, &ts);
+
+  /* Timeout in 5 seconds.  */
+  ts.tv_sec += 5;
+
+  /* This call should block and be cancelable.  */
+  sem_timedwait (&sem, &ts);
+
+  pthread_cleanup_pop (0);
+
+  puts ("sem_timedwait returned");
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t th;
+
+  if (pthread_barrier_init (&bar, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  if (sem_init (&sem, 0, 1) != 0)
+    {
+      puts ("sem_init failed");
+      exit (1);
+    }
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      exit (1);
+    }
+
+  /* Check whether cancellation is honored even before sem_timedwait does
+     anything.  */
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("1st cancel failed");
+      exit (1);
+    }
+
+  int e = pthread_barrier_wait (&bar);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("1st barrier_wait failed");
+      exit (1);
+    }
+
+  void *r;
+  if (pthread_join (th, &r) != 0)
+    {
+      puts ("join failed");
+      exit (1);
+    }
+
+  if (r != PTHREAD_CANCELED)
+    {
+      puts ("thread not canceled");
+      exit (1);
+    }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancel15.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancel15.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancel15.c	(revision 2036)
@@ -0,0 +1,141 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static pthread_barrier_t bar;
+static sem_t sem;
+
+
+static void
+cleanup (void *arg)
+{
+  static int ncall;
+
+  if (++ncall != 1)
+    {
+      puts ("second call to cleanup");
+      exit (1);
+    }
+
+  printf ("cleanup call #%d\n", ncall);
+}
+
+
+static void *
+tf (void *arg)
+{
+  int e;
+
+  pthread_cleanup_push (cleanup, NULL);
+
+  e = pthread_barrier_wait (&bar);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("tf: 1st barrier_wait failed");
+      exit (1);
+    }
+
+  struct timeval tv;
+  (void) gettimeofday (&tv, NULL);
+
+  struct timespec ts;
+  TIMEVAL_TO_TIMESPEC (&tv, &ts);
+
+  /* Timeout in 5 seconds.  */
+  ts.tv_sec += 5;
+
+  /* This call should block and be cancelable.  */
+  errno = 0;
+  e = sem_timedwait (&sem, &ts);
+
+  pthread_cleanup_pop (0);
+
+  printf ("sem_timedwait returned, e = %d, errno = %d\n", e, errno);
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t th;
+
+  if (pthread_barrier_init (&bar, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  if (sem_init (&sem, 0, 0) != 0)
+    {
+      puts ("sem_init failed");
+      exit (1);
+    }
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      exit (1);
+    }
+
+  int e = pthread_barrier_wait (&bar);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("1st barrier_wait failed");
+      exit (1);
+    }
+
+  /* Give the child a chance to go to sleep in sem_wait.  */
+  sleep (1);
+
+  /* Check whether cancellation is honored when waiting in sem_timedwait.  */
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("1st cancel failed");
+      exit (1);
+    }
+
+  void *r;
+  if (pthread_join (th, &r) != 0)
+    {
+      puts ("join failed");
+      exit (1);
+    }
+
+  if (r != PTHREAD_CANCELED)
+    {
+      puts ("thread not canceled");
+      exit (1);
+    }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancel16.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancel16.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancel16.c	(revision 2036)
@@ -0,0 +1,231 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+
+static pthread_barrier_t b2;
+static int fd;
+static int called;
+
+
+static void
+cl (void *arg)
+{
+  called = 1;
+}
+
+
+static void *
+tf (void *arg)
+{
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("child thread: barrier_wait failed");
+      exit (1);
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  /* This call should never return.  */
+  (void) lockf (fd, F_LOCK, 0);
+
+  pthread_cleanup_pop (0);
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  char fname[] = "/tmp/cancel16XXXXXX";
+  fd = mkstemp (fname);
+  if (fd == -1)
+    {
+      puts ("mkstemp failed");
+      return 1;
+    }
+  unlink (fname);
+
+  char mem[sizeof (pthread_barrier_t)];
+  memset (mem, '\0', sizeof (mem));
+  if (TEMP_FAILURE_RETRY (pwrite (fd, mem, sizeof (mem), 0)) != sizeof (mem))
+    {
+      puts ("pwrite failed");
+      return 1;
+    }
+
+  void *p = mmap (NULL, sizeof (mem), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+  if (p == MAP_FAILED)
+    {
+      puts ("mmap failed");
+      return 1;
+    }
+  pthread_barrier_t *b = (pthread_barrier_t *) p;
+
+  pthread_barrierattr_t ba;
+  if (pthread_barrierattr_init (&ba) != 0)
+    {
+      puts ("barrierattr_init failed");
+      return 1;
+    }
+  if (pthread_barrierattr_setpshared (&ba, 1) != 0)
+    {
+      puts ("barrierattr_setshared failed");
+      return 1;
+    }
+
+  if (pthread_barrier_init (b, &ba, 2) != 0)
+    {
+      puts ("1st barrier_init failed");
+      return 1;
+    }
+  if (pthread_barrierattr_destroy (&ba) != 0)
+    {
+      puts ("barrier_destroy failed");
+      return 1;
+    }
+
+  pid_t pid = fork ();
+  if (pid == 0)
+    {
+      /* Child.  Lock the file and wait.  */
+      if (lockf (fd, F_LOCK, 0) != 0)
+	{
+	  puts ("child process: lockf failed");
+	  _exit (1);
+	}
+
+      int r = pthread_barrier_wait (b);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  puts ("child process: 1st barrier_wait failed");
+	  _exit (1);
+	}
+
+      /* Make sure the process dies.  */
+      alarm (5);
+
+      r = pthread_barrier_wait (b);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  puts ("child process: 2nd barrier_wait failed");
+	  _exit (1);
+	}
+
+      _exit (0);
+    }
+  if (pid == -1)
+    {
+      puts ("fork failed");
+      return 1;
+    }
+
+  int r = pthread_barrier_wait (b);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("main: 1st barrier_wait failed");
+      _exit (1);
+    }
+
+  if (pthread_barrier_init (&b2, NULL, 2) != 0)
+    {
+      puts ("2nd barrier_init failed");
+      return 1;
+    }
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      return 1;
+    }
+
+  r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("main: 2nd barrier_wait failed");
+      return 1;
+    }
+
+  /* Delay.  */
+  sleep (1);
+
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("cancel failed");
+      return 1;
+    }
+
+  void *result;
+  if (pthread_join (th, &result) != 0)
+    {
+      puts ("join failed");
+      return 1;
+    }
+  if (result != PTHREAD_CANCELED)
+    {
+      puts ("thread not canceled");
+      return 1;
+    }
+  if (called == 0)
+    {
+      puts ("cleanup handler not called");
+      return 1;
+    }
+
+  r = pthread_barrier_wait (b);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("main: 3rd barrier_wait failed");
+      return 1;
+    }
+
+  int status;
+  if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
+    {
+      puts ("waitpid failed");
+      return 1;
+    }
+  if (WEXITSTATUS (status) != 0)
+    {
+      printf ("child process exits with %d\n", WEXITSTATUS (status));
+      return 1;
+    }
+
+  if (lockf (fd, F_LOCK, 0) != 0)
+    {
+      puts ("main: lockf failed");
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancel17.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancel17.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancel17.c	(revision 2036)
@@ -0,0 +1,341 @@
+/* Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <aio.h>
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static pthread_barrier_t b;
+
+
+/* Cleanup handling test.  */
+static int cl_called;
+
+static void
+cl (void *arg)
+{
+  ++cl_called;
+}
+
+
+static void *
+tf (void *arg)
+{
+  int r = pthread_barrier_wait (&b);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("tf: barrier_wait failed");
+      exit (1);
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  const struct aiocb *l[1] = { arg };
+
+  TEMP_FAILURE_RETRY (aio_suspend (l, 1, NULL));
+
+  pthread_cleanup_pop (0);
+
+  puts ("tf: aio_suspend returned");
+
+  exit (1);
+}
+
+
+static void *
+tf2 (void *arg)
+{
+  int r = pthread_barrier_wait (&b);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("tf2: barrier_wait failed");
+      exit (1);
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  const struct aiocb *l[1] = { arg };
+  struct timespec ts = { .tv_sec = 1000, .tv_nsec = 0 };
+
+  TEMP_FAILURE_RETRY (aio_suspend (l, 1, &ts));
+
+  pthread_cleanup_pop (0);
+
+  puts ("tf2: aio_suspend returned");
+
+  exit (1);
+}
+
+
+static int
+do_test (void)
+{
+  int fds[2];
+  if (pipe (fds) != 0)
+    {
+      puts ("pipe failed");
+      return 1;
+    }
+
+  struct aiocb a, a2, *ap;
+  char mem[1];
+  memset (&a, '\0', sizeof (a));
+  a.aio_fildes = fds[0];
+  a.aio_buf = mem;
+  a.aio_nbytes = sizeof (mem);
+  if (aio_read (&a) != 0)
+    {
+      puts ("aio_read failed");
+      return 1;
+    }
+
+  if (pthread_barrier_init (&b, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      return 1;
+    }
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, &a) != 0)
+    {
+      puts ("1st create failed");
+      return 1;
+    }
+
+  int r = pthread_barrier_wait (&b);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      exit (1);
+    }
+
+  struct timespec  ts = { .tv_sec = 0, .tv_nsec = 100000000 };
+  while (nanosleep (&ts, &ts) != 0)
+    continue;
+
+  puts ("going to cancel tf in-time");
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("1st cancel failed");
+      return 1;
+    }
+
+  void *status;
+  if (pthread_join (th, &status) != 0)
+    {
+      puts ("1st join failed");
+      return 1;
+    }
+  if (status != PTHREAD_CANCELED)
+    {
+      puts ("1st thread not canceled");
+      return 1;
+    }
+
+  if (cl_called == 0)
+    {
+      puts ("tf cleanup handler not called");
+      return 1;
+    }
+  if (cl_called > 1)
+    {
+      puts ("tf cleanup handler called more than once");
+      return 1;
+    }
+
+  cl_called = 0;
+
+  if (pthread_create (&th, NULL, tf2, &a) != 0)
+    {
+      puts ("2nd create failed");
+      return 1;
+    }
+
+  r = pthread_barrier_wait (&b);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("2nd barrier_wait failed");
+      exit (1);
+    }
+
+  ts.tv_sec = 0;
+  ts.tv_nsec = 100000000;
+  while (nanosleep (&ts, &ts) != 0)
+    continue;
+
+  puts ("going to cancel tf2 in-time");
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("2nd cancel failed");
+      return 1;
+    }
+
+  if (pthread_join (th, &status) != 0)
+    {
+      puts ("2nd join failed");
+      return 1;
+    }
+  if (status != PTHREAD_CANCELED)
+    {
+      puts ("2nd thread not canceled");
+      return 1;
+    }
+
+  if (cl_called == 0)
+    {
+      puts ("tf2 cleanup handler not called");
+      return 1;
+    }
+  if (cl_called > 1)
+    {
+      puts ("tf2 cleanup handler called more than once");
+      return 1;
+    }
+
+  puts ("in-time cancellation succeeded");
+
+  ap = &a;
+  if (aio_cancel (fds[0], &a) != AIO_CANCELED)
+    {
+      puts ("aio_cancel failed");
+      /* If aio_cancel failed, we cannot reuse aiocb a.  */
+      ap = &a2;
+    }
+
+
+  cl_called = 0;
+
+  size_t len2 = fpathconf (fds[1], _PC_PIPE_BUF);
+  size_t page_size = sysconf (_SC_PAGESIZE);
+  len2 = 20 * (len2 < page_size ? page_size : len2) + sizeof (mem) + 1;
+  char *mem2 = malloc (len2);
+  if (mem2 == NULL)
+    {
+      puts ("could not allocate memory for pipe write");
+      return 1;
+    }
+
+  memset (ap, '\0', sizeof (*ap));
+  ap->aio_fildes = fds[1];
+  ap->aio_buf = mem2;
+  ap->aio_nbytes = len2;
+  if (aio_write (ap) != 0)
+    {
+      puts ("aio_write failed");
+      return 1;
+    }
+
+  if (pthread_create (&th, NULL, tf, ap) != 0)
+    {
+      puts ("3rd create failed");
+      return 1;
+    }
+
+  puts ("going to cancel tf early");
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("3rd cancel failed");
+      return 1;
+    }
+
+  r = pthread_barrier_wait (&b);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("3rd barrier_wait failed");
+      exit (1);
+    }
+
+  if (pthread_join (th, &status) != 0)
+    {
+      puts ("3rd join failed");
+      return 1;
+    }
+  if (status != PTHREAD_CANCELED)
+    {
+      puts ("3rd thread not canceled");
+      return 1;
+    }
+
+  if (cl_called == 0)
+    {
+      puts ("tf cleanup handler not called");
+      return 1;
+    }
+  if (cl_called > 1)
+    {
+      puts ("tf cleanup handler called more than once");
+      return 1;
+    }
+
+  cl_called = 0;
+
+  if (pthread_create (&th, NULL, tf2, ap) != 0)
+    {
+      puts ("4th create failed");
+      return 1;
+    }
+
+  puts ("going to cancel tf2 early");
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("4th cancel failed");
+      return 1;
+    }
+
+  r = pthread_barrier_wait (&b);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("4th barrier_wait failed");
+      exit (1);
+    }
+
+  if (pthread_join (th, &status) != 0)
+    {
+      puts ("4th join failed");
+      return 1;
+    }
+  if (status != PTHREAD_CANCELED)
+    {
+      puts ("4th thread not canceled");
+      return 1;
+    }
+
+  if (cl_called == 0)
+    {
+      puts ("tf2 cleanup handler not called");
+      return 1;
+    }
+  if (cl_called > 1)
+    {
+      puts ("tf2 cleanup handler called more than once");
+      return 1;
+    }
+
+  puts ("early cancellation succeeded");
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancel18.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancel18.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancel18.c	(revision 2036)
@@ -0,0 +1,174 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+
+
+static pthread_barrier_t b;
+
+
+/* Cleanup handling test.  */
+static int cl_called;
+
+static void
+cl (void *arg)
+{
+  ++cl_called;
+}
+
+
+static void *
+tf (void *arg)
+{
+  int r = pthread_barrier_wait (&b);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      exit (1);
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  struct timespec ts = { .tv_sec = arg == NULL ? 10000000 : 0, .tv_nsec = 0 };
+  TEMP_FAILURE_RETRY (clock_nanosleep (CLOCK_REALTIME, 0, &ts, &ts));
+
+  pthread_cleanup_pop (0);
+
+  puts ("clock_nanosleep returned");
+
+  exit (1);
+}
+
+
+static int
+do_test (void)
+{
+  if (pthread_barrier_init (&b, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      return 1;
+    }
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("1st create failed");
+      return 1;
+    }
+
+  int r = pthread_barrier_wait (&b);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      exit (1);
+    }
+
+  struct timespec  ts = { .tv_sec = 0, .tv_nsec = 100000000 };
+  while (nanosleep (&ts, &ts) != 0)
+    continue;
+
+  puts ("going to cancel in-time");
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("1st cancel failed");
+      return 1;
+    }
+
+  void *status;
+  if (pthread_join (th, &status) != 0)
+    {
+      puts ("1st join failed");
+      return 1;
+    }
+  if (status != PTHREAD_CANCELED)
+    {
+      puts ("1st thread not canceled");
+      return 1;
+    }
+
+  if (cl_called == 0)
+    {
+      puts ("cleanup handler not called");
+      return 1;
+    }
+  if (cl_called > 1)
+    {
+      puts ("cleanup handler called more than once");
+      return 1;
+    }
+
+  puts ("in-time cancellation succeeded");
+
+
+  cl_called = 0;
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("2nd create failed");
+      return 1;
+    }
+
+  puts ("going to cancel early");
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("2nd cancel failed");
+      return 1;
+    }
+
+  r = pthread_barrier_wait (&b);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      exit (1);
+    }
+
+  if (pthread_join (th, &status) != 0)
+    {
+      puts ("2nd join failed");
+      return 1;
+    }
+  if (status != PTHREAD_CANCELED)
+    {
+      puts ("2nd thread not canceled");
+      return 1;
+    }
+
+  if (cl_called == 0)
+    {
+      printf ("cleanup handler not called\n");
+      return 1;
+    }
+  if (cl_called > 1)
+    {
+      printf ("cleanup handler called more than once\n");
+      return 1;
+    }
+
+  puts ("early cancellation succeeded");
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancel19.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancel19.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancel19.c	(revision 2036)
@@ -0,0 +1,287 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <error.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/select.h>
+#include <sys/time.h>
+#include <unistd.h>
+
+static void *
+tf (void *arg)
+{
+  return NULL;
+}
+
+static void
+handler (int sig)
+{
+}
+
+static void __attribute__ ((noinline))
+clobber_lots_of_regs (void)
+{
+#define X1(n) long r##n = 10##n; __asm __volatile ("" : "+r" (r##n));
+#define X2(n) X1(n##0) X1(n##1) X1(n##2) X1(n##3) X1(n##4)
+#define X3(n) X2(n##0) X2(n##1) X2(n##2) X2(n##3) X2(n##4)
+  X3(0) X3(1) X3(2) X3(3) X3(4)
+#undef X1
+#define X1(n) __asm __volatile ("" : : "r" (r##n));
+  X3(0) X3(1) X3(2) X3(3) X3(4)
+#undef X1
+#undef X2
+#undef X3
+}
+
+static int
+do_test (void)
+{
+  pthread_t th;
+  int old, rc;
+  int ret = 0;
+  int fd[2];
+
+  rc = pipe (fd);
+  if (rc < 0)
+    error (EXIT_FAILURE, errno, "couldn't create pipe");
+
+  rc = pthread_create (&th, NULL, tf, NULL);
+  if (rc)
+    error (EXIT_FAILURE, rc, "couldn't create thread");
+
+  rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old);
+  if (rc)
+    {
+      error (0, rc, "1st pthread_setcanceltype failed");
+      ret = 1;
+    }
+  if (old != PTHREAD_CANCEL_DEFERRED && old != PTHREAD_CANCEL_ASYNCHRONOUS)
+    {
+      error (0, 0, "1st pthread_setcanceltype returned invalid value %d",
+	     old);
+      ret = 1;
+    }
+
+  clobber_lots_of_regs ();
+  close (fd[0]);
+
+  rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old);
+  if (rc)
+    {
+      error (0, rc, "pthread_setcanceltype after close failed");
+      ret = 1;
+    }
+  if (old != PTHREAD_CANCEL_DEFERRED)
+    {
+      error (0, 0, "pthread_setcanceltype after close returned invalid value %d",
+	     old);
+      ret = 1;
+    }
+
+  clobber_lots_of_regs ();
+  close (fd[1]);
+
+  rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old);
+  if (rc)
+    {
+      error (0, rc, "pthread_setcanceltype after 2nd close failed");
+      ret = 1;
+    }
+  if (old != PTHREAD_CANCEL_ASYNCHRONOUS)
+    {
+      error (0, 0, "pthread_setcanceltype after 2nd close returned invalid value %d",
+	     old);
+      ret = 1;
+    }
+
+  struct sigaction sa = { .sa_handler = handler, .sa_flags = 0 };
+  sigemptyset (&sa.sa_mask);
+  sigaction (SIGALRM, &sa, NULL);
+
+  struct itimerval it;
+  it.it_value.tv_sec = 1;
+  it.it_value.tv_usec = 0;
+  it.it_interval = it.it_value;
+  setitimer (ITIMER_REAL, &it, NULL);
+
+  clobber_lots_of_regs ();
+  pause ();
+
+  memset (&it, 0, sizeof (it));
+  setitimer (ITIMER_REAL, &it, NULL);
+
+  rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old);
+  if (rc)
+    {
+      error (0, rc, "pthread_setcanceltype after pause failed");
+      ret = 1;
+    }
+  if (old != PTHREAD_CANCEL_DEFERRED)
+    {
+      error (0, 0, "pthread_setcanceltype after pause returned invalid value %d",
+	     old);
+      ret = 1;
+    }
+
+  it.it_value.tv_sec = 1;
+  it.it_value.tv_usec = 0;
+  it.it_interval = it.it_value;
+  setitimer (ITIMER_REAL, &it, NULL);
+
+  clobber_lots_of_regs ();
+  pause ();
+
+  memset (&it, 0, sizeof (it));
+  setitimer (ITIMER_REAL, &it, NULL);
+
+  rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old);
+  if (rc)
+    {
+      error (0, rc, "pthread_setcanceltype after 2nd pause failed");
+      ret = 1;
+    }
+  if (old != PTHREAD_CANCEL_ASYNCHRONOUS)
+    {
+      error (0, 0, "pthread_setcanceltype after 2nd pause returned invalid value %d",
+	     old);
+      ret = 1;
+    }
+
+  char fname[] = "/tmp/tst-cancel19-dir-XXXXXX\0foo/bar";
+  char *enddir = strchr (fname, '\0');
+  if (mkdtemp (fname) == NULL)
+    {
+      error (0, errno, "mkdtemp failed");
+      ret = 1;
+    }
+  *enddir = '/';
+
+  clobber_lots_of_regs ();
+  creat (fname, 0400);
+
+  rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old);
+  if (rc)
+    {
+      error (0, rc, "pthread_setcanceltype after creat failed");
+      ret = 1;
+    }
+  if (old != PTHREAD_CANCEL_DEFERRED)
+    {
+      error (0, 0, "pthread_setcanceltype after creat returned invalid value %d",
+	     old);
+      ret = 1;
+    }
+
+  clobber_lots_of_regs ();
+  creat (fname, 0400);
+
+  rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old);
+  if (rc)
+    {
+      error (0, rc, "pthread_setcanceltype after 2nd creat failed");
+      ret = 1;
+    }
+  if (old != PTHREAD_CANCEL_ASYNCHRONOUS)
+    {
+      error (0, 0, "pthread_setcanceltype after 2nd creat returned invalid value %d",
+	     old);
+      ret = 1;
+    }
+
+  clobber_lots_of_regs ();
+  open (fname, O_CREAT, 0400);
+
+  rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old);
+  if (rc)
+    {
+      error (0, rc, "pthread_setcanceltype after open failed");
+      ret = 1;
+    }
+  if (old != PTHREAD_CANCEL_DEFERRED)
+    {
+      error (0, 0, "pthread_setcanceltype after open returned invalid value %d",
+	     old);
+      ret = 1;
+    }
+
+  clobber_lots_of_regs ();
+  open (fname, O_CREAT, 0400);
+
+  rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old);
+  if (rc)
+    {
+      error (0, rc, "pthread_setcanceltype after 2nd open failed");
+      ret = 1;
+    }
+  if (old != PTHREAD_CANCEL_ASYNCHRONOUS)
+    {
+      error (0, 0, "pthread_setcanceltype after 2nd open returned invalid value %d",
+	     old);
+      ret = 1;
+    }
+
+  *enddir = '\0';
+  rmdir (fname);
+
+  clobber_lots_of_regs ();
+  select (-1, NULL, NULL, NULL, NULL);
+
+  rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old);
+  if (rc)
+    {
+      error (0, rc, "pthread_setcanceltype after select failed");
+      ret = 1;
+    }
+  if (old != PTHREAD_CANCEL_DEFERRED)
+    {
+      error (0, 0, "pthread_setcanceltype after select returned invalid value %d",
+	     old);
+      ret = 1;
+    }
+
+  clobber_lots_of_regs ();
+  select (-1, NULL, NULL, NULL, NULL);
+
+  rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old);
+  if (rc)
+    {
+      error (0, rc, "pthread_setcanceltype after 2nd select failed");
+      ret = 1;
+    }
+  if (old != PTHREAD_CANCEL_ASYNCHRONOUS)
+    {
+      error (0, 0, "pthread_setcanceltype after 2nd select returned invalid value %d",
+	     old);
+      ret = 1;
+    }
+
+  pthread_join (th, NULL);
+
+  return ret;
+}
+
+#define TIMEOUT 20
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancel2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancel2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancel2.c	(revision 2036)
@@ -0,0 +1,100 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+static int fd[2];
+
+
+static void *
+tf (void *arg)
+{
+  /* The buffer size must be larger than the pipe size so that the
+     write blocks.  */
+  char buf[100000];
+
+  if (write (fd[1], buf, sizeof (buf)) == sizeof (buf))
+    {
+      puts ("write succeeded");
+      return (void *) 1l;
+    }
+
+  return (void *) 42l;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t th;
+  void *r;
+  struct sigaction sa;
+
+  sa.sa_handler = SIG_IGN;
+  sigemptyset (&sa.sa_mask);
+  sa.sa_flags = 0;
+
+  if (sigaction (SIGPIPE, &sa, NULL) != 0)
+    {
+      puts ("sigaction failed");
+      return 1;
+    }
+
+  if (pipe (fd) != 0)
+    {
+      puts ("pipe failed");
+      return 1;
+    }
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      return 1;
+    }
+
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("cancel failed");
+      return 1;
+    }
+
+  /* This will cause the write in the child to return.  */
+  close (fd[0]);
+
+  if (pthread_join (th, &r) != 0)
+    {
+      puts ("join failed");
+      return 1;
+    }
+
+  if (r != PTHREAD_CANCELED)
+    {
+      printf ("result is wrong: expected %p, got %p\n", PTHREAD_CANCELED, r);
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancel20.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancel20.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancel20.c	(revision 2036)
@@ -0,0 +1,264 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static int fd[4];
+static pthread_barrier_t b;
+volatile int in_sh_body;
+unsigned long cleanups;
+
+static void
+cl (void *arg)
+{
+  cleanups = (cleanups << 4) | (long) arg;
+}
+
+
+static void __attribute__((noinline))
+sh_body (void)
+{
+  char c;
+
+  pthread_cleanup_push (cl, (void *) 1L);
+
+  in_sh_body = 1;
+  if (read (fd[2], &c, 1) == 1)
+    {
+      puts ("read succeeded");
+      exit (1);
+    }
+
+  pthread_cleanup_pop (0);
+}
+
+
+static void
+sh (int sig)
+{
+  pthread_cleanup_push (cl, (void *) 2L);
+  sh_body ();
+  in_sh_body = 0;
+
+  pthread_cleanup_pop (0);
+}
+
+
+static void __attribute__((noinline))
+tf_body (void)
+{
+  char c;
+
+  pthread_cleanup_push (cl, (void *) 3L);
+
+  int r = pthread_barrier_wait (&b);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("child thread: barrier_wait failed");
+      exit (1);
+    }
+
+  if (read (fd[0], &c, 1) == 1)
+    {
+      puts ("read succeeded");
+      exit (1);
+    }
+
+  read (fd[0], &c, 1);
+
+  pthread_cleanup_pop (0);
+}
+
+
+static void *
+tf (void *arg)
+{
+  pthread_cleanup_push (cl, (void *) 4L);
+  tf_body ();
+  pthread_cleanup_pop (0);
+  return NULL;
+}
+
+
+static int
+do_one_test (void)
+{
+  in_sh_body = 0;
+  cleanups = 0;
+  if (pipe (fd) != 0 || pipe (fd + 2) != 0)
+    {
+      puts ("pipe failed");
+      return 1;
+    }
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      return 1;
+    }
+
+  int r = pthread_barrier_wait (&b);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("parent thread: barrier_wait failed");
+      return 1;
+    }
+
+  sleep (1);
+
+  r = pthread_kill (th, SIGHUP);
+  if (r)
+    {
+      errno = r;
+      printf ("pthread_kill failed %m\n");
+      return 1;
+    }
+
+  while (in_sh_body == 0)
+    sleep (1);
+
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("cancel failed");
+      return 1;
+    }
+
+  /* This will cause the read in the child to return.  */
+  close (fd[0]);
+  close (fd[1]);
+  close (fd[2]);
+  close (fd[3]);
+
+  void *ret;
+  if (pthread_join (th, &ret) != 0)
+    {
+      puts ("join failed");
+      return 1;
+    }
+
+  if (ret != PTHREAD_CANCELED)
+    {
+      puts ("result is wrong");
+      return 1;
+    }
+
+  if (cleanups != 0x1234L)
+    {
+      printf ("called cleanups %lx\n", cleanups);
+      return 1;
+    }
+
+  return 0;
+}
+
+
+static int
+do_test (void)
+{
+  stack_t ss;
+  ss.ss_sp = malloc (2 * SIGSTKSZ);
+  if (ss.ss_sp == NULL)
+    {
+      puts ("failed to allocate alternate stack");
+      return 1;
+    }
+  ss.ss_flags = 0;
+  ss.ss_size = 2 * SIGSTKSZ;
+  if (sigaltstack (&ss, NULL) < 0)
+    {
+      printf ("sigaltstack failed %m\n");
+      return 1;
+    }
+
+  if (pthread_barrier_init (&b, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      return 1;
+    }
+
+  struct sigaction sa;
+  sa.sa_handler = sh;
+  sigemptyset (&sa.sa_mask);
+  sa.sa_flags = 0;
+
+  if (sigaction (SIGHUP, &sa, NULL) != 0)
+    {
+      puts ("sigaction failed");
+      return 1;
+    }
+
+  puts ("sa_flags = 0 test");
+  if (do_one_test ())
+    return 1;
+
+  sa.sa_handler = sh;
+  sigemptyset (&sa.sa_mask);
+  sa.sa_flags = SA_ONSTACK;
+
+  if (sigaction (SIGHUP, &sa, NULL) != 0)
+    {
+      puts ("sigaction failed");
+      return 1;
+    }
+
+  puts ("sa_flags = SA_ONSTACK test");
+  if (do_one_test ())
+    return 1;
+
+  sa.sa_sigaction = (void (*)(int, siginfo_t *, void *)) sh;
+  sigemptyset (&sa.sa_mask);
+  sa.sa_flags = SA_SIGINFO;
+
+  if (sigaction (SIGHUP, &sa, NULL) != 0)
+    {
+      puts ("sigaction failed");
+      return 1;
+    }
+
+  puts ("sa_flags = SA_SIGINFO test");
+  if (do_one_test ())
+    return 1;
+
+  sa.sa_sigaction = (void (*)(int, siginfo_t *, void *)) sh;
+  sigemptyset (&sa.sa_mask);
+  sa.sa_flags = SA_SIGINFO | SA_ONSTACK;
+
+  if (sigaction (SIGHUP, &sa, NULL) != 0)
+    {
+      puts ("sigaction failed");
+      return 1;
+    }
+
+  puts ("sa_flags = SA_SIGINFO|SA_ONSTACK test");
+  if (do_one_test ())
+    return 1;
+
+  return 0;
+}
+
+#define TIMEOUT 40
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancel21.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancel21.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancel21.c	(revision 2036)
@@ -0,0 +1,294 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+
+static int fd[4];
+static pthread_barrier_t b;
+volatile int in_sh_body;
+unsigned long cleanups;
+
+static void
+cl (void *arg)
+{
+  cleanups = (cleanups << 4) | (long) arg;
+}
+
+
+static void __attribute__((noinline))
+sh_body (void)
+{
+  char c;
+
+  pthread_cleanup_push (cl, (void *) 1L);
+
+  in_sh_body = 1;
+  if (read (fd[2], &c, 1) == 1)
+    {
+      puts ("read succeeded");
+      exit (1);
+    }
+
+  pthread_cleanup_pop (0);
+}
+
+
+static void
+sh (int sig)
+{
+  pthread_cleanup_push (cl, (void *) 2L);
+  sh_body ();
+  in_sh_body = 0;
+
+  pthread_cleanup_pop (0);
+}
+
+
+static void __attribute__((noinline))
+tf_body (void)
+{
+  char c;
+
+  pthread_cleanup_push (cl, (void *) 3L);
+
+  int r = pthread_barrier_wait (&b);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("child thread: barrier_wait failed");
+      exit (1);
+    }
+
+  if (read (fd[0], &c, 1) == 1)
+    {
+      puts ("read succeeded");
+      exit (1);
+    }
+
+  read (fd[0], &c, 1);
+
+  pthread_cleanup_pop (0);
+}
+
+
+static void *
+tf (void *arg)
+{
+  pthread_t th = (pthread_t) arg;
+
+  int r = pthread_barrier_wait (&b);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("parent thread: barrier_wait failed");
+      exit (1);
+    }
+
+  sleep (1);
+
+  r = pthread_kill (th, SIGHUP);
+  if (r)
+    {
+      errno = r;
+      printf ("pthread_kill failed %m\n");
+      exit (1);
+    }
+
+  while (in_sh_body == 0)
+    sleep (1);
+
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("cancel failed");
+      exit (1);
+    }
+
+  /* This will cause the read in the initial thread to return.  */
+  close (fd[0]);
+  close (fd[1]);
+  close (fd[2]);
+  close (fd[3]);
+
+  void *ret;
+  if (pthread_join (th, &ret) != 0)
+    {
+      puts ("join failed");
+      exit (1);
+    }
+
+  if (ret != PTHREAD_CANCELED)
+    {
+      puts ("result is wrong");
+      exit (1);
+    }
+
+  if (cleanups != 0x1234L)
+    {
+      printf ("called cleanups %lx\n", cleanups);
+      exit (1);
+    }
+
+  if (pthread_barrier_destroy (&b))
+    {
+      puts ("barrier destroy failed");
+      exit (1);
+    }
+
+  exit (0);
+}
+
+
+static int
+do_one_test (void)
+{
+  in_sh_body = 0;
+
+  pid_t pid = fork ();
+
+  if (pid == -1)
+    {
+      printf ("fork failed: %m\n");
+      return 1;
+    }
+
+  if (pid)
+    {
+      int status;
+      if (waitpid (pid, &status, 0) < 0)
+	{
+	  printf ("waitpid failed %m\n");
+	  return 1;
+	}
+
+      return !WIFEXITED (status) || WEXITSTATUS (status);
+    }
+
+  if (pthread_barrier_init (&b, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  cleanups = 0;
+  if (pipe (fd) != 0 || pipe (fd + 2) != 0)
+    {
+      puts ("pipe failed");
+      exit (1);
+    }
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, (void *) pthread_self ()) != 0)
+    {
+      puts ("create failed");
+      exit (1);
+    }
+
+  pthread_cleanup_push (cl, (void *) 4L);
+  tf_body ();
+  pthread_cleanup_pop (0);
+  exit (1);
+}
+
+
+static int
+do_test (void)
+{
+  stack_t ss;
+  ss.ss_sp = malloc (2 * SIGSTKSZ);
+  if (ss.ss_sp == NULL)
+    {
+      puts ("failed to allocate alternate stack");
+      return 1;
+    }
+  ss.ss_flags = 0;
+  ss.ss_size = 2 * SIGSTKSZ;
+  if (sigaltstack (&ss, NULL) < 0)
+    {
+      printf ("sigaltstack failed %m\n");
+      return 1;
+    }
+
+  struct sigaction sa;
+  sa.sa_handler = sh;
+  sigemptyset (&sa.sa_mask);
+  sa.sa_flags = 0;
+
+  if (sigaction (SIGHUP, &sa, NULL) != 0)
+    {
+      puts ("sigaction failed");
+      return 1;
+    }
+
+  puts ("sa_flags = 0 test");
+  if (do_one_test ())
+    return 1;
+
+  sa.sa_handler = sh;
+  sigemptyset (&sa.sa_mask);
+  sa.sa_flags = SA_ONSTACK;
+
+  if (sigaction (SIGHUP, &sa, NULL) != 0)
+    {
+      puts ("sigaction failed");
+      return 1;
+    }
+
+  puts ("sa_flags = SA_ONSTACK test");
+  if (do_one_test ())
+    return 1;
+
+  sa.sa_sigaction = (void (*)(int, siginfo_t *, void *)) sh;
+  sigemptyset (&sa.sa_mask);
+  sa.sa_flags = SA_SIGINFO;
+
+  if (sigaction (SIGHUP, &sa, NULL) != 0)
+    {
+      puts ("sigaction failed");
+      return 1;
+    }
+
+  puts ("sa_flags = SA_SIGINFO test");
+  if (do_one_test ())
+    return 1;
+
+  sa.sa_sigaction = (void (*)(int, siginfo_t *, void *)) sh;
+  sigemptyset (&sa.sa_mask);
+  sa.sa_flags = SA_SIGINFO | SA_ONSTACK;
+
+  if (sigaction (SIGHUP, &sa, NULL) != 0)
+    {
+      puts ("sigaction failed");
+      return 1;
+    }
+
+  puts ("sa_flags = SA_SIGINFO|SA_ONSTACK test");
+  if (do_one_test ())
+    return 1;
+
+  return 0;
+}
+
+#define TIMEOUT 40
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancel22.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancel22.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancel22.c	(revision 2036)
@@ -0,0 +1,121 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+pthread_barrier_t b;
+int seen;
+
+static void *
+tf (void *arg)
+{
+  int old;
+  int r = pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &old);
+  if (r != 0)
+    {
+      puts ("setcancelstate failed");
+      exit (1);
+    }
+
+  r = pthread_barrier_wait (&b);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      exit (1);
+    }
+
+  for (int i = 0; i < 10; ++i)
+    {
+      struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 };
+      TEMP_FAILURE_RETRY (nanosleep (&ts, &ts));
+    }
+
+  seen = 1;
+  pthread_setcancelstate (old, NULL);
+
+  struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 };
+  TEMP_FAILURE_RETRY (nanosleep (&ts, &ts));
+
+  exit (1);
+}
+
+
+static int
+do_test (void)
+{
+  if (pthread_barrier_init (&b, NULL, 2) != 0)
+   {
+     puts ("barrier init failed");
+     return 1;
+   }
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("thread creation failed");
+      return 1;
+    }
+
+  int r = pthread_barrier_wait (&b);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      return 1;
+    }
+
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("cancel failed");
+      return 1;
+    }
+
+  void *status;
+  if (pthread_join (th, &status) != 0)
+    {
+      puts ("join failed");
+      return 1;
+    }
+  if (status != PTHREAD_CANCELED)
+    {
+      puts ("thread not canceled");
+      return 1;
+    }
+
+  if (pthread_barrier_destroy (&b) != 0)
+    {
+      puts ("barrier_destroy failed");
+      return 1;
+    }
+
+  if (seen != 1)
+    {
+      puts ("thread cancelled when PTHREAD_CANCEL_DISABLED");
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TIMEOUT 5
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancel23.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancel23.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancel23.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cancel22.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancel3.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancel3.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancel3.c	(revision 2036)
@@ -0,0 +1,98 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+static int fd[2];
+
+
+static void *
+tf (void *arg)
+{
+  char buf[100];
+
+  if (read (fd[0], buf, sizeof (buf)) == sizeof (buf))
+    {
+      puts ("read succeeded");
+      return (void *) 1l;
+    }
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t th;
+  void *r;
+  struct sigaction sa;
+
+  sa.sa_handler = SIG_IGN;
+  sigemptyset (&sa.sa_mask);
+  sa.sa_flags = 0;
+
+  if (sigaction (SIGPIPE, &sa, NULL) != 0)
+    {
+      puts ("sigaction failed");
+      return 1;
+    }
+
+  if (pipe (fd) != 0)
+    {
+      puts ("pipe failed");
+      return 1;
+    }
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      return 1;
+    }
+
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("cancel failed");
+      return 1;
+    }
+
+  /* This will cause the read in the child to return.  */
+  close (fd[0]);
+
+  if (pthread_join (th, &r) != 0)
+    {
+      puts ("join failed");
+      return 1;
+    }
+
+  if (r != PTHREAD_CANCELED)
+    {
+      puts ("result is wrong");
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancel4.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancel4.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancel4.c	(revision 2036)
@@ -0,0 +1,2282 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* NOTE: this tests functionality beyond POSIX.  POSIX does not allow
+   exit to be called more than once.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <pthread.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <termios.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/msg.h>
+#include <sys/poll.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <sys/uio.h>
+#include <sys/un.h>
+#include <sys/wait.h>
+
+#include "pthreadP.h"
+
+
+/* Since STREAMS are not supported in the standard Linux kernel and
+   there we don't advertise STREAMS as supported is no need to test
+   the STREAMS related functions.  This affects
+     getmsg()              getpmsg()          putmsg()
+     putpmsg()
+
+   lockf() and fcntl() are tested in tst-cancel16.
+
+   pthread_join() is tested in tst-join5.
+
+   pthread_testcancel()'s only purpose is to allow cancellation.  This
+   is tested in several places.
+
+   sem_wait() and sem_timedwait() are checked in tst-cancel1[2345] tests.
+
+   mq_send(), mq_timedsend(), mq_receive() and mq_timedreceive() are checked
+   in tst-mqueue8{,x} tests.
+
+   aio_suspend() is tested in tst-cancel17.
+
+   clock_nanosleep() is tested in tst-cancel18.
+*/
+
+/* Pipe descriptors.  */
+static int fds[2];
+
+/* Temporary file descriptor, to be closed after each round.  */
+static int tempfd = -1;
+static int tempfd2 = -1;
+/* Name of temporary file to be removed after each round.  */
+static char *tempfname;
+/* Temporary message queue.  */
+static int tempmsg = -1;
+
+/* Often used barrier for two threads.  */
+static pthread_barrier_t b2;
+
+
+#ifndef IPC_ADDVAL
+# define IPC_ADDVAL 0
+#endif
+
+#define WRITE_BUFFER_SIZE 4096
+
+/* Cleanup handling test.  */
+static int cl_called;
+
+static void
+cl (void *arg)
+{
+  ++cl_called;
+}
+
+
+
+static void *
+tf_read  (void *arg)
+{
+  int fd;
+  int r;
+
+  if (arg == NULL)
+    fd = fds[0];
+  else
+    {
+      char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
+      tempfd = fd = mkstemp (fname);
+      if (fd == -1)
+	printf ("%s: mkstemp failed\n", __FUNCTION__);
+      unlink (fname);
+
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  ssize_t s;
+  pthread_cleanup_push (cl, NULL);
+
+  char buf[100];
+  s = read (fd, buf, sizeof (buf));
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: read returns with %zd\n", __FUNCTION__, s);
+
+  exit (1);
+}
+
+
+static void *
+tf_readv  (void *arg)
+{
+  int fd;
+  int r;
+
+  if (arg == NULL)
+    fd = fds[0];
+  else
+    {
+      char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
+      tempfd = fd = mkstemp (fname);
+      if (fd == -1)
+	printf ("%s: mkstemp failed\n", __FUNCTION__);
+      unlink (fname);
+
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  ssize_t s;
+  pthread_cleanup_push (cl, NULL);
+
+  char buf[100];
+  struct iovec iov[1] = { [0] = { .iov_base = buf, .iov_len = sizeof (buf) } };
+  s = readv (fd, iov, 1);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: readv returns with %zd\n", __FUNCTION__, s);
+
+  exit (1);
+}
+
+
+static void *
+tf_write  (void *arg)
+{
+  int fd;
+  int r;
+
+  if (arg == NULL)
+    fd = fds[1];
+  else
+    {
+      char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
+      tempfd = fd = mkstemp (fname);
+      if (fd == -1)
+	printf ("%s: mkstemp failed\n", __FUNCTION__);
+      unlink (fname);
+
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  ssize_t s;
+  pthread_cleanup_push (cl, NULL);
+
+  char buf[WRITE_BUFFER_SIZE];
+  memset (buf, '\0', sizeof (buf));
+  s = write (fd, buf, sizeof (buf));
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: write returns with %zd\n", __FUNCTION__, s);
+
+  exit (1);
+}
+
+
+static void *
+tf_writev  (void *arg)
+{
+  int fd;
+  int r;
+
+  if (arg == NULL)
+    fd = fds[1];
+  else
+    {
+      char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
+      tempfd = fd = mkstemp (fname);
+      if (fd == -1)
+	printf ("%s: mkstemp failed\n", __FUNCTION__);
+      unlink (fname);
+
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  ssize_t s;
+  pthread_cleanup_push (cl, NULL);
+
+  char buf[WRITE_BUFFER_SIZE];
+  memset (buf, '\0', sizeof (buf));
+  struct iovec iov[1] = { [0] = { .iov_base = buf, .iov_len = sizeof (buf) } };
+  s = writev (fd, iov, 1);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: writev returns with %zd\n", __FUNCTION__, s);
+
+  exit (1);
+}
+
+
+static void *
+tf_sleep (void *arg)
+{
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  if (arg != NULL)
+    {
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  sleep (arg == NULL ? 1000000 : 0);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: sleep returns\n", __FUNCTION__);
+
+  exit (1);
+}
+
+
+static void *
+tf_usleep (void *arg)
+{
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  if (arg != NULL)
+    {
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  usleep (arg == NULL ? (useconds_t) ULONG_MAX : 0);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: usleep returns\n", __FUNCTION__);
+
+  exit (1);
+}
+
+
+static void *
+tf_nanosleep (void *arg)
+{
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  if (arg != NULL)
+    {
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  struct timespec ts = { .tv_sec = arg == NULL ? 10000000 : 0, .tv_nsec = 0 };
+  TEMP_FAILURE_RETRY (nanosleep (&ts, &ts));
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: nanosleep returns\n", __FUNCTION__);
+
+  exit (1);
+}
+
+
+static void *
+tf_select (void *arg)
+{
+  int fd;
+  int r;
+
+  if (arg == NULL)
+    fd = fds[0];
+  else
+    {
+      char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
+      tempfd = fd = mkstemp (fname);
+      if (fd == -1)
+	printf ("%s: mkstemp failed\n", __FUNCTION__);
+      unlink (fname);
+
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  fd_set rfs;
+  FD_ZERO (&rfs);
+  FD_SET (fd, &rfs);
+
+  int s;
+  pthread_cleanup_push (cl, NULL);
+
+  s = select (fd + 1, &rfs, NULL, NULL, NULL);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: select returns with %d (%s)\n", __FUNCTION__, s,
+	  strerror (errno));
+
+  exit (1);
+}
+
+
+static void *
+tf_pselect (void *arg)
+{
+  int fd;
+  int r;
+
+  if (arg == NULL)
+    fd = fds[0];
+  else
+    {
+      char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
+      tempfd = fd = mkstemp (fname);
+      if (fd == -1)
+	printf ("%s: mkstemp failed\n", __FUNCTION__);
+      unlink (fname);
+
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  fd_set rfs;
+  FD_ZERO (&rfs);
+  FD_SET (fd, &rfs);
+
+  int s;
+  pthread_cleanup_push (cl, NULL);
+
+  s = pselect (fd + 1, &rfs, NULL, NULL, NULL, NULL);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: pselect returns with %d (%s)\n", __FUNCTION__, s,
+	  strerror (errno));
+
+  exit (1);
+}
+
+
+static void *
+tf_poll (void *arg)
+{
+  int fd;
+  int r;
+
+  if (arg == NULL)
+    fd = fds[0];
+  else
+    {
+      char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
+      tempfd = fd = mkstemp (fname);
+      if (fd == -1)
+	printf ("%s: mkstemp failed\n", __FUNCTION__);
+      unlink (fname);
+
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  struct pollfd rfs[1] = { [0] = { .fd = fd, .events = POLLIN } };
+
+  int s;
+  pthread_cleanup_push (cl, NULL);
+
+  s = poll (rfs, 1, -1);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: poll returns with %d (%s)\n", __FUNCTION__, s,
+	  strerror (errno));
+
+  exit (1);
+}
+
+
+static void *
+tf_wait (void *arg)
+{
+  pid_t pid = fork ();
+  if (pid == -1)
+    {
+      puts ("fork failed");
+      exit (1);
+    }
+
+  if (pid == 0)
+    {
+      /* Make the program disappear after a while.  */
+      if (arg == NULL)
+	sleep (10);
+      exit (0);
+    }
+
+  int r;
+  if (arg != NULL)
+    {
+      struct timespec  ts = { .tv_sec = 0, .tv_nsec = 100000000 };
+      while (nanosleep (&ts, &ts) != 0)
+	continue;
+
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  int s;
+  pthread_cleanup_push (cl, NULL);
+
+  s = wait (NULL);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: wait returns with %d (%s)\n", __FUNCTION__, s,
+	  strerror (errno));
+
+  exit (1);
+}
+
+
+static void *
+tf_waitpid (void *arg)
+{
+
+  pid_t pid = fork ();
+  if (pid == -1)
+    {
+      puts ("fork failed");
+      exit (1);
+    }
+
+  if (pid == 0)
+    {
+      /* Make the program disappear after a while.  */
+      if (arg == NULL)
+	sleep (10);
+      exit (0);
+    }
+
+  int r;
+  if (arg != NULL)
+    {
+      struct timespec  ts = { .tv_sec = 0, .tv_nsec = 100000000 };
+      while (nanosleep (&ts, &ts) != 0)
+	continue;
+
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  int s;
+ pthread_cleanup_push (cl, NULL);
+
+  s = waitpid (-1, NULL, 0);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: waitpid returns with %d (%s)\n", __FUNCTION__, s,
+	  strerror (errno));
+
+  exit (1);
+}
+
+
+static void *
+tf_waitid (void *arg)
+{
+  pid_t pid = fork ();
+  if (pid == -1)
+    {
+      puts ("fork failed");
+      exit (1);
+    }
+
+  if (pid == 0)
+    {
+      /* Make the program disappear after a while.  */
+      if (arg == NULL)
+	sleep (10);
+      exit (0);
+    }
+
+  int r;
+  if (arg != NULL)
+    {
+      struct timespec  ts = { .tv_sec = 0, .tv_nsec = 100000000 };
+      while (nanosleep (&ts, &ts) != 0)
+	continue;
+
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  int s;
+  pthread_cleanup_push (cl, NULL);
+
+#ifndef WEXITED
+# define WEXITED 0
+#endif
+  siginfo_t si;
+  s = waitid (P_PID, pid, &si, WEXITED);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: waitid returns with %d (%s)\n", __FUNCTION__, s,
+	  strerror (errno));
+
+  exit (1);
+}
+
+
+static void *
+tf_sigpause (void *arg)
+{
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  if (arg != NULL)
+    {
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  /* Just for fun block the cancellation signal.  We need to use
+     __xpg_sigpause since otherwise we will get the BSD version.  */
+  __xpg_sigpause (SIGCANCEL);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: sigpause returned\n", __FUNCTION__);
+
+  exit (1);
+}
+
+
+static void *
+tf_sigsuspend (void *arg)
+{
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  if (arg != NULL)
+    {
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  /* Just for fun block all signals.  */
+  sigset_t mask;
+  sigfillset (&mask);
+  sigsuspend (&mask);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: sigsuspend returned\n", __FUNCTION__);
+
+  exit (1);
+}
+
+
+static void *
+tf_sigwait (void *arg)
+{
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  if (arg != NULL)
+    {
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  /* Block SIGUSR1.  */
+  sigset_t mask;
+  sigemptyset (&mask);
+  sigaddset (&mask, SIGUSR1);
+  if (pthread_sigmask (SIG_BLOCK, &mask, NULL) != 0)
+    {
+      printf ("%s: pthread_sigmask failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  int sig;
+  pthread_cleanup_push (cl, NULL);
+
+  /* Wait for SIGUSR1.  */
+  sigwait (&mask, &sig);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: sigwait returned with signal %d\n", __FUNCTION__, sig);
+
+  exit (1);
+}
+
+
+static void *
+tf_sigwaitinfo (void *arg)
+{
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  if (arg != NULL)
+    {
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  /* Block SIGUSR1.  */
+  sigset_t mask;
+  sigemptyset (&mask);
+  sigaddset (&mask, SIGUSR1);
+  if (pthread_sigmask (SIG_BLOCK, &mask, NULL) != 0)
+    {
+      printf ("%s: pthread_sigmask failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  siginfo_t info;
+  pthread_cleanup_push (cl, NULL);
+
+  /* Wait for SIGUSR1.  */
+  sigwaitinfo (&mask, &info);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: sigwaitinfo returned with signal %d\n", __FUNCTION__,
+	  info.si_signo);
+
+  exit (1);
+}
+
+
+static void *
+tf_sigtimedwait (void *arg)
+{
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  if (arg != NULL)
+    {
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  /* Block SIGUSR1.  */
+  sigset_t mask;
+  sigemptyset (&mask);
+  sigaddset (&mask, SIGUSR1);
+  if (pthread_sigmask (SIG_BLOCK, &mask, NULL) != 0)
+    {
+      printf ("%s: pthread_sigmask failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  /* Wait for SIGUSR1.  */
+  siginfo_t info;
+  struct timespec ts = { .tv_sec = 60, .tv_nsec = 0 };
+  pthread_cleanup_push (cl, NULL);
+
+  sigtimedwait (&mask, &info, &ts);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: sigtimedwait returned with signal %d\n", __FUNCTION__,
+	  info.si_signo);
+
+  exit (1);
+}
+
+
+static void *
+tf_pause (void *arg)
+{
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  if (arg != NULL)
+    {
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  pause ();
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: pause returned\n", __FUNCTION__);
+
+  exit (1);
+}
+
+
+static void *
+tf_accept (void *arg)
+{
+  struct sockaddr_un sun;
+  /* To test a non-blocking accept call we make the call file by using
+     a datagrame socket.  */
+  int pf = arg == NULL ? SOCK_STREAM : SOCK_DGRAM;
+
+  tempfd = socket (AF_UNIX, pf, 0);
+  if (tempfd == -1)
+    {
+      printf ("%s: socket call failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  int tries = 0;
+  do
+    {
+      if (++tries > 10)
+	{
+	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
+	}
+
+      strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-1-XXXXXX");
+      if (mktemp (sun.sun_path) == NULL)
+	{
+	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
+	  exit (1);
+	}
+
+      sun.sun_family = AF_UNIX;
+    }
+  while (bind (tempfd, (struct sockaddr *) &sun,
+	       offsetof (struct sockaddr_un, sun_path)
+	       + strlen (sun.sun_path) + 1) != 0);
+
+  unlink (sun.sun_path);
+
+  listen (tempfd, 5);
+
+  socklen_t len = sizeof (sun);
+
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  if (arg != NULL)
+    {
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  accept (tempfd, (struct sockaddr *) &sun, &len);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: accept returned\n", __FUNCTION__);
+
+  exit (1);
+}
+
+
+static void *
+tf_send (void *arg)
+{
+  struct sockaddr_un sun;
+
+  tempfd = socket (AF_UNIX, SOCK_STREAM, 0);
+  if (tempfd == -1)
+    {
+      printf ("%s: first socket call failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  int tries = 0;
+  do
+    {
+      if (++tries > 10)
+	{
+	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
+	}
+
+      strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-2-XXXXXX");
+      if (mktemp (sun.sun_path) == NULL)
+	{
+	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
+	  exit (1);
+	}
+
+      sun.sun_family = AF_UNIX;
+    }
+  while (bind (tempfd, (struct sockaddr *) &sun,
+	       offsetof (struct sockaddr_un, sun_path)
+	       + strlen (sun.sun_path) + 1) != 0);
+
+  listen (tempfd, 5);
+
+  tempfd2 = socket (AF_UNIX, SOCK_STREAM, 0);
+  if (tempfd2 == -1)
+    {
+      printf ("%s: second socket call failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  if (connect (tempfd2, (struct sockaddr *) &sun, sizeof (sun)) != 0)
+    {
+      printf ("%s: connect failed\n", __FUNCTION__);
+      exit(1);
+    }
+
+  unlink (sun.sun_path);
+
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  if (arg != NULL)
+    {
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  /* Very large block, so that the send call blocks.  */
+  char mem[700000];
+
+  send (tempfd2, mem, arg == NULL ? sizeof (mem) : 1, 0);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: send returned\n", __FUNCTION__);
+
+  exit (1);
+}
+
+
+static void *
+tf_recv (void *arg)
+{
+  struct sockaddr_un sun;
+
+  tempfd = socket (AF_UNIX, SOCK_STREAM, 0);
+  if (tempfd == -1)
+    {
+      printf ("%s: first socket call failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  int tries = 0;
+  do
+    {
+      if (++tries > 10)
+	{
+	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
+	}
+
+      strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-3-XXXXXX");
+      if (mktemp (sun.sun_path) == NULL)
+	{
+	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
+	  exit (1);
+	}
+
+      sun.sun_family = AF_UNIX;
+    }
+  while (bind (tempfd, (struct sockaddr *) &sun,
+	       offsetof (struct sockaddr_un, sun_path)
+	       + strlen (sun.sun_path) + 1) != 0);
+
+  listen (tempfd, 5);
+
+  tempfd2 = socket (AF_UNIX, SOCK_STREAM, 0);
+  if (tempfd2 == -1)
+    {
+      printf ("%s: second socket call failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  if (connect (tempfd2, (struct sockaddr *) &sun, sizeof (sun)) != 0)
+    {
+      printf ("%s: connect failed\n", __FUNCTION__);
+      exit(1);
+    }
+
+  unlink (sun.sun_path);
+
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  if (arg != NULL)
+    {
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  char mem[70];
+
+  recv (tempfd2, mem, arg == NULL ? sizeof (mem) : 0, 0);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: recv returned\n", __FUNCTION__);
+
+  exit (1);
+}
+
+
+static void *
+tf_recvfrom (void *arg)
+{
+  struct sockaddr_un sun;
+
+  tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
+  if (tempfd == -1)
+    {
+      printf ("%s: first socket call failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  int tries = 0;
+  do
+    {
+      if (++tries > 10)
+	{
+	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
+	}
+
+      strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-4-XXXXXX");
+      if (mktemp (sun.sun_path) == NULL)
+	{
+	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
+	  exit (1);
+	}
+
+      sun.sun_family = AF_UNIX;
+    }
+  while (bind (tempfd, (struct sockaddr *) &sun,
+	       offsetof (struct sockaddr_un, sun_path)
+	       + strlen (sun.sun_path) + 1) != 0);
+
+  tempfname = strdup (sun.sun_path);
+
+  tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0);
+  if (tempfd2 == -1)
+    {
+      printf ("%s: second socket call failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  if (arg != NULL)
+    {
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  char mem[70];
+  socklen_t len = sizeof (sun);
+
+  recvfrom (tempfd2, mem, arg == NULL ? sizeof (mem) : 0, 0,
+	    (struct sockaddr *) &sun, &len);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: recvfrom returned\n", __FUNCTION__);
+
+  exit (1);
+}
+
+
+static void *
+tf_recvmsg (void *arg)
+{
+  struct sockaddr_un sun;
+
+  tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
+  if (tempfd == -1)
+    {
+      printf ("%s: first socket call failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  int tries = 0;
+  do
+    {
+      if (++tries > 10)
+	{
+	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
+	}
+
+      strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-5-XXXXXX");
+      if (mktemp (sun.sun_path) == NULL)
+	{
+	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
+	  exit (1);
+	}
+
+      sun.sun_family = AF_UNIX;
+    }
+  while (bind (tempfd, (struct sockaddr *) &sun,
+	       offsetof (struct sockaddr_un, sun_path)
+	       + strlen (sun.sun_path) + 1) != 0);
+
+  tempfname = strdup (sun.sun_path);
+
+  tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0);
+  if (tempfd2 == -1)
+    {
+      printf ("%s: second socket call failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  if (arg != NULL)
+    {
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  char mem[70];
+  struct iovec iov[1];
+  iov[0].iov_base = mem;
+  iov[0].iov_len = arg == NULL ? sizeof (mem) : 0;
+
+  struct msghdr m;
+  m.msg_name = &sun;
+  m.msg_namelen = sizeof (sun);
+  m.msg_iov = iov;
+  m.msg_iovlen = 1;
+  m.msg_control = NULL;
+  m.msg_controllen = 0;
+
+  recvmsg (tempfd2, &m, 0);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: recvmsg returned\n", __FUNCTION__);
+
+  exit (1);
+}
+
+
+static void *
+tf_open (void *arg)
+{
+  if (arg == NULL)
+    // XXX If somebody can provide a portable test case in which open()
+    // blocks we can enable this test to run in both rounds.
+    abort ();
+
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  open ("Makefile", O_RDONLY);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: open returned\n", __FUNCTION__);
+
+  exit (1);
+}
+
+
+static void *
+tf_close (void *arg)
+{
+  if (arg == NULL)
+    // XXX If somebody can provide a portable test case in which close()
+    // blocks we can enable this test to run in both rounds.
+    abort ();
+
+  char fname[] = "/tmp/tst-cancel-fd-XXXXXX";
+  tempfd = mkstemp (fname);
+  if (tempfd == -1)
+    {
+      printf ("%s: mkstemp failed\n", __FUNCTION__);
+      exit (1);
+    }
+  unlink (fname);
+
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  close (tempfd);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: close returned\n", __FUNCTION__);
+
+  exit (1);
+}
+
+
+static void *
+tf_pread (void *arg)
+{
+  if (arg == NULL)
+    // XXX If somebody can provide a portable test case in which pread()
+    // blocks we can enable this test to run in both rounds.
+    abort ();
+
+  tempfd = open ("Makefile", O_RDONLY);
+  if (tempfd == -1)
+    {
+      printf ("%s: cannot open Makefile\n", __FUNCTION__);
+      exit (1);
+    }
+
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  char mem[10];
+  pread (tempfd, mem, sizeof (mem), 0);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: pread returned\n", __FUNCTION__);
+
+  exit (1);
+}
+
+
+static void *
+tf_pwrite (void *arg)
+{
+  if (arg == NULL)
+    // XXX If somebody can provide a portable test case in which pwrite()
+    // blocks we can enable this test to run in both rounds.
+    abort ();
+
+  char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
+  tempfd = mkstemp (fname);
+  if (tempfd == -1)
+    {
+      printf ("%s: mkstemp failed\n", __FUNCTION__);
+      exit (1);
+    }
+  unlink (fname);
+
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  char mem[10];
+  pwrite (tempfd, mem, sizeof (mem), 0);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: pwrite returned\n", __FUNCTION__);
+
+  exit (1);
+}
+
+
+static void *
+tf_fsync (void *arg)
+{
+  if (arg == NULL)
+    // XXX If somebody can provide a portable test case in which fsync()
+    // blocks we can enable this test to run in both rounds.
+    abort ();
+
+  tempfd = open ("Makefile", O_RDONLY);
+  if (tempfd == -1)
+    {
+      printf ("%s: cannot open Makefile\n", __FUNCTION__);
+      exit (1);
+    }
+
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  fsync (tempfd);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: fsync returned\n", __FUNCTION__);
+
+  exit (1);
+}
+
+
+static void *
+tf_msync (void *arg)
+{
+  if (arg == NULL)
+    // XXX If somebody can provide a portable test case in which msync()
+    // blocks we can enable this test to run in both rounds.
+    abort ();
+
+  tempfd = open ("Makefile", O_RDONLY);
+  if (tempfd == -1)
+    {
+      printf ("%s: cannot open Makefile\n", __FUNCTION__);
+      exit (1);
+    }
+  void *p = mmap (NULL, 10, PROT_READ, MAP_SHARED, tempfd, 0);
+  if (p == MAP_FAILED)
+    {
+      printf ("%s: mmap failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  msync (p, 10, 0);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: msync returned\n", __FUNCTION__);
+
+  exit (1);
+}
+
+
+static void *
+tf_sendto (void *arg)
+{
+  if (arg == NULL)
+    // XXX If somebody can provide a portable test case in which sendto()
+    // blocks we can enable this test to run in both rounds.
+    abort ();
+
+  struct sockaddr_un sun;
+
+  tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
+  if (tempfd == -1)
+    {
+      printf ("%s: first socket call failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  int tries = 0;
+  do
+    {
+      if (++tries > 10)
+	{
+	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
+	}
+
+      strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-6-XXXXXX");
+      if (mktemp (sun.sun_path) == NULL)
+	{
+	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
+	  exit (1);
+	}
+
+      sun.sun_family = AF_UNIX;
+    }
+  while (bind (tempfd, (struct sockaddr *) &sun,
+	       offsetof (struct sockaddr_un, sun_path)
+	       + strlen (sun.sun_path) + 1) != 0);
+  tempfname = strdup (sun.sun_path);
+
+  tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0);
+  if (tempfd2 == -1)
+    {
+      printf ("%s: second socket call failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  char mem[1];
+
+  sendto (tempfd2, mem, arg == NULL ? sizeof (mem) : 1, 0,
+	  (struct sockaddr *) &sun,
+	  offsetof (struct sockaddr_un, sun_path) + strlen (sun.sun_path) + 1);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: sendto returned\n", __FUNCTION__);
+
+  exit (1);
+}
+
+
+static void *
+tf_sendmsg (void *arg)
+{
+  if (arg == NULL)
+    // XXX If somebody can provide a portable test case in which sendmsg()
+    // blocks we can enable this test to run in both rounds.
+    abort ();
+
+  struct sockaddr_un sun;
+
+  tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
+  if (tempfd == -1)
+    {
+      printf ("%s: first socket call failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  int tries = 0;
+  do
+    {
+      if (++tries > 10)
+	{
+	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
+	}
+
+      strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-7-XXXXXX");
+      if (mktemp (sun.sun_path) == NULL)
+	{
+	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
+	  exit (1);
+	}
+
+      sun.sun_family = AF_UNIX;
+    }
+  while (bind (tempfd, (struct sockaddr *) &sun,
+	       offsetof (struct sockaddr_un, sun_path)
+	       + strlen (sun.sun_path) + 1) != 0);
+  tempfname = strdup (sun.sun_path);
+
+  tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0);
+  if (tempfd2 == -1)
+    {
+      printf ("%s: second socket call failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  char mem[1];
+  struct iovec iov[1];
+  iov[0].iov_base = mem;
+  iov[0].iov_len = 1;
+
+  struct msghdr m;
+  m.msg_name = &sun;
+  m.msg_namelen = (offsetof (struct sockaddr_un, sun_path)
+		   + strlen (sun.sun_path) + 1);
+  m.msg_iov = iov;
+  m.msg_iovlen = 1;
+  m.msg_control = NULL;
+  m.msg_controllen = 0;
+
+  sendmsg (tempfd2, &m, 0);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: sendmsg returned\n", __FUNCTION__);
+
+  exit (1);
+}
+
+
+static void *
+tf_creat (void *arg)
+{
+  if (arg == NULL)
+    // XXX If somebody can provide a portable test case in which sendmsg()
+    // blocks we can enable this test to run in both rounds.
+    abort ();
+
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  creat ("tmp/tst-cancel-4-should-not-exist", 0666);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: creat returned\n", __FUNCTION__);
+
+  exit (1);
+}
+
+
+static void *
+tf_connect (void *arg)
+{
+  if (arg == NULL)
+    // XXX If somebody can provide a portable test case in which connect()
+    // blocks we can enable this test to run in both rounds.
+    abort ();
+
+  struct sockaddr_un sun;
+
+  tempfd = socket (AF_UNIX, SOCK_STREAM, 0);
+  if (tempfd == -1)
+    {
+      printf ("%s: first socket call failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  int tries = 0;
+  do
+    {
+      if (++tries > 10)
+	{
+	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
+	}
+
+      strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-2-XXXXXX");
+      if (mktemp (sun.sun_path) == NULL)
+	{
+	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
+	  exit (1);
+	}
+
+      sun.sun_family = AF_UNIX;
+    }
+  while (bind (tempfd, (struct sockaddr *) &sun,
+	       offsetof (struct sockaddr_un, sun_path)
+	       + strlen (sun.sun_path) + 1) != 0);
+  tempfname = strdup (sun.sun_path);
+
+  listen (tempfd, 5);
+
+  tempfd2 = socket (AF_UNIX, SOCK_STREAM, 0);
+  if (tempfd2 == -1)
+    {
+      printf ("%s: second socket call failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  if (arg != NULL)
+    {
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  connect (tempfd2, (struct sockaddr *) &sun, sizeof (sun));
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: connect returned\n", __FUNCTION__);
+
+  exit (1);
+}
+
+
+static void *
+tf_tcdrain (void *arg)
+{
+  if (arg == NULL)
+    // XXX If somebody can provide a portable test case in which tcdrain()
+    // blocks we can enable this test to run in both rounds.
+    abort ();
+
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  if (arg != NULL)
+    {
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  /* Regardless of stderr being a terminal, the tcdrain call should be
+     canceled.  */
+  tcdrain (STDERR_FILENO);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: tcdrain returned\n", __FUNCTION__);
+
+  exit (1);
+}
+
+
+static void *
+tf_msgrcv (void *arg)
+{
+  tempmsg = msgget (IPC_PRIVATE, 0666 | IPC_CREAT);
+  if (tempmsg == -1)
+    {
+      printf ("%s: msgget failed: %s\n", __FUNCTION__, strerror (errno));
+      exit (1);
+    }
+
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  if (arg != NULL)
+    {
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+    }
+
+  ssize_t s;
+
+  pthread_cleanup_push (cl, NULL);
+
+  struct
+  {
+    long int type;
+    char mem[10];
+  } m;
+  int randnr;
+  /* We need a positive random number.  */
+  do
+    randnr = random () % 64000;
+  while (randnr <= 0);
+  do
+    {
+      errno = 0;
+      s = msgrcv (tempmsg, (struct msgbuf *) &m, 10, randnr, 0);
+    }
+  while (errno == EIDRM || errno == EINTR);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: msgrcv returned %zd with errno = %m\n", __FUNCTION__, s);
+
+  msgctl (tempmsg, IPC_RMID, NULL);
+
+  exit (1);
+}
+
+
+static void *
+tf_msgsnd (void *arg)
+{
+  if (arg == NULL)
+    // XXX If somebody can provide a portable test case in which msgsnd()
+    // blocks we can enable this test to run in both rounds.
+    abort ();
+
+  tempmsg = msgget (IPC_PRIVATE, 0666 | IPC_CREAT);
+  if (tempmsg == -1)
+    {
+      printf ("%s: msgget failed: %s\n", __FUNCTION__, strerror (errno));
+      exit (1);
+    }
+
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  struct
+  {
+    long int type;
+    char mem[1];
+  } m;
+  /* We need a positive random number.  */
+  do
+    m.type = random () % 64000;
+  while (m.type <= 0);
+  msgsnd (tempmsg, (struct msgbuf *) &m, sizeof (m.mem), 0);
+
+  pthread_cleanup_pop (0);
+
+  printf ("%s: msgsnd returned\n", __FUNCTION__);
+
+  msgctl (tempmsg, IPC_RMID, NULL);
+
+  exit (1);
+}
+
+
+static struct
+{
+  const char *name;
+  void *(*tf) (void *);
+  int nb;
+  int only_early;
+} tests[] =
+{
+#define ADD_TEST(name, nbar, early) { #name, tf_##name, nbar, early }
+  ADD_TEST (read, 2, 0),
+  ADD_TEST (readv, 2, 0),
+  ADD_TEST (select, 2, 0),
+  ADD_TEST (pselect, 2, 0),
+  ADD_TEST (poll, 2, 0),
+  ADD_TEST (write, 2, 0),
+  ADD_TEST (writev, 2, 0),
+  ADD_TEST (sleep, 2, 0),
+  ADD_TEST (usleep, 2, 0),
+  ADD_TEST (nanosleep, 2, 0),
+  ADD_TEST (wait, 2, 0),
+  ADD_TEST (waitid, 2, 0),
+  ADD_TEST (waitpid, 2, 0),
+  ADD_TEST (sigpause, 2, 0),
+  ADD_TEST (sigsuspend, 2, 0),
+  ADD_TEST (sigwait, 2, 0),
+  ADD_TEST (sigwaitinfo, 2, 0),
+  ADD_TEST (sigtimedwait, 2, 0),
+  ADD_TEST (pause, 2, 0),
+  ADD_TEST (accept, 2, 0),
+  ADD_TEST (send, 2, 0),
+  ADD_TEST (recv, 2, 0),
+  ADD_TEST (recvfrom, 2, 0),
+  ADD_TEST (recvmsg, 2, 0),
+  ADD_TEST (open, 2, 1),
+  ADD_TEST (close, 2, 1),
+  ADD_TEST (pread, 2, 1),
+  ADD_TEST (pwrite, 2, 1),
+  ADD_TEST (fsync, 2, 1),
+  ADD_TEST (msync, 2, 1),
+  ADD_TEST (sendto, 2, 1),
+  ADD_TEST (sendmsg, 2, 1),
+  ADD_TEST (creat, 2, 1),
+  ADD_TEST (connect, 2, 1),
+  ADD_TEST (tcdrain, 2, 1),
+  ADD_TEST (msgrcv, 2, 0),
+  ADD_TEST (msgsnd, 2, 1),
+};
+#define ntest_tf (sizeof (tests) / sizeof (tests[0]))
+
+
+static int
+do_test (void)
+{
+  int val;
+  socklen_t len;
+
+  if (socketpair (AF_UNIX, SOCK_STREAM, PF_UNIX, fds) != 0)
+    {
+      perror ("socketpair");
+      exit (1);
+    }
+
+  val = 1;
+  len = sizeof(val);
+  setsockopt (fds[1], SOL_SOCKET, SO_SNDBUF, &val, sizeof(val));
+  if (getsockopt (fds[1], SOL_SOCKET, SO_SNDBUF, &val, &len) < 0)
+    {
+      perror ("getsockopt");
+      exit (1);
+    }
+  if (val >= WRITE_BUFFER_SIZE)
+    {
+      puts ("minimum write buffer size too large");
+      exit (1);
+    }
+  setsockopt (fds[1], SOL_SOCKET, SO_SNDBUF, &val, sizeof(val));
+
+  int result = 0;
+  size_t cnt;
+  for (cnt = 0; cnt < ntest_tf; ++cnt)
+    {
+      if (tests[cnt].only_early)
+	continue;
+
+      if (pthread_barrier_init (&b2, NULL, tests[cnt].nb) != 0)
+	{
+	  puts ("b2 init failed");
+	  exit (1);
+	}
+
+      /* Reset the counter for the cleanup handler.  */
+      cl_called = 0;
+
+      pthread_t th;
+      if (pthread_create (&th, NULL, tests[cnt].tf, NULL) != 0)
+	{
+	  printf ("create for '%s' test failed\n", tests[cnt].name);
+	  result = 1;
+	  continue;
+	}
+
+      int r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
+	  result = 1;
+	  continue;
+	}
+
+      struct timespec  ts = { .tv_sec = 0, .tv_nsec = 100000000 };
+      while (nanosleep (&ts, &ts) != 0)
+	continue;
+
+      if (pthread_cancel (th) != 0)
+	{
+	  printf ("cancel for '%s' failed\n", tests[cnt].name);
+	  result = 1;
+	  continue;
+	}
+
+      void *status;
+      if (pthread_join (th, &status) != 0)
+	{
+	  printf ("join for '%s' failed\n", tests[cnt].name);
+	  result = 1;
+	  continue;
+	}
+      if (status != PTHREAD_CANCELED)
+	{
+	  printf ("thread for '%s' not canceled\n", tests[cnt].name);
+	  result = 1;
+	  continue;
+	}
+
+      if (pthread_barrier_destroy (&b2) != 0)
+	{
+	  puts ("barrier_destroy failed");
+	  result = 1;
+	  continue;
+	}
+
+      if (cl_called == 0)
+	{
+	  printf ("cleanup handler not called for '%s'\n", tests[cnt].name);
+	  result = 1;
+	  continue;
+	}
+      if (cl_called > 1)
+	{
+	  printf ("cleanup handler called more than once for '%s'\n",
+		  tests[cnt].name);
+	  result = 1;
+	  continue;
+	}
+
+      printf ("in-time cancel test of '%s' successful\n", tests[cnt].name);
+
+      if (tempfd != -1)
+	{
+	  close (tempfd);
+	  tempfd = -1;
+	}
+      if (tempfd2 != -1)
+	{
+	  close (tempfd2);
+	  tempfd2 = -1;
+	}
+      if (tempfname != NULL)
+	{
+	  unlink (tempfname);
+	  free (tempfname);
+	  tempfname = NULL;
+	}
+      if (tempmsg != -1)
+	{
+	  msgctl (tempmsg, IPC_RMID, NULL);
+	  tempmsg = -1;
+	}
+    }
+
+  for (cnt = 0; cnt < ntest_tf; ++cnt)
+    {
+      if (pthread_barrier_init (&b2, NULL, tests[cnt].nb) != 0)
+	{
+	  puts ("b2 init failed");
+	  exit (1);
+	}
+
+      /* Reset the counter for the cleanup handler.  */
+      cl_called = 0;
+
+      pthread_t th;
+      if (pthread_create (&th, NULL, tests[cnt].tf, (void *) 1l) != 0)
+	{
+	  printf ("create for '%s' test failed\n", tests[cnt].name);
+	  result = 1;
+	  continue;
+	}
+
+      int r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
+	  result = 1;
+	  continue;
+	}
+
+      if (pthread_cancel (th) != 0)
+	{
+	  printf ("cancel for '%s' failed\n", tests[cnt].name);
+	  result = 1;
+	  continue;
+	}
+
+      r = pthread_barrier_wait (&b2);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
+	  result = 1;
+	  continue;
+	}
+
+      void *status;
+      if (pthread_join (th, &status) != 0)
+	{
+	  printf ("join for '%s' failed\n", tests[cnt].name);
+	  result = 1;
+	  continue;
+	}
+      if (status != PTHREAD_CANCELED)
+	{
+	  printf ("thread for '%s' not canceled\n", tests[cnt].name);
+	  result = 1;
+	  continue;
+	}
+
+      if (pthread_barrier_destroy (&b2) != 0)
+	{
+	  puts ("barrier_destroy failed");
+	  result = 1;
+	  continue;
+	}
+
+      if (cl_called == 0)
+	{
+	  printf ("cleanup handler not called for '%s'\n", tests[cnt].name);
+	  result = 1;
+	  continue;
+	}
+      if (cl_called > 1)
+	{
+	  printf ("cleanup handler called more than once for '%s'\n",
+		  tests[cnt].name);
+	  result = 1;
+	  continue;
+	}
+
+      printf ("early cancel test of '%s' successful\n", tests[cnt].name);
+
+      if (tempfd != -1)
+	{
+	  close (tempfd);
+	  tempfd = -1;
+	}
+      if (tempfd2 != -1)
+	{
+	  close (tempfd2);
+	  tempfd2 = -1;
+	}
+      if (tempfname != NULL)
+	{
+	  unlink (tempfname);
+	  free (tempfname);
+	  tempfname = NULL;
+	}
+      if (tempmsg != -1)
+	{
+	  msgctl (tempmsg, IPC_RMID, NULL);
+	  tempmsg = -1;
+	}
+    }
+
+  return result;
+}
+
+#define TIMEOUT 60
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancel5.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancel5.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancel5.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cancel4.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancel6.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancel6.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancel6.c	(revision 2036)
@@ -0,0 +1,79 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static void *
+tf (void *arg)
+{
+  char buf[100];
+  fgets (buf, sizeof (buf), arg);
+  /* This call should never return.  */
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  int fd[2];
+  if (pipe (fd) != 0)
+    {
+      puts ("pipe failed");
+      return 1;
+    }
+
+  FILE *fp = fdopen (fd[0], "r");
+  if (fp == NULL)
+    {
+      puts ("fdopen failed");
+      return 1;
+    }
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, fp) != 0)
+    {
+      puts ("pthread_create failed");
+      return 1;
+    }
+
+  sleep (1);
+
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("pthread_cancel failed");
+      return 1;
+    }
+
+  void *r;
+  if (pthread_join (th, &r) != 0)
+    {
+      puts ("pthread_join failed");
+      return 1;
+    }
+
+  return r != PTHREAD_CANCELED;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancel7.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancel7.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancel7.c	(revision 2036)
@@ -0,0 +1,211 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+const char *command;
+const char *pidfile;
+char pidfilename[] = "/tmp/tst-cancel7-XXXXXX";
+
+static void *
+tf (void *arg)
+{
+  const char *args = " --direct --pidfile ";
+  char *cmd = alloca (strlen (command) + strlen (args)
+		      + strlen (pidfilename) + 1);
+
+  strcpy (stpcpy (stpcpy (cmd, command), args), pidfilename);
+  system (cmd);
+  /* This call should never return.  */
+  return NULL;
+}
+
+
+static void
+sl (void)
+{
+  FILE *f = fopen (pidfile, "w");
+  if (f == NULL)
+    exit (1);
+
+  fprintf (f, "%lld\n", (long long) getpid ());
+  fflush (f);
+
+  struct flock fl =
+    {
+      .l_type = F_WRLCK,
+      .l_start = 0,
+      .l_whence = SEEK_SET,
+      .l_len = 1
+    };
+  if (fcntl (fileno (f), F_SETLK, &fl) != 0)
+    exit (1);
+
+  sigset_t ss;
+  sigfillset (&ss);
+  sigsuspend (&ss);
+  exit (0);
+}
+
+
+static void
+do_prepare (int argc, char *argv[])
+{
+  if (command == NULL)
+    command = argv[0];
+
+  if (pidfile)
+    sl ();
+
+  int fd = mkstemp (pidfilename);
+  if (fd == -1)
+    {
+      puts ("mkstemp failed");
+      exit (1);
+    }
+
+  write (fd, " ", 1);
+  close (fd);
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("pthread_create failed");
+      return 1;
+    }
+
+  do
+    sleep (1);
+  while (access (pidfilename, R_OK) != 0);
+
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("pthread_cancel failed");
+      return 1;
+    }
+
+  void *r;
+  if (pthread_join (th, &r) != 0)
+    {
+      puts ("pthread_join failed");
+      return 1;
+    }
+
+  sleep (1);
+
+  FILE *f = fopen (pidfilename, "r+");
+  if (f == NULL)
+    {
+      puts ("no pidfile");
+      return 1;
+    }
+
+  long long ll;
+  if (fscanf (f, "%lld\n", &ll) != 1)
+    {
+      puts ("could not read pid");
+      unlink (pidfilename);
+      return 1;
+    }
+
+  struct flock fl =
+    {
+      .l_type = F_WRLCK,
+      .l_start = 0,
+      .l_whence = SEEK_SET,
+      .l_len = 1
+    };
+  if (fcntl (fileno (f), F_GETLK, &fl) != 0)
+    {
+      puts ("F_GETLK failed");
+      unlink (pidfilename);
+      return 1;
+    }
+
+  if (fl.l_type != F_UNLCK)
+    {
+      printf ("child %lld still running\n", (long long) fl.l_pid);
+      if (fl.l_pid == ll)
+	kill (fl.l_pid, SIGKILL);
+
+      unlink (pidfilename);
+      return 1;
+    }
+
+  fclose (f);
+
+  unlink (pidfilename);
+
+  return r != PTHREAD_CANCELED;
+}
+
+static void
+do_cleanup (void)
+{
+  FILE *f = fopen (pidfilename, "r+");
+  long long ll;
+
+  if (f != NULL && fscanf (f, "%lld\n", &ll) == 1)
+    {
+      struct flock fl =
+	{
+	  .l_type = F_WRLCK,
+	  .l_start = 0,
+	  .l_whence = SEEK_SET,
+	  .l_len = 1
+	};
+      if (fcntl (fileno (f), F_GETLK, &fl) == 0 && fl.l_type != F_UNLCK
+	  && fl.l_pid == ll)
+	kill (fl.l_pid, SIGKILL);
+
+      fclose (f);
+    }
+
+  unlink (pidfilename);
+}
+
+#define OPT_COMMAND	10000
+#define OPT_PIDFILE	10001
+#define CMDLINE_OPTIONS \
+  { "command", required_argument, NULL, OPT_COMMAND },	\
+  { "pidfile", required_argument, NULL, OPT_PIDFILE },
+#define CMDLINE_PROCESS \
+  case OPT_COMMAND:	\
+    command = optarg;	\
+    break;		\
+  case OPT_PIDFILE:	\
+    pidfile = optarg;	\
+    break;
+// #define CLEANUP_HANDLER do_cleanup ()
+#define PREPARE(argc, argv) do_prepare (argc, argv)
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 5
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancel8.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancel8.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancel8.c	(revision 2036)
@@ -0,0 +1,143 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static pthread_barrier_t bar;
+
+static int global;
+
+
+static void
+cleanup (void *arg)
+{
+  global = 1;
+}
+
+
+static void *
+tf (void *arg)
+{
+  /* Enable cancellation, but defer it.  */
+  if (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL) != 0)
+    {
+      puts ("setcancelstate failed");
+      exit (1);
+    }
+  if (pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, NULL) != 0)
+    {
+      puts ("setcanceltype failed");
+      exit (1);
+    }
+
+  /* Add cleanup handler.  */
+  pthread_cleanup_push (cleanup, NULL);
+
+  /* Synchronize with the main thread.  */
+  int r = pthread_barrier_wait (&bar);
+  if (r != 0 && r!= PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("tf: first barrier_wait failed");
+      exit (1);
+    }
+
+  /* And again.  Once this is done the main thread should have canceled
+     this thread.  */
+  r = pthread_barrier_wait (&bar);
+  if (r != 0 && r!= PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("tf: second barrier_wait failed");
+      exit (1);
+    }
+
+  /* Remove the cleanup handler without executing it.  */
+  pthread_cleanup_pop (0);
+
+  /* Now react on the cancellation.  */
+  pthread_testcancel ();
+
+  /* This call should never return.  */
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  if (pthread_barrier_init (&bar, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("pthread_create failed");
+      return 1;
+    }
+
+  int r = pthread_barrier_wait (&bar);
+  if (r != 0 && r!= PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("first barrier_wait failed");
+      exit (1);
+    }
+
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("pthread_cancel failed");
+      return 1;
+    }
+
+  r = pthread_barrier_wait (&bar);
+  if (r != 0 && r!= PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("second barrier_wait failed");
+      exit (1);
+    }
+
+  void *result;
+  if (pthread_join (th, &result) != 0)
+    {
+      puts ("pthread_join failed");
+      return 1;
+    }
+
+  if (result != PTHREAD_CANCELED)
+    {
+      puts ("thread was not canceled");
+      exit (1);
+    }
+
+  if (global != 0)
+    {
+      puts ("cancellation handler has been called");
+      exit (1);
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancel9.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancel9.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancel9.c	(revision 2036)
@@ -0,0 +1,126 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <fcntl.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static pthread_barrier_t b;
+
+
+static void
+cleanup (void *arg)
+{
+  fputs ("in cleanup\n", stdout);
+}
+
+
+static void *
+tf (void *arg)
+{
+  int fd = open ("/dev/null", O_RDWR);
+  if (fd == -1)
+    {
+      puts ("cannot open /dev/null");
+      exit (1);
+    }
+  FILE *fp = fdopen (fd, "w");
+  if (fp == NULL)
+    {
+      puts ("fdopen failed");
+      exit (1);
+    }
+
+  pthread_cleanup_push (cleanup, NULL);
+
+  int e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      exit (1);
+    }
+
+  while (1)
+    /* fprintf() uses write() which is a cancallation point.  */
+    fprintf (fp, "foo");
+
+  pthread_cleanup_pop (0);
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  if (pthread_barrier_init (&b, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      return 1;
+    }
+
+  int e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      exit (1);
+    }
+
+  sleep (1);
+
+  puts ("cancel now");
+
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("cancel failed");
+      exit (1);
+    }
+
+  puts ("waiting for the child");
+
+  void *r;
+  if (pthread_join (th, &r) != 0)
+    {
+      puts ("join failed");
+      exit (1);
+    }
+
+  if (r != PTHREAD_CANCELED)
+    {
+      puts ("thread wasn't canceled");
+      exit (1);
+    }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancelx1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancelx1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancelx1.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cancel1.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancelx10.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancelx10.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancelx10.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cancel10.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancelx11.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancelx11.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancelx11.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cancel11.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancelx12.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancelx12.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancelx12.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cancel12.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancelx13.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancelx13.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancelx13.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cancel13.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancelx14.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancelx14.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancelx14.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cancel14.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancelx15.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancelx15.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancelx15.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cancel15.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancelx16.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancelx16.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancelx16.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cancel16.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancelx17.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancelx17.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancelx17.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cancel17.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancelx18.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancelx18.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancelx18.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cancel18.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancelx2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancelx2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancelx2.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cancel2.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancelx20.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancelx20.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancelx20.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cancel20.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancelx21.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancelx21.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancelx21.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cancel21.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancelx3.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancelx3.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancelx3.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cancel3.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancelx4.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancelx4.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancelx4.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cancel4.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancelx5.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancelx5.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancelx5.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cancel5.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancelx6.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancelx6.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancelx6.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cancel6.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancelx7.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancelx7.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancelx7.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cancel7.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancelx8.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancelx8.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancelx8.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cancel8.c"
Index: trunk/src/libctests/glibc/nptl/tst-cancelx9.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cancelx9.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cancelx9.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cancel9.c"
Index: trunk/src/libctests/glibc/nptl/tst-cleanup0.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cleanup0.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cleanup0.c	(revision 2036)
@@ -0,0 +1,76 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static int global;
+
+
+static void
+ch (void *arg)
+{
+  int val = (long int) arg;
+
+  printf ("ch (%d)\n", val);
+
+  global *= val;
+  global += val;
+}
+
+
+static void
+endfct (void)
+{
+  /* We force exit right here.  */
+  _exit (global);
+}
+
+
+static int
+do_test (void)
+{
+  atexit (endfct);
+
+  pthread_cancel (pthread_self ());
+
+  pthread_cleanup_push (ch, (void *) 1l);
+
+  pthread_cleanup_push (ch, (void *) 2l);
+
+  pthread_cleanup_push (ch, (void *) 3l);
+
+  pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+
+  pthread_cleanup_pop (1);
+
+  pthread_cleanup_pop (1);
+
+  pthread_cleanup_pop (1);
+
+  return 100;
+}
+
+
+#define EXPECTED_STATUS 9
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cleanup0.expect
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cleanup0.expect	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cleanup0.expect	(revision 2036)
@@ -0,0 +1,3 @@
+ch (3)
+ch (2)
+ch (1)
Index: trunk/src/libctests/glibc/nptl/tst-cleanup1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cleanup1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cleanup1.c	(revision 2036)
@@ -0,0 +1,100 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static int global;
+
+
+static void
+ch (void *arg)
+{
+  int val = (long int) arg;
+
+  printf ("ch (%d)\n", val);
+
+  global *= val;
+  global += val;
+}
+
+
+static void *
+tf (void *a)
+{
+  pthread_cancel (pthread_self ());
+
+  pthread_cleanup_push (ch, (void *) 1l);
+
+  pthread_cleanup_push (ch, (void *) 2l);
+
+  pthread_cleanup_push (ch, (void *) 3l);
+
+  pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+
+  pthread_cleanup_pop (1);
+
+  pthread_cleanup_pop (1);
+
+  pthread_cleanup_pop (1);
+
+  return NULL;
+}
+
+
+int
+do_test (void)
+{
+  pthread_t th;
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      write (2, "create failed\n", 14);
+      _exit (1);
+    }
+
+  void *r;
+  int e;
+  if ((e = pthread_join (th, &r)) != 0)
+    {
+      printf ("join failed: %d\n", e);
+      _exit (1);
+    }
+
+  if (r != PTHREAD_CANCELED)
+    {
+      puts ("thread not canceled");
+      exit (1);
+    }
+
+  if (global != 9)
+    {
+      printf ("global = %d, expected 9\n", global);
+      exit (1);
+    }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cleanup2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cleanup2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cleanup2.c	(revision 2036)
@@ -0,0 +1,63 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Bao Duong <bduong@progress.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <setjmp.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+
+static sigjmp_buf jmpbuf;
+
+static void
+sig_handler (int signo)
+{
+  siglongjmp (jmpbuf, 1);
+}
+
+static int
+do_test (void)
+{
+  char *p = NULL;
+  struct sigaction sa;
+
+  sa.sa_handler = sig_handler;
+  sigemptyset (&sa.sa_mask);
+  sa.sa_flags = SA_SIGINFO;
+
+  if (sigaction (SIGSEGV, &sa, 0))
+    {
+      perror ("installing SIGSEGV handler\n");
+      exit (1);
+    }
+
+  puts ("Attempting to sprintf to null ptr");
+  if (setjmp (jmpbuf))
+    {
+      puts ("Exiting main...");
+      return 0;
+    }
+
+  sprintf (p, "This should segv\n");
+
+  return 1;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cleanup3.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cleanup3.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cleanup3.c	(revision 2036)
@@ -0,0 +1,98 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static int global;
+
+
+static void
+ch (void *arg)
+{
+  int val = (long int) arg;
+
+  printf ("ch (%d)\n", val);
+
+  global *= val;
+  global += val;
+}
+
+
+static void *
+tf (void *a)
+{
+  pthread_cleanup_push (ch, (void *) 1l);
+
+  pthread_cleanup_push (ch, (void *) 2l);
+
+  pthread_cleanup_push (ch, (void *) 3l);
+
+  pthread_exit ((void *) 1l);
+
+  pthread_cleanup_pop (1);
+
+  pthread_cleanup_pop (1);
+
+  pthread_cleanup_pop (1);
+
+  return NULL;
+}
+
+
+int
+do_test (void)
+{
+  pthread_t th;
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      write (2, "create failed\n", 14);
+      _exit (1);
+    }
+
+  void *r;
+  int e;
+  if ((e = pthread_join (th, &r)) != 0)
+    {
+      printf ("join failed: %d\n", e);
+      _exit (1);
+    }
+
+  if (r != (void *) 1l)
+    {
+      puts ("thread not canceled");
+      exit (1);
+    }
+
+  if (global != 9)
+    {
+      printf ("global = %d, expected 9\n", global);
+      exit (1);
+    }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cleanup4.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cleanup4.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cleanup4.c	(revision 2036)
@@ -0,0 +1,198 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+/* LinuxThreads pthread_cleanup_{push,pop} helpers.  */
+extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *__buffer,
+                                   void (*__routine) (void *),
+                                   void *__arg);
+extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *__buffer,
+                                  int __execute);
+
+static int fds[2];
+static pthread_barrier_t b2;
+static int global;
+
+/* Defined in tst-cleanup4aux.c, never compiled with -fexceptions.  */
+extern void fn5 (void);
+extern void fn7 (void);
+extern void fn9 (void);
+
+void
+clh (void *arg)
+{
+  int val = (long int) arg;
+
+  printf ("clh (%d)\n", val);
+
+  global *= val;
+  global += val;
+}
+
+
+static __attribute__((noinline)) void
+fn_read (void)
+{
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("%s: barrier_wait failed\n", __FUNCTION__);
+      exit (1);
+    }
+
+  char c;
+  read (fds[0], &c, 1);
+}
+
+
+__attribute__((noinline)) void
+fn0 (void)
+{
+  pthread_cleanup_push (clh, (void *) 1l);
+
+  fn_read ();
+
+  pthread_cleanup_pop (1);
+}
+
+
+__attribute__((noinline)) void
+fn1 (void)
+{
+  /* This is the old LinuxThreads pthread_cleanup_{push,pop}.  */
+  struct _pthread_cleanup_buffer b;
+  _pthread_cleanup_push (&b, clh, (void *) 2l);
+
+  fn0 ();
+
+  _pthread_cleanup_pop (&b, 1);
+}
+
+
+static __attribute__((noinline)) void
+fn2 (void)
+{
+  pthread_cleanup_push (clh, (void *) 3l);
+
+  fn1 ();
+
+  pthread_cleanup_pop (1);
+}
+
+
+static void *
+tf (void *a)
+{
+  switch ((long) a)
+    {
+    case 0:
+      fn2 ();
+      break;
+    case 1:
+      fn5 ();
+      break;
+    case 2:
+      fn7 ();
+      break;
+    case 3:
+      fn9 ();
+      break;
+    }
+
+  return NULL;
+}
+
+
+int
+do_test (void)
+{
+  int result = 0;
+
+  if (pipe (fds) != 0)
+    {
+      puts ("pipe failed");
+      exit (1);
+    }
+
+  if (pthread_barrier_init (&b2, NULL, 2) != 0)
+    {
+      puts ("b2 init failed");
+      exit (1);
+    }
+
+  const int expect[] =
+    {
+      15,	/* 1 2 3 */
+      276,	/* 1 4 5 6 */
+      120,	/* 1 7 8 */
+      460	/* 1 2 9 10 */
+    };
+
+  long i;
+  for (i = 0; i < 4; ++i)
+    {
+      global = 0;
+
+      printf ("test %ld\n", i);
+
+      pthread_t th;
+      if (pthread_create (&th, NULL, tf, (void *) i) != 0)
+	{
+	  puts ("create failed");
+	  exit (1);
+	}
+
+      int e = pthread_barrier_wait (&b2);
+      if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
+	  exit (1);
+	}
+
+      pthread_cancel (th);
+
+      void *r;
+      if ((e = pthread_join (th, &r)) != 0)
+	{
+	  printf ("join failed: %d\n", e);
+	  _exit (1);
+	}
+
+      if (r != PTHREAD_CANCELED)
+	{
+	  puts ("thread not canceled");
+	  exit (1);
+	}
+
+      if (global != expect[i])
+	{
+	  printf ("global = %d, expected %d\n", global, expect[i]);
+	  result = 1;
+	}
+    }
+
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cleanup4aux.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cleanup4aux.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cleanup4aux.c	(revision 2036)
@@ -0,0 +1,121 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *__buffer,
+                                   void (*__routine) (void *),
+                                   void *__arg);
+extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *__buffer,
+                                  int __execute);
+
+extern void clh (void *arg);
+extern void fn0 (void);
+extern void fn1 (void);
+extern void fn5 (void);
+extern void fn7 (void);
+extern void fn9 (void);
+
+
+static __attribute__((noinline)) void
+fn3 (void)
+{
+  /* This is the old LinuxThreads pthread_cleanup_{push,pop}.  */
+     struct _pthread_cleanup_buffer b;
+  _pthread_cleanup_push (&b, clh, (void *) 4l);
+
+  fn0 ();
+
+  _pthread_cleanup_pop (&b, 1);
+}
+
+
+static __attribute__((noinline)) void
+fn4 (void)
+{
+  pthread_cleanup_push (clh, (void *) 5l);
+
+  fn3 ();
+
+  pthread_cleanup_pop (1);
+}
+
+
+void
+fn5 (void)
+{
+  /* This is the old LinuxThreads pthread_cleanup_{push,pop}.  */
+     struct _pthread_cleanup_buffer b;
+  _pthread_cleanup_push (&b, clh, (void *) 6l);
+
+  fn4 ();
+
+  _pthread_cleanup_pop (&b, 1);
+}
+
+
+static __attribute__((noinline)) void
+fn6 (void)
+{
+  pthread_cleanup_push (clh, (void *) 7l);
+
+  fn0 ();
+
+  pthread_cleanup_pop (1);
+}
+
+
+void
+fn7 (void)
+{
+  /* This is the old LinuxThreads pthread_cleanup_{push,pop}.  */
+     struct _pthread_cleanup_buffer b;
+  _pthread_cleanup_push (&b, clh, (void *) 8l);
+
+  fn6 ();
+
+  _pthread_cleanup_pop (&b, 1);
+}
+
+
+static __attribute__((noinline)) void
+fn8 (void)
+{
+  pthread_cleanup_push (clh, (void *) 9l);
+
+  fn1 ();
+
+  pthread_cleanup_pop (1);
+}
+
+
+void
+fn9 (void)
+{
+  /* This is the old LinuxThreads pthread_cleanup_{push,pop}.  */
+     struct _pthread_cleanup_buffer b;
+  _pthread_cleanup_push (&b, clh, (void *) 10l);
+
+  fn8 ();
+
+  _pthread_cleanup_pop (&b, 1);
+}
Index: trunk/src/libctests/glibc/nptl/tst-cleanupx0.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cleanupx0.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cleanupx0.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cleanup0.c"
Index: trunk/src/libctests/glibc/nptl/tst-cleanupx0.expect
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cleanupx0.expect	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cleanupx0.expect	(revision 2036)
@@ -0,0 +1,3 @@
+ch (3)
+ch (2)
+ch (1)
Index: trunk/src/libctests/glibc/nptl/tst-cleanupx1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cleanupx1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cleanupx1.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cleanup1.c"
Index: trunk/src/libctests/glibc/nptl/tst-cleanupx2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cleanupx2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cleanupx2.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cleanup2.c"
Index: trunk/src/libctests/glibc/nptl/tst-cleanupx3.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cleanupx3.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cleanupx3.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cleanup3.c"
Index: trunk/src/libctests/glibc/nptl/tst-cleanupx4.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cleanupx4.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cleanupx4.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-cleanup4.c"
Index: trunk/src/libctests/glibc/nptl/tst-clock1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-clock1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-clock1.c	(revision 2036)
@@ -0,0 +1,51 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+
+
+int
+do_test (void)
+{
+#if defined _POSIX_THREAD_CPUTIME && _POSIX_THREAD_CPUTIME >= 0
+  clockid_t cl;
+  /* This is really only a linking-test here.  */
+  int e = pthread_getcpuclockid (pthread_self (), &cl);
+  if (e != 0)
+    {
+# if _POSIX_THREAD_CPUTIME == 0
+      if (sysconf (_SC_THREAD_CPUTIME) >= 0)
+# endif
+	{
+	  puts ("cpuclock advertized, but cannot get ID");
+	  exit (1);
+	}
+    }
+#endif
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-clock2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-clock2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-clock2.c	(revision 2036)
@@ -0,0 +1,202 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+
+
+#if defined _POSIX_THREAD_CPUTIME && _POSIX_THREAD_CPUTIME >= 0
+static pthread_barrier_t b2;
+static pthread_barrier_t bN;
+
+
+static void *
+tf (void *arg)
+{
+  int e = pthread_barrier_wait (&b2);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      exit (1);
+    }
+
+  e = pthread_barrier_wait (&bN);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      exit (1);
+    }
+
+  return NULL;
+}
+#endif
+
+
+int
+do_test (void)
+{
+#if defined _POSIX_THREAD_CPUTIME && _POSIX_THREAD_CPUTIME >= 0
+# define N 10
+
+# if _POSIX_THREAD_CPUTIME == 0
+  if (sysconf (_SC_THREAD_CPUTIME) < 0)
+    {
+      puts ("_POSIX_THREAD_CPUTIME option not available");
+      return 0;
+    }
+# endif
+
+  if (pthread_barrier_init (&b2, NULL, 2) != 0
+      || pthread_barrier_init (&bN, NULL, N + 1) != 0)
+    {
+      puts ("barrier_init failed");
+      return 1;
+    }
+
+  struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 };
+  TEMP_FAILURE_RETRY (nanosleep (&ts, &ts));
+
+  pthread_t th[N + 1];
+  clockid_t cl[N + 1];
+# ifndef CLOCK_THREAD_CPUTIME_ID
+  if (pthread_getcpuclockid (pthread_self (), &cl[0]) != 0)
+    {
+      puts ("own pthread_getcpuclockid failed");
+      return 1;
+    }
+# else
+  cl[0] = CLOCK_THREAD_CPUTIME_ID;
+# endif
+
+  pthread_attr_t at;
+
+  if (pthread_attr_init (&at) != 0)
+    {
+      puts ("attr_init failed");
+      return 1;
+    }
+
+  if (pthread_attr_setstacksize (&at, 1 * 1024 * 1024) != 0)
+    {
+      puts ("attr_setstacksize failed");
+      return 1;
+    }
+
+  int i;
+  int e;
+  for (i = 0; i < N; ++i)
+    {
+      if (pthread_create (&th[i], &at, tf, NULL) != 0)
+	{
+	  puts ("create failed");
+	  return 1;
+	}
+
+      e = pthread_barrier_wait (&b2);
+      if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  puts ("barrier_wait failed");
+	  return 1;
+	}
+
+      ts.tv_sec = 0;
+      ts.tv_nsec = 100000000;
+      TEMP_FAILURE_RETRY (nanosleep (&ts, &ts));
+
+      if (pthread_getcpuclockid (th[i], &cl[i + 1]) != 0)
+	{
+	  puts ("pthread_getcpuclockid failed");
+	  return 1;
+	}
+    }
+
+  if (pthread_attr_destroy (&at) != 0)
+    {
+      puts ("attr_destroy failed");
+      return 1;
+    }
+
+  struct timespec t[N + 1];
+  for (i = 0; i < N + 1; ++i)
+    if (clock_gettime (cl[i], &t[i]) != 0)
+      {
+	printf ("clock_gettime round %d failed\n", i);
+	return 1;
+      }
+
+  for (i = 0; i < N; ++i)
+    {
+      struct timespec diff;
+
+      diff.tv_sec = t[i].tv_sec - t[i + 1].tv_sec;
+      diff.tv_nsec = t[i].tv_nsec - t[i + 1].tv_nsec;
+      if (diff.tv_nsec < 0)
+	{
+	  diff.tv_nsec += 1000000000;
+	  --diff.tv_sec;
+	}
+
+      if (diff.tv_sec < 0 || (diff.tv_sec == 0 && diff.tv_nsec < 100000000))
+	{
+	  printf ("\
+difference between thread %d and %d too small (%ld.%09ld)\n",
+		  i, i + 1, (long int) diff.tv_sec, (long int) diff.tv_nsec);
+	  return 1;
+	}
+
+      printf ("diff %d->%d: %ld.%09ld\n",
+	      i, i + 1, (long int) diff.tv_sec, (long int) diff.tv_nsec);
+    }
+
+  ts.tv_sec = 0;
+  ts.tv_nsec = 0;
+  for (i = 0; i < N + 1; ++i)
+    if (clock_settime (cl[i], &ts) != 0)
+      {
+	printf ("clock_settime(%d) round %d failed\n", cl[i], i);
+	return 1;
+      }
+
+  for (i = 0; i < N + 1; ++i)
+    {
+      if (clock_gettime (cl[i], &ts) != 0)
+	{
+	  puts ("clock_gettime failed");
+	  return 1;
+	}
+
+      if (ts.tv_sec > t[i].tv_sec
+	  || (ts.tv_sec == t[i].tv_sec && ts.tv_nsec > t[i].tv_nsec))
+	{
+	  puts ("clock_settime didn't reset clock");
+	  return 1;
+	}
+    }
+#endif
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cond1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cond1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cond1.c	(revision 2036)
@@ -0,0 +1,94 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <error.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
+
+
+static void *
+tf (void *p)
+{
+  int err;
+
+  err = pthread_mutex_lock (&mut);
+  if (err != 0)
+    error (EXIT_FAILURE, err, "child: cannot get mutex");
+
+  puts ("child: got mutex; signalling");
+
+  pthread_cond_signal (&cond);
+
+  puts ("child: unlock");
+
+  err = pthread_mutex_unlock (&mut);
+  if (err != 0)
+    error (EXIT_FAILURE, err, "child: cannot unlock");
+
+  puts ("child: done");
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t th;
+  int err;
+
+  printf ("&cond = %p\n&mut = %p\n", &cond, &mut);
+
+  puts ("parent: get mutex");
+
+  err = pthread_mutex_lock (&mut);
+  if (err != 0)
+    error (EXIT_FAILURE, err, "parent: cannot get mutex");
+
+  puts ("parent: create child");
+
+  err = pthread_create (&th, NULL, tf, NULL);
+  if (err != 0)
+    error (EXIT_FAILURE, err, "parent: cannot create thread");
+
+  puts ("parent: wait for condition");
+
+  err = pthread_cond_wait (&cond, &mut);
+  if (err != 0)
+    error (EXIT_FAILURE, err, "parent: cannot wait fir signal");
+
+  puts ("parent: got signal");
+
+  err = pthread_join (th, NULL);
+  if (err != 0)
+    error (EXIT_FAILURE, err, "parent: failed to join");
+
+  puts ("done");
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cond10.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cond10.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cond10.c	(revision 2036)
@@ -0,0 +1,173 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <error.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+#define N 10
+#define ROUNDS 100
+
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
+static pthread_barrier_t bN1;
+static pthread_barrier_t b2;
+
+
+static void *
+tf (void *p)
+{
+  if (pthread_mutex_lock (&mut) != 0)
+    {
+      puts ("child: 1st mutex_lock failed");
+      exit (1);
+    }
+
+  int e = pthread_barrier_wait (&b2);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("child: 1st barrier_wait failed");
+      exit (1);
+    }
+
+  if (pthread_cond_wait (&cond, &mut) != 0)
+    {
+      puts ("child: cond_wait failed");
+      exit (1);
+    }
+
+  if (pthread_mutex_unlock (&mut) != 0)
+    {
+      puts ("child: mutex_unlock failed");
+      exit (1);
+    }
+
+  e = pthread_barrier_wait (&bN1);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("child: 2nd barrier_wait failed");
+      exit (1);
+    }
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  if (pthread_barrier_init (&bN1, NULL, N + 1) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  if (pthread_barrier_init (&b2, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  pthread_attr_t at;
+
+  if (pthread_attr_init (&at) != 0)
+    {
+      puts ("attr_init failed");
+      return 1;
+    }
+
+  if (pthread_attr_setstacksize (&at, 1 * 1024 * 1024) != 0)
+    {
+      puts ("attr_setstacksize failed");
+      return 1;
+    }
+
+  int r;
+  for (r = 0; r < ROUNDS; ++r)
+    {
+      printf ("round %d\n", r + 1);
+
+      int i;
+      pthread_t th[N];
+      for (i = 0; i < N; ++i)
+	{
+	  if (pthread_create (&th[i], &at, tf, NULL) != 0)
+	    {
+	      puts ("create failed");
+	      exit (1);
+	    }
+
+	  int e = pthread_barrier_wait (&b2);
+	  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+	    {
+	      puts ("parent: 1st barrier_wait failed");
+	      exit (1);
+	    }
+	}
+
+      if (pthread_mutex_lock (&mut) != 0)
+	{
+	  puts ("parent: mutex_lock failed");
+	  exit (1);
+	}
+      if (pthread_mutex_unlock (&mut) != 0)
+	{
+	  puts ("parent: mutex_unlock failed");
+	  exit (1);
+	}
+
+      /* N single signal calls.  Without locking.  This tests that no
+	 signal gets lost.  */
+      for (i = 0; i < N; ++i)
+	if (pthread_cond_signal (&cond) != 0)
+	  {
+	    puts ("cond_signal failed");
+	    exit (1);
+	  }
+
+      int e = pthread_barrier_wait (&bN1);
+      if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  puts ("parent: 2nd barrier_wait failed");
+	  exit (1);
+	}
+
+      for (i = 0; i < N; ++i)
+	if (pthread_join (th[i], NULL) != 0)
+	  {
+	    puts ("join failed");
+	    exit (1);
+	  }
+    }
+
+  if (pthread_attr_destroy (&at) != 0)
+    {
+      puts ("attr_destroy failed");
+      return 1;
+    }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cond11.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cond11.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cond11.c	(revision 2036)
@@ -0,0 +1,191 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <time.h>
+#include <unistd.h>
+
+
+#if defined _POSIX_CLOCK_SELECTION && _POSIX_CLOCK_SELECTION >= 0
+static int
+run_test (clockid_t cl)
+{
+  pthread_condattr_t condattr;
+  pthread_cond_t cond;
+  pthread_mutexattr_t mutattr;
+  pthread_mutex_t mut;
+
+  printf ("clock = %d\n", (int) cl);
+
+  if (pthread_condattr_init (&condattr) != 0)
+    {
+      puts ("condattr_init failed");
+      return 1;
+    }
+
+  if (pthread_condattr_setclock (&condattr, cl) != 0)
+    {
+      puts ("condattr_setclock failed");
+      return 1;
+    }
+
+  clockid_t cl2;
+  if (pthread_condattr_getclock (&condattr, &cl2) != 0)
+    {
+      puts ("condattr_getclock failed");
+      return 1;
+    }
+  if (cl != cl2)
+    {
+      printf ("condattr_getclock returned wrong value: %d, expected %d\n",
+	      (int) cl2, (int) cl);
+      return 1;
+    }
+
+  if (pthread_cond_init (&cond, &condattr) != 0)
+    {
+      puts ("cond_init failed");
+      return 1;
+    }
+
+  if (pthread_condattr_destroy (&condattr) != 0)
+    {
+      puts ("condattr_destroy failed");
+      return 1;
+    }
+
+  if (pthread_mutexattr_init (&mutattr) != 0)
+    {
+      puts ("mutexattr_init failed");
+      return 1;
+    }
+
+  if (pthread_mutexattr_settype (&mutattr, PTHREAD_MUTEX_ERRORCHECK) != 0)
+    {
+      puts ("mutexattr_settype failed");
+      return 1;
+    }
+
+  if (pthread_mutex_init (&mut, &mutattr) != 0)
+    {
+      puts ("mutex_init failed");
+      return 1;
+    }
+
+  if (pthread_mutexattr_destroy (&mutattr) != 0)
+    {
+      puts ("mutexattr_destroy failed");
+      return 1;
+    }
+
+  if (pthread_mutex_lock (&mut) != 0)
+    {
+      puts ("mutex_lock failed");
+      return 1;
+    }
+
+  if (pthread_mutex_lock (&mut) != EDEADLK)
+    {
+      puts ("2nd mutex_lock did not return EDEADLK");
+      return 1;
+    }
+
+  struct timespec ts;
+  if (clock_gettime (cl, &ts) != 0)
+    {
+      puts ("clock_gettime failed");
+      return 1;
+    }
+
+  /* Wait one second.  */
+  ++ts.tv_sec;
+
+  int e = pthread_cond_timedwait (&cond, &mut, &ts);
+  if (e == 0)
+    {
+      puts ("cond_timedwait succeeded");
+      return 1;
+    }
+  else if (e != ETIMEDOUT)
+    {
+      puts ("cond_timedwait did not return ETIMEDOUT");
+      return 1;
+    }
+
+  if (pthread_mutex_unlock (&mut) != 0)
+    {
+      puts ("mutex_unlock failed");
+      return 1;
+    }
+
+  if (pthread_mutex_destroy (&mut) != 0)
+    {
+      puts ("mutex_destroy failed");
+      return 1;
+    }
+
+  if (pthread_cond_destroy (&cond) != 0)
+    {
+      puts ("cond_destroy failed");
+      return 1;
+    }
+
+  return 0;
+}
+#endif
+
+
+static int
+do_test (void)
+{
+#if !defined _POSIX_CLOCK_SELECTION || _POSIX_CLOCK_SELECTION == -1
+
+  puts ("_POSIX_CLOCK_SELECTION not supported, test skipped");
+  return 0;
+
+#else
+
+  int res = run_test (CLOCK_REALTIME);
+
+# if defined _POSIX_MONOTONIC_CLOCK && _POSIX_MONOTONIC_CLOCK >= 0
+#  if _POSIX_MONOTONIC_CLOCK == 0
+  int e = sysconf (_SC_MONOTONIC_CLOCK);
+  if (e < 0)
+    puts ("CLOCK_MONOTONIC not supported");
+  else if (e == 0)
+    {
+      puts ("sysconf (_SC_MONOTONIC_CLOCK) must not return 0");
+      res = 1;
+    }
+  else
+#  endif
+    res |= run_test (CLOCK_MONOTONIC);
+# else
+  puts ("_POSIX_MONOTONIC_CLOCK not defined");
+# endif
+
+  return res;
+#endif
+}
+
+#define TIMEOUT 3
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cond12.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cond12.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cond12.c	(revision 2036)
@@ -0,0 +1,196 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+
+static char fname[] = "/tmp/tst-cond12-XXXXXX";
+static int fd;
+
+
+static void prepare (void);
+#define PREPARE(argc, argv) prepare ()
+
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+
+#include "../test-skeleton.c"
+
+
+static void
+prepare (void)
+{
+  fd = mkstemp (fname);
+  if (fd == -1)
+    {
+      printf ("mkstemp failed: %m\n");
+      exit (1);
+    }
+  add_temp_file (fname);
+  if (ftruncate (fd, 1000) < 0)
+    {
+      printf ("ftruncate failed: %m\n");
+      exit (1);
+    }
+}
+
+
+static int
+do_test (void)
+{
+  struct
+  {
+    pthread_mutex_t m;
+    pthread_cond_t c;
+    int var;
+  } *p = mmap (NULL, sizeof (*p), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+  if (p == MAP_FAILED)
+    {
+      printf ("initial mmap failed: %m\n");
+      return 1;
+    }
+
+  pthread_mutexattr_t ma;
+  if (pthread_mutexattr_init (&ma) != 0)
+    {
+      puts ("mutexattr_init failed");
+      return 1;
+    }
+  if (pthread_mutexattr_setpshared (&ma, 1) != 0)
+    {
+      puts ("mutexattr_setpshared failed");
+      return 1;
+    }
+  if (pthread_mutex_init (&p->m, &ma) != 0)
+    {
+      puts ("mutex_init failed");
+      return 1;
+    }
+  if (pthread_mutexattr_destroy (&ma) != 0)
+    {
+      puts ("mutexattr_destroy failed");
+      return 1;
+    }
+
+  pthread_condattr_t ca;
+  if (pthread_condattr_init (&ca) != 0)
+    {
+      puts ("condattr_init failed");
+      return 1;
+    }
+  if (pthread_condattr_setpshared (&ca, 1) != 0)
+    {
+      puts ("condattr_setpshared failed");
+      return 1;
+    }
+  if (pthread_cond_init (&p->c, &ca) != 0)
+    {
+      puts ("mutex_init failed");
+      return 1;
+    }
+  if (pthread_condattr_destroy (&ca) != 0)
+    {
+      puts ("condattr_destroy failed");
+      return 1;
+    }
+
+  if (pthread_mutex_lock (&p->m) != 0)
+    {
+      puts ("initial mutex_lock failed");
+      return 1;
+    }
+
+  p->var = 42;
+
+  pid_t pid = fork ();
+  if (pid == -1)
+    {
+      printf ("fork failed: %m\n");
+      return 1;
+    }
+
+  if (pid == 0)
+    {
+      void *oldp = p;
+      p = mmap (NULL, sizeof (*p), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+
+      if (p == oldp)
+	{
+	  puts ("child: mapped to same address");
+	  kill (getppid (), SIGKILL);
+	  exit (1);
+	}
+
+      munmap (oldp, sizeof (*p));
+
+      if (pthread_mutex_lock (&p->m) != 0)
+	{
+	  puts ("child: mutex_lock failed");
+	  kill (getppid (), SIGKILL);
+	  exit (1);
+	}
+
+      p->var = 0;
+
+#ifndef USE_COND_SIGNAL
+      if (pthread_cond_broadcast (&p->c) != 0)
+	{
+	  puts ("child: cond_broadcast failed");
+	  kill (getppid (), SIGKILL);
+	  exit (1);
+	}
+#else
+      if (pthread_cond_signal (&p->c) != 0)
+	{
+	  puts ("child: cond_signal failed");
+	  kill (getppid (), SIGKILL);
+	  exit (1);
+	}
+#endif
+
+      if (pthread_mutex_unlock (&p->m) != 0)
+	{
+	  puts ("child: mutex_unlock failed");
+	  kill (getppid (), SIGKILL);
+	  exit (1);
+	}
+
+      exit (0);
+    }
+
+  do
+    pthread_cond_wait (&p->c, &p->m);
+  while (p->var != 0);
+
+  if (TEMP_FAILURE_RETRY (waitpid (pid, NULL, 0)) != pid)
+    {
+      printf ("waitpid failed: %m\n");
+      kill (pid, SIGKILL);
+      return 1;
+    }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/nptl/tst-cond13.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cond13.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cond13.c	(revision 2036)
@@ -0,0 +1,2 @@
+#define USE_COND_SIGNAL 1
+#include "tst-cond12.c"
Index: trunk/src/libctests/glibc/nptl/tst-cond14.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cond14.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cond14.c	(revision 2036)
@@ -0,0 +1,118 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mut = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+static pthread_mutex_t mut2 = PTHREAD_MUTEX_INITIALIZER;
+
+static void *
+tf (void *p)
+{
+  if (pthread_mutex_lock (&mut) != 0)
+    {
+      printf ("%s: 1st mutex_lock failed\n", __func__);
+      exit (1);
+    }
+  if (pthread_mutex_lock (&mut) != 0)
+    {
+      printf ("%s: 2nd mutex_lock failed\n", __func__);
+      exit (1);
+    }
+  if (pthread_mutex_lock (&mut) != 0)
+    {
+      printf ("%s: 3rd mutex_lock failed\n", __func__);
+      exit (1);
+    }
+
+  if (pthread_mutex_unlock (&mut2) != 0)
+    {
+      printf ("%s: mutex_unlock failed\n", __func__);
+      exit (1);
+    }
+
+  if (pthread_cond_wait (&cond, &mut) != 0)
+    {
+      printf ("%s: cond_wait failed\n", __func__);
+      exit (1);
+    }
+
+  puts ("child: done");
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  if (pthread_mutex_lock (&mut2) != 0)
+    {
+      puts ("1st mutex_lock failed");
+      return 1;
+    }
+
+  puts ("parent: create child");
+
+  pthread_t th;
+  int err = pthread_create (&th, NULL, tf, NULL);
+  if (err != 0)
+    {
+      printf ("parent: cannot create thread: %s\n", strerror (err));
+      return 1;
+    }
+
+  /* We have to synchronize with the child.  */
+  if (pthread_mutex_lock (&mut2) != 0)
+    {
+      puts ("2nd mutex_lock failed");
+      return 1;
+    }
+
+  /* Give the child to reach to pthread_cond_wait.  */
+  sleep (1);
+
+  if (pthread_cond_signal (&cond) != 0)
+    {
+      puts ("cond_signal failed");
+      return 1;
+    }
+
+  err = pthread_join (th, NULL);
+  if (err != 0)
+    {
+      printf ("parent: failed to join: %s\n", strerror (err));
+      return 1;
+    }
+
+  puts ("done");
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 3
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cond15.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cond15.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cond15.c	(revision 2036)
@@ -0,0 +1,160 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mut = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+static pthread_mutex_t mut2 = PTHREAD_MUTEX_INITIALIZER;
+
+static void *
+tf (void *p)
+{
+  if (pthread_mutex_lock (&mut) != 0)
+    {
+      printf ("%s: 1st mutex_lock failed\n", __func__);
+      exit (1);
+    }
+  if (pthread_mutex_lock (&mut) != 0)
+    {
+      printf ("%s: 2nd mutex_lock failed\n", __func__);
+      exit (1);
+    }
+  if (pthread_mutex_lock (&mut) != 0)
+    {
+      printf ("%s: 3rd mutex_lock failed\n", __func__);
+      exit (1);
+    }
+
+  if (pthread_mutex_unlock (&mut2) != 0)
+    {
+      printf ("%s: mutex_unlock failed\n", __func__);
+      exit (1);
+    }
+
+  struct timeval tv;
+  gettimeofday (&tv, NULL);
+  struct timespec ts;
+  TIMEVAL_TO_TIMESPEC (&tv, &ts);
+  ts.tv_sec += p == NULL ? 100 : 1;
+
+  int err = pthread_cond_timedwait (&cond, &mut, &ts);
+  if ((err != 0 && p == NULL) || (err != ETIMEDOUT && p != NULL))
+    {
+      printf ("%s: cond_wait failed\n", __func__);
+      exit (1);
+    }
+
+  if (pthread_mutex_unlock (&mut) != 0)
+    {
+      printf ("%s: 1st mutex_unlock failed\n", __func__);
+      exit (1);
+    }
+  if (pthread_mutex_unlock (&mut) != 0)
+    {
+      printf ("%s: 2nd mutex_unlock failed\n", __func__);
+      exit (1);
+    }
+  if (pthread_mutex_unlock (&mut) != 0)
+    {
+      printf ("%s: 3rd mutex_unlock failed\n", __func__);
+      exit (1);
+    }
+
+  puts ("child: done");
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  if (pthread_mutex_lock (&mut2) != 0)
+    {
+      puts ("1st mutex_lock failed");
+      return 1;
+    }
+
+  puts ("parent: create 1st child");
+
+  pthread_t th;
+  int err = pthread_create (&th, NULL, tf, NULL);
+  if (err != 0)
+    {
+      printf ("parent: cannot 1st create thread: %s\n", strerror (err));
+      return 1;
+    }
+
+  /* We have to synchronize with the child.  */
+  if (pthread_mutex_lock (&mut2) != 0)
+    {
+      puts ("2nd mutex_lock failed");
+      return 1;
+    }
+
+  /* Give the child to reach to pthread_cond_wait.  */
+  sleep (1);
+
+  if (pthread_cond_signal (&cond) != 0)
+    {
+      puts ("cond_signal failed");
+      return 1;
+    }
+
+  err = pthread_join (th, NULL);
+  if (err != 0)
+    {
+      printf ("parent: failed to join: %s\n", strerror (err));
+      return 1;
+    }
+
+
+  puts ("parent: create 2nd child");
+
+  err = pthread_create (&th, NULL, tf, (void *) 1l);
+  if (err != 0)
+    {
+      printf ("parent: cannot 2nd create thread: %s\n", strerror (err));
+      return 1;
+    }
+
+  err = pthread_join (th, NULL);
+  if (err != 0)
+    {
+      printf ("parent: failed to join: %s\n", strerror (err));
+      return 1;
+    }
+
+  puts ("done");
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 6
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cond16.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cond16.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cond16.c	(revision 2036)
@@ -0,0 +1,105 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+pthread_cond_t cv = PTHREAD_COND_INITIALIZER;
+pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+bool n, exiting;
+FILE *f;
+int count;
+
+void *
+tf (void *dummy)
+{
+  bool loop = true;
+
+  while (loop)
+    {
+      pthread_mutex_lock (&lock);
+      while (n && !exiting)
+	pthread_cond_wait (&cv, &lock);
+      n = true;
+      pthread_mutex_unlock (&lock);
+
+      fputs (".", f);
+
+      pthread_mutex_lock (&lock);
+      n = false;
+      if (exiting)
+	loop = false;
+#ifdef UNLOCK_AFTER_BROADCAST
+      pthread_cond_broadcast (&cv);
+      pthread_mutex_unlock (&lock);
+#else
+      pthread_mutex_unlock (&lock);
+      pthread_cond_broadcast (&cv);
+#endif
+    }
+
+  return NULL;
+}
+
+int
+do_test (void)
+{
+  f = fopen ("/dev/null", "w");
+  if (f == NULL)
+    {
+      printf ("couldn't open /dev/null, %m\n");
+      return 1;
+    }
+
+  count = sysconf (_SC_NPROCESSORS_ONLN);
+  if (count <= 0)
+    count = 1;
+  count *= 4;
+
+  pthread_t th[count];
+  int i, ret;
+  for (i = 0; i < count; ++i)
+    if ((ret = pthread_create (&th[i], NULL, tf, NULL)) != 0)
+      {
+	errno = ret;
+	printf ("pthread_create %d failed: %m\n", i);
+	return 1;
+      }
+
+  struct timespec ts = { .tv_sec = 20, .tv_nsec = 0 };
+  while (nanosleep (&ts, &ts) != 0);
+
+  pthread_mutex_lock (&lock);
+  exiting = true;
+  pthread_mutex_unlock (&lock);
+
+  for (i = 0; i < count; ++i)
+    pthread_join (th[i], NULL);
+
+  fclose (f);
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 40
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cond17.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cond17.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cond17.c	(revision 2036)
@@ -0,0 +1,2 @@
+#define UNLOCK_AFTER_BROADCAST 1
+#include "tst-cond16.c"
Index: trunk/src/libctests/glibc/nptl/tst-cond18.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cond18.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cond18.c	(revision 2036)
@@ -0,0 +1,117 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+pthread_cond_t cv = PTHREAD_COND_INITIALIZER;
+pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+bool exiting;
+int fd, count, spins, nn;
+
+void *
+tf (void *id)
+{
+  pthread_mutex_lock (&lock);
+
+  if ((long) id == 0)
+    {
+      while (!exiting)
+	{
+	  if ((spins++ % 1000) == 0)
+	    write (fd, ".", 1);
+	  pthread_mutex_unlock (&lock);
+
+	  pthread_mutex_lock (&lock);
+	  int njobs = rand () % (count + 1);
+	  nn = njobs;
+	  if ((rand () % 30) == 0)
+	    pthread_cond_broadcast (&cv);
+	  else
+	    while (njobs--)
+	      pthread_cond_signal (&cv);
+	}
+
+      pthread_cond_broadcast (&cv);
+    }
+  else
+    {
+      while (!exiting)
+	{
+	  while (!nn && !exiting)
+	    pthread_cond_wait (&cv, &lock);
+	  --nn;
+	  pthread_mutex_unlock (&lock);
+
+	  pthread_mutex_lock (&lock);
+	}
+    }
+
+  pthread_mutex_unlock (&lock);
+  return NULL;
+}
+
+int
+do_test (void)
+{
+  fd = open ("/dev/null", O_WRONLY);
+  if (fd < 0)
+    {
+      printf ("couldn't open /dev/null, %m\n");
+      return 1;
+    }
+
+  count = sysconf (_SC_NPROCESSORS_ONLN);
+  if (count <= 0)
+    count = 1;
+  count *= 8;
+
+  pthread_t th[count + 1];
+  int i, ret;
+
+  for (i = 0; i <= count; ++i)
+    if ((ret = pthread_create (&th[i], NULL, tf, (void *) (long) i)) != 0)
+      {
+	errno = ret;
+	printf ("pthread_create %d failed: %m\n", i);
+	return 1;
+      }
+
+  struct timespec ts = { .tv_sec = 20, .tv_nsec = 0 };
+  while (nanosleep (&ts, &ts) != 0);
+
+  pthread_mutex_lock (&lock);
+  exiting = true;
+  pthread_mutex_unlock (&lock);
+
+  for (i = 0; i < count; ++i)
+    pthread_join (th[i], NULL);
+
+  close (fd);
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 40
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cond19.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cond19.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cond19.c	(revision 2036)
@@ -0,0 +1,76 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
+
+
+static int
+do_test (void)
+{
+  int result = 0;
+  struct timespec ts;
+
+  if (clock_gettime (CLOCK_REALTIME, &ts) != 0)
+    {
+      puts ("clock_gettime failed");
+      return 1;
+    }
+
+  ts.tv_nsec = -1;
+
+  int e = pthread_cond_timedwait (&cond, &mut, &ts);
+  if (e == 0)
+    {
+      puts ("first cond_timedwait did not fail");
+      result = 1;
+    }
+  else if (e != EINVAL)
+    {
+      puts ("first cond_timedwait did not return EINVAL");
+      result = 1;
+    }
+
+  ts.tv_nsec = 2000000000;
+
+  e = pthread_cond_timedwait (&cond, &mut, &ts);
+  if (e == 0)
+    {
+      puts ("second cond_timedwait did not fail");
+      result = 1;
+    }
+  else if (e != EINVAL)
+    {
+      puts ("second cond_timedwait did not return EINVAL");
+      result = 1;
+    }
+
+  return result;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cond2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cond2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cond2.c	(revision 2036)
@@ -0,0 +1,163 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <error.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+
+static pthread_barrier_t bar;
+
+
+static void *
+tf (void *a)
+{
+  int i = (long int) a;
+  int err;
+
+  printf ("child %d: lock\n", i);
+
+  err = pthread_mutex_lock (&mut);
+  if (err != 0)
+    error (EXIT_FAILURE, err, "locking in child failed");
+
+  printf ("child %d: sync\n", i);
+
+  int e = pthread_barrier_wait (&bar);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("child: barrier_wait failed");
+      exit (1);
+    }
+
+  printf ("child %d: wait\n", i);
+
+  err = pthread_cond_wait (&cond, &mut);
+  if (err != 0)
+    error (EXIT_FAILURE, err, "child %d: failed to wait", i);
+
+  printf ("child %d: woken up\n", i);
+
+  err = pthread_mutex_unlock (&mut);
+  if (err != 0)
+    error (EXIT_FAILURE, err, "child %d: unlock[2] failed", i);
+
+  printf ("child %d: done\n", i);
+
+  return NULL;
+}
+
+
+#define N 10
+
+
+static int
+do_test (void)
+{
+  pthread_t th[N];
+  int i;
+  int err;
+
+  printf ("&cond = %p\n&mut = %p\n", &cond, &mut);
+
+  if (pthread_barrier_init (&bar, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  pthread_attr_t at;
+
+  if (pthread_attr_init (&at) != 0)
+    {
+      puts ("attr_init failed");
+      return 1;
+    }
+
+  if (pthread_attr_setstacksize (&at, 1 * 1024 * 1024) != 0)
+    {
+      puts ("attr_setstacksize failed");
+      return 1;
+    }
+
+  for (i = 0; i < N; ++i)
+    {
+      printf ("create thread %d\n", i);
+
+      err = pthread_create (&th[i], &at, tf, (void *) (long int) i);
+      if (err != 0)
+	error (EXIT_FAILURE, err, "cannot create thread %d", i);
+
+      printf ("wait for child %d\n", i);
+
+      /* Wait for the child to start up and get the mutex for the
+	 conditional variable.  */
+      int e = pthread_barrier_wait (&bar);
+      if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  puts ("barrier_wait failed");
+	  exit (1);
+	}
+    }
+
+  if (pthread_attr_destroy (&at) != 0)
+    {
+      puts ("attr_destroy failed");
+      return 1;
+    }
+
+  puts ("get lock outselves");
+
+  err = pthread_mutex_lock (&mut);
+  if (err != 0)
+    error (EXIT_FAILURE, err, "mut locking failed");
+
+  puts ("broadcast");
+
+  /* Wake up all threads.  */
+  err = pthread_cond_broadcast (&cond);
+  if (err != 0)
+    error (EXIT_FAILURE, err, "parent: broadcast failed");
+
+  err = pthread_mutex_unlock (&mut);
+  if (err != 0)
+    error (EXIT_FAILURE, err, "mut unlocking failed");
+
+  /* Join all threads.  */
+  for (i = 0; i < N; ++i)
+    {
+      printf ("join thread %d\n", i);
+
+      err = pthread_join (th[i], NULL);
+      if (err != 0)
+	error (EXIT_FAILURE, err, "join of child %d failed", i);
+    }
+
+  puts ("done");
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cond20.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cond20.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cond20.c	(revision 2036)
@@ -0,0 +1,170 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#define N 10
+#define ROUNDS 1000
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_cond_t cond2 = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
+static pthread_barrier_t b;
+static int count;
+
+static void *
+tf (void *p)
+{
+  int i;
+  for (i = 0; i < ROUNDS; ++i)
+    {
+      pthread_mutex_lock (&mut);
+
+      if (++count == N)
+	pthread_cond_signal (&cond2);
+
+#ifdef TIMED
+      struct timeval tv;
+      gettimeofday (&tv, NULL);
+      struct timespec ts;
+      /* Wait three seconds.  */
+      ts.tv_sec = tv.tv_sec + 3;
+      ts.tv_nsec = tv.tv_usec * 1000;
+      pthread_cond_timedwait (&cond, &mut, &ts);
+#else
+      pthread_cond_wait (&cond, &mut);
+#endif
+
+      pthread_mutex_unlock (&mut);
+
+      int err = pthread_barrier_wait (&b);
+      if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  puts ("child: barrier_wait failed");
+	  exit (1);
+	}
+
+      err = pthread_barrier_wait (&b);
+      if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  puts ("child: barrier_wait failed");
+	  exit (1);
+	}
+    }
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  if (pthread_barrier_init (&b, NULL, N + 1) != 0)
+    {
+      puts ("barrier_init failed");
+      return 1;
+    }
+
+  pthread_mutex_lock (&mut);
+
+  int i, j, err;
+  pthread_t th[N];
+  for (i = 0; i < N; ++i)
+    if ((err = pthread_create (&th[i], NULL, tf, NULL)) != 0)
+      {
+	printf ("cannot create thread %d: %s\n", i, strerror (err));
+	return 1;
+      }
+
+  for (i = 0; i < ROUNDS; ++i)
+    {
+      pthread_cond_wait (&cond2, &mut);
+
+      if (i & 1)
+        pthread_mutex_unlock (&mut);
+
+      if (i & 2)
+	pthread_cond_broadcast (&cond);
+      else if (i & 4)
+	for (j = 0; j < N; ++j)
+	  pthread_cond_signal (&cond);
+      else
+	{
+	  for (j = 0; j < (i / 8) % N; ++j)
+	    pthread_cond_signal (&cond);
+	  pthread_cond_broadcast (&cond);
+	}
+
+      if ((i & 1) == 0)
+        pthread_mutex_unlock (&mut);
+
+      err = pthread_cond_destroy (&cond);
+      if (err)
+	{
+	  printf ("pthread_cond_destroy failed: %s\n", strerror (err));
+	  return 1;
+	}
+
+      /* Now clobber the cond variable which has been successfully
+         destroyed above.  */
+      memset (&cond, (char) i, sizeof (cond));
+
+      err = pthread_barrier_wait (&b);
+      if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  puts ("parent: barrier_wait failed");
+	  return 1;
+	}
+
+      pthread_mutex_lock (&mut);
+
+      err = pthread_barrier_wait (&b);
+      if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  puts ("parent: barrier_wait failed");
+	  return 1;
+	}
+
+      count = 0;
+      err = pthread_cond_init (&cond, NULL);
+      if (err)
+	{
+	  printf ("pthread_cond_init failed: %s\n", strerror (err));
+	  return 1;
+	}
+    }
+
+  for (i = 0; i < N; ++i)
+    if ((err = pthread_join (th[i], NULL)) != 0)
+      {
+	printf ("failed to join thread %d: %s\n", i, strerror (err));
+	return 1;
+      }
+
+  puts ("done");
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cond21.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cond21.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cond21.c	(revision 2036)
@@ -0,0 +1,3 @@
+#include <sys/time.h>
+#define TIMED 1
+#include "tst-cond20.c"
Index: trunk/src/libctests/glibc/nptl/tst-cond3.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cond3.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cond3.c	(revision 2036)
@@ -0,0 +1,113 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+/* Note that this test requires more than the standard.  It is
+   required that there are no spurious wakeups if only more readers
+   are added.  This is a reasonable demand.  */
+
+
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
+
+
+#define N 10
+
+
+static void *
+tf (void *arg)
+{
+  int i = (long int) arg;
+  int err;
+
+  /* Get the mutex.  */
+  err = pthread_mutex_lock (&mut);
+  if (err != 0)
+    {
+      printf ("child %d mutex_lock failed: %s\n", i, strerror (err));
+      exit (1);
+    }
+
+  /* This call should never return.  */
+  pthread_cond_wait (&cond, &mut);
+
+  /* We should never get here.  */
+  exit (1);
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  int err;
+  int i;
+
+  for (i = 0; i < N; ++i)
+    {
+      pthread_t th;
+
+      if (i != 0)
+	{
+	  /* Release the mutex.  */
+	  err = pthread_mutex_unlock (&mut);
+	  if (err != 0)
+	    {
+	      printf ("mutex_unlock %d failed: %s\n", i, strerror (err));
+	      return 1;
+	    }
+	}
+
+      err = pthread_create (&th, NULL, tf, (void *) (long int) i);
+      if (err != 0)
+	{
+	  printf ("create %d failed: %s\n", i, strerror (err));
+	  return 1;
+	}
+
+      /* Get the mutex.  */
+      err = pthread_mutex_lock (&mut);
+      if (err != 0)
+	{
+	  printf ("mutex_lock %d failed: %s\n", i, strerror (err));
+	  return 1;
+	}
+    }
+
+  /* Set an alarm for 1 second.  The wrapper will expect this.  */
+  alarm (1);
+
+  /* This call should never return.  */
+  pthread_cond_wait (&cond, &mut);
+
+  puts ("cond_wait returned");
+  return 1;
+}
+
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cond4.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cond4.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cond4.c	(revision 2036)
@@ -0,0 +1,263 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+
+int *condition;
+
+static int
+do_test (void)
+{
+  size_t ps = sysconf (_SC_PAGESIZE);
+  char tmpfname[] = "/tmp/tst-cond4.XXXXXX";
+  char data[ps];
+  void *mem;
+  int fd;
+  pthread_mutexattr_t ma;
+  pthread_mutex_t *mut1;
+  pthread_mutex_t *mut2;
+  pthread_condattr_t ca;
+  pthread_cond_t *cond;
+  pid_t pid;
+  int result = 0;
+  int p;
+
+  fd = mkstemp (tmpfname);
+  if (fd == -1)
+    {
+      printf ("cannot open temporary file: %m\n");
+      return 1;
+    }
+
+  /* Make sure it is always removed.  */
+  unlink (tmpfname);
+
+  /* Create one page of data.  */
+  memset (data, '\0', ps);
+
+  /* Write the data to the file.  */
+  if (write (fd, data, ps) != (ssize_t) ps)
+    {
+      puts ("short write");
+      return 1;
+    }
+
+  mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+  if (mem == MAP_FAILED)
+    {
+      printf ("mmap failed: %m\n");
+      return 1;
+    }
+
+  mut1 = (pthread_mutex_t *) (((uintptr_t) mem
+			       + __alignof (pthread_mutex_t))
+			      & ~(__alignof (pthread_mutex_t) - 1));
+  mut2 = mut1 + 1;
+
+  cond = (pthread_cond_t *) (((uintptr_t) (mut2 + 1)
+			      + __alignof (pthread_cond_t))
+			     & ~(__alignof (pthread_cond_t) - 1));
+
+  condition = (int *) (((uintptr_t) (cond + 1) + __alignof (int))
+		       & ~(__alignof (int) - 1));
+
+  if (pthread_mutexattr_init (&ma) != 0)
+    {
+      puts ("mutexattr_init failed");
+      return 1;
+    }
+
+  if (pthread_mutexattr_getpshared (&ma, &p) != 0)
+    {
+      puts ("1st mutexattr_getpshared failed");
+      return 1;
+    }
+
+  if (p != PTHREAD_PROCESS_PRIVATE)
+    {
+      puts ("default pshared value wrong");
+      return 1;
+    }
+
+  if (pthread_mutexattr_setpshared (&ma, PTHREAD_PROCESS_SHARED) != 0)
+    {
+      puts ("mutexattr_setpshared failed");
+      return 1;
+    }
+
+  if (pthread_mutexattr_getpshared (&ma, &p) != 0)
+    {
+      puts ("2nd mutexattr_getpshared failed");
+      return 1;
+    }
+
+  if (p != PTHREAD_PROCESS_SHARED)
+    {
+      puts ("pshared value after setpshared call wrong");
+      return 1;
+    }
+
+  if (pthread_mutex_init (mut1, &ma) != 0)
+    {
+      puts ("1st mutex_init failed");
+      return 1;
+    }
+
+  if (pthread_mutex_init (mut2, &ma) != 0)
+    {
+      puts ("2nd mutex_init failed");
+      return 1;
+    }
+
+  if (pthread_condattr_init (&ca) != 0)
+    {
+      puts ("condattr_init failed");
+      return 1;
+    }
+
+  if (pthread_condattr_getpshared (&ca, &p) != 0)
+    {
+      puts ("1st condattr_getpshared failed");
+      return 1;
+    }
+
+  if (p != PTHREAD_PROCESS_PRIVATE)
+    {
+      puts ("default value for pshared in condattr wrong");
+      return 1;
+    }
+
+  if (pthread_condattr_setpshared (&ca, PTHREAD_PROCESS_SHARED) != 0)
+    {
+      puts ("condattr_setpshared failed");
+      return 1;
+    }
+
+  if (pthread_condattr_getpshared (&ca, &p) != 0)
+    {
+      puts ("2nd condattr_getpshared failed");
+      return 1;
+    }
+
+  if (p != PTHREAD_PROCESS_SHARED)
+    {
+      puts ("pshared condattr still not set");
+      return 1;
+    }
+
+  if (pthread_cond_init (cond, &ca) != 0)
+    {
+      puts ("cond_init failed");
+      return 1;
+    }
+
+  if (pthread_mutex_lock (mut1) != 0)
+    {
+      puts ("parent: 1st mutex_lock failed");
+      return 1;
+    }
+
+  puts ("going to fork now");
+  pid = fork ();
+  if (pid == -1)
+    {
+      puts ("fork failed");
+      return 1;
+    }
+  else if (pid == 0)
+    {
+      if (pthread_mutex_lock (mut2) != 0)
+	{
+	  puts ("child: mutex_lock failed");
+	  return 1;
+	}
+
+      if (pthread_mutex_unlock (mut1) != 0)
+	{
+	  puts ("child: 1st mutex_unlock failed");
+	  return 1;
+	}
+
+      do
+	if (pthread_cond_wait (cond, mut2) != 0)
+	  {
+	    puts ("child: cond_wait failed");
+	    return 1;
+	  }
+      while (*condition == 0);
+
+      if (pthread_mutex_unlock (mut2) != 0)
+	{
+	  puts ("child: 2nd mutex_unlock failed");
+	  return 1;
+	}
+
+      puts ("child done");
+    }
+  else
+    {
+      int status;
+
+      if (pthread_mutex_lock (mut1) != 0)
+	{
+	  puts ("parent: 2nd mutex_lock failed");
+	  return 1;
+	}
+
+      if (pthread_mutex_lock (mut2) != 0)
+	{
+	  puts ("parent: 3rd mutex_lock failed");
+	  return 1;
+	}
+
+      if (pthread_cond_signal (cond) != 0)
+	{
+	  puts ("parent: cond_signal failed");
+	  return 1;
+	}
+
+      *condition = 1;
+
+      if (pthread_mutex_unlock (mut2) != 0)
+	{
+	  puts ("parent: mutex_unlock failed");
+	  return 1;
+	}
+
+      puts ("waiting for child");
+
+      waitpid (pid, &status, 0);
+      result |= status;
+
+      puts ("parent done");
+    }
+
+ return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cond5.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cond5.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cond5.c	(revision 2036)
@@ -0,0 +1,106 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <sys/time.h>
+
+
+static pthread_mutex_t mut;
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+
+
+static int
+do_test (void)
+{
+  pthread_mutexattr_t ma;
+  int err;
+  struct timespec ts;
+  struct timeval tv;
+
+  if (pthread_mutexattr_init (&ma) != 0)
+    {
+      puts ("mutexattr_init failed");
+      exit (1);
+    }
+
+  if (pthread_mutexattr_settype (&ma, PTHREAD_MUTEX_ERRORCHECK) != 0)
+    {
+      puts ("mutexattr_settype failed");
+      exit (1);
+    }
+
+  if (pthread_mutex_init (&mut, &ma) != 0)
+    {
+      puts ("mutex_init failed");
+      exit (1);
+    }
+
+  /* Get the mutex.  */
+  if (pthread_mutex_lock (&mut) != 0)
+    {
+      puts ("mutex_lock failed");
+      exit (1);
+    }
+
+  /* Waiting for the condition will fail.  But we want the timeout here.  */
+  if (gettimeofday (&tv, NULL) != 0)
+    {
+      puts ("gettimeofday failed");
+      exit (1);
+    }
+
+  TIMEVAL_TO_TIMESPEC (&tv, &ts);
+  ts.tv_nsec += 500000000;
+  if (ts.tv_nsec >= 1000000000)
+    {
+      ts.tv_nsec -= 1000000000;
+      ++ts.tv_sec;
+    }
+  err = pthread_cond_timedwait (&cond, &mut, &ts);
+  if (err == 0)
+    {
+      /* This could in theory happen but here without any signal and
+	 additional waiter it should not.  */
+      puts ("cond_timedwait succeeded");
+      exit (1);
+    }
+  else if (err != ETIMEDOUT)
+    {
+      printf ("cond_timedwait returned with %s\n", strerror (err));
+      exit (1);
+    }
+
+  err = pthread_mutex_unlock (&mut);
+  if (err != 0)
+    {
+      printf ("mutex_unlock failed: %s\n", strerror (err));
+      exit (1);
+    }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cond6.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cond6.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cond6.c	(revision 2036)
@@ -0,0 +1,233 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+
+
+int *condition;
+
+static int
+do_test (void)
+{
+  size_t ps = sysconf (_SC_PAGESIZE);
+  char tmpfname[] = "/tmp/tst-cond6.XXXXXX";
+  char data[ps];
+  void *mem;
+  int fd;
+  pthread_mutexattr_t ma;
+  pthread_mutex_t *mut1;
+  pthread_mutex_t *mut2;
+  pthread_condattr_t ca;
+  pthread_cond_t *cond;
+  pid_t pid;
+  int result = 0;
+
+  fd = mkstemp (tmpfname);
+  if (fd == -1)
+    {
+      printf ("cannot open temporary file: %m\n");
+      exit (1);
+    }
+
+  /* Make sure it is always removed.  */
+  unlink (tmpfname);
+
+  /* Create one page of data.  */
+  memset (data, '\0', ps);
+
+  /* Write the data to the file.  */
+  if (write (fd, data, ps) != (ssize_t) ps)
+    {
+      puts ("short write");
+      exit (1);
+    }
+
+  mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+  if (mem == MAP_FAILED)
+    {
+      printf ("mmap failed: %m\n");
+      exit (1);
+    }
+
+  mut1 = (pthread_mutex_t *) (((uintptr_t) mem
+			       + __alignof (pthread_mutex_t))
+			      & ~(__alignof (pthread_mutex_t) - 1));
+  mut2 = mut1 + 1;
+
+  cond = (pthread_cond_t *) (((uintptr_t) (mut2 + 1)
+			      + __alignof (pthread_cond_t))
+			     & ~(__alignof (pthread_cond_t) - 1));
+
+  condition = (int *) (((uintptr_t) (cond + 1) + __alignof (int))
+		       & ~(__alignof (int) - 1));
+
+  if (pthread_mutexattr_init (&ma) != 0)
+    {
+      puts ("mutexattr_init failed");
+      exit (1);
+    }
+
+  if (pthread_mutexattr_setpshared (&ma, PTHREAD_PROCESS_SHARED) != 0)
+    {
+      puts ("mutexattr_setpshared failed");
+      exit (1);
+    }
+
+  if (pthread_mutex_init (mut1, &ma) != 0)
+    {
+      puts ("1st mutex_init failed");
+      exit (1);
+    }
+
+  if (pthread_mutex_init (mut2, &ma) != 0)
+    {
+      puts ("2nd mutex_init failed");
+      exit (1);
+    }
+
+  if (pthread_condattr_init (&ca) != 0)
+    {
+      puts ("condattr_init failed");
+      exit (1);
+    }
+
+  if (pthread_condattr_setpshared (&ca, PTHREAD_PROCESS_SHARED) != 0)
+    {
+      puts ("condattr_setpshared failed");
+      exit (1);
+    }
+
+  if (pthread_cond_init (cond, &ca) != 0)
+    {
+      puts ("cond_init failed");
+      exit (1);
+    }
+
+  if (pthread_mutex_lock (mut1) != 0)
+    {
+      puts ("parent: 1st mutex_lock failed");
+      exit (1);
+    }
+
+  puts ("going to fork now");
+  pid = fork ();
+  if (pid == -1)
+    {
+      puts ("fork failed");
+      exit (1);
+    }
+  else if (pid == 0)
+    {
+      struct timespec ts;
+      struct timeval tv;
+
+      if (pthread_mutex_lock (mut2) != 0)
+	{
+	  puts ("child: mutex_lock failed");
+	  exit (1);
+	}
+
+      if (pthread_mutex_unlock (mut1) != 0)
+	{
+	  puts ("child: 1st mutex_unlock failed");
+	  exit (1);
+	}
+
+      if (gettimeofday (&tv, NULL) != 0)
+	{
+	  puts ("gettimeofday failed");
+	  exit (1);
+	}
+
+      TIMEVAL_TO_TIMESPEC (&tv, &ts);
+      ts.tv_nsec += 500000000;
+      if (ts.tv_nsec >= 1000000000)
+	{
+	  ts.tv_nsec -= 1000000000;
+	  ++ts.tv_sec;
+	}
+
+      do
+	if (pthread_cond_timedwait (cond, mut2, &ts) != 0)
+	  {
+	    puts ("child: cond_wait failed");
+	    exit (1);
+	  }
+      while (*condition == 0);
+
+      if (pthread_mutex_unlock (mut2) != 0)
+	{
+	  puts ("child: 2nd mutex_unlock failed");
+	  exit (1);
+	}
+
+      puts ("child done");
+    }
+  else
+    {
+      int status;
+
+      if (pthread_mutex_lock (mut1) != 0)
+	{
+	  puts ("parent: 2nd mutex_lock failed");
+	  exit (1);
+	}
+
+      if (pthread_mutex_lock (mut2) != 0)
+	{
+	  puts ("parent: 3rd mutex_lock failed");
+	  exit (1);
+	}
+
+      if (pthread_cond_signal (cond) != 0)
+	{
+	  puts ("parent: cond_signal failed");
+	  exit (1);
+	}
+
+      *condition = 1;
+
+      if (pthread_mutex_unlock (mut2) != 0)
+	{
+	  puts ("parent: mutex_unlock failed");
+	  exit (1);
+	}
+
+      puts ("waiting for child");
+
+      waitpid (pid, &status, 0);
+      result |= status;
+
+      puts ("parent done");
+    }
+
+ return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cond7.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cond7.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cond7.c	(revision 2036)
@@ -0,0 +1,168 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <sys/time.h>
+
+
+typedef struct
+  {
+    pthread_cond_t cond;
+    pthread_mutex_t lock;
+    pthread_t h;
+  } T;
+
+
+static volatile bool done;
+
+
+static void *
+tf (void *arg)
+{
+  puts ("child created");
+
+  if (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL) != 0
+      || pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, NULL) != 0)
+    {
+      puts ("cannot set cancellation options");
+      exit (1);
+    }
+
+  T *t = (T *) arg;
+
+  if (pthread_mutex_lock (&t->lock) != 0)
+    {
+      puts ("child: lock failed");
+      exit (1);
+    }
+
+  done = true;
+
+  if (pthread_cond_signal (&t->cond) != 0)
+    {
+      puts ("child: cond_signal failed");
+      exit (1);
+    }
+
+  if (pthread_cond_wait (&t->cond, &t->lock) != 0)
+    {
+      puts ("child: cond_wait failed");
+      exit (1);
+    }
+
+  if (pthread_mutex_unlock (&t->lock) != 0)
+    {
+      puts ("child: unlock failed");
+      exit (1);
+    }
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  int i;
+#define N 100
+  T *t[N];
+  for (i = 0; i < N; ++i)
+    {
+      printf ("round %d\n", i);
+
+      t[i] = (T *) malloc (sizeof (T));
+      if (t[i] == NULL)
+	{
+	  puts ("out of memory");
+	  exit (1);
+	}
+
+      if (pthread_mutex_init (&t[i]->lock, NULL) != 0
+	  || pthread_cond_init (&t[i]->cond, NULL) != 0)
+	{
+	  puts ("an _init function failed");
+	  exit (1);
+	}
+
+      if (pthread_mutex_lock (&t[i]->lock) != 0)
+	{
+	  puts ("initial mutex_lock failed");
+	  exit (1);
+	}
+
+      done = false;
+
+      if (pthread_create (&t[i]->h, NULL, tf, t[i]) != 0)
+	{
+	  puts ("pthread_create failed");
+	  exit (1);
+	}
+
+      do
+	if (pthread_cond_wait (&t[i]->cond, &t[i]->lock) != 0)
+	  {
+	    puts ("cond_wait failed");
+	    exit (1);
+	  }
+      while (! done);
+
+      /* Release the lock since the cancel handler will get it.  */
+      if (pthread_mutex_unlock (&t[i]->lock) != 0)
+	{
+	  puts ("mutex_unlock failed");
+	  exit (1);
+	}
+
+      if (pthread_cancel (t[i]->h) != 0)
+	{
+	  puts ("cancel failed");
+	  exit (1);
+	}
+
+      puts ("parent: joining now");
+
+      void *result;
+      if (pthread_join (t[i]->h, &result) != 0)
+	{
+	  puts ("join failed");
+	  exit (1);
+	}
+
+      if (result != PTHREAD_CANCELED)
+	{
+	  puts ("result != PTHREAD_CANCELED");
+	  exit (1);
+	}
+    }
+
+  for (i = 0; i < N; ++i)
+    free (t[i]);
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cond8.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cond8.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cond8.c	(revision 2036)
@@ -0,0 +1,277 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <sys/time.h>
+
+
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mut = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
+
+static pthread_barrier_t bar;
+
+
+static void
+ch (void *arg)
+{
+  int e = pthread_mutex_lock (&mut);
+  if (e == 0)
+    {
+      puts ("mutex not locked at all by cond_wait");
+      exit (1);
+    }
+
+  if (e != EDEADLK)
+    {
+      puts ("no deadlock error signaled");
+      exit (1);
+    }
+
+  if (pthread_mutex_unlock (&mut) != 0)
+    {
+      puts ("ch: cannot unlock mutex");
+      exit (1);
+    }
+
+  puts ("ch done");
+}
+
+
+static void *
+tf1 (void *p)
+{
+  int err;
+
+  if (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL) != 0
+      || pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, NULL) != 0)
+    {
+      puts ("cannot set cancellation options");
+      exit (1);
+    }
+
+  err = pthread_mutex_lock (&mut);
+  if (err != 0)
+    {
+      puts ("child: cannot get mutex");
+      exit (1);
+    }
+
+  err = pthread_barrier_wait (&bar);
+  if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("barrier_wait returned %d\n", err);
+      exit (1);
+    }
+
+  puts ("child: got mutex; waiting");
+
+  pthread_cleanup_push (ch, NULL);
+
+  pthread_cond_wait (&cond, &mut);
+
+  pthread_cleanup_pop (0);
+
+  puts ("child: cond_wait should not have returned");
+
+  return NULL;
+}
+
+
+static void *
+tf2 (void *p)
+{
+  int err;
+
+  if (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL) != 0
+      || pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, NULL) != 0)
+    {
+      puts ("cannot set cancellation options");
+      exit (1);
+    }
+
+  err = pthread_mutex_lock (&mut);
+  if (err != 0)
+    {
+      puts ("child: cannot get mutex");
+      exit (1);
+    }
+
+  err = pthread_barrier_wait (&bar);
+  if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      printf ("barrier_wait returned %d\n", err);
+      exit (1);
+    }
+
+  puts ("child: got mutex; waiting");
+
+  pthread_cleanup_push (ch, NULL);
+
+  /* Current time.  */
+  struct timeval tv;
+  (void) gettimeofday (&tv, NULL);
+  /* +1000 seconds in correct format.  */
+  struct timespec ts;
+  TIMEVAL_TO_TIMESPEC (&tv, &ts);
+  ts.tv_sec += 1000;
+
+  pthread_cond_timedwait (&cond, &mut, &ts);
+
+  pthread_cleanup_pop (0);
+
+  puts ("child: cond_wait should not have returned");
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t th;
+  int err;
+
+  printf ("&cond = %p\n&mut = %p\n", &cond, &mut);
+
+  puts ("parent: get mutex");
+
+  err = pthread_barrier_init (&bar, NULL, 2);
+  if (err != 0)
+    {
+      puts ("parent: cannot init barrier");
+      exit (1);
+    }
+
+  puts ("parent: create child");
+
+  err = pthread_create (&th, NULL, tf1, NULL);
+  if (err != 0)
+    {
+      puts ("parent: cannot create thread");
+      exit (1);
+    }
+
+  puts ("parent: wait for child to lock mutex");
+
+  err = pthread_barrier_wait (&bar);
+  if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("parent: cannot wait for barrier");
+      exit (1);
+    }
+
+  err = pthread_mutex_lock (&mut);
+  if (err != 0)
+    {
+      puts ("parent: mutex_lock failed");
+      exit (1);
+    }
+
+  err = pthread_mutex_unlock (&mut);
+  if (err != 0)
+    {
+      puts ("parent: mutex_unlock failed");
+      exit (1);
+    }
+
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("cannot cancel thread");
+      exit (1);
+    }
+
+  void *r;
+  err = pthread_join (th, &r);
+  if (err != 0)
+    {
+      puts ("parent: failed to join");
+      exit (1);
+    }
+
+  if (r != PTHREAD_CANCELED)
+    {
+      puts ("child hasn't been canceled");
+      exit (1);
+    }
+
+
+
+  puts ("parent: create 2nd child");
+
+  err = pthread_create (&th, NULL, tf2, NULL);
+  if (err != 0)
+    {
+      puts ("parent: cannot create thread");
+      exit (1);
+    }
+
+  puts ("parent: wait for child to lock mutex");
+
+  err = pthread_barrier_wait (&bar);
+  if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("parent: cannot wait for barrier");
+      exit (1);
+    }
+
+  err = pthread_mutex_lock (&mut);
+  if (err != 0)
+    {
+      puts ("parent: mutex_lock failed");
+      exit (1);
+    }
+
+  err = pthread_mutex_unlock (&mut);
+  if (err != 0)
+    {
+      puts ("parent: mutex_unlock failed");
+      exit (1);
+    }
+
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("cannot cancel thread");
+      exit (1);
+    }
+
+  err = pthread_join (th, &r);
+  if (err != 0)
+    {
+      puts ("parent: failed to join");
+      exit (1);
+    }
+
+  if (r != PTHREAD_CANCELED)
+    {
+      puts ("child hasn't been canceled");
+      exit (1);
+    }
+
+  puts ("done");
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-cond9.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-cond9.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-cond9.c	(revision 2036)
@@ -0,0 +1,150 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <sys/time.h>
+
+
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mut = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
+
+
+static void *
+tf (void *arg)
+{
+  int err = pthread_cond_wait (&cond, &mut);
+  if (err == 0)
+    {
+      puts ("cond_wait did not fail");
+      exit (1);
+    }
+
+  if (err != EPERM)
+    {
+      printf ("cond_wait didn't return EPERM but %d\n", err);
+      exit (1);
+    }
+
+
+  /* Current time.  */
+  struct timeval tv;
+  (void) gettimeofday (&tv, NULL);
+  /* +1000 seconds in correct format.  */
+  struct timespec ts;
+  TIMEVAL_TO_TIMESPEC (&tv, &ts);
+  ts.tv_sec += 1000;
+
+  err = pthread_cond_timedwait (&cond, &mut, &ts);
+  if (err == 0)
+    {
+      puts ("cond_timedwait did not fail");
+      exit (1);
+    }
+
+  if (err != EPERM)
+    {
+      printf ("cond_timedwait didn't return EPERM but %d\n", err);
+      exit (1);
+    }
+
+  return (void *) 1l;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t th;
+  int err;
+
+  printf ("&cond = %p\n&mut = %p\n", &cond, &mut);
+
+  err = pthread_cond_wait (&cond, &mut);
+  if (err == 0)
+    {
+      puts ("cond_wait did not fail");
+      exit (1);
+    }
+
+  if (err != EPERM)
+    {
+      printf ("cond_wait didn't return EPERM but %d\n", err);
+      exit (1);
+    }
+
+
+  /* Current time.  */
+  struct timeval tv;
+  (void) gettimeofday (&tv, NULL);
+  /* +1000 seconds in correct format.  */
+  struct timespec ts;
+  TIMEVAL_TO_TIMESPEC (&tv, &ts);
+  ts.tv_sec += 1000;
+
+  err = pthread_cond_timedwait (&cond, &mut, &ts);
+  if (err == 0)
+    {
+      puts ("cond_timedwait did not fail");
+      exit (1);
+    }
+
+  if (err != EPERM)
+    {
+      printf ("cond_timedwait didn't return EPERM but %d\n", err);
+      exit (1);
+    }
+
+  if (pthread_mutex_lock (&mut) != 0)
+    {
+      puts ("parent: mutex_lock failed");
+      exit (1);
+    }
+
+  puts ("creating thread");
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      exit (1);
+    }
+
+  void *r;
+  if (pthread_join (th, &r) != 0)
+    {
+      puts ("join failed");
+      exit (1);
+    }
+  if (r != (void *) 1l)
+    {
+      puts ("thread has wrong return value");
+      exit (1);
+    }
+
+  puts ("done");
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-context1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-context1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-context1.c	(revision 2036)
@@ -0,0 +1,206 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <error.h>
+#include <limits.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <ucontext.h>
+
+#define N	4
+#if __WORDSIZE == 64
+#define GUARD_PATTERN 0xdeadbeafdeadbeaf
+#else
+#define GUARD_PATTERN 0xdeadbeaf
+#endif
+
+typedef struct {
+       ucontext_t uctx;
+       unsigned long	guard[3];
+   } tst_context_t;
+
+static char stacks[N][2 * PTHREAD_STACK_MIN];
+static tst_context_t ctx[N][2];
+static volatile int failures;
+
+
+static void
+fct (long int n)
+{
+  char on_stack[1];
+
+  /* Just to use the thread local descriptor.  */
+  printf ("%ld: in %s now, on_stack = %p\n", n, __FUNCTION__, on_stack);
+  errno = 0;
+
+  if (ctx[n][1].uctx.uc_link != &ctx[n][0].uctx)
+    {
+      printf ("context[%ld][1] uc_link damaged, = %p\n", n,
+	      ctx[n][1].uctx.uc_link);
+      exit (1);
+    }
+
+  if ((ctx[n][0].guard[0] != GUARD_PATTERN)
+  ||  (ctx[n][0].guard[1] != GUARD_PATTERN)
+  ||  (ctx[n][0].guard[2] != GUARD_PATTERN))
+    {
+      printf ("%ld: %s context[0] overflow detected!\n", n, __FUNCTION__);
+      ++failures;
+    }
+
+  if ((ctx[n][1].guard[0] != GUARD_PATTERN)
+  ||  (ctx[n][1].guard[1] != GUARD_PATTERN)
+  ||  (ctx[n][1].guard[2] != GUARD_PATTERN))
+    {
+      printf ("%ld: %s context[1] overflow detected!\n", n, __FUNCTION__);
+      ++failures;
+    }
+
+  if (n < 0 || n >= N)
+    {
+      printf ("%ld out of range\n", n);
+      exit (1);
+    }
+
+  if (on_stack < stacks[n] || on_stack >= stacks[n] + sizeof (stacks[0]))
+    {
+      printf ("%ld: on_stack not on appropriate stack\n", n);
+      exit (1);
+    }
+}
+
+
+static void *
+tf (void *arg)
+{
+  int n = (int) (long int) arg;
+
+  ctx[n][0].guard[0] = GUARD_PATTERN;
+  ctx[n][0].guard[1] = GUARD_PATTERN;
+  ctx[n][0].guard[2] = GUARD_PATTERN;
+
+  ctx[n][1].guard[0] = GUARD_PATTERN;
+  ctx[n][1].guard[1] = GUARD_PATTERN;
+  ctx[n][1].guard[2] = GUARD_PATTERN;
+
+  if (getcontext (&ctx[n][1].uctx) != 0)
+    {
+      printf ("%d: cannot get context: %m\n", n);
+      exit (1);
+    }
+
+  printf ("%d: %s: before makecontext\n", n, __FUNCTION__);
+
+  ctx[n][1].uctx.uc_stack.ss_sp = stacks[n];
+  ctx[n][1].uctx.uc_stack.ss_size = sizeof (stacks[n]);
+  ctx[n][1].uctx.uc_link = &ctx[n][0].uctx;
+  makecontext (&ctx[n][1].uctx, (void (*) (void)) fct, 1, (long int) n);
+
+  printf ("%d: %s: before swapcontext\n", n, __FUNCTION__);
+
+  if (swapcontext (&ctx[n][0].uctx, &ctx[n][1].uctx) != 0)
+    {
+      ++failures;
+      printf ("%d: %s: swapcontext failed\n", n, __FUNCTION__);
+    }
+  else
+    printf ("%d: back in %s\n", n, __FUNCTION__);
+
+  return NULL;
+}
+
+
+static volatile int global;
+
+
+static int
+do_test (void)
+{
+  int n;
+  pthread_t th[N];
+  ucontext_t mctx;
+
+  puts ("making contexts");
+  if (getcontext (&mctx) != 0)
+    {
+      if (errno == ENOSYS)
+	{
+	  puts ("context handling not supported");
+	  exit (0);
+	}
+
+      printf ("%s: getcontext: %m\n", __FUNCTION__);
+      exit (1);
+    }
+
+  /* Play some tricks with this context.  */
+  if (++global == 1)
+    if (setcontext (&mctx) != 0)
+      {
+	puts ("setcontext failed");
+	exit (1);
+      }
+  if (global != 2)
+    {
+      puts ("global not incremented twice");
+      exit (1);
+    }
+  puts ("global OK");
+
+  pthread_attr_t at;
+
+  if (pthread_attr_init (&at) != 0)
+    {
+      puts ("attr_init failed");
+      return 1;
+    }
+
+  if (pthread_attr_setstacksize (&at, 1 * 1024 * 1024) != 0)
+    {
+      puts ("attr_setstacksize failed");
+      return 1;
+    }
+
+  for (n = 0; n < N; ++n)
+    if (pthread_create (&th[n], &at, tf, (void *) (long int) n) != 0)
+      {
+	puts ("create failed");
+	exit (1);
+      }
+
+  if (pthread_attr_destroy (&at) != 0)
+    {
+      puts ("attr_destroy failed");
+      return 1;
+    }
+
+  for (n = 0; n < N; ++n)
+    if (pthread_join (th[n], NULL) != 0)
+      {
+	puts ("join failed");
+	exit (1);
+      }
+
+  return failures;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-detach1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-detach1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-detach1.c	(revision 2036)
@@ -0,0 +1,56 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static void *
+tf (void *arg)
+{
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, (void *) pthread_self ()) != 0)
+    {
+      puts ("create failed");
+      exit (1);
+    }
+
+  /* Give the child a chance to finish.  */
+  sleep (1);
+
+  if (pthread_detach (th) != 0)
+    {
+      puts ("detach failed");
+      exit (1);
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-dlsym1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-dlsym1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-dlsym1.c	(revision 2036)
@@ -0,0 +1,66 @@
+/* Test case by Hui Huang <hui.huang@sun.com>.  */
+#include <dlfcn.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static void *
+start_routine (void *args)
+{
+  int i;
+  void **addrs = (void **) args;
+  for (i = 0; i < 10000; ++i)
+    addrs[i % 1024] = dlsym (NULL, "does_not_exist");
+
+  return addrs;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t tid1, tid2, tid3;
+
+  void *addrs1[1024];
+  void *addrs2[1024];
+  void *addrs3[1024];
+
+  if (pthread_create (&tid1, NULL, start_routine, addrs1) != 0)
+    {
+      puts ("1st create failed");
+      exit (1);
+    }
+  if (pthread_create (&tid2, NULL, start_routine, addrs2) != 0)
+    {
+      puts ("2nd create failed");
+      exit (1);
+    }
+  if (pthread_create (&tid3, NULL, start_routine, addrs3) != 0)
+    {
+      puts ("3rd create failed");
+      exit (1);
+    }
+
+  if (pthread_join (tid1, NULL) != 0)
+    {
+      puts ("1st join failed");
+      exit (1);
+    }
+  if (pthread_join (tid2, NULL) != 0)
+    {
+      puts ("2nd join failed");
+      exit (1);
+    }
+  if (pthread_join (tid3, NULL) != 0)
+    {
+      puts ("2rd join failed");
+      exit (1);
+    }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-eintr1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-eintr1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-eintr1.c	(revision 2036)
@@ -0,0 +1,105 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "eintr.c"
+
+
+static void *
+tf2 (void *arg)
+{
+  return arg;
+}
+
+
+static void *
+tf1 (void *arg)
+{
+  while (1)
+    {
+      pthread_t th;
+
+      int e = pthread_create (&th, NULL, tf2, NULL);
+      if (e != 0)
+	{
+	  if (e == EINTR)
+	    {
+	      puts ("pthread_create returned EINTR");
+	      exit (1);
+	    }
+
+	  char buf[100];
+	  printf ("tf1: pthread_create failed: %s\n",
+		  strerror_r (e, buf, sizeof (buf)));
+	  exit (1);
+	}
+
+      e = pthread_join (th, NULL);
+      if (e != 0)
+	{
+	  if (e == EINTR)
+	    {
+	      puts ("pthread_join returned EINTR");
+	      exit (1);
+	    }
+
+	  char buf[100];
+	  printf ("tf1: pthread_join failed: %s\n",
+		  strerror_r (e, buf, sizeof (buf)));
+	  exit (1);
+	}
+    }
+}
+
+
+static int
+do_test (void)
+{
+  setup_eintr (SIGUSR1, NULL);
+
+  int i;
+  for (i = 0; i < 10; ++i)
+    {
+      pthread_t th;
+      int e = pthread_create (&th, NULL, tf1, NULL);
+      if (e != 0)
+	{
+	  char buf[100];
+	  printf ("main: pthread_create failed: %s\n",
+		  strerror_r (e, buf, sizeof (buf)));
+	  exit (1);
+	}
+    }
+
+  (void) tf1 (NULL);
+  /* NOTREACHED */
+
+  return 0;
+}
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TIMEOUT 3
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-eintr2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-eintr2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-eintr2.c	(revision 2036)
@@ -0,0 +1,118 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+
+#include "eintr.c"
+
+
+static pthread_mutex_t m1 = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t m2 = PTHREAD_MUTEX_INITIALIZER;
+
+
+static void *
+tf1 (void *arg)
+{
+  struct timespec ts;
+  struct timeval tv;
+
+  gettimeofday (&tv, NULL);
+  TIMEVAL_TO_TIMESPEC (&tv, &ts);
+  ts.tv_sec += 10000;
+
+  /* This call must never return.  */
+  int e = pthread_mutex_timedlock (&m1, &ts);
+  char buf[100];
+  printf ("tf1: mutex_timedlock returned: %s\n",
+	  strerror_r (e, buf, sizeof (buf)));
+
+  exit (1);
+}
+
+
+static void *
+tf2 (void *arg)
+{
+  while (1)
+    {
+      int e = pthread_mutex_lock (&m2);
+      if (e != 0)
+	{
+	  puts ("tf2: mutex_lock failed");
+	  exit (1);
+	}
+      e = pthread_mutex_unlock (&m2);
+      if (e != 0)
+	{
+	  puts ("tf2: mutex_unlock failed");
+	  exit (1);
+	}
+      struct timespec ts = { .tv_sec = 0, .tv_nsec = 10000000 };
+      nanosleep (&ts, NULL);
+    }
+}
+
+
+static int
+do_test (void)
+{
+  if (pthread_mutex_lock (&m1) != 0)
+    {
+      puts ("mutex_lock failed");
+      exit (1);
+    }
+
+  setup_eintr (SIGUSR1, NULL);
+
+  pthread_t th;
+  char buf[100];
+  int e = pthread_create (&th, NULL, tf1, NULL);
+  if (e != 0)
+    {
+      printf ("main: 1st pthread_create failed: %s\n",
+	      strerror_r (e, buf, sizeof (buf)));
+      exit (1);
+    }
+
+  e = pthread_create (&th, NULL, tf2, NULL);
+  if (e != 0)
+    {
+      printf ("main: 2nd pthread_create failed: %s\n",
+	      strerror_r (e, buf, sizeof (buf)));
+      exit (1);
+    }
+
+  /* This call must never return.  */
+  e = pthread_mutex_lock (&m1);
+  printf ("main: mutex_lock returned: %s\n",
+	  strerror_r (e, buf, sizeof (buf)));
+
+  return 0;
+}
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TIMEOUT 3
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-eintr3.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-eintr3.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-eintr3.c	(revision 2036)
@@ -0,0 +1,72 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "eintr.c"
+
+
+static void *
+tf (void *arg)
+{
+  pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
+  pthread_mutex_lock (&m);
+  /* This call must not return.  */
+  pthread_mutex_lock (&m);
+
+  puts ("tf: mutex_lock returned");
+  exit (1);
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t self = pthread_self ();
+
+  setup_eintr (SIGUSR1, &self);
+
+  pthread_t th;
+  char buf[100];
+  int e = pthread_create (&th, NULL, tf, NULL);
+  if (e != 0)
+    {
+      printf ("main: pthread_create failed: %s\n",
+	      strerror_r (e, buf, sizeof (buf)));
+      exit (1);
+    }
+
+  /* This call must never return.  */
+  e = pthread_join (th, NULL);
+
+  if (e == EINTR)
+    puts ("pthread_join returned with EINTR");
+
+  return 0;
+}
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TIMEOUT 1
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-eintr4.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-eintr4.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-eintr4.c	(revision 2036)
@@ -0,0 +1,56 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "eintr.c"
+
+
+static int
+do_test (void)
+{
+  pthread_t self = pthread_self ();
+
+  setup_eintr (SIGUSR1, &self);
+
+  pthread_barrier_t b;
+  if (pthread_barrier_init (&b, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  /* This call must never return.  */
+  int e = pthread_barrier_wait (&b);
+
+  if (e == EINTR)
+    puts ("pthread_join returned with EINTR");
+
+  return 0;
+}
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TIMEOUT 1
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-eintr5.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-eintr5.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-eintr5.c	(revision 2036)
@@ -0,0 +1,81 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+
+#include "eintr.c"
+
+
+static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t c = PTHREAD_COND_INITIALIZER;
+
+
+static void *
+tf (void *arg)
+{
+  struct timespec ts;
+  struct timeval tv;
+
+  gettimeofday (&tv, NULL);
+  TIMEVAL_TO_TIMESPEC (&tv, &ts);
+  ts.tv_sec += 10000;
+
+  /* This call must never return.  */
+  int e = pthread_cond_timedwait (&c, &m, &ts);
+  char buf[100];
+  printf ("tf: cond_timedwait returned: %s\n",
+	  strerror_r (e, buf, sizeof (buf)));
+
+  exit (1);
+}
+
+
+static int
+do_test (void)
+{
+  setup_eintr (SIGUSR1, NULL);
+
+  pthread_t th;
+  char buf[100];
+  int e = pthread_create (&th, NULL, tf, NULL);
+  if (e != 0)
+    {
+      printf ("main: pthread_create failed: %s\n",
+	      strerror_r (e, buf, sizeof (buf)));
+      exit (1);
+    }
+
+  /* This call must never return.  */
+  e = pthread_cond_wait (&c, &m);
+  printf ("main: cond_wait returned: %s\n",
+	  strerror_r (e, buf, sizeof (buf)));
+
+  return 0;
+}
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TIMEOUT 3
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-exec1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-exec1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-exec1.c	(revision 2036)
@@ -0,0 +1,160 @@
+/* Simple exec test, only a thread in the parent.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <paths.h>
+#include <pthread.h>
+#include <signal.h>
+#include <spawn.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+
+static void *
+tf (void *arg)
+{
+  pthread_t th = (pthread_t) arg;
+
+  if (pthread_join (th, NULL) == 0)
+    {
+      puts ("thread in parent joined!?");
+      exit (1);
+    }
+
+  puts ("join in thread in parent returned!?");
+  exit (1);
+}
+
+
+static int
+do_test (void)
+{
+  int fd[2];
+  if (pipe (fd) != 0)
+    {
+      puts ("pipe failed");
+      exit (1);
+    }
+
+  /* Not interested in knowing when the pipe is closed.  */
+  if (sigignore (SIGPIPE) != 0)
+    {
+      puts ("sigignore failed");
+      exit (1);
+    }
+
+  posix_spawn_file_actions_t a;
+  if (posix_spawn_file_actions_init (&a) != 0)
+    {
+      puts ("spawn_file_actions_init failed");
+      exit (1);
+    }
+
+  if (posix_spawn_file_actions_adddup2 (&a, fd[1], STDOUT_FILENO) != 0)
+    {
+      puts ("spawn_file_actions_adddup2 failed");
+      exit (1);
+    }
+
+  if (posix_spawn_file_actions_addclose (&a, fd[0]) != 0)
+    {
+      puts ("spawn_file_actions_addclose");
+      exit (1);
+    }
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, (void *) pthread_self ()) != 0)
+    {
+      puts ("create failed");
+      exit (1);
+    }
+
+  pid_t pid;
+  char *argv[] = { (char *) _PATH_BSHELL, (char *) "-c", (char *) "echo $$",
+		   NULL };
+  if (posix_spawn (&pid, _PATH_BSHELL, &a, NULL, argv, NULL) != 0)
+    {
+      puts ("spawn failed");
+      exit (1);
+    }
+
+  close (fd[1]);
+
+  char buf[200];
+  ssize_t n;
+  bool seen_pid = false;
+  while (TEMP_FAILURE_RETRY ((n = read (fd[0], buf, sizeof (buf)))) > 0)
+    {
+      /* We only expect to read the PID.  */
+      char *endp;
+      long int rpid = strtol (buf, &endp, 10);
+
+      if (*endp != '\n')
+	{
+	  printf ("didn't parse whole line: \"%s\"\n", buf);
+	  exit (1);
+	}
+      if (endp == buf)
+	{
+	  puts ("read empty line");
+	  exit (1);
+	}
+
+      if (rpid != pid)
+	{
+	  printf ("found \"%s\", expected PID %ld\n", buf, (long int) pid);
+	  exit (1);
+	}
+
+      if (seen_pid)
+	{
+	  puts ("found more than one PID line");
+	  exit (1);
+	}
+
+      seen_pid = true;
+    }
+
+  close (fd[0]);
+
+  int status;
+  int err = waitpid (pid, &status, 0);
+  if (err != pid)
+    {
+      puts ("waitpid failed");
+      exit (1);
+    }
+
+  if (!seen_pid)
+    {
+      puts ("didn't get PID");
+      exit (1);
+    }
+
+  puts ("read correct PID");
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-exec2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-exec2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-exec2.c	(revision 2036)
@@ -0,0 +1,155 @@
+/* Thread with running thread calls exec.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <paths.h>
+#include <pthread.h>
+#include <signal.h>
+#include <spawn.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+
+static void *
+tf (void *arg)
+{
+  pthread_t th = (pthread_t) arg;
+
+  if (pthread_join (th, NULL) == 0)
+    {
+      puts ("thread in parent joined!?");
+      exit (1);
+    }
+
+  puts ("join in thread in parent returned!?");
+  exit (1);
+}
+
+
+static int
+do_test (void)
+{
+  int fd[2];
+  if (pipe (fd) != 0)
+    {
+      puts ("pipe failed");
+      exit (1);
+    }
+
+  /* Not interested in knowing when the pipe is closed.  */
+  if (sigignore (SIGPIPE) != 0)
+    {
+      puts ("sigignore failed");
+      exit (1);
+    }
+
+  pid_t pid = fork ();
+  if (pid == -1)
+    {
+      puts ("fork failed");
+      exit (1);
+    }
+
+  if (pid == 0)
+    {
+      /* Use the fd for stdout.  This is kind of ugly because it
+	 substitutes the fd of stdout but we know what we are doing
+	 here...  */
+      if (dup2 (fd[1], STDOUT_FILENO) != STDOUT_FILENO)
+	{
+	  puts ("dup2 failed");
+	  exit (1);
+	}
+
+      close (fd[0]);
+
+      pthread_t th;
+      if (pthread_create (&th, NULL, tf, (void *) pthread_self ()) != 0)
+	{
+	  puts ("create failed");
+	  exit (1);
+	}
+
+      execl (_PATH_BSHELL, _PATH_BSHELL, "-c", "echo $$", NULL);
+
+      puts ("execl failed");
+      exit (1);
+    }
+
+  close (fd[1]);
+
+  char buf[200];
+  ssize_t n;
+  bool seen_pid = false;
+  while (TEMP_FAILURE_RETRY ((n = read (fd[0], buf, sizeof (buf)))) > 0)
+    {
+      /* We only expect to read the PID.  */
+      char *endp;
+      long int rpid = strtol (buf, &endp, 10);
+
+      if (*endp != '\n')
+	{
+	  printf ("didn't parse whole line: \"%s\"\n", buf);
+	  exit (1);
+	}
+      if (endp == buf)
+	{
+	  puts ("read empty line");
+	  exit (1);
+	}
+
+      if (rpid != pid)
+	{
+	  printf ("found \"%s\", expected PID %ld\n", buf, (long int) pid);
+	  exit (1);
+	}
+
+      if (seen_pid)
+	{
+	  puts ("found more than one PID line");
+	  exit (1);
+	}
+      seen_pid = true;
+    }
+
+  close (fd[0]);
+
+  int status;
+  int err = waitpid (pid, &status, 0);
+  if (err != pid)
+    {
+      puts ("waitpid failed");
+      exit (1);
+    }
+
+  if (!seen_pid)
+    {
+      puts ("didn't get PID");
+      exit (1);
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-exec3.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-exec3.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-exec3.c	(revision 2036)
@@ -0,0 +1,153 @@
+/* Thread calls exec.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <paths.h>
+#include <pthread.h>
+#include <signal.h>
+#include <spawn.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+
+static void *
+tf (void *arg)
+{
+  execl (_PATH_BSHELL, _PATH_BSHELL, "-c", "echo $$", NULL);
+
+  puts ("execl failed");
+  exit (1);
+}
+
+
+static int
+do_test (void)
+{
+  int fd[2];
+  if (pipe (fd) != 0)
+    {
+      puts ("pipe failed");
+      exit (1);
+    }
+
+  /* Not interested in knowing when the pipe is closed.  */
+  if (sigignore (SIGPIPE) != 0)
+    {
+      puts ("sigignore failed");
+      exit (1);
+    }
+
+  pid_t pid = fork ();
+  if (pid == -1)
+    {
+      puts ("fork failed");
+      exit (1);
+    }
+
+  if (pid == 0)
+    {
+      /* Use the fd for stdout.  This is kind of ugly because it
+	 substitutes the fd of stdout but we know what we are doing
+	 here...  */
+      if (dup2 (fd[1], STDOUT_FILENO) != STDOUT_FILENO)
+	{
+	  puts ("dup2 failed");
+	  exit (1);
+	}
+
+      close (fd[0]);
+
+      pthread_t th;
+      if (pthread_create (&th, NULL, tf, NULL) != 0)
+	{
+	  puts ("create failed");
+	  exit (1);
+	}
+
+      if (pthread_join (th, NULL) == 0)
+	{
+	  puts ("join succeeded!?");
+	  exit (1);
+	}
+
+      puts ("join returned!?");
+      exit (1);
+    }
+
+  close (fd[1]);
+
+  char buf[200];
+  ssize_t n;
+  bool seen_pid = false;
+  while (TEMP_FAILURE_RETRY ((n = read (fd[0], buf, sizeof (buf)))) > 0)
+    {
+      /* We only expect to read the PID.  */
+      char *endp;
+      long int rpid = strtol (buf, &endp, 10);
+
+      if (*endp != '\n')
+	{
+	  printf ("didn't parse whole line: \"%s\"\n", buf);
+	  exit (1);
+	}
+      if (endp == buf)
+	{
+	  puts ("read empty line");
+	  exit (1);
+	}
+
+      if (rpid != pid)
+	{
+	  printf ("found \"%s\", expected PID %ld\n", buf, (long int) pid);
+	  exit (1);
+	}
+
+      if (seen_pid)
+	{
+	  puts ("found more than one PID line");
+	  exit (1);
+	}
+      seen_pid = true;
+    }
+
+  close (fd[0]);
+
+  int status;
+  int err = waitpid (pid, &status, 0);
+  if (err != pid)
+    {
+      puts ("waitpid failed");
+      exit (1);
+    }
+
+  if (!seen_pid)
+    {
+      puts ("didn't get PID");
+      exit (1);
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-exec4.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-exec4.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-exec4.c	(revision 2036)
@@ -0,0 +1,116 @@
+/* Signal handler and mask set in thread which calls exec.
+   Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static void *
+tf (void *arg)
+{
+  /* Ignore SIGUSR1 and block SIGUSR2.  */
+  if (sigignore (SIGUSR1) != 0)
+    {
+      puts ("sigignore failed");
+      exit (1);
+    }
+
+  sigset_t ss;
+  sigemptyset (&ss);
+  sigaddset (&ss, SIGUSR2);
+  if (pthread_sigmask (SIG_BLOCK, &ss, NULL) != 0)
+    {
+      puts ("1st run: sigmask failed");
+      exit (1);
+    }
+
+  char **oldargv = (char **) arg;
+  size_t n = 1;
+  while (oldargv[n] != NULL)
+    ++n;
+
+  char **argv = (char **) alloca ((n + 1) * sizeof (char *));
+  for (n = 0; oldargv[n + 1] != NULL; ++n)
+    argv[n] = oldargv[n + 1];
+  argv[n++] = (char *) "--direct";
+  argv[n] = NULL;
+
+  execv (argv[0], argv);
+
+  puts ("execv failed");
+
+  exit (1);
+}
+
+
+static int
+do_test (int argc, char *argv[])
+{
+  if (argc == 1)
+    {
+      /* This is the second call.  Perform the test.  */
+      struct sigaction sa;
+
+      if (sigaction (SIGUSR1, NULL, &sa) != 0)
+	{
+	  puts ("2nd run: sigaction failed");
+	  return 1;
+	}
+      if (sa.sa_handler != SIG_IGN)
+	{
+	  puts ("SIGUSR1 not ignored");
+	  return 1;
+	}
+
+      sigset_t ss;
+      if (pthread_sigmask (SIG_SETMASK, NULL, &ss) != 0)
+	{
+	  puts ("2nd run: sigmask failed");
+	  return 1;
+	}
+      if (! sigismember (&ss, SIGUSR2))
+	{
+	  puts ("SIGUSR2 not blocked");
+	  return 1;
+	}
+
+      return 0;
+    }
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, argv) != 0)
+    {
+      puts ("create failed");
+      exit (1);
+    }
+
+  /* This call should never return.  */
+  pthread_join (th, NULL);
+
+  puts ("join returned");
+
+  return 1;
+}
+
+#define TEST_FUNCTION do_test (argc, argv)
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-execstack-mod.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-execstack-mod.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-execstack-mod.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "../elf/tst-execstack-mod.c"
Index: trunk/src/libctests/glibc/nptl/tst-execstack.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-execstack.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-execstack.c	(revision 2036)
@@ -0,0 +1,2 @@
+#define USE_PTHREADS 1
+#include "../elf/tst-execstack.c"
Index: trunk/src/libctests/glibc/nptl/tst-exit1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-exit1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-exit1.c	(revision 2036)
@@ -0,0 +1,79 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* NOTE: this tests functionality beyond POSIX.  POSIX does not allow
+   exit to be called more than once.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static pthread_barrier_t b;
+
+
+static void *
+tf (void *arg)
+{
+  int r = pthread_barrier_wait (&b);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      exit (1);
+    }
+
+  exit (0);
+}
+
+
+static int
+do_test (void)
+{
+  if (pthread_barrier_init (&b, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      exit (1);
+    }
+
+  int r = pthread_barrier_wait (&b);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      exit (1);
+    }
+
+  /* Do nothing.  */
+  if (pthread_join (th, NULL) == 0)
+    {
+      puts ("join succeeded!?");
+      exit (1);
+    }
+
+  puts ("join returned!?");
+  exit (1);
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-exit2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-exit2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-exit2.c	(revision 2036)
@@ -0,0 +1,40 @@
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static void *
+tf (void *arg)
+{
+  while (1)
+    sleep (100);
+
+  /* NOTREACHED */
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t th;
+
+  int e = pthread_create (&th, NULL, tf, NULL);
+  if (e != 0)
+    {
+      printf ("create failed: %s\n", strerror (e));
+      return 1;
+    }
+
+  /* Terminate only this thread.  */
+  pthread_exit (NULL);
+
+  /* NOTREACHED */
+  return 1;
+}
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-exit3.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-exit3.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-exit3.c	(revision 2036)
@@ -0,0 +1,81 @@
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static pthread_barrier_t b;
+
+
+static void *
+tf2 (void *arg)
+{
+  while (1)
+    sleep (100);
+
+  /* NOTREACHED */
+  return NULL;
+}
+
+
+static void *
+tf (void *arg)
+{
+  pthread_t th;
+
+  int e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      exit (1);
+    }
+
+  e = pthread_create (&th, NULL, tf2, NULL);
+  if (e != 0)
+    {
+      printf ("create failed: %s\n", strerror (e));
+      exit (1);
+    }
+
+  /* Terminate only this thread.  */
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t th;
+
+  if (pthread_barrier_init (&b, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  int e = pthread_create (&th, NULL, tf, NULL);
+  if (e != 0)
+    {
+      printf ("create failed: %s\n", strerror (e));
+      exit (1);
+    }
+
+  e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      exit (1);
+    }
+
+  /* Terminate only this thread.  */
+  pthread_exit (NULL);
+
+  /* NOTREACHED */
+  return 1;
+}
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-fini1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-fini1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-fini1.c	(revision 2036)
@@ -0,0 +1,35 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <unistd.h>
+
+extern void m (void);
+
+int
+main (void)
+{
+  alarm (5);
+
+  m ();
+
+  /* The destructor is supposed to run now.  Make sure that if it is
+     not we will notice it by using 42 as the exit code.  In case the
+     destructor is run it will terminate with status zero.  */
+  return 42;
+}
Index: trunk/src/libctests/glibc/nptl/tst-fini1mod.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-fini1mod.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-fini1mod.c	(revision 2036)
@@ -0,0 +1,72 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static void *
+tf (void *arg)
+{
+  int fds[2];
+  if (pipe (fds) != 0)
+    {
+      puts ("pipe failed");
+      exit (1);
+    }
+
+  char buf[10];
+  read (fds[0], buf, sizeof (buf));
+
+  puts ("read returned");
+  exit (1);
+}
+
+static pthread_t th;
+
+static void
+__attribute ((destructor))
+dest (void)
+{
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("cancel failed");
+      _exit (1);
+    }
+  void *r;
+  if (pthread_join (th, &r) != 0)
+    {
+      puts ("join failed");
+      _exit (1);
+    }
+  /* Exit successfully.  */
+  _exit (0);
+}
+
+void
+m (void)
+{
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      _exit (1);
+    }
+}
Index: trunk/src/libctests/glibc/nptl/tst-flock1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-flock1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-flock1.c	(revision 2036)
@@ -0,0 +1,93 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/file.h>
+
+
+static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+
+static int fd;
+
+
+static void *
+tf (void *arg)
+{
+  if (flock (fd, LOCK_SH | LOCK_NB) != 0)
+    {
+      puts ("second flock failed");
+      exit (1);
+    }
+
+  pthread_mutex_unlock (&lock);
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  char tmp[] = "/tmp/tst-flock1-XXXXXX";
+
+  fd = mkstemp (tmp);
+  if (fd == -1)
+    {
+      puts ("mkstemp failed");
+      exit (1);
+    }
+
+  unlink (tmp);
+
+  write (fd, "foobar xyzzy", 12);
+
+  if (flock (fd, LOCK_EX | LOCK_NB) != 0)
+    {
+      puts ("first flock failed");
+      exit (1);
+    }
+
+  pthread_mutex_lock (&lock);
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("pthread_create failed");
+      exit (1);
+    }
+
+  pthread_mutex_lock (&lock);
+
+  void *result;
+  if (pthread_join (th, &result) != 0)
+    {
+      puts ("pthread_join failed");
+      exit (1);
+    }
+
+  close (fd);
+
+  return result != NULL;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-flock2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-flock2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-flock2.c	(revision 2036)
@@ -0,0 +1,260 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/file.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+
+static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t lock2 = PTHREAD_MUTEX_INITIALIZER;
+static int fd;
+
+
+static void *
+tf (void *arg)
+{
+  struct flock fl =
+    {
+      .l_type = F_WRLCK,
+      .l_start = 0,
+      .l_whence = SEEK_SET,
+      .l_len = 10
+    };
+  if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLKW, &fl)) != 0)
+    {
+      puts ("fourth fcntl failed");
+      exit (1);
+    }
+
+  pthread_mutex_unlock (&lock);
+
+  pthread_mutex_lock (&lock2);
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  char tmp[] = "/tmp/tst-flock2-XXXXXX";
+
+  fd = mkstemp (tmp);
+  if (fd == -1)
+    {
+      puts ("mkstemp failed");
+      return 1;
+    }
+
+  unlink (tmp);
+
+  int i;
+  for (i = 0; i < 20; ++i)
+    write (fd, "foobar xyzzy", 12);
+
+  pthread_barrier_t *b;
+  b = mmap (NULL, sizeof (pthread_barrier_t), PROT_READ | PROT_WRITE,
+	    MAP_SHARED, fd, 0);
+  if (b == MAP_FAILED)
+    {
+      puts ("mmap failed");
+      return 1;
+    }
+
+  pthread_barrierattr_t ba;
+  if (pthread_barrierattr_init (&ba) != 0)
+    {
+      puts ("barrierattr_init failed");
+      return 1;
+    }
+
+  if (pthread_barrierattr_setpshared (&ba, PTHREAD_PROCESS_SHARED) != 0)
+    {
+      puts ("barrierattr_setpshared failed");
+      return 1;
+    }
+
+  if (pthread_barrier_init (b, &ba, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      return 1;
+    }
+
+  if (pthread_barrierattr_destroy (&ba) != 0)
+    {
+      puts ("barrierattr_destroy failed");
+      return 1;
+    }
+
+  struct flock fl =
+    {
+      .l_type = F_WRLCK,
+      .l_start = 0,
+      .l_whence = SEEK_SET,
+      .l_len = 10
+    };
+  if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLKW, &fl)) != 0)
+    {
+      puts ("first fcntl failed");
+      return 1;
+    }
+
+  pid_t pid = fork ();
+  if (pid == -1)
+    {
+      puts ("fork failed");
+      return 1;
+    }
+
+  if (pid == 0)
+    {
+      /* Make sure the child does not stay around indefinitely.  */
+      alarm (10);
+
+      /* Try to get the lock.  */
+      if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLK, &fl)) == 0)
+	{
+	  puts ("child:  second flock succeeded");
+	  return 1;
+	}
+    }
+
+  pthread_barrier_wait (b);
+
+  if (pid != 0)
+    {
+      fl.l_type = F_UNLCK;
+      if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLKW, &fl)) != 0)
+	{
+	  puts ("third fcntl failed");
+	  return 1;
+	}
+    }
+
+  pthread_barrier_wait (b);
+
+  pthread_t th;
+  if (pid == 0)
+    {
+      if (pthread_mutex_lock (&lock) != 0)
+	{
+	  puts ("1st locking of lock failed");
+	  return 1;
+	}
+
+      if (pthread_mutex_lock (&lock2) != 0)
+	{
+	  puts ("1st locking of lock2 failed");
+	  return 1;
+	}
+
+      if (pthread_create (&th, NULL, tf, NULL) != 0)
+	{
+	  puts ("pthread_create failed");
+	  return 1;
+	}
+
+      if (pthread_mutex_lock (&lock) != 0)
+	{
+	  puts ("2nd locking of lock failed");
+	  return 1;
+	}
+
+      puts ("child locked file");
+    }
+
+  pthread_barrier_wait (b);
+
+  if (pid != 0)
+    {
+      fl.l_type = F_WRLCK;
+      if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLK, &fl)) == 0)
+	{
+	  puts ("fifth fcntl succeeded");
+	  return 1;
+	}
+
+      puts ("file locked by child");
+    }
+
+  pthread_barrier_wait (b);
+
+  if (pid == 0)
+    {
+      if (pthread_mutex_unlock (&lock2) != 0)
+	{
+	  puts ("unlock of lock2 failed");
+	  return 1;
+	}
+
+      if (pthread_join (th, NULL) != 0)
+	{
+	  puts ("join failed");
+	  return 1;
+	}
+
+      puts ("child's thread terminated");
+    }
+
+  pthread_barrier_wait (b);
+
+  if (pid != 0)
+    {
+      fl.l_type = F_WRLCK;
+      if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLK, &fl)) == 0)
+	{
+	  puts ("fifth fcntl succeeded");
+	  return 1;
+	}
+
+      puts ("file still locked");
+    }
+
+  pthread_barrier_wait (b);
+
+  if (pid == 0)
+    {
+      _exit (0);
+    }
+
+  int status;
+  if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
+    {
+      puts ("waitpid failed");
+      return 1;
+    }
+  puts ("child terminated");
+
+  if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLKW, &fl)) != 0)
+    {
+      puts ("sixth fcntl failed");
+      return 1;
+    }
+
+  return status;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-fork1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-fork1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-fork1.c	(revision 2036)
@@ -0,0 +1,120 @@
+/* Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Roland McGrath <roland@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+static void *
+thread_function (void * arg)
+{
+  int i = (intptr_t) arg;
+  int status;
+  pid_t pid;
+  pid_t pid2;
+
+  pid = fork ();
+  switch (pid)
+    {
+    case 0:
+      printf ("%ld for %d\n", (long int) getpid (), i);
+      struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 * i };
+      nanosleep (&ts, NULL);
+      _exit (i);
+      break;
+    case -1:
+      printf ("fork: %m\n");
+      return (void *) 1l;
+      break;
+    }
+
+  pid2 = TEMP_FAILURE_RETRY (waitpid (pid, &status, 0));
+  if (pid2 != pid)
+    {
+      printf ("waitpid returned %ld, expected %ld\n",
+	      (long int) pid2, (long int) pid);
+      return (void *) 1l;
+    }
+
+  printf ("%ld with %d, expected %d\n",
+	  (long int) pid, WEXITSTATUS (status), i);
+
+  return WEXITSTATUS (status) == i ? NULL : (void *) 1l;
+}
+
+#define N 5
+static const int t[N] = { 7, 6, 5, 4, 3 };
+
+int
+main (void)
+{
+  pthread_t th[N];
+  int i;
+  int result = 0;
+  pthread_attr_t at;
+
+  if (pthread_attr_init (&at) != 0)
+    {
+      puts ("attr_init failed");
+      return 1;
+    }
+
+  if (pthread_attr_setstacksize (&at, 1 * 1024 * 1024) != 0)
+    {
+      puts ("attr_setstacksize failed");
+      return 1;
+    }
+
+  for (i = 0; i < N; ++i)
+    if (pthread_create (&th[i], NULL, thread_function,
+			(void *) (intptr_t) t[i]) != 0)
+      {
+	printf ("creation of thread %d failed\n", i);
+	exit (1);
+      }
+
+  if (pthread_attr_destroy (&at) != 0)
+    {
+      puts ("attr_destroy failed");
+      return 1;
+    }
+
+  for (i = 0; i < N; ++i)
+    {
+      void *v;
+      if (pthread_join (th[i], &v) != 0)
+	{
+	  printf ("join of thread %d failed\n", i);
+	  result = 1;
+	}
+      else if (v != NULL)
+	{
+	  printf ("join %d successful, but child failed\n", i);
+	  result = 1;
+	}
+      else
+	printf ("join %d successful\n", i);
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/nptl/tst-fork2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-fork2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-fork2.c	(revision 2036)
@@ -0,0 +1,90 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Roland McGrath <roland@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+
+static pid_t initial_pid;
+
+
+static void *
+tf (void *arg)
+{
+  if (getppid () != initial_pid)
+    {
+      printf ("getppid in thread returned %ld, expected %ld\n",
+	      (long int) getppid (), (long int) initial_pid);
+      return (void *) -1;
+    }
+
+  return NULL;
+}
+
+
+int
+main (void)
+{
+  initial_pid = getpid ();
+
+  pid_t child = fork ();
+  if (child == 0)
+    {
+      if (getppid () != initial_pid)
+	{
+	  printf ("first getppid returned %ld, expected %ld\n",
+		  (long int) getppid (), (long int) initial_pid);
+	  exit (1);
+	}
+
+      pthread_t th;
+      if (pthread_create (&th, NULL, tf, NULL) != 0)
+	{
+	  puts ("pthread_create failed");
+	  exit (1);
+	}
+
+      void *result;
+      if (pthread_join (th, &result) != 0)
+	{
+	  puts ("pthread_join failed");
+	  exit  (1);
+	}
+
+      exit (result == NULL ? 0 : 1);
+    }
+  else if (child == -1)
+    {
+      puts ("initial fork failed");
+      return 1;
+    }
+
+  int status;
+  if (TEMP_FAILURE_RETRY (waitpid (child, &status, 0)) != child)
+    {
+      printf ("waitpid failed: %m\n");
+      return 1;
+    }
+
+  return status;
+}
Index: trunk/src/libctests/glibc/nptl/tst-fork3.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-fork3.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-fork3.c	(revision 2036)
@@ -0,0 +1,107 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Roland McGrath <roland@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+
+static pid_t initial_pid;
+
+
+static void *
+tf2 (void *arg)
+{
+  if (getppid () != initial_pid)
+    {
+      printf ("getppid in thread returned %ld, expected %ld\n",
+	      (long int) getppid (), (long int) initial_pid);
+      return (void *) -1;
+    }
+
+  return NULL;
+}
+
+
+static void *
+tf1 (void *arg)
+{
+  pid_t child = fork ();
+  if (child == 0)
+    {
+      if (getppid () != initial_pid)
+	{
+	  printf ("first getppid returned %ld, expected %ld\n",
+		  (long int) getppid (), (long int) initial_pid);
+	  exit (1);
+	}
+
+      pthread_t th2;
+      if (pthread_create (&th2, NULL, tf2, NULL) != 0)
+	{
+	  puts ("child: pthread_create failed");
+	  exit (1);
+	}
+
+      void *result;
+      if (pthread_join (th2, &result) != 0)
+	{
+	  puts ("pthread_join failed");
+	  exit  (1);
+	}
+
+      exit (result == NULL ? 0 : 1);
+    }
+  else if (child == -1)
+    {
+      puts ("initial fork failed");
+      exit (1);
+    }
+
+  int status;
+  if (TEMP_FAILURE_RETRY (waitpid (child, &status, 0)) != child)
+    {
+      printf ("waitpid failed: %m\n");
+      exit (1);
+    }
+
+  exit (status);
+}
+
+
+int
+main (void)
+{
+  initial_pid = getpid ();
+
+  pthread_t th1;
+  if (pthread_create (&th1, NULL, tf1, NULL) != 0)
+    {
+      puts ("parent: pthread_create failed");
+      exit (1);
+    }
+
+  /* This call should never return.  */
+  pthread_join (th1, NULL);
+
+  return 1;
+}
Index: trunk/src/libctests/glibc/nptl/tst-fork4.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-fork4.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-fork4.c	(revision 2036)
@@ -0,0 +1,65 @@
+/* Test of fork updating child universe's pthread structures.
+   Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <string.h>
+
+
+static int
+do_test (void)
+{
+  pthread_t me = pthread_self ();
+
+  pid_t pid = fork ();
+
+  if (pid < 0)
+    {
+      printf ("fork: %m\n");
+      return 1;
+    }
+
+  if (pid == 0)
+    {
+      int err = pthread_kill (me, SIGTERM);
+      printf ("pthread_kill returned: %s\n", strerror (err));
+      return 3;
+    }
+
+  int status;
+  errno = 0;
+  if (wait (&status) != pid)
+    printf ("wait failed: %m\n");
+  else if (WIFSIGNALED (status) && WTERMSIG (status) == SIGTERM)
+    {
+      printf ("child correctly died with SIGTERM\n");
+      return 0;
+    }
+  else
+    printf ("child died with bad status %#x\n", status);
+
+  return 1;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-getpid1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-getpid1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-getpid1.c	(revision 2036)
@@ -0,0 +1,115 @@
+#include <sched.h>
+#include <signal.h>
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#ifndef TEST_CLONE_FLAGS
+#define TEST_CLONE_FLAGS 0
+#endif
+
+static int sig;
+
+static int
+f (void *a)
+{
+  puts ("in f");
+  union sigval sival;
+  sival.sival_int = getpid ();
+  printf ("pid = %d\n", sival.sival_int);
+  if (sigqueue (getppid (), sig, sival) != 0)
+    return 1;
+  return 0;
+}
+
+
+static int
+do_test (void)
+{
+  int mypid = getpid ();
+
+  sig = SIGRTMIN;
+  sigset_t ss;
+  sigemptyset (&ss);
+  sigaddset (&ss, sig);
+  if (sigprocmask (SIG_BLOCK, &ss, NULL) != 0)
+    {
+      printf ("sigprocmask failed: %m\n");
+      return 1;
+    }
+
+#ifdef __ia64__
+  extern int __clone2 (int (*__fn) (void *__arg), void *__child_stack_base,
+		       size_t __child_stack_size, int __flags,
+		       void *__arg, ...);
+  char st[256 * 1024] __attribute__ ((aligned));
+  pid_t p = __clone2 (f, st, sizeof (st), TEST_CLONE_FLAGS, 0);
+#else
+  char st[128 * 1024] __attribute__ ((aligned));
+  pid_t p = clone (f, st + sizeof (st), TEST_CLONE_FLAGS, 0);
+#endif
+  if (p == -1)
+    {
+      printf("clone failed: %m\n");
+      return 1;
+    }
+  printf ("new thread: %d\n", (int) p);
+
+  siginfo_t si;
+  do
+    if (sigwaitinfo (&ss, &si) < 0)
+      {
+	printf("sigwaitinfo failed: %m\n");
+	kill (p, SIGKILL);
+	return 1;
+      }
+  while  (si.si_signo != sig || si.si_code != SI_QUEUE);
+
+  int e;
+  if (waitpid (p, &e, __WCLONE) != p)
+    {
+      puts ("waitpid failed");
+      kill (p, SIGKILL);
+      return 1;
+    }
+  if (!WIFEXITED (e))
+    {
+      if (WIFSIGNALED (e))
+	printf ("died from signal %s\n", strsignal (WTERMSIG (e)));
+      else
+	puts ("did not terminate correctly");
+      return 1;
+    }
+  if (WEXITSTATUS (e) != 0)
+    {
+      printf ("exit code %d\n", WEXITSTATUS (e));
+      return 1;
+    }
+
+  if (si.si_int != (int) p)
+    {
+      printf ("expected PID %d, got si_int %d\n", (int) p, si.si_int);
+      kill (p, SIGKILL);
+      return 1;
+    }
+
+  if (si.si_pid != p)
+    {
+      printf ("expected PID %d, got si_pid %d\n", (int) p, (int) si.si_pid);
+      kill (p, SIGKILL);
+      return 1;
+    }
+
+  if (getpid () != mypid)
+    {
+      puts ("my PID changed");
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-getpid2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-getpid2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-getpid2.c	(revision 2036)
@@ -0,0 +1,2 @@
+#define TEST_CLONE_FLAGS CLONE_VM
+#include "tst-getpid1.c"
Index: trunk/src/libctests/glibc/nptl/tst-join1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-join1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-join1.c	(revision 2036)
@@ -0,0 +1,83 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+
+
+static void *
+tf (void *arg)
+{
+  pthread_t mh = (pthread_t) arg;
+  void *result;
+
+  if (pthread_mutex_unlock (&lock) != 0)
+    {
+      puts ("unlock failed");
+      exit (1);
+    }
+
+  if (pthread_join (mh, &result) != 0)
+    {
+      puts ("join failed");
+      exit (1);
+    }
+
+  if (result != (void *) 42l)
+    {
+      printf ("result wrong: expected %p, got %p\n", (void *) 42, result);
+      exit (1);
+    }
+
+  exit (0);
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t th;
+
+  if (pthread_mutex_lock (&lock) != 0)
+    {
+      puts ("1st lock failed");
+      exit (1);
+    }
+
+  if (pthread_create (&th, NULL, tf, (void *) pthread_self ()) != 0)
+    {
+      puts ("create failed");
+      exit (1);
+    }
+
+  if (pthread_mutex_lock (&lock) != 0)
+    {
+      puts ("2nd lock failed");
+      exit (1);
+    }
+
+  pthread_exit ((void *) 42);
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-join2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-join2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-join2.c	(revision 2036)
@@ -0,0 +1,104 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+
+static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+
+
+static void *
+tf (void *arg)
+{
+  if (pthread_mutex_lock (&lock) != 0)
+    {
+      puts ("child: mutex_lock failed");
+      return NULL;
+    }
+
+  return (void *) 42l;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t th;
+
+  if (pthread_mutex_lock (&lock) != 0)
+    {
+      puts ("mutex_lock failed");
+      exit (1);
+    }
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("mutex_create failed");
+      exit (1);
+    }
+
+  void *status;
+  int val = pthread_tryjoin_np (th, &status);
+  if (val == 0)
+    {
+      puts ("1st tryjoin succeeded");
+      exit (1);
+    }
+  else if (val != EBUSY)
+    {
+      puts ("1st tryjoin didn't return EBUSY");
+      exit (1);
+    }
+
+  if (pthread_mutex_unlock (&lock) != 0)
+    {
+      puts ("mutex_unlock failed");
+      exit (1);
+    }
+
+  while ((val = pthread_tryjoin_np (th, &status)) != 0)
+    {
+      if (val != EBUSY)
+	{
+	  printf ("tryjoin returned %s (%d), expected only 0 or EBUSY\n",
+		  strerror (val), val);
+	  exit (1);
+	}
+
+      /* Delay minimally.  */
+      struct timespec ts = { .tv_sec = 0, .tv_nsec = 10000000 };
+      nanosleep (&ts, NULL);
+    }
+
+  if (status != (void *) 42l)
+    {
+      printf ("return value %p, expected %p\n", status, (void *) 42l);
+      exit (1);
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-join3.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-join3.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-join3.c	(revision 2036)
@@ -0,0 +1,123 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+
+
+static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+
+
+static void *
+tf (void *arg)
+{
+  if (pthread_mutex_lock (&lock) != 0)
+    {
+      puts ("child: mutex_lock failed");
+      return NULL;
+    }
+
+  return (void *) 42l;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t th;
+
+  if (pthread_mutex_lock (&lock) != 0)
+    {
+      puts ("mutex_lock failed");
+      exit (1);
+    }
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("mutex_create failed");
+      exit (1);
+    }
+
+  void *status;
+  struct timespec ts;
+  struct timeval tv;
+  (void) gettimeofday (&tv, NULL);
+  TIMEVAL_TO_TIMESPEC (&tv, &ts);
+  ts.tv_nsec += 200000000;
+  if (ts.tv_nsec >= 1000000000)
+    {
+      ts.tv_nsec -= 1000000000;
+      ++ts.tv_sec;
+    }
+  int val = pthread_timedjoin_np (th, &status, &ts);
+  if (val == 0)
+    {
+      puts ("1st timedjoin succeeded");
+      exit (1);
+    }
+  else if (val != ETIMEDOUT)
+    {
+      puts ("1st timedjoin didn't return ETIMEDOUT");
+      exit (1);
+    }
+
+  if (pthread_mutex_unlock (&lock) != 0)
+    {
+      puts ("mutex_unlock failed");
+      exit (1);
+    }
+
+  while (1)
+    {
+      (void) gettimeofday (&tv, NULL);
+      TIMEVAL_TO_TIMESPEC (&tv, &ts);
+      ts.tv_nsec += 200000000;
+      if (ts.tv_nsec >= 1000000000)
+	{
+	  ts.tv_nsec -= 1000000000;
+	  ++ts.tv_sec;
+	}
+
+      val = pthread_timedjoin_np (th, &status, &ts);
+      if (val == 0)
+	break;
+
+      if (val != ETIMEDOUT)
+	{
+	  printf ("timedjoin returned %s (%d), expected only 0 or ETIMEDOUT\n",
+		  strerror (val), val);
+	  exit (1);
+	}
+    }
+
+  if (status != (void *) 42l)
+    {
+      printf ("return value %p, expected %p\n", status, (void *) 42l);
+      exit (1);
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-join4.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-join4.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-join4.c	(revision 2036)
@@ -0,0 +1,125 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_barrier_t bar;
+
+
+static void *
+tf (void *arg)
+{
+  if (pthread_barrier_wait (&bar) != 0)
+    {
+      puts ("tf: barrier_wait failed");
+      exit (1);
+    }
+
+  return (void *) 1l;
+}
+
+
+static int
+do_test (void)
+{
+  if (pthread_barrier_init (&bar, NULL, 3) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  pthread_attr_t a;
+
+  if (pthread_attr_init (&a) != 0)
+    {
+      puts ("attr_init failed");
+      exit (1);
+    }
+
+  if (pthread_attr_setstacksize (&a, 1 * 1024 * 1024) != 0)
+    {
+      puts ("attr_setstacksize failed");
+      return 1;
+    }
+
+  pthread_t th[2];
+
+  if (pthread_create (&th[0], &a, tf, NULL) != 0)
+    {
+      puts ("1st create failed");
+      exit (1);
+    }
+
+  if (pthread_attr_setdetachstate (&a, PTHREAD_CREATE_DETACHED) != 0)
+    {
+      puts ("attr_setdetachstate failed");
+      exit (1);
+    }
+
+  if (pthread_create (&th[1], &a, tf, NULL) != 0)
+    {
+      puts ("1st create failed");
+      exit (1);
+    }
+
+  if (pthread_attr_destroy (&a) != 0)
+    {
+      puts ("attr_destroy failed");
+      exit (1);
+    }
+
+  if (pthread_detach (th[0]) != 0)
+    {
+      puts ("could not detach 1st thread");
+      exit (1);
+    }
+
+  int err = pthread_detach (th[0]);
+  if (err == 0)
+    {
+      puts ("second detach of 1st thread succeeded");
+      exit (1);
+    }
+  if (err != EINVAL)
+    {
+      printf ("second detach of 1st thread returned %d, not EINVAL\n", err);
+      exit (1);
+    }
+
+  err = pthread_detach (th[1]);
+  if (err == 0)
+    {
+      puts ("detach of 2nd thread succeeded");
+      exit (1);
+    }
+  if (err != EINVAL)
+    {
+      printf ("detach of 2nd thread returned %d, not EINVAL\n", err);
+      exit (1);
+    }
+
+  exit (0);
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-join5.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-join5.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-join5.c	(revision 2036)
@@ -0,0 +1,141 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static void *
+tf1 (void *arg)
+{
+  pthread_join ((pthread_t) arg, NULL);
+
+  puts ("1st join returned");
+
+  return (void *) 1l;
+}
+
+
+static void *
+tf2 (void *arg)
+{
+  pthread_join ((pthread_t) arg, NULL);
+
+  puts ("2nd join returned");
+
+  return (void *) 1l;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t th;
+
+  int err = pthread_join (pthread_self (), NULL);
+  if (err == 0)
+    {
+      puts ("1st circular join succeeded");
+      exit (1);
+    }
+  if (err != EDEADLK)
+    {
+      printf ("1st circular join %d, not EDEADLK\n", err);
+      exit (1);
+    }
+
+  if (pthread_create (&th, NULL, tf1, (void *) pthread_self ()) != 0)
+    {
+      puts ("1st create failed");
+      exit (1);
+    }
+
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("cannot cancel 1st thread");
+      exit (1);
+    }
+
+  void *r;
+  err = pthread_join (th, &r);
+  if (err != 0)
+    {
+      printf ("cannot join 1st thread: %d\n", err);
+      exit (1);
+    }
+  if (r != PTHREAD_CANCELED)
+    {
+      puts ("1st thread not canceled");
+      exit (1);
+    }
+
+  err = pthread_join (pthread_self (), NULL);
+  if (err == 0)
+    {
+      puts ("2nd circular join succeeded");
+      exit (1);
+    }
+  if (err != EDEADLK)
+    {
+      printf ("2nd circular join %d, not EDEADLK\n", err);
+      exit (1);
+    }
+
+  if (pthread_create (&th, NULL, tf2, (void *) pthread_self ()) != 0)
+    {
+      puts ("2nd create failed");
+      exit (1);
+    }
+
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("cannot cancel 2nd thread");
+      exit (1);
+    }
+
+  if (pthread_join (th, &r) != 0)
+    {
+      puts ("cannot join 2nd thread");
+      exit (1);
+    }
+  if (r != PTHREAD_CANCELED)
+    {
+      puts ("2nd thread not canceled");
+      exit (1);
+    }
+
+  err = pthread_join (pthread_self (), NULL);
+  if (err == 0)
+    {
+      puts ("2nd circular join succeeded");
+      exit (1);
+    }
+  if (err != EDEADLK)
+    {
+      printf ("2nd circular join %d, not EDEADLK\n", err);
+      exit (1);
+    }
+
+  exit (0);
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-key1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-key1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-key1.c	(revision 2036)
@@ -0,0 +1,89 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <limits.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+int
+do_test (void)
+{
+  int max;
+#ifdef PTHREAD_KEYS_MAX
+  max = PTHREAD_KEYS_MAX;
+#else
+  max = _POSIX_THREAD_KEYS_MAX;
+#endif
+  pthread_key_t *keys = alloca (max * sizeof (pthread_key_t));
+
+  int i;
+  for (i = 0; i < max; ++i)
+    if (pthread_key_create (&keys[i], NULL) != 0)
+      {
+	write (2, "key_create failed\n", 18);
+	_exit (1);
+      }
+    else
+      {
+	printf ("created key %d\n", i);
+
+	if (pthread_setspecific (keys[i], (const void *) (i + 100l)) != 0)
+	  {
+	    write (2, "setspecific failed\n", 19);
+	    _exit (1);
+	  }
+      }
+
+  for (i = 0; i < max; ++i)
+    {
+      if (pthread_getspecific (keys[i]) != (void *) (i + 100l))
+	{
+	  write (2, "getspecific failed\n", 19);
+	  _exit (1);
+	}
+
+      if (pthread_key_delete (keys[i]) != 0)
+	{
+	  write (2, "key_delete failed\n", 18);
+	  _exit (1);
+	}
+    }
+
+  /* Now it must be once again possible to allocate keys.  */
+  if (pthread_key_create (&keys[0], NULL) != 0)
+    {
+      write (2, "2nd key_create failed\n", 22);
+      _exit (1);
+    }
+
+  if (pthread_key_delete (keys[0]) != 0)
+    {
+      write (2, "2nd key_delete failed\n", 22);
+      _exit (1);
+    }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-key2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-key2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-key2.c	(revision 2036)
@@ -0,0 +1,115 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#define N 2
+
+
+static int cnt0;
+static void
+f0 (void *p)
+{
+  ++cnt0;
+}
+
+
+static int cnt1;
+static void
+f1 (void *p)
+{
+  ++cnt1;
+}
+
+
+static void (*fcts[N]) (void *) =
+{
+  f0,
+  f1
+};
+
+
+static void *
+tf (void *arg)
+{
+  pthread_key_t *key = (pthread_key_t *) arg;
+
+  if (pthread_setspecific (*key, (void *) -1l) != 0)
+    {
+      write (2, "setspecific failed\n", 19);
+      _exit (1);
+    }
+
+  return NULL;
+}
+
+
+int
+do_test (void)
+{
+  pthread_key_t keys[N];
+
+  int i;
+  for (i = 0; i < N; ++i)
+    if (pthread_key_create (&keys[i], fcts[i]) != 0)
+      {
+	write (2, "key_create failed\n", 18);
+	_exit (1);
+      }
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, &keys[1]) != 0)
+    {
+      write (2, "create failed\n", 14);
+      _exit (1);
+    }
+
+  if (pthread_join (th, NULL) != 0)
+    {
+      write (2, "join failed\n", 12);
+      _exit (1);
+    }
+
+  if (cnt0 != 0)
+    {
+      write (2, "cnt0 != 0\n", 10);
+      _exit (1);
+    }
+
+  if (cnt1 != 1)
+    {
+      write (2, "cnt1 != 1\n", 10);
+      _exit (1);
+    }
+
+  for (i = 0; i < N; ++i)
+    if (pthread_key_delete (keys[i]) != 0)
+      {
+	write (2, "key_delete failed\n", 18);
+	_exit (1);
+      }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-key3.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-key3.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-key3.c	(revision 2036)
@@ -0,0 +1,156 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#define N 2
+
+
+static int cnt0;
+static void
+f0 (void *p)
+{
+  ++cnt0;
+}
+
+
+static int cnt1;
+static void
+f1 (void *p)
+{
+  ++cnt1;
+}
+
+
+static void (*fcts[N]) (void *) =
+{
+  f0,
+  f1
+};
+
+
+static pthread_barrier_t b;
+
+
+static void *
+tf (void *arg)
+{
+  pthread_key_t *key = (pthread_key_t *) arg;
+
+  if (pthread_setspecific (*key, (void *) -1l) != 0)
+    {
+      write (2, "setspecific failed\n", 19);
+      _exit (1);
+    }
+
+  pthread_barrier_wait (&b);
+
+  const struct timespec t = { .tv_sec = 1000, .tv_nsec = 0 };
+  while (1)
+    nanosleep (&t, NULL);
+
+  /* NOTREACHED */
+  return NULL;
+}
+
+
+int
+do_test (void)
+{
+  pthread_key_t keys[N];
+
+  int i;
+  for (i = 0; i < N; ++i)
+    if (pthread_key_create (&keys[i], fcts[i]) != 0)
+      {
+	write (2, "key_create failed\n", 18);
+	_exit (1);
+      }
+
+  if (pthread_barrier_init (&b, NULL, 2) != 0)
+    {
+      write (2, "barrier_init failed\n", 20);
+      _exit (1);
+    }
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, &keys[1]) != 0)
+    {
+      write (2, "create failed\n", 14);
+      _exit (1);
+    }
+
+  pthread_barrier_wait (&b);
+
+  if (pthread_cancel (th) != 0)
+    {
+      write (2, "cancel failed\n", 14);
+      _exit (1);
+    }
+
+  void *status;
+  if (pthread_join (th, &status) != 0)
+    {
+      write (2, "join failed\n", 12);
+      _exit (1);
+    }
+
+  if (status != PTHREAD_CANCELED)
+    {
+      write (2, "thread not canceled\n", 20);
+      _exit (1);
+    }
+
+  /* Note that the TSD destructors not necessarily have to have
+     finished by the time pthread_join returns.  At least according to
+     POSIX.  We implement the stronger requirement that they indeed
+     have run and therefore these tests succeed.  */
+  if (cnt0 != 0)
+    {
+      write (2, "cnt0 != 0\n", 10);
+      _exit (1);
+    }
+
+  if (cnt1 != 1)
+    {
+      write (2, "cnt1 != 1\n", 10);
+      _exit (1);
+    }
+
+  for (i = 0; i < N; ++i)
+    if (pthread_key_delete (keys[i]) != 0)
+      {
+	write (2, "key_delete failed\n", 18);
+	_exit (1);
+      }
+
+  if (pthread_barrier_destroy (&b) != 0)
+    {
+      write (2, "barrier_destroy failed\n", 23);
+      _exit (1);
+    }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-key4.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-key4.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-key4.c	(revision 2036)
@@ -0,0 +1,137 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <limits.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+#ifdef PTHREAD_KEYS_MAX
+const int max = PTHREAD_KEYS_MAX;
+#else
+const int max = _POSIX_THREAD_KEYS_MAX;
+#endif
+static pthread_key_t *keys;
+
+
+static void *
+tf1 (void *arg)
+{
+  int i;
+  for (i = 0; i < max; ++i)
+    if (pthread_setspecific (keys[i], (void *) (long int) (i + 1)) != 0)
+      {
+	puts ("setspecific failed");
+	exit (1);
+      }
+
+  return NULL;
+}
+
+
+static void *
+tf2 (void *arg)
+{
+  int i;
+  for (i = 0; i < max; ++i)
+    if (pthread_getspecific (keys[i]) != NULL)
+      {
+	printf ("getspecific for key %d not NULL\n", i);
+	exit (1);
+      }
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  keys = alloca (max * sizeof (pthread_key_t));
+
+  int i;
+  for (i = 0; i < max; ++i)
+    if (pthread_key_create (&keys[i], NULL) != 0)
+      {
+	puts ("key_create failed");
+	exit (1);
+      }
+
+  pthread_attr_t a;
+
+  if (pthread_attr_init (&a) != 0)
+    {
+      puts ("attr_init failed");
+      exit (1);
+    }
+
+  if (pthread_attr_setstacksize (&a, 1 * 1024 * 1024) != 0)
+    {
+      puts ("attr_setstacksize failed");
+      return 1;
+    }
+
+  for (i = 0; i < 10; ++i)
+    {
+      int j;
+#define N 2
+      pthread_t th[N];
+      for (j = 0; j < N; ++j)
+	if (pthread_create (&th[j], NULL, tf1, NULL) != 0)
+	  {
+	    puts ("1st create failed");
+	    exit (1);
+	  }
+
+      for (j = 0; j < N; ++j)
+	if (pthread_join (th[j], NULL) != 0)
+	  {
+	    puts ("1st join failed");
+	    exit (1);
+	  }
+
+      for (j = 0; j < N; ++j)
+	if (pthread_create (&th[j], NULL, tf2, NULL) != 0)
+	  {
+	    puts ("2nd create failed");
+	    exit (1);
+	  }
+
+      for (j = 0; j < N; ++j)
+	if (pthread_join (th[j], NULL) != 0)
+	  {
+	    puts ("2nd join failed");
+	    exit (1);
+	  }
+    }
+
+  if (pthread_attr_destroy (&a) != 0)
+    {
+      puts ("attr_destroy failed");
+      exit (1);
+    }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-kill1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-kill1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-kill1.c	(revision 2036)
@@ -0,0 +1,100 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_cond_t c = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
+static pthread_barrier_t b;
+
+static void *
+tf (void *a)
+{
+  if (pthread_mutex_lock (&m) != 0)
+    {
+      puts ("child: mutex_lock failed");
+      exit (1);
+    }
+
+  int e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("child: barrier_wait failed");
+      exit (1);
+    }
+
+  /* This call should never return.  */
+  pthread_cond_wait (&c, &m);
+
+  return NULL;
+}
+
+
+int
+do_test (void)
+{
+  pthread_t th;
+
+  if (pthread_barrier_init (&b, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      exit (1);
+    }
+
+  int e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      exit (1);
+    }
+
+  if (pthread_mutex_lock (&m) != 0)
+    {
+      puts ("mutex_lock failed");
+      exit (1);
+    }
+
+  /* Send the thread a signal which it doesn't catch and which will
+     cause the process to terminate.  */
+  if (pthread_kill (th, SIGUSR1) != 0)
+    {
+      puts ("kill failed");
+      exit (1);
+    }
+
+  /* This call should never return.  */
+  pthread_join (th, NULL);
+
+  return 0;
+}
+
+
+#define EXPECTED_SIGNAL SIGUSR1
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-kill2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-kill2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-kill2.c	(revision 2036)
@@ -0,0 +1,139 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+
+
+static pthread_cond_t c = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
+static pthread_barrier_t b;
+
+static void *
+tf (void *a)
+{
+  /* Block SIGUSR1.  */
+  sigset_t ss;
+
+  sigemptyset (&ss);
+  sigaddset (&ss, SIGUSR1);
+  if (pthread_sigmask (SIG_BLOCK, &ss, NULL) != 0)
+    {
+      puts ("child: sigmask failed");
+      exit (1);
+    }
+
+  if (pthread_mutex_lock (&m) != 0)
+    {
+      puts ("child: mutex_lock failed");
+      exit (1);
+    }
+
+  int e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("child: barrier_wait failed");
+      exit (1);
+    }
+
+  /* Compute timeout.  */
+  struct timeval tv;
+  (void) gettimeofday (&tv, NULL);
+  struct timespec ts;
+  TIMEVAL_TO_TIMESPEC (&tv, &ts);
+  /* Timeout: 1sec.  */
+  ts.tv_sec += 1;
+
+  /* This call should never return.  */
+  if (pthread_cond_timedwait (&c, &m, &ts) != ETIMEDOUT)
+    {
+      puts ("cond_timedwait didn't time out");
+      exit (1);
+    }
+
+  return NULL;
+}
+
+
+int
+do_test (void)
+{
+  pthread_t th;
+
+  if (pthread_barrier_init (&b, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      exit (1);
+    }
+
+  int e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      exit (1);
+    }
+
+  if (pthread_mutex_lock (&m) != 0)
+    {
+      puts ("mutex_lock failed");
+      exit (1);
+    }
+
+  /* Send the thread a signal which it has blocked.  */
+  if (pthread_kill (th, SIGUSR1) != 0)
+    {
+      puts ("kill failed");
+      exit (1);
+    }
+
+  if (pthread_mutex_unlock (&m) != 0)
+    {
+      puts ("mutex_unlock failed");
+      exit (1);
+    }
+
+  void *r;
+  if (pthread_join (th, &r) != 0)
+    {
+      puts ("join failed");
+      exit (1);
+    }
+  if (r != NULL)
+    {
+      puts ("return value wrong");
+      exit (1);
+    }
+
+  return 0;
+}
+
+
+#define TIMEOUT 5
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-kill3.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-kill3.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-kill3.c	(revision 2036)
@@ -0,0 +1,159 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+
+static pthread_cond_t c = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
+static pthread_barrier_t b;
+
+
+static void
+handler (int sig)
+{
+  write (1, "handler called\n", 15);
+  _exit (1);
+}
+
+
+static void *
+tf (void *a)
+{
+  /* Block SIGUSR1.  */
+  sigset_t ss;
+
+  sigemptyset (&ss);
+  sigaddset (&ss, SIGUSR1);
+  if (pthread_sigmask (SIG_BLOCK, &ss, NULL) != 0)
+    {
+      puts ("child: sigmask failed");
+      exit (1);
+    }
+
+  if (pthread_mutex_lock (&m) != 0)
+    {
+      puts ("child: mutex_lock failed");
+      exit (1);
+    }
+
+  int e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("child: barrier_wait failed");
+      exit (1);
+    }
+
+  /* Compute timeout.  */
+  struct timeval tv;
+  (void) gettimeofday (&tv, NULL);
+  struct timespec ts;
+  TIMEVAL_TO_TIMESPEC (&tv, &ts);
+  /* Timeout: 1sec.  */
+  ts.tv_sec += 1;
+
+  /* This call should never return.  */
+  if (pthread_cond_timedwait (&c, &m, &ts) != ETIMEDOUT)
+    {
+      puts ("cond_timedwait didn't time out");
+      exit (1);
+    }
+
+  return NULL;
+}
+
+
+int
+do_test (void)
+{
+  pthread_t th;
+
+  struct sigaction sa;
+  sigemptyset (&sa.sa_mask);
+  sa.sa_flags = 0;
+  sa.sa_handler = handler;
+  if (sigaction (SIGUSR1, &sa, NULL) != 0)
+    {
+      puts ("sigaction failed");
+      exit (1);
+    }
+
+  if (pthread_barrier_init (&b, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      exit (1);
+    }
+
+  int e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      exit (1);
+    }
+
+  if (pthread_mutex_lock (&m) != 0)
+    {
+      puts ("mutex_lock failed");
+      exit (1);
+    }
+
+  /* Send the thread a signal which it has blocked.  */
+  if (pthread_kill (th, SIGUSR1) != 0)
+    {
+      puts ("kill failed");
+      exit (1);
+    }
+
+  if (pthread_mutex_unlock (&m) != 0)
+    {
+      puts ("mutex_unlock failed");
+      exit (1);
+    }
+
+  void *r;
+  if (pthread_join (th, &r) != 0)
+    {
+      puts ("join failed");
+      exit (1);
+    }
+  if (r != NULL)
+    {
+      puts ("return value wrong");
+      exit (1);
+    }
+
+  return 0;
+}
+
+
+#define TIMEOUT 5
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-kill4.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-kill4.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-kill4.c	(revision 2036)
@@ -0,0 +1,74 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static void *
+tf (void *a)
+{
+  return NULL;
+}
+
+
+int
+do_test (void)
+{
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      exit (1);
+    }
+
+  if (pthread_join (th, NULL) != 0)
+    {
+      puts ("join failed");
+      exit (1);
+    }
+
+  /* The following only works because we assume here something about
+     the implementation.  Namely, that the memory allocated for the
+     thread descriptor is not going away, that the the TID field is
+     cleared and therefore the signal is sent to process 0, and that
+     we can savely assume there is no other process with this ID at
+     that time.  */
+  int e = pthread_kill (th, 0);
+  if (e == 0)
+    {
+      puts ("pthread_kill succeeded");
+      exit (1);
+    }
+  if (e != ESRCH)
+    {
+      puts ("pthread_kill didn't return ESRCH");
+      exit (1);
+    }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-kill5.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-kill5.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-kill5.c	(revision 2036)
@@ -0,0 +1,49 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+int
+do_test (void)
+{
+  /* XXX This test might require architecture and system specific changes.
+     There is no guarantee that this signal number is invalid.  */
+  int e = pthread_kill (pthread_self (), SIGRTMAX + 10);
+  if (e == 0)
+    {
+      puts ("kill didn't failed");
+      exit (1);
+    }
+  if (e != EINVAL)
+    {
+      puts ("error not EINVAL");
+      exit (1);
+    }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-kill6.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-kill6.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-kill6.c	(revision 2036)
@@ -0,0 +1,162 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <semaphore.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static pthread_t receiver;
+static sem_t sem;
+static pthread_barrier_t b;
+
+static void
+handler (int sig)
+{
+  if (sig != SIGUSR1)
+    {
+      write (STDOUT_FILENO, "wrong signal\n", 13);
+      _exit (1);
+    }
+
+  if (pthread_self () != receiver)
+    {
+      write (STDOUT_FILENO, "not the intended receiver\n", 26);
+      _exit (1);
+    }
+
+  if (sem_post (&sem) != 0)
+    {
+      write (STDOUT_FILENO, "sem_post failed\n", 16);
+      _exit (1);
+    }
+}
+
+
+static void *
+tf (void *a)
+{
+  int e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("child: barrier_wait failed");
+      exit (1);
+    }
+
+  return NULL;
+}
+
+
+int
+do_test (void)
+{
+  struct sigaction sa;
+  sigemptyset (&sa.sa_mask);
+  sa.sa_flags = 0;
+  sa.sa_handler = handler;
+  if (sigaction (SIGUSR1, &sa, NULL) != 0)
+    {
+      puts ("sigaction failed");
+      exit (1);
+    }
+
+#define N 20
+
+  if (pthread_barrier_init (&b, NULL, N + 1) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  pthread_attr_t a;
+
+  if (pthread_attr_init (&a) != 0)
+    {
+      puts ("attr_init failed");
+      exit (1);
+    }
+
+  if (pthread_attr_setstacksize (&a, 1 * 1024 * 1024) != 0)
+    {
+      puts ("attr_setstacksize failed");
+      return 1;
+    }
+
+  pthread_t th[N];
+  int i;
+  for (i = 0; i < N; ++i)
+    if (pthread_create (&th[i], &a, tf, NULL) != 0)
+      {
+	puts ("create failed");
+	exit (1);
+      }
+
+  if (pthread_attr_destroy (&a) != 0)
+    {
+      puts ("attr_destroy failed");
+      exit (1);
+    }
+
+  if (sem_init (&sem, 0, 0) != 0)
+    {
+      puts ("sem_init failed");
+      exit (1);
+    }
+
+  for (i = 0; i < N * 10; ++i)
+    {
+      receiver = th[i % N];
+
+      if (pthread_kill (receiver, SIGUSR1) != 0)
+	{
+	  puts ("kill failed");
+	  exit (1);
+	}
+
+      if (TEMP_FAILURE_RETRY (sem_wait (&sem)) != 0)
+	{
+	  puts ("sem_wait failed");
+	  exit (1);
+	}
+    }
+
+  int e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      exit (1);
+    }
+
+  for (i = 0; i < N; ++i)
+    if (pthread_join (th[i], NULL) != 0)
+      {
+	puts ("join failed");
+	exit (1);
+      }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-locale1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-locale1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-locale1.c	(revision 2036)
@@ -0,0 +1,17 @@
+/* Test that the thread-local locale works right in the main thread
+   when statically linked.  */
+
+#include "../locale/tst-C-locale.c"
+
+#include <pthread.h>
+#include <signal.h>
+
+/* This is never called, just here to get pthreads linked in.  */
+int
+useless (void)
+{
+  pthread_create (0, 0, 0, 0);
+  /* This is to check __libc_current_sigrt* can be used in statically
+     linked apps.  */
+  return SIGRTMIN;
+}
Index: trunk/src/libctests/glibc/nptl/tst-locale2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-locale2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-locale2.c	(revision 2036)
@@ -0,0 +1,13 @@
+/* Test that the thread-local locale works right in the main thread
+   when statically linked.  */
+
+#include "../argp/tst-argp1.c"
+
+#include <pthread.h>
+
+/* This is never called, just here to get pthreads linked in.  */
+void
+useless (void)
+{
+  pthread_create (0, 0, 0, 0);
+}
Index: trunk/src/libctests/glibc/nptl/tst-mutex1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-mutex1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-mutex1.c	(revision 2036)
@@ -0,0 +1,57 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+
+
+static int
+do_test (void)
+{
+  pthread_mutex_t m;
+
+  if (pthread_mutex_init (&m, NULL) != 0)
+    {
+      puts ("mutex_init failed");
+      return 1;
+    }
+
+  if (pthread_mutex_lock (&m) != 0)
+    {
+      puts ("mutex_lock failed");
+      return 1;
+    }
+
+  if (pthread_mutex_unlock (&m) != 0)
+    {
+      puts ("mutex_unlock failed");
+      return 1;
+    }
+
+  if (pthread_mutex_destroy (&m) != 0)
+    {
+      puts ("mutex_destroy failed");
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-mutex2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-mutex2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-mutex2.c	(revision 2036)
@@ -0,0 +1,223 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_mutex_t m;
+static pthread_barrier_t b;
+
+
+static void *
+tf (void *arg)
+{
+  int e = pthread_mutex_unlock (&m);
+  if (e == 0)
+    {
+      puts ("child: 1st mutex_unlock succeeded");
+      exit (1);
+    }
+  else if (e != EPERM)
+    {
+      puts ("child: 1st mutex_unlock error != EPERM");
+      exit (1);
+    }
+
+  e = pthread_mutex_trylock (&m);
+  if (e == 0)
+    {
+      puts ("child: 1st trylock suceeded");
+      exit (1);
+    }
+  if (e != EBUSY)
+    {
+      puts ("child: 1st trylock didn't return EBUSY");
+      exit (1);
+    }
+
+  e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("child: 1st barrier_wait failed");
+      exit (1);
+    }
+
+  e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("child: 2nd barrier_wait failed");
+      exit (1);
+    }
+
+  e = pthread_mutex_unlock (&m);
+  if (e == 0)
+    {
+      puts ("child: 2nd mutex_unlock succeeded");
+      exit (1);
+    }
+  else if (e != EPERM)
+    {
+      puts ("child: 2nd mutex_unlock error != EPERM");
+      exit (1);
+    }
+
+  if (pthread_mutex_trylock (&m) != 0)
+    {
+      puts ("child: 2nd trylock failed");
+      exit (1);
+    }
+
+  if (pthread_mutex_unlock (&m) != 0)
+    {
+      puts ("child: 3rd mutex_unlock failed");
+      exit (1);
+    }
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_mutexattr_t a;
+  int e;
+
+  if (pthread_mutexattr_init (&a) != 0)
+    {
+      puts ("mutexattr_init failed");
+      exit (1);
+    }
+
+  if (pthread_mutexattr_settype (&a, PTHREAD_MUTEX_ERRORCHECK) != 0)
+    {
+      puts ("mutexattr_settype failed");
+      exit (1);
+    }
+
+  if (pthread_mutex_init (&m, &a) != 0)
+    {
+      puts ("mutex_init failed");
+      exit (1);
+    }
+
+  if (pthread_barrier_init (&b, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  if ((e = pthread_mutex_unlock (&m)) == 0)
+    {
+      puts ("1st mutex_unlock succeeded");
+      exit (1);
+    }
+  else if (e != EPERM)
+    {
+      puts ("1st mutex_unlock error != EPERM");
+      exit (1);
+    }
+
+  if (pthread_mutex_lock (&m) != 0)
+    {
+      puts ("mutex_lock failed");
+      exit (1);
+    }
+
+  if ((e = pthread_mutex_lock (&m)) == 0)
+    {
+      puts ("2nd mutex_lock succeeded");
+      exit (1);
+    }
+  else if (e != EDEADLK)
+    {
+      puts ("2nd mutex_lock error != EDEADLK");
+      exit (1);
+    }
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      exit (1);
+    }
+
+  e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("1st barrier_wait failed");
+      exit (1);
+    }
+
+  if (pthread_mutex_unlock (&m) != 0)
+    {
+      puts ("2nd mutex_unlock failed");
+      exit (1);
+    }
+
+  if ((e = pthread_mutex_unlock (&m)) == 0)
+    {
+      puts ("3rd mutex_unlock succeeded");
+      exit (1);
+    }
+  else if (e != EPERM)
+    {
+      puts ("3rd mutex_unlock error != EPERM");
+      exit (1);
+    }
+
+  e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("2nd barrier_wait failed");
+      exit (1);
+    }
+
+  if (pthread_join (th, NULL) != 0)
+    {
+      puts ("join failed");
+      exit (1);
+    }
+
+  if (pthread_mutex_destroy (&m) != 0)
+    {
+      puts ("mutex_destroy failed");
+      exit (1);
+    }
+
+  if (pthread_barrier_destroy (&b) != 0)
+    {
+      puts ("barrier_destroy failed");
+      exit (1);
+    }
+
+  if (pthread_mutexattr_destroy (&a) != 0)
+    {
+      puts ("mutexattr_destroy failed");
+      exit (1);
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-mutex3.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-mutex3.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-mutex3.c	(revision 2036)
@@ -0,0 +1,225 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_mutex_t m;
+static pthread_barrier_t b;
+
+
+static void *
+tf (void *arg)
+{
+  int e = pthread_mutex_unlock (&m);
+  if (e == 0)
+    {
+      puts ("1st mutex_unlock in child succeeded");
+      exit (1);
+    }
+  if (e != EPERM)
+    {
+      puts ("1st mutex_unlock in child didn't return EPERM");
+      exit (1);
+    }
+
+  e = pthread_mutex_trylock (&m);
+  if (e == 0)
+    {
+      puts ("mutex_trylock in second thread succeeded");
+      exit (1);
+    }
+  if (e != EBUSY)
+    {
+      puts ("mutex_trylock returned wrong value");
+      exit (1);
+    }
+
+  e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      exit (1);
+    }
+
+  e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      exit (1);
+    }
+
+  e = pthread_mutex_unlock (&m);
+  if (e == 0)
+    {
+      puts ("2nd mutex_unlock in child succeeded");
+      exit (1);
+    }
+  if (e != EPERM)
+    {
+      puts ("2nd mutex_unlock in child didn't return EPERM");
+      exit (1);
+    }
+
+  if (pthread_mutex_trylock (&m) != 0)
+    {
+      puts ("2nd mutex_trylock in second thread failed");
+      exit (1);
+    }
+
+  if (pthread_mutex_unlock (&m) != 0)
+    {
+      puts ("3rd mutex_unlock in second thread failed");
+      exit (1);
+    }
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_mutexattr_t a;
+
+  if (pthread_mutexattr_init (&a) != 0)
+    {
+      puts ("mutexattr_init failed");
+      return 1;
+    }
+
+  if (pthread_mutexattr_settype (&a, PTHREAD_MUTEX_RECURSIVE) != 0)
+    {
+      puts ("mutexattr_settype failed");
+      return 1;
+    }
+
+  if (pthread_mutex_init (&m, &a) != 0)
+    {
+      puts ("mutex_init failed");
+      return 1;
+    }
+
+  if (pthread_barrier_init (&b, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      return 1;
+    }
+
+  if (pthread_mutex_lock (&m) != 0)
+    {
+      puts ("mutex_lock failed");
+      return 1;
+    }
+
+  if (pthread_mutex_lock (&m) != 0)
+    {
+      puts ("2nd mutex_lock failed");
+      return 1;
+    }
+
+  if (pthread_mutex_trylock (&m) != 0)
+    {
+      puts ("1st trylock failed");
+      return 1;
+    }
+
+  if (pthread_mutex_unlock (&m) != 0)
+    {
+      puts ("mutex_unlock failed");
+      return 1;
+    }
+
+  if (pthread_mutex_unlock (&m) != 0)
+    {
+      puts ("2nd mutex_unlock failed");
+      return 1;
+    }
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      return 1;
+    }
+
+  int e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      return 1;
+    }
+
+  if (pthread_mutex_unlock (&m) != 0)
+    {
+      puts ("3rd mutex_unlock failed");
+      return 1;
+    }
+
+  e = pthread_mutex_unlock (&m);
+  if (e == 0)
+    {
+      puts ("4th mutex_unlock succeeded");
+      return 1;
+    }
+  if (e != EPERM)
+    {
+      puts ("4th mutex_unlock didn't return EPERM");
+      return 1;
+    }
+
+  e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      return 1;
+    }
+
+  if (pthread_join (th, NULL) != 0)
+    {
+      puts ("join failed");
+      return 1;
+    }
+
+  if (pthread_barrier_destroy (&b) != 0)
+    {
+      puts ("barrier_destroy failed");
+      return 1;
+    }
+
+  if (pthread_mutex_destroy (&m) != 0)
+    {
+      puts ("mutex_destroy failed");
+      return 1;
+    }
+
+  if (pthread_mutexattr_destroy (&a) != 0)
+    {
+      puts ("mutexattr_destroy failed");
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-mutex4.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-mutex4.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-mutex4.c	(revision 2036)
@@ -0,0 +1,191 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+
+static int
+do_test (void)
+{
+  size_t ps = sysconf (_SC_PAGESIZE);
+  char tmpfname[] = "/tmp/tst-mutex4.XXXXXX";
+  char data[ps];
+  void *mem;
+  int fd;
+  pthread_mutex_t *m;
+  pthread_mutexattr_t a;
+  pid_t pid;
+  char *p;
+  int err;
+  int s;
+
+  fd = mkstemp (tmpfname);
+  if (fd == -1)
+    {
+      printf ("cannot open temporary file: %m\n");
+      return 1;
+    }
+
+  /* Make sure it is always removed.  */
+  unlink (tmpfname);
+
+  /* Create one page of data.  */
+  memset (data, '\0', ps);
+
+  /* Write the data to the file.  */
+  if (write (fd, data, ps) != (ssize_t) ps)
+    {
+      puts ("short write");
+      return 1;
+    }
+
+  mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+  if (mem == MAP_FAILED)
+    {
+      printf ("mmap failed: %m\n");
+      return 1;
+    }
+
+  m = (pthread_mutex_t *) (((uintptr_t) mem + __alignof (pthread_mutex_t))
+			   & ~(__alignof (pthread_mutex_t) - 1));
+  p = (char *) (m + 1);
+
+  if (pthread_mutexattr_init (&a) != 0)
+    {
+      puts ("mutexattr_init failed");
+      return 1;
+    }
+
+  if (pthread_mutexattr_getpshared (&a, &s) != 0)
+    {
+      puts ("1st mutexattr_getpshared failed");
+      return 1;
+    }
+
+  if (s != PTHREAD_PROCESS_PRIVATE)
+    {
+      puts ("default pshared value wrong");
+      return 1;
+    }
+
+  if (pthread_mutexattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0)
+    {
+      puts ("mutexattr_setpshared failed");
+      return 1;
+    }
+
+  if (pthread_mutexattr_getpshared (&a, &s) != 0)
+    {
+      puts ("2nd mutexattr_getpshared failed");
+      return 1;
+    }
+
+  if (s != PTHREAD_PROCESS_SHARED)
+    {
+      puts ("pshared value after setpshared call wrong");
+      return 1;
+    }
+
+  if (pthread_mutex_init (m, &a) != 0)
+    {
+      puts ("mutex_init failed");
+      return 1;
+    }
+
+  if (pthread_mutex_lock (m) != 0)
+    {
+      puts ("mutex_lock failed");
+      return 1;
+    }
+
+  if (pthread_mutexattr_destroy (&a) != 0)
+    {
+      puts ("mutexattr_destroy failed");
+      return 1;
+    }
+
+  err = pthread_mutex_trylock (m);
+  if (err == 0)
+    {
+      puts ("mutex_trylock succeeded");
+      return 1;
+    }
+  else if (err != EBUSY)
+    {
+      puts ("mutex_trylock didn't return EBUSY");
+      return 1;
+    }
+
+  *p = 0;
+
+  puts ("going to fork now");
+  pid = fork ();
+  if (pid == -1)
+    {
+      puts ("fork failed");
+      return 1;
+    }
+  else if (pid == 0)
+    {
+      /* Play some lock ping-pong.  It's our turn to unlock first.  */
+      if ((*p)++ != 0)
+	{
+	  puts ("child: *p != 0");
+	  return 1;
+	}
+
+      if (pthread_mutex_unlock (m) != 0)
+	{
+	  puts ("child: 1st mutex_unlock failed");
+	  return 1;
+	}
+
+      puts ("child done");
+    }
+  else
+    {
+      if (pthread_mutex_lock (m) != 0)
+	{
+	  puts ("parent: 2nd mutex_lock failed");
+	  return 1;
+	}
+
+      if (*p != 1)
+	{
+	  puts ("*p != 1");
+	  return 1;
+	}
+
+      puts ("parent done");
+    }
+
+  return 0;
+}
+
+#define TIMEOUT 4
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-mutex5.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-mutex5.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-mutex5.c	(revision 2036)
@@ -0,0 +1,186 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+
+#ifndef TYPE
+# define TYPE PTHREAD_MUTEX_NORMAL
+#endif
+
+
+static int
+do_test (void)
+{
+  pthread_mutex_t m;
+  struct timespec ts;
+  struct timeval tv;
+  struct timeval tv2;
+  int err;
+  pthread_mutexattr_t a;
+
+  if (pthread_mutexattr_init (&a) != 0)
+    {
+      puts ("mutexattr_init failed");
+      return 1;
+    }
+
+  if (pthread_mutexattr_settype (&a, TYPE) != 0)
+    {
+      puts ("mutexattr_settype failed");
+      return 1;
+    }
+
+  if (pthread_mutex_init (&m, &a) != 0)
+    {
+      puts ("mutex_init failed");
+      return 1;
+    }
+
+  if (pthread_mutexattr_destroy (&a) != 0)
+    {
+      puts ("mutexattr_destroy failed");
+      return 1;
+    }
+
+  if (pthread_mutex_lock (&m) != 0)
+    {
+      puts ("mutex_lock failed");
+      return 1;
+    }
+
+  if (pthread_mutex_trylock (&m) == 0)
+    {
+      puts ("mutex_trylock succeeded");
+      return 1;
+    }
+
+  gettimeofday (&tv, NULL);
+  TIMEVAL_TO_TIMESPEC (&tv, &ts);
+
+  ts.tv_sec += 2;	/* Wait 2 seconds.  */
+
+  err = pthread_mutex_timedlock (&m, &ts);
+  if (err == 0)
+    {
+      puts ("timedlock succeeded");
+      return 1;
+    }
+  else if (err != ETIMEDOUT)
+    {
+      printf ("timedlock error != ETIMEDOUT: %d\n", err);
+      return 1;
+    }
+  else
+    {
+      int clk_tck = sysconf (_SC_CLK_TCK);
+
+      gettimeofday (&tv2, NULL);
+
+      tv2.tv_sec -= tv.tv_sec;
+      tv2.tv_usec -= tv.tv_usec;
+      if (tv2.tv_usec < 0)
+	{
+	  tv2.tv_usec += 1000000;
+	  tv2.tv_sec -= 1;
+	}
+
+      /* Be a bit tolerant, add one CLK_TCK.  */
+      tv2.tv_usec += 1000000 / clk_tck;
+      if (tv2.tv_usec >= 1000000)
+	{
+	  tv2.tv_usec -= 1000000;
+	  ++tv2.tv_sec;
+	}
+
+      if (tv2.tv_sec < 2)
+	{
+	  printf ("premature timeout: %ld.%06ld difference\n",
+		  tv2.tv_sec, tv2.tv_usec);
+	  return 1;
+	}
+    }
+
+  (void) gettimeofday (&tv, NULL);
+  TIMEVAL_TO_TIMESPEC (&tv, &ts);
+
+  ts.tv_sec += 2;	/* Wait 2 seconds.  */
+  /* The following makes the ts value invalid.  */
+  ts.tv_nsec += 1000000000;
+
+  err = pthread_mutex_timedlock (&m, &ts);
+  if (err == 0)
+    {
+      puts ("2nd timedlock succeeded");
+      return 1;
+    }
+  else if (err != EINVAL)
+    {
+      printf ("2nd timedlock error != EINVAL: %d\n", err);
+      return 1;
+    }
+
+  if (pthread_mutex_unlock (&m) != 0)
+    {
+      puts ("mutex_unlock failed");
+      return 1;
+    }
+
+  (void) gettimeofday (&tv, NULL);
+  TIMEVAL_TO_TIMESPEC (&tv, &ts);
+
+  ts.tv_sec += 2;	/* Wait 2 seconds.  */
+  if (pthread_mutex_timedlock (&m, &ts) != 0)
+    {
+      puts ("3rd timedlock failed");
+    }
+
+  (void) gettimeofday (&tv2, NULL);
+
+  /* Check that timedlock didn't delay.  We use a limit of 0.1 secs.  */
+  timersub (&tv2, &tv, &tv2);
+  if (tv2.tv_sec > 0 || tv2.tv_usec > 100000)
+    {
+      puts ("3rd timedlock didn't return right away");
+      return 1;
+    }
+
+  if (pthread_mutex_unlock (&m) != 0)
+    {
+      puts ("final mutex_unlock failed");
+      return 1;
+    }
+
+  if (pthread_mutex_destroy (&m) != 0)
+    {
+      puts ("mutex_destroy failed");
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TIMEOUT 4
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-mutex5a.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-mutex5a.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-mutex5a.c	(revision 2036)
@@ -0,0 +1,2 @@
+#define TYPE PTHREAD_MUTEX_ADAPTIVE_NP
+#include "tst-mutex5.c"
Index: trunk/src/libctests/glibc/nptl/tst-mutex6.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-mutex6.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-mutex6.c	(revision 2036)
@@ -0,0 +1,55 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+static int
+do_test (void)
+{
+  pthread_mutex_t m;
+
+  if (pthread_mutex_init (&m, NULL) != 0)
+    {
+      puts ("mutex_init failed");
+      return 1;
+    }
+
+  if (pthread_mutex_lock (&m) != 0)
+    {
+      puts ("1st mutex_lock failed");
+      return 1;
+    }
+
+  /* Set an alarm for 1 second.  The wrapper will expect this.  */
+  alarm (1);
+
+  /* This call should never return.  */
+  pthread_mutex_lock (&m);
+
+  puts ("2nd mutex_lock returned");
+  return 1;
+}
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-mutex7.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-mutex7.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-mutex7.c	(revision 2036)
@@ -0,0 +1,121 @@
+/* Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <time.h>
+
+
+#ifndef INIT
+# define INIT PTHREAD_MUTEX_INITIALIZER
+#endif
+
+
+static pthread_mutex_t lock = INIT;
+
+
+#define ROUNDS 1000
+#define N 100
+
+
+static void *
+tf (void *arg)
+{
+  int nr = (long int) arg;
+  int cnt;
+  struct timespec ts = { .tv_sec = 0, .tv_nsec = 11000 };
+
+  for (cnt = 0; cnt < ROUNDS; ++cnt)
+    {
+      if (pthread_mutex_lock (&lock) != 0)
+	{
+	  printf ("thread %d: failed to get the lock\n", nr);
+	  return (void *) 1l;
+	}
+
+      if (pthread_mutex_unlock (&lock) != 0)
+	{
+	  printf ("thread %d: failed to release the lock\n", nr);
+	  return (void *) 1l;
+	}
+
+      nanosleep (&ts, NULL);
+    }
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_attr_t at;
+  pthread_t th[N];
+  int cnt;
+
+  if (pthread_attr_init (&at) != 0)
+    {
+      puts ("attr_init failed");
+      return 1;
+    }
+
+  if (pthread_attr_setstacksize (&at, 1 * 1024 * 1024) != 0)
+    {
+      puts ("attr_setstacksize failed");
+      return 1;
+    }
+
+  if (pthread_mutex_lock (&lock) != 0)
+    {
+      puts ("locking in parent failed");
+      return 1;
+    }
+
+  for (cnt = 0; cnt < N; ++cnt)
+    if (pthread_create (&th[cnt], &at, tf, (void *) (long int) cnt) != 0)
+      {
+	printf ("creating thread %d failed\n", cnt);
+	return 1;
+      }
+
+  if (pthread_attr_destroy (&at) != 0)
+    {
+      puts ("attr_destroy failed");
+      return 1;
+    }
+
+  if (pthread_mutex_unlock (&lock) != 0)
+    {
+      puts ("unlocking in parent failed");
+      return 1;
+    }
+
+  for (cnt = 0; cnt < N; ++cnt)
+    if (pthread_join (th[cnt], NULL) != 0)
+      {
+	printf ("joining thread %d failed\n", cnt);
+	return 1;
+      }
+
+  return 0;
+}
+
+#define TIMEOUT 60
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-mutex7a.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-mutex7a.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-mutex7a.c	(revision 2036)
@@ -0,0 +1,2 @@
+#define INIT PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
+#include "tst-mutex7.c"
Index: trunk/src/libctests/glibc/nptl/tst-mutex8.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-mutex8.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-mutex8.c	(revision 2036)
@@ -0,0 +1,367 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* This test checks behavior not required by POSIX.  */
+#include <errno.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_mutex_t *m;
+static pthread_barrier_t b;
+static pthread_cond_t c;
+static bool done;
+
+
+static void
+cl (void *arg)
+{
+  if (pthread_mutex_unlock (m) != 0)
+    {
+      puts ("cl: mutex_unlocked failed");
+      exit (1);
+    }
+}
+
+
+static void *
+tf (void *arg)
+{
+  if (pthread_mutex_lock (m) != 0)
+    {
+      puts ("tf: mutex_lock failed");
+      return (void *) 1l;
+    }
+
+  int e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      return (void *) 1l;
+    }
+
+  if (arg == NULL)
+    do
+      if (pthread_cond_wait (&c, m) != 0)
+	{
+	  puts ("tf: cond_wait failed");
+	  return (void *) 1l;
+	}
+    while (! done);
+  else
+    do
+      {
+	pthread_cleanup_push (cl, NULL);
+
+	if (pthread_cond_wait (&c, m) != 0)
+	  {
+	    puts ("tf: cond_wait failed");
+	    return (void *) 1l;
+	  }
+
+	pthread_cleanup_pop (0);
+      }
+    while (! done);
+
+  if (pthread_mutex_unlock (m) != 0)
+    {
+      puts ("tf: mutex_unlock failed");
+      return (void *) 1l;
+    }
+
+  return NULL;
+}
+
+
+static int
+check_type (const char *mas, pthread_mutexattr_t *ma)
+{
+  if (pthread_mutex_init (m, ma) != 0)
+    {
+      printf ("1st mutex_init failed for %s\n", mas);
+      return 1;
+    }
+
+  if (pthread_mutex_destroy (m) != 0)
+    {
+      printf ("immediate mutex_destroy failed for %s\n", mas);
+      return 1;
+    }
+
+  if (pthread_mutex_init (m, ma) != 0)
+    {
+      printf ("2nd mutex_init failed for %s\n", mas);
+      return 1;
+    }
+
+  if (pthread_mutex_lock (m) != 0)
+    {
+      printf ("1st mutex_lock failed for %s\n", mas);
+      return 1;
+    }
+
+  int e = pthread_mutex_destroy (m);
+  if (e == 0)
+    {
+      printf ("mutex_destroy of self-locked mutex succeeded for %s\n", mas);
+      return 1;
+    }
+  if (e != EBUSY)
+    {
+      printf ("mutex_destroy of self-locked mutex did not return EBUSY %s\n",
+	      mas);
+      return 1;
+    }
+
+  if (pthread_mutex_unlock (m) != 0)
+    {
+      printf ("1st mutex_unlock failed for %s\n", mas);
+      return 1;
+    }
+
+  if (pthread_mutex_trylock (m) != 0)
+    {
+      printf ("mutex_trylock failed for %s\n", mas);
+      return 1;
+    }
+
+  e = pthread_mutex_destroy (m);
+  if (e == 0)
+    {
+      printf ("mutex_destroy of self-trylocked mutex succeeded for %s\n", mas);
+      return 1;
+    }
+  if (e != EBUSY)
+    {
+      printf ("\
+mutex_destroy of self-trylocked mutex did not return EBUSY %s\n",
+	      mas);
+      return 1;
+    }
+
+  if (pthread_mutex_unlock (m) != 0)
+    {
+      printf ("2nd mutex_unlock failed for %s\n", mas);
+      return 1;
+    }
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("1st create failed");
+      return 1;
+    }
+  done = false;
+
+  e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("1st barrier_wait failed");
+      return 1;
+    }
+
+  if (pthread_mutex_lock (m) != 0)
+    {
+      printf ("2nd mutex_lock failed for %s\n", mas);
+      return 1;
+    }
+
+  if (pthread_mutex_unlock (m) != 0)
+    {
+      printf ("3rd mutex_unlock failed for %s\n", mas);
+      return 1;
+    }
+
+  e = pthread_mutex_destroy (m);
+  if (e == 0)
+    {
+      printf ("mutex_destroy of condvar-used mutex succeeded for %s\n", mas);
+      return 1;
+    }
+  if (e != EBUSY)
+    {
+      printf ("\
+mutex_destroy of condvar-used mutex did not return EBUSY for %s\n", mas);
+      return 1;
+    }
+
+  done = true;
+  if (pthread_cond_signal (&c) != 0)
+    {
+      puts ("cond_signal failed");
+      return 1;
+    }
+
+  void *r;
+  if (pthread_join (th, &r) != 0)
+    {
+      puts ("join failed");
+      return 1;
+    }
+  if (r != NULL)
+    {
+      puts ("thread didn't return NULL");
+      return 1;
+    }
+
+  if (pthread_mutex_destroy (m) != 0)
+    {
+      printf ("mutex_destroy after condvar-use failed for %s\n", mas);
+      return 1;
+    }
+
+  if (pthread_mutex_init (m, ma) != 0)
+    {
+      printf ("3rd mutex_init failed for %s\n", mas);
+      return 1;
+    }
+
+  if (pthread_create (&th, NULL, tf, (void *) 1) != 0)
+    {
+      puts ("2nd create failed");
+      return 1;
+    }
+  done = false;
+
+  e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("2nd barrier_wait failed");
+      return 1;
+    }
+
+  if (pthread_mutex_lock (m) != 0)
+    {
+      printf ("3rd mutex_lock failed for %s\n", mas);
+      return 1;
+    }
+
+  if (pthread_mutex_unlock (m) != 0)
+    {
+      printf ("4th mutex_unlock failed for %s\n", mas);
+      return 1;
+    }
+
+  e = pthread_mutex_destroy (m);
+  if (e == 0)
+    {
+      printf ("2nd mutex_destroy of condvar-used mutex succeeded for %s\n",
+	      mas);
+      return 1;
+    }
+  if (e != EBUSY)
+    {
+      printf ("\
+2nd mutex_destroy of condvar-used mutex did not return EBUSY for %s\n",
+	      mas);
+      return 1;
+    }
+
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("cond_cancel failed");
+      return 1;
+    }
+
+  if (pthread_join (th, &r) != 0)
+    {
+      puts ("join failed");
+      return 1;
+    }
+  if (r != PTHREAD_CANCELED)
+    {
+      puts ("thread not canceled");
+      return 1;
+    }
+
+  if (pthread_mutex_destroy (m) != 0)
+    {
+      printf ("mutex_destroy after condvar-canceled failed for %s\n", mas);
+      return 1;
+    }
+
+  return 0;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_mutex_t mm;
+  m = &mm;
+
+  if (pthread_barrier_init (&b, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      return 1;
+    }
+
+  if (pthread_cond_init (&c, NULL) != 0)
+    {
+      puts ("cond_init failed");
+      return 1;
+    }
+
+  puts ("check normal mutex");
+  int res = check_type ("normal", NULL);
+
+  pthread_mutexattr_t ma;
+  if (pthread_mutexattr_init (&ma) != 0)
+    {
+      puts ("1st mutexattr_init failed");
+      return 1;
+    }
+  if (pthread_mutexattr_settype (&ma, PTHREAD_MUTEX_RECURSIVE) != 0)
+    {
+      puts ("1st mutexattr_settype failed");
+      return 1;
+    }
+  puts ("check recursive mutex");
+  res |= check_type ("recursive", &ma);
+  if (pthread_mutexattr_destroy (&ma) != 0)
+    {
+      puts ("1st mutexattr_destroy failed");
+      return 1;
+    }
+
+  if (pthread_mutexattr_init (&ma) != 0)
+    {
+      puts ("2nd mutexattr_init failed");
+      return 1;
+    }
+  if (pthread_mutexattr_settype (&ma, PTHREAD_MUTEX_ERRORCHECK) != 0)
+    {
+      puts ("2nd mutexattr_settype failed");
+      return 1;
+    }
+  puts ("check error-checking mutex");
+  res |= check_type ("error-checking", &ma);
+  if (pthread_mutexattr_destroy (&ma) != 0)
+    {
+      puts ("2nd mutexattr_destroy failed");
+      return 1;
+    }
+
+  return res;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-mutex9.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-mutex9.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-mutex9.c	(revision 2036)
@@ -0,0 +1,186 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+
+static int
+do_test (void)
+{
+  size_t ps = sysconf (_SC_PAGESIZE);
+  char tmpfname[] = "/tmp/tst-mutex9.XXXXXX";
+  char data[ps];
+  void *mem;
+  int fd;
+  pthread_mutex_t *m;
+  pthread_mutexattr_t a;
+  pid_t pid;
+  char *p;
+
+  fd = mkstemp (tmpfname);
+  if (fd == -1)
+    {
+      printf ("cannot open temporary file: %m\n");
+      return 1;
+    }
+
+  /* Make sure it is always removed.  */
+  unlink (tmpfname);
+
+  /* Create one page of data.  */
+  memset (data, '\0', ps);
+
+  /* Write the data to the file.  */
+  if (write (fd, data, ps) != (ssize_t) ps)
+    {
+      puts ("short write");
+      return 1;
+    }
+
+  mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+  if (mem == MAP_FAILED)
+    {
+      printf ("mmap failed: %m\n");
+      return 1;
+    }
+
+  m = (pthread_mutex_t *) (((uintptr_t) mem + __alignof (pthread_mutex_t))
+			   & ~(__alignof (pthread_mutex_t) - 1));
+  p = (char *) (m + 1);
+
+  if (pthread_mutexattr_init (&a) != 0)
+    {
+      puts ("mutexattr_init failed");
+      return 1;
+    }
+
+  if (pthread_mutexattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0)
+    {
+      puts ("mutexattr_setpshared failed");
+      return 1;
+    }
+
+  if (pthread_mutexattr_settype (&a, PTHREAD_MUTEX_RECURSIVE) != 0)
+    {
+      puts ("mutexattr_settype failed");
+      return 1;
+    }
+
+  if (pthread_mutex_init (m, &a) != 0)
+    {
+      puts ("mutex_init failed");
+      return 1;
+    }
+
+  if (pthread_mutex_lock (m) != 0)
+    {
+      puts ("mutex_lock failed");
+      return 1;
+    }
+
+  if (pthread_mutexattr_destroy (&a) != 0)
+    {
+      puts ("mutexattr_destroy failed");
+      return 1;
+    }
+
+  puts ("going to fork now");
+  pid = fork ();
+  if (pid == -1)
+    {
+      puts ("fork failed");
+      return 1;
+    }
+  else if (pid == 0)
+    {
+      if (pthread_mutex_trylock (m) == 0)
+	{
+	  puts ("child: mutex_trylock succeeded");
+	  exit (1);
+	}
+
+      if (pthread_mutex_unlock (m) == 0)
+	{
+	  puts ("child: mutex_unlock succeeded");
+	  exit (1);
+	}
+
+      struct timeval tv;
+      gettimeofday (&tv, NULL);
+      struct timespec ts;
+      TIMEVAL_TO_TIMESPEC (&tv, &ts);
+      ts.tv_nsec += 500000000;
+      if (ts.tv_nsec >= 1000000000)
+	{
+	  ++ts.tv_sec;
+	  ts.tv_nsec -= 1000000000;
+	}
+
+      int e = pthread_mutex_timedlock (m, &ts);
+      if (e == 0)
+	{
+	  puts ("child: mutex_timedlock succeeded");
+	  exit (1);
+	}
+      if (e != ETIMEDOUT)
+	{
+	  puts ("child: mutex_timedlock didn't time out");
+	  exit (1);
+	}
+
+      alarm (1);
+
+      pthread_mutex_lock (m);
+
+      puts ("child: mutex_lock returned");
+
+      exit (0);
+    }
+
+  sleep (2);
+
+  int status;
+  if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
+    {
+      puts ("waitpid failed");
+      return 1;
+    }
+  if (! WIFSIGNALED (status))
+    {
+      puts ("child not killed by signal");
+      return 1;
+    }
+  if (WTERMSIG (status) != SIGALRM)
+    {
+      puts ("child not killed by SIGALRM");
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TIMEOUT 3
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-oddstacklimit.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-oddstacklimit.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-oddstacklimit.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-basic1.c"
Index: trunk/src/libctests/glibc/nptl/tst-once1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-once1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-once1.c	(revision 2036)
@@ -0,0 +1,51 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+
+
+static pthread_once_t once = PTHREAD_ONCE_INIT;
+
+static int global;
+
+static void
+once_handler (void)
+{
+  ++global;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_once (&once, once_handler);
+  pthread_once (&once, once_handler);
+
+  if (global != 1)
+    {
+      printf ("global = %d, expected 1\n", global);
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-once2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-once2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-once2.c	(revision 2036)
@@ -0,0 +1,104 @@
+/* Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+
+#define N 100
+
+static pthread_once_t once = PTHREAD_ONCE_INIT;
+
+static int global;
+
+static void
+once_handler (void)
+{
+  struct timespec ts;
+
+  ++global;
+
+  ts.tv_sec = 2;
+  ts.tv_nsec = 0;
+  nanosleep (&ts, NULL);
+}
+
+
+static void *
+tf (void *arg)
+{
+  pthread_once (&once, once_handler);
+
+  if (global != 1)
+    {
+      printf ("thread %ld: global == %d\n", (long int) arg, global);
+      exit (1);
+    }
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_attr_t at;
+  pthread_t th[N];
+  int cnt;
+
+  if (pthread_attr_init (&at) != 0)
+    {
+      puts ("attr_init failed");
+      return 1;
+    }
+
+  if (pthread_attr_setstacksize (&at, 1 * 1024 * 1024) != 0)
+    {
+      puts ("attr_setstacksize failed");
+      return 1;
+    }
+
+  for (cnt = 0; cnt < N; ++cnt)
+    if (pthread_create (&th[cnt], &at, tf, (void *) (long int) cnt) != 0)
+      {
+	printf ("creation of thread %d failed\n", cnt);
+	return 1;
+      }
+
+  if (pthread_attr_destroy (&at) != 0)
+    {
+      puts ("attr_destroy failed");
+      return 1;
+    }
+
+  for (cnt = 0; cnt < N; ++cnt)
+    if (pthread_join (th[cnt], NULL) != 0)
+      {
+	printf ("join of thread %d failed\n", cnt);
+	return 1;
+      }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 4
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-once3.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-once3.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-once3.c	(revision 2036)
@@ -0,0 +1,162 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+
+#define N 100
+
+static pthread_once_t once = PTHREAD_ONCE_INIT;
+
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
+
+static pthread_barrier_t bar;
+
+static int global;
+static int cl_called;
+
+static void
+once_handler1 (void)
+{
+  if (pthread_mutex_lock (&mut) != 0)
+    {
+      puts ("once_handler1: mutex_lock failed");
+      exit (1);
+    }
+  puts ("once_handler1: locked");
+
+  int r = pthread_barrier_wait (&bar);
+  if (r != 0 && r!= PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("once_handler1: barrier_wait failed");
+      exit (1);
+    }
+
+  pthread_cond_wait (&cond, &mut);
+
+  /* We should never get here.  */
+  exit (42);
+}
+
+static void
+once_handler2 (void)
+{
+  global = 1;
+}
+
+
+static void
+cl (void *arg)
+{
+  cl_called = 1;
+}
+
+
+static void *
+tf (void *arg)
+{
+  pthread_cleanup_push (cl, NULL)
+
+  pthread_once (&once, once_handler1);
+
+  pthread_cleanup_pop (0);
+
+  /* We should never get here.  */
+  puts ("pthread_once in tf returned");
+  exit (1);
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t th;
+
+  if (pthread_barrier_init (&bar, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      return 1;
+    }
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("first create failed");
+      return 1;
+    }
+
+  int r = pthread_barrier_wait (&bar);
+  if (r != 0 && r!= PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      return 1;
+    }
+
+  if (pthread_mutex_lock (&mut) != 0)
+    {
+      puts ("mutex_lock failed");
+      return 1;
+    }
+  /* We unlock the mutex so that we catch the case where the pthread_cond_wait
+     call incorrectly resumes and tries to get the mutex.  */
+  if (pthread_mutex_unlock (&mut) != 0)
+    {
+      puts ("mutex_unlock failed");
+      return 1;
+    }
+
+  /* Cancel the thread.  */
+  puts ("going to cancel");
+  if (pthread_cancel (th) != 0)
+    {
+      puts ("cancel failed");
+      return 1;
+    }
+
+  void *result;
+  pthread_join (th, &result);
+  if (result != PTHREAD_CANCELED)
+    {
+      puts ("join didn't return PTHREAD_CANCELED");
+      return 1;
+    }
+
+  if (cl_called != 1)
+    {
+      puts ("cleanup handler not called");
+      return 1;
+    }
+
+  pthread_once (&once, once_handler2);
+
+  if (global != 1)
+    {
+      puts ("global still 0");
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 4
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-once4.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-once4.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-once4.c	(revision 2036)
@@ -0,0 +1,202 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+
+
+static pthread_once_t once = PTHREAD_ONCE_INIT;
+
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
+
+static pthread_barrier_t bar;
+
+static int global;
+static int cl_called;
+
+static void
+once_handler1 (void)
+{
+  if (pthread_mutex_lock (&mut) != 0)
+    {
+      puts ("once_handler1: mutex_lock failed");
+      exit (1);
+    }
+
+  int r = pthread_barrier_wait (&bar);
+  if (r != 0 && r!= PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("once_handler1: barrier_wait failed");
+      exit (1);
+    }
+
+  pthread_cond_wait (&cond, &mut);
+
+  /* We should never get here.  */
+}
+
+
+static void
+once_handler2 (void)
+{
+  global = 1;
+}
+
+
+static void
+cl (void *arg)
+{
+  ++cl_called;
+}
+
+
+static void *
+tf1 (void *arg)
+{
+  pthread_cleanup_push (cl, NULL);
+
+  pthread_once (&once, once_handler1);
+
+  pthread_cleanup_pop (0);
+
+  /* We should never get here.  */
+  puts ("pthread_once in tf returned");
+  exit (1);
+}
+
+
+static void *
+tf2 (void *arg)
+{
+  pthread_cleanup_push (cl, NULL);
+
+  int r = pthread_barrier_wait (&bar);
+  if (r != 0 && r!= PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("once_handler2: barrier_wait failed");
+      exit (1);
+    }
+
+  pthread_cleanup_pop (0);
+
+  pthread_once (&once, once_handler2);
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t th[2];
+
+  if (pthread_barrier_init (&bar, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      return 1;
+    }
+
+  if (pthread_create (&th[0], NULL, tf1, NULL) != 0)
+    {
+      puts ("first create failed");
+      return 1;
+    }
+
+  int r = pthread_barrier_wait (&bar);
+  if (r != 0 && r!= PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("first barrier_wait failed");
+      return 1;
+    }
+
+  if (pthread_mutex_lock (&mut) != 0)
+    {
+      puts ("mutex_lock failed");
+      return 1;
+    }
+  /* We unlock the mutex so that we catch the case where the pthread_cond_wait
+     call incorrectly resumes and tries to get the mutex.  */
+  if (pthread_mutex_unlock (&mut) != 0)
+    {
+      puts ("mutex_unlock failed");
+      return 1;
+    }
+
+  if (pthread_create (&th[1], NULL, tf2, NULL) != 0)
+    {
+      puts ("second create failed");
+      return 1;
+    }
+
+  r = pthread_barrier_wait (&bar);
+  if (r != 0 && r!= PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("second barrier_wait failed");
+      return 1;
+    }
+
+  /* Give the second thread a chance to reach the pthread_once call.  */
+  sleep (2);
+
+  /* Cancel the thread.  */
+  if (pthread_cancel (th[0]) != 0)
+    {
+      puts ("cancel failed");
+      return 1;
+    }
+
+  void *result;
+  pthread_join (th[0], &result);
+  if (result != PTHREAD_CANCELED)
+    {
+      puts ("first join didn't return PTHREAD_CANCELED");
+      return 1;
+    }
+
+  puts ("joined first thread");
+
+  pthread_join (th[1], &result);
+  if (result != NULL)
+    {
+      puts ("second join didn't return PTHREAD_CANCELED");
+      return 1;
+    }
+
+  if (global != 1)
+    {
+      puts ("global still 0");
+      return 1;
+    }
+
+  if (cl_called != 1)
+    {
+      printf ("cl_called = %d\n", cl_called);
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 4
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-oncex3.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-oncex3.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-oncex3.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-once3.c"
Index: trunk/src/libctests/glibc/nptl/tst-oncex4.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-oncex4.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-oncex4.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-once4.c"
Index: trunk/src/libctests/glibc/nptl/tst-popen1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-popen1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-popen1.c	(revision 2036)
@@ -0,0 +1,60 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <error.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+static void *
+dummy (void *x)
+{
+  return NULL;
+}
+
+static char buf[sizeof "something\n"];
+
+static int
+do_test (void)
+{
+  FILE *f;
+  pthread_t p;
+  int err;
+
+  f = popen ("echo something", "r");
+  if (f == NULL)
+    error (EXIT_FAILURE, errno, "popen failed");
+  if (fgets (buf, sizeof (buf), f) == NULL)
+    error (EXIT_FAILURE, 0, "fgets failed");
+  if (strcmp (buf, "something\n"))
+    error (EXIT_FAILURE, 0, "read wrong data");
+  if (pclose (f))
+    error (EXIT_FAILURE, errno, "pclose returned non-zero");
+  if ((err = pthread_create (&p, NULL, dummy, NULL)))
+    error (EXIT_FAILURE, err, "pthread_create failed");
+  if ((err = pthread_join (p, NULL)))
+    error (EXIT_FAILURE, err, "pthread_join failed");
+  exit (0);
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-raise1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-raise1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-raise1.c	(revision 2036)
@@ -0,0 +1,62 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <error.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+volatile int count;
+
+void
+sh (int sig)
+{
+  ++count;
+}
+
+int
+main (void)
+{
+  struct sigaction sa;
+  sa.sa_handler = sh;
+  sigemptyset (&sa.sa_mask);
+  sa.sa_flags = 0;
+  if (sigaction (SIGUSR1, &sa, NULL) < 0)
+    {
+      printf ("sigaction failed: %m\n");
+      exit (1);
+    }
+  if (raise (SIGUSR1) < 0)
+    {
+      printf ("first raise failed: %m\n");
+      exit (1);
+    }
+  if (raise (SIGUSR1) < 0)
+    {
+      printf ("second raise failed: %m\n");
+      exit (1);
+    }
+  if (count != 2)
+    {
+      printf ("signal handler not called 2 times\n");
+      exit (1);
+    }
+  exit (0);
+}
Index: trunk/src/libctests/glibc/nptl/tst-rwlock1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-rwlock1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-rwlock1.c	(revision 2036)
@@ -0,0 +1,117 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+
+
+static int
+do_test (void)
+{
+  pthread_rwlock_t r;
+
+  if (pthread_rwlock_init (&r, NULL) != 0)
+    {
+      puts ("rwlock_init failed");
+      return 1;
+    }
+  puts ("rwlock_init succeeded");
+
+  if (pthread_rwlock_rdlock (&r) != 0)
+    {
+      puts ("1st rwlock_rdlock failed");
+      return 1;
+    }
+  puts ("1st rwlock_rdlock succeeded");
+
+  if (pthread_rwlock_rdlock (&r) != 0)
+    {
+      puts ("2nd rwlock_rdlock failed");
+      return 1;
+    }
+  puts ("2nd rwlock_rdlock succeeded");
+
+  if (pthread_rwlock_unlock (&r) != 0)
+    {
+      puts ("1st rwlock_unlock failed");
+      return 1;
+    }
+  puts ("1st rwlock_unlock succeeded");
+
+  if (pthread_rwlock_unlock (&r) != 0)
+    {
+      puts ("2nd rwlock_unlock failed");
+      return 1;
+    }
+  puts ("2nd rwlock_unlock succeeded");
+
+  if (pthread_rwlock_wrlock (&r) != 0)
+    {
+      puts ("1st rwlock_wrlock failed");
+      return 1;
+    }
+  puts ("1st rwlock_wrlock succeeded");
+
+  if (pthread_rwlock_unlock (&r) != 0)
+    {
+      puts ("3rd rwlock_unlock failed");
+      return 1;
+    }
+  puts ("3rd rwlock_unlock succeeded");
+
+  if (pthread_rwlock_wrlock (&r) != 0)
+    {
+      puts ("2nd rwlock_wrlock failed");
+      return 1;
+    }
+  puts ("2nd rwlock_wrlock succeeded");
+
+  if (pthread_rwlock_unlock (&r) != 0)
+    {
+      puts ("4th rwlock_unlock failed");
+      return 1;
+    }
+  puts ("4th rwlock_unlock succeeded");
+
+  if (pthread_rwlock_rdlock (&r) != 0)
+    {
+      puts ("3rd rwlock_rdlock failed");
+      return 1;
+    }
+  puts ("3rd rwlock_rdlock succeeded");
+
+  if (pthread_rwlock_unlock (&r) != 0)
+    {
+      puts ("5th rwlock_unlock failed");
+      return 1;
+    }
+  puts ("5th rwlock_unlock succeeded");
+
+  if (pthread_rwlock_destroy (&r) != 0)
+    {
+      puts ("rwlock_destroy failed");
+      return 1;
+    }
+  puts ("rwlock_destroy succeeded");
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-rwlock10.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-rwlock10.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-rwlock10.c	(revision 2036)
@@ -0,0 +1,21 @@
+/* Test program for timedout read/write lock functions.
+   Copyright (C) 2003 Free Software Foundation, Inc.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#define INIT PTHREAD_RWLOCK_INITIALIZER
+#include "tst-rwlock8.c"
Index: trunk/src/libctests/glibc/nptl/tst-rwlock11.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-rwlock11.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-rwlock11.c	(revision 2036)
@@ -0,0 +1,21 @@
+/* Test program for timedout read/write lock functions.
+   Copyright (C) 2003 Free Software Foundation, Inc.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#define INIT PTHREAD_RWLOCK_INITIALIZER
+#include "tst-rwlock9.c"
Index: trunk/src/libctests/glibc/nptl/tst-rwlock12.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-rwlock12.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-rwlock12.c	(revision 2036)
@@ -0,0 +1,208 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+
+static int
+do_test (void)
+{
+  size_t ps = sysconf (_SC_PAGESIZE);
+  char tmpfname[] = "/tmp/tst-rwlock12.XXXXXX";
+  char data[ps];
+  void *mem;
+  int fd;
+  pthread_mutex_t *m;
+  pthread_mutexattr_t ma;
+  pthread_rwlock_t *r;
+  pthread_rwlockattr_t ra;
+  pid_t pid;
+  int status = 0;
+
+  fd = mkstemp (tmpfname);
+  if (fd == -1)
+    {
+      printf ("cannot open temporary file: %m\n");
+      return 1;
+    }
+
+  /* Make sure it is always removed.  */
+  unlink (tmpfname);
+
+  /* Create one page of data.  */
+  memset (data, '\0', ps);
+
+  /* Write the data to the file.  */
+  if (write (fd, data, ps) != (ssize_t) ps)
+    {
+      puts ("short write");
+      return 1;
+    }
+
+  mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+  if (mem == MAP_FAILED)
+    {
+      printf ("mmap failed: %m\n");
+      return 1;
+    }
+
+  r = (pthread_rwlock_t *) (((uintptr_t) mem + __alignof (pthread_rwlock_t))
+			    & ~(__alignof (pthread_rwlock_t) - 1));
+  /* The following assumes alignment for a mutex is at least as high
+     as that for a rwlock.  Which is true in our case.  */
+  m = (pthread_mutex_t *) (r + 1);
+
+  if (pthread_rwlockattr_init (&ra) != 0)
+    {
+      puts ("rwlockattr_init failed");
+      return 1;
+    }
+
+  if (pthread_rwlockattr_setpshared (&ra, PTHREAD_PROCESS_SHARED) != 0)
+    {
+      puts ("rwlockattr_setpshared failed");
+      return 1;
+    }
+
+  if (pthread_rwlock_init (r, &ra) != 0)
+    {
+      puts ("rwlock_init failed");
+      return 1;
+    }
+
+  if (pthread_mutexattr_init (&ma) != 0)
+    {
+      puts ("rwlockattr_init failed");
+      return 1;
+    }
+
+  if (pthread_mutexattr_setpshared (&ma, PTHREAD_PROCESS_SHARED) != 0)
+    {
+      puts ("mutexattr_setpshared failed");
+      return 1;
+    }
+
+  if (pthread_mutex_init (m, &ma) != 0)
+    {
+      puts ("mutex_init failed");
+      return 1;
+    }
+
+  /* Lock the mutex.  */
+  if (pthread_mutex_lock (m) != 0)
+    {
+      puts ("mutex_lock failed");
+      return 1;
+    }
+
+  puts ("going to fork now");
+  pid = fork ();
+  if (pid == -1)
+    {
+      puts ("fork failed");
+      return 1;
+    }
+  else if (pid == 0)
+    {
+      /* Lock the mutex.  */
+      if (pthread_mutex_lock (m) != 0)
+	{
+	  puts ("child: mutex_lock failed");
+	  return 1;
+	}
+
+      /* Try to get the rwlock.  */
+      if (pthread_rwlock_trywrlock (r) == 0)
+	{
+	  puts ("rwlock_trywrlock succeeded");
+	  return 1;
+	}
+
+      /* Try again.  */
+      struct timespec ts = { .tv_sec = 0, .tv_nsec = 500000000 };
+      int e = pthread_rwlock_timedwrlock (r, &ts);
+      if (e == 0)
+	{
+	  puts ("rwlock_timedwrlock succeeded");
+	  return 1;
+	}
+      if (e != ETIMEDOUT)
+	{
+	  puts ("rwlock_timedwrlock didn't return ETIMEDOUT");
+	  status = 1;
+	}
+
+      if (pthread_rwlock_tryrdlock (r) == 0)
+	{
+	  puts ("rwlock_tryrdlock succeeded");
+	  return 1;
+	}
+
+      e = pthread_rwlock_timedrdlock (r, &ts);
+      if (e == 0)
+	{
+	  puts ("rwlock_timedrdlock succeeded");
+	  return 1;
+	}
+      if (e != ETIMEDOUT)
+	{
+	  puts ("rwlock_timedrdlock didn't return ETIMEDOUT");
+	  status = 1;
+	}
+    }
+  else
+    {
+      /* Lock the rwlock for writing.  */
+      if (pthread_rwlock_wrlock (r) != 0)
+	{
+	  puts ("rwlock_wrlock failed");
+	  kill (pid, SIGTERM);
+	  return 1;
+	}
+
+      /* Allow the child to run.  */
+      if (pthread_mutex_unlock (m) != 0)
+	{
+	  puts ("mutex_unlock failed");
+	  kill (pid, SIGTERM);
+	  return 1;
+	}
+
+      /* Just wait for the child.  */
+      if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
+	{
+	  puts ("waitpid failed");
+	  kill (pid, SIGTERM);
+	  return 1;
+	}
+    }
+
+  return status;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-rwlock13.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-rwlock13.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-rwlock13.c	(revision 2036)
@@ -0,0 +1,71 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <string.h>
+
+
+static int
+do_test (void)
+{
+  pthread_rwlock_t r;
+  int ret;
+
+  memset (&r, 0xaa, sizeof (r));
+  if ((ret = pthread_rwlock_init (&r, NULL)) != 0)
+    {
+      printf ("rwlock_init failed: %d\n", ret);
+      return 1;
+    }
+
+  if ((ret = pthread_rwlock_rdlock (&r)) != 0)
+    {
+      printf ("rwlock_rdlock failed: %d\n", ret);
+      return 1;
+    }
+
+  if ((ret = pthread_rwlock_unlock (&r)) != 0)
+    {
+      printf ("rwlock_unlock failed: %d\n", ret);
+      return 1;
+    }
+
+  if ((ret = pthread_rwlock_wrlock (&r)) != 0)
+    {
+      printf ("rwlock_wrlock failed: %d\n", ret);
+      return 1;
+    }
+
+  if ((ret = pthread_rwlock_unlock (&r)) != 0)
+    {
+      printf ("second rwlock_unlock failed: %d\n", ret);
+      return 1;
+    }
+
+  if ((ret = pthread_rwlock_destroy (&r)) != 0)
+    {
+      printf ("second rwlock_destroy failed: %d\n", ret);
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-rwlock14.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-rwlock14.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-rwlock14.c	(revision 2036)
@@ -0,0 +1,169 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+
+static pthread_barrier_t b;
+static pthread_rwlock_t r = PTHREAD_RWLOCK_INITIALIZER;
+
+
+static void *
+tf (void *arg)
+{
+  /* Lock the read-write lock.  */
+  if (pthread_rwlock_wrlock (&r) != 0)
+    {
+      puts ("tf: cannot lock rwlock");
+      exit (EXIT_FAILURE);
+    }
+
+  pthread_t mt = *(pthread_t *) arg;
+
+  pthread_barrier_wait (&b);
+
+  /* This call will never return.  */
+  pthread_join (mt, NULL);
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  int result = 0;
+  struct timespec ts;
+
+  if (clock_gettime (CLOCK_REALTIME, &ts) != 0)
+    {
+      puts ("clock_gettime failed");
+      return 1;
+    }
+
+  if (pthread_barrier_init (&b, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      return 1;
+    }
+
+  pthread_t me = pthread_self ();
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, &me) != 0)
+    {
+      puts ("create failed");
+      return 1;
+    }
+
+  /* Wait until the rwlock is locked.  */
+  pthread_barrier_wait (&b);
+
+  ts.tv_nsec = -1;
+
+  int e = pthread_rwlock_timedrdlock (&r, &ts);
+  if (e == 0)
+    {
+      puts ("first rwlock_timedrdlock did not fail");
+      result = 1;
+    }
+  else if (e != EINVAL)
+    {
+      puts ("first rwlock_timedrdlock did not return EINVAL");
+      result = 1;
+    }
+
+  e = pthread_rwlock_timedwrlock (&r, &ts);
+  if (e == 0)
+    {
+      puts ("first rwlock_timedwrlock did not fail");
+      result = 1;
+    }
+  else if (e != EINVAL)
+    {
+      puts ("first rwlock_timedwrlock did not return EINVAL");
+      result = 1;
+    }
+
+  ts.tv_nsec = 1000000000;
+
+  e = pthread_rwlock_timedrdlock (&r, &ts);
+  if (e == 0)
+    {
+      puts ("second rwlock_timedrdlock did not fail");
+      result = 1;
+    }
+  else if (e != EINVAL)
+    {
+      puts ("second rwlock_timedrdlock did not return EINVAL");
+      result = 1;
+    }
+
+  e = pthread_rwlock_timedrdlock (&r, &ts);
+  if (e == 0)
+    {
+      puts ("second rwlock_timedrdlock did not fail");
+      result = 1;
+    }
+  else if (e != EINVAL)
+    {
+      puts ("second rwlock_timedrdlock did not return EINVAL");
+      result = 1;
+    }
+
+  ts.tv_nsec = 0x100001000LL;
+  if (ts.tv_nsec != 0x100001000LL)
+    ts.tv_nsec = 2000000000;
+
+  e = pthread_rwlock_timedrdlock (&r, &ts);
+  if (e == 0)
+    {
+      puts ("third rwlock_timedrdlock did not fail");
+      result = 1;
+    }
+  else if (e != EINVAL)
+    {
+      puts ("third rwlock_timedrdlock did not return EINVAL");
+      result = 1;
+    }
+
+  e = pthread_rwlock_timedrdlock (&r, &ts);
+  if (e == 0)
+    {
+      puts ("third rwlock_timedrdlock did not fail");
+      result = 1;
+    }
+  else if (e != EINVAL)
+    {
+      puts ("third rwlock_timedrdlock did not return EINVAL");
+      result = 1;
+    }
+
+  if (result == 0)
+    puts ("no bugs");
+
+  return result;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-rwlock2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-rwlock2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-rwlock2.c	(revision 2036)
@@ -0,0 +1,143 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+
+
+static int
+do_test (void)
+{
+  pthread_rwlock_t r;
+  int e;
+
+  if (pthread_rwlock_init (&r, NULL) != 0)
+    {
+      puts ("rwlock_init failed");
+      return 1;
+    }
+  puts ("rwlock_init succeeded");
+
+  if (pthread_rwlock_wrlock (&r) != 0)
+    {
+      puts ("1st rwlock_wrlock failed");
+      return 1;
+    }
+  puts ("1st rwlock_wrlock succeeded");
+
+  e = pthread_rwlock_tryrdlock (&r);
+  if (e == 0)
+    {
+      puts ("rwlock_tryrdlock on rwlock with writer succeeded");
+      return 1;
+    }
+  if (e != EBUSY)
+    {
+      puts ("rwlock_tryrdlock on rwlock with writer return value != EBUSY");
+      return 1;
+    }
+  puts ("rwlock_tryrdlock on rwlock with writer failed with EBUSY");
+
+  e = pthread_rwlock_trywrlock (&r);
+  if (e == 0)
+    {
+      puts ("rwlock_trywrlock on rwlock with writer succeeded");
+      return 1;
+    }
+  if (e != EBUSY)
+    {
+      puts ("rwlock_trywrlock on rwlock with writer return value != EBUSY");
+      return 1;
+    }
+  puts ("rwlock_trywrlock on rwlock with writer failed with EBUSY");
+
+  if (pthread_rwlock_unlock (&r) != 0)
+    {
+      puts ("1st rwlock_unlock failed");
+      return 1;
+    }
+  puts ("1st rwlock_unlock succeeded");
+
+  if (pthread_rwlock_tryrdlock (&r) != 0)
+    {
+      puts ("rwlock_tryrdlock on unlocked rwlock failed");
+      return 1;
+    }
+  puts ("rwlock_tryrdlock on unlocked rwlock succeeded");
+
+  e = pthread_rwlock_trywrlock (&r);
+  if (e == 0)
+    {
+      puts ("rwlock_trywrlock on rwlock with reader succeeded");
+      return 1;
+    }
+  if (e != EBUSY)
+    {
+      puts ("rwlock_trywrlock on rwlock with reader return value != EBUSY");
+      return 1;
+    }
+  puts ("rwlock_trywrlock on rwlock with reader failed with EBUSY");
+
+  if (pthread_rwlock_unlock (&r) != 0)
+    {
+      puts ("2nd rwlock_unlock failed");
+      return 1;
+    }
+  puts ("2nd rwlock_unlock succeeded");
+
+  if (pthread_rwlock_trywrlock (&r) != 0)
+    {
+      puts ("rwlock_trywrlock on unlocked rwlock failed");
+      return 1;
+    }
+  puts ("rwlock_trywrlock on unlocked rwlock succeeded");
+
+  e = pthread_rwlock_tryrdlock (&r);
+  if (e == 0)
+    {
+      puts ("rwlock_tryrdlock on rwlock with writer succeeded");
+      return 1;
+    }
+  if (e != EBUSY)
+    {
+      puts ("rwlock_tryrdlock on rwlock with writer return value != EBUSY");
+      return 1;
+    }
+  puts ("rwlock_tryrdlock on rwlock with writer failed with EBUSY");
+
+  if (pthread_rwlock_unlock (&r) != 0)
+    {
+      puts ("3rd rwlock_unlock failed");
+      return 1;
+    }
+  puts ("3rd rwlock_unlock succeeded");
+
+  if (pthread_rwlock_destroy (&r) != 0)
+    {
+      puts ("rwlock_destroy failed");
+      return 1;
+    }
+  puts ("rwlock_destroy succeeded");
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-rwlock3.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-rwlock3.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-rwlock3.c	(revision 2036)
@@ -0,0 +1,93 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* This test case checks more than standard compliance.  An
+   implementation may provide this service but it is not required to
+   do so.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+
+
+static int
+do_test (void)
+{
+  pthread_rwlock_t r;
+  int e;
+
+  if (pthread_rwlock_init (&r, NULL) != 0)
+    {
+      puts ("rwlock_init failed");
+      return 1;
+    }
+  puts ("rwlock_init succeeded");
+
+  if (pthread_rwlock_trywrlock (&r) != 0)
+    {
+      puts ("rwlock_trywrlock on unlocked rwlock failed");
+      return 1;
+    }
+  puts ("rwlock_trywrlock on unlocked rwlock succeeded");
+
+  e = pthread_rwlock_rdlock (&r);
+  if (e == 0)
+    {
+      puts ("rwlock_rdlock on rwlock with writer succeeded");
+      return 1;
+    }
+  if (e != EDEADLK)
+    {
+      puts ("rwlock_rdlock on rwlock with writer failed != EDEADLK");
+      return 1;
+    }
+  puts ("rwlock_rdlock on rwlock with writer failed with EDEADLK");
+
+  e = pthread_rwlock_wrlock (&r);
+  if (e == 0)
+    {
+      puts ("rwlock_wrlock on rwlock with writer succeeded");
+      return 1;
+    }
+  if (e != EDEADLK)
+    {
+      puts ("rwlock_wrlock on rwlock with writer failed != EDEADLK");
+      return 1;
+    }
+  puts ("rwlock_wrlock on rwlock with writer failed with EDEADLK");
+
+  if (pthread_rwlock_unlock (&r) != 0)
+    {
+      puts ("rwlock_unlock failed");
+      return 1;
+    }
+  puts ("rwlock_unlock succeeded");
+
+  if (pthread_rwlock_destroy (&r) != 0)
+    {
+      puts ("rwlock_destroy failed");
+      return 1;
+    }
+  puts ("rwlock_destroy succeeded");
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-rwlock4.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-rwlock4.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-rwlock4.c	(revision 2036)
@@ -0,0 +1,190 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+
+static int
+do_test (void)
+{
+  size_t ps = sysconf (_SC_PAGESIZE);
+  char tmpfname[] = "/tmp/tst-rwlock4.XXXXXX";
+  char data[ps];
+  void *mem;
+  int fd;
+  pthread_rwlock_t *r;
+  pthread_rwlockattr_t a;
+  pid_t pid;
+  char *p;
+  int err;
+  int s;
+
+  fd = mkstemp (tmpfname);
+  if (fd == -1)
+    {
+      printf ("cannot open temporary file: %m\n");
+      return 1;
+    }
+
+  /* Make sure it is always removed.  */
+  unlink (tmpfname);
+
+  /* Create one page of data.  */
+  memset (data, '\0', ps);
+
+  /* Write the data to the file.  */
+  if (write (fd, data, ps) != (ssize_t) ps)
+    {
+      puts ("short write");
+      return 1;
+    }
+
+  mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+  if (mem == MAP_FAILED)
+    {
+      printf ("mmap failed: %m\n");
+      return 1;
+    }
+
+  r = (pthread_rwlock_t *) (((uintptr_t) mem + __alignof (pthread_rwlock_t))
+			    & ~(__alignof (pthread_rwlock_t) - 1));
+  p = (char *) (r + 1);
+
+  if (pthread_rwlockattr_init (&a) != 0)
+    {
+      puts ("rwlockattr_init failed");
+      return 1;
+    }
+
+  if (pthread_rwlockattr_getpshared (&a, &s) != 0)
+    {
+      puts ("1st rwlockattr_getpshared failed");
+      return 1;
+    }
+
+  if (s != PTHREAD_PROCESS_PRIVATE)
+    {
+      puts ("default pshared value wrong");
+      return 1;
+    }
+
+  if (pthread_rwlockattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0)
+    {
+      puts ("rwlockattr_setpshared failed");
+      return 1;
+    }
+
+  if (pthread_rwlockattr_getpshared (&a, &s) != 0)
+    {
+      puts ("2nd rwlockattr_getpshared failed");
+      return 1;
+    }
+
+  if (s != PTHREAD_PROCESS_SHARED)
+    {
+      puts ("pshared value after setpshared call wrong");
+      return 1;
+    }
+
+  if (pthread_rwlock_init (r, &a) != 0)
+    {
+      puts ("rwlock_init failed");
+      return 1;
+    }
+
+  if (pthread_rwlock_rdlock (r) != 0)
+    {
+      puts ("rwlock_rdlock failed");
+      return 1;
+    }
+
+  if (pthread_rwlockattr_destroy (&a) != 0)
+    {
+      puts ("rwlockattr_destroy failed");
+      return 1;
+    }
+
+  err = pthread_rwlock_trywrlock (r);
+  if (err == 0)
+    {
+      puts ("rwlock_trywrlock succeeded");
+      return 1;
+    }
+  else if (err != EBUSY)
+    {
+      puts ("rwlock_trywrlock didn't return EBUSY");
+      return 1;
+    }
+
+  *p = 0;
+
+  puts ("going to fork now");
+  pid = fork ();
+  if (pid == -1)
+    {
+      puts ("fork failed");
+      return 1;
+    }
+  else if (pid == 0)
+    {
+      /* Play some lock ping-pong.  It's our turn to unlock first.  */
+      if ((*p)++ != 0)
+	{
+	  puts ("child: *p != 0");
+	  return 1;
+	}
+
+      if (pthread_rwlock_unlock (r) != 0)
+	{
+	  puts ("child: 1st rwlock_unlock failed");
+	  return 1;
+	}
+
+      puts ("child done");
+    }
+  else
+    {
+      if (pthread_rwlock_wrlock (r) != 0)
+	{
+	  puts ("parent: rwlock_wrlock failed");
+	  return 1;
+	}
+
+      if (*p != 1)
+	{
+	  puts ("*p != 1");
+	  return 1;
+	}
+
+      puts ("parent done");
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-rwlock5.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-rwlock5.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-rwlock5.c	(revision 2036)
@@ -0,0 +1,87 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
+static pthread_rwlock_t r;
+
+
+static void *
+tf (void *arg)
+{
+  if (pthread_rwlock_wrlock (&r) == 0)
+    {
+      puts ("child: rwlock_wrlock succeeded");
+      exit (1);
+    }
+
+  puts ("child: rwlock_wrlock returned");
+
+  exit (1);
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t th;
+
+  if (pthread_rwlock_init (&r, NULL) != 0)
+    {
+      puts ("rwlock_init failed");
+      return 1;
+    }
+
+  if (pthread_rwlock_wrlock (&r) != 0)
+    {
+      puts ("rwlock_wrlock failed");
+      return 1;
+    }
+
+  if (pthread_mutex_lock (&m) != 0)
+    {
+      puts ("mutex_lock failed");
+      return 1;
+    }
+
+  /* Set an alarm for 1 second.  The wrapper will expect this.  */
+  alarm (1);
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      return 1;
+    }
+
+  /* This call should never return.  */
+  pthread_mutex_lock (&m);
+
+  puts ("2nd mutex_lock returned");
+  return 1;
+}
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-rwlock6.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-rwlock6.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-rwlock6.c	(revision 2036)
@@ -0,0 +1,226 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/time.h>
+
+
+static int kind[] =
+  {
+    PTHREAD_RWLOCK_PREFER_READER_NP,
+    PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,
+    PTHREAD_RWLOCK_PREFER_WRITER_NP,
+  };
+
+
+static void *
+tf (void *arg)
+{
+  pthread_rwlock_t *r = arg;
+
+  /* Timeout: 0.3 secs.  */
+  struct timeval tv;
+  (void) gettimeofday (&tv, NULL);
+
+  struct timespec ts;
+  TIMEVAL_TO_TIMESPEC (&tv, &ts);
+  ts.tv_nsec += 300000000;
+  if (ts.tv_nsec >= 1000000000)
+    {
+      ts.tv_nsec -= 1000000000;
+      ++ts.tv_sec;
+    }
+
+  puts ("child calling timedrdlock");
+
+  int err = pthread_rwlock_timedrdlock (r, &ts);
+  if (err == 0)
+    {
+      puts ("rwlock_timedrdlock returned");
+      pthread_exit ((void *) 1l);
+    }
+
+  if (err != ETIMEDOUT)
+    {
+      printf ("err = %s (%d), expected %s (%d)\n",
+	      strerror (err), err, strerror (ETIMEDOUT), ETIMEDOUT);
+      pthread_exit ((void *) 1l);
+    }
+
+  puts ("1st child timedrdlock done");
+
+  struct timeval tv2;
+  (void) gettimeofday (&tv2, NULL);
+
+  timersub (&tv2, &tv, &tv);
+
+  if (tv.tv_usec < 200000)
+    {
+      puts ("timeout too short");
+      pthread_exit ((void *) 1l);
+    }
+
+  (void) gettimeofday (&tv, NULL);
+  TIMEVAL_TO_TIMESPEC (&tv, &ts);
+  ts.tv_sec += 10;
+  /* Note that the following operation makes ts invalid.  */
+  ts.tv_nsec += 1000000000;
+
+  err = pthread_rwlock_timedrdlock (r, &ts);
+  if (err == 0)
+    {
+      puts ("2nd timedrdlock succeeded");
+      pthread_exit ((void *) 1l);
+    }
+  if (err != EINVAL)
+    {
+      puts ("2nd timedrdlock did not return EINVAL");
+      pthread_exit ((void *) 1l);
+    }
+
+  puts ("2nd child timedrdlock done");
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  size_t cnt;
+  for (cnt = 0; cnt < sizeof (kind) / sizeof (kind[0]); ++cnt)
+    {
+      pthread_rwlock_t r;
+      pthread_rwlockattr_t a;
+
+      if (pthread_rwlockattr_init (&a) != 0)
+	{
+	  printf ("round %Zu: rwlockattr_t failed\n", cnt);
+	  exit (1);
+	}
+
+      if (pthread_rwlockattr_setkind_np (&a, kind[cnt]) != 0)
+	{
+	  printf ("round %Zu: rwlockattr_setkind failed\n", cnt);
+	  exit (1);
+	}
+
+      if (pthread_rwlock_init (&r, &a) != 0)
+	{
+	  printf ("round %Zu: rwlock_init failed\n", cnt);
+	  exit (1);
+	}
+
+      if (pthread_rwlockattr_destroy (&a) != 0)
+	{
+	  printf ("round %Zu: rwlockattr_destroy failed\n", cnt);
+	  exit (1);
+	}
+
+      struct timeval tv;
+      (void) gettimeofday (&tv, NULL);
+
+      struct timespec ts;
+      TIMEVAL_TO_TIMESPEC (&tv, &ts);
+
+      ++ts.tv_sec;
+
+      /* Get a write lock.  */
+      int e = pthread_rwlock_timedwrlock (&r, &ts);
+      if (e != 0)
+	{
+	  printf ("round %Zu: rwlock_timedwrlock failed (%d)\n", cnt, e);
+	  exit (1);
+	}
+
+      puts ("1st timedwrlock done");
+
+      (void) gettimeofday (&tv, NULL);
+      TIMEVAL_TO_TIMESPEC (&tv, &ts);
+      ++ts.tv_sec;
+      e = pthread_rwlock_timedrdlock (&r, &ts);
+      if (e == 0)
+	{
+	  puts ("timedrdlock succeeded");
+	  exit (1);
+	}
+      if (e != EDEADLK)
+	{
+	  puts ("timedrdlock did not return EDEADLK");
+	  exit (1);
+	}
+
+      puts ("1st timedrdlock done");
+
+      (void) gettimeofday (&tv, NULL);
+      TIMEVAL_TO_TIMESPEC (&tv, &ts);
+      ++ts.tv_sec;
+      e = pthread_rwlock_timedwrlock (&r, &ts);
+      if (e == 0)
+	{
+	  puts ("2nd timedwrlock succeeded");
+	  exit (1);
+	}
+      if (e != EDEADLK)
+	{
+	  puts ("2nd timedwrlock did not return EDEADLK");
+	  exit (1);
+	}
+
+      puts ("2nd timedwrlock done");
+
+      pthread_t th;
+      if (pthread_create (&th, NULL, tf, &r) != 0)
+	{
+	  printf ("round %Zu: create failed\n", cnt);
+	  exit (1);
+	}
+
+      puts ("started thread");
+
+      void *status;
+      if (pthread_join (th, &status) != 0)
+	{
+	  printf ("round %Zu: join failed\n", cnt);
+	  exit (1);
+	}
+      if (status != NULL)
+	{
+	  printf ("failure in round %Zu\n", cnt);
+	  exit (1);
+	}
+
+      puts ("joined thread");
+
+      if (pthread_rwlock_destroy (&r) != 0)
+	{
+	  printf ("round %Zu: rwlock_destroy failed\n", cnt);
+	  exit (1);
+	}
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-rwlock7.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-rwlock7.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-rwlock7.c	(revision 2036)
@@ -0,0 +1,179 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/time.h>
+
+
+static int kind[] =
+  {
+    PTHREAD_RWLOCK_PREFER_READER_NP,
+    PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,
+    PTHREAD_RWLOCK_PREFER_WRITER_NP,
+  };
+
+
+static void *
+tf (void *arg)
+{
+  pthread_rwlock_t *r = arg;
+
+  /* Timeout: 0.3 secs.  */
+  struct timeval tv;
+  (void) gettimeofday (&tv, NULL);
+
+  struct timespec ts;
+  TIMEVAL_TO_TIMESPEC (&tv, &ts);
+  ts.tv_nsec += 300000000;
+  if (ts.tv_nsec >= 1000000000)
+    {
+      ts.tv_nsec -= 1000000000;
+      ++ts.tv_sec;
+    }
+
+  int err = pthread_rwlock_timedwrlock (r, &ts);
+  if (err == 0)
+    {
+      puts ("rwlock_timedwrlock returned");
+      pthread_exit ((void *) 1l);
+    }
+
+  if (err != ETIMEDOUT)
+    {
+      printf ("err = %s (%d), expected %s (%d)\n",
+	      strerror (err), err, strerror (ETIMEDOUT), ETIMEDOUT);
+      pthread_exit ((void *) 1l);
+    }
+
+  struct timeval tv2;
+  (void) gettimeofday (&tv2, NULL);
+
+  timersub (&tv2, &tv, &tv);
+
+  if (tv.tv_usec < 200000)
+    {
+      puts ("timeout too short");
+      pthread_exit ((void *) 1l);
+    }
+
+  (void) gettimeofday (&tv, NULL);
+  TIMEVAL_TO_TIMESPEC (&tv, &ts);
+  ts.tv_sec += 10;
+  /* Note that the following operation makes ts invalid.  */
+  ts.tv_nsec += 1000000000;
+
+  err = pthread_rwlock_timedwrlock (r, &ts);
+  if (err == 0)
+    {
+      puts ("2nd timedwrlock succeeded");
+      pthread_exit ((void *) 1l);
+    }
+  if (err != EINVAL)
+    {
+      puts ("2nd timedwrlock did not return EINVAL");
+      pthread_exit ((void *) 1l);
+    }
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  size_t cnt;
+  for (cnt = 0; cnt < sizeof (kind) / sizeof (kind[0]); ++cnt)
+    {
+      pthread_rwlock_t r;
+      pthread_rwlockattr_t a;
+
+      if (pthread_rwlockattr_init (&a) != 0)
+	{
+	  printf ("round %Zu: rwlockattr_t failed\n", cnt);
+	  exit (1);
+	}
+
+      if (pthread_rwlockattr_setkind_np (&a, kind[cnt]) != 0)
+	{
+	  printf ("round %Zu: rwlockattr_setkind failed\n", cnt);
+	  exit (1);
+	}
+
+      if (pthread_rwlock_init (&r, &a) != 0)
+	{
+	  printf ("round %Zu: rwlock_init failed\n", cnt);
+	  exit (1);
+	}
+
+      if (pthread_rwlockattr_destroy (&a) != 0)
+	{
+	  printf ("round %Zu: rwlockattr_destroy failed\n", cnt);
+	  exit (1);
+	}
+
+      struct timeval tv;
+      (void) gettimeofday (&tv, NULL);
+
+      struct timespec ts;
+      TIMEVAL_TO_TIMESPEC (&tv, &ts);
+
+      ++ts.tv_sec;
+
+      /* Get a read lock.  */
+      if (pthread_rwlock_timedrdlock (&r, &ts) != 0)
+	{
+	  printf ("round %Zu: rwlock_timedrdlock failed\n", cnt);
+	  exit (1);
+	}
+
+      pthread_t th;
+      if (pthread_create (&th, NULL, tf, &r) != 0)
+	{
+	  printf ("round %Zu: create failed\n", cnt);
+	  exit (1);
+	}
+
+      void *status;
+      if (pthread_join (th, &status) != 0)
+	{
+	  printf ("round %Zu: join failed\n", cnt);
+	  exit (1);
+	}
+      if (status != NULL)
+	{
+	  printf ("failure in round %Zu\n", cnt);
+	  exit (1);
+	}
+
+      if (pthread_rwlock_destroy (&r) != 0)
+	{
+	  printf ("round %Zu: rwlock_destroy failed\n", cnt);
+	  exit (1);
+	}
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-rwlock8.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-rwlock8.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-rwlock8.c	(revision 2036)
@@ -0,0 +1,164 @@
+/* Test program for timedout read/write lock functions.
+   Copyright (C) 2000, 2003 Free Software Foundation, Inc.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <errno.h>
+#include <error.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+
+
+#define NWRITERS 15
+#define WRITETRIES 10
+#define NREADERS 15
+#define READTRIES 15
+
+#define DELAY   1000000
+
+#ifndef INIT
+# define INIT PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP
+#endif
+
+static pthread_rwlock_t lock = INIT;
+
+
+static void *
+writer_thread (void *nr)
+{
+  struct timespec delay;
+  int n;
+
+  delay.tv_sec = 0;
+  delay.tv_nsec = DELAY;
+
+  for (n = 0; n < WRITETRIES; ++n)
+    {
+      printf ("writer thread %ld tries again\n", (long int) nr);
+
+      if (pthread_rwlock_wrlock (&lock) != 0)
+	{
+	  puts ("wrlock failed");
+	  exit (1);
+	}
+
+      printf ("writer thread %ld succeeded\n", (long int) nr);
+
+      nanosleep (&delay, NULL);
+
+      if (pthread_rwlock_unlock (&lock) != 0)
+	{
+	  puts ("unlock for writer failed");
+	  exit (1);
+	}
+
+      printf ("writer thread %ld released\n", (long int) nr);
+    }
+
+  return NULL;
+}
+
+
+static void *
+reader_thread (void *nr)
+{
+  struct timespec delay;
+  int n;
+
+  delay.tv_sec = 0;
+  delay.tv_nsec = DELAY;
+
+  for (n = 0; n < READTRIES; ++n)
+    {
+      printf ("reader thread %ld tries again\n", (long int) nr);
+
+      if (pthread_rwlock_rdlock (&lock) != 0)
+	{
+	  puts ("rdlock failed");
+	  exit (1);
+	}
+
+      printf ("reader thread %ld succeeded\n", (long int) nr);
+
+      nanosleep (&delay, NULL);
+
+      if (pthread_rwlock_unlock (&lock) != 0)
+	{
+	  puts ("unlock for reader failed");
+	  exit (1);
+	}
+
+      printf ("reader thread %ld released\n", (long int) nr);
+    }
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t thwr[NWRITERS];
+  pthread_t thrd[NREADERS];
+  int n;
+  void *res;
+
+  /* Make standard error the same as standard output.  */
+  dup2 (1, 2);
+
+  /* Make sure we see all message, even those on stdout.  */
+  setvbuf (stdout, NULL, _IONBF, 0);
+
+  for (n = 0; n < NWRITERS; ++n)
+    if (pthread_create (&thwr[n], NULL, writer_thread,
+			(void *) (long int) n) != 0)
+      {
+	puts ("writer create failed");
+	exit (1);
+      }
+
+  for (n = 0; n < NREADERS; ++n)
+    if (pthread_create (&thrd[n], NULL, reader_thread,
+			(void *) (long int) n) != 0)
+      {
+	puts ("reader create failed");
+	exit (1);
+      }
+
+  /* Wait for all the threads.  */
+  for (n = 0; n < NWRITERS; ++n)
+    if (pthread_join (thwr[n], &res) != 0)
+      {
+	puts ("writer join failed");
+	exit (1);
+      }
+  for (n = 0; n < NREADERS; ++n)
+    if (pthread_join (thrd[n], &res) != 0)
+      {
+	puts ("reader join failed");
+	exit (1);
+      }
+
+  return 0;
+}
+
+#define TIMEOUT 30
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-rwlock9.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-rwlock9.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-rwlock9.c	(revision 2036)
@@ -0,0 +1,203 @@
+/* Test program for timedout read/write lock functions.
+   Copyright (C) 2000, 2003 Free Software Foundation, Inc.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <errno.h>
+#include <error.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+
+#define NWRITERS 15
+#define WRITETRIES 10
+#define NREADERS 15
+#define READTRIES 15
+
+#define TIMEOUT 1000000
+#define DELAY   1000000
+
+#ifndef INIT
+# define INIT PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP
+#endif
+
+static pthread_rwlock_t lock = INIT;
+
+
+static void *
+writer_thread (void *nr)
+{
+  struct timespec ts;
+  struct timespec delay;
+  int n;
+
+  delay.tv_sec = 0;
+  delay.tv_nsec = DELAY;
+
+  for (n = 0; n < WRITETRIES; ++n)
+    {
+      int e;
+      do
+	{
+	  struct timeval tv;
+	  (void) gettimeofday (&tv, NULL);
+	  TIMEVAL_TO_TIMESPEC (&tv, &ts);
+
+	  ts.tv_nsec += 2 * TIMEOUT;
+	  if (ts.tv_nsec >= 1000000000)
+	    {
+	      ts.tv_nsec -= 1000000000;
+	      ++ts.tv_sec;
+	    }
+
+	  printf ("writer thread %ld tries again\n", (long int) nr);
+
+	  e = pthread_rwlock_timedwrlock (&lock, &ts);
+	  if (e != 0 && e != ETIMEDOUT)
+	    {
+	      puts ("timedwrlock failed");
+	      exit (1);
+	    }
+	}
+      while (e == ETIMEDOUT);
+
+      printf ("writer thread %ld succeeded\n", (long int) nr);
+
+      nanosleep (&delay, NULL);
+
+      if (pthread_rwlock_unlock (&lock) != 0)
+	{
+	  puts ("unlock for writer failed");
+	  exit (1);
+	}
+
+      printf ("writer thread %ld released\n", (long int) nr);
+    }
+
+  return NULL;
+}
+
+
+static void *
+reader_thread (void *nr)
+{
+  struct timespec ts;
+  struct timespec delay;
+  int n;
+
+  delay.tv_sec = 0;
+  delay.tv_nsec = DELAY;
+
+  for (n = 0; n < READTRIES; ++n)
+    {
+      int e;
+      do
+	{
+	  struct timeval tv;
+	  (void) gettimeofday (&tv, NULL);
+	  TIMEVAL_TO_TIMESPEC (&tv, &ts);
+
+	  ts.tv_nsec += TIMEOUT;
+	  if (ts.tv_nsec >= 1000000000)
+	    {
+	      ts.tv_nsec -= 1000000000;
+	      ++ts.tv_sec;
+	    }
+
+	  printf ("reader thread %ld tries again\n", (long int) nr);
+
+	  e = pthread_rwlock_timedrdlock (&lock, &ts);
+	  if (e != 0 && e != ETIMEDOUT)
+	    {
+	      puts ("timedrdlock failed");
+	      exit (1);
+	    }
+	}
+      while (e == ETIMEDOUT);
+
+      printf ("reader thread %ld succeeded\n", (long int) nr);
+
+      nanosleep (&delay, NULL);
+
+      if (pthread_rwlock_unlock (&lock) != 0)
+	{
+	  puts ("unlock for reader failed");
+	  exit (1);
+	}
+
+      printf ("reader thread %ld released\n", (long int) nr);
+    }
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_t thwr[NWRITERS];
+  pthread_t thrd[NREADERS];
+  int n;
+  void *res;
+
+  /* Make standard error the same as standard output.  */
+  dup2 (1, 2);
+
+  /* Make sure we see all message, even those on stdout.  */
+  setvbuf (stdout, NULL, _IONBF, 0);
+
+  for (n = 0; n < NWRITERS; ++n)
+    if (pthread_create (&thwr[n], NULL, writer_thread,
+			(void *) (long int) n) != 0)
+      {
+	puts ("writer create failed");
+	exit (1);
+      }
+
+  for (n = 0; n < NREADERS; ++n)
+    if (pthread_create (&thrd[n], NULL, reader_thread,
+			(void *) (long int) n) != 0)
+      {
+	puts ("reader create failed");
+	exit (1);
+      }
+
+  /* Wait for all the threads.  */
+  for (n = 0; n < NWRITERS; ++n)
+    if (pthread_join (thwr[n], &res) != 0)
+      {
+	puts ("writer join failed");
+	exit (1);
+      }
+  for (n = 0; n < NREADERS; ++n)
+    if (pthread_join (thrd[n], &res) != 0)
+      {
+	puts ("reader join failed");
+	exit (1);
+      }
+
+  return 0;
+}
+
+#undef TIMEOUT
+#define TIMEOUT 30
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-sched1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-sched1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-sched1.c	(revision 2036)
@@ -0,0 +1,98 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+
+static int global;
+
+static void *
+tf (void *a)
+{
+  global = 1;
+
+  return 0;
+}
+
+
+int
+do_test (void)
+{
+  pthread_t th;
+  pthread_attr_t at;
+
+  if (pthread_attr_init (&at) != 0)
+    {
+      puts ("attr_init failed");
+      return 1;
+    }
+
+  if (pthread_attr_setschedpolicy (&at, SCHED_OTHER) != 0)
+    {
+      puts ("attr_setschedpolicy failed");
+      return 1;
+    }
+
+  struct sched_param pa;
+  if (sched_getparam (getpid (), &pa) != 0)
+    {
+      puts ("sched_getschedparam failed");
+      return 1;
+    }
+
+  if (pthread_attr_setschedparam (&at, &pa) != 0)
+    {
+      puts ("attr_setschedparam failed");
+      return 1;
+    }
+
+  if (pthread_attr_setinheritsched (&at, PTHREAD_EXPLICIT_SCHED) != 0)
+    {
+      puts ("attr_setinheritsched failed");
+      return 1;
+    }
+
+  if (pthread_create (&th, &at, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      return 1;
+    }
+
+  int e = pthread_join (th, NULL);
+  if (e != 0)
+    {
+      printf ("join failed: %d\n", e);
+      return 1;
+    }
+
+  if (global == 0)
+    {
+      puts ("thread didn't run");
+      return 1;
+    }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-sem1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-sem1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-sem1.c	(revision 2036)
@@ -0,0 +1,89 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+static int
+do_test (void)
+{
+  sem_t s;
+
+  if (sem_init (&s, 0, 1) == -1)
+    {
+      puts ("init failed");
+      return 1;
+    }
+
+  if (TEMP_FAILURE_RETRY (sem_wait (&s)) == -1)
+    {
+      puts ("1st wait failed");
+      return 1;
+    }
+
+  if (sem_post (&s) == -1)
+    {
+      puts ("1st post failed");
+      return 1;
+    }
+
+  if (TEMP_FAILURE_RETRY (sem_trywait (&s)) == -1)
+    {
+      puts ("1st trywait failed");
+      return 1;
+    }
+
+  errno = 0;
+  if (TEMP_FAILURE_RETRY (sem_trywait (&s)) != -1)
+    {
+      puts ("2nd trywait succeeded");
+      return 1;
+    }
+  else if (errno != EAGAIN)
+    {
+      puts ("2nd trywait did not set errno to EAGAIN");
+      return 1;
+    }
+
+  if (sem_post (&s) == -1)
+    {
+      puts ("2nd post failed");
+      return 1;
+    }
+
+  if (TEMP_FAILURE_RETRY (sem_wait (&s)) == -1)
+    {
+      puts ("2nd wait failed");
+      return 1;
+    }
+
+  if (sem_destroy (&s) == -1)
+    {
+      puts ("destroy failed");
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-sem2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-sem2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-sem2.c	(revision 2036)
@@ -0,0 +1,54 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <semaphore.h>
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+static int
+do_test (void)
+{
+  sem_t s;
+
+  if (sem_init (&s, 0, 0) == -1)
+    {
+      puts ("init failed");
+      return 1;
+    }
+
+  /* Set an alarm for 1 second.  The wrapper will expect this.  */
+  alarm (1);
+
+  if (TEMP_FAILURE_RETRY (sem_wait (&s)) == -1)
+    {
+      puts ("wait failed");
+      return 1;
+    }
+
+  /* We should never get here.  */
+  puts ("wait succeeded");
+  return 1;
+}
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-sem3.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-sem3.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-sem3.c	(revision 2036)
@@ -0,0 +1,142 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <semaphore.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+
+int
+main (void)
+{
+  size_t ps = sysconf (_SC_PAGESIZE);
+  char tmpfname[] = "/tmp/tst-sem3.XXXXXX";
+  char data[ps];
+  void *mem;
+  int fd;
+  sem_t *s;
+  pid_t pid;
+  char *p;
+
+  fd = mkstemp (tmpfname);
+  if (fd == -1)
+    {
+      printf ("cannot open temporary file: %m\n");
+      exit (1);
+    }
+
+  /* Make sure it is always removed.  */
+  unlink (tmpfname);
+
+  /* Create one page of data.  */
+  memset (data, '\0', ps);
+
+  /* Write the data to the file.  */
+  if (write (fd, data, ps) != (ssize_t) ps)
+    {
+      puts ("short write");
+      exit (1);
+    }
+
+  mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+  if (mem == MAP_FAILED)
+    {
+      printf ("mmap failed: %m\n");
+      exit (1);
+    }
+
+  s = (sem_t *) (((uintptr_t) mem + __alignof (sem_t))
+		 & ~(__alignof (sem_t) - 1));
+  p = (char *) (s + 1);
+
+  if (sem_init (s, 1, 1) == -1)
+    {
+      puts ("init failed");
+      exit (1);
+    }
+
+  if (TEMP_FAILURE_RETRY (sem_wait (s)) == -1)
+    {
+      puts ("1st wait failed");
+      exit (1);
+    }
+
+  errno = 0;
+  if (TEMP_FAILURE_RETRY (sem_trywait (s)) != -1)
+    {
+      puts ("trywait succeeded");
+      exit (1);
+    }
+  else if (errno != EAGAIN)
+    {
+      puts ("trywait didn't return EAGAIN");
+      exit (1);
+    }
+
+  *p = 0;
+
+  puts ("going to fork now");
+  pid = fork ();
+  if (pid == -1)
+    {
+      puts ("fork failed");
+      exit (1);
+    }
+  else if (pid == 0)
+    {
+      /* Play some lock ping-pong.  It's our turn to unlock first.  */
+      if ((*p)++ != 0)
+	{
+	  puts ("child: *p != 0");
+	  exit (1);
+	}
+
+      if (sem_post (s) == -1)
+	{
+	  puts ("child: 1st post failed");
+	  exit (1);
+	}
+
+      puts ("child done");
+    }
+  else
+    {
+      if (TEMP_FAILURE_RETRY (sem_wait (s)) == -1)
+	{
+	  printf ("parent: 2nd wait failed: %m\n");
+	  exit (1);
+	}
+
+      if (*p != 1)
+	{
+	  puts ("*p != 1");
+	  exit (1);
+	}
+
+      puts ("parent done");
+    }
+
+  exit (0);
+}
Index: trunk/src/libctests/glibc/nptl/tst-sem4.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-sem4.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-sem4.c	(revision 2036)
@@ -0,0 +1,147 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static void
+remove_sem (int status, void *arg)
+{
+  sem_unlink (arg);
+}
+
+
+int
+main (void)
+{
+  sem_t *s;
+  sem_t *s2;
+  pid_t pid;
+  int val;
+
+  s = sem_open ("/glibc-tst-sem4", O_CREAT, 0600, 1);
+  if (s == SEM_FAILED)
+    {
+      if (errno == ENOSYS)
+	{
+	  puts ("sem_open not supported.  Oh well.");
+	  return 0;
+	}
+
+      /* Maybe the shm filesystem has strict permissions.  */
+      if (errno == EACCES)
+	{
+	  puts ("sem_open not allowed.  Oh well.");
+	  return 0;
+	}
+
+      printf ("sem_open: %m\n");
+      return 1;
+    }
+
+  on_exit (remove_sem, (void *) "/glibc-tst-sem4");
+
+  /* We have the semaphore object.  Now try again with O_EXCL, this
+     should fail.  */
+  s2 = sem_open ("/glibc-tst-sem4", O_CREAT | O_EXCL, 0600, 1);
+  if (s2 != SEM_FAILED)
+    {
+      puts ("2nd sem_open didn't fail");
+      return 1;
+    }
+  if (errno != EEXIST)
+    {
+      puts ("2nd sem_open returned wrong error");
+      return 1;
+    }
+
+  /* Check the value.  */
+  if (sem_getvalue (s, &val) == -1)
+    {
+      puts ("getvalue failed");
+      return 1;
+    }
+  if (val != 1)
+    {
+      printf ("initial value wrong: got %d, expected 1\n", val);
+      return 1;
+    }
+
+  if (TEMP_FAILURE_RETRY (sem_wait (s)) == -1)
+    {
+      puts ("1st sem_wait failed");
+      return 1;
+    }
+
+  pid = fork ();
+  if (pid == -1)
+    {
+      printf ("fork failed: %m\n");
+      return 1;
+    }
+
+  if (pid == 0)
+    {
+      /* Child.  */
+
+      /* Check the value.  */
+      if (sem_getvalue (s, &val) == -1)
+	{
+	  puts ("child: getvalue failed");
+	  return 1;
+	}
+      if (val != 0)
+	{
+	  printf ("child: value wrong: got %d, expect 0\n", val);
+	  return 1;
+	}
+
+      if (sem_post (s) == -1)
+	{
+	  puts ("child: post failed");
+	  return 1;
+	}
+    }
+  else
+    {
+      if (TEMP_FAILURE_RETRY (sem_wait (s)) == -1)
+	{
+	  puts ("2nd sem_wait failed");
+	  return 1;
+	}
+
+      if (sem_getvalue (s, &val) == -1)
+	{
+	  puts ("parent: 2nd getvalue failed");
+	  return 1;
+	}
+      if (val != 0)
+	{
+	  printf ("parent: value wrong: got %d, expected 0\n", val);
+	  return 1;
+	}
+    }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/nptl/tst-sem5.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-sem5.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-sem5.c	(revision 2036)
@@ -0,0 +1,80 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+
+static int
+do_test (void)
+{
+  sem_t s;
+  struct timespec ts;
+  struct timeval tv;
+
+  if (sem_init (&s, 0, 1) == -1)
+    {
+      puts ("sem_init failed");
+      return 1;
+    }
+
+  if (TEMP_FAILURE_RETRY (sem_wait (&s)) == -1)
+    {
+      puts ("sem_wait failed");
+      return 1;
+    }
+
+  if (gettimeofday (&tv, NULL) != 0)
+    {
+      puts ("gettimeofday failed");
+      return 1;
+    }
+
+  TIMEVAL_TO_TIMESPEC (&tv, &ts);
+
+  /* We wait for half a second.  */
+  ts.tv_nsec += 500000000;
+  if (ts.tv_nsec >= 1000000000)
+    {
+      ++ts.tv_sec;
+      ts.tv_nsec -= 1000000000;
+    }
+
+  errno = 0;
+  if (TEMP_FAILURE_RETRY (sem_timedwait (&s, &ts)) != -1)
+    {
+      puts ("sem_timedwait succeeded");
+      return 1;
+    }
+  if (errno != ETIMEDOUT)
+    {
+      printf ("sem_timedwait return errno = %d instead of ETIMEDOUT\n",
+	      errno);
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-sem6.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-sem6.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-sem6.c	(revision 2036)
@@ -0,0 +1,81 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <semaphore.h>
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+static void
+handler (int sig)
+{
+  struct sigaction sa;
+
+  sa.sa_handler = SIG_DFL;
+  sa.sa_flags = 0;
+  sigemptyset (&sa.sa_mask);
+
+  sigaction (SIGALRM, &sa, NULL);
+
+  /* Rearm the timer.  */
+  alarm (1);
+}
+
+
+static int
+do_test (void)
+{
+  sem_t s;
+  struct sigaction sa;
+
+  sa.sa_handler = handler;
+  sa.sa_flags = 0;
+  sigemptyset (&sa.sa_mask);
+
+  sigaction (SIGALRM, &sa, NULL);
+
+  if (sem_init (&s, 0, 0) == -1)
+    {
+      puts ("init failed");
+      return 1;
+    }
+
+  /* Set an alarm for 1 second.  The wrapper will expect this.  */
+  alarm (1);
+
+  int res = sem_wait (&s);
+  if (res == 0)
+    {
+      puts ("wait succeeded");
+      return 1;
+    }
+  if (res != -1 || errno != EINTR)
+    {
+      puts ("wait didn't fail with EINTR");
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TIMEOUT 3
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-sem7.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-sem7.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-sem7.c	(revision 2036)
@@ -0,0 +1,109 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static void
+remove_sem (int status, void *arg)
+{
+  sem_unlink (arg);
+}
+
+
+int
+main (void)
+{
+  sem_t *s;
+  sem_t *s2;
+  sem_t *s3;
+
+  s = sem_open ("/glibc-tst-sem7", O_CREAT, 0600, 1);
+  if (s == SEM_FAILED)
+    {
+      if (errno == ENOSYS)
+	{
+	  puts ("sem_open not supported.  Oh well.");
+	  return 0;
+	}
+
+      /* Maybe the shm filesystem has strict permissions.  */
+      if (errno == EACCES)
+	{
+	  puts ("sem_open not allowed.  Oh well.");
+	  return 0;
+	}
+
+      printf ("sem_open: %m\n");
+      return 1;
+    }
+
+  on_exit (remove_sem, (void *) "/glibc-tst-sem7");
+
+  /* We have the semaphore object.  Now try again.  We should get the
+     same address.  */
+  s2 = sem_open ("/glibc-tst-sem7", O_CREAT, 0600, 1);
+  if (s2 == SEM_FAILED)
+    {
+      puts ("2nd sem_open failed");
+      return 1;
+    }
+  if (s != s2)
+    {
+      puts ("2nd sem_open didn't return the same address");
+      return 1;
+    }
+
+  /* And again, this time without O_CREAT.  */
+  s3 = sem_open ("/glibc-tst-sem7", 0);
+  if (s3 == SEM_FAILED)
+    {
+      puts ("3rd sem_open failed");
+      return 1;
+    }
+  if (s != s3)
+    {
+      puts ("3rd sem_open didn't return the same address");
+      return 1;
+    }
+
+  /* Now close the handle.  Three times.  */
+  if (sem_close (s2) != 0)
+    {
+      puts ("1st sem_close failed");
+      return 1;
+    }
+  if (sem_close (s) != 0)
+    {
+      puts ("2nd sem_close failed");
+      return 1;
+    }
+  if (sem_close (s3) != 0)
+    {
+      puts ("3rd sem_close failed");
+      return 1;
+    }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/nptl/tst-sem8.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-sem8.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-sem8.c	(revision 2036)
@@ -0,0 +1,74 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static void
+remove_sem (int status, void *arg)
+{
+  sem_unlink (arg);
+}
+
+
+int
+main (void)
+{
+  sem_t *s;
+  int i;
+
+  on_exit (remove_sem, (void *) "/glibc-tst-sem8");
+
+  for (i = 0; i < 3; ++i)
+    {
+      s = sem_open ("/glibc-tst-sem8", O_CREAT, 0600, 1);
+      if (s == SEM_FAILED)
+	{
+	  if (errno == ENOSYS)
+	    {
+	      puts ("sem_open not supported.  Oh well.");
+	      return 0;
+	    }
+
+	  /* Maybe the shm filesystem has strict permissions.  */
+	  if (errno == EACCES)
+	    {
+	      puts ("sem_open not allowed.  Oh well.");
+	      return 0;
+	    }
+
+	  printf ("sem_open: %m\n");
+	  return 1;
+	}
+
+      /* Now close the handle.  */
+      if (sem_close (s) != 0)
+	{
+	  puts ("sem_close failed");
+	  return 1;
+	}
+    }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/nptl/tst-sem9.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-sem9.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-sem9.c	(revision 2036)
@@ -0,0 +1,81 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static void
+remove_sem (int status, void *arg)
+{
+  sem_unlink (arg);
+}
+
+
+int
+main (void)
+{
+  sem_t *s;
+  int i;
+
+  on_exit (remove_sem, (void *) "/glibc-tst-sem9");
+
+  for (i = 0; i < 3; ++i)
+    {
+      s = sem_open ("/glibc-tst-sem9", O_CREAT, 0600, 1);
+      if (s == SEM_FAILED)
+	{
+	  if (errno == ENOSYS)
+	    {
+	      puts ("sem_open not supported.  Oh well.");
+	      return 0;
+	    }
+
+	  /* Maybe the shm filesystem has strict permissions.  */
+	  if (errno == EACCES)
+	    {
+	      puts ("sem_open not allowed.  Oh well.");
+	      return 0;
+	    }
+
+	  printf ("sem_open: %m\n");
+	  return 1;
+	}
+
+      /* Now close the handle.  */
+      if (sem_close (s) != 0)
+	{
+	  puts ("sem_close failed");
+	  return 1;
+	}
+
+      /* And remove it.  */
+      if (sem_unlink ("/glibc-tst-sem9") != 0)
+	{
+	  puts ("sem_unlink failed");
+	  return 1;
+	}
+    }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/nptl/tst-setuid1-static.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-setuid1-static.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-setuid1-static.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include "tst-setuid1.c"
Index: trunk/src/libctests/glibc/nptl/tst-setuid1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-setuid1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-setuid1.c	(revision 2036)
@@ -0,0 +1,1085 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jaku@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <pwd.h>
+#include <grp.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+
+static pthread_barrier_t b3, b4;
+static uid_t prev_ruid, prev_euid, prev_suid, nobody_uid;
+static gid_t prev_rgid, prev_egid, prev_sgid, nobody_gid;
+enum ACTION { PREPARE, SET, CHECK_BEFORE, CHECK_AFTER };
+#define TESTNO(arg) ((long int) (arg) & 0xff)
+#define THREADNO(arg) ((long int) (arg) >> 8)
+
+
+static void
+check_prev_uid (int tno)
+{
+  uid_t ruid, euid, suid;
+  if (getresuid (&ruid, &euid, &suid) < 0)
+    {
+      printf ("getresuid failed: %d %m\n", tno);
+      exit (1);
+    }
+
+  if (ruid != prev_ruid || euid != prev_euid || suid != prev_suid)
+    {
+      printf ("uids before in %d (%d %d %d) != (%d %d %d)\n", tno,
+	      ruid, euid, suid, prev_ruid, prev_euid, prev_suid);
+      exit (1);
+    }
+}
+
+
+static void
+check_prev_gid (int tno)
+{
+  gid_t rgid, egid, sgid;
+  if (getresgid (&rgid, &egid, &sgid) < 0)
+    {
+      printf ("getresgid failed: %d %m\n", tno);
+      exit (1);
+    }
+
+  if (rgid != prev_rgid || egid != prev_egid || sgid != prev_sgid)
+    {
+      printf ("gids before in %d (%d %d %d) != (%d %d %d)\n", tno,
+	      rgid, egid, sgid, prev_rgid, prev_egid, prev_sgid);
+      exit (1);
+    }
+}
+
+
+static void
+test_setuid1 (enum ACTION action, int tno)
+{
+  if (action == PREPARE)
+    return;
+
+  if (action != CHECK_AFTER)
+    check_prev_uid (tno);
+
+  if (action == SET && setuid (nobody_uid) < 0)
+    {
+       printf ("setuid failed: %m\n");
+       exit (1);
+    }
+
+  if (action != CHECK_BEFORE)
+    {
+      uid_t ruid, euid, suid;
+      if (getresuid (&ruid, &euid, &suid) < 0)
+	{
+	  printf ("getresuid failed: %d %m\n", tno);
+	  exit (1);
+	}
+
+      if (ruid != nobody_uid || euid != nobody_uid || suid != nobody_uid)
+	{
+	  printf ("after setuid %d (%d %d %d) != (%d %d %d)\n", tno,
+		  ruid, euid, suid, nobody_uid, nobody_uid, nobody_uid);
+	  exit (1);
+	}
+    }
+}
+
+
+static void
+test_setuid2 (enum ACTION action, int tno)
+{
+  if (action == PREPARE)
+    {
+      if (setresuid (nobody_uid, nobody_uid, -1) < 0)
+	{
+	  printf ("setresuid failed: %m\n");
+	  exit (1);
+	}
+
+      prev_ruid = nobody_uid;
+      prev_euid = nobody_uid;
+      return;
+    }
+
+  if (action != CHECK_AFTER)
+    check_prev_uid (tno);
+
+  if (action == SET && setuid (prev_suid) < 0)
+    {
+      printf ("setuid failed: %m\n");
+      exit (1);
+    }
+
+  if (action != CHECK_BEFORE)
+    {
+      uid_t ruid, euid, suid;
+      if (getresuid (&ruid, &euid, &suid) < 0)
+	{
+	  printf ("getresuid failed: %d %m\n", tno);
+	  exit (1);
+	}
+
+      if (ruid != nobody_uid || euid != prev_suid || suid != prev_suid)
+	{
+	  printf ("after setuid %d (%d %d %d) != (%d %d %d)\n", tno,
+		  ruid, euid, suid, nobody_uid, prev_suid, prev_suid);
+	  exit (1);
+	}
+    }
+}
+
+
+static void
+test_seteuid1 (enum ACTION action, int tno)
+{
+  if (action == PREPARE)
+    return;
+
+  if (action != CHECK_AFTER)
+    check_prev_uid (tno);
+
+  if (action == SET && seteuid (nobody_uid) < 0)
+    {
+       printf ("seteuid failed: %m\n");
+       exit (1);
+    }
+
+  if (action != CHECK_BEFORE)
+    {
+      uid_t ruid, euid, suid;
+      if (getresuid (&ruid, &euid, &suid) < 0)
+	{
+	  printf ("getresuid failed: %d %m\n", tno);
+	  exit (1);
+	}
+
+      if (ruid != prev_ruid || euid != nobody_uid || suid != prev_suid)
+	{
+	  printf ("after seteuid %d (%d %d %d) != (%d %d %d)\n", tno,
+		  ruid, euid, suid, prev_ruid, nobody_uid, prev_suid);
+	  exit (1);
+	}
+    }
+}
+
+
+static void
+test_seteuid2 (enum ACTION action, int tno)
+{
+  if (action == PREPARE)
+    {
+      if (setresuid (nobody_uid, nobody_uid, -1) < 0)
+	{
+	  printf ("setresuid failed: %m\n");
+	  exit (1);
+	}
+
+      prev_ruid = nobody_uid;
+      prev_euid = nobody_uid;
+      nobody_uid = prev_suid;
+      return;
+    }
+
+  test_seteuid1 (action, tno);
+}
+
+
+static void
+test_setreuid1 (enum ACTION action, int tno)
+{
+  if (action == PREPARE)
+    return;
+
+  if (action != CHECK_AFTER)
+    check_prev_uid (tno);
+
+  if (action == SET && setreuid (-1, nobody_uid) < 0)
+    {
+       printf ("setreuid failed: %m\n");
+       exit (1);
+    }
+
+  if (action != CHECK_BEFORE)
+    {
+      uid_t ruid, euid, suid, esuid;
+      if (getresuid (&ruid, &euid, &suid) < 0)
+	{
+	  printf ("getresuid failed: %d %m\n", tno);
+	  exit (1);
+	}
+
+      if (prev_ruid != nobody_uid)
+	esuid = nobody_uid;
+      else
+	esuid = prev_suid;
+
+      if (ruid != prev_ruid || euid != nobody_uid || suid != esuid)
+	{
+	  printf ("after setreuid %d (%d %d %d) != (%d %d %d)\n", tno,
+		  ruid, euid, suid, prev_ruid, nobody_uid, esuid);
+	  exit (1);
+	}
+    }
+}
+
+
+static void
+test_setreuid2 (enum ACTION action, int tno)
+{
+  if (action == PREPARE)
+    return;
+
+  if (action != CHECK_AFTER)
+    check_prev_uid (tno);
+
+  if (action == SET && setreuid (nobody_uid, -1) < 0)
+    {
+       printf ("setreuid failed: %m\n");
+       exit (1);
+    }
+
+  if (action != CHECK_BEFORE)
+    {
+      uid_t ruid, euid, suid;
+      if (getresuid (&ruid, &euid, &suid) < 0)
+	{
+	  printf ("getresuid failed: %d %m\n", tno);
+	  exit (1);
+	}
+
+      if (ruid != nobody_uid || euid != prev_euid || suid != prev_euid)
+	{
+	  printf ("after setreuid %d (%d %d %d) != (%d %d %d)\n", tno,
+		  ruid, euid, suid, nobody_uid, prev_euid, prev_euid);
+	  exit (1);
+	}
+    }
+}
+
+
+static void
+test_setreuid3 (enum ACTION action, int tno)
+{
+  if (action == PREPARE)
+    return;
+
+  if (action != CHECK_AFTER)
+    check_prev_uid (tno);
+
+  if (action == SET && setreuid (nobody_uid, nobody_uid) < 0)
+    {
+       printf ("setreuid failed: %m\n");
+       exit (1);
+    }
+
+  if (action != CHECK_BEFORE)
+    {
+      uid_t ruid, euid, suid;
+      if (getresuid (&ruid, &euid, &suid) < 0)
+	{
+	  printf ("getresuid failed: %d %m\n", tno);
+	  exit (1);
+	}
+
+      if (ruid != nobody_uid || euid != nobody_uid || suid != nobody_uid)
+	{
+	  printf ("after setreuid %d (%d %d %d) != (%d %d %d)\n", tno,
+		  ruid, euid, suid, nobody_uid, nobody_uid, nobody_uid);
+	  exit (1);
+	}
+    }
+}
+
+
+static void
+test_setreuid4 (enum ACTION action, int tno)
+{
+  if (action == PREPARE)
+    {
+      if (setresuid (nobody_uid, nobody_uid, -1) < 0)
+	{
+	  printf ("setresuid failed: %m\n");
+	  exit (1);
+	}
+
+      prev_ruid = nobody_uid;
+      prev_euid = nobody_uid;
+      nobody_uid = prev_suid;
+      return;
+    }
+
+  test_setreuid1 (action, tno);
+}
+
+
+static void
+test_setresuid1 (enum ACTION action, int tno)
+{
+  if (action == PREPARE)
+    return;
+
+  if (action != CHECK_AFTER)
+    check_prev_uid (tno);
+
+  if (action == SET && setresuid (-1, nobody_uid, -1) < 0)
+    {
+       printf ("setresuid failed: %m\n");
+       exit (1);
+    }
+
+  if (action != CHECK_BEFORE)
+    {
+      uid_t ruid, euid, suid;
+      if (getresuid (&ruid, &euid, &suid) < 0)
+	{
+	  printf ("getresuid failed: %d %m\n", tno);
+	  exit (1);
+	}
+
+      if (ruid != prev_ruid || euid != nobody_uid || suid != prev_suid)
+	{
+	  printf ("after setresuid %d (%d %d %d) != (%d %d %d)\n", tno,
+		  ruid, euid, suid, prev_ruid, nobody_uid, prev_suid);
+	  exit (1);
+	}
+    }
+}
+
+
+static void
+test_setresuid2 (enum ACTION action, int tno)
+{
+  if (action == PREPARE)
+    return;
+
+  if (action != CHECK_AFTER)
+    check_prev_uid (tno);
+
+  if (action == SET && setresuid (prev_euid, nobody_uid, nobody_uid) < 0)
+    {
+       printf ("setresuid failed: %m\n");
+       exit (1);
+    }
+
+  if (action != CHECK_BEFORE)
+    {
+      uid_t ruid, euid, suid;
+      if (getresuid (&ruid, &euid, &suid) < 0)
+	{
+	  printf ("getresuid failed: %d %m\n", tno);
+	  exit (1);
+	}
+
+      if (ruid != prev_euid || euid != nobody_uid || suid != nobody_uid)
+	{
+	  printf ("after setresuid %d (%d %d %d) != (%d %d %d)\n", tno,
+		  ruid, euid, suid, prev_euid, nobody_uid, nobody_uid);
+	  exit (1);
+	}
+    }
+}
+
+
+static void
+test_setresuid3 (enum ACTION action, int tno)
+{
+  if (action == PREPARE)
+    return;
+
+  if (action != CHECK_AFTER)
+    check_prev_uid (tno);
+
+  if (action == SET && setresuid (nobody_uid, nobody_uid, nobody_uid) < 0)
+    {
+       printf ("setresuid failed: %m\n");
+       exit (1);
+    }
+
+  if (action != CHECK_BEFORE)
+    {
+      uid_t ruid, euid, suid;
+      if (getresuid (&ruid, &euid, &suid) < 0)
+	{
+	  printf ("getresuid failed: %d %m\n", tno);
+	  exit (1);
+	}
+
+      if (ruid != nobody_uid || euid != nobody_uid || suid != nobody_uid)
+	{
+	  printf ("after setresuid %d (%d %d %d) != (%d %d %d)\n", tno,
+		  ruid, euid, suid, nobody_uid, nobody_uid, nobody_uid);
+	  exit (1);
+	}
+    }
+}
+
+
+static void
+test_setresuid4 (enum ACTION action, int tno)
+{
+  if (action == PREPARE)
+    {
+      if (setresuid (nobody_uid, nobody_uid, -1) < 0)
+	{
+	  printf ("setresuid failed: %m\n");
+	  exit (1);
+	}
+
+      prev_ruid = nobody_uid;
+      prev_euid = nobody_uid;
+      nobody_uid = prev_suid;
+      return;
+    }
+
+  test_setresuid1 (action, tno);
+}
+
+
+static void
+test_setgid1 (enum ACTION action, int tno)
+{
+  if (action == PREPARE)
+    return;
+
+  if (action != CHECK_AFTER)
+    check_prev_gid (tno);
+
+  if (action == SET && setgid (nobody_gid) < 0)
+    {
+       printf ("setgid failed: %m\n");
+       exit (1);
+    }
+
+  if (action != CHECK_BEFORE)
+    {
+      gid_t rgid, egid, sgid;
+      if (getresgid (&rgid, &egid, &sgid) < 0)
+	{
+	  printf ("getresgid failed: %d %m\n", tno);
+	  exit (1);
+	}
+
+      if (rgid != nobody_gid || egid != nobody_gid || sgid != nobody_gid)
+	{
+	  printf ("after setgid %d (%d %d %d) != (%d %d %d)\n", tno,
+		  rgid, egid, sgid, nobody_gid, nobody_gid, nobody_gid);
+	  exit (1);
+	}
+    }
+}
+
+
+static void
+test_setgid2 (enum ACTION action, int tno)
+{
+  if (action == PREPARE)
+    {
+      if (setresgid (nobody_gid, nobody_gid, -1) < 0)
+	{
+	  printf ("setresgid failed: %m\n");
+	  exit (1);
+	}
+
+      prev_rgid = nobody_gid;
+      prev_egid = nobody_gid;
+
+      if (setresuid (nobody_uid, nobody_uid, -1) < 0)
+	{
+	  printf ("setresuid failed: %m\n");
+	  exit (1);
+	}
+
+      prev_ruid = nobody_uid;
+      prev_euid = nobody_uid;
+      return;
+    }
+
+  if (action != CHECK_AFTER)
+    check_prev_gid (tno);
+
+  if (action == SET && setgid (prev_sgid) < 0)
+    {
+      printf ("setgid failed: %m\n");
+      exit (1);
+    }
+
+  if (action != CHECK_BEFORE)
+    {
+      gid_t rgid, egid, sgid;
+      if (getresgid (&rgid, &egid, &sgid) < 0)
+	{
+	  printf ("getresgid failed: %d %m\n", tno);
+	  exit (1);
+	}
+
+      if (rgid != nobody_gid || egid != prev_sgid || sgid != prev_sgid)
+	{
+	  printf ("after setgid %d (%d %d %d) != (%d %d %d)\n", tno,
+		  rgid, egid, sgid, nobody_gid, prev_sgid, prev_sgid);
+	  exit (1);
+	}
+    }
+}
+
+
+static void
+test_setegid1 (enum ACTION action, int tno)
+{
+  if (action == PREPARE)
+    return;
+
+  if (action != CHECK_AFTER)
+    check_prev_gid (tno);
+
+  if (action == SET && setegid (nobody_gid) < 0)
+    {
+       printf ("setegid failed: %m\n");
+       exit (1);
+    }
+
+  if (action != CHECK_BEFORE)
+    {
+      gid_t rgid, egid, sgid;
+      if (getresgid (&rgid, &egid, &sgid) < 0)
+	{
+	  printf ("getresgid failed: %d %m\n", tno);
+	  exit (1);
+	}
+
+      if (rgid != prev_rgid || egid != nobody_gid || sgid != prev_sgid)
+	{
+	  printf ("after setegid %d (%d %d %d) != (%d %d %d)\n", tno,
+		  rgid, egid, sgid, prev_rgid, nobody_gid, prev_sgid);
+	  exit (1);
+	}
+    }
+}
+
+
+static void
+test_setegid2 (enum ACTION action, int tno)
+{
+  if (action == PREPARE)
+    {
+      if (setresgid (nobody_gid, nobody_gid, -1) < 0)
+	{
+	  printf ("setresgid failed: %m\n");
+	  exit (1);
+	}
+
+      prev_rgid = nobody_gid;
+      prev_egid = nobody_gid;
+      nobody_gid = prev_sgid;
+      return;
+    }
+
+  test_setegid1 (action, tno);
+}
+
+
+static void
+test_setregid1 (enum ACTION action, int tno)
+{
+  if (action == PREPARE)
+    return;
+
+  if (action != CHECK_AFTER)
+    check_prev_gid (tno);
+
+  if (action == SET && setregid (-1, nobody_gid) < 0)
+    {
+       printf ("setregid failed: %m\n");
+       exit (1);
+    }
+
+  if (action != CHECK_BEFORE)
+    {
+      gid_t rgid, egid, sgid, esgid;
+      if (getresgid (&rgid, &egid, &sgid) < 0)
+	{
+	  printf ("getresgid failed: %d %m\n", tno);
+	  exit (1);
+	}
+
+      if (prev_rgid != nobody_gid)
+	esgid = nobody_gid;
+      else
+	esgid = prev_sgid;
+
+      if (rgid != prev_rgid || egid != nobody_gid || sgid != esgid)
+	{
+	  printf ("after setregid %d (%d %d %d) != (%d %d %d)\n", tno,
+		  rgid, egid, sgid, prev_rgid, nobody_gid, esgid);
+	  exit (1);
+	}
+    }
+}
+
+
+static void
+test_setregid2 (enum ACTION action, int tno)
+{
+  if (action == PREPARE)
+    return;
+
+  if (action != CHECK_AFTER)
+    check_prev_gid (tno);
+
+  if (action == SET && setregid (nobody_gid, -1) < 0)
+    {
+       printf ("setregid failed: %m\n");
+       exit (1);
+    }
+
+  if (action != CHECK_BEFORE)
+    {
+      gid_t rgid, egid, sgid;
+      if (getresgid (&rgid, &egid, &sgid) < 0)
+	{
+	  printf ("getresgid failed: %d %m\n", tno);
+	  exit (1);
+	}
+
+      if (rgid != nobody_gid || egid != prev_egid || sgid != prev_egid)
+	{
+	  printf ("after setregid %d (%d %d %d) != (%d %d %d)\n", tno,
+		  rgid, egid, sgid, nobody_gid, prev_egid, prev_egid);
+	  exit (1);
+	}
+    }
+}
+
+
+static void
+test_setregid3 (enum ACTION action, int tno)
+{
+  if (action == PREPARE)
+    return;
+
+  if (action != CHECK_AFTER)
+    check_prev_gid (tno);
+
+  if (action == SET && setregid (nobody_gid, nobody_gid) < 0)
+    {
+       printf ("setregid failed: %m\n");
+       exit (1);
+    }
+
+  if (action != CHECK_BEFORE)
+    {
+      gid_t rgid, egid, sgid;
+      if (getresgid (&rgid, &egid, &sgid) < 0)
+	{
+	  printf ("getresgid failed: %d %m\n", tno);
+	  exit (1);
+	}
+
+      if (rgid != nobody_gid || egid != nobody_gid || sgid != nobody_gid)
+	{
+	  printf ("after setregid %d (%d %d %d) != (%d %d %d)\n", tno,
+		  rgid, egid, sgid, nobody_gid, nobody_gid, nobody_gid);
+	  exit (1);
+	}
+    }
+}
+
+
+static void
+test_setregid4 (enum ACTION action, int tno)
+{
+  if (action == PREPARE)
+    {
+      if (setresgid (nobody_gid, nobody_gid, -1) < 0)
+	{
+	  printf ("setresgid failed: %m\n");
+	  exit (1);
+	}
+
+      prev_rgid = nobody_gid;
+      prev_egid = nobody_gid;
+      nobody_gid = prev_sgid;
+      return;
+    }
+
+  test_setregid1 (action, tno);
+}
+
+
+static void
+test_setresgid1 (enum ACTION action, int tno)
+{
+  if (action == PREPARE)
+    return;
+
+  if (action != CHECK_AFTER)
+    check_prev_gid (tno);
+
+  if (action == SET && setresgid (-1, nobody_gid, -1) < 0)
+    {
+       printf ("setresgid failed: %m\n");
+       exit (1);
+    }
+
+  if (action != CHECK_BEFORE)
+    {
+      gid_t rgid, egid, sgid;
+      if (getresgid (&rgid, &egid, &sgid) < 0)
+	{
+	  printf ("getresgid failed: %d %m\n", tno);
+	  exit (1);
+	}
+
+      if (rgid != prev_rgid || egid != nobody_gid || sgid != prev_sgid)
+	{
+	  printf ("after setresgid %d (%d %d %d) != (%d %d %d)\n", tno,
+		  rgid, egid, sgid, prev_rgid, nobody_gid, prev_sgid);
+	  exit (1);
+	}
+    }
+}
+
+
+static void
+test_setresgid2 (enum ACTION action, int tno)
+{
+  if (action == PREPARE)
+    return;
+
+  if (action != CHECK_AFTER)
+    check_prev_gid (tno);
+
+  if (action == SET && setresgid (prev_egid, nobody_gid, nobody_gid) < 0)
+    {
+       printf ("setresgid failed: %m\n");
+       exit (1);
+    }
+
+  if (action != CHECK_BEFORE)
+    {
+      gid_t rgid, egid, sgid;
+      if (getresgid (&rgid, &egid, &sgid) < 0)
+	{
+	  printf ("getresgid failed: %d %m\n", tno);
+	  exit (1);
+	}
+
+      if (rgid != prev_egid || egid != nobody_gid || sgid != nobody_gid)
+	{
+	  printf ("after setresgid %d (%d %d %d) != (%d %d %d)\n", tno,
+		  rgid, egid, sgid, prev_egid, nobody_gid, nobody_gid);
+	  exit (1);
+	}
+    }
+}
+
+
+static void
+test_setresgid3 (enum ACTION action, int tno)
+{
+  if (action == PREPARE)
+    return;
+
+  if (action != CHECK_AFTER)
+    check_prev_gid (tno);
+
+  if (action == SET && setresgid (nobody_gid, nobody_gid, nobody_gid) < 0)
+    {
+       printf ("setresgid failed: %m\n");
+       exit (1);
+    }
+
+  if (action != CHECK_BEFORE)
+    {
+      gid_t rgid, egid, sgid;
+      if (getresgid (&rgid, &egid, &sgid) < 0)
+	{
+	  printf ("getresgid failed: %d %m\n", tno);
+	  exit (1);
+	}
+
+      if (rgid != nobody_gid || egid != nobody_gid || sgid != nobody_gid)
+	{
+	  printf ("after setresgid %d (%d %d %d) != (%d %d %d)\n", tno,
+		  rgid, egid, sgid, nobody_gid, nobody_gid, nobody_gid);
+	  exit (1);
+	}
+    }
+}
+
+
+static void
+test_setresgid4 (enum ACTION action, int tno)
+{
+  if (action == PREPARE)
+    {
+      if (setresgid (nobody_gid, nobody_gid, -1) < 0)
+	{
+	  printf ("setresgid failed: %m\n");
+	  exit (1);
+	}
+
+      prev_rgid = nobody_gid;
+      prev_egid = nobody_gid;
+      nobody_gid = prev_sgid;
+      return;
+    }
+
+  test_setresgid1 (action, tno);
+}
+
+
+static struct setuid_test
+{
+  const char *name;
+  void (*test) (enum ACTION, int tno);
+} setuid_tests[] =
+{
+  { "setuid1", test_setuid1 },
+  { "setuid2", test_setuid2 },
+  { "seteuid1", test_seteuid1 },
+  { "seteuid2", test_seteuid2 },
+  { "setreuid1", test_setreuid1 },
+  { "setreuid2", test_setreuid2 },
+  { "setreuid3", test_setreuid3 },
+  { "setreuid4", test_setreuid4 },
+  { "setresuid1", test_setresuid1 },
+  { "setresuid2", test_setresuid2 },
+  { "setresuid3", test_setresuid3 },
+  { "setresuid4", test_setresuid4 },
+  { "setgid1", test_setgid1 },
+  { "setgid2", test_setgid2 },
+  { "setegid1", test_setegid1 },
+  { "setegid2", test_setegid2 },
+  { "setregid1", test_setregid1 },
+  { "setregid2", test_setregid2 },
+  { "setregid3", test_setregid3 },
+  { "setregid4", test_setregid4 },
+  { "setresgid1", test_setresgid1 },
+  { "setresgid2", test_setresgid2 },
+  { "setresgid3", test_setresgid3 },
+  { "setresgid4", test_setresgid4 }
+};
+
+
+static void *
+tf2 (void *arg)
+{
+  int e = pthread_barrier_wait (&b4);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      exit (1);
+    }
+
+  setuid_tests[TESTNO (arg)].test (CHECK_AFTER, THREADNO (arg));
+  return NULL;
+}
+
+
+static void *
+tf (void *arg)
+{
+  setuid_tests[TESTNO (arg)].test (CHECK_BEFORE, THREADNO (arg));
+
+  int e = pthread_barrier_wait (&b3);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      exit (1);
+    }
+
+  return tf2 (arg);
+}
+
+
+static int
+do_one_test (long int testno)
+{
+  printf ("%s test\n", setuid_tests[testno].name);
+
+  pid_t pid = fork ();
+  if (pid == 0)
+    {
+      setuid_tests[testno].test (PREPARE, 0);
+      setuid_tests[testno].test (SET, 0);
+      exit (0);
+    }
+
+  if (pid < 0)
+    {
+      printf ("fork failed: %m\n");
+      exit (1);
+    }
+
+  int status;
+  if (waitpid (pid, &status, 0) < 0)
+    {
+      printf ("waitpid failed: %m\n");
+      exit (1);
+    }
+
+  if (!WIFEXITED (status))
+    {
+      puts ("child did not exit");
+      exit (1);
+    }
+
+  if (WEXITSTATUS (status))
+    {
+      printf ("skipping %s test\n", setuid_tests[testno].name);
+      return 0;
+    }
+
+  pid = fork ();
+  if (pid == 0)
+    {
+      setuid_tests[testno].test (PREPARE, 0);
+
+      pthread_t th;
+      int e = pthread_create (&th, NULL, tf, (void *) (testno | 0x100L));
+      if (e != 0)
+	{
+	  printf ("create failed: %m\n");
+	  exit (1);
+	}
+
+      pthread_t th2;
+      e = pthread_create (&th2, NULL, tf, (void *) (testno | 0x200L));
+      if (e != 0)
+	{
+	  printf ("create failed: %m\n");
+	  exit (1);
+	}
+
+      e = pthread_barrier_wait (&b3);
+      if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  puts ("barrier_wait failed");
+	  exit (1);
+	}
+
+      setuid_tests[testno].test (SET, 0);
+
+      pthread_t th3;
+      e = pthread_create (&th3, NULL, tf2, (void *) (testno | 0x300L));
+      if (e != 0)
+	{
+	  printf ("create failed: %m\n");
+	  exit (1);
+	}
+
+      e = pthread_barrier_wait (&b4);
+      if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  puts ("barrier_wait failed");
+	  exit (1);
+	}
+
+      exit (0);
+    }
+
+  if (pid < 0)
+    {
+      printf ("fork failed: %m\n");
+      exit (1);
+    }
+
+  if (waitpid (pid, &status, 0) < 0)
+    {
+      printf ("waitpid failed: %m\n");
+      exit (1);
+    }
+
+  if (!WIFEXITED (status))
+    {
+      puts ("second child did not exit");
+      exit (1);
+    }
+
+  if (WEXITSTATUS (status))
+    exit (WEXITSTATUS (status));
+
+  return 0;
+}
+
+
+static int
+do_test (void)
+{
+  struct passwd *pwd = getpwnam ("nobody");
+  if (pwd == NULL)
+    {
+      puts ("User nobody doesn't exist");
+      return 0;
+    }
+  nobody_uid = pwd->pw_uid;
+  nobody_gid = pwd->pw_gid;
+
+  if (getresuid (&prev_ruid, &prev_euid, &prev_suid) < 0)
+    {
+      printf ("getresuid failed: %m\n");
+      exit (1);
+    }
+
+  if (getresgid (&prev_rgid, &prev_egid, &prev_sgid) < 0)
+    {
+      printf ("getresgid failed: %m\n");
+      exit (1);
+    }
+
+  if (prev_ruid == nobody_uid || prev_euid == nobody_uid
+      || prev_suid == nobody_uid)
+    {
+      puts ("already running as user nobody, skipping tests");
+      exit (0);
+    }
+
+  if (prev_rgid == nobody_gid || prev_egid == nobody_gid
+      || prev_sgid == nobody_gid)
+    {
+      puts ("already running as group nobody, skipping tests");
+      exit (0);
+    }
+
+  if (pthread_barrier_init (&b3, NULL, 3) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  if (pthread_barrier_init (&b4, NULL, 4) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  for (unsigned long int testno = 0;
+       testno < sizeof (setuid_tests) / sizeof (setuid_tests[0]);
+       ++testno)
+    do_one_test (testno);
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-signal1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-signal1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-signal1.c	(revision 2036)
@@ -0,0 +1,189 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+
+static sigset_t ss;
+static pthread_barrier_t *b;
+
+
+static void *
+tf (void *arg)
+{
+  sigdelset (&ss, SIGINT);
+
+  if (pthread_sigmask (SIG_SETMASK, &ss, NULL) != 0)
+    {
+      puts ("2nd pthread_sigmask failed");
+      exit (1);
+    }
+
+  pthread_barrier_wait (b);
+
+  int sig;
+  int res = sigwait (&ss, &sig);
+  if (res == 0)
+    {
+      printf ("sigwait returned successfully with signal %d\n", sig);
+      exit (1);
+    }
+
+  printf ("sigwait returned with %s (%d)\n", strerror (res), res);
+
+  return NULL;
+}
+
+
+static void
+receiver (void)
+{
+  pthread_t th;
+
+  /* Make sure the process doesn't run forever.  */
+  alarm (10);
+
+  sigfillset (&ss);
+
+  if (pthread_sigmask (SIG_SETMASK, &ss, NULL) != 0)
+    {
+      puts ("1st pthread_sigmask failed");
+      exit (1);
+    }
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("pthread_create failed");
+      exit (1);
+    }
+
+  if (pthread_join (th, NULL) == 0)
+    {
+      puts ("thread joined?!");
+      exit (1);
+    }
+
+  _exit (0);
+}
+
+
+static int
+do_test (void)
+{
+  char tmp[] = "/tmp/tst-signal1-XXXXXX";
+
+  int fd = mkstemp (tmp);
+  if (fd == -1)
+    {
+      puts ("mkstemp failed");
+      exit (1);
+    }
+
+  unlink (tmp);
+
+  int i;
+  for (i = 0; i < 20; ++i)
+    write (fd, "foobar xyzzy", 12);
+
+  b = mmap (NULL, sizeof (pthread_barrier_t), PROT_READ | PROT_WRITE,
+	    MAP_SHARED, fd, 0);
+  if (b == MAP_FAILED)
+    {
+      puts ("mmap failed");
+      exit (1);
+    }
+
+  pthread_barrierattr_t ba;
+  if (pthread_barrierattr_init (&ba) != 0)
+    {
+      puts ("barrierattr_init failed");
+      exit (1);
+    }
+
+  if (pthread_barrierattr_setpshared (&ba, PTHREAD_PROCESS_SHARED) != 0)
+    {
+      puts ("barrierattr_setpshared failed");
+      exit (1);
+    }
+
+  if (pthread_barrier_init (b, &ba, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  if (pthread_barrierattr_destroy (&ba) != 0)
+    {
+      puts ("barrierattr_destroy failed");
+      exit (1);
+    }
+
+  pid_t pid = fork ();
+  if (pid == -1)
+    {
+      puts ("fork failed");
+      exit (1);
+    }
+
+  if (pid == 0)
+    receiver ();
+
+  pthread_barrier_wait (b);
+
+  /* Wait a bit more.  */
+  struct timespec ts = { .tv_sec = 0, .tv_nsec = 10000000 };
+  nanosleep (&ts, NULL);
+
+  /* Send the signal.  */
+  puts ("sending the signal now");
+  kill (pid, SIGINT);
+
+  /* Wait for the process to terminate.  */
+  int status;
+  if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
+    {
+      puts ("wrong child reported terminated");
+      exit (1);
+    }
+
+  if (!WIFSIGNALED (status))
+    {
+      puts ("child wasn't signalled");
+      exit (1);
+    }
+
+  if (WTERMSIG (status) != SIGINT)
+    {
+      puts ("child not terminated with SIGINT");
+      exit (1);
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-signal2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-signal2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-signal2.c	(revision 2036)
@@ -0,0 +1,198 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+#include <string.h>
+
+
+static sigset_t ss;
+static pthread_barrier_t *b;
+
+
+static void *
+tf (void *arg)
+{
+  pthread_barrier_wait (b);
+
+  puts ("child: calling sigwait now");
+
+  int sig;
+  int err;
+  err = sigwait (&ss, &sig);
+  if (err != 0)
+    {
+      printf ("sigwait returned unsuccessfully: %s (%d)\n",
+	      strerror (err), err);
+      _exit (1);
+    }
+
+  puts ("sigwait returned");
+
+  if (sig != SIGINT)
+    {
+      printf ("caught signal %d, expected %d (SIGINT)\n", sig, SIGINT);
+      _exit (1);
+    }
+
+  puts ("child thread terminating now");
+
+  return NULL;
+}
+
+
+static void
+receiver (void)
+{
+  pthread_t th;
+
+  /* Make sure the process doesn't run forever.  */
+  alarm (10);
+
+  sigfillset (&ss);
+
+  if (pthread_sigmask (SIG_SETMASK, &ss, NULL) != 0)
+    {
+      puts ("1st pthread_sigmask failed");
+      _exit (1);
+    }
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("pthread_create failed");
+      _exit (1);
+    }
+
+  if (pthread_join (th, NULL) != 0)
+    {
+      puts ("thread didn't join");
+      _exit (1);
+    }
+
+  puts ("join succeeded");
+
+  _exit (0);
+}
+
+
+static int
+do_test (void)
+{
+  char tmp[] = "/tmp/tst-signal1-XXXXXX";
+
+  int fd = mkstemp (tmp);
+  if (fd == -1)
+    {
+      puts ("mkstemp failed");
+      exit (1);
+    }
+
+  unlink (tmp);
+
+  int i;
+  for (i = 0; i < 20; ++i)
+    write (fd, "foobar xyzzy", 12);
+
+  b = mmap (NULL, sizeof (pthread_barrier_t), PROT_READ | PROT_WRITE,
+	    MAP_SHARED, fd, 0);
+  if (b == MAP_FAILED)
+    {
+      puts ("mmap failed");
+      exit (1);
+    }
+
+  pthread_barrierattr_t ba;
+  if (pthread_barrierattr_init (&ba) != 0)
+    {
+      puts ("barrierattr_init failed");
+      exit (1);
+    }
+
+  if (pthread_barrierattr_setpshared (&ba, PTHREAD_PROCESS_SHARED) != 0)
+    {
+      puts ("barrierattr_setpshared failed");
+      exit (1);
+    }
+
+  if (pthread_barrier_init (b, &ba, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  if (pthread_barrierattr_destroy (&ba) != 0)
+    {
+      puts ("barrierattr_destroy failed");
+      exit (1);
+    }
+
+  pid_t pid = fork ();
+  if (pid == -1)
+    {
+      puts ("fork failed");
+      exit (1);
+    }
+
+  if (pid == 0)
+    receiver ();
+
+  pthread_barrier_wait (b);
+
+  /* Wait a bit more.  */
+  struct timespec ts = { .tv_sec = 0, .tv_nsec = 10000000 };
+  nanosleep (&ts, NULL);
+
+  /* Send the signal.  */
+  puts ("sending the signal now");
+  kill (pid, SIGINT);
+
+  /* Wait for the process to terminate.  */
+  int status;
+  if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
+    {
+      puts ("wrong child reported terminated");
+      exit (1);
+    }
+
+  if (!WIFEXITED (status))
+    {
+      if (WIFSIGNALED (status))
+	printf ("child exited with signal %d\n", WTERMSIG (status));
+      else
+	puts ("child didn't exit normally");
+      exit (1);
+    }
+
+  if (WEXITSTATUS (status) != 0)
+    {
+      printf ("exit status %d != 0\n", WEXITSTATUS (status));
+      exit (1);
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-signal3.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-signal3.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-signal3.c	(revision 2036)
@@ -0,0 +1,261 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <semaphore.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+/* Number of different signalss to use.  Also is the number of
+   threads.  */
+#define N 10
+/* Maximum number of threads in flight at any one time.  */
+#define INFLIGHT 5
+/* Number of signals sent in total.  */
+#define ROUNDS 10000
+
+
+static int received[N][N];
+static int nsig[N];
+static pthread_t th[N];
+static sem_t sem;
+static pthread_mutex_t lock[N];
+static pthread_t th_main;
+static int sig0;
+
+static void
+handler (int sig)
+{
+  int i;
+  for (i = 0; i < N; ++i)
+    if (pthread_equal (pthread_self (), th[i]))
+      break;
+
+  if (i == N)
+    {
+      if (pthread_equal (pthread_self (), th_main))
+	puts ("signal received by main thread");
+      else
+	printf ("signal received by unknown thread (%lx)\n",
+		(unsigned long int) pthread_self ());
+      exit (1);
+    }
+
+  ++received[i][sig - sig0];
+
+  sem_post (&sem);
+}
+
+
+static void *
+tf (void *arg)
+{
+  int idx = (long int) arg;
+
+  sigset_t ss;
+  sigemptyset (&ss);
+
+  int i;
+  for (i = 0; i <= idx; ++i)
+    sigaddset (&ss, sig0 + i);
+
+  if (pthread_sigmask (SIG_UNBLOCK, &ss, NULL) != 0)
+    {
+      printf ("thread %d: pthread_sigmask failed\n", i);
+      exit (1);
+    }
+
+  pthread_mutex_lock (&lock[idx]);
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  /* Block all signals.  */
+  sigset_t ss;
+  sigfillset (&ss);
+
+  th_main = pthread_self ();
+
+  sig0 = SIGRTMIN;
+
+  if (pthread_sigmask (SIG_SETMASK, &ss, NULL) != 0)
+    {
+      puts ("1st pthread_sigmask failed");
+      exit (1);
+    }
+
+  /* Install the handler.  */
+  int i;
+  for (i = 0; i < N; ++i)
+    {
+      struct sigaction sa =
+	{
+	  .sa_handler = handler,
+	  .sa_flags = 0
+	};
+      sigfillset (&sa.sa_mask);
+
+      if (sigaction (sig0 + i, &sa, NULL) != 0)
+	{
+	  printf ("sigaction for signal %d failed\n", i);
+	  exit (1);
+	}
+    }
+
+  if (sem_init (&sem, 0, INFLIGHT) != 0)
+    {
+      puts ("sem_init failed");
+      exit (1);
+    }
+
+  pthread_attr_t a;
+
+  if (pthread_attr_init (&a) != 0)
+    {
+      puts ("attr_init failed");
+      exit (1);
+    }
+
+  if (pthread_attr_setstacksize (&a, 1 * 1024 * 1024) != 0)
+    {
+      puts ("attr_setstacksize failed");
+      return 1;
+    }
+
+  for (i = 0; i < N; ++i)
+    {
+      if (pthread_mutex_init (&lock[i], NULL) != 0)
+	{
+	  printf ("mutex_init[%d] failed\n", i);
+	}
+
+      if (pthread_mutex_lock (&lock[i]) != 0)
+	{
+	  printf ("mutex_lock[%d] failed\n", i);
+	}
+
+      if (pthread_create (&th[i], &a, tf, (void *) (long int) i) != 0)
+	{
+	  printf ("create of thread %d failed\n", i);
+	  exit (1);
+	}
+    }
+
+  if (pthread_attr_destroy (&a) != 0)
+    {
+      puts ("attr_destroy failed");
+      exit (1);
+    }
+
+  int result = 0;
+  unsigned int r = 42;
+  pid_t pid = getpid ();
+
+  for (i = 0; i < ROUNDS; ++i)
+    {
+      if (TEMP_FAILURE_RETRY (sem_wait (&sem)) != 0)
+	{
+	  printf ("sem_wait round %d failed: %m\n", i);
+	  exit (1);
+	}
+
+      int s = rand_r (&r) % N;
+
+      kill (pid, sig0 + s);
+    }
+
+  void *status;
+  for (i = 0; i < N; ++i)
+    {
+      if (pthread_mutex_unlock (&lock[i]) != 0)
+	{
+	  printf ("unlock %d failed\n", i);
+	  exit (1);
+	}
+
+      if (pthread_join (th[i], &status) != 0)
+	{
+	  printf ("join %d failed\n", i);
+	  result = 1;
+	}
+      else if (status != NULL)
+	{
+	  printf ("%d: result != NULL\n", i);
+	  result = 1;
+	}
+    }
+
+  int total = 0;
+  for (i = 0; i < N; ++i)
+    {
+      int j;
+
+      for (j = 0; j <= i; ++j)
+	total += received[i][j];
+
+      for (j = i + 1; j < N; ++j)
+	if (received[i][j] != 0)
+	  {
+	    printf ("thread %d received signal SIGRTMIN+%d\n", i, j);
+	    result = 1;
+	  }
+    }
+
+  if (total != ROUNDS)
+    {
+      printf ("total number of handled signals is %d, expected %d\n",
+	      total, ROUNDS);
+      result = 1;
+    }
+
+  printf ("A total of %d signals sent and received\n", total);
+  for (i = 0; i < N; ++i)
+    {
+      printf ("thread %2d:", i);
+
+      int j;
+      for (j = 0; j <= i; ++j)
+	{
+	  printf (" %5d", received[i][j]);
+	  nsig[j] += received[i][j];
+	}
+
+      putchar ('\n');
+
+    }
+
+  printf ("\nTotal    :");
+  for (i = 0; i < N; ++i)
+    printf (" %5d", nsig[i]);
+  putchar ('\n');
+
+  return result;
+}
+
+#define TIMEOUT 10
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-signal4.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-signal4.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-signal4.c	(revision 2036)
@@ -0,0 +1,60 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static int
+do_test (void)
+{
+  sigset_t ss;
+
+  sigemptyset (&ss);
+
+  int i;
+  for (i = 0; i < 10000; ++i)
+    {
+      long int r = random ();
+
+      if (r != SIG_BLOCK && r != SIG_SETMASK && r != SIG_UNBLOCK)
+	{
+	  int e = pthread_sigmask (r, &ss, NULL);
+
+	  if (e == 0)
+	    {
+	      printf ("pthread_sigmask succeeded for how = %ld\n", r);
+	      exit (1);
+	    }
+
+	  if (e != EINVAL)
+	    {
+	      puts ("pthread_sigmask didn't return EINVAL");
+	      exit (1);
+	    }
+	}
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-signal5.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-signal5.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-signal5.c	(revision 2036)
@@ -0,0 +1,111 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+
+static sigset_t ss;
+
+
+static void *
+tf (void *arg)
+{
+  sigset_t ss2;
+  if (pthread_sigmask (SIG_SETMASK, NULL, &ss2) != 0)
+    {
+      puts ("child: sigmask failed");
+      exit (1);
+    }
+
+  int i;
+  for (i = 1; i < 32; ++i)
+    if (sigismember (&ss, i) && ! sigismember (&ss2, i))
+      {
+	printf ("signal %d set in parent mask, but not in child\n", i);
+	exit (1);
+      }
+    else if (! sigismember (&ss, i) && sigismember (&ss2, i))
+      {
+	printf ("signal %d set in child mask, but not in parent\n", i);
+	exit (1);
+      }
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  sigemptyset (&ss);
+  sigaddset (&ss, SIGUSR1);
+  if (pthread_sigmask (SIG_SETMASK, &ss, NULL) != 0)
+    {
+      puts ("1st sigmask failed");
+      exit (1);
+    }
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("1st create failed");
+      exit (1);
+    }
+
+  void *r;
+  if (pthread_join (th, &r) != 0)
+    {
+      puts ("1st join failed");
+      exit (1);
+    }
+
+  sigemptyset (&ss);
+  sigaddset (&ss, SIGUSR2);
+  sigaddset (&ss, SIGFPE);
+  if (pthread_sigmask (SIG_SETMASK, &ss, NULL) != 0)
+    {
+      puts ("2nd sigmask failed");
+      exit (1);
+    }
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("2nd create failed");
+      exit (1);
+    }
+
+  if (pthread_join (th, &r) != 0)
+    {
+      puts ("2nd join failed");
+      exit (1);
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-signal6.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-signal6.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-signal6.c	(revision 2036)
@@ -0,0 +1,192 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <signal.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+#define N 2
+static pthread_barrier_t bar;
+static struct
+{
+  void *p;
+  pthread_t s;
+} ti[N];
+static int sig1;
+
+
+static void
+handler (int sig)
+{
+  pthread_t self = pthread_self ();
+  size_t i;
+
+  for (i = 0; i < N; ++i)
+    if (ti[i].s == self)
+      {
+	if ((uintptr_t) ti[i].p <= (uintptr_t) &self
+	    && (uintptr_t) ti[i].p + 2 * MINSIGSTKSZ > (uintptr_t) &self)
+	  {
+	    puts ("alt stack not used");
+	    exit (1);
+	  }
+
+	printf ("thread %zu used alt stack for signal %d\n", i, sig);
+
+	return;
+      }
+
+  puts ("handler: thread not found");
+  exit (1);
+}
+
+
+static void *
+tf (void *arg)
+{
+  size_t nr = (uintptr_t) arg;
+  if (nr >= N)
+    {
+      puts ("wrong nr parameter");
+      exit (1);
+    }
+
+  sigset_t ss;
+  sigemptyset (&ss);
+  size_t i;
+  for (i = 0; i < N; ++i)
+    if (i != nr)
+      if (sigaddset (&ss, sig1 + i) != 0)
+	{
+	  puts ("tf: sigaddset failed");
+	  exit (1);
+	}
+  if (pthread_sigmask (SIG_BLOCK, &ss, NULL) != 0)
+    {
+      puts ("tf: sigmask failed");
+      exit (1);
+    }
+
+  void *p = malloc (2 * MINSIGSTKSZ);
+  if (p == NULL)
+    {
+      puts ("tf: malloc failed");
+      exit (1);
+    }
+
+  stack_t s;
+  s.ss_sp = p;
+  s.ss_size = 2 * MINSIGSTKSZ;
+  s.ss_flags = 0;
+  if (sigaltstack (&s, NULL) != 0)
+    {
+      puts ("tf: sigaltstack failed");
+      exit (1);
+    }
+
+  ti[nr].p = p;
+  ti[nr].s = pthread_self ();
+
+  pthread_barrier_wait (&bar);
+
+  pthread_barrier_wait (&bar);
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  sig1 = SIGRTMIN;
+  if (sig1 + N > SIGRTMAX)
+    {
+      puts ("too few RT signals");
+      return 0;
+    }
+
+  struct sigaction sa;
+  sa.sa_handler = handler;
+  sa.sa_flags = 0;
+  sigemptyset (&sa.sa_mask);
+
+  if (sigaction (sig1, &sa, NULL) != 0
+      || sigaction (sig1 + 1, &sa, NULL) != 0
+      || sigaction (sig1 + 2, &sa, NULL) != 0)
+    {
+      puts ("sigaction failed");
+      return 1;
+    }
+
+  if (pthread_barrier_init (&bar, NULL, 1 + N) != 0)
+    {
+      puts ("barrier_init failed");
+      return 1;
+    }
+
+  pthread_t th[N];
+  size_t i;
+  for (i = 0; i < N; ++i)
+    if (pthread_create (&th[i], NULL, tf, (void *) (long int) i) != 0)
+      {
+	puts ("create failed");
+	return 1;
+      }
+
+  /* Block the three signals.  */
+  sigset_t ss;
+  sigemptyset (&ss);
+  for (i = 0; i <= N; ++i)
+    sigaddset (&ss, sig1 + i);
+  if (pthread_sigmask (SIG_BLOCK, &ss, NULL) != 0)
+    {
+      puts ("main: sigmask failed");
+      return 1;
+    }
+
+  pthread_barrier_wait (&bar);
+
+  /* Send some signals.  */
+  pid_t me = getpid ();
+  kill (me, sig1 + N);
+  for (i = 0; i < N; ++i)
+    kill (me, sig1 + i);
+  kill (me, sig1 + N);
+
+  /* Give the signals a chance to be worked on.  */
+  sleep (1);
+
+  pthread_barrier_wait (&bar);
+
+  for (i = 0; i < N; ++i)
+    if (pthread_join (th[i], NULL) != 0)
+      {
+	puts ("join failed");
+	return 1;
+      }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-spin1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-spin1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-spin1.c	(revision 2036)
@@ -0,0 +1,57 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+
+
+static int
+do_test (void)
+{
+  pthread_spinlock_t s;
+
+  if (pthread_spin_init (&s, PTHREAD_PROCESS_PRIVATE) != 0)
+    {
+      puts ("spin_init failed");
+      return 1;
+    }
+
+  if (pthread_spin_lock (&s) != 0)
+    {
+      puts ("spin_lock failed");
+      return 1;
+    }
+
+  if (pthread_spin_unlock (&s) != 0)
+    {
+      puts ("spin_unlock failed");
+      return 1;
+    }
+
+  if (pthread_spin_destroy (&s) != 0)
+    {
+      puts ("spin_destroy failed");
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-spin2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-spin2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-spin2.c	(revision 2036)
@@ -0,0 +1,159 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+
+static int
+do_test (void)
+{
+  size_t ps = sysconf (_SC_PAGESIZE);
+  char tmpfname[] = "/tmp/tst-spin2.XXXXXX";
+  char data[ps];
+  void *mem;
+  int fd;
+  pthread_spinlock_t *s;
+  pid_t pid;
+  char *p;
+  int err;
+
+  fd = mkstemp (tmpfname);
+  if (fd == -1)
+    {
+      printf ("cannot open temporary file: %m\n");
+      return 1;
+    }
+
+  /* Make sure it is always removed.  */
+  unlink (tmpfname);
+
+  /* Create one page of data.  */
+  memset (data, '\0', ps);
+
+  /* Write the data to the file.  */
+  if (write (fd, data, ps) != (ssize_t) ps)
+    {
+      puts ("short write");
+      return 1;
+    }
+
+  mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+  if (mem == MAP_FAILED)
+    {
+      printf ("mmap failed: %m\n");
+      return 1;
+    }
+
+  s = (pthread_spinlock_t *) (((uintptr_t) mem
+			       + __alignof (pthread_spinlock_t))
+			      & ~(__alignof (pthread_spinlock_t) - 1));
+  p = (char *) (s + 1);
+
+  if (pthread_spin_init (s, PTHREAD_PROCESS_SHARED) != 0)
+    {
+      puts ("spin_init failed");
+      return 1;
+    }
+
+  if (pthread_spin_lock (s) != 0)
+    {
+      puts ("spin_lock failed");
+      return 1;
+    }
+
+  err = pthread_spin_trylock (s);
+  if (err == 0)
+    {
+      puts ("1st spin_trylock succeeded");
+      return 1;
+    }
+  else if (err != EBUSY)
+    {
+      puts ("1st spin_trylock didn't return EBUSY");
+      return 1;
+    }
+
+  err = pthread_spin_unlock (s);
+  if (err != 0)
+    {
+      puts ("parent: spin_unlock failed");
+      return 1;
+    }
+
+  err = pthread_spin_trylock (s);
+  if (err != 0)
+    {
+      puts ("2nd spin_trylock failed");
+      return 1;
+    }
+
+  *p = 0;
+
+  puts ("going to fork now");
+  pid = fork ();
+  if (pid == -1)
+    {
+      puts ("fork failed");
+      return 1;
+    }
+  else if (pid == 0)
+    {
+      /* Play some lock ping-pong.  It's our turn to unlock first.  */
+      if ((*p)++ != 0)
+	{
+	  puts ("child: *p != 0");
+	  return 1;
+	}
+
+      if (pthread_spin_unlock (s) != 0)
+	{
+	  puts ("child: 1st spin_unlock failed");
+	  return 1;
+	}
+
+      puts ("child done");
+    }
+  else
+    {
+      if (pthread_spin_lock (s) != 0)
+	{
+	  puts ("parent: 2nd spin_lock failed");
+	  return 1;
+	}
+
+      puts ("waiting for child");
+
+      waitpid (pid, NULL, 0);
+
+      puts ("parent done");
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-spin3.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-spin3.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-spin3.c	(revision 2036)
@@ -0,0 +1,55 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+static int
+do_test (void)
+{
+  pthread_spinlock_t s;
+
+  if (pthread_spin_init (&s, PTHREAD_PROCESS_PRIVATE) != 0)
+    {
+      puts ("spin_init failed");
+      return 1;
+    }
+
+  if (pthread_spin_lock (&s) != 0)
+    {
+      puts ("1st spin_lock failed");
+      return 1;
+    }
+
+  /* Set an alarm for 1 second.  The wrapper will expect this.  */
+  alarm (1);
+
+  /* This call should never return.  */
+  pthread_spin_lock (&s);
+
+  puts ("2nd spin_lock returned");
+  return 1;
+}
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-stack1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-stack1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-stack1.c	(revision 2036)
@@ -0,0 +1,146 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <limits.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/param.h>
+#include <unistd.h>
+
+
+static void *stack;
+static size_t size;
+
+
+static void *
+tf (void *a)
+{
+  int result = 0;
+
+  puts ("child start");
+
+  pthread_attr_t attr;
+  if (pthread_getattr_np (pthread_self (), &attr) != 0)
+    {
+      puts ("getattr_np failed");
+      exit (1);
+    }
+
+  size_t test_size;
+  void *test_stack;
+  if (pthread_attr_getstack (&attr, &test_stack, &test_size) != 0)
+    {
+      puts ("attr_getstack failed");
+      exit (1);
+    }
+
+  if (test_size != size)
+    {
+      printf ("child: reported size differs: is %zu, expected %zu\n",
+	      test_size, size);
+      result = 1;
+    }
+
+  if (test_stack != stack)
+    {
+      printf ("child: reported stack address differs: is %p, expected %p\n",
+	      test_stack, stack);
+      result = 1;
+    }
+
+  puts ("child OK");
+
+  return result ? (void *) 1l : NULL;
+}
+
+
+int
+do_test (void)
+{
+  int result = 0;
+
+  size = MAX (4 * getpagesize (), PTHREAD_STACK_MIN);
+  if (posix_memalign (&stack, getpagesize (), size) != 0)
+    {
+      puts ("out of memory while allocating the stack memory");
+      exit (1);
+    }
+
+  pthread_attr_t attr;
+  if (pthread_attr_init (&attr) != 0)
+    {
+      puts ("attr_init failed");
+      exit (1);
+    }
+
+  puts ("attr_setstack");
+  if (pthread_attr_setstack (&attr, stack, size) != 0)
+    {
+      puts ("attr_setstack failed");
+      exit (1);
+    }
+
+  size_t test_size;
+  void *test_stack;
+  puts ("attr_getstack");
+  if (pthread_attr_getstack (&attr, &test_stack, &test_size) != 0)
+    {
+      puts ("attr_getstack failed");
+      exit (1);
+    }
+
+  if (test_size != size)
+    {
+      printf ("reported size differs: is %zu, expected %zu\n",
+	      test_size, size);
+      result = 1;
+    }
+
+  if (test_stack != stack)
+    {
+      printf ("reported stack address differs: is %p, expected %p\n",
+	      test_stack, stack);
+      result = 1;
+    }
+
+  puts ("create");
+
+  pthread_t th;
+  if (pthread_create (&th, &attr, tf, NULL) != 0)
+    {
+      puts ("failed to create thread");
+      exit (1);
+    }
+
+  void *status;
+  if (pthread_join (th, &status) != 0)
+    {
+      puts ("join failed");
+      exit (1);
+    }
+
+  result |= status != NULL;
+
+  return result;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-stack2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-stack2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-stack2.c	(revision 2036)
@@ -0,0 +1,79 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* Test whether it is possible to create a thread with PTHREAD_STACK_MIN
+   stack size.  */
+
+#include <pthread.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+static int seen;
+
+static void *
+tf (void *p)
+{
+  ++seen;
+  return NULL;
+}
+
+static int
+do_test (void)
+{
+  pthread_attr_t attr;
+  pthread_attr_init (&attr);
+
+  int result = 0;
+  int res = pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN);
+  if (res)
+    {
+      printf ("pthread_attr_setstacksize failed %d\n", res);
+      result = 1;
+    }
+
+  /* Create the thread.  */
+  pthread_t th;
+  res = pthread_create (&th, &attr, tf, NULL);
+  if (res)
+    {
+      printf ("pthread_create failed %d\n", res);
+      result = 1;
+    }
+  else
+    {
+      res = pthread_join (th, NULL);
+      if (res)
+	{
+	  printf ("pthread_join failed %d\n", res);
+	  result = 1;
+	}
+    }
+
+  if (seen != 1)
+    {
+      printf ("seen %d != 1\n", seen);
+      result = 1;
+    }
+
+  return result;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-stack3.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-stack3.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-stack3.c	(revision 2036)
@@ -0,0 +1,101 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* Test whether pthread_create/pthread_join with user defined stacks
+   doesn't leak memory.
+   NOTE: this tests functionality beyond POSIX.  In POSIX user defined
+   stacks cannot be ever freed once used by pthread_create nor they can
+   be reused for other thread.  */
+
+#include <limits.h>
+#include <mcheck.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+static int seen;
+
+static void *
+tf (void *p)
+{
+  ++seen;
+  return NULL;
+}
+
+static int
+do_test (void)
+{
+  mtrace ();
+
+  void *stack;
+  int res = posix_memalign (&stack, getpagesize (), 4 * PTHREAD_STACK_MIN);
+  if (res)
+    {
+      printf ("malloc failed %s\n", strerror (res));
+      return 1;
+    }
+
+  pthread_attr_t attr;
+  pthread_attr_init (&attr);
+
+  int result = 0;
+  res = pthread_attr_setstack (&attr, stack, 4 * PTHREAD_STACK_MIN);
+  if (res)
+    {
+      printf ("pthread_attr_setstack failed %d\n", res);
+      result = 1;
+    }
+
+  for (int i = 0; i < 16; ++i)
+    {
+      /* Create the thread.  */
+      pthread_t th;
+      res = pthread_create (&th, &attr, tf, NULL);
+      if (res)
+	{
+	  printf ("pthread_create failed %d\n", res);
+	  result = 1;
+	}
+      else
+	{
+	  res = pthread_join (th, NULL);
+	  if (res)
+	    {
+	      printf ("pthread_join failed %d\n", res);
+	      result = 1;
+	    }
+	}
+    }
+
+  pthread_attr_destroy (&attr);
+
+  if (seen != 16)
+    {
+      printf ("seen %d != 16\n", seen);
+      result = 1;
+    }
+
+  free (stack);
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-stdio1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-stdio1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-stdio1.c	(revision 2036)
@@ -0,0 +1,57 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+static void *tf (void *a)
+{
+  flockfile (stdout);
+  /* This call should never return.  */
+  return a;
+}
+
+
+int
+do_test (void)
+{
+  pthread_t th;
+
+  flockfile (stdout);
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      write (2, "create failed\n", 14);
+      _exit (1);
+    }
+
+  pthread_join (th, NULL);
+
+  puts ("join returned");
+
+  return 0;
+}
+
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-stdio2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-stdio2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-stdio2.c	(revision 2036)
@@ -0,0 +1,82 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static void *tf (void *a)
+{
+  puts ("start tf");
+
+  /* Multiple locking, implicitly or explicitly, must be possible.  */
+  flockfile (stdout);
+
+  puts ("after first flockfile");
+
+  flockfile (stdout);
+
+  puts ("foo");
+
+  funlockfile (stdout);
+
+  puts ("after first funlockfile");
+
+  funlockfile (stdout);
+
+  puts ("all done");
+
+  return a;
+}
+
+
+int
+do_test (void)
+{
+  pthread_t th;
+
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      write (2, "create failed\n", 14);
+      _exit (1);
+    }
+
+  void *result;
+  if (pthread_join (th, &result) != 0)
+    {
+      puts ("join failed");
+      exit (1);
+    }
+  else if (result != NULL)
+    {
+      printf ("wrong return value: %p, expected %p\n", result, NULL);
+      exit (1);
+    }
+
+  puts ("join returned succsefully");
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-sysconf.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-sysconf.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-sysconf.c	(revision 2036)
@@ -0,0 +1,48 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+static int
+do_test (void)
+{
+  puts ("We expect no limits");
+  /* We have no fixed limit on the number of threads.  Make sure the
+     headers tell the right story.  */
+#ifdef PTHREAD_THREADS_MAX
+  printf ("Header report maximum number of threads = %lu\n",
+	  (unsigned long int) PTHREAD_THREADS_MAX);
+  return 1;
+#else
+  long int r = sysconf (_SC_THREAD_THREADS_MAX);
+  if (r != -1)
+    {
+      printf ("sysconf(_SC_THREAD_THREADS_MAX) return %ld\n", r);
+      return 1;
+    }
+#endif
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-tls1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-tls1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-tls1.c	(revision 2036)
@@ -0,0 +1,122 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+#if HAVE___THREAD
+struct test_s
+{
+  int a;
+  int b;
+};
+
+#define INIT_A 1
+#define INIT_B 42
+/* Deliberately not static.  */
+__thread struct test_s s __attribute__ ((tls_model ("initial-exec"))) =
+{
+  .a = INIT_A,
+  .b = INIT_B
+};
+
+
+static void *
+tf (void *arg)
+{
+  if (s.a != INIT_A || s.b != INIT_B)
+    {
+      puts ("initial value of s in child thread wrong");
+      exit (1);
+    }
+
+  ++s.a;
+
+  return NULL;
+}
+#endif
+
+
+int
+do_test (void)
+{
+#if !HAVE___THREAD
+
+  puts ("No __thread support in compiler, test skipped.");
+
+  return 0;
+#else
+
+  if (s.a != INIT_A || s.b != INIT_B)
+    {
+      puts ("initial value of s in main thread wrong");
+      exit (1);
+    }
+
+  pthread_attr_t a;
+
+  if (pthread_attr_init (&a) != 0)
+    {
+      puts ("attr_init failed");
+      exit (1);
+    }
+
+  if (pthread_attr_setstacksize (&a, 1 * 1024 * 1024) != 0)
+    {
+      puts ("attr_setstacksize failed");
+      return 1;
+    }
+
+#define N 10
+  int i;
+  for (i = 0; i < N; ++i)
+    {
+#define M 10
+      pthread_t th[M];
+      int j;
+      for (j = 0; j < M; ++j, ++s.a)
+	if (pthread_create (&th[j], &a, tf, NULL) != 0)
+	  {
+	    puts ("pthread_create failed");
+	    exit (1);
+	  }
+
+      for (j = 0; j < M; ++j)
+	if (pthread_join (th[j], NULL) != 0)
+	  {
+	    puts ("pthread_join failed");
+	    exit (1);
+	  }
+    }
+
+  if (pthread_attr_destroy (&a) != 0)
+    {
+      puts ("attr_destroy failed");
+      exit (1);
+    }
+
+  return 0;
+#endif
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-tls2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-tls2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-tls2.c	(revision 2036)
@@ -0,0 +1,215 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#if HAVE___THREAD
+
+#define N 10
+static pthread_t th[N];
+
+
+#define CB(n) \
+static void								      \
+cb##n (void)								      \
+{									      \
+  if (th[n] != pthread_self ())						      \
+    {									      \
+      write (STDOUT_FILENO, "wrong callback\n", 15);			      \
+      _exit (1);							      \
+    }									      \
+}
+CB (0)
+CB (1)
+CB (2)
+CB (3)
+CB (4)
+CB (5)
+CB (6)
+CB (7)
+CB (8)
+CB (9)
+static void (*cbs[]) (void) =
+{
+  cb0, cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, cb9
+};
+
+
+static __thread void (*fp) (void) __attribute__ ((tls_model ("local-exec")));
+
+
+static sem_t s;
+
+
+#define THE_SIG SIGUSR1
+static void
+handler (int sig)
+{
+  if (sig != THE_SIG)
+    {
+      write (STDOUT_FILENO, "wrong signal\n", 13);
+      _exit (1);
+    }
+
+  fp ();
+
+  if (sem_post (&s) != 0)
+    {
+      write (STDOUT_FILENO, "sem_post failed\n", 16);
+      _exit (1);
+    }
+}
+
+
+static pthread_barrier_t b;
+
+#define TOTAL_SIGS 1000
+static int nsigs;
+
+
+static void *
+tf (void *arg)
+{
+  fp = arg;
+
+  pthread_barrier_wait (&b);
+
+  pthread_barrier_wait (&b);
+
+  if (nsigs != TOTAL_SIGS)
+    {
+      puts ("barrier_wait prematurely returns");
+      exit (1);
+    }
+
+  return NULL;
+}
+#endif
+
+int
+do_test (void)
+{
+#if !HAVE___THREAD
+
+  puts ("No __thread support in compiler, test skipped.");
+
+  return 0;
+#else
+
+  if (pthread_barrier_init (&b, NULL, N + 1) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  if (sem_init (&s, 0, 0) != 0)
+    {
+      puts ("sem_init failed");
+      exit (1);
+    }
+
+  struct sigaction sa;
+  sa.sa_handler = handler;
+  sigemptyset (&sa.sa_mask);
+  sa.sa_flags = 0;
+  if (sigaction (THE_SIG, &sa, NULL) != 0)
+    {
+      puts ("sigaction failed");
+      exit (1);
+    }
+
+  pthread_attr_t a;
+
+  if (pthread_attr_init (&a) != 0)
+    {
+      puts ("attr_init failed");
+      exit (1);
+    }
+
+  if (pthread_attr_setstacksize (&a, 1 * 1024 * 1024) != 0)
+    {
+      puts ("attr_setstacksize failed");
+      return 1;
+    }
+
+  int i;
+  for (i = 0; i < N; ++i)
+    if (pthread_create (&th[i], &a, tf, cbs[i]) != 0)
+      {
+	puts ("pthread_create failed");
+	exit (1);
+      }
+
+  if (pthread_attr_destroy (&a) != 0)
+    {
+      puts ("attr_destroy failed");
+      exit (1);
+    }
+
+  pthread_barrier_wait (&b);
+
+  sigset_t ss;
+  sigemptyset (&ss);
+  sigaddset (&ss, THE_SIG);
+  if (pthread_sigmask (SIG_BLOCK, &ss, NULL) != 0)
+    {
+      puts ("pthread_sigmask failed");
+      exit (1);
+    }
+
+  /* Start sending signals.  */
+  for (i = 0; i < TOTAL_SIGS; ++i)
+    {
+      if (kill (getpid (), THE_SIG) != 0)
+	{
+	  puts ("kill failed");
+	  exit (1);
+	}
+
+      if (TEMP_FAILURE_RETRY (sem_wait (&s)) != 0)
+	{
+	  puts ("sem_wait failed");
+	  exit (1);
+	}
+
+      ++nsigs;
+    }
+
+  pthread_barrier_wait (&b);
+
+  for (i = 0; i < N; ++i)
+    if (pthread_join (th[i], NULL) != 0)
+      {
+	puts ("join failed");
+	exit (1);
+      }
+
+  return 0;
+#endif
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-tls3.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-tls3.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-tls3.c	(revision 2036)
@@ -0,0 +1,215 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <dlfcn.h>
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <semaphore.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <pthreaddef.h>
+
+#define THE_SIG SIGUSR1
+
+
+#define N 10
+static pthread_t th[N];
+
+
+#define CB(n) \
+static void								      \
+cb##n (void)								      \
+{									      \
+  if (th[n] != pthread_self ())						      \
+    {									      \
+      write (STDOUT_FILENO, "wrong callback\n", 15);			      \
+      _exit (1);							      \
+    }									      \
+}
+CB (0)
+CB (1)
+CB (2)
+CB (3)
+CB (4)
+CB (5)
+CB (6)
+CB (7)
+CB (8)
+CB (9)
+static void (*cbs[]) (void) =
+{
+  cb0, cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, cb9
+};
+
+
+sem_t s;
+
+
+pthread_barrier_t b;
+
+#define TOTAL_SIGS 1000
+int nsigs;
+
+
+int
+do_test (void)
+{
+#if !HAVE___THREAD
+
+  puts ("No __thread support in compiler, test skipped.");
+
+  return 0;
+#else
+
+  if ((uintptr_t) pthread_self () & (TCB_ALIGNMENT - 1))
+    {
+      puts ("initial thread's struct pthread not aligned enough");
+      exit (1);
+    }
+
+  if (pthread_barrier_init (&b, NULL, N + 1) != 0)
+    {
+      puts ("barrier_init failed");
+      exit (1);
+    }
+
+  if (sem_init (&s, 0, 0) != 0)
+    {
+      puts ("sem_init failed");
+      exit (1);
+    }
+
+  void *h = dlopen ("tst-tls3mod.so", RTLD_LAZY);
+  if (h == NULL)
+    {
+      puts ("dlopen failed");
+      exit (1);
+    }
+
+  void *(*tf) (void *) = dlsym (h, "tf");
+  if (tf == NULL)
+    {
+      puts ("dlsym for tf failed");
+      exit (1);
+    }
+
+  struct sigaction sa;
+  sa.sa_handler = dlsym (h, "handler");
+  if (sa.sa_handler == NULL)
+    {
+      puts ("dlsym for handler failed");
+      exit (1);
+    }
+  sigemptyset (&sa.sa_mask);
+  sa.sa_flags = 0;
+  if (sigaction (THE_SIG, &sa, NULL) != 0)
+    {
+      puts ("sigaction failed");
+      exit (1);
+    }
+
+  pthread_attr_t a;
+
+  if (pthread_attr_init (&a) != 0)
+    {
+      puts ("attr_init failed");
+      exit (1);
+    }
+
+  if (pthread_attr_setstacksize (&a, 1 * 1024 * 1024) != 0)
+    {
+      puts ("attr_setstacksize failed");
+      return 1;
+    }
+
+  int r;
+  for (r = 0; r < 10; ++r)
+    {
+      int i;
+      for (i = 0; i < N; ++i)
+	if (pthread_create (&th[i], &a, tf, cbs[i]) != 0)
+	  {
+	    puts ("pthread_create failed");
+	    exit (1);
+	  }
+
+      nsigs = 0;
+
+      pthread_barrier_wait (&b);
+
+      sigset_t ss;
+      sigemptyset (&ss);
+      sigaddset (&ss, THE_SIG);
+      if (pthread_sigmask (SIG_BLOCK, &ss, NULL) != 0)
+	{
+	  puts ("pthread_sigmask failed");
+	  exit (1);
+	}
+
+      /* Start sending signals.  */
+      for (i = 0; i < TOTAL_SIGS; ++i)
+	{
+	  if (kill (getpid (), THE_SIG) != 0)
+	    {
+	      puts ("kill failed");
+	      exit (1);
+	    }
+
+	  if (TEMP_FAILURE_RETRY (sem_wait (&s)) != 0)
+	    {
+	      puts ("sem_wait failed");
+	      exit (1);
+	    }
+
+	  ++nsigs;
+	}
+
+      pthread_barrier_wait (&b);
+
+      if (pthread_sigmask (SIG_UNBLOCK, &ss, NULL) != 0)
+	{
+	  puts ("pthread_sigmask failed");
+	  exit (1);
+	}
+
+      for (i = 0; i < N; ++i)
+	if (pthread_join (th[i], NULL) != 0)
+	  {
+	    puts ("join failed");
+	    exit (1);
+	  }
+    }
+
+  if (pthread_attr_destroy (&a) != 0)
+    {
+      puts ("attr_destroy failed");
+      exit (1);
+    }
+
+  return 0;
+#endif
+}
+
+
+#define TIMEOUT 5
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-tls3mod.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-tls3mod.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-tls3mod.c	(revision 2036)
@@ -0,0 +1,92 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <semaphore.h>
+#include <signal.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <pthreaddef.h>
+
+#if HAVE___THREAD
+
+extern pthread_barrier_t b;
+
+#define TOTAL_SIGS 1000
+extern int nsigs;
+
+extern sem_t s;
+
+
+static __thread void (*fp) (void);
+
+
+#define THE_SIG SIGUSR1
+void
+handler (int sig)
+{
+  if (sig != THE_SIG)
+    {
+      write (STDOUT_FILENO, "wrong signal\n", 13);
+      _exit (1);
+    }
+
+  fp ();
+
+  if (sem_post (&s) != 0)
+    {
+      write (STDOUT_FILENO, "sem_post failed\n", 16);
+      _exit (1);
+    }
+}
+
+
+void *
+tf (void *arg)
+{
+  if ((uintptr_t) pthread_self () & (TCB_ALIGNMENT - 1))
+    {
+      puts ("thread's struct pthread not aligned enough");
+      exit (1);
+    }
+
+  if (fp != NULL)
+    {
+      puts ("fp not initially NULL");
+      exit (1);
+    }
+
+  fp = arg;
+
+  pthread_barrier_wait (&b);
+
+  pthread_barrier_wait (&b);
+
+  if (nsigs != TOTAL_SIGS)
+    {
+      puts ("barrier_wait prematurely returns");
+      exit (1);
+    }
+
+  return NULL;
+}
+
+#endif
Index: trunk/src/libctests/glibc/nptl/tst-tls4.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-tls4.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-tls4.c	(revision 2036)
@@ -0,0 +1,191 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <dlfcn.h>
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <tls.h>
+
+#if HAVE___THREAD && defined HAVE_TLS_MODEL_ATTRIBUTE
+
+#define N 3
+
+void (*test1) (void), (*test2) (void);
+
+pthread_barrier_t b2, b3;
+
+static void *
+tf (void *arg)
+{
+  int i;
+
+  for (i = 0; i <= (uintptr_t) arg; ++i)
+    {
+      int r = pthread_barrier_wait (&b3);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  puts ("tf: barrier_wait failed");
+	  exit (1);
+	}
+    }
+
+  test1 ();
+
+  for (i = 0; i < 3; ++i)
+    {
+      int r = pthread_barrier_wait (&b3);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  puts ("tf: barrier_wait failed");
+	  exit (1);
+	}
+    }
+
+  test2 ();
+
+  for (i = 0; i < 3 - (uintptr_t) arg; ++i)
+    {
+      int r = pthread_barrier_wait (&b3);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  puts ("tf: barrier_wait failed");
+	  exit (1);
+	}
+    }
+
+  return NULL;
+}
+
+static void *
+tf2 (void *arg)
+{
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("tf2: barrier_wait failed");
+      exit (1);
+    }
+
+  int i;
+  for (i = 0; i < N; ++i)
+    tf (arg);
+  return NULL;
+}
+
+int
+do_test (void)
+{
+  pthread_t th[2];
+  const char *modules[N]
+    = { "tst-tls4moda.so", "tst-tls4moda.so", "tst-tls4modb.so" };
+
+  if (pthread_barrier_init (&b2, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      return 1;
+    }
+
+  if (pthread_barrier_init (&b3, NULL, 3) != 0)
+    {
+      puts ("barrier_init failed");
+      return 1;
+    }
+
+  if (pthread_create (&th[0], NULL, tf2, (void *) (uintptr_t) 1))
+    {
+      puts ("pthread_create failed");
+      return 1;
+    }
+
+  int r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("barrier_wait failed");
+      return 1;
+    }
+
+  int i;
+  for (i = 0; i < N; ++i)
+    {
+      void *h = dlopen (modules[i], RTLD_LAZY);
+      if (h == NULL)
+	{
+	  printf ("dlopen failed %s\n", dlerror ());
+	  return 1;
+	}
+
+      test1 = dlsym (h, "test1");
+      if (test1 == NULL)
+	{
+	  printf ("dlsym for test1 failed %s\n", dlerror ());
+	  return 1;
+	}
+
+      test2 = dlsym (h, "test2");
+      if (test2 == NULL)
+	{
+	  printf ("dlsym for test2 failed %s\n", dlerror ());
+	  return 1;
+	}
+
+      if (pthread_create (&th[1], NULL, tf, (void *) (uintptr_t) 2))
+	{
+	  puts ("pthread_create failed");
+	  return 1;
+	}
+
+      tf ((void *) (uintptr_t) 0);
+
+      if (pthread_join (th[1], NULL) != 0)
+	{
+	  puts ("join failed");
+	  return 1;
+	}
+
+      if (dlclose (h))
+	{
+	  puts ("dlclose failed");
+	  return 1;
+	}
+
+      printf ("test %d with %s succeeded\n", i, modules[i]);
+    }
+
+  if (pthread_join (th[0], NULL) != 0)
+    {
+      puts ("join failed");
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TIMEOUT 5
+#define TEST_FUNCTION do_test ()
+
+#else
+
+#define TEST_FUNCTION 0
+
+#endif
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-tls4moda.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-tls4moda.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-tls4moda.c	(revision 2036)
@@ -0,0 +1,56 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <tls.h>
+
+#if HAVE___THREAD && defined HAVE_TLS_MODEL_ATTRIBUTE
+
+static __thread unsigned char foo [32]
+  __attribute__ ((tls_model ("initial-exec"), aligned (sizeof (void *))));
+
+void
+test1 (void)
+{
+  size_t s;
+
+  for (s = 0; s < sizeof (foo); ++s)
+    {
+      if (foo [s])
+        abort ();
+      foo [s] = s;
+    }
+}
+
+void
+test2 (void)
+{
+  size_t s;
+
+  for (s = 0; s < sizeof (foo); ++s)
+    {
+      if (foo [s] != s)
+        abort ();
+      foo [s] = sizeof (foo) - s;
+    }
+}
+
+#endif
Index: trunk/src/libctests/glibc/nptl/tst-tls4modb.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-tls4modb.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-tls4modb.c	(revision 2036)
@@ -0,0 +1,65 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <tls.h>
+
+#if HAVE___THREAD && defined HAVE_TLS_MODEL_ATTRIBUTE
+
+static int i;
+int bar;
+
+static __thread void *foo [32 / sizeof (void *)]
+  __attribute__ ((tls_model ("initial-exec"), aligned (sizeof (void *))))
+  = { &i, &bar };
+
+void
+test1 (void)
+{
+  size_t s;
+
+  if (foo [0] != &i || foo [1] != &bar)
+    abort ();
+
+  foo [0] = NULL;
+  foo [1] = NULL;
+  for (s = 0; s < sizeof (foo) / sizeof (void *); ++s)
+    {
+      if (foo [s])
+        abort ();
+      foo [s] = &foo[s];
+    }
+}
+
+void
+test2 (void)
+{
+  size_t s;
+
+  for (s = 0; s < sizeof (foo) / sizeof (void *); ++s)
+    {
+      if (foo [s] != &foo [s])
+        abort ();
+      foo [s] = &foo [s ^ 1];
+    }
+}
+
+#endif
Index: trunk/src/libctests/glibc/nptl/tst-tls5.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-tls5.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-tls5.c	(revision 2036)
@@ -0,0 +1,120 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* Check alignment, overlapping and layout of TLS variables.  */
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <pthreadP.h>
+#include <sys/param.h>
+
+#include "tst-tls5.h"
+
+#ifdef TLS_REGISTER
+
+struct tls_obj tls_registry[64];
+
+static int
+tls_addr_cmp (const void *a, const void *b)
+{
+  if (((struct tls_obj *)a)->addr < ((struct tls_obj *)b)->addr)
+    return -1;
+  if (((struct tls_obj *)a)->addr > ((struct tls_obj *)b)->addr)
+    return 1;
+  return 0;
+}
+
+static int
+do_test (void)
+{
+  size_t cnt, i;
+  int res = 0;
+  uintptr_t min_addr = ~(uintptr_t) 0, max_addr = 0;
+
+  for (cnt = 0; tls_registry[cnt].name; ++cnt);
+  tls_registry[cnt].name = NULL;
+  tls_registry[cnt].addr = (uintptr_t) pthread_self ();
+  tls_registry[cnt].size = sizeof (struct pthread);
+  tls_registry[cnt++].align = __alignof__ (struct pthread);
+
+  qsort (tls_registry, cnt, sizeof (struct tls_obj), tls_addr_cmp);
+
+  for (i = 0; i < cnt; ++i)
+    {
+      printf ("%s%s = %p, size %zd, align %zd",
+	      tls_registry[i].name ? "&" : "",
+	      tls_registry[i].name ?: "pthread_self ()",
+	      (void *) tls_registry[i].addr,
+	      tls_registry[i].size, tls_registry[i].align);
+      if (tls_registry[i].addr & (tls_registry[i].align - 1))
+	{
+	  fputs (", WRONG ALIGNMENT", stdout);
+	  res = 1;
+	}
+      if (i > 0
+	  && (tls_registry[i - 1].addr + tls_registry[i - 1].size
+	      > tls_registry[i].addr))
+	{
+	  fputs (", ADDRESS OVERLAP", stdout);
+	  res = 1;
+	}
+      puts ("");
+      if (tls_registry[i].name)
+	{
+	  min_addr = MIN (tls_registry[i].addr, min_addr);
+	  max_addr = MAX (tls_registry[i].addr + tls_registry[i].size,
+			  max_addr);
+	}
+    }
+
+  if (cnt > 1)
+    {
+#if TLS_TCB_AT_TP
+      if (tls_registry[cnt - 1].name)
+	{
+	  puts ("pthread_self () not larger than all TLS addresses");
+	  res = 1;
+	}
+      else
+	max_addr = MAX (tls_registry[cnt - 1].addr, max_addr);
+#elif TLS_DTV_AT_TP
+      if (tls_registry[0].name)
+	{
+	  puts ("pthread_self () not smaller than all TLS addresses");
+	  res = 1;
+	}
+#else
+      abort ();
+#endif
+      printf ("Initial TLS used block size %zd\n",
+	      (size_t) (max_addr - min_addr));
+    }
+  return res;
+}
+
+#define TEST_FUNCTION do_test ()
+
+#else
+
+#define TEST_FUNCTION 0
+
+#endif
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-tls5.h
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-tls5.h	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-tls5.h	(revision 2036)
@@ -0,0 +1,28 @@
+#include <stdint.h>
+#include <stdlib.h>
+#include <tls.h>
+
+#if USE_TLS && HAVE___THREAD
+
+struct tls_obj
+{
+  const char *name;
+  uintptr_t addr;
+  size_t size;
+  size_t align;
+};
+extern struct tls_obj tls_registry[];
+
+#define TLS_REGISTER(x)				\
+static void __attribute__((constructor))	\
+tls_register_##x (void)				\
+{						\
+  size_t i;					\
+  for (i = 0; tls_registry[i].name; ++i);	\
+  tls_registry[i].name = #x;			\
+  tls_registry[i].addr = (uintptr_t) &x;	\
+  tls_registry[i].size = sizeof (x);		\
+  tls_registry[i].align = __alignof__ (x);	\
+}
+
+#endif
Index: trunk/src/libctests/glibc/nptl/tst-tls5mod.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-tls5mod.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-tls5mod.c	(revision 2036)
@@ -0,0 +1,6 @@
+#include <tst-tls5.h>
+
+#ifdef TLS_REGISTER
+/* Ensure tls_registry is exported from the binary.  */
+void *tst_tls5mod attribute_hidden = tls_registry;
+#endif
Index: trunk/src/libctests/glibc/nptl/tst-tls5moda.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-tls5moda.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-tls5moda.c	(revision 2036)
@@ -0,0 +1,6 @@
+#include <tst-tls5.h>
+
+#ifdef TLS_REGISTER
+static __thread char a [32] __attribute__ ((aligned (64)));
+TLS_REGISTER (a)
+#endif
Index: trunk/src/libctests/glibc/nptl/tst-tls5modb.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-tls5modb.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-tls5modb.c	(revision 2036)
@@ -0,0 +1,6 @@
+#include <tst-tls5.h>
+
+#ifdef TLS_REGISTER
+static __thread int b;
+TLS_REGISTER (b)
+#endif
Index: trunk/src/libctests/glibc/nptl/tst-tls5modc.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-tls5modc.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-tls5modc.c	(revision 2036)
@@ -0,0 +1,6 @@
+#include <tst-tls5.h>
+
+#ifdef TLS_REGISTER
+static __thread int c;
+TLS_REGISTER (c)
+#endif
Index: trunk/src/libctests/glibc/nptl/tst-tls5modd.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-tls5modd.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-tls5modd.c	(revision 2036)
@@ -0,0 +1,6 @@
+#include <tst-tls5.h>
+
+#ifdef TLS_REGISTER
+static __thread int d;
+TLS_REGISTER (d)
+#endif
Index: trunk/src/libctests/glibc/nptl/tst-tls5mode.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-tls5mode.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-tls5mode.c	(revision 2036)
@@ -0,0 +1,8 @@
+#include <tst-tls5.h>
+
+#ifdef TLS_REGISTER
+static __thread int e1 = 24;
+static __thread char e2 [32] __attribute__ ((aligned (64)));
+TLS_REGISTER (e1)
+TLS_REGISTER (e2)
+#endif
Index: trunk/src/libctests/glibc/nptl/tst-tls5modf.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-tls5modf.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-tls5modf.c	(revision 2036)
@@ -0,0 +1,9 @@
+#include <tst-tls5.h>
+
+#ifdef TLS_REGISTER
+char tst_tls5modf[60] attribute_hidden = { 26 };
+static __thread int f1 = 24;
+static __thread char f2 [32] __attribute__ ((aligned (64)));
+TLS_REGISTER (f1)
+TLS_REGISTER (f2)
+#endif
Index: trunk/src/libctests/glibc/nptl/tst-tls6.sh
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-tls6.sh	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-tls6.sh	(revision 2036)
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+common_objpfx=$1; shift
+elf_objpfx=$1; shift
+rtld_installed_name=$1; shift
+logfile=$common_objpfx/nptl/tst-tls6.out
+
+# We have to find libc and nptl
+library_path=${common_objpfx}:${common_objpfx}nptl
+tst_tls5="${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+	  ${common_objpfx}/nptl/tst-tls5"
+
+LC_ALL=C
+export LC_ALL
+LANG=C
+export LANG
+
+> $logfile
+fail=0
+
+for aligned in a e f; do
+  echo "preload tst-tls5mod{$aligned,b,c,d}.so" >> $logfile
+  echo "===============" >> $logfile
+  LD_PRELOAD=`echo ${common_objpfx}nptl/tst-tls5mod{$aligned,b,c,d}.so \
+	      | sed 's/:$//;s/: /:/g'` ${tst_tls5} >> $logfile || fail=1
+  echo >> $logfile
+
+  echo "preload tst-tls5mod{b,$aligned,c,d}.so" >> $logfile
+  echo "===============" >> $logfile
+  LD_PRELOAD=`echo ${common_objpfx}nptl/tst-tls5mod{b,$aligned,c,d}.so \
+	      | sed 's/:$//;s/: /:/g'` ${tst_tls5} >> $logfile || fail=1
+  echo >> $logfile
+
+  echo "preload tst-tls5mod{b,c,d,$aligned}.so" >> $logfile
+  echo "===============" >> $logfile
+  LD_PRELOAD=`echo ${common_objpfx}nptl/tst-tls5mod{b,c,d,$aligned}.so \
+	      | sed 's/:$//;s/: /:/g'` ${tst_tls5} >> $logfile || fail=1
+  echo >> $logfile
+done
+
+echo "preload tst-tls5mod{d,a,b,c,e}" >> $logfile
+echo "===============" >> $logfile
+LD_PRELOAD=`echo ${common_objpfx}nptl/tst-tls5mod{d,a,b,c,e}.so \
+	    | sed 's/:$//;s/: /:/g'` ${tst_tls5} >> $logfile || fail=1
+echo >> $logfile
+
+echo "preload tst-tls5mod{d,a,b,e,f}" >> $logfile
+echo "===============" >> $logfile
+LD_PRELOAD=`echo ${common_objpfx}nptl/tst-tls5mod{d,a,b,e,f}.so \
+	    | sed 's/:$//;s/: /:/g'` ${tst_tls5} >> $logfile || fail=1
+echo >> $logfile
+
+exit $fail
Index: trunk/src/libctests/glibc/nptl/tst-tsd1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-tsd1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-tsd1.c	(revision 2036)
@@ -0,0 +1,118 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <string.h>
+
+
+static int
+do_test (void)
+{
+  pthread_key_t key1;
+  pthread_key_t key2;
+  void *value;
+  int result = 0;
+  int err;
+
+  err = pthread_key_create (&key1, NULL);
+  if (err != 0)
+    {
+      printf ("1st key_create failed: %s\n", strerror (err));
+      return 1;
+    }
+
+  /* Initial value must be NULL.  */
+  value = pthread_getspecific (key1);
+  if (value != NULL)
+    {
+      puts ("1st getspecific != NULL");
+      result = 1;
+    }
+
+  err = pthread_setspecific (key1, (void *) -2l);
+  if (err != 0)
+    {
+      printf ("1st setspecific failed: %s\n", strerror (err));
+      return 1;
+    }
+
+  value = pthread_getspecific (key1);
+  if (value == NULL)
+    {
+      puts ("2nd getspecific == NULL\n");
+      result = 1;
+    }
+  else if (value != (void *) -2l)
+    {
+      puts ("2nd getspecific != -2l\n");
+      result = 1;
+    }
+
+  err = pthread_setspecific (key1, (void *) -3l);
+  if (err != 0)
+    {
+      printf ("2nd setspecific failed: %s\n", strerror (err));
+      return 1;
+    }
+
+  value = pthread_getspecific (key1);
+  if (value == NULL)
+    {
+      puts ("3rd getspecific == NULL\n");
+      result = 1;
+    }
+  else if (value != (void *) -3l)
+    {
+      puts ("3rd getspecific != -2l\n");
+      result = 1;
+    }
+
+  err = pthread_key_delete (key1);
+  if (err != 0)
+    {
+      printf ("key_delete failed: %s\n", strerror (err));
+      result = 1;
+    }
+
+
+  err = pthread_key_create (&key2, NULL);
+  if (err != 0)
+    {
+      printf ("2nd key_create failed: %s\n", strerror (err));
+      return 1;
+    }
+
+  if (key1 != key2)
+    puts ("key1 != key2; no more tests performed");
+  else
+    {
+      value = pthread_getspecific (key2);
+      if (value != NULL)
+	{
+	  puts ("4th getspecific != NULL");
+	  result = 1;
+	}
+    }
+
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-tsd2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-tsd2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-tsd2.c	(revision 2036)
@@ -0,0 +1,97 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <string.h>
+
+
+static int result;
+
+
+static void
+destr (void *arg)
+{
+  if (arg != (void *) -2l)
+    result = 2;
+  else
+    result = 0;
+}
+
+
+static void *
+tf (void *arg)
+{
+  pthread_key_t key = (pthread_key_t) (long int) arg;
+  int err;
+
+  err = pthread_setspecific (key, (void *) -2l);
+  if (err != 0)
+    result = 3;
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  pthread_key_t key;
+  pthread_t th;
+  int err;
+
+  err = pthread_key_create (&key, destr);
+  if (err != 0)
+    {
+      printf ("key_create failed: %s\n", strerror (err));
+      return 1;
+    }
+
+  result = 1;
+
+  err = pthread_create (&th, NULL, tf, (void *) (long int) key);
+  if (err != 0)
+    {
+      printf ("create failed: %s\n", strerror (err));
+      return 1;
+    }
+
+  /* Wait for the thread to terminate.  */
+  err = pthread_join (th, NULL);
+  if (err != 0)
+    {
+      printf ("join failed: %s\n", strerror (err));
+      return 1;
+    }
+
+  if (result == 1)
+    puts ("destructor not called");
+  else if (result == 2)
+    puts ("destructor got passed a wrong value");
+  else if (result == 3)
+    puts ("setspecific in child failed");
+  else if (result != 0)
+    puts ("result != 0");
+
+  return result;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-tsd3.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-tsd3.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-tsd3.c	(revision 2036)
@@ -0,0 +1,129 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <limits.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static pthread_key_t key1;
+static pthread_key_t key2;
+
+
+static int left;
+
+
+static void
+destr1 (void *arg)
+{
+  if (--left > 0)
+    {
+      puts ("set key2");
+
+      if (pthread_setspecific (key2, (void *) 1l) != 0)
+	{
+	  puts ("destr1: setspecific failed");
+	  exit (1);
+	}
+    }
+}
+
+
+static void
+destr2 (void *arg)
+{
+  if (--left > 0)
+    {
+      puts ("set key1");
+
+      if (pthread_setspecific (key1, (void *) 1l) != 0)
+	{
+	  puts ("destr2: setspecific failed");
+	  exit (1);
+	}
+    }
+}
+
+
+static void *
+tf (void *arg)
+{
+  /* Let the destructors work.  */
+  left = 7;
+
+  if (pthread_setspecific (key1, (void *) 1l) != 0
+      || pthread_setspecific (key2, (void *) 1l) != 0)
+    {
+      puts ("tf: setspecific failed");
+      exit (1);
+    }
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  /* Allocate two keys, both with destructors.  */
+  if (pthread_key_create (&key1, destr1) != 0
+      || pthread_key_create (&key2, destr2) != 0)
+    {
+      puts ("key_create failed");
+      return 1;
+    }
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      return 1;
+    }
+
+  if (pthread_join (th, NULL) != 0)
+    {
+      puts ("join failed");
+      return 1;
+    }
+
+  if (left != 0)
+    {
+      printf ("left == %d\n", left);
+      return 1;
+    }
+
+  if (pthread_getspecific (key1) != NULL)
+    {
+      puts ("key1 data != NULL");
+      return 1;
+    }
+  if (pthread_getspecific (key2) != NULL)
+    {
+      puts ("key2 data != NULL");
+      return 1;
+    }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-tsd4.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-tsd4.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-tsd4.c	(revision 2036)
@@ -0,0 +1,103 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <limits.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static pthread_key_t key;
+
+
+static int rounds;
+
+
+static void
+destr (void *arg)
+{
+  ++rounds;
+
+  if (pthread_setspecific (key, (void *) 1l) != 0)
+    {
+      puts ("destr: setspecific failed");
+      exit (1);
+    }
+}
+
+
+static void *
+tf (void *arg)
+{
+  if (pthread_setspecific (key, (void *) 1l) != 0)
+    {
+      puts ("tf: setspecific failed");
+      exit (1);
+    }
+
+  return NULL;
+}
+
+
+/* This test check non-standard behavior.  The standard does not
+   require that the implementation has to stop calling TSD destructors
+   when they are set over and over again.  But NPTL does.  */
+static int
+do_test (void)
+{
+  /* Allocate two keys, both with destructors.  */
+  if (pthread_key_create (&key, destr) != 0)
+    {
+      puts ("key_create failed");
+      return 1;
+    }
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      return 1;
+    }
+
+  if (pthread_join (th, NULL) != 0)
+    {
+      puts ("join failed");
+      return 1;
+    }
+
+  if (rounds < PTHREAD_DESTRUCTOR_ITERATIONS)
+    {
+      printf ("rounds == %d, PTHREAD_DESTRUCTOR_ITERATIONS = %d\n",
+	      rounds, PTHREAD_DESTRUCTOR_ITERATIONS);
+      return 1;
+    }
+
+  if (pthread_getspecific (key) != NULL)
+    {
+      puts ("key data != NULL");
+      return 1;
+    }
+
+  return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-tsd5.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-tsd5.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-tsd5.c	(revision 2036)
@@ -0,0 +1,81 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
+
+
+static void
+cl (void *p)
+{
+  pthread_mutex_unlock (&m);
+}
+
+
+static void *
+tf (void *arg)
+{
+  if (pthread_mutex_lock (&m) != 0)
+    {
+      puts ("2nd mutex_lock failed");
+      exit (1);
+    }
+
+  exit (0);
+}
+
+
+static int
+do_test (void)
+{
+  pthread_key_t k;
+  if (pthread_key_create (&k, cl) != 0)
+    {
+      puts ("key_create failed");
+      return 1;
+    }
+  if (pthread_setspecific (k, (void *) 1) != 0)
+    {
+      puts ("setspecific failed");
+      return 1;
+    }
+
+  if (pthread_mutex_lock (&m) != 0)
+    {
+      puts ("1st mutex_lock failed");
+      return 1;
+    }
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      return 1;
+    }
+
+  pthread_exit (NULL);
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-umask1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-umask1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-umask1.c	(revision 2036)
@@ -0,0 +1,137 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <fcntl.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+
+static struct
+{
+  int (*fp) (const char *, mode_t);
+  const char *name;
+  bool is_fd;
+} fcts[] =
+{
+  { creat, "creat", true },
+  { mkdir, "mkdir", false },
+  { mkfifo, "mkfifo", false },
+};
+#define nfcts (sizeof (fcts) / sizeof (fcts[0]))
+
+
+static int
+work (const char *fname, int mask)
+{
+  int result = 0;
+  size_t i;
+  for (i = 0; i < nfcts; ++i)
+    {
+      remove (fname);
+      int fd = fcts[i].fp (fname, 0777);
+      if (fd == -1)
+	{
+	  printf ("cannot %s %s: %m\n", fcts[i].name, fname);
+	  exit (1);
+	}
+      if (fcts[i].is_fd)
+	close (fd);
+      struct stat64 st;
+      if (stat64 (fname, &st) == -1)
+	{
+	  printf ("cannot stat %s after %s: %m\n", fname, fcts[i].name);
+	  exit (1);
+	}
+
+      if ((st.st_mode & mask) != 0)
+	{
+	  printf ("mask not successful after %s: %x still set\n",
+	      	  fcts[i].name, (unsigned int) (st.st_mode & mask));
+	  result = 1;
+	}
+    }
+
+  return result;
+}
+
+
+static pthread_barrier_t bar;
+
+
+static void *
+tf (void *arg)
+{
+  pthread_barrier_wait (&bar);
+
+  int result = work (arg, 022);
+
+  pthread_barrier_wait (&bar);
+
+  pthread_barrier_wait (&bar);
+
+  return (work (arg, 0) | result) ? (void *) -1l : NULL;
+}
+
+
+static int
+do_test (const char *fname)
+{
+  int result = 0;
+
+  umask (0);
+  result |= work (fname, 0);
+
+  pthread_barrier_init (&bar, NULL, 2);
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, (void *) fname) != 0)
+    {
+      puts ("cannot create thread");
+      exit (1);
+    }
+
+  umask (022);
+  result |= work (fname, 022);
+
+  pthread_barrier_wait (&bar);
+
+  pthread_barrier_wait (&bar);
+
+  umask (0);
+
+  pthread_barrier_wait (&bar);
+
+  void *res;
+  if (pthread_join (th, &res) != 0)
+    {
+      puts ("join failed");
+      exit (1);
+    }
+
+  remove (fname);
+
+  return result || res != NULL;
+}
+
+#define TEST_FUNCTION do_test (argc < 2 ? "/tmp/tst-umask.tmp" : argv[1])
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-unload.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-unload.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-unload.c	(revision 2036)
@@ -0,0 +1,48 @@
+/* Tests for non-unloading of libpthread.
+   Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <gnu/lib-names.h>
+
+static int
+do_test (void)
+{
+  void *p = dlopen (LIBPTHREAD_SO, RTLD_LAZY);
+
+  if (p == NULL)
+    {
+      puts ("failed to load " LIBPTHREAD_SO);
+      return 1;
+    }
+
+  if (dlclose (p) != 0)
+    {
+      puts ("dlclose (" LIBPTHREAD_SO ") failed");
+      return 1;
+    }
+
+  puts ("seems to work");
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/nptl/tst-vfork1.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-vfork1.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-vfork1.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include <posix/tst-vfork1.c>
Index: trunk/src/libctests/glibc/nptl/tst-vfork1x.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-vfork1x.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-vfork1x.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include <posix/tst-vfork1.c>
Index: trunk/src/libctests/glibc/nptl/tst-vfork2.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-vfork2.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-vfork2.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include <posix/tst-vfork2.c>
Index: trunk/src/libctests/glibc/nptl/tst-vfork2x.c
===================================================================
--- trunk/src/libctests/glibc/nptl/tst-vfork2x.c	(revision 2036)
+++ trunk/src/libctests/glibc/nptl/tst-vfork2x.c	(revision 2036)
@@ -0,0 +1,1 @@
+#include <posix/tst-vfork2.c>
Index: trunk/src/libctests/glibc/nss/Makefile
===================================================================
--- trunk/src/libctests/glibc/nss/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/nss/Makefile	(revision 2036)
@@ -0,0 +1,85 @@
+# Copyright (C) 1996,1997,1998,2000,2001,2002 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Makefile for name service switch.
+#
+subdir	:= nss
+
+headers			:= nss.h
+distribute		:= nsswitch.h XXX-lookup.c getXXbyYY.c getXXbyYY_r.c \
+			   getXXent.c getXXent_r.c databases.def \
+			   nsswitch.conf digits_dots.c function.def
+
+# This is the trivial part which goes into libc itself.
+routines		= nsswitch getnssent getnssent_r digits_dots \
+			  $(addsuffix -lookup,$(databases))
+
+# These are the databases that go through nss dispatch.
+# Caution: if you add a database here, you must add its real name
+# in databases.def, too.
+databases		= proto service hosts network grp pwd rpc ethers \
+			  spwd netgrp key alias
+
+others                  := getent
+install-bin             := getent
+
+tests			= test-netdb
+xtests			= bug-erange
+
+include ../Makeconfig
+
+ifeq (yes,$(build-static-nss))
+otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
+	     $(resolvobjdir)/libresolv.a
+endif
+
+# Specify rules for the nss_* modules.  We have some services.
+services		:= files
+
+extra-libs		= $(services:%=libnss_%)
+# These libraries will be built in the `others' pass rather than
+# the `lib' pass, because they depend on libc.so being built already.
+extra-libs-others	= $(extra-libs)
+
+# The sources are found in the appropriate subdir.
+subdir-dirs = $(services:%=nss_%)
+vpath %.c $(subdir-dirs)
+
+
+libnss_files-routines	:= $(addprefix files-,$(databases))
+distribute		+= files-XXX.c files-parse.c
+
+
+# Build static module if requested
+ifneq ($(build-static-nss),yes)
+libnss_files-inhibit-o	= $(filter-out .os,$(object-suffixes))
+endif
+
+include ../Rules
+
+
+ifeq (yes,$(build-static-nss))
+$(objpfx)getent: $(objpfx)libnss_files.a
+endif
+
+# Depend on libc.so so a DT_NEEDED is generated in the shared objects.
+# This ensures they will load libc.so for needed symbols if loaded by
+# a statically-linked program that hasn't already loaded it.
+$(services:%=$(objpfx)libnss_%.so): $(common-objpfx)libc.so \
+				    $(common-objpfx)libc_nonshared.a
Index: trunk/src/libctests/glibc/nss/bug-erange.c
===================================================================
--- trunk/src/libctests/glibc/nss/bug-erange.c	(revision 2036)
+++ trunk/src/libctests/glibc/nss/bug-erange.c	(revision 2036)
@@ -0,0 +1,52 @@
+/* Test case for gethostbyname_r bug when buffer expansion required.  */
+
+#include <netdb.h>
+#include <arpa/inet.h>
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+int
+main (void)
+{
+  const char *host = "www.gnu.org";
+
+  /* This code approximates the example code in the library manual.  */
+
+  struct hostent hostbuf, *hp;
+  size_t hstbuflen;
+  char *tmphstbuf;
+  int res;
+  int herr;
+
+  hstbuflen = 16;		/* Make it way small to ensure ERANGE.  */
+  /* Allocate buffer, remember to free it to avoid memory leakage.  */
+  tmphstbuf = malloc (hstbuflen);
+
+  while ((res = gethostbyname_r (host, &hostbuf, tmphstbuf, hstbuflen,
+                                 &hp, &herr)) == ERANGE)
+    {
+      /* Enlarge the buffer.  */
+      hstbuflen *= 2;
+      tmphstbuf = realloc (tmphstbuf, hstbuflen);
+    }
+
+  if (res != 0 || hp == NULL)
+    {
+      printf ("gethostbyname_r failed: %s (errno: %m)\n", strerror (res));
+
+      if (access ("/etc/resolv.conf", R_OK))
+	{
+	  puts ("DNS probably not set up");
+	  return 0;
+	}
+
+      return 1;
+    }
+
+  printf ("Got: %s %s\n", hp->h_name,
+	  inet_ntoa (*(struct in_addr *) hp->h_addr));
+  return 0;
+}
Index: trunk/src/libctests/glibc/nss/test-netdb.c
===================================================================
--- trunk/src/libctests/glibc/nss/test-netdb.c	(revision 2036)
+++ trunk/src/libctests/glibc/nss/test-netdb.c	(revision 2036)
@@ -0,0 +1,379 @@
+/* Copyright (C) 1998,99,2000,01 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@suse.de>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/*
+  Testing of some network related lookup functions.
+  The system databases looked up are:
+  - /etc/services
+  - /etc/hosts
+  - /etc/networks
+  - /etc/protocols
+  - /etc/rpc
+  The tests try to be fairly generic and simple so that they work on
+  every possible setup (and might therefore not detect some possible
+  errors).
+*/
+
+#include <netdb.h>
+#include <rpc/netdb.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <unistd.h>
+#include <errno.h>
+#include "nss.h"
+
+/*
+  The following define is necessary for glibc 2.0.6
+*/
+#ifndef INET6_ADDRSTRLEN
+# define INET6_ADDRSTRLEN 46
+#endif
+
+int error_count;
+
+static void
+output_servent (const char *call, struct servent *sptr)
+{
+  char **pptr;
+
+  if (sptr == NULL)
+    printf ("Call: %s returned NULL\n", call);
+  else
+    {
+      printf ("Call: %s, returned: s_name: %s, s_port: %d, s_proto: %s\n",
+	      call, sptr->s_name, ntohs(sptr->s_port), sptr->s_proto);
+      for (pptr = sptr->s_aliases; *pptr != NULL; pptr++)
+	printf ("  alias: %s\n", *pptr);
+    }
+}
+
+
+static void
+test_services (void)
+{
+  struct servent *sptr;
+
+  sptr = getservbyname ("domain", "tcp");
+  output_servent ("getservbyname (\"domain\", \"tcp\")", sptr);
+
+  sptr = getservbyname ("domain", "udp");
+  output_servent ("getservbyname (\"domain\", \"udp\")", sptr);
+
+  sptr = getservbyname ("domain", NULL);
+  output_servent ("getservbyname (\"domain\", NULL)", sptr);
+
+  sptr = getservbyname ("not-existant", NULL);
+  output_servent ("getservbyname (\"not-existant\", NULL)", sptr);
+
+  /* This shouldn't return anything.  */
+  sptr = getservbyname ("", "");
+  output_servent ("getservbyname (\"\", \"\")", sptr);
+
+  sptr = getservbyname ("", "tcp");
+  output_servent ("getservbyname (\"\", \"tcp\")", sptr);
+
+  sptr = getservbyport (htons(53), "tcp");
+  output_servent ("getservbyport (htons(53), \"tcp\")", sptr);
+
+  sptr = getservbyport (htons(53), NULL);
+  output_servent ("getservbyport (htons(53), NULL)", sptr);
+
+  sptr = getservbyport (htons(1), "udp"); /* shouldn't exist */
+  output_servent ("getservbyport (htons(1), \"udp\")", sptr);
+
+  setservent (0);
+  do
+    {
+      sptr = getservent ();
+      output_servent ("getservent ()", sptr);
+    }
+  while (sptr != NULL);
+  endservent ();
+}
+
+
+static void
+output_hostent (const char *call, struct hostent *hptr)
+{
+  char **pptr;
+  char buf[INET6_ADDRSTRLEN];
+
+  if (hptr == NULL)
+    printf ("Call: %s returned NULL\n", call);
+  else
+    {
+      printf ("Call: %s returned: name: %s, addr_type: %d\n",
+	      call, hptr->h_name, hptr->h_addrtype);
+      if (hptr->h_aliases)
+	for (pptr = hptr->h_aliases; *pptr != NULL; pptr++)
+	  printf ("  alias: %s\n", *pptr);
+
+      for (pptr = hptr->h_addr_list; *pptr != NULL; pptr++)
+	printf ("  ip: %s\n",
+		inet_ntop (hptr->h_addrtype, *pptr, buf, sizeof (buf)));
+    }
+}
+
+static void
+test_hosts (void)
+{
+  struct hostent *hptr1, *hptr2;
+  char *name = NULL;
+  size_t namelen = 0;
+  struct in_addr ip;
+
+  hptr1 = gethostbyname ("localhost");
+  hptr2 = gethostbyname ("LocalHost");
+  if (hptr1 != NULL || hptr2 != NULL)
+    {
+      if (hptr1 == NULL)
+	{
+	  printf ("localhost not found - but LocalHost found:-(\n");
+	  ++error_count;
+	}
+      else if (hptr2 == NULL)
+	{
+	  printf ("LocalHost not found - but localhost found:-(\n");
+	  ++error_count;
+	}
+      else if (strcmp (hptr1->h_name, hptr2->h_name) != 0)
+	{
+	  printf ("localhost and LocalHost have different canoncial name\n");
+	  printf ("gethostbyname (\"localhost\")->%s\n", hptr1->h_name);
+	  printf ("gethostbyname (\"LocalHost\")->%s\n", hptr2->h_name);
+	  ++error_count;
+	}
+      else
+	output_hostent ("gethostbyname(\"localhost\")", hptr1);
+    }
+
+  hptr1 = gethostbyname ("127.0.0.1");
+  output_hostent ("gethostbyname (\"127.0.0.1\")", hptr1);
+
+  hptr1 = gethostbyname ("10.1234");
+  output_hostent ("gethostbyname (\"10.1234\")", hptr1);
+
+  hptr1 = gethostbyname2 ("localhost", AF_INET);
+  output_hostent ("gethostbyname2 (\"localhost\", AF_INET)", hptr1);
+
+  while (gethostname (name, namelen) < 0 && errno == ENAMETOOLONG)
+    {
+      namelen += 2;		/* tiny increments to test a lot */
+      name = realloc (name, namelen);
+    }
+  if (gethostname (name, namelen) == 0)
+    {
+      printf ("Hostname: %s\n", name);
+      if (name != NULL)
+	{
+	  hptr1 = gethostbyname (name);
+	  output_hostent ("gethostbyname (gethostname(...))", hptr1);
+	}
+    }
+
+  ip.s_addr = htonl (INADDR_LOOPBACK);
+  hptr1 = gethostbyaddr ((char *) &ip, sizeof(ip), AF_INET);
+  if (hptr1 != NULL)
+    {
+      printf ("official name of 127.0.0.1: %s\n", hptr1->h_name);
+    }
+
+  sethostent (0);
+  do
+    {
+      hptr1 = gethostent ();
+      output_hostent ("gethostent ()", hptr1);
+    }
+  while (hptr1 != NULL);
+  endhostent ();
+
+}
+
+
+static void
+output_netent (const char *call, struct netent *nptr)
+{
+  char **pptr;
+
+  if (nptr == NULL)
+    printf ("Call: %s returned NULL\n", call);
+  else
+    {
+      struct in_addr ip;
+
+      ip.s_addr = htonl(nptr->n_net);
+      printf ("Call: %s, returned: n_name: %s, network_number: %s\n",
+	      call, nptr->n_name, inet_ntoa (ip));
+
+      for (pptr = nptr->n_aliases; *pptr != NULL; pptr++)
+	printf ("  alias: %s\n", *pptr);
+    }
+}
+
+static void
+test_network (void)
+{
+  struct netent *nptr;
+  u_int32_t ip;
+
+  /*
+     This test needs the following line in /etc/networks:
+     loopback        127.0.0.0
+  */
+  nptr = getnetbyname ("loopback");
+  output_netent ("getnetbyname (\"loopback\")",nptr);
+
+  nptr = getnetbyname ("LoopBACK");
+  output_netent ("getnetbyname (\"LoopBACK\")",nptr);
+
+  ip = inet_network ("127.0.0.0");
+  nptr = getnetbyaddr (ip, AF_INET);
+  output_netent ("getnetbyaddr (inet_network (\"127.0.0.0\"), AF_INET)",nptr);
+
+  setnetent (0);
+  do
+    {
+      nptr = getnetent ();
+      output_netent ("getnetent ()", nptr);
+    }
+  while (nptr != NULL);
+  endnetent ();
+}
+
+
+static void
+output_protoent (const char *call, struct protoent *prptr)
+{
+  char **pptr;
+
+  if (prptr == NULL)
+    printf ("Call: %s returned NULL\n", call);
+  else
+    {
+      printf ("Call: %s, returned: p_name: %s, p_proto: %d\n",
+	      call, prptr->p_name, prptr->p_proto);
+      for (pptr = prptr->p_aliases; *pptr != NULL; pptr++)
+	printf ("  alias: %s\n", *pptr);
+    }
+}
+
+
+static void
+test_protocols (void)
+{
+  struct protoent *prptr;
+
+  prptr = getprotobyname ("IP");
+  output_protoent ("getprotobyname (\"IP\")", prptr);
+
+  prptr = getprotobynumber (1);
+  output_protoent ("getprotobynumber (1)", prptr);
+
+  setprotoent (0);
+  do
+    {
+      prptr = getprotoent ();
+      output_protoent ("getprotoent ()", prptr);
+    }
+  while (prptr != NULL);
+  endprotoent ();
+}
+
+
+static void
+output_rpcent (const char *call, struct rpcent *rptr)
+{
+  char **pptr;
+
+  if (rptr == NULL)
+    printf ("Call: %s returned NULL\n", call);
+  else
+    {
+      printf ("Call: %s, returned: r_name: %s, r_number: %d\n",
+		call, rptr->r_name, rptr->r_number);
+      for (pptr = rptr->r_aliases; *pptr != NULL; pptr++)
+	printf ("  alias: %s\n", *pptr);
+    }
+}
+
+static void
+test_rpc (void)
+{
+  struct rpcent *rptr;
+
+  rptr = getrpcbyname ("portmap");
+  output_rpcent ("getrpcyname (\"portmap\")", rptr);
+
+  rptr = getrpcbynumber (100000);
+  output_rpcent ("getrpcbynumber (100000)", rptr);
+
+  setrpcent (0);
+  do
+    {
+      rptr = getrpcent ();
+      output_rpcent ("getrpcent ()", rptr);
+    }
+  while (rptr != NULL);
+  endrpcent ();
+}
+
+/* Override /etc/nsswitch.conf for this program.  This is mainly
+   useful for developers. */
+static void  __attribute__ ((unused))
+setdb (const char *dbname)
+{
+  if (strcmp ("db", dbname))
+      {
+	/*
+	  db is not implemented for hosts, networks
+	*/
+	__nss_configure_lookup ("hosts", dbname);
+	__nss_configure_lookup ("networks", dbname);
+      }
+  __nss_configure_lookup ("protocols", dbname);
+  __nss_configure_lookup ("rpc", dbname);
+  __nss_configure_lookup ("services", dbname);
+}
+
+
+int
+main (void)
+{
+  /*
+    setdb ("db");
+  */
+
+  test_hosts ();
+  test_network ();
+  test_protocols ();
+  test_rpc ();
+  test_services ();
+
+  if (error_count)
+    printf ("\n %d errors occurred!\n", error_count);
+  else
+    printf ("No visible errors occurred!\n");
+
+  return (error_count != 0);
+}
Index: trunk/src/libctests/glibc/posix/BOOST.tests
===================================================================
--- trunk/src/libctests/glibc/posix/BOOST.tests	(revision 2036)
+++ trunk/src/libctests/glibc/posix/BOOST.tests	(revision 2036)
@@ -0,0 +1,829 @@
+; 
+; 
+; this file contains a script of tests to run through regress.exe
+;
+; comments start with a semicolon and proceed to the end of the line
+;
+; changes to regular expression compile flags start with a "-" as the first
+; non-whitespace character and consist of a list of the printable names
+; of the flags, for example "match_default"
+;
+; Other lines contain a test to perform using the current flag status
+; the first token contains the expression to compile, the second the string
+; to match it against. If the second string is "!" then the expression should
+; not compile, that is the first string is an invalid regular expression.
+; This is then followed by a list of integers that specify what should match,
+; each pair represents the starting and ending positions of a subexpression
+; starting with the zeroth subexpression (the whole match).
+; A value of -1 indicates that the subexpression should not take part in the
+; match at all, if the first value is -1 then no part of the expression should
+; match the string.
+;
+; Tests taken from BOOST testsuite and adapted to glibc regex.
+;
+; Boost Software License - Version 1.0 - August 17th, 2003
+;
+; Permission is hereby granted, free of charge, to any person or organization
+; obtaining a copy of the software and accompanying documentation covered by
+; this license (the "Software") to use, reproduce, display, distribute,
+; execute, and transmit the Software, and to prepare derivative works of the
+; Software, and to permit third-parties to whom the Software is furnished to
+; do so, all subject to the following:
+;
+; The copyright notices in the Software and this entire statement, including
+; the above license grant, this restriction and the following disclaimer,
+; must be included in all copies of the Software, in whole or in part, and
+; all derivative works of the Software, unless such copies or derivative
+; works are solely in the form of machine-executable object code generated by
+; a source language processor.
+;
+; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+; FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+; SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+; FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+; ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+; DEALINGS IN THE SOFTWARE.
+;
+
+- match_default normal REG_EXTENDED
+
+;
+; try some really simple literals:
+a a 0 1
+Z Z 0 1
+Z aaa -1 -1
+Z xxxxZZxxx 4 5
+
+; and some simple brackets:
+(a) zzzaazz 3 4 3 4
+() zzz 0 0 0 0
+() "" 0 0 0 0
+( !
+) ) 0 1
+(aa !
+aa) baa)b 1 4
+a b -1 -1
+\(\) () 0 2
+\(a\) (a) 0 3
+\() () 0 2
+(\) !
+p(a)rameter ABCparameterXYZ 3 12 4 5
+[pq](a)rameter ABCparameterXYZ 3 12 4 5
+
+; now try escaped brackets:
+- match_default bk_parens REG_BASIC
+\(a\) zzzaazz 3 4 3 4
+\(\) zzz 0 0 0 0
+\(\) "" 0 0 0 0
+\( !
+\) !
+\(aa !
+aa\) !
+() () 0 2
+(a) (a) 0 3
+(\) !
+\() !
+
+; now move on to "." wildcards
+- match_default normal REG_EXTENDED REG_STARTEND
+. a 0 1
+. \n 0 1
+. \r 0 1
+. \0 0 1
+
+;
+; now move on to the repetion ops,
+; starting with operator *
+- match_default normal REG_EXTENDED
+a* b 0 0
+ab* a 0 1
+ab* ab 0 2
+ab* sssabbbbbbsss 3 10
+ab*c* a 0 1
+ab*c* abbb 0 4
+ab*c* accc 0 4
+ab*c* abbcc 0 5
+*a !
+\<* !
+\>* !
+\n* \n\n 0 2
+\** ** 0 2
+\* * 0 1
+
+; now try operator +
+ab+ a -1 -1
+ab+ ab 0 2
+ab+ sssabbbbbbsss 3 10
+ab+c+ a -1 -1
+ab+c+ abbb -1 -1
+ab+c+ accc -1 -1
+ab+c+ abbcc 0 5
++a !
+\<+ !
+\>+ !
+\n+ \n\n 0 2
+\+ + 0 1
+\+ ++ 0 1
+\++ ++ 0 2
+
+; now try operator ?
+- match_default normal REG_EXTENDED
+a? b 0 0
+ab? a 0 1
+ab? ab 0 2
+ab? sssabbbbbbsss 3 5
+ab?c? a 0 1
+ab?c? abbb 0 2
+ab?c? accc 0 2
+ab?c? abcc 0 3
+?a !
+\<? !
+\>? !
+\n? \n\n 0 1
+\? ? 0 1
+\? ?? 0 1
+\?? ?? 0 1
+
+; now try operator {}
+- match_default normal REG_EXTENDED
+a{2} a -1 -1
+a{2} aa 0 2
+a{2} aaa 0 2
+a{2,} a -1 -1
+a{2,} aa 0 2
+a{2,} aaaaa 0 5
+a{2,4} a -1 -1
+a{2,4} aa 0 2
+a{2,4} aaa 0 3
+a{2,4} aaaa 0 4
+a{2,4} aaaaa 0 4
+a{} !
+a{2 !
+a} a} 0 2
+\{\} {} 0 2
+
+- match_default normal REG_BASIC
+a\{2\} a -1 -1
+a\{2\} aa 0 2
+a\{2\} aaa 0 2
+a\{2,\} a -1 -1
+a\{2,\} aa 0 2
+a\{2,\} aaaaa 0 5
+a\{2,4\} a -1 -1
+a\{2,4\} aa 0 2
+a\{2,4\} aaa 0 3
+a\{2,4\} aaaa 0 4
+a\{2,4\} aaaaa 0 4
+{} {} 0 2
+
+; now test the alternation operator |
+- match_default normal REG_EXTENDED
+a|b a 0 1
+a|b b 0 1
+a(b|c) ab 0 2 1 2
+a(b|c) ac 0 2 1 2
+a(b|c) ad -1 -1 -1 -1
+a\| a| 0 2
+
+; now test the set operator []
+- match_default normal REG_EXTENDED
+; try some literals first
+[abc] a 0 1
+[abc] b 0 1
+[abc] c 0 1
+[abc] d -1 -1
+[^bcd] a 0 1
+[^bcd] b -1 -1
+[^bcd] d -1 -1
+[^bcd] e 0 1
+a[b]c abc 0 3
+a[ab]c abc 0 3
+a[^ab]c adc 0 3
+a[]b]c a]c 0 3
+a[[b]c a[c 0 3
+a[-b]c a-c 0 3
+a[^]b]c adc 0 3
+a[^-b]c adc 0 3
+a[b-]c a-c 0 3
+a[b !
+a[] !
+
+; then some ranges
+[b-e] a -1 -1
+[b-e] b 0 1
+[b-e] e 0 1
+[b-e] f -1 -1
+[^b-e] a 0 1
+[^b-e] b -1 -1
+[^b-e] e -1 -1
+[^b-e] f 0 1
+a[1-3]c a2c 0 3
+a[3-1]c !
+a[1-3-5]c !
+a[1- !
+
+; and some classes
+a[[:alpha:]]c abc 0 3
+a[[:unknown:]]c !
+a[[: !
+a[[:alpha !
+a[[:alpha:] !
+a[[:alpha,:] !
+a[[:]:]]b !
+a[[:-:]]b !
+a[[:alph:]] !
+a[[:alphabet:]] !
+[[:alnum:]]+ -%@a0X_- 3 6
+[[:alpha:]]+ -%@aX_0- 3 5
+[[:blank:]]+ "a  \tb" 1 4
+[[:cntrl:]]+ a\n\tb 1 3
+[[:digit:]]+ a019b 1 4
+[[:graph:]]+ " a%b " 1 4
+[[:lower:]]+ AabC 1 3
+; This test fails with STLPort, disable for now as this is a corner case anyway...
+;[[:print:]]+ "\na b\n" 1 4
+[[:punct:]]+ " %-&\t" 1 4
+[[:space:]]+ "a \n\t\rb" 1 5
+[[:upper:]]+ aBCd 1 3
+[[:xdigit:]]+ p0f3Cx 1 5
+
+; now test flag settings:
+- escape_in_lists REG_NO_POSIX_TEST
+[\n] \n 0 1
+- REG_NO_POSIX_TEST
+
+; line anchors
+- match_default normal REG_EXTENDED
+^ab ab 0 2
+^ab xxabxx -1 -1
+ab$ ab 0 2
+ab$ abxx -1 -1
+- match_default match_not_bol match_not_eol normal REG_EXTENDED REG_NOTBOL REG_NOTEOL
+^ab ab -1 -1
+^ab xxabxx -1 -1
+ab$ ab -1 -1
+ab$ abxx -1 -1
+
+; back references
+- match_default normal REG_PERL
+a(b)\2c	!
+a(b\1)c	!
+a(b*)c\1d abbcbbd 0 7 1 3
+a(b*)c\1d abbcbd -1 -1
+a(b*)c\1d abbcbbbd -1 -1
+^(.)\1 abc -1 -1
+a([bc])\1d abcdabbd	4 8 5 6
+; strictly speaking this is at best ambiguous, at worst wrong, this is what most
+; re implimentations will match though.
+a(([bc])\2)*d abbccd 0 6 3 5 3 4
+
+a(([bc])\2)*d abbcbd -1 -1
+a((b)*\2)*d abbbd 0 5 1 4 2 3
+; perl only:
+(ab*)[ab]*\1 ababaaa 0 7 0 1
+(a)\1bcd aabcd 0 5 0 1
+(a)\1bc*d aabcd 0 5 0 1
+(a)\1bc*d aabd 0 4 0 1
+(a)\1bc*d aabcccd 0 7 0 1
+(a)\1bc*[ce]d aabcccd 0 7 0 1
+^(a)\1b(c)*cd$ aabcccd 0 7 0 1 4 5
+
+; posix only: 
+- match_default extended REG_EXTENDED
+(ab*)[ab]*\1 ababaaa 0 7 0 1
+
+;
+; word operators:
+\w a 0 1
+\w z 0 1
+\w A 0 1
+\w Z 0 1
+\w _ 0 1
+\w } -1 -1
+\w ` -1 -1
+\w [ -1 -1
+\w @ -1 -1
+; non-word:
+\W a -1 -1
+\W z -1 -1
+\W A -1 -1
+\W Z -1 -1
+\W _ -1 -1
+\W } 0 1
+\W ` 0 1
+\W [ 0 1
+\W @ 0 1
+; word start:
+\<abcd "  abcd" 2 6
+\<ab cab -1 -1
+\<ab "\nab" 1 3
+\<tag ::tag 2 5
+;word end:
+abc\> abc 0 3
+abc\> abcd -1 -1
+abc\> abc\n 0 3
+abc\> abc:: 0 3
+; word boundary:
+\babcd "  abcd" 2 6
+\bab cab -1 -1
+\bab "\nab" 1 3
+\btag ::tag 2 5
+abc\b abc 0 3
+abc\b abcd -1 -1
+abc\b abc\n 0 3
+abc\b abc:: 0 3
+; within word:
+\B ab 1 1
+a\Bb ab 0 2
+a\B ab 0 1
+a\B a -1 -1
+a\B "a " -1 -1
+
+;
+; buffer operators:
+\`abc abc 0 3
+\`abc \nabc -1 -1
+\`abc " abc" -1 -1
+abc\' abc 0 3
+abc\' abc\n -1 -1
+abc\' "abc " -1 -1
+
+;
+; now follows various complex expressions designed to try and bust the matcher:
+a(((b)))c abc 0 3 1 2 1 2 1 2
+a(b|(c))d abd 0 3 1 2 -1 -1
+a(b|(c))d acd 0 3 1 2 1 2
+a(b*|c)d abbd 0 4 1 3
+; just gotta have one DFA-buster, of course
+a[ab]{20} aaaaabaaaabaaaabaaaab 0 21
+; and an inline expansion in case somebody gets tricky
+a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab] aaaaabaaaabaaaabaaaab 0 21
+; and in case somebody just slips in an NFA...
+a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab](wee|week)(knights|night) aaaaabaaaabaaaabaaaabweeknights 0 31 21 24 24 31
+; one really big one
+1234567890123456789012345678901234567890123456789012345678901234567890 a1234567890123456789012345678901234567890123456789012345678901234567890b 1 71
+; fish for problems as brackets go past 8
+[ab][cd][ef][gh][ij][kl][mn] xacegikmoq 1 8
+[ab][cd][ef][gh][ij][kl][mn][op] xacegikmoq 1 9
+[ab][cd][ef][gh][ij][kl][mn][op][qr] xacegikmoqy 1 10
+[ab][cd][ef][gh][ij][kl][mn][op][q] xacegikmoqy 1 10
+; and as parenthesis go past 9:
+(a)(b)(c)(d)(e)(f)(g)(h) zabcdefghi 1 9 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9
+(a)(b)(c)(d)(e)(f)(g)(h)(i) zabcdefghij 1 10 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10
+(a)(b)(c)(d)(e)(f)(g)(h)(i)(j) zabcdefghijk 1 11 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11
+(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k) zabcdefghijkl 1 12 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12
+(a)d|(b)c abc 1 3 -1 -1 1 2
+_+((www)|(ftp)|(mailto)):_* "_wwwnocolon _mailto:" 12 20 13 19 -1 -1 -1 -1 13 19
+
+; subtleties of matching
+;a(b)?c\1d acd 0 3 -1 -1
+; POSIX is about the following test:
+a(b)?c\1d acd -1 -1 -1 -1
+a(b?c)+d accd 0 4 2 3
+(wee|week)(knights|night) weeknights 0 10 0 3 3 10
+.* abc 0 3
+a(b|(c))d abd 0 3 1 2 -1 -1
+a(b|(c))d acd 0 3 1 2 1 2
+a(b*|c|e)d abbd 0 4 1 3
+a(b*|c|e)d acd 0 3 1 2
+a(b*|c|e)d ad 0 2 1 1
+a(b?)c abc 0 3 1 2
+a(b?)c ac 0 2 1 1
+a(b+)c abc 0 3 1 2
+a(b+)c abbbc 0 5 1 4 
+a(b*)c ac 0 2 1 1 
+(a|ab)(bc([de]+)f|cde) abcdef 0 6 0 1 1 6 3 5
+a([bc]?)c abc 0 3 1 2
+a([bc]?)c ac 0 2 1 1 
+a([bc]+)c abc 0 3 1 2
+a([bc]+)c abcc 0 4 1 3
+a([bc]+)bc abcbc 0 5 1 3
+a(bb+|b)b abb 0 3 1 2
+a(bbb+|bb+|b)b abb 0 3 1 2
+a(bbb+|bb+|b)b abbb 0 4 1 3
+a(bbb+|bb+|b)bb abbb 0 4 1 2
+(.*).* abcdef 0 6 0 6
+(a*)* bc 0 0 0 0
+xyx*xz xyxxxxyxxxz 5 11
+
+; do we get the right subexpression when it is used more than once?
+a(b|c)*d ad 0 2 -1 -1
+a(b|c)*d abcd 0 4 2 3
+a(b|c)+d abd 0 3 1 2
+a(b|c)+d abcd 0 4 2 3
+a(b|c?)+d ad 0 2 1 1
+a(b|c){0,0}d ad 0 2 -1 -1
+a(b|c){0,1}d ad 0 2 -1 -1
+a(b|c){0,1}d abd 0 3 1 2
+a(b|c){0,2}d ad 0 2 -1 -1
+a(b|c){0,2}d abcd 0 4 2 3
+a(b|c){0,}d ad 0 2 -1 -1
+a(b|c){0,}d abcd 0 4 2 3
+a(b|c){1,1}d abd 0 3 1 2
+a(b|c){1,2}d abd 0 3 1 2
+a(b|c){1,2}d abcd 0 4 2 3
+a(b|c){1,}d abd 0 3 1 2
+a(b|c){1,}d abcd 0 4 2 3
+a(b|c){2,2}d acbd 0 4 2 3
+a(b|c){2,2}d abcd 0 4 2 3
+a(b|c){2,4}d abcd 0 4 2 3
+a(b|c){2,4}d abcbd 0 5 3 4
+a(b|c){2,4}d abcbcd 0 6 4 5
+a(b|c){2,}d abcd 0 4 2 3
+a(b|c){2,}d abcbd 0 5 3 4
+; perl only: these conflict with the POSIX test below
+;a(b|c?)+d abcd 0 4 3 3
+;a(b+|((c)*))+d abd 0 3 2 2 2 2 -1 -1
+;a(b+|((c)*))+d abcd 0 4 3 3 3 3 2 3
+
+; posix only:
+- match_default extended REG_EXTENDED REG_STARTEND
+
+a(b|c?)+d abcd 0 4 2 3
+a(b|((c)*))+d abcd 0 4 2 3 2 3 2 3
+a(b+|((c)*))+d abd 0 3 1 2 -1 -1 -1 -1
+a(b+|((c)*))+d abcd 0 4 2 3 2 3 2 3
+a(b|((c)*))+d ad 0 2 1 1 1 1 -1 -1
+a(b|((c)*))*d abcd 0 4 2 3 2 3 2 3
+a(b+|((c)*))*d abd 0 3 1 2 -1 -1 -1 -1
+a(b+|((c)*))*d abcd 0 4 2 3 2 3 2 3
+a(b|((c)*))*d ad 0 2 1 1 1 1 -1 -1
+
+- match_default normal REG_PERL
+; try to match C++ syntax elements:
+; line comment:
+//[^\n]* "++i //here is a line comment\n" 4 28
+; block comment:
+/\*([^*]|\*+[^*/])*\*+/ "/* here is a block comment */" 0 29 26 27
+/\*([^*]|\*+[^*/])*\*+/ "/**/" 0 4 -1 -1
+/\*([^*]|\*+[^*/])*\*+/ "/***/" 0 5 -1 -1
+/\*([^*]|\*+[^*/])*\*+/ "/****/" 0 6 -1 -1
+/\*([^*]|\*+[^*/])*\*+/ "/*****/" 0 7 -1 -1
+/\*([^*]|\*+[^*/])*\*+/ "/*****/*/" 0 7 -1 -1
+; preprossor directives:
+^[[:blank:]]*#([^\n]*\\[[:space:]]+)*[^\n]* "#define some_symbol" 0 19 -1 -1
+^[[:blank:]]*#([^\n]*\\[[:space:]]+)*[^\n]* "#define some_symbol(x) #x" 0 25 -1 -1
+; perl only:
+^[[:blank:]]*#([^\n]*\\[[:space:]]+)*[^\n]* "#define some_symbol(x) \\  \r\n  foo();\\\r\n   printf(#x);" 0 53 30 42
+; literals:
+((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)? 0xFF         						0 4		0 4		0 4 	-1 -1 	-1 -1 	-1 -1 	-1 -1
+((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)? 35 									0 2 	0 2		-1 -1 	0 2 	-1 -1 	-1 -1 	-1 -1
+((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)? 0xFFu 								0 5		0 4		0 4 	-1 -1 	-1 -1 	-1 -1 	-1 -1
+((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)? 0xFFL 								0 5		0 4		0 4 	-1 -1 	4 5 	-1 -1 	-1 -1
+((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)? 0xFFFFFFFFFFFFFFFFuint64 			0 24	0 18	0 18 	-1 -1 	19 24 	19 24 	22 24
+; strings:
+'([^\\']|\\.)*' '\\x3A' 0 6 4 5
+'([^\\']|\\.)*' '\\'' 0 4 1 3
+'([^\\']|\\.)*' '\\n' 0 4 1 3
+
+; finally try some case insensitive matches:
+- match_default normal REG_EXTENDED REG_ICASE
+; upper and lower have no meaning here so they fail, however these
+; may compile with other libraries...
+;[[:lower:]] !
+;[[:upper:]] !
+0123456789@abcdefghijklmnopqrstuvwxyz\[\\\]\^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ\{\|\} 0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]\^_`abcdefghijklmnopqrstuvwxyz\{\|\} 0 72
+
+; known and suspected bugs:
+- match_default normal REG_EXTENDED
+\( ( 0 1
+\) ) 0 1
+\$ $ 0 1
+\^ ^ 0 1
+\. . 0 1
+\* * 0 1
+\+ + 0 1
+\? ? 0 1
+\[ [ 0 1
+\] ] 0 1
+\| | 0 1
+\\ \\ 0 1
+# # 0 1
+\# # 0 1
+a- a- 0 2
+\- - 0 1
+\{ { 0 1
+\} } 0 1
+0 0 0 1
+1 1 0 1
+9 9 0 1
+b b 0 1
+B B 0 1
+< < 0 1
+> > 0 1
+w w 0 1
+W W 0 1
+` ` 0 1
+' ' 0 1
+\n \n 0 1
+, , 0 1
+a a 0 1
+f f 0 1
+n n 0 1
+r r 0 1
+t t 0 1
+v v 0 1
+c c 0 1
+x x 0 1
+: : 0 1
+(\.[[:alnum:]]+){2} "w.a.b " 1 5 3 5
+
+- match_default normal REG_EXTENDED REG_ICASE
+a A 0 1
+A a 0 1
+[abc]+ abcABC 0 6
+[ABC]+ abcABC 0 6
+[a-z]+ abcABC 0 6
+[A-Z]+ abzANZ 0 6
+[a-Z]+ abzABZ 0 6
+[A-z]+ abzABZ 0 6
+[[:lower:]]+ abyzABYZ 0 8
+[[:upper:]]+ abzABZ 0 6
+[[:alpha:]]+ abyzABYZ 0 8
+[[:alnum:]]+ 09abyzABYZ 0 10
+
+; word start:
+\<abcd "  abcd" 2 6
+\<ab cab -1 -1
+\<ab "\nab" 1 3
+\<tag ::tag 2 5
+;word end:
+abc\> abc 0 3
+abc\> abcd -1 -1
+abc\> abc\n 0 3
+abc\> abc:: 0 3
+
+; collating elements and rewritten set code:
+- match_default normal REG_EXTENDED REG_STARTEND
+;[[.zero.]] 0 0 1
+;[[.one.]] 1 0 1
+;[[.two.]] 2 0 1
+;[[.three.]] 3 0 1
+[[.a.]] baa 1 2
+;[[.right-curly-bracket.]] } 0 1
+;[[.NUL.]] \0 0 1
+[[:<:]z] !
+[a[:>:]] !
+[[=a=]] a 0 1
+;[[=right-curly-bracket=]] } 0 1
+- match_default normal REG_EXTENDED REG_STARTEND REG_ICASE
+[[.A.]] A 0 1
+[[.A.]] a 0 1
+[[.A.]-b]+ AaBb 0 4
+[A-[.b.]]+ AaBb 0 4
+[[.a.]-B]+ AaBb 0 4
+[a-[.B.]]+ AaBb 0 4
+- match_default normal REG_EXTENDED REG_STARTEND
+[[.a.]-c]+ abcd 0 3
+[a-[.c.]]+ abcd 0 3
+[[:alpha:]-a] !
+[a-[:alpha:]] !
+
+; try mutli-character ligatures:
+;[[.ae.]] ae 0 2
+;[[.ae.]] aE -1 -1
+;[[.AE.]] AE 0 2
+;[[.Ae.]] Ae 0 2
+;[[.ae.]-b] a -1 -1
+;[[.ae.]-b] b 0 1
+;[[.ae.]-b] ae 0 2
+;[a-[.ae.]] a 0 1
+;[a-[.ae.]] b -1 -1
+;[a-[.ae.]] ae 0 2
+- match_default normal REG_EXTENDED REG_STARTEND REG_ICASE
+;[[.ae.]] AE 0 2
+;[[.ae.]] Ae 0 2
+;[[.AE.]] Ae 0 2
+;[[.Ae.]] aE 0 2
+;[[.AE.]-B] a -1 -1
+;[[.Ae.]-b] b 0 1
+;[[.Ae.]-b] B 0 1
+;[[.ae.]-b] AE 0 2
+
+- match_default normal REG_EXTENDED REG_STARTEND REG_NO_POSIX_TEST
+\s+ "ab   ab" 2 5
+\S+ "  abc  " 2 5
+
+- match_default normal REG_EXTENDED REG_STARTEND
+\`abc abc 0 3
+\`abc aabc -1 -1
+abc\' abc 0 3
+abc\' abcd -1 -1
+abc\' abc\n\n -1 -1
+abc\' abc 0 3
+
+; extended repeat checking to exercise new algorithms:
+ab.*xy abxy_ 0 4
+ab.*xy ab_xy_ 0 5
+ab.*xy abxy 0 4
+ab.*xy ab_xy 0 5
+ab.* ab 0 2
+ab.* ab__ 0 4
+
+ab.{2,5}xy ab__xy_ 0 6
+ab.{2,5}xy ab____xy_ 0 8
+ab.{2,5}xy ab_____xy_ 0 9
+ab.{2,5}xy ab__xy 0 6
+ab.{2,5}xy ab_____xy 0 9
+ab.{2,5} ab__ 0 4
+ab.{2,5} ab_______ 0 7
+ab.{2,5}xy ab______xy -1 -1
+ab.{2,5}xy ab_xy -1 -1
+
+ab.*?xy abxy_ 0 4
+ab.*?xy ab_xy_ 0 5
+ab.*?xy abxy 0 4
+ab.*?xy ab_xy 0 5
+ab.*? ab 0 2
+ab.*? ab__ 0 4
+
+ab.{2,5}?xy ab__xy_ 0 6
+ab.{2,5}?xy ab____xy_ 0 8
+ab.{2,5}?xy ab_____xy_ 0 9
+ab.{2,5}?xy ab__xy 0 6
+ab.{2,5}?xy ab_____xy 0 9
+ab.{2,5}? ab__ 0 4
+ab.{2,5}? ab_______ 0 7
+ab.{2,5}?xy ab______xy -1 -1
+ab.{2,5}xy ab_xy -1 -1
+
+; again but with slower algorithm variant:
+- match_default REG_EXTENDED
+; now again for single character repeats:
+
+ab_*xy abxy_ 0 4
+ab_*xy ab_xy_ 0 5
+ab_*xy abxy 0 4
+ab_*xy ab_xy 0 5
+ab_* ab 0 2
+ab_* ab__ 0 4
+
+ab_{2,5}xy ab__xy_ 0 6
+ab_{2,5}xy ab____xy_ 0 8
+ab_{2,5}xy ab_____xy_ 0 9
+ab_{2,5}xy ab__xy 0 6
+ab_{2,5}xy ab_____xy 0 9
+ab_{2,5} ab__ 0 4
+ab_{2,5} ab_______ 0 7
+ab_{2,5}xy ab______xy -1 -1
+ab_{2,5}xy ab_xy -1 -1
+
+ab_*?xy abxy_ 0 4
+ab_*?xy ab_xy_ 0 5
+ab_*?xy abxy 0 4
+ab_*?xy ab_xy 0 5
+ab_*? ab 0 2
+ab_*? ab__ 0 4
+
+ab_{2,5}?xy ab__xy_ 0 6
+ab_{2,5}?xy ab____xy_ 0 8
+ab_{2,5}?xy ab_____xy_ 0 9
+ab_{2,5}?xy ab__xy 0 6
+ab_{2,5}?xy ab_____xy 0 9
+ab_{2,5}? ab__ 0 4
+ab_{2,5}? ab_______ 0 7
+ab_{2,5}?xy ab______xy -1 -1
+ab_{2,5}xy ab_xy -1 -1
+
+; and again for sets:
+ab[_,;]*xy abxy_ 0 4
+ab[_,;]*xy ab_xy_ 0 5
+ab[_,;]*xy abxy 0 4
+ab[_,;]*xy ab_xy 0 5
+ab[_,;]* ab 0 2
+ab[_,;]* ab__ 0 4
+
+ab[_,;]{2,5}xy ab__xy_ 0 6
+ab[_,;]{2,5}xy ab____xy_ 0 8
+ab[_,;]{2,5}xy ab_____xy_ 0 9
+ab[_,;]{2,5}xy ab__xy 0 6
+ab[_,;]{2,5}xy ab_____xy 0 9
+ab[_,;]{2,5} ab__ 0 4
+ab[_,;]{2,5} ab_______ 0 7
+ab[_,;]{2,5}xy ab______xy -1 -1
+ab[_,;]{2,5}xy ab_xy -1 -1
+
+ab[_,;]*?xy abxy_ 0 4
+ab[_,;]*?xy ab_xy_ 0 5
+ab[_,;]*?xy abxy 0 4
+ab[_,;]*?xy ab_xy 0 5
+ab[_,;]*? ab 0 2
+ab[_,;]*? ab__ 0 4
+
+ab[_,;]{2,5}?xy ab__xy_ 0 6
+ab[_,;]{2,5}?xy ab____xy_ 0 8
+ab[_,;]{2,5}?xy ab_____xy_ 0 9
+ab[_,;]{2,5}?xy ab__xy 0 6
+ab[_,;]{2,5}?xy ab_____xy 0 9
+ab[_,;]{2,5}? ab__ 0 4
+ab[_,;]{2,5}? ab_______ 0 7
+ab[_,;]{2,5}?xy ab______xy -1 -1
+ab[_,;]{2,5}xy ab_xy -1 -1
+
+; and again for tricky sets with digraphs:
+;ab[_[.ae.]]*xy abxy_ 0 4
+;ab[_[.ae.]]*xy ab_xy_ 0 5
+;ab[_[.ae.]]*xy abxy 0 4
+;ab[_[.ae.]]*xy ab_xy 0 5
+;ab[_[.ae.]]* ab 0 2
+;ab[_[.ae.]]* ab__ 0 4
+
+;ab[_[.ae.]]{2,5}xy ab__xy_ 0 6
+;ab[_[.ae.]]{2,5}xy ab____xy_ 0 8
+;ab[_[.ae.]]{2,5}xy ab_____xy_ 0 9
+;ab[_[.ae.]]{2,5}xy ab__xy 0 6
+;ab[_[.ae.]]{2,5}xy ab_____xy 0 9
+;ab[_[.ae.]]{2,5} ab__ 0 4
+;ab[_[.ae.]]{2,5} ab_______ 0 7
+;ab[_[.ae.]]{2,5}xy ab______xy -1 -1
+;ab[_[.ae.]]{2,5}xy ab_xy -1 -1
+
+;ab[_[.ae.]]*?xy abxy_ 0 4
+;ab[_[.ae.]]*?xy ab_xy_ 0 5
+;ab[_[.ae.]]*?xy abxy 0 4
+;ab[_[.ae.]]*?xy ab_xy 0 5
+;ab[_[.ae.]]*? ab 0 2
+;ab[_[.ae.]]*? ab__ 0 2
+
+;ab[_[.ae.]]{2,5}?xy ab__xy_ 0 6
+;ab[_[.ae.]]{2,5}?xy ab____xy_ 0 8
+;ab[_[.ae.]]{2,5}?xy ab_____xy_ 0 9
+;ab[_[.ae.]]{2,5}?xy ab__xy 0 6
+;ab[_[.ae.]]{2,5}?xy ab_____xy 0 9
+;ab[_[.ae.]]{2,5}? ab__ 0 4
+;ab[_[.ae.]]{2,5}? ab_______ 0 4
+;ab[_[.ae.]]{2,5}?xy ab______xy -1 -1
+;ab[_[.ae.]]{2,5}xy ab_xy -1 -1
+
+; new bugs detected in spring 2003:
+- normal match_continuous REG_NO_POSIX_TEST
+b abc 1 2
+
+() abc 0 0 0 0
+^() abc 0 0 0 0
+^()+ abc 0 0 0 0
+^(){1} abc 0 0 0 0
+^(){2} abc 0 0 0 0
+^((){2}) abc 0 0 0 0 0 0
+() "" 0 0 0 0
+()\1 "" 0 0 0 0
+()\1 a 0 0 0 0
+a()\1b ab 0 2 1 1
+a()b\1 ab 0 2 1 1
+
+; subtleties of matching with no sub-expressions marked
+- normal match_nosubs REG_NO_POSIX_TEST
+a(b?c)+d accd 0 4 
+(wee|week)(knights|night) weeknights 0 10 
+.* abc 0 3
+a(b|(c))d abd 0 3 
+a(b|(c))d acd 0 3
+a(b*|c|e)d abbd 0 4
+a(b*|c|e)d acd 0 3 
+a(b*|c|e)d ad 0 2
+a(b?)c abc 0 3
+a(b?)c ac 0 2
+a(b+)c abc 0 3
+a(b+)c abbbc 0 5
+a(b*)c ac 0 2
+(a|ab)(bc([de]+)f|cde) abcdef 0 6
+a([bc]?)c abc 0 3
+a([bc]?)c ac 0 2
+a([bc]+)c abc 0 3
+a([bc]+)c abcc 0 4
+a([bc]+)bc abcbc 0 5
+a(bb+|b)b abb 0 3
+a(bbb+|bb+|b)b abb 0 3
+a(bbb+|bb+|b)b abbb 0 4
+a(bbb+|bb+|b)bb abbb 0 4
+(.*).* abcdef 0 6
+(a*)* bc 0 0
+
+- normal nosubs REG_NO_POSIX_TEST
+a(b?c)+d accd 0 4 
+(wee|week)(knights|night) weeknights 0 10 
+.* abc 0 3
+a(b|(c))d abd 0 3 
+a(b|(c))d acd 0 3
+a(b*|c|e)d abbd 0 4
+a(b*|c|e)d acd 0 3 
+a(b*|c|e)d ad 0 2
+a(b?)c abc 0 3
+a(b?)c ac 0 2
+a(b+)c abc 0 3
+a(b+)c abbbc 0 5
+a(b*)c ac 0 2
+(a|ab)(bc([de]+)f|cde) abcdef 0 6
+a([bc]?)c abc 0 3
+a([bc]?)c ac 0 2
+a([bc]+)c abc 0 3
+a([bc]+)c abcc 0 4
+a([bc]+)bc abcbc 0 5
+a(bb+|b)b abb 0 3
+a(bbb+|bb+|b)b abb 0 3
+a(bbb+|bb+|b)b abbb 0 4
+a(bbb+|bb+|b)bb abbb 0 4
+(.*).* abcdef 0 6
+(a*)* bc 0 0
+
Index: trunk/src/libctests/glibc/posix/Makefile
===================================================================
--- trunk/src/libctests/glibc/posix/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/posix/Makefile	(revision 2036)
@@ -0,0 +1,290 @@
+# Copyright (C) 1991-1999, 2000-2003, 2004, 2005 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Sub-makefile for POSIX portion of the library.
+#
+subdir	:= posix
+
+headers	:= sys/utsname.h sys/times.h sys/wait.h sys/types.h unistd.h	      \
+	   glob.h regex.h wordexp.h fnmatch.h getopt.h			      \
+	   bits/types.h bits/typesizes.h bits/pthreadtypes.h		      \
+	   bits/posix1_lim.h bits/posix2_lim.h bits/posix_opt.h		      \
+	   bits/local_lim.h tar.h bits/utsname.h bits/confname.h	      \
+	   bits/waitflags.h bits/waitstatus.h sys/unistd.h sched.h	      \
+	   bits/sched.h re_comp.h wait.h bits/environments.h cpio.h	      \
+	   sys/sysmacros.h spawn.h bits/unistd.h
+
+distribute := confstr.h TESTS TESTS2C.sed testcases.h \
+	      PTESTS PTESTS2C.sed ptestcases.h \
+	      globtest.c globtest.sh wordexp-tst.sh annexc.c fnmatch_loop.c   \
+	      spawn_int.h tst-getconf.sh regcomp.c regexec.c regex_internal.c \
+	      regex_internal.h fork.h rxspencer/tests rxspencer/COPYRIGHT     \
+	      PCRE.tests BOOST.tests
+
+routines :=								      \
+	uname								      \
+	times								      \
+	wait waitpid wait3 wait4 waitid					      \
+	alarm sleep pause nanosleep					      \
+	fork vfork _exit						      \
+	execve fexecve execv execle execl execvp execlp			      \
+	getpid getppid							      \
+	getuid geteuid getgid getegid getgroups setuid setgid group_member    \
+	getpgid setpgid getpgrp bsd-getpgrp setpgrp getsid setsid	      \
+	getresuid getresgid setresuid setresgid				      \
+	getlogin getlogin_r setlogin					      \
+	pathconf sysconf fpathconf					      \
+	glob glob64 fnmatch regex					      \
+	confstr								      \
+	getopt getopt1 getopt_init					      \
+	sched_setp sched_getp sched_sets sched_gets sched_yield sched_primax  \
+	sched_primin sched_rr_gi sched_getaffinity sched_setaffinity	      \
+	getaddrinfo gai_strerror wordexp				      \
+	pread pwrite pread64 pwrite64					      \
+	spawn_faction_init spawn_faction_destroy spawn_faction_addclose	      \
+	spawn_faction_addopen spawn_faction_adddup2			      \
+	spawnattr_init spawnattr_destroy				      \
+	spawnattr_getdefault spawnattr_setdefault			      \
+	spawnattr_getflags spawnattr_setflags				      \
+	spawnattr_getpgroup spawnattr_setpgroup spawn spawnp spawni	      \
+	spawnattr_getsigmask spawnattr_getschedpolicy spawnattr_getschedparam \
+	spawnattr_setsigmask spawnattr_setschedpolicy spawnattr_setschedparam \
+	posix_madvise
+
+include ../Makeconfig
+
+aux		:= init-posix environ
+tests		:= tstgetopt testfnm runtests runptests	     \
+		   tst-preadwrite tst-preadwrite64 test-vfork regexbug1 \
+		   tst-getlogin tst-mmap tst-getaddrinfo tst-truncate \
+		   tst-truncate64 tst-fork tst-fnmatch tst-regexloc tst-dir \
+		   tst-chmod bug-regex1 bug-regex2 bug-regex3 bug-regex4 \
+		   tst-gnuglob tst-regex bug-regex5 bug-regex6 bug-regex7 \
+		   bug-regex8 bug-regex9 bug-regex10 bug-regex11 bug-regex12 \
+		   bug-regex13 bug-regex14 bug-regex15 bug-regex16 \
+		   bug-regex17 bug-regex18 bug-regex19 bug-regex20 \
+		   bug-regex21 bug-regex22 bug-regex23 bug-regex24 \
+		   tst-nice tst-nanosleep tst-regex2 \
+		   transbug tst-rxspencer tst-pcre tst-boost \
+		   bug-ga1 tst-vfork1 tst-vfork2 tst-waitid \
+		   tst-getaddrinfo2 bug-glob1 bug-glob2 tst-sysconf \
+		   tst-execvp1 tst-execvp2 tst-execlp1 tst-execlp2 \
+		   tst-execv1 tst-execv2 tst-execl1 tst-execl2 \
+		   tst-execve1 tst-execve2 tst-execle1 tst-execle2 \
+		   tst-execvp3
+xtests		:= bug-ga2
+ifeq (yes,$(build-shared))
+test-srcs	:= globtest
+tests           += wordexp-test tst-exec tst-spawn
+endif
+others		:= getconf
+install-bin	:= getconf
+install-others	:= $(inst_libexecdir)/getconf
+
+before-compile	:= testcases.h ptestcases.h
+
+# So they get cleaned up.
+generated := $(addprefix wordexp-test-result, 1 2 3 4 5 6 7 8 9 10) \
+	     annexc annexc.out wordexp-tst.out bug-regex2-mem \
+	     bug-regex2.mtrace bug-regex14-mem bug-regex14.mtrace \
+	     bug-regex21-mem bug-regex21.mtrace \
+	     tst-rxspencer-mem tst-rxspencer.mtrace tst-getconf.out \
+	     tst-pcre-mem tst-pcre.mtrace tst-boost-mem tst-boost.mtrace \
+	     bug-ga2.mtrace bug-ga2-mem bug-glob2.mtrace bug-glob2-mem
+
+include ../Rules
+
+ifeq (yes,$(build-static-nss))
+# We need it for "make check" only. We can skip them if they haven't
+# been built yet during "make".
+otherlibs += $(wildcard $(nssobjdir)/libnss_files.a \
+			$(resolvobjdir)/libnss_dns.a \
+			$(resolvobjdir)/libresolv.a)
+endif
+
+ifeq (no,$(cross-compiling))
+# globtest and wordexp-test currently only works with shared libraries
+ifeq (yes,$(build-shared))
+tests: $(objpfx)globtest.out $(objpfx)wordexp-tst.out
+$(objpfx)globtest.out: globtest.sh $(objpfx)globtest
+	$(SHELL) -e globtest.sh $(common-objpfx) $(elf-objpfx) \
+		 $(rtld-installed-name)
+$(objpfx)wordexp-tst.out: wordexp-tst.sh $(objpfx)wordexp-test
+	$(SHELL) -e wordexp-tst.sh $(common-objpfx) $(elf-objpfx) \
+		 $(rtld-installed-name)
+endif
+endif
+
+CFLAGS-regex.c = -Wno-strict-prototypes
+CFLAGS-getaddrinfo.c = -DRESOLVER -fexceptions -DUSE_NSCD
+CFLAGS-pread.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-pread64.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-pwrite.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-pwrite64.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-sleep.c = -fexceptions
+CFLAGS-wait.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-waitid.c = -fexceptions
+CFLAGS-waitpid.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-getopt.c = -fexceptions
+CFLAGS-wordexp.c = -fexceptions
+CFLAGS-wordexp.os = -fomit-frame-pointer
+CFLAGS-sysconf.c = -fexceptions -DGETCONF_DIR='"$(libexecdir)/getconf"'
+CFLAGS-pathconf.c = -fexceptions
+CFLAGS-fpathconf.c = -fexceptions
+CFLAGS-spawn.c = -fexceptions
+CFLAGS-spawn.os = -fomit-frame-pointer
+CFLAGS-spawnp.c = -fexceptions
+CFLAGS-spawnp.os = -fomit-frame-pointer
+CFLAGS-spawni.c = -fexceptions
+CFLAGS-spawni.os = -fomit-frame-pointer
+CFLAGS-pause.c = -fexceptions
+CFLAGS-glob.c = $(uses-callbacks) -fexceptions
+CFLAGS-glob64.c = $(uses-callbacks) -fexceptions
+CFLAGS-getconf.c = -DGETCONF_DIR='"$(libexecdir)/getconf"'
+CFLAGS-execve.os = -fomit-frame-pointer
+CFLAGS-fexecve.os = -fomit-frame-pointer
+CFLAGS-execv.os = -fomit-frame-pointer
+CFLAGS-execle.os = -fomit-frame-pointer
+CFLAGS-execl.os = -fomit-frame-pointer
+CFLAGS-execvp.os = -fomit-frame-pointer
+CFLAGS-execlp.os = -fomit-frame-pointer
+
+tstgetopt-ARGS = -a -b -cfoobar --required foobar --optional=bazbug \
+		--none random --col --color --colour
+
+tst-exec-ARGS = -- $(built-program-cmd)
+tst-spawn-ARGS = -- $(built-program-cmd)
+tst-dir-ARGS = `pwd` `cd $(common-objdir)/$(subdir); pwd` `cd $(common-objdir); pwd` $(objpfx)tst-dir
+tst-chmod-ARGS = `pwd`
+
+tst-fnmatch-ENV = LOCPATH=$(common-objpfx)localedata
+tst-regexloc-ENV = LOCPATH=$(common-objpfx)localedata
+bug-regex1-ENV = LOCPATH=$(common-objpfx)localedata
+tst-regex-ENV = LOCPATH=$(common-objpfx)localedata
+tst-regex2-ENV = LOCPATH=$(common-objpfx)localedata
+bug-regex5-ENV = LOCPATH=$(common-objpfx)localedata
+bug-regex6-ENV = LOCPATH=$(common-objpfx)localedata
+bug-regex17-ENV = LOCPATH=$(common-objpfx)localedata
+bug-regex18-ENV = LOCPATH=$(common-objpfx)localedata
+bug-regex19-ENV = LOCPATH=$(common-objpfx)localedata
+bug-regex20-ENV = LOCPATH=$(common-objpfx)localedata
+bug-regex22-ENV = LOCPATH=$(common-objpfx)localedata
+bug-regex23-ENV = LOCPATH=$(common-objpfx)localedata
+tst-rxspencer-ARGS = --utf8 rxspencer/tests
+tst-rxspencer-ENV = LOCPATH=$(common-objpfx)localedata
+tst-pcre-ARGS = PCRE.tests
+tst-boost-ARGS = BOOST.tests
+bug-glob1-ARGS = "$(objpfx)"
+tst-execvp3-ARGS = --test-dir=$(objpfx)
+
+testcases.h: TESTS TESTS2C.sed
+	sed -f TESTS2C.sed < $< > $@T
+	mv -f $@T $@
+ifeq ($(with-cvs),yes)
+	test ! -d CVS || cvs $(CVSOPTS) commit -mRegenerated $@
+endif
+
+ptestcases.h: PTESTS PTESTS2C.sed
+	sed -f PTESTS2C.sed < $< > $@T
+	mv -f $@T $@
+ifeq ($(with-cvs),yes)
+	test ! -d CVS || cvs $(CVSOPTS) commit -mRegenerated $@
+endif
+
+# Run a test on the header files we use.
+# XXX Please note that for now we ignore the result of this test.
+tests: $(objpfx)annexc.out
+ifeq (no,$(cross-compiling))
+tests: $(objpfx)bug-regex2-mem $(objpfx)bug-regex14-mem \
+  $(objpfx)bug-regex21-mem $(objpfx)tst-rxspencer-mem \
+  $(objpfx)tst-pcre-mem $(objpfx)tst-boost-mem $(objpfx)tst-getconf.out \
+  $(objpfx)bug-glob2-mem
+xtests: $(objpfx)bug-ga2-mem
+endif
+
+$(objpfx)annexc.out: $(objpfx)annexc
+	-$(dir $<)$(notdir $<) '$(CC)' \
+	  '$(patsubst %,-I../%,$(sorted-subdirs)) -I../include -I.. $(+sysdep-includes) $(sysincludes)' > $@
+
+annexc-CFLAGS = -O
+$(objpfx)annexc: annexc.c
+	$(native-compile)
+
+bug-regex2-ENV = MALLOC_TRACE=$(objpfx)bug-regex2.mtrace
+
+$(objpfx)bug-regex2-mem: $(objpfx)bug-regex2.out
+	$(common-objpfx)malloc/mtrace $(objpfx)bug-regex2.mtrace > $@
+
+bug-regex14-ENV = MALLOC_TRACE=$(objpfx)bug-regex14.mtrace
+
+$(objpfx)bug-regex14-mem: $(objpfx)bug-regex14.out
+	$(common-objpfx)malloc/mtrace $(objpfx)bug-regex14.mtrace > $@
+
+bug-regex21-ENV = MALLOC_TRACE=$(objpfx)bug-regex21.mtrace
+
+$(objpfx)bug-regex21-mem: $(objpfx)bug-regex21.out
+	$(common-objpfx)malloc/mtrace $(objpfx)bug-regex21.mtrace > $@
+
+# tst-rxspencer.mtrace is generated only when run without --utf8
+# option, since otherwise the file has almost 100M and takes very long
+# time to process.
+$(objpfx)tst-rxspencer-mem: $(objpfx)tst-rxspencer.out
+	MALLOC_TRACE=$(objpfx)tst-rxspencer.mtrace $(tst-rxspencer-ENV) \
+	  $(run-program-prefix) $(objpfx)tst-rxspencer rxspencer/tests \
+	  > /dev/null
+	$(common-objpfx)malloc/mtrace $(objpfx)tst-rxspencer.mtrace > $@
+
+tst-pcre-ENV = MALLOC_TRACE=$(objpfx)tst-pcre.mtrace
+$(objpfx)tst-pcre-mem: $(objpfx)tst-pcre.out
+	$(common-objpfx)malloc/mtrace $(objpfx)tst-pcre.mtrace > $@
+
+tst-boost-ENV = MALLOC_TRACE=$(objpfx)tst-boost.mtrace
+$(objpfx)tst-boost-mem: $(objpfx)tst-boost.out
+	$(common-objpfx)malloc/mtrace $(objpfx)tst-boost.mtrace > $@
+
+$(objpfx)tst-getconf.out: tst-getconf.sh $(objpfx)getconf
+	$(SHELL) -e $< $(common-objpfx) $(elf-objpfx) $(rtld-installed-name)
+
+ifeq (yes,$(build-shared))
+$(objpfx)tst-regex: $(common-objpfx)rt/librt.so
+$(objpfx)tst-regex2: $(common-objpfx)rt/librt.so
+else
+$(objpfx)tst-regex: $(common-objpfx)rt/librt.a
+$(objpfx)tst-regex2: $(common-objpfx)rt/librt.a
+endif
+
+$(objpfx)bug-ga2-mem: $(objpfx)bug-ga2.out
+	$(common-objpfx)malloc/mtrace $(objpfx)bug-ga2.mtrace > $@
+
+bug-ga2-ENV = MALLOC_TRACE=$(objpfx)bug-ga2.mtrace
+
+bug-glob2-ENV = MALLOC_TRACE=$(objpfx)bug-glob2.mtrace
+
+$(objpfx)bug-glob2-mem: $(objpfx)bug-glob2.out
+	$(common-objpfx)malloc/mtrace $(objpfx)bug-glob2.mtrace > $@
+
+$(inst_libexecdir)/getconf: $(objpfx)getconf FORCE
+	$(addprefix $(..)./scripts/mkinstalldirs ,\
+		    $(filter-out $(wildcard $@),$@))
+	for spec in `LC_ALL=C GETCONF_DIR=/dev/null \
+		     $(run-program-prefix) $< \
+		     _POSIX_V6_WIDTH_RESTRICTED_ENVS`; do \
+		$(INSTALL_PROGRAM) $< $@/$$spec.new; \
+		mv -f $@/$$spec.new $@/$$spec; \
+	done
Index: trunk/src/libctests/glibc/posix/PCRE.tests
===================================================================
--- trunk/src/libctests/glibc/posix/PCRE.tests	(revision 2036)
+++ trunk/src/libctests/glibc/posix/PCRE.tests	(revision 2036)
@@ -0,0 +1,2386 @@
+# PCRE version 4.4 21-August-2003
+
+# Tests taken from PCRE and modified to suit glibc regex.
+#
+# PCRE LICENCE
+# ------------
+#
+# PCRE is a library of functions to support regular expressions whose syntax
+# and semantics are as close as possible to those of the Perl 5 language.
+#
+# Written by: Philip Hazel <ph10@cam.ac.uk>
+#
+# University of Cambridge Computing Service,
+# Cambridge, England. Phone: +44 1223 334714.
+#
+# Copyright (c) 1997-2003 University of Cambridge
+#
+# Permission is granted to anyone to use this software for any purpose on any
+# computer system, and to redistribute it freely, subject to the following
+# restrictions:
+#
+# 1. This software 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.
+#
+# 2. The origin of this software must not be misrepresented, either by
+#    explicit claim or by omission. In practice, this means that if you use
+#    PCRE in software that you distribute to others, commercially or
+#    otherwise, you must put a sentence like this
+#
+#      Regular expression support is provided by the PCRE library package,
+#      which is open source software, written by Philip Hazel, and copyright
+#      by the University of Cambridge, England.
+#
+#    somewhere reasonably visible in your documentation and in any relevant
+#    files or online help data or similar. A reference to the ftp site for
+#    the source, that is, to
+#
+#      ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
+#
+#    should also be given in the documentation. However, this condition is not
+#    intended to apply to whole chains of software. If package A includes PCRE,
+#    it must acknowledge it, but if package B is software that includes package
+#    A, the condition is not imposed on package B (unless it uses PCRE
+#    independently).
+#
+# 3. Altered versions must be plainly marked as such, and must not be
+#    misrepresented as being the original software.
+#
+# 4. If PCRE is embedded in any software that is released under the GNU
+#   General Purpose Licence (GPL), or Lesser General Purpose Licence (LGPL),
+#   then the terms of that licence shall supersede any condition above with
+#   which it is incompatible.
+#
+# The documentation for PCRE, supplied in the "doc" directory, is distributed
+# under the same terms as the software itself.
+#
+# End
+#
+
+/the quick brown fox/
+    the quick brown fox
+ 0: the quick brown fox
+    The quick brown FOX
+No match
+    What do you know about the quick brown fox?
+ 0: the quick brown fox
+    What do you know about THE QUICK BROWN FOX?
+No match
+
+/The quick brown fox/i
+    the quick brown fox
+ 0: the quick brown fox
+    The quick brown FOX
+ 0: The quick brown FOX
+    What do you know about the quick brown fox?
+ 0: the quick brown fox
+    What do you know about THE QUICK BROWN FOX?
+ 0: THE QUICK BROWN FOX
+
+/a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz/
+    abxyzpqrrrabbxyyyypqAzz
+ 0: abxyzpqrrrabbxyyyypqAzz
+    abxyzpqrrrabbxyyyypqAzz
+ 0: abxyzpqrrrabbxyyyypqAzz
+    aabxyzpqrrrabbxyyyypqAzz
+ 0: aabxyzpqrrrabbxyyyypqAzz
+    aaabxyzpqrrrabbxyyyypqAzz
+ 0: aaabxyzpqrrrabbxyyyypqAzz
+    aaaabxyzpqrrrabbxyyyypqAzz
+ 0: aaaabxyzpqrrrabbxyyyypqAzz
+    abcxyzpqrrrabbxyyyypqAzz
+ 0: abcxyzpqrrrabbxyyyypqAzz
+    aabcxyzpqrrrabbxyyyypqAzz
+ 0: aabcxyzpqrrrabbxyyyypqAzz
+    aaabcxyzpqrrrabbxyyyypAzz
+ 0: aaabcxyzpqrrrabbxyyyypAzz
+    aaabcxyzpqrrrabbxyyyypqAzz
+ 0: aaabcxyzpqrrrabbxyyyypqAzz
+    aaabcxyzpqrrrabbxyyyypqqAzz
+ 0: aaabcxyzpqrrrabbxyyyypqqAzz
+    aaabcxyzpqrrrabbxyyyypqqqAzz
+ 0: aaabcxyzpqrrrabbxyyyypqqqAzz
+    aaabcxyzpqrrrabbxyyyypqqqqAzz
+ 0: aaabcxyzpqrrrabbxyyyypqqqqAzz
+    aaabcxyzpqrrrabbxyyyypqqqqqAzz
+ 0: aaabcxyzpqrrrabbxyyyypqqqqqAzz
+    aaabcxyzpqrrrabbxyyyypqqqqqqAzz
+ 0: aaabcxyzpqrrrabbxyyyypqqqqqqAzz
+    aaaabcxyzpqrrrabbxyyyypqAzz
+ 0: aaaabcxyzpqrrrabbxyyyypqAzz
+    abxyzzpqrrrabbxyyyypqAzz
+ 0: abxyzzpqrrrabbxyyyypqAzz
+    aabxyzzzpqrrrabbxyyyypqAzz
+ 0: aabxyzzzpqrrrabbxyyyypqAzz
+    aaabxyzzzzpqrrrabbxyyyypqAzz
+ 0: aaabxyzzzzpqrrrabbxyyyypqAzz
+    aaaabxyzzzzpqrrrabbxyyyypqAzz
+ 0: aaaabxyzzzzpqrrrabbxyyyypqAzz
+    abcxyzzpqrrrabbxyyyypqAzz
+ 0: abcxyzzpqrrrabbxyyyypqAzz
+    aabcxyzzzpqrrrabbxyyyypqAzz
+ 0: aabcxyzzzpqrrrabbxyyyypqAzz
+    aaabcxyzzzzpqrrrabbxyyyypqAzz
+ 0: aaabcxyzzzzpqrrrabbxyyyypqAzz
+    aaaabcxyzzzzpqrrrabbxyyyypqAzz
+ 0: aaaabcxyzzzzpqrrrabbxyyyypqAzz
+    aaaabcxyzzzzpqrrrabbbxyyyypqAzz
+ 0: aaaabcxyzzzzpqrrrabbbxyyyypqAzz
+    aaaabcxyzzzzpqrrrabbbxyyyyypqAzz
+ 0: aaaabcxyzzzzpqrrrabbbxyyyyypqAzz
+    aaabcxyzpqrrrabbxyyyypABzz
+ 0: aaabcxyzpqrrrabbxyyyypABzz
+    aaabcxyzpqrrrabbxyyyypABBzz
+ 0: aaabcxyzpqrrrabbxyyyypABBzz
+    >>>aaabxyzpqrrrabbxyyyypqAzz
+ 0: aaabxyzpqrrrabbxyyyypqAzz
+    >aaaabxyzpqrrrabbxyyyypqAzz
+ 0: aaaabxyzpqrrrabbxyyyypqAzz
+    >>>>abcxyzpqrrrabbxyyyypqAzz
+ 0: abcxyzpqrrrabbxyyyypqAzz
+    *** Failers
+No match
+    abxyzpqrrabbxyyyypqAzz
+No match
+    abxyzpqrrrrabbxyyyypqAzz
+No match
+    abxyzpqrrrabxyyyypqAzz
+No match
+    aaaabcxyzzzzpqrrrabbbxyyyyyypqAzz
+No match
+    aaaabcxyzzzzpqrrrabbbxyyypqAzz
+No match
+    aaabcxyzpqrrrabbxyyyypqqqqqqqAzz
+No match
+
+/^(abc){1,2}zz/
+    abczz
+ 0: abczz
+ 1: abc
+    abcabczz
+ 0: abcabczz
+ 1: abc
+    *** Failers
+No match
+    zz
+No match
+    abcabcabczz
+No match
+    >>abczz
+No match
+
+/^(b+|a){1,2}c/
+    bc
+ 0: bc
+ 1: b
+    bbc
+ 0: bbc
+ 1: bb
+    bbbc
+ 0: bbbc
+ 1: bbb
+    bac
+ 0: bac
+ 1: a
+    bbac
+ 0: bbac
+ 1: a
+    aac
+ 0: aac
+ 1: a
+    abbbbbbbbbbbc
+ 0: abbbbbbbbbbbc
+ 1: bbbbbbbbbbb
+    bbbbbbbbbbbac
+ 0: bbbbbbbbbbbac
+ 1: a
+    *** Failers
+No match
+    aaac
+No match
+    abbbbbbbbbbbac
+No match
+
+/^[]cde]/
+    ]thing
+ 0: ]
+    cthing
+ 0: c
+    dthing
+ 0: d
+    ething
+ 0: e
+    *** Failers
+No match
+    athing
+No match
+    fthing
+No match
+
+/^[^]cde]/
+    athing
+ 0: a
+    fthing
+ 0: f
+    *** Failers
+ 0: *
+    ]thing
+No match
+    cthing
+No match
+    dthing
+No match
+    ething
+No match
+
+/^[0-9]+$/
+    0
+ 0: 0
+    1
+ 0: 1
+    2
+ 0: 2
+    3
+ 0: 3
+    4
+ 0: 4
+    5
+ 0: 5
+    6
+ 0: 6
+    7
+ 0: 7
+    8
+ 0: 8
+    9
+ 0: 9
+    10
+ 0: 10
+    100
+ 0: 100
+    *** Failers
+No match
+    abc
+No match
+
+/^.*nter/
+    enter
+ 0: enter
+    inter
+ 0: inter
+    uponter
+ 0: uponter
+
+/^xxx[0-9]+$/
+    xxx0
+ 0: xxx0
+    xxx1234
+ 0: xxx1234
+    *** Failers
+No match
+    xxx
+No match
+
+/^.+[0-9][0-9][0-9]$/
+    x123
+ 0: x123
+    xx123
+ 0: xx123
+    123456
+ 0: 123456
+    *** Failers
+No match
+    123
+No match
+    x1234
+ 0: x1234
+
+/^([^!]+)!(.+)=apquxz\.ixr\.zzz\.ac\.uk$/
+    abc!pqr=apquxz.ixr.zzz.ac.uk
+ 0: abc!pqr=apquxz.ixr.zzz.ac.uk
+ 1: abc
+ 2: pqr
+    *** Failers
+No match
+    !pqr=apquxz.ixr.zzz.ac.uk
+No match
+    abc!=apquxz.ixr.zzz.ac.uk
+No match
+    abc!pqr=apquxz:ixr.zzz.ac.uk
+No match
+    abc!pqr=apquxz.ixr.zzz.ac.ukk
+No match
+
+/:/
+    Well, we need a colon: somewhere
+ 0: :
+    *** Fail if we don't
+No match
+
+/([0-9a-f:]+)$/i
+    0abc
+ 0: 0abc
+ 1: 0abc
+    abc
+ 0: abc
+ 1: abc
+    fed
+ 0: fed
+ 1: fed
+    E
+ 0: E
+ 1: E
+    ::
+ 0: ::
+ 1: ::
+    5f03:12C0::932e
+ 0: 5f03:12C0::932e
+ 1: 5f03:12C0::932e
+    fed def
+ 0: def
+ 1: def
+    Any old stuff
+ 0: ff
+ 1: ff
+    *** Failers
+No match
+    0zzz
+No match
+    gzzz
+No match
+    Any old rubbish
+No match
+
+/^.*\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/
+    .1.2.3
+ 0: .1.2.3
+ 1: 1
+ 2: 2
+ 3: 3
+    A.12.123.0
+ 0: A.12.123.0
+ 1: 12
+ 2: 123
+ 3: 0
+    *** Failers
+No match
+    .1.2.3333
+No match
+    1.2.3
+No match
+    1234.2.3
+No match
+
+/^([0-9]+)\s+IN\s+SOA\s+(\S+)\s+(\S+)\s*\(\s*$/
+    1 IN SOA non-sp1 non-sp2(
+ 0: 1 IN SOA non-sp1 non-sp2(
+ 1: 1
+ 2: non-sp1
+ 3: non-sp2
+    1    IN    SOA    non-sp1    non-sp2   (
+ 0: 1    IN    SOA    non-sp1    non-sp2   (
+ 1: 1
+ 2: non-sp1
+ 3: non-sp2
+    *** Failers
+No match
+    1IN SOA non-sp1 non-sp2(
+No match
+
+/^[a-zA-Z0-9][a-zA-Z0-9-]*(\.[a-zA-Z0-9][a-zA-z0-9-]*)*\.$/
+    a.
+ 0: a.
+    Z.
+ 0: Z.
+    2.
+ 0: 2.
+    ab-c.pq-r.
+ 0: ab-c.pq-r.
+ 1: .pq-r
+    sxk.zzz.ac.uk.
+ 0: sxk.zzz.ac.uk.
+ 1: .uk
+    x-.y-.
+ 0: x-.y-.
+ 1: .y-
+    *** Failers
+No match
+    -abc.peq.
+No match
+
+/^\*\.[a-z]([a-z0-9-]*[a-z0-9]+)?(\.[a-z]([a-z0-9-]*[a-z0-9]+)?)*$/
+    *.a
+ 0: *.a
+    *.b0-a
+ 0: *.b0-a
+ 1: 0-a
+    *.c3-b.c
+ 0: *.c3-b.c
+ 1: 3-b
+ 2: .c
+    *.c-a.b-c
+ 0: *.c-a.b-c
+ 1: -a
+ 2: .b-c
+ 3: -c
+    *** Failers
+No match
+    *.0
+No match
+    *.a-
+No match
+    *.a-b.c-
+No match
+    *.c-a.0-c
+No match
+
+/^[0-9a-f](\.[0-9a-f])*$/i
+    a.b.c.d
+ 0: a.b.c.d
+ 1: .d
+    A.B.C.D
+ 0: A.B.C.D
+ 1: .D
+    a.b.c.1.2.3.C
+ 0: a.b.c.1.2.3.C
+ 1: .C
+
+/^".*"\s*(;.*)?$/
+    "1234"
+ 0: "1234"
+    "abcd" ;
+ 0: "abcd" ;
+ 1: ;
+    "" ; rhubarb
+ 0: "" ; rhubarb
+ 1: ; rhubarb
+    *** Failers
+No match
+    "1234" : things
+No match
+
+/^(a(b(c)))(d(e(f)))(h(i(j)))(k(l(m)))$/
+    abcdefhijklm
+ 0: abcdefhijklm
+ 1: abc
+ 2: bc
+ 3: c
+ 4: def
+ 5: ef
+ 6: f
+ 7: hij
+ 8: ij
+ 9: j
+10: klm
+11: lm
+12: m
+
+/^a*\w/
+    z
+ 0: z
+    az
+ 0: az
+    aaaz
+ 0: aaaz
+    a
+ 0: a
+    aa
+ 0: aa
+    aaaa
+ 0: aaaa
+    a+
+ 0: a
+    aa+
+ 0: aa
+
+/^a+\w/
+    az
+ 0: az
+    aaaz
+ 0: aaaz
+    aa
+ 0: aa
+    aaaa
+ 0: aaaa
+    aa+
+ 0: aa
+
+/^[0-9]{8}\w{2,}/
+    1234567890
+ 0: 1234567890
+    12345678ab
+ 0: 12345678ab
+    12345678__
+ 0: 12345678__
+    *** Failers
+No match
+    1234567
+No match
+
+/^[aeiou0-9]{4,5}$/
+    uoie
+ 0: uoie
+    1234
+ 0: 1234
+    12345
+ 0: 12345
+    aaaaa
+ 0: aaaaa
+    *** Failers
+No match
+    123456
+No match
+
+/\`(abc|def)=(\1){2,3}\'/
+    abc=abcabc
+ 0: abc=abcabc
+ 1: abc
+ 2: abc
+    def=defdefdef
+ 0: def=defdefdef
+ 1: def
+ 2: def
+    *** Failers
+No match
+    abc=defdef
+No match
+
+/(cat(a(ract|tonic)|erpillar)) \1()2(3)/
+    cataract cataract23
+ 0: cataract cataract23
+ 1: cataract
+ 2: aract
+ 3: ract
+ 4: 
+ 5: 3
+    catatonic catatonic23
+ 0: catatonic catatonic23
+ 1: catatonic
+ 2: atonic
+ 3: tonic
+ 4: 
+ 5: 3
+    caterpillar caterpillar23
+ 0: caterpillar caterpillar23
+ 1: caterpillar
+ 2: erpillar
+ 3: <unset>
+ 4: 
+ 5: 3
+
+
+/^From +([^ ]+) +[a-zA-Z][a-zA-Z][a-zA-Z] +[a-zA-Z][a-zA-Z][a-zA-Z] +[0-9]?[0-9] +[0-9][0-9]:[0-9][0-9]/
+    From abcd  Mon Sep 01 12:33:02 1997
+ 0: From abcd  Mon Sep 01 12:33
+ 1: abcd
+
+/^From\s+\S+\s+([a-zA-Z]{3}\s+){2}[0-9]{1,2}\s+[0-9][0-9]:[0-9][0-9]/
+    From abcd  Mon Sep 01 12:33:02 1997
+ 0: From abcd  Mon Sep 01 12:33
+ 1: Sep 
+    From abcd  Mon Sep  1 12:33:02 1997
+ 0: From abcd  Mon Sep  1 12:33
+ 1: Sep  
+    *** Failers
+No match
+    From abcd  Sep 01 12:33:02 1997
+No match
+
+/^(a)\1{2,3}(.)/
+    aaab
+ 0: aaab
+ 1: a
+ 2: b
+    aaaab
+ 0: aaaab
+ 1: a
+ 2: b
+    aaaaab
+ 0: aaaaa
+ 1: a
+ 2: a
+    aaaaaab
+ 0: aaaaa
+ 1: a
+ 2: a
+
+/^[ab]{1,3}(ab*|b)/
+    aabbbbb
+ 0: aabbbbb
+ 1: abbbbb
+
+/^(cow|)\1(bell)/
+    cowcowbell
+ 0: cowcowbell
+ 1: cow
+ 2: bell
+    bell
+ 0: bell
+ 1: 
+ 2: bell
+    *** Failers
+No match
+    cowbell
+No match
+
+/^(a|)\1+b/
+    aab
+ 0: aab
+ 1: a
+    aaaab
+ 0: aaaab
+ 1: a
+    b
+ 0: b
+ 1: 
+    *** Failers
+No match
+    ab
+No match
+
+/^(a|)\1{2}b/
+    aaab
+ 0: aaab
+ 1: a
+    b
+ 0: b
+ 1: 
+    *** Failers
+No match
+    ab
+No match
+    aab
+No match
+    aaaab
+No match
+
+/^(a|)\1{2,3}b/
+    aaab
+ 0: aaab
+ 1: a
+    aaaab
+ 0: aaaab
+ 1: a
+    b
+ 0: b
+ 1: 
+    *** Failers
+No match
+    ab
+No match
+    aab
+No match
+    aaaaab
+No match
+
+/ab{1,3}bc/
+    abbbbc
+ 0: abbbbc
+    abbbc
+ 0: abbbc
+    abbc
+ 0: abbc
+    *** Failers
+No match
+    abc
+No match
+    abbbbbc
+No match
+
+/([^.]*)\.([^:]*):[T ]+(.*)/
+    track1.title:TBlah blah blah
+ 0: track1.title:TBlah blah blah
+ 1: track1
+ 2: title
+ 3: Blah blah blah
+
+/([^.]*)\.([^:]*):[T ]+(.*)/i
+    track1.title:TBlah blah blah
+ 0: track1.title:TBlah blah blah
+ 1: track1
+ 2: title
+ 3: Blah blah blah
+
+/([^.]*)\.([^:]*):[t ]+(.*)/i
+    track1.title:TBlah blah blah
+ 0: track1.title:TBlah blah blah
+ 1: track1
+ 2: title
+ 3: Blah blah blah
+
+/^abc$/
+    abc
+ 0: abc
+    *** Failers
+No match
+
+/[-az]+/
+    az-
+ 0: az-
+    *** Failers
+ 0: a
+    b
+No match
+
+/[az-]+/
+    za-
+ 0: za-
+    *** Failers
+ 0: a
+    b
+No match
+
+/[a-z]+/
+    abcdxyz
+ 0: abcdxyz
+
+/[0-9-]+/
+    12-34
+ 0: 12-34
+    *** Failers
+No match
+    aaa
+No match
+
+/(abc)\1/i
+    abcabc
+ 0: abcabc
+ 1: abc
+    ABCabc
+ 0: ABCabc
+ 1: ABC
+    abcABC
+ 0: abcABC
+ 1: abc
+
+/a{0}bc/
+    bc
+ 0: bc
+
+/^([^a])([^b])([^c]*)([^d]{3,4})/
+    baNOTccccd
+ 0: baNOTcccc
+ 1: b
+ 2: a
+ 3: NOT
+ 4: cccc
+    baNOTcccd
+ 0: baNOTccc
+ 1: b
+ 2: a
+ 3: NOT
+ 4: ccc
+    baNOTccd
+ 0: baNOTcc
+ 1: b
+ 2: a
+ 3: NO
+ 4: Tcc
+    bacccd
+ 0: baccc
+ 1: b
+ 2: a
+ 3: 
+ 4: ccc
+    *** Failers
+ 0: *** Failers
+ 1: *
+ 2: *
+ 3: * Fail
+ 4: ers
+    anything
+No match
+    baccd
+No match
+
+/[^a]/
+    Abc
+ 0: A
+
+/[^a]/i
+    Abc 
+ 0: b
+
+/[^a]+/
+    AAAaAbc
+ 0: AAA
+
+/[^a]+/i
+    AAAaAbc
+ 0: bc
+
+/[^k]$/
+    abc
+ 0: c
+    *** Failers
+ 0: s
+    abk
+No match
+
+/[^k]{2,3}$/
+    abc
+ 0: abc
+    kbc
+ 0: bc
+    kabc
+ 0: abc
+    *** Failers
+ 0: ers
+    abk
+No match
+    akb
+No match
+    akk 
+No match
+
+/^[0-9]{8,}@.+[^k]$/
+    12345678@a.b.c.d
+ 0: 12345678@a.b.c.d
+    123456789@x.y.z
+ 0: 123456789@x.y.z
+    *** Failers
+No match
+    12345678@x.y.uk
+No match
+    1234567@a.b.c.d       
+No match
+
+/(a)\1{8,}/
+    aaaaaaaaa
+ 0: aaaaaaaaa
+ 1: a
+    aaaaaaaaaa
+ 0: aaaaaaaaaa
+ 1: a
+    *** Failers
+No match
+    aaaaaaa   
+No match
+
+/[^a]/
+    aaaabcd
+ 0: b
+    aaAabcd 
+ 0: A
+
+/[^a]/i
+    aaaabcd
+ 0: b
+    aaAabcd 
+ 0: b
+
+/[^az]/
+    aaaabcd
+ 0: b
+    aaAabcd 
+ 0: A
+
+/[^az]/i
+    aaaabcd
+ 0: b
+    aaAabcd 
+ 0: b
+
+/P[^*]TAIRE[^*]{1,6}LL/
+    xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
+ 0: PSTAIREISLL
+
+/P[^*]TAIRE[^*]{1,}LL/
+    xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
+ 0: PSTAIREISLL
+
+/(\.[0-9][0-9][1-9]?)[0-9]+/
+    1.230003938
+ 0: .230003938
+ 1: .23
+    1.875000282   
+ 0: .875000282
+ 1: .875
+    1.235  
+ 0: .235
+ 1: .23
+                  
+/\b(foo)\s+(\w+)/i
+    Food is on the foo table
+ 0: foo table
+ 1: foo
+ 2: table
+    
+/foo(.*)bar/
+    The food is under the bar in the barn.
+ 0: food is under the bar in the bar
+ 1: d is under the bar in the 
+    
+/(.*)([0-9]*)/
+    I have 2 numbers: 53147
+ 0: I have 2 numbers: 53147
+ 1: I have 2 numbers: 53147
+ 2: 
+    
+/(.*)([0-9]+)/
+    I have 2 numbers: 53147
+ 0: I have 2 numbers: 53147
+ 1: I have 2 numbers: 5314
+ 2: 7
+
+/(.*)([0-9]+)$/
+    I have 2 numbers: 53147
+ 0: I have 2 numbers: 53147
+ 1: I have 2 numbers: 5314
+ 2: 7
+
+/(.*)\b([0-9]+)$/
+    I have 2 numbers: 53147
+ 0: I have 2 numbers: 53147
+ 1: I have 2 numbers: 
+ 2: 53147
+
+/(.*[^0-9])([0-9]+)$/
+    I have 2 numbers: 53147
+ 0: I have 2 numbers: 53147
+ 1: I have 2 numbers: 
+ 2: 53147
+
+/[[:digit:]][[:digit:]]\/[[:digit:]][[:digit:]]\/[[:digit:]][[:digit:]][[:digit:]][[:digit:]]/
+    01/01/2000
+ 0: 01/01/2000
+
+/^(a){0,0}/
+    bcd
+ 0: 
+    abc
+ 0: 
+    aab     
+ 0: 
+
+/^(a){0,1}/
+    bcd
+ 0: 
+    abc
+ 0: a
+ 1: a
+    aab  
+ 0: a
+ 1: a
+
+/^(a){0,2}/
+    bcd
+ 0: 
+    abc
+ 0: a
+ 1: a
+    aab  
+ 0: aa
+ 1: a
+
+/^(a){0,3}/
+    bcd
+ 0: 
+    abc
+ 0: a
+ 1: a
+    aab
+ 0: aa
+ 1: a
+    aaa   
+ 0: aaa
+ 1: a
+
+/^(a){0,}/
+    bcd
+ 0: 
+    abc
+ 0: a
+ 1: a
+    aab
+ 0: aa
+ 1: a
+    aaa
+ 0: aaa
+ 1: a
+    aaaaaaaa    
+ 0: aaaaaaaa
+ 1: a
+
+/^(a){1,1}/
+    bcd
+No match
+    abc
+ 0: a
+ 1: a
+    aab  
+ 0: a
+ 1: a
+
+/^(a){1,2}/
+    bcd
+No match
+    abc
+ 0: a
+ 1: a
+    aab  
+ 0: aa
+ 1: a
+
+/^(a){1,3}/
+    bcd
+No match
+    abc
+ 0: a
+ 1: a
+    aab
+ 0: aa
+ 1: a
+    aaa   
+ 0: aaa
+ 1: a
+
+/^(a){1,}/
+    bcd
+No match
+    abc
+ 0: a
+ 1: a
+    aab
+ 0: aa
+ 1: a
+    aaa
+ 0: aaa
+ 1: a
+    aaaaaaaa    
+ 0: aaaaaaaa
+ 1: a
+
+/^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/
+    123456654321
+ 0: 123456654321
+
+/^[[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]]/
+    123456654321 
+ 0: 123456654321
+
+/^[abc]{12}/
+    abcabcabcabc
+ 0: abcabcabcabc
+    
+/^[a-c]{12}/
+    abcabcabcabc
+ 0: abcabcabcabc
+    
+/^(a|b|c){12}/
+    abcabcabcabc 
+ 0: abcabcabcabc
+ 1: c
+
+/^[abcdefghijklmnopqrstuvwxy0123456789]/
+    n
+ 0: n
+    *** Failers 
+No match
+    z 
+No match
+
+/abcde{0,0}/
+    abcd
+ 0: abcd
+    *** Failers
+No match
+    abce  
+No match
+
+/ab[cd]{0,0}e/
+    abe
+ 0: abe
+    *** Failers
+No match
+    abcde 
+No match
+    
+/ab(c){0,0}d/
+    abd
+ 0: abd
+    *** Failers
+No match
+    abcd   
+No match
+
+/a(b*)/
+    a
+ 0: a
+ 1: 
+    ab
+ 0: ab
+ 1: b
+    abbbb
+ 0: abbbb
+ 1: bbbb
+    *** Failers
+ 0: a
+ 1: 
+    bbbbb    
+No match
+    
+/ab[0-9]{0}e/
+    abe
+ 0: abe
+    *** Failers
+No match
+    ab1e   
+No match
+    
+/(A|B)*CD/
+    CD 
+ 0: CD
+
+/(AB)*\1/
+    ABABAB
+ 0: ABABAB
+ 1: AB
+    
+/([0-9]+)(\w)/
+    12345a
+ 0: 12345a
+ 1: 12345
+ 2: a
+    12345+ 
+ 0: 12345
+ 1: 1234
+ 2: 5
+
+/(abc|)+/
+    abc
+ 0: abc
+ 1: abc
+    abcabc
+ 0: abcabc
+ 1: abc
+    abcabcabc
+ 0: abcabcabc
+ 1: abc
+    xyz      
+ 0: 
+ 1: 
+
+/([a]*)*/
+    a
+ 0: a
+ 1: a
+    aaaaa 
+ 0: aaaaa
+ 1: aaaaa
+
+/([ab]*)*/
+    a
+ 0: a
+ 1: a
+    b
+ 0: b
+ 1: b
+    ababab
+ 0: ababab
+ 1: ababab
+    aaaabcde
+ 0: aaaab
+ 1: aaaab
+    bbbb    
+ 0: bbbb
+ 1: bbbb
+
+/([^a]*)*/
+    b
+ 0: b
+ 1: b
+    bbbb
+ 0: bbbb
+ 1: bbbb
+    aaa   
+ 0: 
+
+/([^ab]*)*/
+    cccc
+ 0: cccc
+ 1: cccc
+    abab  
+ 0: 
+
+/abc/
+    abc
+ 0: abc
+    xabcy
+ 0: abc
+    ababc
+ 0: abc
+    *** Failers
+No match
+    xbc
+No match
+    axc
+No match
+    abx
+No match
+
+/ab*c/
+    abc
+ 0: abc
+
+/ab*bc/
+    abc
+ 0: abc
+    abbc
+ 0: abbc
+    abbbbc
+ 0: abbbbc
+
+/.{1}/
+    abbbbc
+ 0: a
+
+/.{3,4}/
+    abbbbc
+ 0: abbb
+
+/ab{0,}bc/
+    abbbbc
+ 0: abbbbc
+
+/ab+bc/
+    abbc
+ 0: abbc
+    *** Failers
+No match
+    abc
+No match
+    abq
+No match
+
+/ab+bc/
+    abbbbc
+ 0: abbbbc
+
+/ab{1,}bc/
+    abbbbc
+ 0: abbbbc
+
+/ab{1,3}bc/
+    abbbbc
+ 0: abbbbc
+
+/ab{3,4}bc/
+    abbbbc
+ 0: abbbbc
+
+/ab{4,5}bc/
+    *** Failers
+No match
+    abq
+No match
+    abbbbc
+No match
+
+/ab?bc/
+    abbc
+ 0: abbc
+    abc
+ 0: abc
+
+/ab{0,1}bc/
+    abc
+ 0: abc
+
+/ab?c/
+    abc
+ 0: abc
+
+/ab{0,1}c/
+    abc
+ 0: abc
+
+/^abc$/
+    abc
+ 0: abc
+    *** Failers
+No match
+    abbbbc
+No match
+    abcc
+No match
+
+/^abc/
+    abcc
+ 0: abc
+
+/abc$/
+    aabc
+ 0: abc
+    *** Failers
+No match
+    aabc
+ 0: abc
+    aabcd
+No match
+
+/^/
+    abc
+ 0: 
+
+/$/
+    abc
+ 0: 
+
+/a.c/
+    abc
+ 0: abc
+    axc
+ 0: axc
+
+/a.*c/
+    axyzc
+ 0: axyzc
+
+/a[bc]d/
+    abd
+ 0: abd
+    *** Failers
+No match
+    axyzd
+No match
+    abc
+No match
+
+/a[b-d]e/
+    ace
+ 0: ace
+
+/a[b-d]/
+    aac
+ 0: ac
+
+/a[-b]/
+    a-
+ 0: a-
+
+/a[b-]/
+    a-
+ 0: a-
+
+/a[]]b/
+    a]b
+ 0: a]b
+
+/a[^bc]d/
+    aed
+ 0: aed
+    *** Failers
+No match
+    abd
+No match
+    abd
+No match
+
+/a[^-b]c/
+    adc
+ 0: adc
+
+/a[^]b]c/
+    adc
+ 0: adc
+    *** Failers
+No match
+    a-c
+ 0: a-c
+    a]c
+No match
+
+/\ba\b/
+    a-
+ 0: a
+    -a
+ 0: a
+    -a-
+ 0: a
+
+/\by\b/
+    *** Failers
+No match
+    xy
+No match
+    yz
+No match
+    xyz
+No match
+
+/\Ba\B/
+    *** Failers
+ 0: a
+    a-
+No match
+    -a
+No match
+    -a-
+No match
+
+/\By\b/
+    xy
+ 0: y
+
+/\by\B/
+    yz
+ 0: y
+
+/\By\B/
+    xyz
+ 0: y
+
+/\w/
+    a
+ 0: a
+
+/\W/
+    -
+ 0: -
+    *** Failers
+ 0: *
+    -
+ 0: -
+    a
+No match
+
+/a\sb/
+    a b
+ 0: a b
+
+/a\Sb/
+    a-b
+ 0: a-b
+    *** Failers
+No match
+    a-b
+ 0: a-b
+    a b
+No match
+
+/[0-9]/
+    1
+ 0: 1
+
+/[^0-9]/
+    -
+ 0: -
+    *** Failers
+ 0: *
+    -
+ 0: -
+    1
+No match
+
+/ab|cd/
+    abc
+ 0: ab
+    abcd
+ 0: ab
+
+/()ef/
+    def
+ 0: ef
+ 1: 
+
+/a\(b/
+    a(b
+ 0: a(b
+
+/a\(*b/
+    ab
+ 0: ab
+    a((b
+ 0: a((b
+
+/((a))/
+    abc
+ 0: a
+ 1: a
+ 2: a
+
+/(a)b(c)/
+    abc
+ 0: abc
+ 1: a
+ 2: c
+
+/a+b+c/
+    aabbabc
+ 0: abc
+
+/a{1,}b{1,}c/
+    aabbabc
+ 0: abc
+
+/(a+|b)*/
+    ab
+ 0: ab
+ 1: b
+
+/(a+|b){0,}/
+    ab
+ 0: ab
+ 1: b
+
+/(a+|b)+/
+    ab
+ 0: ab
+ 1: b
+
+/(a+|b){1,}/
+    ab
+ 0: ab
+ 1: b
+
+/(a+|b)?/
+    ab
+ 0: a
+ 1: a
+
+/(a+|b){0,1}/
+    ab
+ 0: a
+ 1: a
+
+/[^ab]*/
+    cde
+ 0: cde
+
+/abc/
+    *** Failers
+No match
+    b
+No match
+    
+
+/a*/
+    
+
+/([abc])*d/
+    abbbcd
+ 0: abbbcd
+ 1: c
+
+/([abc])*bcd/
+    abcd
+ 0: abcd
+ 1: a
+
+/a|b|c|d|e/
+    e
+ 0: e
+
+/(a|b|c|d|e)f/
+    ef
+ 0: ef
+ 1: e
+
+/abcd*efg/
+    abcdefg
+ 0: abcdefg
+
+/ab*/
+    xabyabbbz
+ 0: ab
+    xayabbbz
+ 0: a
+
+/(ab|cd)e/
+    abcde
+ 0: cde
+ 1: cd
+
+/[abhgefdc]ij/
+    hij
+ 0: hij
+
+/(abc|)ef/
+    abcdef
+ 0: ef
+ 1: 
+
+/(a|b)c*d/
+    abcd
+ 0: bcd
+ 1: b
+
+/(ab|ab*)bc/
+    abc
+ 0: abc
+ 1: a
+
+/a([bc]*)c*/
+    abc
+ 0: abc
+ 1: bc
+
+/a([bc]*)(c*d)/
+    abcd
+ 0: abcd
+ 1: bc
+ 2: d
+
+/a([bc]+)(c*d)/
+    abcd
+ 0: abcd
+ 1: bc
+ 2: d
+
+/a([bc]*)(c+d)/
+    abcd
+ 0: abcd
+ 1: b
+ 2: cd
+
+/a[bcd]*dcdcde/
+    adcdcde
+ 0: adcdcde
+
+/a[bcd]+dcdcde/
+    *** Failers
+No match
+    abcde
+No match
+    adcdcde
+No match
+
+/(ab|a)b*c/
+    abc
+ 0: abc
+ 1: ab
+
+/((a)(b)c)(d)/
+    abcd
+ 0: abcd
+ 1: abc
+ 2: a
+ 3: b
+ 4: d
+
+/[a-zA-Z_][a-zA-Z0-9_]*/
+    alpha
+ 0: alpha
+
+/^a(bc+|b[eh])g|.h$/
+    abh
+ 0: bh
+
+/(bc+d$|ef*g.|h?i(j|k))/
+    effgz
+ 0: effgz
+ 1: effgz
+    ij
+ 0: ij
+ 1: ij
+ 2: j
+    reffgz
+ 0: effgz
+ 1: effgz
+    *** Failers
+No match
+    effg
+No match
+    bcdd
+No match
+
+/((((((((((a))))))))))/
+    a
+ 0: a
+ 1: a
+ 2: a
+ 3: a
+ 4: a
+ 5: a
+ 6: a
+ 7: a
+ 8: a
+ 9: a
+10: a
+
+/((((((((((a))))))))))\9/
+    aa
+ 0: aa
+ 1: a
+ 2: a
+ 3: a
+ 4: a
+ 5: a
+ 6: a
+ 7: a
+ 8: a
+ 9: a
+10: a
+
+/(((((((((a)))))))))/
+    a
+ 0: a
+ 1: a
+ 2: a
+ 3: a
+ 4: a
+ 5: a
+ 6: a
+ 7: a
+ 8: a
+ 9: a
+
+/multiple words of text/
+    *** Failers
+No match
+    aa
+No match
+    uh-uh
+No match
+
+/multiple words/
+    multiple words, yeah
+ 0: multiple words
+
+/(.*)c(.*)/
+    abcde
+ 0: abcde
+ 1: ab
+ 2: de
+
+/\((.*), (.*)\)/
+    (a, b)
+ 0: (a, b)
+ 1: a
+ 2: b
+
+/abcd/
+    abcd
+ 0: abcd
+
+/a(bc)d/
+    abcd
+ 0: abcd
+ 1: bc
+
+/a[-]?c/
+    ac
+ 0: ac
+
+/(abc)\1/
+    abcabc
+ 0: abcabc
+ 1: abc
+
+/([a-c]*)\1/
+    abcabc
+ 0: abcabc
+ 1: abc
+
+/(a)|\1/
+    a
+ 0: a
+ 1: a
+    *** Failers
+ 0: a
+ 1: a
+    ab
+ 0: a
+ 1: a
+    x
+No match
+
+/abc/i
+    ABC
+ 0: ABC
+    XABCY
+ 0: ABC
+    ABABC
+ 0: ABC
+    *** Failers
+No match
+    aaxabxbaxbbx
+No match
+    XBC
+No match
+    AXC
+No match
+    ABX
+No match
+
+/ab*c/i
+    ABC
+ 0: ABC
+
+/ab*bc/i
+    ABC
+ 0: ABC
+    ABBC
+ 0: ABBC
+
+/ab+bc/i
+    *** Failers
+No match
+    ABC
+No match
+    ABQ
+No match
+
+/ab+bc/i
+    ABBBBC
+ 0: ABBBBC
+
+/^abc$/i
+    ABC
+ 0: ABC
+    *** Failers
+No match
+    ABBBBC
+No match
+    ABCC
+No match
+
+/^abc/i
+    ABCC
+ 0: ABC
+
+/abc$/i
+    AABC
+ 0: ABC
+
+/^/i
+    ABC
+ 0: 
+
+/$/i
+    ABC
+ 0: 
+
+/a.c/i
+    ABC
+ 0: ABC
+    AXC
+ 0: AXC
+
+/a.*c/i
+    *** Failers
+No match
+    AABC
+ 0: AABC
+    AXYZD
+No match
+
+/a[bc]d/i
+    ABD
+ 0: ABD
+
+/a[b-d]e/i
+    ACE
+ 0: ACE
+    *** Failers
+No match
+    ABC
+No match
+    ABD
+No match
+
+/a[b-d]/i
+    AAC
+ 0: AC
+
+/a[-b]/i
+    A-
+ 0: A-
+
+/a[b-]/i
+    A-
+ 0: A-
+
+/a[]]b/i
+    A]B
+ 0: A]B
+
+/a[^bc]d/i
+    AED
+ 0: AED
+
+/a[^-b]c/i
+    ADC
+ 0: ADC
+    *** Failers
+No match
+    ABD
+No match
+    A-C
+No match
+
+/a[^]b]c/i
+    ADC
+ 0: ADC
+
+/ab|cd/i
+    ABC
+ 0: AB
+    ABCD
+ 0: AB
+
+/()ef/i
+    DEF
+ 0: EF
+ 1: 
+
+/$b/i
+    *** Failers
+No match
+    A]C
+No match
+    B
+No match
+
+/a\(b/i
+    A(B
+ 0: A(B
+
+/a\(*b/i
+    AB
+ 0: AB
+    A((B
+ 0: A((B
+
+/((a))/i
+    ABC
+ 0: A
+ 1: A
+ 2: A
+
+/(a)b(c)/i
+    ABC
+ 0: ABC
+ 1: A
+ 2: C
+
+/a+b+c/i
+    AABBABC
+ 0: ABC
+
+/a{1,}b{1,}c/i
+    AABBABC
+ 0: ABC
+
+/(a+|b)*/i
+    AB
+ 0: AB
+ 1: B
+
+/(a+|b){0,}/i
+    AB
+ 0: AB
+ 1: B
+
+/(a+|b)+/i
+    AB
+ 0: AB
+ 1: B
+
+/(a+|b){1,}/i
+    AB
+ 0: AB
+ 1: B
+
+/(a+|b)?/i
+    AB
+ 0: A
+ 1: A
+
+/(a+|b){0,1}/i
+    AB
+ 0: A
+ 1: A
+
+/[^ab]*/i
+    CDE
+ 0: CDE
+
+/([abc])*d/i
+    ABBBCD
+ 0: ABBBCD
+ 1: C
+
+/([abc])*bcd/i
+    ABCD
+ 0: ABCD
+ 1: A
+
+/a|b|c|d|e/i
+    E
+ 0: E
+
+/(a|b|c|d|e)f/i
+    EF
+ 0: EF
+ 1: E
+
+/abcd*efg/i
+    ABCDEFG
+ 0: ABCDEFG
+
+/ab*/i
+    XABYABBBZ
+ 0: AB
+    XAYABBBZ
+ 0: A
+
+/(ab|cd)e/i
+    ABCDE
+ 0: CDE
+ 1: CD
+
+/[abhgefdc]ij/i
+    HIJ
+ 0: HIJ
+
+/^(ab|cd)e/i
+    ABCDE
+No match
+
+/(abc|)ef/i
+    ABCDEF
+ 0: EF
+ 1: 
+
+/(a|b)c*d/i
+    ABCD
+ 0: BCD
+ 1: B
+
+/(ab|ab*)bc/i
+    ABC
+ 0: ABC
+ 1: A
+
+/a([bc]*)c*/i
+    ABC
+ 0: ABC
+ 1: BC
+
+/a([bc]*)(c*d)/i
+    ABCD
+ 0: ABCD
+ 1: BC
+ 2: D
+
+/a([bc]+)(c*d)/i
+    ABCD
+ 0: ABCD
+ 1: BC
+ 2: D
+
+/a([bc]*)(c+d)/i
+    ABCD
+ 0: ABCD
+ 1: B
+ 2: CD
+
+/a[bcd]*dcdcde/i
+    ADCDCDE
+ 0: ADCDCDE
+
+/a[bcd]+dcdcde/i
+
+/(ab|a)b*c/i
+    ABC
+ 0: ABC
+ 1: AB
+
+/((a)(b)c)(d)/i
+    ABCD
+ 0: ABCD
+ 1: ABC
+ 2: A
+ 3: B
+ 4: D
+
+/[a-zA-Z_][a-zA-Z0-9_]*/i
+    ALPHA
+ 0: ALPHA
+
+/^a(bc+|b[eh])g|.h$/i
+    ABH
+ 0: BH
+
+/(bc+d$|ef*g.|h?i(j|k))/i
+    EFFGZ
+ 0: EFFGZ
+ 1: EFFGZ
+    IJ
+ 0: IJ
+ 1: IJ
+ 2: J
+    REFFGZ
+ 0: EFFGZ
+ 1: EFFGZ
+    *** Failers
+No match
+    ADCDCDE
+No match
+    EFFG
+No match
+    BCDD
+No match
+
+/((((((((((a))))))))))/i
+    A
+ 0: A
+ 1: A
+ 2: A
+ 3: A
+ 4: A
+ 5: A
+ 6: A
+ 7: A
+ 8: A
+ 9: A
+10: A
+
+/((((((((((a))))))))))\9/i
+    AA
+ 0: AA
+ 1: A
+ 2: A
+ 3: A
+ 4: A
+ 5: A
+ 6: A
+ 7: A
+ 8: A
+ 9: A
+10: A
+
+/(((((((((a)))))))))/i
+    A
+ 0: A
+ 1: A
+ 2: A
+ 3: A
+ 4: A
+ 5: A
+ 6: A
+ 7: A
+ 8: A
+ 9: A
+
+/multiple words of text/i
+    *** Failers
+No match
+    AA
+No match
+    UH-UH
+No match
+
+/multiple words/i
+    MULTIPLE WORDS, YEAH
+ 0: MULTIPLE WORDS
+
+/(.*)c(.*)/i
+    ABCDE
+ 0: ABCDE
+ 1: AB
+ 2: DE
+
+/\((.*), (.*)\)/i
+    (A, B)
+ 0: (A, B)
+ 1: A
+ 2: B
+
+/abcd/i
+    ABCD
+ 0: ABCD
+
+/a(bc)d/i
+    ABCD
+ 0: ABCD
+ 1: BC
+
+/a[-]?c/i
+    AC
+ 0: AC
+
+/(abc)\1/i
+    ABCABC
+ 0: ABCABC
+ 1: ABC
+
+/([a-c]*)\1/i
+    ABCABC
+ 0: ABCABC
+ 1: ABC
+
+/((foo)|(bar))*/
+    foobar
+ 0: foobar
+ 1: bar
+ 2: foo
+ 3: bar
+
+/^(.+)?B/
+    AB
+ 0: AB
+ 1: A
+
+/^([^a-z])|(\^)$/
+    .
+ 0: .
+ 1: .
+
+/^[<>]&/
+    <&OUT
+ 0: <&
+
+/^(){3,5}/
+    abc
+ 0: 
+ 1: 
+
+/^(a+)*ax/
+    aax
+ 0: aax
+ 1: a
+
+/^((a|b)+)*ax/
+    aax
+ 0: aax
+ 1: a
+ 2: a
+
+/^((a|bc)+)*ax/
+    aax
+ 0: aax
+ 1: a
+ 2: a
+
+/(a|x)*ab/
+    cab
+ 0: ab
+
+/(a)*ab/
+    cab
+ 0: ab
+
+/(ab)[0-9]\1/i
+    Ab4ab
+ 0: Ab4ab
+ 1: Ab
+    ab4Ab
+ 0: ab4Ab
+ 1: ab
+
+/foo\w*[0-9]{4}baz/
+    foobar1234baz
+ 0: foobar1234baz
+
+/(\w+:)+/
+    one:
+ 0: one:
+ 1: one:
+
+/((\w|:)+::)?(\w+)$/
+    abcd
+ 0: abcd
+ 1: <unset>
+ 2: <unset>
+ 3: abcd
+    xy:z:::abcd
+ 0: xy:z:::abcd
+ 1: xy:z:::
+ 2: :
+ 3: abcd
+
+/^[^bcd]*(c+)/
+    aexycd
+ 0: aexyc
+ 1: c
+
+/(a*)b+/
+    caab
+ 0: aab
+ 1: aa
+
+/((\w|:)+::)?(\w+)$/
+    abcd
+ 0: abcd
+ 1: <unset>
+ 2: <unset>
+ 3: abcd
+    xy:z:::abcd
+ 0: xy:z:::abcd
+ 1: xy:z:::
+ 2: :
+ 3: abcd
+    *** Failers
+ 0: Failers
+ 1: <unset>
+ 2: <unset>
+ 3: Failers
+    abcd:
+No match
+    abcd:
+No match
+
+/^[^bcd]*(c+)/
+    aexycd
+ 0: aexyc
+ 1: c
+
+/((Z)+|A)*/
+    ZABCDEFG
+ 0: ZA
+ 1: A
+ 2: Z
+
+/(Z()|A)*/
+    ZABCDEFG
+ 0: ZA
+ 1: A
+ 2: 
+
+/(Z(())|A)*/
+    ZABCDEFG
+ 0: ZA
+ 1: A
+ 2: 
+ 3: 
+
+/(.*)[0-9]+\1/
+    abc123abc
+ 0: abc123abc
+ 1: abc
+    abc123bc 
+ 0: bc123bc
+ 1: bc
+
+/((.*))[0-9]+\1/
+    abc123abc
+ 0: abc123abc
+ 1: abc
+ 2: abc
+    abc123bc  
+ 0: bc123bc
+ 1: bc
+ 2: bc
+
+/^a{2,5}$/
+    aa
+ 0: aa
+    aaa
+ 0: aaa
+    aaaa
+ 0: aaaa
+    aaaaa
+ 0: aaaaa
+    *** Failers
+No match
+    a
+No match
+    b
+No match
+    aaaaab
+No match
+    aaaaaa
Index: trunk/src/libctests/glibc/posix/bug-ga1.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-ga1.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-ga1.c	(revision 2036)
@@ -0,0 +1,23 @@
+/* Test case by Anders Carlsson <andersca@gnome.org>.  */
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <stdio.h>
+#include <string.h>
+
+int
+main (void)
+{
+  struct addrinfo req, *ai;
+  char name[] = "3ffe:0200:0064:0000:0202:b3ff:fe16:ddc5";
+
+  memset (&req, '\0', sizeof req);
+  req.ai_family = AF_INET6;
+
+  /* This call used to crash.  We cannot expect the test machine to have
+     IPv6 enabled so we just check that the call returns.  */
+  getaddrinfo (name, NULL, &req, &ai);
+
+  puts ("success!");
+  return 0;
+}
Index: trunk/src/libctests/glibc/posix/bug-ga2.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-ga2.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-ga2.c	(revision 2036)
@@ -0,0 +1,30 @@
+/* Test case by Sam Varshavchik <mrsam@courier-mta.com>.  */
+#include <mcheck.h>
+#include <netdb.h>
+#include <stdio.h>
+#include <string.h>
+
+int
+main (void)
+{
+  struct addrinfo hints, *res;
+  int i, ret;
+
+  mtrace ();
+  for (i = 0; i < 100; i++)
+    {
+      memset (&hints, 0, sizeof (hints));
+      hints.ai_family = PF_UNSPEC;
+      hints.ai_socktype = SOCK_STREAM;
+
+      ret = getaddrinfo ("www.gnu.org", "http", &hints, &res);
+
+      if (ret)
+	{
+	  printf ("%s\n", gai_strerror (ret));
+	  return 1;
+	}
+      freeaddrinfo (res);
+    }
+  return 0;
+}
Index: trunk/src/libctests/glibc/posix/bug-glob1.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-glob1.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-glob1.c	(revision 2036)
@@ -0,0 +1,88 @@
+/* Test case for globbing dangling symlink.  By Ulrich Drepper.  */
+#include <errno.h>
+#include <error.h>
+#include <glob.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static void prepare (int argc, char *argv[]);
+#define PREPARE prepare
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+
+#include "../test-skeleton.c"
+
+
+static char *fname;
+
+static void
+prepare (int argc, char *argv[])
+{
+  if (argc < 2)
+    error (EXIT_FAILURE, 0, "missing argument");
+
+  size_t len = strlen (argv[1]);
+  static const char ext[] = "globXXXXXX";
+  fname = malloc (len + sizeof (ext));
+  if (fname == NULL)
+    error (EXIT_FAILURE, errno, "cannot create temp file");
+ again:
+  strcpy (stpcpy (fname, argv[1]), ext);
+  fname = mktemp (fname);
+  if (fname == NULL || *fname == '\0')
+    error (EXIT_FAILURE, errno, "cannot create temp file name");
+  if (symlink ("bug-glob1-does-not-exist", fname) != 0)
+    {
+      if (errno == EEXIST)
+	goto again;
+
+      error (EXIT_FAILURE, errno, "cannot create symlink");
+    }
+  add_temp_file (fname);
+}
+
+
+static int
+do_test (void)
+{
+  glob_t gl;
+  int retval = 0;
+  int e;
+
+  e = glob (fname, 0, NULL, &gl);
+  if (e == 0)
+    {
+      printf ("glob(\"%s\") succeeded\n", fname);
+      retval = 1;
+    }
+  globfree (&gl);
+
+  size_t fnamelen = strlen (fname);
+  char buf[fnamelen + 2];
+
+  strcpy (buf, fname);
+  buf[fnamelen - 1] = '?';
+  e = glob (buf, 0, NULL, &gl);
+  if (e == 0)
+    {
+      printf ("glob(\"%s\") succeeded\n", buf);
+      retval = 1;
+    }
+  globfree (&gl);
+
+  strcpy (buf, fname);
+  buf[fnamelen] = '*';
+  buf[fnamelen + 1] = '\0';
+  e = glob (buf, 0, NULL, &gl);
+  if (e == 0)
+    {
+      printf ("glob(\"%s\") succeeded\n", buf);
+      retval = 1;
+    }
+  globfree (&gl);
+
+  return retval;
+}
Index: trunk/src/libctests/glibc/posix/bug-glob2.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-glob2.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-glob2.c	(revision 2036)
@@ -0,0 +1,303 @@
+/* Test glob memory management.
+   for the filesystem access functions.
+   Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <error.h>
+#include <dirent.h>
+#include <glob.h>
+#include <mcheck.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+
+// #define DEBUG
+#ifdef DEBUG
+# define PRINTF(fmt, args...) \
+  do					\
+    {					\
+      int save_errno = errno;		\
+      printf (fmt, ##args);		\
+      errno = save_errno;		\
+    } while (0)
+#else
+# define PRINTF(fmt, args...)
+#endif
+
+
+static struct
+{
+  const char *name;
+  int level;
+  int type;
+  mode_t mode;
+} filesystem[] =
+{
+  { ".", 1, DT_DIR, 0755 },
+  { "..", 1, DT_DIR, 0755 },
+  { "dir", 1, DT_DIR, 0755 },
+    { ".", 2, DT_DIR, 0755 },
+    { "..", 2, DT_DIR, 0755 },
+    { "readable", 2, DT_DIR, 0755 },
+      { ".", 3, DT_DIR, 0755 },
+      { "..", 3, DT_DIR, 0755 },
+      { "a", 3, DT_REG, 0644 },
+    { "unreadable", 2, DT_DIR, 0111 },
+      { ".", 3, DT_DIR, 0111 },
+      { "..", 3, DT_DIR, 0755 },
+      { "a", 3, DT_REG, 0644 },
+    { "zz-readable", 2, DT_DIR, 0755 },
+      { ".", 3, DT_DIR, 0755 },
+      { "..", 3, DT_DIR, 0755 },
+      { "a", 3, DT_REG, 0644 }
+};
+#define nfiles (sizeof (filesystem) / sizeof (filesystem[0]))
+
+
+typedef struct
+{
+  int level;
+  int idx;
+  struct dirent d;
+  char room_for_dirent[NAME_MAX];
+} my_DIR;
+
+
+static long int
+find_file (const char *s)
+{
+  int level = 1;
+  long int idx = 0;
+
+  if (strcmp (s, ".") == 0)
+    return 0;
+
+  if (s[0] == '.' && s[1] == '/')
+    s += 2;
+
+  while (*s != '\0')
+    {
+      char *endp = strchrnul (s, '/');
+
+      PRINTF ("looking for %.*s, level %d\n", (int) (endp - s), s, level);
+
+      while (idx < nfiles && filesystem[idx].level >= level)
+	{
+	  if (filesystem[idx].level == level
+	      && memcmp (s, filesystem[idx].name, endp - s) == 0
+	      && filesystem[idx].name[endp - s] == '\0')
+	    break;
+	  ++idx;
+	}
+
+      if (idx == nfiles || filesystem[idx].level < level)
+	{
+	  errno = ENOENT;
+	  return -1;
+	}
+
+      if (*endp == '\0')
+	return idx + 1;
+
+      if (filesystem[idx].type != DT_DIR
+	  && (idx + 1 >= nfiles
+	      || filesystem[idx].level >= filesystem[idx + 1].level))
+	{
+	  errno = ENOTDIR;
+	  return -1;
+	}
+
+      ++idx;
+
+      s = endp + 1;
+      ++level;
+    }
+
+  errno = ENOENT;
+  return -1;
+}
+
+
+static void *
+my_opendir (const char *s)
+{
+  long int idx = find_file (s);
+  my_DIR *dir;
+
+  if (idx == -1)
+    {
+      PRINTF ("my_opendir(\"%s\") == NULL (%m)\n", s);
+      return NULL;
+    }
+
+  if ((filesystem[idx].mode & 0400) == 0)
+    {
+      errno = EACCES;
+      PRINTF ("my_opendir(\"%s\") == NULL (%m)\n", s);
+      return NULL;
+    }
+
+  dir = (my_DIR *) malloc (sizeof (my_DIR));
+  if (dir == NULL)
+    {
+      printf ("cannot allocate directory handle: %m\n");
+      exit (EXIT_FAILURE);
+    }
+
+  dir->level = filesystem[idx].level;
+  dir->idx = idx;
+
+  PRINTF ("my_opendir(\"%s\") == { level: %d, idx: %ld }\n",
+	  s, filesystem[idx].level, idx);
+
+  return dir;
+}
+
+
+static struct dirent *
+my_readdir (void *gdir)
+{
+  my_DIR *dir = gdir;
+
+  if (dir->idx == -1)
+    {
+      PRINTF ("my_readdir ({ level: %d, idx: %ld }) = NULL\n",
+	      dir->level, (long int) dir->idx);
+      return NULL;
+    }
+
+  while (dir->idx < nfiles && filesystem[dir->idx].level > dir->level)
+    ++dir->idx;
+
+  if (dir->idx == nfiles || filesystem[dir->idx].level < dir->level)
+    {
+      dir->idx = -1;
+      PRINTF ("my_readdir ({ level: %d, idx: %ld }) = NULL\n",
+	      dir->level, (long int) dir->idx);
+      return NULL;
+    }
+
+  dir->d.d_ino = dir->idx;
+
+#ifdef _DIRENT_HAVE_D_TYPE
+  dir->d.d_type = filesystem[dir->idx].type;
+#endif
+
+  strcpy (dir->d.d_name, filesystem[dir->idx].name);
+
+#ifdef _DIRENT_HAVE_D_TYPE
+  PRINTF ("my_readdir ({ level: %d, idx: %ld }) = { d_ino: %ld, d_type: %d, d_name: \"%s\" }\n",
+	  dir->level, (long int) dir->idx, dir->d.d_ino, dir->d.d_type,
+	  dir->d.d_name);
+#else
+  PRINTF ("my_readdir ({ level: %d, idx: %ld }) = { d_ino: %ld, d_name: \"%s\" }\n",
+	  dir->level, (long int) dir->idx, dir->d.d_ino,
+	  dir->d.d_name);
+#endif
+
+  ++dir->idx;
+
+  return &dir->d;
+}
+
+
+static void
+my_closedir (void *dir)
+{
+  PRINTF ("my_closedir ()\n");
+  free (dir);
+}
+
+
+/* We use this function for lstat as well since we don't have any.  */
+static int
+my_stat (const char *name, struct stat *st)
+{
+  long int idx = find_file (name);
+
+  if (idx == -1)
+    {
+      PRINTF ("my_stat (\"%s\", ...) = -1 (%m)\n", name);
+      return -1;
+    }
+
+  memset (st, '\0', sizeof (*st));
+
+  if (filesystem[idx].type == DT_UNKNOWN)
+    st->st_mode = DTTOIF (idx + 1 < nfiles
+			  && filesystem[idx].level < filesystem[idx + 1].level
+			  ? DT_DIR : DT_REG) | filesystem[idx].mode;
+  else
+    st->st_mode = DTTOIF (filesystem[idx].type) | filesystem[idx].mode;
+
+  PRINTF ("my_stat (\"%s\", { st_mode: %o }) = 0\n", name, st->st_mode);
+
+  return 0;
+}
+
+
+static void
+init_glob_altdirfuncs (glob_t *pglob)
+{
+  pglob->gl_closedir = my_closedir;
+  pglob->gl_readdir = my_readdir;
+  pglob->gl_opendir = my_opendir;
+  pglob->gl_lstat = my_stat;
+  pglob->gl_stat = my_stat;
+}
+
+
+int
+do_test (void)
+{
+  mtrace ();
+
+  glob_t gl;
+  memset (&gl, 0, sizeof (gl));
+  init_glob_altdirfuncs (&gl);
+
+  if (glob ("dir/*able/*", GLOB_ERR | GLOB_ALTDIRFUNC, NULL, &gl)
+      != GLOB_ABORTED)
+    {
+      puts ("glob did not fail with GLOB_ABORTED");
+      exit (EXIT_FAILURE); 
+    }
+
+  globfree (&gl);
+
+  memset (&gl, 0, sizeof (gl));
+  init_glob_altdirfuncs (&gl);
+
+  gl.gl_offs = 3;
+  if (glob ("dir2/*", GLOB_DOOFFS, NULL, &gl) != GLOB_NOMATCH)
+    {
+      puts ("glob did not fail with GLOB_NOMATCH");
+      exit (EXIT_FAILURE); 
+    }
+
+  globfree (&gl);
+
+  muntrace ();
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/posix/bug-regex1.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-regex1.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-regex1.c	(revision 2036)
@@ -0,0 +1,65 @@
+/* Test case by Jim Meyering <jim@meyering.net>.  */
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+#include <regex.h>
+#include <wchar.h>
+
+int
+main (void)
+{
+  struct re_pattern_buffer regex;
+  struct re_registers regs;
+  const char *s;
+  int match;
+  int result = 0;
+
+  memset (&regex, '\0', sizeof (regex));
+
+  setlocale (LC_ALL, "de_DE.ISO-8859-1");
+  fwide (stdout, -1);
+
+  re_set_syntax (RE_SYNTAX_POSIX_EGREP | RE_DEBUG);
+
+  puts ("in C locale");
+  setlocale (LC_ALL, "C");
+  s = re_compile_pattern ("[anù]*n", 7, &regex);
+  if (s != NULL)
+    {
+      puts ("re_compile_pattern return non-NULL value");
+      result = 1;
+    }
+  else
+    {
+      match = re_match (&regex, "an", 2, 0, &regs);
+      if (match != 2)
+	{
+	  printf ("re_match returned %d, expected 2\n", match);
+	  result = 1;
+	}
+      else
+	puts (" -> OK");
+    }
+
+  puts ("in de_DE.ISO-8859-1 locale");
+  setlocale (LC_ALL, "de_DE.ISO-8859-1");
+  s = re_compile_pattern ("[anù]*n", 7, &regex);
+  if (s != NULL)
+    {
+      puts ("re_compile_pattern return non-NULL value");
+      result = 1;
+    }
+  else
+    {
+      match = re_match (&regex, "an", 2, 0, &regs);
+      if (match != 2)
+	{
+	  printf ("re_match returned %d, expected 2\n", match);
+	  result = 1;
+	}
+      else
+	puts (" -> OK");
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/posix/bug-regex10.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-regex10.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-regex10.c	(revision 2036)
@@ -0,0 +1,61 @@
+/* Test for re_match with non-zero start.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+#include <regex.h>
+
+int
+main (void)
+{
+  struct re_pattern_buffer regex;
+  struct re_registers regs;
+  const char *s;
+  int match;
+  int result = 0;
+
+  regs.num_regs = 1;
+  memset (&regex, '\0', sizeof (regex));
+  s = re_compile_pattern ("[abc]*d", 7, &regex);
+  if (s != NULL)
+    {
+      puts ("re_compile_pattern return non-NULL value");
+      result = 1;
+    }
+  else
+    {
+      match = re_match (&regex, "foacabdxy", 9, 2, &regs);
+      if (match != 5)
+	{
+	  printf ("re_match returned %d, expected 5\n", match);
+	  result = 1;
+	}
+      else if (regs.start[0] != 2 || regs.end[0] != 7)
+	{
+	  printf ("re_match returned %d..%d, expected 2..7\n",
+		  regs.start[0], regs.end[0]);
+	  result = 1;
+	}
+	puts (" -> OK");
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/posix/bug-regex11.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-regex11.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-regex11.c	(revision 2036)
@@ -0,0 +1,139 @@
+/* Regular expression tests.
+   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sys/types.h>
+#include <mcheck.h>
+#include <regex.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/* Tests supposed to match.  */
+struct
+{
+  const char *pattern;
+  const char *string;
+  int flags, nmatch;
+  regmatch_t rm[5];
+} tests[] = {
+  /* Test for newline handling in regex.  */
+  { "[^~]*~", "\nx~y", 0, 2, { { 0, 3 }, { -1, -1 } } },
+  /* Other tests.  */
+  { "a(.*)b", "a b", REG_EXTENDED, 2, { { 0, 3 }, { 1, 2 } } },
+  { ".*|\\([KIO]\\)\\([^|]*\\).*|?[KIO]", "10~.~|P|K0|I10|O16|?KSb", 0, 3,
+    { { 0, 21 }, { 15, 16 }, { 16, 18 } } },
+  { ".*|\\([KIO]\\)\\([^|]*\\).*|?\\1", "10~.~|P|K0|I10|O16|?KSb", 0, 3,
+    { { 0, 21 }, { 8, 9 }, { 9, 10 } } },
+  { "^\\(a*\\)\\1\\{9\\}\\(a\\{0,9\\}\\)\\([0-9]*;.*[^a]\\2\\([0-9]\\)\\)",
+    "a1;;0a1aa2aaa3aaaa4aaaaa5aaaaaa6aaaaaaa7aaaaaaaa8aaaaaaaaa9aa2aa1a0", 0,
+    5, { { 0, 67 }, { 0, 0 }, { 0, 1 }, { 1, 67 }, { 66, 67 } } },
+  /* Test for BRE expression anchoring.  POSIX says just that this may match;
+     in glibc regex it always matched, so avoid changing it.  */
+  { "\\(^\\|foo\\)bar", "bar", 0, 2, { { 0, 3 }, { -1, -1 } } },
+  { "\\(foo\\|^\\)bar", "bar", 0, 2, { { 0, 3 }, { -1, -1 } } },
+  /* In ERE this must be treated as an anchor.  */
+  { "(^|foo)bar", "bar", REG_EXTENDED, 2, { { 0, 3 }, { -1, -1 } } },
+  { "(foo|^)bar", "bar", REG_EXTENDED, 2, { { 0, 3 }, { -1, -1 } } },
+  /* Here ^ cannot be treated as an anchor according to POSIX.  */
+  { "(^|foo)bar", "(^|foo)bar", 0, 2, { { 0, 10 }, { -1, -1 } } },
+  { "(foo|^)bar", "(foo|^)bar", 0, 2, { { 0, 10 }, { -1, -1 } } },
+  /* More tests on backreferences.  */
+  { "()\\1", "x", REG_EXTENDED, 2, { { 0, 0 }, { 0, 0 } } },
+  { "()x\\1", "x", REG_EXTENDED, 2, { { 0, 1 }, { 0, 0 } } },
+  { "()\\1*\\1*", "", REG_EXTENDED, 2, { { 0, 0 }, { 0, 0 } } },
+  { "([0-9]).*\\1(a*)", "7;7a6", REG_EXTENDED, 3, { { 0, 4 }, { 0, 1 }, { 3, 4 } } },
+  { "([0-9]).*\\1(a*)", "7;7a", REG_EXTENDED, 3, { { 0, 4 }, { 0, 1 }, { 3, 4 } } },
+  { "(b)()c\\1", "bcb", REG_EXTENDED, 3, { { 0, 3 }, { 0, 1 }, { 1, 1 } } },
+  { "()(b)c\\2", "bcb", REG_EXTENDED, 3, { { 0, 3 }, { 0, 0 }, { 0, 1 } } },
+  { "a(b)()c\\1", "abcb", REG_EXTENDED, 3, { { 0, 4 }, { 1, 2 }, { 2, 2 } } },
+  { "a()(b)c\\2", "abcb", REG_EXTENDED, 3, { { 0, 4 }, { 1, 1 }, { 1, 2 } } },
+  { "()(b)\\1c\\2", "bcb", REG_EXTENDED, 3, { { 0, 3 }, { 0, 0 }, { 0, 1 } } },
+  { "(b())\\2\\1", "bbbb", REG_EXTENDED, 3, { { 0, 2 }, { 0, 1 }, { 1, 1 } } },
+  { "a()(b)\\1c\\2", "abcb", REG_EXTENDED, 3, { { 0, 4 }, { 1, 1 }, { 1, 2 } } },
+  { "a()d(b)\\1c\\2", "adbcb", REG_EXTENDED, 3, { { 0, 5 }, { 1, 1 }, { 2, 3 } } },
+  { "a(b())\\2\\1", "abbbb", REG_EXTENDED, 3, { { 0, 3 }, { 1, 2 }, { 2, 2 } } },
+  { "(bb())\\2\\1", "bbbb", REG_EXTENDED, 3, { { 0, 4 }, { 0, 2 }, { 2, 2 } } },
+  { "^([^,]*),\\1,\\1$", "a,a,a", REG_EXTENDED, 2, { { 0, 5 }, { 0, 1 } } },
+  { "^([^,]*),\\1,\\1$", "ab,ab,ab", REG_EXTENDED, 2, { { 0, 8 }, { 0, 2 } } },
+  { "^([^,]*),\\1,\\1,\\1$", "abc,abc,abc,abc", REG_EXTENDED, 2,
+    { { 0, 15 }, { 0, 3 } } },
+  { "^(.?)(.?)(.?)(.?)(.?).?\\5\\4\\3\\2\\1$",
+    "level", REG_NOSUB | REG_EXTENDED, 0, { { -1, -1 } } },
+  { "^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.).?\\9\\8\\7\\6\\5\\4\\3\\2\\1$|^.?$",
+    "level", REG_NOSUB | REG_EXTENDED, 0, { { -1, -1 } } },
+  { "^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.).?\\9\\8\\7\\6\\5\\4\\3\\2\\1$|^.?$",
+    "abcdedcba", REG_EXTENDED, 1, { { 0, 9 } } },
+#if 0
+  /* XXX Not used since they fail so far.  */
+  { "^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.).?\\9\\8\\7\\6\\5\\4\\3\\2\\1$|^.?$",
+    "ababababa", REG_EXTENDED, 1, { { 0, 9 } } },
+  { "^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?).?\\9\\8\\7\\6\\5\\4\\3\\2\\1$",
+    "level", REG_NOSUB | REG_EXTENDED, 0, { { -1, -1 } } },
+  { "^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?).?\\9\\8\\7\\6\\5\\4\\3\\2\\1$",
+    "ababababa", REG_EXTENDED, 1, { { 0, 9 } } },
+#endif
+};
+
+int
+main (void)
+{
+  regex_t re;
+  regmatch_t rm[5];
+  size_t i;
+  int n, ret = 0;
+
+  mtrace ();
+
+  for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
+    {
+      n = regcomp (&re, tests[i].pattern, tests[i].flags);
+      if (n != 0)
+	{
+	  char buf[500];
+	  regerror (n, &re, buf, sizeof (buf));
+	  printf ("%s: regcomp %zd failed: %s\n", tests[i].pattern, i, buf);
+	  ret = 1;
+	  continue;
+	}
+
+      if (regexec (&re, tests[i].string, tests[i].nmatch, rm, 0))
+	{
+	  printf ("%s: regexec %zd failed\n", tests[i].pattern, i);
+	  ret = 1;
+	  regfree (&re);
+	  continue;
+	}
+
+      for (n = 0; n < tests[i].nmatch; ++n)
+	if (rm[n].rm_so != tests[i].rm[n].rm_so
+              || rm[n].rm_eo != tests[i].rm[n].rm_eo)
+	  {
+	    if (tests[i].rm[n].rm_so == -1 && tests[i].rm[n].rm_eo == -1)
+	      break;
+	    printf ("%s: regexec %zd match failure rm[%d] %d..%d\n",
+		    tests[i].pattern, i, n, rm[n].rm_so, rm[n].rm_eo);
+	    ret = 1;
+	    break;
+	  }
+
+      regfree (&re);
+    }
+
+  return ret;
+}
Index: trunk/src/libctests/glibc/posix/bug-regex12.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-regex12.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-regex12.c	(revision 2036)
@@ -0,0 +1,73 @@
+/* Regular expression tests.
+   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sys/types.h>
+#include <mcheck.h>
+#include <regex.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/* Tests supposed to not match.  */
+struct
+{
+  const char *pattern;
+  const char *string;
+  int flags, nmatch;
+} tests[] = {
+  { "^<\\([^~]*\\)\\([^~]\\)[^~]*~\\1\\(.\\).*|=.*\\3.*\\2",
+    "<,.8~2,~so-|=-~.0,123456789<><", REG_NOSUB, 0 },
+  /* In ERE, all carets must be treated as anchors.  */
+  { "a^b", "a^b", REG_EXTENDED, 0 }
+};
+
+int
+main (void)
+{
+  regex_t re;
+  regmatch_t rm[4];
+  size_t i;
+  int n, ret = 0;
+
+  mtrace ();
+
+  for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
+    {
+      n = regcomp (&re, tests[i].pattern, tests[i].flags);
+      if (n != 0)
+	{
+	  char buf[500];
+	  regerror (n, &re, buf, sizeof (buf));
+	  printf ("regcomp %zd failed: %s\n", i, buf);
+	  ret = 1;
+	  continue;
+	}
+
+      if (! regexec (&re, tests[i].string, tests[i].nmatch,
+		     tests[i].nmatch ? rm : NULL, 0))
+	{
+	  printf ("regexec %zd incorrectly matched\n", i);
+	  ret = 1;
+	}
+
+      regfree (&re);
+    }
+
+  return ret;
+}
Index: trunk/src/libctests/glibc/posix/bug-regex13.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-regex13.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-regex13.c	(revision 2036)
@@ -0,0 +1,103 @@
+/* Regular expression tests.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sys/types.h>
+#include <mcheck.h>
+#include <regex.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static struct
+{
+  int syntax;
+  const char *pattern;
+  const char *string;
+  int start;
+} tests[] = {
+  {RE_BACKSLASH_ESCAPE_IN_LISTS, "[0\\-9]", "1", -1}, /* It should not match.  */
+  {RE_BACKSLASH_ESCAPE_IN_LISTS, "[0\\-9]", "-", 0}, /* It should match.  */
+  {RE_SYNTAX_POSIX_BASIC, "s1\n.*\ns3", "s1\ns2\ns3", 0},
+  {RE_SYNTAX_POSIX_EXTENDED, "ab{0}c", "ac", 0},
+  {RE_SYNTAX_POSIX_EXTENDED, "ab{0}c", "abc", -1},
+  {RE_SYNTAX_POSIX_EXTENDED, "ab{0}c", "abbc", -1},
+  /* Nested duplication.  */
+  {RE_SYNTAX_POSIX_EXTENDED, "ab{1}{1}c", "ac", -1},
+  {RE_SYNTAX_POSIX_EXTENDED, "ab{1}{1}c", "abc", 0},
+  {RE_SYNTAX_POSIX_EXTENDED, "ab{1}{1}c", "abbc", -1},
+  {RE_SYNTAX_POSIX_EXTENDED, "ab{2}{2}c", "ac", -1},
+  {RE_SYNTAX_POSIX_EXTENDED, "ab{2}{2}c", "abbc", -1},
+  {RE_SYNTAX_POSIX_EXTENDED, "ab{2}{2}c", "abbbbc", 0},
+  {RE_SYNTAX_POSIX_EXTENDED, "ab{2}{2}c", "abbbbbc", -1},
+  {RE_SYNTAX_POSIX_EXTENDED, "ab{0}{1}c", "ac", 0},
+  {RE_SYNTAX_POSIX_EXTENDED, "ab{0}{1}c", "abc", -1},
+  {RE_SYNTAX_POSIX_EXTENDED, "ab{0}{1}c", "abbc", -1},
+  {RE_SYNTAX_POSIX_EXTENDED, "ab{1}{0}c", "ac", 0},
+  {RE_SYNTAX_POSIX_EXTENDED, "ab{1}{0}c", "abc", -1},
+  {RE_SYNTAX_POSIX_EXTENDED, "ab{1}{0}c", "abbc", -1},
+  {RE_SYNTAX_POSIX_EXTENDED, "ab{0}*c", "ac", 0},
+  {RE_SYNTAX_POSIX_EXTENDED, "ab{0}*c", "abc", -1},
+  {RE_SYNTAX_POSIX_EXTENDED, "ab{0}*c", "abbc", -1},
+  {RE_SYNTAX_POSIX_EXTENDED, "ab{0}?c", "ac", 0},
+  {RE_SYNTAX_POSIX_EXTENDED, "ab{0}?c", "abc", -1},
+  {RE_SYNTAX_POSIX_EXTENDED, "ab{0}?c", "abbc", -1},
+  {RE_SYNTAX_POSIX_EXTENDED, "ab{0}+c", "ac", 0},
+  {RE_SYNTAX_POSIX_EXTENDED, "ab{0}+c", "abc", -1},
+  {RE_SYNTAX_POSIX_EXTENDED, "ab{0}+c", "abbc", -1},
+};
+
+int
+main (void)
+{
+  struct re_pattern_buffer regbuf;
+  const char *err;
+  size_t i;
+  int ret = 0;
+
+  mtrace ();
+
+  for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
+    {
+      int start;
+      re_set_syntax (tests[i].syntax);
+      memset (&regbuf, '\0', sizeof (regbuf));
+      err = re_compile_pattern (tests[i].pattern, strlen (tests[i].pattern),
+                                &regbuf);
+      if (err != NULL)
+	{
+	  printf ("re_compile_pattern failed: %s\n", err);
+	  ret = 1;
+	  continue;
+	}
+
+      start = re_search (&regbuf, tests[i].string, strlen (tests[i].string),
+                         0, strlen (tests[i].string), NULL);
+      if (start != tests[i].start)
+	{
+	  printf ("re_search failed %d\n", start);
+	  ret = 1;
+	  regfree (&regbuf);
+	  continue;
+	}
+      regfree (&regbuf);
+    }
+
+  return ret;
+}
Index: trunk/src/libctests/glibc/posix/bug-regex14.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-regex14.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-regex14.c	(revision 2036)
@@ -0,0 +1,54 @@
+/* Tests re_comp and re_exec.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define _REGEX_RE_COMP
+#include <sys/types.h>
+#include <mcheck.h>
+#include <regex.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main (void)
+{
+  const char *err;
+  size_t i;
+  int ret = 0;
+
+  mtrace ();
+
+  for (i = 0; i < 100; ++i)
+    {
+      err = re_comp ("a t.st");
+      if (err)
+	{
+	  printf ("re_comp failed: %s\n", err);
+	  ret = 1;
+	}
+
+      if (! re_exec ("This is a test."))
+	{
+	  printf ("re_exec failed\n");
+	  ret = 1;
+	}
+    }
+
+  return ret;
+}
Index: trunk/src/libctests/glibc/posix/bug-regex15.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-regex15.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-regex15.c	(revision 2036)
@@ -0,0 +1,32 @@
+/* Test for memory/CPU leak in regcomp.  */
+
+#include <error.h>
+#include <sys/types.h>
+#include <regex.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define TEST_DATA_LIMIT (32 << 20)
+
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
+
+static int
+do_test (void)
+{
+  regex_t re;
+  int reerr;
+
+  reerr = regcomp (&re, "^6?3?[25]?5?[14]*[25]*[69]*+[58]*87?4?$",
+		   REG_EXTENDED | REG_NOSUB);
+  if (reerr != 0)
+    {
+      char buf[100];
+      regerror (reerr, &re, buf, sizeof buf);
+      printf ("regerror %s\n", buf);
+      return 1;
+    }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/posix/bug-regex16.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-regex16.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-regex16.c	(revision 2036)
@@ -0,0 +1,35 @@
+/* Test re_compile_pattern error messages.  */
+
+#include <stdio.h>
+#include <string.h>
+#include <regex.h>
+
+int
+main (void)
+{
+  struct re_pattern_buffer re;
+  const char *s;
+  int ret = 0;
+
+  re_set_syntax (RE_SYNTAX_POSIX_EGREP);
+  memset (&re, 0, sizeof (re));
+  s = re_compile_pattern ("[[.invalid_collating_symbol.]]", 30, &re);
+  if (s == NULL || strcmp (s, "Invalid collation character"))
+    {
+      printf ("re_compile_pattern returned %s\n", s);
+      ret = 1;
+    }
+  s = re_compile_pattern ("[[=invalid_equivalence_class=]]", 31, &re);
+  if (s == NULL || strcmp (s, "Invalid collation character"))
+    {
+      printf ("re_compile_pattern returned %s\n", s);
+      ret = 1;
+    }
+  s = re_compile_pattern ("[[:invalid_character_class:]]", 29, &re);
+  if (s == NULL || strcmp (s, "Invalid character class name"))
+    {
+      printf ("re_compile_pattern returned %s\n", s);
+      ret = 1;
+    }
+  return ret;
+}
Index: trunk/src/libctests/glibc/posix/bug-regex17.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-regex17.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-regex17.c	(revision 2036)
@@ -0,0 +1,95 @@
+/* Turkish regular expression tests.
+   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sys/types.h>
+#include <mcheck.h>
+#include <regex.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <locale.h>
+
+/* Tests supposed to match.  */
+struct
+{
+  const char *pattern;
+  const char *string;
+  int flags, nmatch;
+  regmatch_t rm[5];
+} tests[] = {
+  /* \xc3\x84	LATIN CAPITAL LETTER A WITH DIAERESIS
+     \xc3\x96	LATIN CAPITAL LETTER O WITH DIAERESIS
+     \xc3\xa4	LATIN SMALL LETTER A WITH DIAERESIS
+     \xc3\xb6	LATIN SMALL LETTER O WITH DIAERESIS  */
+  { "\xc3\x84\xc3\x96*\xc3\xb6$", "aB\xc3\xa4\xc3\xb6\xc3\xb6\xc3\x96", REG_ICASE, 2,
+    { { 2, 10 }, { -1, -1 } } },
+  { "[\xc3\x84x]\xc3\x96*\xc3\xb6$", "aB\xc3\x84\xc3\xb6\xc3\xb6\xc3\x96", REG_ICASE, 2,
+    { { 2, 10 }, { -1, -1 } } },
+  { "[\xc3\x84x]\xc3\x96*\xc3\xb6$", "aB\xc3\xa4\xc3\xb6\xc3\xb6\xc3\x96", REG_ICASE, 2,
+    { { 2, 10 }, { -1, -1 } } },
+  { "[^x]\xc3\x96*\xc3\xb6$", "aB\xc3\xa4\xc3\xb6\xc3\xb6\xc3\x96", REG_ICASE, 2,
+    { { 2, 10 }, { -1, -1 } } },
+};
+
+int
+main (void)
+{
+  regex_t re;
+  regmatch_t rm[5];
+  size_t i;
+  int n, ret = 0;
+
+  setlocale (LC_ALL, "de_DE.UTF-8");
+  for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
+    {
+      n = regcomp (&re, tests[i].pattern, tests[i].flags);
+      if (n != 0)
+	{
+	  char buf[500];
+	  regerror (n, &re, buf, sizeof (buf));
+	  printf ("regcomp %zd failed: %s\n", i, buf);
+	  ret = 1;
+	  continue;
+	}
+
+      if (regexec (&re, tests[i].string, tests[i].nmatch, rm, 0))
+	{
+	  printf ("regexec %zd failed\n", i);
+	  ret = 1;
+	  regfree (&re);
+	  continue;
+	}
+
+      for (n = 0; n < tests[i].nmatch; ++n)
+	if (rm[n].rm_so != tests[i].rm[n].rm_so
+              || rm[n].rm_eo != tests[i].rm[n].rm_eo)
+	  {
+	    if (tests[i].rm[n].rm_so == -1 && tests[i].rm[n].rm_eo == -1)
+	      break;
+	    printf ("regexec match failure rm[%d] %d..%d\n",
+		    n, rm[n].rm_so, rm[n].rm_eo);
+	    ret = 1;
+	    break;
+	  }
+
+      regfree (&re);
+    }
+
+  return ret;
+}
Index: trunk/src/libctests/glibc/posix/bug-regex18.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-regex18.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-regex18.c	(revision 2036)
@@ -0,0 +1,100 @@
+/* Turkish regular expression tests.
+   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sys/types.h>
+#include <mcheck.h>
+#include <regex.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <locale.h>
+
+/* Tests supposed to match.  */
+struct
+{
+  const char *pattern;
+  const char *string;
+  int flags, nmatch;
+  regmatch_t rm[5];
+} tests[] = {
+  /* \xc4\xb0		LATIN CAPITAL LETTER I WITH DOT ABOVE
+     \xc4\xb1		LATIN SMALL LETTER DOTLESS I
+     \xe2\x80\x94	EM DASH  */
+  { "\xc4\xb0I*\xc4\xb1$", "aBi\xc4\xb1\xc4\xb1I", REG_ICASE, 2,
+    { { 2, 8 }, { -1, -1 } } },
+  { "[\xc4\xb0x]I*\xc4\xb1$", "aBi\xc4\xb1\xc4\xb1I", REG_ICASE, 2,
+    { { 2, 8 }, { -1, -1 } } },
+  { "[^x]I*\xc4\xb1$", "aBi\xc4\xb1\xc4\xb1I", REG_ICASE, 2,
+    { { 2, 8 }, { -1, -1 } } },
+  { "([[:alpha:]]i[[:xdigit:]])(\xc4\xb1*)(\xc4\xb0{2})",
+    "\xe2\x80\x94\xc4\xb1\xc4\xb0""fIi\xc4\xb0ii", REG_ICASE | REG_EXTENDED,
+    4, { { 3, 12 }, { 3, 8 }, { 8, 9 }, { 9, 12 } } },
+  { "\xc4\xb1i(i)*()(\\s\xc4\xb0|\\SI)", "SIi\xc4\xb0\xc4\xb0 is",
+    REG_ICASE | REG_EXTENDED, 4, { { 1, 9 }, { 5, 7 }, { 7, 7 }, { 7, 9 } } },
+  { "\xc4\xb1i(i)*()(\\s\xc4\xb0|\\SI)", "\xc4\xb1\xc4\xb0\xc4\xb0iJ\xc4\xb1",
+    REG_ICASE | REG_EXTENDED, 4,
+    { { 0, 10 }, { 6, 7 }, { 7, 7 }, { 7, 10 } } },
+};
+
+int
+main (void)
+{
+  regex_t re;
+  regmatch_t rm[5];
+  size_t i;
+  int n, ret = 0;
+
+  setlocale (LC_ALL, "tr_TR.UTF-8");
+  for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
+    {
+      n = regcomp (&re, tests[i].pattern, tests[i].flags);
+      if (n != 0)
+	{
+	  char buf[500];
+	  regerror (n, &re, buf, sizeof (buf));
+	  printf ("regcomp %zd failed: %s\n", i, buf);
+	  ret = 1;
+	  continue;
+	}
+
+      if (regexec (&re, tests[i].string, tests[i].nmatch, rm, 0))
+	{
+	  printf ("regexec %zd failed\n", i);
+	  ret = 1;
+	  regfree (&re);
+	  continue;
+	}
+
+      for (n = 0; n < tests[i].nmatch; ++n)
+	if (rm[n].rm_so != tests[i].rm[n].rm_so
+              || rm[n].rm_eo != tests[i].rm[n].rm_eo)
+	  {
+	    if (tests[i].rm[n].rm_so == -1 && tests[i].rm[n].rm_eo == -1)
+	      break;
+	    printf ("regexec match failure rm[%d] %d..%d\n",
+		    n, rm[n].rm_so, rm[n].rm_eo);
+	    ret = 1;
+	    break;
+	  }
+
+      regfree (&re);
+    }
+
+  return ret;
+}
Index: trunk/src/libctests/glibc/posix/bug-regex19.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-regex19.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-regex19.c	(revision 2036)
@@ -0,0 +1,418 @@
+/* Regular expression tests.
+   Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sys/types.h>
+#include <mcheck.h>
+#include <regex.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <locale.h>
+
+#define BRE RE_SYNTAX_POSIX_BASIC
+#define ERE RE_SYNTAX_POSIX_EXTENDED
+
+static struct test_s
+{
+  int syntax;
+  const char *pattern;
+  const char *string;
+  int start, res;
+} tests[] = {
+  {BRE, "\\<A", "CBAA", 0, -1},
+  {BRE, "\\<A", "CBAA", 2, -1},
+  {BRE, "A\\>", "CAAB", 1, -1},
+  {BRE, "\\bA", "CBAA", 0, -1},
+  {BRE, "\\bA", "CBAA", 2, -1},
+  {BRE, "A\\b", "CAAB", 1, -1},
+  {BRE, "\\<A", "AA", 0, 0},
+  {BRE, "\\<A", "C-AA", 2, 2},
+  {BRE, "A\\>", "CAA-", 1, 2},
+  {BRE, "A\\>", "CAA", 1, 2},
+  {BRE, "\\bA", "AA", 0, 0},
+  {BRE, "\\bA", "C-AA", 2, 2},
+  {BRE, "A\\b", "CAA-", 1, 2},
+  {BRE, "A\\b", "CAA", 1, 2},
+  {BRE, "\\<[A]", "CBAA", 0, -1},
+  {BRE, "\\<[A]", "CBAA", 2, -1},
+  {BRE, "[A]\\>", "CAAB", 1, -1},
+  {BRE, "\\b[A]", "CBAA", 0, -1},
+  {BRE, "\\b[A]", "CBAA", 2, -1},
+  {BRE, "[A]\\b", "CAAB", 1, -1},
+  {BRE, "\\<[A]", "AA", 0, 0},
+  {BRE, "\\<[A]", "C-AA", 2, 2},
+  {BRE, "[A]\\>", "CAA-", 1, 2},
+  {BRE, "[A]\\>", "CAA", 1, 2},
+  {BRE, "\\b[A]", "AA", 0, 0},
+  {BRE, "\\b[A]", "C-AA", 2, 2},
+  {BRE, "[A]\\b", "CAA-", 1, 2},
+  {BRE, "[A]\\b", "CAA", 1, 2},
+  {ERE, "\\b(A|!|.B)", "A=AC", 0, 0},
+  {ERE, "\\b(A|!|.B)", "=AC", 0, 1},
+  {ERE, "\\b(A|!|.B)", "!AC", 0, 1},
+  {ERE, "\\b(A|!|.B)", "=AB", 0, 1},
+  {ERE, "\\b(A|!|.B)", "DA!C", 0, 2},
+  {ERE, "\\b(A|!|.B)", "=CB", 0, 1},
+  {ERE, "\\b(A|!|.B)", "!CB", 0, 1},
+  {ERE, "\\b(A|!|.B)", "D,B", 0, 1},
+  {ERE, "\\b(A|!|.B)", "!.C", 0, -1},
+  {ERE, "\\b(A|!|.B)", "BCB", 0, -1},
+  {ERE, "(A|\\b)(A|B|C)", "DAAD", 0, 1},
+  {ERE, "(A|\\b)(A|B|C)", "DABD", 0, 1},
+  {ERE, "(A|\\b)(A|B|C)", "AD", 0, 0},
+  {ERE, "(A|\\b)(A|B|C)", "C!", 0, 0},
+  {ERE, "(A|\\b)(A|B|C)", "D,B", 0, 2},
+  {ERE, "(A|\\b)(A|B|C)", "DA?A", 0, 3},
+  {ERE, "(A|\\b)(A|B|C)", "BBC", 0, 0},
+  {ERE, "(A|\\b)(A|B|C)", "DA", 0, -1},
+  {ERE, "(!|\\b)(!|=|~)", "A!=\\", 0, 1},
+  {ERE, "(!|\\b)(!|=|~)", "/!=A", 0, 1},
+  {ERE, "(!|\\b)(!|=|~)", "A=A", 0, 1},
+  {ERE, "(!|\\b)(!|=|~)", "==!=", 0, 2},
+  {ERE, "(!|\\b)(!|=|~)", "==C~", 0, 3},
+  {ERE, "(!|\\b)(!|=|~)", "=~=", 0, -1},
+  {ERE, "(!|\\b)(!|=|~)", "~!", 0, -1},
+  {ERE, "(!|\\b)(!|=|~)", "~=~", 0, -1},
+  {ERE, "(\\b|A.)[ABC]", "AC", 0, 0},
+  {ERE, "(\\b|A.)[ABC]", "=A", 0, 1},
+  {ERE, "(\\b|A.)[ABC]", "DACC", 0, 1},
+  {ERE, "(\\b|A.)[A~C]", "AC", 0, 0},
+  {ERE, "(\\b|A.)[A~C]", "=A", 0, 1},
+  {ERE, "(\\b|A.)[A~C]", "DACC", 0, 1},
+  {ERE, "(\\b|A.)[A~C]", "B!A=", 0, 2},
+  {ERE, "(\\b|A.)[A~C]", "B~C", 0, 1},
+  {ERE, ".\\b.", "AA~", 0, 1},
+  {ERE, ".\\b.", "=A=", 0, 0},
+  {ERE, ".\\b.", "==", 0, -1},
+  {ERE, ".\\b.", "ABA", 0, -1},
+  {ERE, "[^k]\\b[^k]", "AA~", 0, 1},
+  {ERE, "[^k]\\b[^k]", "=A=", 0, 0},
+  {ERE, "[^k]\\b[^k]", "Ak~kA~", 0, 4},
+  {ERE, "[^k]\\b[^k]", "==", 0, -1},
+  {ERE, "[^k]\\b[^k]", "ABA", 0, -1},
+  {ERE, "[^k]\\b[^k]", "Ak~", 0, -1},
+  {ERE, "[^k]\\b[^k]", "k=k", 0, -1},
+  {ERE, "[^C]\\b[^C]", "AA~", 0, 1},
+  {ERE, "[^C]\\b[^C]", "=A=", 0, 0},
+  {ERE, "[^C]\\b[^C]", "AC~CA~", 0, 4},
+  {ERE, "[^C]\\b[^C]", "==", 0, -1},
+  {ERE, "[^C]\\b[^C]", "ABA", 0, -1},
+  {ERE, "[^C]\\b[^C]", "AC~", 0, -1},
+  {ERE, "[^C]\\b[^C]", "C=C", 0, -1},
+  {ERE, "\\<(A|!|.B)", "A=AC", 0, 0},
+  {ERE, "\\<(A|!|.B)", "=AC", 0, 1},
+  {ERE, "\\<(A|!|.B)", "!AC", 0, 1},
+  {ERE, "\\<(A|!|.B)", "=AB", 0, 1},
+  {ERE, "\\<(A|!|.B)", "=CB", 0, 1},
+  {ERE, "\\<(A|!|.B)", "!CB", 0, 1},
+  {ERE, "\\<(A|!|.B)", "DA!C", 0, -1},
+  {ERE, "\\<(A|!|.B)", "D,B", 0, -1},
+  {ERE, "\\<(A|!|.B)", "!.C", 0, -1},
+  {ERE, "\\<(A|!|.B)", "BCB", 0, -1},
+  {ERE, "(A|\\<)(A|B|C)", "DAAD", 0, 1},
+  {ERE, "(A|\\<)(A|B|C)", "DABD", 0, 1},
+  {ERE, "(A|\\<)(A|B|C)", "AD", 0, 0},
+  {ERE, "(A|\\<)(A|B|C)", "C!", 0, 0},
+  {ERE, "(A|\\<)(A|B|C)", "D,B", 0, 2},
+  {ERE, "(A|\\<)(A|B|C)", "DA?A", 0, 3},
+  {ERE, "(A|\\<)(A|B|C)", "BBC", 0, 0},
+  {ERE, "(A|\\<)(A|B|C)", "DA", 0, -1},
+  {ERE, "(!|\\<)(!|=|~)", "A!=\\", 0, 1},
+  {ERE, "(!|\\<)(!|=|~)", "/!=A", 0, 1},
+  {ERE, "(!|\\<)(!|=|~)", "==!=", 0, 2},
+  {ERE, "(!|\\<)(!|=|~)", "==C~", 0, -1},
+  {ERE, "(!|\\<)(!|=|~)", "A=A", 0, -1},
+  {ERE, "(!|\\<)(!|=|~)", "=~=", 0, -1},
+  {ERE, "(!|\\<)(!|=|~)", "~!", 0, -1},
+  {ERE, "(!|\\<)(!|=|~)", "~=~", 0, -1},
+  {ERE, "(\\<|A.)[ABC]", "AC", 0, 0},
+  {ERE, "(\\<|A.)[ABC]", "=A", 0, 1},
+  {ERE, "(\\<|A.)[ABC]", "DACC", 0, 1},
+  {ERE, "(\\<|A.)[A~C]", "AC", 0, 0},
+  {ERE, "(\\<|A.)[A~C]", "=A", 0, 1},
+  {ERE, "(\\<|A.)[A~C]", "DACC", 0, 1},
+  {ERE, "(\\<|A.)[A~C]", "B!A=", 0, 2},
+  {ERE, "(\\<|A.)[A~C]", "B~C", 0, 2},
+  {ERE, ".\\<.", "=A=", 0, 0},
+  {ERE, ".\\<.", "AA~", 0, -1},
+  {ERE, ".\\<.", "==", 0, -1},
+  {ERE, ".\\<.", "ABA", 0, -1},
+  {ERE, "[^k]\\<[^k]", "=k=A=", 0, 2},
+  {ERE, "[^k]\\<[^k]", "kk~", 0, -1},
+  {ERE, "[^k]\\<[^k]", "==", 0, -1},
+  {ERE, "[^k]\\<[^k]", "ABA", 0, -1},
+  {ERE, "[^k]\\<[^k]", "=k=", 0, -1},
+  {ERE, "[^C]\\<[^C]", "=C=A=", 0, 2},
+  {ERE, "[^C]\\<[^C]", "CC~", 0, -1},
+  {ERE, "[^C]\\<[^C]", "==", 0, -1},
+  {ERE, "[^C]\\<[^C]", "ABA", 0, -1},
+  {ERE, "[^C]\\<[^C]", "=C=", 0, -1},
+  {ERE, ".\\B.", "ABA", 0, 0},
+  {ERE, ".\\B.", "=BDC", 0, 1},
+  {ERE, "[^k]\\B[^k]", "kkkABA", 0, 3},
+  {ERE, "[^k]\\B[^k]", "kBk", 0, -1},
+  {ERE, "[^C]\\B[^C]", "CCCABA", 0, 3},
+  {ERE, "[^C]\\B[^C]", "CBC", 0, -1},
+  {ERE, ".(\\b|\\B).", "=~AB", 0, 0},
+  {ERE, ".(\\b|\\B).", "A=C", 0, 0},
+  {ERE, ".(\\b|\\B).", "ABC", 0, 0},
+  {ERE, ".(\\b|\\B).", "=~\\!", 0, 0},
+  {ERE, "[^k](\\b|\\B)[^k]", "=~AB", 0, 0},
+  {ERE, "[^k](\\b|\\B)[^k]", "A=C", 0, 0},
+  {ERE, "[^k](\\b|\\B)[^k]", "ABC", 0, 0},
+  {ERE, "[^k](\\b|\\B)[^k]", "=~kBD", 0, 0},
+  {ERE, "[^k](\\b|\\B)[^k]", "=~\\!", 0, 0},
+  {ERE, "[^k](\\b|\\B)[^k]", "=~kB", 0, 0},
+  {ERE, "[^C](\\b|\\B)[^C]", "=~AB", 0, 0},
+  {ERE, "[^C](\\b|\\B)[^C]", "A=C", 0, 0},
+  {ERE, "[^C](\\b|\\B)[^C]", "ABC", 0, 0},
+  {ERE, "[^C](\\b|\\B)[^C]", "=~CBD", 0, 0},
+  {ERE, "[^C](\\b|\\B)[^C]", "=~\\!", 0, 0},
+  {ERE, "[^C](\\b|\\B)[^C]", "=~CB", 0, 0},
+  {ERE, "\\b([A]|[!]|.B)", "A=AC", 0, 0},
+  {ERE, "\\b([A]|[!]|.B)", "=AC", 0, 1},
+  {ERE, "\\b([A]|[!]|.B)", "!AC", 0, 1},
+  {ERE, "\\b([A]|[!]|.B)", "=AB", 0, 1},
+  {ERE, "\\b([A]|[!]|.B)", "DA!C", 0, 2},
+  {ERE, "\\b([A]|[!]|.B)", "=CB", 0, 1},
+  {ERE, "\\b([A]|[!]|.B)", "!CB", 0, 1},
+  {ERE, "\\b([A]|[!]|.B)", "D,B", 0, 1},
+  {ERE, "\\b([A]|[!]|.B)", "!.C", 0, -1},
+  {ERE, "\\b([A]|[!]|.B)", "BCB", 0, -1},
+  {ERE, "([A]|\\b)([A]|[B]|[C])", "DAAD", 0, 1},
+  {ERE, "([A]|\\b)([A]|[B]|[C])", "DABD", 0, 1},
+  {ERE, "([A]|\\b)([A]|[B]|[C])", "AD", 0, 0},
+  {ERE, "([A]|\\b)([A]|[B]|[C])", "C!", 0, 0},
+  {ERE, "([A]|\\b)([A]|[B]|[C])", "D,B", 0, 2},
+  {ERE, "([A]|\\b)([A]|[B]|[C])", "DA?A", 0, 3},
+  {ERE, "([A]|\\b)([A]|[B]|[C])", "BBC", 0, 0},
+  {ERE, "([A]|\\b)([A]|[B]|[C])", "DA", 0, -1},
+  {ERE, "([!]|\\b)([!]|[=]|[~])", "A!=\\", 0, 1},
+  {ERE, "([!]|\\b)([!]|[=]|[~])", "/!=A", 0, 1},
+  {ERE, "([!]|\\b)([!]|[=]|[~])", "A=A", 0, 1},
+  {ERE, "([!]|\\b)([!]|[=]|[~])", "==!=", 0, 2},
+  {ERE, "([!]|\\b)([!]|[=]|[~])", "==C~", 0, 3},
+  {ERE, "([!]|\\b)([!]|[=]|[~])", "=~=", 0, -1},
+  {ERE, "([!]|\\b)([!]|[=]|[~])", "~!", 0, -1},
+  {ERE, "([!]|\\b)([!]|[=]|[~])", "~=~", 0, -1},
+  {ERE, "\\<([A]|[!]|.B)", "A=AC", 0, 0},
+  {ERE, "\\<([A]|[!]|.B)", "=AC", 0, 1},
+  {ERE, "\\<([A]|[!]|.B)", "!AC", 0, 1},
+  {ERE, "\\<([A]|[!]|.B)", "=AB", 0, 1},
+  {ERE, "\\<([A]|[!]|.B)", "=CB", 0, 1},
+  {ERE, "\\<([A]|[!]|.B)", "!CB", 0, 1},
+  {ERE, "\\<([A]|[!]|.B)", "DA!C", 0, -1},
+  {ERE, "\\<([A]|[!]|.B)", "D,B", 0, -1},
+  {ERE, "\\<([A]|[!]|.B)", "!.C", 0, -1},
+  {ERE, "\\<([A]|[!]|.B)", "BCB", 0, -1},
+  {ERE, "([A]|\\<)([A]|[B]|[C])", "DAAD", 0, 1},
+  {ERE, "([A]|\\<)([A]|[B]|[C])", "DABD", 0, 1},
+  {ERE, "([A]|\\<)([A]|[B]|[C])", "AD", 0, 0},
+  {ERE, "([A]|\\<)([A]|[B]|[C])", "C!", 0, 0},
+  {ERE, "([A]|\\<)([A]|[B]|[C])", "D,B", 0, 2},
+  {ERE, "([A]|\\<)([A]|[B]|[C])", "DA?A", 0, 3},
+  {ERE, "([A]|\\<)([A]|[B]|[C])", "BBC", 0, 0},
+  {ERE, "([A]|\\<)([A]|[B]|[C])", "DA", 0, -1},
+  {ERE, "([!]|\\<)([!=]|[~])", "A!=\\", 0, 1},
+  {ERE, "([!]|\\<)([!=]|[~])", "/!=A", 0, 1},
+  {ERE, "([!]|\\<)([!=]|[~])", "==!=", 0, 2},
+  {ERE, "([!]|\\<)([!=]|[~])", "==C~", 0, -1},
+  {ERE, "([!]|\\<)([!=]|[~])", "A=A", 0, -1},
+  {ERE, "([!]|\\<)([!=]|[~])", "=~=", 0, -1},
+  {ERE, "([!]|\\<)([!=]|[~])", "~!", 0, -1},
+  {ERE, "([!]|\\<)([!=]|[~])", "~=~", 0, -1},
+  {ERE, "(\\<|[A].)[ABC]", "AC", 0, 0},
+  {ERE, "(\\<|[A].)[ABC]", "=A", 0, 1},
+  {ERE, "(\\<|[A].)[ABC]", "DACC", 0, 1},
+  {ERE, "(\\<|[A].)[A~C]", "AC", 0, 0},
+  {ERE, "(\\<|[A].)[A~C]", "=A", 0, 1},
+  {ERE, "(\\<|[A].)[A~C]", "DACC", 0, 1},
+  {ERE, "(\\<|[A].)[A~C]", "B!A=", 0, 2},
+  {ERE, "(\\<|[A].)[A~C]", "B~C", 0, 2},
+  {ERE, "^[^A]*\\bB", "==B", 0, 0},
+  {ERE, "^[^A]*\\bB", "CBD!=B", 0, 0},
+  {ERE, "[^A]*\\bB", "==B", 2, 2}
+};
+
+int
+do_one_test (const struct test_s *test, const char *fail)
+{
+  int res;
+  const char *err;
+  struct re_pattern_buffer regbuf;
+
+  re_set_syntax (test->syntax);
+  memset (&regbuf, '\0', sizeof (regbuf));
+  err = re_compile_pattern (test->pattern, strlen (test->pattern),
+			    &regbuf);
+  if (err != NULL)
+    {
+      printf ("%sre_compile_pattern \"%s\" failed: %s\n", fail, test->pattern,
+	      err);
+      return 1;
+    }
+
+  res = re_search (&regbuf, test->string, strlen (test->string),
+		   test->start, strlen (test->string) - test->start, NULL);
+  if (res != test->res)
+    {
+      printf ("%sre_search \"%s\" \"%s\" failed: %d (expected %d)\n",
+	      fail, test->pattern, test->string, res, test->res);
+      regfree (&regbuf);
+      return 1;
+    }
+
+  if (test->res > 0 && test->start == 0)
+    {
+      res = re_search (&regbuf, test->string, strlen (test->string),
+		       test->res, strlen (test->string) - test->res, NULL);
+      if (res != test->res)
+	{
+	  printf ("%sre_search from expected \"%s\" \"%s\" failed: %d (expected %d)\n",
+		  fail, test->pattern, test->string, res, test->res);
+	  regfree (&regbuf);
+	  return 1;
+	}
+    }
+
+  regfree (&regbuf);
+  return 0;
+}
+
+static char *
+replace (char *p, char c)
+{
+  switch (c)
+    {
+      /* A -> A" */
+      case 'A': *p++ = '\xc3'; *p++ = '\x84'; break;
+      /* B -> O" */
+      case 'B': *p++ = '\xc3'; *p++ = '\x96'; break;
+      /* C -> U" */
+      case 'C': *p++ = '\xc3'; *p++ = '\x9c'; break;
+      /* D -> a" */
+      case 'D': *p++ = '\xc3'; *p++ = '\xa4'; break;
+      /* ! -> MULTIPLICATION SIGN */
+      case '!': *p++ = '\xc3'; *p++ = '\x97'; break;
+      /* = -> EM DASH */
+      case '=': *p++ = '\xe2'; *p++ = '\x80'; *p++ = '\x94'; break;
+      /* ~ -> MUSICAL SYMBOL HALF NOTE */
+      case '~': *p++ = '\xf0'; *p++ = '\x9d'; *p++ = '\x85'; *p++ = '\x9e';
+      break;
+    }
+  return p;
+}
+
+int
+do_mb_tests (const struct test_s *test)
+{
+  int i, j;
+  struct test_s t;
+  const char *const chars = "ABCD!=~";
+  char repl[8], *p;
+  char pattern[strlen (test->pattern) * 4 + 1];
+  char string[strlen (test->string) * 4 + 1];
+  char fail[8 + sizeof ("UTF-8 ")];
+
+  t = *test;
+  t.pattern = pattern;
+  t.string = string;
+  strcpy (fail, "UTF-8 ");
+  for (i = 1; i < 128; ++i)
+    {
+      p = repl;
+      for (j = 0; j < 7; ++j)
+	if (i & (1 << j))
+	  {
+	    if (!strchr (test->pattern, chars[j])
+		&& !strchr (test->string, chars[j]))
+	      break;
+	    *p++ = chars[j];
+	  }
+      if (j < 7)
+	continue;
+      *p = '\0';
+
+      for (j = 0, p = pattern; test->pattern[j]; ++j)
+	if (strchr (repl, test->pattern[j]))
+	  p = replace (p, test->pattern[j]);
+	else if (test->pattern[j] == '\\' && test->pattern[j + 1])
+	  {
+	    *p++ = test->pattern[j++];
+	    *p++ = test->pattern[j];
+	  }
+	else
+	  *p++ = test->pattern[j];
+      *p = '\0';
+
+      t.start = test->start;
+      t.res = test->res;
+
+      for (j = 0, p = string; test->string[j]; ++j)
+	if (strchr (repl, test->string[j]))
+	  {
+	    char *d = replace (p, test->string[j]);
+	    if (test->start > j)
+	      t.start += d - p - 1;
+	    if (test->res > j)
+	      t.res += d - p - 1;
+	    p = d;
+	  }
+	else
+	  *p++ = test->string[j];
+      *p = '\0';
+
+      p = stpcpy (fail + strlen ("UTF-8 "), repl);
+      *p++ = ' ';
+      *p = '\0';
+
+      if (do_one_test (&t, fail))
+	return 1;
+    }
+  return 0;
+}
+
+int
+main (void)
+{
+  size_t i;
+  int ret = 0;
+
+  mtrace ();
+
+  for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
+    {
+      if (setlocale (LC_ALL, "de_DE.ISO-8859-1") == NULL)
+	{
+	  puts ("setlocale de_DE.ISO-8859-1 failed");
+	  ret = 1;
+	}
+      ret |= do_one_test (&tests[i], "");
+      if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
+	{
+	  puts ("setlocale de_DE.UTF-8 failed");
+	  ret = 1;
+	}
+      ret |= do_one_test (&tests[i], "UTF-8 ");
+      ret |= do_mb_tests (&tests[i]);
+    }
+
+  return ret;
+}
Index: trunk/src/libctests/glibc/posix/bug-regex2.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-regex2.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-regex2.c	(revision 2036)
@@ -0,0 +1,54 @@
+/* Test for memory handling in regex.
+   Copyright (C) 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sys/types.h>
+#include <mcheck.h>
+#include <regex.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static const char text[] = "This is a test; this is a test";
+
+int
+main (void)
+{
+  regex_t re;
+  regmatch_t rm[2];
+  int n;
+
+  mtrace ();
+
+  n = regcomp (&re, "a test", REG_EXTENDED);
+  if (n != 0)
+    {
+      char buf[500];
+      regerror (n, &re, buf, sizeof (buf));
+      printf ("regcomp failed: %s\n", buf);
+      exit (1);
+    }
+
+  for (n = 0; n < 20; ++n)
+    regexec (&re, text, 2, rm, 0);
+
+  regfree (&re);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/posix/bug-regex20.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-regex20.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-regex20.c	(revision 2036)
@@ -0,0 +1,287 @@
+/* Test for UTF-8 regular expression optimizations.
+   Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sys/types.h>
+#include <mcheck.h>
+#include <regex.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <locale.h>
+
+#define RE_NO_INTERNAL_PROTOTYPES 1
+#include "regex_internal.h"
+
+#define BRE RE_SYNTAX_POSIX_BASIC
+#define ERE RE_SYNTAX_POSIX_EXTENDED
+
+static struct
+{
+  int syntax;
+  const char *pattern;
+  const char *string;
+  int res, optimize;
+} tests[] = {
+  /* \xc3\x84		LATIN CAPITAL LETTER A WITH DIAERESIS
+     \xc3\x96		LATIN CAPITAL LETTER O WITH DIAERESIS
+     \xc3\xa4		LATIN SMALL LETTER A WITH DIAERESIS
+     \xc3\xb6		LATIN SMALL LETTER O WITH DIAERESIS
+     \xe2\x80\x94	EM DASH  */
+  /* Should be optimized.  */
+  {BRE, "foo", "b\xc3\xa4rfoob\xc3\xa4z", 4, 1},
+  {BRE, "b\xc3\xa4z", "b\xc3\xa4rfoob\xc3\xa4z", 7, 1},
+  {BRE, "b\xc3\xa4*z", "b\xc3\xa4rfoob\xc3\xa4z", 7, 1},
+  {BRE, "b\xc3\xa4*z", "b\xc3\xa4rfoobz", 7, 1},
+  {BRE, "b\xc3\xa4\\+z", "b\xc3\xa4rfoob\xc3\xa4\xc3\xa4z", 7, 1},
+  {BRE, "b\xc3\xa4\\?z", "b\xc3\xa4rfoob\xc3\xa4z", 7, 1},
+  {BRE, "b\xc3\xa4\\{1,2\\}z", "b\xc3\xa4rfoob\xc3\xa4z", 7, 1},
+  {BRE, "^x\\|xy*z$", "\xc3\xb6xyyz", 2, 1},
+  {BRE, "^x\\\\y\\{6\\}z\\+", "x\\yyyyyyzz\xc3\xb6", 0, 1},
+  {BRE, "^x\\\\y\\{2,36\\}z\\+", "x\\yzz\xc3\xb6", -1, 1},
+  {BRE, "^x\\\\y\\{,3\\}z\\+", "x\\yyyzz\xc3\xb6", 0, 1},
+  {BRE, "^x\\|x\xc3\xa4*z$", "\xc3\xb6x\xc3\xa4\xc3\xa4z", 2, 1},
+  {BRE, "^x\\\\\xc3\x84\\{6\\}z\\+",
+   "x\\\xc3\x84\xc3\x84\xc3\x84\xc3\x84\xc3\x84\xc3\x84zz\xc3\xb6", 0, 1},
+  {BRE, "^x\\\\\xc3\x84\\{2,36\\}z\\+", "x\\\xc3\x84zz\xc3\xb6", -1, 1},
+  {BRE, "^x\\\\\xc3\x84\\{,3\\}z\\+",
+   "x\\\xc3\x84\xc3\x84\xc3\x84zz\xc3\xb6", 0, 1},
+  {BRE, "x[C]y", "axCy", 1, 1},
+  {BRE, "x[ABC]y", "axCy", 1, 1},
+  {BRE, "\\`x\\|z\\'", "x\xe2\x80\x94", 0, 1},
+  {BRE, "\\(xy\\)z\\1a\\1", "\xe2\x80\x94xyzxyaxy\xc3\x84", 3, 1},
+  {BRE, "xy\\?z", "\xc3\x84xz\xc3\xb6", 2, 1},
+  {BRE, "\\`\xc3\x84\\|z\\'", "\xc3\x84\xe2\x80\x94", 0, 1},
+  {BRE, "\\(x\xc3\x84\\)z\\1\x61\\1",
+   "\xe2\x80\x94x\xc3\x84zx\xc3\x84\x61x\xc3\x84\xc3\x96", 3, 1},
+  {BRE, "x\xc3\x96\\?z", "\xc3\x84xz\xc3\xb6", 2, 1},
+  {BRE, "x.y", "ax\xe2\x80\x94yz", 1, 1},
+  {BRE, "x.*z", "\xc3\x84xz", 2, 1},
+  {BRE, "x.*z", "\xc3\x84x\xe2\x80\x94z", 2, 1},
+  {BRE, "x.*z", "\xc3\x84x\xe2\x80\x94y\xf1\x90\x80\x90z", 2, 1},
+  {BRE, "x.*z", "\xc3\x84x\xe2\x80\x94\xc3\x94\xf1\x90\x80\x90z", 2, 1},
+  {BRE, "x.\\?z", "axz", 1, 1},
+  {BRE, "x.\\?z", "axyz", 1, 1},
+  {BRE, "x.\\?z", "ax\xc3\x84z", 1, 1},
+  {BRE, "x.\\?z", "ax\xe2\x80\x94z", 1, 1},
+  {BRE, "x.\\?z", "ax\xf0\x9d\x80\x80z", 1, 1},
+  {BRE, "x.\\?z", "ax\xf9\x81\x82\x83\x84z", 1, 1},
+  {BRE, "x.\\?z", "ax\xfd\xbf\xbf\xbf\xbf\xbfz", 1, 1},
+  {BRE, ".", "y", 0, 1},
+  {BRE, ".", "\xc3\x84", 0, 1},
+  {BRE, ".", "\xe2\x80\x94", 0, 1},
+  {BRE, ".", "\xf0\x9d\x80\x80", 0, 1},
+  {BRE, ".", "\xf9\x81\x82\x83\x84", 0, 1},
+  {BRE, ".", "\xfd\xbf\xbf\xbf\xbf\xbf", 0, 1},
+  {BRE, "x.\\?z", "axyyz", -1, 1},
+  {BRE, "x.\\?z", "ax\xc3\x84\xc3\x96z", -1, 1},
+  {BRE, "x.\\?z", "ax\xe2\x80\x94\xc3\xa4z", -1, 1},
+  {BRE, "x.\\?z", "ax\xf0\x9d\x80\x80yz", -1, 1},
+  {BRE, "x.\\?z", "ax\xf9\x81\x82\x83\x84\xf0\x9d\x80\x81z", -1, 1},
+  {BRE, "x.\\?z", "ax\xfd\xbf\xbf\xbf\xbf\xbf\xc3\x96z", -1, 1},
+  {BRE, "x.\\+z", "\xe2\x80\x94xz", -1, 1},
+  {BRE, "x.\\+z", "\xe2\x80\x94xyz", 3, 1},
+  {BRE, "x.\\+z", "\xe2\x80\x94x\xc3\x84y\xe2\x80\x94z", 3, 1},
+  {BRE, "x.\\+z", "\xe2\x80\x94x\xe2\x80\x94z", 3, 1},
+  {BRE, "x.\\+z", "\xe2\x80\x94x\xf0\x9d\x80\x80\xc3\x84z", 3, 1},
+  {BRE, "x.\\+z", "\xe2\x80\x94x.~\xe2\x80\x94\xf9\x81\x82\x83\x84z", 3, 1},
+  {BRE, "x.\\+z", "\xe2\x80\x94x\xfd\xbf\xbf\xbf\xbf\xbfz", 3, 1},
+  {BRE, "x.\\{1,2\\}z", "\xe2\x80\x94xz", -1, 1},
+  {BRE, "x.\\{1,2\\}z", "\xe2\x80\x94x\xc3\x96y\xc3\xa4z", -1, 1},
+  {BRE, "x.\\{1,2\\}z", "\xe2\x80\x94xyz", 3, 1},
+  {BRE, "x.\\{1,2\\}z", "\xe2\x80\x94x\xc3\x84\xe2\x80\x94z", 3, 1},
+  {BRE, "x.\\{1,2\\}z", "\xe2\x80\x94x\xe2\x80\x94z", 3, 1},
+  {BRE, "x.\\{1,2\\}z", "\xe2\x80\x94x\xf0\x9d\x80\x80\xc3\x84z", 3, 1},
+  {BRE, "x.\\{1,2\\}z", "\xe2\x80\x94x~\xe2\x80\x94z", 3, 1},
+  {BRE, "x.\\{1,2\\}z", "\xe2\x80\x94x\xfd\xbf\xbf\xbf\xbf\xbfz", 3, 1},
+  {BRE, "x\\(.w\\|\xc3\x86\\)\\?z", "axz", 1, 1},
+  {BRE, "x\\(.w\\|\xc3\x86\\)\\?z", "ax\xfd\xbf\xbf\xbf\xbf\xbfwz", 1, 1},
+  {BRE, "x\\(.w\\|\xc3\x86\\)\\?z", "ax\xc3\x86z", 1, 1},
+  {BRE, "x\\(.w\\|\xc3\x86\\)\\?z", "ax\xe2\x80\x96wz", 1, 1},
+  {ERE, "foo", "b\xc3\xa4rfoob\xc3\xa4z", 4, 1},
+  {ERE, "^x|xy*z$", "\xc3\xb6xyyz", 2, 1},
+  {ERE, "^x\\\\y{6}z+", "x\\yyyyyyzz\xc3\xb6", 0, 1},
+  {ERE, "^x\\\\y{2,36}z+", "x\\yzz\xc3\xb6", -1, 1},
+  {ERE, "^x\\\\y{,3}z+", "x\\yyyzz\xc3\xb6", 0, 1},
+  {ERE, "x[C]y", "axCy", 1, 1},
+  {ERE, "x[ABC]y", "axCy", 1, 1},
+  {ERE, "\\`x|z\\'", "x\xe2\x80\x94", 0, 1},
+  {ERE, "(xy)z\\1a\\1", "\xe2\x80\x94xyzxyaxy\xc3\x84", 3, 1},
+  {ERE, "xy?z", "\xc3\x84xz\xc3\xb6", 2, 1},
+  {ERE, "x.y", "ax\xe2\x80\x94yz", 1, 1},
+  {ERE, "x.*z", "\xc3\x84xz", 2, 1},
+  {ERE, "x.*z", "\xc3\x84x\xe2\x80\x94z", 2, 1},
+  {ERE, "x.*z", "\xc3\x84x\xe2\x80\x94y\xf1\x90\x80\x90z", 2, 1},
+  {ERE, "x.*z", "\xc3\x84x\xe2\x80\x94\xc3\x94\xf1\x90\x80\x90z", 2, 1},
+  {ERE, "x.?z", "axz", 1, 1},
+  {ERE, "x.?z", "axyz", 1, 1},
+  {ERE, "x.?z", "ax\xc3\x84z", 1, 1},
+  {ERE, "x.?z", "ax\xe2\x80\x94z", 1, 1},
+  {ERE, "x.?z", "ax\xf0\x9d\x80\x80z", 1, 1},
+  {ERE, "x.?z", "ax\xf9\x81\x82\x83\x84z", 1, 1},
+  {ERE, "x.?z", "ax\xfd\xbf\xbf\xbf\xbf\xbfz", 1, 1},
+  {ERE, "x.?z", "axyyz", -1, 1},
+  {ERE, "x.?z", "ax\xc3\x84\xc3\x96z", -1, 1},
+  {ERE, "x.?z", "ax\xe2\x80\x94\xc3\xa4z", -1, 1},
+  {ERE, "x.?z", "ax\xf0\x9d\x80\x80yz", -1, 1},
+  {ERE, "x.?z", "ax\xf9\x81\x82\x83\x84\xf0\x9d\x80\x81z", -1, 1},
+  {ERE, "x.?z", "ax\xfd\xbf\xbf\xbf\xbf\xbf\xc3\x96z", -1, 1},
+  {ERE, "x.+z", "\xe2\x80\x94xz", -1, 1},
+  {ERE, "x.+z", "\xe2\x80\x94xyz", 3, 1},
+  {ERE, "x.+z", "\xe2\x80\x94x\xc3\x84y\xe2\x80\x94z", 3, 1},
+  {ERE, "x.+z", "\xe2\x80\x94x\xe2\x80\x94z", 3, 1},
+  {ERE, "x.+z", "\xe2\x80\x94x\xf0\x9d\x80\x80\xc3\x84z", 3, 1},
+  {ERE, "x.+z", "\xe2\x80\x94x.~\xe2\x80\x94\xf9\x81\x82\x83\x84z", 3, 1},
+  {ERE, "x.+z", "\xe2\x80\x94x\xfd\xbf\xbf\xbf\xbf\xbfz", 3, 1},
+  {ERE, "x.{1,2}z", "\xe2\x80\x94xz", -1, 1},
+  {ERE, "x.{1,2}z", "\xe2\x80\x94x\xc3\x96y\xc3\xa4z", -1, 1},
+  {ERE, "x.{1,2}z", "\xe2\x80\x94xyz", 3, 1},
+  {ERE, "x.{1,2}z", "\xe2\x80\x94x\xc3\x84\xe2\x80\x94z", 3, 1},
+  {ERE, "x.{1,2}z", "\xe2\x80\x94x\xe2\x80\x94z", 3, 1},
+  {ERE, "x.{1,2}z", "\xe2\x80\x94x\xf0\x9d\x80\x80\xc3\x84z", 3, 1},
+  {ERE, "x.{1,2}z", "\xe2\x80\x94x~\xe2\x80\x94z", 3, 1},
+  {ERE, "x.{1,2}z", "\xe2\x80\x94x\xfd\xbf\xbf\xbf\xbf\xbfz", 3, 1},
+  {ERE, "x(.w|\xc3\x86)?z", "axz", 1, 1},
+  {ERE, "x(.w|\xc3\x86)?z", "ax\xfd\xbf\xbf\xbf\xbf\xbfwz", 1, 1},
+  {ERE, "x(.w|\xc3\x86)?z", "ax\xc3\x86z", 1, 1},
+  {ERE, "x(.w|\xc3\x86)?z", "ax\xe2\x80\x96wz", 1, 1},
+  /* Should not be optimized.  */
+  {BRE, "x[\xc3\x84\xc3\xa4]y", "ax\xc3\xa4y", 1, 0},
+  {BRE, "x[A-Z,]y", "axCy", 1, 0},
+  {BRE, "x[^y]z", "ax\xe2\x80\x94z", 1, 0},
+  {BRE, "x[[:alnum:]]z", "ax\xc3\x96z", 1, 0},
+  {BRE, "x[[=A=]]z", "axAz", 1, 0},
+  {BRE, "x[[=\xc3\x84=]]z", "ax\xc3\x84z", 1, 0},
+  {BRE, "\\<g", "\xe2\x80\x94g", 3, 0},
+  {BRE, "\\bg\\b", "\xe2\x80\x94g", 3, 0},
+  {BRE, "\\Bg\\B", "\xc3\xa4g\xc3\xa4", 2, 0},
+  {BRE, "a\\wz", "a\xc3\x84z", 0, 0},
+  {BRE, "x\\Wz", "\xc3\x96x\xe2\x80\x94z", 2, 0},
+  {ERE, "x[\xc3\x84\xc3\xa4]y", "ax\xc3\xa4y", 1, 0},
+  {ERE, "x[A-Z,]y", "axCy", 1, 0},
+  {ERE, "x[^y]z", "ax\xe2\x80\x94z", 1, 0},
+  {ERE, "x[[:alnum:]]z", "ax\xc3\x96z", 1, 0},
+  {ERE, "x[[=A=]]z", "axAz", 1, 0},
+  {ERE, "x[[=\xc3\x84=]]z", "ax\xc3\x84z", 1, 0},
+  {ERE, "\\<g", "\xe2\x80\x94g", 3, 0},
+  {ERE, "\\bg\\b", "\xe2\x80\x94g", 3, 0},
+  {ERE, "\\Bg\\B", "\xc3\xa4g\xc3\xa4", 2, 0},
+  {ERE, "a\\wz", "a\xc3\x84z", 0, 0},
+  {ERE, "x\\Wz", "\xc3\x96x\xe2\x80\x94z", 2, 0},
+};
+
+int
+main (void)
+{
+  struct re_pattern_buffer regbuf;
+  const char *err;
+  size_t i;
+  int ret = 0;
+
+  mtrace ();
+
+  setlocale (LC_ALL, "de_DE.UTF-8");
+  for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
+    {
+      int res, optimized;
+
+      re_set_syntax (tests[i].syntax);
+      memset (&regbuf, '\0', sizeof (regbuf));
+      err = re_compile_pattern (tests[i].pattern, strlen (tests[i].pattern),
+                                &regbuf);
+      if (err != NULL)
+	{
+	  printf ("re_compile_pattern failed: %s\n", err);
+	  ret = 1;
+	  continue;
+	}
+
+      /* Check if re_search will be done as multi-byte or single-byte.  */
+      optimized = ((re_dfa_t *) regbuf.buffer)->mb_cur_max == 1;
+      if (optimized != tests[i].optimize)
+        {
+          printf ("pattern %zd %soptimized while it should%s be\n",
+		  i, optimized ? "" : "not ", tests[i].optimize ? "" : " not");
+	  ret = 1;
+        }
+
+      int str_len = strlen (tests[i].string);
+      res = re_search (&regbuf, tests[i].string, str_len, 0, str_len, NULL);
+      if (res != tests[i].res)
+	{
+	  printf ("re_search %zd failed: %d\n", i, res);
+	  ret = 1;
+	  regfree (&regbuf);
+	  continue;
+	}
+
+      res = re_search (&regbuf, tests[i].string, str_len, str_len, -str_len,
+		       NULL);
+      if (res != tests[i].res)
+	{
+	  printf ("backward re_search %zd failed: %d\n", i, res);
+	  ret = 1;
+	  regfree (&regbuf);
+	  continue;
+	}
+      regfree (&regbuf);
+
+      re_set_syntax (tests[i].syntax | RE_ICASE);
+      memset (&regbuf, '\0', sizeof (regbuf));
+      err = re_compile_pattern (tests[i].pattern, strlen (tests[i].pattern),
+                                &regbuf);
+      if (err != NULL)
+	{
+	  printf ("re_compile_pattern failed: %s\n", err);
+	  ret = 1;
+	  continue;
+	}
+
+      /* Check if re_search will be done as multi-byte or single-byte.  */
+      optimized = ((re_dfa_t *) regbuf.buffer)->mb_cur_max == 1;
+      if (optimized)
+        {
+          printf ("pattern %zd optimized while it should not be when case insensitive\n",
+		  i);
+	  ret = 1;
+        }
+
+      res = re_search (&regbuf, tests[i].string, str_len, 0, str_len, NULL);
+      if (res != tests[i].res)
+	{
+	  printf ("ICASE re_search %zd failed: %d\n", i, res);
+	  ret = 1;
+	  regfree (&regbuf);
+	  continue;
+	}
+
+      res = re_search (&regbuf, tests[i].string, str_len, str_len, -str_len,
+		       NULL);
+      if (res != tests[i].res)
+	{
+	  printf ("ICASE backward re_search %zd failed: %d\n", i, res);
+	  ret = 1;
+	  regfree (&regbuf);
+	  continue;
+	}
+      regfree (&regbuf);
+    }
+
+  return ret;
+}
Index: trunk/src/libctests/glibc/posix/bug-regex21.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-regex21.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-regex21.c	(revision 2036)
@@ -0,0 +1,45 @@
+/* Test for memory leaks in regcomp.
+   Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <mcheck.h>
+#include <regex.h>
+#include <stdio.h>
+
+int main (void)
+{
+  regex_t re;
+  int i;
+  int ret = 0;
+
+  mtrace ();
+
+  for (i = 0; i < 32; ++i)
+    {
+      if (regcomp (&re, "X-.+:.+Y=\".*\\.(A|B|C|D|E|F|G|H|I",
+		   REG_EXTENDED | REG_ICASE) == 0)
+	{
+	  puts ("regcomp unexpectedly succeeded");
+	  ret = 1;
+	}
+      else
+	regfree (&re);
+    }
+  return ret;
+}
Index: trunk/src/libctests/glibc/posix/bug-regex22.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-regex22.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-regex22.c	(revision 2036)
@@ -0,0 +1,119 @@
+/* Test re.translate != NULL.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <ctype.h>
+#include <locale.h>
+#include <regex.h>
+#include <stdio.h>
+#include <string.h>
+
+int
+main (void)
+{
+  struct re_pattern_buffer re;
+  char trans[256];
+  int i, result = 0;
+  const char *s;
+
+  setlocale (LC_ALL, "de_DE.ISO-8859-1");
+
+  for (i = 0; i < 256; ++i)
+    trans[i] = tolower (i);
+
+  re_set_syntax (RE_SYNTAX_POSIX_EGREP);
+
+  memset (&re, 0, sizeof (re));
+  re.translate = trans;
+  s = re_compile_pattern ("\\W", 2, &re);
+
+  if (s != NULL)
+    {
+      printf ("failed to compile pattern \"\\W\": %s\n", s);
+      result = 1;
+    }
+  else
+    {
+      int ret = re_search (&re, "abc.de", 6, 0, 6, NULL);
+      if (ret != 3)
+	{
+	  printf ("1st re_search returned %d\n", ret);
+	  result = 1;
+	}
+
+      ret = re_search (&re, "\xc4\xd6\xae\xf7", 4, 0, 4, NULL);
+      if (ret != 2)
+	{
+	  printf ("2nd re_search returned %d\n", ret);
+	  result = 1;
+	}
+      re.translate = NULL;
+      regfree (&re);
+    }
+
+  memset (&re, 0, sizeof (re));
+  re.translate = trans;
+  s = re_compile_pattern ("\\w", 2, &re);
+
+  if (s != NULL)
+    {
+      printf ("failed to compile pattern \"\\w\": %s\n", s);
+      result = 1;
+    }
+  else
+    {
+      int ret = re_search (&re, ".,!abc", 6, 0, 6, NULL);
+      if (ret != 3)
+	{
+	  printf ("3rd re_search returned %d\n", ret);
+	  result = 1;
+	}
+
+      ret = re_search (&re, "\xae\xf7\xc4\xd6", 4, 0, 4, NULL);
+      if (ret != 2)
+	{
+	  printf ("4th re_search returned %d\n", ret);
+	  result = 1;
+	}
+      re.translate = NULL;
+      regfree (&re);
+    }
+
+  memset (&re, 0, sizeof (re));
+  re.translate = trans;
+  s = re_compile_pattern ("[[:DIGIT:]]", 11, &re);
+  if (s == NULL)
+    {
+      printf ("compilation of \"[[:DIGIT:]]\" pattern unexpectedly succeeded: %s\n",
+	      s);
+      result = 1;
+    }
+
+  memset (&re, 0, sizeof (re));
+  re.translate = trans;
+  s = re_compile_pattern ("[[:DIGIT:]]", 2, &re);
+  if (s == NULL)
+    {
+      printf ("compilation of \"[[:DIGIT:]]\" pattern unexpectedly succeeded: %s\n",
+	      s);
+      result = 1;
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/posix/bug-regex23.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-regex23.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-regex23.c	(revision 2036)
@@ -0,0 +1,35 @@
+/* Test we don't segfault on invalid UTF-8 sequence.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <locale.h>
+#include <regex.h>
+#include <string.h>
+
+int
+main (void)
+{
+  regex_t r;
+
+  memset (&r, 0, sizeof (r));
+  setlocale (LC_ALL, "de_DE.UTF-8");
+  regcomp (&r, "[-a-z_0-9.]+@[-a-z_0-9.]+", REG_EXTENDED | REG_ICASE);
+  regexec (&r, "\xe7\xb7\x95\xe7\x97", 0, NULL, 0);
+  return 0;
+}
Index: trunk/src/libctests/glibc/posix/bug-regex24.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-regex24.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-regex24.c	(revision 2036)
@@ -0,0 +1,60 @@
+#include <regex.h>
+#include <stdio.h>
+#include <string.h>
+
+#define str "civic"
+
+#define N 10
+static const char *expected[N] =
+  {
+    str, "c", "i", "", "", "", "", "", "", ""
+  };
+
+static int
+do_test (void)
+{
+  regex_t rbuf;
+  static const char pat[] = "\
+^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?).?\\9\\8\\7\\6\\5\\4\\3\\2\\1$";
+
+  int err = regcomp (&rbuf, pat, REG_EXTENDED);
+  if (err != 0)
+    {
+      char errstr[300];
+      regerror (err, &rbuf, errstr, sizeof (errstr));
+      puts (errstr);
+      return err;
+    }
+
+  regmatch_t m[N];
+  err = regexec (&rbuf, str, N, m, 0);
+  if (err != 0)
+    {
+      puts ("regexec failed");
+      return 1;
+    }
+
+  int result = 0;
+  for (int i = 0; i < N; ++i)
+    if (m[i].rm_so == -1)
+      {
+	printf ("m[%d] unused\n", i);
+	result = 1;
+      }
+    else
+      {
+	int len = m[i].rm_eo - m[i].rm_so;
+
+	printf ("m[%d] = \"%.*s\"\n", i, len, str + m[i].rm_so);
+
+	if (strlen (expected[i]) != len
+	    || memcmp (expected[i], str + m[i].rm_so, len) != 0)
+	  result = 1;
+      }
+
+  return result;
+}
+
+#define TIMEOUT 30
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/posix/bug-regex3.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-regex3.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-regex3.c	(revision 2036)
@@ -0,0 +1,45 @@
+/* Test for case handling in regex.
+   Copyright (C) 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2001.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sys/types.h>
+#include <regex.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+int
+main (void)
+{
+  regex_t re;
+  int n;
+
+  n = regcomp (&re, "[a-bA-B]", REG_ICASE);
+  if (n != 0)
+    {
+      char buf[500];
+      regerror (n, &re, buf, sizeof (buf));
+      printf ("regcomp failed: %s\n", buf);
+      exit (1);
+    }
+
+  regfree (&re);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/posix/bug-regex4.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-regex4.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-regex4.c	(revision 2036)
@@ -0,0 +1,60 @@
+/* Test for re_search_2.
+   Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2001.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+#include <regex.h>
+
+int
+main (void)
+{
+  struct re_pattern_buffer regex;
+  const char *s;
+  int match[3];
+  int result = 0;
+
+  memset (&regex, '\0', sizeof (regex));
+
+  setlocale (LC_ALL, "C");
+
+  s = re_compile_pattern ("ab[cde]", 7, &regex);
+  if (s != NULL)
+    {
+      puts ("re_compile_pattern returned non-NULL value");
+      result = 1;
+    }
+  else
+    {
+      match[0] = re_search_2 (&regex, "xyabez", 6, "", 0, 1, 5, NULL, 6);
+      match[1] = re_search_2 (&regex, NULL, 0, "abc", 3, 0, 3, NULL, 3);
+      match[2] = re_search_2 (&regex, "xya", 3, "bd", 2, 2, 3, NULL, 5);
+      if (match[0] != 2 || match[1] != 0 || match[2] != 2)
+	{
+	  printf ("re_search_2 returned %d,%d,%d, expected 2,0,2\n",
+		  match[0], match[1], match[2]);
+	  result = 1;
+	}
+      else
+	puts (" -> OK");
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/posix/bug-regex5.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-regex5.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-regex5.c	(revision 2036)
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <string.h>
+#include <locale.h>
+#include <locale/localeinfo.h>
+
+int
+main (void)
+{
+  int32_t table_size, idx, i, found;
+  const int32_t *symb_table;
+  const unsigned char *extra;
+  uint32_t nrules;
+  char *ca;
+  union locale_data_value u;
+
+  ca = setlocale (LC_ALL, "da_DK.ISO-8859-1");
+  if (ca == NULL)
+    {
+      printf ("cannot set locale: %m\n");
+      return 1;
+    }
+  printf ("current locale : %s\n", ca);
+
+  u.string = nl_langinfo (_NL_COLLATE_NRULES);
+  nrules = u.word;
+  if (nrules == 0)
+    {
+      printf("No rule\n");
+      return 1;
+    }
+
+  u.string = nl_langinfo (_NL_COLLATE_SYMB_HASH_SIZEMB);
+  table_size = u.word;
+  symb_table = (const int32_t *) nl_langinfo (_NL_COLLATE_SYMB_TABLEMB);
+  extra = (const unsigned char *) nl_langinfo (_NL_COLLATE_SYMB_EXTRAMB);
+
+  found = 0;
+  for (i = 0; i < table_size; ++i)
+    {
+      if (symb_table[2 * i] != 0)
+	{
+	  char elem[256];
+	  idx = symb_table[2 * i + 1];
+	  strncpy (elem, extra + idx + 1, extra[idx]);
+	  elem[extra[idx]] = '\0';
+	  printf ("Found a collating element: %s\n", elem);
+	  ++found;
+	}
+    }
+  if (found == 0)
+    {
+      printf ("No collating element!\n");
+      return 1;
+    }
+  else if (found != 4)
+    {
+      printf ("expected 4 collating elements, found %d\n", found);
+      return 1;
+    }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/posix/bug-regex6.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-regex6.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-regex6.c	(revision 2036)
@@ -0,0 +1,76 @@
+/* Test for regexec.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <regex.h>
+
+
+int
+main (int argc, char *argv[])
+{
+  regex_t re;
+  regmatch_t mat[10];
+  int i, j, ret = 0;
+  const char *locales[] = { "C", "de_DE.UTF-8" };
+  const char *string = "http://www.regex.com/pattern/matching.html#intro";
+  regmatch_t expect[10] = {
+    { 0, 48 }, { 0, 5 }, { 0, 4 }, { 5, 20 }, { 7, 20 }, { 20, 42 },
+    { -1, -1 }, { -1, -1 }, { 42, 48 }, { 43, 48 } };
+
+  for (i = 0; i < sizeof (locales) / sizeof (locales[0]); ++i)
+    {
+      if (setlocale (LC_ALL, locales[i]) == NULL)
+	{
+	  puts ("cannot set locale");
+	  ret = 1;
+	}
+      else if (regcomp (&re,
+			"^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?",
+			REG_EXTENDED) != REG_NOERROR)
+	{
+	  puts ("cannot compile the regular expression");
+	  ret = 1;
+	}
+      else if (regexec (&re, string, 10, mat, 0) == REG_NOMATCH)
+	{
+	  puts ("no match");
+	  ret = 1;
+	}
+      else
+	{
+	  if (! memcmp (mat, expect, sizeof (mat)))
+	    printf ("matching ok for %s locale\n", locales[i]);
+	  else
+	    {
+	      printf ("matching failed for %s locale:\n", locales[i]);
+	      ret = 1;
+	      for (j = 0; j < 9; ++j)
+		if (mat[j].rm_so != -1)
+		  printf ("%d: %.*s\n", j, mat[j].rm_eo - mat[j].rm_so,
+			  string + mat[j].rm_so);
+	    }
+	}
+    }
+
+  return ret;
+}
Index: trunk/src/libctests/glibc/posix/bug-regex7.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-regex7.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-regex7.c	(revision 2036)
@@ -0,0 +1,92 @@
+/* Test for regs allocation in re_search and re_match.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Stepan Kasal <kasal@math.cas.cz>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <regex.h>
+
+
+int
+main (void)
+{
+  struct re_pattern_buffer regex;
+  struct re_registers regs;
+  const char *s;
+  int match, n;
+  int result = 0;
+
+  memset (&regex, '\0', sizeof (regex));
+  regs.start = regs.end = NULL;
+  regs.num_regs = 0;
+  s = re_compile_pattern ("a", 1, &regex);
+  if (s != NULL)
+    {
+      puts ("failed to compile pattern \"a\"");
+      result = 1;
+    }
+  else
+    {
+      match = re_search (&regex, "baobab", 6, 0, 6, &regs);
+      n = 1;
+      if (match != 1)
+	{
+	  printf ("re_search returned %d, expected 1\n", match);
+	  result = 1;
+	}
+      else if (regs.num_regs <= n || regs.start[n] != -1 || regs.end[n] != -1)
+	{
+	  puts ("re_search failed to fill the -1 sentinel");
+	  result = 1;
+	}
+    }
+
+  free (regex.buffer);
+  memset (&regex, '\0', sizeof (regex));
+
+  s = re_compile_pattern ("\\(\\(\\(a\\)\\)\\)", 13, &regex);
+  if (s != NULL)
+    {
+      puts ("failed to compile pattern /\\(\\(\\(a\\)\\)\\)/");
+      result = 1;
+    }
+  else
+    {
+      match = re_match (&regex, "apl", 3, 0, &regs);
+      n = 4;
+      if (match != 1)
+	{
+	  printf ("re_match returned %d, expected 1\n", match);
+	  result = 1;
+	}
+      else if (regs.num_regs <= n || regs.start[n] != -1 || regs.end[n] != -1)
+	{
+	  puts ("re_match failed to fill the -1 sentinel");
+	  result = 1;
+	}
+    }
+
+  if (result == 0)
+    puts (" -> OK");
+
+  return result;
+}
Index: trunk/src/libctests/glibc/posix/bug-regex8.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-regex8.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-regex8.c	(revision 2036)
@@ -0,0 +1,84 @@
+/* Test for the STOP parameter of re_match_2 and re_search_2.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Stepan Kasal <kasal@math.cas.cz>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <regex.h>
+
+
+int
+main (void)
+{
+  struct re_pattern_buffer regex;
+  const char *s;
+  int match[4];
+
+  memset (&regex, '\0', sizeof (regex));
+
+  s = re_compile_pattern ("xy$", 3, &regex);
+  if (s != NULL)
+    {
+      puts ("failed to compile pattern \"xy$\"");
+      return 1;
+    }
+  else
+    match[0] = re_match_2(&regex,"xyz",3,NULL,0,0,NULL,2);
+
+  free (regex.buffer);
+  memset (&regex, '\0', sizeof (regex));
+
+  s = re_compile_pattern ("xy\\>", 4, &regex);
+  if (s != NULL)
+    {
+      puts ("failed to compile pattern \"xy\\>\"");
+      return 1;
+    }
+  else
+    match[1] = re_search_2(&regex,"xyz",3,NULL,0,0,2,NULL,2);
+
+  free (regex.buffer);
+  memset (&regex, '\0', sizeof (regex));
+
+  s = re_compile_pattern ("xy \\<", 5, &regex);
+  if (s != NULL)
+    {
+      puts ("failed to compile pattern \"xy \\<\"");
+      return 1;
+    }
+  else
+    {
+      match[2] = re_match_2(&regex,"xy  ",4,NULL,0,0,NULL,3);
+      match[3] = re_match_2(&regex,"xy z",4,NULL,0,0,NULL,3);
+    }
+
+  if (match[0] != -1 || match[1] != -1 || match[2] != -1 || match[3] != 3)
+    {
+      printf ("re_{match,search}_2 returned %d,%d,%d,%d, expected -1,-1,-1,3\n",
+		match[0], match[1], match[2], match[3]);
+      return 1;
+    }
+
+  puts (" -> OK");
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/posix/bug-regex9.c
===================================================================
--- trunk/src/libctests/glibc/posix/bug-regex9.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/bug-regex9.c	(revision 2036)
@@ -0,0 +1,67 @@
+/* Test for memory handling in regex.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sys/types.h>
+#include <mcheck.h>
+#include <regex.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static const char text[] = "#! /bin/sh";
+
+int
+main (void)
+{
+  regex_t re;
+  regmatch_t rm[2];
+  int n;
+
+  mtrace ();
+
+  n = regcomp (&re, "^#! */.*/(k|ba||pdk|z)sh", REG_EXTENDED);
+  if (n != 0)
+    {
+      char buf[500];
+      regerror (n, &re, buf, sizeof (buf));
+      printf ("regcomp failed: %s\n", buf);
+      exit (1);
+    }
+
+  for (n = 0; n < 20; ++n)
+    {
+      if (regexec (&re, text, 2, rm, 0))
+	{
+	  puts ("regexec failed");
+	  exit (2);
+	}
+      if (rm[0].rm_so != 0 || rm[0].rm_eo != 10
+	  || rm[1].rm_so != 8 || rm[1].rm_eo != 8)
+	{
+	  printf ("regexec match failure: %d %d %d %d\n",
+		  rm[0].rm_so, rm[0].rm_eo, rm[1].rm_so, rm[1].rm_eo);
+	  exit (3);
+	}
+    }
+
+  regfree (&re);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/posix/globtest.c
===================================================================
--- trunk/src/libctests/glibc/posix/globtest.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/globtest.c	(revision 2036)
@@ -0,0 +1,119 @@
+/* Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <getopt.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <glob.h>
+
+int
+main (int argc, char *argv[])
+{
+  int i, j;
+  int glob_flags = 0;
+  glob_t g;
+  int quotes = 1;
+
+  g.gl_offs = 0;
+
+  while ((i = getopt (argc, argv, "bcdeEgmopqstT")) != -1)
+    switch(i)
+      {
+      case 'b':
+	glob_flags |= GLOB_BRACE;
+	break;
+      case 'c':
+	glob_flags |= GLOB_NOCHECK;
+	break;
+      case 'd':
+	glob_flags |= GLOB_ONLYDIR;
+	break;
+      case 'e':
+	glob_flags |= GLOB_NOESCAPE;
+	break;
+      case 'E':
+	glob_flags |= GLOB_ERR;
+	break;
+      case 'g':
+	glob_flags |= GLOB_NOMAGIC;
+	break;
+      case 'm':
+	glob_flags |= GLOB_MARK;
+	break;
+      case 'o':
+	glob_flags |= GLOB_DOOFFS;
+	g.gl_offs = 1;
+	break;
+      case 'p':
+	glob_flags |= GLOB_PERIOD;
+	break;
+      case 'q':
+	quotes = 0;
+	break;
+      case 's':
+	glob_flags |= GLOB_NOSORT;
+	break;
+      case 't':
+	glob_flags |= GLOB_TILDE;
+	break;
+      case 'T':
+	glob_flags |= GLOB_TILDE_CHECK;
+	break;
+      default:
+	exit (-1);
+      }
+
+  if (optind >= argc || chdir (argv[optind]))
+    exit(1);
+
+  j = optind + 1;
+  if (optind + 1 >= argc)
+    exit (1);
+
+  /* Do a glob on each remaining argument.  */
+  for (j = optind + 1; j < argc; j++) {
+    i = glob (argv[j], glob_flags, NULL, &g);
+    if (i != 0)
+      break;
+    glob_flags |= GLOB_APPEND;
+  }
+
+  /* Was there an error? */
+  if (i == GLOB_NOSPACE)
+    puts ("GLOB_NOSPACE");
+  else if (i == GLOB_ABORTED)
+    puts ("GLOB_ABORTED");
+  else if (i == GLOB_NOMATCH)
+    puts ("GLOB_NOMATCH");
+
+  /* If we set an offset, fill in the first field.
+     (Unless glob() has filled it in already - which is an error) */
+  if ((glob_flags & GLOB_DOOFFS) && g.gl_pathv[0] == NULL)
+    g.gl_pathv[0] = (char *) "abc";
+
+  /* Print out the names.  Unless otherwise specified, qoute them.  */
+  if (g.gl_pathv)
+    {
+      for (i = 0; i < g.gl_offs + g.gl_pathc; ++i)
+        printf ("%s%s%s\n", quotes ? "`" : "",
+		g.gl_pathv[i] ? g.gl_pathv[i] : "(null)",
+		quotes ? "'" : "");
+    }
+  return 0;
+}
Index: trunk/src/libctests/glibc/posix/globtest.sh
===================================================================
--- trunk/src/libctests/glibc/posix/globtest.sh	(revision 2036)
+++ trunk/src/libctests/glibc/posix/globtest.sh	(revision 2036)
@@ -0,0 +1,724 @@
+#! /bin/sh
+
+common_objpfx=$1; shift
+elf_objpfx=$1; shift
+rtld_installed_name=$1; shift
+logfile=$common_objpfx/posix/globtest.out
+
+#CMP=cmp
+CMP="diff -u"
+
+# We have to make the paths `common_objpfx' absolute.
+case "$common_objpfx" in
+  .*)
+    common_objpfx="`pwd`/$common_objpfx"
+    ;;
+  *)
+    ;;
+esac
+
+# We have to find the libc and the NSS modules.
+library_path=${common_objpfx}:${common_objpfx}nss:${common_objpfx}nis:${common_objpfx}db2:${common_objpfx}hesiod
+
+# Since we use `sort' we must make sure to use the same locale everywhere.
+LC_ALL=C
+export LC_ALL
+LANG=C
+export LANG
+
+# Create the arena
+: ${TMPDIR=/tmp}
+testdir=$TMPDIR/globtest-dir
+testout=$TMPDIR/globtest-out
+
+trap 'chmod 777 $testdir/noread; rm -fr $testdir $testout' 1 2 3 15
+
+test -d $testdir/noread && chmod 777 $testdir/noread
+rm -fr $testdir 2>/dev/null
+mkdir $testdir
+echo 1 > $testdir/file1
+echo 2 > $testdir/file2
+echo 3 > $testdir/-file3
+echo 4 > $testdir/~file4
+echo 5 > $testdir/.file5
+echo 6 > $testdir/'*file6'
+echo 7 > $testdir/'{file7,}'
+echo 8 > $testdir/'\{file8\}'
+echo 9 > $testdir/'\{file9\,file9b\}'
+echo 9 > $testdir/'\file9b\' #'
+echo a > $testdir/'filea,'
+echo a > $testdir/'fileb}c'
+mkdir $testdir/dir1
+mkdir $testdir/dir2
+test -d $testdir/noread || mkdir $testdir/noread
+chmod a-r $testdir/noread
+echo 1_1 > $testdir/dir1/file1_1
+echo 1_2 > $testdir/dir1/file1_2
+ln -fs dir1 $testdir/link1
+
+# Run some tests.
+result=0
+rm -f $logfile
+
+# Normal test
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest "$testdir" "*" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`*file6'
+`-file3'
+`\file9b\'
+`\{file8\}'
+`\{file9\,file9b\}'
+`dir1'
+`dir2'
+`file1'
+`file2'
+`filea,'
+`fileb}c'
+`link1'
+`noread'
+`{file7,}'
+`~file4'
+EOF
+if test $failed -ne 0; then
+  echo "Normal test failed" >> $logfile
+  result=1
+fi
+
+# Don't let glob sort it
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -s "$testdir" "*" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`*file6'
+`-file3'
+`\file9b\'
+`\{file8\}'
+`\{file9\,file9b\}'
+`dir1'
+`dir2'
+`file1'
+`file2'
+`filea,'
+`fileb}c'
+`link1'
+`noread'
+`{file7,}'
+`~file4'
+EOF
+if test $failed -ne 0; then
+  echo "No sort test failed" >> $logfile
+  result=1
+fi
+
+# Mark directories
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -m "$testdir" "*" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`*file6'
+`-file3'
+`\file9b\'
+`\{file8\}'
+`\{file9\,file9b\}'
+`dir1/'
+`dir2/'
+`file1'
+`file2'
+`filea,'
+`fileb}c'
+`link1/'
+`noread/'
+`{file7,}'
+`~file4'
+EOF
+if test $failed -ne 0; then
+  echo "Mark directories test failed" >> $logfile
+  result=1
+fi
+
+# Find files starting with .
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -p "$testdir" "*" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`*file6'
+`-file3'
+`.'
+`..'
+`.file5'
+`\file9b\'
+`\{file8\}'
+`\{file9\,file9b\}'
+`dir1'
+`dir2'
+`file1'
+`file2'
+`filea,'
+`fileb}c'
+`link1'
+`noread'
+`{file7,}'
+`~file4'
+EOF
+if test $failed -ne 0; then
+  echo "Leading period test failed" >> $logfile
+  result=1
+fi
+
+# Test braces
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -b "$testdir" "file{1,2}" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`file1'
+`file2'
+EOF
+if test $failed -ne 0; then
+  echo "Braces test failed" >> $logfile
+  result=1
+fi
+
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -b "$testdir" "{file{1,2},-file3}" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`-file3'
+`file1'
+`file2'
+EOF
+if test $failed -ne 0; then
+  echo "Braces test 2 failed" >> $logfile
+  result=1
+fi
+
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -b "$testdir" "{" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+GLOB_NOMATCH
+EOF
+if test $failed -ne 0; then
+  echo "Braces test 3 failed" >> $logfile
+  result=1
+fi
+
+# Test NOCHECK
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -c "$testdir" "abc" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`abc'
+EOF
+if test $failed -ne 0; then
+  echo "No check test failed" >> $logfile
+  result=1
+fi
+
+# Test NOMAGIC without magic characters
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -g "$testdir" "abc" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`abc'
+EOF
+if test $failed -ne 0; then
+  echo "No magic test failed" >> $logfile
+  result=1
+fi
+
+# Test NOMAGIC with magic characters
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -g "$testdir" "abc*" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+GLOB_NOMATCH
+EOF
+if test $failed -ne 0; then
+  echo "No magic w/ magic chars test failed" >> $logfile
+  result=1
+fi
+
+# Test NOMAGIC for subdirs
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -g "$testdir" "*/does-not-exist" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+GLOB_NOMATCH
+EOF
+if test $failed -ne 0; then
+  echo "No magic in subdir test failed" >> $logfile
+  result=1
+fi
+
+# Test subdirs correctly
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest "$testdir" "*/*" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`dir1/file1_1'
+`dir1/file1_2'
+`link1/file1_1'
+`link1/file1_2'
+EOF
+if test $failed -ne 0; then
+  echo "Subdirs test failed" >> $logfile
+  result=1
+fi
+
+# Test subdirs for invalid names
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest "$testdir" "*/1" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+GLOB_NOMATCH
+EOF
+if test $failed -ne 0; then
+  echo "Invalid subdir test failed" >> $logfile
+  result=1
+fi
+
+# Test subdirs with wildcard
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest "$testdir" "*/*1_1" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`dir1/file1_1'
+`link1/file1_1'
+EOF
+if test $failed -ne 0; then
+  echo "Wildcard subdir test failed" >> $logfile
+  result=1
+fi
+
+# Test subdirs with ?
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest "$testdir" "*/*?_?" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`dir1/file1_1'
+`dir1/file1_2'
+`link1/file1_1'
+`link1/file1_2'
+EOF
+if test $failed -ne 0; then
+  echo "Wildcard2 subdir test failed" >> $logfile
+  result=1
+fi
+
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest "$testdir" "*/file1_1" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`dir1/file1_1'
+`link1/file1_1'
+EOF
+if test $failed -ne 0; then
+  echo "Wildcard3 subdir test failed" >> $logfile
+  result=1
+fi
+
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest "$testdir" "*-/*" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+GLOB_NOMATCH
+EOF
+if test $failed -ne 0; then
+  echo "Wildcard4 subdir test failed" >> $logfile
+  result=1
+fi
+
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest "$testdir" "*-" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+GLOB_NOMATCH
+EOF
+if test $failed -ne 0; then
+  echo "Wildcard5 subdir test failed" >> $logfile
+  result=1
+fi
+
+# Test subdirs with ?
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest "$testdir" "*/*?_?" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`dir1/file1_1'
+`dir1/file1_2'
+`link1/file1_1'
+`link1/file1_2'
+EOF
+if test $failed -ne 0; then
+  echo "Wildcard6 subdir test failed" >> $logfile
+  result=1
+fi
+
+# Test subdirs with [ .. ]
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest "$testdir" "*/file1_[12]" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`dir1/file1_1'
+`dir1/file1_2'
+`link1/file1_1'
+`link1/file1_2'
+EOF
+if test $failed -ne 0; then
+  echo "Brackets test failed" >> $logfile
+  result=1
+fi
+
+# Test ']' inside bracket expression
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest "$testdir" "dir1/file1_[]12]" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`dir1/file1_1'
+`dir1/file1_2'
+EOF
+if test $failed -ne 0; then
+  echo "Brackets2 test failed" >> $logfile
+  result=1
+fi
+
+# Test tilde expansion
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -q -t "$testdir" "~" |
+sort >$testout
+echo ~ | $CMP - $testout >> $logfile || failed=1
+if test $failed -ne 0; then
+  if test -d ~; then
+    echo "Tilde test failed" >> $logfile
+    result=1
+  else
+    echo "Tilde test could not be run" >> $logfile
+  fi
+fi
+
+# Test tilde expansion with trailing slash
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -q -t "$testdir" "~/" |
+sort > $testout
+# Some shell incorrectly(?) convert ~/ into // if ~ expands to /.
+if test ~/ = //; then
+    echo / | $CMP - $testout >> $logfile || failed=1
+else
+    echo ~/ | $CMP - $testout >> $logfile || failed=1
+fi
+if test $failed -ne 0; then
+  if test -d ~/; then
+    echo "Tilde2 test failed" >> $logfile
+    result=1
+  else
+    echo "Tilde2 test could not be run" >> $logfile
+  fi
+fi
+
+# Test tilde expansion with username
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -q -t "$testdir" "~"$USER |
+sort > $testout
+eval echo ~$USER | $CMP - $testout >> $logfile || failed=1
+if test $failed -ne 0; then
+  if eval test -d ~$USER; then
+    echo "Tilde3 test failed" >> $logfile
+    result=1
+  else
+    echo "Tilde3 test could not be run" >> $logfile
+  fi
+fi
+
+# Tilde expansion shouldn't match a file
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -T "$testdir" "~file4" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+GLOB_NOMATCH
+EOF
+if test $failed -ne 0; then
+  echo "Tilde4 test failed" >> $logfile
+  result=1
+fi
+
+# Matching \** should only find *file6
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest "$testdir" "\**" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`*file6'
+EOF
+if test $failed -ne 0; then
+  echo "Star test failed" >> $logfile
+  result=1
+fi
+
+# ... unless NOESCAPE is used, in which case it should entries with a
+# leading \.
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -e "$testdir" "\**" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`\file9b\'
+`\{file8\}'
+`\{file9\,file9b\}'
+EOF
+if test $failed -ne 0; then
+  echo "Star2 test failed" >> $logfile
+  result=1
+fi
+
+# Matching \*file6 should find *file6
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest "$testdir" "\*file6" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`*file6'
+EOF
+if test $failed -ne 0; then
+  echo "Star3 test failed" >> $logfile
+  result=1
+fi
+
+# GLOB_BRACE alone
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -b "$testdir" '\{file7\,\}' |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`{file7,}'
+EOF
+if test $failed -ne 0; then
+  echo "Brace4 test failed" >> $logfile
+  result=1
+fi
+
+# GLOB_BRACE and GLOB_NOESCAPE
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -b -e "$testdir" '\{file9\,file9b\}' |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`\file9b\'
+EOF
+if test $failed -ne 0; then
+  echo "Brace5 test failed" >> $logfile
+  result=1
+fi
+
+# Escaped comma
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -b "$testdir" '{filea\,}' |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`filea,'
+EOF
+if test $failed -ne 0; then
+  echo "Brace6 test failed" >> $logfile
+  result=1
+fi
+
+# Escaped closing brace
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -b "$testdir" '{fileb\}c}' |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`fileb}c'
+EOF
+if test $failed -ne 0; then
+  echo "Brace7 test failed" >> $logfile
+  result=1
+fi
+
+# Try a recursive failed search
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -e "$testdir" "a*/*" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+GLOB_NOMATCH
+EOF
+if test $failed -ne 0; then
+  echo "Star4 test failed" >> $logfile
+  result=1
+fi
+
+# ... with GLOB_ERR
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -E "$testdir" "a*/*" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+GLOB_NOMATCH
+EOF
+if test $failed -ne 0; then
+  echo "Star5 test failed" >> $logfile
+  result=1
+fi
+
+# Try a recursive search in unreadable directory
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest "$testdir" "noread/*" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+GLOB_NOMATCH
+EOF
+if test $failed -ne 0; then
+  echo "Star6 test failed" >> $logfile
+  result=1
+fi
+
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest "$testdir" "noread*/*" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+GLOB_NOMATCH
+EOF
+if test $failed -ne 0; then
+  echo "Star6 test failed" >> $logfile
+  result=1
+fi
+
+# The following tests will fail if run as root.
+user=`id -un 2> /dev/null`
+if test -z "$user"; then
+    uid="$USER"
+fi
+if test "$user" != root; then
+    # ... with GLOB_ERR
+    ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+    ${common_objpfx}posix/globtest -E "$testdir" "noread/*" |
+    sort > $testout
+    cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+GLOB_ABORTED
+EOF
+
+    ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+    ${common_objpfx}posix/globtest -E "$testdir" "noread*/*" |
+    sort > $testout
+    cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+GLOB_ABORTED
+EOF
+if test $failed -ne 0; then
+  echo "GLOB_ERR test failed" >> $logfile
+  result=1
+fi
+fi # not run as root
+
+# Try multiple patterns (GLOB_APPEND)
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest "$testdir" "file1" "*/*" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`dir1/file1_1'
+`dir1/file1_2'
+`file1'
+`link1/file1_1'
+`link1/file1_2'
+EOF
+if test $failed -ne 0; then
+  echo "GLOB_APPEND test failed" >> $logfile
+  result=1
+fi
+
+# Try multiple patterns (GLOB_APPEND) with offset (GLOB_DOOFFS)
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -o "$testdir" "file1" "*/*" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`abc'
+`dir1/file1_1'
+`dir1/file1_2'
+`file1'
+`link1/file1_1'
+`link1/file1_2'
+EOF
+if test $failed -ne 0; then
+  echo "GLOB_APPEND2 test failed" >> $logfile
+  result=1
+fi
+
+# Test NOCHECK with non-existing file in subdir.
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -c "$testdir" "*/blahblah" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`*/blahblah'
+EOF
+if test $failed -ne 0; then
+  echo "No check2 test failed" >> $logfile
+  result=1
+fi
+
+# Test [[:punct:]] not matching leading period.
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -c "$testdir" "[[:punct:]]*" |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`*file6'
+`-file3'
+`\file9b\'
+`\{file8\}'
+`\{file9\,file9b\}'
+`{file7,}'
+`~file4'
+EOF
+if test $failed -ne 0; then
+  echo "Punct test failed" >> $logfile
+  result=1
+fi
+
+if test $result -eq 0; then
+    chmod 777 $testdir/noread
+    rm -fr $testdir $testout
+    echo "All OK." > $logfile
+fi
+
+exit $result
+
+# Preserve executable bits for this shell script.
+Local Variables:
+eval:(defun frobme () (set-file-modes buffer-file-name file-mode))
+eval:(make-local-variable 'file-mode)
+eval:(setq file-mode (file-modes (buffer-file-name)))
+eval:(make-local-variable 'after-save-hook)
+eval:(add-hook 'after-save-hook 'frobme)
+End:
Index: trunk/src/libctests/glibc/posix/ptestcases.h
===================================================================
--- trunk/src/libctests/glibc/posix/ptestcases.h	(revision 2036)
+++ trunk/src/libctests/glibc/posix/ptestcases.h	(revision 2036)
@@ -0,0 +1,326 @@
+  { 0, 0, "2.8.2  Regular Expression General Requirement", NULL, },
+  { 2, 4, "bb*", "abbbc",  },
+  { 2, 2, "bb*", "ababbbc",  },
+  { 7, 9, "A#*::", "A:A#:qA::qA#::qA##::q",  },
+  { 1, 5, "A#*::", "A##::A#::qA::qA#:q",  },
+  { 0, 0, "2.8.3.1.2  BRE Special Characters", NULL, },
+  { 0, 0, "GA108", NULL, },
+  { 2, 2, "\\.", "a.c",  },
+  { 2, 2, "\\[", "a[c",  },
+  { 2, 2, "\\\\", "a\\c",  },
+  { 2, 2, "\\*", "a*c",  },
+  { 2, 2, "\\^", "a^c",  },
+  { 2, 2, "\\$", "a$c",  },
+  { 7, 11, "X\\*Y\\*8", "Y*8X*8X*Y*8",  },
+  { 0, 0, "GA109", NULL, },
+  { 2, 2, "[.]", "a.c",  },
+  { 2, 2, "[[]", "a[c",  },
+  { -1, -1, "[[]", "ac",  },
+  { 2, 2, "[\\]", "a\\c",  },
+  { 1, 1, "[\\a]", "abc",  },
+  { 2, 2, "[\\.]", "a\\.c",  },
+  { 2, 2, "[\\.]", "a.\\c",  },
+  { 2, 2, "[*]", "a*c",  },
+  { 2, 2, "[$]", "a$c",  },
+  { 2, 2, "[X*Y8]", "7*8YX",  },
+  { 0, 0, "GA110", NULL, },
+  { 2, 2, "*", "a*c",  },
+  { 3, 4, "*a", "*b*a*c",  },
+  { 1, 5, "**9=", "***9=9",  },
+  { 0, 0, "GA111", NULL, },
+  { 1, 1, "^*", "*bc",  },
+  { -1, -1, "^*", "a*c",  },
+  { -1, -1, "^*", "^*ab",  },
+  { 1, 5, "^**9=", "***9=",  },
+  { -1, -1, "^*5<*9", "5<9*5<*9",  },
+  { 0, 0, "GA112", NULL, },
+  { 2, 3, "\\(*b\\)", "a*b",  },
+  { -1, -1, "\\(*b\\)", "ac",  },
+  { 1, 6, "A\\(**9\\)=", "A***9=79",  },
+  { 0, 0, "GA113(1)", NULL, },
+  { 1, 3, "\\(^*ab\\)", "*ab",  },
+  { -1, -1, "\\(^*ab\\)", "^*ab",  },
+  { -1, -1, "\\(^*b\\)", "a*b",  },
+  { -1, -1, "\\(^*b\\)", "^*b",  },
+  { 0, 0, "GA114", NULL, },
+  { 1, 3, "a^b", "a^b",  },
+  { 1, 3, "a\\^b", "a^b",  },
+  { 1, 1, "^^", "^bc",  },
+  { 2, 2, "\\^", "a^c",  },
+  { 1, 1, "[c^b]", "^abc",  },
+  { 1, 1, "[\\^ab]", "^ab",  },
+  { 2, 2, "[\\^ab]", "c\\d",  },
+  { -1, -1, "[^^]", "^",  },
+  { 1, 3, "\\(a^b\\)", "a^b",  },
+  { 1, 3, "\\(a\\^b\\)", "a^b",  },
+  { 2, 2, "\\(\\^\\)", "a^b",  },
+  { 0, 0, "GA115", NULL, },
+  { 3, 3, "$$", "ab$",  },
+  { -1, -1, "$$", "$ab",  },
+  { 2, 3, "$c", "a$c",  },
+  { 2, 2, "[$]", "a$c",  },
+  { 1, 2, "\\$a", "$a",  },
+  { 3, 3, "\\$$", "ab$",  },
+  { 2, 6, "A\\([34]$[34]\\)B", "XA4$3BY",  },
+  { 0, 0, "2.8.3.1.3  Periods in BREs", NULL, },
+  { 0, 0, "GA116", NULL, },
+  { 1, 1, ".", "abc",  },
+  { -1, -1, ".ab", "abc",  },
+  { 1, 3, "ab.", "abc",  },
+  { 1, 3, "a.b", "a,b",  },
+  { -1, -1, ".......", "PqRs6",  },
+  { 1, 7, ".......", "PqRs6T8",  },
+  { 0, 0, "2.8.3.2  RE Bracket Expression", NULL, },
+  { 0, 0, "GA118", NULL, },
+  { 2, 2, "[abc]", "xbyz",  },
+  { -1, -1, "[abc]", "xyz",  },
+  { 2, 2, "[abc]", "xbay",  },
+  { 0, 0, "GA119", NULL, },
+  { 2, 2, "[^a]", "abc",  },
+  { 4, 4, "[^]cd]", "cd]ef",  },
+  { 2, 2, "[^abc]", "axyz",  },
+  { -1, -1, "[^abc]", "abc",  },
+  { 3, 3, "[^[.a.]b]", "abc",  },
+  { 3, 3, "[^[=a=]b]", "abc",  },
+  { 2, 2, "[^-ac]", "abcde-",  },
+  { 2, 2, "[^ac-]", "abcde-",  },
+  { 3, 3, "[^a-b]", "abcde",  },
+  { 3, 3, "[^a-bd-e]", "dec",  },
+  { 2, 2, "[^---]", "-ab",  },
+  { 16, 16, "[^a-zA-Z0-9]", "pqrstVWXYZ23579#",  },
+  { 0, 0, "GA120(1)", NULL, },
+  { 3, 3, "[]a]", "cd]ef",  },
+  { 1, 1, "[]-a]", "a_b",  },
+  { 3, 3, "[][.-.]-0]", "ab0-]",  },
+  { 1, 1, "[]^a-z]", "string",  },
+  { 0, 0, "GA120(2)", NULL, },
+  { 4, 4, "[^]cd]", "cd]ef",  },
+  { 0, 0, "[^]]*", "]]]]]]]]X",  },
+  { 0, 0, "[^]]*", "]]]]]]]]",  },
+  { 9, 9, "[^]]\\{1,\\}", "]]]]]]]]X",  },
+  { -1, -1, "[^]]\\{1,\\}", "]]]]]]]]",  },
+  { 0, 0, "GA120(3)", NULL, },
+  { 3, 3, "[c[.].]d]", "ab]cd",  },
+  { 2, 8, "[a-z]*[[.].]][A-Z]*", "Abcd]DEFg",  },
+  { 0, 0, "GA121", NULL, },
+  { 2, 2, "[[.a.]b]", "Abc",  },
+  { 1, 1, "[[.a.]b]", "aBc",  },
+  { -1, -1, "[[.a.]b]", "ABc",  },
+  { 3, 3, "[^[.a.]b]", "abc",  },
+  { 3, 3, "[][.-.]-0]", "ab0-]",  },
+  { 3, 3, "[A-[.].]c]", "ab]!",  },
+  { 0, 0, "GA122", NULL, },
+  { -2, -2, "[[.ch.]]", "abc",  },
+  { -2, -2, "[[.ab.][.CD.][.EF.]]", "yZabCDEFQ9",  },
+  { 0, 0, "GA125", NULL, },
+  { 2, 2, "[[=a=]b]", "Abc",  },
+  { 1, 1, "[[=a=]b]", "aBc",  },
+  { -1, -1, "[[=a=]b]", "ABc",  },
+  { 3, 3, "[^[=a=]b]", "abc",  },
+  { 0, 0, "GA126", NULL, },
+  { 0, 0, NULL, "the expected result for [[:alnum:]]* is 2-7 which is wrong" },
+  { 0, 0, "[[:alnum:]]*", " aB28gH",  },
+  { 2, 7, "[[:alnum:]][[:alnum:]]*", " aB28gH",  },
+  { 0, 0, NULL, "the expected result for [^[:alnum:]]* is 2-5 which is wrong" },
+  { 0, 0, "[^[:alnum:]]*", "2 	,a",  },
+  { 2, 5, "[^[:alnum:]][^[:alnum:]]*", "2 	,a",  },
+  { 0, 0, NULL, "the expected result for [[:alpha:]]* is 2-5 which is wrong" },
+  { 0, 0, "[[:alpha:]]*", " aBgH2",  },
+  { 2, 5, "[[:alpha:]][[:alpha:]]*", " aBgH2",  },
+  { 1, 6, "[^[:alpha:]]*", "2 	8,a",  },
+  { 1, 2, "[[:blank:]]*", " 	\r",  },
+  { 1, 8, "[^[:blank:]]*", "aB28gH, ",  },
+  { 1, 2, "[[:cntrl:]]*", "	 ",  },
+  { 1, 8, "[^[:cntrl:]]*", "aB2 8gh,",  },
+  { 0, 0, NULL, "the expected result for [[:digit:]]* is 2-3 which is wrong" },
+  { 0, 0, "[[:digit:]]*", "a28",  },
+  { 2, 3, "[[:digit:]][[:digit:]]*", "a28",  },
+  { 1, 8, "[^[:digit:]]*", "aB 	gH,",  },
+  { 1, 7, "[[:graph:]]*", "aB28gH, ",  },
+  { 1, 3, "[^[:graph:]]*", " 	,",  },
+  { 1, 2, "[[:lower:]]*", "agB",  },
+  { 1, 8, "[^[:lower:]]*", "B2 	8H,a",  },
+  { 1, 8, "[[:print:]]*", "aB2 8gH,	",  },
+  { 1, 2, "[^[:print:]]*", "	 ",  },
+  { 0, 0, NULL, "the expected result for [[:punct:]]* is 2-2 which is wrong" },
+  { 0, 0, "[[:punct:]]*", "a,2",  },
+  { 2, 3, "[[:punct:]][[:punct:]]*", "a,,2",  },
+  { 1, 9, "[^[:punct:]]*", "aB2 	8gH",  },
+  { 1, 3, "[[:space:]]*", " 	\r",  },
+  { 0, 0, NULL, "the expected result for [^[:space:]]* is 2-9 which is wrong" },
+  { 0, 0, "[^[:space:]]*", " aB28gH,	",  },
+  { 2, 9, "[^[:space:]][^[:space:]]*", " aB28gH,	",  },
+  { 0, 0, NULL, "the expected result for [[:upper:]]* is 2-3 which is wrong" },
+  { 0, 0, "[[:upper:]]*", "aBH2",  },
+  { 2, 3, "[[:upper:]][[:upper:]]*", "aBH2",  },
+  { 1, 8, "[^[:upper:]]*", "a2 	8g,B",  },
+  { 0, 0, NULL, "the expected result for [[:xdigit:]]* is 2-5 which is wrong" },
+  { 0, 0, "[[:xdigit:]]*", "gaB28h",  },
+  { 2, 5, "[[:xdigit:]][[:xdigit:]]*", "gaB28h",  },
+  { 0, 0, NULL, "the expected result for [^[:xdigit:]]* is 2-7 which is wrong" },
+  { 2, 7, "[^[:xdigit:]][^[:xdigit:]]*", "a 	gH,2",  },
+  { 0, 0, "GA127", NULL, },
+  { -2, -2, "[b-a]", "abc",  },
+  { 1, 1, "[a-c]", "bbccde",  },
+  { 2, 2, "[a-b]", "-bc",  },
+  { 3, 3, "[a-z0-9]", "AB0",  },
+  { 3, 3, "[^a-b]", "abcde",  },
+  { 3, 3, "[^a-bd-e]", "dec",  },
+  { 1, 1, "[]-a]", "a_b",  },
+  { 2, 2, "[+--]", "a,b",  },
+  { 2, 2, "[--/]", "a.b",  },
+  { 2, 2, "[^---]", "-ab",  },
+  { 3, 3, "[][.-.]-0]", "ab0-]",  },
+  { 3, 3, "[A-[.].]c]", "ab]!",  },
+  { 2, 6, "bc[d-w]xy", "abchxyz",  },
+  { 0, 0, "GA129", NULL, },
+  { 1, 1, "[a-cd-f]", "dbccde",  },
+  { -1, -1, "[a-ce-f]", "dBCCdE",  },
+  { 2, 4, "b[n-zA-M]Y", "absY9Z",  },
+  { 2, 4, "b[n-zA-M]Y", "abGY9Z",  },
+  { 0, 0, "GA130", NULL, },
+  { 3, 3, "[-xy]", "ac-",  },
+  { 2, 4, "c[-xy]D", "ac-D+",  },
+  { 2, 2, "[--/]", "a.b",  },
+  { 2, 4, "c[--/]D", "ac.D+b",  },
+  { 2, 2, "[^-ac]", "abcde-",  },
+  { 1, 3, "a[^-ac]c", "abcde-",  },
+  { 3, 3, "[xy-]", "zc-",  },
+  { 2, 4, "c[xy-]7", "zc-786",  },
+  { 2, 2, "[^ac-]", "abcde-",  },
+  { 2, 4, "a[^ac-]c", "5abcde-",  },
+  { 2, 2, "[+--]", "a,b",  },
+  { 2, 4, "a[+--]B", "Xa,By",  },
+  { 2, 2, "[^---]", "-ab",  },
+  { 4, 6, "X[^---]Y", "X-YXaYXbY",  },
+  { 0, 0, "2.8.3.3  BREs Matching Multiple Characters", NULL, },
+  { 0, 0, "GA131", NULL, },
+  { 3, 4, "cd", "abcdeabcde",  },
+  { 1, 2, "ag*b", "abcde",  },
+  { -1, -1, "[a-c][e-f]", "abcdef",  },
+  { 3, 4, "[a-c][e-f]", "acbedf",  },
+  { 4, 8, "abc*XYZ", "890abXYZ#*",  },
+  { 4, 9, "abc*XYZ", "890abcXYZ#*",  },
+  { 4, 15, "abc*XYZ", "890abcccccccXYZ#*",  },
+  { -1, -1, "abc*XYZ", "890abc*XYZ#*",  },
+  { 0, 0, "GA132", NULL, },
+  { 2, 4, "\\(*bc\\)", "a*bc",  },
+  { 1, 2, "\\(ab\\)", "abcde",  },
+  { 1, 10, "\\(a\\(b\\(c\\(d\\(e\\(f\\(g\\)h\\(i\\(j\\)\\)\\)\\)\\)\\)\\)\\)", "abcdefghijk",  },
+  { 3, 8, "43\\(2\\(6\\)*0\\)AB", "654320ABCD",  },
+  { 3, 9, "43\\(2\\(7\\)*0\\)AB", "6543270ABCD",  },
+  { 3, 12, "43\\(2\\(7\\)*0\\)AB", "6543277770ABCD",  },
+  { 0, 0, "GA133", NULL, },
+  { 1, 10, "\\(a\\(b\\(c\\(d\\(e\\(f\\(g\\)h\\(i\\(j\\)\\)\\)\\)\\)\\)\\)\\)", "abcdefghijk",  },
+  { -1, -1, "\\(a\\(b\\(c\\(d\\(e\\(f\\(g\\)h\\(i\\(k\\)\\)\\)\\)\\)\\)\\)\\)", "abcdefghijk",  },
+  { 0, 0, "GA134", NULL, },
+  { 2, 4, "\\(bb*\\)", "abbbc",  },
+  { 2, 2, "\\(bb*\\)", "ababbbc",  },
+  { 1, 6, "a\\(.*b\\)", "ababbbc",  },
+  { 1, 2, "a\\(b*\\)", "ababbbc",  },
+  { 1, 20, "a\\(.*b\\)c", "axcaxbbbcsxbbbbbbbbc",  },
+  { 0, 0, "GA135", NULL, },
+  { 1, 7, "\\(a\\(b\\(c\\(d\\(e\\)\\)\\)\\)\\)\\4", "abcdededede",  },
+  { 0, 0, NULL, "POSIX does not really specify whether a\\(b\\)*c\\1 matches acb." },
+  { 0, 0, NULL, "back references are supposed to expand to the last match, but what" },
+  { 0, 0, NULL, "if there never was a match as in this case?" },
+  { -1, -1, "a\\(b\\)*c\\1", "acb",  },
+  { 1, 11, "\\(a\\(b\\(c\\(d\\(e\\(f\\(g\\)h\\(i\\(j\\)\\)\\)\\)\\)\\)\\)\\)\\9", "abcdefghijjk",  },
+  { 0, 0, "GA136", NULL, },
+  { 0, 0, NULL, "These two tests have the same problem as the test in GA135.  No match" },
+  { 0, 0, NULL, "of a subexpression, why should the back reference be usable?" },
+  { 0, 0, NULL, "1 2 a\\(b\\)*c\\1 acb" },
+  { 0, 0, NULL, "4 7 a\\(b\\(c\\(d\\(f\\)*\\)\\)\\)\\4ŠxYzabcdePQRST" },
+  { -1, -1, "a\\(b\\)*c\\1", "acb",  },
+  { -1, -1, "a\\(b\\(c\\(d\\(f\\)*\\)\\)\\)\\4", "xYzabcdePQRST",  },
+  { 0, 0, "GA137", NULL, },
+  { -2, -2, "\\(a\\(b\\)\\)\\3", "foo",  },
+  { -2, -2, "\\(a\\(b\\)\\)\\(a\\(b\\)\\)\\5", "foo",  },
+  { 0, 0, "GA138", NULL, },
+  { 1, 2, "ag*b", "abcde",  },
+  { 1, 10, "a.*b", "abababvbabc",  },
+  { 2, 5, "b*c", "abbbcdeabbbbbbcde",  },
+  { 2, 5, "bbb*c", "abbbcdeabbbbbbcde",  },
+  { 1, 5, "a\\(b\\)*c\\1", "abbcbbb",  },
+  { -1, -1, "a\\(b\\)*c\\1", "abbdbd",  },
+  { 0, 0, "\\([a-c]*\\)\\1", "abcacdef",  },
+  { 1, 6, "\\([a-c]*\\)\\1", "abcabcabcd",  },
+  { 1, 2, "a^*b", "ab",  },
+  { 1, 5, "a^*b", "a^^^b",  },
+  { 0, 0, "GA139", NULL, },
+  { 1, 2, "a\\{2\\}", "aaaa",  },
+  { 1, 7, "\\([a-c]*\\)\\{0,\\}", "aabcaab",  },
+  { 1, 2, "\\(a\\)\\1\\{1,2\\}", "aabc",  },
+  { 1, 3, "\\(a\\)\\1\\{1,2\\}", "aaaabc",  },
+  { 0, 0, NULL, "the expression \\(\\(a\\)\\1\\)\\{1,2\\} is ill-formed, using \\2" },
+  { 1, 4, "\\(\\(a\\)\\2\\)\\{1,2\\}", "aaaabc",  },
+  { 0, 0, "GA140", NULL, },
+  { 1, 2, "a\\{2\\}", "aaaa",  },
+  { -1, -1, "a\\{2\\}", "abcd",  },
+  { 0, 0, "a\\{0\\}", "aaaa",  },
+  { 1, 64, "a\\{64\\}", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",  },
+  { 0, 0, "GA141", NULL, },
+  { 1, 7, "\\([a-c]*\\)\\{0,\\}", "aabcaab",  },
+  { 0, 0, NULL, "the expected result for \\([a-c]*\\)\\{2,\\} is failure which isn't correct" },
+  { 1, 3, "\\([a-c]*\\)\\{2,\\}", "abcdefg",  },
+  { 1, 3, "\\([a-c]*\\)\\{1,\\}", "abcdefg",  },
+  { -1, -1, "a\\{64,\\}", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",  },
+  { 0, 0, "GA142", NULL, },
+  { 1, 3, "a\\{2,3\\}", "aaaa",  },
+  { -1, -1, "a\\{2,3\\}", "abcd",  },
+  { 0, 0, "\\([a-c]*\\)\\{0,0\\}", "foo",  },
+  { 1, 63, "a\\{1,63\\}", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",  },
+  { 0, 0, "2.8.3.4  BRE Precedence", NULL, },
+  { 0, 0, "GA143", NULL, },
+  { 0, 0, NULL, "There are numerous bugs in the original version." },
+  { 2, 19, "\\^\\[[[.].]]\\\\(\\\\1\\\\)\\*\\\\{1,2\\\\}\\$", "a^[]\\(\\1\\)*\\{1,2\\}$b",  },
+  { 1, 6, "[[=*=]][[=\\=]][[=]=]][[===]][[...]][[:punct:]]", "*\\]=.;",  },
+  { 1, 6, "[$\\(*\\)^]*", "$\\()*^",  },
+  { 1, 1, "[\\1]", "1",  },
+  { 1, 1, "[\\{1,2\\}]", "{",  },
+  { 0, 0, NULL, "the expected result for \\(*\\)*\\1* is 2-2 which isn't correct" },
+  { 0, 0, "\\(*\\)*\\1*", "a*b*11",  },
+  { 2, 3, "\\(*\\)*\\1*b", "a*b*11",  },
+  { 0, 0, NULL, "the expected result for \\(a\\(b\\{1,2\\}\\)\\{1,2\\}\\) is 1-5 which isn't correct" },
+  { 1, 3, "\\(a\\(b\\{1,2\\}\\)\\{1,2\\}\\)", "abbab",  },
+  { 1, 5, "\\(a\\(b\\{1,2\\}\\)\\)\\{1,2\\}", "abbab",  },
+  { 1, 1, "^\\(^\\(^a$\\)$\\)$", "a",  },
+  { 1, 2, "\\(a\\)\\1$", "aa",  },
+  { 1, 3, "ab*", "abb",  },
+  { 1, 4, "ab\\{2,4\\}", "abbbc",  },
+  { 0, 0, "2.8.3.5  BRE Expression Anchoring", NULL, },
+  { 0, 0, "GA144", NULL, },
+  { 1, 1, "^a", "abc",  },
+  { -1, -1, "^b", "abc",  },
+  { -1, -1, "^[a-zA-Z]", "99Nine",  },
+  { 1, 4, "^[a-zA-Z]*", "Nine99",  },
+  { 0, 0, "GA145(1)", NULL, },
+  { 1, 2, "\\(^a\\)\\1", "aabc",  },
+  { -1, -1, "\\(^a\\)\\1", "^a^abc",  },
+  { 1, 2, "\\(^^a\\)", "^a",  },
+  { 1, 1, "\\(^^\\)", "^^",  },
+  { 1, 3, "\\(^abc\\)", "abcdef",  },
+  { -1, -1, "\\(^def\\)", "abcdef",  },
+  { 0, 0, "GA146", NULL, },
+  { 3, 3, "a$", "cba",  },
+  { -1, -1, "a$", "abc",  },
+  { 5, 7, "[a-z]*$", "99ZZxyz",  },
+  { 0, 0, NULL, "the expected result for [a-z]*$ is failure which isn't correct" },
+  { 10, 9, "[a-z]*$", "99ZZxyz99",  },
+  { 3, 3, "$$", "ab$",  },
+  { -1, -1, "$$", "$ab",  },
+  { 3, 3, "\\$$", "ab$",  },
+  { 0, 0, "GA147(1)", NULL, },
+  { -1, -1, "\\(a$\\)\\1", "bcaa",  },
+  { -1, -1, "\\(a$\\)\\1", "ba$",  },
+  { -1, -1, "\\(ab$\\)", "ab$",  },
+  { 1, 2, "\\(ab$\\)", "ab",  },
+  { 4, 6, "\\(def$\\)", "abcdef",  },
+  { -1, -1, "\\(abc$\\)", "abcdef",  },
+  { 0, 0, "GA148", NULL, },
+  { 0, 0, "^$", "",  },
+  { 1, 3, "^abc$", "abc",  },
+  { -1, -1, "^xyz$", "^xyz^",  },
+  { -1, -1, "^234$", "^234$",  },
+  { 1, 9, "^[a-zA-Z0-9]*$", "2aA3bB9zZ",  },
+  { -1, -1, "^[a-z0-9]*$", "2aA3b#B9zZ",  },
Index: trunk/src/libctests/glibc/posix/runptests.c
===================================================================
--- trunk/src/libctests/glibc/posix/runptests.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/runptests.c	(revision 2036)
@@ -0,0 +1,123 @@
+/* POSIX regex testsuite from IEEE 2003.2.
+   Copyright (C) 1998, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sys/types.h>
+#include <regex.h>
+#include <stdio.h>
+#include <string.h>
+
+/* Data structure to describe the tests.  */
+struct test
+{
+  int start;
+  int end;
+  const char *reg;
+  const char *str;
+  int options;
+} tests[] =
+{
+#include "ptestcases.h"
+};
+
+
+int
+main (int argc, char *argv[])
+{
+  size_t cnt;
+  int errors = 0;
+
+  for (cnt = 0; cnt < sizeof (tests) / sizeof (tests[0]); ++cnt)
+    if (tests[cnt].str == NULL)
+      {
+	printf ("\n%s\n%.*s\n", tests[cnt].reg,
+		(int) strlen (tests[cnt].reg),
+		"-----------------------------------------------------");
+      }
+    else if (tests[cnt].reg == NULL)
+	printf ("!!! %s\n", tests[cnt].str);
+    else
+      {
+	regex_t re;
+	regmatch_t match[20];
+	int err;
+
+	printf ("regexp: \"%s\", string: \"%s\" -> ", tests[cnt].reg,
+		tests[cnt].str);
+
+	/* Compile the expression.  */
+	err = regcomp (&re, tests[cnt].reg, tests[cnt].options);
+	if (err != 0)
+	  {
+	    if (tests[cnt].start == -2)
+	      puts ("compiling failed, OK");
+	    else
+	      {
+		char buf[100];
+		regerror (err, &re, buf, sizeof (buf));
+		printf ("FAIL: %s\n", buf);
+		++errors;
+	      }
+
+	    continue;
+	  }
+	else if (tests[cnt].start == -2)
+	  {
+	    puts ("compiling suceeds, FAIL");
+	    errors++;
+	    continue;
+	  }
+
+	/* Run the actual test.  */
+	err = regexec (&re, tests[cnt].str, 20, match, 0);
+
+	if (err != 0)
+	  {
+	    if (tests[cnt].start == -1)
+	      puts ("no match, OK");
+	    else
+	      {
+		puts ("no match, FAIL");
+		++errors;
+	      }
+	  }
+	else
+	  {
+	    if (match[0].rm_so == 0 && tests[cnt].start == 0
+		&& match[0].rm_eo == 0 && tests[cnt].end == 0)
+	      puts ("match, OK");
+	    else if (match[0].rm_so + 1 == tests[cnt].start
+		     && match[0].rm_eo == tests[cnt].end)
+	      puts ("match, OK");
+	    else
+	      {
+		printf ("wrong match (%d to %d): FAIL\n",
+			match[0].rm_so, match[0].rm_eo);
+		++errors;
+	      }
+	  }
+
+	/* Free all resources.  */
+	regfree (&re);
+      }
+
+  printf ("\n%Zu tests, %d errors\n", cnt, errors);
+
+  return errors != 0;
+}
Index: trunk/src/libctests/glibc/posix/runtests.c
===================================================================
--- trunk/src/libctests/glibc/posix/runtests.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/runtests.c	(revision 2036)
@@ -0,0 +1,142 @@
+/***********************************************************
+
+Copyright 1995 by Tom Lord
+
+                        All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the copyright holder not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+Tom Lord DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL TOM LORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
+
+******************************************************************/
+
+
+
+
+#include <sys/types.h>
+#include <regex.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+
+
+struct a_test
+{
+  int expected;
+  const char * pattern;
+  const unsigned char * data;
+};
+
+static const struct a_test the_tests[] =
+{
+#include "testcases.h"
+  {-1, 0, 0}
+};
+
+
+
+
+
+static int
+run_a_test (int id, const struct a_test * t)
+{
+  static const char * last_pattern = 0;
+  static regex_t r;
+  int err;
+  char errmsg[100];
+  int x;
+  regmatch_t regs[10];
+
+  if (!last_pattern || strcmp (last_pattern, t->pattern))
+    {
+      if (last_pattern)
+	regfree (&r);
+      last_pattern = t->pattern;
+      err = regcomp (&r, t->pattern, REG_EXTENDED);
+      if (err)
+	{
+	  if (t->expected == 2)
+	    {
+	      puts (" OK.");
+	      return 0;
+	    }
+	  if (last_pattern)
+	    regfree (&r);
+	  last_pattern = NULL;
+	  regerror (err, &r, errmsg, 100);
+	  printf (" FAIL: %s.\n", errmsg);
+	  return 1;
+	}
+      else if (t->expected == 2)
+	{
+	  printf ("test %d\n", id);
+	  printf ("pattern \"%s\" successfull compilation not expected\n",
+		  t->pattern);
+	  return 1;
+	}
+    }
+
+  err = regexec (&r, t->data, 10, regs, 0);
+
+  if (err != t->expected)
+    {
+      printf ("test %d\n", id);
+      printf ("pattern \"%s\" data \"%s\" wanted %d got %d\n",
+	      t->pattern, t->data, t->expected, err);
+      for (x = 0; x < 10; ++x)
+	printf ("reg %d == (%d, %d) %.*s\n",
+		x,
+		regs[x].rm_so,
+		regs[x].rm_eo,
+		regs[x].rm_eo - regs[x].rm_so,
+		t->data + regs[x].rm_so);
+      return 1;
+    }
+  puts (" OK.");
+  return 0;
+}
+
+
+
+
+int
+main (int argc, char * argv[])
+{
+  int x;
+  int lo;
+  int hi;
+  int res = 0;
+
+  lo = 0;
+  hi = (sizeof (the_tests) / sizeof (the_tests[0])) - 1;
+
+  if (argc > 1)
+    {
+      lo = atoi (argv[1]);
+      hi = lo + 1;
+
+      if (argc > 2)
+	hi = atoi (argv[2]);
+    }
+
+  for (x = lo; x < hi; ++x)
+    {
+      printf ("#%d:", x);
+      res |= run_a_test (x, &the_tests[x]);
+    }
+  return res != 0;
+}
Index: trunk/src/libctests/glibc/posix/rxspencer/tests
===================================================================
--- trunk/src/libctests/glibc/posix/rxspencer/tests	(revision 2036)
+++ trunk/src/libctests/glibc/posix/rxspencer/tests	(revision 2036)
@@ -0,0 +1,538 @@
+# regular expression test set
+# Lines are at least three fields, separated by one or more tabs.  "" stands
+# for an empty field.  First field is an RE.  Second field is flags.  If
+# C flag given, regcomp() is expected to fail, and the third field is the
+# error name (minus the leading REG_).
+#
+# Otherwise it is expected to succeed, and the third field is the string to
+# try matching it against.  If there is no fourth field, the match is
+# expected to fail.  If there is a fourth field, it is the substring that
+# the RE is expected to match.  If there is a fifth field, it is a comma-
+# separated list of what the subexpressions should match, with - indicating
+# no match for that one.  In both the fourth and fifth fields, a (sub)field
+# starting with @ indicates that the (sub)expression is expected to match
+# a null string followed by the stuff after the @; this provides a way to
+# test where null strings match.  The character `N' in REs and strings
+# is newline, `S' is space, `T' is tab, `Z' is NUL.
+#
+# The full list of flags:
+#	-	placeholder, does nothing
+#	b	RE is a BRE, not an ERE
+#	&	try it as both an ERE and a BRE
+#	C	regcomp() error expected, third field is error name
+#	i	REG_ICASE
+#	m	("mundane") REG_NOSPEC
+#	s	REG_NOSUB (not really testable)
+#	n	REG_NEWLINE
+#	^	REG_NOTBOL
+#	$	REG_NOTEOL
+#	#	REG_STARTEND (see below)
+#	p	REG_PEND
+#
+# For REG_STARTEND, the start/end offsets are those of the substring
+# enclosed in ().
+
+# basics
+a		&	a	a
+abc		&	abc	abc
+abc|de		-	abc	abc
+a|b|c		-	abc	a
+
+# parentheses and perversions thereof
+a(b)c		-	abc	abc
+a\(b\)c		b	abc	abc
+a(		C	EPAREN
+a(		b	a(	a(
+a\(		-	a(	a(
+a\(		bC	EPAREN
+a\(b		bC	EPAREN
+a(b		C	EPAREN
+a(b		b	a(b	a(b
+# gag me with a right parenthesis -- 1003.2 goofed here (my fault, partly)
+a)		-	a)	a)
+)		-	)	)
+# end gagging (in a just world, those *should* give EPAREN)
+a)		b	a)	a)
+a\)		bC	EPAREN
+\)		bC	EPAREN
+a()b		-	ab	ab
+a\(\)b		b	ab	ab
+
+# anchoring and REG_NEWLINE
+^abc$		&	abc	abc
+a^b		-	a^b
+a^b		b	a^b	a^b
+a$b		-	a$b
+a$b		b	a$b	a$b
+^		&	abc	@abc
+$		&	abc	@
+^$		&	""	@
+$^		-	""	@
+\($\)\(^\)	b	""	@
+# stop retching, those are legitimate (although disgusting)
+^^		-	""	@
+$$		-	""	@
+b$		&	abNc
+b$		&n	abNc	b
+^b$		&	aNbNc
+^b$		&n	aNbNc	b
+^$		&n	aNNb	@Nb
+^$		n	abc
+^$		n	abcN	@
+$^		n	aNNb	@Nb
+\($\)\(^\)	bn	aNNb	@Nb
+^^		n^	aNNb	@Nb
+$$		n	aNNb	@NN
+^a		^	a
+a$		$	a
+^a		^n	aNb
+^b		^n	aNb	b
+a$		$n	bNa
+b$		$n	bNa	b
+a*(^b$)c*	-	b	b
+a*\(^b$\)c*	b	b	b
+
+# certain syntax errors and non-errors
+|		C	EMPTY
+|		b	|	|
+*		C	BADRPT
+*		b	*	*
++		C	BADRPT
+?		C	BADRPT
+""		&C	EMPTY
+()		-	abc	@abc
+\(\)		b	abc	@abc
+a||b		C	EMPTY
+|ab		C	EMPTY
+ab|		C	EMPTY
+(|a)b		C	EMPTY
+(a|)b		C	EMPTY
+(*a)		C	BADRPT
+(+a)		C	BADRPT
+(?a)		C	BADRPT
+({1}a)		C	BADRPT
+\(\{1\}a\)	bC	BADRPT
+(a|*b)		C	BADRPT
+(a|+b)		C	BADRPT
+(a|?b)		C	BADRPT
+(a|{1}b)	C	BADRPT
+^*		C	BADRPT
+^*		b	*	*
+^+		C	BADRPT
+^?		C	BADRPT
+^{1}		C	BADRPT
+^\{1\}		bC	BADRPT
+
+# metacharacters, backslashes
+a.c		&	abc	abc
+a[bc]d		&	abd	abd
+a\*c		&	a*c	a*c
+a\\b		&	a\b	a\b
+a\\\*b		&	a\*b	a\*b
+# The following test is wrong.  Using \b in an BRE or ERE is undefined.
+# a\bc		&	abc	abc
+a\		&C	EESCAPE
+a\\bc		&	a\bc	a\bc
+\{		bC	BADRPT
+a\[b		&	a[b	a[b
+a[b		&C	EBRACK
+# trailing $ is a peculiar special case for the BRE code
+a$		&	a	a
+a$		&	a$
+a\$		&	a
+a\$		&	a$	a$
+a\\$		&	a
+a\\$		&	a$
+a\\$		&	a\$
+a\\$		&	a\	a\
+
+# back references, ugh
+a\(b\)\2c	bC	ESUBREG
+a\(b\1\)c	bC	ESUBREG
+a\(b*\)c\1d	b	abbcbbd	abbcbbd	bb
+a\(b*\)c\1d	b	abbcbd
+a\(b*\)c\1d	b	abbcbbbd
+^\(.\)\1	b	abc
+a\([bc]\)\1d	b	abcdabbd	abbd	b
+a\(\([bc]\)\2\)*d	b	abbccd	abbccd
+a\(\([bc]\)\2\)*d	b	abbcbd
+# actually, this next one probably ought to fail, but the spec is unclear
+a\(\(b\)*\2\)*d		b	abbbd	abbbd
+# here is a case that no NFA implementation does right
+\(ab*\)[ab]*\1	b	ababaaa	ababaaa	a
+# check out normal matching in the presence of back refs
+\(a\)\1bcd	b	aabcd	aabcd
+\(a\)\1bc*d	b	aabcd	aabcd
+\(a\)\1bc*d	b	aabd	aabd
+\(a\)\1bc*d	b	aabcccd	aabcccd
+\(a\)\1bc*[ce]d	b	aabcccd	aabcccd
+^\(a\)\1b\(c\)*cd$	b	aabcccd	aabcccd
+
+# ordinary repetitions
+ab*c		&	abc	abc
+ab+c		-	abc	abc
+ab?c		-	abc	abc
+a\(*\)b		b	a*b	a*b
+a\(**\)b	b	ab	ab
+a\(***\)b	bC	BADRPT
+*a		b	*a	*a
+**a		b	a	a
+***a		bC	BADRPT
+
+# the dreaded bounded repetitions
+# The following two tests are not correct:
+#{		&	{	{
+#{abc		&	{abc	{abc
+# '{' is always a special char outside bracket expressions.  So test ony BRE:
+{		b	{	{
+{abc		b	{abc	{abc
+{1		C	BADRPT
+{1}		C	BADRPT
+# Same reason as for the two tests above:
+#a{b		&	a{b	a{b
+a{b		b	a{b	a{b
+a{1}b		-	ab	ab
+a\{1\}b		b	ab	ab
+a{1,}b		-	ab	ab
+a\{1,\}b	b	ab	ab
+a{1,2}b		-	aab	aab
+a\{1,2\}b	b	aab	aab
+a{1		C	EBRACE
+a\{1		bC	EBRACE
+a{1a		C	EBRACE
+a\{1a		bC	EBRACE
+a{1a}		C	BADBR
+a\{1a\}		bC	BADBR
+# These four tests checks for undefined behavior.  Our implementation does
+# something different.
+#a{,2}		-	a{,2}	a{,2}
+#a\{,2\}		bC	BADBR
+#a{,}		-	a{,}	a{,}
+#a\{,\}		bC	BADBR
+a{1,x}		C	BADBR
+a\{1,x\}	bC	BADBR
+a{1,x		C	EBRACE
+a\{1,x		bC	EBRACE
+# These two tests probably fails due to an arbitrary limit on the number of
+# repetitions in the other implementation.
+#a{300}		C	BADBR
+#a\{300\}	bC	BADBR
+a{1,0}		C	BADBR
+a\{1,0\}	bC	BADBR
+ab{0,0}c	-	abcac	ac
+ab\{0,0\}c	b	abcac	ac
+ab{0,1}c	-	abcac	abc
+ab\{0,1\}c	b	abcac	abc
+ab{0,3}c	-	abbcac	abbc
+ab\{0,3\}c	b	abbcac	abbc
+ab{1,1}c	-	acabc	abc
+ab\{1,1\}c	b	acabc	abc
+ab{1,3}c	-	acabc	abc
+ab\{1,3\}c	b	acabc	abc
+ab{2,2}c	-	abcabbc	abbc
+ab\{2,2\}c	b	abcabbc	abbc
+ab{2,4}c	-	abcabbc	abbc
+ab\{2,4\}c	b	abcabbc	abbc
+((a{1,10}){1,10}){1,10}	-	a	a	a,a
+
+# multiple repetitions
+# Wow, there is serious disconnect here.  The ERE grammar is like this:
+# ERE_expression : one_char_or_coll_elem_ERE
+#                | '^'
+#                | '$'
+#                | '(' extended_reg_exp ')'
+#                | ERE_expression ERE_dupl_symbol
+#                ;
+# where ERE_dupl_symbol is any of the repetition methods.  It is clear from
+# this that consecutive repetition is OK.  On top of this, the one test not
+# marked as failing must fail.  For BREs the situation is different, so we
+# use the four tests.
+#a**		&C	BADRPT
+a**		bC	BADRPT
+#a++		C	BADRPT
+#a??		C	BADRPT
+#a*+		C	BADRPT
+#a*?		C	BADRPT
+#a+*		C	BADRPT
+#a+?		C	BADRPT
+#a?*		C	BADRPT
+#a?+		C	BADRPT
+#a{1}{1}		C	BADRPT
+#a*{1}		C	BADRPT
+#a+{1}		C	BADRPT
+#a?{1}		C	BADRPT
+#a{1}*		C	BADRPT
+#a{1}+		C	BADRPT
+#a{1}?		C	BADRPT
+#a*{b}		-	a{b}	a{b}
+a\{1\}\{1\}	bC	BADRPT
+a*\{1\}		bC	BADRPT
+a\{1\}*		bC	BADRPT
+
+# brackets, and numerous perversions thereof
+a[b]c		&	abc	abc
+a[ab]c		&	abc	abc
+a[^ab]c		&	adc	adc
+a[]b]c		&	a]c	a]c
+a[[b]c		&	a[c	a[c
+a[-b]c		&	a-c	a-c
+a[^]b]c		&	adc	adc
+a[^-b]c		&	adc	adc
+a[b-]c		&	a-c	a-c
+a[b		&C	EBRACK
+a[]		&C	EBRACK
+a[1-3]c		&	a2c	a2c
+a[3-1]c		&C	ERANGE
+a[1-3-5]c	&C	ERANGE
+a[[.-.]--]c	&	a-c	a-c
+# I don't thing the error value should be ERANGE since a[1-] would be
+# valid, too.  Expect EBRACK.
+#a[1-		&C	ERANGE
+a[1-		&C	EBRACK
+a[[.		&C	EBRACK
+a[[.x		&C	EBRACK
+a[[.x.		&C	EBRACK
+a[[.x.]		&C	EBRACK
+a[[.x.]]	&	ax	ax
+a[[.x,.]]	&C	ECOLLATE
+# This test is invalid.  "one" is no collating symbol in any standardized
+# locale.
+# a[[.one.]]b	&	a1b	a1b
+a[[.notdef.]]b	&C	ECOLLATE
+a[[.].]]b	&	a]b	a]b
+a[[:alpha:]]c	&	abc	abc
+a[[:notdef:]]c	&C	ECTYPE
+a[[:		&C	EBRACK
+a[[:alpha	&C	EBRACK
+a[[:alpha:]	&C	EBRACK
+a[[:alpha,:]	&C	ECTYPE
+a[[:]:]]b	&C	ECTYPE
+a[[:-:]]b	&C	ECTYPE
+a[[:alph:]]	&C	ECTYPE
+a[[:alphabet:]]	&C	ECTYPE
+[[:alnum:]]+	-	-%@a0X-	a0X
+[[:alpha:]]+	-	-%@aX0-	aX
+[[:blank:]]+	-	aSSTb	SST
+[[:cntrl:]]+	-	aNTb	NT
+[[:digit:]]+	-	a019b	019
+[[:graph:]]+	-	Sa%bS	a%b
+[[:lower:]]+	-	AabC	ab
+[[:print:]]+	-	NaSbN	aSb
+[[:punct:]]+	-	S%-&T	%-&
+[[:space:]]+	-	aSNTb	SNT
+[[:upper:]]+	-	aBCd	BC
+[[:xdigit:]]+	-	p0f3Cq	0f3C
+a[[=b=]]c	&	abc	abc
+a[[=		&C	EBRACK
+a[[=b		&C	EBRACK
+a[[=b=		&C	EBRACK
+a[[=b=]		&C	EBRACK
+a[[=b,=]]	&C	ECOLLATE
+# This test is invalid.  "one" is no collating symbol in any standardized
+# locale.
+#a[[=one=]]b	&	a1b	a1b
+
+# complexities
+a(((b)))c	-	abc	abc
+a(b|(c))d	-	abd	abd
+a(b*|c)d	-	abbd	abbd
+# just gotta have one DFA-buster, of course
+a[ab]{20}	-	aaaaabaaaabaaaabaaaab	aaaaabaaaabaaaabaaaab
+# and an inline expansion in case somebody gets tricky
+a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab]	-	aaaaabaaaabaaaabaaaab	aaaaabaaaabaaaabaaaab
+# and in case somebody just slips in an NFA...
+a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab](wee|week)(knights|night)	-	aaaaabaaaabaaaabaaaabweeknights	aaaaabaaaabaaaabaaaabweeknights
+# fish for anomalies as the number of states passes 32
+12345678901234567890123456789	-	a12345678901234567890123456789b	12345678901234567890123456789
+123456789012345678901234567890	-	a123456789012345678901234567890b	123456789012345678901234567890
+1234567890123456789012345678901	-	a1234567890123456789012345678901b	1234567890123456789012345678901
+12345678901234567890123456789012	-	a12345678901234567890123456789012b	12345678901234567890123456789012
+123456789012345678901234567890123	-	a123456789012345678901234567890123b	123456789012345678901234567890123
+# and one really big one, beyond any plausible word width
+1234567890123456789012345678901234567890123456789012345678901234567890	-	a1234567890123456789012345678901234567890123456789012345678901234567890b	1234567890123456789012345678901234567890123456789012345678901234567890
+# fish for problems as brackets go past 8
+[ab][cd][ef][gh][ij][kl][mn]	-	xacegikmoq	acegikm
+[ab][cd][ef][gh][ij][kl][mn][op]	-	xacegikmoq	acegikmo
+[ab][cd][ef][gh][ij][kl][mn][op][qr]	-	xacegikmoqy	acegikmoq
+[ab][cd][ef][gh][ij][kl][mn][op][q]	-	xacegikmoqy	acegikmoq
+
+# subtleties of matching
+abc		&	xabcy	abc
+a\(b\)?c\1d	b	acd
+aBc		i	Abc	Abc
+a[Bc]*d		i	abBCcd	abBCcd
+0[[:upper:]]1	&i	0a1	0a1
+0[[:lower:]]1	&i	0A1	0A1
+a[^b]c		&i	abc
+a[^b]c		&i	aBc
+a[^b]c		&i	adc	adc
+[a]b[c]		-	abc	abc
+[a]b[a]		-	aba	aba
+[abc]b[abc]	-	abc	abc
+[abc]b[abd]	-	abd	abd
+a(b?c)+d	-	accd	accd
+(wee|week)(knights|night)	-	weeknights	weeknights
+(we|wee|week|frob)(knights|night|day)	-	weeknights	weeknights
+a[bc]d		-	xyzaaabcaababdacd	abd
+a[ab]c		-	aaabc	abc
+abc		s	abc	abc
+()		s	abc	@abc
+a*		&	b	@b
+
+# Let's have some fun -- try to match a C comment.
+# first the obvious, which looks okay at first glance...
+/\*.*\*/	-	/*x*/	/*x*/
+# but...
+/\*.*\*/	-	/*x*/y/*z*/	/*x*/y/*z*/
+# okay, we must not match */ inside; try to do that...
+/\*([^*]|\*[^/])*\*/	-	/*x*/	/*x*/
+/\*([^*]|\*[^/])*\*/	-	/*x*/y/*z*/	/*x*/
+# but...
+/\*([^*]|\*[^/])*\*/	-	/*x**/y/*z*/	/*x**/y/*z*/
+# and a still fancier version, which does it right (I think)...
+/\*([^*]|\*+[^*/])*\*+/	-	/*x*/	/*x*/
+/\*([^*]|\*+[^*/])*\*+/	-	/*x*/y/*z*/	/*x*/
+/\*([^*]|\*+[^*/])*\*+/	-	/*x**/y/*z*/	/*x**/
+/\*([^*]|\*+[^*/])*\*+/	-	/*x****/y/*z*/	/*x****/
+/\*([^*]|\*+[^*/])*\*+/	-	/*x**x*/y/*z*/	/*x**x*/
+/\*([^*]|\*+[^*/])*\*+/	-	/*x***x/y/*z*/	/*x***x/y/*z*/
+
+# subexpressions
+.*		-	abc	abc	-
+a(b)(c)d	-	abcd	abcd	b,c
+a(((b)))c	-	abc	abc	b,b,b
+a(b|(c))d	-	abd	abd	b,-
+a(b*|c|e)d	-	abbd	abbd	bb
+a(b*|c|e)d	-	acd	acd	c
+a(b*|c|e)d	-	ad	ad	@d
+a(b?)c		-	abc	abc	b
+a(b?)c		-	ac	ac	@c
+a(b+)c		-	abc	abc	b
+a(b+)c		-	abbbc	abbbc	bbb
+a(b*)c		-	ac	ac	@c
+(a|ab)(bc([de]+)f|cde)	-	abcdef	abcdef	a,bcdef,de
+# the regression tester only asks for 9 subexpressions
+a(b)(c)(d)(e)(f)(g)(h)(i)(j)k	-	abcdefghijk	abcdefghijk	b,c,d,e,f,g,h,i,j
+a(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)l	-	abcdefghijkl	abcdefghijkl	b,c,d,e,f,g,h,i,j,k
+a([bc]?)c	-	abc	abc	b
+a([bc]?)c	-	ac	ac	@c
+a([bc]+)c	-	abc	abc	b
+a([bc]+)c	-	abcc	abcc	bc
+a([bc]+)bc	-	abcbc	abcbc	bc
+a(bb+|b)b	-	abb	abb	b
+a(bbb+|bb+|b)b	-	abb	abb	b
+a(bbb+|bb+|b)b	-	abbb	abbb	bb
+a(bbb+|bb+|b)bb	-	abbb	abbb	b
+(.*).*		-	abcdef	abcdef	abcdef
+(a*)*		-	bc	@b	@b
+
+# do we get the right subexpression when it is used more than once?
+a(b|c)*d	-	ad	ad	-
+a(b|c)*d	-	abcd	abcd	c
+a(b|c)+d	-	abd	abd	b
+a(b|c)+d	-	abcd	abcd	c
+a(b|c?)+d	-	ad	ad	@d
+a(b|c?)+d	-	abcd	abcd	c
+a(b|c){0,0}d	-	ad	ad	-
+a(b|c){0,1}d	-	ad	ad	-
+a(b|c){0,1}d	-	abd	abd	b
+a(b|c){0,2}d	-	ad	ad	-
+a(b|c){0,2}d	-	abcd	abcd	c
+a(b|c){0,}d	-	ad	ad	-
+a(b|c){0,}d	-	abcd	abcd	c
+a(b|c){1,1}d	-	abd	abd	b
+a(b|c){1,1}d	-	acd	acd	c
+a(b|c){1,2}d	-	abd	abd	b
+a(b|c){1,2}d	-	abcd	abcd	c
+a(b|c){1,}d	-	abd	abd	b
+a(b|c){1,}d	-	abcd	abcd	c
+a(b|c){2,2}d	-	acbd	acbd	b
+a(b|c){2,2}d	-	abcd	abcd	c
+a(b|c){2,4}d	-	abcd	abcd	c
+a(b|c){2,4}d	-	abcbd	abcbd	b
+a(b|c){2,4}d	-	abcbcd	abcbcd	c
+a(b|c){2,}d	-	abcd	abcd	c
+a(b|c){2,}d	-	abcbd	abcbd	b
+a(b+|((c)*))+d	-	abd	abd	b,-,-
+a(b+|((c)*))+d	-	abcd	abcd	c,c,c
+
+# check out the STARTEND option
+[abc]		&#	a(b)c	b
+[abc]		&#	a(d)c
+[abc]		&#	a(bc)d	b
+[abc]		&#	a(dc)d	c
+.		&#	a()c
+b.*c		&#	b(bc)c	bc
+b.*		&#	b(bc)c	bc
+.*c		&#	b(bc)c	bc
+
+# plain strings, with the NOSPEC flag
+abc		m	abc	abc
+abc		m	xabcy	abc
+abc		m	xyz
+a*b		m	aba*b	a*b
+a*b		m	ab
+""		mC	EMPTY
+
+# cases involving NULs
+aZb		&	a	a
+aZb		&p	a
+aZb		&p#	(aZb)	aZb
+aZ*b		&p#	(ab)	ab
+a.b		&#	(aZb)	aZb
+a.*		&#	(aZb)c	aZb
+
+# word boundaries (ick)
+[[:<:]]a	&	a	a
+[[:<:]]a	&	ba
+[[:<:]]a	&	-a	a
+a[[:>:]]	&	a	a
+a[[:>:]]	&	ab
+a[[:>:]]	&	a-	a
+[[:<:]]a.c[[:>:]]	&	axcd-dayc-dazce-abc	abc
+[[:<:]]a.c[[:>:]]	&	axcd-dayc-dazce-abc-q	abc
+[[:<:]]a.c[[:>:]]	&	axc-dayc-dazce-abc	axc
+[[:<:]]b.c[[:>:]]	&	a_bxc-byc_d-bzc-q	bzc
+[[:<:]].x..[[:>:]]	&	y_xa_-_xb_y-_xc_-axdc	_xc_
+[[:<:]]a_b[[:>:]]	&	x_a_b
+
+# past problems, and suspected problems
+(A[1])|(A[2])|(A[3])|(A[4])|(A[5])|(A[6])|(A[7])|(A[8])|(A[9])|(A[A])	-	A1	A1
+abcdefghijklmnop	i	abcdefghijklmnop	abcdefghijklmnop
+abcdefghijklmnopqrstuv	i	abcdefghijklmnopqrstuv	abcdefghijklmnopqrstuv
+(ALAK)|(ALT[AB])|(CC[123]1)|(CM[123]1)|(GAMC)|(LC[23][EO ])|(SEM[1234])|(SL[ES][12])|(SLWW)|(SLF )|(SLDT)|(VWH[12])|(WH[34][EW])|(WP1[ESN])	-	CC11	CC11
+CC[13]1|a{21}[23][EO][123][Es][12]a{15}aa[34][EW]aaaaaaa[X]a	-	CC11	CC11
+Char \([a-z0-9_]*\)\[.*	b	Char xyz[k	Char xyz[k	xyz
+a?b	-	ab	ab
+-\{0,1\}[0-9]*$	b	-5	-5
+a*a*a*a*a*a*a*	&	aaaaaa	aaaaaa
+(\b){0}	-	x	@x	-
+\(\b\)\{0,0\}	b	abc	@abc	-
+a(\b){0}c	-	ac	ac	-
+a(.*)b(\1){0}c	-	abc	abc	@bc,-
+a(.*)b(\1){0}c	-	axbc	axbc	x,-
+
+a\(\(b*\)\)c\1d	b	abbcbbd	abbcbbd	bb,bb
+a\(\([bc]\)\)\2d	b	abcdabbd	abbd	b,b
+a\(\(\(\([bc]\)\)\3\)\)*d	b	abbccd	abbccd	cc,cc,c,c
+a(b)(c)d	-	abcd	abcd	b,c
+a(((b)))c	-	abc	abc	b,b,b
+a(((b|(((c))))))d	-	abd	abd	b,b,b,-,-,-
+a(((b*|c|e)))d	-	abbd	abbd	bb,bb,bb
+a((b|c)){0,0}d	-	ad	ad	-,-
+a((b|c)){0,1}d	-	abd	abd	b,b
+a((b|c)){0,2}d	-	abcd	abcd	c,c
+a((b+|((c)*)))+d	-	abd	abd	b,b,-,-
+a((b+|((c)*)))+d	-	abcd	abcd	c,c,c,c
+(((\b))){0}	-	x	@x	-,-,-
+a(((.*)))b((\2)){0}c	-	abc	abc	@bc,@bc,@bc,-,-
+a(((.*)))b((\1)){0}c	-	axbc	axbc	x,x,x,-,-
+
+\b	&	SaT	@aT
+\b	&	aT	@aT
+a.*\b	&	abT	ab
+\b	&	STSS
+\B	&	abc	@bc
+\B	&	aSbTc
+\B	&	SaT	@SaT
+\B	&	aSTSb	@TSb
Index: trunk/src/libctests/glibc/posix/test-vfork.c
===================================================================
--- trunk/src/libctests/glibc/posix/test-vfork.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/test-vfork.c	(revision 2036)
@@ -0,0 +1,42 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <error.h>
+#include <errno.h>
+#include <sys/wait.h>
+
+void __attribute_noinline__ noop (void);
+
+#define NR	2	/* Exit code of the child.  */
+
+int
+main (void)
+{
+  pid_t pid;
+  int status;
+
+  printf ("Before vfork\n");
+  fflush (stdout);
+  pid = vfork ();
+  if (pid == 0)
+    {
+      /* This will clobber the return pc from vfork in the parent on
+	 machines where it is stored on the stack, if vfork wasn't
+	 implemented correctly, */
+      noop ();
+      _exit (NR);
+    }
+  else if (pid < 0)
+    error (1, errno, "vfork");
+  printf ("After vfork (parent)\n");
+  if (waitpid (0, &status, 0) != pid
+      || !WIFEXITED (status) || WEXITSTATUS (status) != NR)
+    exit (1);
+
+  return 0;
+}
+
+void
+noop ()
+{
+}
Index: trunk/src/libctests/glibc/posix/testcases.h
===================================================================
--- trunk/src/libctests/glibc/posix/testcases.h	(revision 2036)
+++ trunk/src/libctests/glibc/posix/testcases.h	(revision 2036)
@@ -0,0 +1,167 @@
+  {0, "(.*)*\\1", "xx"},
+  {0, "^", ""},
+  {0, "$", ""},
+  {0, "^$", ""},
+  {0, "^a$", "a"},
+  {0, "abc", "abc"},
+  {1, "abc", "xbc"},
+  {1, "abc", "axc"},
+  {1, "abc", "abx"},
+  {0, "abc", "xabcy"},
+  {0, "abc", "ababc"},
+  {0, "ab*c", "abc"},
+  {0, "ab*bc", "abc"},
+  {0, "ab*bc", "abbc"},
+  {0, "ab*bc", "abbbbc"},
+  {0, "ab+bc", "abbc"},
+  {1, "ab+bc", "abc"},
+  {1, "ab+bc", "abq"},
+  {0, "ab+bc", "abbbbc"},
+  {0, "ab?bc", "abbc"},
+  {0, "ab?bc", "abc"},
+  {1, "ab?bc", "abbbbc"},
+  {0, "ab?c", "abc"},
+  {0, "^abc$", "abc"},
+  {1, "^abc$", "abcc"},
+  {0, "^abc", "abcc"},
+  {1, "^abc$", "aabc"},
+  {0, "abc$", "aabc"},
+  {0, "^", "abc"},
+  {0, "$", "abc"},
+  {0, "a.c", "abc"},
+  {0, "a.c", "axc"},
+  {0, "a.*c", "axyzc"},
+  {1, "a.*c", "axyzd"},
+  {1, "a[bc]d", "abc"},
+  {0, "a[bc]d", "abd"},
+  {1, "a[b-d]e", "abd"},
+  {0, "a[b-d]e", "ace"},
+  {0, "a[b-d]", "aac"},
+  {0, "a[-b]", "a-"},
+  {0, "a[b-]", "a-"},
+  {2, "a[b-a]", "-"},
+  {2, "a[]b", "-"},
+  {2, "a[", "-"},
+  {0, "a]", "a]"},
+  {0, "a[]]b", "a]b"},
+  {0, "a[^bc]d", "aed"},
+  {1, "a[^bc]d", "abd"},
+  {0, "a[^-b]c", "adc"},
+  {1, "a[^-b]c", "a-c"},
+  {1, "a[^]b]c", "a]c"},
+  {0, "a[^]b]c", "adc"},
+  {0, "ab|cd", "abc"},
+  {0, "ab|cd", "abcd"},
+  {0, "()ef", "def"},
+  {0, "()*", "-"},
+  {2, "*a", "-"},
+  {2, "^*", "-"},
+  {2, "$*", "-"},
+  {2, "(*)b", "-"},
+  {1, "$b", "b"},
+  {2, "a\\", "-"},
+  {0, "a\\(b", "a(b"},
+  {0, "a\\(*b", "ab"},
+  {0, "a\\(*b", "a((b"},
+  {1, "a\\x", "a\\x"},
+  {1, "abc)", "-"},
+  {2, "(abc", "-"},
+  {0, "((a))", "abc"},
+  {0, "(a)b(c)", "abc"},
+  {0, "a+b+c", "aabbabc"},
+  {0, "a**", "-"},
+  {0, "a*?", "-"},
+  {0, "(a*)*", "-"},
+  {0, "(a*)+", "-"},
+  {0, "(a|)*", "-"},
+  {0, "(a*|b)*", "-"},
+  {0, "(a+|b)*", "ab"},
+  {0, "(a+|b)+", "ab"},
+  {0, "(a+|b)?", "ab"},
+  {0, "[^ab]*", "cde"},
+  {0, "(^)*", "-"},
+  {0, "(ab|)*", "-"},
+  {2, ")(", "-"},
+  {1, "abc", ""},
+  {1, "abc", ""},
+  {0, "a*", ""},
+  {0, "([abc])*d", "abbbcd"},
+  {0, "([abc])*bcd", "abcd"},
+  {0, "a|b|c|d|e", "e"},
+  {0, "(a|b|c|d|e)f", "ef"},
+  {0, "((a*|b))*", "-"},
+  {0, "abcd*efg", "abcdefg"},
+  {0, "ab*", "xabyabbbz"},
+  {0, "ab*", "xayabbbz"},
+  {0, "(ab|cd)e", "abcde"},
+  {0, "[abhgefdc]ij", "hij"},
+  {1, "^(ab|cd)e", "abcde"},
+  {0, "(abc|)ef", "abcdef"},
+  {0, "(a|b)c*d", "abcd"},
+  {0, "(ab|ab*)bc", "abc"},
+  {0, "a([bc]*)c*", "abc"},
+  {0, "a([bc]*)(c*d)", "abcd"},
+  {0, "a([bc]+)(c*d)", "abcd"},
+  {0, "a([bc]*)(c+d)", "abcd"},
+  {0, "a[bcd]*dcdcde", "adcdcde"},
+  {1, "a[bcd]+dcdcde", "adcdcde"},
+  {0, "(ab|a)b*c", "abc"},
+  {0, "((a)(b)c)(d)", "abcd"},
+  {0, "[A-Za-z_][A-Za-z0-9_]*", "alpha"},
+  {0, "^a(bc+|b[eh])g|.h$", "abh"},
+  {0, "(bc+d$|ef*g.|h?i(j|k))", "effgz"},
+  {0, "(bc+d$|ef*g.|h?i(j|k))", "ij"},
+  {1, "(bc+d$|ef*g.|h?i(j|k))", "effg"},
+  {1, "(bc+d$|ef*g.|h?i(j|k))", "bcdd"},
+  {0, "(bc+d$|ef*g.|h?i(j|k))", "reffgz"},
+  {1, "((((((((((a))))))))))", "-"},
+  {0, "(((((((((a)))))))))", "a"},
+  {1, "multiple words of text", "uh-uh"},
+  {0, "multiple words", "multiple words, yeah"},
+  {0, "(.*)c(.*)", "abcde"},
+  {1, "\\((.*),", "(.*)\\)"},
+  {1, "[k]", "ab"},
+  {0, "abcd", "abcd"},
+  {0, "a(bc)d", "abcd"},
+  {0, "a[-]?c", "ac"},
+  {0, "(....).*\\1", "beriberi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar Qaddafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Mo'ammar Gadhafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar Kaddafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar Qadhafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Moammar El Kadhafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar Gadafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Mu'ammar al-Qadafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Moamer El Kazzafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Moamar al-Gaddafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Mu'ammar Al Qathafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar Al Qathafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Mo'ammar el-Gadhafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Moamar El Kadhafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar al-Qadhafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Mu'ammar al-Qadhdhafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Mu'ammar Qadafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Moamar Gaddafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Mu'ammar Qadhdhafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar Khaddafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar al-Khaddafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Mu'amar al-Kadafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar Ghaddafy"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar Ghadafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar Ghaddafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muamar Kaddafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar Quathafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar Gheddafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muamar Al-Kaddafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Moammar Khadafy "},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Moammar Qudhafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Mu'ammar al-Qaddafi"},
+  {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Mulazim Awwal Mu'ammar Muhammad Abu Minyar al-Qadhafi"},
+  {0, "[[:digit:]]+", "01234"},
+  {1, "[[:alpha:]]+", "01234"},
+  {0, "^[[:digit:]]*$", "01234"},
+  {1, "^[[:digit:]]*$", "01234a"},
+  {0, "^[[:alnum:]]*$", "01234a"},
+  {0, "^[[:xdigit:]]*$", "01234a"},
+  {1, "^[[:xdigit:]]*$", "01234g"},
+  {0, "^[[:alnum:][:space:]]*$", "Hello world"},
Index: trunk/src/libctests/glibc/posix/testfnm.c
===================================================================
--- trunk/src/libctests/glibc/posix/testfnm.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/testfnm.c	(revision 2036)
@@ -0,0 +1,84 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include "fnmatch.h"
+
+struct {
+  const char *name;
+  const char *pattern;
+  int flags;
+  int expected;
+} tests[] = {
+  { "lib", "*LIB*", FNM_PERIOD, FNM_NOMATCH },
+  { "lib", "*LIB*", FNM_CASEFOLD|FNM_PERIOD, 0 },
+  { "a/b", "a[/]b", 0, 0 },
+  { "a/b", "a[/]b", FNM_PATHNAME, FNM_NOMATCH },
+  { "a/b", "[a-z]/[a-z]", 0, 0 },
+  { "a/b", "*", FNM_PATHNAME, FNM_NOMATCH },
+  { "a/b", "*[/]b", FNM_PATHNAME, FNM_NOMATCH },
+  { "a/b", "*[b]", FNM_PATHNAME, FNM_NOMATCH },
+  { "a/b", "[*]/b", 0, FNM_NOMATCH },
+  { "*/b", "[*]/b", 0, 0 },
+  { "a/b", "[?]/b", 0, FNM_NOMATCH },
+  { "?/b", "[?]/b", 0, 0 },
+  { "a/b", "[[a]/b", 0, 0 },
+  { "[/b", "[[a]/b", 0, 0 },
+  { "a/b", "\\*/b", 0, FNM_NOMATCH },
+  { "*/b", "\\*/b", 0, 0 },
+  { "a/b", "\\?/b", 0, FNM_NOMATCH },
+  { "?/b", "\\?/b", 0, 0 },
+  { "[/b", "[/b", 0, FNM_NOMATCH },
+  { "[/b", "\\[/b", 0, 0 },
+  { "aa/b", "?""?/b", 0, 0 },
+  { "aa/b", "?""?""?b", 0, 0 },
+  { "aa/b", "?""?""?b", FNM_PATHNAME, FNM_NOMATCH },
+  { ".a/b", "?a/b", FNM_PATHNAME|FNM_PERIOD, FNM_NOMATCH },
+  { "a/.b", "a/?b", FNM_PATHNAME|FNM_PERIOD, FNM_NOMATCH },
+  { ".a/b", "*a/b", FNM_PATHNAME|FNM_PERIOD, FNM_NOMATCH },
+  { "a/.b", "a/*b", FNM_PATHNAME|FNM_PERIOD, FNM_NOMATCH },
+  { ".a/b", "[.]a/b", FNM_PATHNAME|FNM_PERIOD, FNM_NOMATCH },
+  { "a/.b", "a/[.]b", FNM_PATHNAME|FNM_PERIOD, FNM_NOMATCH },
+  { "a/b", "*/?", FNM_PATHNAME|FNM_PERIOD, 0 },
+  { "a/b", "?/*", FNM_PATHNAME|FNM_PERIOD, 0 },
+  { ".a/b", ".*/?", FNM_PATHNAME|FNM_PERIOD, 0 },
+  { "a/.b", "*/.?", FNM_PATHNAME|FNM_PERIOD, 0 },
+  { "a/.b", "*/*", FNM_PATHNAME|FNM_PERIOD, FNM_NOMATCH },
+  { "a/.b", "*?*/*", FNM_PERIOD, 0 },
+  { "a./b", "*[.]/b", FNM_PATHNAME|FNM_PERIOD, 0 },
+  { "a/b", "*[[:alpha:]]/*[[:alnum:]]", FNM_PATHNAME, 0 },
+  { "a/b", "*[![:digit:]]*/[![:d-d]", FNM_PATHNAME, 0 },
+  { "a/[", "*[![:digit:]]*/[[:d-d]", FNM_PATHNAME, 0 },
+  { "a/[", "*[![:digit:]]*/[![:d-d]", FNM_PATHNAME, FNM_NOMATCH },
+  { "a.b", "a?b", FNM_PATHNAME|FNM_PERIOD, 0 },
+  { "a.b", "a*b", FNM_PATHNAME|FNM_PERIOD, 0 },
+  { "a.b", "a[.]b", FNM_PATHNAME|FNM_PERIOD, 0 },
+  { "a/b", "*a*", FNM_PATHNAME|FNM_LEADING_DIR, 0 },
+  { "ab/c", "*a?", FNM_PATHNAME|FNM_LEADING_DIR, 0 },
+  { "ab/c", "a?", FNM_PATHNAME|FNM_LEADING_DIR, 0 },
+  { "a/b", "?*/?", FNM_PATHNAME, 0 },
+  { "/b", "*/?", FNM_PATHNAME, 0 },
+  { "/b", "**/?", FNM_PATHNAME, 0 },
+};
+
+int
+main (void)
+{
+  size_t i;
+  int errors = 0;
+
+  for (i = 0; i < sizeof (tests) / sizeof (*tests); i++)
+    {
+      int match;
+
+      match = fnmatch (tests[i].pattern, tests[i].name, tests[i].flags);
+
+      printf ("[%2zd]  %s %s %s  -> %s\n", i, tests[i].pattern,
+	      match == 0 ? "matches" : "does not match",
+	      tests[i].name,
+	      match != tests[i].expected ? "FAIL" : "OK");
+
+      if (match != tests[i].expected)
+	++errors ;
+    }
+
+  return errors != 0;
+}
Index: trunk/src/libctests/glibc/posix/tst-boost.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-boost.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-boost.c	(revision 2036)
@@ -0,0 +1,227 @@
+/* Regular expression tests.
+   Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sys/types.h>
+#include <mcheck.h>
+#include <regex.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+void
+frob_escapes (char *src, int pattern)
+{
+  char *dst;
+
+  for (dst = src; *src != '\0'; dst++, src++)
+    {
+      if (*src == '\\')
+	{
+	  switch (src[1])
+	    {
+	    case 't':
+	      src++;
+	      *dst = '\t';
+	      continue;
+	    case 'n':
+	      src++;
+	      *dst = '\n';
+	      continue;
+	    case 'r':
+	      src++;
+	      *dst = '\r';
+	      continue;
+	    case '\\':
+	    case '^':
+	    case '{':
+	    case '|':
+	    case '}':
+	      if (!pattern)
+		{
+		  src++;
+		  *dst = *src;
+		  continue;
+		}
+	      break;
+	    }
+	}
+      if (src != dst)
+	*dst = *src;
+    }
+  *dst = '\0';
+}
+
+int
+main (int argc, char **argv)
+{
+  int ret = 0, n;
+  char *line = NULL;
+  size_t line_len = 0;
+  ssize_t len;
+  FILE *f;
+  char *pattern, *string;
+  int flags = REG_EXTENDED;
+  int eflags = 0;
+  regex_t re;
+  regmatch_t rm[20];
+
+  mtrace ();
+
+  if (argc < 2)
+    {
+      fprintf (stderr, "Missing test filename\n");
+      return 1;
+    }
+
+  f = fopen (argv[1], "r");
+  if (f == NULL)
+    {
+      fprintf (stderr, "Couldn't open %s\n", argv[1]);
+      return 1;
+    }
+
+  while ((len = getline (&line, &line_len, f)) > 0)
+    {
+      char *p, *q;
+      int i;
+
+      if (line[len - 1] == '\n')
+	line[--len] = '\0';
+
+      puts (line);
+
+      if (line[0] == ';')
+	continue;
+
+      if (line[0] == '\0')
+	continue;
+
+      if (line[0] == '-')
+	{
+	  if (strstr (line, "REG_BASIC"))
+	    flags = 0;
+	  else
+	    flags = REG_EXTENDED;
+	  if (strstr (line, "REG_ICASE"))
+	    flags |= REG_ICASE;
+	  if (strstr (line, "REG_NEWLINE"))
+	    flags |= REG_NEWLINE;
+	  eflags = 0;
+	  if (strstr (line, "REG_NOTBOL"))
+	    eflags |= REG_NOTBOL;
+	  if (strstr (line, "REG_NOTEOL"))
+	    eflags |= REG_NOTEOL;
+	  continue;
+	}
+
+      pattern = line + strspn (line, " \t");
+      if (*pattern == '\0')
+	continue;
+      p = pattern + strcspn (pattern, " \t");
+      if (*p == '\0')
+	continue;
+      *p++ = '\0';
+
+      string = p + strspn (p, " \t");
+      if (*string == '\0')
+	continue;
+      if (*string == '"')
+	{
+	  string++;
+	  p = strchr (string, '"');
+	  if (p == NULL)
+	    continue;
+	  *p++ = '\0';
+	}
+      else
+	{
+	  p = string + strcspn (string, " \t");
+	  if (*string == '!')
+	    string = NULL;
+	  else if (*p == '\0')
+	    continue;
+	  else
+	    *p++ = '\0';
+	}
+
+      frob_escapes (pattern, 1);
+      if (string != NULL)
+	frob_escapes (string, 0);
+
+      n = regcomp (&re, pattern, flags);
+      if (n != 0)
+	{
+	  if (string != NULL)
+	    {
+	      char buf[500];
+	      regerror (n, &re, buf, sizeof (buf));
+	      printf ("FAIL regcomp unexpectedly failed: %s\n",
+		      buf);
+	      ret = 1;
+	    }
+	  continue;
+	}
+      else if (string == NULL)
+	{
+	  regfree (&re);
+	  puts ("FAIL regcomp unpexpectedly succeeded");
+	  ret = 1;
+	  continue;
+	}
+
+      if (regexec (&re, string, 20, rm, eflags))
+	{
+	  for (i = 0; i < 20; ++i)
+	    {
+	      rm[i].rm_so = -1;
+	      rm[i].rm_eo = -1;
+	    }
+	}
+
+      regfree (&re);
+
+      for (i = 0; i < 20 && *p != '\0'; ++i)
+	{
+	  int rm_so, rm_eo;
+
+	  rm_so = strtol (p, &q, 10);
+	  if (p == q)
+	    break;
+	  p = q;
+
+	  rm_eo = strtol (p, &q, 10);
+	  if (p == q)
+	    break;
+	  p = q;
+
+	  if (rm[i].rm_so != rm_so || rm[i].rm_eo != rm_eo)
+	    {
+	      printf ("FAIL rm[%d] %d..%d != expected %d..%d\n",
+		      i, rm[i].rm_so, rm[i].rm_eo, rm_so, rm_eo);
+	      ret = 1;
+	      break;
+	    }
+	}
+    }
+
+  free (line);
+  fclose (f);
+  return ret;
+}
Index: trunk/src/libctests/glibc/posix/tst-chmod.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-chmod.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-chmod.c	(revision 2036)
@@ -0,0 +1,378 @@
+/* Test for chmod functions.
+   Copyright (C) 2000, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <dirent.h>
+#include <errno.h>
+#include <error.h>
+#include <fcntl.h>
+#include <mcheck.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+
+#define OUT_OF_MEMORY \
+  do {									      \
+    puts ("cannot allocate memory");					      \
+    result = 1;								      \
+    goto fail;								      \
+  } while (0)
+
+static int
+do_test (int argc, char *argv[])
+{
+  const char *builddir;
+  struct stat64 st1;
+  struct stat64 st2;
+  char *buf;
+  char *testdir;
+  char *testfile = NULL;
+  char *startdir;
+  size_t buflen;
+  int fd;
+  int result = 0;
+  DIR *dir;
+
+  mtrace ();
+
+  if (argc <= 1)
+    error (EXIT_FAILURE, 0, "no parameters");
+
+  /* This is where we will create the test files.  */
+  builddir = argv[1];
+  buflen = strlen (builddir) + 50;
+
+  startdir = getcwd (NULL, 0);
+  if (startdir == NULL)
+    {
+      printf ("cannot get current directory: %m\n");
+      exit (EXIT_FAILURE);
+    }
+
+  /* A buffer large enough for everything we need.  */
+  buf = (char *) alloca (buflen);
+
+  /* Create the directory name.  */
+  snprintf (buf, buflen, "%s/chmoddirXXXXXX", builddir);
+
+  if (mkdtemp (buf) == NULL)
+    {
+      printf ("cannot create test directory: %m\n");
+      exit (EXIT_FAILURE);
+    }
+
+  if (chmod ("", 0600) == 0)
+    {
+      puts ("chmod(\"\", 0600 didn't fail");
+      result = 1;
+    }
+  else if (errno != ENOENT)
+    {
+      puts ("chmod(\"\",0600) does not set errno to ENOENT");
+      result = 1;
+    }
+
+  /* Create a duplicate.  */
+  testdir = strdup (buf);
+  if (testdir == NULL)
+    OUT_OF_MEMORY;
+
+  if (stat64 (testdir, &st1) != 0)
+    {
+      printf ("cannot stat test directory: %m\n");
+      exit (1);
+    }
+  if (!S_ISDIR (st1.st_mode))
+    {
+      printf ("file not created as directory: %m\n");
+      exit (1);
+    }
+
+  /* We have to wait for a second to make sure the ctime changes.  */
+  sleep (1);
+
+  /* Remove all access rights from the directory.  */
+  if (chmod (testdir, 0) != 0)
+    {
+      printf ("cannot change mode of test directory: %m\n");
+      result = 1;
+      goto fail;
+    }
+
+  if (stat64 (testdir, &st2) != 0)
+    {
+      printf ("cannot stat test directory: %m\n");
+      result = 1;
+      goto fail;
+    }
+
+  /* Compare result.  */
+  if ((st2.st_mode & ALLPERMS) != 0)
+    {
+      printf ("chmod(...,0) on directory left bits nonzero: %o\n",
+	      st2.st_mode & ALLPERMS);
+      result = 1;
+    }
+  if (st1.st_ctime >= st2.st_ctime)
+    {
+      puts ("chmod(...,0) did not set ctime correctly");
+      result = 1;
+    }
+
+  /* Name of a file in the directory.  */
+  snprintf (buf, buflen, "%s/file", testdir);
+  testfile = strdup (buf);
+  if (testfile == NULL)
+    OUT_OF_MEMORY;
+
+  fd = creat (testfile, 0);
+  if (fd != -1)
+    {
+      if (getuid () != 0)
+	{
+	  puts ("managed to create test file in protected directory");
+	  result = 1;
+	}
+      close (fd);
+    }
+  else if (errno != EACCES)
+    {
+      puts ("creat didn't generate correct errno value");
+      result = 1;
+    }
+
+  /* With this mode it still shouldn't be possible to create a file.  */
+  if (chmod (testdir, 0600) != 0)
+    {
+      printf ("cannot change mode of test directory to 0600: %m\n");
+      result = 1;
+      goto fail;
+    }
+
+  fd = creat (testfile, 0);
+  if (fd != -1)
+    {
+      if (getuid () != 0)
+	{
+	  puts ("managed to create test file in no-x protected directory");
+	  result = 1;
+	}
+      close (fd);
+    }
+  else if (errno != EACCES)
+    {
+      puts ("creat didn't generate correct errno value");
+      result = 1;
+    }
+
+  /* Change the directory mode back to allow creating a file.  This
+     time with fchmod.  */
+  dir = opendir (testdir);
+  if (dir != NULL)
+    {
+      if (fchmod (dirfd (dir), 0700) != 0)
+	{
+	  printf ("cannot change mode of test directory to 0700: %m\n");
+	  result = 1;
+	  closedir (dir);
+	  goto fail;
+	}
+
+      closedir (dir);
+    }
+  else
+    {
+      printf ("cannot open directory: %m\n");
+      result = 1;
+
+      if (chmod (testdir, 0700) != 0)
+	{
+	  printf ("cannot change mode of test directory to 0700: %m\n");
+	  goto fail;
+	}
+    }
+
+  fd = creat (testfile, 0);
+  if (fd == -1)
+    {
+      puts ("still didn't manage to create test file in protected directory");
+      result = 1;
+      goto fail;
+    }
+  if (fstat64 (fd, &st1) != 0)
+    {
+      printf ("cannot stat new file: %m\n");
+      result = 1;
+    }
+  else if ((st1.st_mode & ALLPERMS) != 0)
+    {
+      puts ("file not created with access mode 0");
+      result = 1;
+    }
+  close (fd);
+
+  snprintf (buf, buflen, "%s/..", testdir);
+  chdir (buf);
+  /* We are now in the directory above the one we create the test
+     directory in.  */
+
+  sleep (1);
+  snprintf (buf, buflen, "./%s/../%s/file",
+	    basename (testdir), basename (testdir));
+  if (chmod (buf, 0600) != 0)
+    {
+      printf ("cannot change mode of file to 0600: %m\n");
+      result = 1;
+      goto fail;
+    }
+  snprintf (buf, buflen, "./%s//file", basename (testdir));
+  if (stat64 (buf, &st2) != 0)
+    {
+      printf ("cannot stat new file: %m\n");
+      result = 1;
+    }
+  else if ((st2.st_mode & ALLPERMS) != 0600)
+    {
+      puts ("file mode not changed to 0600");
+      result = 1;
+    }
+  else if (st1.st_ctime >= st2.st_ctime)
+    {
+      puts ("chmod(\".../file\",0600) did not set ctime correctly");
+      result = 1;
+    }
+
+  if (chmod (buf, 0777 | S_ISUID | S_ISGID) != 0)
+    {
+      printf ("cannot change mode of file to %o: %m\n",
+	      0777 | S_ISUID | S_ISGID);
+      result = 1;
+    }
+  if (stat64 (buf, &st2) != 0)
+    {
+      printf ("cannot stat test file: %m\n");
+      result = 1;
+    }
+  else if ((st2.st_mode & ALLPERMS) != (0777 | S_ISUID | S_ISGID))
+    {
+      puts ("file mode not changed to 0777 | S_ISUID | S_ISGID");
+      result = 1;
+    }
+
+  if (chmod (basename (testdir), 0777 | S_ISUID | S_ISGID | S_ISVTX) != 0)
+    {
+      printf ("cannot change mode of test directory to %o: %m\n",
+	      0777 | S_ISUID | S_ISGID | S_ISVTX);
+      result = 1;
+    }
+  if (stat64 (basename (testdir), &st2) != 0)
+    {
+      printf ("cannot stat test directory: %m\n");
+      result = 1;
+    }
+  else if ((st2.st_mode & ALLPERMS) != (0777 | S_ISUID | S_ISGID | S_ISVTX))
+    {
+      puts ("directory mode not changed to 0777 | S_ISUID | S_ISGID | S_ISGID");
+      result = 1;
+    }
+
+  snprintf (buf, buflen, "./%s/no-such-file", basename (testdir));
+  if (chmod (buf, 0600) != -1)
+    {
+      puts ("chmod(\".../no-such-file\",0600) did not fail");
+      result = 1;
+    }
+  else if (errno != ENOENT)
+    {
+      puts ("chmod(\".../no-such-file\",0600) does not set errno to ENOENT");
+      result = 1;
+    }
+
+  snprintf (buf, buflen, "%s/", basename (testdir));
+  if (chmod (basename (testdir), 0677) != 0)
+    {
+      printf ("cannot change mode of test directory to 0677: %m\n");
+      result = 1;
+    }
+  else
+    {
+      snprintf (buf, buflen, "./%s/file", basename (testdir));
+      if (chmod (buf, 0600) == 0)
+	{
+	  if (getuid () != 0)
+	    {
+	      puts ("chmod(\".../file\") with no-exec directory succeeded");
+	      result = 1;
+	    }
+	}
+      else if (errno != EACCES)
+	{
+	  puts ("chmod(\".../file\") with no-exec directory didn't set EACCES");
+	  result = 1;
+	}
+    }
+
+  if (chmod (basename (testdir), 0777) != 0)
+    {
+      printf ("cannot change mode of test directory to 0777: %m\n");
+      result = 1;
+      goto fail;
+    }
+
+  snprintf (buf, buflen, "%s/file/cannot-be", basename (testdir));
+  if (chmod (buf, 0600) == 0)
+    {
+      puts ("chmod(\".../file/cannot-be\",0600) did not fail");
+      result = 1;
+    }
+  else if (errno != ENOTDIR)
+    {
+      puts ("chmod(\".../file/cannot-be\",0600) does not set errno to ENOTDIR");
+      result = 1;
+    }
+
+ fail:
+  chdir (startdir);
+
+  /* Remove all the files.  */
+  chmod (testdir, 0700);
+  if (testfile != NULL)
+    {
+      chmod (testfile, 0700);
+      unlink (testfile);
+    }
+  rmdir (testdir);
+
+  /* Free the resources.  */
+  free (testfile);
+  free (testdir);
+  free (startdir);
+
+  return result;
+}
+
+
+/* We need a few seconds since we have a few sleeps in the code.  */
+#define TIMEOUT	20
+
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/posix/tst-dir.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-dir.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-dir.c	(revision 2036)
@@ -0,0 +1,571 @@
+/* Copyright (C) 2000-2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <mcheck.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+
+/* We expect four arguments:
+   - source directory name
+   - object directory
+   - common object directory
+   - the program name with path
+*/
+int
+main (int argc, char *argv[])
+{
+  const char *srcdir;
+  const char *objdir;
+  const char *common_objdir;
+  const char *progpath;
+  struct stat64 st1;
+  struct stat64 st2;
+  struct stat64 st3;
+  DIR *dir1;
+  DIR *dir2;
+  int result = 0;
+  struct dirent64 *d;
+  union
+    {
+      struct dirent64 d;
+      char room [offsetof (struct dirent64, d_name[0]) + NAME_MAX + 1];
+    }
+    direntbuf;
+  char *objdir_copy1;
+  char *objdir_copy2;
+  char *buf;
+  int fd;
+
+  mtrace ();
+
+  if (argc < 5)
+    {
+      puts ("not enough parameters");
+      exit (1);
+    }
+
+  /* Make parameters available with nicer names.  */
+  srcdir = argv[1];
+  objdir = argv[2];
+  common_objdir = argv[3];
+  progpath = argv[4];
+
+  /* First test the current source dir.  We cannot really compare the
+     result of `getpwd' with the srcdir string but we have other means.  */
+  if (stat64 (".", &st1) < 0)
+    {
+      printf ("cannot stat starting directory: %m\n");
+      exit (1);
+    }
+
+  if (chdir (srcdir) < 0)
+    {
+      printf ("cannot change to source directory: %m\n");
+      exit (1);
+    }
+  if (stat64 (".", &st2) < 0)
+    {
+      printf ("cannot stat source directory: %m\n");
+      exit (1);
+    }
+
+  /* The two last stat64 calls better were for the same directory.  */
+  if (st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino)
+    {
+      printf ("stat of source directory failed: (%lld,%lld) vs (%lld,%lld)\n",
+	      (long long int) st1.st_dev, (long long int) st1.st_ino,
+	      (long long int) st2.st_dev, (long long int) st2.st_ino);
+      exit (1);
+    }
+
+  /* Change to the object directory.  */
+  if (chdir (objdir) < 0)
+    {
+      printf ("cannot change to object directory: %m\n");
+      exit (1);
+    }
+  if (stat64 (".", &st1) < 0)
+    {
+      printf ("cannot stat object directory: %m\n");
+      exit (1);
+    }
+  /* Is this the same we get as with the full path?  */
+  if (stat64 (objdir, &st2) < 0)
+    {
+      printf ("cannot stat object directory with full path: %m\n");
+      exit (1);
+    }
+  if (st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino)
+    {
+      printf ("stat of object directory failed: (%lld,%lld) vs (%lld,%lld)\n",
+	      (long long int) st1.st_dev, (long long int) st1.st_ino,
+	      (long long int) st2.st_dev, (long long int) st2.st_ino);
+      exit (1);
+    }
+
+  objdir_copy1 = getcwd (NULL, 0);
+  if (objdir_copy1 == NULL)
+    {
+      printf ("cannot get current directory name for object directory: %m\n");
+      result = 1;
+    }
+
+  /* First test: this directory must include our program.  */
+  if (stat64 (progpath, &st2) < 0)
+    {
+      printf ("cannot stat program: %m\n");
+      exit (1);
+    }
+
+  dir1 = opendir (".");
+  if (dir1 == NULL)
+    {
+      printf ("cannot open object directory: %m\n");
+      exit (1);
+    }
+
+  while ((d = readdir64 (dir1)) != NULL)
+    {
+#ifdef _DIRENT_HAVE_D_TYPE
+      if (d->d_type != DT_UNKNOWN && d->d_type != DT_REG)
+	continue;
+#endif
+
+      if (d->d_ino == st2.st_ino)
+	{
+	  /* Might be it.  Test the device.  We could use the st_dev
+	     element from st1 but what the heck, do more testing.  */
+	  if (stat64 (d->d_name, &st3) < 0)
+	    {
+	      printf ("cannot stat entry from readdir: %m\n");
+	      result = 1;
+	      d = NULL;
+	      break;
+	    }
+
+	  if (st3.st_dev == st2.st_dev)
+	    break;
+	}
+    }
+
+  if (d == NULL)
+    {
+      puts ("haven't found program in object directory");
+      result = 1;
+    }
+
+  /* We leave dir1 open.  */
+
+  /* Stat using file descriptor.  */
+  if (fstat64 (dirfd (dir1), &st2) < 0)
+    {
+      printf ("cannot fstat object directory: %m\n");
+      result = 1;
+    }
+  if (st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino)
+    {
+      printf ("fstat of object directory failed: (%lld,%lld) vs (%lld,%lld)\n",
+	      (long long int) st1.st_dev, (long long int) st1.st_ino,
+	      (long long int) st2.st_dev, (long long int) st2.st_ino);
+      exit (1);
+    }
+
+  if (chdir ("..") < 0)
+    {
+      printf ("cannot go to common object directory with \"..\": %m\n");
+      exit (1);
+    }
+
+  if (stat64 (".", &st1) < 0)
+    {
+      printf ("cannot stat common object directory: %m\n");
+      exit (1);
+    }
+  /* Is this the same we get as with the full path?  */
+  if (stat64 (common_objdir, &st2) < 0)
+    {
+      printf ("cannot stat common object directory with full path: %m\n");
+      exit (1);
+    }
+  if (st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino)
+    {
+      printf ("stat of object directory failed: (%lld,%lld) vs (%lld,%lld)\n",
+	      (long long int) st1.st_dev, (long long int) st1.st_ino,
+	      (long long int) st2.st_dev, (long long int) st2.st_ino);
+      exit (1);
+    }
+
+  /* Stat using file descriptor.  */
+  if (fstat64 (dirfd (dir1), &st2) < 0)
+    {
+      printf ("cannot fstat object directory: %m\n");
+      result = 1;
+    }
+
+  dir2 = opendir (common_objdir);
+  if (dir2 == NULL)
+    {
+      printf ("cannot open common object directory: %m\n");
+      exit (1);
+    }
+
+  while ((d = readdir64 (dir2)) != NULL)
+    {
+#ifdef _DIRENT_HAVE_D_TYPE
+      if (d->d_type != DT_UNKNOWN && d->d_type != DT_DIR)
+	continue;
+#endif
+
+      if (d->d_ino == st2.st_ino)
+	{
+	  /* Might be it.  Test the device.  We could use the st_dev
+	     element from st1 but what the heck, do more testing.  */
+	  if (stat64 (d->d_name, &st3) < 0)
+	    {
+	      printf ("cannot stat entry from readdir: %m\n");
+	      result = 1;
+	      d = NULL;
+	      break;
+	    }
+
+	  if (st3.st_dev == st2.st_dev)
+	    break;
+	}
+    }
+
+  /* This better should be the object directory again.  */
+  if (fchdir (dirfd (dir1)) < 0)
+    {
+      printf ("cannot fchdir to object directory: %m\n");
+      exit (1);
+    }
+
+  objdir_copy2 = getcwd (NULL, 0);
+  if (objdir_copy2 == NULL)
+    {
+      printf ("cannot get current directory name for object directory: %m\n");
+      result = 1;
+    }
+  if (strcmp (objdir_copy1, objdir_copy2) != 0)
+    {
+      puts ("getcwd returned a different string the second time");
+      result = 1;
+    }
+
+  /* This better should be the common object directory again.  */
+  if (fchdir (dirfd (dir2)) < 0)
+    {
+      printf ("cannot fchdir to common object directory: %m\n");
+      exit (1);
+    }
+
+  if (stat64 (".", &st2) < 0)
+    {
+      printf ("cannot stat common object directory: %m\n");
+      exit (1);
+    }
+  if (st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino)
+    {
+      printf ("stat of object directory failed: (%lld,%lld) vs (%lld,%lld)\n",
+	      (long long int) st1.st_dev, (long long int) st1.st_ino,
+	      (long long int) st2.st_dev, (long long int) st2.st_ino);
+      exit (1);
+    }
+
+  buf = (char *) malloc (strlen (objdir_copy1) + 1 + sizeof "tst-dir.XXXXXX");
+  if (buf == NULL)
+    {
+      printf ("cannot allocate buffer: %m");
+      exit (1);
+    }
+
+  stpcpy (stpcpy (stpcpy (buf, objdir_copy1), "/"), "tst-dir.XXXXXX");
+  if (mkdtemp (buf) == NULL)
+    {
+      printf ("cannot create test directory in object directory: %m\n");
+      exit (1);
+    }
+  if (stat64 (buf, &st1) < 0)
+    {
+      printf ("cannot stat new directory \"%s\": %m\n", buf);
+      exit (1);
+    }
+  if (chmod (buf, 0700) < 0)
+    {
+      printf ("cannot change mode of new directory: %m\n");
+      exit (1);
+    }
+
+  /* Try to find the new directory.  */
+  rewinddir (dir1);
+  while (readdir64_r (dir1, &direntbuf.d, &d) == 0 && d != NULL)
+    {
+#ifdef _DIRENT_HAVE_D_TYPE
+      if (d->d_type != DT_UNKNOWN && d->d_type != DT_DIR)
+	continue;
+#endif
+
+      if (d->d_ino == st1.st_ino)
+	{
+	  /* Might be it.  Test the device.  We could use the st_dev
+	     element from st1 but what the heck, do more testing.  */
+	  size_t len = strlen (objdir) + 1 + _D_EXACT_NAMLEN (d) + 1;
+	  char tmpbuf[len];
+
+	  stpcpy (stpcpy (stpcpy (tmpbuf, objdir), "/"), d->d_name);
+
+	  if (stat64 (tmpbuf, &st3) < 0)
+	    {
+	      printf ("cannot stat entry from readdir: %m\n");
+	      result = 1;
+	      d = NULL;
+	      break;
+	    }
+
+	  if (st3.st_dev == st2.st_dev
+	      && strcmp (d->d_name, buf + strlen (buf) - 14) == 0)
+	    break;
+	}
+    }
+
+  if (d == NULL)
+    {
+      printf ("haven't found new directory \"%s\"\n", buf);
+      exit (1);
+    }
+
+  if (closedir (dir2) < 0)
+    {
+      printf ("closing dir2 failed: %m\n");
+      result = 1;
+    }
+
+  if (chdir (buf) < 0)
+    {
+      printf ("cannot change to new directory: %m\n");
+      exit (1);
+    }
+
+  dir2 = opendir (buf);
+  if (dir2 == NULL)
+    {
+      printf ("cannot open new directory: %m\n");
+      exit (1);
+    }
+
+  if (fstat64 (dirfd (dir2), &st2) < 0)
+    {
+      printf ("cannot fstat new directory \"%s\": %m\n", buf);
+      exit (1);
+    }
+  if (st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino)
+    {
+      printf ("stat of new directory failed: (%lld,%lld) vs (%lld,%lld)\n",
+	      (long long int) st1.st_dev, (long long int) st1.st_ino,
+	      (long long int) st2.st_dev, (long long int) st2.st_ino);
+      exit (1);
+    }
+
+  if (mkdir ("another-dir", 0777) < 0)
+    {
+      printf ("cannot create \"another-dir\": %m\n");
+      exit (1);
+    }
+  fd = open ("and-a-file", O_RDWR | O_CREAT | O_EXCL, 0666);
+  if (fd == -1)
+    {
+      printf ("cannot create \"and-a-file\": %m\n");
+      exit (1);
+    }
+  close (fd);
+
+  /* Some tests about error reporting.  */
+  errno = 0;
+  if (chdir ("and-a-file") >= 0)
+    {
+      printf ("chdir to \"and-a-file\" succeeded\n");
+      exit (1);
+    }
+  if (errno != ENOTDIR)
+    {
+      printf ("chdir to \"and-a-file\" didn't set correct error\n");
+      result = 1;
+    }
+
+  errno = 0;
+  if (chdir ("and-a-file/..") >= 0)
+    {
+      printf ("chdir to \"and-a-file/..\" succeeded\n");
+      exit (1);
+    }
+  if (errno != ENOTDIR)
+    {
+      printf ("chdir to \"and-a-file/..\" didn't set correct error\n");
+      result = 1;
+    }
+
+  errno = 0;
+  if (chdir ("another-dir/../and-a-file") >= 0)
+    {
+      printf ("chdir to \"another-dir/../and-a-file\" succeeded\n");
+      exit (1);
+    }
+  if (errno != ENOTDIR)
+    {
+      printf ("chdir to \"another-dir/../and-a-file\" didn't set correct error\n");
+      result = 1;
+    }
+
+  /* We now should have a directory and a file in the new directory.  */
+  rewinddir (dir2);
+  while (readdir64_r (dir2, &direntbuf.d, &d) == 0 && d != NULL)
+    {
+      if (strcmp (d->d_name, ".") == 0
+	  || strcmp (d->d_name, "..") == 0
+	  || strcmp (d->d_name, "another-dir") == 0)
+	{
+#ifdef _DIRENT_HAVE_D_TYPE
+	  if (d->d_type != DT_UNKNOWN && d->d_type != DT_DIR)
+	    {
+	      printf ("d_type for \"%s\" is wrong\n", d->d_name);
+	      result = 1;
+	    }
+#endif
+	  if (stat64 (d->d_name, &st3) < 0)
+	    {
+	      printf ("cannot stat \"%s\" is wrong\n", d->d_name);
+	      result = 1;
+	    }
+	  else if (! S_ISDIR (st3.st_mode))
+	    {
+	      printf ("\"%s\" is no directory\n", d->d_name);
+	      result = 1;
+	    }
+	}
+      else if (strcmp (d->d_name, "and-a-file") == 0)
+	{
+#ifdef _DIRENT_HAVE_D_TYPE
+	  if (d->d_type != DT_UNKNOWN && d->d_type != DT_REG)
+	    {
+	      printf ("d_type for \"%s\" is wrong\n", d->d_name);
+	      result = 1;
+	    }
+#endif
+	  if (stat64 (d->d_name, &st3) < 0)
+	    {
+	      printf ("cannot stat \"%s\" is wrong\n", d->d_name);
+	      result = 1;
+	    }
+	  else if (! S_ISREG (st3.st_mode))
+	    {
+	      printf ("\"%s\" is no regular file\n", d->d_name);
+	      result = 1;
+	    }
+	}
+      else
+	{
+	  printf ("unexpected directory entry \"%s\"\n", d->d_name);
+	  result = 1;
+	}
+    }
+
+  if (stat64 ("does-not-exist", &st1) >= 0)
+    {
+      puts ("stat for unexisting file did not fail");
+      result = 1;
+    }
+
+  /* Free all resources.  */
+
+  if (closedir (dir1) < 0)
+    {
+      printf ("closing dir1 failed: %m\n");
+      result = 1;
+    }
+  if (closedir (dir2) < 0)
+    {
+      printf ("second closing dir2 failed: %m\n");
+      result = 1;
+    }
+
+  if (rmdir ("another-dir") < 0)
+    {
+      printf ("cannot remove \"another-dir\": %m\n");
+      result = 1;
+    }
+
+  if (unlink ("and-a-file") < 0)
+    {
+      printf ("cannot remove \"and-a-file\": %m\n");
+      result = 1;
+    }
+
+  /* One more test before we leave: mkdir() is supposed to fail with
+     EEXIST if the named file is a symlink.  */
+  if (symlink ("a-symlink", "a-symlink") != 0)
+    {
+      printf ("cannot create symlink \"a-symlink\": %m\n");
+      result = 1;
+    }
+  else
+    {
+      if (mkdir ("a-symlink", 0666) == 0)
+	{
+	  puts ("can make directory \"a-symlink\"");
+	  result = 1;
+	}
+      else if (errno != EEXIST)
+	{
+	  puts ("mkdir(\"a-symlink\") does not fail with EEXIST\n");
+	  result = 1;
+	}
+      if (unlink ("a-symlink") < 0)
+	{
+	  printf ("cannot unlink \"a-symlink\": %m\n");
+	  result = 1;
+	}
+    }
+
+  if (chdir (srcdir) < 0)
+    {
+      printf ("cannot change back to source directory: %m\n");
+      exit (1);
+    }
+
+  if (rmdir (buf) < 0)
+    {
+      printf ("cannot remove \"%s\": %m\n", buf);
+      result = 1;
+    }
+  free (objdir_copy1);
+  free (objdir_copy2);
+
+  if (result == 0)
+    puts ("all OK");
+
+  return result;
+}
Index: trunk/src/libctests/glibc/posix/tst-exec.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-exec.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-exec.c	(revision 2036)
@@ -0,0 +1,210 @@
+/* Tests for exec.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <error.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <wait.h>
+
+
+/* Nonzero if the program gets called via `exec'.  */
+static int restart;
+
+
+#define CMDLINE_OPTIONS \
+  { "restart", no_argument, &restart, 1 },
+
+/* Prototype for our test function.  */
+extern void do_prepare (int argc, char *argv[]);
+extern int do_test (int argc, char *argv[]);
+
+/* We have a preparation function.  */
+#define PREPARE do_prepare
+
+#include "../test-skeleton.c"
+
+
+/* Name of the temporary files.  */
+static char *name1;
+static char *name2;
+
+/* The contents of our files.  */
+static const char fd1string[] = "This file should get closed";
+static const char fd2string[] = "This file should stay opened";
+
+
+/* We have a preparation function.  */
+void
+do_prepare (int argc, char *argv[])
+{
+   char name_len;
+
+   name_len = strlen (test_dir);
+   name1 = malloc (name_len + sizeof ("/execXXXXXX"));
+   mempcpy (mempcpy (name1, test_dir, name_len),
+	    "/execXXXXXX", sizeof ("/execXXXXXX"));
+   add_temp_file (name1);
+
+   name2 = malloc (name_len + sizeof ("/execXXXXXX"));
+   mempcpy (mempcpy (name2, test_dir, name_len),
+	    "/execXXXXXX", sizeof ("/execXXXXXX"));
+   add_temp_file (name2);
+}
+
+
+static int
+handle_restart (const char *fd1s, const char *fd2s, const char *name)
+{
+  char buf[100];
+  int fd1;
+  int fd2;
+
+  /* First get the descriptors.  */
+  fd1 = atol (fd1s);
+  fd2 = atol (fd2s);
+
+  /* Sanity check.  */
+  if (fd1 == fd2)
+    error (EXIT_FAILURE, 0, "value of fd1 and fd2 is the same");
+
+  /* First the easy part: read from the file descriptor which is
+     supposed to be open.  */
+  if (lseek (fd2, 0, SEEK_CUR) != strlen (fd2string))
+    error (EXIT_FAILURE, errno, "file 2 not in right position");
+  if (lseek (fd2, 0, SEEK_SET) != 0)
+    error (EXIT_FAILURE, 0, "cannot reset position in file 2");
+  if (read (fd2, buf, sizeof buf) != strlen (fd2string))
+    error (EXIT_FAILURE, 0, "cannot read file 2");
+  if (memcmp (fd2string, buf, strlen (fd2string)) != 0)
+    error (EXIT_FAILURE, 0, "file 2 does not match");
+
+  /* No try to read the first file.  First make sure it is not opened.  */
+  if (lseek (fd1, 0, SEEK_CUR) != (off_t) -1 || errno != EBADF)
+    error (EXIT_FAILURE, 0, "file 1 (%d) is not closed", fd1);
+
+  /* Now open the file and read it.  */
+  fd1 = open (name, O_RDONLY);
+  if (fd1 == -1)
+    error (EXIT_FAILURE, errno,
+	   "cannot open first file \"%s\" for verification", name);
+
+  if (read (fd1, buf, sizeof buf) != strlen (fd1string))
+    error (EXIT_FAILURE, errno, "cannot read file 1");
+  if (memcmp (fd1string, buf, strlen (fd1string)) != 0)
+    error (EXIT_FAILURE, 0, "file 1 does not match");
+
+  return 0;
+}
+
+
+int
+do_test (int argc, char *argv[])
+{
+  pid_t pid;
+  int fd1;
+  int fd2;
+  int flags;
+  int status;
+
+  /* We must have
+     - four parameters left of called initially
+       + path for ld.so
+       + "--library-path"
+       + the library path
+       + the application name
+     - three parameters left if called through re-execution
+       + file descriptor number which is supposed to be closed
+       + the open file descriptor
+       + the name of the closed desriptor
+  */
+
+  if (restart)
+    {
+      if (argc != 4)
+	error (EXIT_FAILURE, 0, "wrong number of arguments (%d)", argc);
+
+      return handle_restart (argv[1], argv[2], argv[3]);
+    }
+
+  if (argc != 5)
+    error (EXIT_FAILURE, 0, "wrong number of arguments (%d)", argc);
+
+  /* Prepare the test.  We are creating two files: one which file descriptor
+     will be marked with FD_CLOEXEC, another which is not.  */
+
+   /* Open our test files.   */
+   fd1 = mkstemp (name1);
+   if (fd1 == -1)
+     error (EXIT_FAILURE, errno, "cannot open test file `%s'", name1);
+   fd2 = mkstemp (name2);
+   if (fd2 == -1)
+     error (EXIT_FAILURE, errno, "cannot open test file `%s'", name2);
+
+   /* Set the bit.  */
+   flags = fcntl (fd1, F_GETFD, 0);
+   if (flags < 0)
+     error (EXIT_FAILURE, errno, "cannot get flags");
+   flags |= FD_CLOEXEC;
+   if (fcntl (fd1, F_SETFD, flags) < 0)
+     error (EXIT_FAILURE, errno, "cannot set flags");
+
+   /* Write something in the files.  */
+   if (write (fd1, fd1string, strlen (fd1string)) != strlen (fd1string))
+     error (EXIT_FAILURE, errno, "cannot write to first file");
+   if (write (fd2, fd2string, strlen (fd2string)) != strlen (fd2string))
+     error (EXIT_FAILURE, errno, "cannot write to second file");
+
+  /* We want to test the `exec' function.  To do this we restart the program
+     with an additional parameter.  But first create another process.  */
+  pid = fork ();
+  if (pid == 0)
+    {
+      char fd1name[18];
+      char fd2name[18];
+
+      snprintf (fd1name, sizeof fd1name, "%d", fd1);
+      snprintf (fd2name, sizeof fd2name, "%d", fd2);
+
+      /* This is the child.  Construct the command line.  */
+      execl (argv[1], argv[1], argv[2], argv[3], argv[4], "--direct",
+	     "--restart", fd1name, fd2name, name1, NULL);
+
+      error (EXIT_FAILURE, errno, "cannot exec");
+    }
+  else if (pid == (pid_t) -1)
+    error (EXIT_FAILURE, errno, "cannot fork");
+
+  /* Wait for the child.  */
+  if (waitpid (pid, &status, 0) != pid)
+    error (EXIT_FAILURE, errno, "wrong child");
+
+  if (WTERMSIG (status) != 0)
+    error (EXIT_FAILURE, 0, "Child terminated incorrectly");
+  status = WEXITSTATUS (status);
+
+  /* Remove the test files.  */
+  unlink (name1);
+  unlink (name2);
+
+  return status;
+}
Index: trunk/src/libctests/glibc/posix/tst-execl1.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-execl1.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-execl1.c	(revision 2036)
@@ -0,0 +1,22 @@
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+
+static int
+do_test (void)
+{
+  static const char prog[] = "does-not-exist";
+  errno = 0;
+  execl (prog, prog, NULL);
+
+  if (errno != ENOENT)
+    {
+      printf ("errno = %d (%m), expected ENOENT\n", errno);
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/posix/tst-execl2.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-execl2.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-execl2.c	(revision 2036)
@@ -0,0 +1,58 @@
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+
+static void prepare (int argc, char *argv[]);
+static int do_test (void);
+#define PREPARE(argc, argv) prepare (argc, argv)
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
+
+
+static char *copy;
+
+static void
+prepare (int argc, char *argv[])
+{
+  char *buf;
+  int off;
+  asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]);
+  if (buf == NULL)
+    {
+      puts ("asprintf  failed");
+      exit (1);
+    }
+  if (system (buf) != 0)
+    {
+      puts ("system  failed");
+      exit (1);
+    }
+
+  /* Make it not executable.  */
+  copy = buf + off;
+  if (chmod (copy, 0666) != 0)
+    {
+      puts ("chmod  failed");
+      exit (1);
+    }
+
+  add_temp_file (copy);
+}
+
+
+static int
+do_test (void)
+{
+  errno = 0;
+  execl (copy, copy, NULL);
+
+  if (errno != EACCES)
+    {
+      printf ("errno = %d (%m), expected EACCES\n", errno);
+      return 1;
+    }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/posix/tst-execle1.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-execle1.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-execle1.c	(revision 2036)
@@ -0,0 +1,23 @@
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+
+static int
+do_test (void)
+{
+  static const char prog[] = "does-not-exist";
+  char *env [] = {"FOO=BAR", NULL};
+  errno = 0;
+  execle (prog, prog, NULL, env);
+
+  if (errno != ENOENT)
+    {
+      printf ("errno = %d (%m), expected ENOENT\n", errno);
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/posix/tst-execle2.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-execle2.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-execle2.c	(revision 2036)
@@ -0,0 +1,59 @@
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+
+static void prepare (int argc, char *argv[]);
+static int do_test (void);
+#define PREPARE(argc, argv) prepare (argc, argv)
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
+
+
+static char *copy;
+
+static void
+prepare (int argc, char *argv[])
+{
+  char *buf;
+  int off;
+  asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]);
+  if (buf == NULL)
+    {
+      puts ("asprintf  failed");
+      exit (1);
+    }
+  if (system (buf) != 0)
+    {
+      puts ("system  failed");
+      exit (1);
+    }
+
+  /* Make it not executable.  */
+  copy = buf + off;
+  if (chmod (copy, 0666) != 0)
+    {
+      puts ("chmod  failed");
+      exit (1);
+    }
+
+  add_temp_file (copy);
+}
+
+
+static int
+do_test (void)
+{
+  char *env[] = {"FOO=BAR", NULL};
+  errno = 0;
+  execle (copy, copy, NULL, env);
+
+  if (errno != EACCES)
+    {
+      printf ("errno = %d (%m), expected EACCES\n", errno);
+      return 1;
+    }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/posix/tst-execlp1.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-execlp1.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-execlp1.c	(revision 2036)
@@ -0,0 +1,34 @@
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+static int
+do_test (void)
+{
+  char *cwd = get_current_dir_name ();
+  if (cwd == NULL)
+    {
+      puts ("get_current_dir_name failed");
+      return 1;
+    }
+
+  /* Make sure we do not find a binary with the name we are going to
+     use.  */
+  setenv ("PATH", cwd, 1);
+
+  static const char prog[] = "does-not-exist";
+  errno = 0;
+  execlp (prog, prog, NULL);
+
+  if (errno != ENOENT)
+    {
+      printf ("errno = %d (%m), expected ENOENT\n", errno);
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/posix/tst-execlp2.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-execlp2.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-execlp2.c	(revision 2036)
@@ -0,0 +1,82 @@
+#include <errno.h>
+#include <libgen.h>
+#undef basename
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+
+static void prepare (int argc, char *argv[]);
+static int do_test (void);
+#define PREPARE(argc, argv) prepare (argc, argv)
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
+
+
+static char *copy;
+
+static void
+prepare (int argc, char *argv[])
+{
+  char *buf;
+  int off;
+  asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]);
+  if (buf == NULL)
+    {
+      puts ("asprintf  failed");
+      exit (1);
+    }
+  if (system (buf) != 0)
+    {
+      puts ("system  failed");
+      exit (1);
+    }
+
+  /* Make it not executable.  */
+  copy = buf + off;
+  if (chmod (copy, 0666) != 0)
+    {
+      puts ("chmod  failed");
+      exit (1);
+    }
+
+  add_temp_file (copy);
+}
+
+
+static int
+do_test (void)
+{
+  /* Make sure we do not find a binary with the name we are going to
+     use.  */
+  char *bindir = strdupa (copy);
+  bindir = canonicalize_file_name (dirname (bindir));
+  if (bindir == NULL)
+    {
+      puts ("canonicalize_file_name failed");
+      return 1;
+    }
+  char *path;
+  asprintf (&path, "%s:../libio:../elf", bindir);
+  if (path == NULL)
+    {
+      puts ("asprintf  failed");
+      return 1;
+    }
+
+  setenv ("PATH", path, 1);
+
+  char *prog = basename (copy);
+  errno = 0;
+  execlp (prog, prog, NULL);
+
+  if (errno != EACCES)
+    {
+      printf ("errno = %d (%m), expected EACCES\n", errno);
+      return 1;
+    }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/posix/tst-execv1.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-execv1.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-execv1.c	(revision 2036)
@@ -0,0 +1,22 @@
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+
+static int
+do_test (void)
+{
+  char *argv[] = { (char *) "does-not-exist", NULL };
+  errno = 0;
+  execv (argv[0], argv);
+
+  if (errno != ENOENT)
+    {
+      printf ("errno = %d (%m), expected ENOENT\n", errno);
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/posix/tst-execv2.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-execv2.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-execv2.c	(revision 2036)
@@ -0,0 +1,60 @@
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+
+static void prepare (int argc, char *argv[]);
+static int do_test (void);
+#define PREPARE(argc, argv) prepare (argc, argv)
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
+
+
+static char *copy;
+
+static void
+prepare (int argc, char *argv[])
+{
+  char *buf;
+  int off;
+  asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]);
+  if (buf == NULL)
+    {
+      puts ("asprintf  failed");
+      exit (1);
+    }
+  if (system (buf) != 0)
+    {
+      puts ("system  failed");
+      exit (1);
+    }
+
+  /* Make it not executable.  */
+  copy = buf + off;
+  if (chmod (copy, 0666) != 0)
+    {
+      puts ("chmod  failed");
+      exit (1);
+    }
+
+  add_temp_file (copy);
+}
+
+
+static int
+do_test (void)
+{
+  char *argv[] = { copy, NULL };
+
+  errno = 0;
+  execv (copy, argv);
+
+  if (errno != EACCES)
+    {
+      printf ("errno = %d (%m), expected EACCES\n", errno);
+      return 1;
+    }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/posix/tst-execve1.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-execve1.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-execve1.c	(revision 2036)
@@ -0,0 +1,23 @@
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+
+static int
+do_test (void)
+{
+  char *argv[] = { (char *) "does-not-exist", NULL };
+  char *envp[] = { (char *) "FOO=BAR", NULL };
+  errno = 0;
+  execve (argv[0], argv, envp);
+
+  if (errno != ENOENT)
+    {
+      printf ("errno = %d (%m), expected ENOENT\n", errno);
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/posix/tst-execve2.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-execve2.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-execve2.c	(revision 2036)
@@ -0,0 +1,61 @@
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+
+static void prepare (int argc, char *argv[]);
+static int do_test (void);
+#define PREPARE(argc, argv) prepare (argc, argv)
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
+
+
+static char *copy;
+
+static void
+prepare (int argc, char *argv[])
+{
+  char *buf;
+  int off;
+  asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]);
+  if (buf == NULL)
+    {
+      puts ("asprintf  failed");
+      exit (1);
+    }
+  if (system (buf) != 0)
+    {
+      puts ("system  failed");
+      exit (1);
+    }
+
+  /* Make it not executable.  */
+  copy = buf + off;
+  if (chmod (copy, 0666) != 0)
+    {
+      puts ("chmod  failed");
+      exit (1);
+    }
+
+  add_temp_file (copy);
+}
+
+
+static int
+do_test (void)
+{
+  char *argv[] = { copy, NULL };
+  char *envp[] = { (char *) "FOO=BAR", NULL };
+
+  errno = 0;
+  execve (copy, argv, envp);
+
+  if (errno != EACCES)
+    {
+      printf ("errno = %d (%m), expected EACCES\n", errno);
+      return 1;
+    }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/posix/tst-execvp1.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-execvp1.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-execvp1.c	(revision 2036)
@@ -0,0 +1,34 @@
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+static int
+do_test (void)
+{
+  char *cwd = get_current_dir_name ();
+  if (cwd == NULL)
+    {
+      puts ("get_current_dir_name failed");
+      return 1;
+    }
+
+  /* Make sure we do not find a binary with the name we are going to
+     use.  */
+  setenv ("PATH", cwd, 1);
+
+  char *argv[] = { (char *) "does-not-exist", NULL };
+  errno = 0;
+  execvp (argv[0], argv);
+
+  if (errno != ENOENT)
+    {
+      printf ("errno = %d (%m), expected ENOENT\n", errno);
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/posix/tst-execvp2.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-execvp2.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-execvp2.c	(revision 2036)
@@ -0,0 +1,82 @@
+#include <errno.h>
+#include <libgen.h>
+#undef basename
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+
+static void prepare (int argc, char *argv[]);
+static int do_test (void);
+#define PREPARE(argc, argv) prepare (argc, argv)
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
+
+
+static char *copy;
+
+static void
+prepare (int argc, char *argv[])
+{
+  char *buf;
+  int off;
+  asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]);
+  if (buf == NULL)
+    {
+      puts ("asprintf  failed");
+      exit (1);
+    }
+  if (system (buf) != 0)
+    {
+      puts ("system  failed");
+      exit (1);
+    }
+
+  /* Make it not executable.  */
+  copy = buf + off;
+  if (chmod (copy, 0666) != 0)
+    {
+      puts ("chmod  failed");
+      exit (1);
+    }
+
+  add_temp_file (copy);
+}
+
+
+static int
+do_test (void)
+{
+  /* Make sure we do not find a binary with the name we are going to
+     use.  */
+  char *bindir = strdupa (copy);
+  bindir = canonicalize_file_name (dirname (bindir));
+  if (bindir == NULL)
+    {
+      puts ("canonicalize_file_name failed");
+      return 1;
+    }
+  char *path;
+  asprintf (&path, "%s:../libio:../elf", bindir);
+  if (path == NULL)
+    {
+      puts ("asprintf  failed");
+      return 1;
+    }
+
+  setenv ("PATH", path, 1);
+
+  char *argv[] = { basename (copy), NULL };
+  errno = 0;
+  execvp (argv[0], argv);
+
+  if (errno != EACCES)
+    {
+      printf ("errno = %d (%m), expected EACCES\n", errno);
+      return 1;
+    }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/posix/tst-execvp3.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-execvp3.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-execvp3.c	(revision 2036)
@@ -0,0 +1,42 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+
+static void do_prepare (void);
+#define PREPARE(argc, argv) do_prepare ()
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+
+#include "../test-skeleton.c"
+
+
+static char *fname;
+
+static void
+do_prepare (void)
+{
+  int fd = create_temp_file ("testscript", &fname);
+  dprintf (fd, "echo foo\n");
+  fchmod (fd, 0700);
+  close (fd);
+}
+
+
+static int
+do_test (void)
+{
+  if  (setenv ("PATH", test_dir, 1) != 0)
+    {
+      puts ("setenv failed");
+      return 1;
+    }
+
+  char *argv[] = { fname, NULL };
+  execvp (basename (fname), argv);
+
+  /* If we come here, the execvp call failed.  */
+  return 1;
+}
Index: trunk/src/libctests/glibc/posix/tst-fnmatch.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-fnmatch.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-fnmatch.c	(revision 2036)
@@ -0,0 +1,388 @@
+/* Tests for fnmatch function.
+   Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <error.h>
+#include <fnmatch.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+
+
+static char *next_input (char **line, int first, int last);
+static int convert_flags (const char *str);
+static char *flag_output (int flags);
+static char *escape (const char *str, size_t *reslenp, char **resbuf);
+
+
+int
+main (void)
+{
+  char *linebuf = NULL;
+  size_t linebuflen = 0;
+  int ntests = 0;
+  int nfailed = 0;
+  char *escinput = NULL;
+  size_t escinputlen = 0;
+  char *escpattern = NULL;
+  size_t escpatternlen = 0;
+  int nr = 0;
+
+  /* Read lines from stdin with the following format:
+
+       locale  input-string  match-string  flags  result
+
+     where `result' is either 0 or 1.  If the first character of a
+     string is '"' we read until the next '"' and handled escaped '"'.  */
+  while (! feof (stdin))
+    {
+      ssize_t n = getline (&linebuf, &linebuflen, stdin);
+      char *cp;
+      const char *locale;
+      const char *input;
+      const char *pattern;
+      const char *result_str;
+      int result;
+      const char *flags;
+      int flags_val;
+      int fnmres;
+      char numbuf[24];
+
+      if (n == -1)
+	break;
+
+      if (n == 0)
+	/* Maybe an empty line.  */
+	continue;
+
+      /* Skip over all leading white spaces.  */
+      cp = linebuf;
+
+      locale = next_input (&cp, 1, 0);
+      if (locale == NULL)
+	continue;
+
+      input = next_input (&cp, 0, 0);
+      if (input == NULL)
+	continue;
+
+      pattern = next_input (&cp, 0, 0);
+      if (pattern == NULL)
+	continue;
+
+      result_str = next_input (&cp, 0, 0);
+      if (result_str == NULL)
+	continue;
+
+      if (strcmp (result_str, "0") == 0)
+	result = 0;
+      else if  (strcasecmp (result_str, "NOMATCH") == 0)
+	result = FNM_NOMATCH;
+      else
+	{
+	  char *endp;
+	  result = strtol (result_str, &endp, 0);
+	  if (*endp != '\0')
+	    continue;
+	}
+
+      flags = next_input (&cp, 0, 1);
+      if (flags == NULL)
+	/* We allow the flags missing.  */
+	flags = "";
+
+      /* Convert the text describing the flags in a numeric value.  */
+      flags_val = convert_flags (flags);
+      if (flags_val == -1)
+	/* Something went wrong.  */
+	continue;
+
+      /* Now run the actual test.  */
+      ++ntests;
+
+      if (setlocale (LC_COLLATE, locale) == NULL
+	  || setlocale (LC_CTYPE, locale) == NULL)
+	{
+	  puts ("*** Cannot set locale");
+	  ++nfailed;
+	  continue;
+	}
+
+      fnmres = fnmatch (pattern, input, flags_val);
+
+      printf ("%3d: fnmatch (\"%s\", \"%s\", %s) = %s%c",
+	      ++nr,
+	      escape (pattern, &escpatternlen, &escpattern),
+	      escape (input, &escinputlen, &escinput),
+	      flag_output (flags_val),
+	      (fnmres == 0
+	       ? "0" : (fnmres == FNM_NOMATCH
+			? "FNM_NOMATCH"
+			: (sprintf (numbuf, "%d", fnmres), numbuf))),
+	      (fnmres != 0) != (result != 0) ? ' ' : '\n');
+
+      if ((fnmres != 0) != (result != 0))
+	{
+	  printf ("(FAIL, expected %s) ***\n",
+		  result == 0
+		  ? "0" : (result == FNM_NOMATCH
+			   ? "FNM_NOMATCH"
+			   : (sprintf (numbuf, "%d", result), numbuf)));
+	  ++nfailed;
+	}
+    }
+
+  printf ("=====================\n%3d tests, %3d failed\n", ntests, nfailed);
+
+  free (escpattern);
+  free (escinput);
+  free (linebuf);
+
+  return nfailed != 0;
+}
+
+
+static char *
+next_input (char **line, int first, int last)
+{
+  char *cp = *line;
+  char *result;
+
+  while (*cp == ' ' || *cp == '\t')
+    ++cp;
+
+  /* We allow comment lines starting with '#'.  */
+  if (first && *cp == '#')
+    return NULL;
+
+  if (*cp == '"')
+    {
+      char *wp;
+
+      result = ++cp;
+      wp = cp;
+
+      while (*cp != '"' && *cp != '\0' && *cp != '\n')
+	if (*cp == '\\')
+	  {
+	    if (cp[1] == '\n' || cp[1] == '\0')
+	      return NULL;
+
+	    ++cp;
+	    if (*cp == 't')
+	      *wp++ = '\t';
+	    else if (*cp == 'n')
+	      *wp++ = '\n';
+	    else
+	      *wp++ = *cp;
+
+	    ++cp;
+	  }
+	else
+	  *wp++ = *cp++;
+
+      if (*cp != '"')
+	return NULL;
+
+      if (wp != cp)
+	*wp = '\0';
+    }
+  else
+    {
+      result = cp;
+      while (*cp != '\0' && *cp != '\n' && *cp != ' ' && *cp != '\t')
+	++cp;
+
+      if (cp == result && ! last)
+	/* Premature end of line.  */
+	return NULL;
+    }
+
+  /* Terminate and skip over the next white spaces.  */
+  *cp++ = '\0';
+
+  *line = cp;
+  return result;
+}
+
+
+static int
+convert_flags (const char *str)
+{
+  int result = 0;
+
+  while (*str != '\0')
+    {
+      int len;
+
+      if (strncasecmp (str, "PATHNAME", 8) == 0
+	  && (str[8] == '|' || str[8] == '\0'))
+	{
+	  result |= FNM_PATHNAME;
+	  len = 8;
+	}
+      else if (strncasecmp (str, "NOESCAPE", 8) == 0
+	       && (str[8] == '|' || str[8] == '\0'))
+	{
+	  result |= FNM_NOESCAPE;
+	  len = 8;
+	}
+      else if (strncasecmp (str, "PERIOD", 6) == 0
+	       && (str[6] == '|' || str[6] == '\0'))
+	{
+	  result |= FNM_PERIOD;
+	  len = 6;
+	}
+      else if (strncasecmp (str, "LEADING_DIR", 11) == 0
+	       && (str[11] == '|' || str[11] == '\0'))
+	{
+	  result |= FNM_LEADING_DIR;
+	  len = 11;
+	}
+      else if (strncasecmp (str, "CASEFOLD", 8) == 0
+	       && (str[8] == '|' || str[8] == '\0'))
+	{
+	  result |= FNM_CASEFOLD;
+	  len = 8;
+	}
+      else if (strncasecmp (str, "EXTMATCH", 8) == 0
+	       && (str[8] == '|' || str[8] == '\0'))
+	{
+	  result |= FNM_EXTMATCH;
+	  len = 8;
+	}
+      else
+	return -1;
+
+      str += len;
+      if (*str != '\0')
+	++str;
+    }
+
+  return result;
+}
+
+
+static char *
+flag_output (int flags)
+{
+  static char buf[100];
+  int first = 1;
+  char *cp = buf;
+
+  if (flags & FNM_PATHNAME)
+    {
+      cp = stpcpy (cp, "FNM_PATHNAME");
+      first = 0;
+    }
+  if (flags & FNM_NOESCAPE)
+    {
+      if (! first)
+	*cp++ = '|';
+      cp = stpcpy (cp, "FNM_NOESCAPE");
+      first = 0;
+    }
+  if (flags & FNM_PERIOD)
+    {
+      if (! first)
+	*cp++ = '|';
+      cp = stpcpy (cp, "FNM_PERIOD");
+      first = 0;
+    }
+  if (flags & FNM_LEADING_DIR)
+    {
+      if (! first)
+	*cp++ = '|';
+      cp = stpcpy (cp, "FNM_LEADING_DIR");
+      first = 0;
+    }
+  if (flags & FNM_CASEFOLD)
+    {
+      if (! first)
+	*cp++ = '|';
+      cp = stpcpy (cp, "FNM_CASEFOLD");
+      first = 0;
+    }
+  if (flags & FNM_EXTMATCH)
+    {
+      if (! first)
+	*cp++ = '|';
+      cp = stpcpy (cp, "FNM_EXTMATCH");
+      first = 0;
+    }
+  if (cp == buf)
+    *cp++ = '0';
+  *cp = '\0';
+
+  return buf;
+}
+
+
+static char *
+escape (const char *str, size_t *reslenp, char **resbufp)
+{
+  size_t reslen = *reslenp;
+  char *resbuf = *resbufp;
+  size_t len = strlen (str);
+  char *wp;
+
+  if (2 * len + 1 > reslen)
+    {
+      resbuf = (char *) realloc (resbuf, 2 * len + 1);
+      if (resbuf == NULL)
+	error (EXIT_FAILURE, errno, "while allocating buffer for printing");
+      *reslenp = 2 * len + 1;
+      *resbufp = resbuf;
+    }
+
+  wp = resbuf;
+  while (*str != '\0')
+    if (*str == '\t')
+      {
+	*wp++ = '\\';
+	*wp++ = 't';
+	++str;
+      }
+    else if (*str == '\n')
+      {
+	*wp++ = '\\';
+	*wp++ = 'n';
+	++str;
+      }
+    else if (*str == '"')
+      {
+	*wp++ = '\\';
+	*wp++ = '"';
+	++str;
+      }
+    else if (*str == '\\')
+      {
+	*wp++ = '\\';
+	*wp++ = '\\';
+	++str;
+      }
+    else
+      *wp++ = *str++;
+
+  *wp = '\0';
+
+  return resbuf;
+}
Index: trunk/src/libctests/glibc/posix/tst-fnmatch.input
===================================================================
--- trunk/src/libctests/glibc/posix/tst-fnmatch.input	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-fnmatch.input	(revision 2036)
@@ -0,0 +1,755 @@
+# Tests for fnmatch.
+# Copyright (C) 2000, 2001, 2004 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+# Contributes by Ulrich Drepper <drepper@redhat.com>.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+
+# Derived from the IEEE 2003.2 text.  The standard only contains some
+# wording describing the situations to be tested.  It does not specify
+# any specific tests.  I.e., the tests below are in no case sufficient.
+# They are hopefully necessary, though.
+
+# B.6 004(C)
+C		 "!#%+,-./01234567889"	"!#%+,-./01234567889"  0
+C		 ":;=@ABCDEFGHIJKLMNO"	":;=@ABCDEFGHIJKLMNO"  0
+C		 "PQRSTUVWXYZ]abcdefg"	"PQRSTUVWXYZ]abcdefg"  0
+C		 "hijklmnopqrstuvwxyz"	"hijklmnopqrstuvwxyz"  0
+C		 "^_{}~"		"^_{}~"		       0
+
+# B.6 005(C)
+C		 "\"$&'()"		"\\\"\\$\\&\\'\\(\\)"  0
+C		 "*?[\\`|"		"\\*\\?\\[\\\\\\`\\|"  0
+C		 "<>"			"\\<\\>"	       0
+
+# B.6 006(C)
+C		 "?*["			"[?*[][?*[][?*[]"      0
+C		 "a/b"			"?/b"		       0
+
+# B.6 007(C)
+C		 "a/b"			"a?b"		       0
+C		 "a/b"			"a/?"		       0
+C		 "aa/b"			"?/b"		       NOMATCH
+C		 "aa/b"			"a?b"		       NOMATCH
+C		 "a/bb"			"a/?"		       NOMATCH
+
+# B.6 009(C)
+C		 "abc"			"[abc]"		       NOMATCH
+C		 "x"			"[abc]"		       NOMATCH
+C		 "a"			"[abc]"		       0
+C		 "["			"[[abc]"	       0
+C		 "a"			"[][abc]"	       0
+C		 "a]"			"[]a]]"		       0
+
+# B.6 010(C)
+C		 "xyz"			"[!abc]"	       NOMATCH
+C		 "x"			"[!abc]"	       0
+C		 "a"			"[!abc]"	       NOMATCH
+
+# B.6 011(C)
+C		 "]"			"[][abc]"	       0
+C		 "abc]"			"[][abc]"	       NOMATCH
+C		 "[]abc"		"[][]abc"	       NOMATCH
+C		 "]"		        "[!]]"		       NOMATCH
+C		 "aa]"			"[!]a]"		       NOMATCH
+C		 "]"		        "[!a]"		       0
+C		 "]]"		        "[!a]]"		       0
+
+# B.6 012(C)
+C		 "a"			"[[.a.]]"	       0
+C		 "-"			"[[.-.]]"	       0
+C		 "-"			"[[.-.][.].]]"	       0
+C		 "-"			"[[.].][.-.]]"	       0
+C		 "-"			"[[.-.][=u=]]"	       0
+C		 "-"			"[[.-.][:alpha:]]"     0
+C		 "a"			"[![.a.]]"	       NOMATCH
+
+# B.6 013(C)
+C		 "a"			"[[.b.]]"	       NOMATCH
+C		 "a"			"[[.b.][.c.]]"	       NOMATCH
+C		 "a"			"[[.b.][=b=]]"	       NOMATCH
+
+
+# B.6 015(C)
+C		 "a"			"[[=a=]]"	       0
+C		 "b"			"[[=a=]b]"	       0
+C		 "b"			"[[=a=][=b=]]"	       0
+C		 "a"			"[[=a=][=b=]]"	       0
+C		 "a"			"[[=a=][.b.]]"	       0
+C		 "a"			"[[=a=][:digit:]]"     0
+
+# B.6 016(C)
+C		 "="			"[[=a=]b]"	       NOMATCH
+C		 "]"			"[[=a=]b]"	       NOMATCH
+C		 "a"			"[[=b=][=c=]]"	       NOMATCH
+C		 "a"			"[[=b=][.].]]"	       NOMATCH
+C		 "a"			"[[=b=][:digit:]]"     NOMATCH
+
+# B.6 017(C)
+C		 "a"			"[[:alnum:]]"	       0
+C		 "a"			"[![:alnum:]]"	       NOMATCH
+C		 "-"			"[[:alnum:]]"	       NOMATCH
+C		 "a]a"			"[[:alnum:]]a"	       NOMATCH
+C		 "-"			"[[:alnum:]-]"	       0
+C		 "aa"			"[[:alnum:]]a"	       0
+C		 "-"			"[![:alnum:]]"	       0
+C		 "]"			"[!][:alnum:]]"	       NOMATCH
+C		 "["			"[![:alnum:][]"	       NOMATCH
+C		 "a"			"[[:alnum:]]"	       0
+C		 "b"			"[[:alnum:]]"	       0
+C		 "c"			"[[:alnum:]]"	       0
+C		 "d"			"[[:alnum:]]"	       0
+C		 "e"			"[[:alnum:]]"	       0
+C		 "f"			"[[:alnum:]]"	       0
+C		 "g"			"[[:alnum:]]"	       0
+C		 "h"			"[[:alnum:]]"	       0
+C		 "i"			"[[:alnum:]]"	       0
+C		 "j"			"[[:alnum:]]"	       0
+C		 "k"			"[[:alnum:]]"	       0
+C		 "l"			"[[:alnum:]]"	       0
+C		 "m"			"[[:alnum:]]"	       0
+C		 "n"			"[[:alnum:]]"	       0
+C		 "o"			"[[:alnum:]]"	       0
+C		 "p"			"[[:alnum:]]"	       0
+C		 "q"			"[[:alnum:]]"	       0
+C		 "r"			"[[:alnum:]]"	       0
+C		 "s"			"[[:alnum:]]"	       0
+C		 "t"			"[[:alnum:]]"	       0
+C		 "u"			"[[:alnum:]]"	       0
+C		 "v"			"[[:alnum:]]"	       0
+C		 "w"			"[[:alnum:]]"	       0
+C		 "x"			"[[:alnum:]]"	       0
+C		 "y"			"[[:alnum:]]"	       0
+C		 "z"			"[[:alnum:]]"	       0
+C		 "A"			"[[:alnum:]]"	       0
+C		 "B"			"[[:alnum:]]"	       0
+C		 "C"			"[[:alnum:]]"	       0
+C		 "D"			"[[:alnum:]]"	       0
+C		 "E"			"[[:alnum:]]"	       0
+C		 "F"			"[[:alnum:]]"	       0
+C		 "G"			"[[:alnum:]]"	       0
+C		 "H"			"[[:alnum:]]"	       0
+C		 "I"			"[[:alnum:]]"	       0
+C		 "J"			"[[:alnum:]]"	       0
+C		 "K"			"[[:alnum:]]"	       0
+C		 "L"			"[[:alnum:]]"	       0
+C		 "M"			"[[:alnum:]]"	       0
+C		 "N"			"[[:alnum:]]"	       0
+C		 "O"			"[[:alnum:]]"	       0
+C		 "P"			"[[:alnum:]]"	       0
+C		 "Q"			"[[:alnum:]]"	       0
+C		 "R"			"[[:alnum:]]"	       0
+C		 "S"			"[[:alnum:]]"	       0
+C		 "T"			"[[:alnum:]]"	       0
+C		 "U"			"[[:alnum:]]"	       0
+C		 "V"			"[[:alnum:]]"	       0
+C		 "W"			"[[:alnum:]]"	       0
+C		 "X"			"[[:alnum:]]"	       0
+C		 "Y"			"[[:alnum:]]"	       0
+C		 "Z"			"[[:alnum:]]"	       0
+C		 "0"			"[[:alnum:]]"	       0
+C		 "1"			"[[:alnum:]]"	       0
+C		 "2"			"[[:alnum:]]"	       0
+C		 "3"			"[[:alnum:]]"	       0
+C		 "4"			"[[:alnum:]]"	       0
+C		 "5"			"[[:alnum:]]"	       0
+C		 "6"			"[[:alnum:]]"	       0
+C		 "7"			"[[:alnum:]]"	       0
+C		 "8"			"[[:alnum:]]"	       0
+C		 "9"			"[[:alnum:]]"	       0
+C		 "!"			"[[:alnum:]]"	       NOMATCH
+C		 "#"			"[[:alnum:]]"	       NOMATCH
+C		 "%"			"[[:alnum:]]"	       NOMATCH
+C		 "+"			"[[:alnum:]]"	       NOMATCH
+C		 ","			"[[:alnum:]]"	       NOMATCH
+C		 "-"			"[[:alnum:]]"	       NOMATCH
+C		 "."			"[[:alnum:]]"	       NOMATCH
+C		 "/"			"[[:alnum:]]"	       NOMATCH
+C		 ":"			"[[:alnum:]]"	       NOMATCH
+C		 ";"			"[[:alnum:]]"	       NOMATCH
+C		 "="			"[[:alnum:]]"	       NOMATCH
+C		 "@"			"[[:alnum:]]"	       NOMATCH
+C		 "["			"[[:alnum:]]"	       NOMATCH
+C		 "\\"			"[[:alnum:]]"	       NOMATCH
+C		 "]"			"[[:alnum:]]"	       NOMATCH
+C		 "^"			"[[:alnum:]]"	       NOMATCH
+C		 "_"			"[[:alnum:]]"	       NOMATCH
+C		 "{"			"[[:alnum:]]"	       NOMATCH
+C		 "}"			"[[:alnum:]]"	       NOMATCH
+C		 "~"			"[[:alnum:]]"	       NOMATCH
+C		 "\""			"[[:alnum:]]"	       NOMATCH
+C		 "$"			"[[:alnum:]]"	       NOMATCH
+C		 "&"			"[[:alnum:]]"	       NOMATCH
+C		 "'"			"[[:alnum:]]"	       NOMATCH
+C		 "("			"[[:alnum:]]"	       NOMATCH
+C		 ")"			"[[:alnum:]]"	       NOMATCH
+C		 "*"			"[[:alnum:]]"	       NOMATCH
+C		 "?"			"[[:alnum:]]"	       NOMATCH
+C		 "`"			"[[:alnum:]]"	       NOMATCH
+C		 "|"			"[[:alnum:]]"	       NOMATCH
+C		 "<"			"[[:alnum:]]"	       NOMATCH
+C		 ">"			"[[:alnum:]]"	       NOMATCH
+C		 "\t"			"[[:cntrl:]]"	       0
+C		 "t"			"[[:cntrl:]]"	       NOMATCH
+C		 "t"			"[[:lower:]]"	       0
+C		 "\t"			"[[:lower:]]"	       NOMATCH
+C		 "T"			"[[:lower:]]"	       NOMATCH
+C		 "\t"			"[[:space:]]"	       0
+C		 "t"			"[[:space:]]"	       NOMATCH
+C		 "t"			"[[:alpha:]]"	       0
+C		 "\t"			"[[:alpha:]]"	       NOMATCH
+C		 "0"			"[[:digit:]]"	       0
+C		 "\t"			"[[:digit:]]"	       NOMATCH
+C		 "t"			"[[:digit:]]"	       NOMATCH
+C		 "\t"			"[[:print:]]"	       NOMATCH
+C		 "t"			"[[:print:]]"	       0
+C		 "T"			"[[:upper:]]"	       0
+C		 "\t"			"[[:upper:]]"	       NOMATCH
+C		 "t"			"[[:upper:]]"	       NOMATCH
+C		 "\t"			"[[:blank:]]"	       0
+C		 "t"			"[[:blank:]]"	       NOMATCH
+C		 "\t"			"[[:graph:]]"	       NOMATCH
+C		 "t"			"[[:graph:]]"	       0
+C		 "."			"[[:punct:]]"	       0
+C		 "t"			"[[:punct:]]"	       NOMATCH
+C		 "\t"			"[[:punct:]]"	       NOMATCH
+C		 "0"			"[[:xdigit:]]"	       0
+C		 "\t"			"[[:xdigit:]]"	       NOMATCH
+C		 "a"			"[[:xdigit:]]"	       0
+C		 "A"			"[[:xdigit:]]"	       0
+C		 "t"			"[[:xdigit:]]"	       NOMATCH
+C		 "a"			"[[alpha]]"	       NOMATCH
+C		 "a"			"[[alpha:]]"	       NOMATCH
+C		 "a]"			"[[alpha]]"	       0
+C		 "a]"			"[[alpha:]]"	       0
+C		 "a"			"[[:alpha:][.b.]]"     0
+C		 "a"			"[[:alpha:][=b=]]"     0
+C		 "a"			"[[:alpha:][:digit:]]" 0
+C		 "a"			"[[:digit:][:alpha:]]" 0
+
+# B.6 018(C)
+C		 "a"			"[a-c]"		       0
+C		 "b"			"[a-c]"		       0
+C		 "c"			"[a-c]"		       0
+C		 "a"			"[b-c]"		       NOMATCH
+C		 "d"			"[b-c]"		       NOMATCH
+C		 "B"			"[a-c]"		       NOMATCH
+C		 "b"			"[A-C]"		       NOMATCH
+C		 ""			"[a-c]"		       NOMATCH
+C		 "as"			"[a-ca-z]"	       NOMATCH
+C		 "a"			"[[.a.]-c]"	       0
+C		 "a"			"[a-[.c.]]"	       0
+C		 "a"			"[[.a.]-[.c.]]"	       0
+C		 "b"			"[[.a.]-c]"	       0
+C		 "b"			"[a-[.c.]]"	       0
+C		 "b"			"[[.a.]-[.c.]]"	       0
+C		 "c"			"[[.a.]-c]"	       0
+C		 "c"			"[a-[.c.]]"	       0
+C		 "c"			"[[.a.]-[.c.]]"	       0
+C		 "d"			"[[.a.]-c]"	       NOMATCH
+C		 "d"			"[a-[.c.]]"	       NOMATCH
+C		 "d"			"[[.a.]-[.c.]]"	       NOMATCH
+
+# B.6 019(C)
+C		 "a"			"[c-a]"		       NOMATCH
+C		 "a"			"[[.c.]-a]"	       NOMATCH
+C		 "a"			"[c-[.a.]]"	       NOMATCH
+C		 "a"			"[[.c.]-[.a.]]"	       NOMATCH
+C		 "c"			"[c-a]"		       NOMATCH
+C		 "c"			"[[.c.]-a]"	       NOMATCH
+C		 "c"			"[c-[.a.]]"	       NOMATCH
+C		 "c"			"[[.c.]-[.a.]]"	       NOMATCH
+
+# B.6 020(C)
+C		 "a"			"[a-c0-9]"	       0
+C		 "d"			"[a-c0-9]"	       NOMATCH
+C		 "B"			"[a-c0-9]"	       NOMATCH
+
+# B.6 021(C)
+C		 "-"			"[-a]"		       0
+C		 "a"			"[-b]"		       NOMATCH
+C		 "-"			"[!-a]"		       NOMATCH
+C		 "a"			"[!-b]"		       0
+C		 "-"			"[a-c-0-9]"	       0
+C		 "b"			"[a-c-0-9]"	       0
+C		 "a:"			"a[0-9-a]"	       NOMATCH
+C		 "a:"			"a[09-a]"	       0
+
+# B.6 024(C)
+C		 ""			"*"		       0
+C		 "asd/sdf"		"*"		       0
+
+# B.6 025(C)
+C		 "as"			"[a-c][a-z]"	       0
+C		 "as"			"??"		       0
+
+# B.6 026(C)
+C		 "asd/sdf"		"as*df"		       0
+C		 "asd/sdf"		"as*"		       0
+C		 "asd/sdf"		"*df"		       0
+C		 "asd/sdf"		"as*dg"		       NOMATCH
+C		 "asdf"			"as*df"		       0
+C		 "asdf"			"as*df?"	       NOMATCH
+C		 "asdf"			"as*??"		       0
+C		 "asdf"			"a*???"		       0
+C		 "asdf"			"*????"		       0
+C		 "asdf"			"????*"		       0
+C		 "asdf"			"??*?"		       0
+
+# B.6 027(C)
+C		 "/"			"/"		       0
+C		 "/"			"/*"		       0
+C		 "/"			"*/"		       0
+C		 "/"			"/?"		       NOMATCH
+C		 "/"			"?/"		       NOMATCH
+C		 "/"			"?"		       0
+C		 "."			"?"		       0
+C		 "/."			"??"		       0
+C		 "/"			"[!a-c]"	       0
+C		 "."			"[!a-c]"	       0
+
+# B.6 029(C)
+C		 "/"			"/"		       0       PATHNAME
+C		 "//"			"//"		       0       PATHNAME
+C		 "/.a"			"/*"		       0       PATHNAME
+C		 "/.a"			"/?a"		       0       PATHNAME
+C		 "/.a"			"/[!a-z]a"	       0       PATHNAME
+C		 "/.a/.b"		"/*/?b"		       0       PATHNAME
+
+# B.6 030(C)
+C		 "/"			"?"		       NOMATCH PATHNAME
+C		 "/"			"*"		       NOMATCH PATHNAME
+C		 "a/b"			"a?b"		       NOMATCH PATHNAME
+C		 "/.a/.b"		"/*b"		       NOMATCH PATHNAME
+
+# B.6 031(C)
+C		 "/$"			"\\/\\$"	       0
+C		 "/["			"\\/\\["	       0
+C		 "/["			"\\/["		       NOMATCH
+
+# B.6 032(C)
+C		 "/$"			"\\/\\$"	       NOMATCH NOESCAPE
+C		 "/\\$"			"\\/\\$"	       NOMATCH NOESCAPE
+C		 "\\/\\$"		"\\/\\$"	       0       NOESCAPE
+
+# B.6 033(C)
+C		 ".asd"			".*"		       0       PERIOD
+C		 "/.asd"		"*"		       0       PERIOD
+C		 "/as/.df"		"*/?*f"		       0       PERIOD
+C		 "..asd"		".[!a-z]*"	       0       PERIOD
+
+# B.6 034(C)
+C		 ".asd"			"*"		       NOMATCH PERIOD
+C		 ".asd"			"?asd"		       NOMATCH PERIOD
+C		 ".asd"			"[!a-z]*"	       NOMATCH PERIOD
+
+# B.6 035(C)
+C		 "/."			"/."		       0       PATHNAME|PERIOD
+C		 "/.a./.b."		"/.*/.*"	       0       PATHNAME|PERIOD
+C		 "/.a./.b."		"/.??/.??"	       0       PATHNAME|PERIOD
+
+# B.6 036(C)
+C		 "/."			"*"		       NOMATCH PATHNAME|PERIOD
+C		 "/."			"/*"		       NOMATCH PATHNAME|PERIOD
+C		 "/."			"/?"		       NOMATCH PATHNAME|PERIOD
+C		 "/."			"/[!a-z]"	       NOMATCH PATHNAME|PERIOD
+C		 "/a./.b."		"/*/*"		       NOMATCH PATHNAME|PERIOD
+C		 "/a./.b."		"/??/???"	       NOMATCH PATHNAME|PERIOD
+
+# Some home-grown tests.
+C		"foobar"		"foo*[abc]z"	       NOMATCH
+C		"foobaz"		"foo*[abc][xyz]"       0
+C		"foobaz"		"foo?*[abc][xyz]"      0
+C		"foobaz"		"foo?*[abc][x/yz]"     0
+C		"foobaz"		"foo?*[abc]/[xyz]"     NOMATCH PATHNAME
+C		"a"			"a/"                   NOMATCH PATHNAME
+C		"a/"			"a"		       NOMATCH PATHNAME
+C		"//a"			"/a"		       NOMATCH PATHNAME
+C		"/a"			"//a"		       NOMATCH PATHNAME
+C		"az"			"[a-]z"		       0
+C		"bz"			"[ab-]z"	       0
+C		"cz"			"[ab-]z"	       NOMATCH
+C		"-z"			"[ab-]z"	       0
+C		"az"			"[-a]z"		       0
+C		"bz"			"[-ab]z"	       0
+C		"cz"			"[-ab]z"	       NOMATCH
+C		"-z"			"[-ab]z"	       0
+C		"\\"			"[\\\\-a]"	       0
+C		"_"			"[\\\\-a]"	       0
+C		"a"			"[\\\\-a]"	       0
+C		"-"			"[\\\\-a]"	       NOMATCH
+C		"\\"			"[\\]-a]"	       NOMATCH
+C		"_"			"[\\]-a]"	       0
+C		"a"			"[\\]-a]"	       0
+C		"]"			"[\\]-a]"	       0
+C		"-"			"[\\]-a]"	       NOMATCH
+C		"\\"			"[!\\\\-a]"	       NOMATCH
+C		"_"			"[!\\\\-a]"	       NOMATCH
+C		"a"			"[!\\\\-a]"	       NOMATCH
+C		"-"			"[!\\\\-a]"	       0
+C		"!"			"[\\!-]"	       0
+C		"-"			"[\\!-]"	       0
+C		"\\"			"[\\!-]"	       NOMATCH
+C		"Z"			"[Z-\\\\]"	       0
+C		"["			"[Z-\\\\]"	       0
+C		"\\"			"[Z-\\\\]"	       0
+C		"-"			"[Z-\\\\]"	       NOMATCH
+C		"Z"			"[Z-\\]]"	       0
+C		"["			"[Z-\\]]"	       0
+C		"\\"			"[Z-\\]]"	       0
+C		"]"			"[Z-\\]]"	       0
+C		"-"			"[Z-\\]]"	       NOMATCH
+
+# Following are tests outside the scope of IEEE 2003.2 since they are using
+# locales other than the C locale.  The main focus of the tests is on the
+# handling of ranges and the recognition of character (vs bytes).
+de_DE.ISO-8859-1 "a"			"[a-z]"		       0
+de_DE.ISO-8859-1 "z"			"[a-z]"		       0
+de_DE.ISO-8859-1 "ä"			"[a-z]"		       0
+de_DE.ISO-8859-1 "ö"			"[a-z]"		       0
+de_DE.ISO-8859-1 "ü"			"[a-z]"		       0
+de_DE.ISO-8859-1 "A"			"[a-z]"		       NOMATCH
+de_DE.ISO-8859-1 "Z"			"[a-z]"		       NOMATCH
+de_DE.ISO-8859-1 "Ä"			"[a-z]"		       NOMATCH
+de_DE.ISO-8859-1 "Ö"			"[a-z]"		       NOMATCH
+de_DE.ISO-8859-1 "Ü"			"[a-z]"		       NOMATCH
+de_DE.ISO-8859-1 "a"			"[A-Z]"		       NOMATCH
+de_DE.ISO-8859-1 "z"			"[A-Z]"		       NOMATCH
+de_DE.ISO-8859-1 "ä"			"[A-Z]"		       NOMATCH
+de_DE.ISO-8859-1 "ö"			"[A-Z]"		       NOMATCH
+de_DE.ISO-8859-1 "ü"			"[A-Z]"		       NOMATCH
+de_DE.ISO-8859-1 "A"			"[A-Z]"		       0
+de_DE.ISO-8859-1 "Z"			"[A-Z]"		       0
+de_DE.ISO-8859-1 "Ä"			"[A-Z]"		       0
+de_DE.ISO-8859-1 "Ö"			"[A-Z]"		       0
+de_DE.ISO-8859-1 "Ü"			"[A-Z]"		       0
+de_DE.ISO-8859-1 "a"			"[[:lower:]]"	       0
+de_DE.ISO-8859-1 "z"			"[[:lower:]]"	       0
+de_DE.ISO-8859-1 "ä"			"[[:lower:]]"	       0
+de_DE.ISO-8859-1 "ö"			"[[:lower:]]"	       0
+de_DE.ISO-8859-1 "ü"			"[[:lower:]]"	       0
+de_DE.ISO-8859-1 "A"			"[[:lower:]]"	       NOMATCH
+de_DE.ISO-8859-1 "Z"			"[[:lower:]]"	       NOMATCH
+de_DE.ISO-8859-1 "Ä"			"[[:lower:]]"	       NOMATCH
+de_DE.ISO-8859-1 "Ö"			"[[:lower:]]"	       NOMATCH
+de_DE.ISO-8859-1 "Ü"			"[[:lower:]]"	       NOMATCH
+de_DE.ISO-8859-1 "a"			"[[:upper:]]"	       NOMATCH
+de_DE.ISO-8859-1 "z"			"[[:upper:]]"	       NOMATCH
+de_DE.ISO-8859-1 "ä"			"[[:upper:]]"	       NOMATCH
+de_DE.ISO-8859-1 "ö"			"[[:upper:]]"	       NOMATCH
+de_DE.ISO-8859-1 "ü"			"[[:upper:]]"	       NOMATCH
+de_DE.ISO-8859-1 "A"			"[[:upper:]]"	       0
+de_DE.ISO-8859-1 "Z"			"[[:upper:]]"	       0
+de_DE.ISO-8859-1 "Ä"			"[[:upper:]]"	       0
+de_DE.ISO-8859-1 "Ö"			"[[:upper:]]"	       0
+de_DE.ISO-8859-1 "Ü"			"[[:upper:]]"	       0
+de_DE.ISO-8859-1 "a"			"[[:alpha:]]"	       0
+de_DE.ISO-8859-1 "z"			"[[:alpha:]]"	       0
+de_DE.ISO-8859-1 "ä"			"[[:alpha:]]"	       0
+de_DE.ISO-8859-1 "ö"			"[[:alpha:]]"	       0
+de_DE.ISO-8859-1 "ü"			"[[:alpha:]]"	       0
+de_DE.ISO-8859-1 "A"			"[[:alpha:]]"	       0
+de_DE.ISO-8859-1 "Z"			"[[:alpha:]]"	       0
+de_DE.ISO-8859-1 "Ä"			"[[:alpha:]]"	       0
+de_DE.ISO-8859-1 "Ö"			"[[:alpha:]]"	       0
+de_DE.ISO-8859-1 "Ü"			"[[:alpha:]]"	       0
+
+de_DE.ISO-8859-1 "a"			"[[=a=]b]"	       0
+de_DE.ISO-8859-1 "â"			"[[=a=]b]"	       0
+de_DE.ISO-8859-1 "à"			"[[=a=]b]"	       0
+de_DE.ISO-8859-1 "á"			"[[=a=]b]"	       0
+de_DE.ISO-8859-1 "ä"			"[[=a=]b]"	       0
+de_DE.ISO-8859-1 "b"			"[[=a=]b]"	       0
+de_DE.ISO-8859-1 "c"			"[[=a=]b]"	       NOMATCH
+de_DE.ISO-8859-1 "a"			"[[=â=]b]"	       0
+de_DE.ISO-8859-1 "â"			"[[=â=]b]"	       0
+de_DE.ISO-8859-1 "à"			"[[=â=]b]"	       0
+de_DE.ISO-8859-1 "á"			"[[=â=]b]"	       0
+de_DE.ISO-8859-1 "ä"			"[[=â=]b]"	       0
+de_DE.ISO-8859-1 "b"			"[[=â=]b]"	       0
+de_DE.ISO-8859-1 "c"			"[[=â=]b]"	       NOMATCH
+de_DE.ISO-8859-1 "a"			"[[=à=]b]"	       0
+de_DE.ISO-8859-1 "â"			"[[=à=]b]"	       0
+de_DE.ISO-8859-1 "à"			"[[=à=]b]"	       0
+de_DE.ISO-8859-1 "á"			"[[=à=]b]"	       0
+de_DE.ISO-8859-1 "ä"			"[[=à=]b]"	       0
+de_DE.ISO-8859-1 "b"			"[[=à=]b]"	       0
+de_DE.ISO-8859-1 "c"			"[[=à=]b]"	       NOMATCH
+de_DE.ISO-8859-1 "a"			"[[=á=]b]"	       0
+de_DE.ISO-8859-1 "â"			"[[=á=]b]"	       0
+de_DE.ISO-8859-1 "à"			"[[=á=]b]"	       0
+de_DE.ISO-8859-1 "á"			"[[=á=]b]"	       0
+de_DE.ISO-8859-1 "ä"			"[[=á=]b]"	       0
+de_DE.ISO-8859-1 "b"			"[[=á=]b]"	       0
+de_DE.ISO-8859-1 "c"			"[[=á=]b]"	       NOMATCH
+de_DE.ISO-8859-1 "a"			"[[=ä=]b]"	       0
+de_DE.ISO-8859-1 "â"			"[[=ä=]b]"	       0
+de_DE.ISO-8859-1 "à"			"[[=ä=]b]"	       0
+de_DE.ISO-8859-1 "á"			"[[=ä=]b]"	       0
+de_DE.ISO-8859-1 "ä"			"[[=ä=]b]"	       0
+de_DE.ISO-8859-1 "b"			"[[=ä=]b]"	       0
+de_DE.ISO-8859-1 "c"			"[[=ä=]b]"	       NOMATCH
+
+de_DE.ISO-8859-1 "aa"			"[[.a.]]a"	       0
+de_DE.ISO-8859-1 "ba"			"[[.a.]]a"	       NOMATCH
+
+
+# And with a multibyte character set.
+de_DE.UTF-8	 "a"			"[a-z]"		       0
+de_DE.UTF-8	 "z"			"[a-z]"		       0
+de_DE.UTF-8	 "Ã€"			"[a-z]"		       0
+de_DE.UTF-8	 "Ã¶"			"[a-z]"		       0
+de_DE.UTF-8	 "ÃŒ"			"[a-z]"		       0
+de_DE.UTF-8	 "A"			"[a-z]"		       NOMATCH
+de_DE.UTF-8	 "Z"			"[a-z]"		       NOMATCH
+de_DE.UTF-8	 "Ã"			"[a-z]"		       NOMATCH
+de_DE.UTF-8	 "Ã"			"[a-z]"		       NOMATCH
+de_DE.UTF-8	 "Ã"			"[a-z]"		       NOMATCH
+de_DE.UTF-8	 "a"			"[A-Z]"		       NOMATCH
+de_DE.UTF-8	 "z"			"[A-Z]"		       NOMATCH
+de_DE.UTF-8	 "Ã€"			"[A-Z]"		       NOMATCH
+de_DE.UTF-8	 "Ã¶"			"[A-Z]"		       NOMATCH
+de_DE.UTF-8	 "ÃŒ"			"[A-Z]"		       NOMATCH
+de_DE.UTF-8	 "A"			"[A-Z]"		       0
+de_DE.UTF-8	 "Z"			"[A-Z]"		       0
+de_DE.UTF-8	 "Ã"			"[A-Z]"		       0
+de_DE.UTF-8	 "Ã"			"[A-Z]"		       0
+de_DE.UTF-8	 "Ã"			"[A-Z]"		       0
+de_DE.UTF-8	 "a"			"[[:lower:]]"	       0
+de_DE.UTF-8	 "z"			"[[:lower:]]"	       0
+de_DE.UTF-8	 "Ã€"			"[[:lower:]]"	       0
+de_DE.UTF-8	 "Ã¶"			"[[:lower:]]"	       0
+de_DE.UTF-8	 "ÃŒ"			"[[:lower:]]"	       0
+de_DE.UTF-8	 "A"			"[[:lower:]]"	       NOMATCH
+de_DE.UTF-8	 "Z"			"[[:lower:]]"	       NOMATCH
+de_DE.UTF-8	 "Ã"			"[[:lower:]]"	       NOMATCH
+de_DE.UTF-8	 "Ã"			"[[:lower:]]"	       NOMATCH
+de_DE.UTF-8	 "Ã"			"[[:lower:]]"	       NOMATCH
+de_DE.UTF-8	 "a"			"[[:upper:]]"	       NOMATCH
+de_DE.UTF-8	 "z"			"[[:upper:]]"	       NOMATCH
+de_DE.UTF-8	 "Ã€"			"[[:upper:]]"	       NOMATCH
+de_DE.UTF-8	 "Ã¶"			"[[:upper:]]"	       NOMATCH
+de_DE.UTF-8	 "ÃŒ"			"[[:upper:]]"	       NOMATCH
+de_DE.UTF-8	 "A"			"[[:upper:]]"	       0
+de_DE.UTF-8	 "Z"			"[[:upper:]]"	       0
+de_DE.UTF-8	 "Ã"			"[[:upper:]]"	       0
+de_DE.UTF-8	 "Ã"			"[[:upper:]]"	       0
+de_DE.UTF-8	 "Ã"			"[[:upper:]]"	       0
+de_DE.UTF-8	 "a"			"[[:alpha:]]"	       0
+de_DE.UTF-8	 "z"			"[[:alpha:]]"	       0
+de_DE.UTF-8	 "Ã€"			"[[:alpha:]]"	       0
+de_DE.UTF-8	 "Ã¶"			"[[:alpha:]]"	       0
+de_DE.UTF-8	 "ÃŒ"			"[[:alpha:]]"	       0
+de_DE.UTF-8	 "A"			"[[:alpha:]]"	       0
+de_DE.UTF-8	 "Z"			"[[:alpha:]]"	       0
+de_DE.UTF-8	 "Ã"			"[[:alpha:]]"	       0
+de_DE.UTF-8	 "Ã"			"[[:alpha:]]"	       0
+de_DE.UTF-8	 "Ã"			"[[:alpha:]]"	       0
+
+de_DE.UTF-8	 "a"			"[[=a=]b]"	       0
+de_DE.UTF-8	 "Ã¢"			"[[=a=]b]"	       0
+de_DE.UTF-8	 "Ã "			"[[=a=]b]"	       0
+de_DE.UTF-8	 "Ã¡"			"[[=a=]b]"	       0
+de_DE.UTF-8	 "Ã€"			"[[=a=]b]"	       0
+de_DE.UTF-8	 "b"			"[[=a=]b]"	       0
+de_DE.UTF-8	 "c"			"[[=a=]b]"	       NOMATCH
+de_DE.UTF-8	 "a"			"[[=Ã¢=]b]"	       0
+de_DE.UTF-8	 "Ã¢"			"[[=Ã¢=]b]"	       0
+de_DE.UTF-8	 "Ã "			"[[=Ã¢=]b]"	       0
+de_DE.UTF-8	 "Ã¡"			"[[=Ã¢=]b]"	       0
+de_DE.UTF-8	 "Ã€"			"[[=Ã¢=]b]"	       0
+de_DE.UTF-8	 "b"			"[[=Ã¢=]b]"	       0
+de_DE.UTF-8	 "c"			"[[=Ã¢=]b]"	       NOMATCH
+de_DE.UTF-8	 "a"			"[[=Ã =]b]"	       0
+de_DE.UTF-8	 "Ã¢"			"[[=Ã =]b]"	       0
+de_DE.UTF-8	 "Ã "			"[[=Ã =]b]"	       0
+de_DE.UTF-8	 "Ã¡"			"[[=Ã =]b]"	       0
+de_DE.UTF-8	 "Ã€"			"[[=Ã =]b]"	       0
+de_DE.UTF-8	 "b"			"[[=Ã =]b]"	       0
+de_DE.UTF-8	 "c"			"[[=Ã =]b]"	       NOMATCH
+de_DE.UTF-8	 "a"			"[[=Ã¡=]b]"	       0
+de_DE.UTF-8	 "Ã¢"			"[[=Ã¡=]b]"	       0
+de_DE.UTF-8	 "Ã "			"[[=Ã¡=]b]"	       0
+de_DE.UTF-8	 "Ã¡"			"[[=Ã¡=]b]"	       0
+de_DE.UTF-8	 "Ã€"			"[[=Ã¡=]b]"	       0
+de_DE.UTF-8	 "b"			"[[=Ã¡=]b]"	       0
+de_DE.UTF-8	 "c"			"[[=Ã¡=]b]"	       NOMATCH
+de_DE.UTF-8	 "a"			"[[=Ã€=]b]"	       0
+de_DE.UTF-8	 "Ã¢"			"[[=Ã€=]b]"	       0
+de_DE.UTF-8	 "Ã "			"[[=Ã€=]b]"	       0
+de_DE.UTF-8	 "Ã¡"			"[[=Ã€=]b]"	       0
+de_DE.UTF-8	 "Ã€"			"[[=Ã€=]b]"	       0
+de_DE.UTF-8	 "b"			"[[=Ã€=]b]"	       0
+de_DE.UTF-8	 "c"			"[[=Ã€=]b]"	       NOMATCH
+
+de_DE.UTF-8	 "aa"			"[[.a.]]a"	       0
+de_DE.UTF-8	 "ba"			"[[.a.]]a"	       NOMATCH
+
+
+# Test of GNU extensions.
+C		 "x"			"x"		       0       PATHNAME|LEADING_DIR
+C		 "x/y"			"x"		       0       PATHNAME|LEADING_DIR
+C		 "x/y/z"		"x"		       0       PATHNAME|LEADING_DIR
+C		 "x"			"*"		       0       PATHNAME|LEADING_DIR
+C		 "x/y"			"*"		       0       PATHNAME|LEADING_DIR
+C		 "x/y/z"		"*"		       0       PATHNAME|LEADING_DIR
+C		 "x"			"*x"		       0       PATHNAME|LEADING_DIR
+C		 "x/y"			"*x"		       0       PATHNAME|LEADING_DIR
+C		 "x/y/z"		"*x"		       0       PATHNAME|LEADING_DIR
+C		 "x"			"x*"		       0       PATHNAME|LEADING_DIR
+C		 "x/y"			"x*"		       0       PATHNAME|LEADING_DIR
+C		 "x/y/z"		"x*"		       0       PATHNAME|LEADING_DIR
+C		 "x"			"a"		       NOMATCH PATHNAME|LEADING_DIR
+C		 "x/y"			"a"		       NOMATCH PATHNAME|LEADING_DIR
+C		 "x/y/z"		"a"		       NOMATCH PATHNAME|LEADING_DIR
+C		 "x"			"x/y"		       NOMATCH PATHNAME|LEADING_DIR
+C		 "x/y"			"x/y"		       0       PATHNAME|LEADING_DIR
+C		 "x/y/z"		"x/y"		       0       PATHNAME|LEADING_DIR
+C		 "x"			"x?y"		       NOMATCH PATHNAME|LEADING_DIR
+C		 "x/y"			"x?y"		       NOMATCH PATHNAME|LEADING_DIR
+C		 "x/y/z"		"x?y"		       NOMATCH PATHNAME|LEADING_DIR
+
+# ksh style matching.
+C		"abcd"			"?@(a|b)*@(c)d"	       0       EXTMATCH
+C		"/dev/udp/129.22.8.102/45" "/dev/@(tcp|udp)/*/*" 0     PATHNAME|EXTMATCH
+C		"12"			"[1-9]*([0-9])"        0       EXTMATCH
+C		"12abc"			"[1-9]*([0-9])"        NOMATCH EXTMATCH
+C		"1"			"[1-9]*([0-9])"	       0       EXTMATCH
+C		"07"			"+([0-7])"	       0       EXTMATCH
+C		"0377"			"+([0-7])"	       0       EXTMATCH
+C		"09"			"+([0-7])"	       NOMATCH EXTMATCH
+C		"paragraph"		"para@(chute|graph)"   0       EXTMATCH
+C		"paramour"		"para@(chute|graph)"   NOMATCH EXTMATCH
+C		"para991"		"para?([345]|99)1"     0       EXTMATCH
+C		"para381"		"para?([345]|99)1"     NOMATCH EXTMATCH
+C		"paragraph"		"para*([0-9])"	       NOMATCH EXTMATCH
+C		"para"			"para*([0-9])"	       0       EXTMATCH
+C		"para13829383746592"	"para*([0-9])"	       0       EXTMATCH
+C		"paragraph"		"para+([0-9])"	       NOMATCH EXTMATCH
+C		"para"			"para+([0-9])"	       NOMATCH EXTMATCH
+C		"para987346523"		"para+([0-9])"	       0       EXTMATCH
+C		"paragraph"		"para!(*.[0-9])"       0       EXTMATCH
+C		"para.38"		"para!(*.[0-9])"       0       EXTMATCH
+C		"para.graph"		"para!(*.[0-9])"       0       EXTMATCH
+C		"para39"		"para!(*.[0-9])"       0       EXTMATCH
+C		""			"*(0|1|3|5|7|9)"       0       EXTMATCH
+C		"137577991"		"*(0|1|3|5|7|9)"       0       EXTMATCH
+C		"2468"			"*(0|1|3|5|7|9)"       NOMATCH EXTMATCH
+C		"1358"			"*(0|1|3|5|7|9)"       NOMATCH EXTMATCH
+C		"file.c"		"*.c?(c)"	       0       EXTMATCH
+C		"file.C"		"*.c?(c)"	       NOMATCH EXTMATCH
+C		"file.cc"		"*.c?(c)"	       0       EXTMATCH
+C		"file.ccc"		"*.c?(c)"	       NOMATCH EXTMATCH
+C		"parse.y"		"!(*.c|*.h|Makefile.in|config*|README)" 0 EXTMATCH
+C		"shell.c"		"!(*.c|*.h|Makefile.in|config*|README)" NOMATCH EXTMATCH
+C		"Makefile"		"!(*.c|*.h|Makefile.in|config*|README)" 0 EXTMATCH
+C		"VMS.FILE;1"		"*\;[1-9]*([0-9])"     0       EXTMATCH
+C		"VMS.FILE;0"		"*\;[1-9]*([0-9])"     NOMATCH EXTMATCH
+C		"VMS.FILE;"		"*\;[1-9]*([0-9])"     NOMATCH EXTMATCH
+C		"VMS.FILE;139"		"*\;[1-9]*([0-9])"     0       EXTMATCH
+C		"VMS.FILE;1N"		"*\;[1-9]*([0-9])"     NOMATCH EXTMATCH
+C		"abcfefg"		"ab**(e|f)"	       0       EXTMATCH
+C		"abcfefg"		"ab**(e|f)g"	       0       EXTMATCH
+C		"ab"			"ab*+(e|f)"	       NOMATCH EXTMATCH
+C		"abef"			"ab***ef"	       0       EXTMATCH
+C		"abef"			"ab**"		       0       EXTMATCH
+C		"fofo"			"*(f*(o))"	       0       EXTMATCH
+C		"ffo"			"*(f*(o))"	       0       EXTMATCH
+C		"foooofo"		"*(f*(o))"	       0       EXTMATCH
+C		"foooofof"		"*(f*(o))"	       0       EXTMATCH
+C		"fooofoofofooo"		"*(f*(o))"	       0       EXTMATCH
+C		"foooofof"		"*(f+(o))"	       NOMATCH EXTMATCH
+C		"xfoooofof"		"*(f*(o))"	       NOMATCH EXTMATCH
+C		"foooofofx"		"*(f*(o))"	       NOMATCH EXTMATCH
+C		"ofxoofxo"		"*(*(of*(o)x)o)"       0       EXTMATCH
+C		"ofooofoofofooo"	"*(f*(o))"	       NOMATCH EXTMATCH
+C		"foooxfooxfoxfooox"	"*(f*(o)x)"	       0       EXTMATCH
+C		"foooxfooxofoxfooox"	"*(f*(o)x)"	       NOMATCH EXTMATCH
+C		"foooxfooxfxfooox"	"*(f*(o)x)"	       0       EXTMATCH
+C		"ofxoofxo"		"*(*(of*(o)x)o)"       0       EXTMATCH
+C		"ofoooxoofxo"		"*(*(of*(o)x)o)"       0       EXTMATCH
+C		"ofoooxoofxoofoooxoofxo" "*(*(of*(o)x)o)"      0       EXTMATCH
+C		"ofoooxoofxoofoooxoofxoo" "*(*(of*(o)x)o)"     0       EXTMATCH
+C		"ofoooxoofxoofoooxoofxofo" "*(*(of*(o)x)o)"    NOMATCH EXTMATCH
+C		"ofoooxoofxoofoooxoofxooofxofxo" "*(*(of*(o)x)o)" 0    EXTMATCH
+C		"aac"			"*(@(a))a@(c)"	       0       EXTMATCH
+C		"ac"			"*(@(a))a@(c)"	       0       EXTMATCH
+C		"c"			"*(@(a))a@(c)"	       NOMATCH EXTMATCH
+C		"aaac"			"*(@(a))a@(c)"	       0       EXTMATCH
+C		"baaac"			"*(@(a))a@(c)"	       NOMATCH EXTMATCH
+C		"abcd"			"?@(a|b)*@(c)d"	       0       EXTMATCH
+C		"abcd"			"@(ab|a*@(b))*(c)d"    0       EXTMATCH
+C		"acd"			"@(ab|a*(b))*(c)d"     0       EXTMATCH
+C		"abbcd"			"@(ab|a*(b))*(c)d"     0       EXTMATCH
+C		"effgz"			"@(b+(c)d|e*(f)g?|?(h)i@(j|k))" 0 EXTMATCH
+C		"efgz"			"@(b+(c)d|e*(f)g?|?(h)i@(j|k))" 0 EXTMATCH
+C		"egz"			"@(b+(c)d|e*(f)g?|?(h)i@(j|k))" 0 EXTMATCH
+C		"egzefffgzbcdij"	"*(b+(c)d|e*(f)g?|?(h)i@(j|k))" 0 EXTMATCH
+C		"egz"			"@(b+(c)d|e+(f)g?|?(h)i@(j|k))" NOMATCH EXTMATCH
+C		"ofoofo"		"*(of+(o))"	       0       EXTMATCH
+C		"oxfoxoxfox"		"*(oxf+(ox))"	       0       EXTMATCH
+C		"oxfoxfox"		"*(oxf+(ox))"	       NOMATCH EXTMATCH
+C		"ofoofo"		"*(of+(o)|f)"	       0       EXTMATCH
+C		"foofoofo"		"@(foo|f|fo)*(f|of+(o))" 0     EXTMATCH
+C		"oofooofo"		"*(of|oof+(o))"	       0       EXTMATCH
+C		"fffooofoooooffoofffooofff" "*(*(f)*(o))"      0       EXTMATCH
+C		"fofoofoofofoo"		"*(fo|foo)"	       0       EXTMATCH
+C		"foo"			"!(x)"		       0       EXTMATCH
+C		"foo"			"!(x)*"		       0       EXTMATCH
+C		"foo"			"!(foo)"	       NOMATCH EXTMATCH
+C		"foo"			"!(foo)*"	       0       EXTMATCH
+C		"foobar"		"!(foo)"	       0       EXTMATCH
+C		"foobar"		"!(foo)*"	       0       EXTMATCH
+C		"moo.cow"		"!(*.*).!(*.*)"	       0       EXTMATCH
+C		"mad.moo.cow"		"!(*.*).!(*.*)"	       NOMATCH EXTMATCH
+C		"mucca.pazza"		"mu!(*(c))?.pa!(*(z))?" NOMATCH EXTMATCH
+C		"fff"			"!(f)"		       0       EXTMATCH
+C		"fff"			"*(!(f))"	       0       EXTMATCH
+C		"fff"			"+(!(f))"	       0       EXTMATCH
+C		"ooo"			"!(f)"		       0       EXTMATCH
+C		"ooo"			"*(!(f))"	       0       EXTMATCH
+C		"ooo"			"+(!(f))"	       0       EXTMATCH
+C		"foo"			"!(f)"		       0       EXTMATCH
+C		"foo"			"*(!(f))"	       0       EXTMATCH
+C		"foo"			"+(!(f))"	       0       EXTMATCH
+C		"f"			"!(f)"		       NOMATCH EXTMATCH
+C		"f"			"*(!(f))"	       NOMATCH EXTMATCH
+C		"f"			"+(!(f))"	       NOMATCH EXTMATCH
+C		"foot"			"@(!(z*)|*x)"	       0       EXTMATCH
+C		"zoot"			"@(!(z*)|*x)"	       NOMATCH EXTMATCH
+C		"foox"			"@(!(z*)|*x)"	       0       EXTMATCH
+C		"zoox"			"@(!(z*)|*x)"	       0       EXTMATCH
+C		"foo"			"*(!(foo))	       0       EXTMATCH
+C		"foob"			"!(foo)b*"	       NOMATCH EXTMATCH
+C		"foobb"			"!(foo)b*"	       0       EXTMATCH
+C		"["			"*([a[])"	       0       EXTMATCH
+C		"]"			"*([]a[])"	       0       EXTMATCH
+C		"a"			"*([]a[])"	       0       EXTMATCH
+C		"b"			"*([!]a[])"	       0       EXTMATCH
+C		"["			"*([!]a[]|[[])"	       0       EXTMATCH
+C		"]"			"*([!]a[]|[]])"	       0       EXTMATCH
+C		"["			"!([!]a[])"	       0       EXTMATCH
+C		"]"			"!([!]a[])"	       0       EXTMATCH
+C		")"			"*([)])"	       0       EXTMATCH
+C		"*"			"*([*(])"	       0       EXTMATCH
+C		"abcd"			"*!(|a)cd"	       0       EXTMATCH
+C		"ab/.a"			"+([abc])/*"	       NOMATCH EXTMATCH|PATHNAME|PERIOD
+C		""			""		       0
+C		""			""		       0       EXTMATCH
+C		""			"*([abc])"	       0       EXTMATCH
+C		""			"?([abc])"	       0       EXTMATCH
Index: trunk/src/libctests/glibc/posix/tst-fork.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-fork.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-fork.c	(revision 2036)
@@ -0,0 +1,152 @@
+/* Tests for fork.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <error.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <wait.h>
+
+
+static const char testdata[] = "This is a test";
+static const char testdata2[] = "And here we go again";
+
+
+int
+main (void)
+{
+  const char *tmpdir = getenv ("TMPDIR");
+  char buf[100];
+  size_t tmpdirlen;
+  char *name;
+  int fd;
+  pid_t pid;
+  pid_t ppid;
+  off_t off;
+  int status;
+
+  if (tmpdir == NULL || *tmpdir == '\0')
+    tmpdir = "/tmp";
+  tmpdirlen = strlen (tmpdir);
+
+  name = (char *) malloc (tmpdirlen + strlen ("/forkXXXXXX") + 1);
+  if (name == NULL)
+    error (EXIT_FAILURE, errno, "cannot allocate file name");
+
+  mempcpy (mempcpy (name, tmpdir, tmpdirlen),
+	   "/forkXXXXXX", sizeof ("/forkXXXXXX"));
+
+  /* Open our test file.   */
+  fd = mkstemp (name);
+  if (fd == -1)
+     error (EXIT_FAILURE, errno, "cannot open test file `%s'", name);
+
+  /* Make sure it gets removed.  */
+  unlink (name);
+
+  /* Write some data.  */
+  if (write (fd, testdata, strlen (testdata)) != strlen (testdata))
+    error (EXIT_FAILURE, errno, "cannot write test data");
+
+  /* Get the position in the stream.  */
+  off = lseek (fd, 0, SEEK_CUR);
+  if (off == (off_t) -1 || off != strlen (testdata))
+    error (EXIT_FAILURE, errno, "wrong file position");
+
+  /* Get the parent PID.  */
+  ppid = getpid ();
+
+  /* Now fork of the process.  */
+  pid = fork ();
+  if (pid == 0)
+    {
+      /* One little test first: the PID must have changed.  */
+      if (getpid () == ppid)
+	error (EXIT_FAILURE, 0, "child and parent have same PID");
+
+      /* Test the `getppid' function.  */
+      pid = getppid ();
+      if (pid == (pid_t) -1 ? errno != ENOSYS : pid != ppid)
+	error (EXIT_FAILURE, 0,
+	       "getppid returned wrong PID (%ld, should be %ld)",
+	       (long int) pid, (long int) ppid);
+
+      /* This is the child.  First get the position of the descriptor.  */
+      off = lseek (fd, 0, SEEK_CUR);
+      if (off == (off_t) -1 || off != strlen (testdata))
+	error (EXIT_FAILURE, errno, "wrong file position in child");
+
+      /* Reset the position.  */
+      if (lseek (fd, 0, SEEK_SET) != 0)
+	error (EXIT_FAILURE, errno, "cannot reset position in child");
+
+      /* Read the data.  */
+      if (read (fd, buf, sizeof buf) != strlen (testdata))
+	error (EXIT_FAILURE, errno, "cannot read data in child");
+
+      /* Compare the data.  */
+      if (memcmp (buf, testdata, strlen (testdata)) != 0)
+	error (EXIT_FAILURE, 0, "data comparison failed in child");
+
+      /* Reset position again.  */
+      if (lseek (fd, 0, SEEK_SET) != 0)
+	error (EXIT_FAILURE, errno, "cannot reset position again in child");
+
+      /* Write new data.  */
+      if (write (fd, testdata2, strlen (testdata2)) != strlen (testdata2))
+	error (EXIT_FAILURE, errno, "cannot write new data in child");
+
+      /* Close the file.  This must not remove it.  */
+      close (fd);
+
+      _exit (0);
+    }
+  else if (pid < 0)
+    /* Something went wrong.  */
+    error (EXIT_FAILURE, errno, "cannot fork");
+
+  /* Wait for the child.  */
+  if (waitpid (pid, &status, 0) != pid)
+    error (EXIT_FAILURE, 0, "Oops, wrong test program terminated");
+
+  if (WTERMSIG (status) != 0)
+    error (EXIT_FAILURE, 0, "Child terminated incorrectly");
+  status = WEXITSTATUS (status);
+
+  if (status == 0)
+    {
+      /* Test whether the child wrote the right data.  First test the
+	 position.  It must be the same as in the child.  */
+      if (lseek (fd, 0, SEEK_CUR) != strlen (testdata2))
+	error (EXIT_FAILURE, 0, "file position not changed");
+
+      if (lseek (fd, 0, SEEK_SET) != 0)
+	error (EXIT_FAILURE, errno, "cannot reset file position");
+
+      if (read (fd, buf, sizeof buf) != strlen (testdata2))
+	error (EXIT_FAILURE, errno, "cannot read new data");
+
+      if (memcmp (buf, testdata2, strlen (testdata2)) != 0)
+	error (EXIT_FAILURE, 0, "new data not read correctly");
+    }
+
+  return status;
+}
Index: trunk/src/libctests/glibc/posix/tst-getaddrinfo.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-getaddrinfo.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-getaddrinfo.c	(revision 2036)
@@ -0,0 +1,69 @@
+/* Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+
+static int
+do_test (void)
+{
+  const int family[2] = { AF_INET, AF_INET6 };
+  int result = 0;
+  int gaierr;
+  size_t index;
+  struct addrinfo hints, *ai, *aitop;
+
+  for (index = 0; index < sizeof (family) / sizeof (family[0]); ++index)
+    {
+      memset (&hints, '\0', sizeof (hints));
+      hints.ai_family = family[index];
+      hints.ai_socktype = SOCK_STREAM;
+
+      gaierr = getaddrinfo (NULL, "54321", &hints, &aitop);
+      if (gaierr != 0)
+	{
+	  gai_strerror (gaierr);
+	  result = 1;
+	}
+      else
+	{
+	  for (ai = aitop; ai != NULL; ai = ai->ai_next)
+	    {
+	      printf ("Should return family: %d. Returned: %d\n",
+		      family[index], ai->ai_family);
+	      result |= family[index] != ai->ai_family;
+	    }
+
+	  while (aitop != NULL)
+	    {
+	      ai = aitop;
+	      aitop = aitop->ai_next;
+	      freeaddrinfo (ai);
+	    }
+	}
+    }
+
+  return result;
+}
+#define TEST_FUNCTION do_test ()
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/posix/tst-getaddrinfo2.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-getaddrinfo2.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-getaddrinfo2.c	(revision 2036)
@@ -0,0 +1,77 @@
+/* Test by David L Stevens <dlstevens@us.ibm.com> [BZ #358] */
+#include <errno.h>
+#include <netdb.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h>
+
+static int
+do_test (void)
+{
+  const char portstr[] = "583";
+  int port = atoi (portstr);
+  struct addrinfo hints, *aires, *pai;
+  int rv;
+  int res = 1;
+
+  memset (&hints, 0, sizeof (hints));
+  hints.ai_family = AF_INET;
+  rv = getaddrinfo (NULL, portstr, &hints, &aires);
+  if (rv == 0)
+    {
+      struct sockaddr_in *psin = 0;
+      int got_tcp, got_udp;
+      int err = 0;
+
+      got_tcp = got_udp = 0;
+      for (pai = aires; pai; pai = pai->ai_next)
+        {
+          printf ("ai_family=%d, ai_addrlen=%d, ai_socktype=%d",
+                  (int) pai->ai_family, (int) pai->ai_addrlen,
+                  (int) pai->ai_socktype);
+          if (pai->ai_family == AF_INET)
+            printf (", port=%d",
+                    ntohs (((struct sockaddr_in *) pai->ai_addr)->sin_port));
+          puts ("");
+
+          err |= pai->ai_family != AF_INET;
+          err |= pai->ai_addrlen != sizeof (struct sockaddr_in);
+          err |= pai->ai_addr == 0;
+          if (pai->ai_family == AF_INET)
+            err |=
+              ntohs (((struct sockaddr_in *) pai->ai_addr)->sin_port) != port;
+          got_tcp |= pai->ai_socktype == SOCK_STREAM;
+          got_udp |= pai->ai_socktype == SOCK_DGRAM;
+          if (err)
+            break;
+        }
+      if (err)
+        {
+          printf ("FAIL getaddrinfo IPv4 socktype 0,513: "
+                  "fam %d alen %d addr %p addr/fam %d "
+                  "addr/port %d H[%d]\n",
+                  pai->ai_family, pai->ai_addrlen, psin,
+                  psin ? psin->sin_family : 0,
+                  psin ? psin->sin_port : 0,
+                  psin ? htons (psin->sin_port) : 0);
+        }
+      else if (got_tcp && got_udp)
+        {
+          printf ("SUCCESS getaddrinfo IPv4 socktype 0,513\n");
+          res = 0;
+        }
+      else
+        printf ("FAIL getaddrinfo IPv4 socktype 0,513 TCP %d"
+                " UDP %d\n", got_tcp, got_udp);
+      freeaddrinfo (aires);
+    }
+  else
+    printf ("FAIL getaddrinfo IPv4 socktype 0,513 returns %d "
+            "(\"%s\")\n", rv, gai_strerror (rv));
+
+  return res;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/posix/tst-getconf.sh
===================================================================
--- trunk/src/libctests/glibc/posix/tst-getconf.sh	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-getconf.sh	(revision 2036)
@@ -0,0 +1,243 @@
+#! /bin/sh
+
+common_objpfx=$1; shift
+elf_objpfx=$1; shift
+if [ $# -eq 0 ]; then
+  # Static case.
+  runit() {
+    "$@"
+  }
+else
+  rtld_installed_name=$1; shift
+  runit() {
+    ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} "$@"
+  }
+fi
+
+logfile=$common_objpfx/posix/tst-getconf.out
+
+# Since we use `sort' we must make sure to use the same locale everywhere.
+LC_ALL=C
+export LC_ALL
+LANG=C
+export LANG
+
+rm -f $logfile
+result=0
+while read name; do
+  echo -n "getconf $name: " >> $logfile
+  runit ${common_objpfx}posix/getconf "$name" 2>> $logfile >> $logfile
+  if test $? -ne 0; then
+    echo "*** $name FAILED" >> $logfile
+    result=1
+  fi
+done <<EOF
+AIO_LISTIO_MAX
+AIO_MAX
+AIO_PRIO_DELTA_MAX
+ARG_MAX
+ATEXIT_MAX
+BC_BASE_MAX
+BC_DIM_MAX
+BC_SCALE_MAX
+BC_STRING_MAX
+CHILD_MAX
+COLL_WEIGHTS_MAX
+DELAYTIMER_MAX
+EXPR_NEST_MAX
+HOST_NAME_MAX
+IOV_MAX
+LINE_MAX
+LOGIN_NAME_MAX
+NGROUPS_MAX
+MQ_OPEN_MAX
+MQ_PRIO_MAX
+OPEN_MAX
+_POSIX_ADVISORY_INFO
+_POSIX_BARRIERS
+_POSIX_ASYNCHRONOUS_IO
+_POSIX_BASE
+_POSIX_C_LANG_SUPPORT
+_POSIX_C_LANG_SUPPORT_R
+_POSIX_CLOCK_SELECTION
+_POSIX_CPUTIME
+_POSIX_DEVICE_IO
+_POSIX_DEVICE_SPECIFIC
+_POSIX_DEVICE_SPECIFIC_R
+_POSIX_FD_MGMT
+_POSIX_FIFO
+_POSIX_FILE_ATTRIBUTES
+_POSIX_FILE_LOCKING
+_POSIX_FILE_SYSTEM
+_POSIX_FSYNC
+_POSIX_JOB_CONTROL
+_POSIX_MAPPED_FILES
+_POSIX_MEMLOCK
+_POSIX_MEMLOCK_RANGE
+_POSIX_MEMORY_PROTECTION
+_POSIX_MESSAGE_PASSING
+_POSIX_MONOTONIC_CLOCK
+_POSIX_MULTI_PROCESS
+_POSIX_NETWORKING
+_POSIX_PIPE
+_POSIX_PRIORITIZED_IO
+_POSIX_PRIORITY_SCHEDULING
+_POSIX_READER_WRITER_LOCKS
+_POSIX_REALTIME_SIGNALS
+_POSIX_REGEXP
+_POSIX_SAVED_IDS
+_POSIX_SEMAPHORES
+_POSIX_SHARED_MEMORY_OBJECTS
+_POSIX_SHELL
+_POSIX_SIGNALS
+_POSIX_SINGLE_PROCESS
+_POSIX_SPAWN
+_POSIX_SPIN_LOCKS
+_POSIX_SPORADIC_SERVER
+_POSIX_SYNCHRONIZED_IO
+_POSIX_SYSTEM_DATABASE
+_POSIX_SYSTEM_DATABASE_R
+_POSIX_THREAD_ATTR_STACKADDR
+_POSIX_THREAD_ATTR_STACKSIZE
+_POSIX_THREAD_CPUTIME
+_POSIX_THREAD_PRIO_INHERIT
+_POSIX_THREAD_PRIO_PROTECT
+_POSIX_THREAD_PRIORITY_SCHEDULING
+_POSIX_THREAD_PROCESS_SHARED
+_POSIX_THREAD_SAFE_FUNCTIONS
+_POSIX_THREAD_SPORADIC_SERVER
+_POSIX_THREADS
+_POSIX_TIMEOUTS
+_POSIX_TIMERS
+_POSIX_TRACE
+_POSIX_TRACE_EVENT_FILTER
+_POSIX_TRACE_INHERIT
+_POSIX_TRACE_LOG
+_POSIX_TYPED_MEMORY_OBJECTS
+_POSIX_USER_GROUPS
+_POSIX_USER_GROUPS_R
+_POSIX_VERSION
+_POSIX_V6_ILP32_OFF32
+_POSIX_V6_ILP32_OFFBIG
+_POSIX_V6_LP64_OFF64
+_POSIX_V6_LPBIG_OFFBIG
+_POSIX_V6_WIDTH_RESTRICTED_ENVS
+POSIX2_C_BIND
+POSIX2_C_DEV
+POSIX2_C_VERSION
+POSIX2_CHAR_TERM
+POSIX2_FORT_DEV
+POSIX2_FORT_RUN
+POSIX2_LOCALEDEF
+POSIX2_PBS
+POSIX2_PBS_ACCOUNTING
+POSIX2_PBS_LOCATE
+POSIX2_PBS_MESSAGE
+POSIX2_PBS_TRACK
+POSIX2_SW_DEV
+POSIX2_UPE
+POSIX2_VERSION
+_REGEX_VERSION
+PAGE_SIZE
+PAGESIZE
+PTHREAD_DESTRUCTOR_ITERATIONS
+PTHREAD_KEYS_MAX
+PTHREAD_STACK_MIN
+PTHREAD_THREADS_MAX
+RE_DUP_MAX
+RTSIG_MAX
+SEM_NSEMS_MAX
+SEM_VALUE_MAX
+SIGQUEUE_MAX
+STREAM_MAX
+SYMLOOP_MAX
+TIMER_MAX
+TTY_NAME_MAX
+TZNAME_MAX
+_XBS5_ILP32_OFF32
+_XBS5_ILP32_OFFBIG
+_XBS5_LP64_OFF64
+_XBS5_LPBIG_OFFBIG
+_XOPEN_CRYPT
+_XOPEN_ENH_I18N
+_XOPEN_LEGACY
+_XOPEN_REALTIME
+_XOPEN_REALTIME_THREADS
+_XOPEN_SHM
+_XOPEN_UNIX
+_XOPEN_VERSION
+_XOPEN_XCU_VERSION
+PATH
+POSIX_V6_ILP32_OFF32_CFLAGS
+POSIX_V6_ILP32_OFF32_LDFLAGS
+POSIX_V6_ILP32_OFF32_LIBS
+POSIX_V6_ILP32_OFF32_LINTFLAGS
+POSIX_V6_ILP32_OFFBIG_CFLAGS
+POSIX_V6_ILP32_OFFBIG_LDFLAGS
+POSIX_V6_ILP32_OFFBIG_LIBS
+POSIX_V6_ILP32_OFFBIG_LINTFLAGS
+POSIX_V6_LP64_OFF64_CFLAGS
+POSIX_V6_LP64_OFF64_LDFLAGS
+POSIX_V6_LP64_OFF64_LIBS
+POSIX_V6_LP64_OFF64_LINTFLAGS
+POSIX_V6_LPBIG_OFFBIG_CFLAGS
+POSIX_V6_LPBIG_OFFBIG_LDFLAGS
+POSIX_V6_LPBIG_OFFBIG_LIBS
+POSIX_V6_LPBIG_OFFBIG_LINTFLAGS
+XBS5_ILP32_OFF32_CFLAGS
+XBS5_ILP32_OFF32_LDFLAGS
+XBS5_ILP32_OFF32_LIBS
+XBS5_ILP32_OFF32_LINTFLAGS
+XBS5_ILP32_OFFBIG_CFLAGS
+XBS5_ILP32_OFFBIG_LDFLAGS
+XBS5_ILP32_OFFBIG_LIBS
+XBS5_ILP32_OFFBIG_LINTFLAGS
+XBS5_LP64_OFF64_CFLAGS
+XBS5_LP64_OFF64_LDFLAGS
+XBS5_LP64_OFF64_LIBS
+XBS5_LP64_OFF64_LINTFLAGS
+XBS5_LPBIG_OFFBIG_CFLAGS
+XBS5_LPBIG_OFFBIG_LDFLAGS
+XBS5_LPBIG_OFFBIG_LIBS
+XBS5_LPBIG_OFFBIG_LINTFLAGS
+EOF
+
+while read name; do
+  echo -n "getconf $name /: " >> $logfile
+  runit ${common_objpfx}posix/getconf "$name" / 2>> $logfile >> $logfile
+  if test $? -ne 0; then
+    echo "*** $name FAILED" >> $logfile
+    result=1
+  fi
+done <<EOF
+FILESIZEBITS
+LINK_MAX
+MAX_CANON
+MAX_INPUT
+NAME_MAX
+PATH_MAX
+PIPE_BUF
+POSIX_ALLOC_SIZE_MIN
+POSIX_REC_INCR_XFER_SIZE
+POSIX_REC_MAX_XFER_SIZE
+POSIX_REC_MIN_XFER_SIZE
+POSIX_REC_XFER_ALIGN
+SYMLINK_MAX
+_POSIX_CHOWN_RESTRICTED
+_POSIX_NO_TRUNC
+_POSIX_VDISABLE
+_POSIX_ASYNC_IO
+_POSIX_PRIO_IO
+_POSIX_SYNC_IO
+EOF
+
+exit $result
+
+# Preserve executable bits for this shell script.
+Local Variables:
+eval:(defun frobme () (set-file-modes buffer-file-name file-mode))
+eval:(make-local-variable 'file-mode)
+eval:(setq file-mode (file-modes (buffer-file-name)))
+eval:(make-local-variable 'after-save-hook)
+eval:(add-hook 'after-save-hook 'frobme)
+End:
Index: trunk/src/libctests/glibc/posix/tst-getlogin.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-getlogin.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-getlogin.c	(revision 2036)
@@ -0,0 +1,58 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+
+int
+main (void)
+{
+  char *login;
+  int errors = 0;
+
+  login = getlogin ();
+  if (login == NULL)
+    puts ("getlogin returned NULL, no further tests");
+  else
+    {
+      char name[1024];
+      int ret;
+
+      printf ("getlogin returned: `%s'\n", login);
+
+      ret = getlogin_r (name, sizeof (name));
+      if (ret == 0)
+	{
+	  printf ("getlogin_r returned: `%s'\n", name);
+	  if (strcmp (name, login) != 0)
+	    {
+	      puts ("Error: getlogin and getlogin_r returned different names");
+	      ++errors;
+	    }
+	}
+      else
+	{
+	  printf ("Error: getlogin_r returned: %d (%s)\n",
+		  ret, strerror (ret));
+	  ++errors;
+	}
+    }
+
+  return errors != 0;
+}
Index: trunk/src/libctests/glibc/posix/tst-gnuglob.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-gnuglob.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-gnuglob.c	(revision 2036)
@@ -0,0 +1,445 @@
+/* Test the GNU extensions in glob which allow the user to provide callbacks
+   for the filesystem access functions.
+   Copyright (C) 2001-2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <dirent.h>
+#include <errno.h>
+#include <error.h>
+#include <glob.h>
+#include <mcheck.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+
+
+// #define DEBUG
+#ifdef DEBUG
+# define PRINTF(fmt, args...) printf (fmt, ##args)
+#else
+# define PRINTF(fmt, args...)
+#endif
+
+
+static struct
+{
+  const char *name;
+  int level;
+  int type;
+} filesystem[] =
+{
+  { ".", 1, DT_DIR },
+  { "..", 1, DT_DIR },
+  { "file1lev1", 1, DT_REG },
+  { "file2lev1", 1, DT_UNKNOWN },
+  { "dir1lev1", 1, DT_UNKNOWN },
+    { ".", 2, DT_DIR },
+    { "..", 2, DT_DIR },
+    { "file1lev2", 2, DT_REG },
+    { "dir1lev2", 2, DT_DIR },
+      { ".", 3, DT_DIR },
+      { "..", 3, DT_DIR },
+    { "dir2lev2", 2, DT_DIR },
+      { ".", 3, DT_DIR },
+      { "..", 3, DT_DIR },
+      { ".foo", 3, DT_REG },
+      { "dir1lev3", 3, DT_DIR },
+        { ".", 4, DT_DIR },
+        { "..", 4, DT_DIR },
+        { "file1lev4", 4, DT_REG },
+      { "file1lev3", 3, DT_REG },
+      { "file2lev3", 3, DT_REG },
+    { "file2lev2", 2, DT_REG },
+    { "file3lev2", 2, DT_REG },
+    { "dir3lev2", 2, DT_DIR },
+      { ".", 3, DT_DIR },
+      { "..", 3, DT_DIR },
+      { "file3lev3", 3, DT_REG },
+      { "file4lev3", 3, DT_REG },
+  { "dir2lev1", 1, DT_DIR },
+    { ".", 2, DT_DIR },
+    { "..", 2, DT_DIR },
+    { "dir1lev2", 2, DT_UNKNOWN },
+      { ".", 3, DT_DIR },
+      { "..", 3, DT_DIR },
+      { ".foo", 3, DT_REG },
+      { ".dir", 3, DT_DIR },
+        { ".", 4, DT_DIR },
+        { "..", 4, DT_DIR },
+        { "hidden", 4, DT_REG }
+};
+#define nfiles (sizeof (filesystem) / sizeof (filesystem[0]))
+
+
+typedef struct
+{
+  int level;
+  int idx;
+  struct dirent d;
+  char room_for_dirent[NAME_MAX];
+} my_DIR;
+
+
+static long int
+find_file (const char *s)
+{
+  int level = 1;
+  long int idx = 0;
+
+  if (strcmp (s, ".") == 0)
+    return 0;
+
+  if (s[0] == '.' && s[1] == '/')
+    s += 2;
+
+  while (*s != '\0')
+    {
+      char *endp = strchrnul (s, '/');
+
+      PRINTF ("looking for %.*s, level %d\n", (int) (endp - s), s, level);
+
+      while (idx < nfiles && filesystem[idx].level >= level)
+	{
+	  if (filesystem[idx].level == level
+	      && memcmp (s, filesystem[idx].name, endp - s) == 0
+	      && filesystem[idx].name[endp - s] == '\0')
+	    break;
+	  ++idx;
+	}
+
+      if (idx == nfiles || filesystem[idx].level < level)
+	{
+	  errno = ENOENT;
+	  return -1;
+	}
+
+      if (*endp == '\0')
+	return idx + 1;
+
+      if (filesystem[idx].type != DT_DIR
+	  && (idx + 1 >= nfiles
+	      || filesystem[idx].level >= filesystem[idx + 1].level))
+	{
+	  errno = ENOTDIR;
+	  return -1;
+	}
+
+      ++idx;
+
+      s = endp + 1;
+      ++level;
+    }
+
+  errno = ENOENT;
+  return -1;
+}
+
+
+static void *
+my_opendir (const char *s)
+{
+  long int idx = find_file (s);
+  my_DIR *dir;
+
+
+  if (idx == -1)
+    {
+      PRINTF ("my_opendir(\"%s\") == NULL\n", s);
+      return NULL;
+    }
+
+  dir = (my_DIR *) malloc (sizeof (my_DIR));
+  if (dir == NULL)
+    error (EXIT_FAILURE, errno, "cannot allocate directory handle");
+
+  dir->level = filesystem[idx].level;
+  dir->idx = idx;
+
+  PRINTF ("my_opendir(\"%s\") == { level: %d, idx: %ld }\n",
+	  s, filesystem[idx].level, idx);
+
+  return dir;
+}
+
+
+static struct dirent *
+my_readdir (void *gdir)
+{
+  my_DIR *dir = gdir;
+
+  if (dir->idx == -1)
+    {
+      PRINTF ("my_readdir ({ level: %d, idx: %ld }) = NULL\n",
+	      dir->level, (long int) dir->idx);
+      return NULL;
+    }
+
+  while (dir->idx < nfiles && filesystem[dir->idx].level > dir->level)
+    ++dir->idx;
+
+  if (dir->idx == nfiles || filesystem[dir->idx].level < dir->level)
+    {
+      dir->idx = -1;
+      PRINTF ("my_readdir ({ level: %d, idx: %ld }) = NULL\n",
+	      dir->level, (long int) dir->idx);
+      return NULL;
+    }
+
+  dir->d.d_ino = dir->idx;
+
+#ifdef _DIRENT_HAVE_D_TYPE
+  dir->d.d_type = filesystem[dir->idx].type;
+#endif
+
+  strcpy (dir->d.d_name, filesystem[dir->idx].name);
+
+#ifdef _DIRENT_HAVE_D_TYPE
+  PRINTF ("my_readdir ({ level: %d, idx: %ld }) = { d_ino: %ld, d_type: %d, d_name: \"%s\" }\n",
+	  dir->level, (long int) dir->idx, dir->d.d_ino, dir->d.d_type,
+	  dir->d.d_name);
+#else
+  PRINTF ("my_readdir ({ level: %d, idx: %ld }) = { d_ino: %ld, d_name: \"%s\" }\n",
+	  dir->level, (long int) dir->idx, dir->d.d_ino,
+	  dir->d.d_name);
+#endif
+
+  ++dir->idx;
+
+  return &dir->d;
+}
+
+
+static void
+my_closedir (void *dir)
+{
+  PRINTF ("my_closedir ()\n");
+  free (dir);
+}
+
+
+/* We use this function for lstat as well since we don't have any.  */
+static int
+my_stat (const char *name, struct stat *st)
+{
+  long int idx = find_file (name);
+
+  if (idx == -1)
+    {
+      PRINTF ("my_stat (\"%s\", ...) = -1 (%s)\n", name, strerror (errno));
+      return -1;
+    }
+
+  memset (st, '\0', sizeof (*st));
+
+  if (filesystem[idx].type == DT_UNKNOWN)
+    st->st_mode = DTTOIF (idx + 1 < nfiles
+			  && filesystem[idx].level < filesystem[idx + 1].level
+			  ? DT_DIR : DT_REG) | 0777;
+  else
+    st->st_mode = DTTOIF (filesystem[idx].type) | 0777;
+
+  PRINTF ("my_stat (\"%s\", { st_mode: %o }) = 0\n", name, st->st_mode);
+
+  return 0;
+}
+
+
+static const char *glob_errstring[] =
+{
+  [GLOB_NOSPACE] = "out of memory",
+  [GLOB_ABORTED] = "read error",
+  [GLOB_NOMATCH] = "no matches found"
+};
+#define nglob_errstring (sizeof (glob_errstring) / sizeof (glob_errstring[0]))
+
+
+static const char *
+flagstr (int flags)
+{
+  const char *strs[] =
+  {
+    "GLOB_ERR", "GLOB_MARK", "GLOB_NOSORT", "GLOB_DOOFSS", "GLOB_NOCHECK",
+    "GLOB_APPEND", "GLOB_NOESCAPE", "GLOB_PERIOD", "GLOB_MAGCHAR",
+    "GLOB_ALTDIRFUNC", "GLOB_BRACE", "GLOB_NOMAGIC", "GLOB_TILDE",
+    "GLOB_ONLYDIR", "GLOB_TILDECHECK"
+  };
+#define nstrs (sizeof (strs) / sizeof (strs[0]))
+  static char buf[100];
+  char *cp = buf;
+  int cnt;
+
+  for (cnt = 0; cnt < nstrs; ++cnt)
+    if (flags & (1 << cnt))
+      {
+	flags &= ~(1 << cnt);
+	if (cp != buf)
+	  *cp++ = '|';
+	cp = stpcpy (cp, strs[cnt]);
+      }
+
+  if (flags != 0)
+    {
+      if (cp != buf)
+	*cp++ = '|';
+      sprintf (cp, "%#x", flags);
+    }
+
+  return buf;
+}
+
+
+static int
+test_result (const char *fmt, int flags, glob_t *gl, const char *str[])
+{
+  size_t cnt;
+  int result = 0;
+
+  printf ("results for glob (\"%s\", %s)\n", fmt, flagstr (flags));
+  for (cnt = 0; cnt < gl->gl_pathc && str[cnt] != NULL; ++cnt)
+    {
+      int ok = strcmp (gl->gl_pathv[cnt], str[cnt]) == 0;
+      const char *errstr = "";
+
+      if (! ok)
+	{
+	  size_t inner;
+
+	  for (inner = 0; str[inner] != NULL; ++inner)
+	    if (strcmp (gl->gl_pathv[cnt], str[inner]) == 0)
+	      break;
+
+	  if (str[inner] == NULL)
+	    errstr =  ok ? "" : " *** WRONG";
+	  else
+	    errstr = ok ? "" : " * wrong position";
+
+	  result = 1;
+	}
+
+      printf ("  %s%s\n", gl->gl_pathv[cnt], errstr);
+    }
+  puts ("");
+
+  if (str[cnt] != NULL || cnt < gl->gl_pathc)
+    {
+      puts ("  *** incorrect number of entries");
+      result = 1;
+    }
+
+  return result;
+}
+
+
+int
+main (void)
+{
+  glob_t gl;
+  int errval;
+  int result = 0;
+  const char *fmt;
+  int flags;
+
+  mtrace ();
+
+  memset (&gl, '\0', sizeof (gl));
+
+  gl.gl_closedir = my_closedir;
+  gl.gl_readdir = my_readdir;
+  gl.gl_opendir = my_opendir;
+  gl.gl_lstat = my_stat;
+  gl.gl_stat = my_stat;
+
+#define test(a, b, c...) \
+  fmt = a;								      \
+  flags = b;								      \
+  errval = glob (fmt, flags, NULL, &gl);				      \
+  if (errval != 0)							      \
+    {									      \
+      printf ("glob (\"%s\", %s) failed: %s\n", fmt, flagstr (flags),	      \
+	      errval >= 0 && errval < nglob_errstring			      \
+	      ? glob_errstring[errval] : "???");			      \
+      result = 1;							      \
+    }									      \
+  else									      \
+    result |= test_result (fmt, flags, &gl, (const char *[]) { c, NULL })
+
+  test ("*/*/*", GLOB_ALTDIRFUNC,
+	"dir1lev1/dir2lev2/dir1lev3",
+	"dir1lev1/dir2lev2/file1lev3",
+	"dir1lev1/dir2lev2/file2lev3",
+	"dir1lev1/dir3lev2/file3lev3",
+	"dir1lev1/dir3lev2/file4lev3");
+
+  test ("*/*/*", GLOB_ALTDIRFUNC | GLOB_PERIOD,
+	"dir1lev1/dir1lev2/.",
+	"dir1lev1/dir1lev2/..",
+	"dir1lev1/dir2lev2/.",
+	"dir1lev1/dir2lev2/..",
+	"dir1lev1/dir2lev2/.foo",
+	"dir1lev1/dir2lev2/dir1lev3",
+	"dir1lev1/dir2lev2/file1lev3",
+	"dir1lev1/dir2lev2/file2lev3",
+	"dir1lev1/dir3lev2/.",
+	"dir1lev1/dir3lev2/..",
+	"dir1lev1/dir3lev2/file3lev3",
+	"dir1lev1/dir3lev2/file4lev3",
+	"dir2lev1/dir1lev2/.",
+	"dir2lev1/dir1lev2/..",
+	"dir2lev1/dir1lev2/.dir",
+	"dir2lev1/dir1lev2/.foo");
+
+  test ("*/*/.*", GLOB_ALTDIRFUNC,
+	"dir1lev1/dir1lev2/.",
+	"dir1lev1/dir1lev2/..",
+	"dir1lev1/dir2lev2/.",
+	"dir1lev1/dir2lev2/..",
+	"dir1lev1/dir2lev2/.foo",
+	"dir1lev1/dir3lev2/.",
+	"dir1lev1/dir3lev2/..",
+	"dir2lev1/dir1lev2/.",
+	"dir2lev1/dir1lev2/..",
+	"dir2lev1/dir1lev2/.dir",
+	"dir2lev1/dir1lev2/.foo");
+
+  test ("*1*/*2*/.*", GLOB_ALTDIRFUNC,
+	"dir1lev1/dir1lev2/.",
+	"dir1lev1/dir1lev2/..",
+	"dir1lev1/dir2lev2/.",
+	"dir1lev1/dir2lev2/..",
+	"dir1lev1/dir2lev2/.foo",
+	"dir1lev1/dir3lev2/.",
+	"dir1lev1/dir3lev2/..",
+	"dir2lev1/dir1lev2/.",
+	"dir2lev1/dir1lev2/..",
+	"dir2lev1/dir1lev2/.dir",
+	"dir2lev1/dir1lev2/.foo");
+
+  test ("*1*/*1*/.*", GLOB_ALTDIRFUNC,
+	"dir1lev1/dir1lev2/.",
+	"dir1lev1/dir1lev2/..",
+	"dir2lev1/dir1lev2/.",
+	"dir2lev1/dir1lev2/..",
+	"dir2lev1/dir1lev2/.dir",
+	"dir2lev1/dir1lev2/.foo");
+
+  globfree (&gl);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/posix/tst-mmap.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-mmap.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-mmap.c	(revision 2036)
@@ -0,0 +1,197 @@
+#include <assert.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+
+int
+main (void)
+{
+  int result = 0;
+  FILE *fp;
+  size_t c;
+  char buf[1000];
+  int fd;
+  unsigned char *ptr;
+  size_t ps = sysconf (_SC_PAGESIZE);
+  void *mem;
+
+  /* Create a file and put some data in it.  */
+  fp = tmpfile ();
+  if (fp == NULL)
+    {
+      printf ("Cannot create temporary file: %m\n");
+      return 1;
+    }
+  fd = fileno (fp);
+
+  for (c = 0; c < sizeof (buf); ++c)
+    buf[c] = '0' + (c % 10);
+
+  for (c = 0; c < (ps * 4) / sizeof (buf); ++c)
+    if (fwrite (buf, 1, sizeof (buf), fp) != sizeof (buf))
+      {
+	printf ("`fwrite' failed: %m\n");
+	return 1;
+      }
+  fflush (fp);
+  assert (ps + 1000 < c * sizeof (buf));
+
+  /* First try something which is not allowed: map at an offset which is
+     not modulo the pagesize.  */
+  ptr = mmap (NULL, 1000, PROT_READ, MAP_SHARED, fd, ps - 1);
+  if (ptr != MAP_FAILED)
+    {
+      puts ("mapping at offset with mod pagesize != 0 succeeded!");
+      result = 1;
+    }
+  else if (errno != EINVAL && errno != ENOSYS)
+    {
+      puts ("wrong error value for mapping at offset with mod pagesize != 0: %m (should be EINVAL)");
+      result = 1;
+    }
+
+  /* Try the same for mmap64.  */
+  ptr = mmap64 (NULL, 1000, PROT_READ, MAP_SHARED, fd, ps - 1);
+  if (ptr != MAP_FAILED)
+    {
+      puts ("mapping at offset with mod pagesize != 0 succeeded!");
+      result = 1;
+    }
+  else if (errno != EINVAL && errno != ENOSYS)
+    {
+      puts ("wrong error value for mapping at offset with mod pagesize != 0: %m (should be EINVAL)");
+      result = 1;
+    }
+
+  /* And the same for private mapping.  */
+  ptr = mmap (NULL, 1000, PROT_READ, MAP_PRIVATE, fd, ps - 1);
+  if (ptr != MAP_FAILED)
+    {
+      puts ("mapping at offset with mod pagesize != 0 succeeded!");
+      result = 1;
+    }
+  else if (errno != EINVAL && errno != ENOSYS)
+    {
+      puts ("wrong error value for mapping at offset with mod pagesize != 0: %m (should be EINVAL)");
+      result = 1;
+    }
+
+  /* Try the same for mmap64.  */
+  ptr = mmap64 (NULL, 1000, PROT_READ, MAP_PRIVATE, fd, ps - 1);
+  if (ptr != MAP_FAILED)
+    {
+      puts ("mapping at offset with mod pagesize != 0 succeeded!");
+      result = 1;
+    }
+  else if (errno != EINVAL && errno != ENOSYS)
+    {
+      puts ("wrong error value for mapping at offset with mod pagesize != 0: %m (should be EINVAL)");
+      result = 1;
+    }
+
+  /* Get a valid address.  */
+  mem = malloc (2 * ps);
+  if (mem != NULL)
+    {
+      /* Now we map at an address which is not mod pagesize.  */
+      ptr = mmap (mem + 1, 1000, PROT_READ, MAP_SHARED | MAP_FIXED, fd, ps);
+      if (ptr != MAP_FAILED)
+	{
+	  puts ("mapping at address with mod pagesize != 0 succeeded!");
+	  result = 1;
+	}
+      else  if (errno != EINVAL && errno != ENOSYS)
+	{
+	  puts ("wrong error value for mapping at address with mod pagesize != 0: %m (should be EINVAL)");
+	  result = 1;
+	}
+
+      /* Try the same for mmap64.  */
+      ptr = mmap64 (mem + 1, 1000, PROT_READ, MAP_SHARED | MAP_FIXED, fd, ps);
+      if (ptr != MAP_FAILED)
+	{
+	  puts ("mapping at address with mod pagesize != 0 succeeded!");
+	  result = 1;
+	}
+      else  if (errno != EINVAL && errno != ENOSYS)
+	{
+	  puts ("wrong error value for mapping at address with mod pagesize != 0: %m (should be EINVAL)");
+	  result = 1;
+	}
+
+      /* And again for MAP_PRIVATE.  */
+      ptr = mmap (mem + 1, 1000, PROT_READ, MAP_PRIVATE | MAP_FIXED, fd, ps);
+      if (ptr != MAP_FAILED)
+	{
+	  puts ("mapping at address with mod pagesize != 0 succeeded!");
+	  result = 1;
+	}
+      else  if (errno != EINVAL && errno != ENOSYS)
+	{
+	  puts ("wrong error value for mapping at address with mod pagesize != 0: %m (should be EINVAL)");
+	  result = 1;
+	}
+
+      /* Try the same for mmap64.  */
+      ptr = mmap64 (mem + 1, 1000, PROT_READ, MAP_PRIVATE | MAP_FIXED, fd, ps);
+      if (ptr != MAP_FAILED)
+	{
+	  puts ("mapping at address with mod pagesize != 0 succeeded!");
+	  result = 1;
+	}
+      else  if (errno != EINVAL && errno != ENOSYS)
+	{
+	  puts ("wrong error value for mapping at address with mod pagesize != 0: %m (should be EINVAL)");
+	  result = 1;
+	}
+
+      free (mem);
+    }
+
+  /* Now map the memory and see whether the content of the mapped area
+     is correct.  */
+  ptr = mmap (NULL, 1000, PROT_READ, MAP_SHARED, fd, ps);
+  if (ptr == MAP_FAILED)
+    {
+      if (errno != ENOSYS)
+	{
+	  printf ("cannot mmap file: %m\n");
+	  result = 1;
+	}
+    }
+  else
+    {
+      for (c = ps; c < ps + 1000; ++c)
+	if (ptr[c - ps] != '0' + (c % 10))
+	  {
+	    printf ("wrong data mapped at offset %zd\n", c);
+	    result = 1;
+	  }
+    }
+
+  /* And for mmap64. */
+  ptr = mmap64 (NULL, 1000, PROT_READ, MAP_SHARED, fd, ps);
+  if (ptr == MAP_FAILED)
+    {
+      if (errno != ENOSYS)
+	{
+	  printf ("cannot mmap file: %m\n");
+	  result = 1;
+	}
+    }
+  else
+    {
+      for (c = ps; c < ps + 1000; ++c)
+	if (ptr[c - ps] != '0' + (c % 10))
+	  {
+	    printf ("wrong data mapped at offset %zd\n", c);
+	    result = 1;
+	  }
+    }
+
+  /* That's it.  */
+  return result;
+}
Index: trunk/src/libctests/glibc/posix/tst-nanosleep.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-nanosleep.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-nanosleep.c	(revision 2036)
@@ -0,0 +1,58 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <time.h>
+
+
+/* Test that nanosleep() does sleep.  */
+static int
+do_test (void)
+{
+  /* Current time.  */
+  struct timeval tv1;
+  (void) gettimeofday (&tv1, NULL);
+
+  struct timespec ts;
+  ts.tv_sec = 1;
+  ts.tv_nsec = 0;
+  TEMP_FAILURE_RETRY (nanosleep (&ts, &ts));
+
+  /* At least one second must have passed.  */
+  struct timeval tv2;
+  (void) gettimeofday (&tv2, NULL);
+
+  tv2.tv_sec -= tv1.tv_sec;
+  tv2.tv_usec -= tv1.tv_usec;
+  if (tv2.tv_usec < 0)
+    --tv2.tv_sec;
+
+  if (tv2.tv_sec < 1)
+    {
+      puts ("nanosleep didn't sleep long enough");
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/posix/tst-nice.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-nice.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-nice.c	(revision 2036)
@@ -0,0 +1,66 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+/* Test that nice() does not incorrectly return 0.  */
+static int
+do_test (void)
+{
+  int ret;
+  const int incr = 10;
+  int old;
+
+  /* Discover current nice value.  */
+  errno = 0;
+  old = nice (0);
+  if (old == -1 && errno != 0)
+    {
+      printf ("break: nice(%d) return: %d, %m\n", 0, old);
+      return 1;
+    }
+
+  /* Nice ourselves up.  */
+  errno = 0;
+  ret = nice (incr);
+  if (ret == -1 && errno != 0)
+    {
+      printf ("break: nice(%d) return: %d, %m\n", incr, ret);
+      return 1;
+    }
+
+  /* Check for return value being zero when it shouldn't.  Cannot simply
+     check for expected value since nice values are capped at 2^n-1.
+     But we assume that we didn't start at the cap and so should have
+     increased some.  */
+  if (ret <= old)
+    {
+      printf ("FAIL: retval (%d) of nice(%d) != %d\n", ret, incr, old + incr);
+      return 1;
+    }
+
+  printf ("PASS: nice(%d) from %d return: %d\n", incr, old, ret);
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/posix/tst-pcre.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-pcre.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-pcre.c	(revision 2036)
@@ -0,0 +1,241 @@
+/* Regular expression tests.
+   Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sys/types.h>
+#include <mcheck.h>
+#include <regex.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main (int argc, char **argv)
+{
+  int ret = 0;
+  char *line = NULL;
+  size_t line_len = 0;
+  ssize_t len;
+  FILE *f;
+  char *pattern = NULL, *string = NULL;
+  regmatch_t rm[20];
+  size_t pattern_alloced = 0, string_alloced = 0;
+  int ignorecase = 0;
+  int pattern_valid = 0, rm_valid = 0;
+  size_t linenum;
+
+  mtrace ();
+
+  if (argc < 2)
+    {
+      fprintf (stderr, "Missing test filename\n");
+      return 1;
+    }
+
+  f = fopen (argv[1], "r");
+  if (f == NULL)
+    {
+      fprintf (stderr, "Couldn't open %s\n", argv[1]);
+      return 1;
+    }
+
+  if ((len = getline (&line, &line_len, f)) <= 0
+      || strncmp (line, "# PCRE", 6) != 0)
+    {
+      fprintf (stderr, "Not a PCRE test file\n");
+      fclose (f);
+      free (line);
+      return 1;
+    }
+
+  linenum = 1;
+
+  while ((len = getline (&line, &line_len, f)) > 0)
+    {
+      char *p;
+      unsigned long num;
+
+      ++linenum;
+
+      if (line[len - 1] == '\n')
+	line[--len] = '\0';
+
+      if (line[0] == '#')
+	continue;
+
+      if (line[0] == '\0')
+	{
+	  /* End of test.  */
+	  ignorecase = 0;
+	  pattern_valid = 0;
+	  rm_valid = 0;
+	  continue;
+	}
+
+      if (line[0] == '/')
+	{
+	  /* Pattern.  */
+	  p = strrchr (line + 1, '/');
+
+	  pattern_valid = 0;
+	  rm_valid = 0;
+	  if (p == NULL)
+	    {
+	      printf ("%zd: Invalid pattern line: %s\n", linenum, line);
+	      ret = 1;
+	      continue;
+	    }
+
+	  if (p[1] == 'i' && p[2] == '\0')
+	    ignorecase = 1;
+	  else if (p[1] != '\0')
+	    {
+	      printf ("%zd: Invalid pattern line: %s\n", linenum, line);
+	      ret = 1;
+	      continue;
+	    }
+
+	  if (pattern_alloced < (size_t) (p - line))
+	    {
+	      pattern = realloc (pattern, p - line);
+	      if (pattern == NULL)
+		{
+		  printf ("%zd: Cannot record pattern: %m\n", linenum);
+		  ret = 1;
+		  break;
+		}
+	      pattern_alloced = p - line;
+	    }
+
+	  memcpy (pattern, line + 1, p - line - 1);
+	  pattern[p - line - 1] = '\0';
+	  pattern_valid = 1;
+	  continue;
+	}
+
+      if (strncmp (line, "    ", 4) == 0)
+	{
+	  regex_t re;
+	  int n;
+    
+	  if (!pattern_valid)
+	    {
+	      printf ("%zd: No previous valid pattern %s\n", linenum, line);
+	      continue;
+	    }
+
+	  if (string_alloced < (size_t) (len - 3))
+	    {
+	      string = realloc (string, len - 3);
+	      if (string == NULL)
+		{
+		  printf ("%zd: Cannot record search string: %m\n", linenum);
+		  ret = 1;
+		  break;
+		}
+	      string_alloced = len - 3;
+	    }
+
+	  memcpy (string, line + 4, len - 3);
+
+	  n = regcomp (&re, pattern,
+		       REG_EXTENDED | (ignorecase ? REG_ICASE : 0));
+	  if (n != 0)
+	    {
+	      char buf[500];
+	      regerror (n, &re, buf, sizeof (buf));
+	      printf ("%zd: regcomp failed for %s: %s\n",
+		      linenum, pattern, buf);
+	      ret = 1;
+	      continue;
+	    }
+
+	  if (regexec (&re, string, 20, rm, 0))
+	    {
+	      rm[0].rm_so = -1;
+	      rm[0].rm_eo = -1;
+	    }
+
+	  regfree (&re);
+	  rm_valid = 1;
+	  continue;
+	}
+
+      if (!rm_valid)
+	{
+	  printf ("%zd: No preceeding pattern or search string\n", linenum);
+	  ret = 1;
+	  continue;
+	}
+
+      if (strcmp (line, "No match") == 0)
+	{
+	  if (rm[0].rm_so != -1 || rm[0].rm_eo != -1)
+	    {
+	      printf ("%zd: /%s/ on %s unexpectedly matched %d..%d\n",
+		      linenum, pattern, string, rm[0].rm_so, rm[0].rm_eo);
+	      ret = 1;
+	    }
+
+	  continue;
+	}
+
+      p = line;
+      if (*p == ' ')
+        ++p;
+
+      num = strtoul (p, &p, 10);
+      if (num >= 20 || *p != ':' || p[1] != ' ')
+	{
+	  printf ("%zd: Invalid line %s\n", linenum, line);
+	  ret = 1;
+	  continue;
+	}
+
+      if (rm[num].rm_so == -1 || rm[num].rm_eo == -1)
+	{
+	  if (strcmp (p + 2, "<unset>") != 0)
+	    {
+	      printf ("%zd: /%s/ on %s unexpectedly failed to match register %ld %d..%d\n",
+		      linenum, pattern, string, num,
+		      rm[num].rm_so, rm[num].rm_eo);
+	      ret = 1;
+	    }
+	  continue;
+	}
+
+      if (rm[num].rm_eo < rm[num].rm_so
+	  || rm[num].rm_eo - rm[num].rm_so != len - (p + 2 - line)
+	  || strncmp (p + 2, string + rm[num].rm_so,
+		      rm[num].rm_eo - rm[num].rm_so) != 0)
+	{
+	  printf ("%zd: /%s/ on %s unexpectedly failed to match %s for register %ld %d..%d\n",
+		  linenum, pattern, string, p + 2, num,
+		  rm[num].rm_so, rm[num].rm_eo);
+	  ret = 1;
+	  continue;
+	}
+    }
+
+  free (pattern);
+  free (string);
+  free (line);
+  fclose (f);
+  return ret;
+}
Index: trunk/src/libctests/glibc/posix/tst-preadwrite.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-preadwrite.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-preadwrite.c	(revision 2036)
@@ -0,0 +1,105 @@
+/* Tests for pread and pwrite.
+   Copyright (C) 1998, 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <error.h>
+#include <string.h>
+#include <unistd.h>
+
+
+/* Allow testing of the 64-bit versions as well.  */
+#ifndef PREAD
+# define PREAD pread
+# define PWRITE pwrite
+#endif
+
+#define STRINGIFY(s) STRINGIFY2 (s)
+#define STRINGIFY2(s) #s
+
+/* Prototype for our test function.  */
+extern void do_prepare (int argc, char *argv[]);
+extern int do_test (int argc, char *argv[]);
+
+/* We have a preparation function.  */
+#define PREPARE do_prepare
+
+/* We might need a bit longer timeout.  */
+#define TIMEOUT 20 /* sec */
+
+/* This defines the `main' function and some more.  */
+#include <test-skeleton.c>
+
+/* These are for the temporary file we generate.  */
+char *name;
+int fd;
+
+void
+do_prepare (int argc, char *argv[])
+{
+   char name_len;
+
+#define FNAME FNAME2(TRUNCATE)
+#define FNAME2(s) "/" STRINGIFY(s) "XXXXXX"
+
+   name_len = strlen (test_dir);
+   name = malloc (name_len + sizeof (FNAME));
+   if (name == NULL)
+     error (EXIT_FAILURE, errno, "cannot allocate file name");
+   mempcpy (mempcpy (name, test_dir, name_len), FNAME, sizeof (FNAME));
+   add_temp_file (name);
+
+   /* Open our test file.   */
+   fd = mkstemp (name);
+   if (fd == -1)
+     error (EXIT_FAILURE, errno, "cannot open test file `%s'", name);
+}
+
+
+int
+do_test (int argc, char *argv[])
+{
+  char buf[1000];
+  char res[1000];
+  int i;
+
+  memset (buf, '\0', sizeof (buf));
+  memset (res, '\xff', sizeof (res));
+
+  if (write (fd, buf, sizeof (buf)) != sizeof (buf))
+    error (EXIT_FAILURE, errno, "during write");
+
+  for (i = 100; i < 200; ++i)
+    buf[i] = i;
+  if (PWRITE (fd, buf + 100, 100, 100) != 100)
+    error (EXIT_FAILURE, errno, "during %s", STRINGIFY (PWRITE));
+
+  for (i = 450; i < 600; ++i)
+    buf[i] = i;
+  if (PWRITE (fd, buf + 450, 150, 450) != 150)
+    error (EXIT_FAILURE, errno, "during %s", STRINGIFY (PWRITE));
+
+  if (PREAD (fd, res, sizeof (buf) - 50, 50) != sizeof (buf) - 50)
+    error (EXIT_FAILURE, errno, "during %s", STRINGIFY (PREAD));
+
+  close (fd);
+  unlink (name);
+
+  return memcmp (buf + 50, res, sizeof (buf) - 50);
+}
Index: trunk/src/libctests/glibc/posix/tst-preadwrite64.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-preadwrite64.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-preadwrite64.c	(revision 2036)
@@ -0,0 +1,24 @@
+/* Tests for pread64 and pwrite64.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define PREAD pread64
+#define PWRITE pwrite64
+
+#include "tst-preadwrite.c"
Index: trunk/src/libctests/glibc/posix/tst-regex.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-regex.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-regex.c	(revision 2036)
@@ -0,0 +1,508 @@
+/* Copyright (C) 2001, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <spawn.h>
+#include "spawn_int.h"
+
+#include <assert.h>
+#include <errno.h>
+#include <error.h>
+#include <fcntl.h>
+#include <getopt.h>
+#include <iconv.h>
+#include <locale.h>
+#include <mcheck.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <regex.h>
+
+
+#if defined _POSIX_CPUTIME && _POSIX_CPUTIME >= 0
+static clockid_t cl;
+static int use_clock;
+#endif
+static iconv_t cd;
+static char *mem;
+static char *umem;
+static size_t memlen;
+static size_t umemlen;
+static int timing;
+
+static int test_expr (const char *expr, int expected, int expectedicase);
+static int run_test (const char *expr, const char *mem, size_t memlen,
+		     int icase, int expected);
+static int run_test_backwards (const char *expr, const char *mem,
+			       size_t memlen, int icase, int expected);
+
+
+int
+main (int argc, char *argv[])
+{
+  const char *file;
+  int fd;
+  struct stat st;
+  int result;
+  char *inmem;
+  char *outmem;
+  size_t inlen;
+  size_t outlen;
+  static const struct option options[] =
+    {
+      {"timing",no_argument,	&timing,	1 },
+      {NULL,	0,		NULL,		0 }
+    };
+
+  mtrace ();
+
+  while (getopt_long (argc, argv, "", options, NULL) >= 0);
+
+  /* Make the content of the file available in memory.  */
+  file = "../ChangeLog.8";
+  fd = open (file, O_RDONLY);
+  if (fd == -1)
+    error (EXIT_FAILURE, errno, "cannot open %s", basename (file));
+
+  if (fstat (fd, &st) != 0)
+    error (EXIT_FAILURE, errno, "cannot stat %s", basename (file));
+  memlen = st.st_size;
+
+  mem = (char *) malloc (memlen + 1);
+  if (mem == NULL)
+    error (EXIT_FAILURE, errno, "while allocating buffer");
+
+  if ((size_t) read (fd, mem, memlen) != memlen)
+    error (EXIT_FAILURE, 0, "cannot read entire file");
+  mem[memlen] = '\0';
+
+  close (fd);
+
+  /* We have to convert a few things from Latin-1 to UTF-8.  */
+  cd = iconv_open ("UTF-8", "ISO-8859-1");
+  if (cd == (iconv_t) -1)
+    error (EXIT_FAILURE, errno, "cannot get conversion descriptor");
+
+  /* For the second test we have to convert the file content to UTF-8.
+     Since the text is mostly ASCII it should be enough to allocate
+     twice as much memory for the UTF-8 text than for the Latin-1
+     text.  */
+  umem = (char *) calloc (2, memlen);
+  if (umem == NULL)
+    error (EXIT_FAILURE, errno, "while allocating buffer");
+
+  inmem = mem;
+  inlen = memlen;
+  outmem = umem;
+  outlen = 2 * memlen - 1;
+  iconv (cd, &inmem, &inlen, &outmem, &outlen);
+  umemlen = outmem - umem;
+  if (inlen != 0)
+    error (EXIT_FAILURE, errno, "cannot convert buffer");
+
+#if defined _POSIX_CPUTIME && _POSIX_CPUTIME >= 0
+# if _POSIX_CPUTIME == 0
+  if (sysconf (_SC_CPUTIME) < 0)
+    use_clock = 0;
+  else
+# endif
+    /* See whether we can use the CPU clock.  */
+    use_clock = clock_getcpuclockid (0, &cl) == 0;
+#endif
+
+#ifdef DEBUG
+  re_set_syntax (RE_DEBUG);
+#endif
+
+  /* Run the actual tests.  All tests are run in a single-byte and a
+     multi-byte locale.  */
+  result = test_expr ("[äáàâéèêíìîñöóòôüúùû]", 2, 2);
+  result |= test_expr ("G.ran", 2, 3);
+  result |= test_expr ("G.\\{1\\}ran", 2, 3);
+  result |= test_expr ("G.*ran", 3, 44);
+  result |= test_expr ("[äáàâ]", 0, 0);
+  result |= test_expr ("Uddeborg", 2, 2);
+  result |= test_expr (".Uddeborg", 2, 2);
+
+  /* Free the resources.  */
+  free (umem);
+  iconv_close (cd);
+  free (mem);
+
+  return result;
+}
+
+
+static int
+test_expr (const char *expr, int expected, int expectedicase)
+{
+  int result;
+  char *inmem;
+  char *outmem;
+  size_t inlen;
+  size_t outlen;
+  char *uexpr;
+
+  /* First test: search with an ISO-8859-1 locale.  */
+  if (setlocale (LC_ALL, "de_DE.ISO-8859-1") == NULL)
+    error (EXIT_FAILURE, 0, "cannot set locale de_DE.ISO-8859-1");
+
+  printf ("\nTest \"%s\" with 8-bit locale\n", expr);
+  result = run_test (expr, mem, memlen, 0, expected);
+  printf ("\nTest \"%s\" with 8-bit locale, case insensitive\n", expr);
+  result |= run_test (expr, mem, memlen, 1, expectedicase);
+  printf ("\nTest \"%s\" backwards with 8-bit locale\n", expr);
+  result |= run_test_backwards (expr, mem, memlen, 0, expected);
+  printf ("\nTest \"%s\" backwards with 8-bit locale, case insensitive\n",
+	  expr);
+  result |= run_test_backwards (expr, mem, memlen, 1, expectedicase);
+
+  /* Second test: search with an UTF-8 locale.  */
+  if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
+    error (EXIT_FAILURE, 0, "cannot set locale de_DE.UTF-8");
+
+  inmem = (char *) expr;
+  inlen = strlen (expr);
+  outlen = inlen * MB_CUR_MAX;
+  outmem = uexpr = alloca (outlen + 1);
+  memset (outmem, '\0', outlen + 1);
+  iconv (cd, &inmem, &inlen, &outmem, &outlen);
+  if (inlen != 0)
+    error (EXIT_FAILURE, errno, "cannot convert expression");
+
+  /* Run the tests.  */
+  printf ("\nTest \"%s\" with multi-byte locale\n", expr);
+  result |= run_test (uexpr, umem, umemlen, 0, expected);
+  printf ("\nTest \"%s\" with multi-byte locale, case insensitive\n", expr);
+  result |= run_test (uexpr, umem, umemlen, 1, expectedicase);
+  printf ("\nTest \"%s\" backwards with multi-byte locale\n", expr);
+  result |= run_test_backwards (uexpr, umem, umemlen, 0, expected);
+  printf ("\nTest \"%s\" backwards with multi-byte locale, case insensitive\n",
+	  expr);
+  result |= run_test_backwards (uexpr, umem, umemlen, 1, expectedicase);
+
+  return result;
+}
+
+
+static int
+run_test (const char *expr, const char *mem, size_t memlen, int icase,
+	  int expected)
+{
+#if defined _POSIX_CPUTIME && _POSIX_CPUTIME >= 0
+  struct timespec start;
+  struct timespec finish;
+#endif
+  regex_t re;
+  int err;
+  size_t offset;
+  int cnt;
+
+#if defined _POSIX_CPUTIME && _POSIX_CPUTIME >= 0
+  if (use_clock && !timing)
+    use_clock = clock_gettime (cl, &start) == 0;
+#endif
+
+  err = regcomp (&re, expr, REG_NEWLINE | (icase ? REG_ICASE : 0));
+  if (err != REG_NOERROR)
+    {
+      char buf[200];
+      regerror (err, &re, buf, sizeof buf);
+      error (EXIT_FAILURE, 0, "cannot compile expression: %s", buf);
+    }
+
+  cnt = 0;
+  offset = 0;
+  assert (mem[memlen] == '\0');
+  while (offset < memlen)
+    {
+      regmatch_t ma[1];
+      const char *sp;
+      const char *ep;
+
+      err = regexec (&re, mem + offset, 1, ma, 0);
+      if (err == REG_NOMATCH)
+	break;
+
+      if (err != REG_NOERROR)
+	{
+	  char buf[200];
+	  regerror (err, &re, buf, sizeof buf);
+	  error (EXIT_FAILURE, 0, "cannot use expression: %s", buf);
+	}
+
+      assert (ma[0].rm_so >= 0);
+      sp = mem + offset + ma[0].rm_so;
+      while (sp > mem && sp[-1] != '\n')
+	--sp;
+
+      ep = mem + offset + ma[0].rm_so;
+      while (*ep != '\0' && *ep != '\n')
+	++ep;
+
+      printf ("match %d: \"%.*s\"\n", ++cnt, (int) (ep - sp), sp);
+
+      offset = ep + 1 - mem;
+    }
+
+  regfree (&re);
+
+#if defined _POSIX_CPUTIME && _POSIX_CPUTIME >= 0
+  if (use_clock && !timing)
+    {
+      use_clock = clock_gettime (cl, &finish) == 0;
+      if (use_clock)
+	{
+	  if (finish.tv_nsec < start.tv_nsec)
+	    {
+	      finish.tv_nsec -= start.tv_nsec - 1000000000;
+	      finish.tv_sec -= 1 + start.tv_sec;
+	    }
+	  else
+	    {
+	      finish.tv_nsec -= start.tv_nsec;
+	      finish.tv_sec -= start.tv_sec;
+	    }
+
+	  printf ("elapsed time: %ld.%09ld sec\n",
+		  finish.tv_sec, finish.tv_nsec);
+	}
+    }
+
+  if (use_clock && timing)
+    {
+      struct timespec mintime = { .tv_sec = 24 * 60 * 60 };
+
+      for (int i = 0; i < 10; ++i)
+	{
+	  offset = 0;
+	  use_clock = clock_gettime (cl, &start) == 0;
+
+	  if (!use_clock)
+	    continue;
+
+	  err = regcomp (&re, expr, REG_NEWLINE | (icase ? REG_ICASE : 0));
+	  if (err != REG_NOERROR)
+	    continue;
+
+	  while (offset < memlen)
+	    {
+	      regmatch_t ma[1];
+
+	      err = regexec (&re, mem + offset, 1, ma, 0);
+	      if (err != REG_NOERROR)
+		break;
+
+	      offset += ma[0].rm_eo;
+	    }
+
+	  regfree (&re);
+
+	  use_clock = clock_gettime (cl, &finish) == 0;
+	  if (use_clock)
+	    {
+	      if (finish.tv_nsec < start.tv_nsec)
+		{
+		  finish.tv_nsec -= start.tv_nsec - 1000000000;
+		  finish.tv_sec -= 1 + start.tv_sec;
+		}
+	      else
+		{
+		  finish.tv_nsec -= start.tv_nsec;
+		  finish.tv_sec -= start.tv_sec;
+		}
+	      if (finish.tv_sec < mintime.tv_sec
+		  || (finish.tv_sec == mintime.tv_sec
+		      && finish.tv_nsec < mintime.tv_nsec))
+		mintime = finish;
+	    }
+	}
+      printf ("elapsed time: %ld.%09ld sec\n",
+	      mintime.tv_sec, mintime.tv_nsec);
+    }
+#endif
+
+  /* Return an error if the number of matches found is not match we
+     expect.  */
+  return cnt != expected;
+}
+
+
+static int
+run_test_backwards (const char *expr, const char *mem, size_t memlen,
+		    int icase, int expected)
+{
+#if defined _POSIX_CPUTIME && _POSIX_CPUTIME >= 0
+  struct timespec start;
+  struct timespec finish;
+#endif
+  struct re_pattern_buffer re;
+  const char *err;
+  size_t offset;
+  int cnt;
+
+#if defined _POSIX_CPUTIME && _POSIX_CPUTIME >= 0
+  if (use_clock && !timing)
+    use_clock = clock_gettime (cl, &start) == 0;
+#endif
+
+  re_set_syntax ((RE_SYNTAX_POSIX_BASIC & ~RE_DOT_NEWLINE)
+		 | RE_HAT_LISTS_NOT_NEWLINE
+		 | (icase ? RE_ICASE : 0));
+
+  memset (&re, 0, sizeof (re));
+  re.fastmap = malloc (256);
+  if (re.fastmap == NULL)
+    error (EXIT_FAILURE, errno, "cannot allocate fastmap");
+
+  err = re_compile_pattern (expr, strlen (expr), &re);
+  if (err != NULL)
+    error (EXIT_FAILURE, 0, "cannot compile expression: %s", err);
+
+  if (re_compile_fastmap (&re))
+    error (EXIT_FAILURE, 0, "couldn't compile fastmap");
+
+  cnt = 0;
+  offset = memlen;
+  assert (mem[memlen] == '\0');
+  while (offset <= memlen)
+    {
+      int start;
+      const char *sp;
+      const char *ep;
+
+      start = re_search (&re, mem, memlen, offset, -offset, NULL);
+      if (start == -1)
+	break;
+
+      if (start == -2)
+	error (EXIT_FAILURE, 0, "internal error in re_search");
+
+      sp = mem + start;
+      while (sp > mem && sp[-1] != '\n')
+	--sp;
+
+      ep = mem + start;
+      while (*ep != '\0' && *ep != '\n')
+	++ep;
+
+      printf ("match %d: \"%.*s\"\n", ++cnt, (int) (ep - sp), sp);
+
+      offset = sp - 1 - mem;
+    }
+
+  regfree (&re);
+
+#if defined _POSIX_CPUTIME && _POSIX_CPUTIME >= 0
+  if (use_clock && !timing)
+    {
+      use_clock = clock_gettime (cl, &finish) == 0;
+      if (use_clock)
+	{
+	  if (finish.tv_nsec < start.tv_nsec)
+	    {
+	      finish.tv_nsec -= start.tv_nsec - 1000000000;
+	      finish.tv_sec -= 1 + start.tv_sec;
+	    }
+	  else
+	    {
+	      finish.tv_nsec -= start.tv_nsec;
+	      finish.tv_sec -= start.tv_sec;
+	    }
+
+	  printf ("elapsed time: %ld.%09ld sec\n",
+		  finish.tv_sec, finish.tv_nsec);
+	}
+    }
+
+  if (use_clock && timing)
+    {
+      struct timespec mintime = { .tv_sec = 24 * 60 * 60 };
+
+      for (int i = 0; i < 10; ++i)
+	{
+	  offset = memlen;
+	  use_clock = clock_gettime (cl, &start) == 0;
+
+	  if (!use_clock)
+	    continue;
+
+	  memset (&re, 0, sizeof (re));
+	  re.fastmap = malloc (256);
+	  if (re.fastmap == NULL)
+	    continue;
+
+	  err = re_compile_pattern (expr, strlen (expr), &re);
+	  if (err != NULL)
+	    continue;
+
+	  if (re_compile_fastmap (&re))
+	    {
+	      regfree (&re);
+	      continue;
+	    }
+
+	  while (offset <= memlen)
+	    {
+	      int start;
+	      const char *sp;
+
+	      start = re_search (&re, mem, memlen, offset, -offset, NULL);
+	      if (start < -1)
+		break;
+
+	      sp = mem + start;
+	      while (sp > mem && sp[-1] != '\n')
+		--sp;
+
+	      offset = sp - 1 - mem;
+	    }
+
+	  regfree (&re);
+
+	  use_clock = clock_gettime (cl, &finish) == 0;
+	  if (use_clock)
+	    {
+	      if (finish.tv_nsec < start.tv_nsec)
+		{
+		  finish.tv_nsec -= start.tv_nsec - 1000000000;
+		  finish.tv_sec -= 1 + start.tv_sec;
+		}
+	      else
+		{
+		  finish.tv_nsec -= start.tv_nsec;
+		  finish.tv_sec -= start.tv_sec;
+		}
+	      if (finish.tv_sec < mintime.tv_sec
+		  || (finish.tv_sec == mintime.tv_sec
+		      && finish.tv_nsec < mintime.tv_nsec))
+		mintime = finish;
+	    }
+	}
+      printf ("elapsed time: %ld.%09ld sec\n",
+	      mintime.tv_sec, mintime.tv_nsec);
+    }
+#endif
+
+  /* Return an error if the number of matches found is not match we
+     expect.  */
+  return cnt != expected;
+}
Index: trunk/src/libctests/glibc/posix/tst-regex2.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-regex2.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-regex2.c	(revision 2036)
@@ -0,0 +1,249 @@
+#include <fcntl.h>
+#include <locale.h>
+#include <regex.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <time.h>
+#include <unistd.h>
+
+#if defined _POSIX_CPUTIME && _POSIX_CPUTIME >= 0
+static clockid_t cl;
+static int use_clock;
+#endif
+
+static int
+do_test (void)
+{
+#if defined _POSIX_CPUTIME && _POSIX_CPUTIME >= 0
+# if _POSIX_CPUTIME == 0
+  if (sysconf (_SC_CPUTIME) < 0)
+    use_clock = 0;
+  else
+# endif
+    /* See whether we can use the CPU clock.  */
+    use_clock = clock_getcpuclockid (0, &cl) == 0;
+#endif
+
+  static const char *pat[] = {
+    ".?.?.?.?.?.?.?Log\\.13",
+    "(.?)(.?)(.?)(.?)(.?)(.?)(.?)Log\\.13",
+    "((((((((((.?))))))))))((((((((((.?))))))))))((((((((((.?))))))))))"
+    "((((((((((.?))))))))))((((((((((.?))))))))))((((((((((.?))))))))))"
+    "((((((((((.?))))))))))Log\\.13" };
+
+  int fd = open ("../ChangeLog.14", O_RDONLY);
+  if (fd < 0)
+    {
+      printf ("Couldn't open ChangeLog.14: %m\n");
+      return 1;
+    }
+
+  struct stat64 st;
+  if (fstat64 (fd, &st) < 0)
+    {
+      printf ("Couldn't fstat ChangeLog.14: %m\n");
+      return 1;
+    }
+
+  char *buf = malloc (st.st_size + 1);
+  if (buf == NULL)
+    {
+      printf ("Couldn't allocate buffer: %m\n");
+      return 1;
+    }
+
+  if (read (fd, buf, st.st_size) != (ssize_t) st.st_size)
+    {
+      puts ("Couldn't read ChangeLog.14");
+      return 1;
+    }
+
+  close (fd);
+  buf[st.st_size] = '\0';
+
+  setlocale (LC_ALL, "de_DE.UTF-8");
+
+  char *string = buf;
+  size_t len = st.st_size;
+
+#ifndef WHOLE_FILE_TIMING
+  /* Don't search the whole file normally, it takes too long.  */
+  if (len > 500000 + 64)
+    {
+      string += 500000;
+      len -= 500000;
+    }
+#endif
+
+  for (int testno = 0; testno < 4; ++testno)
+    for (int i = 0; i < sizeof (pat) / sizeof (pat[0]); ++i)
+      {
+	printf ("test %d pattern %d", testno, i);
+
+	regex_t rbuf;
+	struct re_pattern_buffer rpbuf;
+	int err;
+	if (testno < 2)
+	  {
+	    err = regcomp (&rbuf, pat[i],
+			   REG_EXTENDED | (testno ? REG_NOSUB : 0));
+	    if (err != 0)
+	      {
+		putchar ('\n');
+		char errstr[300];
+		regerror (err, &rbuf, errstr, sizeof (errstr));
+		puts (errstr);
+		return err;
+	      }
+	  }
+	else
+	  {
+	    re_set_syntax (RE_SYNTAX_POSIX_EGREP
+			   | (testno == 3 ? RE_NO_SUB : 0));
+
+	    memset (&rpbuf, 0, sizeof (rpbuf));
+	    const char *s = re_compile_pattern (pat[i], strlen (pat[i]),
+						&rpbuf);
+	    if (s != NULL)
+	      {
+		printf ("\n%s\n", s);
+		return 1;
+	      }
+
+	    /* Just so that this can be tested with earlier glibc as well.  */
+	    if (testno == 3)
+	      rpbuf.no_sub = 1;
+	  }
+
+#if defined _POSIX_CPUTIME && _POSIX_CPUTIME >= 0
+      struct timespec start, stop;
+      if (use_clock)
+	use_clock = clock_gettime (cl, &start) == 0;
+#endif
+
+      if (testno < 2)
+	{
+	  regmatch_t pmatch[71];
+	  err = regexec (&rbuf, string, 71, pmatch, 0);
+	  if (err == REG_NOMATCH)
+	    {
+	      puts ("\nregexec failed");
+	      return 1;
+	    }
+
+	  if (testno == 0)
+	    {
+	      if (pmatch[0].rm_eo != pmatch[0].rm_so + 13
+		  || pmatch[0].rm_eo > len
+		  || pmatch[0].rm_so < len - 100
+		  || strncmp (string + pmatch[0].rm_so,
+			      " ChangeLog.13 for earlier changes",
+			      sizeof " ChangeLog.13 for earlier changes" - 1)
+		     != 0)
+		{
+		  puts ("\nregexec without REG_NOSUB did not find the correct match");
+		  return 1;
+		}
+
+	      if (i > 0)
+		for (int j = 0, l = 1; j < 7; ++j)
+		  for (int k = 0; k < (i == 1 ? 1 : 10); ++k, ++l)
+		    if (pmatch[l].rm_so != pmatch[0].rm_so + j
+			|| pmatch[l].rm_eo != pmatch[l].rm_so + 1)
+		      {
+			printf ("\npmatch[%d] incorrect\n", l);
+			return 1;
+		      }
+	    }
+	}
+      else
+	{
+	  struct re_registers regs;
+
+	  memset (&regs, 0, sizeof (regs));
+	  int match = re_search (&rpbuf, string, len, 0, len,
+				 &regs);
+	  if (match < 0)
+	    {
+	      puts ("\nre_search failed");
+	      return 1;
+	    }
+
+	  if (match + 13 > len
+	      || match < len - 100
+	      || strncmp (string + match,
+			  " ChangeLog.13 for earlier changes",
+			  sizeof " ChangeLog.13 for earlier changes" - 1)
+		  != 0)
+	    {
+	      puts ("\nre_search did not find the correct match");
+	      return 1;
+	    }
+
+	  if (testno == 2)
+	    {
+	      if (regs.num_regs != 2 + (i == 0 ? 0 : i == 1 ? 7 : 70))
+		{
+		  printf ("\nincorrect num_regs %d\n", regs.num_regs);
+		  return 1;
+		}
+
+	      if (regs.start[0] != match || regs.end[0] != match + 13)
+		{
+		  printf ("\nincorrect regs.{start,end}[0] = { %d, %d}\n",
+			  regs.start[0], regs.end[0]);
+		  return 1;
+		}
+
+	      if (regs.start[regs.num_regs - 1] != -1
+		  || regs.end[regs.num_regs - 1] != -1)
+		{
+		  puts ("\nincorrect regs.{start,end}[num_regs - 1]");
+		  return 1;
+		}
+
+	      if (i > 0)
+		for (int j = 0, l = 1; j < 7; ++j)
+		  for (int k = 0; k < (i == 1 ? 1 : 10); ++k, ++l)
+		    if (regs.start[l] != match + j
+			|| regs.end[l] != regs.start[l] + 1)
+		      {
+			printf ("\nregs.{start,end}[%d] incorrect\n", l);
+			return 1;
+		      }
+	    }
+	}
+
+#if defined _POSIX_CPUTIME && _POSIX_CPUTIME >= 0
+      if (use_clock)
+	use_clock = clock_gettime (cl, &stop) == 0;
+      if (use_clock)
+	{
+	  stop.tv_sec -= start.tv_sec;
+	  if (stop.tv_nsec < start.tv_nsec)
+	    {
+	      stop.tv_sec--;
+	      stop.tv_nsec += 1000000000 - start.tv_nsec;
+	    }
+	  else
+	    stop.tv_nsec -= start.tv_nsec;
+	  printf (": %ld.%09lds\n", (long) stop.tv_sec, (long) stop.tv_nsec);
+	}
+      else
+#endif
+	putchar ('\n');
+
+      if (testno < 2)
+	regfree (&rbuf);
+      else
+	regfree (&rpbuf);
+    }
+
+  return 0;
+}
+
+#define TIMEOUT 20
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/posix/tst-regexloc.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-regexloc.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-regexloc.c	(revision 2036)
@@ -0,0 +1,47 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <spawn.h>
+#include "spawn_int.h"
+
+#include <sys/types.h>
+#include <regex.h>
+#include <locale.h>
+#include <stdio.h>
+
+int
+main (int argc, char *argv[])
+{
+  regex_t re;
+  regmatch_t mat[1];
+  int res = 1;
+
+  if (setlocale (LC_ALL, "de_DE.ISO-8859-1") == NULL)
+    puts ("cannot set locale");
+  else if (regcomp (&re, "[a-f]*", 0) != REG_NOERROR)
+    puts ("cannot compile expression \"[a-f]*\"");
+  else if (regexec (&re, "abcdefCDEF", 1, mat, 0) == REG_NOMATCH)
+    puts ("no match");
+  else
+    {
+      printf ("match from %d to %d\n", mat[0].rm_so, mat[0].rm_eo);
+      res = mat[0].rm_so != 0 || mat[0].rm_eo != 6;
+    }
+
+  return res;
+}
Index: trunk/src/libctests/glibc/posix/tst-rxspencer.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-rxspencer.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-rxspencer.c	(revision 2036)
@@ -0,0 +1,562 @@
+/* Regular expression tests.
+   Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sys/types.h>
+#include <mcheck.h>
+#include <regex.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <locale.h>
+#include <getopt.h>
+
+static void
+replace_special_chars (char *str)
+{
+  for (; (str = strpbrk (str, "NTSZ")) != NULL; ++str)
+    switch (*str)
+      {
+      case 'N': *str = '\n'; break;
+      case 'T': *str = '\t'; break;
+      case 'S': *str = ' '; break;
+      case 'Z': *str = '\0'; break;
+      }
+}
+
+static void
+glibc_re_syntax (char *str)
+{
+  char *p, *end = strchr (str, '\0') + 1;
+
+  /* Replace [[:<:]] with \< and [[:>:]] with \>.  */
+  for (p = str; (p = strstr (p, "[[:")) != NULL; )
+    if ((p[3] == '<' || p[3] == '>') && strncmp (p + 4, ":]]", 3) == 0)
+      {
+        p[0] = '\\';
+        p[1] = p[3];
+        memmove (p + 2, p + 7, end - p - 7);
+        end -= 5;
+        p += 2;
+      }
+    else
+      p += 3;
+}
+
+static char *
+mb_replace (char *dst, const char c)
+{
+  switch (c)
+    {
+    /* Replace a with \'a and A with \'A.  */
+    case 'a':
+      *dst++ = '\xc3';
+      *dst++ = '\xa1';
+      break;
+    case 'A':
+      *dst++ = '\xc3';
+      *dst++ = '\x81';
+      break;
+    /* Replace b with \v{c} and B with \v{C}.  */
+    case 'b':
+      *dst++ = '\xc4';
+      *dst++ = '\x8d';
+      break;
+    case 'B':
+      *dst++ = '\xc4';
+      *dst++ = '\x8c';
+      break;
+    /* Replace c with \v{d} and C with \v{D}.  */
+    case 'c':
+      *dst++ = '\xc4';
+      *dst++ = '\x8f';
+      break;
+    case 'C':
+      *dst++ = '\xc4';
+      *dst++ = '\x8e';
+      break;
+    /* Replace d with \'e and D with \'E.  */
+    case 'd':
+      *dst++ = '\xc3';
+      *dst++ = '\xa9';
+      break;
+    case 'D':
+      *dst++ = '\xc3';
+      *dst++ = '\x89';
+      break;
+    }
+  return dst;
+}
+
+static char *
+mb_frob_string (const char *str, const char *letters)
+{
+  char *ret, *dst;
+  const char *src;
+
+  if (str == NULL)
+    return NULL;
+
+  ret = malloc (2 * strlen (str) + 1);
+  if (ret == NULL)
+    return NULL;
+
+  for (src = str, dst = ret; *src; ++src)
+    if (strchr (letters, *src))
+      dst = mb_replace (dst, *src);
+    else
+      *dst++ = *src;
+  *dst = '\0';
+  return ret;
+}
+
+/* Like mb_frob_string, but don't replace anything between
+   [: and :], [. and .] or [= and =] or characters escaped
+   with a backslash.  */
+
+static char *
+mb_frob_pattern (const char *str, const char *letters)
+{
+  char *ret, *dst;
+  const char *src;
+  int in_class = 0, escaped = 0;
+
+  if (str == NULL)
+    return NULL;
+
+  ret = malloc (2 * strlen (str) + 1);
+  if (ret == NULL)
+    return NULL;
+
+  for (src = str, dst = ret; *src; ++src)
+    if (*src == '\\')
+      {
+	escaped ^= 1;
+	*dst++ = *src;
+      }
+    else if (escaped)
+      {
+	escaped = 0;
+	*dst++ = *src;
+	continue;
+      }
+    else if (!in_class && strchr (letters, *src))
+      dst = mb_replace (dst, *src);
+    else
+      {
+	if (!in_class && *src == '[' && strchr (":.=", src[1]))
+	  in_class = 1;
+	else if (in_class && *src == ']' && strchr (":.=", src[-1]))
+	  in_class = 0;
+	*dst++ = *src;
+      }
+  *dst = '\0';
+  return ret;
+}
+
+static int
+check_match (regmatch_t *rm, int idx, const char *string,
+	     const char *match, const char *fail)
+{
+  if (match[0] == '-' && match[1] == '\0')
+    {
+      if (rm[idx].rm_so == -1 && rm[idx].rm_eo == -1)
+	return 0;
+      printf ("%s rm[%d] unexpectedly matched\n", fail, idx);
+      return 1;
+    }
+
+  if (rm[idx].rm_so == -1 || rm[idx].rm_eo == -1)
+    {
+      printf ("%s rm[%d] unexpectedly did not match\n", fail, idx);
+      return 1;
+    }
+
+  if (match[0] == '@')
+    {
+      if (rm[idx].rm_so != rm[idx].rm_eo)
+	{
+	  printf ("%s rm[%d] not empty\n", fail, idx);
+	  return 1;
+	}
+
+      if (strncmp (string + rm[idx].rm_so, match + 1, strlen (match + 1) ?: 1))
+	{
+	  printf ("%s rm[%d] not matching %s\n", fail, idx, match);
+	  return 1;
+	}
+      return 0;
+    }
+
+  if (rm[idx].rm_eo - rm[idx].rm_so != strlen (match)
+      || strncmp (string + rm[idx].rm_so, match,
+		  rm[idx].rm_eo - rm[idx].rm_so))
+    {
+      printf ("%s rm[%d] not matching %s\n", fail, idx, match);
+      return 1;
+    }
+
+  return 0;
+}
+
+static int
+test (const char *pattern, int cflags, const char *string, int eflags,
+      char *expect, char *matches, const char *fail)
+{
+  regex_t re;
+  regmatch_t rm[10];
+  int n, ret = 0;
+
+  n = regcomp (&re, pattern, cflags);
+  if (n != 0)
+    {
+      char buf[500];
+      if (eflags == -1)
+	{
+	  static struct { reg_errcode_t code; const char *name; } codes []
+#define C(x) { REG_##x, #x }
+	    = { C(NOERROR), C(NOMATCH), C(BADPAT), C(ECOLLATE),
+		C(ECTYPE), C(EESCAPE), C(ESUBREG), C(EBRACK),
+		C(EPAREN), C(EBRACE), C(BADBR), C(ERANGE),
+		C(ESPACE), C(BADRPT) };
+
+	  for (int i = 0; i < sizeof (codes) / sizeof (codes[0]); ++i)
+	    if (n == codes[i].code)
+	      {
+		if (strcmp (string, codes[i].name))
+		  {
+		    printf ("%s regcomp returned REG_%s (expected REG_%s)\n",
+			    fail, codes[i].name, string);
+		    return 1;
+		  }
+	        return 0;
+	      }
+
+	  printf ("%s regcomp return value REG_%d\n", fail, n);
+	  return 1;
+	}
+
+      regerror (n, &re, buf, sizeof (buf));
+      printf ("%s regcomp failed: %s\n", fail, buf);
+      return 1;
+    }
+
+  if (eflags == -1)
+    {
+      regfree (&re);
+
+      /* The test case file assumes something only guaranteed by the
+	 rxspencer regex implementation.  Namely that for empty
+	 expressions regcomp() return REG_EMPTY.  This is not the case
+	 for us and so we ignore this error.  */
+      if (strcmp (string, "EMPTY") == 0)
+	return 0;
+
+      printf ("%s regcomp unexpectedly succeeded\n", fail);
+      return 1;
+    }
+
+  if (regexec (&re, string, 10, rm, eflags))
+    {
+      regfree (&re);
+      if (expect == NULL)
+	return 0;
+      printf ("%s regexec failed\n", fail);
+      return 1;
+    }
+
+  regfree (&re);
+
+  if (expect == NULL)
+    {
+      printf ("%s regexec unexpectedly succeeded\n", fail);
+      return 1;
+    }
+
+  if (cflags & REG_NOSUB)
+    return 0;
+
+  ret = check_match (rm, 0, string, expect, fail);
+  if (matches == NULL)
+    return ret;
+
+  for (n = 1; ret == 0 && n < 10; ++n)
+    {
+      char *p = NULL;
+
+      if (matches)
+	{
+	  p = strchr (matches, ',');
+	  if (p != NULL)
+	    *p = '\0';
+	}
+      ret = check_match (rm, n, string, matches ?: "-", fail);
+      if (p)
+	{
+	  *p = ',';
+	  matches = p + 1;
+	}
+      else
+	matches = NULL;
+    }
+
+  return ret;
+}
+
+static int
+mb_test (const char *pattern, int cflags, const char *string, int eflags,
+	 char *expect, const char *matches, const char *letters,
+	 const char *fail)
+{
+  char *pattern_mb = mb_frob_pattern (pattern, letters);
+  const char *string_mb
+    = eflags == -1 ? string : mb_frob_string (string, letters);
+  char *expect_mb = mb_frob_string (expect, letters);
+  char *matches_mb = mb_frob_string (matches, letters);
+  int ret = 0;
+
+  if (!pattern_mb || !string_mb
+      || (expect && !expect_mb) || (matches && !matches_mb))
+    {
+      printf ("%s %m", fail);
+      ret = 1;
+    }
+  else
+    ret = test (pattern_mb, cflags, string_mb, eflags, expect_mb,
+		matches_mb, fail);
+
+  free (matches_mb);
+  free (expect_mb);
+  if (string_mb != string)
+    free ((char *) string_mb);
+  free (pattern_mb);
+  return ret;
+}
+
+static int
+mb_tests (const char *pattern, int cflags, const char *string, int eflags,
+	  char *expect, const char *matches)
+{
+  int ret = 0;
+  int i;
+  char letters[9], fail[20];
+
+  /* The tests aren't supposed to work with xdigit, since a-dA-D are
+     hex digits while \'a \'A \v{c}\v{C}\v{d}\v{D}\'e \'E are not.  */
+  if (strstr (pattern, "[:xdigit:]"))
+    return 0;
+
+  /* XXX: regex ATM handles only single byte equivalence classes.  */
+  if (strstr (pattern, "[[=b=]]"))
+    return 0;
+
+  for (i = 1; i < 16; ++i)
+    {
+      char *p = letters;
+      if (i & 1)
+	{
+	  if (!strchr (pattern, 'a') && !strchr (string, 'a')
+	      && !strchr (pattern, 'A') && !strchr (string, 'A'))
+	    continue;
+	  *p++ = 'a', *p++ = 'A';
+	}
+      if (i & 2)
+	{
+	  if (!strchr (pattern, 'b') && !strchr (string, 'b')
+	      && !strchr (pattern, 'B') && !strchr (string, 'B'))
+	    continue;
+	  *p++ = 'b', *p++ = 'B';
+	}
+      if (i & 4)
+	{
+	  if (!strchr (pattern, 'c') && !strchr (string, 'c')
+	      && !strchr (pattern, 'C') && !strchr (string, 'C'))
+	    continue;
+	  *p++ = 'c', *p++ = 'C';
+	}
+      if (i & 8)
+	{
+	  if (!strchr (pattern, 'd') && !strchr (string, 'd')
+	      && !strchr (pattern, 'D') && !strchr (string, 'D'))
+	    continue;
+	  *p++ = 'd', *p++ = 'D';
+	}
+      *p++ = '\0';
+      sprintf (fail, "UTF-8 %s FAIL", letters);
+      ret |= mb_test (pattern, cflags, string, eflags, expect, matches,
+		      letters, fail);
+    }
+  return ret;
+}
+
+int
+main (int argc, char **argv)
+{
+  int ret = 0;
+  char *line = NULL;
+  size_t line_len = 0;
+  ssize_t len;
+  FILE *f;
+  static int test_utf8 = 0;
+  static const struct option options[] =
+    {
+      {"utf8",	no_argument,	&test_utf8,	1},
+      {NULL,	0,		NULL,		0 }
+    };
+
+  mtrace ();
+
+  while (getopt_long (argc, argv, "", options, NULL) >= 0);
+
+  if (optind + 1 != argc)
+    {
+      fprintf (stderr, "Missing test filename\n");
+      return 1;
+    }
+
+  f = fopen (argv[optind], "r");
+  if (f == NULL)
+    {
+      fprintf (stderr, "Couldn't open %s\n", argv[optind]);
+      return 1;
+    }
+
+  while ((len = getline (&line, &line_len, f)) > 0)
+    {
+      char *pattern, *flagstr, *string, *expect, *matches, *p;
+      int cflags = REG_EXTENDED, eflags = 0, try_bre_ere = 0;
+
+      if (line[len - 1] == '\n')
+        line[len - 1] = '\0';
+
+      /* Skip comments and empty lines.  */
+      if (*line == '#' || *line == '\0')
+	continue;
+
+      puts (line);
+      fflush (stdout);
+
+      pattern = strtok (line, "\t");
+      if (pattern == NULL)
+        continue;
+
+      if (strcmp (pattern, "\"\"") == 0)
+	pattern += 2;
+
+      flagstr = strtok (NULL, "\t");
+      if (flagstr == NULL)
+        continue;
+
+      string = strtok (NULL, "\t");
+      if (string == NULL)
+        continue;
+
+      if (strcmp (string, "\"\"") == 0)
+	string += 2;
+
+      for (p = flagstr; *p; ++p)
+	switch (*p)
+	  {
+	  case '-':
+	    break;
+	  case 'b':
+	    cflags &= ~REG_EXTENDED;
+	    break;
+	  case '&':
+	    try_bre_ere = 1;
+	    break;
+	  case 'C':
+	    eflags = -1;
+	    break;
+	  case 'i':
+	    cflags |= REG_ICASE;
+	    break;
+	  case 's':
+	    cflags |= REG_NOSUB;
+	    break;
+	  case 'n':
+	    cflags |= REG_NEWLINE;
+	    break;
+	  case '^':
+	    eflags |= REG_NOTBOL;
+	    break;
+	  case '$':
+	    eflags |= REG_NOTEOL;
+	    break;
+	  case 'm':
+	  case 'p':
+	  case '#':
+	    /* Not supported.  */
+	    flagstr = NULL;
+	    break;
+	  }
+
+      if (flagstr == NULL)
+	continue;
+
+      replace_special_chars (pattern);
+      glibc_re_syntax (pattern);
+      if (eflags != -1)
+        replace_special_chars (string);
+
+      expect = strtok (NULL, "\t");
+      matches = NULL;
+      if (expect != NULL)
+        {
+	  replace_special_chars (expect);
+	  matches = strtok (NULL, "\t");
+	  if (matches != NULL)
+	    replace_special_chars (matches);
+        }
+
+      if (setlocale (LC_ALL, "C") == NULL)
+	{
+	  puts ("setlocale C failed");
+	  ret = 1;
+	}
+      if (test (pattern, cflags, string, eflags, expect, matches, "FAIL")
+	  || (try_bre_ere
+	      && test (pattern, cflags & ~REG_EXTENDED, string, eflags,
+		       expect, matches, "FAIL")))
+	ret = 1;
+      else if (test_utf8)
+	{
+	  if (setlocale (LC_ALL, "cs_CZ.UTF-8") == NULL)
+	    {
+	      puts ("setlocale cs_CZ.UTF-8 failed");
+	      ret = 1;
+	    }
+	  else if (test (pattern, cflags, string, eflags, expect, matches,
+			 "UTF-8 FAIL")
+		   || (try_bre_ere
+		       && test (pattern, cflags & ~REG_EXTENDED, string,
+				eflags, expect, matches, "UTF-8 FAIL")))
+	    ret = 1;
+	  else if (mb_tests (pattern, cflags, string, eflags, expect, matches)
+		   || (try_bre_ere
+		       && mb_tests (pattern, cflags & ~REG_EXTENDED, string,
+				    eflags, expect, matches)))
+	    ret = 1;
+	}
+    }
+
+  free (line);
+  fclose (f);
+  return ret;
+}
Index: trunk/src/libctests/glibc/posix/tst-spawn.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-spawn.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-spawn.c	(revision 2036)
@@ -0,0 +1,273 @@
+/* Tests for spawn.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <error.h>
+#include <fcntl.h>
+#include <spawn.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <wait.h>
+#include <sys/param.h>
+
+
+/* Nonzero if the program gets called via `exec'.  */
+static int restart;
+
+
+#define CMDLINE_OPTIONS \
+  { "restart", no_argument, &restart, 1 },
+
+/* Prototype for our test function.  */
+extern void do_prepare (int argc, char *argv[]);
+extern int do_test (int argc, char *argv[]);
+
+/* We have a preparation function.  */
+#define PREPARE do_prepare
+
+#include "../test-skeleton.c"
+
+
+/* Name of the temporary files.  */
+static char *name1;
+static char *name2;
+static char *name3;
+
+/* The contents of our files.  */
+static const char fd1string[] = "This file should get closed";
+static const char fd2string[] = "This file should stay opened";
+static const char fd3string[] = "This file will be opened";
+
+
+/* We have a preparation function.  */
+void
+do_prepare (int argc, char *argv[])
+{
+   char name_len;
+
+   name_len = strlen (test_dir);
+   name1 = (char *) malloc (name_len + sizeof ("/spawnXXXXXX"));
+   mempcpy (mempcpy (name1, test_dir, name_len),
+	    "/spawnXXXXXX", sizeof ("/spawnXXXXXX"));
+   add_temp_file (name1);
+
+   name2 = (char *) malloc (name_len + sizeof ("/spawnXXXXXX"));
+   mempcpy (mempcpy (name2, test_dir, name_len),
+	    "/spawnXXXXXX", sizeof ("/spawnXXXXXX"));
+   add_temp_file (name2);
+
+   name3 = (char *) malloc (name_len + sizeof ("/spawnXXXXXX"));
+   mempcpy (mempcpy (name3, test_dir, name_len),
+	    "/spawnXXXXXX", sizeof ("/spawnXXXXXX"));
+   add_temp_file (name3);
+}
+
+
+static int
+handle_restart (const char *fd1s, const char *fd2s, const char *fd3s,
+		const char *fd4s, const char *name)
+{
+  char buf[100];
+  int fd1;
+  int fd2;
+  int fd3;
+  int fd4;
+
+  /* First get the descriptors.  */
+  fd1 = atol (fd1s);
+  fd2 = atol (fd2s);
+  fd3 = atol (fd3s);
+  fd4 = atol (fd4s);
+
+  /* Sanity check.  */
+  if (fd1 == fd2)
+    error (EXIT_FAILURE, 0, "value of fd1 and fd2 is the same");
+  if (fd1 == fd3)
+    error (EXIT_FAILURE, 0, "value of fd1 and fd3 is the same");
+  if (fd1 == fd4)
+    error (EXIT_FAILURE, 0, "value of fd1 and fd4 is the same");
+  if (fd2 == fd3)
+    error (EXIT_FAILURE, 0, "value of fd2 and fd3 is the same");
+  if (fd2 == fd4)
+    error (EXIT_FAILURE, 0, "value of fd2 and fd4 is the same");
+  if (fd3 == fd4)
+    error (EXIT_FAILURE, 0, "value of fd3 and fd4 is the same");
+
+  /* First the easy part: read from the file descriptor which is
+     supposed to be open.  */
+  if (lseek (fd2, 0, SEEK_CUR) != strlen (fd2string))
+    error (EXIT_FAILURE, errno, "file 2 not in right position");
+  /* The duped descriptor must have the same position.  */
+  if (lseek (fd4, 0, SEEK_CUR) != strlen (fd2string))
+    error (EXIT_FAILURE, errno, "file 4 not in right position");
+  if (lseek (fd2, 0, SEEK_SET) != 0)
+    error (EXIT_FAILURE, 0, "cannot reset position in file 2");
+  if (lseek (fd4, 0, SEEK_CUR) != 0)
+    error (EXIT_FAILURE, errno, "file 4 not set back, too");
+  if (read (fd2, buf, sizeof buf) != strlen (fd2string))
+    error (EXIT_FAILURE, 0, "cannot read file 2");
+  if (memcmp (fd2string, buf, strlen (fd2string)) != 0)
+    error (EXIT_FAILURE, 0, "file 2 does not match");
+
+  /* Now read from the third file.  */
+  if (read (fd3, buf, sizeof buf) != strlen (fd3string))
+    error (EXIT_FAILURE, 0, "cannot read file 3");
+  if (memcmp (fd3string, buf, strlen (fd3string)) != 0)
+    error (EXIT_FAILURE, 0, "file 3 does not match");
+  /* Try to write to the file.  This should not be allowed.  */
+  if (write (fd3, "boo!", 4) != -1 || errno != EBADF)
+    error (EXIT_FAILURE, 0, "file 3 is writable");
+
+  /* Now try to read the first file.  First make sure it is not opened.  */
+  if (lseek (fd1, 0, SEEK_CUR) != (off_t) -1 || errno != EBADF)
+    error (EXIT_FAILURE, 0, "file 1 (%d) is not closed", fd1);
+
+  /* Now open the file and read it.  */
+  fd1 = open (name, O_RDONLY);
+  if (fd1 == -1)
+    error (EXIT_FAILURE, errno,
+	   "cannot open first file \"%s\" for verification", name);
+
+  if (read (fd1, buf, sizeof buf) != strlen (fd1string))
+    error (EXIT_FAILURE, errno, "cannot read file 1");
+  if (memcmp (fd1string, buf, strlen (fd1string)) != 0)
+    error (EXIT_FAILURE, 0, "file 1 does not match");
+
+  return 0;
+}
+
+
+int
+do_test (int argc, char *argv[])
+{
+  pid_t pid;
+  int fd1;
+  int fd2;
+  int fd3;
+  int fd4;
+  int status;
+  posix_spawn_file_actions_t actions;
+  char fd1name[18];
+  char fd2name[18];
+  char fd3name[18];
+  char fd4name[18];
+  char *spargv[12];
+
+  /* We must have
+     - four parameters left of called initially
+       + path for ld.so
+       + "--library-path"
+       + the library path
+       + the application name
+     - five parameters left if called through re-execution
+       + file descriptor number which is supposed to be closed
+       + the open file descriptor
+       + the newly opened file descriptor
+       + thhe duped second descriptor
+       + the name of the closed descriptor
+  */
+  if (argc != (restart ? 6 : 5))
+    error (EXIT_FAILURE, 0, "wrong number of arguments (%d)", argc);
+
+  if (restart)
+    return handle_restart (argv[1], argv[2], argv[3], argv[4], argv[5]);
+
+  /* Prepare the test.  We are creating two files: one which file descriptor
+     will be marked with FD_CLOEXEC, another which is not.  */
+
+   /* Open our test files.   */
+   fd1 = mkstemp (name1);
+   if (fd1 == -1)
+     error (EXIT_FAILURE, errno, "cannot open test file `%s'", name1);
+   fd2 = mkstemp (name2);
+   if (fd2 == -1)
+     error (EXIT_FAILURE, errno, "cannot open test file `%s'", name2);
+   fd3 = mkstemp (name3);
+   if (fd3 == -1)
+     error (EXIT_FAILURE, errno, "cannot open test file `%s'", name3);
+
+   /* Write something in the files.  */
+   if (write (fd1, fd1string, strlen (fd1string)) != strlen (fd1string))
+     error (EXIT_FAILURE, errno, "cannot write to first file");
+   if (write (fd2, fd2string, strlen (fd2string)) != strlen (fd2string))
+     error (EXIT_FAILURE, errno, "cannot write to second file");
+   if (write (fd3, fd3string, strlen (fd3string)) != strlen (fd3string))
+     error (EXIT_FAILURE, errno, "cannot write to third file");
+
+   /* Close the third file.  It'll be opened by `spawn'.  */
+   close (fd3);
+
+   /* Tell `spawn' what to do.  */
+   if (posix_spawn_file_actions_init (&actions) != 0)
+     error (EXIT_FAILURE, errno, "posix_spawn_file_actions_init");
+   /* Close `fd1'.  */
+   if (posix_spawn_file_actions_addclose (&actions, fd1) != 0)
+     error (EXIT_FAILURE, errno, "posix_spawn_file_actions_addclose");
+   /* We want to open the third file.  */
+   if (posix_spawn_file_actions_addopen (&actions, fd3, name3,
+					 O_RDONLY, 0666) != 0)
+     error (EXIT_FAILURE, errno, "posix_spawn_file_actions_addopen");
+   /* We dup the second descriptor.  */
+   fd4 = MAX (2, MAX (fd1, MAX (fd2, fd3))) + 1;
+   if (posix_spawn_file_actions_adddup2 (&actions, fd2, fd4) != 0)
+     error (EXIT_FAILURE, errno, "posix_spawn_file_actions_adddup2");
+
+   /* Now spawn the process.  */
+   snprintf (fd1name, sizeof fd1name, "%d", fd1);
+   snprintf (fd2name, sizeof fd2name, "%d", fd2);
+   snprintf (fd3name, sizeof fd3name, "%d", fd3);
+   snprintf (fd4name, sizeof fd4name, "%d", fd4);
+
+   spargv[0] = argv[1];
+   spargv[1] = argv[2];
+   spargv[2] = argv[3];
+   spargv[3] = argv[4];
+   spargv[4] = (char *) "--direct";
+   spargv[5] = (char *) "--restart";
+   spargv[6] = fd1name;
+   spargv[7] = fd2name;
+   spargv[8] = fd3name;
+   spargv[9] = fd4name;
+   spargv[10] = name1;
+   spargv[11] = NULL;
+
+   if (posix_spawn (&pid, argv[1], &actions, NULL, spargv, environ) != 0)
+     error (EXIT_FAILURE, errno, "posix_spawn");
+
+   /* Cleanup.  */
+   if (posix_spawn_file_actions_destroy (&actions) != 0)
+     error (EXIT_FAILURE, errno, "posix_spawn_file_actions_destroy");
+
+  /* Wait for the child.  */
+  if (waitpid (pid, &status, 0) != pid)
+    error (EXIT_FAILURE, errno, "wrong child");
+
+  if (WTERMSIG (status) != 0)
+    error (EXIT_FAILURE, 0, "Child terminated incorrectly");
+  status = WEXITSTATUS (status);
+
+  /* Remove the test files.  */
+  unlink (name1);
+  unlink (name2);
+  unlink (name3);
+
+  return status;
+}
Index: trunk/src/libctests/glibc/posix/tst-sysconf.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-sysconf.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-sysconf.c	(revision 2036)
@@ -0,0 +1,114 @@
+#include <stdbool.h>
+#include <stdio.h>
+#include <unistd.h>
+
+static struct
+{
+  long int _P_val;
+  const char *name;
+  int _SC_val;
+  bool positive;
+  bool posix2;
+} posix_options[] =
+  {
+#define N_(name, pos) { _POSIX_##name, #name, _SC_##name, pos, false }
+#define NP(name) N_ (name, true)
+#define N(name) N_ (name, false)
+#define N2(name) { _POSIX2_##name, #name, _SC_2_##name, false, true }
+    N (ADVISORY_INFO),
+    N (ASYNCHRONOUS_IO),
+    N (BARRIERS),
+    N (CLOCK_SELECTION),
+    N (CPUTIME),
+    N (FSYNC),
+    N (IPV6),
+    NP (JOB_CONTROL),
+    N (MAPPED_FILES),
+    N (MEMLOCK),
+    N (MEMLOCK_RANGE),
+    N (MEMORY_PROTECTION),
+    N (MESSAGE_PASSING),
+    N (MONOTONIC_CLOCK),
+    N (PRIORITIZED_IO),
+    N (PRIORITY_SCHEDULING),
+    N (RAW_SOCKETS),
+    N (READER_WRITER_LOCKS),
+    N (REALTIME_SIGNALS),
+    NP (REGEXP),
+    NP (SAVED_IDS),
+    N (SEMAPHORES),
+    N (SHARED_MEMORY_OBJECTS),
+    NP (SHELL),
+    N (SPAWN),
+    N (SPIN_LOCKS),
+    N (SPORADIC_SERVER),
+    N (SYNCHRONIZED_IO),
+    N (THREAD_ATTR_STACKADDR),
+    N (THREAD_ATTR_STACKSIZE),
+    N (THREAD_CPUTIME),
+    N (THREAD_PRIO_INHERIT),
+    N (THREAD_PRIO_PROTECT),
+    N (THREAD_PRIORITY_SCHEDULING),
+    N (THREAD_PROCESS_SHARED),
+    N (THREAD_SAFE_FUNCTIONS),
+    N (THREAD_SPORADIC_SERVER),
+    N (THREADS),
+    N (TIMEOUTS),
+    N (TIMERS),
+    N (TRACE),
+    N (TRACE_EVENT_FILTER),
+    N (TRACE_INHERIT),
+    N (TRACE_LOG),
+    N (TYPED_MEMORY_OBJECTS),
+    N2 (C_BIND),
+    N2 (C_DEV),
+    N2 (CHAR_TERM)
+  };
+#define nposix_options (sizeof (posix_options) / sizeof (posix_options[0]))
+
+static int
+do_test (void)
+{
+  int result = 0;
+
+  for (int i = 0; i < nposix_options; ++i)
+    {
+      long int scret = sysconf (posix_options[i]._SC_val);
+
+      if (scret == 0)
+	{
+	  printf ("sysconf(_SC_%s%s) returned zero\n",
+		  posix_options[i].posix2 ? "2_" : "", posix_options[i].name);
+	  result = 1;
+	}
+      if (posix_options[i]._P_val != 0 && posix_options[i]._P_val != scret)
+	{
+	  printf ("sysconf(_SC_%s%s) = %ld does not match _POSIX%s_%s = %ld\n",
+		  posix_options[i].posix2 ? "2_" : "", posix_options[i].name,
+		  scret,
+		  posix_options[i].posix2 ? "2" : "", posix_options[i].name,
+		  posix_options[i]._P_val);
+	  result = 1;
+	}
+      else if (posix_options[i].positive && scret < 0)
+	{
+	  printf ("sysconf(_SC_%s%s) must be > 0\n",
+		  posix_options[i].posix2 ? "2_" : "", posix_options[i].name);
+	  result = 1;
+	}
+
+#define STDVER 200112L
+      if (scret > 0 && scret != STDVER && !posix_options[i].positive)
+	{
+	  printf ("sysconf(_SC_%s%s) must be %ldL\n",
+		  posix_options[i].posix2 ? "2_" : "", posix_options[i].name,
+		  STDVER);
+	  result = 1;
+	}
+    }
+
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/posix/tst-truncate.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-truncate.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-truncate.c	(revision 2036)
@@ -0,0 +1,133 @@
+/* Tests for ftruncate and truncate.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <error.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+
+/* Allow testing of the 64-bit versions as well.  */
+#ifndef TRUNCATE
+# define TRUNCATE truncate
+# define FTRUNCATE ftruncate
+#endif
+
+#define STRINGIFY(s) STRINGIFY2 (s)
+#define STRINGIFY2(s) #s
+
+/* Prototype for our test function.  */
+extern void do_prepare (int argc, char *argv[]);
+extern int do_test (int argc, char *argv[]);
+
+/* We have a preparation function.  */
+#define PREPARE do_prepare
+
+/* We might need a bit longer timeout.  */
+#define TIMEOUT 20 /* sec */
+
+/* This defines the `main' function and some more.  */
+#include <test-skeleton.c>
+
+/* These are for the temporary file we generate.  */
+char *name;
+int fd;
+
+void
+do_prepare (int argc, char *argv[])
+{
+   char name_len;
+
+#define FNAME FNAME2(TRUNCATE)
+#define FNAME2(s) "/" STRINGIFY(s) "XXXXXX"
+
+   name_len = strlen (test_dir);
+   name = malloc (name_len + sizeof (FNAME));
+   mempcpy (mempcpy (name, test_dir, name_len), FNAME, sizeof (FNAME));
+   add_temp_file (name);
+
+   /* Open our test file.   */
+   fd = mkstemp (name);
+   if (fd == -1)
+     error (EXIT_FAILURE, errno, "cannot open test file `%s'", name);
+}
+
+
+int
+do_test (int argc, char *argv[])
+{
+  struct stat st;
+  char buf[1000];
+
+  memset (buf, '\0', sizeof (buf));
+
+  if (write (fd, buf, sizeof (buf)) != sizeof (buf))
+    error (EXIT_FAILURE, errno, "during write");
+
+  if (fstat (fd, &st) < 0 || st.st_size != sizeof (buf))
+    error (EXIT_FAILURE, 0, "initial size wrong");
+
+
+  if (FTRUNCATE (fd, 800) < 0)
+    error (EXIT_FAILURE, errno, "size reduction with %s failed",
+	   STRINGIFY (FTRUNCATE));
+
+  if (fstat (fd, &st) < 0 || st.st_size != 800)
+    error (EXIT_FAILURE, 0, "size after reduction with %s incorrect",
+	   STRINGIFY (FTRUNCATE));
+
+  /* The following test covers more than POSIX.  POSIX does not require
+     that ftruncate() can increase the file size.  But we are testing
+     Unix systems.  */
+  if (FTRUNCATE (fd, 1200) < 0)
+    error (EXIT_FAILURE, errno, "size increase with %s failed",
+	   STRINGIFY (FTRUNCATE));
+
+  if (fstat (fd, &st) < 0 || st.st_size != 1200)
+    error (EXIT_FAILURE, 0, "size after increase with %s incorrect",
+	   STRINGIFY (FTRUNCATE));
+
+
+  if (TRUNCATE (name, 800) < 0)
+    error (EXIT_FAILURE, errno, "size reduction with %s failed",
+	   STRINGIFY (TRUNCATE));
+
+  if (fstat (fd, &st) < 0 || st.st_size != 800)
+    error (EXIT_FAILURE, 0, "size after reduction with %s incorrect",
+	   STRINGIFY (TRUNCATE));
+
+  /* The following test covers more than POSIX.  POSIX does not require
+     that truncate() can increase the file size.  But we are testing
+     Unix systems.  */
+  if (TRUNCATE (name, 1200) < 0)
+    error (EXIT_FAILURE, errno, "size increase with %s failed",
+	   STRINGIFY (TRUNCATE));
+
+  if (fstat (fd, &st) < 0 || st.st_size != 1200)
+    error (EXIT_FAILURE, 0, "size after increase with %s incorrect",
+	   STRINGIFY (TRUNCATE));
+
+
+  close (fd);
+  unlink (name);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/posix/tst-truncate64.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-truncate64.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-truncate64.c	(revision 2036)
@@ -0,0 +1,24 @@
+/* Tests for ftruncate64 and truncate64.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define TRUNCATE truncate64
+#define FTRUNCATE ftruncate64
+
+#include "tst-truncate.c"
Index: trunk/src/libctests/glibc/posix/tst-vfork1.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-vfork1.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-vfork1.c	(revision 2036)
@@ -0,0 +1,150 @@
+/* Test for vfork functions.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+/* This test relies on non-POSIX functionality since the child
+   processes call write and getpid.  */
+static int
+do_test (void)
+{
+  int result = 0;
+  int fd[2];
+
+  if (pipe (fd) == -1)
+    {
+      puts ("pipe failed");
+      return 1;
+    }
+
+  /* First vfork() without previous getpid().  */
+  pid_t p1;
+  if ((p1 = vfork ()) == 0)
+    {
+      pid_t p = getpid ();
+      _exit (TEMP_FAILURE_RETRY (write (fd[1], &p, sizeof (p))) != sizeof (p));
+    }
+  else if (p1 == -1)
+    {
+      puts ("1st vfork failed");
+      result = 1;
+    }
+
+  pid_t p2 = 0;
+  if (TEMP_FAILURE_RETRY (read (fd[0], &p2, sizeof (pid_t))) != sizeof (pid_t))
+    {
+      puts ("1st read failed");
+      result = 1;
+    }
+  int r;
+  if (TEMP_FAILURE_RETRY (waitpid (p1, &r, 0)) != p1)
+    {
+      puts ("1st waitpid failed");
+      result = 1;
+    }
+  else if (r != 0)
+    {
+      puts ("write in 1st child failed");
+      result = 1;
+    }
+
+  /* Main process' ID.  */
+  pid_t p0 = getpid ();
+
+  /* vfork() again, but after a getpid() in the main process.  */
+  pid_t p3;
+  if ((p3 = vfork ()) == 0)
+    {
+      pid_t p = getpid ();
+      _exit (TEMP_FAILURE_RETRY (write (fd[1], &p, sizeof (p))) != sizeof (p));
+    }
+  else if (p1 == -1)
+    {
+      puts ("2nd vfork failed");
+      result = 1;
+    }
+
+  pid_t p4;
+  if (TEMP_FAILURE_RETRY (read (fd[0], &p4, sizeof (pid_t))) != sizeof (pid_t))
+    {
+      puts ("2nd read failed");
+      result = 1;
+    }
+  if (TEMP_FAILURE_RETRY (waitpid (p3, &r, 0)) != p3)
+    {
+      puts ("2nd waitpid failed");
+      result = 1;
+    }
+  else if (r != 0)
+    {
+      puts ("write in 2nd child failed");
+      result = 1;
+    }
+
+  /* And getpid in the main process again.  */
+  pid_t p5 = getpid ();
+
+  /* Analysis of the results.  */
+  if (p0 != p5)
+    {
+      printf ("p0(%ld) != p5(%ld)\n", (long int) p0, (long int) p5);
+      result = 1;
+    }
+
+  if (p0 == p1)
+    {
+      printf ("p0(%ld) == p1(%ld)\n", (long int) p0, (long int) p1);
+      result = 1;
+    }
+
+  if (p1 != p2)
+    {
+      printf ("p1(%ld) != p2(%ld)\n", (long int) p1, (long int) p2);
+      result = 1;
+    }
+
+  if (p0 == p3)
+    {
+      printf ("p0(%ld) == p3(%ld)\n", (long int) p0, (long int) p3);
+      result = 1;
+    }
+
+  if (p3 != p4)
+    {
+      printf ("p3(%ld) != p4(%ld)\n", (long int) p3, (long int) p4);
+      result = 1;
+    }
+
+  close (fd[0]);
+  close (fd[1]);
+
+  if (result == 0)
+    puts ("All OK");
+
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/posix/tst-vfork2.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-vfork2.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-vfork2.c	(revision 2036)
@@ -0,0 +1,199 @@
+/* Test for vfork functions.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+int raise_fail;
+
+static void
+alrm (int sig)
+{
+  if (raise (SIGUSR1) < 0)
+    raise_fail = 1;
+}
+
+/* This test relies on non-POSIX functionality since the child
+   processes call write, nanosleep and getpid.  */
+static int
+do_test (void)
+{
+  int result = 0;
+  int fd[2];
+
+  signal (SIGUSR1, SIG_IGN);
+
+  struct sigaction sa;
+  sa.sa_handler = alrm;
+  sigemptyset (&sa.sa_mask);
+  sa.sa_flags = 0;
+  if (sigaction (SIGALRM, &sa, NULL) < 0)
+    {
+      puts ("couldn't set up SIGALRM handler");
+      return 1;
+    }
+
+  if (pipe (fd) == -1)
+    {
+      puts ("pipe failed");
+      return 1;
+    }
+
+  struct itimerval it;
+  it.it_value.tv_sec = 0;
+  it.it_value.tv_usec = 200 * 1000;
+  it.it_interval = it.it_value;
+  if (setitimer (ITIMER_REAL, &it, NULL) < 0)
+    {
+      puts ("couldn't set up timer");
+      return 1;
+    }
+
+  /* First vfork() without previous getpid().  */
+  pid_t p1;
+  if ((p1 = vfork ()) == 0)
+    {
+      pid_t p = getpid ();
+
+      struct timespec ts;
+      ts.tv_sec = 1;
+      ts.tv_nsec = 0;
+      TEMP_FAILURE_RETRY (nanosleep (&ts, &ts));
+      _exit (TEMP_FAILURE_RETRY (write (fd[1], &p, sizeof (p))) != sizeof (p));
+    }
+  else if (p1 == -1)
+    {
+      puts ("1st vfork failed");
+      result = 1;
+    }
+
+  memset (&it, 0, sizeof (it));
+  setitimer (ITIMER_REAL, &it, NULL);
+
+  pid_t p2 = 0;
+  if (TEMP_FAILURE_RETRY (read (fd[0], &p2, sizeof (pid_t))) != sizeof (pid_t))
+    {
+      puts ("1st read failed");
+      result = 1;
+    }
+  int r;
+  if (TEMP_FAILURE_RETRY (waitpid (p1, &r, 0)) != p1)
+    {
+      puts ("1st waitpid failed");
+      result = 1;
+    }
+  else if (r != 0)
+    {
+      puts ("write in 1st child failed");
+      result = 1;
+    }
+
+  /* Main process' ID.  */
+  pid_t p0 = getpid ();
+
+  /* vfork() again, but after a getpid() in the main process.  */
+  pid_t p3;
+  if ((p3 = vfork ()) == 0)
+    {
+      pid_t p = getpid ();
+      _exit (TEMP_FAILURE_RETRY (write (fd[1], &p, sizeof (p))) != sizeof (p));
+    }
+  else if (p1 == -1)
+    {
+      puts ("2nd vfork failed");
+      result = 1;
+    }
+
+  pid_t p4;
+  if (TEMP_FAILURE_RETRY (read (fd[0], &p4, sizeof (pid_t))) != sizeof (pid_t))
+    {
+      puts ("2nd read failed");
+      result = 1;
+    }
+  if (TEMP_FAILURE_RETRY (waitpid (p3, &r, 0)) != p3)
+    {
+      puts ("2nd waitpid failed");
+      result = 1;
+    }
+  else if (r != 0)
+    {
+      puts ("write in 2nd child failed");
+      result = 1;
+    }
+
+  /* And getpid in the main process again.  */
+  pid_t p5 = getpid ();
+
+  /* Analysis of the results.  */
+  if (p0 != p5)
+    {
+      printf ("p0(%ld) != p5(%ld)\n", (long int) p0, (long int) p5);
+      result = 1;
+    }
+
+  if (p0 == p1)
+    {
+      printf ("p0(%ld) == p1(%ld)\n", (long int) p0, (long int) p1);
+      result = 1;
+    }
+
+  if (p1 != p2)
+    {
+      printf ("p1(%ld) != p2(%ld)\n", (long int) p1, (long int) p2);
+      result = 1;
+    }
+
+  if (p0 == p3)
+    {
+      printf ("p0(%ld) == p3(%ld)\n", (long int) p0, (long int) p3);
+      result = 1;
+    }
+
+  if (p3 != p4)
+    {
+      printf ("p3(%ld) != p4(%ld)\n", (long int) p3, (long int) p4);
+      result = 1;
+    }
+
+  close (fd[0]);
+  close (fd[1]);
+
+  if (raise_fail)
+    {
+      puts ("raise failed");
+      result = 1;
+    }
+
+  if (result == 0)
+    puts ("All OK");
+
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/posix/tst-waitid.c
===================================================================
--- trunk/src/libctests/glibc/posix/tst-waitid.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tst-waitid.c	(revision 2036)
@@ -0,0 +1,514 @@
+/* Tests for waitid.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+#include <signal.h>
+
+#define TIMEOUT 15
+
+static void
+test_child (void)
+{
+  /* Wait a second to be sure the parent set his variables before we
+     produce a SIGCHLD.  */
+  sleep (1);
+
+  /* First thing, we stop ourselves.  */
+  raise (SIGSTOP);
+
+  /* Hey, we got continued!  */
+  while (1)
+    pause ();
+}
+
+#ifndef WEXITED
+# define WEXITED	0
+# define WCONTINUED	0
+# define WSTOPPED	WUNTRACED
+#endif
+
+static sig_atomic_t expecting_sigchld, spurious_sigchld;
+#ifdef SA_SIGINFO
+static siginfo_t sigchld_info;
+
+static void
+sigchld (int signo, siginfo_t *info, void *ctx)
+{
+  if (signo != SIGCHLD)
+    {
+      printf ("SIGCHLD handler got signal %d instead!\n", signo);
+      _exit (EXIT_FAILURE);
+    }
+
+  if (! expecting_sigchld)
+    {
+      spurious_sigchld = 1;
+      printf ("spurious SIGCHLD: signo %d code %d status %d pid %d\n",
+	      info->si_signo, info->si_code, info->si_status, info->si_pid);
+    }
+  else
+    {
+      sigchld_info = *info;
+      expecting_sigchld = 0;
+    }
+}
+
+static void
+check_sigchld (const char *phase, int *ok, int code, int status, pid_t pid)
+{
+  if (expecting_sigchld)
+    {
+      printf ("missing SIGCHLD on %s\n", phase);
+      *ok = EXIT_FAILURE;
+      expecting_sigchld = 0;
+      return;
+    }
+
+  if (sigchld_info.si_signo != SIGCHLD)
+    {
+      printf ("SIGCHLD for %s signal %d\n", phase, sigchld_info.si_signo);
+      *ok = EXIT_FAILURE;
+    }
+  if (sigchld_info.si_code != code)
+    {
+      printf ("SIGCHLD for %s code %d\n", phase, sigchld_info.si_code);
+      *ok = EXIT_FAILURE;
+    }
+  if (sigchld_info.si_status != status)
+    {
+      printf ("SIGCHLD for %s status %d\n", phase, sigchld_info.si_status);
+      *ok = EXIT_FAILURE;
+    }
+  if (sigchld_info.si_pid != pid)
+    {
+      printf ("SIGCHLD for %s pid %d\n", phase, sigchld_info.si_pid);
+      *ok = EXIT_FAILURE;
+    }
+}
+# define CHECK_SIGCHLD(phase, code_check, status_check) \
+  check_sigchld ((phase), &status, (code_check), (status_check), pid)
+#else
+# define CHECK_SIGCHLD(phase, code, status) ((void) 0)
+#endif
+
+static int
+do_test (int argc, char *argv[])
+{
+#ifdef SA_SIGINFO
+  struct sigaction sa;
+  sa.sa_flags = SA_SIGINFO|SA_RESTART;
+  sa.sa_sigaction = &sigchld;
+  if (sigemptyset (&sa.sa_mask) < 0 || sigaction (SIGCHLD, &sa, NULL) < 0)
+    {
+      printf ("setting SIGCHLD handler: %m\n");
+      return EXIT_FAILURE;
+    }
+#endif
+
+  expecting_sigchld = 1;
+
+  pid_t pid = fork ();
+  if (pid < 0)
+    {
+      printf ("fork: %m\n");
+      return EXIT_FAILURE;
+    }
+  else if (pid == 0)
+    {
+      test_child ();
+      _exit (127);
+    }
+
+  int status = EXIT_SUCCESS;
+#define RETURN(ok) \
+    do { if (status == EXIT_SUCCESS) status = (ok); goto out; } while (0)
+
+  /* Give the child a chance to stop.  */
+  sleep (3);
+
+  CHECK_SIGCHLD ("stopped", CLD_STOPPED, SIGSTOP);
+
+  /* Now try a wait that should not succeed.  */
+  siginfo_t info;
+  info.si_signo = 0;		/* A successful call sets it to SIGCHLD.  */
+  int fail = waitid (P_PID, pid, &info, WEXITED|WCONTINUED|WNOHANG);
+  switch (fail)
+    {
+    default:
+      printf ("waitid returned bogus value %d\n", fail);
+      RETURN (EXIT_FAILURE);
+    case -1:
+      printf ("waitid WNOHANG on stopped: %m\n");
+      RETURN (errno == ENOTSUP ? EXIT_SUCCESS : EXIT_FAILURE);
+    case 0:
+      if (info.si_signo == 0)
+	break;
+      if (info.si_signo == SIGCHLD)
+	printf ("waitid WNOHANG on stopped status %d\n", info.si_status);
+      else
+	printf ("waitid WNOHANG on stopped signal %d\n", info.si_signo);
+      RETURN (EXIT_FAILURE);
+    }
+
+  /* Next the wait that should succeed right away.  */
+  info.si_signo = 0;		/* A successful call sets it to SIGCHLD.  */
+  info.si_pid = -1;
+  info.si_status = -1;
+  fail = waitid (P_PID, pid, &info, WSTOPPED|WNOHANG);
+  switch (fail)
+    {
+    default:
+      printf ("waitid WSTOPPED|WNOHANG returned bogus value %d\n", fail);
+      RETURN (EXIT_FAILURE);
+    case -1:
+      printf ("waitid WSTOPPED|WNOHANG on stopped: %m\n");
+      RETURN (errno == ENOTSUP ? EXIT_SUCCESS : EXIT_FAILURE);
+    case 0:
+      if (info.si_signo != SIGCHLD)
+	{
+	  printf ("waitid WSTOPPED|WNOHANG on stopped signal %d\n",
+		  info.si_signo);
+	  RETURN (EXIT_FAILURE);
+	}
+      if (info.si_code != CLD_STOPPED)
+	{
+	  printf ("waitid WSTOPPED|WNOHANG on stopped code %d\n",
+		  info.si_code);
+	  RETURN (EXIT_FAILURE);
+	}
+      if (info.si_status != SIGSTOP)
+	{
+	  printf ("waitid WSTOPPED|WNOHANG on stopped status %d\n",
+		  info.si_status);
+	  RETURN (EXIT_FAILURE);
+	}
+      if (info.si_pid != pid)
+	{
+	  printf ("waitid WSTOPPED|WNOHANG on stopped pid %d != %d\n",
+		  info.si_pid, pid);
+	  RETURN (EXIT_FAILURE);
+	}
+    }
+
+  expecting_sigchld = WCONTINUED != 0;
+
+  if (kill (pid, SIGCONT) != 0)
+    {
+      printf ("kill (%d, SIGCONT): %m\n", pid);
+      RETURN (EXIT_FAILURE);
+    }
+
+  /* Wait for the child to have continued.  */
+  sleep (2);
+
+#if WCONTINUED != 0
+  if (expecting_sigchld)
+    {
+      printf ("no SIGCHLD seen for SIGCONT (optional)\n");
+      expecting_sigchld = 0;
+    }
+  else
+    CHECK_SIGCHLD ("continued", CLD_CONTINUED, SIGCONT);
+
+  info.si_signo = 0;		/* A successful call sets it to SIGCHLD.  */
+  info.si_pid = -1;
+  info.si_status = -1;
+  fail = waitid (P_PID, pid, &info, WCONTINUED|WNOWAIT);
+  switch (fail)
+    {
+    default:
+      printf ("waitid WCONTINUED|WNOWAIT returned bogus value %d\n", fail);
+      RETURN (EXIT_FAILURE);
+    case -1:
+      printf ("waitid WCONTINUED|WNOWAIT on continued: %m\n");
+      RETURN (errno == ENOTSUP ? EXIT_SUCCESS : EXIT_FAILURE);
+    case 0:
+      if (info.si_signo != SIGCHLD)
+	{
+	  printf ("waitid WCONTINUED|WNOWAIT on continued signal %d\n",
+		  info.si_signo);
+	  RETURN (EXIT_FAILURE);
+	}
+      if (info.si_code != CLD_CONTINUED)
+	{
+	  printf ("waitid WCONTINUED|WNOWAIT on continued code %d\n",
+		  info.si_code);
+	  RETURN (EXIT_FAILURE);
+	}
+      if (info.si_status != SIGCONT)
+	{
+	  printf ("waitid WCONTINUED|WNOWAIT on continued status %d\n",
+		  info.si_status);
+	  RETURN (EXIT_FAILURE);
+	}
+      if (info.si_pid != pid)
+	{
+	  printf ("waitid WCONTINUED|WNOWAIT on continued pid %d != %d\n",
+		  info.si_pid, pid);
+	  RETURN (EXIT_FAILURE);
+	}
+    }
+
+  /* That should leave the CLD_CONTINUED state waiting to be seen again.  */
+  info.si_signo = 0;		/* A successful call sets it to SIGCHLD.  */
+  info.si_pid = -1;
+  info.si_status = -1;
+  fail = waitid (P_PID, pid, &info, WCONTINUED);
+  switch (fail)
+    {
+    default:
+      printf ("waitid WCONTINUED returned bogus value %d\n", fail);
+      RETURN (EXIT_FAILURE);
+    case -1:
+      printf ("waitid WCONTINUED on continued: %m\n");
+      RETURN (errno == ENOTSUP ? EXIT_SUCCESS : EXIT_FAILURE);
+    case 0:
+      if (info.si_signo != SIGCHLD)
+	{
+	  printf ("waitid WCONTINUED on continued signal %d\n", info.si_signo);
+	  RETURN (EXIT_FAILURE);
+	}
+      if (info.si_code != CLD_CONTINUED)
+	{
+	  printf ("waitid WCONTINUED on continued code %d\n", info.si_code);
+	  RETURN (EXIT_FAILURE);
+	}
+      if (info.si_status != SIGCONT)
+	{
+	  printf ("waitid WCONTINUED on continued status %d\n",
+		  info.si_status);
+	  RETURN (EXIT_FAILURE);
+	}
+      if (info.si_pid != pid)
+	{
+	  printf ("waitid WCONTINUED on continued pid %d != %d\n",
+		  info.si_pid, pid);
+	  RETURN (EXIT_FAILURE);
+	}
+    }
+
+  /* Now try a wait that should not succeed.  */
+  info.si_signo = 0;		/* A successful call sets it to SIGCHLD.  */
+  fail = waitid (P_PID, pid, &info, WCONTINUED|WNOHANG);
+  switch (fail)
+    {
+    default:
+      printf ("waitid returned bogus value %d\n", fail);
+      RETURN (EXIT_FAILURE);
+    case -1:
+      printf ("waitid WCONTINUED|WNOHANG on waited continued: %m\n");
+      RETURN (errno == ENOTSUP ? EXIT_SUCCESS : EXIT_FAILURE);
+    case 0:
+      if (info.si_signo == 0)
+	break;
+      if (info.si_signo == SIGCHLD)
+	printf ("waitid WCONTINUED|WNOHANG on waited continued status %d\n",
+		info.si_status);
+      else
+	printf ("waitid WCONTINUED|WNOHANG on waited continued signal %d\n",
+		info.si_signo);
+      RETURN (EXIT_FAILURE);
+    }
+
+  /* Now stop him again and test waitpid with WCONTINUED.  */
+  expecting_sigchld = 1;
+  if (kill (pid, SIGSTOP) != 0)
+    {
+      printf ("kill (%d, SIGSTOP): %m\n", pid);
+      RETURN (EXIT_FAILURE);
+    }
+  pid_t wpid = waitpid (pid, &fail, WUNTRACED);
+  if (wpid < 0)
+    {
+      printf ("waitpid WUNTRACED on stopped: %m\n");
+      RETURN (EXIT_FAILURE);
+    }
+  else if (wpid != pid)
+    {
+      printf ("waitpid WUNTRACED on stopped returned %d != %d (status %x)\n",
+	      wpid, pid, fail);
+      RETURN (EXIT_FAILURE);
+    }
+  else if (!WIFSTOPPED (fail) || WIFSIGNALED (fail) || WIFEXITED (fail)
+	   || WIFCONTINUED (fail) || WSTOPSIG (fail) != SIGSTOP)
+    {
+      printf ("waitpid WUNTRACED on stopped: status %x\n", fail);
+      RETURN (EXIT_FAILURE);
+    }
+  CHECK_SIGCHLD ("stopped", CLD_STOPPED, SIGSTOP);
+
+  expecting_sigchld = 1;
+  if (kill (pid, SIGCONT) != 0)
+    {
+      printf ("kill (%d, SIGCONT): %m\n", pid);
+      RETURN (EXIT_FAILURE);
+    }
+
+  /* Wait for the child to have continued.  */
+  sleep (2);
+
+  if (expecting_sigchld)
+    {
+      printf ("no SIGCHLD seen for SIGCONT (optional)\n");
+      expecting_sigchld = 0;
+    }
+  else
+    CHECK_SIGCHLD ("continued", CLD_CONTINUED, SIGCONT);
+
+  wpid = waitpid (pid, &fail, WCONTINUED);
+  if (wpid < 0)
+    {
+      if (errno == EINVAL)
+	printf ("waitpid does not support WCONTINUED\n");
+      else
+	{
+	  printf ("waitpid WCONTINUED on continued: %m\n");
+	  RETURN (EXIT_FAILURE);
+	}
+    }
+  else if (wpid != pid)
+    {
+      printf ("\
+waitpid WCONTINUED on continued returned %d != %d (status %x)\n",
+	     wpid, pid, fail);
+      RETURN (EXIT_FAILURE);
+    }
+  else if (WIFSTOPPED (fail) || WIFSIGNALED (fail) || WIFEXITED (fail)
+	   || !WIFCONTINUED (fail))
+    {
+      printf ("waitpid WCONTINUED on continued: status %x\n", fail);
+      RETURN (EXIT_FAILURE);
+    }
+#endif
+
+  expecting_sigchld = 1;
+
+  /* Die, child, die!  */
+  if (kill (pid, SIGKILL) != 0)
+    {
+      printf ("kill (%d, SIGKILL): %m\n", pid);
+      RETURN (EXIT_FAILURE);
+    }
+
+#ifdef WNOWAIT
+  info.si_signo = 0;		/* A successful call sets it to SIGCHLD.  */
+  info.si_pid = -1;
+  info.si_status = -1;
+  fail = waitid (P_PID, pid, &info, WEXITED|WNOWAIT);
+  switch (fail)
+    {
+    default:
+      printf ("waitid WNOWAIT returned bogus value %d\n", fail);
+      RETURN (EXIT_FAILURE);
+    case -1:
+      printf ("waitid WNOWAIT on killed: %m\n");
+      RETURN (errno == ENOTSUP ? EXIT_SUCCESS : EXIT_FAILURE);
+    case 0:
+      if (info.si_signo != SIGCHLD)
+	{
+	  printf ("waitid WNOWAIT on killed signal %d\n", info.si_signo);
+	  RETURN (EXIT_FAILURE);
+	}
+      if (info.si_code != CLD_KILLED)
+	{
+	  printf ("waitid WNOWAIT on killed code %d\n", info.si_code);
+	  RETURN (EXIT_FAILURE);
+	}
+      if (info.si_status != SIGKILL)
+	{
+	  printf ("waitid WNOWAIT on killed status %d\n", info.si_status);
+	  RETURN (EXIT_FAILURE);
+	}
+      if (info.si_pid != pid)
+	{
+	  printf ("waitid WNOWAIT on killed pid %d != %d\n", info.si_pid, pid);
+	  RETURN (EXIT_FAILURE);
+	}
+    }
+#else
+  /* Allow enough time to be sure the child died; we didn't synchronize.  */
+  sleep (2);
+#endif
+
+  CHECK_SIGCHLD ("killed", CLD_KILLED, SIGKILL);
+
+  info.si_signo = 0;		/* A successful call sets it to SIGCHLD.  */
+  info.si_pid = -1;
+  info.si_status = -1;
+  fail = waitid (P_PID, pid, &info, WEXITED|WNOHANG);
+  switch (fail)
+    {
+    default:
+      printf ("waitid WNOHANG returned bogus value %d\n", fail);
+      RETURN (EXIT_FAILURE);
+    case -1:
+      printf ("waitid WNOHANG on killed: %m\n");
+      RETURN (EXIT_FAILURE);
+    case 0:
+      if (info.si_signo != SIGCHLD)
+	{
+	  printf ("waitid WNOHANG on killed signal %d\n", info.si_signo);
+	  RETURN (EXIT_FAILURE);
+	}
+      if (info.si_code != CLD_KILLED)
+	{
+	  printf ("waitid WNOHANG on killed code %d\n", info.si_code);
+	  RETURN (EXIT_FAILURE);
+	}
+      if (info.si_status != SIGKILL)
+	{
+	  printf ("waitid WNOHANG on killed status %d\n", info.si_status);
+	  RETURN (EXIT_FAILURE);
+	}
+      if (info.si_pid != pid)
+	{
+	  printf ("waitid WNOHANG on killed pid %d != %d\n", info.si_pid, pid);
+	  RETURN (EXIT_FAILURE);
+	}
+    }
+
+  fail = waitid (P_PID, pid, &info, WEXITED);
+  if (fail == -1)
+    {
+      if (errno != ECHILD)
+	{
+	  printf ("waitid WEXITED on killed: %m\n");
+	  RETURN (EXIT_FAILURE);
+	}
+    }
+  else
+    {
+      printf ("waitid WEXITED returned bogus value %d\n", fail);
+      RETURN (EXIT_FAILURE);
+    }
+
+#undef RETURN
+ out:
+  if (spurious_sigchld)
+    status = EXIT_FAILURE;
+  signal (SIGCHLD, SIG_IGN);
+  kill (pid, SIGKILL);		/* Make sure it's dead if we bailed early.  */
+  return status;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/posix/tstgetopt.c
===================================================================
--- trunk/src/libctests/glibc/posix/tstgetopt.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/tstgetopt.c	(revision 2036)
@@ -0,0 +1,76 @@
+#include <getopt.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+int
+main (int argc, char **argv)
+{
+  static const struct option options[] =
+    {
+      {"required", required_argument, NULL, 'r'},
+      {"optional", optional_argument, NULL, 'o'},
+      {"none",     no_argument,       NULL, 'n'},
+      {"color",    no_argument,       NULL, 'C'},
+      {"colour",   no_argument,       NULL, 'C'},
+      {NULL,       0,                 NULL, 0 }
+    };
+
+  int aflag = 0;
+  int bflag = 0;
+  char *cvalue = NULL;
+  int Cflag = 0;
+  int nflag = 0;
+  int index;
+  int c;
+  int result = 0;
+
+  while ((c = getopt_long (argc, argv, "abc:", options, NULL)) >= 0)
+    switch (c)
+      {
+      case 'a':
+	aflag = 1;
+	break;
+      case 'b':
+	bflag = 1;
+	break;
+      case 'c':
+	cvalue = optarg;
+	break;
+      case 'C':
+	++Cflag;
+	break;
+      case '?':
+	fputs ("Unknown option.\n", stderr);
+	return 1;
+      default:
+	fprintf (stderr, "This should never happen!\n");
+	return 1;
+
+      case 'r':
+	printf ("--required %s\n", optarg);
+	result |= strcmp (optarg, "foobar") != 0;
+	break;
+      case 'o':
+	printf ("--optional %s\n", optarg);
+	result |= optarg == NULL || strcmp (optarg, "bazbug") != 0;
+	break;
+      case 'n':
+	puts ("--none");
+	nflag = 1;
+	break;
+      }
+
+  printf ("aflag = %d, bflag = %d, cvalue = %s, Cflags = %d, nflag = %d\n",
+	  aflag, bflag, cvalue, Cflag, nflag);
+
+  result |= (aflag != 1 || bflag != 1 || cvalue == NULL
+	     || strcmp (cvalue, "foobar") != 0 || Cflag != 3 || nflag != 1);
+
+  for (index = optind; index < argc; index++)
+    printf ("Non-option argument %s\n", argv[index]);
+
+  result |= optind + 1 != argc || strcmp (argv[optind], "random") != 0;
+
+  return result;
+}
Index: trunk/src/libctests/glibc/posix/wordexp-test.c
===================================================================
--- trunk/src/libctests/glibc/posix/wordexp-test.c	(revision 2036)
+++ trunk/src/libctests/glibc/posix/wordexp-test.c	(revision 2036)
@@ -0,0 +1,438 @@
+/* Copyright (C) 1997, 1998, 2000, 2001, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <pwd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wordexp.h>
+
+#define IFS " \n\t"
+
+struct test_case_struct
+{
+  int retval;
+  const char *env;
+  const char *words;
+  int flags;
+  size_t wordc;
+  const char *wordv[10];
+  const char *ifs;
+} test_case[] =
+  {
+    /* Simple word- and field-splitting */
+    { 0, NULL, "one", 0, 1, { "one", }, IFS },
+    { 0, NULL, "one two", 0, 2, { "one", "two", }, IFS },
+    { 0, NULL, "one two three", 0, 3, { "one", "two", "three", }, IFS },
+    { 0, NULL, " \tfoo\t\tbar ", 0, 2, { "foo", "bar", }, IFS },
+    { 0, NULL, "red , white blue", 0, 4, { "red", ",", "white", "blue", }, " ," },
+    { 0, NULL, "one two three", 0, 3, { "one", "two", "three", }, "" },
+    { 0, NULL, "one \"two three\"", 0, 2, { "one", "two three", }, IFS },
+    { 0, NULL, "one \"two three\"", 0, 2, { "one", "two three", }, "" },
+    { 0, "two three", "one \"$var\"", 0, 2, { "one", "two three", }, IFS },
+    { 0, "two three", "one $var", 0, 3, { "one", "two", "three", }, IFS },
+    { 0, "two three", "one \"$var\"", 0, 2, { "one", "two three", }, "" },
+    { 0, "two three", "one $var", 0, 2, { "one", "two three", }, "" },
+
+    /* The non-whitespace IFS char at the end delimits the second field
+     * but does NOT start a new field. */
+    { 0, ":abc:", "$var", 0, 2, { "", "abc", }, ":" },
+
+    { 0, NULL, "$(echo :abc:)", 0, 2, { "", "abc", }, ":" },
+    { 0, NULL, "$(echo :abc:\\ )", 0, 2, { "", "abc", }, ": " },
+    { 0, NULL, "$(echo :abc\\ )", 0, 2, { "", "abc", }, ": " },
+    { 0, ":abc:", "$(echo $var)", 0, 2, { "", "abc", }, ":" },
+    { 0, NULL, ":abc:", 0, 1, { ":abc:", }, ":" },
+    { 0, NULL, "$(echo :abc:)def", 0, 3, { "", "abc", "def", },
+      ":" },
+    { 0, NULL, "$(echo abc:de)f", 0, 2, { "abc", "def", }, ":" },
+    { 0, NULL, "$(echo abc:de)f:ghi", 0, 2, { "abc", "def:ghi", },
+      ":" },
+    { 0, NULL, "abc:d$(echo ef:ghi)", 0, 2, { "abc:def", "ghi", },
+      ":" },
+    { 0, "abc:", "$var$(echo def:ghi)", 0, 3, { "abc", "def",
+							  "ghi", }, ":" },
+    { 0, "abc:d", "$var$(echo ef:ghi)", 0, 3, { "abc", "def",
+							  "ghi", }, ":" },
+    { 0, "def:ghi", "$(echo abc:)$var", 0, 3, { "abc", "def",
+							  "ghi", }, ":" },
+    { 0, "ef:ghi", "$(echo abc:d)$var", 0, 3, { "abc", "def",
+							  "ghi", }, ":" },
+
+    /* Simple parameter expansion */
+    { 0, "foo", "${var}", 0, 1, { "foo", }, IFS },
+    { 0, "foo", "$var", 0, 1, { "foo", }, IFS },
+    { 0, "foo", "\\\"$var\\\"", 0, 1, { "\"foo\"", }, IFS },
+    { 0, "foo", "%$var%", 0, 1, { "%foo%", }, IFS },
+    { 0, "foo", "-$var-", 0, 1, { "-foo-", }, IFS },
+
+    /* Simple quote removal */
+    { 0, NULL, "\"quoted\"", 0, 1, { "quoted", }, IFS },
+    { 0, "foo", "\"$var\"\"$var\"", 0, 1, { "foofoo", }, IFS },
+    { 0, NULL, "'singly-quoted'", 0, 1, { "singly-quoted", }, IFS },
+    { 0, NULL, "contin\\\nuation", 0, 1, { "continuation", }, IFS },
+    { 0, NULL, "explicit ''", 0, 2, { "explicit", "", }, IFS },
+    { 0, NULL, "explicit \"\"", 0, 2, { "explicit", "", }, IFS },
+    { 0, NULL, "explicit ``", 0, 1, { "explicit", }, IFS },
+
+    /* Simple command substitution */
+    { 0, NULL, "$(echo hello)", 0, 1, { "hello", }, IFS },
+    { 0, NULL, "$( (echo hello) )", 0, 1, { "hello", }, IFS },
+    { 0, NULL, "$((echo hello);(echo there))", 0, 2, { "hello", "there", }, IFS },
+    { 0, NULL, "`echo one two`", 0, 2, { "one", "two", }, IFS },
+    { 0, NULL, "$(echo ')')", 0, 1, { ")" }, IFS },
+    { 0, NULL, "$(echo hello; echo)", 0, 1, { "hello", }, IFS },
+    { 0, NULL, "a$(echo b)c", 0, 1, { "abc", }, IFS },
+
+    /* Simple arithmetic expansion */
+    { 0, NULL, "$((1 + 1))", 0, 1, { "2", }, IFS },
+    { 0, NULL, "$((2-3))", 0, 1, { "-1", }, IFS },
+    { 0, NULL, "$((-1))", 0, 1, { "-1", }, IFS },
+    { 0, NULL, "$[50+20]", 0, 1, { "70", }, IFS },
+    { 0, NULL, "$(((2+3)*(4+5)))", 0, 1, { "45", }, IFS },
+    { 0, NULL, "$((010))", 0, 1, { "8" }, IFS },
+    { 0, NULL, "$((0x10))", 0, 1, { "16" }, IFS },
+    { 0, NULL, "$((010+0x10))", 0, 1, { "24" }, IFS },
+    { 0, NULL, "$((-010+0x10))", 0, 1, { "8" }, IFS },
+    { 0, NULL, "$((-0x10+010))", 0, 1, { "-8" }, IFS },
+
+    /* Advanced parameter expansion */
+    { 0, NULL, "${var:-bar}", 0, 1, { "bar", }, IFS },
+    { 0, NULL, "${var-bar}", 0, 1, { "bar", }, IFS },
+    { 0, "", "${var:-bar}", 0, 1, { "bar", }, IFS },
+    { 0, "foo", "${var:-bar}", 0, 1, { "foo", }, IFS },
+    { 0, "", "${var-bar}", 0, 0, { NULL, }, IFS },
+    { 0, NULL, "${var:=bar}", 0, 1, { "bar", }, IFS },
+    { 0, NULL, "${var=bar}", 0, 1, { "bar", }, IFS },
+    { 0, "", "${var:=bar}", 0, 1, { "bar", }, IFS },
+    { 0, "foo", "${var:=bar}", 0, 1, { "foo", }, IFS },
+    { 0, "", "${var=bar}", 0, 0, { NULL, }, IFS },
+    { 0, "foo", "${var:?bar}", 0, 1, { "foo", }, IFS },
+    { 0, NULL, "${var:+bar}", 0, 0, { NULL, }, IFS },
+    { 0, NULL, "${var+bar}", 0, 0, { NULL, }, IFS },
+    { 0, "", "${var:+bar}", 0, 0, { NULL, }, IFS },
+    { 0, "foo", "${var:+bar}", 0, 1, { "bar", }, IFS },
+    { 0, "", "${var+bar}", 0, 1, { "bar", }, IFS },
+    { 0, "12345", "${#var}", 0, 1, { "5", }, IFS },
+    { 0, NULL, "${var:-'}'}", 0, 1, { "}", }, IFS },
+    { 0, NULL, "${var-}", 0, 0, { NULL }, IFS },
+
+    { 0, "pizza", "${var#${var}}", 0, 0, { NULL }, IFS },
+    { 0, "pepperoni", "${var%$(echo oni)}", 0, 1, { "pepper" }, IFS },
+    { 0, "6pack", "${var#$((6))}", 0, 1, { "pack" }, IFS },
+    { 0, "b*witched", "${var##b*}", 0, 0, { NULL }, IFS },
+    { 0, "b*witched", "${var##\"b*\"}", 0, 1, { "witched" }, IFS },
+    { 0, "banana", "${var%na*}", 0, 1, { "bana", }, IFS },
+    { 0, "banana", "${var%%na*}", 0, 1, { "ba", }, IFS },
+    { 0, "borabora-island", "${var#*bora}", 0, 1, { "bora-island", }, IFS },
+    { 0, "borabora-island", "${var##*bora}", 0, 1, { "-island", }, IFS },
+    { 0, "coconut", "${var##\\*co}", 0, 1, { "coconut", }, IFS },
+    { 0, "100%", "${var%0%}", 0, 1, { "10" }, IFS },
+
+    /* Pathname expansion */
+    { 0, NULL, "???", 0, 2, { "one", "two", }, IFS },
+    { 0, NULL, "[ot]??", 0, 2, { "one", "two", }, IFS },
+    { 0, NULL, "t*", 0, 2, { "three", "two", }, IFS },
+    { 0, NULL, "\"t\"*", 0, 2, { "three", "two", }, IFS },
+
+    /* Nested constructs */
+    { 0, "one two", "$var", 0, 2, { "one", "two", }, IFS },
+    { 0, "one two three", "$var", 0, 3, { "one", "two", "three", }, IFS },
+    { 0, " \tfoo\t\tbar ", "$var", 0, 2, { "foo", "bar", }, IFS },
+    { 0, "  red  , white blue", "$var", 0, 3, { "red", "white", "blue", }, ", \n\t" },
+    { 0, "  red  , white blue", "\"$var\"", 0, 1, { "  red  , white blue", }, ", \n\t" },
+    { 0, NULL, "\"$(echo hello there)\"", 0, 1, { "hello there", }, IFS },
+    { 0, NULL, "\"$(echo \"hello there\")\"", 0, 1, { "hello there", }, IFS },
+    { 0, NULL, "${var=one two} \"$var\"", 0, 3, { "one", "two", "one two", }, IFS },
+    { 0, "1", "$(( $(echo 3)+$var ))", 0, 1, { "4", }, IFS },
+    { 0, NULL, "\"$(echo \"*\")\"", 0, 1, { "*", }, IFS },
+    { 0, NULL, "\"a\n\n$(echo)b\"", 0, 1, { "a\n\nb", }, IFS },
+    { 0, "foo", "*$var*", 0, 1, { "*foo*", }, IFS },
+    { 0, "o thr", "*$var*", 0, 2, { "two", "three" }, IFS },
+
+    /* Different IFS values */
+    { 0, "a b\tc\nd  ", "$var", 0, 4, { "a", "b", "c", "d" }, NULL /* unset */ },
+    { 0, "a b\tc d  ", "$var", 0, 1, { "a b\tc d  " }, "" /* `null' */ },
+    { 0, "a,b c\n, d", "$var", 0, 3, { "a", "b c", " d" }, "\t\n," },
+
+    /* Other things that should succeed */
+    { 0, NULL, "\\*\"|&;<>\"\\(\\)\\{\\}", 0, 1, { "*|&;<>(){}", }, IFS },
+    { 0, "???", "$var", 0, 1, { "???", }, IFS },
+    { 0, NULL, "$var", 0, 0, { NULL, }, IFS },
+    { 0, NULL, "\"\\n\"", 0, 1, { "\\n", }, IFS },
+    { 0, NULL, "", 0, 0, { NULL, }, IFS },
+
+    /* Flags not already covered (testit() has special handling for these) */
+    { 0, NULL, "one two", WRDE_DOOFFS, 2, { "one", "two", }, IFS },
+    { 0, NULL, "appended", WRDE_APPEND, 3, { "pre1", "pre2", "appended", }, IFS },
+    { 0, NULL, "appended", WRDE_DOOFFS|WRDE_APPEND, 3, { "pre1", "pre2", "appended", }, IFS },
+
+    /* Things that should fail */
+    { WRDE_BADCHAR, NULL, "new\nline", 0, 0, { NULL, }, "" /* \n not IFS */ },
+    { WRDE_BADCHAR, NULL, "pipe|symbol", 0, 0, { NULL, }, IFS },
+    { WRDE_BADCHAR, NULL, "&ampersand", 0, 0, { NULL, }, IFS },
+    { WRDE_BADCHAR, NULL, "semi;colon", 0, 0, { NULL, }, IFS },
+    { WRDE_BADCHAR, NULL, "<greater", 0, 0, { NULL, }, IFS },
+    { WRDE_BADCHAR, NULL, "less>", 0, 0, { NULL, }, IFS },
+    { WRDE_BADCHAR, NULL, "(open-paren", 0, 0, { NULL, }, IFS },
+    { WRDE_BADCHAR, NULL, "close-paren)", 0, 0, { NULL, }, IFS },
+    { WRDE_BADCHAR, NULL, "{open-brace", 0, 0, { NULL, }, IFS },
+    { WRDE_BADCHAR, NULL, "close-brace}", 0, 0, { NULL, }, IFS },
+    { WRDE_CMDSUB, NULL, "$(ls)", WRDE_NOCMD, 0, { NULL, }, IFS },
+    { WRDE_BADVAL, NULL, "$var", WRDE_UNDEF, 0, { NULL, }, IFS },
+    { WRDE_BADVAL, NULL, "$9", WRDE_UNDEF, 0, { NULL, }, IFS },
+    { WRDE_SYNTAX, NULL, "$[50+20))", 0, 0, { NULL, }, IFS },
+    { WRDE_SYNTAX, NULL, "${%%noparam}", 0, 0, { NULL, }, IFS },
+    { WRDE_SYNTAX, NULL, "${missing-brace", 0, 0, { NULL, }, IFS },
+    { WRDE_SYNTAX, NULL, "$(for i in)", 0, 0, { NULL, }, IFS },
+    { WRDE_SYNTAX, NULL, "$((2+))", 0, 0, { NULL, }, IFS },
+    { WRDE_SYNTAX, NULL, "`", 0, 0, { NULL, }, IFS },
+    { WRDE_SYNTAX, NULL, "$((010+4+))", 0, 0, { NULL }, IFS },
+
+    { -1, NULL, NULL, 0, 0, { NULL, }, IFS },
+  };
+
+static int testit (struct test_case_struct *tc);
+static int tests;
+
+static void
+command_line_test (const char *words)
+{
+  wordexp_t we;
+  int i;
+  int retval = wordexp (words, &we, 0);
+  printf ("wordexp returned %d\n", retval);
+  for (i = 0; i < we.we_wordc; i++)
+    printf ("we_wordv[%d] = \"%s\"\n", i, we.we_wordv[i]);
+}
+
+int
+main (int argc, char *argv[])
+{
+  const char *globfile[] = { "one", "two", "three", NULL };
+  char tmpdir[32];
+  struct passwd *pw;
+  const char *cwd;
+  int test;
+  int fail = 0;
+  int i;
+  struct test_case_struct ts;
+
+  if (argc > 1)
+    {
+      command_line_test (argv[1]);
+      return 0;
+    }
+
+  cwd = getcwd (NULL, 0);
+
+  /* Set up arena for pathname expansion */
+  tmpnam (tmpdir);
+  if (mkdir (tmpdir, S_IRWXU) || chdir (tmpdir))
+    return -1;
+  else
+    {
+      int fd;
+
+      for (i = 0; globfile[i]; ++i)
+	if ((fd = creat (globfile[i], S_IRUSR | S_IWUSR)) == -1
+	    || close (fd))
+	  return -1;
+    }
+
+  for (test = 0; test_case[test].retval != -1; test++)
+    if (testit (&test_case[test]))
+      ++fail;
+
+  /* Tilde-expansion tests. */
+  pw = getpwnam ("root");
+  if (pw != NULL)
+    {
+      ts.retval = 0;
+      ts.env = NULL;
+      ts.words = "~root ";
+      ts.flags = 0;
+      ts.wordc = 1;
+      ts.wordv[0] = pw->pw_dir;
+      ts.ifs = IFS;
+
+      if (testit (&ts))
+	++fail;
+
+      ts.retval = 0;
+      ts.env = pw->pw_dir;
+      ts.words = "${var#~root}x";
+      ts.flags = 0;
+      ts.wordc = 1;
+      ts.wordv[0] = "x";
+      ts.ifs = IFS;
+
+      if (testit (&ts))
+	++fail;
+    }
+
+  /* "~" expands to value of $HOME when HOME is set */
+
+  setenv ("HOME", "/dummy/home", 1);
+  ts.retval = 0;
+  ts.env = NULL;
+  ts.words = "~ ~/foo";
+  ts.flags = 0;
+  ts.wordc = 2;
+  ts.wordv[0] = "/dummy/home";
+  ts.wordv[1] = "/dummy/home/foo";
+  ts.ifs = IFS;
+
+  if (testit (&ts))
+    ++fail;
+
+  /* "~" expands to home dir from passwd file if HOME is not set */
+
+  pw = getpwuid (getuid ());
+  if (pw != NULL)
+    {
+      unsetenv ("HOME");
+      ts.retval = 0;
+      ts.env = NULL;
+      ts.words = "~";
+      ts.flags = 0;
+      ts.wordc = 1;
+      ts.wordv[0] = pw->pw_dir;
+      ts.ifs = IFS;
+
+      if (testit (&ts))
+	++fail;
+    }
+
+  puts ("tests completed, now cleaning up");
+
+  /* Clean up */
+  for (i = 0; globfile[i]; ++i)
+    remove (globfile[i]);
+
+  if (cwd == NULL)
+    cwd = "..";
+
+  chdir (cwd);
+  rmdir (tmpdir);
+
+  printf ("tests failed: %d\n", fail);
+
+  return fail != 0;
+}
+
+
+static int
+testit (struct test_case_struct *tc)
+{
+  int retval;
+  wordexp_t we, sav_we;
+  char *dummy;
+  int bzzzt = 0;
+  int start_offs = 0;
+  int i;
+
+  if (tc->env)
+    setenv ("var", tc->env, 1);
+  else
+    unsetenv ("var");
+
+  if (tc->ifs)
+    setenv ("IFS", tc->ifs, 1);
+  else
+    unsetenv ("IFS");
+
+  sav_we.we_wordc = 99;
+  sav_we.we_wordv = &dummy;
+  sav_we.we_offs = 3;
+  we = sav_we;
+
+  printf ("Test %d (%s): ", ++tests, tc->words);
+
+  if (tc->flags & WRDE_APPEND)
+    {
+      /* initial wordexp() call, to be appended to */
+      if (wordexp ("pre1 pre2", &we, tc->flags & ~WRDE_APPEND) != 0)
+        {
+	  printf ("FAILED setup\n");
+	  return 1;
+	}
+    }
+  retval = wordexp (tc->words, &we, tc->flags);
+
+  if (tc->flags & WRDE_DOOFFS)
+      start_offs = sav_we.we_offs;
+
+  if (retval != tc->retval || (retval == 0 && we.we_wordc != tc->wordc))
+    bzzzt = 1;
+  else if (retval == 0)
+    {
+      for (i = 0; i < start_offs; ++i)
+	if (we.we_wordv[i] != NULL)
+	  {
+	    bzzzt = 1;
+	    break;
+	  }
+
+      for (i = 0; i < we.we_wordc; ++i)
+	if (we.we_wordv[i+start_offs] == NULL ||
+	    strcmp (tc->wordv[i], we.we_wordv[i+start_offs]) != 0)
+	  {
+	    bzzzt = 1;
+	    break;
+	  }
+    }
+
+  if (bzzzt)
+    {
+      printf ("FAILED\n");
+      printf ("Test words: <%s>, need retval %d, wordc %Zd\n",
+	      tc->words, tc->retval, tc->wordc);
+      if (start_offs != 0)
+	printf ("(preceded by %d NULLs)\n", start_offs);
+      printf ("Got retval %d, wordc %Zd: ", retval, we.we_wordc);
+      if (retval == 0 || retval == WRDE_NOSPACE)
+	{
+	  for (i = 0; i < we.we_wordc + start_offs; ++i)
+	    if (we.we_wordv[i] == NULL)
+	      printf ("NULL ");
+	    else
+	      printf ("<%s> ", we.we_wordv[i]);
+	}
+      printf ("\n");
+    }
+  else if (retval != 0 && retval != WRDE_NOSPACE &&
+	   (we.we_wordc != sav_we.we_wordc ||
+            we.we_wordv != sav_we.we_wordv ||
+            we.we_offs != sav_we.we_offs))
+    {
+      bzzzt = 1;
+      printf ("FAILED to restore wordexp_t members\n");
+    }
+  else
+    printf ("OK\n");
+
+  if (retval == 0 || retval == WRDE_NOSPACE)
+    wordfree (&we);
+
+  return bzzzt;
+}
Index: trunk/src/libctests/glibc/posix/wordexp-tst.sh
===================================================================
--- trunk/src/libctests/glibc/posix/wordexp-tst.sh	(revision 2036)
+++ trunk/src/libctests/glibc/posix/wordexp-tst.sh	(revision 2036)
@@ -0,0 +1,153 @@
+#!/bin/sh
+
+# Some of these tests may look a little weird.
+# The first parameter to wordexp-test is what it gives to wordexp.
+# The others are just there to be parameters.
+
+common_objpfx=$1; shift
+elf_objpfx=$1; shift
+rtld_installed_name=$1; shift
+logfile=${common_objpfx}posix/wordexp-tst.out
+testout=${common_objpfx}posix/wordexp-test-result
+
+result=0
+rm -f $logfile
+# This is written in this funny way so that there is no trailing whitespace.
+# The first line contains a space followed by a tab.
+IFS=" 	\
+
+"
+export IFS
+
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
+${common_objpfx}posix/wordexp-test '$*' > ${testout}1
+cat <<"EOF" | cmp - ${testout}1 >> $logfile || failed=1
+wordexp returned 0
+we_wordv[0] = "$*"
+EOF
+if test $failed -ne 0; then
+  echo '$* test failed'
+  status=1
+fi
+
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
+${common_objpfx}posix/wordexp-test '${*}' unquoted > ${testout}2
+cat <<"EOF" | cmp - ${testout}2 >> $logfile || failed=1
+wordexp returned 0
+we_wordv[0] = "${*}"
+we_wordv[1] = "unquoted"
+EOF
+if test $failed -ne 0; then
+  echo '${*} test failed'
+  status=1
+fi
+
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
+${common_objpfx}posix/wordexp-test '$@' unquoted > ${testout}3
+cat <<"EOF" | cmp - ${testout}3 >> $logfile || failed=1
+wordexp returned 0
+we_wordv[0] = "$@"
+we_wordv[1] = "unquoted"
+EOF
+if test $failed -ne 0; then
+  echo '$@ test failed'
+  status=1
+fi
+
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
+${common_objpfx}posix/wordexp-test '"$* quoted"' param > ${testout}4
+cat <<"EOF" | cmp - ${testout}4 >> $logfile || failed=1
+wordexp returned 0
+we_wordv[0] = ""$* quoted" param quoted"
+EOF
+if test $failed -ne 0; then
+  echo '$* quoted test failed'
+  status=1
+fi
+
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
+${common_objpfx}posix/wordexp-test '"$@ quoted"' param > ${testout}5
+cat <<"EOF" | cmp - ${testout}5 >> $logfile || failed=1
+wordexp returned 0
+we_wordv[0] = ""$@ quoted""
+we_wordv[1] = "param quoted"
+EOF
+if test $failed -ne 0; then
+  echo '$@ quoted test failed'
+  status=1
+fi
+# Why?  Because bash does it that way..
+
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
+${common_objpfx}posix/wordexp-test '$#' 2 3 4 5 > ${testout}6
+cat <<"EOF" | cmp - ${testout}6 >> $logfile || failed=1
+wordexp returned 0
+we_wordv[0] = "5"
+EOF
+if test $failed -ne 0; then
+  echo '$# test failed'
+  status=1
+fi
+
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
+${common_objpfx}posix/wordexp-test '$2 ${3} $4' 2nd 3rd "4 th" > ${testout}7
+cat <<"EOF" | cmp - ${testout}7 >> $logfile || failed=1
+wordexp returned 0
+we_wordv[0] = "2nd"
+we_wordv[1] = "3rd"
+we_wordv[2] = "4"
+we_wordv[3] = "th"
+EOF
+if test $failed -ne 0; then
+  echo '$2 ${3} $4 test failed'
+  status=1
+fi
+
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
+${common_objpfx}posix/wordexp-test '${11}' 2 3 4 5 6 7 8 9 10 11 > ${testout}8
+cat <<"EOF" | cmp - ${testout}8 >> $logfile || failed=1
+wordexp returned 0
+we_wordv[0] = "11"
+EOF
+if test $failed -ne 0; then
+  echo '${11} test failed'
+  status=1
+fi
+
+failed=0
+${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
+${common_objpfx}posix/wordexp-test '"a $@ b"' c d > ${testout}9
+cat <<"EOF" | cmp - ${testout}9 >> $logfile || failed=1
+wordexp returned 0
+we_wordv[0] = "a "a $@ b""
+we_wordv[1] = "c"
+we_wordv[2] = "d b"
+EOF
+if test $failed -ne 0; then
+  echo '"a $@ b" test failed'
+  status=1
+fi
+
+${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
+${common_objpfx}posix/wordexp-test '${#@} ${#2} *$**' two 3 4 > ${testout}10
+cat <<"EOF" | cmp - ${testout}10 || failed=1
+wordexp returned 0
+we_wordv[0] = "4"
+we_wordv[1] = "3"
+we_wordv[2] = "*${#@}"
+we_wordv[3] = "${#2}"
+we_wordv[4] = "*$**"
+we_wordv[5] = "two"
+we_wordv[6] = "3"
+we_wordv[7] = "4*"
+EOF
+
+exit $result
Index: trunk/src/libctests/glibc/pwd/Makefile
===================================================================
--- trunk/src/libctests/glibc/pwd/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/pwd/Makefile	(revision 2036)
@@ -0,0 +1,47 @@
+# Copyright (C) 1991,1996-1999,2003,2004 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Sub-makefile for pwd portion of the library.
+#
+subdir	:= pwd
+headers := pwd.h
+
+routines := fgetpwent getpw putpwent \
+	    getpwent getpwnam getpwuid \
+	    getpwent_r getpwnam_r getpwuid_r fgetpwent_r
+
+tests := tst-getpw
+
+include ../Rules
+
+ifeq ($(have-thread-library),yes)
+
+CFLAGS-getpwuid_r.c = -DUSE_NSCD=1
+CFLAGS-getpwnam_r.c = -DUSE_NSCD=1
+CFLAGS-getpwent_r.c = -fexceptions
+CFLAGS-getpwent.c = -fexceptions
+CFLAGS-getpw.c = -fexceptions
+CFLAGS-fgetpwent_r.c = -D_IO_MTSAFE_IO
+
+endif
+
+ifeq (yes,$(build-static-nss))
+otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
+             $(resolvobjdir)/libresolv.a
+endif
Index: trunk/src/libctests/glibc/pwd/tst-getpw.c
===================================================================
--- trunk/src/libctests/glibc/pwd/tst-getpw.c	(revision 2036)
+++ trunk/src/libctests/glibc/pwd/tst-getpw.c	(revision 2036)
@@ -0,0 +1,41 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pwd.h>
+
+static void
+check (uid_t uid)
+{
+  char buf[1024];
+
+  (void) getpw (uid, buf);
+}
+
+int
+main (void)
+{
+  uid_t uid;
+
+  /* Just call it a different number of times the range should be
+     large enough to find some existing and some non existing uids.  */
+
+  for (uid = 0; uid < 2000; ++uid)
+    check (uid);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/resolv/Makefile
===================================================================
--- trunk/src/libctests/glibc/resolv/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/resolv/Makefile	(revision 2036)
@@ -0,0 +1,117 @@
+# Copyright (C) 1994,1995,1996,1997,1998,1999,2000,2001,2003,2004
+#	Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Sub-makefile for resolv portion of the library.
+#
+subdir	:= resolv
+
+headers	:= resolv.h \
+	   netdb.h bits/netdb.h \
+	   arpa/nameser.h arpa/nameser_compat.h \
+	   sys/bitypes.h
+distribute := ../conf/portability.h mapv4v6addr.h mapv4v6hostent.h \
+	      Banner res_hconf.h res_debug.h README gai_misc.h ga_test.c
+
+routines := herror inet_addr inet_ntop inet_pton nsap_addr res_init \
+	    res_hconf res_libc res-state
+
+tests = tst-aton tst-leaks
+xtests = tst-leaks2
+
+generate := mtrace-tst-leaks tst-leaks.mtrace tst-leaks2.mtrace
+
+include ../Makeconfig
+
+extra-libs := libresolv libnss_dns
+ifeq ($(have-thread-library),yes)
+extra-libs += libanl
+routines += gai_sigqueue
+endif
+extra-libs-others = $(extra-libs)
+libresolv-routines := gethnamaddr res_comp res_debug	\
+		      res_data res_mkquery res_query res_send		\
+		      inet_net_ntop inet_net_pton inet_neta base64	\
+		      ns_parse ns_name ns_netint ns_ttl ns_print	\
+		      ns_samedomain
+
+libanl-routines := gai_cancel gai_error gai_misc gai_notify gai_suspend \
+		   getaddrinfo_a
+
+subdir-dirs = nss_dns
+vpath %.c nss_dns
+
+libnss_dns-routines	:= dns-host dns-network dns-canon
+ifneq ($(build-static-nss),yes)
+libnss_dns-inhibit-o	= $(filter-out .os,$(object-suffixes))
+endif
+
+ifeq (yesyes,$(build-shared)$(have-thread-library))
+tests: $(objpfx)ga_test
+endif
+
+generated := mtrace-tst-leaks tst-leaks.mtrace \
+	     mtrace-tst-leaks2 tst-leaks2.mtrace
+
+include ../Rules
+
+CPPFLAGS += -Dgethostbyname=res_gethostbyname \
+	    -Dgethostbyname2=res_gethostbyname2 \
+	    -Dgethostbyaddr=res_gethostbyaddr \
+	    -Dgetnetbyname=res_getnetbyname \
+	    -Dgetnetbyaddr=res_getnetbyaddr
+
+CFLAGS-res_hconf.c = -fexceptions
+
+# The BIND code elicits some harmless warnings.
++cflags += -Wno-strict-prototypes -Wno-write-strings
+
+# Depend on libc.so so a DT_NEEDED is generated in the shared objects.
+# This ensures they will load libc.so for needed symbols if loaded by
+# a statically-linked program that hasn't already loaded it.
+$(objpfx)libresolv.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a
+
+# The DNS NSS modules needs the resolver.
+$(objpfx)libnss_dns.so: $(objpfx)libresolv.so $(common-objpfx)libc.so \
+			$(common-objpfx)libc_nonshared.a
+
+# The asynchronous name lookup code needs the thread library.
+$(objpfx)libanl.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a \
+		    $(shared-thread-library)
+
+$(objpfx)ga_test: $(objpfx)libanl.so $(shared-thread-library)
+
+$(objpfx)tst-leaks: $(objpfx)libresolv.so
+tst-leaks-ENV = MALLOC_TRACE=$(objpfx)tst-leaks.mtrace
+$(objpfx)mtrace-tst-leaks: $(objpfx)tst-leaks.out
+	$(common-objpfx)malloc/mtrace $(objpfx)tst-leaks.mtrace > $@
+ifeq (no,$(cross-compiling))
+ifneq (no,$(PERL))
+tests: $(objpfx)mtrace-tst-leaks
+endif
+endif
+
+tst-leaks2-ENV = MALLOC_TRACE=$(objpfx)tst-leaks2.mtrace
+$(objpfx)mtrace-tst-leaks2: $(objpfx)tst-leaks2.out
+	$(common-objpfx)malloc/mtrace $(objpfx)tst-leaks2.mtrace > $@
+ifeq (no,$(cross-compiling))
+ifneq (no,$(PERL))
+xtests: $(objpfx)mtrace-tst-leaks2
+endif
+endif
Index: trunk/src/libctests/glibc/resolv/ga_test.c
===================================================================
--- trunk/src/libctests/glibc/resolv/ga_test.c	(revision 2036)
+++ trunk/src/libctests/glibc/resolv/ga_test.c	(revision 2036)
@@ -0,0 +1,99 @@
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+int
+main (void)
+{
+#define N 10
+  struct gaicb reqmem[N];
+  struct gaicb *req[N];
+  int n;
+
+  for (n = 0; n < N; ++n)
+    {
+      asprintf (&reqmem[n].ar_name, "test%d.test.redhat.com", 140 + n);
+      reqmem[n].ar_service = NULL;
+      reqmem[n].ar_request = NULL;
+      reqmem[n].ar_result = NULL;
+      req[n] = &reqmem[n];
+    }
+
+  if (getaddrinfo_a (GAI_NOWAIT, req, N, NULL) != 0)
+    {
+      puts ("queue call failed");
+      exit (1);
+    }
+  else
+    puts ("queue call successful");
+
+  while (1)
+    {
+      int any = 0;
+
+      for (n = 0; n < N; ++n)
+	if (req[n] != NULL && gai_error (req[n]) != EAI_INPROGRESS)
+	  {
+	    if (gai_error (req[n]) == 0)
+	      {
+		struct addrinfo *runp = req[n]->ar_result;
+
+		while (runp != NULL)
+		  {
+		    switch (runp->ai_family)
+		      {
+		      case PF_INET:
+			{
+			  struct sockaddr_in *sinp;
+
+			  sinp = (struct sockaddr_in *) runp->ai_addr;
+			  printf ("%2d: %s = %s\n", n,
+				  req[n]->ar_name, inet_ntoa (sinp->sin_addr));
+			}
+			break;
+		      default:
+			printf ("%2d: family %d\n", n, runp->ai_family);
+			break;
+		      }
+		    runp = runp->ai_next;
+		  }
+	      }
+	    else
+	      printf ("error for %d: %s\n", n,
+		      gai_strerror (gai_error (req[n])));
+	    req[n] = NULL;
+	    break;
+	  }
+	else if (req[n] != NULL)
+	  any = 1;
+
+      if (n == N)
+	{
+	  if (any)
+	    gai_suspend (req, N, NULL);
+	  else
+	    break;
+	}
+    }
+
+  __libc_write(1,"got all\n", 8);
+
+  for (n = 0; n < N; ++n)
+    if (gai_error (&reqmem[n]) == 0)
+      {
+	struct addrinfo *runp = reqmem[n].ar_result;
+
+	while (runp != NULL)
+	  {
+	    struct addrinfo *oldp = runp;
+	    runp = runp->ai_next;
+	    freeaddrinfo (oldp);
+	  }
+      }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/resolv/tst-aton.c
===================================================================
--- trunk/src/libctests/glibc/resolv/tst-aton.c	(revision 2036)
+++ trunk/src/libctests/glibc/resolv/tst-aton.c	(revision 2036)
@@ -0,0 +1,73 @@
+#include <stdio.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+
+static struct tests
+{
+  const char *input;
+  int valid;
+  uint32_t result;
+} tests[] =
+{
+  { "", 0, 0 },
+  { "-1", 0, 0 },
+  { "256", 1, 0x00000100 },
+  { "256.", 0, 0 },
+  { "256a", 0, 0 },
+  { "0x100", 1, 0x00000100 },
+  { "0200.0x123456", 1, 0x80123456 },
+  { "0300.0x89123456.", 0 ,0 },
+  { "0100.-0xffff0000", 0, 0 },
+  { "0.0xffffff", 1, 0x00ffffff },
+  { "0.0x1000000", 0, 0 },
+  { "0377.16777215", 1, 0xffffffff },
+  { "0377.16777216", 0, 0 },
+  { "0x87.077777777", 1, 0x87ffffff },
+  { "0x87.0100000000", 0, 0 },
+  { "0.1.3", 1, 0x00010003 },
+  { "0.256.3", 0, 0 },
+  { "256.1.3", 0, 0 },
+  { "0.1.0x10000", 0, 0 },
+  { "0.1.0xffff", 1, 0x0001ffff },
+  { "0.1a.3", 0, 0 },
+  { "0.1.a3", 0, 0 },
+  { "1.2.3.4", 1, 0x01020304 },
+  { "0400.2.3.4", 0, 0 },
+  { "1.0x100.3.4", 0, 0 },
+  { "1.2.256.4", 0, 0 },
+  { "1.2.3.0x100", 0, 0 },
+  { "323543357756889", 0, 0 },
+  { "10.1.2.3.4", 0, 0},
+};
+
+
+int
+main (int argc, char *argv[])
+{
+  int result = 0;
+  size_t cnt;
+
+  for (cnt = 0; cnt < sizeof (tests) / sizeof (tests[0]); ++cnt)
+    {
+      struct in_addr addr;
+
+      if ((int) inet_aton (tests[cnt].input, &addr) != tests[cnt].valid)
+	{
+	  if (tests[cnt].valid)
+	    printf ("\"%s\" not seen as valid IP address\n", tests[cnt].input);
+	  else
+	    printf ("\"%s\" seen as valid IP address\n", tests[cnt].input);
+	  result = 1;
+	}
+      else if (tests[cnt].valid && addr.s_addr != ntohl (tests[cnt].result))
+	{
+	  printf ("\"%s\" not converted correctly: is %08x, should be %08x\n",
+		  tests[cnt].input, addr.s_addr, tests[cnt].result);
+	  result = 1;
+	}
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/resolv/tst-leaks.c
===================================================================
--- trunk/src/libctests/glibc/resolv/tst-leaks.c	(revision 2036)
+++ trunk/src/libctests/glibc/resolv/tst-leaks.c	(revision 2036)
@@ -0,0 +1,44 @@
+/* Tests for res_query in libresolv
+   Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <netinet/in.h>
+#include <arpa/nameser.h>
+#include <resolv.h>
+#include <mcheck.h>
+
+/* Prototype for our test function.  */
+extern int do_test (int argc, char *argv[]);
+
+/* This defines the `main' function and some more.  */
+#define TIMEOUT 40
+#include <test-skeleton.c>
+
+int
+do_test (int argc, char *argv[])
+{
+  unsigned char buf[256];
+
+  mtrace();
+
+  /* This will allocate some memory, which should be automatically
+     freed at exit.  */
+  res_query ("1.0.0.127.in-addr.arpa.", C_ANY, T_ANY, buf, 256);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/resolv/tst-leaks2.c
===================================================================
--- trunk/src/libctests/glibc/resolv/tst-leaks2.c	(revision 2036)
+++ trunk/src/libctests/glibc/resolv/tst-leaks2.c	(revision 2036)
@@ -0,0 +1,41 @@
+/* Tests for res_init in libresolv
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#undef gethostbyname
+
+#include <mcheck.h>
+#include <netdb.h>
+#include <resolv.h>
+
+static int
+do_test (void)
+{
+  mtrace ();
+  for (int i = 0; i < 20; ++i)
+    {
+      res_init ();
+      gethostbyname ("www.gnu.org");
+    }
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 30
+/* This defines the `main' function and some more.  */
+#include <test-skeleton.c>
Index: trunk/src/libctests/glibc/rt/Makefile
===================================================================
--- trunk/src/libctests/glibc/rt/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/rt/Makefile	(revision 2036)
@@ -0,0 +1,86 @@
+# Copyright (C) 1997-2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Sub-makefile for real-time portion of the library.
+#
+subdir	:= rt
+
+headers	:= aio.h mqueue.h bits/mqueue.h
+
+aio-routines   := aio_cancel aio_error aio_fsync aio_misc aio_read	\
+		  aio_read64 aio_return aio_suspend aio_write		\
+		  aio_write64 lio_listio lio_listio64 aio_sigqueue	\
+		  aio_notify
+clock-routines := get_clockfreq clock_getcpuclockid			\
+		  clock_getres clock_gettime clock_settime		\
+		  clock_nanosleep
+timer-routines := timer_create timer_delete timer_getoverr		\
+		  timer_gettime timer_settime
+shm-routines   := shm_open shm_unlink
+mq-routines    := mq_open mq_close mq_unlink mq_getattr mq_setattr	\
+		  mq_notify mq_send mq_receive mq_timedsend		\
+		  mq_timedreceive
+
+librt-routines = $(aio-routines) \
+		 $(clock-routines) $(timer-routines) \
+		 $(shm-routines) $(mq-routines)
+
+tests := tst-shm tst-clock tst-clock_nanosleep tst-timer tst-timer2 \
+	 tst-aio tst-aio64 tst-aio2 tst-aio3 tst-aio4 tst-aio5 tst-aio6 \
+	 tst-aio7 tst-mqueue1 tst-mqueue2 tst-mqueue3 tst-mqueue4 \
+	 tst-mqueue5 tst-mqueue6 tst-mqueue7 tst-mqueue8 tst-mqueue9 \
+	 tst-timer3 tst-timer4 tst-timer5 \
+	 tst-cpuclock1 tst-cpuclock2 \
+	 tst-cputimer1 tst-cputimer2 tst-cputimer3
+
+extra-libs := librt
+extra-libs-others := $(extra-libs)
+
+distribute := aio_misc.h
+
+include ../Rules
+
+CFLAGS-aio_suspend.c = -fexceptions
+CFLAGS-clock_nanosleep.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-librt-cancellation.c = -fasynchronous-unwind-tables
+
+LDFLAGS-rt.so = -Wl,--enable-new-dtags,-z,nodelete
+
+# Depend on libc.so so a DT_NEEDED is generated in the shared objects.
+# This ensures they will load libc.so for needed symbols if loaded by
+# a statically-linked program that hasn't already loaded it.
+$(objpfx)librt.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a \
+		   $(shared-thread-library) \
+		   $(if $(filter yes,$(elf)), $(elfobjdir)/ld.so)
+
+ifeq (yes,$(build-shared))
+$(addprefix $(objpfx),$(tests)): $(objpfx)librt.so $(shared-thread-library)
+else
+$(addprefix $(objpfx),$(tests)): $(objpfx)librt.a $(static-thread-library)
+endif
+ifeq (yes,$(build-bounded))
+$(tests:%=$(objpfx)%-bp): $(objpfx)librt_b.a $(bounded-thread-library)
+endif
+
+tst-mqueue7-ARGS = -- $(built-program-cmd)
+
+ifeq (yes,$(build-static-nss))
+otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
+             $(resolvobjdir)/libresolv.a
+endif
Index: trunk/src/libctests/glibc/rt/tst-aio.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-aio.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-aio.c	(revision 2036)
@@ -0,0 +1,289 @@
+/* Tests for AIO in librt.
+   Copyright (C) 1998,2000,02 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <aio.h>
+#include <errno.h>
+#include <error.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+
+/* Prototype for our test function.  */
+extern void do_prepare (int argc, char *argv[]);
+extern int do_test (int argc, char *argv[]);
+
+/* We have a preparation function.  */
+#define PREPARE do_prepare
+
+/* We might need a bit longer timeout.  */
+#define TIMEOUT 20 /* sec */
+
+/* This defines the `main' function and some more.  */
+#include <test-skeleton.c>
+
+
+/* These are for the temporary file we generate.  */
+char *name;
+int fd;
+
+void
+do_prepare (int argc, char *argv[])
+{
+  char name_len;
+
+  name_len = strlen (test_dir);
+  name = malloc (name_len + sizeof ("/aioXXXXXX"));
+  mempcpy (mempcpy (name, test_dir, name_len),
+	   "/aioXXXXXX", sizeof ("/aioXXXXXX"));
+  add_temp_file (name);
+
+  /* Open our test file.   */
+  fd = mkstemp (name);
+  if (fd == -1)
+    error (EXIT_FAILURE, errno, "cannot open test file `%s'", name);
+}
+
+
+static int
+test_file (const void *buf, size_t size, int fd, const char *msg)
+{
+  struct stat st;
+  char tmp[size];
+
+  errno = 0;
+  if (fstat (fd, &st) < 0)
+    {
+      error (0, errno, "%s: failed stat", msg);
+      return 1;
+    }
+
+  if (st.st_size != (off_t) size)
+    {
+      error (0, errno, "%s: wrong size: %lu, should be %lu",
+	     msg, (unsigned long int) st.st_size, (unsigned long int) size);
+      return 1;
+    }
+
+  if (pread (fd, tmp, size, 0) != (ssize_t) size)
+    {
+      error (0, errno, "%s: failed pread", msg);
+      return 1;
+    }
+
+  if (memcmp (buf, tmp, size) != 0)
+    {
+      error (0, errno, "%s: failed comparison", msg);
+      return 1;
+    }
+
+  printf ("%s test ok\n", msg);
+
+  return 0;
+}
+
+
+static int
+do_wait (struct aiocb **cbp, size_t nent, int allowed_err)
+{
+  int go_on;
+  size_t cnt;
+  int result = 0;
+
+  do
+    {
+      aio_suspend ((const struct aiocb *const *) cbp, nent, NULL);
+      go_on = 0;
+      for (cnt = 0; cnt < nent; ++cnt)
+	if (cbp[cnt] != NULL)
+	  {
+	    if (aio_error (cbp[cnt]) == EINPROGRESS)
+	      go_on = 1;
+	    else
+	      {
+		if (aio_return (cbp[cnt]) == -1
+		    && (allowed_err == 0
+			|| aio_error (cbp[cnt]) != allowed_err))
+		  {
+		    error (0, aio_error (cbp[cnt]), "Operation failed\n");
+		    result = 1;
+		  }
+		cbp[cnt] = NULL;
+	      }
+	  }
+    }
+  while (go_on);
+
+  return result;
+}
+
+
+int
+do_test (int argc, char *argv[])
+{
+  struct aiocb cbs[10];
+  struct aiocb cbs_fsync;
+  struct aiocb *cbp[10];
+  struct aiocb *cbp_fsync[1];
+  char buf[1000];
+  size_t cnt;
+  int result = 0;
+
+  /* Preparation.  */
+  for (cnt = 0; cnt < 10; ++cnt)
+    {
+      cbs[cnt].aio_fildes = fd;
+      cbs[cnt].aio_reqprio = 0;
+      cbs[cnt].aio_buf = memset (&buf[cnt * 100], '0' + cnt, 100);
+      cbs[cnt].aio_nbytes = 100;
+      cbs[cnt].aio_offset = cnt * 100;
+      cbs[cnt].aio_sigevent.sigev_notify = SIGEV_NONE;
+
+      cbp[cnt] = &cbs[cnt];
+    }
+
+  /* First a simple test.  */
+  for (cnt = 10; cnt > 0; )
+    if (aio_write (cbp[--cnt]) < 0 && errno == ENOSYS)
+      {
+	error (0, 0, "no aio support in this configuration");
+	return 0;
+      }
+  /* Wait 'til the results are there.  */
+  result |= do_wait (cbp, 10, 0);
+  /* Test this.  */
+  result |= test_file (buf, sizeof (buf), fd, "aio_write");
+
+  /* Read now as we've written it.  */
+  memset (buf, '\0', sizeof (buf));
+  /* Issue the commands.  */
+  for (cnt = 10; cnt > 0; )
+    {
+      --cnt;
+      cbp[cnt] = &cbs[cnt];
+      aio_read (cbp[cnt]);
+    }
+  /* Wait 'til the results are there.  */
+  result |= do_wait (cbp, 10, 0);
+  /* Test this.  */
+  for (cnt = 0; cnt < 1000; ++cnt)
+    if (buf[cnt] != '0' + (cnt / 100))
+      {
+	result = 1;
+	error (0, 0, "comparison failed for aio_read test");
+	break;
+      }
+
+  if (cnt == 1000)
+    puts ("aio_read test ok");
+
+  /* Remove the test file contents.  */
+  if (ftruncate (fd, 0) < 0)
+    {
+      error (0, errno, "ftruncate failed\n");
+      result = 1;
+    }
+
+  /* Test lio_listio.  */
+  for (cnt = 0; cnt < 10; ++cnt)
+    {
+      cbs[cnt].aio_lio_opcode = LIO_WRITE;
+      cbp[cnt] = &cbs[cnt];
+    }
+  /* Issue the command.  */
+  lio_listio (LIO_WAIT, cbp, 10, NULL);
+  /* ...and immediately test it since we started it in wait mode.  */
+  result |= test_file (buf, sizeof (buf), fd, "lio_listio (write)");
+
+  /* Test aio_fsync.  */
+  cbs_fsync.aio_fildes = fd;
+  cbs_fsync.aio_sigevent.sigev_notify = SIGEV_NONE;
+  cbp_fsync[0] = &cbs_fsync;
+
+  /* Remove the test file contents first.  */
+  if (ftruncate (fd, 0) < 0)
+    {
+      error (0, errno, "ftruncate failed\n");
+      result = 1;
+    }
+
+  /* Write again.  */
+  for (cnt = 10; cnt > 0; )
+    aio_write (cbp[--cnt]);
+
+  if (aio_fsync (O_SYNC, &cbs_fsync) < 0)
+    {
+      error (0, errno, "aio_fsync failed\n");
+      result = 1;
+    }
+  result |= do_wait (cbp_fsync, 1, 0);
+
+  /* ...and test since all data should be on disk now.  */
+  result |= test_file (buf, sizeof (buf), fd, "aio_fsync (aio_write)");
+
+  /* Test aio_cancel.  */
+  /* Remove the test file contents first.  */
+  if (ftruncate (fd, 0) < 0)
+    {
+      error (0, errno, "ftruncate failed\n");
+      result = 1;
+    }
+
+  /* Write again.  */
+  for (cnt = 10; cnt > 0; )
+    aio_write (cbp[--cnt]);
+
+  /* Cancel all requests.  */
+  if (aio_cancel (fd, NULL) == -1)
+    printf ("aio_cancel (fd, NULL) cannot cancel anything\n");
+
+  result |= do_wait (cbp, 10, ECANCELED);
+
+  /* Another test for aio_cancel.  */
+  /* Remove the test file contents first.  */
+  if (ftruncate (fd, 0) < 0)
+    {
+      error (0, errno, "ftruncate failed\n");
+      result = 1;
+    }
+
+  /* Write again.  */
+  for (cnt = 10; cnt > 0; )
+    {
+      --cnt;
+      cbp[cnt] = &cbs[cnt];
+      aio_write (cbp[cnt]);
+    }
+  puts ("finished3");
+
+  /* Cancel all requests.  */
+  for (cnt = 10; cnt > 0; )
+    if (aio_cancel (fd, cbp[--cnt]) == -1)
+      /* This is not an error.  The request can simply be finished.  */
+      printf ("aio_cancel (fd, cbp[%Zd]) cannot be canceled\n", cnt);
+  puts ("finished2");
+
+  result |= do_wait (cbp, 10, ECANCELED);
+
+  puts ("finished");
+
+  return result;
+}
Index: trunk/src/libctests/glibc/rt/tst-aio2.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-aio2.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-aio2.c	(revision 2036)
@@ -0,0 +1,91 @@
+/* Test for notification mechanism in lio_listio.
+   Copyright (C) 2000,02 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <aio.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+
+int flag;
+
+
+static void
+thrfct (sigval_t arg)
+{
+  flag = 1;
+}
+
+
+static int
+do_test (int argc, char *argv[])
+{
+  char name[] = "/tmp/aio2.XXXXXX";
+  int fd;
+  struct aiocb *arr[1];
+  struct aiocb cb;
+  static const char buf[] = "Hello World\n";
+
+  fd = mkstemp (name);
+  if (fd == -1)
+    {
+      printf ("cannot open temp name: %m\n");
+      return 1;
+    }
+
+  unlink (name);
+
+  arr[0] = &cb;
+
+  cb.aio_fildes = fd;
+  cb.aio_lio_opcode = LIO_WRITE;
+  cb.aio_reqprio = 0;
+  cb.aio_buf = (void *) buf;
+  cb.aio_nbytes = sizeof (buf) - 1;
+  cb.aio_offset = 0;
+  cb.aio_sigevent.sigev_notify = SIGEV_THREAD;
+  cb.aio_sigevent.sigev_notify_function = thrfct;
+  cb.aio_sigevent.sigev_notify_attributes = NULL;
+  cb.aio_sigevent.sigev_value.sival_ptr = NULL;
+
+  if (lio_listio (LIO_WAIT, arr, 1, NULL) < 0)
+    {
+      if (errno == ENOSYS)
+	{
+	  puts ("no aio support in this configuration");
+	  return 0;
+	}
+      printf ("lio_listio failed: %m\n");
+      return 1;
+    }
+
+  if (flag != 0)
+    {
+      puts ("thread created, should not have happened");
+      return 1;
+    }
+
+  puts ("all OK");
+
+  return 0;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/rt/tst-aio3.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-aio3.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-aio3.c	(revision 2036)
@@ -0,0 +1,96 @@
+/* Test for notification mechanism in lio_listio.
+   Copyright (C) 2000,02 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <aio.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+
+int flag;
+
+
+static void
+thrfct (sigval_t arg)
+{
+  flag = 1;
+}
+
+
+static int
+do_test (int argc, char *argv[])
+{
+  char name[] = "/tmp/aio3.XXXXXX";
+  int fd;
+  struct aiocb *arr[1];
+  struct aiocb cb;
+  static const char buf[] = "Hello World\n";
+
+  fd = mkstemp (name);
+  if (fd == -1)
+    {
+      printf ("cannot open temp name: %m\n");
+      return 1;
+    }
+
+  unlink (name);
+
+  arr[0] = &cb;
+
+  cb.aio_fildes = fd;
+  cb.aio_lio_opcode = LIO_WRITE;
+  cb.aio_reqprio = 0;
+  cb.aio_buf = (void *) buf;
+  cb.aio_nbytes = sizeof (buf) - 1;
+  cb.aio_offset = 0;
+  cb.aio_sigevent.sigev_notify = SIGEV_THREAD;
+  cb.aio_sigevent.sigev_notify_function = thrfct;
+  cb.aio_sigevent.sigev_notify_attributes = NULL;
+  cb.aio_sigevent.sigev_value.sival_ptr = NULL;
+
+  if (lio_listio (LIO_NOWAIT, arr, 1, NULL) < 0)
+    {
+      if (errno == ENOSYS)
+	{
+	  puts ("no aio support in this configuration");
+	  return 0;
+	}
+      printf ("lio_listio failed: %m\n");
+      return 1;
+    }
+
+  if (aio_suspend ((const struct aiocb *const *) arr, 1, NULL) < 0)
+    {
+      printf ("aio_suspend failed: %m\n");
+      return 1;
+    }
+
+  if (flag != 0)
+    {
+      puts ("thread created, should not have happened");
+      return 1;
+    }
+
+  puts ("all OK");
+
+  return 0;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/rt/tst-aio4.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-aio4.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-aio4.c	(revision 2036)
@@ -0,0 +1,160 @@
+/* Test for completion signal handling.
+   Copyright (C) 2000,01,02 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <aio.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+
+/* We might need a bit longer timeout.  */
+#define TIMEOUT 10 /* sec */
+
+int my_signo;
+
+volatile sig_atomic_t flag;
+
+
+static void
+sighandler (const int signo)
+{
+  flag = signo;
+}
+
+static int
+wait_flag (void)
+{
+  while (flag == 0)
+    {
+      puts ("Sleeping...");
+      sleep (1);
+    }
+
+  if (flag != my_signo)
+    {
+      printf ("signal handler received wrong signal, flag is %d\n", flag);
+      return 1;
+    }
+
+  return 0;
+}
+
+#ifndef SIGRTMIN
+# define SIGRTMIN -1
+# define SIGRTMAX -1
+#endif
+
+static int
+do_test (int argc, char *argv[])
+{
+  char name[] = "/tmp/aio4.XXXXXX";
+  int fd;
+  struct aiocb *arr[1];
+  struct aiocb cb;
+  static const char buf[] = "Hello World\n";
+  struct aioinit init = {10, 20, 0};
+  struct sigaction sa;
+  struct sigevent ev;
+
+  if (SIGRTMIN == -1)
+  {
+      printf ("RT signals not supported.\n");
+      return 0;
+  }
+
+  /* Select a signal from the middle of the available choices... */
+  my_signo = (SIGRTMAX + SIGRTMIN) / 2;
+
+  fd = mkstemp (name);
+  if (fd == -1)
+    {
+      printf ("cannot open temp name: %m\n");
+      return 1;
+    }
+
+  unlink (name);
+
+  /* Test also aio_init.  */
+  aio_init (&init);
+
+  arr[0] = &cb;
+
+  cb.aio_fildes = fd;
+  cb.aio_lio_opcode = LIO_WRITE;
+  cb.aio_reqprio = 0;
+  cb.aio_buf = (void *) buf;
+  cb.aio_nbytes = sizeof (buf) - 1;
+  cb.aio_offset = 0;
+  cb.aio_sigevent.sigev_notify = SIGEV_SIGNAL;
+  cb.aio_sigevent.sigev_notify_function = NULL;
+  cb.aio_sigevent.sigev_notify_attributes = NULL;
+  cb.aio_sigevent.sigev_signo = my_signo;
+  cb.aio_sigevent.sigev_value.sival_ptr = NULL;
+
+  ev.sigev_notify = SIGEV_SIGNAL;
+  ev.sigev_notify_function = NULL;
+  ev.sigev_notify_attributes = NULL;
+  ev.sigev_signo = my_signo;
+
+  sa.sa_handler = sighandler;
+  sigemptyset (&sa.sa_mask);
+  sa.sa_flags = SA_RESTART;
+
+  if (sigaction (my_signo, &sa, NULL) < 0)
+    {
+      printf ("sigaction failed: %m\n");
+      return 1;
+    }
+
+  flag = 0;
+  /* First use aio_write.  */
+  if (aio_write (arr[0]) < 0)
+    {
+      if (errno == ENOSYS)
+	{
+	  puts ("no aio support in this configuration");
+	  return 0;
+	}
+      printf ("aio_write failed: %m\n");
+      return 1;
+    }
+
+  if (wait_flag ())
+    return 1;
+
+  puts ("aio_write OK");
+
+  flag = 0;
+  /* Again with lio_listio.  */
+  if (lio_listio (LIO_NOWAIT, arr, 1, &ev) < 0)
+    {
+      printf ("lio_listio failed: %m\n");
+      return 1;
+    }
+
+  if (wait_flag ())
+    return 1;
+
+  puts ("all OK");
+
+  return 0;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/rt/tst-aio5.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-aio5.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-aio5.c	(revision 2036)
@@ -0,0 +1,130 @@
+/* Test for completion thread handling.
+   Copyright (C) 2000,02 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <aio.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+
+/* We might need a bit longer timeout.  */
+#define TIMEOUT 10 /* sec */
+
+#define MY_SIVAL 27
+
+volatile sig_atomic_t flag;
+
+
+static void
+callback (sigval_t s)
+{
+  flag = s.sival_int;
+}
+
+static int
+wait_flag (void)
+{
+  while (flag == 0)
+    {
+      puts ("Sleeping...");
+      sleep (1);
+    }
+
+  if (flag != MY_SIVAL)
+    {
+      printf ("signal handler received wrong signal, flag is %d\n", flag);
+      return 1;
+    }
+
+  return 0;
+}
+
+
+static int
+do_test (int argc, char *argv[])
+{
+  char name[] = "/tmp/aio5.XXXXXX";
+  int fd;
+  struct aiocb *arr[1];
+  struct aiocb cb;
+  static const char buf[] = "Hello World\n";
+  struct sigevent ev;
+
+  fd = mkstemp (name);
+  if (fd == -1)
+    {
+      printf ("cannot open temp name: %m\n");
+      return 1;
+    }
+
+  unlink (name);
+
+  arr[0] = &cb;
+
+  cb.aio_fildes = fd;
+  cb.aio_lio_opcode = LIO_WRITE;
+  cb.aio_reqprio = 0;
+  cb.aio_buf = (void *) buf;
+  cb.aio_nbytes = sizeof (buf) - 1;
+  cb.aio_offset = 0;
+  cb.aio_sigevent.sigev_notify = SIGEV_THREAD;
+  cb.aio_sigevent.sigev_notify_function = callback;
+  cb.aio_sigevent.sigev_notify_attributes = NULL;
+  cb.aio_sigevent.sigev_value.sival_int = MY_SIVAL;
+
+  ev.sigev_notify = SIGEV_THREAD;
+  ev.sigev_notify_function = callback;
+  ev.sigev_notify_attributes = NULL;
+  ev.sigev_value.sival_int = MY_SIVAL;
+
+  /* First use aio_write.  */
+  if (aio_write (arr[0]) < 0)
+    {
+      if (errno == ENOSYS)
+	{
+	  puts ("no aio support in this configuration");
+	  return 0;
+	}
+      printf ("aio_write failed: %m\n");
+      return 1;
+    }
+
+  if (wait_flag ())
+    return 1;
+
+  puts ("aio_write OK");
+
+  flag = 0;
+  /* Again with lio_listio.  */
+  if (lio_listio (LIO_NOWAIT, arr, 1, &ev) < 0)
+    {
+      printf ("lio_listio failed: %m\n");
+      return 1;
+    }
+
+  if (wait_flag ())
+    return 1;
+
+  puts ("all OK");
+
+  return 0;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/rt/tst-aio6.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-aio6.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-aio6.c	(revision 2036)
@@ -0,0 +1,102 @@
+/* Test for timeout handling.
+   Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <aio.h>
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+
+/* We expect to wait for 3 seconds so we have to increase the timeout.  */
+#define TIMEOUT 10 /* sec */
+
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+  struct aiocb *arr[1];
+  struct aiocb cb;
+  char buf[100];
+  struct timeval before;
+  struct timeval after;
+  struct timespec timeout;
+  int fd[2];
+  int result = 0;
+
+  if (pipe (fd) != 0)
+    {
+      printf ("cannot create pipe: %m\n");
+      return 1;
+    }
+
+  arr[0] = &cb;
+
+  cb.aio_fildes = fd[0];
+  cb.aio_lio_opcode = LIO_WRITE;
+  cb.aio_reqprio = 0;
+  cb.aio_buf = (void *) buf;
+  cb.aio_nbytes = sizeof (buf) - 1;
+  cb.aio_offset = 0;
+  cb.aio_sigevent.sigev_notify = SIGEV_NONE;
+
+  /* Try to read from stdin where nothing will be available.  */
+  if (aio_read (arr[0]) < 0)
+    {
+      if (errno == ENOSYS)
+	{
+	  puts ("no aio support in this configuration");
+	  return 0;
+	}
+      printf ("aio_read failed: %m\n");
+      return 1;
+    }
+
+  /* Get the current time.  */
+  gettimeofday (&before, NULL);
+
+  /* Wait for input which is unsuccessful and therefore the function will
+     time out.  */
+  timeout.tv_sec = 3;
+  timeout.tv_nsec = 0;
+  if (aio_suspend ((const struct aiocb *const*) arr, 1, &timeout) != -1)
+    {
+      puts ("aio_suspend() didn't return -1");
+      result = 1;
+    }
+  else if (errno != EAGAIN)
+    {
+      puts ("error not set to EAGAIN");
+      result = 1;
+    }
+  else
+    {
+      gettimeofday (&after, NULL);
+      if (after.tv_sec < before.tv_sec + 1)
+	{
+	  puts ("timeout came too early");
+	  result = 1;
+	}
+    }
+
+  return result;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/rt/tst-aio64.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-aio64.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-aio64.c	(revision 2036)
@@ -0,0 +1,290 @@
+/* Tests for 64bit AIO in librt.
+   Copyright (C) 1998,99,2000,02 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define _LARGEFILE_SOURCE 1
+#include <aio.h>
+#include <errno.h>
+#include <error.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+
+/* Prototype for our test function.  */
+extern void do_prepare (int argc, char *argv[]);
+extern int do_test (int argc, char *argv[]);
+
+/* We have a preparation function.  */
+#define PREPARE do_prepare
+
+/* We might need a bit longer timeout.  */
+#define TIMEOUT 20 /* sec */
+
+/* This defines the `main' function and some more.  */
+#include <test-skeleton.c>
+
+
+/* These are for the temporary file we generate.  */
+char *name;
+int fd;
+
+void
+do_prepare (int argc, char *argv[])
+{
+  char name_len;
+
+  name_len = strlen (test_dir);
+  name = malloc (name_len + sizeof ("/aioXXXXXX"));
+  mempcpy (mempcpy (name, test_dir, name_len),
+	   "/aioXXXXXX", sizeof ("/aioXXXXXX"));
+  add_temp_file (name);
+
+  /* Open our test file.   */
+  fd = mkstemp (name);
+  if (fd == -1)
+    error (EXIT_FAILURE, errno, "cannot open test file `%s'", name);
+}
+
+
+static int
+test_file (const void *buf, size_t size, int fd, const char *msg)
+{
+  struct stat st;
+  char tmp[size];
+
+  errno = 0;
+  if (fstat (fd, &st) < 0)
+    {
+      error (0, errno, "%s: failed stat", msg);
+      return 1;
+    }
+
+  if (st.st_size != (off_t) size)
+    {
+      error (0, errno, "%s: wrong size: %lu, should be %lu",
+	     msg, (unsigned long int) st.st_size, (unsigned long int) size);
+      return 1;
+    }
+
+  if (pread (fd, tmp, size, 0) != (ssize_t) size)
+    {
+      error (0, errno, "%s: failed pread", msg);
+      return 1;
+    }
+
+  if (memcmp (buf, tmp, size) != 0)
+    {
+      error (0, errno, "%s: failed comparison", msg);
+      return 1;
+    }
+
+  printf ("%s test ok\n", msg);
+
+  return 0;
+}
+
+
+static int
+do_wait (struct aiocb64 **cbp, size_t nent, int allowed_err)
+{
+  int go_on;
+  size_t cnt;
+  int result = 0;
+
+  do
+    {
+      aio_suspend64 ((const struct aiocb64 *const *) cbp, nent, NULL);
+      go_on = 0;
+      for (cnt = 0; cnt < nent; ++cnt)
+	if (cbp[cnt] != NULL)
+	  {
+	    if (aio_error64 (cbp[cnt]) == EINPROGRESS)
+	      go_on = 1;
+	    else
+	      {
+		if (aio_return64 (cbp[cnt]) == -1
+		    && (allowed_err == 0
+			|| aio_error64 (cbp[cnt]) != allowed_err))
+		  {
+		    error (0, aio_error64 (cbp[cnt]), "Operation failed\n");
+		    result = 1;
+		  }
+		cbp[cnt] = NULL;
+	      }
+	  }
+    }
+  while (go_on);
+
+  return result;
+}
+
+
+int
+do_test (int argc, char *argv[])
+{
+  struct aiocb64 cbs[10];
+  struct aiocb64 cbs_fsync;
+  struct aiocb64 *cbp[10];
+  struct aiocb64 *cbp_fsync[1];
+  char buf[1000];
+  size_t cnt;
+  int result = 0;
+
+  /* Preparation.  */
+  for (cnt = 0; cnt < 10; ++cnt)
+    {
+      cbs[cnt].aio_fildes = fd;
+      cbs[cnt].aio_reqprio = 0;
+      cbs[cnt].aio_buf = memset (&buf[cnt * 100], '0' + cnt, 100);
+      cbs[cnt].aio_nbytes = 100;
+      cbs[cnt].aio_offset = cnt * 100;
+      cbs[cnt].aio_sigevent.sigev_notify = SIGEV_NONE;
+
+      cbp[cnt] = &cbs[cnt];
+    }
+
+  /* First a simple test.  */
+  for (cnt = 10; cnt > 0; )
+    if (aio_write64 (cbp[--cnt]) < 0 && errno == ENOSYS)
+      {
+	error (0, 0, "no aio support in this configuration");
+	return 0;
+      }
+  /* Wait 'til the results are there.  */
+  result |= do_wait (cbp, 10, 0);
+  /* Test this.  */
+  result |= test_file (buf, sizeof (buf), fd, "aio_write");
+
+  /* Read now as we've written it.  */
+  memset (buf, '\0', sizeof (buf));
+  /* Issue the commands.  */
+  for (cnt = 10; cnt > 0; )
+    {
+      --cnt;
+      cbp[cnt] = &cbs[cnt];
+      aio_read64 (cbp[cnt]);
+    }
+  /* Wait 'til the results are there.  */
+  result |= do_wait (cbp, 10, 0);
+  /* Test this.  */
+  for (cnt = 0; cnt < 1000; ++cnt)
+    if (buf[cnt] != '0' + (cnt / 100))
+      {
+	result = 1;
+	error (0, 0, "comparison failed for aio_read test");
+	break;
+      }
+
+  if (cnt == 1000)
+    puts ("aio_read test ok");
+
+  /* Remove the test file contents.  */
+  if (ftruncate64 (fd, 0) < 0)
+    {
+      error (0, errno, "ftruncate failed\n");
+      result = 1;
+    }
+
+  /* Test lio_listio.  */
+  for (cnt = 0; cnt < 10; ++cnt)
+    {
+      cbs[cnt].aio_lio_opcode = LIO_WRITE;
+      cbp[cnt] = &cbs[cnt];
+    }
+  /* Issue the command.  */
+  lio_listio64 (LIO_WAIT, cbp, 10, NULL);
+  /* ...and immediately test it since we started it in wait mode.  */
+  result |= test_file (buf, sizeof (buf), fd, "lio_listio (write)");
+
+  /* Test aio_fsync.  */
+  cbs_fsync.aio_fildes = fd;
+  cbs_fsync.aio_sigevent.sigev_notify = SIGEV_NONE;
+  cbp_fsync[0] = &cbs_fsync;
+
+  /* Remove the test file contents first.  */
+  if (ftruncate64 (fd, 0) < 0)
+    {
+      error (0, errno, "ftruncate failed\n");
+      result = 1;
+    }
+
+  /* Write again.  */
+  for (cnt = 10; cnt > 0; )
+    aio_write64 (cbp[--cnt]);
+
+  if (aio_fsync64 (O_SYNC, &cbs_fsync) < 0)
+    {
+      error (0, errno, "aio_fsync failed\n");
+      result = 1;
+    }
+  result |= do_wait (cbp_fsync, 1, 0);
+
+  /* ...and test since all data should be on disk now.  */
+  result |= test_file (buf, sizeof (buf), fd, "aio_fsync (aio_write)");
+
+  /* Test aio_cancel.  */
+  /* Remove the test file contents first.  */
+  if (ftruncate64 (fd, 0) < 0)
+    {
+      error (0, errno, "ftruncate failed\n");
+      result = 1;
+    }
+
+  /* Write again.  */
+  for (cnt = 10; cnt > 0; )
+    aio_write64 (cbp[--cnt]);
+
+  /* Cancel all requests.  */
+  if (aio_cancel64 (fd, NULL) == -1)
+    printf ("aio_cancel64 (fd, NULL) cannot cancel anything\n");
+
+  result |= do_wait (cbp, 10, ECANCELED);
+
+  /* Another test for aio_cancel.  */
+  /* Remove the test file contents first.  */
+  if (ftruncate64 (fd, 0) < 0)
+    {
+      error (0, errno, "ftruncate failed\n");
+      result = 1;
+    }
+
+  /* Write again.  */
+  for (cnt = 10; cnt > 0; )
+    {
+      --cnt;
+      cbp[cnt] = &cbs[cnt];
+      aio_write64 (cbp[cnt]);
+    }
+  puts ("finished3");
+
+  /* Cancel all requests.  */
+  for (cnt = 10; cnt > 0; )
+    if (aio_cancel64 (fd, cbp[--cnt]) == -1)
+      /* This is not an error.  The request can simply be finished.  */
+      printf ("aio_cancel64 (fd, cbp[%Zd]) cannot be canceled\n", cnt);
+  puts ("finished2");
+
+  result |= do_wait (cbp, 10, ECANCELED);
+
+  puts ("finished");
+
+  return result;
+}
Index: trunk/src/libctests/glibc/rt/tst-aio7.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-aio7.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-aio7.c	(revision 2036)
@@ -0,0 +1,192 @@
+/* Test for AIO POSIX compliance.
+   Copyright (C) 2001,02, 03 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <aio.h>
+#include <error.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+/* We might wait for 3 seconds, so increase timeout to 10 seconds.  */
+#define TIMEOUT 10
+
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+  int result = 0;
+  int piped[2];
+
+  /* Make a pipe that we will never write to, so we can block reading it.  */
+  if (pipe (piped) < 0)
+    {
+      perror ("pipe");
+      return 1;
+    }
+
+  /* Test for aio_cancel() detecting invalid file descriptor.  */
+  {
+    struct aiocb cb;
+    int fd = -1;
+
+    cb.aio_fildes = fd;
+    cb.aio_offset = 0;
+    cb.aio_buf = NULL;
+    cb.aio_nbytes = 0;
+    cb.aio_reqprio = 0;
+    cb.aio_sigevent.sigev_notify = SIGEV_NONE;
+
+    errno = 0;
+
+    /* Case one: invalid fds that match.  */
+    if (aio_cancel (fd, &cb) != -1 || errno != EBADF)
+      {
+	if (errno == ENOSYS)
+	  {
+	    puts ("no aio support in this configuration");
+	    return 0;
+	  }
+
+	puts ("aio_cancel( -1, {-1..} ) did not return -1 or errno != EBADF");
+	++result;
+      }
+
+    cb.aio_fildes = -2;
+    errno = 0;
+
+    /* Case two: invalid fds that do not match; just print warning.  */
+    if (aio_cancel (fd, &cb) != -1 || errno != EBADF)
+      puts ("aio_cancel( -1, {-2..} ) did not return -1 or errno != EBADF");
+  }
+
+  /* Test for aio_fsync() detecting bad fd, and fd not open for writing.  */
+  {
+    struct aiocb cb;
+    int fd = -1;
+
+    cb.aio_fildes = fd;
+    cb.aio_offset = 0;
+    cb.aio_buf = NULL;
+    cb.aio_nbytes = 0;
+    cb.aio_reqprio = 0;
+    cb.aio_sigevent.sigev_notify = SIGEV_NONE;
+
+    errno = 0;
+
+    /* Case one: invalid fd.  */
+    if (aio_fsync (O_SYNC, &cb) != -1 || errno != EBADF)
+      {
+	puts ("aio_fsync( op, {-1..} ) did not return -1 or errno != EBADF");
+	++result;
+      }
+
+    if ((fd = open ("/dev/null", O_RDONLY)) < 0)
+      error (1, errno, "opening /dev/null");
+
+    cb.aio_fildes = fd;
+    errno = 0;
+
+    /* Case two: valid fd but open for read only.  */
+    if (aio_fsync (O_SYNC, &cb) != -1 || errno != EBADF)
+      {
+	puts ("aio_fsync( op, {RO..} ) did not return -1 or errno != EBADF");
+	++result;
+      }
+
+    close (fd);
+  }
+
+  /* Test for aio_suspend() suspending even if completed elements in list.  */
+  {
+#define BYTES 8
+    const int ELEMS = 2;
+    int i, r, fd;
+    static char buff[BYTES];
+    char name[] = "/tmp/aio7.XXXXXX";
+    struct timespec timeout;
+    static struct aiocb cb0, cb1;
+    struct aiocb *list[ELEMS];
+
+    fd = mkstemp (name);
+    if (fd < 0)
+      error (1, errno, "creating temp file");
+
+    if (unlink (name))
+      error (1, errno, "unlinking temp file");
+
+    if (write (fd, "01234567", BYTES) != BYTES)
+      error (1, errno, "writing to temp file");
+
+    cb0.aio_fildes = fd;
+    cb0.aio_offset = 0;
+    cb0.aio_buf = buff;
+    cb0.aio_nbytes = BYTES;
+    cb0.aio_reqprio = 0;
+    cb0.aio_sigevent.sigev_notify = SIGEV_NONE;
+
+    r = aio_read (&cb0);
+    if (r != 0)
+      error (1, errno, "reading from file");
+
+    while (aio_error (&(cb0)) == EINPROGRESS)
+      usleep (10);
+
+    for (i = 0; i < BYTES; i++)
+      printf ("%c ", buff[i]);
+    printf ("\n");
+
+    /* At this point, the first read is completed, so start another one on
+       the read half of a pipe on which nothing will be written.  */
+    cb1.aio_fildes = piped[0];
+    cb1.aio_offset = 0;
+    cb1.aio_buf = buff;
+    cb1.aio_nbytes = BYTES;
+    cb1.aio_reqprio = 0;
+    cb1.aio_sigevent.sigev_notify = SIGEV_NONE;
+
+    r = aio_read (&cb1);
+    if (r != 0)
+      error (1, errno, "reading from file");
+
+    /* Now call aio_suspend() with the two reads.  It should return
+     * immediately according to the POSIX spec.
+     */
+    list[0] = &cb0;
+    list[1] = &cb1;
+    timeout.tv_sec = 3;
+    timeout.tv_nsec = 0;
+    r = aio_suspend ((const struct aiocb * const *) list, ELEMS, &timeout);
+
+    if (r == -1 && errno == EAGAIN)
+      {
+	puts ("aio_suspend([done,blocked],2,3) suspended thread");
+	++result;
+      }
+
+    /* Note that CB1 is still pending, and so cannot be an auto variable.
+       Thus we also test that exiting with an outstanding request works.  */
+  }
+
+  return result;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/rt/tst-clock.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-clock.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-clock.c	(revision 2036)
@@ -0,0 +1,124 @@
+/* Test program for POSIX clock_* functions.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+
+
+/* We want to see output immediately.  */
+#define STDOUT_UNBUFFERED
+
+/* We expect to run at least 10 seconds.  */
+#define TIMEOUT 15
+
+static int
+clock_test (clockid_t cl)
+{
+  struct timespec old_ts;
+  struct timespec ts;
+  struct timespec waitit;
+  int result = 0;
+  int i;
+
+  memset (&ts, '\0', sizeof ts);
+
+  waitit.tv_sec = 0;
+  waitit.tv_nsec = 500000000;
+
+  /* Get and print resolution of the clock.  */
+  if (clock_getres (cl, &ts) == 0)
+    {
+      if (ts.tv_nsec < 0 || ts.tv_nsec >= 1000000000)
+	{
+	  printf ("clock %d: nanosecond value of resolution wrong\n", cl);
+	  result = 1;
+	}
+      else
+	printf ("clock %d: resolution = %ld.%09ld secs\n",
+		cl, ts.tv_sec, ts.tv_nsec);
+    }
+  else
+    {
+      printf ("clock %d: cannot get resolution\n", cl);
+      result = 1;
+    }
+
+  memset (&ts, '\0', sizeof ts);
+  memset (&old_ts, '\0', sizeof old_ts);
+
+  /* Next get the current time value a few times.  */
+  for (i = 0; i < 10; ++i)
+    {
+      if (clock_gettime (cl, &ts) == 0)
+	{
+	  if (ts.tv_nsec < 0 || ts.tv_nsec >= 1000000000)
+	    {
+	      printf ("clock %d: nanosecond value of time wrong (try %d)\n",
+		      cl, i);
+	      result = 1;
+	    }
+	  else
+	    {
+	      printf ("clock %d: time = %ld.%09ld secs\n",
+		      cl, ts.tv_sec, ts.tv_nsec);
+
+	      if (memcmp (&ts, &old_ts, sizeof ts) == 0)
+		{
+		  printf ("clock %d: time hasn't changed (try %d)\n", cl, i);
+		  result = 1;
+
+		  old_ts = ts;
+		}
+	    }
+	}
+      else
+	{
+	  printf ("clock %d: cannot get time (try %d)\n", cl, i);
+	  result = 1;
+	}
+
+      /* Wait a bit before the next iteration.  */
+      nanosleep (&waitit, NULL);
+    }
+
+  return result;
+}
+
+static int
+do_test (void)
+{
+  clockid_t cl;
+  int result;
+
+  result = clock_test (CLOCK_REALTIME);
+
+  if (clock_getcpuclockid (0, &cl) == 0)
+    /* XXX It's not yet a bug when this fails.  */
+    clock_test (cl);
+  else
+	  printf("CPU clock unavailble, skipping test\n");
+
+  return result;
+}
+#define TEST_FUNCTION do_test ()
+
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/rt/tst-clock_nanosleep.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-clock_nanosleep.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-clock_nanosleep.c	(revision 2036)
@@ -0,0 +1,58 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <time.h>
+
+
+/* Test that clock_nanosleep() does sleep.  */
+static int
+do_test (void)
+{
+  /* Current time.  */
+  struct timeval tv1;
+  (void) gettimeofday (&tv1, NULL);
+
+  struct timespec ts;
+  ts.tv_sec = 1;
+  ts.tv_nsec = 0;
+  TEMP_FAILURE_RETRY (clock_nanosleep (CLOCK_REALTIME, 0, &ts, &ts));
+
+  /* At least one second must have passed.  */
+  struct timeval tv2;
+  (void) gettimeofday (&tv2, NULL);
+
+  tv2.tv_sec -= tv1.tv_sec;
+  tv2.tv_usec -= tv1.tv_usec;
+  if (tv2.tv_usec < 0)
+    --tv2.tv_sec;
+
+  if (tv2.tv_sec < 1)
+    {
+      puts ("clock_nanosleep didn't sleep long enough");
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/rt/tst-cpuclock1.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-cpuclock1.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-cpuclock1.c	(revision 2036)
@@ -0,0 +1,307 @@
+/* Test program for process CPU clocks.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <signal.h>
+#include <sys/wait.h>
+
+/* This function is intended to rack up both user and system time.  */
+static void
+chew_cpu (void)
+{
+  while (1)
+    {
+      static volatile char buf[4096];
+      for (int i = 0; i < 100; ++i)
+	for (size_t j = 0; j < sizeof buf; ++j)
+	  buf[j] = 0xaa;
+      int nullfd = open ("/dev/null", O_WRONLY);
+      for (int i = 0; i < 100; ++i)
+	for (size_t j = 0; j < sizeof buf; ++j)
+	  buf[j] = 0xbb;
+      write (nullfd, (char *) buf, sizeof buf);
+      close (nullfd);
+      if (getppid () == 1)
+	_exit (2);
+    }
+}
+
+static int
+do_test (void)
+{
+  int result = 0;
+  clockid_t cl;
+  int e;
+  pid_t dead_child, child;
+
+  /* Fork a child and let it die, to give us a PID known not be valid
+     (assuming PIDs don't wrap around during the test).  */
+  {
+    dead_child = fork ();
+    if (dead_child == 0)
+      _exit (0);
+    if (dead_child < 0)
+      {
+	perror ("fork");
+	return 1;
+      }
+    int x;
+    if (wait (&x) != dead_child)
+      {
+	perror ("wait");
+	return 2;
+      }
+  }
+
+  /* POSIX says we should get ESRCH for this.  */
+  e = clock_getcpuclockid (dead_child, &cl);
+  if (e != ENOSYS && e != ESRCH && e != EPERM)
+    {
+      printf ("clock_getcpuclockid on dead PID %d => %s\n",
+	      dead_child, strerror (e));
+      result = 1;
+    }
+
+  /* Now give us a live child eating up CPU time.  */
+  child = fork ();
+  if (child == 0)
+    {
+      chew_cpu ();
+      _exit (1);
+    }
+  if (child < 0)
+    {
+      perror ("fork");
+      return 1;
+    }
+
+  e = clock_getcpuclockid (child, &cl);
+  if (e == EPERM)
+    {
+      puts ("clock_getcpuclockid does not support other processes");
+      goto done;
+    }
+  if (e != 0)
+    {
+      printf ("clock_getcpuclockid on live PID %d => %s\n",
+	      child, strerror (e));
+      result = 1;
+      goto done;
+    }
+
+  const clockid_t child_clock = cl;
+  struct timespec res;
+  if (clock_getres (child_clock, &res) < 0)
+    {
+      printf ("clock_getres on live PID %d clock %lx => %s\n",
+	      child, (unsigned long int) child_clock, strerror (errno));
+      result = 1;
+      goto done;
+    }
+  printf ("live PID %d clock %lx resolution %lu.%.9lu\n",
+	  child, (unsigned long int) child_clock, res.tv_sec, res.tv_nsec);
+
+  struct timespec before, after;
+  if (clock_gettime (child_clock, &before) < 0)
+    {
+      printf ("clock_gettime on live PID %d clock %lx => %s\n",
+	      child, (unsigned long int) child_clock, strerror (errno));
+      result = 1;
+      goto done;
+    }
+  printf ("live PID %d before sleep => %lu.%.9lu\n",
+	  child, before.tv_sec, before.tv_nsec);
+
+  struct timespec sleeptime = { .tv_nsec = 500000000 };
+  nanosleep (&sleeptime, NULL);
+
+  if (clock_gettime (child_clock, &after) < 0)
+    {
+      printf ("clock_gettime on live PID %d clock %lx => %s\n",
+	      child, (unsigned long int) child_clock, strerror (errno));
+      result = 1;
+      goto done;
+    }
+  printf ("live PID %d after sleep => %lu.%.9lu\n",
+	  child, after.tv_sec, after.tv_nsec);
+
+  struct timespec diff = { .tv_sec = after.tv_sec - before.tv_sec,
+			   .tv_nsec = after.tv_nsec - before.tv_nsec };
+  if (diff.tv_nsec < 0)
+    {
+      --diff.tv_sec;
+      diff.tv_nsec += 1000000000;
+    }
+  if (diff.tv_sec != 0
+      || diff.tv_nsec > 600000000
+      || diff.tv_nsec < 100000000)
+    {
+      printf ("before - after %lu.%.9lu outside reasonable range\n",
+	      diff.tv_sec, diff.tv_nsec);
+      result = 1;
+    }
+
+  sleeptime.tv_nsec = 100000000;
+  e = clock_nanosleep (child_clock, 0, &sleeptime, NULL);
+  if (e == EINVAL || e == ENOTSUP || e == ENOSYS)
+    {
+      printf ("clock_nanosleep not supported for other process clock: %s\n",
+	      strerror (e));
+    }
+  else if (e != 0)
+    {
+      printf ("clock_nanosleep on other process clock: %s\n", strerror (e));
+      result = 1;
+    }
+  else
+    {
+      struct timespec afterns;
+      if (clock_gettime (child_clock, &afterns) < 0)
+	{
+	  printf ("clock_gettime on live PID %d clock %lx => %s\n",
+		  child, (unsigned long int) child_clock, strerror (errno));
+	  result = 1;
+	}
+      else
+	{
+	  struct timespec d = { .tv_sec = afterns.tv_sec - after.tv_sec,
+				.tv_nsec = afterns.tv_nsec - after.tv_nsec };
+	  if (d.tv_nsec < 0)
+	    {
+	      --d.tv_sec;
+	      d.tv_nsec += 1000000000;
+	    }
+	  if (d.tv_sec > 0
+	      || d.tv_nsec < sleeptime.tv_nsec
+	      || d.tv_nsec > sleeptime.tv_nsec * 2)
+	    {
+	      printf ("nanosleep time %lu.%.9lu outside reasonable range\n",
+		      d.tv_sec, d.tv_nsec);
+	      result = 1;
+	    }
+	}
+    }
+
+  if (kill (child, SIGKILL) != 0)
+    {
+      perror ("kill");
+      result = 2;
+      goto done;
+    }
+
+  /* Wait long enough to let the child finish dying.  */
+
+  sleeptime.tv_nsec = 200000000;
+  nanosleep (&sleeptime, NULL);
+
+  struct timespec dead;
+  if (clock_gettime (child_clock, &dead) < 0)
+    {
+      printf ("clock_gettime on dead PID %d clock %lx => %s\n",
+	      child, (unsigned long int) child_clock, strerror (errno));
+      result = 1;
+      goto done;
+    }
+  printf ("dead PID %d => %lu.%.9lu\n",
+	  child, dead.tv_sec, dead.tv_nsec);
+
+  diff.tv_sec = dead.tv_sec - after.tv_sec;
+  diff.tv_nsec = dead.tv_nsec - after.tv_nsec;
+  if (diff.tv_nsec < 0)
+    {
+      --diff.tv_sec;
+      diff.tv_nsec += 1000000000;
+    }
+  if (diff.tv_sec != 0 || diff.tv_nsec > 200000000)
+    {
+      printf ("dead - after %lu.%.9lu outside reasonable range\n",
+	      diff.tv_sec, diff.tv_nsec);
+      result = 1;
+    }
+
+  /* Now reap the child and verify that its clock is no longer valid.  */
+  {
+    int x;
+    if (waitpid (child, &x, 0) != child)
+      {
+	perror ("waitpid");
+	result = 1;
+      }
+  }
+
+  if (clock_gettime (child_clock, &dead) == 0)
+    {
+      printf ("clock_gettime on reaped PID %d clock %lx => %lu%.9lu\n",
+	      child, (unsigned long int) child_clock,
+	      dead.tv_sec, dead.tv_nsec);
+      result = 1;
+    }
+  else
+    {
+      if (errno != EINVAL)
+	result = 1;
+      printf ("clock_gettime on reaped PID %d clock %lx => %s\n",
+	      child, (unsigned long int) child_clock, strerror (errno));
+    }
+
+  if (clock_getres (child_clock, &dead) == 0)
+    {
+      printf ("clock_getres on reaped PID %d clock %lx => %lu%.9lu\n",
+	      child, (unsigned long int) child_clock,
+	      dead.tv_sec, dead.tv_nsec);
+      result = 1;
+    }
+  else
+    {
+      if (errno != EINVAL)
+	result = 1;
+      printf ("clock_getres on reaped PID %d clock %lx => %s\n",
+	      child, (unsigned long int) child_clock, strerror (errno));
+    }
+
+  return result;
+
+ done:
+  {
+    if (kill (child, SIGKILL) != 0 && errno != ESRCH)
+      {
+	perror ("kill");
+	return 2;
+      }
+    int x;
+    if (waitpid (child, &x, 0) != child && errno != ECHILD)
+      {
+	perror ("waitpid");
+	return 2;
+      }
+  }
+
+  return result;
+}
+
+
+#define TIMEOUT 5
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/rt/tst-cpuclock2.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-cpuclock2.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-cpuclock2.c	(revision 2036)
@@ -0,0 +1,332 @@
+/* Test program for process and thread CPU clocks.
+   Copyright (C) 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <unistd.h>
+
+#if (_POSIX_THREADS - 0) <= 0
+
+# define TEST_FUNCTION 0
+
+#else
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <pthread.h>
+
+static pthread_barrier_t barrier;
+
+/* This function is intended to rack up both user and system time.  */
+static void *
+chew_cpu (void *arg)
+{
+  pthread_barrier_wait (&barrier);
+
+  while (1)
+    {
+      static volatile char buf[4096];
+      for (int i = 0; i < 100; ++i)
+	for (size_t j = 0; j < sizeof buf; ++j)
+	  buf[j] = 0xaa;
+      int nullfd = open ("/dev/null", O_WRONLY);
+      for (int i = 0; i < 100; ++i)
+	for (size_t j = 0; j < sizeof buf; ++j)
+	  buf[j] = 0xbb;
+      write (nullfd, (char *) buf, sizeof buf);
+      close (nullfd);
+    }
+
+  return NULL;
+}
+
+static unsigned long long int
+tsdiff (const struct timespec *before, const struct timespec *after)
+{
+  struct timespec diff = { .tv_sec = after->tv_sec - before->tv_sec,
+			   .tv_nsec = after->tv_nsec - before->tv_nsec };
+  while (diff.tv_nsec < 0)
+    {
+      --diff.tv_sec;
+      diff.tv_nsec += 1000000000;
+    }
+  return diff.tv_sec * 1000000000ULL + diff.tv_nsec;
+}
+
+static unsigned long long int
+test_nanosleep (clockid_t clock, const char *which,
+		const struct timespec *before, int *bad)
+{
+  const struct timespec sleeptime = { .tv_nsec = 100000000 };
+  int e = clock_nanosleep (clock, 0, &sleeptime, NULL);
+  if (e == EINVAL || e == ENOTSUP || e == ENOSYS)
+    {
+      printf ("clock_nanosleep not supported for %s CPU clock: %s\n",
+	      which, strerror (e));
+      return 0;
+    }
+  if (e != 0)
+    {
+      printf ("clock_nanosleep on %s CPU clock: %s\n", which, strerror (e));
+      *bad = 1;
+      return 0;
+    }
+
+  struct timespec after;
+  if (clock_gettime (clock, &after) < 0)
+    {
+      printf ("clock_gettime on %s CPU clock %lx => %s\n",
+	      which, (unsigned long int) clock, strerror (errno));
+      *bad = 1;
+      return 0;
+    }
+
+  unsigned long long int diff = tsdiff (before, &after);
+  if (diff < sleeptime.tv_nsec || diff > sleeptime.tv_nsec * 2)
+    {
+      printf ("clock_nanosleep on %s slept %llu (outside reasonable range)\n",
+	      which, diff);
+      *bad = 1;
+      return diff;
+    }
+
+  struct timespec sleeptimeabs = sleeptime;
+  sleeptimeabs.tv_sec += after.tv_sec;
+  sleeptimeabs.tv_nsec += after.tv_nsec;
+  while (sleeptimeabs.tv_nsec > 1000000000)
+    {
+      ++sleeptimeabs.tv_sec;
+      sleeptimeabs.tv_nsec -= 1000000000;
+    }
+  e = clock_nanosleep (clock, TIMER_ABSTIME, &sleeptimeabs, NULL);
+  if (e != 0)
+    {
+      printf ("absolute clock_nanosleep on %s CPU clock: %s\n",
+	      which, strerror (e));
+      *bad = 1;
+      return diff;
+    }
+
+  struct timespec afterabs;
+  if (clock_gettime (clock, &afterabs) < 0)
+    {
+      printf ("clock_gettime on %s CPU clock %lx => %s\n",
+	      which, (unsigned long int) clock, strerror (errno));
+      *bad = 1;
+      return diff;
+    }
+
+  unsigned long long int sleepdiff = tsdiff (&sleeptimeabs, &afterabs);
+  if (sleepdiff > sleeptime.tv_nsec)
+    {
+      printf ("\
+absolute clock_nanosleep on %s %llu past target (outside reasonable range)\n",
+	      which, sleepdiff);
+      *bad = 1;
+    }
+
+  unsigned long long int diffabs = tsdiff (&after, &afterabs);
+  if (diffabs < sleeptime.tv_nsec || diffabs > sleeptime.tv_nsec * 2)
+    {
+      printf ("\
+absolute clock_nanosleep on %s slept %llu (outside reasonable range)\n",
+	      which, diffabs);
+      *bad = 1;
+    }
+
+  return diff + diffabs;
+}
+
+
+
+static int
+do_test (void)
+{
+  int result = 0;
+  clockid_t process_clock, th_clock, my_thread_clock;
+  int e;
+  pthread_t th;
+
+  e = clock_getcpuclockid (0, &process_clock);
+  if (e != 0)
+    {
+      printf ("clock_getcpuclockid on self => %s\n", strerror (e));
+      return 1;
+    }
+
+  e = pthread_getcpuclockid (pthread_self (), &my_thread_clock);
+  if (e != 0)
+    {
+      printf ("pthread_getcpuclockid on self => %s\n", strerror (e));
+      return 1;
+    }
+
+  /* This is a kludge.  This test fails if the semantics of thread and
+     process clocks are wrong.  The old code using hp-timing without kernel
+     support has bogus semantics if there are context switches.  We don't
+     fail to report failure when the proper functionality is not available
+     in the kernel.  It so happens that Linux kernels without correct CPU
+     clock support also lack CPU timer support, so we use use that to guess
+     that we are using the bogus code and not test it.  */
+  timer_t t;
+  if (timer_create (my_thread_clock, NULL, &t) != 0)
+    {
+      printf ("timer_create: %m\n");
+      puts ("No support for CPU clocks with good semantics, skipping test");
+      return 0;
+    }
+  timer_delete (t);
+
+
+  pthread_barrier_init (&barrier, NULL, 2);
+
+  e = pthread_create (&th, NULL, chew_cpu, NULL);
+  if (e != 0)
+    {
+      printf ("pthread_create: %s\n", strerror (e));
+      return 1;
+    }
+
+  e = pthread_getcpuclockid (th, &th_clock);
+  if (e == ENOENT || e == ENOSYS || e == ENOTSUP)
+    {
+      puts ("pthread_getcpuclockid does not support other threads");
+      return 1;
+    }
+
+  pthread_barrier_wait (&barrier);
+
+  struct timespec res;
+  if (clock_getres (th_clock, &res) < 0)
+    {
+      printf ("clock_getres on thread clock %lx => %s\n",
+	      (unsigned long int) th_clock, strerror (errno));
+      result = 1;
+      return 1;
+    }
+  printf ("live thread clock %lx resolution %lu.%.9lu\n",
+	  (unsigned long int) th_clock, res.tv_sec, res.tv_nsec);
+
+  struct timespec process_before, process_after;
+  if (clock_gettime (process_clock, &process_before) < 0)
+    {
+      printf ("clock_gettime on process clock %lx => %s\n",
+	      (unsigned long int) th_clock, strerror (errno));
+      return 1;
+    }
+
+  struct timespec before, after;
+  if (clock_gettime (th_clock, &before) < 0)
+    {
+      printf ("clock_gettime on live thread clock %lx => %s\n",
+	      (unsigned long int) th_clock, strerror (errno));
+      return 1;
+    }
+  printf ("live thread before sleep => %lu.%.9lu\n",
+	  before.tv_sec, before.tv_nsec);
+
+  struct timespec me_before, me_after;
+  if (clock_gettime (my_thread_clock, &me_before) < 0)
+    {
+      printf ("clock_gettime on live thread clock %lx => %s\n",
+	      (unsigned long int) th_clock, strerror (errno));
+      return 1;
+    }
+  printf ("self thread before sleep => %lu.%.9lu\n",
+	  me_before.tv_sec, me_before.tv_nsec);
+
+  struct timespec sleeptime = { .tv_nsec = 500000000 };
+  nanosleep (&sleeptime, NULL);
+
+  if (clock_gettime (th_clock, &after) < 0)
+    {
+      printf ("clock_gettime on live thread clock %lx => %s\n",
+	      (unsigned long int) th_clock, strerror (errno));
+      return 1;
+    }
+  printf ("live thread after sleep => %lu.%.9lu\n",
+	  after.tv_sec, after.tv_nsec);
+
+  if (clock_gettime (process_clock, &process_after) < 0)
+    {
+      printf ("clock_gettime on process clock %lx => %s\n",
+	      (unsigned long int) th_clock, strerror (errno));
+      return 1;
+    }
+
+  if (clock_gettime (my_thread_clock, &me_after) < 0)
+    {
+      printf ("clock_gettime on live thread clock %lx => %s\n",
+	      (unsigned long int) th_clock, strerror (errno));
+      return 1;
+    }
+  printf ("self thread after sleep => %lu.%.9lu\n",
+	  me_after.tv_sec, me_after.tv_nsec);
+
+  unsigned long long int th_diff = tsdiff (&before, &after);
+  unsigned long long int pdiff = tsdiff (&process_before, &process_after);
+  unsigned long long int my_diff = tsdiff (&me_before, &me_after);
+
+  if (th_diff < 100000000 || th_diff > 600000000)
+    {
+      printf ("thread before - after %llu outside reasonable range\n",
+	      th_diff);
+      result = 1;
+    }
+
+  if (my_diff > 100000000)
+    {
+      printf ("self thread before - after %llu outside reasonable range\n",
+	      my_diff);
+      result = 1;
+    }
+
+  if (pdiff < th_diff)
+    {
+      printf ("process before - after %llu outside reasonable range (%llu)\n",
+	      pdiff, th_diff);
+      result = 1;
+    }
+
+  process_after.tv_nsec += test_nanosleep (th_clock, "thread",
+					   &after, &result);
+  process_after.tv_nsec += test_nanosleep (process_clock, "process",
+					   &process_after, &result);
+  test_nanosleep (CLOCK_PROCESS_CPUTIME_ID,
+		  "PROCESS_CPUTIME_ID", &process_after, &result);
+
+  pthread_cancel (th);
+
+  e = clock_nanosleep (CLOCK_THREAD_CPUTIME_ID, 0, &sleeptime, NULL);
+  if (e != EINVAL)
+    {
+      printf ("clock_nanosleep CLOCK_THREAD_CPUTIME_ID: %s\n",
+	      strerror (e));
+      result = 1;
+    }
+
+  return result;
+}
+# define TIMEOUT 8
+# define TEST_FUNCTION do_test ()
+#endif
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/rt/tst-cputimer1.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-cputimer1.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-cputimer1.c	(revision 2036)
@@ -0,0 +1,68 @@
+/* Tests for POSIX timer implementation using process CPU clock.  */
+
+#include <unistd.h>
+
+#if _POSIX_THREADS && defined _POSIX_CPUTIME
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <time.h>
+#include <pthread.h>
+
+#define TEST_CLOCK CLOCK_PROCESS_CPUTIME_ID
+#define TEST_CLOCK_MISSING(clock) \
+  (setup_test () ? "process CPU clock timer support" : NULL)
+
+/* This function is intended to rack up both user and system time.  */
+static void *
+chew_cpu (void *arg)
+{
+  while (1)
+    {
+      static volatile char buf[4096];
+      for (int i = 0; i < 100; ++i)
+	for (size_t j = 0; j < sizeof buf; ++j)
+	  buf[j] = 0xaa;
+      int nullfd = open ("/dev/null", O_WRONLY);
+      for (int i = 0; i < 100; ++i)
+	for (size_t j = 0; j < sizeof buf; ++j)
+	  buf[j] = 0xbb;
+      write (nullfd, (char *) buf, sizeof buf);
+      close (nullfd);
+    }
+
+  return NULL;
+}
+
+static int
+setup_test (void)
+{
+  /* Test timers on our own process CPU clock by having a worker thread
+     eating CPU.  First make sure we can make such timers at all.  */
+
+  timer_t t;
+  if (timer_create (TEST_CLOCK, NULL, &t) != 0)
+    {
+      printf ("timer_create: %m\n");
+      return 1;
+    }
+  timer_delete (t);
+
+  pthread_t th;
+  int e = pthread_create (&th, NULL, chew_cpu, NULL);
+  if (e != 0)
+    {
+      printf ("pthread_create: %s\n", strerror (e));
+      exit (1);
+    }
+
+  return 0;
+}
+
+#else
+# define TEST_CLOCK_MISSING(clock) "process clocks"
+#endif
+
+#include "tst-timer4.c"
Index: trunk/src/libctests/glibc/rt/tst-cputimer2.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-cputimer2.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-cputimer2.c	(revision 2036)
@@ -0,0 +1,83 @@
+/* Tests for POSIX timer implementation using thread CPU clock.  */
+
+#include <unistd.h>
+
+#if _POSIX_THREADS && defined _POSIX_CPUTIME
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <time.h>
+#include <pthread.h>
+
+static clockid_t worker_thread_clock;
+
+#define TEST_CLOCK worker_thread_clock
+#define TEST_CLOCK_MISSING(clock) \
+  (setup_test () ? "thread CPU clock timer support" : NULL)
+
+/* This function is intended to rack up both user and system time.  */
+static void *
+chew_cpu (void *arg)
+{
+  while (1)
+    {
+      static volatile char buf[4096];
+      for (int i = 0; i < 100; ++i)
+	for (size_t j = 0; j < sizeof buf; ++j)
+	  buf[j] = 0xaa;
+      int nullfd = open ("/dev/null", O_WRONLY);
+      for (int i = 0; i < 100; ++i)
+	for (size_t j = 0; j < sizeof buf; ++j)
+	  buf[j] = 0xbb;
+      write (nullfd, (char *) buf, sizeof buf);
+      close (nullfd);
+    }
+
+  return NULL;
+}
+
+static int
+setup_test (void)
+{
+  /* Test timers on a thread CPU clock by having a worker thread eating
+     CPU.  First make sure we can make such timers at all.  */
+
+  pthread_t th;
+  int e = pthread_create (&th, NULL, chew_cpu, NULL);
+  if (e != 0)
+    {
+      printf ("pthread_create: %s\n", strerror (e));
+      exit (1);
+    }
+
+  e = pthread_getcpuclockid (th, &worker_thread_clock);
+  if (e == EPERM || e == ENOENT || e == ENOTSUP)
+    {
+      puts ("pthread_getcpuclockid does not support other threads");
+      return 1;
+    }
+  if (e != 0)
+    {
+      printf ("pthread_getcpuclockid: %s\n", strerror (e));
+      exit (1);
+    }
+
+  timer_t t;
+  if (timer_create (TEST_CLOCK, NULL, &t) != 0)
+    {
+      printf ("timer_create: %m\n");
+      return 1;
+    }
+  timer_delete (t);
+
+  return 0;
+}
+
+#else
+# define TEST_CLOCK_MISSING(clock) "process clocks"
+#endif
+
+#include "tst-timer4.c"
Index: trunk/src/libctests/glibc/rt/tst-cputimer3.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-cputimer3.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-cputimer3.c	(revision 2036)
@@ -0,0 +1,130 @@
+/* Tests for POSIX timer implementation using another process's CPU clock.  */
+
+#include <unistd.h>
+
+#if _POSIX_THREADS && defined _POSIX_CPUTIME
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <time.h>
+#include <signal.h>
+#include <sys/wait.h>
+
+static clockid_t child_clock;
+
+#define TEST_CLOCK child_clock
+#define TEST_CLOCK_MISSING(clock) \
+  (setup_test () ? "other-process CPU clock timer support" : NULL)
+
+/* This function is intended to rack up both user and system time.  */
+static void
+chew_cpu (void)
+{
+  while (1)
+    {
+      static volatile char buf[4096];
+      for (int i = 0; i < 100; ++i)
+	for (size_t j = 0; j < sizeof buf; ++j)
+	  buf[j] = 0xaa;
+      int nullfd = open ("/dev/null", O_WRONLY);
+      for (int i = 0; i < 100; ++i)
+	for (size_t j = 0; j < sizeof buf; ++j)
+	  buf[j] = 0xbb;
+      write (nullfd, (char *) buf, sizeof buf);
+      close (nullfd);
+      if (getppid () == 1)
+	_exit (2);
+    }
+}
+
+static pid_t child;
+static void
+cleanup_child (void)
+{
+  if (child <= 0)
+    return;
+  if (kill (child, SIGKILL) < 0 && errno != ESRCH)
+    printf ("cannot kill child %d: %m\n", child);
+  else
+    {
+      int status;
+      errno = 0;
+      if (waitpid (child, &status, 0) != child)
+	printf ("waitpid %d: %m\n", child);
+    }
+}
+#define CLEANUP_HANDLER cleanup_child ()
+
+static int
+setup_test (void)
+{
+  /* Test timers on a process CPU clock by having a child process eating
+     CPU.  First make sure we can make such timers at all.  */
+
+  int pipefd[2];
+  if (pipe (pipefd) < 0)
+    {
+      printf ("pipe: %m\n");
+      exit (1);
+    }
+
+  child = fork ();
+
+  if (child == 0)
+    {
+      char c;
+      close (pipefd[1]);
+      if (read (pipefd[0], &c, 1) == 1)
+	chew_cpu ();
+      _exit (1);
+    }
+
+  if (child < 0)
+    {
+      printf ("fork: %m\n");
+      exit (1);
+    }
+
+  atexit (&cleanup_child);
+
+  close (pipefd[0]);
+
+  int e = clock_getcpuclockid (child, &child_clock);
+  if (e == EPERM)
+    {
+      puts ("clock_getcpuclockid does not support other processes");
+      return 1;
+    }
+  if (e != 0)
+    {
+      printf ("clock_getcpuclockid: %s\n", strerror (e));
+      exit (1);
+    }
+
+  timer_t t;
+  if (timer_create (TEST_CLOCK, NULL, &t) != 0)
+    {
+      printf ("timer_create: %m\n");
+      return 1;
+    }
+  timer_delete (t);
+
+  /* Get the child started chewing.  */
+  if (write (pipefd[1], "x", 1) != 1)
+    {
+      printf ("write to pipe: %m\n");
+      return 1;
+    }
+  close (pipefd[1]);
+
+  return 0;
+}
+
+#else
+# define TEST_CLOCK_MISSING(clock) "process clocks"
+#endif
+
+#include "tst-timer4.c"
Index: trunk/src/libctests/glibc/rt/tst-mqueue.h
===================================================================
--- trunk/src/libctests/glibc/rt/tst-mqueue.h	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-mqueue.h	(revision 2036)
@@ -0,0 +1,84 @@
+/* Common code for message queue passing tests.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <mqueue.h>
+#include <search.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/uio.h>
+#include <unistd.h>
+
+static int temp_mq_fd;
+
+/* Add temporary files in list.  */
+static void
+__attribute__ ((unused))
+add_temp_mq (const char *name)
+{
+  struct iovec iov[2];
+  iov[0].iov_base = (char *) name;
+  iov[0].iov_len = strlen (name);
+  iov[1].iov_base = (char *) "\n";
+  iov[1].iov_len = 1;
+  if (writev (temp_mq_fd, iov, 2) != iov[0].iov_len + 1)
+    printf ("Could not record temp mq filename %s\n", name);
+}
+
+/* Delete all temporary message queues.  */
+static void
+do_cleanup (void)
+{
+  if (lseek (temp_mq_fd, 0, SEEK_SET) != 0)
+    return;
+
+  FILE *f = fdopen (temp_mq_fd, "r");
+  if (f == NULL)
+    return;
+
+  char *line = NULL;
+  size_t n = 0;
+  ssize_t rets;
+  while ((rets = getline (&line, &n, f)) > 0)
+    {
+      if (line[rets - 1] != '\n')
+        continue;
+
+      line[rets - 1] = '\0';
+      mq_unlink (line);
+    }
+  fclose (f);
+}
+
+static void
+do_prepare (void)
+{
+  char name [] = "/tmp/tst-mqueueN.XXXXXX";
+  temp_mq_fd = mkstemp (name);
+  if (temp_mq_fd == -1)
+    {
+      printf ("Could not create temporary file %s: %m\n", name);
+      exit (1);
+    }
+  unlink (name);
+}
+
+#define PREPARE(argc, argv) do_prepare ()
+#define CLEANUP_HANDLER	do_cleanup ()
Index: trunk/src/libctests/glibc/rt/tst-mqueue1.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-mqueue1.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-mqueue1.c	(revision 2036)
@@ -0,0 +1,417 @@
+/* Test message queue passing.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <mqueue.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <time.h>
+#include <unistd.h>
+#include "tst-mqueue.h"
+
+static int
+intcmp (const void *a, const void *b)
+{
+  if (*(unsigned char *)a < *(unsigned char *)b)
+    return 1;
+  if (*(unsigned char *)a > *(unsigned char *)b)
+    return -1;
+  return 0;
+}
+
+static int
+check_attrs (struct mq_attr *attr, int nonblock, long cnt)
+{
+  int result = 0;
+
+  if (attr->mq_maxmsg != 10 || attr->mq_msgsize != 1)
+    {
+      printf ("attributes don't match those passed to mq_open\n"
+	      "mq_maxmsg %ld, mq_msgsize %ld\n",
+	      attr->mq_maxmsg, attr->mq_msgsize);
+      result = 1;
+    }
+
+  if ((attr->mq_flags & O_NONBLOCK) != nonblock)
+    {
+      printf ("mq_flags %lx != %x\n", (attr->mq_flags & O_NONBLOCK), nonblock);
+      result = 1;
+    }
+
+  if (attr->mq_curmsgs != cnt)
+    {
+      printf ("mq_curmsgs %ld != %ld\n", attr->mq_curmsgs, cnt);
+      result = 1;
+    }
+
+  return result;
+}
+
+static int
+do_one_test (mqd_t q, const char *name, int nonblock)
+{
+  int result = 0;
+
+  unsigned char v []
+    = { 0x32, 0x62, 0x22, 0x31, 0x11, 0x73, 0x61, 0x21, 0x72, 0x71, 0x81 };
+
+  struct mq_attr attr;
+  memset (&attr, 0xaa, sizeof (attr));
+  if (mq_getattr (q, &attr) != 0)
+    {
+      printf ("mq_getattr failed: %m\n");
+      result = 1;
+    }
+  else
+    result |= check_attrs (&attr, nonblock, 0);
+
+  if (mq_receive (q, &v[0], 1, NULL) != -1)
+    {
+      puts ("mq_receive on O_WRONLY mqd_t unexpectedly succeeded");
+      result = 1;
+    }
+  else if (errno != EBADF)
+    {
+      printf ("mq_receive on O_WRONLY mqd_t did not fail with EBADF: %m\n");
+      result = 1;
+    }
+
+  struct timespec ts;
+  if (clock_gettime (CLOCK_REALTIME, &ts) == 0)
+    --ts.tv_sec;
+  else
+    {
+      ts.tv_sec = time (NULL) - 1;
+      ts.tv_nsec = 0;
+    }
+
+  int ret;
+  for (int i = 0; i < 10; ++i)
+    {
+      if (i & 1)
+	ret = mq_send (q, &v[i], 1, v[i] >> 4);
+      else
+	ret = mq_timedsend (q, &v[i], 1, v[i] >> 4, &ts);
+
+      if (ret)
+	{
+	  printf ("mq_%ssend failed: %m\n", (i & 1) ? "" : "timed");
+	  result = 1;
+	}
+    }
+
+  ret = mq_timedsend (q, &v[10], 1, 8, &ts);
+  if (ret != -1)
+    {
+      puts ("mq_timedsend on full queue did not fail");
+      result = 1;
+    }
+  else if (errno != (nonblock ? EAGAIN : ETIMEDOUT))
+    {
+      printf ("mq_timedsend on full queue did not fail with %s: %m\n",
+	      nonblock ? "EAGAIN" : "ETIMEDOUT");
+      result = 1;
+    }
+
+  if (nonblock)
+    {
+      ret = mq_send (q, &v[10], 1, 8);
+      if (ret != -1)
+	{
+	  puts ("mq_send on full non-blocking queue did not fail");
+	  result = 1;
+	}
+      else if (errno != EAGAIN)
+	{
+	  printf ("mq_send on full non-blocking queue did not fail"
+		  "with EAGAIN: %m\n");
+	  result = 1;
+	}
+    }
+
+  memset (&attr, 0xaa, sizeof (attr));
+  if (mq_getattr (q, &attr) != 0)
+    {
+      printf ("mq_getattr failed: %m\n");
+      result = 1;
+    }
+  else
+    result |= check_attrs (&attr, nonblock, 10);
+
+  pid_t pid = fork ();
+  if (pid == -1)
+    {
+      printf ("fork failed: %m\n");
+      result = 1;
+    }
+  else if (pid == 0)
+    {
+      result = 0;
+
+      if (mq_close (q) != 0)
+	{
+	  printf ("mq_close in child failed: %m\n");
+	  result = 1;
+	}
+
+      q = mq_open (name, O_RDONLY | nonblock);
+      if (q == (mqd_t) -1)
+        {
+	  printf ("mq_open in child failed: %m\n");
+	  exit (1);
+        }
+
+      memset (&attr, 0xaa, sizeof (attr));
+      if (mq_getattr (q, &attr) != 0)
+	{
+	  printf ("mq_getattr failed: %m\n");
+	  result = 1;
+	}
+      else
+	result |= check_attrs (&attr, nonblock, 10);
+
+      unsigned char vr[11] = { };
+      unsigned int prio;
+      ssize_t rets;
+
+      if (mq_send (q, &v[0], 1, 1) != -1)
+	{
+	  puts ("mq_send on O_RDONLY mqd_t unexpectedly succeeded");
+	  result = 1;
+	}
+      else if (errno != EBADF)
+	{
+	  printf ("mq_send on O_WRONLY mqd_t did not fail with EBADF: %m\n");
+	  result = 1;
+	}
+
+      for (int i = 0; i < 10; ++i)
+	{
+	  if (i & 1)
+	    rets = mq_receive (q, &vr[i], 1, &prio);
+	  else
+	    rets = mq_timedreceive (q, &vr[i], 1, &prio, &ts);
+
+	  if (rets != 1)
+	    {
+	      if (rets == -1)
+		printf ("mq_%sreceive failed: %m\n", (i & 1) ? "" : "timed");
+	      else
+		printf ("mq_%sreceive returned %zd != 1\n",
+			(i & 1) ? "" : "timed", rets);
+	      result = 1;
+	    }
+	  else if (prio != (unsigned int) vr[i] >> 4)
+	    {
+	      printf ("unexpected priority %x for value %02x\n", prio,
+		      vr[i]);
+	      result = 1;
+	    }
+	}
+
+      qsort (v, 10, 1, intcmp);
+      if (memcmp (v, vr, 10) != 0)
+	{
+	  puts ("messages not received in expected order");
+	  result = 1;
+	}
+
+      rets = mq_timedreceive (q, &vr[10], 1, &prio, &ts);
+      if (rets != -1)
+	{
+	  puts ("mq_timedreceive on empty queue did not fail");
+	  result = 1;
+	}
+      else if (errno != (nonblock ? EAGAIN : ETIMEDOUT))
+	{
+	  printf ("mq_timedreceive on empty queue did not fail with %s: %m\n",
+		  nonblock ? "EAGAIN" : "ETIMEDOUT");
+	  result = 1;
+	}
+
+      if (nonblock)
+	{
+	  ret = mq_receive (q, &vr[10], 1, &prio);
+	  if (ret != -1)
+	    {
+	      puts ("mq_receive on empty non-blocking queue did not fail");
+	      result = 1;
+	    }
+	  else if (errno != EAGAIN)
+	    {
+	      printf ("mq_receive on empty non-blocking queue did not fail"
+		      "with EAGAIN: %m\n");
+	      result = 1;
+	    }
+	}
+
+      memset (&attr, 0xaa, sizeof (attr));
+      if (mq_getattr (q, &attr) != 0)
+	{
+	  printf ("mq_getattr failed: %m\n");
+	  result = 1;
+	}
+      else
+	result |= check_attrs (&attr, nonblock, 0);
+
+      if (mq_close (q) != 0)
+	{
+	  printf ("mq_close in child failed: %m\n");
+	  result = 1;
+	}
+
+      exit (result);
+    }
+
+  int status;
+  if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
+    {
+      printf ("waitpid failed: %m\n");
+      kill (pid, SIGKILL);
+      result = 1;
+    }
+  else if (!WIFEXITED (status) || WEXITSTATUS (status))
+    {
+      printf ("child failed: %d\n", status);
+      result = 1;
+    }
+
+  memset (&attr, 0xaa, sizeof (attr));
+  if (mq_getattr (q, &attr) != 0)
+    {
+      printf ("mq_getattr failed: %m\n");
+      result = 1;
+    }
+  else
+    result |= check_attrs (&attr, nonblock, 0);
+
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+  int result = 0;
+
+  char name[sizeof "/tst-mqueue1-" + sizeof (pid_t) * 3];
+  snprintf (name, sizeof (name), "/tst-mqueue1-%u", getpid ());
+
+  struct mq_attr attr = { .mq_maxmsg = 10, .mq_msgsize = 1 };
+  mqd_t q = mq_open (name, O_CREAT | O_EXCL | O_WRONLY, 0600, &attr);
+
+  if (q == (mqd_t) -1)
+    {
+      printf ("mq_open failed with: %m\n");
+      return result;
+    }
+  else
+    add_temp_mq (name);
+
+  result |= do_one_test (q, name, 0);
+
+  mqd_t q2 = mq_open (name, O_WRONLY | O_NONBLOCK);
+  if (q2 == (mqd_t) -1)
+    {
+      printf ("mq_open failed with: %m\n");
+      q2 = q;
+      result = 1;
+    }
+  else
+    {
+      if (mq_close (q) != 0)
+	{
+	  printf ("mq_close in parent failed: %m\n");
+	  result = 1;
+	}
+
+      q = q2;
+      result |= do_one_test (q, name, O_NONBLOCK);
+
+      if (mq_getattr (q, &attr) != 0)
+	{
+	  printf ("mq_getattr failed: %m\n");
+	  result = 1;
+	}
+      else
+	{
+	  attr.mq_flags ^= O_NONBLOCK;
+
+	  struct mq_attr attr2;
+	  memset (&attr2, 0x55, sizeof (attr2));
+	  if (mq_setattr (q, &attr, &attr2) != 0)
+	    {
+	      printf ("mq_setattr failed: %m\n");
+	      result = 1;
+	    }
+	  else if (attr.mq_flags != (attr2.mq_flags ^ O_NONBLOCK)
+		   || attr.mq_maxmsg != attr2.mq_maxmsg
+		   || attr.mq_msgsize != attr2.mq_msgsize
+		   || attr.mq_curmsgs != 0
+		   || attr2.mq_curmsgs != 0)
+	    {
+	      puts ("mq_setattr returned unexpected values in *omqstat");
+	      result = 1;
+	    }
+	  else
+	    {
+	      result |= do_one_test (q, name, 0);
+
+	      if (mq_setattr (q, &attr2, NULL) != 0)
+		{
+		  printf ("mq_setattr failed: %m\n");
+		  result = 1;
+		}
+	      else
+		result |= do_one_test (q, name, O_NONBLOCK);
+	    }
+	}
+    }
+
+  if (mq_unlink (name) != 0)
+    {
+      printf ("mq_unlink failed: %m\n");
+      result = 1;
+    }
+
+  if (mq_close (q) != 0)
+    {
+      printf ("mq_close in parent failed: %m\n");
+      result = 1;
+    }
+
+  if (mq_close (q) != -1)
+    {
+      puts ("second mq_close did not fail");
+      result = 1;
+    }
+  else if (errno != EBADF)
+    {
+      printf ("second mq_close did not fail with EBADF: %m\n");
+      result = 1;
+    }
+
+  return result;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/rt/tst-mqueue2.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-mqueue2.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-mqueue2.c	(revision 2036)
@@ -0,0 +1,477 @@
+/* Test message queue passing.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <mqueue.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <time.h>
+#include <unistd.h>
+#include "tst-mqueue.h"
+
+static void
+alrm_handler (int sig)
+{
+}
+
+#define TIMEOUT 10
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+  int result = 0;
+
+  char name[sizeof "/tst-mqueue2-" + sizeof (pid_t) * 3];
+  snprintf (name, sizeof (name), "/tst-mqueue2-%u", getpid ());
+
+  struct mq_attr attr = { .mq_maxmsg = 2, .mq_msgsize = 2 };
+  mqd_t q = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr);
+
+  if (q == (mqd_t) -1)
+    {
+      printf ("mq_open failed with: %m\n");
+      return result;
+    }
+  else
+    add_temp_mq (name);
+
+  mqd_t q2 = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr);
+  if (q2 != (mqd_t) -1)
+    {
+      puts ("mq_open with O_EXCL unexpectedly succeeded");
+      result = 1;
+    }
+  else if (errno != EEXIST)
+    {
+      printf ("mq_open did not fail with EEXIST: %m\n");
+      result = 1;
+    }
+
+  char name2[sizeof "/tst-mqueue2-2-" + sizeof (pid_t) * 3];
+  snprintf (name2, sizeof (name2), "/tst-mqueue2-2-%u", getpid ());
+
+  attr.mq_maxmsg = -2;
+  q2 = mq_open (name2, O_CREAT | O_EXCL | O_RDWR, 0600, &attr);
+  if (q2 != (mqd_t) -1)
+    {
+      puts ("mq_open with invalid mq_maxmsg unexpectedly succeeded");
+      add_temp_mq (name2);
+      result = 1;
+    }
+  else if (errno != EINVAL)
+    {
+      printf ("mq_open with invalid mq_maxmsg did not fail with "
+	      "EINVAL: %m\n");
+      result = 1;
+    }
+
+  attr.mq_maxmsg = 2;
+  attr.mq_msgsize = -56;
+  q2 = mq_open (name2, O_CREAT | O_EXCL | O_RDWR, 0600, &attr);
+  if (q2 != (mqd_t) -1)
+    {
+      puts ("mq_open with invalid mq_msgsize unexpectedly succeeded");
+      add_temp_mq (name2);
+      result = 1;
+    }
+  else if (errno != EINVAL)
+    {
+      printf ("mq_open with invalid mq_msgsize did not fail with "
+	      "EINVAL: %m\n");
+      result = 1;
+    }
+
+  char buf[3];
+  struct timespec ts;
+  if (clock_gettime (CLOCK_REALTIME, &ts) == 0)
+    ts.tv_sec += 10;
+  else
+    {
+      ts.tv_sec = time (NULL) + 10;
+      ts.tv_nsec = 0;
+    }
+
+  if (mq_timedreceive (q, buf, 1, NULL, &ts) == 0)
+    {
+      puts ("mq_timedreceive with too small msg_len did not fail");
+      result = 1;
+    }
+  else if (errno != EMSGSIZE)
+    {
+      printf ("mq_timedreceive with too small msg_len did not fail with "
+	      "EMSGSIZE: %m\n");
+      result = 1;
+    }
+
+  ts.tv_nsec = -1;
+  if (mq_timedreceive (q, buf, 2, NULL, &ts) == 0)
+    {
+      puts ("mq_timedreceive with negative tv_nsec did not fail");
+      result = 1;
+    }
+  else if (errno != EINVAL)
+    {
+      printf ("mq_timedreceive with negative tv_nsec did not fail with "
+	      "EINVAL: %m\n");
+      result = 1;
+    }
+
+  ts.tv_nsec = 1000000000;
+  if (mq_timedreceive (q, buf, 2, NULL, &ts) == 0)
+    {
+      puts ("mq_timedreceive with tv_nsec >= 1000000000 did not fail");
+      result = 1;
+    }
+  else if (errno != EINVAL)
+    {
+      printf ("mq_timedreceive with tv_nsec >= 1000000000 did not fail with "
+	      "EINVAL: %m\n");
+      result = 1;
+    }
+
+  struct sigaction sa = { .sa_handler = alrm_handler, .sa_flags = 0 };
+  sigemptyset (&sa.sa_mask);
+  sigaction (SIGALRM, &sa, NULL);
+
+  struct itimerval it = { .it_value = { .tv_sec = 1 } };
+  setitimer (ITIMER_REAL, &it, NULL);
+
+  if (mq_receive (q, buf, 2, NULL) == 0)
+    {
+      puts ("mq_receive on empty queue did not block");
+      result = 1;
+    }
+  else if (errno != EINTR)
+    {
+      printf ("mq_receive on empty queue did not fail with EINTR: %m\n");
+      result = 1;
+    }
+
+  setitimer (ITIMER_REAL, &it, NULL);
+
+  ts.tv_nsec = 0;
+  if (mq_timedreceive (q, buf, 2, NULL, &ts) == 0)
+    {
+      puts ("mq_timedreceive on empty queue did not block");
+      result = 1;
+    }
+  else if (errno != EINTR)
+    {
+      printf ("mq_timedreceive on empty queue did not fail with EINTR: %m\n");
+      result = 1;
+    }
+
+  buf[0] = '6';
+  buf[1] = '7';
+  if (mq_send (q, buf, 2, 3) != 0
+      || (buf[0] = '8', mq_send (q, buf, 1, 4) != 0))
+    {
+      printf ("mq_send failed: %m\n");
+      result = 1;
+    }
+
+  memset (buf, ' ', sizeof (buf));
+
+  unsigned int prio;
+  ssize_t rets = mq_receive (q, buf, 3, &prio);
+  if (rets != 1)
+    {
+      if (rets == -1)
+	printf ("mq_receive failed: %m\n");
+      else
+	printf ("mq_receive returned %zd != 1\n", rets);
+      result = 1;
+    }
+  else if (prio != 4 || memcmp (buf, "8  ", 3) != 0)
+    {
+      printf ("mq_receive prio %u (4) buf \"%c%c%c\" (\"8  \")\n",
+	      prio, buf[0], buf[1], buf[2]);
+      result = 1;
+    }
+
+  rets = mq_receive (q, buf, 2, NULL);
+  if (rets != 2)
+    {
+      if (rets == -1)
+	printf ("mq_receive failed: %m\n");
+      else
+	printf ("mq_receive returned %zd != 2\n", rets);
+      result = 1;
+    }
+  else if (memcmp (buf, "67 ", 3) != 0)
+    {
+      printf ("mq_receive buf \"%c%c%c\" != \"67 \"\n",
+	      buf[0], buf[1], buf[2]);
+      result = 1;
+    }
+
+  buf[0] = '2';
+  buf[1] = '1';
+  if (clock_gettime (CLOCK_REALTIME, &ts) != 0)
+    ts.tv_sec = time (NULL);
+  ts.tv_nsec = -1000000001;
+  if ((mq_timedsend (q, buf, 2, 5, &ts) != 0
+       && (errno != EINVAL || mq_send (q, buf, 2, 5) != 0))
+      || (buf[0] = '3', ts.tv_nsec = -ts.tv_nsec,
+	  (mq_timedsend (q, buf, 1, 4, &ts) != 0
+	   && (errno != EINVAL || mq_send (q, buf, 1, 4) != 0))))
+    {
+      printf ("mq_timedsend failed: %m\n");
+      result = 1;
+    }
+
+  buf[0] = '-';
+  ts.tv_nsec = 1000000001;
+  if (mq_timedsend (q, buf, 1, 6, &ts) == 0)
+    {
+      puts ("mq_timedsend with tv_nsec >= 1000000000 did not fail");
+      result = 1;
+    }
+  else if (errno != EINVAL)
+    {
+      printf ("mq_timedsend with tv_nsec >= 1000000000 did not fail with "
+	      "EINVAL: %m\n");
+      result = 1;
+    }
+
+  ts.tv_nsec = -2;
+  if (mq_timedsend (q, buf, 1, 6, &ts) == 0)
+    {
+      puts ("mq_timedsend with negative tv_nsec did not fail");
+      result = 1;
+    }
+  else if (errno != EINVAL)
+    {
+      printf ("mq_timedsend with megatove tv_nsec did not fail with "
+	      "EINVAL: %m\n");
+      result = 1;
+    }
+
+  setitimer (ITIMER_REAL, &it, NULL);
+
+  if (mq_send (q, buf, 2, 8) == 0)
+    {
+      puts ("mq_send on full queue did not block");
+      result = 1;
+    }
+  else if (errno != EINTR)
+    {
+      printf ("mq_send on full queue did not fail with EINTR: %m\n");
+      result = 1;
+    }
+
+  setitimer (ITIMER_REAL, &it, NULL);
+
+  ts.tv_sec += 10;
+  ts.tv_nsec = 0;
+  if (mq_timedsend (q, buf, 2, 7, &ts) == 0)
+    {
+      puts ("mq_timedsend on full queue did not block");
+      result = 1;
+    }
+  else if (errno != EINTR)
+    {
+      printf ("mq_timedsend on full queue did not fail with EINTR: %m\n");
+      result = 1;
+    }
+
+  memset (buf, ' ', sizeof (buf));
+
+  if (clock_gettime (CLOCK_REALTIME, &ts) != 0)
+    ts.tv_sec = time (NULL);
+  ts.tv_nsec = -1000000001;
+  rets = mq_timedreceive (q, buf, 2, &prio, &ts);
+  if (rets == -1 && errno == EINVAL)
+    rets = mq_receive (q, buf, 2, &prio);
+  if (rets != 2)
+    {
+      if (rets == -1)
+	printf ("mq_timedreceive failed: %m\n");
+      else
+	printf ("mq_timedreceive returned %zd != 2\n", rets);
+      result = 1;
+    }
+  else if (prio != 5 || memcmp (buf, "21 ", 3) != 0)
+    {
+      printf ("mq_timedreceive prio %u (5) buf \"%c%c%c\" (\"21 \")\n",
+	      prio, buf[0], buf[1], buf[2]);
+      result = 1;
+    }
+
+  if (mq_receive (q, buf, 1, NULL) == 0)
+    {
+      puts ("mq_receive with too small msg_len did not fail");
+      result = 1;
+    }
+  else if (errno != EMSGSIZE)
+    {
+      printf ("mq_receive with too small msg_len did not fail with "
+	      "EMSGSIZE: %m\n");
+      result = 1;
+    }
+
+  ts.tv_nsec = -ts.tv_nsec;
+  rets = mq_timedreceive (q, buf, 2, NULL, &ts);
+  if (rets == -1 && errno == EINVAL)
+    rets = mq_receive (q, buf, 2, NULL);
+  if (rets != 1)
+    {
+      if (rets == -1)
+	printf ("mq_timedreceive failed: %m\n");
+      else
+	printf ("mq_timedreceive returned %zd != 1\n", rets);
+      result = 1;
+    }
+  else if (memcmp (buf, "31 ", 3) != 0)
+    {
+      printf ("mq_timedreceive buf \"%c%c%c\" != \"31 \"\n",
+	      buf[0], buf[1], buf[2]);
+      result = 1;
+    }
+
+  if (mq_send (q, "", 0, 2) != 0)
+    {
+      printf ("mq_send with msg_len 0 failed: %m\n");
+      result = 1;
+    }
+
+  rets = mq_receive (q, buf, 2, &prio);
+  if (rets)
+    {
+      if (rets == -1)
+	printf ("mq_receive failed: %m\n");
+      else
+	printf ("mq_receive returned %zd != 0\n", rets);
+      result = 1;
+    }
+
+  long mq_prio_max = sysconf (_SC_MQ_PRIO_MAX);
+  if (mq_prio_max > 0 && (unsigned int) mq_prio_max == mq_prio_max)
+    {
+      if (mq_send (q, buf, 1, mq_prio_max) == 0)
+	{
+	  puts ("mq_send with MQ_PRIO_MAX priority unpexpectedly succeeded");
+	  result = 1;
+	}
+      else if (errno != EINVAL)
+	{
+	  printf ("mq_send with MQ_PRIO_MAX priority did not fail with "
+		  "EINVAL: %m\n");
+	  result = 1;
+	}
+
+      if (mq_send (q, buf, 1, mq_prio_max - 1) != 0)
+	{
+	  printf ("mq_send with MQ_PRIO_MAX-1 priority failed: %m\n");
+	  result = 1;
+	}
+    }
+
+  if (mq_unlink (name) != 0)
+    {
+      printf ("mq_unlink failed: %m\n");
+      result = 1;
+    }
+
+  q2 = mq_open (name, O_RDWR);
+  if (q2 != (mqd_t) -1)
+    {
+      printf ("mq_open of unlinked %s without O_CREAT unexpectedly"
+	      "succeeded\n", name);
+      result = 1;
+    }
+  else if (errno != ENOENT)
+    {
+      printf ("mq_open of unlinked %s without O_CREAT did not fail with "
+	      "ENOENT: %m\n", name);
+      result = 1;
+    }
+
+  if (mq_close (q) != 0)
+    {
+      printf ("mq_close in parent failed: %m\n");
+      result = 1;
+    }
+
+  if (mq_receive (q, buf, 2, NULL) == 0)
+    {
+      puts ("mq_receive on invalid mqd_t did not fail");
+      result = 1;
+    }
+  else if (errno != EBADF)
+    {
+      printf ("mq_receive on invalid mqd_t did not fail with EBADF: %m\n");
+      result = 1;
+    }
+
+  if (mq_send (q, buf, 1, 2) == 0)
+    {
+      puts ("mq_send on invalid mqd_t did not fail");
+      result = 1;
+    }
+  else if (errno != EBADF)
+    {
+      printf ("mq_send on invalid mqd_t did not fail with EBADF: %m\n");
+      result = 1;
+    }
+
+  if (mq_getattr (q, &attr) == 0)
+    {
+      puts ("mq_getattr on invalid mqd_t did not fail");
+      result = 1;
+    }
+  else if (errno != EBADF)
+    {
+      printf ("mq_getattr on invalid mqd_t did not fail with EBADF: %m\n");
+      result = 1;
+    }
+
+  memset (&attr, 0, sizeof (attr));
+  if (mq_setattr (q, &attr, NULL) == 0)
+    {
+      puts ("mq_setattr on invalid mqd_t did not fail");
+      result = 1;
+    }
+  else if (errno != EBADF)
+    {
+      printf ("mq_setattr on invalid mqd_t did not fail with EBADF: %m\n");
+      result = 1;
+    }
+
+  if (mq_unlink ("/tst-mqueue2-which-should-never-exist") != -1)
+    {
+      puts ("mq_unlink of non-existant message queue unexpectedly succeeded");
+      result = 1;
+    }
+  else if (errno != ENOENT)
+    {
+      printf ("mq_unlink of non-existant message queue did not fail with "
+	      "ENOENT: %m\n");
+      result = 1;
+    }
+  return result;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/rt/tst-mqueue3.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-mqueue3.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-mqueue3.c	(revision 2036)
@@ -0,0 +1,244 @@
+/* Test SIGEV_THREAD handling for POSIX message queues.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <mqueue.h>
+#include <signal.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#if _POSIX_THREADS
+# include <pthread.h>
+
+static pid_t pid;
+static mqd_t m;
+static const char message[] = "hello";
+
+# define MAXMSG 10
+# define MSGSIZE 10
+# define UNIQUE 42
+
+
+static void
+fct (union sigval s)
+{
+  /* Put the mq in non-blocking mode.  */
+  struct mq_attr attr;
+  if (mq_getattr (m, &attr) != 0)
+    {
+      printf ("%s: mq_getattr failed: %m\n", __FUNCTION__);
+      exit (1);
+    }
+  attr.mq_flags |= O_NONBLOCK;
+  if (mq_setattr (m, &attr, NULL) != 0)
+    {
+      printf ("%s: mq_setattr failed: %m\n", __FUNCTION__);
+      exit (1);
+    }
+
+  /* Check the values.  */
+  if (attr.mq_maxmsg != MAXMSG)
+    {
+      printf ("%s: mq_maxmsg wrong: is %ld, expecte %d\n",
+	      __FUNCTION__, attr.mq_maxmsg, MAXMSG);
+      exit (1);
+    }
+  if (attr.mq_msgsize != MAXMSG)
+    {
+      printf ("%s: mq_msgsize wrong: is %ld, expecte %d\n",
+	      __FUNCTION__, attr.mq_msgsize, MSGSIZE);
+      exit (1);
+    }
+
+  /* Read the message.  */
+  char buf[attr.mq_msgsize];
+  ssize_t n = TEMP_FAILURE_RETRY (mq_receive (m, buf, attr.mq_msgsize, NULL));
+  if (n != sizeof (message))
+    {
+      printf ("%s: length of message wrong: is %zd, expected %zu\n",
+	      __FUNCTION__, n, sizeof (message));
+      exit (1);
+    }
+  if (memcmp (buf, message, sizeof (message)) != 0)
+    {
+      printf ("%s: message wrong: is \"%s\", expected \"%s\"\n",
+	      __FUNCTION__, buf, message);
+      exit (1);
+    }
+
+  exit (UNIQUE);
+}
+
+
+int
+do_test (void)
+{
+  char tmpfname[] = "/tmp/tst-mqueue3-barrier.XXXXXX";
+  int fd = mkstemp (tmpfname);
+  if (fd == -1)
+    {
+      printf ("cannot open temporary file: %m\n");
+      return 1;
+    }
+
+  /* Make sure it is always removed.  */
+  unlink (tmpfname);
+
+  /* Create one page of data.  */
+  size_t ps = sysconf (_SC_PAGESIZE);
+  char data[ps];
+  memset (data, '\0', ps);
+
+  /* Write the data to the file.  */
+  if (write (fd, data, ps) != (ssize_t) ps)
+    {
+      puts ("short write");
+      return 1;
+    }
+
+  void *mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+  if (mem == MAP_FAILED)
+    {
+      printf ("mmap failed: %m\n");
+      return 1;
+    }
+
+  pthread_barrier_t *b;
+  b = (pthread_barrier_t *) (((uintptr_t) mem + __alignof (pthread_barrier_t))
+                             & ~(__alignof (pthread_barrier_t) - 1));
+
+  pthread_barrierattr_t a;
+  if (pthread_barrierattr_init (&a) != 0)
+    {
+      puts ("barrierattr_init failed");
+      return 1;
+    }
+
+  if (pthread_barrierattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0)
+    {
+      puts ("barrierattr_setpshared failed, could not test");
+      return 0;
+    }
+
+  if (pthread_barrier_init (b, &a, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      return 1;
+    }
+
+  if (pthread_barrierattr_destroy (&a) != 0)
+    {
+      puts ("barrierattr_destroy failed");
+      return 1;
+    }
+
+  /* Name for the message queue.  */
+  char mqname[sizeof ("/tst-mqueue3-") + 3 * sizeof (pid_t)];
+  snprintf (mqname, sizeof (mqname) - 1, "/tst-mqueue3-%ld",
+	    (long int) getpid ());
+
+  /* Create the message queue.  */
+  struct mq_attr attr = { .mq_maxmsg = MAXMSG, .mq_msgsize = MSGSIZE };
+  m = mq_open (mqname, O_CREAT | O_EXCL | O_RDWR, 0600, &attr);
+  if (m == -1)
+    {
+      if (errno == ENOSYS)
+	{
+	  puts ("not implemented");
+	  return 0;
+	}
+
+      puts ("mq_open failed");
+      return 1;
+    }
+
+  /* Unlink the message queue right away.  */
+  if (mq_unlink (mqname) != 0)
+    {
+      puts ("mq_unlink failed");
+      return 1;
+    }
+
+  pid = fork ();
+  if (pid == -1)
+    {
+      puts ("fork failed");
+      return 1;
+    }
+  if (pid == 0)
+    {
+      /* Request notification via thread.  */
+      struct sigevent ev;
+      ev.sigev_notify = SIGEV_THREAD;
+      ev.sigev_notify_function = fct;
+      ev.sigev_value.sival_ptr = NULL;
+      ev.sigev_notify_attributes = NULL;
+
+      /* Tell the kernel.  */
+      if (mq_notify (m,&ev) != 0)
+	{
+	  puts ("mq_notify failed");
+	  exit (1);
+	}
+
+      /* Tell the parent we are ready.  */
+      (void) pthread_barrier_wait (b);
+
+      /* Make sure the process goes away eventually.  */
+      alarm (10);
+
+      /* Do nothing forever.  */
+      while (1)
+	pause ();
+    }
+
+  /* Wait for the child process to register to notification method.  */
+  (void) pthread_barrier_wait (b);
+
+  /* Send the message.  */
+  if (mq_send (m, message, sizeof (message), 1) != 0)
+    {
+      kill (pid, SIGKILL);
+      puts ("mq_send failed");
+      return 1;
+    }
+
+  int r;
+  if (TEMP_FAILURE_RETRY (waitpid (pid, &r, 0)) != pid)
+    {
+      kill (pid, SIGKILL);
+      puts ("waitpid failed");
+      return 1;
+    }
+
+  return WIFEXITED (r) && WEXITSTATUS (r) == UNIQUE ? 0 : 1;
+}
+# define TEST_FUNCTION do_test ()
+#else
+# define TEST_FUNCTION 0
+#endif
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/rt/tst-mqueue4.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-mqueue4.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-mqueue4.c	(revision 2036)
@@ -0,0 +1,288 @@
+/* Test message queue passing.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <mqueue.h>
+#include <limits.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <time.h>
+#include <unistd.h>
+#include "tst-mqueue.h"
+
+#define TIMEOUT 4
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+  int result = 0;
+
+  char name[sizeof "/tst-mqueue4-" + sizeof (pid_t) * 3 + NAME_MAX];
+  char *p;
+  p = name + snprintf (name, sizeof (name), "/tst-mqueue4-%u", getpid ());
+  struct mq_attr attr = { .mq_maxmsg = 2, .mq_msgsize = 2 };
+  mqd_t q = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr);
+
+  if (q == (mqd_t) -1)
+    {
+      printf ("mq_open failed with: %m\n");
+      return result;
+    }
+  else
+    add_temp_mq (name);
+
+  *p = '.';
+  memset (p + 1, 'x', NAME_MAX + 1 - (p - name));
+  name[NAME_MAX + 1] = '\0';
+
+  mqd_t q2 = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr);
+  if (q2 == (mqd_t) -1)
+    {
+      printf ("mq_open with NAME_MAX long name compoment failed with: %m\n");
+      result = 1;
+    }
+
+  if (mq_unlink (name) != 0)
+    {
+      printf ("mq_unlink failed: %m\n");
+      result = 1;
+    }
+
+  if (mq_close (q2) != 0)
+    {
+      printf ("mq_close failed: %m\n");
+      result = 1;
+    }
+
+  name[NAME_MAX + 1] = 'x';
+  name[NAME_MAX + 2] = '\0';
+  q2 = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr);
+  if (q2 != (mqd_t) -1)
+    {
+      puts ("mq_open with too long name component unexpectedly succeeded");
+      mq_unlink (name);
+      mq_close (q2);
+      result = 1;
+    }
+  else if (errno != ENAMETOOLONG)
+    {
+      printf ("mq_open with too long name component did not fail with "
+	      "ENAMETOOLONG: %m\n");
+      result = 1;
+    }
+
+  if (mq_unlink (name) == 0)
+    {
+      puts ("mq_unlink with too long name component unexpectedly succeeded");
+      result = 1;
+    }
+  else if (errno != ENAMETOOLONG)
+    {
+      printf ("mq_unlink with too long name component did not fail with "
+	      "ENAMETOOLONG: %m\n");
+      result = 1;
+    }
+
+  *p = '\0';
+  attr.mq_maxmsg = 1;
+  attr.mq_msgsize = 3;
+  q2 = mq_open (name, O_CREAT | O_RDWR, 0600, &attr);
+  if (q2 == (mqd_t) -1)
+    {
+      printf ("mq_open without O_EXCL failed with %m\n");
+      result = 1;
+    }
+
+  char buf[3];
+  strcpy (buf, "jk");
+  if (mq_send (q, buf, 2, 4) != 0)
+    {
+      printf ("mq_send failed: %m\n");
+      result = 1;
+    }
+
+  if (mq_send (q, buf + 1, 1, 5) != 0)
+    {
+      printf ("mq_send failed: %m\n");
+      result = 1;
+    }
+
+  if (mq_getattr (q2, &attr) != 0)
+    {
+      printf ("mq_getattr failed: %m\n");
+      result = 1;
+    }
+
+  if ((attr.mq_flags & O_NONBLOCK)
+      || attr.mq_maxmsg != 2
+      || attr.mq_msgsize != 2
+      || attr.mq_curmsgs != 2)
+    {
+      printf ("mq_getattr returned unexpected { .mq_flags = %ld,\n"
+	      ".mq_maxmsg = %ld, .mq_msgsize = %ld, .mq_curmsgs = %ld }\n",
+	      attr.mq_flags, attr.mq_maxmsg, attr.mq_msgsize, attr.mq_curmsgs);
+      result = 1;
+    }
+
+  struct timespec ts;
+  if (clock_gettime (CLOCK_REALTIME, &ts) == 0)
+    ++ts.tv_sec;
+  else
+    {
+      ts.tv_sec = time (NULL) + 1;
+      ts.tv_nsec = 0;
+    }
+
+  if (mq_timedsend (q2, buf, 1, 1, &ts) == 0)
+    {
+      puts ("mq_timedsend unexpectedly succeeded");
+      result = 1;
+    }
+  else if (errno != ETIMEDOUT)
+    {
+      printf ("mq_timedsend did not fail with ETIMEDOUT: %m\n");
+      result = 1;
+    }
+
+  if (mq_close (q2) != 0)
+    {
+      printf ("mq_close failed: %m\n");
+      result = 1;
+    }
+
+  q2 = mq_open (name, O_RDONLY, 0600);
+  if (q2 == (mqd_t) -1)
+    {
+      printf ("mq_open without O_CREAT failed with %m\n");
+      result = 1;
+    }
+
+  mqd_t q3 = mq_open (name, O_RDONLY, 0600);
+  if (q3 == (mqd_t) -1)
+    {
+      printf ("mq_open without O_CREAT failed with %m\n");
+      result = 1;
+    }
+
+  memset (buf, ' ', sizeof (buf));
+
+  unsigned int prio;
+  ssize_t rets = mq_receive (q2, buf, 2, &prio);
+  if (rets != 1)
+    {
+      if (rets == -1)
+	printf ("mq_receive failed with: %m\n");
+      else
+	printf ("mq_receive returned %zd != 1\n", rets);
+      result = 1;
+    }
+  else if (prio != 5 || memcmp (buf, "k  ", 3) != 0)
+    {
+      printf ("mq_receive returned prio %u (2) buf \"%c%c%c\" (\"k  \")\n",
+	      prio, buf[0], buf[1], buf[2]);
+      result = 1;
+    }
+
+  if (mq_getattr (q3, &attr) != 0)
+    {
+      printf ("mq_getattr failed: %m\n");
+      result = 1;
+    }
+
+  if ((attr.mq_flags & O_NONBLOCK)
+      || attr.mq_maxmsg != 2
+      || attr.mq_msgsize != 2
+      || attr.mq_curmsgs != 1)
+    {
+      printf ("mq_getattr returned unexpected { .mq_flags = %ld,\n"
+	      ".mq_maxmsg = %ld, .mq_msgsize = %ld, .mq_curmsgs = %ld }\n",
+	      attr.mq_flags, attr.mq_maxmsg, attr.mq_msgsize, attr.mq_curmsgs);
+      result = 1;
+    }
+
+  rets = mq_receive (q3, buf, 2, NULL);
+  if (rets != 2)
+    {
+      if (rets == -1)
+	printf ("mq_receive failed with: %m\n");
+      else
+	printf ("mq_receive returned %zd != 2\n", rets);
+      result = 1;
+    }
+  else if (memcmp (buf, "jk ", 3) != 0)
+    {
+      printf ("mq_receive returned buf \"%c%c%c\" != \"jk \"\n",
+	      buf[0], buf[1], buf[2]);
+      result = 1;
+    }
+
+  if (clock_gettime (CLOCK_REALTIME, &ts) == 0)
+    ++ts.tv_sec;
+  else
+    {
+      ts.tv_sec = time (NULL) + 1;
+      ts.tv_nsec = 0;
+    }
+
+  if (mq_timedreceive (q2, buf, 2, NULL, &ts) != -1)
+    {
+      puts ("mq_timedreceive on empty queue unexpectedly succeeded");
+      result = 1;
+    }
+  else if (errno != ETIMEDOUT)
+    {
+      printf ("mq_timedreceive on empty queue did not fail with "
+	      "ETIMEDOUT: %m\n");
+      result = 1;
+    }
+
+  if (mq_unlink (name) != 0)
+    {
+      printf ("mq_unlink failed: %m\n");
+      result = 1;
+    }
+
+  if (mq_close (q) != 0)
+    {
+      printf ("mq_close failed: %m\n");
+      result = 1;
+    }
+
+  if (mq_close (q2) != 0)
+    {
+      printf ("mq_close failed: %m\n");
+      result = 1;
+    }
+
+  if (mq_close (q3) != 0)
+    {
+      printf ("mq_close failed: %m\n");
+      result = 1;
+    }
+
+  return result;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/rt/tst-mqueue5.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-mqueue5.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-mqueue5.c	(revision 2036)
@@ -0,0 +1,1014 @@
+/* Test mq_notify.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <mqueue.h>
+#include <limits.h>
+#include <signal.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <time.h>
+#include <unistd.h>
+#include "tst-mqueue.h"
+
+#define TIMEOUT 3
+
+#if _POSIX_THREADS
+# include <pthread.h>
+
+volatile int rtmin_cnt;
+volatile pid_t rtmin_pid;
+volatile uid_t rtmin_uid;
+volatile int rtmin_code;
+volatile union sigval rtmin_sigval;
+
+static void
+rtmin_handler (int sig, siginfo_t *info, void *ctx)
+{
+  if (sig != SIGRTMIN)
+    abort ();
+  ++rtmin_cnt;
+  rtmin_pid = info->si_pid;
+  rtmin_uid = info->si_uid;
+  rtmin_code = info->si_code;
+  rtmin_sigval = info->si_value;
+}
+
+#define mqsend(q) (mqsend) (q, __LINE__)
+static int
+(mqsend) (mqd_t q, int line)
+{
+  char c;
+  if (mq_send (q, &c, 1, 1) != 0)
+    {
+      printf ("mq_send on line %d failed with: %m\n", line);
+      return 1;
+    }
+  return 0;
+}
+
+#define mqrecv(q) (mqrecv) (q, __LINE__)
+static int
+(mqrecv) (mqd_t q, int line)
+{
+  char c;
+  ssize_t rets = TEMP_FAILURE_RETRY (mq_receive (q, &c, 1, NULL));
+  if (rets != 1)
+    {
+      if (rets == -1)
+	printf ("mq_receive on line %d failed with: %m\n", line);
+      else
+	printf ("mq_receive on line %d returned %zd != 1\n",
+		line, rets);
+      return 1;
+    }
+  return 0;
+}
+
+struct thr_data
+{
+  const char *name;
+  pthread_barrier_t *b3;
+  mqd_t q;
+};
+
+static void *
+thr (void *arg)
+{
+  pthread_barrier_t *b3 = ((struct thr_data *)arg)->b3;
+  mqd_t q = ((struct thr_data *)arg)->q;
+  const char *name = ((struct thr_data *)arg)->name;
+  int result = 0;
+
+  result |= mqrecv (q);
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Child verifies SIGRTMIN has not been sent.  */
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Parent calls mqsend (q), which should trigger notification.  */
+
+  (void) pthread_barrier_wait (b3);
+
+  if (rtmin_cnt != 2)
+    {
+      puts ("SIGRTMIN signal in child did not arrive");
+      result = 1;
+    }
+  else if (rtmin_pid != getppid ()
+	   || rtmin_uid != getuid ()
+	   || rtmin_code != SI_MESGQ
+	   || rtmin_sigval.sival_int != 0xdeadbeef)
+    {
+      printf ("unexpected siginfo_t fields: pid %u (%u), uid %u (%u), code %d (%d), si_int %d (%d)\n",
+	      rtmin_pid, getppid (), rtmin_uid, getuid (),
+	      rtmin_code, SI_MESGQ, rtmin_sigval.sival_int, 0xdeadbeef);
+      result = 1;
+    }
+
+  struct sigevent ev;
+  memset (&ev, 0x82, sizeof (ev));
+  ev.sigev_notify = SIGEV_NONE;
+  if (mq_notify (q, &ev) != 0)
+    {
+      printf ("mq_notify in thread (q, { SIGEV_NONE }) failed with: %m\n");
+      result = 1;
+    }
+
+  if (mq_notify (q, NULL) != 0)
+    {
+      printf ("mq_notify in thread (q, NULL) failed with: %m\n");
+      result = 1;
+    }
+
+  result |= mqrecv (q);
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Child calls mq_notify (q, { SIGEV_SIGNAL }).  */
+
+  (void) pthread_barrier_wait (b3);
+
+  if (mq_notify (q, NULL) != 0)
+    {
+      printf ("second mq_notify in thread (q, NULL) failed with: %m\n");
+      result = 1;
+    }
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Parent calls mqsend (q), which should not trigger notification.  */
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Child verifies SIGRTMIN has not been received.  */
+  /* Child calls mq_notify (q, { SIGEV_SIGNAL }).  */
+
+  (void) pthread_barrier_wait (b3);
+
+  mqd_t q4 = mq_open (name, O_RDONLY);
+  if (q4 == (mqd_t) -1)
+    {
+      printf ("mq_open in thread failed with: %m\n");
+      result = 1;
+    }
+
+  if (mq_notify (q4, NULL) != 0)
+    {
+      printf ("mq_notify in thread (q4, NULL) failed with: %m\n");
+      result = 1;
+    }
+
+  if (mq_close (q4) != 0)
+    {
+      printf ("mq_close in thread failed with: %m\n");
+      result = 1;
+    }
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Parent calls mqsend (q), which should not trigger notification.  */
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Child verifies SIGRTMIN has not been received.  */
+  /* Child calls mq_notify (q, { SIGEV_SIGNAL }).  */
+
+  (void) pthread_barrier_wait (b3);
+
+  mqd_t q5 = mq_open (name, O_WRONLY);
+  if (q5 == (mqd_t) -1)
+    {
+      printf ("mq_open O_WRONLY in thread failed with: %m\n");
+      result = 1;
+    }
+
+  if (mq_notify (q5, NULL) != 0)
+    {
+      printf ("mq_notify in thread (q5, NULL) failed with: %m\n");
+      result = 1;
+    }
+
+  if (mq_close (q5) != 0)
+    {
+      printf ("mq_close in thread failed with: %m\n");
+      result = 1;
+    }
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Parent calls mqsend (q), which should not trigger notification.  */
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Child verifies SIGRTMIN has not been received.  */
+
+  return (void *) (long) result;
+}
+
+static void
+do_child (const char *name, pthread_barrier_t *b2, pthread_barrier_t *b3,
+	  mqd_t q)
+{
+  int result = 0;
+
+  struct sigevent ev;
+  memset (&ev, 0x55, sizeof (ev));
+  ev.sigev_notify = SIGEV_SIGNAL;
+  ev.sigev_signo = SIGRTMIN;
+  ev.sigev_value.sival_ptr = &ev;
+  if (mq_notify (q, &ev) == 0)
+    {
+      puts ("first mq_notify in child (q, { SIGEV_SIGNAL }) unexpectedly succeeded");
+      result = 1;
+    }
+  else if (errno != EBUSY)
+    {
+      printf ("first mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n");
+      result = 1;
+    }
+
+  (void) pthread_barrier_wait (b2);
+
+  /* Parent calls mqsend (q), which makes notification available.  */
+
+  (void) pthread_barrier_wait (b2);
+
+  rtmin_cnt = 0;
+
+  if (mq_notify (q, &ev) != 0)
+    {
+      printf ("second mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n");
+      result = 1;
+    }
+
+  if (rtmin_cnt != 0)
+    {
+      puts ("SIGRTMIN signal in child caught too early");
+      result = 1;
+    }
+
+  (void) pthread_barrier_wait (b2);
+
+  /* Parent unsuccessfully attempts to mq_notify.  */
+  /* Parent calls mqsend (q), which makes notification available
+     and triggers a signal in the child.  */
+  /* Parent successfully calls mq_notify SIGEV_SIGNAL.  */
+
+  (void) pthread_barrier_wait (b2);
+
+  if (rtmin_cnt != 1)
+    {
+      puts ("SIGRTMIN signal in child did not arrive");
+      result = 1;
+    }
+  else if (rtmin_pid != getppid ()
+	   || rtmin_uid != getuid ()
+	   || rtmin_code != SI_MESGQ
+	   || rtmin_sigval.sival_ptr != &ev)
+    {
+      printf ("unexpected siginfo_t fields: pid %u (%u), uid %u (%u), code %d (%d), si_ptr %p (%p)\n",
+	      rtmin_pid, getppid (), rtmin_uid, getuid (),
+	      rtmin_code, SI_MESGQ, rtmin_sigval.sival_ptr, &ev);
+      result = 1;
+    }
+
+  result |= mqsend (q);
+
+  (void) pthread_barrier_wait (b2);
+
+  /* Parent verifies caught SIGRTMIN.  */
+
+  mqd_t q2 = mq_open (name, O_RDWR);
+  if (q2 == (mqd_t) -1)
+    {
+      printf ("mq_open in child failed with: %m\n");
+      result = 1;
+    }
+
+  (void) pthread_barrier_wait (b2);
+
+  /* Parent mq_open's another mqd_t for the same queue (q3).  */
+
+  memset (&ev, 0x11, sizeof (ev));
+  ev.sigev_notify = SIGEV_SIGNAL;
+  ev.sigev_signo = SIGRTMIN;
+  ev.sigev_value.sival_ptr = &ev;
+  if (mq_notify (q2, &ev) != 0)
+    {
+      printf ("mq_notify in child (q2, { SIGEV_SIGNAL }) failed with: %m\n");
+      result = 1;
+    }
+
+  (void) pthread_barrier_wait (b2);
+
+  /* Parent unsuccessfully attempts to mq_notify { SIGEV_NONE } on q.  */
+
+  (void) pthread_barrier_wait (b2);
+
+  if (mq_close (q2) != 0)
+    {
+      printf ("mq_close failed: %m\n");
+      result = 1;
+    }
+
+  (void) pthread_barrier_wait (b2);
+
+  /* Parent successfully calls mq_notify { SIGEV_NONE } on q3.  */
+
+  (void) pthread_barrier_wait (b2);
+
+  memset (&ev, 0xbb, sizeof (ev));
+  ev.sigev_notify = SIGEV_SIGNAL;
+  ev.sigev_signo = SIGRTMIN;
+  ev.sigev_value.sival_ptr = &b2;
+  if (mq_notify (q, &ev) == 0)
+    {
+      puts ("third mq_notify in child (q, { SIGEV_SIGNAL }) unexpectedly succeeded");
+      result = 1;
+    }
+  else if (errno != EBUSY)
+    {
+      printf ("third mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n");
+      result = 1;
+    }
+
+  (void) pthread_barrier_wait (b2);
+
+  /* Parent calls mq_close on q3, which makes the queue available again for
+     notification.  */
+
+  (void) pthread_barrier_wait (b2);
+
+  memset (&ev, 0x13, sizeof (ev));
+  ev.sigev_notify = SIGEV_NONE;
+  if (mq_notify (q, &ev) != 0)
+    {
+      printf ("mq_notify in child (q, { SIGEV_NONE }) failed with: %m\n");
+      result = 1;
+    }
+
+  if (mq_notify (q, NULL) != 0)
+    {
+      printf ("mq_notify in child (q, NULL) failed with: %m\n");
+      result = 1;
+    }
+
+  (void) pthread_barrier_wait (b2);
+
+  struct thr_data thr_data = { .name = name, .b3 = b3, .q = q };
+  pthread_t th;
+  int ret = pthread_create (&th, NULL, thr, &thr_data);
+  if (ret)
+    {
+      errno = ret;
+      printf ("pthread_created failed with: %m\n");
+      result = 1;
+    }
+
+  /* Wait till thr calls mq_receive on the empty queue q and blocks on it.  */
+  sleep (1);
+
+  memset (&ev, 0x5f, sizeof (ev));
+  ev.sigev_notify = SIGEV_SIGNAL;
+  ev.sigev_signo = SIGRTMIN;
+  ev.sigev_value.sival_int = 0xdeadbeef;
+  if (mq_notify (q, &ev) != 0)
+    {
+      printf ("fourth mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n");
+      result = 1;
+    }
+
+  (void) pthread_barrier_wait (b2);
+
+  /* Parent calls mqsend (q), which should wake up mqrecv (q)
+     in the thread but no notification should be sent.  */
+
+  (void) pthread_barrier_wait (b3);
+
+  if (rtmin_cnt != 1)
+    {
+      puts ("SIGRTMIN signal caught while thr was blocked on mq_receive");
+      result = 1;
+    }
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Parent calls mqsend (q), which should trigger notification.  */
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Thread verifies SIGRTMIN has been received.  */
+  /* Thread calls mq_notify (q, { SIGEV_NONE }) to verify notification is now
+     available for registration.  */
+  /* Thread calls mq_notify (q, NULL).  */
+
+  (void) pthread_barrier_wait (b3);
+
+  memset (&ev, 0x6a, sizeof (ev));
+  ev.sigev_notify = SIGEV_SIGNAL;
+  ev.sigev_signo = SIGRTMIN;
+  ev.sigev_value.sival_ptr = do_child;
+  if (mq_notify (q, &ev) != 0)
+    {
+      printf ("fifth mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n");
+      result = 1;
+    }
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Thread calls mq_notify (q, NULL), which should unregister the above
+     notification.  */
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Parent calls mqsend (q), which should not trigger notification.  */
+
+  (void) pthread_barrier_wait (b3);
+
+  if (rtmin_cnt != 2)
+    {
+      puts ("SIGRTMIN signal caught while notification has been disabled");
+      result = 1;
+    }
+
+  memset (&ev, 0x7b, sizeof (ev));
+  ev.sigev_notify = SIGEV_SIGNAL;
+  ev.sigev_signo = SIGRTMIN;
+  ev.sigev_value.sival_ptr = thr;
+  if (mq_notify (q, &ev) != 0)
+    {
+      printf ("sixth mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n");
+      result = 1;
+    }
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Thread opens a new O_RDONLY mqd_t (q4).  */
+  /* Thread calls mq_notify (q4, NULL), which should unregister the above
+     notification.  */
+  /* Thread calls mq_close (q4).  */
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Parent calls mqsend (q), which should not trigger notification.  */
+
+  (void) pthread_barrier_wait (b3);
+
+  if (rtmin_cnt != 2)
+    {
+      puts ("SIGRTMIN signal caught while notification has been disabled");
+      result = 1;
+    }
+
+  memset (&ev, 0xe1, sizeof (ev));
+  ev.sigev_notify = SIGEV_SIGNAL;
+  ev.sigev_signo = SIGRTMIN;
+  ev.sigev_value.sival_int = 127;
+  if (mq_notify (q, &ev) != 0)
+    {
+      printf ("seventh mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n");
+      result = 1;
+    }
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Thread opens a new O_WRONLY mqd_t (q5).  */
+  /* Thread calls mq_notify (q5, NULL), which should unregister the above
+     notification.  */
+  /* Thread calls mq_close (q5).  */
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Parent calls mqsend (q), which should not trigger notification.  */
+
+  (void) pthread_barrier_wait (b3);
+
+  if (rtmin_cnt != 2)
+    {
+      puts ("SIGRTMIN signal caught while notification has been disabled");
+      result = 1;
+    }
+
+ void *thr_ret;
+  ret = pthread_join (th, &thr_ret);
+  if (ret)
+    {
+      errno = ret;
+      printf ("pthread_join failed: %m\n");
+      result = 1;
+    }
+  else if (thr_ret)
+    result = 1;
+
+  if (mq_close (q) != 0)
+    {
+      printf ("mq_close failed: %m\n");
+      result = 1;
+    }
+
+  exit (result);
+}
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+  int result = 0;
+
+  char tmpfname[] = "/tmp/tst-mqueue5-barrier.XXXXXX";
+  int fd = mkstemp (tmpfname);
+  if (fd == -1)
+    {
+      printf ("cannot open temporary file: %m\n");
+      return 1;
+    }
+
+  /* Make sure it is always removed.  */
+  unlink (tmpfname);
+
+  /* Create one page of data.  */
+  size_t ps = sysconf (_SC_PAGESIZE);
+  char data[ps];
+  memset (data, '\0', ps);
+
+  /* Write the data to the file.  */
+  if (write (fd, data, ps) != (ssize_t) ps)
+    {
+      puts ("short write");
+      return 1;
+    }
+
+  void *mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+  if (mem == MAP_FAILED)
+    {
+      printf ("mmap failed: %m\n");
+      return 1;
+    }
+
+  pthread_barrier_t *b2;
+  b2 = (pthread_barrier_t *) (((uintptr_t) mem + __alignof (pthread_barrier_t))
+			      & ~(__alignof (pthread_barrier_t) - 1));
+
+  pthread_barrier_t *b3;
+  b3 = b2 + 1;
+
+  pthread_barrierattr_t a;
+  if (pthread_barrierattr_init (&a) != 0)
+    {
+      puts ("barrierattr_init failed");
+      return 1;
+    }
+
+  if (pthread_barrierattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0)
+    {
+      puts ("barrierattr_setpshared failed, could not test");
+      return 0;
+    }
+
+  if (pthread_barrier_init (b2, &a, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      return 1;
+    }
+
+  if (pthread_barrier_init (b3, &a, 3) != 0)
+    {
+      puts ("barrier_init failed");
+      return 1;
+    }
+
+  if (pthread_barrierattr_destroy (&a) != 0)
+    {
+      puts ("barrierattr_destroy failed");
+      return 1;
+    }
+
+  char name[sizeof "/tst-mqueue5-" + sizeof (pid_t) * 3];
+  snprintf (name, sizeof (name), "/tst-mqueue5-%u", getpid ());
+
+  struct mq_attr attr = { .mq_maxmsg = 1, .mq_msgsize = 1 };
+  mqd_t q = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr);
+
+  if (q == (mqd_t) -1)
+    {
+      printf ("mq_open failed with: %m\n");
+      return result;
+    }
+  else
+    add_temp_mq (name);
+
+  struct sigevent ev;
+  memset (&ev, 0xaa, sizeof (ev));
+  ev.sigev_notify = SIGEV_NONE;
+  if (mq_notify (q, &ev) != 0)
+    {
+      printf ("mq_notify (q, { SIGEV_NONE }) failed with: %m\n");
+      result = 1;
+    }
+
+  if (mq_notify (q, &ev) == 0)
+    {
+      puts ("second mq_notify (q, { SIGEV_NONE }) unexpectedly succeeded");
+      result = 1;
+    }
+  else if (errno != EBUSY)
+    {
+      printf ("second mq_notify (q, { SIGEV_NONE }) failed with: %m\n");
+      result = 1;
+    }
+
+  result |= mqsend (q);
+
+  if (mq_notify (q, &ev) != 0)
+    {
+      printf ("third mq_notify (q, { SIGEV_NONE }) failed with: %m\n");
+      result = 1;
+    }
+
+  result |= mqrecv (q);
+
+  if (mq_notify (q, NULL) != 0)
+    {
+      printf ("mq_notify (q, NULL) failed with: %m\n");
+      result = 1;
+    }
+
+  if (mq_notify (q, NULL) != 0)
+    {
+      /* Implementation-defined behaviour, so don't fail,
+	 just inform.  */
+      printf ("second mq_notify (q, NULL) failed with: %m\n");
+    }
+
+  struct sigaction sa = { .sa_sigaction = rtmin_handler,
+			  .sa_flags = SA_SIGINFO };
+  sigemptyset (&sa.sa_mask);
+  sigaction (SIGRTMIN, &sa, NULL);
+
+  memset (&ev, 0x55, sizeof (ev));
+  ev.sigev_notify = SIGEV_SIGNAL;
+  ev.sigev_signo = SIGRTMIN;
+  ev.sigev_value.sival_int = 26;
+  if (mq_notify (q, &ev) != 0)
+    {
+      printf ("mq_notify (q, { SIGEV_SIGNAL }) failed with: %m\n");
+      result = 1;
+    }
+
+  ev.sigev_value.sival_ptr = &ev;
+  if (mq_notify (q, &ev) == 0)
+    {
+      puts ("second mq_notify (q, { SIGEV_SIGNAL }) unexpectedly succeeded");
+      result = 1;
+    }
+  else if (errno != EBUSY)
+    {
+      printf ("second mq_notify (q, { SIGEV_SIGNAL }) failed with: %m\n");
+      result = 1;
+    }
+
+  if (rtmin_cnt != 0)
+    {
+      puts ("SIGRTMIN signal caught too early");
+      result = 1;
+    }
+
+  result |= mqsend (q);
+
+  if (rtmin_cnt != 1)
+    {
+      puts ("SIGRTMIN signal did not arrive");
+      result = 1;
+    }
+  else if (rtmin_pid != getpid ()
+	   || rtmin_uid != getuid ()
+	   || rtmin_code != SI_MESGQ
+	   || rtmin_sigval.sival_int != 26)
+    {
+      printf ("unexpected siginfo_t fields: pid %u (%u), uid %u (%u), code %d (%d), si_int %d (26)\n",
+	      rtmin_pid, getpid (), rtmin_uid, getuid (),
+	      rtmin_code, SI_MESGQ, rtmin_sigval.sival_int);
+      result = 1;
+    }
+
+  ev.sigev_value.sival_int = 75;
+  if (mq_notify (q, &ev) != 0)
+    {
+      printf ("third mq_notify (q, { SIGEV_SIGNAL }) failed with: %m\n");
+      result = 1;
+    }
+
+  result |= mqrecv (q);
+
+  if (mq_notify (q, NULL) != 0)
+    {
+      printf ("mq_notify (q, NULL) failed with: %m\n");
+      result = 1;
+    }
+
+  memset (&ev, 0x33, sizeof (ev));
+  ev.sigev_notify = SIGEV_NONE;
+  if (mq_notify (q, &ev) != 0)
+    {
+      printf ("fourth mq_notify (q, { SIGEV_NONE }) failed with: %m\n");
+      result = 1;
+    }
+
+  pid_t pid = fork ();
+  if (pid == -1)
+    {
+      printf ("fork () failed: %m\n");
+      mq_unlink (name);
+      return 1;
+    }
+
+  if (pid == 0)
+    do_child (name, b2, b3, q);
+
+  /* Child unsuccessfully attempts to mq_notify.  */
+
+  (void) pthread_barrier_wait (b2);
+
+  result |= mqsend (q);
+
+  (void) pthread_barrier_wait (b2);
+
+  /* Child successfully calls mq_notify SIGEV_SIGNAL now.  */
+
+  result |= mqrecv (q);
+
+  (void) pthread_barrier_wait (b2);
+
+  memset (&ev, 0xbb, sizeof (ev));
+  ev.sigev_notify = SIGEV_SIGNAL;
+  ev.sigev_signo = SIGRTMIN;
+  ev.sigev_value.sival_int = 15;
+  if (mq_notify (q, &ev) == 0)
+    {
+      puts ("fourth mq_notify (q, { SIGEV_SIGNAL }) unexpectedly succeeded");
+      result = 1;
+    }
+  else if (errno != EBUSY)
+    {
+      printf ("fourth mq_notify (q, { SIGEV_SIGNAL }) failed with: %m\n");
+      result = 1;
+    }
+
+  result |= mqsend (q);
+
+  if (mq_notify (q, &ev) != 0)
+    {
+      printf ("fifth mq_notify (q, { SIGEV_SIGNAL }) failed with: %m\n");
+      result = 1;
+    }
+
+  if (rtmin_cnt != 1)
+    {
+      puts ("SIGRTMIN signal caught too early");
+      result = 1;
+    }
+
+  result |= mqrecv (q);
+
+  (void) pthread_barrier_wait (b2);
+
+  /* Child verifies caught SIGRTMIN signal.  */
+  /* Child calls mq_send (q) which triggers SIGRTMIN signal here.  */
+
+  (void) pthread_barrier_wait (b2);
+
+  /* Child mq_open's another mqd_t for the same queue (q2).  */
+
+  if (rtmin_cnt != 2)
+    {
+      puts ("SIGRTMIN signal did not arrive");
+      result = 1;
+    }
+  else if (rtmin_pid != pid
+	   || rtmin_uid != getuid ()
+	   || rtmin_code != SI_MESGQ
+	   || rtmin_sigval.sival_int != 15)
+    {
+      printf ("unexpected siginfo_t fields: pid %u (%u), uid %u (%u), code %d (%d), si_int %d (15)\n",
+	      rtmin_pid, pid, rtmin_uid, getuid (),
+	      rtmin_code, SI_MESGQ, rtmin_sigval.sival_int);
+      result = 1;
+    }
+
+  result |= mqrecv (q);
+
+  (void) pthread_barrier_wait (b2);
+
+  /* Child successfully calls mq_notify { SIGEV_SIGNAL } on q2.  */
+
+  (void) pthread_barrier_wait (b2);
+
+  memset (&ev, 0xbb, sizeof (ev));
+  ev.sigev_notify = SIGEV_NONE;
+  if (mq_notify (q, &ev) == 0)
+    {
+      puts ("fifth mq_notify (q, { SIGEV_NONE }) unexpectedly succeeded");
+      result = 1;
+    }
+  else if (errno != EBUSY)
+    {
+      printf ("fifth mq_notify (q, { SIGEV_NONE }) failed with: %m\n");
+      result = 1;
+    }
+
+  (void) pthread_barrier_wait (b2);
+
+  /* Child calls mq_close on q2, which makes the queue available again for
+     notification.  */
+
+  mqd_t q3 = mq_open (name, O_RDWR);
+  if (q3 == (mqd_t) -1)
+    {
+      printf ("mq_open q3 in parent failed with: %m\n");
+      result = 1;
+    }
+
+  (void) pthread_barrier_wait (b2);
+
+  memset (&ev, 0x12, sizeof (ev));
+  ev.sigev_notify = SIGEV_NONE;
+  if (mq_notify (q3, &ev) != 0)
+    {
+      printf ("mq_notify (q3, { SIGEV_NONE }) failed with: %m\n");
+      result = 1;
+    }
+
+  (void) pthread_barrier_wait (b2);
+
+  /* Child unsuccessfully attempts to mq_notify { SIGEV_SIGNAL } on q.  */
+
+  (void) pthread_barrier_wait (b2);
+
+  if (mq_close (q3) != 0)
+    {
+      printf ("mq_close failed: %m\n");
+      result = 1;
+    }
+
+  (void) pthread_barrier_wait (b2);
+
+  /* Child successfully calls mq_notify { SIGEV_NONE } on q.  */
+  /* Child successfully calls mq_notify NULL on q.  */
+
+  (void) pthread_barrier_wait (b2);
+
+  /* Child creates new thread.  */
+  /* Thread blocks on mqrecv (q).  */
+  /* Child sleeps for 1sec so that thread has time to reach that point.  */
+  /* Child successfully calls mq_notify { SIGEV_SIGNAL } on q.  */
+
+  (void) pthread_barrier_wait (b2);
+
+  result |= mqsend (q);
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Child verifies SIGRTMIN has not been sent.  */
+
+  (void) pthread_barrier_wait (b3);
+
+  result |= mqsend (q);
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Thread verifies SIGRTMIN has been caught.  */
+  /* Thread calls mq_notify (q, { SIGEV_NONE }) to verify notification is now
+     available for registration.  */
+  /* Thread calls mq_notify (q, NULL).  */
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Child calls mq_notify (q, { SIGEV_SIGNAL }).  */
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Thread calls mq_notify (q, NULL). */
+
+  (void) pthread_barrier_wait (b3);
+
+  result |= mqsend (q);
+  result |= mqrecv (q);
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Child verifies SIGRTMIN has not been sent.  */
+  /* Child calls mq_notify (q, { SIGEV_SIGNAL }).  */
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Thread opens a new O_RDONLY mqd_t (q4).  */
+  /* Thread calls mq_notify (q4, NULL). */
+  /* Thread calls mq_close (q4).  */
+
+  (void) pthread_barrier_wait (b3);
+
+  result |= mqsend (q);
+  result |= mqrecv (q);
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Child verifies SIGRTMIN has not been sent.  */
+  /* Child calls mq_notify (q, { SIGEV_SIGNAL }).  */
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Thread opens a new O_WRONLY mqd_t (q5).  */
+  /* Thread calls mq_notify (q5, NULL). */
+  /* Thread calls mq_close (q5).  */
+
+  (void) pthread_barrier_wait (b3);
+
+  result |= mqsend (q);
+  result |= mqrecv (q);
+
+  (void) pthread_barrier_wait (b3);
+
+  /* Child verifies SIGRTMIN has not been sent.  */
+
+  int status;
+  if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
+    {
+      puts ("waitpid failed");
+      kill (pid, SIGKILL);
+      result = 1;
+    }
+  else if (!WIFEXITED (status) || WEXITSTATUS (status))
+    {
+      printf ("child failed with status %d\n", status);
+      result = 1;
+    }
+
+  if (mq_unlink (name) != 0)
+    {
+      printf ("mq_unlink failed: %m\n");
+      result = 1;
+    }
+
+  if (mq_close (q) != 0)
+    {
+      printf ("mq_close failed: %m\n");
+      result = 1;
+    }
+
+  if (mq_notify (q, NULL) == 0)
+    {
+      puts ("mq_notify on closed mqd_t unexpectedly succeeded");
+      result = 1;
+    }
+  else if (errno != EBADF)
+    {
+      printf ("mq_notify on closed mqd_t did not fail with EBADF: %m\n");
+      result = 1;
+    }
+
+  memset (&ev, 0x55, sizeof (ev));
+  ev.sigev_notify = SIGEV_NONE;
+  if (mq_notify (q, &ev) == 0)
+    {
+      puts ("mq_notify on closed mqd_t unexpectedly succeeded");
+      result = 1;
+    }
+  else if (errno != EBADF)
+    {
+      printf ("mq_notify on closed mqd_t did not fail with EBADF: %m\n");
+      result = 1;
+    }
+
+  return result;
+}
+#else
+# define TEST_FUNCTION 0
+#endif
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/rt/tst-mqueue6.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-mqueue6.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-mqueue6.c	(revision 2036)
@@ -0,0 +1,305 @@
+/* Test mq_notify.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <mqueue.h>
+#include <limits.h>
+#include <signal.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <time.h>
+#include <unistd.h>
+#include "tst-mqueue.h"
+
+#if _POSIX_THREADS
+# include <pthread.h>
+
+# define mqsend(q) (mqsend) (q, __LINE__)
+static int
+(mqsend) (mqd_t q, int line)
+{
+  char c;
+  if (mq_send (q, &c, 1, 1) != 0)
+    {
+      printf ("mq_send on line %d failed with: %m\n", line);
+      return 1;
+    }
+  return 0;
+}
+
+# define mqrecv(q) (mqrecv) (q, __LINE__)
+static int
+(mqrecv) (mqd_t q, int line)
+{
+  char c;
+  ssize_t rets = TEMP_FAILURE_RETRY (mq_receive (q, &c, 1, NULL));
+  if (rets != 1)
+    {
+      if (rets == -1)
+	printf ("mq_receive on line %d failed with: %m\n", line);
+      else
+	printf ("mq_receive on line %d returned %zd != 1\n",
+		line, rets);
+      return 1;
+    }
+  return 0;
+}
+
+volatile int fct_cnt, fct_err;
+size_t fct_guardsize;
+
+static void
+fct (union sigval s)
+{
+  mqd_t q = *(mqd_t *) s.sival_ptr;
+
+  pthread_attr_t nattr;
+  int ret = pthread_getattr_np (pthread_self (), &nattr);
+  if (ret)
+    {
+      errno = ret;
+      printf ("pthread_getattr_np failed: %m\n");
+      fct_err = 1;
+    }
+  else
+    {
+      ret = pthread_attr_getguardsize (&nattr, &fct_guardsize);
+      if (ret)
+	{
+	  errno = ret;
+	  printf ("pthread_attr_getguardsize failed: %m\n");
+	  fct_err = 1;
+	}
+      if (pthread_attr_destroy (&nattr) != 0)
+	{
+	  puts ("pthread_attr_destroy failed");
+	  fct_err = 1;
+	}
+    }
+
+  ++fct_cnt;
+  fct_err |= mqsend (q);
+}
+
+# define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+  int result = 0;
+
+  char name[sizeof "/tst-mqueue6-" + sizeof (pid_t) * 3];
+  snprintf (name, sizeof (name), "/tst-mqueue6-%u", getpid ());
+
+  struct mq_attr attr = { .mq_maxmsg = 1, .mq_msgsize = 1 };
+  mqd_t q = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr);
+
+  if (q == (mqd_t) -1)
+    {
+      printf ("mq_open failed with: %m\n");
+      return result;
+    }
+  else
+    add_temp_mq (name);
+
+  pthread_attr_t nattr;
+  if (pthread_attr_init (&nattr)
+      || pthread_attr_setguardsize (&nattr, 0))
+    {
+      puts ("pthread_attr_t setup failed");
+      result = 1;
+    }
+
+  fct_guardsize = 1;
+
+  struct sigevent ev;
+  memset (&ev, 0xaa, sizeof (ev));
+  ev.sigev_notify = SIGEV_THREAD;
+  ev.sigev_notify_function = fct;
+  ev.sigev_notify_attributes = &nattr;
+  ev.sigev_value.sival_ptr = &q;
+  if (mq_notify (q, &ev) != 0)
+    {
+      printf ("mq_notify (q, { SIGEV_THREAD }) failed with: %m\n");
+      result = 1;
+    }
+
+  size_t ps = sysconf (_SC_PAGESIZE);
+  if (pthread_attr_setguardsize (&nattr, 32 * ps))
+    {
+      puts ("pthread_attr_t setup failed");
+      result = 1;
+    }
+
+  if (mq_notify (q, &ev) == 0)
+    {
+      puts ("second mq_notify (q, { SIGEV_NONE }) unexpectedly succeeded");
+      result = 1;
+    }
+  else if (errno != EBUSY)
+    {
+      printf ("second mq_notify (q, { SIGEV_NONE }) failed with: %m\n");
+      result = 1;
+    }
+
+  if (fct_cnt != 0)
+    {
+      printf ("fct called too early (%d on %d)\n", fct_cnt, __LINE__);
+      result = 1;
+    }
+
+  result |= mqsend (q);
+
+  result |= mqrecv (q);
+  result |= mqrecv (q);
+
+  if (fct_cnt != 1)
+    {
+      printf ("fct not called (%d on %d)\n", fct_cnt, __LINE__);
+      result = 1;
+    }
+  else if (fct_guardsize != 0)
+    {
+      printf ("fct_guardsize %zd != 0\n", fct_guardsize);
+      result = 1;
+    }
+
+  if (mq_notify (q, &ev) != 0)
+    {
+      printf ("third mq_notify (q, { SIGEV_NONE }) failed with: %m\n");
+      result = 1;
+    }
+
+  if (mq_notify (q, NULL) != 0)
+    {
+      printf ("mq_notify (q, NULL) failed with: %m\n");
+      result = 1;
+    }
+
+  memset (&ev, 0x11, sizeof (ev));
+  ev.sigev_notify = SIGEV_THREAD;
+  ev.sigev_notify_function = fct;
+  ev.sigev_notify_attributes = &nattr;
+  ev.sigev_value.sival_ptr = &q;
+  if (mq_notify (q, &ev) != 0)
+    {
+      printf ("mq_notify (q, { SIGEV_THREAD }) failed with: %m\n");
+      result = 1;
+    }
+
+  if (pthread_attr_setguardsize (&nattr, 0))
+    {
+      puts ("pthread_attr_t setup failed");
+      result = 1;
+    }
+
+  if (mq_notify (q, &ev) == 0)
+    {
+      puts ("second mq_notify (q, { SIGEV_NONE }) unexpectedly succeeded");
+      result = 1;
+    }
+  else if (errno != EBUSY)
+    {
+      printf ("second mq_notify (q, { SIGEV_NONE }) failed with: %m\n");
+      result = 1;
+    }
+
+  if (fct_cnt != 1)
+    {
+      printf ("fct called too early (%d on %d)\n", fct_cnt, __LINE__);
+      result = 1;
+    }
+
+  result |= mqsend (q);
+
+  result |= mqrecv (q);
+  result |= mqrecv (q);
+
+  if (fct_cnt != 2)
+    {
+      printf ("fct not called (%d on %d)\n", fct_cnt, __LINE__);
+      result = 1;
+    }
+  else if (fct_guardsize != 32 * ps)
+    {
+      printf ("fct_guardsize %zd != %zd\n", fct_guardsize, 32 * ps);
+      result = 1;
+    }
+
+  if (mq_notify (q, &ev) != 0)
+    {
+      printf ("third mq_notify (q, { SIGEV_NONE }) failed with: %m\n");
+      result = 1;
+    }
+
+  if (mq_notify (q, NULL) != 0)
+    {
+      printf ("mq_notify (q, NULL) failed with: %m\n");
+      result = 1;
+    }
+
+  if (pthread_attr_destroy (&nattr) != 0)
+    {
+      puts ("pthread_attr_destroy failed");
+      result = 1;
+    }
+
+  if (mq_unlink (name) != 0)
+    {
+      printf ("mq_unlink failed: %m\n");
+      result = 1;
+    }
+
+  if (mq_close (q) != 0)
+    {
+      printf ("mq_close failed: %m\n");
+      result = 1;
+    }
+
+  memset (&ev, 0x55, sizeof (ev));
+  ev.sigev_notify = SIGEV_THREAD;
+  ev.sigev_notify_function = fct;
+  ev.sigev_notify_attributes = NULL;
+  ev.sigev_value.sival_int = 0;
+  if (mq_notify (q, &ev) == 0)
+    {
+      puts ("mq_notify on closed mqd_t unexpectedly succeeded");
+      result = 1;
+    }
+  else if (errno != EBADF)
+    {
+      printf ("mq_notify on closed mqd_t did not fail with EBADF: %m\n");
+      result = 1;
+    }
+
+  if (fct_err)
+    result = 1;
+  return result;
+}
+#else
+# define TEST_FUNCTION 0
+#endif
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/rt/tst-mqueue7.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-mqueue7.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-mqueue7.c	(revision 2036)
@@ -0,0 +1,109 @@
+/* Test all open message queues descriptors are closed during exec*.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <mqueue.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <time.h>
+#include <unistd.h>
+
+#define OPT_AFTEREXEC 20000
+
+static mqd_t after_exec = (mqd_t) -1;
+
+#define CMDLINE_OPTIONS \
+  { "after-exec", required_argument, NULL, OPT_AFTEREXEC },
+
+#define CMDLINE_PROCESS \
+  case OPT_AFTEREXEC:					\
+    after_exec = (mqd_t) strtoul (optarg, NULL, 0);	\
+    break;
+
+static int
+do_after_exec (void)
+{
+  int result = 0;
+
+  struct mq_attr attr;
+  if (mq_getattr (after_exec, &attr) == 0)
+    {
+      puts ("mq_getattr after exec unexpectedly succeeded");
+      result = 1;
+    }
+  else if (errno != EBADF)
+    {
+      printf ("mq_getattr after exec did not fail with EBADF: %m\n");
+      result = 1;
+    }
+
+  return result;
+}
+
+static int
+do_test (int argc, char **argv)
+{
+  if (after_exec != (mqd_t) -1)
+    return do_after_exec ();
+
+  char name[sizeof "/tst-mqueue7-" + sizeof (pid_t) * 3];
+  snprintf (name, sizeof (name), "/tst-mqueue7-%u", getpid ());
+
+  struct mq_attr attr = { .mq_maxmsg = 10, .mq_msgsize = 1 };
+  mqd_t q = mq_open (name, O_CREAT | O_EXCL | O_WRONLY, 0600, &attr);
+
+  if (q == (mqd_t) -1)
+    {
+      printf ("mq_open failed with: %m\n");
+      return 0;
+    }
+  else if (mq_unlink (name) != 0)
+    {
+      printf ("mq_unlink failed with: %m\n");
+      return 1;
+    }
+
+  if (mq_getattr (q, &attr) != 0)
+    {
+      printf ("mq_getattr failed: %m\n");
+      return 1;
+    }
+
+  char after_exec_arg[sizeof "--after-exec=0x" + sizeof (long) * 3];
+  snprintf (after_exec_arg, sizeof (after_exec_arg),
+	    "--after-exec=0x%lx", (long) q);
+
+  const char *newargv[argc + 2];
+  for (int i = 1; i < argc; ++i)
+    newargv[i - 1] = argv[i];
+  newargv[argc - 1] = "--direct";
+  newargv[argc] = after_exec_arg;
+  newargv[argc + 1] = NULL;
+
+  /* Verify that exec* has the effect of mq_close (q).  */
+  execv (newargv[0], (char * const *) newargv);
+  printf ("execv failed: %m\n");
+  return 1;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/rt/tst-mqueue8.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-mqueue8.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-mqueue8.c	(revision 2036)
@@ -0,0 +1,266 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <mqueue.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#if _POSIX_THREADS
+# include <pthread.h>
+
+static pthread_barrier_t b;
+
+/* Cleanup handling test.  */
+static int cl_called;
+
+static void
+cl (void *arg)
+{
+  ++cl_called;
+}
+
+#define TF_MQ_RECEIVE		0L
+#define TF_MQ_TIMEDRECEIVE	1L
+#define TF_MQ_SEND		2L
+#define TF_MQ_TIMEDSEND		3L
+
+static const char *names[]
+  = { "mq_receive", "mq_timedreceive", "mq_send", "mq_timedsend" };
+
+static mqd_t q;
+static struct timespec never;
+
+static void *
+tf (void *arg)
+{
+  int r = pthread_barrier_wait (&b);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("tf: barrier_wait failed");
+      exit (1);
+    }
+
+  pthread_cleanup_push (cl, NULL);
+
+  char c = ' ';
+
+  switch ((long) arg)
+    {
+    case TF_MQ_SEND:
+      TEMP_FAILURE_RETRY (mq_send (q, &c, 1, 1));
+      break;
+    case TF_MQ_TIMEDSEND:
+      TEMP_FAILURE_RETRY (mq_timedsend (q, &c, 1, 1, &never));
+      break;
+    case TF_MQ_RECEIVE:
+      TEMP_FAILURE_RETRY (mq_receive (q, &c, 1, NULL));
+      break;
+    case TF_MQ_TIMEDRECEIVE:
+      TEMP_FAILURE_RETRY (mq_timedreceive (q, &c, 1, NULL, &never));
+      break;
+    }
+
+  pthread_cleanup_pop (0);
+
+  printf ("tf: %s returned\n", names[(long) arg]);
+
+  exit (1);
+}
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+  char name[sizeof "/tst-mqueue8-" + sizeof (pid_t) * 3];
+  snprintf (name, sizeof (name), "/tst-mqueue8-%u", getpid ());
+
+  struct mq_attr attr = { .mq_maxmsg = 1, .mq_msgsize = 1 };
+  q = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr);
+
+  if (q == (mqd_t) -1)
+    {
+      printf ("mq_open failed with: %m\n");
+      return 0;
+    }
+
+  if (mq_unlink (name) != 0)
+    {
+      printf ("mq_unlink failed with: %m\n");
+      return 1;
+    }
+
+  if (pthread_barrier_init (&b, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      return 1;
+    }
+
+  if (clock_gettime (CLOCK_REALTIME, &never) == 0)
+    never.tv_sec += 100;
+  else
+    {
+      never.tv_sec = time (NULL) + 100;
+      never.tv_nsec = 0;
+    }
+
+  int result = 0;
+  for (long l = TF_MQ_RECEIVE; l <= TF_MQ_TIMEDSEND; ++l)
+    {
+      cl_called = 0;
+
+      pthread_t th;
+      if (pthread_create (&th, NULL, tf, (void *) l) != 0)
+	{
+	  printf ("1st %s create failed\n", names[l]);
+	  result = 1;
+	  continue;
+	}
+
+      int r = pthread_barrier_wait (&b);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  puts ("barrier_wait failed");
+	  result = 1;
+	  continue;
+	}
+
+      struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 };
+      while (nanosleep (&ts, &ts) != 0)
+	continue;
+
+      printf ("going to cancel %s in-time\n", names[l]);
+      if (pthread_cancel (th) != 0)
+	{
+	  printf ("1st cancel of %s failed\n", names[l]);
+	  result = 1;
+	  continue;
+	}
+
+      void *status;
+      if (pthread_join (th, &status) != 0)
+	{
+	  printf ("1st join of %s failed\n", names[l]);
+	  result = 1;
+	  continue;
+	}
+      if (status != PTHREAD_CANCELED)
+	{
+	  printf ("1st %s thread not canceled\n", names[l]);
+	  result = 1;
+	  continue;
+	}
+
+      if (cl_called == 0)
+	{
+	  printf ("%s cleanup handler not called\n", names[l]);
+	  result = 1;
+	  continue;
+	}
+      if (cl_called > 1)
+	{
+	  printf ("%s cleanup handler called more than once\n", names[l]);
+	  result = 1;
+	  continue;
+	}
+
+      printf ("in-time %s cancellation succeeded\n", names[l]);
+
+      cl_called = 0;
+
+      if (pthread_create (&th, NULL, tf, (void *) l) != 0)
+	{
+	  printf ("2nd %s create failed\n", names[l]);
+	  result = 1;
+	  continue;
+	}
+
+      printf ("going to cancel %s early\n", names[l]);
+      if (pthread_cancel (th) != 0)
+	{
+	  printf ("2nd cancel of %s failed\n", names[l]);
+	  result = 1;
+	  continue;
+	}
+
+      r = pthread_barrier_wait (&b);
+      if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+	{
+	  puts ("barrier_wait failed");
+	  result = 1;
+	  continue;
+	}
+
+      if (pthread_join (th, &status) != 0)
+	{
+	  printf ("2nd join of %s failed\n", names[l]);
+	  result = 1;
+	  continue;
+	}
+      if (status != PTHREAD_CANCELED)
+	{
+	  printf ("2nd %s thread not canceled\n", names[l]);
+	  result = 1;
+	  continue;
+	}
+
+      if (cl_called == 0)
+	{
+	  printf ("%s cleanup handler not called\n", names[l]);
+	  result = 1;
+	  continue;
+	}
+      if (cl_called > 1)
+	{
+	  printf ("%s cleanup handler called more than once\n", names[l]);
+	  result = 1;
+	  continue;
+	}
+
+      printf ("early %s cancellation succeeded\n", names[l]);
+
+      if (l == TF_MQ_TIMEDRECEIVE)
+	{
+	  /* mq_receive and mq_timedreceive are tested on empty mq.
+	     For mq_send and mq_timedsend we need to make it full.
+	     If this fails, there is no point in doing further testing.  */
+	  char c = ' ';
+	  if (mq_send (q, &c, 1, 1) != 0)
+	    {
+	      printf ("mq_send failed: %m\n");
+	      result = 1;
+	      break;
+	    }
+	}
+    }
+
+  if (mq_close (q) != 0)
+    {
+      printf ("mq_close failed: %m\n");
+      result = 1;
+    }
+
+  return result;
+}
+#else
+# define TEST_FUNCTION 0
+#endif
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/rt/tst-mqueue9.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-mqueue9.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-mqueue9.c	(revision 2036)
@@ -0,0 +1,92 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <mqueue.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include "tst-mqueue.h"
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+  if (geteuid () != 0)
+    {
+      puts ("this test requires root");
+      return 0;
+    }
+
+  char name[sizeof "/tst-mqueue9-" + sizeof (pid_t) * 3];
+  snprintf (name, sizeof (name), "/tst-mqueue9-%u", getpid ());
+
+  struct mq_attr attr = { .mq_maxmsg = 1, .mq_msgsize = 1 };
+  mqd_t q = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr);
+
+  if (q == (mqd_t) -1)
+    {
+      printf ("mq_open failed with: %m\n");
+      return 0;
+    }
+  else
+    add_temp_mq (name);
+
+  if (seteuid (1) != 0)
+    {
+      printf ("failed to seteuid (1): %m\n");
+      mq_unlink (name);
+      return 0;
+    }
+
+  int result = 0;
+  if (mq_unlink (name) == 0)
+    {
+      puts ("mq_unlink unexpectedly succeeded");
+      result = 1;
+    }
+  else if (errno != EACCES)
+    {
+      printf ("mq_unlink did not fail with EACCES: %m\n");
+      result = 1;;
+    }
+
+  if (seteuid (0) != 0)
+    {
+      printf ("failed to seteuid (0): %m\n");
+      result = 1;
+    }
+
+  if (mq_unlink (name) != 0)
+    {
+      printf ("mq_unlink failed with: %m\n");
+      result = 1;
+    }
+
+  if (mq_close (q) != 0)
+    {
+      printf ("mq_close failed with: %m\n");
+      result = 1;
+    }
+
+  return result;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/rt/tst-shm.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-shm.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-shm.c	(revision 2036)
@@ -0,0 +1,207 @@
+/* Test program for POSIX shm_* functions.
+   Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <error.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+
+
+/* We want to see output immediately.  */
+#define STDOUT_UNBUFFERED
+
+
+static int
+do_open (void)
+{
+  int fd;
+
+  /* Create the shared memory object.  */
+  fd = shm_open ("/shm-test", O_RDWR, 0600);
+  if (fd == -1)
+    {
+      /* We don't regard this as a bug.  Simply don't run the test.  It could
+	 means there is no such implementation or the object is already in
+	 use in which case we don't want to disturb.  */
+      perror ("failed to open shared memory object: shm_open");
+      return -1;
+    }
+
+  return fd;
+}
+
+
+static void
+worker (int write_now)
+{
+  struct timespec ts;
+  struct stat st;
+  int i;
+  int fd = do_open ();
+  char *mem;
+
+  if (fd == -1)
+    exit (fd);
+
+  if (fstat (fd, &st) == -1 || st.st_size != 4000)
+    error (EXIT_FAILURE, 0, "stat failed");
+
+  mem = mmap (NULL, 4000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+  if (mem == NULL)
+    error (EXIT_FAILURE, 0, "mmap failed");
+
+  ts.tv_sec = 0;
+  ts.tv_nsec = 500000000;
+
+  if (write_now)
+    for (i = 0; i <= 4; ++i)
+      mem[i] = i;
+  else
+    /* Wait until the first bytes of the memory region are 0, 1, 2, 3, 4.  */
+    while (1)
+      {
+	for (i = 0; i <= 4; ++i)
+	  if (mem[i] != i)
+	    break;
+
+	if (i > 4)
+	  /* OK, that's done.  */
+	  break;
+
+	nanosleep (&ts, NULL);
+      }
+
+  if (!write_now)
+    for (i = 0; i <= 4; ++i)
+      mem[i] = 4 + i;
+  else
+    /* Wait until the first bytes of the memory region are 4, 5, 6, 7, 8.  */
+    while (1)
+      {
+	for (i = 0; i <= 4; ++i)
+	  if (mem[i] != 4 + i)
+	    break;
+
+	if (i > 4)
+	  /* OK, that's done.  */
+	  break;
+
+	nanosleep (&ts, NULL);
+      }
+
+  if (munmap (mem, 4000) == -1)
+    error (EXIT_FAILURE, errno, "munmap");
+
+  close (fd);
+
+  exit (0);
+}
+
+
+static int
+do_test (void)
+{
+  int fd;
+  pid_t pid1;
+  pid_t pid2;
+  int status1;
+  int status2;
+  struct stat st;
+
+  /* Create the shared memory object.  */
+  fd = shm_open ("/shm-test", O_RDWR | O_CREAT | O_TRUNC | O_EXCL, 0600);
+  if (fd == -1)
+    {
+      /* We don't regard this as a bug.  Simply don't run the test.  It could
+	 means there is no such implementation or the object is already in
+	 use in which case we don't want to disturb.  */
+      perror ("failed to create a shared memory object: shm_open");
+      return 0;
+    }
+
+  /* Size the object.  We make it 4000 bytes long.  */
+  if (ftruncate (fd, 4000) == -1)
+    {
+      /* This failed.  Must be a bug in the implementation of the
+         shared memory itself.  */
+      perror ("failed to size of shared memory object: ftruncate");
+      close (fd);
+      shm_unlink ("/shm-test");
+      return 0;
+    }
+
+  if (fstat (fd, &st) == -1 || st.st_size != 4000)
+    {
+      shm_unlink ("/shm-test");
+      error (EXIT_FAILURE, 0, "initial stat failed");
+    }
+
+  /* Spawn to processes which will do the work.  */
+  pid1 = fork ();
+  if (pid1 == 0)
+    worker (0);
+  else if (pid1 == -1)
+    {
+      /* Couldn't create a second process.  */
+      perror ("fork");
+      close (fd);
+      shm_unlink ("/shm-test");
+      return 0;
+    }
+
+  pid2 = fork ();
+  if (pid2 == 0)
+    worker (1);
+  else if (pid2 == -1)
+    {
+      /* Couldn't create a second process.  */
+      int ignore;
+      perror ("fork");
+      kill (pid1, SIGTERM);
+      waitpid (pid1, &ignore, 0);
+      close (fd);
+      shm_unlink ("/shm-test");
+      return 0;
+    }
+
+  /* Wait until the two processes are finished.  */
+  waitpid (pid1, &status1, 0);
+  waitpid (pid2, &status2, 0);
+
+  /* Now we can unlink the shared object.  */
+  shm_unlink ("/shm-test");
+
+  return (!WIFEXITED (status1) || WEXITSTATUS (status1) != 0
+	  || !WIFEXITED (status2) || WEXITSTATUS (status2) != 0);
+}
+#define TEST_FUNCTION do_test ()
+
+#define CLEANUP_HANDLER shm_unlink ("/shm-test");
+
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/rt/tst-timer2.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-timer2.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-timer2.c	(revision 2036)
@@ -0,0 +1,65 @@
+/* Test for crashing bugs when trying to create too many timers.  */
+
+#include <stdio.h>
+#include <time.h>
+#include <signal.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <unistd.h>
+
+#if _POSIX_THREADS
+# include <pthread.h>
+
+void
+thread (union sigval arg)
+{
+  puts ("Timeout");
+}
+
+int
+do_test (void)
+{
+  int i, res;
+  timer_t timerId;
+  struct itimerspec itval;
+  struct sigevent sigev;
+
+  itval.it_interval.tv_sec = 2;
+  itval.it_interval.tv_nsec = 0;
+  itval.it_value.tv_sec = 2;
+  itval.it_value.tv_nsec = 0;
+
+  sigev.sigev_notify = SIGEV_THREAD;
+  sigev.sigev_signo = SIGRTMIN;
+  sigev.sigev_notify_function = thread;
+  sigev.sigev_notify_attributes = 0;
+  sigev.sigev_value.sival_ptr = (void *) &timerId;
+
+  for (i = 0; i < 100; i++)
+    {
+      printf ("cnt = %d\n", i);
+
+      if (timer_create (CLOCK_REALTIME, &sigev, &timerId) < 0)
+	{
+	  perror ("timer_create");
+	  continue;
+	}
+
+      res = timer_settime (timerId, 0, &itval, NULL);
+      if (res < 0)
+	perror ("timer_settime");
+
+      res = timer_delete (timerId);
+      if (res < 0)
+	perror ("timer_delete");
+    }
+
+  return 0;
+}
+
+# define TEST_FUNCTION do_test ()
+#else
+# define TEST_FUNCTION 0
+#endif
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/rt/tst-timer3.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-timer3.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-timer3.c	(revision 2036)
@@ -0,0 +1,86 @@
+/* Test for bogus per-thread deletion of timers.  */
+
+#include <stdio.h>
+#include <error.h>
+#include <time.h>
+#include <signal.h>
+#include <stdint.h>
+#include <string.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <unistd.h>
+#if _POSIX_THREADS
+# include <pthread.h>
+
+
+/* Creating timers in another thread should work too.  */
+static void *
+do_timer_create (void *arg)
+{
+  struct sigevent *const sigev = arg;
+  timer_t *const timerId = sigev->sigev_value.sival_ptr;
+  if (timer_create (CLOCK_REALTIME, sigev, timerId) < 0)
+    {
+      printf ("timer_create: %m\n");
+      return NULL;
+    }
+  return timerId;
+}
+
+
+static int
+do_test (void)
+{
+  int i, res;
+  timer_t timerId;
+  struct itimerspec itval;
+  struct sigevent sigev;
+
+  itval.it_interval.tv_sec = 2;
+  itval.it_interval.tv_nsec = 0;
+  itval.it_value.tv_sec = 2;
+  itval.it_value.tv_nsec = 0;
+
+  sigev.sigev_notify = SIGEV_SIGNAL;
+  sigev.sigev_signo = SIGALRM;
+  sigev.sigev_value.sival_ptr = (void *) &timerId;
+
+  for (i = 0; i < 100; i++)
+    {
+      printf ("cnt = %d\n", i);
+
+      pthread_t thr;
+      res = pthread_create (&thr, NULL, &do_timer_create, &sigev);
+      if (res)
+	{
+	  printf ("pthread_create: %s\n", strerror (res));
+	  continue;
+	}
+      void *val;
+      res = pthread_join (thr, &val);
+      if (res)
+	{
+	  printf ("pthread_join: %s\n", strerror (res));
+	  continue;
+	}
+      if (val == NULL)
+	continue;
+
+      res = timer_settime (timerId, 0, &itval, NULL);
+      if (res < 0)
+	printf ("timer_settime: %m\n");
+
+      res = timer_delete (timerId);
+      if (res < 0)
+	printf ("timer_delete: %m\n");
+    }
+
+  return 0;
+}
+
+# define TEST_FUNCTION do_test ()
+#else
+# define TEST_FUNCTION 0
+#endif
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/rt/tst-timer4.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-timer4.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-timer4.c	(revision 2036)
@@ -0,0 +1,648 @@
+/* Tests for POSIX timer implementation.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2004
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+#if _POSIX_THREADS
+# include <pthread.h>
+
+# ifndef TEST_CLOCK
+#  define TEST_CLOCK		CLOCK_REALTIME
+# endif
+
+pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+
+timer_t timer_none, timer_sig1, timer_sig2, timer_thr1, timer_thr2;
+
+int thr1_cnt, thr1_err;
+union sigval thr1_sigval;
+struct timespec thr1_ts;
+
+static void
+thr1 (union sigval sigval)
+{
+  pthread_mutex_lock (&lock);
+  thr1_err = clock_gettime (TEST_CLOCK, &thr1_ts);
+  if (thr1_cnt >= 5)
+    {
+      struct itimerspec it = { };
+      thr1_err |= timer_settime (timer_thr1, 0, &it, NULL);
+    }
+  thr1_sigval = sigval;
+  ++thr1_cnt;
+  pthread_cond_signal (&cond);
+  pthread_mutex_unlock (&lock);
+}
+
+int thr2_cnt, thr2_err;
+union sigval thr2_sigval;
+size_t thr2_guardsize;
+struct timespec thr2_ts;
+
+static void
+thr2 (union sigval sigval)
+{
+  pthread_attr_t nattr;
+  int err = 0;
+  size_t guardsize = -1;
+  int ret = pthread_getattr_np (pthread_self (), &nattr);
+  if (ret)
+    {
+      errno = ret;
+      printf ("*** pthread_getattr_np failed: %m\n");
+      err = 1;
+    }
+  else
+    {
+      ret = pthread_attr_getguardsize (&nattr, &guardsize);
+      if (ret)
+        {
+          errno = ret;
+          printf ("*** pthread_attr_getguardsize failed: %m\n");
+          err = 1;
+        }
+      if (pthread_attr_destroy (&nattr) != 0)
+        {
+          puts ("*** pthread_attr_destroy failed");
+          err = 1;
+        }
+    }
+  pthread_mutex_lock (&lock);
+  thr2_err = clock_gettime (TEST_CLOCK, &thr2_ts) | err;
+  if (thr2_cnt >= 5)
+    {
+      struct itimerspec it = { };
+      thr2_err |= timer_settime (timer_thr2, 0, &it, NULL);
+    }
+  thr2_sigval = sigval;
+  ++thr2_cnt;
+  thr2_guardsize = guardsize;
+  pthread_cond_signal (&cond);
+  pthread_mutex_unlock (&lock);
+}
+
+volatile int sig1_cnt, sig1_err;
+volatile union sigval sig1_sigval;
+struct timespec sig1_ts;
+
+static void
+sig1_handler (int sig, siginfo_t *info, void *ctx)
+{
+  int err = 0;
+  if (sig != SIGRTMIN) err |= 1 << 0;
+  if (info->si_signo != SIGRTMIN) err |= 1 << 1;
+  if (info->si_code != SI_TIMER) err |= 1 << 2;
+  if (clock_gettime (TEST_CLOCK, &sig1_ts) != 0)
+    err |= 1 << 3;
+  if (sig1_cnt >= 5)
+    {
+      struct itimerspec it = { };
+      if (timer_settime (timer_sig1, 0, &it, NULL))
+	err |= 1 << 4;
+    }
+  sig1_err |= err;
+  sig1_sigval = info->si_value;
+  ++sig1_cnt;
+}
+
+volatile int sig2_cnt, sig2_err;
+volatile union sigval sig2_sigval;
+struct timespec sig2_ts;
+
+static void
+sig2_handler (int sig, siginfo_t *info, void *ctx)
+{
+  int err = 0;
+  if (sig != SIGRTMIN + 1) err |= 1 << 0;
+  if (info->si_signo != SIGRTMIN + 1) err |= 1 << 1;
+  if (info->si_code != SI_TIMER) err |= 1 << 2;
+  if (clock_gettime (TEST_CLOCK, &sig2_ts) != 0)
+    err |= 1 << 3;
+  if (sig2_cnt >= 5)
+    {
+      struct itimerspec it = { };
+      if (timer_settime (timer_sig2, 0, &it, NULL))
+	err |= 1 << 4;
+    }
+  sig2_err |= err;
+  sig2_sigval = info->si_value;
+  ++sig2_cnt;
+}
+
+/* Check if end is later or equal to start + nsec.  */
+static int
+check_ts (const char *name, const struct timespec *start,
+	  const struct timespec *end, long msec)
+{
+  struct timespec ts = *start;
+
+  ts.tv_sec += msec / 1000000;
+  ts.tv_nsec += (msec % 1000000) * 1000;
+  if (ts.tv_nsec >= 1000000000)
+    {
+      ++ts.tv_sec;
+      ts.tv_nsec -= 1000000000;
+    }
+  if (end->tv_sec < ts.tv_sec
+      || (end->tv_sec == ts.tv_sec && end->tv_nsec < ts.tv_nsec))
+    {
+      printf ("\
+*** timer %s invoked too soon: %ld.%09ld instead of expected %ld.%09ld\n",
+	      name, (long) end->tv_sec, end->tv_nsec,
+	      (long) ts.tv_sec, ts.tv_nsec);
+      return 1;
+    }
+  else
+    return 0;
+}
+
+#define TIMEOUT 15
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+  int result = 0;
+
+#ifdef TEST_CLOCK_MISSING
+  const char *missing = TEST_CLOCK_MISSING (TEST_CLOCK);
+  if (missing != NULL)
+    {
+      printf ("%s missing, skipping test\n", missing);
+      return 0;
+    }
+#endif
+
+  struct timespec ts;
+  if (clock_gettime (TEST_CLOCK, &ts) != 0)
+    {
+      printf ("*** clock_gettime failed: %m\n");
+      result = 1;
+    }
+  else
+    printf ("clock_gettime returned timespec = { %ld, %ld }\n",
+	    (long) ts.tv_sec, ts.tv_nsec);
+
+  if (clock_getres (TEST_CLOCK, &ts) != 0)
+    {
+      printf ("*** clock_getres failed: %m\n");
+      result = 1;
+    }
+  else
+    printf ("clock_getres returned timespec = { %ld, %ld }\n",
+	    (long) ts.tv_sec, ts.tv_nsec);
+
+  struct sigevent ev;
+  memset (&ev, 0x11, sizeof (ev));
+  ev.sigev_notify = SIGEV_NONE;
+  if (timer_create (TEST_CLOCK, &ev, &timer_none) != 0)
+    {
+      printf ("*** timer_create for timer_none failed: %m\n");
+      return 1;
+    }
+
+  struct sigaction sa = { .sa_sigaction = sig1_handler,
+			  .sa_flags = SA_SIGINFO };
+  sigemptyset (&sa.sa_mask);
+  sigaction (SIGRTMIN, &sa, NULL);
+  sa.sa_sigaction = sig2_handler;
+  sigaction (SIGRTMIN + 1, &sa, NULL);
+
+  memset (&ev, 0x22, sizeof (ev));
+  ev.sigev_notify = SIGEV_SIGNAL;
+  ev.sigev_signo = SIGRTMIN;
+  ev.sigev_value.sival_ptr = &ev;
+  if (timer_create (TEST_CLOCK, &ev, &timer_sig1) != 0)
+    {
+      printf ("*** timer_create for timer_sig1 failed: %m\n");
+      return 1;
+    }
+
+  memset (&ev, 0x33, sizeof (ev));
+  ev.sigev_notify = SIGEV_SIGNAL;
+  ev.sigev_signo = SIGRTMIN + 1;
+  ev.sigev_value.sival_int = 163;
+  if (timer_create (TEST_CLOCK, &ev, &timer_sig2) != 0)
+    {
+      printf ("*** timer_create for timer_sig2 failed: %m\n");
+      return 1;
+    }
+
+  memset (&ev, 0x44, sizeof (ev));
+  ev.sigev_notify = SIGEV_THREAD;
+  ev.sigev_notify_function = thr1;
+  ev.sigev_notify_attributes = NULL;
+  ev.sigev_value.sival_ptr = &ev;
+  if (timer_create (TEST_CLOCK, &ev, &timer_thr1) != 0)
+    {
+      printf ("*** timer_create for timer_thr1 failed: %m\n");
+      return 1;
+    }
+
+  pthread_attr_t nattr;
+  if (pthread_attr_init (&nattr)
+      || pthread_attr_setguardsize (&nattr, 0))
+    {
+      puts ("*** pthread_attr_t setup failed");
+      result = 1;
+    }
+
+  memset (&ev, 0x55, sizeof (ev));
+  ev.sigev_notify = SIGEV_THREAD;
+  ev.sigev_notify_function = thr2;
+  ev.sigev_notify_attributes = &nattr;
+  ev.sigev_value.sival_int = 111;
+  if (timer_create (TEST_CLOCK, &ev, &timer_thr2) != 0)
+    {
+      printf ("*** timer_create for timer_thr2 failed: %m\n");
+      return 1;
+    }
+
+  int ret = timer_getoverrun (timer_thr1);
+  if (ret != 0)
+    {
+      if (ret == -1)
+	printf ("*** timer_getoverrun failed: %m\n");
+      else
+	printf ("*** timer_getoverrun returned %d != 0\n", ret);
+      result = 1;
+    }
+
+  struct itimerspec it;
+  it.it_value.tv_sec = 0;
+  it.it_value.tv_nsec = -26;
+  it.it_interval.tv_sec = 0;
+  it.it_interval.tv_nsec = 0;
+  if (timer_settime (timer_sig1, 0, &it, NULL) == 0)
+    {
+      puts ("*** timer_settime with negative tv_nsec unexpectedly succeeded");
+      result = 1;
+    }
+  else if (errno != EINVAL)
+    {
+      printf ("*** timer_settime with negative tv_nsec did not fail with "
+	      "EINVAL: %m\n");
+      result = 1;
+    }
+
+  it.it_value.tv_nsec = 100000;
+  it.it_interval.tv_nsec = 1000000000;
+  if (timer_settime (timer_sig2, 0, &it, NULL) == 0)
+    {
+      puts ("\
+*** timer_settime with tv_nsec 1000000000 unexpectedly succeeded");
+      result = 1;
+    }
+  else if (errno != EINVAL)
+    {
+      printf ("*** timer_settime with tv_nsec 1000000000 did not fail with "
+	      "EINVAL: %m\n");
+      result = 1;
+    }
+
+#if 0
+  it.it_value.tv_nsec = 0;
+  it.it_interval.tv_nsec = -26;
+  if (timer_settime (timer_thr1, 0, &it, NULL) != 0)
+    {
+      printf ("\
+!!! timer_settime with it_value 0 it_interval invalid failed: %m\n");
+      /* FIXME: is this mandated by POSIX?
+      result = 1; */
+    }
+
+  it.it_interval.tv_nsec = 3000000000;
+  if (timer_settime (timer_thr2, 0, &it, NULL) != 0)
+    {
+      printf ("\
+!!! timer_settime with it_value 0 it_interval invalid failed: %m\n");
+      /* FIXME: is this mandated by POSIX?
+      result = 1; */
+    }
+#endif
+
+  struct timespec startts;
+  if (clock_gettime (TEST_CLOCK, &startts) != 0)
+    {
+      printf ("*** clock_gettime failed: %m\n");
+      result = 1;
+    }
+
+  it.it_value.tv_nsec = 100000000;
+  it.it_interval.tv_nsec = 0;
+  if (timer_settime (timer_none, 0, &it, NULL) != 0)
+    {
+      printf ("*** timer_settime timer_none failed: %m\n");
+      result = 1;
+    }
+
+  it.it_value.tv_nsec = 200000000;
+  if (timer_settime (timer_thr1, 0, &it, NULL) != 0)
+    {
+      printf ("*** timer_settime timer_thr1 failed: %m\n");
+      result = 1;
+    }
+
+  it.it_value.tv_nsec = 300000000;
+  if (timer_settime (timer_thr2, 0, &it, NULL) != 0)
+    {
+      printf ("*** timer_settime timer_thr2 failed: %m\n");
+      result = 1;
+    }
+
+  it.it_value.tv_nsec = 400000000;
+  if (timer_settime (timer_sig1, 0, &it, NULL) != 0)
+    {
+      printf ("*** timer_settime timer_sig1 failed: %m\n");
+      result = 1;
+    }
+
+  it.it_value.tv_nsec = 500000000;
+  if (TEMP_FAILURE_RETRY (timer_settime (timer_sig2, 0, &it, NULL)) != 0)
+    {
+      printf ("*** timer_settime timer_sig2 failed: %m\n");
+      result = 1;
+    }
+
+  pthread_mutex_lock (&lock);
+  while (thr1_cnt == 0 || thr2_cnt == 0)
+    pthread_cond_wait (&cond, &lock);
+  pthread_mutex_unlock (&lock);
+
+  while (sig1_cnt == 0 || sig2_cnt == 0)
+    {
+      ts.tv_sec = 0;
+      ts.tv_nsec = 100000000;
+      nanosleep (&ts, NULL);
+    }
+
+  pthread_mutex_lock (&lock);
+
+  if (thr1_cnt != 1)
+    {
+      printf ("*** thr1 not called exactly once, but %d times\n", thr1_cnt);
+      result = 1;
+    }
+  else if (thr1_err)
+    {
+      puts ("*** an error occurred in thr1");
+      result = 1;
+    }
+  else if (thr1_sigval.sival_ptr != &ev)
+    {
+      printf ("*** thr1_sigval.sival_ptr %p != %p\n",
+	      thr1_sigval.sival_ptr, &ev);
+      result = 1;
+    }
+  else if (check_ts ("thr1", &startts, &thr1_ts, 200000))
+    result = 1;
+
+  if (thr2_cnt != 1)
+    {
+      printf ("*** thr2 not called exactly once, but %d times\n", thr2_cnt);
+      result = 1;
+    }
+  else if (thr2_err)
+    {
+      puts ("*** an error occurred in thr2");
+      result = 1;
+    }
+  else if (thr2_sigval.sival_int != 111)
+    {
+      printf ("*** thr2_sigval.sival_ptr %d != 111\n", thr2_sigval.sival_int);
+      result = 1;
+    }
+  else if (check_ts ("thr2", &startts, &thr2_ts, 300000))
+    result = 1;
+  else if (thr2_guardsize != 0)
+    {
+      printf ("*** thr2 guardsize %zd != 0\n", thr2_guardsize);
+      result = 1;
+    }
+
+  pthread_mutex_unlock (&lock);
+
+  if (sig1_cnt != 1)
+    {
+      printf ("*** sig1 not called exactly once, but %d times\n", sig1_cnt);
+      result = 1;
+    }
+  else if (sig1_err)
+    {
+      printf ("*** errors occurred in sig1 handler %x\n", sig1_err);
+      result = 1;
+    }
+  else if (sig1_sigval.sival_ptr != &ev)
+    {
+      printf ("*** sig1_sigval.sival_ptr %p != %p\n",
+	      sig1_sigval.sival_ptr, &ev);
+      result = 1;
+    }
+  else if (check_ts ("sig1", &startts, &sig1_ts, 400000))
+    result = 1;
+
+  if (sig2_cnt != 1)
+    {
+      printf ("*** sig2 not called exactly once, but %d times\n", sig2_cnt);
+      result = 1;
+    }
+  else if (sig2_err)
+    {
+      printf ("*** errors occurred in sig2 handler %x\n", sig2_err);
+      result = 1;
+    }
+  else if (sig2_sigval.sival_int != 163)
+    {
+      printf ("*** sig2_sigval.sival_ptr %d != 163\n", sig2_sigval.sival_int);
+      result = 1;
+    }
+  else if (check_ts ("sig2", &startts, &sig2_ts, 500000))
+    result = 1;
+
+  if (timer_gettime (timer_none, &it) != 0)
+    {
+      printf ("*** timer_gettime timer_none failed: %m\n");
+      result = 1;
+    }
+  else if (it.it_value.tv_sec || it.it_value.tv_nsec
+	   || it.it_interval.tv_sec || it.it_interval.tv_nsec)
+    {
+      printf ("\
+*** timer_gettime timer_none returned { %ld.%09ld, %ld.%09ld }\n",
+	      (long) it.it_value.tv_sec, it.it_value.tv_nsec,
+	      (long) it.it_interval.tv_sec, it.it_interval.tv_nsec);
+      result = 1;
+    }
+
+  if (clock_gettime (TEST_CLOCK, &startts) != 0)
+    {
+      printf ("*** clock_gettime failed: %m\n");
+      result = 1;
+    }
+
+  it.it_value.tv_sec = 1;
+  it.it_value.tv_nsec = 0;
+  it.it_interval.tv_sec = 0;
+  it.it_interval.tv_nsec = 100000000;
+  if (timer_settime (timer_none, 0, &it, NULL) != 0)
+    {
+      printf ("*** timer_settime timer_none failed: %m\n");
+      result = 1;
+    }
+
+  it.it_value.tv_nsec = 100000000;
+  it.it_interval.tv_nsec = 200000000;
+  if (timer_settime (timer_thr1, 0, &it, NULL) != 0)
+    {
+      printf ("*** timer_settime timer_thr1 failed: %m\n");
+      result = 1;
+    }
+
+  it.it_value.tv_nsec = 200000000;
+  it.it_interval.tv_nsec = 300000000;
+  if (timer_settime (timer_thr2, 0, &it, NULL) != 0)
+    {
+      printf ("*** timer_settime timer_thr2 failed: %m\n");
+      result = 1;
+    }
+
+  it.it_value.tv_nsec = 300000000;
+  it.it_interval.tv_nsec = 400000000;
+  if (timer_settime (timer_sig1, 0, &it, NULL) != 0)
+    {
+      printf ("*** timer_settime timer_sig1 failed: %m\n");
+      result = 1;
+    }
+
+  it.it_value.tv_nsec = 400000000;
+  it.it_interval.tv_nsec = 500000000;
+  if (TEMP_FAILURE_RETRY (timer_settime (timer_sig2, 0, &it, NULL)) != 0)
+    {
+      printf ("*** timer_settime timer_sig2 failed: %m\n");
+      result = 1;
+    }
+
+  pthread_mutex_lock (&lock);
+  while (thr1_cnt < 6 || thr2_cnt < 6)
+    pthread_cond_wait (&cond, &lock);
+  pthread_mutex_unlock (&lock);
+
+  while (sig1_cnt < 6 || sig2_cnt < 6)
+    {
+      ts.tv_sec = 0;
+      ts.tv_nsec = 100000000;
+      nanosleep (&ts, NULL);
+    }
+
+  pthread_mutex_lock (&lock);
+
+  if (thr1_err)
+    {
+      puts ("*** an error occurred in thr1");
+      result = 1;
+    }
+  else if (check_ts ("thr1", &startts, &thr1_ts, 1100000 + 4 * 200000))
+    result = 1;
+
+  if (thr2_err)
+    {
+      puts ("*** an error occurred in thr2");
+      result = 1;
+    }
+  else if (check_ts ("thr2", &startts, &thr2_ts, 1200000 + 4 * 300000))
+    result = 1;
+  else if (thr2_guardsize != 0)
+    {
+      printf ("*** thr2 guardsize %zd != 0\n", thr2_guardsize);
+      result = 1;
+    }
+
+  pthread_mutex_unlock (&lock);
+
+  if (sig1_err)
+    {
+      printf ("*** errors occurred in sig1 handler %x\n", sig1_err);
+      result = 1;
+    }
+  else if (check_ts ("sig1", &startts, &sig1_ts, 1300000 + 4 * 400000))
+    result = 1;
+
+  if (sig2_err)
+    {
+      printf ("*** errors occurred in sig2 handler %x\n", sig2_err);
+      result = 1;
+    }
+  else if (check_ts ("sig2", &startts, &sig2_ts, 1400000 + 4 * 500000))
+    result = 1;
+
+  if (timer_gettime (timer_none, &it) != 0)
+    {
+      printf ("*** timer_gettime timer_none failed: %m\n");
+      result = 1;
+    }
+  else if (it.it_interval.tv_sec || it.it_interval.tv_nsec != 100000000)
+    {
+      printf ("\
+!!! second timer_gettime timer_none returned it_interval %ld.%09ld\n",
+	      (long) it.it_interval.tv_sec, it.it_interval.tv_nsec);
+      /* FIXME: For now disabled.
+      result = 1; */
+    }
+
+  if (timer_delete (timer_none) != 0)
+    {
+      printf ("*** timer_delete for timer_none failed: %m\n");
+      result = 1;
+    }
+
+  if (timer_delete (timer_sig1) != 0)
+    {
+      printf ("*** timer_delete for timer_sig1 failed: %m\n");
+      result = 1;
+    }
+
+  if (timer_delete (timer_sig2) != 0)
+    {
+      printf ("*** timer_delete for timer_sig2 failed: %m\n");
+      result = 1;
+    }
+
+  if (timer_delete (timer_thr1) != 0)
+    {
+      printf ("*** timer_delete for timer_thr1 failed: %m\n");
+      result = 1;
+    }
+
+  if (timer_delete (timer_thr2) != 0)
+    {
+      printf ("*** timer_delete for timer_thr2 failed: %m\n");
+      result = 1;
+    }
+  return result;
+}
+#else
+# define TEST_FUNCTION 0
+#endif
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/rt/tst-timer5.c
===================================================================
--- trunk/src/libctests/glibc/rt/tst-timer5.c	(revision 2036)
+++ trunk/src/libctests/glibc/rt/tst-timer5.c	(revision 2036)
@@ -0,0 +1,38 @@
+/* Timer test using the monotonic clock.  */
+
+#include <time.h>
+#include <unistd.h>
+
+#if defined CLOCK_MONOTONIC && defined _POSIX_MONOTONIC_CLOCK
+
+# define TEST_CLOCK	CLOCK_MONOTONIC
+# define TEST_CLOCK_MISSING(clock) \
+  (setup_test () ? "CLOCK_MONOTONIC" : NULL)
+
+# include <stdio.h>
+
+static int
+setup_test (void)
+{
+  if (sysconf (_SC_MONOTONIC_CLOCK) <= 0)
+    return 1;
+
+  /* The user-level timers implementation doesn't support CLOCK_MONOTONIC,
+     even though sysconf claims it will.  */
+  timer_t t;
+  if (timer_create (TEST_CLOCK, NULL, &t) != 0)
+    {
+      printf ("timer_create: %m\n");
+      return 1;
+    }
+  timer_delete (t);
+
+  return 0;
+}
+
+# include "tst-timer4.c"
+
+#else
+# define TEST_FUNCTION	0
+# include "../test-skeleton.c"
+#endif
Index: trunk/src/libctests/glibc/setjmp/Makefile
===================================================================
--- trunk/src/libctests/glibc/setjmp/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/setjmp/Makefile	(revision 2036)
@@ -0,0 +1,32 @@
+# Copyright (C) 1991, 92, 93, 94, 95, 97 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Makefile for setjmp/longjmp routines
+#
+subdir	:= setjmp
+
+headers	:= setjmp.h bits/setjmp.h
+
+routines	:= setjmp sigjmp bsd-setjmp bsd-_setjmp \
+		   longjmp __longjmp jmp-unwind
+
+tests		:= tst-setjmp jmpbug bug269-setjmp
+
+
+include ../Rules
Index: trunk/src/libctests/glibc/setjmp/tst-setjmp.c
===================================================================
--- trunk/src/libctests/glibc/setjmp/tst-setjmp.c	(revision 2036)
+++ trunk/src/libctests/glibc/setjmp/tst-setjmp.c	(revision 2036)
@@ -0,0 +1,118 @@
+/* Copyright (C) 1991, 1992, 1997, 1998, 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <setjmp.h>
+#include <stdlib.h>
+
+static jmp_buf env;
+static int last_value = -1, lose = 0;
+
+static void
+jump (int val)
+{
+  longjmp (env, val);
+}
+
+int
+main (void)
+{
+  int value;
+
+  value = setjmp (env);
+  if (value != last_value + 1)
+    {
+      fputs("Shouldn't have ", stdout);
+      lose = 1;
+    }
+  last_value = value;
+  switch (value)
+    {
+    case 0:
+      puts("Saved environment.");
+      jump (0);
+    default:
+      printf ("Jumped to %d.\n", value);
+      if (value < 10)
+	jump (value + 1);
+    }
+
+  if (!lose && value == 10)
+    {
+      /* Do a second test, this time without `setjmp' being a macro.
+         This is not required by ISO C but we have this for compatibility.  */
+#undef setjmp
+      extern int setjmp (jmp_buf);
+
+      last_value = -1;
+      lose = 0;
+
+      value = setjmp (env);
+      if (value != last_value + 1)
+	{
+	  fputs("Shouldn't have ", stdout);
+	  lose = 1;
+	}
+      last_value = value;
+      switch (value)
+	{
+	case 0:
+	  puts("Saved environment.");
+	  jump (0);
+	default:
+	  printf ("Jumped to %d.\n", value);
+	  if (value < 10)
+	    jump (value + 1);
+	}
+    }
+
+  if (!lose && value == 10)
+    {
+      /* And again for the `_setjmp' function.  */
+#ifndef _setjmp
+      extern int _setjmp (jmp_buf);
+#endif
+      last_value = -1;
+      lose = 0;
+
+      value = _setjmp (env);
+      if (value != last_value + 1)
+	{
+	  fputs("Shouldn't have ", stdout);
+	  lose = 1;
+	}
+      last_value = value;
+      switch (value)
+	{
+	case 0:
+	  puts("Saved environment.");
+	  jump (0);
+	default:
+	  printf ("Jumped to %d.\n", value);
+	  if (value < 10)
+	    jump (value + 1);
+	}
+    }
+
+  if (lose || value != 10)
+    puts ("Test FAILED!");
+  else
+    puts ("Test succeeded!");
+
+  return lose ? EXIT_FAILURE : EXIT_SUCCESS;
+}
Index: trunk/src/libctests/glibc/signal/Makefile
===================================================================
--- trunk/src/libctests/glibc/signal/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/signal/Makefile	(revision 2036)
@@ -0,0 +1,52 @@
+# Copyright (C) 1991,1992,1993,1994,1995,1996,1997,1998,2003
+#	Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Makefile for signal routines.
+#
+subdir	:= signal
+
+headers	:= signal.h sys/signal.h bits/signum.h bits/sigcontext.h \
+	   bits/sigaction.h bits/sigset.h bits/siginfo.h bits/sigstack.h \
+	   bits/sigthread.h
+
+routines	:= signal raise killpg \
+		   sigaction sigprocmask kill \
+		   sigpending sigsuspend sigwait \
+		   sigblock sigsetmask sigpause sigvec \
+		   sigstack sigaltstack sigintr \
+		   sigsetops sigempty sigfillset sigaddset sigdelset sigismem \
+		   sigreturn \
+		   siggetmask sysv_signal \
+		   sigisempty sigandset sigorset \
+		   allocrtsig sigtimedwait sigwaitinfo sigqueue \
+		   sighold sigrelse sigignore sigset
+
+tests		:= tst-signal tst-sigset tst-sigsimple tst-raise
+
+distribute	:= sigsetops.h testrtsig.h sigset-cvt-mask.h
+
+
+include ../Rules
+
+CFLAGS-sigpause.c = -fexceptions
+CFLAGS-sigsuspend.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-sigtimedwait.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-sigwait.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-sigwaitinfo.c = -fexceptions -fasynchronous-unwind-tables
Index: trunk/src/libctests/glibc/signal/tst-raise.c
===================================================================
--- trunk/src/libctests/glibc/signal/tst-raise.c	(revision 2036)
+++ trunk/src/libctests/glibc/signal/tst-raise.c	(revision 2036)
@@ -0,0 +1,62 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <error.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+volatile int count;
+
+void
+sh (int sig)
+{
+  ++count;
+}
+
+int
+main (void)
+{
+  struct sigaction sa;
+  sa.sa_handler = sh;
+  sigemptyset (&sa.sa_mask);
+  sa.sa_flags = 0;
+  if (sigaction (SIGUSR1, &sa, NULL) < 0)
+    {
+      printf ("sigaction failed: %m\n");
+      exit (1);
+    }
+  if (raise (SIGUSR1) < 0)
+    {
+      printf ("first raise failed: %m\n");
+      exit (1);
+    }
+  if (raise (SIGUSR1) < 0)
+    {
+      printf ("second raise failed: %m\n");
+      exit (1);
+    }
+  if (count != 2)
+    {
+      printf ("signal handler not called 2 times\n");
+      exit (1);
+    }
+  exit (0);
+}
Index: trunk/src/libctests/glibc/signal/tst-signal.c
===================================================================
--- trunk/src/libctests/glibc/signal/tst-signal.c	(revision 2036)
+++ trunk/src/libctests/glibc/signal/tst-signal.c	(revision 2036)
@@ -0,0 +1,44 @@
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int win = 0;
+
+static void
+handler (int sig)
+{
+  printf ("Received signal %d (%s).\n", sig, strsignal(sig));
+  win = 1;
+}
+
+int
+main (void)
+{
+  if (signal (SIGTERM, handler) == SIG_ERR)
+    {
+      perror ("signal: SIGTERM");
+      exit (EXIT_FAILURE);
+    }
+
+  puts ("Set handler.");
+
+  printf ("Sending myself signal %d.\n", SIGTERM);
+  fflush (stdout);
+
+  if (raise (SIGTERM) < 0)
+    {
+      perror ("raise: SIGTERM");
+      exit (EXIT_FAILURE);
+    }
+
+  if (!win)
+    {
+      puts ("Didn't get any signal.  Test FAILED!");
+      exit (EXIT_FAILURE);
+    }
+
+  puts ("Got a signal.  Test succeeded.");
+
+  return EXIT_SUCCESS;
+}
Index: trunk/src/libctests/glibc/signal/tst-sigset.c
===================================================================
--- trunk/src/libctests/glibc/signal/tst-sigset.c	(revision 2036)
+++ trunk/src/libctests/glibc/signal/tst-sigset.c	(revision 2036)
@@ -0,0 +1,43 @@
+/* Test sig*set functions.  */
+
+#include <signal.h>
+#include <stdio.h>
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+  int result = 0;
+  int sig = -1;
+
+#define TRY(call)							      \
+  if (call)								      \
+    {									      \
+      printf ("%s (sig = %d): %m\n", #call, sig);			      \
+      result = 1;							      \
+    }									      \
+  else
+
+
+  sigset_t set;
+  TRY (sigemptyset (&set) != 0);
+
+#ifdef SIGRTMAX
+  int max_sig = SIGRTMAX;
+#else
+  int max_sig = NSIG - 1;
+#endif
+
+  for (sig = 1; sig <= max_sig; ++sig)
+    {
+      TRY (sigismember (&set, sig) != 0);
+      TRY (sigaddset (&set, sig) != 0);
+      TRY (sigismember (&set, sig) == 0);
+      TRY (sigdelset (&set, sig) != 0);
+      TRY (sigismember (&set, sig) != 0);
+    }
+
+  return result;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/signal/tst-sigsimple.c
===================================================================
--- trunk/src/libctests/glibc/signal/tst-sigsimple.c	(revision 2036)
+++ trunk/src/libctests/glibc/signal/tst-sigsimple.c	(revision 2036)
@@ -0,0 +1,57 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <string.h>
+
+
+static int
+do_test (void)
+{
+  int result = 0;
+  int e;
+
+#define RUN(test) \
+  errno = 0;								      \
+  e = test;								      \
+  if (e != -1)								      \
+    {									      \
+      printf ("%s returned %d\n", #test, e);				      \
+      result = 1;							      \
+    }									      \
+  else if (errno != EINVAL)						      \
+    {									      \
+      printf ("%s didn't set errno to EINVAL (%s instead)\n",		      \
+	      #test, strerror (errno));					      \
+      result = 1;							      \
+    }
+
+  RUN (sighold (-1));
+  RUN (sighold (_NSIG + 100));
+
+  RUN (sigrelse (-1));
+  RUN (sigrelse (_NSIG + 100));
+
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/soft-fp/Makefile
===================================================================
--- trunk/src/libctests/glibc/soft-fp/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/soft-fp/Makefile	(revision 2036)
@@ -0,0 +1,44 @@
+# Copyright (C) 1997, 1999, 2000  Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Makefile for software floating-point routines
+#
+subdir	:= soft-fp
+
+gcc-single-routines := negsf2 addsf3 subsf3 mulsf3 divsf3 eqsf2 \
+	lesf2 gesf2 fixsfsi fixunssfsi floatsisf fixsfdi        \
+	fixunssfdi floatdisf sqrtsf2
+
+gcc-double-routines := negdf2 adddf3 subdf3 muldf3 divdf3 eqdf2 \
+	ledf2 gedf2 fixdfsi fixunsdfsi floatsidf fixdfdi        \
+	fixunsdfdi floatdidf extendsfdf2 truncdfsf2 sqrtdf2
+
+gcc-quad-routines := negtf2 addtf3 subtf3 multf3 divtf3 eqtf2 \
+	letf2 getf2 fixtfsi fixunstfsi floatsitf fixtfdi      \
+	fixunstfdi floatditf extendsftf2 trunctfsf2 extenddftf2 \
+	trunctfdf2 sqrttf2
+
+distribute := double.h op-1.h op-2.h op-4.h op-common.h quad.h \
+	single.h soft-fp.h extended.h Banner op-8.h testit.c \
+	$(addsuffix .c,$(gcc-single-routines)) \
+	$(addsuffix .c,$(gcc-double-routines)) \
+	$(addsuffix .c,$(gcc-quad-routines))
+
+include ../Rules
Index: trunk/src/libctests/glibc/soft-fp/testit.c
===================================================================
--- trunk/src/libctests/glibc/soft-fp/testit.c	(revision 2036)
+++ trunk/src/libctests/glibc/soft-fp/testit.c	(revision 2036)
@@ -0,0 +1,788 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include "soft-fp.h"
+#include "single.h"
+#include "double.h"
+
+#include <fpu_control.h>
+
+/*======================================================================*/
+/* declarations for the functions we are testing */
+
+double __adddf3(double, double);
+double __subdf3(double, double);
+double __muldf3(double, double);
+double __divdf3(double, double);
+double __negdf2(double);
+double __sqrtdf2(double);
+double __negdf3(double a, double dummy) { return __negdf2(a); }
+double __sqrtdf3(double a, double dummy) { return __sqrtdf2(a); }
+
+float __addsf3(float, float);
+float __subsf3(float, float);
+float __mulsf3(float, float);
+float __divsf3(float, float);
+float __negsf2(float);
+float __sqrtsf2(float);
+float __negsf3(float a, float dummy) { return __negsf2(a); }
+float __sqrtsf3(float a, float dummy) { return __sqrtsf2(a); }
+
+int __fixdfsi(double);
+int __fixsfsi(float);
+double __floatsidf(int);
+float __floatsisf(int);
+double __extendsfdf2(float);
+float __truncdfsf2(double);
+
+int __eqdf2(double, double);
+int __nedf2(double, double);
+int __gtdf2(double, double);
+int __gedf2(double, double);
+int __ltdf2(double, double);
+int __ledf2(double, double);
+
+int __eqsf2(float, float);
+int __nesf2(float, float);
+int __gtsf2(float, float);
+int __gesf2(float, float);
+int __ltsf2(float, float);
+int __lesf2(float, float);
+
+/*======================================================================*/
+/* definitions for functions we are checking against */
+
+double r_adddf3(double a, double b) { return a + b; }
+double r_subdf3(double a, double b) { return a - b; }
+double r_muldf3(double a, double b) { return a * b; }
+double r_divdf3(double a, double b) { return a / b; }
+double r_negdf3(double a, double b) { return -a; }
+double sqrt(double x);
+double r_sqrtdf3(double a, double b) { return sqrt(a); }
+
+float r_addsf3(float a, float b) { return a + b; }
+float r_subsf3(float a, float b) { return a - b; }
+float r_mulsf3(float a, float b) { return a * b; }
+float r_divsf3(float a, float b) { return a / b; }
+float r_negsf3(float a, float b) { return -a; }
+float sqrtf(float x);
+float r_sqrtsf3(float a, float b) { return sqrtf(a); }
+
+int r_fixdfsi(double a) { return (int)a; }
+int r_fixsfsi(float a) { return (int)a; }
+double r_floatsidf(int a) { return (double)a; }
+float r_floatsisf(int a) { return (float)a; }
+double r_extendsfdf2(float a) { return (double)a; }
+float r_truncdfsf2(double a) { return (float)a; }
+
+int r_eqdf2(double a, double b) { return !(a == b); }
+int r_nedf2(double a, double b) { return a != b; }
+int r_gtdf2(double a, double b) { return a > b; }
+int r_gedf2(double a, double b) { return (a >= b) - 1; }
+int r_ltdf2(double a, double b) { return -(a < b); }
+int r_ledf2(double a, double b) { return 1 - (a <= b); }
+
+int r_eqsf2(float a, float b) { return !(a == b); }
+int r_nesf2(float a, float b) { return a != b; }
+int r_gtsf2(float a, float b) { return a > b; }
+int r_gesf2(float a, float b) { return (a >= b) - 1; }
+int r_ltsf2(float a, float b) { return -(a < b); }
+int r_lesf2(float a, float b) { return 1 - (a <= b); }
+
+/*======================================================================*/
+
+void print_float(float x)
+{
+    union _FP_UNION_S ux;
+    ux.flt = x;
+    printf("%-20.8e %X %02X %06lX",
+	   x, ux.bits.sign, ux.bits.exp, (unsigned long)ux.bits.frac);
+}
+
+void print_double(double x)
+{
+    union _FP_UNION_D ux;
+    ux.flt = x;
+#if _FP_W_TYPE_SIZE < _FP_FRACBITS_D
+    printf("%-30.18e %X %04X %06lX%08lX",
+	   x, ux.bits.sign, ux.bits.exp,
+	   (unsigned long)ux.bits.frac1, (unsigned long)ux.bits.frac0);
+#else
+    printf("%-30.18e %X %04X %014lX",
+	   x, ux.bits.sign, ux.bits.exp,
+	   (unsigned long)ux.bits.frac);
+#endif
+}
+
+float rand_float(void)
+{
+    union {
+	union _FP_UNION_S u;
+	int i;
+    } u;
+
+    u.i = lrand48() << 1;
+
+    if (u.u.bits.exp == _FP_EXPMAX_S)
+	u.u.bits.exp--;
+    else if (u.u.bits.exp == 0 && u.u.bits.frac != 0)
+	u.u.bits.exp++;
+
+    return u.u.flt;
+}
+
+
+double rand_double(void)
+{
+    union {
+	union _FP_UNION_D u;
+	int i[2];
+    } u;
+
+    u.i[0] = lrand48() << 1;
+    u.i[1] = lrand48() << 1;
+
+    if (u.u.bits.exp == _FP_EXPMAX_D)
+	u.u.bits.exp--;
+#if _FP_W_TYPE_SIZE < _FP_FRACBITS_D
+    else if (u.u.bits.exp == 0 && !(u.u.bits.frac0 == 0 && u.u.bits.frac1 == 0))
+	u.u.bits.exp++;
+#else
+    else if (u.u.bits.exp == 0 && u.u.bits.frac != 0)
+	u.u.bits.exp++;
+#endif
+
+    return u.u.flt;
+}
+
+#define NSPECIALS  10
+
+float gen_special_float(int i)
+{
+    FP_DECL_EX;
+    FP_DECL_S(X);
+    float x;
+
+    switch (i & ~1)
+    {
+      case 0:
+	X_c = FP_CLS_NAN; X_f = 0x1234;
+	break;
+      case 2:
+	X_c = FP_CLS_NAN; X_f = 0x1;
+	break;
+      case 4:
+	X_c = FP_CLS_INF;
+	break;
+      case 6:
+	X_c = FP_CLS_ZERO;
+	break;
+      case 8:
+	X_c = FP_CLS_NORMAL; X_e = 0;
+	X_f = 0x4321;
+	break;
+    }
+    X_s = (i & 1);
+
+    FP_PACK_S(x, X);
+    return x;
+}
+
+double gen_special_double(int i)
+{
+    FP_DECL_EX;
+    FP_DECL_D(X);
+    double x;
+
+    switch (i & ~1)
+    {
+      case 0:
+	X_c = FP_CLS_NAN;
+#if _FP_W_TYPE_SIZE < _FP_FRACBITS_D
+	__FP_FRAC_SET_2(X, _FP_QNANBIT_D, 0x1234);
+#else
+	_FP_FRAC_SET_1(X, _FP_QNANBIT_D | 0x1234);
+#endif
+	break;
+      case 2:
+	X_c = FP_CLS_NAN;
+#if _FP_W_TYPE_SIZE < _FP_FRACBITS_D
+	__FP_FRAC_SET_2(X, _FP_QNANBIT_D, 0x1);
+#else
+	_FP_FRAC_SET_1(X, _FP_QNANBIT_D | 0x1);
+#endif
+	break;
+      case 4:
+	X_c = FP_CLS_INF;
+	break;
+      case 6:
+	X_c = FP_CLS_ZERO;
+	break;
+      case 8:
+	X_c = FP_CLS_NORMAL; X_e = 0;
+#if _FP_W_TYPE_SIZE < _FP_FRACBITS_D
+	__FP_FRAC_SET_2(X, 0, 0x87654321);
+#else
+	_FP_FRAC_SET_1(X, 0x87654321);
+#endif
+	break;
+    }
+    X_s = (i & 1);
+
+    FP_PACK_D(x, X);
+    return x;
+}
+
+float build_float(const char *s, const char *e, const char *f)
+{
+    union _FP_UNION_S u;
+
+    u.bits.sign = strtoul(s, 0, 16);
+    u.bits.exp = strtoul(e, 0, 16);
+    u.bits.frac = strtoul(f, 0, 16);
+
+    return u.flt;
+}
+      
+double build_double(const char *s, const char *e, const char *f)
+{
+    union _FP_UNION_D u;
+
+    u.bits.sign = strtoul(s, 0, 16);
+    u.bits.exp = strtoul(e, 0, 16);
+#if _FP_W_TYPE_SIZE < _FP_FRACBITS_D
+    {
+	size_t len = strlen(f)+1;
+	char *dup = memcpy(alloca(len), f, len);
+	char *low = dup + len - _FP_W_TYPE_SIZE/4 - 1;
+
+	u.bits.frac0 = strtoul(low, 0, 16);
+	*low = 0;
+	u.bits.frac1 = strtoul(dup, 0, 16);
+    }
+#else
+    u.bits.frac = strtoul(f, 0, 16);
+#endif
+	
+    return u.flt;
+}
+      
+/*======================================================================*/
+
+fpu_control_t fcw0, fcw1;
+
+void test_float_arith(float (*tf)(float, float),
+		      float (*rf)(float, float),
+		      float x, float y)
+{
+    float tr, rr;
+    rr = (*rf)(x, y);
+    tr = (*tf)(x, y);
+    if (memcmp(&tr, &rr, sizeof(float)) != 0)
+    {
+	fputs("error:\n\tx     = ", stdout); print_float(x);
+	fputs("\n\ty     = ", stdout); print_float(y);
+	fputs("\n\ttrue  = ", stdout); print_float(rr);
+	fputs("\n\tfalse = ", stdout); print_float(tr);
+	putchar('\n');
+    }
+}
+
+void test_double_arith(double (*tf)(double, double),
+		       double (*rf)(double, double),
+		       double x, double y)
+{
+    double tr, rr;
+#ifdef __i386__
+    /* Don't worry.  Even this does not make it error free
+       on ia32.  If the result is denormal,  it will not
+       honour the double precision and generate bad results
+       anyway.  On the other side,  who wants to use ia32
+       for IEEE math?  I don't.  */
+    _FPU_GETCW(fcw0);
+    fcw1 = ((fcw0 & ~_FPU_EXTENDED) | _FPU_DOUBLE);
+    _FPU_SETCW(fcw1);
+#endif    
+    rr = (*rf)(x, y);
+#ifdef __i386__
+    _FPU_SETCW(fcw0);
+#endif
+    tr = (*tf)(x, y);
+    if (memcmp(&tr, &rr, sizeof(double)) != 0)
+    {
+	fputs("error:\n\tx     = ", stdout); print_double(x);
+	fputs("\n\ty     = ", stdout); print_double(y);
+	fputs("\n\ttrue  = ", stdout); print_double(rr);
+	fputs("\n\tfalse = ", stdout); print_double(tr);
+	putchar('\n');
+    }
+}
+
+void test_float_double_conv(float x)
+{
+    double tr, rr;
+    rr = r_extendsfdf2(x);
+    tr = __extendsfdf2(x);
+    if (memcmp(&tr, &rr, sizeof(double)) != 0)
+    {
+	fputs("error:\n\tx     = ", stdout); print_float(x);
+	fputs("\n\ttrue  = ", stdout); print_double(rr);
+	fputs("\n\tfalse = ", stdout); print_double(tr);
+	putchar('\n');
+    }
+}
+
+void test_double_float_conv(double x)
+{
+    float tr, rr;
+    rr = r_truncdfsf2(x);
+    tr = __truncdfsf2(x);
+    if (memcmp(&tr, &rr, sizeof(float)) != 0)
+    {
+	fputs("error:\n\tx     = ", stdout); print_double(x);
+	fputs("\n\ttrue  = ", stdout); print_float(rr);
+	fputs("\n\tfalse = ", stdout); print_float(tr);
+	putchar('\n');
+    }
+}
+
+void test_int_float_conv(int x)
+{
+    float tr, rr;
+    rr = r_floatsisf(x);
+    tr = __floatsisf(x);
+    if (memcmp(&tr, &rr, sizeof(float)) != 0)
+    {
+	printf("error\n\tx     = %d", x);
+	fputs("\n\ttrue  = ", stdout); print_float(rr);
+	fputs("\n\tfalse = ", stdout); print_float(tr);
+	putchar('\n');
+    }
+}
+
+void test_int_double_conv(int x)
+{
+    double tr, rr;
+    rr = r_floatsidf(x);
+    tr = __floatsidf(x);
+    if (memcmp(&tr, &rr, sizeof(double)) != 0)
+    {
+	printf("error\n\tx     = %d", x);
+	fputs("\n\ttrue  = ", stdout); print_double(rr);
+	fputs("\n\tfalse = ", stdout); print_double(tr);
+	putchar('\n');
+    }
+}
+
+void test_float_int_conv(float x)
+{
+    int tr, rr;
+    rr = r_fixsfsi(x);
+    tr = __fixsfsi(x);
+    if (rr != tr)
+    {
+	fputs("error:\n\tx     = ", stdout); print_float(x);
+	printf("\n\ttrue  = %d\n\tfalse = %d\n", rr, tr);
+    }
+}
+	
+void test_double_int_conv(double x)
+{
+    int tr, rr;
+    rr = r_fixsfsi(x);
+    tr = __fixsfsi(x);
+    if (rr != tr)
+    {
+	fputs("error:\n\tx     = ", stdout); print_double(x);
+	printf("\n\ttrue  = %d\n\tfalse = %d\n", rr, tr);
+    }
+}
+
+int eq0(int x) { return x == 0; }
+int ne0(int x) { return x != 0; }
+int le0(int x) { return x <= 0; }
+int lt0(int x) { return x < 0; }
+int ge0(int x) { return x >= 0; }
+int gt0(int x) { return x > 0; }
+
+void test_float_cmp(int (*tf)(float, float),
+		    int (*rf)(float, float),
+		    int (*cmp0)(int),
+		    float x, float y)
+{
+    int tr, rr;
+    rr = (*rf)(x, y);
+    tr = (*tf)(x, y);
+    if (cmp0(rr) != cmp0(tr))
+    {
+	fputs("error:\n\tx     = ", stdout); print_float(x);
+	fputs("\n\ty     = ", stdout); print_float(y);
+	printf("\n\ttrue  = %d\n\tfalse = %d\n", rr, tr);
+    }
+}
+
+void test_double_cmp(int (*tf)(double, double),
+		     int (*rf)(double, double),
+		     int (*cmp0)(int),
+		     double x, double y)
+{
+    int tr, rr;
+    rr = (*rf)(x, y);
+    tr = (*tf)(x, y);
+    if (cmp0(rr) != cmp0(tr))
+    {
+	fputs("error:\n\tx     = ", stdout); print_double(x);
+	fputs("\n\ty     = ", stdout); print_double(y);
+	printf("\n\ttrue  = %d\n\tfalse = %d\n", rr, tr);
+    }
+}
+
+
+/*======================================================================*/
+
+
+int main(int ac, char **av)
+{
+#ifdef __alpha__
+    __ieee_set_fp_control(0);
+#endif
+    av++, ac--;
+    switch (*(*av)++)
+    {
+	{
+	    float (*r)(float, float);
+	    float (*t)(float, float);
+
+	    do {
+	      case 'a': r = r_addsf3; t = __addsf3; break;
+	      case 's': r = r_subsf3; t = __subsf3; break;
+	      case 'm': r = r_mulsf3; t = __mulsf3; break;
+	      case 'd': r = r_divsf3; t = __divsf3; break;
+	      case 'r': r = r_sqrtsf3; t = __sqrtsf3; break;
+	      case 'j': r = r_negsf3; t = __negsf3; break;
+	    } while (0);
+
+	    switch (*(*av)++)
+	    {
+	      case 'n':
+		{
+		    int count = (ac > 1 ? atoi(av[1]) : 100);
+		    while (count--)
+			test_float_arith(t, r, rand_float(), rand_float());
+		}
+		break;
+
+	      case 's':
+		{
+		    int i, j;
+		    for (i = 0; i < NSPECIALS; i++)
+			for (j = 0; j < NSPECIALS; j++)
+			    test_float_arith(t, r, gen_special_float(i),
+					      gen_special_float(j));
+		}
+		break;
+
+	      case 0:
+		if (ac < 7) abort();
+		test_float_arith(t, r, build_float(av[1], av[2], av[3]),
+				 build_float(av[4], av[5], av[6]));
+		break;
+	    }
+	}
+	break;
+
+	{
+	    double (*r)(double, double);
+	    double (*t)(double, double);
+
+	    do {
+	      case 'A': r = r_adddf3; t = __adddf3; break;
+	      case 'S': r = r_subdf3; t = __subdf3; break;
+	      case 'M': r = r_muldf3; t = __muldf3; break;
+	      case 'D': r = r_divdf3; t = __divdf3; break;
+	      case 'R': r = r_sqrtdf3; t = __sqrtdf3; break;
+	      case 'J': r = r_negdf3; t = __negdf3; break;
+	    } while (0);
+
+	    switch (*(*av)++)
+	    {
+	      case 'n':
+		{
+		    int count = (ac > 1 ? atoi(av[1]) : 100);
+		    while (count--)
+			test_double_arith(t, r, rand_double(), rand_double());
+		}
+		break;
+
+	      case 's':
+		{
+		    int i, j;
+		    for (i = 0; i < NSPECIALS; i++)
+			for (j = 0; j < NSPECIALS; j++)
+			    test_double_arith(t, r, gen_special_double(i),
+					      gen_special_double(j));
+		}
+		break;
+
+	      case 0:
+		if (ac < 7) abort();
+		test_double_arith(t, r, build_double(av[1], av[2], av[3]),
+				  build_double(av[4], av[5], av[6]));
+		break;
+	    }
+	}
+	break;
+
+      case 'c':
+	switch (*(*av)++)
+	{
+	  case 'n':
+	    {
+		int count = (ac > 1 ? atoi(av[1]) : 100);
+		while (count--)
+		    test_float_double_conv(rand_float());
+	    }
+	    break;
+
+	  case 's':
+	    {
+		int i;
+		for (i = 0; i < NSPECIALS; i++)
+		    test_float_double_conv(gen_special_float(i));
+	    }
+	    break;
+
+	  case 0:
+	    if (ac < 4) abort();
+	    test_float_double_conv(build_float(av[1], av[2], av[3]));
+	    break;
+	}
+	break;
+
+      case 'C':
+	switch (*(*av)++)
+	{
+	  case 'n':
+	    {
+		int count = (ac > 1 ? atoi(av[1]) : 100);
+		while (count--)
+		    test_double_float_conv(rand_double());
+	    }
+	    break;
+
+	  case 's':
+	    {
+		int i;
+		for (i = 0; i < NSPECIALS; i++)
+		    test_double_float_conv(gen_special_double(i));
+	    }
+	    break;
+
+	  case 0:
+	    if (ac < 4) abort();
+	    test_double_float_conv(build_double(av[1], av[2], av[3]));
+	    break;
+	}
+	break;
+
+      case 'i':
+	switch (*(*av)++)
+	{
+	  case 'n':
+	    {
+		int count = (ac > 1 ? atoi(av[1]) : 100);
+		while (count--)
+		    test_int_float_conv(lrand48() << 1);
+	    }
+	    break;
+
+	  case 0:
+	    if (ac < 2) abort();
+	    test_int_float_conv(strtol(av[1], 0, 0));
+	    break;
+	}
+	break;
+
+      case 'I':
+	switch (*(*av)++)
+	{
+	  case 'n':
+	    {
+		int count = (ac > 1 ? atoi(av[1]) : 100);
+		while (count--)
+		    test_int_double_conv(lrand48() << 1);
+	    }
+	    break;
+
+	  case 0:
+	    if (ac < 2) abort();
+	    test_int_double_conv(strtol(av[1], 0, 0));
+	    break;
+	}
+	break;
+
+      case 'f':
+	switch (*(*av)++)
+	{
+	  case 'n':
+	    {
+		int count = (ac > 1 ? atoi(av[1]) : 100);
+		while (count--)
+		    test_float_int_conv(rand_float());
+	    }
+	    break;
+
+	  case 's':
+	    {
+		int i;
+		for (i = 0; i < NSPECIALS; i++)
+		    test_float_int_conv(gen_special_float(i));
+	    }
+	    break;
+
+	  case 0:
+	    if (ac < 4) abort();
+	    test_float_int_conv(build_float(av[1], av[2], av[3]));
+	    break;
+	}
+	break;
+
+      case 'F':
+	switch (*(*av)++)
+	{
+	  case 'n':
+	    {
+		int count = (ac > 1 ? atoi(av[1]) : 100);
+		while (count--)
+		    test_double_int_conv(rand_double());
+	    }
+	    break;
+
+	  case 's':
+	    {
+		int i;
+		for (i = 0; i < NSPECIALS; i++)
+		    test_double_int_conv(gen_special_double(i));
+	    }
+	    break;
+
+	  case 0:
+	    if (ac < 4) abort();
+	    test_double_int_conv(build_double(av[1], av[2], av[3]));
+	    break;
+	}
+	break;
+
+	{
+	    int (*r)(float, float);
+	    int (*t)(float, float);
+	    int (*c)(int);
+
+	    do {
+	      case 'e': r = r_eqsf2; t = __eqsf2; c = eq0; break;
+	      case 'n': r = r_nesf2; t = __nesf2; c = ne0; break;
+	      case 'l':
+		switch (*(*av)++)
+		{
+		  case 'e': r = r_lesf2; t = __lesf2; c = le0; break;
+		  case 't': r = r_ltsf2; t = __ltsf2; c = lt0; break;
+		}
+		break;
+	      case 'g':
+		switch (*(*av)++)
+		{
+		  case 'e': r = r_gesf2; t = __gesf2; c = ge0; break;
+		  case 't': r = r_gtsf2; t = __gtsf2; c = gt0; break;
+		}
+		break;
+	    } while (0);
+
+	    switch (*(*av)++)
+	    {
+	      case 'n':
+		{
+		    int count = (ac > 1 ? atoi(av[1]) : 100);
+		    while (count--)
+			test_float_cmp(t, r, c, rand_float(), rand_float());
+		}
+		break;
+
+	      case 's':
+		{
+		    int i, j;
+		    for (i = 0; i < NSPECIALS; i++)
+			for (j = 0; j < NSPECIALS; j++)
+			    test_float_cmp(t, r, c, gen_special_float(i),
+					   gen_special_float(j));
+		}
+		break;
+
+	      case 0:
+		if (ac < 7) abort();
+		test_float_cmp(t, r, c, build_float(av[1], av[2], av[3]),
+				build_float(av[4], av[5], av[6]));
+		break;
+	    }
+	}
+	break;
+
+	{
+	    int (*r)(double, double);
+	    int (*t)(double, double);
+	    int (*c)(int);
+
+	    do {
+	      case 'E': r = r_eqdf2; t = __eqdf2; c = eq0; break;
+	      case 'N': r = r_nedf2; t = __nedf2; c = ne0; break;
+	      case 'L':
+		switch (*(*av)++)
+		{
+		  case 'E': r = r_ledf2; t = __ledf2; c = le0; break;
+		  case 'T': r = r_ltdf2; t = __ltdf2; c = lt0; break;
+		}
+		break;
+	      case 'G':
+		switch (*(*av)++)
+		{
+		  case 'E': r = r_gedf2; t = __gedf2; c = ge0; break;
+		  case 'T': r = r_gtdf2; t = __gtdf2; c = gt0; break;
+		}
+		break;
+	    } while (0);
+
+	    switch (*(*av)++)
+	    {
+	      case 'n':
+		{
+		    int count = (ac > 1 ? atoi(av[1]) : 100);
+		    while (count--)
+			test_double_cmp(t, r, c, rand_double(), rand_double());
+		}
+		break;
+
+	      case 's':
+		{
+		    int i, j;
+		    for (i = 0; i < NSPECIALS; i++)
+			for (j = 0; j < NSPECIALS; j++)
+			    test_double_cmp(t, r, c, gen_special_double(i),
+					    gen_special_double(j));
+		}
+		break;
+
+	      case 0:
+		if (ac < 7) abort();
+		test_double_cmp(t, r, c, build_double(av[1], av[2], av[3]),
+				build_double(av[4], av[5], av[6]));
+		break;
+	    }
+	}
+	break;
+
+      default:
+	abort();
+    }
+
+    return 0;
+}
Index: trunk/src/libctests/glibc/stdio-common/Makefile
===================================================================
--- trunk/src/libctests/glibc/stdio-common/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/Makefile	(revision 2036)
@@ -0,0 +1,102 @@
+# Copyright (C) 1991-2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Specific makefile for stdio-common.
+#
+subdir	:= stdio-common
+
+headers	:= printf.h stdio_ext.h
+
+routines	:=							      \
+	ctermid cuserid							      \
+	_itoa _itowa itoa-digits itoa-udigits itowa-digits		      \
+	vfprintf vprintf printf_fp reg-printf printf-prs printf_fphex	      \
+	printf_size fprintf printf snprintf sprintf asprintf dprintf	      \
+	vfwprintf vfscanf vfwscanf					      \
+	fscanf scanf sscanf						      \
+	perror psignal							      \
+	tmpfile tmpfile64 tmpnam tmpnam_r tempnam tempname		      \
+	getline getw putw						      \
+	remove rename							      \
+	flockfile ftrylockfile funlockfile
+
+install-others = $(inst_includedir)/bits/stdio_lim.h
+
+include ../Makeconfig
+
+aux	:= errlist siglist printf-parsemb printf-parsewc
+distribute := _itoa.h _itowa.h _i18n_number.h \
+	      printf-parse.h stdio_lim.h.in tst-unbputc.sh tst-printf.sh
+
+tests := tstscanf test_rdwr test-popen tstgetln test-fseek \
+	 temptest tst-fileno test-fwrite tst-ungetc tst-ferror \
+	 xbug errnobug \
+	 bug1 bug2 bug3 bug4 bug5 bug6 bug7 bug8 bug9 bug10 bug11 bug12 bug13 \
+	 tfformat tiformat tllformat tstdiomisc tst-printfsz tst-wc-printf \
+	 scanf1 scanf2 scanf3 scanf4 scanf5 scanf7 scanf8 scanf9 scanf10 \
+	 scanf11 scanf12 tst-tmpnam tst-cookie tst-obprintf tst-sscanf \
+	 tst-swprintf tst-fseek tst-fmemopen test-vfprintf tst-gets \
+	 tst-perror tst-sprintf tst-rndseek tst-fdopen tst-fphex bug14 bug15 \
+	 tst-popen tst-unlockedio tst-fmemopen2
+
+test-srcs = tst-unbputc tst-printf
+
+include ../Rules
+
+$(inst_includedir)/bits/stdio_lim.h: $(common-objpfx)bits/stdio_lim.h $(+force)
+	$(do-install)
+
+ifeq ($(cross-compiling),no)
+.PHONY: do-tst-unbputc do-tst-printf
+tests: do-tst-unbputc do-tst-printf
+
+do-tst-unbputc: $(objpfx)tst-unbputc.out
+$(objpfx)tst-unbputc.out: $(objpfx)tst-unbputc tst-unbputc.sh
+	$(SHELL) -e tst-unbputc.sh $(common-objpfx) '$(run-program-prefix)'
+
+do-tst-printf: $(objpfx)tst-printf.out
+$(objpfx)tst-printf.out: $(objpfx)tst-printf tst-printf.sh
+	$(SHELL) -e tst-printf.sh $(common-objpfx) '$(run-program-prefix)'
+endif
+
+CFLAGS-vfprintf.c = -Wno-uninitialized
+CFLAGS-tst-printf.c = -Wno-format
+CFLAGS-tstdiomisc.c = -Wno-format
+CFLAGS-scanf4.c = -Wno-format
+CFLAGS-scanf7.c = -Wno-format
+CFLAGS-tst-printfsz.c = -Wno-format
+
+CFLAGS-tmpfile.c = -fexceptions
+CFLAGS-tmpfile64.c = -fexceptions
+CFLAGS-tempname.c = -fexceptions
+CFLAGS-psignal.c = -fexceptions
+CFLAGS-vprintf.c = -fexceptions
+CFLAGS-cuserid.c = -fexceptions
+CFLAGS-errlist.c = $(fno-unit-at-a-time)
+CFLAGS-siglist.c = $(fno-unit-at-a-time)
+
+tst-sscanf-ENV = LOCPATH=$(common-objpfx)localedata
+tst-swprintf-ENV = LOCPATH=$(common-objpfx)localedata
+test-vfprintf-ENV = LOCPATH=$(common-objpfx)localedata
+bug14-ENV = LOCPATH=$(common-objpfx)localedata
+bug15-ENV = LOCPATH=$(common-objpfx)localedata
+
+ifneq (,$(filter %REENTRANT, $(defines)))
+CPPFLAGS += -D_IO_MTSAFE_IO
+endif
Index: trunk/src/libctests/glibc/stdio-common/temptest.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/temptest.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/temptest.c	(revision 2036)
@@ -0,0 +1,28 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+char *files[500];
+
+int
+main (int argc, char *argv[])
+{
+  FILE *fp;
+  int i;
+
+  for (i = 0; i < 500; i++) {
+    files[i] = tempnam (NULL, "file");
+    if (files[i] == NULL) {
+      printf ("tempnam failed\n");
+      exit (1);
+    }
+    printf ("file: %s\n", files[i]);
+    fp = fopen (files[i], "w");
+    fclose (fp);
+  }
+
+  for (i = 0; i < 500; i++)
+    remove (files[i]);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/stdio-common/test-fseek.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/test-fseek.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/test-fseek.c	(revision 2036)
@@ -0,0 +1,85 @@
+/* Copyright (C) 1991, 1992, 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+
+#define TESTFILE "/tmp/test.dat"
+
+int
+main (void)
+{
+  FILE *fp;
+  int i, j;
+
+  puts ("\nFile seek test");
+  fp = fopen (TESTFILE, "w");
+  if (fp == NULL)
+    {
+      perror (TESTFILE);
+      return 1;
+    }
+
+  for (i = 0; i < 256; i++)
+    putc (i, fp);
+  if (freopen (TESTFILE, "r", fp) != fp)
+    {
+      perror ("Cannot open file for reading");
+      return 1;
+    }
+
+  for (i = 1; i <= 255; i++)
+    {
+      printf ("%3d\n", i);
+      fseek (fp, (long) -i, SEEK_END);
+      if ((j = getc (fp)) != 256 - i)
+	{
+	  printf ("SEEK_END failed %d\n", j);
+	  break;
+	}
+      if (fseek (fp, (long) i, SEEK_SET))
+	{
+	  puts ("Cannot SEEK_SET");
+	  break;
+	}
+      if ((j = getc (fp)) != i)
+	{
+	  printf ("SEEK_SET failed %d\n", j);
+	  break;
+	}
+      if (fseek (fp, (long) i, SEEK_SET))
+	{
+	  puts ("Cannot SEEK_SET");
+	  break;
+	}
+      if (fseek (fp, (long) (i >= 128 ? -128 : 128), SEEK_CUR))
+	{
+	  puts ("Cannot SEEK_CUR");
+	  break;
+	}
+      if ((j = getc (fp)) != (i >= 128 ? i - 128 : i + 128))
+	{
+	  printf ("SEEK_CUR failed %d\n", j);
+	  break;
+	}
+    }
+  fclose (fp);
+  remove (TESTFILE);
+
+  puts ((i > 255) ? "Test succeeded." : "Test FAILED!");
+  return (i > 255) ? 0 : 1;
+}
Index: trunk/src/libctests/glibc/stdio-common/test-fwrite.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/test-fwrite.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/test-fwrite.c	(revision 2036)
@@ -0,0 +1,68 @@
+#include <stdio.h>
+#include <string.h>
+
+int
+main (int argc, char *argv[])
+{
+  FILE *f = tmpfile ();
+  char obuf[99999], ibuf[sizeof obuf];
+  char *line;
+  size_t linesz;
+
+  if (! f)
+    {
+      perror ("tmpfile");
+      return 1;
+    }
+
+  if (fputs ("line\n", f) == EOF)
+    {
+      perror ("fputs");
+      return 1;
+    }
+
+  memset (obuf, 'z', sizeof obuf);
+  memset (ibuf, 'y', sizeof ibuf);
+
+  if (fwrite (obuf, sizeof obuf, 1, f) != 1)
+    {
+      perror ("fwrite");
+      return 1;
+    }
+
+  rewind (f);
+
+  line = NULL;
+  linesz = 0;
+  if (getline (&line, &linesz, f) != 5)
+    {
+      perror ("getline");
+      return 1;
+    }
+  if (strcmp (line, "line\n"))
+    {
+      puts ("Lines differ.  Test FAILED!");
+      return 1;
+    }
+
+  if (fread (ibuf, sizeof ibuf, 1, f) != 1)
+    {
+      perror ("fread");
+      return 1;
+    }
+
+  if (memcmp (ibuf, obuf, sizeof ibuf))
+    {
+      puts ("Buffers differ.  Test FAILED!");
+      return 1;
+    }
+
+  asprintf (&line, "\
+GDB is free software and you are welcome to distribute copies of it\n\
+ under certain conditions; type \"show copying\" to see the conditions.\n\
+There is absolutely no warranty for GDB; type \"show warranty\" for details.\n\
+");
+
+  puts ("Test succeeded.");
+  return 0;
+}
Index: trunk/src/libctests/glibc/stdio-common/test-popen.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/test-popen.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/test-popen.c	(revision 2036)
@@ -0,0 +1,103 @@
+/* Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static void
+write_data (FILE *stream)
+{
+  int i;
+  for (i=0; i<100; i++)
+    fprintf (stream, "%d\n", i);
+  if (ferror (stream))
+    {
+      fprintf (stderr, "Output to stream failed.\n");
+      exit (1);
+    }
+}
+
+static void
+read_data (FILE *stream)
+{
+  int i, j;
+
+  for (i=0; i<100; i++)
+    {
+      if (fscanf (stream, "%d\n", &j) != 1 || j != i)
+	{
+	  if (ferror (stream))
+	    perror ("fscanf");
+	  puts ("Test FAILED!");
+	  exit (1);
+	}
+    }
+}
+
+int
+main (void)
+{
+  FILE *output, *input;
+  int wstatus, rstatus;
+
+  /* We must remove this entry to assure the `cat' binary does not use
+     the perhaps incompatible new shared libraries.  */
+  unsetenv ("LD_LIBRARY_PATH");
+
+  output = popen ("/bin/cat >/tmp/tstpopen.tmp", "w");
+  if (output == NULL)
+    {
+      perror ("popen");
+      puts ("Test FAILED!");
+      exit (1);
+    }
+  write_data (output);
+  wstatus = pclose (output);
+  printf ("writing pclose returned %d\n", wstatus);
+  input = popen ("/bin/cat /tmp/tstpopen.tmp", "r");
+  if (input == NULL)
+    {
+      perror ("/tmp/tstpopen.tmp");
+      puts ("Test FAILED!");
+      exit (1);
+    }
+  read_data (input);
+  rstatus = pclose (input);
+  printf ("reading pclose returned %d\n", rstatus);
+
+  remove ("/tmp/tstpopen.tmp");
+
+  errno = 0;
+  output = popen ("/bin/cat", "m");
+  if (output != NULL)
+    {
+      puts ("popen called with illegal mode does not return NULL");
+      puts ("Test FAILED!");
+      exit (1);
+    }
+  if (errno != EINVAL)
+    {
+      puts ("popen called with illegal mode does not set errno to EINVAL");
+      puts ("Test FAILED!");
+      exit (1);
+    }
+
+  puts (wstatus | rstatus  ? "Test FAILED!" : "Test succeeded.");
+  return (wstatus | rstatus);
+}
Index: trunk/src/libctests/glibc/stdio-common/test-vfprintf.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/test-vfprintf.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/test-vfprintf.c	(revision 2036)
@@ -0,0 +1,125 @@
+/* Tests of *printf for very large strings.
+   Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <locale.h>
+#include <mcheck.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+
+const char *locs[] =
+{
+  "C", "de_DE.ISO-8859-1", "de_DE.UTF-8", "ja_JP.EUC-JP"
+};
+#define nlocs (sizeof (locs) / sizeof (locs[0]))
+
+
+char large[50000];
+
+int
+main (void)
+{
+  char buf[25];
+  size_t i;
+  int res = 0;
+  int fd;
+
+  mtrace ();
+
+  strcpy (buf, "/tmp/test-vfprintfXXXXXX");
+  fd = mkstemp (buf);
+  if (fd == -1)
+    {
+      printf ("cannot open temporary file: %m\n");
+      exit (1);
+    }
+  unlink (buf);
+
+  for (i = 0; i < nlocs; ++i)
+    {
+      FILE *fp;
+      struct stat st;
+      int fd2;
+
+      setlocale (LC_ALL, locs[i]);
+
+      memset (large, '\1', sizeof (large));
+      large[sizeof (large) - 1] = '\0';
+
+      fd2 = dup (fd);
+      if (fd2 == -1)
+	{
+	  printf ("cannot dup for locale %s: %m\n",
+		  setlocale (LC_ALL, NULL));
+	  exit (1);
+	}
+
+      if (ftruncate (fd2, 0) != 0)
+	{
+	  printf ("cannot truncate file for locale %s: %m\n",
+		  setlocale (LC_ALL, NULL));
+	  exit (1);
+	}
+
+      fp = fdopen (fd2, "a");
+      if (fp == NULL)
+	{
+	  printf ("cannot create FILE for locale %s: %m\n",
+		  setlocale (LC_ALL, NULL));
+	  exit (1);
+	}
+
+      fprintf (fp, "%s", large);
+      fprintf (fp, "%.*s", 30000, large);
+      large[20000] = '\0';
+      fprintf (fp, large);
+
+      if (fflush (fp) != 0 || ferror (fp) != 0 || fclose (fp) != 0)
+	{
+	  printf ("write error for locale %s: %m\n",
+		  setlocale (LC_ALL, NULL));
+	  exit (1);
+	}
+
+      if (fstat (fd, &st) != 0)
+	{
+	  printf ("cannot stat for locale %s: %m\n",
+		  setlocale (LC_ALL, NULL));
+	  exit (1);
+	}
+      else if (st.st_size != 99999)
+	{
+	  printf ("file size incorrect for locale %s: %jd instead of %jd\n",
+		  setlocale (LC_ALL, NULL),
+		  (intmax_t) st.st_size, (intmax_t) 99999);
+	  res = 1;
+	}
+      else
+	printf ("locale %s OK\n", setlocale (LC_ALL, NULL));
+    }
+
+  close (fd);
+
+  return res;
+}
Index: trunk/src/libctests/glibc/stdio-common/test_rdwr.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/test_rdwr.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/test_rdwr.c	(revision 2036)
@@ -0,0 +1,129 @@
+/* Copyright (C) 1991,1992,1996,1997,1998,2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+int
+main (int argc, char **argv)
+{
+  static const char hello[] = "Hello, world.\n";
+  static const char replace[] = "Hewwo, world.\n";
+  static const size_t replace_from = 2, replace_to = 4;
+  char filename[FILENAME_MAX];
+  char *name = strrchr (*argv, '/');
+  char buf[BUFSIZ];
+  FILE *f;
+  int lose = 0;
+
+  if (name != NULL)
+    ++name;
+  else
+    name = *argv;
+
+  (void) sprintf (filename, "/tmp/%s.test", name);
+
+  f = fopen (filename, "w+");
+  if (f == NULL)
+    {
+      perror (filename);
+      exit (1);
+    }
+
+  (void) fputs (hello, f);
+  rewind (f);
+  (void) fgets (buf, sizeof (buf), f);
+  rewind (f);
+  (void) fputs (buf, f);
+  rewind (f);
+  {
+    size_t i;
+    for (i = 0; i < replace_from; ++i)
+      {
+	int c = getc (f);
+	if (c == EOF)
+	  {
+	    printf ("EOF at %Zu.\n", i);
+	    lose = 1;
+	    break;
+	  }
+	else if (c != hello[i])
+	  {
+	    printf ("Got '%c' instead of '%c' at %Zu.\n",
+		    (unsigned char) c, hello[i], i);
+	    lose = 1;
+	    break;
+	  }
+      }
+  }
+
+  {
+    long int where = ftell (f);
+    if (where == (long int) replace_from)
+      {
+	register size_t i;
+	for (i = replace_from; i < replace_to; ++i)
+	  if (putc(replace[i], f) == EOF)
+	    {
+	      printf ("putc('%c') got %s at %Zu.\n",
+		      replace[i], strerror (errno), i);
+	      lose = 1;
+	      break;
+	    }
+      }
+    else if (where == -1L)
+      {
+	printf ("ftell got %s (should be at %Zu).\n",
+		strerror (errno), replace_from);
+	lose = 1;
+      }
+    else
+      {
+	printf ("ftell returns %lu; should be %Zu.\n", where, replace_from);
+	lose = 1;
+      }
+  }
+
+  if (!lose)
+    {
+      rewind (f);
+      if (fgets (buf, sizeof (buf), f) == NULL)
+	{
+	  printf ("fgets got %s.\n", strerror(errno));
+	  lose = 1;
+	}
+      else if (strcmp (buf, replace))
+	{
+	  printf ("Read \"%s\" instead of \"%s\".\n", buf, replace);
+	  lose = 1;
+	}
+    }
+
+  if (lose)
+    printf ("Test FAILED!  Losing file is \"%s\".\n", filename);
+  else
+    {
+      (void) remove (filename);
+      puts ("Test succeeded.");
+    }
+
+  return lose ? EXIT_FAILURE : EXIT_SUCCESS;
+}
Index: trunk/src/libctests/glibc/stdio-common/tst-cookie.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-cookie.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-cookie.c	(revision 2036)
@@ -0,0 +1,92 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include <stdio.h>
+
+
+#define THE_COOKIE ((void *) 0xdeadbeeful)
+
+static int errors;
+
+
+static int cookieread_called;
+static ssize_t
+cookieread (void *cookie, char *buf, size_t count)
+{
+  printf ("`%s' called with cookie %#lx\n", __FUNCTION__,
+	  (unsigned long int) cookie);
+  if (cookie != THE_COOKIE)
+    ++errors;
+  cookieread_called = 1;
+  return 42;
+}
+
+
+static int cookiewrite_called;
+static ssize_t
+cookiewrite (void *cookie, const char *buf, size_t count)
+{
+  printf ("`%s' called with cookie %#lx\n", __FUNCTION__,
+	  (unsigned long int) cookie);
+  if (cookie != THE_COOKIE)
+    ++errors;
+  cookiewrite_called = 1;
+  return 43;
+}
+
+
+static int cookieseek_called;
+static int
+cookieseek (void *cookie, off64_t *offset, int whence)
+{
+  printf ("`%s' called with cookie %#lx\n", __FUNCTION__,
+	  (unsigned long int) cookie);
+  if (cookie != THE_COOKIE)
+    ++errors;
+  cookieseek_called = 1;
+  return 44;
+}
+
+
+static int cookieclose_called;
+static int
+cookieclose (void *cookie)
+{
+  printf ("`%s' called with cookie %#lx\n", __FUNCTION__,
+	  (unsigned long int) cookie);
+  if (cookie != THE_COOKIE)
+    ++errors;
+  cookieclose_called = 1;
+  return 45;
+}
+
+
+int
+main (void)
+{
+  cookie_io_functions_t fcts;
+  char buf[1];
+  FILE *f;
+
+  fcts.read = cookieread;
+  fcts.seek = cookieseek;
+  fcts.close = cookieclose;
+  fcts.write = cookiewrite;
+
+  f = fopencookie (THE_COOKIE, "r+", fcts);
+
+  fread (buf, 1, 1, f);
+  fwrite (buf, 1, 1, f);
+  fseek (f, 0, SEEK_CUR);
+  fclose (f);
+
+  if (cookieread_called == 0
+      || cookiewrite_called == 0
+      || cookieseek_called == 0
+      || cookieclose_called == 0)
+    ++errors;
+
+  return errors != 0;
+}
Index: trunk/src/libctests/glibc/stdio-common/tst-fdopen.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-fdopen.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-fdopen.c	(revision 2036)
@@ -0,0 +1,50 @@
+/* Test for fdopen bugs.  */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#undef assert
+#define assert(x) \
+  if (!(x)) \
+    { \
+      fputs ("test failed: " #x "\n", stderr); \
+      retval = 1; \
+      goto the_end; \
+    }
+
+char buffer[256];
+
+int
+main (int argc, char *argv[])
+{
+  char *name;
+  FILE *fp = NULL;
+  int retval = 0;
+  int fd;
+
+  name = tmpnam (NULL);
+  fp = fopen (name, "w");
+  assert (fp != NULL)
+  fputs ("foobar and baz", fp);
+  fclose (fp);
+  fp = NULL;
+
+  fd = open (name, O_RDONLY);
+  assert (fd != -1);
+  assert (lseek (fd, 5, SEEK_SET) == 5);
+  /* The file position indicator associated with the new stream is set to
+     the position indicated by the file offset associated with the file
+     descriptor.  */
+  fp = fdopen (fd, "r");
+  assert (fp != NULL);
+  assert (getc (fp) == 'r');
+  assert (getc (fp) == ' ');
+
+the_end:
+  if (fp != NULL)
+    fclose (fp);
+  unlink (name);
+
+  return retval;
+}
Index: trunk/src/libctests/glibc/stdio-common/tst-ferror.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-ferror.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-ferror.c	(revision 2036)
@@ -0,0 +1,41 @@
+#include <stdio.h>
+
+int
+main (int argc, char *argv[])
+{
+  char buf[100];
+  int result = 0;
+
+  if (ferror (stdin) != 0)
+    {
+      fputs ("error bit set for stdin at startup\n", stdout);
+      result = 1;
+    }
+  if (fgets (buf, sizeof buf, stdin) != buf)
+    {
+      fputs ("fgets with existing input has problem\n", stdout);
+      result = 1;
+    }
+  if (ferror (stdin) != 0)
+    {
+      fputs ("error bit set for stdin after setup\n", stdout);
+      result = 1;
+    }
+  if (fputc ('a', stdin) != EOF)
+    {
+      fputs ("fputc to stdin does not terminate with an error\n", stdout);
+      result = 1;
+    }
+  if (ferror (stdin) == 0)
+    {
+      fputs ("error bit not set for stdin after fputc\n", stdout);
+      result = 1;
+    }
+  clearerr (stdin);
+  if (ferror (stdin) != 0)
+    {
+      fputs ("error bit set for stdin after clearerr\n", stdout);
+      result = 1;
+    }
+  return result;
+}
Index: trunk/src/libctests/glibc/stdio-common/tst-ferror.input
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-ferror.input	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-ferror.input	(revision 2036)
@@ -0,0 +1,1 @@
+This is a test.
Index: trunk/src/libctests/glibc/stdio-common/tst-fileno.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-fileno.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-fileno.c	(revision 2036)
@@ -0,0 +1,38 @@
+/* Copyright (C) 1994, 1997, 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+static int
+check (const char *name, FILE *stream, int fd)
+{
+  int sfd = fileno (stream);
+  printf ("(fileno (%s) = %d) %c= %d\n", name, sfd,
+	  sfd == fd ? '=' : '!', fd);
+  return sfd != fd;
+}
+
+int
+main (void)
+{
+  return (check ("stdin", stdin, STDIN_FILENO) ||
+	  check ("stdout", stdout, STDOUT_FILENO) ||
+	  check ("stderr", stderr, STDERR_FILENO));
+}
Index: trunk/src/libctests/glibc/stdio-common/tst-fmemopen.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-fmemopen.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-fmemopen.c	(revision 2036)
@@ -0,0 +1,111 @@
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#define TEST_FILE "test-1"
+
+int
+main (void)
+{
+  const char blah[] = "BLAH";
+  FILE *fp;
+  char *mmap_data;
+  int ch, fd;
+  struct stat fs;
+  const char *cp;
+
+  /* setup the physical file, and use it */
+  if ((fp = fopen (TEST_FILE, "w+")) == NULL)
+    exit (1);
+  if (fwrite (blah, 1, strlen (blah), fp) != strlen (blah))
+    exit (2);
+
+  rewind (fp);
+  printf ("file: ");
+  cp = blah;
+  while ((ch = getc (fp)) != EOF)
+    {
+      fputc (ch, stdout);
+      if (ch != *cp)
+	{
+	  printf ("\ncharacter %td: '%c' instead of '%c'\n",
+		  cp - blah, ch, *cp);
+	  exit (1);
+	}
+      ++cp;
+    }
+  fputc ('\n', stdout);
+  if (ferror (fp))
+    {
+      puts ("fp: error");
+      exit (1);
+    }
+  if (feof (fp))
+    printf ("fp: EOF\n");
+  else
+    {
+      puts ("not EOF");
+      exit (1);
+    }
+  fclose (fp);
+
+  /* Now, mmap the file into a buffer, and do that too */
+  if ((fd = open (TEST_FILE, O_RDONLY)) == -1)
+    exit (3);
+  if (fstat (fd, &fs) == -1)
+    exit (4);
+
+  if ((mmap_data = (char *) mmap (NULL, fs.st_size, PROT_READ,
+				  MAP_SHARED, fd, 0)) == MAP_FAILED)
+    {
+      if (errno == ENOSYS)
+	exit (0);
+      exit (5);
+    }
+
+  if ((fp = fmemopen (mmap_data, fs.st_size, "r")) == NULL)
+    exit (1);
+
+  printf ("mem: ");
+  cp = blah;
+  while ((ch = getc (fp)) != EOF)
+    {
+      fputc (ch, stdout);
+      if (ch != *cp)
+	{
+	  printf ("%td character: '%c' instead of '%c'\n",
+		  cp - blah, ch, *cp);
+	  exit (1);
+	}
+      ++cp;
+    }
+
+  fputc ('\n', stdout);
+
+  if (ferror (fp))
+    {
+      puts ("fp: error");
+      exit (1);
+    }
+  if (feof (fp))
+    printf ("fp: EOF\n");
+  else
+    {
+      puts ("not EOF");
+      exit (1);
+    }
+
+  fclose (fp);
+
+  munmap (mmap_data, fs.st_size);
+
+  unlink (TEST_FILE);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/stdio-common/tst-fmemopen2.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-fmemopen2.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-fmemopen2.c	(revision 2036)
@@ -0,0 +1,68 @@
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+
+
+static int
+do_test (void)
+{
+  int result = 0;
+  char buf[100];
+  FILE *fp = fmemopen (buf, sizeof (buf), "w");
+  if (fp == NULL)
+    {
+      puts ("fmemopen failed");
+      return 0;
+    }
+  static const char str[] = "hello world";
+#define nstr (sizeof (str) - 1)
+  fputs (str, fp);
+  off_t o = ftello (fp);
+  if (o != nstr)
+    {
+      printf ("first ftello returned %ld, expected %zu\n", o, nstr);
+      result = 1;
+    }
+  rewind (fp);
+  o = ftello (fp);
+  if (o != 0)
+    {
+      printf ("second ftello returned %ld, expected %zu\n", o, 0);
+      result = 1;
+    }
+  if (fseeko (fp, 0, SEEK_END) != 0)
+    {
+      puts ("fseeko failed");
+      return 1;
+    }
+  o = ftello (fp);
+  if (o != nstr)
+    {
+      printf ("third ftello returned %ld, expected %zu\n", o, nstr);
+      result = 1;
+    }
+  rewind (fp);
+  static const char str2[] = "just hello";
+#define nstr2 (sizeof (str2) - 1)
+  assert (nstr2 < nstr);
+  fputs (str2, fp);
+  o = ftello (fp);
+  if (o != nstr2)
+    {
+      printf ("fourth ftello returned %ld, expected %zu\n", o, nstr2);
+      result = 1;
+    }
+  fclose (fp);
+  static const char str3[] = "just hellod";
+  if (strcmp (buf, str3) != 0)
+    {
+      printf ("final string is \"%s\", expected \"%s\"\n",
+              buf, str3);
+      result = 1;
+    }
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/stdio-common/tst-fphex.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-fphex.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-fphex.c	(revision 2036)
@@ -0,0 +1,51 @@
+/* Test program for %a printf formats.  */
+
+#include <stdio.h>
+#include <string.h>
+
+struct testcase
+{
+  double value;
+  const char *fmt;
+  const char *expect;
+};
+
+static const struct testcase testcases[] =
+  {
+    { 0x0.0030p+0, "%a",	"0x1.8p-11" },
+    { 0x0.0040p+0, "%a",	"0x1p-10" },
+    { 0x0.0030p+0, "%040a",	"0x00000000000000000000000000000001.8p-11" },
+    { 0x0.0040p+0, "%040a",	"0x0000000000000000000000000000000001p-10" },
+    { 0x0.0040p+0, "%40a",	"                                 0x1p-10" },
+    { 0x0.0040p+0, "%#40a",	"                                0x1.p-10" },
+    { 0x0.0040p+0, "%-40a",	"0x1p-10                                 " },
+    { 0x0.0040p+0, "%#-40a",	"0x1.p-10                                " },
+    { 0x0.0030p+0, "%040e",	"00000000000000000000000000007.324219e-04" },
+    { 0x0.0040p+0, "%040e",	"00000000000000000000000000009.765625e-04" },
+  };
+
+
+static int
+do_test (int argc, char **argv)
+{
+  const struct testcase *t;
+  int result = 0;
+
+  for (t = testcases;
+       t < &testcases[sizeof testcases / sizeof testcases[0]];
+       ++t)
+    {
+      char buf[1024];
+      int n = snprintf (buf, sizeof buf, t->fmt, t->value);
+      if (n != strlen (t->expect) || strcmp (buf, t->expect) != 0)
+	{
+	  printf ("%s\tExpected \"%s\" (%Zu)\n\tGot      \"%s\" (%d, %Zu)\n",
+		  t->fmt, t->expect, strlen (t->expect), buf, n, strlen (buf));
+	  result = 1;
+	}
+    }
+
+  return result;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/stdio-common/tst-fseek.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-fseek.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-fseek.c	(revision 2036)
@@ -0,0 +1,479 @@
+/* Tests of fseek and fseeko.
+   Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <error.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <time.h>
+#include <sys/stat.h>
+
+
+int
+main (void)
+{
+  const char *tmpdir;
+  char *fname;
+  int fd;
+  FILE *fp;
+  const char outstr[] = "hello world!\n";
+  char strbuf[sizeof outstr];
+  char buf[200];
+  struct stat64 st1;
+  struct stat64 st2;
+  int result = 0;
+
+  tmpdir = getenv ("TMPDIR");
+  if (tmpdir == NULL || tmpdir[0] == '\0')
+    tmpdir = "/tmp";
+
+  asprintf (&fname, "%s/tst-fseek.XXXXXX", tmpdir);
+  if (fname == NULL)
+    error (EXIT_FAILURE, errno, "cannot generate name for temporary file");
+
+  /* Create a temporary file.   */
+  fd = mkstemp (fname);
+  if (fd == -1)
+    error (EXIT_FAILURE, errno, "cannot open temporary file");
+
+  fp = fdopen (fd, "w+");
+  if (fp == NULL)
+    error (EXIT_FAILURE, errno, "cannot get FILE for temporary file");
+
+  setbuffer (fp, strbuf, sizeof (outstr) -1);
+
+  if (fwrite (outstr, sizeof (outstr) - 1, 1, fp) != 1)
+    {
+      printf ("%d: write error\n", __LINE__);
+      result = 1;
+      goto out;
+    }
+
+  /* The EOF flag must be reset.  */
+  if (fgetc (fp) != EOF)
+    {
+      printf ("%d: managed to read at end of file\n", __LINE__);
+      result = 1;
+    }
+  else if (! feof (fp))
+    {
+      printf ("%d: EOF flag not set\n", __LINE__);
+      result = 1;
+    }
+  if (fseek (fp, 0, SEEK_CUR) != 0)
+    {
+      printf ("%d: fseek(fp, 0, SEEK_CUR) failed\n", __LINE__);
+      result = 1;
+    }
+  else if (feof (fp))
+    {
+      printf ("%d: fseek() didn't reset EOF flag\n", __LINE__);
+      result = 1;
+    }
+
+  /* Do the same for fseeko().  */
+    if (fgetc (fp) != EOF)
+    {
+      printf ("%d: managed to read at end of file\n", __LINE__);
+      result = 1;
+    }
+  else if (! feof (fp))
+    {
+      printf ("%d: EOF flag not set\n", __LINE__);
+      result = 1;
+    }
+  if (fseeko (fp, 0, SEEK_CUR) != 0)
+    {
+      printf ("%d: fseek(fp, 0, SEEK_CUR) failed\n", __LINE__);
+      result = 1;
+    }
+  else if (feof (fp))
+    {
+      printf ("%d: fseek() didn't reset EOF flag\n", __LINE__);
+      result = 1;
+    }
+
+  /* Go back to the beginning of the file: absolute.  */
+  if (fseek (fp, 0, SEEK_SET) != 0)
+    {
+      printf ("%d: fseek(fp, 0, SEEK_SET) failed\n", __LINE__);
+      result = 1;
+    }
+  else if (fflush (fp) != 0)
+    {
+      printf ("%d: fflush() failed\n", __LINE__);
+      result = 1;
+    }
+  else if (lseek (fd, 0, SEEK_CUR) != 0)
+    {
+      printf ("%d: lseek() returned different position\n", __LINE__);
+      result = 1;
+    }
+  else if (fread (buf, sizeof (outstr) - 1, 1, fp) != 1)
+    {
+      printf ("%d: fread() failed\n", __LINE__);
+      result = 1;
+    }
+  else if (memcmp (buf, outstr, sizeof (outstr) - 1) != 0)
+    {
+      printf ("%d: content after fseek(,,SEEK_SET) wrong\n", __LINE__);
+      result = 1;
+    }
+
+  /* Now with fseeko.  */
+  if (fseeko (fp, 0, SEEK_SET) != 0)
+    {
+      printf ("%d: fseeko(fp, 0, SEEK_SET) failed\n", __LINE__);
+      result = 1;
+    }
+  else if (fflush (fp) != 0)
+    {
+      printf ("%d: fflush() failed\n", __LINE__);
+      result = 1;
+    }
+  else if (lseek (fd, 0, SEEK_CUR) != 0)
+    {
+      printf ("%d: lseek() returned different position\n", __LINE__);
+      result = 1;
+    }
+  else if (fread (buf, sizeof (outstr) - 1, 1, fp) != 1)
+    {
+      printf ("%d: fread() failed\n", __LINE__);
+      result = 1;
+    }
+  else if (memcmp (buf, outstr, sizeof (outstr) - 1) != 0)
+    {
+      printf ("%d: content after fseeko(,,SEEK_SET) wrong\n", __LINE__);
+      result = 1;
+    }
+
+  /* Go back to the beginning of the file: relative.  */
+  if (fseek (fp, -((int) sizeof (outstr) - 1), SEEK_CUR) != 0)
+    {
+      printf ("%d: fseek(fp, 0, SEEK_SET) failed\n", __LINE__);
+      result = 1;
+    }
+  else if (fflush (fp) != 0)
+    {
+      printf ("%d: fflush() failed\n", __LINE__);
+      result = 1;
+    }
+  else if (lseek (fd, 0, SEEK_CUR) != 0)
+    {
+      printf ("%d: lseek() returned different position\n", __LINE__);
+      result = 1;
+    }
+  else if (fread (buf, sizeof (outstr) - 1, 1, fp) != 1)
+    {
+      printf ("%d: fread() failed\n", __LINE__);
+      result = 1;
+    }
+  else if (memcmp (buf, outstr, sizeof (outstr) - 1) != 0)
+    {
+      printf ("%d: content after fseek(,,SEEK_SET) wrong\n", __LINE__);
+      result = 1;
+    }
+
+  /* Now with fseeko.  */
+  if (fseeko (fp, -((int) sizeof (outstr) - 1), SEEK_CUR) != 0)
+    {
+      printf ("%d: fseeko(fp, 0, SEEK_SET) failed\n", __LINE__);
+      result = 1;
+    }
+  else if (fflush (fp) != 0)
+    {
+      printf ("%d: fflush() failed\n", __LINE__);
+      result = 1;
+    }
+  else if (lseek (fd, 0, SEEK_CUR) != 0)
+    {
+      printf ("%d: lseek() returned different position\n", __LINE__);
+      result = 1;
+    }
+  else if (fread (buf, sizeof (outstr) - 1, 1, fp) != 1)
+    {
+      printf ("%d: fread() failed\n", __LINE__);
+      result = 1;
+    }
+  else if (memcmp (buf, outstr, sizeof (outstr) - 1) != 0)
+    {
+      printf ("%d: content after fseeko(,,SEEK_SET) wrong\n", __LINE__);
+      result = 1;
+    }
+
+  /* Go back to the beginning of the file: from the end.  */
+  if (fseek (fp, -((int) sizeof (outstr) - 1), SEEK_END) != 0)
+    {
+      printf ("%d: fseek(fp, 0, SEEK_SET) failed\n", __LINE__);
+      result = 1;
+    }
+  else if (fflush (fp) != 0)
+    {
+      printf ("%d: fflush() failed\n", __LINE__);
+      result = 1;
+    }
+  else if (lseek (fd, 0, SEEK_CUR) != 0)
+    {
+      printf ("%d: lseek() returned different position\n", __LINE__);
+      result = 1;
+    }
+  else if (fread (buf, sizeof (outstr) - 1, 1, fp) != 1)
+    {
+      printf ("%d: fread() failed\n", __LINE__);
+      result = 1;
+    }
+  else if (memcmp (buf, outstr, sizeof (outstr) - 1) != 0)
+    {
+      printf ("%d: content after fseek(,,SEEK_SET) wrong\n", __LINE__);
+      result = 1;
+    }
+
+  /* Now with fseeko.  */
+  if (fseeko (fp, -((int) sizeof (outstr) - 1), SEEK_END) != 0)
+    {
+      printf ("%d: fseeko(fp, 0, SEEK_SET) failed\n", __LINE__);
+      result = 1;
+    }
+  else if (fflush (fp) != 0)
+    {
+      printf ("%d: fflush() failed\n", __LINE__);
+      result = 1;
+    }
+  else if (lseek (fd, 0, SEEK_CUR) != 0)
+    {
+      printf ("%d: lseek() returned different position\n", __LINE__);
+      result = 1;
+    }
+  else if (fread (buf, sizeof (outstr) - 1, 1, fp) != 1)
+    {
+      printf ("%d: fread() failed\n", __LINE__);
+      result = 1;
+    }
+  else if (memcmp (buf, outstr, sizeof (outstr) - 1) != 0)
+    {
+      printf ("%d: content after fseeko(,,SEEK_SET) wrong\n", __LINE__);
+      result = 1;
+    }
+
+  if (fwrite (outstr, sizeof (outstr) - 1, 1, fp) != 1)
+    {
+      printf ("%d: write error 2\n", __LINE__);
+      result = 1;
+      goto out;
+    }
+
+  if (fwrite (outstr, sizeof (outstr) - 1, 1, fp) != 1)
+    {
+      printf ("%d: write error 3\n", __LINE__);
+      result = 1;
+      goto out;
+    }
+
+  if (fwrite (outstr, sizeof (outstr) - 1, 1, fp) != 1)
+    {
+      printf ("%d: write error 4\n", __LINE__);
+      result = 1;
+      goto out;
+    }
+
+  if (fwrite (outstr, sizeof (outstr) - 1, 1, fp) != 1)
+    {
+      printf ("%d: write error 5\n", __LINE__);
+      result = 1;
+      goto out;
+    }
+
+  if (fputc ('1', fp) == EOF || fputc ('2', fp) == EOF)
+    {
+      printf ("%d: cannot add characters at the end\n", __LINE__);
+      result = 1;
+      goto out;
+    }
+
+  /* Check the access time.  */
+  if (fstat64 (fd, &st1) < 0)
+    {
+      printf ("%d: fstat64() before fseeko() failed\n\n", __LINE__);
+      result = 1;
+    }
+  else
+    {
+      sleep (1);
+
+      if (fseek (fp, -(2 + 2 * (sizeof (outstr) - 1)), SEEK_CUR) != 0)
+	{
+	  printf ("%d: fseek() after write characters failed\n", __LINE__);
+	  result = 1;
+	  goto out;
+	}
+      else
+	{
+
+	  time_t t;
+	  /* Make sure the timestamp actually can be different.  */
+	  sleep (1);
+	  t = time (NULL);
+
+	  if (fstat64 (fd, &st2) < 0)
+	    {
+	      printf ("%d: fstat64() after fseeko() failed\n\n", __LINE__);
+	      result = 1;
+	    }
+	  if (st1.st_ctime >= t)
+	    {
+	      printf ("%d: st_ctime not updated\n", __LINE__);
+	      result = 1;
+	    }
+	  if (st1.st_mtime >= t)
+	    {
+	      printf ("%d: st_mtime not updated\n", __LINE__);
+	      result = 1;
+	    }
+	  if (st1.st_ctime >= st2.st_ctime)
+	    {
+	      printf ("%d: st_ctime not changed\n", __LINE__);
+	      result = 1;
+	    }
+	  if (st1.st_mtime >= st2.st_mtime)
+	    {
+	      printf ("%d: st_mtime not changed\n", __LINE__);
+	      result = 1;
+	    }
+	}
+    }
+
+  if (fread (buf, 1, 2 + 2 * (sizeof (outstr) - 1), fp)
+      != 2 + 2 * (sizeof (outstr) - 1))
+    {
+      printf ("%d: reading 2 records plus bits failed\n", __LINE__);
+      result = 1;
+    }
+  else if (memcmp (buf, outstr, sizeof (outstr) - 1) != 0
+	   || memcmp (&buf[sizeof (outstr) - 1], outstr,
+		      sizeof (outstr) - 1) != 0
+	   || buf[2 * (sizeof (outstr) - 1)] != '1'
+	   || buf[2 * (sizeof (outstr) - 1) + 1] != '2')
+    {
+      printf ("%d: reading records failed\n", __LINE__);
+      result = 1;
+    }
+  else if (ungetc ('9', fp) == EOF)
+    {
+      printf ("%d: ungetc() failed\n", __LINE__);
+      result = 1;
+    }
+  else if (fseek (fp, -(2 + 2 * (sizeof (outstr) - 1)), SEEK_END) != 0)
+    {
+      printf ("%d: fseek after ungetc failed\n", __LINE__);
+      result = 1;
+    }
+  else if (fread (buf, 1, 2 + 2 * (sizeof (outstr) - 1), fp)
+      != 2 + 2 * (sizeof (outstr) - 1))
+    {
+      printf ("%d: reading 2 records plus bits failed\n", __LINE__);
+      result = 1;
+    }
+  else if (memcmp (buf, outstr, sizeof (outstr) - 1) != 0
+	   || memcmp (&buf[sizeof (outstr) - 1], outstr,
+		      sizeof (outstr) - 1) != 0
+	   || buf[2 * (sizeof (outstr) - 1)] != '1')
+    {
+      printf ("%d: reading records for the second time failed\n", __LINE__);
+      result = 1;
+    }
+  else if (buf[2 * (sizeof (outstr) - 1) + 1] == '9')
+    {
+      printf ("%d: unget character not ignored\n", __LINE__);
+      result = 1;
+    }
+  else if (buf[2 * (sizeof (outstr) - 1) + 1] != '2')
+    {
+      printf ("%d: unget somehow changed character\n", __LINE__);
+      result = 1;
+    }
+
+  fclose (fp);
+
+  fp = fopen (fname, "r");
+  if (fp == NULL)
+    {
+      printf ("%d: fopen() failed\n\n", __LINE__);
+      result = 1;
+    }
+  else if (fstat64 (fileno (fp), &st1) < 0)
+    {
+      printf ("%d: fstat64() before fseeko() failed\n\n", __LINE__);
+      result = 1;
+    }
+  else if (fseeko (fp, 0, SEEK_END) != 0)
+    {
+      printf ("%d: fseeko(fp, 0, SEEK_END) failed\n", __LINE__);
+      result = 1;
+    }
+  else if (ftello (fp) != st1.st_size)
+    {
+      printf ("%d: fstat64 st_size %zd ftello %zd\n", __LINE__,
+	      (size_t) st1.st_size, (size_t) ftello (fp));
+      result = 1;
+    }
+  else
+    printf ("%d: SEEK_END works\n", __LINE__);
+  if (fp != NULL)
+    fclose (fp);
+
+  fp = fopen (fname, "r");
+  if (fp == NULL)
+    {
+      printf ("%d: fopen() failed\n\n", __LINE__);
+      result = 1;
+    }
+  else if (fstat64 (fileno (fp), &st1) < 0)
+    {
+      printf ("%d: fstat64() before fgetc() failed\n\n", __LINE__);
+      result = 1;
+    }
+  else if (fgetc (fp) == EOF)
+    {
+      printf ("%d: fgetc() before fseeko() failed\n\n", __LINE__);
+      result = 1;
+    }
+  else if (fseeko (fp, 0, SEEK_END) != 0)
+    {
+      printf ("%d: fseeko(fp, 0, SEEK_END) failed\n", __LINE__);
+      result = 1;
+    }
+  else if (ftello (fp) != st1.st_size)
+    {
+      printf ("%d: fstat64 st_size %zd ftello %zd\n", __LINE__,
+	      (size_t) st1.st_size, (size_t) ftello (fp));
+      result = 1;
+    }
+  else
+    printf ("%d: SEEK_END works\n", __LINE__);
+  if (fp != NULL)
+    fclose (fp);
+
+ out:
+  unlink (fname);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/stdio-common/tst-gets.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-gets.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-gets.c	(revision 2036)
@@ -0,0 +1,63 @@
+/* Tests for gets.
+   Copyright (C) 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <string.h>
+
+int
+main (void)
+{
+  char buf[100];
+  int result = 0;
+
+  if (gets (buf) != buf)
+    {
+      printf ("gets: read error: %m\n");
+      result = 1;
+    }
+  else if (strchr (buf, '\n') != NULL)
+    {
+      printf ("newline not stripped: \"%s\"\n", buf);
+      result = 1;
+    }
+  else if (strcmp (buf, "foo") != 0)
+    {
+      printf ("read mismatch: expected \"%s\", got \"%s\"\n", "foo", buf);
+      result = 1;
+    }
+
+  if (gets (buf) != buf)
+    {
+      printf ("gets: read error: %m\n");
+      result = 1;
+    }
+  else if (strchr (buf, '\n') != NULL)
+    {
+      printf ("newline not stripped: \"%s\"\n", buf);
+      result = 1;
+    }
+  else if (strcmp (buf, "bar") != 0)
+    {
+      printf ("read mismatch: expected \"%s\", got \"%s\"\n", "bar", buf);
+      result = 1;
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/stdio-common/tst-gets.input
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-gets.input	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-gets.input	(revision 2036)
@@ -0,0 +1,2 @@
+foo
+bar
Index: trunk/src/libctests/glibc/stdio-common/tst-obprintf.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-obprintf.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-obprintf.c	(revision 2036)
@@ -0,0 +1,42 @@
+#include <mcheck.h>
+#include <obstack.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+int
+main (void)
+{
+  struct obstack ob;
+  int n;
+
+  mcheck_pedantic (NULL);
+
+#define obstack_chunk_alloc malloc
+#define obstack_chunk_free free
+
+  obstack_init (&ob);
+
+  for (n = 0; n < 40000; ++n)
+    {
+      mcheck_check_all ();
+      obstack_printf (&ob, "%.*s%05d", 1 + n % 7, "foobarbaz", n);
+      if (n % 777 == 0)
+	obstack_finish (&ob);
+    }
+
+  /* Another loop where we finish all objects, each of size 1.  This will
+     manage to call `obstack_print' with all possible positions inside
+     an obstack chunk.  */
+  for (n = 0; n < 40000; ++n)
+    {
+      mcheck_check_all ();
+      obstack_printf (&ob, "%c", 'a' + n % 26);
+      obstack_finish (&ob);
+    }
+
+  /* And a final check.  */
+  mcheck_check_all ();
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/stdio-common/tst-perror.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-perror.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-perror.c	(revision 2036)
@@ -0,0 +1,154 @@
+/* Test of perror.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
+   To be used only for testing glibc.  */
+
+#include <errno.h>
+#include <error.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <wchar.h>
+
+
+#define MB_EXP \
+  "null mode test 1: Invalid or incomplete multibyte or wide character\n" \
+  "multibyte string\n" \
+  "<0 mode test: Invalid argument\n"
+#define MB_EXP_LEN (sizeof (MB_EXP) - 1)
+
+#define WC_EXP \
+  "null mode test 2: Invalid or incomplete multibyte or wide character\n" \
+  "wide string\n" \
+  ">0 mode test: Invalid argument\n"
+#define WC_EXP_LEN (sizeof (WC_EXP) - 1)
+
+
+int
+main (void)
+{
+  int fd;
+  char fname[] = "/tmp/tst-perror.XXXXXX";
+  int result = 0;
+  char buf[200];
+  ssize_t n;
+
+  fd = mkstemp (fname);
+  if (fd == -1)
+    error (EXIT_FAILURE, errno, "cannot create temporary file");
+
+  /* Make sure the file gets removed.  */
+  unlink (fname);
+
+  fclose (stderr);
+
+  if (dup2 (fd, 2) == -1)
+    {
+      printf ("cannot create file descriptor 2: %m\n");
+      exit (EXIT_FAILURE);
+    }
+
+  stderr = fdopen (2, "w");
+  if (stderr == NULL)
+    {
+      printf ("fdopen failed: %m\n");
+      exit (EXIT_FAILURE);
+    }
+
+  if (fwide (stderr, 0) != 0)
+    {
+      printf ("stderr not initially in mode 0\n");
+      exit (EXIT_FAILURE);
+    }
+
+  errno = EILSEQ;
+  perror ("null mode test 1");
+
+  if (fwide (stderr, 0) != 0)
+    {
+      puts ("perror changed the mode from 0");
+      result = 1;
+    }
+
+  fputs ("multibyte string\n", stderr);
+
+  if (fwide (stderr, 0) >= 0)
+    {
+      puts ("fputs didn't set orientation to narrow");
+      result = 1;
+    }
+
+  errno = EINVAL;
+  perror ("<0 mode test");
+
+  fclose (stderr);
+
+  lseek (fd, 0, SEEK_SET);
+  n = read (fd, buf, sizeof (buf));
+  if (n != MB_EXP_LEN || memcmp (buf, MB_EXP, MB_EXP_LEN) != 0)
+    {
+      printf ("multibyte test failed.  Expected:\n%s\nGot:\n%.*s\n",
+	      MB_EXP, (int) n, buf);
+      result = 1;
+    }
+  else
+    puts ("multibyte test succeeded");
+
+  lseek (fd, 0, SEEK_SET);
+  ftruncate (fd, 0);
+
+  if (dup2 (fd, 2) == -1)
+    {
+      printf ("cannot create file descriptor 2: %m\n");
+      exit (EXIT_FAILURE);
+    }
+  stderr = fdopen (2, "w");
+  if (stderr == NULL)
+    {
+      printf ("fdopen failed: %m\n");
+      exit (EXIT_FAILURE);
+    }
+
+  if (fwide (stderr, 0) != 0)
+    {
+      printf ("stderr not initially in mode 0\n");
+      exit (EXIT_FAILURE);
+    }
+
+  errno = EILSEQ;
+  perror ("null mode test 2");
+
+  if (fwide (stderr, 0) != 0)
+    {
+      puts ("perror changed the mode from 0");
+      result = 1;
+    }
+
+  fputws (L"wide string\n", stderr);
+
+  if (fwide (stderr, 0) <= 0)
+    {
+      puts ("fputws didn't set orientation to wide");
+      result = 1;
+    }
+
+  errno = EINVAL;
+  perror (">0 mode test");
+
+  fclose (stderr);
+
+  lseek (fd, 0, SEEK_SET);
+  n = read (fd, buf, sizeof (buf));
+  if (n != WC_EXP_LEN || memcmp (buf, WC_EXP, WC_EXP_LEN) != 0)
+    {
+      printf ("wide test failed.  Expected:\n%s\nGot:\n%.*s\n",
+	      WC_EXP, (int) n, buf);
+      result = 1;
+    }
+  else
+    puts ("wide test succeeded");
+
+  close (fd);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/stdio-common/tst-popen.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-popen.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-popen.c	(revision 2036)
@@ -0,0 +1,73 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+
+static int
+do_test (void)
+{
+  FILE *f = popen ("echo test", "r");
+  int result = 0, ret;
+  char *line = NULL;
+  size_t len = 0;
+
+  if (f == NULL)
+    {
+      printf ("popen failed %m");
+      return 1;
+    }
+
+  /* POSIX says that pipe streams are byte-oriented.  */
+  if (fwide (f, 0) >= 0)
+    {
+      puts ("popen did not return byte-oriented stream");
+      result = 1;
+    }
+
+  if (getline (&line, &len, f) != 5)
+    {
+      puts ("could not read line from popen");
+      result = 1;
+    }
+  else if (strcmp (line, "test\n") != 0)
+    {
+      printf ("read \"%s\"\n", line);
+      result = 1;
+    }
+
+  if (getline (&line, &len, f) != -1)
+    {
+      puts ("second getline did not return -1");
+      result = 1;
+    }
+
+  ret = pclose (f);
+  if (ret != 0)
+    {
+      printf ("pclose returned %d\n", ret);
+      result = 1;
+    }
+
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/stdio-common/tst-printf.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-printf.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-printf.c	(revision 2036)
@@ -0,0 +1,386 @@
+/* Copyright (C) 1991,92,93,95,96,97,98,99, 2000, 2002
+     Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifdef	BSD
+#include </usr/include/stdio.h>
+#define EXIT_SUCCESS 0
+#else
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#endif
+
+#include <float.h>
+
+static void rfg1 (void);
+static void rfg2 (void);
+static void rfg3 (void);
+
+
+static void
+fmtchk (const char *fmt)
+{
+  (void) fputs(fmt, stdout);
+  (void) printf(":\t`");
+  (void) printf(fmt, 0x12);
+  (void) printf("'\n");
+}
+
+static void
+fmtst1chk (const char *fmt)
+{
+  (void) fputs(fmt, stdout);
+  (void) printf(":\t`");
+  (void) printf(fmt, 4, 0x12);
+  (void) printf("'\n");
+}
+
+static void
+fmtst2chk (const char *fmt)
+{
+  (void) fputs(fmt, stdout);
+  (void) printf(":\t`");
+  (void) printf(fmt, 4, 4, 0x12);
+  (void) printf("'\n");
+}
+
+
+/* This page is covered by the following copyright: */
+
+/* (C) Copyright C E Chew
+ *
+ * Feel free to copy, use and distribute this software provided:
+ *
+ *	1. you do not pretend that you wrote it
+ *	2. you leave this copyright notice intact.
+ */
+
+/*
+ * Extracted from exercise.c for glibc-1.05 bug report by Bruce Evans.
+ */
+
+#define DEC -123
+#define INT 255
+#define UNS (~0)
+
+/* Formatted Output Test
+ *
+ * This exercises the output formatting code.
+ */
+
+static void
+fp_test (void)
+{
+  int i, j, k, l;
+  char buf[7];
+  char *prefix = buf;
+  char tp[20];
+
+  puts("\nFormatted output test");
+  printf("prefix  6d      6o      6x      6X      6u\n");
+  strcpy(prefix, "%");
+  for (i = 0; i < 2; i++) {
+    for (j = 0; j < 2; j++) {
+      for (k = 0; k < 2; k++) {
+	for (l = 0; l < 2; l++) {
+	  strcpy(prefix, "%");
+	  if (i == 0) strcat(prefix, "-");
+	  if (j == 0) strcat(prefix, "+");
+	  if (k == 0) strcat(prefix, "#");
+	  if (l == 0) strcat(prefix, "0");
+	  printf("%5s |", prefix);
+	  strcpy(tp, prefix);
+	  strcat(tp, "6d |");
+	  printf(tp, DEC);
+	  strcpy(tp, prefix);
+	  strcat(tp, "6o |");
+	  printf(tp, INT);
+	  strcpy(tp, prefix);
+	  strcat(tp, "6x |");
+	  printf(tp, INT);
+	  strcpy(tp, prefix);
+	  strcat(tp, "6X |");
+	  printf(tp, INT);
+	  strcpy(tp, prefix);
+	  strcat(tp, "6u |");
+	  printf(tp, UNS);
+	  printf("\n");
+	}
+      }
+    }
+  }
+  printf("%10s\n", (char *) NULL);
+  printf("%-10s\n", (char *) NULL);
+}
+
+
+int
+main (int argc, char *argv[])
+{
+  static char shortstr[] = "Hi, Z.";
+  static char longstr[] = "Good morning, Doctor Chandra.  This is Hal.  \
+I am ready for my first lesson today.";
+  int result = 0;
+
+  fmtchk("%.4x");
+  fmtchk("%04x");
+  fmtchk("%4.4x");
+  fmtchk("%04.4x");
+  fmtchk("%4.3x");
+  fmtchk("%04.3x");
+
+  fmtst1chk("%.*x");
+  fmtst1chk("%0*x");
+  fmtst2chk("%*.*x");
+  fmtst2chk("%0*.*x");
+
+#ifndef	BSD
+  printf("bad format:\t\"%b\"\n");
+  printf("nil pointer (padded):\t\"%10p\"\n", (void *) NULL);
+#endif
+
+  printf("decimal negative:\t\"%d\"\n", -2345);
+  printf("octal negative:\t\"%o\"\n", -2345);
+  printf("hex negative:\t\"%x\"\n", -2345);
+  printf("long decimal number:\t\"%ld\"\n", -123456L);
+  printf("long octal negative:\t\"%lo\"\n", -2345L);
+  printf("long unsigned decimal number:\t\"%lu\"\n", -123456L);
+  printf("zero-padded LDN:\t\"%010ld\"\n", -123456L);
+  printf("left-adjusted ZLDN:\t\"%-010ld\"\n", -123456L);
+  printf("space-padded LDN:\t\"%10ld\"\n", -123456L);
+  printf("left-adjusted SLDN:\t\"%-10ld\"\n", -123456L);
+
+  printf("zero-padded string:\t\"%010s\"\n", shortstr);
+  printf("left-adjusted Z string:\t\"%-010s\"\n", shortstr);
+  printf("space-padded string:\t\"%10s\"\n", shortstr);
+  printf("left-adjusted S string:\t\"%-10s\"\n", shortstr);
+  printf("null string:\t\"%s\"\n", (char *)NULL);
+  printf("limited string:\t\"%.22s\"\n", longstr);
+
+  printf("e-style >= 1:\t\"%e\"\n", 12.34);
+  printf("e-style >= .1:\t\"%e\"\n", 0.1234);
+  printf("e-style < .1:\t\"%e\"\n", 0.001234);
+  printf("e-style big:\t\"%.60e\"\n", 1e20);
+  printf ("e-style == .1:\t\"%e\"\n", 0.1);
+  printf("f-style >= 1:\t\"%f\"\n", 12.34);
+  printf("f-style >= .1:\t\"%f\"\n", 0.1234);
+  printf("f-style < .1:\t\"%f\"\n", 0.001234);
+  printf("g-style >= 1:\t\"%g\"\n", 12.34);
+  printf("g-style >= .1:\t\"%g\"\n", 0.1234);
+  printf("g-style < .1:\t\"%g\"\n", 0.001234);
+  printf("g-style big:\t\"%.60g\"\n", 1e20);
+
+  printf (" %6.5f\n", .099999999860301614);
+  printf (" %6.5f\n", .1);
+  printf ("x%5.4fx\n", .5);
+
+  printf ("%#03x\n", 1);
+
+  printf ("something really insane: %.10000f\n", 1.0);
+
+  {
+    double d = FLT_MIN;
+    int niter = 17;
+
+    while (niter-- != 0)
+      printf ("%.17e\n", d / 2);
+    fflush (stdout);
+  }
+
+  printf ("%15.5e\n", 4.9406564584124654e-324);
+
+#define FORMAT "|%12.4f|%12.4e|%12.4g|\n"
+  printf (FORMAT, 0.0, 0.0, 0.0);
+  printf (FORMAT, 1.0, 1.0, 1.0);
+  printf (FORMAT, -1.0, -1.0, -1.0);
+  printf (FORMAT, 100.0, 100.0, 100.0);
+  printf (FORMAT, 1000.0, 1000.0, 1000.0);
+  printf (FORMAT, 10000.0, 10000.0, 10000.0);
+  printf (FORMAT, 12345.0, 12345.0, 12345.0);
+  printf (FORMAT, 100000.0, 100000.0, 100000.0);
+  printf (FORMAT, 123456.0, 123456.0, 123456.0);
+#undef	FORMAT
+
+  {
+    char buf[20];
+    char buf2[512];
+    printf ("snprintf (\"%%30s\", \"foo\") == %d, \"%.*s\"\n",
+	    snprintf (buf, sizeof (buf), "%30s", "foo"), (int) sizeof (buf),
+	    buf);
+    printf ("snprintf (\"%%.999999u\", 10) == %d\n",
+	    snprintf(buf2, sizeof(buf2), "%.999999u", 10));
+  }
+
+  fp_test ();
+
+  printf ("%e should be 1.234568e+06\n", 1234567.8);
+  printf ("%f should be 1234567.800000\n", 1234567.8);
+  printf ("%g should be 1.23457e+06\n", 1234567.8);
+  printf ("%g should be 123.456\n", 123.456);
+  printf ("%g should be 1e+06\n", 1000000.0);
+  printf ("%g should be 10\n", 10.0);
+  printf ("%g should be 0.02\n", 0.02);
+
+#if 0
+  /* This test rather checks the way the compiler handles constant
+     folding.  gcc behavior wrt to this changed in 3.2 so it is not a
+     portable test.  */
+  {
+    double x=1.0;
+    printf("%.17f\n",(1.0/x/10.0+1.0)*x-x);
+  }
+#endif
+
+  {
+    char buf[200];
+
+    sprintf(buf,"%*s%*s%*s",-1,"one",-20,"two",-30,"three");
+
+    result |= strcmp (buf,
+		      "onetwo                 three                         ");
+
+    puts (result != 0 ? "Test failed!" : "Test ok.");
+  }
+
+  {
+    char buf[200];
+
+    sprintf (buf, "%07Lo", 040000000000ll);
+    printf ("sprintf (buf, \"%%07Lo\", 040000000000ll) = %s", buf);
+
+    if (strcmp (buf, "40000000000") != 0)
+      {
+	result = 1;
+	fputs ("\tFAILED", stdout);
+      }
+    puts ("");
+  }
+
+  printf ("printf (\"%%hhu\", %u) = %hhu\n", UCHAR_MAX + 2, UCHAR_MAX + 2);
+  printf ("printf (\"%%hu\", %u) = %hu\n", USHRT_MAX + 2, USHRT_MAX + 2);
+
+  puts ("--- Should be no further output. ---");
+  rfg1 ();
+  rfg2 ();
+  rfg3 ();
+
+  {
+    char bytes[7];
+    char buf[20];
+
+    memset (bytes, '\xff', sizeof bytes);
+    sprintf (buf, "foo%hhn\n", &bytes[3]);
+    if (bytes[0] != '\xff' || bytes[1] != '\xff' || bytes[2] != '\xff'
+	|| bytes[4] != '\xff' || bytes[5] != '\xff' || bytes[6] != '\xff')
+      {
+	puts ("%hhn overwrite more bytes");
+	result = 1;
+      }
+    if (bytes[3] != 3)
+      {
+	puts ("%hhn wrote incorrect value");
+	result = 1;
+      }
+  }
+
+  return result != 0;
+}
+
+
+static void
+rfg1 (void)
+{
+  char buf[100];
+
+  sprintf (buf, "%5.s", "xyz");
+  if (strcmp (buf, "     ") != 0)
+    printf ("got: '%s', expected: '%s'\n", buf, "     ");
+  sprintf (buf, "%5.f", 33.3);
+  if (strcmp (buf, "   33") != 0)
+    printf ("got: '%s', expected: '%s'\n", buf, "   33");
+  sprintf (buf, "%8.e", 33.3e7);
+  if (strcmp (buf, "   3e+08") != 0)
+    printf ("got: '%s', expected: '%s'\n", buf, "   3e+08");
+  sprintf (buf, "%8.E", 33.3e7);
+  if (strcmp (buf, "   3E+08") != 0)
+    printf ("got: '%s', expected: '%s'\n", buf, "   3E+08");
+  sprintf (buf, "%.g", 33.3);
+  if (strcmp (buf, "3e+01") != 0)
+    printf ("got: '%s', expected: '%s'\n", buf, "3e+01");
+  sprintf (buf, "%.G", 33.3);
+  if (strcmp (buf, "3E+01") != 0)
+    printf ("got: '%s', expected: '%s'\n", buf, "3E+01");
+}
+
+static void
+rfg2 (void)
+{
+  int prec;
+  char buf[100];
+
+  prec = 0;
+  sprintf (buf, "%.*g", prec, 3.3);
+  if (strcmp (buf, "3") != 0)
+    printf ("got: '%s', expected: '%s'\n", buf, "3");
+  prec = 0;
+  sprintf (buf, "%.*G", prec, 3.3);
+  if (strcmp (buf, "3") != 0)
+    printf ("got: '%s', expected: '%s'\n", buf, "3");
+  prec = 0;
+  sprintf (buf, "%7.*G", prec, 3.33);
+  if (strcmp (buf, "      3") != 0)
+    printf ("got: '%s', expected: '%s'\n", buf, "      3");
+  prec = 3;
+  sprintf (buf, "%04.*o", prec, 33);
+  if (strcmp (buf, " 041") != 0)
+    printf ("got: '%s', expected: '%s'\n", buf, " 041");
+  prec = 7;
+  sprintf (buf, "%09.*u", prec, 33);
+  if (strcmp (buf, "  0000033") != 0)
+    printf ("got: '%s', expected: '%s'\n", buf, "  0000033");
+  prec = 3;
+  sprintf (buf, "%04.*x", prec, 33);
+  if (strcmp (buf, " 021") != 0)
+    printf ("got: '%s', expected: '%s'\n", buf, " 021");
+  prec = 3;
+  sprintf (buf, "%04.*X", prec, 33);
+  if (strcmp (buf, " 021") != 0)
+    printf ("got: '%s', expected: '%s'\n", buf, " 021");
+}
+
+static void
+rfg3 (void)
+{
+  char buf[100];
+  double g = 5.0000001;
+  unsigned long l = 1234567890;
+  double d = 321.7654321;
+  const char s[] = "test-string";
+  int i = 12345;
+  int h = 1234;
+
+  sprintf (buf,
+	   "%1$*5$d %2$*6$hi %3$*7$lo %4$*8$f %9$*12$e %10$*13$g %11$*14$s",
+	   i, h, l, d, 8, 5, 14, 14, d, g, s, 14, 3, 14);
+  if (strcmp (buf,
+	      "   12345  1234    11145401322     321.765432   3.217654e+02   5    test-string") != 0)
+    printf ("got: '%s', expected: '%s'\n", buf,
+	    "   12345  1234    11145401322     321.765432   3.217654e+02   5    test-string");
+}
Index: trunk/src/libctests/glibc/stdio-common/tst-printf.sh
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-printf.sh	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-printf.sh	(revision 2036)
@@ -0,0 +1,257 @@
+#! /bin/sh
+# Testing of printf.
+# Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+common_objpfx=$1; shift
+run_program_prefix=$1; shift
+
+status=0
+
+LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
+${run_program_prefix} \
+  ${common_objpfx}stdio-common/tst-printf \
+  > ${common_objpfx}stdio-common/tst-printf.out || status=1
+
+cat <<'EOF' |
+%.4x:	`0012'
+%04x:	`0012'
+%4.4x:	`0012'
+%04.4x:	`0012'
+%4.3x:	` 012'
+%04.3x:	` 012'
+%.*x:	`0012'
+%0*x:	`0012'
+%*.*x:	`0012'
+%0*.*x:	`0012'
+bad format:	"%b"
+nil pointer (padded):	"     (nil)"
+decimal negative:	"-2345"
+octal negative:	"37777773327"
+hex negative:	"fffff6d7"
+long decimal number:	"-123456"
+long octal negative:	"37777773327"
+long unsigned decimal number:	"4294843840"
+zero-padded LDN:	"-000123456"
+left-adjusted ZLDN:	"-123456   "
+space-padded LDN:	"   -123456"
+left-adjusted SLDN:	"-123456   "
+zero-padded string:	"    Hi, Z."
+left-adjusted Z string:	"Hi, Z.    "
+space-padded string:	"    Hi, Z."
+left-adjusted S string:	"Hi, Z.    "
+null string:	"(null)"
+limited string:	"Good morning, Doctor C"
+e-style >= 1:	"1.234000e+01"
+e-style >= .1:	"1.234000e-01"
+e-style < .1:	"1.234000e-03"
+e-style big:	"1.000000000000000000000000000000000000000000000000000000000000e+20"
+e-style == .1:	"1.000000e-01"
+f-style >= 1:	"12.340000"
+f-style >= .1:	"0.123400"
+f-style < .1:	"0.001234"
+g-style >= 1:	"12.34"
+g-style >= .1:	"0.1234"
+g-style < .1:	"0.001234"
+g-style big:	"100000000000000000000"
+ 0.10000
+ 0.10000
+x0.5000x
+0x1
+something really insane: 1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+   4.94066e-324
+|      0.0000|  0.0000e+00|           0|
+|      1.0000|  1.0000e+00|           1|
+|     -1.0000| -1.0000e+00|          -1|
+|    100.0000|  1.0000e+02|         100|
+|   1000.0000|  1.0000e+03|        1000|
+|  10000.0000|  1.0000e+04|       1e+04|
+|  12345.0000|  1.2345e+04|   1.234e+04|
+| 100000.0000|  1.0000e+05|       1e+05|
+| 123456.0000|  1.2346e+05|   1.235e+05|
+snprintf ("%30s", "foo") == 30, "                   "
+snprintf ("%.999999u", 10) == 999999
+
+Formatted output test
+prefix  6d      6o      6x      6X      6u
+%-+#0 |-123   |0377   |0xff   |0XFF   |4294967295 |
+ %-+# |-123   |0377   |0xff   |0XFF   |4294967295 |
+ %-+0 |-123   |377    |ff     |FF     |4294967295 |
+  %-+ |-123   |377    |ff     |FF     |4294967295 |
+ %-#0 |-123   |0377   |0xff   |0XFF   |4294967295 |
+  %-# |-123   |0377   |0xff   |0XFF   |4294967295 |
+  %-0 |-123   |377    |ff     |FF     |4294967295 |
+   %- |-123   |377    |ff     |FF     |4294967295 |
+ %+#0 |-00123 |000377 |0x00ff |0X00FF |4294967295 |
+  %+# |  -123 |  0377 |  0xff |  0XFF |4294967295 |
+  %+0 |-00123 |000377 |0000ff |0000FF |4294967295 |
+   %+ |  -123 |   377 |    ff |    FF |4294967295 |
+  %#0 |-00123 |000377 |0x00ff |0X00FF |4294967295 |
+   %# |  -123 |  0377 |  0xff |  0XFF |4294967295 |
+   %0 |-00123 |000377 |0000ff |0000FF |4294967295 |
+    % |  -123 |   377 |    ff |    FF |4294967295 |
+    (null)
+(null)    
+1.234568e+06 should be 1.234568e+06
+1234567.800000 should be 1234567.800000
+1.23457e+06 should be 1.23457e+06
+123.456 should be 123.456
+1e+06 should be 1e+06
+10 should be 10
+0.02 should be 0.02
+Test ok.
+sprintf (buf, "%07Lo", 040000000000ll) = 40000000000
+printf ("%hhu", 257) = 1
+printf ("%hu", 65537) = 1
+--- Should be no further output. ---
+EOF
+cmp - ${common_objpfx}stdio-common/tst-printf.out > /dev/null 2>&1 ||
+cat <<'EOF' |
+%.4x:	`0012'
+%04x:	`0012'
+%4.4x:	`0012'
+%04.4x:	`0012'
+%4.3x:	` 012'
+%04.3x:	` 012'
+%.*x:	`0012'
+%0*x:	`0012'
+%*.*x:	`0012'
+%0*.*x:	`0012'
+bad format:	"%b"
+nil pointer (padded):	"     (nil)"
+decimal negative:	"-2345"
+octal negative:	"37777773327"
+hex negative:	"fffff6d7"
+long decimal number:	"-123456"
+long octal negative:	"1777777777777777773327"
+long unsigned decimal number:	"18446744073709428160"
+zero-padded LDN:	"-000123456"
+left-adjusted ZLDN:	"-123456   "
+space-padded LDN:	"   -123456"
+left-adjusted SLDN:	"-123456   "
+zero-padded string:	"    Hi, Z."
+left-adjusted Z string:	"Hi, Z.    "
+space-padded string:	"    Hi, Z."
+left-adjusted S string:	"Hi, Z.    "
+null string:	"(null)"
+limited string:	"Good morning, Doctor C"
+e-style >= 1:	"1.234000e+01"
+e-style >= .1:	"1.234000e-01"
+e-style < .1:	"1.234000e-03"
+e-style big:	"1.000000000000000000000000000000000000000000000000000000000000e+20"
+e-style == .1:	"1.000000e-01"
+f-style >= 1:	"12.340000"
+f-style >= .1:	"0.123400"
+f-style < .1:	"0.001234"
+g-style >= 1:	"12.34"
+g-style >= .1:	"0.1234"
+g-style < .1:	"0.001234"
+g-style big:	"100000000000000000000"
+ 0.10000
+ 0.10000
+x0.5000x
+0x1
+something really insane: 1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+5.87747175411143754e-39
+   4.94066e-324
+|      0.0000|  0.0000e+00|           0|
+|      1.0000|  1.0000e+00|           1|
+|     -1.0000| -1.0000e+00|          -1|
+|    100.0000|  1.0000e+02|         100|
+|   1000.0000|  1.0000e+03|        1000|
+|  10000.0000|  1.0000e+04|       1e+04|
+|  12345.0000|  1.2345e+04|   1.234e+04|
+| 100000.0000|  1.0000e+05|       1e+05|
+| 123456.0000|  1.2346e+05|   1.235e+05|
+snprintf ("%30s", "foo") == 30, "                   "
+snprintf ("%.999999u", 10) == 999999
+
+Formatted output test
+prefix  6d      6o      6x      6X      6u
+%-+#0 |-123   |0377   |0xff   |0XFF   |4294967295 |
+ %-+# |-123   |0377   |0xff   |0XFF   |4294967295 |
+ %-+0 |-123   |377    |ff     |FF     |4294967295 |
+  %-+ |-123   |377    |ff     |FF     |4294967295 |
+ %-#0 |-123   |0377   |0xff   |0XFF   |4294967295 |
+  %-# |-123   |0377   |0xff   |0XFF   |4294967295 |
+  %-0 |-123   |377    |ff     |FF     |4294967295 |
+   %- |-123   |377    |ff     |FF     |4294967295 |
+ %+#0 |-00123 |000377 |0x00ff |0X00FF |4294967295 |
+  %+# |  -123 |  0377 |  0xff |  0XFF |4294967295 |
+  %+0 |-00123 |000377 |0000ff |0000FF |4294967295 |
+   %+ |  -123 |   377 |    ff |    FF |4294967295 |
+  %#0 |-00123 |000377 |0x00ff |0X00FF |4294967295 |
+   %# |  -123 |  0377 |  0xff |  0XFF |4294967295 |
+   %0 |-00123 |000377 |0000ff |0000FF |4294967295 |
+    % |  -123 |   377 |    ff |    FF |4294967295 |
+    (null)
+(null)    
+1.234568e+06 should be 1.234568e+06
+1234567.800000 should be 1234567.800000
+1.23457e+06 should be 1.23457e+06
+123.456 should be 123.456
+1e+06 should be 1e+06
+10 should be 10
+0.02 should be 0.02
+Test ok.
+sprintf (buf, "%07Lo", 040000000000ll) = 40000000000
+printf ("%hhu", 257) = 1
+printf ("%hu", 65537) = 1
+--- Should be no further output. ---
+EOF
+cmp - ${common_objpfx}stdio-common/tst-printf.out > /dev/null 2>&1 ||
+{
+  status=1
+  echo "*** output comparison failed"
+}
+
+exit $status
Index: trunk/src/libctests/glibc/stdio-common/tst-printfsz.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-printfsz.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-printfsz.c	(revision 2036)
@@ -0,0 +1,67 @@
+/* Based on code by Larry McVoy <lm@neteng.engr.sgi.com>.  */
+#include <printf.h>
+#include <stdio.h>
+#include <string.h>
+
+#define V       12345678.12345678
+
+
+int
+main (int argc, char *argv[])
+{
+  char buf[1024];
+  int result = 0;
+
+  /* Register the printf handlers.  */
+  register_printf_function ('b', printf_size, printf_size_info);
+  register_printf_function ('B', printf_size, printf_size_info);
+
+
+  sprintf (buf, "%g %b %B %.0b %.0B %.1b %.1B %8.0b %08.0B",
+	   V, 1025., V, V, V, V, V, V, V, V);
+  fputs (buf, stdout);
+  if (strcmp (buf, "\
+1.23457e+07 1.001k 12.346M 12m 12M 11.8m 12.3M      12m 0000012M"))
+    {
+      result = 1;
+      fputs (" -> WRONG\n", stdout);
+    }
+  else
+    fputs (" -> OK\n", stdout);
+
+  sprintf (buf, "%b|%B|%-20.2b|%-10.0b|%-10.8b|%-10.2B|",
+	   V, V, V, V, V, V, V, V, V, V, V);
+  fputs (buf, stdout);
+  if (strcmp (buf, "\
+11.774m|12.346M|11.77m              |12m       |11.77375614m|12.35M    |"))
+    {
+      result = 1;
+      fputs (" -> WRONG\n", stdout);
+    }
+  else
+    fputs (" -> OK\n", stdout);
+
+  sprintf (buf, "%#.0B %*.0b %10.*b %*.*B %10.2B",
+	   V, 2, V, 2, V, 10, 2, V, V);
+  fputs (buf, stdout);
+  if (strcmp (buf, "12.M 12m     11.77m     12.35M     12.35M"))
+    {
+      result = 1;
+      fputs (" -> WRONG\n", stdout);
+    }
+  else
+    fputs (" -> OK\n", stdout);
+
+  sprintf (buf, "%6B %6.1B %b %B %b %B",
+	   V, V, 1000.0, 1000.0, 1024.0, 1024.0);
+  fputs (buf, stdout);
+  if (strcmp (buf, "12.346M  12.3M 1000.000  1.000K 1.000k 1.024K"))
+    {
+      result = 1;
+      fputs (" -> WRONG\n", stdout);
+    }
+  else
+    fputs (" -> OK\n", stdout);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/stdio-common/tst-rndseek.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-rndseek.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-rndseek.c	(revision 2036)
@@ -0,0 +1,144 @@
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static char fname[] = "/tmp/rndseek.XXXXXX";
+static char tempdata[65 * 1024];
+
+
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 10
+
+#include "../test-skeleton.c"
+
+
+static int
+fp_test (const char *name, FILE *fp)
+{
+  int result = 0;
+  int rounds = 10000;
+
+  do
+    {
+      int idx = random () % (sizeof (tempdata) - 2);
+      char ch1;
+      char ch2;
+
+      if (fseek (fp, idx, SEEK_SET) != 0)
+	{
+	  printf ("%s: %d: fseek failed: %m\n", name, rounds);
+	  result = 1;
+	  break;
+	}
+
+      ch1 = fgetc_unlocked (fp);
+      ch2 = tempdata[idx];
+      if (ch1 != ch2)
+	{
+	  printf ("%s: %d: character at index %d not what is expected ('%c' vs '%c')\n",
+		  name, rounds, idx, ch1, ch2);
+	  result = 1;
+	  break;
+	}
+
+      ch1 = fgetc (fp);
+      ch2 = tempdata[idx + 1];
+      if (ch1 != ch2)
+	{
+	  printf ("%s: %d: character at index %d not what is expected ('%c' vs '%c')\n",
+		  name, rounds, idx + 1, ch1, ch2);
+	  result = 1;
+	  break;
+	}
+    }
+  while (--rounds > 0);
+
+  fclose (fp);
+
+  return result;
+}
+
+
+static int
+do_test (void)
+{
+  int fd;
+  FILE *fp;
+  size_t i;
+  int result;
+
+  fd = mkstemp (fname);
+  if (fd == -1)
+    {
+      printf ("cannot open temporary file: %m\n");
+      return 1;
+    }
+  /* Make sure the file gets removed.  */
+  add_temp_file (fname);
+
+  /* Repeatability demands this.  */
+  srandom (42);
+
+  /* First create some temporary data.  */
+  for (i = 0; i < sizeof (tempdata); ++i)
+    tempdata[i] = 'a' + random () % 26;
+
+  /* Write this data to a file.  */
+  if (TEMP_FAILURE_RETRY (write (fd, tempdata, sizeof (tempdata)))
+      != sizeof (tempdata))
+    {
+      printf ("cannot wrote data to temporary file: %m\n");
+      return 1;
+    }
+
+  /* Now try reading the data.  */
+  fp = fdopen (dup (fd), "r");
+  if (fp == NULL)
+    {
+      printf ("cannot duplicate temporary file descriptor: %m\n");
+      return 1;
+    }
+
+  rewind (fp);
+  for (i = 0; i < sizeof (tempdata); ++i)
+    {
+      int ch0 = fgetc (fp);
+      char ch1 = ch0;
+      char ch2 = tempdata[i];
+
+      if (ch0 == EOF)
+	{
+	  puts ("premature end of file while reading data");
+	  return 1;
+	}
+
+      if (ch1 != ch2)
+	{
+	  printf ("%zd: '%c' vs '%c'\n", i, ch1, ch2);
+	  return 1;
+	}
+    }
+
+  result = fp_test ("fdopen(\"r\")", fp);
+
+  fp = fopen (fname, "r");
+  result |= fp_test ("fopen(\"r\")", fp);
+
+  fp = fopen64 (fname, "r");
+  result |= fp_test ("fopen64(\"r\")", fp);
+
+  /* The "rw" mode will prevent the mmap-using code from being used.  */
+  fp = fdopen (fd, "rw");
+  result = fp_test ("fdopen(\"rw\")", fp);
+
+  fp = fopen (fname, "rw");
+  result |= fp_test ("fopen(\"rw\")", fp);
+
+  fp = fopen64 (fname, "rw");
+  result |= fp_test ("fopen64(\"rw\")", fp);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/stdio-common/tst-sprintf.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-sprintf.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-sprintf.c	(revision 2036)
@@ -0,0 +1,41 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+int
+main (void)
+{
+  char buf[100];
+  int result = 0;
+
+  if (sprintf (buf, "%.0ls", L"foo") != 0
+      || strlen (buf) != 0)
+    {
+      puts ("sprintf (buf, \"%.0ls\", L\"foo\") produced some output");
+      result = 1;
+    }
+
+#define SIZE (1024*70000)
+#define STR(x) #x
+
+  char *dst = malloc (SIZE + 1);
+
+  if (dst == NULL)
+    {
+      puts ("memory allocation failure");
+      result = 1;
+    }
+  else
+    {
+      sprintf (dst, "%*s", SIZE, "");
+      if (strnlen (dst, SIZE + 1) != SIZE)
+	{
+	  puts ("sprintf (dst, \"%*s\", " STR(SIZE) ", \"\") did not produce enough output");
+	  result = 1;
+	}
+      free (dst);
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/stdio-common/tst-sscanf.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-sscanf.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-sscanf.c	(revision 2036)
@@ -0,0 +1,170 @@
+/* Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <locale.h>
+
+const char *str_double[] =
+{
+  "-.10000E+020.20000E+020.25000E+010.40000E+010.50000E+010.12500E+01",
+  "0.10000E+020.20000E+020.25000E+010.40000E+010.50000E+010.12500E+01",
+  "-1234567E0198765432E0912345678901987654321091234567890198765432109",
+  "-0.1000E+020.20000E+020.25000E+010.40000E+010.50000E+010.12500E+01"
+};
+
+const double val_double[] =
+{
+  -.10000E+02, 0.20000E+02, 0.25000E+01, 0.40000E+01, 0.50000E+01, 0.12500E+01,
+  0.10000E+02, 0.20000E+02, 0.25000E+01, 0.40000E+01, 0.50000E+01, 0.12500E+01,
+  -1234567E01, 98765432E09, 12345678901.0, 98765432109.0, 12345678901.0,
+    98765432109.0,
+  -0.1000E+02, 0.20000E+02, 0.25000E+01, 0.40000E+01, 0.50000E+01, 0.12500E+01
+};
+
+const char *str_long[] =
+{
+  "-12345678987654321123456789987654321123456789987654321",
+  "-12345678987654321123456789987654321123456789987654321",
+  "-12,345,678987,654,321123,456,789987,654,321123,456,789987,654,321",
+  "-12,345,678987,654,321123,456,789987,654,321123,456,789987,654,321"
+};
+
+const char *fmt_long[] =
+{
+  "%9ld%9ld%9ld%9ld%9ld%9ld",
+  "%I9ld%I9ld%I9ld%I9ld%I9ld%I9ld",
+  "%'11ld%'11ld%'11ld%'11ld%'11ld%'11ld",
+  "%I'11ld%I'11ld%I'11ld%I'11ld%I'11ld%I'11ld"
+};
+
+const long int val_long[] =
+{
+  -12345678, 987654321, 123456789, 987654321, 123456789, 987654321
+};
+
+struct int_test
+{
+  const char *str;
+  const char *fmt;
+  int retval;
+} int_tests[] = 
+{
+  { "foo\n", "foo\nbar", -1 },
+  { "foo\n", "foo bar", -1 },
+  { "foo\n", "foo %d", -1 },
+  { "foo\n", "foo\n%d", -1 },
+  { "foon", "foonbar", -1 },
+  { "foon", "foon%d", -1 },
+  { "foo ", "foo bar", -1 },
+  { "foo ", "foo %d", -1 },
+  { "foo\t", "foo\tbar", -1 },
+  { "foo\t", "foo bar", -1 },
+  { "foo\t", "foo %d", -1 },
+  { "foo\t", "foo\t%d", -1 },
+  { "foo", "foo", 0 },
+  { "foon", "foo bar", 0 },
+  { "foon", "foo %d", 0 },
+  { "foo ", "fooxbar", 0 },
+  { "foo ", "foox%d", 0 },
+  { "foo bar", "foon", 0 },
+  { "foo bar", "foo bar", 0 },
+  { "foo bar", "foo %d", 0 },
+  { "foo bar", "foon%d", 0 },
+  { "foo ", "foo %n", 0 },
+  { "foo%bar1", "foo%%bar%d", 1 },
+  /* Some OSes skip whitespace here while others don't.  */
+  { "foo \t %bar1", "foo%%bar%d", 1 }
+};
+
+int
+main (void)
+{
+  double d[6];
+  long l[6];
+  int i, j;
+  int tst_locale;
+  int result = 0;
+
+  tst_locale = 1;
+  if (tst_locale)
+    if (setlocale (LC_ALL, "en_US.ISO-8859-1") == NULL)
+      {
+	puts ("Failed to set en_US locale, skipping locale related tests");
+	tst_locale = 0;
+      }
+
+  for (i = 0; i < 4; ++i)
+    {
+      if (sscanf (str_double[i], "%11lf%11lf%11lf%11lf%11lf%11lf",
+		  &d[0], &d[1], &d[2], &d[3], &d[4], &d[5]) != 6)
+	{
+	  printf ("Double sscanf test %d wrong number of "
+		  "assigned inputs\n", i);
+	  result = 1;
+	}
+      else
+	for (j = 0; j < 6; ++j)
+	  if (d[j] != val_double[6 * i + j])
+	    {
+	      printf ("Double sscanf test %d failed (%g instead of %g)\n",
+		      i, d[j], val_double[6 * i + j]);
+	      result = 1;
+	      break;
+	    }
+    }
+
+  for (i = 0; i < 4; ++i)
+    {
+      if (sscanf (str_long[i], fmt_long[i],
+		  &l[0], &l[1], &l[2], &l[3], &l[4], &l[5]) != 6)
+	{
+	  printf ("Integer sscanf test %d wrong number of "
+		  "assigned inputs\n", i);
+	  result = 1;
+	}
+      else
+	for (j = 0; j < 6; ++j)
+	  if (l[j] != val_long[j])
+	    {
+	      printf ("Integer sscanf test %d failed (%ld instead %ld)\n",
+		      i, l[j], val_long[j]);
+	      result = 1;
+	      break;
+	    }
+
+      if (! tst_locale)
+	break;
+    }
+
+  for (i = 0; i < sizeof (int_tests) / sizeof (int_tests[0]); ++i)
+    {
+      int dummy, ret;
+
+      if ((ret = sscanf (int_tests[i].str, int_tests[i].fmt,
+			 &dummy)) != int_tests[i].retval)
+	{
+	  printf ("int_tests[%d] returned %d != %d\n",
+		  i, ret, int_tests[i].retval);
+	  result = 1;
+	}
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/stdio-common/tst-swprintf.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-swprintf.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-swprintf.c	(revision 2036)
@@ -0,0 +1,56 @@
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <wchar.h>
+
+/* This is the relevant piece from the charmap:
+<UFF61>     /x8e/xa1     HALFWIDTH IDEOGRAPHIC FULL STOP
+<UFF62>     /x8e/xa2     HALFWIDTH LEFT CORNER BRACKET
+<UFF63>     /x8e/xa3     HALFWIDTH RIGHT CORNER BRACKET
+<UFF64>     /x8e/xa4     HALFWIDTH IDEOGRAPHIC COMMA
+ */
+
+const char input[] = "\x8e\xa1g\x8e\xa2h\x8e\xa3i\x8e\xa4j";
+
+int
+main (void)
+{
+  wchar_t buf[1000];
+#define nbuf (sizeof (buf) / sizeof (buf[0]))
+  int result = 0;
+  ssize_t n;
+
+  if (setlocale (LC_ALL, "ja_JP.EUC-JP") == NULL)
+    {
+      puts ("cannot set locale");
+      exit (1);
+    }
+
+#define CHECK(fmt, nexp, exp) \
+  n = swprintf (buf, nbuf, fmt, input);					      \
+  if (n != nexp)							      \
+    {									      \
+      printf ("swprintf (.., .., L\"%ls\", \"%ls\") return %d, not %d\n",     \
+	      fmt, (wchar_t*) input, (int) n, (int) nexp);		      \
+      result = 1;							      \
+    }									      \
+  else if (wcscmp (buf, exp) != 0)					      \
+    {									      \
+      printf ("\
+swprintf (.., .., L\"%ls\", \"%ls\") produced \"%ls\", not \"%ls\"\n",	      \
+	     fmt, (wchar_t *) input, buf, exp );			      \
+      result = 1;							      \
+    }
+
+  CHECK (L"[%-6.0s]", 8, L"[      ]");
+  CHECK (L"[%-6.1s]", 8, L"[\xff61     ]");
+  CHECK (L"[%-6.2s]", 8, L"[\xff61g    ]");
+  CHECK (L"[%-6.3s]", 8, L"[\xff61g\xff62   ]");
+  CHECK (L"[%-6.4s]", 8, L"[\xff61g\xff62h  ]");
+  CHECK (L"[%-6.5s]", 8, L"[\xff61g\xff62h\xff63 ]");
+  CHECK (L"[%-6.6s]", 8, L"[\xff61g\xff62h\xff63i]");
+  CHECK (L"[%-6.7s]", 9, L"[\xff61g\xff62h\xff63i\xff64]");
+  CHECK (L"[%-6.8s]", 10, L"[\xff61g\xff62h\xff63i\xff64j]");
+
+  return result;
+}
Index: trunk/src/libctests/glibc/stdio-common/tst-tmpnam.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-tmpnam.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-tmpnam.c	(revision 2036)
@@ -0,0 +1,51 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main (void)
+{
+  const char *name;
+  int retval = 0;
+
+  /* Set TMPDIR to a value other than the traditional /tmp.  */
+  setenv ("TMPDIR", "/usr", 1);
+
+  name = tmpnam (NULL);
+
+  printf ("name = %s\n", name);
+
+  /* Make sure the name is not based on the value in TMPDIR.  */
+  if (strncmp (name, "/usr", 4) == 0)
+    {
+      puts ("error: `tmpnam' used TMPDIR value");
+      retval = 1;
+    }
+
+  /* Test that it is in the directory denoted by P_tmpdir.  */
+  if (strncmp (name, P_tmpdir, sizeof (P_tmpdir) - 1) != 0)
+    {
+      puts ("error: `tmpnam' return value not in P_tmpdir directory");
+      retval = 1;
+    }
+
+  return retval;
+}
Index: trunk/src/libctests/glibc/stdio-common/tst-unbputc.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-unbputc.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-unbputc.c	(revision 2036)
@@ -0,0 +1,11 @@
+#include <stdio.h>
+
+
+int
+main (void)
+{
+  putc ('1', stderr);
+  putc ('2', stderr);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/stdio-common/tst-unbputc.sh
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-unbputc.sh	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-unbputc.sh	(revision 2036)
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Testing the stdio implementation
+# Copyright (C) 2000 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+common_objpfx=$1; shift
+run_program_prefix=$1; shift
+
+status=0
+
+${run_program_prefix} \
+  ${common_objpfx}stdio-common/tst-unbputc \
+    2> ${common_objpfx}stdio-common/tst-unbputc.out || status=1
+
+(echo -n 12 | cmp ${common_objpfx}stdio-common/tst-unbputc.out -) || status=1
+
+exit $status
Index: trunk/src/libctests/glibc/stdio-common/tst-ungetc.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-ungetc.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-ungetc.c	(revision 2036)
@@ -0,0 +1,63 @@
+/* Test for ungetc bugs.  */
+
+#include <stdio.h>
+#include <unistd.h>
+
+#undef assert
+#define assert(x) \
+  if (!(x)) \
+    { \
+      fputs ("test failed: " #x "\n", stderr); \
+      retval = 1; \
+      goto the_end; \
+    }
+
+int
+main (int argc, char *argv[])
+{
+  char *name;
+  FILE *fp = NULL;
+  int retval = 0;
+  int c;
+  char buffer[64];
+
+  name = tmpnam (NULL);
+  fp = fopen (name, "w");
+  assert (fp != NULL)
+  fputs ("bla", fp);
+  fclose (fp);
+  fp = NULL;
+
+  fp = fopen (name, "r");
+  assert (fp != NULL);
+  assert (ungetc ('z', fp) == 'z');
+  assert (getc (fp) == 'z');
+  assert (getc (fp) == 'b');
+  assert (getc (fp) == 'l');
+  assert (ungetc ('m', fp) == 'm');
+  assert (getc (fp) == 'm');
+  assert ((c = getc (fp)) == 'a');
+  assert (getc (fp) == EOF);
+  assert (ungetc (c, fp) == c);
+  assert (feof (fp) == 0);
+  assert (getc (fp) == c);
+  assert (getc (fp) == EOF);
+  fclose (fp);
+  fp = NULL;
+
+  fp = fopen (name, "r");
+  assert (fp != NULL);
+  assert (getc (fp) == 'b');
+  assert (getc (fp) == 'l');
+  assert (ungetc ('b', fp) == 'b');
+  assert (fread (buffer, 1, 64, fp) == 2);
+  assert (buffer[0] == 'b');
+  assert (buffer[1] == 'a');
+
+the_end:
+  if (fp != NULL)
+    fclose (fp);
+  unlink (name);
+
+  return retval;
+}
Index: trunk/src/libctests/glibc/stdio-common/tst-unlockedio.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-unlockedio.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-unlockedio.c	(revision 2036)
@@ -0,0 +1,157 @@
+/* Test for some *_unlocked stdio interfaces.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+int fd;
+static void do_prepare (void);
+static int do_test (void);
+#define PREPARE(argc, argv) do_prepare ()
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
+
+static int
+do_test (void)
+{
+  const char blah[] = "BLAH";
+  char buf[strlen (blah) + 1];
+  FILE *fp, *f;
+  const char *cp;
+  char *wp;
+
+  if ((fp = fdopen (fd, "w+")) == NULL)
+    exit (1);
+
+  flockfile (fp);
+
+  f = fp;
+  cp = blah;
+  if (ftello (fp) != 0
+      || fwrite_unlocked (blah, blah - blah, strlen (blah), f++) != 0
+      || f != fp + 1
+      || fwrite_unlocked ("", 5.0, 0, --f) != 0
+      || f != fp
+      || fwrite_unlocked (cp++, 16, 0.25, fp) != 0
+      || cp != blah + 1
+      || fwrite_unlocked (--cp, 0.25, 16, fp) != 0
+      || cp != blah
+      || fwrite_unlocked (blah, 0, -0.0, fp) != 0
+      || ftello (fp) != 0)
+    {
+      puts ("One of fwrite_unlocked tests failed");
+      exit (1);
+    }
+
+  if (fwrite_unlocked (blah, 1, strlen (blah) - 2, fp) != strlen (blah) - 2)
+    {
+      puts ("Could not write string into file");
+      exit (1);
+    }
+
+  if (putc_unlocked ('A' + 0x1000000, fp) != 'A')
+    {
+      puts ("putc_unlocked failed");
+      exit (1);
+    }
+
+  f = fp;
+  cp = blah + strlen (blah) - 1;
+  if (putc_unlocked (*cp++, f++) != 'H'
+      || f != fp + 1
+      || cp != strchr (blah, '\0'))
+    {
+      puts ("fputc_unlocked failed");
+      exit (1);
+    }
+
+  if (ftello (fp) != (off_t) strlen (blah))
+    {
+      printf ("Failed to write %zd bytes to temporary file", strlen (blah));
+      exit (1);
+    }
+
+  rewind (fp);
+
+  f = fp;
+  wp = buf;
+  memset (buf, ' ', sizeof (buf));
+  if (ftello (fp) != 0
+      || fread_unlocked (buf, buf - buf, strlen (blah), f++) != 0
+      || f != fp + 1
+      || fread_unlocked (buf, 5.0, 0, --f) != 0
+      || f != fp
+      || fread_unlocked (wp++, 16, 0.25, fp) != 0
+      || wp != buf + 1
+      || fread_unlocked (--wp, 0.25, 16, fp) != 0
+      || wp != buf
+      || fread_unlocked (buf, 0, -0.0, fp) != 0
+      || ftello (fp) != 0
+      || memcmp (buf, "     ", sizeof (buf)) != 0)
+    {
+      puts ("One of fread_unlocked tests failed");
+      exit (1);
+    }
+
+  if (fread_unlocked (buf, 1, strlen (blah) - 2, fp) != strlen (blah) - 2)
+    {
+      puts ("Could not read string from file");
+      exit (1);
+    }
+
+  if (getc_unlocked (fp) != 'A')
+    {
+      puts ("getc_unlocked failed");
+      exit (1);
+    }
+
+  f = fp;
+  if (fgetc_unlocked (f++) != 'H'
+      || f != fp + 1
+      || fgetc_unlocked (--f) != EOF
+      || f != fp)
+    {
+      puts ("fgetc_unlocked failed");
+      exit (1);
+    }
+
+  if (ftello (fp) != (off_t) strlen (blah))
+    {
+      printf ("Failed to read %zd bytes from temporary file", strlen (blah));
+      exit (1);
+    }
+
+  funlockfile (fp);
+  fclose (fp);
+
+  return 0;
+}
+
+static void
+do_prepare (void)
+{
+  fd = create_temp_file ("tst-unlockedio.", NULL);
+  if (fd == -1)
+    {
+      printf ("cannot create temporary file: %m\n");
+      exit (1);
+    }
+}
Index: trunk/src/libctests/glibc/stdio-common/tst-wc-printf.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tst-wc-printf.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tst-wc-printf.c	(revision 2036)
@@ -0,0 +1,22 @@
+#define _GNU_SOURCE 1
+#include <wchar.h>
+#include <stdio.h>
+#include <string.h>
+#include <wctype.h>
+
+int
+main (void)
+{
+  wchar_t tmp[3];
+  tmp[0] = '8';
+  tmp[1] = '1';
+  tmp[2] = 0;
+
+  printf ("Test for wide character output with printf\n");
+
+  printf ("with %%S: %S\n", tmp);
+
+  printf ("with %%C: %C\n", (wint_t) tmp[0]);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/stdio-common/tstdiomisc.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tstdiomisc.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tstdiomisc.c	(revision 2036)
@@ -0,0 +1,91 @@
+#include <float.h>
+#include <math.h>
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+
+static int
+t1 (void)
+{
+  int n = -1;
+  sscanf ("abc  ", "abc %n", &n);
+  printf ("t1: count=%d\n", n);
+
+  return n != 5;
+}
+
+static int
+t2 (void)
+{
+  int result = 0;
+  int n;
+  long N;
+  int retval;
+#define SCAN(INPUT, FORMAT, VAR, EXP_RES, EXP_VAL) \
+  VAR = -1; \
+  retval = sscanf (INPUT, FORMAT, &VAR); \
+  printf ("sscanf (\"%s\", \"%s\", &x) => %d, x = %ld\n", \
+	  INPUT, FORMAT, retval, (long int) VAR); \
+  result |= retval != EXP_RES || VAR != EXP_VAL
+
+  SCAN ("12345", "%ld", N, 1, 12345);
+  SCAN ("12345", "%llllld", N, 0, -1);
+  SCAN ("12345", "%LLLLLd", N, 0, -1);
+  SCAN ("test ", "%*s%n",  n, 0, 4);
+  SCAN ("test ", "%2*s%n",  n, 0, -1);
+  SCAN ("12 ",   "%l2d",  n, 0, -1);
+  SCAN ("12 ",   "%2ld",  N, 1, 12);
+
+  n = -1;
+  N = -1;
+  retval = sscanf ("1 1", "%d %Z", &n, &N);
+  printf ("sscanf (\"1 1\", \"%%d %%Z\", &n, &N) => %d, n = %d, N = %ld\n", \
+	  retval, n, N); \
+  result |= retval != 1 || n != 1 || N != -1;
+
+  return result;
+}
+
+static int
+F (void)
+{
+  char buf[20];
+  wchar_t wbuf[10];
+  int result;
+
+  snprintf (buf, sizeof buf, "%f %F", DBL_MAX * DBL_MAX - DBL_MAX * DBL_MAX,
+	    DBL_MAX * DBL_MAX - DBL_MAX * DBL_MAX);
+  result = strcmp (buf, "nan NAN") != 0;
+  printf ("expected \"nan NAN\", got \"%s\"\n", buf);
+
+  snprintf (buf, sizeof buf, "%f %F", DBL_MAX * DBL_MAX, DBL_MAX * DBL_MAX);
+  result |= strcmp (buf, "inf INF") != 0;
+  printf ("expected \"inf INF\", got \"%s\"\n", buf);
+
+  swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), L"%f %F",
+	    DBL_MAX * DBL_MAX - DBL_MAX * DBL_MAX,
+	    DBL_MAX * DBL_MAX - DBL_MAX * DBL_MAX);
+  result |= wcscmp (wbuf, L"nan NAN") != 0;
+  printf ("expected L\"nan NAN\", got L\"%S\"\n", wbuf);
+
+  swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), L"%f %F",
+	    DBL_MAX * DBL_MAX, DBL_MAX * DBL_MAX);
+  result |= wcscmp (wbuf, L"inf INF") != 0;
+  printf ("expected L\"inf INF\", got L\"%S\"\n", wbuf);
+
+  return result;
+}
+
+int
+main (int argc, char *argv[])
+{
+  int result = 0;
+
+  result |= t1 ();
+  result |= t2 ();
+  result |= F ();
+
+  result |= fflush (stdout) == EOF;
+
+  return result;
+}
Index: trunk/src/libctests/glibc/stdio-common/tstgetln.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tstgetln.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tstgetln.c	(revision 2036)
@@ -0,0 +1,48 @@
+/* Copyright (C) 1992, 1995, 1996, 1997, 1998, 2004
+   Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#undef ssize_t
+#define ssize_t _IO_ssize_t
+
+int
+main (int argc, char *argv[])
+{
+  char *buf = NULL;
+  size_t size = 0;
+  ssize_t len;
+
+  while ((len = getline (&buf, &size, stdin)) != -1)
+    {
+      printf ("bufsize %Zu; read %Zd: ", size, len);
+      if (fwrite (buf, len, 1, stdout) != 1)
+	{
+	  perror ("fwrite");
+	  return 1;
+	}
+    }
+
+  if (ferror (stdin))
+    {
+      perror ("getline");
+      return 1;
+    }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/stdio-common/tstgetln.input
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tstgetln.input	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tstgetln.input	(revision 2036)
@@ -0,0 +1,3 @@
+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
+z
Index: trunk/src/libctests/glibc/stdio-common/tstscanf.c
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tstscanf.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tstscanf.c	(revision 2036)
@@ -0,0 +1,356 @@
+/* Copyright (C) 1991,92,96,97,98,99,2000,2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifdef	BSD
+#include </usr/include/stdio.h>
+#else
+#include <stdio.h>
+#endif
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+int
+main (int argc, char **argv)
+{
+  char buf[BUFSIZ];
+  FILE *in = stdin, *out = stdout;
+  int x;
+  int result = 0;
+
+  if (sscanf ("0", "%d", &x) != 1)
+    {
+      fputs ("test failed!\n", stdout);
+      result = 1;
+    }
+
+  if (sscanf ("08905x", "%9[0-9]", buf) != 1
+      || strcmp (buf, "08905") != 0)
+    {
+      fputs ("test failed!\n", stdout);
+      result = 1;
+    }
+
+  if (sscanf ("", "%10[a-z]", buf) != EOF)
+    {
+      fputs ("test failed!\n", stdout);
+      result = 1;
+    }
+
+  sscanf ("conversion] Zero flag Ze]ro#\n", "%*[^]] %[^#]\n", buf);
+  if (strcmp (buf, "] Zero flag Ze]ro") != 0)
+    {
+      fputs ("test failed!\n", stdout);
+      result = 1;
+    }
+
+  if (argc == 2 && !strcmp (argv[1], "-opipe"))
+    {
+      out = popen ("/bin/cat", "w");
+      if (out == NULL)
+	{
+	  perror ("popen: /bin/cat");
+	  result = 1;
+	}
+    }
+  else if (argc == 3 && !strcmp (argv[1], "-ipipe"))
+    {
+      sprintf (buf, "/bin/cat %s", argv[2]);
+      in = popen (buf, "r");
+      if (in == NULL)
+	{
+	  perror ("popen: /bin/cat");
+	  result = 1;
+	}
+    }
+
+  {
+    char name[50];
+    fprintf (out,
+	     "sscanf (\"thompson\", \"%%s\", name) == %d, name == \"%s\"\n",
+	     sscanf ("thompson", "%s", name),
+	     name);
+    if (strcmp (name, "thompson") != 0)
+      {
+	fputs ("test failed!\n", stdout);
+	result = 1;
+      }
+  }
+
+  fputs ("Testing scanf (vfscanf)\n", out);
+
+  fputs ("Test 1:\n", out);
+  {
+    int n, i;
+    float x;
+    char name[50];
+    n = fscanf (in, "%d%f%s", &i, &x, name);
+    fprintf (out, "n = %d, i = %d, x = %f, name = \"%.50s\"\n",
+	     n, i, x, name);
+    if (n != 3 || i != 25 || x != 5.432F || strcmp (name, "thompson"))
+      {
+	fputs ("test failed!\n", stdout);
+	result = 1;
+      }
+  }
+  fprintf (out, "Residual: \"%s\"\n", fgets (buf, sizeof (buf), in));
+  if (strcmp (buf, "\n"))
+    {
+      fputs ("test failed!\n", stdout);
+      result = 1;
+    }
+  fputs ("Test 2:\n", out);
+  {
+    int i;
+    float x;
+    char name[50];
+    (void) fscanf (in, "%2d%f%*d %[0123456789]", &i, &x, name);
+    fprintf (out, "i = %d, x = %f, name = \"%.50s\"\n", i, x, name);
+    if (i != 56 || x != 789.0F || strcmp (name, "56"))
+      {
+	fputs ("test failed!\n", stdout);
+	result = 1;
+      }
+  }
+  fprintf (out, "Residual: \"%s\"\n", fgets (buf, sizeof (buf), in));
+  if (strcmp (buf, "a72\n"))
+    {
+      fputs ("test failed!\n", stdout);
+      result = 1;
+    }
+  fputs ("Test 3:\n", out);
+  {
+    static struct {
+      int count;
+      float quant;
+      const char *units;
+      const char *item;
+    } ok[] = {
+      { 3, 2.0F, "quarts", "oil" },
+      { 2, -12.8F, "degrees", "" },
+      { 0, 0.0F, "", "" },
+      { 3, 10.0F, "LBS", "fertilizer" },
+      { 3, 100.0F, "rgs", "energy" },
+      { -1, 0.0F, "", "" }};
+    size_t rounds = 0;
+    float quant;
+    char units[21], item[21];
+    while (!feof (in) && !ferror (in))
+      {
+	int count;
+
+	if (rounds++ >= sizeof (ok) / sizeof (ok[0]))
+	  {
+	    fputs ("test failed!\n", stdout);
+	    result = 1;
+	  }
+
+	quant = 0.0;
+	units[0] = item[0] = '\0';
+	count = fscanf (in, "%f%20s of %20s", &quant, units, item);
+	(void) fscanf (in, "%*[^\n]");
+	fprintf (out, "count = %d, quant = %f, item = %.21s, units = %.21s\n",
+		 count, quant, item, units);
+	if (count != ok[rounds-1].count || quant != ok[rounds-1].quant
+	    || strcmp (item, ok[rounds-1].item)
+	    || strcmp (units, ok[rounds-1].units))
+	  {
+	    fputs ("test failed!\n", stdout);
+	    result = 1;
+	  }
+      }
+  }
+  buf[0] = '\0';
+  fprintf (out, "Residual: \"%s\"\n", fgets (buf, sizeof (buf), in));
+  if (strcmp (buf, ""))
+    {
+      fputs ("test failed!\n", stdout);
+      result = 1;
+    }
+
+  if (out != stdout)
+    pclose (out);
+
+  fputs ("Test 4:\n", out);
+  {
+    int res, val, n;
+
+    res = sscanf ("-242", "%3o%n", &val, &n);
+    printf ("res = %d, val = %d, n = %d\n", res, val, n);
+    if (res != 1 || val != -20 || n != 3)
+      {
+	fputs ("test failed!\n", stdout);
+	result = 1;
+      }
+  }
+
+  fputs ("Test 5:\n", out);
+  {
+    double a = 0, b = 0;
+    int res, n;
+
+    res = sscanf ("1234567", "%3lg%3lg%n", &a, &b, &n);
+    printf ("res = %d, a = %g, b = %g, n = %d\n", res, a, b, n);
+
+    if (res != 2 || a != 123 || b != 456 || n != 6)
+      {
+	fputs ("test failed!\n", stdout);
+	result = 1;
+      }
+
+    res = sscanf ("0", "%lg", &a);
+    printf ("res = %d, a = %g\n", res, a);
+
+    if (res != 1 || a != 0)
+      {
+	fputs ("test failed!\n", stdout);
+	result = 1;
+      }
+
+    res = sscanf ("1e3", "%lg%n", &a, &n);
+    printf ("res = %d, a = %g, n = %d\n", res, a, n);
+
+    if (res != 1 || a != 1000 || n != 3)
+      {
+	fputs ("test failed!\n", stdout);
+	result = 1;
+      }
+  }
+
+  fputs ("Test 6:\n", stdout);
+  {
+    char *p = (char *) -1;
+    int res;
+
+    sprintf (buf, "%p", NULL);
+    res = sscanf (buf, "%p", &p);
+    printf ("sscanf (\"%s\", \"%%p\", &p) = %d, p == %p\n", buf, res, p);
+
+    if (res != 1 || p != NULL)
+      {
+	fputs ("test failed!\n", stdout);
+	result = 1;
+      }
+  }
+
+  fputs ("Test 7:\n", stdout);
+  {
+    short a[2] = { -1, -1 };
+    int res;
+
+    res = sscanf ("32767 1234", "%hd %hd", &a[0], &a[1]);
+    printf ("res = %d, a[0] = %d, a[1] = %d\n", res, a[0], a[1]);
+
+    if (res != 2 || a[0] != 32767 || a[1] != 1234)
+      {
+	fputs ("test failed!\n", stdout);
+	result = 1;
+      }
+  }
+
+  fputs ("Test 8:\n", stdout);
+  {
+    double d = 123456.789;
+    int res;
+
+    res = sscanf ("0x1234", "%lf", &d);
+    printf ("res = %d, d = %f\n", res, d);
+
+    if (res != 0 || d != 123456.789)
+      {
+	fputs ("test failed!\n", stdout);
+	result = 1;
+      }
+  }
+
+  fputs ("Test 9:\n", stdout);
+  {
+    /* From PR libc/1313 reported by Ben Caradoc-Davies <bmcd@physics.otago.ac.nz>.  */
+    float value;
+    int res;
+
+    res = sscanf ("0123", "%2f", &value);
+    if (res != 1 || value != 1.0)
+      {
+	fputs ("test failed!\n", stdout);
+	result = 1;
+      }
+  }
+
+  fputs ("Test 10:\n", stdout);
+  {
+    float value;
+    int res;
+
+    res = sscanf ("--", "%f", &value);
+    if (res != 0)
+      {
+	fputs ("test failed!\n", stdout);
+	result = 1;
+      }
+  }
+
+  fputs ("Test 11:\n", stdout);
+  {
+    char uart[50];
+    int res;
+
+    res = sscanf ("uart:16550A tx:0", "uart:%31s tx:%*u", uart);
+    if (res != 1)
+      {
+	fputs ("test failed!\n", stdout);
+	result = 1;
+      }
+  }
+
+  fputs ("Test 12:\n", stdout);
+  {
+    char uart[50];
+    int res;
+
+    res = sscanf ("uart:16550A", "uart:%31s tx:%*u", uart);
+    if (res != 1)
+      {
+	fputs ("test failed!\n", stdout);
+	result = 1;
+      }
+  }
+
+  fputs ("Test 13:\n", stdout);
+  {
+    float value;
+    int res;
+
+    res = sscanf ("-InF", "%f", &value);
+    if (res != 1 || isinf (value) != -1)
+      {
+	fputs ("test failed!\n", stdout);
+	result = 1;
+      }
+
+    res = sscanf ("+InfiNiTY", "%f", &value);
+    if (res != 1 || isinf (value) != 1)
+      {
+	fputs ("test failed!\n", stdout);
+	result = 1;
+      }
+  }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/stdio-common/tstscanf.input
===================================================================
--- trunk/src/libctests/glibc/stdio-common/tstscanf.input	(revision 2036)
+++ trunk/src/libctests/glibc/stdio-common/tstscanf.input	(revision 2036)
@@ -0,0 +1,7 @@
+25 54.32E-1 thompson
+56789 0123 56a72
+2 quarts of oil
+-12.8degrees Celsius
+lots of luck
+10.0LBS      of       fertilizer
+100ergs of energy
Index: trunk/src/libctests/glibc/stdlib/Makefile
===================================================================
--- trunk/src/libctests/glibc/stdlib/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/Makefile	(revision 2036)
@@ -0,0 +1,140 @@
+# Copyright (C) 1991-2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Makefile for stdlib routines
+#
+subdir	:= stdlib
+
+headers	:= stdlib.h alloca.h monetary.h fmtmsg.h ucontext.h sys/ucontext.h    \
+	   inttypes.h stdint.h bits/wordsize.h bits/wchar.h		      \
+	   errno.h sys/errno.h bits/errno.h
+
+routines	:=							      \
+	atof atoi atol atoll						      \
+	abort								      \
+	bsearch qsort msort						      \
+	getenv putenv setenv secure-getenv				      \
+	exit on_exit atexit cxa_atexit cxa_finalize old_atexit		      \
+	abs labs llabs							      \
+	div ldiv lldiv							      \
+	mblen mbstowcs mbtowc wcstombs wctomb				      \
+	random random_r rand rand_r					      \
+	drand48 erand48 lrand48 nrand48 mrand48 jrand48			      \
+	srand48 seed48 lcong48						      \
+	drand48_r erand48_r lrand48_r nrand48_r mrand48_r jrand48_r	      \
+	srand48_r seed48_r lcong48_r					      \
+	drand48-iter							      \
+	strtol strtoul strtoll strtoull					      \
+	strtol_l strtoul_l strtoll_l strtoull_l				      \
+	strtof strtod strtold						      \
+	strtof_l strtod_l strtold_l					      \
+	system canonicalize						      \
+	a64l l64a							      \
+	rpmatch strfmon strfmon_l getsubopt xpg_basename fmtmsg		      \
+	strtoimax strtoumax wcstoimax wcstoumax				      \
+	getcontext setcontext makecontext swapcontext
+aux =	grouping groupingwc
+
+# These routines will be omitted from the libc shared object.
+# Instead the static object files will be included in a special archive
+# linked against when the shared library will be used.
+static-only-routines = atexit
+
+distribute	:= exit.h grouping.h abort-instr.h isomac.c tst-fmtmsg.sh   \
+		   allocalim.h
+test-srcs	:= tst-fmtmsg
+tests		:= tst-strtol tst-strtod testmb testrand testsort testdiv   \
+		   test-canon test-canon2 tst-strtoll tst-environ	    \
+		   tst-xpg-basename tst-random tst-random2 tst-bsearch	    \
+		   tst-limits tst-rand48 bug-strtod tst-setcontext	    \
+		   test-a64l tst-qsort tst-system testmb2
+
+include ../Makeconfig
+
+ifeq ($(build-shared),yes)
+tests		+= tst-putenv
+endif
+
+# Several mpn functions from GNU MP are used by the strtod function.
+mpn-routines := inlines add_n addmul_1 cmp divmod_1 divrem udiv_qrnnd \
+		lshift rshift mod_1 mul mul_1 mul_n sub_n submul_1
+mpn-headers = longlong.h gmp.h gmp-impl.h gmp-mparam.h asm-syntax.h
+
+routines := $(strip $(routines) $(mpn-routines))	\
+	    dbl2mpn ldbl2mpn				\
+	    mpn2flt mpn2dbl mpn2ldbl
+aux += fpioconst mp_clz_tab
+distribute := $(distribute) $(mpn-headers) gen-mpn-copy fpioconst.h \
+	      tst-putenvmod.c
+
+tests-extras += tst-putenvmod
+extra-objs += tst-putenvmod.os
+
+generated += isomac isomac.out tst-putenvmod.so
+
+CFLAGS-bsearch.c = $(uses-callbacks)
+CFLAGS-msort.c = $(uses-callbacks)
+CFLAGS-qsort.c = $(uses-callbacks)
+CFLAGS-system.c = -fexceptions
+CFLAGS-system.os = -fomit-frame-pointer
+CFLAGS-fmtmsg.c = -fexceptions
+
+ifneq (,$(filter %REENTRANT, $(defines)))
+CFLAGS-strfmon.c = -D_IO_MTSAFE_IO
+CFLAGS-strfmon_l.c = -D_IO_MTSAFE_IO
+endif
+
+ifeq (yes,$(have-protected))
+CFLAGS-atexit.c = -DHAVE_DOT_HIDDEN
+endif
+
+CFLAGS-tst-bsearch.c = $(stack-align-test-flags)
+CFLAGS-tst-qsort.c = $(stack-align-test-flags)
+
+include ../Rules
+
+# Testdir has to be named stdlib and needs to be writable
+test-canon-ARGS = --test-dir=${common-objpfx}stdlib
+
+tst-strtod-ENV = LOCPATH=$(common-objpfx)localedata
+testmb2-ENV = LOCPATH=$(common-objpfx)localedata
+
+# Run a test on the header files we use.
+tests: $(objpfx)isomac.out
+
+ifeq (no,$(cross-compiling))
+tests: $(objpfx)tst-fmtmsg.out
+endif
+
+$(objpfx)isomac.out: $(objpfx)isomac
+	$(dir $<)$(notdir $<) '$(CC)'  \
+	'-I../include -I.. $(+sysdep-includes) $(sysincludes)' > $<.out
+
+isomac-CFLAGS = -O
+$(objpfx)isomac: isomac.c
+	$(native-compile)
+
+$(objpfx)tst-fmtmsg.out: tst-fmtmsg.sh $(objpfx)tst-fmtmsg
+	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' $(common-objpfx)stdlib/
+
+$(objpfx)tst-putenv: $(objpfx)tst-putenvmod.so
+
+$(objpfx)tst-putenvmod.so: $(objpfx)tst-putenvmod.os
+	$(build-module)
+CFLAGS-tst-putenvmod.c = -DNOT_IN_libc=1
Index: trunk/src/libctests/glibc/stdlib/bug-strtod.c
===================================================================
--- trunk/src/libctests/glibc/stdlib/bug-strtod.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/bug-strtod.c	(revision 2036)
@@ -0,0 +1,94 @@
+/* Test to strtod etc for numbers like x000...0000.000e-nn.
+   This file is part of the GNU C Library.
+   Copyright (C) 2001 Free Software Foundation, Inc.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+int
+main (void)
+{
+  char buf[300];
+  int cnt;
+  int result = 0;
+
+  for (cnt = 0; cnt < 200; ++cnt)
+    {
+      ssize_t n;
+      float f;
+
+      n = sprintf (buf, "%d", cnt);
+      memset (buf + n, '0', cnt);
+      sprintf (buf + n + cnt, ".000e-%d", cnt);
+      f = strtof (buf, NULL);
+
+      if (f != (float) cnt)
+	{
+	  printf ("strtof(\"%s\") failed for cnt == %d (%g instead of %g)\n",
+		  buf, cnt, f, (float) cnt);
+	  result = 1;
+	}
+      else
+	printf ("strtof() fine for cnt == %d\n", cnt);
+    }
+
+  for (cnt = 0; cnt < 200; ++cnt)
+    {
+      ssize_t n;
+      double f;
+
+      n = sprintf (buf, "%d", cnt);
+      memset (buf + n, '0', cnt);
+      sprintf (buf + n + cnt, ".000e-%d", cnt);
+      f = strtod (buf, NULL);
+
+      if (f != (double) cnt)
+	{
+	  printf ("strtod(\"%s\") failed for cnt == %d (%g instead of %g)\n",
+		  buf, cnt, f, (double) cnt);
+	  result = 1;
+	}
+      else
+	printf ("strtod() fine for cnt == %d\n", cnt);
+    }
+
+  for (cnt = 0; cnt < 200; ++cnt)
+    {
+      ssize_t n;
+      long double f;
+
+      n = sprintf (buf, "%d", cnt);
+      memset (buf + n, '0', cnt);
+      sprintf (buf + n + cnt, ".000e-%d", cnt);
+      f = strtold (buf, NULL);
+
+      if (f != (long double) cnt)
+	{
+	  printf ("strtold(\"%s\") failed for cnt == %d (%Lg instead of %Lg)\n",
+		  buf, cnt, f, (long double) cnt);
+	  result = 1;
+	}
+      else
+	printf ("strtold() fine for cnt == %d\n", cnt);
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/stdlib/test-a64l.c
===================================================================
--- trunk/src/libctests/glibc/stdlib/test-a64l.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/test-a64l.c	(revision 2036)
@@ -0,0 +1,81 @@
+/* Test program for the l64a and a64l functions.
+   Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Schwab <schwab@suse.de>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* Prototype for our test function.  */
+extern int do_test (int argc, char *argv[]);
+#include <test-skeleton.c>
+
+struct a64l_test
+{
+  const char *base64;
+  long int value;
+};
+
+static const struct a64l_test tests[] =
+  {
+    { "./", 64 },
+    { "", 0 },
+    { "/", 1 },
+    { "FT", 2001 },
+    { "zzzzz1", 0xffffffff },
+    { "zzzz1", 0x3ffffff },
+    { "zzz1", 0xfffff },
+    { "zz1", 0x3fff },
+    { "z1", 0xff },
+    { "1", 0x3 },
+    { NULL, 0 }
+  };
+
+int
+do_test (int argc, char ** argv)
+{
+  const struct a64l_test *at;
+  long int l;
+  const char *s;
+  int status = 0;
+
+  for (at = tests; at->base64 != NULL; ++at)
+    {
+      printf ("a64l (\"%s\")", at->base64);
+      l = a64l (at->base64);
+      if (l == at->value)
+	puts ("\tOK");
+      else
+	{
+	  printf ("\tBAD\n  returns %ld, expected %ld\n", l, at->value);
+	  status = 1;
+	}
+      printf ("l64a (%ld)", at->value);
+      s = l64a (at->value);
+      if (strcmp (s, at->base64) == 0)
+	puts ("\tOK");
+      else
+	{
+	  printf ("\tBAD\n  returns \"%s\", expected \"%s\"\n", s, at->base64);
+	  status = 1;
+	}
+    }
+
+  return status ? EXIT_FAILURE : EXIT_SUCCESS;
+}
Index: trunk/src/libctests/glibc/stdlib/test-canon.c
===================================================================
--- trunk/src/libctests/glibc/stdlib/test-canon.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/test-canon.c	(revision 2036)
@@ -0,0 +1,232 @@
+/* Test program for returning the canonical absolute name of a given file.
+   Copyright (C) 1996,1997,2000,2002,2004,2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by David Mosberger <davidm@azstarnet.com>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* This file must be run from within a directory called "stdlib".  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/param.h>
+
+/* Prototype for our test function.  */
+extern int do_test (int argc, char *argv[]);
+#include <test-skeleton.c>
+
+#ifndef PATH_MAX
+# define PATH_MAX 4096
+#endif
+static char	cwd[PATH_MAX];
+static size_t	cwd_len;
+
+struct {
+  const char *	name;
+  const char *	value;
+} symlinks[] = {
+  {"SYMLINK_LOOP",	"SYMLINK_LOOP"},
+  {"SYMLINK_1",		"."},
+  {"SYMLINK_2",		"//////./../../etc"},
+  {"SYMLINK_3",		"SYMLINK_1"},
+  {"SYMLINK_4",		"SYMLINK_2"},
+  {"SYMLINK_5",		"doesNotExist"},
+};
+
+struct {
+  const char * in, * out, * resolved;
+  int error;
+} tests[] = {
+  /*  0 */
+  {"/",					"/"},
+  {"/////////////////////////////////",	"/"},
+  {"/.././.././.././..///",		"/"},
+  {"/etc",				"/etc"},
+  {"/etc/../etc",			"/etc"},
+  /*  5 */
+  {"/doesNotExist/../etc",		0, "/doesNotExist", ENOENT},
+  {"./././././././././.",		"."},
+  {"/etc/.//doesNotExist",		0, "/etc/doesNotExist", ENOENT},
+  {"./doesExist",			"./doesExist"},
+  {"./doesExist/",			"./doesExist"},
+  /* 10 */
+  {"./doesExist/../doesExist",		"./doesExist"},
+  {"foobar",				0, "./foobar", ENOENT},
+  {".",					"."},
+  {"./foobar",				0, "./foobar", ENOENT},
+  {"SYMLINK_LOOP",			0, "./SYMLINK_LOOP", ELOOP},
+  /* 15 */
+  {"./SYMLINK_LOOP",			0, "./SYMLINK_LOOP", ELOOP},
+  {"SYMLINK_1",				"."},
+  {"SYMLINK_1/foobar",			0, "./foobar", ENOENT},
+  {"SYMLINK_2",				"/etc"},
+  {"SYMLINK_3",				"."},
+  /* 20 */
+  {"SYMLINK_4",				"/etc"},
+  {"../stdlib/SYMLINK_1",		"."},
+  {"../stdlib/SYMLINK_2",		"/etc"},
+  {"../stdlib/SYMLINK_3",		"."},
+  {"../stdlib/SYMLINK_4",		"/etc"},
+  /* 25 */
+  {"./SYMLINK_5",			0, "./doesNotExist", ENOENT},
+  {"SYMLINK_5",				0, "./doesNotExist", ENOENT},
+  {"SYMLINK_5/foobar",			0, "./doesNotExist", ENOENT},
+  {"doesExist/../../stdlib/doesExist",	"./doesExist"},
+  {"doesExist/.././../stdlib/.",	"."},
+  /* 30 */
+  {"./doesExist/someFile/",		0, "./doesExist/someFile", ENOTDIR},
+  {"./doesExist/someFile/..",		0, "./doesExist/someFile", ENOTDIR},
+};
+
+
+static int
+check_path (const char * result, const char * expected)
+{
+  int good;
+
+  if (!result)
+    return (expected == NULL);
+
+  if (!expected)
+    return 0;
+
+  if (expected[0] == '.' && (expected[1] == '/' || expected[1] == '\0'))
+    good = (strncmp (result, cwd, cwd_len) == 0
+	    && strcmp (result + cwd_len, expected + 1) == 0);
+  else
+    good = (strcmp (expected, result) == 0);
+
+  return good;
+}
+
+
+int
+do_test (int argc, char ** argv)
+{
+  char * result;
+  int i, errors = 0;
+  char buf[PATH_MAX];
+
+  getcwd (cwd, sizeof(buf));
+  cwd_len = strlen (cwd);
+
+  errno = 0;
+  if (realpath (NULL, buf) != NULL || errno != EINVAL)
+    {
+      printf ("%s: expected return value NULL and errno set to EINVAL"
+	      " for realpath(NULL,...)\n", argv[0]);
+      ++errors;
+    }
+
+#if 0
+  /* This is now allowed.  The test is invalid.  */
+  errno = 0;
+  if (realpath ("/", NULL) != NULL || errno != EINVAL)
+    {
+      printf ("%s: expected return value NULL and errno set to EINVAL"
+	      " for realpath(...,NULL)\n", argv[0]);
+      ++errors;
+    }
+#endif
+
+  errno = 0;
+  if (realpath ("", buf) != NULL || errno != ENOENT)
+    {
+      printf ("%s: expected return value NULL and set errno to ENOENT"
+	      " for realpath(\"\",...)\n", argv[0]);
+      ++errors;
+    }
+
+  for (i = 0; i < (int) (sizeof (symlinks) / sizeof (symlinks[0])); ++i)
+    symlink (symlinks[i].value, symlinks[i].name);
+
+  int has_dir = mkdir ("doesExist", 0777) == 0;
+
+  int fd = has_dir ? creat ("doesExist/someFile", 0777) : -1;
+
+  for (i = 0; i < (int) (sizeof (tests) / sizeof (tests[0])); ++i)
+    {
+      buf[0] = '\0';
+      result = realpath (tests[i].in, buf);
+
+      if (!check_path (result, tests[i].out))
+	{
+	  printf ("%s: flunked test %d (expected `%s', got `%s')\n",
+		  argv[0], i, tests[i].out ? tests[i].out : "NULL",
+		  result ? result : "NULL");
+	  ++errors;
+	  continue;
+	}
+
+      if (!check_path (buf, tests[i].out ? tests[i].out : tests[i].resolved))
+	{
+	  printf ("%s: flunked test %d (expected resolved `%s', got `%s')\n",
+		  argv[0], i, tests[i].out ? tests[i].out : tests[i].resolved,
+		  buf);
+	  ++errors;
+	  continue;
+	}
+
+      if (!tests[i].out && errno != tests[i].error)
+	{
+	  printf ("%s: flunked test %d (expected errno %d, got %d)\n",
+		  argv[0], i, tests[i].error, errno);
+	  ++errors;
+	  continue;
+	}
+
+      char *result2 = realpath (tests[i].in, NULL);
+      if ((result2 == NULL && result != NULL)
+	  || (result2 != NULL && strcmp (result, result2) != 0))
+	{
+	  printf ("\
+%s: realpath(..., NULL) produced different result than realpath(..., buf): '%s' vs '%s'\n",
+		  argv[0], result2, result);
+	  ++errors;
+	}
+      free (result2);
+    }
+
+  getcwd (buf, sizeof(buf));
+  if (strcmp (buf, cwd))
+    {
+      printf ("%s: current working directory changed from %s to %s\n",
+	      argv[0], cwd, buf);
+      ++errors;
+    }
+
+  if (fd >= 0)
+    unlink ("doesExist/someFile");
+
+  if (has_dir)
+    rmdir ("doesExist");
+
+  for (i = 0; i < (int) (sizeof (symlinks) / sizeof (symlinks[0])); ++i)
+    unlink (symlinks[i].name);
+
+  if (errors != 0)
+    {
+      printf ("%d errors.\n", errors);
+      return EXIT_FAILURE;
+    }
+
+  puts ("No errors.");
+  return EXIT_SUCCESS;
+}
Index: trunk/src/libctests/glibc/stdlib/test-canon2.c
===================================================================
--- trunk/src/libctests/glibc/stdlib/test-canon2.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/test-canon2.c	(revision 2036)
@@ -0,0 +1,75 @@
+/* Test for realpath/canonicalize function.
+   Copyright (C) 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <string.h>
+
+
+/* Prototype for our test function.  */
+extern void do_prepare (int argc, char *argv[]);
+extern int do_test (int argc, char *argv[]);
+
+/* We have a preparation function.  */
+#define PREPARE do_prepare
+
+#include <test-skeleton.c>
+
+/* Name of the temporary files we create.  */
+char *name1;
+char *name2;
+
+/* Preparation.  */
+void
+do_prepare (int argc, char *argv[])
+{
+  char test_dir_len;
+
+  test_dir_len = strlen (test_dir);
+
+  /* Generate the circular symlinks.  */
+  name1 = malloc (test_dir_len + sizeof ("/canonXXXXXX"));
+  mempcpy (mempcpy (name1, test_dir, test_dir_len),
+	   "/canonXXXXXX", sizeof ("/canonXXXXXX"));
+  name2 = strdup (name1);
+
+  add_temp_file (mktemp (name1));
+  add_temp_file (mktemp (name2));
+}
+
+
+/* Run the test.  */
+int
+do_test (int argc, char *argv[])
+{
+  char *canon;
+
+  printf ("create symlinks from %s to %s and vice versa\n", name1, name2);
+  if (symlink (name1, name2) == -1
+      || symlink (name2, name1) == -1)
+    /* We cannot test this.  */
+    return 0;
+
+  /* Call the function.  This is equivalent the using `realpath' but the
+     function allocates the room for the result.  */
+  errno = 0;
+  canon = canonicalize_file_name (name1);
+
+  return canon != NULL || errno != ELOOP;
+}
Index: trunk/src/libctests/glibc/stdlib/testdiv.c
===================================================================
--- trunk/src/libctests/glibc/stdlib/testdiv.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/testdiv.c	(revision 2036)
@@ -0,0 +1,40 @@
+/* Copyright (C) 1992, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+int
+main (void)
+{
+  int err = 0;
+  int i, j;
+  while (scanf ("%d %d\n", &i, &j) == 2)
+    {
+      div_t d = div (i, j);
+      printf ("%d / %d = %d + %d/%d", i, j, d.quot, d.rem, j);
+      if (i == d.quot * j + d.rem)
+	fputs ("  OK\n", stdout);
+      else
+	{
+	  fputs ("  FAILED\n", stdout);
+	  err = 1;
+	}
+    }
+  return err;
+}
Index: trunk/src/libctests/glibc/stdlib/testdiv.input
===================================================================
--- trunk/src/libctests/glibc/stdlib/testdiv.input	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/testdiv.input	(revision 2036)
@@ -0,0 +1,2 @@
+10 3
+-10 3
Index: trunk/src/libctests/glibc/stdlib/testmb.c
===================================================================
--- trunk/src/libctests/glibc/stdlib/testmb.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/testmb.c	(revision 2036)
@@ -0,0 +1,65 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main (int argc, char *argv[])
+{
+  wchar_t w[10];
+  char c[10];
+  int i;
+  int lose = 0;
+
+  i = mbstowcs (w, "bar", 4);
+  if (!(i == 3 && w[1] == 'a'))
+    {
+      puts ("mbstowcs FAILED!");
+      lose = 1;
+    }
+
+  mbstowcs (w, "blah", 5);
+  i = wcstombs (c, w, 10);
+  if (i != 4)
+    {
+      puts ("wcstombs FAILED!");
+      lose = 1;
+    }
+
+  if (mblen ("foobar", 7) != 1)
+    {
+      puts ("mblen 1 FAILED!");
+      lose = 1;
+    }
+
+  if (mblen ("", 1) != 0)
+    {
+      puts ("mblen 2 FAILED!");
+      lose = 1;
+    }
+
+  {
+    int r;
+    char c = 'x';
+    wchar_t wc;
+    char mbc[MB_CUR_MAX];
+
+    if ((r = mbtowc (&wc, &c, MB_CUR_MAX)) <= 0)
+      {
+	printf ("conversion to wide failed, result: %d\n", r);
+	lose = 1;
+      }
+    else
+      {
+	printf ("wide value: 0x%04lx\n", (unsigned long) wc);
+	mbc[0] = '\0';
+	if ((r = wctomb (mbc, wc)) <= 0)
+	  {
+	    printf ("conversion to multibyte failed, result: %d\n", r);
+	    lose = 1;
+	  }
+      }
+
+  }
+
+  puts (lose ? "Test FAILED!" : "Test succeeded.");
+  return lose;
+}
Index: trunk/src/libctests/glibc/stdlib/testmb2.c
===================================================================
--- trunk/src/libctests/glibc/stdlib/testmb2.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/testmb2.c	(revision 2036)
@@ -0,0 +1,31 @@
+/* Test case by Miloslav Trmac <mitr@volny.cz>.  */
+#include <locale.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+int
+main (void)
+{
+  wchar_t wc;
+
+  if (setlocale (LC_CTYPE, "de_DE.UTF-8") == NULL)
+    {
+      puts ("setlocale failed");
+      return 1;
+    }
+
+  if (mbtowc (&wc, "\xc3\xa1", MB_CUR_MAX) != 2 || wc != 0xE1)
+    {
+      puts ("1st mbtowc failed");
+      return 1;
+    }
+
+  if (mbtowc (&wc, "\xc3\xa1", SIZE_MAX) != 2 || wc != 0xE1)
+    {
+      puts ("2nd mbtowc failed");
+      return 1;
+    }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/stdlib/testrand.c
===================================================================
--- trunk/src/libctests/glibc/stdlib/testrand.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/testrand.c	(revision 2036)
@@ -0,0 +1,53 @@
+/* Copyright (C) 1992, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+int
+main (void)
+{
+  int i1, i2;
+  int j1, j2;
+
+  /* The C standard says that "If rand is called before any calls to
+     srand have been made, the same sequence shall be generated as
+     when srand is first called with a seed value of 1." */
+  i1 = rand();
+  i2 = rand();
+  srand (1);
+  j1 = rand();
+  j2 = rand();
+  if (i1 < 0 || i2 < 0 || j1 < 0 || j2 < 0) {
+      puts ("Test FAILED!");
+  }
+  if (j1 == i1 && j2 == i2)
+    {
+      puts ("Test succeeded.");
+      return 0;
+    }
+  else
+    {
+      if (j1 != i1)
+	printf ("%d != %d\n", j1, i1);
+      if (j2 != i2)
+	printf ("%d != %d\n", j2, i2);
+      puts ("Test FAILED!");
+      return 1;
+    }
+}
Index: trunk/src/libctests/glibc/stdlib/testsort.c
===================================================================
--- trunk/src/libctests/glibc/stdlib/testsort.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/testsort.c	(revision 2036)
@@ -0,0 +1,36 @@
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+static int
+compare (const void *a, const void *b)
+{
+  return strcmp (*(char **) a, *(char **) b);
+}
+
+int
+main (void)
+{
+  char bufs[500][20];
+  char *lines[500];
+  size_t lens[500];
+  size_t i, j;
+
+  srandom (1);
+
+  for (i = 0; i < 500; ++i)
+    {
+      lens[i] = random() % 19;
+      lines[i] = bufs[i];
+      for (j = 0; j < lens[i]; ++j)
+	lines[i][j] = random() % 26 + 'a';
+      lines[i][j] = '\0';
+    }
+
+  qsort (lines, 500, sizeof (char *), compare);
+
+  for (i = 0; i < 500 && lines[i] != NULL; ++i)
+    puts (lines[i]);
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/stdlib/tst-bsearch.c
===================================================================
--- trunk/src/libctests/glibc/stdlib/tst-bsearch.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/tst-bsearch.c	(revision 2036)
@@ -0,0 +1,151 @@
+/* Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <tst-stack-align.h>
+
+struct entry
+{
+  int val;
+  const char *str;
+} arr[] =
+{
+  { 0, "zero" },
+  { 1, "one" },
+  { 2, "two" },
+  { 3, "three" },
+  { 4, "four" },
+  { 5, "five" },
+  { 6, "six" },
+  { 7, "seven" },
+  { 8, "eight" },
+  { 9, "nine" },
+  { 10, "ten" }
+};
+#define narr (sizeof (arr) / sizeof (arr[0]))
+
+static int align_check;
+
+static int
+comp (const void *p1, const void *p2)
+{
+  struct entry *e1 = (struct entry *) p1;
+  struct entry *e2 = (struct entry *) p2;
+
+  if (!align_check)
+    align_check = TEST_STACK_ALIGN () ? -1 : 1;
+
+  return e1->val - e2->val;
+}
+
+
+int
+main (void)
+{
+  size_t cnt;
+  int result = 0;
+  struct entry key;
+  struct entry *res;
+
+  for (cnt = 0; cnt < narr; ++cnt)
+    {
+
+      key.val = arr[cnt].val;
+
+      res = (struct entry *) bsearch (&key, arr, narr, sizeof (arr[0]), comp);
+      if (res == NULL)
+	{
+	  printf ("entry %zd not found\n", cnt);
+	  result = 1;
+	}
+      else if (res != &arr[cnt])
+	{
+	  puts ("wrong entry returned");
+	  result = 1;
+	}
+    }
+
+  /* And some special tests that shouldn't find any entry.  */
+  key.val = -1;
+  res = (struct entry *) bsearch (&key, arr, narr, sizeof (arr[0]), comp);
+  if (res != NULL)
+    {
+      puts ("found an entry that's not there");
+      result = 1;
+    }
+
+  key.val = 11;
+  res = (struct entry *) bsearch (&key, arr, narr, sizeof (arr[0]), comp);
+  if (res != NULL)
+    {
+      puts ("found an entry that's not there");
+      result = 1;
+    }
+
+  key.val = 11;
+  res = (struct entry *) bsearch (&key, arr, 0, sizeof (arr[0]), comp);
+  if (res != NULL)
+    {
+      puts ("found an entry that's not there");
+      result = 1;
+    }
+
+  /* Now the array contains only one element - no entry should be found.  */
+  for (cnt = 0; cnt < narr; ++cnt)
+    {
+      key.val = arr[cnt].val;
+
+      res = (struct entry *) bsearch (&key, &arr[5], 1, sizeof (arr[0]), comp);
+      if (cnt == 5)
+	{
+	  if (res == NULL)
+	    {
+	      printf ("entry %zd not found\n", cnt);
+	      result = 1;
+	    }
+	  else if (res != &arr[cnt])
+	    {
+	      puts ("wrong entry returned");
+	      result = 1;
+	    }
+	}
+      else if (res != NULL)
+	{
+	  puts ("found an entry that's not there");
+	  result = 1;
+	}
+    }
+
+  if (align_check == 0)
+    {
+      puts ("alignment not checked");
+      result = 1;
+    }
+  else if (align_check == -1)
+    {
+      puts ("stack not sufficiently aligned");
+      result = 1;
+    }
+
+  if (result == 0)
+    puts ("all OK");
+
+  return result;
+}
Index: trunk/src/libctests/glibc/stdlib/tst-environ.c
===================================================================
--- trunk/src/libctests/glibc/stdlib/tst-environ.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/tst-environ.c	(revision 2036)
@@ -0,0 +1,222 @@
+/* Copyright (C) 1999, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+#define VAR "FOOBAR"
+
+char putenv_val[100] = VAR "=some longer value";
+
+int
+main (void)
+{
+  int result = 0;
+  const char *valp;
+
+  /* First test: remove entry FOOBAR, whether it exists or not.  */
+  unsetenv (VAR);
+
+  /* Now getting the value should fail.  */
+  if (getenv (VAR) != NULL)
+    {
+      printf ("There should be no `%s' value\n", VAR);
+      result = 1;
+    }
+
+  /* Now add a value, with the replace flag cleared.  */
+  if (setenv (VAR, "one", 0) != 0)
+    {
+      printf ("setenv #1 failed: %m\n");
+      result = 1;
+    }
+
+  /* Getting this value should now be possible.  */
+  valp = getenv (VAR);
+  if (valp == NULL || strcmp (valp, "one") != 0)
+    {
+      puts ("getenv #2 failed");
+      result = 1;
+    }
+
+  /* Try to replace without the replace flag set.  This should fail.  */
+  if (setenv (VAR, "two", 0) != 0)
+    {
+      printf ("setenv #2 failed: %m\n");
+      result = 1;
+    }
+
+  /* The value shouldn't have changed.  */
+  valp = getenv (VAR);
+  if (valp == NULL || strcmp (valp, "one") != 0)
+    {
+      puts ("getenv #3 failed");
+      result = 1;
+    }
+
+  /* Now replace the value using putenv.  */
+  if (putenv (putenv_val) != 0)
+    {
+      printf ("putenv #1 failed: %m\n");
+      result = 1;
+    }
+
+  /* The value should have changed now.  */
+  valp = getenv (VAR);
+  if (valp == NULL || strcmp (valp, "some longer value") != 0)
+    {
+      printf ("getenv #4 failed (is \"%s\")\n", valp);
+      result = 1;
+    }
+
+  /* Now one tricky check: changing the variable passed in putenv should
+     change the environment.  */
+  strcpy (&putenv_val[sizeof VAR], "a short one");
+
+  /* The value should have changed again.  */
+  valp = getenv (VAR);
+  if (valp == NULL || strcmp (valp, "a short one") != 0)
+    {
+      puts ("getenv #5 failed");
+      result = 1;
+    }
+
+  /* It should even be possible to rename the variable.  */
+  strcpy (putenv_val, "XYZZY=some other value");
+
+  /* Now a lookup using the old name should fail.  */
+  if (getenv (VAR) != NULL)
+    {
+      puts ("getenv #6 failed");
+      result = 1;
+    }
+
+  /* But using the new name it should work.  */
+  valp = getenv ("XYZZY");
+  if (valp == NULL || strcmp (valp, "some other value") != 0)
+    {
+      puts ("getenv #7 failed");
+      result = 1;
+    }
+
+  /* Create a new variable with the old name.  */
+  if (setenv (VAR, "a new value", 0) != 0)
+    {
+      printf ("setenv #3 failed: %m\n");
+      result = 1;
+    }
+
+  /* At this point a getenv call must return the new value.  */
+  valp = getenv (VAR);
+  if (valp == NULL || strcmp (valp, "a new value") != 0)
+    {
+      puts ("getenv #8 failed");
+      result = 1;
+    }
+
+  /* Black magic: rename the variable we added using putenv back.  */
+  strcpy (putenv_val, VAR "=old name new value");
+
+  /* This is interesting.  We have two variables with the same name.
+     Getting a value should return one of them.  */
+  valp = getenv (VAR);
+  if (valp == NULL
+      || (strcmp (valp, "a new value") != 0
+	  && strcmp (valp, "old name new value") != 0))
+    {
+      puts ("getenv #9 failed");
+      result = 1;
+    }
+
+  /* More fun ahead: we are now removing the variable.  This should remove
+     both values.  The cast is ok: this call should never put the string
+     in the environment and it should never modify it.  */
+  putenv ((char *) VAR);
+
+  /* Getting the value should now fail.  */
+  if (getenv (VAR) != NULL)
+    {
+      printf ("getenv #10 failed (\"%s\" found)\n", getenv (VAR));
+      result = 1;
+    }
+
+  /* Now a test with an environment variable that's one character long.
+     This is to test a special case in the getenv implementation.  */
+  strcpy (putenv_val, "X=one character test");
+  if (putenv (putenv_val) != 0)
+    {
+      printf ("putenv #2 failed: %m\n");
+      result = 1;
+    }
+
+  valp = getenv ("X");
+  if (valp == NULL || strcmp (valp, "one character test") != 0)
+    {
+      puts ("getenv #11 failed");
+      result = 1;
+    }
+
+  /* Both setenv and unsetenv should return -1/EINVAL for NULL or "" name
+     or if name contains '=' character.  */
+  errno = 0;
+  if (setenv (NULL, "val", 1) >= 0 || errno != EINVAL)
+    {
+      puts ("setenv #4 failed");
+      result = 1;
+    }
+
+  errno = 0;
+  if (setenv ("", "val", 0) >= 0 || errno != EINVAL)
+    {
+      puts ("setenv #5 failed");
+      result = 1;
+    }
+
+  errno = 0;
+  if (setenv ("var=val", "val", 1) >= 0 || errno != EINVAL)
+    {
+      puts ("setenv #6 failed");
+      result = 1;
+    }
+
+  errno = 0;
+  if (unsetenv (NULL) >= 0 || errno != EINVAL)
+    {
+      puts ("unsetenv #1 failed");
+      result = 1;
+    }
+
+  errno = 0;
+  if (unsetenv ("") >= 0 || errno != EINVAL)
+    {
+      puts ("unsetenv #2 failed");
+      result = 1;
+    }
+
+  errno = 0;
+  if (unsetenv ("x=y") >= 0 || errno != EINVAL)
+    {
+      puts ("unsetenv #3 failed");
+      result = 1;
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/stdlib/tst-fmtmsg.c
===================================================================
--- trunk/src/libctests/glibc/stdlib/tst-fmtmsg.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/tst-fmtmsg.c	(revision 2036)
@@ -0,0 +1,82 @@
+#include <fmtmsg.h>
+#include <mcheck.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+#define MM_TEST 10
+
+int
+main (void)
+{
+  int result = 0;
+
+  mtrace ();
+
+  char TEST[] = "ABCD";
+  if (addseverity (MM_TEST, TEST) != MM_OK)
+    {
+      puts ("addseverity failed");
+      result = 1;
+    }
+  strcpy (TEST, "TEST");
+
+  if (fmtmsg (MM_PRINT, "GLIBC:tst-fmtmsg", MM_HALT, "halt",
+	      "should print message for MM_HALT", "GLIBC:tst-fmtmsg:1")
+      != MM_OK)
+    result = 1;
+
+  if (fmtmsg (MM_PRINT, "GLIBC:tst-fmtmsg", MM_ERROR, "halt",
+	      "should print message for MM_ERROR", "GLIBC:tst-fmtmsg:2")
+      != MM_OK)
+    result = 1;
+
+  if (fmtmsg (MM_PRINT, "GLIBC:tst-fmtmsg", MM_WARNING, "halt",
+	      "should print message for MM_WARNING", "GLIBC:tst-fmtmsg:3")
+      != MM_OK)
+    result = 1;
+
+  if (fmtmsg (MM_PRINT, "GLIBC:tst-fmtmsg", MM_INFO, "halt",
+	      "should print message for MM_INFO", "GLIBC:tst-fmtmsg:4")
+      != MM_OK)
+    result = 1;
+
+  if (fmtmsg (MM_PRINT, "GLIBC:tst-fmtmsg", MM_NOSEV, "halt",
+	      "should print message for MM_NOSEV", "GLIBC:tst-fmtmsg:5")
+      != MM_OK)
+    result = 1;
+
+  if (fmtmsg (MM_PRINT, "GLIBC:tst-fmtmsg", MM_TEST, "halt",
+	      "should print message for MM_TEST", "GLIBC:tst-fmtmsg:6")
+      != MM_OK)
+    result = 1;
+
+  if (addseverity (MM_TEST, NULL) != MM_OK)
+    {
+      puts ("second addseverity failed");
+      result = 1;
+    }
+
+  if (addseverity (MM_TEST, NULL) != MM_NOTOK)
+    {
+      puts ("third addseverity unexpectedly succeeded");
+      result = 1;
+    }
+
+  char *p = strdup ("TEST2");
+  if (addseverity (MM_TEST, p) != MM_OK)
+    {
+      puts ("fourth addseverity failed");
+      result = 1;
+    }
+  if (addseverity (MM_TEST, "TEST3") != MM_OK)
+    {
+      puts ("fifth addseverity failed");
+      result = 1;
+    }
+
+  free (p);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/stdlib/tst-fmtmsg.sh
===================================================================
--- trunk/src/libctests/glibc/stdlib/tst-fmtmsg.sh	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/tst-fmtmsg.sh	(revision 2036)
@@ -0,0 +1,337 @@
+#! /bin/sh
+# Test of fmtmsg function family.
+# Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+common_objpfx=$1
+run_program_prefix=$2
+objpfx=$3
+
+test="${run_program_prefix} ${objpfx}tst-fmtmsg"
+out=${objpfx}tst-fmtmsg.out
+
+LC_ALL=C
+export LC_ALL
+
+(MSGVERB= $test || exit 1;
+ MSGVERB=label $test || exit 1;
+ MSGVERB=severity $test || exit 1;
+ MSGVERB=severity:label $test || exit 1;
+ MSGVERB=text $test || exit 1;
+ MSGVERB=text:label $test || exit 1;
+ MSGVERB=text:severity $test || exit 1;
+ MSGVERB=text:severity:label $test || exit 1;
+ MSGVERB=action $test || exit 1;
+ MSGVERB=action:label $test || exit 1;
+ MSGVERB=action:severity $test || exit 1;
+ MSGVERB=action:severity:label $test || exit 1;
+ MSGVERB=action:text $test || exit 1;
+ MSGVERB=action:text:label $test || exit 1;
+ MSGVERB=action:text:severity $test || exit 1;
+ MSGVERB=action:text:severity:label $test || exit 1;
+ MSGVERB=tag $test || exit 1;
+ MSGVERB=tag:label $test || exit 1;
+ MSGVERB=tag:severity $test || exit 1;
+ MSGVERB=tag:severity:label $test || exit 1;
+ MSGVERB=tag:text $test || exit 1;
+ MSGVERB=tag:text:label $test || exit 1;
+ MSGVERB=tag:text:severity $test || exit 1;
+ MSGVERB=tag:text:severity:label $test || exit 1;
+ MSGVERB=tag:action $test || exit 1;
+ MSGVERB=tag:action:label $test || exit 1;
+ MSGVERB=tag:action:severity $test || exit 1;
+ MSGVERB=tag:action:severity:label $test || exit 1;
+ MSGVERB=tag:action:text $test || exit 1;
+ MSGVERB=tag:action:text:label $test || exit 1;
+ MSGVERB=tag:action:text:severity $test || exit 1;
+ MSGVERB=tag:action:text:severity:label $test || exit 1;) 2> $out
+
+cmp $out <<EOF
+GLIBC:tst-fmtmsg: HALT: halt
+TO FIX: should print message for MM_HALT  GLIBC:tst-fmtmsg:1
+GLIBC:tst-fmtmsg: ERROR: halt
+TO FIX: should print message for MM_ERROR  GLIBC:tst-fmtmsg:2
+GLIBC:tst-fmtmsg: WARNING: halt
+TO FIX: should print message for MM_WARNING  GLIBC:tst-fmtmsg:3
+GLIBC:tst-fmtmsg: INFO: halt
+TO FIX: should print message for MM_INFO  GLIBC:tst-fmtmsg:4
+GLIBC:tst-fmtmsg: halt
+TO FIX: should print message for MM_NOSEV  GLIBC:tst-fmtmsg:5
+GLIBC:tst-fmtmsg: TEST: halt
+TO FIX: should print message for MM_TEST  GLIBC:tst-fmtmsg:6
+GLIBC:tst-fmtmsg
+GLIBC:tst-fmtmsg
+GLIBC:tst-fmtmsg
+GLIBC:tst-fmtmsg
+GLIBC:tst-fmtmsg
+GLIBC:tst-fmtmsg
+HALT
+ERROR
+WARNING
+INFO
+
+TEST
+GLIBC:tst-fmtmsg: HALT
+GLIBC:tst-fmtmsg: ERROR
+GLIBC:tst-fmtmsg: WARNING
+GLIBC:tst-fmtmsg: INFO
+GLIBC:tst-fmtmsg
+GLIBC:tst-fmtmsg: TEST
+halt
+halt
+halt
+halt
+halt
+halt
+GLIBC:tst-fmtmsg: halt
+GLIBC:tst-fmtmsg: halt
+GLIBC:tst-fmtmsg: halt
+GLIBC:tst-fmtmsg: halt
+GLIBC:tst-fmtmsg: halt
+GLIBC:tst-fmtmsg: halt
+HALT: halt
+ERROR: halt
+WARNING: halt
+INFO: halt
+halt
+TEST: halt
+GLIBC:tst-fmtmsg: HALT: halt
+GLIBC:tst-fmtmsg: ERROR: halt
+GLIBC:tst-fmtmsg: WARNING: halt
+GLIBC:tst-fmtmsg: INFO: halt
+GLIBC:tst-fmtmsg: halt
+GLIBC:tst-fmtmsg: TEST: halt
+TO FIX: should print message for MM_HALT
+TO FIX: should print message for MM_ERROR
+TO FIX: should print message for MM_WARNING
+TO FIX: should print message for MM_INFO
+TO FIX: should print message for MM_NOSEV
+TO FIX: should print message for MM_TEST
+GLIBC:tst-fmtmsg: TO FIX: should print message for MM_HALT
+GLIBC:tst-fmtmsg: TO FIX: should print message for MM_ERROR
+GLIBC:tst-fmtmsg: TO FIX: should print message for MM_WARNING
+GLIBC:tst-fmtmsg: TO FIX: should print message for MM_INFO
+GLIBC:tst-fmtmsg: TO FIX: should print message for MM_NOSEV
+GLIBC:tst-fmtmsg: TO FIX: should print message for MM_TEST
+HALT: TO FIX: should print message for MM_HALT
+ERROR: TO FIX: should print message for MM_ERROR
+WARNING: TO FIX: should print message for MM_WARNING
+INFO: TO FIX: should print message for MM_INFO
+TO FIX: should print message for MM_NOSEV
+TEST: TO FIX: should print message for MM_TEST
+GLIBC:tst-fmtmsg: HALT: TO FIX: should print message for MM_HALT
+GLIBC:tst-fmtmsg: ERROR: TO FIX: should print message for MM_ERROR
+GLIBC:tst-fmtmsg: WARNING: TO FIX: should print message for MM_WARNING
+GLIBC:tst-fmtmsg: INFO: TO FIX: should print message for MM_INFO
+GLIBC:tst-fmtmsg: TO FIX: should print message for MM_NOSEV
+GLIBC:tst-fmtmsg: TEST: TO FIX: should print message for MM_TEST
+halt
+TO FIX: should print message for MM_HALT
+halt
+TO FIX: should print message for MM_ERROR
+halt
+TO FIX: should print message for MM_WARNING
+halt
+TO FIX: should print message for MM_INFO
+halt
+TO FIX: should print message for MM_NOSEV
+halt
+TO FIX: should print message for MM_TEST
+GLIBC:tst-fmtmsg: halt
+TO FIX: should print message for MM_HALT
+GLIBC:tst-fmtmsg: halt
+TO FIX: should print message for MM_ERROR
+GLIBC:tst-fmtmsg: halt
+TO FIX: should print message for MM_WARNING
+GLIBC:tst-fmtmsg: halt
+TO FIX: should print message for MM_INFO
+GLIBC:tst-fmtmsg: halt
+TO FIX: should print message for MM_NOSEV
+GLIBC:tst-fmtmsg: halt
+TO FIX: should print message for MM_TEST
+HALT: halt
+TO FIX: should print message for MM_HALT
+ERROR: halt
+TO FIX: should print message for MM_ERROR
+WARNING: halt
+TO FIX: should print message for MM_WARNING
+INFO: halt
+TO FIX: should print message for MM_INFO
+halt
+TO FIX: should print message for MM_NOSEV
+TEST: halt
+TO FIX: should print message for MM_TEST
+GLIBC:tst-fmtmsg: HALT: halt
+TO FIX: should print message for MM_HALT
+GLIBC:tst-fmtmsg: ERROR: halt
+TO FIX: should print message for MM_ERROR
+GLIBC:tst-fmtmsg: WARNING: halt
+TO FIX: should print message for MM_WARNING
+GLIBC:tst-fmtmsg: INFO: halt
+TO FIX: should print message for MM_INFO
+GLIBC:tst-fmtmsg: halt
+TO FIX: should print message for MM_NOSEV
+GLIBC:tst-fmtmsg: TEST: halt
+TO FIX: should print message for MM_TEST
+GLIBC:tst-fmtmsg:1
+GLIBC:tst-fmtmsg:2
+GLIBC:tst-fmtmsg:3
+GLIBC:tst-fmtmsg:4
+GLIBC:tst-fmtmsg:5
+GLIBC:tst-fmtmsg:6
+GLIBC:tst-fmtmsg: GLIBC:tst-fmtmsg:1
+GLIBC:tst-fmtmsg: GLIBC:tst-fmtmsg:2
+GLIBC:tst-fmtmsg: GLIBC:tst-fmtmsg:3
+GLIBC:tst-fmtmsg: GLIBC:tst-fmtmsg:4
+GLIBC:tst-fmtmsg: GLIBC:tst-fmtmsg:5
+GLIBC:tst-fmtmsg: GLIBC:tst-fmtmsg:6
+HALT: GLIBC:tst-fmtmsg:1
+ERROR: GLIBC:tst-fmtmsg:2
+WARNING: GLIBC:tst-fmtmsg:3
+INFO: GLIBC:tst-fmtmsg:4
+GLIBC:tst-fmtmsg:5
+TEST: GLIBC:tst-fmtmsg:6
+GLIBC:tst-fmtmsg: HALT: GLIBC:tst-fmtmsg:1
+GLIBC:tst-fmtmsg: ERROR: GLIBC:tst-fmtmsg:2
+GLIBC:tst-fmtmsg: WARNING: GLIBC:tst-fmtmsg:3
+GLIBC:tst-fmtmsg: INFO: GLIBC:tst-fmtmsg:4
+GLIBC:tst-fmtmsg: GLIBC:tst-fmtmsg:5
+GLIBC:tst-fmtmsg: TEST: GLIBC:tst-fmtmsg:6
+halt
+GLIBC:tst-fmtmsg:1
+halt
+GLIBC:tst-fmtmsg:2
+halt
+GLIBC:tst-fmtmsg:3
+halt
+GLIBC:tst-fmtmsg:4
+halt
+GLIBC:tst-fmtmsg:5
+halt
+GLIBC:tst-fmtmsg:6
+GLIBC:tst-fmtmsg: halt
+GLIBC:tst-fmtmsg:1
+GLIBC:tst-fmtmsg: halt
+GLIBC:tst-fmtmsg:2
+GLIBC:tst-fmtmsg: halt
+GLIBC:tst-fmtmsg:3
+GLIBC:tst-fmtmsg: halt
+GLIBC:tst-fmtmsg:4
+GLIBC:tst-fmtmsg: halt
+GLIBC:tst-fmtmsg:5
+GLIBC:tst-fmtmsg: halt
+GLIBC:tst-fmtmsg:6
+HALT: halt
+GLIBC:tst-fmtmsg:1
+ERROR: halt
+GLIBC:tst-fmtmsg:2
+WARNING: halt
+GLIBC:tst-fmtmsg:3
+INFO: halt
+GLIBC:tst-fmtmsg:4
+halt
+GLIBC:tst-fmtmsg:5
+TEST: halt
+GLIBC:tst-fmtmsg:6
+GLIBC:tst-fmtmsg: HALT: halt
+GLIBC:tst-fmtmsg:1
+GLIBC:tst-fmtmsg: ERROR: halt
+GLIBC:tst-fmtmsg:2
+GLIBC:tst-fmtmsg: WARNING: halt
+GLIBC:tst-fmtmsg:3
+GLIBC:tst-fmtmsg: INFO: halt
+GLIBC:tst-fmtmsg:4
+GLIBC:tst-fmtmsg: halt
+GLIBC:tst-fmtmsg:5
+GLIBC:tst-fmtmsg: TEST: halt
+GLIBC:tst-fmtmsg:6
+TO FIX: should print message for MM_HALT  GLIBC:tst-fmtmsg:1
+TO FIX: should print message for MM_ERROR  GLIBC:tst-fmtmsg:2
+TO FIX: should print message for MM_WARNING  GLIBC:tst-fmtmsg:3
+TO FIX: should print message for MM_INFO  GLIBC:tst-fmtmsg:4
+TO FIX: should print message for MM_NOSEV  GLIBC:tst-fmtmsg:5
+TO FIX: should print message for MM_TEST  GLIBC:tst-fmtmsg:6
+GLIBC:tst-fmtmsg: TO FIX: should print message for MM_HALT  GLIBC:tst-fmtmsg:1
+GLIBC:tst-fmtmsg: TO FIX: should print message for MM_ERROR  GLIBC:tst-fmtmsg:2
+GLIBC:tst-fmtmsg: TO FIX: should print message for MM_WARNING  GLIBC:tst-fmtmsg:3
+GLIBC:tst-fmtmsg: TO FIX: should print message for MM_INFO  GLIBC:tst-fmtmsg:4
+GLIBC:tst-fmtmsg: TO FIX: should print message for MM_NOSEV  GLIBC:tst-fmtmsg:5
+GLIBC:tst-fmtmsg: TO FIX: should print message for MM_TEST  GLIBC:tst-fmtmsg:6
+HALT: TO FIX: should print message for MM_HALT  GLIBC:tst-fmtmsg:1
+ERROR: TO FIX: should print message for MM_ERROR  GLIBC:tst-fmtmsg:2
+WARNING: TO FIX: should print message for MM_WARNING  GLIBC:tst-fmtmsg:3
+INFO: TO FIX: should print message for MM_INFO  GLIBC:tst-fmtmsg:4
+TO FIX: should print message for MM_NOSEV  GLIBC:tst-fmtmsg:5
+TEST: TO FIX: should print message for MM_TEST  GLIBC:tst-fmtmsg:6
+GLIBC:tst-fmtmsg: HALT: TO FIX: should print message for MM_HALT  GLIBC:tst-fmtmsg:1
+GLIBC:tst-fmtmsg: ERROR: TO FIX: should print message for MM_ERROR  GLIBC:tst-fmtmsg:2
+GLIBC:tst-fmtmsg: WARNING: TO FIX: should print message for MM_WARNING  GLIBC:tst-fmtmsg:3
+GLIBC:tst-fmtmsg: INFO: TO FIX: should print message for MM_INFO  GLIBC:tst-fmtmsg:4
+GLIBC:tst-fmtmsg: TO FIX: should print message for MM_NOSEV  GLIBC:tst-fmtmsg:5
+GLIBC:tst-fmtmsg: TEST: TO FIX: should print message for MM_TEST  GLIBC:tst-fmtmsg:6
+halt
+TO FIX: should print message for MM_HALT  GLIBC:tst-fmtmsg:1
+halt
+TO FIX: should print message for MM_ERROR  GLIBC:tst-fmtmsg:2
+halt
+TO FIX: should print message for MM_WARNING  GLIBC:tst-fmtmsg:3
+halt
+TO FIX: should print message for MM_INFO  GLIBC:tst-fmtmsg:4
+halt
+TO FIX: should print message for MM_NOSEV  GLIBC:tst-fmtmsg:5
+halt
+TO FIX: should print message for MM_TEST  GLIBC:tst-fmtmsg:6
+GLIBC:tst-fmtmsg: halt
+TO FIX: should print message for MM_HALT  GLIBC:tst-fmtmsg:1
+GLIBC:tst-fmtmsg: halt
+TO FIX: should print message for MM_ERROR  GLIBC:tst-fmtmsg:2
+GLIBC:tst-fmtmsg: halt
+TO FIX: should print message for MM_WARNING  GLIBC:tst-fmtmsg:3
+GLIBC:tst-fmtmsg: halt
+TO FIX: should print message for MM_INFO  GLIBC:tst-fmtmsg:4
+GLIBC:tst-fmtmsg: halt
+TO FIX: should print message for MM_NOSEV  GLIBC:tst-fmtmsg:5
+GLIBC:tst-fmtmsg: halt
+TO FIX: should print message for MM_TEST  GLIBC:tst-fmtmsg:6
+HALT: halt
+TO FIX: should print message for MM_HALT  GLIBC:tst-fmtmsg:1
+ERROR: halt
+TO FIX: should print message for MM_ERROR  GLIBC:tst-fmtmsg:2
+WARNING: halt
+TO FIX: should print message for MM_WARNING  GLIBC:tst-fmtmsg:3
+INFO: halt
+TO FIX: should print message for MM_INFO  GLIBC:tst-fmtmsg:4
+halt
+TO FIX: should print message for MM_NOSEV  GLIBC:tst-fmtmsg:5
+TEST: halt
+TO FIX: should print message for MM_TEST  GLIBC:tst-fmtmsg:6
+GLIBC:tst-fmtmsg: HALT: halt
+TO FIX: should print message for MM_HALT  GLIBC:tst-fmtmsg:1
+GLIBC:tst-fmtmsg: ERROR: halt
+TO FIX: should print message for MM_ERROR  GLIBC:tst-fmtmsg:2
+GLIBC:tst-fmtmsg: WARNING: halt
+TO FIX: should print message for MM_WARNING  GLIBC:tst-fmtmsg:3
+GLIBC:tst-fmtmsg: INFO: halt
+TO FIX: should print message for MM_INFO  GLIBC:tst-fmtmsg:4
+GLIBC:tst-fmtmsg: halt
+TO FIX: should print message for MM_NOSEV  GLIBC:tst-fmtmsg:5
+GLIBC:tst-fmtmsg: TEST: halt
+TO FIX: should print message for MM_TEST  GLIBC:tst-fmtmsg:6
+EOF
+exit $?
Index: trunk/src/libctests/glibc/stdlib/tst-limits.c
===================================================================
--- trunk/src/libctests/glibc/stdlib/tst-limits.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/tst-limits.c	(revision 2036)
@@ -0,0 +1,69 @@
+/* It is important that this comes first to not hide effects introduced
+   by other headers.  */
+#include <limits.h>
+
+#include <inttypes.h>
+#include <stdio.h>
+
+
+static long long int
+bitval (int bits)
+{
+  long long int val = 0;
+  while (bits-- > 0)
+    val |= 1ll << bits;
+  return val;
+}
+
+
+int
+main (void)
+{
+  int result = 0;
+
+#define TEST(name, format, expected) \
+  printf ("%-12s expected = %-20" format "  actual = %" format "\n",	      \
+	  #name ":", expected, name);					      \
+  result |= name != expected
+
+  /* The limits from ISO C99.  */
+
+  /* We cannot support anything but 8-bit chars.  */
+  TEST (CHAR_BIT, "d", 8);
+  TEST (SCHAR_MIN, "d", -128);
+  TEST (SCHAR_MAX, "d", 127);
+  TEST (UCHAR_MAX, "d", 255);
+
+  TEST (SHRT_MIN, "d", -(1 << (sizeof (short int) * CHAR_BIT - 1)));
+  TEST (SHRT_MAX, "d", (1 << (sizeof (short int) * CHAR_BIT - 1)) - 1);
+  TEST (USHRT_MAX, "d", (1 << sizeof (short int) * CHAR_BIT) - 1);
+
+  TEST (INT_MIN, "d", (int) -bitval (sizeof (int) * CHAR_BIT - 1) - 1);
+  TEST (INT_MAX, "d", (int) bitval (sizeof (int) * CHAR_BIT - 1));
+  TEST (UINT_MAX, "u",
+	(unsigned int) bitval (sizeof (unsigned int) * CHAR_BIT));
+
+  TEST (LONG_MIN, "ld",
+	(long int) -bitval (sizeof (long int) * CHAR_BIT - 1) - 1);
+  TEST (LONG_MAX, "ld", (long int) bitval (sizeof (long int) * CHAR_BIT - 1));
+  TEST (ULONG_MAX, "lu",
+	(unsigned long int) bitval (sizeof (unsigned long int) * CHAR_BIT));
+
+  TEST (LLONG_MIN, "lld", -bitval (sizeof (long long int) * CHAR_BIT - 1) - 1);
+  TEST (LLONG_MAX, "lld", bitval (sizeof (long long int) * CHAR_BIT - 1));
+  TEST (ULLONG_MAX, "llu",
+	(unsigned long long int) bitval (sizeof (unsigned long long int)
+					 * CHAR_BIT));
+
+  /* Values from POSIX and Unix.  */
+#ifdef PAGESIZE
+  TEST (PAGESIZE, "d", getpagesize ());
+#elif PAGE_SIZE
+  TEST (PAGE_SIZE, "d", getpagesize ());
+#endif
+
+  TEST (WORD_BIT, "d", (int) sizeof (int) * CHAR_BIT);
+  TEST (LONG_BIT, "d", (int) sizeof (long int) * CHAR_BIT);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/stdlib/tst-putenv.c
===================================================================
--- trunk/src/libctests/glibc/stdlib/tst-putenv.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/tst-putenv.c	(revision 2036)
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+static int
+do_test (void)
+{
+  char *p = getenv ("SOMETHING_NOBODY_USES");
+  if (p == NULL)
+    {
+      puts ("envvar not defined");
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/stdlib/tst-putenvmod.c
===================================================================
--- trunk/src/libctests/glibc/stdlib/tst-putenvmod.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/tst-putenvmod.c	(revision 2036)
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+void
+__attribute ((constructor))
+init (void)
+{
+  puts ("init DSO");
+
+  static char str[] = "SOMETHING_NOBODY_USES=something_else";
+  if (putenv (str) != 0)
+    {
+      puts ("putenv failed");
+      _exit (1);
+    }
+}
Index: trunk/src/libctests/glibc/stdlib/tst-qsort.c
===================================================================
--- trunk/src/libctests/glibc/stdlib/tst-qsort.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/tst-qsort.c	(revision 2036)
@@ -0,0 +1,55 @@
+/* Test case by Paul Eggert <eggert@twinsun.com> */
+#include <stdio.h>
+#include <stdlib.h>
+#include <tst-stack-align.h>
+
+struct big { char c[4 * 1024]; };
+
+struct big *array;
+struct big *array_end;
+
+static int align_check;
+
+int
+compare (void const *a1, void const *b1)
+{
+  struct big const *a = a1;
+  struct big const *b = b1;
+
+  if (!align_check)
+    align_check = TEST_STACK_ALIGN () ? -1 : 1;
+
+  if (! (array <= a && a < array_end
+	 && array <= b && b < array_end))
+    {
+      exit (EXIT_FAILURE);
+    }
+  return b->c[0] - a->c[0];
+}
+
+int
+main (int argc, char **argv)
+{
+  size_t i;
+  size_t array_members = argv[1] ? atoi (argv[1]) : 50;
+  array = (struct big *) malloc (array_members * sizeof *array);
+  if (array == NULL)
+    {
+      puts ("no memory");
+      exit (EXIT_FAILURE);
+    }
+
+  array_end = array + array_members;
+  for (i = 0; i < array_members; i++)
+    array[i].c[0] = i % 128;
+
+  qsort (array, array_members, sizeof *array, compare);
+
+  if (align_check == -1)
+    {
+      puts ("stack not sufficiently aligned");
+      exit (EXIT_FAILURE);
+    }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/stdlib/tst-rand48.c
===================================================================
--- trunk/src/libctests/glibc/stdlib/tst-rand48.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/tst-rand48.c	(revision 2036)
@@ -0,0 +1,390 @@
+#include <float.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef DECIMAL_DIG
+# define DECIMAL_DIG	21
+#endif
+
+
+int
+main (void)
+{
+  unsigned short int xs[3] = { 0x0001, 0x0012, 0x0123 };
+  unsigned short int lxs[7];
+  unsigned short int *xsp;
+  int result = 0;
+  long int l;
+  double d;
+  double e;
+
+  /* Test srand48.  */
+  srand48 (0x98765432);
+  /* Get the values of the internal Xi array.  */
+  xsp = seed48 (xs);
+  if (xsp[0] != 0x330e || xsp[1] != 0x5432 || xsp[2] != 0x9876)
+    {
+      puts ("srand48(0x98765432) didn't set correct value");
+      printf ("  expected: { %04hx, %04hx, %04hx }\n", 0x330e, 0x5432, 0x9876);
+      printf ("  seen:     { %04hx, %04hx, %04hx }\n", xsp[0], xsp[1], xsp[2]);
+      result = 1;
+    }
+  /* Put the values back.  */
+  memcpy (xs, xsp, sizeof (xs));
+  (void) seed48 (xs);
+
+  /* See whether the correct values are installed.  */
+  l = lrand48 ();
+  if (l != 0x2fed1413l)
+    {
+      printf ("lrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0x2fed1413l, l);
+      result = 1;
+    }
+
+  l = mrand48 ();
+  if (l != 0xa28c1003l)
+    {
+      printf ("mrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0xa28c1003l, l);
+      result = 1;
+    }
+
+  l = lrand48 ();
+  if (l != 0x585fcfb7l)
+    {
+      printf ("lrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0x585fcfb7l, l);
+      result = 1;
+    }
+
+  l = mrand48 ();
+  if (l != 0x9e88f474l)
+    {
+      printf ("mrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0x9e88f474l, l);
+      result = 1;
+    }
+
+  /* Test seed48.  The previous call should have install the values in
+     the initialization of `xs' above.  */
+  xs[0] = 0x1234;
+  xs[1] = 0x5678;
+  xs[2] = 0x9012;
+  xsp = seed48 (xs);
+  if (xsp[0] != 0x62f2 || xsp[1] != 0xf474 || xsp[2] != 0x9e88)
+    {
+      puts ("seed48() did not install the values correctly");
+      printf ("  expected: { %04hx, %04hx, %04hx }\n", 0x62f2, 0xf474, 0x9e88);
+      printf ("  seen:     { %04hx, %04hx, %04hx }\n", xsp[0], xsp[1], xsp[2]);
+      result = 1;
+    }
+
+  /* Test lrand48 and mrand48.  We continue from the seed established
+     above.  */
+  l = lrand48 ();
+  if (l != 0x017e48b5l)
+    {
+      printf ("lrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0x017e48b5l, l);
+      result = 1;
+    }
+
+  l = mrand48 ();
+  if (l != 0xeb7a1fa3l)
+    {
+      printf ("mrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0xeb7a1fa3l, l);
+      result = 1;
+    }
+
+  l = lrand48 ();
+  if (l != 0x6b6a3f95l)
+    {
+      printf ("lrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0x6b6a3f95l, l);
+      result = 1;
+    }
+
+  l = mrand48 ();
+  if (l != 0x175c0d6fl)
+    {
+      printf ("mrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0x175c0d6fl, l);
+      result = 1;
+    }
+
+  /* Test lcong48.  */
+  lxs[0] = 0x4567;
+  lxs[1] = 0x6789;
+  lxs[2] = 0x8901;
+  lxs[3] = 0x0123;
+  lxs[4] = 0x2345;
+  lxs[5] = 0x1111;
+  lxs[6] = 0x2222;
+  lcong48 (lxs);
+
+  /* See whether the correct values are installed.  */
+  l = lrand48 ();
+  if (l != 0x6df63d66l)
+    {
+      printf ("lrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0x6df63d66l, l);
+      result = 1;
+    }
+
+  l = mrand48 ();
+  if (l != 0x2f92c8e1l)
+    {
+      printf ("mrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0x2f92c8e1l, l);
+      result = 1;
+    }
+
+  l = lrand48 ();
+  if (l != 0x3b4869ffl)
+    {
+      printf ("lrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0x3b4869ffl, l);
+      result = 1;
+    }
+
+  l = mrand48 ();
+  if (l != 0x5cd4cc3el)
+    {
+      printf ("mrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0x5cd4cc3el, l);
+      result = 1;
+    }
+
+  /* Check whether srand48() restores the A and C parameters.  */
+  srand48 (0x98765432);
+
+  /* See whether the correct values are installed.  */
+  l = lrand48 ();
+  if (l != 0x2fed1413l)
+    {
+      printf ("lrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0x2fed1413l, l);
+      result = 1;
+    }
+
+  l = mrand48 ();
+  if (l != 0xa28c1003l)
+    {
+      printf ("mrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0xa28c1003l, l);
+      result = 1;
+    }
+
+  l = lrand48 ();
+  if (l != 0x585fcfb7l)
+    {
+      printf ("lrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0x585fcfb7l, l);
+      result = 1;
+    }
+
+  l = mrand48 ();
+  if (l != 0x9e88f474l)
+    {
+      printf ("mrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0x9e88f474l, l);
+      result = 1;
+    }
+
+  /* And again to see whether seed48() does the same.  */
+  lcong48 (lxs);
+
+  /* See whether lxs wasn't modified.  */
+  l = lrand48 ();
+  if (l != 0x6df63d66l)
+    {
+      printf ("lrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0x6df63d66l, l);
+      result = 1;
+    }
+
+  /* Test seed48.  The previous call should have install the values in
+     the initialization of `xs' above.  */
+  xs[0] = 0x1234;
+  xs[1] = 0x5678;
+  xs[2] = 0x9012;
+  xsp = seed48 (xs);
+  if (xsp[0] != 0x0637 || xsp[1] != 0x7acd || xsp[2] != 0xdbec)
+    {
+      puts ("seed48() did not install the values correctly");
+      printf ("  expected: { %04hx, %04hx, %04hx }\n", 0x0637, 0x7acd, 0xdbec);
+      printf ("  seen:     { %04hx, %04hx, %04hx }\n", xsp[0], xsp[1], xsp[2]);
+      result = 1;
+    }
+
+  /* Test lrand48 and mrand48.  We continue from the seed established
+     above.  */
+  l = lrand48 ();
+  if (l != 0x017e48b5l)
+    {
+      printf ("lrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0x017e48b5l, l);
+      result = 1;
+    }
+
+  l = mrand48 ();
+  if (l != 0xeb7a1fa3l)
+    {
+      printf ("mrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0xeb7a1fa3l, l);
+      result = 1;
+    }
+
+  l = lrand48 ();
+  if (l != 0x6b6a3f95l)
+    {
+      printf ("lrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0x6b6a3f95l, l);
+      result = 1;
+    }
+
+  l = mrand48 ();
+  if (l != 0x175c0d6fl)
+    {
+      printf ("mrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0x175c0d6fl, l);
+      result = 1;
+    }
+
+  /* Test drand48.  */
+  d = drand48 ();
+  if (d != 0.0908832261858485424)
+    {
+      printf ("drand48() in line %d failed: expected %.*g, seen %.*g\n",
+	      __LINE__ - 4, DECIMAL_DIG, 0.0908832261858485424,
+	      DECIMAL_DIG, d);
+      result = 1;
+    }
+
+  d = drand48 ();
+  if (d != 0.943149381730059133133)
+    {
+      printf ("drand48() in line %d failed: expected %.*g, seen %.*g\n",
+	      __LINE__ - 4, DECIMAL_DIG, 0.943149381730059133133,
+	      DECIMAL_DIG, d);
+      result = 1;
+    }
+
+  /* Now the functions which get the Xis passed.  */
+  xs[0] = 0x3849;
+  xs[1] = 0x5061;
+  xs[2] = 0x7283;
+
+  l = nrand48 (xs);
+  if (l != 0x1efe61a1l)
+    {
+      printf ("nrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0x1efe61a1l, l);
+      result = 1;
+    }
+
+  l = jrand48 (xs);
+  if (l != 0xf568c7a0l)
+    {
+      printf ("jrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0xf568c7a0l, l);
+      result = 1;
+    }
+
+  l = nrand48 (xs);
+  if (l != 0x2a5e57fel)
+    {
+      printf ("nrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0x2a5e57fel, l);
+      result = 1;
+    }
+
+  l = jrand48 (xs);
+  if (l != 0x71a779a8l)
+    {
+      printf ("jrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0x71a779a8l, l);
+      result = 1;
+    }
+
+  /* Test whether the global A and C are used.  */
+  lcong48 (lxs);
+
+  l = nrand48 (xs);
+  if (l != 0x32beee9fl)
+    {
+      printf ("nrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0x32beee9fl, l);
+      result = 1;
+    }
+
+  l = jrand48 (xs);
+  if (l != 0x7bddf3bal)
+    {
+      printf ("jrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0x7bddf3bal, l);
+      result = 1;
+    }
+
+  l = nrand48 (xs);
+  if (l != 0x85bdf28l)
+    {
+      printf ("nrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0x85bdf28l, l);
+      result = 1;
+    }
+
+  l = jrand48 (xs);
+  if (l != 0x7b433e47l)
+    {
+      printf ("jrand48() in line %d failed: expected %lx, seen %lx\n",
+	      __LINE__ - 4, 0x7b433e47l, l);
+      result = 1;
+    }
+
+  /* Test erand48.  Also compare with the drand48 results.  */
+  (void) seed48 (xs);
+
+  d = drand48 ();
+  e = erand48 (xs);
+  if (d != e)
+    {
+      printf ("\
+drand48() and erand48 in lines %d and %d produce different results\n",
+	      __LINE__ - 6, __LINE__ - 5);
+      printf ("  drand48() = %g, erand48() = %g\n", d, e);
+      result = 1;
+    }
+  else if (e != 0.640650904452755298735)
+    {
+      printf ("erand48() in line %d failed: expected %.*g, seen %.*g\n",
+	      __LINE__ - 4, DECIMAL_DIG, 0.640650904452755298735,
+	      DECIMAL_DIG, e);
+      result = 1;
+
+    }
+
+  d = drand48 ();
+  e = erand48 (xs);
+  if (d != e)
+    {
+      printf ("\
+drand48() and erand48 in lines %d and %d produce different results\n",
+	      __LINE__ - 6, __LINE__ - 5);
+      printf ("  drand48() = %g, erand48() = %g\n", d, e);
+      result = 1;
+    }
+  else if (e != 0.115372323508150742555)
+    {
+      printf ("erand48() in line %d failed: expected %.*g, seen %.*g\n",
+	      __LINE__ - 4, DECIMAL_DIG, 0.0115372323508150742555,
+	      DECIMAL_DIG, e);
+      result = 1;
+
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/stdlib/tst-random.c
===================================================================
--- trunk/src/libctests/glibc/stdlib/tst-random.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/tst-random.c	(revision 2036)
@@ -0,0 +1,119 @@
+/* Test program for random(), srandom(), initstate(), setstate()
+   Written by Michael J. Fischer, August 21, 2000
+   Placed in the public domain.  */
+
+/* This program primarily tests the correct functioning of srandom()
+   and setstate().  The strategy is generate and store a set of random
+   sequences, each with a specified starting seed.  Then each sequence
+   is regenerated twice and checked against the stored values.
+
+   First they are regenerated one sequence at a time, using srandom()
+   to set the initial state.  A discrepency here would suggest that
+   srandom() was failing to completely initialize the random number
+   generator.
+
+   Second the sequences are regenerated in an interleaved order.
+   A state vector is created for each sequence using initstate().
+   setstate() is used to switch from sequence to sequence during
+   the interleaved generation.  A discrepency here would suggest
+   a problem with either initstate() failing to initialize the
+   random number generator properly, or the failure of setstate()
+   to correctly save and restore state information.  Also, each
+   time setstate() is called, the returned value is checked for
+   correctness (since we know what it should be).
+
+   Note:  We use default state vector for sequence 0 and our own
+   state vectors for the remaining sequences.  This is to give a check
+   that the value returned by initstate() is valid and can indeed be
+   used in the future.  */
+
+/* Strategy:
+   1.  Use srandom() followed by calls on random to generate a set of
+       sequences of values.
+   2.  Regenerate and check the sequences.
+   3.  Use initstate() to create new states.
+   4.  Regenerate the sequences in an interleaved manner and check.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+
+const int degree = 128;		/* random number generator degree (should
+				   be one of 8, 16, 32, 64, 128, 256) */
+const int nseq = 3;		/* number of test sequences */
+const int nrnd = 50;		/* length of each test sequence */
+const unsigned int seed[3] = { 0x12344321U, 0xEE11DD22U, 0xFEDCBA98 };
+
+void fail (const char *msg, int s, int i) __attribute__ ((__noreturn__));
+
+int
+main (void)
+{
+  long int rnd[nseq][nrnd];	/* pseudorandom numbers */
+  char* state[nseq];		/* state for PRNG */
+  char* oldstate[nseq];		/* old PRNG state */
+  int s;			/* sequence index */
+  int i;			/* element index */
+
+  printf ("Begining random package test using %d sequences of length %d.\n",
+	  nseq, nrnd);
+
+  /* 1. Generate and store the sequences.  */
+  printf ("Generating random sequences.\n");
+  for (s = 0; s < nseq; ++s)
+    {
+      srandom ( seed[s] );
+      for (i = 0; i < nrnd; ++i)
+	rnd[s][i] = random ();
+    }
+
+  /* 2. Regenerate and check.  */
+  printf ("Regenerating and checking sequences.\n");
+  for (s = 0; s < nseq; ++s)
+    {
+      srandom (seed[s]);
+      for (i = 0; i < nrnd; ++i)
+	if (rnd[s][i] != random ())
+	  fail ("first regenerate test", s, i);
+    }
+
+  /* 3. Create state vector, one for each sequence.
+	First state is random's internal state; others are malloced.  */
+  printf ("Creating and checking state vector for each sequence.\n");
+  srandom (seed[0]);			/* reseed with first seed */
+  for (s = 1; s < nseq; ++s)
+    {
+      state[s] = (char*) malloc (degree);
+      oldstate[s] = initstate (seed[s], state[s], degree);
+    }
+  state[0] = oldstate[1];
+
+  /* Check returned values.  */
+  for (s = 1; s < nseq - 1; ++s)
+    if (state[s] != oldstate[s + 1])
+      fail ("bad initstate() return value", s, i);
+
+  /* 4. Regenerate sequences interleaved and check.  */
+  printf ("Regenerating and checking sequences in interleaved order.\n");
+  for (i = 0; i < nrnd; ++i)
+    {
+      for (s = 0; s < nseq; ++s)
+	{
+	  char *oldstate = (char *) setstate (state[s]);
+	  if (oldstate != state[(s + nseq - 1) % nseq])
+	    fail ("bad setstate() return value", s, i);
+	  if (rnd[s][i] != random ())
+	    fail ("bad value generated in interleave test", s, i);
+	}
+    }
+  printf ("All tests passed!\n");
+  return 0;
+}
+
+void
+fail (const char *msg, int s, int i)
+{
+  printf ("\nTest FAILED: ");
+  printf ("%s (seq %d, pos %d).\n", msg, s, i);
+  exit (1);
+}
Index: trunk/src/libctests/glibc/stdlib/tst-random2.c
===================================================================
--- trunk/src/libctests/glibc/stdlib/tst-random2.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/tst-random2.c	(revision 2036)
@@ -0,0 +1,59 @@
+/* Test initstate saving the old state.
+   Copyright (C) 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2005.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main (void)
+{
+  int pass;
+  int ret = 0;
+  long int r[2];
+
+  for (pass = 0; pass < 2; pass++)
+    {
+      srandom (0x12344321);
+
+      int j;
+      for (j = 0; j < 3; ++j)
+	random ();
+      if (pass == 1)
+	{
+	  char state[128];
+	  char *ostate = initstate (0x34562101, state, 128);
+	  if (setstate (ostate) != state)
+	    {
+	      puts ("setstate (ostate) != state");
+	      ret = 1;
+	    }
+	}
+
+      random ();
+      r[pass] = random ();
+    }
+
+  if (r[0] != r[1])
+    {
+      printf ("%ld != %ld\n", r[0], r[1]);
+      ret = 1;
+    }
+  return ret;
+}
Index: trunk/src/libctests/glibc/stdlib/tst-setcontext.c
===================================================================
--- trunk/src/libctests/glibc/stdlib/tst-setcontext.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/tst-setcontext.c	(revision 2036)
@@ -0,0 +1,202 @@
+/* Copyright (C) 2001,02, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ucontext.h>
+
+static ucontext_t ctx[3];
+
+static int was_in_f1;
+static int was_in_f2;
+
+static char st2[32768];
+
+static void
+f1 (long a0, long a1, long a2, long a3)
+{
+  printf ("start f1(a0=%lx,a1=%lx,a2=%lx,a3=%lx)\n", a0, a1, a2, a3);
+
+  if (a0 != 1 || a1 != 2 || a2 != 3 || a3 != -4)
+    {
+      puts ("arg mismatch");
+      exit (-1);
+    }
+
+  if (swapcontext (&ctx[1], &ctx[2]) != 0)
+    {
+      printf ("%s: swapcontext: %m\n", __FUNCTION__);
+      exit (1);
+    }
+  puts ("finish f1");
+  was_in_f1 = 1;
+}
+
+static void
+f2 (void)
+{
+  char on_stack[1];
+
+  puts ("start f2");
+
+  printf ("&on_stack=%p\n", on_stack);
+  if (on_stack < st2 || on_stack >= st2 + sizeof (st2))
+    {
+      printf ("%s: memory stack is not where it belongs!", __FUNCTION__);
+      exit (1);
+    }
+
+  if (swapcontext (&ctx[2], &ctx[1]) != 0)
+    {
+      printf ("%s: swapcontext: %m\n", __FUNCTION__);
+      exit (1);
+    }
+  puts ("finish f2");
+  was_in_f2 = 1;
+}
+
+void
+test_stack(volatile int a, volatile int b,
+           volatile int c, volatile int d)
+{
+  volatile int e = 5;
+  volatile int f = 6;
+  ucontext_t uc;
+
+  /* Test for cases where getcontext is clobbering the callers
+     stack, including parameters.  */
+  getcontext(&uc);
+
+  if (a != 1)
+    {
+      printf ("%s: getcontext clobbers parm a\n", __FUNCTION__);
+      exit (1);
+    }
+
+  if (b != 2)
+    {
+      printf ("%s: getcontext clobbers parm b\n", __FUNCTION__);
+      exit (1);
+    }
+
+  if (c != 3)
+    {
+      printf ("%s: getcontext clobbers parm c\n", __FUNCTION__);
+      exit (1);
+    }
+
+  if (d != 4)
+    {
+      printf ("%s: getcontext clobbers parm d\n", __FUNCTION__);
+      exit (1);
+    }
+
+  if (e != 5)
+    {
+      printf ("%s: getcontext clobbers varible e\n", __FUNCTION__);
+      exit (1);
+    }
+
+  if (f != 6)
+    {
+      printf ("%s: getcontext clobbers variable f\n", __FUNCTION__);
+      exit (1);
+    }
+}
+
+volatile int global;
+
+int
+main (void)
+{
+  char st1[32768];
+
+  puts ("making contexts");
+  if (getcontext (&ctx[1]) != 0)
+    {
+      if (errno == ENOSYS)
+	exit (0);
+
+      printf ("%s: getcontext: %m\n", __FUNCTION__);
+      exit (1);
+    }
+
+  test_stack (1, 2, 3, 4);
+
+  /* Play some tricks with this context.  */
+  if (++global == 1)
+    if (setcontext (&ctx[1]) != 0)
+      {
+	printf ("%s: setcontext: %m\n", __FUNCTION__);
+	exit (1);
+      }
+  if (global != 2)
+    {
+      printf ("%s: 'global' not incremented twice\n", __FUNCTION__);
+      exit (1);
+    }
+
+  ctx[1].uc_stack.ss_sp = st1;
+  ctx[1].uc_stack.ss_size = sizeof st1;
+  ctx[1].uc_link = &ctx[0];
+  {
+    ucontext_t tempctx = ctx[1];
+    makecontext (&ctx[1], (void (*) (void)) f1, 4, 1, 2, 3, -4);
+
+    /* Without this check, a stub makecontext can make us spin forever.  */
+    if (memcmp (&tempctx, &ctx[1], sizeof ctx[1]) == 0)
+      {
+	puts ("makecontext was a no-op, presuming not implemented");
+	return 0;
+      }
+  }
+
+  if (getcontext (&ctx[2]) != 0)
+    {
+      printf ("%s: second getcontext: %m\n", __FUNCTION__);
+      exit (1);
+    }
+  ctx[2].uc_stack.ss_sp = st2;
+  ctx[2].uc_stack.ss_size = sizeof st2;
+  ctx[2].uc_link = &ctx[1];
+  makecontext (&ctx[2], f2, 0);
+
+  puts ("swapping contexts");
+  if (swapcontext (&ctx[0], &ctx[2]) != 0)
+    {
+      printf ("%s: swapcontext: %m\n", __FUNCTION__);
+      exit (1);
+    }
+  puts ("back at main program");
+
+  if (was_in_f1 == 0)
+    {
+      puts ("didn't reach f1");
+      exit (1);
+    }
+  if (was_in_f2 == 0)
+    {
+      puts ("didn't reach f2");
+      exit (1);
+    }
+
+  puts ("test succeeded");
+  return 0;
+}
Index: trunk/src/libctests/glibc/stdlib/tst-strtod.c
===================================================================
--- trunk/src/libctests/glibc/stdlib/tst-strtod.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/tst-strtod.c	(revision 2036)
@@ -0,0 +1,276 @@
+/* Copyright (C) 1991,96,97,98,99,2000,2001,2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <ctype.h>
+#include <locale.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <math.h>
+
+struct ltest
+  {
+    const char *str;		/* Convert this.  */
+    double expect;		/* To get this.  */
+    char left;			/* With this left over.  */
+    int err;			/* And this in errno.  */
+  };
+static const struct ltest tests[] =
+  {
+    { "12.345", 12.345, '\0', 0 },
+    { "12.345e19", 12.345e19, '\0', 0 },
+    { "-.1e+9", -.1e+9, '\0', 0 },
+    { ".125", .125, '\0', 0 },
+    { "1e20", 1e20, '\0', 0 },
+    { "0e-19", 0, '\0', 0 },
+    { "4\00012", 4.0, '\0', 0 },
+    { "5.9e-76", 5.9e-76, '\0', 0 },
+    { "0x1.4p+3", 10.0, '\0', 0 },
+    { "0xAp0", 10.0, '\0', 0 },
+    { "0x0Ap0", 10.0, '\0', 0 },
+    { "0x0A", 10.0, '\0', 0 },
+    { "0xA0", 160.0, '\0', 0 },
+    { "0x0.A0p8", 160.0, '\0', 0 },
+    { "0x0.50p9", 160.0, '\0', 0 },
+    { "0x0.28p10", 160.0, '\0', 0 },
+    { "0x0.14p11", 160.0, '\0', 0 },
+    { "0x0.0A0p12", 160.0, '\0', 0 },
+    { "0x0.050p13", 160.0, '\0', 0 },
+    { "0x0.028p14", 160.0, '\0', 0 },
+    { "0x0.014p15", 160.0, '\0', 0 },
+    { "0x00.00A0p16", 160.0, '\0', 0 },
+    { "0x00.0050p17", 160.0, '\0', 0 },
+    { "0x00.0028p18", 160.0, '\0', 0 },
+    { "0x00.0014p19", 160.0, '\0', 0 },
+    { "0x1p-1023",
+      1.11253692925360069154511635866620203210960799023116591527666e-308,
+      '\0', 0 },
+    { "0x0.8p-1022",
+      1.11253692925360069154511635866620203210960799023116591527666e-308,
+      '\0', 0 },
+#if __GNUC_PREREQ(2,96)
+    /* For older GCC release HUGE_VAL is not a constant.  */
+    { "Inf", HUGE_VAL, '\0', 0 },
+    { "-Inf", -HUGE_VAL, '\0', 0 },
+    { "+InFiNiTy", HUGE_VAL, '\0', 0 },
+#endif
+    { "0x80000Ap-23", 0x80000Ap-23, '\0', 0 },
+    { NULL, 0, '\0', 0 }
+  };
+
+static void expand (char *dst, int c);
+static int long_dbl (void);
+static int locale_test (void);
+
+int
+main (int argc, char ** argv)
+{
+  char buf[100];
+  register const struct ltest *lt;
+  char *ep;
+  int status = 0;
+  int save_errno;
+
+  for (lt = tests; lt->str != NULL; ++lt)
+    {
+      double d;
+
+      errno = 0;
+      d = strtod(lt->str, &ep);
+      save_errno = errno;
+      printf ("strtod (\"%s\") test %u",
+	     lt->str, (unsigned int) (lt - tests));
+      if (d == lt->expect && *ep == lt->left && save_errno == lt->err)
+	puts ("\tOK");
+      else
+	{
+	  puts ("\tBAD");
+	  if (d != lt->expect)
+	    printf ("  returns %.60g, expected %.60g\n", d, lt->expect);
+	  if (lt->left != *ep)
+	    {
+	      char exp1[5], exp2[5];
+	      expand (exp1, *ep);
+	      expand (exp2, lt->left);
+	      printf ("  leaves '%s', expected '%s'\n", exp1, exp2);
+	    }
+	  if (save_errno != lt->err)
+	    printf ("  errno %d (%s)  instead of %d (%s)\n",
+		    save_errno, strerror (save_errno),
+		    lt->err, strerror (lt->err));
+	  status = 1;
+	}
+    }
+
+  sprintf (buf, "%f", strtod ("-0.0", NULL));
+  if (strcmp (buf, "-0.000000") != 0)
+    {
+      printf ("  strtod (\"-0.0\", NULL) returns \"%s\"\n", buf);
+      status = 1;
+    }
+
+  const char input[] = "3752432815e-39";
+
+  float f1 = strtold (input, NULL);
+  float f2;
+  float f3 = strtof (input, NULL);
+  sscanf (input, "%g", &f2);
+
+  if (f1 != f2)
+    {
+      printf ("f1 = %a != f2 = %a\n", f1, f2);
+      status = 1;
+    }
+  if (f1 != f3)
+    {
+      printf ("f1 = %a != f3 = %a\n", f1, f3);
+      status = 1;
+    }
+  if (f2 != f3)
+    {
+      printf ("f2 = %a != f3 = %a\n", f2, f3);
+      status = 1;
+    }
+
+  const char input2[] = "+1.000000000116415321826934814453125";
+  if (strtold (input2, NULL) != +1.000000000116415321826934814453125L)
+    {
+      printf ("input2: %La != %La\n", strtold (input2, NULL),
+	      +1.000000000116415321826934814453125L);
+      status = 1;
+    }
+
+  static struct { const char *str; long double l; } ltests[] =
+    {
+      { "42.0000000000000000001", 42.0000000000000000001L },
+      { "42.00000000000000000001", 42.00000000000000000001L },
+      { "42.000000000000000000001", 42.000000000000000000001L }
+    };
+  int n;
+  for (n = 0; n < sizeof (ltests) / sizeof (ltests[0]); ++n)
+    if (strtold (ltests[n].str, NULL) != ltests[n].l)
+      {
+	printf ("ltests[%d]: %La != %La\n", n,
+		strtold (ltests[n].str, NULL), ltests[n].l);
+	status = 1;
+      }
+
+  status |= long_dbl ();
+
+  status |= locale_test ();
+
+  return status ? EXIT_FAILURE : EXIT_SUCCESS;
+}
+
+static void
+expand (dst, c)
+     char *dst;
+     register int c;
+{
+  if (isprint (c))
+    {
+      dst[0] = c;
+      dst[1] = '\0';
+    }
+  else
+    (void) sprintf (dst, "%#.3o", (unsigned int) c);
+}
+
+static int
+long_dbl (void)
+{
+  /* Regenerate this string using
+
+     echo '(2^53-1)*2^(1024-53)' | bc | sed 's/\([^\]*\)\\*$/    "\1"/'
+
+  */
+  static const char longestdbl[] =
+    "17976931348623157081452742373170435679807056752584499659891747680315"
+    "72607800285387605895586327668781715404589535143824642343213268894641"
+    "82768467546703537516986049910576551282076245490090389328944075868508"
+    "45513394230458323690322294816580855933212334827479782620414472316873"
+    "8177180919299881250404026184124858368";
+  double d = strtod (longestdbl, NULL);
+
+  printf ("strtod (\"%s\", NULL) = %g\n", longestdbl, d);
+
+  if (d != 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000)
+    return 1;
+
+  return 0;
+}
+
+/* Perform a few tests in a locale with thousands separators.  */
+static int
+locale_test (void)
+{
+  static const struct
+  {
+    const char *loc;
+    const char *str;
+    double exp;
+    ptrdiff_t nread;
+  } tests[] =
+    {
+      { "de_DE.UTF-8", "1,5", 1.5, 3 },
+      { "de_DE.UTF-8", "1.5", 1.0, 1 },
+      { "de_DE.UTF-8", "1.500", 1500.0, 5 },
+      { "de_DE.UTF-8", "36.893.488.147.419.103.232", 0x1.0p65, 26 }
+    };
+#define ntests (sizeof (tests) / sizeof (tests[0]))
+  size_t n;
+  int result = 0;
+
+  puts ("\nLocale tests");
+
+  for (n = 0; n < ntests; ++n)
+    {
+      double d;
+      char *endp;
+
+      if (setlocale (LC_ALL, tests[n].loc) == NULL)
+	{
+	  printf ("cannot set locale %s\n", tests[n].loc);
+	  result = 1;
+	  continue;
+	}
+
+      /* We call __strtod_interal here instead of strtod to tests the
+	 handling of grouping.  */
+      d = __strtod_internal (tests[n].str, &endp, 1);
+      if (d != tests[n].exp)
+	{
+	  printf ("strtod(\"%s\") returns %g and not %g\n",
+		  tests[n].str, d, tests[n].exp);
+	  result = 1;
+	}
+      else if (endp - tests[n].str != tests[n].nread)
+	{
+	  printf ("strtod(\"%s\") read %td bytes and not %td\n",
+		  tests[n].str, endp - tests[n].str, tests[n].nread);
+	  result = 1;
+	}
+    }
+
+  if (result == 0)
+    puts ("all OK");
+
+  return result;
+}
Index: trunk/src/libctests/glibc/stdlib/tst-strtol.c
===================================================================
--- trunk/src/libctests/glibc/stdlib/tst-strtol.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/tst-strtol.c	(revision 2036)
@@ -0,0 +1,187 @@
+/* My bet is this was written by Chris Torek.
+   I reformatted and ansidecl-ized it, and tweaked it a little.  */
+
+#include <ctype.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+
+struct ltest
+  {
+    const char *str;		/* Convert this.  */
+    unsigned long int expect;	/* To get this.  */
+    int base;			/* Use this base.  */
+    char left;			/* With this left over.  */
+    int err;			/* And this in errno.  */
+  };
+static const struct ltest tests[] =
+  {
+  /* First, signed numbers:  */
+  /* simple... */
+  {"123", 123, 0, 0, 0},
+  {"+123", 123, 0, 0, 0},
+  {"  123", 123, 0, 0, 0},
+  {" 123 ", 123, 0, ' ', 0},
+  {"   -17", -17, 0, 0, 0},
+
+  /* implicit base... */
+  {"0123", 0123, 0, 0, 0},
+  {"0123a", 0123, 0, 'a', 0},
+  {"01239", 0123, 0, '9', 0},
+  {"0x123", 0x123, 0, 0, 0},
+  {"-0x123", -0x123, 0, 0, 0},
+  {"0x0xc", 0, 0, 'x', 0},
+  {" +0x123fg", 0x123f, 0, 'g', 0},
+
+  /* explicit base... */
+  {"123", 0x123, 16, 0, 0},
+  {"0x123", 0x123, 16, 0, 0},
+  {"123", 0123, 8, 0, 0},
+  {"0123", 0123, 8, 0, 0},
+  {"0123", 123, 10, 0, 0},
+  {"0x123", 0, 10, 'x', 0},
+
+  /* case insensitivity... */
+  {"abcd", 0xabcd, 16, 0, 0},
+  {"AbCd", 0xabcd, 16, 0, 0},
+  {"0xABCD", 0xabcd, 16, 0, 0},
+  {"0Xabcd", 0xabcd, 16, 0, 0},
+
+  /* odd bases... */
+  {"0xyz", 33 * 35 + 34, 35, 'z', 0},
+  {"yz!", 34 * 36 + 35, 36, '!', 0},
+  {"-yz", -(34*36 + 35), 36, 0, 0},
+  {"GhI4", ((16*20 + 17)*20 + 18)*20 + 4, 20, 0, 0},
+
+  /* extremes... */
+#if LONG_MAX == 0x7fffffff
+  {"2147483647", 2147483647, 0, 0, 0},
+  {"2147483648", 2147483647, 0, 0, ERANGE},
+  {"214748364888", 2147483647, 0, 0, ERANGE},
+  {"2147483650", 2147483647, 0, 0, ERANGE},
+  {"-2147483648", 0x80000000, 0, 0, 0},
+  {"-2147483649", 0x80000000, 0, 0, ERANGE},
+  {"0x1122334455z", 2147483647, 16, 'z', ERANGE},
+#else
+  {"9223372036854775807", 9223372036854775807, 0, 0, 0},
+  {"9223372036854775808", 9223372036854775807, 0, 0, ERANGE},
+  {"922337203685477580777", 9223372036854775807, 0, 0, ERANGE},
+  {"9223372036854775810", 9223372036854775807, 0, 0, ERANGE},
+  {"-2147483648", -2147483648, 0, 0, 0},
+  {"-9223372036854775808", 0x8000000000000000, 0, 0, 0},
+  {"-9223372036854775809", 0x8000000000000000, 0, 0, ERANGE},
+  {"0x112233445566778899z", 9223372036854775807, 16, 'z', ERANGE},
+  {"0xFFFFFFFFFFFF00FF" , 9223372036854775807, 0, 0, ERANGE},
+#endif
+  {NULL, 0, 0, 0, 0},
+
+  /* Then unsigned.  */
+  {"  0", 0, 0, 0, 0},
+  {"0xffffffffg", 0xffffffff, 0, 'g', 0},
+#if LONG_MAX == 0x7fffffff
+  {"-0xfedcba98", 0x01234568, 0, 0, 0},
+  {"0xf1f2f3f4f5", 0xffffffff, 0, 0, ERANGE},
+  {"-0x123456789", 0xffffffff, 0, 0, ERANGE},
+#else
+  {"0xffffffffffffffffg", 0xffffffffffffffff, 0, 'g', 0},
+  {"-0xfedcba987654321", 0xf0123456789abcdf, 0, 0, 0},
+  {"0xf1f2f3f4f5f6f7f8f9", 0xffffffffffffffff, 0, 0, ERANGE},
+  {"-0x123456789abcdef01", 0xffffffffffffffff, 0, 0, ERANGE},
+#endif
+  {NULL, 0, 0, 0, 0},
+  };
+
+/* Prototypes for local functions.  */
+static void expand (char *dst, int c);
+
+int
+main (void)
+{
+  register const struct ltest *lt;
+  char *ep;
+  int status = 0;
+  int save_errno;
+
+  for (lt = tests; lt->str != NULL; ++lt)
+    {
+      register long int l;
+
+      errno = 0;
+      l = strtol (lt->str, &ep, lt->base);
+      save_errno = errno;
+      printf ("strtol(\"%s\", , %d) test %u",
+	      lt->str, lt->base, (unsigned int) (lt - tests));
+      if (l == (long int) lt->expect && *ep == lt->left
+	  && save_errno == lt->err)
+	puts("\tOK");
+      else
+	{
+	  puts("\tBAD");
+	  if (l != (long int) lt->expect)
+	    printf("  returns %ld, expected %ld\n",
+		   l, (long int) lt->expect);
+	  if (lt->left != *ep)
+	    {
+	      char exp1[5], exp2[5];
+	      expand (exp1, *ep);
+	      expand (exp2, lt->left);
+	      printf ("  leaves '%s', expected '%s'\n", exp1, exp2);
+	    }
+	  if (save_errno != lt->err)
+	    printf ("  errno %d (%s)  instead of %d (%s)\n",
+		    save_errno, strerror (save_errno),
+		    lt->err, strerror (lt->err));
+	  status = 1;
+	}
+    }
+
+  for (++lt; lt->str != NULL; lt++)
+    {
+      register unsigned long int ul;
+
+      errno = 0;
+      ul = strtoul (lt->str, &ep, lt->base);
+      save_errno = errno;
+      printf ("strtoul(\"%s\", , %d) test %u",
+	      lt->str, lt->base, (unsigned int) (lt - tests));
+      if (ul == lt->expect && *ep == lt->left && save_errno == lt->err)
+	puts("\tOK");
+      else
+	{
+	  puts ("\tBAD");
+	  if (ul != lt->expect)
+	    printf ("  returns %lu, expected %lu\n",
+		    ul, lt->expect);
+	  if (lt->left != *ep)
+	    {
+	      char exp1[5], exp2[5];
+	      expand (exp1, *ep);
+	      expand (exp2, lt->left);
+	      printf ("  leaves '%s', expected '%s'\n", exp1, exp2);
+	    }
+	  if (save_errno != lt->err)
+	    printf ("  errno %d (%s) instead of %d (%s)\n",
+		    save_errno, strerror (save_errno),
+		    lt->err, strerror (lt->err));
+	  status = 1;
+	}
+    }
+
+  return status ? EXIT_FAILURE : EXIT_SUCCESS;
+}
+
+static void
+expand (dst, c)
+     char *dst;
+     int c;
+{
+  if (isprint (c))
+    {
+      dst[0] = c;
+      dst[1] = '\0';
+    }
+  else
+    (void) sprintf (dst, "%#.3o", (unsigned int) c);
+}
Index: trunk/src/libctests/glibc/stdlib/tst-strtoll.c
===================================================================
--- trunk/src/libctests/glibc/stdlib/tst-strtoll.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/tst-strtoll.c	(revision 2036)
@@ -0,0 +1,175 @@
+/* My bet is this was written by Chris Torek.
+   I reformatted and ansidecl-ized it, and tweaked it a little.  */
+
+#include <ctype.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+
+struct ltest
+  {
+    const char *str;		/* Convert this.  */
+    unsigned long long int expect;	/* To get this.  */
+    int base;			/* Use this base.  */
+    char left;			/* With this left over.  */
+    int err;			/* And this in errno.  */
+  };
+static const struct ltest tests[] =
+  {
+  /* First, signed numbers:  */
+  /* simple... */
+  {"123", 123, 0, 0, 0},
+  {"+123", 123, 0, 0, 0},
+  {"  123", 123, 0, 0, 0},
+  {" 123 ", 123, 0, ' ', 0},
+  {"   -17", -17, 0, 0, 0},
+
+  /* implicit base... */
+  {"0123", 0123, 0, 0, 0},
+  {"0123a", 0123, 0, 'a', 0},
+  {"01239", 0123, 0, '9', 0},
+  {"0x123", 0x123, 0, 0, 0},
+  {"-0x123", -0x123, 0, 0, 0},
+  {"0x0xc", 0, 0, 'x', 0},
+  {" +0x123fg", 0x123f, 0, 'g', 0},
+
+  /* explicit base... */
+  {"123", 0x123, 16, 0, 0},
+  {"0x123", 0x123, 16, 0, 0},
+  {"123", 0123, 8, 0, 0},
+  {"0123", 0123, 8, 0, 0},
+  {"0123", 123, 10, 0, 0},
+  {"0x123", 0, 10, 'x', 0},
+
+  /* case insensitivity... */
+  {"abcd", 0xabcd, 16, 0, 0},
+  {"AbCd", 0xabcd, 16, 0, 0},
+  {"0xABCD", 0xabcd, 16, 0, 0},
+  {"0Xabcd", 0xabcd, 16, 0, 0},
+
+  /* odd bases... */
+  {"0xyz", 33 * 35 + 34, 35, 'z', 0},
+  {"yz!", 34 * 36 + 35, 36, '!', 0},
+  {"-yz", -(34*36 + 35), 36, 0, 0},
+  {"GhI4", ((16*20 + 17)*20 + 18)*20 + 4, 20, 0, 0},
+
+  /* special case for the 32-bit version of strtoll,
+     from a ncftp configure test */
+  {"99000000001", 1000000000ll * 99ll + 1ll, 0, 0},
+
+  /* extremes... */
+  {"9223372036854775807", 9223372036854775807ll, 0, 0, 0},
+  {"9223372036854775808", 9223372036854775807ll, 0, 0, ERANGE},
+  {"922337203685477580777", 9223372036854775807ll, 0, 0, ERANGE},
+  {"9223372036854775810", 9223372036854775807ll, 0, 0, ERANGE},
+  {"-2147483648", -2147483648ll, 0, 0, 0},
+  {"-9223372036854775808", -9223372036854775807ll - 1, 0, 0, 0},
+  {"-9223372036854775809", -9223372036854775807ll - 1, 0, 0, ERANGE},
+  {"0x112233445566778899z", 9223372036854775807ll, 16, 'z', ERANGE},
+  {"0xFFFFFFFFFFFF00FF" , 9223372036854775807ll, 0, 0, ERANGE},
+  {NULL, 0, 0, 0, 0},
+
+  /* Then unsigned.  */
+  {"  0", 0, 0, 0, 0},
+  {"0xffffffffg", 0xffffffff, 0, 'g', 0},
+  {"0xffffffffffffffffg", 0xffffffffffffffffull, 0, 'g', 0},
+  {"-0xfedcba987654321", 0xf0123456789abcdfull, 0, 0, 0},
+  {"0xf1f2f3f4f5f6f7f8f9", 0xffffffffffffffffull, 0, 0, ERANGE},
+  {"-0x123456789abcdef01", 0xffffffffffffffffull, 0, 0, ERANGE},
+  {NULL, 0, 0, 0, 0},
+  };
+
+/* Prototypes for local functions.  */
+static void expand (char *dst, int c);
+
+int
+main (void)
+{
+  register const struct ltest *lt;
+  char *ep;
+  int status = 0;
+  int save_errno;
+
+  for (lt = tests; lt->str != NULL; ++lt)
+    {
+      register long long int l;
+
+      errno = 0;
+      l = strtoll (lt->str, &ep, lt->base);
+      save_errno = errno;
+      printf ("strtoll(\"%s\", , %d) test %u",
+	      lt->str, lt->base, (unsigned int) (lt - tests));
+      if (l == (long long int) lt->expect && *ep == lt->left
+	  && save_errno == lt->err)
+	puts("\tOK");
+      else
+	{
+	  puts("\tBAD");
+	  if (l != (long long int) lt->expect)
+	    printf("  returns %lld, expected %lld\n",
+		   l, (long long int) lt->expect);
+	  if (lt->left != *ep)
+	    {
+	      char exp1[5], exp2[5];
+	      expand (exp1, *ep);
+	      expand (exp2, lt->left);
+	      printf ("  leaves '%s', expected '%s'\n", exp1, exp2);
+	    }
+	  if (save_errno != lt->err)
+	    printf ("  errno %d (%s)  instead of %d (%s)\n",
+		    save_errno, strerror (save_errno),
+		    lt->err, strerror (lt->err));
+	  status = 1;
+	}
+    }
+
+  for (++lt; lt->str != NULL; lt++)
+    {
+      register unsigned long long int ul;
+
+      errno = 0;
+      ul = strtoull (lt->str, &ep, lt->base);
+      save_errno = errno;
+      printf ("strtoull(\"%s\", , %d) test %u",
+	      lt->str, lt->base, (unsigned int) (lt - tests));
+      if (ul == lt->expect && *ep == lt->left && save_errno == lt->err)
+	puts("\tOK");
+      else
+	{
+	  puts ("\tBAD");
+	  if (ul != lt->expect)
+	    printf ("  returns %llu, expected %llu\n",
+		    ul, lt->expect);
+	  if (lt->left != *ep)
+	    {
+	      char exp1[5], exp2[5];
+	      expand (exp1, *ep);
+	      expand (exp2, lt->left);
+	      printf ("  leaves '%s', expected '%s'\n", exp1, exp2);
+	    }
+	  if (save_errno != lt->err)
+	    printf ("  errno %d (%s) instead of %d (%s)\n",
+		    save_errno, strerror (save_errno),
+		    lt->err, strerror (lt->err));
+	  status = 1;
+	}
+    }
+
+  return status ? EXIT_FAILURE : EXIT_SUCCESS;
+}
+
+static void
+expand (dst, c)
+     char *dst;
+     int c;
+{
+  if (isprint (c))
+    {
+      dst[0] = c;
+      dst[1] = '\0';
+    }
+  else
+    (void) sprintf (dst, "%#.3o", (unsigned int) c);
+}
Index: trunk/src/libctests/glibc/stdlib/tst-system.c
===================================================================
--- trunk/src/libctests/glibc/stdlib/tst-system.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/tst-system.c	(revision 2036)
@@ -0,0 +1,31 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdlib.h>
+
+
+static int
+do_test (void)
+{
+  return system (":");
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/stdlib/tst-xpg-basename.c
===================================================================
--- trunk/src/libctests/glibc/stdlib/tst-xpg-basename.c	(revision 2036)
+++ trunk/src/libctests/glibc/stdlib/tst-xpg-basename.c	(revision 2036)
@@ -0,0 +1,67 @@
+/* Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@suse.de>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <libgen.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static struct
+{
+  const char *path;
+  const char *file;
+} tests [] =
+{
+  { "/dir/file", "file" },
+  { "file", "file"},
+  { "/dir/file///", "file" },
+  { "../file", "file" },
+  { "/", "/" },
+  { NULL, "."},
+  { "", "."}
+};
+
+
+int
+main (void)
+{
+  size_t i = 0;
+  int errors = 0;
+  char path[1024];
+  char *file;
+
+  for (i = 0; i < sizeof (tests) / sizeof (tests [0]); ++i)
+    {
+      if (tests [i].path == NULL)
+	file = __xpg_basename (NULL);
+      else
+	{
+	  strcpy (path, tests [i].path);
+	  file = __xpg_basename (path);
+	}
+      if (strcmp (file, tests [i].file))
+	{
+	  printf ("Test with `%s' failed: Result is: `%s'.\n",
+		  (tests [i].path == NULL ? "NULL" : tests [i].path), file);
+	  errors = 1;
+	}
+    }
+
+  return errors;
+}
Index: trunk/src/libctests/glibc/string/Makefile
===================================================================
--- trunk/src/libctests/glibc/string/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/string/Makefile	(revision 2036)
@@ -0,0 +1,78 @@
+# Copyright (C) 1991-1999,2000,2001,2002, 2005 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Sub-makefile for string portion of library.
+#
+subdir	:= string
+
+headers	:= string.h strings.h memory.h endian.h bits/endian.h \
+	   argz.h envz.h byteswap.h bits/byteswap.h bits/string.h \
+	   bits/string2.h bits/string3.h
+
+routines	:= strcat strchr strcmp strcoll strcpy strcspn		\
+		   strverscmp strdup strndup				\
+		   strerror _strerror strlen strnlen			\
+		   strncat strncmp strncpy				\
+		   strrchr strpbrk strsignal strspn strstr strtok	\
+		   strtok_r strxfrm memchr memcmp memmove memset	\
+		   mempcpy bcopy bzero ffs ffsll stpcpy stpncpy		\
+		   strcasecmp strncase strcasecmp_l strncase_l		\
+		   memccpy memcpy wordcopy strsep strcasestr		\
+		   swab strfry memfrob memmem rawmemchr strchrnul	\
+		   $(addprefix argz-,append count create ctsep next	\
+			             delete extract insert stringify	\
+				     addsep replace)			\
+		   envz basename					\
+		   strcoll_l strxfrm_l string-inlines memrchr		\
+		   xpg-strerror
+
+# Gcc internally generates calls to unbounded memcpy and memset
+# for -fbounded-pointer compiles.  Glibc uses memchr for explicit checks.
+o-objects.ob	:= memcpy.o memset.o memchr.o
+
+strop-tests	:= memchr memcmp memcpy memmove mempcpy memset memccpy	\
+		   stpcpy stpncpy strcat strchr strcmp strcpy strcspn	\
+		   strlen strncmp strncpy strpbrk strrchr strspn
+tests		:= tester inl-tester noinl-tester testcopy test-ffs	\
+		   tst-strlen stratcliff tst-svc tst-inlcall		\
+		   bug-strncat1 bug-strspn1 bug-strpbrk1 tst-bswap	\
+		   tst-strtok tst-strxfrm bug-strcoll1 tst-strfry	\
+		   $(addprefix test-,$(strop-tests))
+distribute	:= memcopy.h pagecopy.h tst-svc.expect test-string.h
+
+
+include ../Rules
+
+tester-ENV = LANGUAGE=C
+inl-tester-ENV = LANGUAGE=C
+noinl-tester-ENV = LANGUAGE=C
+tst-strxfrm-ENV = LOCPATH=$(common-objpfx)localedata
+bug-strcoll1-ENV = LOCPATH=$(common-objpfx)localedata
+CFLAGS-noinl-tester.c = -fno-builtin
+CFLAGS-tst-strlen.c = -fno-builtin
+CFLAGS-stratcliff.c = -fno-builtin
+CFLAGS-test-ffs.c = -fno-builtin
+
+ifeq ($(cross-compiling),no)
+tests: $(objpfx)tst-svc.out
+$(objpfx)tst-svc.out: tst-svc.input $(objpfx)tst-svc
+	GCONV_PATH=$(common-objpfx)iconvdata LC_ALL=C \
+	  $(built-program-cmd) < $(word 1,$^) > $@
+	-cmp tst-svc.expect $(objpfx)tst-svc.out
+endif
Index: trunk/src/libctests/glibc/string/bug-strcoll1.c
===================================================================
--- trunk/src/libctests/glibc/string/bug-strcoll1.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/bug-strcoll1.c	(revision 2036)
@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include <string.h>
+#include <locale.h>
+
+int
+main (void)
+{
+  const char t1[] = "0-0-0-0-0-0-0-0-0-0.COM";
+  const char t2[] = "00000-00000.COM";
+  int res1;
+  int res2;
+
+  setlocale (LC_ALL, "en_US.ISO-8859-1");
+
+  res1 = strcoll (t1, t2);
+  printf ("strcoll (\"%s\", \"%s\") = %d\n", t1, t2, res1);
+  res2 = strcoll (t2, t1);
+  printf ("strcoll (\"%s\", \"%s\") = %d\n", t2, t1, res2);
+
+  return ((res1 == 0 && res2 != 0)
+	  || (res1 != 0 && res2 == 0)
+	  || (res1 < 0 && res2 < 0)
+	  || (res1 > 0 && res2 > 0));
+}
Index: trunk/src/libctests/glibc/string/bug-strncat1.c
===================================================================
--- trunk/src/libctests/glibc/string/bug-strncat1.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/bug-strncat1.c	(revision 2036)
@@ -0,0 +1,31 @@
+/* Test case by Joseph S. Myers <jsm28@cam.ac.uk>.  */
+#undef __USE_STRING_INLINES
+#define __USE_STRING_INLINES
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+char d[3] = "\0\1\2";
+
+int
+main (void)
+{
+  strncat (d, "\5\6", 1);
+  if (d[0] != '\5')
+    {
+      puts ("d[0] != '\\5'");
+      exit (1);
+    }
+  if (d[1] != '\0')
+    {
+      puts ("d[1] != '\\0'");
+      exit (1);
+    }
+  if (d[2] != '\2')
+    {
+      puts ("d[2] != '\\2'");
+      exit (1);
+    }
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/string/bug-strpbrk1.c
===================================================================
--- trunk/src/libctests/glibc/string/bug-strpbrk1.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/bug-strpbrk1.c	(revision 2036)
@@ -0,0 +1,19 @@
+/* Test case by Joseph S. Myers <jsm28@cam.ac.uk>.  */
+#undef __USE_STRING_INLINES
+#define __USE_STRING_INLINES
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+int
+main (void)
+{
+  const char *a = "abc";
+  const char *b = a;
+
+  strpbrk (b++, "");
+  if (b != a + 1)
+    return 1;
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/string/bug-strspn1.c
===================================================================
--- trunk/src/libctests/glibc/string/bug-strspn1.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/bug-strspn1.c	(revision 2036)
@@ -0,0 +1,19 @@
+/* Test case by Joseph S. Myers <jsm28@cam.ac.uk>.  */
+#undef __USE_STRING_INLINES
+#define __USE_STRING_INLINES
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+int
+main (void)
+{
+  const char *a = "abc";
+  const char *b = a;
+
+  strspn (b++, "");
+  if (b != a + 1)
+    return 1;
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/string/inl-tester.c
===================================================================
--- trunk/src/libctests/glibc/string/inl-tester.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/inl-tester.c	(revision 2036)
@@ -0,0 +1,6 @@
+/* We want to test the inline functions here.  */
+
+#define DO_STRING_INLINES
+#undef __USE_STRING_INLINES
+#define __USE_STRING_INLINES 1
+#include "tester.c"
Index: trunk/src/libctests/glibc/string/noinl-tester.c
===================================================================
--- trunk/src/libctests/glibc/string/noinl-tester.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/noinl-tester.c	(revision 2036)
@@ -0,0 +1,4 @@
+/* We don't want to test any of the inline functions here.  */
+
+#define __NO_STRING_INLINES 1
+#include "tester.c"
Index: trunk/src/libctests/glibc/string/test-ffs.c
===================================================================
--- trunk/src/libctests/glibc/string/test-ffs.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/test-ffs.c	(revision 2036)
@@ -0,0 +1,64 @@
+/* Copyright (C) 1994, 1997, 2000, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+     On-Line Applications Research Corporation.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+int
+main (void)
+{
+  int failures = 0;
+  int i;
+
+  auto void try (const char *name, long long int param, int value,
+		 int expected);
+
+  void try (const char *name, long long int param, int value, int expected)
+    {
+      if (value != expected)
+	{
+	  printf ("%s(%#llx) expected %d got %d\n",
+		  name, param, expected, value);
+	  ++failures;
+	}
+      else
+	printf ("%s(%#llx) as expected %d\n", name, param, value);
+    }
+
+#define TEST(fct, type) \
+  try (#fct, 0, fct ((type) 0), 0);					      \
+  for (i=0 ; i < 8 * sizeof (type); i++)				      \
+    try (#fct, 1ll << i, fct (((type) 1) << i), i + 1);			      \
+  for (i=0 ; i < 8 * sizeof (type) ; i++)				      \
+    try (#fct, (~((type) 0) >> i) << i, fct ((~((type) 0) >> i) << i), i + 1);\
+  try (#fct, 0x80008000, fct ((type) 0x80008000), 16)
+
+  TEST (ffs, int);
+  TEST (ffsl, long int);
+  TEST (ffsll, long long int);
+
+  if (failures)
+    printf ("Test FAILED!  %d failure%s.\n", failures, &"s"[failures == 1]);
+  else
+    puts ("Test succeeded.");
+
+  return failures;
+}
Index: trunk/src/libctests/glibc/string/test-memccpy.c
===================================================================
--- trunk/src/libctests/glibc/string/test-memccpy.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/test-memccpy.c	(revision 2036)
@@ -0,0 +1,293 @@
+/* Test and measure memccpy functions.
+   Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Jakub Jelinek <jakub@redhat.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define TEST_MAIN
+#include "test-string.h"
+
+void *simple_memccpy (void *, const void *, int, size_t);
+void *stupid_memccpy (void *, const void *, int, size_t);
+
+IMPL (stupid_memccpy, 0)
+IMPL (simple_memccpy, 0)
+IMPL (memccpy, 1)
+
+void *
+simple_memccpy (void *dst, const void *src, int c, size_t n)
+{
+  const char *s = src;
+  char *d = dst;
+
+  while (n-- > 0)
+    if ((*d++ = *s++) == (char) c)
+      return d;
+
+  return NULL;
+}
+
+void *
+stupid_memccpy (void *dst, const void *src, int c, size_t n)
+{
+  void *p = memchr (src, c, n);
+
+  if (p != NULL)
+    return mempcpy (dst, src, p - src + 1);
+
+  memcpy (dst, src, n);
+  return NULL;
+}
+
+typedef void *(*proto_t) (void *, const void *, int c, size_t);
+
+static void
+do_one_test (impl_t *impl, void *dst, const void *src, int c, size_t len,
+	     size_t n)
+{
+  void *expect = len > n ? NULL : (char *) dst + len;
+  if (CALL (impl, dst, src, c, n) != expect)
+    {
+      error (0, 0, "Wrong result in function %s %p %p", impl->name,
+	     CALL (impl, dst, src, c, n), expect);
+      ret = 1;
+      return;
+    }
+
+  if (memcmp (dst, src, len > n ? n : len) != 0)
+    {
+      error (0, 0, "Wrong result in function %s", impl->name);
+      ret = 1;
+      return;
+    }
+
+  if (HP_TIMING_AVAIL)
+    {
+      hp_timing_t start __attribute__ ((unused));
+      hp_timing_t stop __attribute__ ((unused));
+      hp_timing_t best_time = ~ (hp_timing_t) 0;
+      size_t i;
+
+      for (i = 0; i < 32; ++i)
+	{
+	  HP_TIMING_NOW (start);
+	  CALL (impl, dst, src, c, n);
+	  HP_TIMING_NOW (stop);
+	  HP_TIMING_BEST (best_time, start, stop);
+	}
+
+      printf ("\t%zd", (size_t) best_time);
+    }
+}
+
+static void
+do_test (size_t align1, size_t align2, int c, size_t len, size_t n,
+	 int max_char)
+{
+  size_t i;
+  char *s1, *s2;
+
+  align1 &= 7;
+  if (align1 + len >= page_size)
+    return;
+
+  align2 &= 7;
+  if (align2 + len >= page_size)
+    return;
+
+  s1 = buf1 + align1;
+  s2 = buf2 + align2;
+
+  for (i = 0; i < len - 1; ++i)
+    {
+      s1[i] = 32 + 23 * i % (max_char - 32);
+      if (s1[i] == (char) c)
+	--s1[i];
+    }
+  s1[len - 1] = c;
+  for (i = len; i + align1 < page_size && i < len + 64; ++i)
+    s1[i] = 32 + 32 * i % (max_char - 32);
+
+  if (HP_TIMING_AVAIL)
+    printf ("Length %4zd, n %4zd, char %d, alignment %2zd/%2zd:", len, n, c, align1, align2);
+
+  FOR_EACH_IMPL (impl, 0)
+    do_one_test (impl, s2, s1, c, len, n);
+
+  if (HP_TIMING_AVAIL)
+    putchar ('\n');
+}
+
+static void
+do_random_tests (void)
+{
+  size_t i, j, n, align1, align2, len, size, mode;
+  unsigned char *p1 = buf1 + page_size - 512;
+  unsigned char *p2 = buf2 + page_size - 512;
+  unsigned char *res, c;
+
+  for (n = 0; n < ITERATIONS; n++)
+    {
+      mode = random ();
+      c = random ();
+      if (mode & 1)
+	{
+	  size = random () & 255;
+	  align1 = 512 - size - (random () & 15);
+	  if (mode & 2)
+	    align2 = align1 - (random () & 24);
+	  else
+	    align2 = align1 - (random () & 31);
+	  if (mode & 4)
+	    {
+	      j = align1;
+	      align1 = align2;
+	      align2 = j;
+	    }
+	  if (mode & 8)
+	    len = size - (random () & 31);
+	  else
+	    len = 512;
+	  if (len >= 512)
+	    len = random () & 511;
+	}
+      else
+	{
+	  align1 = random () & 31;
+	  if (mode & 2)
+	    align2 = random () & 31;
+	  else
+	    align2 = align1 + (random () & 24);
+	  len = random () & 511;
+	  j = align1;
+	  if (align2 > j)
+	    j = align2;
+	  if (mode & 4)
+	    {
+	      size = random () & 511;
+	      if (size + j > 512)
+		size = 512 - j - (random() & 31);
+	    }
+	  else
+	    size = 512 - j;
+	  if ((mode & 8) && len + j >= 512)
+	    len = 512 - j - (random () & 7);
+	}
+      j = len + align1 + 64;
+      if (j > 512)
+	j = 512;
+      for (i = 0; i < j; i++)
+	{
+	  if (i == len + align1)
+	    p1[i] = c;
+	  else
+	    {
+	      p1[i] = random () & 255;
+	      if (i >= align1 && i < len + align1 && p1[i] == c)
+		p1[i] = (random () & 127) + 3 + c;
+	    }
+	}
+
+      FOR_EACH_IMPL (impl, 1)
+	{
+	  unsigned char *expect;
+	  memset (p2 - 64, '\1', 512 + 64);
+	  res = CALL (impl, p2 + align2, p1 + align1, (char) c, size);
+	  if (len >= size)
+	    expect = NULL;
+	  else
+	    expect = p2 + align2 + len + 1;
+
+	  if (res != expect)
+	    {
+	      error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %zd, %zd, %zd, %d) %p != %p",
+		     n, impl->name, align1, align2, len, size, c, res, expect);
+	      ret = 1;
+	    }
+	  for (j = 0; j < align2 + 64; ++j)
+	    {
+	      if (p2[j - 64] != '\1')
+		{
+		  error (0, 0, "Iteration %zd - garbage before, %s (%zd, %zd, %zd)",
+			 n, impl->name, align1, align2, len);
+		  ret = 1;
+		  break;
+		}
+	    }
+	  j = align2 + len + 1;
+	  if (size + align2 < j)
+	    j = size + align2;
+	  for (; j < 512; ++j)
+	    {
+	      if (p2[j] != '\1')
+		{
+		  error (0, 0, "Iteration %zd - garbage after, %s (%zd, %zd, %zd)",
+			 n, impl->name, align1, align2, len);
+		  ret = 1;
+		  break;
+		}
+	    }
+	  j = len + 1;
+	  if (size < j)
+	    j = size;
+	  if (memcmp (p1 + align1, p2 + align2, j))
+	    {
+	      error (0, 0, "Iteration %zd - different strings, %s (%zd, %zd, %zd)",
+		     n, impl->name, align1, align2, len);
+	      ret = 1;
+	    }
+	}
+    }
+}
+
+int
+test_main (void)
+{
+  size_t i;
+
+  test_init ();
+
+  printf ("%28s", "");
+  FOR_EACH_IMPL (impl, 0)
+    printf ("\t%s", impl->name);
+  putchar ('\n');
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (i, i, 12, 16, 16, 127);
+      do_test (i, i, 23, 16, 16, 255);
+      do_test (i, 2 * i, 28, 16, 16, 127);
+      do_test (2 * i, i, 31, 16, 16, 255);
+      do_test (8 - i, 2 * i, 1, 1 << i, 2 << i, 127);
+      do_test (2 * i, 8 - i, 17, 2 << i, 1 << i, 127);
+      do_test (8 - i, 2 * i, 0, 1 << i, 2 << i, 255);
+      do_test (2 * i, 8 - i, i, 2 << i, 1 << i, 255);
+    }
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (0, 0, i, 4 << i, 8 << i, 127);
+      do_test (0, 0, i, 16 << i, 8 << i, 127);
+      do_test (8 - i, 2 * i, i, 4 << i, 8 << i, 127);
+      do_test (8 - i, 2 * i, i, 16 << i, 8 << i, 127);
+    }
+
+  do_random_tests ();
+  return ret;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/string/test-memchr.c
===================================================================
--- trunk/src/libctests/glibc/string/test-memchr.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/test-memchr.c	(revision 2036)
@@ -0,0 +1,191 @@
+/* Test and measure memchr functions.
+   Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Jakub Jelinek <jakub@redhat.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define TEST_MAIN
+#include "test-string.h"
+
+typedef char *(*proto_t) (const char *, int, size_t);
+char *simple_memchr (const char *, int, size_t);
+
+IMPL (simple_memchr, 0)
+IMPL (memchr, 1)
+
+char *
+simple_memchr (const char *s, int c, size_t n)
+{
+  while (n--)
+    if (*s++ == (char) c)
+      return (char *) s - 1;
+  return NULL;
+}
+
+static void
+do_one_test (impl_t *impl, const char *s, int c, size_t n, char *exp_res)
+{
+  char *res = CALL (impl, s, c, n);
+  if (res != exp_res)
+    {
+      error (0, 0, "Wrong result in function %s %p %p", impl->name,
+	     res, exp_res);
+      ret = 1;
+      return;
+    }
+
+  if (HP_TIMING_AVAIL)
+    {
+      hp_timing_t start __attribute ((unused));
+      hp_timing_t stop __attribute ((unused));
+      hp_timing_t best_time = ~ (hp_timing_t) 0;
+      size_t i;
+
+      for (i = 0; i < 32; ++i)
+	{
+	  HP_TIMING_NOW (start);
+	  CALL (impl, s, c, n);
+	  HP_TIMING_NOW (stop);
+	  HP_TIMING_BEST (best_time, start, stop);
+	}
+
+      printf ("\t%zd", (size_t) best_time);
+    }
+}
+
+static void
+do_test (size_t align, size_t pos, size_t len, int seek_char)
+{
+  size_t i;
+  char *result;
+
+  align &= 7;
+  if (align + len >= page_size)
+    return;
+
+  for (i = 0; i < len; ++i)
+    {
+      buf1[align + i] = 1 + 23 * i % 127;
+      if (buf1[align + i] == seek_char)
+        buf1[align + i] = seek_char + 1;
+    }
+  buf1[align + len] = 0;
+
+  if (pos < len)
+    {
+      buf1[align + pos] = seek_char;
+      buf1[align + len] = -seek_char;
+      result = buf1 + align + pos;
+    }
+  else
+    {
+      result = NULL;
+      buf1[align + len] = seek_char;
+    }
+
+  if (HP_TIMING_AVAIL)
+    printf ("Length %4zd, alignment %2zd:", pos, align);
+
+  FOR_EACH_IMPL (impl, 0)
+    do_one_test (impl, buf1 + align, seek_char, len, result);
+
+  if (HP_TIMING_AVAIL)
+    putchar ('\n');
+}
+
+static void
+do_random_tests (void)
+{
+  size_t i, j, n, align, pos, len;
+  int seek_char;
+  char *result;
+  unsigned char *p = buf1 + page_size - 512;
+
+  for (n = 0; n < ITERATIONS; n++)
+    {
+      align = random () & 15;
+      pos = random () & 511;
+      if (pos + align >= 512)
+	pos = 511 - align - (random () & 7);
+      len = random () & 511;
+      if (pos >= len)
+	len = pos + (random () & 7);
+      if (len + align >= 512)
+        len = 512 - align - (random () & 7);
+      seek_char = random () & 255;
+      j = len + align + 64;
+      if (j > 512)
+        j = 512;
+
+      for (i = 0; i < j; i++)
+	{
+	  if (i == pos + align)
+	    p[i] = seek_char;
+	  else
+	    {
+	      p[i] = random () & 255;
+	      if (i < pos + align && p[i] == seek_char)
+		p[i] = seek_char + 13;
+	    }
+	}
+
+      if (pos < len)
+	result = p + pos + align;
+      else
+	result = NULL;
+
+      FOR_EACH_IMPL (impl, 1)
+	if (CALL (impl, p + align, seek_char, len) != result)
+	  {
+	    error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %d, %zd, %zd) %p != %p, p %p",
+		   n, impl->name, align, seek_char, len, pos,
+		   CALL (impl, p + align, seek_char, len), result, p);
+	    ret = 1;
+	  }
+    }
+}
+
+int
+test_main (void)
+{
+  size_t i;
+
+  test_init ();
+
+  printf ("%20s", "");
+  FOR_EACH_IMPL (impl, 0)
+    printf ("\t%s", impl->name);
+  putchar ('\n');
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (0, 16 << i, 2048, 23);
+      do_test (i, 64, 256, 23);
+      do_test (0, 16 << i, 2048, 0);
+      do_test (i, 64, 256, 0);
+    }
+  for (i = 1; i < 32; ++i)
+    {
+      do_test (0, i, i + 1, 23);
+      do_test (0, i, i + 1, 0);
+    }
+
+  do_random_tests ();
+  return ret;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/string/test-memcmp.c
===================================================================
--- trunk/src/libctests/glibc/string/test-memcmp.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/test-memcmp.c	(revision 2036)
@@ -0,0 +1,228 @@
+/* Test and measure memcmp functions.
+   Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Jakub Jelinek <jakub@redhat.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define TEST_MAIN
+#include "test-string.h"
+
+typedef int (*proto_t) (const char *, const char *, size_t);
+int simple_memcmp (const char *, const char *, size_t);
+
+IMPL (simple_memcmp, 0)
+IMPL (memcmp, 1)
+
+int
+simple_memcmp (const char *s1, const char *s2, size_t n)
+{
+  int ret = 0;
+
+  while (n--
+	 && (ret = *(unsigned char *) s1++ - *(unsigned char *) s2++) == 0);
+  return ret;
+}
+
+static void
+do_one_test (impl_t *impl, const char *s1, const char *s2, size_t len,
+	     int exp_result)
+{
+  int result = CALL (impl, s1, s2, len);
+  if ((exp_result == 0 && result != 0)
+      || (exp_result < 0 && result >= 0)
+      || (exp_result > 0 && result <= 0))
+    {
+      error (0, 0, "Wrong result in function %s %d %d", impl->name,
+	     result, exp_result);
+      ret = 1;
+      return;
+    }
+
+  if (HP_TIMING_AVAIL)
+    {
+      hp_timing_t start __attribute ((unused));
+      hp_timing_t stop __attribute ((unused));
+      hp_timing_t best_time = ~ (hp_timing_t) 0;
+      size_t i;
+
+      for (i = 0; i < 32; ++i)
+	{
+	  HP_TIMING_NOW (start);
+	  CALL (impl, s1, s2, len);
+	  HP_TIMING_NOW (stop);
+	  HP_TIMING_BEST (best_time, start, stop);
+	}
+
+      printf ("\t%zd", (size_t) best_time);
+    }
+}
+
+static void
+do_test (size_t align1, size_t align2, size_t len, int exp_result)
+{
+  size_t i;
+  char *s1, *s2;
+
+  if (len == 0)
+    return;
+
+  align1 &= 7;
+  if (align1 + len >= page_size)
+    return;
+
+  align2 &= 7;
+  if (align2 + len >= page_size)
+    return;
+
+  s1 = buf1 + align1;
+  s2 = buf2 + align2;
+
+  for (i = 0; i < len; i++)
+    s1[i] = s2[i] = 1 + 23 * i % 255;
+
+  s1[len] = align1;
+  s2[len] = align2;
+  s2[len - 1] -= exp_result;
+
+  if (HP_TIMING_AVAIL)
+    printf ("Length %4zd, alignment %2zd/%2zd:", len, align1, align2);
+
+  FOR_EACH_IMPL (impl, 0)
+    do_one_test (impl, s1, s2, len, exp_result);
+
+  if (HP_TIMING_AVAIL)
+    putchar ('\n');
+}
+
+static void
+do_random_tests (void)
+{
+  size_t i, j, n, align1, align2, pos, len;
+  int result;
+  long r;
+  unsigned char *p1 = buf1 + page_size - 512;
+  unsigned char *p2 = buf2 + page_size - 512;
+
+  for (n = 0; n < ITERATIONS; n++)
+    {
+      align1 = random () & 31;
+      if (random () & 1)
+	align2 = random () & 31;
+      else
+	align2 = align1 + (random () & 24);
+      pos = random () & 511;
+      j = align1;
+      if (align2 > j)
+	j = align2;
+      if (pos + j >= 512)
+	pos = 511 - j - (random () & 7);
+      len = random () & 511;
+      if (len + j >= 512)
+        len = 511 - j - (random () & 7);
+      j = len + align1 + 64;
+      if (j > 512) j = 512;
+      for (i = 0; i < j; ++i)
+	p1[i] = random () & 255;
+      for (i = 0; i < j; ++i)
+	p2[i] = random () & 255;
+
+      result = 0;
+      if (pos >= len)
+	memcpy (p2 + align2, p1 + align1, len);
+      else
+	{
+	  memcpy (p2 + align2, p1 + align1, pos);
+	  if (p2[align2 + pos] == p1[align1 + pos])
+	    {
+	      p2[align2 + pos] = random () & 255;
+	      if (p2[align2 + pos] == p1[align1 + pos])
+		p2[align2 + pos] = p1[align1 + pos] + 3 + (random () & 127);
+	    }
+
+	  if (p1[align1 + pos] < p2[align2 + pos])
+	    result = -1;
+	  else
+	    result = 1;
+	}
+
+      FOR_EACH_IMPL (impl, 1)
+	{
+	  r = CALL (impl, p1 + align1, p2 + align2, len);
+	  /* Test whether on 64-bit architectures where ABI requires
+	     callee to promote has the promotion been done.  */
+	  asm ("" : "=g" (r) : "0" (r));
+	  if ((r == 0 && result)
+	      || (r < 0 && result >= 0)
+	      || (r > 0 && result <= 0))
+	    {
+	      error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %zd, %zd, %zd) %ld != %d, p1 %p p2 %p",
+		     n, impl->name, align1, align2, len, pos, r, result, p1, p2);
+	      ret = 1;
+	    }
+	}
+    }
+}
+
+int
+test_main (void)
+{
+  size_t i;
+
+  test_init ();
+
+  printf ("%23s", "");
+  FOR_EACH_IMPL (impl, 0)
+    printf ("\t%s", impl->name);
+  putchar ('\n');
+
+  for (i = 1; i < 16; ++i)
+    {
+      do_test (i, i, i, 0);
+      do_test (i, i, i, 1);
+      do_test (i, i, i, -1);
+    }
+
+  for (i = 0; i < 16; ++i)
+    {
+      do_test (0, 0, i, 0);
+      do_test (0, 0, i, 1);
+      do_test (0, 0, i, -1);
+    }
+
+  for (i = 1; i < 10; ++i)
+    {
+      do_test (0, 0, 2 << i, 0);
+      do_test (0, 0, 2 << i, 1);
+      do_test (0, 0, 2 << i, -1);
+      do_test (0, 0, 16 << i, 0);
+      do_test (8 - i, 2 * i, 16 << i, 0);
+      do_test (0, 0, 16 << i, 1);
+      do_test (0, 0, 16 << i, -1);
+    }
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (i, 2 * i, 8 << i, 0);
+      do_test (i, 2 * i, 8 << i, 1);
+      do_test (i, 2 * i, 8 << i, -1);
+    }
+
+  do_random_tests ();
+  return ret;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/string/test-memcpy.c
===================================================================
--- trunk/src/libctests/glibc/string/test-memcpy.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/test-memcpy.c	(revision 2036)
@@ -0,0 +1,275 @@
+/* Test and measure memcpy functions.
+   Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Jakub Jelinek <jakub@redhat.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef MEMCPY_RESULT
+# define MEMCPY_RESULT(dst, len) dst
+# define MIN_PAGE_SIZE 131072
+# define TEST_MAIN
+# include "test-string.h"
+
+char *simple_memcpy (char *, const char *, size_t);
+char *builtin_memcpy (char *, const char *, size_t);
+
+IMPL (simple_memcpy, 0)
+IMPL (builtin_memcpy, 0)
+IMPL (memcpy, 1)
+
+char *
+simple_memcpy (char *dst, const char *src, size_t n)
+{
+  char *ret = dst;
+  while (n--)
+    *dst++ = *src++;
+  return ret;
+}
+
+char *
+builtin_memcpy (char *dst, const char *src, size_t n)
+{
+  return __builtin_memcpy (dst, src, n);
+}
+#endif
+
+typedef char *(*proto_t) (char *, const char *, size_t);
+
+static void
+do_one_test (impl_t *impl, char *dst, const char *src,
+	     size_t len)
+{
+  if (CALL (impl, dst, src, len) != MEMCPY_RESULT (dst, len))
+    {
+      error (0, 0, "Wrong result in function %s %p %p", impl->name,
+	     CALL (impl, dst, src, len), MEMCPY_RESULT (dst, len));
+      ret = 1;
+      return;
+    }
+
+  if (memcmp (dst, src, len) != 0)
+    {
+      error (0, 0, "Wrong result in function %s dst \"%s\" src \"%s\"",
+	     impl->name, dst, src);
+      ret = 1;
+      return;
+    }
+
+  if (HP_TIMING_AVAIL)
+    {
+      hp_timing_t start __attribute ((unused));
+      hp_timing_t stop __attribute ((unused));
+      hp_timing_t best_time = ~ (hp_timing_t) 0;
+      size_t i;
+
+      for (i = 0; i < 32; ++i)
+	{
+	  HP_TIMING_NOW (start);
+	  CALL (impl, dst, src, len);
+	  HP_TIMING_NOW (stop);
+	  HP_TIMING_BEST (best_time, start, stop);
+	}
+
+      printf ("\t%zd", (size_t) best_time);
+    }
+}
+
+static void
+do_test (size_t align1, size_t align2, size_t len)
+{
+  size_t i, j;
+  char *s1, *s2;
+
+  align1 &= 63;
+  if (align1 + len >= page_size)
+    return;
+
+  align2 &= 63;
+  if (align2 + len >= page_size)
+    return;
+
+  s1 = buf1 + align1;
+  s2 = buf2 + align2;
+
+  for (i = 0, j = 1; i < len; i++, j += 23)
+    s1[i] = j;
+
+  if (HP_TIMING_AVAIL)
+    printf ("Length %4zd, alignment %2zd/%2zd:", len, align1, align2);
+
+  FOR_EACH_IMPL (impl, 0)
+    do_one_test (impl, s2, s1, len);
+
+  if (HP_TIMING_AVAIL)
+    putchar ('\n');
+}
+
+static void
+do_random_tests (void)
+{
+  size_t i, j, n, align1, align2, len, size1, size2, size;
+  int c;
+  unsigned char *p1, *p2;
+  unsigned char *res;
+
+  for (n = 0; n < ITERATIONS; n++)
+    {
+      if (n == 0)
+	{
+	  len = getpagesize ();
+	  size = len + 512;
+	  size1 = size;
+	  size2 = size;
+	  align1 = 512;
+	  align2 = 512;
+	}
+      else
+	{
+	  if ((random () & 255) == 0)
+	    size = 65536;
+	  else
+	    size = 768;
+	  if (size > page_size)
+	    size = page_size;
+	  size1 = size;
+	  size2 = size;
+	  i = random ();
+	  if (i & 3)
+	    size -= 256;
+	  if (i & 1)
+	    size1 -= 256;
+	  if (i & 2)
+	    size2 -= 256;
+	  if (i & 4)
+	    {
+	      len = random () % size;
+	      align1 = size1 - len - (random () & 31);
+	      align2 = size2 - len - (random () & 31);
+	      if (align1 > size1)
+		align1 = 0;
+	      if (align2 > size2)
+		align2 = 0;
+	    }
+	  else
+	    {
+	      align1 = random () & 63;
+	      align2 = random () & 63;
+	      len = random () % size;
+	      if (align1 + len > size1)
+		align1 = size1 - len;
+	      if (align2 + len > size2)
+		align2 = size2 - len;
+	    }
+	}
+      p1 = buf1 + page_size - size1;
+      p2 = buf2 + page_size - size2;
+      c = random () & 255;
+      j = align1 + len + 256;
+      if (j > size1)
+	j = size1;
+      for (i = 0; i < j; ++i)
+	p1[i] = random () & 255;
+
+      FOR_EACH_IMPL (impl, 1)
+	{
+	  j = align2 + len + 256;
+	  if (j > size2)
+	    j = size2;
+	  memset (p2, c, j);
+	  res = CALL (impl, p2 + align2, p1 + align1, len);
+	  if (res != MEMCPY_RESULT (p2 + align2, len))
+	    {
+	      error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %zd, %zd) %p != %p",
+		     n, impl->name, align1, align2, len, res,
+		     MEMCPY_RESULT (p2 + align2, len));
+	      ret = 1;
+	    }
+	  for (i = 0; i < align2; ++i)
+	    {
+	      if (p2[i] != c)
+		{
+		  error (0, 0, "Iteration %zd - garbage before, %s (%zd, %zd, %zd)",
+			 n, impl->name, align1, align2, len);
+		  ret = 1;
+		  break;
+		}
+	    }
+	  for (i = align2 + len; i < j; ++i)
+	    {
+	      if (p2[i] != c)
+		{
+		  error (0, 0, "Iteration %zd - garbage after, %s (%zd, %zd, %zd)",
+			 n, impl->name, align1, align2, len);
+		  ret = 1;
+		  break;
+		}
+	    }
+	  if (memcmp (p1 + align1, p2 + align2, len))
+	    {
+	      error (0, 0, "Iteration %zd - different strings, %s (%zd, %zd, %zd)",
+		     n, impl->name, align1, align2, len);
+	      ret = 1;
+	    }
+	}
+    }
+}
+
+int
+test_main (void)
+{
+  size_t i;
+
+  test_init ();
+
+  printf ("%23s", "");
+  FOR_EACH_IMPL (impl, 0)
+    printf ("\t%s", impl->name);
+  putchar ('\n');
+
+  for (i = 0; i < 18; ++i)
+    {
+      do_test (0, 0, 1 << i);
+      do_test (i, 0, 1 << i);
+      do_test (0, i, 1 << i);
+      do_test (i, i, 1 << i);
+    }
+
+  for (i = 0; i < 32; ++i)
+    {
+      do_test (0, 0, i);
+      do_test (i, 0, i);
+      do_test (0, i, i);
+      do_test (i, i, i);
+    }
+
+  for (i = 3; i < 32; ++i)
+    {
+      if ((i & (i - 1)) == 0)
+	continue;
+      do_test (0, 0, 16 * i);
+      do_test (i, 0, 16 * i);
+      do_test (0, i, 16 * i);
+      do_test (i, i, 16 * i);
+    }
+
+  do_test (0, 0, getpagesize ());
+
+  do_random_tests ();
+  return ret;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/string/test-memmove.c
===================================================================
--- trunk/src/libctests/glibc/string/test-memmove.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/test-memmove.c	(revision 2036)
@@ -0,0 +1,281 @@
+/* Test and measure memmove functions.
+   Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Jakub Jelinek <jakub@redhat.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define TEST_MAIN
+#include "test-string.h"
+
+typedef char *(*proto_t) (char *, const char *, size_t);
+char *simple_memmove (char *, const char *, size_t);
+
+IMPL (simple_memmove, 0)
+IMPL (memmove, 1)
+
+char *
+simple_memmove (char *dst, const char *src, size_t n)
+{
+  char *ret = dst;
+  if (src < dst)
+    {
+      dst += n;
+      src += n;
+      while (n--)
+	*--dst = *--src;
+    }
+  else
+    while (n--)
+      *dst++ = *src++;
+  return ret;
+}
+
+static void
+do_one_test (impl_t *impl, char *dst, char *src, const char *orig_src,
+	     size_t len)
+{
+  char *res;
+
+  memcpy (src, orig_src, len);
+  res = CALL (impl, dst, src, len);
+  if (res != dst)
+    {
+      error (0, 0, "Wrong result in function %s %p %p", impl->name,
+	     res, dst);
+      ret = 1;
+      return;
+    }
+
+  if (memcmp (dst, orig_src, len) != 0)
+    {
+      error (0, 0, "Wrong result in function %s dst \"%s\" src \"%s\"",
+	     impl->name, dst, src);
+      ret = 1;
+      return;
+    }
+
+  if (HP_TIMING_AVAIL)
+    {
+      hp_timing_t start __attribute ((unused));
+      hp_timing_t stop __attribute ((unused));
+      hp_timing_t best_time = ~ (hp_timing_t) 0;
+      size_t i;
+
+      for (i = 0; i < 32; ++i)
+	{
+	  HP_TIMING_NOW (start);
+	  CALL (impl, dst, src, len);
+	  HP_TIMING_NOW (stop);
+	  HP_TIMING_BEST (best_time, start, stop);
+	}
+
+      printf ("\t%zd", (size_t) best_time);
+    }
+}
+
+static void
+do_test (size_t align1, size_t align2, size_t len)
+{
+  size_t i, j;
+  char *s1, *s2;
+
+  align1 &= 63;
+  if (align1 + len >= page_size)
+    return;
+
+  align2 &= 63;
+  if (align2 + len >= page_size)
+    return;
+
+  s1 = buf1 + align1;
+  s2 = buf2 + align2;
+
+  for (i = 0, j = 1; i < len; i++, j += 23)
+    s1[i] = j;
+
+  if (HP_TIMING_AVAIL)
+    printf ("Length %4zd, alignment %2zd/%2zd:", len, align1, align2);
+
+  FOR_EACH_IMPL (impl, 0)
+    do_one_test (impl, s2, buf2 + align1, s1, len);
+
+  if (HP_TIMING_AVAIL)
+    putchar ('\n');
+}
+
+static void
+do_random_tests (void)
+{
+  size_t i, n, align1, align2, len, size;
+  size_t srcstart, srcend, dststart, dstend;
+  int c;
+  unsigned char *p1, *p2;
+  unsigned char *res;
+
+  for (n = 0; n < ITERATIONS; n++)
+    {
+      if ((random () & 255) == 0)
+	size = 65536;
+      else
+	size = 512;
+      if (size > page_size)
+	size = page_size;
+      if ((random () & 3) == 0)
+	{
+	  len = random () & (size - 1);
+	  align1 = size - len - (random () & 31);
+	  align2 = size - len - (random () & 31);
+	  if (align1 > size)
+	    align1 = 0;
+	  if (align2 > size)
+	    align2 = 0;
+	}
+      else
+	{
+	  align1 = random () & (size / 2 - 1);
+	  align2 = random () & (size / 2 - 1);
+	  len = random () & (size - 1);
+	  if (align1 + len > size)
+	    align1 = size - len;
+	  if (align2 + len > size)
+	    align2 = size - len;
+	}
+
+      p1 = buf1 + page_size - size;
+      p2 = buf2 + page_size - size;
+      c = random () & 255;
+      srcend = align1 + len + 256;
+      if (srcend > size)
+	srcend = size;
+      if (align1 > 256)
+	srcstart = align1 - 256;
+      else
+	srcstart = 0;
+      for (i = srcstart; i < srcend; ++i)
+	p1[i] = random () & 255;
+      dstend = align2 + len + 256;
+      if (dstend > size)
+	dstend = size;
+      if (align2 > 256)
+	dststart = align2 - 256;
+      else
+	dststart = 0;
+
+      FOR_EACH_IMPL (impl, 1)
+	{
+	  memset (p2 + dststart, c, dstend - dststart);
+	  memcpy (p2 + srcstart, p1 + srcstart, srcend - srcstart);
+	  res = CALL (impl, p2 + align2, p2 + align1, len);
+	  if (res != p2 + align2)
+	    {
+	      error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %zd, %zd) %p != %p",
+		     n, impl->name, align1, align2, len, res, p2 + align2);
+	      ret = 1;
+	    }
+	  if (memcmp (p1 + align1, p2 + align2, len))
+	    {
+	      error (0, 0, "Iteration %zd - different strings, %s (%zd, %zd, %zd)",
+		     n, impl->name, align1, align2, len);
+	      ret = 1;
+	    }
+	  for (i = dststart; i < dstend; ++i)
+	    {
+	      if (i >= align2 && i < align2 + len)
+		{
+		  i = align2 + len - 1;
+		  continue;
+		}
+	      if (i >= srcstart && i < srcend)
+		{
+		  i = srcend - 1;
+		  continue;
+		}
+	      if (p2[i] != c)
+		{
+		  error (0, 0, "Iteration %zd - garbage in memset area, %s (%zd, %zd, %zd)",
+			 n, impl->name, align1, align2, len);
+		  ret = 1;
+		  break;
+		}
+	    }
+
+	  if (srcstart < align2
+	      && memcmp (p2 + srcstart, p1 + srcstart,
+			 (srcend > align2 ? align2 : srcend) - srcstart))
+	    {
+	      error (0, 0, "Iteration %zd - garbage before dst, %s (%zd, %zd, %zd)",
+		     n, impl->name, align1, align2, len);
+	      ret = 1;
+	      break;
+	    }
+
+	  i = srcstart > align2 + len ? srcstart : align2 + len;
+	  if (srcend > align2 + len
+	      && memcmp (p2 + i, p1 + i, srcend - i))
+	    {
+	      error (0, 0, "Iteration %zd - garbage after dst, %s (%zd, %zd, %zd)",
+		     n, impl->name, align1, align2, len);
+	      ret = 1;
+	      break;
+	    }
+	}
+    }
+}
+
+int
+test_main (void)
+{
+  size_t i;
+
+  test_init ();
+
+  printf ("%23s", "");
+  FOR_EACH_IMPL (impl, 0)
+    printf ("\t%s", impl->name);
+  putchar ('\n');
+
+  for (i = 0; i < 14; ++i)
+    {
+      do_test (0, 32, 1 << i);
+      do_test (32, 0, 1 << i);
+      do_test (0, i, 1 << i);
+      do_test (i, 0, 1 << i);
+    }
+
+  for (i = 0; i < 32; ++i)
+    {
+      do_test (0, 32, i);
+      do_test (32, 0, i);
+      do_test (0, i, i);
+      do_test (i, 0, i);
+    }
+
+  for (i = 3; i < 32; ++i)
+    {
+      if ((i & (i - 1)) == 0)
+	continue;
+      do_test (0, 32, 16 * i);
+      do_test (32, 0, 16 * i);
+      do_test (0, i, 16 * i);
+      do_test (i, 0, 16 * i);
+    }
+
+  do_random_tests ();
+  return ret;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/string/test-mempcpy.c
===================================================================
--- trunk/src/libctests/glibc/string/test-mempcpy.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/test-mempcpy.c	(revision 2036)
@@ -0,0 +1,38 @@
+/* Test and measure mempcpy functions.
+   Copyright (C) 1999, 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Jakub Jelinek <jakub@redhat.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define MEMCPY_RESULT(dst, len) (dst) + (len)
+#define TEST_MAIN
+#include "test-string.h"
+
+char *simple_mempcpy (char *, const char *, size_t);
+
+IMPL (simple_mempcpy, 0)
+IMPL (mempcpy, 1)
+
+char *
+simple_mempcpy (char *dst, const char *src, size_t n)
+{
+  while (n--)
+    *dst++ = *src++;
+  return dst;
+}
+
+#include "test-memcpy.c"
Index: trunk/src/libctests/glibc/string/test-memset.c
===================================================================
--- trunk/src/libctests/glibc/string/test-memset.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/test-memset.c	(revision 2036)
@@ -0,0 +1,214 @@
+/* Test and measure memset functions.
+   Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Jakub Jelinek <jakub@redhat.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define TEST_MAIN
+#define MIN_PAGE_SIZE 131072
+#include "test-string.h"
+
+typedef char *(*proto_t) (char *, int, size_t);
+char *simple_memset (char *, int, size_t);
+char *builtin_memset (char *, int, size_t);
+
+IMPL (simple_memset, 0)
+IMPL (builtin_memset, 0)
+IMPL (memset, 1)
+
+char *
+simple_memset (char *s, int c, size_t n)
+{
+  char *r = s, *end = s + n;
+  while (r < end)
+    *r++ = c;
+  return s;
+}
+
+char *
+builtin_memset (char *s, int c, size_t n)
+{
+  return __builtin_memset (s, c, n);
+}
+
+static void
+do_one_test (impl_t *impl, char *s, int c, size_t n)
+{
+  char *res = CALL (impl, s, c, n);
+  if (res != s)
+    {
+      error (0, 0, "Wrong result in function %s %p != %p", impl->name,
+	     res, s);
+      ret = 1;
+      return;
+    }
+
+  if (HP_TIMING_AVAIL)
+    {
+      hp_timing_t start __attribute ((unused));
+      hp_timing_t stop __attribute ((unused));
+      hp_timing_t best_time = ~ (hp_timing_t) 0;
+      size_t i;
+
+      for (i = 0; i < 32; ++i)
+	{
+	  HP_TIMING_NOW (start);
+	  CALL (impl, s, c, n);
+	  HP_TIMING_NOW (stop);
+	  HP_TIMING_BEST (best_time, start, stop);
+	}
+
+      printf ("\t%zd", (size_t) best_time);
+    }
+}
+
+static void
+do_test (size_t align, int c, size_t len)
+{
+  align &= 7;
+  if (align + len > page_size)
+    return;
+
+  if (HP_TIMING_AVAIL)
+    printf ("Length %4zd, alignment %2zd, c %2d:", len, align, c);
+
+  FOR_EACH_IMPL (impl, 0)
+    do_one_test (impl, buf1 + align, c, len);
+
+  if (HP_TIMING_AVAIL)
+    putchar ('\n');
+}
+
+static void
+do_random_tests (void)
+{
+  size_t i, j, k, n, align, len, size;
+  int c, o;
+  unsigned char *p, *res;
+
+  for (i = 0; i < 65536; ++i)
+    buf2[i] = random () & 255;
+
+  for (n = 0; n < ITERATIONS; n++)
+    {
+      if ((random () & 31) == 0)
+	size = 65536;
+      else
+	size = 512;
+      p = buf1 + page_size - size;
+      len = random () & (size - 1);
+      align = size - len - (random () & 31);
+      if (align > size)
+	align = size - len;
+      if ((random () & 7) == 0)
+	align &= ~63;
+      if ((random () & 7) == 0)
+	c = 0;
+      else
+	c = random () & 255;
+      o = random () & 255;
+      if (o == c)
+        o = (c + 1) & 255;
+      j = len + align + 128;
+      if (j > size)
+	j = size;
+      if (align >= 128)
+	k = align - 128;
+      else
+	k = 0;
+      for (i = k; i < align; ++i)
+	p[i] = o;
+      for (i = align + len; i < j; ++i)
+	p[i] = o;
+
+      FOR_EACH_IMPL (impl, 1)
+	{
+	  for (i = 0; i < len; ++i)
+	    {
+	      p[i + align] = buf2[i];
+	      if (p[i + align] == c)
+		p[i + align] = o;
+	    }
+	  res = CALL (impl, p + align, c, len);
+	  if (res != p + align)
+	    {
+	      error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %d, %zd) %p != %p",
+		     n, impl->name, align, c, len, res, p + align);
+	      ret = 1;
+	    }
+	  for (i = k; i < align; ++i)
+	    if (p[i] != o)
+	      {
+		error (0, 0, "Iteration %zd - garbage before %s (%zd, %d, %zd)",
+		       n, impl->name, align, c, len);
+		ret = 1;
+		break;
+	      }
+	  for (; i < align + len; ++i)
+	    if (p[i] != c)
+	      {
+		error (0, 0, "Iteration %zd - not cleared correctly %s (%zd, %d, %zd)",
+		       n, impl->name, align, c, len);
+		ret = 1;
+		break;
+	      }
+	  for (; i < j; ++i)
+	    if (p[i] != o)
+	      {
+		error (0, 0, "Iteration %zd - garbage after %s (%zd, %d, %zd)",
+		       n, impl->name, align, c, len);
+		ret = 1;
+		break;
+	      }
+	}
+    }
+}
+
+int
+test_main (void)
+{
+  size_t i;
+  int c;
+
+  test_init ();
+
+  printf ("%24s", "");
+  FOR_EACH_IMPL (impl, 0)
+    printf ("\t%s", impl->name);
+  putchar ('\n');
+
+  for (c = 0; c <= 65; c += 65)
+    {
+      for (i = 0; i < 18; ++i)
+	do_test (0, c, 1 << i);
+      for (i = 1; i < 32; ++i)
+	{
+	  do_test (i, c, i);
+	  if (i & (i - 1))
+	    do_test (0, c, i);
+	}
+      do_test (1, c, 14);
+      do_test (3, c, 1024);
+      do_test (4, c, 64);
+      do_test (2, c, 25);
+    }
+
+  do_random_tests ();
+  return ret;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/string/test-stpcpy.c
===================================================================
--- trunk/src/libctests/glibc/string/test-stpcpy.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/test-stpcpy.c	(revision 2036)
@@ -0,0 +1,37 @@
+/* Test and measure stpcpy functions.
+   Copyright (C) 1999, 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Jakub Jelinek <jakub@redhat.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define STRCPY_RESULT(dst, len) ((dst) + (len))
+#define TEST_MAIN
+#include "test-string.h"
+
+char *simple_stpcpy (char *, const char *);
+
+IMPL (simple_stpcpy, 0)
+IMPL (stpcpy, 1)
+
+char *
+simple_stpcpy (char *dst, const char *src)
+{
+  while ((*dst++ = *src++) != '\0');
+  return dst - 1;
+}
+
+#include "test-strcpy.c"
Index: trunk/src/libctests/glibc/string/test-stpncpy.c
===================================================================
--- trunk/src/libctests/glibc/string/test-stpncpy.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/test-stpncpy.c	(revision 2036)
@@ -0,0 +1,60 @@
+/* Test and measure stpncpy functions.
+   Copyright (C) 1999, 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Jakub Jelinek <jakub@redhat.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define STRNCPY_RESULT(dst, len, n) ((dst) + ((len) > (n) ? (n) : (len)))
+#define TEST_MAIN
+#include "test-string.h"
+
+char *simple_stpncpy (char *, const char *, size_t);
+char *stupid_stpncpy (char *, const char *, size_t);
+
+IMPL (stupid_stpncpy, 0)
+IMPL (simple_stpncpy, 0)
+IMPL (stpncpy, 1)
+
+char *
+simple_stpncpy (char *dst, const char *src, size_t n)
+{
+  while (n--)
+    if ((*dst++ = *src++) == '\0')
+      {
+	size_t i;
+
+	for (i = 0; i < n; ++i)
+	  dst[i] = '\0';
+	return dst - 1;
+      }
+  return dst;
+}
+
+char *
+stupid_stpncpy (char *dst, const char *src, size_t n)
+{
+  size_t nc = strnlen (src, n);
+  size_t i;
+
+  for (i = 0; i < nc; ++i)
+    dst[i] = src[i];
+  for (; i < n; ++i)
+    dst[i] = '\0';
+  return dst + nc;
+}
+
+#include "test-strncpy.c"
Index: trunk/src/libctests/glibc/string/test-strcat.c
===================================================================
--- trunk/src/libctests/glibc/string/test-strcat.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/test-strcat.c	(revision 2036)
@@ -0,0 +1,262 @@
+/* Test and measure strcat functions.
+   Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Jakub Jelinek <jakub@redhat.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define TEST_MAIN
+#include "test-string.h"
+
+typedef char *(*proto_t) (char *, const char *);
+char *simple_strcat (char *, const char *);
+
+IMPL (simple_strcat, 0)
+IMPL (strcat, 1)
+
+char *
+simple_strcat (char *dst, const char *src)
+{
+  char *ret = dst;
+  while (*dst++ != '\0');
+  --dst;
+  while ((*dst++ = *src++) != '\0');
+  return ret;
+}
+
+static void
+do_one_test (impl_t *impl, char *dst, const char *src)
+{
+  size_t k = strlen (dst);
+  if (CALL (impl, dst, src) != dst)
+    {
+      error (0, 0, "Wrong result in function %s %p %p", impl->name,
+	     CALL (impl, dst, src), dst);
+      ret = 1;
+      return;
+    }
+
+  if (strcmp (dst + k, src) != 0)
+    {
+      error (0, 0, "Wrong result in function %s dst \"%s\" src \"%s\"",
+	     impl->name, dst, src);
+      ret = 1;
+      return;
+    }
+
+  if (HP_TIMING_AVAIL)
+    {
+      hp_timing_t start __attribute ((unused));
+      hp_timing_t stop __attribute ((unused));
+      hp_timing_t best_time = ~ (hp_timing_t) 0;
+      size_t i;
+
+      for (i = 0; i < 32; ++i)
+	{
+	  dst[k] = '\0';
+	  HP_TIMING_NOW (start);
+	  CALL (impl, dst, src);
+	  HP_TIMING_NOW (stop);
+	  HP_TIMING_BEST (best_time, start, stop);
+	}
+
+      printf ("\t%zd", (size_t) best_time);
+    }
+}
+
+static void
+do_test (size_t align1, size_t align2, size_t len1, size_t len2, int max_char)
+{
+  size_t i;
+  char *s1, *s2;
+
+  align1 &= 7;
+  if (align1 + len1 >= page_size)
+    return;
+
+  align2 &= 7;
+  if (align2 + len1 + len2 >= page_size)
+    return;
+
+  s1 = buf1 + align1;
+  s2 = buf2 + align2;
+
+  for (i = 0; i < len1; ++i)
+    s1[i] = 32 + 23 * i % (max_char - 32);
+  s1[len1] = '\0';
+
+  for (i = 0; i < len2; i++)
+    s2[i] = 32 + 23 * i % (max_char - 32);
+
+  if (HP_TIMING_AVAIL)
+    printf ("Length %4zd/%4zd, alignment %2zd/%2zd:", len1, len2, align1, align2);
+
+  FOR_EACH_IMPL (impl, 0)
+    {
+      s2[len2] = '\0';
+      do_one_test (impl, s2, s1);
+    }
+
+  if (HP_TIMING_AVAIL)
+    putchar ('\n');
+}
+
+static void
+do_random_tests (void)
+{
+  size_t i, j, n, align1, align2, len1, len2;
+  unsigned char *p1 = buf1 + page_size - 512;
+  unsigned char *p2 = buf2 + page_size - 512;
+  unsigned char *res;
+
+  for (n = 0; n < ITERATIONS; n++)
+    {
+      align1 = random () & 31;
+      if (random () & 1)
+	align2 = random () & 31;
+      else
+	align2 = align1 + (random () & 24);
+      len1 = random () & 511;
+      if (len1 + align2 > 512)
+	len2 = random () & 7;
+      else
+	len2 = (512 - len1 - align2) * (random () & (1024 * 1024 - 1))
+	       / (1024 * 1024);
+      j = align1;
+      if (align2 + len2 > j)
+	j = align2 + len2;
+      if (len1 + j >= 511)
+	len1 = 510 - j - (random () & 7);
+      if (len1 >= 512)
+	len1 = 0;
+      if (align1 + len1 < 512 - 8)
+	{
+	  j = 510 - align1 - len1 - (random () & 31);
+	  if (j > 0 && j < 512)
+	    align1 += j;
+	}
+      j = len1 + align1 + 64;
+      if (j > 512)
+	j = 512;
+      for (i = 0; i < j; i++)
+	{
+	  if (i == len1 + align1)
+	    p1[i] = 0;
+	  else
+	    {
+	      p1[i] = random () & 255;
+	      if (i >= align1 && i < len1 + align1 && !p1[i])
+		p1[i] = (random () & 127) + 3;
+	    }
+	}
+      for (i = 0; i < len2; i++)
+	{
+	  buf1[i] = random () & 255;
+	  if (!buf1[i])
+	    buf1[i] = (random () & 127) + 3;
+	}
+      buf1[len2] = 0;
+
+      FOR_EACH_IMPL (impl, 1)
+	{
+	  memset (p2 - 64, '\1', align2 + 64);
+	  memset (p2 + align2 + len2 + 1, '\1', 512 - align2 - len2 - 1);
+	  memcpy (p2 + align2, buf1, len2 + 1);
+	  res = CALL (impl, p2 + align2, p1 + align1);
+	  if (res != p2 + align2)
+	    {
+	      error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %zd, %zd %zd) %p != %p",
+		     n, impl->name, align1, align2, len1, len2, res,
+		     p2 + align2);
+	      ret = 1;
+	    }
+	  for (j = 0; j < align2 + 64; ++j)
+	    {
+	      if (p2[j - 64] != '\1')
+		{
+		  error (0, 0, "Iteration %zd - garbage before, %s (%zd, %zd, %zd, %zd)",
+			 n, impl->name, align1, align2, len1, len2);
+		  ret = 1;
+		  break;
+		}
+	    }
+	  if (memcmp (p2 + align2, buf1, len2))
+	    {
+	      error (0, 0, "Iteration %zd - garbage in string before, %s (%zd, %zd, %zd, %zd)",
+		     n, impl->name, align1, align2, len1, len2);
+	      ret = 1;
+	    }
+	  for (j = align2 + len1 + len2 + 1; j < 512; ++j)
+	    {
+	      if (p2[j] != '\1')
+		{
+		  error (0, 0, "Iteration %zd - garbage after, %s (%zd, %zd, %zd, %zd)",
+			 n, impl->name, align1, align2, len1, len2);
+		  ret = 1;
+		  break;
+		}
+	    }
+	  if (memcmp (p1 + align1, p2 + align2 + len2, len1 + 1))
+	    {
+	      error (0, 0, "Iteration %zd - different strings, %s (%zd, %zd, %zd, %zd)",
+		     n, impl->name, align1, align2, len1, len2);
+	      ret = 1;
+	    }
+	}
+    }
+}
+
+int
+test_main (void)
+{
+  size_t i;
+
+  test_init ();
+
+  printf ("%28s", "");
+  FOR_EACH_IMPL (impl, 0)
+    printf ("\t%s", impl->name);
+  putchar ('\n');
+
+  for (i = 0; i < 16; ++i)
+    {
+      do_test (0, 0, i, i, 127);
+      do_test (0, 0, i, i, 255);
+      do_test (0, i, i, i, 127);
+      do_test (i, 0, i, i, 255);
+    }
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (0, 0, 8 << i, 8 << i, 127);
+      do_test (8 - i, 2 * i, 8 << i, 8 << i, 127);
+      do_test (0, 0, 8 << i, 2 << i, 127);
+      do_test (8 - i, 2 * i, 8 << i, 2 << i, 127);
+    }
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (i, 2 * i, 8 << i, 1, 127);
+      do_test (2 * i, i, 8 << i, 1, 255);
+      do_test (i, i, 8 << i, 10, 127);
+      do_test (i, i, 8 << i, 10, 255);
+    }
+
+  do_random_tests ();
+  return ret;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/string/test-strchr.c
===================================================================
--- trunk/src/libctests/glibc/string/test-strchr.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/test-strchr.c	(revision 2036)
@@ -0,0 +1,238 @@
+/* Test and measure strchr functions.
+   Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Jakub Jelinek <jakub@redhat.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define TEST_MAIN
+#include "test-string.h"
+
+typedef char *(*proto_t) (const char *, int);
+char *simple_strchr (const char *, int);
+char *stupid_strchr (const char *, int);
+
+IMPL (stupid_strchr, 0)
+IMPL (simple_strchr, 0)
+IMPL (strchr, 1)
+
+char *
+simple_strchr (const char *s, int c)
+{
+  for (; *s != (char) c; ++s)
+    if (*s == '\0')
+      return NULL;
+  return (char *) s;
+}
+
+char *
+stupid_strchr (const char *s, int c)
+{
+  size_t n = strlen (s) + 1;
+
+  while (n--)
+    if (*s++ == (char) c)
+      return (char *) s - 1;
+  return NULL;
+}
+
+static void
+do_one_test (impl_t *impl, const char *s, int c, char *exp_res)
+{
+  char *res = CALL (impl, s, c);
+  if (res != exp_res)
+    {
+      error (0, 0, "Wrong result in function %s %p %p", impl->name,
+	     res, exp_res);
+      ret = 1;
+      return;
+    }
+
+  if (HP_TIMING_AVAIL)
+    {
+      hp_timing_t start __attribute ((unused));
+      hp_timing_t stop __attribute ((unused));
+      hp_timing_t best_time = ~ (hp_timing_t) 0;
+      size_t i;
+
+      for (i = 0; i < 32; ++i)
+	{
+	  HP_TIMING_NOW (start);
+	  CALL (impl, s, c);
+	  HP_TIMING_NOW (stop);
+	  HP_TIMING_BEST (best_time, start, stop);
+	}
+
+      printf ("\t%zd", (size_t) best_time);
+    }
+}
+
+static void
+do_test (size_t align, size_t pos, size_t len, int seek_char, int max_char)
+{
+  size_t i;
+  char *result;
+
+  align &= 7;
+  if (align + len >= page_size)
+    return;
+
+  for (i = 0; i < len; ++i)
+    {
+      buf1[align + i] = 32 + 23 * i % (max_char - 32);
+      if (buf1[align + i] == seek_char)
+        buf1[align + i] = seek_char + 1;
+    }
+  buf1[align + len] = 0;
+
+  if (pos < len)
+    {
+      buf1[align + pos] = seek_char;
+      result = buf1 + align + pos;
+    }
+  else if (seek_char == 0)
+    result = buf1 + align + len;
+  else
+    result = NULL;
+
+  if (HP_TIMING_AVAIL)
+    printf ("Length %4zd, alignment %2zd:", pos, align);
+
+  FOR_EACH_IMPL (impl, 0)
+    do_one_test (impl, buf1 + align, seek_char, result);
+
+  if (HP_TIMING_AVAIL)
+    putchar ('\n');
+}
+
+static void
+do_random_tests (void)
+{
+  size_t i, j, n, align, pos, len;
+  int seek_char;
+  char *result;
+  unsigned char *p = buf1 + page_size - 512;
+
+  for (n = 0; n < ITERATIONS; n++)
+    {
+      align = random () & 15;
+      pos = random () & 511;
+      seek_char = random () & 255;
+      if (pos + align >= 511)
+	pos = 510 - align - (random () & 7);
+      len = random () & 511;
+      if ((pos == len && seek_char)
+	  || (pos > len && (random () & 1)))
+	len = pos + 1 + (random () & 7);
+      if (len + align >= 512)
+        len = 511 - align - (random () & 7);
+      if (pos == len && seek_char)
+	len = pos + 1;
+      j = (pos > len ? pos : len) + align + 64;
+      if (j > 512)
+        j = 512;
+
+      for (i = 0; i < j; i++)
+	{
+	  if (i == pos + align)
+	    p[i] = seek_char;
+	  else if (i == len + align)
+	    p[i] = 0;
+	  else
+	    {
+	      p[i] = random () & 255;
+	      if (i < pos + align && p[i] == seek_char)
+		p[i] = seek_char + 13;
+	      if (i < len + align && !p[i])
+		{
+		  p[i] = seek_char - 13;
+		  if (!p[i])
+		    p[i] = 140;
+		}
+	    }
+	}
+
+      if (pos <= len)
+	result = p + pos + align;
+      else if (seek_char == 0)
+	result = p + len + align;
+      else
+	result = NULL;
+
+      FOR_EACH_IMPL (impl, 1)
+	if (CALL (impl, p + align, seek_char) != result)
+	  {
+	    error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %d, %zd, %zd) %p != %p, p %p",
+		   n, impl->name, align, seek_char, len, pos,
+		   CALL (impl, p + align, seek_char), result, p);
+	    ret = 1;
+	  }
+    }
+}
+
+int
+test_main (void)
+{
+  size_t i;
+
+  test_init ();
+
+  printf ("%20s", "");
+  FOR_EACH_IMPL (impl, 0)
+    printf ("\t%s", impl->name);
+  putchar ('\n');
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (0, 16 << i, 2048, 23, 127);
+      do_test (i, 16 << i, 2048, 23, 127);
+    }
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (i, 64, 256, 23, 127);
+      do_test (i, 64, 256, 23, 255);
+    }
+
+  for (i = 0; i < 32; ++i)
+    {
+      do_test (0, i, i + 1, 23, 127);
+      do_test (0, i, i + 1, 23, 255);
+    }
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (0, 16 << i, 2048, 0, 127);
+      do_test (i, 16 << i, 2048, 0, 127);
+    }
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (i, 64, 256, 0, 127);
+      do_test (i, 64, 256, 0, 255);
+    }
+
+  for (i = 0; i < 32; ++i)
+    {
+      do_test (0, i, i + 1, 0, 127);
+      do_test (0, i, i + 1, 0, 255);
+    }
+
+  do_random_tests ();
+  return ret;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/string/test-strcmp.c
===================================================================
--- trunk/src/libctests/glibc/string/test-strcmp.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/test-strcmp.c	(revision 2036)
@@ -0,0 +1,260 @@
+/* Test and measure strcmp functions.
+   Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Jakub Jelinek <jakub@redhat.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define TEST_MAIN
+#include "test-string.h"
+
+typedef int (*proto_t) (const char *, const char *);
+int simple_strcmp (const char *, const char *);
+int stupid_strcmp (const char *, const char *);
+
+IMPL (stupid_strcmp, 0)
+IMPL (simple_strcmp, 0)
+IMPL (strcmp, 1)
+
+int
+simple_strcmp (const char *s1, const char *s2)
+{
+  int ret;
+
+  while ((ret = *(unsigned char *) s1 - *(unsigned char *) s2++) == 0
+	 && *s1++);
+  return ret;
+}
+
+int
+stupid_strcmp (const char *s1, const char *s2)
+{
+  size_t ns1 = strlen (s1) + 1, ns2 = strlen (s2) + 1;
+  size_t n = ns1 < ns2 ? ns1 : ns2;
+  int ret = 0;
+
+  while (n--)
+    if ((ret = *(unsigned char *) s1++ - *(unsigned char *) s2++) != 0)
+      break;
+  return ret;
+}
+
+static void
+do_one_test (impl_t *impl, const char *s1, const char *s2, int exp_result)
+{
+  int result = CALL (impl, s1, s2);
+  if ((exp_result == 0 && result != 0)
+      || (exp_result < 0 && result >= 0)
+      || (exp_result > 0 && result <= 0))
+    {
+      error (0, 0, "Wrong result in function %s %d %d", impl->name,
+	     result, exp_result);
+      ret = 1;
+      return;
+    }
+
+  if (HP_TIMING_AVAIL)
+    {
+      hp_timing_t start __attribute ((unused));
+      hp_timing_t stop __attribute ((unused));
+      hp_timing_t best_time = ~ (hp_timing_t) 0;
+      size_t i;
+
+      for (i = 0; i < 32; ++i)
+	{
+	  HP_TIMING_NOW (start);
+	  CALL (impl, s1, s2);
+	  HP_TIMING_NOW (stop);
+	  HP_TIMING_BEST (best_time, start, stop);
+	}
+
+      printf ("\t%zd", (size_t) best_time);
+    }
+}
+
+static void
+do_test (size_t align1, size_t align2, size_t len, int max_char,
+	 int exp_result)
+{
+  size_t i;
+  char *s1, *s2;
+
+  if (len == 0)
+    return;
+
+  align1 &= 7;
+  if (align1 + len + 1 >= page_size)
+    return;
+
+  align2 &= 7;
+  if (align2 + len + 1 >= page_size)
+    return;
+
+  s1 = buf1 + align1;
+  s2 = buf2 + align2;
+
+  for (i = 0; i < len; i++)
+    s1[i] = s2[i] = 1 + 23 * i % max_char;
+
+  s1[len] = s2[len] = 0;
+  s1[len + 1] = 23;
+  s2[len + 1] = 24 + exp_result;
+  s2[len - 1] -= exp_result;
+
+  if (HP_TIMING_AVAIL)
+    printf ("Length %4zd, alignment %2zd/%2zd:", len, align1, align2);
+
+  FOR_EACH_IMPL (impl, 0)
+    do_one_test (impl, s1, s2, exp_result);
+
+  if (HP_TIMING_AVAIL)
+    putchar ('\n');
+}
+
+static void
+do_random_tests (void)
+{
+  size_t i, j, n, align1, align2, pos, len1, len2;
+  int result;
+  long r;
+  unsigned char *p1 = buf1 + page_size - 512;
+  unsigned char *p2 = buf2 + page_size - 512;
+
+  for (n = 0; n < ITERATIONS; n++)
+    {
+      align1 = random () & 31;
+      if (random () & 1)
+	align2 = random () & 31;
+      else
+	align2 = align1 + (random () & 24);
+      pos = random () & 511;
+      j = align1 > align2 ? align1 : align2;
+      if (pos + j >= 511)
+	pos = 510 - j - (random () & 7);
+      len1 = random () & 511;
+      if (pos >= len1 && (random () & 1))
+        len1 = pos + (random () & 7);
+      if (len1 + j >= 512)
+        len1 = 511 - j - (random () & 7);
+      if (pos >= len1)
+	len2 = len1;
+      else
+	len2 = len1 + (len1 != 511 - j ? random () % (511 - j - len1) : 0);
+      j = (pos > len2 ? pos : len2) + align1 + 64;
+      if (j > 512)
+	j = 512;
+      for (i = 0; i < j; ++i)
+	{
+	  p1[i] = random () & 255;
+	  if (i < len1 + align1 && !p1[i])
+	    {
+	      p1[i] = random () & 255;
+	      if (!p1[i])
+		p1[i] = 1 + (random () & 127);
+	    }
+	}
+      for (i = 0; i < j; ++i)
+	{
+	  p2[i] = random () & 255;
+	  if (i < len2 + align2 && !p2[i])
+	    {
+	      p2[i] = random () & 255;
+	      if (!p2[i])
+		p2[i] = 1 + (random () & 127);
+	    }
+	}
+
+      result = 0;
+      memcpy (p2 + align2, p1 + align1, pos);
+      if (pos < len1)
+	{
+	  if (p2[align2 + pos] == p1[align1 + pos])
+	    {
+	      p2[align2 + pos] = random () & 255;
+	      if (p2[align2 + pos] == p1[align1 + pos])
+		p2[align2 + pos] = p1[align1 + pos] + 3 + (random () & 127);
+	    }
+
+	  if (p1[align1 + pos] < p2[align2 + pos])
+	    result = -1;
+	  else
+	    result = 1;
+	}
+      p1[len1 + align1] = 0;
+      p2[len2 + align2] = 0;
+
+      FOR_EACH_IMPL (impl, 1)
+	{
+	  r = CALL (impl, p1 + align1, p2 + align2);
+	  /* Test whether on 64-bit architectures where ABI requires
+	     callee to promote has the promotion been done.  */
+	  asm ("" : "=g" (r) : "0" (r));
+	  if ((r == 0 && result)
+	      || (r < 0 && result >= 0)
+	      || (r > 0 && result <= 0))
+	    {
+	      error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %zd, %zd, %zd, %zd) %ld != %d, p1 %p p2 %p",
+		     n, impl->name, align1, align2, len1, len2, pos, r, result, p1, p2);
+	      ret = 1;
+	    }
+	}
+    }
+}
+
+int
+test_main (void)
+{
+  size_t i;
+
+  test_init ();
+
+  printf ("%23s", "");
+  FOR_EACH_IMPL (impl, 0)
+    printf ("\t%s", impl->name);
+  putchar ('\n');
+
+  for (i = 1; i < 16; ++i)
+    {
+      do_test (i, i, i, 127, 0);
+      do_test (i, i, i, 127, 1);
+      do_test (i, i, i, 127, -1);
+    }
+
+  for (i = 1; i < 10; ++i)
+    {
+      do_test (0, 0, 2 << i, 127, 0);
+      do_test (0, 0, 2 << i, 254, 0);
+      do_test (0, 0, 2 << i, 127, 1);
+      do_test (0, 0, 2 << i, 254, 1);
+      do_test (0, 0, 2 << i, 127, -1);
+      do_test (0, 0, 2 << i, 254, -1);
+    }
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (i, 2 * i, 8 << i, 127, 0);
+      do_test (2 * i, i, 8 << i, 254, 0);
+      do_test (i, 2 * i, 8 << i, 127, 1);
+      do_test (2 * i, i, 8 << i, 254, 1);
+      do_test (i, 2 * i, 8 << i, 127, -1);
+      do_test (2 * i, i, 8 << i, 254, -1);
+    }
+
+  do_random_tests ();
+  return ret;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/string/test-strcpy.c
===================================================================
--- trunk/src/libctests/glibc/string/test-strcpy.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/test-strcpy.c	(revision 2036)
@@ -0,0 +1,227 @@
+/* Test and measure strcpy functions.
+   Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Jakub Jelinek <jakub@redhat.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef STRCPY_RESULT
+# define STRCPY_RESULT(dst, len) dst
+# define TEST_MAIN
+# include "test-string.h"
+
+char *simple_strcpy (char *, const char *);
+
+IMPL (simple_strcpy, 0)
+IMPL (strcpy, 1)
+
+char *
+simple_strcpy (char *dst, const char *src)
+{
+  char *ret = dst;
+  while ((*dst++ = *src++) != '\0');
+  return ret;
+}
+#endif
+
+typedef char *(*proto_t) (char *, const char *);
+
+static void
+do_one_test (impl_t *impl, char *dst, const char *src,
+	     size_t len __attribute__((unused)))
+{
+  if (CALL (impl, dst, src) != STRCPY_RESULT (dst, len))
+    {
+      error (0, 0, "Wrong result in function %s %p %p", impl->name,
+	     CALL (impl, dst, src), STRCPY_RESULT (dst, len));
+      ret = 1;
+      return;
+    }
+
+  if (strcmp (dst, src) != 0)
+    {
+      error (0, 0, "Wrong result in function %s dst \"%s\" src \"%s\"",
+	     impl->name, dst, src);
+      ret = 1;
+      return;
+    }
+
+  if (HP_TIMING_AVAIL)
+    {
+      hp_timing_t start __attribute ((unused));
+      hp_timing_t stop __attribute ((unused));;
+      hp_timing_t best_time = ~ (hp_timing_t) 0;
+      size_t i;
+
+      for (i = 0; i < 32; ++i)
+	{
+	  HP_TIMING_NOW (start);
+	  CALL (impl, dst, src);
+	  HP_TIMING_NOW (stop);
+	  HP_TIMING_BEST (best_time, start, stop);
+	}
+
+      printf ("\t%zd", (size_t) best_time);
+    }
+}
+
+static void
+do_test (size_t align1, size_t align2, size_t len, int max_char)
+{
+  size_t i;
+  char *s1, *s2;
+
+  align1 &= 7;
+  if (align1 + len >= page_size)
+    return;
+
+  align2 &= 7;
+  if (align2 + len >= page_size)
+    return;
+
+  s1 = buf1 + align1;
+  s2 = buf2 + align2;
+
+  for (i = 0; i < len; i++)
+    s1[i] = 32 + 23 * i % (max_char - 32);
+  s1[len] = 0;
+
+  if (HP_TIMING_AVAIL)
+    printf ("Length %4zd, alignment %2zd/%2zd:", len, align1, align2);
+
+  FOR_EACH_IMPL (impl, 0)
+    do_one_test (impl, s2, s1, len);
+
+  if (HP_TIMING_AVAIL)
+    putchar ('\n');
+}
+
+static void
+do_random_tests (void)
+{
+  size_t i, j, n, align1, align2, len;
+  unsigned char *p1 = buf1 + page_size - 512;
+  unsigned char *p2 = buf2 + page_size - 512;
+  unsigned char *res;
+
+  for (n = 0; n < ITERATIONS; n++)
+    {
+      align1 = random () & 31;
+      if (random () & 1)
+	align2 = random () & 31;
+      else
+	align2 = align1 + (random () & 24);
+      len = random () & 511;
+      j = align1;
+      if (align2 > j)
+	j = align2;
+      if (len + j >= 511)
+	len = 510 - j - (random () & 7);
+      j = len + align1 + 64;
+      if (j > 512)
+	j = 512;
+      for (i = 0; i < j; i++)
+	{
+	  if (i == len + align1)
+	    p1[i] = 0;
+	  else
+	    {
+	      p1[i] = random () & 255;
+	      if (i >= align1 && i < len + align1 && !p1[i])
+		p1[i] = (random () & 127) + 3;
+	    }
+	}
+
+      FOR_EACH_IMPL (impl, 1)
+	{
+	  memset (p2 - 64, '\1', 512 + 64);
+	  res = CALL (impl, p2 + align2, p1 + align1);
+	  if (res != STRCPY_RESULT (p2 + align2, len))
+	    {
+	      error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %zd, %zd) %p != %p",
+		     n, impl->name, align1, align2, len, res,
+		     STRCPY_RESULT (p2 + align2, len));
+	      ret = 1;
+	    }
+	  for (j = 0; j < align2 + 64; ++j)
+	    {
+	      if (p2[j - 64] != '\1')
+		{
+		  error (0, 0, "Iteration %zd - garbage before, %s (%zd, %zd, %zd)",
+			 n, impl->name, align1, align2, len);
+		  ret = 1;
+		  break;
+		}
+	    }
+	  for (j = align2 + len + 1; j < 512; ++j)
+	    {
+	      if (p2[j] != '\1')
+		{
+		  error (0, 0, "Iteration %zd - garbage after, %s (%zd, %zd, %zd)",
+			 n, impl->name, align1, align2, len);
+		  ret = 1;
+		  break;
+		}
+	    }
+	  if (memcmp (p1 + align1, p2 + align2, len + 1))
+	    {
+	      error (0, 0, "Iteration %zd - different strings, %s (%zd, %zd, %zd)",
+		     n, impl->name, align1, align2, len);
+	      ret = 1;
+	    }
+	}
+    }
+}
+
+int
+test_main (void)
+{
+  size_t i;
+
+  test_init ();
+
+  printf ("%23s", "");
+  FOR_EACH_IMPL (impl, 0)
+    printf ("\t%s", impl->name);
+  putchar ('\n');
+
+  for (i = 0; i < 16; ++i)
+    {
+      do_test (0, 0, i, 127);
+      do_test (0, 0, i, 255);
+      do_test (0, i, i, 127);
+      do_test (i, 0, i, 255);
+    }
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (0, 0, 8 << i, 127);
+      do_test (8 - i, 2 * i, 8 << i, 127);
+    }
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (i, 2 * i, 8 << i, 127);
+      do_test (2 * i, i, 8 << i, 255);
+      do_test (i, i, 8 << i, 127);
+      do_test (i, i, 8 << i, 255);
+    }
+
+  do_random_tests ();
+  return ret;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/string/test-strcspn.c
===================================================================
--- trunk/src/libctests/glibc/string/test-strcspn.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/test-strcspn.c	(revision 2036)
@@ -0,0 +1,60 @@
+/* Test and measure strcspn functions.
+   Copyright (C) 1999, 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Jakub Jelinek <jakub@redhat.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define STRPBRK_RESULT(s, pos) (pos)
+#define RES_TYPE size_t
+#define TEST_MAIN
+#include "test-string.h"
+
+typedef size_t (*proto_t) (const char *, const char *);
+size_t simple_strcspn (const char *, const char *);
+size_t stupid_strcspn (const char *, const char *);
+
+IMPL (stupid_strcspn, 0)
+IMPL (simple_strcspn, 0)
+IMPL (strcspn, 1)
+
+size_t
+simple_strcspn (const char *s, const char *rej)
+{
+  const char *r, *str = s;
+  char c;
+
+  while ((c = *s++) != '\0')
+    for (r = rej; *r != '\0'; ++r)
+      if (*r == c)
+	return s - str - 1;
+  return s - str - 1;
+}
+
+size_t
+stupid_strcspn (const char *s, const char *rej)
+{
+  size_t ns = strlen (s), nrej = strlen (rej);
+  size_t i, j;
+
+  for (i = 0; i < ns; ++i)
+    for (j = 0; j < nrej; ++j)
+      if (s[i] == rej[j])
+	return i;
+  return i;
+}
+
+#include "test-strpbrk.c"
Index: trunk/src/libctests/glibc/string/test-string.h
===================================================================
--- trunk/src/libctests/glibc/string/test-string.h	(revision 2036)
+++ trunk/src/libctests/glibc/string/test-string.h	(revision 2036)
@@ -0,0 +1,152 @@
+/* Test and measure string and memory functions.
+   Copyright (C) 1999, 2002, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Jakub Jelinek <jakub@redhat.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+typedef struct
+{
+  const char *name;
+  void (*fn) (void);
+  long test;
+} impl_t;
+extern impl_t __start_impls[], __stop_impls[];
+
+#define IMPL(name, test) \
+  impl_t tst_ ## name							\
+  __attribute__ ((section ("impls"), aligned (sizeof (void *))))	\
+    = { #name, (void (*) (void))name, test };
+
+#ifdef TEST_MAIN
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#undef __USE_STRING_INLINES
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <error.h>
+#include <errno.h>
+#include <time.h>
+#define GL(x) _##x
+#define GLRO(x) _##x
+#include <hp-timing.h>
+
+
+# define TEST_FUNCTION test_main ()
+# define TIMEOUT (4 * 60)
+# define OPT_ITERATIONS 10000
+# define OPT_RANDOM 10001
+# define OPT_SEED 10002
+
+unsigned char *buf1, *buf2;
+int ret, do_srandom;
+unsigned int seed;
+size_t page_size;
+
+hp_timing_t _dl_hp_timing_overhead;
+
+# ifndef ITERATIONS
+size_t iterations = 100000;
+#  define ITERATIONS_OPTIONS \
+  { "iterations", required_argument, NULL, OPT_ITERATIONS },
+#  define ITERATIONS_PROCESS \
+  case OPT_ITERATIONS:				\
+    iterations = strtoul (optarg, NULL, 0);	\
+    break;
+#  define ITERATIONS iterations
+# else
+#  define ITERATIONS_OPTIONS
+#  define ITERATIONS_PROCESS
+# endif
+
+# define CMDLINE_OPTIONS ITERATIONS_OPTIONS \
+  { "random", no_argument, NULL, OPT_RANDOM },	\
+  { "seed", required_argument, NULL, OPT_SEED },
+# define CMDLINE_PROCESS ITERATIONS_PROCESS \
+  case OPT_RANDOM:							\
+    {									\
+      int fdr = open ("/dev/urandom", O_RDONLY);			\
+									\
+      if (fdr < 0 || read (fdr, &seed, sizeof(seed)) != sizeof (seed))	\
+	seed = time (NULL);						\
+      if (fdr >= 0)							\
+	close (fdr);							\
+      do_srandom = 1;							\
+      break;								\
+    }									\
+									\
+  case OPT_SEED:							\
+    seed = strtoul (optarg, NULL, 0);					\
+    do_srandom = 1;							\
+    break;
+
+#define CALL(impl, ...)	\
+  (* (proto_t) (impl)->fn) (__VA_ARGS__)
+
+#define FOR_EACH_IMPL(impl, notall) \
+  for (impl_t *impl = __start_impls; impl < __stop_impls; ++impl)	\
+    if (!notall || impl->test)
+
+#define HP_TIMING_BEST(best_time, start, end)	\
+  do									\
+    {									\
+      hp_timing_t tmptime;						\
+      HP_TIMING_DIFF (tmptime, start + _dl_hp_timing_overhead, end);	\
+      if (best_time > tmptime)						\
+	best_time = tmptime;						\
+    }									\
+  while (0)
+
+static void
+test_init (void)
+{
+  page_size = 2 * getpagesize ();
+#ifdef MIN_PAGE_SIZE
+  if (page_size < MIN_PAGE_SIZE)
+    page_size = MIN_PAGE_SIZE;
+#endif
+  buf1 = mmap (0, 2 * page_size, PROT_READ | PROT_WRITE,
+	       MAP_PRIVATE | MAP_ANON, -1, 0);
+  if (buf1 == MAP_FAILED)
+    error (EXIT_FAILURE, errno, "mmap failed");
+  if (mprotect (buf1 + page_size, page_size, PROT_NONE))
+    error (EXIT_FAILURE, errno, "mprotect failed");
+  buf2 = mmap (0, 2 * page_size, PROT_READ | PROT_WRITE,
+	       MAP_PRIVATE | MAP_ANON, -1, 0);
+  if (buf2 == MAP_FAILED)
+    error (EXIT_FAILURE, errno, "mmap failed");
+  if (mprotect (buf2 + page_size, page_size, PROT_NONE))
+    error (EXIT_FAILURE, errno, "mprotect failed");
+  HP_TIMING_DIFF_INIT ();
+  if (do_srandom)
+    {
+      printf ("Setting seed to 0x%x\n", seed);
+      srandom (seed);
+    }
+
+  memset (buf1, 0xa5, page_size);
+  memset (buf2, 0x5a, page_size);
+}
+
+#endif
Index: trunk/src/libctests/glibc/string/test-strlen.c
===================================================================
--- trunk/src/libctests/glibc/string/test-strlen.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/test-strlen.c	(revision 2036)
@@ -0,0 +1,179 @@
+/* Test and measure strlen functions.
+   Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Jakub Jelinek <jakub@redhat.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define TEST_MAIN
+#include "test-string.h"
+
+typedef size_t (*proto_t) (const char *);
+size_t simple_strlen (const char *);
+size_t builtin_strlen (const char *);
+
+IMPL (simple_strlen, 0)
+IMPL (builtin_strlen, 0)
+IMPL (strlen, 1)
+
+size_t
+simple_strlen (const char *s)
+{
+  const char *p;
+
+  for (p = s; *p; ++p);
+  return p - s;
+}
+
+size_t
+builtin_strlen (const char *p)
+{
+  return __builtin_strlen (p);
+}
+
+static void
+do_one_test (impl_t *impl, const char *s, size_t exp_len)
+{
+  size_t len = CALL (impl, s);
+  if (len != exp_len)
+    {
+      error (0, 0, "Wrong result in function %s %zd %zd", impl->name,
+	     len, exp_len);
+      ret = 1;
+      return;
+    }
+
+  if (HP_TIMING_AVAIL)
+    {
+      hp_timing_t start __attribute ((unused));
+      hp_timing_t stop __attribute ((unused));
+      hp_timing_t best_time = ~ (hp_timing_t) 0;
+      size_t i;
+
+      for (i = 0; i < 32; ++i)
+	{
+	  HP_TIMING_NOW (start);
+	  CALL (impl, s);
+	  HP_TIMING_NOW (stop);
+	  HP_TIMING_BEST (best_time, start, stop);
+	}
+
+      printf ("\t%zd", (size_t) best_time);
+    }
+}
+
+static void
+do_test (size_t align, size_t len, int max_char)
+{
+  size_t i;
+
+  align &= 7;
+  if (align + len >= page_size)
+    return;
+
+  for (i = 0; i < len; ++i)
+    buf1[align + i] = 1 + 7 * i % max_char;
+  buf1[align + len] = 0;
+
+  if (HP_TIMING_AVAIL)
+    printf ("Length %4zd, alignment %2zd:", len, align);
+
+  FOR_EACH_IMPL (impl, 0)
+    do_one_test (impl, buf1 + align, len);
+
+  if (HP_TIMING_AVAIL)
+    putchar ('\n');
+}
+
+static void
+do_random_tests (void)
+{
+  size_t i, j, n, align, len;
+  unsigned char *p = buf1 + page_size - 512;
+
+  for (n = 0; n < ITERATIONS; n++)
+    {
+      align = random () & 15;
+      len = random () & 511;
+      if (len + align > 510)
+	len = 511 - align - (random () & 7);
+      j = len + align + 64;
+      if (j > 512)
+	j = 512;
+
+      for (i = 0; i < j; i++)
+	{
+	  if (i == len + align)
+	    p[i] = 0;
+	  else
+	    {
+	      p[i] = random () & 255;
+	      if (i >= align && i < len + align && !p[i])
+		p[i] = (random () & 127) + 1;
+	    }
+	}
+
+      FOR_EACH_IMPL (impl, 1)
+	if (CALL (impl, p + align) != len)
+	  {
+	    error (0, 0, "Iteration %zd - wrong result in function %s (%zd) %zd != %zd, p %p",
+		   n, impl->name, align, CALL (impl, p + align), len, p);
+	    ret = 1;
+	  }
+    }
+}
+
+int
+test_main (void)
+{
+  size_t i;
+
+  test_init ();
+
+  printf ("%20s", "");
+  FOR_EACH_IMPL (impl, 0)
+    printf ("\t%s", impl->name);
+  putchar ('\n');
+
+  for (i = 1; i < 8; ++i)
+    do_test (0, i, 127);
+
+  for (i = 1; i < 8; ++i)
+    do_test (i, i, 127);
+
+  for (i = 2; i <= 10; ++i)
+    {
+      do_test (0, 1 << i, 127);
+      do_test (1, 1 << i, 127);
+    }
+
+  for (i = 1; i < 8; ++i)
+    do_test (0, i, 255);
+
+  for (i = 1; i < 8; ++i)
+    do_test (i, i, 255);
+
+  for (i = 2; i <= 10; ++i)
+    {
+      do_test (0, 1 << i, 255);
+      do_test (1, 1 << i, 255);
+    }
+
+  do_random_tests ();
+  return ret;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/string/test-strncmp.c
===================================================================
--- trunk/src/libctests/glibc/string/test-strncmp.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/test-strncmp.c	(revision 2036)
@@ -0,0 +1,279 @@
+/* Test and measure strncmp functions.
+   Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Jakub Jelinek <jakub@redhat.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define TEST_MAIN
+#include "test-string.h"
+
+typedef int (*proto_t) (const char *, const char *, size_t);
+int simple_strncmp (const char *, const char *, size_t);
+int stupid_strncmp (const char *, const char *, size_t);
+
+IMPL (stupid_strncmp, 0)
+IMPL (simple_strncmp, 0)
+IMPL (strncmp, 1)
+
+int
+simple_strncmp (const char *s1, const char *s2, size_t n)
+{
+  int ret = 0;
+
+  while (n-- && (ret = *(unsigned char *) s1 - * (unsigned char *) s2++) == 0
+	 && *s1++);
+  return ret;
+}
+
+int
+stupid_strncmp (const char *s1, const char *s2, size_t n)
+{
+  size_t ns1 = strnlen (s1, n) + 1, ns2 = strnlen (s2, n) + 1;
+  int ret = 0;
+
+  n = ns1 < n ? ns1 : n;
+  n = ns2 < n ? ns2 : n;
+  while (n-- && (ret = *(unsigned char *) s1++ - * (unsigned char *) s2++) == 0);
+  return ret;
+}
+
+static void
+do_one_test (impl_t *impl, const char *s1, const char *s2, size_t n,
+	     int exp_result)
+{
+  int result = CALL (impl, s1, s2, n);
+  if ((exp_result == 0 && result != 0)
+      || (exp_result < 0 && result >= 0)
+      || (exp_result > 0 && result <= 0))
+    {
+      error (0, 0, "Wrong result in function %s %d %d", impl->name,
+	     result, exp_result);
+      ret = 1;
+      return;
+    }
+
+  if (HP_TIMING_AVAIL)
+    {
+      hp_timing_t start __attribute ((unused));
+      hp_timing_t stop __attribute ((unused));
+      hp_timing_t best_time = ~ (hp_timing_t) 0;
+      size_t i;
+
+      for (i = 0; i < 32; ++i)
+	{
+	  HP_TIMING_NOW (start);
+	  CALL (impl, s1, s2, n);
+	  HP_TIMING_NOW (stop);
+	  HP_TIMING_BEST (best_time, start, stop);
+	}
+
+      printf ("\t%zd", (size_t) best_time);
+    }
+}
+
+static void
+do_test (size_t align1, size_t align2, size_t len, size_t n, int max_char,
+	 int exp_result)
+{
+  size_t i;
+  char *s1, *s2;
+
+  if (n == 0)
+    return;
+
+  align1 &= 7;
+  if (align1 + n + 1 >= page_size)
+    return;
+
+  align2 &= 7;
+  if (align2 + n + 1 >= page_size)
+    return;
+
+  s1 = buf1 + align1;
+  s2 = buf2 + align2;
+
+  for (i = 0; i < n; i++)
+    s1[i] = s2[i] = 1 + 23 * i % max_char;
+
+  s1[n] = 24 + exp_result;
+  s2[n] = 23;
+  s1[len] = 0;
+  s2[len] = 0;
+  if (exp_result < 0)
+    s2[len] = 32;
+  else if (exp_result > 0)
+    s1[len] = 64;
+  if (len >= n)
+    s2[n - 1] -= exp_result;
+
+  if (HP_TIMING_AVAIL)
+    printf ("Length %4zd/%4zd, alignment %2zd/%2zd:", len, n, align1, align2);
+
+  FOR_EACH_IMPL (impl, 0)
+    do_one_test (impl, s1, s2, n, exp_result);
+
+  if (HP_TIMING_AVAIL)
+    putchar ('\n');
+}
+
+static void
+do_random_tests (void)
+{
+  size_t i, j, n, align1, align2, pos, len1, len2, size;
+  int result;
+  long r;
+  unsigned char *p1 = buf1 + page_size - 512;
+  unsigned char *p2 = buf2 + page_size - 512;
+
+  for (n = 0; n < ITERATIONS; n++)
+    {
+      align1 = random () & 31;
+      if (random () & 1)
+	align2 = random () & 31;
+      else
+	align2 = align1 + (random () & 24);
+      pos = random () & 511;
+      size = random () & 511;
+      j = align1 > align2 ? align1 : align2;
+      if (pos + j >= 511)
+	pos = 510 - j - (random () & 7);
+      len1 = random () & 511;
+      if (pos >= len1 && (random () & 1))
+	len1 = pos + (random () & 7);
+      if (len1 + j >= 512)
+	len1 = 511 - j - (random () & 7);
+      if (pos >= len1)
+	len2 = len1;
+      else
+	len2 = len1 + (len1 != 511 - j ? random () % (511 - j - len1) : 0);
+      j = (pos > len2 ? pos : len2) + align1 + 64;
+      if (j > 512)
+	j = 512;
+      for (i = 0; i < j; ++i)
+	{
+	  p1[i] = random () & 255;
+	  if (i < len1 + align1 && !p1[i])
+	    {
+	      p1[i] = random () & 255;
+	      if (!p1[i])
+		p1[i] = 1 + (random () & 127);
+	    }
+	}
+      for (i = 0; i < j; ++i)
+	{
+	  p2[i] = random () & 255;
+	  if (i < len2 + align2 && !p2[i])
+	    {
+	      p2[i] = random () & 255;
+	      if (!p2[i])
+		p2[i] = 1 + (random () & 127);
+	    }
+	}
+
+      result = 0;
+      memcpy (p2 + align2, p1 + align1, pos);
+      if (pos < len1)
+	{
+	  if (p2[align2 + pos] == p1[align1 + pos])
+	    {
+	      p2[align2 + pos] = random () & 255;
+	      if (p2[align2 + pos] == p1[align1 + pos])
+		p2[align2 + pos] = p1[align1 + pos] + 3 + (random () & 127);
+	    }
+
+	  if (pos < size)
+	    {
+	      if (p1[align1 + pos] < p2[align2 + pos])
+		result = -1;
+	      else
+		result = 1;
+	    }
+	}
+      p1[len1 + align1] = 0;
+      p2[len2 + align2] = 0;
+
+      FOR_EACH_IMPL (impl, 1)
+	{
+	  r = CALL (impl, p1 + align1, p2 + align2, size);
+	  /* Test whether on 64-bit architectures where ABI requires
+	     callee to promote has the promotion been done.  */
+	  asm ("" : "=g" (r) : "0" (r));
+	  if ((r == 0 && result)
+	      || (r < 0 && result >= 0)
+	      || (r > 0 && result <= 0))
+	    {
+	      error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %zd, %zd, %zd, %zd, %zd) %ld != %d, p1 %p p2 %p",
+		     n, impl->name, align1, align2, len1, len2, pos, size, r, result, p1, p2);
+	      ret = 1;
+	    }
+	}
+    }
+}
+
+int
+test_main (void)
+{
+  size_t i;
+
+  test_init ();
+
+  printf ("%23s", "");
+  FOR_EACH_IMPL (impl, 0)
+    printf ("\t%s", impl->name);
+  putchar ('\n');
+
+  for (i =0; i < 16; ++i)
+    {
+      do_test (0, 0, 8, i, 127, 0);
+      do_test (0, 0, 8, i, 127, -1);
+      do_test (0, 0, 8, i, 127, 1);
+      do_test (i, i, 8, i, 127, 0);
+      do_test (i, i, 8, i, 127, 1);
+      do_test (i, i, 8, i, 127, -1);
+      do_test (i, 2 * i, 8, i, 127, 0);
+      do_test (2 * i, i, 8, i, 127, 1);
+      do_test (i, 3 * i, 8, i, 127, -1);
+      do_test (0, 0, 8, i, 255, 0);
+      do_test (0, 0, 8, i, 255, -1);
+      do_test (0, 0, 8, i, 255, 1);
+      do_test (i, i, 8, i, 255, 0);
+      do_test (i, i, 8, i, 255, 1);
+      do_test (i, i, 8, i, 255, -1);
+      do_test (i, 2 * i, 8, i, 255, 0);
+      do_test (2 * i, i, 8, i, 255, 1);
+      do_test (i, 3 * i, 8, i, 255, -1);
+    }
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (0, 0, 8 << i, 16 << i, 127, 0);
+      do_test (0, 0, 8 << i, 16 << i, 127, 1);
+      do_test (0, 0, 8 << i, 16 << i, 127, -1);
+      do_test (0, 0, 8 << i, 16 << i, 255, 0);
+      do_test (0, 0, 8 << i, 16 << i, 255, 1);
+      do_test (0, 0, 8 << i, 16 << i, 255, -1);
+      do_test (8 - i, 2 * i, 8 << i, 16 << i, 127, 0);
+      do_test (8 - i, 2 * i, 8 << i, 16 << i, 127, 1);
+      do_test (2 * i, i, 8 << i, 16 << i, 255, 0);
+      do_test (2 * i, i, 8 << i, 16 << i, 255, 1);
+    }
+
+  do_random_tests ();
+  return ret;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/string/test-strncpy.c
===================================================================
--- trunk/src/libctests/glibc/string/test-strncpy.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/test-strncpy.c	(revision 2036)
@@ -0,0 +1,306 @@
+/* Test and measure strncpy functions.
+   Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Jakub Jelinek <jakub@redhat.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef STRNCPY_RESULT
+# define STRNCPY_RESULT(dst, len, n) dst
+# define TEST_MAIN
+# include "test-string.h"
+
+char *simple_strncpy (char *, const char *, size_t);
+char *stupid_strncpy (char *, const char *, size_t);
+
+IMPL (stupid_strncpy, 0)
+IMPL (simple_strncpy, 0)
+IMPL (strncpy, 1)
+
+char *
+simple_strncpy (char *dst, const char *src, size_t n)
+{
+  char *ret = dst;
+  while (n--)
+    if ((*dst++ = *src++) == '\0')
+      {
+	while (n--)
+	  *dst++ = '\0';
+	return ret;
+      }
+  return ret;
+}
+
+char *
+stupid_strncpy (char *dst, const char *src, size_t n)
+{
+  size_t nc = strnlen (src, n);
+  size_t i;
+
+  for (i = 0; i < nc; ++i)
+    dst[i] = src[i];
+  for (; i < n; ++i)
+    dst[i] = '\0';
+  return dst;
+}
+#endif
+
+typedef char *(*proto_t) (char *, const char *, size_t);
+
+static void
+do_one_test (impl_t *impl, char *dst, const char *src, size_t len, size_t n)
+{
+  if (CALL (impl, dst, src, n) != STRNCPY_RESULT (dst, len, n))
+    {
+      error (0, 0, "Wrong result in function %s %p %p", impl->name,
+	     CALL (impl, dst, src, n), dst);
+      ret = 1;
+      return;
+    }
+
+  if (memcmp (dst, src, len > n ? n : len) != 0)
+    {
+      error (0, 0, "Wrong result in function %s", impl->name);
+      ret = 1;
+      return;
+    }
+
+  if (n > len)
+    {
+      size_t i;
+
+      for (i = len; i < n; ++i)
+	if (dst [i] != '\0')
+	  {
+	    error (0, 0, "Wrong result in function %s", impl->name);
+	    ret = 1;
+	    return;
+	  }
+    }
+
+  if (HP_TIMING_AVAIL)
+    {
+      hp_timing_t start __attribute__ ((unused));
+      hp_timing_t stop __attribute__ ((unused));
+      hp_timing_t best_time = ~ (hp_timing_t) 0;
+      size_t i;
+
+      for (i = 0; i < 32; ++i)
+	{
+	  HP_TIMING_NOW (start);
+	  CALL (impl, dst, src, n);
+	  HP_TIMING_NOW (stop);
+	  HP_TIMING_BEST (best_time, start, stop);
+	}
+
+      printf ("\t%zd", (size_t) best_time);
+    }
+}
+
+static void
+do_test (size_t align1, size_t align2, size_t len, size_t n, int max_char)
+{
+  size_t i;
+  char *s1, *s2;
+
+  align1 &= 7;
+  if (align1 + len >= page_size)
+    return;
+
+  align2 &= 7;
+  if (align2 + len >= page_size)
+    return;
+
+  s1 = buf1 + align1;
+  s2 = buf2 + align2;
+
+  for (i = 0; i < len; ++i)
+    s1[i] = 32 + 23 * i % (max_char - 32);
+  s1[len] = 0;
+  for (i = len + 1; i + align1 < page_size && i < len + 64; ++i)
+    s1[i] = 32 + 32 * i % (max_char - 32);
+
+  if (HP_TIMING_AVAIL)
+    printf ("Length %4zd, n %4zd, alignment %2zd/%2zd:", len, n, align1, align2);
+
+  FOR_EACH_IMPL (impl, 0)
+    do_one_test (impl, s2, s1, len, n);
+
+  if (HP_TIMING_AVAIL)
+    putchar ('\n');
+}
+
+static void
+do_random_tests (void)
+{
+  size_t i, j, n, align1, align2, len, size, mode;
+  unsigned char *p1 = buf1 + page_size - 512;
+  unsigned char *p2 = buf2 + page_size - 512;
+  unsigned char *res;
+
+  for (n = 0; n < ITERATIONS; n++)
+    {
+      mode = random ();
+      if (mode & 1)
+	{
+	  size = random () & 255;
+	  align1 = 512 - size - (random () & 15);
+	  if (mode & 2)
+	    align2 = align1 - (random () & 24);
+	  else
+	    align2 = align1 - (random () & 31);
+	  if (mode & 4)
+	    {
+	      j = align1;
+	      align1 = align2;
+	      align2 = j;
+	    }
+	  if (mode & 8)
+	    len = size - (random () & 31);
+	  else
+	    len = 512;
+	  if (len >= 512)
+	    len = random () & 511;
+	}
+      else
+	{
+	  align1 = random () & 31;
+	  if (mode & 2)
+	    align2 = random () & 31;
+	  else
+	    align2 = align1 + (random () & 24);
+	  len = random () & 511;
+	  j = align1;
+	  if (align2 > j)
+	    j = align2;
+	  if (mode & 4)
+	    {
+	      size = random () & 511;
+	      if (size + j > 512)
+		size = 512 - j - (random() & 31);
+	    }
+	  else
+	    size = 512 - j;
+	  if ((mode & 8) && len + j >= 512)
+	    len = 512 - j - (random () & 7);
+	}
+      j = len + align1 + 64;
+      if (j > 512)
+	j = 512;
+      for (i = 0; i < j; i++)
+	{
+	  if (i == len + align1)
+	    p1[i] = 0;
+	  else
+	    {
+	      p1[i] = random () & 255;
+	      if (i >= align1 && i < len + align1 && !p1[i])
+		p1[i] = (random () & 127) + 3;
+	    }
+	}
+
+      FOR_EACH_IMPL (impl, 1)
+	{
+	  memset (p2 - 64, '\1', 512 + 64);
+	  res = CALL (impl, p2 + align2, p1 + align1, size);
+	  if (res != STRNCPY_RESULT (p2 + align2, len, size))
+	    {
+	      error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %zd, %zd) %p != %p",
+		     n, impl->name, align1, align2, len, res,
+		     STRNCPY_RESULT (p2 + align2, len, size));
+	      ret = 1;
+	    }
+	  for (j = 0; j < align2 + 64; ++j)
+	    {
+	      if (p2[j - 64] != '\1')
+		{
+		  error (0, 0, "Iteration %zd - garbage before, %s (%zd, %zd, %zd)",
+			 n, impl->name, align1, align2, len);
+		  ret = 1;
+		  break;
+		}
+	    }
+	  j = align2 + len + 1;
+	  if (size + align2 > j)
+	    j = size + align2;
+	  for (; j < 512; ++j)
+	    {
+	      if (p2[j] != '\1')
+		{
+		  error (0, 0, "Iteration %zd - garbage after, %s (%zd, %zd, %zd)",
+			 n, impl->name, align1, align2, len);
+		  ret = 1;
+		  break;
+		}
+	    }
+	  for (j = align2 + len + 1; j < align2 + size; ++j)
+	    if (p2[j])
+	      {
+		error (0, 0, "Iteration %zd - garbage after size, %s (%zd, %zd, %zd)",
+		       n, impl->name, align1, align2, len);
+		ret = 1;
+		break;
+	      }
+	  j = len + 1;
+	  if (size < j)
+	    j = size;
+	  if (memcmp (p1 + align1, p2 + align2, j))
+	    {
+	      error (0, 0, "Iteration %zd - different strings, %s (%zd, %zd, %zd)",
+		     n, impl->name, align1, align2, len);
+	      ret = 1;
+	    }
+	}
+    }
+}
+
+int
+test_main (void)
+{
+  size_t i;
+
+  test_init ();
+
+  printf ("%28s", "");
+  FOR_EACH_IMPL (impl, 0)
+    printf ("\t%s", impl->name);
+  putchar ('\n');
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (i, i, 16, 16, 127);
+      do_test (i, i, 16, 16, 255);
+      do_test (i, 2 * i, 16, 16, 127);
+      do_test (2 * i, i, 16, 16, 255);
+      do_test (8 - i, 2 * i, 1 << i, 2 << i, 127);
+      do_test (2 * i, 8 - i, 2 << i, 1 << i, 127);
+      do_test (8 - i, 2 * i, 1 << i, 2 << i, 255);
+      do_test (2 * i, 8 - i, 2 << i, 1 << i, 255);
+    }
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (0, 0, 4 << i, 8 << i, 127);
+      do_test (0, 0, 16 << i, 8 << i, 127);
+      do_test (8 - i, 2 * i, 4 << i, 8 << i, 127);
+      do_test (8 - i, 2 * i, 16 << i, 8 << i, 127);
+    }
+
+  do_random_tests ();
+  return ret;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/string/test-strpbrk.c
===================================================================
--- trunk/src/libctests/glibc/string/test-strpbrk.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/test-strpbrk.c	(revision 2036)
@@ -0,0 +1,258 @@
+/* Test and measure strpbrk functions.
+   Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Jakub Jelinek <jakub@redhat.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef STRPBRK_RESULT
+# define STRPBRK_RESULT(s, pos) ((s)[(pos)] ? (s) + (pos) : NULL)
+# define RES_TYPE char *
+# define TEST_MAIN
+# include "test-string.h"
+
+typedef char *(*proto_t) (const char *, const char *);
+char *simple_strpbrk (const char *, const char *);
+char *stupid_strpbrk (const char *, const char *);
+
+IMPL (stupid_strpbrk, 0)
+IMPL (simple_strpbrk, 0)
+IMPL (strpbrk, 1)
+
+char *
+simple_strpbrk (const char *s, const char *rej)
+{
+  const char *r;
+  char c;
+
+  while ((c = *s++) != '\0')
+    for (r = rej; *r != '\0'; ++r)
+      if (*r == c)
+	return (char *) s - 1;
+  return NULL;
+}
+
+char *
+stupid_strpbrk (const char *s, const char *rej)
+{
+  size_t ns = strlen (s), nrej = strlen (rej);
+  size_t i, j;
+
+  for (i = 0; i < ns; ++i)
+    for (j = 0; j < nrej; ++j)
+      if (s[i] == rej[j])
+	return (char *) s + i;
+  return NULL;
+}
+#endif
+
+static void
+do_one_test (impl_t *impl, const char *s, const char *rej, RES_TYPE exp_res)
+{
+  RES_TYPE res = CALL (impl, s, rej);
+  if (res != exp_res)
+    {
+      error (0, 0, "Wrong result in function %s %p %p", impl->name,
+	     (void *) res, (void *) exp_res);
+      ret = 1;
+      return;
+    }
+
+  if (HP_TIMING_AVAIL)
+    {
+      hp_timing_t start __attribute ((unused));
+      hp_timing_t stop __attribute ((unused));
+      hp_timing_t best_time = ~ (hp_timing_t) 0;
+      size_t i;
+
+      for (i = 0; i < 32; ++i)
+	{
+	  HP_TIMING_NOW (start);
+	  CALL (impl, s, rej);
+	  HP_TIMING_NOW (stop);
+	  HP_TIMING_BEST (best_time, start, stop);
+	}
+
+      printf ("\t%zd", (size_t) best_time);
+    }
+}
+
+static void
+do_test (size_t align, size_t pos, size_t len)
+{
+  size_t i;
+  int c;
+  RES_TYPE result;
+  char *rej, *s;
+
+  align &= 7;
+  if (align + pos + 10 >= page_size || len > 240)
+    return;
+
+  rej = buf2 + (random () & 255);
+  s = buf1 + align;
+
+  for (i = 0; i < len; ++i)
+    {
+      rej[i] = random () & 255;
+      if (!rej[i])
+	rej[i] = random () & 255;
+      if (!rej[i])
+	rej[i] = 1 + (random () & 127);
+    }
+  rej[len] = '\0';
+  for (c = 1; c <= 255; ++c)
+    if (strchr (rej, c) == NULL)
+      break;
+
+  for (i = 0; i < pos; ++i)
+    {
+      s[i] = random () & 255;
+      if (strchr (rej, s[i]))
+	{
+	  s[i] = random () & 255;
+	  if (strchr (rej, s[i]))
+	    s[i] = c;
+	}
+    }
+  s[pos] = rej[random () % (len + 1)];
+  if (s[pos])
+    {
+      for (i = pos + 1; i < pos + 10; ++i)
+	s[i] = random () & 255;
+      s[i] = '\0';
+    }
+  result = STRPBRK_RESULT (s, pos);
+
+  if (HP_TIMING_AVAIL)
+    printf ("Length %4zd, alignment %2zd, rej len %2zd:", pos, align, len);
+
+  FOR_EACH_IMPL (impl, 0)
+    do_one_test (impl, s, rej, result);
+
+  if (HP_TIMING_AVAIL)
+    putchar ('\n');
+}
+
+static void
+do_random_tests (void)
+{
+  size_t i, j, n, align, pos, len, rlen;
+  RES_TYPE result;
+  int c;
+  unsigned char *p = buf1 + page_size - 512;
+  unsigned char *rej;
+
+  for (n = 0; n < ITERATIONS; n++)
+    {
+      align = random () & 15;
+      pos = random () & 511;
+      if (pos + align >= 511)
+	pos = 510 - align - (random () & 7);
+      len = random () & 511;
+      if (pos >= len && (random () & 1))
+	len = pos + 1 + (random () & 7);
+      if (len + align >= 512)
+	len = 511 - align - (random () & 7);
+      if (random () & 1)
+	rlen = random () & 63;
+      else
+	rlen = random () & 15;
+      rej = buf2 + page_size - rlen - 1 - (random () & 7);
+      for (i = 0; i < rlen; ++i)
+	{
+	  rej[i] = random () & 255;
+	  if (!rej[i])
+	    rej[i] = random () & 255;
+	  if (!rej[i])
+	    rej[i] = 1 + (random () & 127);
+	}
+      rej[i] = '\0';
+      for (c = 1; c <= 255; ++c)
+	if (strchr (rej, c) == NULL)
+	  break;
+      j = (pos > len ? pos : len) + align + 64;
+      if (j > 512)
+	j = 512;
+
+      for (i = 0; i < j; i++)
+	{
+	  if (i == len + align)
+	    p[i] = '\0';
+	  else if (i == pos + align)
+	    p[i] = rej[random () % (rlen + 1)];
+	  else if (i < align || i > pos + align)
+	    p[i] = random () & 255;
+	  else
+	    {
+	      p[i] = random () & 255;
+	      if (strchr (rej, p[i]))
+		{
+		  p[i] = random () & 255;
+		  if (strchr (rej, p[i]))
+		    p[i] = c;
+		}
+	    }
+	}
+
+      result = STRPBRK_RESULT (p + align, pos < len ? pos : len);
+
+      FOR_EACH_IMPL (impl, 1)
+	if (CALL (impl, p + align, rej) != result)
+	  {
+	    error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %p, %zd, %zd, %zd) %p != %p",
+		   n, impl->name, align, rej, rlen, pos, len,
+		   (void *) CALL (impl, p + align, rej), (void *) result);
+	    ret = 1;
+	  }
+    }
+}
+
+int
+test_main (void)
+{
+  size_t i;
+
+  test_init ();
+
+  printf ("%32s", "");
+  FOR_EACH_IMPL (impl, 0)
+    printf ("\t%s", impl->name);
+  putchar ('\n');
+
+  for (i = 0; i < 32; ++i)
+    {
+      do_test (0, 512, i);
+      do_test (i, 512, i);
+    }
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (0, 16 << i, 4);
+      do_test (i, 16 << i, 4);
+    }
+
+  for (i = 1; i < 8; ++i)
+    do_test (i, 64, 10);
+
+  for (i = 0; i < 64; ++i)
+    do_test (0, i, 6);
+
+  do_random_tests ();
+  return ret;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/string/test-strrchr.c
===================================================================
--- trunk/src/libctests/glibc/string/test-strrchr.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/test-strrchr.c	(revision 2036)
@@ -0,0 +1,237 @@
+/* Test and measure strrchr functions.
+   Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Jakub Jelinek <jakub@redhat.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define TEST_MAIN
+#include "test-string.h"
+
+typedef char *(*proto_t) (const char *, int);
+char *simple_strrchr (const char *, int);
+
+IMPL (simple_strrchr, 0)
+IMPL (strrchr, 1)
+
+char *
+simple_strrchr (const char *s, int c)
+{
+  const char *ret = NULL;
+
+  for (; *s != '\0'; ++s)
+    if (*s == (char) c)
+      ret = s;
+
+  return (char *) (c == '\0' ? s : ret);
+}
+
+static void
+do_one_test (impl_t *impl, const char *s, int c, char *exp_res)
+{
+  char *res = CALL (impl, s, c);
+  if (res != exp_res)
+    {
+      error (0, 0, "Wrong result in function %s %p %p", impl->name,
+	     res, exp_res);
+      ret = 1;
+      return;
+    }
+
+  if (HP_TIMING_AVAIL)
+    {
+      hp_timing_t start __attribute ((unused));
+      hp_timing_t stop __attribute ((unused));
+      hp_timing_t best_time = ~ (hp_timing_t) 0;
+      size_t i;
+
+      for (i = 0; i < 32; ++i)
+	{
+	  HP_TIMING_NOW (start);
+	  CALL (impl, s, c);
+	  HP_TIMING_NOW (stop);
+	  HP_TIMING_BEST (best_time, start, stop);
+	}
+
+      printf ("\t%zd", (size_t) best_time);
+    }
+}
+
+static void
+do_test (size_t align, size_t pos, size_t len, int seek_char, int max_char)
+{
+  size_t i;
+  char *result;
+
+  align &= 7;
+  if (align + len >= page_size)
+    return;
+
+  for (i = 0; i < len; ++i)
+    {
+      buf1[align + i] = random () & max_char;
+      if (!buf1[align + i])
+	buf1[align + i] = random () & max_char;
+      if (!buf1[align + i])
+        buf1[align + i] = 1;
+      if ((i > pos || pos >= len) && buf1[align + i] == seek_char)
+	buf1[align + i] = seek_char + 10 + (random () & 15);
+    }
+  buf1[align + len] = 0;
+
+  if (pos < len)
+    {
+      buf1[align + pos] = seek_char;
+      result = buf1 + align + pos;
+    }
+  else if (seek_char == 0)
+    result = buf1 + align + len;
+  else
+    result = NULL;
+
+  if (HP_TIMING_AVAIL)
+    printf ("Length %4zd, alignment %2zd:", pos, align);
+
+  FOR_EACH_IMPL (impl, 0)
+    do_one_test (impl, buf1 + align, seek_char, result);
+
+  if (HP_TIMING_AVAIL)
+    putchar ('\n');
+}
+
+static void
+do_random_tests (void)
+{
+  size_t i, j, n, align, pos, len;
+  int seek_char;
+  char *result;
+  unsigned char *p = buf1 + page_size - 512;
+
+  for (n = 0; n < ITERATIONS; n++)
+    {
+      align = random () & 15;
+      pos = random () & 511;
+      if (pos + align >= 511)
+	pos = 510 - align - (random () & 7);
+      len = random () & 511;
+      if (pos >= len)
+	len = pos + (random () & 7);
+      if (len + align >= 512)
+        len = 511 - align - (random () & 7);
+      seek_char = random () & 255;
+      if (seek_char && pos == len)
+	{
+	  if (pos)
+	    --pos;
+	  else
+	    ++len;
+	}
+      j = len + align + 64;
+      if (j > 512)
+        j = 512;
+
+      for (i = 0; i < j; i++)
+	{
+	  if (i == pos + align)
+	    p[i] = seek_char;
+	  else if (i == len + align)
+	    p[i] = 0;
+	  else
+	    {
+	      p[i] = random () & 255;
+	      if (((i > pos + align && i < len + align) || pos > len)
+		  && p[i] == seek_char)
+		p[i] = seek_char + 13;
+	      if (i < len + align && !p[i])
+		{
+		  p[i] = seek_char - 13;
+		  if (!p[i])
+		    p[i] = 140;
+		}
+	    }
+	}
+
+      if (pos <= len)
+	result = p + pos + align;
+      else if (seek_char == 0)
+        result = p + len + align;
+      else
+	result = NULL;
+
+      FOR_EACH_IMPL (impl, 1)
+	if (CALL (impl, p + align, seek_char) != result)
+	  {
+	    error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %d, %zd, %zd) %p != %p, p %p",
+		   n, impl->name, align, seek_char, len, pos,
+		   CALL (impl, p + align, seek_char), result, p);
+	    ret = 1;
+	  }
+    }
+}
+
+int
+test_main (void)
+{
+  size_t i;
+
+  test_init ();
+
+  printf ("%20s", "");
+  FOR_EACH_IMPL (impl, 0)
+    printf ("\t%s", impl->name);
+  putchar ('\n');
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (0, 16 << i, 2048, 23, 127);
+      do_test (i, 16 << i, 2048, 23, 127);
+    }
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (i, 64, 256, 23, 127);
+      do_test (i, 64, 256, 23, 255);
+    }
+
+  for (i = 0; i < 32; ++i)
+    {
+      do_test (0, i, i + 1, 23, 127);
+      do_test (0, i, i + 1, 23, 255);
+    }
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (0, 16 << i, 2048, 0, 127);
+      do_test (i, 16 << i, 2048, 0, 127);
+    }
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (i, 64, 256, 0, 127);
+      do_test (i, 64, 256, 0, 255);
+    }
+
+  for (i = 0; i < 32; ++i)
+    {
+      do_test (0, i, i + 1, 0, 127);
+      do_test (0, i, i + 1, 0, 255);
+    }
+
+  do_random_tests ();
+  return ret;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/string/test-strspn.c
===================================================================
--- trunk/src/libctests/glibc/string/test-strspn.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/test-strspn.c	(revision 2036)
@@ -0,0 +1,240 @@
+/* Test and measure strspn functions.
+   Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Jakub Jelinek <jakub@redhat.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define TEST_MAIN
+#include "test-string.h"
+
+typedef size_t (*proto_t) (const char *, const char *);
+size_t simple_strspn (const char *, const char *);
+size_t stupid_strspn (const char *, const char *);
+
+IMPL (stupid_strspn, 0)
+IMPL (simple_strspn, 0)
+IMPL (strspn, 1)
+
+size_t
+simple_strspn (const char *s, const char *acc)
+{
+  const char *r, *str = s;
+  char c;
+
+  while ((c = *s++) != '\0')
+    {
+      for (r = acc; *r != '\0'; ++r)
+	if (*r == c)
+	  break;
+      if (*r == '\0')
+	return s - str - 1;
+    }
+  return s - str - 1;
+}
+
+size_t
+stupid_strspn (const char *s, const char *acc)
+{
+  size_t ns = strlen (s), nacc = strlen (acc);
+  size_t i, j;
+
+  for (i = 0; i < ns; ++i)
+    {
+      for (j = 0; j < nacc; ++j)
+	if (s[i] == acc[j])
+	  break;
+      if (j == nacc)
+	return i;
+    }
+  return i;
+}
+
+static void
+do_one_test (impl_t *impl, const char *s, const char *acc, size_t exp_res)
+{
+  size_t res = CALL (impl, s, acc);
+  if (res != exp_res)
+    {
+      error (0, 0, "Wrong result in function %s %p %p", impl->name,
+	     (void *) res, (void *) exp_res);
+      ret = 1;
+      return;
+    }
+
+  if (HP_TIMING_AVAIL)
+    {
+      hp_timing_t start __attribute ((unused));
+      hp_timing_t stop __attribute ((unused));
+      hp_timing_t best_time = ~ (hp_timing_t) 0;
+      size_t i;
+
+      for (i = 0; i < 32; ++i)
+	{
+	  HP_TIMING_NOW (start);
+	  CALL (impl, s, acc);
+	  HP_TIMING_NOW (stop);
+	  HP_TIMING_BEST (best_time, start, stop);
+	}
+
+      printf ("\t%zd", (size_t) best_time);
+    }
+}
+
+static void
+do_test (size_t align, size_t pos, size_t len)
+{
+  size_t i;
+  char *acc, *s;
+
+  align &= 7;
+  if (align + pos + 10 >= page_size || len > 240 || ! len)
+    return;
+
+  acc = buf2 + (random () & 255);
+  s = buf1 + align;
+
+  for (i = 0; i < len; ++i)
+    {
+      acc[i] = random () & 255;
+      if (!acc[i])
+	acc[i] = random () & 255;
+      if (!acc[i])
+	acc[i] = 1 + (random () & 127);
+    }
+  acc[len] = '\0';
+
+  for (i = 0; i < pos; ++i)
+    s[i] = acc[random () % len];
+  s[pos] = random () & 255;
+  if (strchr (acc, s[pos]))
+    s[pos] = '\0';
+  else
+    {
+      for (i = pos + 1; i < pos + 10; ++i)
+	s[i] = random () & 255;
+      s[i] = '\0';
+    }
+
+  if (HP_TIMING_AVAIL)
+    printf ("Length %4zd, alignment %2zd, acc len %2zd:", pos, align, len);
+
+  FOR_EACH_IMPL (impl, 0)
+    do_one_test (impl, s, acc, pos);
+
+  if (HP_TIMING_AVAIL)
+    putchar ('\n');
+}
+
+static void
+do_random_tests (void)
+{
+  size_t i, j, n, align, pos, alen, len;
+  unsigned char *p = buf1 + page_size - 512;
+  unsigned char *acc;
+
+  for (n = 0; n < ITERATIONS; n++)
+    {
+      align = random () & 15;
+      if (random () & 1)
+	alen = random () & 63;
+      else
+	alen = random () & 15;
+      if (!alen)
+	pos = 0;
+      else
+	pos = random () & 511;
+      if (pos + align >= 511)
+	pos = 510 - align - (random () & 7);
+      len = random () & 511;
+      if (len + align >= 512)
+	len = 511 - align - (random () & 7);
+      acc = buf2 + page_size - alen - 1 - (random () & 7);
+      for (i = 0; i < alen; ++i)
+	{
+	  acc[i] = random () & 255;
+	  if (!acc[i])
+	    acc[i] = random () & 255;
+	  if (!acc[i])
+	    acc[i] = 1 + (random () & 127);
+	}
+      acc[i] = '\0';
+      j = (pos > len ? pos : len) + align + 64;
+      if (j > 512)
+	j = 512;
+
+      for (i = 0; i < j; i++)
+	{
+	  if (i == len + align)
+	    p[i] = '\0';
+	  else if (i == pos + align)
+	    {
+	      p[i] = random () & 255;
+	      if (strchr (acc, p[i]))
+		p[i] = '\0';
+	    }
+	  else if (i < align || i > pos + align)
+	    p[i] = random () & 255;
+	  else
+	    p[i] = acc [random () % alen];
+	}
+
+      FOR_EACH_IMPL (impl, 1)
+	if (CALL (impl, p + align, acc) != (pos < len ? pos : len))
+	  {
+	    error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %p, %zd, %zd, %zd) %zd != %zd",
+		   n, impl->name, align, acc, alen, pos, len,
+		   CALL (impl, p + align, acc), (pos < len ? pos : len));
+	    ret = 1;
+	  }
+    }
+}
+
+int
+test_main (void)
+{
+  size_t i;
+
+  test_init ();
+
+  printf ("%32s", "");
+  FOR_EACH_IMPL (impl, 0)
+    printf ("\t%s", impl->name);
+  putchar ('\n');
+
+  for (i = 0; i < 32; ++i)
+    {
+      do_test (0, 512, i);
+      do_test (i, 512, i);
+    }
+
+  for (i = 1; i < 8; ++i)
+    {
+      do_test (0, 16 << i, 4);
+      do_test (i, 16 << i, 4);
+    }
+
+  for (i = 1; i < 8; ++i)
+    do_test (i, 64, 10);
+
+  for (i = 0; i < 64; ++i)
+    do_test (0, i, 6);
+
+  do_random_tests ();
+  return ret;
+}
+
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/string/testcopy.c
===================================================================
--- trunk/src/libctests/glibc/string/testcopy.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/testcopy.c	(revision 2036)
@@ -0,0 +1,108 @@
+/* Copyright (C) 1990, 1991, 1992, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Torbjorn Granlund (tege@sics.se).
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <malloc.h>
+
+int
+main (void)
+{
+  char *mem, *memp;
+  char *rand_mem;
+  char *lo_around, *hi_around;
+  int size, max_size;
+  int src_off, dst_off;
+  int i;
+  int space_around = 10;
+
+  max_size = 256;
+
+  mem = malloc (max_size + 2 * max_size + 2 * space_around);
+  rand_mem = malloc (max_size);
+  lo_around = malloc (space_around);
+  hi_around = malloc (space_around);
+  memp = mem + space_around;
+
+  /* Fill RAND_MEM with random bytes, each non-zero.  */
+  for (i = 0; i < max_size; i++)
+    {
+      int x;
+      do
+	x = random ();
+      while (x == 0);
+      rand_mem[i] = x;
+    }
+
+  for (size = 0; size < max_size; size++)
+    {
+      printf("phase %d\n", size);
+      for (src_off = 0; src_off <= 16; src_off++)
+	{
+	  for (dst_off = 0; dst_off <= 16; dst_off++)
+	    {
+	      /* Put zero around the intended destination, to check
+		 that it's not clobbered.  */
+	      for (i = 1; i < space_around; i++)
+		{
+		  memp[dst_off - i] = 0;
+		  memp[dst_off + size - 1 + i] = 0;
+		}
+
+	      /* Fill the source area with known contents.  */
+	      for (i = 0; i < size; i++)
+		memp[src_off + i] = rand_mem[i];
+
+	      /* Remember the contents around the destination area.
+		 (It might not be what we wrote some lines above, since
+		 the src area and the dst area overlap.)  */
+	      for (i = 1; i < space_around; i++)
+		{
+		  lo_around[i] = memp[dst_off - i];
+		  hi_around[i] = memp[dst_off + size - 1 + i];
+		}
+
+	      memmove (memp + dst_off, memp + src_off, size);
+
+	      /* Check that the destination area has the same
+		 contents we wrote to the source area.  */
+	      for (i = 0; i < size; i++)
+		{
+		  if (memp[dst_off + i] != rand_mem[i])
+		    abort ();
+		}
+
+	      /* Check that the area around the destination is not
+		 clobbered.  */
+	      for (i = 1; i < space_around; i++)
+		{
+		  if (memp[dst_off - i] != lo_around[i])
+		    abort ();
+		  if (memp[dst_off + size - 1 + i] != hi_around[i])
+		    abort ();
+		}
+	    }
+	}
+    }
+
+  puts ("Test succeeded.");
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/string/tester.c
===================================================================
--- trunk/src/libctests/glibc/string/tester.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/tester.c	(revision 2036)
@@ -0,0 +1,1485 @@
+/* Tester for string functions.
+   Copyright (C) 1995-2000, 2001, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+/* Make sure we don't test the optimized inline functions if we want to
+   test the real implementation.  */
+#if !defined DO_STRING_INLINES
+#undef __USE_STRING_INLINES
+#endif
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <fcntl.h>
+
+#ifndef HAVE_GNU_LD
+#define _sys_nerr	sys_nerr
+#define _sys_errlist	sys_errlist
+#endif
+
+#define	STREQ(a, b)	(strcmp((a), (b)) == 0)
+
+const char *it = "<UNSET>";	/* Routine name for message routines. */
+size_t errors = 0;
+
+/* Complain if condition is not true.  */
+static void
+check (int thing, int number)
+{
+  if (!thing)
+    {
+      printf("%s flunked test %d\n", it, number);
+      ++errors;
+    }
+}
+
+/* Complain if first two args don't strcmp as equal.  */
+static void
+equal (const char *a, const char *b, int number)
+{
+  check(a != NULL && b != NULL && STREQ (a, b), number);
+}
+
+char one[50];
+char two[50];
+char *cp;
+
+static void
+test_strcmp (void)
+{
+  it = "strcmp";
+  check (strcmp ("", "") == 0, 1);		/* Trivial case. */
+  check (strcmp ("a", "a") == 0, 2);		/* Identity. */
+  check (strcmp ("abc", "abc") == 0, 3);	/* Multicharacter. */
+  check (strcmp ("abc", "abcd") < 0, 4);	/* Length mismatches. */
+  check (strcmp ("abcd", "abc") > 0, 5);
+  check (strcmp ("abcd", "abce") < 0, 6);	/* Honest miscompares. */
+  check (strcmp ("abce", "abcd") > 0, 7);
+  check (strcmp ("a\203", "a") > 0, 8);		/* Tricky if char signed. */
+  check (strcmp ("a\203", "a\003") > 0, 9);
+
+  {
+    char buf1[0x40], buf2[0x40];
+    int i, j;
+    for (i=0; i < 0x10; i++)
+      for (j = 0; j < 0x10; j++)
+	{
+	  int k;
+	  for (k = 0; k < 0x3f; k++)
+	    {
+	      buf1[k] = '0' ^ (k & 4);
+	      buf2[k] = '4' ^ (k & 4);
+	    }
+	  buf1[i] = buf1[0x3f] = 0;
+	  buf2[j] = buf2[0x3f] = 0;
+	  for (k = 0; k < 0xf; k++)
+	    {
+	      int cnum = 0x10+0x10*k+0x100*j+0x1000*i;
+	      check (strcmp (buf1+i,buf2+j) == 0, cnum);
+	      buf1[i+k] = 'A' + i + k;
+	      buf1[i+k+1] = 0;
+	      check (strcmp (buf1+i,buf2+j) > 0, cnum+1);
+	      check (strcmp (buf2+j,buf1+i) < 0, cnum+2);
+	      buf2[j+k] = 'B' + i + k;
+	      buf2[j+k+1] = 0;
+	      check (strcmp (buf1+i,buf2+j) < 0, cnum+3);
+	      check (strcmp (buf2+j,buf1+i) > 0, cnum+4);
+	      buf2[j+k] = 'A' + i + k;
+	      buf1[i] = 'A' + i + 0x80;
+	      check (strcmp (buf1+i,buf2+j) > 0, cnum+5);
+	      check (strcmp (buf2+j,buf1+i) < 0, cnum+6);
+	      buf1[i] = 'A' + i;
+	    }
+	}
+  }
+}
+
+#define SIMPLE_COPY(fn, n, str, ntest) \
+  do {									      \
+    int __n;								      \
+    char *cp;								      \
+    for (__n = 0; __n < (int) sizeof (one); ++__n)			      \
+      one[__n] = 'Z';							      \
+    fn (one, str);							      \
+    for (cp = one, __n = 0; __n < n; ++__n, ++cp)			      \
+      check (*cp == '0' + (n % 10), ntest);				      \
+    check (*cp == '\0', ntest);						      \
+  } while (0)
+
+static void
+test_strcpy (void)
+{
+  int i;
+  it = "strcpy";
+  check (strcpy (one, "abcd") == one, 1); /* Returned value. */
+  equal (one, "abcd", 2);		/* Basic test. */
+
+  (void) strcpy (one, "x");
+  equal (one, "x", 3);			/* Writeover. */
+  equal (one+2, "cd", 4);		/* Wrote too much? */
+
+  (void) strcpy (two, "hi there");
+  (void) strcpy (one, two);
+  equal (one, "hi there", 5);		/* Basic test encore. */
+  equal (two, "hi there", 6);		/* Stomped on source? */
+
+  (void) strcpy (one, "");
+  equal (one, "", 7);			/* Boundary condition. */
+
+  for (i = 0; i < 16; i++)
+    {
+      (void) strcpy (one + i, "hi there");	/* Unaligned destination. */
+      equal (one + i, "hi there", 8 + (i * 2));
+      (void) strcpy (two, one + i);		/* Unaligned source. */
+      equal (two, "hi there", 9 + (i * 2));
+    }
+
+  SIMPLE_COPY(strcpy, 0, "", 41);
+  SIMPLE_COPY(strcpy, 1, "1", 42);
+  SIMPLE_COPY(strcpy, 2, "22", 43);
+  SIMPLE_COPY(strcpy, 3, "333", 44);
+  SIMPLE_COPY(strcpy, 4, "4444", 45);
+  SIMPLE_COPY(strcpy, 5, "55555", 46);
+  SIMPLE_COPY(strcpy, 6, "666666", 47);
+  SIMPLE_COPY(strcpy, 7, "7777777", 48);
+  SIMPLE_COPY(strcpy, 8, "88888888", 49);
+  SIMPLE_COPY(strcpy, 9, "999999999", 50);
+  SIMPLE_COPY(strcpy, 10, "0000000000", 51);
+  SIMPLE_COPY(strcpy, 11, "11111111111", 52);
+  SIMPLE_COPY(strcpy, 12, "222222222222", 53);
+  SIMPLE_COPY(strcpy, 13, "3333333333333", 54);
+  SIMPLE_COPY(strcpy, 14, "44444444444444", 55);
+  SIMPLE_COPY(strcpy, 15, "555555555555555", 56);
+  SIMPLE_COPY(strcpy, 16, "6666666666666666", 57);
+
+  /* Simple test using implicitly coerced `void *' arguments.  */
+  const void *src = "frobozz";
+  void *dst = one;
+  check (strcpy (dst, src) == dst, 1);
+  equal (dst, "frobozz", 2);
+}
+
+static void
+test_stpcpy (void)
+{
+  it = "stpcpy";
+  check ((stpcpy (one, "a") - one) == 1, 1);
+  equal (one, "a", 2);
+
+  check ((stpcpy (one, "ab") - one) == 2, 3);
+  equal (one, "ab", 4);
+
+  check ((stpcpy (one, "abc") - one) == 3, 5);
+  equal (one, "abc", 6);
+
+  check ((stpcpy (one, "abcd") - one) == 4, 7);
+  equal (one, "abcd", 8);
+
+  check ((stpcpy (one, "abcde") - one) == 5, 9);
+  equal (one, "abcde", 10);
+
+  check ((stpcpy (one, "abcdef") - one) == 6, 11);
+  equal (one, "abcdef", 12);
+
+  check ((stpcpy (one, "abcdefg") - one) == 7, 13);
+  equal (one, "abcdefg", 14);
+
+  check ((stpcpy (one, "abcdefgh") - one) == 8, 15);
+  equal (one, "abcdefgh", 16);
+
+  check ((stpcpy (one, "abcdefghi") - one) == 9, 17);
+  equal (one, "abcdefghi", 18);
+
+  check ((stpcpy (one, "x") - one) == 1, 19);
+  equal (one, "x", 20);			/* Writeover. */
+  equal (one+2, "cdefghi", 21);		/* Wrote too much? */
+
+  check ((stpcpy (one, "xx") - one) == 2, 22);
+  equal (one, "xx", 23);		/* Writeover. */
+  equal (one+3, "defghi", 24);		/* Wrote too much? */
+
+  check ((stpcpy (one, "xxx") - one) == 3, 25);
+  equal (one, "xxx", 26);		/* Writeover. */
+  equal (one+4, "efghi", 27);		/* Wrote too much? */
+
+  check ((stpcpy (one, "xxxx") - one) == 4, 28);
+  equal (one, "xxxx", 29);		/* Writeover. */
+  equal (one+5, "fghi", 30);		/* Wrote too much? */
+
+  check ((stpcpy (one, "xxxxx") - one) == 5, 31);
+  equal (one, "xxxxx", 32);		/* Writeover. */
+  equal (one+6, "ghi", 33);		/* Wrote too much? */
+
+  check ((stpcpy (one, "xxxxxx") - one) == 6, 34);
+  equal (one, "xxxxxx", 35);		/* Writeover. */
+  equal (one+7, "hi", 36);		/* Wrote too much? */
+
+  check ((stpcpy (one, "xxxxxxx") - one) == 7, 37);
+  equal (one, "xxxxxxx", 38);		/* Writeover. */
+  equal (one+8, "i", 39);		/* Wrote too much? */
+
+  check ((stpcpy (stpcpy (stpcpy (one, "a"), "b"), "c") - one) == 3, 40);
+  equal (one, "abc", 41);
+  equal (one + 4, "xxx", 42);
+
+  SIMPLE_COPY(stpcpy, 0, "", 43);
+  SIMPLE_COPY(stpcpy, 1, "1", 44);
+  SIMPLE_COPY(stpcpy, 2, "22", 45);
+  SIMPLE_COPY(stpcpy, 3, "333", 46);
+  SIMPLE_COPY(stpcpy, 4, "4444", 47);
+  SIMPLE_COPY(stpcpy, 5, "55555", 48);
+  SIMPLE_COPY(stpcpy, 6, "666666", 49);
+  SIMPLE_COPY(stpcpy, 7, "7777777", 50);
+  SIMPLE_COPY(stpcpy, 8, "88888888", 51);
+  SIMPLE_COPY(stpcpy, 9, "999999999", 52);
+  SIMPLE_COPY(stpcpy, 10, "0000000000", 53);
+  SIMPLE_COPY(stpcpy, 11, "11111111111", 54);
+  SIMPLE_COPY(stpcpy, 12, "222222222222", 55);
+  SIMPLE_COPY(stpcpy, 13, "3333333333333", 56);
+  SIMPLE_COPY(stpcpy, 14, "44444444444444", 57);
+  SIMPLE_COPY(stpcpy, 15, "555555555555555", 58);
+  SIMPLE_COPY(stpcpy, 16, "6666666666666666", 59);
+}
+
+static void
+test_stpncpy (void)
+{
+  it = "stpncpy";
+  memset (one, 'x', sizeof (one));
+  check (stpncpy (one, "abc", 2) == one + 2, 1);
+  check (stpncpy (one, "abc", 3) == one + 3, 2);
+  check (stpncpy (one, "abc", 4) == one + 3, 3);
+  check (one[3] == '\0' && one[4] == 'x', 4);
+  check (stpncpy (one, "abcd", 5) == one + 4, 5);
+  check (one[4] == '\0' && one[5] == 'x', 6);
+  check (stpncpy (one, "abcd", 6) == one + 4, 7);
+  check (one[4] == '\0' && one[5] == '\0' && one[6] == 'x', 8);
+}
+
+static void
+test_strcat (void)
+{
+  it = "strcat";
+  (void) strcpy (one, "ijk");
+  check (strcat (one, "lmn") == one, 1); /* Returned value. */
+  equal (one, "ijklmn", 2);		/* Basic test. */
+
+  (void) strcpy (one, "x");
+  (void) strcat (one, "yz");
+  equal (one, "xyz", 3);			/* Writeover. */
+  equal (one+4, "mn", 4);			/* Wrote too much? */
+
+  (void) strcpy (one, "gh");
+  (void) strcpy (two, "ef");
+  (void) strcat (one, two);
+  equal (one, "ghef", 5);			/* Basic test encore. */
+  equal (two, "ef", 6);			/* Stomped on source? */
+
+  (void) strcpy (one, "");
+  (void) strcat (one, "");
+  equal (one, "", 7);			/* Boundary conditions. */
+  (void) strcpy (one, "ab");
+  (void) strcat (one, "");
+  equal (one, "ab", 8);
+  (void) strcpy (one, "");
+  (void) strcat (one, "cd");
+  equal (one, "cd", 9);
+}
+
+static void
+test_strncat (void)
+{
+  /* First test it as strcat, with big counts, then test the count
+     mechanism.  */
+  it = "strncat";
+  (void) strcpy (one, "ijk");
+  check (strncat (one, "lmn", 99) == one, 1);	/* Returned value. */
+  equal (one, "ijklmn", 2);		/* Basic test. */
+
+  (void) strcpy (one, "x");
+  (void) strncat (one, "yz", 99);
+  equal (one, "xyz", 3);		/* Writeover. */
+  equal (one+4, "mn", 4);		/* Wrote too much? */
+
+  (void) strcpy (one, "gh");
+  (void) strcpy (two, "ef");
+  (void) strncat (one, two, 99);
+  equal (one, "ghef", 5);			/* Basic test encore. */
+  equal (two, "ef", 6);			/* Stomped on source? */
+
+  (void) strcpy (one, "");
+  (void) strncat (one, "", 99);
+  equal (one, "", 7);			/* Boundary conditions. */
+  (void) strcpy (one, "ab");
+  (void) strncat (one, "", 99);
+  equal (one, "ab", 8);
+  (void) strcpy (one, "");
+  (void) strncat (one, "cd", 99);
+  equal (one, "cd", 9);
+
+  (void) strcpy (one, "ab");
+  (void) strncat (one, "cdef", 2);
+  equal (one, "abcd", 10);			/* Count-limited. */
+
+  (void) strncat (one, "gh", 0);
+  equal (one, "abcd", 11);			/* Zero count. */
+
+  (void) strncat (one, "gh", 2);
+  equal (one, "abcdgh", 12);		/* Count and length equal. */
+}
+
+static void
+test_strncmp (void)
+{
+  /* First test as strcmp with big counts, then test count code.  */
+  it = "strncmp";
+  check (strncmp ("", "", 99) == 0, 1);	/* Trivial case. */
+  check (strncmp ("a", "a", 99) == 0, 2);	/* Identity. */
+  check (strncmp ("abc", "abc", 99) == 0, 3);	/* Multicharacter. */
+  check (strncmp ("abc", "abcd", 99) < 0, 4);	/* Length unequal. */
+  check (strncmp ("abcd", "abc", 99) > 0, 5);
+  check (strncmp ("abcd", "abce", 99) < 0, 6);	/* Honestly unequal. */
+  check (strncmp ("abce", "abcd", 99) > 0, 7);
+  check (strncmp ("a\203", "a", 2) > 0, 8);	/* Tricky if '\203' < 0 */
+  check (strncmp ("a\203", "a\003", 2) > 0, 9);
+  check (strncmp ("abce", "abcd", 3) == 0, 10);	/* Count limited. */
+  check (strncmp ("abce", "abc", 3) == 0, 11);	/* Count == length. */
+  check (strncmp ("abcd", "abce", 4) < 0, 12);	/* Nudging limit. */
+  check (strncmp ("abc", "def", 0) == 0, 13);	/* Zero count. */
+}
+
+static void
+test_strncpy (void)
+{
+  /* Testing is a bit different because of odd semantics.  */
+  it = "strncpy";
+  check (strncpy (one, "abc", 4) == one, 1);	/* Returned value. */
+  equal (one, "abc", 2);			/* Did the copy go right? */
+
+  (void) strcpy (one, "abcdefgh");
+  (void) strncpy (one, "xyz", 2);
+  equal (one, "xycdefgh", 3);			/* Copy cut by count. */
+
+  (void) strcpy (one, "abcdefgh");
+  (void) strncpy (one, "xyz", 3);		/* Copy cut just before NUL. */
+  equal (one, "xyzdefgh", 4);
+
+  (void) strcpy (one, "abcdefgh");
+  (void) strncpy (one, "xyz", 4);		/* Copy just includes NUL. */
+  equal (one, "xyz", 5);
+  equal (one+4, "efgh", 6);			/* Wrote too much? */
+
+  (void) strcpy (one, "abcdefgh");
+  (void) strncpy (one, "xyz", 5);		/* Copy includes padding. */
+  equal (one, "xyz", 7);
+  equal (one+4, "", 8);
+  equal (one+5, "fgh", 9);
+
+  (void) strcpy (one, "abc");
+  (void) strncpy (one, "xyz", 0);		/* Zero-length copy. */
+  equal (one, "abc", 10);
+
+  (void) strncpy (one, "", 2);		/* Zero-length source. */
+  equal (one, "", 11);
+  equal (one+1, "", 12);
+  equal (one+2, "c", 13);
+
+  (void) strcpy (one, "hi there");
+  (void) strncpy (two, one, 9);
+  equal (two, "hi there", 14);		/* Just paranoia. */
+  equal (one, "hi there", 15);		/* Stomped on source? */
+}
+
+static void
+test_strlen (void)
+{
+  it = "strlen";
+  check (strlen ("") == 0, 1);		/* Empty. */
+  check (strlen ("a") == 1, 2);		/* Single char. */
+  check (strlen ("abcd") == 4, 3);	/* Multiple chars. */
+  {
+    char buf[4096];
+    int i;
+    char *p;
+    for (i=0; i < 0x100; i++)
+      {
+	p = (char *) ((unsigned long int)(buf + 0xff) & ~0xff) + i;
+	strcpy (p, "OK");
+	strcpy (p+3, "BAD/WRONG");
+	check (strlen (p) == 2, 4+i);
+      }
+   }
+}
+
+static void
+test_strchr (void)
+{
+  it = "strchr";
+  check (strchr ("abcd", 'z') == NULL, 1);	/* Not found. */
+  (void) strcpy (one, "abcd");
+  check (strchr (one, 'c') == one+2, 2);	/* Basic test. */
+  check (strchr (one, 'd') == one+3, 3);	/* End of string. */
+  check (strchr (one, 'a') == one, 4);		/* Beginning. */
+  check (strchr (one, '\0') == one+4, 5);	/* Finding NUL. */
+  (void) strcpy (one, "ababa");
+  check (strchr (one, 'b') == one+1, 6);	/* Finding first. */
+  (void) strcpy (one, "");
+  check (strchr (one, 'b') == NULL, 7);		/* Empty string. */
+  check (strchr (one, '\0') == one, 8);		/* NUL in empty string. */
+  {
+    char buf[4096];
+    int i;
+    char *p;
+    for (i=0; i < 0x100; i++)
+      {
+	p = (char *) ((unsigned long int) (buf + 0xff) & ~0xff) + i;
+	strcpy (p, "OK");
+	strcpy (p+3, "BAD/WRONG");
+	check (strchr (p, '/') == NULL, 9+i);
+      }
+   }
+}
+
+static void
+test_strchrnul (void)
+{
+  const char *os;
+  it = "strchrnul";
+  cp = strchrnul ((os = "abcd"), 'z');
+  check (*cp == '\0', 1);			/* Not found. */
+  check (cp == os + 4, 2);
+  (void) strcpy (one, "abcd");
+  check (strchrnul (one, 'c') == one+2, 3);	/* Basic test. */
+  check (strchrnul (one, 'd') == one+3, 4);	/* End of string. */
+  check (strchrnul (one, 'a') == one, 5);	/* Beginning. */
+  check (strchrnul (one, '\0') == one+4, 6);	/* Finding NUL. */
+  (void) strcpy (one, "ababa");
+  check (strchrnul (one, 'b') == one+1, 7);	/* Finding first. */
+  (void) strcpy (one, "");
+  check (strchrnul (one, 'b') == one, 8);	/* Empty string. */
+  check (strchrnul (one, '\0') == one, 9);	/* NUL in empty string. */
+  {
+    char buf[4096];
+    int i;
+    char *p;
+    for (i=0; i < 0x100; i++)
+      {
+	p = (char *) ((unsigned long int) (buf + 0xff) & ~0xff) + i;
+	strcpy (p, "OK");
+	strcpy (p+3, "BAD/WRONG");
+	cp = strchrnul (p, '/');
+	check (*cp == '\0', 9+2*i);
+	check (cp == p+2, 10+2*i);
+      }
+   }
+}
+
+static void
+test_rawmemchr (void)
+{
+  it = "rawmemchr";
+  (void) strcpy (one, "abcd");
+  check (rawmemchr (one, 'c') == one+2, 1);	/* Basic test. */
+  check (rawmemchr (one, 'd') == one+3, 2);	/* End of string. */
+  check (rawmemchr (one, 'a') == one, 3);		/* Beginning. */
+  check (rawmemchr (one, '\0') == one+4, 4);	/* Finding NUL. */
+  (void) strcpy (one, "ababa");
+  check (rawmemchr (one, 'b') == one+1, 5);	/* Finding first. */
+  (void) strcpy (one, "");
+  check (rawmemchr (one, '\0') == one, 6);	/* NUL in empty string. */
+  {
+    char buf[4096];
+    int i;
+    char *p;
+    for (i=0; i < 0x100; i++)
+      {
+	p = (char *) ((unsigned long int) (buf + 0xff) & ~0xff) + i;
+	strcpy (p, "OK");
+	strcpy (p+3, "BAD/WRONG");
+	check (rawmemchr (p, 'R') == p+8, 6+i);
+      }
+   }
+}
+
+static void
+test_index (void)
+{
+  it = "index";
+  check (index ("abcd", 'z') == NULL, 1);	/* Not found. */
+  (void) strcpy (one, "abcd");
+  check (index (one, 'c') == one+2, 2);	/* Basic test. */
+  check (index (one, 'd') == one+3, 3);	/* End of string. */
+  check (index (one, 'a') == one, 4);	/* Beginning. */
+  check (index (one, '\0') == one+4, 5);	/* Finding NUL. */
+  (void) strcpy (one, "ababa");
+  check (index (one, 'b') == one+1, 6);	/* Finding first. */
+  (void) strcpy (one, "");
+  check (index (one, 'b') == NULL, 7);	/* Empty string. */
+  check (index (one, '\0') == one, 8);	/* NUL in empty string. */
+}
+
+static void
+test_strrchr (void)
+{
+  it = "strrchr";
+  check (strrchr ("abcd", 'z') == NULL, 1);	/* Not found. */
+  (void) strcpy (one, "abcd");
+  check (strrchr (one, 'c') == one+2, 2);	/* Basic test. */
+  check (strrchr (one, 'd') == one+3, 3);	/* End of string. */
+  check (strrchr (one, 'a') == one, 4);		/* Beginning. */
+  check (strrchr (one, '\0') == one+4, 5);	/* Finding NUL. */
+  (void) strcpy (one, "ababa");
+  check (strrchr (one, 'b') == one+3, 6);	/* Finding last. */
+  (void) strcpy (one, "");
+  check (strrchr (one, 'b') == NULL, 7);	/* Empty string. */
+  check (strrchr (one, '\0') == one, 8);	/* NUL in empty string. */
+  {
+    char buf[4096];
+    int i;
+    char *p;
+    for (i=0; i < 0x100; i++)
+      {
+	p = (char *) ((unsigned long int) (buf + 0xff) & ~0xff) + i;
+	strcpy (p, "OK");
+	strcpy (p+3, "BAD/WRONG");
+	check (strrchr (p, '/') == NULL, 9+i);
+      }
+   }
+}
+
+static void
+test_memrchr (void)
+{
+  size_t l;
+  it = "memrchr";
+  check (memrchr ("abcd", 'z', 5) == NULL, 1);	/* Not found. */
+  (void) strcpy (one, "abcd");
+  l = strlen (one) + 1;
+  check (memrchr (one, 'c', l) == one+2, 2);	/* Basic test. */
+  check (memrchr (one, 'd', l) == one+3, 3);	/* End of string. */
+  check (memrchr (one, 'a', l) == one, 4);		/* Beginning. */
+  check (memrchr (one, '\0', l) == one+4, 5);	/* Finding NUL. */
+  (void) strcpy (one, "ababa");
+  l = strlen (one) + 1;
+  check (memrchr (one, 'b', l) == one+3, 6);	/* Finding last. */
+  (void) strcpy (one, "");
+  l = strlen (one) + 1;
+  check (memrchr (one, 'b', l) == NULL, 7);	/* Empty string. */
+  check (memrchr (one, '\0', l) == one, 8);	/* NUL in empty string. */
+
+  /* now test all possible alignment and length combinations to catch
+     bugs due to unrolled loops (assuming unrolling is limited to no
+     more than 128 byte chunks: */
+  {
+    char buf[128 + sizeof(long)];
+    long align, len, i, pos;
+
+    for (align = 0; align < (long) sizeof(long); ++align) {
+      for (len = 0; len < (long) (sizeof(buf) - align); ++len) {
+	for (i = 0; i < len; ++i)
+	  buf[align + i] = 'x';		/* don't depend on memset... */
+
+	for (pos = len - 1; pos >= 0; --pos) {
+#if 0
+	  printf("align %d, len %d, pos %d\n", align, len, pos);
+#endif
+	  check(memrchr(buf + align, 'x', len) == buf + align + pos, 9);
+	  check(memrchr(buf + align + pos + 1, 'x', len - (pos + 1)) == NULL,
+		10);
+	  buf[align + pos] = '-';
+	}
+      }
+    }
+  }
+}
+
+static void
+test_rindex (void)
+{
+  it = "rindex";
+  check (rindex ("abcd", 'z') == NULL, 1);	/* Not found. */
+  (void) strcpy (one, "abcd");
+  check (rindex (one, 'c') == one+2, 2);	/* Basic test. */
+  check (rindex (one, 'd') == one+3, 3);	/* End of string. */
+  check (rindex (one, 'a') == one, 4);	/* Beginning. */
+  check (rindex (one, '\0') == one+4, 5);	/* Finding NUL. */
+  (void) strcpy (one, "ababa");
+  check (rindex (one, 'b') == one+3, 6);	/* Finding last. */
+  (void) strcpy (one, "");
+  check (rindex (one, 'b') == NULL, 7);	/* Empty string. */
+  check (rindex (one, '\0') == one, 8);	/* NUL in empty string. */
+}
+
+static void
+test_strpbrk (void)
+{
+  it = "strpbrk";
+  check(strpbrk("abcd", "z") == NULL, 1);	/* Not found. */
+  (void) strcpy(one, "abcd");
+  check(strpbrk(one, "c") == one+2, 2);	/* Basic test. */
+  check(strpbrk(one, "d") == one+3, 3);	/* End of string. */
+  check(strpbrk(one, "a") == one, 4);	/* Beginning. */
+  check(strpbrk(one, "") == NULL, 5);	/* Empty search list. */
+  check(strpbrk(one, "cb") == one+1, 6);	/* Multiple search. */
+  (void) strcpy(one, "abcabdea");
+  check(strpbrk(one, "b") == one+1, 7);	/* Finding first. */
+  check(strpbrk(one, "cb") == one+1, 8);	/* With multiple search. */
+  check(strpbrk(one, "db") == one+1, 9);	/* Another variant. */
+  (void) strcpy(one, "");
+  check(strpbrk(one, "bc") == NULL, 10);	/* Empty string. */
+  (void) strcpy(one, "");
+  check(strpbrk(one, "bcd") == NULL, 11);	/* Empty string. */
+  (void) strcpy(one, "");
+  check(strpbrk(one, "bcde") == NULL, 12);	/* Empty string. */
+  check(strpbrk(one, "") == NULL, 13);	/* Both strings empty. */
+  (void) strcpy(one, "abcabdea");
+  check(strpbrk(one, "befg") == one+1, 14);	/* Finding first. */
+  check(strpbrk(one, "cbr") == one+1, 15);	/* With multiple search. */
+  check(strpbrk(one, "db") == one+1, 16);	/* Another variant. */
+  check(strpbrk(one, "efgh") == one+6, 17);	/* And yet another. */
+}
+
+static void
+test_strstr (void)
+{
+  it = "strstr";
+  check(strstr("abcd", "z") == NULL, 1);	/* Not found. */
+  check(strstr("abcd", "abx") == NULL, 2);	/* Dead end. */
+  (void) strcpy(one, "abcd");
+  check(strstr(one, "c") == one+2, 3);	/* Basic test. */
+  check(strstr(one, "bc") == one+1, 4);	/* Multichar. */
+  check(strstr(one, "d") == one+3, 5);	/* End of string. */
+  check(strstr(one, "cd") == one+2, 6);	/* Tail of string. */
+  check(strstr(one, "abc") == one, 7);	/* Beginning. */
+  check(strstr(one, "abcd") == one, 8);	/* Exact match. */
+  check(strstr(one, "abcde") == NULL, 9);	/* Too long. */
+  check(strstr(one, "de") == NULL, 10);	/* Past end. */
+  check(strstr(one, "") == one, 11);	/* Finding empty. */
+  (void) strcpy(one, "ababa");
+  check(strstr(one, "ba") == one+1, 12);	/* Finding first. */
+  (void) strcpy(one, "");
+  check(strstr(one, "b") == NULL, 13);	/* Empty string. */
+  check(strstr(one, "") == one, 14);	/* Empty in empty string. */
+  (void) strcpy(one, "bcbca");
+  check(strstr(one, "bca") == one+2, 15);	/* False start. */
+  (void) strcpy(one, "bbbcabbca");
+  check(strstr(one, "bbca") == one+1, 16);	/* With overlap. */
+}
+
+static void
+test_strspn (void)
+{
+  it = "strspn";
+  check(strspn("abcba", "abc") == 5, 1);	/* Whole string. */
+  check(strspn("abcba", "ab") == 2, 2);	/* Partial. */
+  check(strspn("abc", "qx") == 0, 3);	/* None. */
+  check(strspn("", "ab") == 0, 4);	/* Null string. */
+  check(strspn("abc", "") == 0, 5);	/* Null search list. */
+}
+
+static void
+test_strcspn (void)
+{
+  it = "strcspn";
+  check(strcspn("abcba", "qx") == 5, 1);	/* Whole string. */
+  check(strcspn("abcba", "cx") == 2, 2);	/* Partial. */
+  check(strcspn("abc", "abc") == 0, 3);	/* None. */
+  check(strcspn("", "ab") == 0, 4);	/* Null string. */
+  check(strcspn("abc", "") == 3, 5);	/* Null search list. */
+}
+
+static void
+test_strtok (void)
+{
+  it = "strtok";
+  (void) strcpy(one, "first, second, third");
+  equal(strtok(one, ", "), "first", 1);	/* Basic test. */
+  equal(one, "first", 2);
+  equal(strtok((char *)NULL, ", "), "second", 3);
+  equal(strtok((char *)NULL, ", "), "third", 4);
+  check(strtok((char *)NULL, ", ") == NULL, 5);
+  (void) strcpy(one, ", first, ");
+  equal(strtok(one, ", "), "first", 6);	/* Extra delims, 1 tok. */
+  check(strtok((char *)NULL, ", ") == NULL, 7);
+  (void) strcpy(one, "1a, 1b; 2a, 2b");
+  equal(strtok(one, ", "), "1a", 8);	/* Changing delim lists. */
+  equal(strtok((char *)NULL, "; "), "1b", 9);
+  equal(strtok((char *)NULL, ", "), "2a", 10);
+  (void) strcpy(two, "x-y");
+  equal(strtok(two, "-"), "x", 11);	/* New string before done. */
+  equal(strtok((char *)NULL, "-"), "y", 12);
+  check(strtok((char *)NULL, "-") == NULL, 13);
+  (void) strcpy(one, "a,b, c,, ,d");
+  equal(strtok(one, ", "), "a", 14);	/* Different separators. */
+  equal(strtok((char *)NULL, ", "), "b", 15);
+  equal(strtok((char *)NULL, " ,"), "c", 16);	/* Permute list too. */
+  equal(strtok((char *)NULL, " ,"), "d", 17);
+  check(strtok((char *)NULL, ", ") == NULL, 18);
+  check(strtok((char *)NULL, ", ") == NULL, 19);	/* Persistence. */
+  (void) strcpy(one, ", ");
+  check(strtok(one, ", ") == NULL, 20);	/* No tokens. */
+  (void) strcpy(one, "");
+  check(strtok(one, ", ") == NULL, 21);	/* Empty string. */
+  (void) strcpy(one, "abc");
+  equal(strtok(one, ", "), "abc", 22);	/* No delimiters. */
+  check(strtok((char *)NULL, ", ") == NULL, 23);
+  (void) strcpy(one, "abc");
+  equal(strtok(one, ""), "abc", 24);	/* Empty delimiter list. */
+  check(strtok((char *)NULL, "") == NULL, 25);
+  (void) strcpy(one, "abcdefgh");
+  (void) strcpy(one, "a,b,c");
+  equal(strtok(one, ","), "a", 26);	/* Basics again... */
+  equal(strtok((char *)NULL, ","), "b", 27);
+  equal(strtok((char *)NULL, ","), "c", 28);
+  check(strtok((char *)NULL, ",") == NULL, 29);
+  equal(one+6, "gh", 30);			/* Stomped past end? */
+  equal(one, "a", 31);			/* Stomped old tokens? */
+  equal(one+2, "b", 32);
+  equal(one+4, "c", 33);
+}
+
+static void
+test_strtok_r (void)
+{
+  it = "strtok_r";
+  (void) strcpy(one, "first, second, third");
+  cp = NULL;	/* Always initialize cp to make sure it doesn't point to some old data.  */
+  equal(strtok_r(one, ", ", &cp), "first", 1);	/* Basic test. */
+  equal(one, "first", 2);
+  equal(strtok_r((char *)NULL, ", ", &cp), "second", 3);
+  equal(strtok_r((char *)NULL, ", ", &cp), "third", 4);
+  check(strtok_r((char *)NULL, ", ", &cp) == NULL, 5);
+  (void) strcpy(one, ", first, ");
+  cp = NULL;
+  equal(strtok_r(one, ", ", &cp), "first", 6);	/* Extra delims, 1 tok. */
+  check(strtok_r((char *)NULL, ", ", &cp) == NULL, 7);
+  (void) strcpy(one, "1a, 1b; 2a, 2b");
+  cp = NULL;
+  equal(strtok_r(one, ", ", &cp), "1a", 8);	/* Changing delim lists. */
+  equal(strtok_r((char *)NULL, "; ", &cp), "1b", 9);
+  equal(strtok_r((char *)NULL, ", ", &cp), "2a", 10);
+  (void) strcpy(two, "x-y");
+  cp = NULL;
+  equal(strtok_r(two, "-", &cp), "x", 11);	/* New string before done. */
+  equal(strtok_r((char *)NULL, "-", &cp), "y", 12);
+  check(strtok_r((char *)NULL, "-", &cp) == NULL, 13);
+  (void) strcpy(one, "a,b, c,, ,d");
+  cp = NULL;
+  equal(strtok_r(one, ", ", &cp), "a", 14);	/* Different separators. */
+  equal(strtok_r((char *)NULL, ", ", &cp), "b", 15);
+  equal(strtok_r((char *)NULL, " ,", &cp), "c", 16);	/* Permute list too. */
+  equal(strtok_r((char *)NULL, " ,", &cp), "d", 17);
+  check(strtok_r((char *)NULL, ", ", &cp) == NULL, 18);
+  check(strtok_r((char *)NULL, ", ", &cp) == NULL, 19);	/* Persistence. */
+  (void) strcpy(one, ", ");
+  cp = NULL;
+  check(strtok_r(one, ", ", &cp) == NULL, 20);	/* No tokens. */
+  (void) strcpy(one, "");
+  cp = NULL;
+  check(strtok_r(one, ", ", &cp) == NULL, 21);	/* Empty string. */
+  check(strtok_r((char *)NULL, ", ", &cp) == NULL, 22);	/* Persistence. */
+  (void) strcpy(one, "abc");
+  cp = NULL;
+  equal(strtok_r(one, ", ", &cp), "abc", 23);	/* No delimiters. */
+  check(strtok_r((char *)NULL, ", ", &cp) == NULL, 24);
+  (void) strcpy(one, "abc");
+  cp = NULL;
+  equal(strtok_r(one, "", &cp), "abc", 25);	/* Empty delimiter list. */
+  check(strtok_r((char *)NULL, "", &cp) == NULL, 26);
+  (void) strcpy(one, "abcdefgh");
+  (void) strcpy(one, "a,b,c");
+  cp = NULL;
+  equal(strtok_r(one, ",", &cp), "a", 27);	/* Basics again... */
+  equal(strtok_r((char *)NULL, ",", &cp), "b", 28);
+  equal(strtok_r((char *)NULL, ",", &cp), "c", 29);
+  check(strtok_r((char *)NULL, ",", &cp) == NULL, 30);
+  equal(one+6, "gh", 31);			/* Stomped past end? */
+  equal(one, "a", 32);			/* Stomped old tokens? */
+  equal(one+2, "b", 33);
+  equal(one+4, "c", 34);
+}
+
+static void
+test_strsep (void)
+{
+  char *ptr;
+  it = "strsep";
+  cp = strcpy(one, "first, second, third");
+  equal(strsep(&cp, ", "), "first", 1);	/* Basic test. */
+  equal(one, "first", 2);
+  equal(strsep(&cp, ", "), "", 3);
+  equal(strsep(&cp, ", "), "second", 4);
+  equal(strsep(&cp, ", "), "", 5);
+  equal(strsep(&cp, ", "), "third", 6);
+  check(strsep(&cp, ", ") == NULL, 7);
+  cp = strcpy(one, ", first, ");
+  equal(strsep(&cp, ", "), "", 8);
+  equal(strsep(&cp, ", "), "", 9);
+  equal(strsep(&cp, ", "), "first", 10);	/* Extra delims, 1 tok. */
+  equal(strsep(&cp, ", "), "", 11);
+  equal(strsep(&cp, ", "), "", 12);
+  check(strsep(&cp, ", ") == NULL, 13);
+  cp = strcpy(one, "1a, 1b; 2a, 2b");
+  equal(strsep(&cp, ", "), "1a", 14);	/* Changing delim lists. */
+  equal(strsep(&cp, ", "), "", 15);
+  equal(strsep(&cp, "; "), "1b", 16);
+  equal(strsep(&cp, ", "), "", 17);
+  equal(strsep(&cp, ", "), "2a", 18);
+  cp = strcpy(two, "x-y");
+  equal(strsep(&cp, "-"), "x", 19);	/* New string before done. */
+  equal(strsep(&cp, "-"), "y", 20);
+  check(strsep(&cp, "-") == NULL, 21);
+  cp = strcpy(one, "a,b, c,, ,d ");
+  equal(strsep(&cp, ", "), "a", 22);	/* Different separators. */
+  equal(strsep(&cp, ", "), "b", 23);
+  equal(strsep(&cp, " ,"), "", 24);
+  equal(strsep(&cp, " ,"), "c", 25);	/* Permute list too. */
+  equal(strsep(&cp, " ,"), "", 26);
+  equal(strsep(&cp, " ,"), "", 27);
+  equal(strsep(&cp, " ,"), "", 28);
+  equal(strsep(&cp, " ,"), "d", 29);
+  equal(strsep(&cp, " ,"), "", 30);
+  check(strsep(&cp, ", ") == NULL, 31);
+  check(strsep(&cp, ", ") == NULL, 32);	/* Persistence. */
+  cp = strcpy(one, ", ");
+  equal(strsep(&cp, ", "), "", 33);
+  equal(strsep(&cp, ", "), "", 34);
+  equal(strsep(&cp, ", "), "", 35);
+  check(strsep(&cp, ", ") == NULL, 36);	/* No tokens. */
+  cp = strcpy(one, "");
+  equal(strsep(&cp, ", "), "", 37);
+  check(strsep(&cp, ", ") == NULL, 38);	/* Empty string. */
+  cp = strcpy(one, "abc");
+  equal(strsep(&cp, ", "), "abc", 39);	/* No delimiters. */
+  check(strsep(&cp, ", ") == NULL, 40);
+  cp = strcpy(one, "abc");
+  equal(strsep(&cp, ""), "abc", 41);	/* Empty delimiter list. */
+  check(strsep(&cp, "") == NULL, 42);
+  (void) strcpy(one, "abcdefgh");
+  cp = strcpy(one, "a,b,c");
+  equal(strsep(&cp, ","), "a", 43);	/* Basics again... */
+  equal(strsep(&cp, ","), "b", 44);
+  equal(strsep(&cp, ","), "c", 45);
+  check(strsep(&cp, ",") == NULL, 46);
+  equal(one+6, "gh", 47);		/* Stomped past end? */
+  equal(one, "a", 48);			/* Stomped old tokens? */
+  equal(one+2, "b", 49);
+  equal(one+4, "c", 50);
+
+  {
+    char text[] = "This,is,a,test";
+    char *list = strdupa (text);
+    equal (strsep (&list, ","), "This", 51);
+    equal (strsep (&list, ","), "is", 52);
+    equal (strsep (&list, ","), "a", 53);
+    equal (strsep (&list, ","), "test", 54);
+    check (strsep (&list, ",") == NULL, 55);
+  }
+
+  cp = strcpy(one, "a,b, c,, ,d,");
+  equal(strsep(&cp, ","), "a", 56);	/* Different separators. */
+  equal(strsep(&cp, ","), "b", 57);
+  equal(strsep(&cp, ","), " c", 58);	/* Permute list too. */
+  equal(strsep(&cp, ","), "", 59);
+  equal(strsep(&cp, ","), " ", 60);
+  equal(strsep(&cp, ","), "d", 61);
+  equal(strsep(&cp, ","), "", 62);
+  check(strsep(&cp, ",") == NULL, 63);
+  check(strsep(&cp, ",") == NULL, 64);	/* Persistence. */
+
+  cp = strcpy(one, "a,b, c,, ,d,");
+  equal(strsep(&cp, "xy,"), "a", 65);	/* Different separators. */
+  equal(strsep(&cp, "x,y"), "b", 66);
+  equal(strsep(&cp, ",xy"), " c", 67);	/* Permute list too. */
+  equal(strsep(&cp, "xy,"), "", 68);
+  equal(strsep(&cp, "x,y"), " ", 69);
+  equal(strsep(&cp, ",xy"), "d", 70);
+  equal(strsep(&cp, "xy,"), "", 71);
+  check(strsep(&cp, "x,y") == NULL, 72);
+  check(strsep(&cp, ",xy") == NULL, 73);	/* Persistence. */
+
+  cp = strcpy(one, "ABC");
+  one[4] = ':';
+  equal(strsep(&cp, "C"), "AB", 74);	/* Access beyond NUL.  */
+  ptr = strsep(&cp, ":");
+  equal(ptr, "", 75);
+  check(ptr == one + 3, 76);
+  check(cp == NULL, 77);
+
+  cp = strcpy(one, "ABC");
+  one[4] = ':';
+  equal(strsep(&cp, "CD"), "AB", 78);	/* Access beyond NUL.  */
+  ptr = strsep(&cp, ":.");
+  equal(ptr, "", 79);
+  check(ptr == one + 3, 80);
+
+  cp = strcpy(one, "ABC");		/* No token in string.  */
+  equal(strsep(&cp, ","), "ABC", 81);
+  check(cp == NULL, 82);
+
+  *one = '\0';				/* Empty string. */
+  cp = one;
+  ptr = strsep(&cp, ",");
+  equal(ptr, "", 83);
+  check(ptr == one, 84);
+  check(cp == NULL, 85);
+
+  *one = '\0';				/* Empty string and no token. */
+  cp = one;
+  ptr = strsep(&cp, "");
+  equal(ptr, "", 86);
+  check(ptr == one , 87);
+  check(cp == NULL, 88);
+}
+
+static void
+test_memcmp (void)
+{
+  it = "memcmp";
+  check(memcmp("a", "a", 1) == 0, 1);		/* Identity. */
+  check(memcmp("abc", "abc", 3) == 0, 2);	/* Multicharacter. */
+  check(memcmp("abcd", "abce", 4) < 0, 3);	/* Honestly unequal. */
+  check(memcmp("abce", "abcd", 4) > 0, 4);
+  check(memcmp("alph", "beta", 4) < 0, 5);
+  check(memcmp("a\203", "a\003", 2) > 0, 6);
+  check(memcmp("abce", "abcd", 3) == 0, 7);	/* Count limited. */
+  check(memcmp("abc", "def", 0) == 0, 8);	/* Zero count. */
+}
+
+static void
+test_memchr (void)
+{
+  it = "memchr";
+  check(memchr("abcd", 'z', 4) == NULL, 1);	/* Not found. */
+  (void) strcpy(one, "abcd");
+  check(memchr(one, 'c', 4) == one+2, 2);	/* Basic test. */
+  check(memchr(one, ~0xff|'c', 4) == one+2, 2);	/* ignore highorder bits. */
+  check(memchr(one, 'd', 4) == one+3, 3);	/* End of string. */
+  check(memchr(one, 'a', 4) == one, 4);	/* Beginning. */
+  check(memchr(one, '\0', 5) == one+4, 5);	/* Finding NUL. */
+  (void) strcpy(one, "ababa");
+  check(memchr(one, 'b', 5) == one+1, 6);	/* Finding first. */
+  check(memchr(one, 'b', 0) == NULL, 7);	/* Zero count. */
+  check(memchr(one, 'a', 1) == one, 8);	/* Singleton case. */
+  (void) strcpy(one, "a\203b");
+  check(memchr(one, 0203, 3) == one+1, 9);	/* Unsignedness. */
+
+  /* now test all possible alignment and length combinations to catch
+     bugs due to unrolled loops (assuming unrolling is limited to no
+     more than 128 byte chunks: */
+  {
+    char buf[128 + sizeof(long)];
+    long align, len, i, pos;
+
+    for (align = 0; align < (long) sizeof(long); ++align) {
+      for (len = 0; len < (long) (sizeof(buf) - align); ++len) {
+	for (i = 0; i < len; ++i) {
+	  buf[align + i] = 'x';		/* don't depend on memset... */
+	}
+	for (pos = 0; pos < len; ++pos) {
+#if 0
+	  printf("align %d, len %d, pos %d\n", align, len, pos);
+#endif
+	  check(memchr(buf + align, 'x', len) == buf + align + pos, 10);
+	  check(memchr(buf + align, 'x', pos) == NULL, 11);
+	  buf[align + pos] = '-';
+	}
+      }
+    }
+  }
+}
+
+static void
+test_memcpy (void)
+{
+  int i;
+  it = "memcpy";
+  check(memcpy(one, "abc", 4) == one, 1);	/* Returned value. */
+  equal(one, "abc", 2);			/* Did the copy go right? */
+
+  (void) strcpy(one, "abcdefgh");
+  (void) memcpy(one+1, "xyz", 2);
+  equal(one, "axydefgh", 3);		/* Basic test. */
+
+  (void) strcpy(one, "abc");
+  (void) memcpy(one, "xyz", 0);
+  equal(one, "abc", 4);			/* Zero-length copy. */
+
+  (void) strcpy(one, "hi there");
+  (void) strcpy(two, "foo");
+  (void) memcpy(two, one, 9);
+  equal(two, "hi there", 5);		/* Just paranoia. */
+  equal(one, "hi there", 6);		/* Stomped on source? */
+
+  for (i = 0; i < 16; i++)
+    {
+      const char *x = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
+      strcpy (one, x);
+      check (memcpy (one + i, "hi there", 9) == one + i,
+	     7 + (i * 6));		/* Unaligned destination. */
+      check (memcmp (one, x, i) == 0, 8 + (i * 6));  /* Wrote under? */
+      equal (one + i, "hi there", 9 + (i * 6));
+      check (one[i + 9] == 'x', 10 + (i * 6));       /* Wrote over? */
+      check (memcpy (two, one + i, 9) == two,
+	     11 + (i * 6));		/* Unaligned source. */
+      equal (two, "hi there", 12 + (i * 6));
+    }
+}
+
+static void
+test_mempcpy (void)
+{
+  int i;
+  it = "mempcpy";
+  check(mempcpy(one, "abc", 4) == one + 4, 1);	/* Returned value. */
+  equal(one, "abc", 2);			/* Did the copy go right? */
+
+  (void) strcpy(one, "abcdefgh");
+  (void) mempcpy(one+1, "xyz", 2);
+  equal(one, "axydefgh", 3);		/* Basic test. */
+
+  (void) strcpy(one, "abc");
+  (void) mempcpy(one, "xyz", 0);
+  equal(one, "abc", 4);			/* Zero-length copy. */
+
+  (void) strcpy(one, "hi there");
+  (void) strcpy(two, "foo");
+  (void) mempcpy(two, one, 9);
+  equal(two, "hi there", 5);		/* Just paranoia. */
+  equal(one, "hi there", 6);		/* Stomped on source? */
+
+  for (i = 0; i < 16; i++)
+    {
+      const char *x = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
+      strcpy (one, x);
+      check (mempcpy (one + i, "hi there", 9) == one + i + 9,
+	     7 + (i * 6));		/* Unaligned destination. */
+      check (memcmp (one, x, i) == 0, 8 + (i * 6));  /* Wrote under? */
+      equal (one + i, "hi there", 9 + (i * 6));
+      check (one[i + 9] == 'x', 10 + (i * 6));       /* Wrote over? */
+      check (mempcpy (two, one + i, 9) == two + 9,
+	     11 + (i * 6));		/* Unaligned source. */
+      equal (two, "hi there", 12 + (i * 6));
+    }
+}
+
+static void
+test_memmove (void)
+{
+  it = "memmove";
+  check(memmove(one, "abc", 4) == one, 1);	/* Returned value. */
+  equal(one, "abc", 2);			/* Did the copy go right? */
+
+  (void) strcpy(one, "abcdefgh");
+  (void) memmove(one+1, "xyz", 2);
+  equal(one, "axydefgh", 3);		/* Basic test. */
+
+  (void) strcpy(one, "abc");
+  (void) memmove(one, "xyz", 0);
+  equal(one, "abc", 4);			/* Zero-length copy. */
+
+  (void) strcpy(one, "hi there");
+  (void) strcpy(two, "foo");
+  (void) memmove(two, one, 9);
+  equal(two, "hi there", 5);		/* Just paranoia. */
+  equal(one, "hi there", 6);		/* Stomped on source? */
+
+  (void) strcpy(one, "abcdefgh");
+  (void) memmove(one+1, one, 9);
+  equal(one, "aabcdefgh", 7);		/* Overlap, right-to-left. */
+
+  (void) strcpy(one, "abcdefgh");
+  (void) memmove(one+1, one+2, 7);
+  equal(one, "acdefgh", 8);		/* Overlap, left-to-right. */
+
+  (void) strcpy(one, "abcdefgh");
+  (void) memmove(one, one, 9);
+  equal(one, "abcdefgh", 9);		/* 100% overlap. */
+}
+
+static void
+test_memccpy (void)
+{
+  /* First test like memcpy, then the search part The SVID, the only
+     place where memccpy is mentioned, says overlap might fail, so we
+     don't try it.  Besides, it's hard to see the rationale for a
+     non-left-to-right memccpy.  */
+  it = "memccpy";
+  check(memccpy(one, "abc", 'q', 4) == NULL, 1);	/* Returned value. */
+  equal(one, "abc", 2);			/* Did the copy go right? */
+
+  (void) strcpy(one, "abcdefgh");
+  (void) memccpy(one+1, "xyz", 'q', 2);
+  equal(one, "axydefgh", 3);		/* Basic test. */
+
+  (void) strcpy(one, "abc");
+  (void) memccpy(one, "xyz", 'q', 0);
+  equal(one, "abc", 4);			/* Zero-length copy. */
+
+  (void) strcpy(one, "hi there");
+  (void) strcpy(two, "foo");
+  (void) memccpy(two, one, 'q', 9);
+  equal(two, "hi there", 5);		/* Just paranoia. */
+  equal(one, "hi there", 6);		/* Stomped on source? */
+
+  (void) strcpy(one, "abcdefgh");
+  (void) strcpy(two, "horsefeathers");
+  check(memccpy(two, one, 'f', 9) == two+6, 7);	/* Returned value. */
+  equal(one, "abcdefgh", 8);		/* Source intact? */
+  equal(two, "abcdefeathers", 9);		/* Copy correct? */
+
+  (void) strcpy(one, "abcd");
+  (void) strcpy(two, "bumblebee");
+  check(memccpy(two, one, 'a', 4) == two+1, 10);	/* First char. */
+  equal(two, "aumblebee", 11);
+  check(memccpy(two, one, 'd', 4) == two+4, 12);	/* Last char. */
+  equal(two, "abcdlebee", 13);
+  (void) strcpy(one, "xyz");
+  check(memccpy(two, one, 'x', 1) == two+1, 14);	/* Singleton. */
+  equal(two, "xbcdlebee", 15);
+}
+
+static void
+test_memset (void)
+{
+  int i;
+
+  it = "memset";
+  (void) strcpy(one, "abcdefgh");
+  check(memset(one+1, 'x', 3) == one+1, 1);	/* Return value. */
+  equal(one, "axxxefgh", 2);		/* Basic test. */
+
+  (void) memset(one+2, 'y', 0);
+  equal(one, "axxxefgh", 3);		/* Zero-length set. */
+
+  (void) memset(one+5, 0, 1);
+  equal(one, "axxxe", 4);			/* Zero fill. */
+  equal(one+6, "gh", 5);			/* And the leftover. */
+
+  (void) memset(one+2, 010045, 1);
+  equal(one, "ax\045xe", 6);		/* Unsigned char convert. */
+
+  /* Non-8bit fill character.  */
+  memset (one, 0x101, sizeof (one));
+  for (i = 0; i < (int) sizeof (one); ++i)
+    check (one[i] == '\01', 7);
+
+  /* Test for more complex versions of memset, for all alignments and
+     lengths up to 256. This test takes a little while, perhaps it should
+     be made weaker?  */
+  {
+    char data[512];
+    int j;
+    int k;
+    int c;
+
+    for (i = 0; i < 512; i++)
+      data[i] = 'x';
+    for (c = 0; c <= 'y'; c += 'y')  /* check for memset(,0,) and
+					memset(,'y',) */
+      for (j = 0; j < 256; j++)
+	for (i = 0; i < 256; i++)
+	  {
+	    memset (data + i, c, j);
+	    for (k = 0; k < i; k++)
+	      if (data[k] != 'x')
+		goto fail;
+	    for (k = i; k < i+j; k++)
+	      {
+		if (data[k] != c)
+		  goto fail;
+		data[k] = 'x';
+	      }
+	    for (k = i+j; k < 512; k++)
+	      if (data[k] != 'x')
+		goto fail;
+	    continue;
+
+	  fail:
+	    check (0, 8 + i + j * 256 + (c != 0) * 256 * 256);
+	  }
+  }
+}
+
+static void
+test_bcopy (void)
+{
+  /* Much like memcpy.  Berklix manual is silent about overlap, so
+     don't test it.  */
+  it = "bcopy";
+  (void) bcopy("abc", one, 4);
+  equal(one, "abc", 1);			/* Simple copy. */
+
+  (void) strcpy(one, "abcdefgh");
+  (void) bcopy("xyz", one+1, 2);
+  equal(one, "axydefgh", 2);		/* Basic test. */
+
+  (void) strcpy(one, "abc");
+  (void) bcopy("xyz", one, 0);
+  equal(one, "abc", 3);			/* Zero-length copy. */
+
+  (void) strcpy(one, "hi there");
+  (void) strcpy(two, "foo");
+  (void) bcopy(one, two, 9);
+  equal(two, "hi there", 4);		/* Just paranoia. */
+  equal(one, "hi there", 5);		/* Stomped on source? */
+}
+
+static void
+test_bzero (void)
+{
+  it = "bzero";
+  (void) strcpy(one, "abcdef");
+  bzero(one+2, 2);
+  equal(one, "ab", 1);			/* Basic test. */
+  equal(one+3, "", 2);
+  equal(one+4, "ef", 3);
+
+  (void) strcpy(one, "abcdef");
+  bzero(one+2, 0);
+  equal(one, "abcdef", 4);		/* Zero-length copy. */
+}
+
+static void
+test_strndup (void)
+{
+  char *p, *q;
+  it = "strndup";
+  p = strndup("abcdef", 12);
+  check(p != NULL, 1);
+  if (p != NULL)
+    {
+      equal(p, "abcdef", 2);
+      q = strndup(p + 1, 2);
+      check(q != NULL, 3);
+      if (q != NULL)
+	equal(q, "bc", 4);
+      free (q);
+    }
+  free (p);
+  p = strndup("abc def", 3);
+  check(p != NULL, 5);
+  if (p != NULL)
+    equal(p, "abc", 6);
+  free (p);
+}
+
+static void
+test_bcmp (void)
+{
+  it = "bcmp";
+  check(bcmp("a", "a", 1) == 0, 1);	/* Identity. */
+  check(bcmp("abc", "abc", 3) == 0, 2);	/* Multicharacter. */
+  check(bcmp("abcd", "abce", 4) != 0, 3);	/* Honestly unequal. */
+  check(bcmp("abce", "abcd", 4) != 0, 4);
+  check(bcmp("alph", "beta", 4) != 0, 5);
+  check(bcmp("abce", "abcd", 3) == 0, 6);	/* Count limited. */
+  check(bcmp("abc", "def", 0) == 0, 8);	/* Zero count. */
+}
+
+static void
+test_strerror (void)
+{
+  it = "strerror";
+  check(strerror(EDOM) != 0, 1);
+  check(strerror(ERANGE) != 0, 2);
+  check(strerror(ENOENT) != 0, 3);
+}
+
+static void
+test_strcasecmp (void)
+{
+  it = "strcasecmp";
+  /* Note that the locale is "C".  */
+  check(strcasecmp("a", "a") == 0, 1);
+  check(strcasecmp("a", "A") == 0, 2);
+  check(strcasecmp("A", "a") == 0, 3);
+  check(strcasecmp("a", "b") < 0, 4);
+  check(strcasecmp("c", "b") > 0, 5);
+  check(strcasecmp("abc", "AbC") == 0, 6);
+  check(strcasecmp("0123456789", "0123456789") == 0, 7);
+  check(strcasecmp("", "0123456789") < 0, 8);
+  check(strcasecmp("AbC", "") > 0, 9);
+  check(strcasecmp("AbC", "A") > 0, 10);
+  check(strcasecmp("AbC", "Ab") > 0, 11);
+  check(strcasecmp("AbC", "ab") > 0, 12);
+}
+
+static void
+test_strncasecmp (void)
+{
+  it = "strncasecmp";
+  /* Note that the locale is "C".  */
+  check(strncasecmp("a", "a", 5) == 0, 1);
+  check(strncasecmp("a", "A", 5) == 0, 2);
+  check(strncasecmp("A", "a", 5) == 0, 3);
+  check(strncasecmp("a", "b", 5) < 0, 4);
+  check(strncasecmp("c", "b", 5) > 0, 5);
+  check(strncasecmp("abc", "AbC", 5) == 0, 6);
+  check(strncasecmp("0123456789", "0123456789", 10) == 0, 7);
+  check(strncasecmp("", "0123456789", 10) < 0, 8);
+  check(strncasecmp("AbC", "", 5) > 0, 9);
+  check(strncasecmp("AbC", "A", 5) > 0, 10);
+  check(strncasecmp("AbC", "Ab", 5) > 0, 11);
+  check(strncasecmp("AbC", "ab", 5) > 0, 12);
+  check(strncasecmp("0123456789", "AbC", 0) == 0, 13);
+  check(strncasecmp("AbC", "abc", 1) == 0, 14);
+  check(strncasecmp("AbC", "abc", 2) == 0, 15);
+  check(strncasecmp("AbC", "abc", 3) == 0, 16);
+  check(strncasecmp("AbC", "abcd", 3) == 0, 17);
+  check(strncasecmp("AbC", "abcd", 4) < 0, 18);
+  check(strncasecmp("ADC", "abcd", 1) == 0, 19);
+  check(strncasecmp("ADC", "abcd", 2) > 0, 20);
+}
+
+int
+main (void)
+{
+  int status;
+
+  /* Test strcmp first because we use it to test other things.  */
+  test_strcmp ();
+
+  /* Test strcpy next because we need it to set up other tests.  */
+  test_strcpy ();
+
+  /* A closely related function is stpcpy.  */
+  test_stpcpy ();
+
+  /* stpncpy.  */
+  test_stpncpy ();
+
+  /* strcat.  */
+  test_strcat ();
+
+  /* strncat.  */
+  test_strncat ();
+
+  /* strncmp.  */
+  test_strncmp ();
+
+  /* strncpy.  */
+  test_strncpy ();
+
+  /* strlen.  */
+  test_strlen ();
+
+  /* strchr.  */
+  test_strchr ();
+
+  /* strchrnul.  */
+  test_strchrnul ();
+
+  /* rawmemchr.  */
+  test_rawmemchr ();
+
+  /* index - just like strchr.  */
+  test_index ();
+
+  /* strrchr.  */
+  test_strrchr ();
+
+  /* memrchr.  */
+  test_memrchr ();
+
+  /* rindex - just like strrchr.  */
+  test_rindex ();
+
+  /* strpbrk - somewhat like strchr.  */
+  test_strpbrk ();
+
+  /* strstr - somewhat like strchr.  */
+  test_strstr ();
+
+  /* strspn.  */
+  test_strspn ();
+
+  /* strcspn.  */
+  test_strcspn ();
+
+  /* strtok - the hard one.  */
+  test_strtok ();
+
+  /* strtok_r.  */
+  test_strtok_r ();
+
+  /* strsep.  */
+  test_strsep ();
+
+  /* memcmp.  */
+  test_memcmp ();
+
+  /* memchr.  */
+  test_memchr ();
+
+  /* memcpy - need not work for overlap.  */
+  test_memcpy ();
+
+  /* memmove - must work on overlap.  */
+  test_memmove ();
+
+  /* mempcpy */
+  test_mempcpy ();
+
+  /* memccpy.  */
+  test_memccpy ();
+
+  /* memset.  */
+  test_memset ();
+
+  /* bcopy.  */
+  test_bcopy ();
+
+  /* bzero.  */
+  test_bzero ();
+
+  /* bcmp - somewhat like memcmp.  */
+  test_bcmp ();
+
+  /* strndup.  */
+  test_strndup ();
+
+  /* strerror - VERY system-dependent.  */
+  test_strerror ();
+
+  /* strcasecmp.  Without locale dependencies.  */
+  test_strcasecmp ();
+
+  /* strncasecmp.  Without locale dependencies.  */
+  test_strncasecmp ();
+
+  if (errors == 0)
+    {
+      status = EXIT_SUCCESS;
+      puts("No errors.");
+    }
+  else
+    {
+      status = EXIT_FAILURE;
+      printf("%Zd errors.\n", errors);
+    }
+
+  return status;
+}
Index: trunk/src/libctests/glibc/string/tst-bswap.c
===================================================================
--- trunk/src/libctests/glibc/string/tst-bswap.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/tst-bswap.c	(revision 2036)
@@ -0,0 +1,74 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <byteswap.h>
+#include <stdio.h>
+
+extern unsigned long long int wash (unsigned long long int a);
+
+int
+main (void)
+{
+  int result = 0;
+
+  /* Test the functions with constant arguments.  */
+  if (bswap_16 (0x1234) != 0x3412)
+    {
+      puts ("bswap_16 (constant) flunked");
+      result = 1;
+    }
+  if (bswap_32 (0x12345678) != 0x78563412)
+    {
+      puts ("bswap_32 (constant) flunked");
+      result = 1;
+    }
+  if (bswap_64 (0x1234567890abcdefULL) != 0xefcdab9078563412ULL)
+    {
+      puts ("bswap_64 (constant) flunked");
+      result = 1;
+    }
+
+  /* Test the functions with non-constant arguments.  */
+  if (bswap_16 (wash (0x1234)) != 0x3412)
+    {
+      puts ("bswap_16 (non-constant) flunked");
+      result = 1;
+    }
+  if (bswap_32 (wash (0x12345678)) != 0x78563412)
+    {
+      puts ("bswap_32 (non-constant) flunked");
+      result = 1;
+    }
+  if (bswap_64 (wash (0x1234567890abcdefULL)) != 0xefcdab9078563412ULL)
+    {
+      puts ("bswap_64 (non-constant) flunked");
+      result = 1;
+    }
+
+  return result;
+}
+
+
+unsigned long long int
+wash (unsigned long long int a)
+{
+  /* Do nothing.  This function simply exists to avoid that the compiler
+     regards the argument to the bswap_*() functions as constant.  */
+  return a + 0;
+}
Index: trunk/src/libctests/glibc/string/tst-inlcall.c
===================================================================
--- trunk/src/libctests/glibc/string/tst-inlcall.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/tst-inlcall.c	(revision 2036)
@@ -0,0 +1,83 @@
+/* Tester for calling inline string functions.
+   Copyright (C) 1998, 2000, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+/* Make sure we test the optimized inline functions.  */
+#define __USE_STRING_INLINES	1
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <fcntl.h>
+
+
+int
+main (void)
+{
+  int status;
+  int errors = 0;
+  char buf1[1000];
+  char *cp;
+  char ch;
+
+  cp = strcpy (buf1, "hello world");
+  if (strcmp ("hello world", cp++) != 0)
+    {
+      puts ("strcmp test 1 failed");
+      ++errors;
+    }
+
+  cp = buf1;
+  if (strcmp (cp++, "hello world") != 0)
+    {
+      puts ("strcmp test 2 failed");
+      ++errors;
+    }
+
+  ch = 'h';
+  if (strchr ("hello world", ch++) == NULL)
+    {
+      puts ("strchr test 1 failed");
+      ++errors;
+    }
+
+  const char * const hw = "hello world";
+  if (strpbrk (hw, "o") - hw != 4)
+    {
+      puts ("strpbrk test 1 failed");
+      ++errors;
+    }
+
+  if (errors == 0)
+    {
+      status = EXIT_SUCCESS;
+      puts ("No errors.");
+    }
+  else
+    {
+      status = EXIT_FAILURE;
+      printf ("%d errors.\n", errors);
+    }
+  return status;
+}
Index: trunk/src/libctests/glibc/string/tst-strfry.c
===================================================================
--- trunk/src/libctests/glibc/string/tst-strfry.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/tst-strfry.c	(revision 2036)
@@ -0,0 +1,15 @@
+#include <stdio.h>
+#include <string.h>
+
+static int
+do_test (void)
+{
+  char str[] = "this is a test";
+
+  strfry (str);
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/string/tst-strlen.c
===================================================================
--- trunk/src/libctests/glibc/string/tst-strlen.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/tst-strlen.c	(revision 2036)
@@ -0,0 +1,45 @@
+/* Make sure we don't test the optimized inline functions if we want to
+   test the real implementation.  */
+#undef __USE_STRING_INLINES
+
+#include <stdio.h>
+#include <string.h>
+
+int
+main(int argc, char *argv[])
+{
+  static const size_t lens[] = { 0, 1, 0, 2, 0, 1, 0, 3,
+				 0, 1, 0, 2, 0, 1, 0, 4 };
+  char basebuf[24 + 32];
+  size_t base;
+
+  for (base = 0; base < 32; ++base)
+    {
+      char *buf = basebuf + base;
+      size_t words;
+
+      for (words = 0; words < 4; ++words)
+	{
+	  size_t last;
+	  memset (buf, 'a', words * 4);
+
+	  for (last = 0; last < 16; ++last)
+	    {
+	      buf[words * 4 + 0] = (last & 1) != 0 ? 'b' : '\0';
+	      buf[words * 4 + 1] = (last & 2) != 0 ? 'c' : '\0';
+	      buf[words * 4 + 2] = (last & 4) != 0 ? 'd' : '\0';
+	      buf[words * 4 + 3] = (last & 8) != 0 ? 'e' : '\0';
+	      buf[words * 4 + 4] = '\0';
+
+	      if (strlen (buf) != words * 4 + lens[last]
+		  || strnlen (buf, -1) != words * 4 + lens[last])
+		{
+		  printf ("failed for base=%Zu, words=%Zu, and last=%Zu\n",
+			  base, words, last);
+		  return 1;
+		}
+	    }
+	}
+    }
+  return 0;
+}
Index: trunk/src/libctests/glibc/string/tst-strtok.c
===================================================================
--- trunk/src/libctests/glibc/string/tst-strtok.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/tst-strtok.c	(revision 2036)
@@ -0,0 +1,23 @@
+/* Testcase for strtok reported by Andrew Church <achurch@achurch.org>.  */
+#include <stdio.h>
+#include <string.h>
+
+int
+main (void)
+{
+  char buf[1] = { 0 };
+  int result = 0;
+
+  if (strtok (buf, " ") != NULL)
+    {
+      puts ("first strtok call did not return NULL");
+      result = 1;
+    }
+  else if (strtok (NULL, " ") != NULL)
+    {
+      puts ("second strtok call did not return NULL");
+      result = 1;
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/string/tst-strxfrm.c
===================================================================
--- trunk/src/libctests/glibc/string/tst-strxfrm.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/tst-strxfrm.c	(revision 2036)
@@ -0,0 +1,71 @@
+/* Based on a test case by Paul Eggert.  */
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+char const string[] = "";
+
+
+static int
+test (const char *locale)
+{
+  size_t bufsize;
+  size_t r;
+  size_t l;
+  char *buf;
+  locale_t loc;
+  int result = 0;
+
+  if (setlocale (LC_COLLATE, locale) == NULL)
+    {
+      printf ("cannot set locale \"%s\"\n", locale);
+      return 1;
+    }
+  bufsize = strxfrm (NULL, string, 0) + 1;
+  buf = malloc (bufsize);
+  if (buf == NULL)
+    {
+      printf ("cannot allocate %zd bytes\n", bufsize);
+      return 1;
+    }
+  r = strxfrm (buf, string, bufsize);
+  l = strlen (buf);
+  if (r != l)
+    {
+       printf ("locale \"%s\": strxfrm returned %zu, strlen returned %zu\n",
+	       locale, r, l);
+       result = 1;
+    }
+
+  loc = newlocale (1 << LC_ALL, locale, NULL);
+
+  r = strxfrm_l (buf, string, bufsize, loc);
+  l = strlen (buf);
+  if (r != l)
+    {
+       printf ("locale \"%s\": strxfrm_l returned %zu, strlen returned %zu\n",
+	       locale, r, l);
+       result = 1;
+    }
+
+  freelocale (loc);
+
+  free (buf);
+
+  return result;
+}
+
+
+int
+main (void)
+{
+  int result = 0;
+
+  result |= test ("C");
+  result |= test ("en_US.ISO-8859-1");
+  result |= test ("de_DE.UTF-8");
+
+  return result;
+}
Index: trunk/src/libctests/glibc/string/tst-svc.c
===================================================================
--- trunk/src/libctests/glibc/string/tst-svc.c	(revision 2036)
+++ trunk/src/libctests/glibc/string/tst-svc.c	(revision 2036)
@@ -0,0 +1,45 @@
+/* Test for strverscmp() */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#define  MAX_STRINGS      256
+#define  MAX_LINE_SIZE    32
+
+static int
+compare (const void *p1, const void *p2)
+{
+  return strverscmp (*((char **) p1), *((char **) p2));
+}
+
+int
+main (int argc, char *argv[])
+{
+  char line[MAX_LINE_SIZE + 1];
+  char *str[MAX_STRINGS];
+  int  count = 0;
+  int  i, n;
+
+  while (count < MAX_STRINGS && fgets (line, MAX_LINE_SIZE, stdin) != NULL)
+    {
+      n = strlen (line) - 1;
+
+      if (line[n] == '\n')
+        line[n] = '\0';
+
+      str[count] = strdup (line);
+
+      if (str[count] == NULL)
+        exit (EXIT_FAILURE);
+
+      ++count;
+    }
+
+  qsort (str, count, sizeof (char *), compare);
+
+  for (i = 0; i < count; ++i)
+    puts (str[i]);
+
+  return EXIT_SUCCESS;
+}
Index: trunk/src/libctests/glibc/string/tst-svc.expect
===================================================================
--- trunk/src/libctests/glibc/string/tst-svc.expect	(revision 2036)
+++ trunk/src/libctests/glibc/string/tst-svc.expect	(revision 2036)
@@ -0,0 +1,31 @@
+000
+001
+00
+00a
+01
+01a
+0
+0a
+2.8
+2.8-0.4
+20
+21
+22
+212
+CP037
+CP345
+CP1257
+foo
+foo-0.4
+foo-0.4a
+foo-0.4b
+foo-0.5
+foo-0.10.5
+foo-3.01
+foo-3.0
+foo-3.0.0
+foo-3.0.1
+foo-3.2
+foo-3.10
+foo00
+foo0
Index: trunk/src/libctests/glibc/string/tst-svc.input
===================================================================
--- trunk/src/libctests/glibc/string/tst-svc.input	(revision 2036)
+++ trunk/src/libctests/glibc/string/tst-svc.input	(revision 2036)
@@ -0,0 +1,31 @@
+0a
+00
+0
+01
+001
+01a
+00a
+000
+20
+212
+21
+22
+foo0
+foo00
+foo-0.4
+foo-3.0
+foo
+foo-3.0.0
+foo-3.0.1
+foo-0.5
+foo-0.4b
+foo-3.10
+foo-3.2
+foo-3.01
+foo-0.4a
+foo-0.10.5
+CP037
+CP1257
+CP345
+2.8-0.4
+2.8
Index: trunk/src/libctests/glibc/sunrpc/Makefile
===================================================================
--- trunk/src/libctests/glibc/sunrpc/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/sunrpc/Makefile	(revision 2036)
@@ -0,0 +1,192 @@
+# Copyright (C) 1994-2004, 2005 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Sub-makefile for sunrpc portion of the library.
+#
+subdir	:= sunrpc
+
+# The code in this subdirectory is taken from Sun's RPCSRC-4.0
+# distribution with some additional changes from the TI-RPC package
+# which is also available from Sun.  The files are heavily changed to
+# compile cleanly and to fit in the GNU environment.  All the code
+# from Sun's rpc, etc, and rpcgen subdirectories is in this directory;
+# the rpc subdirectory contains only the header files.  Other than
+# that, several files were renamed so as not to exceed 14-character
+# file name limits:
+#
+#	authunix_prot.c -> authuxprot.c
+#	bindresvport.c -> bindrsvprt.c
+#	clnt_generic.c -> clnt_gen.c
+#	clnt_perror.c -> clnt_perr.c
+#	clnt_simple.c -> clnt_simp.c
+#	get_myaddress.c -> get_myaddr.c
+#	pmap_getmaps.c -> pm_getmaps.c
+#	pmap_getport.c -> pm_getport.c
+#	rpc_callmsg.c -> rpc_cmsg.c
+#	rpc_commondata.c -> rpc_common.c
+#	rpc_dtablesize.c -> rpc_dtable.c
+#	svc_auth_unix.c -> svc_authux.c
+#	xdr_reference.c -> xdr_ref.c
+
+rpcsvc = bootparam_prot.x nlm_prot.x rstat.x \
+	 yppasswd.x klm_prot.x rex.x sm_inter.x mount.x \
+	 rusers.x spray.x nfs_prot.x rquota.x key_prot.x
+headers = $(addprefix rpc/,auth.h auth_unix.h clnt.h netdb.h pmap_clnt.h \
+			   pmap_prot.h pmap_rmt.h rpc.h rpc_msg.h svc.h \
+			   svc_auth.h types.h xdr.h auth_des.h \
+			   des_crypt.h key_prot.h rpc_des.h) \
+	  $(rpcsvc:%=rpcsvc/%) rpcsvc/bootparam.h
+install-others = $(inst_sysconfdir)/rpc
+generated = $(rpcsvc:%.x=rpcsvc/%.h) $(rpcsvc:%.x=x%.c) $(rpcsvc:%.x=x%.stmp) \
+	    $(rpcsvc:%.x=rpcsvc/%.stmp) rpcgen
+generated-dirs := rpcsvc
+
+routines := auth_none auth_unix authuxprot bindrsvprt \
+	    clnt_gen clnt_perr clnt_raw clnt_simp clnt_tcp \
+	    clnt_udp rpc_dtable get_myaddr getrpcport \
+	    pmap_clnt pm_getmaps pm_getport pmap_prot \
+	    pmap_prot2 pmap_rmt rpc_prot rpc_common rpc_cmsg rpc_thread \
+	    svc svc_auth svc_authux svc_raw svc_run svc_simple \
+	    svc_tcp svc_udp xdr xdr_array xdr_float xdr_mem \
+	    xdr_rec xdr_ref xdr_stdio publickey xdr_sizeof \
+	    auth_des authdes_prot des_crypt des_impl des_soft \
+	    key_call key_prot netname openchild rtime svcauth_des xcrypt\
+	    clnt_unix svc_unix create_xid xdr_intXX_t
+
+others := rpcinfo
+install-bin := rpcgen
+install-sbin := rpcinfo
+rpcgen-objs = rpc_main.o rpc_hout.o rpc_cout.o rpc_parse.o \
+	      rpc_scan.o rpc_util.o rpc_svcout.o rpc_clntout.o \
+	      rpc_tblout.o rpc_sample.o
+# These headers are part of rpcgen.
+distribute := proto.h rpc_util.h rpc_parse.h rpc_scan.h \
+	      $(rpcgen-objs:.o=.c) etc.rpc \
+	      errqueue.h
+extra-objs = $(rpcgen-objs)
+
+all: # Make this the default target; it will be defined in Rules.
+
+include ../Makeconfig
+
+xtests := tst-getmyaddr
+
+ifeq ($(have-thread-library),yes)
+xtests += thrsvc
+endif
+distribute += thrsvc.c
+
+ifeq (yes,$(build-static-nss))
+otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
+	     $(resolvobjdir)/libresolv.a
+endif
+
+ifeq (no,$(cross-compiling))
+# We can only build this library if we can run the rpcgen we build.
+headers += $(rpcsvc:%.x=rpcsvc/%.h)
+extra-libs := librpcsvc
+extra-libs-others := librpcsvc # Make it in `others' pass, not `lib' pass.
+librpcsvc-routines = $(rpcsvc:%.x=x%)
+librpcsvc-inhibit-o = .os # Build no shared rpcsvc library.
+omit-deps = $(librpcsvc-routines)
+endif
+
+CFLAGS-xbootparam_prot.c = -Wno-unused $(PIC-ccflag)
+CFLAGS-xnlm_prot.c = -Wno-unused $(PIC-ccflag)
+CFLAGS-xrstat.c = -Wno-unused $(PIC-ccflag)
+CFLAGS-xyppasswd.c = -Wno-unused $(PIC-ccflag)
+CFLAGS-xklm_prot.c = -Wno-unused $(PIC-ccflag)
+CFLAGS-xrex.c = -Wno-unused $(PIC-ccflag)
+CFLAGS-xsm_inter.c = -Wno-unused $(PIC-ccflag)
+CFLAGS-xmount.c = -Wno-unused $(PIC-ccflag)
+CFLAGS-xrusers.c = -Wno-unused $(PIC-ccflag)
+CFLAGS-xspray.c = -Wno-unused $(PIC-ccflag)
+CFLAGS-xnfs_prot.c = -Wno-unused $(PIC-ccflag)
+CFLAGS-xrquota.c = -Wno-unused $(PIC-ccflag)
+CFLAGS-xkey_prot.c = -Wno-unused $(PIC-ccflag)
+CFLAGS-auth_unix.c = -fexceptions
+CFLAGS-key_call.c = -fexceptions
+CFLAGS-pmap_rmt.c = -fexceptions
+CFLAGS-clnt_perr.c = -fexceptions
+CFLAGS-openchild.c = -fexceptions
+
+CPPFLAGS += -D_RPC_THREAD_SAFE_
+
+include ../Rules
+
+$(objpfx)rpcgen: $(addprefix $(objpfx),$(rpcgen-objs)) \
+  $(sort $(filter $(common-objpfx)libc%,$(link-libc))) \
+  $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
+	$(+link)
+
+# This makes sure -DNOT_IN_libc is passed for all these modules.
+cpp-srcs-left := $(rpcgen-objs:.o=.c)
+lib := nonlib
+include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
+
+# Tell rpcgen where to find the C preprocessor.
+rpcgen-cmd = CPP='$(CC) -E -x c-header' $(built-program-cmd) -Y ../scripts
+
+# Install the rpc data base file.
+$(inst_sysconfdir)/rpc: etc.rpc $(+force)
+	$(do-install)
+
+
+# Generate the rpcsvc headers with rpcgen.
+# We use a stamp file to avoid unnessary recompilation each time rpcgen is
+# relinked.
+$(rpcsvc:%.x=$(objpfx)rpcsvc/%.h): $(objpfx)rpcsvc/%.h: $(objpfx)rpcsvc/%.stmp
+	@:
+$(objpfx)rpcsvc/%.stmp: rpcsvc/%.x $(objpfx)rpcgen
+	$(make-target-directory)
+	-@rm -f ${@:stmp=T} $@
+	$(rpcgen-cmd) -h $< -o ${@:stmp=T}
+	$(move-if-change) $(@:stmp=T) $(@:stmp=h)
+	touch $@
+
+# Generate the rpcsvc XDR functions with rpcgen.
+$(rpcsvc:%.x=$(objpfx)x%.c): $(objpfx)x%.c: $(objpfx)x%.stmp
+	@:
+$(objpfx)x%.stmp: rpcsvc/%.x $(objpfx)rpcgen
+	-@rm -f ${@:stmp=T} $@
+	$(rpcgen-cmd) -c $< -o ${@:stmp=T}
+	$(move-if-change) $(@:stmp=T) $(@:stmp=c)
+	touch $@
+
+# The generated source files depend on the corresponding generated headers.
+# Gratuitous dependency on generated .c file here just gets it mentioned to
+# avoid being an intermediate file and getting removed.
+define o-iterator-doit
+$(rpcsvc:%.x=$(objpfx)x%$o): $(objpfx)x%$o: $(objpfx)x%.c $(objpfx)rpcsvc/%.h
+endef
+object-suffixes-left = $(filter-out $(librpcsvc-inhibit-o),$(object-suffixes))
+include $(o-iterator)
+
+rpcsvc-dt-files := $(foreach o,$(filter-out $(librpcsvc-inhibit-o),\
+					    $(object-suffixes)),\
+			     $(rpcsvc:%.x=$(objpfx)x%$o.dt))
+rpcsvc-depfiles := $(patsubst %.dt,%.d,$(wildcard $(rpcsvc-dt-files))) \
+		   $(wildcard $(rpcsvc-dt-files:.dt=.d))
+ifdef rpcsvc-depfiles
+ifneq ($(no_deps),t)
+-include $(rpcsvc-depfiles)
+endif
+endif
+
+$(objpfx)thrsvc: $(shared-thread-library)
Index: trunk/src/libctests/glibc/sunrpc/tst-getmyaddr.c
===================================================================
--- trunk/src/libctests/glibc/sunrpc/tst-getmyaddr.c	(revision 2036)
+++ trunk/src/libctests/glibc/sunrpc/tst-getmyaddr.c	(revision 2036)
@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include <string.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <rpc/clnt.h>
+
+
+static int
+do_test (void)
+{
+  struct sockaddr_in ad;
+  struct sockaddr_in ad2;
+  memset (&ad, '\0', sizeof (ad));
+  memset (&ad2, '\0', sizeof (ad2));
+
+  get_myaddress (&ad);
+
+  printf ("addr = %s:%d\n", inet_ntoa (ad.sin_addr), ad.sin_port);
+
+  return memcmp (&ad, &ad2, sizeof (ad)) == 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/sysdeps/alpha/fpu/ftestexcept.c
===================================================================
--- trunk/src/libctests/glibc/sysdeps/alpha/fpu/ftestexcept.c	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/alpha/fpu/ftestexcept.c	(revision 2036)
@@ -0,0 +1,32 @@
+/* Test exception in current environment.
+   Copyright (C) 1997, 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Richard Henderson <rth@tamu.edu>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <fenv_libc.h>
+
+int
+fetestexcept (int excepts)
+{
+  unsigned long tmp;
+
+  /* Get current exceptions.  */
+  tmp = __ieee_get_fp_control();
+
+  return tmp & excepts & SWCR_STATUS_MASK;
+}
Index: trunk/src/libctests/glibc/sysdeps/alpha/fpu/libm-test-ulps
===================================================================
--- trunk/src/libctests/glibc/sysdeps/alpha/fpu/libm-test-ulps	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/alpha/fpu/libm-test-ulps	(revision 2036)
@@ -0,0 +1,886 @@
+# Begin of automatic generation
+
+# atan2
+Test "atan2 (-0.00756827042671106339, -.001792735857538728036) == -1.80338464113663849327153994379639112":
+float: 6
+ifloat: 6
+Test "atan2 (-0.75, -1.0) == -2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+Test "atan2 (0.75, -1.0) == 2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+Test "atan2 (1.390625, 0.9296875) == 0.981498387184244311516296577615519772":
+float: 1
+ifloat: 1
+
+# atanh
+Test "atanh (0.75) == 0.972955074527656652552676371721589865":
+float: 1
+ifloat: 1
+
+# cacosh
+Test "Real part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+Test "Imaginary part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+# casin
+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# catan
+Test "Real part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+float: 3
+ifloat: 3
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i":
+float: 4
+ifloat: 4
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 4
+idouble: 4
+Test "Imaginary part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+float: 4
+ifloat: 4
+Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+float: 6
+ifloat: 6
+
+# cbrt
+Test "cbrt (-27.0) == -3.0":
+double: 1
+idouble: 1
+Test "cbrt (0.75) == 0.908560296416069829445605878163630251":
+double: 1
+idouble: 1
+Test "cbrt (0.9921875) == 0.997389022060725270579075195353955217":
+double: 1
+idouble: 1
+
+# ccos
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+float: 1
+ifloat: 1
+
+# ccosh
+Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+
+# cexp
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+float: 1
+ifloat: 1
+
+# clog
+Test "Imaginary part of: clog (-2 - 3 i) == 1.2824746787307683680267437207826593 - 2.1587989303424641704769327722648368 i":
+float: 3
+ifloat: 3
+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+float: 1
+ifloat: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+float: 1
+ifloat: 1
+
+# cos
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "cos (pi/2) == 0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+# csinh
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+
+# csqrt
+Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+
+# ctan
+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+double: 1
+idouble: 1
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+float: 1
+ifloat: 1
+Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+idouble: 1
+
+# erf
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (2.0) == 0.00467773498104726583793074363274707139":
+double: 1
+idouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+
+# exp10
+Test "exp10 (-1) == 0.1":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "exp10 (3) == 1000":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+# expm1
+Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
+double: 1
+idouble: 1
+Test "expm1 (1) == M_El - 1.0":
+float: 1
+ifloat: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "j0 (2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+
+# j1
+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+
+# jn
+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "jn (0, 2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
+float: 4
+ifloat: 4
+Test "jn (3, 0.125) == 0.406503832554912875023029337653442868e-4":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# lgamma
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+
+# log1p
+Test "log1p (-0.25) == -0.287682072451780927439219005993827432":
+float: 1
+ifloat: 1
+
+# sincos
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/6, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res":
+float: 1
+ifloat: 1
+
+# tan
+Test "tan (pi/4) == 1":
+double: 1
+idouble: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y0
+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y1
+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "y1 (1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# yn
+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "yn (1, 1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "yn (10, 0.125) == -127057845771019398.252538486899753195":
+double: 1
+idouble: 1
+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (10, 1.0) == -121618014.278689189288130426667971145":
+double: 1
+idouble: 1
+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (10, 2.0) == -129184.542208039282635913145923304214":
+double: 2
+idouble: 2
+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
+double: 1
+idouble: 1
+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 10.0) == -0.251362657183837329779204747654240998":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: "atan2":
+float: 6
+ifloat: 6
+
+Function: "atanh":
+float: 1
+ifloat: 1
+
+Function: Real part of "cacosh":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+
+Function: Real part of "catan":
+float: 4
+ifloat: 4
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catanh":
+double: 4
+idouble: 4
+
+Function: Imaginary part of "catanh":
+float: 6
+ifloat: 6
+
+Function: "cbrt":
+double: 1
+idouble: 1
+
+Function: Real part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccos":
+float: 1
+ifloat: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccosh":
+float: 1
+ifloat: 1
+
+Function: Real part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Real part of "clog":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "clog":
+float: 3
+ifloat: 3
+
+Function: Real part of "clog10":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Real part of "cpow":
+double: 2
+float: 4
+idouble: 2
+ifloat: 4
+
+Function: Imaginary part of "cpow":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csqrt":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "ctan":
+double: 1
+idouble: 1
+
+Function: Real part of "ctanh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Imaginary part of "ctanh":
+float: 1
+ifloat: 1
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+idouble: 1
+
+Function: "exp10":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+Function: "expm1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "j0":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "jn":
+double: 4
+float: 4
+idouble: 4
+ifloat: 4
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log10":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log1p":
+float: 1
+ifloat: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+# end of automatic generation
Index: trunk/src/libctests/glibc/sysdeps/generic/Makefile
===================================================================
--- trunk/src/libctests/glibc/sysdeps/generic/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/generic/Makefile	(revision 2036)
@@ -0,0 +1,45 @@
+# Copyright (C) 1992,93,94,95,96,97,99,2002 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+ifeq (,$(filter-out $(sysdep_dir)/generic/bits $(common-objpfx)/bits,\
+	$(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/bits/endian.h))))))
+
+$(common-objpfx)bytesex.h: $(common-objpfx)det_endian
+	$(dir $<)$(notdir $<) > $@-tmp
+	mv $@-tmp $@
+
+$(common-objpfx)det_endian: $(sysdep_dir)/generic/det_endian.c
+	$(common-objdir-compile)
+
+before-compile := $(before-compile) $(common-objpfx)bits/endian.h
+common-generated := $(common-generated) bits/endian.h det_endian
+
+endif
+
+
+ifeq ($(subdir),string)
+CFLAGS-wordcopy.c += -Wno-uninitialized
+endif
+
+ifeq ($(subdir),elf)
+ifeq (yes:yes,$(build-shared):$(unwind-find-fde))
+# This is needed to support g++ v2 and v3.
+sysdep_routines += framestate unwind-pe
+shared-only-routines += framestate unwind-pe
+endif
+endif
Index: trunk/src/libctests/glibc/sysdeps/generic/bits/waitstatus.h
===================================================================
--- trunk/src/libctests/glibc/sysdeps/generic/bits/waitstatus.h	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/generic/bits/waitstatus.h	(revision 2036)
@@ -0,0 +1,106 @@
+/* Definitions of status bits for `wait' et al.
+   Copyright (C) 1992,1994,1996,1997,2000,2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#if !defined _SYS_WAIT_H && !defined _STDLIB_H
+# error "Never include <bits/waitstatus.h> directly; use <sys/wait.h> instead."
+#endif
+
+
+/* Everything extant so far uses these same bits.  */
+
+
+/* If WIFEXITED(STATUS), the low-order 8 bits of the status.  */
+#define	__WEXITSTATUS(status)	(((status) & 0xff00) >> 8)
+
+/* If WIFSIGNALED(STATUS), the terminating signal.  */
+#define	__WTERMSIG(status)	((status) & 0x7f)
+
+/* If WIFSTOPPED(STATUS), the signal that stopped the child.  */
+#define	__WSTOPSIG(status)	__WEXITSTATUS(status)
+
+/* Nonzero if STATUS indicates normal termination.  */
+#define	__WIFEXITED(status)	(__WTERMSIG(status) == 0)
+
+/* Nonzero if STATUS indicates termination by a signal.  */
+#define __WIFSIGNALED(status) \
+  (((signed char) (((status) & 0x7f) + 1) >> 1) > 0)
+
+/* Nonzero if STATUS indicates the child is stopped.  */
+#define	__WIFSTOPPED(status)	(((status) & 0xff) == 0x7f)
+
+/* Nonzero if STATUS indicates the child continued after a stop.  We only
+   define this if <bits/waitflags.h> provides the WCONTINUED flag bit.  */
+#ifdef WCONTINUED
+# define __WIFCONTINUED(status)	((status) == __W_CONTINUED)
+#endif
+
+/* Nonzero if STATUS indicates the child dumped core.  */
+#define	__WCOREDUMP(status)	((status) & __WCOREFLAG)
+
+/* Macros for constructing status values.  */
+#define	__W_EXITCODE(ret, sig)	((ret) << 8 | (sig))
+#define	__W_STOPCODE(sig)	((sig) << 8 | 0x7f)
+#define __W_CONTINUED		0xffff
+#define	__WCOREFLAG		0x80
+
+
+#ifdef	__USE_BSD
+
+# include <endian.h>
+
+union wait
+  {
+    int w_status;
+    struct
+      {
+# if	__BYTE_ORDER == __LITTLE_ENDIAN
+	unsigned int __w_termsig:7; /* Terminating signal.  */
+	unsigned int __w_coredump:1; /* Set if dumped core.  */
+	unsigned int __w_retcode:8; /* Return code if exited normally.  */
+	unsigned int:16;
+# endif				/* Little endian.  */
+# if	__BYTE_ORDER == __BIG_ENDIAN
+	unsigned int:16;
+	unsigned int __w_retcode:8;
+	unsigned int __w_coredump:1;
+	unsigned int __w_termsig:7;
+# endif				/* Big endian.  */
+      } __wait_terminated;
+    struct
+      {
+# if	__BYTE_ORDER == __LITTLE_ENDIAN
+	unsigned int __w_stopval:8; /* W_STOPPED if stopped.  */
+	unsigned int __w_stopsig:8; /* Stopping signal.  */
+	unsigned int:16;
+# endif				/* Little endian.  */
+# if	__BYTE_ORDER == __BIG_ENDIAN
+	unsigned int:16;
+	unsigned int __w_stopsig:8; /* Stopping signal.  */
+	unsigned int __w_stopval:8; /* W_STOPPED if stopped.  */
+# endif				/* Big endian.  */
+      } __wait_stopped;
+  };
+
+# define w_termsig	__wait_terminated.__w_termsig
+# define w_coredump	__wait_terminated.__w_coredump
+# define w_retcode	__wait_terminated.__w_retcode
+# define w_stopsig	__wait_stopped.__w_stopsig
+# define w_stopval	__wait_stopped.__w_stopval
+
+#endif	/* Use BSD.  */
Index: trunk/src/libctests/glibc/sysdeps/generic/ftestexcept.c
===================================================================
--- trunk/src/libctests/glibc/sysdeps/generic/ftestexcept.c	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/generic/ftestexcept.c	(revision 2036)
@@ -0,0 +1,29 @@
+/* Test exception in current environment.
+   Copyright (C) 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <fenv.h>
+
+int
+fetestexcept (int excepts)
+{
+  return 0;
+}
+stub_warning (fetestexcept)
+#include <stub-tag.h>
Index: trunk/src/libctests/glibc/sysdeps/generic/libm-test-ulps
===================================================================
--- trunk/src/libctests/glibc/sysdeps/generic/libm-test-ulps	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/generic/libm-test-ulps	(revision 2036)
@@ -0,0 +1,5 @@
+# File with deltas for math/libm-test
+# This file is the fallback and contains
+# no data
+# You can create a new file with e.g. `test-double -u'
+# followed by `gen-libm-test.pl -u ULPs -n'.
Index: trunk/src/libctests/glibc/sysdeps/generic/sigaltstack.c
===================================================================
--- trunk/src/libctests/glibc/sysdeps/generic/sigaltstack.c	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/generic/sigaltstack.c	(revision 2036)
@@ -0,0 +1,34 @@
+/* Copyright (C) 1992, 1995, 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <signal.h>
+
+/* Run signals handlers on the stack specified by SS (if not NULL).
+   If OSS is not NULL, it is filled in with the old signal stack status.  */
+int
+sigaltstack (ss, oss)
+     const struct sigaltstack *ss;
+     struct sigaltstack *oss;
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+
+stub_warning (sigaltstack)
+#include <stub-tag.h>
Index: trunk/src/libctests/glibc/sysdeps/generic/testrtsig.h
===================================================================
--- trunk/src/libctests/glibc/sysdeps/generic/testrtsig.h	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/generic/testrtsig.h	(revision 2036)
@@ -0,0 +1,28 @@
+/* Test whether RT signals are really available.
+   Copyright (C) 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <string.h>
+#include <sys/utsname.h>
+
+static int
+kernel_has_rtsig (void)
+{
+  return 0;
+}
Index: trunk/src/libctests/glibc/sysdeps/generic/tst-stack-align.h
===================================================================
--- trunk/src/libctests/glibc/sysdeps/generic/tst-stack-align.h	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/generic/tst-stack-align.h	(revision 2036)
@@ -0,0 +1,35 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <stdint.h>
+
+#define TEST_STACK_ALIGN() \
+  ({									     \
+    double _d = 12.0;							     \
+    long double _ld = 15.0;						     \
+    int _ret = 0;							     \
+    printf ("double:  %g %p %zu\n", _d, &_d, __alignof (double));	     \
+    if ((((uintptr_t) &_d) & (__alignof (double) - 1)) != 0)		     \
+      _ret = 1;								     \
+									     \
+    printf ("ldouble: %Lg %p %zu\n", _ld, &_ld, __alignof (long double));    \
+    if ((((uintptr_t) &_ld) & (__alignof (long double) - 1)) != 0)	     \
+      _ret = 1;								     \
+    _ret;								     \
+    })
Index: trunk/src/libctests/glibc/sysdeps/generic/tst-timer.c
===================================================================
--- trunk/src/libctests/glibc/sysdeps/generic/tst-timer.c	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/generic/tst-timer.c	(revision 2036)
@@ -0,0 +1,33 @@
+/* Tests for POSIX timer implementation.  Dummy version.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <unistd.h>
+
+/* This file is only used if there is no other implementation and it should
+   means that there is no implementation of POSIX timers.  */
+int
+main (void)
+{
+#ifdef _POSIX_TIMERS
+  /* There should be a test.  */
+  return 1;
+#else
+  return 0;
+#endif
+}
Index: trunk/src/libctests/glibc/sysdeps/hppa/fpu/ftestexcept.c
===================================================================
--- trunk/src/libctests/glibc/sysdeps/hppa/fpu/ftestexcept.c	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/hppa/fpu/ftestexcept.c	(revision 2036)
@@ -0,0 +1,32 @@
+/* Test exception in current environment.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by David Huggins-Daines <dhd@debian.org>, 2000
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <fenv.h>
+
+int
+fetestexcept (int excepts)
+{
+  unsigned int sw[2];
+
+  /* Get the current status word. */
+  __asm__ ("fstd %%fr0,0(%1)" : "=m" (*sw) : "r" (sw));
+
+  return (sw[0] >> 27) & excepts & FE_ALL_EXCEPT;
+}
Index: trunk/src/libctests/glibc/sysdeps/hppa/fpu/libm-test-ulps
===================================================================
--- trunk/src/libctests/glibc/sysdeps/hppa/fpu/libm-test-ulps	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/hppa/fpu/libm-test-ulps	(revision 2036)
@@ -0,0 +1,890 @@
+# Begin of automatic generation
+
+# atan2
+Test "atan2 (-0.75, -1.0) == -2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+Test "atan2 (0.75, -1.0) == 2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+Test "atan2 (1.390625, 0.9296875) == 0.981498387184244311516296577615519772":
+float: 1
+ifloat: 1
+
+# atanh
+Test "atanh (0.75) == 0.972955074527656652552676371721589865":
+float: 1
+ifloat: 1
+
+# cacosh
+Test "Real part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+Test "Imaginary part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+# casin
+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# catan
+Test "Real part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+float: 3
+ifloat: 3
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i":
+float: 4
+ifloat: 4
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 4
+idouble: 4
+Test "Imaginary part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+float: 4
+ifloat: 4
+Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+float: 6
+ifloat: 6
+
+# cbrt
+Test "cbrt (-27.0) == -3.0":
+double: 1
+idouble: 1
+Test "cbrt (0.75) == 0.908560296416069829445605878163630251":
+double: 1
+idouble: 1
+Test "cbrt (0.9921875) == 0.997389022060725270579075195353955217":
+double: 1
+idouble: 1
+
+# ccos
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+float: 1
+ifloat: 1
+
+# ccosh
+Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+
+# cexp
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+float: 1
+ifloat: 1
+
+# clog
+Test "Imaginary part of: clog (-2 - 3 i) == 1.2824746787307683680267437207826593 - 2.1587989303424641704769327722648368 i":
+float: 3
+ifloat: 3
+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+float: 1
+ifloat: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+float: 1
+ifloat: 1
+
+# cos
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "cos (pi/2) == 0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+# csinh
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+
+# csqrt
+Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+double: 1
+idouble: 1
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+float: 1
+ifloat: 1
+Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+idouble: 1
+
+# erf
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (2.0) == 0.00467773498104726583793074363274707139":
+double: 1
+idouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+
+# exp10
+Test "exp10 (-1) == 0.1":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "exp10 (3) == 1000":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+# expm1
+Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
+double: 1
+idouble: 1
+Test "expm1 (1) == M_El - 1.0":
+float: 1
+ifloat: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "j0 (2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+
+# j1
+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+
+# jn
+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "jn (0, 2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
+float: 4
+ifloat: 4
+Test "jn (3, 0.125) == 0.406503832554912875023029337653442868e-4":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# lgamma
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+
+# log1p
+Test "log1p (-0.25) == -0.287682072451780927439219005993827432":
+float: 1
+ifloat: 1
+
+# sincos
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/6, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res":
+float: 1
+ifloat: 1
+
+# tan
+Test "tan (pi/4) == 1":
+double: 1
+idouble: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y0
+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y1
+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "y1 (1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# yn
+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "yn (1, 1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "yn (10, 0.125) == -127057845771019398.252538486899753195":
+double: 1
+idouble: 1
+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (10, 1.0) == -121618014.278689189288130426667971145":
+double: 1
+idouble: 1
+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (10, 2.0) == -129184.542208039282635913145923304214":
+double: 2
+idouble: 2
+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
+double: 1
+idouble: 1
+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 10.0) == -0.251362657183837329779204747654240998":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: "atan2":
+float: 3
+ifloat: 3
+
+Function: "atanh":
+float: 1
+ifloat: 1
+
+Function: Real part of "cacosh":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+
+Function: Real part of "catan":
+float: 4
+ifloat: 4
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catanh":
+double: 4
+idouble: 4
+
+Function: Imaginary part of "catanh":
+float: 6
+ifloat: 6
+
+Function: "cbrt":
+double: 1
+idouble: 1
+
+Function: Real part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccos":
+float: 1
+ifloat: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccosh":
+float: 1
+ifloat: 1
+
+Function: Real part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Real part of "clog":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "clog":
+float: 3
+ifloat: 3
+
+Function: Real part of "clog10":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Real part of "cpow":
+double: 2
+float: 4
+idouble: 2
+ifloat: 4
+
+Function: Imaginary part of "cpow":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csqrt":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctan":
+double: 1
+idouble: 1
+
+Function: Imaginary part of "ctan":
+double: 1
+idouble: 1
+
+Function: Real part of "ctanh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Imaginary part of "ctanh":
+float: 1
+ifloat: 1
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+idouble: 1
+
+Function: "exp10":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+Function: "expm1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "j0":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "jn":
+double: 4
+float: 4
+idouble: 4
+ifloat: 4
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log10":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log1p":
+float: 1
+ifloat: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+# end of automatic generation
Index: trunk/src/libctests/glibc/sysdeps/i386/Makefile
===================================================================
--- trunk/src/libctests/glibc/sysdeps/i386/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/i386/Makefile	(revision 2036)
@@ -0,0 +1,67 @@
+# The mpn functions need a #define for asm syntax flavor.
+# Every i386 port in use uses gas syntax (I think).
+asm-CPPFLAGS += -DGAS_SYNTAX
+
+# The i386 `long double' is a distinct type we support.
+long-double-fcts = yes
+
+ifeq ($(subdir),csu)
+# On i686 we must avoid generating the trampoline functions generated
+# to get the GOT pointer.
+CFLAGS-initfini.s += -march=i386 -mtune=i386
+endif
+
+ifeq ($(subdir),gmon)
+sysdep_routines += i386-mcount
+endif
+
+ifeq ($(subdir),elf)
+CFLAGS-rtld.c += -Wno-uninitialized -Wno-unused
+CFLAGS-dl-load.c += -Wno-unused
+CFLAGS-dl-reloc.c += -Wno-unused
+endif
+
+ifeq ($(subdir),debug)
+CFLAGS-backtrace.c += -fexceptions
+endif
+
+# Most of the glibc routines don't ever call user defined callbacks
+# nor use any FPU or SSE* and as such don't need bigger %esp alignment
+# than 4 bytes.
+# Lots of routines in math will use FPU, so make math subdir an exception
+# here.
+ifeq ($(subdir),math)
+sysdep-CFLAGS += -mpreferred-stack-boundary=4
+else
+ifeq ($(subdir),csu)
+sysdep-CFLAGS += -mpreferred-stack-boundary=4
+else
+sysdep-CFLAGS += -mpreferred-stack-boundary=2
+# Likewise, any function which calls user callbacks
+uses-callbacks += -mpreferred-stack-boundary=4
+# Likewise, any stack alignment tests
+stack-align-test-flags += -malign-double -mpreferred-stack-boundary=4
+endif
+endif
+
+# And a couple of other routines
+ifeq ($(subdir),stdlib)
+CFLAGS-exit.c += -mpreferred-stack-boundary=4
+endif
+ifeq ($(subdir),elf)
+CFLAGS-dl-init.c += -mpreferred-stack-boundary=4
+CFLAGS-dl-fini.c += -mpreferred-stack-boundary=4
+CFLAGS-dl-open.c += -mpreferred-stack-boundary=4
+CFLAGS-dl-close.c += -mpreferred-stack-boundary=4
+CFLAGS-dl-error.c += -mpreferred-stack-boundary=4
+endif
+ifeq ($(subdir),dlfcn)
+CFLAGS-dlopen.c += -mpreferred-stack-boundary=4
+CFLAGS-dlopenold.c += -mpreferred-stack-boundary=4
+CFLAGS-dlclose.c += -mpreferred-stack-boundary=4
+CFLAGS-dlerror.c += -mpreferred-stack-boundary=4
+endif
+
+ifneq (,$(filter -mno-tls-direct-seg-refs,$(CFLAGS)))
+defines += -DNO_TLS_DIRECT_SEG_REFS
+endif
Index: trunk/src/libctests/glibc/sysdeps/i386/fpu/Makefile
===================================================================
--- trunk/src/libctests/glibc/sysdeps/i386/fpu/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/i386/fpu/Makefile	(revision 2036)
@@ -0,0 +1,3 @@
+ifeq ($(subdir),math)
+$(objpfx)libm.so: $(elfobjdir)/ld.so
+endif
Index: trunk/src/libctests/glibc/sysdeps/i386/fpu/ftestexcept.c
===================================================================
--- trunk/src/libctests/glibc/sysdeps/i386/fpu/ftestexcept.c	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/i386/fpu/ftestexcept.c	(revision 2036)
@@ -0,0 +1,40 @@
+/* Test exception in current environment.
+   Copyright (C) 1997, 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <fenv.h>
+#include <unistd.h>
+#include <dl-procinfo.h>
+#include <ldsodefs.h>
+
+int
+fetestexcept (int excepts)
+{
+  int temp;
+  int xtemp = 0;
+
+  /* Get current exceptions.  */
+  __asm__ ("fnstsw %0" : "=a" (temp));
+
+  /* If the CPU supports SSE we test the MXCSR as well.  */
+  if ((GLRO(dl_hwcap) & HWCAP_I386_XMM) != 0)
+    __asm__ ("stmxcsr %0" : "=m" (*&xtemp));
+
+  return (temp | xtemp) & excepts & FE_ALL_EXCEPT;
+}
Index: trunk/src/libctests/glibc/sysdeps/i386/fpu/libm-test-ulps
===================================================================
--- trunk/src/libctests/glibc/sysdeps/i386/fpu/libm-test-ulps	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/i386/fpu/libm-test-ulps	(revision 2036)
@@ -0,0 +1,1220 @@
+# Begin of automatic generation
+
+# acos
+Test "acos (0.75) == 0.722734247813415611178377352641333362":
+ildouble: 1
+ldouble: 1
+
+# asin
+Test "asin (-0.5) == -pi/6":
+ildouble: 1
+ldouble: 1
+Test "asin (-1.0) == -pi/2":
+ildouble: 1
+ldouble: 1
+Test "asin (0.5) == pi/6":
+ildouble: 1
+ldouble: 1
+Test "asin (0.75) == 0.848062078981481008052944338998418080":
+ildouble: 1
+ldouble: 1
+Test "asin (1.0) == pi/2":
+ildouble: 1
+ldouble: 1
+
+# atanh
+Test "atanh (0.75) == 0.972955074527656652552676371721589865":
+ildouble: 2
+ldouble: 1
+
+# cacos
+Test "Imaginary part of: cacos (0.75 + 1.25 i) == 1.11752014915610270578240049553777969 - 1.13239363160530819522266333696834467 i":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+# cacosh
+Test "Real part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 9
+idouble: 1
+ifloat: 9
+ildouble: 6
+ldouble: 6
+Test "Imaginary part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0.75 + 1.25 i) == 1.13239363160530819522266333696834467 + 1.11752014915610270578240049553777969 i":
+ildouble: 1
+ldouble: 1
+
+# casin
+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+ildouble: 5
+ldouble: 5
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 5
+ldouble: 5
+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# catan
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+double: 1
+idouble: 1
+
+# cbrt
+Test "cbrt (-27.0) == -3.0":
+ildouble: 1
+ldouble: 1
+Test "cbrt (0.75) == 0.908560296416069829445605878163630251":
+ildouble: 1
+ldouble: 1
+
+# ccos
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+ildouble: 1
+ldouble: 1
+
+# ccosh
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+
+# cexp
+Test "Real part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+ildouble: 1
+ldouble: 1
+
+# clog
+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + inf i) == inf + 3/4 pi*log10(e) i":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cos
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "cos (pi/2) == 0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# cosh
+Test "cosh (0.75) == 1.29468328467684468784170818539018176":
+ildouble: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+float: 3
+ifloat: 3
+ildouble: 6
+ldouble: 6
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i":
+float: 1
+ifloat: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+ildouble: 3
+ldouble: 3
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+ildouble: 1
+ldouble: 1
+
+# csin
+Test "Real part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i":
+float: 1
+ifloat: 1
+
+# csinh
+Test "Real part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+double: 1
+idouble: 1
+ildouble: 439
+ldouble: 439
+Test "Imaginary part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Real part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+float: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+ildouble: 5
+ldouble: 5
+Test "Imaginary part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+float: 1
+ifloat: 1
+ildouble: 25
+ldouble: 25
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+float: 1
+ifloat: 1
+Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# erf
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (0.75) == 0.288844366346484868401062165408589223":
+float: 1
+ifloat: 1
+Test "erfc (1.25) == 0.0770998717435417698634765188027188596":
+ildouble: 1
+ldouble: 1
+Test "erfc (2.0) == 0.00467773498104726583793074363274707139":
+double: 1
+idouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# exp
+Test "exp (0.75) == 2.11700001661267466854536981983709561":
+ildouble: 1
+Test "exp (1000.0) == 0.197007111401704699388887935224332313e435":
+ildouble: 754
+Test "exp (50.0) == 5184705528587072464087.45332293348538":
+ildouble: 16
+
+# exp10
+Test "exp10 (-1) == 0.1":
+ildouble: 1
+ldouble: 1
+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
+ildouble: 2
+ldouble: 2
+Test "exp10 (3) == 1000":
+ildouble: 8
+ldouble: 8
+
+# gamma
+Test "gamma (-0.5) == log(2*sqrt(pi))":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+
+# j0
+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "j0 (2.0) == 0.223890779141235668051827454649948626":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "j0 (8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+
+# j1
+Test "j1 (0.75) == 0.349243602174862192523281016426251335":
+double: 1
+idouble: 1
+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# jn
+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "jn (0, 2.0) == 0.223890779141235668051827454649948626":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "jn (0, 8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+Test "jn (1, 0.75) == 0.349243602174862192523281016426251335":
+double: 1
+idouble: 1
+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (10, -1.0) == 0.263061512368745320699785368779050294e-9":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "jn (10, 1.0) == 0.263061512368745320699785368779050294e-9":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
+double: 5
+float: 2
+idouble: 5
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
+double: 2
+idouble: 2
+ildouble: 1
+ldouble: 1
+Test "jn (3, -1.0) == -0.0195633539826684059189053216217515083":
+ildouble: 1
+ldouble: 1
+Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 1.0) == 0.0195633539826684059189053216217515083":
+ildouble: 1
+ldouble: 1
+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
+double: 5
+float: 2
+idouble: 5
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# lgamma
+Test "lgamma (-0.5) == log(2*sqrt(pi))":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# log
+Test "log (e) == 1":
+float: 1
+ifloat: 1
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+ildouble: 1
+ldouble: 1
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# sincos
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# sinh
+Test "sinh (0.75) == 0.822316731935829980703661634446913849":
+ildouble: 1
+
+# tan
+Test "tan (pi/4) == 1":
+double: 1
+idouble: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (4) == 6":
+ildouble: 1
+ldouble: 1
+
+# y0
+Test "y0 (0.125) == -1.38968062514384052915582277745018693":
+ildouble: 1
+ldouble: 1
+Test "y0 (0.75) == -0.137172769385772397522814379396581855":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# y1
+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
+ildouble: 1
+ldouble: 1
+Test "y1 (1.0) == -0.781212821300288716547150000047964821":
+double: 1
+idouble: 1
+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# yn
+Test "yn (0, 0.125) == -1.38968062514384052915582277745018693":
+ildouble: 1
+ldouble: 1
+Test "yn (0, 0.75) == -0.137172769385772397522814379396581855":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
+ildouble: 1
+ldouble: 1
+Test "yn (1, 1.0) == -0.781212821300288716547150000047964821":
+double: 1
+idouble: 1
+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "yn (10, 0.125) == -127057845771019398.252538486899753195":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
+float: 1
+ifloat: 1
+ildouble: 4
+ldouble: 4
+Test "yn (10, 1.0) == -121618014.278689189288130426667971145":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+Test "yn (10, 2.0) == -129184.542208039282635913145923304214":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
+ildouble: 1
+ldouble: 1
+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (3, 10.0) == -0.251362657183837329779204747654240998":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# Maximal error of functions:
+Function: "acos":
+ildouble: 622
+ldouble: 622
+
+Function: "asin":
+ildouble: 1
+ldouble: 1
+
+Function: "atanh":
+ildouble: 2
+ldouble: 1
+
+Function: Imaginary part of "cacos":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "cacosh":
+double: 1
+float: 9
+idouble: 1
+ifloat: 9
+ildouble: 6
+ldouble: 6
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "casin":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+ildouble: 5
+ldouble: 5
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 5
+ldouble: 5
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catanh":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "cbrt":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccos":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ccos":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cexp":
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "cexp":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "clog":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "clog10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "cosh":
+ildouble: 1
+
+Function: Real part of "cpow":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+ildouble: 763
+ldouble: 763
+
+Function: Imaginary part of "cpow":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "csin":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csin":
+float: 1
+ifloat: 1
+
+Function: Real part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "ctan":
+double: 1
+idouble: 1
+ildouble: 439
+ldouble: 439
+
+Function: Imaginary part of "ctan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+
+Function: Real part of "ctanh":
+float: 1
+ifloat: 1
+ildouble: 5
+ldouble: 5
+
+Function: Imaginary part of "ctanh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 25
+ldouble: 25
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "exp":
+ildouble: 754
+
+Function: "exp10":
+ildouble: 8
+ldouble: 8
+
+Function: "gamma":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: "hypot":
+float: 1
+
+Function: "j0":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "j1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "jn":
+double: 5
+float: 2
+idouble: 5
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "log":
+float: 1
+ifloat: 1
+
+Function: "log10":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "sinh":
+ildouble: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tgamma":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "y1":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "yn":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+ildouble: 4
+ldouble: 4
+
+# end of automatic generation
Index: trunk/src/libctests/glibc/sysdeps/i386/i686/Makefile
===================================================================
--- trunk/src/libctests/glibc/sysdeps/i386/i686/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/i386/i686/Makefile	(revision 2036)
@@ -0,0 +1,7 @@
+ifeq ($(subdir),csu)
+sysdep_routines += hp-timing
+elide-routines.os += hp-timing
+endif
+
+# So that we can test __m128's alignment
+stack-align-test-flags += -msse
Index: trunk/src/libctests/glibc/sysdeps/i386/i686/hp-timing.h
===================================================================
--- trunk/src/libctests/glibc/sysdeps/i386/i686/hp-timing.h	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/i386/i686/hp-timing.h	(revision 2036)
@@ -0,0 +1,157 @@
+/* High precision, low overhead timing functions.  i686 version.
+   Copyright (C) 1998, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _HP_TIMING_H
+#define _HP_TIMING_H	1
+
+#include <string.h>
+#include <sys/param.h>
+#include <stdio-common/_itoa.h>
+
+/* The macros defined here use the timestamp counter in i586 and up versions
+   of the x86 processors.  They provide a very accurate way to measure the
+   time with very little overhead.  The time values themself have no real
+   meaning, only differences are interesting.
+
+   This version is for the i686 processors.  The difference to the i586
+   version is that the timerstamp register is unconditionally used.  This is
+   not the case for the i586 version where we have to perform runtime test
+   whether the processor really has this capability.  We have to make this
+   distinction since the sysdeps/i386/i586 code is supposed to work on all
+   platforms while the i686 already contains i686-specific code.
+
+   The list of macros we need includes the following:
+
+   - HP_TIMING_AVAIL: test for availability.
+
+   - HP_TIMING_INLINE: this macro is non-zero if the functionality is not
+     implemented using function calls but instead uses some inlined code
+     which might simply consist of a few assembler instructions.  We have to
+     know this since we might want to use the macros here in places where we
+     cannot make function calls.
+
+   - hp_timing_t: This is the type for variables used to store the time
+     values.
+
+   - HP_TIMING_ZERO: clear `hp_timing_t' object.
+
+   - HP_TIMING_NOW: place timestamp for current time in variable given as
+     parameter.
+
+   - HP_TIMING_DIFF_INIT: do whatever is necessary to be able to use the
+     HP_TIMING_DIFF macro.
+
+   - HP_TIMING_DIFF: compute difference between two times and store it
+     in a third.  Source and destination might overlap.
+
+   - HP_TIMING_ACCUM: add time difference to another variable.  This might
+     be a bit more complicated to implement for some platforms as the
+     operation should be thread-safe and 64bit arithmetic on 32bit platforms
+     is not.
+
+   - HP_TIMING_ACCUM_NT: this is the variant for situations where we know
+     there are no threads involved.
+
+   - HP_TIMING_PRINT: write decimal representation of the timing value into
+     the given string.  This operation need not be inline even though
+     HP_TIMING_INLINE is specified.
+
+*/
+
+/* We always assume having the timestamp register.  */
+#define HP_TIMING_AVAIL		(1)
+
+/* We indeed have inlined functions.  */
+#define HP_TIMING_INLINE	(1)
+
+/* We use 64bit values for the times.  */
+typedef unsigned long long int hp_timing_t;
+
+/* Set timestamp value to zero.  */
+#define HP_TIMING_ZERO(Var)	(Var) = (0)
+
+/* That's quite simple.  Use the `rdtsc' instruction.  Note that the value
+   might not be 100% accurate since there might be some more instructions
+   running in this moment.  This could be changed by using a barrier like
+   'cpuid' right before the `rdtsc' instruciton.  But we are not interested
+   in accurate clock cycles here so we don't do this.  */
+#define HP_TIMING_NOW(Var)	__asm__ __volatile__ ("rdtsc" : "=A" (Var))
+
+/* Use two 'rdtsc' instructions in a row to find out how long it takes.  */
+#define HP_TIMING_DIFF_INIT() \
+  do {									      \
+    if (GLRO(dl_hp_timing_overhead) == 0)				      \
+      {									      \
+	int __cnt = 5;							      \
+	GLRO(dl_hp_timing_overhead) = ~0ull;				      \
+	do								      \
+	  {								      \
+	    hp_timing_t __t1, __t2;					      \
+	    HP_TIMING_NOW (__t1);					      \
+	    HP_TIMING_NOW (__t2);					      \
+	    if (__t2 - __t1 < GLRO(dl_hp_timing_overhead))		      \
+	      GLRO(dl_hp_timing_overhead) = __t2 - __t1;		      \
+	  }								      \
+	while (--__cnt > 0);						      \
+      }									      \
+  } while (0)
+
+/* It's simple arithmetic for us.  */
+#define HP_TIMING_DIFF(Diff, Start, End)	(Diff) = ((End) - (Start))
+
+/* We have to jump through hoops to get this correctly implemented.  */
+#define HP_TIMING_ACCUM(Sum, Diff) \
+  do {									      \
+    int __not_done;							      \
+    hp_timing_t __oldval = (Sum);					      \
+    hp_timing_t __diff = (Diff) - GLRO(dl_hp_timing_overhead);		      \
+    do									      \
+      {									      \
+	hp_timing_t __newval = __oldval + __diff;			      \
+	int __temp0, __temp1;						      \
+	__asm__ __volatile__ ("xchgl %0, %%ebx\n\t"			      \
+			      "lock; cmpxchg8b %1\n\t"			      \
+			      "sete %%bl\n\t"				      \
+			      "xchgl %0, %%ebx"				      \
+			      : "=SD" (__not_done), "=m" (Sum),		      \
+				"=A" (__oldval), "=c" (__temp0)		      \
+			      : "m" (Sum), "2" (__oldval),		      \
+				"3" ((unsigned int) (__newval >> 32)),	      \
+				"0" ((unsigned int) __newval));		      \
+      }									      \
+    while ((unsigned char) __not_done);					      \
+  } while (0)
+
+/* No threads, no extra work.  */
+#define HP_TIMING_ACCUM_NT(Sum, Diff)	(Sum) += (Diff)
+
+/* Print the time value.  */
+#define HP_TIMING_PRINT(Buf, Len, Val) \
+  do {									      \
+    char __buf[20];							      \
+    char *__cp = _itoa (Val, __buf + sizeof (__buf), 10, 0);		      \
+    size_t __len = (Len);						      \
+    char *__dest = (Buf);						      \
+    while (__len-- > 0 && __cp < __buf + sizeof (__buf))		      \
+      *__dest++ = *__cp++;						      \
+    memcpy (__dest, " clock cycles", MIN (__len, sizeof (" clock cycles")));  \
+  } while (0)
+
+#endif	/* hp-timing.h */
Index: trunk/src/libctests/glibc/sysdeps/i386/i686/tst-stack-align.h
===================================================================
--- trunk/src/libctests/glibc/sysdeps/i386/i686/tst-stack-align.h	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/i386/i686/tst-stack-align.h	(revision 2036)
@@ -0,0 +1,45 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <stdint.h>
+#ifndef __SSE__
+#include_next <tst-stack-align.h>
+#else
+#include <xmmintrin.h>
+
+#define TEST_STACK_ALIGN() \
+  ({									     \
+    __m128 _m;								     \
+    double _d = 12.0;							     \
+    long double _ld = 15.0;						     \
+    int _ret = 0;							     \
+    printf ("__m128:  %p %zu\n", &_m, __alignof (__m128));		     \
+    if ((((uintptr_t) &_m) & (__alignof (__m128) - 1)) != 0)		     \
+      _ret = 1;								     \
+									     \
+    printf ("double:  %g %p %zu\n", _d, &_d, __alignof (double));	     \
+    if ((((uintptr_t) &_d) & (__alignof (double) - 1)) != 0)		     \
+      _ret = 1;								     \
+									     \
+    printf ("ldouble: %Lg %p %zu\n", _ld, &_ld, __alignof (long double));    \
+    if ((((uintptr_t) &_ld) & (__alignof (long double) - 1)) != 0)	     \
+      _ret = 1;								     \
+    _ret;								     \
+    })
+#endif
Index: trunk/src/libctests/glibc/sysdeps/i386/tst-stack-align.h
===================================================================
--- trunk/src/libctests/glibc/sysdeps/i386/tst-stack-align.h	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/i386/tst-stack-align.h	(revision 2036)
@@ -0,0 +1,42 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <stdint.h>
+
+typedef struct { int i[4]; } int_al16 __attribute__((aligned (16)));
+
+#define TEST_STACK_ALIGN() \
+  ({									     \
+    int_al16 _m;							     \
+    double _d = 12.0;							     \
+    long double _ld = 15.0;						     \
+    int _ret = 0;							     \
+    printf ("int_al16:  %p %zu\n", &_m, __alignof (int_al16));		     \
+    if ((((uintptr_t) &_m) & (__alignof (int_al16) - 1)) != 0)		     \
+      _ret = 1;								     \
+									     \
+    printf ("double:  %g %p %zu\n", _d, &_d, __alignof (double));	     \
+    if ((((uintptr_t) &_d) & (__alignof (double) - 1)) != 0)		     \
+      _ret = 1;								     \
+									     \
+    printf ("ldouble: %Lg %p %zu\n", _ld, &_ld, __alignof (long double));    \
+    if ((((uintptr_t) &_ld) & (__alignof (long double) - 1)) != 0)	     \
+      _ret = 1;								     \
+    _ret;								     \
+    })
Index: trunk/src/libctests/glibc/sysdeps/ia64/fpu/Makefile
===================================================================
--- trunk/src/libctests/glibc/sysdeps/ia64/fpu/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/ia64/fpu/Makefile	(revision 2036)
@@ -0,0 +1,34 @@
+ifeq ($(subdir),math)
+#
+# Some files which need to go both into libc and libm have external
+# dependencies which need to be resolved differently for libc
+# vs. libm.  For example, inside libc, __libm_error_support needs to
+# resolve to HIDDEN_JUMPTARGET(__libm_error_support) whereas within
+# libm it always resolves to __libm_error_support.  Such files need to
+# be compiled twice.  Fortunately, math/Makefile already has logic to
+# support this: if a file starts with "s_", make will automatically
+# generate a matching file whose name starts with "m_" which simply
+# includes the corresponding "s_" file.
+#
+duplicated-routines = s_libm_ldexp s_libm_ldexpf s_libm_ldexpl \
+		      s_libm_scalbn s_libm_scalbnf s_libm_scalbnl
+
+libm-sysdep_routines += s_erfc s_erfcf s_erfcl \
+			s_matherrf s_matherrl libm_reduce \
+			libm_error \
+			libm_frexp libm_frexpf libm_frexpl \
+			libm_sincos libm_sincosf libm_sincosl \
+			libm_sincos_large \
+			libm_lgamma libm_lgammaf libm_lgammal \
+			libm_scalblnf \
+			$(duplicated-routines:s_%=m_%)
+
+sysdep_routines += libc_libm_error libm_frexp libm_frexpf libm_frexpl \
+		   $(duplicated-routines)
+
+sysdep-CPPFLAGS += -include libm-symbols.h \
+	-D__POSIX__ -Dopensource \
+	-D_LIB_VERSIONIMF=_LIB_VERSION \
+	-DSIZE_INT_32 -DSIZE_LONG_INT_64 -DSIZE_LONG_LONG_INT_64 \
+	-DSIZE_LONG_64 -DIA64
+endif
Index: trunk/src/libctests/glibc/sysdeps/ia64/fpu/ftestexcept.c
===================================================================
--- trunk/src/libctests/glibc/sysdeps/ia64/fpu/ftestexcept.c	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/ia64/fpu/ftestexcept.c	(revision 2036)
@@ -0,0 +1,32 @@
+/* Test exception in current environment.
+   Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Christian Boissat <Christian.Boissat@cern.ch>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <fenv.h>
+
+int
+fetestexcept (int excepts)
+{
+  fenv_t fpsr;
+
+  /* Get current exceptions.  */
+  __asm__ __volatile__ ("mov.m %0=ar.fpsr" : "=r" (fpsr));
+
+  return (fpsr >> 13) & excepts & FE_ALL_EXCEPT;
+}
Index: trunk/src/libctests/glibc/sysdeps/ia64/fpu/libm-test-ulps
===================================================================
--- trunk/src/libctests/glibc/sysdeps/ia64/fpu/libm-test-ulps	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/ia64/fpu/libm-test-ulps	(revision 2036)
@@ -0,0 +1,1116 @@
+# Begin of automatic generation
+
+# cacos
+Test "Imaginary part of: cacos (0.75 + 1.25 i) == 1.11752014915610270578240049553777969 - 1.13239363160530819522266333696834467 i":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+# cacosh
+Test "Real part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+ildouble: 7
+ldouble: 7
+Test "Imaginary part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# casin
+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+ildouble: 5
+ldouble: 5
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 5
+ldouble: 5
+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# catan
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 4
+idouble: 4
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+double: 1
+idouble: 1
+
+# ccos
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+ildouble: 1
+ldouble: 1
+
+# ccosh
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+
+# cexp
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+ildouble: 1
+ldouble: 1
+
+# clog
+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + inf i) == inf + 3/4 pi*log10(e) i":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cos
+Test "cos (0.80190127184058835) == 0.69534156199418473":
+double: 1
+idouble: 1
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "cos (pi/2) == 0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+ildouble: 3
+ldouble: 3
+Test "Real part of: cpow (2 + 0 i, 10 + 0 i) == 1024.0 + 0.0 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 2
+ifloat: 2
+ildouble: 4
+ldouble: 4
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+ildouble: 1
+ldouble: 1
+
+# csin
+Test "Real part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i":
+float: 1
+ifloat: 1
+
+# csinh
+Test "Real part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+
+# csqrt
+Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+float: 1
+ifloat: 1
+ildouble: 24
+ldouble: 24
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+float: 1
+ifloat: 1
+Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# erf
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (0.75) == 0.288844366346484868401062165408589223":
+float: 1
+ifloat: 1
+Test "erfc (1.25) == 0.0770998717435417698634765188027188596":
+ildouble: 1
+ldouble: 1
+Test "erfc (2.0) == 0.00467773498104726583793074363274707139":
+double: 1
+idouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# exp10
+Test "exp10 (-1) == 0.1":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "exp10 (3) == 1000":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+ildouble: 3
+ldouble: 3
+
+# expm1
+Test "expm1 (1) == M_El - 1.0":
+ildouble: 1
+ldouble: 1
+
+# gamma
+Test "gamma (-0.5) == log(2*sqrt(pi))":
+ildouble: 1
+ldouble: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "j0 (8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+
+# j1
+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+
+# jn
+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "jn (0, 8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+Test "jn (10, -1.0) == 0.263061512368745320699785368779050294e-9":
+ildouble: 1
+ldouble: 1
+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "jn (10, 1.0) == 0.263061512368745320699785368779050294e-9":
+ildouble: 1
+ldouble: 1
+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
+float: 3
+ifloat: 3
+ildouble: 1
+ldouble: 1
+Test "jn (3, -1.0) == -0.0195633539826684059189053216217515083":
+ildouble: 1
+ldouble: 1
+Test "jn (3, 0.125) == 0.406503832554912875023029337653442868e-4":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2":
+double: 1
+idouble: 1
+Test "jn (3, 1.0) == 0.0195633539826684059189053216217515083":
+ildouble: 1
+ldouble: 1
+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# lgamma
+Test "lgamma (-0.5) == log(2*sqrt(pi))":
+ildouble: 1
+ldouble: 1
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# log
+Test "log (e) == 1":
+float: 1
+ifloat: 1
+
+# log10
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# sincos
+Test "sincos (0.80190127184058835, &sin_res, &cos_res) puts 0.69534156199418473 in cos_res":
+double: 1
+idouble: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# tan
+Test "tan (pi/4) == 1":
+double: 1
+idouble: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y0
+Test "y0 (0.125) == -1.38968062514384052915582277745018693":
+ildouble: 1
+ldouble: 1
+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y0 (2.0) == 0.510375672649745119596606592727157873":
+double: 1
+idouble: 1
+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# y1
+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
+ildouble: 1
+ldouble: 1
+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# yn
+Test "yn (0, 0.125) == -1.38968062514384052915582277745018693":
+ildouble: 1
+ldouble: 1
+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (0, 2.0) == 0.510375672649745119596606592727157873":
+double: 1
+idouble: 1
+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
+ildouble: 1
+ldouble: 1
+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "yn (10, 0.125) == -127057845771019398.252538486899753195":
+ildouble: 2
+ldouble: 2
+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "yn (10, 1.0) == -121618014.278689189288130426667971145":
+float: 2
+ifloat: 2
+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
+double: 2
+idouble: 2
+Test "yn (10, 2.0) == -129184.542208039282635913145923304214":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
+ildouble: 1
+ldouble: 1
+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (3, 10.0) == -0.251362657183837329779204747654240998":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: Imaginary part of "cacos":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "cacosh":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+ildouble: 7
+ldouble: 7
+
+Function: Imaginary part of "cacosh":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "casin":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+ildouble: 5
+ldouble: 5
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 5
+ldouble: 5
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catanh":
+double: 4
+idouble: 4
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccos":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ccos":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "cexp":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "clog":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "clog10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cpow":
+double: 2
+float: 5
+idouble: 2
+ifloat: 5
+ildouble: 3
+ldouble: 3
+
+Function: Imaginary part of "cpow":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+ildouble: 4
+ldouble: 4
+
+Function: Real part of "csin":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csin":
+float: 1
+ifloat: 1
+
+Function: Real part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "csqrt":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctan":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "ctan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ctanh":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ctanh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 24
+ldouble: 24
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "exp10":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+ildouble: 3
+ldouble: 3
+
+Function: "expm1":
+ildouble: 1
+ldouble: 1
+
+Function: "gamma":
+ildouble: 1
+ldouble: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "j0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "jn":
+double: 3
+float: 3
+idouble: 3
+ifloat: 3
+ildouble: 2
+ldouble: 2
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "log":
+float: 1
+ifloat: 1
+
+Function: "log10":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+# end of automatic generation
Index: trunk/src/libctests/glibc/sysdeps/m68k/fpu/Makefile
===================================================================
--- trunk/src/libctests/glibc/sysdeps/m68k/fpu/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/m68k/fpu/Makefile	(revision 2036)
@@ -0,0 +1,11 @@
+ifeq	($(subdir),math)
+ifndef	math-twiddled
+
+# Avoid twiddling in generic/Makefile.
+math-twiddled := t
+
+endif
+
+bsdmath_dirs := $(bsdmath_dirs) mc68881
+
+endif
Index: trunk/src/libctests/glibc/sysdeps/m68k/fpu/ftestexcept.c
===================================================================
--- trunk/src/libctests/glibc/sysdeps/m68k/fpu/ftestexcept.c	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/m68k/fpu/ftestexcept.c	(revision 2036)
@@ -0,0 +1,32 @@
+/* Test exception in current environment.
+   Copyright (C) 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <fenv.h>
+
+int
+fetestexcept (int excepts)
+{
+  fexcept_t fpsr;
+
+  /* Get current exceptions.  */
+  __asm__ ("fmove%.l %/fpsr,%0" : "=dm" (fpsr));
+
+  return fpsr & excepts & FE_ALL_EXCEPT;
+}
Index: trunk/src/libctests/glibc/sysdeps/m68k/fpu/libm-test-ulps
===================================================================
--- trunk/src/libctests/glibc/sysdeps/m68k/fpu/libm-test-ulps	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/m68k/fpu/libm-test-ulps	(revision 2036)
@@ -0,0 +1,1165 @@
+# Begin of automatic generation
+
+# acosh
+Test "acosh (7) == 2.63391579384963341725009269461593689":
+ildouble: 1
+ldouble: 1
+
+# asinh
+Test "asinh (0.75) == 0.693147180559945309417232121458176568":
+ildouble: 1
+ldouble: 1
+
+# atan2
+Test "atan2 (0.390625, .00029) == 1.57005392693128974780151246612928941":
+ildouble: 1
+ldouble: 1
+Test "atan2 (1.390625, 0.9296875) == 0.981498387184244311516296577615519772":
+ildouble: 1
+ldouble: 1
+
+# atanh
+Test "atanh (0.75) == 0.972955074527656652552676371721589865":
+ildouble: 1
+ldouble: 1
+
+# cacos
+Test "Real part of: cacos (0.75 + 1.25 i) == 1.11752014915610270578240049553777969 - 1.13239363160530819522266333696834467 i":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0.75 + 1.25 i) == 1.11752014915610270578240049553777969 - 1.13239363160530819522266333696834467 i":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+# cacosh
+Test "Real part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+ildouble: 6
+ldouble: 6
+Test "Imaginary part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+Test "Real part of: cacosh (0.75 + 1.25 i) == 1.13239363160530819522266333696834467 + 1.11752014915610270578240049553777969 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0.75 + 1.25 i) == 1.13239363160530819522266333696834467 + 1.11752014915610270578240049553777969 i":
+float: 1
+ifloat: 1
+
+# casin
+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+ildouble: 3
+ldouble: 3
+Test "Imaginary part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 6
+float: 19
+idouble: 6
+ifloat: 19
+ildouble: 5
+ldouble: 5
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 13
+float: 1
+idouble: 13
+ifloat: 1
+ildouble: 6
+ldouble: 6
+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# catan
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i":
+ildouble: 1
+ldouble: 1
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+ildouble: 1
+ldouble: 1
+
+# cbrt
+Test "cbrt (-0.001) == -0.1":
+ildouble: 1
+ldouble: 1
+Test "cbrt (0.9921875) == 0.997389022060725270579075195353955217":
+ildouble: 1
+ldouble: 1
+
+# ccos
+Test "Real part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# ccosh
+Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# cexp
+Test "Real part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# clog
+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+ildouble: 1
+ldouble: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Real part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + inf i) == inf + 3/4 pi*log10(e) i":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+float: 1
+ifloat: 1
+
+# cos
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "cos (pi/2) == 0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+float: 1
+ifloat: 1
+ildouble: 9
+ldouble: 9
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 15
+ldouble: 15
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (2 + 0 i, 10 + 0 i) == 1024.0 + 0.0 i":
+ildouble: 5
+ldouble: 5
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 4
+ldouble: 4
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 6
+ifloat: 6
+ildouble: 2
+ldouble: 2
+Test "Real part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+ildouble: 1
+ldouble: 1
+
+# csin
+Test "Real part of: csin (-2 - 3 i) == -9.15449914691142957346729954460983256 + 4.16890695996656435075481305885375484 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csin (-2 - 3 i) == -9.15449914691142957346729954460983256 + 4.16890695996656435075481305885375484 i":
+float: 1
+ifloat: 1
+Test "Real part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i":
+float: 1
+ifloat: 1
+
+# csinh
+Test "Real part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+float: 1
+ifloat: 1
+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+ildouble: 2
+ldouble: 2
+
+# ctanh
+Test "Imaginary part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# erfc
+Test "erfc (0.75) == 0.288844366346484868401062165408589223":
+float: 1
+ifloat: 1
+Test "erfc (1.25) == 0.0770998717435417698634765188027188596":
+ildouble: 1
+ldouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+float: 1
+ifloat: 1
+
+# expm1
+Test "expm1 (1) == M_El - 1.0":
+ildouble: 1
+ldouble: 1
+
+# gamma
+Test "gamma (-0.5) == log(2*sqrt(pi))":
+ildouble: 1
+ldouble: 1
+Test "gamma (0.5) == log(sqrt(pi))":
+ildouble: 1
+ldouble: 1
+Test "gamma (3) == M_LN2l":
+ildouble: 1
+ldouble: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "j0 (0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "j0 (1.5) == 0.511827671735918128749051744283411720":
+float: 1
+ifloat: 1
+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
+double: 1
+idouble: 1
+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# j1
+Test "j1 (-1.0) == -0.440050585744933515959682203718914913":
+float: 1
+ifloat: 1
+Test "j1 (1.0) == 0.440050585744933515959682203718914913":
+float: 1
+ifloat: 1
+Test "j1 (1.5) == 0.557936507910099641990121213156089400":
+float: 1
+ifloat: 1
+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
+float: 1
+ifloat: 1
+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# jn
+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (0, 0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "jn (0, 1.5) == 0.511827671735918128749051744283411720":
+float: 1
+ifloat: 1
+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
+double: 1
+idouble: 1
+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (1, -1.0) == -0.440050585744933515959682203718914913":
+float: 1
+ifloat: 1
+Test "jn (1, 1.0) == 0.440050585744933515959682203718914913":
+float: 1
+ifloat: 1
+Test "jn (1, 1.5) == 0.557936507910099641990121213156089400":
+float: 1
+ifloat: 1
+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
+float: 1
+ifloat: 1
+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (10, -1.0) == 0.263061512368745320699785368779050294e-9":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
+float: 1
+ifloat: 1
+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "jn (10, 1.0) == 0.263061512368745320699785368779050294e-9":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+ildouble: 2
+ldouble: 2
+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "jn (3, -1.0) == -0.0195633539826684059189053216217515083":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (3, 1.0) == 0.0195633539826684059189053216217515083":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
+ildouble: 1
+ldouble: 1
+
+# lgamma
+Test "lgamma (-0.5) == log(2*sqrt(pi))":
+ildouble: 1
+ldouble: 1
+Test "lgamma (0.5) == log(sqrt(pi))":
+ildouble: 1
+ldouble: 1
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "lgamma (3) == M_LN2l":
+ildouble: 1
+ldouble: 1
+
+# log
+Test "log (0.75) == -0.287682072451780927439219005993827432":
+ildouble: 1
+ldouble: 1
+Test "log (2) == M_LN2l":
+ildouble: 1
+ldouble: 1
+Test "log (e) == 1":
+float: 1
+ifloat: 1
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+ildouble: 2
+ldouble: 2
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+
+# log1p
+Test "log1p (-0.25) == -0.287682072451780927439219005993827432":
+ildouble: 1
+ldouble: 1
+
+# log2
+Test "log2 (0.75) == -.415037499278843818546261056052183492":
+ildouble: 1
+ldouble: 1
+
+# pow
+Test "pow (0.75, 1.25) == 0.697953644326574699205914060237425566":
+ildouble: 1
+ldouble: 1
+
+# sincos
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# sinh
+Test "sinh (0.75) == 0.822316731935829980703661634446913849":
+ildouble: 1
+ldouble: 1
+
+# tan
+Test "tan (0.75) == 0.931596459944072461165202756573936428":
+ildouble: 1
+ldouble: 1
+Test "tan (pi/4) == 1":
+double: 1
+idouble: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (4) == 6":
+ildouble: 1
+ldouble: 1
+
+# y0
+Test "y0 (0.125) == -1.38968062514384052915582277745018693":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y0 (0.75) == -0.137172769385772397522814379396581855":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
+ildouble: 1
+ldouble: 1
+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
+ildouble: 1
+ldouble: 1
+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
+ildouble: 1
+ldouble: 1
+Test "y0 (2.0) == 0.510375672649745119596606592727157873":
+float: 1
+ifloat: 1
+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# y1
+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
+ildouble: 1
+ldouble: 1
+Test "y1 (1.0) == -0.781212821300288716547150000047964821":
+double: 1
+idouble: 1
+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
+float: 1
+ifloat: 1
+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
+ildouble: 1
+ldouble: 1
+
+# yn
+Test "yn (0, 0.125) == -1.38968062514384052915582277745018693":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (0, 0.75) == -0.137172769385772397522814379396581855":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
+ildouble: 1
+ldouble: 1
+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
+ildouble: 1
+ldouble: 1
+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
+ildouble: 1
+ldouble: 1
+Test "yn (0, 2.0) == 0.510375672649745119596606592727157873":
+float: 1
+ifloat: 1
+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 0.75) == -1.03759455076928541973767132140642198":
+float: 1
+ifloat: 1
+Test "yn (1, 1.0) == -0.781212821300288716547150000047964821":
+double: 1
+idouble: 1
+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
+float: 1
+ifloat: 1
+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
+ildouble: 1
+ldouble: 1
+Test "yn (10, 0.125) == -127057845771019398.252538486899753195":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
+float: 1
+ifloat: 1
+ildouble: 4
+ldouble: 4
+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
+ildouble: 1
+ldouble: 1
+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
+float: 1
+ifloat: 1
+
+# Maximal error of functions:
+Function: "acosh":
+ildouble: 1
+ldouble: 1
+
+Function: "asinh":
+ildouble: 1
+ldouble: 1
+
+Function: "atan2":
+ildouble: 1
+ldouble: 1
+
+Function: "atanh":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cacos":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "cacos":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "cacosh":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+ildouble: 6
+ldouble: 6
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "casin":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+ildouble: 3
+ldouble: 3
+
+Function: Imaginary part of "casin":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "casinh":
+double: 6
+float: 19
+idouble: 6
+ifloat: 19
+ildouble: 5
+ldouble: 5
+
+Function: Imaginary part of "casinh":
+double: 13
+float: 1
+idouble: 13
+ifloat: 1
+ildouble: 6
+ldouble: 6
+
+Function: Real part of "catan":
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catanh":
+ildouble: 1
+ldouble: 1
+
+Function: "cbrt":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccos":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ccos":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccosh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "ccosh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cexp":
+float: 2
+ifloat: 2
+
+Function: Imaginary part of "cexp":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "clog":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "clog":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "clog10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cpow":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 15
+ldouble: 15
+
+Function: Imaginary part of "cpow":
+double: 2
+float: 6
+idouble: 2
+ifloat: 6
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "csin":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csin":
+float: 1
+ifloat: 1
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csinh":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctan":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ctan":
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "ctanh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "erfc":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "expm1":
+ildouble: 1
+ldouble: 1
+
+Function: "gamma":
+ildouble: 1
+ldouble: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "j0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "j1":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "jn":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+ildouble: 2
+ldouble: 2
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "log":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "log10":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: "log1p":
+ildouble: 1
+ldouble: 1
+
+Function: "log2":
+ildouble: 1
+ldouble: 1
+
+Function: "pow":
+ildouble: 1
+ldouble: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "sinh":
+ildouble: 1
+ldouble: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "y0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: "y1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "yn":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 4
+ldouble: 4
+
+# end of automatic generation
Index: trunk/src/libctests/glibc/sysdeps/mach/hurd/Makefile
===================================================================
--- trunk/src/libctests/glibc/sysdeps/mach/hurd/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/mach/hurd/Makefile	(revision 2036)
@@ -0,0 +1,213 @@
+# Copyright (C) 1993,94,95,96,97,98,99,2000,2001,2002, 2003, 2004
+#	Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+ifdef in-Makerules
+
+# Look for header files in hurd/ under the top-level library source directory.
+# Look for generated header files where they get created.
+includes += -I$(..)hurd -I$(common-objpfx)hurd/
+
+# We use the style `if (err = call(...))' a lot in the Hurd code,
+# where we have a lot of functions that return zero or an errno code.
++cflags += -Wno-parentheses
+
+# Do not use any assembly code from sysdeps/unix (and subdirectories).
+# This bypasses all the system call stubs and uses any existing posix or
+# generic C files instead.
+inhibit-sysdep-asm += unix*
+inhibit-unix-syscalls = yes
+
+# Don't try to generate anything from the installed Unix system and its
+# libraries.  That is only of use when building for a Unix system, so as to
+# be compatible with some existing binaries for that system.
+inhibit-glue = yes
+
+ifeq (,$(filter mach hurd,$(subdir)))
+# Subdirectories other than hurd/ might use the generated Hurd headers.
+# So make sure we get a chance to run in hurd/ to make them before all else.
+# (But we don't want to do this in mach/, because hurd/ needs some things
+# there, and we know mach/ doesn't need anything from hurd/.)
+
+hurd-objpfx = $(common-objpfx)hurd/
+
+# These are all the generated headers that <hurd.h> includes.
+before-compile += $(patsubst %,$(hurd-objpfx)hurd/%.h,auth io fs process)
+$(patsubst %,$(hurd-objpfx)hurd/%.%,auth io fs process): \
+  $(common-objpfx)mach/mach-shortcuts.h
+	$(MAKE) -C $(..)hurd before-compile no_deps=t
+endif
+
+# Hurd profil.c includes this file, so give a rule to make it.
+ifeq ($(subdir),gmon)
+$(common-objpfx)hurd/../mach/RPC_task_get_sampled_pcs.c:
+	$(MAKE) -C $(..)mach before-compile no_deps=t
+endif
+
+
+
+# Generate bits/errno.h from the section of the manual that lists all the errno
+# codes.
+
+errno.texinfo = $(..)manual/errno.texi
+
+hurd = $(..)sysdeps/mach/hurd
+
+define mach-errno-h
+($(foreach h,mach/message.h \
+	     mach/kern_return.h \
+	     mach/mig_errors.h \
+	     device/device_types.h,\
+ echo '#include <$h>';\
+ ))
+endef
+
+# We use the compiler to generate a list of absolute file names for
+# the headers we want to search for Mach error codes, listed above (and
+# incidentally, all other headers those include).
+-include $(common-objpfx)errnos.d
+$(common-objpfx)errnos.d: $(mach-errnos-deps)
+	$(mach-errno-h) | \
+	$(CC) $(CFLAGS) $(CPPFLAGS) -M -x c - | \
+	sed $(sed-remove-objpfx) -e 's,- *:,mach-errnos-deps :=,' \
+	    -e 's, \.\./, $(..),g' > $@t
+	mv -f $@t $@
+
+$(hurd)/bits/errno.h: $(common-objpfx)stamp-errnos ;
+$(common-objpfx)stamp-errnos: $(hurd)/errnos.awk $(errno.texinfo) \
+			      $(mach-errnos-deps) $(common-objpfx)errnos.d
+	$(AWK) -f $^ > $(hurd)/bits/errno.h-tmp
+# Make it unwritable so noone will edit it by mistake.
+	-chmod a-w $(hurd)/bits/errno.h-tmp
+	$(move-if-change) $(hurd)/bits/errno.h-tmp $(hurd)/bits/errno.h
+ifeq ($(with-cvs),yes)
+	test ! -d $(hurd)/CVS || \
+	  (cd $(hurd) && cvs commit -m'Regenerated from $^' bits/errno.h)
+endif
+	touch $@
+
+common-generated += errnos.d stamp-errnos
+
+
+# We install the real libc.a as libcrt.a and as libc.a we install a linker
+# script which does -( -lcrt -lmachuser -lhurduser -).
+
+libc-name = crt
+
+ifeq (,$(subdir))
+install-others += $(inst_libdir)/libc.a
+$(inst_libdir)/libc.a: $(hurd)/libc-ldscript $(+force); $(do-install)
+ifeq (yes,$(build-profile))
+install-others += $(inst_libdir)/libc_p.a
+$(inst_libdir)/libc_p.a: $(hurd)/libc_p-ldscript $(+force); $(do-install)
+endif
+endif
+
+# Make sure these are used to build the libc.so shared object too.  There
+# is a circular dependency between each of these shared objects and libc
+# (many high-level libc functions call stubs, stubs call low-level libc
+# functions like memcpy and mach_msg).  This works out fine at run time
+# (all the objects are loaded before resolving their symbols, so these
+# interdependencies are fine).  But to create the shared objects we must
+# link them one at a time; since each needs one or both of the others to
+# produce its DT_NEEDED entries and to assign its undefined symbols the
+# right symbol versions, we can't do any of them before the others!  To
+# get around this, we link each lib*user.so shared object twice.  First,
+# we link an object without reference to libc.so (since we haven't linked
+# libc.so yet), so it lacks a DT_NEEDED record for the libc soname it
+# depends on, and its undefined symbol references lack the symbol version
+# assignments they should have.  We will use this shared object solely to
+# link libc.so against it; that gives libc.so the proper DT_NEEDED record,
+# and symbol versions assignments (if the lib*user.so object is using them).
+# Finally we link a second version of the same lib*user.so shared object,
+# this time linked normally against libc so it gets a proper DT_NEEDED
+# record and symbol version set; this one can be installed for run-time use.
+rpcuserlibs := $(common-objpfx)mach/libmachuser.so \
+	       $(common-objpfx)hurd/libhurduser.so
+link-rpcuserlibs := $(rpcuserlibs:%user.so=%user-link.so)
+$(common-objpfx)libc.so: $(link-rpcuserlibs)
+rpath-dirs += mach hurd
+
+# Make sure the `lib' pass builds the dummy shared objects so
+# we can link libc against them.
+ifeq (mach,$(subdir))
+lib-noranlib: $(common-objpfx)mach/libmachuser-link.so
+endif
+ifeq (hurd,$(subdir))
+lib-noranlib: $(common-objpfx)hurd/libhurduser-link.so
+endif
+
+$(link-rpcuserlibs): %-link.so: %_pic.a
+# These shared objects are just for the purpose of linking libc,
+# so they don't need abi-note.o linked into them.
+	$(build-shlib-helper) \
+		-nostdlib -o $@ \
+		-Wl,-soname=$(*F).so$($(*F).so-version) \
+		$(build-shlib-objlist)
+libmachuser-link.so-no-z-defs = yes
+libhurduser-link.so-no-z-defs = yes
+
+# And get them into the libc.so ldscript.
+$(inst_libdir)/libc.so: $(rpcuserlibs)
+
+# The RPC stubs from these libraries are needed in building the dynamic
+# linker, too.  It must be self-contained, so we link the needed PIC
+# objects directly into the shared object.
+ifeq (elf,$(subdir))
+$(objpfx)librtld.map: $(rpcuserlibs:.so=_pic.a)
+
+CFLAGS-dl-load.c = -DEXTERNAL_MAP_FROM_FD
+endif
+
+# We need these libs to link static programs in the libc source tree, too.
+ifeq (yes,$(build-static))
+link-libc-static := -Wl,-\( \
+		    $(patsubst %,$(common-objpfx)%.a,\
+			       libc mach/libmachuser hurd/libhurduser) \
+		    $(static-gnulib) -Wl,-\)
+else
+ifeq (yes,$(build-shared))
+# We can try to link the programs with lib*_pic.a...
+link-libc-static := $(link-libc) -Wl,-\( \
+		    $(patsubst %,$(common-objpfx)%_pic.a,\
+			       libc mach/libmachuser hurd/libhurduser) \
+		    $(static-gnulib) -Wl,-\)
+endif
+endif
+
+
+ifeq ($(subdir),csu)
+
+extra-objs += static-start.o
+
+# We need special startup code for statically linked binaries.
+$(objpfx)crt0.o: $(objpfx)static-start.o $(objpfx)abi-note.o $(objpfx)init.o
+	$(link-relocatable)
+
+endif
+
+
+ifeq (hurd, $(subdir))
+sysdep_routines += cthreads
+endif
+
+ifeq ($(subdir),sunrpc)
+sysdep_headers += nfs/nfs.h
+endif
+
+endif	# in-Makerules
Index: trunk/src/libctests/glibc/sysdeps/mach/hurd/sigaltstack.c
===================================================================
--- trunk/src/libctests/glibc/sysdeps/mach/hurd/sigaltstack.c	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/mach/hurd/sigaltstack.c	(revision 2036)
@@ -0,0 +1,63 @@
+/* Copyright (C) 1992, 93, 94, 95, 97, 98 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <hurd.h>
+#include <hurd/signal.h>
+
+/* Run signals handlers on the stack specified by SS (if not NULL).
+   If OSS is not NULL, it is filled in with the old signal stack status.  */
+int
+__sigaltstack (argss, oss)
+     const struct sigaltstack *argss;
+     struct sigaltstack *oss;
+{
+  struct hurd_sigstate *s;
+  struct sigaltstack ss, old;
+
+  /* Fault before taking any locks.  */
+  if (argss != NULL)
+    ss = *argss;
+  if (oss != NULL)
+    *(volatile struct sigaltstack *) oss = *oss;
+
+  s = _hurd_self_sigstate ();
+  __spin_lock (&s->lock);
+
+  if (argss != NULL &&
+      (ss.ss_flags & SS_DISABLE) && (s->sigaltstack.ss_flags & SS_ONSTACK))
+    {
+      /* Can't disable a stack that is in use.  */
+      __spin_unlock (&s->lock);
+      errno = EINVAL;
+      return -1;
+    }
+
+  old = s->sigaltstack;
+
+  if (argss != NULL)
+    s->sigaltstack = ss;
+
+  __spin_unlock (&s->lock);
+
+  if (oss != NULL)
+    *oss = old;
+
+  return 0;
+}
+weak_alias (__sigaltstack, sigaltstack)
Index: trunk/src/libctests/glibc/sysdeps/mips/fpu/ftestexcept.c
===================================================================
--- trunk/src/libctests/glibc/sysdeps/mips/fpu/ftestexcept.c	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/mips/fpu/ftestexcept.c	(revision 2036)
@@ -0,0 +1,33 @@
+/* Test exception in current environment.
+   Copyright (C) 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@arthur.rhein-neckar.de>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+fetestexcept (int excepts)
+{
+  int cw;
+
+  /* Get current control word.  */
+  _FPU_GETCW (cw);
+
+  return cw & excepts & FE_ALL_EXCEPT;
+}
Index: trunk/src/libctests/glibc/sysdeps/mips/fpu/libm-test-ulps
===================================================================
--- trunk/src/libctests/glibc/sysdeps/mips/fpu/libm-test-ulps	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/mips/fpu/libm-test-ulps	(revision 2036)
@@ -0,0 +1,890 @@
+# Begin of automatic generation
+
+# atan2
+Test "atan2 (-0.75, -1.0) == -2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+Test "atan2 (0.75, -1.0) == 2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+Test "atan2 (1.390625, 0.9296875) == 0.981498387184244311516296577615519772":
+float: 1
+ifloat: 1
+
+# atanh
+Test "atanh (0.75) == 0.972955074527656652552676371721589865":
+float: 1
+ifloat: 1
+
+# cacosh
+Test "Real part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+Test "Imaginary part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+# casin
+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# catan
+Test "Real part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+float: 3
+ifloat: 3
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i":
+float: 4
+ifloat: 4
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 4
+idouble: 4
+Test "Imaginary part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+float: 4
+ifloat: 4
+Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+float: 6
+ifloat: 6
+
+# cbrt
+Test "cbrt (-27.0) == -3.0":
+double: 1
+idouble: 1
+Test "cbrt (0.75) == 0.908560296416069829445605878163630251":
+double: 1
+idouble: 1
+Test "cbrt (0.9921875) == 0.997389022060725270579075195353955217":
+double: 1
+idouble: 1
+
+# ccos
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+float: 1
+ifloat: 1
+
+# ccosh
+Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+
+# cexp
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+float: 1
+ifloat: 1
+
+# clog
+Test "Imaginary part of: clog (-2 - 3 i) == 1.2824746787307683680267437207826593 - 2.1587989303424641704769327722648368 i":
+float: 3
+ifloat: 3
+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+float: 1
+ifloat: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+float: 1
+ifloat: 1
+
+# cos
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "cos (pi/2) == 0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+# csinh
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+
+# csqrt
+Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+double: 1
+idouble: 1
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+float: 1
+ifloat: 1
+Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+idouble: 1
+
+# erf
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (2.0) == 0.00467773498104726583793074363274707139":
+double: 1
+idouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+
+# exp10
+Test "exp10 (-1) == 0.1":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "exp10 (3) == 1000":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+# expm1
+Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
+double: 1
+idouble: 1
+Test "expm1 (1) == M_El - 1.0":
+float: 1
+ifloat: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "j0 (2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+
+# j1
+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+
+# jn
+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "jn (0, 2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
+float: 4
+ifloat: 4
+Test "jn (3, 0.125) == 0.406503832554912875023029337653442868e-4":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# lgamma
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+
+# log1p
+Test "log1p (-0.25) == -0.287682072451780927439219005993827432":
+float: 1
+ifloat: 1
+
+# sincos
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/6, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res":
+float: 1
+ifloat: 1
+
+# tan
+Test "tan (pi/4) == 1":
+double: 1
+idouble: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y0
+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y1
+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "y1 (1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# yn
+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "yn (1, 1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "yn (10, 0.125) == -127057845771019398.252538486899753195":
+double: 1
+idouble: 1
+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (10, 1.0) == -121618014.278689189288130426667971145":
+double: 1
+idouble: 1
+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (10, 2.0) == -129184.542208039282635913145923304214":
+double: 2
+idouble: 2
+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
+double: 1
+idouble: 1
+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 10.0) == -0.251362657183837329779204747654240998":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: "atan2":
+float: 3
+ifloat: 3
+
+Function: "atanh":
+float: 1
+ifloat: 1
+
+Function: Real part of "cacosh":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+
+Function: Real part of "catan":
+float: 4
+ifloat: 4
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catanh":
+double: 4
+idouble: 4
+
+Function: Imaginary part of "catanh":
+float: 6
+ifloat: 6
+
+Function: "cbrt":
+double: 1
+idouble: 1
+
+Function: Real part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccos":
+float: 1
+ifloat: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccosh":
+float: 1
+ifloat: 1
+
+Function: Real part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Real part of "clog":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "clog":
+float: 3
+ifloat: 3
+
+Function: Real part of "clog10":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Real part of "cpow":
+double: 2
+float: 4
+idouble: 2
+ifloat: 4
+
+Function: Imaginary part of "cpow":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csqrt":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctan":
+double: 1
+idouble: 1
+
+Function: Imaginary part of "ctan":
+double: 1
+idouble: 1
+
+Function: Real part of "ctanh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Imaginary part of "ctanh":
+float: 1
+ifloat: 1
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+idouble: 1
+
+Function: "exp10":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+Function: "expm1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "j0":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "jn":
+double: 4
+float: 4
+idouble: 4
+ifloat: 4
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log10":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log1p":
+float: 1
+ifloat: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+# end of automatic generation
Index: trunk/src/libctests/glibc/sysdeps/powerpc/Makefile
===================================================================
--- trunk/src/libctests/glibc/sysdeps/powerpc/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/powerpc/Makefile	(revision 2036)
@@ -0,0 +1,30 @@
+# We always want to use the new mnemonic syntax even if we are on a RS6000
+# machine.
++cflags += -mnew-mnemonics
+
+ifeq ($(subdir),gmon)
+sysdep_routines += ppc-mcount
+endif
+
+ifeq ($(subdir),string)
+CFLAGS-memcmp.c += -Wno-uninitialized
+endif
+
+ifeq ($(subdir),elf)
+# extra shared linker files to link into dl-allobjs.so and libc
+sysdep-dl-routines += dl-machine
+sysdep_routines += dl-machine
+# extra shared linker files to link only into dl-allobjs.so
+sysdep-rtld-routines += dl-machine
+endif
+
+ifeq ($(subdir),setjmp)
+ifeq (yes,$(build-shared))
+sysdep_routines += novmx-longjmp novmx-sigjmp
+endif
+endif
+
+ifeq ($(subdir),csu)
+# get offset to rtld_global._dl_hwcap
+gen-as-const-headers += rtld-global-offsets.sym
+endif
Index: trunk/src/libctests/glibc/sysdeps/powerpc/fpu/Makefile
===================================================================
--- trunk/src/libctests/glibc/sysdeps/powerpc/fpu/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/powerpc/fpu/Makefile	(revision 2036)
@@ -0,0 +1,6 @@
+ifeq ($(subdir),math)
+libm-support += fenv_const fe_nomask t_sqrt
+
+# libm needs ld.so to access dl_hwcap
+$(objpfx)libm.so: $(elfobjdir)/ld.so
+endif
Index: trunk/src/libctests/glibc/sysdeps/powerpc/fpu/ftestexcept.c
===================================================================
--- trunk/src/libctests/glibc/sysdeps/powerpc/fpu/ftestexcept.c	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/powerpc/fpu/ftestexcept.c	(revision 2036)
@@ -0,0 +1,33 @@
+/* Test exception in current environment.
+   Copyright (C) 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <fenv_libc.h>
+
+int
+fetestexcept (int excepts)
+{
+  fenv_union_t u;
+
+  /* Get the current state.  */
+  u.fenv = fegetenv_register ();
+
+  /* The FE_INVALID bit is dealt with correctly by the hardware, so we can
+     just:  */
+  return u.l[1] & excepts;
+}
Index: trunk/src/libctests/glibc/sysdeps/powerpc/fpu/libm-test-ulps
===================================================================
--- trunk/src/libctests/glibc/sysdeps/powerpc/fpu/libm-test-ulps	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/powerpc/fpu/libm-test-ulps	(revision 2036)
@@ -0,0 +1,869 @@
+# Begin of automatic generation
+
+# atan2
+Test "atan2 (-0.75, -1.0) == -2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+Test "atan2 (0.75, -1.0) == 2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+Test "atan2 (1.390625, 0.9296875) == 0.981498387184244311516296577615519772":
+float: 1
+ifloat: 1
+Test "atan2 (-0.00756827042671106339, -.001792735857538728036) == -1.80338464113663849327153994379639112":
+float: 6
+ifloat: 6
+
+# atanh
+Test "atanh (0.75) == 0.972955074527656652552676371721589865":
+float: 1
+ifloat: 1
+
+# cacosh
+Test "Real part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+Test "Imaginary part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+# casin
+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# catan
+Test "Real part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+float: 3
+ifloat: 3
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i":
+float: 4
+ifloat: 4
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 4
+idouble: 4
+Test "Imaginary part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+float: 4
+ifloat: 4
+Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+float: 6
+ifloat: 6
+
+# cbrt
+Test "cbrt (-27.0) == -3.0":
+double: 1
+idouble: 1
+Test "cbrt (0.9921875) == 0.997389022060725270579075195353955217":
+double: 1
+idouble: 1
+
+# ccos
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+float: 1
+ifloat: 1
+
+# ccosh
+Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+
+# cexp
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+float: 1
+ifloat: 1
+
+# clog
+Test "Imaginary part of: clog (-2 - 3 i) == 1.2824746787307683680267437207826593 - 2.1587989303424641704769327722648368 i":
+float: 3
+ifloat: 3
+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+float: 1
+ifloat: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+float: 1
+ifloat: 1
+
+# cos
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "cos (pi/2) == 0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+# csinh
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+
+# csqrt
+Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+double: 1
+idouble: 1
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+float: 1
+ifloat: 1
+Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+idouble: 1
+
+# erf
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (0.75) == 0.288844366346484868401062165408589223":
+float: 1
+ifloat: 1
+Test "erfc (2.0) == 0.00467773498104726583793074363274707139":
+double: 1
+idouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+
+# exp10
+Test "exp10 (-1) == 0.1":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "exp10 (3) == 1000":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+# expm1
+Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
+double: 1
+idouble: 1
+Test "expm1 (1) == M_El - 1.0":
+float: 1
+ifloat: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+
+# j1
+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+
+# jn
+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
+float: 1
+ifloat: 1
+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
+float: 3
+ifloat: 3
+Test "jn (3, 0.125) == 0.406503832554912875023029337653442868e-4":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2":
+double: 1
+idouble: 1
+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# lgamma
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+
+# log1p
+Test "log1p (-0.25) == -0.287682072451780927439219005993827432":
+float: 1
+ifloat: 1
+
+# sincos
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/6, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res":
+float: 1
+ifloat: 1
+
+# tan
+Test "tan (pi/4) == 1":
+double: 1
+idouble: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y0
+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y0 (2.0) == 0.510375672649745119596606592727157873":
+double: 1
+idouble: 1
+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y1
+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# yn
+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (0, 2.0) == 0.510375672649745119596606592727157873":
+double: 1
+idouble: 1
+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "yn (10, 1.0) == -121618014.278689189288130426667971145":
+float: 2
+ifloat: 2
+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
+double: 2
+idouble: 2
+Test "yn (10, 2.0) == -129184.542208039282635913145923304214":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
+float: 1
+ifloat: 1
+Test "yn (3, 10.0) == -0.251362657183837329779204747654240998":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: "atan2":
+float: 6
+ifloat: 6
+
+Function: "atanh":
+float: 1
+ifloat: 1
+
+Function: Real part of "cacosh":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+
+Function: Real part of "catan":
+float: 4
+ifloat: 4
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catanh":
+double: 4
+idouble: 4
+
+Function: Imaginary part of "catanh":
+float: 6
+ifloat: 6
+
+Function: "cbrt":
+double: 1
+idouble: 1
+
+Function: Real part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccos":
+float: 1
+ifloat: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccosh":
+float: 1
+ifloat: 1
+
+Function: Real part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Real part of "clog":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "clog":
+float: 3
+ifloat: 3
+
+Function: Real part of "clog10":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Real part of "cpow":
+double: 2
+float: 4
+idouble: 2
+ifloat: 4
+
+Function: Imaginary part of "cpow":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csqrt":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctan":
+double: 1
+idouble: 1
+
+Function: Imaginary part of "ctan":
+double: 1
+idouble: 1
+
+Function: Real part of "ctanh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Imaginary part of "ctanh":
+float: 1
+ifloat: 1
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "exp10":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+Function: "expm1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "j0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "jn":
+double: 3
+float: 3
+idouble: 3
+ifloat: 3
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log10":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log1p":
+float: 1
+ifloat: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+# end of automatic generation
Index: trunk/src/libctests/glibc/sysdeps/powerpc/nofpu/Makefile
===================================================================
--- trunk/src/libctests/glibc/sysdeps/powerpc/nofpu/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/powerpc/nofpu/Makefile	(revision 2036)
@@ -0,0 +1,9 @@
+# Makefile fragment for PowerPC with no FPU.
+
+ifeq ($(subdir),soft-fp)
+sysdep_routines += $(gcc-single-routines) $(gcc-double-routines) sim-full
+endif
+
+ifeq ($(subdir),math)
+libm-support += fenv_const fe_nomask
+endif
Index: trunk/src/libctests/glibc/sysdeps/powerpc/nofpu/ftestexcept.c
===================================================================
--- trunk/src/libctests/glibc/sysdeps/powerpc/nofpu/ftestexcept.c	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/powerpc/nofpu/ftestexcept.c	(revision 2036)
@@ -0,0 +1,28 @@
+/* Test floating-point exceptions (soft-float edition).
+   Copyright (C) 2002 Free Software Foundation, Inc.
+   Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include "soft-fp.h"
+#include "soft-supp.h"
+
+int
+fetestexcept (int x)
+{
+  return __sim_exceptions & x;
+}
Index: trunk/src/libctests/glibc/sysdeps/powerpc/nofpu/libm-test-ulps
===================================================================
--- trunk/src/libctests/glibc/sysdeps/powerpc/nofpu/libm-test-ulps	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/powerpc/nofpu/libm-test-ulps	(revision 2036)
@@ -0,0 +1,890 @@
+# Begin of automatic generation
+
+# atan2
+Test "atan2 (-0.75, -1.0) == -2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+Test "atan2 (0.75, -1.0) == 2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+Test "atan2 (1.390625, 0.9296875) == 0.981498387184244311516296577615519772":
+float: 1
+ifloat: 1
+
+# atanh
+Test "atanh (0.75) == 0.972955074527656652552676371721589865":
+float: 1
+ifloat: 1
+
+# cacosh
+Test "Real part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+Test "Imaginary part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+# casin
+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# catan
+Test "Real part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+float: 3
+ifloat: 3
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i":
+float: 4
+ifloat: 4
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 4
+idouble: 4
+Test "Imaginary part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+float: 4
+ifloat: 4
+Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+float: 6
+ifloat: 6
+
+# cbrt
+Test "cbrt (-27.0) == -3.0":
+double: 1
+idouble: 1
+Test "cbrt (0.75) == 0.908560296416069829445605878163630251":
+double: 1
+idouble: 1
+Test "cbrt (0.9921875) == 0.997389022060725270579075195353955217":
+double: 1
+idouble: 1
+
+# ccos
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+float: 1
+ifloat: 1
+
+# ccosh
+Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+
+# cexp
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+float: 1
+ifloat: 1
+
+# clog
+Test "Imaginary part of: clog (-2 - 3 i) == 1.2824746787307683680267437207826593 - 2.1587989303424641704769327722648368 i":
+float: 3
+ifloat: 3
+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+float: 1
+ifloat: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+float: 1
+ifloat: 1
+
+# cos
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "cos (pi/2) == 0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+# csinh
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+
+# csqrt
+Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+double: 1
+idouble: 1
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+float: 1
+ifloat: 1
+Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+idouble: 1
+
+# erf
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (2.0) == 0.00467773498104726583793074363274707139":
+double: 1
+idouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+
+# exp10
+Test "exp10 (-1) == 0.1":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "exp10 (3) == 1000":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+# expm1
+Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
+double: 1
+idouble: 1
+Test "expm1 (1) == M_El - 1.0":
+float: 1
+ifloat: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "j0 (2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+
+# j1
+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+
+# jn
+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "jn (0, 2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
+float: 4
+ifloat: 4
+Test "jn (3, 0.125) == 0.406503832554912875023029337653442868e-4":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# lgamma
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+
+# log1p
+Test "log1p (-0.25) == -0.287682072451780927439219005993827432":
+float: 1
+ifloat: 1
+
+# sincos
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/6, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res":
+float: 1
+ifloat: 1
+
+# tan
+Test "tan (pi/4) == 1":
+double: 1
+idouble: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y0
+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y1
+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "y1 (1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# yn
+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "yn (1, 1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "yn (10, 0.125) == -127057845771019398.252538486899753195":
+double: 1
+idouble: 1
+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (10, 1.0) == -121618014.278689189288130426667971145":
+double: 1
+idouble: 1
+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (10, 2.0) == -129184.542208039282635913145923304214":
+double: 2
+idouble: 2
+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
+double: 1
+idouble: 1
+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 10.0) == -0.251362657183837329779204747654240998":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: "atan2":
+float: 3
+ifloat: 3
+
+Function: "atanh":
+float: 1
+ifloat: 1
+
+Function: Real part of "cacosh":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+
+Function: Real part of "catan":
+float: 4
+ifloat: 4
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catanh":
+double: 4
+idouble: 4
+
+Function: Imaginary part of "catanh":
+float: 6
+ifloat: 6
+
+Function: "cbrt":
+double: 1
+idouble: 1
+
+Function: Real part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccos":
+float: 1
+ifloat: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccosh":
+float: 1
+ifloat: 1
+
+Function: Real part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Real part of "clog":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "clog":
+float: 3
+ifloat: 3
+
+Function: Real part of "clog10":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Real part of "cpow":
+double: 2
+float: 4
+idouble: 2
+ifloat: 4
+
+Function: Imaginary part of "cpow":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csqrt":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctan":
+double: 1
+idouble: 1
+
+Function: Imaginary part of "ctan":
+double: 1
+idouble: 1
+
+Function: Real part of "ctanh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Imaginary part of "ctanh":
+float: 1
+ifloat: 1
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+idouble: 1
+
+Function: "exp10":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+Function: "expm1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "j0":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "jn":
+double: 4
+float: 4
+idouble: 4
+ifloat: 4
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log10":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log1p":
+float: 1
+ifloat: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+# end of automatic generation
Index: trunk/src/libctests/glibc/sysdeps/powerpc/test-arith.c
===================================================================
--- trunk/src/libctests/glibc/sysdeps/powerpc/test-arith.c	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/powerpc/test-arith.c	(revision 2036)
@@ -0,0 +1,605 @@
+/* Test floating-point arithmetic operations.
+   Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fenv.h>
+#include <assert.h>
+
+#ifndef ESIZE
+typedef double tocheck_t;
+#define ESIZE 11
+#define MSIZE 52
+#define FUNC(x) x
+#endif
+
+#define R_NEAREST 1
+#define R_ZERO 2
+#define R_UP 4
+#define R_DOWN 8
+#define R_ALL (R_NEAREST|R_ZERO|R_UP|R_DOWN)
+static fenv_t rmodes[4];
+static const char * const rmnames[4] =
+{ "nearest","zero","+Inf","-Inf" };
+
+typedef union {
+  tocheck_t tc;
+  unsigned char c[sizeof(tocheck_t)];
+} union_t;
+
+/* Don't try reading these in a font that doesn't distinguish
+   O and zero.  */
+typedef enum {
+  P_Z    = 0x0,  /* 00000...0 */
+  P_000O = 0x1,  /* 00011...1 */
+  P_001Z = 0x2,  /* 00100...0 */
+  P_00O  = 0x3,  /* 00111...1 */
+  P_01Z  = 0x4,  /* 01000...0 */
+  P_010O = 0x5,  /* 01011...1 */
+  P_011Z = 0x6,  /* 01100...0 */
+  P_0O   = 0x7,  /* 01111...1 */
+  P_1Z   = 0x8,  /* 10000...0 */
+  P_100O = 0x9,  /* 10011...1 */
+  P_101Z = 0xa,  /* 10100...0 */
+  P_10O  = 0xb,  /* 10111...1 */
+  P_11Z  = 0xc,  /* 11000...0 */
+  P_110O = 0xd,  /* 11011...1 */
+  P_111Z = 0xe,  /* 11100...0 */
+  P_O    = 0xf,  /* 11111...1 */
+  P_Z1   = 0x11, /* 000...001 */
+  P_Z10  = 0x12, /* 000...010 */
+  P_Z11  = 0x13, /* 000...011 */
+  P_0O00 = 0x14, /* 011...100 */
+  P_0O01 = 0x15, /* 011...101 */
+  P_0O0  = 0x16, /* 011...110 */
+  P_1Z1  = 0x19, /* 100...001 */
+  P_1Z10 = 0x1a, /* 100...010 */
+  P_1Z11 = 0x1b, /* 100...011 */
+  P_O00  = 0x1c, /* 111...100 */
+  P_O01  = 0x1d, /* 111...101 */
+  P_O0   = 0x1e, /* 111...110 */
+  P_R    = 0x20, /* rrr...rrr */ /* ('r' means random. ) */
+  P_Ro   = 0x21, /* rrr...rrr, with odd parity.  */
+  P_0R   = 0x22, /* 0rr...rrr */
+  P_1R   = 0x23, /* 1rr...rrr */
+  P_Rno  = 0x24, /* rrr...rrr, but not all ones.  */
+} pattern_t;
+
+static void
+pattern_fill(pattern_t ptn, unsigned char *start, int bitoffset, int count)
+{
+#define bitset(count, value) \
+      start[(count)/8] = (start[(count)/8] & ~(1 << 7-(count)%8)  \
+                          |  (value) << 7-(count)%8)
+  int i;
+
+  if (ptn >= 0 && ptn <= 0xf)
+    {
+      /* Patterns between 0 and 0xF have the following format:
+	 The LSBit is used to fill the last n-3 bits of the pattern;
+	 The next 3 bits are the first 3 bits of the pattern. */
+      for (i = 0; i < count; i++)
+	if (i < 3)
+	  bitset((bitoffset+i), ptn >> (3-i) & 1);
+	else
+	  bitset((bitoffset+i), ptn >> 0 & 1);
+    }
+  else if (ptn <= 0x1f)
+    {
+      /* Patterns between 0x10 and 0x1F have the following format:
+	 The two LSBits are the last two bits of the pattern;
+	 The 0x8 bit is the first bit of the pattern;
+	 The 0x4 bit is used to fill the remainder. */
+      for (i = 0; i < count; i++)
+	if (i == 0)
+	  bitset((bitoffset+i), ptn >> 3 & 1);
+	else if (i >= count-2)
+	  bitset((bitoffset+i), ptn >> (count-1-i) & 1);
+	else
+	  bitset((bitoffset+i), ptn >> 2 & 1);
+    }
+  else switch (ptn)
+    {
+    case P_0R: case P_1R:
+      assert(count > 0);
+      bitset(bitoffset, ptn & 1);
+      count--;
+      bitoffset++;
+    case P_R:
+      for (; count > 0; count--, bitoffset++)
+	bitset(bitoffset, rand() & 1);
+      break;
+    case P_Ro:
+      {
+	int op = 1;
+	assert(count > 0);
+	for (; count > 1; count--, bitoffset++)
+	  bitset(bitoffset, op ^= (rand() & 1));
+	bitset(bitoffset, op);
+	break;
+      }
+    case P_Rno:
+      {
+	int op = 1;
+	assert(count > 0);
+	for (; count > 1; count--, bitoffset++)
+	{
+	  int r = rand() & 1;
+	  op &= r;
+	  bitset(bitoffset, r);
+	}
+	bitset(bitoffset, rand() & (op ^ 1));
+	break;
+      }
+
+    default:
+      assert(0);
+    }
+#undef bitset
+}
+
+static tocheck_t
+pattern(int negative, pattern_t exp, pattern_t mant)
+{
+  union_t result;
+#if 0
+  int i;
+#endif
+
+  pattern_fill(negative ? P_O : P_Z, result.c, 0, 1);
+  pattern_fill(exp, result.c, 1, ESIZE);
+  pattern_fill(mant, result.c, ESIZE+1, MSIZE);
+#if 0
+  printf("neg=%d exp=%02x mant=%02x: ", negative, exp, mant);
+  for (i = 0; i < sizeof(tocheck_t); i++)
+    printf("%02x", result.c[i]);
+  printf("\n");
+#endif
+  return result.tc;
+}
+
+/* Return the closest different tocheck_t to 'x' in the direction of
+   'direction', or 'x' if there is no such value.  Assumes 'x' is not
+   a NaN.  */
+static tocheck_t
+delta(tocheck_t x, int direction)
+{
+  union_t xx;
+  int i;
+
+  xx.tc = x;
+  if (xx.c[0] & 0x80)
+    direction = -direction;
+  if (direction == +1)
+    {
+      union_t tx;
+      tx.tc = pattern(xx.c[0] >> 7, P_O, P_Z);
+      if (memcmp(tx.c, xx.c, sizeof(tocheck_t)) == 0)
+	return x;
+    }
+  for (i = sizeof(tocheck_t)-1; i > 0; i--)
+    {
+      xx.c[i] += direction;
+      if (xx.c[i] != (direction > 0 ? 0 : 0xff))
+	return xx.tc;
+    }
+  if (direction < 0 && (xx.c[0] & 0x7f) == 0)
+    return pattern(~(xx.c[0] >> 7) & 1, P_Z, P_Z1);
+  else
+    {
+      xx.c[0] += direction;
+      return xx.tc;
+    }
+}
+
+static int nerrors = 0;
+
+#ifdef FE_ALL_INVALID
+static const int all_exceptions = FE_ALL_INVALID | FE_ALL_EXCEPT;
+#else
+static const int all_exceptions = FE_ALL_EXCEPT;
+#endif
+
+static void
+check_result(int line, const char *rm, tocheck_t expected, tocheck_t actual)
+{
+  if (memcmp(&expected, &actual, sizeof(tocheck_t)) != 0)
+    {
+      unsigned char *ex, *ac;
+      size_t i;
+
+      printf("%s:%d:round %s:result failed\n"
+	     " expected result 0x", __FILE__, line, rm);
+      ex = (unsigned char *)&expected;
+      ac = (unsigned char *)&actual;
+      for (i = 0; i < sizeof(tocheck_t); i++)
+	printf("%02x", ex[i]);
+      printf(" got 0x");
+      for (i = 0; i < sizeof(tocheck_t); i++)
+	printf("%02x", ac[i]);
+      printf("\n");
+      nerrors++;
+    }
+}
+
+static const struct {
+  int except;
+  const char *name;
+} excepts[] = {
+#define except_entry(ex) { ex, #ex } ,
+#ifdef FE_INEXACT
+  except_entry(FE_INEXACT)
+#else
+# define FE_INEXACT 0
+#endif
+#ifdef FE_DIVBYZERO
+  except_entry(FE_DIVBYZERO)
+#else
+# define FE_DIVBYZERO 0
+#endif
+#ifdef FE_UNDERFLOW
+  except_entry(FE_UNDERFLOW)
+#else
+# define FE_UNDERFLOW 0
+#endif
+#ifdef FE_OVERFLOW
+  except_entry(FE_OVERFLOW)
+#else
+# define FE_OVERFLOW 0
+#endif
+#ifdef FE_INVALID
+  except_entry(FE_INVALID)
+#else
+# define FE_INVALID 0
+#endif
+#ifdef FE_INVALID_SNAN
+  except_entry(FE_INVALID_SNAN)
+#else
+# define FE_INVALID_SNAN FE_INVALID
+#endif
+#ifdef FE_INVALID_ISI
+  except_entry(FE_INVALID_ISI)
+#else
+# define FE_INVALID_ISI FE_INVALID
+#endif
+#ifdef FE_INVALID_IDI
+  except_entry(FE_INVALID_IDI)
+#else
+# define FE_INVALID_IDI FE_INVALID
+#endif
+#ifdef FE_INVALID_ZDZ
+  except_entry(FE_INVALID_ZDZ)
+#else
+# define FE_INVALID_ZDZ FE_INVALID
+#endif
+#ifdef FE_INVALID_COMPARE
+  except_entry(FE_INVALID_COMPARE)
+#else
+# define FE_INVALID_COMPARE FE_INVALID
+#endif
+#ifdef FE_INVALID_SOFTWARE
+  except_entry(FE_INVALID_SOFTWARE)
+#else
+# define FE_INVALID_SOFTWARE FE_INVALID
+#endif
+#ifdef FE_INVALID_SQRT
+  except_entry(FE_INVALID_SQRT)
+#else
+# define FE_INVALID_SQRT FE_INVALID
+#endif
+#ifdef FE_INVALID_INTEGER_CONVERSION
+  except_entry(FE_INVALID_INTEGER_CONVERSION)
+#else
+# define FE_INVALID_INTEGER_CONVERSION FE_INVALID
+#endif
+};
+
+static int excepts_missing = 0;
+
+static void
+check_excepts(int line, const char *rm, int expected, int actual)
+{
+  if (expected & excepts_missing)
+    expected = expected & ~excepts_missing | FE_INVALID_SNAN;
+  if ((expected & all_exceptions) != actual)
+    {
+      size_t i;
+      printf("%s:%d:round %s:exceptions failed\n"
+	     " expected exceptions ", __FILE__, line,rm);
+      for (i = 0; i < sizeof(excepts)/sizeof(excepts[0]); i++)
+	if (expected & excepts[i].except)
+	  printf("%s ",excepts[i].name);
+      if ((expected & all_exceptions) == 0)
+	printf("- ");
+      printf("got");
+      for (i = 0; i < sizeof(excepts)/sizeof(excepts[0]); i++)
+	if (actual & excepts[i].except)
+	  printf(" %s",excepts[i].name);
+      if ((actual & all_exceptions) == 0)
+	printf("- ");
+      printf(".\n");
+      nerrors++;
+    }
+}
+
+typedef enum {
+  B_ADD, B_SUB, B_MUL, B_DIV, B_NEG, B_ABS, B_SQRT
+} op_t;
+typedef struct {
+  int line;
+  op_t op;
+  int a_sgn;
+  pattern_t a_exp, a_mant;
+  int b_sgn;
+  pattern_t b_exp, b_mant;
+  int rmode;
+  int excepts;
+  int x_sgn;
+  pattern_t x_exp, x_mant;
+} optest_t;
+static const optest_t optests[] = {
+  /* Additions of zero.  */
+  {__LINE__,B_ADD, 0,P_Z,P_Z, 0,P_Z,P_Z, R_ALL,0, 0,P_Z,P_Z },
+  {__LINE__,B_ADD, 1,P_Z,P_Z, 0,P_Z,P_Z, R_ALL & ~R_DOWN,0, 0,P_Z,P_Z },
+  {__LINE__,B_ADD, 1,P_Z,P_Z, 0,P_Z,P_Z, R_DOWN,0, 1,P_Z,P_Z },
+  {__LINE__,B_ADD, 1,P_Z,P_Z, 1,P_Z,P_Z, R_ALL,0, 1,P_Z,P_Z },
+
+  /* Additions with NaN.  */
+  {__LINE__,B_ADD, 0,P_O,P_101Z, 0,P_Z,P_Z, R_ALL,0, 0,P_O,P_101Z },
+  {__LINE__,B_ADD, 0,P_O,P_01Z, 0,P_Z,P_Z, R_ALL,
+   FE_INVALID | FE_INVALID_SNAN, 0,P_O,P_11Z },
+  {__LINE__,B_ADD, 0,P_O,P_Z, 0,P_O,P_0O, R_ALL,
+   FE_INVALID | FE_INVALID_SNAN, 0,P_O,P_O },
+  {__LINE__,B_ADD, 0,P_Z,P_Z, 0,P_O,P_11Z, R_ALL,0, 0,P_O,P_11Z },
+  {__LINE__,B_ADD, 0,P_O,P_001Z, 0,P_O,P_001Z, R_ALL,
+   FE_INVALID | FE_INVALID_SNAN, 0,P_O,P_101Z },
+  {__LINE__,B_ADD, 0,P_O,P_1Z, 0,P_Z,P_Z, R_ALL,0, 0,P_O,P_1Z },
+  {__LINE__,B_ADD, 0,P_0O,P_Z, 0,P_O,P_10O, R_ALL,0, 0,P_O,P_10O },
+
+  /* Additions with infinity.  */
+  {__LINE__,B_ADD, 0,P_O,P_Z, 0,P_Z,P_Z, R_ALL,0, 0,P_O,P_Z },
+  {__LINE__,B_ADD, 0,P_O,P_Z, 1,P_Z,P_Z, R_ALL,0, 0,P_O,P_Z },
+  {__LINE__,B_ADD, 1,P_O,P_Z, 0,P_Z,P_Z, R_ALL,0, 1,P_O,P_Z },
+  {__LINE__,B_ADD, 1,P_O,P_Z, 1,P_Z,P_Z, R_ALL,0, 1,P_O,P_Z },
+  {__LINE__,B_ADD, 0,P_O,P_Z, 0,P_O,P_Z, R_ALL,0, 0,P_O,P_Z },
+  {__LINE__,B_ADD, 1,P_O,P_Z, 1,P_O,P_Z, R_ALL,0, 1,P_O,P_Z },
+  {__LINE__,B_ADD, 0,P_O,P_Z, 1,P_O,P_Z, R_ALL,
+   FE_INVALID | FE_INVALID_ISI, 0,P_O,P_1Z },
+  {__LINE__,B_ADD, 1,P_O,P_Z, 0,P_O,P_Z, R_ALL,
+   FE_INVALID | FE_INVALID_ISI, 0,P_O,P_1Z },
+  {__LINE__,B_ADD, 0,P_O,P_Z, 0,P_0O,P_Z, R_ALL,0, 0,P_O,P_Z },
+  {__LINE__,B_ADD, 1,P_O,P_Z, 0,P_0O,P_Z, R_ALL,0, 1,P_O,P_Z },
+  {__LINE__,B_ADD, 0,P_O,P_Z, 1,P_0O,P_Z, R_ALL,0, 0,P_O,P_Z },
+  {__LINE__,B_ADD, 1,P_O,P_Z, 1,P_0O,P_Z, R_ALL,0, 1,P_O,P_Z },
+
+  /* Overflow (and zero).  */
+  {__LINE__,B_ADD, 0,P_O0,P_Z, 0,P_O0,P_Z, R_NEAREST | R_UP,
+   FE_INEXACT | FE_OVERFLOW, 0,P_O,P_Z },
+  {__LINE__,B_ADD, 0,P_O0,P_Z, 0,P_O0,P_Z, R_ZERO | R_DOWN,
+   FE_INEXACT | FE_OVERFLOW, 0,P_O0,P_O },
+  {__LINE__,B_ADD, 1,P_O0,P_Z, 1,P_O0,P_Z, R_NEAREST | R_DOWN,
+   FE_INEXACT | FE_OVERFLOW, 1,P_O,P_Z },
+  {__LINE__,B_ADD, 1,P_O0,P_Z, 1,P_O0,P_Z, R_ZERO | R_UP,
+   FE_INEXACT | FE_OVERFLOW, 1,P_O0,P_O },
+  {__LINE__,B_ADD, 0,P_O0,P_Z, 1,P_O0,P_Z, R_ALL & ~R_DOWN,
+   0, 0,P_Z,P_Z },
+  {__LINE__,B_ADD, 0,P_O0,P_Z, 1,P_O0,P_Z, R_DOWN,
+   0, 1,P_Z,P_Z },
+
+  /* Negation.  */
+  {__LINE__,B_NEG, 0,P_Z,P_Z,   0,0,0, R_ALL, 0, 1,P_Z,P_Z },
+  {__LINE__,B_NEG, 1,P_Z,P_Z,   0,0,0, R_ALL, 0, 0,P_Z,P_Z },
+  {__LINE__,B_NEG, 0,P_O,P_Z,   0,0,0, R_ALL, 0, 1,P_O,P_Z },
+  {__LINE__,B_NEG, 1,P_O,P_Z,   0,0,0, R_ALL, 0, 0,P_O,P_Z },
+  {__LINE__,B_NEG, 0,P_O,P_1Z,  0,0,0, R_ALL, 0, 1,P_O,P_1Z },
+  {__LINE__,B_NEG, 1,P_O,P_1Z,  0,0,0, R_ALL, 0, 0,P_O,P_1Z },
+  {__LINE__,B_NEG, 0,P_O,P_01Z, 0,0,0, R_ALL, 0, 1,P_O,P_01Z },
+  {__LINE__,B_NEG, 1,P_O,P_01Z, 0,0,0, R_ALL, 0, 0,P_O,P_01Z },
+  {__LINE__,B_NEG, 0,P_1Z,P_1Z1, 0,0,0, R_ALL, 0, 1,P_1Z,P_1Z1 },
+  {__LINE__,B_NEG, 1,P_1Z,P_1Z1, 0,0,0, R_ALL, 0, 0,P_1Z,P_1Z1 },
+  {__LINE__,B_NEG, 0,P_Z,P_Z1,  0,0,0, R_ALL, 0, 1,P_Z,P_Z1 },
+  {__LINE__,B_NEG, 1,P_Z,P_Z1,  0,0,0, R_ALL, 0, 0,P_Z,P_Z1 },
+
+  /* Absolute value.  */
+  {__LINE__,B_ABS, 0,P_Z,P_Z,   0,0,0, R_ALL, 0, 0,P_Z,P_Z },
+  {__LINE__,B_ABS, 1,P_Z,P_Z,   0,0,0, R_ALL, 0, 0,P_Z,P_Z },
+  {__LINE__,B_ABS, 0,P_O,P_Z,   0,0,0, R_ALL, 0, 0,P_O,P_Z },
+  {__LINE__,B_ABS, 1,P_O,P_Z,   0,0,0, R_ALL, 0, 0,P_O,P_Z },
+  {__LINE__,B_ABS, 0,P_O,P_1Z,  0,0,0, R_ALL, 0, 0,P_O,P_1Z },
+  {__LINE__,B_ABS, 1,P_O,P_1Z,  0,0,0, R_ALL, 0, 0,P_O,P_1Z },
+  {__LINE__,B_ABS, 0,P_O,P_01Z, 0,0,0, R_ALL, 0, 0,P_O,P_01Z },
+  {__LINE__,B_ABS, 1,P_O,P_01Z, 0,0,0, R_ALL, 0, 0,P_O,P_01Z },
+  {__LINE__,B_ABS, 0,P_1Z,P_1Z1, 0,0,0, R_ALL, 0, 0,P_1Z,P_1Z1 },
+  {__LINE__,B_ABS, 1,P_1Z,P_1Z1, 0,0,0, R_ALL, 0, 0,P_1Z,P_1Z1 },
+  {__LINE__,B_ABS, 0,P_Z,P_Z1,  0,0,0, R_ALL, 0, 0,P_Z,P_Z1 },
+  {__LINE__,B_ABS, 1,P_Z,P_Z1,  0,0,0, R_ALL, 0, 0,P_Z,P_Z1 },
+
+  /* Square root.  */
+  {__LINE__,B_SQRT, 0,P_Z,P_Z,   0,0,0, R_ALL, 0, 0,P_Z,P_Z },
+  {__LINE__,B_SQRT, 1,P_Z,P_Z,   0,0,0, R_ALL, 0, 1,P_Z,P_Z },
+  {__LINE__,B_SQRT, 0,P_O,P_1Z,  0,0,0, R_ALL, 0, 0,P_O,P_1Z },
+  {__LINE__,B_SQRT, 1,P_O,P_1Z,  0,0,0, R_ALL, 0, 1,P_O,P_1Z },
+  {__LINE__,B_SQRT, 0,P_O,P_01Z, 0,0,0, R_ALL,
+   FE_INVALID | FE_INVALID_SNAN, 0,P_O,P_11Z },
+  {__LINE__,B_SQRT, 1,P_O,P_01Z, 0,0,0, R_ALL,
+   FE_INVALID | FE_INVALID_SNAN, 1,P_O,P_11Z },
+
+  {__LINE__,B_SQRT, 0,P_O,P_Z,   0,0,0, R_ALL, 0, 0,P_O,P_Z },
+  {__LINE__,B_SQRT, 0,P_0O,P_Z,  0,0,0, R_ALL, 0, 0,P_0O,P_Z },
+
+  {__LINE__,B_SQRT, 1,P_O,P_Z,   0,0,0, R_ALL,
+   FE_INVALID | FE_INVALID_SQRT, 0,P_O,P_1Z },
+  {__LINE__,B_SQRT, 1,P_1Z,P_1Z1, 0,0,0, R_ALL,
+   FE_INVALID | FE_INVALID_SQRT, 0,P_O,P_1Z },
+  {__LINE__,B_SQRT, 1,P_Z,P_Z1,  0,0,0, R_ALL,
+   FE_INVALID | FE_INVALID_SQRT, 0,P_O,P_1Z },
+
+};
+
+static void
+check_op(void)
+{
+  size_t i;
+  int j;
+  tocheck_t r, a, b, x;
+  int raised;
+
+  for (i = 0; i < sizeof(optests)/sizeof(optests[0]); i++)
+    {
+      a = pattern(optests[i].a_sgn, optests[i].a_exp,
+		  optests[i].a_mant);
+      b = pattern(optests[i].b_sgn, optests[i].b_exp,
+		  optests[i].b_mant);
+      x = pattern(optests[i].x_sgn, optests[i].x_exp,
+		  optests[i].x_mant);
+      for (j = 0; j < 4; j++)
+	if (optests[i].rmode & 1<<j)
+	  {
+	    fesetenv(rmodes+j);
+	    switch (optests[i].op)
+	      {
+	      case B_ADD: r = a + b; break;
+	      case B_SUB: r = a - b; break;
+	      case B_MUL: r = a * b; break;
+	      case B_DIV: r = a / b; break;
+	      case B_NEG: r = -a; break;
+	      case B_ABS: r = FUNC(fabs)(a); break;
+	      case B_SQRT: r = FUNC(sqrt)(a); break;
+	      }
+	    raised = fetestexcept(all_exceptions);
+	    check_result(optests[i].line,rmnames[j],x,r);
+	    check_excepts(optests[i].line,rmnames[j],
+			  optests[i].excepts,raised);
+	  }
+    }
+}
+
+static void
+fail_xr(int line, const char *rm, tocheck_t x, tocheck_t r, tocheck_t xx,
+	int xflag)
+{
+  size_t i;
+  unsigned char *cx, *cr, *cxx;
+
+  printf("%s:%d:round %s:fail\n with x=0x", __FILE__, line,rm);
+  cx = (unsigned char *)&x;
+  cr = (unsigned char *)&r;
+  cxx = (unsigned char *)&xx;
+  for (i = 0; i < sizeof(tocheck_t); i++)
+    printf("%02x", cx[i]);
+  printf(" r=0x");
+  for (i = 0; i < sizeof(tocheck_t); i++)
+    printf("%02x", cr[i]);
+  printf(" xx=0x");
+  for (i = 0; i < sizeof(tocheck_t); i++)
+    printf("%02x", cxx[i]);
+  printf(" inexact=%d\n", xflag != 0);
+  nerrors++;
+}
+
+static void
+check_sqrt(tocheck_t a)
+{
+  int j;
+  tocheck_t r0, r1, r2, x0, x1, x2;
+  int raised = 0;
+  int ok;
+
+  for (j = 0; j < 4; j++)
+    {
+      int excepts;
+
+      fesetenv(rmodes+j);
+      r1 = FUNC(sqrt)(a);
+      excepts = fetestexcept(all_exceptions);
+      fesetenv(FE_DFL_ENV);
+      raised |= excepts & ~FE_INEXACT;
+      x1 = r1 * r1 - a;
+      if (excepts & FE_INEXACT)
+	{
+	  r0 = delta(r1,-1); r2 = delta(r1,1);
+	  switch (1 << j)
+	    {
+	    case R_NEAREST:
+	      x0 = r0 * r0 - a; x2 = r2 * r2 - a;
+	      ok = fabs(x0) >= fabs(x1) && fabs(x1) <= fabs(x2);
+	      break;
+	    case R_ZERO:  case R_DOWN:
+	      x2 = r2 * r2 - a;
+	      ok = x1 <= 0 && x2 >= 0;
+	      break;
+	    case R_UP:
+	      x0 = r0 * r0 - a;
+	      ok = x1 >= 0 && x0 <= 0;
+	      break;
+	    default:
+	      assert(0);
+	    }
+	}
+      else
+	ok = x1 == 0;
+      if (!ok)
+	fail_xr(__LINE__,rmnames[j],a,r1,x1,excepts&FE_INEXACT);
+    }
+  check_excepts(__LINE__,"all",0,raised);
+}
+
+int main(int argc, char **argv)
+{
+  int i;
+
+  _LIB_VERSION = _IEEE_;
+
+  /* Set up environments for rounding modes.  */
+  fesetenv(FE_DFL_ENV);
+  fesetround(FE_TONEAREST);
+  fegetenv(rmodes+0);
+  fesetround(FE_TOWARDZERO);
+  fegetenv(rmodes+1);
+  fesetround(FE_UPWARD);
+  fegetenv(rmodes+2);
+  fesetround(FE_DOWNWARD);
+  fegetenv(rmodes+3);
+
+#if defined(FE_INVALID_SOFTWARE) || defined(FE_INVALID_SQRT)
+  /* There's this really stupid feature of the 601... */
+  fesetenv(FE_DFL_ENV);
+  feraiseexcept(FE_INVALID_SOFTWARE);
+  if (!fetestexcept(FE_INVALID_SOFTWARE))
+    excepts_missing |= FE_INVALID_SOFTWARE;
+  fesetenv(FE_DFL_ENV);
+  feraiseexcept(FE_INVALID_SQRT);
+  if (!fetestexcept(FE_INVALID_SQRT))
+    excepts_missing |= FE_INVALID_SQRT;
+#endif
+
+  check_op();
+  for (i = 0; i < 100000; i++)
+    check_sqrt(pattern(0, P_Rno, P_R));
+  for (i = 0; i < 100; i++)
+    check_sqrt(pattern(0, P_Z, P_R));
+  check_sqrt(pattern(0,P_Z,P_Z1));
+
+  printf("%d errors.\n", nerrors);
+  return nerrors == 0 ? 0 : 1;
+}
Index: trunk/src/libctests/glibc/sysdeps/powerpc/test-arithf.c
===================================================================
--- trunk/src/libctests/glibc/sysdeps/powerpc/test-arithf.c	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/powerpc/test-arithf.c	(revision 2036)
@@ -0,0 +1,6 @@
+typedef float tocheck_t;
+#define ESIZE 8
+#define MSIZE 23
+#define FUNC(x) x##f
+
+#include "test-arith.c"
Index: trunk/src/libctests/glibc/sysdeps/powerpc/tst-stack-align.h
===================================================================
--- trunk/src/libctests/glibc/sysdeps/powerpc/tst-stack-align.h	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/powerpc/tst-stack-align.h	(revision 2036)
@@ -0,0 +1,47 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <stdint.h>
+
+#define TEST_STACK_ALIGN() \
+  ({									     \
+    /* Altivec __vector int etc. needs 16byte aligned stack.		     \
+       Instead of using altivec.h here, use aligned attribute instead.  */   \
+    struct _S								     \
+      {									     \
+        int _i __attribute__((aligned (16)));				     \
+	int _j[3];							     \
+      } _s = { ._i = 18, ._j[0] = 19, ._j[1] = 20, ._j[2] = 21 };	     \
+    double _d = 12.0;							     \
+    long double _ld = 15.0;						     \
+    int _ret = 0;							     \
+    printf ("__vector int:  { %d, %d, %d, %d } %p %zu\n", _s._i, _s._j[0],   \
+            _s._j[1], _s._j[2], &_s, __alignof (_s));			     \
+    if ((((uintptr_t) &_s) & (__alignof (_s) - 1)) != 0)		     \
+      _ret = 1;								     \
+									     \
+    printf ("double:  %g %p %zu\n", _d, &_d, __alignof (double));	     \
+    if ((((uintptr_t) &_d) & (__alignof (double) - 1)) != 0)		     \
+      _ret = 1;								     \
+									     \
+    printf ("ldouble: %Lg %p %zu\n", _ld, &_ld, __alignof (long double));    \
+    if ((((uintptr_t) &_ld) & (__alignof (long double) - 1)) != 0)	     \
+      _ret = 1;								     \
+    _ret;								     \
+    })
Index: trunk/src/libctests/glibc/sysdeps/s390/fpu/ftestexcept.c
===================================================================
--- trunk/src/libctests/glibc/sysdeps/s390/fpu/ftestexcept.c	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/s390/fpu/ftestexcept.c	(revision 2036)
@@ -0,0 +1,33 @@
+/* Test exception in current environment.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Denis Joseph Barrow (djbarrow@de.ibm.com).
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <fenv_libc.h>
+#include <fpu_control.h>
+
+int
+fetestexcept (int excepts)
+{
+  fexcept_t temp;
+
+  /* Get current exceptions.  */
+  _FPU_GETCW (temp);
+  temp = (temp >> FPC_DXC_SHIFT) | (temp >> FPC_FLAGS_SHIFT);
+  return temp & excepts & FE_ALL_EXCEPT;
+}
Index: trunk/src/libctests/glibc/sysdeps/s390/fpu/libm-test-ulps
===================================================================
--- trunk/src/libctests/glibc/sysdeps/s390/fpu/libm-test-ulps	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/s390/fpu/libm-test-ulps	(revision 2036)
@@ -0,0 +1,916 @@
+# Begin of automatic generation
+
+# atan2
+Test "atan2 (-0.75, -1.0) == -2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+Test "atan2 (0.75, -1.0) == 2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+Test "atan2 (1.390625, 0.9296875) == 0.981498387184244311516296577615519772":
+float: 1
+ifloat: 1
+Test "atan2 (-0.00756827042671106339, -.001792735857538728036) == -1.80338464113663849327153994379639112":
+float: 6
+ifloat: 6
+
+# atanh
+Test "atanh (0.75) == 0.972955074527656652552676371721589865":
+float: 1
+ifloat: 1
+
+# cacosh
+Test "Real part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+Test "Imaginary part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+# casin
+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# catan
+Test "Real part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+float: 3
+ifloat: 3
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i":
+float: 4
+ifloat: 4
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 4
+idouble: 4
+Test "Imaginary part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+float: 4
+ifloat: 4
+Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+float: 6
+ifloat: 6
+
+# cbrt
+Test "cbrt (-27.0) == -3.0":
+double: 1
+idouble: 1
+Test "cbrt (0.75) == 0.908560296416069829445605878163630251":
+double: 1
+idouble: 1
+Test "cbrt (0.9921875) == 0.997389022060725270579075195353955217":
+double: 1
+idouble: 1
+
+# ccos
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+float: 1
+ifloat: 1
+
+# ccosh
+Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+
+# cexp
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+float: 1
+ifloat: 1
+
+# clog
+Test "Imaginary part of: clog (-2 - 3 i) == 1.2824746787307683680267437207826593 - 2.1587989303424641704769327722648368 i":
+float: 3
+ifloat: 3
+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+float: 1
+ifloat: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+float: 1
+ifloat: 1
+
+# cos
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "cos (pi/2) == 0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+# csinh
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+
+# csqrt
+Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+double: 1
+idouble: 1
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+float: 1
+ifloat: 1
+Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+idouble: 1
+
+# erf
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (0.75) == 0.288844366346484868401062165408589223":
+float: 1
+ifloat: 1
+Test "erfc (2.0) == 0.00467773498104726583793074363274707139":
+double: 1
+idouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+
+# exp10
+Test "exp10 (-1) == 0.1":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "exp10 (3) == 1000":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+# expm1
+Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
+double: 1
+idouble: 1
+Test "expm1 (1) == M_El - 1.0":
+float: 1
+ifloat: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "j0 (2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+
+# j1
+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+
+# jn
+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "jn (0, 2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
+float: 4
+ifloat: 4
+Test "jn (3, 0.125) == 0.406503832554912875023029337653442868e-4":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# lgamma
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+
+# log1p
+Test "log1p (-0.25) == -0.287682072451780927439219005993827432":
+float: 1
+ifloat: 1
+
+# sincos
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/6, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res":
+float: 1
+ifloat: 1
+
+# tan
+Test "tan (pi/4) == 1":
+double: 1
+idouble: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y0
+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y0 (2.0) == 0.510375672649745119596606592727157873":
+double: 1
+idouble: 1
+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y1
+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "y1 (1.5) == -0.412308626973911295952829820633445323":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# yn
+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (0, 2.0) == 0.510375672649745119596606592727157873":
+double: 1
+idouble: 1
+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "yn (1, 1.5) == -0.412308626973911295952829820633445323":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "yn (10, 0.125) == -127057845771019398.252538486899753195":
+double: 1
+idouble: 1
+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "yn (10, 1.0) == -121618014.278689189288130426667971145":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (10, 2.0) == -129184.542208039282635913145923304214":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
+double: 1
+idouble: 1
+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 10.0) == -0.251362657183837329779204747654240998":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: "atan2":
+float: 6
+ifloat: 6
+
+Function: "atanh":
+float: 1
+ifloat: 1
+
+Function: Real part of "cacosh":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+
+Function: Real part of "catan":
+float: 4
+ifloat: 4
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catanh":
+double: 4
+idouble: 4
+
+Function: Imaginary part of "catanh":
+float: 6
+ifloat: 6
+
+Function: "cbrt":
+double: 1
+idouble: 1
+
+Function: Real part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccos":
+float: 1
+ifloat: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccosh":
+float: 1
+ifloat: 1
+
+Function: Real part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Real part of "clog":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "clog":
+float: 3
+ifloat: 3
+
+Function: Real part of "clog10":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Real part of "cpow":
+double: 2
+float: 4
+idouble: 2
+ifloat: 4
+
+Function: Imaginary part of "cpow":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csqrt":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctan":
+double: 1
+idouble: 1
+
+Function: Imaginary part of "ctan":
+double: 1
+idouble: 1
+
+Function: Real part of "ctanh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Imaginary part of "ctanh":
+float: 1
+ifloat: 1
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "exp10":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+Function: "expm1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "j0":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "jn":
+double: 4
+float: 4
+idouble: 4
+ifloat: 4
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log10":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log1p":
+float: 1
+ifloat: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+# end of automatic generation
Index: trunk/src/libctests/glibc/sysdeps/sh/sh4/fpu/ftestexcept.c
===================================================================
--- trunk/src/libctests/glibc/sysdeps/sh/sh4/fpu/ftestexcept.c	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/sh/sh4/fpu/ftestexcept.c	(revision 2036)
@@ -0,0 +1,32 @@
+/* Test exception in current environment.
+   Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+fetestexcept (int excepts)
+{
+  fexcept_t temp;
+
+  /* Get current exceptions.  */
+  _FPU_GETCW (temp);
+
+  return temp & excepts & FE_ALL_EXCEPT;
+}
Index: trunk/src/libctests/glibc/sysdeps/sh/sh4/fpu/libm-test-ulps
===================================================================
--- trunk/src/libctests/glibc/sysdeps/sh/sh4/fpu/libm-test-ulps	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/sh/sh4/fpu/libm-test-ulps	(revision 2036)
@@ -0,0 +1,1094 @@
+# Begin of automatic generation
+
+# asin
+Test "asin (-0.5) == -pi/6":
+float: 2
+ifloat: 2
+Test "asin (0.5) == pi/6":
+float: 2
+ifloat: 2
+Test "asin (0.7) == 0.7753974966107530637":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# atan2
+Test "atan2 (0.7, -1.0) == 2.530866689200584621918884506789267":
+float: 3
+ifloat: 3
+Test "atan2 (-0.7, -1.0) == -2.530866689200584621918884506789267":
+float: 3
+ifloat: 3
+Test "atan2 (1.4, -0.93) == 2.1571487668237843754887415992772736":
+float: 4
+ifloat: 4
+
+# atanh
+Test "atanh (0.7) == 0.8673005276940531944":
+double: 1
+idouble: 1
+
+# cabs
+Test "cabs (-0.7 + 12.4 i) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "cabs (-0.7 - 12.4 i) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "cabs (-12.4 + 0.7 i) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "cabs (-12.4 - 0.7 i) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "cabs (0.7 + 1.2 i) == 1.3892443989449804508432547041028554":
+double: 1
+idouble: 1
+Test "cabs (0.7 + 12.4 i) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# cacos
+Test "Real part of: cacos (0.7 + 1.2 i) == 1.1351827477151551088992008271819053 - 1.0927647857577371459105272080819308 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0.7 + 1.2 i) == 1.1351827477151551088992008271819053 - 1.0927647857577371459105272080819308 i":
+float: 1
+ifloat: 1
+
+# cacosh
+Test "Real part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+Test "Imaginary part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+Test "Real part of: cacosh (0.7 + 1.2 i) == 1.0927647857577371459105272080819308 + 1.1351827477151551088992008271819053 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# casin
+Test "Real part of: casin (0.7 + 1.2 i) == 0.4356135790797415103321208644578462 + 1.0927647857577371459105272080819308 i":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+Test "Imaginary part of: casin (0.7 + 1.2 i) == 0.4356135790797415103321208644578462 + 1.0927647857577371459105272080819308 i":
+float: 1
+ifloat: 1
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+Test "Real part of: casinh (0.7 + 1.2 i) == 0.97865459559367387689317593222160964 + 0.91135418953156011567903546856170941 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (0.7 + 1.2 i) == 0.97865459559367387689317593222160964 + 0.91135418953156011567903546856170941 i":
+float: 1
+ifloat: 1
+
+# catan
+Test "Real part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+float: 3
+ifloat: 3
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: catan (0.7 + 1.2 i) == 1.0785743834118921877443707996386368 + 0.57705737765343067644394541889341712 i":
+float: 4
+ifloat: 4
+Test "Imaginary part of: catan (0.7 + 1.2 i) == 1.0785743834118921877443707996386368 + 0.57705737765343067644394541889341712 i":
+double: 1
+idouble: 1
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 4
+idouble: 4
+Test "Imaginary part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+float: 4
+ifloat: 4
+Test "Real part of: catanh (0.7 + 1.2 i) == 0.2600749516525135959200648705635915 + 0.97024030779509898497385130162655963 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (0.7 + 1.2 i) == 0.2600749516525135959200648705635915 + 0.97024030779509898497385130162655963 i":
+double: 1
+float: 6
+idouble: 1
+ifloat: 6
+
+# cbrt
+Test "cbrt (-27.0) == -3.0":
+double: 1
+idouble: 1
+Test "cbrt (0.970299) == 0.99":
+double: 1
+idouble: 1
+
+# ccos
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccos (0.7 + 1.2 i) == 1.3848657645312111080 - 0.97242170335830028619 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: ccos (0.7 + 1.2 i) == 1.3848657645312111080 - 0.97242170335830028619 i":
+double: 1
+idouble: 1
+
+# ccosh
+Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccosh (0.7 + 1.2 i) == 0.4548202223691477654 + 0.7070296600921537682 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.7 + 1.2 i) == 0.4548202223691477654 + 0.7070296600921537682 i":
+double: 1
+idouble: 1
+
+# cexp
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+Test "Real part of: cexp (0.7 + 1.2 i) == 0.7296989091503236012 + 1.8768962328348102821 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cexp (0.7 + 1.2 i) == 0.7296989091503236012 + 1.8768962328348102821 i":
+float: 1
+ifloat: 1
+
+# clog
+Test "Imaginary part of: clog (-2 - 3 i) == 1.2824746787307683680267437207826593 - 2.1587989303424641704769327722648368 i":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Real part of: clog10 (0.7 + 1.2 i) == 0.1427786545038868803 + 0.4528483579352493248 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0.7 + 1.2 i) == 0.1427786545038868803 + 0.4528483579352493248 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+float: 1
+ifloat: 1
+
+# cos
+Test "cos (0.7) == 0.7648421872844884262":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+float: 0.5
+idouble: 1
+ifloat: 0.5
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "cos (pi/2) == 0":
+double: 0.2758
+float: 0.3667
+idouble: 0.2758
+ifloat: 0.3667
+
+# cpow
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 1.1031
+float: 1.5
+idouble: 1.1031
+ifloat: 1.5
+
+# csin
+Test "Imaginary part of: csin (0.7 + 1.2 i) == 1.1664563419657581376 + 1.1544997246948547371 i":
+float: 1
+ifloat: 1
+
+# csinh
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+Test "Real part of: csinh (0.7 + 1.2 i) == 0.27487868678117583582 + 1.1698665727426565139 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (0.7 + 1.2 i) == 0.27487868678117583582 + 1.1698665727426565139 i":
+float: 1
+ifloat: 1
+
+# csqrt
+Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (0.7 + 1.2 i) == 1.022067610030026450706487883081139 + 0.58704531296356521154977678719838035 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: csqrt (0.7 + 1.2 i) == 1.022067610030026450706487883081139 + 0.58704531296356521154977678719838035 i":
+float: 1
+ifloat: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+double: 1
+idouble: 1
+Test "Real part of: ctan (0.7 + 1.2 i) == 0.1720734197630349001 + 0.9544807059989405538 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ctan (0.7 + 1.2 i) == 0.1720734197630349001 + 0.9544807059989405538 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+float: 1
+ifloat: 1
+Test "Real part of: ctanh (0.7 + 1.2 i) == 1.3472197399061191630 + 0.4778641038326365540 i":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "Imaginary part of: ctanh (0.7 + 1.2 i) == 1.3472197399061191630 + 0.4778641038326365540 i":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+# erfc
+Test "erfc (0.7) == 0.32219880616258152702":
+double: 1
+idouble: 1
+Test "erfc (1.2) == 0.089686021770364619762":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+Test "erfc (2.0) == 0.0046777349810472658379":
+double: 1
+idouble: 1
+Test "erfc (4.1) == 0.67000276540848983727e-8":
+double: 24
+float: 12
+idouble: 24
+ifloat: 12
+
+# exp10
+Test "exp10 (-1) == 0.1":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "exp10 (0.7) == 5.0118723362727228500":
+float: 1
+ifloat: 1
+Test "exp10 (3) == 1000":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+# expm1
+Test "expm1 (1) == M_El - 1.0":
+float: 1
+ifloat: 1
+
+# fmod
+Test "fmod (-6.5, -2.3) == -1.9":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "fmod (-6.5, 2.3) == -1.9":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "fmod (6.5, -2.3) == 1.9":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "fmod (6.5, 2.3) == 1.9":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 1.2) == 1.3892443989449804508432547041028554":
+double: 1
+idouble: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (10.0) == -0.24593576445134833520":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "j0 (2.0) == 0.22389077914123566805":
+float: 2
+ifloat: 2
+Test "j0 (8.0) == 0.17165080713755390609":
+float: 1
+ifloat: 1
+
+# j1
+Test "j1 (10.0) == 0.043472746168861436670":
+float: 2
+ifloat: 2
+Test "j1 (2.0) == 0.57672480775687338720":
+double: 1
+idouble: 1
+Test "j1 (8.0) == 0.23463634685391462438":
+double: 1
+idouble: 1
+
+# jn
+Test "jn (0, 10.0) == -0.24593576445134833520":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "jn (0, 2.0) == 0.22389077914123566805":
+float: 2
+ifloat: 2
+Test "jn (0, 8.0) == 0.17165080713755390609":
+float: 1
+ifloat: 1
+Test "jn (1, 10.0) == 0.043472746168861436670":
+float: 2
+ifloat: 2
+Test "jn (1, 2.0) == 0.57672480775687338720":
+double: 1
+idouble: 1
+Test "jn (1, 8.0) == 0.23463634685391462438":
+double: 1
+idouble: 1
+Test "jn (10, 0.1) == 0.26905328954342155795e-19":
+double: 6
+float: 4
+idouble: 6
+ifloat: 4
+Test "jn (10, 0.7) == 0.75175911502153953928e-11":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "jn (10, 10.0) == 0.20748610663335885770":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+Test "jn (10, 2.0) == 0.25153862827167367096e-6":
+float: 4
+ifloat: 4
+Test "jn (3, 0.1) == 0.000020820315754756261429":
+double: 1
+idouble: 1
+Test "jn (3, 0.7) == 0.0069296548267508408077":
+float: 1
+ifloat: 1
+Test "jn (3, 10.0) == 0.058379379305186812343":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "jn (3, 2.0) == 0.12894324947440205110":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# lgamma
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# log
+Test "log (0.7) == -0.35667494393873237891263871124118447":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# log10
+Test "log10 (0.7) == -0.15490195998574316929":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+
+# log1p
+Test "log1p (-0.3) == -0.35667494393873237891263871124118447":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# log2
+Test "log2 (0.7) == -0.51457317282975824043":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# sincos
+Test "sincos (0.7, &sin_res, &cos_res) puts 0.76484218728448842626 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+float: 0.5
+idouble: 1
+ifloat: 0.5
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.866025403784438646764 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
+double: 0.2758
+float: 0.3667
+idouble: 0.2758
+ifloat: 0.3667
+Test "sincos (pi/6, &sin_res, &cos_res) puts 0.866025403784438646764 in cos_res":
+float: 1
+ifloat: 1
+
+# sinh
+Test "sinh (0.7) == 0.75858370183953350346":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# tan
+Test "tan (pi/4) == 1":
+double: 0.5
+idouble: 0.5
+
+# tanh
+Test "tanh (0.7) == 0.60436777711716349631":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y0
+Test "y0 (0.7) == -0.19066492933739506743":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (1.0) == 0.088256964215676957983":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (1.5) == 0.38244892379775884396":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0) == 0.055671167283599391424":
+float: 1
+ifloat: 1
+Test "y0 (8.0) == 0.22352148938756622053":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y1
+Test "y1 (0.1) == -6.4589510947020269877":
+double: 1
+idouble: 1
+Test "y1 (0.7) == -1.1032498719076333697":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y1 (1.5) == -0.41230862697391129595":
+float: 1
+ifloat: 1
+Test "y1 (10.0) == 0.24901542420695388392":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "y1 (2.0) == -0.10703243154093754689":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y1 (8.0) == -0.15806046173124749426":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# yn
+Test "yn (0, 0.7) == -0.19066492933739506743":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 1.0) == 0.088256964215676957983":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 1.5) == 0.38244892379775884396":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0) == 0.055671167283599391424":
+float: 1
+ifloat: 1
+Test "yn (0, 8.0) == 0.22352148938756622053":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 0.1) == -6.4589510947020269877":
+double: 1
+idouble: 1
+Test "yn (1, 0.7) == -1.1032498719076333697":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 1.5) == -0.41230862697391129595":
+float: 1
+ifloat: 1
+Test "yn (1, 10.0) == 0.24901542420695388392":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (1, 2.0) == -0.10703243154093754689":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 8.0) == -0.15806046173124749426":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "yn (10, 0.1) == -0.11831335132045197885e19":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+Test "yn (10, 0.7) == -0.42447194260703866924e10":
+double: 3
+idouble: 3
+Test "yn (10, 1.0) == -0.12161801427868918929e9":
+double: 1
+idouble: 1
+Test "yn (10, 10.0) == -0.35981415218340272205":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (10, 2.0) == -129184.54220803928264":
+double: 2
+idouble: 2
+Test "yn (3, 0.1) == -5099.3323786129048894":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 0.7) == -15.819479052819633505":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (3, 10.0) == -0.25136265718383732978":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 2.0) == -1.1277837768404277861":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: "asin":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "atan2":
+float: 4
+ifloat: 4
+
+Function: "atanh":
+double: 1
+idouble: 1
+
+Function: "cabs":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "cacos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "cacos":
+float: 1
+ifloat: 1
+
+Function: Real part of "cacosh":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+Function: Real part of "casin":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+Function: Imaginary part of "casin":
+float: 1
+ifloat: 1
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+
+Function: Real part of "catan":
+float: 4
+ifloat: 4
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catanh":
+double: 4
+float: 1
+idouble: 4
+ifloat: 1
+
+Function: Imaginary part of "catanh":
+double: 1
+float: 6
+idouble: 1
+ifloat: 6
+
+Function: "cbrt":
+double: 1
+idouble: 1
+
+Function: Real part of "ccos":
+double: 1
+idouble: 1
+
+Function: Imaginary part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "cexp":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "clog":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+Function: Real part of "clog10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Real part of "cpow":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+
+Function: Imaginary part of "cpow":
+double: 1.1031
+float: 2
+idouble: 1.1031
+ifloat: 2
+
+Function: Imaginary part of "csin":
+float: 1
+ifloat: 1
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csqrt":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "csqrt":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ctan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "ctanh":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: Imaginary part of "ctanh":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "erfc":
+double: 24
+float: 12
+idouble: 24
+ifloat: 12
+
+Function: "exp10":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+Function: "expm1":
+float: 1
+ifloat: 1
+
+Function: "fmod":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "hypot":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "j0":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "jn":
+double: 6
+float: 4
+idouble: 6
+ifloat: 4
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "log10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "log1p":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "log2":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "sinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "tan":
+double: 0.5
+idouble: 0.5
+
+Function: "tanh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+# end of automatic generation
Index: trunk/src/libctests/glibc/sysdeps/sparc/fpu/ftestexcept.c
===================================================================
--- trunk/src/libctests/glibc/sysdeps/sparc/fpu/ftestexcept.c	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/sparc/fpu/ftestexcept.c	(revision 2036)
@@ -0,0 +1,30 @@
+/* Test exception in current environment.
+   Copyright (C) 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <fenv.h>
+
+int
+fetestexcept (int excepts)
+{
+  fenv_t tmp;
+
+  __fenv_stfsr (tmp);
+
+  return tmp & excepts & FE_ALL_EXCEPT;
+}
Index: trunk/src/libctests/glibc/sysdeps/sparc/sparc32/fpu/libm-test-ulps
===================================================================
--- trunk/src/libctests/glibc/sysdeps/sparc/sparc32/fpu/libm-test-ulps	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/sparc/sparc32/fpu/libm-test-ulps	(revision 2036)
@@ -0,0 +1,893 @@
+# Begin of automatic generation
+
+# atan2
+Test "atan2 (-0.75, -1.0) == -2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+Test "atan2 (0.75, -1.0) == 2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+Test "atan2 (1.390625, 0.9296875) == 0.981498387184244311516296577615519772":
+float: 1
+ifloat: 1
+Test "atan2 (-0.00756827042671106339, -.001792735857538728036) == -1.80338464113663849327153994379639112":
+float: 6
+ifloat: 6
+
+# atanh
+Test "atanh (0.75) == 0.972955074527656652552676371721589865":
+float: 1
+ifloat: 1
+
+# cacosh
+Test "Real part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+Test "Imaginary part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+# casin
+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# catan
+Test "Real part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+float: 3
+ifloat: 3
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i":
+float: 4
+ifloat: 4
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 4
+idouble: 4
+Test "Imaginary part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+float: 4
+ifloat: 4
+Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+float: 6
+ifloat: 6
+
+# cbrt
+Test "cbrt (-27.0) == -3.0":
+double: 1
+idouble: 1
+Test "cbrt (0.75) == 0.908560296416069829445605878163630251":
+double: 1
+idouble: 1
+Test "cbrt (0.9921875) == 0.997389022060725270579075195353955217":
+double: 1
+idouble: 1
+
+# ccos
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+float: 1
+ifloat: 1
+
+# ccosh
+Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+
+# cexp
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+float: 1
+ifloat: 1
+
+# clog
+Test "Imaginary part of: clog (-2 - 3 i) == 1.2824746787307683680267437207826593 - 2.1587989303424641704769327722648368 i":
+float: 3
+ifloat: 3
+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+float: 1
+ifloat: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+float: 1
+ifloat: 1
+
+# cos
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "cos (pi/2) == 0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+# csinh
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+
+# csqrt
+Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+double: 1
+idouble: 1
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+float: 1
+ifloat: 1
+Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+idouble: 1
+
+# erf
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (2.0) == 0.00467773498104726583793074363274707139":
+double: 1
+idouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+
+# exp10
+Test "exp10 (-1) == 0.1":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "exp10 (3) == 1000":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+# expm1
+Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
+double: 1
+idouble: 1
+Test "expm1 (1) == M_El - 1.0":
+float: 1
+ifloat: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "j0 (2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+
+# j1
+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+
+# jn
+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "jn (0, 2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
+float: 4
+ifloat: 4
+Test "jn (3, 0.125) == 0.406503832554912875023029337653442868e-4":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# lgamma
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+
+# log1p
+Test "log1p (-0.25) == -0.287682072451780927439219005993827432":
+float: 1
+ifloat: 1
+
+# sincos
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/6, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res":
+float: 1
+ifloat: 1
+
+# tan
+Test "tan (pi/4) == 1":
+double: 1
+idouble: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y0
+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y1
+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "y1 (1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# yn
+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "yn (1, 1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "yn (10, 0.125) == -127057845771019398.252538486899753195":
+double: 1
+idouble: 1
+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (10, 1.0) == -121618014.278689189288130426667971145":
+double: 1
+idouble: 1
+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (10, 2.0) == -129184.542208039282635913145923304214":
+double: 2
+idouble: 2
+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
+double: 1
+idouble: 1
+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 10.0) == -0.251362657183837329779204747654240998":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: "atan2":
+float: 6
+ifloat: 6
+
+Function: "atanh":
+float: 1
+ifloat: 1
+
+Function: Real part of "cacosh":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+
+Function: Real part of "catan":
+float: 4
+ifloat: 4
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catanh":
+double: 4
+idouble: 4
+
+Function: Imaginary part of "catanh":
+float: 6
+ifloat: 6
+
+Function: "cbrt":
+double: 1
+idouble: 1
+
+Function: Real part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccos":
+float: 1
+ifloat: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccosh":
+float: 1
+ifloat: 1
+
+Function: Real part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Real part of "clog":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "clog":
+float: 3
+ifloat: 3
+
+Function: Real part of "clog10":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Real part of "cpow":
+double: 2
+float: 4
+idouble: 2
+ifloat: 4
+
+Function: Imaginary part of "cpow":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csqrt":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctan":
+double: 1
+idouble: 1
+
+Function: Imaginary part of "ctan":
+double: 1
+idouble: 1
+
+Function: Real part of "ctanh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Imaginary part of "ctanh":
+float: 1
+ifloat: 1
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+idouble: 1
+
+Function: "exp10":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+Function: "expm1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "j0":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "jn":
+double: 4
+float: 4
+idouble: 4
+ifloat: 4
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log10":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log1p":
+float: 1
+ifloat: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+# end of automatic generation
Index: trunk/src/libctests/glibc/sysdeps/sparc/sparc64/fpu/libm-test-ulps
===================================================================
--- trunk/src/libctests/glibc/sysdeps/sparc/sparc64/fpu/libm-test-ulps	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/sparc/sparc64/fpu/libm-test-ulps	(revision 2036)
@@ -0,0 +1,1313 @@
+# Begin of automatic generation
+
+# atan2
+Test "atan2 (-0.00756827042671106339, -.001792735857538728036) == -1.80338464113663849327153994379639112":
+float: 6
+ifloat: 6
+ildouble: 1
+ldouble: 1
+Test "atan2 (-0.75, -1.0) == -2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+ildouble: 1
+ldouble: 1
+Test "atan2 (0.75, -1.0) == 2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+ildouble: 1
+ldouble: 1
+Test "atan2 (1.390625, 0.9296875) == 0.981498387184244311516296577615519772":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# atanh
+Test "atanh (0.75) == 0.972955074527656652552676371721589865":
+float: 1
+ifloat: 1
+
+# cacos
+Test "Imaginary part of: cacos (0.75 + 1.25 i) == 1.11752014915610270578240049553777969 - 1.13239363160530819522266333696834467 i":
+ildouble: 1
+ldouble: 1
+
+# cacosh
+Test "Real part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+ildouble: 5
+ldouble: 5
+Test "Imaginary part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+ildouble: 1
+ldouble: 1
+
+# casin
+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+ildouble: 1
+ldouble: 1
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+ildouble: 4
+ldouble: 4
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 2
+ldouble: 2
+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# catan
+Test "Real part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+float: 3
+ifloat: 3
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i":
+float: 4
+ifloat: 4
+Test "Imaginary part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i":
+ildouble: 1
+ldouble: 1
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 4
+idouble: 4
+Test "Imaginary part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+float: 4
+ifloat: 4
+Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+float: 6
+ifloat: 6
+ildouble: 1
+ldouble: 1
+
+# cbrt
+Test "cbrt (-0.001) == -0.1":
+ildouble: 1
+ldouble: 1
+Test "cbrt (-27.0) == -3.0":
+double: 1
+idouble: 1
+Test "cbrt (0.75) == 0.908560296416069829445605878163630251":
+double: 1
+idouble: 1
+Test "cbrt (0.9921875) == 0.997389022060725270579075195353955217":
+double: 1
+idouble: 1
+
+# ccos
+Test "Real part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+float: 1
+ifloat: 1
+
+# ccosh
+Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+
+# cexp
+Test "Real part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+ildouble: 1
+ldouble: 1
+
+# clog
+Test "Imaginary part of: clog (-2 - 3 i) == 1.2824746787307683680267437207826593 - 2.1587989303424641704769327722648368 i":
+float: 3
+ifloat: 3
+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + inf i) == inf + 3/4 pi*log10(e) i":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cos
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "cos (pi/2) == 0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+ildouble: 4
+ldouble: 4
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i":
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+ildouble: 10
+ldouble: 10
+Test "Real part of: cpow (2 + 0 i, 10 + 0 i) == 1024.0 + 0.0 i":
+ildouble: 2
+ldouble: 2
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+ildouble: 3
+ldouble: 3
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# csin
+Test "Imaginary part of: csin (-2 - 3 i) == -9.15449914691142957346729954460983256 + 4.16890695996656435075481305885375484 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i":
+ildouble: 1
+ldouble: 1
+
+# csinh
+Test "Real part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+
+# csqrt
+Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csqrt (0.75 + 1.25 i) == 1.05065169626078392338656675760808326 + 0.594868882070379067881984030639932657 i":
+ildouble: 1
+ldouble: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+float: 1
+ifloat: 1
+Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+idouble: 1
+
+# erf
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (2.0) == 0.00467773498104726583793074363274707139":
+double: 1
+idouble: 1
+Test "erfc (27.0) == 0.523704892378925568501606768284954709e-318":
+ildouble: 1
+ldouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+
+# exp10
+Test "exp10 (-1) == 0.1":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "exp10 (3) == 1000":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# expm1
+Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
+double: 1
+idouble: 1
+Test "expm1 (1) == M_El - 1.0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# gamma
+Test "gamma (-0.5) == log(2*sqrt(pi))":
+ildouble: 1
+ldouble: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "j0 (2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# j1
+Test "j1 (-1.0) == -0.440050585744933515959682203718914913":
+ildouble: 1
+ldouble: 1
+Test "j1 (0.75) == 0.349243602174862192523281016426251335":
+ildouble: 1
+ldouble: 1
+Test "j1 (1.0) == 0.440050585744933515959682203718914913":
+ildouble: 1
+ldouble: 1
+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+ildouble: 4
+ldouble: 4
+
+# jn
+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "jn (0, 2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (1, -1.0) == -0.440050585744933515959682203718914913":
+ildouble: 1
+ldouble: 1
+Test "jn (1, 0.75) == 0.349243602174862192523281016426251335":
+ildouble: 1
+ldouble: 1
+Test "jn (1, 1.0) == 0.440050585744933515959682203718914913":
+ildouble: 1
+ldouble: 1
+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+ildouble: 4
+ldouble: 4
+Test "jn (10, -1.0) == 0.263061512368745320699785368779050294e-9":
+ildouble: 1
+ldouble: 1
+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (10, 1.0) == 0.263061512368745320699785368779050294e-9":
+ildouble: 1
+ldouble: 1
+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+ildouble: 2
+ldouble: 2
+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
+float: 4
+ifloat: 4
+Test "jn (3, 0.125) == 0.406503832554912875023029337653442868e-4":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# lgamma
+Test "lgamma (-0.5) == log(2*sqrt(pi))":
+ildouble: 1
+ldouble: 1
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# log1p
+Test "log1p (-0.25) == -0.287682072451780927439219005993827432":
+float: 1
+ifloat: 1
+Test "log1p (M_El - 1.0) == 1":
+ildouble: 1
+ldouble: 1
+
+# log2
+Test "log2 (0.75) == -.415037499278843818546261056052183492":
+ildouble: 1
+ldouble: 1
+
+# sincos
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "sincos (pi/6, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res":
+float: 1
+ifloat: 1
+
+# sqrt
+Test "sqrt (2) == M_SQRT2l":
+ildouble: 1
+ldouble: 1
+
+# tan
+Test "tan (pi/4) == 1":
+double: 1
+idouble: 1
+
+# tanh
+Test "tanh (-0.75) == -0.635148952387287319214434357312496495":
+ildouble: 1
+ldouble: 1
+Test "tanh (-1.0) == -0.7615941559557648881194582826047935904":
+ildouble: 1
+ldouble: 1
+Test "tanh (0.75) == 0.635148952387287319214434357312496495":
+ildouble: 1
+ldouble: 1
+Test "tanh (1.0) == 0.7615941559557648881194582826047935904":
+ildouble: 1
+ldouble: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (4) == 6":
+ildouble: 1
+ldouble: 1
+
+# y0
+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+
+# y1
+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "y1 (0.75) == -1.03759455076928541973767132140642198":
+ildouble: 1
+ldouble: 1
+Test "y1 (1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# yn
+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "yn (1, 0.75) == -1.03759455076928541973767132140642198":
+ildouble: 1
+ldouble: 1
+Test "yn (1, 1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "yn (10, 0.125) == -127057845771019398.252538486899753195":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 5
+ldouble: 5
+Test "yn (10, 1.0) == -121618014.278689189288130426667971145":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (10, 2.0) == -129184.542208039282635913145923304214":
+double: 2
+idouble: 2
+ildouble: 2
+ldouble: 2
+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
+double: 1
+idouble: 1
+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (3, 10.0) == -0.251362657183837329779204747654240998":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: "atan2":
+float: 6
+ifloat: 6
+ildouble: 1
+ldouble: 1
+
+Function: "atanh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "cacos":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cacosh":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+ildouble: 5
+ldouble: 5
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "casin":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+ildouble: 4
+ldouble: 4
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "catan":
+float: 4
+ifloat: 4
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "catanh":
+double: 4
+idouble: 4
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "catanh":
+float: 6
+ifloat: 6
+ildouble: 1
+ldouble: 1
+
+Function: "cbrt":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ccos":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ccosh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cexp":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "cexp":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "clog":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "clog":
+float: 3
+ifloat: 3
+
+Function: Real part of "clog10":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+ildouble: 1
+ldouble: 1
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cpow":
+double: 2
+float: 4
+idouble: 2
+ifloat: 4
+ildouble: 10
+ldouble: 10
+
+Function: Imaginary part of "cpow":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "csin":
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csin":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csqrt":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csqrt":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ctan":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ctan":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "ctanh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ctanh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: "exp10":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "expm1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "gamma":
+ildouble: 1
+ldouble: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "j0":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 4
+ldouble: 4
+
+Function: "jn":
+double: 4
+float: 4
+idouble: 4
+ifloat: 4
+ildouble: 4
+ldouble: 4
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "log10":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "log1p":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "log2":
+ildouble: 1
+ldouble: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "sqrt":
+ildouble: 1
+ldouble: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tanh":
+ildouble: 1
+ldouble: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 3
+ldouble: 3
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 5
+ldouble: 5
+
+# end of automatic generation
Index: trunk/src/libctests/glibc/sysdeps/unix/sysv/linux/Makefile
===================================================================
--- trunk/src/libctests/glibc/sysdeps/unix/sysv/linux/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/unix/sysv/linux/Makefile	(revision 2036)
@@ -0,0 +1,157 @@
+ifeq ($(subdir),csu)
+sysdep_routines += errno-loc
+endif
+
+ifeq ($(subdir),assert)
+CFLAGS-assert.c += -DFATAL_PREPARE_INCLUDE='<fatal-prepare.h>'
+CFLAGS-assert-perr.c += -DFATAL_PREPARE_INCLUDE='<fatal-prepare.h>'
+endif
+
+ifeq ($(subdir),malloc)
+CFLAGS-malloc.c += -DMORECORE_CLEARS=2
+endif
+
+ifeq ($(subdir),misc)
+sysdep_routines += sysctl clone llseek umount umount2 readahead \
+		   setfsuid setfsgid makedev
+
+CFLAGS-gethostid.c = -fexceptions
+
+sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \
+		  sys/klog.h sys/kdaemon.h \
+		  sys/user.h sys/procfs.h sys/prctl.h \
+		  sys/kd.h sys/soundcard.h sys/vt.h \
+		  sys/quota.h sys/fsuid.h \
+		  scsi/sg.h scsi/scsi.h scsi/scsi_ioctl.h sys/pci.h \
+		  sys/ultrasound.h sys/raw.h sys/personality.h sys/epoll.h \
+		  bits/a.out.h
+
+install-others += $(inst_includedir)/bits/syscall.h
+
+# Generate the list of SYS_* macros for the system calls (__NR_* macros).
+# For bi-arch platforms, the CPU/Makefile defines {32,64}bit-predefine and
+# we generate a file that uses <bits/wordsize.h>.
+$(objpfx)syscall-%.h $(objpfx)syscall-%.d: ../sysdeps/unix/sysv/linux/sys/syscall.h
+	$(make-target-directory)
+	{ \
+	 echo '/* Generated at libc build time from kernel syscall list.  */';\
+	 echo ''; \
+	 echo '#ifndef _SYSCALL_H'; \
+	 echo '# error "Never use <bits/syscall.h> directly; include <sys/syscall.h> instead."'; \
+	 echo '#endif'; \
+	 echo ''; \
+	 $(CC) -E -MD -MP -MF $(@:.h=.d)-t1 -MT '$(@:.d=.h) $(@:.h=.d)' \
+	       -x c $(sysincludes) $< $(addprefix -U,$(64bit-predefine)) \
+	       $(addprefix -D,$(32bit-predefine)) -D_LIBC -dM | \
+	 sed -n 's@^#define __NR_\([^ ]*\) .*$$@#define SYS_\1 __NR_\1@p' | \
+	 LC_ALL=C sort > $(@:.d=.h).new32; \
+	 $(CC) -E -MD -MP -MF $(@:.h=.d)-t2 -MT '$(@:.d=.h) $(@:.h=.d)' \
+	       -x c $(sysincludes) $< $(addprefix -U,$(32bit-predefine)) \
+	       $(addprefix -D,$(64bit-predefine)) -D_LIBC -dM | \
+	 sed -n 's@^#define __NR_\([^ ]*\) .*$$@#define SYS_\1 __NR_\1@p' | \
+	 LC_ALL=C sort > $(@:.d=.h).new64; \
+	 if cmp -s $(@:.d=.h).new32 $(@:.d=.h).new64; then \
+	   cat $(@:.d=.h).new32; \
+	 else \
+	   echo '#include <bits/wordsize.h>'; \
+	   echo ''; \
+	   LC_ALL=C comm -12 $(@:.d=.h).new32 $(@:.d=.h).new64; \
+	   echo '#if __WORDSIZE == 64'; \
+	   LC_ALL=C comm -13 $(@:.d=.h).new32 $(@:.d=.h).new64; \
+	   echo '#else'; \
+	   LC_ALL=C comm -23 $(@:.d=.h).new32 $(@:.d=.h).new64; \
+	   echo '#endif'; \
+	 fi; \
+	 rm -f $(@:.d=.h).new32 $(@:.d=.h).new64; \
+	} > $(@:.d=.h).new
+	mv -f $(@:.d=.h).new $(@:.d=.h)
+ifneq (,$(objpfx))
+	sed $(sed-remove-objpfx) $(@:.h=.d)-t1 $(@:.h=.d)-t2 > $(@:.h=.d)-t3
+else
+	cat $(@:.h=.d)-t1 $(@:.h=.d)-t2 > $(@:.h=.d)-t3
+endif
+	rm -f $(@:.h=.d)-t1 $(@:.h=.d)-t2
+	mv -f $(@:.h=.d)-t3 $(@:.h=.d)
+
+$(inst_includedir)/bits/syscall.h: $(objpfx)syscall-list.h $(+force)
+	$(make-target-directory)
+	if test -r $@ && cmp -s $< $@; \
+        then echo 'bits/syscall.h unchanged'; \
+        else $(INSTALL_DATA) $< $@; fi
+
+ifndef no_deps
+# Get the generated list of dependencies (probably /usr/include/asm/unistd.h).
+-include $(objpfx)syscall-list.d
+endif
+generated += syscall-list.h syscall-list.d
+endif
+
+ifeq ($(subdir),time)
+sysdep_headers += sys/timex.h
+
+sysdep_routines += ntp_gettime
+endif
+
+ifeq ($(subdir),socket)
+sysdep_headers += net/if_ppp.h net/ppp-comp.h \
+		  net/ppp_defs.h net/if_arp.h net/route.h net/ethernet.h \
+		  net/if_slip.h net/if_packet.h net/if_shaper.h
+sysdep_routines += cmsg_nxthdr sa_len
+endif
+
+ifeq ($(subdir),sunrpc)
+sysdep_headers += nfs/nfs.h
+endif
+
+ifeq ($(subdir),termios)
+sysdep_headers += termio.h
+endif
+
+ifeq ($(subdir),stdio-common)
+# Just disable the auto generation in sysdeps/generic
+inhibit-siglist := yes
+endif
+
+ifeq ($(subdir),posix)
+sysdep_headers += bits/initspin.h
+
+sysdep_routines += exit-thread
+endif
+
+ifeq ($(subdir),inet)
+sysdep_headers += netinet/if_fddi.h netinet/if_tr.h \
+		  netipx/ipx.h netash/ash.h netax25/ax25.h netatalk/at.h \
+		  netrom/netrom.h netpacket/packet.h netrose/rose.h \
+		  neteconet/ec.h
+endif
+
+# Don't compile the ctype glue code, since there is no old non-GNU C library.
+inhibit-glue = yes
+
+ifeq ($(subdir),dirent)
+sysdep_routines += getdirentries getdirentries64
+endif
+
+ifeq ($(subdir),nis)
+CFLAGS-ypclnt.c = -DUSE_BINDINGDIR=1
+endif
+
+ifeq ($(subdir),io)
+sysdep_routines += xstatconv internal_statvfs internal_statvfs64
+endif
+
+ifeq ($(subdir),elf)
+sysdep-rtld-routines += dl-brk dl-sbrk
+
+CPPFLAGS-lddlibc4 += -DNOT_IN_libc
+endif
+
+ifeq ($(subdir),rt)
+CFLAGS-mq_send.c += -fexceptions
+CFLAGS-mq_receive.c += -fexceptions
+endif
+
+ifeq ($(subdir),nscd)
+CFLAGS-connections.c += -DHAVE_EPOLL
+CFLAGS-gai.c += -DNEED_NETLINK
+endif
Index: trunk/src/libctests/glibc/sysdeps/unix/sysv/linux/mips/Makefile
===================================================================
--- trunk/src/libctests/glibc/sysdeps/unix/sysv/linux/mips/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/unix/sysv/linux/mips/Makefile	(revision 2036)
@@ -0,0 +1,128 @@
+ifeq ($(subdir),signal)
+#sysdep_routines += sigsuspend
+endif
+
+ifeq ($(subdir),misc)
+sysdep_routines += cachectl cacheflush sysmips _test_and_set
+
+sysdep_headers += sys/cachectl.h sys/sysmips.h sys/tas.h
+
+no_syscall_list_h = 1
+
+# A callable macro that expands to a shell command.  Preprocess file $(1)
+# using ABI option $(2) and see which macros it defines.  Print FOO for each
+# macro of the form __NR$(3)_FOO, filtering out ABI-specific __NR macros
+# that have a prefix other than $(3).
+mips_list_syscalls =	$(filter-out -m%,$(CC)) -E -x c $(+includes) \
+			    $(sysincludes) -D_LIBC -dM -mabi=$(2) $(1) | \
+			sed -n 's@^\#define __NR$(3)_\([^ ]*\) .*@\1@p' | \
+			sed -e '/^[ON]32_/d' -e '/^N64_/d' -e '/^64_/d' | \
+			LC_ALL=C sort
+
+# Generate a list of SYS_* macros from the linux __NR macros.
+#
+# Before version 2.6, linux had separate 32-bit and 64-bit MIPS ports,
+# each with its own set of headers.  The ports were merged for 2.6 and
+# this merged port defines the syscalls in a slightly different way.
+# There are therefore three sets of headers that we need to consider:
+#
+#    (1) Headers from the separate 32-bit MIPS port.  They just define
+#	 a single list of __NR macros.
+#
+#    (2) Headers from the separate 64-bit MIPS port.  They unconditionally
+#	 define syscalls for all three ABIs, with o32 syscalls prefixed
+#	 by __NR_O32, n32 syscalls prefixed by __NR_N32 and n64 syscalls
+#	 prefixed by plain __NR.
+#
+#    (3) Headers from the combined port.  They use the _MIPS_SIM macro to
+#	 define the right set of syscalls for the current ABI.  The syscalls
+#	 themselves have no special ABI prefix, but the headers also define:
+#
+#	    __NR_O32_Linux{,_syscalls}
+#	    __NR_N32_Linux{,_syscalls}
+#	    __NR_64_Linux{,_syscalls}
+#
+# In case (1) we just want a simple list of SYS_* macros.  In cases (2)
+# and (3) we want a file that will work for all three ABIs, regardless
+# of which ABI we are currently using.  We also want the file to work
+# if the user later moves from (2) to (3).  Thus the file we create
+# for (2) and (3) has the form:
+#
+#    #if _MIPS_SIM == _ABIN32
+#    # ifdef __NR_N32_open
+#    #  define SYS_n32syscall1 __NR_N32_n32syscall1
+#    #  ...
+#    # else
+#    #  define SYS_n32syscall1 __NR_n32syscall1
+#    #  ...
+#    # endif
+#    #elif _MIPS_SIM == _ABI64
+#    # define SYS_n64syscall1 __NR_n64syscall1
+#    # ...
+#    #else
+#    # ifdef __NR_O32_open
+#    #  define SYS_o32syscall1 __NR_O32_o32syscall1
+#    #  ...
+#    # else
+#    #  define SYS_o32syscall1 __NR_o32syscall1
+#    #  ...
+#    # endif
+#    #endif
+#
+# Here, __NR_N32_open and __NR_O32_open are used to detect case (2)
+# over case (3).  The n64 SYS_* macros can always use the normal
+# ABI-less names.
+$(objpfx)syscall-%.h $(objpfx)syscall-%.d: ../sysdeps/unix/sysv/linux/mips/sys/syscall.h
+	$(make-target-directory)
+	$(CC) -E -x c $(+includes) $(sysincludes) -D_LIBC $< -MD -MP \
+	      -MF $(@:.h=.d)-t -MT '$(@:.d=.h) $(@:.h=.d)' > /dev/null
+	{ \
+	 echo '/* Generated at libc build time from kernel syscall list.  */';\
+	 echo ''; \
+	 echo '#ifndef _SYSCALL_H'; \
+	 echo '# error "Never use <bits/syscall.h> directly; include <sys/syscall.h> instead."'; \
+	 echo '#endif'; \
+	 echo ''; \
+	 echo '#include <sgidefs.h>'; \
+	 rm -f $(@:.d=.h).new32 $(@:.d=.h).newn32 $(@:.d=.h).new64; \
+	 $(call mips_list_syscalls,$<,n32,_N32) > $(@:.d=.h).newn32; \
+	 if test -s $(@:.d=.h).newn32; then \
+	   if grep open $(@:.d=.h).newn32 > /dev/null; then \
+	     $(call mips_list_syscalls,$<,32,_O32) > $(@:.d=.h).new32; \
+	     $(call mips_list_syscalls,$<,64,) > $(@:.d=.h).new64; \
+	   else \
+	     $(call mips_list_syscalls,$<,32,) > $(@:.d=.h).new32; \
+	     $(call mips_list_syscalls,$<,n32,) > $(@:.d=.h).newn32; \
+	     $(call mips_list_syscalls,$<,64,) > $(@:.d=.h).new64; \
+	   fi; \
+	   echo '#if _MIPS_SIM == _ABIN32'; \
+	   echo '# ifdef __NR_N32_open'; \
+	   sed 's@\(.*\)@#  define SYS_\1 __NR_N32_\1@' < $(@:.d=.h).newn32; \
+	   echo '# else'; \
+	   sed 's@\(.*\)@#  define SYS_\1 __NR_\1@' < $(@:.d=.h).newn32; \
+	   echo '# endif'; \
+	   echo '#elif _MIPS_SIM == _ABI64'; \
+	   sed 's@\(.*\)@# define SYS_\1 __NR_\1@' < $(@:.d=.h).new64; \
+	   echo '#else'; \
+	   echo '# ifdef __NR_O32_open'; \
+	   sed 's@\(.*\)@#  define SYS_\1 __NR_O32_\1@' < $(@:.d=.h).new32; \
+	   echo '# else'; \
+	   sed 's@\(.*\)@#  define SYS_\1 __NR_\1@' < $(@:.d=.h).new32; \
+	   echo '# endif'; \
+	   echo '#endif'; \
+	 else \
+	   $(CC) -E -x c $(+includes) $(sysincludes) -D_LIBC -dM $< | \
+	   sed -n 's@^\#define __NR_\([^ ]*\) .*@\#define SYS_\1 __NR_\1@p' | \
+	   LC_ALL=C sort; \
+	 fi; \
+	 rm -f $(@:.d=.h).new32 $(@:.d=.h).newn32 $(@:.d=.h).new64; \
+	} > $(@:.d=.h).new
+	mv -f $(@:.d=.h).new $(@:.d=.h)
+ifneq (,$(objpfx))
+	sed $(sed-remove-objpfx) $(@:.h=.d)-t > $(@:.h=.d)-t2
+	rm -f $(@:.h=.d)-t
+	mv -f $(@:.h=.d)-t2 $(@:.h=.d)
+else
+	mv -f $(@:.h=.d)-t $(@:.h=.d)
+endif
+endif
Index: trunk/src/libctests/glibc/sysdeps/unix/sysv/linux/mips/_test_and_set.c
===================================================================
--- trunk/src/libctests/glibc/sysdeps/unix/sysv/linux/mips/_test_and_set.c	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/unix/sysv/linux/mips/_test_and_set.c	(revision 2036)
@@ -0,0 +1,30 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Maciej W. Rozycki <macro@ds2.pg.gda.pl>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* Define the real-function versions of all inline functions
+   defined in sys/tas.h  */
+
+#include <features.h>
+
+#define _EXTERN_INLINE
+#ifndef __USE_EXTERN_INLINES
+# define __USE_EXTERN_INLINES 1
+#endif
+
+#include "sys/tas.h"
Index: trunk/src/libctests/glibc/sysdeps/unix/sysv/linux/testrtsig.h
===================================================================
--- trunk/src/libctests/glibc/sysdeps/unix/sysv/linux/testrtsig.h	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/unix/sysv/linux/testrtsig.h	(revision 2036)
@@ -0,0 +1,36 @@
+/* Test whether RT signals are really available.
+   Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <string.h>
+#include <sys/utsname.h>
+
+#include "kernel-features.h"
+
+static int
+kernel_has_rtsig (void)
+{
+#if __ASSUME_REALTIME_SIGNALS
+  return 1;
+#else
+  struct utsname name;
+
+  return uname (&name) == 0 && __strverscmp (name.release, "2.1.70") >= 0;
+#endif
+}
Index: trunk/src/libctests/glibc/sysdeps/x86_64/Makefile
===================================================================
--- trunk/src/libctests/glibc/sysdeps/x86_64/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/x86_64/Makefile	(revision 2036)
@@ -0,0 +1,11 @@
+# The i387 `long double' is a distinct type we support.
+long-double-fcts = yes
+
+ifeq ($(subdir),csu)
+sysdep_routines += hp-timing
+elide-routines.os += hp-timing
+endif
+
+ifeq ($(subdir),gmon)
+sysdep_routines += _mcount
+endif
Index: trunk/src/libctests/glibc/sysdeps/x86_64/fpu/ftestexcept.c
===================================================================
--- trunk/src/libctests/glibc/sysdeps/x86_64/fpu/ftestexcept.c	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/x86_64/fpu/ftestexcept.c	(revision 2036)
@@ -0,0 +1,33 @@
+/* Test exception in current environment.
+   Copyright (C) 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <fenv.h>
+
+int
+fetestexcept (int excepts)
+{
+  int temp;
+  unsigned int mxscr;
+
+  /* Get current exceptions.  */
+  __asm__ ("fnstsw %0\n"
+	   "stmxcsr %1" : "=m" (*&temp), "=m" (*&mxscr));
+
+  return (temp | mxscr) & excepts & FE_ALL_EXCEPT;
+}
Index: trunk/src/libctests/glibc/sysdeps/x86_64/fpu/libm-test-ulps
===================================================================
--- trunk/src/libctests/glibc/sysdeps/x86_64/fpu/libm-test-ulps	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/x86_64/fpu/libm-test-ulps	(revision 2036)
@@ -0,0 +1,1311 @@
+# Begin of automatic generation
+
+# acos
+Test "acos (0.75) == 0.722734247813415611178377352641333362":
+ildouble: 1
+ldouble: 1
+
+# asin
+Test "asin (-0.5) == -pi/6":
+ildouble: 1
+ldouble: 1
+Test "asin (-1.0) == -pi/2":
+ildouble: 1
+ldouble: 1
+Test "asin (0.5) == pi/6":
+ildouble: 1
+ldouble: 1
+Test "asin (0.75) == 0.848062078981481008052944338998418080":
+ildouble: 1
+ldouble: 1
+Test "asin (1.0) == pi/2":
+ildouble: 1
+ldouble: 1
+
+# atan2
+Test "atan2 (-0.75, -1.0) == -2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+Test "atan2 (0.75, -1.0) == 2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+Test "atan2 (1.390625, 0.9296875) == 0.981498387184244311516296577615519772":
+float: 1
+ifloat: 1
+Test "atan2 (-0.00756827042671106339, -.001792735857538728036) == -1.80338464113663849327153994379639112":
+float: 6
+ifloat: 6
+
+# atanh
+Test "atanh (0.75) == 0.972955074527656652552676371721589865":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# cacos
+Test "Imaginary part of: cacos (0.75 + 1.25 i) == 1.11752014915610270578240049553777969 - 1.13239363160530819522266333696834467 i":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+# cacosh
+Test "Real part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+ildouble: 6
+ldouble: 6
+Test "Imaginary part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0.75 + 1.25 i) == 1.13239363160530819522266333696834467 + 1.11752014915610270578240049553777969 i":
+ildouble: 1
+ldouble: 1
+
+# casin
+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+ildouble: 5
+ldouble: 5
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 5
+ldouble: 5
+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ldouble: 1
+ildouble: 1
+
+# catan
+Test "Real part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+float: 3
+ifloat: 3
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i":
+float: 4
+ifloat: 4
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 4
+idouble: 4
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+float: 4
+ifloat: 4
+Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+float: 6
+ifloat: 6
+
+# cbrt
+Test "cbrt (-0.001) == -0.1":
+ildouble: 1
+ldouble: 1
+Test "cbrt (-27.0) == -3.0":
+double: 1
+idouble: 1
+Test "cbrt (0.75) == 0.908560296416069829445605878163630251":
+double: 1
+idouble: 1
+Test "cbrt (0.9921875) == 0.997389022060725270579075195353955217":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# ccos
+Test "Real part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+ildouble: 1
+ldouble: 1
+float: 1
+ifloat: 1
+
+# ccosh
+Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+
+# cexp
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+ildouble: 1
+ldouble: 1
+
+# clog
+Test "Imaginary part of: clog (-2 - 3 i) == 1.2824746787307683680267437207826593 - 2.1587989303424641704769327722648368 i":
+float: 3
+ifloat: 3
+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + inf i) == inf + 3/4 pi*log10(e) i":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cos
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "cos (pi/2) == 0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "cos (0.80190127184058835) == 0.69534156199418473":
+double: 1
+idouble: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+ldouble: 1
+ildouble: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+ildouble: 5
+ldouble: 5
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+ildouble: 2
+ldouble: 2
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+ildouble: 3
+ldouble: 3
+Test "Real part of: cpow (2 + 0 i, 10 + 0 i) == 1024.0 + 0.0 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# csin
+Test "Real part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csin (-2 - 3 i) == -9.15449914691142957346729954460983256 + 4.16890695996656435075481305885375484 i":
+double: 1
+idouble: 1
+
+# csinh
+Test "Real part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+
+# csqrt
+Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+double: 1
+idouble: 1
+ildouble: 439
+ldouble: 439
+Test "Imaginary part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Real part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+float: 2
+ifloat: 2
+ildouble: 5
+ldouble: 5
+double: 1
+idouble: 1
+Test "Imaginary part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+ildouble: 25
+ldouble: 25
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+float: 1
+ifloat: 1
+Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+ildouble: 1
+ldouble: 1
+double: 1
+idouble: 1
+
+# erf
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (1.25) == 0.0770998717435417698634765188027188596":
+ildouble: 1
+ldouble: 1
+Test "erfc (2.0) == 0.00467773498104726583793074363274707139":
+double: 1
+idouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# exp10
+Test "exp10 (-1) == 0.1":
+ildouble: 1
+ldouble: 1
+float: 1
+ifloat: 1
+double: 2
+idouble: 2
+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
+ildouble: 2
+ldouble: 2
+float: 1
+ifloat: 1
+double: 1
+idouble: 1
+Test "exp10 (3) == 1000":
+ildouble: 8
+ldouble: 8
+float: 2
+ifloat: 2
+double: 6
+idouble: 6
+
+# expm1
+Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
+double: 1
+idouble: 1
+Test "expm1 (1) == M_El - 1.0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# gamma
+Test "gamma (-0.5) == log(2*sqrt(pi))":
+ildouble: 1
+ldouble: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "j0 (0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "j0 (2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "j0 (8.0) == 0.171650807137553906090869407851972001":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+# j1
+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# jn
+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (0, 0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "jn (0, 2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (0, 8.0) == 0.171650807137553906090869407851972001":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "jn (10, -1.0) == 0.263061512368745320699785368779050294e-9":
+ildouble: 1
+ldouble: 1
+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "jn (10, 1.0) == 0.263061512368745320699785368779050294e-9":
+ildouble: 1
+ldouble: 1
+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+ildouble: 2
+ldouble: 2
+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
+float: 4
+ifloat: 4
+ildouble: 1
+ldouble: 1
+Test "jn (3, -1.0) == -0.0195633539826684059189053216217515083":
+ildouble: 1
+ldouble: 1
+Test "jn (3, 0.125) == 0.406503832554912875023029337653442868e-4":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 1.0) == 0.0195633539826684059189053216217515083":
+ildouble: 1
+ldouble: 1
+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# lgamma
+Test "lgamma (-0.5) == log(2*sqrt(pi))":
+ildouble: 1
+ldouble: 1
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+ildouble: 1
+ldouble: 1
+float: 2
+ifloat: 2
+double: 1
+idouble: 1
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# log1p
+Test "log1p (-0.25) == -0.287682072451780927439219005993827432":
+float: 1
+ifloat: 1
+
+# sincos
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "sincos (pi/6, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res":
+float: 1
+ifloat: 1
+Test "sincos (0.80190127184058835, &sin_res, &cos_res) puts 0.69534156199418473 in cos_res":
+double: 1
+idouble: 1
+
+# tan
+Test "tan (pi/4) == 1":
+double: 1
+idouble: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (4) == 6":
+ildouble: 1
+ldouble: 1
+
+# y0
+Test "y0 (0.125) == -1.38968062514384052915582277745018693":
+ildouble: 1
+ldouble: 1
+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# y1
+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "y1 (1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# yn
+Test "yn (0, 0.125) == -1.38968062514384052915582277745018693":
+ildouble: 1
+ldouble: 1
+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "yn (10, 0.125) == -127057845771019398.252538486899753195":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 4
+ldouble: 4
+Test "yn (10, 1.0) == -121618014.278689189288130426667971145":
+double: 1
+idouble: 1
+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (10, 2.0) == -129184.542208039282635913145923304214":
+double: 2
+idouble: 2
+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (3, 10.0) == -0.251362657183837329779204747654240998":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: "acos":
+ildouble: 1
+ldouble: 1
+
+Function: "asin":
+ildouble: 1
+ldouble: 1
+
+Function: "atan2":
+float: 6
+ifloat: 6
+
+Function: "atanh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "cacos":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "cacosh":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+ildouble: 6
+ldouble: 6
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "casin":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+ildouble: 5
+ldouble: 5
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 5
+ldouble: 5
+
+Function: Real part of "catan":
+float: 4
+ifloat: 4
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catanh":
+double: 4
+idouble: 4
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "catanh":
+float: 6
+ifloat: 6
+
+Function: "cbrt":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ccos":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "cexp":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "clog":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "clog":
+float: 3
+ifloat: 3
+
+Function: Real part of "clog10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+ildouble: 1
+ldouble: 1
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cpow":
+double: 2
+float: 5
+idouble: 2
+ifloat: 5
+ildouble: 5
+ldouble: 5
+
+Function: Imaginary part of "cpow":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "csin":
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "csqrt":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctan":
+double: 1
+idouble: 1
+ildouble: 439
+ldouble: 439
+
+Function: Imaginary part of "ctan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+
+Function: Real part of "ctanh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 5
+ldouble: 5
+
+Function: Imaginary part of "ctanh":
+float: 1
+ifloat: 1
+ildouble: 25
+ldouble: 25
+double: 1
+idouble: 1
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: "exp10":
+ildouble: 8
+ldouble: 8
+float: 2
+ifloat: 2
+double: 6
+idouble: 6
+
+Function: "expm1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "gamma":
+ildouble: 1
+ldouble: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "j0":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "jn":
+double: 4
+float: 4
+idouble: 4
+ifloat: 4
+ildouble: 2
+ldouble: 2
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "log10":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+double: 1
+idouble: 1
+
+Function: "log1p":
+float: 1
+ifloat: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 4
+ldouble: 4
+
+# end of automatic generation
Index: trunk/src/libctests/glibc/sysdeps/x86_64/tst-stack-align.h
===================================================================
--- trunk/src/libctests/glibc/sysdeps/x86_64/tst-stack-align.h	(revision 2036)
+++ trunk/src/libctests/glibc/sysdeps/x86_64/tst-stack-align.h	(revision 2036)
@@ -0,0 +1,47 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <stdint.h>
+
+#define TEST_STACK_ALIGN() \
+  ({									     \
+    /* AMD64 ABI mandates 16byte aligned stack.				     \
+       Unfortunately, current GCC doesn't support __int128 or __float128     \
+       types, so use aligned attribute instead.  */			     \
+    struct _S								     \
+      {									     \
+        int _i __attribute__((aligned (16)));				     \
+	int _pad[3];							     \
+      } _s = { ._i = 18 };						     \
+    double _d = 12.0;							     \
+    long double _ld = 15.0;						     \
+    int _ret = 0;							     \
+    printf ("__int128:  %d %p %zu\n", _s._i, &_s, __alignof (_s));	     \
+    if ((((uintptr_t) &_s) & (__alignof (_s) - 1)) != 0)		     \
+      _ret = 1;								     \
+									     \
+    printf ("double:  %g %p %zu\n", _d, &_d, __alignof (double));	     \
+    if ((((uintptr_t) &_d) & (__alignof (double) - 1)) != 0)		     \
+      _ret = 1;								     \
+									     \
+    printf ("ldouble: %Lg %p %zu\n", _ld, &_ld, __alignof (long double));    \
+    if ((((uintptr_t) &_ld) & (__alignof (long double) - 1)) != 0)	     \
+      _ret = 1;								     \
+    _ret;								     \
+    })
Index: trunk/src/libctests/glibc/test-skeleton.c
===================================================================
--- trunk/src/libctests/glibc/test-skeleton.c	(revision 2036)
+++ trunk/src/libctests/glibc/test-skeleton.c	(revision 2036)
@@ -0,0 +1,380 @@
+/* Skeleton for test programs.
+   Copyright (C) 1998,2000-2004, 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <getopt.h>
+#include <malloc.h>
+#include <search.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/resource.h>
+#include <sys/wait.h>
+#include <sys/param.h>
+#include <time.h>
+
+/* The test function is normally called `do_test' and it is called
+   with argc and argv as the arguments.  We nevertheless provide the
+   possibility to overwrite this name.  */
+#ifndef TEST_FUNCTION
+# define TEST_FUNCTION do_test (argc, argv)
+#endif
+
+#ifndef TEST_DATA_LIMIT
+# define TEST_DATA_LIMIT (64 << 20) /* Data limit (bytes) to run with.  */
+#endif
+
+#define OPT_DIRECT 1000
+#define OPT_TESTDIR 1001
+
+static struct option options[] =
+{
+#ifdef CMDLINE_OPTIONS
+  CMDLINE_OPTIONS
+#endif
+  { "direct", no_argument, NULL, OPT_DIRECT },
+  { "test-dir", required_argument, NULL, OPT_TESTDIR },
+  { NULL, 0, NULL, 0 }
+};
+
+/* PID of the test itself.  */
+static pid_t pid;
+
+/* Directory to place temporary files in.  */
+static const char *test_dir;
+
+/* List of temporary files.  */
+struct temp_name_list
+{
+  struct qelem q;
+  const char *name;
+} *temp_name_list;
+
+/* Add temporary files in list.  */
+static void
+__attribute__ ((unused))
+add_temp_file (const char *name)
+{
+  struct temp_name_list *newp
+    = (struct temp_name_list *) calloc (sizeof (*newp), 1);
+  if (newp != NULL)
+    {
+      newp->name = name;
+      if (temp_name_list == NULL)
+	temp_name_list = (struct temp_name_list *) &newp->q;
+      else
+	insque (newp, temp_name_list);
+    }
+}
+
+/* Delete all temporary files.  */
+static void
+delete_temp_files (void)
+{
+  while (temp_name_list != NULL)
+    {
+      remove (temp_name_list->name);
+      temp_name_list = (struct temp_name_list *) temp_name_list->q.q_forw;
+    }
+}
+
+/* Create a temporary file.  */
+static int
+__attribute__ ((unused))
+create_temp_file (const char *base, char **filename)
+{
+  char *fname;
+  int fd;
+
+  fname = (char *) malloc (strlen (test_dir) + 1 + strlen (base)
+			   + sizeof ("XXXXXX"));
+  if (fname == NULL)
+    {
+      puts ("out of memory");
+      return -1;
+    }
+  strcpy (stpcpy (stpcpy (stpcpy (fname, test_dir), "/"), base), "XXXXXX");
+
+  fd = mkstemp (fname);
+  if (fd == -1)
+    {
+      printf ("cannot open temporary file '%s': %m\n", fname);
+      free (fname);
+      return -1;
+    }
+
+  add_temp_file (fname);
+  if (filename != NULL)
+    *filename = fname;
+
+  return fd;
+}
+
+/* Timeout handler.  We kill the child and exit with an error.  */
+static void
+__attribute__ ((noreturn))
+timeout_handler (int sig __attribute__ ((unused)))
+{
+  int killed;
+  int status;
+
+  /* Send signal.  */
+  kill (pid, SIGKILL);
+
+  /* Wait for it to terminate.  */
+  int i;
+  for (i = 0; i < 5; ++i)
+    {
+      killed = waitpid (pid, &status, WNOHANG|WUNTRACED);
+      if (killed != 0)
+	break;
+
+      /* Delay, give the system time to process the kill.  If the
+	 nanosleep() call return prematurely, all the better.  We
+	 won't restart it since this probably means the child process
+	 finally died.  */
+      struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 };
+      nanosleep (&ts, NULL);
+    }
+  if (killed != 0 && killed != pid)
+    {
+      perror ("Failed to kill test process");
+      exit (1);
+    }
+
+#ifdef CLEANUP_HANDLER
+  CLEANUP_HANDLER;
+#endif
+
+  /* If we expected this signal: good!  */
+#ifdef EXPECTED_SIGNAL
+  if (EXPECTED_SIGNAL == SIGALRM)
+    exit (0);
+#endif
+
+  if (killed == 0 || (WIFSIGNALED (status) && WTERMSIG (status) == SIGKILL))
+    fputs ("Timed out: killed the child process\n", stderr);
+  else if (WIFSTOPPED (status))
+    fprintf (stderr, "Timed out: the child process was %s\n",
+	     strsignal (WSTOPSIG (status)));
+  else if (WIFSIGNALED (status))
+    fprintf (stderr, "Timed out: the child process got signal %s\n",
+	     strsignal (WTERMSIG (status)));
+  else
+    fprintf (stderr, "Timed out: killed the child process but it exited %d\n",
+	     WEXITSTATUS (status));
+
+  /* Exit with an error.  */
+  exit (1);
+}
+
+/* We provide the entry point here.  */
+int
+main (int argc, char *argv[])
+{
+  int direct = 0;	/* Directly call the test function?  */
+  int status;
+  int opt;
+  unsigned int timeoutfactor = 1;
+  pid_t termpid;
+
+  /* Make uses of freed and uninitialized memory known.  */
+  mallopt (M_PERTURB, 42);
+
+#ifdef STDOUT_UNBUFFERED
+  setbuf (stdout, NULL);
+#endif
+
+  while ((opt = getopt_long (argc, argv, "+", options, NULL)) != -1)
+    switch (opt)
+      {
+      case '?':
+	exit (1);
+      case OPT_DIRECT:
+	direct = 1;
+	break;
+      case OPT_TESTDIR:
+	test_dir = optarg;
+	break;
+#ifdef CMDLINE_PROCESS
+	CMDLINE_PROCESS
+#endif
+      }
+
+  /* If set, read the test TIMEOUTFACTOR value from the environment.
+     This value is used to scale the default test timeout values. */
+  char *envstr_timeoutfactor = getenv ("TIMEOUTFACTOR");
+  if (envstr_timeoutfactor != NULL)
+    {
+      char *envstr_conv = envstr_timeoutfactor;
+      unsigned long int env_fact;
+
+      env_fact = strtoul (envstr_timeoutfactor, &envstr_conv, 0);
+      if (*envstr_conv == '\0' && envstr_conv != envstr_timeoutfactor)
+	timeoutfactor = MAX (env_fact, 1);
+    }
+
+  /* Set TMPDIR to specified test directory.  */
+  if (test_dir != NULL)
+    {
+      setenv ("TMPDIR", test_dir, 1);
+
+      if (chdir (test_dir) < 0)
+	{
+	  perror ("chdir");
+	  exit (1);
+	}
+    }
+  else
+    {
+      test_dir = getenv ("TMPDIR");
+      if (test_dir == NULL || test_dir[0] == '\0')
+	test_dir = "/tmp";
+    }
+
+  /* Make sure we see all message, even those on stdout.  */
+  setvbuf (stdout, NULL, _IONBF, 0);
+
+  /* make sure temporary files are deleted.  */
+  atexit (delete_temp_files);
+
+  /* Correct for the possible parameters.  */
+  argv[optind - 1] = argv[0];
+  argv += optind - 1;
+  argc -= optind - 1;
+
+  /* Call the initializing function, if one is available.  */
+#ifdef PREPARE
+  PREPARE (argc, argv);
+#endif
+
+  /* If we are not expected to fork run the function immediately.  */
+  if (direct)
+    return TEST_FUNCTION;
+
+  /* Set up the test environment:
+     - prevent core dumps
+     - set up the timer
+     - fork and execute the function.  */
+
+  pid = fork ();
+  if (pid == 0)
+    {
+      /* This is the child.  */
+#ifdef RLIMIT_CORE
+      /* Try to avoid dumping core.  */
+      struct rlimit core_limit;
+      core_limit.rlim_cur = 0;
+      core_limit.rlim_max = 0;
+      setrlimit (RLIMIT_CORE, &core_limit);
+#endif
+
+#ifdef RLIMIT_DATA
+      /* Try to avoid eating all memory if a test leaks.  */
+      struct rlimit data_limit;
+      if (getrlimit (RLIMIT_DATA, &data_limit) == 0)
+	{
+	  if (TEST_DATA_LIMIT == RLIM_INFINITY)
+	    data_limit.rlim_cur = data_limit.rlim_max;
+	  else if (data_limit.rlim_cur > (rlim_t) TEST_DATA_LIMIT)
+	    data_limit.rlim_cur = MIN ((rlim_t) TEST_DATA_LIMIT,
+				       data_limit.rlim_max);
+	  if (setrlimit (RLIMIT_DATA, &data_limit) < 0)
+	    perror ("setrlimit: RLIMIT_DATA");
+	}
+      else
+	perror ("getrlimit: RLIMIT_DATA");
+#endif
+
+      /* We put the test process in its own pgrp so that if it bogusly
+	 generates any job control signals, they won't hit the whole build.  */
+      setpgid (0, 0);
+
+      /* Execute the test function and exit with the return value.   */
+      exit (TEST_FUNCTION);
+    }
+  else if (pid < 0)
+    {
+      perror ("Cannot fork test program");
+      exit (1);
+    }
+
+  /* Set timeout.  */
+#ifndef TIMEOUT
+  /* Default timeout is two seconds.  */
+# define TIMEOUT 2
+#endif
+  signal (SIGALRM, timeout_handler);
+  alarm (TIMEOUT * timeoutfactor);
+
+  /* Wait for the regular termination.  */
+  termpid = TEMP_FAILURE_RETRY (waitpid (pid, &status, 0));
+  if (termpid == -1)
+    {
+      printf ("Waiting for test program failed: %m\n");
+      exit (1);
+    }
+  if (termpid != pid)
+    {
+      printf ("Oops, wrong test program terminated: expected %ld, got %ld\n",
+	      (long int) pid, (long int) termpid);
+      exit (1);
+    }
+
+#ifndef EXPECTED_SIGNAL
+  /* We don't expect any signal.  */
+# define EXPECTED_SIGNAL 0
+#endif
+  if (WTERMSIG (status) != EXPECTED_SIGNAL)
+    {
+      if (EXPECTED_SIGNAL != 0)
+	{
+	  if (WTERMSIG (status) == 0)
+	    fprintf (stderr,
+		     "Expected signal '%s' from child, got none\n",
+		     strsignal (EXPECTED_SIGNAL));
+	  else
+	    fprintf (stderr,
+		     "Incorrect signal from child: got `%s', need `%s'\n",
+		     strsignal (WTERMSIG (status)),
+		     strsignal (EXPECTED_SIGNAL));
+	}
+      else
+	fprintf (stderr, "Didn't expect signal from child: got `%s'\n",
+		 strsignal (WTERMSIG (status)));
+      exit (1);
+    }
+
+  /* Simply exit with the return value of the test.  */
+#ifndef EXPECTED_STATUS
+  return WEXITSTATUS (status);
+#else
+  if (WEXITSTATUS (status) != EXPECTED_STATUS)
+    {
+      fprintf (stderr, "Expected status %d, got %d\n",
+	       EXPECTED_STATUS, WEXITSTATUS (status));
+      exit (1);
+    }
+
+  return 0;
+#endif
+}
Index: trunk/src/libctests/glibc/time/Makefile
===================================================================
--- trunk/src/libctests/glibc/time/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/time/Makefile	(revision 2036)
@@ -0,0 +1,57 @@
+# Copyright (C) 1991-2003, 2004, 2005 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Makefile for time routines
+#
+subdir	:= time
+
+headers	:= time.h sys/time.h sys/timeb.h bits/time.h
+
+routines := offtime asctime clock ctime ctime_r difftime \
+	    gmtime localtime mktime time		 \
+	    gettimeofday settimeofday adjtime tzset	 \
+	    tzfile getitimer setitimer			 \
+	    stime dysize timegm ftime			 \
+	    getdate strptime strptime_l			 \
+	    strftime wcsftime strftime_l wcsftime_l
+aux :=	    era alt_digit lc-time-cleanup
+distribute := datemsk
+
+tests	:= test_time clocktest tst-posixtz tst-strptime tst_wcsftime \
+	   tst-getdate tst-mktime tst-mktime2 tst-ftime_l tst-strftime \
+	   tst-mktime3 tst-strptime2
+
+include ../Rules
+
+tz-cflags = -DTZDIR='"$(zonedir)"' \
+	    -DTZDEFAULT='"$(localtime-file)"' \
+	    -DTZDEFRULES='"$(posixrules-file)"'
+
+CFLAGS-tzfile.c = $(tz-cflags)
+CFLAGS-tzset.c = $(tz-cflags)
+CFLAGS-getdate.c = -fexceptions
+
+# Don't warn about Y2k problem in strftime format string.
+CFLAGS-test_time.c = -Wno-format
+
+tst-getdate-ENV= DATEMSK=datemsk TZDIR=${common-objpfx}timezone/testdata
+test_time-ARGS= EST5EDT CST
+
+tst-strptime-ENV = LOCPATH=${common-objpfx}localedata
+tst-ftime_l-ENV = LOCPATH=${common-objpfx}localedata
Index: trunk/src/libctests/glibc/time/clocktest.c
===================================================================
--- trunk/src/libctests/glibc/time/clocktest.c	(revision 2036)
+++ trunk/src/libctests/glibc/time/clocktest.c	(revision 2036)
@@ -0,0 +1,36 @@
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+
+volatile int gotit = 0;
+
+static void
+alarm_handler (int signal)
+{
+    gotit = 1;
+}
+
+
+int
+main (int argc, char ** argv)
+{
+  clock_t start, stop;
+
+  if (signal(SIGALRM, alarm_handler) == SIG_ERR)
+    {
+      perror ("signal");
+      exit (1);
+    }
+  alarm(1);
+  start = clock ();
+  while (!gotit);
+  stop = clock ();
+
+  printf ("%ld clock ticks per second (start=%ld,stop=%ld)\n",
+	  stop - start, start, stop);
+  printf ("CLOCKS_PER_SEC=%ld, sysconf(_SC_CLK_TCK)=%ld\n",
+	  CLOCKS_PER_SEC, sysconf(_SC_CLK_TCK));
+  return 0;
+}
Index: trunk/src/libctests/glibc/time/test_time.c
===================================================================
--- trunk/src/libctests/glibc/time/test_time.c	(revision 2036)
+++ trunk/src/libctests/glibc/time/test_time.c	(revision 2036)
@@ -0,0 +1,116 @@
+/* Copyright (C) 1991, 1992, 1994, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+
+int
+main (int argc, char **argv)
+{
+  time_t t;
+  register struct tm *tp;
+  struct tm tbuf;
+  int lose = 0;
+
+  --argc;
+  ++argv;
+
+  do
+    {
+      char buf[BUFSIZ];
+      if (argc > 0)
+	{
+	  static char buf[BUFSIZ];
+	  sprintf(buf, "TZ=%s", *argv);
+	  if (putenv(buf))
+	    {
+	      puts("putenv failed.");
+	      lose = 1;
+	    }
+	  else
+	    puts (buf);
+	}
+      tzset();
+      tbuf.tm_year = 72;
+      tbuf.tm_mon = 0;
+      tbuf.tm_mday = 31;
+      tbuf.tm_hour = 6;
+      tbuf.tm_min = 14;
+      tbuf.tm_sec = 50;
+      tbuf.tm_isdst = -1;
+    doit:;
+      t = mktime(&tbuf);
+      if (t == (time_t) -1)
+	{
+	  puts("mktime() failed?");
+	  lose = 1;
+	}
+      tp = localtime(&t);
+      if (tp == NULL)
+	{
+	  puts("localtime() failed.");
+	  lose = 1;
+	}
+      else if (strftime(buf, sizeof(buf), "%a %b %d %X %Z %Y", tp) == 0)
+	{
+	  puts("strftime() failed.");
+	  lose = 1;
+	}
+      else
+	puts(buf);
+      if (tbuf.tm_year == 101)
+	{
+	  tbuf.tm_year = 97;
+	  tbuf.tm_mon = 0;
+	  goto doit;
+	}
+      ++argv;
+    } while (--argc > 0);
+
+  {
+#define	SIZE	256
+    char buffer[SIZE];
+    time_t curtime;
+    struct tm *loctime;
+
+    curtime = time (NULL);
+
+    loctime = localtime (&curtime);
+
+    fputs (asctime (loctime), stdout);
+
+    strftime (buffer, SIZE, "Today is %A, %B %d.\n", loctime);
+    fputs (buffer, stdout);
+    strftime (buffer, SIZE, "The time is %I:%M %p.\n", loctime);
+    fputs (buffer, stdout);
+
+    loctime->tm_year = 72;
+    loctime->tm_mon = 8;
+    loctime->tm_mday = 12;
+    loctime->tm_hour = 20;
+    loctime->tm_min = 49;
+    loctime->tm_sec = 05;
+    curtime = mktime (loctime);
+    strftime (buffer, SIZE, "%D %T was %w the %jth.\n", loctime);
+    fputs (buffer, stdout);
+  }
+
+  return (lose ? EXIT_FAILURE : EXIT_SUCCESS);
+}
Index: trunk/src/libctests/glibc/time/tst-ftime_l.c
===================================================================
--- trunk/src/libctests/glibc/time/tst-ftime_l.c	(revision 2036)
+++ trunk/src/libctests/glibc/time/tst-ftime_l.c	(revision 2036)
@@ -0,0 +1,126 @@
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <wchar.h>
+
+
+int
+main (void)
+{
+  locale_t l;
+  locale_t old;
+  struct tm tm;
+  char buf[1000];
+  wchar_t wbuf[1000];
+  int result = 0;
+  size_t n;
+
+  l = newlocale (LC_ALL_MASK, "de_DE.ISO-8859-1", NULL);
+  if (l == NULL)
+    {
+      puts ("newlocale failed");
+      exit (1);
+    }
+
+  memset (&tm, '\0', sizeof (tm));
+
+  tm.tm_year = 102;
+  tm.tm_mon = 2;
+  tm.tm_mday = 1;
+
+  if (strftime (buf, sizeof (buf), "%e %^B %Y", &tm) == 0)
+    {
+      puts ("initial strftime failed");
+      exit (1);
+    }
+  if (strcmp (buf, " 1 MARCH 2002") != 0)
+    {
+      printf ("initial strftime: expected \"%s\", got \"%s\"\n",
+	      " 1 MARCH 2002", buf);
+      result = 1;
+    }
+  else
+    printf ("got \"%s\"\n", buf);
+
+  /* Now using the extended locale model.  */
+  if (strftime_l (buf, sizeof (buf), "%e %^B %Y", &tm, l) == 0)
+    {
+      puts ("strftime_l failed");
+      result = 1;
+    }
+  else if (strcmp (buf, " 1 M\xc4RZ 2002") != 0)
+    {
+      printf ("strftime_l: expected \"%s\", got \"%s\"\n",
+	      " 1 M\xc4RZ 2002", buf);
+      result = 1;
+    }
+  else
+    {
+      setlocale (LC_ALL, "de_DE.ISO-8859-1");
+      printf ("got \"%s\"\n", buf);
+      setlocale (LC_ALL, "C");
+    }
+
+  /* And the wide character version.  */
+  if (wcsftime_l (wbuf, sizeof (wbuf) / sizeof (wbuf[0]), L"%e %^B %Y", &tm, l)
+      == 0)
+    {
+      puts ("wcsftime_l failed");
+      result = 1;
+    }
+  else if (wcscmp (wbuf, L" 1 M\x00c4RZ 2002") != 0)
+    {
+      printf ("wcsftime_l: expected \"%ls\", got \"%ls\"\n",
+	      L" 1 M\x00c4RZ 2002", wbuf);
+      result = 1;
+    }
+  else
+    {
+      setlocale (LC_ALL, "de_DE.ISO-8859-1");
+      printf ("got \"%ls\"\n", wbuf);
+      setlocale (LC_ALL, "C");
+    }
+
+  old = uselocale (l);
+
+  n = strftime (buf, sizeof (buf), "%e %^B %Y", &tm);
+
+  /* Switch back.  */
+  (void) uselocale (old);
+
+  if (n == 0)
+    {
+      puts ("strftime after first uselocale failed");
+      result = 1;
+    }
+  else if (strcmp (buf, " 1 M\xc4RZ 2002") != 0)
+    {
+      printf ("strftime in non-C locale: expected \"%s\", got \"%s\"\n",
+	      " 1 M\xc4RZ 2002", buf);
+      result = 1;
+    }
+  else
+    {
+      setlocale (LC_ALL, "de_DE.ISO-8859-1");
+      printf ("got \"%s\"\n", buf);
+      setlocale (LC_ALL, "C");
+    }
+
+  if (strftime (buf, sizeof (buf), "%e %^B %Y", &tm) == 0)
+    {
+      puts ("strftime after second uselocale failed");
+      result = 1;
+    }
+  else if (strcmp (buf, " 1 MARCH 2002") != 0)
+    {
+      printf ("initial strftime: expected \"%s\", got \"%s\"\n",
+	      " 1 MARCH 2002", buf);
+      result = 1;
+    }
+  else
+    printf ("got \"%s\"\n", buf);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/time/tst-getdate.c
===================================================================
--- trunk/src/libctests/glibc/time/tst-getdate.c	(revision 2036)
+++ trunk/src/libctests/glibc/time/tst-getdate.c	(revision 2036)
@@ -0,0 +1,120 @@
+/* Test for getdate.
+   Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@suse.de>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+static const struct
+{
+  const char *str;
+  const char *tz;
+  int err;
+  struct tm tm;
+} tests [] =
+{
+  {"21:01:10 1999-1-31", "Universal", 0, {10, 1, 21, 31, 0, 99, 0, 0, 0}},
+  {"21:01:10 1999-2-28", "Universal", 0, {10, 1, 21, 28, 1, 99, 0, 0, 0}},
+  {"16:30:46 2000-2-29", "Universal", 0, {46, 30,16, 29, 1, 100, 0, 0, 0}},
+  {"01-08-2000 05:06:07", "Europe/Berlin", 0, {7, 6, 5, 1, 7, 100, 0, 0, 0}}
+};
+
+static void
+report_date_error (int err)
+{
+  switch(err)
+    {
+    case 1:
+      printf ("The environment variable DATEMSK is not defined or null.\n");
+      break;
+    case 2:
+      printf ("The template file denoted by the DATEMSK environment variable cannot be opened.\n");
+      break;
+    case 3:
+      printf ("Information about the template file cannot retrieved.\n");
+      break;
+    case 4:
+      printf ("The template file is not a regular file.\n");
+      break;
+    case 5:
+      printf ("An I/O error occurred while reading the template file.\n");
+      break;
+    case 6:
+      printf ("Not enough memory available to execute the function.\n");
+      break;
+    case 7:
+      printf ("The template file contains no matching template.\n");
+      break;
+    case 8:
+      printf ("The input date is invalid, but would match a template otherwise.\n");
+      break;
+    default:
+      printf("Unknown error code.\n");
+      break;
+    }
+}
+
+
+int
+main (void)
+{
+  int errors = 0;
+  size_t i;
+  struct tm *tm;
+
+
+  for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
+    {
+      setenv ("TZ", tests[i].tz, 1);
+
+      tm = getdate (tests[i].str);
+
+      if (getdate_err != tests[i].err)
+	{
+	  printf ("Failure for getdate (\"%s\"):\n", tests[i].str);
+	  printf ("getdate_err should be %d but returned: %d which means:\n",
+		  tests[i].err, getdate_err);
+	  report_date_error (getdate_err);
+	  ++errors;
+	}
+      else if (tests[i].tm.tm_mon != tm->tm_mon
+	       || tests[i].tm.tm_year != tm->tm_year
+	       || tests[i].tm.tm_mday != tm->tm_mday
+	       || tests[i].tm.tm_hour != tm->tm_hour
+	       || tests[i].tm.tm_min != tm->tm_min
+	       || tests[i].tm.tm_sec != tm->tm_sec)
+	{
+	  printf ("Failure for getdate (\"%s\"):\n", tests[i].str);
+	  printf ("struct tm is:  %d-%d-%d %d:%d:%d\n",
+		  tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
+		  tm->tm_hour, tm->tm_min, tm->tm_sec);
+	  printf ("but should be: %d-%d-%d %d:%d:%d\n",
+		  tests[i].tm.tm_year + 1900, tests[i].tm.tm_mon + 1,
+		  tests[i].tm.tm_mday,
+		  tests[i].tm.tm_hour, tests[i].tm.tm_min, tests[i].tm.tm_sec);
+	  ++errors;
+	}
+    }
+
+  if (!errors)
+    printf ("No errors found.\n");
+  return errors != 0;
+}
Index: trunk/src/libctests/glibc/time/tst-mktime.c
===================================================================
--- trunk/src/libctests/glibc/time/tst-mktime.c	(revision 2036)
+++ trunk/src/libctests/glibc/time/tst-mktime.c	(revision 2036)
@@ -0,0 +1,70 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+
+int
+main (void)
+{
+  struct tm time_str, *tm;
+  time_t t;
+  char daybuf[20];
+  int result;
+
+  time_str.tm_year = 2001 - 1900;
+  time_str.tm_mon = 7 - 1;
+  time_str.tm_mday = 4;
+  time_str.tm_hour = 0;
+  time_str.tm_min = 0;
+  time_str.tm_sec = 1;
+  time_str.tm_isdst = -1;
+
+  if (mktime (&time_str) == -1)
+    {
+      (void) puts ("-unknown-");
+      result = 1;
+    }
+  else
+    {
+      (void) strftime (daybuf, sizeof (daybuf), "%A", &time_str);
+      (void) puts (daybuf);
+      result = strcmp (daybuf, "Wednesday") != 0;
+    }
+
+  setenv ("TZ", "EST+5", 1);
+#define EVENING69 1 * 60 * 60 + 2 * 60 + 29
+  t = EVENING69;
+  tm = localtime (&t);
+  if (tm == NULL)
+    {
+      (void) puts ("localtime returned NULL");
+      result = 1;
+    }
+  else
+    {
+      time_str = *tm;
+      t = mktime (&time_str);
+      if (t != EVENING69)
+        {
+          printf ("mktime returned %ld, expected %d\n",
+		  (long) t, EVENING69);
+	  result = 1;
+        }
+      else
+        (void) puts ("Dec 31 1969 EST test passed");
+
+      setenv ("TZ", "CET-1", 1);
+      t = mktime (&time_str);
+#define EVENING69_CET (EVENING69 - (5 - -1) * 60 * 60)
+      if (t != EVENING69_CET)
+        {
+	  printf ("mktime returned %ld, expected %ld\n",
+		  (long) t, (long) EVENING69_CET);
+	  result = 1;
+        }
+      else
+        (void) puts ("Dec 31 1969 CET test passed");
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/time/tst-mktime2.c
===================================================================
--- trunk/src/libctests/glibc/time/tst-mktime2.c	(revision 2036)
+++ trunk/src/libctests/glibc/time/tst-mktime2.c	(revision 2036)
@@ -0,0 +1,141 @@
+/* Test program from Paul Eggert and Tony Leneis.  */
+#include <time.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+static time_t time_t_max;
+static time_t time_t_min;
+
+/* Values we'll use to set the TZ environment variable.  */
+static const char *tz_strings[] =
+  {
+    (const char *) 0, "GMT0", "JST-9",
+    "EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
+  };
+#define N_STRINGS ((int) (sizeof (tz_strings) / sizeof (tz_strings[0])))
+
+/* Fail if mktime fails to convert a date in the spring-forward gap.
+   Based on a problem report from Andreas Jaeger.  */
+static void
+spring_forward_gap (void)
+{
+  /* glibc (up to about 1998-10-07) failed this test. */
+  struct tm tm;
+
+  /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
+     instead of "TZ=America/Vancouver" in order to detect the bug even
+     on systems that don't support the Olson extension, or don't have the
+     full zoneinfo tables installed.  */
+  setenv ("TZ", "PST8PDT,M4.1.0,M10.5.0", 1);
+
+  tm.tm_year = 98;
+  tm.tm_mon = 3;
+  tm.tm_mday = 5;
+  tm.tm_hour = 2;
+  tm.tm_min = 0;
+  tm.tm_sec = 0;
+  tm.tm_isdst = -1;
+  if (mktime (&tm) == (time_t)-1)
+    exit (1);
+}
+
+static void
+mktime_test1 (time_t now)
+{
+  struct tm *lt = localtime (&now);
+  if (lt && mktime (lt) != now)
+    exit (2);
+}
+
+static void
+mktime_test (time_t now)
+{
+  mktime_test1 (now);
+  mktime_test1 ((time_t) (time_t_max - now));
+  mktime_test1 ((time_t) (time_t_min + now));
+}
+
+static void
+irix_6_4_bug (void)
+{
+  /* Based on code from Ariel Faigon.  */
+  struct tm tm;
+  tm.tm_year = 96;
+  tm.tm_mon = 3;
+  tm.tm_mday = 0;
+  tm.tm_hour = 0;
+  tm.tm_min = 0;
+  tm.tm_sec = 0;
+  tm.tm_isdst = -1;
+  mktime (&tm);
+  if (tm.tm_mon != 2 || tm.tm_mday != 31)
+    exit (3);
+}
+
+static void
+bigtime_test (int j)
+{
+  struct tm tm;
+  time_t now;
+  tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
+  tm.tm_isdst = -1;
+  now = mktime (&tm);
+  if (now != (time_t) -1)
+    {
+      struct tm *lt = localtime (&now);
+      if (! (lt
+	     && lt->tm_year == tm.tm_year
+	     && lt->tm_mon == tm.tm_mon
+	     && lt->tm_mday == tm.tm_mday
+	     && lt->tm_hour == tm.tm_hour
+	     && lt->tm_min == tm.tm_min
+	     && lt->tm_sec == tm.tm_sec
+	     && lt->tm_yday == tm.tm_yday
+	     && lt->tm_wday == tm.tm_wday
+	     && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
+		  == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
+	exit (4);
+    }
+}
+
+static int
+do_test (void)
+{
+  time_t t, delta;
+  int i, j;
+
+  setenv ("TZ", "America/Sao_Paulo", 1);
+  /* This test makes some buggy mktime implementations loop.
+     Give up after 60 seconds; a mktime slower than that
+     isn't worth using anyway.  */
+  alarm (60);
+
+  for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
+    continue;
+  time_t_max--;
+  if ((time_t) -1 < 0)
+    for (time_t_min = -1; (time_t) (time_t_min * 2) < 0; time_t_min *= 2)
+      continue;
+  delta = time_t_max / 997; /* a suitable prime number */
+  for (i = 0; i < N_STRINGS; i++)
+    {
+      if (tz_strings[i])
+	setenv ("TZ", tz_strings[i], 1);
+
+      for (t = 0; t <= time_t_max - delta; t += delta)
+	mktime_test (t);
+      mktime_test ((time_t) 1);
+      mktime_test ((time_t) (60 * 60));
+      mktime_test ((time_t) (60 * 60 * 24));
+
+      for (j = 1; 0 < j; j *= 2)
+	bigtime_test (j);
+      bigtime_test (j - 1);
+    }
+  irix_6_4_bug ();
+  spring_forward_gap ();
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/time/tst-mktime3.c
===================================================================
--- trunk/src/libctests/glibc/time/tst-mktime3.c	(revision 2036)
+++ trunk/src/libctests/glibc/time/tst-mktime3.c	(revision 2036)
@@ -0,0 +1,50 @@
+/* Test program for mktime bugs with out-of-range tm_sec values.  */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+
+struct tm tests[] =
+{
+  { .tm_sec = -1, .tm_mday = 1, .tm_year = 104 },
+  { .tm_sec = 65, .tm_min = 59, .tm_hour = 23, .tm_mday = 31,
+    .tm_mon = 11, .tm_year = 101 }
+};
+struct tm expected[] =
+{
+  { .tm_sec = 59, .tm_min = 59, .tm_hour = 23, .tm_mday = 31,
+    .tm_mon = 11, .tm_year = 103, .tm_wday = 3, .tm_yday = 364 },
+  { .tm_sec = 5, .tm_mday = 1, .tm_year = 102, .tm_wday = 2 }
+};
+
+int
+main (void)
+{
+  setenv ("TZ", "UTC", 1);
+  int i;
+  for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
+    {
+      if (mktime (&tests[i]) < 0)
+	{
+	  printf ("mktime %d failed\n", i);
+	  return 1;
+	}
+#define CHECK(name) \
+      if (tests[i].name != expected[i].name)			\
+	{							\
+	  printf ("test %d " #name " got %d expected %d\n",	\
+		  i, tests[i].name, expected[i].name);		\
+	  return 1;						\
+	}
+      CHECK (tm_sec)
+      CHECK (tm_min)
+      CHECK (tm_hour)
+      CHECK (tm_mday)
+      CHECK (tm_mon)
+      CHECK (tm_year)
+      CHECK (tm_wday)
+      CHECK (tm_yday)
+      CHECK (tm_isdst)
+    }
+  return 0;
+}
Index: trunk/src/libctests/glibc/time/tst-posixtz.c
===================================================================
--- trunk/src/libctests/glibc/time/tst-posixtz.c	(revision 2036)
+++ trunk/src/libctests/glibc/time/tst-posixtz.c	(revision 2036)
@@ -0,0 +1,88 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+struct
+{
+  time_t when;
+  const char *tz;
+  const char *result;
+} tests[] =
+{
+  { 909312849L, "AEST-10AEDST-11,M10.5.0,M3.5.0",
+    "1998/10/25 21:54:09 dst=1 zone=AEDST" },
+  { 924864849L, "AEST-10AEDST-11,M10.5.0,M3.5.0",
+    "1999/04/23 20:54:09 dst=0 zone=AEST" },
+  { 919973892L, "AEST-10AEDST-11,M10.5.0,M3.5.0",
+    "1999/02/26 07:18:12 dst=1 zone=AEDST" },
+  { 909312849L, "EST+5EDT,M4.1.0/2,M10.5.0/2",
+    "1998/10/25 05:54:09 dst=0 zone=EST" },
+  { 924864849L, "EST+5EDT,M4.1.0/2,M10.5.0/2",
+    "1999/04/23 06:54:09 dst=1 zone=EDT" },
+  { 919973892L, "EST+5EDT,M4.1.0/2,M10.5.0/2",
+    "1999/02/25 15:18:12 dst=0 zone=EST" },
+};
+
+int
+main (void)
+{
+  int result = 0;
+  size_t cnt;
+
+  for (cnt = 0; cnt < sizeof (tests) / sizeof (tests[0]); ++cnt)
+    {
+      char buf[100];
+      struct tm *tmp;
+
+      printf ("TZ = \"%s\", time = %ld => ", tests[cnt].tz, tests[cnt].when);
+      fflush (stdout);
+
+      setenv ("TZ", tests[cnt].tz, 1);
+
+      tmp = localtime (&tests[cnt].when);
+
+      snprintf (buf, sizeof (buf),
+		"%04d/%02d/%02d %02d:%02d:%02d dst=%d zone=%s",
+		tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
+		tmp->tm_hour, tmp->tm_min, tmp->tm_sec, tmp->tm_isdst,
+		tzname[tmp->tm_isdst ? 1 : 0]);
+
+      fputs (buf, stdout);
+
+      if (strcmp (buf, tests[cnt].result) == 0)
+	puts (", OK");
+      else
+	{
+	  result = 1;
+	  puts (", FAIL");
+	}
+    }
+
+  setenv ("TZ", "Universal", 1);
+  localtime (&tests[0].when);
+  printf ("TZ = \"Universal\" daylight %d tzname = { \"%s\", \"%s\" }",
+	  daylight, tzname[0], tzname[1]);
+  if (! daylight)
+    puts (", OK");
+  else
+    {
+      result = 1;
+      puts (", FAIL");
+    }
+
+  setenv ("TZ", "AEST-10AEDST-11,M10.5.0,M3.5.0", 1);
+  tzset ();
+  printf ("TZ = \"AEST-10AEDST-11,M10.5.0,M3.5.0\" daylight %d"
+	  " tzname = { \"%s\", \"%s\" }", daylight, tzname[0], tzname[1]);
+  if (daylight
+      && strcmp (tzname[0], "AEST") == 0 && strcmp (tzname[1], "AEDST") == 0)
+    puts (", OK");
+  else
+    {
+      result = 1;
+      puts (", FAIL");
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/time/tst-strftime.c
===================================================================
--- trunk/src/libctests/glibc/time/tst-strftime.c	(revision 2036)
+++ trunk/src/libctests/glibc/time/tst-strftime.c	(revision 2036)
@@ -0,0 +1,111 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+
+static struct
+{
+  const char *fmt;
+  size_t min;
+  size_t max;
+} tests[] =
+  {
+    { "%2000Y", 2000, 4000 },
+    { "%02000Y", 2000, 4000 },
+    { "%_2000Y", 2000, 4000 },
+    { "%-2000Y", 2000, 4000 },
+  };
+#define ntests (sizeof (tests) / sizeof (tests[0]))
+
+
+static int
+do_test (void)
+{
+  size_t cnt;
+  int result = 0;
+
+  time_t tnow = time (NULL);
+  struct tm *now = localtime (&tnow);
+
+  for (cnt = 0; cnt < ntests; ++cnt)
+    {
+      size_t size = 0;
+      int res;
+      char *buf = NULL;
+
+      do
+	{
+	  size += 500;
+	  buf = (char *) realloc (buf, size);
+	  if (buf == NULL)
+	    {
+	      puts ("out of memory");
+	      exit (1);
+	    }
+
+	  res = strftime (buf, size, tests[cnt].fmt, now);
+	  if (res != 0)
+	    break;
+	}
+      while (size < tests[cnt].max);
+
+      if (res == 0)
+	{
+	  printf ("%Zu: %s: res == 0 despite size == %Zu\n",
+		  cnt, tests[cnt].fmt, size);
+	  result = 1;
+	}
+      else if (size < tests[cnt].min)
+	{
+	  printf ("%Zu: %s: size == %Zu was enough\n",
+		  cnt, tests[cnt].fmt, size);
+	  result = 1;
+	}
+      else
+	printf ("%Zu: %s: size == %Zu: OK\n", cnt, tests[cnt].fmt, size);
+
+      free (buf);
+    }
+
+  struct tm ttm =
+    {
+      /* Initialize the fields which are needed in the tests.  */
+      .tm_mday = 1,
+      .tm_hour = 2
+    };
+  const struct
+  {
+    const char *fmt;
+    const char *exp;
+    size_t n;
+  } ftests[] =
+    {
+      { "%-e", "1", 1 },
+      { "%-k", "2", 1 },
+      { "%-l", "2", 1 },
+    };
+#define nftests (sizeof (ftests) / sizeof (ftests[0]))
+  for (cnt = 0; cnt < nftests; ++cnt)
+    {
+      char buf[100];
+      size_t r = strftime (buf, sizeof (buf), ftests[cnt].fmt, &ttm);
+      if (r != ftests[cnt].n)
+	{
+	  printf ("strftime(\"%s\") returned %zu not %zu\n",
+		  ftests[cnt].fmt, r, ftests[cnt].n);
+	  result = 1;
+	}
+      if (strcmp (buf, ftests[cnt].exp) != 0)
+	{
+	  printf ("strftime(\"%s\") produced \"%s\" not \"%s\"\n",
+		  ftests[cnt].fmt, buf, ftests[cnt].exp);
+	  result = 1;
+	}
+    }
+
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Index: trunk/src/libctests/glibc/time/tst-strptime.c
===================================================================
--- trunk/src/libctests/glibc/time/tst-strptime.c	(revision 2036)
+++ trunk/src/libctests/glibc/time/tst-strptime.c	(revision 2036)
@@ -0,0 +1,193 @@
+/* Test for strptime.
+   Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+
+static const struct
+{
+  const char *locale;
+  const char *input;
+  const char *format;
+  int wday;
+  int yday;
+  int mon;
+  int mday;
+} day_tests[] =
+{
+  { "C", "2000-01-01", "%Y-%m-%d", 6, 0, 0, 1 },
+  { "C", "03/03/00", "%D", 5, 62, 2, 3 },
+  { "C", "9/9/99", "%x", 4, 251, 8, 9 },
+  { "C", "19990502123412", "%Y%m%d%H%M%S", 0, 121, 4, 2 },
+  { "C", "2001 20 Mon", "%Y %U %a", 1, 140, 4, 21 },
+  { "C", "2001 21 Mon", "%Y %W %a", 1, 140, 4, 21 },
+  { "ja_JP.EUC-JP", "2000-01-01 08:12:21 AM", "%Y-%m-%d %I:%M:%S %p",
+    6, 0, 0, 1 },
+  { "en_US.ISO-8859-1", "2000-01-01 08:12:21 PM", "%Y-%m-%d %I:%M:%S %p",
+    6, 0, 0, 1 },
+  { "ja_JP.EUC-JP", "2001 20 \xb7\xee", "%Y %U %a", 1, 140, 4, 21 },
+  { "ja_JP.EUC-JP", "2001 21 \xb7\xee", "%Y %W %a", 1, 140, 4, 21 },
+};
+
+
+static const struct
+{
+  const char *input;
+  const char *format;
+  const char *output;
+  int wday;
+  int yday;
+} tm_tests [] =
+{
+  {"17410105012000", "%H%M%S%d%m%Y", "2000-01-05 17:41:01", 3, 4}
+};
+
+
+
+static int
+test_tm (void)
+{
+  struct tm tm;
+  size_t i;
+  int result = 0;
+  char buf[100];
+
+  for (i = 0; i < sizeof (tm_tests) / sizeof (tm_tests[0]); ++i)
+    {
+      memset (&tm, '\0', sizeof (tm));
+
+      char *ret = strptime (tm_tests[i].input, tm_tests[i].format, &tm);
+      if (ret == NULL)
+	{
+	  printf ("strptime returned NULL for `%s'\n", tm_tests[i].input);
+	  result = 1;
+	  continue;
+	}
+      else if (*ret != '\0')
+	{
+	  printf ("not all of `%s' read\n", tm_tests[i].input);
+	  result = 1;
+	}
+      strftime (buf, sizeof (buf), "%F %T", &tm);
+      printf ("strptime (\"%s\", \"%s\", ...)\n"
+	      "\tshould be: %s, wday = %d, yday = %3d\n"
+	      "\t       is: %s, wday = %d, yday = %3d\n",
+	      tm_tests[i].input, tm_tests[i].format,
+	      tm_tests[i].output,
+	      tm_tests[i].wday, tm_tests[i].yday,
+	      buf, tm.tm_wday, tm.tm_yday);
+
+      if (strcmp (buf, tm_tests[i].output) != 0)
+	{
+	  printf ("Time and date are not correct.\n");
+	  result = 1;
+	}
+      if (tm.tm_wday != tm_tests[i].wday)
+	{
+	  printf ("weekday for `%s' incorrect: %d instead of %d\n",
+		  tm_tests[i].input, tm.tm_wday, tm_tests[i].wday);
+	  result = 1;
+	}
+      if (tm.tm_yday != tm_tests[i].yday)
+	{
+	  printf ("yearday for `%s' incorrect: %d instead of %d\n",
+		  tm_tests[i].input, tm.tm_yday, tm_tests[i].yday);
+	  result = 1;
+	}
+    }
+
+  return result;
+}
+
+
+int
+main (int argc, char *argv[])
+{
+  struct tm tm;
+  size_t i;
+  int result = 0;
+
+  for (i = 0; i < sizeof (day_tests) / sizeof (day_tests[0]); ++i)
+    {
+      memset (&tm, '\0', sizeof (tm));
+
+      if (setlocale (LC_ALL, day_tests[i].locale) == NULL)
+	{
+	  printf ("cannot set locale %s: %m\n", day_tests[i].locale);
+	  exit (EXIT_FAILURE);
+	}
+
+      char *ret = strptime (day_tests[i].input, day_tests[i].format, &tm);
+      if (ret == NULL)
+	{
+	  printf ("strptime returned NULL for `%s'\n", day_tests[i].input);
+	  result = 1;
+	  continue;
+	}
+      else if (*ret != '\0')
+	{
+	  printf ("not all of `%s' read\n", day_tests[i].input);
+	  result = 1;
+	}
+
+      printf ("strptime (\"%s\", \"%s\", ...)\n"
+	      "\tshould be: wday = %d, yday = %3d, mon = %2d, mday = %2d\n"
+	      "\t       is: wday = %d, yday = %3d, mon = %2d, mday = %2d\n",
+	      day_tests[i].input, day_tests[i].format,
+	      day_tests[i].wday, day_tests[i].yday,
+	      day_tests[i].mon, day_tests[i].mday,
+	      tm.tm_wday, tm.tm_yday, tm.tm_mon, tm.tm_mday);
+
+      if (tm.tm_wday != day_tests[i].wday)
+	{
+	  printf ("weekday for `%s' incorrect: %d instead of %d\n",
+		  day_tests[i].input, tm.tm_wday, day_tests[i].wday);
+	  result = 1;
+	}
+      if (tm.tm_yday != day_tests[i].yday)
+	{
+	  printf ("yearday for `%s' incorrect: %d instead of %d\n",
+		  day_tests[i].input, tm.tm_yday, day_tests[i].yday);
+	  result = 1;
+	}
+      if (tm.tm_mon != day_tests[i].mon)
+	{
+	  printf ("month for `%s' incorrect: %d instead of %d\n",
+		  day_tests[i].input, tm.tm_mon, day_tests[i].mon);
+	  result = 1;
+	}
+      if (tm.tm_mday != day_tests[i].mday)
+	{
+	  printf ("monthday for `%s' incorrect: %d instead of %d\n",
+		  day_tests[i].input, tm.tm_mday, day_tests[i].mday);
+	  result = 1;
+	}
+    }
+
+  setlocale (LC_ALL, "C");
+
+  result |= test_tm ();
+
+  return result;
+}
Index: trunk/src/libctests/glibc/time/tst-strptime2.c
===================================================================
--- trunk/src/libctests/glibc/time/tst-strptime2.c	(revision 2036)
+++ trunk/src/libctests/glibc/time/tst-strptime2.c	(revision 2036)
@@ -0,0 +1,59 @@
+#include <limits.h>
+#include <stdio.h>
+#include <time.h>
+
+
+static const struct
+{
+  const char *fmt;
+  long int gmtoff;
+} tests[] =
+  {
+    { "1113472456 +1000", 36000 },
+    { "1113472456 -1000", -36000 },
+    { "1113472456 +10", 36000 },
+    { "1113472456 -10", -36000 },
+    { "1113472456 +1030", 37800 },
+    { "1113472456 -1030", -37800 },
+    { "1113472456 +0030", 1800 },
+    { "1113472456 -0030", -1800 },
+    { "1113472456 -1330", LONG_MAX },
+    { "1113472456 +1330", LONG_MAX },
+    { "1113472456 -1060", LONG_MAX },
+    { "1113472456 +1060", LONG_MAX },
+    { "1113472456  1030", LONG_MAX },
+  };
+#define ntests (sizeof (tests) / sizeof (tests[0]))
+
+
+int
+main (void)
+{
+  int result = 0;
+
+  for (int i = 0; i < ntests; ++i)
+    {
+      struct tm tm;
+
+      if (strptime (tests[i].fmt, "%s %z", &tm) == NULL)
+	{
+	  if (tests[i].gmtoff != LONG_MAX)
+	    {
+	      printf ("round %d: strptime unexpectedly failed\n", i);
+	      result = 1;
+	    }
+	  continue;
+	}
+
+      if (tm.tm_gmtoff != tests[i].gmtoff)
+	{
+	  printf ("round %d: tm_gmtoff is %ld\n", i, (long int) tm.tm_gmtoff);
+	  result = 1;
+	}
+    }
+
+  if (result == 0)
+    puts ("all OK");
+
+  return 0;
+}
Index: trunk/src/libctests/glibc/time/tst_wcsftime.c
===================================================================
--- trunk/src/libctests/glibc/time/tst_wcsftime.c	(revision 2036)
+++ trunk/src/libctests/glibc/time/tst_wcsftime.c	(revision 2036)
@@ -0,0 +1,28 @@
+#include <time.h>
+#include <wchar.h>
+
+int
+main (int argc, char *argv[])
+{
+  wchar_t buf[200];
+  time_t t;
+  struct tm *tp;
+  int result = 0;
+  size_t n;
+
+  time (&t);
+  tp = gmtime (&t);
+
+  n = wcsftime (buf, sizeof (buf) / sizeof (buf[0]),
+		L"%H:%M:%S  %Y-%m-%d\n", tp);
+  if (n != 21)
+    result = 1;
+
+  wprintf (L"It is now %ls", buf);
+
+  wcsftime (buf, sizeof (buf) / sizeof (buf[0]), L"%A\n", tp);
+
+  wprintf (L"The weekday is %ls", buf);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/timezone/Makefile
===================================================================
--- trunk/src/libctests/glibc/timezone/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/timezone/Makefile	(revision 2036)
@@ -0,0 +1,222 @@
+# Copyright (C) 1998,1999,2000,2002,2005 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Makefile for timezone information
+#
+subdir	:= timezone
+
+distribute := tzfile.h private.h scheck.c ialloc.c yearistype	\
+	      iso3166.tab zone.tab tzselect.ksh checktab.awk	\
+	      README
+
+extra-objs := scheck.o ialloc.o
+
+others	:= zdump zic
+tests	:= test-tz tst-timezone
+
+tzbases := africa antarctica asia australasia europe northamerica \
+	   southamerica etcetera factory \
+	   solar87 solar88 solar89
+tzlinks := backward systemv
+tzfiles := $(tzbases) $(tzlinks)
+# pacificnew doesn't compile; if it is to be used, it should be included in
+# northamerica.
+distribute += $(tzfiles) leapseconds pacificnew simplebackw
+
+generated := $(addprefix z.,$(tzfiles))
+install-sbin := zic zdump
+
+generated-dirs = testdata
+
+all: # Make this the default target; it will be defined in Rules.
+
+include ../Makeconfig	# Get objpfx defined so we can use it below.
+
+CPPFLAGS-zic = -DNOT_IN_libc
+
+# z.* use this variable.
+define nl
+
+
+endef
+ifndef avoid-generated
+ifndef inhibit_timezone_rules
+-include $(addprefix $(objpfx)z.,$(tzfiles))
+endif
+endif
+
+# Make these absolute file names.
+installed-localtime-file := $(firstword $(filter /%,$(inst_localtime-file)) \
+					$(addprefix $(inst_zonedir)/, \
+						    $(localtime-file)))
+installed-posixrules-file := $(firstword $(filter /%,$(posixrules-file)) \
+					 $(addprefix $(inst_zonedir)/, \
+						     $(posixrules-file)))
+
+ifeq ($(cross-compiling),no)
+# Don't try to install the zoneinfo files since we can't run zic.
+install-others = $(addprefix $(inst_zonedir)/,$(zonenames) \
+					      $(zonenames:%=posix/%) \
+					      $(zonenames:%=right/%)) \
+		 $(installed-localtime-file) $(installed-posixrules-file)
+endif
+
+ifeq ($(have-ksh),yes)
+install-others += $(inst_zonedir)/iso3166.tab $(inst_zonedir)/zone.tab
+install-bin-script = tzselect
+generated += tzselect
+endif
+
+include ../Rules
+
+
+$(tzfiles:%=$(objpfx)z.%): $(objpfx)z.%: % Makefile
+# Kludge alert: we use an implicit rule (in what we are generating here)
+# because that is the only way to tell Make that the one command builds all
+# the files.
+# The extra kludge for the $(tzlinks) files is necessary since running zic
+# this file requires all other files to exist.  Blech!
+	$(make-target-directory)
+	(echo 'define $*-zones'						    ;\
+	 $(AWK) '$$1 == "Zone" { print $$2 } $$1 == "Link" { print $$3 }' $^ ;\
+	 echo 'endef'							    ;\
+	 echo '$*-zones := $$(subst $$(nl), ,$$($*-zones))'		    ;\
+	 echo 'ifdef $*-zones'						    ;\
+	 if test x$(findstring $*, $(tzlinks)) != x; then		     \
+	   echo '$$(addprefix $$(inst_zonedir)/right/,$$($*-zones)): \';\
+	   echo '$$(foreach t,$$(tzbases),$$(addprefix $$(inst_zonedir)/right/,$$($$t-zones)))' ;\
+	   echo '$$(addprefix $$(inst_zonedir)/posix/,$$($*-zones)): \';\
+	   echo '$$(foreach t,$$(tzbases),$$(addprefix $$(inst_zonedir)/posix/,$$($$t-zones)))' ;\
+	   echo '$$(addprefix $$(inst_zonedir)/,$$($*-zones)): \'	    ;\
+	   echo '$$(foreach t,$$(tzbases),$$(addprefix $$(inst_zonedir)/,$$($$t-zones)))' ;\
+	 fi								    ;\
+	 echo '$$(addprefix $$(dir $$(inst_zonedir))zone%/right/,$$($*-zones)): \' ;\
+	 echo '$< $$(objpfx)zic leapseconds yearistype'			    ;\
+	 echo '	$$(tzcompile)'						    ;\
+	 echo '$$(addprefix $$(dir $$(inst_zonedir))zone%/posix/,$$($*-zones)): \' ;\
+	 echo '$< $$(objpfx)zic /dev/null yearistype'			    ;\
+	 echo '	$$(tzcompile)'						    ;\
+	 echo '$$(addprefix $$(dir $$(inst_zonedir))zone%/,$$($*-zones)): \' ;\
+	 echo '$< $$(objpfx)zic $$(leapseconds) yearistype'		    ;\
+	 echo '	$$(tzcompile)'						    ;\
+	 echo 'endif'							    ;\
+	 echo 'zonenames := $$(zonenames) $$($*-zones)'			    ;\
+	) > $@.new
+	mv $@.new $@
+
+.PHONY: echo-zonenames
+echo-zonenames:
+	@echo 'Known zones: $(zonenames)'
+
+
+# We have to use `-d $(inst_zonedir)' to explictly tell zic where to
+# place the output files although $(zonedir) is compiled in.  But the
+# user might have set $(install_root) on the command line of `make install'.
+zic-cmd = $(built-program-cmd) -d $(inst_zonedir)
+tzcompile = $(zic-cmd)$(target-zone-flavor) -L $(word 3,$^) \
+	    -y $(dir $(word 4,$^))$(notdir $(word 4,$^)) $<
+
+# The source files specify the zone names relative to the -d directory,
+# so for the posix/ and right/ flavors we need to pass -d $(inst_zonedir)/posix
+# and the like.  This magic extracts /posix or /right if it's the first
+# component after $(inst_zonedir) in the target name $@.
+target-zone-flavor = $(filter /posix /right, \
+			      /$(firstword $(subst /, , \
+					  $(patsubst $(inst_zonedir)/%,%,$@))))
+
+ifdef localtime
+$(installed-localtime-file): $(inst_zonedir)/$(localtime) $(objpfx)zic \
+			     $(+force)
+	$(make-target-directory)
+	if test -r $@; then \
+	  echo Site timezone NOT reset to Factory.; \
+	else \
+	  rm -f $@T; \
+	  $(SHELL) $(..)scripts/rellns-sh $< $@T; \
+	  mv -f $@T $@; \
+	fi
+endif
+ifdef posixrules
+$(installed-posixrules-file): $(inst_zonedir)/$(posixrules) $(objpfx)zic \
+			      $(+force)
+	$(zic-cmd) -p $(posixrules)
+endif
+
+
+$(objpfx)zic: $(objpfx)scheck.o $(objpfx)ialloc.o
+
+tz-cflags = -DTZDIR='"$(zonedir)"' \
+	    -DTZDEFAULT='"$(localtime-file)"' \
+	    -DTZDEFRULES='"$(posixrules-file)"' \
+	    -DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone
+
+CFLAGS-zdump.c = -Wno-strict-prototypes -DNOID $(tz-cflags) -DHAVE_GETTEXT
+CFLAGS-zic.c = -Wno-strict-prototypes -DNOID $(tz-cflags) -DHAVE_GETTEXT
+CFLAGS-ialloc.c = -Wno-strict-prototypes -DNOID -DHAVE_GETTEXT
+CFLAGS-scheck.c = -Wno-strict-prototypes -DNOID -DHAVE_GETTEXT
+
+# We have to make sure the data for testing the tz functions is available.
+# Don't add leapseconds here since test-tz made checks that work only without
+# leapseconds.
+testdata = $(objpfx)testdata
+define build-testdata
+GCONV_PATH=${common-objpfx}iconvdata LANGUAGE=C LC_ALL=C \
+  $(built-program-cmd) -d $(testdata) -y ./yearistype $<
+endef
+
+$(objpfx)test-tz.out: $(addprefix $(testdata)/, America/New_York Etc/UTC UTC)
+$(objpfx)tst-timezone.out: $(addprefix $(testdata)/, \
+				       Europe/Berlin Universal \
+				       Australia/Melbourne \
+				       America/Sao_Paulo Asia/Tokyo \
+				       Europe/London)
+
+test-tz-ENV = TZDIR=$(testdata)
+tst-timezone-ENV = TZDIR=$(testdata)
+
+# Note this must come second in the deps list for $(built-program-cmd) to work.
+zic-deps = $(objpfx)zic $(leapseconds) yearistype
+
+$(testdata)/America/New_York: northamerica $(zic-deps)
+	$(build-testdata)
+$(testdata)/Etc/UTC: etcetera $(zic-deps)
+	$(build-testdata)
+# Use a pattern rule to indicate the command produces both targets at once.
+# Two separate targets built separately can collide if in parallel.
+%/UTC %/Universal: simplebackw $(zic-deps) %/Etc/UTC
+	$(build-testdata)
+$(testdata)/%/Berlin $(testdata)/%/London: europe $(zic-deps)
+	$(build-testdata)
+$(testdata)/Australia/Melbourne: australasia $(zic-deps)
+	$(build-testdata)
+$(testdata)/America/Sao_Paulo: southamerica $(zic-deps)
+	$(build-testdata)
+$(testdata)/Asia/Tokyo: asia $(zic-deps)
+	$(build-testdata)
+
+
+$(objpfx)tzselect: tzselect.ksh $(common-objpfx)config.make
+	sed -e 's%@KSH@%$(KSH)%g' \
+	    -e 's%@TZDIR@%$(zonedir)%g' < $< > $@.new
+	chmod 555 $@.new
+	mv -f $@.new $@
+
+$(addprefix $(inst_zonedir)/,iso3166.tab zone.tab): \
+    $(inst_zonedir)/%: % $(+force)
+	$(do-install)
Index: trunk/src/libctests/glibc/timezone/test-tz.c
===================================================================
--- trunk/src/libctests/glibc/timezone/test-tz.c	(revision 2036)
+++ trunk/src/libctests/glibc/timezone/test-tz.c	(revision 2036)
@@ -0,0 +1,56 @@
+#include <stdlib.h>
+#include <time.h>
+#include <string.h>
+#include <stdio.h>
+
+struct {
+  const char *	env;
+  time_t	expected;
+} tests[] = {
+  {"MST",	832935315},
+  {"",		832910115},
+  {":UTC",	832910115},
+  {"UTC",	832910115},
+  {"UTC0",	832910115}
+};
+
+
+int
+main (int argc, char ** argv)
+{
+  int errors = 0;
+  struct tm tm;
+  time_t t;
+  unsigned int i;
+
+  memset (&tm, 0, sizeof (tm));
+  tm.tm_isdst = 0;
+  tm.tm_year  = 96;	/* years since 1900 */
+  tm.tm_mon   = 4;
+  tm.tm_mday  = 24;
+  tm.tm_hour  =  3;
+  tm.tm_min   = 55;
+  tm.tm_sec   = 15;
+
+  for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
+    {
+      setenv ("TZ", tests[i].env, 1);
+      t = mktime (&tm);
+      if (t != tests[i].expected)
+	{
+	  printf ("%s: flunked test %u (expected %lu, got %lu)\n",
+		  argv[0], i, (long) tests[i].expected, (long) t);
+	  ++errors;
+	}
+    }
+  if (errors == 0)
+    {
+      puts ("No errors.");
+      return EXIT_SUCCESS;
+    }
+  else
+    {
+      printf ("%d errors.\n", errors);
+      return EXIT_FAILURE;
+    }
+}
Index: trunk/src/libctests/glibc/timezone/tst-timezone.c
===================================================================
--- trunk/src/libctests/glibc/timezone/tst-timezone.c	(revision 2036)
+++ trunk/src/libctests/glibc/timezone/tst-timezone.c	(revision 2036)
@@ -0,0 +1,170 @@
+/* Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@suse.de>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+int failed = 0;
+
+struct test_times
+{
+  const char *name;
+  int daylight;
+  int timezone;
+  const char *tzname[2];
+};
+
+static const struct test_times tests[] =
+{
+  { "Europe/Amsterdam", 1, -3600, { "CET", "CEST" }},
+  { "Europe/Berlin", 1, -3600, { "CET", "CEST" }},
+  { "Europe/London", 1, 0, { "GMT", "BST" }},
+  { "Universal", 0, 0, {"UTC", "UTC" }},
+  { "Australia/Melbourne", 1, -36000, { "EST", "EST" }},
+  { "America/Sao_Paulo", 1, 10800, {"BRT", "BRST" }},
+  { "America/Chicago", 1, 21600, {"CST", "CDT" }},
+  { "America/Indianapolis", 1, 18000, {"EST", "EDT" }},
+  { "America/Los_Angeles", 1, 28800, {"PST", "PDT" }},
+  { "Asia/Tokyo", 0, -32400, {"JST", "JST" }},
+  { "Pacific/Auckland", 1, -43200, { "NZST", "NZDT" }},
+  { NULL, 0, 0 }
+};
+
+/* This string will be used for `putenv' calls.  */
+char envstring[100];
+
+static void
+print_tzvars (void)
+{
+  printf ("tzname[0]: %s\n", tzname[0]);
+  printf ("tzname[1]: %s\n", tzname[1]);
+  printf ("daylight: %d\n", daylight);
+  printf ("timezone: %ld\n", timezone);
+}
+
+
+static void
+check_tzvars (const char *name, int dayl, int timez, const char *const tznam[])
+{
+  int i;
+
+  if (daylight != dayl)
+    {
+      printf ("*** Timezone: %s, daylight is: %d but should be: %d\n",
+	      name, daylight, dayl);
+      ++failed;
+    }
+  if (timezone != timez)
+    {
+      printf ("*** Timezone: %s, timezone is: %ld but should be: %d\n",
+	      name, timezone, timez);
+      ++failed;
+    }
+  for (i = 0; i <= 1; ++i)
+    if (strcmp (tzname[i], tznam[i]) != 0)
+      {
+	printf ("*** Timezone: %s, tzname[%d] is: %s but should be: %s\n",
+		name, i, tzname[i], tznam[i]);
+	++failed;
+      }
+}
+
+
+int
+main (int argc, char ** argv)
+{
+  time_t t;
+  const struct test_times *pt;
+  char buf[BUFSIZ];
+
+  /* This should be: Fri May 15 01:02:16 1998 (UTC).  */
+  t = 895194136;
+  printf ("We use this date: %s\n", asctime (gmtime (&t)));
+
+  for (pt = tests; pt->name != NULL; ++pt)
+    {
+      /* Start with a known state */
+      printf ("Checking timezone %s\n", pt->name);
+      sprintf (buf, "TZ=%s", pt->name);
+      if (putenv (buf))
+	{
+	  puts ("putenv failed.");
+	  failed = 1;
+	}
+      tzset ();
+      print_tzvars ();
+      check_tzvars (pt->name, pt->daylight, pt->timezone, pt->tzname);
+
+      /* calling localtime shouldn't make a difference */
+      localtime (&t);
+      print_tzvars ();
+      check_tzvars (pt->name, pt->daylight, pt->timezone, pt->tzname);
+    }
+
+  /* From a post of Scott Harrington <seh4@ix.netcom.com> to the timezone
+     mailing list.  */
+  {
+    struct tm tmBuf = {0, 0, 0, 10, 3, 98, 0, 0, -1};
+    char buf[200];
+    strcpy (envstring, "TZ=Europe/London");
+    putenv (envstring);
+    t = mktime (&tmBuf);
+    snprintf (buf, sizeof (buf), "TZ=%s %ld %d %d %d %d %d %d %d %d %d",
+	      getenv ("TZ"), t,
+	      tmBuf.tm_sec, tmBuf.tm_min, tmBuf.tm_hour,
+	      tmBuf.tm_mday, tmBuf.tm_mon, tmBuf.tm_year,
+	      tmBuf.tm_wday, tmBuf.tm_yday, tmBuf.tm_isdst);
+    fputs (buf, stdout);
+    puts (" should be");
+    puts ("TZ=Europe/London 892162800 0 0 0 10 3 98 5 99 1");
+    if (strcmp (buf, "TZ=Europe/London 892162800 0 0 0 10 3 98 5 99 1") != 0)
+      {
+	failed = 1;
+	fputs (" FAILED ***", stdout);
+      }
+  }
+
+  printf("\n");
+
+  {
+    struct tm tmBuf = {0, 0, 0, 10, 3, 98, 0, 0, -1};
+    char buf[200];
+    strcpy (envstring, "TZ=GMT");
+    /* No putenv call needed!  */
+    t = mktime (&tmBuf);
+    snprintf (buf, sizeof (buf), "TZ=%s %ld %d %d %d %d %d %d %d %d %d",
+	      getenv ("TZ"), t,
+	      tmBuf.tm_sec, tmBuf.tm_min, tmBuf.tm_hour,
+	      tmBuf.tm_mday, tmBuf.tm_mon, tmBuf.tm_year,
+	      tmBuf.tm_wday, tmBuf.tm_yday, tmBuf.tm_isdst);
+    fputs (buf, stdout);
+    puts (" should be");
+    puts ("TZ=GMT 892166400 0 0 0 10 3 98 5 99 0");
+    if (strcmp (buf, "TZ=GMT 892166400 0 0 0 10 3 98 5 99 0") != 0)
+      {
+	failed = 1;
+	fputs (" FAILED ***", stdout);
+      }
+  }
+
+  return failed ? EXIT_FAILURE : EXIT_SUCCESS;
+}
Index: trunk/src/libctests/glibc/wcsmbs/Makefile
===================================================================
--- trunk/src/libctests/glibc/wcsmbs/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/wcsmbs/Makefile	(revision 2036)
@@ -0,0 +1,68 @@
+# Copyright (C) 1995-2000, 2002, 2003, 2004 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Sub-makefile for wcsmbs portion of the library.
+#
+subdir	:= wcsmbs
+
+headers	:= wchar.h
+distribute := wcwidth.h wcsmbsload.h
+
+routines := wcscat wcschr wcscmp wcscpy wcscspn wcsdup wcslen wcsncat \
+	    wcsncmp wcsncpy wcspbrk wcsrchr wcsspn wcstok wcsstr wmemchr \
+	    wmemcmp wmemcpy wmemmove wmemset wcpcpy wcpncpy wmempcpy \
+	    btowc wctob mbsinit \
+	    mbrlen mbrtowc wcrtomb mbsrtowcs wcsrtombs \
+	    mbsnrtowcs wcsnrtombs wcsnlen wcschrnul \
+	    wcstol wcstoul wcstoll wcstoull wcstod wcstold wcstof \
+	    wcstol_l wcstoul_l wcstoll_l wcstoull_l \
+	    wcstod_l wcstold_l wcstof_l \
+	    wcscoll wcsxfrm \
+	    wcwidth wcswidth \
+	    wcscoll_l wcsxfrm_l \
+	    wcscasecmp wcsncase wcscasecmp_l wcsncase_l \
+	    wcsmbsload mbsrtowcs_l
+
+tests := tst-wcstof wcsmbs-tst1 tst-wcsnlen tst-btowc tst-mbrtowc \
+	 tst-wcrtomb tst-wcpncpy tst-mbsrtowcs
+
+include ../Rules
+
+CFLAGS-wcwidth.c = -I../wctype
+CFLAGS-wcswidth.c = -I../wctype
+
+strtox-CFLAGS = -I../include -I../stdlib
+CFLAGS-wcstol.c = $(strtox-CFLAGS)
+CFLAGS-wcstoul.c = $(strtox-CFLAGS)
+CFLAGS-wcstoll.c = $(strtox-CFLAGS)
+CFLAGS-wcstoull.c = $(strtox-CFLAGS)
+CFLAGS-wcstod.c = $(strtox-CFLAGS)
+CFLAGS-wcstold.c = $(strtox-CFLAGS)
+CFLAGS-wcstof.c = $(strtox-CFLAGS)
+CFLAGS-wcstol_l.c = $(strtox-CFLAGS)
+CFLAGS-wcstoul_l.c = $(strtox-CFLAGS)
+CFLAGS-wcstoll_l.c = $(strtox-CFLAGS)
+CFLAGS-wcstoull_l.c = $(strtox-CFLAGS)
+CFLAGS-wcstod_l.c = $(strtox-CFLAGS)
+CFLAGS-wcstold_l.c = $(strtox-CFLAGS)
+CFLAGS-wcstof_l.c = $(strtox-CFLAGS)
+
+tst-btowc-ENV = LOCPATH=$(common-objpfx)localedata
+tst-mbrtowc-ENV = LOCPATH=$(common-objpfx)localedata
+tst-wcrtomb-ENV = LOCPATH=$(common-objpfx)localedata
Index: trunk/src/libctests/glibc/wcsmbs/tst-btowc.c
===================================================================
--- trunk/src/libctests/glibc/wcsmbs/tst-btowc.c	(revision 2036)
+++ trunk/src/libctests/glibc/wcsmbs/tst-btowc.c	(revision 2036)
@@ -0,0 +1,175 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <locale.h>
+#include <stdio.h>
+#include <wchar.h>
+
+
+/* Currently selected locale.  */
+static const char *current_locale;
+
+
+/* Test which should succeed.  */
+static int
+ok_test (int c, wint_t expwc)
+{
+  wint_t wc = btowc (c);
+
+  if (wc != expwc)
+    {
+      printf ("%s: btowc('%c') failed, returned L'\\x%x' instead of L'\\x%x'\n",
+	      current_locale, c, wc, expwc);
+      return 1;
+    }
+
+  return 0;
+}
+
+/* Test which should fail.  */
+static int
+fail_test (int c)
+{
+  wint_t wc = btowc (c);
+
+  if (wc != WEOF)
+    {
+      printf ("%s: btowc('%c') succeded, returned L'\\x%x' instead of WEOF\n",
+	      current_locale, c, wc);
+      return 1;
+    }
+
+  return 0;
+}
+
+
+/* Test EOF handling.  */
+static int
+eof_test (void)
+{
+  wint_t wc = btowc (EOF);
+  if (wc != WEOF)
+    {
+      printf ("%s: btowc(EOF) returned L'\\x%x', not WEOF\n",
+	      current_locale, wc);
+    }
+
+  return 0;
+}
+
+
+/* Test the btowc() function for a few locales with known character sets.  */
+int
+main (void)
+{
+  int result = 0;
+
+  current_locale = setlocale (LC_ALL, "en_US.ANSI_X3.4-1968");
+  if (current_locale == NULL)
+    {
+      puts ("cannot set locale \"en_US.ANSI_X3.4-1968\"");
+      result = 1;
+    }
+  else
+    {
+      int c;
+
+      for (c = 0; c < 128; ++c)
+	result |= ok_test (c, c);
+
+      for (c = 128; c < 256; ++c)
+	result |= fail_test (c);
+
+      result |= eof_test ();
+    }
+
+  current_locale = setlocale (LC_ALL, "de_DE.ISO-8859-1");
+  if (current_locale == NULL)
+    {
+      puts ("cannot set locale \"de_DE.ISO-8859-1\"");
+      result = 1;
+    }
+  else
+    {
+      int c;
+
+      for (c = 0; c < 256; ++c)
+	result |= ok_test (c, c);
+
+      result |= eof_test ();
+    }
+
+  current_locale = setlocale (LC_ALL, "de_DE.UTF-8");
+  if (current_locale == NULL)
+    {
+      puts ("cannot set locale \"de_DE.UTF-8\"");
+      result = 1;
+    }
+  else
+    {
+      int c;
+
+      for (c = 0; c < 128; ++c)
+	result |= ok_test (c, c);
+
+      for (c = 128; c < 256; ++c)
+	result |= fail_test (c);
+
+      result |= eof_test ();
+    }
+
+  current_locale = setlocale (LC_ALL, "hr_HR.ISO-8859-2");
+  if (current_locale == NULL)
+    {
+      puts ("cannot set locale \"hr_HR.ISO-8859-2\"");
+      result = 1;
+    }
+  else
+    {
+      static const wint_t upper_half[] =
+      {
+	0x0104, 0x02D8, 0x0141, 0x00A4, 0x013D, 0x015A, 0x00A7, 0x00A8,
+	0x0160, 0x015E, 0x0164, 0x0179, 0x00AD, 0x017D, 0x017B, 0x00B0,
+	0x0105, 0x02DB, 0x0142, 0x00B4, 0x013E, 0x015B, 0x02C7, 0x00B8,
+	0x0161, 0x015F, 0x0165, 0x017A, 0x02DD, 0x017E, 0x017C, 0x0154,
+	0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7, 0x010C,
+	0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E, 0x0110,
+	0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7, 0x0158,
+	0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF, 0x0155,
+	0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7, 0x010D,
+	0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F, 0x0111,
+	0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7, 0x0159,
+	0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9
+      };
+      int c;
+
+      for (c = 0; c < 161; ++c)
+	result |= ok_test (c, c);
+
+      for (c = 161; c < 256; ++c)
+	result |= ok_test (c, upper_half[c - 161]);
+
+      result |= eof_test ();
+    }
+
+  if (result == 0)
+    puts ("all OK");
+
+  return result;
+}
Index: trunk/src/libctests/glibc/wcsmbs/tst-mbrtowc.c
===================================================================
--- trunk/src/libctests/glibc/wcsmbs/tst-mbrtowc.c	(revision 2036)
+++ trunk/src/libctests/glibc/wcsmbs/tst-mbrtowc.c	(revision 2036)
@@ -0,0 +1,233 @@
+/* Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* We always want assert to be fully defined.  */
+#undef NDEBUG
+#include <assert.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+
+
+static int check_ascii (const char *locname);
+
+/* UTF-8 single byte feeding test for mbrtowc(),
+   contributed by Markus Kuhn <mkuhn@acm.org>.  */
+static int
+utf8_test_1 (void)
+{
+  wchar_t wc;
+  mbstate_t s;
+
+  wc = 42;			/* arbitrary number */
+  memset (&s, 0, sizeof (s));	/* get s into initial state */
+  assert (mbrtowc (&wc, "\xE2", 1, &s) == (size_t) -2);	/* 1st byte processed */
+  assert (mbrtowc (&wc, "\x89", 1, &s) == (size_t) -2);	/* 2nd byte processed */
+  assert (wc == 42);		/* no value has not been stored into &wc yet */
+  assert (mbrtowc (&wc, "\xA0", 1, &s) == 1);	/* 3nd byte processed */
+  assert (wc == 0x2260);	/* E2 89 A0 = U+2260 (not equal) decoded correctly */
+  assert (mbrtowc (&wc, "", 1, &s) == 0);	/* test final byte processing */
+  assert (wc == 0);		/* test final byte decoding */
+
+  /* The following test is by Al Viro <aviro@redhat.com>.  */
+  const char str[] = "\xe0\xa0\x80";
+
+  wc = 42;			/* arbitrary number */
+  memset (&s, 0, sizeof (s));	/* get s into initial state */
+  assert (mbrtowc (&wc, str, 1, &s) == -2);
+  assert (mbrtowc (&wc, str + 1, 2, &s) == 2);
+  assert (wc == 0x800);
+
+  wc = 42;			/* arbitrary number */
+  memset (&s, 0, sizeof (s));	/* get s into initial state */
+  assert (mbrtowc (&wc, str, 3, &s) == 3);
+  assert (wc == 0x800);
+
+  return 0;
+}
+
+/* Test for NUL byte processing via empty string.  */
+static int
+utf8_test_2 (void)
+{
+  wchar_t wc;
+  mbstate_t s;
+
+  wc = 42;			/* arbitrary number */
+  memset (&s, 0, sizeof (s));	/* get s into initial state */
+  assert (mbrtowc (NULL, "", 1, &s) == 0); /* valid terminator */
+  assert (mbsinit (&s));
+
+  wc = 42;			/* arbitrary number */
+  memset (&s, 0, sizeof (s));	/* get s into initial state */
+  assert (mbrtowc (&wc, "\xE2", 1, &s) == (size_t) -2);	/* 1st byte processed */
+  assert (mbrtowc (NULL, "", 1, &s) == (size_t) -1); /* invalid terminator */
+
+  wc = 42;			/* arbitrary number */
+  memset (&s, 0, sizeof (s));	/* get s into initial state */
+  assert (mbrtowc (&wc, "\xE2", 1, &s) == (size_t) -2);	/* 1st byte processed */
+  assert (mbrtowc (&wc, "\x89", 1, &s) == (size_t) -2);	/* 2nd byte processed */
+  assert (mbrtowc (NULL, "", 1, &s) == (size_t) -1); /* invalid terminator */
+
+  wc = 42;			/* arbitrary number */
+  memset (&s, 0, sizeof (s));	/* get s into initial state */
+  assert (mbrtowc (&wc, "\xE2", 1, &s) == (size_t) -2);	/* 1st byte processed */
+  assert (mbrtowc (&wc, "\x89", 1, &s) == (size_t) -2);	/* 2nd byte processed */
+  assert (mbrtowc (&wc, "\xA0", 1, &s) == 1);	/* 3nd byte processed */
+  assert (mbrtowc (NULL, "", 1, &s) == 0); /* valid terminator */
+  assert (mbsinit (&s));
+
+  return 0;
+}
+
+/* Test for NUL byte processing via NULL string.  */
+static int
+utf8_test_3 (void)
+{
+  wchar_t wc;
+  mbstate_t s;
+
+  wc = 42;			/* arbitrary number */
+  memset (&s, 0, sizeof (s));	/* get s into initial state */
+  assert (mbrtowc (NULL, NULL, 0, &s) == 0); /* valid terminator */
+  assert (mbsinit (&s));
+
+  wc = 42;			/* arbitrary number */
+  memset (&s, 0, sizeof (s));	/* get s into initial state */
+  assert (mbrtowc (&wc, "\xE2", 1, &s) == (size_t) -2);	/* 1st byte processed */
+  assert (mbrtowc (NULL, NULL, 0, &s) == (size_t) -1); /* invalid terminator */
+
+  wc = 42;			/* arbitrary number */
+  memset (&s, 0, sizeof (s));	/* get s into initial state */
+  assert (mbrtowc (&wc, "\xE2", 1, &s) == (size_t) -2);	/* 1st byte processed */
+  assert (mbrtowc (&wc, "\x89", 1, &s) == (size_t) -2);	/* 2nd byte processed */
+  assert (mbrtowc (NULL, NULL, 0, &s) == (size_t) -1); /* invalid terminator */
+
+  wc = 42;			/* arbitrary number */
+  memset (&s, 0, sizeof (s));	/* get s into initial state */
+  assert (mbrtowc (&wc, "\xE2", 1, &s) == (size_t) -2);	/* 1st byte processed */
+  assert (mbrtowc (&wc, "\x89", 1, &s) == (size_t) -2);	/* 2nd byte processed */
+  assert (mbrtowc (&wc, "\xA0", 1, &s) == 1);	/* 3nd byte processed */
+  assert (mbrtowc (NULL, NULL, 0, &s) == 0); /* valid terminator */
+  assert (mbsinit (&s));
+
+  return 0;
+}
+
+static int
+utf8_test (void)
+{
+  const char *locale = "de_DE.UTF-8";
+  int error = 0;
+
+  if (!setlocale (LC_CTYPE, locale))
+    {
+      fprintf (stderr, "locale '%s' not available!\n", locale);
+      exit (1);
+    }
+
+  error |= utf8_test_1 ();
+  error |= utf8_test_2 ();
+  error |= utf8_test_3 ();
+
+  return error;
+}
+
+
+int
+main (void)
+{
+  int result = 0;
+
+  /* Check mapping of ASCII range for some character sets which have
+     ASCII as a subset.  For those the wide char generated must have
+     the same value.  */
+  setlocale (LC_ALL, "C");
+  result |= check_ascii (setlocale (LC_ALL, NULL));
+
+  setlocale (LC_ALL, "de_DE.UTF-8");
+  result |= check_ascii (setlocale (LC_ALL, NULL));
+  result |= utf8_test ();
+
+  setlocale (LC_ALL, "ja_JP.EUC-JP");
+  result |= check_ascii (setlocale (LC_ALL, NULL));
+
+  return result;
+}
+
+
+static int
+check_ascii (const char *locname)
+{
+  int c;
+  int res = 0;
+
+  printf ("Testing locale \"%s\":\n", locname);
+
+  for (c = 0; c <= 127; ++c)
+    {
+      char buf[MB_CUR_MAX];
+      wchar_t wc = 0xffffffff;
+      mbstate_t s;
+      size_t n, i;
+
+      for (i = 0; i < MB_CUR_MAX; ++i)
+	buf[i] = c + i;
+
+      memset (&s, '\0', sizeof (s));
+
+      n = mbrtowc (&wc, buf, MB_CUR_MAX, &s);
+      if (n == (size_t) -1)
+	{
+	  printf ("%s: '\\x%x': encoding error\n", locname, c);
+	  ++res;
+	}
+      else if (n == (size_t) -2)
+	{
+	  printf ("%s: '\\x%x': incomplete character\n", locname, c);
+	  ++res;
+	}
+      else if (n == 0 && c != 0)
+	{
+	  printf ("%s: '\\x%x': 0 returned\n", locname, c);
+	  ++res;
+	}
+      else if (n != 0 && c == 0)
+	{
+	  printf ("%s: '\\x%x': not 0 returned\n", locname, c);
+	  ++res;
+	}
+      else if (c != 0 && n != 1)
+	{
+	  printf ("%s: '\\x%x': not 1 returned\n", locname, c);
+	  ++res;
+	}
+      else if (wc != (wchar_t) c)
+	{
+	  printf ("%s: '\\x%x': wc != L'\\x%x'\n", locname, c, c);
+	  ++res;
+	}
+    }
+
+  printf (res == 1 ? "%d error\n" : "%d errors\n", res);
+
+  return res != 0;
+}
Index: trunk/src/libctests/glibc/wcsmbs/tst-mbsrtowcs.c
===================================================================
--- trunk/src/libctests/glibc/wcsmbs/tst-mbsrtowcs.c	(revision 2036)
+++ trunk/src/libctests/glibc/wcsmbs/tst-mbsrtowcs.c	(revision 2036)
@@ -0,0 +1,65 @@
+/* Test NUL handling of mbsrtowcs.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+
+int
+main (void)
+{
+  const unsigned char buf[] = { 'a', 'b', '\0', 'c', 'd', '\0', 'e' };
+  wchar_t out[sizeof (buf)];
+  memset (out, '\xff', sizeof (out));
+
+  mbstate_t state;
+  memset (&state, '\0', sizeof (state));
+
+  const char *in = buf;
+  size_t n = mbsrtowcs (out, &in, sizeof (out) / sizeof (wchar_t), &state);
+
+  int result = 0;
+  if (n != 2)
+    {
+      printf ("n = %zu, expected 2\n", n);
+      result = 1;
+    }
+  if (in != NULL)
+    {
+      printf ("in = %p, expected NULL\n", in);
+      result = 1;
+    }
+  if (out[0] != L'a')
+    {
+      printf ("out[0] = L'%lc', expected L'a'\n", (wint_t) out[0]);
+      result = 1;
+    }
+  if (out[1] != L'b')
+    {
+      printf ("out[1] = L'%lc', expected L'b'\n", (wint_t) out[1]);
+      result = 1;
+    }
+  if (out[2] != L'\0')
+    {
+      printf ("out[2] = L'%lc', expected L'\\0'\n", (wint_t) out[2]);
+      result = 1;
+    }
+  return result;
+}
Index: trunk/src/libctests/glibc/wcsmbs/tst-wcpncpy.c
===================================================================
--- trunk/src/libctests/glibc/wcsmbs/tst-wcpncpy.c	(revision 2036)
+++ trunk/src/libctests/glibc/wcsmbs/tst-wcpncpy.c	(revision 2036)
@@ -0,0 +1,77 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <wchar.h>
+
+
+int
+main (void)
+{
+  int result = 0;
+
+  const wchar_t src[] = L"0";
+  wchar_t dest[21];
+  wmemset (dest, L'\0', 10);
+  wchar_t *endp = wcpncpy (dest, src, 2);
+  if (wcscmp (dest, src) != 0)
+    {
+      result = 1;
+      puts ("L\"0\" string test failed");
+    }
+  if (endp != dest + 1)
+    {
+      result = 1;
+      puts ("return value of L\"0\" string call incorrect");
+    }
+
+  const wchar_t src2[] = L"abc";
+  endp = wcpncpy (dest, src2, 2);
+  if (endp != dest + 2)
+    {
+      result = 1;
+      puts ("return value of limited call incorrect");
+    }
+
+  const wchar_t src3[] = L"";
+  endp = wcpncpy (dest, src3, 2);
+  if (endp != dest)
+    {
+      result = 1;
+      puts ("return value of empty string call incorrect");
+    }
+
+  const wchar_t src4[] = L"abcdefghijklmnopqrstuvwxyz";
+  endp = wcpncpy (dest, src4, 2);
+  if (endp != dest + 2)
+    {
+      result = 1;
+      puts ("return value of long string call incorrect");
+    }
+
+  const wchar_t src5[] = L"ab";
+  endp = wcpncpy (dest, src5, 20);
+  if (endp != dest + 2)
+    {
+      result = 1;
+      puts ("return value of large limit call incorrect");
+    }
+
+  return result;
+}
Index: trunk/src/libctests/glibc/wcsmbs/tst-wcrtomb.c
===================================================================
--- trunk/src/libctests/glibc/wcsmbs/tst-wcrtomb.c	(revision 2036)
+++ trunk/src/libctests/glibc/wcsmbs/tst-wcrtomb.c	(revision 2036)
@@ -0,0 +1,95 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+
+
+static int check_ascii (const char *locname);
+
+
+int
+main (void)
+{
+  int result = 0;
+
+  /* Check mapping of ASCII range for some character sets which have
+     ASCII as a subset.  For those the wide char generated must have
+     the same value.  */
+  setlocale (LC_ALL, "C");
+  result |= check_ascii (setlocale (LC_ALL, NULL));
+
+  setlocale (LC_ALL, "de_DE.UTF-8");
+  result |= check_ascii (setlocale (LC_ALL, NULL));
+
+  setlocale (LC_ALL, "ja_JP.EUC-JP");
+  result |= check_ascii (setlocale (LC_ALL, NULL));
+
+  return result;
+}
+
+
+static int
+check_ascii (const char *locname)
+{
+  wchar_t wc;
+  int res = 0;
+
+  printf ("Testing locale \"%s\":\n", locname);
+
+  for (wc = 0; wc <= 127; ++wc)
+    {
+      char buf[2 * MB_CUR_MAX];
+      mbstate_t s;
+      size_t n;
+
+      memset (buf, '\xff', sizeof (buf));
+      memset (&s, '\0', sizeof (s));
+
+      n = wcrtomb (buf, wc, &s);
+      if (n == (size_t) -1)
+	{
+	  printf ("%s: '\\x%x': encoding error\n", locname, (int) wc);
+	  ++res;
+	}
+      else if (n == 0)
+	{
+	  printf ("%s: '\\x%x': 0 returned\n", locname, (int) wc);
+	  ++res;
+	}
+      else if (n != 1)
+	{
+	  printf ("%s: '\\x%x': not 1 returned\n", locname, (int) wc);
+	  ++res;
+	}
+      else if (wc != (wchar_t) buf[0])
+	{
+	  printf ("%s: L'\\x%x': buf[0] != '\\x%x'\n", locname, (int) wc,
+		  (int) wc);
+	  ++res;
+	}
+    }
+
+  printf (res == 1 ? "%d error\n" : "%d errors\n", res);
+
+  return res != 0;
+}
Index: trunk/src/libctests/glibc/wcsmbs/tst-wcsnlen.c
===================================================================
--- trunk/src/libctests/glibc/wcsmbs/tst-wcsnlen.c	(revision 2036)
+++ trunk/src/libctests/glibc/wcsmbs/tst-wcsnlen.c	(revision 2036)
@@ -0,0 +1,51 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <wchar.h>
+
+#define TEST(Str, Max, Exp) \
+  n = wcsnlen (L##Str, Max);						      \
+  if (n != Exp)								      \
+    {									      \
+      result = 1;							      \
+      printf ("wcsnlen (L\"%s\", %d) = %d, not %d\n", Str, Max, n, Exp);      \
+    }
+
+int
+main (void)
+{
+  int result = 0;
+  int n;
+
+  TEST ("0123456789", 0, 0);
+  TEST ("0123456789", 1, 1);
+  TEST ("0123456789", 2, 2);
+  TEST ("0123456789", 3, 3);
+  TEST ("0123456789", 4, 4);
+  TEST ("0123456789", 5, 5);
+  TEST ("0123456789", 6, 6);
+  TEST ("0123456789", 7, 7);
+  TEST ("0123456789", 8, 8);
+  TEST ("0123456789", 9, 9);
+
+  TEST ("01234", 9, 5);
+
+  return result;
+}
Index: trunk/src/libctests/glibc/wcsmbs/tst-wcstof.c
===================================================================
--- trunk/src/libctests/glibc/wcsmbs/tst-wcstof.c	(revision 2036)
+++ trunk/src/libctests/glibc/wcsmbs/tst-wcstof.c	(revision 2036)
@@ -0,0 +1,23 @@
+#define _GNU_SOURCE 1
+#include <wchar.h>
+#include <stdio.h>
+#include <string.h>
+#include <wctype.h>
+
+int
+main (void)
+{
+  int result = 0;
+  char buf[100];
+  wchar_t tmp[3];
+  tmp[0] = '8';
+  tmp[1] = '1';
+  tmp[2] = 0;
+
+  snprintf (buf, 100, "%S = %f", tmp, wcstof (tmp, NULL));
+  printf ("\"%s\" -> %s\n", buf,
+	  strcmp (buf, "81 = 81.000000") == 0 ? "okay" : "buggy");
+  result |= strcmp (buf, "81 = 81.000000") != 0;
+
+  return result;
+}
Index: trunk/src/libctests/glibc/wcsmbs/wcsmbs-tst1.c
===================================================================
--- trunk/src/libctests/glibc/wcsmbs/wcsmbs-tst1.c	(revision 2036)
+++ trunk/src/libctests/glibc/wcsmbs/wcsmbs-tst1.c	(revision 2036)
@@ -0,0 +1,59 @@
+/* Based on a test program by Won Kyu Park <wkpark@chem.skku.ac.kr>.  */
+
+#include <wchar.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wctype.h>
+#include <locale.h>
+
+int
+main (void)
+{
+  int test = 0;
+  int idx = 0;
+  char buf[100], *pchar;
+  wchar_t tmp[10];
+  wchar_t tmp1[] = { L'W', L'o', L'r', L'l', L'd', L'\0' };
+  char str[] = "Hello";
+  int result = 0;
+
+  pchar = setlocale (LC_ALL, "");
+  printf ("locale : %s\n",pchar);
+  printf ("MB_CUR_MAX %Zd\n", MB_CUR_MAX);
+
+  puts ("---- test 1 ------");
+  test = mbstowcs (tmp, str, (strlen (str) + 1) * sizeof (char));
+  printf ("size of string by mbstowcs %d\n", test);
+  if (test != strlen (str))
+    result = 1;
+  idx += wctomb (&buf[0], tmp[0]);
+  idx += wctomb (&buf[idx], tmp[1]);
+  buf[idx] = 0;
+  printf ("orig string %s\n", str);
+  printf ("string by wctomb %s\n", buf);
+  printf ("string by %%C %C", (wint_t) tmp[0]);
+  if (tmp[0] != L'H')
+    result = 1;
+  printf ("%C\n", (wint_t) tmp[1]);
+  if (tmp[1] != L'e')
+    result = 1;
+  printf ("string by %%S %S\n", tmp);
+  if (wcscmp (tmp, L"Hello") != 0)
+    result = 1;
+  puts ("---- test 2 ------");
+  printf ("wchar string %S\n", tmp1);
+  printf ("wchar %C\n", (wint_t) tmp1[0]);
+  test = wcstombs (buf, tmp1, (wcslen (tmp1) + 1) * sizeof (wchar_t));
+  printf ("size of string by wcstombs %d\n", test);
+  if (test != wcslen (tmp1))
+    result = 1;
+  test = wcslen (tmp1);
+  printf ("size of string by wcslen %d\n", test);
+  printf ("char %s\n", buf);
+  if (strcmp (buf, "World") != 0)
+    result = 1;
+  puts ("------------------");
+
+  return result;
+}
Index: trunk/src/libctests/glibc/wctype/Makefile
===================================================================
--- trunk/src/libctests/glibc/wctype/Makefile	(revision 2036)
+++ trunk/src/libctests/glibc/wctype/Makefile	(revision 2036)
@@ -0,0 +1,31 @@
+# Copyright (C) 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+#	Sub-makefile for wctype portion of the library.
+#
+subdir	:= wctype
+
+headers		:= wctype.h
+distribute	:= wchar-lookup.h
+routines	:= wcfuncs wctype iswctype wctrans towctrans \
+		   wcfuncs_l wctype_l iswctype_l wctrans_l towctrans_l
+
+tests	:= test_wctype test_wcfuncs
+
+include ../Rules
Index: trunk/src/libctests/glibc/wctype/test_wcfuncs.c
===================================================================
--- trunk/src/libctests/glibc/wctype/test_wcfuncs.c	(revision 2036)
+++ trunk/src/libctests/glibc/wctype/test_wcfuncs.c	(revision 2036)
@@ -0,0 +1,88 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <wctype.h>
+
+int
+main (int argc, char *argv[])
+{
+  int result = 0;
+  wint_t ch;
+
+
+  for (ch = 0; ch < 128; ++ch)
+    {
+      if (iswlower (ch))
+	{
+	  /* Get corresponding upper case character.  */
+	  wint_t up = towupper (ch);
+	  /* This should have no effect.  */
+	  wint_t low  = towlower (ch);
+
+	  if ((ch != low) || (up == ch) || (up == low))
+	    {
+	      printf ("iswlower/towupper/towlower for character \\%x failed\n", ch);
+	      result++;
+	    }
+	}
+      if (iswupper (ch))
+	{
+	  /* Get corresponding lower case character.  */
+	  wint_t low = towlower (ch);
+	  /* This should have no effect.  */
+	  wint_t up  = towupper (ch);
+
+	  if ((ch != up) || (low == ch) || (up == low))
+	    {
+	      printf ("iswupper/towlower/towupper for character \\%x failed\n", ch);
+	      result++;
+	    }
+	}
+    }
+
+  /* Finally some specific tests.  */
+  ch = L'A';
+  if (!iswupper (ch) || iswlower (ch))
+    {
+      printf ("!iswupper/iswlower (L'A') failed\n");
+      result++;
+
+    }
+  ch = L'a';
+  if (iswupper (ch) || !iswlower (ch))
+    {
+      printf ("iswupper/!iswlower (L'a') failed\n");
+      result++;
+    }
+  if (towlower (L'A') != L'a')
+    {
+      printf ("towlower(L'A') failed\n");
+      result++;
+    }
+  if (towupper (L'a') != L'A')
+    {
+      printf ("towupper(L'a') failed\n");
+      result++;
+    }
+
+  if (result == 0)
+    puts ("All test successful!");
+  return result != 0;
+}
Index: trunk/src/libctests/glibc/wctype/test_wctype.c
===================================================================
--- trunk/src/libctests/glibc/wctype/test_wctype.c	(revision 2036)
+++ trunk/src/libctests/glibc/wctype/test_wctype.c	(revision 2036)
@@ -0,0 +1,83 @@
+/* Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <wctype.h>
+
+int
+main (int argc, char *argv[])
+{
+  int result = 0;
+  wctype_t bit_alnum = wctype ("alnum");
+  wctype_t bit_alpha = wctype ("alpha");
+  wctype_t bit_cntrl = wctype ("cntrl");
+  wctype_t bit_digit = wctype ("digit");
+  wctype_t bit_graph = wctype ("graph");
+  wctype_t bit_lower = wctype ("lower");
+  wctype_t bit_print = wctype ("print");
+  wctype_t bit_punct = wctype ("punct");
+  wctype_t bit_space = wctype ("space");
+  wctype_t bit_upper = wctype ("upper");
+  wctype_t bit_xdigit = wctype ("xdigit");
+  int ch;
+
+  if (wctype ("does not exist") != 0)
+    {
+      puts ("wctype return value != 0 for non existing property");
+      result = 1;
+    }
+
+  for (ch = 0; ch < 256; ++ch)
+    {
+#define TEST(test) \
+      do								      \
+	{								      \
+	  if ((is##test (ch) == 0) != (iswctype (ch, bit_##test) == 0))	      \
+	    {								      \
+	      printf ("`iswctype' class `%s' test "			      \
+		      "for character \\%o failed\n", #test, ch);	      \
+	      result = 1;						      \
+	    }								      \
+	  if ((is##test (ch) == 0) != (isw##test (ch) == 0))		      \
+	    {								      \
+	      printf ("`isw%s' test for character \\%o failed\n",	      \
+		      #test, ch);					      \
+	      result = 1;						      \
+	    }								      \
+	 }								      \
+      while (0)
+
+      TEST (alnum);
+      TEST (alpha);
+      TEST (cntrl);
+      TEST (digit);
+      TEST (graph);
+      TEST (lower);
+      TEST (print);
+      TEST (punct);
+      TEST (space);
+      TEST (upper);
+      TEST (xdigit);
+    }
+
+  if (result == 0)
+    puts ("All test successful!");
+  return result;
+}
