Mark extern blocks as unsafe

This commit is contained in:
Michael Goulet 2025-02-07 19:42:33 +00:00
parent 04bbc8340a
commit a4e7f8f9bf
66 changed files with 132 additions and 132 deletions

View file

@ -56,15 +56,15 @@ cfg_if::cfg_if! {
compile_error!("`llvm-libunwind` and `system-llvm-libunwind` cannot be enabled at the same time");
} else if #[cfg(feature = "llvm-libunwind")] {
#[link(name = "unwind", kind = "static", modifiers = "-bundle")]
extern "C" {}
unsafe extern "C" {}
} else if #[cfg(feature = "system-llvm-libunwind")] {
#[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
#[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
extern "C" {}
unsafe extern "C" {}
} else {
#[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
extern "C" {}
unsafe extern "C" {}
}
}
@ -76,11 +76,11 @@ cfg_if::cfg_if! {
compile_error!("`llvm-libunwind` and `system-llvm-libunwind` cannot be enabled at the same time");
} else if #[cfg(feature = "llvm-libunwind")] {
#[link(name = "unwind", kind = "static", modifiers = "-bundle")]
extern "C" {}
unsafe extern "C" {}
} else {
#[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
#[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
extern "C" {}
unsafe extern "C" {}
}
}
@ -91,14 +91,14 @@ cfg_if::cfg_if! {
} else {
#[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
#[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
extern "C" {}
unsafe extern "C" {}
}
}
// Android's unwinding library depends on dl_iterate_phdr in `libdl`.
#[cfg(target_os = "android")]
#[link(name = "dl", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
#[link(name = "dl", cfg(not(target_feature = "crt-static")))]
extern "C" {}
unsafe extern "C" {}
// When building with crt-static, we get `gcc_eh` from the `libc` crate, since
// glibc needs it, and needs it listed later on the linker command line. We
@ -110,7 +110,7 @@ extern "C" {}
not(feature = "system-llvm-libunwind")
))]
#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
extern "C" {}
unsafe extern "C" {}
#[cfg(all(
target_os = "linux",
@ -119,67 +119,67 @@ extern "C" {}
feature = "system-llvm-libunwind"
))]
#[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
extern "C" {}
unsafe extern "C" {}
#[cfg(target_os = "redox")]
#[link(name = "gcc_eh", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
extern "C" {}
unsafe extern "C" {}
#[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
#[link(name = "unwind", kind = "static", modifiers = "-bundle")]
extern "C" {}
unsafe extern "C" {}
#[cfg(target_os = "netbsd")]
#[link(name = "gcc_s")]
extern "C" {}
unsafe extern "C" {}
#[cfg(target_os = "freebsd")]
#[link(name = "gcc", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
#[link(name = "gcc_eh", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
extern "C" {}
unsafe extern "C" {}
#[cfg(all(target_os = "openbsd", target_arch = "sparc64"))]
#[link(name = "gcc")]
extern "C" {}
unsafe extern "C" {}
#[cfg(all(target_os = "openbsd", not(target_arch = "sparc64")))]
#[link(name = "c++abi")]
extern "C" {}
unsafe extern "C" {}
#[cfg(any(target_os = "solaris", target_os = "illumos"))]
#[link(name = "gcc_s")]
extern "C" {}
unsafe extern "C" {}
#[cfg(target_os = "dragonfly")]
#[link(name = "gcc_pic")]
extern "C" {}
unsafe extern "C" {}
#[cfg(target_os = "haiku")]
#[link(name = "gcc_s")]
extern "C" {}
unsafe extern "C" {}
#[cfg(target_os = "aix")]
#[link(name = "unwind")]
extern "C" {}
unsafe extern "C" {}
#[cfg(target_os = "nto")]
cfg_if::cfg_if! {
if #[cfg(target_env = "nto70")] {
#[link(name = "gcc")]
extern "C" {}
unsafe extern "C" {}
} else {
#[link(name = "gcc_s")]
extern "C" {}
unsafe extern "C" {}
}
}
#[cfg(target_os = "hurd")]
#[link(name = "gcc_s")]
extern "C" {}
unsafe extern "C" {}
#[cfg(all(target_os = "windows", target_env = "gnu", target_abi = "llvm"))]
#[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
#[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
extern "C" {}
unsafe extern "C" {}

View file

@ -108,10 +108,10 @@ pub type _Unwind_Exception_Cleanup_Fn =
),
link(name = "unwind", kind = "static", modifiers = "-bundle")
)]
extern "C-unwind" {
unsafe extern "C-unwind" {
pub fn _Unwind_Resume(exception: *mut _Unwind_Exception) -> !;
}
extern "C" {
unsafe extern "C" {
pub fn _Unwind_DeleteException(exception: *mut _Unwind_Exception);
pub fn _Unwind_GetLanguageSpecificData(ctx: *mut _Unwind_Context) -> *mut c_void;
pub fn _Unwind_GetRegionStart(ctx: *mut _Unwind_Context) -> _Unwind_Ptr;
@ -140,7 +140,7 @@ if #[cfg(any(target_vendor = "apple", target_os = "netbsd", not(target_arch = "a
all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux", target_os = "xous")),
link(name = "unwind", kind = "static", modifiers = "-bundle")
)]
extern "C" {
unsafe extern "C" {
pub fn _Unwind_GetGR(ctx: *mut _Unwind_Context, reg_index: c_int) -> _Unwind_Word;
pub fn _Unwind_SetGR(ctx: *mut _Unwind_Context, reg_index: c_int, value: _Unwind_Word);
pub fn _Unwind_GetIP(ctx: *mut _Unwind_Context) -> _Unwind_Word;
@ -198,7 +198,7 @@ if #[cfg(any(target_vendor = "apple", target_os = "netbsd", not(target_arch = "a
all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux", target_os = "xous")),
link(name = "unwind", kind = "static", modifiers = "-bundle")
)]
extern "C" {
unsafe extern "C" {
fn _Unwind_VRS_Get(ctx: *mut _Unwind_Context,
regclass: _Unwind_VRS_RegClass,
regno: _Unwind_Word,
@ -261,7 +261,7 @@ cfg_if::cfg_if! {
if #[cfg(all(target_vendor = "apple", not(target_os = "watchos"), target_arch = "arm"))] {
// 32-bit ARM Apple (except for watchOS armv7k specifically) uses SjLj and
// does not provide _Unwind_Backtrace()
extern "C-unwind" {
unsafe extern "C-unwind" {
pub fn _Unwind_SjLj_RaiseException(e: *mut _Unwind_Exception) -> _Unwind_Reason_Code;
}
@ -271,14 +271,14 @@ if #[cfg(all(target_vendor = "apple", not(target_os = "watchos"), target_arch =
all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux", target_os = "xous")),
link(name = "unwind", kind = "static", modifiers = "-bundle")
)]
extern "C-unwind" {
unsafe extern "C-unwind" {
pub fn _Unwind_RaiseException(exception: *mut _Unwind_Exception) -> _Unwind_Reason_Code;
}
#[cfg_attr(
all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux", target_os = "xous")),
link(name = "unwind", kind = "static", modifiers = "-bundle")
)]
extern "C" {
unsafe extern "C" {
pub fn _Unwind_Backtrace(trace: _Unwind_Trace_Fn,
trace_argument: *mut c_void)
-> _Unwind_Reason_Code;
@ -302,7 +302,7 @@ if #[cfg(all(windows, any(target_arch = "aarch64", target_arch = "x86_64"), targ
context: *mut _Unwind_Context)
-> _Unwind_Reason_Code;
extern "C" {
unsafe extern "C" {
pub fn _GCC_specific_handler(exceptionRecord: *mut EXCEPTION_RECORD,
establisherFrame: LPVOID,
contextRecord: *mut CONTEXT,