Skip to content

Commit afbc8b6

Browse files
authored
Merge pull request #4 from flier/develop
update `bindgen`
2 parents 43e5574 + 9b911b4 commit afbc8b6

File tree

6 files changed

+262
-255
lines changed

6 files changed

+262
-255
lines changed

fasthash-sys/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fasthash-sys"
3-
version = "0.2.5"
3+
version = "0.2.6"
44
authors = ["Flier Lu <flier.lu@gmail.com>"]
55
description = "A suite of non-cryptographic hash functions for Rust."
66
homepage = "https://github.com/flier/rust-fasthash"
@@ -13,10 +13,10 @@ links = "fasthash"
1313
[features]
1414
default = ["sse42"]
1515
sse42 = []
16-
bindgen = ["libbindgen"]
16+
gen = ["bindgen"]
1717

1818
[dependencies]
1919

2020
[build-dependencies]
2121
gcc = "0.3"
22-
libbindgen = { version="0.1", optional=true }
22+
bindgen = { version="0.25", optional=true }

fasthash-sys/build.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
extern crate gcc;
22
#[cfg(feature = "bindgen")]
3-
extern crate libbindgen;
3+
extern crate bindgen;
44

55
#[cfg(not(feature = "bindgen"))]
66
use std::fs;
@@ -9,16 +9,16 @@ use std::path::Path;
99

1010
#[cfg(feature = "bindgen")]
1111
fn generate_binding(out_file: &Path) {
12-
let _ = libbindgen::builder()
13-
.clang_arg("-xc++")
12+
let _ = bindgen::builder()
1413
.clang_arg("--std=c++11")
1514
.clang_arg(if cfg!(feature = "sse42") {
16-
"-msse4.2"
17-
} else {
18-
"-march=native"
19-
})
15+
"-msse4.2"
16+
} else {
17+
"-march=native"
18+
})
2019
.header("src/fasthash.hpp")
2120
.no_unstable_rust()
21+
.generate_inline_functions(true)
2222
.disable_name_namespacing()
2323
.hide_type(".*PCCP.*")
2424
.whitelisted_function("^CityHash.*")
@@ -51,7 +51,8 @@ fn generate_binding(out_file: &Path) {
5151
fn main() {
5252
let mut gcc_config = gcc::Config::new();
5353

54-
gcc_config.file("src/fasthash.cpp")
54+
gcc_config
55+
.file("src/fasthash.cpp")
5556
.file("src/smhasher/City.cpp")
5657
.file("src/smhasher/farmhash-c.c")
5758
.file("src/smhasher/lookup3.cpp")
@@ -66,7 +67,8 @@ fn main() {
6667
.file("src/smhasher/xxhash.c");
6768

6869
if cfg!(feature = "sse42") {
69-
gcc_config.flag("-msse4.2")
70+
gcc_config
71+
.flag("-msse4.2")
7072
.file("src/smhasher/metrohash64crc.cpp")
7173
.file("src/smhasher/metrohash128crc.cpp");
7274
}

fasthash-sys/src/fasthash.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,31 @@ uint64_t farmhash_fingerprint_uint128(uint128_c_t x);
1313

1414
uint64_t farmhash_fingerprint_uint64(uint64_t x);
1515

16-
uint32_t lookup3(const void * key, int length, uint32_t initval);
16+
uint32_t lookup3(const void *key, int length, uint32_t initval);
1717

1818
uint64_t mum_hash_(const void *key, size_t len, uint64_t seed);
1919

2020
void SpookyHasherHash(
21-
const void *message, // message to hash
22-
size_t length, // length of message in bytes
23-
uint64 *hash1, // in/out: in seed 1, out hash value 1
24-
uint64 *hash2); // in/out: in seed 2, out hash value 2
21+
const void *message, // message to hash
22+
size_t length, // length of message in bytes
23+
uint64 *hash1, // in/out: in seed 1, out hash value 1
24+
uint64 *hash2); // in/out: in seed 2, out hash value 2
2525

2626
void *SpookyHasherNew();
2727

2828
void SpookyHasherFree(void *h);
2929

3030
void SpookyHasherInit(
3131
void *h,
32-
uint64 seed1, // any 64-bit value will do, including 0
33-
uint64 seed2); // different seeds produce independent hashes
32+
uint64 seed1, // any 64-bit value will do, including 0
33+
uint64 seed2); // different seeds produce independent hashes
3434

3535
void SpookyHasherUpdate(
3636
void *h,
37-
const void *message, // message fragment
38-
size_t length); // length of message fragment in bytes
37+
const void *message, // message fragment
38+
size_t length); // length of message fragment in bytes
3939

4040
void SpookyHasherFinal(
4141
void *h,
42-
uint64 *hash1, // out only: first 64 bits of hash value.
43-
uint64 *hash2); // out only: second 64 bits of hash value.
42+
uint64 *hash1, // out only: first 64 bits of hash value.
43+
uint64 *hash2); // out only: second 64 bits of hash value.

fasthash-sys/src/fasthash_linux.rs

Lines changed: 48 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
// automatically generated by rust-bindgen
1+
/* automatically generated by rust-bindgen */
22

33
#[repr(C)]
44
#[derive(Debug, Copy, Clone)]
55
pub struct pair<_T1, _T2> {
66
pub first: _T1,
77
pub second: _T2,
8+
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<_T1>>,
9+
pub _phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell<_T2>>,
810
}
911
pub type pair_first_type<_T1> = _T1;
1012
pub type pair_second_type<_T2> = _T2;
@@ -71,8 +73,12 @@ pub struct uint128_c_t {
7173
}
7274
#[test]
7375
fn bindgen_test_layout_uint128_c_t() {
74-
assert_eq!(::std::mem::size_of::<uint128_c_t>(), 16usize);
75-
assert_eq!(::std::mem::align_of::<uint128_c_t>(), 8usize);
76+
assert_eq!(::std::mem::size_of::<uint128_c_t>(),
77+
16usize,
78+
concat!("Size of: ", stringify!(uint128_c_t)));
79+
assert_eq!(::std::mem::align_of::<uint128_c_t>(),
80+
8usize,
81+
concat!("Alignment of ", stringify!(uint128_c_t)));
7682
}
7783
impl Clone for uint128_c_t {
7884
fn clone(&self) -> Self {
@@ -110,10 +116,6 @@ extern "C" {
110116
seed: uint128_c_t)
111117
-> uint128_c_t;
112118
}
113-
extern "C" {
114-
#[link_name = "_Z17farmhash128_to_6411uint128_c_t"]
115-
pub fn farmhash128_to_64(x: uint128_c_t) -> u64;
116-
}
117119
extern "C" {
118120
pub fn farmhash_fingerprint32(s: *const ::std::os::raw::c_char, len: usize) -> u32;
119121
}
@@ -123,14 +125,6 @@ extern "C" {
123125
extern "C" {
124126
pub fn farmhash_fingerprint128(s: *const ::std::os::raw::c_char, len: usize) -> uint128_c_t;
125127
}
126-
extern "C" {
127-
#[link_name = "_Z32farmhash_fingerprint_uint128_c_t11uint128_c_t"]
128-
pub fn farmhash_fingerprint_uint128_c_t(x: uint128_c_t) -> u64;
129-
}
130-
extern "C" {
131-
#[link_name = "_Z29farmhash_fingerprint_uint64_tm"]
132-
pub fn farmhash_fingerprint_uint64_t(x: u64) -> u64;
133-
}
134128
extern "C" {
135129
#[link_name = "_Z13metrohash64_1PKhmjPh"]
136130
pub fn metrohash64_1(key: *const u8, len: u64, seed: u32, out: *mut u8);
@@ -163,30 +157,6 @@ extern "C" {
163157
#[link_name = "_Z17metrohash128crc_2PKhmjPh"]
164158
pub fn metrohash128crc_2(key: *const u8, len: u64, seed: u32, out: *mut u8);
165159
}
166-
extern "C" {
167-
#[link_name = "_ZL18mum_hash_randomizem"]
168-
pub fn mum_hash_randomize(seed: u64);
169-
}
170-
extern "C" {
171-
#[link_name = "_ZL13mum_hash_initm"]
172-
pub fn mum_hash_init(seed: u64) -> u64;
173-
}
174-
extern "C" {
175-
#[link_name = "_ZL13mum_hash_stepmm"]
176-
pub fn mum_hash_step(h: u64, key: u64) -> u64;
177-
}
178-
extern "C" {
179-
#[link_name = "_ZL15mum_hash_finishm"]
180-
pub fn mum_hash_finish(h: u64) -> u64;
181-
}
182-
extern "C" {
183-
#[link_name = "_ZL10mum_hash64mm"]
184-
pub fn mum_hash64(key: u64, seed: u64) -> usize;
185-
}
186-
extern "C" {
187-
#[link_name = "_ZL8mum_hashPKvmm"]
188-
pub fn mum_hash(key: *const ::std::os::raw::c_void, len: usize, seed: u64) -> u64;
189-
}
190160
extern "C" {
191161
#[link_name = "_Z11MurmurHash1PKvij"]
192162
pub fn MurmurHash1(key: *const ::std::os::raw::c_void,
@@ -270,10 +240,6 @@ extern "C" {
270240
extern "C" {
271241
pub fn t1ha_64be(data: *const ::std::os::raw::c_void, len: usize, seed: u64) -> u64;
272242
}
273-
extern "C" {
274-
#[link_name = "_Z9t1ha_64lePKvmm"]
275-
pub fn t1ha_64le(data: *const ::std::os::raw::c_void, len: usize, seed: u64) -> u64;
276-
}
277243
extern "C" {
278244
pub fn t1ha_32le(data: *const ::std::os::raw::c_void, len: usize, seed: u64) -> u64;
279245
}
@@ -283,22 +249,19 @@ extern "C" {
283249
extern "C" {
284250
pub fn t1ha_ia32crc(data: *const ::std::os::raw::c_void, len: usize, seed: u64) -> u64;
285251
}
286-
pub const XXH_OK: _bindgen_ty_64 = _bindgen_ty_64::XXH_OK;
287-
pub const XXH_ERROR: _bindgen_ty_64 = _bindgen_ty_64::XXH_ERROR;
288252
#[repr(u32)]
289-
/// ***************************
290-
/// Type
291-
/// **************************
253+
/*****************************
254+
Type
255+
*****************************/
292256
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
293-
pub enum _bindgen_ty_64 {
257+
pub enum XXH_errorcode {
294258
XXH_OK = 0,
295259
XXH_ERROR = 1,
296260
}
297-
pub type XXH_errorcode = _bindgen_ty_64;
298261
extern "C" {
299-
/// ***************************
300-
/// Simple Hash Functions
301-
/// **************************
262+
/*****************************
263+
Simple Hash Functions
264+
*****************************/
302265
pub fn XXH32(input: *const ::std::os::raw::c_void,
303266
length: usize,
304267
seed: ::std::os::raw::c_uint)
@@ -310,41 +273,47 @@ extern "C" {
310273
seed: ::std::os::raw::c_ulonglong)
311274
-> ::std::os::raw::c_ulonglong;
312275
}
313-
/// ***************************
314-
/// Advanced Hash Functions
315-
/// **************************
276+
/*****************************
277+
Advanced Hash Functions
278+
*****************************/
316279
#[repr(C)]
317280
#[derive(Debug, Copy)]
318-
pub struct _bindgen_ty_65 {
281+
pub struct XXH32_state_t {
319282
pub ll: [::std::os::raw::c_longlong; 6usize],
320283
}
321284
#[test]
322-
fn bindgen_test_layout__bindgen_ty_65() {
323-
assert_eq!(::std::mem::size_of::<_bindgen_ty_65>(), 48usize);
324-
assert_eq!(::std::mem::align_of::<_bindgen_ty_65>(), 8usize);
325-
}
326-
impl Clone for _bindgen_ty_65 {
285+
fn bindgen_test_layout_XXH32_state_t() {
286+
assert_eq!(::std::mem::size_of::<XXH32_state_t>(),
287+
48usize,
288+
concat!("Size of: ", stringify!(XXH32_state_t)));
289+
assert_eq!(::std::mem::align_of::<XXH32_state_t>(),
290+
8usize,
291+
concat!("Alignment of ", stringify!(XXH32_state_t)));
292+
}
293+
impl Clone for XXH32_state_t {
327294
fn clone(&self) -> Self {
328295
*self
329296
}
330297
}
331-
pub type XXH32_state_t = _bindgen_ty_65;
332298
#[repr(C)]
333299
#[derive(Debug, Copy)]
334-
pub struct _bindgen_ty_66 {
300+
pub struct XXH64_state_t {
335301
pub ll: [::std::os::raw::c_longlong; 11usize],
336302
}
337303
#[test]
338-
fn bindgen_test_layout__bindgen_ty_66() {
339-
assert_eq!(::std::mem::size_of::<_bindgen_ty_66>(), 88usize);
340-
assert_eq!(::std::mem::align_of::<_bindgen_ty_66>(), 8usize);
341-
}
342-
impl Clone for _bindgen_ty_66 {
304+
fn bindgen_test_layout_XXH64_state_t() {
305+
assert_eq!(::std::mem::size_of::<XXH64_state_t>(),
306+
88usize,
307+
concat!("Size of: ", stringify!(XXH64_state_t)));
308+
assert_eq!(::std::mem::align_of::<XXH64_state_t>(),
309+
8usize,
310+
concat!("Alignment of ", stringify!(XXH64_state_t)));
311+
}
312+
impl Clone for XXH64_state_t {
343313
fn clone(&self) -> Self {
344314
*self
345315
}
346316
}
347-
pub type XXH64_state_t = _bindgen_ty_66;
348317
extern "C" {
349318
pub fn XXH32_createState() -> *mut XXH32_state_t;
350319
}
@@ -436,9 +405,15 @@ extern "C" {
436405
hash2: *mut uint64);
437406
}
438407
#[test]
439-
fn __bindgen_test_layout_template_1() {
408+
fn __bindgen_test_layout_pair_instantiation_7216() {
440409
assert_eq!(::std::mem::size_of::<pair<::std::os::raw::c_ulong, ::std::os::raw::c_ulong>>(),
441-
16usize);
410+
16usize,
411+
concat!("Size of template specialization: ",
412+
stringify ! (
413+
pair<::std::os::raw::c_ulong, ::std::os::raw::c_ulong> )));
442414
assert_eq!(::std::mem::align_of::<pair<::std::os::raw::c_ulong, ::std::os::raw::c_ulong>>(),
443-
8usize);
415+
8usize,
416+
concat!("Alignment of template specialization: ",
417+
stringify ! (
418+
pair<::std::os::raw::c_ulong, ::std::os::raw::c_ulong> )));
444419
}

0 commit comments

Comments
 (0)