aboutsummaryrefslogtreecommitdiff
path: root/linuxthreads/sysdeps
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-08-26 16:00:46 +0000
committerUlrich Drepper <drepper@redhat.com>1998-08-26 16:00:46 +0000
commit00a2f9aa41a4f2a441c3b9787ca1a7701632de5f (patch)
tree55ba2c2f0f2e630c24fd23f81029c1dbc7de3058 /linuxthreads/sysdeps
parent08cac4ac19abd40887afbd9d841cd96a8efbbe98 (diff)
downloadglibc-00a2f9aa41a4f2a441c3b9787ca1a7701632de5f.tar
glibc-00a2f9aa41a4f2a441c3b9787ca1a7701632de5f.tar.gz
glibc-00a2f9aa41a4f2a441c3b9787ca1a7701632de5f.tar.bz2
glibc-00a2f9aa41a4f2a441c3b9787ca1a7701632de5f.zip
Update.
1998-08-26 15:46 Ulrich Drepper <drepper@cygnus.com> * internals.h: Define THREAD_GETMEM and THREAD_SETMEM to default if not already defined. (struct _pthread_descr_struct): Add p_self and p_nr field. * manager.c (__pthread_handles): Define second element to point to manager thread. (__pthread_handles_num): Initialize to 2. (__pthread_manager): Use INIT_THREAD_SELF with two arguments. (pthread_start_thread): Likewise. (pthread_handle_create): Start search for free slot at entry 2. Initialize new fields p_self and p_nr. Call __clone with CLONE_PTRACE if available. (pthread_free): Call FREE_THREAD_SELF if available. * pthread.c (__pthread_initial_thread): Initialize new fields. (__pthread_manager_thread): Likewise. (__pthread_initialize_manager): Call __clone with CLONE_PTRACE. * cancel.c: Use THREAD_GETMEM and THREAD_SETMEM to access the elements of the thread descriptor. * condvar.c: Likewise. * errno.c: Likewise. * join.c: Likewise. * manager.c: Likewise. * pthread.c: Likewise. * ptlongjmp.c: Likewise. * semaphore.c: Likewise. * signals.c: Likewise. * specific.c: Likewise. * spinlock.c: Likewise. * sysdeps/alpha/pt-machine.h (INIT_THREAD_SELF): Add extra parameter. * sysdeps/i386/useldt.h: New file. * sysdeps/i386/i686/pt-machine.h: Show how to use this file. * sysdeps/sparc/sparc32/pt-machine.h: Define THREAD_GETMEM and THREAD_SETMEM using __thread_self. * sysdeps/sparc/sparc64/pt-machine.h: Likewise.
Diffstat (limited to 'linuxthreads/sysdeps')
-rw-r--r--linuxthreads/sysdeps/alpha/pt-machine.h4
-rw-r--r--linuxthreads/sysdeps/i386/i686/pt-machine.h4
-rw-r--r--linuxthreads/sysdeps/i386/useldt.h124
-rw-r--r--linuxthreads/sysdeps/sparc/sparc32/pt-machine.h6
-rw-r--r--linuxthreads/sysdeps/sparc/sparc64/pt-machine.h6
5 files changed, 140 insertions, 4 deletions
diff --git a/linuxthreads/sysdeps/alpha/pt-machine.h b/linuxthreads/sysdeps/alpha/pt-machine.h
index a0c7cc77e2..41b37daf8e 100644
--- a/linuxthreads/sysdeps/alpha/pt-machine.h
+++ b/linuxthreads/sysdeps/alpha/pt-machine.h
@@ -1,6 +1,6 @@
/* Machine-dependent pthreads configuration and inline functions.
Alpha version.
- Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Richard Henderson <rth@tamu.edu>.
@@ -70,7 +70,7 @@ register char *stack_pointer __asm__("$30");
})
/* Initialize the thread-unique value. */
-#define INIT_THREAD_SELF(descr) \
+#define INIT_THREAD_SELF(descr, nr) \
{ \
register pthread_descr __self __asm__("$16") = (descr); \
__asm__ __volatile__ ("call_pal %1" : : "r"(__self), "i"(PAL_wruniq)); \
diff --git a/linuxthreads/sysdeps/i386/i686/pt-machine.h b/linuxthreads/sysdeps/i386/i686/pt-machine.h
index bb0f0bc8e1..a4b3a63f1c 100644
--- a/linuxthreads/sysdeps/i386/i686/pt-machine.h
+++ b/linuxthreads/sysdeps/i386/i686/pt-machine.h
@@ -70,3 +70,7 @@ set_eflags (int newflags)
{
__asm__ __volatile__ ("pushl %0; popfl" : : "r" (newflags) : "cc");
}
+
+
+/* Use the LDT implementation only if the kernel is fixed. */
+//#include "../useldt.h"
diff --git a/linuxthreads/sysdeps/i386/useldt.h b/linuxthreads/sysdeps/i386/useldt.h
new file mode 100644
index 0000000000..2fdc0ce767
--- /dev/null
+++ b/linuxthreads/sysdeps/i386/useldt.h
@@ -0,0 +1,124 @@
+/* Special definitions for ix86 machine using segment register based
+ thread descriptor.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library 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 <stddef.h> /* For offsetof. */
+
+
+/* We don't want to include the kernel header. So duplicate the
+ information. */
+
+/* Structure passed on `modify_ldt' call. */
+struct modify_ldt_ldt_s
+{
+ unsigned int entry_number;
+ unsigned long int base_addr;
+ unsigned int limit;
+ unsigned int seg_32bit:1;
+ unsigned int contents:2;
+ unsigned int read_exec_only:1;
+ unsigned int limit_in_pages:1;
+ unsigned int seg_not_present:1;
+ unsigned int useable:1;
+ unsigned int empty:25;
+};
+
+/* System call to set LDT entry. */
+extern int __modify_ldt (int, struct modify_ldt_ldt_s *, size_t);
+
+
+/* Return the thread descriptor for the current thread.
+
+ The contained asm must *not* be marked volatile since otherwise
+ assignments like
+ pthread_descr self = thread_self();
+ do not get optimized away. */
+#define THREAD_SELF \
+({ \
+ register pthread_descr __self; \
+ __asm__ ("movl %%gs:%c1,%0" : "=r" (__self) \
+ : "i" (offsetof (struct _pthread_descr_struct, p_self))); \
+ __self; \
+})
+
+/* Initialize the thread-unique value. */
+#define INIT_THREAD_SELF(descr, nr) \
+{ \
+ struct modify_ldt_ldt_s ldt_entry = \
+ { nr, (unsigned long int) descr, sizeof (*descr), 1, 0, 0, 0, 0, 1, 0 }; \
+ if (__modify_ldt (1, &ldt_entry, sizeof (ldt_entry)) != 0) \
+ abort (); \
+ __asm__ __volatile__ ("movw %w0, %%gs" : : "r" (nr * 8 + 7)); \
+}
+
+/* Free resources associated with thread descriptor. */
+#define FREE_THREAD_SELF(descr, nr) \
+{ \
+ struct modify_ldt_ldt_s ldt_entry = \
+ { nr, 0, 0, 0, 0, 1, 0, 1, 0, 0 }; \
+ __asm__ __volatile__ ("movw %w0,%%gs" : : "r" (0)); \
+ __modify_ldt (1, &ldt_entry, sizeof (ldt_entry)); \
+}
+
+/* Read member of the thread descriptor directly. */
+#define THREAD_GETMEM(descr, member) \
+({ \
+ __typeof__ (descr->member) __value; \
+ if (sizeof (__value) == 1) \
+ __asm__ __volatile__ ("movb %%gs:%c1,%b0" \
+ : "=r" (__value) \
+ : "0" (0), \
+ "i" (offsetof (struct _pthread_descr_struct, \
+ member))); \
+ else \
+ { \
+ if (sizeof (__value) != 4) \
+ /* There should not be any value with a size other than 1 or 4. */ \
+ abort (); \
+ \
+ __asm__ __volatile__ ("movl %%gs:%c1,%0" \
+ : "=r" (__value) \
+ : "i" (offsetof (struct _pthread_descr_struct, \
+ member))); \
+ } \
+ __value; \
+})
+
+/* Set member of the thread descriptor directly. */
+#define THREAD_SETMEM(descr, member, value) \
+({ \
+ __typeof__ (descr->member) __value = (value); \
+ if (sizeof (__value) == 1) \
+ __asm__ __volatile__ ("movb %0,%%gs:%c1" : \
+ : "r" (__value), \
+ "i" (offsetof (struct _pthread_descr_struct, \
+ member))); \
+ else \
+ { \
+ if (sizeof (__value) != 4) \
+ /* There should not be any value with a size other than 1 or 4. */ \
+ abort (); \
+ \
+ __asm__ __volatile__ ("movl %0,%%gs:%c1" : \
+ : "r" (__value), \
+ "i" (offsetof (struct _pthread_descr_struct, \
+ member))); \
+ } \
+})
diff --git a/linuxthreads/sysdeps/sparc/sparc32/pt-machine.h b/linuxthreads/sysdeps/sparc/sparc32/pt-machine.h
index 13f78e319a..7eea8d400c 100644
--- a/linuxthreads/sysdeps/sparc/sparc32/pt-machine.h
+++ b/linuxthreads/sysdeps/sparc/sparc32/pt-machine.h
@@ -1,6 +1,6 @@
/* Machine-dependent pthreads configuration and inline functions.
sparc version.
- Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Richard Henderson <rth@tamu.edu>.
@@ -53,3 +53,7 @@ register struct _pthread_descr_struct *__thread_self __asm__("%g6");
/* Initialize the thread-unique value. */
#define INIT_THREAD_SELF(descr) (__thread_self = (descr))
+
+/* Access to data in the thread descriptor is easy. */
+#define THREAD_GETMEM(descr, member) __thread_self->member
+#define THREAD_SETMEM(descr, member, value) __thread_self->member = (value)
diff --git a/linuxthreads/sysdeps/sparc/sparc64/pt-machine.h b/linuxthreads/sysdeps/sparc/sparc64/pt-machine.h
index 5424860786..e94e1a5fb2 100644
--- a/linuxthreads/sysdeps/sparc/sparc64/pt-machine.h
+++ b/linuxthreads/sysdeps/sparc/sparc64/pt-machine.h
@@ -1,6 +1,6 @@
/* Machine-dependent pthreads configuration and inline functions.
Sparc v9 version.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Richard Henderson <rth@tamu.edu>.
@@ -65,3 +65,7 @@ __compare_and_swap (long int *p, long int oldval, long int newval)
return readval == newval;
}
+
+/* Access to data in the thread descriptor is easy. */
+#define THREAD_GETMEM(descr, member) __thread_self->member
+#define THREAD_SETMEM(descr, member, value) __thread_self->member = (value)