Skip to content

Commit

Permalink
Add a linux_kernel cfg, to simplify a common platform set. (#675)
Browse files Browse the repository at this point in the history
"android" and "linux" share much in common, so add a `linux_kernel`
config to factor out `any(target_os = "android", target_os = "linux")`.
  • Loading branch information
sunfishcode authored May 21, 2023
1 parent 1c1fc80 commit 730b0d2
Show file tree
Hide file tree
Showing 91 changed files with 380 additions and 567 deletions.
6 changes: 6 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ fn main() {
{
use_feature("bsd");
}

// Add some additional common target combinations.
if target_os == "android" || target_os == "linux" {
use_feature("linux_kernel");
}

if target_os == "wasi" {
use_feature_or_nothing("wasi_ext");
}
Expand Down
4 changes: 2 additions & 2 deletions src/backend/libc/c.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pub(crate) use libc::*;

/// `PROC_SUPER_MAGIC`—The magic number for the procfs filesystem.
#[cfg(all(any(target_os = "android", target_os = "linux"), target_env = "musl"))]
#[cfg(all(linux_kernel, target_env = "musl"))]
pub(crate) const PROC_SUPER_MAGIC: u32 = 0x0000_9fa0;

/// `NFS_SUPER_MAGIC`—The magic number for the NFS filesystem.
#[cfg(all(any(target_os = "android", target_os = "linux"), target_env = "musl"))]
#[cfg(all(linux_kernel, target_env = "musl"))]
pub(crate) const NFS_SUPER_MAGIC: u32 = 0x0000_6969;
2 changes: 1 addition & 1 deletion src/backend/libc/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub(super) fn syscall_ret_usize(raw: c::c_long) -> io::Result<usize> {
}
}

#[cfg(any(target_os = "android", target_os = "linux"))]
#[cfg(linux_kernel)]
#[inline]
pub(super) fn syscall_ret_u32(raw: c::c_long) -> io::Result<u32> {
if raw == -1 {
Expand Down
2 changes: 1 addition & 1 deletion src/backend/libc/fs/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[cfg(not(target_os = "redox"))]
pub(crate) mod dir;
#[cfg(any(target_os = "android", target_os = "linux"))]
#[cfg(linux_kernel)]
pub mod inotify;
#[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "wasi")))]
pub(crate) mod makedev;
Expand Down
Loading

0 comments on commit 730b0d2

Please sign in to comment.