Skip to content

Fix warnings on nightly regarding "extern" functions #2585

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
Jan 18, 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
28 changes: 14 additions & 14 deletions src/sys/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,11 +757,11 @@ pub enum SigHandler {
/// Request that the signal be ignored.
SigIgn,
/// Use the given signal-catching function, which takes in the signal.
Handler(extern fn(libc::c_int)),
Handler(extern "C" fn(libc::c_int)),
/// Use the given signal-catching function, which takes in the signal, information about how
/// the signal was generated, and a pointer to the threads `ucontext_t`.
#[cfg(not(target_os = "redox"))]
SigAction(extern fn(libc::c_int, *mut libc::siginfo_t, *mut libc::c_void))
SigAction(extern "C" fn(libc::c_int, *mut libc::siginfo_t, *mut libc::c_void))
}

/// Action to take on receipt of a signal. Corresponds to `sigaction`.
Expand Down Expand Up @@ -790,9 +790,9 @@ impl SigAction {
(*p).sa_sigaction = match handler {
SigHandler::SigDfl => libc::SIG_DFL,
SigHandler::SigIgn => libc::SIG_IGN,
SigHandler::Handler(f) => f as *const extern fn(libc::c_int) as usize,
SigHandler::Handler(f) => f as *const extern "C" fn(libc::c_int) as usize,
#[cfg(not(target_os = "redox"))]
SigHandler::SigAction(f) => f as *const extern fn(libc::c_int, *mut libc::siginfo_t, *mut libc::c_void) as usize,
SigHandler::SigAction(f) => f as *const extern "C" fn(libc::c_int, *mut libc::siginfo_t, *mut libc::c_void) as usize,
};
}
}
Expand Down Expand Up @@ -852,9 +852,9 @@ impl SigAction {
// ensured that it is correctly initialized.
unsafe{
*(&p as *const usize
as *const extern fn(_, _, _))
as *const extern "C" fn(_, _, _))
}
as extern fn(_, _, _)),
as extern "C" fn(_, _, _)),
p => SigHandler::Handler(
// Safe for one of two reasons:
// * The SigHandler was created by SigHandler::new, in which
Expand All @@ -864,9 +864,9 @@ impl SigAction {
// ensured that it is correctly initialized.
unsafe{
*(&p as *const usize
as *const extern fn(libc::c_int))
as *const extern "C" fn(libc::c_int))
}
as extern fn(libc::c_int)),
as extern "C" fn(libc::c_int)),
}
}

Expand All @@ -880,12 +880,12 @@ impl SigAction {
p if self.flags().contains(SaFlags::SA_SIGINFO) =>
SigHandler::SigAction(
*(&p as *const usize
as *const extern fn(_, _, _))
as extern fn(_, _, _)),
as *const extern "C" fn(_, _, _))
as extern "C" fn(_, _, _)),
p => SigHandler::Handler(
*(&p as *const usize
as *const extern fn(libc::c_int))
as extern fn(libc::c_int)),
as *const extern "C" fn(libc::c_int))
as extern "C" fn(libc::c_int)),
}
}
}
Expand Down Expand Up @@ -947,7 +947,7 @@ pub unsafe fn sigaction(signal: Signal, sigaction: &SigAction) -> Result<SigActi
/// # use nix::sys::signal::{self, Signal, SigHandler};
/// static SIGNALED: AtomicBool = AtomicBool::new(false);
///
/// extern fn handle_sigint(signal: libc::c_int) {
/// extern "C" fn handle_sigint(signal: libc::c_int) {
/// let signal = Signal::try_from(signal).unwrap();
/// SIGNALED.store(signal == Signal::SIGINT, Ordering::Relaxed);
/// }
Expand Down Expand Up @@ -984,7 +984,7 @@ pub unsafe fn signal(signal: Signal, handler: SigHandler) -> Result<SigHandler>
libc::SIG_DFL => SigHandler::SigDfl,
libc::SIG_IGN => SigHandler::SigIgn,
p => SigHandler::Handler(
unsafe { *(&p as *const usize as *const extern fn(libc::c_int)) } as extern fn(libc::c_int)),
unsafe { *(&p as *const usize as *const extern "C" fn(libc::c_int)) } as extern "C" fn(libc::c_int)),
}
})
}
Expand Down
8 changes: 4 additions & 4 deletions src/sys/statfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ pub type fsid_t = libc::fsid_t;
cfg_if! {
if #[cfg(any(linux_android, target_os = "fuchsia"))] {
type type_of_statfs = libc::statfs64;
const LIBC_FSTATFS: unsafe extern fn
const LIBC_FSTATFS: unsafe extern "C" fn
(fd: libc::c_int, buf: *mut type_of_statfs) -> libc::c_int
= libc::fstatfs64;
const LIBC_STATFS: unsafe extern fn
const LIBC_STATFS: unsafe extern "C" fn
(path: *const libc::c_char, buf: *mut type_of_statfs) -> libc::c_int
= libc::statfs64;
} else {
type type_of_statfs = libc::statfs;
const LIBC_FSTATFS: unsafe extern fn
const LIBC_FSTATFS: unsafe extern "C" fn
(fd: libc::c_int, buf: *mut type_of_statfs) -> libc::c_int
= libc::fstatfs;
const LIBC_STATFS: unsafe extern fn
const LIBC_STATFS: unsafe extern "C" fn
(path: *const libc::c_char, buf: *mut type_of_statfs) -> libc::c_int
= libc::statfs;
}
Expand Down
Loading