Rev 2581 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2581 | Rev 2586 | ||
---|---|---|---|
Line 32... | Line 32... | ||
32 | */ |
32 | */ |
33 | /** @file |
33 | /** @file |
34 | * @ingroup libcia32 |
34 | * @ingroup libcia32 |
35 | */ |
35 | */ |
36 | 36 | ||
37 | #include <thread.h> |
37 | #include <tls.h> |
38 | #include <malloc.h> |
38 | #include <sys/types.h> |
39 | #include <align.h> |
- | |
40 | 39 | ||
41 | /** Allocate TLS & TCB for initial module threads |
- | |
42 | * |
- | |
43 | * @param data Start of data section |
- | |
44 | * @return pointer to tcb_t structure |
- | |
45 | */ |
- | |
46 | tcb_t * __alloc_tls(void **data, size_t size) |
40 | tcb_t * __alloc_tls(void **data, size_t size) |
47 | { |
41 | { |
48 | tcb_t *tcb; |
- | |
49 | - | ||
50 | size = ALIGN_UP(size, &_tls_alignment); |
- | |
51 | *data = memalign(&_tls_alignment, sizeof(tcb_t) + size); |
- | |
52 | - | ||
53 | tcb = (tcb_t *) (*data + size); |
42 | return tls_alloc_variant_2(data, size); |
54 | tcb->self = tcb; |
- | |
55 | - | ||
56 | return tcb; |
- | |
57 | } |
43 | } |
58 | 44 | ||
59 | void __free_tls_arch(tcb_t *tcb, size_t size) |
45 | void __free_tls_arch(tcb_t *tcb, size_t size) |
60 | { |
46 | { |
61 | size = ALIGN_UP(size, &_tls_alignment); |
- | |
62 | void *start = ((void *)tcb) - size; |
47 | tls_free_variant_2(tcb, size); |
63 | free(start); |
- | |
64 | } |
48 | } |
65 | 49 | ||
66 | /** @} |
50 | /** @} |
67 | */ |
51 | */ |