libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
Loading...
Searching...
No Matches
StrHash64.h
Go to the documentation of this file.
1#pragma once
2
3/*
4 * Below are the various copyright notices from the original source.
5 * <http://www.mirrorservice.org/sites/download.sourceforge.net/pub/
6 * sourceforge/l/li/libcore/libcore_0.22.7.tar.gz/libcore/lib/hash/Crc.cpp>
7 *
8 * The source has be substationally modified:
9 * 1. Unneeded code has been deleted.
10 * 2. The code was converted from C++ to C.
11 * 3. Routines optimized for hashing were added.
12 */
14//
15// Copyright (c) 2006 Anton Samokhvalov
16//
17// Permission is hereby granted, free of charge, to any person obtaining a copy
18// of this software and associated documentation files (the "Software"), to deal
19// in the Software without restriction, including without limitation the rights
20// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21// copies of the Software, and to permit persons to whom the Software is
22// furnished to do so, subject to the following conditions:
23//
24// The above copyright notice and this permission notice shall be included in
25// all copies or substantial portions of the Software.
26//
27// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
33// THE SOFTWARE.
34//
36/*
37 [To some parts of this code]
38*/
39/*
40 Copyright (C) 1995-2004 Jean-loup Gailly and Mark Adler
41 This software is provided 'as-is', without any express or implied
42 warranty. In no event will the authors be held liable for any damages
43 arising from the use of this software.
44 Permission is granted to anyone to use this software for any purpose,
45 including commercial applications, and to alter it and redistribute it
46 freely, subject to the following restrictions:
47 1. The origin of this software must not be misrepresented; you must not
48 claim that you wrote the original software. If you use this software
49 in a product, an acknowledgment in the product documentation would be
50 appreciated but is not required.
51 2. Altered source versions must be plainly marked as such, and must not be
52 misrepresented as being the original software.
53 3. This notice may not be removed or altered from any source distribution.
54 Jean-loup Gailly Mark Adler
56*/
57/*
58 [To some parts of this code]
59*/
60/*
61 Copyright (c) 2003, Dominik Reichl <[email protected]>
62 All rights reserved.
63 LICENSE TERMS
64 Redistribution and use in source and binary forms, with or without
65 modification, are permitted provided that the following conditions are met:
66 * Redistributions of source code must retain the above copyright notice, this
67 list of conditions and the following disclaimer.
68 * Redistributions in binary form must reproduce the above copyright notice,
69 this list of conditions and the following disclaimer in the documentation
70 and/or other materials provided with the distribution.
71 * Neither the name of ReichlSoft nor the names of its contributors may be used
72 to endorse or promote products derived from this software without specific
73 prior written permission.
74 DISCLAIMER
75 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
76 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
77 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
78 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
79 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
80 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
81 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
82 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
83 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
84 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
85*/
86
87#include <stdint.h>
88
90#define INITIAL_CRC64 0xffffffffffffffffULL
91
107extern uint64_t update_crc64(const void* buf, uint32_t len, uint64_t crc);
108
118extern uint64_t crc64(const void* buf, uint32_t len);
119
129extern uint64_t CRC64(const char* t);
uint64_t update_crc64(const void *buf, uint32_t len, uint64_t crc)
Updates a running CRC64 checksum with len bytes from buf.
uint64_t CRC64(const char *t)
Computes the CRC64 of a null-terminated string t.
uint64_t crc64(const void *buf, uint32_t len)
Computes the CRC64 of len bytes starting at buf.