
///////////////////////////////////////////////////////////////////////////////
//
// File   : Asura_Assert.h (PS3 SPU)
// Author : Mike Healey
// Date   : 31-Aug-2005
//
// Copyright (C) 2005 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
	#pragma once
#endif   // ifdef ASURA_USE_PRAGMA_ONCE

#ifndef __ASURA_ASSERT_H__
#define __ASURA_ASSERT_H__

////////////////////////////////////////////////////////////////////////////////
// Include files...
////////////////////////////////////////////////////////////////////////////////

#include <spu_printf.h>

////////////////////////////////////////////////////////////////////////////////
// Macro definitions...
////////////////////////////////////////////////////////////////////////////////

#if defined(ASURA_ASSERT)

	// Standard assert macro...
    #define Asura_Assert(cond,desc) \
    { \
		if(!(cond)) \
		{ \
            spu_printf( "SPU ASSERTION FAILED (%s): %s\nFile %s, Line %d\n", #cond, desc, __FILE__, __LINE__ ); \
		} \
    } 

    // (MH - 01.11.2002) paramaterised assert. Usage example (note the brackets around arg 2):
    // Asura_Assertf(false, ("%s is invalid", szString));
    #define Asura_Assertf( cond, params ) \
    { \
		if( !(cond) ) \
		{ \
			spu_printf( "SPU ASSERTION FAILED (%s)\n", #cond ); \
			spu_printf params ; \
			spu_printf( "\nFile %s, Line %d\n", __FILE__, __LINE__ ); \
		} \
    }

#else

	#define Asura_Assert(ignore1,ignore2)
	#define Asura_Assertf(ignore1,ignore2)

#endif	//defined(ASURA_ASSERT)


#define ASURA_STATIC_ASSERT_COMBINE_LITERALS( a, b ) a ## b
#define ASURA_STATIC_ASSERT_MAKE_UNIQUE_NAME( a ) ASURA_STATIC_ASSERT_COMBINE_LITERALS( ASURA_STATIC_ASSERT_FAILED_AT_LINE_, a )

template<bool b> struct ASURA_STATIC_ASSERTION_FAILURE;
template<> struct ASURA_STATIC_ASSERTION_FAILURE<false> { enum { VALUE = -1 }; };
template<> struct ASURA_STATIC_ASSERTION_FAILURE<true> { enum { VALUE = 1 }; };

#define ASURA_STATIC_ASSERT( bCondition ) \
    typedef char ASURA_STATIC_ASSERT_MAKE_UNIQUE_NAME(__LINE__) [ ASURA_STATIC_ASSERTION_FAILURE<((bCondition) != 0)>::VALUE ] 



#endif   // ifndef __ASURA_ASSERT_H__


/// End of file. ///
