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#warning FIXME: M68K 11 12#include <runtime_loader/runtime_loader.h> 13 14#include "support/TLS.h" 15#include "tls.h" 16 17 18static int32 gNextSlot = TLS_FIRST_FREE_SLOT; 19static void *gSlots[TLS_MAX_KEYS]; 20 21struct tls_index { 22 unsigned long int module; 23 unsigned long int offset; 24}; 25 26void* __tls_get_addr(struct tls_index* ti); 27 28 29int32 30tls_allocate(void) 31{ 32 int32 next = atomic_add(&gNextSlot, 1); 33 if (next >= TLS_MAX_KEYS) 34 return B_NO_MEMORY; 35 36 return next; 37} 38 39 40void * 41tls_get(int32 index) 42{ 43 return gSlots[index]; 44} 45 46 47void ** 48tls_address(int32 index) 49{ 50 return &gSlots[index]; 51} 52 53 54void 55tls_set(int32 index, void *value) 56{ 57 gSlots[index] = value; 58} 59 60void* 61__tls_get_addr(struct tls_index* ti) 62{ 63 return __gRuntimeLoader->get_tls_address(ti->module, ti->offset); 64} 65 66