1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#![allow(bad_style)]

extern crate libc;

use libc::{c_void, size_t, c_uint, c_ulonglong, c_uchar, c_longlong};

#[cfg(target_env = "msvc")]
type __enum_ty = libc::c_int;
#[cfg(not(target_env = "msvc"))]
type __enum_ty = libc::c_uint;
pub type XXH32_hash_t = c_uint;
pub type XXH64_hash_t = c_ulonglong;
pub type XXH_errorcode = __enum_ty;

pub const XXH_OK: XXH_errorcode = 0;
pub const XXH_ERROR: XXH_errorcode = 1;

pub enum XXH32_state_t {}
pub enum XXH64_state_t {}

#[repr(C)]
#[derive(Copy, Clone)]
pub struct XXH32_stateBody_t {
    pub ll: [c_longlong; 6],
}

#[repr(C)]
#[derive(Copy, Clone)]
pub struct XXH64_stateBody_t {
    pub ll: [c_longlong; 11],
}

#[repr(C)]
pub struct XXH32_canonical_t {
    pub digest: [c_uchar; 4],
}

#[repr(C)]
pub struct XXH64_canonical_t {
    pub digest: [c_uchar; 8],
}

extern {
    #[link_name = "__rust_xxhash_sys_XXH32"]
    pub fn XXH32(input: *const c_void,
                 length: size_t,
                 seed: c_uint) -> XXH32_hash_t;
    #[link_name = "__rust_xxhash_sys_XXH64"]
    pub fn XXH64(input: *const c_void,
                 length: size_t,
                 seed: c_ulonglong) -> XXH64_hash_t;

    #[link_name = "__rust_xxhash_sys_XXH32_createState"]
    pub fn XXH32_createState() -> *mut XXH32_state_t;
    #[link_name = "__rust_xxhash_sys_XXH32_freeState"]
    pub fn XXH32_freeState(ptr: *mut XXH32_state_t) -> XXH_errorcode;
    #[link_name = "__rust_xxhash_sys_XXH64_createState"]
    pub fn XXH64_createState() -> *mut XXH64_state_t;
    #[link_name = "__rust_xxhash_sys_XXH64_freeState"]
    pub fn XXH64_freeState(ptr: *mut XXH64_state_t) -> XXH_errorcode;

    #[link_name = "__rust_xxhash_sys_XXH32_reset"]
    pub fn XXH32_reset(statePtr: *mut XXH32_state_t,
                       seed: c_uint) -> XXH_errorcode;
    #[link_name = "__rust_xxhash_sys_XXH32_update"]
    pub fn XXH32_update(statePtr: *mut XXH32_state_t,
                        input: *const c_void,
                        length: size_t) -> XXH_errorcode;
    #[link_name = "__rust_xxhash_sys_XXH32_digest"]
    pub fn XXH32_digest(statePtr: *const XXH32_state_t) -> XXH32_hash_t;

    #[link_name = "__rust_xxhash_sys_XXH64_reset"]
    pub fn XXH64_reset(statePtr: *mut XXH64_state_t,
                       seed: c_ulonglong) -> XXH_errorcode;
    #[link_name = "__rust_xxhash_sys_XXH64_update"]
    pub fn XXH64_update(statePtr: *mut XXH64_state_t,
                        input: *const c_void,
                        length: size_t) -> XXH_errorcode;
    #[link_name = "__rust_xxhash_sys_XXH64_digest"]
    pub fn XXH64_digest(statePtr: *const XXH64_state_t) -> XXH64_hash_t;

    // apis that aren't namespaced?!

    pub fn XXH32_canonicalFromHash(dst: *mut XXH32_canonical_t,
                                   hash: XXH32_hash_t);
    pub fn XXH64_canonicalFromHash(dst: *mut XXH64_canonical_t,
                                   hash: XXH64_hash_t);

    pub fn XXH32_hashFromCanonical(src: *const XXH32_canonical_t)
                                   -> XXH32_hash_t;
    pub fn XXH64_hashFromCanonical(src: *const XXH64_canonical_t)
                                   -> XXH64_hash_t;
}