From 5c339b0237387ee8b11dfcd22dc247f6d2c79057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 6 Jan 2003 07:57:10 +0000 Subject: [PATCH] Fixed some issues in TLS.h (i.e. the inline version of tls_address() accidently returned a (void *) instead of a (void **)). Added TLS_MAX_KEYS macro, and a comment. Cleanup. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2359 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/support/TLS.h | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/headers/os/support/TLS.h b/headers/os/support/TLS.h index 27503c1bb4..855897fedd 100644 --- a/headers/os/support/TLS.h +++ b/headers/os/support/TLS.h @@ -1,28 +1,40 @@ #ifndef _TLS_H -#define _TLS_H 1 +#define _TLS_H +/* +** Distributed under the terms of the OpenBeOS License. +*/ #include #include +/* A maximum of 64 keys is allowed to store in TLS - the key is reserved + * process-wide. Note that tls_allocate() will return B_NO_MEMORY if you + * try to exceed this limit. + */ +#define TLS_MAX_KEYS 64 #ifdef __cplusplus extern "C" { #endif -extern _IMPEXP_ROOT int32 tls_allocate(void); +extern int32 tls_allocate(void); -#if __INTEL__ +#if !_NO_INLINE_ASM && __INTEL__ && __GNUC__ -static inline void * tls_get(int32 index) { - void *ret; +static inline void * +tls_get(int32 index) +{ + void *ret; __asm__ __volatile__ ( "movl %%fs:(,%%edx, 4), %%eax \n\t" : "=a"(ret) : "d"(index) ); return ret; } -static inline void * tls_address(int32 index) { - void *ret; +static inline void ** +tls_address(int32 index) +{ + void *ret; __asm__ __volatile__ ( "movl %%fs:0, %%eax \n\t" "leal (%%eax, %%edx, 4), %%eax \n\t" @@ -30,7 +42,9 @@ static inline void * tls_address(int32 index) { return ret; } -static inline void tls_set(int32 index, void *value) { +static inline void +tls_set(int32 index, void *value) +{ __asm__ __volatile__ ( "movl %%eax, %%fs:(,%%edx, 4) \n\t" : : "d"(index), "a"(value) ); @@ -38,9 +52,9 @@ static inline void tls_set(int32 index, void *value) { #else -extern _IMPEXP_ROOT void * tls_get(int32 index); -extern _IMPEXP_ROOT void ** tls_address(int32 index); -extern _IMPEXP_ROOT void tls_set(int32 index, void *value); +extern void *tls_get(int32 index); +extern void **tls_address(int32 index); +extern void tls_set(int32 index, void *value); #endif @@ -48,4 +62,4 @@ extern _IMPEXP_ROOT void tls_set(int32 index, void *value); } #endif -#endif +#endif /* _TLS_H */