Skip to content

Commit 3434230

Browse files
committed
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
1 parent f7b7942 commit 3434230

File tree

9 files changed

+74
-33
lines changed

9 files changed

+74
-33
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
@@ -2920,6 +2920,7 @@ SO_RXQ_OVFL
29202920
SO_SNDBUFFORCE
29212921
SO_TIMESTAMP
29222922
SO_TIMESTAMPING
2923+
SO_TIMESTAMPNS
29232924
SPLICE_F_GIFT
29242925
SPLICE_F_MORE
29252926
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
@@ -37,10 +37,8 @@ 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;
40+
const SO_RCVTIMEO_OLD: ::c_int = 20;
41+
const SO_SNDTIMEO_OLD: ::c_int = 21;
4442
pub const SO_SECURITY_AUTHENTICATION: ::c_int = 22;
4543
pub const SO_SECURITY_ENCRYPTION_TRANSPORT: ::c_int = 23;
4644
pub const SO_SECURITY_ENCRYPTION_NETWORK: ::c_int = 24;
@@ -49,18 +47,35 @@ pub const SO_ATTACH_FILTER: ::c_int = 26;
4947
pub const SO_DETACH_FILTER: ::c_int = 27;
5048
pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER;
5149
pub const SO_PEERNAME: ::c_int = 28;
52-
pub const SO_TIMESTAMP: ::c_int = 29;
53-
// pub const SO_TIMESTAMP_OLD: ::c_int = 29;
50+
const SO_TIMESTAMP_OLD: ::c_int = 29;
51+
const SO_TIMESTAMPNS_OLD: ::c_int = 35;
52+
const SO_TIMESTAMPING_OLD: ::c_int = 37;
53+
54+
cfg_if! {
55+
if #[cfg(all(
56+
linux_time_bits64,
57+
any(target_arch = "arm", target_arch = "x86")
58+
))] {
59+
pub const SO_TIMESTAMP: ::c_int = SO_TIMESTAMP_NEW;
60+
pub const SO_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS_NEW;
61+
pub const SO_TIMESTAMPING: ::c_int = SO_TIMESTAMPING_NEW;
62+
pub const SO_RCVTIMEO: ::c_int = SO_RCVTIMEO_NEW;
63+
pub const SO_SNDTIMEO: ::c_int = SO_SNDTIMEO_NEW;
64+
} else {
65+
pub const SO_TIMESTAMP: ::c_int = SO_TIMESTAMP_OLD;
66+
pub const SO_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS_OLD;
67+
pub const SO_TIMESTAMPING: ::c_int = SO_TIMESTAMPING_OLD;
68+
pub const SO_RCVTIMEO: ::c_int = SO_RCVTIMEO_OLD;
69+
pub const SO_SNDTIMEO: ::c_int = SO_SNDTIMEO_OLD;
70+
}
71+
}
72+
5473
pub const SO_ACCEPTCONN: ::c_int = 30;
5574
pub const SO_PEERSEC: ::c_int = 31;
5675
pub const SO_SNDBUFFORCE: ::c_int = 32;
5776
pub const SO_RCVBUFFORCE: ::c_int = 33;
5877
pub const SO_PASSSEC: ::c_int = 34;
59-
pub const SO_TIMESTAMPNS: ::c_int = 35;
60-
// pub const SO_TIMESTAMPNS_OLD: ::c_int = 35;
6178
pub const SO_MARK: ::c_int = 36;
62-
pub const SO_TIMESTAMPING: ::c_int = 37;
63-
// pub const SO_TIMESTAMPING_OLD: ::c_int = 37;
6479
pub const SO_PROTOCOL: ::c_int = 38;
6580
pub const SO_DOMAIN: ::c_int = 39;
6681
pub const SO_RXQ_OVFL: ::c_int = 40;

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

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,17 @@ 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;
38-
// pub const SO_SNDTIMEO_OLD: ::c_int = 0x1005;
39-
// pub const SO_RCVTIMEO_OLD: ::c_int = 0x1006;
36+
const SO_SNDTIMEO_OLD: ::c_int = 0x1005;
37+
const SO_RCVTIMEO_OLD: ::c_int = 0x1006;
38+
cfg_if! {
39+
if #[cfg(linux_time_bits64)] {
40+
pub const SO_SNDTIMEO: ::c_int = SO_SNDTIMEO_NEW;
41+
pub const SO_RCVTIMEO: ::c_int = SO_RCVTIMEO_NEW;
42+
} else {
43+
pub const SO_SNDTIMEO: ::c_int = SO_SNDTIMEO_OLD;
44+
pub const SO_RCVTIMEO: ::c_int = SO_RCVTIMEO_OLD;
45+
}
46+
}
4047
pub const SO_ACCEPTCONN: ::c_int = 0x1009;
4148
pub const SO_PROTOCOL: ::c_int = 0x1028;
4249
pub const SO_DOMAIN: ::c_int = 0x1029;
@@ -88,12 +95,20 @@ 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;
94-
// pub const SO_TIMESTAMP_OLD: ::c_int = 29;
95-
// pub const SO_TIMESTAMPNS_OLD: ::c_int = 35;
96-
// pub const SO_TIMESTAMPING_OLD: ::c_int = 37;
98+
const SO_TIMESTAMP_OLD: ::c_int = 29;
99+
const SO_TIMESTAMPNS_OLD: ::c_int = 35;
100+
const SO_TIMESTAMPING_OLD: ::c_int = 37;
101+
cfg_if! {
102+
if #[cfg(linux_time_bits64)] {
103+
pub const SO_TIMESTAMP: ::c_int = SO_TIMESTAMP_NEW;
104+
pub const SO_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS_NEW;
105+
pub const SO_TIMESTAMPING: ::c_int = SO_TIMESTAMPING_NEW;
106+
} else {
107+
pub const SO_TIMESTAMP: ::c_int = SO_TIMESTAMP_OLD;
108+
pub const SO_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS_OLD;
109+
pub const SO_TIMESTAMPING: ::c_int = SO_TIMESTAMPING_OLD;
110+
}
111+
}
97112
// pub const SO_TIMESTAMP_NEW: ::c_int = 63;
98113
// pub const SO_TIMESTAMPNS_NEW: ::c_int = 64;
99114
// pub const SO_TIMESTAMPING_NEW: ::c_int = 65;

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

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,15 @@ 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(linux_time_bits64)] {
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;
2835
pub const SO_PASSCRED: ::c_int = 20;
@@ -36,18 +43,26 @@ pub const SO_ATTACH_FILTER: ::c_int = 26;
3643
pub const SO_DETACH_FILTER: ::c_int = 27;
3744
pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER;
3845
pub const SO_PEERNAME: ::c_int = 28;
39-
pub const SO_TIMESTAMP: ::c_int = 29;
40-
// pub const SO_TIMESTAMP_OLD: ::c_int = 29;
46+
cfg_if! {
47+
if #[cfg(linux_time_bits64)] {
48+
pub const SO_TIMESTAMP: ::c_int = SO_TIMESTAMP_NEW;
49+
pub const SO_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS_NEW;
50+
pub const SO_TIMESTAMPING: ::c_int = SO_TIMESTAMPING_NEW;
51+
} else {
52+
pub const SO_TIMESTAMP: ::c_int = SO_TIMESTAMP_OLD;
53+
pub const SO_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS_OLD;
54+
pub const SO_TIMESTAMPING: ::c_int = SO_TIMESTAMPING_OLD;
55+
}
56+
}
57+
const SO_TIMESTAMP_OLD: ::c_int = 29;
58+
const SO_TIMESTAMPNS_OLD: ::c_int = 35;
59+
const SO_TIMESTAMPING_OLD: ::c_int = 37;
4160
pub const SO_ACCEPTCONN: ::c_int = 30;
4261
pub const SO_PEERSEC: ::c_int = 31;
4362
pub const SO_SNDBUFFORCE: ::c_int = 32;
4463
pub const SO_RCVBUFFORCE: ::c_int = 33;
4564
pub const SO_PASSSEC: ::c_int = 34;
46-
pub const SO_TIMESTAMPNS: ::c_int = 35;
47-
// pub const SO_TIMESTAMPNS_OLD: ::c_int = 35;
4865
pub const SO_MARK: ::c_int = 36;
49-
pub const SO_TIMESTAMPING: ::c_int = 37;
50-
// pub const SO_TIMESTAMPING_OLD: ::c_int = 37;
5166
pub const SO_PROTOCOL: ::c_int = 38;
5267
pub const SO_DOMAIN: ::c_int = 39;
5368
pub const SO_RXQ_OVFL: ::c_int = 40;

0 commit comments

Comments
 (0)