Skip to content

Commit 53c2321

Browse files
committed
Add support for NetBSD/amd64
Signed-off-by: Julio Merino <[email protected]>
1 parent bc23fa1 commit 53c2321

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/addr_validate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn create_pipe() -> nix::Result<(i32, i32)> {
2828
}
2929

3030
#[inline]
31-
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
31+
#[cfg(any(target_os = "freebsd", target_os = "macos", target_os = "netbsd"))]
3232
fn create_pipe() -> nix::Result<(i32, i32)> {
3333
use nix::fcntl::{fcntl, FcntlArg, FdFlag, OFlag};
3434
use nix::unistd::pipe;

src/profiler.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ struct ErrnoProtector(libc::c_int);
233233
impl ErrnoProtector {
234234
fn new() -> Self {
235235
unsafe {
236-
#[cfg(target_os = "android")]
236+
#[cfg(any(target_os = "android", target_os = "netbsd"))]
237237
{
238238
let errno = *libc::__errno();
239239
Self(errno)
@@ -255,7 +255,7 @@ impl ErrnoProtector {
255255
impl Drop for ErrnoProtector {
256256
fn drop(&mut self) {
257257
unsafe {
258-
#[cfg(target_os = "android")]
258+
#[cfg(any(target_os = "android", target_os = "netbsd"))]
259259
{
260260
*libc::__errno() = self.0;
261261
}
@@ -304,9 +304,13 @@ extern "C" fn perf_signal_handler(
304304
let addr =
305305
unsafe { (*ucontext).uc_mcontext.gregs[libc::REG_RIP as usize] as usize };
306306

307-
#[cfg(all(target_arch = "x86_64", target_os = "freebsd"))]
307+
#[cfg(target_os = "freebsd")]
308308
let addr = unsafe { (*ucontext).uc_mcontext.mc_rip as usize };
309309

310+
#[cfg(all(target_arch = "x86_64", target_os = "netbsd"))]
311+
let addr =
312+
unsafe { (*ucontext).uc_mcontext.__gregs[libc::_REG_RIP as usize] as usize };
313+
310314
#[cfg(all(target_arch = "x86_64", target_os = "macos"))]
311315
let addr = unsafe {
312316
let mcontext = (*ucontext).uc_mcontext;
@@ -323,7 +327,7 @@ extern "C" fn perf_signal_handler(
323327
))]
324328
let addr = unsafe { (*ucontext).uc_mcontext.pc as usize };
325329

326-
#[cfg(all(target_arch = "aarch64", target_os = "freebsd"))]
330+
#[cfg(all(target_arch = "aarch64", any(target_os = "freebsd", target_os = "netbsd")))]
327331
let addr = unsafe { (*ucontext).mc_gpregs.gp_elr as usize };
328332

329333
#[cfg(all(target_arch = "aarch64", target_os = "macos"))]

0 commit comments

Comments
 (0)