#asm #proc-macro #naked

macro no-std naked-function-macro

Proc macro for the naked-function crate

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

#35 in #asm

Download history 46/week @ 2023-12-14 51/week @ 2023-12-21 329/week @ 2023-12-28 106/week @ 2024-01-04 136/week @ 2024-01-11 138/week @ 2024-01-18 73/week @ 2024-01-25 197/week @ 2024-02-01 257/week @ 2024-02-08 198/week @ 2024-02-15 177/week @ 2024-02-22 187/week @ 2024-02-29 223/week @ 2024-03-07 228/week @ 2024-03-14 139/week @ 2024-03-21 93/week @ 2024-03-28

691 downloads per month
Used in 2 crates (via naked-function)

MIT/Apache

19KB
381 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.


lib.rs:

Implementation of the proc macro used by the naked-function crate.

Don't use this crate directly, use the naked-function crate instead.

Dependencies

~0.4–0.8MB
~19K SLoC