1/* 2** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. 3** Distributed under the terms of the OpenBeOS 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// we don't want to have the inline assembly included here 11#ifndef _NO_INLINE_ASM 12# define _NO_INLINE_ASM 1 13#endif 14 15#include "support/TLS.h" 16#include "tls.h" 17 18 19static int32 gNextSlot = TLS_FIRST_FREE_SLOT; 20static void *gSlots[TLS_MAX_KEYS]; 21 22 23int32 24tls_allocate(void) 25{ 26 int32 next = atomic_add(&gNextSlot, 1); 27 if (next >= TLS_MAX_KEYS) 28 return B_NO_MEMORY; 29 30 return next; 31} 32 33 34void * 35tls_get(int32 index) 36{ 37 return gSlots[index]; 38} 39 40 41void ** 42tls_address(int32 index) 43{ 44 return &gSlots[index]; 45} 46 47 48void 49tls_set(int32 index, void *value) 50{ 51 gSlots[index] = value; 52} 53 54