From bd3b68dadaa493bb98bfd5e76a0e83913366e717 Mon Sep 17 00:00:00 2001 From: pin Date: Wed, 27 Sep 2023 20:07:52 +0200 Subject: [PATCH] backtrace definitions and support for getmntinfo and getvfsstat --- libc-test/semver/netbsd.txt | 10 ++++++++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 35 +++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 21a4cb7adcbb1..5fa24d0e8cf4f 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -671,6 +671,9 @@ MNT_RELATIME MNT_SOFTDEP MNT_SYMPERM MNT_UNION +MNT_WAIT +MNT_NOWAIT +MNT_LAZY MOD_CLKA MOD_CLKB MOD_ESTERROR @@ -1188,6 +1191,11 @@ arc4random arc4random_buf arc4random_uniform arphdr +backtrace +backtrace_symbols +backtrace_symbols_fd +backtrace_symbols_fmt +backtrace_symbols_fd_fmt bsearch chflags chroot @@ -1275,6 +1283,7 @@ getitimer getlastlogx getline getloadavg +getmntinfo getnameinfo getopt_long getpeereid @@ -1295,6 +1304,7 @@ getutmpx getutxent getutxid getutxline +getvfsstat getxattr glob glob_t diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 3beb8c68dea7a..bd5161893a864 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1852,6 +1852,9 @@ pub const MNT_NODEVMTIME: ::c_int = 0x40000000; pub const MNT_SOFTDEP: ::c_int = 0x80000000; pub const MNT_POSIX1EACLS: ::c_int = 0x00000800; pub const MNT_ACLS: ::c_int = MNT_POSIX1EACLS; +pub const MNT_WAIT: ::c_int = 1; +pub const MNT_NOWAIT: ::c_int = 2; +pub const MNT_LAZY: ::c_int = 3; // pub const NTP_API: ::c_int = 4; @@ -3154,6 +3157,38 @@ extern "C" { pub fn kinfo_getvmmap(pid: ::pid_t, cntp: *mut ::size_t) -> *mut kinfo_vmentry; } +#[link(name = "execinfo")] +extern "C" { + pub fn backtrace(addrlist: *mut *mut ::c_void, len: ::size_t) -> ::size_t; + pub fn backtrace_symbols(addrlist: *const *mut ::c_void, len: ::size_t) -> *mut *mut ::c_char; + pub fn backtrace_symbols_fd( + addrlist: *const *mut ::c_void, + len: ::size_t, + fd: ::c_int, + ) -> ::c_int; + pub fn backtrace_symbols_fmt( + addrlist: *const *mut ::c_void, + len: ::size_t, + fmt: *const ::c_char, + ) -> *mut *mut ::c_char; + pub fn backtrace_symbols_fd_fmt( + addrlist: *const *mut ::c_void, + len: ::size_t, + fd: ::c_int, + fmt: *const ::c_char, + ) -> ::c_int; +} + +cfg_if! { + if #[cfg(libc_union)] { + extern { + // these functions use statvfs: + pub fn getmntinfo(mntbufp: *mut *mut ::statvfs, flags: ::c_int) -> ::c_int; + pub fn getvfsstat(buf: *mut statvfs, bufsize: ::size_t, flags: ::c_int) -> ::c_int; + } + } +} + cfg_if! { if #[cfg(target_arch = "aarch64")] { mod aarch64;