To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.7% of users enabled 2FA.

Commit 276d513c authored by Javad Ebrahimian Amiri's avatar Javad Ebrahimian Amiri
Browse files

fixing rust files formatting

parent a81d7e91
...@@ -861,7 +861,12 @@ impl Instruction { ...@@ -861,7 +861,12 @@ impl Instruction {
format!("COMMINST @uvm.settime({})", ops[time]) format!("COMMINST @uvm.settime({})", ops[time])
} }
&Instruction_::NewTimer => format!("COMMINST @uvm.newtimer"), &Instruction_::NewTimer => format!("COMMINST @uvm.newtimer"),
&Instruction_::SetTimer { tmr, tm, prd, ref data } => format!( &Instruction_::SetTimer {
tmr,
tm,
prd,
ref data
} => format!(
"COMMINST @uvm.settimer({}, {}, {}) ", "COMMINST @uvm.settimer({}, {}, {}) ",
ops[tmr], ops[tm], ops[prd] ops[tmr], ops[tm], ops[prd]
), ),
...@@ -1481,11 +1486,11 @@ pub enum Instruction_ { ...@@ -1481,11 +1486,11 @@ pub enum Instruction_ {
SetTime(OpIndex), SetTime(OpIndex),
NewTimer, NewTimer,
SetTimer{ SetTimer {
tmr: OpIndex, tmr: OpIndex,
tm: OpIndex, tm: OpIndex,
prd: OpIndex, prd: OpIndex,
data: CallData, data: CallData
}, },
CancelTimer(OpIndex), CancelTimer(OpIndex),
DeleteTimer(OpIndex), DeleteTimer(OpIndex),
......
...@@ -293,7 +293,6 @@ impl MuType { ...@@ -293,7 +293,6 @@ impl MuType {
} }
} }
pub fn is_eq_comparable(&self) -> bool { pub fn is_eq_comparable(&self) -> bool {
self.is_int() self.is_int()
|| self.is_ptr() || self.is_ptr()
......
...@@ -3133,7 +3133,12 @@ impl<'a> InstructionSelection { ...@@ -3133,7 +3133,12 @@ impl<'a> InstructionSelection {
} }
#[cfg(feature = "realtime")] #[cfg(feature = "realtime")]
Instruction_::SetTimer { tmr, tm, prd, ref data } => { Instruction_::SetTimer {
tmr,
tm,
prd,
ref data
} => {
trace!("instsel on SetTimer"); trace!("instsel on SetTimer");
let ref ops = inst.ops; let ref ops = inst.ops;
...@@ -3143,14 +3148,16 @@ impl<'a> InstructionSelection { ...@@ -3143,14 +3148,16 @@ impl<'a> InstructionSelection {
let ref func = ops[data.func]; let ref func = ops[data.func];
let ref func_sig = match func.v { let ref func_sig = match func.v {
TreeNode_::Value(ref pv) => pv.ty.get_func_sig().unwrap(), TreeNode_::Value(ref pv) => {
pv.ty.get_func_sig().unwrap()
}
TreeNode_::Instruction(ref inst) => { TreeNode_::Instruction(ref inst) => {
let ref funcref_val = inst.value.as_ref().unwrap()[0]; let ref funcref_val =
inst.value.as_ref().unwrap()[0];
funcref_val.ty.get_func_sig().unwrap() funcref_val.ty.get_func_sig().unwrap()
} }
}; };
let tmp_tmr = let tmp_tmr =
self.emit_ireg(tmr, f_content, f_context, vm); self.emit_ireg(tmr, f_content, f_context, vm);
let tmp_tm = let tmp_tm =
...@@ -3160,37 +3167,40 @@ impl<'a> InstructionSelection { ...@@ -3160,37 +3167,40 @@ impl<'a> InstructionSelection {
let tmp_func = let tmp_func =
self.emit_ireg(func, f_content, f_context, vm); self.emit_ireg(func, f_content, f_context, vm);
// arguments should match the signature // arguments should match the signature
// assert_eq!(func_sig.arg_tys.len(), data.args.len()); //
// assert_eq!(func_sig.arg_tys.len(), data.args.len());
let tmp_arg = { let tmp_arg = {
if data.args.len() == 0 { if data.args.len() == 0 {
self.make_nullref(vm) self.make_nullref(vm)
} } else if data.args.len() == 1 {
else if data.args.len() == 1 {
let ref e_arg = ops[data.args[0]]; let ref e_arg = ops[data.args[0]];
self.emit_ireg(e_arg, f_content, f_context, vm) self.emit_ireg(e_arg, f_content, f_context, vm)
} } else {
else {
panic!("SetTimer entry function can only have one argument of type futexref"); panic!("SetTimer entry function can only have one argument of type futexref");
} }
}; };
// let arg_values = self // let arg_values = self
// .process_call_arguments(data, ops, f_content, f_context, vm); //
// let (stack_arg_size, arg_regs) = self.emit_precall_convention( // .process_call_arguments(data, ops, f_content,
// func_sig, // f_context, vm);
// &arg_values, // let (stack_arg_size, arg_regs) =
// data.convention, // self.emit_precall_convention(
// f_context, // func_sig,
// vm // &arg_values,
// ); // data.convention,
// // f_context,
// assert_eq!(stack_arg_size, 0, "SetTimer args do not fit in registers"); // vm
// );
//
// assert_eq!(stack_arg_size, 0,
// "SetTimer args do not fit in registers");
let mut args = vec![tmp_tmr, tmp_tm, tmp_prd, tmp_func, tmp_arg]; let mut args =
// args.extend(arg_regs); vec![tmp_tmr, tmp_tm, tmp_prd, tmp_func, tmp_arg];
// args.extend(arg_regs);
self.emit_runtime_entry( self.emit_runtime_entry(
&entrypoints::SETTIMER, &entrypoints::SETTIMER,
......
...@@ -104,7 +104,7 @@ fn is_suitable_child(inst: &Instruction) -> bool { ...@@ -104,7 +104,7 @@ fn is_suitable_child(inst: &Instruction) -> bool {
| GetTime | GetTime
| SetTime(_) | SetTime(_)
| NewTimer | NewTimer
| SetTimer{ .. } | SetTimer { .. }
| CancelTimer(_) | CancelTimer(_)
| DeleteTimer(_) | DeleteTimer(_)
| Sleep(_) | Sleep(_)
......
...@@ -122,7 +122,8 @@ fn sys_futex_lock_slowpath(futex_ptr: *mut u32, timeout_ns: u64) { ...@@ -122,7 +122,8 @@ fn sys_futex_lock_slowpath(futex_ptr: *mut u32, timeout_ns: u64) {
} }
}; };
assert_eq!( assert_eq!(
res, 0, res,
0,
"FUTEX.lock slowpath failed with error code #{}", "FUTEX.lock slowpath failed with error code #{}",
unsafe { (*libc::__errno_location()) } unsafe { (*libc::__errno_location()) }
); );
......
...@@ -22,7 +22,8 @@ pub fn sys_get_time_ns() -> i64 { ...@@ -22,7 +22,8 @@ pub fn sys_get_time_ns() -> i64 {
); );
} }
let res = (timestamp.tv_nsec as i64) + (1_000_000_000 * (timestamp.tv_sec as i64)); let res = (timestamp.tv_nsec as i64)
+ (1_000_000_000 * (timestamp.tv_sec as i64));
if cfg!(debug_assertions) { if cfg!(debug_assertions) {
debug!("sys_get_time_ns: {}", res); debug!("sys_get_time_ns: {}", res);
......
...@@ -349,9 +349,11 @@ pub struct MuThread { ...@@ -349,9 +349,11 @@ pub struct MuThread {
pub rt_attr: Box<RTAttr>, pub rt_attr: Box<RTAttr>,
// #[cfg(feature = "realtime")] // #[cfg(feature = "realtime")]
pub sys_thread_id: SysThreadID, pub sys_thread_id: SysThreadID,
pub sys_thread_context: *mut MuThreadContext /* #[cfg(feature = "realtime")] pub sys_thread_context: *mut MuThreadContext /* #[cfg(feature =
* "realtime")]
* pub runnable: * pub runnable:
* Arc<(Mutex<bool>, Condvar)>, */ * Arc<(Mutex<bool>,
* Condvar)>, */
} }
rodal_named!(MuThread); rodal_named!(MuThread);
...@@ -438,9 +440,7 @@ pub fn check_result() -> c_int { ...@@ -438,9 +440,7 @@ pub fn check_result() -> c_int {
impl MuThread { impl MuThread {
pub fn join(&self) { pub fn join(&self) {
let res = unsafe { let res = unsafe { sys_thread_join(self.sys_thread_id) };
sys_thread_join(self.sys_thread_id)
};
trace!("pthread_join returned: {}", res); trace!("pthread_join returned: {}", res);
} }
...@@ -530,8 +530,7 @@ impl MuThread { ...@@ -530,8 +530,7 @@ impl MuThread {
rt_attr: Box::new(RTAttr::new()), rt_attr: Box::new(RTAttr::new()),
// #[cfg(feature = "realtime")] // #[cfg(feature = "realtime")]
sys_thread_id: 0 as SysThreadID, sys_thread_id: 0 as SysThreadID,
sys_thread_context: std::ptr::null_mut() as *mut MuThreadContext sys_thread_context: std::ptr::null_mut() as *mut MuThreadContext /*
/*
* #[cfg(feature = * #[cfg(feature =
* "realtime")] * "realtime")]
* runnable: * runnable:
...@@ -695,8 +694,7 @@ impl MuThread { ...@@ -695,8 +694,7 @@ impl MuThread {
rt_attr: Box::new(RTAttr::new()), rt_attr: Box::new(RTAttr::new()),
// #[cfg(feature = "realtime")] // #[cfg(feature = "realtime")]
sys_thread_id: muthread_self(), sys_thread_id: muthread_self(),
sys_thread_context: std::ptr::null_mut() as *mut MuThreadContext sys_thread_context: std::ptr::null_mut() as *mut MuThreadContext /*
/*
* #[cfg(feature = * #[cfg(feature =
* "realtime")] * "realtime")]
* runnable: * runnable:
...@@ -714,7 +712,8 @@ impl MuThread { ...@@ -714,7 +712,8 @@ impl MuThread {
(*ptr_fake_mu_thread).sys_thread_context = (*ptr_fake_mu_thread).sys_thread_context =
Box::into_raw(Box::new(MuThreadContext { Box::into_raw(Box::new(MuThreadContext {
// muthread: Address::from_mut_ptr(ptr_fake_mu_thread), // muthread:
// Address::from_mut_ptr(ptr_fake_mu_thread),
new_sp: Address::from_mut_ptr((*ptr_fake_mu_thread).stack), new_sp: Address::from_mut_ptr((*ptr_fake_mu_thread).stack),
exception: Address::zero() exception: Address::zero()
})); }));
......
...@@ -33,10 +33,7 @@ pub unsafe fn sys_thread_launch( ...@@ -33,10 +33,7 @@ pub unsafe fn sys_thread_launch(
let muthread_add = Address::from_mut_ptr(muthread_ptr); let muthread_add = Address::from_mut_ptr(muthread_ptr);
let mut muthread_box = Box::from_raw(muthread_ptr); let mut muthread_box = Box::from_raw(muthread_ptr);
let context = Box::new(MuThreadContext { let context = Box::new(MuThreadContext { new_sp, exception });
new_sp,
exception
});
let context = Box::into_raw(context); let context = Box::into_raw(context);
muthread_box.sys_thread_context = context; muthread_box.sys_thread_context = context;
......
...@@ -37,7 +37,7 @@ pub const MAX_CPU_COUNT: usize = 32; ...@@ -37,7 +37,7 @@ pub const MAX_CPU_COUNT: usize = 32;
#[derive(Debug)] #[derive(Debug)]
#[repr(C)] #[repr(C)]
pub struct MuThreadContext { pub struct MuThreadContext {
// pub muthread: Address, // pub muthread: Address,
// attr: Option<RTAttr>, // attr: Option<RTAttr>,
pub new_sp: Address, pub new_sp: Address,
pub exception: Address pub exception: Address
...@@ -56,14 +56,12 @@ pub(super) extern "C" fn _pthread_entry_point( ...@@ -56,14 +56,12 @@ pub(super) extern "C" fn _pthread_entry_point(
// let muthread_ptr = Box::into_raw(context); // let muthread_ptr = Box::into_raw(context);
// let context = unsafe { Box::from_raw(context) }; // let context = unsafe { Box::from_raw(context) };
let context = unsafe { let context = unsafe { Box::from_raw(muthread_boxed.sys_thread_context) };
Box::from_raw(muthread_boxed.sys_thread_context)
};
debug!("PTHREAD_ENTRY input context:{:#?}", context); debug!("PTHREAD_ENTRY input context:{:#?}", context);
let muthread_ptr = Box::into_raw(muthread_boxed); let muthread_ptr = Box::into_raw(muthread_boxed);
// let muthread_ptr: *mut MuThread = context.muthread.to_ptr_mut(); // let muthread_ptr: *mut MuThread = context.muthread.to_ptr_mut();
let new_sp = unsafe { (*(*muthread_ptr).stack).sp.clone() }; let new_sp = unsafe { (*(*muthread_ptr).stack).sp.clone() };
let exception = context.exception; let exception = context.exception;
...@@ -100,7 +98,7 @@ pub(super) extern "C" fn _pthread_entry_point( ...@@ -100,7 +98,7 @@ pub(super) extern "C" fn _pthread_entry_point(
} }
// Thread finished, delete it's data // Thread finished, delete it's data
// Box::from_raw(muthread_ptr); // Box::from_raw(muthread_ptr);
} }
std::ptr::null() as *const SysVoid as *mut SysVoid std::ptr::null() as *const SysVoid as *mut SysVoid
...@@ -118,18 +116,22 @@ pub(super) fn sys_thread_self() -> SysThreadID { ...@@ -118,18 +116,22 @@ pub(super) fn sys_thread_self() -> SysThreadID {
} }
pub(super) fn sys_new_default_affinity_mask() -> SysAffinityMask { pub(super) fn sys_new_default_affinity_mask() -> SysAffinityMask {
// let def_attr: SysThreadAttr = unsafe { std::mem::zeroed() }; // let def_attr: SysThreadAttr = unsafe { std::mem::zeroed() };
let mut def_aff: SysAffinityMask = unsafe { std::mem::zeroed() }; let mut def_aff: SysAffinityMask = unsafe { std::mem::zeroed() };
// let res = unsafe { libc::pthread_attr_init( // let res = unsafe { libc::pthread_attr_init(
// &def_attr as *const SysThreadAttr as *mut SysThreadAttr // &def_attr as *const SysThreadAttr as *mut SysThreadAttr
// ) }; // ) };
// assert_eq!(res, MU_SUCCESS); // assert_eq!(res, MU_SUCCESS);
// //
// let res = unsafe { libc::pthread_attr_getaffinity_np(&def_attr as *const libc::pthread_attr_t, libc::CPU_SETSIZE as usize, &def_aff as *const libc::cpu_set_t as *mut libc::cpu_set_t) }; // let res = unsafe { libc::pthread_attr_getaffinity_np(&def_attr as
// assert_eq!(res, MU_SUCCESS); // *const libc::pthread_attr_t, libc::CPU_SETSIZE as usize, &def_aff as
// *const libc::cpu_set_t as *mut libc::cpu_set_t) }; assert_eq!(res,
// MU_SUCCESS);
for i in 0..MAX_CPU_COUNT { for i in 0..MAX_CPU_COUNT {
unsafe { libc::CPU_SET(i, &mut def_aff); }; unsafe {
libc::CPU_SET(i, &mut def_aff);
};
} }
def_aff def_aff
......
...@@ -161,7 +161,7 @@ pub unsafe extern "C" fn muentry_attr_set_cpu(attr: *mut SysVoid, cpu: usize) { ...@@ -161,7 +161,7 @@ pub unsafe extern "C" fn muentry_attr_set_cpu(attr: *mut SysVoid, cpu: usize) {
debug!("muentry_attr_set_cpu ({:#?}, {})", attr, cpu); debug!("muentry_attr_set_cpu ({:#?}, {})", attr, cpu);
let mut attr: Box<RTAttr> = Box::from_raw(attr as *mut RTAttr); let mut attr: Box<RTAttr> = Box::from_raw(attr as *mut RTAttr);
sys_affinity_set_cpu(cpu, &mut unsafe { *(attr.affinity) } ); sys_affinity_set_cpu(cpu, &mut unsafe { *(attr.affinity) });
Box::into_raw(attr); Box::into_raw(attr);
} }
...@@ -173,7 +173,7 @@ pub unsafe extern "C" fn muentry_attr_clear_cpu( ...@@ -173,7 +173,7 @@ pub unsafe extern "C" fn muentry_attr_clear_cpu(
debug!("muentry_attr_clear_cpu ({:#?}, {})", attr, cpu); debug!("muentry_attr_clear_cpu ({:#?}, {})", attr, cpu);
let mut attr: Box<RTAttr> = Box::from_raw(attr as *mut RTAttr); let mut attr: Box<RTAttr> = Box::from_raw(attr as *mut RTAttr);
sys_affinity_clear_cpu(cpu, &mut unsafe { *(attr.affinity) } ); sys_affinity_clear_cpu(cpu, &mut unsafe { *(attr.affinity) });
Box::into_raw(attr); Box::into_raw(attr);
} }
...@@ -184,7 +184,7 @@ pub unsafe extern "C" fn muentry_attr_isset_cpu( ...@@ -184,7 +184,7 @@ pub unsafe extern "C" fn muentry_attr_isset_cpu(
) -> bool { ) -> bool {
debug!("muentry_attr_isset_cpu ({:#?}, {})", attr, cpu); debug!("muentry_attr_isset_cpu ({:#?}, {})", attr, cpu);
let mut attr: Box<RTAttr> = Box::from_raw(attr as *mut RTAttr); let mut attr: Box<RTAttr> = Box::from_raw(attr as *mut RTAttr);
let res = sys_affinity_isset_cpu(cpu, &mut unsafe { *(attr.affinity) } ); let res = sys_affinity_isset_cpu(cpu, &mut unsafe { *(attr.affinity) });
debug!("muentry_attr_isset_cpu returned ({})", res); debug!("muentry_attr_isset_cpu returned ({})", res);
...@@ -196,7 +196,7 @@ pub unsafe extern "C" fn muentry_attr_isset_cpu( ...@@ -196,7 +196,7 @@ pub unsafe extern "C" fn muentry_attr_isset_cpu(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn muentry_attr_zero_cpu(attr: *mut SysVoid) { pub unsafe extern "C" fn muentry_attr_zero_cpu(attr: *mut SysVoid) {
let mut attr: Box<RTAttr> = Box::from_raw(attr as *mut RTAttr); let mut attr: Box<RTAttr> = Box::from_raw(attr as *mut RTAttr);
sys_affinity_zero_cpu(&mut unsafe { *(attr.affinity) } ); sys_affinity_zero_cpu(&mut unsafe { *(attr.affinity) });
Box::into_raw(attr); Box::into_raw(attr);
} }
...@@ -336,7 +336,7 @@ pub extern "C" fn muentry_thread_set_cpu(muthread: *mut MuThread, cpu: usize) { ...@@ -336,7 +336,7 @@ pub extern "C" fn muentry_thread_set_cpu(muthread: *mut MuThread, cpu: usize) {
} }
}) })
}; };
sys_affinity_set_cpu(cpu, &mut unsafe { * (cur_muthread.rt_attr.affinity) }); sys_affinity_set_cpu(cpu, &mut unsafe { *(cur_muthread.rt_attr.affinity) });
sys_thread_set_affinity( sys_thread_set_affinity(
cur_muthread.sys_thread_id, cur_muthread.sys_thread_id,
MU_DEFAULT_AFF_SIZE, MU_DEFAULT_AFF_SIZE,
...@@ -359,7 +359,9 @@ pub extern "C" fn muentry_thread_clear_cpu( ...@@ -359,7 +359,9 @@ pub extern "C" fn muentry_thread_clear_cpu(
} }
}) })
}; };
sys_affinity_clear_cpu(cpu, &mut unsafe { * (cur_muthread.rt_attr.affinity) }); sys_affinity_clear_cpu(cpu, &mut unsafe {
*(cur_muthread.rt_attr.affinity)
});
sys_thread_set_affinity( sys_thread_set_affinity(
cur_muthread.sys_thread_id, cur_muthread.sys_thread_id,
MU_DEFAULT_AFF_SIZE, MU_DEFAULT_AFF_SIZE,
...@@ -383,7 +385,9 @@ pub extern "C" fn muentry_thread_isset_cpu( ...@@ -383,7 +385,9 @@ pub extern "C" fn muentry_thread_isset_cpu(
} }
}) })
}; };
let res = sys_affinity_isset_cpu(cpu, &mut unsafe { * (cur_muthread.rt_attr.affinity) }); let res = sys_affinity_isset_cpu(cpu, &mut unsafe {
*(cur_muthread.rt_attr.affinity)
});
let _cur_muthread = Box::into_raw(cur_muthread); let _cur_muthread = Box::into_raw(cur_muthread);
res res
......
...@@ -155,11 +155,12 @@ pub(super) unsafe fn sys_thread_launch( ...@@ -155,11 +155,12 @@ pub(super) unsafe fn sys_thread_launch(
}; };
let muthread_ptr = Box::into_raw(muthread); let muthread_ptr = Box::into_raw(muthread);
// let muthread_add = Address::from_mut_ptr(muthread_ptr); // let muthread_add = Address::from_mut_ptr(muthread_ptr);
let mut muthread_box = unsafe { Box::from_raw(muthread_ptr) }; let mut muthread_box = unsafe { Box::from_raw(muthread_ptr) };
muthread_box.sys_thread_context = Box::into_raw(Box::new(MuThreadContext { muthread_box.sys_thread_context =
// muthread: muthread_add.clone(), Box::into_raw(Box::new(MuThreadContext {
// muthread: muthread_add.clone(),
new_sp: Address::from(new_sp), new_sp: Address::from(new_sp),
exception: Address::from(exception) exception: Address::from(exception)
})); }));
......
This diff is collapsed.
This diff is collapsed.
...@@ -603,31 +603,31 @@ pub enum NodeInst { ...@@ -603,31 +603,31 @@ pub enum NodeInst {
NodeExitThread { NodeExitThread {
id: MuID, id: MuID,
tref: MuVarNode, tref: MuVarNode,
exc_clause: Option<MuExcClause>, exc_clause: Option<MuExcClause>
}, },
NodeYield { NodeYield {
id: MuID, id: MuID,
exc_clause: Option<MuExcClause>, exc_clause: Option<MuExcClause>
}, },
NodeNewFutex { NodeNewFutex {
id: MuID, id: MuID,
result_id: MuID, result_id: MuID
}, },
NodeNewAttr { NodeNewAttr {
id: MuID, id: MuID,
result_id: MuID, result_id: MuID
}, },
NodeSetAttr { NodeSetAttr {
id: MuID, id: MuID,
tref: MuVarNode, tref: MuVarNode,
aref: MuVarNode, aref: MuVarNode,
exc_clause: Option<MuExcClause>, exc_clause: Option<MuExcClause>
}, },
NodeGetAttr { NodeGetAttr {
id: MuID, id: MuID,
result_id: MuID, result_id: MuID,
tref: MuVarNode, tref: MuVarNode,
exc_clause: Option<MuExcClause>, exc_clause: Option<MuExcClause>
}, },
NodeSwapStack { NodeSwapStack {
id: MuID, id: MuID,
...@@ -640,21 +640,21 @@ pub enum NodeInst { ...@@ -640,21 +640,21 @@ pub enum NodeInst {
}, },
NodeGetTime { NodeGetTime {
id: MuID, id: MuID,
result_id: MuID, result_id: MuID
}, },
NodeSetTime { NodeSetTime {
id: MuID, id: MuID,
tm: MuVarNode, tm: MuVarNode,
exc_clause: Option<MuExcClause>, exc_clause: Option<MuExcClause>
}, },
NodeNewTimer { NodeNewTimer {
id: MuID, id: MuID,
result_id: MuID, result_id: MuID,