File: SPUAssert.h

package info (click to toggle)
openmohaa 0.82.1%2Bdfsg-1
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 34,192 kB
  • sloc: cpp: 315,720; ansic: 275,789; sh: 312; xml: 246; asm: 141; makefile: 7
file content (44 lines) | stat: -rw-r--r-- 1,615 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef __SPU_ASSERT_H__
#define __SPU_ASSERT_H__

// Author: Sauce
// 1/18/2006
// Better assert on SPU side, but it assumes spu_printf works.

#ifdef _DEBUG

#ifdef __CELLOS_LV2__
#include <spu_printf.h>
#define SPU_ASSERT(cond) do { if (__builtin_expect(!(cond), 0)) { spu_printf("SPU: Assertion failed!  Expression: " #cond "\n    in %s at " __FILE__ ":%i\n", __FUNCTION__, __LINE__); spu_hcmpeq((cond), 0); } } while (0)
#else // __CELLOS_LV2__
#define SPU_ASSERT(cond) assert(cond)
#endif //__CELLOS_LV2__

#else  // _DEBUG

#ifdef __CELLOS_LV2__
#include <spu_printf.h>
#define SPU_ASSERT(cond) do { if (__builtin_expect(!(cond), 0)) { spu_printf("SPU: Assertion failed!  Expression: " #cond "\n    in %s at " __FILE__ ":%i\n", __FUNCTION__, __LINE__); spu_hcmpeq((cond), 0); } } while (0)
// Sauce
// Later on we'll want no asserts in release builds
//#define SPU_ASSERT(cond) do {} while (0)
#else  // __CELLOS_LV2__
#define SPU_ASSERT(cond)  assert(cond)
#endif // __CELLOS_LV2__

#endif // _DEBUG

// Usage:
// SPU_COMPILE_TIME_ASSERT(sizeof(MyStructure) <= 128);
// Gives the following error message if it fails:
//  error: size of array `spu_compile_time_assert_failed' is negative
#define SPU_COMPILE_TIME_ASSERT(cond) extern char spu_compile_time_assert_failed[cond ? 1 : -1]

// Usage:
// SPU_NAMED_COMPILE_TIME_ASSERT(MyStructure_is_more_than_128_bytes, sizeof(MyStructure) <= 128);
// Gives the following error message if it fails:
//  error: size of array `MyStructure_is_more_than_128_bytes' is negative
#define SPU_NAMED_COMPILE_TIME_ASSERT(name, cond) extern char name[cond ? 1 : -1]


#endif