naked-function

Crates.ionaked-function
lib.rsnaked-function
version0.1.5
sourcesrc
created_at2022-08-12 01:26:16.354587
updated_at2023-04-13 17:11:45.568761
descriptionProc macro implementation of #[naked]
homepage
repositoryhttps://github.com/Amanieu/naked-function
max_upload_size
id643683
size28,736
rodio-maintainers (github:rustaudio:rodio-maintainers)

documentation

README

#[naked]

Crates.io

Documentation

This crate provide a proc macro version of the #[naked] attribute which can be used on stable Rust.

Example

// The SYSV64 calling convention used on x86_64 Linux passes the first
// 2 integer arguments in EDI/ESI.
#[naked_function::naked]
pub unsafe extern "C" fn add(a: i32, b: i32) -> i32 {
    asm!(
        "lea eax, [edi + esi]",
        "ret",
    );
}

#[test]
fn main() {
    let ret = unsafe { add(1, 2) };
    assert_eq!(ret, 3);
}

License

Licensed under either of:

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 23

cargo fmt