1#![expect(non_snake_case, non_camel_case_types)]
2#![cfg_attr(not(test), no_std)]
3pub use self::error::*;
4
5use core::mem;
6use core::sync::atomic::{AtomicI32, Ordering};
7
8mod error;
9
10#[must_use]
11pub fn SQLITE_STATIC() -> sqlite3_destructor_type {
12 None
13}
14
15#[must_use]
16pub fn SQLITE_TRANSIENT() -> sqlite3_destructor_type {
17 Some(unsafe { mem::transmute::<isize, unsafe extern "C" fn(*mut core::ffi::c_void)>(-1_isize) })
18}
19
20#[allow(dead_code, clippy::all)]
21mod bindings {
22 include!(concat!(env!("OUT_DIR"), "/bindgen.rs"));
23}
24pub use bindings::*;
25
26unsafe extern "C" {
27 fn doltliteInstallAutoExt() -> core::ffi::c_int;
28}
29
30static DOLTLITE_INIT_RESULT: AtomicI32 = AtomicI32::new(i32::MIN);
31
32pub fn initialize_doltlite() -> core::ffi::c_int {
33 let existing = DOLTLITE_INIT_RESULT.load(Ordering::Acquire);
34 if existing != i32::MIN {
35 return existing;
36 }
37
38 let result = unsafe { doltliteInstallAutoExt() };
39 match DOLTLITE_INIT_RESULT.compare_exchange(
40 i32::MIN,
41 result,
42 Ordering::AcqRel,
43 Ordering::Acquire,
44 ) {
45 Ok(_) => result,
46 Err(previous) => previous,
47 }
48}
49
50impl Default for sqlite3_vtab {
51 fn default() -> Self {
52 unsafe { mem::zeroed() }
53 }
54}
55
56impl Default for sqlite3_vtab_cursor {
57 fn default() -> Self {
58 unsafe { mem::zeroed() }
59 }
60}