| Crates.io | x86-alignment-check |
| lib.rs | x86-alignment-check |
| version | 0.1.6 |
| created_at | 2023-03-30 11:53:02.240382+00 |
| updated_at | 2023-06-03 12:17:35.322321+00 |
| description | x86 aligment check flag manipulation |
| homepage | |
| repository | https://github.com/aki-akaguma/x86-alignment-check |
| max_upload_size | |
| id | 824995 |
| size | 28,421 |
x86-alignment-check is set ac flag in eflags on x86 or x86_64
ac flag bit into ON, its included eflags of x86.x86_64 are supported too.#![no_std]First, add the following to Cargo.toml:
[target.'cfg(any(target_arch = "x86_64", target_arch = "x86"))'.dev-dependencies]
x86-alignment-check = "*"
Second, enclose your test code with x86_alignment_check() as follows:
use x86_alignment_check::x86_alignment_check;
//
let old_flag = x86_alignment_check(true);
//
// here your test codes, processing anythings, a bus error may occur.
//
let _ = x86_alignment_check(old_flag);
Finally execute cargo test
let val = x86_alignment_check::ac_call_once(|| {
// here is alignment check
// processing anythings
// return value for assertion
1
});
assert_eq!(val, 1);
For now, assertions such as assert_eq!() cannot be included inside FnOnce,
because of the rust runtime bug.
let val = x86_alignment_check::no_ac_call_once(|| {
// here is not alignment check
// processing anythings
// return value for assertion
1
});
assert_eq!(val, 1);
This project is licensed under either of
at your option.