Skip to content

Commit facf674

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 059b698 commit facf674

File tree

6 files changed

+406
-2
lines changed

6 files changed

+406
-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: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,12 +1133,14 @@ extern "C" {
11331133
>,
11341134
arg: *mut ::c_void,
11351135
);
1136+
#[cfg_attr(target_pointer_width = "32", link_name = "__sendmmsg64")]
11361137
pub fn sendmmsg(
11371138
sockfd: ::c_int,
11381139
msgvec: *mut ::mmsghdr,
11391140
vlen: ::c_uint,
11401141
flags: ::c_int,
11411142
) -> ::c_int;
1143+
#[cfg_attr(target_pointer_width = "32", link_name = "__recvmmsg64")]
11421144
pub fn recvmmsg(
11431145
sockfd: ::c_int,
11441146
msgvec: *mut ::mmsghdr,
@@ -1149,8 +1151,11 @@ extern "C" {
11491151

11501152
pub fn getrlimit64(resource: ::__rlimit_resource_t, rlim: *mut ::rlimit64) -> ::c_int;
11511153
pub fn setrlimit64(resource: ::__rlimit_resource_t, rlim: *const ::rlimit64) -> ::c_int;
1154+
#[cfg_attr(all(target_pointer_width = "32"), link_name = "getrlimit64")]
11521155
pub fn getrlimit(resource: ::__rlimit_resource_t, rlim: *mut ::rlimit) -> ::c_int;
1156+
#[cfg_attr(all(target_pointer_width = "32"), link_name = "setrlimit64")]
11531157
pub fn setrlimit(resource: ::__rlimit_resource_t, rlim: *const ::rlimit) -> ::c_int;
1158+
#[cfg_attr(all(target_pointer_width = "32"), link_name = "prlimit64")]
11541159
pub fn prlimit(
11551160
pid: ::pid_t,
11561161
resource: ::__rlimit_resource_t,
@@ -1173,6 +1178,7 @@ extern "C" {
11731178
pub fn endutxent();
11741179
pub fn getpt() -> ::c_int;
11751180
pub fn mallopt(param: ::c_int, value: ::c_int) -> ::c_int;
1181+
#[cfg_attr(target_pointer_width = "32", link_name = "__gettimeofday64")]
11761182
pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int;
11771183
pub fn statx(
11781184
dirfd: ::c_int,
@@ -1185,10 +1191,11 @@ extern "C" {
11851191
pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
11861192
pub fn getauxval(type_: ::c_ulong) -> ::c_ulong;
11871193

1194+
#[cfg_attr(target_pointer_width = "32", link_name = "___adjtimex64")]
11881195
pub fn adjtimex(buf: *mut timex) -> ::c_int;
1196+
#[cfg_attr(target_pointer_width = "32", link_name = "___adjtimex64")]
11891197
pub fn ntp_adjtime(buf: *mut timex) -> ::c_int;
1190-
#[link_name = "ntp_gettimex"]
1191-
pub fn ntp_gettime(buf: *mut ntptimeval) -> ::c_int;
1198+
#[cfg_attr(target_pointer_width = "32", link_name = "__clock_adjtime64")]
11921199
pub fn clock_adjtime(clk_id: ::clockid_t, buf: *mut ::timex) -> ::c_int;
11931200

11941201
pub fn fanotify_mark(
@@ -1198,13 +1205,15 @@ extern "C" {
11981205
dirfd: ::c_int,
11991206
path: *const ::c_char,
12001207
) -> ::c_int;
1208+
#[cfg_attr(target_pointer_width = "32", link_name = "preadv64v2")]
12011209
pub fn preadv2(
12021210
fd: ::c_int,
12031211
iov: *const ::iovec,
12041212
iovcnt: ::c_int,
12051213
offset: ::off_t,
12061214
flags: ::c_int,
12071215
) -> ::ssize_t;
1216+
#[cfg_attr(target_pointer_width = "32", link_name = "pwritev64v2")]
12081217
pub fn pwritev2(
12091218
fd: ::c_int,
12101219
iov: *const ::iovec,
@@ -1243,14 +1252,17 @@ extern "C" {
12431252
}
12441253

12451254
extern "C" {
1255+
#[cfg_attr(target_pointer_width = "32", link_name = "__ioctl_time64")]
12461256
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
12471257
pub fn backtrace(buf: *mut *mut ::c_void, sz: ::c_int) -> ::c_int;
1258+
#[cfg_attr(target_pointer_width = "32", link_name = "__glob64_time64")]
12481259
pub fn glob64(
12491260
pattern: *const ::c_char,
12501261
flags: ::c_int,
12511262
errfunc: ::Option<extern "C" fn(epath: *const ::c_char, errno: ::c_int) -> ::c_int>,
12521263
pglob: *mut glob64_t,
12531264
) -> ::c_int;
1265+
#[cfg_attr(target_pointer_width = "32", link_name = "__globfree64_time64")]
12541266
pub fn globfree64(pglob: *mut glob64_t);
12551267
pub fn ptrace(request: ::c_uint, ...) -> ::c_long;
12561268
pub fn pthread_attr_getaffinity_np(
@@ -1314,6 +1326,7 @@ extern "C" {
13141326
pub fn eaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int;
13151327

13161328
pub fn asctime_r(tm: *const ::tm, buf: *mut ::c_char) -> *mut ::c_char;
1329+
#[cfg_attr(target_pointer_width = "32", link_name = "__ctime64_r")]
13171330
pub fn ctime_r(timep: *const time_t, buf: *mut ::c_char) -> *mut ::c_char;
13181331

13191332
pub fn strftime(

0 commit comments

Comments
 (0)