Uh oh!
There was an error while loading. Please reload this page.
Remove libstd dependancy for Opening and Reading files - #58
Conversation
116738a to
1426f2eComparebriansmith
commented
Jul 11, 2019
As you can read in the linked ring issue, I made so such suggestion. |
josephlr
commented
Jul 11, 2019
Whoops sorry about that, meant to say you pointed out the libsodium implementation, changed to be more accurate. |
dhardy
commented
Jul 27, 2019
I guess it's time for a rebase — however I believe the only motivation is rust-lang/rust#62082, thus ideally this should wait on a decision whether we should go ahead with that (except that decision may depend on the existence of a viable PR...) |
@dhardy I rebased this PR, and the CI is passing. I agree that if we don't do rust-lang/rust#62082, we should not merge this PR. |
Uh oh!
There was an error while loading. Please reload this page.
You also have to disable default features for |
josephlr
commented
Jul 29, 2019
Done |
Uh oh!
There was an error while loading. Please reload this page.
josephlr
commented
Jul 31, 2019
As rust-lang/rust#62516 might take awhile to reslove. I just added in the RHEL 5 compat code. It only takes 2 lines. |
newpavlov
commented
Aug 5, 2019
So I think we can merge this without waiting for decision regarding rust-lang/rust#62082, if |
josephlr
commented
Aug 5, 2019
I slightly changed the
Sounds reasonable to me. |
newpavlov
commented
Aug 5, 2019
Can you also update the table in |
josephlr
commented
Aug 5, 2019
Done, I also fixed up the |
newpavlov
commented
Aug 5, 2019
I think you can simplify the loop even further like this: let ret = loop{// A negative timeout means an infinite timeout.let res = unsafe{ libc::poll(&mut pfd,1, -1)};if res == 1{breakunsafe{open_readonly("/dev/urandom\0")};}elseif res < 0{let e = last_os_error().raw_os_error();if e == Some(libc::EINTR) || e == Some(libc::EAGAIN){continue;}}breakNone;};unsafe{ libc::close(pfd.fd)};
ret |
josephlr
commented
Aug 5, 2019
Done. I totally forgot that rust loops can return a value. |
| ))] | ||
| // std-only trait definitions | ||
| #[cfg(feature = "std")] | ||
| mod error_impls; |
There was a problem hiding this comment.
What happens in this case when the getrandom crate is used both by std and by other crates wanting std features?
There was a problem hiding this comment.
IIUC right now getrandom will be compiled into std, so enabling features for it during usual builds will not influence the copy of the crate used by std. Although I am not sure how it will work with rust-lang/rfcs#2663.
dhardy
commented
Aug 6, 2019
There may not be another way to go about this, so fair enough. |
josephlr
commented
Aug 6, 2019
@newpavlov if we're going with the build script approach in #69, do we still want to wait on that PR before merging this one? |
newpavlov
commented
Aug 6, 2019
No, I think we can merge it right away. |
RalfJung
commented
Aug 27, 2019
Wasn't the plan to use this crate in libstd? Rust officially supports Linux 2.6.18+. |
mati865
commented
Aug 27, 2019
Description was not updated to reflect #58 (comment) |
Depends on #54 so only look at the last commit if you want to just review this PR.
This PR removes the last part of
libstdwe were depending on (when not using thestdfeature). Specifically:libc::open(path.as_ptr(), libc::O_RDONLY | libc::O_CLOEXEC)libc::O_CLOEXEC(kernel < 2.6.22)/dev/randomwe nowpoll(2)on the/dev/randomfile descriptor/dev/urandomis safe/dev/random/dev/urandomhas been seeded before using it. briansmith/ring#558