Skip to content

Commit b469721

Browse files
authored
Merge pull request #4433 from snogge/gnu-time-bits-64
Gnu time bits 64
2 parents 3451a9d + 402a851 commit b469721

File tree

16 files changed

+516
-131
lines changed

16 files changed

+516
-131
lines changed

.github/workflows/ci.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ jobs:
9898
artifact-tag: offset-bits64
9999
env:
100100
RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64
101+
- target: i686-unknown-linux-gnu
102+
docker: true
103+
os: ubuntu-24.04
104+
artifact-tag: time-bits64
105+
env:
106+
RUST_LIBC_UNSTABLE_GNU_TIME_BITS: 64
101107
- target: x86_64-unknown-linux-gnu
102108
docker: true
103109
os: ubuntu-24.04
@@ -195,6 +201,10 @@ jobs:
195201
env:
196202
RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64
197203
artifact-tag: offset-bits64
204+
- target: arm-unknown-linux-gnueabihf
205+
env:
206+
RUST_LIBC_UNSTABLE_GNU_TIME_BITS: 64
207+
artifact-tag: time-bits64
198208
- target: aarch64-unknown-linux-musl
199209
env:
200210
RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1
@@ -214,6 +224,10 @@ jobs:
214224
# env:
215225
# RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64
216226
# artifact-tag: offset-bits64
227+
# - target: powerpc-unknown-linux-gnu
228+
# env:
229+
# RUST_LIBC_UNSTABLE_GNU_TIME_BITS: 64
230+
# artifact-tag: time-bits64
217231
timeout-minutes: 25
218232
env:
219233
TARGET: ${{ matrix.target }}

build.rs

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ const ALLOWED_CFGS: &[&str] = &[
1515
"freebsd15",
1616
// Corresponds to `_FILE_OFFSET_BITS=64` in glibc
1717
"gnu_file_offset_bits64",
18+
// Corresponds to `_TIME_BITS=64` in glibc
19+
"gnu_time_bits64",
1820
// FIXME(ctest): this config shouldn't be needed but ctest can't parse `const extern fn`
1921
"libc_const_extern_fn",
2022
"libc_deny_warnings",
@@ -99,23 +101,35 @@ fn main() {
99101
set_cfg("linux_time_bits64");
100102
}
101103
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS");
102-
match env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS") {
103-
Ok(val) if val == "64" => {
104-
if target_env == "gnu"
105-
&& target_os == "linux"
106-
&& target_ptr_width == "32"
107-
&& target_arch != "riscv32"
108-
&& target_arch != "x86_64"
109-
{
104+
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_GNU_TIME_BITS");
105+
if target_env == "gnu"
106+
&& target_os == "linux"
107+
&& target_ptr_width == "32"
108+
&& target_arch != "riscv32"
109+
&& target_arch != "x86_64"
110+
{
111+
match env::var("RUST_LIBC_UNSTABLE_GNU_TIME_BITS") {
112+
Ok(val) if val == "64" => {
110113
set_cfg("gnu_file_offset_bits64");
114+
set_cfg("linux_time_bits64");
115+
set_cfg("gnu_time_bits64");
116+
}
117+
Ok(val) if val != "32" => {
118+
panic!("RUST_LIBC_UNSTABLE_GNU_TIME_BITS may only be set to '32' or '64'")
119+
}
120+
_ => {
121+
match env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS") {
122+
Ok(val) if val == "64" => {
123+
set_cfg("gnu_file_offset_bits64");
124+
}
125+
Ok(val) if val != "32" => {
126+
panic!("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS may only be set to '32' or '64'")
127+
}
128+
_ => {}
129+
}
111130
}
112131
}
113-
Ok(val) if val != "32" => {
114-
panic!("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS may only be set to '32' or '64'")
115-
}
116-
_ => {}
117132
}
118-
119133
// On CI: deny all warnings
120134
if libc_ci {
121135
set_cfg("libc_deny_warnings");

ci/run-docker.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ run() {
4444
--env LIBC_CI \
4545
--env LIBC_CI_ZBUILD_STD \
4646
--env RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS \
47+
--env RUST_LIBC_UNSTABLE_GNU_TIME_BITS \
4748
--env CARGO_HOME=/cargo \
4849
--env CARGO_TARGET_DIR=/checkout/target \
4950
--volume "$CARGO_HOME":/cargo \

ci/verify-build.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,12 @@ test_target() {
7575
# Test with the equivalent of __USE_TIME_BITS64
7676
RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64=1 $cmd
7777
case "$target" in
78-
# Test with the equivalent of __FILE_OFFSET_BITS=64
7978
arm*-gnu*|i*86*-gnu|powerpc-*-gnu*|mips*-gnu|sparc-*-gnu|thumb-*gnu*)
80-
RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS=64 $cmd;;
79+
# Test with the equivalent of _FILE_OFFSET_BITS=64
80+
RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS=64 $cmd
81+
# Test with the equivalent of _TIME_BITS=64
82+
RUST_LIBC_UNSTABLE_GNU_TIME_BITS=64 $cmd
83+
;;
8184
esac
8285
fi
8386

libc-test/build.rs

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3615,22 +3615,37 @@ fn test_vxworks(target: &str) {
36153615
}
36163616

36173617
fn config_gnu_bits(target: &str, cfg: &mut ctest::TestGenerator) {
3618-
match env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS") {
3619-
Ok(val) if val == "64" => {
3620-
if target.contains("gnu")
3621-
&& target.contains("linux")
3622-
&& !target.ends_with("x32")
3623-
&& !target.contains("riscv32")
3624-
&& env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap() == "32"
3625-
{
3618+
let pointer_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap_or_default();
3619+
if target.contains("gnu")
3620+
&& target.contains("linux")
3621+
&& !target.ends_with("x32")
3622+
&& !target.contains("riscv32")
3623+
&& pointer_width == "32"
3624+
{
3625+
match env::var("RUST_LIBC_UNSTABLE_GNU_TIME_BITS") {
3626+
Ok(val) if val == "64" => {
36263627
cfg.define("_FILE_OFFSET_BITS", Some("64"));
3628+
cfg.define("_TIME_BITS", Some("64"));
36273629
cfg.cfg("gnu_file_offset_bits64", None);
3630+
cfg.cfg("linux_time_bits64", None);
3631+
cfg.cfg("gnu_time_bits64", None);
3632+
}
3633+
Ok(val) if val != "32" => {
3634+
panic!("RUST_LIBC_UNSTABLE_GNU_TIME_BITS may only be set to '32' or '64'")
3635+
}
3636+
_ => {
3637+
match env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS") {
3638+
Ok(val) if val == "64" => {
3639+
cfg.define("_FILE_OFFSET_BITS", Some("64"));
3640+
cfg.cfg("gnu_file_offset_bits64", None);
3641+
}
3642+
Ok(val) if val != "32" => {
3643+
panic!("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS may only be set to '32' or '64'")
3644+
}
3645+
_ => {}
3646+
}
36283647
}
36293648
}
3630-
Ok(val) if val != "32" => {
3631-
panic!("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS may only be set to '32' or '64'")
3632-
}
3633-
_ => {}
36343649
}
36353650
}
36363651

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,35 @@ s! {
6060

6161
pub struct stat64 {
6262
pub st_dev: crate::dev_t,
63+
#[cfg(not(gnu_time_bits64))]
6364
__pad1: c_uint,
65+
#[cfg(not(gnu_time_bits64))]
6466
__st_ino: c_ulong,
67+
#[cfg(gnu_time_bits64)]
68+
pub st_ino: crate::ino_t,
6569
pub st_mode: crate::mode_t,
6670
pub st_nlink: crate::nlink_t,
6771
pub st_uid: crate::uid_t,
6872
pub st_gid: crate::gid_t,
6973
pub st_rdev: crate::dev_t,
74+
#[cfg(not(gnu_time_bits64))]
7075
__pad2: c_uint,
7176
pub st_size: off64_t,
7277
pub st_blksize: crate::blksize_t,
7378
pub st_blocks: crate::blkcnt64_t,
7479
pub st_atime: crate::time_t,
7580
pub st_atime_nsec: c_long,
81+
#[cfg(gnu_time_bits64)]
82+
_atime_pad: c_int,
7683
pub st_mtime: crate::time_t,
7784
pub st_mtime_nsec: c_long,
85+
#[cfg(gnu_time_bits64)]
86+
_mtime_pad: c_int,
7887
pub st_ctime: crate::time_t,
7988
pub st_ctime_nsec: c_long,
89+
#[cfg(gnu_time_bits64)]
90+
_ctime_pad: c_int,
91+
#[cfg(not(gnu_time_bits64))]
8092
pub st_ino: crate::ino64_t,
8193
}
8294

@@ -115,10 +127,13 @@ s! {
115127
pub shm_perm: crate::ipc_perm,
116128
pub shm_segsz: size_t,
117129
pub shm_atime: crate::time_t,
130+
#[cfg(not(gnu_time_bits64))]
118131
__unused1: c_ulong,
119132
pub shm_dtime: crate::time_t,
133+
#[cfg(not(gnu_time_bits64))]
120134
__unused2: c_ulong,
121135
pub shm_ctime: crate::time_t,
136+
#[cfg(not(gnu_time_bits64))]
122137
__unused3: c_ulong,
123138
pub shm_cpid: crate::pid_t,
124139
pub shm_lpid: crate::pid_t,
@@ -130,10 +145,13 @@ s! {
130145
pub struct msqid_ds {
131146
pub msg_perm: crate::ipc_perm,
132147
pub msg_stime: crate::time_t,
148+
#[cfg(not(gnu_time_bits64))]
133149
__glibc_reserved1: c_ulong,
134150
pub msg_rtime: crate::time_t,
151+
#[cfg(not(gnu_time_bits64))]
135152
__glibc_reserved2: c_ulong,
136153
pub msg_ctime: crate::time_t,
154+
#[cfg(not(gnu_time_bits64))]
137155
__glibc_reserved3: c_ulong,
138156
pub __msg_cbytes: c_ulong,
139157
pub msg_qnum: crate::msgqnum_t,

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

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ pub type wchar_t = i32;
55

66
s! {
77
pub struct stat {
8+
#[cfg(not(gnu_time_bits64))]
89
pub st_dev: c_ulong,
10+
#[cfg(gnu_time_bits64)]
11+
pub st_dev: crate::dev_t,
912

13+
#[cfg(not(gnu_time_bits64))]
1014
st_pad1: [c_long; 3],
1115

1216
pub st_ino: crate::ino_t,
@@ -16,52 +20,99 @@ s! {
1620
pub st_uid: crate::uid_t,
1721
pub st_gid: crate::gid_t,
1822

23+
#[cfg(not(gnu_time_bits64))]
1924
pub st_rdev: c_ulong,
25+
#[cfg(gnu_time_bits64)]
26+
pub st_rdev: crate::dev_t,
2027

2128
#[cfg(not(gnu_file_offset_bits64))]
2229
st_pad2: [c_long; 2],
23-
#[cfg(gnu_file_offset_bits64)]
30+
#[cfg(all(not(gnu_time_bits64), gnu_file_offset_bits64))]
2431
st_pad2: [c_long; 3],
2532

2633
pub st_size: off_t,
2734

2835
#[cfg(not(gnu_file_offset_bits64))]
2936
st_pad3: c_long,
3037

38+
#[cfg(gnu_time_bits64)]
39+
pub st_blksize: crate::blksize_t,
40+
#[cfg(gnu_time_bits64)]
41+
pub st_blocks: crate::blkcnt_t,
42+
3143
pub st_atime: crate::time_t,
44+
#[cfg(gnu_time_bits64)]
45+
_atime_pad: c_int,
3246
pub st_atime_nsec: c_long,
3347
pub st_mtime: crate::time_t,
48+
#[cfg(gnu_time_bits64)]
49+
_mtime_pad: c_int,
3450
pub st_mtime_nsec: c_long,
3551
pub st_ctime: crate::time_t,
52+
#[cfg(gnu_time_bits64)]
53+
_ctime_pad: c_int,
3654
pub st_ctime_nsec: c_long,
3755

56+
#[cfg(not(gnu_time_bits64))]
3857
pub st_blksize: crate::blksize_t,
39-
#[cfg(gnu_file_offset_bits64)]
58+
#[cfg(all(not(gnu_time_bits64), gnu_file_offset_bits64))]
4059
st_pad4: c_long,
60+
#[cfg(not(gnu_time_bits64))]
4161
pub st_blocks: crate::blkcnt_t,
62+
#[cfg(not(gnu_time_bits64))]
4263
st_pad5: [c_long; 14],
4364
}
4465

4566
pub struct stat64 {
67+
#[cfg(not(gnu_time_bits64))]
4668
pub st_dev: c_ulong,
69+
#[cfg(gnu_time_bits64)]
70+
pub st_dev: crate::dev_t,
71+
72+
#[cfg(not(gnu_time_bits64))]
4773
st_pad1: [c_long; 3],
74+
4875
pub st_ino: crate::ino64_t,
4976
pub st_mode: crate::mode_t,
5077
pub st_nlink: crate::nlink_t,
5178
pub st_uid: crate::uid_t,
5279
pub st_gid: crate::gid_t,
80+
81+
#[cfg(not(gnu_time_bits64))]
5382
pub st_rdev: c_ulong,
83+
#[cfg(gnu_time_bits64)]
84+
pub st_rdev: crate::dev_t,
85+
86+
#[cfg(not(gnu_time_bits64))]
5487
st_pad2: [c_long; 3],
88+
5589
pub st_size: off64_t,
90+
91+
#[cfg(gnu_time_bits64)]
92+
pub st_blksize: crate::blksize_t,
93+
#[cfg(gnu_time_bits64)]
94+
pub st_blocks: crate::blkcnt_t,
95+
5696
pub st_atime: crate::time_t,
97+
#[cfg(gnu_time_bits64)]
98+
_atime_pad: c_int,
5799
pub st_atime_nsec: c_long,
58100
pub st_mtime: crate::time_t,
101+
#[cfg(gnu_time_bits64)]
102+
_mtime_pad: c_int,
59103
pub st_mtime_nsec: c_long,
60104
pub st_ctime: crate::time_t,
105+
#[cfg(gnu_time_bits64)]
106+
_ctime_pad: c_int,
61107
pub st_ctime_nsec: c_long,
108+
109+
#[cfg(not(gnu_time_bits64))]
62110
pub st_blksize: crate::blksize_t,
111+
#[cfg(not(gnu_time_bits64))]
63112
st_pad3: c_long,
113+
#[cfg(not(gnu_time_bits64))]
64114
pub st_blocks: crate::blkcnt64_t,
115+
#[cfg(not(gnu_time_bits64))]
65116
st_pad5: [c_long; 14],
66117
}
67118

@@ -161,22 +212,22 @@ s! {
161212

162213
pub struct msqid_ds {
163214
pub msg_perm: crate::ipc_perm,
164-
#[cfg(target_endian = "big")]
215+
#[cfg(all(not(gnu_time_bits64), target_endian = "big"))]
165216
__glibc_reserved1: c_ulong,
166217
pub msg_stime: crate::time_t,
167-
#[cfg(target_endian = "little")]
218+
#[cfg(all(not(gnu_time_bits64), target_endian = "little"))]
168219
__glibc_reserved1: c_ulong,
169-
#[cfg(target_endian = "big")]
220+
#[cfg(all(not(gnu_time_bits64), target_endian = "big"))]
170221
__glibc_reserved2: c_ulong,
171222
pub msg_rtime: crate::time_t,
172-
#[cfg(target_endian = "little")]
223+
#[cfg(all(not(gnu_time_bits64), target_endian = "little"))]
173224
__glibc_reserved2: c_ulong,
174-
#[cfg(target_endian = "big")]
225+
#[cfg(all(not(gnu_time_bits64), target_endian = "big"))]
175226
__glibc_reserved3: c_ulong,
176227
pub msg_ctime: crate::time_t,
177228
#[cfg(target_endian = "little")]
178229
__glibc_reserved3: c_ulong,
179-
pub __msg_cbytes: c_ulong,
230+
__msg_cbytes: c_ulong,
180231
pub msg_qnum: crate::msgqnum_t,
181232
pub msg_qbytes: crate::msglen_t,
182233
pub msg_lspid: crate::pid_t,

0 commit comments

Comments
 (0)