Commit 7f2d0b42 authored by Paul Sajna's avatar Paul Sajna

fmt.sh

parent 632e88fd
Pipeline #793 failed with stages
in 4 minutes and 55 seconds
......@@ -9,8 +9,8 @@ extern crate alloc;
extern crate errno;
extern crate netinet;
extern crate platform;
extern crate utils;
extern crate sys_socket;
extern crate utils;
use core::str::FromStr;
use core::{mem, ptr, slice, str};
......@@ -18,7 +18,7 @@ use errno::*;
pub use netinet::in_h::*;
use platform::types::*;
use platform::{socklen_t, AF_INET};
use utils::{c_str};
use utils::c_str;
#[no_mangle]
pub extern "C" fn htonl(hostlong: u32) -> u32 {
......
......@@ -69,7 +69,7 @@ pub struct sigaction {
pub sa_handler: extern "C" fn(c_int),
pub sa_flags: c_ulong,
pub sa_restorer: unsafe extern "C" fn(),
pub sa_mask: sigset_t
pub sa_mask: sigset_t,
}
const NSIG: usize = 64;
......
......@@ -350,7 +350,13 @@ pub fn shutdown(socket: c_int, how: c_int) -> c_int {
}
pub unsafe fn sigaction(sig: c_int, act: *const sigaction, oact: *mut sigaction) -> c_int {
e(syscall!(RT_SIGACTION, sig, act, oact, mem::size_of::<sigset_t>())) as c_int
e(syscall!(
RT_SIGACTION,
sig,
act,
oact,
mem::size_of::<sigset_t>()
)) as c_int
}
pub fn sigprocmask(how: c_int, set: *const sigset_t, oset: *mut sigset_t) -> c_int {
......
......@@ -613,14 +613,14 @@ pub unsafe fn sigaction(sig: c_int, act: *const sigaction, oact: *mut sigaction)
Some(syscall::SigAction {
sa_handler: sig_handler,
sa_mask: [m[0] as u64, 0],
sa_flags: (*act).sa_flags as usize
sa_flags: (*act).sa_flags as usize,
})
};
let mut old = syscall::SigAction::default();
let ret = e(syscall::sigaction(
sig as usize,
act.as_ref(),
if oact.is_null() { None } else { Some(&mut old) }
if oact.is_null() { None } else { Some(&mut old) },
)) as c_int;
if !oact.is_null() {
let m = old.sa_mask;
......
......@@ -27,7 +27,7 @@ pub struct sigaction {
pub sa_handler: extern "C" fn(c_int),
pub sa_flags: c_ulong,
pub sa_restorer: unsafe extern "C" fn(),
pub sa_mask: sigset_t
pub sa_mask: sigset_t,
}
const NSIG: usize = 64;
......@@ -35,8 +35,8 @@ const NSIG: usize = 64;
pub use sys::*;
use core::{mem, ptr};
use platform::types::*;
use platform::sigset_t;
use platform::types::*;
#[no_mangle]
pub extern "C" fn kill(pid: pid_t, sig: c_int) -> c_int {
......@@ -54,7 +54,11 @@ pub extern "C" fn raise(sig: c_int) -> c_int {
}
#[no_mangle]
pub unsafe extern "C" fn sigaction(sig: c_int, act: *const sigaction, oact: *mut sigaction) -> c_int {
pub unsafe extern "C" fn sigaction(
sig: c_int,
act: *const sigaction,
oact: *mut sigaction,
) -> c_int {
let mut _sigaction = None;
let ptr = if !act.is_null() {
_sigaction = Some((*act).clone());
......@@ -120,7 +124,7 @@ pub extern "C" fn signal(sig: c_int, func: extern "C" fn(c_int)) -> extern "C" f
sa_handler: func,
sa_flags: SA_RESTART as c_ulong,
sa_restorer: __restore_rt,
sa_mask: sigset_t::default()
sa_mask: sigset_t::default(),
};
let mut old_sa = unsafe { mem::uninitialized() };
if unsafe { sigaction(sig, &sa, &mut old_sa) } < 0 {
......
// Needs to be defined in assembly because it can't have a function prologue
#[cfg(target_arch = "x86_64")]
global_asm!("
global_asm!(
"
.global __restore_rt
__restore_rt:
mov $15, %rax # <- rax is register, 15 is RT_SIGRETURN
syscall
");
"
);
#[cfg(target_arch = "aarch64")]
global_asm!("
global_asm!(
"
.global __restore_rt
__restore_rt:
mov x8, #139 # <- x8 is register, 139 is RT_SIGRETURN
svc 0
");
"
);
pub const SIGHUP: usize = 1;
pub const SIGINT: usize = 2;
......
// Needs to be defined in assembly because it can't have a function prologue
#[cfg(target_arch = "x86_64")]
global_asm!("
global_asm!(
"
.global __restore_rt
__restore_rt:
mov $119, %rax # <- rax is register, 119 is SIGRETURN
int $0x80
");
"
);
#[cfg(target_arch = "aarch64")]
global_asm!("
global_asm!(
"
.global __restore_rt
__restore_rt:
mov x8, #119 # <- x8 is register, 119 is SIGRETURN
svc 0
");
"
);
pub const SIGHUP: usize = 1;
pub const SIGINT: usize = 2;
......
......@@ -12,8 +12,8 @@ extern crate fcntl;
#[macro_use]
extern crate lazy_static;
extern crate platform;
extern crate utils;
extern crate string;
extern crate utils;
extern crate va_list as vl;
use core::fmt::Write as WriteFmt;
......@@ -23,8 +23,8 @@ use core::{ptr, str};
use alloc::vec::Vec;
use errno::STR_ERROR;
use platform::types::*;
use platform::errno;
use platform::types::*;
use utils::{c_str, Read, Write};
use vl::VaList as va_list;
......@@ -935,9 +935,5 @@ pub unsafe extern "C" fn vscanf(format: *const c_char, ap: va_list) -> c_int {
#[no_mangle]
pub unsafe extern "C" fn vsscanf(s: *const c_char, format: *const c_char, ap: va_list) -> c_int {
scanf::scanf(
&mut utils::UnsafeStringReader(s as *const u8),
format,
ap,
)
scanf::scanf(&mut utils::UnsafeStringReader(s as *const u8), format, ap)
}
......@@ -7,11 +7,11 @@ extern crate ctype;
extern crate errno;
extern crate fcntl;
extern crate platform;
extern crate utils;
extern crate rand;
extern crate string;
extern crate time;
extern crate unistd;
extern crate utils;
extern crate wchar;
use core::{iter, mem, ptr, slice, str};
......
use alloc::string::String;
use platform::types::*;
use utils::Write;
use tm;
use utils::Write;
pub unsafe fn strftime<W: Write>(
toplevel: bool,
......
//! A set of commonly used functions to be used throughout relibc
//! A set of commonly used functions to be used throughout relibc
#![no_std]
#![feature(alloc)]
extern crate alloc;
......
use core::{mem, str, ptr};
use platform::read;
use alloc::boxed::Box;
use core::{mem, ptr, str};
use platform::read;
/// Implements an `Iterator` which returns on either newline or EOF.
#[derive(Clone, Copy)]
......@@ -37,9 +37,9 @@ impl Iterator for RawLineBuffer {
type Item = Box<str>;
fn next(&mut self) -> Option<Self::Item> {
if self.cur != 0 && self.read != 0 {
if let Some(mut pos) = self.buf[self.cur..self.read].iter().position(
|&x| x == b'\n',
)
if let Some(mut pos) = self.buf[self.cur..self.read]
.iter()
.position(|&x| x == b'\n')
{
pos += self.cur + 1;
let line = unsafe { str::from_utf8_unchecked(&self.buf[self.cur..pos]) };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment