Skip to content
This repository was archived by the owner on Mar 24, 2022. It is now read-only.

Implement the remaining hostcalls#176

Merged
jedisct1 merged 3 commits intomasterfrom
fdenis/moar-hostcalls
May 17, 2019
Merged

Implement the remaining hostcalls#176
jedisct1 merged 3 commits intomasterfrom
fdenis/moar-hostcalls

Conversation

@jedisct1
Copy link
Copy Markdown
Contributor

@jedisct1 jedisct1 commented May 9, 2019

The large hostcalls.rs file becomes a module, split in multiple files.

The hostcalls implementations themselves are not in the macro any more. What is inside the macro is not valid Rust code, RLS cannot do anything with it, neither can rustfmt, so maintaining that code was tedious.

So, implementations are now outside the macro, with the content of the macro being nothing but thin wrappers.

(draft: not tested on Linux yet)
(update: now compatible with Linux)

@acfoltzer
Copy link
Copy Markdown
Contributor

I think we should do this refactoring either way, but if removing the &mut vmctx syntax from the lucet_hostcalls! macro would make rustfmt work, then let's do that as well.

@jedisct1
Copy link
Copy Markdown
Contributor Author

jedisct1 commented May 9, 2019

Unfortunately, removing the &mut vmctx syntax to make it valid Rust doesn't help much.
Everything in the macro is seen as an unstructured blob of text.

But the wrappers are fine. It's actually very convenient to have all of the public definitions in a single file, while having some flexibility for the actual implementations.

@acfoltzer
Copy link
Copy Markdown
Contributor

Gotcha, that's what I thought, which is why I wasn't worrying too much about messing with the syntax. It definitely is a major downside of using this kind of macro. Eventually it'd be nice to make it a proc macro so that we can use attribute syntax instead.

I totally agree about the separation.

@jedisct1
Copy link
Copy Markdown
Contributor Author

jedisct1 commented May 9, 2019

Procedural macros are going to make a lot of things way easier and cleaner.

Looking forward to them being stabilized some day...

@acfoltzer
Copy link
Copy Markdown
Contributor

They are stable, or at least enough of them that we could do this. I just didn't have the time to dig in and do it properly when implementing the macro the first time around.

@jedisct1 jedisct1 force-pushed the fdenis/moar-hostcalls branch 3 times, most recently from 15e5118 to fd06a71 Compare May 9, 2019 21:53
@jedisct1 jedisct1 marked this pull request as ready for review May 9, 2019 22:04
@jedisct1 jedisct1 force-pushed the fdenis/moar-hostcalls branch from fd06a71 to 71f371c Compare May 10, 2019 07:29
@sunfishcode
Copy link
Copy Markdown
Member

I've only made a brief skim through the code here, but it looks good to me as a base to build on!

@jedisct1
Copy link
Copy Markdown
Contributor Author

Thanks a ton for your review, Dan!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants