Index: trunk/kernel/libk/remote_spinlock.c
===================================================================
--- trunk/kernel/libk/remote_spinlock.c	(revision 60)
+++ trunk/kernel/libk/remote_spinlock.c	(revision 93)
@@ -1,5 +1,5 @@
 /*
  * remote_spinlock.c - kernel remote spinlock implementation.
- * 
+ *
  * Authors  Mohamed Karaoui (2015)
  *          Alain   Greiner (2016)
@@ -33,53 +33,53 @@
 ///////////////////////////////////////////
 void remote_spinlock_init( xptr_t lock_xp )
-{ 
-    remote_spinlock_t * ptr = (remote_spinlock_t *)GET_PTR( lock_xp );
-    cxy_t               cxy = GET_CXY( lock_xp );
-
-    hal_remote_sw ( XPTR( cxy , &ptr->taken ) , 0 );
-    hal_remote_swd( XPTR( cxy , &ptr->owner ) , XPTR_NULL );
-    xlist_entry_init( XPTR( cxy , &ptr->list ) ); 
+{
+	remote_spinlock_t * ptr = (remote_spinlock_t *)GET_PTR( lock_xp );
+	cxy_t               cxy = GET_CXY( lock_xp );
+
+	hal_remote_sw ( XPTR( cxy , &ptr->taken ) , 0 );
+	hal_remote_swd( XPTR( cxy , &ptr->owner ) , XPTR_NULL );
+	xlist_entry_init( XPTR( cxy , &ptr->list ) );
 }
 
 /////////////////////////////////////////////////
 error_t remote_spinlock_trylock( xptr_t lock_xp )
-{ 
+{
 	reg_t               mode;
 	bool_t              isAtomic = false;
 
-    // get cluster and local pointer on remote_spinlock
-    remote_spinlock_t * lock_ptr = (remote_spinlock_t *)GET_PTR( lock_xp );
-    cxy_t               lock_cxy = GET_CXY( lock_xp );
-
-    // get cluster and local pointer on local thread
-    cxy_t               thread_cxy = local_cxy;
-    thread_t          * thread_ptr = CURRENT_THREAD;
-
-    // disable interrupts
-    hal_disable_irq( &mode );
+	// get cluster and local pointer on remote_spinlock
+	remote_spinlock_t * lock_ptr = (remote_spinlock_t *)GET_PTR( lock_xp );
+	cxy_t               lock_cxy = GET_CXY( lock_xp );
+
+	// get cluster and local pointer on local thread
+	cxy_t               thread_cxy = local_cxy;
+	thread_t          * thread_ptr = CURRENT_THREAD;
+
+	// disable interrupts
+	hal_disable_irq( &mode );
 
 	if( hal_remote_lw( XPTR( lock_cxy , &lock_ptr->taken ) ) == 0 )
-    {
+	{
 		isAtomic = hal_remote_atomic_cas( XPTR( lock_cxy , &lock_ptr->taken ) , 0 , 1 );
-    }
-
-	if( isAtomic == false )    // failure 
+	}
+
+	if( isAtomic == false )    // failure
 	{
 		hal_restore_irq( mode );
 		return 1;
 	}
-    else                      // success : register lock in thread
-    {
-	    thread_ptr->remote_locks++;
-
-        hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) ,
-                    (uint64_t)XPTR( thread_cxy , thread_ptr) );
-
-        xlist_add_first( XPTR( thread_cxy , &thread_ptr->xlocks_root ) ,
-                     XPTR( lock_cxy , &lock_ptr->list ) );
-
-	    hal_restore_irq(mode);  
-	    return 0;
-    }
+	else                      // success : register lock in thread
+	{
+		thread_ptr->remote_locks++;
+
+		hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) ,
+		            (uint64_t)XPTR( thread_cxy , thread_ptr) );
+
+		xlist_add_first( XPTR( thread_cxy , &thread_ptr->xlocks_root ) ,
+		             XPTR( lock_cxy , &lock_ptr->list ) );
+
+		hal_restore_irq(mode);
+		return 0;
+	}
 }
 
@@ -88,42 +88,42 @@
                                 uint32_t * irq_state )
 {
-    bool_t              isAtomic = false;
+	bool_t              isAtomic = false;
 	reg_t               mode;
-    volatile uint32_t   taken;
-
-    // get cluster and local pointer on remote_spinlock
-    remote_spinlock_t * lock_ptr = (remote_spinlock_t *)GET_PTR( lock_xp );
-    cxy_t               lock_cxy = GET_CXY( lock_xp );
-
-    // get cluster and local pointer on local thread
-    cxy_t               thread_cxy = local_cxy;
-    thread_t          * thread_ptr = CURRENT_THREAD;
-
-    // disable interrupts
+	volatile uint32_t   taken;
+
+	// get cluster and local pointer on remote_spinlock
+	remote_spinlock_t * lock_ptr = (remote_spinlock_t *)GET_PTR( lock_xp );
+	cxy_t               lock_cxy = GET_CXY( lock_xp );
+
+	// get cluster and local pointer on local thread
+	cxy_t               thread_cxy = local_cxy;
+	thread_t          * thread_ptr = CURRENT_THREAD;
+
+	// disable interrupts
 	hal_disable_irq( &mode );
-  
-    // loop until success 
+
+	// loop until success
 	while( isAtomic == false )
 	{
 		taken = hal_remote_lw( XPTR( lock_cxy , &lock_ptr->taken ) );
 
-        // try to take the lock if not already taken
+		// try to take the lock if not already taken
 		if( taken == 0 )
 		{
-		    isAtomic = hal_remote_atomic_cas( XPTR( lock_cxy , &lock_ptr->taken ) , 0 , 1 );
-        }
-	}
-
-    // register lock in thread
+			isAtomic = hal_remote_atomic_cas( XPTR( lock_cxy , &lock_ptr->taken ) , 0 , 1 );
+		}
+	}
+
+	// register lock in thread
 	thread_ptr->remote_locks++;
 
-    hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) ,
-                    (uint64_t)XPTR( thread_cxy , thread_ptr) );
-
-    xlist_add_first( XPTR( thread_cxy , &thread_ptr->xlocks_root ) ,
-                     XPTR( lock_cxy , &lock_ptr->list ) );
-
-    // irq_state must be restored when lock is released 
-    *irq_state = mode;
+	hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) ,
+	                (uint64_t)XPTR( thread_cxy , thread_ptr) );
+
+	xlist_add_first( XPTR( thread_cxy , &thread_ptr->xlocks_root ) ,
+	                 XPTR( lock_cxy , &lock_ptr->list ) );
+
+	// irq_state must be restored when lock is released
+	*irq_state = mode;
 
 }  // end remote_spinlock_lock_busy()
@@ -133,10 +133,10 @@
                                   uint32_t  irq_state )
 {
-    // get cluster and local pointer on remote_spinlock
-    remote_spinlock_t * lock_ptr = (remote_spinlock_t *)GET_PTR( lock_xp );
-    cxy_t               lock_cxy = GET_CXY( lock_xp );
-
-    // get pointer on local thread
-    thread_t          * thread_ptr = CURRENT_THREAD;
+	// get cluster and local pointer on remote_spinlock
+	remote_spinlock_t * lock_ptr = (remote_spinlock_t *)GET_PTR( lock_xp );
+	cxy_t               lock_cxy = GET_CXY( lock_xp );
+
+	// get pointer on local thread
+	thread_t          * thread_ptr = CURRENT_THREAD;
 
 	hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) , XPTR_NULL );
@@ -146,7 +146,7 @@
 	thread_ptr->remote_locks--;
 
-    xlist_unlink( XPTR( lock_cxy , &lock_ptr->list ) );
-
-    hal_restore_irq( irq_state );
+	xlist_unlink( XPTR( lock_cxy , &lock_ptr->list ) );
+
+	hal_restore_irq( irq_state );
 }
 
@@ -154,47 +154,47 @@
 void remote_spinlock_lock( xptr_t lock_xp )
 {
-    bool_t              isAtomic = false;
+	bool_t              isAtomic = false;
 	reg_t               mode;
-    volatile uint32_t   taken;
-
-    // get cluster and local pointer on remote_spinlock
-    remote_spinlock_t * lock_ptr = (remote_spinlock_t *)GET_PTR( lock_xp );
-    cxy_t               lock_cxy = GET_CXY( lock_xp );
-
-    // get cluster and local pointer on local thread
-    cxy_t               thread_cxy = local_cxy;
-    thread_t          * thread_ptr = CURRENT_THREAD;
-
-    // disable interrupts
+	volatile uint32_t   taken;
+
+	// get cluster and local pointer on remote_spinlock
+	remote_spinlock_t * lock_ptr = (remote_spinlock_t *)GET_PTR( lock_xp );
+	cxy_t               lock_cxy = GET_CXY( lock_xp );
+
+	// get cluster and local pointer on local thread
+	cxy_t               thread_cxy = local_cxy;
+	thread_t          * thread_ptr = CURRENT_THREAD;
+
+	// disable interrupts
 	hal_disable_irq( &mode );
-  
-    // loop until success 
+
+	// loop until success
 	while( isAtomic == false )
 	{
 		taken = hal_remote_lw( XPTR( lock_cxy , &lock_ptr->taken ) );
 
-        // deschedule if possible when lock already taken
+		// deschedule if possible when lock already taken
 		if( taken != 0 )
 		{
-	        hal_restore_irq( mode );
-            if( thread_can_yield() ) sched_yield();
-	        hal_disable_irq( &mode );
+			hal_restore_irq( mode );
+			if( thread_can_yield() ) sched_yield();
+			hal_disable_irq( &mode );
 			continue;
 		}
-    
-        // try to take the lock if not already taken
+
+		// try to take the lock if not already taken
 		isAtomic = hal_remote_atomic_cas( XPTR( lock_cxy , &lock_ptr->taken ) , 0 , 1 );
 	}
 
-    // register lock in thread
+	// register lock in thread
 	thread_ptr->remote_locks++;
 
-    hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) ,
-                    (uint64_t)XPTR( thread_cxy , thread_ptr) );
-
-    xlist_add_first( XPTR( thread_cxy , &thread_ptr->xlocks_root ) ,
-                     XPTR( lock_cxy , &lock_ptr->list ) );
-
-    // enable interrupts
+	hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) ,
+	                (uint64_t)XPTR( thread_cxy , thread_ptr) );
+
+	xlist_add_first( XPTR( thread_cxy , &thread_ptr->xlocks_root ) ,
+	                 XPTR( lock_cxy , &lock_ptr->list ) );
+
+	// enable interrupts
 	hal_restore_irq( mode );
 }
@@ -203,10 +203,10 @@
 void remote_spinlock_unlock( xptr_t lock_xp )
 {
-    // get cluster and local pointer on remote_spinlock
-    remote_spinlock_t * lock_ptr = (remote_spinlock_t *)GET_PTR( lock_xp );
-    cxy_t               lock_cxy = GET_CXY( lock_xp );
-
-    // get pointer on local thread
-    thread_t          * thread_ptr = CURRENT_THREAD;
+	// get cluster and local pointer on remote_spinlock
+	remote_spinlock_t * lock_ptr = (remote_spinlock_t *)GET_PTR( lock_xp );
+	cxy_t               lock_cxy = GET_CXY( lock_xp );
+
+	// get pointer on local thread
+	thread_t          * thread_ptr = CURRENT_THREAD;
 
 	hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) , XPTR_NULL );
@@ -216,5 +216,5 @@
 	thread_ptr->remote_locks--;
 
-    xlist_unlink( XPTR( lock_cxy , &lock_ptr->list ) );
-}
-
+	xlist_unlink( XPTR( lock_cxy , &lock_ptr->list ) );
+}
+
