From: Andreas Jaeger Date: Fri, 14 Dec 2001 15:56:38 +0000 (+0000) Subject: Merge from mainline. X-Git-Tag: cvs/glibc-2-2-5~79 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d46d6ca3db74aeccc783c579ac326c3cedf5da43;p=thirdparty%2Fglibc.git Merge from mainline. --- diff --git a/ChangeLog b/ChangeLog index bc85c2b7149..1f8524194a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-11-29 Andreas Jaeger + + * sysdeps/unix/sysv/linux/x86_64/Versions: Add arch_prctl. + * sysdeps/unix/sysv/linux/x86_64/syscalls.list: Add arch_prctl call. + 2001-12-13 Andreas Schwab * stdio-common/vfprintf.c (process_string_arg): Correctly handle diff --git a/NEWS b/NEWS index 24df25f428b..afcea61a94f 100644 --- a/NEWS +++ b/NEWS @@ -14,7 +14,7 @@ Version 2.2.5 * Masahide Washizawa contributed iconv modules for IBM1132, IBM1133, IBM1160, IBM1161, and IBM1162 charsets. -* Andreas Jaeger contributed a port to x86_64/Linux. +* Andreas Jaeger contributed a port to x86-64/Linux. * Peter Bruin contributed a port to PowerPC/Hurd. diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog index 5dadede8cf1..b32585e9202 100644 --- a/linuxthreads/ChangeLog +++ b/linuxthreads/ChangeLog @@ -1,3 +1,16 @@ +2001-11-29 Andreas Jaeger + + * sysdeps/x86_64/pt-machine.h: Use %gs as thread specific + register. + (THREAD_SELF): New. + (INIT_THREAD_SELF): New. + (THREAD_GETMEM): New. + (THREAD_GETMEM_NC): + (THREAD_SETMEM): New. + (THREAD_SETMEM_NC): New. + (FLOATING_STACKS): Define. + (ARCH_STACK_MAX_SIZE): Define. + 2001-12-13 Andreas Schwab * specific.c (pthread_key_delete): Don't contact the thread @@ -23,7 +36,7 @@ (__pthread_manager): Handle new REQ_FOR_EACH_THREAD request. * specific.c (struct pthread_key_delete_helper_args): New type. (pthread_key_delete_helper): New static function. - (pthread_key_delete): Use the new thread manager + (pthread_key_delete): Use the new thread manager REQ_FOR_EACH_THREAD function to iterate over the threads and set the delete key slot to a null value in each thread. * Examples/ex18.c: New test. diff --git a/linuxthreads/sysdeps/x86_64/pt-machine.h b/linuxthreads/sysdeps/x86_64/pt-machine.h index 877b3fad036..fa664746eff 100644 --- a/linuxthreads/sysdeps/x86_64/pt-machine.h +++ b/linuxthreads/sysdeps/x86_64/pt-machine.h @@ -18,6 +18,11 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#include /* For offsetof. */ +#include /* For abort(). */ +#include + + #ifndef PT_EI # define PT_EI extern inline #endif @@ -59,3 +64,147 @@ __compare_and_swap (long int *p, long int oldval, long int newval) : "memory"); return ret; } + + +/* 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__ ("movq %%gs:%c1,%0" : "=r" (__self) \ + : "i" (offsetof (struct _pthread_descr_struct, \ + p_header.data.self))); \ + __self; \ +}) + +/* Prototype for the system call. */ +extern int __arch_prctl (int __code, unsigned long __addr); + +/* Initialize the thread-unique value. */ +#define INIT_THREAD_SELF(descr, nr) \ +{ \ + if (__arch_prctl (ARCH_SET_GS, descr) != 0) \ + abort (); \ +} + +/* Read member of the thread descriptor directly. */ +#define THREAD_GETMEM(descr, member) \ +({ \ + __typeof__ (descr->member) __value; \ + if (sizeof (__value) == 1) \ + __asm__ __volatile__ ("movb %%gs:%P2,%b0" \ + : "=q" (__value) \ + : "0" (0), \ + "i" (offsetof (struct _pthread_descr_struct, \ + member))); \ + else if (sizeof (__value) == 4) \ + __asm__ __volatile__ ("movl %%gs:%P1,%0" \ + : "=r" (__value) \ + : "i" (offsetof (struct _pthread_descr_struct, \ + member))); \ + else \ + { \ + if (sizeof (__value) != 8) \ + /* There should not be any value with a size other than 1, 4 or 8. */\ + abort (); \ + \ + __asm__ __volatile__ ("movq %%gs:%P1,%0" \ + : "=r" (__value) \ + : "i" (offsetof (struct _pthread_descr_struct, \ + member))); \ + } \ + __value; \ +}) + +/* Same as THREAD_GETMEM, but the member offset can be non-constant. */ +#define THREAD_GETMEM_NC(descr, member) \ +({ \ + __typeof__ (descr->member) __value; \ + if (sizeof (__value) == 1) \ + __asm__ __volatile__ ("movb %%gs:(%2),%b0" \ + : "=q" (__value) \ + : "0" (0), \ + "r" (offsetof (struct _pthread_descr_struct, \ + member))); \ + else if (sizeof (__value) == 4) \ + __asm__ __volatile__ ("movl %%gs:(%1),%0" \ + : "=r" (__value) \ + : "r" (offsetof (struct _pthread_descr_struct, \ + member))); \ + else \ + { \ + if (sizeof (__value) != 8) \ + /* There should not be any value with a size other than 1, 4 or 8. */\ + abort (); \ + \ + __asm__ __volatile__ ("movq %%gs:(%1),%0" \ + : "=r" (__value) \ + : "r" (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:%P1" : \ + : "q" (__value), \ + "i" (offsetof (struct _pthread_descr_struct, \ + member))); \ + else if (sizeof (__value) == 4) \ + __asm__ __volatile__ ("movl %0,%%gs:%P1" : \ + : "r" (__value), \ + "i" (offsetof (struct _pthread_descr_struct, \ + member))); \ + else \ + { \ + if (sizeof (__value) != 8) \ + /* There should not be any value with a size other than 1, 4 or 8. */\ + abort (); \ + \ + __asm__ __volatile__ ("movq %0,%%gs:%P1" : \ + : "r" (__value), \ + "i" (offsetof (struct _pthread_descr_struct, \ + member))); \ + } \ +}) + +/* Same as THREAD_SETMEM, but the member offset can be non-constant. */ +#define THREAD_SETMEM_NC(descr, member, value) \ +({ \ + __typeof__ (descr->member) __value = (value); \ + if (sizeof (__value) == 1) \ + __asm__ __volatile__ ("movb %0,%%gs:(%1)" : \ + : "q" (__value), \ + "r" (offsetof (struct _pthread_descr_struct, \ + member))); \ + else if (sizeof (__value) == 4) \ + __asm__ __volatile__ ("movl %0,%%gs:(%1)" : \ + : "r" (__value), \ + "r" (offsetof (struct _pthread_descr_struct, \ + member))); \ + else \ + { \ + if (sizeof (__value) != 8) \ + /* There should not be any value with a size other than 1, 4 or 8. */\ + abort (); \ + \ + __asm__ __volatile__ ("movq %0,%%gs:(%1)" : \ + : "r" (__value), \ + "r" (offsetof (struct _pthread_descr_struct, \ + member))); \ + } \ +}) + +/* We want the OS to assign stack addresses. */ +#define FLOATING_STACKS 1 + +/* Maximum size of the stack if the rlimit is unlimited. */ +#define ARCH_STACK_MAX_SIZE 32*1024*1024 diff --git a/sysdeps/unix/sysv/linux/x86_64/Makefile b/sysdeps/unix/sysv/linux/x86_64/Makefile index 6564eb0bc5d..0aacd002240 100644 --- a/sysdeps/unix/sysv/linux/x86_64/Makefile +++ b/sysdeps/unix/sysv/linux/x86_64/Makefile @@ -1,4 +1,4 @@ ifeq ($(subdir),misc) sysdep_routines += ioperm iopl -sysdep_headers += sys/perm.h sys/reg.h +sysdep_headers += sys/perm.h sys/reg.h sys/debugreg.h endif diff --git a/sysdeps/unix/sysv/linux/x86_64/Versions b/sysdeps/unix/sysv/linux/x86_64/Versions index 76ee0ae8761..e28893a9324 100644 --- a/sysdeps/unix/sysv/linux/x86_64/Versions +++ b/sysdeps/unix/sysv/linux/x86_64/Versions @@ -1,5 +1,7 @@ libc { GLIBC_2.2.5 { + arch_prctl; __arch_prctl; + ioperm; iopl; __modify_ldt; modify_ldt;