support windows
This commit is contained in:
@@ -5,12 +5,12 @@ pub enum SystemTimeSpec {
|
||||
Absolute(SystemTime),
|
||||
}
|
||||
|
||||
pub trait WasiSystemClock {
|
||||
pub trait WasiSystemClock: Send + Sync {
|
||||
fn resolution(&self) -> Duration;
|
||||
fn now(&self, precision: Duration) -> SystemTime;
|
||||
}
|
||||
|
||||
pub trait WasiMonotonicClock {
|
||||
pub trait WasiMonotonicClock: Send + Sync {
|
||||
fn resolution(&self) -> Duration;
|
||||
fn now(&self, precision: Duration) -> Instant;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
use crate::asyncify;
|
||||
use std::any::Any;
|
||||
use std::io;
|
||||
#[cfg(windows)]
|
||||
use std::os::windows::io::{AsRawHandle, RawHandle};
|
||||
use wasi_common::{
|
||||
file::{Advice, FdFlags, FileType, Filestat, WasiFile},
|
||||
Error,
|
||||
@@ -135,6 +137,7 @@ macro_rules! wasi_file_impl {
|
||||
#[cfg(windows)]
|
||||
async fn readable(&mut self) -> Result<(), Error> {
|
||||
// Windows uses a rawfd based scheduler :(
|
||||
use wasi_common::ErrorExt;
|
||||
Err(Error::badf())
|
||||
}
|
||||
|
||||
@@ -164,9 +167,16 @@ macro_rules! wasi_file_impl {
|
||||
#[cfg(windows)]
|
||||
async fn writable(&mut self) -> Result<(), Error> {
|
||||
// Windows uses a rawfd based scheduler :(
|
||||
use wasi_common::ErrorExt;
|
||||
Err(Error::badf())
|
||||
}
|
||||
}
|
||||
#[cfg(windows)]
|
||||
impl AsRawHandle for $ty {
|
||||
fn as_raw_handle(&self) -> RawHandle {
|
||||
self.0.as_raw_handle()
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::asyncify;
|
||||
use anyhow::Context;
|
||||
use std::ops::Deref;
|
||||
use std::os::windows::io::{AsRawHandle, RawHandle};
|
||||
@@ -9,12 +10,16 @@ use wasi_common::{
|
||||
file::WasiFile,
|
||||
sched::{
|
||||
subscription::{RwEventFlags, Subscription},
|
||||
Poll, WasiSched,
|
||||
Poll,
|
||||
},
|
||||
Error, ErrorExt,
|
||||
};
|
||||
|
||||
pub async fn poll_oneoff<'a>(poll: &mut Poll<'a>) -> Result<(), Error> {
|
||||
asyncify(move || poll_oneoff_(poll))
|
||||
}
|
||||
|
||||
async fn poll_oneoff_<'a>(poll: &mut Poll<'a>) -> Result<(), Error> {
|
||||
if poll.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user