aboutsummaryrefslogtreecommitdiff
path: root/linuxthreads
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2002-09-25 01:58:37 +0000
committerRoland McGrath <roland@gnu.org>2002-09-25 01:58:37 +0000
commit160bb4094514b41e70a4701235fb622c0061442b (patch)
tree3c176309b281310c577d02a235035534bffbb56f /linuxthreads
parent1e78de0594ad3963cb789ff82f9e50ec7c48fd9d (diff)
downloadglibc-160bb4094514b41e70a4701235fb622c0061442b.zip
glibc-160bb4094514b41e70a4701235fb622c0061442b.tar.gz
glibc-160bb4094514b41e70a4701235fb622c0061442b.tar.bz2
* 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.
Diffstat (limited to 'linuxthreads')
-rw-r--r--linuxthreads/ChangeLog8
-rw-r--r--linuxthreads/Examples/ex13.c5
-rw-r--r--linuxthreads/sysdeps/x86_64/tls.h119
3 files changed, 129 insertions, 3 deletions
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog
index 084ed37..58c9ef3 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 0a3fcc0..c485039 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 0000000..17773d5
--- /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 */