Changeset 6a57b93 in mainline
- Timestamp:
- 2025-03-05T21:40:21Z (4 days ago)
- Children:
- 5208709
- Parents:
- df2b4ce7
- git-author:
- Matěj Volf <git@…> (2025-01-17 14:14:59)
- git-committer:
- Matěj Volf <git@…> (2025-03-05 21:40:21)
- Location:
- uspace/lib/c
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/private/fibril.h
rdf2b4ce7 r6a57b93 70 70 fibril_owner_info_t *waits_for; 71 71 fibril_event_t *sleep_event; 72 73 list_t exit_hooks; 72 74 }; 75 76 typedef struct { 77 link_t link; 78 void (*func)(void); 79 } fibril_hook_t; 73 80 74 81 extern fibril_t *fibril_alloc(void); -
uspace/lib/c/generic/thread/fibril.c
rdf2b4ce7 r6a57b93 198 198 if (fibril->is_freeable) { 199 199 tls_free(fibril->tcb); 200 list_foreach_safe(fibril->exit_hooks, cur, _next) { 201 fibril_hook_t *hook = list_get_instance(cur, fibril_hook_t, link); 202 free(hook); 203 } 200 204 free(fibril); 201 205 } … … 562 566 fibril->arg = arg; 563 567 568 list_initialize(&fibril->exit_hooks); 569 564 570 context_create_t sctx = { 565 571 .fn = _fibril_main, … … 855 861 (void) retval; 856 862 863 list_foreach(fibril_self()->exit_hooks, link, fibril_hook_t, hook) { 864 hook->func(); 865 } 866 857 867 fibril_t *f = _ready_list_pop_nonblocking(false); 858 868 if (!f) … … 918 928 } 919 929 930 errno_t fibril_add_exit_hook(void (*hook)(void)) 931 { 932 fibril_hook_t *h = malloc(sizeof(fibril_hook_t)); 933 if (!h) 934 return ENOMEM; 935 936 h->func = hook; 937 list_append(&h->link, &fibril_self()->exit_hooks); 938 return EOK; 939 } 940 920 941 errno_t fibril_ipc_wait(ipc_call_t *call, const struct timespec *expires) 921 942 { -
uspace/lib/c/include/fibril.h
rdf2b4ce7 r6a57b93 74 74 extern __noreturn void fibril_exit(long); 75 75 76 /** Add a function to be called after fibril exits, just before it is destroyed */ 77 extern errno_t fibril_add_exit_hook(void (*)(void)); 78 76 79 __HELENOS_DECLS_END; 77 80
Note:
See TracChangeset
for help on using the changeset viewer.