Changeset 25ee7ec5 in mainline
- Timestamp:
- 2025-03-06T14:35:33Z (3 days ago)
- Children:
- af28af6
- Parents:
- 7064e71
- git-author:
- Matěj Volf <git@…> (2025-03-05 23:13:58)
- git-committer:
- Matěj Volf <git@…> (2025-03-06 14:35:33)
- Location:
- uspace/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/test/fibril/exit_hook.c
r7064e71 r25ee7ec5 36 36 static int value; 37 37 38 static void exit_hook(void) { 39 value = 5; 38 static void exit_hook(void) 39 { 40 value = 5; 40 41 } 41 42 42 static errno_t fibril_basic(void* _arg) { 43 fibril_add_exit_hook(exit_hook); 44 return EOK; 43 static errno_t fibril_basic(void *_arg) 44 { 45 fibril_add_exit_hook(exit_hook); 46 return EOK; 45 47 } 46 48 47 PCUT_TEST(exit_hook_basic) { 48 value = 0; 49 fid_t other = fibril_create(fibril_basic, NULL); 50 fibril_start(other); 49 PCUT_TEST(exit_hook_basic) 50 { 51 value = 0; 52 fid_t other = fibril_create(fibril_basic, NULL); 53 fibril_start(other); 51 54 52 55 fibril_yield(); 53 56 54 57 PCUT_ASSERT_INT_EQUALS(5, value); 55 58 } 56 59 57 60 /* 58 static errno_t fibril_to_be_killed(void* _arg) { 59 fibril_add_exit_hook(exit_hook); 60 61 while (true) 62 firbil_yield(); 63 64 assert(0 && "unreachable"); 65 } 66 67 PCUT_TEST(exit_hook_kill) { 68 value = 0; 69 fid_t other = fibril_create(fibril_to_be_killed, NULL); 70 fibril_start(other); 71 72 fibril_yield(); 73 74 fibril_kill(other); // anything like this doesn't exist yet 75 76 PCUT_ASSERT_INT_EQUALS(5, value); 77 } 78 */ 79 61 * static errno_t fibril_to_be_killed(void* _arg) { 62 * fibril_add_exit_hook(exit_hook); 63 * 64 * while (true) 65 * firbil_yield(); 66 * 67 * assert(0 && "unreachable"); 68 * } 69 * 70 * PCUT_TEST(exit_hook_kill) { 71 * value = 0; 72 * fid_t other = fibril_create(fibril_to_be_killed, NULL); 73 * fibril_start(other); 74 * 75 * fibril_yield(); 76 * 77 * fibril_kill(other); // anything like this doesn't exist yet 78 * 79 * PCUT_ASSERT_INT_EQUALS(5, value); 80 * } 81 */ 80 82 81 83 PCUT_EXPORT(fibril_exit_hook); -
uspace/lib/posix/src/pthread/keys.c
r7064e71 r25ee7ec5 58 58 { 59 59 // initialization is done in setspecific -> if not initialized, nothing was set yet 60 if (!fibril_initialized) return NULL; 60 if (!fibril_initialized) 61 return NULL; 61 62 62 63 assert(key < PTHREAD_KEYS_MAX); … … 67 68 } 68 69 69 static void pthread_key_on_fibril_exit(void) { 70 if (!fibril_initialized) return; 70 static void pthread_key_on_fibril_exit(void) 71 { 72 if (!fibril_initialized) 73 return; 71 74 72 75 for (unsigned i = 0; i < PTHREAD_KEYS_MAX; i++) { … … 78 81 */ 79 82 if (key_data[i] != NULL && destructors[i] != NULL) 80 83 destructors[i](key_data[i]); 81 84 } 82 85 } … … 87 90 DPRINTF("initializing pthread keys\n"); 88 91 errno_t res = fibril_add_exit_hook(pthread_key_on_fibril_exit); 89 if (res != EOK) return res; 92 if (res != EOK) 93 return res; 94 90 95 for (unsigned i = 0; i < PTHREAD_KEYS_MAX; i++) { 91 96 key_data[i] = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.