Skip to content

Commit f679d3d

Browse files
committed
linux: add missing SOL_* constants
SOL_SOCKET appears to be the only constant that is not the same across architectures and it was already present in libc. The constants provided match bionic and the Linux kernel but are a supseret of those provided by musl and glibc. They are just constants, so it should be fine (and avoids upstream from having to define/maintain them). Signed-off-by: Paul Osborne <osbpau@gmail.com>
1 parent 722fedd commit f679d3d

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

libc-test/build.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ fn main() {
154154
if !musl {
155155
cfg.header("linux/netlink.h");
156156
cfg.header("linux/magic.h");
157+
cfg.header("netinet/udp.h");
158+
cfg.header("netipx/ipx.h");
159+
cfg.header("netax25/ax25.h");
160+
cfg.header("netatalk/at.h");
161+
cfg.header("netrose/rose.h");
162+
cfg.header("netrom/netrom.h");
157163

158164
if !mips {
159165
cfg.header("linux/quota.h");
@@ -289,6 +295,24 @@ fn main() {
289295
"FILE_ATTRIBUTE_INTEGRITY_STREAM" |
290296
"ERROR_NOTHING_TO_TERMINATE" if mingw => true,
291297

298+
// these are not in musl
299+
"SOL_NETLINK" |
300+
"SOL_UDP" |
301+
"SOL_AX25" |
302+
"SOL_ATALK" |
303+
"SOL_NETROM" |
304+
"SOL_IPX" |
305+
"SOL_ROSE" if musl => true,
306+
307+
// these are not in glibc or musl yet (but they are in android)
308+
"SOL_SCTP" |
309+
"SOL_UDPLITE" |
310+
"SOL_NETBEUI" |
311+
"SOL_LLC" |
312+
"SOL_DCCP" |
313+
"SOL_NETLINK" |
314+
"SOL_TIPC" if linux => true,
315+
292316
"SIG_IGN" => true, // sighandler_t weirdness
293317

294318
// types on musl are defined a little differently

src/unix/notbsd/linux/mod.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,31 @@ pub const ST_IMMUTABLE: ::c_ulong = 512;
308308
pub const ST_NOATIME: ::c_ulong = 1024;
309309
pub const ST_NODIRATIME: ::c_ulong = 2048;
310310

311+
pub const SOL_IP: ::c_int = 0;
312+
pub const SOL_TCP: ::c_int = 6;
313+
pub const SOL_UDP: ::c_int = 17;
314+
pub const SOL_IPV6: ::c_int = 41;
315+
pub const SOL_ICMPV6: ::c_int = 58;
316+
pub const SOL_SCTP: ::c_int = 132;
317+
pub const SOL_UDPLITE: ::c_int = 136;
318+
pub const SOL_RAW: ::c_int = 255;
319+
pub const SOL_IPX: ::c_int = 256;
320+
pub const SOL_AX25: ::c_int = 257;
321+
pub const SOL_ATALK: ::c_int = 258;
322+
pub const SOL_NETROM: ::c_int = 259;
323+
pub const SOL_ROSE: ::c_int = 260;
324+
pub const SOL_DECNET: ::c_int = 261;
325+
pub const SOL_X25: ::c_int = 262;
326+
pub const SOL_PACKET: ::c_int = 263;
327+
pub const SOL_ATM: ::c_int = 264;
328+
pub const SOL_AAL: ::c_int = 265;
329+
pub const SOL_IRDA: ::c_int = 266;
330+
pub const SOL_NETBEUI: ::c_int = 267;
331+
pub const SOL_LLC: ::c_int = 268;
332+
pub const SOL_DCCP: ::c_int = 269;
333+
pub const SOL_NETLINK: ::c_int = 270;
334+
pub const SOL_TIPC: ::c_int = 271;
335+
311336
pub const RTLD_NEXT: *mut ::c_void = -1i64 as *mut ::c_void;
312337
pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;
313338
pub const RTLD_NODELETE: ::c_int = 0x1000;

0 commit comments

Comments
 (0)