-
-
Save thomcc/95cb28cf3dd08f3e01a4cddc06205d61 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[cfg(feature = "sqlcipher")] | |
#[link(name = "sqlcipher")] | |
extern "C" { | |
fn sqlite3_key( | |
db: *mut ::std::os::raw::c_void, | |
p_key: *const ::std::os::raw::c_void, | |
n_key: ::std::os::raw::c_int | |
) -> ::std::os::raw::c_int; | |
} | |
#[cfg(feature = "sqlcipher")] | |
#[inline(never)] | |
fn hacky_ensure_sqlcipher_exists() { | |
use std::ptr; | |
// Use the address of sqlite3_key here, and write it into a volatile "buffer". | |
// This is a crude way of forcing a linking failure if sqlite3_key is not | |
// available, without requiring us actually call sqlite3_key. | |
let p = (&sqlite3_key as *const _) as usize; | |
let mut dest: usize = 0; | |
unsafe { | |
ptr::write_volatile(&mut dest as *mut usize, p); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment