]>
Commit | Line | Data |
---|---|---|
c2afe833 | 1 | /* libc-internal interface for thread-specific data. Stub or TLS version. |
b168057a | 2 | Copyright (C) 1998-2015 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 | 15 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
16 | License along with the GNU C Library; if not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
348ed515 | 18 | |
c2afe833 RM |
19 | #ifndef _GENERIC_BITS_LIBC_TSD_H |
20 | #define _GENERIC_BITS_LIBC_TSD_H 1 | |
348ed515 UD |
21 | |
22 | /* This file defines the following macros for accessing a small fixed | |
23 | set of thread-specific `void *' data used only internally by libc. | |
24 | ||
4b23f9bd | 25 | __libc_tsd_define(CLASS, TYPE, KEY) -- Define or declare a datum with TYPE |
d063d164 | 26 | for KEY. CLASS can be `static' for |
348ed515 UD |
27 | keys used in only one source file, |
28 | empty for global definitions, or | |
29 | `extern' for global declarations. | |
4b23f9bd | 30 | __libc_tsd_address(TYPE, KEY) -- Return the `TYPE *' pointing to |
d063d164 | 31 | the current thread's datum for KEY. |
4b23f9bd JJ |
32 | __libc_tsd_get(TYPE, KEY) -- Return the `TYPE' datum for KEY. |
33 | __libc_tsd_set(TYPE, KEY, VALUE) -- Set the datum for KEY to VALUE. | |
348ed515 UD |
34 | |
35 | The set of available KEY's will usually be provided as an enum, | |
36 | and contains (at least): | |
37 | _LIBC_TSD_KEY_MALLOC | |
38 | _LIBC_TSD_KEY_DL_ERROR | |
f1e4a4a4 | 39 | _LIBC_TSD_KEY_RPC_VARS |
348ed515 UD |
40 | All uses must be the literal _LIBC_TSD_* name in the __libc_tsd_* macros. |
41 | Some implementations may not provide any enum at all and instead | |
42 | using string pasting in the macros. */ | |
43 | ||
c2afe833 | 44 | #include <tls.h> |
348ed515 | 45 | |
c2afe833 RM |
46 | /* When full support for __thread variables is available, this interface is |
47 | just a trivial wrapper for it. Without TLS, this is the generic/stub | |
48 | implementation for wholly single-threaded systems. | |
348ed515 | 49 | |
c2afe833 RM |
50 | We don't define an enum for the possible key values, because the KEYs |
51 | translate directly into variables by macro magic. */ | |
52 | ||
d063d164 | 53 | #define __libc_tsd_define(CLASS, TYPE, KEY) \ |
4b23f9bd | 54 | CLASS __thread TYPE __libc_tsd_##KEY attribute_tls_model_ie; |
b50f3877 | 55 | |
d063d164 UD |
56 | #define __libc_tsd_address(TYPE, KEY) (&__libc_tsd_##KEY) |
57 | #define __libc_tsd_get(TYPE, KEY) (__libc_tsd_##KEY) | |
58 | #define __libc_tsd_set(TYPE, KEY, VALUE) (__libc_tsd_##KEY = (VALUE)) | |
348ed515 UD |
59 | |
60 | #endif /* bits/libc-tsd.h */ |