Older NetBSD kernels cannot handle buffers bigger than 256 bytes, and
all FreeBSD and NetBSD kernels only return up to 256 bytes per call.
Signed-off-by: Joe Richey <joerichey@google.com>
Right now "cargo web test" is broken due to upstream changes. We will
disable stdweb tests until the stdweb project fixes things.
See: https://github.com/koute/cargo-web/issues/243
Signed-off-by: Joe Richey <joerichey@google.com>
Add back the "test-in-browser" feature. This makes it easier to manage
a single file containing all of the test code.
Signed-off-by: Joe Richey <joerichey@google.com>
They will be gated behind the "js" feature, as we can now do detect,
at compile-time, which implementation (wasm-bindgen vs stdweb) we
should use.
The "js" implementation takes precedence over the "custom"
implementation. This prevents issues that arise from the buggy way
Cargo handles features across multiple targets.
Signed-off-by: Joe Richey <joerichey@google.com>
Right now, features are always enabled across all targets. This means
that if _any_ Custom RNG is used _anywhere_ in a crate's dependancy
graph on _any_ target. The "custom" feature will be active on all
targets.
This makes it impossible to have a bare metal target that uses "cpu" on
x86_64 and a Custom RNG on aarch64. This solution also makes sure that
any implementation `getrandom` itself provides cannot be overridden.
Signed-off-by: Joe Richey <joerichey@google.com>
Right now, while our implementations for stdweb and wasm-bindgen use
similar APIs, they do not use similar implementations. This change:
- Switches to using the same error codes for both implementations
- Uses error codes that detail exactly what API is missing
- Cleans up the implemetnations to make them much more readable
- Consitantly use thread_local in both implementations
This makes issues easier to debug and the code easier to understand.
Signed-off-by: Joe Richey <joerichey@google.com>
Split emscripten stuff into its own target and stop relying on cargo web
to download/manage then emscripten toolchain. We can just get it
ourselves. We also now run the emscripten tests.
Signed-off-by: Joe Richey <joerichey@google.com>
Split emscripten stuff into its own target and stop relying on cargo web
to download/manage then emscripten toolchain. We can just get it
ourselves. We also now run the emscripten tests.
Signed-off-by: Joe Richey <joerichey@google.com>
- Cleanup .travis.yml
- Loops over std/no_std targets
- Remove deprecated/useless keys
- No more `cd`, we just use `--package`.
- Improve tests
- Main `getrandom` tests are now unit test modules instead of
integration tests, making the code cleaner.
- The custom RNG crates now use this common module as part of their
integration tests.
- No more weird test-only features needed to get the crate to build.
Signed-off-by: Joe Richey <joerichey@google.com>
This feature isn't enabled by rand/rand_core and provides very little
error information that isn't already conveyed through our Error values.
This also simplifies the supported configuration space for getrandom.
We update the docs and CI to match this change.
Don't spin when polling /dev/random. We also remove the use of spin
locks when opening the persistent fd for platforms that require it.
For both these cases, we can just use the pthread lock/unlock methods
in libc. This includes adding Mutex and DropGuard abstractions.
Signed-off-by: Joe Richey <joerichey@google.com>
Right now for each of `util_libc` and `use_file` we have a list of
`target_os` configs to determine if we build the module.
This PR moves these mod declarations into the main `cfg_if` statement
(the one that selects which implementation we use). This way, the mod
statements are kept in-sync with the implementations that use them.
Also, I merged together `target_os` cfgs that have the same
implementation. The downside to this is that the targets are no longer
in alphabetical order.
Also, this is only being applied to `0.2` as the `0.1` cfgs still have
to keep `std` around.