Changeset 88cbc66 in mainline for uspace/lib/c/generic/thread/fibril.c


Ignore:
Timestamp:
2025-03-08T16:41:12Z (29 hours ago)
Author:
GitHub <noreply@…>
Parents:
797ab95 (diff), af28af6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Matěj Volf <mat.volfik@…> (2025-03-08 16:41:12)
git-committer:
GitHub <noreply@…> (2025-03-08 16:41:12)
Message:

Merge af28af66b2f75b653b814d95c7e3b93389a559e6 into 797ab957fc37b27462c54f0c3a7520af8a33e233

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/thread/fibril.c

    r797ab95 r88cbc66  
    185185void fibril_setup(fibril_t *f)
    186186{
     187        list_initialize(&f->exit_hooks);
    187188        futex_lock(&fibril_futex);
    188189        list_append(&f->all_link, &fibril_list);
     
    845846}
    846847
     848void fibril_run_exit_hooks(fibril_t *f)
     849{
     850        list_foreach_safe(f->exit_hooks, cur, _next) {
     851                fibril_hook_t *hook = list_get_instance(cur, fibril_hook_t, link);
     852                list_remove(cur);
     853                hook->func();
     854                free(hook);
     855        }
     856}
     857
    847858/**
    848859 * Exit a fibril. Never returns.
     
    854865        // TODO: implement fibril_join() and remember retval
    855866        (void) retval;
     867
     868        fibril_run_exit_hooks(fibril_self());
    856869
    857870        fibril_t *f = _ready_list_pop_nonblocking(false);
     
    918931}
    919932
     933errno_t fibril_add_exit_hook(void (*hook)(void))
     934{
     935        fibril_hook_t *h = malloc(sizeof(fibril_hook_t));
     936        if (!h)
     937                return ENOMEM;
     938
     939        DPRINTF("adding exit hook: function %p (fibril_hook_t structure at %p)\n", hook, h);
     940
     941        h->func = hook;
     942        list_append(&h->link, &fibril_self()->exit_hooks);
     943        return EOK;
     944}
     945
    920946errno_t fibril_ipc_wait(ipc_call_t *call, const struct timespec *expires)
    921947{
Note: See TracChangeset for help on using the changeset viewer.