Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2581 → Rev 2586

/trunk/uspace/lib/libc/arch/sparc64/src/tls.c/thread.c
34,50 → 34,17
*
*/
 
#include <thread.h>
#include <malloc.h>
#include <align.h>
#include <tls.h>
#include <sys/types.h>
 
/*
* sparc64 uses thread-local storage data structures, variant II, as described
* in:
* Drepper U.: ELF Handling For Thread-Local Storage, 2005
*/
 
/** Allocate TLS variant II data structures for a thread.
*
* Only static model is supported.
*
* @param data Pointer to pointer to thread local data. This is actually an
* output argument.
* @param size Size of thread local data.
* @return Pointer to TCB structure.
*/
tcb_t * __alloc_tls(void **data, size_t size)
{
tcb_t *tcb;
size = ALIGN_UP(size, &_tls_alignment);
*data = memalign(&_tls_alignment, sizeof(tcb_t) + size);
 
tcb = (tcb_t *) (*data + size);
tcb->self = tcb;
 
return tcb;
return tls_alloc_variant_2(data, size);
}
 
/** Free TLS variant II data structures of a thread.
*
* Only static model is supported.
*
* @param tcb Pointer to TCB structure.
* @param size Size of thread local data.
*/
void __free_tls_arch(tcb_t *tcb, size_t size)
{
size = ALIGN_UP(size, &_tls_alignment);
void *start = ((void *) tcb) - size;
free(start);
tls_free_variant_2(tcb, size);
}
 
/** @}