Index: libcfa/src/concurrency/monitor.cfa
===================================================================
--- libcfa/src/concurrency/monitor.cfa	(revision 43784ac7ca1579ca19d7dc8bc4e1423986fd4d97)
+++ libcfa/src/concurrency/monitor.cfa	(revision 6ff08d8fa68f653d45a0ec10f0c2b0d9842f1f2a)
@@ -5,5 +5,5 @@
 // file "LICENCE" distributed with Cforall.
 //
-// $monitor.c --
+// monitor.cfa --
 //
 // Author           : Thierry Delisle
@@ -28,31 +28,31 @@
 //-----------------------------------------------------------------------------
 // Forward declarations
-static inline void __set_owner ( $monitor * this, $thread * owner );
-static inline void __set_owner ( $monitor * storage [], __lock_size_t count, $thread * owner );
-static inline void set_mask  ( $monitor * storage [], __lock_size_t count, const __waitfor_mask_t & mask );
-static inline void reset_mask( $monitor * this );
-
-static inline $thread * next_thread( $monitor * this );
-static inline bool is_accepted( $monitor * this, const __monitor_group_t & monitors );
+static inline void __set_owner ( monitor$ * this, thread$ * owner );
+static inline void __set_owner ( monitor$ * storage [], __lock_size_t count, thread$ * owner );
+static inline void set_mask  ( monitor$ * storage [], __lock_size_t count, const __waitfor_mask_t & mask );
+static inline void reset_mask( monitor$ * this );
+
+static inline thread$ * next_thread( monitor$ * this );
+static inline bool is_accepted( monitor$ * this, const __monitor_group_t & monitors );
 
 static inline void lock_all  ( __spinlock_t * locks [], __lock_size_t count );
-static inline void lock_all  ( $monitor * source [], __spinlock_t * /*out*/ locks [], __lock_size_t count );
+static inline void lock_all  ( monitor$ * source [], __spinlock_t * /*out*/ locks [], __lock_size_t count );
 static inline void unlock_all( __spinlock_t * locks [], __lock_size_t count );
-static inline void unlock_all( $monitor * locks [], __lock_size_t count );
-
-static inline void save   ( $monitor * ctx [], __lock_size_t count, __spinlock_t * locks [], unsigned int /*out*/ recursions [], __waitfor_mask_t /*out*/ masks [] );
-static inline void restore( $monitor * ctx [], __lock_size_t count, __spinlock_t * locks [], unsigned int /*in */ recursions [], __waitfor_mask_t /*in */ masks [] );
-
-static inline void init     ( __lock_size_t count, $monitor * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] );
-static inline void init_push( __lock_size_t count, $monitor * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] );
-
-static inline $thread *        check_condition   ( __condition_criterion_t * );
+static inline void unlock_all( monitor$ * locks [], __lock_size_t count );
+
+static inline void save   ( monitor$ * ctx [], __lock_size_t count, __spinlock_t * locks [], unsigned int /*out*/ recursions [], __waitfor_mask_t /*out*/ masks [] );
+static inline void restore( monitor$ * ctx [], __lock_size_t count, __spinlock_t * locks [], unsigned int /*in */ recursions [], __waitfor_mask_t /*in */ masks [] );
+
+static inline void init     ( __lock_size_t count, monitor$ * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] );
+static inline void init_push( __lock_size_t count, monitor$ * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] );
+
+static inline thread$ *        check_condition   ( __condition_criterion_t * );
 static inline void                 brand_condition   ( condition & );
-static inline [$thread *, int] search_entry_queue( const __waitfor_mask_t &, $monitor * monitors [], __lock_size_t count );
+static inline [thread$ *, int] search_entry_queue( const __waitfor_mask_t &, monitor$ * monitors [], __lock_size_t count );
 
 forall(T & | sized( T ))
 static inline __lock_size_t insert_unique( T * array [], __lock_size_t & size, T * val );
 static inline __lock_size_t count_max    ( const __waitfor_mask_t & mask );
-static inline __lock_size_t aggregate    ( $monitor * storage [], const __waitfor_mask_t & mask );
+static inline __lock_size_t aggregate    ( monitor$ * storage [], const __waitfor_mask_t & mask );
 
 //-----------------------------------------------------------------------------
@@ -69,5 +69,5 @@
 
 #define monitor_ctx( mons, cnt )                                /* Define that create the necessary struct for internal/external scheduling operations */ \
-	$monitor ** monitors = mons;                          /* Save the targeted monitors                                                          */ \
+	monitor$ ** monitors = mons;                          /* Save the targeted monitors                                                          */ \
 	__lock_size_t count = cnt;                                /* Save the count to a local variable                                                  */ \
 	unsigned int recursions[ count ];                         /* Save the current recursion levels to restore them later                             */ \
@@ -82,6 +82,6 @@
 // Enter/Leave routines
 // Enter single monitor
-static void __enter( $monitor * this, const __monitor_group_t & group ) {
-	$thread * thrd = active_thread();
+static void __enter( monitor$ * this, const __monitor_group_t & group ) {
+	thread$ * thrd = active_thread();
 
 	// Lock the monitor spinlock
@@ -141,6 +141,6 @@
 }
 
-static void __dtor_enter( $monitor * this, fptr_t func, bool join ) {
-	$thread * thrd = active_thread();
+static void __dtor_enter( monitor$ * this, fptr_t func, bool join ) {
+	thread$ * thrd = active_thread();
 	#if defined( __CFA_WITH_VERIFY__ )
 		bool is_thrd = this == &thrd->self_mon;
@@ -173,5 +173,5 @@
 	// because join will not release the monitor after it executed.
 	// to avoid that it sets the owner to the special value thrd | 1p before exiting
-	else if( this->owner == ($thread*)(1 | (uintptr_t)thrd) ) {
+	else if( this->owner == (thread$*)(1 | (uintptr_t)thrd) ) {
 		// restore the owner and just return
 		__cfaabi_dbg_print_safe( "Kernel : Destroying free mon %p\n", this);
@@ -191,5 +191,5 @@
 
 	__lock_size_t count = 1;
-	$monitor ** monitors = &this;
+	monitor$ ** monitors = &this;
 	__monitor_group_t group = { &this, 1, func };
 	if( is_accepted( this, group) ) {
@@ -243,5 +243,5 @@
 
 // Leave single monitor
-void __leave( $monitor * this ) {
+void __leave( monitor$ * this ) {
 	// Lock the monitor spinlock
 	lock( this->lock __cfaabi_dbg_ctx2 );
@@ -263,5 +263,5 @@
 
 	// Get the next thread, will be null on low contention monitor
-	$thread * new_owner = next_thread( this );
+	thread$ * new_owner = next_thread( this );
 
 	// Check the new owner is consistent with who we wake-up
@@ -278,5 +278,5 @@
 
 // Leave single monitor for the last time
-void __dtor_leave( $monitor * this, bool join ) {
+void __dtor_leave( monitor$ * this, bool join ) {
 	__cfaabi_dbg_debug_do(
 		if( active_thread() != this->owner ) {
@@ -288,9 +288,9 @@
 	)
 
-	this->owner = ($thread*)(1 | (uintptr_t)this->owner);
-}
-
-void __thread_finish( $thread * thrd ) {
-	$monitor * this = &thrd->self_mon;
+	this->owner = (thread$*)(1 | (uintptr_t)this->owner);
+}
+
+void __thread_finish( thread$ * thrd ) {
+	monitor$ * this = &thrd->self_mon;
 
 	// Lock the monitor now
@@ -298,6 +298,6 @@
 	/* paranoid */ verify( this->lock.lock );
 	/* paranoid */ verify( thrd->context.SP );
-	/* paranoid */ verifyf( ((uintptr_t)thrd->context.SP) > ((uintptr_t)__get_stack(thrd->curr_cor)->limit), "ERROR : $thread %p has been corrupted.\n StackPointer too large.\n", thrd );
-	/* paranoid */ verifyf( ((uintptr_t)thrd->context.SP) < ((uintptr_t)__get_stack(thrd->curr_cor)->base ), "ERROR : $thread %p has been corrupted.\n StackPointer too small.\n", thrd );
+	/* paranoid */ verifyf( ((uintptr_t)thrd->context.SP) > ((uintptr_t)__get_stack(thrd->curr_cor)->limit), "ERROR : thread$ %p has been corrupted.\n StackPointer too large.\n", thrd );
+	/* paranoid */ verifyf( ((uintptr_t)thrd->context.SP) < ((uintptr_t)__get_stack(thrd->curr_cor)->base ), "ERROR : thread$ %p has been corrupted.\n StackPointer too small.\n", thrd );
 	/* paranoid */ verify( ! __preemption_enabled() );
 
@@ -311,5 +311,5 @@
 
 	// Fetch the next thread, can be null
-	$thread * new_owner = next_thread( this );
+	thread$ * new_owner = next_thread( this );
 
 	// Mark the state as fully halted
@@ -336,5 +336,5 @@
 // Leave multiple monitor
 // relies on the monitor array being sorted
-static inline void leave($monitor * monitors [], __lock_size_t count) {
+static inline void leave(monitor$ * monitors [], __lock_size_t count) {
 	for( __lock_size_t i = count - 1; i >= 0; i--) {
 		__leave( monitors[i] );
@@ -344,6 +344,6 @@
 // Ctor for monitor guard
 // Sorts monitors before entering
-void ?{}( monitor_guard_t & this, $monitor * m [], __lock_size_t count, fptr_t func ) {
-	$thread * thrd = active_thread();
+void ?{}( monitor_guard_t & this, monitor$ * m [], __lock_size_t count, fptr_t func ) {
+	thread$ * thrd = active_thread();
 
 	// Store current array
@@ -385,7 +385,7 @@
 // Ctor for monitor guard
 // Sorts monitors before entering
-void ?{}( monitor_dtor_guard_t & this, $monitor * m [], fptr_t func, bool join ) {
+void ?{}( monitor_dtor_guard_t & this, monitor$ * m [], fptr_t func, bool join ) {
 	// optimization
-	$thread * thrd = active_thread();
+	thread$ * thrd = active_thread();
 
 	// Store current array
@@ -415,5 +415,5 @@
 //-----------------------------------------------------------------------------
 // Internal scheduling types
-void ?{}(__condition_node_t & this, $thread * waiting_thread, __lock_size_t count, uintptr_t user_info ) {
+void ?{}(__condition_node_t & this, thread$ * waiting_thread, __lock_size_t count, uintptr_t user_info ) {
 	this.waiting_thread = waiting_thread;
 	this.count = count;
@@ -429,5 +429,5 @@
 }
 
-void ?{}(__condition_criterion_t & this, $monitor * target, __condition_node_t & owner ) {
+void ?{}(__condition_criterion_t & this, monitor$ * target, __condition_node_t & owner ) {
 	this.ready  = false;
 	this.target = target;
@@ -463,5 +463,5 @@
 	// Find the next thread(s) to run
 	__lock_size_t thread_count = 0;
-	$thread * threads[ count ];
+	thread$ * threads[ count ];
 	__builtin_memset( threads, 0, sizeof( threads ) );
 
@@ -471,5 +471,5 @@
 	// Remove any duplicate threads
 	for( __lock_size_t i = 0; i < count; i++) {
-		$thread * new_owner = next_thread( monitors[i] );
+		thread$ * new_owner = next_thread( monitors[i] );
 		insert_unique( threads, thread_count, new_owner );
 	}
@@ -501,5 +501,5 @@
 	//Some more checking in debug
 	__cfaabi_dbg_debug_do(
-		$thread * this_thrd = active_thread();
+		thread$ * this_thrd = active_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 );
@@ -555,5 +555,5 @@
 
 	//Find the thread to run
-	$thread * signallee = pop_head( this.blocked )->waiting_thread;
+	thread$ * signallee = pop_head( this.blocked )->waiting_thread;
 	__set_owner( monitors, count, signallee );
 
@@ -608,5 +608,5 @@
 	// Create one!
 	__lock_size_t max = count_max( mask );
-	$monitor * mon_storage[max];
+	monitor$ * mon_storage[max];
 	__builtin_memset( mon_storage, 0, sizeof( mon_storage ) );
 	__lock_size_t actual_count = aggregate( mon_storage, mask );
@@ -626,5 +626,5 @@
 	{
 		// Check if the entry queue
-		$thread * next; int index;
+		thread$ * next; int index;
 		[next, index] = search_entry_queue( mask, monitors, count );
 
@@ -636,5 +636,5 @@
 				verifyf( accepted.size == 1,  "ERROR: Accepted dtor has more than 1 mutex parameter." );
 
-				$monitor * mon2dtor = accepted[0];
+				monitor$ * mon2dtor = accepted[0];
 				verifyf( mon2dtor->dtor_node, "ERROR: Accepted monitor has no dtor_node." );
 
@@ -730,5 +730,5 @@
 // Utilities
 
-static inline void __set_owner( $monitor * this, $thread * owner ) {
+static inline void __set_owner( monitor$ * this, thread$ * owner ) {
 	/* paranoid */ verify( this->lock.lock );
 
@@ -740,5 +740,5 @@
 }
 
-static inline void __set_owner( $monitor * monitors [], __lock_size_t count, $thread * owner ) {
+static inline void __set_owner( monitor$ * monitors [], __lock_size_t count, thread$ * owner ) {
 	/* paranoid */ verify ( monitors[0]->lock.lock );
 	/* paranoid */ verifyf( monitors[0]->owner == active_thread(), "Expected owner to be %p, got %p (r: %i, m: %p)", active_thread(), monitors[0]->owner, monitors[0]->recursion, monitors[0] );
@@ -753,5 +753,5 @@
 }
 
-static inline void set_mask( $monitor * storage [], __lock_size_t count, const __waitfor_mask_t & mask ) {
+static inline void set_mask( monitor$ * storage [], __lock_size_t count, const __waitfor_mask_t & mask ) {
 	for( __lock_size_t i = 0; i < count; i++) {
 		storage[i]->mask = mask;
@@ -759,5 +759,5 @@
 }
 
-static inline void reset_mask( $monitor * this ) {
+static inline void reset_mask( monitor$ * this ) {
 	this->mask.accepted = 0p;
 	this->mask.data = 0p;
@@ -765,5 +765,5 @@
 }
 
-static inline $thread * next_thread( $monitor * this ) {
+static inline thread$ * next_thread( monitor$ * this ) {
 	//Check the signaller stack
 	__cfaabi_dbg_print_safe( "Kernel :  mon %p AS-stack top %p\n", this, this->signal_stack.top);
@@ -781,5 +781,5 @@
 	// No signaller thread
 	// Get the next thread in the entry_queue
-	$thread * new_owner = pop_head( this->entry_queue );
+	thread$ * new_owner = pop_head( this->entry_queue );
 	/* paranoid */ verifyf( !this->owner || active_thread() == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", active_thread(), this->owner, this->recursion, this );
 	/* paranoid */ verify( !new_owner || new_owner->link.next == 0p );
@@ -789,5 +789,5 @@
 }
 
-static inline bool is_accepted( $monitor * this, const __monitor_group_t & group ) {
+static inline bool is_accepted( monitor$ * this, const __monitor_group_t & group ) {
 	__acceptable_t * it = this->mask.data; // Optim
 	__lock_size_t count = this->mask.size;
@@ -811,5 +811,5 @@
 }
 
-static inline void init( __lock_size_t count, $monitor * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] ) {
+static inline void init( __lock_size_t count, monitor$ * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] ) {
 	for( __lock_size_t i = 0; i < count; i++) {
 		(criteria[i]){ monitors[i], waiter };
@@ -819,5 +819,5 @@
 }
 
-static inline void init_push( __lock_size_t count, $monitor * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] ) {
+static inline void init_push( __lock_size_t count, monitor$ * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] ) {
 	for( __lock_size_t i = 0; i < count; i++) {
 		(criteria[i]){ monitors[i], waiter };
@@ -835,5 +835,5 @@
 }
 
-static inline void lock_all( $monitor * source [], __spinlock_t * /*out*/ locks [], __lock_size_t count ) {
+static inline void lock_all( monitor$ * source [], __spinlock_t * /*out*/ locks [], __lock_size_t count ) {
 	for( __lock_size_t i = 0; i < count; i++ ) {
 		__spinlock_t * l = &source[i]->lock;
@@ -849,5 +849,5 @@
 }
 
-static inline void unlock_all( $monitor * locks [], __lock_size_t count ) {
+static inline void unlock_all( monitor$ * locks [], __lock_size_t count ) {
 	for( __lock_size_t i = 0; i < count; i++ ) {
 		unlock( locks[i]->lock );
@@ -856,5 +856,5 @@
 
 static inline void save(
-	$monitor * ctx [],
+	monitor$ * ctx [],
 	__lock_size_t count,
 	__attribute((unused)) __spinlock_t * locks [],
@@ -869,5 +869,5 @@
 
 static inline void restore(
-	$monitor * ctx [],
+	monitor$ * ctx [],
 	__lock_size_t count,
 	__spinlock_t * locks [],
@@ -887,5 +887,5 @@
 // 2 - Checks if all the monitors are ready to run
 //     if so return the thread to run
-static inline $thread * check_condition( __condition_criterion_t * target ) {
+static inline thread$ * check_condition( __condition_criterion_t * target ) {
 	__condition_node_t * node = target->owner;
 	unsigned short count = node->count;
@@ -910,5 +910,5 @@
 
 static inline void brand_condition( condition & this ) {
-	$thread * thrd = active_thread();
+	thread$ * thrd = active_thread();
 	if( !this.monitors ) {
 		// __cfaabi_dbg_print_safe( "Branding\n" );
@@ -916,5 +916,5 @@
 		this.monitor_count = thrd->monitors.size;
 
-		this.monitors = ($monitor **)malloc( this.monitor_count * sizeof( *this.monitors ) );
+		this.monitors = (monitor$ **)malloc( this.monitor_count * sizeof( *this.monitors ) );
 		for( int i = 0; i < this.monitor_count; i++ ) {
 			this.monitors[i] = thrd->monitors[i];
@@ -923,10 +923,10 @@
 }
 
-static inline [$thread *, int] search_entry_queue( const __waitfor_mask_t & mask, $monitor * monitors [], __lock_size_t count ) {
-
-	__queue_t($thread) & entry_queue = monitors[0]->entry_queue;
+static inline [thread$ *, int] search_entry_queue( const __waitfor_mask_t & mask, monitor$ * monitors [], __lock_size_t count ) {
+
+	__queue_t(thread$) & entry_queue = monitors[0]->entry_queue;
 
 	// For each thread in the entry-queue
-	for(	$thread ** thrd_it = &entry_queue.head;
+	for(	thread$ ** thrd_it = &entry_queue.head;
 		(*thrd_it) != 1p;
 		thrd_it = &(*thrd_it)->link.next
@@ -972,5 +972,5 @@
 }
 
-static inline __lock_size_t aggregate( $monitor * storage [], const __waitfor_mask_t & mask ) {
+static inline __lock_size_t aggregate( monitor$ * storage [], const __waitfor_mask_t & mask ) {
 	__lock_size_t size = 0;
 	for( __lock_size_t i = 0; i < mask.size; i++ ) {
