]>
Commit | Line | Data |
---|---|---|
c2afe833 RM |
1 | /* libc-internal interface for thread-specific data. Stub or TLS version. |
2 | Copyright (C) 1998,2001,02 Free Software Foundation, Inc. | |
348ed515 UD |
3 | This file is part of the GNU C Library. |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
348ed515 UD |
9 | |
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 | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
348ed515 | 14 | |
41bdb6e2 AJ |
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 | |
17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
18 | 02111-1307 USA. */ | |
348ed515 | 19 | |
c2afe833 RM |
20 | #ifndef _GENERIC_BITS_LIBC_TSD_H |
21 | #define _GENERIC_BITS_LIBC_TSD_H 1 | |
348ed515 UD |
22 | |
23 | /* This file defines the following macros for accessing a small fixed | |
24 | set of thread-specific `void *' data used only internally by libc. | |
25 | ||
26 | __libc_tsd_define(CLASS, KEY) -- Define or declare a `void *' datum | |
27 | for KEY. CLASS can be `static' for | |
28 | keys used in only one source file, | |
29 | empty for global definitions, or | |
30 | `extern' for global declarations. | |
cf684340 RM |
31 | __libc_tsd_address(KEY) -- Return the `void **' pointing to |
32 | the current thread's datum for KEY. | |
348ed515 UD |
33 | __libc_tsd_get(KEY) -- Return the `void *' datum for KEY. |
34 | __libc_tsd_set(KEY, VALUE) -- Set the datum for KEY to VALUE. | |
35 | ||
36 | The set of available KEY's will usually be provided as an enum, | |
37 | and contains (at least): | |
38 | _LIBC_TSD_KEY_MALLOC | |
39 | _LIBC_TSD_KEY_DL_ERROR | |
f1e4a4a4 | 40 | _LIBC_TSD_KEY_RPC_VARS |
348ed515 UD |
41 | All uses must be the literal _LIBC_TSD_* name in the __libc_tsd_* macros. |
42 | Some implementations may not provide any enum at all and instead | |
43 | using string pasting in the macros. */ | |
44 | ||
c2afe833 | 45 | #include <tls.h> |
348ed515 | 46 | |
c2afe833 RM |
47 | /* When full support for __thread variables is available, this interface is |
48 | just a trivial wrapper for it. Without TLS, this is the generic/stub | |
49 | implementation for wholly single-threaded systems. | |
348ed515 | 50 | |
c2afe833 RM |
51 | We don't define an enum for the possible key values, because the KEYs |
52 | translate directly into variables by macro magic. */ | |
53 | ||
54 | #if USE_TLS && HAVE___THREAD | |
55 | # define __libc_tsd_define(CLASS, KEY) CLASS __thread void *__libc_tsd_##KEY; | |
b50f3877 | 56 | |
cf684340 | 57 | # define __libc_tsd_address(KEY) (&__libc_tsd_##KEY) |
b50f3877 UD |
58 | # define __libc_tsd_get(KEY) (__libc_tsd_##KEY) |
59 | # define __libc_tsd_set(KEY, VALUE) (__libc_tsd_##KEY = (VALUE)) | |
c2afe833 | 60 | #else |
b50f3877 | 61 | # define __libc_tsd_define(CLASS, KEY) CLASS void *__libc_tsd_##KEY##_data; |
c2afe833 | 62 | |
cf684340 | 63 | # define __libc_tsd_address(KEY) (&__libc_tsd_##KEY) |
b50f3877 UD |
64 | # define __libc_tsd_get(KEY) (__libc_tsd_##KEY##_data) |
65 | # define __libc_tsd_set(KEY, VALUE) (__libc_tsd_##KEY##_data = (VALUE)) | |
66 | #endif | |
348ed515 UD |
67 | |
68 | #endif /* bits/libc-tsd.h */ |