Skip to content

Commit 5681f48

Browse files
committed
Use the gnu_time64_abi config to control which glibc symbols to redirect
Refines "Use _TIME_BITS and _FILE_OFFSET_BITS=64 versions of glibc symbols"
1 parent 9cfe2e9 commit 5681f48

File tree

4 files changed

+26
-109
lines changed

4 files changed

+26
-109
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ extern "C" {
355355
newp: *mut ::c_void,
356356
newlen: ::size_t,
357357
) -> ::c_int;
358-
#[link_name = "__ntp_gettime64"]
358+
#[cfg_attr(gnu_time64_abi, link_name = "__ntp_gettime64")]
359359
pub fn ntp_gettime(buf: *mut ntptimeval) -> ::c_int;
360360
}
361361

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

Lines changed: 15 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,20 +1072,14 @@ extern "C" {
10721072
>,
10731073
arg: *mut ::c_void,
10741074
);
1075-
#[cfg_attr(
1076-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1077-
link_name = "__sendmmsg64"
1078-
)]
1075+
#[cfg_attr(gnu_time64_abi, link_name = "__sendmmsg64")]
10791076
pub fn sendmmsg(
10801077
sockfd: ::c_int,
10811078
msgvec: *mut ::mmsghdr,
10821079
vlen: ::c_uint,
10831080
flags: ::c_int,
10841081
) -> ::c_int;
1085-
#[cfg_attr(
1086-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1087-
link_name = "__recvmmsg64"
1088-
)]
1082+
#[cfg_attr(gnu_time64_abi, link_name = "__recvmmsg64")]
10891083
pub fn recvmmsg(
10901084
sockfd: ::c_int,
10911085
msgvec: *mut ::mmsghdr,
@@ -1096,20 +1090,11 @@ extern "C" {
10961090

10971091
pub fn getrlimit64(resource: ::__rlimit_resource_t, rlim: *mut ::rlimit64) -> ::c_int;
10981092
pub fn setrlimit64(resource: ::__rlimit_resource_t, rlim: *const ::rlimit64) -> ::c_int;
1099-
#[cfg_attr(
1100-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1101-
link_name = "getrlimit64"
1102-
)]
1093+
#[cfg_attr(gnu_time64_abi, link_name = "getrlimit64")]
11031094
pub fn getrlimit(resource: ::__rlimit_resource_t, rlim: *mut ::rlimit) -> ::c_int;
1104-
#[cfg_attr(
1105-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1106-
link_name = "setrlimit64"
1107-
)]
1095+
#[cfg_attr(gnu_time64_abi, link_name = "setrlimit64")]
11081096
pub fn setrlimit(resource: ::__rlimit_resource_t, rlim: *const ::rlimit) -> ::c_int;
1109-
#[cfg_attr(
1110-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1111-
link_name = "prlimit64"
1112-
)]
1097+
#[cfg_attr(gnu_time64_abi, link_name = "prlimit64")]
11131098
pub fn prlimit(
11141099
pid: ::pid_t,
11151100
resource: ::__rlimit_resource_t,
@@ -1132,10 +1117,7 @@ extern "C" {
11321117
pub fn endutxent();
11331118
pub fn getpt() -> ::c_int;
11341119
pub fn mallopt(param: ::c_int, value: ::c_int) -> ::c_int;
1135-
#[cfg_attr(
1136-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1137-
link_name = "__gettimeofday64"
1138-
)]
1120+
#[cfg_attr(gnu_time64_abi, link_name = "__gettimeofday64")]
11391121
pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int;
11401122
pub fn statx(
11411123
dirfd: ::c_int,
@@ -1148,20 +1130,11 @@ extern "C" {
11481130
pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
11491131
pub fn getauxval(type_: ::c_ulong) -> ::c_ulong;
11501132

1151-
#[cfg_attr(
1152-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1153-
link_name = "___adjtimex64"
1154-
)]
1133+
#[cfg_attr(gnu_time64_abi, link_name = "___adjtimex64")]
11551134
pub fn adjtimex(buf: *mut timex) -> ::c_int;
1156-
#[cfg_attr(
1157-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1158-
link_name = "___adjtimex64"
1159-
)]
1135+
#[cfg_attr(gnu_time64_abi, link_name = "___adjtimex64")]
11601136
pub fn ntp_adjtime(buf: *mut timex) -> ::c_int;
1161-
#[cfg_attr(
1162-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1163-
link_name = "__clock_adjtime64"
1164-
)]
1137+
#[cfg_attr(gnu_time64_abi, link_name = "__clock_adjtime64")]
11651138
pub fn clock_adjtime(clk_id: ::clockid_t, buf: *mut ::timex) -> ::c_int;
11661139

11671140
pub fn fanotify_mark(
@@ -1171,21 +1144,15 @@ extern "C" {
11711144
dirfd: ::c_int,
11721145
path: *const ::c_char,
11731146
) -> ::c_int;
1174-
#[cfg_attr(
1175-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1176-
link_name = "preadv64v2"
1177-
)]
1147+
#[cfg_attr(gnu_time64_abi, link_name = "preadv64v2")]
11781148
pub fn preadv2(
11791149
fd: ::c_int,
11801150
iov: *const ::iovec,
11811151
iovcnt: ::c_int,
11821152
offset: ::off_t,
11831153
flags: ::c_int,
11841154
) -> ::ssize_t;
1185-
#[cfg_attr(
1186-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1187-
link_name = "pwritev64v2"
1188-
)]
1155+
#[cfg_attr(gnu_time64_abi, link_name = "pwritev64v2")]
11891156
pub fn pwritev2(
11901157
fd: ::c_int,
11911158
iov: *const ::iovec,
@@ -1221,26 +1188,17 @@ extern "C" {
12211188
pub fn reallocarray(ptr: *mut ::c_void, nmemb: ::size_t, size: ::size_t) -> *mut ::c_void;
12221189

12231190
pub fn ctermid(s: *mut ::c_char) -> *mut ::c_char;
1224-
#[cfg_attr(
1225-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1226-
link_name = "__ioctl_time64"
1227-
)]
1191+
#[cfg_attr(gnu_time64_abi, link_name = "__ioctl_time64")]
12281192
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
12291193
pub fn backtrace(buf: *mut *mut ::c_void, sz: ::c_int) -> ::c_int;
1230-
#[cfg_attr(
1231-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1232-
link_name = "__glob64_time64"
1233-
)]
1194+
#[cfg_attr(gnu_time64_abi, link_name = "__glob64_time64")]
12341195
pub fn glob64(
12351196
pattern: *const ::c_char,
12361197
flags: ::c_int,
12371198
errfunc: ::Option<extern "C" fn(epath: *const ::c_char, errno: ::c_int) -> ::c_int>,
12381199
pglob: *mut glob64_t,
12391200
) -> ::c_int;
1240-
#[cfg_attr(
1241-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1242-
link_name = "__globfree64_time64"
1243-
)]
1201+
#[cfg_attr(gnu_time64_abi, link_name = "__globfree64_time64")]
12441202
pub fn globfree64(pglob: *mut glob64_t);
12451203
pub fn ptrace(request: ::c_uint, ...) -> ::c_long;
12461204
pub fn pthread_attr_getaffinity_np(
@@ -1307,10 +1265,7 @@ extern "C" {
13071265
pub fn eaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int;
13081266

13091267
pub fn asctime_r(tm: *const ::tm, buf: *mut ::c_char) -> *mut ::c_char;
1310-
#[cfg_attr(
1311-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1312-
link_name = "__ctime64_r"
1313-
)]
1268+
#[cfg_attr(gnu_time64_abi, link_name = "__ctime64_r")]
13141269
pub fn ctime_r(timep: *const time_t, buf: *mut ::c_char) -> *mut ::c_char;
13151270

13161271
pub fn strftime(

src/unix/linux_like/linux/mod.rs

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4104,45 +4104,24 @@ safe_f! {
41044104
cfg_if! {
41054105
if #[cfg(all(not(target_env = "uclibc"), not(target_env = "ohos")))] {
41064106
extern "C" {
4107-
#[cfg_attr(
4108-
all(target_env = "gnu", target_pointer_width = "32", not(target_arch = "x86_64")),
4109-
link_name = "aio_read64"
4110-
)]
4107+
#[cfg_attr(gnu_time64_abi, link_name = "aio_read64")]
41114108
pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
4112-
#[cfg_attr(
4113-
all(target_env = "gnu", target_pointer_width = "32", not(target_arch = "x86_64")),
4114-
link_name = "aio_write64"
4115-
)]
4109+
#[cfg_attr(gnu_time64_abi, link_name = "aio_write64")]
41164110
pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;
41174111
pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
4118-
#[cfg_attr(
4119-
all(target_env = "gnu", target_pointer_width = "32", not(target_arch = "x86_64")),
4120-
link_name = "aio_error64"
4121-
)]
4112+
#[cfg_attr(gnu_time64_abi, link_name = "aio_error64")]
41224113
pub fn aio_error(aiocbp: *const aiocb) -> ::c_int;
4123-
#[cfg_attr(
4124-
all(target_env = "gnu", target_pointer_width = "32", not(target_arch = "x86_64")),
4125-
link_name = "aio_return64"
4126-
)]
4114+
#[cfg_attr(gnu_time64_abi, link_name = "aio_return64")]
41274115
pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t;
4128-
#[cfg_attr(
4129-
all(target_env = "gnu", target_pointer_width = "32", not(target_arch = "x86_64")),
4130-
link_name = "__aio_suspend_time64"
4131-
)]
4116+
#[cfg_attr(gnu_time64_abi, link_name = "__aio_suspend_time64")]
41324117
pub fn aio_suspend(
41334118
aiocb_list: *const *const aiocb,
41344119
nitems: ::c_int,
41354120
timeout: *const ::timespec,
41364121
) -> ::c_int;
4137-
#[cfg_attr(
4138-
all(target_env = "gnu", target_pointer_width = "32", not(target_arch = "x86_64")),
4139-
link_name = "aio_cancel64"
4140-
)]
4122+
#[cfg_attr(gnu_time64_abi, link_name = "aio_cancel64")]
41414123
pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
4142-
#[cfg_attr(
4143-
all(target_env = "gnu", target_pointer_width = "32", not(target_arch = "x86_64")),
4144-
link_name = "lio_listio64"
4145-
)]
4124+
#[cfg_attr(gnu_time64_abi, link_name = "lio_listio64")]
41464125
pub fn lio_listio(
41474126
mode: ::c_int,
41484127
aiocb_list: *const *mut aiocb,
@@ -4398,14 +4377,7 @@ extern "C" {
43984377
link_name = "fallocate64"
43994378
)]
44004379
pub fn fallocate(fd: ::c_int, mode: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int;
4401-
#[cfg_attr(
4402-
all(
4403-
target_env = "gnu",
4404-
target_pointer_width = "32",
4405-
not(target_arch = "x86_64")
4406-
),
4407-
link_name = "posix_fallocate64"
4408-
)]
4380+
#[cfg_attr(gnu_time64_abi, link_name = "posix_fallocate64")]
44094381
pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int;
44104382
pub fn readahead(fd: ::c_int, offset: ::off64_t, count: ::size_t) -> ::ssize_t;
44114383
pub fn getxattr(

src/unix/mod.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -480,23 +480,13 @@ extern "C" {
480480
all(target_os = "macos", target_arch = "x86"),
481481
link_name = "fopen$UNIX2003"
482482
)]
483-
#[cfg_attr(
484-
all(target_os = "linux", target_env = "gnu", target_pointer_width = "32"),
485-
link_name = "fopen64"
486-
)]
483+
#[cfg_attr(gnu_time64_abi, link_name = "fopen64")]
487484
pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE;
488485
#[cfg_attr(
489486
all(target_os = "macos", target_arch = "x86"),
490487
link_name = "freopen$UNIX2003"
491488
)]
492-
#[cfg_attr(
493-
all(
494-
target_env = "gnu",
495-
target_pointer_width = "32",
496-
not(target_arch = "x86_64")
497-
),
498-
link_name = "freopen64"
499-
)]
489+
#[cfg_attr(gnu_time64_abi, link_name = "freopen64")]
500490
pub fn freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE;
501491

502492
pub fn fflush(file: *mut FILE) -> c_int;

0 commit comments

Comments
 (0)