Skip to content

Commit 215cd15

Browse files
committed
Update to the latest wasi-sysroot.
- Rename `wasm32-unknown-wasi` to `wasm32-wasi`. - `__wasilibc_rmfileat` was renamed to `__wasilibc_unlinkat` - Add bindings for a few more functions and typedefs.
1 parent 8b14a7e commit 215cd15

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

libc-test/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,7 @@ fn test_wasi(target: &str) {
11581158
"locale.h",
11591159
"malloc.h",
11601160
"poll.h",
1161+
"sched.h",
11611162
"stdbool.h",
11621163
"stddef.h",
11631164
"stdint.h",

src/wasi.rs

+18
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ pub type c_long = i32;
1010
pub type c_ulong = u32;
1111
pub type c_longlong = i64;
1212
pub type c_ulonglong = u64;
13+
pub type intmax_t = i64;
14+
pub type uintmax_t = u64;
1315
pub type size_t = usize;
1416
pub type ssize_t = isize;
17+
pub type ptrdiff_t = isize;
18+
pub type intptr_t = isize;
19+
pub type uintptr_t = usize;
1520
pub type off_t = i64;
1621
pub type pid_t = i32;
1722
pub type int8_t = i8;
@@ -619,11 +624,13 @@ extern {
619624
pub fn getenv(s: *const c_char) -> *mut c_char;
620625
pub fn malloc(amt: size_t) -> *mut c_void;
621626
pub fn malloc_usable_size(ptr: *mut c_void) -> size_t;
627+
pub fn sbrk(increment: ::intptr_t) -> *mut ::c_void;
622628
pub fn rand() -> c_int;
623629
pub fn read(fd: c_int, ptr: *mut c_void, size: size_t) -> ssize_t;
624630
pub fn realloc(ptr: *mut c_void, amt: size_t) -> *mut c_void;
625631
pub fn setenv(k: *const c_char, v: *const c_char, a: c_int) -> c_int;
626632
pub fn unsetenv(k: *const c_char) -> c_int;
633+
pub fn clearenv() -> ::c_int;
627634
pub fn write(fd: c_int, ptr: *const c_void, size: size_t) -> ssize_t;
628635
pub static mut environ: *mut *mut c_char;
629636
pub fn fopen(a: *const c_char, b: *const c_char) -> *mut FILE;
@@ -724,6 +731,7 @@ extern {
724731
pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE)
725732
-> *mut c_char;
726733
pub fn atoi(s: *const c_char) -> c_int;
734+
pub fn atof(s: *const c_char) -> c_double;
727735
pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
728736
pub fn strtol(
729737
s: *const c_char,
@@ -822,6 +830,7 @@ extern {
822830
pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent;
823831
pub fn closedir(dirp: *mut ::DIR) -> ::c_int;
824832
pub fn rewinddir(dirp: *mut ::DIR);
833+
pub fn dirfd(dirp: *mut ::DIR) -> ::c_int;
825834

826835
pub fn openat(
827836
dirfd: ::c_int,
@@ -902,9 +911,11 @@ extern {
902911
pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int;
903912

904913
pub fn fsync(fd: ::c_int) -> ::c_int;
914+
pub fn fdatasync(fd: ::c_int) -> ::c_int;
905915

906916
pub fn symlink(path1: *const c_char, path2: *const c_char) -> ::c_int;
907917

918+
pub fn truncate(path: *const c_char, length: off_t) -> ::c_int;
908919
pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int;
909920

910921
pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int;
@@ -954,6 +965,11 @@ extern {
954965
whence: ::c_int,
955966
) -> ::c_int;
956967
pub fn ftello(stream: *mut ::FILE) -> ::off_t;
968+
pub fn posix_fallocate(
969+
fd: ::c_int,
970+
offset: ::off_t,
971+
len: ::off_t,
972+
) -> ::c_int;
957973

958974
pub fn strcasestr(cs: *const c_char, ct: *const c_char) -> *mut c_char;
959975
pub fn getline(
@@ -1019,6 +1035,7 @@ extern {
10191035
base: ::locale_t,
10201036
) -> ::locale_t;
10211037
pub fn uselocale(loc: ::locale_t) -> ::locale_t;
1038+
pub fn sched_yield() -> ::c_int;
10221039

10231040
pub fn __wasilibc_register_preopened_fd(
10241041
fd: c_int,
@@ -1034,6 +1051,7 @@ extern {
10341051
rights_inheriting: __wasi_rights_t,
10351052
relative_path: *mut *const c_char,
10361053
) -> c_int;
1054+
pub fn __wasilibc_tell(fd: c_int) -> ::off_t;
10371055

10381056
pub fn arc4random() -> u32;
10391057
pub fn arc4random_buf(a: *mut c_void, b: size_t);

0 commit comments

Comments
 (0)