medfall

A super great game engine
Log | Files | Refs

commit 6a52f454ea2c0970ad031cde04df499435574a42
parent 4b28975f4ea49f30d0b239cbbc4414353b18cb0f
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Mon, 23 Oct 2017 23:46:31 +0300

FNV fixes

Diffstat:
fnv.h | 7++++---
intrinsics.h | 9+++++++++
2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/fnv.h b/fnv.h @@ -4,9 +4,9 @@ #include "array.h" forceinline u64 fnv1a( const void * data, size_t n ) { - u64 hash = 14695981039346656037; + u64 hash = U64( 14695981039346656037 ); for( size_t i = 0; i < n; i++ ) { - hash = ( hash * 1099511628211 ) ^ data[ i ]; + hash = ( hash * U64( 1099511628211 ) ) ^ data[ i ]; } return hash; } @@ -15,6 +15,7 @@ forceinline u64 fnv1a( const array< u8 > a ) { return fnv1a( a.ptr(), a.num_bytes() ); } -forceinline u64 fnv1a( u64 x ) { +template< typename T > +forceinline u64 fnv1a( const T & x ) { return fnv1a( &x, sizeof( x ) ); } diff --git a/intrinsics.h b/intrinsics.h @@ -36,6 +36,15 @@ typedef uintptr_t uptr; #define U32_MAX u32( UINT32_MAX ) #define U64_MAX u64( UINT64_MAX ) +#define S8 INT8_C +#define S16 INT16_C +#define S32 INT32_C +#define S64 INT64_C +#define U8 UINT8_C +#define U16 UINT16_C +#define U32 UINT32_C +#define U64 UINT64_C + #define PI 3.14159265359f #define TAU 6.28318530717958647692f