OLD | NEW |
1 /* Definition for thread-local data handling. nptl/i386 version. | 1 /* Definition for thread-local data handling. nptl/i386 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 #include <dl-sysdep.h> | 23 #include <dl-sysdep.h> |
24 #ifndef __ASSEMBLER__ | 24 #ifndef __ASSEMBLER__ |
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 # include <list.h> | 29 # include <list.h> |
| 30 /* Return the thread descriptor for the current thread. |
| 31 |
| 32 The contained asm must *not* be marked volatile since otherwise |
| 33 assignments like |
| 34 pthread_descr self = thread_self(); |
| 35 do not get optimized away. |
| 36 |
| 37 We need it before sysdep.h in NaCl for INTERNAL_SYSCALL_gettid_0. */ |
| 38 # ifdef __native_client__ |
| 39 # define THREAD_SELF \ |
| 40 ({ struct pthread *__self; \ |
| 41 asm ("movl %%gs:0,%0" : "=r" (__self)); \ |
| 42 __self; }) |
| 43 #endif |
30 # include <sysdep.h> | 44 # include <sysdep.h> |
31 # include <kernel-features.h> | 45 # include <kernel-features.h> |
32 | 46 |
33 | 47 |
34 /* Type for the dtv. */ | 48 /* Type for the dtv. */ |
35 typedef union dtv | 49 typedef union dtv |
36 { | 50 { |
37 size_t counter; | 51 size_t counter; |
38 struct | 52 struct |
39 { | 53 { |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 # define THREAD_DTV() \ | 229 # define THREAD_DTV() \ |
216 THREAD_GETMEM (THREAD_SELF, header.dtv) | 230 THREAD_GETMEM (THREAD_SELF, header.dtv) |
217 | 231 |
218 | 232 |
219 /* Return the thread descriptor for the current thread. | 233 /* Return the thread descriptor for the current thread. |
220 | 234 |
221 The contained asm must *not* be marked volatile since otherwise | 235 The contained asm must *not* be marked volatile since otherwise |
222 assignments like | 236 assignments like |
223 pthread_descr self = thread_self(); | 237 pthread_descr self = thread_self(); |
224 do not get optimized away. */ | 238 do not get optimized away. */ |
225 # ifdef __native_client__ | 239 #ifndef __native_client__ |
226 # define THREAD_SELF» » » » » » » \ | |
227 ({ struct pthread *__self;» » » » » » \ | |
228 asm ("movl %%gs:0,%0" : "=r" (__self));» » » » \ | |
229 __self; }) | |
230 # else | |
231 # define THREAD_SELF \ | 240 # define THREAD_SELF \ |
232 ({ struct pthread *__self; \ | 241 ({ struct pthread *__self; \ |
233 asm ("movl %%gs:%c1,%0" : "=r" (__self) \ | 242 asm ("movl %%gs:%c1,%0" : "=r" (__self) \ |
234 : "i" (offsetof (struct pthread, header.self))); \ | 243 : "i" (offsetof (struct pthread, header.self))); \ |
235 __self;}) | 244 __self;}) |
236 #endif | 245 #endif |
237 | 246 |
238 /* Magic for libthread_db to know how to do THREAD_SELF. */ | 247 /* Magic for libthread_db to know how to do THREAD_SELF. */ |
239 # define DB_THREAD_SELF \ | 248 # define DB_THREAD_SELF \ |
240 REGISTER_THREAD_AREA (32, offsetof (struct user_regs_struct, xgs), 3) \ | 249 REGISTER_THREAD_AREA (32, offsetof (struct user_regs_struct, xgs), 3) \ |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 } \ | 454 } \ |
446 while (0) | 455 while (0) |
447 #define THREAD_GSCOPE_SET_FLAG() \ | 456 #define THREAD_GSCOPE_SET_FLAG() \ |
448 THREAD_SETMEM (THREAD_SELF, header.gscope_flag, THREAD_GSCOPE_FLAG_USED) | 457 THREAD_SETMEM (THREAD_SELF, header.gscope_flag, THREAD_GSCOPE_FLAG_USED) |
449 #define THREAD_GSCOPE_WAIT() \ | 458 #define THREAD_GSCOPE_WAIT() \ |
450 GL(dl_wait_lookup_done) () | 459 GL(dl_wait_lookup_done) () |
451 | 460 |
452 #endif /* __ASSEMBLER__ */ | 461 #endif /* __ASSEMBLER__ */ |
453 | 462 |
454 #endif /* tls.h */ | 463 #endif /* tls.h */ |
OLD | NEW |