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 3, 2021
1 parent ddc070c commit ac6e16b
Show file tree
Hide file tree
Showing 2 changed files with 362 additions and 3 deletions.
28 changes: 25 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 @@ -2261,6 +2275,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 +2295,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 ac6e16b

Please sign in to comment.