Skip to content

use #[naked] as an unsafe attribute #817

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler-builtins/src/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use core::intrinsics;

intrinsics! {
#[naked]
#[unsafe(naked)]
#[cfg(all(target_os = "uefi", not(feature = "no-asm")))]
pub unsafe extern "C" fn __chkstk() {
core::arch::naked_asm!(
Expand Down
8 changes: 4 additions & 4 deletions compiler-builtins/src/aarch64_linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ macro_rules! compare_and_swap {
($ordering:ident, $bytes:tt, $name:ident) => {
intrinsics! {
#[maybe_use_optimized_c_shim]
#[naked]
#[unsafe(naked)]
pub unsafe extern "C" fn $name (
expected: int_ty!($bytes), desired: int_ty!($bytes), ptr: *mut int_ty!($bytes)
) -> int_ty!($bytes) {
Expand Down Expand Up @@ -161,7 +161,7 @@ macro_rules! compare_and_swap_i128 {
($ordering:ident, $name:ident) => {
intrinsics! {
#[maybe_use_optimized_c_shim]
#[naked]
#[unsafe(naked)]
pub unsafe extern "C" fn $name (
expected: i128, desired: i128, ptr: *mut i128
) -> i128 {
Expand Down Expand Up @@ -190,7 +190,7 @@ macro_rules! swap {
($ordering:ident, $bytes:tt, $name:ident) => {
intrinsics! {
#[maybe_use_optimized_c_shim]
#[naked]
#[unsafe(naked)]
pub unsafe extern "C" fn $name (
left: int_ty!($bytes), right_ptr: *mut int_ty!($bytes)
) -> int_ty!($bytes) {
Expand All @@ -215,7 +215,7 @@ macro_rules! fetch_op {
($ordering:ident, $bytes:tt, $name:ident, $op:literal) => {
intrinsics! {
#[maybe_use_optimized_c_shim]
#[naked]
#[unsafe(naked)]
pub unsafe extern "C" fn $name (
val: int_ty!($bytes), ptr: *mut int_ty!($bytes)
) -> int_ty!($bytes) {
Expand Down
8 changes: 4 additions & 4 deletions compiler-builtins/src/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ macro_rules! bl {
intrinsics! {
// NOTE This function and the ones below are implemented using assembly because they are using a
// custom calling convention which can't be implemented using a normal Rust function.
#[naked]
#[unsafe(naked)]
#[cfg(not(target_env = "msvc"))]
pub unsafe extern "C" fn __aeabi_uidivmod() {
core::arch::naked_asm!(
Expand All @@ -34,7 +34,7 @@ intrinsics! {
);
}

#[naked]
#[unsafe(naked)]
pub unsafe extern "C" fn __aeabi_uldivmod() {
core::arch::naked_asm!(
"push {{r4, lr}}",
Expand All @@ -49,7 +49,7 @@ intrinsics! {
);
}

#[naked]
#[unsafe(naked)]
pub unsafe extern "C" fn __aeabi_idivmod() {
core::arch::naked_asm!(
"push {{r0, r1, r4, lr}}",
Expand All @@ -61,7 +61,7 @@ intrinsics! {
);
}

#[naked]
#[unsafe(naked)]
pub unsafe extern "C" fn __aeabi_ldivmod() {
core::arch::naked_asm!(
"push {{r4, lr}}",
Expand Down
4 changes: 2 additions & 2 deletions compiler-builtins/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ macro_rules! intrinsics {
// Naked functions are special: we can't generate wrappers for them since
// they use a custom calling convention.
(
#[naked]
#[unsafe(naked)]
$(#[$($attr:tt)*])*
pub unsafe extern $abi:tt fn $name:ident( $($argname:ident: $ty:ty),* ) $(-> $ret:ty)? {
$($body:tt)*
Expand All @@ -433,7 +433,7 @@ macro_rules! intrinsics {
) => (
// `#[naked]` definitions are referenced by other places, so we can't use `cfg` like the others
pub mod $name {
#[naked]
#[unsafe(naked)]
$(#[$($attr)*])*
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
#[cfg_attr(not(any(all(windows, target_env = "gnu"), target_os = "cygwin")), linkage = "weak")]
Expand Down
4 changes: 2 additions & 2 deletions compiler-builtins/src/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use core::intrinsics;
// NOTE These functions are never mangled as they are not tested against compiler-rt

intrinsics! {
#[naked]
#[unsafe(naked)]
#[cfg(all(
any(all(windows, target_env = "gnu"), target_os = "uefi"),
not(feature = "no-asm")
Expand All @@ -20,7 +20,7 @@ intrinsics! {
);
}

#[naked]
#[unsafe(naked)]
#[cfg(all(
any(all(windows, target_env = "gnu"), target_os = "uefi"),
not(feature = "no-asm")
Expand Down
2 changes: 1 addition & 1 deletion compiler-builtins/src/x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use core::intrinsics;
// NOTE These functions are never mangled as they are not tested against compiler-rt

intrinsics! {
#[naked]
#[unsafe(naked)]
#[cfg(all(
any(
all(windows, target_env = "gnu"),
Expand Down
Loading