Followup to #331, we don't need the condidtional compilation anymore,
because this file is only used if
`any(target_os = "freebsd", target_os = "netbsd")` anyway.
Also cleans up `use` statements and type declarations to look like those
in macos.rs
Signed-off-by: Joe Richey <joerichey@google.com>
NetBSD supports the getrandom system call since version 10.0 [1].
Use it if available, otherwise fall back to kern.arandom like on FreeBSD.
[1] https://man.netbsd.org/getrandom.2
glibc is providing open64 and other lfs64 functions but musl aliases
them to normal equivalents since off_t is always 64-bit on musl,
therefore check for target env along when target OS is linux before
using open64, this is more available. Latest Musl has made these
namespace changes [1]
There is no need for using LFS64 open explicitly as we are only using it
for opening device files and not real files
[1] https://git.musl-libc.org/cgit/musl/commit/?id=246f1c811448f37a44b41cd8df8d0ef9736d95f4
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
The upgrade to macOS 12 broke this iOS simulator CI (as support for the
iPhone 7 was dropped I think).
We should have a follow up PR to see if we can just test against a more
recent iPhone.
Signed-off-by: Joe Richey <joerichey@google.com>
This builds, links, and runs the tests on `x86_64-apple-ios` using
[`dinghy`](https://github.com/sonos/dinghy). It moves the targets
which only Build/Link to their own job.
Signed-off-by: Joe Richey <joerichey@google.com>
The current action we are using is unmantained:
https://github.com/actions-rs/toolchain/issues/216
This replacement is faster, smaller, and more cachable.
We can also completely remove the toolchain step when testing with
cross, as cross handles configuration of its own toolchain.
Signed-off-by: Joe Richey <joerichey@google.com>
We can build and link just fine, but we cannot actually run the tests as
`wasm-bindgen-test-runner` hasn't yet added support.
Signed-off-by: Joe Richey <joerichey@google.com>
* Cleanup wasm32-wasi target
This change ensures that we only compile our WASI implementation for
32-bit targets. The interaction between the WASI proposal and the
memory64 proposal is not yet clear, [wasmtime does not yet support](
https://github.com/bytecodealliance/wasmtime/issues/3594#issuecomment-992590383)
using WASI with memory64, and many of the interfaces use 32-bit values
for pointers.
This change also reduces the use of `unsafe` from the wasi
implementation. As noted in #253, changes to `Errno` mean that we can't
get the error message from the raw error code, but we can avoid using
unsafe when converting this code to a NonZeroU32. This handling also
makes WASI behave more like our other targets, which also manually check
that errno is non-zero.
Signed-off-by: Joe Richey <joerichey@google.com>
* Disable default features for WASI crate
Similar to this crate, the `wasi` crate just uses a `std` feature to
implement `std::error::Errno`, which we don't use.
Signed-off-by: Joe Richey <joerichey@google.com>
Signed-off-by: Joe Richey <joerichey@google.com>
This PR adds some tests which make sure calls to getrandom (for both small and large buffers) "look" random.
While we could certainly add more complicated randomness tests, these simple tests are:
- Very easy to understand
- Don't require any external crates
- Makes sure we aren't doing something obviously stupid like
- forgetting [these lines](bd0654fe70/src/rdrand.rs (L91-L95))
- failing to initialize every other byte
- initializing some significant fraction of bytes with a constant
As this tests all buffer sizes from 1 to 64, it also fixes#290.