Skip to content

Commit a0f1ba9

Browse files
authored
Merge pull request #4242 from snogge/linux-time64-fixes
Fix missing SO_* values
2 parents 0141340 + b0e6878 commit a0f1ba9

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

build.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ fn main() {
4444
let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
4545
let libc_ci = env::var("LIBC_CI").is_ok();
4646
let libc_check_cfg = env::var("LIBC_CHECK_CFG").is_ok() || rustc_minor_ver >= 80;
47-
let linux_time_bits64 = env::var("RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64").is_ok();
4847

4948
// The ABI of libc used by std is backward compatible with FreeBSD 12.
5049
// The ABI of libc from crates.io is backward compatible with FreeBSD 12.
@@ -81,6 +80,8 @@ fn main() {
8180
Some(_) | None => (),
8281
}
8382

83+
let linux_time_bits64 = env::var("RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64").is_ok();
84+
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64");
8485
if linux_time_bits64 {
8586
set_cfg("linux_time_bits64");
8687
}

src/unix/linux_like/linux/arch/generic/mod.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,24 @@ const SO_TIMESTAMPING_OLD: c_int = 37;
5757
cfg_if! {
5858
if #[cfg(all(
5959
linux_time_bits64,
60-
any(target_arch = "arm", target_arch = "x86")
60+
any(target_arch = "arm", target_arch = "x86"),
61+
not(any(target_env = "musl", target_env = "ohos"))
6162
))] {
6263
pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_NEW;
6364
pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_NEW;
6465
pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_NEW;
6566
pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_NEW;
6667
pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_NEW;
68+
} else if #[cfg(all(
69+
linux_time_bits64,
70+
any(target_arch = "arm", target_arch = "x86"),
71+
any(target_env = "musl", target_env = "ohos")
72+
))] {
73+
pub const SO_TIMESTAMP: c_int = 63;
74+
pub const SO_TIMESTAMPNS: c_int = 64;
75+
pub const SO_TIMESTAMPING: c_int = 65;
76+
pub const SO_RCVTIMEO: c_int = 66;
77+
pub const SO_SNDTIMEO: c_int = 67;
6778
} else {
6879
pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_OLD;
6980
pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_OLD;
@@ -114,6 +125,7 @@ cfg_if! {
114125
any(
115126
target_arch = "x86",
116127
target_arch = "x86_64",
128+
target_arch = "arm",
117129
target_arch = "aarch64",
118130
target_arch = "csky",
119131
target_arch = "loongarch64"

src/unix/linux_like/linux/arch/mips/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,13 @@ pub const SO_BINDTOIFINDEX: c_int = 62;
9999
// but CI haven't support them yet.
100100
// Some related consts could be found in b32.rs and b64.rs
101101
const SO_TIMESTAMP_OLD: c_int = 29;
102+
const SO_RCVTIMEO_NEW: c_int = 66;
103+
const SO_SNDTIMEO_NEW: c_int = 67;
102104
const SO_TIMESTAMPNS_OLD: c_int = 35;
103105
const SO_TIMESTAMPING_OLD: c_int = 37;
106+
const SO_TIMESTAMP_NEW: c_int = 63;
107+
const SO_TIMESTAMPNS_NEW: c_int = 64;
108+
const SO_TIMESTAMPING_NEW: c_int = 65;
104109
cfg_if! {
105110
if #[cfg(linux_time_bits64)] {
106111
pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_NEW;

src/unix/linux_like/linux/arch/powerpc/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ pub const SO_ZEROCOPY: c_int = 60;
9494
pub const SO_TXTIME: c_int = 61;
9595
pub const SCM_TXTIME: c_int = SO_TXTIME;
9696
pub const SO_BINDTOIFINDEX: c_int = 62;
97-
// pub const SO_TIMESTAMP_NEW: c_int = 63;
98-
// pub const SO_TIMESTAMPNS_NEW: c_int = 64;
99-
// pub const SO_TIMESTAMPING_NEW: c_int = 65;
100-
// pub const SO_RCVTIMEO_NEW: c_int = 66;
101-
// pub const SO_SNDTIMEO_NEW: c_int = 67;
97+
const SO_TIMESTAMP_NEW: c_int = 63;
98+
const SO_TIMESTAMPNS_NEW: c_int = 64;
99+
const SO_TIMESTAMPING_NEW: c_int = 65;
100+
const SO_RCVTIMEO_NEW: c_int = 66;
101+
const SO_SNDTIMEO_NEW: c_int = 67;
102102
// pub const SO_DETACH_REUSEPORT_BPF: c_int = 68;
103103
// pub const SO_PREFER_BUSY_POLL: c_int = 69;
104104
// pub const SO_BUSY_POLL_BUDGET: c_int = 70;

0 commit comments

Comments
 (0)