Skip to content

Commit

Permalink
Add comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel-Durov committed Apr 18, 2024
1 parent 18b7fee commit e1be48c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ykrt/src/trace/swt/patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ unsafe fn save_original_instructions(
///
unsafe fn patch_function(function_ptr: usize, code: *const u8, size: size_t) {
let page_size = sysconf(_SC_PAGESIZE) as usize;

// Align the function_ptr address down to the nearest page boundary.
let page_address = (function_ptr & !(page_size - 1)) as *mut c_void;
// Calculate the offset of function_ptr from the page start.
let start_offset = function_ptr - (page_address as usize);

// This unwrap should be safe since we are using a page that is
Expand Down

0 comments on commit e1be48c

Please sign in to comment.