-
Notifications
You must be signed in to change notification settings - Fork 256
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
Clarification for implementing Rust-like enums with values, specifically clockid
#316
Comments
Hi Josh, great questions! First off, I'm sorry that witx docs are lacking - the language and tooling has been evolving, and I've been too busy to write any. The short story is, witx types resemble C more than Rust right now, for historical reasons - the original spec of WASI snapshot 0 was a C header, and we wanted to keep ABI compatibility when we changed the canonical description to be witx. We expect this to evolve when the Interface Types spec and toolchain support lands - many of the same people working on WASI are working on that right now. Witx Witx If you're using the |
Thanks for the detailed information! Is there a place I can contribute the information you mentioned (with an obligatory ASCII chart of the byte layout of course) to the docs somewhere? I'd hate for this information to be buried in a Github issue :P On another note, it seems that |
That is another great question - The subtypes category is a different thing from that concept, the idea there is there will be a type hierarchy (subtyping relationships) between handles, so we can eventaully use the type system to distinguish between directory fds, file fds, stream fds, and so on. That whole aspect of witx and implementations is not fleshed out at all, and probably should not have been added until it was actually going to be used. Not all #define constants got added to the witx spec - I think there's one weird one about dircookie but the As for docs, I think making a markdown file about witx in the |
I submitted some beginner quality PRs to describe the layout of witx types in #318, and to draft a document helping explain file descriptors in #319. I chose to do nothing about the subtypes, since it was just something added early. Closing this issue as further resolutions to this can take place in their respective PRs. |
For the
clockid
enum, it seems to be anEnum(u32)
with four variants. Is theu32
used to represent the value of the clock? The size/alignment is 4, but if the clock reports 4 bytes surely there must be another byte to store the variant? Whilst I understand Rust enums conceptually, to me this doesn't make sense at how I'd implement this in a cross platform manner for other languages. Can this be clarified?The text was updated successfully, but these errors were encountered: