Message ID | 1323169274-31657-17-git-send-email-stefanha@linux.vnet.ibm.com |
---|---|
State | New |
Headers | show |
Am 06.12.2011 12:01, schrieb Stefan Hajnoczi: > From: Jan Kiszka <jan.kiszka@siemens.com> > > get_tls() can serve as a lvalue as well, so 'get' might be confusing. Note that this does not work for POSIX pthread_getspecific(), which we'll need to support at some point in time, so I don't think this is a terribly good idea. At least please don't start actually using it as lvalue, we'd need a set_tls() for assignment (in which case get_tls() would've provided nice symmetry). Andreas > > Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> > Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> > --- > cpu-all.h | 2 +- > qemu-tls.h | 4 ++-- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/cpu-all.h b/cpu-all.h > index 7246a67..9d78715 100644 > --- a/cpu-all.h > +++ b/cpu-all.h > @@ -336,7 +336,7 @@ void QEMU_NORETURN cpu_abort(CPUState *env, const char *fmt, ...) > GCC_FMT_ATTR(2, 3); > extern CPUState *first_cpu; > DECLARE_TLS(CPUState *,cpu_single_env); > -#define cpu_single_env get_tls(cpu_single_env) > +#define cpu_single_env tls_var(cpu_single_env) > > /* Flags for use in ENV->INTERRUPT_PENDING. > > diff --git a/qemu-tls.h b/qemu-tls.h > index 5b70f10..b92ea9d 100644 > --- a/qemu-tls.h > +++ b/qemu-tls.h > @@ -41,12 +41,12 @@ > #ifdef __linux__ > #define DECLARE_TLS(type, x) extern DEFINE_TLS(type, x) > #define DEFINE_TLS(type, x) __thread __typeof__(type) tls__##x > -#define get_tls(x) tls__##x > +#define tls_var(x) tls__##x > #else > /* Dummy implementations which define plain global variables */ > #define DECLARE_TLS(type, x) extern DEFINE_TLS(type, x) > #define DEFINE_TLS(type, x) __typeof__(type) tls__##x > -#define get_tls(x) tls__##x > +#define tls_var(x) tls__##x > #endif > > #endif
On 2011-12-06 12:43, Andreas Färber wrote: > Am 06.12.2011 12:01, schrieb Stefan Hajnoczi: >> From: Jan Kiszka <jan.kiszka@siemens.com> >> >> get_tls() can serve as a lvalue as well, so 'get' might be confusing. > > Note that this does not work for POSIX pthread_getspecific(), which > we'll need to support at some point in time, so I don't think this is a > terribly good idea. > > At least please don't start actually using it as lvalue, we'd need a > set_tls() for assignment (in which case get_tls() would've provided nice > symmetry). We already use it like this as TLS is not usable otherwise. I don't mind get/set_tls, I just didn't like current get_tls(x) = bla. Jan
On 12/06/2011 12:43 PM, Andreas Färber wrote: > Am 06.12.2011 12:01, schrieb Stefan Hajnoczi: >> From: Jan Kiszka<jan.kiszka@siemens.com> >> >> get_tls() can serve as a lvalue as well, so 'get' might be confusing. > > Note that this does not work for POSIX pthread_getspecific(), which > we'll need to support at some point in time, so I don't think this is a > terribly good idea. I already posted the code for pthread_getspecific(), but it didn't work on OpenBSD. The idea was to reserve a single pthread key and allocate a whole block of memory. Then get_tls can use pthread_getspecific() and add an offset within the block of memory. The reason is that with many allocated keys pthread_getspecific() becomes slower. Paolo
diff --git a/cpu-all.h b/cpu-all.h index 7246a67..9d78715 100644 --- a/cpu-all.h +++ b/cpu-all.h @@ -336,7 +336,7 @@ void QEMU_NORETURN cpu_abort(CPUState *env, const char *fmt, ...) GCC_FMT_ATTR(2, 3); extern CPUState *first_cpu; DECLARE_TLS(CPUState *,cpu_single_env); -#define cpu_single_env get_tls(cpu_single_env) +#define cpu_single_env tls_var(cpu_single_env) /* Flags for use in ENV->INTERRUPT_PENDING. diff --git a/qemu-tls.h b/qemu-tls.h index 5b70f10..b92ea9d 100644 --- a/qemu-tls.h +++ b/qemu-tls.h @@ -41,12 +41,12 @@ #ifdef __linux__ #define DECLARE_TLS(type, x) extern DEFINE_TLS(type, x) #define DEFINE_TLS(type, x) __thread __typeof__(type) tls__##x -#define get_tls(x) tls__##x +#define tls_var(x) tls__##x #else /* Dummy implementations which define plain global variables */ #define DECLARE_TLS(type, x) extern DEFINE_TLS(type, x) #define DEFINE_TLS(type, x) __typeof__(type) tls__##x -#define get_tls(x) tls__##x +#define tls_var(x) tls__##x #endif #endif