1// devela::sys::os::linux
2//
3//! Linux-specific definitions
4//!
5//! # Supported architectures
6//!
7//! Linux functionality will only be compiled in the following target architectures:
8//! - `x86-64`, `x86`, `ARM`, `AArch64`, `RISC-V RV32`, `RISC-V RV64`.
9//!
10//! Apart from that, this module will compile without checking whether the
11//! current OS is `linux`, since that would require enabling `std` and the
12//! whole point is to be able to use all of this functionality from `no_std`.
13//
14// NOTE: doc cfg attributes for target_arch are hidden from reexports
15// in order to be have a more concise documentation in the libera crate.
16// This is achieved by attaching a brief version to the item itself,
17// and attaching a complete version to the module that reexports them.
18//
19// This is so both for syscalls and safe syscall wrappers. And when more
20// platforms are supported they will all need to be updated accordingly.
2122mod consts;
23mod structs;
2425#[cfg(all(feature = "unsafe_syscall", not(miri)))]
26#[cfg_attr(feature = "nightly_doc", doc(cfg(feature = "unsafe_syscall")))]
27mod fns;
2829#[cfg(all(feature = "unsafe_syscall", not(miri)))]
30#[cfg_attr(feature = "nightly_doc", doc(cfg(feature = "unsafe_syscall")))]
31mod terminal;
3233/// Linux-specific extensions to [`std::io`].
34pub mod io {
35#[allow(unused)]
36pub use _all::*;
37pub(super) mod _all {
38#[cfg(all(
39 any(
40 target_arch = "x86_64",
41 target_arch = "x86",
42 target_arch = "arm",
43 target_arch = "aarch64",
44 target_arch = "riscv32",
45 target_arch = "riscv64"
46),
47 feature = "unsafe_syscall",
48 not(miri),
49 ))]
50pub use super::super::{
51 consts::termios::*,
52 fns::{
53 linux_eprint, linux_eprintln, linux_get_byte, linux_get_char, linux_get_dirty_char,
54 linux_get_line, linux_get_str, linux_get_utf8_bytes, linux_pause_until_char,
55 linux_print, linux_print_bytes, linux_println, linux_prompt, linux_random_bytes,
56 linux_random_u128, linux_random_u16, linux_random_u32, linux_random_u64,
57 linux_random_u8, linux_sys_getrandom, linux_sys_ioctl, linux_sys_read,
58 linux_sys_write,
59 },
60 structs::{LinuxTerminalSize, LinuxTermios},
61 };
62 }
63}
6465/// Linux-specific extensions to [`std::process`].
66pub mod process {
67#[allow(unused)]
68pub use _all::*;
69pub(super) mod _all {
70#[cfg(all(
71 any(
72 target_arch = "x86_64",
73 target_arch = "x86",
74 target_arch = "arm",
75 target_arch = "aarch64",
76 target_arch = "riscv32",
77 target_arch = "riscv64"
78),
79 feature = "unsafe_syscall",
80 not(miri),
81 ))]
82pub use super::super::{
83 consts::signal::*,
84 fns::{linux_sig_handler_no_return, linux_sys_exit, linux_sys_rt_sigaction},
85 structs::{LinuxSigaction, LinuxSigset},
86 };
87 }
88}
8990/// Linux-specific extensions to [`std::thread`].
91pub mod thread {
92#[allow(unused)]
93pub use _all::*;
94pub(super) mod _all {
95#[cfg(all(
96 any(
97 target_arch = "x86_64",
98 target_arch = "x86",
99 target_arch = "arm",
100 target_arch = "aarch64",
101 target_arch = "riscv32",
102 target_arch = "riscv64"
103),
104 feature = "unsafe_syscall",
105 not(miri),
106 ))]
107pub use super::super::{
108 fns::{linux_getpid, linux_sleep, linux_sys_getpid, linux_sys_nanosleep},
109 structs::LinuxTimespec,
110 };
111 }
112}
113114crate::items! { // structural access: _mods, _pub_mods, _all
115#[allow(unused)]
116pub use _mods::*;
117#[allow(unused)] #[doc(hidden, no_inline)]
118pub use _pub_mods::*;
119120mod _mods {
121#[cfg(all(feature = "unsafe_syscall", not(miri)))]
122pub use super::terminal::*;
123 }
124mod _pub_mods { #![allow(unused)]
125pub use super::{consts::_all::*, io::_all::*, process::_all::*, thread::_all::*};
126 }
127pub(super) mod _all { #![allow(unused)]
128 #[doc(inline)]
129pub use super::{_mods::*, _pub_mods::*};
130 }
131}