Skip to content

Commit 9991e33

Browse files
committed
SCTP support for FreeBSD, NetBSD
Notification and log `union` types are exposed as partially-opaque structs for now, until libc targets a version of Rust which supports unions.
1 parent 7c1297c commit 9991e33

File tree

3 files changed

+2026
-2
lines changed

3 files changed

+2026
-2
lines changed

libc-test/build.rs

+32-2
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,12 @@ fn main() {
251251
if linux || android {
252252
cfg.header("sys/fsuid.h");
253253

254-
// DCCP support
255254
if !uclibc && !musl && !emscripten {
255+
// DCCP support
256256
cfg.header("linux/dccp.h");
257+
258+
// SCTP support
259+
//cfg.header("netinet/sctp.h");
257260
}
258261

259262
if !musl || mips {
@@ -275,6 +278,9 @@ fn main() {
275278
cfg.header("sys/ipc.h");
276279
cfg.header("sys/msg.h");
277280
cfg.header("sys/shm.h");
281+
282+
// SCTP support
283+
cfg.header("netinet/sctp.h");
278284
}
279285

280286
if netbsd {
@@ -284,6 +290,9 @@ fn main() {
284290

285291
// DCCP support
286292
cfg.header("netinet/dccp.h");
293+
294+
// SCTP support
295+
cfg.header("netinet/sctp.h");
287296
}
288297

289298
if openbsd {
@@ -369,6 +378,8 @@ fn main() {
369378
"type_" if linux &&
370379
(struct_ == "input_event" || struct_ == "input_mask" ||
371380
struct_ == "ff_effect") => "type".to_string(),
381+
"type_" if freebsd &&
382+
(struct_ == "sctp_error_missing_param") => "type".to_string(),
372383
s => s.to_string(),
373384
}
374385
});
@@ -378,6 +389,12 @@ fn main() {
378389
// sighandler_t is crazy across platforms
379390
"sighandler_t" => true,
380391

392+
// Temporarily skip the 'sctp_nets' type for FreeBSD,
393+
// it's currently just an alias for c_void since the true
394+
// type layout is very complex and it's only ever used
395+
// through a pointer (e.g. sctp_nets*).
396+
"sctp_nets" if freebsd => true,
397+
381398
_ => false
382399
}
383400
});
@@ -410,6 +427,9 @@ fn main() {
410427
// header conflicts when including them with all the other structs.
411428
"termios2" => true,
412429

430+
// This was added in FreeBSD 11
431+
"sctp_error_auth_invalid_hmac" if freebsd => true,
432+
413433
_ => false
414434
}
415435
});
@@ -480,6 +500,14 @@ fn main() {
480500
"HW_MAXID" |
481501
"USER_MAXID" if freebsd => true,
482502

503+
// These constants were added in FreeBSD 11.
504+
"SCTP_INTERLEAVING_SUPPORTED" |
505+
"SCTP_IDATA" |
506+
"SCTP_IFORWARD_CUM_TSN" |
507+
"SCTP_PR_SCTP_PRIO" |
508+
"SCTP_ASSOC_SUPPORTS_INTERLEAVING" |
509+
"SCTP_NOHEARTBEAT" if freebsd => true,
510+
483511
// These OSX constants are removed in Sierra.
484512
// https://developer.apple.com/library/content/releasenotes/General/APIDiffsMacOS10_12/Swift/Darwin.html
485513
"KERN_KDENABLE_BG_TRACE" if apple => true,
@@ -709,7 +737,9 @@ fn main() {
709737
// musl seems to define this as an *anonymous* bitfield
710738
(musl && struct_ == "statvfs" && field == "__f_unused") ||
711739
// sigev_notify_thread_id is actually part of a sigev_un union
712-
(struct_ == "sigevent" && field == "sigev_notify_thread_id")
740+
(struct_ == "sigevent" && field == "sigev_notify_thread_id") ||
741+
// Added in FreeBSD 11, which isn't yet supported by the libc CI
742+
(freebsd && struct_ == "sctp_error_missing_param" && field == "type")
713743
});
714744

715745
cfg.fn_cname(move |name, cname| {

0 commit comments

Comments
 (0)