-
Notifications
You must be signed in to change notification settings - Fork 198
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
Use getrandom on FreeBSD #35
Comments
Is there a good reason to add this? If we have to keep the sysctl approach around regardless, it just seems like more maintenance to maintain two equivalent implementations for FreeBSD. |
The sysctl is slower and does not block by itself (as in, it would occasionally return less bytes and your current code would return an error, it must be used in a loop) |
So it looks like the only reason this is true is because the sysctl only allows up to 256 bytes per call, while the getrandom syscall allows very large reads per call. This only seems relevant if we are bottlenecked by the ring transition overhead. Are there any metrics on this?
Good catch, fixed in: #36 Looking at FreeBSD's @myfreeweb to do this we need to add libc related bindings (this was done for Linux in rust-lang/libc#1399). Is there a better way to detect if the syscall is supported? On Linux, this is indicated by the syscall returning ENOSYS, does FreeBSD do something similar? |
Do not call the syscall directly, FreeBSD's public ABI is the libc. Just do what you're doing on Illumos: getrandom/src/solaris_illumos.rs Line 93 in 0b87a09
|
@myfreeweb |
getentropy
in libc usessysctl
only as a fallback and uses thegetrandom
syscall if available.This crate should check for
getrandom
viadlopen
and use it if available.The text was updated successfully, but these errors were encountered: