Skip to content

Commit a630a8a

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 63c884b commit a630a8a

File tree

6 files changed

+667
-2
lines changed

6 files changed

+667
-2
lines changed

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
@@ -95,6 +95,11 @@ pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
9595

9696
pub const O_LARGEFILE: ::c_int = 0;
9797

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

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

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,12 +1133,20 @@ extern "C" {
11331133
>,
11341134
arg: *mut ::c_void,
11351135
);
1136+
#[cfg_attr(
1137+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1138+
link_name = "__sendmmsg64"
1139+
)]
11361140
pub fn sendmmsg(
11371141
sockfd: ::c_int,
11381142
msgvec: *mut ::mmsghdr,
11391143
vlen: ::c_uint,
11401144
flags: ::c_int,
11411145
) -> ::c_int;
1146+
#[cfg_attr(
1147+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1148+
link_name = "__recvmmsg64"
1149+
)]
11421150
pub fn recvmmsg(
11431151
sockfd: ::c_int,
11441152
msgvec: *mut ::mmsghdr,
@@ -1149,8 +1157,20 @@ extern "C" {
11491157

11501158
pub fn getrlimit64(resource: ::__rlimit_resource_t, rlim: *mut ::rlimit64) -> ::c_int;
11511159
pub fn setrlimit64(resource: ::__rlimit_resource_t, rlim: *const ::rlimit64) -> ::c_int;
1160+
#[cfg_attr(
1161+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1162+
link_name = "getrlimit64"
1163+
)]
11521164
pub fn getrlimit(resource: ::__rlimit_resource_t, rlim: *mut ::rlimit) -> ::c_int;
1165+
#[cfg_attr(
1166+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1167+
link_name = "setrlimit64"
1168+
)]
11531169
pub fn setrlimit(resource: ::__rlimit_resource_t, rlim: *const ::rlimit) -> ::c_int;
1170+
#[cfg_attr(
1171+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1172+
link_name = "prlimit64"
1173+
)]
11541174
pub fn prlimit(
11551175
pid: ::pid_t,
11561176
resource: ::__rlimit_resource_t,
@@ -1173,6 +1193,10 @@ extern "C" {
11731193
pub fn endutxent();
11741194
pub fn getpt() -> ::c_int;
11751195
pub fn mallopt(param: ::c_int, value: ::c_int) -> ::c_int;
1196+
#[cfg_attr(
1197+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1198+
link_name = "__gettimeofday64"
1199+
)]
11761200
pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int;
11771201
pub fn statx(
11781202
dirfd: ::c_int,
@@ -1185,10 +1209,20 @@ extern "C" {
11851209
pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
11861210
pub fn getauxval(type_: ::c_ulong) -> ::c_ulong;
11871211

1212+
#[cfg_attr(
1213+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1214+
link_name = "___adjtimex64"
1215+
)]
11881216
pub fn adjtimex(buf: *mut timex) -> ::c_int;
1217+
#[cfg_attr(
1218+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1219+
link_name = "___adjtimex64"
1220+
)]
11891221
pub fn ntp_adjtime(buf: *mut timex) -> ::c_int;
1190-
#[link_name = "ntp_gettimex"]
1191-
pub fn ntp_gettime(buf: *mut ntptimeval) -> ::c_int;
1222+
#[cfg_attr(
1223+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1224+
link_name = "__clock_adjtime64"
1225+
)]
11921226
pub fn clock_adjtime(clk_id: ::clockid_t, buf: *mut ::timex) -> ::c_int;
11931227

11941228
pub fn fanotify_mark(
@@ -1198,13 +1232,21 @@ extern "C" {
11981232
dirfd: ::c_int,
11991233
path: *const ::c_char,
12001234
) -> ::c_int;
1235+
#[cfg_attr(
1236+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1237+
link_name = "preadv64v2"
1238+
)]
12011239
pub fn preadv2(
12021240
fd: ::c_int,
12031241
iov: *const ::iovec,
12041242
iovcnt: ::c_int,
12051243
offset: ::off_t,
12061244
flags: ::c_int,
12071245
) -> ::ssize_t;
1246+
#[cfg_attr(
1247+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1248+
link_name = "pwritev64v2"
1249+
)]
12081250
pub fn pwritev2(
12091251
fd: ::c_int,
12101252
iov: *const ::iovec,
@@ -1240,14 +1282,26 @@ extern "C" {
12401282
pub fn reallocarray(ptr: *mut ::c_void, nmemb: ::size_t, size: ::size_t) -> *mut ::c_void;
12411283

12421284
pub fn ctermid(s: *mut ::c_char) -> *mut ::c_char;
1285+
#[cfg_attr(
1286+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1287+
link_name = "__ioctl_time64"
1288+
)]
12431289
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
12441290
pub fn backtrace(buf: *mut *mut ::c_void, sz: ::c_int) -> ::c_int;
1291+
#[cfg_attr(
1292+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1293+
link_name = "__glob64_time64"
1294+
)]
12451295
pub fn glob64(
12461296
pattern: *const ::c_char,
12471297
flags: ::c_int,
12481298
errfunc: ::Option<extern "C" fn(epath: *const ::c_char, errno: ::c_int) -> ::c_int>,
12491299
pglob: *mut glob64_t,
12501300
) -> ::c_int;
1301+
#[cfg_attr(
1302+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1303+
link_name = "__globfree64_time64"
1304+
)]
12511305
pub fn globfree64(pglob: *mut glob64_t);
12521306
pub fn ptrace(request: ::c_uint, ...) -> ::c_long;
12531307
pub fn pthread_attr_getaffinity_np(
@@ -1311,6 +1365,10 @@ extern "C" {
13111365
pub fn eaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int;
13121366

13131367
pub fn asctime_r(tm: *const ::tm, buf: *mut ::c_char) -> *mut ::c_char;
1368+
#[cfg_attr(
1369+
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1370+
link_name = "__ctime64_r"
1371+
)]
13141372
pub fn ctime_r(timep: *const time_t, buf: *mut ::c_char) -> *mut ::c_char;
13151373

13161374
pub fn strftime(

0 commit comments

Comments
 (0)