Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation errors on solaris. #396

Merged
merged 1 commit into from Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions examples/process.rs
Expand Up @@ -42,9 +42,13 @@ fn main() -> io::Result<()> {
println!("Data Limit: {:?}", getrlimit(Resource::Data));
println!("Stack Limit: {:?}", getrlimit(Resource::Stack));
println!("Core Limit: {:?}", getrlimit(Resource::Core));
#[cfg(not(target_os = "solaris"))]
println!("Rss Limit: {:?}", getrlimit(Resource::Rss));
#[cfg(not(target_os = "solaris"))]
println!("Nproc Limit: {:?}", getrlimit(Resource::Nproc));
#[cfg(not(target_os = "solaris"))]
println!("Nofile Limit: {:?}", getrlimit(Resource::Nofile));
#[cfg(not(target_os = "solaris"))]
println!("Memlock Limit: {:?}", getrlimit(Resource::Memlock));
#[cfg(not(target_os = "openbsd"))]
println!("As Limit: {:?}", getrlimit(Resource::As));
Expand All @@ -54,6 +58,7 @@ fn main() -> io::Result<()> {
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
)))]
println!("Locks Limit: {:?}", getrlimit(Resource::Locks));
#[cfg(not(any(
Expand All @@ -62,6 +67,7 @@ fn main() -> io::Result<()> {
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
)))]
println!("Sigpending Limit: {:?}", getrlimit(Resource::Sigpending));
#[cfg(not(any(
Expand All @@ -70,6 +76,7 @@ fn main() -> io::Result<()> {
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
)))]
println!("Msgqueue Limit: {:?}", getrlimit(Resource::Msgqueue));
#[cfg(not(any(
Expand All @@ -78,6 +85,7 @@ fn main() -> io::Result<()> {
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
)))]
println!("Nice Limit: {:?}", getrlimit(Resource::Nice));
#[cfg(not(any(
Expand All @@ -86,6 +94,7 @@ fn main() -> io::Result<()> {
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
)))]
println!("Rtprio Limit: {:?}", getrlimit(Resource::Rtprio));
#[cfg(not(any(
Expand All @@ -96,6 +105,7 @@ fn main() -> io::Result<()> {
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
)))]
println!("Rttime Limit: {:?}", getrlimit(Resource::Rttime));
#[cfg(any(
Expand Down
9 changes: 9 additions & 0 deletions examples/stdio.rs
Expand Up @@ -124,6 +124,7 @@ fn show<Fd: AsFd>(fd: Fd) -> io::Result<()> {
target_os = "netbsd",
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
)))]
if (term.c_iflag & IUTF8) != 0 {
print!(" IUTF8");
Expand Down Expand Up @@ -193,6 +194,7 @@ fn show<Fd: AsFd>(fd: Fd) -> io::Result<()> {
target_os = "netbsd",
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
)))]
if (term.c_oflag & NLDLY) != 0 {
print!(" NLDLY");
Expand All @@ -206,6 +208,7 @@ fn show<Fd: AsFd>(fd: Fd) -> io::Result<()> {
target_os = "netbsd",
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
)))]
if (term.c_oflag & CRDLY) != 0 {
print!(" CRDLY");
Expand All @@ -217,6 +220,7 @@ fn show<Fd: AsFd>(fd: Fd) -> io::Result<()> {
target_os = "openbsd",
target_os = "illumos",
target_os = "redox",
target_os = "solaris",
)))]
if (term.c_oflag & TABDLY) != 0 {
print!(" TABDLY");
Expand All @@ -230,6 +234,7 @@ fn show<Fd: AsFd>(fd: Fd) -> io::Result<()> {
target_os = "netbsd",
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
)))]
if (term.c_oflag & BSDLY) != 0 {
print!(" BSDLY");
Expand All @@ -244,6 +249,7 @@ fn show<Fd: AsFd>(fd: Fd) -> io::Result<()> {
target_os = "netbsd",
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
)))]
if (term.c_oflag & VTDLY) != 0 {
print!(" VTDLY");
Expand All @@ -258,6 +264,7 @@ fn show<Fd: AsFd>(fd: Fd) -> io::Result<()> {
target_os = "netbsd",
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
)))]
if (term.c_oflag & FFDLY) != 0 {
print!(" FFDLY");
Expand Down Expand Up @@ -286,6 +293,7 @@ fn show<Fd: AsFd>(fd: Fd) -> io::Result<()> {
target_os = "netbsd",
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
)))]
if (term.c_cflag & CBAUDEX) != 0 {
print!(" CBAUDEX");
Expand Down Expand Up @@ -339,6 +347,7 @@ fn show<Fd: AsFd>(fd: Fd) -> io::Result<()> {
target_os = "netbsd",
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
)))]
if (term.c_cflag & CMSPAR) != 0 {
print!(" CMSPAR");
Expand Down
24 changes: 18 additions & 6 deletions src/backend/libc/fs/dir.rs
@@ -1,6 +1,6 @@
use super::super::c;
use super::super::conv::owned_fd;
#[cfg(not(target_os = "illumos"))]
#[cfg(not(any(target_os = "illumos", target_os = "solaris")))]
use super::types::FileType;
use crate::fd::{AsFd, BorrowedFd};
use crate::ffi::CStr;
Expand All @@ -11,10 +11,16 @@ use crate::fs::{fcntl_getfl, fstat, openat, Mode, OFlags, Stat};
target_os = "illumos",
target_os = "netbsd",
target_os = "redox",
target_os = "solaris",
target_os = "wasi",
)))]
use crate::fs::{fstatfs, StatFs};
#[cfg(not(any(target_os = "illumos", target_os = "redox", target_os = "wasi")))]
#[cfg(not(any(
target_os = "illumos",
target_os = "redox",
target_os = "solaris",
target_os = "wasi",
)))]
use crate::fs::{fstatvfs, StatVfs};
use crate::io;
#[cfg(not(any(target_os = "fuchsia", target_os = "wasi")))]
Expand Down Expand Up @@ -134,6 +140,7 @@ impl Dir {
target_os = "illumos",
target_os = "netbsd",
target_os = "redox",
target_os = "solaris",
target_os = "wasi",
)))]
#[inline]
Expand All @@ -142,7 +149,12 @@ impl Dir {
}

/// `fstatvfs(self)`
#[cfg(not(any(target_os = "illumos", target_os = "redox", target_os = "wasi")))]
#[cfg(not(any(
target_os = "illumos",
target_os = "redox",
target_os = "solaris",
target_os = "wasi",
)))]
#[inline]
pub fn statvfs(&self) -> io::Result<StatVfs> {
fstatvfs(unsafe { BorrowedFd::borrow_raw(c::dirfd(self.0.as_ptr())) })
Expand All @@ -160,7 +172,7 @@ impl Dir {
// struct, as the name is NUL-terminated and memory may not be allocated for
// the full extent of the struct. Copy the fields one at a time.
unsafe fn read_dirent(input: &libc_dirent) -> libc_dirent {
#[cfg(not(target_os = "illumos"))]
#[cfg(not(any(target_os = "illumos", target_os = "solaris")))]
let d_type = input.d_type;

#[cfg(not(any(
Expand Down Expand Up @@ -204,7 +216,7 @@ unsafe fn read_dirent(input: &libc_dirent) -> libc_dirent {
// whole `d_name` field, which may not be entirely allocated.
#[cfg_attr(target_os = "wasi", allow(unused_mut))]
let mut dirent = libc_dirent {
#[cfg(not(target_os = "illumos"))]
#[cfg(not(any(target_os = "illumos", target_os = "solaris")))]
d_type,
#[cfg(not(any(
target_os = "dragonfly",
Expand Down Expand Up @@ -315,7 +327,7 @@ impl DirEntry {
}

/// Returns the type of this directory entry.
#[cfg(not(target_os = "illumos"))]
#[cfg(not(any(target_os = "illumos", target_os = "solaris")))]
#[inline]
pub fn file_type(&self) -> FileType {
FileType::from_dirent_d_type(self.dirent.d_type)
Expand Down
1 change: 1 addition & 0 deletions src/backend/libc/fs/mod.rs
Expand Up @@ -10,6 +10,7 @@ pub(crate) mod dir;
target_os = "netbsd",
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
target_os = "wasi",
)))]
pub(crate) mod makedev;
Expand Down
58 changes: 49 additions & 9 deletions src/backend/libc/fs/syscalls.rs
Expand Up @@ -16,6 +16,7 @@ use super::super::offset::libc_fallocate;
target_os = "netbsd",
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
)))]
use super::super::offset::libc_posix_fadvise;
#[cfg(not(any(
Expand All @@ -29,17 +30,24 @@ use super::super::offset::libc_posix_fadvise;
target_os = "netbsd",
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
)))]
use super::super::offset::libc_posix_fallocate;
use super::super::offset::{libc_fstat, libc_fstatat, libc_ftruncate, libc_lseek, libc_off_t};
#[cfg(not(any(
target_os = "illumos",
target_os = "netbsd",
target_os = "redox",
target_os = "solaris",
target_os = "wasi",
)))]
use super::super::offset::{libc_fstatfs, libc_statfs};
#[cfg(not(any(target_os = "illumos", target_os = "redox", target_os = "wasi")))]
#[cfg(not(any(
target_os = "illumos",
target_os = "redox",
target_os = "solaris",
target_os = "wasi",
)))]
use super::super::offset::{libc_fstatvfs, libc_statvfs};
#[cfg(all(
any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
Expand All @@ -52,7 +60,7 @@ use crate::fd::{BorrowedFd, OwnedFd};
use crate::ffi::CStr;
#[cfg(any(target_os = "ios", target_os = "macos"))]
use crate::ffi::CString;
#[cfg(not(target_os = "illumos"))]
#[cfg(not(any(target_os = "illumos", target_os = "solaris")))]
use crate::fs::Access;
#[cfg(not(any(
target_os = "dragonfly",
Expand All @@ -62,6 +70,7 @@ use crate::fs::Access;
target_os = "netbsd",
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
)))]
use crate::fs::Advice;
#[cfg(not(any(
Expand All @@ -70,9 +79,10 @@ use crate::fs::Advice;
target_os = "netbsd",
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
)))]
use crate::fs::FallocateFlags;
#[cfg(not(target_os = "wasi"))]
#[cfg(not(any(target_os = "solaris", target_os = "wasi")))]
use crate::fs::FlockOperation;
#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))]
use crate::fs::MemfdFlags;
Expand All @@ -87,6 +97,7 @@ use crate::fs::SealFlags;
target_os = "illumos",
target_os = "netbsd",
target_os = "redox",
target_os = "solaris",
target_os = "wasi",
)))]
use crate::fs::StatFs;
Expand All @@ -100,7 +111,12 @@ use crate::fs::{cwd, RenameFlags, ResolveFlags, Statx, StatxFlags};
)))]
use crate::fs::{Dev, FileType};
use crate::fs::{FdFlags, Mode, OFlags, Stat, Timestamps};
#[cfg(not(any(target_os = "illumos", target_os = "redox", target_os = "wasi")))]
#[cfg(not(any(
target_os = "illumos",
target_os = "redox",
target_os = "solaris",
target_os = "wasi",
)))]
use crate::fs::{StatVfs, StatVfsMountFlags};
use crate::io::{self, SeekFrom};
#[cfg(not(target_os = "wasi"))]
Expand Down Expand Up @@ -202,6 +218,7 @@ pub(crate) fn openat(
target_os = "illumos",
target_os = "netbsd",
target_os = "redox",
target_os = "solaris",
target_os = "wasi",
)))]
#[inline]
Expand All @@ -213,7 +230,12 @@ pub(crate) fn statfs(filename: &CStr) -> io::Result<StatFs> {
}
}

#[cfg(not(any(target_os = "illumos", target_os = "redox", target_os = "wasi")))]
#[cfg(not(any(
target_os = "illumos",
target_os = "redox",
target_os = "solaris",
target_os = "wasi",
)))]
#[inline]
pub(crate) fn statvfs(filename: &CStr) -> io::Result<StatVfs> {
unsafe {
Expand Down Expand Up @@ -403,7 +425,12 @@ fn statat_old(dirfd: BorrowedFd<'_>, path: &CStr, flags: AtFlags) -> io::Result<
}
}

#[cfg(not(any(target_os = "emscripten", target_os = "illumos", target_os = "redox")))]
#[cfg(not(any(
target_os = "emscripten",
target_os = "illumos",
target_os = "redox",
target_os = "solaris",
)))]
pub(crate) fn accessat(
dirfd: BorrowedFd<'_>,
path: &CStr,
Expand Down Expand Up @@ -776,6 +803,7 @@ pub(crate) fn copy_file_range(
target_os = "netbsd",
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
)))]
pub(crate) fn fadvise(fd: BorrowedFd<'_>, offset: u64, len: u64, advice: Advice) -> io::Result<()> {
let offset = offset as i64;
Expand Down Expand Up @@ -910,7 +938,7 @@ pub(crate) fn fchown(fd: BorrowedFd<'_>, owner: Option<Uid>, group: Option<Gid>)
}
}

#[cfg(not(target_os = "wasi"))]
#[cfg(not(any(target_os = "solaris", target_os = "wasi")))]
pub(crate) fn flock(fd: BorrowedFd<'_>, operation: FlockOperation) -> io::Result<()> {
unsafe { ret(c::flock(borrowed_fd(fd), operation as c::c_int)) }
}
Expand Down Expand Up @@ -959,6 +987,7 @@ fn fstat_old(fd: BorrowedFd<'_>) -> io::Result<Stat> {
target_os = "illumos",
target_os = "netbsd",
target_os = "redox",
target_os = "solaris",
target_os = "wasi",
)))]
pub(crate) fn fstatfs(fd: BorrowedFd<'_>) -> io::Result<StatFs> {
Expand All @@ -969,7 +998,12 @@ pub(crate) fn fstatfs(fd: BorrowedFd<'_>) -> io::Result<StatFs> {
}
}

#[cfg(not(any(target_os = "illumos", target_os = "redox", target_os = "wasi")))]
#[cfg(not(any(
target_os = "illumos",
target_os = "redox",
target_os = "solaris",
target_os = "wasi",
)))]
pub(crate) fn fstatvfs(fd: BorrowedFd<'_>) -> io::Result<StatVfs> {
let mut statvfs = MaybeUninit::<libc_statvfs>::uninit();
unsafe {
Expand All @@ -978,7 +1012,12 @@ pub(crate) fn fstatvfs(fd: BorrowedFd<'_>) -> io::Result<StatVfs> {
}
}

#[cfg(not(any(target_os = "illumos", target_os = "redox", target_os = "wasi")))]
#[cfg(not(any(
target_os = "illumos",
target_os = "redox",
target_os = "solaris",
target_os = "wasi"
)))]
fn libc_statvfs_to_statvfs(from: libc_statvfs) -> StatVfs {
StatVfs {
f_bsize: from.f_bsize as u64,
Expand Down Expand Up @@ -1104,6 +1143,7 @@ unsafe fn futimens_old(fd: BorrowedFd<'_>, times: &Timestamps) -> io::Result<()>
target_os = "netbsd",
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
)))]
pub(crate) fn fallocate(
fd: BorrowedFd<'_>,
Expand Down