Skip to content

Commit

Permalink
Auto merge of #1325 - sunfishcode:wasi-more-libc, r=alexcrichton
Browse files Browse the repository at this point in the history
Add more WASI libc bindings

This picks up #1321, adding more WASI libc bindings, adding several more fixes. In particular, `cargo test --all` including libc-test now builds successfully.
  • Loading branch information
bors committed Apr 23, 2019
2 parents fa186bb + ef7ae73 commit e167760
Show file tree
Hide file tree
Showing 3 changed files with 599 additions and 8 deletions.
17 changes: 16 additions & 1 deletion libc-test/build.rs
Expand Up @@ -1875,17 +1875,28 @@ fn test_wasi(target: &str) {
cfg.define("_GNU_SOURCE", None);

headers! { cfg:
"ctype.h",
"dirent.h",
"errno.h",
"fcntl.h",
"limits.h",
"locale.h",
"malloc.h",
"poll.h",
"stdbool.h",
"stddef.h",
"stdint.h",
"stdio.h",
"stdlib.h",
"string.h",
"sys/resource.h",
"sys/select.h",
"sys/socket.h",
"sys/stat.h",
"sys/times.h",
"sys/types.h",
"sys/uio.h",
"sys/utsname.h",
"time.h",
"unistd.h",
"wasi/core.h",
Expand All @@ -1895,7 +1906,7 @@ fn test_wasi(target: &str) {
}

cfg.type_name(move |ty, is_struct, is_union| match ty {
"FILE" => ty.to_string(),
"FILE" | "fd_set" | "DIR" => ty.to_string(),
t if is_union => format!("union {}", t),
t if t.starts_with("__wasi") && t.ends_with("_u") => {
format!("union {}", t)
Expand All @@ -1920,5 +1931,9 @@ fn test_wasi(target: &str) {
// import the same thing but have different function pointers
cfg.skip_fn_ptrcheck(|f| f.starts_with("__wasi"));

// d_name is declared as a flexible array in WASI libc, so it
// doesn't support sizeof.
cfg.skip_field(|s, field| s == "dirent" && field == "d_name");

cfg.generate("../src/lib.rs", "main.rs");
}
2 changes: 1 addition & 1 deletion src/lib.rs
Expand Up @@ -112,7 +112,7 @@ cfg_if! {
} else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] {
mod sgx;
pub use sgx::*;
} else if #[cfg(target_env = "wasi")] {
} else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] {
mod wasi;
pub use wasi::*;
} else {
Expand Down

0 comments on commit e167760

Please sign in to comment.