diff options
author | Roland McGrath <roland@gnu.org> | 2002-09-25 01:58:37 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2002-09-25 01:58:37 +0000 |
commit | 160bb4094514b41e70a4701235fb622c0061442b (patch) | |
tree | 3c176309b281310c577d02a235035534bffbb56f | |
parent | 1e78de0594ad3963cb789ff82f9e50ec7c48fd9d (diff) | |
download | glibc-160bb4094514b41e70a4701235fb622c0061442b.tar.gz |
* csu/Versions: Use %include <tls.h> to get USE_TLS defined.
(libc: GLIBC_2.0) [USE_TLS && HAVE___THREAD]: Remove _errno, errno.
(libc: GLIBC_2.3) [USE_TLS && HAVE___THREAD]: Put errno here instead.
* resolv/Versions: Use %include <tls.h> to get USE_TLS defined.
(libc: GLIBC_2.0) [USE_TLS && HAVE___THREAD]: Remove _h_errno, h_errno,
and _res.
(libc: GLIBC_2.3) [USE_TLS && HAVE___THREAD]: Put h_errno, _res here.
* elf/tls-macros.h [__x86_64__] (TLS_LE, TLS_IE, TLS_LD, TLS_GD):
New macros for x86-64.
* sysdeps/unix/sysv/linux/alpha/bits/time.h: File removed.
It was indentical to the linux/bits/time.h file.
* nscd/nscd_gethst_r.c (nscd_gethst_r): Add a cast to silence warning.
* resolv/gethnamaddr.c (gethostbyaddr): Use socklen_t for SIZE.
-rw-r--r-- | ChangeLog | 20 | ||||
-rw-r--r-- | csu/Versions | 16 | ||||
-rw-r--r-- | elf/tls-macros.h | 35 | ||||
-rw-r--r-- | linuxthreads/ChangeLog | 8 | ||||
-rw-r--r-- | linuxthreads/Examples/ex13.c | 5 | ||||
-rw-r--r-- | linuxthreads/sysdeps/x86_64/tls.h | 119 | ||||
-rw-r--r-- | nscd/nscd_gethst_r.c | 7 | ||||
-rw-r--r-- | resolv/Versions | 15 | ||||
-rw-r--r-- | resolv/gethnamaddr.c | 3 |
9 files changed, 217 insertions, 11 deletions
@@ -1,3 +1,23 @@ +2002-09-24 Roland McGrath <roland@redhat.com> + + * csu/Versions: Use %include <tls.h> to get USE_TLS defined. + (libc: GLIBC_2.0) [USE_TLS && HAVE___THREAD]: Remove _errno, errno. + (libc: GLIBC_2.3) [USE_TLS && HAVE___THREAD]: Put errno here instead. + * resolv/Versions: Use %include <tls.h> to get USE_TLS defined. + (libc: GLIBC_2.0) [USE_TLS && HAVE___THREAD]: Remove _h_errno, h_errno, + and _res. + (libc: GLIBC_2.3) [USE_TLS && HAVE___THREAD]: Put h_errno, _res here. + + * elf/tls-macros.h [__x86_64__] (TLS_LE, TLS_IE, TLS_LD, TLS_GD): + New macros for x86-64. + + * sysdeps/unix/sysv/linux/alpha/bits/time.h: File removed. + It was indentical to the linux/bits/time.h file. + + * nscd/nscd_gethst_r.c (nscd_gethst_r): Add a cast to silence warning. + + * resolv/gethnamaddr.c (gethostbyaddr): Use socklen_t for SIZE. + 2002-09-23 Ulrich Drepper <drepper@redhat.com> * po/zh_CN.po: New file. diff --git a/csu/Versions b/csu/Versions index 10c962d9ea..f0dfe91ca6 100644 --- a/csu/Versions +++ b/csu/Versions @@ -1,16 +1,26 @@ +%include <tls.h> + libc { GLIBC_2.0 { - # global variables - _errno; - # helper functions __libc_init_first; __libc_start_main; +%if !(USE_TLS && HAVE___THREAD) + # global variables + _errno; + # variables in normal name space errno; +%endif } GLIBC_2.1 { # New special glibc functions. gnu_get_libc_release; gnu_get_libc_version; } + GLIBC_2.3 { +%if USE_TLS && HAVE___THREAD + # This version is for the TLS symbol, GLIBC_2.0 is the old object symbol. + errno; +%endif + } } diff --git a/elf/tls-macros.h b/elf/tls-macros.h index 877581198c..2e3635d26f 100644 --- a/elf/tls-macros.h +++ b/elf/tls-macros.h @@ -95,7 +95,42 @@ __l; }) # endif +#elif defined __x86_64__ + +# define TLS_LE(x) \ + ({ int *__l; \ + asm ("movq %%fs:0,%0\n\t" \ + "leaq " #x "@tpoff(%0), %0" \ + : "=r" (__l)); \ + __l; }) + +# define TLS_IE(x) \ + ({ int *__l; \ + asm ("movq %%fs:0,%0\n\t" \ + "addq " #x "@gottpoff(%%rip),%0" \ + : "=r" (__l)); \ + __l; }) + +# define TLS_LD(x) \ + ({ int *__l, __c, __d; \ + asm ("leaq " #x "@tlsld(%%rip),%%rdi\n\t" \ + "callq __tls_get_addr@plt\n\t" \ + "leaq " #x "@dtpoff(%%rax), %%rax" \ + : "=a" (__l), "=&c" (__c), "=&d" (__d) \ + : : "rdi", "rsi", "r8", "r9", "r10", "r11"); \ + __l; }) + +# define TLS_GD(x) \ + ({ int *__l, __c, __d; \ + asm (".long 0x66666666\n\t" \ + "leaq " #x "@tlsgd(%%rip),%%rdi\n\t" \ + "callq __tls_get_addr@plt" \ + : "=a" (__l), "=&c" (__c), "=&d" (__d) \ + : : "rdi", "rsi", "r8", "r9", "r10", "r11"); \ + __l; }) + #elif defined __sh__ + # define TLS_LE(x) \ ({ int *__l; void *__tp; \ asm ("stc gbr,%1\n\t" \ diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog index 084ed375c2..58c9ef337d 100644 --- a/linuxthreads/ChangeLog +++ b/linuxthreads/ChangeLog @@ -1,3 +1,11 @@ +2002-09-24 Roland McGrath <roland@redhat.com> + + * sysdeps/x86_64/tls.h: New file. + +2002-09-23 Roland McGrath <roland@redhat.com> + + * Examples/ex13.c (dump_mut): int -> size_t for counter. + 2002-09-18 Bruno Haible <bruno@clisp.org> * Examples/ex10.c (thread): Fail if pthread_mutex_timedlock() returns diff --git a/linuxthreads/Examples/ex13.c b/linuxthreads/Examples/ex13.c index 0a3fcc0b23..c485039d51 100644 --- a/linuxthreads/Examples/ex13.c +++ b/linuxthreads/Examples/ex13.c @@ -1,5 +1,5 @@ /* Test for Pthreads/mutexes. - Copyright (C) 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Kurt Garloff <garloff@suse.de>, 2000. @@ -38,8 +38,7 @@ struct thr_ctrl static void dump_mut (pthread_mutex_t * mut) { - int i; - + size_t i; for (i = 0; i < sizeof (*mut); i++) printf (" %02x", *((unsigned char *) mut + i)); printf ("\n"); diff --git a/linuxthreads/sysdeps/x86_64/tls.h b/linuxthreads/sysdeps/x86_64/tls.h new file mode 100644 index 0000000000..17773d55bb --- /dev/null +++ b/linuxthreads/sysdeps/x86_64/tls.h @@ -0,0 +1,119 @@ +/* Definitions for thread-local data handling. linuxthreads/x86-64 version. + 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; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _TLS_H +#define _TLS_H + +# include <pt-machine.h> + +#ifndef __ASSEMBLER__ +# include <stddef.h> + +/* Type for the dtv. */ +typedef union dtv +{ + size_t counter; + void *pointer; +} dtv_t; + + +typedef struct +{ + void *tcb; /* Pointer to the TCB. Not necessary the + thread descriptor used by libpthread. */ + dtv_t *dtv; + void *self; /* Pointer to the thread descriptor. */ +} tcbhead_t; +#endif + + +#ifdef HAVE_TLS_SUPPORT + +/* Signal that TLS support is available. */ +# define USE_TLS 1 + +# ifndef __ASSEMBLER__ +/* Get system call information. */ +# include <sysdep.h> + +/* Get the thread descriptor definition. */ +# include <linuxthreads/descr.h> + +/* This is the size of the initial TCB. */ +# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t) + +/* Alignment requirements for the initial TCB. */ +# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t) + +/* This is the size of the TCB. */ +# define TLS_TCB_SIZE sizeof (struct _pthread_descr_struct) + +/* Alignment requirements for the TCB. */ +# define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct) + +/* The TCB can have any size and the memory following the address the + thread pointer points to is unspecified. Allocate the TCB there. */ +# define TLS_TCB_AT_TP 1 + + +/* Install the dtv pointer. The pointer passed is to the element with + index -1 which contain the length. */ +# define INSTALL_DTV(descr, dtvp) \ + ((tcbhead_t *) (descr))->dtv = (dtvp) + 1 + +/* Install new dtv for current thread. */ +# define INSTALL_NEW_DTV(dtv) \ + ({ struct _pthread_descr_struct *__descr; \ + THREAD_SETMEM (__descr, p_header.data.dtvp, (dtv)); }) + +/* Return dtv of given thread descriptor. */ +# define GET_DTV(descr) \ + (((tcbhead_t *) (descr))->dtv) + +/* Code to initially initialize the thread pointer. This might need + special attention since 'errno' is not yet available and if the + operation can cause a failure 'errno' must not be touched. */ +# define TLS_INIT_TP(descr, secondcall) \ + ({ \ + void *_descr = (descr); \ + tcbhead_t *head = _descr; \ + long int _result; \ + \ + head->tcb = _descr; \ + /* For now the thread descriptor is at the same address. */ \ + head->self = _descr; \ + \ + asm volatile ("syscall" \ + : "=a" (_result) \ + : "0" ((unsigned long int) __NR_arch_prctl), \ + "D" ((unsigned long int) ARCH_SET_FS), \ + "S" (_descr) \ + : "memory", "cc", "r11", "cx"); \ + _result ? -1 : 0; \ + }) + +/* Return the address of the dtv for the current thread. */ +# define THREAD_DTV() \ + ({ struct _pthread_descr_struct *__descr; \ + THREAD_GETMEM (__descr, p_header.data.dtvp); }) + +# endif /* HAVE_TLS_SUPPORT */ +#endif /* __ASSEMBLER__ */ + +#endif /* tls.h */ diff --git a/nscd/nscd_gethst_r.c b/nscd/nscd_gethst_r.c index d371922430..f51cceb928 100644 --- a/nscd/nscd_gethst_r.c +++ b/nscd/nscd_gethst_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. +/* Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -263,7 +263,7 @@ nscd_gethst_r (const char *key, size_t keylen, request_type type, } resultbuf->h_addr_list[cnt] = NULL; - if (__readv (sock, vec, n) != total_len) + if ((size_t) __readv (sock, vec, n) != total_len) { __close (sock); return -1; @@ -284,7 +284,8 @@ nscd_gethst_r (const char *key, size_t keylen, request_type type, goto no_room; /* And finally read the aliases. */ - if (__read (sock, resultbuf->h_aliases[0], total_len) != total_len) + if ((size_t) __read (sock, resultbuf->h_aliases[0], total_len) + != total_len) { __close (sock); return -1; diff --git a/resolv/Versions b/resolv/Versions index 668f643363..ab6a386802 100644 --- a/resolv/Versions +++ b/resolv/Versions @@ -1,7 +1,11 @@ +%include <tls.h> + libc { GLIBC_2.0 { +%if !(USE_TLS && HAVE___THREAD) # global variables _h_errno; _res; +%endif # helper functions __h_errno_location; @@ -10,7 +14,10 @@ libc { __res_randomid; # variables in normal name space - h_errlist; h_errno; h_nerr; + h_errlist; h_nerr; +%if !(USE_TLS && HAVE___THREAD) + h_errno; +%endif # h* herror; hstrerror; @@ -22,6 +29,12 @@ libc { # r* __res_state; __res_init; __res_nclose; __res_ninit; _res_hconf; } + GLIBC_2.3 { +%if USE_TLS && HAVE___THREAD + # This version is for the TLS symbol, GLIBC_2.0 is the old object symbol. + h_errno; _res; +%endif + } GLIBC_PRIVATE { __gai_sigqueue; } diff --git a/resolv/gethnamaddr.c b/resolv/gethnamaddr.c index 8236b144a8..1ab102b420 100644 --- a/resolv/gethnamaddr.c +++ b/resolv/gethnamaddr.c @@ -633,7 +633,8 @@ gethostbyaddr(addr, len, af) const u_char *uaddr = (const u_char *)addr; static const u_char mapped[] = { 0,0, 0,0, 0,0, 0,0, 0,0, 0xff,0xff }; static const u_char tunnelled[] = { 0,0, 0,0, 0,0, 0,0, 0,0, 0,0 }; - int n, size; + int n; + socklen_t size; querybuf buf; register struct hostent *hp; char qbuf[MAXDNAME+1], *qp = NULL; |