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 14static int32 gNextSlot = TLS_FIRST_FREE_SLOT; 15static void *gSlots[TLS_MAX_KEYS]; 16 17 18int32 19tls_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 29void * 30tls_get(int32 index) 31{ 32 return gSlots[index]; 33} 34 35 36void ** 37tls_address(int32 index) 38{ 39 return &gSlots[index]; 40} 41 42 43void 44tls_set(int32 index, void *value) 45{ 46 gSlots[index] = value; 47} 48 49