Index: trunk/libs/libpthread/pthread.h
===================================================================
--- trunk/libs/libpthread/pthread.h	(revision 573)
+++ trunk/libs/libpthread/pthread.h	(revision 581)
@@ -25,12 +25,9 @@
 #define _PTHREAD_H_
 
+#include <shared_pthread.h>
+
 //////////////////////////////////////////////////////////////////////////////////////////////
 //             POSIX thread related functions
-// 
-//  This include the thread creation/destruction, as well as the synchronisations:
-//  barriers, mutexes, and condition variables.
-//////////////////////////////////////////////////////////////////////////////////////////////
-
-#include <shared_pthread.h>
+//////////////////////////////////////////////////////////////////////////////////////////////
 
 /********************************************************************************************* 
@@ -90,56 +87,111 @@
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-//                 POSIX barrier related functions
-//
-// These functions are implemented in user space. Only the pthread_barrier_init() function
-// uses system calls to build the distributed quad-tree infrastructure.
-//////////////////////////////////////////////////////////////////////////////////////////////
-
-/********************************************************************************************* 
- * These structures defines a hierarchical, POSIX compliant, barrier.
- * - If the barrier attribute in the pthread_barrier_init() is NULL, it is implemented
- *   as a simple, sense reversing barrier, localised in the calling thread cluster.
- * - If the barrier attribute is defined, it is implemented as a hierarchical, physically
- *   distributed quad-tree, covering all clusters specified, with the following constraints:
- *   . The involved clusters form a mesh [x_size * y_size]
- *   . The lower left involved cluster is cluster(0,0)  
- *   . The number of threads per cluster is the same in all clusters.
- *
- * Implementation note:
- * - The quad three is implemented as a three dimensions array of node[x][y][l]
- *   . [x][y] are the cluster coordinates / max values are (QDT_XMAX-1), (QDT_YMAX-1)
- *   . [l] is the node level / 0 for terminal nodes / (QDT_LMAX-1) for the root node
- ********************************************************************************************/
-
-#define  QDT_XMAX    16                /*! max number of clusters in a row                  */
-#define  QDT_YMAX    16                /*! max number of clusters in a column               */
-#define  QDT_LMAX    5                 /*! max depth of the quad tree                       */
-#define  QDT_YWIDTH  4                 /*! Y field in cxy, for cxy <=> (x,y) translation    */
-#define  QDT_YMASK   0xF               /*! Y field in cxy, for cxy <=> (x,y) translation    */
-
-typedef struct sqt_node_s
-{
-    volatile unsigned int sense;       /*! barrier state (toggle)                           */
-    volatile unsigned int count;       /*! number of not arrived tasks                      */
-    unsigned int          arity;       /*! number of locally expected tasks                 */
-    unsigned int          level;       /*! hierarchical level (0 is bottom)                 */
-    struct sqt_node_s   * parent;      /*! pointer on parent node (NULL for root)           */
-    struct sqt_node_s   * child[4];    /*! pointer on children node (NULL for bottom)       */
-}
-sqt_node_t;
-
-typedef struct pthread_barrier_s
-{
-    sqt_node_t          * node[QDT_XMAX][QDT_YMAX][QDT_LMAX];
-}
-pthread_barrier_t;
-
-typedef struct pthread_barrierattr_s
-{
-    unsigned int          x_size;      /*! number of clusters in a row (0 to x_size-1)      */
-    unsigned int          y_size;      /*! number of clusters in a column (0 to y_size-1)   */
-    unsigned int          nthreads;    /*! number of expected threads in a cluster          */
-}
-pthread_barrierattr_t;
+//                      POSIX mutex related functions
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+/********************************************************************************************* 
+ * This function initialise the mutex identified by the <mutex> argument.
+ * The <attr> argument is not supported yet, and must be NULL.
+ *********************************************************************************************
+ * @ mutex     : pointer on mutex in user space.
+ * @ attr      : pointer on attributes structure / must be NULL.
+ * @ return 0 if success / return -1 if failure.
+ ********************************************************************************************/
+int pthread_mutex_init( pthread_mutex_t           * mutex,
+                        const pthread_mutexattr_t * attr );
+
+/********************************************************************************************* 
+ * This function destroy the mutex identified by the <mutex> argument.
+ *********************************************************************************************
+ * @ mutex     : pointer on mutex in user space.
+ * @ return 0 if success / return -1 if failure.
+ ********************************************************************************************/
+int pthread_mutex_destroy( pthread_mutex_t * mutex );
+
+/********************************************************************************************* 
+ * This bloking function locks the mutex identified by the <mutex> argument,
+ * and blocks until it becomes available.
+ *********************************************************************************************
+ * @ mutex     : pointer on mutex in user space.
+ * @ return 0 if success / return -1 if failure.
+ ********************************************************************************************/
+int pthread_mutex_lock( pthread_mutex_t * mutex );
+
+/********************************************************************************************* 
+ * This function unlocks the mutex identified by the <mutex> argument.
+ *********************************************************************************************
+ * @ mutex     : pointer on mutex in user space.
+ * @ return 0 if success / return -1 if failure.
+ ********************************************************************************************/
+int pthread_mutex_unlock( pthread_mutex_t * mutex );
+
+/********************************************************************************************* 
+ * This function tries to lock the mutex identified by the <mutex> argument,
+ * but don't block if the mutex is locked by another thread, including the current thread.
+ *********************************************************************************************
+ * @ mutex     : pointer on mutex in user space.
+ * @ return 0 if success / return -1 if mutex already taken.
+ ********************************************************************************************/
+int pthread_mutex_trylock( pthread_mutex_t * mutex );
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+//                      POSIX condvar related functions
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+/********************************************************************************************* 
+ * This function initializes a condition variable identified by the <cond> argument.
+ * WARNING: the <attr> argument is not supported and must be NULL.
+ *********************************************************************************************
+ * @ cond   : [in] pointer on condition in user space.
+ * @ attr   : [in] pointer on condition attribute (must be NULL).
+ * @ return 0 if success / return -1 if failure.
+ ********************************************************************************************/
+int pthread_cond_init( pthread_cond_t     * cond,
+                       pthread_condattr_t * attr );
+
+/********************************************************************************************* 
+ * This function atomically unlocks the <mutex> and blocks the calling thread on the 
+ * condition specified by the <cond> argument.  The thread unblocks only after another
+ * thread calls the pthread_cond_signal() or pthread_cond_broadcast() functions with the
+ * same condition variable.  The mutex must be locked before calling this function,
+ * otherwise the behavior is undefined. Before the pthread_cond_wait() function returns
+ * to the calling function, it re-acquires the <mutex>.
+ *********************************************************************************************
+ * @ cond      : pointer on condition in user space.
+ * @ mutex     : pointer on mutex in user space.
+ * @ return 0 if success / return -1 if failure.
+ ********************************************************************************************/
+int pthread_cond_wait( pthread_cond_t  * cond,
+                       pthread_mutex_t * mutex );
+
+/********************************************************************************************* 
+ * This function unblocks one thread blocked on condition specified by the <cond> argument. 
+ *********************************************************************************************
+ * @ cond      : pointer on condition in user space.
+ * @ return 0 if success / return -1 if failure.
+ ********************************************************************************************/
+int pthread_cond_signal( pthread_cond_t * cond );
+
+/********************************************************************************************* 
+ * This function unblocks all threads blocked on condition specified by the <cond> argument. 
+ *********************************************************************************************
+ * @ cond      : pointer on condition in user space.
+ * @ return 0 if success / return -1 if failure.
+ ********************************************************************************************/
+int pthread_cond_broadcast( pthread_cond_t * cond );
+
+/********************************************************************************************* 
+ * This function delete the condition variable specified by the <cond> argument. 
+ *********************************************************************************************
+ * @ cond      : pointer on condition in user space.
+ * @ return 0 if success / return -1 if failure.
+ ********************************************************************************************/
+int pthread_cond_destroy( pthread_cond_t * cond );
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+//                    POSIX barrier related functions
+//////////////////////////////////////////////////////////////////////////////////////////////
 
 /********************************************************************************************* 
@@ -186,109 +238,4 @@
    
 
-//////////////////////////////////////////////////////////////////////////////////////////////
-//                      POSIX mutex related functions
-//////////////////////////////////////////////////////////////////////////////////////////////
-
-/********************************************************************************************* 
- * This function initialise the mutex identified by the <mutex> argument.
- * The <attr> argument is not supported yet, and must be NULL.
- *********************************************************************************************
- * @ mutex     : pointer on mutex in user space.
- * @ attr      : pointer on attributes structure / must be NULL.
- * @ return 0 if success / return -1 if failure.
- ********************************************************************************************/
-int pthread_mutex_init( pthread_mutex_t           * mutex,
-                        const pthread_mutexattr_t * attr );
-
-/********************************************************************************************* 
- * This function destroy the mutex identified by the <mutex> argument.
- *********************************************************************************************
- * @ mutex     : pointer on mutex in user space.
- * @ return 0 if success / return -1 if failure.
- ********************************************************************************************/
-int pthread_mutex_destroy( pthread_mutex_t * mutex );
-
-/********************************************************************************************* 
- * This bloking function locks the mutex identified by the <mutex> argument,
- * and blocks until it becomes available.
- *********************************************************************************************
- * @ mutex     : pointer on mutex in user space.
- * @ return 0 if success / return -1 if failure.
- ********************************************************************************************/
-int pthread_mutex_lock( pthread_mutex_t * mutex );
-
-/********************************************************************************************* 
- * This function unlocks the mutex identified by the <mutex> argument.
- *********************************************************************************************
- * @ mutex     : pointer on mutex in user space.
- * @ return 0 if success / return -1 if failure.
- ********************************************************************************************/
-int pthread_mutex_unlock( pthread_mutex_t * mutex );
-
-/********************************************************************************************* 
- * This function tries to lock the mutex identified by the <mutex> argument,
- * but don't block if the mutex is locked by another thread, including the current thread.
- *********************************************************************************************
- * @ mutex     : pointer on mutex in user space.
- * @ return 0 if success / return -1 if mutex already taken.
- ********************************************************************************************/
-int pthread_mutex_trylock( pthread_mutex_t * mutex );
-
-
-//////////////////////////////////////////////////////////////////////////////////////////////
-//                      POSIX condvar related functions
-//////////////////////////////////////////////////////////////////////////////////////////////
-
-/********************************************************************************************* 
- * This function initializes a condition variable identified by the <cond> argument.
- * WARNING: the <attr> argument is not supported and must be NULL.
- *********************************************************************************************
- * @ cond   : [in] pointer on condition in user space.
- * @ attr   : [in] pointer on condition attribute (must be NULL).
- * @ return 0 if success / return -1 if failure.
- ********************************************************************************************/
-int pthread_cond_init( pthread_cond_t     * cond,
-                       pthread_condattr_t * attr );
-
-/********************************************************************************************* 
- * This function atomically unlocks the <mutex> and blocks the calling thread on the 
- * condition specified by the <cond> argument.  The thread unblocks only after another
- * thread calls the pthread_cond_signal() or pthread_cond_broadcast() functions with the
- * same condition variable.  The mutex must be locked before calling this function,
- * otherwise the behavior is undefined. Before the pthread_cond_wait() function returns
- * to the calling function, it re-acquires the <mutex>.
- *********************************************************************************************
- * @ cond      : pointer on condition in user space.
- * @ mutex     : pointer on mutex in user space.
- * @ return 0 if success / return -1 if failure.
- ********************************************************************************************/
-int pthread_cond_wait( pthread_cond_t  * cond,
-                       pthread_mutex_t * mutex );
-
-/********************************************************************************************* 
- * This function unblocks one thread blocked on condition specified by the <cond> argument. 
- *********************************************************************************************
- * @ cond      : pointer on condition in user space.
- * @ return 0 if success / return -1 if failure.
- ********************************************************************************************/
-int pthread_cond_signal( pthread_cond_t * cond );
-
-/********************************************************************************************* 
- * This function unblocks all threads blocked on condition specified by the <cond> argument. 
- *********************************************************************************************
- * @ cond      : pointer on condition in user space.
- * @ return 0 if success / return -1 if failure.
- ********************************************************************************************/
-int pthread_cond_broadcast( pthread_cond_t * cond );
-
-/********************************************************************************************* 
- * This function delete the condition variable specified by the <cond> argument. 
- *********************************************************************************************
- * @ cond      : pointer on condition in user space.
- * @ return 0 if success / return -1 if failure.
- ********************************************************************************************/
-int pthread_cond_destroy( pthread_cond_t * cond );
-
-
 
 #endif  // _PTHREAD_H_
