medfall

A super great game engine
Log | Files | Refs

commit 82b1a4aebdf03f84d54b7f3a66cf15d1a32a3314
parent 458ab5d362b839df6d94cea858dec1a2f3c88040
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Thu Sep 14 23:36:35 +0300

Add fnv.h

Diffstat:
fnv.h | 20++++++++++++++++++++
1 file changed, 20 insertions(+), 0 deletions(-)
diff --git a/fnv.h b/fnv.h @@ -0,0 +1,20 @@ +#pragma once + +#include "intrinsics.h" +#include "array.h" + +forceinline u64 fnv1a( const void * data, size_t n ) { + u64 hash = 14695981039346656037; + for( size_t i = 0; i < n; i++ ) { + hash = ( hash * 1099511628211 ) ^ data[ i ]; + } + return hash; +} + +forceinline u64 fnv1a( const array< u8 > a ) { + return fnv1a( a.ptr(), a.num_bytes() ); +} + +forceinline u64 fnv1a( u64 x ) { + return fnv1a( &x, sizeof( x ) ); +}