//
//  BSDebugBreak.h
//
//  Created by Dan Wright on 7-April-09, updated 21-August-09
//  Copyright 2009 Banasmoo Software. Do with it what you will: this code may be used,
//  modified or not, in any code that is NOT subject to the GNU Public License (GPL).
//

#import <Foundation/Foundation.h>

#ifndef NDEBUG
#ifndef DEBUG
#define DEBUG 1
#endif
#endif /* !NDEBUG */

#ifdef DEBUG

#if __ppc64__ || __ppc__
#define BSDebugBreak() \
		do { \
		__asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \
			: : : "memory","r0","r3","r4" ); \
			} while(0)
#elif __i386__ || __x86_64__
#define BSDebugBreak() do {__asm__("int $3\n" : : );} while (0)
#elif __arm__
#define BSDebugBreak() \
		do { \
		__asm__("mov r0, #20\nmov ip, r0\nsvc 128\nmov r1, #37\nmov ip, r1\nmov r1, #2\nmov r2, #1\n svc 128\n" \
			: : : "memory","ip","r0","r1","r2"); \
			} while (0)
#else
#define BSDebugBreak() raise(SIGINT)
#endif

#else /* DEBUG */

#define BSDebugBreak()


#endif /* DEBUG */
