codecheck: Remove UB of ch8 usertests #140

This commit is contained in:
Yifan Wu 2024-01-21 15:32:33 +08:00
parent 94d5e66f36
commit 972534f70c
12 changed files with 47 additions and 39 deletions

View file

@ -6,6 +6,7 @@ extern crate user_lib;
extern crate alloc;
use alloc::vec::Vec;
use core::ptr::addr_of_mut;
use user_lib::{exit, get_time, thread_create, waittid};
static mut A: usize = 0;
@ -14,7 +15,7 @@ const THREAD_COUNT_DEFAULT: usize = 16;
static mut PER_THREAD: usize = 0;
unsafe fn critical_section(t: &mut usize) {
let a = &mut A as *mut usize;
let a = addr_of_mut!(A);
let cur = a.read_volatile();
for _ in 0..500 {
*t = (*t) * (*t) % 10007;