• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 mod alloc;
6 pub mod descriptor;
7 pub mod descriptor_reflection;
8 mod errno;
9 pub mod external_mapping;
10 pub mod scoped_event_macro;
11 mod tube;
12 
13 #[cfg(unix)]
14 pub mod unix;
15 
16 #[cfg(windows)]
17 pub mod windows;
18 
19 pub use alloc::LayoutAllocation;
20 pub use errno::{errno_result, Error, Result};
21 pub use external_mapping::{Error as ExternalMappingError, Result as ExternalMappingResult, *};
22 pub use scoped_event_macro::*;
23 pub use tube::{Error as TubeError, RecvTube, Result as TubeResult, SendTube, Tube};
24 
25 cfg_if::cfg_if! {
26      if #[cfg(unix)] {
27         mod event;
28         mod ioctl;
29         mod mmap;
30         mod notifiers;
31         mod shm;
32         mod timer;
33         mod wait_context;
34 
35         pub use unix as platform;
36 
37         pub use unix::net::*;
38         pub use unix::ioctl::*;
39 
40         pub use event::{Event, EventReadResult, ScopedEvent};
41         pub use crate::ioctl::{
42             ioctl, ioctl_with_mut_ptr, ioctl_with_mut_ref, ioctl_with_ptr, ioctl_with_ref, ioctl_with_val,
43         };
44         pub use mmap::{
45             MemoryMapping, MemoryMappingBuilder, MemoryMappingBuilderUnix, Unix as MemoryMappingUnix,
46         };
47         pub use notifiers::*;
48         pub use shm::{SharedMemory, Unix as SharedMemoryUnix};
49         pub use timer::{FakeTimer, Timer};
50         pub use wait_context::{EventToken, EventType, TriggeredEvent, WaitContext};
51      } else if #[cfg(windows)] {
52         pub use windows as platform;
53         pub use tube::{set_duplicate_handle_tube, set_alias_pid, DuplicateHandleTube};
54      } else {
55         compile_error!("Unsupported platform");
56      }
57 }
58 
59 pub use crate::descriptor::{
60     AsRawDescriptor, AsRawDescriptors, Descriptor, FromRawDescriptor, IntoRawDescriptor,
61     SafeDescriptor,
62 };
63 pub use platform::*;
64