From: <axl...@us...> - 2009-01-03 17:48:49
|
Revision: 141 http://hgengine.svn.sourceforge.net/hgengine/?rev=141&view=rev Author: axlecrusher Date: 2009-01-03 17:48:45 +0000 (Sat, 03 Jan 2009) Log Message: ----------- function to check alignedness Modified Paths: -------------- Mercury2/src/MercuryUtil.cpp Mercury2/src/MercuryUtil.h Modified: Mercury2/src/MercuryUtil.cpp =================================================================== --- Mercury2/src/MercuryUtil.cpp 2009-01-02 01:45:52 UTC (rev 140) +++ Mercury2/src/MercuryUtil.cpp 2009-01-03 17:48:45 UTC (rev 141) @@ -29,6 +29,11 @@ return ptr; } +bool isAligned(size_t align, const void* mem) +{ + return (uintptr_t(mem) % align) == 0; +} + long FileToString( const MString & sFileName, char * & data ) { data = 0; Modified: Mercury2/src/MercuryUtil.h =================================================================== --- Mercury2/src/MercuryUtil.h 2009-01-02 01:45:52 UTC (rev 140) +++ Mercury2/src/MercuryUtil.h 2009-01-03 17:48:45 UTC (rev 141) @@ -3,6 +3,7 @@ #include <stdlib.h> #include <MercuryString.h> +#include <assert.h> /*#ifndef NULL #define NULL 0 @@ -16,11 +17,12 @@ //returns an aligned pointer, mem is the actual (unaligned) pointer for freeing void* mmemalign(size_t align, size_t size, void*& mem); +bool isAligned(size_t align, const void* mem); +#define ASSERT(x) assert(!x) + #if defined(__GNUC__) #define M_ALIGN(n) __attribute__((aligned(n))) -//#define MMALLOC(n) memalign(32, n) -//#define MMALLOC(n) malloc(n) #else #define M_ALIGN(n) #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |