Skip to content

Commit

Permalink
Add clarifying comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-davis authored and pnkfelix committed Sep 28, 2023
1 parent 6d12739 commit 8cb725f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/asm_based.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ where
where
F: for<'a> FnOnce(&'a JmpBufFields) -> c_int,
{
// Dereference `closure_env_ptr` with .read() to acquire ownership of
// the FnOnce object, then call it. (See also the forget note below.)
//
// Note that `closure_env_ptr` is not a raw function pointer, it's a
// pointer to a FnOnce; the code we call comes from the generic `F`.
unsafe { (closure_env_ptr.read())(&*jbuf) }
}
unsafe {
Expand Down Expand Up @@ -173,6 +178,11 @@ where
where
F: for<'a> FnOnce(&'a SigJmpBufFields) -> c_int,
{
// Dereference `closure_env_ptr` with .read() to acquire ownership of
// the FnOnce object, then call it. (See also the forget note below.)
//
// Note that `closure_env_ptr` is not a raw function pointer, it's a
// pointer to a FnOnce; the code we call comes from the generic `F`.
unsafe { (closure_env_ptr.read())(&*jbuf) }
}

Expand Down
12 changes: 12 additions & 0 deletions src/cee_based.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ where
F: for<'a> FnOnce(&'a JmpBufFields) -> c_int,
{
let closure_env_ptr: *mut F = closure_env_ptr as *mut F;

// Dereference `closure_env_ptr` with .read() to acquire ownership of
// the FnOnce object, then call it. (See also the forget note below.)
//
// Note that `closure_env_ptr` is not a raw function pointer, it's a
// pointer to a FnOnce; the code we call comes from the generic `F`.
unsafe { (closure_env_ptr.read())(&*jbuf) }
}

Expand Down Expand Up @@ -48,6 +54,12 @@ where
F: for<'a> FnOnce(&'a SigJmpBufFields) -> c_int,
{
let closure_env_ptr: *mut F = closure_env_ptr as *mut F;

// Dereference `closure_env_ptr` with .read() to acquire ownership of
// the FnOnce object, then call it. (See also the forget note below.)
//
// Note that `closure_env_ptr` is not a raw function pointer, it's a
// pointer to a FnOnce; the code we call comes from the generic `F`.
unsafe { (closure_env_ptr.read())(&*jbuf) }
}

Expand Down

0 comments on commit 8cb725f

Please sign in to comment.