diff options
| author | Valentin <[email protected]> | 2018-06-15 18:57:24 +0200 |
|---|---|---|
| committer | FenrirWolf <[email protected]> | 2018-06-15 10:57:24 -0600 |
| commit | f2a90174bb36b9ad528e863ab34c02ebce002b02 (patch) | |
| tree | 959e8d67883d3a89e179b3549b1f30d28e51a87c /ctr-std/src/sys/redox/syscall/data.rs | |
| parent | Merge pull request #68 from linouxis9/master (diff) | |
| download | ctru-rs-f2a90174bb36b9ad528e863ab34c02ebce002b02.tar.xz ctru-rs-f2a90174bb36b9ad528e863ab34c02ebce002b02.zip | |
Update for latest nightly 2018-06-09 (#70)
* Update for latest nightly 2018-06-09
* We now have a proper horizon os and sys modules in libstd
Diffstat (limited to 'ctr-std/src/sys/redox/syscall/data.rs')
| -rw-r--r-- | ctr-std/src/sys/redox/syscall/data.rs | 201 |
1 files changed, 201 insertions, 0 deletions
diff --git a/ctr-std/src/sys/redox/syscall/data.rs b/ctr-std/src/sys/redox/syscall/data.rs new file mode 100644 index 0000000..2e784eb --- /dev/null +++ b/ctr-std/src/sys/redox/syscall/data.rs @@ -0,0 +1,201 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use core::ops::{Deref, DerefMut}; +use core::{mem, slice}; + +#[derive(Copy, Clone, Debug, Default)] +pub struct Event { + pub id: usize, + pub flags: usize, + pub data: usize +} + +impl Deref for Event { + type Target = [u8]; + fn deref(&self) -> &[u8] { + unsafe { + slice::from_raw_parts( + self as *const Event as *const u8, + mem::size_of::<Event>() + ) as &[u8] + } + } +} + +impl DerefMut for Event { + fn deref_mut(&mut self) -> &mut [u8] { + unsafe { + slice::from_raw_parts_mut( + self as *mut Event as *mut u8, + mem::size_of::<Event>() + ) as &mut [u8] + } + } +} + +#[derive(Copy, Clone, Debug, Default)] +#[repr(C)] +pub struct Packet { + pub id: u64, + pub pid: usize, + pub uid: u32, + pub gid: u32, + pub a: usize, + pub b: usize, + pub c: usize, + pub d: usize +} + +impl Deref for Packet { + type Target = [u8]; + fn deref(&self) -> &[u8] { + unsafe { + slice::from_raw_parts( + self as *const Packet as *const u8, + mem::size_of::<Packet>() + ) as &[u8] + } + } +} + +impl DerefMut for Packet { + fn deref_mut(&mut self) -> &mut [u8] { + unsafe { + slice::from_raw_parts_mut( + self as *mut Packet as *mut u8, + mem::size_of::<Packet>() + ) as &mut [u8] + } + } +} + +#[derive(Copy, Clone, Debug)] +#[repr(C)] +pub struct SigAction { + pub sa_handler: extern "C" fn(usize), + pub sa_mask: [u64; 2], + pub sa_flags: usize, +} + +impl Default for SigAction { + fn default() -> Self { + Self { + sa_handler: unsafe { mem::transmute(0usize) }, + sa_mask: [0; 2], + sa_flags: 0, + } + } +} + +#[derive(Copy, Clone, Debug, Default)] +#[repr(C)] +pub struct Stat { + pub st_dev: u64, + pub st_ino: u64, + pub st_mode: u16, + pub st_nlink: u32, + pub st_uid: u32, + pub st_gid: u32, + pub st_size: u64, + pub st_blksize: u32, + pub st_blocks: u64, + pub st_mtime: u64, + pub st_mtime_nsec: u32, + pub st_atime: u64, + pub st_atime_nsec: u32, + pub st_ctime: u64, + pub st_ctime_nsec: u32, +} + +impl Deref for Stat { + type Target = [u8]; + fn deref(&self) -> &[u8] { + unsafe { + slice::from_raw_parts( + self as *const Stat as *const u8, + mem::size_of::<Stat>() + ) as &[u8] + } + } +} + +impl DerefMut for Stat { + fn deref_mut(&mut self) -> &mut [u8] { + unsafe { + slice::from_raw_parts_mut( + self as *mut Stat as *mut u8, + mem::size_of::<Stat>() + ) as &mut [u8] + } + } +} + +#[derive(Copy, Clone, Debug, Default)] +#[repr(C)] +pub struct StatVfs { + pub f_bsize: u32, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, +} + +impl Deref for StatVfs { + type Target = [u8]; + fn deref(&self) -> &[u8] { + unsafe { + slice::from_raw_parts( + self as *const StatVfs as *const u8, + mem::size_of::<StatVfs>() + ) as &[u8] + } + } +} + +impl DerefMut for StatVfs { + fn deref_mut(&mut self) -> &mut [u8] { + unsafe { + slice::from_raw_parts_mut( + self as *mut StatVfs as *mut u8, + mem::size_of::<StatVfs>() + ) as &mut [u8] + } + } +} + +#[derive(Copy, Clone, Debug, Default)] +#[repr(C)] +pub struct TimeSpec { + pub tv_sec: i64, + pub tv_nsec: i32, +} + +impl Deref for TimeSpec { + type Target = [u8]; + fn deref(&self) -> &[u8] { + unsafe { + slice::from_raw_parts( + self as *const TimeSpec as *const u8, + mem::size_of::<TimeSpec>() + ) as &[u8] + } + } +} + +impl DerefMut for TimeSpec { + fn deref_mut(&mut self) -> &mut [u8] { + unsafe { + slice::from_raw_parts_mut( + self as *mut TimeSpec as *mut u8, + mem::size_of::<TimeSpec>() + ) as &mut [u8] + } + } +} |