Created
December 3, 2013 08:23
-
-
Save aras-p/7765792 to your computer and use it in GitHub Desktop.
Assert break implementations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if defined(__ppc__) | |
#define DEBUG_BREAK __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" : : : "memory","r0","r3","r4" ) | |
#elif UNITY_OSX | |
#if defined(__clang__) | |
#define DEBUG_BREAK if (IsDebuggerPresent ()) __builtin_trap () | |
#else | |
#define DEBUG_BREAK if (IsDebuggerPresent ()) __asm { int 3 } | |
#endif | |
#elif UNITY_WIN | |
#define DEBUG_BREAK if (IsDebuggerPresent ()) __debugbreak() | |
#elif (UNITY_IPHONE && !TARGET_IPHONE_SIMULATOR) | |
#define DEBUG_BREAK __asm__ __volatile__ ( "bkpt #0\n\t bx lr\n\t" : : : ) | |
#elif UNITY_ANDROID || UNITY_BB10 | |
#define DEBUG_BREAK __builtin_trap() | |
#elif UNITY_LINUX | |
#define DEBUG_BREAK if (IsDebuggerPresent ()) raise(SIGTRAP) | |
#else | |
/* a bunch of NDA platforms that I've removed /* | |
#endif |
You should maybe put a do { ... } while(false) around those conditionals, or you can get unexpected results if someone should use them in an if...else statement
@bionicbeagle: sure, and we do have a do..while around most of these macros, but not around this one. Maybe someday someone will fix it :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I knew there was a reason I disliked PPC