Skip to content

Commit

Permalink
build on macos
Browse files Browse the repository at this point in the history
Signed-off-by: YangKeao <yangkeao@chunibyo.icu>
  • Loading branch information
YangKeao committed May 7, 2022
1 parent 6a177ec commit 96caf30
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 10 additions & 8 deletions src/addr_validate.rs
Expand Up @@ -18,19 +18,21 @@ fn create_pipe() -> nix::Result<(i32, i32)> {
pipe2(OFlag::O_CLOEXEC | OFlag::O_NONBLOCK)
}

#[inline]
#[cfg(target_os = "macos")]
unsafe fn create_pipe() -> nix::Result<(i32, i32)> {
use nix::fcntl::{fcntl, OFlag};
use nix::fcntl::{fcntl, FdFlag, FcntlArg};
use nix::unistd::pipe;

let (read_fd, write_fd) = libc::pipe(fds)?;
let (read_fd, write_fd) = pipe()?;

let mut flags = fcntl(read_fd, FcntlArg::F_GETFL)?;
flags |= libc::O_CLOEXEC;
fcntl(read_fd, libc::F_SETFD, flags)?;
let mut flags = FdFlag::from_bits(fcntl(read_fd, FcntlArg::F_GETFL)?).unwrap();
flags |= FdFlag::FD_CLOEXEC;
fcntl(read_fd, FcntlArg::F_SETFD(flags))?;

let mut flags = fcntl(write_fd, FcntlArg::F_GETFL)?;
flags |= libc::O_CLOEXEC;
fcntl(write_fd, libc::F_SETFD, flags)?;
let mut flags = FdFlag::from_bits(fcntl(write_fd, FcntlArg::F_GETFL)?).unwrap();
flags |= FdFlag::FD_CLOEXEC;
fcntl(write_fd, FcntlArg::F_SETFD(flags))?;

Ok((read_fd, write_fd))
}
Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Expand Up @@ -45,7 +45,6 @@ pub const MAX_DEPTH: usize = 32;
/// Define the MAX supported thread name length. TODO: make this variable mutable.
pub const MAX_THREAD_NAME: usize = 16;

#[cfg(target_os = "linux")]
mod addr_validate;

mod backtrace;
Expand All @@ -57,7 +56,6 @@ mod report;
mod timer;

pub use self::addr_validate::validate;

pub use self::collector::{Collector, HashCounter};
pub use self::error::{Error, Result};
pub use self::frames::{Frames, Symbol};
Expand Down

0 comments on commit 96caf30

Please sign in to comment.