diff --git a/.github/.cspell/project-dictionary.txt b/.github/.cspell/project-dictionary.txt index b2e26093..36bf62c3 100644 --- a/.github/.cspell/project-dictionary.txt +++ b/.github/.cspell/project-dictionary.txt @@ -144,6 +144,7 @@ subfze swpp syscall sysctlbyname +sysctlnode sysdeps systemsim tagme diff --git a/src/imp/atomic128/detect/aarch64_aa64reg.rs b/src/imp/atomic128/detect/aarch64_aa64reg.rs index 8d7393f3..852089ee 100644 --- a/src/imp/atomic128/detect/aarch64_aa64reg.rs +++ b/src/imp/atomic128/detect/aarch64_aa64reg.rs @@ -30,6 +30,7 @@ include!("common.rs"); +#[cfg_attr(test, derive(Debug, PartialEq))] struct AA64Reg { aa64isar0: u64, #[cfg(test)] @@ -191,7 +192,7 @@ mod imp { } } - unsafe fn sysctl_cpu_id(name: &[u8]) -> Option { + pub(super) unsafe fn sysctl_cpu_id(name: &[u8]) -> Option { const OUT_LEN: ffi::c_size_t = core::mem::size_of::() as ffi::c_size_t; @@ -394,6 +395,145 @@ mod tests { } } + #[allow(clippy::cast_possible_wrap)] + #[cfg(target_os = "netbsd")] + #[test] + fn test_netbsd() { + use c_types::*; + use core::{arch::asm, mem, ptr}; + use imp::ffi; + use test_helper::sys; + + // Call syscall using asm instead of libc. + // Note that NetBSD does not guarantee the stability of raw syscall as + // much as Linux does (It may actually be stable enough, though: https://lists.llvm.org/pipermail/llvm-dev/2019-June/133393.html). + // + // This is currently used only for testing. + unsafe fn sysctl_cpu_id_asm_syscall(name: &[&[u8]]) -> Result { + // https://github.com/golang/go/blob/4badad8d477ffd7a6b762c35bc69aed82faface7/src/syscall/asm_netbsd_arm64.s + #[inline] + unsafe fn sysctl( + name: *const c_int, + name_len: c_uint, + old_p: *mut c_void, + old_len_p: *mut c_size_t, + new_p: *const c_void, + new_len: c_size_t, + ) -> Result { + #[allow(clippy::cast_possible_truncation)] + // SAFETY: the caller must uphold the safety contract. + unsafe { + let mut n = sys::SYS___sysctl as u64; + let r: i64; + asm!( + "svc 0", + "b.cc 2f", + "mov x17, x0", + "mov x0, #-1", + "2:", + inout("x17") n, + inout("x0") ptr_reg!(name) => r, + inout("x1") name_len as u64 => _, + in("x2") ptr_reg!(old_p), + in("x3") ptr_reg!(old_len_p), + in("x4") ptr_reg!(new_p), + in("x5") new_len as u64, + options(nostack), + ); + if r as c_int == -1 { + Err(n as c_int) + } else { + Ok(r as c_int) + } + } + } + + // https://github.com/golang/sys/blob/4badad8d477ffd7a6b762c35bc69aed82faface7/cpu/cpu_netbsd_arm64.go. + use std::{vec, vec::Vec}; + fn sysctl_nodes(mib: &mut Vec) -> Result, i32> { + mib.push(sys::CTL_QUERY); + let mut q_node = sys::sysctlnode { + sysctl_flags: sys::SYSCTL_VERS_1, + ..unsafe { mem::zeroed() } + }; + let qp = (&mut q_node as *mut sys::sysctlnode).cast::(); + let sz = mem::size_of::(); + let mut olen = 0; + #[allow(clippy::cast_possible_truncation)] + unsafe { + sysctl(mib.as_ptr(), mib.len() as c_uint, ptr::null_mut(), &mut olen, qp, sz)?; + } + + let mut nodes = Vec::::with_capacity(olen / sz); + let np = nodes.as_mut_ptr().cast::(); + #[allow(clippy::cast_possible_truncation)] + unsafe { + sysctl(mib.as_ptr(), mib.len() as c_uint, np, &mut olen, qp, sz)?; + nodes.set_len(olen / sz); + } + + mib.pop(); // pop CTL_QUERY + Ok(nodes) + } + fn name_to_mib(parts: &[&[u8]]) -> Result, i32> { + let mut mib = vec![]; + for (part_no, &part) in parts.iter().enumerate() { + let nodes = sysctl_nodes(&mut mib)?; + for node in nodes { + let mut n = vec![]; + for b in node.sysctl_name { + if b != 0 { + n.push(b); + } + } + if n == part { + mib.push(node.sysctl_num); + break; + } + } + if mib.len() != part_no + 1 { + return Err(0); + } + } + + Ok(mib) + } + + const OUT_LEN: ffi::c_size_t = + core::mem::size_of::() as ffi::c_size_t; + + let mib = name_to_mib(name)?; + + let mut buf: ffi::aarch64_sysctl_cpu_id = unsafe { core::mem::zeroed() }; + let mut out_len = OUT_LEN; + #[allow(clippy::cast_possible_truncation)] + unsafe { + sysctl( + mib.as_ptr(), + mib.len() as c_uint, + (&mut buf as *mut ffi::aarch64_sysctl_cpu_id).cast::(), + &mut out_len, + ptr::null_mut(), + 0, + )?; + } + Ok(AA64Reg { + aa64isar0: buf.aa64isar0, + #[cfg(test)] + aa64isar1: buf.aa64isar1, + #[cfg(test)] + aa64mmfr2: buf.aa64mmfr2, + }) + } + + unsafe { + assert_eq!( + imp::sysctl_cpu_id(b"machdep.cpu0.cpu_id\0").unwrap(), + sysctl_cpu_id_asm_syscall(&[b"machdep", b"cpu0", b"cpu_id"]).unwrap() + ); + } + } + // Static assertions for FFI bindings. // This checks that FFI bindings defined in this crate, FFI bindings defined // in libc, and FFI bindings generated for the platform's latest header file diff --git a/tests/helper/src/gen/sys/aarch64_be_netbsd/aarch64_armreg.rs b/tests/helper/src/gen/sys/aarch64_be_netbsd/aarch64_armreg.rs new file mode 100644 index 00000000..70c8a0be --- /dev/null +++ b/tests/helper/src/gen/sys/aarch64_be_netbsd/aarch64_armreg.rs @@ -0,0 +1,27 @@ +// This file is @generated by portable-atomic-internal-codegen +// (gen function at tools/codegen/src/ffi.rs). +// It is not intended for manual editing. + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct aarch64_sysctl_cpu_id { + pub ac_midr: u64, + pub ac_revidr: u64, + pub ac_mpidr: u64, + pub ac_aa64dfr0: u64, + pub ac_aa64dfr1: u64, + pub ac_aa64isar0: u64, + pub ac_aa64isar1: u64, + pub ac_aa64mmfr0: u64, + pub ac_aa64mmfr1: u64, + pub ac_aa64mmfr2: u64, + pub ac_aa64pfr0: u64, + pub ac_aa64pfr1: u64, + pub ac_aa64zfr0: u64, + pub ac_mvfr0: u32, + pub ac_mvfr1: u32, + pub ac_mvfr2: u32, + pub ac_pad: u32, + pub ac_clidr: u64, + pub ac_ctr: u64, +} diff --git a/tests/helper/src/gen/sys/aarch64_be_netbsd/mod.rs b/tests/helper/src/gen/sys/aarch64_be_netbsd/mod.rs new file mode 100644 index 00000000..33f7b3ac --- /dev/null +++ b/tests/helper/src/gen/sys/aarch64_be_netbsd/mod.rs @@ -0,0 +1,16 @@ +// This file is @generated by portable-atomic-internal-codegen +// (gen function at tools/codegen/src/ffi.rs). +// It is not intended for manual editing. + +#![cfg_attr(rustfmt, rustfmt::skip)] +mod sys_sysctl; +pub use sys_sysctl::SYSCTL_VERS_1; +pub use sys_sysctl::CTL_QUERY; +pub use sys_sysctl::sysctl; +pub use sys_sysctl::sysctlbyname; +pub use sys_sysctl::sysctlnode; +mod sys_syscall; +pub use sys_syscall::SYS___sysctl; +mod aarch64_armreg; +pub use aarch64_armreg::aarch64_sysctl_cpu_id; +pub type c_char = u8; diff --git a/tests/helper/src/gen/sys/aarch64_be_netbsd/sys_syscall.rs b/tests/helper/src/gen/sys/aarch64_be_netbsd/sys_syscall.rs new file mode 100644 index 00000000..e3887873 --- /dev/null +++ b/tests/helper/src/gen/sys/aarch64_be_netbsd/sys_syscall.rs @@ -0,0 +1,5 @@ +// This file is @generated by portable-atomic-internal-codegen +// (gen function at tools/codegen/src/ffi.rs). +// It is not intended for manual editing. + +pub const SYS___sysctl: u32 = 202; diff --git a/tests/helper/src/gen/sys/aarch64_be_netbsd/sys_sysctl.rs b/tests/helper/src/gen/sys/aarch64_be_netbsd/sys_sysctl.rs new file mode 100644 index 00000000..c4ffc38c --- /dev/null +++ b/tests/helper/src/gen/sys/aarch64_be_netbsd/sys_sysctl.rs @@ -0,0 +1,142 @@ +// This file is @generated by portable-atomic-internal-codegen +// (gen function at tools/codegen/src/ffi.rs). +// It is not intended for manual editing. + +pub type u_int = ::std::os::raw::c_uint; +pub type u_quad_t = u64; +pub const SYSCTL_VERS_1: u32 = 16777216; +pub const CTL_QUERY: i32 = -2; +pub type sysctlfn = *mut ::core::ffi::c_void; +extern "C" { + pub fn sysctl( + arg1: *const ::std::os::raw::c_int, + arg2: u_int, + arg3: *mut ::core::ffi::c_void, + arg4: *mut usize, + arg5: *const ::core::ffi::c_void, + arg6: usize, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn sysctlbyname( + arg1: *const ::std::os::raw::c_char, + arg2: *mut ::core::ffi::c_void, + arg3: *mut usize, + arg4: *const ::core::ffi::c_void, + arg5: usize, + ) -> ::std::os::raw::c_int; +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct sysctlnode { + pub sysctl_flags: u32, + pub sysctl_num: i32, + pub sysctl_name: [::std::os::raw::c_char; 32usize], + pub sysctl_ver: u32, + pub __rsvd: u32, + pub sysctl_un: sysctlnode__bindgen_ty_1, + pub _sysctl_size: sysctlnode__bindgen_ty_2, + pub _sysctl_func: sysctlnode__bindgen_ty_3, + pub _sysctl_parent: sysctlnode__bindgen_ty_4, + pub _sysctl_desc: sysctlnode__bindgen_ty_5, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union sysctlnode__bindgen_ty_1 { + pub scu_child: sysctlnode__bindgen_ty_1__bindgen_ty_1, + pub scu_data: sysctlnode__bindgen_ty_1__bindgen_ty_2, + pub scu_alias: i32, + pub scu_idata: i32, + pub scu_qdata: u_quad_t, + pub scu_bdata: bool, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct sysctlnode__bindgen_ty_1__bindgen_ty_1 { + pub suc_csize: u32, + pub suc_clen: u32, + pub _suc_child: sysctlnode__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union sysctlnode__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 { + pub __sysc_upad: u64, + pub __sysc_ustr: sysctlnode__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct sysctlnode__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 { + pub __sysc_sdatum: *mut sysctlnode, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct sysctlnode__bindgen_ty_1__bindgen_ty_2 { + pub _sud_data: sysctlnode__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1, + pub _sud_offset: sysctlnode__bindgen_ty_1__bindgen_ty_2__bindgen_ty_2, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union sysctlnode__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1 { + pub __sysc_upad: u64, + pub __sysc_ustr: sysctlnode__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct sysctlnode__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1__bindgen_ty_1 { + pub __sysc_sdatum: *mut ::core::ffi::c_void, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union sysctlnode__bindgen_ty_1__bindgen_ty_2__bindgen_ty_2 { + pub __sysc_upad: u64, + pub __sysc_ustr: sysctlnode__bindgen_ty_1__bindgen_ty_2__bindgen_ty_2__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct sysctlnode__bindgen_ty_1__bindgen_ty_2__bindgen_ty_2__bindgen_ty_1 { + pub __sysc_sdatum: usize, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union sysctlnode__bindgen_ty_2 { + pub __sysc_upad: u64, + pub __sysc_ustr: sysctlnode__bindgen_ty_2__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct sysctlnode__bindgen_ty_2__bindgen_ty_1 { + pub __sysc_sdatum: usize, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union sysctlnode__bindgen_ty_3 { + pub __sysc_upad: u64, + pub __sysc_ustr: sysctlnode__bindgen_ty_3__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct sysctlnode__bindgen_ty_3__bindgen_ty_1 { + pub __sysc_sdatum: sysctlfn, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union sysctlnode__bindgen_ty_4 { + pub __sysc_upad: u64, + pub __sysc_ustr: sysctlnode__bindgen_ty_4__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct sysctlnode__bindgen_ty_4__bindgen_ty_1 { + pub __sysc_sdatum: *mut sysctlnode, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union sysctlnode__bindgen_ty_5 { + pub __sysc_upad: u64, + pub __sysc_ustr: sysctlnode__bindgen_ty_5__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct sysctlnode__bindgen_ty_5__bindgen_ty_1 { + pub __sysc_sdatum: *const ::std::os::raw::c_char, +} diff --git a/tests/helper/src/gen/sys/aarch64_netbsd/mod.rs b/tests/helper/src/gen/sys/aarch64_netbsd/mod.rs index e6dd2d35..33f7b3ac 100644 --- a/tests/helper/src/gen/sys/aarch64_netbsd/mod.rs +++ b/tests/helper/src/gen/sys/aarch64_netbsd/mod.rs @@ -4,7 +4,13 @@ #![cfg_attr(rustfmt, rustfmt::skip)] mod sys_sysctl; +pub use sys_sysctl::SYSCTL_VERS_1; +pub use sys_sysctl::CTL_QUERY; +pub use sys_sysctl::sysctl; pub use sys_sysctl::sysctlbyname; +pub use sys_sysctl::sysctlnode; +mod sys_syscall; +pub use sys_syscall::SYS___sysctl; mod aarch64_armreg; pub use aarch64_armreg::aarch64_sysctl_cpu_id; pub type c_char = u8; diff --git a/tests/helper/src/gen/sys/aarch64_netbsd/sys_syscall.rs b/tests/helper/src/gen/sys/aarch64_netbsd/sys_syscall.rs new file mode 100644 index 00000000..e3887873 --- /dev/null +++ b/tests/helper/src/gen/sys/aarch64_netbsd/sys_syscall.rs @@ -0,0 +1,5 @@ +// This file is @generated by portable-atomic-internal-codegen +// (gen function at tools/codegen/src/ffi.rs). +// It is not intended for manual editing. + +pub const SYS___sysctl: u32 = 202; diff --git a/tests/helper/src/gen/sys/aarch64_netbsd/sys_sysctl.rs b/tests/helper/src/gen/sys/aarch64_netbsd/sys_sysctl.rs index 5f891625..c4ffc38c 100644 --- a/tests/helper/src/gen/sys/aarch64_netbsd/sys_sysctl.rs +++ b/tests/helper/src/gen/sys/aarch64_netbsd/sys_sysctl.rs @@ -2,6 +2,21 @@ // (gen function at tools/codegen/src/ffi.rs). // It is not intended for manual editing. +pub type u_int = ::std::os::raw::c_uint; +pub type u_quad_t = u64; +pub const SYSCTL_VERS_1: u32 = 16777216; +pub const CTL_QUERY: i32 = -2; +pub type sysctlfn = *mut ::core::ffi::c_void; +extern "C" { + pub fn sysctl( + arg1: *const ::std::os::raw::c_int, + arg2: u_int, + arg3: *mut ::core::ffi::c_void, + arg4: *mut usize, + arg5: *const ::core::ffi::c_void, + arg6: usize, + ) -> ::std::os::raw::c_int; +} extern "C" { pub fn sysctlbyname( arg1: *const ::std::os::raw::c_char, @@ -11,3 +26,117 @@ extern "C" { arg5: usize, ) -> ::std::os::raw::c_int; } +#[repr(C)] +#[derive(Copy, Clone)] +pub struct sysctlnode { + pub sysctl_flags: u32, + pub sysctl_num: i32, + pub sysctl_name: [::std::os::raw::c_char; 32usize], + pub sysctl_ver: u32, + pub __rsvd: u32, + pub sysctl_un: sysctlnode__bindgen_ty_1, + pub _sysctl_size: sysctlnode__bindgen_ty_2, + pub _sysctl_func: sysctlnode__bindgen_ty_3, + pub _sysctl_parent: sysctlnode__bindgen_ty_4, + pub _sysctl_desc: sysctlnode__bindgen_ty_5, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union sysctlnode__bindgen_ty_1 { + pub scu_child: sysctlnode__bindgen_ty_1__bindgen_ty_1, + pub scu_data: sysctlnode__bindgen_ty_1__bindgen_ty_2, + pub scu_alias: i32, + pub scu_idata: i32, + pub scu_qdata: u_quad_t, + pub scu_bdata: bool, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct sysctlnode__bindgen_ty_1__bindgen_ty_1 { + pub suc_csize: u32, + pub suc_clen: u32, + pub _suc_child: sysctlnode__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union sysctlnode__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 { + pub __sysc_upad: u64, + pub __sysc_ustr: sysctlnode__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct sysctlnode__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 { + pub __sysc_sdatum: *mut sysctlnode, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct sysctlnode__bindgen_ty_1__bindgen_ty_2 { + pub _sud_data: sysctlnode__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1, + pub _sud_offset: sysctlnode__bindgen_ty_1__bindgen_ty_2__bindgen_ty_2, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union sysctlnode__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1 { + pub __sysc_upad: u64, + pub __sysc_ustr: sysctlnode__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct sysctlnode__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1__bindgen_ty_1 { + pub __sysc_sdatum: *mut ::core::ffi::c_void, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union sysctlnode__bindgen_ty_1__bindgen_ty_2__bindgen_ty_2 { + pub __sysc_upad: u64, + pub __sysc_ustr: sysctlnode__bindgen_ty_1__bindgen_ty_2__bindgen_ty_2__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct sysctlnode__bindgen_ty_1__bindgen_ty_2__bindgen_ty_2__bindgen_ty_1 { + pub __sysc_sdatum: usize, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union sysctlnode__bindgen_ty_2 { + pub __sysc_upad: u64, + pub __sysc_ustr: sysctlnode__bindgen_ty_2__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct sysctlnode__bindgen_ty_2__bindgen_ty_1 { + pub __sysc_sdatum: usize, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union sysctlnode__bindgen_ty_3 { + pub __sysc_upad: u64, + pub __sysc_ustr: sysctlnode__bindgen_ty_3__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct sysctlnode__bindgen_ty_3__bindgen_ty_1 { + pub __sysc_sdatum: sysctlfn, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union sysctlnode__bindgen_ty_4 { + pub __sysc_upad: u64, + pub __sysc_ustr: sysctlnode__bindgen_ty_4__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct sysctlnode__bindgen_ty_4__bindgen_ty_1 { + pub __sysc_sdatum: *mut sysctlnode, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union sysctlnode__bindgen_ty_5 { + pub __sysc_upad: u64, + pub __sysc_ustr: sysctlnode__bindgen_ty_5__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct sysctlnode__bindgen_ty_5__bindgen_ty_1 { + pub __sysc_sdatum: *const ::std::os::raw::c_char, +} diff --git a/tests/helper/src/gen/sys/mod.rs b/tests/helper/src/gen/sys/mod.rs index 8e7c13e5..f4fdeb64 100644 --- a/tests/helper/src/gen/sys/mod.rs +++ b/tests/helper/src/gen/sys/mod.rs @@ -318,6 +318,24 @@ mod aarch64_netbsd; ) )] pub use aarch64_netbsd::*; +#[cfg( + all( + target_arch = "aarch64", + target_os = "netbsd", + target_endian = "big", + target_pointer_width = "64" + ) +)] +mod aarch64_be_netbsd; +#[cfg( + all( + target_arch = "aarch64", + target_os = "netbsd", + target_endian = "big", + target_pointer_width = "64" + ) +)] +pub use aarch64_be_netbsd::*; #[cfg( all( target_arch = "aarch64", diff --git a/tools/build.sh b/tools/build.sh index d57ee7ce..47d54f29 100755 --- a/tools/build.sh +++ b/tools/build.sh @@ -76,6 +76,7 @@ default_targets=( aarch64-apple-darwin # aarch64 big endian aarch64_be-unknown-linux-gnu + aarch64_be-unknown-netbsd # aarch64 ILP32 ABI aarch64-unknown-linux-gnu_ilp32 # aarch64 ILP32 ABI big endian diff --git a/tools/codegen/src/ffi.rs b/tools/codegen/src/ffi.rs index 1b5d37cd..4858c848 100644 --- a/tools/codegen/src/ffi.rs +++ b/tools/codegen/src/ffi.rs @@ -235,14 +235,27 @@ static TARGETS: &[Target] = &[ ], }, Target { - triples: &["aarch64-unknown-netbsd"], + triples: &[ + "aarch64-unknown-netbsd", + "aarch64_be-unknown-netbsd", + ], headers: &[ Header { // https://github.com/NetBSD/src/blob/HEAD/sys/sys/sysctl.h path: "sys/sysctl.h", + types: &["sysctlnode"], + vars: &["CTL_QUERY", "SYSCTL_VERS_1"], + functions: &["sysctl", "sysctlbyname"], + arch: &[], + os: &[], + env: &[], + }, + Header { + // https://github.com/NetBSD/src/blob/HEAD/sys/sys/syscall.h + path: "sys/syscall.h", types: &[], - vars: &[], - functions: &["sysctlbyname"], + vars: &["SYS___sysctl"], + functions: &[], arch: &[], os: &[], env: &[],