Skip to content

Commit 4134091

Browse files
snoggetgross35
authored andcommitted
linux: Set SO_TIMESTAMP* and SO_RCVTIMEO and SO_SNDTIMEO
The actual values may be different on 32bit archs with and without __USE_TIME_BITS64 (backport <rust-lang#4148>) (cherry picked from commit 616d546)
1 parent 11079fd commit 4134091

File tree

9 files changed

+74
-38
lines changed

9 files changed

+74
-38
lines changed

libc-test/semver/TODO-linux.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ SO_SELECT_ERR_QUEUE
5454
SO_SNDTIMEO_NEW
5555
SO_STYLE
5656
SO_TIMESTAMPING_NEW
57-
SO_TIMESTAMPNS
5857
SO_TIMESTAMPNS_NEW
5958
SO_TIMESTAMP_NEW
6059
SO_TXTIME

libc-test/semver/linux-loongarch64.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ SO_SECURITY_AUTHENTICATION
8787
SO_SECURITY_ENCRYPTION_NETWORK
8888
SO_SECURITY_ENCRYPTION_TRANSPORT
8989
SO_SELECT_ERR_QUEUE
90-
SO_TIMESTAMPNS
9190
SO_WIFI_STATUS
9291
SYS_accept
9392
SYS_msgctl

libc-test/semver/linux-powerpc64.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ SO_SECURITY_AUTHENTICATION
4848
SO_SECURITY_ENCRYPTION_NETWORK
4949
SO_SECURITY_ENCRYPTION_TRANSPORT
5050
SO_SELECT_ERR_QUEUE
51-
SO_TIMESTAMPNS
5251
SO_WIFI_STATUS
5352
SYS__llseek
5453
SYS__newselect

libc-test/semver/linux-powerpc64le.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ SO_SECURITY_AUTHENTICATION
4646
SO_SECURITY_ENCRYPTION_NETWORK
4747
SO_SECURITY_ENCRYPTION_TRANSPORT
4848
SO_SELECT_ERR_QUEUE
49-
SO_TIMESTAMPNS
5049
SO_WIFI_STATUS
5150
SYS__llseek
5251
SYS__newselect

libc-test/semver/linux-riscv64gc.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ SO_SECURITY_AUTHENTICATION
5151
SO_SECURITY_ENCRYPTION_NETWORK
5252
SO_SECURITY_ENCRYPTION_TRANSPORT
5353
SO_SELECT_ERR_QUEUE
54-
SO_TIMESTAMPNS
5554
SO_WIFI_STATUS
5655
SYS_accept
5756
SYS_fadvise64

libc-test/semver/linux.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2964,6 +2964,7 @@ SO_RXQ_OVFL
29642964
SO_SNDBUFFORCE
29652965
SO_TIMESTAMP
29662966
SO_TIMESTAMPING
2967+
SO_TIMESTAMPNS
29672968
SPLICE_F_GIFT
29682969
SPLICE_F_MORE
29692970
SPLICE_F_MOVE

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

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ pub const SO_PASSCRED: c_int = 16;
4040
pub const SO_PEERCRED: c_int = 17;
4141
pub const SO_RCVLOWAT: c_int = 18;
4242
pub const SO_SNDLOWAT: c_int = 19;
43-
pub const SO_RCVTIMEO: c_int = 20;
44-
pub const SO_SNDTIMEO: c_int = 21;
45-
// pub const SO_RCVTIMEO_OLD: c_int = 20;
46-
// pub const SO_SNDTIMEO_OLD: c_int = 21;
43+
const SO_RCVTIMEO_OLD: c_int = 20;
44+
const SO_SNDTIMEO_OLD: c_int = 21;
4745
pub const SO_SECURITY_AUTHENTICATION: c_int = 22;
4846
pub const SO_SECURITY_ENCRYPTION_TRANSPORT: c_int = 23;
4947
pub const SO_SECURITY_ENCRYPTION_NETWORK: c_int = 24;
@@ -52,18 +50,35 @@ pub const SO_ATTACH_FILTER: c_int = 26;
5250
pub const SO_DETACH_FILTER: c_int = 27;
5351
pub const SO_GET_FILTER: c_int = SO_ATTACH_FILTER;
5452
pub const SO_PEERNAME: c_int = 28;
55-
pub const SO_TIMESTAMP: c_int = 29;
56-
// pub const SO_TIMESTAMP_OLD: c_int = 29;
53+
const SO_TIMESTAMP_OLD: c_int = 29;
54+
const SO_TIMESTAMPNS_OLD: c_int = 35;
55+
const SO_TIMESTAMPING_OLD: c_int = 37;
56+
57+
cfg_if! {
58+
if #[cfg(all(
59+
linux_time_bits64,
60+
any(target_arch = "arm", target_arch = "x86")
61+
))] {
62+
pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_NEW;
63+
pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_NEW;
64+
pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_NEW;
65+
pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_NEW;
66+
pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_NEW;
67+
} else {
68+
pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_OLD;
69+
pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_OLD;
70+
pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_OLD;
71+
pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_OLD;
72+
pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_OLD;
73+
}
74+
}
75+
5776
pub const SO_ACCEPTCONN: c_int = 30;
5877
pub const SO_PEERSEC: c_int = 31;
5978
pub const SO_SNDBUFFORCE: c_int = 32;
6079
pub const SO_RCVBUFFORCE: c_int = 33;
6180
pub const SO_PASSSEC: c_int = 34;
62-
pub const SO_TIMESTAMPNS: c_int = 35;
63-
// pub const SO_TIMESTAMPNS_OLD: c_int = 35;
6481
pub const SO_MARK: c_int = 36;
65-
pub const SO_TIMESTAMPING: c_int = 37;
66-
// pub const SO_TIMESTAMPING_OLD: c_int = 37;
6782
pub const SO_PROTOCOL: c_int = 38;
6883
pub const SO_DOMAIN: c_int = 39;
6984
pub const SO_RXQ_OVFL: c_int = 40;

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

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,17 @@ pub const SO_RCVLOWAT: c_int = 0x1004;
3636
// NOTE: These definitions are now being renamed with _OLD postfix,
3737
// but CI haven't support them yet.
3838
// Some related consts could be found in b32.rs and b64.rs
39-
pub const SO_SNDTIMEO: c_int = 0x1005;
40-
pub const SO_RCVTIMEO: c_int = 0x1006;
41-
// pub const SO_SNDTIMEO_OLD: c_int = 0x1005;
42-
// pub const SO_RCVTIMEO_OLD: c_int = 0x1006;
39+
const SO_SNDTIMEO_OLD: c_int = 0x1005;
40+
const SO_RCVTIMEO_OLD: c_int = 0x1006;
41+
cfg_if! {
42+
if #[cfg(linux_time_bits64)] {
43+
pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_NEW;
44+
pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_NEW;
45+
} else {
46+
pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_OLD;
47+
pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_OLD;
48+
}
49+
}
4350
pub const SO_ACCEPTCONN: c_int = 0x1009;
4451
pub const SO_PROTOCOL: c_int = 0x1028;
4552
pub const SO_DOMAIN: c_int = 0x1029;
@@ -91,17 +98,20 @@ pub const SO_BINDTOIFINDEX: c_int = 62;
9198
// NOTE: These definitions are now being renamed with _OLD postfix,
9299
// but CI haven't support them yet.
93100
// Some related consts could be found in b32.rs and b64.rs
94-
pub const SO_TIMESTAMP: c_int = 29;
95-
pub const SO_TIMESTAMPNS: c_int = 35;
96-
pub const SO_TIMESTAMPING: c_int = 37;
97-
// pub const SO_TIMESTAMP_OLD: c_int = 29;
98-
// pub const SO_TIMESTAMPNS_OLD: c_int = 35;
99-
// pub const SO_TIMESTAMPING_OLD: c_int = 37;
100-
// pub const SO_TIMESTAMP_NEW: c_int = 63;
101-
// pub const SO_TIMESTAMPNS_NEW: c_int = 64;
102-
// pub const SO_TIMESTAMPING_NEW: c_int = 65;
103-
// pub const SO_RCVTIMEO_NEW: c_int = 66;
104-
// pub const SO_SNDTIMEO_NEW: c_int = 67;
101+
const SO_TIMESTAMP_OLD: c_int = 29;
102+
const SO_TIMESTAMPNS_OLD: c_int = 35;
103+
const SO_TIMESTAMPING_OLD: c_int = 37;
104+
cfg_if! {
105+
if #[cfg(linux_time_bits64)] {
106+
pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_NEW;
107+
pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_NEW;
108+
pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_NEW;
109+
} else {
110+
pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_OLD;
111+
pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_OLD;
112+
pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_OLD;
113+
}
114+
}
105115
// pub const SO_DETACH_REUSEPORT_BPF: c_int = 68;
106116
// pub const SO_PREFER_BUSY_POLL: c_int = 69;
107117
// pub const SO_BUSY_POLL_BUDGET: c_int = 70;

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

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,15 @@ pub const SO_REUSEPORT: c_int = 15;
2424
// powerpc only differs in these
2525
pub const SO_RCVLOWAT: c_int = 16;
2626
pub const SO_SNDLOWAT: c_int = 17;
27-
pub const SO_RCVTIMEO: c_int = 18;
28-
pub const SO_SNDTIMEO: c_int = 19;
27+
cfg_if! {
28+
if #[cfg(linux_time_bits64)] {
29+
pub const SO_SNDTIMEO: c_int = 67;
30+
pub const SO_RCVTIMEO: c_int = 66;
31+
} else {
32+
pub const SO_SNDTIMEO: c_int = 19;
33+
pub const SO_RCVTIMEO: c_int = 18;
34+
}
35+
}
2936
// pub const SO_RCVTIMEO_OLD: c_int = 18;
3037
// pub const SO_SNDTIMEO_OLD: c_int = 19;
3138
pub const SO_PASSCRED: c_int = 20;
@@ -39,18 +46,26 @@ pub const SO_ATTACH_FILTER: c_int = 26;
3946
pub const SO_DETACH_FILTER: c_int = 27;
4047
pub const SO_GET_FILTER: c_int = SO_ATTACH_FILTER;
4148
pub const SO_PEERNAME: c_int = 28;
42-
pub const SO_TIMESTAMP: c_int = 29;
43-
// pub const SO_TIMESTAMP_OLD: c_int = 29;
49+
cfg_if! {
50+
if #[cfg(linux_time_bits64)] {
51+
pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_NEW;
52+
pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_NEW;
53+
pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_NEW;
54+
} else {
55+
pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_OLD;
56+
pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_OLD;
57+
pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_OLD;
58+
}
59+
}
60+
const SO_TIMESTAMP_OLD: c_int = 29;
61+
const SO_TIMESTAMPNS_OLD: c_int = 35;
62+
const SO_TIMESTAMPING_OLD: c_int = 37;
4463
pub const SO_ACCEPTCONN: c_int = 30;
4564
pub const SO_PEERSEC: c_int = 31;
4665
pub const SO_SNDBUFFORCE: c_int = 32;
4766
pub const SO_RCVBUFFORCE: c_int = 33;
4867
pub const SO_PASSSEC: c_int = 34;
49-
pub const SO_TIMESTAMPNS: c_int = 35;
50-
// pub const SO_TIMESTAMPNS_OLD: c_int = 35;
5168
pub const SO_MARK: c_int = 36;
52-
pub const SO_TIMESTAMPING: c_int = 37;
53-
// pub const SO_TIMESTAMPING_OLD: c_int = 37;
5469
pub const SO_PROTOCOL: c_int = 38;
5570
pub const SO_DOMAIN: c_int = 39;
5671
pub const SO_RXQ_OVFL: c_int = 40;

0 commit comments

Comments
 (0)