Support getrandom syscall

This commit is contained in:
hkalbasi 2023-07-11 00:29:06 +03:30
parent ea02f4cba1
commit 59420afa46
8 changed files with 180 additions and 21 deletions

View file

@ -2494,6 +2494,28 @@ fn exec_limits() {
);
}
#[test]
fn memory_limit() {
check_fail(
r#"
extern "Rust" {
#[rustc_allocator]
fn __rust_alloc(size: usize, align: usize) -> *mut u8;
}
const GOAL: u8 = unsafe {
__rust_alloc(30_000_000_000, 1); // 30GB
2
};
"#,
|e| {
e == ConstEvalError::MirEvalError(MirEvalError::Panic(
"Memory allocation of 30000000000 bytes failed".to_string(),
))
},
);
}
#[test]
fn type_error() {
check_fail(

View file

@ -602,3 +602,41 @@ fn rotate() {
320192512,
);
}
#[test]
fn simd() {
check_number(
r#"
pub struct i8x16(
i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,
);
extern "platform-intrinsic" {
pub fn simd_bitmask<T, U>(x: T) -> U;
}
const GOAL: u16 = simd_bitmask(i8x16(
0, 1, 0, 0, 2, 255, 100, 0, 50, 0, 1, 1, 0, 0, 0, 0
));
"#,
0b0000110101110010,
);
check_number(
r#"
pub struct i8x16(
i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,
);
extern "platform-intrinsic" {
pub fn simd_lt<T, U>(x: T, y: T) -> U;
pub fn simd_bitmask<T, U>(x: T) -> U;
}
const GOAL: u16 = simd_bitmask(simd_lt::<i8x16, i8x16>(
i8x16(
-105, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
),
i8x16(
-4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
),
));
"#,
0xFFFF,
);
}