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