Changes in / [c8680be4:0ae9e18] in mainline
- Location:
- uspace/lib
- Files:
-
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/libc.c
rc8680be4 r0ae9e18 81 81 main_fibril.tcb = tls_make_initial(__progsymbols.elfstart); 82 82 } 83 main_fibril.is_freeable = false;84 83 85 84 assert(main_fibril.tcb); -
uspace/lib/c/generic/rtld/symbol.c
rc8680be4 r0ae9e18 65 65 static elf_symbol_t *def_find_in_module(const char *name, module_t *m) 66 66 { 67 if (m->dyn.hash == NULL) {68 /* No hash table */69 return NULL;70 }71 72 67 elf_symbol_t *sym_table; 73 68 elf_symbol_t *s, *sym; -
uspace/lib/posix/meson.build
rc8680be4 r0ae9e18 30 30 includes += include_directories('include/posix', 'include') 31 31 c_args += [ '-fno-builtin', '-D_XOPEN_SOURCE' ] 32 allow_shared = true33 32 34 33 # TODO … … 62 61 'test/stdlib.c', 63 62 'test/unistd.c', 64 'test/pthread/keys.c',65 63 ) 66 64 -
uspace/lib/posix/src/pthread/keys.c
rc8680be4 r0ae9e18 36 36 #include <pthread.h> 37 37 #include <errno.h> 38 #include <fibril.h>39 #include <stdatomic.h>40 38 #include "../internal/common.h" 41 42 #include <stdio.h>43 #define DPRINTF(format, ...) ((void) 0);44 45 static fibril_local bool fibril_initialized = false;46 static atomic_ushort next_key = 1; // skip the key 'zero'47 48 /*49 * For now, we just support maximum of 100 keys. This can be improved50 * in the future by implementing a dynamically growing array with51 * reallocations, but that will require more synchronization.52 */53 #define PTHREAD_KEYS_MAX 10054 55 static fibril_local void *key_data[PTHREAD_KEYS_MAX];56 39 57 40 void *pthread_getspecific(pthread_key_t key) 58 41 { 59 // initialization is done in setspecific -> if not initialized, nothing was set yet 60 if (!fibril_initialized) { 61 DPRINTF("pthread_getspecific(%d) = NULL (uninitialized)\n", key); 62 return NULL; 63 } 64 65 assert(key < PTHREAD_KEYS_MAX); 66 assert(key < next_key); 67 assert(key > 0); 68 69 DPRINTF("pthread_getspecific(%d) = %p\n", key, key_data[key]); 70 return key_data[key]; 42 not_implemented(); 43 return NULL; 71 44 } 72 45 73 46 int pthread_setspecific(pthread_key_t key, const void *data) 74 47 { 75 DPRINTF("pthread_setspecific(%d, %p)\n", key, data); 76 if (!fibril_initialized) { 77 DPRINTF("initializing pthread keys\n"); 78 for (unsigned i = 0; i < PTHREAD_KEYS_MAX; i++) { 79 key_data[i] = NULL; 80 } 81 fibril_initialized = true; 82 } 83 assert(key < PTHREAD_KEYS_MAX); 84 assert(key < next_key); 85 assert(key > 0); 86 87 key_data[key] = (void *) data; 88 return EOK; 48 not_implemented(); 49 return ENOTSUP; 89 50 } 90 51 91 52 int pthread_key_delete(pthread_key_t key) 92 53 { 93 // see https://github.com/HelenOS/helenos/pull/245#issuecomment-270679584894 54 not_implemented(); 95 return E OK;55 return ENOTSUP; 96 56 } 97 57 98 58 int pthread_key_create(pthread_key_t *key, void (*destructor)(void *)) 99 59 { 100 unsigned short k = atomic_fetch_add(&next_key, 1); 101 DPRINTF("pthread_key_create(%p, %p) = %d\n", key, destructor, k); 102 if (k >= PTHREAD_KEYS_MAX) { 103 atomic_store(&next_key, PTHREAD_KEYS_MAX + 1); 104 return ELIMIT; 105 } 106 if (destructor != NULL) { 107 static int __counter = 0; 108 if (__counter == 0) { 109 fprintf(stderr, "pthread_key_create: destructors not supported\n"); 110 } 111 __counter++; 112 } 113 114 *key = k; 115 return EOK; 60 not_implemented(); 61 return ENOTSUP; 116 62 } 117 63 -
uspace/lib/posix/test/main.c
rc8680be4 r0ae9e18 34 34 PCUT_IMPORT(stdlib); 35 35 PCUT_IMPORT(unistd); 36 PCUT_IMPORT(pthread_keys);37 36 38 37 PCUT_MAIN();
Note:
See TracChangeset
for help on using the changeset viewer.