Skip to content

Commit 3eae744

Browse files
committed
Added bindings for wasm32-wali-linux-musl target
1 parent 0f9f8c9 commit 3eae744

File tree

7 files changed

+2462
-3
lines changed

7 files changed

+2462
-3
lines changed

src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//! libc - Raw FFI bindings to platforms' system libraries
22
#![crate_name = "libc"]
33
#![crate_type = "rlib"]
4+
#![feature(c_variadic)]
5+
#![feature(concat_idents)]
46
#![allow(
57
renamed_and_removed_lints, // Keep this order.
68
unknown_lints, // Keep this order.

src/unix/linux_like/linux/arch/generic/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ cfg_if! {
291291
target_arch = "riscv64",
292292
target_arch = "aarch64",
293293
target_arch = "s390x",
294-
target_arch = "loongarch64"
294+
target_arch = "loongarch64",
295+
target_arch = "wasm32"
295296
))] {
296297
pub const FS_IOC_GETFLAGS: Ioctl = 0x80086601;
297298
pub const FS_IOC_SETFLAGS: Ioctl = 0x40086602;

src/unix/linux_like/linux/mod.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -6432,7 +6432,7 @@ extern "C" {
64326432
pub fn vhangup() -> c_int;
64336433
pub fn sync();
64346434
pub fn syncfs(fd: c_int) -> c_int;
6435-
pub fn syscall(num: c_long, ...) -> c_long;
6435+
64366436
pub fn sched_getaffinity(
64376437
pid: crate::pid_t,
64386438
cpusetsize: size_t,
@@ -6839,6 +6839,23 @@ extern "C" {
68396839
pub fn ioctl(fd: c_int, request: Ioctl, ...) -> c_int;
68406840
}
68416841

6842+
// Syscall libc stub for non-wasm32 (WALI) targets
6843+
//
6844+
// For wasm32, all syscalls are name-bound and typed.
6845+
// The 'syscall' implementation from C library is avoided since
6846+
// higher level libraries do not explicitly typecast arguments to
6847+
// 64-bit register sizes, which is expected of C variadic arguments.
6848+
// To overcome this, a wrapper 'syscall' method is implemented,
6849+
// which binds the syscall types statically at compile time
6850+
// and binds their numbers at runtime
6851+
cfg_if!(
6852+
if #[cfg(not(target_arch = "wasm32"))] {
6853+
extern "C" {
6854+
pub fn syscall(num: c_long, ...) -> c_long;
6855+
}
6856+
}
6857+
);
6858+
68426859
// LFS64 extensions
68436860
//
68446861
// * musl has 64-bit versions only so aliases the LFS64 symbols to the standard ones

src/unix/linux_like/linux/musl/b64/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ cfg_if! {
109109
} else if #[cfg(any(target_arch = "loongarch64"))] {
110110
mod loongarch64;
111111
pub use self::loongarch64::*;
112+
} else if #[cfg(any(target_arch = "wasm32"))] {
113+
mod wasm32;
114+
pub use self::wasm32::*;
112115
} else {
113116
// Unknown target_arch
114117
}

0 commit comments

Comments
 (0)