xxhash_sys/
lib.rs

1#![allow(bad_style)]
2
3extern crate libc;
4
5use libc::{c_void, size_t, c_uint, c_ulonglong, c_uchar, c_longlong};
6
7#[cfg(target_env = "msvc")]
8type __enum_ty = libc::c_int;
9#[cfg(not(target_env = "msvc"))]
10type __enum_ty = libc::c_uint;
11pub type XXH32_hash_t = c_uint;
12pub type XXH64_hash_t = c_ulonglong;
13pub type XXH_errorcode = __enum_ty;
14
15pub const XXH_OK: XXH_errorcode = 0;
16pub const XXH_ERROR: XXH_errorcode = 1;
17
18pub enum XXH32_state_t {}
19pub enum XXH64_state_t {}
20
21#[repr(C)]
22#[derive(Copy, Clone)]
23pub struct XXH32_stateBody_t {
24    pub ll: [c_longlong; 6],
25}
26
27#[repr(C)]
28#[derive(Copy, Clone)]
29pub struct XXH64_stateBody_t {
30    pub ll: [c_longlong; 11],
31}
32
33#[repr(C)]
34pub struct XXH32_canonical_t {
35    pub digest: [c_uchar; 4],
36}
37
38#[repr(C)]
39pub struct XXH64_canonical_t {
40    pub digest: [c_uchar; 8],
41}
42
43extern {
44    #[link_name = "__rust_xxhash_sys_XXH32"]
45    pub fn XXH32(input: *const c_void,
46                 length: size_t,
47                 seed: c_uint) -> XXH32_hash_t;
48    #[link_name = "__rust_xxhash_sys_XXH64"]
49    pub fn XXH64(input: *const c_void,
50                 length: size_t,
51                 seed: c_ulonglong) -> XXH64_hash_t;
52
53    #[link_name = "__rust_xxhash_sys_XXH32_createState"]
54    pub fn XXH32_createState() -> *mut XXH32_state_t;
55    #[link_name = "__rust_xxhash_sys_XXH32_freeState"]
56    pub fn XXH32_freeState(ptr: *mut XXH32_state_t) -> XXH_errorcode;
57    #[link_name = "__rust_xxhash_sys_XXH64_createState"]
58    pub fn XXH64_createState() -> *mut XXH64_state_t;
59    #[link_name = "__rust_xxhash_sys_XXH64_freeState"]
60    pub fn XXH64_freeState(ptr: *mut XXH64_state_t) -> XXH_errorcode;
61
62    #[link_name = "__rust_xxhash_sys_XXH32_reset"]
63    pub fn XXH32_reset(statePtr: *mut XXH32_state_t,
64                       seed: c_uint) -> XXH_errorcode;
65    #[link_name = "__rust_xxhash_sys_XXH32_update"]
66    pub fn XXH32_update(statePtr: *mut XXH32_state_t,
67                        input: *const c_void,
68                        length: size_t) -> XXH_errorcode;
69    #[link_name = "__rust_xxhash_sys_XXH32_digest"]
70    pub fn XXH32_digest(statePtr: *const XXH32_state_t) -> XXH32_hash_t;
71
72    #[link_name = "__rust_xxhash_sys_XXH64_reset"]
73    pub fn XXH64_reset(statePtr: *mut XXH64_state_t,
74                       seed: c_ulonglong) -> XXH_errorcode;
75    #[link_name = "__rust_xxhash_sys_XXH64_update"]
76    pub fn XXH64_update(statePtr: *mut XXH64_state_t,
77                        input: *const c_void,
78                        length: size_t) -> XXH_errorcode;
79    #[link_name = "__rust_xxhash_sys_XXH64_digest"]
80    pub fn XXH64_digest(statePtr: *const XXH64_state_t) -> XXH64_hash_t;
81
82    // apis that aren't namespaced?!
83
84    pub fn XXH32_canonicalFromHash(dst: *mut XXH32_canonical_t,
85                                   hash: XXH32_hash_t);
86    pub fn XXH64_canonicalFromHash(dst: *mut XXH64_canonical_t,
87                                   hash: XXH64_hash_t);
88
89    pub fn XXH32_hashFromCanonical(src: *const XXH32_canonical_t)
90                                   -> XXH32_hash_t;
91    pub fn XXH64_hashFromCanonical(src: *const XXH64_canonical_t)
92                                   -> XXH64_hash_t;
93}