Skip to content

Commit 0e964d8

Browse files
committed
NetBSD: Correct a number of symbol link names
Relevant source: * `devname`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/include/stdlib.h#L296 * `getutent`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/include/utmp.h#L70 * `ntp_gettime`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/sys/sys/timex.h#L257 * `sched_rr_get_interval`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/include/sched.h#L50-L51 * `shmctl`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/sys/sys/shm.h#L2011 * `sig{action,suspend}`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/include/signal.h#L85-L95 * `{get,set}itimer`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/sys/sys/time.h#L331-L335 * `timer_{get,set}time`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/include/time.h#L158-L160 * `utmpx` symbols: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/include/utmpx.h#L135-L150 * `wait4`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/sys/sys/wait.h#L209 Excluded are `__statvfs90`, `__fstatvfs90`, `__sigaction_siginfo`, `__getmntinfo90`, `__getvfsstat90`which are only present in 10.0+ (the symbol version seems to be N-1). Source: * https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/sys/sys/statvfs.h#L160-L168 There is also a deprecated aliases that used to be needed and is removed here. * `__getmntinfo13`: https://github.com/NetBSD/src/blob/62c785e59d064070166dab5d2a4492055effba89/lib/libc/compat/gen/compat___getmntinfo13.c#L49-L50 (backport <#4782>) (cherry picked from commit 1816f60)
1 parent 0eb105b commit 0e964d8

File tree

8 files changed

+32
-2
lines changed

8 files changed

+32
-2
lines changed

libc-test/build.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,6 +1465,15 @@ fn test_netbsd(target: &str) {
14651465
}
14661466
});
14671467

1468+
cfg.skip_fn_ptrcheck(move |func| {
1469+
match func {
1470+
// New symbol version present in NetBSD10, but we keep the old versions for NetBSD9
1471+
// compatibility.
1472+
"getmntinfo" | "statvfs" | "fstatvfs" | "getvfsstat" | "sigaction" => true,
1473+
_ => false,
1474+
}
1475+
});
1476+
14681477
cfg.skip_struct_field_type(move |struct_, field| {
14691478
// This is a weird union, don't check the type.
14701479
(struct_.ident() == "ifaddrs" && field.ident() == "ifa_ifu") ||

src/new/netbsd/sys/timex.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ s! {
8989
}
9090

9191
extern "C" {
92+
#[link_name = "__ntp_gettime50"]
9293
pub fn ntp_gettime(buf: *mut ntptimeval) -> c_int;
9394
pub fn ntp_adjtime(buf: *mut timex) -> c_int;
9495
}

src/new/netbsd/utmp_.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ s! {
2727
extern "C" {
2828
pub fn utmpname(file: *const c_char) -> c_int;
2929
pub fn setutent();
30+
#[link_name = "__getutent50"]
3031
pub fn getutent() -> *mut utmp;
3132
pub fn endutent();
3233
}

src/new/netbsd/utmpx_.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,26 @@ extern "C" {
6767
pub fn setutxent();
6868
pub fn endutxent();
6969

70+
#[link_name = "__getutxent50"]
7071
pub fn getutxent() -> *mut utmpx;
72+
#[link_name = "__getutxid50"]
7173
pub fn getutxid(ut: *const utmpx) -> *mut utmpx;
74+
#[link_name = "__getutxline50"]
7275
pub fn getutxline(ut: *const utmpx) -> *mut utmpx;
76+
#[link_name = "__pututxline50"]
7377
pub fn pututxline(ut: *const utmpx) -> *mut utmpx;
7478

79+
#[link_name = "__updwtmpx50"]
7580
pub fn updwtmpx(file: *const c_char, ut: *const utmpx) -> c_int;
81+
#[link_name = "__getlastlogx50"]
7682
pub fn getlastlogx(fname: *const c_char, uid: crate::uid_t, ll: *mut lastlogx)
7783
-> *mut lastlogx;
84+
85+
#[link_name = "__updlastlogx50"]
7886
pub fn updlastlogx(fname: *const c_char, uid: crate::uid_t, ll: *mut lastlogx) -> c_int;
87+
#[link_name = "__getutmp50"]
7988
pub fn getutmp(ux: *const utmpx, u: *mut crate::utmp);
89+
#[link_name = "__getutmpx50"]
8090
pub fn getutmpx(u: *const crate::utmp, ux: *mut utmpx);
8191
pub fn utmpxname(file: *const c_char) -> c_int;
8292
}

src/unix/bsd/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,7 @@ extern "C" {
730730
)]
731731
#[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")]
732732
pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> c_int;
733+
#[cfg_attr(target_os = "netbsd", link_name = "__sigsuspend14")]
733734
pub fn sigsuspend(mask: *const crate::sigset_t) -> c_int;
734735
pub fn sem_close(sem: *mut sem_t) -> c_int;
735736
pub fn getdtablesize() -> c_int;
@@ -804,6 +805,7 @@ extern "C" {
804805
all(target_os = "freebsd", any(freebsd12, freebsd11, freebsd10)),
805806
link_name = "wait4@FBSD_1.0"
806807
)]
808+
#[cfg_attr(target_os = "netbsd", link_name = "__wait450")]
807809
pub fn wait4(
808810
pid: crate::pid_t,
809811
status: *mut c_int,
@@ -814,11 +816,13 @@ extern "C" {
814816
all(target_os = "macos", target_arch = "x86"),
815817
link_name = "getitimer$UNIX2003"
816818
)]
819+
#[cfg_attr(target_os = "netbsd", link_name = "__getitimer50")]
817820
pub fn getitimer(which: c_int, curr_value: *mut crate::itimerval) -> c_int;
818821
#[cfg_attr(
819822
all(target_os = "macos", target_arch = "x86"),
820823
link_name = "setitimer$UNIX2003"
821824
)]
825+
#[cfg_attr(target_os = "netbsd", link_name = "__setitimer50")]
822826
pub fn setitimer(
823827
which: c_int,
824828
new_value: *const crate::itimerval,
@@ -879,6 +883,7 @@ extern "C" {
879883
locale: crate::locale_t,
880884
) -> size_t;
881885

886+
#[cfg_attr(target_os = "netbsd", link_name = "__devname50")]
882887
pub fn devname(dev: crate::dev_t, mode_t: crate::mode_t) -> *mut c_char;
883888

884889
pub fn issetugid() -> c_int;

src/unix/bsd/netbsdlike/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,7 @@ extern "C" {
749749
pub fn shmget(key: crate::key_t, size: size_t, shmflg: c_int) -> c_int;
750750
pub fn shmat(shmid: c_int, shmaddr: *const c_void, shmflg: c_int) -> *mut c_void;
751751
pub fn shmdt(shmaddr: *const c_void) -> c_int;
752+
#[cfg_attr(target_os = "netbsd", link_name = "__shmctl50")]
752753
pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int;
753754

754755
// DIFF(main): changed to `*const *mut` in e77f551de9

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2124,7 +2124,9 @@ extern "C" {
21242124
) -> c_int;
21252125
pub fn timer_delete(timerid: crate::timer_t) -> c_int;
21262126
pub fn timer_getoverrun(timerid: crate::timer_t) -> c_int;
2127+
#[link_name = "__timer_gettime50"]
21272128
pub fn timer_gettime(timerid: crate::timer_t, curr_value: *mut crate::itimerspec) -> c_int;
2129+
#[link_name = "__timer_settime50"]
21282130
pub fn timer_settime(
21292131
timerid: crate::timer_t,
21302132
flags: c_int,
@@ -2150,6 +2152,7 @@ extern "C" {
21502152
flags: c_int,
21512153
) -> *mut c_void;
21522154

2155+
#[link_name = "__sched_rr_get_interval50"]
21532156
pub fn sched_rr_get_interval(pid: crate::pid_t, t: *mut crate::timespec) -> c_int;
21542157
pub fn sched_setparam(pid: crate::pid_t, param: *const crate::sched_param) -> c_int;
21552158
pub fn sched_getparam(pid: crate::pid_t, param: *mut crate::sched_param) -> c_int;
@@ -2192,7 +2195,6 @@ extern "C" {
21922195
ntargets: size_t,
21932196
hint: *const c_void,
21942197
) -> c_int;
2195-
#[link_name = "__getmntinfo13"]
21962198
pub fn getmntinfo(mntbufp: *mut *mut crate::statvfs, flags: c_int) -> c_int;
21972199
pub fn getvfsstat(buf: *mut crate::statvfs, bufsize: size_t, flags: c_int) -> c_int;
21982200

@@ -2239,7 +2241,7 @@ extern "C" {
22392241

22402242
#[link(name = "util")]
22412243
extern "C" {
2242-
#[cfg_attr(target_os = "netbsd", link_name = "__getpwent_r50")]
2244+
#[link_name = "__getpwent_r50"]
22432245
pub fn getpwent_r(
22442246
pwd: *mut crate::passwd,
22452247
buf: *mut c_char,

src/unix/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,6 +1646,7 @@ cfg_if! {
16461646
target_os = "aix",
16471647
)))] {
16481648
extern "C" {
1649+
#[cfg_attr(target_os = "netbsd", link_name = "__adjtime50")]
16491650
#[cfg_attr(gnu_time_bits64, link_name = "__adjtime64")]
16501651
pub fn adjtime(delta: *const timeval, olddelta: *mut timeval) -> c_int;
16511652
}

0 commit comments

Comments
 (0)