forked from enarx/enarx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.rs
51 lines (41 loc) · 1.07 KB
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// SPDX-License-Identifier: Apache-2.0
//! errno type and constants for various architectures
//!
//! TODO: this crate is temporary:
//! https://github.com/enarx/enarx/issues/364
#![no_std]
#![deny(clippy::all)]
#![deny(missing_docs)]
#![allow(missing_docs)]
/// x86 errno
pub mod x86_64;
#[cfg(target_arch = "x86_64")]
pub use x86_64::*;
enumerate::enumerate! {
#[derive(Copy, Clone)]
pub enum ArchPrctlTask: u64 {
ArchSetGs = 0x1001,
ArchSetFs = 0x1002,
ArchGetFs = 0x1003,
ArchGetGs = 0x1004,
}
}
/// Buffer used by readv() and writev() syscalls
#[repr(C)]
pub struct Iovec<'a> {
/// Buffer start address
pub base: *mut u8,
/// Number of bytes to transfer
pub size: usize,
phantom: core::marker::PhantomData<&'a ()>,
}
impl<'a> AsRef<[u8]> for Iovec<'a> {
fn as_ref(&self) -> &[u8] {
unsafe { core::slice::from_raw_parts(self.base, self.size) }
}
}
impl<'a> AsMut<[u8]> for Iovec<'a> {
fn as_mut(&mut self) -> &mut [u8] {
unsafe { core::slice::from_raw_parts_mut(self.base, self.size) }
}
}