fixing rust files formatting

parent a81d7e91
......@@ -861,7 +861,12 @@ impl Instruction {
format!("COMMINST @uvm.settime({})", ops[time])
}
&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({}, {}, {}) ",
ops[tmr], ops[tm], ops[prd]
),
......@@ -1481,11 +1486,11 @@ pub enum Instruction_ {
SetTime(OpIndex),
NewTimer,
SetTimer{
SetTimer {
tmr: OpIndex,
tm: OpIndex,
prd: OpIndex,
data: CallData,
data: CallData
},
CancelTimer(OpIndex),
DeleteTimer(OpIndex),
......
......@@ -215,7 +215,7 @@ impl MuType {
_ => false
}
}
#[cfg(feature = "realtime")]
pub fn is_regionref(&self) -> bool {
match self.v {
......@@ -293,7 +293,6 @@ impl MuType {
}
}
pub fn is_eq_comparable(&self) -> bool {
self.is_int()
|| self.is_ptr()
......
......@@ -3133,7 +3133,12 @@ impl<'a> InstructionSelection {
}
#[cfg(feature = "realtime")]
Instruction_::SetTimer { tmr, tm, prd, ref data } => {
Instruction_::SetTimer {
tmr,
tm,
prd,
ref data
} => {
trace!("instsel on SetTimer");
let ref ops = inst.ops;
......@@ -3143,14 +3148,16 @@ impl<'a> InstructionSelection {
let ref func = ops[data.func];
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) => {
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()
}
};
let tmp_tmr =
self.emit_ireg(tmr, f_content, f_context, vm);
let tmp_tm =
......@@ -3160,37 +3167,40 @@ impl<'a> InstructionSelection {
let tmp_func =
self.emit_ireg(func, f_content, f_context, vm);
// 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 = {
if data.args.len() == 0 {
self.make_nullref(vm)
}
else if data.args.len() == 1 {
} else if data.args.len() == 1 {
let ref e_arg = ops[data.args[0]];
self.emit_ireg(e_arg, f_content, f_context, vm)
}
else {
} else {
panic!("SetTimer entry function can only have one argument of type futexref");
}
};
// let arg_values = self
// .process_call_arguments(data, ops, f_content, f_context, vm);
// let (stack_arg_size, arg_regs) = self.emit_precall_convention(
// func_sig,
// &arg_values,
// data.convention,
// f_context,
// 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];
// args.extend(arg_regs);
// let arg_values = self
//
// .process_call_arguments(data, ops, f_content,
// f_context, vm);
// let (stack_arg_size, arg_regs) =
// self.emit_precall_convention(
// func_sig,
// &arg_values,
// data.convention,
// f_context,
// 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];
// args.extend(arg_regs);
self.emit_runtime_entry(
&entrypoints::SETTIMER,
......
......@@ -104,7 +104,7 @@ fn is_suitable_child(inst: &Instruction) -> bool {
| GetTime
| SetTime(_)
| NewTimer
| SetTimer{ .. }
| SetTimer { .. }
| CancelTimer(_)
| DeleteTimer(_)
| Sleep(_)
......
......@@ -122,7 +122,8 @@ fn sys_futex_lock_slowpath(futex_ptr: *mut u32, timeout_ns: u64) {
}
};
assert_eq!(
res, 0,
res,
0,
"FUTEX.lock slowpath failed with error code #{}",
unsafe { (*libc::__errno_location()) }
);
......
......@@ -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) {
debug!("sys_get_time_ns: {}", res);
......
......@@ -322,7 +322,7 @@ pub enum MuStackState {
/// MuThread. The compiler emits code that uses offsets to some fields in this
/// struct.
#[repr(C)]
pub struct MuThread {
pub struct MuThread {
pub hdr: MuEntityHeader,
/// the allocator from memory manager
/// Fixme, not all threads need mutator
......@@ -349,9 +349,11 @@ pub struct MuThread {
pub rt_attr: Box<RTAttr>,
// #[cfg(feature = "realtime")]
pub sys_thread_id: SysThreadID,
pub sys_thread_context: *mut MuThreadContext /* #[cfg(feature = "realtime")]
* pub runnable:
* Arc<(Mutex<bool>, Condvar)>, */
pub sys_thread_context: *mut MuThreadContext /* #[cfg(feature =
* "realtime")]
* pub runnable:
* Arc<(Mutex<bool>,
* Condvar)>, */
}
rodal_named!(MuThread);
......@@ -438,9 +440,7 @@ pub fn check_result() -> c_int {
impl MuThread {
pub fn join(&self) {
let res = unsafe {
sys_thread_join(self.sys_thread_id)
};
let res = unsafe { sys_thread_join(self.sys_thread_id) };
trace!("pthread_join returned: {}", res);
}
......@@ -530,14 +530,13 @@ impl MuThread {
rt_attr: Box::new(RTAttr::new()),
// #[cfg(feature = "realtime")]
sys_thread_id: 0 as SysThreadID,
sys_thread_context: std::ptr::null_mut() as *mut MuThreadContext
/*
* #[cfg(feature =
* "realtime")]
* runnable:
* Arc::new((Mutex::
* new(false),
* Condvar::new())), */
sys_thread_context: std::ptr::null_mut() as *mut MuThreadContext /*
* #[cfg(feature =
* "realtime")]
* runnable:
* Arc::new((Mutex::
* new(false),
* Condvar::new())), */
};
}
......@@ -695,14 +694,13 @@ impl MuThread {
rt_attr: Box::new(RTAttr::new()),
// #[cfg(feature = "realtime")]
sys_thread_id: muthread_self(),
sys_thread_context: std::ptr::null_mut() as *mut MuThreadContext
/*
* #[cfg(feature =
* "realtime")]
* runnable:
* Arc::new((Mutex::
* new(false),
* Condvar::new())), */
sys_thread_context: std::ptr::null_mut() as *mut MuThreadContext /*
* #[cfg(feature =
* "realtime")]
* runnable:
* Arc::new((Mutex::
* new(false),
* Condvar::new())), */
});
{
let mutator_ptr = &mut fake_mu_thread.allocator as *mut mm::Mutator;
......@@ -714,7 +712,8 @@ impl MuThread {
(*ptr_fake_mu_thread).sys_thread_context =
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),
exception: Address::zero()
}));
......
......@@ -33,10 +33,7 @@ pub unsafe fn sys_thread_launch(
let muthread_add = Address::from_mut_ptr(muthread_ptr);
let mut muthread_box = Box::from_raw(muthread_ptr);
let context = Box::new(MuThreadContext {
new_sp,
exception
});
let context = Box::new(MuThreadContext { new_sp, exception });
let context = Box::into_raw(context);
muthread_box.sys_thread_context = context;
......
......@@ -37,7 +37,7 @@ pub const MAX_CPU_COUNT: usize = 32;
#[derive(Debug)]
#[repr(C)]
pub struct MuThreadContext {
// pub muthread: Address,
// pub muthread: Address,
// attr: Option<RTAttr>,
pub new_sp: Address,
pub exception: Address
......@@ -56,14 +56,12 @@ pub(super) extern "C" fn _pthread_entry_point(
// let muthread_ptr = Box::into_raw(context);
// let context = unsafe { Box::from_raw(context) };
let context = unsafe {
Box::from_raw(muthread_boxed.sys_thread_context)
};
let context = unsafe { Box::from_raw(muthread_boxed.sys_thread_context) };
debug!("PTHREAD_ENTRY input context:{:#?}", context);
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 exception = context.exception;
......@@ -100,7 +98,7 @@ pub(super) extern "C" fn _pthread_entry_point(
}
// 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
......@@ -118,18 +116,22 @@ pub(super) fn sys_thread_self() -> SysThreadID {
}
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 res = unsafe { libc::pthread_attr_init(
// &def_attr as *const SysThreadAttr as *mut SysThreadAttr
// ) };
// 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) };
// assert_eq!(res, MU_SUCCESS);
// let res = unsafe { libc::pthread_attr_init(
// &def_attr as *const SysThreadAttr as *mut SysThreadAttr
// ) };
// 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) }; assert_eq!(res,
// MU_SUCCESS);
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
......
......@@ -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);
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);
}
......@@ -173,7 +173,7 @@ pub unsafe extern "C" fn muentry_attr_clear_cpu(
debug!("muentry_attr_clear_cpu ({:#?}, {})", attr, cpu);
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);
}
......@@ -184,7 +184,7 @@ pub unsafe extern "C" fn muentry_attr_isset_cpu(
) -> bool {
debug!("muentry_attr_isset_cpu ({:#?}, {})", attr, cpu);
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);
......@@ -196,7 +196,7 @@ pub unsafe extern "C" fn muentry_attr_isset_cpu(
#[no_mangle]
pub unsafe extern "C" fn muentry_attr_zero_cpu(attr: *mut SysVoid) {
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);
}
......@@ -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(
cur_muthread.sys_thread_id,
MU_DEFAULT_AFF_SIZE,
......@@ -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(
cur_muthread.sys_thread_id,
MU_DEFAULT_AFF_SIZE,
......@@ -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);
res
......
......@@ -155,14 +155,15 @@ pub(super) unsafe fn sys_thread_launch(
};
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) };
muthread_box.sys_thread_context = Box::into_raw(Box::new(MuThreadContext {
// muthread: muthread_add.clone(),
new_sp: Address::from(new_sp),
exception: Address::from(exception)
}));
muthread_box.sys_thread_context =
Box::into_raw(Box::new(MuThreadContext {
// muthread: muthread_add.clone(),
new_sp: Address::from(new_sp),
exception: Address::from(exception)
}));
let muthread_ptr = Box::into_raw(muthread_box);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -603,31 +603,31 @@ pub enum NodeInst {
NodeExitThread {
id: MuID,
tref: MuVarNode,
exc_clause: Option<MuExcClause>,
exc_clause: Option<MuExcClause>
},
NodeYield {
id: MuID,
exc_clause: Option<MuExcClause>,
exc_clause: Option<MuExcClause>
},
NodeNewFutex {
id: MuID,
result_id: MuID,
result_id: MuID
},
NodeNewAttr {
id: MuID,
result_id: MuID,
result_id: MuID
},
NodeSetAttr {
id: MuID,
tref: MuVarNode,
aref: MuVarNode,
exc_clause: Option<MuExcClause>,
exc_clause: Option<MuExcClause>
},
NodeGetAttr {
id: MuID,
result_id: MuID,
tref: MuVarNode,
exc_clause: Option<MuExcClause>,
exc_clause: Option<MuExcClause>
},
NodeSwapStack {
id: MuID,
......@@ -640,21 +640,21 @@ pub enum NodeInst {
},
NodeGetTime {
id: MuID,
result_id: MuID,
result_id: MuID
},
NodeSetTime {
id: MuID,
tm: MuVarNode,
exc_clause: Option<MuExcClause>,
exc_clause: Option<MuExcClause>
},
NodeNewTimer {
id: MuID,
result_id: MuID,
exc_clause: Option<MuExcClause>,
exc_clause: Option<MuExcClause>
},
NodeDeleteTimer {
id: MuID,
tmr: MuVarNode,
tmr: MuVarNode
},
NodeSetTimer {
id: MuID,
......@@ -664,11 +664,11 @@ pub enum NodeInst {
fsig: MuFuncSigNode,
func: MuFuncNode,
args: Vec<MuID>,
exc_clause: Option<MuExcClause>,
exc_clause: Option<MuExcClause>
},
NodeCancelTimer {
id: MuID,
tmr: MuVarNode,
tmr: MuVarNode
},
NodeCommInst {
id: MuID,
......
This diff is collapsed.
......@@ -1855,13 +1855,19 @@ impl<'a> VM {
pub fn push_join_handle(&self, join_handle: *mut MuThread) {
self.pending_joins.lock().unwrap().push_front(join_handle);
trace!("push_join_handle-total number of handles: {}", self.pending_joins.lock().unwrap().len());
trace!(
"push_join_handle-total number of handles: {}",
self.pending_joins.lock().unwrap().len()
);
}
// pub fn push_join_handle(&self, join_handle: JoinHandle<()>) {
// self.pending_joins.lock().unwrap().push_front(join_handle);
// }
pub fn pop_join_handle(&self) -> Option<*mut MuThread> {
trace!("pop_join_handle-number of handles before pop: {}", self.pending_joins.lock().unwrap().len());
trace!(
"pop_join_handle-number of handles before pop: {}",
self.pending_joins.lock().unwrap().len()
);
self.pending_joins.lock().unwrap().pop_front()
}
// pub fn pop_join_handle(&self) -> Option<JoinHandle<()>> {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment