diff --git a/cozo-core/src/data/functions.rs b/cozo-core/src/data/functions.rs index b36009f1..ef328d3f 100644 --- a/cozo-core/src/data/functions.rs +++ b/cozo-core/src/data/functions.rs @@ -14,7 +14,7 @@ use std::time::{SystemTime, UNIX_EPOCH}; use chrono::{DateTime, TimeZone, Utc}; use itertools::Itertools; -#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] +#[cfg(target_arch = "wasm32")] use js_sys::Date; use miette::{bail, ensure, miette, Result}; use num_traits::FloatConst; @@ -1486,13 +1486,13 @@ pub(crate) fn op_to_uuid(args: &[DataValue]) -> Result { } define_op!(OP_NOW, 0, false); -#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] +#[cfg(target_arch = "wasm32")] pub(crate) fn op_now(_args: &[DataValue]) -> Result { let d: f64 = Date::now() / 1000.; Ok(DataValue::from(d)) } -#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] +#[cfg(not(target_arch = "wasm32"))] pub(crate) fn op_now(_args: &[DataValue]) -> Result { let now = SystemTime::now(); Ok(DataValue::from( @@ -1501,12 +1501,12 @@ pub(crate) fn op_now(_args: &[DataValue]) -> Result { } pub(crate) fn current_validity() -> ValidityTs { - #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] + #[cfg(not(target_arch = "wasm32"))] let ts_micros = { let now = SystemTime::now(); now.duration_since(UNIX_EPOCH).unwrap().as_micros() as i64 }; - #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] + #[cfg(target_arch = "wasm32")] let ts_micros = { (Date::now() * 1000.) as i64 }; ValidityTs(Reverse(ts_micros)) @@ -1575,14 +1575,14 @@ define_op!(OP_RAND_UUID_V1, 0, false); pub(crate) fn op_rand_uuid_v1(_args: &[DataValue]) -> Result { let mut rng = rand::thread_rng(); let uuid_ctx = uuid::v1::Context::new(rng.gen()); - #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] + #[cfg(target_arch = "wasm32")] let ts = { let since_epoch: f64 = Date::now(); let seconds = since_epoch.floor(); let fractional = (since_epoch - seconds) * 1.0e9; Timestamp::from_unix(uuid_ctx, seconds as u64, fractional as u32) }; - #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] + #[cfg(not(target_arch = "wasm32"))] let ts = { let now = SystemTime::now(); let since_epoch = now.duration_since(UNIX_EPOCH).unwrap(); diff --git a/cozo-core/src/lib.rs b/cozo-core/src/lib.rs index 3b351c0f..ba1b2946 100644 --- a/cozo-core/src/lib.rs +++ b/cozo-core/src/lib.rs @@ -173,17 +173,17 @@ impl DbInstance { payload: &str, params: BTreeMap, ) -> JsonValue { - #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] + #[cfg(not(target_arch = "wasm32"))] let start = Instant::now(); match self.run_script(payload, params) { Ok(named_rows) => { let mut j_val = named_rows.into_json(); - #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] + #[cfg(not(target_arch = "wasm32"))] let took = start.elapsed().as_secs_f64(); let map = j_val.as_object_mut().unwrap(); map.insert("ok".to_string(), json!(true)); - #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] + #[cfg(not(target_arch = "wasm32"))] map.insert("took".to_string(), json!(took)); j_val diff --git a/cozo-core/src/parse/query.rs b/cozo-core/src/parse/query.rs index 161f46fe..bb2157d2 100644 --- a/cozo-core/src/parse/query.rs +++ b/cozo-core/src/parse/query.rs @@ -245,10 +245,10 @@ pub(crate) fn parse_query( out_opts.timeout = Some(timeout); } Rule::sleep_option => { - #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] + #[cfg(target_arch = "wasm32")] bail!(":sleep is not supported under WASM"); - #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] + #[cfg(not(target_arch = "wasm32"))] { let pair = pair.into_inner().next().unwrap(); let span = pair.extract_span(); diff --git a/cozo-core/src/query/eval.rs b/cozo-core/src/query/eval.rs index 44de3021..515f5423 100644 --- a/cozo-core/src/query/eval.rs +++ b/cozo-core/src/query/eval.rs @@ -13,7 +13,7 @@ use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use itertools::Itertools; use log::{debug, trace}; use miette::Result; -#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] +#[cfg(not(target_arch = "wasm32"))] use rayon::prelude::*; use crate::data::aggr::Aggregation; @@ -178,7 +178,7 @@ impl<'a> SessionTx<'a> { }; Ok((k, new_store)) }; - #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] + #[cfg(not(target_arch = "wasm32"))] { let limiter_enabled = limiter.total.is_some(); for res in prog @@ -203,7 +203,7 @@ impl<'a> SessionTx<'a> { to_merge.insert(k, new_store); } } - #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] + #[cfg(target_arch = "wasm32")] { for res in prog.iter().map(execution) { let (k, new_store) = res?; @@ -251,7 +251,7 @@ impl<'a> SessionTx<'a> { }; Ok((k, new_store)) }; - #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] + #[cfg(not(target_arch = "wasm32"))] { let limiter_enabled = limiter.total.is_some(); // entry rules with limiter must execute sequentially in order to get deterministic ordering @@ -276,7 +276,7 @@ impl<'a> SessionTx<'a> { to_merge.insert(k, new_store); } } - #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] + #[cfg(target_arch = "wasm32")] { for res in prog.iter().map(execution) { let (k, new_store) = res?; diff --git a/cozo-core/src/runtime/db.rs b/cozo-core/src/runtime/db.rs index 5cef4e48..787c8411 100644 --- a/cozo-core/src/runtime/db.rs +++ b/cozo-core/src/runtime/db.rs @@ -532,7 +532,7 @@ impl<'s, S: Storage<'s>> Db { } res = q_res; cleanups.extend(q_cleanups); - #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] + #[cfg(not(target_arch = "wasm32"))] if let Some(secs) = sleep_opt { thread::sleep(Duration::from_micros((secs * 1000000.) as u64)); } @@ -903,15 +903,15 @@ impl<'s, S: Storage<'s>> Db { let id = self.queries_count.fetch_add(1, Ordering::AcqRel); // time the query - #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] + #[cfg(not(target_arch = "wasm32"))] let now = SystemTime::now(); - #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] + #[cfg(not(target_arch = "wasm32"))] let since_the_epoch = now .duration_since(UNIX_EPOCH) .into_diagnostic()? .as_secs_f64(); - #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] + #[cfg(target_arch = "wasm32")] let since_the_epoch = js_sys::Date::now(); let handle = RunningQueryHandle { @@ -1195,11 +1195,11 @@ impl Poison { } Ok(()) } - #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] + #[cfg(target_arch = "wasm32")] pub(crate) fn set_timeout(&self, _secs: f64) -> Result<()> { bail!("Cannot set timeout when threading is disallowed"); } - #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] + #[cfg(not(target_arch = "wasm32"))] pub(crate) fn set_timeout(&self, secs: f64) -> Result<()> { let pill = self.clone(); thread::spawn(move || { diff --git a/cozo-core/src/storage/mem.rs b/cozo-core/src/storage/mem.rs index 6af0fa0d..a949e4e3 100644 --- a/cozo-core/src/storage/mem.rs +++ b/cozo-core/src/storage/mem.rs @@ -73,9 +73,9 @@ impl<'s> Storage<'s> for MemStorage { wtr.remove(k); } }; - #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] + #[cfg(target_arch = "wasm32")] closure(); - #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] + #[cfg(not(target_arch = "wasm32"))] std::thread::spawn(closure); Ok(()) }