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

[commits] r7685 - in /fsf/trunk/libc: ./ nptl/ posix/ posix/rxspencer/ resolv/nss_dns/ sysdeps/unix/sysv/linux/s390/ sysdeps/unix/sysv...



Author: eglibc
Date: Thu Jan  8 00:02:50 2009
New Revision: 7685

Log:
Import glibc-mainline for 2009-01-08

Added:
    fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/Versions
    fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/bits/libc-vdso.h
    fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/gettimeofday.c
    fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/init-first.c
Modified:
    fsf/trunk/libc/ChangeLog
    fsf/trunk/libc/nptl/allocatestack.c
    fsf/trunk/libc/posix/bug-regex17.c
    fsf/trunk/libc/posix/regcomp.c
    fsf/trunk/libc/posix/regex_internal.c
    fsf/trunk/libc/posix/regex_internal.h
    fsf/trunk/libc/posix/regexec.c
    fsf/trunk/libc/posix/rxspencer/tests
    fsf/trunk/libc/resolv/nss_dns/dns-host.c
    fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/Makefile
    fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
    fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h

Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Thu Jan  8 00:02:50 2009
@@ -1,3 +1,43 @@
+2009-01-05  Paolo Bonzini  <bonzini@xxxxxxx>
+
+	[BZ 697]
+	* posix/regexec.c (prune_impossible_nodes): Handle sifted_states[0]
+	being NULL also if there are no backreferences.
+	* posix/rxspencer/tests: Add testcases.
+
+2009-01-04  Paolo Bonzini  <bonzini@xxxxxxx>
+
+	[BZ 9697]
+	* posix/bug-regex17.c: Add testcases.
+	* posix/regcomp.c (re_compile_fastmap_iter): Rewrite COMPLEX_BRACKET
+	handling.
+
+2009-01-05  Martin Schwidefsky  <schwidefsky@xxxxxxxxxx>
+
+	* sysdeps/unix/sysv/linux/s390/bits/libc-vdso.h: New file.
+	* sysdeps/unix/sysv/linux/s390/gettimeofday.c: New file.
+	* sysdeps/unix/sysv/linux/s390/init-first.c: New file.
+	* sysdeps/unix/sysv/linux/s390/Makefile (sysdep_routines): Add dl-vdso
+	for elf subdir.
+	* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h (INLINE_VSYSCALL,
+	INTERNAL_VSYSCALL, INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK,
+	INTERNAL_SYSCALL_NCS, HAVE_CLOCK_GETRES_VSYSCALL and
+	HAVE_CLOCK_GETTIME_VSYSCALL: Define.
+	* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h: Likewise.
+	* sysdeps/unix/sysv/linux/s390/Versions: New file.
+
+2008-12-31  Paolo Bonzini  <bonzini@xxxxxxx>
+
+	* posix/regcomp.c (re_compile_fastmap_iter): Use __mbrtowc.
+	* posix/regex_internal.c (build_wcs_buffer, build_wcs_upper_buffer,
+	re_string_skip_chars, re_string_reconstruct): Likewise.
+	* posix/regex_internal.h [!_LIBC] (__mbrtowc): New #define.
+
+2008-12-31  Rafael Avila de Espindola  <espindola@xxxxxxxxxx>
+
+	* resolv/nss_dns/dns-host.c (_nss_dns_gethostbyaddr2_r): Check and
+	adjust the buffer alignment.
+
 2009-01-07  Samuel Thibault  <samuel.thibault@xxxxxxxxxxxx>
 
 	* sysdeps/mach/hurd/Makefile (sysdep_headers) [subdir=socket]:

Modified: fsf/trunk/libc/nptl/allocatestack.c
==============================================================================
--- fsf/trunk/libc/nptl/allocatestack.c (original)
+++ fsf/trunk/libc/nptl/allocatestack.c Thu Jan  8 00:02:50 2009
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2007, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 2002.
 
@@ -112,6 +112,11 @@
 /* List of the stacks in use.  */
 static LIST_HEAD (stack_used);
 
+/* We need to record what list operations we are going to do so that,
+   in case of an asynchronous interruption due to a fork() call, we
+   can correct for the work.  */
+static uintptr_t in_flight_stack;
+
 /* 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));
@@ -125,6 +130,36 @@
 
 /* Check whether the stack is still used or not.  */
 #define FREE_P(descr) ((descr)->tid <= 0)
+
+
+static void
+stack_list_del (list_t *elem)
+{
+  in_flight_stack = (uintptr_t) elem;
+
+  atomic_write_barrier ();
+
+  list_del (elem);
+
+  atomic_write_barrier ();
+
+  in_flight_stack = 0;
+}
+
+
+static void
+stack_list_add (list_t *elem, list_t *list)
+{
+  in_flight_stack = (uintptr_t) elem | 1;
+
+  atomic_write_barrier ();
+
+  list_add (elem, list);
+
+  atomic_write_barrier ();
+
+  in_flight_stack = 0;
+}
 
 
 /* We create a double linked list of all cache entries.  Double linked
@@ -179,10 +214,10 @@
     }
 
   /* Dequeue the entry.  */
-  list_del (&result->list);
+  stack_list_del (&result->list);
 
   /* And add to the list of stacks in use.  */
-  list_add (&result->list, &stack_used);
+  stack_list_add (&result->list, &stack_used);
 
   /* And decrease the cache size.  */
   stack_cache_actsize -= result->stackblock_size;
@@ -230,7 +265,7 @@
       if (FREE_P (curr))
 	{
 	  /* Unlink the block.  */
-	  list_del (entry);
+	  stack_list_del (entry);
 
 	  /* Account for the freed memory.  */
 	  stack_cache_actsize -= curr->stackblock_size;
@@ -260,7 +295,7 @@
   /* 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_list_add (&stack->list, &stack_cache);
 
   stack_cache_actsize += stack->stackblock_size;
   if (__builtin_expect (stack_cache_actsize > stack_cache_maxsize, 0))
@@ -547,7 +582,7 @@
 	  lll_lock (stack_cache_lock, LLL_PRIVATE);
 
 	  /* And add to the list of stacks in use.  */
-	  list_add (&pd->list, &stack_used);
+	  stack_list_add (&pd->list, &stack_used);
 
 	  lll_unlock (stack_cache_lock, LLL_PRIVATE);
 
@@ -601,7 +636,7 @@
 	      lll_lock (stack_cache_lock, LLL_PRIVATE);
 
 	      /* Remove the thread from the list.  */
-	      list_del (&pd->list);
+	      stack_list_del (&pd->list);
 
 	      lll_unlock (stack_cache_lock, LLL_PRIVATE);
 
@@ -703,7 +738,7 @@
 
   /* Remove the thread from the list of threads with user defined
      stacks.  */
-  list_del (&pd->list);
+  stack_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
@@ -776,7 +811,47 @@
 {
   struct pthread *self = (struct pthread *) THREAD_SELF;
 
-  /* No locking necessary.  The caller is the only stack in use.  */
+  /* No locking necessary.  The caller is the only stack in use.  But
+     we have to be aware that we might have interrupted a list
+     operation.  */
+
+  if (in_flight_stack != 0)
+    {
+      bool add_p = in_flight_stack & 1;
+      list_t *elem = (list_t *) (in_flight_stack & ~UINTMAX_C (1));
+
+      if (add_p)
+	{
+	  /* We always add at the beginning of the list.  So in this
+	     case we only need to check the beginning of these lists.  */
+	  int check_list (list_t *l)
+	  {
+	    if (l->next->prev != l)
+	      {
+		assert (l->next->prev == elem);
+
+		elem->next = l->next;
+		elem->prev = l;
+		l->next = elem;
+
+		return 1;
+	      }
+
+	    return 0;
+	  }
+
+	  if (check_list (&stack_used) == 0)
+	    (void) check_list (&stack_cache);
+	}
+      else
+	{
+	  /* We can simply always replay the delete operation.  */
+	  elem->next->prev = elem->prev;
+	  elem->prev->next = elem->next;
+	}
+
+      in_flight_stack = 0;
+    }
 
   /* Mark all stacks except the still running one as free.  */
   list_t *runp;
@@ -829,7 +904,7 @@
   /* 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);
+  stack_list_del (&self->list);
 
   /* Re-initialize the lists for all the threads.  */
   INIT_LIST_HEAD (&stack_used);
@@ -838,7 +913,7 @@
   if (__builtin_expect (THREAD_GETMEM (self, user_stack), 0))
     list_add (&self->list, &__stack_user);
   else
-    list_add (&self->list, &stack_used);
+    stack_list_add (&self->list, &stack_used);
 
   /* There is one thread running.  */
   __nptl_nthreads = 1;

Modified: fsf/trunk/libc/posix/bug-regex17.c
==============================================================================
--- fsf/trunk/libc/posix/bug-regex17.c (original)
+++ fsf/trunk/libc/posix/bug-regex17.c Thu Jan  8 00:02:50 2009
@@ -1,5 +1,5 @@
-/* Turkish regular expression tests.
-   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* German regular expression tests.
+   Copyright (C) 2002, 2003, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Jakub Jelinek <jakub@xxxxxxxxxx>, 2002.
 
@@ -33,10 +33,10 @@
   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  */
+  /* U+00C4	\xc3\x84	LATIN CAPITAL LETTER A WITH DIAERESIS
+     U+00D6	\xc3\x96	LATIN CAPITAL LETTER O WITH DIAERESIS
+     U+00E4	\xc3\xa4	LATIN SMALL LETTER A WITH DIAERESIS
+     U+00F6	\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,
@@ -45,10 +45,22 @@
     { { 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 } } },
+
+  /* Tests for bug 9697:
+     U+00DF	\xc3\x9f	LATIN SMALL LETTER SHARP S
+     U+02DA	\xcb\x9a	RING ABOVE
+     U+02E2	\xcb\xa2	MODIFIER LETTER SMALL S  */
+  { "[a-z]|[^a-z]", "\xcb\xa2", REG_EXTENDED, 2,
+    { { 0, 2 }, { -1, -1 } } },
+  { "[a-z]", "\xc3\x9f", REG_EXTENDED, 2,
+    { { 0, 2 }, { -1, -1 } } },
+  { "[^a-z]", "\xcb\x9a", REG_EXTENDED, 2,
+    { { 0, 2 }, { -1, -1 } } },
 };
 
-int
-main (void)
+
+static int
+do_test (void)
 {
   regex_t re;
   regmatch_t rm[5];
@@ -93,3 +105,6 @@
 
   return ret;
 }
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"

Modified: fsf/trunk/libc/posix/regcomp.c
==============================================================================
--- fsf/trunk/libc/posix/regcomp.c (original)
+++ fsf/trunk/libc/posix/regcomp.c Thu Jan  8 00:02:50 2009
@@ -1,5 +1,6 @@
 /* Extended regular expression matching and search library.
-   Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
+   Copyright (C) 2002,2003,2004,2005,2006,2007,2009
+   Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Isamu Hasegawa <isamu@xxxxxxxxxxxxxx>.
 
@@ -327,8 +328,8 @@
 		     && dfa->nodes[node].mb_partial)
 		*p++ = dfa->nodes[node].opr.c;
 	      memset (&state, '\0', sizeof (state));
-	      if (mbrtowc (&wc, (const char *) buf, p - buf,
-			   &state) == p - buf
+	      if (__mbrtowc (&wc, (const char *) buf, p - buf,
+			     &state) == p - buf
 		  && (__wcrtomb ((char *) buf, towlower (wc), &state)
 		      != (size_t) -1))
 		re_set_fastmap (fastmap, 0, buf[0]);
@@ -350,47 +351,67 @@
 #ifdef RE_ENABLE_I18N
       else if (type == COMPLEX_BRACKET)
 	{
+	  re_charset_t *cset = dfa->nodes[node].opr.mbcset;
 	  int i;
-	  re_charset_t *cset = dfa->nodes[node].opr.mbcset;
-	  if (cset->non_match || cset->ncoll_syms || cset->nequiv_classes
-	      || cset->nranges || cset->nchar_classes)
-	    {
+
 # ifdef _LIBC
-	      if (_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES) != 0)
+	  /* See if we have to try all bytes which start multiple collation
+	     elements.
+	     e.g. In da_DK, we want to catch 'a' since "aa" is a valid
+		  collation element, and don't catch 'b' since 'b' is
+		  the only collation element which starts from 'b' (and
+		  it is caught by SIMPLE_BRACKET).  */
+	      if (_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES) != 0
+		  && (cset->ncoll_syms || cset->nranges))
 		{
-		  /* In this case we want to catch the bytes which are
-		     the first byte of any collation elements.
-		     e.g. In da_DK, we want to catch 'a' since "aa"
-			  is a valid collation element, and don't catch
-			  'b' since 'b' is the only collation element
-			  which starts from 'b'.  */
 		  const int32_t *table = (const int32_t *)
 		    _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
 		  for (i = 0; i < SBC_MAX; ++i)
 		    if (table[i] < 0)
 		      re_set_fastmap (fastmap, icase, i);
 		}
-# else
-	      if (dfa->mb_cur_max > 1)
-		for (i = 0; i < SBC_MAX; ++i)
-		  if (__btowc (i) == WEOF)
-		    re_set_fastmap (fastmap, icase, i);
-# endif /* not _LIBC */
+# endif /* _LIBC */
+
+	  /* See if we have to start the match at all multibyte characters,
+	     i.e. where we would not find an invalid sequence.  This only
+	     applies to multibyte character sets; for single byte character
+	     sets, the SIMPLE_BRACKET again suffices.  */
+	  if (dfa->mb_cur_max > 1
+	      && (cset->nchar_classes || cset->non_match
+# ifdef _LIBC
+		  || cset->nequiv_classes
+# endif /* _LIBC */
+		 ))
+	    {
+	      unsigned char c = 0;
+	      do
+		{
+		  mbstate_t mbs;
+		  memset (&mbs, 0, sizeof (mbs));
+		  if (__mbrtowc (NULL, (char *) &c, 1, &mbs) == (size_t) -2)
+		    re_set_fastmap (fastmap, false, (int) c);
+		}
+	      while (++c != 0);
 	    }
-	  for (i = 0; i < cset->nmbchars; ++i)
+
+	  else
 	    {
-	      char buf[256];
-	      mbstate_t state;
-	      memset (&state, '\0', sizeof (state));
-	      if (__wcrtomb (buf, cset->mbchars[i], &state) != (size_t) -1)
-		re_set_fastmap (fastmap, icase, *(unsigned char *) buf);
-	      if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
+	      /* ... Else catch all bytes which can start the mbchars.  */
+	      for (i = 0; i < cset->nmbchars; ++i)
 		{
-		  if (__wcrtomb (buf, towlower (cset->mbchars[i]), &state)
-		      != (size_t) -1)
-		    re_set_fastmap (fastmap, 0, *(unsigned char *) buf);
-		}
-	    }
+		  char buf[256];
+		  mbstate_t state;
+		  memset (&state, '\0', sizeof (state));
+		  if (__wcrtomb (buf, cset->mbchars[i], &state) != (size_t) -1)
+		    re_set_fastmap (fastmap, icase, *(unsigned char *) buf);
+		  if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
+		    {
+		      if (__wcrtomb (buf, towlower (cset->mbchars[i]), &state)
+			  != (size_t) -1)
+			re_set_fastmap (fastmap, false, *(unsigned char *) buf);
+		    }
+ 		}
+ 	    }
 	}
 #endif /* RE_ENABLE_I18N */
       else if (type == OP_PERIOD

Modified: fsf/trunk/libc/posix/regex_internal.c
==============================================================================
--- fsf/trunk/libc/posix/regex_internal.c (original)
+++ fsf/trunk/libc/posix/regex_internal.c Thu Jan  8 00:02:50 2009
@@ -229,7 +229,7 @@
 	}
       else
 	p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx;
-      mbclen = mbrtowc (&wc, p, remain_len, &pstr->cur_state);
+      mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state);
       if (BE (mbclen == (size_t) -2, 0))
 	{
 	  /* The buffer doesn't have enough space, finish to build.  */
@@ -299,9 +299,9 @@
 
 	  remain_len = end_idx - byte_idx;
 	  prev_st = pstr->cur_state;
-	  mbclen = mbrtowc (&wc,
-			    ((const char *) pstr->raw_mbs + pstr->raw_mbs_idx
-			     + byte_idx), remain_len, &pstr->cur_state);
+	  mbclen = __mbrtowc (&wc,
+			      ((const char *) pstr->raw_mbs + pstr->raw_mbs_idx
+			       + byte_idx), remain_len, &pstr->cur_state);
 	  if (BE (mbclen + 2 > 2, 1))
 	    {
 	      wchar_t wcu = wc;
@@ -369,7 +369,7 @@
 	  }
 	else
 	  p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + src_idx;
-	mbclen = mbrtowc (&wc, p, remain_len, &pstr->cur_state);
+	mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state);
 	if (BE (mbclen + 2 > 2, 1))
 	  {
 	    wchar_t wcu = wc;
@@ -491,8 +491,8 @@
       int remain_len;
       remain_len = pstr->len - rawbuf_idx;
       prev_st = pstr->cur_state;
-      mbclen = mbrtowc (&wc, (const char *) pstr->raw_mbs + rawbuf_idx,
-			remain_len, &pstr->cur_state);
+      mbclen = __mbrtowc (&wc, (const char *) pstr->raw_mbs + rawbuf_idx,
+			  remain_len, &pstr->cur_state);
       if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0))
 	{
 	  /* We treat these cases as a single byte character.  */
@@ -734,8 +734,8 @@
 			  /* XXX Don't use mbrtowc, we know which conversion
 			     to use (UTF-8 -> UCS4).  */
 			  memset (&cur_state, 0, sizeof (cur_state));
-			  mbclen = mbrtowc (&wc2, (const char *) p, mlen,
-					    &cur_state);
+			  mbclen = __mbrtowc (&wc2, (const char *) p, mlen,
+					      &cur_state);
 			  if (raw + offset - p <= mbclen
 			      && mbclen < (size_t) -2)
 			    {

Modified: fsf/trunk/libc/posix/regex_internal.h
==============================================================================
--- fsf/trunk/libc/posix/regex_internal.h (original)
+++ fsf/trunk/libc/posix/regex_internal.h Thu Jan  8 00:02:50 2009
@@ -116,6 +116,7 @@
 # define __wctype wctype
 # define __iswctype iswctype
 # define __btowc btowc
+# define __mbrtowc mbrtowc
 # define __mempcpy mempcpy
 # define __wcrtomb wcrtomb
 # define __regfree regfree

Modified: fsf/trunk/libc/posix/regexec.c
==============================================================================
--- fsf/trunk/libc/posix/regexec.c (original)
+++ fsf/trunk/libc/posix/regexec.c Thu Jan  8 00:02:50 2009
@@ -1,5 +1,5 @@
 /* Extended regular expression matching and search library.
-   Copyright (C) 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Isamu Hasegawa <isamu@xxxxxxxxxxxxxx>.
 
@@ -1004,6 +1004,11 @@
       re_node_set_free (&sctx.limits);
       if (BE (ret != REG_NOERROR, 0))
 	goto free_return;
+      if (sifted_states[0] == NULL)
+	{
+	  ret = REG_NOMATCH;
+	  goto free_return;
+	}
     }
   re_free (mctx->state_log);
   mctx->state_log = sifted_states;

Modified: fsf/trunk/libc/posix/rxspencer/tests
==============================================================================
--- fsf/trunk/libc/posix/rxspencer/tests (original)
+++ fsf/trunk/libc/posix/rxspencer/tests Thu Jan  8 00:02:50 2009
@@ -536,3 +536,7 @@
 \B	&	aSbTc
 \B	&	SaT	@SaT
 \B	&	aSTSb	@TSb
+
+o$($|.)	-	oN
+o$($|.)	-	op
+o$($|.)	-	o	o

Modified: fsf/trunk/libc/resolv/nss_dns/dns-host.c
==============================================================================
--- fsf/trunk/libc/resolv/nss_dns/dns-host.c (original)
+++ fsf/trunk/libc/resolv/nss_dns/dns-host.c Thu Jan  8 00:02:50 2009
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-2004, 2007, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2004, 2007, 2008, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Extended from original form by Ulrich Drepper <drepper@xxxxxxxxxx>, 1996.
 
@@ -376,6 +376,19 @@
   int n, status;
   int olderr = errno;
 
+ uintptr_t pad = -(uintptr_t) buffer % __alignof__ (struct host_data);
+ buffer += pad;
+ buflen = buflen > pad ? buflen - pad : 0;
+
+ if (__builtin_expect (buflen < sizeof (struct host_data), 0))
+   {
+     *errnop = ERANGE;
+     *h_errnop = NETDB_INTERNAL;
+     return NSS_STATUS_TRYAGAIN;
+   }
+
+ host_data = (struct host_data *) buffer;
+
   if (__res_maybe_init (&_res, 0) == -1)
     return NSS_STATUS_UNAVAIL;
 

Modified: fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/Makefile
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/Makefile (original)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/Makefile Thu Jan  8 00:02:50 2009
@@ -6,3 +6,7 @@
 ifeq ($(subdir),stdlib)
 gen-as-const-headers += ucontext_i.sym
 endif
+
+ifeq ($(subdir),elf)
+sysdep_routines += dl-vdso
+endif

Added: fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/Versions
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/Versions (added)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/Versions Thu Jan  8 00:02:50 2009
@@ -1,0 +1,6 @@
+libc {
+  GLIBC_PRIVATE {
+    __vdso_clock_gettime;
+    __vdso_clock_getres;
+  }
+}

Added: fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/bits/libc-vdso.h
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/bits/libc-vdso.h (added)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/bits/libc-vdso.h Thu Jan  8 00:02:50 2009
@@ -1,0 +1,35 @@
+/* Resolve function pointers to VDSO functions.
+   Copyright (C) 2008 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 _LIBC_VDSO_H
+#define _LIBC_VDSO_H
+
+#ifdef SHARED
+
+extern long int (*__vdso_gettimeofday) (struct timeval *, void *)
+  attribute_hidden;
+
+extern long int (*__vdso_clock_gettime) (clockid_t, struct timespec *);
+
+extern long int (*__vdso_clock_getres) (clockid_t, struct timespec *);
+
+#endif
+
+#endif /* _LIBC_VDSO_H */

Added: fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/gettimeofday.c
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/gettimeofday.c (added)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/gettimeofday.c Thu Jan  8 00:02:50 2009
@@ -1,0 +1,42 @@
+/* Copyright (C) 2008 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 <sysdep.h>
+#include <bp-checks.h>
+#include <stddef.h>
+#include <sys/time.h>
+#include <time.h>
+#include <hp-timing.h>
+
+#undef __gettimeofday
+#include <bits/libc-vdso.h>
+
+/* Get the current time of day and timezone information,
+   putting it into *TV and *TZ.  If TZ is NULL, *TZ is not filled.
+   Returns 0 on success, -1 on errors.  */
+
+int
+__gettimeofday (tv, tz)
+     struct timeval *tv;
+     struct timezone *tz;
+{
+  return INLINE_VSYSCALL (gettimeofday, 2, CHECK_1 (tv), CHECK_1 (tz));
+}
+
+INTDEF (__gettimeofday)
+weak_alias (__gettimeofday, gettimeofday)

Added: fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/init-first.c
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/init-first.c (added)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/init-first.c Thu Jan  8 00:02:50 2009
@@ -1,0 +1,50 @@
+/* Copyright (C) 2008 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 SHARED
+# include <dl-vdso.h>
+# undef __gettimeofday
+# undef __clock_gettime
+# undef __clock_getres
+# include <bits/libc-vdso.h>
+
+long int (*__vdso_gettimeofday) (struct timeval *, void *) attribute_hidden;
+
+long int (*__vdso_clock_gettime) (clockid_t, struct timespec *)
+  __attribute__ ((nocommon));
+strong_alias (__vdso_clock_gettime, __GI___vdso_clock_gettime attribute_hidden)
+
+long int (*__vdso_clock_getres) (clockid_t, struct timespec *)
+  __attribute__ ((nocommon));
+strong_alias (__vdso_clock_getres, __GI___vdso_clock_getres attribute_hidden)
+
+
+static inline void
+_libc_vdso_platform_setup (void)
+{
+  PREPARE_VERSION (linux2629, "LINUX_2.6.29", 123718585);
+
+  __vdso_gettimeofday = _dl_vdso_vsym ("__kernel_gettimeofday", &linux2629);
+  __vdso_clock_gettime = _dl_vdso_vsym ("__kernel_clock_gettime", &linux2629);
+  __vdso_clock_getres = _dl_vdso_vsym ("__kernel_clock_getres", &linux2629);
+}
+
+# define VDSO_SETUP _libc_vdso_platform_setup
+#endif
+
+#include "../init-first.c"

Modified: fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h (original)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h Thu Jan  8 00:02:50 2009
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006
+/* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008
    Free Software Foundation, Inc.
    Contributed by Martin Schwidefsky (schwidefsky@xxxxxxxxxx).
    This file is part of the GNU C Library.
@@ -25,6 +25,11 @@
 #include <sysdeps/unix/sysdep.h>
 #include <dl-sysdep.h>	/* For RTLD_PRIVATE_ERRNO.  */
 #include <tls.h>
+
+/* Define __set_errno() for INLINE_SYSCALL macro below.  */
+#ifndef __ASSEMBLER__
+#include <errno.h>
+#endif
 
 /* For Linux we can use the system call table in the header file
 	/usr/include/asm/unistd.h
@@ -276,6 +281,100 @@
 #define ASMFMT_5 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6)
 #define ASMFMT_6 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6), "d" (gpr7)
 
+#define CLOBBER_0 , "3", "4", "5"
+#define CLOBBER_1 , "3", "4", "5"
+#define CLOBBER_2 , "4", "5"
+#define CLOBBER_3 , "5"
+#define CLOBBER_4
+#define CLOBBER_5
+#define CLOBBER_6
+
+/* List of system calls which are supported as vsyscalls.  */
+#define HAVE_CLOCK_GETRES_VSYSCALL	1
+#define HAVE_CLOCK_GETTIME_VSYSCALL	1
+
+/* This version is for kernels that implement system calls that
+   behave like function calls as far as register saving.
+   It falls back to the syscall in the case that the vDSO doesn't
+   exist or fails for ENOSYS */
+#ifdef SHARED
+# define INLINE_VSYSCALL(name, nr, args...) \
+  ({									      \
+    __label__ out;							      \
+    __label__ iserr;							      \
+    long int _ret;							      \
+									      \
+    if (__vdso_##name != NULL)						      \
+      {									      \
+	_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, , nr, ##args);	      \
+	if (!INTERNAL_SYSCALL_ERROR_P (_ret, ))				      \
+	  goto out;							      \
+	if (INTERNAL_SYSCALL_ERRNO (_ret, ) != ENOSYS)			      \
+	  goto iserr;							      \
+      }									      \
+									      \
+    _ret = INTERNAL_SYSCALL (name, , nr, ##args);			      \
+    if (INTERNAL_SYSCALL_ERROR_P (_ret, ))				      \
+      {									      \
+      iserr:								      \
+        __set_errno (INTERNAL_SYSCALL_ERRNO (_ret, ));			      \
+        _ret = -1L;							      \
+      }									      \
+  out:									      \
+    (int) _ret;								      \
+  })
+#else
+# define INLINE_VSYSCALL(name, nr, args...) \
+  INLINE_SYSCALL (name, nr, ##args)
+#endif
+
+#ifdef SHARED
+# define INTERNAL_VSYSCALL(name, err, nr, args...) \
+  ({									      \
+    __label__ out;							      \
+    long int _ret;							      \
+									      \
+    if (__vdso_##name != NULL)						      \
+      {									      \
+	_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, err, nr, ##args);	      \
+	if (!INTERNAL_SYSCALL_ERROR_P (_ret, err)			      \
+	    || INTERNAL_SYSCALL_ERRNO (_ret, err) != ENOSYS)		      \
+	  goto out;							      \
+      }									      \
+    _ret = INTERNAL_SYSCALL (name, err, nr, ##args);			      \
+  out:									      \
+    _ret;								      \
+  })
+#else
+# define INTERNAL_VSYSCALL(name, err, nr, args...) \
+  INTERNAL_SYSCALL (name, err, nr, ##args)
+#endif
+
+/* This version is for internal uses when there is no desire
+   to set errno */
+#define INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK(name, err, nr, args...)	      \
+  ({									      \
+    long int _ret = ENOSYS;						      \
+									      \
+    if (__vdso_##name != NULL)						      \
+      _ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, err, nr, ##args);	      \
+    else								      \
+      err = 1 << 28;							      \
+    _ret;								      \
+  })
+
+#define INTERNAL_VSYSCALL_NCS(fn, err, nr, args...)			      \
+  ({									      \
+    DECLARGS_##nr(args)							      \
+    register long _ret asm("2");						      \
+    asm volatile (							      \
+    "lr 11,14\n\t"							      \
+    "basr 14,%1\n\t"							      \
+    "lr 14,11\n\t"							      \
+    : "=d" (_ret)							      \
+    : "d" (fn) ASMFMT_##nr						      \
+    : "cc", "memory", "0", "1", "11" CLOBBER_##nr);			      \
+    _ret; })
 
 /* Pointer mangling support.  */
 #if defined NOT_IN_libc && defined IS_IN_rtld

Modified: fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h (original)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h Thu Jan  8 00:02:50 2009
@@ -1,5 +1,5 @@
 /* Assembler macros for 64 bit S/390.
-   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
+   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008
    Free Software Foundation, Inc.
    Contributed by Martin Schwidefsky (schwidefsky@xxxxxxxxxx).
    This file is part of the GNU C Library.
@@ -26,6 +26,11 @@
 #include <sysdeps/unix/sysdep.h>
 #include <dl-sysdep.h>	/* For RTLD_PRIVATE_ERRNO.  */
 #include <tls.h>
+
+/* Define __set_errno() for INLINE_SYSCALL macro below.  */
+#ifndef __ASSEMBLER__
+#include <errno.h>
+#endif
 
 /* For Linux we can use the system call table in the header file
 	/usr/include/asm/unistd.h
@@ -278,6 +283,101 @@
 #define ASMFMT_5 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6)
 #define ASMFMT_6 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6), "d" (gpr7)
 
+#define CLOBBER_0 , "3", "4", "5"
+#define CLOBBER_1 , "3", "4", "5"
+#define CLOBBER_2 , "4", "5"
+#define CLOBBER_3 , "5"
+#define CLOBBER_4
+#define CLOBBER_5
+#define CLOBBER_6
+
+/* List of system calls which are supported as vsyscalls.  */
+#define HAVE_CLOCK_GETRES_VSYSCALL	1
+#define HAVE_CLOCK_GETTIME_VSYSCALL	1
+
+/* This version is for kernels that implement system calls that
+   behave like function calls as far as register saving.
+   It falls back to the syscall in the case that the vDSO doesn't
+   exist or fails for ENOSYS */
+#ifdef SHARED
+# define INLINE_VSYSCALL(name, nr, args...) \
+  ({									      \
+    __label__ out;							      \
+    __label__ iserr;							      \
+    long int _ret;							      \
+									      \
+    if (__vdso_##name != NULL)						      \
+      {									      \
+	_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, , nr, ##args);	      \
+	if (!INTERNAL_SYSCALL_ERROR_P (_ret, ))				      \
+	  goto out;							      \
+	if (INTERNAL_SYSCALL_ERRNO (_ret, ) != ENOSYS)			      \
+	  goto iserr;							      \
+      }									      \
+									      \
+    _ret = INTERNAL_SYSCALL (name, , nr, ##args);			      \
+    if (INTERNAL_SYSCALL_ERROR_P (_ret, ))				      \
+      {									      \
+      iserr:								      \
+        __set_errno (INTERNAL_SYSCALL_ERRNO (_ret, ));			      \
+        _ret = -1L;							      \
+      }									      \
+  out:									      \
+    (int) _ret;								      \
+  })
+#else
+# define INLINE_VSYSCALL(name, nr, args...) \
+  INLINE_SYSCALL (name, nr, ##args)
+#endif
+
+#ifdef SHARED
+# define INTERNAL_VSYSCALL(name, err, nr, args...) \
+  ({									      \
+    __label__ out;							      \
+    long int _ret;							      \
+									      \
+    if (__vdso_##name != NULL)						      \
+      {									      \
+	_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, err, nr, ##args);	      \
+	if (!INTERNAL_SYSCALL_ERROR_P (_ret, err)			      \
+	    || INTERNAL_SYSCALL_ERRNO (_ret, err) != ENOSYS)		      \
+	  goto out;							      \
+      }									      \
+    _ret = INTERNAL_SYSCALL (name, err, nr, ##args);			      \
+  out:									      \
+    _ret;								      \
+  })
+#else
+# define INTERNAL_VSYSCALL(name, err, nr, args...) \
+  INTERNAL_SYSCALL (name, err, nr, ##args)
+#endif
+
+/* This version is for internal uses when there is no desire
+   to set errno */
+#define INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK(name, err, nr, args...)	      \
+  ({									      \
+    long int _ret = ENOSYS;						      \
+									      \
+    if (__vdso_##name != NULL)						      \
+      _ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, err, nr, ##args);	      \
+    else								      \
+      err = 1 << 28;							      \
+    _ret;								      \
+  })
+
+#define INTERNAL_VSYSCALL_NCS(fn, err, nr, args...)			      \
+  ({									      \
+    DECLARGS_##nr(args)							      \
+    register long _ret asm("2");					      \
+    asm volatile (							      \
+    "lgr 11,14\n\t"							      \
+    "basr 14,%1\n\t"							      \
+    "lgr 14,11\n\t"							      \
+    : "=d" (_ret)							      \
+    : "a" (fn) ASMFMT_##nr						      \
+    : "cc", "memory", "0", "1", "11" CLOBBER_##nr);			      \
+    _ret; })
+
 /* Pointer mangling support.  */
 #if defined NOT_IN_libc && defined IS_IN_rtld
 /* We cannot use the thread descriptor because in ld.so we use setjmp