aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/common/common_funcs.h
diff options
context:
space:
mode:
authorGravatar archshift <admin@archshift.com>2015-01-20 17:16:47 -0800
committerGravatar archshift <admin@archshift.com>2015-02-10 18:30:31 -0800
commitef24e72b2618806f64345544fa46c84f3f494890 (patch)
treefca138e8377c4d66bd1fe026a3d2fef54a7f090c /src/common/common_funcs.h
parent168eb27aee7992b8abf9f505b8c246a25fc8dca5 (diff)
Asserts: break/crash program, fit to style guide; log.h->assert.h
Involves making asserts use printf instead of the log functions (log functions are asynchronous and, as such, the log won't be printed in time) As such, the log type argument was removed (printf obviously can't use it, and it's made obsolete by the file and line printing) Also removed some GEKKO cruft.
Diffstat (limited to 'src/common/common_funcs.h')
-rw-r--r--src/common/common_funcs.h35
1 files changed, 15 insertions, 20 deletions
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h
index 229eb74c..44d8ae11 100644
--- a/src/common/common_funcs.h
+++ b/src/common/common_funcs.h
@@ -44,15 +44,14 @@ template<> struct CompileTimeAssert<true> {};
#include <sys/endian.h>
#endif
-// go to debugger mode
- #ifdef GEKKO
- #define Crash()
- #elif defined _M_GENERIC
- #define Crash() { exit(1); }
- #else
- #define Crash() {asm ("int $3");}
- #endif
- #define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
+#if defined(__x86_64__) || defined(_M_X64)
+#define Crash() __asm__ __volatile__("int $3")
+#elif defined(_M_ARM)
+#define Crash() __asm__ __volatile__("trap")
+#else
+#define Crash() exit(1)
+#endif
+
// GCC 4.8 defines all the rotate functions now
// Small issue with GCC's lrotl/lrotr intrinsics is they are still 32bit while we require 64bit
#ifndef _rotl
@@ -97,10 +96,10 @@ inline u64 _rotr64(u64 x, unsigned int shift){
#define LC_GLOBAL_LOCALE ((locale_t)-1)
#define LC_ALL_MASK LC_ALL
#define LC_COLLATE_MASK LC_COLLATE
- #define LC_CTYPE_MASK LC_CTYPE
- #define LC_MONETARY_MASK LC_MONETARY
+ #define LC_CTYPE_MASK LC_CTYPE
+ #define LC_MONETARY_MASK LC_MONETARY
#define LC_NUMERIC_MASK LC_NUMERIC
- #define LC_TIME_MASK LC_TIME
+ #define LC_TIME_MASK LC_TIME
inline locale_t uselocale(locale_t new_locale)
{
@@ -136,14 +135,10 @@ inline u64 _rotr64(u64 x, unsigned int shift){
#define fstat64 _fstat64
#define fileno _fileno
- #if _M_IX86
- #define Crash() {__asm int 3}
- #else
-extern "C" {
- __declspec(dllimport) void __stdcall DebugBreak(void);
-}
- #define Crash() {DebugBreak();}
- #endif // M_IX86
+ extern "C" {
+ __declspec(dllimport) void __stdcall DebugBreak(void);
+ }
+ #define Crash() {DebugBreak();}
#endif // _MSC_VER ndef
// Dolphin's min and max functions