Skip to content

Commit

Permalink
Fix compilation on macOS and FreeBSD with --no-default-features. (#966)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfishcode authored Dec 8, 2023
1 parent 748a828 commit 287509b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/backend/libc/fs/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::backend::conv::ret_usize;
use crate::backend::conv::{borrowed_fd, c_str, ret, ret_c_int, ret_off_t, ret_owned_fd};
use crate::fd::{BorrowedFd, OwnedFd};
use crate::ffi::CStr;
#[cfg(apple)]
#[cfg(all(apple, feature = "alloc"))]
use crate::ffi::CString;
#[cfg(not(any(target_os = "espidf", target_os = "vita")))]
use crate::fs::Access;
Expand Down Expand Up @@ -73,7 +73,7 @@ use crate::io;
use crate::timespec::LibcTimespec;
#[cfg(not(target_os = "wasi"))]
use crate::ugid::{Gid, Uid};
#[cfg(apple)]
#[cfg(all(apple, feature = "alloc"))]
use alloc::vec;
use core::mem::MaybeUninit;
#[cfg(apple)]
Expand Down Expand Up @@ -2061,7 +2061,7 @@ pub(crate) unsafe fn copyfile_state_get(
nonnegative_ret(copyfile_state_get(state, flag, dst))
}

#[cfg(apple)]
#[cfg(all(apple, feature = "alloc"))]
pub(crate) fn getpath(fd: BorrowedFd<'_>) -> io::Result<CString> {
// The use of `PATH_MAX` is generally not encouraged, but it
// is inevitable in this case because macOS defines `fcntl` with
Expand Down
4 changes: 2 additions & 2 deletions src/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ mod fcntl_apple;
#[cfg(apple)]
mod fcopyfile;
pub(crate) mod fd;
#[cfg(apple)]
#[cfg(all(apple, feature = "alloc"))]
mod getpath;
#[cfg(not(target_os = "wasi"))] // WASI doesn't have get[gpu]id.
mod id;
Expand Down Expand Up @@ -96,7 +96,7 @@ pub use fcntl_apple::*;
#[cfg(apple)]
pub use fcopyfile::*;
pub use fd::*;
#[cfg(apple)]
#[cfg(all(apple, feature = "alloc"))]
pub use getpath::getpath;
#[cfg(not(target_os = "wasi"))]
pub use id::*;
Expand Down
5 changes: 3 additions & 2 deletions src/process/procctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#![allow(unsafe_code)]

use alloc::vec;
use alloc::vec::Vec;
#[cfg(feature = "alloc")]
use alloc::{vec, vec::Vec};
use core::mem::MaybeUninit;
use core::ptr;

Expand Down Expand Up @@ -342,6 +342,7 @@ pub struct PidInfo {
/// - [FreeBSD: `procctl(PROC_REAP_GETPIDS,...)`]
///
/// [FreeBSD: `procctl(PROC_REAP_GETPIDS,...)`]: https://man.freebsd.org/cgi/man.cgi?query=procctl&sektion=2
#[cfg(feature = "alloc")]
pub fn get_reaper_pids(process: ProcSelector) -> io::Result<Vec<PidInfo>> {
// Sadly no better way to guarantee that we get all the results than to
// allocate ~8MB of memory..
Expand Down

0 comments on commit 287509b

Please sign in to comment.