Add cfg attributes for running under Miri

This commit is contained in:
Bob Peterson
2025-10-13 12:57:13 -05:00
parent bd62c80536
commit cd56f52bd6
5 changed files with 11 additions and 11 deletions

View File

@@ -16,7 +16,7 @@ use std::{
sync::{atomic::Ordering, LazyLock},
};
#[cfg(not(target_family = "wasm"))]
#[cfg(all(not(target_family = "wasm"), not(miri)))]
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;

View File

@@ -2,7 +2,7 @@
mod dynamic;
mod vtab_xconnect;
use crate::schema::{Schema, Table};
#[cfg(all(target_os = "linux", feature = "io_uring"))]
#[cfg(all(target_os = "linux", feature = "io_uring", not(miri)))]
use crate::UringIO;
use crate::{function::ExternalFunc, Connection, Database};
use crate::{vtab::VirtualTable, SymbolTable};
@@ -146,7 +146,7 @@ impl Database {
let io: Arc<dyn IO> = match vfs {
"memory" => Arc::new(MemoryIO::new()),
"syscall" => Arc::new(SyscallIO::new()?),
#[cfg(all(target_os = "linux", feature = "io_uring"))]
#[cfg(all(target_os = "linux", feature = "io_uring", not(miri)))]
"io_uring" => Arc::new(UringIO::new()?),
other => match get_vfs_modules().iter().find(|v| v.0 == vfs) {
Some((_, vfs)) => vfs.clone(),

View File

@@ -717,13 +717,13 @@ impl TempBufferCache {
}
cfg_block! {
#[cfg(all(target_os = "linux", feature = "io_uring"))] {
#[cfg(all(target_os = "linux", feature = "io_uring", not(miri)))] {
mod io_uring;
#[cfg(feature = "fs")]
pub use io_uring::UringIO;
}
#[cfg(target_family = "unix")] {
#[cfg(all(target_family = "unix", not(miri)))] {
mod unix;
#[cfg(feature = "fs")]
pub use unix::UnixIO;
@@ -731,7 +731,7 @@ cfg_block! {
pub use PlatformIO as SyscallIO;
}
#[cfg(not(any(target_family = "unix", target_os = "android", target_os = "ios")))] {
#[cfg(any(not(any(target_family = "unix", target_os = "android", target_os = "ios")), miri))] {
mod generic;
pub use generic::GenericIO as PlatformIO;
pub use PlatformIO as SyscallIO;

View File

@@ -53,9 +53,9 @@ use crate::{incremental::view::AllViewsTxState, translate::emitter::TransactionM
use core::str;
pub use error::{CompletionError, LimboError};
pub use io::clock::{Clock, Instant};
#[cfg(all(feature = "fs", target_family = "unix"))]
#[cfg(all(feature = "fs", target_family = "unix", not(miri)))]
pub use io::UnixIO;
#[cfg(all(feature = "fs", target_os = "linux", feature = "io_uring"))]
#[cfg(all(feature = "fs", target_os = "linux", feature = "io_uring", not(miri)))]
pub use io::UringIO;
pub use io::{
Buffer, Completion, CompletionType, File, GroupCompletion, MemoryIO, OpenFlags, PlatformIO,
@@ -791,7 +791,7 @@ impl Database {
None => match vfs.as_ref() {
"memory" => Arc::new(MemoryIO::new()),
"syscall" => Arc::new(SyscallIO::new()?),
#[cfg(all(target_os = "linux", feature = "io_uring"))]
#[cfg(all(target_os = "linux", feature = "io_uring", not(miri)))]
"io_uring" => Arc::new(UringIO::new()?),
other => {
return Err(LimboError::InvalidArgument(format!("no such VFS: {other}")));

View File

@@ -427,7 +427,7 @@ impl Arena {
}
}
#[cfg(unix)]
#[cfg(all(unix, not(miri)))]
mod arena {
#[cfg(target_vendor = "apple")]
use libc::MAP_ANON as MAP_ANONYMOUS;
@@ -463,7 +463,7 @@ mod arena {
}
}
#[cfg(not(unix))]
#[cfg(any(not(unix), miri))]
mod arena {
pub fn alloc(len: usize) -> *mut u8 {
let layout = std::alloc::Layout::from_size_align(len, std::mem::size_of::<u8>()).unwrap();