Skip to content

Commit bcbcb50

Browse files
authored
Fix warnings on nightly regarding "extern" functions (#2585)
"extern" without an ABI is deprecated. So we need to explicitly use "extern C".
1 parent a331671 commit bcbcb50

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/sys/signal.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -757,11 +757,11 @@ pub enum SigHandler {
757757
/// Request that the signal be ignored.
758758
SigIgn,
759759
/// Use the given signal-catching function, which takes in the signal.
760-
Handler(extern fn(libc::c_int)),
760+
Handler(extern "C" fn(libc::c_int)),
761761
/// Use the given signal-catching function, which takes in the signal, information about how
762762
/// the signal was generated, and a pointer to the threads `ucontext_t`.
763763
#[cfg(not(target_os = "redox"))]
764-
SigAction(extern fn(libc::c_int, *mut libc::siginfo_t, *mut libc::c_void))
764+
SigAction(extern "C" fn(libc::c_int, *mut libc::siginfo_t, *mut libc::c_void))
765765
}
766766

767767
/// Action to take on receipt of a signal. Corresponds to `sigaction`.
@@ -790,9 +790,9 @@ impl SigAction {
790790
(*p).sa_sigaction = match handler {
791791
SigHandler::SigDfl => libc::SIG_DFL,
792792
SigHandler::SigIgn => libc::SIG_IGN,
793-
SigHandler::Handler(f) => f as *const extern fn(libc::c_int) as usize,
793+
SigHandler::Handler(f) => f as *const extern "C" fn(libc::c_int) as usize,
794794
#[cfg(not(target_os = "redox"))]
795-
SigHandler::SigAction(f) => f as *const extern fn(libc::c_int, *mut libc::siginfo_t, *mut libc::c_void) as usize,
795+
SigHandler::SigAction(f) => f as *const extern "C" fn(libc::c_int, *mut libc::siginfo_t, *mut libc::c_void) as usize,
796796
};
797797
}
798798
}
@@ -852,9 +852,9 @@ impl SigAction {
852852
// ensured that it is correctly initialized.
853853
unsafe{
854854
*(&p as *const usize
855-
as *const extern fn(_, _, _))
855+
as *const extern "C" fn(_, _, _))
856856
}
857-
as extern fn(_, _, _)),
857+
as extern "C" fn(_, _, _)),
858858
p => SigHandler::Handler(
859859
// Safe for one of two reasons:
860860
// * The SigHandler was created by SigHandler::new, in which
@@ -864,9 +864,9 @@ impl SigAction {
864864
// ensured that it is correctly initialized.
865865
unsafe{
866866
*(&p as *const usize
867-
as *const extern fn(libc::c_int))
867+
as *const extern "C" fn(libc::c_int))
868868
}
869-
as extern fn(libc::c_int)),
869+
as extern "C" fn(libc::c_int)),
870870
}
871871
}
872872

@@ -880,12 +880,12 @@ impl SigAction {
880880
p if self.flags().contains(SaFlags::SA_SIGINFO) =>
881881
SigHandler::SigAction(
882882
*(&p as *const usize
883-
as *const extern fn(_, _, _))
884-
as extern fn(_, _, _)),
883+
as *const extern "C" fn(_, _, _))
884+
as extern "C" fn(_, _, _)),
885885
p => SigHandler::Handler(
886886
*(&p as *const usize
887-
as *const extern fn(libc::c_int))
888-
as extern fn(libc::c_int)),
887+
as *const extern "C" fn(libc::c_int))
888+
as extern "C" fn(libc::c_int)),
889889
}
890890
}
891891
}
@@ -947,7 +947,7 @@ pub unsafe fn sigaction(signal: Signal, sigaction: &SigAction) -> Result<SigActi
947947
/// # use nix::sys::signal::{self, Signal, SigHandler};
948948
/// static SIGNALED: AtomicBool = AtomicBool::new(false);
949949
///
950-
/// extern fn handle_sigint(signal: libc::c_int) {
950+
/// extern "C" fn handle_sigint(signal: libc::c_int) {
951951
/// let signal = Signal::try_from(signal).unwrap();
952952
/// SIGNALED.store(signal == Signal::SIGINT, Ordering::Relaxed);
953953
/// }
@@ -984,7 +984,7 @@ pub unsafe fn signal(signal: Signal, handler: SigHandler) -> Result<SigHandler>
984984
libc::SIG_DFL => SigHandler::SigDfl,
985985
libc::SIG_IGN => SigHandler::SigIgn,
986986
p => SigHandler::Handler(
987-
unsafe { *(&p as *const usize as *const extern fn(libc::c_int)) } as extern fn(libc::c_int)),
987+
unsafe { *(&p as *const usize as *const extern "C" fn(libc::c_int)) } as extern "C" fn(libc::c_int)),
988988
}
989989
})
990990
}

src/sys/statfs.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ pub type fsid_t = libc::fsid_t;
2525
cfg_if! {
2626
if #[cfg(any(linux_android, target_os = "fuchsia"))] {
2727
type type_of_statfs = libc::statfs64;
28-
const LIBC_FSTATFS: unsafe extern fn
28+
const LIBC_FSTATFS: unsafe extern "C" fn
2929
(fd: libc::c_int, buf: *mut type_of_statfs) -> libc::c_int
3030
= libc::fstatfs64;
31-
const LIBC_STATFS: unsafe extern fn
31+
const LIBC_STATFS: unsafe extern "C" fn
3232
(path: *const libc::c_char, buf: *mut type_of_statfs) -> libc::c_int
3333
= libc::statfs64;
3434
} else {
3535
type type_of_statfs = libc::statfs;
36-
const LIBC_FSTATFS: unsafe extern fn
36+
const LIBC_FSTATFS: unsafe extern "C" fn
3737
(fd: libc::c_int, buf: *mut type_of_statfs) -> libc::c_int
3838
= libc::fstatfs;
39-
const LIBC_STATFS: unsafe extern fn
39+
const LIBC_STATFS: unsafe extern "C" fn
4040
(path: *const libc::c_char, buf: *mut type_of_statfs) -> libc::c_int
4141
= libc::statfs;
4242
}

0 commit comments

Comments
 (0)