This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

[PATCH] Further steps towards GL(dl_dynamic_weak) == 0 everywhere


Hi!

The following patch changes a few routines in libpthread
and/or libc, so that -lc -lpthread and -lpthread -lc have
the same effects.
The following routines still need to be handled (which means
they behave differently ATM with -lc -lpthread and -lpthread -lc):
fork+__fork+vfork+__vfork	- here I think unification
				  of __{,un}register_atfork
				  (and exporting it @@GLIBC_2.3.2)
				  is needed first
longjmp+siglongjmp
raise
sigaction+__sigaction
sigwait

BTW: I'm not sure about longjmp+siglongjmp in NPTL: there is
pt-longjmp which doesn't use __pthread_cleanup_upto and
pt-siglongjmp, apparently unused file, which uses it.

The pt-system.c+tst-cancel-wrappers.sh changes are because I don't
think it makes any sense to surround libpthread.so's system with
cancellation checks when it calls __libc_system from libc.so which
handles cancellation.

2002-12-27  Jakub Jelinek  <jakub@redhat.com>

libc/
	* inet/herrno.c (__h_errno_location): Remove.
	* inet/Makefile (routines): Add herrno-loc.
	* resolv/res_libc.c (__res_state): Remove.
	* resolv/Makefile (routines): Add res-state.
	* sysdeps/generic/herrno-loc.c: New file.
	* sysdeps/generic/res-state.c: New file.
linuxthreads/
	* sysdeps/pthread/bits/libc-tsd.h: Include linuxthreads/descr.h
	and bits/libc-lock.h.
	(__libc_internal_tsd_get, __libc_internal_tsd_set,
	__libc_internal_tsd_address): Remove.
	(__pthread_internal_tsd_address, __pthread_internal_tsd_get,
	__pthread_internal_tsd_set): New weak_externs.
	(__libc_tsd_address, __libc_tsd_get, __libc_tsd_set): Define
	using __libc_maybe_call2.
	(__libc_tsd_key_t): Move to ...
	* descr.h (__libc_tsd_key_t): ...here.
	Remove bits/libc-tsd.h include.
	* sysdeps/pthread/errno-loc.c: New file.
	* sysdeps/pthread/herrno-loc.c: New file.
	* sysdeps/pthread/res-state.c: New file.
	* libc-cancellation.c (THREAD_GETMEM, THREAD_SETMEM): Remove.
	(__libc_enable_asynccancel, __libc_disable_asynccancel): Use
	thread_self unconditionally.  Use LIBC_THREAD_[SG]ETMEM instead
	of THREAD_[SG]ETMEM.
	* specific.c (libc_internal_tsd_set): Renamed to...
	__pthread_internal_tsd_set.  Remove static.
	(libc_internal_tsd_get): Renamed to...
	__pthread_internal_tsd_get.  Remove static.
	(libc_internal_tsd_address): Renamed to...
	__pthread_internal_tsd_address.  Remove static.
	(__libc_internal_tsd_set, __libc_internal_tsd_get,
	__libc_internal_tsd_address, __libc_alloca_cutoff): Remove.
	* internals.h [!NOT_IN_libc] (LIBC_THREAD_GETMEM, LIBC_THREAD_SETMEM):
	Define.
	(__pthread_internal_tsd_set, __pthread_internal_tsd_get,
	__pthread_internal_tsd_address): New prototypes.
	(struct pthread_functions): Add
	ptr_pthread_internal_tsd_([sg]et|address) fields.
	[!NOT_IN_libc && !FLOATING_STACKS] (thread_self): Define.
	* pthread.c (pthread_functions) [!USE_TLS && !HAVE___THREAD]:
	Initialize ptr_pthread_internal_tsd_([sg]et|address) fields.
	* Versions (libpthread): Remove __libc_alloca_cutoff@GLIBC_PRIVATE.
	* alloca_cutoff.c: New file.
	* no-tsd.c: Removed.
	* Makefile (routines): Remove no-tsd.  Add alloca_cutoff.
	* pt-system.c (system): Remove cancellation handling.
	* tst-cancel-wrappers.sh: Allow pt-system.o* to not use the
	cancellation routines.
nptl/
	* pt-system.c (system): Remove cancellation handling.
	* tst-cancel-wrappers.sh: Allow pt-system.o* to not use the
	cancellation routines.

--- libc/inet/herrno.c.jj	2002-11-15 04:36:50.000000000 +0100
+++ libc/inet/herrno.c	2002-12-27 16:16:36.000000000 +0100
@@ -42,11 +42,3 @@ compat_symbol (libc, h_errno, h_errno, G
 compat_symbol (libc, _h_errno, _h_errno, GLIBC_2_0);
 # endif
 #endif
-
-/* When threaded, h_errno may be a per-thread variable.  */
-int *
-weak_const_function
-__h_errno_location (void)
-{
-  return &h_errno;
-}
--- libc/inet/Makefile.jj	2002-07-25 00:56:04.000000000 +0200
+++ libc/inet/Makefile	2002-12-27 16:16:59.000000000 +0100
@@ -30,7 +30,7 @@ distribute := netgroup.h
 
 routines := htonl htons		\
 	    inet_lnaof inet_mkadr	\
-	    inet_netof inet_ntoa inet_net herrno \
+	    inet_netof inet_ntoa inet_net herrno herrno-loc \
 	    gethstbyad gethstbyad_r gethstbynm gethstbynm2 gethstbynm2_r \
 	    gethstbynm_r gethstent gethstent_r \
 	    getnetbyad getnetbyad_r getnetbynm getnetent getnetent_r \
--- libc/linuxthreads/sysdeps/pthread/bits/libc-tsd.h.jj	2002-09-02 09:08:21.000000000 +0200
+++ libc/linuxthreads/sysdeps/pthread/bits/libc-tsd.h	2002-12-27 22:57:41.000000000 +0100
@@ -20,16 +20,7 @@
 #ifndef _BITS_LIBC_TSD_H
 #define _BITS_LIBC_TSD_H 1
 
-/* Fast thread-specific data internal to libc.  */
-enum __libc_tsd_key_t { _LIBC_TSD_KEY_MALLOC = 0,
-			_LIBC_TSD_KEY_DL_ERROR,
-			_LIBC_TSD_KEY_RPC_VARS,
-			_LIBC_TSD_KEY_LOCALE,
-			_LIBC_TSD_KEY_CTYPE_B,
-			_LIBC_TSD_KEY_CTYPE_TOLOWER,
-			_LIBC_TSD_KEY_CTYPE_TOUPPER,
-			_LIBC_TSD_KEY_N };
-
+#include <linuxthreads/descr.h>
 #include <tls.h>
 
 #if USE_TLS && HAVE___THREAD
@@ -39,26 +30,25 @@ enum __libc_tsd_key_t { _LIBC_TSD_KEY_MA
 
 #else
 
-extern void *(*__libc_internal_tsd_get) (enum __libc_tsd_key_t) __THROW;
-extern int (*__libc_internal_tsd_set) (enum __libc_tsd_key_t,
-				       __const void *)  __THROW;
-extern void **(*const __libc_internal_tsd_address) (enum __libc_tsd_key_t)
-     __THROW __attribute__ ((__const__));
+# include <bits/libc-lock.h>
 
-#define __libc_tsd_address(KEY) \
-  (__libc_internal_tsd_address != NULL \
-   ? __libc_internal_tsd_address (_LIBC_TSD_KEY_##KEY) \
-   : &__libc_tsd_##KEY##_data)
+# ifndef SHARED
+weak_extern (__pthread_internal_tsd_address)
+weak_extern (__pthread_internal_tsd_get)
+weak_extern (__pthread_internal_tsd_set)
+# endif
 
 #define __libc_tsd_define(CLASS, KEY)	CLASS void *__libc_tsd_##KEY##_data;
+#define __libc_tsd_address(KEY) \
+  __libc_maybe_call2 (pthread_internal_tsd_address,			\
+		      (_LIBC_TSD_KEY_##KEY), &__libc_tsd_##KEY##_data)
 #define __libc_tsd_get(KEY) \
-  (__libc_internal_tsd_get != NULL \
-   ? __libc_internal_tsd_get (_LIBC_TSD_KEY_##KEY) \
-   : __libc_tsd_##KEY##_data)
+  __libc_maybe_call2 (pthread_internal_tsd_get,				\
+		      (_LIBC_TSD_KEY_##KEY), __libc_tsd_##KEY##_data)
 #define __libc_tsd_set(KEY, VALUE) \
-  (__libc_internal_tsd_set != NULL \
-   ? __libc_internal_tsd_set (_LIBC_TSD_KEY_##KEY, (VALUE)) \
-   : ((__libc_tsd_##KEY##_data = (VALUE)), 0))
+  __libc_maybe_call2 (pthread_internal_tsd_set,				\
+		      (_LIBC_TSD_KEY_##KEY, (VALUE)),			\
+		       (__libc_tsd_##KEY##_data = (VALUE), 0))
 
 #endif
 
--- libc/linuxthreads/sysdeps/pthread/errno-loc.c.jj	2002-12-27 14:49:03.000000000 +0100
+++ libc/linuxthreads/sysdeps/pthread/errno-loc.c	2002-12-27 22:13:34.000000000 +0100
@@ -0,0 +1,44 @@
+/* MT support function to get address of `errno' variable, linuxthreads
+   version.
+   Copyright (C) 1996, 1998, 2002 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 <errno.h>
+#include <tls.h>
+#include <sysdep-cancel.h>
+
+#if ! USE___THREAD
+#undef errno
+extern int errno;
+#endif
+
+int *
+#if ! USE___THREAD
+weak_const_function
+#endif
+__errno_location (void)
+{
+#if ! USE___THREAD && !defined NOT_IN_libc
+  if (! SINGLE_THREAD_P)
+    {
+      pthread_descr self = thread_self();
+      return LIBC_THREAD_GETMEM (self, p_errnop);
+    }
+#endif
+  return &errno;
+}
--- libc/linuxthreads/sysdeps/pthread/herrno-loc.c.jj	2002-12-27 16:17:28.000000000 +0100
+++ libc/linuxthreads/sysdeps/pthread/herrno-loc.c	2002-12-27 16:19:25.000000000 +0100
@@ -0,0 +1,41 @@
+/* Copyright (C) 1996, 97, 98, 2002 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 <netdb.h>
+#include <tls.h>
+#include <sysdep-cancel.h>
+
+#if ! USE___THREAD
+# undef h_errno
+extern int h_errno;
+#endif
+
+/* When threaded, h_errno may be a per-thread variable.  */
+int *
+weak_const_function
+__h_errno_location (void)
+{
+#if ! USE___THREAD
+  if (! SINGLE_THREAD_P)
+    {
+      pthread_descr self = thread_self();
+      return LIBC_THREAD_GETMEM (self, p_h_errnop);
+    }
+#endif
+  return &h_errno;
+}
--- libc/linuxthreads/sysdeps/pthread/res-state.c.jj	2002-12-27 16:25:14.000000000 +0100
+++ libc/linuxthreads/sysdeps/pthread/res-state.c	2002-12-27 16:26:29.000000000 +0100
@@ -0,0 +1,43 @@
+/* Copyright (C) 1996, 97, 98, 2002 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 <resolv.h>
+#include <tls.h>
+#include <sysdep-cancel.h>
+
+#if ! USE___THREAD
+# undef _res
+extern struct __res_state _res;
+#endif
+
+/* When threaded, _res may be a per-thread variable.  */
+struct __res_state *
+#if ! USE___THREAD
+weak_const_function
+#endif
+__res_state (void)
+{
+#if ! USE___THREAD
+  if (! SINGLE_THREAD_P)
+    {
+      pthread_descr self = thread_self();
+      return LIBC_THREAD_GETMEM (self, p_resp);
+    }
+#endif
+  return &_res;
+}
--- libc/linuxthreads/libc-cancellation.c.jj	2002-12-19 00:13:24.000000000 +0100
+++ libc/linuxthreads/libc-cancellation.c	2002-12-27 15:59:05.000000000 +0100
@@ -34,13 +34,6 @@ weak_extern (__pthread_thread_self)
 
 int __libc_multiple_threads attribute_hidden;
 
-# ifndef FLOATING_STACKS
-#  undef THREAD_GETMEM
-#  undef THREAD_SETMEM
-#  define THREAD_GETMEM(descr, member) descr->member
-#  define THREAD_SETMEM(descr, member, value) descr->member = (value)
-# endif
-
 /* The next two functions are similar to pthread_setcanceltype() but
    more specialized for the use in the cancelable functions like write().
    They do not need to check parameters etc.  */
@@ -48,18 +41,11 @@ int
 attribute_hidden
 __libc_enable_asynccancel (void)
 {
-#ifdef FLOATING_STACKS
   pthread_descr self = thread_self();
-#else
-  pthread_descr self = __libc_maybe_call2 (pthread_thread_self, (), NULL);
-
-  if (self == NULL)
-    return PTHREAD_CANCEL_DEFERRED;
-#endif
-  int oldtype = THREAD_GETMEM(self, p_canceltype);
-  THREAD_SETMEM(self, p_canceltype, PTHREAD_CANCEL_ASYNCHRONOUS);
-  if (__builtin_expect (THREAD_GETMEM(self, p_canceled), 0) &&
-      THREAD_GETMEM(self, p_cancelstate) == PTHREAD_CANCEL_ENABLE)
+  int oldtype = LIBC_THREAD_GETMEM(self, p_canceltype);
+  LIBC_THREAD_SETMEM(self, p_canceltype, PTHREAD_CANCEL_ASYNCHRONOUS);
+  if (__builtin_expect (LIBC_THREAD_GETMEM(self, p_canceled), 0) &&
+      LIBC_THREAD_GETMEM(self, p_cancelstate) == PTHREAD_CANCEL_ENABLE)
     __libc_maybe_call2 (pthread_do_exit,
 			(PTHREAD_CANCELED, CURRENT_STACK_FRAME), 0);
   return oldtype;
@@ -69,14 +55,8 @@ void
 internal_function attribute_hidden
 __libc_disable_asynccancel (int oldtype)
 {
-#ifdef FLOATING_STACKS
   pthread_descr self = thread_self();
-#else
-  pthread_descr self = __libc_maybe_call2 (pthread_thread_self, (), NULL);
-
-  if (self != NULL)
-#endif
-    THREAD_SETMEM(self, p_canceltype, oldtype);
+  LIBC_THREAD_SETMEM(self, p_canceltype, oldtype);
 }
 
 #endif
--- libc/linuxthreads/specific.c.jj	2002-10-09 11:12:17.000000000 +0200
+++ libc/linuxthreads/specific.c	2002-12-27 19:10:24.000000000 +0100
@@ -208,40 +208,28 @@ void __pthread_destroy_specifics()
 
 /* Thread-specific data for libc. */
 
-static int
-libc_internal_tsd_set(enum __libc_tsd_key_t key, const void * pointer)
+int
+__pthread_internal_tsd_set (int key, const void * pointer)
 {
   pthread_descr self = thread_self();
 
   THREAD_SETMEM_NC(self, p_libc_specific[key], (void *) pointer);
   return 0;
 }
-int (*__libc_internal_tsd_set)(enum __libc_tsd_key_t key, const void * pointer)
-     = libc_internal_tsd_set;
 
-static void *
-libc_internal_tsd_get(enum __libc_tsd_key_t key)
+void *
+__pthread_internal_tsd_get (int key)
 {
   pthread_descr self = thread_self();
 
   return THREAD_GETMEM_NC(self, p_libc_specific[key]);
 }
-void * (*__libc_internal_tsd_get)(enum __libc_tsd_key_t key)
-     = libc_internal_tsd_get;
 
-static void ** __attribute__ ((__const__))
-libc_internal_tsd_address (enum __libc_tsd_key_t key)
+void ** __attribute__ ((__const__))
+__pthread_internal_tsd_address (int key)
 {
   pthread_descr self = thread_self();
   return &self->p_libc_specific[key];
 }
-void **(*const __libc_internal_tsd_address) (enum __libc_tsd_key_t key)
-     __THROW __attribute__ ((__const__)) = libc_internal_tsd_address;
 
 #endif
-
-int __libc_alloca_cutoff (size_t size)
-{
-  pthread_descr self = thread_self();
-  return size <= THREAD_GETMEM_NC(self, p_alloca_cutoff);
-}
--- libc/linuxthreads/internals.h.jj	2002-12-18 02:34:17.000000000 +0100
+++ libc/linuxthreads/internals.h	2002-12-27 21:49:58.000000000 +0100
@@ -43,6 +43,17 @@
 # define THREAD_SETMEM_NC(descr, member, value) descr->member = (value)
 #endif
 
+#ifndef NOT_IN_libc
+# ifdef FLOATING_STACKS
+#  define LIBC_THREAD_GETMEM(descr, member) THREAD_GETMEM (descr, member)
+#  define LIBC_THREAD_SETMEM(descr, member, value) \
+  THREAD_SETMEM (descr, member, value)
+# else
+#  define LIBC_THREAD_GETMEM(descr, member) descr->member
+#  define LIBC_THREAD_SETMEM(descr, member, value) descr->member = (value)
+# endif
+#endif
+
 typedef void (*destr_function)(void *);
 
 struct pthread_key_struct {
@@ -430,6 +441,11 @@ extern void __linuxthreads_reap_event (v
 /* This function is called to initialize the pthread library.  */
 extern void __pthread_initialize (void);
 
+/* TSD.  */
+extern int __pthread_internal_tsd_set (int key, const void * pointer);
+extern void * __pthread_internal_tsd_get (int key);
+extern void ** __attribute__ ((__const__))
+  __pthread_internal_tsd_address (int key);
 
 /* Sighandler wrappers.  */
 extern void __pthread_sighandler(int signo, SIGCONTEXT ctx);
@@ -504,10 +520,24 @@ struct pthread_functions
   int (*ptr_pthread_setcanceltype) (int, int *);
   void (*ptr_pthread_do_exit) (void *retval, char *currentframe);
   pthread_descr (*ptr_pthread_thread_self) (void);
+  int (*ptr_pthread_internal_tsd_set) (int key, const void * pointer);
+  void * (*ptr_pthread_internal_tsd_get) (int key);
+  void ** __attribute__ ((__const__))
+    (*ptr_pthread_internal_tsd_address) (int key);
 };
 
 /* Variable in libc.so.  */
 extern struct pthread_functions __libc_pthread_functions attribute_hidden;
 extern int * __libc_pthread_init (const struct pthread_functions *functions);
 
+#if !defined NOT_IN_libc && !defined FLOATING_STACKS
+# ifdef SHARED
+#  define thread_self() \
+  (*__libc_pthread_functions.ptr_pthread_thread_self) ()
+# else
+weak_extern (__pthread_thread_self)
+#  define thread_self() __pthread_thread_self ()
+# endif
+#endif
+
 #endif /* internals.h */
--- libc/linuxthreads/pthread.c.jj	2002-12-27 17:38:18.000000000 +0100
+++ libc/linuxthreads/pthread.c	2002-12-27 17:42:04.000000000 +0100
@@ -233,6 +233,11 @@ extern void __libc_setup_tls (size_t tcb
 #ifdef SHARED
 static struct pthread_functions pthread_functions =
   {
+#if !(USE_TLS && HAVE___THREAD)
+    .ptr_pthread_internal_tsd_set = __pthread_internal_tsd_set,
+    .ptr_pthread_internal_tsd_get = __pthread_internal_tsd_get,
+    .ptr_pthread_internal_tsd_address = __pthread_internal_tsd_address,
+#endif
     .ptr_pthread_attr_destroy = __pthread_attr_destroy,
 #if SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_1)
     .ptr_pthread_attr_init_2_0 = __pthread_attr_init_2_0,
--- libc/linuxthreads/descr.h.jj	2002-12-27 21:31:56.000000000 +0100
+++ libc/linuxthreads/descr.h	2002-12-27 21:47:14.000000000 +0100
@@ -23,8 +23,16 @@
 #include <stdint.h>
 #include <sys/types.h>
 #include <hp-timing.h>
-#include <bits/libc-tsd.h> /* for _LIBC_TSD_KEY_N */
 
+/* Fast thread-specific data internal to libc.  */
+enum __libc_tsd_key_t { _LIBC_TSD_KEY_MALLOC = 0,
+			_LIBC_TSD_KEY_DL_ERROR,
+			_LIBC_TSD_KEY_RPC_VARS,
+			_LIBC_TSD_KEY_LOCALE,
+			_LIBC_TSD_KEY_CTYPE_B,
+			_LIBC_TSD_KEY_CTYPE_TOLOWER,
+			_LIBC_TSD_KEY_CTYPE_TOUPPER,
+			_LIBC_TSD_KEY_N };
 
 /* The type of thread descriptors */
 typedef struct _pthread_descr_struct *pthread_descr;
--- libc/linuxthreads/Versions.jj	2002-12-18 02:08:46.000000000 +0100
+++ libc/linuxthreads/Versions	2002-12-27 19:05:34.000000000 +0100
@@ -161,7 +161,7 @@ libpthread {
   GLIBC_PRIVATE {
     # Internal libc interface to libpthread
     __libc_internal_tsd_get; __libc_internal_tsd_set;
-    __libc_internal_tsd_address; __libc_alloca_cutoff;
+    __libc_internal_tsd_address;
     __pthread_kill_other_threads_np;
   }
 }
--- libc/linuxthreads/alloca_cutoff.c.jj	2002-12-27 19:05:43.000000000 +0100
+++ libc/linuxthreads/alloca_cutoff.c	2002-12-27 19:10:09.000000000 +0100
@@ -0,0 +1,35 @@
+/* Determine whether block of given size can be allocated on the stack or not.
+   Copyright (C) 2002 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; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <alloca.h>
+#include <stdlib.h>
+#include <sys/param.h>
+#include <sysdep-cancel.h>
+
+int
+__libc_alloca_cutoff (size_t size)
+{
+  if (! SINGLE_THREAD_P)
+    {
+      pthread_descr self = thread_self ();
+      return size <= LIBC_THREAD_GETMEM (self, p_alloca_cutoff);
+    }
+
+  return size <= __MAX_ALLOCA_CUTOFF;
+}
--- libc/linuxthreads/no-tsd.c.jj	2002-10-09 18:58:08.000000000 +0200
+++ libc/linuxthreads/no-tsd.c	2002-12-27 19:05:56.000000000 +0100
@@ -1,46 +0,0 @@
-/* libc-internal interface for thread-specific data.
-   Copyright (C) 1998,99,2002 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; see the file COPYING.LIB.  If not,
-   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
-
-#include <sys/cdefs.h>  /* for __const */
-#include <stdlib.h>
-#include <bits/libc-tsd.h>
-
-#if !(USE_TLS && HAVE___THREAD)
-
-/* This file provides uinitialized (common) definitions for the
-   hooks used internally by libc to access thread-specific data.
-
-   When -lpthread is used, it provides initialized definitions for these
-   variables (in specific.c), which override these uninitialized definitions.
-
-   If -lpthread is not used, these uninitialized variables default to zero,
-   which the __libc_tsd_* macros check for.   */
-
-void *(*__libc_internal_tsd_get) (enum __libc_tsd_key_t);
-int (*__libc_internal_tsd_set) (enum __libc_tsd_key_t,
-				__const void *);
-void **(*__libc_internal_tsd_address) (enum __libc_tsd_key_t)
-     __THROW __attribute__ ((__const__));
-
-#endif /* !(USE_TLS && HAVE___THREAD) */
-
-int __libc_alloca_cutoff (size_t size)
-{
-  return size <= __MAX_ALLOCA_CUTOFF;
-}
--- libc/linuxthreads/Makefile.jj	2002-12-27 12:54:22.000000000 +0100
+++ libc/linuxthreads/Makefile	2002-12-27 19:10:38.000000000 +0100
@@ -28,7 +28,7 @@ headers := pthread.h semaphore.h
 distribute := internals.h queue.h restart.h spinlock.h smp.h tst-signal.sh \
 	      tst-cancel-wrappers.sh libc-tsd.c
 
-routines := forward no-tsd libc-cancellation libc_pthread_init
+routines := forward alloca_cutoff libc-cancellation libc_pthread_init
 shared-only-routines = forward
 
 extra-libs := libpthread
--- libc/linuxthreads/pt-system.c.jj	2002-12-18 02:20:44.000000000 +0100
+++ libc/linuxthreads/pt-system.c	2002-12-27 19:19:05.000000000 +0100
@@ -25,8 +25,5 @@
 int
 system (const char *line)
 {
-  int oldtype = LIBC_CANCEL_ASYNC ();
-  int result = __libc_system (line);
-  LIBC_CANCEL_RESET (oldtype);
-  return result;
+  return __libc_system (line);
 }
--- libc/linuxthreads/tst-cancel-wrappers.sh.jj	2002-12-18 02:21:53.000000000 +0100
+++ libc/linuxthreads/tst-cancel-wrappers.sh	2002-12-27 23:50:11.000000000 +0100
@@ -69,7 +69,10 @@ C["__xpg_sigpause"]=1
     {
       # signals.c in linuxthreads does the cancellation checks not using
       # *_{enable,disable}_asynccancel.
-      if ((!seen_enable || !seen_disable) && !(object ~ /^signals.o/))
+      # Similarly pt-system.o* is allowed to call __libc_system directly.
+      if ((!seen_enable || !seen_disable)
+	  && !(object ~ /^signals.o/)
+	  && !(object ~ /^pt-system.o/))
 	{
 	  printf "in '$1'(%s) %s'\''s cancellation missing\n", object, seen
 	  ret = 1
--- libc/resolv/res_libc.c.jj	2002-11-15 04:36:51.000000000 +0100
+++ libc/resolv/res_libc.c	2002-12-27 16:24:51.000000000 +0100
@@ -41,17 +41,6 @@ struct __res_state _res;
 compat_symbol (libc, _res, _res, GLIBC_2_0);
 # endif
 #endif
-
-/* This function is used to access the resolver state in
-   single-threaded programs.  */
-struct __res_state *
-#if ! USE___THREAD
-weak_const_function
-#endif
-__res_state (void)
-{
-  return &_res;
-}
 
 
 /* The following bit is copied from res_data.c (where it is #ifdef'ed
--- libc/resolv/Makefile.jj	2001-07-06 06:55:39.000000000 +0200
+++ libc/resolv/Makefile	2002-12-27 16:31:17.000000000 +0100
@@ -29,7 +29,7 @@ distribute := ../conf/portability.h mapv
 	      Banner res_hconf.h res_debug.h README gai_misc.h ga_test.c
 
 routines := herror inet_addr inet_ntop inet_pton nsap_addr res_init \
-	    res_hconf res_libc
+	    res_hconf res_libc res-state
 
 tests = tst-aton
 
--- libc/sysdeps/generic/herrno-loc.c.jj	2002-12-27 16:10:50.000000000 +0100
+++ libc/sysdeps/generic/herrno-loc.c	2002-12-27 16:15:40.000000000 +0100
@@ -0,0 +1,33 @@
+/* Copyright (C) 1996, 97, 98, 2002 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 <netdb.h>
+#include <tls.h>
+
+#if ! USE___THREAD
+# undef h_errno
+extern int h_errno;
+#endif
+
+/* When threaded, h_errno may be a per-thread variable.  */
+int *
+weak_const_function
+__h_errno_location (void)
+{
+  return &h_errno;
+}
--- libc/sysdeps/generic/res-state.c.jj	2002-12-27 16:22:39.000000000 +0100
+++ libc/sysdeps/generic/res-state.c	2002-12-27 16:24:27.000000000 +0100
@@ -0,0 +1,35 @@
+/* Copyright (C) 1996, 97, 98, 2002 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 <resolv.h>
+#include <tls.h>
+
+#if ! USE___THREAD
+# undef _res
+extern struct __res_state _res;
+#endif
+
+/* When threaded, _res may be a per-thread variable.  */
+struct __res_state *
+#if ! USE___THREAD
+weak_const_function
+#endif
+__res_state (void)
+{
+  return &_res;
+}
--- libc/nptl/pt-system.c.jj	2002-12-17 03:02:52.000000000 +0100
+++ libc/nptl/pt-system.c	2002-12-27 19:18:47.000000000 +0100
@@ -26,11 +26,5 @@
 int
 system (const char *line)
 {
-  int oldtype = CANCEL_ASYNC ();
-
-  int result = __libc_system (line);
-
-  CANCEL_RESET (oldtype);
-
-  return result;
+  return __libc_system (line);
 }
--- libc/nptl/tst-cancel-wrappers.sh.jj	2002-12-18 01:31:53.000000000 +0100
+++ libc/nptl/tst-cancel-wrappers.sh	2002-12-27 23:50:58.000000000 +0100
@@ -67,7 +67,8 @@ C["__xpg_sigpause"]=1
 /:$/ {
   if (seen)
     {
-      if (!seen_enable || !seen_disable)
+      # pt-system.o* in NPTL calls __libc_system directly.
+      if ((!seen_enable || !seen_disable) && !(object ~ /^pt-system.o/))
 	{
 	  printf "in '$1'(%s) %s'\''s cancellation missing\n", object, seen
 	  ret = 1

	Jakub


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