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

[commits] r6626 - in /fsf/trunk/libc: ./ include/rpc/ include/sys/ nis/ nptl/ nptl/sysdeps/unix/sysv/linux/ nscd/ socket/ stdio-common...



Author: eglibc
Date: Sat Jul 26 00:07:56 2008
New Revision: 6626

Log:
Import glibc-mainline for 2008-07-26

Added:
    fsf/trunk/libc/socket/have_sock_cloexec.c
Modified:
    fsf/trunk/libc/ChangeLog
    fsf/trunk/libc/include/rpc/clnt.h
    fsf/trunk/libc/include/sys/socket.h
    fsf/trunk/libc/nis/ypclnt.c
    fsf/trunk/libc/nptl/ChangeLog
    fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/mq_notify.c
    fsf/trunk/libc/nscd/connections.c
    fsf/trunk/libc/nscd/nscd_helper.c
    fsf/trunk/libc/socket/Makefile
    fsf/trunk/libc/stdio-common/_i18n_number.h
    fsf/trunk/libc/stdio-common/printf_fp.c
    fsf/trunk/libc/stdio-common/vfprintf.c
    fsf/trunk/libc/sunrpc/Versions
    fsf/trunk/libc/sunrpc/clnt_udp.c
    fsf/trunk/libc/sysdeps/i386/i686/memcmp.S
    fsf/trunk/libc/sysdeps/unix/sysv/linux/kernel-features.h
    fsf/trunk/libc/sysdeps/unix/sysv/linux/opensock.c

Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Sat Jul 26 00:07:56 2008
@@ -1,3 +1,46 @@
+2008-07-25  Ulrich Drepper  <drepper@xxxxxxxxxx>
+
+	* sysdeps/unix/sysv/linux/kernel-features.h: IA-64 and SPARC have
+	the new syscalls, too.
+
+	* sysdeps/i386/i686/memcmp.S: Fix unwind information.
+	Reported by Paul Pluzhnikov <ppluzhnikov@xxxxxxxxxx>.
+
+	[BZ #6698]
+	* stdio-common/_i18n_number.h (_i18n_number_rewrite): Take additional
+	parameter for end of buffer.  If temporary copy is too large use
+	malloc.
+	* stdio-common/vfprintf.c: Adjust for _i18n_number_rewrite
+	interface change.
+	* stdio-common/printf_fp.c (__printf_fp): Likewise..  Account for
+	string rewrite when allocating buffer.
+
+	* sysdeps/unix/sysv/linux/kernel-features.h: PPC has the new
+	syscalls, too.
+
+	* nscd/connections.c (nscd_init): Clean up fcntl call.
+
+	* nscd/nscd_helper.c (open_socket): Use SOCK_CLOEXEC and
+	SOCK_NONBLOCK if possible.
+
+	* sysdeps/unix/sysv/linux/opensock.c (__opensock): Use
+	SOCK_CLOEXEC if available.
+
+	* include/rpc/clnt.h: Declare __libc_clntudp_bufcreate and
+	__libc_clntudp_bufcreate_internal.
+	* include/sys/socket.h: Declare __have_sock_cloexec.
+	* socket/Makefile (aux): Add have_sock_cloexec.
+	* socket/have_sock_cloexec.c: New file.
+	* sunrpc/clnt_udp.h (clntudp_bufcreate): Now a wrapper around
+	__libc_clntudp_bufcreate.
+	(__libc_clntudp_bufcreate): Former implementation of clntudp_bufcreate
+	which takes an additional parameter.  Create socket with non-blocking
+	mode and close-on-exec flag set, if wanted.
+	* sunrpc/Versions: Export __libc_clntudp_bufcreate@GLIBC_PRIVATE.
+	* nis/ypclnt.c (yp_bind_client_create): Use __libc_clntpudp_bufcreate
+	instead of clntudp_create.  The socket has already the close-on-exec
+	flag set if SOCK_CLOEXEC is defined.
+
 2008-07-24  Ulrich Drepper  <drepper@xxxxxxxxxx>
 
 	* sysdeps/unix/sysv/linux/kernel-features.h: Define

Modified: fsf/trunk/libc/include/rpc/clnt.h
==============================================================================
--- fsf/trunk/libc/include/rpc/clnt.h (original)
+++ fsf/trunk/libc/include/rpc/clnt.h Sat Jul 26 00:07:56 2008
@@ -21,6 +21,18 @@
 					   struct timeval __wait_resend,
 					   int *__sockp, u_int __sendsz,
 					   u_int __recvsz) attribute_hidden;
+extern CLIENT *__libc_clntudp_bufcreate (struct sockaddr_in *__raddr,
+					 u_long __program, u_long __version,
+					 struct timeval __wait_resend,
+					 int *__sockp, u_int __sendsz,
+					 u_int __recvsz, int __flags);
+extern CLIENT *__libc_clntudp_bufcreate_internal (struct sockaddr_in *__raddr,
+						  u_long __program,
+						  u_long __version,
+						  struct timeval __wait_resend,
+						  int *__sockp, u_int __sendsz,
+						  u_int __recvsz, int __flags)
+  attribute_hidden;
 extern CLIENT *clntunix_create_internal (struct sockaddr_un *__raddr,
 					 u_long __program, u_long __version,
 					 int *__sockp, u_int __sendsz,

Modified: fsf/trunk/libc/include/sys/socket.h
==============================================================================
--- fsf/trunk/libc/include/sys/socket.h (original)
+++ fsf/trunk/libc/include/sys/socket.h Sat Jul 26 00:07:56 2008
@@ -153,4 +153,12 @@
 # define __connect(fd, addr, len) INTUSE(__connect) (fd, addr, len)
 #endif
 
+#ifdef SOCK_CLOEXEC
+extern int __have_sock_cloexec;
+/* At lot of other functionality became available at the same time as
+   SOCK_CLOEXEC.  Avoid defining separate variables for all of them
+   unless it is really necessary.  */
+# define __have_paccept __have_sock_cloexec
 #endif
+
+#endif

Modified: fsf/trunk/libc/nis/ypclnt.c
==============================================================================
--- fsf/trunk/libc/nis/ypclnt.c (original)
+++ fsf/trunk/libc/nis/ypclnt.c Sat Jul 26 00:07:56 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-2001, 2002, 2003, 2004, 2005, 2006
+/* Copyright (C) 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@xxxxxxx>, 1996.
@@ -28,6 +28,7 @@
 #include <rpcsvc/yp.h>
 #include <rpcsvc/ypclnt.h>
 #include <rpcsvc/ypupd.h>
+#include <sys/socket.h>
 #include <sys/uio.h>
 #include <bits/libc-lock.h>
 
@@ -69,14 +70,24 @@
   ysd->dom_domain[YPMAXDOMAIN] = '\0';
 
   ysd->dom_socket = RPC_ANYSOCK;
-  ysd->dom_client = clntudp_create (&ysd->dom_server_addr, YPPROG, YPVERS,
-				    UDPTIMEOUT, &ysd->dom_socket);
+#ifdef SOCK_CLOEXEC
+# define xflags SOCK_CLOEXEC
+#else
+# define xflags 0
+#endif
+  ysd->dom_client = __libc_clntudp_bufcreate (&ysd->dom_server_addr, YPPROG,
+					      YPVERS, UDPTIMEOUT,
+					      &ysd->dom_socket,
+					      UDPMSGSIZE, UDPMSGSIZE,
+					      xflags);
 
   if (ysd->dom_client != NULL)
     {
+#ifndef SOCK_CLOEXEC
       /* If the program exits, close the socket */
       if (fcntl (ysd->dom_socket, F_SETFD, FD_CLOEXEC) == -1)
 	perror ("fcntl: F_SETFD");
+#endif
     }
 }
 

Modified: fsf/trunk/libc/nptl/ChangeLog
==============================================================================
--- fsf/trunk/libc/nptl/ChangeLog (original)
+++ fsf/trunk/libc/nptl/ChangeLog Sat Jul 26 00:07:56 2008
@@ -1,3 +1,14 @@
+2008-07-25  Ulrich Drepper  <drepper@xxxxxxxxxx>
+
+	* sysdeps/unix/sysv/linux/mq_notify.c (init_mq_netlink): Use
+	SOCK_CLOEXEC if possible.
+
+2008-05-29  Ulrich Drepper  <drepper@xxxxxxxxxx>
+
+	* Makefile (tests): Add tst-rwlock2a.
+	* tst-rwlock2.c: Use TYPE macro to decide what rwlock type to use.
+	* tst-rwlock2a.c: New file.
+
 2008-06-12  Ulrich Drepper  <drepper@xxxxxxxxxx>
 
 	* sysdeps/pthread/pthread.h: Remove inadvertant checkin.
@@ -76,7 +87,7 @@
 
 2008-03-27  Ulrich Drepper  <drepper@xxxxxxxxxx>
 
-	* sysdeps/unix/sysv/linux/bits/local_lim.h: Undefined ARG_MAX if
+	* sysdeps/unix/sysv/linux/bits/local_lim.h: Undefine ARG_MAX if
 	<linux/limits.h> has defined it.
 	* sysdeps/unix/sysv/linux/alpha/bits/local_lim.h: Likewise.
 	* sysdeps/unix/sysv/linux/ia64/bits/local_lim.h: Likewise.

Modified: fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/mq_notify.c
==============================================================================
--- fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/mq_notify.c (original)
+++ fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/mq_notify.c Sat Jul 26 00:07:56 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2004, 2005, 2008 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contribute by Ulrich Drepper <drepper@xxxxxxxxxx>, 2004.
 
@@ -29,6 +29,7 @@
 #include <unistd.h>
 #include <sys/socket.h>
 #include <not-cancel.h>
+#include <kernel-features.h>
 
 
 #ifdef __NR_mq_notify
@@ -152,18 +153,40 @@
 static void
 init_mq_netlink (void)
 {
+#ifdef SOCK_CLOEXEC
+# ifndef __ASSUME_SOCK_CLOEXEC
+  static int have_sock_cloexec;
+# else
+#  define have_sock_cloexec 1
+# endif
+#else
+# define have_sock_cloexec -1
+# define SOCK_CLOEXEC 0
+#endif
+
   /* This code might be called a second time after fork().  The file
      descriptor is inherited from the parent.  */
   if (netlink_socket == -1)
     {
       /* Just a normal netlink socket, not bound.  */
-      netlink_socket = socket (AF_NETLINK, SOCK_RAW, 0);
+      if (have_sock_cloexec)
+	{
+	  netlink_socket = socket (AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, 0);
+#if defined SOCK_CLOEXEC && !defined __ASSUME_SOCK_CLOEXEC
+	  if (have_sock_cloexec == 0)
+	    have_sock_cloexec = (netlink_socket != -1 || errno != EINVAL
+				 ? 1 : -1);
+#endif
+	}
+      if (have_sock_cloexec < 0)
+	netlink_socket = socket (AF_NETLINK, SOCK_RAW, 0);
       /* No need to do more if we have no socket.  */
       if (netlink_socket == -1)
 	return;
 
       /* Make sure the descriptor is closed on exec.  */
-      if (fcntl (netlink_socket, F_SETFD, FD_CLOEXEC) != 0)
+      if (have_sock_cloexec < 0
+	  && fcntl (netlink_socket, F_SETFD, FD_CLOEXEC) != 0)
 	goto errout;
     }
 

Modified: fsf/trunk/libc/nscd/connections.c
==============================================================================
--- fsf/trunk/libc/nscd/connections.c (original)
+++ fsf/trunk/libc/nscd/connections.c Sat Jul 26 00:07:56 2008
@@ -531,7 +531,7 @@
     {
       inotify_fd = inotify_init ();
       if (inotify_fd != -1)
-	fcntl (inotify_fd, F_SETFL, O_NONBLOCK);
+	fcntl (inotify_fd, F_SETFL, O_RDONLY | O_NONBLOCK);
     }
 # endif
 #endif

Modified: fsf/trunk/libc/nscd/nscd_helper.c
==============================================================================
--- fsf/trunk/libc/nscd/nscd_helper.c (original)
+++ fsf/trunk/libc/nscd/nscd_helper.c Sat Jul 26 00:07:56 2008
@@ -33,6 +33,7 @@
 #include <sys/un.h>
 #include <not-cancel.h>
 #include <nis/rpcsvc/nis.h>
+#include <kernel-features.h>
 
 #include "nscd-client.h"
 
@@ -161,7 +162,26 @@
 static int
 open_socket (request_type type, const char *key, size_t keylen)
 {
-  int sock = __socket (PF_UNIX, SOCK_STREAM, 0);
+  int sock;
+
+#ifdef SOCK_CLOEXEC
+# ifndef __ASSUME_SOCK_CLOEXEC
+  if (__have_sock_cloexec >= 0)
+# endif
+    {
+      sock = __socket (PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);
+# ifndef __ASSUME_SOCK_CLOEXEC
+      if (__have_sock_cloexec == 0)
+	__have_sock_cloexec = sock != -1 || errno != EINVAL ? 1 : -1;
+# endif
+    }
+#endif
+#ifndef __ASSUME_SOCK_CLOEXEC
+# ifdef SOCK_CLOEXEC
+  if (__have_sock_cloexec < 0)
+# endif
+    sock = __socket (PF_UNIX, SOCK_STREAM, 0);
+#endif
   if (sock < 0)
     return -1;
 
@@ -172,8 +192,13 @@
   } reqdata;
   size_t real_sizeof_reqdata = sizeof (request_header) + keylen;
 
-  /* Make socket non-blocking.  */
-  __fcntl (sock, F_SETFL, O_RDWR | O_NONBLOCK);
+#ifndef __ASSUME_SOCK_CLOEXEC
+# ifdef SOCK_NONBLOCK
+  if (__have_sock_cloexec < 0)
+# endif
+    /* Make socket non-blocking.  */
+    __fcntl (sock, F_SETFL, O_RDWR | O_NONBLOCK);
+#endif
 
   struct sockaddr_un sun;
   sun.sun_family = AF_UNIX;

Modified: fsf/trunk/libc/socket/Makefile
==============================================================================
--- fsf/trunk/libc/socket/Makefile (original)
+++ fsf/trunk/libc/socket/Makefile Sat Jul 26 00:07:56 2008
@@ -29,6 +29,8 @@
 	    setsockopt shutdown socket socketpair isfdtype opensock	\
 	    sockatmark paccept
 
+aux	 := have_sock_cloexec
+
 distribute := ifreq.h
 
 include ../Rules

Added: fsf/trunk/libc/socket/have_sock_cloexec.c
==============================================================================
--- fsf/trunk/libc/socket/have_sock_cloexec.c (added)
+++ fsf/trunk/libc/socket/have_sock_cloexec.c Sat Jul 26 00:07:56 2008
@@ -1,0 +1,24 @@
+/* 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 <sys/socket.h>
+#include <kernel-features.h>
+
+#if defined SOCK_CLOEXEC && !defined __ASSUME_SOCK_CLOEXEC
+int __have_sock_cloexec;
+#endif

Modified: fsf/trunk/libc/stdio-common/_i18n_number.h
==============================================================================
--- fsf/trunk/libc/stdio-common/_i18n_number.h (original)
+++ fsf/trunk/libc/stdio-common/_i18n_number.h Sat Jul 26 00:07:56 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2004, 2008 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@xxxxxxx>, 2000.
 
@@ -24,7 +24,7 @@
 #include "../locale/outdigitswc.h"
 
 static CHAR_T *
-_i18n_number_rewrite (CHAR_T *w, CHAR_T *rear_ptr)
+_i18n_number_rewrite (CHAR_T *w, CHAR_T *rear_ptr, CHAR_T *end)
 {
 #ifdef COMPILE_WPRINTF
 # define decimal NULL
@@ -58,10 +58,23 @@
 #endif
 
   /* Copy existing string so that nothing gets overwritten.  */
-  CHAR_T *src = (CHAR_T *) alloca ((rear_ptr - w) * sizeof (CHAR_T));
+  CHAR_T *src;
+  bool use_alloca = __libc_use_alloca ((rear_ptr - w) * sizeof (CHAR_T));
+  if (__builtin_expect (use_alloca, true))
+    src = (CHAR_T *) alloca ((rear_ptr - w) * sizeof (CHAR_T));
+  else
+    {
+      src = (CHAR_T *) malloc ((rear_ptr - w) * sizeof (CHAR_T));
+      if (src == NULL)
+	/* If we cannot allocate the memory don't rewrite the string.
+	   It is better than nothing.  */
+	return w;
+    }
+
   CHAR_T *s = (CHAR_T *) __mempcpy (src, w,
 				    (rear_ptr - w) * sizeof (CHAR_T));
-  w = rear_ptr;
+
+  w = end;
 
   /* Process all characters in the string.  */
   while (--s >= src)
@@ -91,5 +104,8 @@
 	}
     }
 
+  if (! use_alloca)
+    free (src);
+
   return w;
 }

Modified: fsf/trunk/libc/stdio-common/printf_fp.c
==============================================================================
--- fsf/trunk/libc/stdio-common/printf_fp.c (original)
+++ fsf/trunk/libc/stdio-common/printf_fp.c Sat Jul 26 00:07:56 2008
@@ -1,5 +1,5 @@
 /* Floating point output for `printf'.
-   Copyright (C) 1995-2003, 2006, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1995-2003, 2006, 2007, 2008 Free Software Foundation, Inc.
 
    This file is part of the GNU C Library.
    Written by Ulrich Drepper <drepper@xxxxxxxxxxxxxx>, 1995.
@@ -1148,6 +1148,7 @@
 
     {
       char *buffer = NULL;
+      char *buffer_end = NULL;
       char *cp = NULL;
       char *tmpptr;
 
@@ -1157,6 +1158,9 @@
 	  size_t decimal_len;
 	  size_t thousands_sep_len;
 	  wchar_t *copywc;
+	  size_t factor = (info->i18n
+			   ? _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MB_CUR_MAX)
+			   : 1);
 
 	  decimal_len = strlen (decimal);
 
@@ -1165,10 +1169,11 @@
 	  else
 	    thousands_sep_len = strlen (thousands_sep);
 
+	  size_t nbuffer = (2 + chars_needed * factor + decimal_len
+			    + ngroups * thousands_sep_len);
 	  if (__builtin_expect (buffer_malloced, 0))
 	    {
-	      buffer = (char *) malloc (2 + chars_needed + decimal_len
-					+ ngroups * thousands_sep_len);
+	      buffer = (char *) malloc (nbuffer);
 	      if (buffer == NULL)
 		{
 		  /* Signal an error to the caller.  */
@@ -1177,8 +1182,8 @@
 		}
 	    }
 	  else
-	    buffer = (char *) alloca (2 + chars_needed + decimal_len
-				      + ngroups * thousands_sep_len);
+	    buffer = (char *) alloca (nbuffer);
+	  buffer_end = buffer + nbuffer;
 
 	  /* Now copy the wide character string.  Since the character
 	     (except for the decimal point and thousands separator) must
@@ -1197,9 +1202,13 @@
       if (__builtin_expect (info->i18n, 0))
         {
 #ifdef COMPILE_WPRINTF
-	  wstartp = _i18n_number_rewrite (wstartp, wcp);
+	  wstartp = _i18n_number_rewrite (wstartp, wcp,
+					  wbuffer + wbuffer_to_alloc);
 #else
-	  tmpptr = _i18n_number_rewrite (tmpptr, cp);
+	  tmpptr = _i18n_number_rewrite (tmpptr, cp, buffer_end);
+	  cp = buffer_end;
+	  assert ((uintptr_t) buffer <= (uintptr_t) tmpptr);
+	  assert ((uintptr_t) tmpptr < (uintptr_t) buffer_end);
 #endif
         }
 

Modified: fsf/trunk/libc/stdio-common/vfprintf.c
==============================================================================
--- fsf/trunk/libc/stdio-common/vfprintf.c (original)
+++ fsf/trunk/libc/stdio-common/vfprintf.c Sat Jul 26 00:07:56 2008
@@ -625,7 +625,7 @@
 				       thousands_sep);			      \
 									      \
 	      if (use_outdigits && base == 10)				      \
-		string = _i18n_number_rewrite (string, workend);	      \
+		string = _i18n_number_rewrite (string, workend, workend);     \
 	    }								      \
 	  /* Simplify further test for num != 0.  */			      \
 	  number.word = number.longlong != 0;				      \
@@ -683,7 +683,7 @@
 				       thousands_sep);			      \
 									      \
 	      if (use_outdigits && base == 10)				      \
-		string = _i18n_number_rewrite (string, workend);	      \
+		string = _i18n_number_rewrite (string, workend, workend);     \
 	    }								      \
 	}								      \
 									      \

Modified: fsf/trunk/libc/sunrpc/Versions
==============================================================================
--- fsf/trunk/libc/sunrpc/Versions (original)
+++ fsf/trunk/libc/sunrpc/Versions Sat Jul 26 00:07:56 2008
@@ -116,4 +116,7 @@
   GLIBC_2.3.4 {
     xdr_quad_t; xdr_u_quad_t;
   }
+  GLIBC_PRIVATE {
+    __libc_clntudp_bufcreate;
+  }
 }

Modified: fsf/trunk/libc/sunrpc/clnt_udp.c
==============================================================================
--- fsf/trunk/libc/sunrpc/clnt_udp.c (original)
+++ fsf/trunk/libc/sunrpc/clnt_udp.c Sat Jul 26 00:07:56 2008
@@ -54,11 +54,14 @@
 #ifdef USE_IN_LIBIO
 # include <wchar.h>
 #endif
+#include <fcntl.h>
 
 #ifdef IP_RECVERR
 #include <errqueue.h>
 #include <sys/uio.h>
 #endif
+
+#include <kernel-features.h>
 
 extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *);
 extern u_long _create_xid (void);
@@ -121,9 +124,9 @@
  * sent and received.
  */
 CLIENT *
-clntudp_bufcreate (struct sockaddr_in *raddr, u_long program, u_long version,
-		   struct timeval wait, int *sockp, u_int sendsz,
-		   u_int recvsz)
+__libc_clntudp_bufcreate (struct sockaddr_in *raddr, u_long program,
+			  u_long version, struct timeval wait, int *sockp,
+			  u_int sendsz, u_int recvsz, int flags)
 {
   CLIENT *cl;
   struct cu_data *cu = NULL;
@@ -178,8 +181,32 @@
     {
       int dontblock = 1;
 
-      *sockp = __socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
-      if (*sockp < 0)
+#ifdef SOCK_NONBLOCK
+# ifndef __ASSUME_SOCK_CLOEXEC
+      if (__have_sock_cloexec >= 0)
+# endif
+	{
+	  *sockp = __socket (AF_INET, SOCK_DGRAM|SOCK_NONBLOCK|flags,
+			     IPPROTO_UDP);
+# ifndef __ASSUME_SOCK_CLOEXEC
+	  if (__have_sock_cloexec == 0)
+	    __have_sock_cloexec = *sockp >= 0 || errno != EINVAL ? 1 : -1;
+# endif
+	}
+#endif
+#ifndef __ASSUME_SOCK_CLOEXEC
+# ifdef SOCK_CLOEXEC
+      if (__have_sock_cloexec < 0)
+# endif
+	{
+	  *sockp = __socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+# ifdef SOCK_CLOEXEC
+	  if (flags & SOCK_CLOEXEC)
+	    fcntl (*sockp, F_SETFD, FD_CLOEXEC);
+# endif
+	}
+#endif
+      if (__builtin_expect (*sockp < 0, 0))
 	{
 	  struct rpc_createerr *ce = &get_rpc_createerr ();
 	  ce->cf_stat = RPC_SYSTEMERROR;
@@ -188,8 +215,13 @@
 	}
       /* attempt to bind to prov port */
       (void) bindresvport (*sockp, (struct sockaddr_in *) 0);
-      /* the sockets rpc controls are non-blocking */
-      (void) __ioctl (*sockp, FIONBIO, (char *) &dontblock);
+#ifndef __ASSUME_SOCK_CLOEXEC
+# ifdef SOCK_CLOEXEC
+      if (__have_sock_cloexec < 0)
+# endif
+	/* the sockets rpc controls are non-blocking */
+	(void) __ioctl (*sockp, FIONBIO, (char *) &dontblock);
+#endif
 #ifdef IP_RECVERR
       {
 	int on = 1;
@@ -212,6 +244,16 @@
     mem_free ((caddr_t) cl, sizeof (CLIENT));
   return (CLIENT *) NULL;
 }
+INTDEF (__libc_clntudp_bufcreate)
+
+CLIENT *
+clntudp_bufcreate (struct sockaddr_in *raddr, u_long program, u_long version,
+		   struct timeval wait, int *sockp, u_int sendsz,
+		   u_int recvsz)
+{
+  return INTUSE(__libc_clntudp_bufcreate) (raddr, program, version, wait,
+					   sockp, sendsz, recvsz, 0);
+}
 INTDEF (clntudp_bufcreate)
 
 CLIENT *
@@ -222,8 +264,8 @@
      struct timeval wait;
      int *sockp;
 {
-  return INTUSE(clntudp_bufcreate) (raddr, program, version, wait, sockp,
-				    UDPMSGSIZE, UDPMSGSIZE);
+  return INTUSE(__libc_clntudp_bufcreate) (raddr, program, version, wait,
+					   sockp, UDPMSGSIZE, UDPMSGSIZE, 0);
 }
 INTDEF (clntudp_create)
 

Modified: fsf/trunk/libc/sysdeps/i386/i686/memcmp.S
==============================================================================
--- fsf/trunk/libc/sysdeps/i386/i686/memcmp.S (original)
+++ fsf/trunk/libc/sysdeps/i386/i686/memcmp.S Sat Jul 26 00:07:56 2008
@@ -29,8 +29,7 @@
 #define ENTRANCE	pushl %ebx; cfi_adjust_cfa_offset (4); \
 			cfi_rel_offset (ebx, 0); ENTER
 #define RETURN		popl %ebx; cfi_adjust_cfa_offset (-4); \
-			cfi_restore (ebx); LEAVE; ret; \
-			cfi_adjust_cfa_offset (4); cfi_rel_offset (ebx, 0);
+			cfi_restore (ebx); LEAVE; ret
 
 /* Load an entry in a jump table into EBX.  TABLE is a jump table
    with relative offsets.  INDEX is a register contains the index
@@ -71,6 +70,8 @@
 	xorl	%eax, %eax
 	RETURN
 
+	cfi_adjust_cfa_offset (4)
+	cfi_rel_offset (ebx, 0)
 L(neq):
 	sbbl	%eax, %eax
 	sbbl	$-1, %eax

Modified: fsf/trunk/libc/sysdeps/unix/sysv/linux/kernel-features.h
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/kernel-features.h (original)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/kernel-features.h Sat Jul 26 00:07:56 2008
@@ -498,10 +498,11 @@
 # define __ASSUME_AT_EXECFN	1
 #endif
 
-/* Support for various CLOEXEC and NONBLOCK flags was added for x86 and
-   x86-64 in 2.6.27.  */
+/* Support for various CLOEXEC and NONBLOCK flags was added for x86,
+   x86-64, PPC, IA-64, and SPARC in 2.6.27.  */
 #if __LINUX_KERNEL_VERSION >= 0x02061b \
-    && (defined __i386__ || defined __x86_64__)
+    && (defined __i386__ || defined __x86_64__ || defined __powerpc__ \
+	|| defined __ia64__ || defined __sparc__)
 # define __ASSUME_SOCK_CLOEXEC	1
 # define __ASSUME_IN_NONBLOCK	1
 # define __ASSUME_PACCEPT	1

Modified: fsf/trunk/libc/sysdeps/unix/sysv/linux/opensock.c
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/opensock.c (original)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/opensock.c Sat Jul 26 00:07:56 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2001, 2002, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2001, 2002, 2007, 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
@@ -22,6 +22,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <sys/socket.h>
+#include <kernel-features.h>
 
 /* Return a socket of any type.  The socket can be used in subsequent
    ioctl calls to talk to the kernel.  */
@@ -70,7 +71,24 @@
     {
       assert (last_type != 0);
 
-      result = __socket (last_family, last_type, 0);
+#ifdef SOCK_CLOEXEC
+# ifndef __ASSUME_SOCK_CLOEXEC
+      if (__have_sock_cloexec >= 0)
+# endif
+	{
+	  result = __socket (last_family, last_type | SOCK_CLOEXEC, 0);
+# ifndef __ASSUME_SOCK_CLOEXEC
+	  if (__have_sock_cloexec == 0)
+	    __have_sock_cloexec = result != -1 || errno != EINVAL ? 1 : -1;
+# endif
+	}
+#endif
+#ifndef __ASSUME_SOCK_CLOEXEC
+# ifdef SOCK_CLOEXEC
+      if (__have_sock_cloexec < 0)
+# endif
+	result = __socket (last_family, last_type, 0);
+#endif
       if (result != -1 || errno != EAFNOSUPPORT)
 	/* Maybe the socket type isn't supported anymore (module is
 	   unloaded).  In this case again try to find the type.  */
@@ -105,7 +123,24 @@
       if (afs[cnt].family == AF_NETROM || afs[cnt].family == AF_X25)
 	type = SOCK_SEQPACKET;
 
-      result = __socket (afs[cnt].family, type, 0);
+#ifdef SOCK_CLOEXEC
+# ifndef __ASSUME_SOCK_CLOEXEC
+      if (__have_sock_cloexec >= 0)
+# endif
+	{
+	  result = __socket (afs[cnt].family, type | SOCK_CLOEXEC, 0);
+# ifndef __ASSUME_SOCK_CLOEXEC
+	  if (__have_sock_cloexec == 0)
+	    __have_sock_cloexec = result != -1 || errno != EINVAL ? 1 : -1;
+# endif
+	}
+#endif
+#ifndef __ASSUME_SOCK_CLOEXEC
+# ifdef SOCK_CLOEXEC
+      if (__have_sock_cloexec < 0)
+# endif
+	result = __socket (afs[cnt].family, type, 0);
+#endif
       if (result != -1)
 	{
 	  /* Found an available family.  */