Skip to content

Commit

Permalink
Add devstat items
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Dec 1, 2021
1 parent ddc070c commit c4de1bc
Show file tree
Hide file tree
Showing 2 changed files with 431 additions and 3 deletions.
39 changes: 36 additions & 3 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1877,6 +1877,7 @@ fn test_freebsd(target: &str) {
"sys/vmmeter.h",
"sys/wait.h",
"libprocstat.h",
"devstat.h",
"syslog.h",
"termios.h",
"time.h",
Expand All @@ -1890,8 +1891,19 @@ fn test_freebsd(target: &str) {
cfg.type_name(move |ty, is_struct, is_union| {
match ty {
// Just pass all these through, no need for a "struct" prefix
"FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" | "Elf64_Phdr"
| "Elf32_Auxinfo" | "Elf64_Auxinfo" => ty.to_string(),
"FILE"
| "fd_set"
| "Dl_info"
| "DIR"
| "Elf32_Phdr"
| "Elf64_Phdr"
| "Elf32_Auxinfo"
| "Elf64_Auxinfo"
| "devstat_select_mode"
| "devstat_support_flags"
| "devstat_type_flags"
| "devstat_match_flags"
| "devstat_priority" => ty.to_string(),

// FIXME: https://github.com/rust-lang/libc/issues/1273
"sighandler_t" => "sig_t".to_string(),
Expand Down Expand Up @@ -1919,7 +1931,9 @@ fn test_freebsd(target: &str) {
}
// Field is named `type` in C but that is a Rust keyword,
// so these fields are translated to `type_` in the bindings.
"type_" if struct_ == "rtprio" || struct_ == "sockstat" => "type".to_string(),
"type_" if struct_ == "rtprio" => "type".to_string(),
"type_" if struct_ == "sockstat" => "type".to_string(),
"type_" if struct_ == "devstat_match_table" => "type".to_string(),
s => s.to_string(),
}
});
Expand Down Expand Up @@ -2149,6 +2163,10 @@ fn test_freebsd(target: &str) {
// for now, it doesn't matter too much...
"kvm_t" => true,

// The C norm is a nightmare to follow for `long double`. Its sized is checked since
// it's being used as a struct field type in any case.
"c_longdouble" => true,

_ => false,
}
});
Expand Down Expand Up @@ -2176,6 +2194,9 @@ fn test_freebsd(target: &str) {
// `ptrace_coredump` introduced in FreeBSD 14.
"ptrace_coredump" if Some(14) > freebsd_ver => true,

// A wrapper around "long double".
"LongDoubleWrap" => true,

_ => false,
}
});
Expand Down Expand Up @@ -2206,6 +2227,10 @@ fn test_freebsd(target: &str) {
// https://github.com/gnzlbg/ctest/issues/68
"lio_listio" => true,

// It returns a `long double`, but it's a nightmare to bind correctly in rust
// for the moment, so it's a best effort thing...
"devstat_compute_etime" => true,

_ => false,
}
});
Expand Down Expand Up @@ -2261,6 +2286,9 @@ fn test_freebsd(target: &str) {
("if_data", "__ifi_lastchange") => true,
("ifreq", "ifr_ifru") => true,

// anonymous struct
("devstat", "dev_links") => true,

// FIXME: structs too complicated to bind for now...
("kinfo_proc", "ki_paddr") => true,
("kinfo_proc", "ki_addr") => true,
Expand All @@ -2278,6 +2306,11 @@ fn test_freebsd(target: &str) {

// `__sem_base` is a private struct field
("semid_ds", "__sem_base") => true,

// `snap_time` is a `long double`, but it's a nightmare to bind correctly in rust
// for the moment, so it's a best effort thing...
("statinfo", "snap_time") => true,

_ => false,
}
});
Expand Down
Loading

0 comments on commit c4de1bc

Please sign in to comment.