~jsvoboda/helenos/dnsr

« back to all changes in this revision

Viewing changes to uspace/lib/c/generic/tls.c

  • Committer: Jiri Svoboda
  • Date: 2012-11-11 21:31:03 UTC
  • mfrom: (1527.1.178 mainline)
  • Revision ID: jiri@wiwaxia-20121111213103-314bmkettwvlwj97
MergeĀ mainlineĀ changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
#include <malloc.h>
42
42
#include <str.h>
43
43
#include <align.h>
 
44
#include <unistd.h>
44
45
 
45
46
/** Create TLS (Thread Local Storage) data structures.
46
47
 *
56
57
        size_t tls_size = &_tbss_end - &_tdata_start;
57
58
        
58
59
        tcb = __alloc_tls(&data, tls_size);
 
60
        if (!tcb)
 
61
                return NULL;
59
62
        
60
63
        /*
61
64
         * Copy thread local data from the initialization image.
88
91
        tcb_t *result;
89
92
 
90
93
        result = malloc(sizeof(tcb_t) + size);
 
94
        if (!result)
 
95
                return NULL;
91
96
        *data = ((void *)result) + sizeof(tcb_t);
 
97
 
92
98
        return result;
93
99
}
94
100
 
117
123
        
118
124
        size = ALIGN_UP(size, &_tls_alignment);
119
125
        *data = memalign((uintptr_t) &_tls_alignment, sizeof(tcb_t) + size);
120
 
 
 
126
        if (!*data)
 
127
                return NULL;
121
128
        tcb = (tcb_t *) (*data + size);
122
129
        tcb->self = tcb;
123
130