Index: src/libcfa/concurrency/monitor.c
===================================================================
--- src/libcfa/concurrency/monitor.c	(revision c2ca04d9fcb38436d3cecb12ea970191dac218ab)
+++ src/libcfa/concurrency/monitor.c	(revision b10affdcb702e2f50d20fa65715ce6473d2bebb4)
@@ -10,6 +10,6 @@
 // Created On       : Thd Feb 23 12:27:26 2017
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Feb 16 14:49:53 2018
-// Update Count     : 5
+// Last Modified On : Fri Mar 30 14:30:26 2018
+// Update Count     : 9
 //
 
@@ -85,5 +85,5 @@
 		// Lock the monitor spinlock
 		lock( this->lock __cfaabi_dbg_ctx2 );
-		thread_desc * thrd = this_thread;
+		thread_desc * thrd = TL_GET( this_thread );
 
 		__cfaabi_dbg_print_safe( "Kernel : %10p Entering mon %p (%p)\n", thrd, this, this->owner);
@@ -134,5 +134,5 @@
 		// Lock the monitor spinlock
 		lock( this->lock __cfaabi_dbg_ctx2 );
-		thread_desc * thrd = this_thread;
+		thread_desc * thrd = TL_GET( this_thread );
 
 		__cfaabi_dbg_print_safe( "Kernel : %10p Entering dtor for mon %p (%p)\n", thrd, this, this->owner);
@@ -168,5 +168,5 @@
 
 			// Create the node specific to this wait operation
-			wait_ctx_primed( this_thread, 0 )
+			wait_ctx_primed( TL_GET( this_thread ), 0 )
 
 			// Some one else has the monitor, wait for him to finish and then run
@@ -179,5 +179,5 @@
 			__cfaabi_dbg_print_safe( "Kernel :  blocking \n" );
 
-			wait_ctx( this_thread, 0 )
+			wait_ctx( TL_GET( this_thread ), 0 )
 			this->dtor_node = &waiter;
 
@@ -199,7 +199,7 @@
 		lock( this->lock __cfaabi_dbg_ctx2 );
 
-		__cfaabi_dbg_print_safe( "Kernel : %10p Leaving mon %p (%p)\n", this_thread, this, this->owner);
-
-		verifyf( this_thread == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", this_thread, this->owner, this->recursion, this );
+		__cfaabi_dbg_print_safe( "Kernel : %10p Leaving mon %p (%p)\n", TL_GET( this_thread ), this, this->owner);
+
+		verifyf( TL_GET( this_thread ) == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", TL_GET( this_thread ), this->owner, this->recursion, this );
 
 		// Leaving a recursion level, decrement the counter
@@ -227,6 +227,6 @@
 	void __leave_dtor_monitor_desc( monitor_desc * this ) {
 		__cfaabi_dbg_debug_do(
-			if( this_thread != this->owner ) {
-				abort( "Destroyed monitor %p has inconsistent owner, expected %p got %p.\n", this, this_thread, this->owner);
+			if( TL_GET( this_thread ) != this->owner ) {
+				abort( "Destroyed monitor %p has inconsistent owner, expected %p got %p.\n", this, TL_GET( this_thread ), this->owner);
 			}
 			if( this->recursion != 1 ) {
@@ -297,8 +297,8 @@
 
 	// Save previous thread context
-	this.prev = this_thread->monitors;
+	this.prev = TL_GET( this_thread )->monitors;
 
 	// Update thread context (needed for conditions)
-	(this_thread->monitors){m, count, func};
+	(TL_GET( this_thread )->monitors){m, count, func};
 
 	// __cfaabi_dbg_print_safe( "MGUARD : enter %d\n", count);
@@ -322,5 +322,5 @@
 
 	// Restore thread context
-	this_thread->monitors = this.prev;
+	TL_GET( this_thread )->monitors = this.prev;
 }
 
@@ -332,8 +332,8 @@
 
 	// Save previous thread context
-	this.prev = this_thread->monitors;
+	this.prev = TL_GET( this_thread )->monitors;
 
 	// Update thread context (needed for conditions)
-	(this_thread->monitors){m, 1, func};
+	(TL_GET( this_thread )->monitors){m, 1, func};
 
 	__enter_monitor_dtor( this.m, func );
@@ -346,5 +346,5 @@
 
 	// Restore thread context
-	this_thread->monitors = this.prev;
+	TL_GET( this_thread )->monitors = this.prev;
 }
 
@@ -386,5 +386,5 @@
 
 	// Create the node specific to this wait operation
-	wait_ctx( this_thread, user_info );
+	wait_ctx( TL_GET( this_thread ), user_info );
 
 	// Append the current wait operation to the ones already queued on the condition
@@ -425,5 +425,5 @@
 	//Some more checking in debug
 	__cfaabi_dbg_debug_do(
-		thread_desc * this_thrd = this_thread;
+		thread_desc * this_thrd = TL_GET( this_thread );
 		if ( this.monitor_count != this_thrd->monitors.size ) {
 			abort( "Signal on condition %p made with different number of monitor(s), expected %zi got %zi", &this, this.monitor_count, this_thrd->monitors.size );
@@ -473,5 +473,5 @@
 
 	// Create the node specific to this wait operation
-	wait_ctx_primed( this_thread, 0 )
+	wait_ctx_primed( TL_GET( this_thread ), 0 )
 
 	//save contexts
@@ -566,5 +566,5 @@
 
 				// Create the node specific to this wait operation
-				wait_ctx_primed( this_thread, 0 );
+				wait_ctx_primed( TL_GET( this_thread ), 0 );
 
 				// Save monitor states
@@ -612,5 +612,5 @@
 
 	// Create the node specific to this wait operation
-	wait_ctx_primed( this_thread, 0 );
+	wait_ctx_primed( TL_GET( this_thread ), 0 );
 
 	monitor_save;
@@ -618,5 +618,5 @@
 
 	for( __lock_size_t i = 0; i < count; i++) {
-		verify( monitors[i]->owner == this_thread );
+		verify( monitors[i]->owner == TL_GET( this_thread ) );
 	}
 
@@ -812,5 +812,5 @@
 
 static inline void brand_condition( condition & this ) {
-	thread_desc * thrd = this_thread;
+	thread_desc * thrd = TL_GET( this_thread );
 	if( !this.monitors ) {
 		// __cfaabi_dbg_print_safe( "Branding\n" );
