Format
This commit is contained in:
@@ -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 "$@"
|
||||
|
||||
+44
-23
@@ -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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-3
@@ -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) }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
sys_includes = []
|
||||
include_guard = "_PTHREAD_H"
|
||||
language = "C"
|
||||
style = "Tag"
|
||||
|
||||
[enum]
|
||||
prefix_with_name = true
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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!();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
sys_includes = []
|
||||
include_guard = "_AIO_H"
|
||||
language = "C"
|
||||
style = "Tag"
|
||||
|
||||
[enum]
|
||||
prefix_with_name = true
|
||||
@@ -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!();
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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::*;
|
||||
|
||||
|
||||
+21
-14
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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",
|
||||
];
|
||||
|
||||
@@ -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) };
|
||||
|
||||
@@ -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),
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use platform::{Pal, Sys};
|
||||
use platform::types::*;
|
||||
use platform::{Pal, Sys};
|
||||
|
||||
pub use self::sys::*;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
use core::ptr;
|
||||
|
||||
use platform;
|
||||
use platform::{PalSocket, Sys};
|
||||
use platform::types::*;
|
||||
use platform::{PalSocket, Sys};
|
||||
|
||||
mod constants;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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::*;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
+4
-4
@@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use core::ops::Deref;
|
||||
|
||||
use super::{Pal, Sys, types::*};
|
||||
use super::{types::*, Pal, Sys};
|
||||
|
||||
pub struct RawFile(c_int);
|
||||
|
||||
|
||||
+20
-19
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
+2
-2
@@ -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,
|
||||
));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user