Skip to content

Commit c1d5ce6

Browse files
committed
Add emscripten support
1 parent 31423a3 commit c1d5ce6

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
))]
7272
#![cfg_attr(target_os = "dragonfly", doc(
7373
html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-dragonfly"
74+
#![cfg_attr(all(target_os = "emscripten", target_arch = "asmjs"), doc(
75+
html_root_url = "https://doc.rust-lang.org/libc/asmjs-unknown-emscripten"
7476
))]
7577

7678
// Attributes needed when building as part of the standard library

src/unix/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ cfg_if! {
124124
} else if #[cfg(target_env = "musl")] {
125125
#[link(name = "c", kind = "static")]
126126
extern {}
127+
} else if #[cfg(target_os = "emscripten")] {
128+
#[link(name = "c")]
129+
extern {}
127130
} else if #[cfg(any(target_os = "macos",
128131
target_os = "ios",
129132
target_os = "android",
@@ -664,7 +667,9 @@ extern {
664667
}
665668

666669
cfg_if! {
667-
if #[cfg(any(target_os = "linux", target_os = "android"))] {
670+
if #[cfg(any(target_os = "linux",
671+
target_os = "android",
672+
target_os = "emscripten"))] {
668673
mod notbsd;
669674
pub use self::notbsd::*;
670675
} else if #[cfg(any(target_os = "macos",

src/unix/notbsd/linux/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,8 @@ extern {
511511
}
512512

513513
cfg_if! {
514-
if #[cfg(target_env = "musl")] {
514+
if #[cfg(any(target_env = "musl",
515+
target_os = "emscripten"))] {
515516
mod musl;
516517
pub use self::musl::*;
517518
} else if #[cfg(any(target_arch = "mips", target_arch = "mipsel"))] {

src/unix/notbsd/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ s! {
5151
pub ai_protocol: ::c_int,
5252
pub ai_addrlen: socklen_t,
5353

54-
#[cfg(target_os = "linux")]
54+
#[cfg(any(target_os = "linux", target_os = "emscripten"))]
5555
pub ai_addr: *mut ::sockaddr,
5656

5757
pub ai_canonname: *mut c_char,
@@ -610,7 +610,8 @@ extern {
610610
}
611611

612612
cfg_if! {
613-
if #[cfg(target_os = "linux")] {
613+
if #[cfg(any(target_os = "linux",
614+
target_os = "emscripten"))] {
614615
mod linux;
615616
pub use self::linux::*;
616617
} else if #[cfg(target_os = "android")] {

0 commit comments

Comments
 (0)