Merge pull request #640 from Genomicsplc/wasm-no-thread-checks

don't perform threading mode checks on wasm32
This commit is contained in:
gwenn 2020-02-29 10:01:25 +01:00 committed by GitHub
commit a3e5ea990d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,7 @@ use std::path::Path;
use std::ptr;
use std::str;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex, Once};
use std::sync::{Arc, Mutex};
use super::ffi;
use super::{str_for_sqlite, str_to_cstring};
@ -324,7 +324,7 @@ impl Drop for InnerConnection {
}
#[cfg(not(feature = "bundled"))]
static SQLITE_VERSION_CHECK: Once = Once::new();
static SQLITE_VERSION_CHECK: std::sync::Once = std::sync::Once::new();
#[cfg(not(feature = "bundled"))]
pub static BYPASS_VERSION_CHECK: AtomicBool = AtomicBool::new(false);
@ -372,9 +372,25 @@ rusqlite was built against SQLite {} but the runtime SQLite version is {}. To fi
});
}
static SQLITE_INIT: Once = Once::new();
#[cfg(not(any(
target_arch = "wasm32"
)))]
static SQLITE_INIT: std::sync::Once = std::sync::Once::new();
pub static BYPASS_SQLITE_INIT: AtomicBool = AtomicBool::new(false);
// threading mode checks are not necessary (and do not work) on target
// platforms that do not have threading (such as webassembly)
#[cfg(any(
target_arch = "wasm32"
))]
fn ensure_safe_sqlite_threading_mode() -> Result<()> {
Ok(())
}
#[cfg(not(any(
target_arch = "wasm32"
)))]
fn ensure_safe_sqlite_threading_mode() -> Result<()> {
// Ensure SQLite was compiled in thredsafe mode.
if unsafe { ffi::sqlite3_threadsafe() == 0 } {