OLD | NEW |
1 /* Definition for thread-local data handling. nptl/x86_64 version. | 1 /* Definition for thread-local data handling. nptl/x86_64 version. |
2 Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc. | 2 Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc. |
3 This file is part of the GNU C Library. | 3 This file is part of the GNU C Library. |
4 | 4 |
5 The GNU C Library is free software; you can redistribute it and/or | 5 The GNU C Library is free software; you can redistribute it and/or |
6 modify it under the terms of the GNU Lesser General Public | 6 modify it under the terms of the GNU Lesser General Public |
7 License as published by the Free Software Foundation; either | 7 License as published by the Free Software Foundation; either |
8 version 2.1 of the License, or (at your option) any later version. | 8 version 2.1 of the License, or (at your option) any later version. |
9 | 9 |
10 The GNU C Library is distributed in the hope that it will be useful, | 10 The GNU C Library is distributed in the hope that it will be useful, |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 Lesser General Public License for more details. | 13 Lesser General Public License for more details. |
14 | 14 |
15 You should have received a copy of the GNU Lesser General Public | 15 You should have received a copy of the GNU Lesser General Public |
16 License along with the GNU C Library; if not, write to the Free | 16 License along with the GNU C Library; if not, write to the Free |
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | 17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
18 02111-1307 USA. */ | 18 02111-1307 USA. */ |
19 | 19 |
20 #ifndef _TLS_H | 20 #ifndef _TLS_H |
21 #define _TLS_H 1 | 21 #define _TLS_H 1 |
22 | 22 |
23 #ifndef __ASSEMBLER__ | 23 #ifndef __ASSEMBLER__ |
24 # include <asm/prctl.h> /* For ARCH_SET_FS. */ | 24 # include <asm/prctl.h> /* For ARCH_SET_FS. */ |
25 # include <stdbool.h> | 25 # include <stdbool.h> |
26 # include <stddef.h> | 26 # include <stddef.h> |
27 # include <stdint.h> | 27 # include <stdint.h> |
28 # include <stdlib.h> | 28 # include <stdlib.h> |
| 29 /* Return the thread descriptor for the current thread. |
| 30 |
| 31 The contained asm must *not* be marked volatile since otherwise |
| 32 assignments like |
| 33 pthread_descr self = thread_self(); |
| 34 do not get optimized away. |
| 35 |
| 36 We need it before sysdep.h in NaCl for INTERNAL_SYSCALL_gettid_0. */ |
| 37 #ifdef __native_client__ |
| 38 void* __nacl_read_tp (void) __attribute__ ((const)); |
| 39 # define THREAD_SELF ((struct pthread *)__nacl_read_tp ()) |
| 40 #endif |
29 # include <sysdep.h> | 41 # include <sysdep.h> |
30 # include <kernel-features.h> | 42 # include <kernel-features.h> |
31 | 43 |
32 | 44 |
33 /* Type for the dtv. */ | 45 /* Type for the dtv. */ |
34 typedef union dtv | 46 typedef union dtv |
35 { | 47 { |
36 size_t counter; | 48 size_t counter; |
37 struct | 49 struct |
38 { | 50 { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 THREAD_GETMEM (__pd, header.dtv); }) | 191 THREAD_GETMEM (__pd, header.dtv); }) |
180 #endif | 192 #endif |
181 | 193 |
182 | 194 |
183 /* Return the thread descriptor for the current thread. | 195 /* Return the thread descriptor for the current thread. |
184 | 196 |
185 The contained asm must *not* be marked volatile since otherwise | 197 The contained asm must *not* be marked volatile since otherwise |
186 assignments like | 198 assignments like |
187 pthread_descr self = thread_self(); | 199 pthread_descr self = thread_self(); |
188 do not get optimized away. */ | 200 do not get optimized away. */ |
189 #ifdef __native_client__ | 201 #ifndef __native_client__ |
190 void* __nacl_read_tp (void) __attribute__ ((const)); | |
191 # define THREAD_SELF ((struct pthread *)__nacl_read_tp ()) | |
192 #else | |
193 # define THREAD_SELF \ | 202 # define THREAD_SELF \ |
194 ({ struct pthread *__self; \ | 203 ({ struct pthread *__self; \ |
195 asm ("movq %%fs:%c1,%q0" : "=r" (__self) \ | 204 asm ("movq %%fs:%c1,%q0" : "=r" (__self) \ |
196 : "i" (offsetof (struct pthread, header.self))); \ | 205 : "i" (offsetof (struct pthread, header.self))); \ |
197 __self;}) | 206 __self;}) |
198 #endif | 207 #endif |
199 | 208 |
200 /* Magic for libthread_db to know how to do THREAD_SELF. */ | 209 /* Magic for libthread_db to know how to do THREAD_SELF. */ |
201 # define DB_THREAD_SELF_INCLUDE <sys/reg.h> /* For the FS constant. */ | 210 # define DB_THREAD_SELF_INCLUDE <sys/reg.h> /* For the FS constant. */ |
202 # define DB_THREAD_SELF CONST_THREAD_AREA (64, FS) | 211 # define DB_THREAD_SELF CONST_THREAD_AREA (64, FS) |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 while (0) | 426 while (0) |
418 #endif | 427 #endif |
419 #define THREAD_GSCOPE_SET_FLAG() \ | 428 #define THREAD_GSCOPE_SET_FLAG() \ |
420 THREAD_SETMEM (THREAD_SELF, header.gscope_flag, THREAD_GSCOPE_FLAG_USED) | 429 THREAD_SETMEM (THREAD_SELF, header.gscope_flag, THREAD_GSCOPE_FLAG_USED) |
421 #define THREAD_GSCOPE_WAIT() \ | 430 #define THREAD_GSCOPE_WAIT() \ |
422 GL(dl_wait_lookup_done) () | 431 GL(dl_wait_lookup_done) () |
423 | 432 |
424 #endif /* __ASSEMBLER__ */ | 433 #endif /* __ASSEMBLER__ */ |
425 | 434 |
426 #endif /* tls.h */ | 435 #endif /* tls.h */ |
OLD | NEW |