Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
First pass of cleanup so that it compiles with paranoid compiler flags
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 6 Apr 2006 13:15:06 +0000 (13:15 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 6 Apr 2006 13:15:06 +0000 (13:15 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@2091 48e7efb5-ca39-0410-a469-dd3cf9ba447f

examples/gras/p2p/can/.cvsignore [new file with mode: 0644]
examples/gras/p2p/can/Makefile.am
examples/gras/p2p/can/can.c
examples/gras/p2p/can/can_tests.c
examples/gras/p2p/can/types.h

diff --git a/examples/gras/p2p/can/.cvsignore b/examples/gras/p2p/can/.cvsignore
new file mode 100644 (file)
index 0000000..508783c
--- /dev/null
@@ -0,0 +1,8 @@
+.deps .libs Makefile Makefile.in _*.c can_node can_simulator
+test_sg
+test_rl
+can.Makefile.am
+can.Makefile.local
+can.Makefile.remote
+can.deploy.sh
+can.trace
index aa7ff40..a9bcb4b 100644 (file)
@@ -5,10 +5,10 @@ EXTRA_DIST=can_deployment.xml $(TESTS)
 # AUTOMAKE variable definition
 noinst_PROGRAMS=can_node can_simulator
 
-can_simulator_SOURCES= _can_simulator.c can.c
+can_simulator_SOURCES= _can_simulator.c can.c # can_tests.c
 can_simulator_LDADD=   $(top_builddir)/src/libsimgrid.la
 
-can_node_SOURCES=      _can_node.c can.c
+can_node_SOURCES=      _can_node.c can.c # can_tests.c
 can_node_LDADD=        $(top_builddir)/src/libgras.la
 
 # Take care of generatated sources
index 372588d..ccbb607 100644 (file)
@@ -1,4 +1,4 @@
-//////////////////////////////////////////////////////
+/*////////////////////////////////////////////////////*/
 // Peer-To-Peer CAN simulator 050406 by Dytto ESIAL //
 //////////////////////////////////////////////////////
 
@@ -6,11 +6,13 @@
 #include "xbt/sysdep.h"
 #include "gras.h"
 
-#include "can_tests.c" // test class & header containing the typedef struct of a node // include type.h must be OFF.
+#include "can_tests.c"                                               
 //#include "types.h" // header alone containing the typedef struct of a node // include can_tests.c must be OFF.
 
 //XBT_LOG_NEW_DEFAULT_CATEGORY(can,"Messages specific to this example"); // include can_tests.c must be OFF.
 
+//extern char *_gras_this_type_symbol_does_not_exist__s_nuke;
+int node_nuke_handler(gras_msg_cb_ctx_t ctx,void *payload_data);
 
 // struct of a "get_successor" message, when a node look after the area in which he want to be.
 GRAS_DEFINE_TYPE(s_get_suc,
@@ -43,6 +45,8 @@ GRAS_DEFINE_TYPE(s_rep_suc,
 );
 typedef struct s_rep_suc rep_suc_t;
 
+int node(int argc,char **argv);
+
 // registering messages types
 static void register_messages(){
        gras_msgtype_declare("can_get_suc",gras_datadesc_by_symbol(s_get_suc));
@@ -53,7 +57,7 @@ static void register_messages(){
 
 // a forwarding function for a "get_suc" message.
 static void forward_get_suc(get_suc_t msg, char host[1024], int port){
-       gras_socket_t temp_sock;
+       gras_socket_t temp_sock=NULL;
        xbt_ex_t e; // the error variable used in TRY.. CATCH tokens.
        //INFO2("Transmiting message to %s:%d",host,port);      
        TRY{
@@ -71,8 +75,9 @@ static void forward_get_suc(get_suc_t msg, char host[1024], int port){
 }
 
 // the handling function of a "get_suc" message (what do a node when he receive a "get_suc" message.
-static void node_get_suc_handler(gras_socket_t expeditor,void *payload_data){
-        get_suc_t *incoming=(get_suc_t*)payload_data;
+static int node_get_suc_handler(gras_msg_cb_ctx_t ctx,void *payload_data){
+        gras_socket_t expeditor=gras_msg_cb_ctx_from(ctx);
+       get_suc_t *incoming=(get_suc_t*)payload_data;
        xbt_ex_t e; // the error variable used in TRY.. CATCH tokens.
        node_data_t *globals=(node_data_t*)gras_userdata_get();
 
@@ -173,7 +178,7 @@ static void node_get_suc_handler(gras_socket_t expeditor,void *payload_data){
                }
                if(validate==1){ // the area for the new node has been defined, then send theses informations to the new node.
                        INFO2("Sending environment informations to node %s:%d",incoming->host,incoming->port);
-                       gras_socket_t temp_sock;        
+                       gras_socket_t temp_sock=NULL;   
                        TRY{
                                temp_sock=gras_socket_client(incoming->host,incoming->port);
                        }CATCH(e){
@@ -198,6 +203,7 @@ static void node_get_suc_handler(gras_socket_t expeditor,void *payload_data){
        INFO4("My area is [%d;%d;%d;%d]",globals->x1,globals->x2,globals->y1,globals->y2);
          //INFO0("Closing node, all has been done!");
        }
+   return 1;
 }
 
 
@@ -232,7 +238,7 @@ int node(int argc,char **argv){
                globals->y2=1000;
        }else{ // asking for an area.
                INFO1("Contacting %s so as to request for an area",argv[4]);
-               gras_socket_t temp_sock;        
+               gras_socket_t temp_sock=NULL;
                TRY{
                        temp_sock=gras_socket_client(argv[4],atoi(argv[5]));
                }CATCH(e){
index efb814b..cdb90b1 100644 (file)
@@ -2,6 +2,8 @@
 // Peer-To-Peer CAN simulator 050406 by Dytto ESIAL //
 //////////////////////////////////////////////////////
 
+#include <time.h>
+//#include "gras.h"
 #include "types.h" // header containing the typedef struct of a node
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(can,"Messages specific to this example");
@@ -20,11 +22,12 @@ GRAS_DEFINE_TYPE(s_nuke,
 typedef struct s_nuke nuke_t;
 
 // the function that start the **** War of the Nodes ****
+int start_war(int argc,char **argv);
 int start_war(int argc,char **argv){
   //return 0; // in order to inhibit the War of the Nodes 
   gras_init(&argc,argv);
   gras_os_sleep((15-gras_os_getpid())*20+200); // wait a bit.
-  gras_socket_t temp_sock;
+  gras_socket_t temp_sock=NULL;
   xbt_ex_t e; // the error variable used in TRY.. CATCH tokens.
        
   TRY{ // contacting the bad guy that will launch the War.
@@ -48,6 +51,7 @@ int start_war(int argc,char **argv){
   }
   gras_socket_close(temp_sock); // spare.
   gras_exit(); // spare.
+  return 0;
 }
 
 // the function thaht send the nuke "msg" on (xId;yId), if it's not on me :p.
@@ -60,7 +64,7 @@ static int send_nuke(nuke_t *msg, int xId, int yId){
   }
   else{
     char host[1024];
-    int port;
+    int port=0;
     
     if(xId<globals->x1){
       strcpy(host,globals->west_host);
@@ -78,7 +82,7 @@ static int send_nuke(nuke_t *msg, int xId, int yId){
     msg->xId=xId;
     msg->yId=yId;
 
-    gras_socket_t temp_sock;
+    gras_socket_t temp_sock=NULL;
     xbt_ex_t e; // the error variable used in TRY.. CATCH tokens.
     TRY{ // sending the nuke.
       temp_sock=gras_socket_client(host,port);
@@ -98,7 +102,8 @@ static int send_nuke(nuke_t *msg, int xId, int yId){
 }
 
 
-static int node_nuke_handler(gras_socket_t expeditor,void *payload_data){
+static int node_nuke_handler(gras_msg_cb_ctx_t ctx,void *payload_data){
+  gras_socket_t expeditor=gras_msg_cb_ctx_from(ctx);
   nuke_t *incoming=(nuke_t*)payload_data;
   node_data_t *globals=(node_data_t*)gras_userdata_get();
 
@@ -149,7 +154,7 @@ static int node_nuke_handler(gras_socket_t expeditor,void *payload_data){
   }
   else{ // the nuke isn't for me, so i forward her.
     char host[1024];
-    int port;
+    int port=0;
     
     if(incoming->xId<globals->x1){
       strcpy(host,globals->west_host);
@@ -164,7 +169,7 @@ static int node_nuke_handler(gras_socket_t expeditor,void *payload_data){
       strcpy(host,globals->north_host);
       port=globals->north_port;}
     
-    gras_socket_t temp_sock;
+    gras_socket_t temp_sock=NULL;
     xbt_ex_t e; // the error variable used in TRY.. CATCH tokens.
     TRY{
       temp_sock=gras_socket_client(host,port);
@@ -187,6 +192,7 @@ static int node_nuke_handler(gras_socket_t expeditor,void *payload_data){
     INFO4("My area is [%d;%d;%d;%d]",globals->x1,globals->x2,globals->y1,globals->y2);
     //INFO0("Closing node, all has been done!");
     }
+   return 1;
 }
 
 // END
index 861e429..3700c37 100644 (file)
@@ -1,3 +1,4 @@
+#include "gras.h"
 
 /* Global private data */
 typedef struct{