diff --git a/fmt.sh b/fmt.sh index cb5a928a33df8657a51debf0a0eb73b84cc3d5c7..be8636e2ab16a4bc43a86d252a7bd77193b6ad4a 100755 --- a/fmt.sh +++ b/fmt.sh @@ -1,9 +1,3 @@ #!/usr/bin/env bash -ARGS=() -for crate in relibc $(find src -name Cargo.toml | cut -d '/' -f2 | grep -v template) -do - ARGS+=("--package" "$crate") -done - -cargo fmt "${ARGS[@]}" "$@" +cargo fmt --package relibc --package crt0 "$@" diff --git a/src/c_str.rs b/src/c_str.rs index 1ad8f2ea6ccc4a6ce49a9ed5cddd305be2101a5c..113015ef46aecfd0808794c7adb72958dcb2c716 100644 --- a/src/c_str.rs +++ b/src/c_str.rs @@ -33,7 +33,8 @@ pub fn memchr(needle: u8, haystack: &[u8]) -> Option<usize> { string::memchr( haystack.as_ptr() as *const c_void, needle as c_int, - haystack.len()) + haystack.len(), + ) }; if p.is_null() { None @@ -222,7 +223,7 @@ pub struct CStr { // just a raw `c_char` along with some form of marker to make // this an unsized type. Essentially `sizeof(&CStr)` should be the // same as `sizeof(&c_char)` but `CStr` should be an unsized type. - inner: [c_char] + inner: [c_char], } /// An error indicating that an interior nul byte was found. @@ -290,10 +291,10 @@ impl FromBytesWithNulError { fn description(&self) -> &str { match self.kind { - FromBytesWithNulErrorKind::InteriorNul(..) => - "data provided contains an interior nul byte", - FromBytesWithNulErrorKind::NotNulTerminated => - "data provided is not nul terminated", + FromBytesWithNulErrorKind::InteriorNul(..) => { + "data provided contains an interior nul byte" + } + FromBytesWithNulErrorKind::NotNulTerminated => "data provided is not nul terminated", } } } @@ -380,7 +381,9 @@ impl CString { pub unsafe fn from_vec_unchecked(mut v: Vec<u8>) -> CString { v.reserve_exact(1); v.push(0); - CString { inner: v.into_boxed_slice() } + CString { + inner: v.into_boxed_slice(), + } } /// Retakes ownership of a `CString` that was transferred to C via [`into_raw`]. @@ -426,7 +429,9 @@ impl CString { pub unsafe fn from_raw(ptr: *mut c_char) -> CString { let len = strlen(ptr) + 1; // Including the NUL byte let slice = slice::from_raw_parts_mut(ptr, len as usize); - CString { inner: Box::from_raw(slice as *mut [c_char] as *mut [u8]) } + CString { + inner: Box::from_raw(slice as *mut [c_char] as *mut [u8]), + } } /// Consumes the `CString` and transfers ownership of the string to a C caller. @@ -486,11 +491,10 @@ impl CString { /// ``` pub fn into_string(self) -> Result<String, IntoStringError> { - String::from_utf8(self.into_bytes()) - .map_err(|e| IntoStringError { - error: e.utf8_error(), - inner: unsafe { CString::from_vec_unchecked(e.into_bytes()) }, - }) + String::from_utf8(self.into_bytes()).map_err(|e| IntoStringError { + error: e.utf8_error(), + inner: unsafe { CString::from_vec_unchecked(e.into_bytes()) }, + }) } /// Consumes the `CString` and returns the underlying byte buffer. @@ -628,7 +632,9 @@ impl CString { impl Drop for CString { #[inline] fn drop(&mut self) { - unsafe { *self.inner.get_unchecked_mut(0) = 0; } + unsafe { + *self.inner.get_unchecked_mut(0) = 0; + } } } @@ -663,7 +669,11 @@ impl From<CString> for Vec<u8> { impl fmt::Debug for CStr { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "\"")?; - for byte in self.to_bytes().iter().flat_map(|&b| ascii::escape_default(b)) { + for byte in self + .to_bytes() + .iter() + .flat_map(|&b| ascii::escape_default(b)) + { f.write_char(byte as char)?; } write!(f, "\"") @@ -687,7 +697,9 @@ impl Default for CString { impl Borrow<CStr> for CString { #[inline] - fn borrow(&self) -> &CStr { self } + fn borrow(&self) -> &CStr { + self + } } impl<'a> From<Cow<'a, CStr>> for CString { @@ -818,7 +830,9 @@ impl NulError { /// let nul_error = CString::new("foo bar\0").unwrap_err(); /// assert_eq!(nul_error.nul_position(), 7); /// ``` - pub fn nul_position(&self) -> usize { self.0 } + pub fn nul_position(&self) -> usize { + self.0 + } /// Consumes this error, returning the underlying vector of bytes which /// generated the error in the first place. @@ -831,9 +845,13 @@ impl NulError { /// let nul_error = CString::new("foo\0bar").unwrap_err(); /// assert_eq!(nul_error.into_vec(), b"foo\0bar"); /// ``` - pub fn into_vec(self) -> Vec<u8> { self.1 } + pub fn into_vec(self) -> Vec<u8> { + self.1 + } - fn description(&self) -> &str { "nul byte found in data" } + fn description(&self) -> &str { + "nul byte found in data" + } } impl fmt::Display for NulError { @@ -951,8 +969,7 @@ impl CStr { /// let c_str = CStr::from_bytes_with_nul(b"he\0llo\0"); /// assert!(c_str.is_err()); /// ``` - pub fn from_bytes_with_nul(bytes: &[u8]) - -> Result<&CStr, FromBytesWithNulError> { + pub fn from_bytes_with_nul(bytes: &[u8]) -> Result<&CStr, FromBytesWithNulError> { let nul_pos = memchr(0, bytes); if let Some(nul_pos) = nul_pos { if nul_pos + 1 != bytes.len() { @@ -1176,7 +1193,9 @@ impl CStr { /// ``` pub fn into_c_string(self: Box<CStr>) -> CString { let raw = Box::into_raw(self) as *mut [u8]; - CString { inner: unsafe { Box::from_raw(raw) } } + CString { + inner: unsafe { Box::from_raw(raw) }, + } } } @@ -1204,7 +1223,9 @@ impl ToOwned for CStr { type Owned = CString; fn to_owned(&self) -> CString { - CString { inner: self.to_bytes_with_nul().into() } + CString { + inner: self.to_bytes_with_nul().into(), + } } } diff --git a/src/crt0/src/lib.rs b/src/crt0/src/lib.rs index d3f1642a9f49219c613a3af3af6173eb1a415248..ca2c2ff2e23620fcb730d8b569f192ff68b18e33 100644 --- a/src/crt0/src/lib.rs +++ b/src/crt0/src/lib.rs @@ -37,7 +37,5 @@ pub extern "C" fn rust_begin_unwind(_pi: &::core::panic::PanicInfo) -> ! { fn exit(status: i32) -> !; } - unsafe { - exit(1) - } + unsafe { exit(1) } } diff --git a/src/header/_todo/oldlib/dns/answer.rs b/src/header/_oldlib/dns/answer.rs similarity index 100% rename from src/header/_todo/oldlib/dns/answer.rs rename to src/header/_oldlib/dns/answer.rs diff --git a/src/header/_todo/oldlib/dns/mod.rs b/src/header/_oldlib/dns/mod.rs similarity index 100% rename from src/header/_todo/oldlib/dns/mod.rs rename to src/header/_oldlib/dns/mod.rs diff --git a/src/header/_todo/oldlib/dns/query.rs b/src/header/_oldlib/dns/query.rs similarity index 100% rename from src/header/_todo/oldlib/dns/query.rs rename to src/header/_oldlib/dns/query.rs diff --git a/src/header/_todo/oldlib/event.rs b/src/header/_oldlib/event.rs similarity index 100% rename from src/header/_todo/oldlib/event.rs rename to src/header/_oldlib/event.rs diff --git a/src/header/_todo/oldlib/file.rs b/src/header/_oldlib/file.rs similarity index 100% rename from src/header/_todo/oldlib/file.rs rename to src/header/_oldlib/file.rs diff --git a/src/header/_todo/oldlib/folder.rs b/src/header/_oldlib/folder.rs similarity index 100% rename from src/header/_todo/oldlib/folder.rs rename to src/header/_oldlib/folder.rs diff --git a/src/header/_todo/oldlib/hostname.rs b/src/header/_oldlib/hostname.rs similarity index 100% rename from src/header/_todo/oldlib/hostname.rs rename to src/header/_oldlib/hostname.rs diff --git a/src/header/_todo/oldlib/lib.rs b/src/header/_oldlib/lib.rs similarity index 100% rename from src/header/_todo/oldlib/lib.rs rename to src/header/_oldlib/lib.rs diff --git a/src/header/_todo/oldlib/macros.rs b/src/header/_oldlib/macros.rs similarity index 100% rename from src/header/_todo/oldlib/macros.rs rename to src/header/_oldlib/macros.rs diff --git a/src/header/_todo/oldlib/mallocnull.rs b/src/header/_oldlib/mallocnull.rs similarity index 100% rename from src/header/_todo/oldlib/mallocnull.rs rename to src/header/_oldlib/mallocnull.rs diff --git a/src/header/_todo/oldlib/netdb.rs b/src/header/_oldlib/netdb.rs similarity index 100% rename from src/header/_todo/oldlib/netdb.rs rename to src/header/_oldlib/netdb.rs diff --git a/src/header/_todo/oldlib/process.rs b/src/header/_oldlib/process.rs similarity index 100% rename from src/header/_todo/oldlib/process.rs rename to src/header/_oldlib/process.rs diff --git a/src/header/_todo/oldlib/rawfile.rs b/src/header/_oldlib/rawfile.rs similarity index 100% rename from src/header/_todo/oldlib/rawfile.rs rename to src/header/_oldlib/rawfile.rs diff --git a/src/header/_todo/oldlib/redox.rs b/src/header/_oldlib/redox.rs similarity index 100% rename from src/header/_todo/oldlib/redox.rs rename to src/header/_oldlib/redox.rs diff --git a/src/header/_todo/oldlib/socket.rs b/src/header/_oldlib/socket.rs similarity index 100% rename from src/header/_todo/oldlib/socket.rs rename to src/header/_oldlib/socket.rs diff --git a/src/header/_todo/oldlib/termios.rs b/src/header/_oldlib/termios.rs similarity index 100% rename from src/header/_todo/oldlib/termios.rs rename to src/header/_oldlib/termios.rs diff --git a/src/header/_todo/oldlib/time.rs b/src/header/_oldlib/time.rs similarity index 100% rename from src/header/_todo/oldlib/time.rs rename to src/header/_oldlib/time.rs diff --git a/src/header/_todo/oldlib/types.rs b/src/header/_oldlib/types.rs similarity index 100% rename from src/header/_todo/oldlib/types.rs rename to src/header/_oldlib/types.rs diff --git a/src/header/_todo/oldlib/unimpl.rs b/src/header/_oldlib/unimpl.rs similarity index 100% rename from src/header/_todo/oldlib/unimpl.rs rename to src/header/_oldlib/unimpl.rs diff --git a/src/header/_todo/oldlib/user.rs b/src/header/_oldlib/user.rs similarity index 100% rename from src/header/_todo/oldlib/user.rs rename to src/header/_oldlib/user.rs diff --git a/src/header/_pthread/cbindgen.toml b/src/header/_pthread/cbindgen.toml new file mode 100644 index 0000000000000000000000000000000000000000..a1ea51c3f35fbfdecd72eca0eac08231f534d976 --- /dev/null +++ b/src/header/_pthread/cbindgen.toml @@ -0,0 +1,7 @@ +sys_includes = [] +include_guard = "_PTHREAD_H" +language = "C" +style = "Tag" + +[enum] +prefix_with_name = true diff --git a/src/header/_todo/pthread/lib.rs b/src/header/_pthread/mod.rs similarity index 69% rename from src/header/_todo/pthread/lib.rs rename to src/header/_pthread/mod.rs index 661c9cdf2813b3367e82e887865f86809169bd0e..b02f301a5177c01f5f50d5a78cd01086b4d136af 100644 --- a/src/header/_todo/pthread/lib.rs +++ b/src/header/_pthread/mod.rs @@ -1,13 +1,26 @@ +use platform::types::*; + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct sched_param { + pub _address: u8, +} +impl Clone for sched_param { + fn clone(&self) -> Self { + *self + } +} + // #[no_mangle] -pub extern "C" fn pthread_attr_destroy(attr: *mut pthread_attr_t) -> libc::c_int { +pub extern "C" fn pthread_attr_destroy(attr: *mut pthread_attr_t) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_attr_getdetachstate( attr: *const pthread_attr_t, - detachstate: *mut libc::c_int, -) -> libc::c_int { + detachstate: *mut c_int, +) -> c_int { unimplemented!(); } @@ -15,15 +28,15 @@ pub extern "C" fn pthread_attr_getdetachstate( pub extern "C" fn pthread_attr_getguardsize( attr: *const pthread_attr_t, guardsize: *mut usize, -) -> libc::c_int { +) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_attr_getinheritsched( attr: *const pthread_attr_t, - inheritsched: *mut libc::c_int, -) -> libc::c_int { + inheritsched: *mut c_int, +) -> c_int { unimplemented!(); } @@ -31,31 +44,31 @@ pub extern "C" fn pthread_attr_getinheritsched( pub extern "C" fn pthread_attr_getschedparam( attr: *const pthread_attr_t, param: *mut sched_param, -) -> libc::c_int { +) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_attr_getschedpolicy( attr: *const pthread_attr_t, - policy: *mut libc::c_int, -) -> libc::c_int { + policy: *mut c_int, +) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_attr_getscope( attr: *const pthread_attr_t, - contentionscope: *mut libc::c_int, -) -> libc::c_int { + contentionscope: *mut c_int, +) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_attr_getstackaddr( attr: *const pthread_attr_t, - stackaddr: *mut *mut libc::c_void, -) -> libc::c_int { + stackaddr: *mut *mut c_void, +) -> c_int { unimplemented!(); } @@ -63,33 +76,33 @@ pub extern "C" fn pthread_attr_getstackaddr( pub extern "C" fn pthread_attr_getstacksize( attr: *const pthread_attr_t, stacksize: *mut usize, -) -> libc::c_int { +) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_attr_init(arg1: *mut pthread_attr_t) -> libc::c_int { +pub extern "C" fn pthread_attr_init(arg1: *mut pthread_attr_t) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_attr_setdetachstate( attr: *mut pthread_attr_t, - detachstate: libc::c_int, -) -> libc::c_int { + detachstate: c_int, +) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_attr_setguardsize(arg1: *mut pthread_attr_t, arg2: usize) -> libc::c_int { +pub extern "C" fn pthread_attr_setguardsize(arg1: *mut pthread_attr_t, arg2: usize) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_attr_setinheritsched( attr: *mut pthread_attr_t, - inheritsched: libc::c_int, -) -> libc::c_int { + inheritsched: c_int, +) -> c_int { unimplemented!(); } @@ -97,61 +110,61 @@ pub extern "C" fn pthread_attr_setinheritsched( pub extern "C" fn pthread_attr_setschedparam( attr: *mut pthread_attr_t, param: *mut sched_param, -) -> libc::c_int { +) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_attr_setschedpolicy( attr: *mut pthread_attr_t, - policy: libc::c_int, -) -> libc::c_int { + policy: c_int, +) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_attr_setscope( attr: *mut pthread_attr_t, - contentionscope: libc::c_int, -) -> libc::c_int { + contentionscope: c_int, +) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_attr_setstackaddr( attr: *mut pthread_attr_t, - stackaddr: *mut libc::c_void, -) -> libc::c_int { + stackaddr: *mut c_void, +) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_attr_setstacksize(attr: *mut pthread_attr_t, stacksize: usize) -> libc::c_int { +pub extern "C" fn pthread_attr_setstacksize(attr: *mut pthread_attr_t, stacksize: usize) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_cancel(thread: pthread_t) -> libc::c_int { +pub extern "C" fn pthread_cancel(thread: pthread_t) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_cleanup_push(routine: *mut libc::c_void, arg: *mut libc::c_void) { +pub extern "C" fn pthread_cleanup_push(routine: *mut c_void, arg: *mut c_void) { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_cleanup_pop(execute: libc::c_int) { +pub extern "C" fn pthread_cleanup_pop(execute: c_int) { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> libc::c_int { +pub extern "C" fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> libc::c_int { +pub extern "C" fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> c_int { unimplemented!(); } @@ -159,12 +172,12 @@ pub extern "C" fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> libc::c_int pub extern "C" fn pthread_cond_init( cond: *mut pthread_cond_t, attr: *const pthread_condattr_t, -) -> libc::c_int { +) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_cond_signal(cond: *mut pthread_cond_t) -> libc::c_int { +pub extern "C" fn pthread_cond_signal(cond: *mut pthread_cond_t) -> c_int { unimplemented!(); } @@ -173,7 +186,7 @@ pub extern "C" fn pthread_cond_timedwait( cond: *mut pthread_cond_t, mutex: *mut pthread_mutex_t, abstime: *const timespec, -) -> libc::c_int { +) -> c_int { unimplemented!(); } @@ -181,33 +194,33 @@ pub extern "C" fn pthread_cond_timedwait( pub extern "C" fn pthread_cond_wait( cond: *mut pthread_cond_t, mutex: *mut pthread_mutex_t, -) -> libc::c_int { +) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> libc::c_int { +pub extern "C" fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_condattr_getpshared( attr: *const pthread_condattr_t, - pshared: *mut libc::c_int, -) -> libc::c_int { + pshared: *mut c_int, +) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> libc::c_int { +pub extern "C" fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_condattr_setpshared( attr: *mut pthread_condattr_t, - pshared: libc::c_int, -) -> libc::c_int { + pshared: c_int, +) -> c_int { unimplemented!(); } @@ -215,74 +228,74 @@ pub extern "C" fn pthread_condattr_setpshared( pub extern "C" fn pthread_create( thread: *mut pthread_t, attr: *const pthread_attr_t, - start_routine: Option<unsafe extern "C" fn(arg1: *mut libc::c_void) -> *mut libc::c_void>, - arg: *mut libc::c_void, -) -> libc::c_int { + start_routine: Option<unsafe extern "C" fn(arg1: *mut c_void) -> *mut c_void>, + arg: *mut c_void, +) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_detach(thread: pthread_t) -> libc::c_int { +pub extern "C" fn pthread_detach(thread: pthread_t) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_equal(t1: pthread_t, t2: pthread_t) -> libc::c_int { +pub extern "C" fn pthread_equal(t1: pthread_t, t2: pthread_t) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_exit(value_ptr: *mut libc::c_void) { +pub extern "C" fn pthread_exit(value_ptr: *mut c_void) { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_getconcurrency() -> libc::c_int { +pub extern "C" fn pthread_getconcurrency() -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_getschedparam( thread: pthread_t, - policy: *mut libc::c_int, + policy: *mut c_int, param: *mut sched_param, -) -> libc::c_int { +) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_getspecific(key: pthread_key_t) -> *mut libc::c_void { +pub extern "C" fn pthread_getspecific(key: pthread_key_t) -> *mut c_void { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_join(thread: pthread_t, value_ptr: *mut *mut libc::c_void) -> libc::c_int { +pub extern "C" fn pthread_join(thread: pthread_t, value_ptr: *mut *mut c_void) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_key_create( key: *mut pthread_key_t, - destructor: Option<unsafe extern "C" fn(arg1: *mut libc::c_void)>, -) -> libc::c_int { + destructor: Option<unsafe extern "C" fn(arg1: *mut c_void)>, +) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_key_delete(key: pthread_key_t) -> libc::c_int { +pub extern "C" fn pthread_key_delete(key: pthread_key_t) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_mutex_destroy(mutex: *mut pthread_mutex_t) -> libc::c_int { +pub extern "C" fn pthread_mutex_destroy(mutex: *mut pthread_mutex_t) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_mutex_getprioceiling( mutex: *const pthread_mutex_t, - prioceiling: *mut libc::c_int, -) -> libc::c_int { + prioceiling: *mut c_int, +) -> c_int { unimplemented!(); } @@ -290,105 +303,105 @@ pub extern "C" fn pthread_mutex_getprioceiling( pub extern "C" fn pthread_mutex_init( mutex: *mut pthread_mutex_t, attr: *const pthread_mutexattr_t, -) -> libc::c_int { +) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_mutex_lock(mutex: *mut pthread_mutex_t) -> libc::c_int { +pub extern "C" fn pthread_mutex_lock(mutex: *mut pthread_mutex_t) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_mutex_setprioceiling( mutex: *mut pthread_mutex_t, - prioceiling: libc::c_int, - old_ceiling: *mut libc::c_int, -) -> libc::c_int { + prioceiling: c_int, + old_ceiling: *mut c_int, +) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_mutex_trylock(mutex: *mut pthread_mutex_t) -> libc::c_int { +pub extern "C" fn pthread_mutex_trylock(mutex: *mut pthread_mutex_t) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_mutex_unlock(mutex: *mut pthread_mutex_t) -> libc::c_int { +pub extern "C" fn pthread_mutex_unlock(mutex: *mut pthread_mutex_t) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> libc::c_int { +pub extern "C" fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_mutexattr_getprioceiling( attr: *const pthread_mutexattr_t, - prioceiling: *mut libc::c_int, -) -> libc::c_int { + prioceiling: *mut c_int, +) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_mutexattr_getprotocol( attr: *const pthread_mutexattr_t, - protocol: *mut libc::c_int, -) -> libc::c_int { + protocol: *mut c_int, +) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_mutexattr_getpshared( attr: *const pthread_mutexattr_t, - pshared: *mut libc::c_int, -) -> libc::c_int { + pshared: *mut c_int, +) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_mutexattr_gettype( attr: *const pthread_mutexattr_t, - type_: *mut libc::c_int, -) -> libc::c_int { + type_: *mut c_int, +) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> libc::c_int { +pub extern "C" fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_mutexattr_setprioceiling( attr: *mut pthread_mutexattr_t, - prioceiling: libc::c_int, -) -> libc::c_int { + prioceiling: c_int, +) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_mutexattr_setprotocol( attr: *mut pthread_mutexattr_t, - protocol: libc::c_int, -) -> libc::c_int { + protocol: c_int, +) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_mutexattr_setpshared( attr: *mut pthread_mutexattr_t, - pshared: libc::c_int, -) -> libc::c_int { + pshared: c_int, +) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_mutexattr_settype( attr: *mut pthread_mutexattr_t, - type_: libc::c_int, -) -> libc::c_int { + type_: c_int, +) -> c_int { unimplemented!(); } @@ -396,12 +409,12 @@ pub extern "C" fn pthread_mutexattr_settype( pub extern "C" fn pthread_once( once_control: *mut pthread_once_t, init_routine: Option<unsafe extern "C" fn()>, -) -> libc::c_int { +) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_rwlock_destroy(rwlock: *mut pthread_rwlock_t) -> libc::c_int { +pub extern "C" fn pthread_rwlock_destroy(rwlock: *mut pthread_rwlock_t) -> c_int { unimplemented!(); } @@ -409,58 +422,58 @@ pub extern "C" fn pthread_rwlock_destroy(rwlock: *mut pthread_rwlock_t) -> libc: pub extern "C" fn pthread_rwlock_init( rwlock: *mut pthread_rwlock_t, attr: *const pthread_rwlockattr_t, -) -> libc::c_int { +) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_rwlock_rdlock(rwlock: *mut pthread_rwlock_t) -> libc::c_int { +pub extern "C" fn pthread_rwlock_rdlock(rwlock: *mut pthread_rwlock_t) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_rwlock_tryrdlock(rwlock: *mut pthread_rwlock_t) -> libc::c_int { +pub extern "C" fn pthread_rwlock_tryrdlock(rwlock: *mut pthread_rwlock_t) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_rwlock_trywrlock(rwlock: *mut pthread_rwlock_t) -> libc::c_int { +pub extern "C" fn pthread_rwlock_trywrlock(rwlock: *mut pthread_rwlock_t) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_rwlock_unlock(rwlock: *mut pthread_rwlock_t) -> libc::c_int { +pub extern "C" fn pthread_rwlock_unlock(rwlock: *mut pthread_rwlock_t) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_rwlock_wrlock(rwlock: *mut pthread_rwlock_t) -> libc::c_int { +pub extern "C" fn pthread_rwlock_wrlock(rwlock: *mut pthread_rwlock_t) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_rwlockattr_destroy(rwlock: *mut pthread_rwlockattr_t) -> libc::c_int { +pub extern "C" fn pthread_rwlockattr_destroy(rwlock: *mut pthread_rwlockattr_t) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_rwlockattr_getpshared( rwlock: *const pthread_rwlockattr_t, - pshared: *mut libc::c_int, -) -> libc::c_int { + pshared: *mut c_int, +) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_rwlockattr_init(rwlock: *mut pthread_rwlockattr_t) -> libc::c_int { +pub extern "C" fn pthread_rwlockattr_init(rwlock: *mut pthread_rwlockattr_t) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_rwlockattr_setpshared( rwlock: *mut pthread_rwlockattr_t, - pshared: libc::c_int, -) -> libc::c_int { + pshared: c_int, +) -> c_int { unimplemented!(); } @@ -470,34 +483,34 @@ pub extern "C" fn pthread_self() -> pthread_t { } // #[no_mangle] -pub extern "C" fn pthread_setcancelstate(state: libc::c_int, oldstate: *mut libc::c_int) -> libc::c_int { +pub extern "C" fn pthread_setcancelstate(state: c_int, oldstate: *mut c_int) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_setcanceltype(type_: libc::c_int, oldtype: *mut libc::c_int) -> libc::c_int { +pub extern "C" fn pthread_setcanceltype(type_: c_int, oldtype: *mut c_int) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn pthread_setconcurrency(new_level: libc::c_int) -> libc::c_int { +pub extern "C" fn pthread_setconcurrency(new_level: c_int) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_setschedparam( thread: pthread_t, - policy: libc::c_int, + policy: c_int, param: *mut sched_param, -) -> libc::c_int { +) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn pthread_setspecific( key: pthread_key_t, - value: *const libc::c_void, -) -> libc::c_int { + value: *const c_void, +) -> c_int { unimplemented!(); } @@ -505,44 +518,3 @@ pub extern "C" fn pthread_setspecific( pub extern "C" fn pthread_testcancel() { unimplemented!(); } - -#[repr(C)] -#[derive(Debug, Copy)] -pub struct sched_param { - pub _address: u8, -} -impl Clone for sched_param { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct sched_param { - pub _address: u8, -} -impl Clone for sched_param { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct sched_param { - pub _address: u8, -} -impl Clone for sched_param { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct sched_param { - pub _address: u8, -} -impl Clone for sched_param { - fn clone(&self) -> Self { - *self - } -} diff --git a/src/header/_todo/wctype/lib.rs b/src/header/_todo/wctype/lib.rs deleted file mode 100644 index c0666b6d0920b8ebccd271a1c519251eb7f212e3..0000000000000000000000000000000000000000 --- a/src/header/_todo/wctype/lib.rs +++ /dev/null @@ -1,89 +0,0 @@ -// #[no_mangle] -pub extern "C" fn iswalnum(wc: wint_t, locale: locale_t) -> libc::c_int { - unimplemented!(); -} - -// #[no_mangle] -pub extern "C" fn iswalpha(wc: wint_t, locale: locale_t) -> libc::c_int { - unimplemented!(); -} - -// #[no_mangle] -pub extern "C" fn iswcntrl(wc: wint_t, locale: locale_t) -> libc::c_int { - unimplemented!(); -} - -// #[no_mangle] -pub extern "C" fn iswdigit(wc: wint_t, locale: locale_t) -> libc::c_int { - unimplemented!(); -} - -// #[no_mangle] -pub extern "C" fn iswgraph(wc: wint_t, locale: locale_t) -> libc::c_int { - unimplemented!(); -} - -// #[no_mangle] -pub extern "C" fn iswlower(wc: wint_t, locale: locale_t) -> libc::c_int { - unimplemented!(); -} - -// #[no_mangle] -pub extern "C" fn iswprint(wc: wint_t, locale: locale_t) -> libc::c_int { - unimplemented!(); -} - -// #[no_mangle] -pub extern "C" fn iswpunct(wc: wint_t, locale: locale_t) -> libc::c_int { - unimplemented!(); -} - -// #[no_mangle] -pub extern "C" fn iswspace(wc: wint_t, locale: locale_t) -> libc::c_int { - unimplemented!(); -} - -// #[no_mangle] -pub extern "C" fn iswupper(wc: wint_t, locale: locale_t) -> libc::c_int { - unimplemented!(); -} - -// #[no_mangle] -pub extern "C" fn iswxdigit(wc: wint_t, locale: locale_t) -> libc::c_int { - unimplemented!(); -} - -// #[no_mangle] -pub extern "C" fn iswblank(wc: wint_t, locale: locale_t) -> libc::c_int { - unimplemented!(); -} - -// #[no_mangle] -pub extern "C" fn wctype(property: *const libc::c_char, locale: locale_t) -> wctype_t { - unimplemented!(); -} - -// #[no_mangle] -pub extern "C" fn iswctype(wc: wint_t, desc: wctype_t, locale: locale_t) -> libc::c_int { - unimplemented!(); -} - -// #[no_mangle] -pub extern "C" fn towlower(wc: wint_t, locale: locale_t) -> wint_t { - unimplemented!(); -} - -// #[no_mangle] -pub extern "C" fn towupper(wc: wint_t, locale: locale_t) -> wint_t { - unimplemented!(); -} - -// #[no_mangle] -pub extern "C" fn wctrans(property: *const libc::c_char, locale: locale_t) -> wctrans_t { - unimplemented!(); -} - -// #[no_mangle] -pub extern "C" fn towctrans(wc: wint_t, desc: wctrans_t, locale: locale_t) -> wint_t { - unimplemented!(); -} diff --git a/src/header/aio/cbindgen.toml b/src/header/aio/cbindgen.toml new file mode 100644 index 0000000000000000000000000000000000000000..007f687f949f86fd27d7d6fa2e0aaa8542ca70b3 --- /dev/null +++ b/src/header/aio/cbindgen.toml @@ -0,0 +1,7 @@ +sys_includes = [] +include_guard = "_AIO_H" +language = "C" +style = "Tag" + +[enum] +prefix_with_name = true diff --git a/src/header/_todo/aio/lib.rs b/src/header/aio/mod.rs similarity index 51% rename from src/header/_todo/aio/lib.rs rename to src/header/aio/mod.rs index 40002aa5117180768e5ac85aaed6212a011a57a5..d1d9ef49f5bfe25a6e4366189fa7c80927665234 100644 --- a/src/header/_todo/aio/lib.rs +++ b/src/header/aio/mod.rs @@ -1,34 +1,37 @@ +use header::time::sigevent; +use platform::types::*; + pub struct aiocb { - pub aio_fildes: libc::c_int, - pub aio_lio_opcode: libc::c_int, - pub aio_reqprio: libc::c_int, - pub aio_buf: *mut libc::c_void, + pub aio_fildes: c_int, + pub aio_lio_opcode: c_int, + pub aio_reqprio: c_int, + pub aio_buf: *mut c_void, pub aio_nbytes: usize, pub aio_sigevent: sigevent, } // #[no_mangle] -pub extern "C" fn aio_read(aiocbp: *mut aiocb) -> libc::c_int { +pub extern "C" fn aio_read(aiocbp: *mut aiocb) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn aio_write(aiocbp: *mut aiocb) -> libc::c_int { +pub extern "C" fn aio_write(aiocbp: *mut aiocb) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn lio_listio( - mode: libc::c_int, + mode: c_int, list: *const *const aiocb, - nent: libc::c_int, + nent: c_int, sig: *mut sigevent, -) -> libc::c_int { +) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn aio_error(aiocbp: *const aiocb) -> libc::c_int { +pub extern "C" fn aio_error(aiocbp: *const aiocb) -> c_int { unimplemented!(); } @@ -38,20 +41,20 @@ pub extern "C" fn aio_return(aiocbp: *mut aiocb) -> usize { } // #[no_mangle] -pub extern "C" fn aio_cancel(fildes: libc::c_int, aiocbp: *mut aiocb) -> libc::c_int { +pub extern "C" fn aio_cancel(fildes: c_int, aiocbp: *mut aiocb) -> c_int { unimplemented!(); } // #[no_mangle] pub extern "C" fn aio_suspend( list: *const *const aiocb, - nent: libc::c_int, + nent: c_int, timeout: *const timespec, -) -> libc::c_int { +) -> c_int { unimplemented!(); } // #[no_mangle] -pub extern "C" fn aio_fsync(operation: libc::c_int, aiocbp: *mut aiocb) -> libc::c_int { +pub extern "C" fn aio_fsync(operation: c_int, aiocbp: *mut aiocb) -> c_int { unimplemented!(); } diff --git a/src/header/dirent/mod.rs b/src/header/dirent/mod.rs index d1967fea3e804dc0b50b8f1fca84d9fa5de27221..09ba4a7f9e73531a61b8f473609ef9e6922bfb97 100644 --- a/src/header/dirent/mod.rs +++ b/src/header/dirent/mod.rs @@ -5,8 +5,8 @@ use core::{mem, ptr}; use header::{errno, fcntl, unistd}; use platform; -use platform::{Pal, Sys}; use platform::types::*; +use platform::{Pal, Sys}; const DIR_BUF_SIZE: usize = mem::size_of::<dirent>() * 3; diff --git a/src/header/fcntl/mod.rs b/src/header/fcntl/mod.rs index 8ce772043be7cd551cd9e72b5858bb6df2d8515b..a22d0eb52818d6cf1c4444a063a5aa475810beb5 100644 --- a/src/header/fcntl/mod.rs +++ b/src/header/fcntl/mod.rs @@ -1,7 +1,7 @@ //! fcntl implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/fcntl.h.html -use platform::{Pal, Sys}; use platform::types::*; +use platform::{Pal, Sys}; pub use self::sys::*; diff --git a/src/header/fnmatch/mod.rs b/src/header/fnmatch/mod.rs index ee5ffaf3457a3805a0a90273c0ee8e89f16f87eb..32819f0a4b3913f35d87b33542f7b3204098265d 100644 --- a/src/header/fnmatch/mod.rs +++ b/src/header/fnmatch/mod.rs @@ -8,7 +8,7 @@ pub const FNM_NOMATCH: c_int = 1; pub const FNM_NOESCAPE: c_int = 1; pub const FNM_PATHNAME: c_int = 2; -pub const FNM_PERIOD: c_int = 4; +pub const FNM_PERIOD: c_int = 4; pub const FNM_CASEFOLD: c_int = 8; #[derive(Debug)] @@ -39,7 +39,7 @@ unsafe fn next_token(pattern: &mut *const c_char, flags: c_int) -> Option<Token> } *pattern = pattern.offset(1); Token::Char(c) - }, + } b'?' => Token::Any, b'*' => Token::Wildcard, b'[' => { @@ -47,7 +47,9 @@ unsafe fn next_token(pattern: &mut *const c_char, flags: c_int) -> Option<Token> let invert = if **pattern as u8 == b'!' { *pattern = pattern.offset(1); true - } else { false }; + } else { + false + }; loop { let mut c = **pattern as u8; @@ -64,8 +66,8 @@ unsafe fn next_token(pattern: &mut *const c_char, flags: c_int) -> Option<Token> // Trailing backslash. Maybe error? break; } - }, - _ => () + } + _ => (), } if matches.len() >= 2 && matches[matches.len() - 1] == b'-' { let len = matches.len(); @@ -81,13 +83,17 @@ unsafe fn next_token(pattern: &mut *const c_char, flags: c_int) -> Option<Token> // Otherwise, there was no closing ]. Maybe error? Token::Match(invert, matches) - }, - c => Token::Char(c) + } + c => Token::Char(c), }) } #[no_mangle] -pub unsafe extern "C" fn fnmatch(mut pattern: *const c_char, mut input: *const c_char, flags: c_int) -> c_int { +pub unsafe extern "C" fn fnmatch( + mut pattern: *const c_char, + mut input: *const c_char, + flags: c_int, +) -> c_int { let pathname = flags & FNM_PATHNAME == FNM_PATHNAME; let casefold = flags & FNM_CASEFOLD == FNM_CASEFOLD; @@ -109,7 +115,7 @@ pub unsafe extern "C" fn fnmatch(mut pattern: *const c_char, mut input: *const c return FNM_NOMATCH; } input = input.offset(1); - }, + } Some(Token::Char(c)) => { let mut a = *input as u8; if casefold && a >= b'a' && a <= b'z' { @@ -126,14 +132,15 @@ pub unsafe extern "C" fn fnmatch(mut pattern: *const c_char, mut input: *const c leading = true; } input = input.offset(1); - }, + } Some(Token::Match(invert, matches)) => { - if (pathname && *input as u8 == b'/') || matches.contains(&(*input as u8)) == invert { + if (pathname && *input as u8 == b'/') || matches.contains(&(*input as u8)) == invert + { // Found it, but it's inverted! Or vise versa. return FNM_NOMATCH; } input = input.offset(1); - }, + } Some(Token::Wildcard) => { loop { let c = *input as u8; @@ -155,8 +162,8 @@ pub unsafe extern "C" fn fnmatch(mut pattern: *const c_char, mut input: *const c } } unreachable!("nothing should be able to break out of the loop"); - }, - None => return FNM_NOMATCH // Pattern ended but there's still some input + } + None => return FNM_NOMATCH, // Pattern ended but there's still some input } } } diff --git a/src/header/mod.rs b/src/header/mod.rs index 4fdee7512608eaddc3ca15f9a35d34c5f283f412..0e1556201f2b3ce123582adcde6e1e8d753b310f 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -1,3 +1,4 @@ +pub mod aio; pub mod arpa_inet; pub mod ctype; pub mod dirent; @@ -10,6 +11,7 @@ pub mod grp; pub mod inttypes; pub mod locale; pub mod netinet_in; +//pub mod pthread; pub mod pwd; pub mod semaphore; pub mod setjmp; diff --git a/src/header/netinet_in/mod.rs b/src/header/netinet_in/mod.rs index f3819f604f937cea7fef1713dea317c2b300c29a..db230c997bfefd5b99dc3e8050a8406c4695538e 100644 --- a/src/header/netinet_in/mod.rs +++ b/src/header/netinet_in/mod.rs @@ -9,19 +9,19 @@ pub type in_port_t = u16; #[repr(C)] #[derive(Debug, Clone, Copy)] pub struct in_addr { - pub s_addr: in_addr_t + pub s_addr: in_addr_t, } #[repr(C)] pub struct in6_addr { - pub s6_addr: [u8; 16] + pub s6_addr: [u8; 16], } #[repr(C)] pub struct sockaddr_in { pub sin_family: sa_family_t, pub sin_port: in_port_t, - pub sin_addr: in_addr + pub sin_addr: in_addr, } #[repr(C)] @@ -30,7 +30,7 @@ pub struct sockaddr_in6 { pub sin6_port: in_port_t, pub sin6_flowinfo: u32, pub sin6_addr: in6_addr, - pub sin6_scope_id: u32 + pub sin6_scope_id: u32, } #[repr(C)] diff --git a/src/header/pwd/mod.rs b/src/header/pwd/mod.rs index f455e40c627ff946c15d491dbd7ad45084723e94..139acc389a8d0549e0ed93938adaed9de3307f85 100644 --- a/src/header/pwd/mod.rs +++ b/src/header/pwd/mod.rs @@ -5,9 +5,9 @@ use core::ptr; use header::{errno, fcntl}; use platform; -use platform::{Pal, Sys}; use platform::types::*; use platform::RawFile; +use platform::{Pal, Sys}; #[repr(C)] pub struct passwd { diff --git a/src/header/sgtty/mod.rs b/src/header/sgtty/mod.rs index c8950c506bd3141009677c8ea72bd00d84a637ac..b5f1a40900858138c3fe904328e32c8041c292d9 100644 --- a/src/header/sgtty/mod.rs +++ b/src/header/sgtty/mod.rs @@ -2,9 +2,9 @@ use core::fmt::Write; +use header::sys_ioctl::*; use platform; use platform::types::*; -use header::sys_ioctl::*; #[no_mangle] pub extern "C" fn gtty(fd: c_int, out: *mut sgttyb) -> c_int { diff --git a/src/header/signal/mod.rs b/src/header/signal/mod.rs index 9929bd07090ed8ab74df2e05fe028897d1794e2a..c9259651d199f153dd03c17b49246a305d9a2a8e 100644 --- a/src/header/signal/mod.rs +++ b/src/header/signal/mod.rs @@ -4,8 +4,8 @@ use core::{mem, ptr}; use header::errno; use platform; -use platform::{PalSignal, Sys}; use platform::types::*; +use platform::{PalSignal, Sys}; pub use self::sys::*; @@ -147,7 +147,10 @@ extern "C" { } #[no_mangle] -pub extern "C" fn signal(sig: c_int, func: Option<extern "C" fn(c_int)>) -> Option<extern "C" fn(c_int)> { +pub extern "C" fn signal( + sig: c_int, + func: Option<extern "C" fn(c_int)>, +) -> Option<extern "C" fn(c_int)> { let sa = sigaction { sa_handler: func, sa_flags: SA_RESTART as c_ulong, @@ -229,5 +232,5 @@ pub const _signal_strings: [&'static str; 32] = [ "Window changed\0", "I/O possible\0", "Power failure\0", - "Bad system call\0" + "Bad system call\0", ]; diff --git a/src/header/stdio/mod.rs b/src/header/stdio/mod.rs index 5bbe0aae6a48361e30134dd2e273b7d9c1ed0a1e..48f31488359c8a09aed264e8bd586f544f342d54 100644 --- a/src/header/stdio/mod.rs +++ b/src/header/stdio/mod.rs @@ -9,10 +9,12 @@ use va_list::VaList as va_list; use header::errno::{self, STR_ERROR}; use header::fcntl; +use header::stdlib::mkstemp; +use header::string::strlen; use platform; -use platform::{Pal, Sys}; use platform::types::*; use platform::{c_str, errno, Read, Write}; +use platform::{Pal, Sys}; mod printf; mod scanf; @@ -220,7 +222,7 @@ impl<'a> Read for LockGuard<'a> { let mut buf = [0]; match self.0.read(&mut buf) { 0 => Ok(None), - _ => Ok(Some(buf[0])) + _ => Ok(Some(buf[0])), } } } @@ -452,9 +454,6 @@ pub extern "C" fn fputc(c: c_int, stream: &mut FILE) -> c_int { /// Insert a string into a stream #[no_mangle] pub extern "C" fn fputs(s: *const c_char, stream: &mut FILE) -> c_int { - extern "C" { - fn strlen(s: *const c_char) -> size_t; - } let len = unsafe { strlen(s) }; (fwrite(s as *const c_void, 1, len, stream) == len) as c_int - 1 } @@ -886,10 +885,6 @@ pub extern "C" fn tempnam(_dir: *const c_char, _pfx: *const c_char) -> *mut c_ch #[no_mangle] pub extern "C" fn tmpfile() -> *mut FILE { - extern "C" { - fn mkstemp(name: *mut c_char) -> c_int; - } - let mut file_name = *b"/tmp/tmpfileXXXXXX"; let file_name = file_name.as_mut_ptr() as *mut c_char; let fd = unsafe { mkstemp(file_name) }; diff --git a/src/header/stdio/scanf.rs b/src/header/stdio/scanf.rs index bdb12fb4fa7fba490a046004cfb51c4b57b96481..d9cd3e15eb69b13fd6dc03834801ac3cb93757a8 100644 --- a/src/header/stdio/scanf.rs +++ b/src/header/stdio/scanf.rs @@ -44,9 +44,9 @@ unsafe fn inner_scanf<R: Read>( byte = b; count += 1; true - }, + } Ok(None) => false, - Err(()) => return Err(-1) + Err(()) => return Err(-1), } }}; } diff --git a/src/header/stdlib/mod.rs b/src/header/stdlib/mod.rs index fd617c506b84aaf19f3c1e2d196b84d016c0fbbc..6de7e36f0227ff92536c7e7d367c3cb5b9f9d131 100644 --- a/src/header/stdlib/mod.rs +++ b/src/header/stdlib/mod.rs @@ -6,15 +6,15 @@ use rand::prng::XorShiftRng; use rand::rngs::JitterRng; use rand::{Rng, SeedableRng}; -use header::{ctype, errno, unistd}; use header::errno::*; use header::fcntl::*; use header::string::*; use header::time::constants::CLOCK_MONOTONIC; use header::wchar::*; +use header::{ctype, errno, unistd}; use platform; -use platform::{Pal, Sys}; use platform::types::*; +use platform::{Pal, Sys}; mod sort; @@ -507,7 +507,11 @@ pub unsafe extern "C" fn putenv(insert: *mut c_char) -> c_int { platform::inner_environ[i] = insert; } else { let i = platform::inner_environ.len() - 1; - assert_eq!(platform::inner_environ[i], ptr::null_mut(), "environ did not end with null"); + assert_eq!( + platform::inner_environ[i], + ptr::null_mut(), + "environ did not end with null" + ); platform::inner_environ[i] = insert; platform::inner_environ.push(ptr::null_mut()); platform::environ = platform::inner_environ.as_mut_ptr(); @@ -571,7 +575,11 @@ pub extern "C" fn seed48(seed16v: [c_ushort; 3]) -> c_ushort { } #[no_mangle] -pub unsafe extern "C" fn setenv(mut key: *const c_char, mut value: *const c_char, overwrite: c_int) -> c_int { +pub unsafe extern "C" fn setenv( + mut key: *const c_char, + mut value: *const c_char, + overwrite: c_int, +) -> c_int { let mut key_len = 0; while *key.offset(key_len) != 0 { key_len += 1; @@ -602,7 +610,11 @@ pub unsafe extern "C" fn setenv(mut key: *const c_char, mut value: *const c_char } } else { let i = platform::inner_environ.len() - 1; - assert_eq!(platform::inner_environ[i], ptr::null_mut(), "environ did not end with null"); + assert_eq!( + platform::inner_environ[i], + ptr::null_mut(), + "environ did not end with null" + ); platform::inner_environ.push(ptr::null_mut()); platform::environ = platform::inner_environ.as_mut_ptr(); i @@ -664,9 +676,15 @@ pub unsafe extern "C" fn strtod(mut s: *const c_char, endptr: *mut *mut c_char) let mut radix = 10; let negative = match *s as u8 { - b'-' => { s = s.offset(1); true }, - b'+' => { s = s.offset(1); false }, - _ => false + b'-' => { + s = s.offset(1); + true + } + b'+' => { + s = s.offset(1); + false + } + _ => false, }; if *s as u8 == b'0' && *s.offset(1) as u8 == b'x' { @@ -855,7 +873,11 @@ pub unsafe extern "C" fn strtoull( } #[no_mangle] -pub unsafe extern "C" fn strtoll(s: *const c_char, endptr: *mut *mut c_char, base: c_int) -> c_long { +pub unsafe extern "C" fn strtoll( + s: *const c_char, + endptr: *mut *mut c_char, + base: c_int, +) -> c_long { strtol(s, endptr, base) } diff --git a/src/header/string/mod.rs b/src/header/string/mod.rs index bd09b9740e7124572188ea26dbf945798a61a6ce..cb48b8871bde8d9ee5c4926ed98d284036c1dcbb 100644 --- a/src/header/string/mod.rs +++ b/src/header/string/mod.rs @@ -4,8 +4,8 @@ use core::mem; use core::ptr; use core::usize; -use header::signal; use header::errno::*; +use header::signal; use platform; use platform::types::*; @@ -179,14 +179,15 @@ pub unsafe fn inner_strspn(s1: *const c_char, s2: *const c_char, cmp: bool) -> s let mut i = 0; while *s2.offset(i) != 0 { byteset[(*s2.offset(i) as usize) / BITSIZE] |= - 1 << (*s2.offset(i) as usize & (BITSIZE-1)); + 1 << (*s2.offset(i) as usize & (BITSIZE - 1)); i += 1; } i = 0; // reset - while *s1.offset(i) != 0 && - (byteset[(*s1.offset(i) as usize) / BITSIZE] & - 1 << (*s1.offset(i) as usize & (BITSIZE-1)) != 0) == cmp { + while *s1.offset(i) != 0 + && (byteset[(*s1.offset(i) as usize) / BITSIZE] + & 1 << (*s1.offset(i) as usize & (BITSIZE - 1)) != 0) == cmp + { i += 1; } i as size_t diff --git a/src/header/sys_file/mod.rs b/src/header/sys_file/mod.rs index f126dd64ba279e42f82a33329973437ab1709522..80a99855c40d74f3e54ece0b0b85c02f0d5a9b3e 100644 --- a/src/header/sys_file/mod.rs +++ b/src/header/sys_file/mod.rs @@ -1,7 +1,7 @@ //! sys/file.h implementation -use platform::{Pal, Sys}; use platform::types::*; +use platform::{Pal, Sys}; pub const LOCK_SH: usize = 1; pub const LOCK_EX: usize = 2; diff --git a/src/header/sys_ioctl/mod.rs b/src/header/sys_ioctl/mod.rs index 78d7714d5c4e175518b4b0a6ffda8f9cd924a17e..adbdd7f3e27b44f4134f2ef1a893fcdfed91758e 100644 --- a/src/header/sys_ioctl/mod.rs +++ b/src/header/sys_ioctl/mod.rs @@ -1,6 +1,5 @@ //! ioctl implementation for linux -use platform::{Pal, Sys}; use platform::types::*; // This is used from sgtty @@ -15,7 +14,8 @@ pub struct sgttyb { #[cfg(target_os = "linux")] pub mod inner { - use super::*; + use platform::types::*; + use platform::{Pal, Sys}; #[repr(C)] pub struct winsize { diff --git a/src/header/sys_mman/mod.rs b/src/header/sys_mman/mod.rs index 56730d401e43c18cbdff3a1252a07059f90bdf18..013050a053bd119c99c07f11fa1a37d3f5f4ba54 100644 --- a/src/header/sys_mman/mod.rs +++ b/src/header/sys_mman/mod.rs @@ -1,5 +1,5 @@ -use platform::{Pal, Sys}; use platform::types::*; +use platform::{Pal, Sys}; pub use self::sys::*; diff --git a/src/header/sys_resource/mod.rs b/src/header/sys_resource/mod.rs index 1b8dae9258267ca9ed624aa55eb43bb329853b22..6afcc6fe9bef476433e6d3a0407bceb41d17f7a8 100644 --- a/src/header/sys_resource/mod.rs +++ b/src/header/sys_resource/mod.rs @@ -3,8 +3,8 @@ use header::sys_time::timeval; use platform; -use platform::{Pal, Sys}; use platform::types::*; +use platform::{Pal, Sys}; // Exported in bits file const RUSAGE_SELF: c_int = 0; diff --git a/src/header/sys_select/mod.rs b/src/header/sys_select/mod.rs index 99590e65e60efbb946d3085b9db601c754648388..dcb40b6af6ce572a9f50d33cd1e1141f3ec8c062 100644 --- a/src/header/sys_select/mod.rs +++ b/src/header/sys_select/mod.rs @@ -1,7 +1,7 @@ //! sys/select.h implementation -use platform::{Pal, Sys}; use platform::types::*; +use platform::{Pal, Sys}; // fd_set is defined in C because cbindgen is incompatible with mem::size_of booo diff --git a/src/header/sys_socket/mod.rs b/src/header/sys_socket/mod.rs index 30ff349e4da7e6f69557907f1bc561c0ccb2cc81..5a305274ef515a08ee9552ae93720921c02263e2 100644 --- a/src/header/sys_socket/mod.rs +++ b/src/header/sys_socket/mod.rs @@ -3,8 +3,8 @@ use core::ptr; use platform; -use platform::{PalSocket, Sys}; use platform::types::*; +use platform::{PalSocket, Sys}; mod constants; diff --git a/src/header/sys_stat/mod.rs b/src/header/sys_stat/mod.rs index 3e393d570f452c70bdfa912d40e71b4a3a9065f2..8490a3126d7b47a6e8136301b7b03b648e1a7fbe 100644 --- a/src/header/sys_stat/mod.rs +++ b/src/header/sys_stat/mod.rs @@ -1,9 +1,9 @@ //! stat implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/sysstat.h.html -use header::fcntl::{O_PATH, O_NOFOLLOW}; +use header::fcntl::{O_NOFOLLOW, O_PATH}; use platform; -use platform::{Pal, Sys}; use platform::types::*; +use platform::{Pal, Sys}; pub const S_IFMT: c_int = 0o0170000; diff --git a/src/header/sys_time/mod.rs b/src/header/sys_time/mod.rs index 163f9c01fbd1f963de7ac93c98ffc364c51ba8e3..13c67d9d457605d325cd7a4c5aad1ba06bb9afb2 100644 --- a/src/header/sys_time/mod.rs +++ b/src/header/sys_time/mod.rs @@ -1,8 +1,8 @@ //! sys/time implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/systime.h.html use platform; -use platform::{Pal, Sys}; use platform::types::*; +use platform::{Pal, Sys}; pub const ITIMER_REAL: c_int = 0; pub const ITIMER_VIRTUAL: c_int = 1; diff --git a/src/header/sys_times/mod.rs b/src/header/sys_times/mod.rs index 57d149da534746a1a313de6d82ff22fc8fac7042..72c0305a2fd5ef4a7fc694fa9f744c18d8c52ee9 100644 --- a/src/header/sys_times/mod.rs +++ b/src/header/sys_times/mod.rs @@ -1,8 +1,8 @@ //! sys/times.h implementation use platform; -use platform::{Pal, Sys}; use platform::types::*; +use platform::{Pal, Sys}; #[repr(C)] pub struct tms { diff --git a/src/header/sys_utsname/mod.rs b/src/header/sys_utsname/mod.rs index 1899d9096290df3411da58d9cac49d773918aa0f..fcd6c80728dfc0d79f50e3645af5c68d877d6206 100644 --- a/src/header/sys_utsname/mod.rs +++ b/src/header/sys_utsname/mod.rs @@ -3,8 +3,8 @@ #[cfg(target_os = "linux")] mod inner { use platform; - use platform::{Pal, Sys}; use platform::types::*; + use platform::{Pal, Sys}; const UTSLENGTH: usize = 65; diff --git a/src/header/sys_wait/mod.rs b/src/header/sys_wait/mod.rs index b9d69f1392bb4ca9646b8bc42e18d6da38b561c9..346fe6772319c952b35878f83e82a5c5b5cc6773 100644 --- a/src/header/sys_wait/mod.rs +++ b/src/header/sys_wait/mod.rs @@ -2,8 +2,8 @@ //! http://pubs.opengroup.org/onlinepubs/7908799/xsh/syswait.h.html use header::sys_resource::rusage; -use platform::{Pal, Sys}; use platform::types::*; +use platform::{Pal, Sys}; pub const WNOHANG: c_int = 1; pub const WUNTRACED: c_int = 2; diff --git a/src/header/termios/mod.rs b/src/header/termios/mod.rs index fe8988f340e0e44abf0d5e27f89cf76ccf72b07b..c9159ffdbabfaa22fd820349637d3ce9cd88be77 100644 --- a/src/header/termios/mod.rs +++ b/src/header/termios/mod.rs @@ -1,8 +1,8 @@ //! termios implementation, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/termios.h.html use platform; -use platform::{Pal, Sys}; use platform::types::*; +use platform::{Pal, Sys}; pub type cc_t = u8; pub type speed_t = u32; @@ -19,7 +19,7 @@ pub struct termios { c_line: cc_t, c_cc: [cc_t; NCCS], __c_ispeed: speed_t, - __c_ospeed: speed_t + __c_ospeed: speed_t, } #[no_mangle] diff --git a/src/header/time/mod.rs b/src/header/time/mod.rs index d8f7f98ac712c61f1ecd26710ffcddd04fc6ce6b..1819601a09bf270ae6f13c46a15b8a6b55896c47 100644 --- a/src/header/time/mod.rs +++ b/src/header/time/mod.rs @@ -4,8 +4,8 @@ use core::mem::transmute; use header::errno::EIO; use platform; -use platform::{Pal, Sys}; use platform::types::*; +use platform::{Pal, Sys}; use self::constants::*; use self::helpers::*; diff --git a/src/header/time/strftime.rs b/src/header/time/strftime.rs index bc8a649b49edec70eaa9d8e0d4a3c28e014e331d..7456ce43b6db17baead00cb9c2492cb181f7c55e 100644 --- a/src/header/time/strftime.rs +++ b/src/header/time/strftime.rs @@ -1,15 +1,11 @@ use alloc::string::String; -use platform::{self, Write}; use platform::types::*; +use platform::{self, Write}; use super::tm; -pub unsafe fn strftime<W: Write>( - w: &mut W, - format: *const c_char, - t: *const tm, -) -> size_t { +pub unsafe fn strftime<W: Write>(w: &mut W, format: *const c_char, t: *const tm) -> size_t { pub unsafe fn inner_strftime<W: Write>( mut w: &mut W, mut format: *const c_char, @@ -73,7 +69,7 @@ pub unsafe fn strftime<W: Write>( while *format != 0 { if *format as u8 != b'%' { - w!(byte *format as u8); + w!(byte * format as u8); format = format.offset(1); continue; } diff --git a/src/header/unistd/brk.rs b/src/header/unistd/brk.rs index 7cf6ead43a964bc5b0f2f869939f6069231cc193..07466da39bd707fdad5894436b2431410666b69e 100644 --- a/src/header/unistd/brk.rs +++ b/src/header/unistd/brk.rs @@ -2,8 +2,8 @@ use core::ptr; use header::errno::ENOMEM; use platform; -use platform::{Pal, Sys}; use platform::types::*; +use platform::{Pal, Sys}; static mut BRK: *mut c_void = ptr::null_mut(); diff --git a/src/header/unistd/mod.rs b/src/header/unistd/mod.rs index 2e565ed43c5845d42ebeb54918fd4da0e179bcaf..817504658acae382ae80c98dc95efb429f120554 100644 --- a/src/header/unistd/mod.rs +++ b/src/header/unistd/mod.rs @@ -4,8 +4,8 @@ use core::{ptr, slice}; use header::sys_time; use platform; -use platform::{Pal, Sys}; use platform::types::*; +use platform::{Pal, Sys}; pub use self::brk::*; pub use self::getopt::*; @@ -195,7 +195,10 @@ pub extern "C" fn getcwd(mut buf: *mut c_char, mut size: size_t) -> *mut c_char } if alloc { - let mut len = stack_buf.iter().position(|b| *b == 0).expect("no nul-byte in getcwd string") + 1; + let mut len = stack_buf + .iter() + .position(|b| *b == 0) + .expect("no nul-byte in getcwd string") + 1; let mut heap_buf = unsafe { platform::alloc(len) as *mut c_char }; for i in 0..len { unsafe { diff --git a/src/header/utime/mod.rs b/src/header/utime/mod.rs index 928243b1aa84b3f04e674fffdc33e5c32244bc7d..dd891aa6ee28fdf63d66ac398cc9dc78366b1c87 100644 --- a/src/header/utime/mod.rs +++ b/src/header/utime/mod.rs @@ -1,7 +1,7 @@ //! utime implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/utime.h.html -use platform::{Pal, Sys}; use platform::types::*; +use platform::{Pal, Sys}; #[repr(C)] #[derive(Clone)] diff --git a/src/platform/linux/mod.rs b/src/platform/linux/mod.rs index 232b6a11a6d8544ab8c9cf066afb4e750188f634..5ef98c4626ecef155b800ddae812d3ec4c1ce263 100644 --- a/src/platform/linux/mod.rs +++ b/src/platform/linux/mod.rs @@ -1,8 +1,8 @@ -use core::{mem, ptr}; use core::fmt::Write; +use core::{mem, ptr}; -use super::{errno, FileWriter, Pal}; use super::types::*; +use super::{errno, FileWriter, Pal}; mod signal; mod socket; @@ -79,7 +79,11 @@ impl Pal for Sys { e(unsafe { syscall!(DUP3, fildes, fildes2, 0) }) as c_int } - unsafe fn execve(path: *const c_char, argv: *const *mut c_char, envp: *const *mut c_char) -> c_int { + unsafe fn execve( + path: *const c_char, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int { e(syscall!(EXECVE, path, argv, envp)) as c_int } diff --git a/src/platform/linux/signal.rs b/src/platform/linux/signal.rs index 0e2e72d80d1ae8f533cf32f8c159c3857de7ad95..9ad5cff3b4150f3120712d25ef286635204c9205 100644 --- a/src/platform/linux/signal.rs +++ b/src/platform/linux/signal.rs @@ -1,8 +1,8 @@ use core::mem; -use super::{e, Sys}; -use super::super::PalSignal; use super::super::types::*; +use super::super::PalSignal; +use super::{e, Sys}; impl PalSignal for Sys { fn kill(pid: pid_t, sig: c_int) -> c_int { diff --git a/src/platform/linux/socket.rs b/src/platform/linux/socket.rs index 73707d7e42a0eb8dfd05c70be139fc93e34b9432..7b030b609cdbbc5c505de5fca11fdee120531973 100644 --- a/src/platform/linux/socket.rs +++ b/src/platform/linux/socket.rs @@ -1,6 +1,6 @@ -use super::{e, Sys}; -use super::super::PalSocket; use super::super::types::*; +use super::super::PalSocket; +use super::{e, Sys}; 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/mod.rs b/src/platform/mod.rs index 4abdab5df76357af7f36634837825daa7b048f85..53acee0e0f40c76f16be6f49f00cb8506856fdc9 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -160,7 +160,7 @@ impl Read for FileReader { match self.read(&mut buf) { 0 => Ok(None), n if n < 0 => Err(()), - _ => Ok(Some(buf[0])) + _ => Ok(Some(buf[0])), } } } @@ -258,13 +258,13 @@ impl Read for UnsafeStringReader { pub struct CountingWriter<T> { pub inner: T, - pub written: usize + pub written: usize, } impl<T> CountingWriter<T> { - pub /* const */ fn new(writer: T) -> Self { + pub fn new(writer: T) -> Self { Self { inner: writer, - written: 0 + written: 0, } } } diff --git a/src/platform/pal/mod.rs b/src/platform/pal/mod.rs index 25b8ea242d2f992980564565d2c1033d7e3e209e..4d15c3b26bc94fea27ce6384b2b181f057052437 100644 --- a/src/platform/pal/mod.rs +++ b/src/platform/pal/mod.rs @@ -45,7 +45,11 @@ pub trait Pal { Self::no_pal("dup2") } - unsafe fn execve(path: *const c_char, argv: *const *mut c_char, envp: *const *mut c_char) -> c_int { + unsafe fn execve( + path: *const c_char, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int { Self::no_pal("execve") } diff --git a/src/platform/pal/signal.rs b/src/platform/pal/signal.rs index e8a40a9621dce80084d1cc4022560c68bb3705ab..f8d69fd2c3086e9ba9523b8d38c3d4b648ef6263 100644 --- a/src/platform/pal/signal.rs +++ b/src/platform/pal/signal.rs @@ -1,5 +1,5 @@ -use super::super::Pal; use super::super::types::*; +use super::super::Pal; pub trait PalSignal: Pal { fn kill(pid: pid_t, sig: c_int) -> c_int { diff --git a/src/platform/pal/socket.rs b/src/platform/pal/socket.rs index 8e8c1f6d9054d11eed91e286a0912705d4856c85..aac4205687675c7b93c6e34a4d657c364fd54738 100644 --- a/src/platform/pal/socket.rs +++ b/src/platform/pal/socket.rs @@ -1,5 +1,5 @@ -use super::super::Pal; use super::super::types::*; +use super::super::Pal; pub trait PalSocket: Pal { unsafe fn accept(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> c_int { @@ -14,11 +14,19 @@ pub trait PalSocket: Pal { Self::no_pal("connect") } - unsafe fn getpeername(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> c_int { + unsafe fn getpeername( + socket: c_int, + address: *mut sockaddr, + address_len: *mut socklen_t, + ) -> c_int { Self::no_pal("getpeername") } - unsafe fn getsockname(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> c_int { + unsafe fn getsockname( + socket: c_int, + address: *mut sockaddr, + address_len: *mut socklen_t, + ) -> c_int { Self::no_pal("getsockname") } diff --git a/src/platform/rawfile.rs b/src/platform/rawfile.rs index 338ed0b4f3f5922c463939883072c474707205d3..4686ce8d04650d4d42666efcc00ad8e97330171e 100644 --- a/src/platform/rawfile.rs +++ b/src/platform/rawfile.rs @@ -1,6 +1,6 @@ use core::ops::Deref; -use super::{Pal, Sys, types::*}; +use super::{types::*, Pal, Sys}; pub struct RawFile(c_int); diff --git a/src/platform/redox/mod.rs b/src/platform/redox/mod.rs index 7c93747043c6942c75a120a5a6035a4b3003e288..02bb24e1e4652471cecbc079efa9f9fe843a2219 100644 --- a/src/platform/redox/mod.rs +++ b/src/platform/redox/mod.rs @@ -1,16 +1,16 @@ //! sys/socket implementation, following http://pubs.opengroup.org/onlinepubs/009696699/basedefs/sys/socket.h.html use alloc::btree_map::BTreeMap; -use core::{mem, ptr, slice}; use core::fmt::Write; -use spin::{Once, Mutex, MutexGuard}; +use core::{mem, ptr, slice}; +use spin::{Mutex, MutexGuard, Once}; use syscall::data::Stat as redox_stat; use syscall::data::TimeSpec as redox_timespec; use syscall::flag::*; use syscall::{self, Result}; -use super::{c_str, errno, FileReader, FileWriter, Pal, RawFile, Read}; use super::types::*; +use super::{c_str, errno, FileReader, FileWriter, Pal, RawFile, Read}; mod signal; mod socket; @@ -22,7 +22,9 @@ const MAP_ANON: c_int = 1; static ANONYMOUS_MAPS: Once<Mutex<BTreeMap<usize, usize>>> = Once::new(); fn anonymous_maps() -> MutexGuard<'static, BTreeMap<usize, usize>> { - ANONYMOUS_MAPS.call_once(|| Mutex::new(BTreeMap::new())).lock() + ANONYMOUS_MAPS + .call_once(|| Mutex::new(BTreeMap::new())) + .lock() } fn e(sys: Result<usize>) -> usize { @@ -51,7 +53,7 @@ impl Pal for Sys { fn access(path: *const c_char, mode: c_int) -> c_int { let fd = match RawFile::open(path, 0, 0) { Ok(fd) => fd, - Err(_) => return -1 + Err(_) => return -1, }; if mode == F_OK { return 0; @@ -82,8 +84,9 @@ impl Pal for Sys { stat.st_mode & 0o7 }; if (mode & R_OK == R_OK && perms & 0o4 != 0o4) - || (mode & W_OK == W_OK && perms & 0o2 != 0o2) - || (mode & X_OK == X_OK && perms & 0o1 != 0o1) { + || (mode & W_OK == W_OK && perms & 0o2 != 0o2) + || (mode & X_OK == X_OK && perms & 0o1 != 0o1) + { unsafe { errno = EINVAL; } @@ -166,7 +169,7 @@ impl Pal for Sys { let fd = match RawFile::open(path, O_RDONLY as c_int, 0) { Ok(fd) => fd, - Err(_) => return -1 + Err(_) => return -1, }; let mut len = 0; @@ -383,12 +386,12 @@ impl Pal for Sys { Ok(Some(b)) => { *name = b as c_char; name = name.offset(1); - }, + } Ok(None) => { *name = 0; break; - }, - Err(()) => return -1 + } + Err(()) => return -1, } } 0 @@ -694,10 +697,9 @@ impl Pal for Sys { return -1; } - let read = e(syscall::read(dup, unsafe { slice::from_raw_parts_mut( - out as *mut u8, - mem::size_of::<termios>() - ) })); + let read = e(syscall::read(dup, unsafe { + slice::from_raw_parts_mut(out as *mut u8, mem::size_of::<termios>()) + })); let _ = syscall::close(dup); if read == !0 { @@ -712,10 +714,9 @@ impl Pal for Sys { return -1; } - let write = e(syscall::write(dup, unsafe { slice::from_raw_parts( - value as *const u8, - mem::size_of::<termios>() - ) })); + let write = e(syscall::write(dup, unsafe { + slice::from_raw_parts(value as *const u8, mem::size_of::<termios>()) + })); let _ = syscall::close(dup); if write == !0 { diff --git a/src/platform/redox/signal.rs b/src/platform/redox/signal.rs index 76b8b818a444e1d8e5e25d7f8a550b891edbeacf..abbf8bd0d3c2607056d300c9f96c15cabc3a85fb 100644 --- a/src/platform/redox/signal.rs +++ b/src/platform/redox/signal.rs @@ -1,8 +1,8 @@ use syscall; -use super::{e, Sys}; -use super::super::{Pal, PalSignal}; use super::super::types::*; +use super::super::{Pal, PalSignal}; +use super::{e, Sys}; #[thread_local] static mut SIG_HANDLER: Option<extern "C" fn(c_int)> = None; diff --git a/src/platform/redox/socket.rs b/src/platform/redox/socket.rs index 7de759dab56c15a2812863efc3352385f88f5fd6..501c4b899b77c26534de066f06a3b913db890f17 100644 --- a/src/platform/redox/socket.rs +++ b/src/platform/redox/socket.rs @@ -1,10 +1,10 @@ use core::{mem, ptr, slice}; -use syscall::{self, Result}; use syscall::flag::*; +use syscall::{self, Result}; -use super::{e, Sys}; -use super::super::{errno, Pal, PalSocket}; use super::super::types::*; +use super::super::{errno, Pal, PalSocket}; +use super::{e, Sys}; macro_rules! bind_or_connect { (bind $path:expr) => { diff --git a/src/platform/types.rs b/src/platform/types.rs index bff380a3b873c3873486d2ae17477e0a9cf6a722..bcccee75fc42820e0b71c3adfa8902738f9a2c9f 100644 --- a/src/platform/types.rs +++ b/src/platform/types.rs @@ -257,5 +257,5 @@ pub struct termios { c_line: cc_t, c_cc: [cc_t; NCCS], __c_ispeed: speed_t, - __c_ospeed: speed_t + __c_ospeed: speed_t, } diff --git a/src/start.rs b/src/start.rs index e628c4f0df2fada28ffb959eda763ee323e59ddd..02e739f82890fc25b97702b4bd86b1c6dcc38f74 100644 --- a/src/start.rs +++ b/src/start.rs @@ -3,8 +3,8 @@ use core::ptr; use header::stdio; use platform; -use platform::{Pal, Sys}; use platform::types::*; +use platform::{Pal, Sys}; #[repr(C)] pub struct Stack { @@ -68,6 +68,6 @@ pub unsafe extern "C" fn relibc_start(sp: &'static Stack) -> ! { argv, // not envp, because programs like bash try to modify this *const* // pointer :| - platform::environ as *const *const c_char + platform::environ as *const *const c_char, )); }