about summary refs log tree commit diff
path: root/linuxthreads
diff options
context:
space:
mode:
Diffstat (limited to 'linuxthreads')
-rw-r--r--linuxthreads/ChangeLog43
-rw-r--r--linuxthreads/Makefile2
-rw-r--r--linuxthreads/Versions2
-rw-r--r--linuxthreads/alloca_cutoff.c35
-rw-r--r--linuxthreads/descr.h10
-rw-r--r--linuxthreads/internals.h30
-rw-r--r--linuxthreads/libc-cancellation.c30
-rw-r--r--linuxthreads/no-tsd.c46
-rw-r--r--linuxthreads/pt-system.c5
-rw-r--r--linuxthreads/pthread.c5
-rw-r--r--linuxthreads/specific.c24
-rw-r--r--linuxthreads/sysdeps/pthread/bits/libc-tsd.h40
-rw-r--r--linuxthreads/sysdeps/pthread/errno-loc.c44
-rw-r--r--linuxthreads/sysdeps/pthread/herrno-loc.c41
-rw-r--r--linuxthreads/sysdeps/pthread/res-state.c43
-rw-r--r--linuxthreads/tst-cancel-wrappers.sh5
16 files changed, 283 insertions, 122 deletions
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog
index 7dccb8c79a..3c50230de0 100644
--- a/linuxthreads/ChangeLog
+++ b/linuxthreads/ChangeLog
@@ -1,5 +1,48 @@
 2002-12-27  Jakub Jelinek  <jakub@redhat.com>
 
+	* 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.
+
 	* sysdeps/i386/tls.h: Include dl-sysdep.h and stdint.h.
 	(tcbhead_t): Add sysinfo field.
 	(SYSINFO_OFFSET, INIT_SYSINFO): Define.
diff --git a/linuxthreads/Makefile b/linuxthreads/Makefile
index 6425108389..a86aae7d53 100644
--- a/linuxthreads/Makefile
+++ b/linuxthreads/Makefile
@@ -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
diff --git a/linuxthreads/Versions b/linuxthreads/Versions
index fea2e368d8..bf7fda222c 100644
--- a/linuxthreads/Versions
+++ b/linuxthreads/Versions
@@ -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;
   }
 }
diff --git a/linuxthreads/alloca_cutoff.c b/linuxthreads/alloca_cutoff.c
new file mode 100644
index 0000000000..ac5ec3a194
--- /dev/null
+++ b/linuxthreads/alloca_cutoff.c
@@ -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;
+}
diff --git a/linuxthreads/descr.h b/linuxthreads/descr.h
index 74ef25e1f4..d266ffb126 100644
--- a/linuxthreads/descr.h
+++ b/linuxthreads/descr.h
@@ -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;
diff --git a/linuxthreads/internals.h b/linuxthreads/internals.h
index 3e10304c2f..68ad6c72d5 100644
--- a/linuxthreads/internals.h
+++ b/linuxthreads/internals.h
@@ -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 (void);
 /* 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 */
diff --git a/linuxthreads/libc-cancellation.c b/linuxthreads/libc-cancellation.c
index 01972a2557..18feddbf3a 100644
--- a/linuxthreads/libc-cancellation.c
+++ b/linuxthreads/libc-cancellation.c
@@ -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
diff --git a/linuxthreads/no-tsd.c b/linuxthreads/no-tsd.c
deleted file mode 100644
index c1cc3adc0f..0000000000
--- a/linuxthreads/no-tsd.c
+++ /dev/null
@@ -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;
-}
diff --git a/linuxthreads/pt-system.c b/linuxthreads/pt-system.c
index bc5098adc0..3a5f46c4f8 100644
--- a/linuxthreads/pt-system.c
+++ b/linuxthreads/pt-system.c
@@ -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);
 }
diff --git a/linuxthreads/pthread.c b/linuxthreads/pthread.c
index b194fcacea..6bd9de9081 100644
--- a/linuxthreads/pthread.c
+++ b/linuxthreads/pthread.c
@@ -233,6 +233,11 @@ extern void __libc_setup_tls (size_t tcbsize, size_t tcbalign);
 #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,
diff --git a/linuxthreads/specific.c b/linuxthreads/specific.c
index 17e62e82b7..0956ed1983 100644
--- a/linuxthreads/specific.c
+++ b/linuxthreads/specific.c
@@ -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);
-}
diff --git a/linuxthreads/sysdeps/pthread/bits/libc-tsd.h b/linuxthreads/sysdeps/pthread/bits/libc-tsd.h
index e37faf6ba4..04cf7c1a6c 100644
--- a/linuxthreads/sysdeps/pthread/bits/libc-tsd.h
+++ b/linuxthreads/sysdeps/pthread/bits/libc-tsd.h
@@ -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_MALLOC = 0,
 
 #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
 
diff --git a/linuxthreads/sysdeps/pthread/errno-loc.c b/linuxthreads/sysdeps/pthread/errno-loc.c
new file mode 100644
index 0000000000..e79a7cf814
--- /dev/null
+++ b/linuxthreads/sysdeps/pthread/errno-loc.c
@@ -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;
+}
diff --git a/linuxthreads/sysdeps/pthread/herrno-loc.c b/linuxthreads/sysdeps/pthread/herrno-loc.c
new file mode 100644
index 0000000000..ead9a16065
--- /dev/null
+++ b/linuxthreads/sysdeps/pthread/herrno-loc.c
@@ -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;
+}
diff --git a/linuxthreads/sysdeps/pthread/res-state.c b/linuxthreads/sysdeps/pthread/res-state.c
new file mode 100644
index 0000000000..90fe41c80b
--- /dev/null
+++ b/linuxthreads/sysdeps/pthread/res-state.c
@@ -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;
+}
diff --git a/linuxthreads/tst-cancel-wrappers.sh b/linuxthreads/tst-cancel-wrappers.sh
index 14c42dfb8b..364b4729dc 100644
--- a/linuxthreads/tst-cancel-wrappers.sh
+++ b/linuxthreads/tst-cancel-wrappers.sh
@@ -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