2 * Copyright 2003-2007 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
10 #include <SupportDefs.h>
13 /* A maximum of 64 keys is allowed to store in TLS - the key is reserved
14 * process-wide. Note that tls_allocate() will return B_NO_MEMORY if you
15 * try to exceed this limit.
17 #define TLS_MAX_KEYS 64
22 #endif /* __cplusplus */
24 extern int32
tls_allocate(void);
26 #if !_NO_INLINE_ASM && __INTEL__ && __GNUC__
32 __asm__
__volatile__ (
33 "movl %%fs:(, %1, 4), %0"
34 : "=r" (ret
) : "r" (index
));
39 tls_address(int32 index
)
42 __asm__
__volatile__ (
44 "leal (%0, %1, 4), %0\n\t"
45 : "=&r" (ret
) : "r" (index
));
50 tls_set(int32 index
, void *value
)
52 __asm__
__volatile__ (
53 "movl %1, %%fs:(, %0, 4)"
54 : : "r" (index
), "r" (value
));
57 #else /* !_NO_INLINE_ASM && __INTEL__ && __GNUC__ */
59 extern void *tls_get(int32 index
);
60 extern void **tls_address(int32 index
);
61 extern void tls_set(int32 index
, void *value
);
63 #endif /* !_NO_INLINE_ASM && __INTEL__ && __GNUC__ */
67 #endif /* __cplusplus */