Skip to content

Commit

Permalink
Fix compilation errors on solaris.
Browse files Browse the repository at this point in the history
  • Loading branch information
gco committed Sep 5, 2022
1 parent ed7c138 commit c066f9a
Show file tree
Hide file tree
Showing 32 changed files with 430 additions and 67 deletions.
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

0 comments on commit c066f9a

Please sign in to comment.