[+] CRC32 and CRC16

[*] Moved auFNV1Utils.hpp to auFNV1.hpp
This commit is contained in:
Reece Wilson 2024-10-19 01:30:19 +01:00
parent c485937918
commit a649d82fd0
5 changed files with 1250 additions and 290 deletions

View File

@ -0,0 +1,11 @@
/***
Copyright (C) 2022-2024 Jamie Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Hashing.hpp
Date: 2024-09-21
Author: Reece
***/
#pragma once
#include "auFNV1.hpp"
#include "auCRC.hpp"

View File

@ -0,0 +1,934 @@
/***
Copyright (C) 2022-2024 Jamie Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auCRC.hpp
Date: 2024-09-21
Author: Reece
Notes: CRC, in practice, is a mess of chinese whispers.
https://github.com/Michaelangel007/crc32 http://www.mrob.com/pub/comp/crc-all.html makecrc.c:"This program will write six C routines for the calculation of..."
Contained within this file are the building blocks of CRC that everybody ends up using in different sometimes broken ways.
***/
#pragma once
#include <auROXTL/auTypeUtils.hpp>
#include <auROXTL/auBitsUtils.hpp>
#if !defined(_AU_CRC_PLATFORM_NO_PREFER_TBL)
#define _AU_CRC_PLATFORM_NO_PREFER_TBL 0
#endif
namespace __audetail
{
static const constexpr AuUInt32 kCRC32LookupTableBZipBackwards[256] = {
#if defined(AU_CPU_ENDIAN_LITTLE)
0x0L, 0x4C11DB7L, 0x9823B6EL, 0xD4326D9L, 0x130476DCL, 0x17C56B6BL, 0x1A864DB2L, 0x1E475005L,
0x2608EDB8L, 0x22C9F00FL, 0x2F8AD6D6L, 0x2B4BCB61L, 0x350C9B64L, 0x31CD86D3L, 0x3C8EA00AL, 0x384FBDBDL,
0x4C11DB70L, 0x48D0C6C7L, 0x4593E01EL, 0x4152FDA9L, 0x5F15ADACL, 0x5BD4B01BL, 0x569796C2L, 0x52568B75L,
0x6A1936C8L, 0x6ED82B7FL, 0x639B0DA6L, 0x675A1011L, 0x791D4014L, 0x7DDC5DA3L, 0x709F7B7AL, 0x745E66CDL,
0x9823B6E0L, 0x9CE2AB57L, 0x91A18D8EL, 0x95609039L, 0x8B27C03CL, 0x8FE6DD8BL, 0x82A5FB52L, 0x8664E6E5L,
0xBE2B5B58L, 0xBAEA46EFL, 0xB7A96036L, 0xB3687D81L, 0xAD2F2D84L, 0xA9EE3033L, 0xA4AD16EAL, 0xA06C0B5DL,
0xD4326D90L, 0xD0F37027L, 0xDDB056FEL, 0xD9714B49L, 0xC7361B4CL, 0xC3F706FBL, 0xCEB42022L, 0xCA753D95L,
0xF23A8028L, 0xF6FB9D9FL, 0xFBB8BB46L, 0xFF79A6F1L, 0xE13EF6F4L, 0xE5FFEB43L, 0xE8BCCD9AL, 0xEC7DD02DL,
0x34867077L, 0x30476DC0L, 0x3D044B19L, 0x39C556AEL, 0x278206ABL, 0x23431B1CL, 0x2E003DC5L, 0x2AC12072L,
0x128E9DCFL, 0x164F8078L, 0x1B0CA6A1L, 0x1FCDBB16L, 0x18AEB13L, 0x54BF6A4L, 0x808D07DL, 0xCC9CDCAL,
0x7897AB07L, 0x7C56B6B0L, 0x71159069L, 0x75D48DDEL, 0x6B93DDDBL, 0x6F52C06CL, 0x6211E6B5L, 0x66D0FB02L,
0x5E9F46BFL, 0x5A5E5B08L, 0x571D7DD1L, 0x53DC6066L, 0x4D9B3063L, 0x495A2DD4L, 0x44190B0DL, 0x40D816BAL,
0xACA5C697L, 0xA864DB20L, 0xA527FDF9L, 0xA1E6E04EL, 0xBFA1B04BL, 0xBB60ADFCL, 0xB6238B25L, 0xB2E29692L,
0x8AAD2B2FL, 0x8E6C3698L, 0x832F1041L, 0x87EE0DF6L, 0x99A95DF3L, 0x9D684044L, 0x902B669DL, 0x94EA7B2AL,
0xE0B41DE7L, 0xE4750050L, 0xE9362689L, 0xEDF73B3EL, 0xF3B06B3BL, 0xF771768CL, 0xFA325055L, 0xFEF34DE2L,
0xC6BCF05FL, 0xC27DEDE8L, 0xCF3ECB31L, 0xCBFFD686L, 0xD5B88683L, 0xD1799B34L, 0xDC3ABDEDL, 0xD8FBA05AL,
0x690CE0EEL, 0x6DCDFD59L, 0x608EDB80L, 0x644FC637L, 0x7A089632L, 0x7EC98B85L, 0x738AAD5CL, 0x774BB0EBL,
0x4F040D56L, 0x4BC510E1L, 0x46863638L, 0x42472B8FL, 0x5C007B8AL, 0x58C1663DL, 0x558240E4L, 0x51435D53L,
0x251D3B9EL, 0x21DC2629L, 0x2C9F00F0L, 0x285E1D47L, 0x36194D42L, 0x32D850F5L, 0x3F9B762CL, 0x3B5A6B9BL,
0x315D626L, 0x7D4CB91L, 0xA97ED48L, 0xE56F0FFL, 0x1011A0FAL, 0x14D0BD4DL, 0x19939B94L, 0x1D528623L,
0xF12F560EL, 0xF5EE4BB9L, 0xF8AD6D60L, 0xFC6C70D7L, 0xE22B20D2L, 0xE6EA3D65L, 0xEBA91BBCL, 0xEF68060BL,
0xD727BBB6L, 0xD3E6A601L, 0xDEA580D8L, 0xDA649D6FL, 0xC423CD6AL, 0xC0E2D0DDL, 0xCDA1F604L, 0xC960EBB3L,
0xBD3E8D7EL, 0xB9FF90C9L, 0xB4BCB610L, 0xB07DABA7L, 0xAE3AFBA2L, 0xAAFBE615L, 0xA7B8C0CCL, 0xA379DD7BL,
0x9B3660C6L, 0x9FF77D71L, 0x92B45BA8L, 0x9675461FL, 0x8832161AL, 0x8CF30BADL, 0x81B02D74L, 0x857130C3L,
0x5D8A9099L, 0x594B8D2EL, 0x5408ABF7L, 0x50C9B640L, 0x4E8EE645L, 0x4A4FFBF2L, 0x470CDD2BL, 0x43CDC09CL,
0x7B827D21L, 0x7F436096L, 0x7200464FL, 0x76C15BF8L, 0x68860BFDL, 0x6C47164AL, 0x61043093L, 0x65C52D24L,
0x119B4BE9L, 0x155A565EL, 0x18197087L, 0x1CD86D30L, 0x29F3D35L, 0x65E2082L, 0xB1D065BL, 0xFDC1BECL,
0x3793A651L, 0x3352BBE6L, 0x3E119D3FL, 0x3AD08088L, 0x2497D08DL, 0x2056CD3AL, 0x2D15EBE3L, 0x29D4F654L,
0xC5A92679L, 0xC1683BCEL, 0xCC2B1D17L, 0xC8EA00A0L, 0xD6AD50A5L, 0xD26C4D12L, 0xDF2F6BCBL, 0xDBEE767CL,
0xE3A1CBC1L, 0xE760D676L, 0xEA23F0AFL, 0xEEE2ED18L, 0xF0A5BD1DL, 0xF464A0AAL, 0xF9278673L, 0xFDE69BC4L,
0x89B8FD09L, 0x8D79E0BEL, 0x803AC667L, 0x84FBDBD0L, 0x9ABC8BD5L, 0x9E7D9662L, 0x933EB0BBL, 0x97FFAD0CL,
0xAFB010B1L, 0xAB710D06L, 0xA6322BDFL, 0xA2F33668L, 0xBCB4666DL, 0xB8757BDAL, 0xB5365D03L, 0xB1F740B4L
#else
0x0L, 0xB71DC104L, 0x6E3B8209L, 0xD926430DL, 0xDC760413L, 0x6B6BC517L, 0xB24D861AL, 0x550471EL,
0xB8ED0826L, 0xFF0C922L, 0xD6D68A2FL, 0x61CB4B2BL, 0x649B0C35L, 0xD386CD31L, 0xAA08E3CL, 0xBDBD4F38L,
0x70DB114CL, 0xC7C6D048L, 0x1EE09345L, 0xA9FD5241L, 0xACAD155FL, 0x1BB0D45BL, 0xC2969756L, 0x758B5652L,
0xC836196AL, 0x7F2BD86EL, 0xA60D9B63L, 0x11105A67L, 0x14401D79L, 0xA35DDC7DL, 0x7A7B9F70L, 0xCD665E74L,
0xE0B62398L, 0x57ABE29CL, 0x8E8DA191L, 0x39906095L, 0x3CC0278BL, 0x8BDDE68FL, 0x52FBA582L, 0xE5E66486L,
0x585B2BBEL, 0xEF46EABAL, 0x3660A9B7L, 0x817D68B3L, 0x842D2FADL, 0x3330EEA9L, 0xEA16ADA4L, 0x5D0B6CA0L,
0x906D32D4L, 0x2770F3D0L, 0xFE56B0DDL, 0x494B71D9L, 0x4C1B36C7L, 0xFB06F7C3L, 0x2220B4CEL, 0x953D75CAL,
0x28803AF2L, 0x9F9DFBF6L, 0x46BBB8FBL, 0xF1A679FFL, 0xF4F63EE1L, 0x43EBFFE5L, 0x9ACDBCE8L, 0x2DD07DECL,
0x77708634L, 0xC06D4730L, 0x194B043DL, 0xAE56C539L, 0xAB068227L, 0x1C1B4323L, 0xC53D002EL, 0x7220C12AL,
0xCF9D8E12L, 0x78804F16L, 0xA1A60C1BL, 0x16BBCD1FL, 0x13EB8A01L, 0xA4F64B05L, 0x7DD00808L, 0xCACDC90CL,
0x7AB9778L, 0xB0B6567CL, 0x69901571L, 0xDE8DD475L, 0xDBDD936BL, 0x6CC0526FL, 0xB5E61162L, 0x2FBD066L,
0xBF469F5EL, 0x85B5E5AL, 0xD17D1D57L, 0x6660DC53L, 0x63309B4DL, 0xD42D5A49L, 0xD0B1944L, 0xBA16D840L,
0x97C6A5ACL, 0x20DB64A8L, 0xF9FD27A5L, 0x4EE0E6A1L, 0x4BB0A1BFL, 0xFCAD60BBL, 0x258B23B6L, 0x9296E2B2L,
0x2F2BAD8AL, 0x98366C8EL, 0x41102F83L, 0xF60DEE87L, 0xF35DA999L, 0x4440689DL, 0x9D662B90L, 0x2A7BEA94L,
0xE71DB4E0L, 0x500075E4L, 0x892636E9L, 0x3E3BF7EDL, 0x3B6BB0F3L, 0x8C7671F7L, 0x555032FAL, 0xE24DF3FEL,
0x5FF0BCC6L, 0xE8ED7DC2L, 0x31CB3ECFL, 0x86D6FFCBL, 0x8386B8D5L, 0x349B79D1L, 0xEDBD3ADCL, 0x5AA0FBD8L,
0xEEE00C69L, 0x59FDCD6DL, 0x80DB8E60L, 0x37C64F64L, 0x3296087AL, 0x858BC97EL, 0x5CAD8A73L, 0xEBB04B77L,
0x560D044FL, 0xE110C54BL, 0x38368646L, 0x8F2B4742L, 0x8A7B005CL, 0x3D66C158L, 0xE4408255L, 0x535D4351L,
0x9E3B1D25L, 0x2926DC21L, 0xF0009F2CL, 0x471D5E28L, 0x424D1936L, 0xF550D832L, 0x2C769B3FL, 0x9B6B5A3BL,
0x26D61503L, 0x91CBD407L, 0x48ED970AL, 0xFFF0560EL, 0xFAA01110L, 0x4DBDD014L, 0x949B9319L, 0x2386521DL,
0xE562FF1L, 0xB94BEEF5L, 0x606DADF8L, 0xD7706CFCL, 0xD2202BE2L, 0x653DEAE6L, 0xBC1BA9EBL, 0xB0668EFL,
0xB6BB27D7L, 0x1A6E6D3L, 0xD880A5DEL, 0x6F9D64DAL, 0x6ACD23C4L, 0xDDD0E2C0L, 0x4F6A1CDL, 0xB3EB60C9L,
0x7E8D3EBDL, 0xC990FFB9L, 0x10B6BCB4L, 0xA7AB7DB0L, 0xA2FB3AAEL, 0x15E6FBAAL, 0xCCC0B8A7L, 0x7BDD79A3L,
0xC660369BL, 0x717DF79FL, 0xA85BB492L, 0x1F467596L, 0x1A163288L, 0xAD0BF38CL, 0x742DB081L, 0xC3307185L,
0x99908A5DL, 0x2E8D4B59L, 0xF7AB0854L, 0x40B6C950L, 0x45E68E4EL, 0xF2FB4F4AL, 0x2BDD0C47L, 0x9CC0CD43L,
0x217D827BL, 0x9660437FL, 0x4F460072L, 0xF85BC176L, 0xFD0B8668L, 0x4A16476CL, 0x93300461L, 0x242DC565L,
0xE94B9B11L, 0x5E565A15L, 0x87701918L, 0x306DD81CL, 0x353D9F02L, 0x82205E06L, 0x5B061D0BL, 0xEC1BDC0FL,
0x51A69337L, 0xE6BB5233L, 0x3F9D113EL, 0x8880D03AL, 0x8DD09724L, 0x3ACD5620L, 0xE3EB152DL, 0x54F6D429L,
0x7926A9C5L, 0xCE3B68C1L, 0x171D2BCCL, 0xA000EAC8L, 0xA550ADD6L, 0x124D6CD2L, 0xCB6B2FDFL, 0x7C76EEDBL,
0xC1CBA1E3L, 0x76D660E7L, 0xAFF023EAL, 0x18EDE2EEL, 0x1DBDA5F0L, 0xAAA064F4L, 0x738627F9L, 0xC49BE6FDL,
0x9FDB889L, 0xBEE0798DL, 0x67C63A80L, 0xD0DBFB84L, 0xD58BBC9AL, 0x62967D9EL, 0xBBB03E93L, 0xCADFF97L,
0xB110B0AFL, 0x60D71ABL, 0xDF2B32A6L, 0x6836F3A2L, 0x6D66B4BCL, 0xDA7B75B8L, 0x35D36B5L, 0xB440F7B1L
#endif
};
static const constexpr AuUInt32 kCRC32LookupTableIEE[256] = {
#if defined(AU_CPU_ENDIAN_LITTLE)
0x0L, 0x77073096L, 0xEE0E612CL, 0x990951BAL, 0x76DC419L, 0x706AF48FL, 0xE963A535L, 0x9E6495A3L,
0xEDB8832L, 0x79DCB8A4L, 0xE0D5E91EL, 0x97D2D988L, 0x9B64C2BL, 0x7EB17CBDL, 0xE7B82D07L, 0x90BF1D91L,
0x1DB71064L, 0x6AB020F2L, 0xF3B97148L, 0x84BE41DEL, 0x1ADAD47DL, 0x6DDDE4EBL, 0xF4D4B551L, 0x83D385C7L,
0x136C9856L, 0x646BA8C0L, 0xFD62F97AL, 0x8A65C9ECL, 0x14015C4FL, 0x63066CD9L, 0xFA0F3D63L, 0x8D080DF5L,
0x3B6E20C8L, 0x4C69105EL, 0xD56041E4L, 0xA2677172L, 0x3C03E4D1L, 0x4B04D447L, 0xD20D85FDL, 0xA50AB56BL,
0x35B5A8FAL, 0x42B2986CL, 0xDBBBC9D6L, 0xACBCF940L, 0x32D86CE3L, 0x45DF5C75L, 0xDCD60DCFL, 0xABD13D59L,
0x26D930ACL, 0x51DE003AL, 0xC8D75180L, 0xBFD06116L, 0x21B4F4B5L, 0x56B3C423L, 0xCFBA9599L, 0xB8BDA50FL,
0x2802B89EL, 0x5F058808L, 0xC60CD9B2L, 0xB10BE924L, 0x2F6F7C87L, 0x58684C11L, 0xC1611DABL, 0xB6662D3DL,
0x76DC4190L, 0x1DB7106L, 0x98D220BCL, 0xEFD5102AL, 0x71B18589L, 0x6B6B51FL, 0x9FBFE4A5L, 0xE8B8D433L,
0x7807C9A2L, 0xF00F934L, 0x9609A88EL, 0xE10E9818L, 0x7F6A0DBBL, 0x86D3D2DL, 0x91646C97L, 0xE6635C01L,
0x6B6B51F4L, 0x1C6C6162L, 0x856530D8L, 0xF262004EL, 0x6C0695EDL, 0x1B01A57BL, 0x8208F4C1L, 0xF50FC457L,
0x65B0D9C6L, 0x12B7E950L, 0x8BBEB8EAL, 0xFCB9887CL, 0x62DD1DDFL, 0x15DA2D49L, 0x8CD37CF3L, 0xFBD44C65L,
0x4DB26158L, 0x3AB551CEL, 0xA3BC0074L, 0xD4BB30E2L, 0x4ADFA541L, 0x3DD895D7L, 0xA4D1C46DL, 0xD3D6F4FBL,
0x4369E96AL, 0x346ED9FCL, 0xAD678846L, 0xDA60B8D0L, 0x44042D73L, 0x33031DE5L, 0xAA0A4C5FL, 0xDD0D7CC9L,
0x5005713CL, 0x270241AAL, 0xBE0B1010L, 0xC90C2086L, 0x5768B525L, 0x206F85B3L, 0xB966D409L, 0xCE61E49FL,
0x5EDEF90EL, 0x29D9C998L, 0xB0D09822L, 0xC7D7A8B4L, 0x59B33D17L, 0x2EB40D81L, 0xB7BD5C3BL, 0xC0BA6CADL,
0xEDB88320L, 0x9ABFB3B6L, 0x3B6E20CL, 0x74B1D29AL, 0xEAD54739L, 0x9DD277AFL, 0x4DB2615L, 0x73DC1683L,
0xE3630B12L, 0x94643B84L, 0xD6D6A3EL, 0x7A6A5AA8L, 0xE40ECF0BL, 0x9309FF9DL, 0xA00AE27L, 0x7D079EB1L,
0xF00F9344L, 0x8708A3D2L, 0x1E01F268L, 0x6906C2FEL, 0xF762575DL, 0x806567CBL, 0x196C3671L, 0x6E6B06E7L,
0xFED41B76L, 0x89D32BE0L, 0x10DA7A5AL, 0x67DD4ACCL, 0xF9B9DF6FL, 0x8EBEEFF9L, 0x17B7BE43L, 0x60B08ED5L,
0xD6D6A3E8L, 0xA1D1937EL, 0x38D8C2C4L, 0x4FDFF252L, 0xD1BB67F1L, 0xA6BC5767L, 0x3FB506DDL, 0x48B2364BL,
0xD80D2BDAL, 0xAF0A1B4CL, 0x36034AF6L, 0x41047A60L, 0xDF60EFC3L, 0xA867DF55L, 0x316E8EEFL, 0x4669BE79L,
0xCB61B38CL, 0xBC66831AL, 0x256FD2A0L, 0x5268E236L, 0xCC0C7795L, 0xBB0B4703L, 0x220216B9L, 0x5505262FL,
0xC5BA3BBEL, 0xB2BD0B28L, 0x2BB45A92L, 0x5CB36A04L, 0xC2D7FFA7L, 0xB5D0CF31L, 0x2CD99E8BL, 0x5BDEAE1DL,
0x9B64C2B0L, 0xEC63F226L, 0x756AA39CL, 0x26D930AL, 0x9C0906A9L, 0xEB0E363FL, 0x72076785L, 0x5005713L,
0x95BF4A82L, 0xE2B87A14L, 0x7BB12BAEL, 0xCB61B38L, 0x92D28E9BL, 0xE5D5BE0DL, 0x7CDCEFB7L, 0xBDBDF21ul,
0x86D3D2D4L, 0xF1D4E242L, 0x68DDB3F8L, 0x1FDA836EL, 0x81BE16CDL, 0xF6B9265BL, 0x6FB077E1L, 0x18B74777L,
0x88085AE6L, 0xFF0F6A70L, 0x66063BCAL, 0x11010B5CL, 0x8F659EFFL, 0xF862AE69L, 0x616BFFD3L, 0x166CCF45L,
0xA00AE278L, 0xD70DD2EEL, 0x4E048354L, 0x3903B3C2L, 0xA7672661L, 0xD06016F7L, 0x4969474DL, 0x3E6E77DBL,
0xAED16A4AL, 0xD9D65ADCL, 0x40DF0B66L, 0x37D83BF0L, 0xA9BCAE53L, 0xDEBB9EC5L, 0x47B2CF7FL, 0x30B5FFE9L,
0xBDBDF21CL, 0xCABAC28AL, 0x53B39330L, 0x24B4A3A6L, 0xBAD03605L, 0xCDD70693L, 0x54DE5729L, 0x23D967BFL,
0xB3667A2EL, 0xC4614AB8L, 0x5D681B02L, 0x2A6F2B94L, 0xB40BBE37L, 0xC30C8EA1L, 0x5A05DF1BL, 0x2D02EF8DL
#else
0x0L, 0x96300777L, 0x2C610EEEL, 0xBA510999L, 0x19C46D07L, 0x8FF46A70L, 0x35A563E9L, 0xA395649EL,
0x3288DB0EL, 0xA4B8DC79L, 0x1EE9D5E0L, 0x88D9D297L, 0x2B4CB609L, 0xBD7CB17EL, 0x72DB8E7L, 0x911DBF90L,
0x6410B71DL, 0xF220B06AL, 0x4871B9F3L, 0xDE41BE84L, 0x7DD4DA1AL, 0xEBE4DD6DL, 0x51B5D4F4L, 0xC785D383L,
0x56986C13L, 0xC0A86B64L, 0x7AF962FDL, 0xECC9658AL, 0x4F5C0114L, 0xD96C0663L, 0x633D0FFAL, 0xF50D088DL,
0xC8206E3BL, 0x5E10694CL, 0xE44160D5L, 0x727167A2L, 0xD1E4033CL, 0x47D4044BL, 0xFD850DD2L, 0x6BB50AA5L,
0xFAA8B535L, 0x6C98B242L, 0xD6C9BBDBL, 0x40F9BCACL, 0xE36CD832L, 0x755CDF45L, 0xCF0DD6DCL, 0x593DD1ABL,
0xAC30D926L, 0x3A00DE51L, 0x8051D7C8L, 0x1661D0BFL, 0xB5F4B421L, 0x23C4B356L, 0x9995BACFL, 0xFA5BDB8L,
0x9EB80228L, 0x888055FL, 0xB2D90CC6L, 0x24E90BB1L, 0x877C6F2FL, 0x114C6858L, 0xAB1D61C1L, 0x3D2D66B6L,
0x9041DC76L, 0x671DB01L, 0xBC20D298L, 0x2A10D5EFL, 0x8985B171L, 0x1FB5B606L, 0xA5E4BF9FL, 0x33D4B8E8L,
0xA2C90778L, 0x34F9000FL, 0x8EA80996L, 0x18980EE1L, 0xBB0D6A7FL, 0x2D3D6D08L, 0x976C6491L, 0x15C63E6L,
0xF4516B6BL, 0x62616C1CL, 0xD8306585L, 0x4E0062F2L, 0xED95066CL, 0x7BA5011BL, 0xC1F40882L, 0x57C40FF5L,
0xC6D9B065L, 0x50E9B712L, 0xEAB8BE8BL, 0x7C88B9FCL, 0xDF1DDD62L, 0x492DDA15L, 0xF37CD38CL, 0x654CD4FBL,
0x5861B24DL, 0xCE51B53AL, 0x7400BCA3L, 0xE230BBD4L, 0x41A5DF4AL, 0xD795D83DL, 0x6DC4D1A4L, 0xFBF4D6D3L,
0x6AE96943L, 0xFCD96E34L, 0x468867ADL, 0xD0B860DAL, 0x732D0444L, 0xE51D0333L, 0x5F4C0AAAL, 0xC97C0DDDL,
0x3C710550L, 0xAA410227L, 0x10100BBEL, 0x86200CC9L, 0x25B56857L, 0xB3856F20L, 0x9D466B9L, 0x9FE461CEL,
0xEF9DE5EL, 0x98C9D929L, 0x2298D0B0L, 0xB4A8D7C7L, 0x173DB359L, 0x810DB42EL, 0x3B5CBDB7L, 0xAD6CBAC0L,
0x2083B8EDL, 0xB6B3BF9AL, 0xCE2B603L, 0x9AD2B174L, 0x3947D5EAL, 0xAF77D29DL, 0x1526DB04L, 0x8316DC73L,
0x120B63E3L, 0x843B6494L, 0x3E6A6D0DL, 0xA85A6A7AL, 0xBCF0EE4L, 0x9DFF0993L, 0x27AE000AL, 0xB19E077DL,
0x44930FF0L, 0xD2A30887L, 0x68F2011EL, 0xFEC20669L, 0x5D5762F7L, 0xCB676580L, 0x71366C19L, 0xE7066B6EL,
0x761BD4FEL, 0xE02BD389L, 0x5A7ADA10L, 0xCC4ADD67L, 0x6FDFB9F9L, 0xF9EFBE8EL, 0x43BEB717L, 0xD58EB060L,
0xE8A3D6D6L, 0x7E93D1A1L, 0xC4C2D838L, 0x52F2DF4FL, 0xF167BBD1L, 0x6757BCA6L, 0xDD06B53FL, 0x4B36B248L,
0xDA2B0DD8L, 0x4C1B0AAFL, 0xF64A0336L, 0x607A0441L, 0xC3EF60DFL, 0x55DF67A8L, 0xEF8E6E31L, 0x79BE6946L,
0x8CB361CBL, 0x1A8366BCL, 0xA0D26F25L, 0x36E26852L, 0x95770CCCL, 0x3470BBBL, 0xB9160222L, 0x2F260555L,
0xBE3BBAC5L, 0x280BBDB2L, 0x925AB42BL, 0x46AB35CL, 0xA7FFD7C2L, 0x31CFD0B5L, 0x8B9ED92CL, 0x1DAEDE5BL,
0xB0C2649BL, 0x26F263ECL, 0x9CA36A75L, 0xA936D02L, 0xA906099CL, 0x3F360EEBL, 0x85670772L, 0x13570005L,
0x824ABF95L, 0x147AB8E2L, 0xAE2BB17BL, 0x381BB60CL, 0x9B8ED292L, 0xDBED5E5L, 0xB7EFDC7CL, 0x21DFDB0BL,
0xD4D2D386L, 0x42E2D4F1L, 0xF8B3DD68L, 0x6E83DA1FL, 0xCD16BE81L, 0x5B26B9F6L, 0xE177B06FL, 0x7747B718L,
0xE65A0888L, 0x706A0FFFL, 0xCA3B0666L, 0x5C0B0111L, 0xFF9E658FL, 0x69AE62F8L, 0xD3FF6B61L, 0x45CF6C16L,
0x78E20AA0L, 0xEED20DD7L, 0x5483044EL, 0xC2B30339L, 0x612667A7L, 0xF71660D0L, 0x4D476949L, 0xDB776E3EL,
0x4A6AD1AEL, 0xDC5AD6D9L, 0x660BDF40L, 0xF03BD837L, 0x53AEBCA9L, 0xC59EBBDEL, 0x7FCFB247L, 0xE9FFB530L,
0x1CF2BDBDL, 0x8AC2BACAL, 0x3093B353L, 0xA6A3B424L, 0x536D0BAL, 0x9306D7CDL, 0x2957DE54L, 0xBF67D923L,
0x2E7A66B3L, 0xB84A61C4L, 0x21B685DL, 0x942B6F2AL, 0x37BE0BB4L, 0xA18E0CC3L, 0x1BDF055AL, 0x8DEF022DL
#endif
};
}
static const constexpr AuUInt32 kCRC32PolynomialPolyBZIP = 0x04C11DB7;
static const constexpr AuUInt32 kCRC32PolynomialPolyCCITT32 = 0x04C11DB7;
static const constexpr AuUInt32 kCRC32PolynomialPolyIEEE = 0xEDB88320;
static const constexpr AuUInt32 kCRC32PolynomialPolyZIP = 0xEDB88320;
static const constexpr AuUInt16 kCRC16PolynomialBinHex = 0x1021;
static const constexpr AuUInt16 kCRC16PolynomialArc = 0xA001;
static const constexpr AuUInt16 kCRC16PolynomialKermit = 0x8408;
static const constexpr AuUInt16 kCRC16PolynomialCCITT = 0x1021;
static const constexpr AuUInt16 kCRC16PolynomialDefault = kCRC16PolynomialCCITT;
static const constexpr bool kCRC32IsSwappedPolyBZIP = false;
static const constexpr bool kCRC32IsSwappedPolyCCITT32 = false;
static const constexpr bool kCRC32IsSwappedPolyIEEE = false;
static const constexpr bool kCRC32IsSwappedPolyZIP = true;
static const constexpr bool kCRC16IsSwappedBinHex = false;
static const constexpr bool kCRC16IsSwappedArc = true;
static const constexpr bool kCRC16IsSwappedKermit = true;
static const constexpr bool kCRC16IsSwappedCCITT = false;
static const constexpr bool kCRC16IsSwappedDefault = kCRC16IsSwappedCCITT;
static const constexpr bool kCRC16IsSwappedDefacto = true;
static const constexpr AuUInt32 kCRC32SeedDefault = 0xFFFFFFFF;
static const constexpr AuUInt32 kCRC32SeedBZIP = kCRC32SeedDefault;
static const constexpr AuUInt32 kCRC32SeedCCITT32 = kCRC32SeedDefault;
static const constexpr AuUInt32 kCRC32SeedZIP = kCRC32SeedDefault;
static const constexpr AuUInt32 kCRC32SeedIEEE = kCRC32SeedDefault;
static const constexpr AuUInt16 kCRC16SeedDefacto = 0;
static const constexpr AuUInt16 kCRC16SeedBinHex = kCRC16SeedDefacto;
static const constexpr AuUInt16 kCRC16SeedArc = kCRC16SeedDefacto;
static const constexpr AuUInt16 kCRC16SeedKermit = kCRC16SeedDefacto;
static const constexpr AuUInt16 kCRC16SeedCCITT = 0xFFFF;
static const constexpr AuUInt16 kCRC16SeedDefault = kCRC16SeedCCITT;
AU_STATIC_CONSTEXPR_14 AuUInt32 AuCRC32Reverse32(const AuUInt32 x)
{
return AuBitReverse(x);
}
AU_STATIC_CONSTEXPR_14 AuUInt32 AuCRC32Reflect32(const AuUInt32 x)
{
return AuBitReverse(x);
}
AU_STATIC_CONSTEXPR_14 AuUInt32 AuCRC32Not32(const AuUInt32 x)
{
return x ^ 0xFFFFFFFF;
}
AU_STATIC_CONSTEXPR_14 AuUInt16 AuCRC16Reverse16(const AuUInt16 x)
{
return AuBitReverse(x);
}
AU_STATIC_CONSTEXPR_14 AuUInt16 AuCRC16Reflect16(const AuUInt16 x)
{
return AuBitReverse(x);
}
AU_STATIC_CONSTEXPR_14 AuUInt16 AuCRC16Not16(const AuUInt16 x)
{
return x ^ 0xFFFF;
}
AU_STATIC_CONSTEXPR_14 AuUInt32 AuCRC32Reverse(const AuUInt32 x)
{
return AuCRC32Reverse32(x);
}
AU_STATIC_CONSTEXPR_14 AuUInt32 AuCRC32Reflect(const AuUInt32 x)
{
return AuCRC32Reflect32(x);
}
AU_STATIC_CONSTEXPR_14 AuUInt32 AuCRC32Not(const AuUInt32 x)
{
return AuCRC32Not32(x);
}
AU_STATIC_CONSTEXPR_14 AuUInt16 AuCRC16Reverse(const AuUInt16 x)
{
return AuCRC16Reverse16(x);
}
AU_STATIC_CONSTEXPR_14 AuUInt16 AuCRC16Reflect(const AuUInt16 x)
{
return AuCRC16Reflect16(x);
}
AU_STATIC_CONSTEXPR_14 AuUInt16 AuCRC16Not(const AuUInt16 x)
{
return AuCRC16Not16(x);
}
template <AuUInt32 uPolynomial, bool bRightReverse>
AU_STATIC_CONSTEXPR_17 AuUInt32 AuCRC32RuntimeHashCompPoly(const char *pCharNoCast,
AuUInt32 uLength,
AuUInt32 uSneed)
{
for (AU_ITERATE_N(i, uLength))
{
auto uByte = pCharNoCast[uLength];
if constexpr (bRightReverse)
{
uSneed ^= uByte;
}
else
{
uSneed ^= uByte << 24;
}
for (AU_ITERATE_N(z, 8))
{
if constexpr (bRightReverse)
{
if (uSneed & 1)
{
uSneed = (uSneed >> 1) ^ uPolynomial;
}
else
{
uSneed >>= 1;
}
}
else
{
if (uSneed & 0x80000000)
{
uSneed = (uSneed << 1) ^ uPolynomial;
}
else
{
uSneed <<= 1;
}
}
}
}
return uSneed;
}
template <bool bRightReverse>
AU_STATIC_CONSTEXPR_17 AuUInt32 AuCRC32RuntimeHashRuntimePoly(const char *pCharNoCast,
AuUInt32 uLength,
AuUInt32 uSneed,
AuUInt32 uPolynomial)
{
// TODO: #if !defined(AU_CPU_ENDIAN_LITTLE) pro and epilog
for (AU_ITERATE_N(i, uLength))
{
auto uByte = pCharNoCast[uLength];
if constexpr (bRightReverse)
{
uSneed ^= uByte;
}
else
{
uSneed ^= uByte << 24;
}
for (AU_ITERATE_N(z, 8))
{
if constexpr (bRightReverse)
{
if (uSneed & 1)
{
uSneed = (uSneed >> 1) ^ uPolynomial;
}
else
{
uSneed >>= 1;
}
}
else
{
if (uSneed & 0x80000000)
{
uSneed = (uSneed << 1) ^ uPolynomial;
}
else
{
uSneed <<= 1;
}
}
}
}
return uSneed;
}
template <AuUInt16 uPolynomial, bool bRightReverse>
AU_STATIC_CONSTEXPR_17 AuUInt16 AuCRC16RuntimeHashCompPoly(const char *pCharNoCast,
AuUInt32 uLength,
AuUInt16 uSneed)
{
for (AU_ITERATE_N(i, uLength))
{
auto uByte = pCharNoCast[uLength];
if constexpr (bRightReverse)
{
uSneed ^= uByte;
}
else
{
uSneed ^= uByte << 8;
}
for (AU_ITERATE_N(z, 8))
{
if constexpr (bRightReverse)
{
if (uSneed & 1)
{
uSneed = (uSneed >> 1) ^ uPolynomial;
}
else
{
uSneed >>= 1;
}
}
else
{
if (uSneed & 0x8000)
{
uSneed = (uSneed << 1) ^ uPolynomial;
}
else
{
uSneed <<= 1;
}
}
}
}
return uSneed;
}
template <bool bRightReverse>
AU_STATIC_CONSTEXPR_17 AuUInt16 AuCRC16RuntimeHashRuntimePoly(const char *pCharNoCast,
AuUInt32 uLength,
AuUInt16 uSneed,
AuUInt16 uPolynomial)
{
// TODO: #if !defined(AU_CPU_ENDIAN_LITTLE) pro and epilog
for (AU_ITERATE_N(i, uLength))
{
auto uByte = pCharNoCast[uLength];
if constexpr (bRightReverse)
{
uSneed ^= uByte;
}
else
{
uSneed ^= uByte << 8;
}
for (AU_ITERATE_N(z, 8))
{
if constexpr (bRightReverse)
{
if (uSneed & 1)
{
uSneed = (uSneed >> 1) ^ uPolynomial;
}
else
{
uSneed >>= 1;
}
}
else
{
if (uSneed & 0x8000)
{
uSneed = (uSneed << 1) ^ uPolynomial;
}
else
{
uSneed <<= 1;
}
}
}
}
return uSneed;
}
AU_STATIC_CONSTEXPR_17 AuUInt32 AuCRC32RuntimeHashCPUBZip(const char *pCharNoCast,
AuUInt32 uLength,
AuUInt32 uSneed = kCRC32SeedBZIP)
{
return AuCRC32RuntimeHashCompPoly<kCRC32PolynomialPolyBZIP, false>(pCharNoCast, uLength, uSneed);
}
AU_STATIC_CONSTEXPR_17 AuUInt32 AuCRC32RuntimeHashCPUIEEE(const char *pCharNoCast,
AuUInt32 uLength,
AuUInt32 uSneed = kCRC32SeedIEEE)
{
return AuCRC32RuntimeHashCompPoly<kCRC32PolynomialPolyIEEE, true>(pCharNoCast, uLength, uSneed);
}
AU_OPTIMIZED AuUInt32 AuCRC32RuntimeHashCPUBZip(const void *pVoid,
AuUInt32 uLength,
AuUInt32 uSneed = kCRC32SeedBZIP)
{
return AuCRC32RuntimeHashCPUBZip((const char *)pVoid, uLength, uSneed);
}
AU_OPTIMIZED AuUInt32 AuCRC32RuntimeHashCPUIEEE(const void *pVoid,
AuUInt32 uLength,
AuUInt32 uSneed = kCRC32SeedIEEE)
{
return AuCRC32RuntimeHashCPUIEEE((const char *)pVoid, uLength, uSneed);
}
template <AuUInt32 uPolynomial, bool bRightReverse>
void AuCRC32RuntimeBuildTableComPoly(AuUInt32(&table)[256])
{
for (AU_ITERATE_N(i, 256))
{
AuUInt32 c;
if constexpr (bRightReverse)
{
c = AuUInt32(i);
}
else
{
c = AuUInt32(i) << 24;
}
for (AU_ITERATE_N(z, 8))
{
if constexpr (bRightReverse)
{
if (c & 1)
{
c = (c >> 1) ^ uPolynomial;
}
else
{
c >>= 1;
}
}
else
{
if (c & 0x80000000)
{
c = (c << 1) ^ uPolynomial;
}
else
{
c <<= 1;
}
}
}
table[i] = c;
}
}
template <bool bRightReverse>
void AuCRC32RuntimeBuildTableRuntimePoly(AuUInt32(&table)[256],
AuUInt32 uPolynomial)
{
for (AU_ITERATE_N(i, 256))
{
AuUInt32 c;
if constexpr (bRightReverse)
{
c = AuUInt32(i);
}
else
{
c = AuUInt32(i) << 24;
}
for (AU_ITERATE_N(z, 8))
{
if constexpr (bRightReverse)
{
if (c & 1)
{
c = (c >> 1) ^ uPolynomial;
}
else
{
c >>= 1;
}
}
else
{
if (c & 0x80000000)
{
c = (c << 1) ^ uPolynomial;
}
else
{
c <<= 1;
}
}
}
table[i] = c;
}
}
AU_INLINE_OR_STATIC_17 void AuCRC32RuntimeBuildTableIEE(AuUInt32(&table)[256])
{
AuCRC32RuntimeBuildTableComPoly<kCRC32PolynomialPolyZIP, true>(table);
}
AU_INLINE_OR_STATIC_17 void AuCRC32RuntimeBuildTableBZIP(AuUInt32(&table)[256])
{
AuCRC32RuntimeBuildTableComPoly<kCRC32PolynomialPolyBZIP, false>(table);
}
AU_INLINE_OR_STATIC_17 void AuCRC32RuntimeBuildTableRuntime(AuUInt32(&table)[256],
AuUInt32 uPolynomial,
bool bRightReverseNoSwap)
{
if (bRightReverseNoSwap)
{
AuCRC32RuntimeBuildTableRuntimePoly<true>(table, uPolynomial);
}
else
{
AuCRC32RuntimeBuildTableRuntimePoly<false>(table, uPolynomial);
}
}
template <AuUInt16 uPolynomial, bool bRightReverse>
void AuCRC16RuntimeBuildTableComPoly(AuUInt16(&table)[256])
{
for (AU_ITERATE_N(i, 256))
{
AuUInt16 c;
if constexpr (bRightReverse)
{
c = AuUInt16(i);
}
else
{
c = AuUInt16(i) << 8;
}
for (AU_ITERATE_N(z, 8))
{
if constexpr (bRightReverse)
{
if (c & 1)
{
c = (c >> 1) ^ uPolynomial;
}
else
{
c >>= 1;
}
}
else
{
if (c & 0x8000)
{
c = (c << 1) ^ uPolynomial;
}
else
{
c <<= 1;
}
}
}
table[i] = c;
}
}
template <bool bRightReverse>
void AuCRC16RuntimeBuildTableRuntimePoly(AuUInt16(&table)[256],
AuUInt16 uPolynomial)
{
for (AU_ITERATE_N(i, 256))
{
AuUInt16 c;
if constexpr (bRightReverse)
{
c = AuUInt16(i);
}
else
{
c = AuUInt16(i) << 8;
}
for (AU_ITERATE_N(z, 8))
{
if constexpr (bRightReverse)
{
if (c & 1)
{
c = (c >> 1) ^ uPolynomial;
}
else
{
c >>= 1;
}
}
else
{
if (c & 0x8000)
{
c = (c << 1) ^ uPolynomial;
}
else
{
c <<= 1;
}
}
}
table[i] = c;
}
}
AU_INLINE_OR_STATIC_17 void AuCRC16RuntimeBuildTableRuntime(AuUInt16(&table)[256],
AuUInt16 uPolynomial,
bool bRightReverseNoSwap)
{
if (bRightReverseNoSwap)
{
AuCRC16RuntimeBuildTableRuntimePoly<true>(table, uPolynomial);
}
else
{
AuCRC16RuntimeBuildTableRuntimePoly<false>(table, uPolynomial);
}
}
template <bool bRightReverse>
AuUInt32 AuCRC32RuntimeLookupBase(const AuUInt32(&table)[256],
const void *pBuf,
AuUInt32 uLength,
AuUInt32 uSneed)
{
static constexpr bool kBitFlip =
#if !defined(AU_CPU_ENDIAN_LITTLE)
true;
#else
false;
#endif
for (AU_ITERATE_N(i, uLength))
{
if constexpr (bRightReverse ^ kBitFlip)
{
uSneed = table[(uSneed ^ AuReadU8(pBuf, i)) & 0xFF] ^ (uSneed >> 8);
}
else
{
uSneed = table[((uSneed >> 24) ^ AuReadU8(pBuf, i)) & 0xFF] ^ (uSneed << 8);
}
}
return uSneed;
}
template <bool bRightReverse>
AuUInt32 AuCRC32RuntimeLookupBaseRaw(AuUInt32 *pTable,
const void *pBuf,
AuUInt32 uLength,
AuUInt32 uSneed)
{
static constexpr bool kBitFlip =
#if !defined(AU_CPU_ENDIAN_LITTLE)
true;
#else
false;
#endif
for (AU_ITERATE_N(i, uLength))
{
if constexpr (bRightReverse ^ kBitFlip)
{
uSneed = pTable[(uSneed ^ AuReadU8(pBuf, i)) & 0xFF] ^ (uSneed >> 8);
}
else
{
uSneed = pTable[((uSneed >> 24) ^ AuReadU8(pBuf, i)) & 0xFF] ^ (uSneed << 8);
}
}
return uSneed;
}
AU_OPTIMIZED AuUInt32 AuCRC32RuntimeLookupReverseRaw(AuUInt32 *pTable,
const void *pBuf,
AuUInt32 uLength,
AuUInt32 uSneed)
{
return AuCRC32RuntimeLookupBaseRaw<true>(pTable, pBuf, uLength, uSneed);
}
AU_OPTIMIZED AuUInt32 AuCRC32RuntimeLookupReflectedRaw(AuUInt32 *pTable,
const void *pBuf,
AuUInt32 uLength,
AuUInt32 uSneed)
{
return AuCRC32RuntimeLookupReverseRaw(pTable, pBuf, uLength, uSneed);
}
AU_OPTIMIZED AuUInt32 AuCRC32RuntimeLookupNormalRaw(AuUInt32 *pTable,
const void *pBuf,
AuUInt32 uLength,
AuUInt32 uSneed)
{
return AuCRC32RuntimeLookupBaseRaw<false>(pTable, pBuf, uLength, uSneed);
}
AU_INLINE_OR_STATIC_17 AuUInt32 AuCRC32RuntimeHashBZip(const char *pCharNoCast,
AuUInt32 uLength,
AuUInt32 uSneed = kCRC32SeedBZIP)
{
if constexpr (_AU_CRC_PLATFORM_NO_PREFER_TBL)
{
return AuCRC32RuntimeHashCPUBZip(pCharNoCast, uLength, uSneed);
}
else
{
return AuCRC32RuntimeLookupBase<false>(__audetail::kCRC32LookupTableBZipBackwards,
pCharNoCast,
uLength,
uSneed);
}
}
AU_INLINE_OR_STATIC_17 AuUInt32 AuCRC32RuntimeHashIEEE(const char *pCharNoCast,
AuUInt32 uLength,
AuUInt32 uSneed = kCRC32SeedIEEE)
{
if constexpr (_AU_CRC_PLATFORM_NO_PREFER_TBL)
{
return AuCRC32RuntimeHashCPUIEEE(pCharNoCast, uLength, uSneed);
}
else
{
return AuCRC32RuntimeLookupBase<true>(__audetail::kCRC32LookupTableIEE,
pCharNoCast,
uLength,
uSneed);
}
}
AU_OPTIMIZED AuUInt32 AuCRC32RuntimeHashBZip(const void *pVoid,
AuUInt32 uLength,
AuUInt32 uSneed = kCRC32SeedBZIP)
{
return AuCRC32RuntimeHashBZip((const char *)pVoid, uLength, uSneed);
}
AU_OPTIMIZED AuUInt32 AuCRC32RuntimeHashIEEE(const void *pVoid,
AuUInt32 uLength,
AuUInt32 uSneed = kCRC32SeedIEEE)
{
return AuCRC32RuntimeHashIEEE((const char *)pVoid, uLength, uSneed);
}
AU_OPTIMIZED AuUInt32 AuCRC32RuntimeHash(const void *pVoid,
AuUInt32 uLength,
AuUInt32 uSneed = kCRC32SeedDefault,
bool bRightReverse = false)
{
if (bRightReverse)
{
return AuCRC32RuntimeHashIEEE(pVoid, uLength, uSneed);
}
else
{
return AuCRC32RuntimeHashBZip(pVoid, uLength, uSneed);
}
}
template <bool bRightReverse>
AuUInt16 AuCRC16RuntimeLookupBase(const AuUInt16(&table)[256],
const void *pBuf,
AuUInt32 uLength,
AuUInt16 uSneed)
{
static constexpr bool kBitFlip =
#if !defined(AU_CPU_ENDIAN_LITTLE)
true;
#else
false;
#endif
for (AU_ITERATE_N(i, uLength))
{
if constexpr (bRightReverse ^ kBitFlip)
{
uSneed = table[(uSneed ^ AuReadU8(pBuf, i)) & 0xFF] ^ (uSneed >> 8);
}
else
{
uSneed = table[((uSneed >> 8) ^ AuReadU8(pBuf, i)) & 0xFF] ^ (uSneed << 8);
}
}
return uSneed;
}
template <bool bRightReverse>
AuUInt16 AuCRC16RuntimeLookupBaseRaw(AuUInt16 *pTable,
const void *pBuf,
AuUInt32 uLength,
AuUInt16 uSneed)
{
static constexpr bool kBitFlip =
#if !defined(AU_CPU_ENDIAN_LITTLE)
true;
#else
false;
#endif
for (AU_ITERATE_N(i, uLength))
{
if constexpr (bRightReverse ^ kBitFlip)
{
uSneed = pTable[(uSneed ^ AuReadU8(pBuf, i)) & 0xFF] ^ (uSneed >> 8);
}
else
{
uSneed = pTable[((uSneed >> 8) ^ AuReadU8(pBuf, i)) & 0xFF] ^ (uSneed << 8);
}
}
return uSneed;
}
AU_OPTIMIZED AuUInt16 AuCRC16RuntimeHash(const void *pVoid,
AuUInt32 uLength,
AuUInt16 uSneed = kCRC16SeedDefault,
bool bRightReverse = false)
{
if (bRightReverse)
{
return AuCRC16RuntimeHashCompPoly<kCRC16PolynomialDefault, true>((const char *)pVoid, uLength, uSneed);
}
else
{
return AuCRC16RuntimeHashCompPoly<kCRC16PolynomialDefault, false>((const char *)pVoid, uLength, uSneed);
}
}
AU_OPTIMIZED AuUInt16 AuCRC16RuntimeHashPoly(const void *pVoid,
AuUInt32 uLength,
AuUInt16 uSneed = kCRC16SeedDefault,
AuUInt16 uPolynomial = kCRC16PolynomialDefault,
bool bRightReverse = false)
{
if (bRightReverse)
{
return AuCRC16RuntimeHashRuntimePoly<true>((const char *)pVoid, uLength, uSneed, uPolynomial);
}
else
{
return AuCRC16RuntimeHashRuntimePoly<false>((const char *)pVoid, uLength, uSneed, uPolynomial);
}
}

View File

@ -0,0 +1,303 @@
/***
Copyright (C) 2022-2024 Jamie Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auFNV1.hpp
File: auFNV1Utils.hpp
Date: 2022-3-23
File: fnv1.hpp
Date: 2021-6-10
Author: Reece
***/
#pragma once
#include <auROXTL/auTypeUtils.hpp>
// Note: we're too early for AuroraEnv.hpp w/ AuroraEnums
#if defined(AURORA_IS_32BIT)
#define _AU_FNV1_32 1
#else
#define _AU_FNV1_32 0
#endif
#if defined(AURORA_COMPILER_CLANG) && !defined(AURORA_BUG_CLANG_SUPPORT_HASH_OVERFLOW)
#define _AU_HASH_RETARD_COMPILER
#pragma optimize("", off)
//#pragma GCC optimize ("no-fast-math")
#endif
constexpr AuUInt64 kFnv1MagicVal64 = 0xcbf29ce484222325ull;
constexpr AuUInt64 kFnv1MagicPrime64 = 0x100000001b3ull;
constexpr AuUInt32 kFnv1MagicVal32 = 0x811c9dc5;
constexpr AuUInt32 kFnv1MagicPrime32 = 0x01000193;
constexpr auto kFnv1MagicValPlatform = _AU_FNV1_32 ? kFnv1MagicVal32 : kFnv1MagicVal64;
constexpr auto kFnv1MagicPrimePlatform = _AU_FNV1_32 ? kFnv1MagicPrime32 : kFnv1MagicPrime64;
inline constexpr AuUInt64 AuFnv1a64(const char *const str, const AuUInt64 value = kFnv1MagicVal64) noexcept
{
return (str[0] == '\0') ? value : AuFnv1a64(&str[1], (value ^ AuUInt64(str[0])) * kFnv1MagicPrime64);
}
inline constexpr AuUInt32 AuFnv1aTrunc(const char *const str) noexcept
{
return static_cast<AuUInt32>(AuFnv1a64(str));
}
inline constexpr AuUInt32 AuFnv1a32(const char *const str, const AuUInt32 value = kFnv1MagicVal32) noexcept
{
return (str[0] == '\0') ? value : AuFnv1a32(&str[1], (value ^ AuUInt32(str[0])) * kFnv1MagicPrime32);
}
inline constexpr AuUInt AuFnv1aType(const char *const type, AuUInt size, AuUInt index, const AuUInt value) noexcept
{
return (index == size) ? value : AuFnv1aType(type + 1, size, index + 1, (value ^ AuUInt(*type)) * kFnv1MagicPrimePlatform);
}
inline constexpr AuUInt32 AuFnv1aType32(const char *const type, AuUInt size, AuUInt index, const AuUInt32 value) noexcept
{
return (index == size) ? value : AuFnv1aType32(type + 1, size, index + 1, (value ^ AuUInt32(*type)) * kFnv1MagicPrime32);
}
inline constexpr AuUInt64 AuFnv1aType64(const char *const type, AuUInt size, AuUInt index, const AuUInt64 value) noexcept
{
return (index == size) ? value : AuFnv1aType64(type + 1, size, index + 1, (value ^ AuUInt64(*type)) * kFnv1MagicPrime64);
}
#if !defined(_AU_HASH_RETARD_COMPILER)
template <class T>
inline constexpr AuUInt32 AuFnv1aType32(T type, const AuUInt32 value = kFnv1MagicVal32) noexcept
{
#if defined(AURORA_COMPILER_CLANG)
static_assert(false, "Unsupported constexpr hash on type");
#else
return AuFnv1aType32(((const char *)&type) + 1, sizeof(T), 1, (value ^ (AuUInt32(*(const char *)&type)) * kFnv1MagicPrime32));
#endif
}
#endif
#if !defined(_AU_HASH_RETARD_COMPILER)
template <class T>
inline constexpr AuUInt64 AuFnv1aType64(T type, const AuUInt64 value = kFnv1MagicVal64) noexcept
{
#if defined(AURORA_COMPILER_CLANG)
static_assert(false, "Unsupported constexpr hash on type");
#else
return AuFnv1aType64(((const char *)&type) + 1, sizeof(T), 1, (value ^ (AuUInt64(*(const char *)&type)) * kFnv1MagicPrime64));
#endif
}
#endif
#if !defined(_AU_HASH_RETARD_COMPILER)
template <class T>
inline constexpr AuUInt AuFnv1aType(const T &type, const AuUInt value = kFnv1MagicValPlatform) noexcept
{
#if _AU_FNV1_32
return AuFnv1aType32(type, value);
#else
return AuFnv1aType64(type, value);
#endif
}
#endif
template <class T>
inline constexpr AuUInt AuFnv1aPtr(const T *const type, AuUInt length, const AuUInt value = kFnv1MagicValPlatform) noexcept
{
return AuFnv1aType((const char *)type,
length,
0,
value);
}
template <class T>
inline constexpr AuUInt32 AuFnv1aPtr32(const T *const type, AuUInt length, const AuUInt32 value = kFnv1MagicVal32) noexcept
{
return AuFnv1aType32((const char *)type,
length,
0,
value);
}
template <class T>
inline constexpr AuUInt64 AuFnv1aPtr64(const T *const type, AuUInt length, const AuUInt64 value = kFnv1MagicVal64) noexcept
{
return AuFnv1aType64((const char *)type,
length,
0,
value);
}
inline constexpr auto AuFnv1a(const char *const str) noexcept
{
return _AU_FNV1_32 ? AuFnv1a32(str) : AuFnv1a64(str);
}
inline constexpr auto AuFnv1a(const char *const str, AuUInt length) noexcept
{
return AuFnv1aPtr(str, length);
}
inline AuUInt32 AuFnv1a32Runtime(const void *base, AuUInt length) noexcept
{
AuUInt32 result {kFnv1MagicVal32};
AuUInt i {};
for (; i < length; i++)
{
result = (result ^ AuUInt32(AuReadU8(base, i))) * AuUInt64(kFnv1MagicPrime32);
}
return result;
}
inline AuUInt64 AuFnv1a64Runtime(const void *base, AuUInt length) noexcept
{
AuUInt64 result {kFnv1MagicVal64};
AuUInt i {};
for (; i < length; i++)
{
result = (result ^ AuUInt64(AuReadU8(base, i))) * AuUInt64(kFnv1MagicPrime64);
}
return result;
}
inline auto AuFnv1aRuntime(const void *base, AuUInt length) noexcept
{
return _AU_FNV1_32 ?
AuFnv1a32Runtime(base, length) :
AuFnv1a64Runtime(base, length);
}
template <AuUInt uCount>
inline AuUInt64 AuFnv1a64Runtime(const void *base) noexcept
{
AuUInt64 result { kFnv1MagicVal64 };
AuUInt i {};
for (; i < uCount; i++)
{
result = (result ^ AuUInt64(AuReadU8(base, i))) * AuUInt64(kFnv1MagicPrime64);
}
return result;
}
template <AuUInt uCount>
inline AuUInt32 AuFnv1a32Runtime(const void *base) noexcept
{
AuUInt32 result { kFnv1MagicVal32 };
AuUInt i {};
for (; i < uCount; i++)
{
result = (result ^ AuUInt32(AuReadU8(base, i))) * AuUInt32(kFnv1MagicPrime32);
}
return result;
}
#if defined(AU_CPU_ENDIAN_LITTLE)
template <>
inline AuUInt32 AuFnv1a32Runtime<2>(const void *base) noexcept
{
AuUInt32 result { kFnv1MagicVal32 };
auto uWord16 = AuReadU16(base, 0);
result = (result ^ AuUInt32((uWord16 & 0xFF) >> 0)) * AuUInt32(kFnv1MagicPrime32);
result = (result ^ AuUInt32((uWord16 & 0xFF00) >> 8)) * AuUInt32(kFnv1MagicPrime32);
return result;
}
template <>
inline AuUInt32 AuFnv1a32Runtime<4>(const void *base) noexcept
{
AuUInt32 result { kFnv1MagicVal32 };
auto uWord32 = AuReadU32(base, 0);
result = (result ^ AuUInt32((uWord32 & 0xFF) >> 0)) * AuUInt32(kFnv1MagicPrime32);
result = (result ^ AuUInt32((uWord32 & 0xFF00) >> 8)) * AuUInt32(kFnv1MagicPrime32);
result = (result ^ AuUInt32((uWord32 & 0xFF0000) >> 16)) * AuUInt32(kFnv1MagicPrime32);
result = (result ^ AuUInt32((uWord32 & 0xFF000000) >> 24)) * AuUInt32(kFnv1MagicPrime32);
return result;
}
template <>
inline AuUInt32 AuFnv1a32Runtime<8>(const void *base) noexcept
{
AuUInt32 result { kFnv1MagicVal32 };
auto uWord32 = AuReadU32(base, 0);
auto uWord32Hi = AuReadU32(base, 4);
result = (result ^ AuUInt32((uWord32 & 0xFF) >> 0)) * AuUInt32(kFnv1MagicPrime32);
result = (result ^ AuUInt32((uWord32 & 0xFF00) >> 8)) * AuUInt32(kFnv1MagicPrime32);
result = (result ^ AuUInt32((uWord32 & 0xFF0000) >> 16)) * AuUInt32(kFnv1MagicPrime32);
result = (result ^ AuUInt32((uWord32 & 0xFF000000) >> 24)) * AuUInt32(kFnv1MagicPrime32);
result = (result ^ AuUInt32((uWord32Hi & 0xFF) >> 0)) * AuUInt32(kFnv1MagicPrime32);
result = (result ^ AuUInt32((uWord32Hi & 0xFF00) >> 8)) * AuUInt32(kFnv1MagicPrime32);
result = (result ^ AuUInt32((uWord32Hi & 0xFF0000) >> 16)) * AuUInt32(kFnv1MagicPrime32);
result = (result ^ AuUInt32((uWord32Hi & 0xFF000000) >> 24)) * AuUInt32(kFnv1MagicPrime32);
return result;
}
template <>
inline AuUInt64 AuFnv1a64Runtime<2>(const void *base) noexcept
{
AuUInt64 result { kFnv1MagicVal64 };
auto uWord16 = AuReadU16(base, 0);
result = (result ^ AuUInt64((uWord16 & 0xFF) >> 0)) * AuUInt64(kFnv1MagicPrime64);
result = (result ^ AuUInt64((uWord16 & 0xFF00) >> 8)) * AuUInt64(kFnv1MagicPrime64);
return result;
}
template <>
inline AuUInt64 AuFnv1a64Runtime<4>(const void *base) noexcept
{
AuUInt64 result { kFnv1MagicVal64 };
auto uWord64 = AuReadU32(base, 0);
result = (result ^ AuUInt64((uWord64 & 0xFF) >> 0)) * AuUInt64(kFnv1MagicPrime64);
result = (result ^ AuUInt64((uWord64 & 0xFF00) >> 8)) * AuUInt64(kFnv1MagicPrime64);
result = (result ^ AuUInt64((uWord64 & 0xFF0000) >> 16)) * AuUInt64(kFnv1MagicPrime64);
result = (result ^ AuUInt64((uWord64 & 0xFF000000) >> 24)) * AuUInt64(kFnv1MagicPrime64);
return result;
}
template <>
inline AuUInt64 AuFnv1a64Runtime<8>(const void *base) noexcept
{
AuUInt64 result { kFnv1MagicVal64 };
auto uWord32 = AuReadU32(base, 0);
auto uWord32Hi = AuReadU32(base, 4);
result = (result ^ AuUInt64((uWord32 & 0xFF) >> 0)) * AuUInt64(kFnv1MagicPrime64);
result = (result ^ AuUInt64((uWord32 & 0xFF00) >> 8)) * AuUInt64(kFnv1MagicPrime64);
result = (result ^ AuUInt64((uWord32 & 0xFF0000) >> 16)) * AuUInt64(kFnv1MagicPrime64);
result = (result ^ AuUInt64((uWord32 & 0xFF000000) >> 24)) * AuUInt64(kFnv1MagicPrime64);
result = (result ^ AuUInt64((uWord32Hi & 0xFF) >> 0)) * AuUInt64(kFnv1MagicPrime64);
result = (result ^ AuUInt64((uWord32Hi & 0xFF00) >> 8)) * AuUInt64(kFnv1MagicPrime64);
result = (result ^ AuUInt64((uWord32Hi & 0xFF0000) >> 16)) * AuUInt64(kFnv1MagicPrime64);
result = (result ^ AuUInt64((uWord32Hi & 0xFF000000) >> 24)) * AuUInt64(kFnv1MagicPrime64);
return result;
}
#endif
template <AuUInt uCount>
inline auto AuFnv1aRuntime(const void *base) noexcept
{
return _AU_FNV1_32 ?
AuFnv1a32Runtime<uCount>(base) :
AuFnv1a64Runtime<uCount>(base);
}
#undef _AU_FNV1_32
#if defined(_AU_HASH_RETARD_COMPILER)
#pragma optimize("", on)
//#pragma GCC optimize ("fast-math")
#undef _AU_HASH_RETARD_COMPILER
#endif

View File

@ -11,292 +11,4 @@
#include "auTypeUtils.hpp"
// Note: we're too early for AuroraEnv.hpp w/ AuroraEnums
#if defined(AURORA_IS_32BIT)
#define _AU_FNV1_32 1
#else
#define _AU_FNV1_32 0
#endif
#if defined(AURORA_COMPILER_CLANG) && !defined(AURORA_BUG_CLANG_SUPPORT_HASH_OVERFLOW)
#define _AU_HASH_RETARD_COMPILER
#pragma optimize("", off)
//#pragma GCC optimize ("no-fast-math")
#endif
constexpr AuUInt64 kFnv1MagicVal64 = 0xcbf29ce484222325ull;
constexpr AuUInt64 kFnv1MagicPrime64 = 0x100000001b3ull;
constexpr AuUInt32 kFnv1MagicVal32 = 0x811c9dc5;
constexpr AuUInt32 kFnv1MagicPrime32 = 0x01000193;
constexpr auto kFnv1MagicValPlatform = _AU_FNV1_32 ? kFnv1MagicVal32 : kFnv1MagicVal64;
constexpr auto kFnv1MagicPrimePlatform = _AU_FNV1_32 ? kFnv1MagicPrime32 : kFnv1MagicPrime64;
inline constexpr AuUInt64 AuFnv1a64(const char *const str, const AuUInt64 value = kFnv1MagicVal64) noexcept
{
return (str[0] == '\0') ? value : AuFnv1a64(&str[1], (value ^ AuUInt64(str[0])) * kFnv1MagicPrime64);
}
inline constexpr AuUInt32 AuFnv1aTrunc(const char *const str) noexcept
{
return static_cast<AuUInt32>(AuFnv1a64(str));
}
inline constexpr AuUInt32 AuFnv1a32(const char *const str, const AuUInt32 value = kFnv1MagicVal32) noexcept
{
return (str[0] == '\0') ? value : AuFnv1a32(&str[1], (value ^ AuUInt32(str[0])) * kFnv1MagicPrime32);
}
inline constexpr AuUInt AuFnv1aType(const char *const type, AuUInt size, AuUInt index, const AuUInt value) noexcept
{
return (index == size) ? value : AuFnv1aType(type + 1, size, index + 1, (value ^ AuUInt(*type)) * kFnv1MagicPrimePlatform);
}
inline constexpr AuUInt32 AuFnv1aType32(const char *const type, AuUInt size, AuUInt index, const AuUInt32 value) noexcept
{
return (index == size) ? value : AuFnv1aType32(type + 1, size, index + 1, (value ^ AuUInt32(*type)) * kFnv1MagicPrime32);
}
inline constexpr AuUInt64 AuFnv1aType64(const char *const type, AuUInt size, AuUInt index, const AuUInt64 value) noexcept
{
return (index == size) ? value : AuFnv1aType64(type + 1, size, index + 1, (value ^ AuUInt64(*type)) * kFnv1MagicPrime64);
}
#if !defined(_AU_HASH_RETARD_COMPILER)
template <class T>
inline constexpr AuUInt32 AuFnv1aType32(T type, const AuUInt32 value = kFnv1MagicVal32) noexcept
{
#if defined(AURORA_COMPILER_CLANG)
static_assert(false, "Unsupported constexpr hash on type");
#else
return AuFnv1aType32(((const char *)&type) + 1, sizeof(T), 1, (value ^ (AuUInt32(*(const char *)&type)) * kFnv1MagicPrime32));
#endif
}
#endif
#if !defined(_AU_HASH_RETARD_COMPILER)
template <class T>
inline constexpr AuUInt64 AuFnv1aType64(T type, const AuUInt64 value = kFnv1MagicVal64) noexcept
{
#if defined(AURORA_COMPILER_CLANG)
static_assert(false, "Unsupported constexpr hash on type");
#else
return AuFnv1aType64(((const char *)&type) + 1, sizeof(T), 1, (value ^ (AuUInt64(*(const char *)&type)) * kFnv1MagicPrime64));
#endif
}
#endif
#if !defined(_AU_HASH_RETARD_COMPILER)
template <class T>
inline constexpr AuUInt AuFnv1aType(const T &type, const AuUInt value = kFnv1MagicValPlatform) noexcept
{
#if _AU_FNV1_32
return AuFnv1aType32(type, value);
#else
return AuFnv1aType64(type, value);
#endif
}
#endif
template <class T>
inline constexpr AuUInt AuFnv1aPtr(const T *const type, AuUInt length, const AuUInt value = kFnv1MagicValPlatform) noexcept
{
return AuFnv1aType((const char *)type,
length,
0,
value);
}
template <class T>
inline constexpr AuUInt32 AuFnv1aPtr32(const T *const type, AuUInt length, const AuUInt32 value = kFnv1MagicVal32) noexcept
{
return AuFnv1aType32((const char *)type,
length,
0,
value);
}
template <class T>
inline constexpr AuUInt64 AuFnv1aPtr64(const T *const type, AuUInt length, const AuUInt64 value = kFnv1MagicVal64) noexcept
{
return AuFnv1aType64((const char *)type,
length,
0,
value);
}
inline constexpr auto AuFnv1a(const char *const str) noexcept
{
return _AU_FNV1_32 ? AuFnv1a32(str) : AuFnv1a64(str);
}
inline constexpr auto AuFnv1a(const char *const str, AuUInt length) noexcept
{
return AuFnv1aPtr(str, length);
}
inline AuUInt32 AuFnv1a32Runtime(const void *base, AuUInt length) noexcept
{
AuUInt32 result {kFnv1MagicVal32};
AuUInt i {};
for (; i < length; i++)
{
result = (result ^ AuUInt32(AuReadU8(base, i))) * AuUInt64(kFnv1MagicPrime32);
}
return result;
}
inline AuUInt64 AuFnv1a64Runtime(const void *base, AuUInt length) noexcept
{
AuUInt64 result {kFnv1MagicVal64};
AuUInt i {};
for (; i < length; i++)
{
result = (result ^ AuUInt64(AuReadU8(base, i))) * AuUInt64(kFnv1MagicPrime64);
}
return result;
}
inline auto AuFnv1aRuntime(const void *base, AuUInt length) noexcept
{
return _AU_FNV1_32 ?
AuFnv1a32Runtime(base, length) :
AuFnv1a64Runtime(base, length);
}
template <AuUInt uCount>
inline AuUInt64 AuFnv1a64Runtime(const void *base) noexcept
{
AuUInt64 result { kFnv1MagicVal64 };
AuUInt i {};
for (; i < uCount; i++)
{
result = (result ^ AuUInt64(AuReadU8(base, i))) * AuUInt64(kFnv1MagicPrime64);
}
return result;
}
template <AuUInt uCount>
inline AuUInt32 AuFnv1a32Runtime(const void *base) noexcept
{
AuUInt32 result { kFnv1MagicVal32 };
AuUInt i {};
for (; i < uCount; i++)
{
result = (result ^ AuUInt32(AuReadU8(base, i))) * AuUInt32(kFnv1MagicPrime32);
}
return result;
}
#if defined(AU_CPU_ENDIAN_LITTLE)
template <>
inline AuUInt32 AuFnv1a32Runtime<2>(const void *base) noexcept
{
AuUInt32 result { kFnv1MagicVal32 };
auto uWord16 = AuReadU16(base, 0);
result = (result ^ AuUInt32((uWord16 & 0xFF) >> 0)) * AuUInt32(kFnv1MagicPrime32);
result = (result ^ AuUInt32((uWord16 & 0xFF00) >> 8)) * AuUInt32(kFnv1MagicPrime32);
return result;
}
template <>
inline AuUInt32 AuFnv1a32Runtime<4>(const void *base) noexcept
{
AuUInt32 result { kFnv1MagicVal32 };
auto uWord32 = AuReadU32(base, 0);
result = (result ^ AuUInt32((uWord32 & 0xFF) >> 0)) * AuUInt32(kFnv1MagicPrime32);
result = (result ^ AuUInt32((uWord32 & 0xFF00) >> 8)) * AuUInt32(kFnv1MagicPrime32);
result = (result ^ AuUInt32((uWord32 & 0xFF0000) >> 16)) * AuUInt32(kFnv1MagicPrime32);
result = (result ^ AuUInt32((uWord32 & 0xFF000000) >> 24)) * AuUInt32(kFnv1MagicPrime32);
return result;
}
template <>
inline AuUInt32 AuFnv1a32Runtime<8>(const void *base) noexcept
{
AuUInt32 result { kFnv1MagicVal32 };
auto uWord32 = AuReadU32(base, 0);
auto uWord32Hi = AuReadU32(base, 4);
result = (result ^ AuUInt32((uWord32 & 0xFF) >> 0)) * AuUInt32(kFnv1MagicPrime32);
result = (result ^ AuUInt32((uWord32 & 0xFF00) >> 8)) * AuUInt32(kFnv1MagicPrime32);
result = (result ^ AuUInt32((uWord32 & 0xFF0000) >> 16)) * AuUInt32(kFnv1MagicPrime32);
result = (result ^ AuUInt32((uWord32 & 0xFF000000) >> 24)) * AuUInt32(kFnv1MagicPrime32);
result = (result ^ AuUInt32((uWord32Hi & 0xFF) >> 0)) * AuUInt32(kFnv1MagicPrime32);
result = (result ^ AuUInt32((uWord32Hi & 0xFF00) >> 8)) * AuUInt32(kFnv1MagicPrime32);
result = (result ^ AuUInt32((uWord32Hi & 0xFF0000) >> 16)) * AuUInt32(kFnv1MagicPrime32);
result = (result ^ AuUInt32((uWord32Hi & 0xFF000000) >> 24)) * AuUInt32(kFnv1MagicPrime32);
return result;
}
template <>
inline AuUInt64 AuFnv1a64Runtime<2>(const void *base) noexcept
{
AuUInt64 result { kFnv1MagicVal64 };
auto uWord16 = AuReadU16(base, 0);
result = (result ^ AuUInt64((uWord16 & 0xFF) >> 0)) * AuUInt64(kFnv1MagicPrime64);
result = (result ^ AuUInt64((uWord16 & 0xFF00) >> 8)) * AuUInt64(kFnv1MagicPrime64);
return result;
}
template <>
inline AuUInt64 AuFnv1a64Runtime<4>(const void *base) noexcept
{
AuUInt64 result { kFnv1MagicVal64 };
auto uWord64 = AuReadU32(base, 0);
result = (result ^ AuUInt64((uWord64 & 0xFF) >> 0)) * AuUInt64(kFnv1MagicPrime64);
result = (result ^ AuUInt64((uWord64 & 0xFF00) >> 8)) * AuUInt64(kFnv1MagicPrime64);
result = (result ^ AuUInt64((uWord64 & 0xFF0000) >> 16)) * AuUInt64(kFnv1MagicPrime64);
result = (result ^ AuUInt64((uWord64 & 0xFF000000) >> 24)) * AuUInt64(kFnv1MagicPrime64);
return result;
}
template <>
inline AuUInt64 AuFnv1a64Runtime<8>(const void *base) noexcept
{
AuUInt64 result { kFnv1MagicVal64 };
auto uWord32 = AuReadU32(base, 0);
auto uWord32Hi = AuReadU32(base, 4);
result = (result ^ AuUInt64((uWord32 & 0xFF) >> 0)) * AuUInt64(kFnv1MagicPrime64);
result = (result ^ AuUInt64((uWord32 & 0xFF00) >> 8)) * AuUInt64(kFnv1MagicPrime64);
result = (result ^ AuUInt64((uWord32 & 0xFF0000) >> 16)) * AuUInt64(kFnv1MagicPrime64);
result = (result ^ AuUInt64((uWord32 & 0xFF000000) >> 24)) * AuUInt64(kFnv1MagicPrime64);
result = (result ^ AuUInt64((uWord32Hi & 0xFF) >> 0)) * AuUInt64(kFnv1MagicPrime64);
result = (result ^ AuUInt64((uWord32Hi & 0xFF00) >> 8)) * AuUInt64(kFnv1MagicPrime64);
result = (result ^ AuUInt64((uWord32Hi & 0xFF0000) >> 16)) * AuUInt64(kFnv1MagicPrime64);
result = (result ^ AuUInt64((uWord32Hi & 0xFF000000) >> 24)) * AuUInt64(kFnv1MagicPrime64);
return result;
}
#endif
template <AuUInt uCount>
inline auto AuFnv1aRuntime(const void *base) noexcept
{
return _AU_FNV1_32 ?
AuFnv1a32Runtime<uCount>(base) :
AuFnv1a64Runtime<uCount>(base);
}
#undef _AU_FNV1_32
#if defined(_AU_HASH_RETARD_COMPILER)
#pragma optimize("", on)
//#pragma GCC optimize ("fast-math")
#undef _AU_HASH_RETARD_COMPILER
#endif
#include <auROXTL/Hashing/auFNV1.hpp>

View File

@ -64,7 +64,7 @@ namespace __audetail
#include <auROXTL/auTypeUtils.hpp>
#include <auROXTL/auNumericLimits.hpp>
#include <auROXTL/auUnitUtils.hpp>
#include <auROXTL/auFNV1Utils.hpp>
#include <auROXTL/Hashing/Hashing.hpp>
#include <auROXTL/auTryConstructUtils.hpp>
#include <auROXTL/auTryCallUtils.hpp>