-
Notifications
You must be signed in to change notification settings - Fork 154
Guest function improvements and macros #851
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
Conversation
c198729 to
3e49309
Compare
3e49309 to
db49f17
Compare
b86709b to
870d40b
Compare
87b2390 to
da5bad6
Compare
ludfjig
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Btw, how does linkme work? xD
da5bad6 to
804f4bf
Compare
Signed-off-by: Jorge Prendes <[email protected]>
Signed-off-by: Jorge Prendes <[email protected]>
Signed-off-by: Jorge Prendes <[email protected]>
Signed-off-by: Jorge Prendes <[email protected]>
Signed-off-by: Jorge Prendes <[email protected]>
Signed-off-by: Jorge Prendes <[email protected]>
…uest-bin Signed-off-by: Jorge Prendes <[email protected]>
Signed-off-by: Jorge Prendes <[email protected]>
Signed-off-by: Jorge Prendes <[email protected]>
804f4bf to
62895b2
Compare
This is the best explanation I found, other than inspecting the source code :-) |
dblnz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Good work Jorge!
I didn't get to look very thoroughly, but overall it looks good
This pull request introduces a new
funcmodule to thehyperlight-commoncrate, which is used to providing newregister_fnfunction for guest function registration:register_fn("function_name", the_function). The traits in thefuncmodule are used to specify and constrain the type ofthe_function.It refactors existing function-related code from
hyperlight_hostintohyperlight_common.This pull request also introduces a new
hyperlight_guest_macrocrate that defines two proc-macros:host_functionandguest_function.host_function: This macro is used to declare host functions in a hyperlight guest. The specified function must have no body (like an ffi function declaration), and the signature is used to create a wrapper for a host function call with the correct types.guest_function: This macros is used to declare guest functions in a hyperlight guest. The function signature is used to create a wrapper that takes care of extracting the arguments from theFunctionCalland serializing the result usinginto_flatbuffer_result. The function is also automatically registered before the call tohyperlight_main, removing the need to do manual registration inhyperlight_main.To enable the automatic registration of functions, the MSRV is bumped to 1.89 (which includes rust-lang/rust#137685, which is required as the automatic registration uses linkme)