/* * xxHash - Extremely Fast Hash algorithm * Copyright (C) 2012-2016, Yann Collet. * * BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 2 as published by the * Free Software Foundation. This program is dual-licensed; you may select * either version 2 of the GNU General Public License ("GPL") or BSD license * ("BSD"). * * You can contact the author at: * - xxHash homepage: https://cyan4973.github.io/xxHash/ * - xxHash source repository: https://github.com/Cyan4973/xxHash */ #include <asm/unaligned.h> #include <linux/errno.h> #include <linux/compiler.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/string.h> #include <linux/xxhash.h> /*-************************************* * Macros **************************************/ #define xxh_rotl32(x, r) … #define xxh_rotl64(x, r) … #ifdef __LITTLE_ENDIAN #define XXH_CPU_LITTLE_ENDIAN … #else #define XXH_CPU_LITTLE_ENDIAN … #endif /*-************************************* * Constants **************************************/ static const uint32_t PRIME32_1 = …; static const uint32_t PRIME32_2 = …; static const uint32_t PRIME32_3 = …; static const uint32_t PRIME32_4 = …; static const uint32_t PRIME32_5 = …; static const uint64_t PRIME64_1 = …; static const uint64_t PRIME64_2 = …; static const uint64_t PRIME64_3 = …; static const uint64_t PRIME64_4 = …; static const uint64_t PRIME64_5 = …; /*-************************** * Utils ***************************/ void xxh32_copy_state(struct xxh32_state *dst, const struct xxh32_state *src) { … } EXPORT_SYMBOL(…); void xxh64_copy_state(struct xxh64_state *dst, const struct xxh64_state *src) { … } EXPORT_SYMBOL(…); /*-*************************** * Simple Hash Functions ****************************/ static uint32_t xxh32_round(uint32_t seed, const uint32_t input) { … } uint32_t xxh32(const void *input, const size_t len, const uint32_t seed) { … } EXPORT_SYMBOL(…); static uint64_t xxh64_round(uint64_t acc, const uint64_t input) { … } static uint64_t xxh64_merge_round(uint64_t acc, uint64_t val) { … } uint64_t xxh64(const void *input, const size_t len, const uint64_t seed) { … } EXPORT_SYMBOL(…); /*-************************************************** * Advanced Hash Functions ***************************************************/ void xxh32_reset(struct xxh32_state *statePtr, const uint32_t seed) { … } EXPORT_SYMBOL(…); void xxh64_reset(struct xxh64_state *statePtr, const uint64_t seed) { … } EXPORT_SYMBOL(…); int xxh32_update(struct xxh32_state *state, const void *input, const size_t len) { … } EXPORT_SYMBOL(…); uint32_t xxh32_digest(const struct xxh32_state *state) { … } EXPORT_SYMBOL(…); int xxh64_update(struct xxh64_state *state, const void *input, const size_t len) { … } EXPORT_SYMBOL(…); uint64_t xxh64_digest(const struct xxh64_state *state) { … } EXPORT_SYMBOL(…); MODULE_LICENSE(…) …; MODULE_DESCRIPTION(…) …;