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] |
Hi! I gave this some more testing yesterday and it seems to work just fine. 2002-08-02 Jakub Jelinek <jakub@redhat.com> * sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_SET_THREAD_AREA_SYSCALL): Define. * sysdeps/i386/useldt.h (DO_MODIFY_LDT): Move from INIT_THREAD_SELF. (INIT_THREAD_SELF): Use sys_thread_area syscall instead if available. (FREE_THREAD): Avoid modify_ldt if using GDT. * sysdeps/i386/pspinlock.c (__have_no_set_thread_area): New. --- libc/linuxthreads/sysdeps/i386/useldt.h.jj 2002-07-29 15:14:52.000000000 +0200 +++ libc/linuxthreads/sysdeps/i386/useldt.h 2002-07-29 17:58:04.000000000 +0200 @@ -22,6 +22,7 @@ #ifndef __ASSEMBLER__ #include <stddef.h> /* For offsetof. */ #include <stdlib.h> /* For abort(). */ +#include <sysdep.h> /* For INLINE_SYSCALL. */ /* We don't want to include the kernel header. So duplicate the @@ -61,24 +62,74 @@ extern int __modify_ldt (int, struct mod __self; \ }) -/* Initialize the thread-unique value. */ -#define INIT_THREAD_SELF(descr, nr) \ -{ \ +#define DO_MODIFY_LDT(descr, nr) \ +({ \ struct modify_ldt_ldt_s ldt_entry = \ { nr, (unsigned long int) descr, sizeof (struct _pthread_descr_struct), \ 1, 0, 0, 0, 0, 1, 0 }; \ if (__modify_ldt (1, &ldt_entry, sizeof (ldt_entry)) != 0) \ abort (); \ - __asm__ __volatile__ ("movw %w0, %%gs" : : "q" (nr * 8 + 7)); \ + nr * 8 + 7; \ +}) + +/* Initialize the thread-unique value. */ +#ifdef __ASSUME_SET_THREAD_AREA_SYSCALL +#define INIT_THREAD_SELF(descr, nr) \ +{ \ + int __gs = INLINE_SYSCALL (set_thread_area, 2, descr, 1); \ + if (__gs == -1) \ + abort (); \ + __asm__ __volatile__ ("movw %w0, %%gs" : : "q" (__gs)); \ } +#elif defined __NR_set_thread_area + +/* Defined in pspinlock.c. */ +extern int __have_no_set_thread_area; + +#define INIT_THREAD_SELF(descr, nr) \ +{ \ + int __gs = -1; \ + if (! __builtin_expect (__have_no_set_thread_area, 0)) \ + { \ + if ((__gs = INLINE_SYSCALL (set_thread_area, 2, descr, 1)) == -1 \ + && errno == ENOSYS) \ + __have_no_set_thread_area = 1; \ + } \ + if (__builtin_expect (__gs == -1, 0)) \ + __gs = DO_MODIFY_LDT (descr, nr); \ + __asm__ __volatile__ ("movw %w0, %%gs" : : "q" (__gs)); \ +} +#else +#define INIT_THREAD_SELF(descr, nr) \ +{ \ + int __gs = DO_MODIFY_LDT (descr, nr); \ + __asm__ __volatile__ ("movw %w0, %%gs" : : "q" (__gs)); \ +} +#endif /* Free resources associated with thread descriptor. */ +#ifdef __ASSUME_SET_THREAD_AREA_SYSCALL +#define FREE_THREAD(descr, nr) do { } while (0) +#elif defined __NR_set_thread_area +#define FREE_THREAD(descr, nr) \ +{ \ + int __gs; \ + __asm__ __volatile__ ("movw %%gs, %w0" : "=q" (__gs)); \ + if (__builtin_expect (__gs & 4, 0)) \ + { \ + struct modify_ldt_ldt_s ldt_entry = \ + { nr, 0, 0, 0, 0, 1, 0, 1, 0, 0 }; \ + __modify_ldt (1, &ldt_entry, sizeof (ldt_entry)); \ + } \ +} +#else #define FREE_THREAD(descr, nr) \ { \ struct modify_ldt_ldt_s ldt_entry = \ { nr, 0, 0, 0, 0, 1, 0, 1, 0, 0 }; \ __modify_ldt (1, &ldt_entry, sizeof (ldt_entry)); \ } +#endif /* Read member of the thread descriptor directly. */ #define THREAD_GETMEM(descr, member) \ --- libc/linuxthreads/sysdeps/i386/pspinlock.c.jj 2001-01-02 14:17:38.000000000 +0100 +++ libc/linuxthreads/sysdeps/i386/pspinlock.c 2002-07-29 15:35:10.000000000 +0200 @@ -95,3 +95,5 @@ __pthread_spin_destroy (pthread_spinlock return 0; } weak_alias (__pthread_spin_destroy, pthread_spin_destroy) + +int __have_no_set_thread_area; --- libc/sysdeps/unix/sysv/linux/kernel-features.h.jj 2002-07-23 10:06:16.000000000 +0200 +++ libc/sysdeps/unix/sysv/linux/kernel-features.h 2002-07-29 18:07:09.000000000 +0200 @@ -1,6 +1,6 @@ /* Set flags signalling availability of kernel features based on given kernel version number. - Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 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 @@ -184,6 +184,12 @@ # define __ASSUME_MMAP2_SYSCALL 1 #endif +/* On x86, the set_thread_area syscall was introduced in 2.5.29, but its + semantics was changed in 2.5.30. */ +#if __LINUX_KERNEL_VERSION >= 132382 && defined __i386__ +# define __ASSUME_SET_THREAD_AREA_SYSCALL 1 +#endif + /* There are an infinite number of PA-RISC kernel versions numbered 2.4.0. But they've not really been released as such. We require and expect the final version here. */ Jakub
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |