medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 66f19612ada06f252536dcf4b8b04b2bc36116da
parent bb79c676a9a29946e51b936a66f5a505b33998b7
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Wed Feb  8 20:19:08 +0200

Add is_aligned

Diffstat:
intrinsics.h | 5+++++
1 file changed, 5 insertions(+), 0 deletions(-)
diff --git a/intrinsics.h b/intrinsics.h @@ -175,6 +175,11 @@ inline void zero_struct( T * x ) { memset( x, 0, sizeof( T ) ); } +template< typename T > +inline bool is_aligned( const T * ptr ) { + return checked_cast< size_t >( ptr ) % alignof( T ) == 0; +} + // TODO: this sucks inline u8 * file_get_contents( const char * path, size_t * out_len = NULL ) { FILE * file = fopen( path, "rb" );