xref: /haiku/src/system/libroot/os/arch/sparc/tls.c (revision 4a55cc230cf7566cadcbb23b1928eefff8aea9a2)
1 /*
2 ** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 ** Distributed under the terms of the MIT License.
4 */
5 
6 // ToDo: this is a dummy implementation - I've not yet gained enough knowledge
7 //	to decide how this should be done, so it's just broken now (okay for single
8 //	threaded apps, though).
9 
10 #include "support/TLS.h"
11 #include "tls.h"
12 
13 
14 static int32 gNextSlot = TLS_FIRST_FREE_SLOT;
15 static void *gSlots[TLS_MAX_KEYS];
16 
17 
18 int32
19 tls_allocate(void)
20 {
21 	int32 next = atomic_add(&gNextSlot, 1);
22 	if (next >= TLS_MAX_KEYS)
23 		return B_NO_MEMORY;
24 
25 	return next;
26 }
27 
28 
29 void *
30 tls_get(int32 index)
31 {
32 	return gSlots[index];
33 }
34 
35 
36 void **
37 tls_address(int32 index)
38 {
39 	return &gSlots[index];
40 }
41 
42 
43 void
44 tls_set(int32 index, void *value)
45 {
46 	gSlots[index] = value;
47 }
48 
49