#asm #naked

no-std naked-function

Proc macro implementation of #[naked]

6 releases

0.1.5 Apr 13, 2023
0.1.4 Apr 7, 2023
0.1.2 Feb 3, 2023
0.1.1 Jan 27, 2023
0.1.0 Aug 12, 2022

#110 in Embedded development

Download history 26/week @ 2023-05-30 5/week @ 2023-06-06 9/week @ 2023-06-13 209/week @ 2023-06-20 520/week @ 2023-06-27 173/week @ 2023-07-04 247/week @ 2023-07-11 148/week @ 2023-07-18 45/week @ 2023-07-25 186/week @ 2023-08-01 210/week @ 2023-08-08 199/week @ 2023-08-15 361/week @ 2023-08-22 205/week @ 2023-08-29 381/week @ 2023-09-05 265/week @ 2023-09-12

1,314 downloads per month
Used in sjlj

MIT/Apache

12KB
221 lines

#[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.

Dependencies

~330–760KB
~18K SLoC