i8254: convert PIO to new memory api read/write
[qemu/agraf.git] / qemu-tls.h
blobb92ea9d7da30f26964c4814425b8067b3399ec47
1 /*
2 * Abstraction layer for defining and using TLS variables
4 * Copyright (c) 2011 Red Hat, Inc
5 * Copyright (c) 2011 Linaro Limited
7 * Authors:
8 * Paolo Bonzini <pbonzini@redhat.com>
9 * Peter Maydell <peter.maydell@linaro.org>
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, see <http://www.gnu.org/licenses/>.
25 #ifndef QEMU_TLS_H
26 #define QEMU_TLS_H
28 /* Per-thread variables. Note that we only have implementations
29 * which are really thread-local on Linux; the dummy implementations
30 * define plain global variables.
32 * This means that for the moment use should be restricted to
33 * per-VCPU variables, which are OK because:
34 * - the only -user mode supporting multiple VCPU threads is linux-user
35 * - TCG system mode is single-threaded regarding VCPUs
36 * - KVM system mode is multi-threaded but limited to Linux
38 * TODO: proper implementations via Win32 .tls sections and
39 * POSIX pthread_getspecific.
41 #ifdef __linux__
42 #define DECLARE_TLS(type, x) extern DEFINE_TLS(type, x)
43 #define DEFINE_TLS(type, x) __thread __typeof__(type) tls__##x
44 #define tls_var(x) tls__##x
45 #else
46 /* Dummy implementations which define plain global variables */
47 #define DECLARE_TLS(type, x) extern DEFINE_TLS(type, x)
48 #define DEFINE_TLS(type, x) __typeof__(type) tls__##x
49 #define tls_var(x) tls__##x
50 #endif
52 #endif