about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-10-15 07:31:04 +0000
committerJakub Jelinek <jakub@redhat.com>2007-10-15 07:31:04 +0000
commit378e8bab9688c447e7567b5066ef26482a4fd8f1 (patch)
tree8b26c8de92c9e555d78b6c0ec4f416e65257fc3d
parent68a071d274b5bd3049ab3ec7cd5cbb901aa95ccd (diff)
downloadglibc-378e8bab9688c447e7567b5066ef26482a4fd8f1.tar.gz
glibc-378e8bab9688c447e7567b5066ef26482a4fd8f1.tar.xz
glibc-378e8bab9688c447e7567b5066ef26482a4fd8f1.zip
Updated to fedora-glibc-20071015T0728 cvs/fedora-glibc-2_6_90-21
-rw-r--r--ChangeLog14
-rw-r--r--fedora/branch.mk4
-rw-r--r--fedora/glibc.spec.in5
-rw-r--r--nscd/nscd_getgr_r.c18
-rw-r--r--posix/glob.c49
-rw-r--r--posix/tst-rfc3484-2.c4
-rw-r--r--posix/tst-rfc3484.c1
7 files changed, 68 insertions, 27 deletions
diff --git a/ChangeLog b/ChangeLog
index 619b6f2054..fb7ef42c9e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,20 @@
 2007-10-14  Ulrich Drepper  <drepper@redhat.com>
 
+	* posix/glob.c: Reimplement link_exists_p to use fstatat64.
+
+	* posix/glob.c: Add some branch prediction throughout.
+
+	* nscd/nscd_getgr_r.c (nscd_getgr_r): Store result of successful
+	read from nscd.
+
 	* sysdeps/posix/getaddrinfo.c (struct sort_result): Add
 	service_order.
-	(rfc3484_sort): Make sure that even of qsort doesn't support
-	stable sorting it is stable by comparing service_order.
+	(rfc3484_sort): Make sure that even if qsort doesn't support
+	stable sorting out sorting here is stable by comparing service_order.
 	(getaddrinfo): Initialize service_order.
+	* posix/tst-rfc3484.c (do_test): Adjust for addition of
+	service_order field to sorting structure.
+	* posix/tst-rfc3484-2.c (do_test): Likewise.
 
 	* include/time.h: Declare __tzset_parse_tz and __tzset_compute.
 	* time/tzset.c (tzset_internal): Break TZ string parsing out into
diff --git a/fedora/branch.mk b/fedora/branch.mk
index a457caf781..1dc4e6b574 100644
--- a/fedora/branch.mk
+++ b/fedora/branch.mk
@@ -3,5 +3,5 @@ glibc-branch := fedora
 glibc-base := HEAD
 DIST_BRANCH := devel
 COLLECTION := dist-f8
-fedora-sync-date := 2007-10-14 21:02 UTC
-fedora-sync-tag := fedora-glibc-20071014T2102
+fedora-sync-date := 2007-10-15 07:28 UTC
+fedora-sync-tag := fedora-glibc-20071015T0728
diff --git a/fedora/glibc.spec.in b/fedora/glibc.spec.in
index 82bbe2d241..a00d799987 100644
--- a/fedora/glibc.spec.in
+++ b/fedora/glibc.spec.in
@@ -1,4 +1,4 @@
-%define glibcrelease 20
+%define glibcrelease 21
 %define run_glibc_tests 1
 %define auxarches i586 i686 athlon sparcv9v sparc64v alphaev6
 %define xenarches i686 athlon
@@ -1010,6 +1010,9 @@ rm -f *.filelist*
 %endif
 
 %changelog
+* Mon Oct 15 2007 Jakub Jelinek <jakub@redhat.com> 2.6.90-21
+- fix getgr{name,gid}{,_r} with nscd
+
 * Sun Oct 14 2007 Jakub Jelinek <jakub@redhat.com> 2.6.90-20
 - install <bits/error.h> (#330031)
 - disable -D_FORTIFY_SOURCE{,=2} support (with a warning) for
diff --git a/nscd/nscd_getgr_r.c b/nscd/nscd_getgr_r.c
index afb4d20435..b84b06b3ce 100644
--- a/nscd/nscd_getgr_r.c
+++ b/nscd/nscd_getgr_r.c
@@ -266,18 +266,16 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type,
       /* If there are no group members TOTAL_LEN is zero.  */
       if (gr_name == NULL)
 	{
-	  if (total_len > 0)
+	  if (total_len > 0
+	      && __builtin_expect (__readall (sock, resultbuf->gr_mem[0],
+					      total_len) != total_len, 0))
 	    {
-	      size_t n = __readall (sock, resultbuf->gr_mem[0], total_len);
-	      if (__builtin_expect (n != total_len, 0))
-		{
-		  /* The `errno' to some value != ERANGE.  */
-		  __set_errno (ENOENT);
-		  retval = ENOENT;
-		}
-	      else
-		*result = resultbuf;
+	      /* The `errno' to some value != ERANGE.  */
+	      __set_errno (ENOENT);
+	      retval = ENOENT;
 	    }
+	  else
+	    *result = resultbuf;
 	}
       else
 	{
diff --git a/posix/glob.c b/posix/glob.c
index d6a1a4a2d1..b7d9617267 100644
--- a/posix/glob.c
+++ b/posix/glob.c
@@ -774,7 +774,7 @@ glob (pattern, flags, errfunc, pglob)
 
       /* Return the directory if we don't check for error or if it exists.  */
       if ((flags & GLOB_NOCHECK)
-	  || (((flags & GLOB_ALTDIRFUNC)
+	  || (((__builtin_expect (flags & GLOB_ALTDIRFUNC, 0))
 	       ? ((*pglob->gl_stat) (dirname, &st) == 0
 		  && S_ISDIR (st.st_mode))
 	       : (__stat64 (dirname, &st64) == 0 && S_ISDIR (st64.st_mode)))))
@@ -846,7 +846,7 @@ glob (pattern, flags, errfunc, pglob)
 	    *(char *) &dirname[--dirlen] = '\0';
 	}
 
-      if ((flags & GLOB_ALTDIRFUNC) != 0)
+      if (__builtin_expect ((flags & GLOB_ALTDIRFUNC) != 0, 0))
 	{
 	  /* Use the alternative access functions also in the recursive
 	     call.  */
@@ -1030,7 +1030,7 @@ glob (pattern, flags, errfunc, pglob)
       struct_stat64 st64;
 
       for (i = oldcount; i < pglob->gl_pathc + pglob->gl_offs; ++i)
-	if (((flags & GLOB_ALTDIRFUNC)
+	if ((__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
 	     ? ((*pglob->gl_stat) (pglob->gl_pathv[i], &st) == 0
 		&& S_ISDIR (st.st_mode))
 	     : (__stat64 (pglob->gl_pathv[i], &st64) == 0
@@ -1222,21 +1222,42 @@ weak_alias (__glob_pattern_p, glob_pattern_p)
    allocated with alloca to be recycled.  */
 #if !defined _LIBC || !defined GLOB_ONLY_P
 static int
-link_exists_p (const char *dir, size_t dirlen, const char *fname,
-	       glob_t *pglob, int flags)
+__attribute_noinline__
+link_exists2_p (const char *dir, size_t dirlen, const char *fname,
+	       glob_t *pglob
+# ifndef _LIBC
+		, int flags
+# endif
+		)
 {
   size_t fnamelen = strlen (fname);
   char *fullname = (char *) __alloca (dirlen + 1 + fnamelen + 1);
   struct stat st;
+# ifndef _LIBC
   struct_stat64 st64;
+# endif
 
   mempcpy (mempcpy (mempcpy (fullname, dir, dirlen), "/", 1),
 	   fname, fnamelen + 1);
 
-  return (((flags & GLOB_ALTDIRFUNC)
+# ifdef _LIBC
+  return (*pglob->gl_stat) (fullname, &st) == 0;
+# else
+  return ((__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
 	   ? (*pglob->gl_stat) (fullname, &st)
 	   : __stat64 (fullname, &st64)) == 0);
+# endif
 }
+# ifdef _LIBC
+#  define link_exists_p(dfd, dirname, dirnamelen, fname, pglob, flags) \
+  (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)			      \
+   ? link_exists2_p (dirname, dirnamelen, fname, pglob)			      \
+   : ({ struct stat64 st64;						      \
+       __fxstatat64 (_STAT_VER, dfd, fname, &st64, 0) == 0; }))
+# else
+#  define link_exists_p(dfd, dirname, dirnamelen, fname, pglob, flags) \
+  link_exists2_p (dirname, dirnamelen, fname, pglob, flags)
+# endif
 #endif
 
 
@@ -1290,7 +1311,7 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
       mempcpy (mempcpy (mempcpy (fullname, directory, dirlen),
 			"/", 1),
 	       pattern, patlen + 1);
-      if (((flags & GLOB_ALTDIRFUNC)
+      if ((__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
 	   ? (*pglob->gl_stat) (fullname, &st)
 	   : __stat64 (fullname, &st64)) == 0)
 	/* We found this file to be existing.  Now tell the rest
@@ -1299,7 +1320,7 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
     }
   else
     {
-      stream = ((flags & GLOB_ALTDIRFUNC)
+      stream = (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
 		? (*pglob->gl_opendir) (directory)
 		: opendir (directory));
       if (stream == NULL)
@@ -1311,6 +1332,10 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
 	}
       else
 	{
+#ifdef _LIBC
+	  int dfd = (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
+		     ? -1 : dirfd ((DIR *) stream));
+#endif
 	  int fnm_flags = ((!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0)
 			   | ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0)
 #if defined _AMIGA || defined VMS
@@ -1333,7 +1358,7 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
 		}
 	      d64buf;
 
-	      if (flags & GLOB_ALTDIRFUNC)
+	      if (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0))
 		{
 		  struct dirent *d32 = (*pglob->gl_readdir) (stream);
 		  if (d32 != NULL)
@@ -1347,7 +1372,7 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
 	      else
 		d = __readdir64 (stream);
 #else
-	      struct dirent *d = ((flags & GLOB_ALTDIRFUNC)
+	      struct dirent *d = (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
 				  ? ((struct dirent *)
 				     (*pglob->gl_readdir) (stream))
 				  : __readdir (stream));
@@ -1369,7 +1394,7 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
 		  /* If the file we found is a symlink we have to
 		     make sure the target file exists.  */
 		  if (!DIRENT_MIGHT_BE_SYMLINK (d)
-		      || link_exists_p (directory, dirlen, name, pglob,
+		      || link_exists_p (dfd, directory, dirlen, name, pglob,
 					flags))
 		    {
 		      if (cur == names->count)
@@ -1485,7 +1510,7 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
   if (stream != NULL)
     {
       save = errno;
-      if (flags & GLOB_ALTDIRFUNC)
+      if (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0))
 	(*pglob->gl_closedir) (stream);
       else
 	closedir (stream);
diff --git a/posix/tst-rfc3484-2.c b/posix/tst-rfc3484-2.c
index ae802c0652..f318523ed5 100644
--- a/posix/tst-rfc3484-2.c
+++ b/posix/tst-rfc3484-2.c
@@ -98,12 +98,14 @@ do_test (void)
   results[0].got_source_addr = true;
   results[0].source_addr_len = sizeof (so1);
   results[0].source_addr_flags = 0;
+  results[0].service_order = 0;
   memcpy (&results[0].source_addr, &so1, sizeof (so1));
 
   results[1].dest_addr = &ai2;
   results[1].got_source_addr = true;
   results[1].source_addr_len = sizeof (so2);
   results[1].source_addr_flags = 0;
+  results[1].service_order = 1;
   memcpy (&results[1].source_addr, &so2, sizeof (so2));
 
 
@@ -122,12 +124,14 @@ do_test (void)
   results[1].got_source_addr = true;
   results[1].source_addr_len = sizeof (so1);
   results[1].source_addr_flags = 0;
+  results[1].service_order = 1;
   memcpy (&results[1].source_addr, &so1, sizeof (so1));
 
   results[0].dest_addr = &ai2;
   results[0].got_source_addr = true;
   results[0].source_addr_len = sizeof (so2);
   results[0].source_addr_flags = 0;
+  results[0].service_order = 0;
   memcpy (&results[0].source_addr, &so2, sizeof (so2));
 
 
diff --git a/posix/tst-rfc3484.c b/posix/tst-rfc3484.c
index 352a7579ac..08d57a66ee 100644
--- a/posix/tst-rfc3484.c
+++ b/posix/tst-rfc3484.c
@@ -93,6 +93,7 @@ do_test (void)
       memcpy(&results[i].source_addr, &so, sizeof (so));
       results[i].source_addr_len = sizeof (so);
       results[i].source_addr_flags = 0;
+      results[i].service_order = i;
     }
 
   qsort (results, naddrs, sizeof (results[0]), rfc3484_sort);