Skip to content

Commit

Permalink
Auto merge of #3361 - 0323pin:main, r=JohnTitor
Browse files Browse the repository at this point in the history
Add backtrace definitions and support for statvfs

Replaces #3359

This allows successful build and use of file deletion, a.k.a. _move to trash_

Tested with a source build of `simp` with the **trash** feature enabled.
Without this commit, `simp` fails to build on NetBSD when the **trash** feature is enabled.

Also, I've added the new symbols to semver and made sure these functions are available on a minimal NetBSD environment.
  • Loading branch information
bors committed Sep 25, 2023
2 parents 9593176 + db2eabd commit 087aa3b
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
12 changes: 12 additions & 0 deletions libc-test/semver/netbsd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,9 @@ MNT_RELATIME
MNT_SOFTDEP
MNT_SYMPERM
MNT_UNION
MNT_WAIT
MNT_NOWAIT
MNT_LAZY
MOD_CLKA
MOD_CLKB
MOD_ESTERROR
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1246,6 +1254,7 @@ fgetxattr
flistxattr
fremovexattr
fsetxattr
fstatvfs
flags_to_string
fmemopen
forkpty
Expand Down Expand Up @@ -1275,6 +1284,7 @@ getitimer
getlastlogx
getline
getloadavg
getmntinfo
getnameinfo
getopt_long
getpeereid
Expand All @@ -1295,6 +1305,7 @@ getutmpx
getutxent
getutxid
getutxline
getvfsstat
getxattr
glob
glob_t
Expand Down Expand Up @@ -1522,6 +1533,7 @@ sockcred
srand
srand48
stack_t
statvfs
strcasecmp
strcasestr
string_to_flags
Expand Down
39 changes: 39 additions & 0 deletions src/unix/bsd/netbsdlike/netbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1853,6 +1853,11 @@ pub const MNT_SOFTDEP: ::c_int = 0x80000000;
pub const MNT_POSIX1EACLS: ::c_int = 0x00000800;
pub const MNT_ACLS: ::c_int = MNT_POSIX1EACLS;

// For use with vfs_sync and getvfsstat
pub const MNT_WAIT: ::c_int = 1;
pub const MNT_NOWAIT: ::c_int = 2;
pub const MNT_LAZY: ::c_int = 3;

//<sys/timex.h>
pub const NTP_API: ::c_int = 4;
pub const MAXPHASE: ::c_long = 500000000;
Expand Down Expand Up @@ -3154,6 +3159,40 @@ 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 statvfs(path: *const ::c_char, buf: *mut statvfs) -> ::c_int;
pub fn fstatvfs(fd: ::c_int, buf: *mut statvfs) -> ::c_int;
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;
Expand Down

0 comments on commit 087aa3b

Please sign in to comment.