Index: src/libcfa/concurrency/preemption.c
===================================================================
--- src/libcfa/concurrency/preemption.c	(revision 65deb18a7ffff4dccefdf2611afde3cadd19efb0)
+++ src/libcfa/concurrency/preemption.c	(revision 7416d46ae4c80902ec659807c72c4b3d78cdba5c)
@@ -10,25 +10,20 @@
 // Created On       : Mon Jun 5 14:20:42 2017
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Jul 21 22:36:05 2017
-// Update Count     : 2
+// Last Modified On : Tue Jan 23 17:59:30 2018
+// Update Count     : 7
 //
 
 #include "preemption.h"
 
+#define ftype `ftype`
 extern "C" {
 #include <errno.h>
-#include <execinfo.h>
-#define __USE_GNU
-#include <signal.h>
-#undef __USE_GNU
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
 }
-
-
-#ifdef __USE_STREAM__
-#include "fstream"
-#endif
+#undef ftype
+
+#include "bits/signal.h"
 
 //TODO move to defaults
@@ -39,8 +34,4 @@
 	return __CFA_DEFAULT_PREEMPTION__;
 }
-
-// Short hands for signal context information
-#define __CFA_SIGCXT__ ucontext_t *
-#define __CFA_SIGPARMS__ __attribute__((unused)) int sig, __attribute__((unused)) siginfo_t *sfp, __attribute__((unused)) __CFA_SIGCXT__ cxt
 
 // FwdDeclarations : timeout handlers
@@ -53,15 +44,14 @@
 void sigHandler_abort    ( __CFA_SIGPARMS__ );
 
-// FwdDeclarations : sigaction wrapper
-static void __kernel_sigaction( int sig, void (*handler)(__CFA_SIGPARMS__), int flags );
-
 // FwdDeclarations : alarm thread main
 void * alarm_loop( __attribute__((unused)) void * args );
 
 // Machine specific register name
-#ifdef __x86_64__
+#if   defined(__x86_64__)
 #define CFA_REG_IP REG_RIP
-#else
+#elif defined(__i386__)
 #define CFA_REG_IP REG_EIP
+#elif defined(__ARM_ARCH__)
+#define CFA_REG_IP REG_R15
 #endif
 
@@ -179,5 +169,5 @@
 	void enable_interrupts_noPoll() {
 		__attribute__((unused)) unsigned short prev = __atomic_fetch_add_2( &disable_preempt_count, -1, __ATOMIC_SEQ_CST );
-		verify( prev != 0u );                     // If this triggers someone is enabled already enabled interrupts
+		verifyf( prev != 0u, "Incremented from %u\n", prev );                     // If this triggers someone is enabled already enabled interrupts
 	}
 }
@@ -243,6 +233,4 @@
 	// Setup proper signal handlers
 	__kernel_sigaction( SIGUSR1, sigHandler_ctxSwitch, SA_SIGINFO | SA_RESTART );         // CtxSwitch handler
-	// __kernel_sigaction( SIGSEGV, sigHandler_segv     , SA_SIGINFO );      // Failure handler
-	// __kernel_sigaction( SIGBUS , sigHandler_segv     , SA_SIGINFO );      // Failure handler
 
 	signal_block( SIGALRM );
@@ -296,8 +284,14 @@
 // Receives SIGUSR1 signal and causes the current thread to yield
 void sigHandler_ctxSwitch( __CFA_SIGPARMS__ ) {
+#if defined( __ARM_ARCH )
+	__cfaabi_dbg_debug_do( last_interrupt = (void *)(cxt->uc_mcontext.arm_pc); )
+#else
 	__cfaabi_dbg_debug_do( last_interrupt = (void *)(cxt->uc_mcontext.gregs[CFA_REG_IP]); )
-
-	// Check if it is safe to preempt here
+#endif
+
+		// Check if it is safe to preempt here
 	if( !preemption_ready() ) { return; }
+
+	__cfaabi_dbg_print_buffer_decl(" KERNEL: preempting core %p (%p).\n", this_processor, this_thread);
 
 	preemption_in_progress = true;                      // Sync flag : prevent recursive calls to the signal handler
@@ -371,133 +365,4 @@
 }
 
-// Sigaction wrapper : register an signal handler
-static void __kernel_sigaction( int sig, void (*handler)(__CFA_SIGPARMS__), int flags ) {
-	struct sigaction act;
-
-	act.sa_sigaction = (void (*)(int, siginfo_t *, void *))handler;
-	act.sa_flags = flags;
-
-	if ( sigaction( sig, &act, NULL ) == -1 ) {
-		__cfaabi_dbg_print_buffer_decl(
-			" __kernel_sigaction( sig:%d, handler:%p, flags:%d ), problem installing signal handler, error(%d) %s.\n",
-			sig, handler, flags, errno, strerror( errno )
-		);
-		_exit( EXIT_FAILURE );
-	}
-}
-
-// Sigaction wrapper : restore default handler
-static void __kernel_sigdefault( int sig ) {
-	struct sigaction act;
-
-	act.sa_handler = SIG_DFL;
-	act.sa_flags = 0;
-	sigemptyset( &act.sa_mask );
-
-	if ( sigaction( sig, &act, NULL ) == -1 ) {
-		__cfaabi_dbg_print_buffer_decl(
-			" __kernel_sigdefault( sig:%d ), problem reseting signal handler, error(%d) %s.\n",
-			sig, errno, strerror( errno )
-		);
-		_exit( EXIT_FAILURE );
-	}
-}
-
-//=============================================================================================
-// Terminating Signals logic
-//=============================================================================================
-
-__cfaabi_dbg_debug_do(
-	static void __kernel_backtrace( int start ) {
-		// skip first N stack frames
-
-		enum { Frames = 50 };
-		void * array[Frames];
-		int size = backtrace( array, Frames );
-		char ** messages = backtrace_symbols( array, size );
-
-		// find executable name
-		*index( messages[0], '(' ) = '\0';
-		#ifdef __USE_STREAM__
-		serr | "Stack back trace for:" | messages[0] | endl;
-		#else
-		fprintf( stderr, "Stack back trace for: %s\n", messages[0]);
-		#endif
-
-		// skip last 2 stack frames after main
-		for ( int i = start; i < size && messages != NULL; i += 1 ) {
-			char * name = NULL;
-			char * offset_begin = NULL;
-			char * offset_end = NULL;
-
-			for ( char *p = messages[i]; *p; ++p ) {
-				// find parantheses and +offset
-				if ( *p == '(' ) {
-					name = p;
-				}
-				else if ( *p == '+' ) {
-					offset_begin = p;
-				}
-				else if ( *p == ')' ) {
-					offset_end = p;
-					break;
-				}
-			}
-
-			// if line contains symbol print it
-			int frameNo = i - start;
-			if ( name && offset_begin && offset_end && name < offset_begin ) {
-				// delimit strings
-				*name++ = '\0';
-				*offset_begin++ = '\0';
-				*offset_end++ = '\0';
-
-				#ifdef __USE_STREAM__
-				serr 	| "("  | frameNo | ")" | messages[i] | ":"
-					| name | "+" | offset_begin | offset_end | endl;
-				#else
-				fprintf( stderr, "(%i) %s : %s + %s %s\n", frameNo, messages[i], name, offset_begin, offset_end);
-				#endif
-			}
-			// otherwise, print the whole line
-			else {
-				#ifdef __USE_STREAM__
-				serr | "(" | frameNo | ")" | messages[i] | endl;
-				#else
-				fprintf( stderr, "(%i) %s\n", frameNo, messages[i] );
-				#endif
-			}
-		}
-
-		free( messages );
-	}
-)
-
-// void sigHandler_segv( __CFA_SIGPARMS__ ) {
-// 	__cfaabi_dbg_debug_do(
-// 		#ifdef __USE_STREAM__
-// 		serr 	| "*CFA runtime error* program cfa-cpp terminated with"
-// 			| (sig == SIGSEGV ? "segment fault." : "bus error.")
-// 			| endl;
-// 		#else
-// 		fprintf( stderr, "*CFA runtime error* program cfa-cpp terminated with %s\n", sig == SIGSEGV ? "segment fault." : "bus error." );
-// 		#endif
-
-// 		// skip first 2 stack frames
-// 		__kernel_backtrace( 1 );
-// 	)
-// 	exit( EXIT_FAILURE );
-// }
-
-// void sigHandler_abort( __CFA_SIGPARMS__ ) {
-// 	// skip first 6 stack frames
-// 	__cfaabi_dbg_debug_do( __kernel_backtrace( 6 ); )
-
-// 	// reset default signal handler
-// 	__kernel_sigdefault( SIGABRT );
-
-// 	raise( SIGABRT );
-// }
-
 // Local Variables: //
 // mode: c //
