From 6ca99a812149d88527b22e65a39457df27b189e0 Mon Sep 17 00:00:00 2001 From: Rick Richardson Date: Wed, 18 Oct 2017 23:04:10 -0700 Subject: [PATCH] add workaround for weird bindgen stddefs.h align bug, fix tests --- librocksdb-sys/build.rs | 1 + librocksdb-sys/tests/ffi.rs | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/librocksdb-sys/build.rs b/librocksdb-sys/build.rs index 10cb2c3..47a74a3 100644 --- a/librocksdb-sys/build.rs +++ b/librocksdb-sys/build.rs @@ -35,6 +35,7 @@ fn build_rocksdb() { let bindings = bindgen::Builder::default() .header("rocksdb/include/rocksdb/c.h") + .hide_type("max_align_t") // https://github.com/rust-lang-nursery/rust-bindgen/issues/550 .ctypes_prefix("libc") .generate() .expect("unable to generate rocksdb bindings"); diff --git a/librocksdb-sys/tests/ffi.rs b/librocksdb-sys/tests/ffi.rs index d230322..e5face9 100644 --- a/librocksdb-sys/tests/ffi.rs +++ b/librocksdb-sys/tests/ffi.rs @@ -429,7 +429,7 @@ fn ffi() { rocksdb_options_set_block_based_table_factory(options, table_options); let no_compression = rocksdb_no_compression; - rocksdb_options_set_compression(options, no_compression); + rocksdb_options_set_compression(options, no_compression as i32); rocksdb_options_set_compression_options(options, -14, -1, 0, 0); let compression_levels = vec![ no_compression, @@ -892,15 +892,15 @@ fn ffi() { let mut cf_options = rocksdb_options_create(); - let cf_names: [*const c_char; 2] = [cstrp!("default"), cstrp!("cf1")]; - let cf_opts: [*const rocksdb_options_t; 2] = [cf_options, cf_options]; + let mut cf_names: [*const c_char; 2] = [cstrp!("default"), cstrp!("cf1")]; + let mut cf_opts: [*const rocksdb_options_t; 2] = [cf_options, cf_options]; let mut handles: [*mut rocksdb_column_family_handle_t; 2] = [ptr::null_mut(), ptr::null_mut()]; db = rocksdb_open_column_families(db_options, dbname, 2, - cf_names.as_ptr(), - cf_opts.as_ptr(), + cf_names.as_mut_ptr(), + cf_opts.as_mut_ptr(), handles.as_mut_ptr(), &mut err); CheckNoError!(err);