diff --git a/redox-rt/src/arch/x86_64.rs b/redox-rt/src/arch/x86_64.rs index b93c59b1d6..56e10e2b00 100644 --- a/redox-rt/src/arch/x86_64.rs +++ b/redox-rt/src/arch/x86_64.rs @@ -464,15 +464,15 @@ pub unsafe fn arch_pre(stack: &mut SigStack, area: &mut SigArea) -> PosixStackt // atomicity inside the critical section, consisting of one instruction at 'crit_first', one at // 'crit_second', and one at 'crit_third', see asm. - if stack.regs.rip == __relibc_internal_sigentry_crit_first as usize { + if stack.regs.rip == __relibc_internal_sigentry_crit_first as *const () as usize { // Reexecute pop rsp and jump steps. This case needs to be different from the one below, // since rsp has not been overwritten with the previous context's stack, just yet. At this // point, we know [rsp+0] contains the saved RSP, and [rsp-8] contains the saved RIP. let stack_ptr = stack.regs.rsp as *const usize; stack.regs.rsp = unsafe { stack_ptr.read() }; stack.regs.rip = unsafe { stack_ptr.sub(1).read() }; - } else if stack.regs.rip == __relibc_internal_sigentry_crit_second as usize - || stack.regs.rip == __relibc_internal_sigentry_crit_third as usize + } else if stack.regs.rip == __relibc_internal_sigentry_crit_second as *const () as usize + || stack.regs.rip == __relibc_internal_sigentry_crit_third as *const () as usize { // Almost finished, just reexecute the jump before tmp_rip is overwritten by this // deeper-level signal. @@ -485,7 +485,10 @@ pub unsafe fn arch_pre(stack: &mut SigStack, area: &mut SigArea) -> PosixStackt /// Rearrange the restore-stack and sigarea in a way that makes it look like a new signal was /// immediately delivered after restoring the allowset to what it was prior to the original signal delivery. pub fn arch_ret_to_sig(stack: &mut SigStack, control: &Sigcontrol) { - let orig_rip = core::mem::replace(&mut stack.regs.rip, __relibc_internal_sigentry as usize); + let orig_rip = core::mem::replace( + &mut stack.regs.rip, + __relibc_internal_sigentry as *const () as usize, + ); control.saved_ip.set(orig_rip); control.saved_archdep_reg.set(stack.regs.rflags); } diff --git a/redox-rt/src/proc.rs b/redox-rt/src/proc.rs index 48cce3453d..c79d475d75 100644 --- a/redox-rt/src/proc.rs +++ b/redox-rt/src/proc.rs @@ -1024,7 +1024,7 @@ pub fn fork_inner(initial_rsp: *mut usize, args: &ForkArgs) -> Result { ))] let buf = create_set_addr_space_buf_for_fork( new_addr_space_fd.as_raw_fd(), - __relibc_internal_fork_ret as usize, + __relibc_internal_fork_ret as *const () as usize, initial_rsp as usize, arg1, ); diff --git a/redox-rt/src/signal.rs b/redox-rt/src/signal.rs index 65636b6546..bf30d98dae 100644 --- a/redox-rt/src/signal.rs +++ b/redox-rt/src/signal.rs @@ -24,7 +24,7 @@ static CPUID_EAX1_ECX: core::sync::atomic::AtomicU32 = core::sync::atomic::Atomi pub fn sighandler_function() -> usize { // TODO: HWCAP? - __relibc_internal_sigentry as usize + __relibc_internal_sigentry as *const () as usize } /// ucontext_t representation @@ -409,7 +409,7 @@ fn convert_old(action: &RawAction) -> Sigaction { let handler = (old_first & !(u64::from(STORED_FLAGS) << 32)) as usize; let flags = SigactionFlags::from_bits_retain(((old_first >> 32) as u32) & STORED_FLAGS); - let kind = if handler == default_handler as usize { + let kind = if handler == default_handler as *const () as usize { SigactionKind::Default } else if flags.contains(SigactionFlags::IGNORED) { SigactionKind::Ignore @@ -492,7 +492,7 @@ fn sigaction_inner( MASK_DONTCARE, SigactionFlags::IGNORED, if matches!(new.kind, SigactionKind::Default) { - default_handler as usize + default_handler as *const () as usize } else { 0 }, @@ -502,7 +502,7 @@ fn sigaction_inner( (SIGTSTP | SIGTTOU | SIGTTIN, SigactionKind::Default) => ( MASK_DONTCARE, SigactionFlags::SIG_SPECIFIC, - default_handler as usize, + default_handler as *const () as usize, ), (SIGCHLD, SigactionKind::Default) => { let nocldstop_bit = new.flags & SigactionFlags::SIG_SPECIFIC; @@ -519,11 +519,11 @@ fn sigaction_inner( ( MASK_DONTCARE, SigactionFlags::IGNORED | nocldstop_bit, - default_handler as usize, + default_handler as *const () as usize, ) } - (_, SigactionKind::Default) => (new.mask, new.flags, default_handler as usize), + (_, SigactionKind::Default) => (new.mask, new.flags, default_handler as *const () as usize), (_, SigactionKind::Handled { .. }) => (new.mask, new.flags, explicit_handler), }; let new_first = (handler as u64) | (u64::from(flags.bits() & STORED_FLAGS) << 32); @@ -635,7 +635,7 @@ pub fn setup_sighandler(tcb: &RtTcb, first_thread: bool) { SigactionFlags::empty() }; action.first.store( - (u64::from(bits.bits()) << 32) | default_handler as u64, + (u64::from(bits.bits()) << 32) | default_handler as *const () as u64, Ordering::Relaxed, ); } diff --git a/src/header/err/mod.rs b/src/header/err/mod.rs index 9e2bf400ec..b15339c94b 100644 --- a/src/header/err/mod.rs +++ b/src/header/err/mod.rs @@ -33,21 +33,21 @@ use crate::{ // Optional callback from user invoked on exit. type ExitCallback = Option; -static mut on_exit: ExitCallback = None; +static mut ON_EXIT: ExitCallback = None; // Messages from this module are written to this sink. -static mut error_sink: *mut FILE = ptr::null_mut(); +static mut ERROR_SINK: *mut FILE = ptr::null_mut(); /// Set global [`FILE`] sink to write errors and warnings. #[unsafe(no_mangle)] pub unsafe extern "C" fn err_set_file(fp: *mut FILE) { if fp.is_null() { unsafe { - error_sink = stdio::stderr; + ERROR_SINK = stdio::stderr; } } else { unsafe { - error_sink = fp; + ERROR_SINK = fp; } } } @@ -56,7 +56,7 @@ pub unsafe extern "C" fn err_set_file(fp: *mut FILE) { #[unsafe(no_mangle)] pub unsafe extern "C" fn err_set_exit(ef: ExitCallback) { unsafe { - on_exit = ef; + ON_EXIT = ef; } } @@ -174,14 +174,14 @@ pub unsafe extern "C" fn vwarnx(fmt: *const c_char, args: va_list) { // Write error messages for err and warn to the currently set sink. unsafe fn display_message(code: Option, fmt: *const c_char, args: va_list) { // SAFETY: - // * error_sink is only null once on start but otherwise always stderr or a user set file + // * ERROR_SINK is only null once on start but otherwise always stderr or a user set file // * User is trusted to pass in a valid file pointer if err_set_file is used - if unsafe { error_sink.is_null() } { + if unsafe { ERROR_SINK.is_null() } { unsafe { - error_sink = stdio::stderr; + ERROR_SINK = stdio::stderr; } } - let sink = unsafe { error_sink }; + let sink = unsafe { ERROR_SINK }; // "progname:" is always printed // SAFETY: @@ -223,7 +223,7 @@ unsafe fn err_exit(eval: c_int, code: Option, fmt: *const c_char, args: v display_message(code, fmt, args); } - if let Some(callback) = unsafe { on_exit } { + if let Some(callback) = unsafe { ON_EXIT } { // errx will hit the unwrap. unsafe { callback(code.unwrap_or_else(|| ERRNO.get())); diff --git a/src/platform/redox/mod.rs b/src/platform/redox/mod.rs index 16c90f4595..54967ade95 100644 --- a/src/platform/redox/mod.rs +++ b/src/platform/redox/mod.rs @@ -93,18 +93,6 @@ fn cvt_uid(id: c_int) -> Result> { Ok(Some(id.try_into().map_err(|_| Errno(EINVAL))?)) } -macro_rules! path_from_c_str { - ($c_str:expr) => {{ - match $c_str.to_str() { - Ok(ok) => ok, - Err(err) => { - ERRNO.set(EINVAL); - return -1; - } - } - }}; -} - static CLONE_LOCK: RwLock<()> = RwLock::new(()); /// Redox syscall implementation of [`Pal`]. @@ -1228,12 +1216,12 @@ impl Pal for Sys { return Err(Errno(EINVAL)); } } else if evp.sigev_notify == SIGEV_SIGNAL { - const n_sig: i32 = NSIG as i32; - const rt_min: i32 = SIGRTMIN as i32; - const rt_max: i32 = SIGRTMIN as i32; + const N_SIG: i32 = NSIG as i32; + const RT_MIN: i32 = SIGRTMIN as i32; + const RT_MAX: i32 = SIGRTMIN as i32; match evp.sigev_signo { - 0..n_sig => {} - rt_min..=rt_max => {} + 0..N_SIG => {} + RT_MIN..=RT_MAX => {} _ => { return Err(Errno(EINVAL)); } diff --git a/src/platform/redox/socket.rs b/src/platform/redox/socket.rs index 553b053882..296263169d 100644 --- a/src/platform/redox/socket.rs +++ b/src/platform/redox/socket.rs @@ -255,9 +255,7 @@ unsafe fn serialize_ancillary_data_to_stream( } let mut cmsg: *mut cmsghdr = unsafe { CMSG_FIRSTHDR(msg) }; - let mut cmsg_count = 0; while !cmsg.is_null() { - cmsg_count += 1; let current_cmsg = unsafe { &*cmsg }; let min_cmsg_len = unsafe { CMSG_ALIGN(mem::size_of::()) }; if current_cmsg.cmsg_len < min_cmsg_len { diff --git a/src/pthread/mod.rs b/src/pthread/mod.rs index 9b1f100de5..f2637202e9 100644 --- a/src/pthread/mod.rs +++ b/src/pthread/mod.rs @@ -110,12 +110,11 @@ pub(crate) unsafe fn create( ) -> Result { let attrs = attrs.cloned().unwrap_or_default(); + #[cfg(not(target_os = "redox"))] let mut current_sigmask = 0_u64; #[cfg(target_os = "redox")] - { - current_sigmask = - redox_rt::signal::get_sigmask().expect("failed to obtain sigprocmask for caller"); - } + let mut current_sigmask = + redox_rt::signal::get_sigmask().expect("failed to obtain sigprocmask for caller"); // Create a locked mutex, unlocked by the thread after it has started. let synchronization_mutex = unsafe { Mutex::locked(current_sigmask) };