#assembly #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 199/week @ 2025-09-16 199/week @ 2025-09-23 179/week @ 2025-09-30 137/week @ 2025-10-07 272/week @ 2025-10-14 261/week @ 2025-10-21 224/week @ 2025-10-28 208/week @ 2025-11-04 187/week @ 2025-11-11 241/week @ 2025-11-18 134/week @ 2025-11-25 194/week @ 2025-12-02 101/week @ 2025-12-09 108/week @ 2025-12-16 69/week @ 2025-12-23 55/week @ 2025-12-30

378 downloads per month
Used in 3 crates (via naked-function)

MIT/Apache

19KB
381 lines

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

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


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

~160–580KB
~14K SLoC