Index: trunk/kernel/libk/remote_buf.h
===================================================================
--- trunk/kernel/libk/remote_buf.h	(revision 666)
+++ trunk/kernel/libk/remote_buf.h	(revision 671)
@@ -32,21 +32,21 @@
  * This structure and the associated access functions define a remotely accessible,
  * kernel buffer, handled as a single-reader & single-writer FIFO. 
- * This kernel buffer is implementes as an array of bytes, whose size is 
- * dynamically defined by an argument of the "remote_buf_init()" function. 
+ * This kernel buffer is implementes as an array of bytes. The size must be a power
+ * of 2, dynamically defined by an argument of the "remote_buf_init()" function. 
  * The "put()" and "get()" functions defined below move the content of another
  * buffer (can be in kernel or in user space) to/from this circular kernel buffer.
  * This structure is NOT protected by a lock, as the only shared variable is the 
  * "sts" variable, that is updated by the hal_remote_atomic_add() primitive.
- * It is used to implement the three socket buffers (rx_buf / r2tq / crqq).
- * - the "ptw" field defines the first empty slot (for write).
- * - the "ptr" field defines the first non empty slot (for read).
- * - the "sts" field defines the total number of non empty slots.
+ *
+ * - It is used to implement the three socket buffers (rx_buf / r2tq / crqq).
+ * - It is also used to implement the inter-process communications channels
+ *   based on named "fifos", or unamed "pipes".
  ***********************************************************************************/
 
 typedef struct remote_buf_s
 {
-    uint32_t   size;    /*! number of slots in data buffer                         */
-	uint32_t   ptw;     /*! first empty slot index                                 */
-	uint32_t   ptr;     /*! first non-empty slot index                             */
+    uint32_t   order;   /*! ln2( size of data buffer in bytes)                     */
+	uint32_t   rid;     /*! first empty slot index                                 */
+	uint32_t   wid;     /*! first non-empty slot index                             */
     uint32_t   sts;     /*! current number of non empty slots                      */
 	uint8_t  * data;    /*! local pointer on local data buffer                     */
@@ -55,20 +55,40 @@
 
 /************************************************************************************
+ * This function allocates memory for a remote_buf descriptor in cluster 
+ * defined by the <cxy> argument, and return a local pointer on this descriptor.
+ ************************************************************************************
+ * @ cxy    : target cluster identifier.
+ * @ return local pointer on remote_buf descriptor.
+ ***********************************************************************************/
+remote_buf_t * remote_buf_alloc( cxy_t  cxy );
+
+/************************************************************************************
  * This function initializes a remote_buf descriptor identified by the <buf_xp>
- * argument. It allocates memory for the data, as defined by the <size> argument,
+ * argument. It allocates memory for the data, as defined by the <order> argument,
  * and initializes the buffer as empty. It must be called by a local thread.
- * No memory is allocated if <size> value is 0.
+ * The <order> value cannot be larger than 31.
  ************************************************************************************
  * @ buf_xp    : [in] extended pointer on buffer descriptor.
- * @ size      : [in] number of bytes in buffer / no memory allocated when null.
- * @ return  0 if success / return -1 if memory failure.
+ * @ order     : [in] ln2( number of bytes in buffer) / must be in [0,31].
+ * @ return  0 if success / return -1 if memory failure or illegal order.
  ***********************************************************************************/
 error_t remote_buf_init( xptr_t   buf_xp,
-                         uint32_t size );
+                         uint32_t order );
 
 /************************************************************************************
- * This function releases memory allocated for the data buffer of a remote-buf
- * descriptor identified by the <buf_xp> argument. 
- * It must be called by a local thread.
+ * This function releases memory allocated for the data buffer of an embedded
+ * remote-buf descriptor identified by the <buf_xp> argument, when the "data"
+ * pointer is not NULL. It does nothing if the data buffer was not allocated. 
+ * WARNING : do NOT use this function for a dynamically allocated remote_buf.
+ ************************************************************************************
+ * @ buf_xp      : [in] extended pointer on buffer descriptor.
+ ***********************************************************************************/
+void remote_buf_release_data( xptr_t buf_xp );
+
+/************************************************************************************
+ * This function releases both the memory allocated for the data buffer, and the
+ * memory allocated for the remote_buf descriptor, for a remote-buf identified 
+ * by the <buf_xp> argument. 
+ * WARNING : do NOT use this function an embedded remote_buf.
  ************************************************************************************
  * @ buf_xp      : [in] extended pointer on buffer descriptor.
