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

[commits] r1193 - in /trunk/libc: ./ include/ inet/ io/ nis/nss_nis/ nptl/ nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/ nptl/sy...



Author: joseph
Date: Sun Jan 14 16:45:23 2007
New Revision: 1193

Log:
Merge changes between r1147 and r1192 from /fsf/trunk.

Added:
    trunk/libc/nscd/getsrvbynm_r.c
      - copied unchanged from r1192, fsf/trunk/libc/nscd/getsrvbynm_r.c
    trunk/libc/nscd/getsrvbypt_r.c
      - copied unchanged from r1192, fsf/trunk/libc/nscd/getsrvbypt_r.c
    trunk/libc/nscd/nscd_getserv_r.c
      - copied unchanged from r1192, fsf/trunk/libc/nscd/nscd_getserv_r.c
    trunk/libc/nscd/servicescache.c
      - copied unchanged from r1192, fsf/trunk/libc/nscd/servicescache.c
    trunk/libc/stdlib/tst-strtod4.c
      - copied unchanged from r1192, fsf/trunk/libc/stdlib/tst-strtod4.c
Removed:
    trunk/libc/sysdeps/i386/soft-fp/
    trunk/libc/sysdeps/x86_64/soft-fp/
Modified:
    trunk/libc/ChangeLog
    trunk/libc/NEWS
    trunk/libc/include/string.h
    trunk/libc/inet/Makefile
    trunk/libc/io/fts.c
    trunk/libc/nis/nss_nis/nis-service.c
    trunk/libc/nptl/ChangeLog
    trunk/libc/nptl/shlib-versions
    trunk/libc/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_wait.c
    trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
    trunk/libc/nptl/tst-rwlock7.c
    trunk/libc/nscd/Makefile
    trunk/libc/nscd/cache.c
    trunk/libc/nscd/connections.c
    trunk/libc/nscd/gai.c
    trunk/libc/nscd/grpcache.c
    trunk/libc/nscd/hstcache.c
    trunk/libc/nscd/nscd-client.h
    trunk/libc/nscd/nscd.c
    trunk/libc/nscd/nscd.conf
    trunk/libc/nscd/nscd.h
    trunk/libc/nscd/nscd_conf.c
    trunk/libc/nscd/nscd_gethst_r.c
    trunk/libc/nscd/nscd_proto.h
    trunk/libc/nscd/pwdcache.c
    trunk/libc/nscd/selinux.c
    trunk/libc/nss/Versions
    trunk/libc/nss/nsswitch.c
    trunk/libc/scripts/check-local-headers.sh
    trunk/libc/stdlib/Makefile
    trunk/libc/stdlib/strtod_l.c
    trunk/libc/stdlib/tst-makecontext.c
    trunk/libc/stdlib/tst-strtod2.c
    trunk/libc/sysdeps/i386/i486/bits/atomic.h
    trunk/libc/sysdeps/x86_64/bits/atomic.h

Modified: trunk/libc/ChangeLog
==============================================================================
--- trunk/libc/ChangeLog (original)
+++ trunk/libc/ChangeLog Sun Jan 14 16:45:23 2007
@@ -1,3 +1,102 @@
+2007-01-13  Ulrich Drepper  <drepper@xxxxxxxxxx>
+
+	* inet/Makefile: Define CFLAGS-getsrvbynm_r.c and
+	CFLAGS-getsrvbynpt_r.c.
+	* nscd/getsrvbynm_r.c: New file.
+	* nscd/getsrvbypt_r.c: New file.
+	* nscd/nscd_getserv_r.c: New file.
+	* nscd/servicescache.c: New file.
+	* nscd/Makefile (routines): Add nscd_getserv_r.
+	(nscd-modules): Add getsrvbynm_r, getsrvbypt_r, and servicescache.
+	Define CFLAGS-servicescache.c, CFLAGS-getsrvbynm_r.c, and
+	CFLAGS-getsrvbypt_r.c.
+	* nscd/cache.c (prune_cache): Rewrite to get re-add function from
+	table.  Add entries for services database.
+	* nscd/connections.c (serv2str): Mark as const.  Add entries for
+	services database.
+	(dbs): Add .reset_res and servdb initialization.
+	(serv2db): Add entries for services database.
+	(verify_persistent_db): Accept dbnr == servdb.
+	(invalidate_cache): Rewrite database name recognition to use a table.
+	Call res_init() if .reset_res is set for database.
+	(handle_request): Add code to handle services database.
+	* nscd/gai.c: Don't define __getservbyname_r.
+	* nscd/nscd-client.h (request_type): Remove LASTDBREQ, add
+	GETSERVBYNAME, GETSERVBYPORT, GETFDSERV.
+	(serv_response_header): Define.
+	(struct datahead): Add serv_response_header member.
+	* nscd/nscd.c (parse_opt): Rewrite parsing of -i parameter value
+	using table.
+	* nscd/nscd.conf: Add entries for services database.
+	* nscd/nscd.h: Adjust declaration of dbnames and serv2str.
+	Declare serv_iov_disabled.
+	Declare addservbyname, readdservbyname, addservbyport, and
+	readdservbyport.
+	* nscd/nscd_conf.c (dbnames): Mark as const.  Add services entry.
+	(find_db): Fix error message.
+	* nscd/nscd_proto.h: Declare __nss_not_use_nscd_services,
+	__nscd_getservbyname_r, and __nscd_getservbyport_r.
+	* nscd/selinux.c (perms): Add entries for services database.
+	* nss/Versions: Export __nss_services_lookup with GLIBC_PRIVATE.
+	* nss/nsswitch.c (__nss_disable_nscd): Also disable services database.
+
+	* nscd/grpcache.c: Remove obsolete code.  Cleanups.
+	* nscd/hstcache.c: Likewise.
+	* nscd/pwdcache.c: Likewise.
+
+	* nis/nss_nis/nis-service.c (_nss_nis_getservbyname_r): Correct
+	computation of keylen.
+
+	* include/string.h: Only redefine strndupa if this is really for
+	libc code.
+
+2007-01-12  Ulrich Drepper  <drepper@xxxxxxxxxx>
+
+	* nscd/nscd_gethst_r.c: Minor cleanups.
+
+	* nscd/connections.c (handle_request): Check selinux permissions
+	for all non-admin commands.
+
+	* sysdeps/i386/i486/bits/atomic.h: Define
+	atomic_compare_and_exchange_val_acq,
+	atomic_compare_and_exchange_bool_acq, and atomic_exchange_and_add
+	using __sync_* built-ins for gcc >= 4.1.
+	* sysdeps/x86_64/bits/atomic.h: Likewise.
+
+	[BZ #3840]
+	* scripts/check-local-headers.sh: Restrict to testing .o.d, .os.d,
+	and .oS.d files.
+
+2007-01-05  Steven Munroe  <sjmunroe@xxxxxxxxxx>
+
+	* stdlib/tst-makecontext.c: Include errno.h.  Change main()
+	to do_test().  Define TEST_FUNCTION. Include test-skeleton.c.
+	(do_test): Check errno and exit(0) if ENOSYS.
+
+2007-01-11  Jakub Jelinek  <jakub@xxxxxxxxxx>
+
+	* stdlib/strtod_l.c (____STRTOF_INTERNAL): Fix handling of multi-byte
+	thousands separators.
+	* stdlib/Makefile: Add rules to build and run tst-strtod4.
+	* stdlib/tst-strtod4.c: New test.
+
+	[BZ #3855]
+	* stdlib/strtod_l.c (____STRTOF_INTERNAL): 0x. not followed by
+	hexadecimal digit should accept just the initial 0.
+	* stdlib/tst-strtod2.c (tests): New variable.
+	(do_test): Run several tests rather than just one.
+
+2007-01-11  Jakub Jelinek  <jakub@xxxxxxxxxx>
+
+	* sysdeps/i386/soft-fp/sfp-machine.h: Remove.
+	* sysdeps/x86_64/soft-fp/sfp-machine.h: Likewise.
+
+2007-01-10  Ulrich Drepper  <drepper@xxxxxxxxxx>
+
+	* io/fts.c: Make sure fts_cur is always valid after return from
+	fts_read.
+	Patch by Miloslav Trmac <mitr@xxxxxxxxxx>.
+
 2006-10-27  Richard Sandiford  <richard@xxxxxxxxxxxxxxxx>
 
 	* elf/elf.h (R_MIPS_GLOB_DAT): Define.

Modified: trunk/libc/NEWS
==============================================================================
--- trunk/libc/NEWS (original)
+++ trunk/libc/NEWS Sun Jan 14 16:45:23 2007
@@ -1,5 +1,5 @@
-GNU C Library NEWS -- history of user-visible changes.  2006-10-11
-Copyright (C) 1992-2002,2003,2004,2005,2006 Free Software Foundation, Inc.
+GNU C Library NEWS -- history of user-visible changes.  2007-1-13
+Copyright (C) 1992-2006, 2007 Free Software Foundation, Inc.
 See the end for copying conditions.
 
 Please send GNU C library bug reports via <http://sources.redhat.com/bugzilla/>
@@ -8,6 +8,8 @@
 Version 2.6
 
 * New Linux interfaces: epoll_pwait.
+
+* nscd can now cache the services database.   Implemented by Ulrich Drepper.
 
 
 Version 2.5

Modified: trunk/libc/include/string.h
==============================================================================
--- trunk/libc/include/string.h (original)
+++ trunk/libc/include/string.h Sun Jan 14 16:45:23 2007
@@ -54,8 +54,9 @@
 extern __typeof (strncasecmp_l) __strncasecmp_l;
 
 /* Alternative version which doesn't pollute glibc's namespace.  */
-#undef strndupa
-#define strndupa(s, n)							      \
+#ifndef NOT_IN_libc
+# undef strndupa
+# define strndupa(s, n)							      \
   (__extension__							      \
     ({									      \
       __const char *__old = (s);					      \
@@ -64,6 +65,7 @@
       __new[__len] = '\0';						      \
       (char *) memcpy (__new, __old, __len);				      \
     }))
+#endif
 
 libc_hidden_proto (__mempcpy)
 libc_hidden_proto (__stpcpy)

Modified: trunk/libc/inet/Makefile
==============================================================================
--- trunk/libc/inet/Makefile (original)
+++ trunk/libc/inet/Makefile Sun Jan 14 16:45:23 2007
@@ -1,4 +1,4 @@
-# Copyright (C) 1991-2002, 2003, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 1991-2006, 2007 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
@@ -79,6 +79,8 @@
 CFLAGS-getrpcent.c = -fexceptions
 CFLAGS-getservent_r.c = -fexceptions
 CFLAGS-getservent.c = -fexceptions
+CFLAGS-getsrvbynm_r.c = -DUSE_NSCD=1
+CFLAGS-getsrvbypt_r.c = -DUSE_NSCD=1
 CFLAGS-getprtent_r.c = -fexceptions
 CFLAGS-getprtent.c = -fexceptions
 CFLAGS-either_ntoh.c = -fexceptions

Modified: trunk/libc/io/fts.c
==============================================================================
--- trunk/libc/io/fts.c (original)
+++ trunk/libc/io/fts.c Sun Jan 14 16:45:23 2007
@@ -376,12 +376,14 @@
 		}
 		p = sp->fts_child;
 		sp->fts_child = NULL;
+		sp->fts_cur = p;
 		goto name;
 	}
 
 	/* Move to the next node on this level. */
 next:	tmp = p;
 	if ((p = p->fts_link) != NULL) {
+		sp->fts_cur = p;
 		free(tmp);
 
 		/*
@@ -394,7 +396,7 @@
 				return (NULL);
 			}
 			fts_load(sp, p);
-			return (sp->fts_cur = p);
+			return p;
 		}
 
 		/*
@@ -420,11 +422,12 @@
 name:		t = sp->fts_path + NAPPEND(p->fts_parent);
 		*t++ = '/';
 		memmove(t, p->fts_name, p->fts_namelen + 1);
-		return (sp->fts_cur = p);
+		return p;
 	}
 
 	/* Move up to the parent node. */
 	p = tmp->fts_parent;
+	sp->fts_cur = p;
 	free(tmp);
 
 	if (p->fts_level == FTS_ROOTPARENTLEVEL) {
@@ -465,7 +468,7 @@
 		return (NULL);
 	}
 	p->fts_info = p->fts_errno ? FTS_ERR : FTS_DP;
-	return (sp->fts_cur = p);
+	return p;
 }
 
 /*

Modified: trunk/libc/nis/nss_nis/nis-service.c
==============================================================================
--- trunk/libc/nis/nss_nis/nis-service.c (original)
+++ trunk/libc/nis/nss_nis/nis-service.c Sun Jan 14 16:45:23 2007
@@ -271,7 +271,7 @@
 
   /* If the protocol is given, we could try if our NIS server knows
      about services.byservicename map. If yes, we only need one query.  */
-  size_t keylen = strlen (name) + 1 + (protocol ? strlen (protocol) : 0);
+  size_t keylen = strlen (name) + (protocol ? 1 + strlen (protocol) : 0);
   char key[keylen + 1];
 
   /* key is: "name/proto" */

Modified: trunk/libc/nptl/ChangeLog
==============================================================================
--- trunk/libc/nptl/ChangeLog (original)
+++ trunk/libc/nptl/ChangeLog Sun Jan 14 16:45:23 2007
@@ -1,3 +1,28 @@
+2007-01-12  Ulrich Drepper  <drepper@xxxxxxxxxx>
+
+	* tst-rwlock7.c: Show some more information in case of correct
+	behavior.
+
+2007-01-11  Ulrich Drepper  <drepper@xxxxxxxxxx>
+
+	* sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
+	(lll_futex_timed_wait): Undo part of last change, don't negate
+	return value.
+
+2007-01-10  Ulrich Drepper  <drepper@xxxxxxxxxx>
+
+	* sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Cleanups.  Define
+	FUTEX_CMP_REQUEUE and lll_futex_requeue.
+
+2006-12-28  David S. Miller  <davem@xxxxxxxxxxxxx>
+
+	* shlib-versions: Fix sparc64 linux target specification.
+
+2007-01-10  Jakub Jelinek  <jakub@xxxxxxxxxx>
+
+	* sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_wait.c:
+	Adjust include path for pthread_barrier_wait.c move.
+
 2006-12-21  Jakub Jelinek  <jakub@xxxxxxxxxx>
 
 	* sysdeps/unix/sysv/linux/pthread_kill.c (pthread_kill): Make sure
@@ -71,7 +96,7 @@
 	* sysdeps/pthread/pthread_getcpuclockid.c: Move to...
 	* pthread_getcpuclockid.c: ...here.
 
-	* init.c: USE_TLS support is now default.
+	* init.c: USE_TLS support is now always enabled.
 	* tst-tls5.h: Likewise.
 	* sysdeps/alpha/tls.h: Likewise.
 	* sysdeps/i386/tls.h: Likewise.

Modified: trunk/libc/nptl/shlib-versions
==============================================================================
--- trunk/libc/nptl/shlib-versions (original)
+++ trunk/libc/nptl/shlib-versions Sun Jan 14 16:45:23 2007
@@ -1,5 +1,5 @@
 mips.*-.*-linux.*	libpthread=0		GLIBC_2.0 GLIBC_2.2
-sparc64-.*-linux.*	libpthread=0		GLIBC_2.2
+sparc64.*-.*-linux.*	libpthread=0		GLIBC_2.2
 sh.*-.*-linux.*		libpthread=0		GLIBC_2.2
 ia64.*-.*-linux.*	libpthread=0		GLIBC_2.2
 hppa.*-.*-linux.*	libpthread=0		GLIBC_2.2

Modified: trunk/libc/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_wait.c
==============================================================================
--- trunk/libc/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_wait.c (original)
+++ trunk/libc/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_wait.c Sun Jan 14 16:45:23 2007
@@ -1,1 +1,1 @@
-#include "../../../../../../pthread/pthread_barrier_wait.c"
+#include "../../../../../../../pthread_barrier_wait.c"

Modified: trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
==============================================================================
--- trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h (original)
+++ trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h Sun Jan 14 16:45:23 2007
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 2002.
 
@@ -35,6 +35,7 @@
 #define SYS_futex		202
 #define FUTEX_WAIT		0
 #define FUTEX_WAKE		1
+#define FUTEX_CMP_REQUEUE	4
 #define FUTEX_LOCK_PI		6
 #define FUTEX_UNLOCK_PI		7
 #define FUTEX_TRYLOCK_PI	8
@@ -150,7 +151,7 @@
 #define lll_futex_wait(futex, val) \
   ({									      \
     int __status;							      \
-    register __typeof (val) _val asm ("edx") = (val);			      \
+    register __typeof (val) _val __asm ("edx") = (val);			      \
     __asm __volatile ("xorq %%r10, %%r10\n\t"				      \
 		      "syscall"						      \
 		      : "=a" (__status)					      \
@@ -163,9 +164,9 @@
 
 #define lll_futex_timed_wait(futex, val, timeout)			      \
   ({									      \
-    register const struct timespec *__to __asm__ ("r10") = timeout;	      \
+    register const struct timespec *__to __asm ("r10") = timeout;	      \
     int __status;							      \
-    register __typeof (val) _val asm ("edx") = (val);			      \
+    register __typeof (val) _val __asm ("edx") = (val);			      \
     __asm __volatile ("syscall"						      \
 		      : "=a" (__status)					      \
 		      : "0" (SYS_futex), "D" (futex), "S" (FUTEX_WAIT),	      \
@@ -178,7 +179,7 @@
 #define lll_futex_wake(futex, nr) \
   do {									      \
     int __ignore;							      \
-    register __typeof (nr) _nr asm ("edx") = (nr);			      \
+    register __typeof (nr) _nr __asm ("edx") = (nr);			      \
     __asm __volatile ("syscall"						      \
 		      : "=a" (__ignore)					      \
 		      : "0" (SYS_futex), "D" (futex), "S" (FUTEX_WAKE),	      \
@@ -421,6 +422,21 @@
 				"S" (FUTEX_WAKE), "1" (__NR_futex),	      \
 				"d" (1)					      \
 			      : "cx", "r11", "cc", "memory"); })
+
+
+/* Returns non-zero if error happened, zero if success.  */
+#define lll_futex_requeue(ftx, nr_wake, nr_move, mutex, val) \
+  ({ int __res;								      \
+     register int __nr_move __asm ("r10") = nr_move;			      \
+     register void *__mutex __asm ("r8") = mutex;			      \
+     register int __val __asm ("r9") = val;				      \
+     __asm __volatile ("syscall"					      \
+		       : "=a" (__res)					      \
+		       : "0" (__NR_futex), "D" ((void *) ftx),		      \
+		         "S" (FUTEX_CMP_REQUEUE), "d" (nr_wake),	      \
+		         "r" (__nr_move), "r" (__mutex), "r" (__val)	      \
+		       : "cx", "r11", "cc", "memory");			      \
+     __res < 0; })
 
 
 #define lll_mutex_islocked(futex) \

Modified: trunk/libc/nptl/tst-rwlock7.c
==============================================================================
--- trunk/libc/nptl/tst-rwlock7.c (original)
+++ trunk/libc/nptl/tst-rwlock7.c Sun Jan 14 16:45:23 2007
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 2002.
 
@@ -64,6 +64,7 @@
 	      strerror (err), err, strerror (ETIMEDOUT), ETIMEDOUT);
       pthread_exit ((void *) 1l);
     }
+  puts ("child: timedwrlock failed with ETIMEDOUT");
 
   struct timeval tv2;
   (void) gettimeofday (&tv2, NULL);
@@ -93,6 +94,7 @@
       puts ("2nd timedwrlock did not return EINVAL");
       pthread_exit ((void *) 1l);
     }
+  puts ("child: timedwrlock failed with EINVAL");
 
   return NULL;
 }
@@ -145,6 +147,7 @@
 	  printf ("round %Zu: rwlock_timedrdlock failed\n", cnt);
 	  exit (1);
 	}
+      printf ("%zu: got timedrdlock\n", cnt);
 
       pthread_t th;
       if (pthread_create (&th, NULL, tf, &r) != 0)

Modified: trunk/libc/nscd/Makefile
==============================================================================
--- trunk/libc/nscd/Makefile (original)
+++ trunk/libc/nscd/Makefile Sun Jan 14 16:45:23 2007
@@ -1,4 +1,4 @@
-# Copyright (C) 1998,2000,2002,2003,2004,2005,2006
+# Copyright (C) 1998,2000,2002,2003,2004,2005,2006,2007
 #	Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
 
@@ -22,7 +22,8 @@
 #
 subdir	:= nscd
 
-routines := nscd_getpw_r nscd_getgr_r nscd_gethst_r nscd_getai nscd_initgroups
+routines := nscd_getpw_r nscd_getgr_r nscd_gethst_r nscd_getai \
+	    nscd_initgroups nscd_getserv_r
 aux	:= nscd_helper
 
 include ../Makeconfig
@@ -32,6 +33,7 @@
 
 nscd-modules := nscd connections pwdcache getpwnam_r getpwuid_r grpcache \
 		getgrnam_r getgrgid_r hstcache gethstbyad_r gethstbynm2_r \
+		getsrvbynm_r getsrvbypt_r servicescache \
 		dbg_log nscd_conf nscd_stat cache mem nscd_setup_thread \
 		xmalloc xstrdup aicache initgrcache gai
 
@@ -117,6 +119,9 @@
 CFLAGS-selinux.c += $(nscd-cflags)
 CFLAGS-initgrcache.c += $(nscd-cflags)
 CFLAGS-gai.c += $(nscd-cflags)
+CFLAGS-servicescache.c += $(nscd-cflags)
+CFLAGS-getsrvbynm_r.c += $(nscd-cflags)
+CFLAGS-getsrvbypt_r.c += $(nscd-cflags)
 
 ifeq (yesyes,$(have-fpie)$(build-shared))
 relro-LDFLAGS += -Wl,-z,now

Modified: trunk/libc/nscd/cache.c
==============================================================================
--- trunk/libc/nscd/cache.c (original)
+++ trunk/libc/nscd/cache.c Sun Jan 14 16:45:23 2007
@@ -1,4 +1,4 @@
-/* Copyright (c) 1998, 1999, 2003-2005, 2006 Free Software Foundation, Inc.
+/* Copyright (c) 1998, 1999, 2003-2006, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 1998.
 
@@ -40,6 +40,25 @@
 unsigned int reload_count = DEFAULT_RELOAD_LIMIT;
 
 
+static void (*const readdfcts[LASTREQ]) (struct database_dyn *,
+					 struct hashentry *,
+					 struct datahead *) =
+{
+  [GETPWBYNAME] = readdpwbyname,
+  [GETPWBYUID] = readdpwbyuid,
+  [GETGRBYNAME] = readdgrbyname,
+  [GETGRBYGID] = readdgrbygid,
+  [GETHOSTBYNAME] = readdhstbyname,
+  [GETHOSTBYNAMEv6] = readdhstbynamev6,
+  [GETHOSTBYADDR] = readdhstbyaddr,
+  [GETHOSTBYADDRv6] = readdhstbyaddrv6,
+  [GETAI] = readdhstai,
+  [INITGROUPS] = readdinitgroups,
+  [GETSERVBYNAME] = readdservbyname,
+  [GETSERVBYPORT] = readdservbyport
+};
+
+
 /* Search the cache for a matching entry and return it when found.  If
    this fails search the negative cache and return (void *) -1 if this
    search was successful.  Otherwise return NULL.
@@ -328,51 +347,10 @@
 		      /* Reload the value.  We do this only for the
 			 initially used key, not the additionally
 			 added derived value.  */
-		      switch (runp->type)
-			{
-			case GETPWBYNAME:
-			  readdpwbyname (table, runp, dh);
-			  break;
-
-			case GETPWBYUID:
-			  readdpwbyuid (table, runp, dh);
-			  break;
-
-			case GETGRBYNAME:
-			  readdgrbyname (table, runp, dh);
-			  break;
-
-			case GETGRBYGID:
-			  readdgrbygid (table, runp, dh);
-			  break;
-
-			case GETHOSTBYNAME:
-			  readdhstbyname (table, runp, dh);
-			  break;
-
-			case GETHOSTBYNAMEv6:
-			  readdhstbynamev6 (table, runp, dh);
-			  break;
-
-			case GETHOSTBYADDR:
-			  readdhstbyaddr (table, runp, dh);
-			  break;
-
-			case GETHOSTBYADDRv6:
-			  readdhstbyaddrv6 (table, runp, dh);
-			  break;
-
-			case GETAI:
-			  readdhstai (table, runp, dh);
-			  break;
-
-			case INITGROUPS:
-			  readdinitgroups (table, runp, dh);
-			  break;
-
-			default:
-			  assert (! "should never happen");
-			}
+		      assert (runp->type < LASTREQ
+			      && readdfcts[runp->type] != NULL);
+
+		      readdfcts[runp->type] (table, runp, dh);
 
 		      /* If the entry has been replaced, we might need
 			 cleanup.  */

Modified: trunk/libc/nscd/connections.c
==============================================================================
--- trunk/libc/nscd/connections.c (original)
+++ trunk/libc/nscd/connections.c Sun Jan 14 16:45:23 2007
@@ -1,5 +1,5 @@
 /* Inner loops of cache daemon.
-   Copyright (C) 1998-2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 1998-2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 1998.
 
@@ -75,7 +75,7 @@
 static void finish_drop_privileges (void);
 
 /* Map request type to a string.  */
-const char *serv2str[LASTREQ] =
+const char *const serv2str[LASTREQ] =
 {
   [GETPWBYNAME] = "GETPWBYNAME",
   [GETPWBYUID] = "GETPWBYUID",
@@ -92,7 +92,10 @@
   [GETFDGR] = "GETFDGR",
   [GETFDHST] = "GETFDHST",
   [GETAI] = "GETAI",
-  [INITGROUPS] = "INITGROUPS"
+  [INITGROUPS] = "INITGROUPS",
+  [GETSERVBYNAME] = "GETSERVBYNAME",
+  [GETSERVBYPORT] = "GETSERVBYPORT",
+  [GETFDSERV] = "GETFDSERV"
 };
 
 /* The control data structures for the services.  */
@@ -107,6 +110,7 @@
     .propagate = 1,
     .shared = 0,
     .max_db_size = DEFAULT_MAX_DB_SIZE,
+    .reset_res = 0,
     .filename = "/etc/passwd",
     .db_filename = _PATH_NSCD_PASSWD_DB,
     .disabled_iov = &pwd_iov_disabled,
@@ -125,6 +129,7 @@
     .propagate = 1,
     .shared = 0,
     .max_db_size = DEFAULT_MAX_DB_SIZE,
+    .reset_res = 0,
     .filename = "/etc/group",
     .db_filename = _PATH_NSCD_GROUP_DB,
     .disabled_iov = &grp_iov_disabled,
@@ -143,10 +148,30 @@
     .propagate = 0,		/* Not used.  */
     .shared = 0,
     .max_db_size = DEFAULT_MAX_DB_SIZE,
+    .reset_res = 1,
     .filename = "/etc/hosts",
     .db_filename = _PATH_NSCD_HOSTS_DB,
     .disabled_iov = &hst_iov_disabled,
     .postimeout = 3600,
+    .negtimeout = 20,
+    .wr_fd = -1,
+    .ro_fd = -1,
+    .mmap_used = false
+  },
+  [servdb] = {
+    .lock = PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP,
+    .prunelock = PTHREAD_MUTEX_INITIALIZER,
+    .enabled = 0,
+    .check_file = 1,
+    .persistent = 0,
+    .propagate = 0,		/* Not used.  */
+    .shared = 0,
+    .max_db_size = DEFAULT_MAX_DB_SIZE,
+    .reset_res = 0,
+    .filename = "/etc/services",
+    .db_filename = _PATH_NSCD_SERVICES_DB,
+    .disabled_iov = &serv_iov_disabled,
+    .postimeout = 28800,
     .negtimeout = 20,
     .wr_fd = -1,
     .ro_fd = -1,
@@ -170,7 +195,10 @@
   [GETFDGR] = &dbs[grpdb],
   [GETFDHST] = &dbs[hstdb],
   [GETAI] = &dbs[hstdb],
-  [INITGROUPS] = &dbs[grpdb]
+  [INITGROUPS] = &dbs[grpdb],
+  [GETSERVBYNAME] = &dbs[servdb],
+  [GETSERVBYPORT] = &dbs[servdb],
+  [GETFDSERV] = &dbs[servdb]
 };
 
 
@@ -305,7 +333,7 @@
 static int
 verify_persistent_db (void *mem, struct database_pers_head *readhead, int dbnr)
 {
-  assert (dbnr == pwddb || dbnr == grpdb || dbnr == hstdb);
+  assert (dbnr == pwddb || dbnr == grpdb || dbnr == hstdb || dbnr == servdb);
 
   time_t now = time (NULL);
 
@@ -821,18 +849,16 @@
   dbtype number;
   int32_t resp;
 
-  if (strcmp (key, "passwd") == 0)
-    number = pwddb;
-  else if (strcmp (key, "group") == 0)
-    number = grpdb;
-  else if (__builtin_expect (strcmp (key, "hosts"), 0) == 0)
-    {
-      number = hstdb;
-
-      /* Re-initialize the resolver.  resolv.conf might have changed.  */
-      res_init ();
-    }
-  else
+  for (number = pwddb; number < lastdb; ++number)
+    if (strcmp (key, dbnames[number]) == 0)
+      {
+	if (dbs[number].reset_res)
+	  res_init ();
+
+	break;
+      }
+
+  if (number == lastdb)
     {
       resp = EINVAL;
       writeall (fd, &resp, sizeof (resp));
@@ -911,8 +937,9 @@
      need to verify that the request type is valid, since it has not
      yet been checked at this point.  */
   if (selinux_enabled
-      && __builtin_expect (req->type, GETPWBYNAME) >= GETPWBYNAME
-      && __builtin_expect (req->type, LASTREQ) < LASTREQ
+      && __builtin_expect (req->type >= GETPWBYNAME, 1)
+      && __builtin_expect (req->type < LASTREQ, 1)
+      && __builtin_expect (req->type < SHUTDOWN || req->type > INVALIDATE, 1)
       && nscd_request_avc_has_perm (fd, req->type) != 0)
     return;
 
@@ -921,8 +948,9 @@
   // XXX Clean up so that each new command need not introduce a
   // XXX new conditional.
   if ((__builtin_expect (req->type, GETPWBYNAME) >= GETPWBYNAME
-       && __builtin_expect (req->type, LASTDBREQ) <= LASTDBREQ)
-      || req->type == GETAI || req->type == INITGROUPS)
+       && __builtin_expect (req->type, GETHOSTBYADDRv6) <= GETHOSTBYADDRv6)
+      || req->type == GETAI || req->type == INITGROUPS
+      || req->type == GETSERVBYNAME || req->type == GETSERVBYPORT)
     {
       if (__builtin_expect (debug_level, 0) > 0)
 	{
@@ -1066,6 +1094,14 @@
       addinitgroups (db, fd, req, key, uid);
       break;
 
+    case GETSERVBYNAME:
+      addservbyname (db, fd, req, key, uid);
+      break;
+
+    case GETSERVBYPORT:
+      addservbyport (db, fd, req, key, uid);
+      break;
+
     case GETSTAT:
     case SHUTDOWN:
     case INVALIDATE:
@@ -1111,6 +1147,7 @@
     case GETFDPW:
     case GETFDGR:
     case GETFDHST:
+    case GETFDSERV:
 #ifdef SCM_RIGHTS
       send_ro_fd (serv2db[req->type], key, fd);
 #endif
@@ -1152,7 +1189,7 @@
       if (n == -1)
 	{
 	  dbg_log (_("\
-cannot open /proc/self/cmdline: %s; disabling paranoia mode"),
+cannot read /proc/self/cmdline: %s; disabling paranoia mode"),
 		   strerror (errno));
 
 	  close (fd);

Modified: trunk/libc/nscd/gai.c
==============================================================================
--- trunk/libc/nscd/gai.c (original)
+++ trunk/libc/nscd/gai.c Sun Jan 14 16:45:23 2007
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 2004.
 
@@ -17,7 +17,6 @@
 
 /* This file uses the getaddrinfo code but it compiles it without NSCD
    support.  We just need a few symbol renames.  */
-#define __getservbyname_r getservbyname_r
 #define __inet_aton inet_aton
 #define __getsockname getsockname
 #define __socket socket

Modified: trunk/libc/nscd/grpcache.c
==============================================================================
--- trunk/libc/nscd/grpcache.c (original)
+++ trunk/libc/nscd/grpcache.c Sun Jan 14 16:45:23 2007
@@ -1,5 +1,5 @@
 /* Cache handling for group lookup.
-   Copyright (C) 1998-2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 1998-2005, 2006, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 1998.
 
@@ -445,23 +445,14 @@
 	dbg_log (_("Reloading \"%s\" in group cache!"), keystr);
     }
 
-#if 0
-  uid_t oldeuid = 0;
-  if (db->secure)
-    {
-      oldeuid = geteuid ();
-      pthread_seteuid_np (uid);
-    }
-#endif
-
   while (lookup (req->type, key, &resultbuf, buffer, buflen, &grp) != 0
 	 && (errval = errno) == ERANGE)
     {
-      char *old_buffer = buffer;
       errno = 0;
 
       if (__builtin_expect (buflen > 32768, 0))
 	{
+	  char *old_buffer = buffer;
 	  buflen *= 2;
 	  buffer = (char *) realloc (use_malloc ? buffer : NULL, buflen);
 	  if (buffer == NULL)
@@ -486,11 +477,6 @@
 	buffer = (char *) extend_alloca (buffer, buflen, 2 * buflen);
     }
 
-#if 0
-  if (db->secure)
-    pthread_seteuid_np (oldeuid);
-#endif
-
   cache_addgr (db, fd, req, keystr, grp, uid, he, dh, errval);
 
   if (use_malloc)

Modified: trunk/libc/nscd/hstcache.c
==============================================================================
--- trunk/libc/nscd/hstcache.c (original)
+++ trunk/libc/nscd/hstcache.c Sun Jan 14 16:45:23 2007
@@ -1,5 +1,5 @@
 /* Cache handling for host lookup.
-   Copyright (C) 1998-2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 1998-2005, 2006, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 1998.
 
@@ -463,24 +463,15 @@
 	dbg_log (_("Reloading \"%s\" in hosts cache!"), (char *) str);
     }
 
-#if 0
-  uid_t oldeuid = 0;
-  if (db->secure)
-    {
-      oldeuid = geteuid ();
-      pthread_seteuid_np (uid);
-    }
-#endif
-
   while (lookup (req->type, key, &resultbuf, buffer, buflen, &hst) != 0
 	 && h_errno == NETDB_INTERNAL
 	 && (errval = errno) == ERANGE)
     {
-      char *old_buffer = buffer;
       errno = 0;
 
       if (__builtin_expect (buflen > 32768, 0))
 	{
+	  char *old_buffer = buffer;
 	  buflen *= 2;
 	  buffer = (char *) realloc (use_malloc ? buffer : NULL, buflen);
 	  if (buffer == NULL)
@@ -505,11 +496,6 @@
 	buffer = (char *) extend_alloca (buffer, buflen, 2 * buflen);
     }
 
-#if 0
-  if (db->secure)
-    pthread_seteuid_np (oldeuid);
-#endif
-
   cache_addhst (db, fd, req, key, hst, uid, he, dh,
 		h_errno == TRY_AGAIN ? errval : 0);
 

Modified: trunk/libc/nscd/nscd-client.h
==============================================================================
--- trunk/libc/nscd/nscd-client.h (original)
+++ trunk/libc/nscd/nscd-client.h Sun Jan 14 16:45:23 2007
@@ -1,4 +1,4 @@
-/* Copyright (c) 1998, 1999, 2000, 2003, 2004, 2005, 2006
+/* Copyright (c) 1998, 1999, 2000, 2003, 2004, 2005, 2006, 2007
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@xxxxxxx>, 1998.
@@ -56,7 +56,6 @@
   GETHOSTBYNAMEv6,
   GETHOSTBYADDR,
   GETHOSTBYADDRv6,
-  LASTDBREQ = GETHOSTBYADDRv6,
   SHUTDOWN,		/* Shut the server down.  */
   GETSTAT,		/* Get the server statistic.  */
   INVALIDATE,           /* Invalidate one special cache.  */
@@ -65,6 +64,9 @@
   GETFDHST,
   GETAI,
   INITGROUPS,
+  GETSERVBYNAME,
+  GETSERVBYPORT,
+  GETFDSERV,
   LASTREQ
 } request_type;
 
@@ -151,6 +153,19 @@
   int32_t found;
   nscd_ssize_t ngrps;
 } initgr_response_header;
+
+
+/* Structure sent in reply to services query.  Note that this struct is
+   sent also if the service is disabled or there is no record found.  */
+typedef struct
+{
+  int32_t version;
+  int32_t found;
+  nscd_ssize_t s_name_len;
+  nscd_ssize_t s_proto_len;
+  nscd_ssize_t s_aliases_cnt;
+  int32_t s_port;
+} serv_response_header;
 
 
 /* Type for offsets in data part of database.  */
@@ -186,6 +201,7 @@
     hst_response_header hstdata;
     ai_response_header aidata;
     initgr_response_header initgrdata;
+    serv_response_header servdata;
     nscd_ssize_t align1;
     nscd_time_t align2;
   } data[0];

Modified: trunk/libc/nscd/nscd.c
==============================================================================
--- trunk/libc/nscd/nscd.c (original)
+++ trunk/libc/nscd/nscd.c Sun Jan 14 16:45:23 2007
@@ -332,15 +332,15 @@
 	    exit (EXIT_FAILURE);
 
 	  request_header req;
-	  if (strcmp (arg, "passwd") == 0)
-	    req.key_len = sizeof "passwd";
-	  else if (strcmp (arg, "group") == 0)
-	    req.key_len = sizeof "group";
-	  else if (strcmp (arg, "hosts") == 0)
-	    req.key_len = sizeof "hosts";
-	  else
+	  dbtype cnt;
+	  for (cnt = pwddb; cnt < lastdb; ++cnt)
+	    if (strcmp (arg, dbnames[cnt]) == 0)
+	      break;
+
+	  if (cnt == lastdb)
 	    return ARGP_ERR_UNKNOWN;
 
+	  req.key_len = strlen (arg) + 1;
 	  req.version = NSCD_VERSION;
 	  req.type = INVALIDATE;
 

Modified: trunk/libc/nscd/nscd.conf
==============================================================================
--- trunk/libc/nscd/nscd.conf (original)
+++ trunk/libc/nscd/nscd.conf Sun Jan 14 16:45:23 2007
@@ -26,7 +26,7 @@
 #	max-db-size		<service> <number bytes>
 #	auto-propagate		<service> <yes|no>
 #
-# Currently supported cache names (services): passwd, group, hosts
+# Currently supported cache names (services): passwd, group, hosts, services
 #
 
 
@@ -68,3 +68,12 @@
 	persistent		hosts		yes
 	shared			hosts		yes
 	max-db-size		hosts		33554432
+
+	enable-cache		services	yes
+	positive-time-to-live	services	28800
+	negative-time-to-live	services	20
+	suggested-size		services	211
+	check-files		services	yes
+	persistent		services	yes
+	shared			services	yes
+	max-db-size		services	33554432

Modified: trunk/libc/nscd/nscd.h
==============================================================================
--- trunk/libc/nscd/nscd.h (original)
+++ trunk/libc/nscd/nscd.h Sun Jan 14 16:45:23 2007
@@ -1,4 +1,4 @@
-/* Copyright (c) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006
+/* Copyright (c) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@xxxxxxx>, 1998.
@@ -38,6 +38,7 @@
   pwddb,
   grpdb,
   hstdb,
+  servdb,
   lastdb
 } dbtype;
 
@@ -65,7 +66,8 @@
   int persistent;
   int shared;
   int propagate;
-  const char filename[12];
+  int reset_res;
+  const char filename[16];
   const char *db_filename;
   time_t file_mtime;
   size_t suggested_module;
@@ -92,6 +94,7 @@
 #define _PATH_NSCD_PASSWD_DB	"/var/db/nscd/passwd"
 #define _PATH_NSCD_GROUP_DB	"/var/db/nscd/group"
 #define _PATH_NSCD_HOSTS_DB	"/var/db/nscd/hosts"
+#define _PATH_NSCD_SERVICES_DB	"/var/db/nscd/services"
 
 /* Path used when not using persistent storage.  */
 #define _PATH_NSCD_XYZ_DB_TMP	"/var/run/nscd/dbXXXXXX"
@@ -110,12 +113,13 @@
 
 /* Global variables.  */
 extern struct database_dyn dbs[lastdb];
-extern const char *dbnames[lastdb];
-extern const char *serv2str[LASTREQ];
+extern const char *const dbnames[lastdb];
+extern const char *const serv2str[LASTREQ];
 
 extern const struct iovec pwd_iov_disabled;
 extern const struct iovec grp_iov_disabled;
 extern const struct iovec hst_iov_disabled;
+extern const struct iovec serv_iov_disabled;
 
 
 /* Initial number of threads to run.  */
@@ -238,6 +242,16 @@
 extern void readdinitgroups (struct database_dyn *db, struct hashentry *he,
 			     struct datahead *dh);
 
+/* servicecache.c */
+extern void addservbyname (struct database_dyn *db, int fd,
+			   request_header *req, void *key, uid_t uid);
+extern void readdservbyname (struct database_dyn *db, struct hashentry *he,
+			     struct datahead *dh);
+extern void addservbyport (struct database_dyn *db, int fd,
+			   request_header *req, void *key, uid_t uid);
+extern void readdservbyport (struct database_dyn *db, struct hashentry *he,
+			     struct datahead *dh);
+
 /* mem.c */
 extern void *mempool_alloc (struct database_dyn *db, size_t len);
 extern void gc (struct database_dyn *db);

Modified: trunk/libc/nscd/nscd_conf.c
==============================================================================
--- trunk/libc/nscd/nscd_conf.c (original)
+++ trunk/libc/nscd/nscd_conf.c Sun Jan 14 16:45:23 2007
@@ -1,4 +1,4 @@
-/* Copyright (c) 1998,2000,2003,2004,2005,2006 Free Software Foundation, Inc.
+/* Copyright (c) 1998, 2000, 2003-2006, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@xxxxxxx>, 1998.
 
@@ -37,11 +37,12 @@
 
 
 /* Names of the databases.  */
-const char *dbnames[lastdb] =
+const char *const dbnames[lastdb] =
 {
   [pwddb] = "passwd",
   [grpdb] = "group",
-  [hstdb] = "hosts"
+  [hstdb] = "hosts",
+  [servdb] = "services"
 };
 
 
@@ -52,7 +53,7 @@
     if (strcmp (name, dbnames[cnt]) == 0)
       return cnt;
 
-  error (0, 0, _("database %s is not supported\n"), name);
+  error (0, 0, _("database %s is not supported"), name);
   return -1;
 }
 

Modified: trunk/libc/nscd/nscd_gethst_r.c
==============================================================================
--- trunk/libc/nscd/nscd_gethst_r.c (original)
+++ trunk/libc/nscd/nscd_gethst_r.c Sun Jan 14 16:45:23 2007
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998-2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 1998-2005, 2006, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 1998.
 
@@ -17,15 +17,10 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-#include <assert.h>
 #include <errno.h>
-#include <netdb.h>
 #include <resolv.h>
-#include <stdint.h>
 #include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #include <arpa/nameser.h>
 #include <not-cancel.h>
 
@@ -175,7 +170,7 @@
       if (sock == -1)
 	{
 	  __nss_not_use_nscd_hosts = 1;
-	  goto out;;
+	  goto out;
 	}
 
       hst_resp = &hst_resp_mem;
@@ -193,7 +188,6 @@
 
   if (hst_resp->found == 1)
     {
-      struct iovec vec[4];
       char *cp = buffer;
       uintptr_t align1;
       uintptr_t align2;
@@ -253,6 +247,8 @@
 
       if (h_name == NULL)
 	{
+	  struct iovec vec[4];
+
 	  vec[0].iov_base = resultbuf->h_name;
 	  vec[0].iov_len = hst_resp->h_name_len;
 	  total_len = hst_resp->h_name_len;

Modified: trunk/libc/nscd/nscd_proto.h
==============================================================================
--- trunk/libc/nscd/nscd_proto.h (original)
+++ trunk/libc/nscd/nscd_proto.h Sun Jan 14 16:45:23 2007
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999, 2000, 2002, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1998-2000, 2002, 2004, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@xxxxxxx>, 1998.
 
@@ -35,6 +35,7 @@
 extern int __nss_not_use_nscd_passwd attribute_hidden;
 extern int __nss_not_use_nscd_group attribute_hidden;
 extern int __nss_not_use_nscd_hosts attribute_hidden;
+extern int __nss_not_use_nscd_services attribute_hidden;
 
 extern int __nscd_getpwnam_r (const char *name, struct passwd *resultbuf,
 			      char *buffer, size_t buflen,
@@ -64,4 +65,11 @@
 			 int *h_errnop);
 extern int __nscd_getgrouplist (const char *user, gid_t group, long int *size,
 				gid_t **groupsp, long int limit);
+extern int __nscd_getservbyname_r (const char *name, const char *proto,
+				   struct servent *result_buf, char *buf,
+				   size_t buflen, struct servent **result);
+extern int __nscd_getservbyport_r (int port, const char *proto,
+				   struct servent *result_buf, char *buf,
+				   size_t buflen, struct servent **result);
+
 #endif /* _NSCD_PROTO_H */

Modified: trunk/libc/nscd/pwdcache.c
==============================================================================
--- trunk/libc/nscd/pwdcache.c (original)
+++ trunk/libc/nscd/pwdcache.c Sun Jan 14 16:45:23 2007
@@ -1,5 +1,5 @@
 /* Cache handling for passwd lookup.
-   Copyright (C) 1998-2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 1998-2005, 2006, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 1998.
 
@@ -440,23 +440,14 @@
 	dbg_log (_("Reloading \"%s\" in password cache!"), keystr);
     }
 
-#if 0
-  uid_t oldeuid = 0;
-  if (db->secure)
-    {
-      oldeuid = geteuid ();
-      pthread_seteuid_np (c_uid);
-    }
-#endif
-
   while (lookup (req->type, key, &resultbuf, buffer, buflen, &pwd) != 0
 	 && (errval = errno) == ERANGE)
     {
-      char *old_buffer = buffer;
       errno = 0;
 
       if (__builtin_expect (buflen > 32768, 0))
 	{
+	  char *old_buffer = buffer;
 	  buflen *= 2;
 	  buffer = (char *) realloc (use_malloc ? buffer : NULL, buflen);
 	  if (buffer == NULL)
@@ -481,11 +472,6 @@
 	buffer = (char *) extend_alloca (buffer, buflen, 2 * buflen);
     }
 
-#if 0
-  if (db->secure)
-    pthread_seteuid_np (oldeuid);
-#endif
-
   /* Add the entry to the cache.  */
   cache_addpw (db, fd, req, keystr, pwd, c_uid, he, dh, errval);
 

Modified: trunk/libc/nscd/selinux.c
==============================================================================
--- trunk/libc/nscd/selinux.c (original)
+++ trunk/libc/nscd/selinux.c Sun Jan 14 16:45:23 2007
@@ -1,5 +1,5 @@
 /* SELinux access controls for nscd.
-   Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Matthew Rickard <mjricka@xxxxxxxxxxxxxx>, 2004.
 
@@ -63,7 +63,12 @@
   [GETFDGR] = NSCD__SHMEMGRP,
   [GETFDHST] = NSCD__SHMEMHOST,
   [GETAI] = NSCD__GETHOST,
-  [INITGROUPS] = NSCD__GETGRP
+  [INITGROUPS] = NSCD__GETGRP,
+#ifdef NSCD__GETSERV
+  [GETSERVBYNAME] = NSCD__GETSERV,
+  [GETSERVBYPORT] = NSCD__GETSERV,
+  [GETFDSERV] = NSCD__SHMEMSERV,
+#endif
 };
 
 /* Store an entry ref to speed AVC decisions.  */

Modified: trunk/libc/nss/Versions
==============================================================================
--- trunk/libc/nss/Versions (original)
+++ trunk/libc/nss/Versions Sun Jan 14 16:45:23 2007
@@ -9,7 +9,7 @@
   }
   GLIBC_PRIVATE {
     _nss_files_parse_grent; _nss_files_parse_pwent; _nss_files_parse_spent;
-    __nss_disable_nscd; __nss_lookup_function;
+    __nss_disable_nscd; __nss_lookup_function; __nss_services_lookup;
   }
 }
 

Modified: trunk/libc/nss/nsswitch.c
==============================================================================
--- trunk/libc/nss/nsswitch.c (original)
+++ trunk/libc/nss/nsswitch.c Sun Jan 14 16:45:23 2007
@@ -1,5 +1,4 @@
-/* Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2006
-   Free Software Foundation, Inc.
+/* Copyright (C) 1996-1999, 2001-2006, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 1996.
 
@@ -708,6 +707,7 @@
   __nss_not_use_nscd_passwd = -1;
   __nss_not_use_nscd_group = -1;
   __nss_not_use_nscd_hosts = -1;
+  __nss_not_use_nscd_services = -1;
 }
 
 

Modified: trunk/libc/scripts/check-local-headers.sh
==============================================================================
--- trunk/libc/scripts/check-local-headers.sh (original)
+++ trunk/libc/scripts/check-local-headers.sh Sun Jan 14 16:45:23 2007
@@ -1,5 +1,5 @@
 #! /bin/bash
-# Copyright (C) 2005 Free Software Foundation, Inc.
+# Copyright (C) 2005, 2007 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
@@ -26,7 +26,7 @@
 
 # Search all dependency files for file names in the include directory.
 # There are a few system headers we are known to use.
-if fgrep "$includedir" */*.d |
+if fgrep "$includedir" */*.{o,os,oS}.d |
 fgrep -v "$includedir/asm" |
 fgrep -v "$includedir/linux" |
 fgrep -v "$includedir/selinux" |

Modified: trunk/libc/stdlib/Makefile
==============================================================================
--- trunk/libc/stdlib/Makefile (original)
+++ trunk/libc/stdlib/Makefile Sun Jan 14 16:45:23 2007
@@ -68,7 +68,7 @@
 		   tst-limits tst-rand48 bug-strtod tst-setcontext	    \
 		   test-a64l tst-qsort tst-system testmb2 bug-strtod2	    \
 		   tst-atof1 tst-atof2 tst-strtod2 tst-strtod3 tst-rand48-2 \
-		   tst-makecontext
+		   tst-makecontext tst-strtod4
 
 include ../Makeconfig
 
@@ -114,6 +114,7 @@
 
 tst-strtod-ENV = LOCPATH=$(common-objpfx)localedata
 tst-strtod3-ENV = LOCPATH=$(common-objpfx)localedata
+tst-strtod4-ENV = LOCPATH=$(common-objpfx)localedata
 testmb2-ENV = LOCPATH=$(common-objpfx)localedata
 
 # Run a test on the header files we use.

Modified: trunk/libc/stdlib/strtod_l.c
==============================================================================
--- trunk/libc/stdlib/strtod_l.c (original)
+++ trunk/libc/stdlib/strtod_l.c Sun Jan 14 16:45:23 2007
@@ -1,5 +1,6 @@
 /* Convert string representing a number to float value, using given locale.
-   Copyright (C) 1997,1998,2002,2004,2005,2006 Free Software Foundation, Inc.
+   Copyright (C) 1997,1998,2002,2004,2005,2006,2007
+   Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 1997.
 
@@ -650,10 +651,11 @@
 	  if (c != '0')
 	    {
 	      for (cnt = 0; thousands[cnt] != '\0'; ++cnt)
-		if (c != thousands[cnt])
+		if (thousands[cnt] != cp[cnt])
 		  break;
 	      if (thousands[cnt] != '\0')
 		break;
+	      cp += cnt - 1;
 	    }
 	  c = *++cp;
 	}
@@ -665,14 +667,23 @@
   if (!((c >= L_('0') && c <= L_('9'))
 	|| (base == 16 && ((CHAR_TYPE) TOLOWER (c) >= L_('a')
 			   && (CHAR_TYPE) TOLOWER (c) <= L_('f')))
+	|| (
 #ifdef USE_WIDE_CHAR
-	|| c == (wint_t) decimal
+	    c == (wint_t) decimal
 #else
-	|| ({ for (cnt = 0; decimal[cnt] != '\0'; ++cnt)
-	      if (decimal[cnt] != cp[cnt])
-		break;
-	      decimal[cnt] == '\0'; })
-#endif
+	    ({ for (cnt = 0; decimal[cnt] != '\0'; ++cnt)
+		 if (decimal[cnt] != cp[cnt])
+		   break;
+	       decimal[cnt] == '\0'; })
+#endif
+	    /* '0x.' alone is not a valid hexadecimal number.
+	       '.' alone is not valid either, but that has been checked
+	       already earlier.  */
+	    && (base != 16
+		|| cp != start_of_digits
+		|| (cp[decimal_len] >= L_('0') && cp[decimal_len] <= L_('9'))
+		|| ((CHAR_TYPE) TOLOWER (cp[decimal_len]) >= L_('a')
+		    && (CHAR_TYPE) TOLOWER (cp[decimal_len]) <= L_('f'))))
 	|| (base == 16 && (cp != start_of_digits
 			   && (CHAR_TYPE) TOLOWER (c) == L_('p')))
 	|| (base != 16 && (CHAR_TYPE) TOLOWER (c) == L_('e'))))
@@ -715,6 +726,7 @@
 		  break;
 	      if (thousands[cnt] != '\0')
 		break;
+	      cp += cnt - 1;
 	    }
 #endif
 	}

Modified: trunk/libc/stdlib/tst-makecontext.c
==============================================================================
--- trunk/libc/stdlib/tst-makecontext.c (original)
+++ trunk/libc/stdlib/tst-makecontext.c Sun Jan 14 16:45:23 2007
@@ -1,4 +1,4 @@
-/* Copyright (C) 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2006, 2007 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
@@ -16,6 +16,7 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+#include <errno.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <ucontext.h>
@@ -36,10 +37,16 @@
 }
 
 int
-main (void)
+do_test (void)
 {
   if (getcontext (&ucp) != 0)
     {
+      if (errno == ENOSYS)
+	{
+	  puts ("context handling not supported");
+	  return 0;
+	}
+
       puts ("getcontext failed");
       return 1;
     }
@@ -47,7 +54,7 @@
   ucp.uc_link = NULL;
   ucp.uc_stack.ss_sp = st1;
   ucp.uc_stack.ss_size = sizeof st1;
-  makecontext (&ucp, (void (*) ()) cf, 1, 78);
+  makecontext (&ucp, (void (*) (void)) cf, 1, 78);
   if (setcontext (&ucp) != 0)
     {
       puts ("setcontext failed");
@@ -55,3 +62,6 @@
     }
   return 2;
 }
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"

Modified: trunk/libc/stdlib/tst-strtod2.c
==============================================================================
--- trunk/libc/stdlib/tst-strtod2.c (original)
+++ trunk/libc/stdlib/tst-strtod2.c Sun Jan 14 16:45:23 2007
@@ -1,22 +1,41 @@
 #include <stdio.h>
 #include <stdlib.h>
+
+struct test
+{
+  const char *str;
+  double result;
+  size_t offset;
+} tests[] =
+{
+  { "0xy", 0.0, 1 },
+  { "0x.y", 0.0, 1 },
+  { "0x0.y", 0.0, 4 },
+  { "0x.0y", 0.0, 4 },
+  { ".y", 0.0, 0 },
+  { "0.y", 0.0, 2 },
+  { ".0y", 0.0, 2 }
+};
 
 static int
 do_test (void)
 {
   int status = 0;
-  const char s[] = "0x";
-  char *ep;
-  double r = strtod (s, &ep);
-  if (r != 0)
+  for (size_t i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
     {
-      printf ("r = %g, expect 0\n", r);
-      status = 1;
-    }
-  if (ep != s + 1)
-    {
-      printf ("strtod parsed %ju characters, expected 1\n", ep - s);
-      status = 1;
+      char *ep;
+      double r = strtod (tests[i].str, &ep);
+      if (r != tests[i].result)
+	{
+	  printf ("test %zu r = %g, expect %g\n", i, r, tests[i].result);
+	  status = 1;
+	}
+      if (ep != tests[i].str + tests[i].offset)
+	{
+	  printf ("test %zu strtod parsed %ju characters, expected %zu\n",
+		  i, ep - tests[i].str, tests[i].offset);
+	  status = 1;
+	}
     }
   return status;
 }

Modified: trunk/libc/sysdeps/i386/i486/bits/atomic.h
==============================================================================
--- trunk/libc/sysdeps/i386/i486/bits/atomic.h (original)
+++ trunk/libc/sysdeps/i386/i486/bits/atomic.h Sun Jan 14 16:45:23 2007
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 2002.
 
@@ -56,26 +56,33 @@
 #endif
 
 
-#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
+#if __GNUC_PREREQ (4, 1)
+# define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
+  __sync_val_compare_and_swap (mem, oldval, newval)
+#  define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
+  (! __sync_bool_compare_and_swap (mem, oldval, newval))
+#else
+# define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
   ({ __typeof (*mem) ret;						      \
      __asm __volatile (LOCK_PREFIX "cmpxchgb %b2, %1"			      \
 		       : "=a" (ret), "=m" (*mem)			      \
 		       : "q" (newval), "m" (*mem), "0" (oldval));	      \
      ret; })
 
-#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
+# define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
   ({ __typeof (*mem) ret;						      \
      __asm __volatile (LOCK_PREFIX "cmpxchgw %w2, %1"			      \
 		       : "=a" (ret), "=m" (*mem)			      \
 		       : "r" (newval), "m" (*mem), "0" (oldval));	      \
      ret; })
 
-#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
+# define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
   ({ __typeof (*mem) ret;						      \
      __asm __volatile (LOCK_PREFIX "cmpxchgl %2, %1"			      \
 		       : "=a" (ret), "=m" (*mem)			      \
 		       : "r" (newval), "m" (*mem), "0" (oldval));	      \
      ret; })
+#endif
 
 
 #define __arch_c_compare_and_exchange_val_8_acq(mem, newval, oldval) \
@@ -240,8 +247,13 @@
        }								      \
      __result; })
 
-#define atomic_exchange_and_add(mem, value) \
+#if __GNUC_PREREQ (4, 1)
+# define atomic_exchange_and_add(mem, value) \
+  __sync_fetch_and_add (mem, value)
+#else
+# define atomic_exchange_and_add(mem, value) \
   __arch_exchange_and_add_body (LOCK_PREFIX, __arch, mem, value)
+#endif
 
 #define __arch_exchange_and_add_cprefix \
   "cmpl $0, %%gs:%P4\n\tje 0f\n\tlock\n0:\t"

Modified: trunk/libc/sysdeps/x86_64/bits/atomic.h
==============================================================================
--- trunk/libc/sysdeps/x86_64/bits/atomic.h (original)
+++ trunk/libc/sysdeps/x86_64/bits/atomic.h Sun Jan 14 16:45:23 2007
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 2002.
 
@@ -56,34 +56,41 @@
 #endif
 
 
-#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
+#if __GNUC_PREREQ (4, 1)
+# define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
+  __sync_val_compare_and_swap (mem, oldval, newval)
+#  define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
+  (! __sync_bool_compare_and_swap (mem, oldval, newval))
+#else
+# define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
   ({ __typeof (*mem) ret;						      \
      __asm __volatile (LOCK_PREFIX "cmpxchgb %b2, %1"			      \
 		       : "=a" (ret), "=m" (*mem)			      \
 		       : "q" (newval), "m" (*mem), "0" (oldval));	      \
      ret; })
 
-#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
+# define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
   ({ __typeof (*mem) ret;						      \
      __asm __volatile (LOCK_PREFIX "cmpxchgw %w2, %1"			      \
 		       : "=a" (ret), "=m" (*mem)			      \
 		       : "r" (newval), "m" (*mem), "0" (oldval));	      \
      ret; })
 
-#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
+# define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
   ({ __typeof (*mem) ret;						      \
      __asm __volatile (LOCK_PREFIX "cmpxchgl %2, %1"			      \
 		       : "=a" (ret), "=m" (*mem)			      \
 		       : "r" (newval), "m" (*mem), "0" (oldval));	      \
      ret; })
 
-#define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
+# define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
   ({ __typeof (*mem) ret;						      \
      __asm __volatile (LOCK_PREFIX "cmpxchgq %q2, %1"			      \
 		       : "=a" (ret), "=m" (*mem)			      \
 		       : "r" ((long int) (newval)), "m" (*mem),		      \
 			 "0" ((long int) (oldval)));			      \
      ret; })
+#endif
 
 
 #define __arch_c_compare_and_exchange_val_8_acq(mem, newval, oldval) \
@@ -178,8 +185,13 @@
 			   "i" (offsetof (tcbhead_t, multiple_threads)));     \
      result; })
 
-#define atomic_exchange_and_add(mem, value) \
+#if __GNUC_PREREQ (4, 1)
+# define atomic_exchange_and_add(mem, value) \
+  __sync_fetch_and_add (mem, value)
+#else
+# define atomic_exchange_and_add(mem, value) \
   __arch_exchange_and_add_body (LOCK_PREFIX, mem, value)
+#endif
 
 #define __arch_exchange_and_add_cprefix \
   "cmpl $0, %%fs:%P4\n\tje 0f\n\tlock\n0:\t"