crosvm/base/src/lib.rs
Daniel Verkamp 418c33e605 base: unify WriteZeroes and PunchHole traits
Move the trait definitions and tests into a single cross-platform file.
The File impl is also defined in the top-level crate so it can be
exported, and that impl calls new platform-specific functions that
provide the actual implementations.

BUG=None
TEST=cargo test -p base write_zeroes
TEST=tools/dev_container tools/run_tests --target=host --arch=win64

Change-Id: I15267c27bd43385545bc406a0143e943e06b16e7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3631027
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-06 18:14:25 +00:00

65 lines
1.9 KiB
Rust

// 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.
mod alloc;
mod clock;
pub mod descriptor;
pub mod descriptor_reflection;
mod errno;
mod event;
pub mod external_mapping;
mod mmap;
mod notifiers;
pub mod scoped_event_macro;
mod shm;
pub mod syslog;
mod timer;
mod tube;
mod write_zeroes;
pub mod sys;
pub use sys::platform;
pub use alloc::LayoutAllocation;
pub use clock::{Clock, FakeClock};
pub use errno::{errno_result, Error, Result};
pub use event::{Event, EventReadResult, ScopedEvent};
pub use external_mapping::{Error as ExternalMappingError, Result as ExternalMappingResult, *};
pub use mmap::{MemoryMapping, MemoryMappingBuilder};
pub use notifiers::*;
pub use platform::ioctl::{
ioctl, ioctl_with_mut_ptr, ioctl_with_mut_ref, ioctl_with_ptr, ioctl_with_ref, ioctl_with_val,
*,
};
pub use scoped_event_macro::*;
pub use shm::SharedMemory;
pub use timer::{FakeTimer, Timer};
pub use tube::{Error as TubeError, RecvTube, Result as TubeResult, SendTube, Tube};
pub use write_zeroes::{PunchHole, WriteZeroesAt};
cfg_if::cfg_if! {
if #[cfg(unix)] {
mod wait_context;
pub use sys::unix;
pub use unix::net::*;
pub use platform::{MemoryMappingBuilderUnix, Unix as MemoryMappingUnix};
pub use wait_context::{EventToken, EventType, TriggeredEvent, WaitContext};
} else if #[cfg(windows)] {
pub use platform::MemoryMappingBuilderWindows;
pub use platform::EventExt;
pub use tube::{deserialize_and_recv, serialize_and_send, set_duplicate_handle_tube, set_alias_pid, DuplicateHandleTube};
} else {
compile_error!("Unsupported platform");
}
}
pub use crate::descriptor::{
AsRawDescriptor, AsRawDescriptors, Descriptor, FromRawDescriptor, IntoRawDescriptor,
SafeDescriptor,
};
pub use log::*;
pub use platform::*;