Skip to content

Commit 01323b2

Browse files
committed
Use _TIME_BITS and _FILE_OFFSET_BITS=64 versions of glibc symbols
Set the link names of relevant symbols to use be the same as when a C program is built against GNU libc with -D_TIME_BITS=64 and -D_FILE_OFFSET_BITS=64.
1 parent 2dcef63 commit 01323b2

File tree

7 files changed

+681
-2
lines changed

7 files changed

+681
-2
lines changed

libc-test/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3376,6 +3376,8 @@ fn test_linux(target: &str) {
33763376

33773377
// LFS64 types have been removed in musl 1.2.4+
33783378
"off64_t" if musl => "off_t".to_string(),
3379+
// In some gnu targets `stat64` is a typedef to `stat`
3380+
"statfs64" if gnu => format!("struct {}", ty),
33793381

33803382
// typedefs don't need any keywords
33813383
t if t.ends_with("_t") => t.to_string(),

src/unix/linux_like/linux/gnu/b32/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,8 @@ extern "C" {
328328
newp: *mut ::c_void,
329329
newlen: ::size_t,
330330
) -> ::c_int;
331+
#[link_name = "__ntp_gettime64"]
332+
pub fn ntp_gettime(buf: *mut ntptimeval) -> ::c_int;
331333
}
332334

333335
cfg_if! {

src/unix/linux_like/linux/gnu/b64/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
9797

9898
pub const O_LARGEFILE: ::c_int = 0;
9999

100+
extern "C" {
101+
#[link_name = "ntp_gettimex"]
102+
pub fn ntp_gettime(buf: *mut ntptimeval) -> ::c_int;
103+
}
104+
100105
cfg_if! {
101106
if #[cfg(target_arch = "aarch64")] {
102107
mod aarch64;

src/unix/linux_like/linux/gnu/mod.rs

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,12 +1150,20 @@ extern "C" {
11501150
>,
11511151
arg: *mut ::c_void,
11521152
);
1153+
#[cfg_attr(
1154+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1155+
link_name = "__sendmmsg64"
1156+
)]
11531157
pub fn sendmmsg(
11541158
sockfd: ::c_int,
11551159
msgvec: *mut ::mmsghdr,
11561160
vlen: ::c_uint,
11571161
flags: ::c_int,
11581162
) -> ::c_int;
1163+
#[cfg_attr(
1164+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1165+
link_name = "__recvmmsg64"
1166+
)]
11591167
pub fn recvmmsg(
11601168
sockfd: ::c_int,
11611169
msgvec: *mut ::mmsghdr,
@@ -1166,8 +1174,20 @@ extern "C" {
11661174

11671175
pub fn getrlimit64(resource: ::__rlimit_resource_t, rlim: *mut ::rlimit64) -> ::c_int;
11681176
pub fn setrlimit64(resource: ::__rlimit_resource_t, rlim: *const ::rlimit64) -> ::c_int;
1177+
#[cfg_attr(
1178+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1179+
link_name = "getrlimit64"
1180+
)]
11691181
pub fn getrlimit(resource: ::__rlimit_resource_t, rlim: *mut ::rlimit) -> ::c_int;
1182+
#[cfg_attr(
1183+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1184+
link_name = "setrlimit64"
1185+
)]
11701186
pub fn setrlimit(resource: ::__rlimit_resource_t, rlim: *const ::rlimit) -> ::c_int;
1187+
#[cfg_attr(
1188+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1189+
link_name = "prlimit64"
1190+
)]
11711191
pub fn prlimit(
11721192
pid: ::pid_t,
11731193
resource: ::__rlimit_resource_t,
@@ -1190,6 +1210,10 @@ extern "C" {
11901210
pub fn endutxent();
11911211
pub fn getpt() -> ::c_int;
11921212
pub fn mallopt(param: ::c_int, value: ::c_int) -> ::c_int;
1213+
#[cfg_attr(
1214+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1215+
link_name = "__gettimeofday64"
1216+
)]
11931217
pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int;
11941218
pub fn statx(
11951219
dirfd: ::c_int,
@@ -1202,10 +1226,20 @@ extern "C" {
12021226
pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
12031227
pub fn getauxval(type_: ::c_ulong) -> ::c_ulong;
12041228

1229+
#[cfg_attr(
1230+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1231+
link_name = "___adjtimex64"
1232+
)]
12051233
pub fn adjtimex(buf: *mut timex) -> ::c_int;
1234+
#[cfg_attr(
1235+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1236+
link_name = "___adjtimex64"
1237+
)]
12061238
pub fn ntp_adjtime(buf: *mut timex) -> ::c_int;
1207-
#[link_name = "ntp_gettimex"]
1208-
pub fn ntp_gettime(buf: *mut ntptimeval) -> ::c_int;
1239+
#[cfg_attr(
1240+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1241+
link_name = "__clock_adjtime64"
1242+
)]
12091243
pub fn clock_adjtime(clk_id: ::clockid_t, buf: *mut ::timex) -> ::c_int;
12101244

12111245
pub fn fanotify_mark(
@@ -1215,13 +1249,21 @@ extern "C" {
12151249
dirfd: ::c_int,
12161250
path: *const ::c_char,
12171251
) -> ::c_int;
1252+
#[cfg_attr(
1253+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1254+
link_name = "preadv64v2"
1255+
)]
12181256
pub fn preadv2(
12191257
fd: ::c_int,
12201258
iov: *const ::iovec,
12211259
iovcnt: ::c_int,
12221260
offset: ::off_t,
12231261
flags: ::c_int,
12241262
) -> ::ssize_t;
1263+
#[cfg_attr(
1264+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1265+
link_name = "pwritev64v2"
1266+
)]
12251267
pub fn pwritev2(
12261268
fd: ::c_int,
12271269
iov: *const ::iovec,
@@ -1257,14 +1299,26 @@ extern "C" {
12571299
pub fn reallocarray(ptr: *mut ::c_void, nmemb: ::size_t, size: ::size_t) -> *mut ::c_void;
12581300

12591301
pub fn ctermid(s: *mut ::c_char) -> *mut ::c_char;
1302+
#[cfg_attr(
1303+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1304+
link_name = "__ioctl_time64"
1305+
)]
12601306
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
12611307
pub fn backtrace(buf: *mut *mut ::c_void, sz: ::c_int) -> ::c_int;
1308+
#[cfg_attr(
1309+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1310+
link_name = "__glob64_time64"
1311+
)]
12621312
pub fn glob64(
12631313
pattern: *const ::c_char,
12641314
flags: ::c_int,
12651315
errfunc: ::Option<extern "C" fn(epath: *const ::c_char, errno: ::c_int) -> ::c_int>,
12661316
pglob: *mut glob64_t,
12671317
) -> ::c_int;
1318+
#[cfg_attr(
1319+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1320+
link_name = "__globfree64_time64"
1321+
)]
12681322
pub fn globfree64(pglob: *mut glob64_t);
12691323
pub fn ptrace(request: ::c_uint, ...) -> ::c_long;
12701324
pub fn pthread_attr_getaffinity_np(
@@ -1331,6 +1385,10 @@ extern "C" {
13311385
pub fn eaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int;
13321386

13331387
pub fn asctime_r(tm: *const ::tm, buf: *mut ::c_char) -> *mut ::c_char;
1388+
#[cfg_attr(
1389+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1390+
link_name = "__ctime64_r"
1391+
)]
13341392
pub fn ctime_r(timep: *const time_t, buf: *mut ::c_char) -> *mut ::c_char;
13351393

13361394
pub fn strftime(

0 commit comments

Comments
 (0)