Skip to content

Commit 0ad0aa6

Browse files
authored
Merge pull request #4299 from tammela/more-constants
linux: Add devmem constants and structs
2 parents 920f841 + 4985e60 commit 0ad0aa6

File tree

7 files changed

+110
-0
lines changed

7 files changed

+110
-0
lines changed

libc-test/build.rs

+31
Original file line numberDiff line numberDiff line change
@@ -4063,6 +4063,10 @@ fn test_linux(target: &str) {
40634063
// FIXME(linux): Requires >= 6.9 kernel headers.
40644064
"epoll_params" => true,
40654065

4066+
// FIXME(linux): Requires >= 6.12 kernel headers.
4067+
"dmabuf_cmsg" |
4068+
"dmabuf_token" => true,
4069+
40664070
_ => false,
40674071
}
40684072
});
@@ -4165,6 +4169,26 @@ fn test_linux(target: &str) {
41654169
{
41664170
return true;
41674171
}
4172+
// FIXME(musl): Not in musl yet
4173+
if name == "SO_NETNS_COOKIE"
4174+
|| name == "SO_BUF_LOCK"
4175+
|| name == "SO_RESERVE_MEM"
4176+
|| name == "SO_TXREHASH"
4177+
|| name == "SO_RCVMARK"
4178+
|| name == "SO_PASSPIDFD"
4179+
|| name == "SO_PEERPIDFD"
4180+
|| name == "SO_DEVMEM_LINEAR"
4181+
|| name == "SO_DEVMEM_DMABUF"
4182+
|| name == "SO_DEVMEM_DONTNEED"
4183+
{
4184+
return true;
4185+
}
4186+
// FIXME(musl): Not in musl yet
4187+
if name == "SCM_DEVMEM_LINEAR"
4188+
|| name == "SCM_DEVMEM_DMABUF"
4189+
{
4190+
return true;
4191+
}
41684192
}
41694193
match name {
41704194
// These constants are not available if gnu headers have been included
@@ -4461,6 +4485,13 @@ fn test_linux(target: &str) {
44614485
// FIXME(linux): Requires >= 6.12 kernel headers.
44624486
"SOF_TIMESTAMPING_OPT_RX_FILTER" => true,
44634487

4488+
// FIXME(linux): Requires >= 6.12 kernel headers.
4489+
"SO_DEVMEM_LINEAR"
4490+
| "SO_DEVMEM_DMABUF"
4491+
| "SO_DEVMEM_DONTNEED"
4492+
| "SCM_DEVMEM_LINEAR"
4493+
| "SCM_DEVMEM_DMABUF" => true,
4494+
44644495
_ => false,
44654496
}
44664497
});

libc-test/semver/linux.txt

+12
Original file line numberDiff line numberDiff line change
@@ -2648,6 +2648,8 @@ SCHED_OTHER
26482648
SCHED_RESET_ON_FORK
26492649
SCHED_RR
26502650
SCM_CREDENTIALS
2651+
SCM_DEVMEM_DMABUF
2652+
SCM_DEVMEM_LINEAR
26512653
SCM_J1939_DEST_ADDR
26522654
SCM_J1939_DEST_NAME
26532655
SCM_J1939_ERRQUEUE
@@ -2954,8 +2956,12 @@ SOL_X25
29542956
SOL_XDP
29552957
SOMAXCONN
29562958
SO_BINDTODEVICE
2959+
SO_BUF_LOCK
29572960
SO_BUSY_POLL
29582961
SO_BUSY_POLL_BUDGET
2962+
SO_DEVMEM_DMABUF
2963+
SO_DEVMEM_DONTNEED
2964+
SO_DEVMEM_LINEAR
29592965
SO_DOMAIN
29602966
SO_EE_OFFENDER
29612967
SO_EE_ORIGIN_ICMP
@@ -2969,20 +2975,26 @@ SO_J1939_FILTER
29692975
SO_J1939_PROMISC
29702976
SO_J1939_SEND_PRIO
29712977
SO_MARK
2978+
SO_NETNS_COOKIE
29722979
SO_ORIGINAL_DST
29732980
SO_PASSCRED
2981+
SO_PASSPIDFD
29742982
SO_PASSSEC
29752983
SO_PEEK_OFF
29762984
SO_PEERCRED
2985+
SO_PEERPIDFD
29772986
SO_PEERSEC
29782987
SO_PREFER_BUSY_POLL
29792988
SO_RCVBUFFORCE
2989+
SO_RCVMARK
2990+
SO_RESERVE_MEM
29802991
SO_REUSEPORT
29812992
SO_RXQ_OVFL
29822993
SO_SNDBUFFORCE
29832994
SO_TIMESTAMP
29842995
SO_TIMESTAMPING
29852996
SO_TIMESTAMPNS
2997+
SO_TXREHASH
29862998
SPLICE_F_GIFT
29872999
SPLICE_F_MORE
29883000
SPLICE_F_MOVE

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

+13
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ cfg_if! {
147147
}
148148
pub const SO_PREFER_BUSY_POLL: c_int = 69;
149149
pub const SO_BUSY_POLL_BUDGET: c_int = 70;
150+
pub const SO_NETNS_COOKIE: c_int = 71;
151+
pub const SO_BUF_LOCK: c_int = 72;
152+
pub const SO_RESERVE_MEM: c_int = 73;
153+
pub const SO_TXREHASH: c_int = 74;
154+
pub const SO_RCVMARK: c_int = 75;
155+
pub const SO_PASSPIDFD: c_int = 76;
156+
pub const SO_PEERPIDFD: c_int = 77;
157+
pub const SO_DEVMEM_LINEAR: c_int = 78;
158+
pub const SO_DEVMEM_DMABUF: c_int = 79;
159+
pub const SO_DEVMEM_DONTNEED: c_int = 80;
150160

151161
cfg_if! {
152162
if #[cfg(any(
@@ -169,6 +179,9 @@ cfg_if! {
169179
pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS;
170180
pub const SCM_TIMESTAMPING: c_int = SO_TIMESTAMPING;
171181

182+
pub const SCM_DEVMEM_LINEAR: c_int = SO_DEVMEM_LINEAR;
183+
pub const SCM_DEVMEM_DMABUF: c_int = SO_DEVMEM_DMABUF;
184+
172185
// Ioctl Constants
173186

174187
pub const TCGETS: Ioctl = 0x5401;

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

+13
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,16 @@ cfg_if! {
120120
// pub const SO_DETACH_REUSEPORT_BPF: c_int = 68;
121121
pub const SO_PREFER_BUSY_POLL: c_int = 69;
122122
pub const SO_BUSY_POLL_BUDGET: c_int = 70;
123+
pub const SO_NETNS_COOKIE: c_int = 71;
124+
pub const SO_BUF_LOCK: c_int = 72;
125+
pub const SO_RESERVE_MEM: c_int = 73;
126+
pub const SO_TXREHASH: c_int = 74;
127+
pub const SO_RCVMARK: c_int = 75;
128+
pub const SO_PASSPIDFD: c_int = 76;
129+
pub const SO_PEERPIDFD: c_int = 77;
130+
pub const SO_DEVMEM_LINEAR: c_int = 78;
131+
pub const SO_DEVMEM_DMABUF: c_int = 79;
132+
pub const SO_DEVMEM_DONTNEED: c_int = 80;
123133

124134
pub const FICLONE: c_ulong = 0x80049409;
125135
pub const FICLONERANGE: c_ulong = 0x8020940D;
@@ -129,6 +139,9 @@ pub const FICLONERANGE: c_ulong = 0x8020940D;
129139
pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS;
130140
pub const SCM_TIMESTAMPING: c_int = SO_TIMESTAMPING;
131141

142+
pub const SCM_DEVMEM_LINEAR: c_int = SO_DEVMEM_LINEAR;
143+
pub const SCM_DEVMEM_DMABUF: c_int = SO_DEVMEM_DMABUF;
144+
132145
// Ioctl Constants
133146

134147
pub const TCGETS: Ioctl = 0x540d;

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

+13
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ 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;
105+
pub const SO_NETNS_COOKIE: c_int = 71;
106+
pub const SO_BUF_LOCK: c_int = 72;
107+
pub const SO_RESERVE_MEM: c_int = 73;
108+
pub const SO_TXREHASH: c_int = 74;
109+
pub const SO_RCVMARK: c_int = 75;
110+
pub const SO_PASSPIDFD: c_int = 76;
111+
pub const SO_PEERPIDFD: c_int = 77;
112+
pub const SO_DEVMEM_LINEAR: c_int = 78;
113+
pub const SO_DEVMEM_DMABUF: c_int = 79;
114+
pub const SO_DEVMEM_DONTNEED: c_int = 80;
105115

106116
pub const FICLONE: c_ulong = 0x80049409;
107117
pub const FICLONERANGE: c_ulong = 0x8020940D;
@@ -111,6 +121,9 @@ pub const FICLONERANGE: c_ulong = 0x8020940D;
111121
pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS;
112122
pub const SCM_TIMESTAMPING: c_int = SO_TIMESTAMPING;
113123

124+
pub const SCM_DEVMEM_LINEAR: c_int = SO_DEVMEM_LINEAR;
125+
pub const SCM_DEVMEM_DMABUF: c_int = SO_DEVMEM_DMABUF;
126+
114127
// Ioctl Constants
115128

116129
cfg_if! {

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

+13
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,25 @@ pub const SO_TIMESTAMPING: c_int = 0x0023;
9797
// pub const SO_DETACH_REUSEPORT_BPF: c_int = 0x0047;
9898
pub const SO_PREFER_BUSY_POLL: c_int = 0x0048;
9999
pub const SO_BUSY_POLL_BUDGET: c_int = 0x0049;
100+
pub const SO_NETNS_COOKIE: c_int = 0x0050;
101+
pub const SO_BUF_LOCK: c_int = 0x0051;
102+
pub const SO_RESERVE_MEM: c_int = 0x0052;
103+
pub const SO_TXREHASH: c_int = 0x0053;
104+
pub const SO_RCVMARK: c_int = 0x0054;
105+
pub const SO_PASSPIDFD: c_int = 0x0055;
106+
pub const SO_PEERPIDFD: c_int = 0x0056;
107+
pub const SO_DEVMEM_LINEAR: c_int = 0x0057;
108+
pub const SO_DEVMEM_DMABUF: c_int = 0x0058;
109+
pub const SO_DEVMEM_DONTNEED: c_int = 0x0059;
100110

101111
// Defined in unix/linux_like/mod.rs
102112
// pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP;
103113
pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS;
104114
pub const SCM_TIMESTAMPING: c_int = SO_TIMESTAMPING;
105115

116+
pub const SCM_DEVMEM_LINEAR: c_int = SO_DEVMEM_LINEAR;
117+
pub const SCM_DEVMEM_DMABUF: c_int = SO_DEVMEM_DMABUF;
118+
106119
// Ioctl Constants
107120

108121
pub const TCGETS: Ioctl = 0x40245408;

src/unix/linux_like/linux/mod.rs

+15
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,21 @@ s! {
13201320
pub propagation: crate::__u64,
13211321
pub userns_fd: crate::__u64,
13221322
}
1323+
1324+
// linux/uio.h
1325+
1326+
pub struct dmabuf_cmsg {
1327+
pub frag_offset: crate::__u64,
1328+
pub frag_size: crate::__u32,
1329+
pub frag_token: crate::__u32,
1330+
pub dmabuf_id: crate::__u32,
1331+
pub flags: crate::__u32,
1332+
}
1333+
1334+
pub struct dmabuf_token {
1335+
pub token_start: crate::__u32,
1336+
pub token_count: crate::__u32,
1337+
}
13231338
}
13241339

13251340
cfg_if! {

0 commit comments

Comments
 (0)