1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef Debug_hpp
16 #define Debug_hpp
17 
18 #ifdef __ANDROID__
19 #include "DebugAndroid.hpp"
20 #else
21 
22 #include <assert.h>
23 #include <stdio.h>
24 
25 #undef min
26 #undef max
27 
28 void trace(const char *format, ...);
29 
30 #ifndef NDEBUG
31 	#define TRACE(format, ...) trace("[0x%0.8X]%s(" format ")\n", this, __FUNCTION__, ##__VA_ARGS__)
32 #else
33 	#define TRACE(...) ((void)0)
34 #endif
35 
36 #ifndef NDEBUG
37 	#define UNIMPLEMENTED() {trace("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); ASSERT(false);}
38 #else
39 	#define UNIMPLEMENTED() ((void)0)
40 #endif
41 
42 #ifndef NDEBUG
43 	#define ASSERT(expression) {if(!(expression)) trace("\t! Assert failed in %s(%d): " #expression "\n", __FUNCTION__, __LINE__); assert(expression);}
44 #else
45 	#define ASSERT assert
46 #endif
47 
48 #endif   // __ANDROID__
49 #endif   // Debug_hpp
50