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