Skip to content

Commit f5b5425

Browse files
committed
Set SO_TIMESTAMP* and SO_RCVTIMEO and SO_SNDTIMEO
1 parent 599fd27 commit f5b5425

File tree

3 files changed

+79
-23
lines changed

3 files changed

+79
-23
lines changed

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

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ pub const SO_PASSCRED: ::c_int = 16;
3737
pub const SO_PEERCRED: ::c_int = 17;
3838
pub const SO_RCVLOWAT: ::c_int = 18;
3939
pub const SO_SNDLOWAT: ::c_int = 19;
40-
pub const SO_RCVTIMEO: ::c_int = 20;
41-
pub const SO_SNDTIMEO: ::c_int = 21;
42-
// pub const SO_RCVTIMEO_OLD: ::c_int = 20;
43-
// pub const SO_SNDTIMEO_OLD: ::c_int = 21;
4440
pub const SO_SECURITY_AUTHENTICATION: ::c_int = 22;
4541
pub const SO_SECURITY_ENCRYPTION_TRANSPORT: ::c_int = 23;
4642
pub const SO_SECURITY_ENCRYPTION_NETWORK: ::c_int = 24;
@@ -49,18 +45,41 @@ pub const SO_ATTACH_FILTER: ::c_int = 26;
4945
pub const SO_DETACH_FILTER: ::c_int = 27;
5046
pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER;
5147
pub const SO_PEERNAME: ::c_int = 28;
52-
pub const SO_TIMESTAMP: ::c_int = 29;
53-
// pub const SO_TIMESTAMP_OLD: ::c_int = 29;
48+
49+
cfg_if! {
50+
if #[cfg(all(target_env = "gnu",
51+
target_pointer_width = "32",
52+
any(target_arch = "arm", target_arch = "x86")))] {
53+
pub const SO_TIMESTAMP: ::c_int = SO_TIMESTAMP_NEW;
54+
pub const SO_TIMESTAMP_OLD: ::c_int = 29;
55+
pub const SO_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS_NEW;
56+
pub const SO_TIMESTAMPNS_OLD: ::c_int = 35;
57+
pub const SO_TIMESTAMPING: ::c_int = SO_TIMESTAMPING_NEW;
58+
pub const SO_TIMESTAMPING_OLD: ::c_int = 37;
59+
pub const SO_RCVTIMEO: ::c_int = SO_RCVTIMEO_NEW;
60+
pub const SO_SNDTIMEO: ::c_int = SO_SNDTIMEO_NEW;
61+
pub const SO_RCVTIMEO_OLD: ::c_int = 20;
62+
pub const SO_SNDTIMEO_OLD: ::c_int = 21;
63+
} else {
64+
pub const SO_TIMESTAMP: ::c_int = 29;
65+
// pub const SO_TIMESTAMP_OLD: ::c_int = 29;
66+
pub const SO_TIMESTAMPNS: ::c_int = 35;
67+
// pub const SO_TIMESTAMPNS_OLD: ::c_int = 35;
68+
pub const SO_TIMESTAMPING: ::c_int = 37;
69+
// pub const SO_TIMESTAMPING_OLD: ::c_int = 37;
70+
pub const SO_RCVTIMEO: ::c_int = 20;
71+
pub const SO_SNDTIMEO: ::c_int = 21;
72+
// pub const SO_RCVTIMEO_OLD: ::c_int = 20;
73+
// pub const SO_SNDTIMEO_OLD: ::c_int = 21;
74+
}
75+
}
76+
5477
pub const SO_ACCEPTCONN: ::c_int = 30;
5578
pub const SO_PEERSEC: ::c_int = 31;
5679
pub const SO_SNDBUFFORCE: ::c_int = 32;
5780
pub const SO_RCVBUFFORCE: ::c_int = 33;
5881
pub const SO_PASSSEC: ::c_int = 34;
59-
pub const SO_TIMESTAMPNS: ::c_int = 35;
60-
// pub const SO_TIMESTAMPNS_OLD: ::c_int = 35;
6182
pub const SO_MARK: ::c_int = 36;
62-
pub const SO_TIMESTAMPING: ::c_int = 37;
63-
// pub const SO_TIMESTAMPING_OLD: ::c_int = 37;
6483
pub const SO_PROTOCOL: ::c_int = 38;
6584
pub const SO_DOMAIN: ::c_int = 39;
6685
pub const SO_RXQ_OVFL: ::c_int = 40;
@@ -94,7 +113,9 @@ cfg_if! {
94113
// But they may still not have those _OLD ones.
95114
if #[cfg(all(any(target_arch = "x86",
96115
target_arch = "x86_64",
97-
target_arch = "aarch64"),
116+
target_arch = "aarch64",
117+
target_arch = "arm",
118+
target_arch = "i686"),
98119
not(any(target_env = "musl", target_env = "ohos"))))] {
99120
pub const SO_TIMESTAMP_NEW: ::c_int = 63;
100121
pub const SO_TIMESTAMPNS_NEW: ::c_int = 64;

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

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,15 @@ pub const SO_RCVLOWAT: ::c_int = 0x1004;
3333
// NOTE: These definitions are now being renamed with _OLD postfix,
3434
// but CI haven't support them yet.
3535
// Some related consts could be found in b32.rs and b64.rs
36-
pub const SO_SNDTIMEO: ::c_int = 0x1005;
37-
pub const SO_RCVTIMEO: ::c_int = 0x1006;
36+
cfg_if! {
37+
if #[cfg(target_env = "gnu")] {
38+
pub const SO_SNDTIMEO: ::c_int = 67;
39+
pub const SO_RCVTIMEO: ::c_int = 66;
40+
} else {
41+
pub const SO_SNDTIMEO: ::c_int = 0x1005;
42+
pub const SO_RCVTIMEO: ::c_int = 0x1006;
43+
}
44+
}
3845
// pub const SO_SNDTIMEO_OLD: ::c_int = 0x1005;
3946
// pub const SO_RCVTIMEO_OLD: ::c_int = 0x1006;
4047
pub const SO_ACCEPTCONN: ::c_int = 0x1009;
@@ -88,9 +95,17 @@ pub const SO_BINDTOIFINDEX: ::c_int = 62;
8895
// NOTE: These definitions are now being renamed with _OLD postfix,
8996
// but CI haven't support them yet.
9097
// Some related consts could be found in b32.rs and b64.rs
91-
pub const SO_TIMESTAMP: ::c_int = 29;
92-
pub const SO_TIMESTAMPNS: ::c_int = 35;
93-
pub const SO_TIMESTAMPING: ::c_int = 37;
98+
cfg_if! {
99+
if #[cfg(target_env = "gnu")] {
100+
pub const SO_TIMESTAMP: ::c_int = 63;
101+
pub const SO_TIMESTAMPNS: ::c_int = 64;
102+
pub const SO_TIMESTAMPING: ::c_int = 65;
103+
} else {
104+
pub const SO_TIMESTAMP: ::c_int = 29;
105+
pub const SO_TIMESTAMPNS: ::c_int = 35;
106+
pub const SO_TIMESTAMPING: ::c_int = 37;
107+
}
108+
}
94109
// pub const SO_TIMESTAMP_OLD: ::c_int = 29;
95110
// pub const SO_TIMESTAMPNS_OLD: ::c_int = 35;
96111
// pub const SO_TIMESTAMPING_OLD: ::c_int = 37;

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

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,19 @@ pub const SO_REUSEPORT: ::c_int = 15;
2121
// powerpc only differs in these
2222
pub const SO_RCVLOWAT: ::c_int = 16;
2323
pub const SO_SNDLOWAT: ::c_int = 17;
24-
pub const SO_RCVTIMEO: ::c_int = 18;
25-
pub const SO_SNDTIMEO: ::c_int = 19;
24+
cfg_if! {
25+
if #[cfg(all(target_env = "gnu", target_pointer_width = "32"))] {
26+
pub const SO_SNDTIMEO: ::c_int = 67;
27+
pub const SO_RCVTIMEO: ::c_int = 66;
28+
} else {
29+
pub const SO_SNDTIMEO: ::c_int = 19;
30+
pub const SO_RCVTIMEO: ::c_int = 18;
31+
}
32+
}
2633
// pub const SO_RCVTIMEO_OLD: ::c_int = 18;
2734
// pub const SO_SNDTIMEO_OLD: ::c_int = 19;
35+
// pub const SO_RCVTIMEO_NEW: ::c_int = 66;
36+
// pub const SO_SNDTIMEO_NEW: ::c_int = 67;
2837
pub const SO_PASSCRED: ::c_int = 20;
2938
pub const SO_PEERCRED: ::c_int = 21;
3039
// end
@@ -36,18 +45,29 @@ pub const SO_ATTACH_FILTER: ::c_int = 26;
3645
pub const SO_DETACH_FILTER: ::c_int = 27;
3746
pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER;
3847
pub const SO_PEERNAME: ::c_int = 28;
39-
pub const SO_TIMESTAMP: ::c_int = 29;
48+
cfg_if! {
49+
if #[cfg(all(target_env = "gnu", target_pointer_width = "32"))] {
50+
pub const SO_TIMESTAMP: ::c_int = 63;
51+
pub const SO_TIMESTAMPNS: ::c_int = 64;
52+
pub const SO_TIMESTAMPING: ::c_int = 65;
53+
} else {
54+
pub const SO_TIMESTAMP: ::c_int = 29;
55+
pub const SO_TIMESTAMPNS: ::c_int = 35;
56+
pub const SO_TIMESTAMPING: ::c_int = 37;
57+
}
58+
}
59+
// pub const SO_TIMESTAMP_NEW: ::c_int = 63;
4060
// pub const SO_TIMESTAMP_OLD: ::c_int = 29;
61+
// pub const SO_TIMESTAMPNS_NEW: ::c_int = 64;
62+
// pub const SO_TIMESTAMPNS_OLD: ::c_int = 35;
63+
// pub const SO_TIMESTAMPING_NEW: ::c_int = 65;
64+
// pub const SO_TIMESTAMPING_OLD: ::c_int = 37;
4165
pub const SO_ACCEPTCONN: ::c_int = 30;
4266
pub const SO_PEERSEC: ::c_int = 31;
4367
pub const SO_SNDBUFFORCE: ::c_int = 32;
4468
pub const SO_RCVBUFFORCE: ::c_int = 33;
4569
pub const SO_PASSSEC: ::c_int = 34;
46-
pub const SO_TIMESTAMPNS: ::c_int = 35;
47-
// pub const SO_TIMESTAMPNS_OLD: ::c_int = 35;
4870
pub const SO_MARK: ::c_int = 36;
49-
pub const SO_TIMESTAMPING: ::c_int = 37;
50-
// pub const SO_TIMESTAMPING_OLD: ::c_int = 37;
5171
pub const SO_PROTOCOL: ::c_int = 38;
5272
pub const SO_DOMAIN: ::c_int = 39;
5373
pub const SO_RXQ_OVFL: ::c_int = 40;

0 commit comments

Comments
 (0)