Skip to content

Commit 878821c

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 ff37811 commit 878821c

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
@@ -1074,20 +1074,14 @@ extern "C" {
10741074
>,
10751075
arg: *mut ::c_void,
10761076
);
1077-
#[cfg_attr(
1078-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1079-
link_name = "__sendmmsg64"
1080-
)]
1077+
#[cfg_attr(gnu_time64_abi, link_name = "__sendmmsg64")]
10811078
pub fn sendmmsg(
10821079
sockfd: ::c_int,
10831080
msgvec: *mut ::mmsghdr,
10841081
vlen: ::c_uint,
10851082
flags: ::c_int,
10861083
) -> ::c_int;
1087-
#[cfg_attr(
1088-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1089-
link_name = "__recvmmsg64"
1090-
)]
1084+
#[cfg_attr(gnu_time64_abi, link_name = "__recvmmsg64")]
10911085
pub fn recvmmsg(
10921086
sockfd: ::c_int,
10931087
msgvec: *mut ::mmsghdr,
@@ -1098,20 +1092,11 @@ extern "C" {
10981092

10991093
pub fn getrlimit64(resource: ::__rlimit_resource_t, rlim: *mut ::rlimit64) -> ::c_int;
11001094
pub fn setrlimit64(resource: ::__rlimit_resource_t, rlim: *const ::rlimit64) -> ::c_int;
1101-
#[cfg_attr(
1102-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1103-
link_name = "getrlimit64"
1104-
)]
1095+
#[cfg_attr(gnu_time64_abi, link_name = "getrlimit64")]
11051096
pub fn getrlimit(resource: ::__rlimit_resource_t, rlim: *mut ::rlimit) -> ::c_int;
1106-
#[cfg_attr(
1107-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1108-
link_name = "setrlimit64"
1109-
)]
1097+
#[cfg_attr(gnu_time64_abi, link_name = "setrlimit64")]
11101098
pub fn setrlimit(resource: ::__rlimit_resource_t, rlim: *const ::rlimit) -> ::c_int;
1111-
#[cfg_attr(
1112-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1113-
link_name = "prlimit64"
1114-
)]
1099+
#[cfg_attr(gnu_time64_abi, link_name = "prlimit64")]
11151100
pub fn prlimit(
11161101
pid: ::pid_t,
11171102
resource: ::__rlimit_resource_t,
@@ -1134,10 +1119,7 @@ extern "C" {
11341119
pub fn endutxent();
11351120
pub fn getpt() -> ::c_int;
11361121
pub fn mallopt(param: ::c_int, value: ::c_int) -> ::c_int;
1137-
#[cfg_attr(
1138-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1139-
link_name = "__gettimeofday64"
1140-
)]
1122+
#[cfg_attr(gnu_time64_abi, link_name = "__gettimeofday64")]
11411123
pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int;
11421124
pub fn statx(
11431125
dirfd: ::c_int,
@@ -1150,20 +1132,11 @@ extern "C" {
11501132
pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
11511133
pub fn getauxval(type_: ::c_ulong) -> ::c_ulong;
11521134

1153-
#[cfg_attr(
1154-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1155-
link_name = "___adjtimex64"
1156-
)]
1135+
#[cfg_attr(gnu_time64_abi, link_name = "___adjtimex64")]
11571136
pub fn adjtimex(buf: *mut timex) -> ::c_int;
1158-
#[cfg_attr(
1159-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1160-
link_name = "___adjtimex64"
1161-
)]
1137+
#[cfg_attr(gnu_time64_abi, link_name = "___adjtimex64")]
11621138
pub fn ntp_adjtime(buf: *mut timex) -> ::c_int;
1163-
#[cfg_attr(
1164-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1165-
link_name = "__clock_adjtime64"
1166-
)]
1139+
#[cfg_attr(gnu_time64_abi, link_name = "__clock_adjtime64")]
11671140
pub fn clock_adjtime(clk_id: ::clockid_t, buf: *mut ::timex) -> ::c_int;
11681141

11691142
pub fn fanotify_mark(
@@ -1173,21 +1146,15 @@ extern "C" {
11731146
dirfd: ::c_int,
11741147
path: *const ::c_char,
11751148
) -> ::c_int;
1176-
#[cfg_attr(
1177-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1178-
link_name = "preadv64v2"
1179-
)]
1149+
#[cfg_attr(gnu_time64_abi, link_name = "preadv64v2")]
11801150
pub fn preadv2(
11811151
fd: ::c_int,
11821152
iov: *const ::iovec,
11831153
iovcnt: ::c_int,
11841154
offset: ::off_t,
11851155
flags: ::c_int,
11861156
) -> ::ssize_t;
1187-
#[cfg_attr(
1188-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1189-
link_name = "pwritev64v2"
1190-
)]
1157+
#[cfg_attr(gnu_time64_abi, link_name = "pwritev64v2")]
11911158
pub fn pwritev2(
11921159
fd: ::c_int,
11931160
iov: *const ::iovec,
@@ -1223,26 +1190,17 @@ extern "C" {
12231190
pub fn reallocarray(ptr: *mut ::c_void, nmemb: ::size_t, size: ::size_t) -> *mut ::c_void;
12241191

12251192
pub fn ctermid(s: *mut ::c_char) -> *mut ::c_char;
1226-
#[cfg_attr(
1227-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1228-
link_name = "__ioctl_time64"
1229-
)]
1193+
#[cfg_attr(gnu_time64_abi, link_name = "__ioctl_time64")]
12301194
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
12311195
pub fn backtrace(buf: *mut *mut ::c_void, sz: ::c_int) -> ::c_int;
1232-
#[cfg_attr(
1233-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1234-
link_name = "__glob64_time64"
1235-
)]
1196+
#[cfg_attr(gnu_time64_abi, link_name = "__glob64_time64")]
12361197
pub fn glob64(
12371198
pattern: *const ::c_char,
12381199
flags: ::c_int,
12391200
errfunc: ::Option<extern "C" fn(epath: *const ::c_char, errno: ::c_int) -> ::c_int>,
12401201
pglob: *mut glob64_t,
12411202
) -> ::c_int;
1242-
#[cfg_attr(
1243-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1244-
link_name = "__globfree64_time64"
1245-
)]
1203+
#[cfg_attr(gnu_time64_abi, link_name = "__globfree64_time64")]
12461204
pub fn globfree64(pglob: *mut glob64_t);
12471205
pub fn ptrace(request: ::c_uint, ...) -> ::c_long;
12481206
pub fn pthread_attr_getaffinity_np(
@@ -1309,10 +1267,7 @@ extern "C" {
13091267
pub fn eaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int;
13101268

13111269
pub fn asctime_r(tm: *const ::tm, buf: *mut ::c_char) -> *mut ::c_char;
1312-
#[cfg_attr(
1313-
all(target_pointer_width = "32", not(target_arch = "x86_64")),
1314-
link_name = "__ctime64_r"
1315-
)]
1270+
#[cfg_attr(gnu_time64_abi, link_name = "__ctime64_r")]
13161271
pub fn ctime_r(timep: *const time_t, buf: *mut ::c_char) -> *mut ::c_char;
13171272

13181273
pub fn strftime(

src/unix/linux_like/linux/mod.rs

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4105,45 +4105,24 @@ safe_f! {
41054105
cfg_if! {
41064106
if #[cfg(all(not(target_env = "uclibc"), not(target_env = "ohos")))] {
41074107
extern "C" {
4108-
#[cfg_attr(
4109-
all(target_env = "gnu", target_pointer_width = "32", not(target_arch = "x86_64")),
4110-
link_name = "aio_read64"
4111-
)]
4108+
#[cfg_attr(gnu_time64_abi, link_name = "aio_read64")]
41124109
pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
4113-
#[cfg_attr(
4114-
all(target_env = "gnu", target_pointer_width = "32", not(target_arch = "x86_64")),
4115-
link_name = "aio_write64"
4116-
)]
4110+
#[cfg_attr(gnu_time64_abi, link_name = "aio_write64")]
41174111
pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;
41184112
pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
4119-
#[cfg_attr(
4120-
all(target_env = "gnu", target_pointer_width = "32", not(target_arch = "x86_64")),
4121-
link_name = "aio_error64"
4122-
)]
4113+
#[cfg_attr(gnu_time64_abi, link_name = "aio_error64")]
41234114
pub fn aio_error(aiocbp: *const aiocb) -> ::c_int;
4124-
#[cfg_attr(
4125-
all(target_env = "gnu", target_pointer_width = "32", not(target_arch = "x86_64")),
4126-
link_name = "aio_return64"
4127-
)]
4115+
#[cfg_attr(gnu_time64_abi, link_name = "aio_return64")]
41284116
pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t;
4129-
#[cfg_attr(
4130-
all(target_env = "gnu", target_pointer_width = "32", not(target_arch = "x86_64")),
4131-
link_name = "__aio_suspend_time64"
4132-
)]
4117+
#[cfg_attr(gnu_time64_abi, link_name = "__aio_suspend_time64")]
41334118
pub fn aio_suspend(
41344119
aiocb_list: *const *const aiocb,
41354120
nitems: ::c_int,
41364121
timeout: *const ::timespec,
41374122
) -> ::c_int;
4138-
#[cfg_attr(
4139-
all(target_env = "gnu", target_pointer_width = "32", not(target_arch = "x86_64")),
4140-
link_name = "aio_cancel64"
4141-
)]
4123+
#[cfg_attr(gnu_time64_abi, link_name = "aio_cancel64")]
41424124
pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
4143-
#[cfg_attr(
4144-
all(target_env = "gnu", target_pointer_width = "32", not(target_arch = "x86_64")),
4145-
link_name = "lio_listio64"
4146-
)]
4125+
#[cfg_attr(gnu_time64_abi, link_name = "lio_listio64")]
41474126
pub fn lio_listio(
41484127
mode: ::c_int,
41494128
aiocb_list: *const *mut aiocb,
@@ -4399,14 +4378,7 @@ extern "C" {
43994378
link_name = "fallocate64"
44004379
)]
44014380
pub fn fallocate(fd: ::c_int, mode: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int;
4402-
#[cfg_attr(
4403-
all(
4404-
target_env = "gnu",
4405-
target_pointer_width = "32",
4406-
not(target_arch = "x86_64")
4407-
),
4408-
link_name = "posix_fallocate64"
4409-
)]
4381+
#[cfg_attr(gnu_time64_abi, link_name = "posix_fallocate64")]
44104382
pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int;
44114383
pub fn readahead(fd: ::c_int, offset: ::off64_t, count: ::size_t) -> ::ssize_t;
44124384
pub fn getxattr(

src/unix/mod.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -475,23 +475,13 @@ extern "C" {
475475
all(target_os = "macos", target_arch = "x86"),
476476
link_name = "fopen$UNIX2003"
477477
)]
478-
#[cfg_attr(
479-
all(target_os = "linux", target_env = "gnu", target_pointer_width = "32"),
480-
link_name = "fopen64"
481-
)]
478+
#[cfg_attr(gnu_time64_abi, link_name = "fopen64")]
482479
pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE;
483480
#[cfg_attr(
484481
all(target_os = "macos", target_arch = "x86"),
485482
link_name = "freopen$UNIX2003"
486483
)]
487-
#[cfg_attr(
488-
all(
489-
target_env = "gnu",
490-
target_pointer_width = "32",
491-
not(target_arch = "x86_64")
492-
),
493-
link_name = "freopen64"
494-
)]
484+
#[cfg_attr(gnu_time64_abi, link_name = "freopen64")]
495485
pub fn freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE;
496486

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

0 commit comments

Comments
 (0)