summaryrefslogtreecommitdiff
path: root/src/sys/mod.rs
diff options
context:
space:
mode:
authorVincent Dagonneau <vincentdagonneau@gmail.com>2020-03-19 11:40:53 +0100
committerAlan Somers <asomers@gmail.com>2021-12-20 18:47:16 -0700
commit5f5b7d4d7a76575673b57e685c13ba2c52c4183e (patch)
tree75b45fc8b1b70750783e89069bc4d90810c500fe /src/sys/mod.rs
parentd1c6fed481638405b0a87e5b7eecf82ce89b2268 (diff)
downloadnix-5f5b7d4d7a76575673b57e685c13ba2c52c4183e.zip
feature-gate most Nix functions
Using features reduces build time and size for consumer crates. By default all features are enabled.
Diffstat (limited to 'src/sys/mod.rs')
-rw-r--r--src/sys/mod.rs175
1 files changed, 124 insertions, 51 deletions
diff --git a/src/sys/mod.rs b/src/sys/mod.rs
index 156b0d9d..16ba9e0a 100644
--- a/src/sys/mod.rs
+++ b/src/sys/mod.rs
@@ -5,24 +5,31 @@
target_os = "linux",
target_os = "macos",
target_os = "netbsd"))]
-pub mod aio;
-
-#[cfg(any(target_os = "android", target_os = "linux"))]
-#[allow(missing_docs)]
-pub mod epoll;
-
-#[cfg(any(target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd"))]
-#[allow(missing_docs)]
-pub mod event;
-
-#[cfg(any(target_os = "android", target_os = "linux"))]
-#[allow(missing_docs)]
-pub mod eventfd;
+feature! {
+ #![feature = "aio"]
+ pub mod aio;
+}
+
+feature! {
+ #![feature = "event"]
+
+ #[cfg(any(target_os = "android", target_os = "linux"))]
+ #[allow(missing_docs)]
+ pub mod epoll;
+
+ #[cfg(any(target_os = "dragonfly",
+ target_os = "freebsd",
+ target_os = "ios",
+ target_os = "macos",
+ target_os = "netbsd",
+ target_os = "openbsd"))]
+ #[allow(missing_docs)]
+ pub mod event;
+
+ #[cfg(any(target_os = "android", target_os = "linux"))]
+ #[allow(missing_docs)]
+ pub mod eventfd;
+}
#[cfg(any(target_os = "android",
target_os = "dragonfly",
@@ -34,21 +41,35 @@ pub mod eventfd;
target_os = "netbsd",
target_os = "illumos",
target_os = "openbsd"))]
+#[cfg(feature = "ioctl")]
+#[cfg_attr(docsrs, doc(cfg(feature = "ioctl")))]
#[macro_use]
pub mod ioctl;
#[cfg(target_os = "linux")]
-pub mod memfd;
+feature! {
+ #![feature = "fs"]
+ pub mod memfd;
+}
#[cfg(not(target_os = "redox"))]
-#[allow(missing_docs)]
-pub mod mman;
+feature! {
+ #![feature = "mman"]
+ #[allow(missing_docs)]
+ pub mod mman;
+}
#[cfg(target_os = "linux")]
-#[allow(missing_docs)]
-pub mod personality;
+feature! {
+ #![feature = "personality"]
+ #[allow(missing_docs)]
+ pub mod personality;
+}
-pub mod pthread;
+feature! {
+ #![feature = "pthread"]
+ pub mod pthread;
+}
#[cfg(any(target_os = "android",
target_os = "dragonfly",
@@ -57,41 +78,68 @@ pub mod pthread;
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd"))]
-#[allow(missing_docs)]
-pub mod ptrace;
+feature! {
+ #![feature = "ptrace"]
+ #[allow(missing_docs)]
+ pub mod ptrace;
+}
#[cfg(target_os = "linux")]
-pub mod quota;
+feature! {
+ #![feature = "quota"]
+ pub mod quota;
+}
-#[cfg(any(target_os = "linux"))]
-#[allow(missing_docs)]
-pub mod reboot;
+#[cfg(target_os = "linux")]
+feature! {
+ #![feature = "reboot"]
+ #[allow(missing_docs)]
+ pub mod reboot;
+}
#[cfg(not(any(target_os = "redox", target_os = "fuchsia", target_os = "illumos")))]
-pub mod resource;
+feature! {
+ #![feature = "resource"]
+ pub mod resource;
+}
#[cfg(not(target_os = "redox"))]
-pub mod select;
+feature! {
+ #![feature = "poll"]
+ pub mod select;
+}
#[cfg(any(target_os = "android",
target_os = "freebsd",
target_os = "ios",
target_os = "linux",
target_os = "macos"))]
-pub mod sendfile;
+feature! {
+ #![feature = "zerocopy"]
+ pub mod sendfile;
+}
pub mod signal;
#[cfg(any(target_os = "android", target_os = "linux"))]
-#[allow(missing_docs)]
-pub mod signalfd;
+feature! {
+ #![feature = "signal"]
+ #[allow(missing_docs)]
+ pub mod signalfd;
+}
#[cfg(not(target_os = "redox"))]
-#[allow(missing_docs)]
-pub mod socket;
-
-#[allow(missing_docs)]
-pub mod stat;
+feature! {
+ #![feature = "socket"]
+ #[allow(missing_docs)]
+ pub mod socket;
+}
+
+feature! {
+ #![feature = "fs"]
+ #[allow(missing_docs)]
+ pub mod stat;
+}
#[cfg(any(target_os = "android",
target_os = "dragonfly",
@@ -101,30 +149,55 @@ pub mod stat;
target_os = "macos",
target_os = "openbsd"
))]
-pub mod statfs;
+feature! {
+ #![feature = "fs"]
+ pub mod statfs;
+}
-pub mod statvfs;
+feature! {
+ #![feature = "fs"]
+ pub mod statvfs;
+}
#[cfg(any(target_os = "android", target_os = "linux"))]
+#[cfg_attr(docsrs, doc(cfg(all())))]
#[allow(missing_docs)]
pub mod sysinfo;
-#[allow(missing_docs)]
-pub mod termios;
+feature! {
+ #![feature = "term"]
+ #[allow(missing_docs)]
+ pub mod termios;
+}
#[allow(missing_docs)]
pub mod time;
-pub mod uio;
+feature! {
+ #![feature = "uio"]
+ pub mod uio;
+}
-pub mod utsname;
+feature! {
+ #![feature = "features"]
+ pub mod utsname;
+}
-pub mod wait;
+feature! {
+ #![feature = "process"]
+ pub mod wait;
+}
#[cfg(any(target_os = "android", target_os = "linux"))]
-#[allow(missing_docs)]
-pub mod inotify;
+feature! {
+ #![feature = "inotify"]
+ #[allow(missing_docs)]
+ pub mod inotify;
+}
#[cfg(any(target_os = "android", target_os = "linux"))]
-#[allow(missing_docs)]
-pub mod timerfd;
+feature! {
+ #![feature = "time"]
+ #[allow(missing_docs)]
+ pub mod timerfd;
+}