Changes in uspace/lib/c/generic/tls.c [6adb775f:31399f3] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/tls.c
r6adb775f r31399f3 34 34 * Support for thread-local storage, as described in: 35 35 * Drepper U.: ELF Handling For Thread-Local Storage, 2005 36 */ 36 * 37 * Only static model is supported. 38 */ 37 39 38 40 #include <tls.h> 39 41 #include <malloc.h> 40 42 #include <str.h> 43 #include <align.h> 41 44 #include <unistd.h> 42 45 43 #ifdef CONFIG_RTLD44 #include <rtld/rtld.h>45 #endif46 47 size_t tls_get_size(void)48 {49 return &_tbss_end - &_tdata_start;50 }51 52 46 /** Create TLS (Thread Local Storage) data structures. 47 * 48 * The code requires, that sections .tdata and .tbss are adjacent. It may be 49 * changed in the future. 53 50 * 54 51 * @return Pointer to TCB. … … 59 56 tcb_t *tcb; 60 57 size_t tls_size = &_tbss_end - &_tdata_start; 61 62 #ifdef CONFIG_RTLD 63 if (runtime_env != NULL) 64 return rtld_tls_make(runtime_env); 65 #endif 58 66 59 tcb = tls_alloc_arch(&data, tls_size); 67 60 if (!tcb) 68 61 return NULL; 69 62 70 63 /* 71 64 * Copy thread local data from the initialization image. … … 84 77 { 85 78 size_t tls_size = &_tbss_end - &_tdata_start; 86 87 #ifdef CONFIG_RTLD88 if (runtime_env != NULL)89 tls_size = runtime_env->tls_size;90 #endif91 79 tls_free_arch(tcb, tls_size); 92 80 } … … 133 121 { 134 122 tcb_t *tcb; 135 136 *data = malloc(sizeof(tcb_t) + size); 137 if (*data == NULL) 123 124 size = ALIGN_UP(size, &_tls_alignment); 125 *data = memalign((uintptr_t) &_tls_alignment, sizeof(tcb_t) + size); 126 if (!*data) 138 127 return NULL; 139 128 tcb = (tcb_t *) (*data + size); … … 150 139 void tls_free_variant_2(tcb_t *tcb, size_t size) 151 140 { 141 size = ALIGN_UP(size, &_tls_alignment); 152 142 void *start = ((void *) tcb) - size; 153 143 free(start);
Note:
See TracChangeset
for help on using the changeset viewer.