Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2060 → Rev 2061

/trunk/uspace/libc/generic/thread.c
55,12 → 55,14
extern char _tbss_start;
extern char _tbss_end;
 
/** Create Thread Local storage area, return pointer to TCB(ThreadControlBlock)
/** Create TLS (Thread Local Storage) data structures.
*
* !! The code requires, that sections .tdata and .tbss are adjacent.
* It may be changed in the future.
* The code requires, that sections .tdata and .tbss are adjacent. It may be
* changed in the future.
*
* @return Pointer to TCB.
*/
tcb_t * __make_tls(void)
tcb_t *__make_tls(void)
{
void *data;
tcb_t *tcb;
68,8 → 70,16
tcb = __alloc_tls(&data, tls_size);
/*
* Copy thread local data from the initialization image.
*/
memcpy(data, &_tdata_start, &_tdata_end - &_tdata_start);
memset(data + (&_tbss_start-&_tdata_start), 0, &_tbss_end-&_tbss_start);
/*
* Zero out the thread local uninitialized data.
*/
memset(data + (&_tbss_start - &_tdata_start), 0, &_tbss_end -
&_tbss_start);
 
return tcb;
}
 
87,8 → 97,6
* directly.
*
* @param uarg Pointer to userspace argument structure.
*
* TODO: Thread stack pages memory leak
*/
void __thread_main(uspace_arg_t *uarg)
{
124,7 → 132,7
char *stack;
uspace_arg_t *uarg;
 
stack = (char *) malloc(getpagesize()*THREAD_INITIAL_STACK_PAGES_NO);
stack = (char *) malloc(getpagesize() * THREAD_INITIAL_STACK_PAGES_NO);
if (!stack)
return -1;
/trunk/uspace/libc/arch/sparc64/include/thread.h
33,10 → 33,6
/**
* @file
* @brief sparc64 TLS functions.
*
* The implementation is based on the IA-32 implementation which was also
* designed by Sun and is virtually the same, except the TCB is stored in
* %g7 (of the normal set).
*/
 
#ifndef LIBC_sparc64_THREAD_H_
/trunk/uspace/libc/arch/sparc64/src/thread.c
37,10 → 37,20
#include <thread.h>
#include <malloc.h>
 
/** Allocate TLS & TCB for initial module threads
/*
* 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.
*
* @param data Start of data section
* @return pointer to tcb_t structure
* 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)
{
54,9 → 64,16
return tcb;
}
 
/** 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)
{
void *start = ((void *)tcb) - size;
void *start = ((void *) tcb) - size;
free(start);
}
 
/trunk/uspace/libc/arch/sparc64/src/psthread.S
28,14 → 28,6
 
#include <libarch/context_offset.h>
 
/**
* Both context_save_arch() and context_restore_arch() are
* leaf-optimized procedures. This kind of optimization
* is very important and prevents any implicit window
* spill/fill/clean traps in these very core kernel
* functions.
*/
.text
 
.global context_save