diff -urN tsp-0.8.3-Source-ref/src/consumers/generic/generic_consumer_main.c tsp-0.8.3-Source-Rtems/src/consumers/generic/generic_consumer_main.c
--- tsp-0.8.3-Source-ref/src/consumers/generic/generic_consumer_main.c	2007-03-29 22:42:53.000000000 +0200
+++ tsp-0.8.3-Source-Rtems/src/consumers/generic/generic_consumer_main.c	2007-12-09 23:08:58.000000000 +0100
@@ -1,6 +1,6 @@
 /*
 
-$Id: generic_consumer_main.c,v 1.11 2007/03/29 20:42:53 deweerdt Exp $
+$Id: generic_consumer_main.c,v 1.13 2007/12/08 13:56:41 erk Exp $
 
 -----------------------------------------------------------------------
 
@@ -37,7 +37,7 @@
 #include <stdio.h>
 #include <malloc.h>
 #include <stdlib.h>
-#ifdef WIN32
+#ifdef _WIN32
     #define assert(exp)     ((void)0)
     #include  "getopt.h"
 #else
@@ -98,7 +98,7 @@
 int 
 main(int argc, char *argv[]){
 
-#if !defined (WIN32)
+#if !defined (_WIN32)
   struct sigaction   my_action;
   struct sigaction   old_action;
 #endif
@@ -112,7 +112,7 @@
 
   opt_ok            = 1;   
 
-#if defined (WIN32)
+#if defined (_WIN32)
   /* Intercept the CTRL-C signal */  
   (void) signal(SIGINT, my_sighandler);
 #else
@@ -131,7 +131,7 @@
   generic_consumer_request_create(&req);
 
   /* Analyse command line parameters */
-  while (opt_ok && (EOF != (c_opt = getopt(argc,argv,"u:hnsv")))) {    
+  while (opt_ok && (EOF != (c_opt = getopt(argc,argv,"+u:hnsv")))) {    
     switch (c_opt) {
     case 'u':
       opt_ok+=2;      
@@ -161,7 +161,7 @@
       break;
     } /* end of switch */
   } /* end of while */
-     
+  
   /* indicates number of global options to skip */
   req.nb_global_opt = opt_ok-1;
   req.argv          = argv;






 
diff -urN tsp-0.8.3-Source-ref/src/core/ctrl/tsp_default_glu.h tsp-0.8.3-Source-Rtems/src/core/ctrl/tsp_default_glu.h
--- tsp-0.8.3-Source-ref/src/core/ctrl/tsp_default_glu.h	2006-10-18 11:58:48.000000000 +0200
+++ tsp-0.8.3-Source-Rtems/src/core/ctrl/tsp_default_glu.h	2008-03-04 17:15:26.000000000 +0100
@@ -136,18 +136,18 @@
 				  TSP_answer_sample_t* answer_sample);
 
 int32_t
-GLU_get_ssi_list_fromPGI_default(struct GLU_handle_t* cthis, 
-				 int* pgis, int pgis_len, 
+GLU_get_ssi_list_fromPGI_default(struct GLU_handle_t* this, 
+				 int32_t* pgis, int32_t pgis_len, 
 				 TSP_sample_symbol_info_list_t* SSI_list);
 
 int32_t
-GLU_get_ssei_list_fromPGI_default(struct GLU_handle_t* cthis, 
-				  int* pgis, int pgis_len, 
-  				  TSP_sample_symbol_extended_info_list_t* SSEI_list);
+GLU_get_ssei_list_fromPGI_default(struct GLU_handle_t* this, 
+				  int32_t* pgis, int32_t pgis_len, 
+				  TSP_sample_symbol_extended_info_list_t* SSEI_list);
 
 int32_t
-GLU_async_sample_read_default(struct GLU_handle_t* cthis, 
-			      int pgi, 
+GLU_async_sample_read_default(struct GLU_handle_t* this, 
+			      int32_t pgi, 
 			      void* value_ptr, uint32_t* value_size);
 
 int32_t


diff -urN tsp-0.8.3-Source-ref/src/core/ctrl/tsp_group_algo.h tsp-0.8.3-Source-Rtems/src/core/ctrl/tsp_group_algo.h
--- tsp-0.8.3-Source-ref/src/core/ctrl/tsp_group_algo.h	2007-02-11 22:45:56.000000000 +0100
+++ tsp-0.8.3-Source-Rtems/src/core/ctrl/tsp_group_algo.h	2008-03-04 17:22:58.000000000 +0100
@@ -54,10 +54,10 @@
  * to the value in the group table
  * @return TRUE=OK
  */
-int TSP_group_algo_create_symbols_table(const TSP_sample_symbol_info_list_t* symbols,
-					TSP_sample_symbol_info_list_t* out_symbols,
-					TSP_groups_t* out_groups,
-					TSP_datapool_t* datapool);
+int32_t TSP_group_algo_create_symbols_table(const TSP_sample_symbol_info_list_t* in_symbols,
+				    TSP_sample_symbol_info_list_t* out_symbols,
+				    TSP_groups_t* out_groups,
+				    TSP_datapool_t* datapool);
 /**
  * Destroy the group table
  * @param groups List allocated by TSP_group_algo_create_symbols_table
diff -urN tsp-0.8.3-Source-ref/src/core/ctrl/tsp_provider.h tsp-0.8.3-Source-Rtems/src/core/ctrl/tsp_provider.h
--- tsp-0.8.3-Source-ref/src/core/ctrl/tsp_provider.h	2006-10-18 23:23:51.000000000 +0200
+++ tsp-0.8.3-Source-Rtems/src/core/ctrl/tsp_provider.h	2008-03-04 17:24:44.000000000 +0100
@@ -60,9 +60,9 @@
  * @param[in,out] argc   the number of argument of the main
  * @param[in,out] argv   array of argument of size argc.
  */
-int TSP_provider_private_init(GLU_handle_t* theGLU, int* argc, char** argv[]);
+int32_t TSP_provider_private_init(GLU_handle_t* theGLU, int* argc, char** argv[]);
 
-int TSP_provider_private_run();
+int32_t TSP_provider_private_run();
 
 const char* TSP_provider_get_name();
 
@@ -93,9 +93,9 @@
 int TSP_provider_get_server_number();
 int TSP_provider_get_server_base_number( );
 
-int TSP_provider_request_async_sample_write(TSP_async_sample_t* async_sample_write);
+int32_t TSP_provider_request_async_sample_write(TSP_async_sample_t* async_sample_write);
 
-int TSP_provider_request_async_sample_read(TSP_async_sample_t* async_sample_read);
+int32_t TSP_provider_request_async_sample_read(TSP_async_sample_t* async_sample_read);
 
 void  TSP_provider_request_extended_information(TSP_request_extended_information_t* req_extinfo, 
 						TSP_answer_extended_information_t* ans_extinfo);

diff -urN tsp-0.8.3-Source-ref/src/core/ctrl/tsp_session.h tsp-0.8.3-Source-Rtems/src/core/ctrl/tsp_session.h
--- tsp-0.8.3-Source-ref/src/core/ctrl/tsp_session.h	2006-10-18 11:58:48.000000000 +0200
+++ tsp-0.8.3-Source-Rtems/src/core/ctrl/tsp_session.h	2007-10-17 11:00:58.000000000 +0200
@@ -50,7 +50,7 @@
  * @param glu_h The GLU handled that will be linked to the session
  * @return TRUE or FALSE. TRUE = OK.
  */
-int TSP_add_session(channel_id_t* new_channel_id, GLU_handle_t* glu_h);
+int32_t TSP_add_session(channel_id_t* new_channel_id, GLU_handle_t* glu_h); // int changed to int32_t
 
 /**
  * Session initialisation.
diff -urN tsp-0.8.3-Source-ref/src/core/ctrl/tsp_stream_sender.c tsp-0.8.3-Source-Rtems/src/core/ctrl/tsp_stream_sender.c
--- tsp-0.8.3-Source-ref/src/core/ctrl/tsp_stream_sender.c	2006-10-21 10:48:00.000000000 +0200
+++ tsp-0.8.3-Source-Rtems/src/core/ctrl/tsp_stream_sender.c	2007-12-11 15:47:14.000000000 +0100
@@ -35,6 +35,10 @@
 -----------------------------------------------------------------------
  */
 
+#ifdef TSP_RTEMS
+# include <sys/types.h>		 /* for types compatibility with RTEMS*/
+#endif /* _TSP_RTEMS_ */ 
+
 #include <signal.h>
 #include <pthread.h>
 #ifdef WIN32
@@ -51,7 +55,7 @@
     #include <assert.h>
 #endif
 
-#if !defined (VXWORKS) && !defined(WIN32)
+#if !defined (VXWORKS) && !defined(WIN32) && !defined(TSP_RTEMS)
 #include <strings.h> /* for bzero */
 #endif
 #include <string.h>  /* for bzero too :=} */
@@ -319,7 +323,7 @@
     }
   myhost = gethostbyname(host);
   if (myhost == NULL) {
-    STRACE_ERROR(("Cannot gethostbyname '(hostname --> @IP)' for host <%s> check your /etc/hosts file.\n",host));
+    STRACE_WARNING(("Cannot gethostbyname '(hostname --> @IP)' for host <%s> check your /etc/hosts file.\n",host));
     /* be tolerant we keep going with hostname but... consumer may not handle this properly */    
   } else {
      /* 
@@ -330,8 +334,8 @@
     myu.addr = (uint32_t)ntohl(*((uint32_t*)myhost->h_addr_list[0]));
     sprintf(host,"%d.%d.%d.%d",myu.parts[3], myu.parts[2], myu.parts[1], myu.parts[0]);
   }
-     
-  sock = (TSP_socket_t*)calloc(1, sizeof(TSP_socket_t));
+  
+	sock = (TSP_socket_t*)calloc(1, sizeof(TSP_socket_t));
   TSP_CHECK_ALLOC(sock, 0);
 
   sock->hClient = 0;
@@ -544,7 +548,7 @@
 #ifdef WIN32
      STRACE_DEBUG(("send failed with errno = %d : <%s>",WSAGetLastError(),strerror(errno)));   
 #else
-	  STRACE_ERROR(("send failed with errno = %d : <%s>",errno,strerror(errno)));
+	  STRACE_WARNING(("send failed with errno = %d : <%s>",errno,strerror(errno)));
 #endif
 	  sock->connection_ok = FALSE;
 	  return FALSE;


diff -urN tsp-0.8.3-Source-ref/src/core/include/tsp_abs_types.h tsp-0.8.3-Source-Rtems/src/core/include/tsp_abs_types.h
--- tsp-0.8.3-Source-ref/src/core/include/tsp_abs_types.h	2007-01-26 18:09:52.000000000 +0100
+++ tsp-0.8.3-Source-Rtems/src/core/include/tsp_abs_types.h	2008-02-20 09:03:56.000000000 +0100
@@ -235,6 +235,27 @@
 
 #endif /* OpenBSD / i386 */
 
+/* RTEMS */
+#if defined (TSP_RTEMS)
+# include <sys/types.h>		 /* for types compatibility */
+# include <rtems/stdint.h>
+
+#if defined (pc386)
+# define TSP_BYTE_ORDER TSP_LITTLE_ENDIAN
+#else
+# define TSP_BYTE_ORDER TSP_BIG_ENDIAN
+#endif	/* Endianness */
+
+# define TSP_SYSTEM_HAVE_NANOSLEEP
+//# define TSP_SYSTEM_HAVE_THREADSAFE_USLEEP
+# define TSP_HAVE_INT64 1
+# define TSP_INT64_CONSTANT(val)  (val##LL)
+# define TSP_GUINT64_FORMAT "llu"
+
+#endif /* _TSP_RTEMS_ */
+
+
+
 /*-----------------------------------------------------*/
 
 #ifndef	NULL
diff -urN tsp-0.8.3-Source-ref/src/core/include/tsp_const_def.h tsp-0.8.3-Source-Rtems/src/core/include/tsp_const_def.h
--- tsp-0.8.3-Source-ref/src/core/include/tsp_const_def.h	2007-02-26 20:30:11.000000000 +0100
+++ tsp-0.8.3-Source-Rtems/src/core/include/tsp_const_def.h	2008-02-26 10:56:02.000000000 +0100
@@ -294,7 +294,7 @@
 	{ \
 		if ( 0 != status ) \
 		{ \
-			STRACE_ERROR(("TSP_CHECK_THREAD : ERROR : Thread API Error"))  \
+			STRACE_ERROR(("TSP_CHECK_THREAD : ERROR : Thread API Error status = %d",status))  \
 			return ret; \
 		} \
 	}	



diff -urN tsp-0.8.3-Source-ref/src/core/include/tsp_sys_headers.h tsp-0.8.3-Source-Rtems/src/core/include/tsp_sys_headers.h
--- tsp-0.8.3-Source-ref/src/core/include/tsp_sys_headers.h	2007-01-29 17:52:39.000000000 +0100
+++ tsp-0.8.3-Source-Rtems/src/core/include/tsp_sys_headers.h	2007-10-29 10:54:26.000000000 +0100
@@ -67,7 +67,7 @@
 
 #include <string.h>
 
-#ifndef WIN32
+#if  !defined(WIN32) && !defined(TSP_RTEMS)
 #include <strings.h>
 #endif
 

diff -urN tsp-0.8.3-Source-ref/src/core/rpc/tsp_client.c tsp-0.8.3-Source-Rtems/src/core/rpc/tsp_client.c
--- tsp-0.8.3-Source-ref/src/core/rpc/tsp_client.c	2007-03-01 23:26:39.000000000 +0100
+++ tsp-0.8.3-Source-Rtems/src/core/rpc/tsp_client.c	2007-10-29 09:50:08.000000000 +0100
@@ -67,16 +67,33 @@
 
 CLIENT* tsp_remote_open_progid(const char *target_name, int progid)
 {
-
+  int sock = -1;      // modif pour RTEMS
+  struct hostent *hp;
+	struct sockaddr_in farAddr;
   CLIENT* cl = (CLIENT *)0;
   /* struct timeval timeout = { 1, 0 }; */
 
-  /*cl = clnt_create_timed(target_name, progid, TSP_RPC_VERSION_INITIAL, "tcp",&timeout );*/
+  /* modifie */
+	hp = gethostbyname (target_name);
+	if (hp == NULL) {
+		fprintf (stderr, "No server %s\n", target_name);
+		return 2;
+	}
+	/*
+	 * Set up server address
+	 * TCP_PORT = 15376 fixe pour RTEMS
+	 */
+	farAddr.sin_family = hp->h_addrtype;
+	farAddr.sin_port = htons (TCP_PORT);
+	memcpy((char*)&farAddr.sin_addr, hp->h_addr, hp->h_length);
 
-  cl = clnt_create(target_name, progid, TSP_RPC_VERSION_INITIAL, "tcp");
+  /*cl = clnt_create_timed(target_name, progid, TSP_RPC_VERSION_INITIAL, "tcp",&timeout );*/
 
+  //cl = clnt_create(target_name, progid, TSP_RPC_VERSION_INITIAL, "tcp");  	
+	cl = clnttcp_create (&farAddr, TSP_RPC, TSP_RPC_VERSION_INITIAL, &sock, 0, 0);
+	
   if (cl == (CLIENT *)0) {
-    STRACE_ERROR(("ERROR : GLOBAL clnt_create failed for host <%s> / progid <%d/0x%08X>", target_name, progid,progid));
+    STRACE_ERROR(("ERROR : GLOBAL clnt_create failed for host <%s> / progid <%d/0x%08X>", target_name, progid, progid));
   }
   else {
     STRACE_INFO(("CONNECTED to server %s", target_name));
diff -urN tsp-0.8.3-Source-ref/src/core/rpc/tsp_rpc_clnt.c.linux tsp-0.8.3-Source-Rtems/src/core/rpc/tsp_rpc_clnt.c.linux
--- tsp-0.8.3-Source-ref/src/core/rpc/tsp_rpc_clnt.c.linux	2007-04-22 23:15:35.000000000 +0200
+++ tsp-0.8.3-Source-Rtems/src/core/rpc/tsp_rpc_clnt.c.linux	2008-03-04 16:23:18.000000000 +0100
@@ -4,7 +4,12 @@
  */
 
 #include <memory.h> /* for memset */
-#include "rpc/tsp_rpc.h"
+
+#ifdef TSP_RTEMS
+# include "tsp_rpc.h"
+#else
+# include "rpc/tsp_rpc.h"
+#endif /* TSP_RTEMS */
 
 int tsp_wrap_rpc_clnt_set_timeout(CLIENT *client, int timeout)
 {
diff -urN tsp-0.8.3-Source-ref/src/core/rpc/tsp_rpc.h.linux tsp-0.8.3-Source-Rtems/src/core/rpc/tsp_rpc.h.linux
--- tsp-0.8.3-Source-ref/src/core/rpc/tsp_rpc.h.linux	2007-04-22 23:15:35.000000000 +0200
+++ tsp-0.8.3-Source-Rtems/src/core/rpc/tsp_rpc.h.linux	2008-03-04 23:44:20.000000000 +0100
@@ -13,6 +13,9 @@
 extern "C" {
 #endif
 
+#ifdef TSP_RTEMS
+# define TCP_PORT 15376
+#endif
 
 enum TSP_status_t {
 	TSP_STATUS_OK = 0,
diff -urN tsp-0.8.3-Source-ref/src/core/rpc/tsp_rpc_svc.c.linux tsp-0.8.3-Source-Rtems/src/core/rpc/tsp_rpc_svc.c.linux
--- tsp-0.8.3-Source-ref/src/core/rpc/tsp_rpc_svc.c.linux	2007-04-22 23:15:35.000000000 +0200
+++ tsp-0.8.3-Source-Rtems/src/core/rpc/tsp_rpc_svc.c.linux	2008-03-04 16:23:14.000000000 +0100
@@ -6,7 +6,12 @@
  * It was generated using rpcgen.
  */
 
-#include "rpc/tsp_rpc.h"
+#ifdef TSP_RTEMS
+# include "tsp_rpc.h"
+#else
+# include "rpc/tsp_rpc.h"
+#endif /* TSP_RTEMS */
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <rpc/pmap_clnt.h>
diff -urN tsp-0.8.3-Source-ref/src/core/rpc/tsp_rpc_xdr.c.linux tsp-0.8.3-Source-Rtems/src/core/rpc/tsp_rpc_xdr.c.linux
--- tsp-0.8.3-Source-ref/src/core/rpc/tsp_rpc_xdr.c.linux	2007-04-22 23:15:35.000000000 +0200
+++ tsp-0.8.3-Source-Rtems/src/core/rpc/tsp_rpc_xdr.c.linux	2008-03-03 17:52:10.000000000 +0100
@@ -3,7 +3,11 @@
  * It was generated using rpcgen.
  */
 
-#include "rpc/tsp_rpc.h"
+#ifdef TSP_RTEMS
+# include "tsp_rpc.h"
+#else
+# include "rpc/tsp_rpc.h"
+#endif /* TSP_RTEMS */
 
 bool_t
 xdr_TSP_status_t (XDR *xdrs, TSP_status_t *objp)
diff -urN tsp-0.8.3-Source-ref/src/core/rpc/tsp_server.c tsp-0.8.3-Source-Rtems/src/core/rpc/tsp_server.c
--- tsp-0.8.3-Source-ref/src/core/rpc/tsp_server.c	2006-10-21 10:48:00.000000000 +0200
+++ tsp-0.8.3-Source-Rtems/src/core/rpc/tsp_server.c	2008-02-25 10:10:52.000000000 +0100
@@ -260,24 +260,52 @@
 
 static void TSP_rpc_run(TSP_rpc_request_config_t *config)
 {
-  int32_t rpc_progid = TSP_get_progid(config->server_number);
-
-  /* svc_create does not exist for linux, we must use the deprecated function */
-  /* pmap_unset (rpc_progid, TSP_RPC_VERSION_INITIAL); */
-
-  config->xprt = svctcp_create(RPC_ANYSOCK, 0, 0);
-  if (config->xprt == NULL) 
-    {
-      STRACE_ERROR(("Cannot create TCP service"));
-      return;
-    }
-
-  if (!svc_register(config->xprt, rpc_progid, TSP_RPC_VERSION_INITIAL, tsp_rpc_1, IPPROTO_TCP))
-    {
-      STRACE_ERROR(("RPC server unable to register ProgId=%X",  rpc_progid));
-      return;
-    }
-
+	int32_t rpc_progid = TSP_get_progid(config->server_number);
+	int sock;
+	struct sockaddr_in myAddr;
+	SVCXPRT *transp;
+	bool_t status;
+	
+	/* svc_create does not exist for linux, we must use the deprecated function */
+	/* pmap_unset (rpc_progid, TSP_RPC_VERSION_INITIAL); */
+	
+	/*             MODIFIE SELON RPC DEMO                */
+	/*
+	 * Create socket
+	 */
+	sock = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
+	if (sock < 0) {
+		perror ("socket creation problem");
+		return 1;
+	}
+
+	/*
+	 * Bind to local address
+	 */
+	myAddr.sin_family = htons (AF_INET);
+	myAddr.sin_port = htons (TCP_PORT);
+	myAddr.sin_addr.s_addr = htonl (INADDR_ANY);
+	if (bind (sock, (struct sockaddr *)&myAddr, sizeof myAddr) < 0) {
+		perror ("bind problem");
+		return 2;
+	}
+	
+	/*
+	 * Create TCP server
+	 */
+	//config->xprt = svctcp_create(RPC_ANYSOCK, 0, 0); 
+	config->xprt = svctcp_create(sock, 0, 0); 	 	
+	if (config->xprt == NULL) 
+	{
+    	STRACE_ERROR(("Cannot create TCP service"));
+    	return;
+	}
+//  if (!svc_register(config->xprt, rpc_progid, TSP_RPC_VERSION_INITIAL, tsp_rpc_1, IPPROTO_TCP))
+	if (!svc_register(config->xprt, rpc_progid, TSP_RPC_VERSION_INITIAL, tsp_rpc_1, 0))
+	{
+    	STRACE_ERROR(("RPC server unable to register ProgId=%X",  rpc_progid));
+    	return;
+	}
   STRACE_DEBUG(("RPC server is being be started with ProgId=%X", rpc_progid));
   
   STRACE_DEBUG(("launching svc_run..."));
diff -urN tsp-0.8.3-Source-ref/src/core/rpc/tsp_server.h tsp-0.8.3-Source-Rtems/src/core/rpc/tsp_server.h
--- tsp-0.8.3-Source-ref/src/core/rpc/tsp_server.h	2006-10-18 11:58:48.000000000 +0200
+++ tsp-0.8.3-Source-Rtems/src/core/rpc/tsp_server.h	2007-10-29 10:55:22.000000000 +0100
@@ -40,6 +40,10 @@
 
 #include "tsp_prjcfg.h"
 
+#ifdef TSP_RTEMS
+# define TCP_PORT 15376
+#endif /* _TSP_RTEMS_ */
+
 /**
  * @defgroup TSP_RPCRequestHandlerLib RPC Request Handler
  * The module is the set of functions which encapsulate











-
diff -urN tsp-0.8.3-Source-ref/src/util/libbb/bb_alias.c tsp-0.8.3-Source-Rtems/src/util/libbb/bb_alias.c
--- tsp-0.8.3-Source-ref/src/util/libbb/bb_alias.c	2007-04-01 15:17:21.000000000 +0200
+++ tsp-0.8.3-Source-Rtems/src/util/libbb/bb_alias.c	2007-11-07 16:24:26.000000000 +0100
@@ -40,7 +40,11 @@
 #include <string.h>
 #include <stdlib.h>
 #include <sys/types.h>
-#include <sys/mman.h>
+
+#if !defined TSP_RTEMS
+# include <sys/mman.h>
+#endif /* _TSP_RTEMS_ */
+
 #include <unistd.h>
 #include <assert.h>
 
diff -urN tsp-0.8.3-Source-ref/src/util/libbb/bb_core.c tsp-0.8.3-Source-Rtems/src/util/libbb/bb_core.c
--- tsp-0.8.3-Source-ref/src/util/libbb/bb_core.c	2007-04-01 15:17:21.000000000 +0200
+++ tsp-0.8.3-Source-Rtems/src/util/libbb/bb_core.c	2007-11-15 16:04:34.000000000 +0100
@@ -39,14 +39,23 @@
 #include <string.h>
 #include <stdlib.h>
 #include <sys/types.h>
-#include <sys/mman.h>
+
+#if !defined (TSP_RTEMS)
+# include <sys/mman.h>
+#endif
+
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <errno.h>
 #include <unistd.h>
 #include <assert.h>
 #include <ctype.h>
-#include <dlfcn.h>
+#include <semaphore.h>
+
+#if !defined TSP_RTEMS
+# include <dlfcn.h>
+#endif /* _TSP_RTEMS_ */
+
 #ifndef RTLD_DEFAULT
 #define RTLD_DEFAULT (void *)0
 #endif
@@ -115,33 +124,49 @@
 extern struct bb_operations k_bb_ops;
 #endif
 #endif
+#if defined(TSP_RTEMS)
+extern struct bb_operations posix_bb_ops;
+#endif
 
 /* Note: This is thigtly related to enum bb_type in bb_core.h,
    if you ever modify this, you'll probably need to modify
    enum bb_type */
 static struct bb_operations *ops[] = {
+#if defined(sysv)
 	&sysv_bb_ops
+#else
+	NULL
+#endif /* sysv */
 #if defined(linux) || defined(__linux)
-	,&k_bb_ops
-#endif
+	&k_bb_ops
+#else
+	,NULL
+#endif /* linux */
+#if defined(TSP_RTEMS)
+	,&posix_bb_ops
+#else
+	,NULL
+#endif /* TSP_RTEMS */
 };
 
 static enum bb_type bb_type(const char *name)
 {
 #ifdef __KERNEL__
 	return BB_KERNEL;
+#endif /* __KERNEL__ */
+
+#ifdef TSP_RTEMS
+	return BB_POSIX;
 #else
 	if (!strncmp(name, "/dev/", 5))
 		return BB_KERNEL;
-
 	return BB_SYSV;
-#endif /* __KERNEL__ */
+#endif /* __TSP_RTEMS__ */
 }
 
-size_t 
-sizeof_bb_type(E_BB_TYPE_T bb_type) {
+size_t sizeof_bb_type(E_BB_TYPE_T bb_type) {
   size_t retval = 0;
-  if ((bb_type>=1) && (bb_type<E_BB_USER)) {
+  if ((bb_type >= 1) && (bb_type < E_BB_USER)) {
     retval = E_BB_TYPE_SIZE[bb_type];
   }
   return retval;
@@ -225,7 +250,7 @@
 bb_set_varname_fn bb_set_varname = bb_set_varname_default;
 bb_varname_max_len_fn bb_varname_max_len = bb_varname_max_len_default;
 
-#ifndef __KERNEL__
+#if !defined (__KERNEL__)  && !defined (TSP_RTEMS)
 static int32_t
 bb_varname_init(S_BB_T *bb)
 {
@@ -678,7 +703,7 @@
        (E_BB_CHAR  != data_desc.type)
        )
       ) {
-    fprintf(pf,"%s  value[%d]     = ",tabs,idx);
+    fprintf(pf,"%s  value[%d]     = ",tabs,(int)idx);
   } else {
     fprintf(pf,"%s  value        = ",tabs);
   }
@@ -913,36 +938,36 @@
 } /* end of bb_data_print */
 #endif /* !__KERNEL__ */
 
-int32_t 
+int32_t
 bb_create(S_BB_T** bb, 
 	       const char* pc_bb_name,
 	       int32_t n_data,
 	       int32_t data_size) {
-
-  enum bb_type type;
-  int32_t retcode;
-  assert(bb);
-
-  type = bb_type(pc_bb_name);
-  retcode = ops[type]->bb_shmem_get(bb, pc_bb_name, n_data, data_size, 1);
-  if (retcode != BB_OK)
-  	goto err;
-
-  retcode = ops[(*bb)->type]->bb_sem_get(*bb, 1);
-  if (retcode != BB_OK)
-  	goto err;
-
-  retcode = ops[(*bb)->type]->bb_msgq_get(*bb, 1);
-  
-err:
-  return retcode;
+	enum bb_type type;
+	int32_t retcode;
+	assert(bb);
+
+	type = bb_type(pc_bb_name);
+
+	retcode = ops[type]->bb_shmem_get(bb, pc_bb_name, n_data, data_size, 1);
+	if (retcode != BB_OK)
+		goto err;
+
+	retcode = ops[(*bb)->type]->bb_sem_get(*bb, 1);
+	if (retcode != BB_OK)
+		goto err;
+	
+	retcode = ops[(*bb)->type]->bb_msgq_get(*bb, 1);
+	
+	err:
+	return retcode;
 } /* end of bb_create */
+	
 #ifdef __KERNEL__
 EXPORT_SYMBOL_GPL(bb_create);
 #endif
 
-int32_t 
-bb_destroy(S_BB_T** bb) {
+int32_t bb_destroy(S_BB_T** bb) {
   
   int32_t retcode;
   
@@ -950,7 +975,7 @@
   assert(*bb);  
   /* 
    * On signale la destruction en cours pour les processes qui
-   * resteraient attach�s
+   * resteraient attaches
    */
   (*bb)->status = BB_STATUS_DESTROYED;
   retcode = ops[(*bb)->type]->bb_sem_destroy(*bb);
@@ -978,12 +1003,11 @@
 
 int32_t 
 bb_lock(volatile S_BB_T* bb) {
-  return ops[bb->type]->bb_unlock(bb);
+  return ops[bb->type]->bb_lock(bb);	// return ops[bb->type]->bb_unlock(bb); -> bug
 } /* end of bb_lock */
 
 int32_t 
-bb_unlock(volatile S_BB_T* bb) {
-  
+bb_unlock(volatile S_BB_T* bb) {  
   return ops[bb->type]->bb_unlock(bb);
 } /* end of bb_unlock */
 
@@ -1012,10 +1036,11 @@
 
 int32_t
 bb_detach(S_BB_T** bb) {
-  assert(bb);
-  assert(*bb);
-
-  return ops[(*bb)->type]->bb_shmem_detach(bb);
+  	assert(bb);
+//  assert(*bb);
+	puts("bb_detach\n");
+	return ops[BB_POSIX]->bb_shmem_detach(bb);
+//  return ops[(*bb)->type]->bb_shmem_detach(bb);
 } /* end of bb_detach */
 
 void*
diff -urN tsp-0.8.3-Source-ref/src/util/libbb/bb_core.h tsp-0.8.3-Source-Rtems/src/util/libbb/bb_core.h
--- tsp-0.8.3-Source-ref/src/util/libbb/bb_core.h	2007-04-01 15:17:21.000000000 +0200
+++ tsp-0.8.3-Source-Rtems/src/util/libbb/bb_core.h	2007-11-13 15:05:06.000000000 +0100
@@ -71,6 +71,8 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <tsp_abs_types.h>
+#include <mqueue.h>		
+#include <semaphore.h>
 
 #endif /* __KERNEL__ */
 
@@ -325,7 +327,19 @@
 	int msg_id;
 };
 
-
+/**
+ * POSIX specific data, part of the S_BB_T structure
+ */
+struct posix_private {
+	/* shm file descriptor */
+	int fd;
+	/** the size of the allocated black board */
+	int shm_size;
+	/* posix semaphore handle */
+	sem_t *sem_id ;
+	/* posix message queue handle */
+	mqd_t msg_id;
+};
 /**
  * BlackBoard message definition.
  * This type must conform to the constraint of
@@ -355,6 +369,7 @@
 enum bb_type {
 	BB_SYSV,
 	BB_KERNEL,
+	BB_POSIX
 };
 /**
  * BlackBoard description structure.
@@ -426,6 +441,7 @@
   union {
 	struct sysv_private sysv;
 	struct kernel_private k;
+	struct posix_private posix;
   } priv;
 
 } S_BB_T;
@@ -733,7 +749,7 @@
 
 /**
  * Lock blackboard.
- * A BlackBoard should be locked befaore any structural change
+ * A BlackBoard should be locked before any structural change
  * or to protect different process against each other from
  * concurrent modifications.
  * This is a blocking call (using sys V semaphore).
diff -urN tsp-0.8.3-Source-ref/src/util/libbb/bb_core_posix.c tsp-0.8.3-Source-Rtems/src/util/libbb/bb_core_posix.c
--- tsp-0.8.3-Source-ref/src/util/libbb/bb_core_posix.c	1970-01-01 01:00:00.000000000 +0100
+++ tsp-0.8.3-Source-Rtems/src/util/libbb/bb_core_posix.c	2007-11-15 14:37:30.000000000 +0100
@@ -0,0 +1,471 @@
+/*
+
+$Header: /sources/tsp/tsp/src/util/libbb/bb_core_posix.c,v 1.4 2007/03/01 18:43:35 deweerdt Exp $
+
+-----------------------------------------------------------------------
+
+TSP Library - core components for a generic Transport Sampling Protocol.
+
+Copyright (c) 2006 Eric NOULARD, Frederik DEWEERDT
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+-----------------------------------------------------------------------
+
+Project   : TSP
+Maintainer : tsp@astrium-space.com
+Component : Consumer
+
+-----------------------------------------------------------------------
+
+Purpose   : Blackboard POSIX implementation
+
+Note	  : Most of the code was written by Eric, and was historically
+	    in bb_core.c
+-----------------------------------------------------------------------
+ */
+
+
+#include <errno.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <mqueue.h>	
+#include <semaphore.h>
+#include <pthread.h>
+#include <fcntl.h>
+#include <mman.h>
+
+#include "bb_core_posix.h"
+#include "bb_core.h"
+#include "bb_utils.h"
+
+
+#define LOG(x, ...)
+
+
+
+struct bb_used_t bb_used[MAX_NUM_OF_BB];
+
+int bb_count = 0;
+
+/* posix rtems ok */
+static int posix_bb_msgq_get(S_BB_T *bb, int create)
+{
+	char *name_msg;
+	int retcode = BB_OK;
+	int oflag = 0 ;
+
+	if (create)
+		oflag = O_CREAT | O_EXCL;
+		name_msg = bb_utils_build_msg_name(bb->name);
+		bb->priv.posix.msg_id = (mqd_t) mq_open( bb_utils_build_msg_name(bb->name),
+											oflag | BB_MSG_ACCESS_RIGHT );
+	
+	if (bb->priv.posix.msg_id < 0) {
+		LOG(BB_LOG_SEVERE, "BlackBoard::bb_create", "Cannot message queue %s ", name_msg);
+		retcode = BB_NOK;
+	}
+	//free(name_msg);
+	return retcode;
+}
+
+/* posix rtems ok */
+static int posix_bb_lock(volatile S_BB_T *bb)
+{
+	int32_t retcode;
+
+	assert(bb);
+
+	if (-1 == sem_wait(bb->priv.posix.sem_id)) {
+		if (EINVAL == errno) {
+			LOG(BB_LOG_WARNING, "BlackBoard::bb_lock",
+				  "Is BB semaphore destroyed?");
+		} else {
+			LOG(BB_LOG_SEVERE, "BlackBoard::bb_lock",
+				  "sem_open failed");
+		}
+		retcode = BB_NOK;
+	} else {
+		retcode = BB_OK;
+	}
+
+	return retcode;
+}
+
+/* posix rtems ok */
+static int posix_bb_unlock(volatile S_BB_T *bb)
+{
+	int32_t retcode;
+
+
+	/* shadow do not honor locking
+	 * they have neither semaphore nor msgqueue attached
+	 */
+	if (BB_STATUS_SHADOW == bb->status) {
+		return BB_OK;
+	}
+
+	if (-1 == sem_post(bb->priv.posix.sem_id)) {
+		if (EINVAL == errno) {
+			bb_logMsg(BB_LOG_WARNING, "BlackBoard::bb_unlock",
+				  "Is BB semaphore destroyed?");
+		}
+		LOG(BB_LOG_SEVERE, "BlackBoard::bb_unlock",
+			  "semop failed");
+		retcode = BB_NOK;
+	} else {
+		retcode = BB_OK;
+	}
+	return retcode;
+}
+
+/* 
+ *	posix_bb_sem_get : posix rtems ok
+ */
+static int posix_bb_sem_get(S_BB_T *bb, int create)
+{
+	int32_t retcode = BB_OK;
+	//char* name_sem = NULL;
+	int oflag = 0;
+	
+	if (create)
+		oflag = O_CREAT | O_EXCL;
+	
+	//name_sem = bb_utils_build_sem_name(bb->name);
+
+	bb->priv.posix.sem_id = (sem_t *)sem_open(bb_utils_build_sem_name(bb->name),
+											oflag | BB_SEM_ACCESS_RIGHT);
+	
+	if ( bb->priv.posix.sem_id < 0) {
+		LOG(BB_LOG_SEVERE, "BlackBoard::bb_create",
+		    "Cannot create semaphore < %s >", name_sem);
+		retcode = BB_NOK;
+	} else {
+		retcode = BB_OK;
+	}
+	return retcode;
+}
+
+/*
+ * Detache le segment de memoire partagee
+ * posix rtems ok 
+ */
+static int posix_bb_shmem_detach(S_BB_T ** bb)
+{
+	int32_t retcode = BB_OK;
+	assert(bb);
+	assert(*bb);
+
+	retcode = shm_unlink((char *)*bb);
+	*bb = NULL;
+	if (!retcode)
+		return BB_OK;
+	else
+		LOG(bb_log_severe, "blackboard::bb_detach","shmem detach failed");
+		return BB_NOK;
+}
+
+/*
+ * posix_bb_shmem_attach : posix Rtems ok
+ */
+static int posix_bb_shmem_attach(S_BB_T ** bb, const char *name)
+{
+	int i_bb, fd_shm, retcode;
+	boolean success = FALSE;
+
+	retcode = BB_OK;
+	fd_shm  = 0;
+
+	for (i_bb = 0; i_bb < bb_count; i_bb++){
+		if ( strncmp((char *)bb_used[i_bb].name, name, BB_NAME_MAX_SIZE + 1) == 0){
+			*bb = bb_used[i_bb].fd;
+			success = TRUE;
+			retcode = BB_OK;
+		}			
+	}
+
+	if (!success){
+		LOG(BB_LOG_SEVERE, "BlackBoard::bb_attach", "Cannot find the BB named :%s ", name);
+		retcode = BB_NOK;
+	}
+	
+	if ((retcode == BB_OK) && ((void *) -1 == *bb)) {
+		LOG(BB_LOG_SEVERE, "BlackBoard::bb_attach", "Cannot attach shm segment (%s)");
+		retcode = BB_NOK;
+	}
+	return retcode;
+}
+
+/*
+ *	posix_bb_shmem_get : posix rtems ok
+ */
+static int posix_bb_shmem_get(S_BB_T ** bb,
+							  const char *name,
+							  int n_data,
+							  int data_size,
+							  int create)
+{
+	int i_bb, shm_size;
+	boolean success = FALSE;
+	//char *shm_name;
+	/*shm_name = bb_utils_build_shm_name(name);
+	if (!shm_name)
+		return BB_NOK;	*/		
+		/*goto err;*/
+	
+	shm_size = bb_size(n_data, data_size);
+	
+	if (create){
+		//flags = IPC_CREAT | IPC_EXCL;
+		if (bb_count == MAX_NUM_OF_BB-1) {
+			LOG(BB_LOG_SEVERE, "BlackBoard::bb_create",
+			  "Max number of BB reached !");
+			return BB_NOK;			
+		}
+		
+		*bb = (S_BB_T *)malloc(shm_size);
+
+		if (*bb == NULL) {
+			LOG(BB_LOG_SEVERE, "BlackBoard::bb_create",
+			  "Cannot allow memory ");
+			return BB_NOK;
+		}
+		
+		/* Init the freshly allocated structure */
+		memset(*bb, 0, shm_size);
+		(*bb)->bb_version_id = BB_VERSION_ID;
+		strncpy((char *)(*bb)->name, name, BB_NAME_MAX_SIZE + 1);		
+		(*bb)->max_data_desc_size = n_data;
+		(*bb)->data_desc_offset = sizeof(S_BB_T);
+		(*bb)->n_data = 0;
+		(*bb)->max_data_size = data_size;
+		(*bb)->data_offset = (*bb)->data_desc_offset + ((*bb)->max_data_desc_size) * sizeof(S_BB_DATADESC_T);
+		(*bb)->data_free_offset = 0;
+		(*bb)->status = BB_STATUS_GENUINE;
+		(*bb)->priv.posix.shm_size = shm_size;
+		(*bb)->priv.posix.fd = *bb;
+		(*bb)->type = BB_POSIX;
+		
+		/* created BB memorisation */
+		strncpy((char *)bb_used[bb_count].name, name, BB_NAME_MAX_SIZE + 1);
+		bb_used[bb_count].fd   = (S_BB_T *)*bb;
+		bb_count++;
+		
+		return BB_OK;
+	}
+		
+	/* else look for the corresponding fd */
+	for (i_bb = 0; i_bb < bb_count; i_bb++){
+		if ( strncmp((char *)bb_used[i_bb].name, name, BB_NAME_MAX_SIZE + 1) == 0){
+			*bb = bb_used[i_bb].fd;
+			success = TRUE;
+		}
+	}
+	
+	if (!success){
+		LOG(BB_LOG_SEVERE, "BlackBoard::bb_get", "Cannot find the BB named :%s ", name);
+		return BB_NOK;	
+	}
+				  
+	return BB_OK;	
+}
+
+/*
+ *	posix_bb_shmem_destroy
+ */
+static int32_t posix_bb_shmem_destroy(S_BB_T ** bb)
+{
+	int32_t retcode = BB_OK;
+	int i_bb, j_bb;
+
+	/*S_BB_MSG_T bb_msg;*/
+
+	/* 
+	 * On signale la destruction en cours pour les processes qui
+	 * resteraient attachés
+	 */
+
+	/* FIXME should reserve a message type for signaling destroy */
+	/*   bb_msg.mtype = 1; */
+	/*   bb_snd_msg(*bb,&bb_msg); */
+	/*   sleep(1); */
+	
+	/* Look for the corresponding BB */
+	for (i_bb = 0; i_bb < bb_count; i_bb++){
+		if ( (S_BB_T *)bb_used[i_bb].fd == ((S_BB_T *)(*bb)->priv.posix.fd) )
+			if ( i_bb == (MAX_NUM_OF_BB - 1)){
+				/* cas en fin de tab*/
+				bb_used[i_bb].name[0] = '\0'; 
+				bb_used[i_bb].fd = NULL;
+				bb_count--;
+			}
+			else { // decallage 
+				for (j_bb = i_bb; j_bb < bb_count-1; j_bb++){
+					strncpy((char *)bb_used[j_bb].name, (char *)bb_used[j_bb+1].name, BB_NAME_MAX_SIZE + 1);
+					bb_used[j_bb].fd = bb_used[j_bb+1].fd;
+				}
+				bb_count--;
+			}			
+	}	
+	free(*bb);
+	*bb = NULL;
+	return retcode;
+} /* end of posix_bb_shmem_destroy */
+
+/*
+ * posix_bb_msgq_recv : posix rtems ok
+ */
+static int32_t posix_bb_msgq_recv(volatile S_BB_T * bb, S_BB_MSG_T * msg)
+{
+	int32_t retcode;
+	int32_t i_cont;
+
+	retcode = BB_OK;
+	assert(bb);
+
+	i_cont = 1;
+	/* Réception bloquante */
+	while (i_cont) {
+		retcode = mq_receive( bb->priv.posix.msg_id, msg->mtext, MAX_SYSMSG_SIZE, NULL );
+		
+		/* On sort de la boucle si on a pas pris un signal */
+		if ((-1 != retcode) || (EINTR != errno)) {
+			i_cont = 0;
+		}
+	}
+	if (-1 == retcode) {
+		retcode = BB_NOK;
+		/* The identifier removed case and INTR
+		 * should not generate a log message 
+		 * FIXME on devrait pouvoir faire mieux que ça.
+		 */
+		if ((EIDRM != errno) && (EINTR != errno)) {
+			bb_logMsg(BB_LOG_SEVERE,
+				  "Blackboard::bb_rcv_msg",
+				  "Cannot receive messsage");
+		}
+	}
+	return retcode;
+}
+
+/*
+ * posix_bb_msgq_send : posix rtems ok
+ */
+static int32_t posix_bb_msgq_send(volatile S_BB_T * bb, S_BB_MSG_T * msg)
+{
+	int32_t retcode;
+//	struct msqid_ds mystat;
+	struct mq_attr mqstat;
+
+	retcode = BB_OK;
+	assert(bb);
+	/* do not flood message queue if no one read it !! */
+//	retcode = msgctl(bb->priv.posix.msg_id, IPC_STAT, &mystat);
+	retcode =  mq_getattr( bb->priv.posix.msg_id , &mqstat );
+
+//	if (!(mystat.msg_cbytes > 2 * MAX_SYSMSG_SIZE))
+	if ( !(mqstat.mq_curmsgs * mqstat.mq_msgsize > 2 * MAX_SYSMSG_SIZE) ) {
+		/* Non blocking send */
+		retcode = mq_send( bb->priv.posix.msg_id, msg->mtext, MAX_SYSMSG_SIZE, 0);
+		if (-1 == retcode) {
+			retcode = BB_NOK;
+			if (EAGAIN == errno) {
+				/*bb_logMsg(BB_LOG_WARNING,
+				   "Blackboard::bb_snd_msg",
+				   "Envoi du message impossible (queue pleine) <%s>",
+				   syserr);
+				 */
+			} else {
+				LOG(BB_LOG_SEVERE,
+				    "Blackboard::bb_snd_msg",
+				    "Cannot send message");
+			}
+		}
+	} else {
+		/* NOP */
+/*     LOG(BB_LOG_WARNING, */
+/* 	      "Blackboard::bb_snd_msg", */
+/* 	      "Cannot send msg <%d> bytes already queued>",mystat.msg_cbytes); */
+	}
+
+	return retcode;
+}
+
+/*
+ * posix_bb_msgq_isalive : posix rtems ok
+ */
+static int32_t posix_bb_msgq_isalive(S_BB_T * bb)
+{
+	int32_t retcode;
+	struct mq_attr mqstat;
+
+	retcode =  mq_getattr( bb->priv.posix.msg_id , &mqstat );
+
+	if ( !retcode && mqstat.mq_curmsgs > 0 ) {
+		retcode = BB_NOK;
+	} else {
+		retcode = BB_OK;
+	}
+
+	return retcode;
+}
+
+/*
+ * posix_bb_sem_destroy : posix rtems ok
+ */
+static int posix_bb_sem_destroy(S_BB_T *bb)
+{
+	/* FIXME should the sem be taken before being removed? */
+	/* Remove the bb's semaphore */
+	//return semctl(bb->priv.posix.sem_id, 0, IPC_RMID);
+	return sem_destroy( bb->priv.posix.sem_id );
+}
+
+/*
+ * posix_bb_msgq_destroy : posix rtems ok
+ */
+static int posix_bb_msgq_destroy(S_BB_T *bb)
+{
+	char *name_msg;
+	name_msg = bb_utils_build_msg_name(bb->name);
+	
+	/* Destroy the bb's message queue */
+	return mq_unlink(name_msg);
+}
+
+
+/*
+ * Structure bb_operations : pointeurs de fonctions
+ */
+struct bb_operations posix_bb_ops = {
+	.bb_shmem_get = posix_bb_shmem_get,
+	.bb_shmem_attach = posix_bb_shmem_attach,
+	.bb_shmem_detach = posix_bb_shmem_detach,
+	.bb_shmem_destroy = posix_bb_shmem_destroy,
+
+	.bb_sem_get = posix_bb_sem_get,
+	.bb_lock = posix_bb_lock,
+	.bb_unlock = posix_bb_unlock,
+	.bb_sem_destroy = posix_bb_sem_destroy,
+
+	.bb_msgq_get = posix_bb_msgq_get,
+	.bb_msgq_send = posix_bb_msgq_send,
+	.bb_msgq_recv = posix_bb_msgq_recv,
+	.bb_msgq_isalive = posix_bb_msgq_isalive,
+	.bb_msgq_destroy = posix_bb_msgq_destroy,
+};
+


diff -urN tsp-0.8.3-Source-ref/src/util/libbb/bb_core_posix.h tsp-0.8.3-Source-Rtems/src/util/libbb/bb_core_posix.h
--- tsp-0.8.3-Source-ref/src/util/libbb/bb_core_posix.h	1970-01-01 01:00:00.000000000 +0100
+++ tsp-0.8.3-Source-Rtems/src/util/libbb/bb_core_posix.h	2007-11-14 08:37:44.000000000 +0100
@@ -0,0 +1,52 @@
+/*
+
+$Header: /sources/tsp/tsp/src/util/libbb/bb_core_sysv.h,v 1.1 2006/07/22 16:52:27 deweerdt Exp $
+
+-----------------------------------------------------------------------
+
+TSP Library - core components for a generic Transport Sampling Protocol.
+
+Copyright (c) 2006 Eric NOULARD, Frederik DEWEERDT
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+-----------------------------------------------------------------------
+
+Project   : TSP
+Maintainer : tsp@astrium-space.com
+Component : BlackBoard
+
+-----------------------------------------------------------------------
+ */
+#ifndef _BB_CORE_POSIX_H_
+#define _BB_CORE_POSIX_H_
+
+#include <tsp_abs_types.h>
+#include "bb_core.h"
+
+/*
+ *	The maximum number of BlackBoard's
+ */
+#define MAX_NUM_OF_BB	5
+
+struct bb_used_t {
+	char name[BB_NAME_MAX_SIZE+1];
+	S_BB_T *fd;
+};
+
+
+
+
+#endif /* _BB_CORE_POSIX_H_ */



diff -urN tsp-0.8.3-Source-ref/src/util/libbb/bb_simple.c tsp-0.8.3-Source-Rtems/src/util/libbb/bb_simple.c
--- tsp-0.8.3-Source-ref/src/util/libbb/bb_simple.c	2007-04-01 15:17:21.000000000 +0200
+++ tsp-0.8.3-Source-Rtems/src/util/libbb/bb_simple.c	2007-11-28 16:35:28.000000000 +0100
@@ -36,7 +36,13 @@
  */
 #ifndef __KERNEL__
 #include <sys/types.h>
-#include <sys/msg.h>
+
+#if !defined TSP_RTEMS
+# include <sys/msg.h>
+#else
+# include <mqueue.h>
+#endif /* TSP_RTEMS */
+
 #include <string.h>
 #endif /* __KERNEL__ */
 
@@ -79,33 +85,35 @@
     int type_size,
     int dimension) {
 
-  void* retval = NULL;
-  S_BB_DATADESC_T s_data_desc;
-  char *new_name;
-  int ret;
+	void* retval = NULL;
+	S_BB_DATADESC_T s_data_desc;
+	char *new_name;
+	int ret;
 
-  new_name = malloc(sizeof(char)*bb_varname_max_len());
-  if (!new_name)
-    goto out;
-  gen_var_name(new_name, module_instance, module_name, var_name);
-  ret = bb_set_varname(&s_data_desc, new_name);
-  if (ret == BB_NOK)
-    goto err_free;
-  s_data_desc.type        = type;
-  s_data_desc.type_size   = type_size;
-  s_data_desc.dimension   = dimension;
-  retval = bb_publish(bb_simple,&s_data_desc);
-
-  if (retval == NULL) {
-    bb_logMsg(BB_LOG_SEVERE,"BlackBoard::bb_simple_publish",
-        "Cannot publish data <%s> instance <%d> module <%s>",
-        var_name,module_instance,module_name);
-  }
+	new_name = malloc(sizeof(char)*bb_varname_max_len());
 
-err_free:
-  free(new_name);
-out:
-  return retval;
+	if (!new_name)
+		goto out;
+	gen_var_name(new_name, module_instance, module_name, var_name);
+	ret = bb_set_varname(&s_data_desc, new_name);
+	if (ret == BB_NOK)
+		goto err_free;
+		
+	s_data_desc.type        = type;
+	s_data_desc.type_size   = type_size;
+	s_data_desc.dimension   = dimension;
+	retval = bb_publish(bb_simple,&s_data_desc);
+
+  	if (retval == NULL) {
+		bb_logMsg(BB_LOG_SEVERE,"BlackBoard::bb_simple_publish",
+					"Cannot publish data <%s> instance <%d> module <%s>",
+					var_name,module_instance,module_name);
+	}
+
+	err_free:
+	  free(new_name);
+	out:
+	  return retval;
 } /* end of bb_simple_publish */
 
 

diff -urN tsp-0.8.3-Source-ref/src/util/libbb/bb_utils.c tsp-0.8.3-Source-Rtems/src/util/libbb/bb_utils.c
--- tsp-0.8.3-Source-ref/src/util/libbb/bb_utils.c	2007-03-20 11:11:33.000000000 +0100
+++ tsp-0.8.3-Source-Rtems/src/util/libbb/bb_utils.c	2007-11-13 11:09:02.000000000 +0100
@@ -41,7 +41,10 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <assert.h>
-#include <sys/ipc.h>
+
+#if !defined TSP_RTEMS
+# include <sys/ipc.h>
+#endif /*_TSP_RTEMS_ */
 
 #include <tsp_sys_headers.h>
 #include <bb_utils.h>
@@ -70,21 +73,20 @@
 char*
 bb_utils_build_sem_name(const char* sem_name) {
   
-  char* retval;
+  char* retval = NULL;
   int i_size_name;
   const char * prefix = "/";
   const char * postfix = "_sem";
 
   i_size_name = strlen(sem_name)+strlen(prefix)+strlen(postfix)+1;
-  retval = NULL;
   retval = (char *) malloc(i_size_name*sizeof(char));
+
   if (retval!=NULL) {
     strncpy(retval,prefix,strlen(prefix));
     strncpy(retval+strlen(prefix),sem_name,strlen(sem_name));
     strncpy(retval+strlen(prefix)+strlen(sem_name),postfix,strlen(postfix));
     retval[i_size_name-1] = '\0';
   }
-
   return retval;
 } /* end of bb_utils_build_sem_name */
 

diff -urN tsp-0.8.3-Source-ref/src/util/libbb/bb_utils.h tsp-0.8.3-Source-Rtems/src/util/libbb/bb_utils.h
--- tsp-0.8.3-Source-ref/src/util/libbb/bb_utils.h	2006-11-27 21:05:22.000000000 +0100
+++ tsp-0.8.3-Source-Rtems/src/util/libbb/bb_utils.h	2007-11-07 15:11:04.000000000 +0100
@@ -40,7 +40,10 @@
 #ifdef __KERNEL__
 #include <linux/types.h>
 #else
-#include <sys/ipc.h>
+#ifndef TSP_RTEMS
+# include <sys/ipc.h>
+#endif /* _TSP_RTEMS_ */
+
 #include <sys/types.h>
 
 #include <tsp_abs_types.h>
