Skip to content

Commit 1816f60

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
1 parent 8cb1db9 commit 1816f60

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
@@ -1375,6 +1375,15 @@ fn test_netbsd(target: &str) {
13751375
}
13761376
});
13771377

1378+
cfg.skip_fn_ptrcheck(move |func| {
1379+
match func {
1380+
// New symbol version present in NetBSD10, but we keep the old versions for NetBSD9
1381+
// compatibility.
1382+
"getmntinfo" | "statvfs" | "fstatvfs" | "getvfsstat" | "sigaction" => true,
1383+
_ => false,
1384+
}
1385+
});
1386+
13781387
cfg.skip_struct_field_type(move |struct_, field| {
13791388
// This is a weird union, don't check the type.
13801389
(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
@@ -729,6 +729,7 @@ extern "C" {
729729
)]
730730
#[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")]
731731
pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> c_int;
732+
#[cfg_attr(target_os = "netbsd", link_name = "__sigsuspend14")]
732733
pub fn sigsuspend(mask: *const crate::sigset_t) -> c_int;
733734
pub fn sem_close(sem: *mut sem_t) -> c_int;
734735
pub fn getdtablesize() -> c_int;
@@ -803,6 +804,7 @@ extern "C" {
803804
all(target_os = "freebsd", any(freebsd12, freebsd11, freebsd10)),
804805
link_name = "wait4@FBSD_1.0"
805806
)]
807+
#[cfg_attr(target_os = "netbsd", link_name = "__wait450")]
806808
pub fn wait4(
807809
pid: crate::pid_t,
808810
status: *mut c_int,
@@ -813,11 +815,13 @@ extern "C" {
813815
all(target_os = "macos", target_arch = "x86"),
814816
link_name = "getitimer$UNIX2003"
815817
)]
818+
#[cfg_attr(target_os = "netbsd", link_name = "__getitimer50")]
816819
pub fn getitimer(which: c_int, curr_value: *mut crate::itimerval) -> c_int;
817820
#[cfg_attr(
818821
all(target_os = "macos", target_arch = "x86"),
819822
link_name = "setitimer$UNIX2003"
820823
)]
824+
#[cfg_attr(target_os = "netbsd", link_name = "__setitimer50")]
821825
pub fn setitimer(
822826
which: c_int,
823827
new_value: *const crate::itimerval,
@@ -878,6 +882,7 @@ extern "C" {
878882
locale: crate::locale_t,
879883
) -> size_t;
880884

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

883888
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
@@ -747,6 +747,7 @@ extern "C" {
747747
pub fn shmget(key: crate::key_t, size: size_t, shmflg: c_int) -> c_int;
748748
pub fn shmat(shmid: c_int, shmaddr: *const c_void, shmflg: c_int) -> *mut c_void;
749749
pub fn shmdt(shmaddr: *const c_void) -> c_int;
750+
#[cfg_attr(target_os = "netbsd", link_name = "__shmctl50")]
750751
pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int;
751752
pub fn execvpe(
752753
file: *const c_char,

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,7 +2123,9 @@ extern "C" {
21232123
) -> c_int;
21242124
pub fn timer_delete(timerid: crate::timer_t) -> c_int;
21252125
pub fn timer_getoverrun(timerid: crate::timer_t) -> c_int;
2126+
#[link_name = "__timer_gettime50"]
21262127
pub fn timer_gettime(timerid: crate::timer_t, curr_value: *mut crate::itimerspec) -> c_int;
2128+
#[link_name = "__timer_settime50"]
21272129
pub fn timer_settime(
21282130
timerid: crate::timer_t,
21292131
flags: c_int,
@@ -2149,6 +2151,7 @@ extern "C" {
21492151
flags: c_int,
21502152
) -> *mut c_void;
21512153

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

@@ -2238,7 +2240,7 @@ extern "C" {
22382240

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

src/unix/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,6 +1659,7 @@ cfg_if! {
16591659
target_os = "aix",
16601660
)))] {
16611661
extern "C" {
1662+
#[cfg_attr(target_os = "netbsd", link_name = "__adjtime50")]
16621663
#[cfg_attr(gnu_time_bits64, link_name = "__adjtime64")]
16631664
pub fn adjtime(delta: *const timeval, olddelta: *mut timeval) -> c_int;
16641665
}

0 commit comments

Comments
 (0)