Index: libcfa/src/concurrency/preemption.cfa
===================================================================
--- libcfa/src/concurrency/preemption.cfa	(revision 1bcbf025a64d88a84a86c7b5d07e08eaeefc8b36)
+++ libcfa/src/concurrency/preemption.cfa	(revision e228f46559ffceeb1ba2edf67158058beed42eeb)
@@ -238,5 +238,5 @@
 //----------
 // special case for preemption since used often
-__attribute__((optimize("no-reorder-blocks"))) bool __preemption_enabled() libcfa_public {
+__attribute__((optimize("no-reorder-blocks"))) bool __preemption_enabled() libcfa_nopreempt libcfa_public {
 	// create a assembler label before
 	// marked as clobber all to avoid movement
@@ -272,9 +272,24 @@
 }
 
+extern "C" {
+	__attribute__((visibility("hidden"))) extern void * const __start_cfatext_nopreempt;
+	__attribute__((visibility("hidden"))) extern void * const __stop_cfatext_nopreempt;
+
+	extern const __cfa_nopreempt_region __libcfa_nopreempt;
+	__attribute__((visibility("protected"))) const __cfa_nopreempt_region __libcfathrd_nopreempt @= {
+		(void * const)&__start_cfatext_nopreempt,
+		(void * const)&__stop_cfatext_nopreempt
+	};
+}
+
+static inline bool __cfaabi_in( void * const ip, const struct __cfa_nopreempt_region & const region ) {
+	return ip >= region.start && ip <= region.stop;
+}
+
 
 //----------
 // Get data from the TLS block
 // struct asm_region __cfaasm_get;
-uintptr_t __cfatls_get( unsigned long int offset ) __attribute__((__noinline__, visibility("default"))); //no inline to avoid problems
+uintptr_t __cfatls_get( unsigned long int offset ) libcfa_nopreempt libcfa_public; //no inline to avoid problems
 uintptr_t __cfatls_get( unsigned long int offset ) {
 	// create a assembler label before
@@ -295,5 +310,5 @@
 extern "C" {
 	// Disable interrupts by incrementing the counter
-	__attribute__((__noinline__, visibility("default"))) void disable_interrupts() libcfa_public {
+	void disable_interrupts() libcfa_nopreempt libcfa_public {
 		// create a assembler label before
 		// marked as clobber all to avoid movement
@@ -326,5 +341,5 @@
 	// Enable interrupts by decrementing the counter
 	// If counter reaches 0, execute any pending __cfactx_switch
-	void enable_interrupts( bool poll ) libcfa_public {
+	void enable_interrupts( bool poll ) libcfa_nopreempt libcfa_public {
 		// Cache the processor now since interrupts can start happening after the atomic store
 		processor   * proc = __cfaabi_tls.this_processor;
@@ -486,84 +501,4 @@
 
 //-----------------------------------------------------------------------------
-// Some assembly required
-#if defined( __i386 )
-	#ifdef __PIC__
-		#define RELOC_PRELUDE( label ) \
-			"calll   .Lcfaasm_prelude_" #label "$pb\n\t" \
-			".Lcfaasm_prelude_" #label "$pb:\n\t" \
-			"popl    %%eax\n\t" \
-			".Lcfaasm_prelude_" #label "_end:\n\t" \
-			"addl    $_GLOBAL_OFFSET_TABLE_+(.Lcfaasm_prelude_" #label "_end-.Lcfaasm_prelude_" #label "$pb), %%eax\n\t"
-		#define RELOC_PREFIX ""
-		#define RELOC_SUFFIX "@GOT(%%eax)"
-	#else
-		#define RELOC_PREFIX "$"
-		#define RELOC_SUFFIX ""
-	#endif
-	#define __cfaasm_label( label ) struct asm_region label = \
-		({ \
-			struct asm_region region; \
-			asm( \
-				RELOC_PRELUDE( label ) \
-				"movl " RELOC_PREFIX "__cfaasm_" #label "_before" RELOC_SUFFIX ", %[vb]\n\t" \
-				"movl " RELOC_PREFIX "__cfaasm_" #label "_after"  RELOC_SUFFIX ", %[va]\n\t" \
-				 : [vb]"=r"(region.before), [va]"=r"(region.after) \
-			); \
-			region; \
-		});
-#elif defined( __x86_64 )
-	#ifdef __PIC__
-		#define RELOC_PREFIX ""
-		#define RELOC_SUFFIX "@GOTPCREL(%%rip)"
-	#else
-		#define RELOC_PREFIX "$"
-		#define RELOC_SUFFIX ""
-	#endif
-	#define __cfaasm_label( label ) struct asm_region label = \
-		({ \
-			struct asm_region region; \
-			asm( \
-				"movq " RELOC_PREFIX "__cfaasm_" #label "_before" RELOC_SUFFIX ", %[vb]\n\t" \
-				"movq " RELOC_PREFIX "__cfaasm_" #label "_after"  RELOC_SUFFIX ", %[va]\n\t" \
-				 : [vb]"=r"(region.before), [va]"=r"(region.after) \
-			); \
-			region; \
-		});
-#elif defined( __aarch64__ )
-	#ifdef __PIC__
-		// Note that this works only for gcc
-		#define __cfaasm_label( label ) struct asm_region label = \
-		({ \
-			struct asm_region region; \
-			asm( \
-				"adrp %[vb], _GLOBAL_OFFSET_TABLE_"                              "\n\t" \
-        			"ldr  %[vb], [%[vb], #:gotpage_lo15:__cfaasm_" #label "_before]" "\n\t" \
-				"adrp %[va], _GLOBAL_OFFSET_TABLE_"                              "\n\t" \
-        			"ldr  %[va], [%[va], #:gotpage_lo15:__cfaasm_" #label "_after]"  "\n\t" \
-				 : [vb]"=r"(region.before), [va]"=r"(region.after) \
-			); \
-			region; \
-		});
-	#else
-		#error this is not the right thing to do
-		/*
-		#define __cfaasm_label( label ) struct asm_region label = \
-		({ \
-			struct asm_region region; \
-			asm( \
-				"adrp %[vb], __cfaasm_" #label "_before"              "\n\t" \
-        			"add  %[vb], %[vb], :lo12:__cfaasm_" #label "_before" "\n\t" \
-				"adrp %[va], :got:__cfaasm_" #label "_after"          "\n\t" \
-        			"add  %[va], %[va], :lo12:__cfaasm_" #label "_after"  "\n\t" \
-				 : [vb]"=r"(region.before), [va]"=r"(region.after) \
-			); \
-			region; \
-		});
-		*/
-	#endif
-#else
-	#error unknown hardware architecture
-#endif
-
 // KERNEL ONLY
 // Check if a __cfactx_switch signal handler shoud defer
@@ -571,16 +506,9 @@
 // If false : preemption is unsafe and marked as pending
 static inline bool preemption_ready( void * ip ) {
-	// Get all the region for which it is not safe to preempt
-	__cfaasm_label( get    );
-	__cfaasm_label( check  );
-	__cfaasm_label( dsable );
-	// __cfaasm_label( debug  );
-
 	// Check if preemption is safe
 	bool ready = true;
-	if( __cfaasm_in( ip, get    ) ) { ready = false; goto EXIT; };
-	if( __cfaasm_in( ip, check  ) ) { ready = false; goto EXIT; };
-	if( __cfaasm_in( ip, dsable ) ) { ready = false; goto EXIT; };
-	// if( __cfaasm_in( ip, debug  ) ) { ready = false; goto EXIT; };
+	if( __cfaabi_in( ip, __libcfa_nopreempt ) ) { ready = false; goto EXIT; };
+	if( __cfaabi_in( ip, __libcfathrd_nopreempt ) ) { ready = false; goto EXIT; };
+
 	if( !__cfaabi_tls.preemption_state.enabled) { ready = false; goto EXIT; };
 	if( __cfaabi_tls.preemption_state.in_progress ) { ready = false; goto EXIT; };
