-
Notifications
You must be signed in to change notification settings - Fork 211
Crate implementation #6
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
I think the global statics design was chosen for two reasons:
I'm not so sure this is a good idea? If the ABI changes, presumably it would be reflected in a new version of those API crates, and thus it'll be more obvious that something needs updating. Also, I suspect most real applications on those platforms would depend on those API libs for something or other anyway, so they'd still be in the build. @erickt @EdSchouten (FYI: this is a re-implementation of BTW did you see this PR? rust-random/rand#709 |
I don't like the fact that with
In the case of Cloud ABI I believe it's safe to rely on ABI stability. Plus pulling less crates will be a plus for potential future inclusion into |
Hello from fuchsia! Thanks for cc'ing me. The code for fuchsia is incorrect, we have since changed the syscall for our cprng Nowadays we recommend using fuchsia-cprng which we plan to keep up to date while we make some bigger changes to the fuchsia-zircon crate. Or you can just copy what we do in fuchsia-cprng, the code is pretty tiny. |
Can you elaborate? (UPD: did you mean Also I wonder what happens with our backward compatibility promise in presence of changing syscalls. For example if in future you will rename syscall and will publish @dhardy |
Probably in this case we should just copy the latest |
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.
Okay, there's a lot here and most of it looks good!
The error type still needs some work. Something minimal like struct Error(u32);
with custom debug and std::error::Error
implementations might be nice?
The WASM implementations can potentially wait until another PR; possibly also changes to the error type.
@newpavlov yeah, if we make a breaking syscall to |
I am not sure... Storing raw error code will allow nice interoperability with Also there is a question of error code for |
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 pretty good, but there are a few reasons the code may have to change yet, so I don't know whether the abstraction is a good fit:
- as you mentioned, we can still avoid repeating some of the checks multiple times via use of
AtomicBool
— this only affects Linux/Android and NetBSD so might be easier to do outside the abstraction - error messages need to be handled more carefully
- we currently have no non-blocking API — though maybe this doesn't matter since most users won't bother with that and those who are concerned can use a dedicated thread
Okay, then I think we're good to merge this (assuming you're not planning on more tweaks)? |
I think I will add |
Note that because we use |
Uh, I don't think there's any need to increment the copyright notice year — the only real purpose of this notice is to make it obvious that there is a copyright notice (I don't think they have any legal function). |
Ah, yes, you are right.
This is why I simply do not include per-file notices in my crates. :) |
@dhardy |
Currently only WASM targets are not migrated. I've introduced some changes to the code, but tested only Linux and SGX, thus crate should be carefully reviewed and tested on all supported platforms before using it for
rand_os
andrand
. Notable changes include:cloudabi
andfuchsia-zircon
is removed in favor of directextern
s.A certain amount of work will be needed to translate
errno
values toError
variants, currently I simply returnError::Unknown
. Ans we will need to create CI config as well.