Skip to content

Commit

Permalink
Update codes for static syscalls
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasSte committed Dec 20, 2024
1 parent 963b2c6 commit 21947f9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub mod x86_64;
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
#[linkage = "weak"]
pub unsafe extern "C" fn abort() -> ! {
let syscall: extern "C" fn() -> ! = core::mem::transmute(3069975057u64); // murmur32 hash of "abort"
let syscall: extern "C" fn() -> ! = core::mem::transmute(1usize); // 1 is the code for "abort"
syscall()
}

Expand Down
9 changes: 4 additions & 5 deletions src/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,25 +219,24 @@ mod syscalls {
mod syscalls {
pub(crate) fn sol_memcpy_(dest: *mut u8, src: *const u8, n: u64) {
let syscall: extern "C" fn(*mut u8, *const u8, u64) =
unsafe { core::mem::transmute(1904002211u64) }; // murmur32 hash of "sol_memcpy_"
unsafe { core::mem::transmute(3usize) }; // 3 is the code for "sol_memcpy_"
syscall(dest, src, n)
}

pub(crate) fn sol_memmove_(dest: *mut u8, src: *const u8, n: u64) {
let syscall: extern "C" fn(*mut u8, *const u8, u64) =
unsafe { core::mem::transmute(1128493560u64) }; // murmur32 hash of "sol_memmove_"
unsafe { core::mem::transmute(4usize) }; // 4 is the code for "sol_memmove_"
syscall(dest, src, n)
}

pub(crate) fn sol_memcmp_(dest: *const u8, src: *const u8, n: u64, result: *mut i32) {
let syscall: extern "C" fn(*const u8, *const u8, u64, *mut i32) =
unsafe { core::mem::transmute(1608310321u64) }; // murmur32 hash of "sol_memcmp_"
unsafe { core::mem::transmute(6usize) }; // 6 is the code for "sol_memcmp_"
syscall(dest, src, n, result)
}

pub(crate) fn sol_memset_(dest: *mut u8, c: u8, n: u64) {
let syscall: extern "C" fn(*mut u8, u8, u64) =
unsafe { core::mem::transmute(930151202u64) }; // murmur32 hash of "sol_memset_"
let syscall: extern "C" fn(*mut u8, u8, u64) = unsafe { core::mem::transmute(5usize) }; // 5 is the code for "sol_memset_"
syscall(dest, c, n)
}
}
Expand Down

0 comments on commit 21947f9

Please sign in to comment.