mirror of
https://github.com/urbit/ares.git
synced 2024-11-26 09:57:56 +03:00
wip: got result value being passed correctly
This commit is contained in:
parent
4ff53a1845
commit
140d02cd55
@ -421,9 +421,9 @@ impl<'closure> CCallback<'closure> {
|
||||
{
|
||||
let cb: &mut F = user_data.cast::<F>().as_mut().unwrap();
|
||||
let mut v = (*cb)();
|
||||
eprint!("ares: v: {:?}\r\n", v);
|
||||
eprint!("call_closure: v: {:?}\r\n", v);
|
||||
let v_ptr = &mut v as *mut _ as *mut c_void;
|
||||
eprint!("ares: v_ptr: {:p}\r\n", v_ptr);
|
||||
eprint!("call_closure: v_ptr: {:p}\r\n", v_ptr);
|
||||
v_ptr
|
||||
}
|
||||
}
|
||||
@ -447,10 +447,9 @@ pub fn call_with_guard<F: FnMut() -> Result>(
|
||||
) -> Result {
|
||||
let c = CCallback::new(f);
|
||||
let mut result: Result = Ok(D(0));
|
||||
let result_ptr = &mut result as *mut _ as *mut c_void;
|
||||
let result_ptr_ptr = result_ptr as *mut *mut c_void;
|
||||
|
||||
eprint!("ares: result_ptr_ptr: {:p}\r\n", result_ptr_ptr);
|
||||
let res_ptr = &mut result as *mut _ as *mut c_void;
|
||||
let res_ptr_ptr = &res_ptr as *const *mut c_void;
|
||||
eprint!("call_with_guard: before res_ptr: {:p}\r\n", res_ptr);
|
||||
|
||||
unsafe {
|
||||
let err = guard(
|
||||
@ -458,15 +457,16 @@ pub fn call_with_guard<F: FnMut() -> Result>(
|
||||
c.user_data as *mut c_void,
|
||||
stack,
|
||||
alloc,
|
||||
result_ptr_ptr,
|
||||
res_ptr_ptr,
|
||||
);
|
||||
|
||||
eprint!("ares: result_ptr: {:p}\r\n", result_ptr);
|
||||
eprint!("call_with_guard: after res_ptr: {:p}\r\n", res_ptr);
|
||||
|
||||
if let Ok(err) = GuardError::try_from(err) {
|
||||
match err {
|
||||
GuardError::GuardSound => {
|
||||
eprint!("ares: result: {:?}\n", result);
|
||||
let result = *(res_ptr as *mut Result);
|
||||
eprint!("call_with_guard: result: {:?}\r\n", result);
|
||||
return result;
|
||||
}
|
||||
GuardError::GuardArmor => {
|
||||
@ -1076,7 +1076,6 @@ pub fn interpret(context: &mut Context, mut subject: Noun, formula: Noun) -> Res
|
||||
})
|
||||
});
|
||||
|
||||
eprint!("nock: {:?}", nock);
|
||||
match nock {
|
||||
Ok(res) => Ok(res),
|
||||
Err(err) => Err(exit(context, &snapshot, virtual_frame, err)),
|
||||
|
@ -112,7 +112,7 @@ guard_err guard(
|
||||
void *user_data,
|
||||
void *const *stack_pp,
|
||||
void *const *alloc_pp,
|
||||
void **ret
|
||||
void *const *ret
|
||||
)
|
||||
{
|
||||
stack = (uint64_t**) stack_pp;
|
||||
@ -124,7 +124,6 @@ guard_err guard(
|
||||
fprintf(stderr, "guard: stack pointer at %p\r\n", (void *) *stack);
|
||||
fprintf(stderr, "guard: alloc pointer at %p\r\n", (void *) *alloc);
|
||||
fprintf(stderr, "guard: ret pointer at %p\r\n", (void *) ret);
|
||||
fprintf(stderr, "guard: res pointer at %p\r\n", (void *) *ret);
|
||||
|
||||
if (guard_p == 0) {
|
||||
fprintf(stderr, "guard: installing guard page\r\n");
|
||||
@ -154,8 +153,9 @@ guard_err guard(
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "guard: assigning ret to %p\r\n", result);
|
||||
*ret = result;
|
||||
fprintf(stderr, "guard: assigning *ret to %p\r\n", result);
|
||||
*(void **)ret = result;
|
||||
fprintf(stderr, "guard: assigned *ret to %p\r\n", *ret);
|
||||
|
||||
if (mprotect(guard_p, GD_PAGESIZE, PROT_READ | PROT_WRITE) == -1) {
|
||||
err = guard_armor;
|
||||
|
@ -45,7 +45,7 @@ guard_err guard(
|
||||
void *user_data,
|
||||
void *const *stack_pp,
|
||||
void *const *alloc_pp,
|
||||
void **ret
|
||||
void *const *ret
|
||||
);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user