This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.22-423-g4e16650


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  4e1665024a48da9c865e991aff03a5ad03c771aa (commit)
       via  6782806d8f6664d87d17bb30f8ce4e0c7c931e17 (commit)
       via  db8ad8fac3ebdb6c68964f4d24185c2bd2c83342 (commit)
       via  52fb79d6cdecb89a6f0375091e7c12ed79ae6760 (commit)
       via  f546f87c4ffb1642ffc96b8d614c329ed35252c3 (commit)
      from  213938ee8ad50156063c3b38c3d236c6f713eb4a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=4e1665024a48da9c865e991aff03a5ad03c771aa

commit 4e1665024a48da9c865e991aff03a5ad03c771aa
Author: Florian Weimer <fweimer@redhat.com>
Date:   Sat Oct 17 12:07:04 2015 +0200

    sunrpc: Rewrite with explicit TLS access using __thread

diff --git a/ChangeLog b/ChangeLog
index eeee6d6..222ae42 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2015-10-17  Florian Weimer  <fweimer@redhat.com>
 
+	sunrpc: Rewrite with explicit TLS access using __thread.
+	* sunrpc/rpc_thread.c (thread_rpc_vars): New TLS variable.
+	(__rpc_thread_destroy, rpc_thread_multi): Access thread_rpc_vars
+	directly.
+	(__rpc_thread_variables): Access thread_rpc_vars directly.
+	Eliminate redundant assignment of the tvp variable.
+
+2015-10-17  Florian Weimer  <fweimer@redhat.com>
+
 	malloc: Rewrite with explicit TLS access using __thread.
 	* sysdeps/generic/malloc-machine.h (tsd_key_t, tsd_key_create)
 	(tsd_setspecific, tsd_getspecific): Remove.
diff --git a/sunrpc/rpc_thread.c b/sunrpc/rpc_thread.c
index 2b93db4..e5225c5 100644
--- a/sunrpc/rpc_thread.c
+++ b/sunrpc/rpc_thread.c
@@ -10,7 +10,8 @@
 
 /* Variable used in non-threaded applications or for the first thread.  */
 static struct rpc_thread_variables __libc_tsd_RPC_VARS_mem;
-__libc_tsd_define (, struct rpc_thread_variables *, RPC_VARS)
+static __thread struct rpc_thread_variables *thread_rpc_vars
+        attribute_tls_model_ie;
 
 /*
  * Task-variable destructor
@@ -18,8 +19,7 @@ __libc_tsd_define (, struct rpc_thread_variables *, RPC_VARS)
 void __attribute__ ((section ("__libc_thread_freeres_fn")))
 __rpc_thread_destroy (void)
 {
-	struct rpc_thread_variables *tvp
-	  = __libc_tsd_get (struct rpc_thread_variables *, RPC_VARS);
+	struct rpc_thread_variables *tvp = thread_rpc_vars;
 
 	if (tvp != NULL) {
 		__rpc_thread_svc_cleanup ();
@@ -34,7 +34,7 @@ __rpc_thread_destroy (void)
 		free (tvp->svc_pollfd_s);
 		if (tvp != &__libc_tsd_RPC_VARS_mem)
 			free (tvp);
-		__libc_tsd_set (struct rpc_thread_variables *, RPC_VARS, NULL);
+		thread_rpc_vars = NULL;
 	}
 }
 #ifdef _LIBC_REENTRANT
@@ -49,8 +49,7 @@ text_set_element (__libc_subfreeres, __rpc_thread_destroy);
 static void
 rpc_thread_multi (void)
 {
-  __libc_tsd_set (struct rpc_thread_variables *, RPC_VARS,
-		  &__libc_tsd_RPC_VARS_mem);
+  thread_rpc_vars = &__libc_tsd_RPC_VARS_mem;
 }
 
 
@@ -58,20 +57,15 @@ struct rpc_thread_variables *
 __rpc_thread_variables (void)
 {
 	__libc_once_define (static, once);
-	struct rpc_thread_variables *tvp;
+	struct rpc_thread_variables *tvp = thread_rpc_vars;
 
-	tvp = __libc_tsd_get (struct rpc_thread_variables *, RPC_VARS);
 	if (tvp == NULL) {
 		__libc_once (once, rpc_thread_multi);
-		tvp = __libc_tsd_get (struct rpc_thread_variables *, RPC_VARS);
+		tvp = thread_rpc_vars;
 		if (tvp == NULL) {
 			tvp = calloc (1, sizeof *tvp);
 			if (tvp != NULL)
-				__libc_tsd_set (struct rpc_thread_variables *,
-						RPC_VARS, tvp);
-			else
-				tvp = __libc_tsd_get (struct rpc_thread_variables *,
-						      RPC_VARS);
+				thread_rpc_vars = tvp;
 		}
 	}
 	return tvp;

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=6782806d8f6664d87d17bb30f8ce4e0c7c931e17

commit 6782806d8f6664d87d17bb30f8ce4e0c7c931e17
Author: Florian Weimer <fweimer@redhat.com>
Date:   Sat Oct 17 12:06:48 2015 +0200

    malloc: Rewrite with explicit TLS access using __thread

diff --git a/ChangeLog b/ChangeLog
index 123f34c..eeee6d6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,27 @@
 2015-10-17  Florian Weimer  <fweimer@redhat.com>
 
+	malloc: Rewrite with explicit TLS access using __thread.
+	* sysdeps/generic/malloc-machine.h (tsd_key_t, tsd_key_create)
+	(tsd_setspecific, tsd_getspecific): Remove.
+	* sysdeps/mach/hurd/malloc-machine.h (tsd_key_t, tsd_key_create)
+	(tsd_setspecific, tsd_getspecific): Likewise.
+	* sysdeps/nptl/malloc-machine.h (tsd_key_t, tsd_key_create)
+	(tsd_setspecific, tsd_getspecific): Likewise.
+	* malloc/arena.c (thread_arena): New TLS variable.
+	(arena_key): Remove variable.
+	(arena_get): Use thread_arena.
+	(arena_lookup): Remove macro.
+	(malloc_atfork, free_atfork, ptmalloc_lock_all)
+	(ptmalloc_unlock_all, ptmalloc_unlock_all2, ptmalloc_init)
+	(_int_new_arena, get_free_list, reused_arena)
+	(arena_thread_freeres): Use thread_arena.
+	* manual/memory.texi (Basic Allocation): Remove arena_lookup,
+	tsd_getspecific, tsd_setspecific from safety annotations.
+	(Allocating Cleared Space): Remove arena_lookup from safety
+	annotations.
+
+2015-10-17  Florian Weimer  <fweimer@redhat.com>
+
 	* stdio-common/vfprintf.c (printf_positional): Rewrite to use
 	struct scratch_buffer instead of extend_alloca.
 
diff --git a/malloc/arena.c b/malloc/arena.c
index cb45a04..caf718d 100644
--- a/malloc/arena.c
+++ b/malloc/arena.c
@@ -64,9 +64,12 @@ extern int sanity_check_heap_info_alignment[(sizeof (heap_info)
                                              + 2 * SIZE_SZ) % MALLOC_ALIGNMENT
                                             ? -1 : 1];
 
-/* Thread specific data */
+/* Thread specific data.  */
+
+static __thread mstate thread_arena attribute_tls_model_ie;
+
+/* Arena free list.  */
 
-static tsd_key_t arena_key;
 static mutex_t list_lock = MUTEX_INITIALIZER;
 static size_t narenas = 1;
 static mstate free_list;
@@ -89,15 +92,10 @@ int __malloc_initialized = -1;
    in the new arena. */
 
 #define arena_get(ptr, size) do { \
-      arena_lookup (ptr);						      \
+      ptr = thread_arena;						      \
       arena_lock (ptr, size);						      \
   } while (0)
 
-#define arena_lookup(ptr) do { \
-      void *vptr = NULL;						      \
-      ptr = (mstate) tsd_getspecific (arena_key, vptr);			      \
-  } while (0)
-
 #define arena_lock(ptr, size) do {					      \
       if (ptr && !arena_is_corrupt (ptr))				      \
         (void) mutex_lock (&ptr->mutex);				      \
@@ -138,11 +136,9 @@ ATFORK_MEM;
 static void *
 malloc_atfork (size_t sz, const void *caller)
 {
-  void *vptr = NULL;
   void *victim;
 
-  tsd_getspecific (arena_key, vptr);
-  if (vptr == ATFORK_ARENA_PTR)
+  if (thread_arena == ATFORK_ARENA_PTR)
     {
       /* We are the only thread that may allocate at all.  */
       if (save_malloc_hook != malloc_check)
@@ -172,7 +168,6 @@ malloc_atfork (size_t sz, const void *caller)
 static void
 free_atfork (void *mem, const void *caller)
 {
-  void *vptr = NULL;
   mstate ar_ptr;
   mchunkptr p;                          /* chunk corresponding to mem */
 
@@ -188,8 +183,7 @@ free_atfork (void *mem, const void *caller)
     }
 
   ar_ptr = arena_for_chunk (p);
-  tsd_getspecific (arena_key, vptr);
-  _int_free (ar_ptr, p, vptr == ATFORK_ARENA_PTR);
+  _int_free (ar_ptr, p, thread_arena == ATFORK_ARENA_PTR);
 }
 
 
@@ -212,9 +206,7 @@ ptmalloc_lock_all (void)
 
   if (mutex_trylock (&list_lock))
     {
-      void *my_arena;
-      tsd_getspecific (arena_key, my_arena);
-      if (my_arena == ATFORK_ARENA_PTR)
+      if (thread_arena == ATFORK_ARENA_PTR)
         /* This is the same thread which already locks the global list.
            Just bump the counter.  */
         goto out;
@@ -234,8 +226,8 @@ ptmalloc_lock_all (void)
   __malloc_hook = malloc_atfork;
   __free_hook = free_atfork;
   /* Only the current thread may perform malloc/free calls now. */
-  tsd_getspecific (arena_key, save_arena);
-  tsd_setspecific (arena_key, ATFORK_ARENA_PTR);
+  save_arena = thread_arena;
+  thread_arena = ATFORK_ARENA_PTR;
 out:
   ++atfork_recursive_cntr;
 }
@@ -251,7 +243,7 @@ ptmalloc_unlock_all (void)
   if (--atfork_recursive_cntr != 0)
     return;
 
-  tsd_setspecific (arena_key, save_arena);
+  thread_arena = save_arena;
   __malloc_hook = save_malloc_hook;
   __free_hook = save_free_hook;
   for (ar_ptr = &main_arena;; )
@@ -279,7 +271,7 @@ ptmalloc_unlock_all2 (void)
   if (__malloc_initialized < 1)
     return;
 
-  tsd_setspecific (arena_key, save_arena);
+  thread_arena = save_arena;
   __malloc_hook = save_malloc_hook;
   __free_hook = save_free_hook;
   free_list = NULL;
@@ -372,8 +364,7 @@ ptmalloc_init (void)
     __morecore = __failing_morecore;
 #endif
 
-  tsd_key_create (&arena_key, NULL);
-  tsd_setspecific (arena_key, (void *) &main_arena);
+  thread_arena = &main_arena;
   thread_atfork (ptmalloc_lock_all, ptmalloc_unlock_all, ptmalloc_unlock_all2);
   const char *s = NULL;
   if (__glibc_likely (_environ != NULL))
@@ -761,7 +752,7 @@ _int_new_arena (size_t size)
   set_head (top (a), (((char *) h + h->size) - ptr) | PREV_INUSE);
 
   LIBC_PROBE (memory_arena_new, 2, a, size);
-  tsd_setspecific (arena_key, (void *) a);
+  thread_arena = a;
   mutex_init (&a->mutex);
   (void) mutex_lock (&a->mutex);
 
@@ -794,7 +785,7 @@ get_free_list (void)
         {
           LIBC_PROBE (memory_arena_reuse_free_list, 1, result);
           (void) mutex_lock (&result->mutex);
-          tsd_setspecific (arena_key, (void *) result);
+	  thread_arena = result;
         }
     }
 
@@ -847,7 +838,7 @@ reused_arena (mstate avoid_arena)
 
 out:
   LIBC_PROBE (memory_arena_reuse, 2, result, avoid_arena);
-  tsd_setspecific (arena_key, (void *) result);
+  thread_arena = result;
   next_to_use = result->next;
 
   return result;
@@ -934,9 +925,8 @@ arena_get_retry (mstate ar_ptr, size_t bytes)
 static void __attribute__ ((section ("__libc_thread_freeres_fn")))
 arena_thread_freeres (void)
 {
-  void *vptr = NULL;
-  mstate a = tsd_getspecific (arena_key, vptr);
-  tsd_setspecific (arena_key, NULL);
+  mstate a = thread_arena;
+  thread_arena = NULL;
 
   if (a != NULL)
     {
diff --git a/manual/memory.texi b/manual/memory.texi
index 0729e70..cea2cd7 100644
--- a/manual/memory.texi
+++ b/manual/memory.texi
@@ -332,8 +332,6 @@ this function is in @file{stdlib.h}.
 @c __libc_malloc @asulock @aculock @acsfd @acsmem
 @c  force_reg ok
 @c  *malloc_hook unguarded
-@c  arena_lookup ok
-@c   tsd_getspecific ok, TLS
 @c  arena_lock @asulock @aculock @acsfd @acsmem
 @c   mutex_lock @asulock @aculock
 @c   arena_get2 @asulock @aculock @acsfd @acsmem
@@ -341,7 +339,6 @@ this function is in @file{stdlib.h}.
 @c     mutex_lock (list_lock) dup @asulock @aculock
 @c     mutex_unlock (list_lock) dup @aculock
 @c     mutex_lock (arena lock) dup @asulock @aculock [returns locked]
-@c     tsd_setspecific ok, TLS
 @c    __get_nprocs ext ok @acsfd
 @c    NARENAS_FROM_NCORES ok
 @c    catomic_compare_and_exchange_bool_acq ok
@@ -835,7 +832,6 @@ is declared in @file{stdlib.h}.
 @c  *__malloc_hook dup unguarded
 @c  memset dup ok
 @c  arena_get @asulock @aculock @acsfd @acsmem
-@c   arena_lookup dup ok
 @c   arena_lock dup @asulock @aculock @acsfd @acsmem
 @c  top dup ok
 @c  chunksize dup ok
diff --git a/sysdeps/generic/malloc-machine.h b/sysdeps/generic/malloc-machine.h
index 10f6e72..802d1f5 100644
--- a/sysdeps/generic/malloc-machine.h
+++ b/sysdeps/generic/malloc-machine.h
@@ -40,13 +40,6 @@ typedef int mutex_t;
 # define mutex_unlock(m)        (*(m) = 0)
 # define MUTEX_INITIALIZER      (0)
 
-typedef void *tsd_key_t;
-# define tsd_key_create(key, destr) do {} while(0)
-# define tsd_setspecific(key, data) ((key) = (data))
-# define tsd_getspecific(key, vptr) (vptr = (key))
-
-# define thread_atfork(prepare, parent, child) do {} while(0)
-
 #endif /* !defined mutex_init */
 
 #ifndef atomic_full_barrier
diff --git a/sysdeps/mach/hurd/malloc-machine.h b/sysdeps/mach/hurd/malloc-machine.h
index 1fdbd3d..9221d1b 100644
--- a/sysdeps/mach/hurd/malloc-machine.h
+++ b/sysdeps/mach/hurd/malloc-machine.h
@@ -52,16 +52,6 @@
 /* No we're *not* using pthreads.  */
 #define __pthread_initialize ((void (*)(void))0)
 
-/* thread specific data for glibc */
-
-#include <libc-tsd.h>
-
-typedef int tsd_key_t[1];	/* no key data structure, libc magic does it */
-__libc_tsd_define (static, void *, MALLOC)	/* declaration/common definition */
-#define tsd_key_create(key, destr)	((void) (key))
-#define tsd_setspecific(key, data)	__libc_tsd_set (void *, MALLOC, (data))
-#define tsd_getspecific(key, vptr)	((vptr) = __libc_tsd_get (void *, MALLOC))
-
 /* madvise is a stub on Hurd, so don't bother calling it.  */
 
 #include <sys/mman.h>
diff --git a/sysdeps/nptl/malloc-machine.h b/sysdeps/nptl/malloc-machine.h
index c0ec49e..8dea606 100644
--- a/sysdeps/nptl/malloc-machine.h
+++ b/sysdeps/nptl/malloc-machine.h
@@ -58,16 +58,6 @@ extern void *__dso_handle __attribute__ ((__weak__));
   __linkin_atfork (&atfork_mem)
 #endif
 
-/* thread specific data for glibc */
-
-#include <libc-tsd.h>
-
-typedef int tsd_key_t[1];	/* no key data structure, libc magic does it */
-__libc_tsd_define (static, void *, MALLOC)	/* declaration/common definition */
-#define tsd_key_create(key, destr)	((void) (key))
-#define tsd_setspecific(key, data)	__libc_tsd_set (void *, MALLOC, (data))
-#define tsd_getspecific(key, vptr)	((vptr) = __libc_tsd_get (void *, MALLOC))
-
 #include <sysdeps/generic/malloc-machine.h>
 
 #endif /* !defined(_MALLOC_MACHINE_H) */

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=db8ad8fac3ebdb6c68964f4d24185c2bd2c83342

commit db8ad8fac3ebdb6c68964f4d24185c2bd2c83342
Author: Florian Weimer <fweimer@redhat.com>
Date:   Sat Oct 17 12:05:12 2015 +0200

    vfprintf: Rewrite printf_positional to use struct scratch_buffer

diff --git a/ChangeLog b/ChangeLog
index 0f5fbc7..123f34c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2015-10-17  Florian Weimer  <fweimer@redhat.com>
 
+	* stdio-common/vfprintf.c (printf_positional): Rewrite to use
+	struct scratch_buffer instead of extend_alloca.
+
+2015-10-17  Florian Weimer  <fweimer@redhat.com>
+
 	* sysdeps/unix/sysv/linux/kernel-features.h
 	(__ASSUME_SOCK_CLOEXEC): Remove.
 	* include/sys/socket.h (__have_sock_cloexec): Remove declaration.
diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
index 5e408d2..ae01452 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -29,6 +29,7 @@
 #include <_itoa.h>
 #include <locale/localeinfo.h>
 #include <stdio.h>
+#include <scratch_buffer.h>
 
 /* This code is shared between the standard stdio implementation found
    in GNU C library and the libio implementation originally found in
@@ -1698,18 +1699,15 @@ printf_positional (_IO_FILE *s, const CHAR_T *format, int readonly_format,
   void *args_malloced = NULL;
 
   /* For positional argument handling.  */
-  struct printf_spec *specs;
-
-  /* Track if we malloced the SPECS array and thus must free it.  */
-  bool specs_malloced = false;
+  struct scratch_buffer specsbuf;
+  scratch_buffer_init (&specsbuf);
+  struct printf_spec *specs = specsbuf.data;
+  size_t specs_limit = specsbuf.length / sizeof (specs[0]);
 
   /* Array with information about the needed arguments.  This has to
      be dynamically extensible.  */
   size_t nspecs = 0;
-  /* A more or less arbitrary start value.  */
-  size_t nspecs_size = 32 * sizeof (struct printf_spec);
 
-  specs = alloca (nspecs_size);
   /* The number of arguments the format string requests.  This will
      determine the size of the array needed to store the argument
      attributes.  */
@@ -1746,42 +1744,15 @@ printf_positional (_IO_FILE *s, const CHAR_T *format, int readonly_format,
   for (const UCHAR_T *f = lead_str_end; *f != L_('\0');
        f = specs[nspecs++].next_fmt)
     {
-      if (nspecs * sizeof (*specs) >= nspecs_size)
+      if (nspecs == specs_limit)
 	{
-	  /* Extend the array of format specifiers.  */
-	  if (nspecs_size * 2 < nspecs_size)
+	  if (!scratch_buffer_grow_preserve (&specsbuf))
 	    {
-	      __set_errno (ENOMEM);
 	      done = -1;
 	      goto all_done;
 	    }
-	  struct printf_spec *old = specs;
-	  if (__libc_use_alloca (2 * nspecs_size))
-	    specs = extend_alloca (specs, nspecs_size, 2 * nspecs_size);
-	  else
-	    {
-	      nspecs_size *= 2;
-	      specs = malloc (nspecs_size);
-	      if (specs == NULL)
-		{
-		  __set_errno (ENOMEM);
-		  specs = old;
-		  done = -1;
-		  goto all_done;
-		}
-	    }
-
-	  /* Copy the old array's elements to the new space.  */
-	  memmove (specs, old, nspecs * sizeof (*specs));
-
-	  /* If we had previously malloc'd space for SPECS, then
-	     release it after the copy is complete.  */
-	  if (specs_malloced)
-	    free (old);
-
-	  /* Now set SPECS_MALLOCED if needed.  */
-	  if (!__libc_use_alloca (nspecs_size))
-	    specs_malloced = true;
+	  specs = specsbuf.data;
+	  specs_limit = specsbuf.length / sizeof (specs[0]);
 	}
 
       /* Parse the format specifier.  */
@@ -2091,12 +2062,11 @@ printf_positional (_IO_FILE *s, const CHAR_T *format, int readonly_format,
 		 - specs[nspecs_done].end_of_fmt);
     }
  all_done:
-  if (__glibc_unlikely (specs_malloced))
-    free (specs);
   if (__glibc_unlikely (args_malloced != NULL))
     free (args_malloced);
   if (__glibc_unlikely (workstart != NULL))
     free (workstart);
+  scratch_buffer_free (&specsbuf);
   return done;
 }
 

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=52fb79d6cdecb89a6f0375091e7c12ed79ae6760

commit 52fb79d6cdecb89a6f0375091e7c12ed79ae6760
Author: Florian Weimer <fweimer@redhat.com>
Date:   Sat Oct 17 12:02:37 2015 +0200

    Assume that SOCK_CLOEXEC is available and works
    
    This fixes (harmless) data races when accessing the various
    __have_sock_cloexec variables.

diff --git a/ChangeLog b/ChangeLog
index 7668307..0f5fbc7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,27 @@
 2015-10-17  Florian Weimer  <fweimer@redhat.com>
 
+	* sysdeps/unix/sysv/linux/kernel-features.h
+	(__ASSUME_SOCK_CLOEXEC): Remove.
+	* include/sys/socket.h (__have_sock_cloexec): Remove declaration.
+	(__have_paccept): Remove unused macro.
+	* include/unistd.h (__have_sock_cloexec): Remove declaration.
+	* misc/syslog.c (openlog_internal): Remove fallback code for
+	!__ASSUME_SOCK_CLOEXEC.
+	* nis/ypclnt.c (yp_bind_client_create): Remove fallback code for
+	missing SOCK_CLOEXEC.
+	* nscd/connections.c (have_sock_cloexec): Remove definition.
+	(nscd_init): Remove fallback code for !__ASSUME_SOCK_CLOEXEC.
+	* nscd/nscd_helper.c (open_socket): Remove fallback code for
+	!__ASSUME_SOCK_CLOEXEC.
+	* resolv/res_send.c (__have_o_nonblock): Remove definition.
+	(reopen): Remove fallback code for !__ASSUME_SOCK_CLOEXEC.
+	* socket/have_sock_cloexec.c (__have_sock_cloexec): Remove
+	definition.
+	* sunrpc/clnt_udp.c (__libc_clntudp_bufcreate): Remove fallback
+	code for !__ASSUME_SOCK_CLOEXEC.
+
+2015-10-17  Florian Weimer  <fweimer@redhat.com>
+
 	[BZ #18982]
 	* manual/stdio.texi (Variable Arguments Output): Add portability
 	note, explaining that vfprintf clobbers the va_list pointer.
diff --git a/include/sys/socket.h b/include/sys/socket.h
index 2f4bfd3..a00ab3c 100644
--- a/include/sys/socket.h
+++ b/include/sys/socket.h
@@ -154,13 +154,5 @@ libc_hidden_proto (__libc_sa_len)
 # define SA_LEN(_x)      __libc_sa_len((_x)->sa_family)
 #endif
 
-#ifdef SOCK_CLOEXEC
-extern int __have_sock_cloexec attribute_hidden;
-/* 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
 #endif
diff --git a/include/unistd.h b/include/unistd.h
index fbba393..cb41637 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -170,7 +170,6 @@ extern int __libc_pause (void);
 /* Not cancelable variant.  */
 extern int __pause_nocancel (void) attribute_hidden;
 
-extern int __have_sock_cloexec attribute_hidden;
 extern int __have_pipe2 attribute_hidden;
 extern int __have_dup3 attribute_hidden;
 
diff --git a/misc/syslog.c b/misc/syslog.c
index e387bf8..6922ad6 100644
--- a/misc/syslog.c
+++ b/misc/syslog.c
@@ -346,36 +346,9 @@ openlog_internal(const char *ident, int logstat, int logfac)
 			(void)strncpy(SyslogAddr.sun_path, _PATH_LOG,
 				      sizeof(SyslogAddr.sun_path));
 			if (LogStat & LOG_NDELAY) {
-#ifdef SOCK_CLOEXEC
-# ifndef __ASSUME_SOCK_CLOEXEC
-				if (__have_sock_cloexec >= 0) {
-# endif
-					LogFile = __socket(AF_UNIX,
-							   LogType
-							   | SOCK_CLOEXEC, 0);
-# ifndef __ASSUME_SOCK_CLOEXEC
-					if (__have_sock_cloexec == 0)
-						__have_sock_cloexec
-						  = ((LogFile != -1
-						      || errno != EINVAL)
-						     ? 1 : -1);
-				}
-# endif
-#endif
-#ifndef __ASSUME_SOCK_CLOEXEC
-# ifdef SOCK_CLOEXEC
-				if (__have_sock_cloexec < 0)
-# endif
-				  LogFile = __socket(AF_UNIX, LogType, 0);
-#endif
-				if (LogFile == -1)
-					return;
-#ifndef __ASSUME_SOCK_CLOEXEC
-# ifdef SOCK_CLOEXEC
-				if (__have_sock_cloexec < 0)
-# endif
-					__fcntl(LogFile, F_SETFD, FD_CLOEXEC);
-#endif
+			  LogFile = __socket(AF_UNIX, LogType | SOCK_CLOEXEC, 0);
+			  if (LogFile == -1)
+			    return;
 			}
 		}
 		if (LogFile != -1 && !connected)
diff --git a/nis/ypclnt.c b/nis/ypclnt.c
index 3a73872..93a95d6 100644
--- a/nis/ypclnt.c
+++ b/nis/ypclnt.c
@@ -68,25 +68,11 @@ yp_bind_client_create (const char *domain, dom_binding *ysd,
   ysd->dom_domain[YPMAXDOMAIN] = '\0';
 
   ysd->dom_socket = RPC_ANYSOCK;
-#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
-    }
+					      SOCK_CLOEXEC);
 }
 
 #if USE_BINDINGDIR
diff --git a/nscd/connections.c b/nscd/connections.c
index cba5e6a..e16406b 100644
--- a/nscd/connections.c
+++ b/nscd/connections.c
@@ -257,11 +257,6 @@ int inotify_fd = -1;
 static int nl_status_fd = -1;
 #endif
 
-#ifndef __ASSUME_SOCK_CLOEXEC
-/* Negative if SOCK_CLOEXEC is not supported, positive if it is, zero
-   before be know the result.  */
-static int have_sock_cloexec;
-#endif
 #ifndef __ASSUME_ACCEPT4
 static int have_accept4;
 #endif
@@ -830,21 +825,7 @@ cannot set socket to close on exec: %s; disabling paranoia mode"),
       }
 
   /* Create the socket.  */
-#ifndef __ASSUME_SOCK_CLOEXEC
-  sock = -1;
-  if (have_sock_cloexec >= 0)
-#endif
-    {
-      sock = socket (AF_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
-    }
-#ifndef __ASSUME_SOCK_CLOEXEC
-  if (have_sock_cloexec < 0)
-    sock = socket (AF_UNIX, SOCK_STREAM, 0);
-#endif
+  sock = socket (AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);
   if (sock < 0)
     {
       dbg_log (_("cannot open socket: %s"), strerror (errno));
@@ -860,28 +841,6 @@ cannot set socket to close on exec: %s; disabling paranoia mode"),
       do_exit (errno == EACCES ? 4 : 1, 0, NULL);
     }
 
-#ifndef __ASSUME_SOCK_CLOEXEC
-  if (have_sock_cloexec < 0)
-    {
-      /* We don't want to get stuck on accept.  */
-      int fl = fcntl (sock, F_GETFL);
-      if (fl == -1 || fcntl (sock, F_SETFL, fl | O_NONBLOCK) == -1)
-	{
-	  dbg_log (_("cannot change socket to nonblocking mode: %s"),
-		   strerror (errno));
-	  do_exit (1, 0, NULL);
-	}
-
-      /* The descriptor needs to be closed on exec.  */
-      if (paranoia && fcntl (sock, F_SETFD, FD_CLOEXEC) == -1)
-	{
-	  dbg_log (_("cannot set socket to close on exec: %s"),
-		   strerror (errno));
-	  do_exit (1, 0, NULL);
-	}
-    }
-#endif
-
   /* Set permissions for the socket.  */
   chmod (_PATH_NSCDSOCKET, DEFFILEMODE);
 
@@ -922,31 +881,6 @@ cannot set socket to close on exec: %s; disabling paranoia mode"),
 	      /* Start the timestamp process.  */
 	      dbs[hstdb].head->extra_data[NSCD_HST_IDX_CONF_TIMESTAMP]
 		= __bump_nl_timestamp ();
-
-# ifndef __ASSUME_SOCK_CLOEXEC
-	      if (have_sock_cloexec < 0)
-		{
-		  /* We don't want to get stuck on accept.  */
-		  int fl = fcntl (nl_status_fd, F_GETFL);
-		  if (fl == -1
-		      || fcntl (nl_status_fd, F_SETFL, fl | O_NONBLOCK) == -1)
-		    {
-		      dbg_log (_("\
-cannot change socket to nonblocking mode: %s"),
-			       strerror (errno));
-		      do_exit (1, 0, NULL);
-		    }
-
-		  /* The descriptor needs to be closed on exec.  */
-		  if (paranoia
-		      && fcntl (nl_status_fd, F_SETFD, FD_CLOEXEC) == -1)
-		    {
-		      dbg_log (_("cannot set socket to close on exec: %s"),
-			       strerror (errno));
-		      do_exit (1, 0, NULL);
-		    }
-		}
-# endif
 	    }
 	}
     }
diff --git a/nscd/nscd_helper.c b/nscd/nscd_helper.c
index 52a5caa..341b931 100644
--- a/nscd/nscd_helper.c
+++ b/nscd/nscd_helper.c
@@ -166,24 +166,7 @@ open_socket (request_type type, const char *key, size_t keylen)
 {
   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
+  sock = __socket (PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);
   if (sock < 0)
     return -1;
 
@@ -194,14 +177,6 @@ open_socket (request_type type, const char *key, size_t keylen)
     char key[];
   } *reqdata = alloca (real_sizeof_reqdata);
 
-#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;
   strcpy (sun.sun_path, _PATH_NSCDSOCKET);
diff --git a/resolv/res_send.c b/resolv/res_send.c
index 5e53cc2..6137e4d 100644
--- a/resolv/res_send.c
+++ b/resolv/res_send.c
@@ -104,14 +104,6 @@ static const char rcsid[] = "$BINDId: res_send.c,v 8.38 2000/03/30 20:16:51 vixi
 #define MAXPACKET       65536
 #endif
 
-
-#ifndef __ASSUME_SOCK_CLOEXEC
-static int __have_o_nonblock;
-#else
-# define __have_o_nonblock 0
-#endif
-
-
 /* From ev_streams.c.  */
 
 static inline void
@@ -927,38 +919,14 @@ reopen (res_state statp, int *terrno, int ns)
 
 		/* only try IPv6 if IPv6 NS and if not failed before */
 		if (nsap->sa_family == AF_INET6 && !statp->ipv6_unavail) {
-			if (__glibc_likely (__have_o_nonblock >= 0))       {
-				EXT(statp).nssocks[ns] =
-				  socket(PF_INET6, SOCK_DGRAM|SOCK_NONBLOCK,
-					 0);
-#ifndef __ASSUME_SOCK_CLOEXEC
-				if (__have_o_nonblock == 0)
-					__have_o_nonblock
-					  = (EXT(statp).nssocks[ns] == -1
-					     && errno == EINVAL ? -1 : 1);
-#endif
-			}
-			if (__glibc_unlikely (__have_o_nonblock < 0))
-				EXT(statp).nssocks[ns] =
-				  socket(PF_INET6, SOCK_DGRAM, 0);
+			EXT(statp).nssocks[ns]
+				= socket(PF_INET6, SOCK_DGRAM|SOCK_NONBLOCK, 0);
 			if (EXT(statp).nssocks[ns] < 0)
 			    statp->ipv6_unavail = errno == EAFNOSUPPORT;
 			slen = sizeof (struct sockaddr_in6);
 		} else if (nsap->sa_family == AF_INET) {
-			if (__glibc_likely (__have_o_nonblock >= 0))       {
-				EXT(statp).nssocks[ns]
-				  = socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK,
-					   0);
-#ifndef __ASSUME_SOCK_CLOEXEC
-				if (__have_o_nonblock == 0)
-					__have_o_nonblock
-					  = (EXT(statp).nssocks[ns] == -1
-					     && errno == EINVAL ? -1 : 1);
-#endif
-			}
-			if (__glibc_unlikely (__have_o_nonblock < 0))
-				EXT(statp).nssocks[ns]
-				  = socket(PF_INET, SOCK_DGRAM, 0);
+			EXT(statp).nssocks[ns]
+				= socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK, 0);
 			slen = sizeof (struct sockaddr_in);
 		}
 		if (EXT(statp).nssocks[ns] < 0) {
@@ -983,15 +951,6 @@ reopen (res_state statp, int *terrno, int ns)
 			__res_iclose(statp, false);
 			return (0);
 		}
-		if (__glibc_unlikely (__have_o_nonblock < 0))       {
-			/* Make socket non-blocking.  */
-			int fl = __fcntl (EXT(statp).nssocks[ns], F_GETFL);
-			if  (fl != -1)
-				__fcntl (EXT(statp).nssocks[ns], F_SETFL,
-					 fl | O_NONBLOCK);
-			Dprint(statp->options & RES_DEBUG,
-			       (stdout, ";; new DG socket\n"))
-		}
 	}
 
 	return 1;
diff --git a/socket/have_sock_cloexec.c b/socket/have_sock_cloexec.c
index c849f92..72b184c 100644
--- a/socket/have_sock_cloexec.c
+++ b/socket/have_sock_cloexec.c
@@ -19,10 +19,6 @@
 #include <sys/socket.h>
 #include <kernel-features.h>
 
-#if defined SOCK_CLOEXEC && !defined __ASSUME_SOCK_CLOEXEC
-int __have_sock_cloexec;
-#endif
-
 #if defined O_CLOEXEC && !defined __ASSUME_PIPE2
 int __have_pipe2;
 #endif
diff --git a/sunrpc/clnt_udp.c b/sunrpc/clnt_udp.c
index 6ffa5f2..cc1da47 100644
--- a/sunrpc/clnt_udp.c
+++ b/sunrpc/clnt_udp.c
@@ -171,31 +171,7 @@ __libc_clntudp_bufcreate (struct sockaddr_in *raddr, u_long program,
   cu->cu_xdrpos = XDR_GETPOS (&(cu->cu_outxdrs));
   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
+      *sockp = __socket (AF_INET, SOCK_DGRAM|SOCK_NONBLOCK|flags, IPPROTO_UDP);
       if (__glibc_unlikely (*sockp < 0))
 	{
 	  struct rpc_createerr *ce = &get_rpc_createerr ();
@@ -205,16 +181,6 @@ __libc_clntudp_bufcreate (struct sockaddr_in *raddr, u_long program,
 	}
       /* attempt to bind to prov port */
       (void) bindresvport (*sockp, (struct sockaddr_in *) 0);
-#ifndef __ASSUME_SOCK_CLOEXEC
-# ifdef SOCK_CLOEXEC
-      if (__have_sock_cloexec < 0)
-# endif
-	{
-	  /* the sockets rpc controls are non-blocking */
-	  int dontblock = 1;
-	  (void) __ioctl (*sockp, FIONBIO, (char *) &dontblock);
-	}
-#endif
 #ifdef IP_RECVERR
       {
 	int on = 1;
diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h
index ce127d6..feb63bb 100644
--- a/sysdeps/unix/sysv/linux/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/kernel-features.h
@@ -86,7 +86,6 @@
 
 /* Support for various CLOEXEC and NONBLOCK flags was added in
    2.6.27.  */
-#define __ASSUME_SOCK_CLOEXEC	1
 #define __ASSUME_IN_NONBLOCK	1
 #define __ASSUME_PIPE2		1
 #define __ASSUME_EVENTFD2	1

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=f546f87c4ffb1642ffc96b8d614c329ed35252c3

commit f546f87c4ffb1642ffc96b8d614c329ed35252c3
Author: Florian Weimer <fweimer@redhat.com>
Date:   Sat Oct 17 12:02:22 2015 +0200

    The va_list pointer is unspecified after a call to vfprintf [BZ #18982]
    
    This adjusts the documentation to the existing implementation.

diff --git a/ChangeLog b/ChangeLog
index d720fcb..7668307 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-10-17  Florian Weimer  <fweimer@redhat.com>
+
+	[BZ #18982]
+	* manual/stdio.texi (Variable Arguments Output): Add portability
+	note, explaining that vfprintf clobbers the va_list pointer.
+
 2015-10-16  Joseph Myers  <joseph@codesourcery.com>
 
 	* math/libm-test.inc (fabs_test_data): Add more tests.
diff --git a/NEWS b/NEWS
index 6fd9a6e..d7404f4 100644
--- a/NEWS
+++ b/NEWS
@@ -18,9 +18,9 @@ Version 2.23
   18790, 18795, 18796, 18803, 18820, 18823, 18824, 18825, 18857, 18863,
   18870, 18872, 18873, 18875, 18887, 18918, 18921, 18928, 18951, 18952,
   18953, 18956, 18961, 18966, 18967, 18969, 18970, 18977, 18980, 18981,
-  18985, 19003, 19007, 19012, 19016, 19018, 19032, 19046, 19049, 19050,
-  19059, 19071, 19074, 19076, 19077, 19078, 19079, 19085, 19086, 19088,
-  19094, 19095, 19124, 19125, 19129, 19134, 19137.
+  18982, 18985, 19003, 19007, 19012, 19016, 19018, 19032, 19046, 19049,
+  19050, 19059, 19071, 19074, 19076, 19077, 19078, 19079, 19085, 19086,
+  19088, 19094, 19095, 19124, 19125, 19129, 19134, 19137.
 
 * The LD_POINTER_GUARD environment variable can no longer be used to
   disable the pointer guard feature.  It is always enabled.
diff --git a/manual/stdio.texi b/manual/stdio.texi
index 5d31774..c0753b1 100644
--- a/manual/stdio.texi
+++ b/manual/stdio.texi
@@ -2621,20 +2621,16 @@ choice, you are ready to call @code{vprintf}.  That argument and all
 subsequent arguments that were passed to your function are used by
 @code{vprintf} along with the template that you specified separately.
 
-In some other systems, the @code{va_list} pointer may become invalid
-after the call to @code{vprintf}, so you must not use @code{va_arg}
-after you call @code{vprintf}.  Instead, you should call @code{va_end}
-to retire the pointer from service.  However, you can safely call
-@code{va_start} on another pointer variable and begin fetching the
-arguments again through that pointer.  Calling @code{vprintf} does not
-destroy the argument list of your function, merely the particular
-pointer that you passed to it.
-
-GNU C does not have such restrictions.  You can safely continue to fetch
-arguments from a @code{va_list} pointer after passing it to
-@code{vprintf}, and @code{va_end} is a no-op.  (Note, however, that
-subsequent @code{va_arg} calls will fetch the same arguments which
-@code{vprintf} previously used.)
+@strong{Portability Note:} The value of the @code{va_list} pointer is
+undetermined after the call to @code{vprintf}, so you must not use
+@code{va_arg} after you call @code{vprintf}.  Instead, you should call
+@code{va_end} to retire the pointer from service.  You can call
+@code{va_start} again and begin fetching the arguments from the start of
+the variable argument list.  (Alternatively, you can use @code{va_copy}
+to make a copy of the @code{va_list} pointer before calling
+@code{vfprintf}.)  Calling @code{vprintf} does not destroy the argument
+list of your function, merely the particular pointer that you passed to
+it.
 
 Prototypes for these functions are declared in @file{stdio.h}.
 @pindex stdio.h

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                 |   64 +++++++++++++++++++++++++++
 NEWS                                      |    6 +-
 include/sys/socket.h                      |    8 ---
 include/unistd.h                          |    1 -
 malloc/arena.c                            |   48 ++++++++------------
 manual/memory.texi                        |    4 --
 manual/stdio.texi                         |   24 ++++------
 misc/syslog.c                             |   33 +-------------
 nis/ypclnt.c                              |   16 +------
 nscd/connections.c                        |   68 +----------------------------
 nscd/nscd_helper.c                        |   27 +-----------
 resolv/res_send.c                         |   49 ++-------------------
 socket/have_sock_cloexec.c                |    4 --
 stdio-common/vfprintf.c                   |   50 ++++-----------------
 sunrpc/clnt_udp.c                         |   36 +---------------
 sunrpc/rpc_thread.c                       |   22 +++------
 sysdeps/generic/malloc-machine.h          |    7 ---
 sysdeps/mach/hurd/malloc-machine.h        |   10 ----
 sysdeps/nptl/malloc-machine.h             |   10 ----
 sysdeps/unix/sysv/linux/kernel-features.h |    1 -
 20 files changed, 125 insertions(+), 363 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]