Subversion Repositories HelenOS-historic

Rev

Rev 1081 | Rev 1129 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1081 Rev 1113
Line 29... Line 29...
29
#include <thread.h>
29
#include <thread.h>
30
#include <libc.h>
30
#include <libc.h>
31
#include <stdlib.h>
31
#include <stdlib.h>
32
#include <arch/faddr.h>
32
#include <arch/faddr.h>
33
#include <kernel/proc/uarg.h>
33
#include <kernel/proc/uarg.h>
-
 
34
#include <psthread.h>
-
 
35
 
-
 
36
#include <stdio.h>
-
 
37
void * __make_tls(void)
-
 
38
{
-
 
39
    psthread_data_t *pt;
-
 
40
 
-
 
41
    pt = malloc(sizeof(psthread_data_t));
-
 
42
    pt->self = pt;
-
 
43
 
-
 
44
    return pt;
-
 
45
}
-
 
46
 
-
 
47
void __free_tls(void *tls)
-
 
48
{
-
 
49
    free(tls);
-
 
50
}
34
 
51
 
35
/** Main thread function.
52
/** Main thread function.
36
 *
53
 *
37
 * This function is called from __thread_entry() and is used
54
 * This function is called from __thread_entry() and is used
38
 * to call the thread's implementing function and perform cleanup
55
 * to call the thread's implementing function and perform cleanup
39
 * and exit when thread returns back. Do not call this function
56
 * and exit when thread returns back. Do not call this function
40
 * directly.
57
 * directly.
41
 *
58
 *
42
 * @param uarg Pointer to userspace argument structure.
59
 * @param uarg Pointer to userspace argument structure.
43
 */
60
 */
44
void thread_main(uspace_arg_t *uarg)
61
void __thread_main(uspace_arg_t *uarg)
45
{
62
{
-
 
63
    /* This should initialize the area according to TLS specicification */
-
 
64
    __tls_set(__make_tls());
-
 
65
 
46
    uarg->uspace_thread_function(uarg->uspace_thread_arg);
66
    uarg->uspace_thread_function(uarg->uspace_thread_arg);
47
    free(uarg->uspace_stack);
67
    free(uarg->uspace_stack);
48
    free(uarg);
68
    free(uarg);
-
 
69
 
-
 
70
    __free_tls(__tls_get());
-
 
71
 
49
    thread_exit(0);
72
    thread_exit(0);
50
}
73
}
51
 
74
 
52
/** Create userspace thread.
75
/** Create userspace thread.
53
 *
76
 *