Skip to content
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

Add VxWorks support #86

Merged
merged 14 commits into from
Oct 23, 2019
6 changes: 3 additions & 3 deletions src/vxworks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ use crate::error::{Error, ERRNO_NOT_POSITIVE};
use core::num::NonZeroU32;

extern "C" {
fn randBytes (buf: *mut u8, length: i32) -> i32;
fn randBytes(buf: *mut u8, length: i32) -> i32;
newpavlov marked this conversation as resolved.
Show resolved Hide resolved
// errnoLib.h
fn errnoGet() -> i32;
}

pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
// Prevent overflow of i32
for chunk in dest.chunks_mut(i32::max_value() as usize) {
let ret = randBytes(chunk.as_mut_ptr(), chunk.len() as i32);
let ret = unsafe { randBytes(chunk.as_mut_ptr(), chunk.len() as i32) };
if ret == -1 {
newpavlov marked this conversation as resolved.
Show resolved Hide resolved
let errno = errnoGet();
let errno = unsafe { errnoGet() };
let err = if errno > 0 {
Error::from(NonZeroU32::new(errno as u32).unwrap())
} else {
Expand Down