File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,25 @@ r[attributes.codegen.naked]
5252r[ attributes.codegen.naked.intro]
5353The * ` naked ` [ attribute] * prevents the compiler from emitting a function prologue and epilogue for the attributed function.
5454
55+ > [ !EXAMPLE]
56+ > ``` rust
57+ > # #[cfg(target_arch = " x86_64" )] {
58+ > /// Adds 3 to the given number.
59+ > ///
60+ > /// SAFETY: The validity of the used registers
61+ > /// is guaranteed according to the "sysv64" ABI.
62+ > #[unsafe (naked)]
63+ > pub extern " sysv64" fn add_n (number : usize ) -> usize {
64+ > core :: arch :: naked_asm! (
65+ > " add rdi, {}" ,
66+ > " mov rax, rdi" ,
67+ > " ret" ,
68+ > const 3 ,
69+ > )
70+ > }
71+ > # }
72+ > ```
73+
5574r [attributes . codegen. naked. body]
5675The [function body ] must consist of exactly one [`naked_asm! `] macro invocation .
5776
You can’t perform that action at this time.
0 commit comments