mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-25 02:21:37 +08:00
Replace ::atomic::Atomic by std AtomicPtr
NoUninit constraint cannot be satisfied
This commit is contained in:
parent
1d74ddcc7b
commit
e8c35fce50
@ -23,7 +23,7 @@ min_sqlite_version_3_14_0 = ["pkg-config", "vcpkg"]
|
||||
# Bundle only the bindings file. Note that this does nothing if
|
||||
# `buildtime_bindgen` is enabled.
|
||||
bundled_bindings = []
|
||||
loadable_extension = ["atomic", "prettyplease", "quote", "syn"]
|
||||
loadable_extension = ["prettyplease", "quote", "syn"]
|
||||
# sqlite3_unlock_notify >= 3.6.12
|
||||
unlock_notify = []
|
||||
# 3.13.0
|
||||
@ -43,7 +43,6 @@ winsqlite3 = []
|
||||
|
||||
[dependencies]
|
||||
openssl-sys = { version = "0.9", optional = true }
|
||||
atomic = { version = "0.6", optional = true }
|
||||
|
||||
[build-dependencies]
|
||||
bindgen = { version = "0.69", optional = true, default-features = false, features = ["runtime"] }
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -745,25 +745,31 @@ mod loadable_extension {
|
||||
let ty = &method.output;
|
||||
let tokens = if "db_config" == name {
|
||||
quote::quote! {
|
||||
static #ptr_name: ::atomic::Atomic<Option<unsafe extern "C" fn(#args #varargs) #ty>> = ::atomic::Atomic::new(None);
|
||||
static #ptr_name: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new(::std::ptr::null_mut());
|
||||
pub unsafe fn #sqlite3_fn_name(#args arg3: ::std::os::raw::c_int, arg4: *mut ::std::os::raw::c_int) #ty {
|
||||
let fun = #ptr_name.load(::atomic::Ordering::Acquire).expect("SQLite API not initialized");
|
||||
let ptr = #ptr_name.load(::std::sync::atomic::Ordering::Acquire);
|
||||
assert!(!ptr.is_null(), "SQLite API not initialized");
|
||||
let fun: unsafe extern "C" fn(#args #varargs) #ty = ::std::mem::transmute(ptr);
|
||||
(fun)(#arg_names, arg3, arg4)
|
||||
}
|
||||
}
|
||||
} else if "log" == name {
|
||||
quote::quote! {
|
||||
static #ptr_name: ::atomic::Atomic<Option<unsafe extern "C" fn(#args #varargs) #ty>> = ::atomic::Atomic::new(None);
|
||||
static #ptr_name: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new(::std::ptr::null_mut());
|
||||
pub unsafe fn #sqlite3_fn_name(#args arg3: *const ::std::os::raw::c_char) #ty {
|
||||
let fun = #ptr_name.load(::atomic::Ordering::Acquire).expect("SQLite API not initialized");
|
||||
let ptr = #ptr_name.load(::std::sync::atomic::Ordering::Acquire);
|
||||
assert!(!ptr.is_null(), "SQLite API not initialized");
|
||||
let fun: unsafe extern "C" fn(#args #varargs) #ty = ::std::mem::transmute(ptr);
|
||||
(fun)(#arg_names, arg3)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
quote::quote! {
|
||||
static #ptr_name: ::atomic::Atomic<Option<unsafe extern "C" fn(#args #varargs) #ty>> = ::atomic::Atomic::new(None);
|
||||
static #ptr_name: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new(::std::ptr::null_mut());
|
||||
pub unsafe fn #sqlite3_fn_name(#args) #ty {
|
||||
let fun = #ptr_name.load(::atomic::Ordering::Acquire).expect("SQLite API not initialized or SQLite feature omitted");
|
||||
let ptr = #ptr_name.load(::std::sync::atomic::Ordering::Acquire);
|
||||
assert!(!ptr.is_null(), "SQLite API not initialized or SQLite feature omitted");
|
||||
let fun: unsafe extern "C" fn(#args #varargs) #ty = ::std::mem::transmute(ptr);
|
||||
(fun)(#arg_names)
|
||||
}
|
||||
}
|
||||
@ -778,10 +784,12 @@ mod loadable_extension {
|
||||
&mut stores
|
||||
}
|
||||
.push(quote::quote! {
|
||||
#ptr_name.store(
|
||||
(*#p_api).#ident,
|
||||
::atomic::Ordering::Release,
|
||||
);
|
||||
if let Some(fun) = (*#p_api).#ident {
|
||||
#ptr_name.store(
|
||||
fun as usize as *mut (),
|
||||
::std::sync::atomic::Ordering::Release,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
// (3) generate rust code similar to SQLITE_EXTENSION_INIT2 macro
|
||||
|
6658
libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs
vendored
6658
libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs
vendored
File diff suppressed because it is too large
Load Diff
@ -28,12 +28,13 @@ find "$TARGET_DIR" -type f -name bindgen.rs -exec mv {} "$SQLITE3_LIB_DIR/bindge
|
||||
# Regenerate bindgen file for sqlite3ext.h
|
||||
# some sqlite3_api_routines fields are function pointers with va_list arg but currently stable Rust doesn't support this type.
|
||||
# FIXME how to generate portable bindings without :
|
||||
sed -i'' -e 's/va_list/void*/' "$SQLITE3_LIB_DIR/sqlite3ext.h"
|
||||
sed -i.bk -e 's/va_list/void*/' "$SQLITE3_LIB_DIR/sqlite3ext.h"
|
||||
rm -f "$SQLITE3_LIB_DIR/bindgen_bundled_version_ext.rs"
|
||||
find "$TARGET_DIR" -type f -name bindgen.rs -exec rm {} \;
|
||||
env LIBSQLITE3_SYS_BUNDLING=1 cargo build --features "buildtime_bindgen loadable_extension" --no-default-features
|
||||
find "$TARGET_DIR" -type f -name bindgen.rs -exec mv {} "$SQLITE3_LIB_DIR/bindgen_bundled_version_ext.rs" \;
|
||||
git checkout "$SQLITE3_LIB_DIR/sqlite3ext.h"
|
||||
rm -f "$SQLITE3_LIB_DIR/sqlite3ext.h.bk"
|
||||
|
||||
# Sanity checks
|
||||
cd "$SCRIPT_DIR/.." || { echo "fatal error" >&2; exit 1; }
|
||||
|
Loading…
Reference in New Issue
Block a user