Skip to content

Commit 54b3f96

Browse files
rahul-thakooreldruin
authored andcommitted
Add support for wasm32-wasi compilation target
Signed-off-by: Rahul Thakoor <[email protected]>
1 parent e220e63 commit 54b3f96

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/error.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#[cfg(not(target_os = "wasi"))]
12
use nix;
23
use std::convert;
34
use std::fmt;
@@ -49,7 +50,7 @@ impl convert::From<io::Error> for Error {
4950
Error::Io(e)
5051
}
5152
}
52-
53+
#[cfg(not(target_os = "wasi"))]
5354
impl convert::From<nix::Error> for Error {
5455
fn from(e: nix::Error) -> Error {
5556
match e {

src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
extern crate futures;
4747
#[cfg(feature = "mio-evented")]
4848
extern crate mio;
49+
#[cfg(not(target_os = "wasi"))]
4950
extern crate nix;
5051
#[cfg(feature = "use_tokio")]
5152
extern crate tokio;
@@ -56,6 +57,7 @@ use std::io;
5657
use std::io::prelude::*;
5758
#[cfg(any(target_os = "linux", target_os = "android", feature = "use_tokio"))]
5859
use std::io::SeekFrom;
60+
#[cfg(not(target_os = "wasi"))]
5961
use std::os::unix::prelude::*;
6062
use std::path::Path;
6163

@@ -67,6 +69,7 @@ use mio::unix::EventedFd;
6769
use mio::Evented;
6870
#[cfg(any(target_os = "linux", target_os = "android"))]
6971
use nix::sys::epoll::*;
72+
#[cfg(not(target_os = "wasi"))]
7073
use nix::unistd::close;
7174
#[cfg(feature = "use_tokio")]
7275
use tokio::reactor::{Handle, PollEvented};
@@ -451,6 +454,7 @@ impl Pin {
451454
/// This pin poller object will register an interrupt with the
452455
/// kernel and allow you to poll() on it and receive notifications
453456
/// that an interrupt has occured with minimal delay.
457+
#[cfg(not(target_os = "wasi"))]
454458
pub fn get_poller(&self) -> Result<PinPoller> {
455459
PinPoller::new(self.pin_num)
456460
}
@@ -537,14 +541,14 @@ fn extract_pin_fom_path_test() {
537541
let err2 = Pin::extract_pin_from_path(&"/sys/class/gpio/gpioSDS");
538542
assert_eq!(true, err2.is_err());
539543
}
540-
544+
#[cfg(not(target_os = "wasi"))]
541545
#[derive(Debug)]
542546
pub struct PinPoller {
543547
pin_num: u64,
544548
epoll_fd: RawFd,
545549
devfile: File,
546550
}
547-
551+
#[cfg(not(target_os = "wasi"))]
548552
impl PinPoller {
549553
/// Get the pin associated with this PinPoller
550554
///
@@ -615,6 +619,7 @@ impl PinPoller {
615619
}
616620
}
617621

622+
#[cfg(not(target_os = "wasi"))]
618623
impl Drop for PinPoller {
619624
fn drop(&mut self) {
620625
// we implement drop to close the underlying epoll fd as

0 commit comments

Comments
 (0)