Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closures: add closure struct definition to closure_type() macro #2006

Merged
merged 1 commit into from
Mar 7, 2024

Conversation

francescolavra
Copy link
Member

With this change, the closure_type() macro includes both a typedef statement and a struct definition; the struct can be used by any basic closure (i.e. a closure without any closure-specific fields in its struct) that uses the type.
This change makes it unnecessary to define a closure struct for each basic closure, and by reusing basic closure structs allows removing several declare_closure_struct() macro invocations. In order to be able to include both a typedef and a struct in the closure_type() macro, the different macros in the closure templates have been changed so that each function parameter in the signature of closure functions is written as <type> <name> (i.e. as a single macro argument) instead of <type>, <name> (i.e. as 2 separate macro arguments).
In order to support the different types of closure instantiations when using a basic closure, 2 new macros have been added: closure_func (for allocating basic closures from a heap) and stack_closure_func (for allocating basic closures on the stack). Various non-basic closures have been replaced with basic closures (embedded in other structs) in different parts of the kernel, which simplifies the code and minimizes the number of allocations and deallocations required when setting up and tearing down the larger structs.

With this change, the closure_type() macro includes both a typedef
statement and a struct definition; the struct can be used by any
basic closure (i.e. a closure without any closure-specific fields
in its struct) that uses the type.
This change makes it unnecessary to define a closure struct for
each basic closure, and by reusing basic closure structs allows
removing several declare_closure_struct() macro invocations.
In order to be able to include both a typedef and a struct in the
closure_type() macro, the different macros in the closure templates
have been changed so that each function parameter in the signature
of closure functions is written as `<type> <name>` (i.e. as a
single macro argument) instead of `<type>, <name>` (i.e. as 2
separate macro arguments).
In order to support the different types of closure instantiations
when using a basic closure, 2 new macros have been added:
closure_func (for allocating basic closures from a heap) and
stack_closure_func (for allocating basic closures on the stack).
Various non-basic closures have been replaced with basic closures
(embedded in other structs) in different parts of the kernel, which
simplifies the code and minimizes the number of allocations and
deallocations required when setting up and tearing down the larger
structs.
@francescolavra francescolavra merged commit 11cbd6f into master Mar 7, 2024
5 checks passed
@francescolavra francescolavra deleted the feature/closure_type branch March 7, 2024 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant