2020-08-03 03:09:41 +00:00
|
|
|
// Copyright 2020 The Chromium OS Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
pub use sys_util::*;
|
2020-08-06 01:50:47 +00:00
|
|
|
|
2020-09-16 22:29:20 +00:00
|
|
|
mod event;
|
2020-10-09 08:20:52 +00:00
|
|
|
mod ioctl;
|
2020-08-06 01:50:47 +00:00
|
|
|
mod mmap;
|
|
|
|
mod shm;
|
2020-08-19 21:45:21 +00:00
|
|
|
mod timer;
|
2020-10-07 10:29:24 +00:00
|
|
|
mod wait_context;
|
2020-08-06 01:50:47 +00:00
|
|
|
|
2020-09-16 22:29:20 +00:00
|
|
|
pub use event::{Event, EventReadResult, ScopedEvent};
|
2020-10-09 08:20:52 +00:00
|
|
|
pub use ioctl::{
|
|
|
|
ioctl, ioctl_with_mut_ptr, ioctl_with_mut_ref, ioctl_with_ptr, ioctl_with_ref, ioctl_with_val,
|
|
|
|
};
|
2020-10-01 06:51:39 +00:00
|
|
|
pub use mmap::{MemoryMapping, MemoryMappingBuilder};
|
2020-08-06 01:50:47 +00:00
|
|
|
pub use shm::{SharedMemory, Unix as SharedMemoryUnix};
|
2020-09-16 22:29:20 +00:00
|
|
|
pub use sys_util::ioctl::*;
|
|
|
|
pub use sys_util::sched::*;
|
|
|
|
pub use sys_util::{
|
|
|
|
volatile_at_impl, volatile_impl, FileAllocate, FileGetLen, FileReadWriteAtVolatile,
|
|
|
|
FileReadWriteVolatile, FileSetLen, FileSync,
|
|
|
|
};
|
|
|
|
pub use sys_util::{SeekHole, WriteZeroesAt};
|
2020-08-19 21:45:21 +00:00
|
|
|
pub use timer::{FakeTimer, Timer};
|
2020-10-07 10:29:24 +00:00
|
|
|
pub use wait_context::{EventToken, EventType, TriggeredEvent, WaitContext};
|
2020-08-06 01:50:47 +00:00
|
|
|
|
|
|
|
/// Wraps an AsRawDescriptor in the simple Descriptor struct, which
|
|
|
|
/// has AsRawFd methods for interfacing with sys_util
|
2020-10-07 10:29:24 +00:00
|
|
|
pub fn wrap_descriptor(descriptor: &dyn AsRawDescriptor) -> Descriptor {
|
2020-08-06 01:50:47 +00:00
|
|
|
Descriptor(descriptor.as_raw_descriptor())
|
|
|
|
}
|
2020-09-16 22:29:20 +00:00
|
|
|
|
|
|
|
/// A trait similar to `AsRawDescriptor` but supports an arbitrary number of descriptors.
|
|
|
|
pub trait AsRawDescriptors {
|
|
|
|
fn as_raw_descriptors(&self) -> Vec<RawDescriptor>;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T> AsRawDescriptors for T
|
|
|
|
where
|
|
|
|
T: AsRawDescriptor,
|
|
|
|
{
|
|
|
|
fn as_raw_descriptors(&self) -> Vec<RawDescriptor> {
|
|
|
|
vec![self.as_raw_descriptor()]
|
|
|
|
}
|
|
|
|
}
|