diff --git a/src/cxa.rs b/src/cxa.rs index 6de8731c69844c17cb12aaffde28775dd36b5710..fa5574c47fe92dc7793cc1368be084172c302269 100644 --- a/src/cxa.rs +++ b/src/cxa.rs @@ -1,10 +1,12 @@ use platform::types::*; +// TODO: Implement cxa_finalize and uncomment this + #[derive(Clone, Copy)] struct CxaAtExitFunc { - func: extern "C" fn(*mut c_void), - arg: *mut c_void, - dso: *mut c_void, + //func: extern "C" fn(*mut c_void), + //arg: *mut c_void, + //dso: *mut c_void, } static mut CXA_ATEXIT_FUNCS: [Option<CxaAtExitFunc>; 32] = [None; 32]; @@ -17,12 +19,10 @@ pub unsafe extern "C" fn __cxa_atexit( ) -> c_int { for item in &mut CXA_ATEXIT_FUNCS { if item.is_none() { - *item = func_opt.map(|func| CxaAtExitFunc { func, arg, dso }); + *item = func_opt.map(|func| CxaAtExitFunc {} /*{ func, arg, dso }*/); return 0; } } -1 } - -// TODO: cxa_finalize diff --git a/src/header/dlfcn/mod.rs b/src/header/dlfcn/mod.rs index 173666564d1d4036d4572b1c25ba122bbaa75de8..f0c895fbf1aff7d5b3d0239dfef2123d2fb366a8 100644 --- a/src/header/dlfcn/mod.rs +++ b/src/header/dlfcn/mod.rs @@ -1,6 +1,6 @@ //! dlfcn implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/dlfcn.h.html -use core::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; +use core::sync::atomic::{AtomicUsize, Ordering}; use core::{ptr, str}; use c_str::CStr; @@ -14,7 +14,7 @@ pub const RTLD_LOCAL: c_int = 0x0000; static ERROR_NOT_SUPPORTED: &'static CStr = c_str!("dlfcn not supported"); #[thread_local] -static ERROR: AtomicUsize = ATOMIC_USIZE_INIT; +static ERROR: AtomicUsize = AtomicUsize::new(0); #[repr(C)] pub struct Dl_info { diff --git a/src/header/netdb/mod.rs b/src/header/netdb/mod.rs index ad4ce9408b0bfadccd33c63d793b43a18a43b909..8bfb17b165b62ebb1d1c4d434dba9edf5f7886fd 100644 --- a/src/header/netdb/mod.rs +++ b/src/header/netdb/mod.rs @@ -17,7 +17,7 @@ use header::fcntl::O_RDONLY; use header::netinet_in::{in_addr, sockaddr_in, sockaddr_in6}; use header::stdlib::atoi; use header::strings::strcasecmp; -use header::sys_socket::constants::{AF_UNSPEC, AF_INET}; +use header::sys_socket::constants::{AF_INET}; use header::sys_socket::{sa_family_t, sockaddr, socklen_t}; use header::unistd::SEEK_SET; use platform; @@ -39,9 +39,6 @@ pub mod host; pub use self::lookup::*; pub mod lookup; -const MAXADDRS: usize = 35; -const MAXALIASES: usize = 35; - #[repr(C)] pub struct hostent { h_name: *mut c_char, @@ -118,15 +115,6 @@ pub const NI_NAMEREQD: c_int = 0x0008; pub const NI_DGRAM: c_int = 0x0010; static mut NETDB: c_int = 0; -static mut NET_ENTRY: netent = netent { - n_name: ptr::null_mut(), - n_aliases: ptr::null_mut(), - n_addrtype: 0, - n_net: 0, -}; -static mut NET_NAME: Option<Vec<u8>> = None; -static mut NET_ALIASES: [*const c_char; MAXALIASES] = [ptr::null(); MAXALIASES]; -static mut NET_NUM: Option<u64> = None; static mut N_POS: usize = 0; static mut NET_STAYOPEN: c_int = 0; @@ -164,8 +152,6 @@ static mut SERV_PROTO: Option<Vec<u8>> = None; static mut S_POS: usize = 0; static mut SERV_STAYOPEN: c_int = 0; -const NULL_ALIASES: [*mut c_char; 2] = [ptr::null_mut(); 2]; - fn bytes_to_box_str(bytes: &[u8]) -> Box<str> { Box::from(core::str::from_utf8(bytes).unwrap_or("")) } @@ -680,9 +666,9 @@ pub unsafe extern "C" fn getaddrinfo( //TODO: Use hints let mut ai_flags = hints_opt.map_or(0, |hints| hints.ai_flags); - let mut ai_family = hints_opt.map_or(AF_UNSPEC, |hints| hints.ai_family); - let mut ai_socktype = hints_opt.map_or(0, |hints| hints.ai_socktype); - let mut ai_protocol = hints_opt.map_or(0, |hints| hints.ai_protocol); + let mut ai_family;// = hints_opt.map_or(AF_UNSPEC, |hints| hints.ai_family); + let ai_socktype = hints_opt.map_or(0, |hints| hints.ai_socktype); + let mut ai_protocol;// = hints_opt.map_or(0, |hints| hints.ai_protocol); *res = ptr::null_mut(); diff --git a/src/header/sgtty/mod.rs b/src/header/sgtty/mod.rs index b5f1a40900858138c3fe904328e32c8041c292d9..6ffeaeb31167e3ecd59d5032d24e861ab758f3de 100644 --- a/src/header/sgtty/mod.rs +++ b/src/header/sgtty/mod.rs @@ -1,15 +1,11 @@ //! sgtty implementation that won't work on redox because no ioctl -use core::fmt::Write; - use header::sys_ioctl::*; -use platform; use platform::types::*; #[no_mangle] pub extern "C" fn gtty(fd: c_int, out: *mut sgttyb) -> c_int { - writeln!( - platform::FileWriter(2), + eprintln!( "unimplemented: gtty({}, {:p})", fd, out diff --git a/src/header/stdio/printf.rs b/src/header/stdio/printf.rs index 7786de019588b31ea5d184a6ab060317ddd26f29..83583dddae185b0c0136984b241dde263b150827 100644 --- a/src/header/stdio/printf.rs +++ b/src/header/stdio/printf.rs @@ -189,7 +189,7 @@ fn float_string(float: c_double, precision: usize, trim: bool) -> String { let mut string = format!("{:.p$}", float, p = precision); if trim { let truncate = { - let mut slice = string.trim_right_matches('0'); + let mut slice = string.trim_end_matches('0'); if slice.ends_with('.') { slice.len() - 1 } else { diff --git a/src/header/stdlib/mod.rs b/src/header/stdlib/mod.rs index 713ba6c25416297f2ceaf1910d40668b3c4869f5..61192f605c9c95be98f15e19a5bd3f6a67877b8e 100644 --- a/src/header/stdlib/mod.rs +++ b/src/header/stdlib/mod.rs @@ -458,7 +458,7 @@ where } let mut rng = JitterRng::new_with_timer(get_nstime); - rng.test_timer(); + let _ = rng.test_timer(); for _ in 0..100 { let char_iter = iter::repeat(()) diff --git a/src/header/string/mod.rs b/src/header/string/mod.rs index 89e68fdd28486d755a4b6da1006fee56f03436c4..ec2598edbf2ba8ce24e562d5e0702ad36db8f2f4 100644 --- a/src/header/string/mod.rs +++ b/src/header/string/mod.rs @@ -217,9 +217,9 @@ pub unsafe extern "C" fn strerror(errnum: c_int) -> *mut c_char { let mut w = platform::StringWriter(strerror_buf.as_mut_ptr(), strerror_buf.len()); if errnum >= 0 && errnum < STR_ERROR.len() as c_int { - w.write_str(STR_ERROR[errnum as usize]); + let _ = w.write_str(STR_ERROR[errnum as usize]); } else { - w.write_fmt(format_args!("Unknown error {}", errnum)); + let _ = w.write_fmt(format_args!("Unknown error {}", errnum)); } strerror_buf.as_mut_ptr() as *mut c_char diff --git a/src/header/strings/mod.rs b/src/header/strings/mod.rs index f40ff6390ca6d3fb7d49697e2ea9325610f0fce3..a0fb773e51a3ccf5f23969eceec37cbd061ca54d 100644 --- a/src/header/strings/mod.rs +++ b/src/header/strings/mod.rs @@ -29,12 +29,12 @@ pub extern "C" fn ffs(i: c_int) -> c_int { } #[no_mangle] -pub unsafe extern "C" fn index(mut s: *const c_char, c: c_int) -> *mut c_char { +pub unsafe extern "C" fn index(s: *const c_char, c: c_int) -> *mut c_char { string::strchr(s, c) } #[no_mangle] -pub unsafe extern "C" fn rindex(mut s: *const c_char, c: c_int) -> *mut c_char { +pub unsafe extern "C" fn rindex(s: *const c_char, c: c_int) -> *mut c_char { string::strrchr(s, c) } diff --git a/src/ld_so/linker.rs b/src/ld_so/linker.rs index 980ff00ef6b12025d825b1b32be40eb848f5a1ba..a48e26dc26d5475de1fc35d79d12a9c0c7df764e 100644 --- a/src/ld_so/linker.rs +++ b/src/ld_so/linker.rs @@ -209,7 +209,7 @@ impl Linker { } // Allocate TLS - let mut tcb = unsafe { Tcb::new(tls_size)? }; + let tcb = unsafe { Tcb::new(tls_size)? }; println!("tcb {:x?}", tcb); // Copy data diff --git a/src/ld_so/start.rs b/src/ld_so/start.rs index 73110e7bcfd7baa9b29342d892598a5d819af276..120c57967bd5619670db0b7a52497c43410e9c90 100644 --- a/src/ld_so/start.rs +++ b/src/ld_so/start.rs @@ -22,7 +22,7 @@ pub extern "C" fn relibc_ld_so_start(sp: &'static mut Stack) -> usize { // Some variables that will be overridden by environment and auxiliary vectors let mut library_path = "/lib"; - let mut page_size = 4096; + //let mut page_size = 4096; // Pop the first argument (path to ld_so), and get the path of the program let path_c = unsafe { @@ -85,10 +85,10 @@ pub extern "C" fn relibc_ld_so_start(sp: &'static mut Stack) -> usize { } println!(" aux: {}={:#x}", kind, value); - match kind { - 6 => page_size = value, - _ => (), - } + //match kind { + // 6 => page_size = value, + // _ => (), + //} } sp.argc -= 1; diff --git a/src/ld_so/tcb.rs b/src/ld_so/tcb.rs index 662ef4c5f595d2eec3cfd7c9ff71353afe44fdfb..17b802ace0443ed3abcc932646c2b9422e3aec6c 100644 --- a/src/ld_so/tcb.rs +++ b/src/ld_so/tcb.rs @@ -3,7 +3,7 @@ use core::{mem, ptr, slice}; use core::ops::Range; use goblin::error::{Error, Result}; -use header::{sys_mman, unistd}; +use header::sys_mman; use super::PAGE_SIZE; diff --git a/src/platform/linux/socket.rs b/src/platform/linux/socket.rs index 6c598ab4c0798bd76ab7f38c17b1cbe5d486daae..442f172c7dbe0d476a8e375002d0a77020cb02d9 100644 --- a/src/platform/linux/socket.rs +++ b/src/platform/linux/socket.rs @@ -3,11 +3,11 @@ use super::super::PalSocket; use super::{e, Sys}; use header::sys_socket::{sockaddr, socklen_t}; -impl Sys { - fn socketpair(domain: c_int, kind: c_int, protocol: c_int, socket_vector: *mut c_int) -> c_int { - e(unsafe { syscall!(SOCKETPAIR, domain, kind, protocol, socket_vector) }) as c_int - } -} +//impl Sys { +// fn socketpair(domain: c_int, kind: c_int, protocol: c_int, socket_vector: *mut c_int) -> c_int { +// e(unsafe { syscall!(SOCKETPAIR, domain, kind, protocol, socket_vector) }) as c_int +// } +//} impl PalSocket for Sys { unsafe fn accept(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> c_int { diff --git a/src/platform/pte.rs b/src/platform/pte.rs index 2948f76df220064753083484cfc1deaa23febad4..3cf3e7e068f848fd828c800f4f68104086d48f02 100644 --- a/src/platform/pte.rs +++ b/src/platform/pte.rs @@ -2,7 +2,7 @@ use alloc::boxed::Box; use alloc::collections::BTreeMap; -use core::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; +use core::sync::atomic::{AtomicUsize, Ordering}; use core::{intrinsics, ptr}; use header::sys_mman; @@ -24,6 +24,7 @@ type pte_osThreadEntryPoint = unsafe extern "C" fn(params: *mut c_void) -> c_int #[repr(C)] #[derive(Eq, PartialEq)] +#[allow(dead_code)] pub enum pte_osResult { PTE_OS_OK = 0, PTE_OS_NO_RESOURCES, @@ -44,7 +45,7 @@ static mut pid_stacks_lock: i32 = 0; #[thread_local] static mut LOCALS: *mut BTreeMap<c_uint, *mut c_void> = ptr::null_mut(); -static NEXT_KEY: AtomicUsize = ATOMIC_USIZE_INIT; +static NEXT_KEY: AtomicUsize = AtomicUsize::new(0); unsafe fn locals() -> &'static mut BTreeMap<c_uint, *mut c_void> { if LOCALS == ptr::null_mut() { @@ -71,7 +72,7 @@ unsafe extern "C" fn pte_osThreadShim( // The kernel allocated TLS does not have masters set, so do not attempt to copy it. // It will be copied by the kernel. if ! tls_masters_ptr.is_null() { - let mut tcb = Tcb::new(tls_size).unwrap(); + let tcb = Tcb::new(tls_size).unwrap(); tcb.masters_ptr = tls_masters_ptr; tcb.masters_len = tls_masters_len; tcb.copy_masters().unwrap();