Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ONGOING work on exceptions plus minor cleanups.
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Sat, 6 Aug 2005 22:20:59 +0000 (22:20 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Sat, 6 Aug 2005 22:20:59 +0000 (22:20 +0000)
DO NOT checkout if you need it *fully* functional.

 - Eradicate xbt_error_t in flavor of exceptions (there's still 98 such
   beasts from 463)
 - Kill some unused variable (compile with -Wunused-variable to achieve
   previous count down)
 - Now that the return value of the functions are not used by the error
   handling, begin moving the OUT argument from the last position to its
   natural place. For example:
      xbt_error_t gras_socket_server(unsigned short port,
                                     /* OUT */ gras_socket_t *dst);
   became:
      gras_socket_t gras_socket_server(unsigned short port);
   More may be needed on that front.
 - Begin adding some exception free functions for the fools:
    xbt_dict_get_or_null returns NULL when not found without throwing any
      exception. It prevents you to store NULL in the dict, but saves your
      mind from the C-ANSI exception madness.
    More are needed here, I guess.
 - Add the backtrace to the exceptions to ease their debuging. This is
   highly non-portable (glibc only), and the autotoys are not in place yet
   This is probably not the only portability breakage.
 - GRAS_DEFINE_TYPE (the parsing macro) is still broken by these changes
   But I need some sleep.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@1582 48e7efb5-ca39-0410-a469-dd3cf9ba447f

92 files changed:
acmacro/compiler-flags.m4
examples/amok/bandwidth/bandwidth.c
examples/gras/ping/ping.c
examples/gras/tokenS/tokenS.c
include/gras.h
include/gras/messages.h
include/gras/process.h
include/gras/timer.h
include/gras/transport.h
include/msg/msg.h
include/xbt/config.h
include/xbt/dict.h
include/xbt/dynar.h
include/xbt/error.h
include/xbt/ex.h
include/xbt/set.h
include/xbt/sysdep.h
src/Makefile.am
src/amok/Bandwidth/bandwidth.c
src/amok/Bandwidth/saturate.c
src/amok/base.c
src/gras/DataDesc/cbps.c
src/gras/DataDesc/datadesc_interface.h
src/gras/DataDesc/ddt_create.c
src/gras/DataDesc/ddt_exchange.c
src/gras/DataDesc/ddt_parse.c
src/gras/DataDesc/ddt_parse.yy.c
src/gras/DataDesc/ddt_parse.yy.l
src/gras/Msg/msg.c
src/gras/Msg/msg_private.h
src/gras/Msg/timer.c
src/gras/Transport/rl_transport.c
src/gras/Transport/sg_transport.c
src/gras/Transport/transport.c
src/gras/Transport/transport_interface.h
src/gras/Transport/transport_plugin_buf.c
src/gras/Transport/transport_plugin_file.c
src/gras/Transport/transport_plugin_sg.c
src/gras/Transport/transport_plugin_tcp.c
src/gras/Transport/transport_private.h
src/gras/Virtu/process.c
src/gras/Virtu/rl_emul.c
src/gras/Virtu/rl_process.c
src/gras/Virtu/sg_emul.c
src/gras/Virtu/sg_process.c
src/include/surf/surf_parse.h
src/msg/deployment.c
src/msg/environment.c
src/msg/global.c
src/msg/gos.c
src/msg/m_process.c
src/msg/msg_config.c
src/msg/task.c
src/surf/cpu.c
src/surf/network.c
src/surf/network_dassf.c
src/surf/surf_parse.c
src/surf/surf_timer.c
src/surf/trace_mgr.c
src/surf/workstation.c
src/surf/workstation_KCCFLN05.c
src/xbt/config.c
src/xbt/context.c
src/xbt/dict.c
src/xbt/dict_cursor.c
src/xbt/dict_elm.c
src/xbt/dict_multi.c
src/xbt/dict_private.h
src/xbt/dynar.c
src/xbt/error.c
src/xbt/ex.c
src/xbt/fifo.c
src/xbt/log.c
src/xbt/set.c
src/xbt/sysdep.c
testsuite/gras/datadesc_usage.c
testsuite/gras/mk_datadesc_structs.pl
testsuite/gras/trp_file_client.c
testsuite/gras/trp_file_server.c
testsuite/gras/trp_tcp_client.c
testsuite/gras/trp_tcp_server.c
testsuite/run_tests.in
testsuite/surf/surf_usage2.c
testsuite/xbt/config_usage.c
testsuite/xbt/dict_crash.c
testsuite/xbt/dict_usage.c
testsuite/xbt/dynar_double.c
testsuite/xbt/dynar_int.c
testsuite/xbt/dynar_string.c
testsuite/xbt/ex_test.c
testsuite/xbt/multidict_crash.c
testsuite/xbt/set_usage.c

index eadecbc..6ee18e2 100644 (file)
@@ -48,9 +48,10 @@ AC_DEFUN([SG_COMPILE_FLAGS],[
       if test "x$enable_compile_warnings" = "xyes"; then
         warnCFLAGS=`echo $warnCFLAGS  -Wmissing-prototypes -Wmissing-declarations \
         -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings \
       if test "x$enable_compile_warnings" = "xyes"; then
         warnCFLAGS=`echo $warnCFLAGS  -Wmissing-prototypes -Wmissing-declarations \
         -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings \
-       -Wno-unused-variable -Wno-unused-function -Wno-unused-label \
+        -Wno-unused-function  \
         -Werror \
        | sed 's/ +/ /g'`
         -Werror \
        | sed 's/ +/ /g'`
+       # -Wno-unused-variable  -Wno-unused-label
       fi
     fi
     AC_MSG_RESULT($warnCFLAGS)
       fi
     fi
     AC_MSG_RESULT($warnCFLAGS)
index f3e1a8a..84d17e9 100644 (file)
@@ -35,29 +35,20 @@ static int sensor_cb_quit(gras_socket_t  expeditor,
 int sensor (int argc,char *argv[]);
 
 int sensor (int argc,char *argv[]) {
 int sensor (int argc,char *argv[]);
 
 int sensor (int argc,char *argv[]) {
-  xbt_error_t errcode;
   sensor_data_t g;
 
   gras_init(&argc, argv);
   g=gras_userdata_new(s_sensor_data_t);  
   amok_bw_init();
    
   sensor_data_t g;
 
   gras_init(&argc, argv);
   g=gras_userdata_new(s_sensor_data_t);  
   amok_bw_init();
    
-  if ((errcode=gras_socket_server(atoi(argv[1]),&(g->sock)))) { 
-    ERROR1("Error %s encountered while opening the server socket",xbt_error_name(errcode));
-    return 1;
-  }
+  g->sock=gras_socket_server(atoi(argv[1]));
   g->done = 0;
   
   gras_msgtype_declare("quit",NULL);
   gras_cb_register(gras_msgtype_by_name("quit"),&sensor_cb_quit);
   
   g->done = 0;
   
   gras_msgtype_declare("quit",NULL);
   gras_cb_register(gras_msgtype_by_name("quit"),&sensor_cb_quit);
   
-  while (! g->done ) {
-    errcode=gras_msg_handle(60.0);
-    if (errcode != no_error) {
-       ERROR1("Error '%s' while handling message",xbt_error_name(errcode));
-       return errcode;
-    }  
-  }    
+  while (! g->done )
+    gras_msg_handle(60.0);
 
   gras_socket_close(g->sock);
   return 0;
 
   gras_socket_close(g->sock);
   return 0;
@@ -76,7 +67,6 @@ typedef struct {
 int maestro (int argc,char *argv[]);
 
 int maestro(int argc,char *argv[]) {
 int maestro (int argc,char *argv[]);
 
 int maestro(int argc,char *argv[]) {
-  xbt_error_t errcode;
   maestro_data_t g;
   double sec, bw;
   int buf_size=32;
   maestro_data_t g;
   double sec, bw;
   int buf_size=32;
@@ -96,31 +86,28 @@ int maestro(int argc,char *argv[]) {
   /* wait to ensure that all server sockets are there before starting the experiment */        
   gras_os_sleep(0.5);
   
   /* wait to ensure that all server sockets are there before starting the experiment */        
   gras_os_sleep(0.5);
   
-  if ((errcode=gras_socket_client(argv[1],atoi(argv[2]),&peer))) {
-     ERROR3("Unable to connect to my peer on %s:%s. Got %s",
-           argv[1],argv[2],xbt_error_name(errcode));
-     return 1;
-  }
+  peer = gras_socket_client(argv[1],atoi(argv[2]));
 
   INFO0("Test the BW between me and one of the sensors");  
 
   INFO0("Test the BW between me and one of the sensors");  
-  TRYOLD(amok_bw_test(peer,buf_size,exp_size,msg_size,&sec,&bw));
+  amok_bw_test(peer,buf_size,exp_size,msg_size,&sec,&bw);
   INFO6("Experience between me and %s:%d (%d kb in msgs of %d kb) took %f sec, achieving %f kb/s",
        argv[1],atoi(argv[2]),
        exp_size,msg_size,
        sec,bw);
 
   INFO0("Test the BW between the two sensors");  
   INFO6("Experience between me and %s:%d (%d kb in msgs of %d kb) took %f sec, achieving %f kb/s",
        argv[1],atoi(argv[2]),
        exp_size,msg_size,
        sec,bw);
 
   INFO0("Test the BW between the two sensors");  
-  TRYOLD(amok_bw_request(argv[1],atoi(argv[2]),argv[3],atoi(argv[4]),
-                      buf_size,exp_size,msg_size,&sec,&bw));   
+  amok_bw_request(argv[1],atoi(argv[2]),argv[3],atoi(argv[4]),
+                 buf_size,exp_size,msg_size,&sec,&bw); 
   INFO2("Experience took took %f sec, achieving %f kb/s",
        sec,bw);
 
   /* ask sensors to quit */                    
   gras_msgtype_declare("quit",NULL);
   INFO2("Experience took took %f sec, achieving %f kb/s",
        sec,bw);
 
   /* ask sensors to quit */                    
   gras_msgtype_declare("quit",NULL);
-  TRYOLD(gras_msg_send(peer,gras_msgtype_by_name("quit"), NULL));
+  gras_msg_send(peer,gras_msgtype_by_name("quit"), NULL);
   gras_socket_close(peer);
   gras_socket_close(peer);
-  TRYOLD(gras_socket_client(argv[3],atoi(argv[4]),&peer));
-  TRYOLD(gras_msg_send(peer,gras_msgtype_by_name("quit"), NULL));
+
+  peer = gras_socket_client(argv[3],atoi(argv[4]));
+  gras_msg_send(peer,gras_msgtype_by_name("quit"), NULL);
   gras_socket_close(peer);
 
   gras_socket_close(g->sock);
   gras_socket_close(peer);
 
   gras_socket_close(g->sock);
index eb98466..6cdd2d7 100644 (file)
@@ -35,7 +35,7 @@ typedef struct {
 static int server_cb_ping_handler(gras_socket_t  expeditor,
                                  void          *payload_data) {
                             
 static int server_cb_ping_handler(gras_socket_t  expeditor,
                                  void          *payload_data) {
                             
-  xbt_error_t errcode;
+  xbt_ex_t e;
   /* 1. Get the payload into the msg variable */
   int msg=*(int*)payload_data;
 
   /* 1. Get the payload into the msg variable */
   int msg=*(int*)payload_data;
 
@@ -52,13 +52,13 @@ static int server_cb_ping_handler(gras_socket_t  expeditor,
   /* 4. Change the value of the msg variable */
   msg = 4321;
   /* 5. Send it back as payload of a pong message to the expeditor */
   /* 4. Change the value of the msg variable */
   msg = 4321;
   /* 5. Send it back as payload of a pong message to the expeditor */
-  errcode = gras_msg_send(expeditor, gras_msgtype_by_name("pong"), &msg);
+  TRY {
+    gras_msg_send(expeditor, gras_msgtype_by_name("pong"), &msg);
 
 
-  /* 6. Deal with errors */
-  if (errcode != no_error) {
-    ERROR1("Unable answer with PONG: %s\n", xbt_error_name(errcode));
+  /* 6. Deal with errors: add some details to the exception */
+  } CATCH(e) {
     gras_socket_close(globals->sock);
     gras_socket_close(globals->sock);
-    return 1;
+    RETHROW0("Unable answer with PONG: %s");
   }
 
   INFO0(">>>>>>>> Answered with PONG(4321) <<<<<<<<");
   }
 
   INFO0(">>>>>>>> Answered with PONG(4321) <<<<<<<<");
@@ -74,7 +74,6 @@ static int server_cb_ping_handler(gras_socket_t  expeditor,
 } /* end_of_server_cb_ping_handler */
 
 int server (int argc,char *argv[]) {
 } /* end_of_server_cb_ping_handler */
 
 int server (int argc,char *argv[]) {
-  xbt_error_t errcode;
   server_data_t *globals;
 
   int port = 4000;
   server_data_t *globals;
 
   int port = 4000;
@@ -91,11 +90,7 @@ int server (int argc,char *argv[]) {
   INFO1("Launch server (port=%d)", port);
 
   /* 3. Create my master socket */
   INFO1("Launch server (port=%d)", port);
 
   /* 3. Create my master socket */
-  if ((errcode=gras_socket_server(port,&(globals->sock)))) { 
-    CRITICAL1("Error %s encountered while opening the server socket",
-             xbt_error_name(errcode));
-    return 1;
-  }
+  globals->sock = gras_socket_server(port);
 
   /* 4. Register the known messages. This function is called twice here, but it's because
         this file also acts as regression test, no need to do so yourself of course. */
 
   /* 4. Register the known messages. This function is called twice here, but it's because
         this file also acts as regression test, no need to do so yourself of course. */
@@ -109,11 +104,9 @@ int server (int argc,char *argv[]) {
   globals->endcondition=0;
 
   /* 6. Wait up to 10 minutes for an incomming message to handle */
   globals->endcondition=0;
 
   /* 6. Wait up to 10 minutes for an incomming message to handle */
-  errcode = gras_msg_handle(600.0);
+  gras_msg_handle(600.0);
    
   /* 7. Housekeeping */
    
   /* 7. Housekeeping */
-  if (errcode != no_error)
-    return errcode;
   if (!globals->endcondition)
      WARN0("An error occured, the endcondition was not set by the callback");
   
   if (!globals->endcondition)
      WARN0("An error occured, the endcondition was not set by the callback");
   
@@ -133,7 +126,7 @@ int server (int argc,char *argv[]) {
 /* Function prototypes */
 
 int client(int argc,char *argv[]) {
 /* Function prototypes */
 
 int client(int argc,char *argv[]) {
-  xbt_error_t errcode; 
+  xbt_ex_t e; 
   gras_socket_t toserver; /* peer */
 
   gras_socket_t from;
   gras_socket_t toserver; /* peer */
 
   gras_socket_t from;
@@ -157,10 +150,10 @@ int client(int argc,char *argv[]) {
   gras_os_sleep(1);
    
   /* 4. Create a socket to speak to the server */
   gras_os_sleep(1);
    
   /* 4. Create a socket to speak to the server */
-  if ((errcode=gras_socket_client(host,port,&toserver))) {
-    ERROR1("Unable to connect to the server. Got %s",
-          xbt_error_name(errcode));
-    return 1;
+  TRY {
+    toserver=gras_socket_client(host,port);
+  } CATCH(e) {
+    RETHROW0("Unable to connect to the server: %s");
   }
   INFO2("Connected to %s:%d.",host,port);    
 
   }
   INFO2("Connected to %s:%d.",host,port);    
 
@@ -175,24 +168,23 @@ int client(int argc,char *argv[]) {
 
   /* 7. Prepare and send the ping message to the server */
   ping = 1234;
 
   /* 7. Prepare and send the ping message to the server */
   ping = 1234;
-  errcode = gras_msg_send(toserver, gras_msgtype_by_name("ping"), &ping);
-  if (errcode != no_error) {
-    fprintf(stderr, "Unable send PING to server (%s)\n",
-           xbt_error_name(errcode));
+  TRY {
+    gras_msg_send(toserver, gras_msgtype_by_name("ping"), &ping);
+  } CATCH(e) {
     gras_socket_close(toserver);
     gras_socket_close(toserver);
-    return 1;
+    RETHROW0("Failed to send PING to server: %s");
   }
   INFO3(">>>>>>>> Message PING(%d) sent to %s:%d <<<<<<<<",
        ping,
        gras_socket_peer_name(toserver),gras_socket_peer_port(toserver));
 
   /* 8. Wait for the answer from the server, and deal with issues */
   }
   INFO3(">>>>>>>> Message PING(%d) sent to %s:%d <<<<<<<<",
        ping,
        gras_socket_peer_name(toserver),gras_socket_peer_port(toserver));
 
   /* 8. Wait for the answer from the server, and deal with issues */
-  if ((errcode=gras_msg_wait(6000,gras_msgtype_by_name("pong"),
-                            &from,&pong))) {
-    ERROR1("Why can't I get my PONG message like everyone else (%s)?",
-          xbt_error_name(errcode));
+  TRY {
+    gras_msg_wait(6000,gras_msgtype_by_name("pong"),
+                 &from,&pong);
+  } CATCH(e) {
     gras_socket_close(toserver);
     gras_socket_close(toserver);
-    return 1;
+    RETHROW0("Why can't I get my PONG message like everyone else: %s");
   }
 
   /* 9. Keep the user informed of what's going on, again */
   }
 
   /* 9. Keep the user informed of what's going on, again */
index d22444c..05b373c 100644 (file)
@@ -40,8 +40,8 @@ typedef struct {
 /* Callback function */
 static int node_cb_stoken_handler(gras_socket_t  expeditor,
                                  void          *payload_data) {
 /* Callback function */
 static int node_cb_stoken_handler(gras_socket_t  expeditor,
                                  void          *payload_data) {
-                            
-  xbt_error_t errcode;
+  
+  xbt_ex_t e;
   
   /* 1. Get the payload into the msg variable */
   int msg=*(int*)payload_data;
   
   /* 1. Get the payload into the msg variable */
   int msg=*(int*)payload_data;
@@ -76,14 +76,14 @@ static int node_cb_stoken_handler(gras_socket_t  expeditor,
      
      
     /* 6. Send it as payload of a stoken message to the successor */
      
      
     /* 6. Send it as payload of a stoken message to the successor */
-    errcode = gras_msg_send(globals->tosuccessor, 
-                           gras_msgtype_by_name("stoken"), &msg);
+    TRY {
+      gras_msg_send(globals->tosuccessor, 
+                   gras_msgtype_by_name("stoken"), &msg);
      
     /* 7. Deal with errors */
      
     /* 7. Deal with errors */
-    if (errcode != no_error) {
-      ERROR1("Unable to forward token: %s\n", xbt_error_name(errcode));
+    } CATCH(e) {
       gras_socket_close(globals->sock);
       gras_socket_close(globals->sock);
-      return 1;
+      RETHROW0("Unable to forward token: %s");
     }
   
   }
     }
   
   }
@@ -106,7 +106,6 @@ static int node_cb_stoken_handler(gras_socket_t  expeditor,
 
 
 int node (int argc,char *argv[]) {
 
 
 int node (int argc,char *argv[]) {
-  xbt_error_t errcode;
   node_data_t *globals;
   
   const char *host;
   node_data_t *globals;
   
   const char *host;
@@ -138,24 +137,14 @@ int node (int argc,char *argv[]) {
        gras_os_getpid(), host,peerport, myport);
 
   /* 4. Create my master socket for listening */
        gras_os_getpid(), host,peerport, myport);
 
   /* 4. Create my master socket for listening */
-  if ((errcode=gras_socket_server(myport,&(globals->sock)))) { 
-    CRITICAL1("Error %s encountered while opening the server socket. Bailing out.",
-             xbt_error_name(errcode));
-    return 1;
-  }
+  globals->sock = gras_socket_server(myport);
   gras_os_sleep(1.0); /* Make sure all server sockets are created */
 
 
   /* 5. Create socket to the successor on the ring */
   DEBUG2("Connect to my successor on %s:%d",host,peerport);
 
   gras_os_sleep(1.0); /* Make sure all server sockets are created */
 
 
   /* 5. Create socket to the successor on the ring */
   DEBUG2("Connect to my successor on %s:%d",host,peerport);
 
-  if ((errcode=gras_socket_client(host,peerport,
-                                 &(globals->tosuccessor)))) {
-    ERROR1("Unable to connect to the node (got %s). Bailing out.",
-          xbt_error_name(errcode));
-    return 1;
-  } 
+  globals->tosuccessor = gras_socket_client(host,peerport);
   
   /* 6. Register the known messages. This function is called twice here,
         but it's because this file also acts as regression test.
   
   /* 6. Register the known messages. This function is called twice here,
         but it's because this file also acts as regression test.
@@ -180,26 +169,14 @@ int node (int argc,char *argv[]) {
     INFO3("Create the token (with value %d) and send it to %s:%d",
          token, host, peerport);
 
     INFO3("Create the token (with value %d) and send it to %s:%d",
          token, host, peerport);
 
-    errcode = gras_msg_send(globals->tosuccessor,
-                           gras_msgtype_by_name("stoken"), &token);
-      
-    if (errcode != no_error) {
-      fprintf(stderr, "Unable send 'stoken' to successor (%s)\n",
-             xbt_error_name(errcode));
-      return 1;
-    }
+    gras_msg_send(globals->tosuccessor,
+                 gras_msgtype_by_name("stoken"), &token);
   } 
   
   /* 8. Wait up to 10 seconds for an incomming message to handle */
   while (globals->remaining_loop > (globals->create ? -1 : 0)) {
   } 
   
   /* 8. Wait up to 10 seconds for an incomming message to handle */
   while (globals->remaining_loop > (globals->create ? -1 : 0)) {
-    errcode = gras_msg_handle(10.0);
+    gras_msg_handle(10.0);
   
   
-    /* 9. Housekeeping */
-    if (errcode != no_error) {
-      ERROR1("Got error %s in msg_handle", xbt_error_name(errcode));
-      return errcode;
-    }
-       
     DEBUG1("looping (remaining_loop=%d)", globals->remaining_loop);
   }
 
     DEBUG1("looping (remaining_loop=%d)", globals->remaining_loop);
   }
 
@@ -211,5 +188,5 @@ int node (int argc,char *argv[]) {
   free(globals);
   gras_exit();
   
   free(globals);
   gras_exit();
   
-  return no_error;
+  return 0;
 } /* end_of_node */
 } /* end_of_node */
index 0e8614a..b974bd8 100644 (file)
@@ -11,6 +11,7 @@
 #define GRAS_H
 
 #include <xbt.h> /* our toolbox */
 #define GRAS_H
 
 #include <xbt.h> /* our toolbox */
+#include <xbt/ex.h> /* There's a whole bunch of exception handling in GRAS */
 
 #include <gras/process.h>
 #include <gras/virtu.h>
 
 #include <gras/process.h>
 #include <gras/virtu.h>
index 8158b0b..1b93c21 100644 (file)
@@ -103,14 +103,14 @@ typedef struct s_gras_msgtype *gras_msgtype_t;
 /** @name 3. Message exchange */
 /** @{ */
 
 /** @name 3. Message exchange */
 /** @{ */
 
-  xbt_error_t gras_msg_send(gras_socket_t   sock,
-                           gras_msgtype_t  msgtype,
-                           void           *payload);
-  xbt_error_t gras_msg_wait(double          timeout,    
-                           gras_msgtype_t  msgt_want,
-                           gras_socket_t  *expeditor,
-                           void           *payload);
-  xbt_error_t gras_msg_handle(double timeOut);
+  void gras_msg_send(gras_socket_t   sock,
+                    gras_msgtype_t  msgtype,
+                    void           *payload);
+  void gras_msg_wait(double          timeout,    
+                    gras_msgtype_t  msgt_want,
+                    gras_socket_t  *expeditor,
+                    void           *payload);
+  void gras_msg_handle(double timeOut);
 
 /* @} */
 
 
 /* @} */
 
index ca99dac..7841c7e 100644 (file)
@@ -23,14 +23,14 @@ BEGIN_DECL()
  * 
  * Perform the various intialisations needed by gras. Each process must run it
  */
  * 
  * Perform the various intialisations needed by gras. Each process must run it
  */
-xbt_error_t gras_process_init(void);
+void gras_process_init(void);
 
 /**
  * gras_process_exit:
  * 
  * Frees the memory allocated by gras. Processes should run it
  */
 
 /**
  * gras_process_exit:
  * 
  * Frees the memory allocated by gras. Processes should run it
  */
-xbt_error_t gras_process_exit(void);
+void gras_process_exit(void);
 
 /****************************************************************************/
 /* Manipulating User Data                                                   */
 
 /****************************************************************************/
 /* Manipulating User Data                                                   */
index 5ac8ce8..8c5e418 100644 (file)
@@ -42,11 +42,11 @@ BEGIN_DECL()
   void gras_timer_delay(double delay, void_f_void_t action);
   void gras_timer_repeat(double interval, void_f_void_t action);
 
   void gras_timer_delay(double delay, void_f_void_t action);
   void gras_timer_repeat(double interval, void_f_void_t action);
 
-  xbt_error_t gras_timer_cancel_delay(double interval, void_f_void_t action);
-  xbt_error_t gras_timer_cancel_repeat(double interval, void_f_void_t action);
+  void gras_timer_cancel_delay(double interval, void_f_void_t action);
+  void gras_timer_cancel_repeat(double interval, void_f_void_t action);
 
 
-  xbt_error_t gras_timer_cancel_delay_all(void);
-  xbt_error_t gras_timer_cancel_repeat_all(void);
+  void gras_timer_cancel_delay_all(void);
+  void gras_timer_cancel_repeat_all(void);
 
   void gras_timer_cancel_all(void);
 
 
   void gras_timer_cancel_all(void);
 
index cee937e..0d0f9a1 100644 (file)
 typedef struct s_gras_socket *gras_socket_t;
 
 /** \brief Simply create a client socket (to speak to a remote host) */
 typedef struct s_gras_socket *gras_socket_t;
 
 /** \brief Simply create a client socket (to speak to a remote host) */
-xbt_error_t gras_socket_client(const char *host,
-                               unsigned short port,
-                               /* OUT */ gras_socket_t *dst);
+gras_socket_t gras_socket_client(const char *host, unsigned short port);
 /** \brief Simply create a server socket (to ear from remote hosts speaking to you) */
 /** \brief Simply create a server socket (to ear from remote hosts speaking to you) */
-xbt_error_t gras_socket_server(unsigned short port,
-                               /* OUT */ gras_socket_t *dst);
+gras_socket_t gras_socket_server(unsigned short port);
 /** \brief Close socket */
 /** \brief Close socket */
-void         gras_socket_close(gras_socket_t sd);
+void          gras_socket_close(gras_socket_t sd);
 
 /** \brief Create a client socket, full interface to all relevant settings */
 
 /** \brief Create a client socket, full interface to all relevant settings */
-xbt_error_t gras_socket_client_ext(const char *host,
-                                   unsigned short port,
-                                   unsigned long int bufSize,
-                                   int measurement, 
-                                   /* OUT */ gras_socket_t *dst);
+gras_socket_t gras_socket_client_ext(const char *host,
+                                    unsigned short port,
+                                    unsigned long int bufSize,
+                                    int measurement);
 /** \brief Create a server socket, full interface to all relevant settings */
 /** \brief Create a server socket, full interface to all relevant settings */
-xbt_error_t gras_socket_server_ext(unsigned short port,
-                                   unsigned long int bufSize,
-                                   int measurement,
-                                   /* OUT */ gras_socket_t *dst);
+gras_socket_t gras_socket_server_ext(unsigned short port,
+                                    unsigned long int bufSize,
+                                    int measurement);
 /* @}*/
 /** \name Retrieving data about sockets and peers 
  *  \ingroup GRAS_sock
 /* @}*/
 /** \name Retrieving data about sockets and peers 
  *  \ingroup GRAS_sock
@@ -75,15 +70,15 @@ char *gras_socket_peer_name(gras_socket_t sock);
 
 
 int gras_socket_is_meas(gras_socket_t sock);
 
 
 int gras_socket_is_meas(gras_socket_t sock);
-xbt_error_t gras_socket_meas_send(gras_socket_t peer, 
-                                 unsigned int timeout,
-                                 unsigned long int expSize, 
-                                 unsigned long int msgSize);
-xbt_error_t gras_socket_meas_recv(gras_socket_t peer, 
-                                 unsigned int timeout,
-                                 unsigned long int expSize, 
-                                 unsigned long int msgSize);
-xbt_error_t gras_socket_meas_accept(gras_socket_t peer,gras_socket_t *accepted);
+void gras_socket_meas_send(gras_socket_t peer, 
+                          unsigned int timeout,
+                          unsigned long int expSize, 
+                          unsigned long int msgSize);
+void gras_socket_meas_recv(gras_socket_t peer, 
+                          unsigned int timeout,
+                          unsigned long int expSize, 
+                          unsigned long int msgSize);
+gras_socket_t gras_socket_meas_accept(gras_socket_t peer);
             
 /* @}*/
 
             
 /* @}*/
 
@@ -98,10 +93,8 @@ xbt_error_t gras_socket_meas_accept(gras_socket_t peer,gras_socket_t *accepted);
  */
 /* @{*/
 /* debuging functions */
  */
 /* @{*/
 /* debuging functions */
-xbt_error_t gras_socket_client_from_file(const char*path,
-                                         /* OUT */ gras_socket_t *dst);
-xbt_error_t gras_socket_server_from_file(const char*path,
-                                         /* OUT */ gras_socket_t *dst);
+gras_socket_t gras_socket_client_from_file(const char*path);
+gras_socket_t gras_socket_server_from_file(const char*path);
                                          
 /* @} */
    
                                          
 /* @} */
    
index 480d3d8..b583f46 100644 (file)
@@ -15,7 +15,7 @@ BEGIN_DECL()
 #include "msg/datatypes.h"
 
 /************************** Global ******************************************/
 #include "msg/datatypes.h"
 
 /************************** Global ******************************************/
-xbt_error_t MSG_config(const char *name, ...);
+void MSG_config(const char *name, ...);
 void MSG_global_init(void);
 void MSG_global_init_args(int *argc, char **argv);
 void MSG_set_verbosity(MSG_outputmode_t mode);
 void MSG_global_init(void);
 void MSG_global_init_args(int *argc, char **argv);
 void MSG_set_verbosity(MSG_outputmode_t mode);
index 30b912a..322c377 100644 (file)
@@ -117,42 +117,42 @@ BEGIN_DECL()
  * @{
  */
 
  * @{
  */
 
-  xbt_error_t xbt_cfg_set(xbt_cfg_t cfg, const char *name, ...);
-  xbt_error_t xbt_cfg_set_vargs(xbt_cfg_t cfg, const char *name, va_list pa);
-  xbt_error_t xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options);
+  void xbt_cfg_set(xbt_cfg_t cfg, const char *name, ...);
+  void xbt_cfg_set_vargs(xbt_cfg_t cfg, const char *name, va_list pa);
+  void xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options);
 
 
 /*
   Set the value of the cell \a name in \a cfg with the provided value.
  */
 
 
 /*
   Set the value of the cell \a name in \a cfg with the provided value.
  */
-xbt_error_t xbt_cfg_set_int   (xbt_cfg_t cfg, const char *name, 
-                                int val);
-xbt_error_t xbt_cfg_set_double(xbt_cfg_t cfg, const char *name, 
-                                double val);
-xbt_error_t xbt_cfg_set_string(xbt_cfg_t cfg, const char *name, 
-                                const char *val);
-xbt_error_t xbt_cfg_set_host  (xbt_cfg_t cfg, const char *name, 
-                                const char *host,int port);
+void xbt_cfg_set_int   (xbt_cfg_t cfg, const char *name, 
+                       int val);
+void xbt_cfg_set_double(xbt_cfg_t cfg, const char *name, 
+                       double val);
+void xbt_cfg_set_string(xbt_cfg_t cfg, const char *name, 
+                       const char *val);
+void xbt_cfg_set_host  (xbt_cfg_t cfg, const char *name, 
+                       const char *host,int port);
 
 /*
  Remove the provided value from the cell @name in @cfg.
  */
 
 /*
  Remove the provided value from the cell @name in @cfg.
  */
-xbt_error_t xbt_cfg_rm_int   (xbt_cfg_t cfg, const char *name, 
-                             int val);
-xbt_error_t xbt_cfg_rm_double(xbt_cfg_t cfg, const char *name, 
-                             double val);
-xbt_error_t xbt_cfg_rm_string(xbt_cfg_t cfg, const char *name, 
-                              const char *val);
-xbt_error_t xbt_cfg_rm_host  (xbt_cfg_t cfg, const char *name, 
-                              const char *host,int port);
+void xbt_cfg_rm_int   (xbt_cfg_t cfg, const char *name, 
+                      int val);
+void xbt_cfg_rm_double(xbt_cfg_t cfg, const char *name, 
+                      double val);
+void xbt_cfg_rm_string(xbt_cfg_t cfg, const char *name, 
+                      const char *val);
+void xbt_cfg_rm_host  (xbt_cfg_t cfg, const char *name, 
+                      const char *host,int port);
                                  
 /*
  Remove the value at position \e pos from the config \e cfg
  */
                                  
 /*
  Remove the value at position \e pos from the config \e cfg
  */
-xbt_error_t xbt_cfg_rm_at   (xbt_cfg_t cfg, const char *name, int pos);
+void xbt_cfg_rm_at   (xbt_cfg_t cfg, const char *name, int pos);
 
 /* rm every values */
 
 /* rm every values */
-xbt_error_t xbt_cfg_empty(xbt_cfg_t cfg, const char *name);    
+void xbt_cfg_empty(xbt_cfg_t cfg, const char *name);   
 
 /* @} */
 /** @name 3.  Registering stuff
 
 /* @} */
 /** @name 3.  Registering stuff
@@ -169,8 +169,7 @@ xbt_error_t xbt_cfg_empty(xbt_cfg_t cfg, const char *name);
   xbt_error_t xbt_cfg_unregister(xbt_cfg_t cfg, const char *name);
   xbt_error_t xbt_cfg_register_str(xbt_cfg_t cfg, const char *entry);
   xbt_error_t xbt_cfg_check(xbt_cfg_t cfg);
   xbt_error_t xbt_cfg_unregister(xbt_cfg_t cfg, const char *name);
   xbt_error_t xbt_cfg_register_str(xbt_cfg_t cfg, const char *entry);
   xbt_error_t xbt_cfg_check(xbt_cfg_t cfg);
-  xbt_error_t xbt_cfg_get_type(xbt_cfg_t cfg, const char *name, 
-                              /* OUT */ e_xbt_cfgelm_type_t *type);
+  e_xbt_cfgelm_type_t xbt_cfg_get_type(xbt_cfg_t cfg, const char *name);
 /*  @} */
 /** @name 4. Getting the stored values
  *
 /*  @} */
 /** @name 4. Getting the stored values
  *
@@ -185,16 +184,16 @@ xbt_error_t xbt_cfg_empty(xbt_cfg_t cfg, const char *name);
  *  @{
  */
 
  *  @{
  */
 
-  xbt_error_t xbt_cfg_get_int   (xbt_cfg_t cfg, const char *name, int    *val);
-  xbt_error_t xbt_cfg_get_double(xbt_cfg_t cfg, const char *name, double *val);
-  xbt_error_t xbt_cfg_get_string(xbt_cfg_t cfg, const char *name, char  **val);
-  xbt_error_t xbt_cfg_get_host  (xbt_cfg_t cfg, const char *name, char  **host, int *port);
-  xbt_error_t xbt_cfg_get_dynar (xbt_cfg_t cfg, const char *name, xbt_dynar_t *dynar);
+  int         xbt_cfg_get_int   (xbt_cfg_t cfg, const char *name);
+  double      xbt_cfg_get_double(xbt_cfg_t cfg, const char *name);
+  char*       xbt_cfg_get_string(xbt_cfg_t cfg, const char *name);
+  void        xbt_cfg_get_host  (xbt_cfg_t cfg, const char *name, char  **host, int *port);
+  xbt_dynar_t xbt_cfg_get_dynar (xbt_cfg_t cfg, const char *name);
 
 
-  xbt_error_t xbt_cfg_get_int_at   (xbt_cfg_t cfg, const char *name, int pos, int *val);
-  xbt_error_t xbt_cfg_get_double_at(xbt_cfg_t cfg, const char *name, int pos, double *val);
-  xbt_error_t xbt_cfg_get_string_at(xbt_cfg_t cfg, const char *name, int pos, char  **val);
-  xbt_error_t xbt_cfg_get_host_at  (xbt_cfg_t cfg, const char *name, int pos, char  **host, int *port);
+  int    xbt_cfg_get_int_at   (xbt_cfg_t cfg, const char *name, int pos);
+  double xbt_cfg_get_double_at(xbt_cfg_t cfg, const char *name, int pos);
+  char*  xbt_cfg_get_string_at(xbt_cfg_t cfg, const char *name, int pos);
+  void   xbt_cfg_get_host_at  (xbt_cfg_t cfg, const char *name, int pos, char  **host, int *port);
 
 /** @} */
 /** @} */
 
 /** @} */
 /** @} */
index 38aab19..d708a71 100644 (file)
@@ -12,8 +12,8 @@
 #define _XBT_DICT_H
 
 #include "xbt/misc.h" /* BEGIN_DECL */
 #define _XBT_DICT_H
 
 #include "xbt/misc.h" /* BEGIN_DECL */
-#include "xbt/error.h"
 #include "xbt/dynar.h" /* void_f_pvoid_t */
 #include "xbt/dynar.h" /* void_f_pvoid_t */
+#include "xbt/error.h"
 
 BEGIN_DECL()
 
 
 BEGIN_DECL()
 
@@ -61,9 +61,11 @@ BEGIN_DECL()
  *
  *  @{ */
 
  *
  *  @{ */
 
-  void xbt_dict_set(xbt_dict_t head, const char *key, void *data, void_f_pvoid_t *free_ctn);
-  xbt_error_t xbt_dict_get(xbt_dict_t head,const char *key, /* OUT */void **data);
-  xbt_error_t xbt_dict_remove(xbt_dict_t head,const char *key);
+  void  xbt_dict_set(xbt_dict_t head, const char *key, void *data, void_f_pvoid_t *free_ctn);
+  void *xbt_dict_get(xbt_dict_t head,const char *key);
+  void *xbt_dict_get_or_null(xbt_dict_t dict, const char *key);
+
+  xbt_error_t xbt_dict_remove(xbt_dict_t head, const char *key);
   void xbt_dict_dump(xbt_dict_t head,void (*output)(void*));
   
 /** @} */
   void xbt_dict_dump(xbt_dict_t head,void (*output)(void*));
   
 /** @} */
@@ -73,12 +75,11 @@ BEGIN_DECL()
  *
  *  @{
  */
  *
  *  @{
  */
-  void xbt_dict_set_ext(xbt_dict_t     head,
-                       const char     *key, int  key_len,
-                       void           *data,
-                       void_f_pvoid_t *free_ctn);
-  xbt_error_t xbt_dict_get_ext(xbt_dict_t head,const char *key, int key_len,
-                              /* OUT */void **data);
+  void  xbt_dict_set_ext(xbt_dict_t     head,
+                        const char     *key, int  key_len,
+                        void           *data,
+                        void_f_pvoid_t *free_ctn);
+  void *xbt_dict_get_ext(xbt_dict_t head,const char *key, int key_len);
   xbt_error_t xbt_dict_remove_ext(xbt_dict_t head,
                                  const char *key, int key_len);
 
   xbt_error_t xbt_dict_remove_ext(xbt_dict_t head,
                                  const char *key, int key_len);
 
@@ -112,10 +113,8 @@ BEGIN_DECL()
   void xbt_dict_cursor_rewind(xbt_dict_cursor_t cursor);
 
 
   void xbt_dict_cursor_rewind(xbt_dict_cursor_t cursor);
 
 
-  xbt_error_t xbt_dict_cursor_get_key     (xbt_dict_cursor_t cursor,
-                                          /*OUT*/char **key);
-  xbt_error_t xbt_dict_cursor_get_data    (xbt_dict_cursor_t cursor,
-                                          /*OUT*/void **data);
+  char * xbt_dict_cursor_get_key     (xbt_dict_cursor_t cursor);
+  void * xbt_dict_cursor_get_data    (xbt_dict_cursor_t cursor);
 
   void xbt_dict_cursor_first (const xbt_dict_t   dict,
                             xbt_dict_cursor_t *cursor);
 
   void xbt_dict_cursor_first (const xbt_dict_t   dict,
                             xbt_dict_cursor_t *cursor);
@@ -150,24 +149,18 @@ void xbt_dict_prints(void *data);
 
 
 /*----[ xbt_multidict_set ]--------------------------------------------------*/
 
 
 /*----[ xbt_multidict_set ]--------------------------------------------------*/
-xbt_error_t 
+void
 xbt_multidict_set(xbt_dict_t mdict,
                   xbt_dynar_t keys,
                   void *data,void (*free_ctn)(void*));
 xbt_multidict_set(xbt_dict_t mdict,
                   xbt_dynar_t keys,
                   void *data,void (*free_ctn)(void*));
-xbt_error_t
+void
 xbt_multidict_set_ext(xbt_dict_t mdict,
                       xbt_dynar_t keys, xbt_dynar_t lens,
                       void *data,void_f_pvoid_t *free_ctn);
 
 /*----[ xbt_multidict_get ]--------------------------------------------------*/
 xbt_multidict_set_ext(xbt_dict_t mdict,
                       xbt_dynar_t keys, xbt_dynar_t lens,
                       void *data,void_f_pvoid_t *free_ctn);
 
 /*----[ xbt_multidict_get ]--------------------------------------------------*/
-xbt_error_t 
-xbt_multidict_get(xbt_dict_t mdict,
-                  xbt_dynar_t keys,
-                 /*OUT*/void **data);
-xbt_error_t 
-xbt_multidict_get_ext(xbt_dict_t mdict,
-                      xbt_dynar_t keys, xbt_dynar_t lens,
-                      /*OUT*/void **data);
+void *xbt_multidict_get    (xbt_dict_t mdict, xbt_dynar_t keys);
+void *xbt_multidict_get_ext(xbt_dict_t mdict, xbt_dynar_t keys, xbt_dynar_t lens);
 
 /*----[ xbt_multidict_remove ]-----------------------------------------------*/
 /*---------------------------------------------------------------------------*/
 
 /*----[ xbt_multidict_remove ]-----------------------------------------------*/
 /*---------------------------------------------------------------------------*/
index b01be7b..d9f599b 100644 (file)
@@ -76,24 +76,24 @@ BEGIN_DECL()
  *  @{
  */
 
  *  @{
  */
 
-  void xbt_dynar_get_cpy(const xbt_dynar_t dynar, int idx, void *const dst);
+  void xbt_dynar_get_cpy(const xbt_dynar_t dynar, int idx, void * const dst);
   
   void xbt_dynar_set(xbt_dynar_t dynar, int idx, const void *src);
   void xbt_dynar_replace(xbt_dynar_t dynar, int idx, const void *object);
 
   void xbt_dynar_insert_at(xbt_dynar_t dynar, int  idx, const void *src);
   
   void xbt_dynar_set(xbt_dynar_t dynar, int idx, const void *src);
   void xbt_dynar_replace(xbt_dynar_t dynar, int idx, const void *object);
 
   void xbt_dynar_insert_at(xbt_dynar_t dynar, int  idx, const void *src);
-  void xbt_dynar_remove_at(xbt_dynar_t dynar, int  idx, void *object);
+  void xbt_dynar_remove_at(xbt_dynar_t dynar, int  idx, void * const dst);
 
 /** @} */
 /** @name 2. Perl-like functions
  *  @{
  */
 
 
 /** @} */
 /** @name 2. Perl-like functions
  *  @{
  */
 
-  void xbt_dynar_push     (xbt_dynar_t dynar, const void *src);
-  void xbt_dynar_pop      (xbt_dynar_t dynar, void *const dst);
-  void xbt_dynar_unshift  (xbt_dynar_t dynar, const void *src);
-  void xbt_dynar_shift    (xbt_dynar_t dynar, void *const dst);
-  void xbt_dynar_map      (const xbt_dynar_t dynar, void_f_pvoid_t *operator);
+  void xbt_dynar_push    (xbt_dynar_t dynar, const void *src);
+  void xbt_dynar_pop     (xbt_dynar_t dynar, void *const dst);
+  void xbt_dynar_unshift (xbt_dynar_t dynar, const void *src);
+  void xbt_dynar_shift   (xbt_dynar_t dynar, void *const dst);
+  void xbt_dynar_map            (const xbt_dynar_t dynar, void_f_pvoid_t *operator);
 
 /** @} */
 /** @name 3. Manipulating pointers to the content
 
 /** @} */
 /** @name 3. Manipulating pointers to the content
index 7ee0b89..97edd88 100644 (file)
@@ -10,8 +10,6 @@
 #ifndef XBT_ERROR_H
 #define XBT_ERROR_H
 
 #ifndef XBT_ERROR_H
 #define XBT_ERROR_H
 
-#include <stdio.h> /* FIXME: Get rid of it */
-
 #include "xbt/misc.h" /* BEGIN_DECL */
 #include "xbt/log.h"
 
 #include "xbt/misc.h" /* BEGIN_DECL */
 #include "xbt/log.h"
 
@@ -31,21 +29,13 @@ BEGIN_DECL()
 /** \brief Error types */
 typedef enum {
   no_error=0,       /**< succes */
 /** \brief Error types */
 typedef enum {
   no_error=0,       /**< succes */
-  mismatch_error=1, /**< The provided ID does not match */
-  system_error=2,   /**< a syscall did fail */
-  network_error=3,  /**< error while sending/receiving data */
-  timeout_error=4,  /**< not quick enough, dude */
-  thread_error=5,   /**< error while [un]locking */
-  unknown_error=6,  /**< unknown error */
+  old_mismatch_error=1, /**< The provided ID does not match */
+  old_system_error=2,   /**< a syscall did fail */
+  old_network_error=3,  /**< error while sending/receiving data */
+  old_timeout_error=4,  /**< not quick enough, dude */
+  old_thread_error=5,   /**< error while [un]locking */
+  old_unknown_error=6   /**< unknown error */
      
      
-  /* remote errors: result of a RMI/RPC.
-     no_error(=0) is the same for both */   
-  remote_mismatch_error=129,
-  remote_system_error,
-  remote_network_error,
-  remote_timeout_error,
-  remote_thread_error,
-  remote_unknown_error
 } xbt_error_t;
 
  const char *xbt_error_name(xbt_error_t errcode);
 } xbt_error_t;
 
  const char *xbt_error_name(xbt_error_t errcode);
@@ -118,19 +108,19 @@ typedef enum {
  */
 
 /** @hideinitializer  */
  */
 
 /** @hideinitializer  */
-#define RAISE0(code,fmt)                   _XBT_ERR_PRE   ERROR0(fmt);                   _XBT_ERR_POST(code)
+#define OLDRAISE0(code,fmt)                   _XBT_ERR_PRE   ERROR0(fmt);                   _XBT_ERR_POST(code)
 /** @hideinitializer  */
 /** @hideinitializer  */
-#define RAISE1(code,fmt,a1)                _XBT_ERR_PRE   ERROR1(fmt,a1);                _XBT_ERR_POST(code)
+#define OLDRAISE1(code,fmt,a1)                _XBT_ERR_PRE   ERROR1(fmt,a1);                _XBT_ERR_POST(code)
 /** @hideinitializer  */
 /** @hideinitializer  */
-#define RAISE2(code,fmt,a1,a2)             _XBT_ERR_PRE   ERROR2(fmt,a1,a2);             _XBT_ERR_POST(code)
+#define OLDRAISE2(code,fmt,a1,a2)             _XBT_ERR_PRE   ERROR2(fmt,a1,a2);             _XBT_ERR_POST(code)
 /** @hideinitializer  */
 /** @hideinitializer  */
-#define RAISE3(code,fmt,a1,a2,a3)          _XBT_ERR_PRE   ERROR3(fmt,a1,a2,a3);          _XBT_ERR_POST(code)
+#define OLDRAISE3(code,fmt,a1,a2,a3)          _XBT_ERR_PRE   ERROR3(fmt,a1,a2,a3);          _XBT_ERR_POST(code)
 /** @hideinitializer  */
 /** @hideinitializer  */
-#define RAISE4(code,fmt,a1,a2,a3,a4)       _XBT_ERR_PRE   ERROR4(fmt,a1,a2,a3,a4);       _XBT_ERR_POST(code)
+#define OLDRAISE4(code,fmt,a1,a2,a3,a4)       _XBT_ERR_PRE   ERROR4(fmt,a1,a2,a3,a4);       _XBT_ERR_POST(code)
 /** @hideinitializer  */
 /** @hideinitializer  */
-#define RAISE5(code,fmt,a1,a2,a3,a4,a5)    _XBT_ERR_PRE   ERROR5(fmt,a1,a2,a3,a4,a5);    _XBT_ERR_POST(code)
+#define OLDRAISE5(code,fmt,a1,a2,a3,a4,a5)    _XBT_ERR_PRE   ERROR5(fmt,a1,a2,a3,a4,a5);    _XBT_ERR_POST(code)
 /** @hideinitializer  */
 /** @hideinitializer  */
-#define RAISE6(code,fmt,a1,a2,a3,a4,a5,a6) _XBT_ERR_PRE   ERROR6(fmt,a1,a2,a3,a4,a5,a6); _XBT_ERR_POST(code)
+#define OLDRAISE6(code,fmt,a1,a2,a3,a4,a5,a6) _XBT_ERR_PRE   ERROR6(fmt,a1,a2,a3,a4,a5,a6); _XBT_ERR_POST(code)
 
 /** @} */
 /** 
 
 /** @} */
 /** 
@@ -176,11 +166,11 @@ typedef enum {
  *
  *  @{ 
  */
  *
  *  @{ 
  */
-#define RAISE_IMPOSSIBLE RAISE0(unknown_error,"The Impossible did happen")
-#define RAISE_UNIMPLEMENTED RAISE1(unknown_error,"Function %s unimplemented",__FUNCTION__)
+#define RAISE_IMPOSSIBLE RAISE0(old_unknown_error,"The Impossible did happen (yet again)")
+#define RAISE_UNIMPLEMENTED RAISE1(old_unknown_error,"Function %s unimplemented",__FUNCTION__)
 
 
-#define DIE_IMPOSSIBLE xbt_assert0(0,"The Impossible did happen (yet again)")
-#define xbt_assert_error(a) xbt_assert1(errcode == (a), "Error %s unexpected",xbt_error_name(errcode))
+#define OLDDIE_IMPOSSIBLE xbt_assert0(0,"The Impossible did happen (yet again)")
+#define OLDxbt_assert_error(a) xbt_assert1(errcode == (a), "Error %s unexpected",xbt_error_name(errcode))
 
 /** @} */
 /** @} */
 
 /** @} */
 /** @} */
index 70ae03a..6ccf495 100644 (file)
 #include <xbt/sysdep.h>
 
 /* required ISO-C standard facilities */
 #include <xbt/sysdep.h>
 
 /* required ISO-C standard facilities */
+#include <errno.h>
 #include <stdio.h>
 
 #include <stdio.h>
 
+//#define __EX_MCTX_MCSC__ 1
+#define __EX_MCTX_SSJLJ__ 1
 /* the machine context */
 #if defined(__EX_MCTX_MCSC__)
 #include <ucontext.h>            /* POSIX.1 ucontext(3) */
 /* the machine context */
 #if defined(__EX_MCTX_MCSC__)
 #include <ucontext.h>            /* POSIX.1 ucontext(3) */
@@ -63,6 +66,7 @@
 
 /* declare the machine context type */
 typedef struct { __ex_mctx_struct } __ex_mctx_t;
 
 /* declare the machine context type */
 typedef struct { __ex_mctx_struct } __ex_mctx_t;
 /** @addtogroup XBT_ex
  *
  * This module is a small ISO-C++ style exception handling library
 /** @addtogroup XBT_ex
  *
  * This module is a small ISO-C++ style exception handling library
@@ -117,7 +121,7 @@ typedef struct { __ex_mctx_struct } __ex_mctx_t;
  *    only in combination and form a language clause as a whole.
  *  - In contrast to the syntax of other languages (such as C++ or Jave) there
  *    is only one CATCH block and not multiple ones (all exceptions are
  *    only in combination and form a language clause as a whole.
  *  - In contrast to the syntax of other languages (such as C++ or Jave) there
  *    is only one CATCH block and not multiple ones (all exceptions are
- *    of the same \em ex_t C type). 
+ *    of the same \em xbt_ex_t C type). 
  *  - the variable of CATCH can naturally be reused in subsequent 
  *    CATCH clauses.
  *  - it is possible to nest TRY clauses.
  *  - the variable of CATCH can naturally be reused in subsequent 
  *    CATCH clauses.
  *  - it is possible to nest TRY clauses.
@@ -145,38 +149,6 @@ typedef struct { __ex_mctx_struct } __ex_mctx_t;
  * between the TRY and the THROW may be discarded if you forget the
  * "volatile" keyword. 
  * 
  * between the TRY and the THROW may be discarded if you forget the
  * "volatile" keyword. 
  * 
- * @section XBT_ex_advanced ADVANCED USAGE
- *
- * @subsection DEFER DEFERING_BLOCK XBT_ex_defer
- *
- * This directive executes DEFERING_BLOCK while deferring the throwing of
- * exceptions, i.e., exceptions thrown within this block are remembered, but
- * the control flow still continues until the end of the block. At its end, the
- * first exception which occured within the block (if any) is rethrown (any
- * subsequent exceptions are ignored).
- *
- * DEFERING_BLOCK is a regular ISO-C language statement block, but it is not
- * allowed to jump into it via "goto" or longjmp(3) or out of it via "break",
- * "return", "goto" or longjmp(3). It is however allowed to nest DEFER
- * clauses.
- *
- * @subsection XBT_ex_shield SHIELD SHIELDED_BLOCK
- *
- * This directive executes SHIELDED_BLOCK while shielding it against the
- * throwing of exceptions, i.e., any exception thrown from this block or its
- * subroutines are silently ignored.
- *
- * SHIELDED_BLOCK is a regular ISO-C language statement block, but it is not
- * allowed to jump into it via "goto" or longjmp(3) or out of it via "break",
- * "return", "goto" or longjmp(3).  It is however allowed to nest SHIELD
- * clauses.
- *
- * @subsection XBT_ex_conditions Retrieving the current execution condition
- *
- * \a IS_CATCHED, \a IS_DEFERRED and \a IS_SHIELDED return a boolean
- * indicating whether the current scope is within a TRYIED_BLOCK,
- * DEFERING_BLOCK and SHIELDED_BLOCK (respectively)
- *
  * \section XBT_ex_pitfalls PROGRAMMING PITFALLS 
  *
  * Exception handling is a very elegant and efficient way of dealing with
  * \section XBT_ex_pitfalls PROGRAMMING PITFALLS 
  *
  * Exception handling is a very elegant and efficient way of dealing with
@@ -226,43 +198,50 @@ typedef struct { __ex_mctx_struct } __ex_mctx_t;
  * @{
  */
 
  * @{
  */
 
+typedef enum {
+  unknown_error=0,  /**< unknown error */
+  arg_error,        /**< Invalid argument */
+  mismatch_error,   /**< The provided ID does not match */
+  
+  system_error,   /**< a syscall did fail */
+  network_error,  /**< error while sending/receiving data */
+  timeout_error,  /**< not quick enough, dude */
+  thread_error    /**< error while [un]locking */
+} xbt_errcat_t;
+
+const char *xbt_errcat_name(xbt_error_t errcode);
+
 /** @brief Structure describing an exception */
 typedef struct {
 /** @brief Structure describing an exception */
 typedef struct {
-  char *msg;      /**< human readable message; to be freed */
-  int   category; /**< category like HTTP (what went wrong) */
-  int   value;    /**< like errno (why did it went wrong) */
+  char        *msg;      /**< human readable message; to be freed */
+  xbt_errcat_t category; /**< category like HTTP (what went wrong) */
+  int          value;    /**< like errno (why did it went wrong) */
   /* throw point */
   char *host;     /* NULL for localhost; hostname:port if remote */
   char *procname; 
   char *file;     /**< to be freed only for remote exceptions */
   int   line;     
   char *func;     /**< to be freed only for remote exceptions */
   /* throw point */
   char *host;     /* NULL for localhost; hostname:port if remote */
   char *procname; 
   char *file;     /**< to be freed only for remote exceptions */
   int   line;     
   char *func;     /**< to be freed only for remote exceptions */
-} ex_t;
+  /* Backtrace */
+  void *bt[10];
+  int   used;
+} xbt_ex_t;
 
 /* declare the context type (private) */
 typedef struct {
     __ex_mctx_t  *ctx_mctx;     /* permanent machine context of enclosing try/catch */
 
 /* declare the context type (private) */
 typedef struct {
     __ex_mctx_t  *ctx_mctx;     /* permanent machine context of enclosing try/catch */
-    int           ctx_deferred; /* permanent flag whether exception is deferred */
-    int           ctx_deferring;/* permanent counter of exception deferring level */
-    int           ctx_defer;    /* temporary flag for exception deferring macro */
-    int           ctx_shielding;/* permanent counter of exception shielding level */
-    int           ctx_shield;   /* temporary flag for exception shielding macro */
     int           ctx_caught;   /* temporary flag whether exception was caught */
     int           ctx_caught;   /* temporary flag whether exception was caught */
-    volatile ex_t ctx_ex;       /* temporary exception storage */
+    volatile xbt_ex_t ctx_ex;       /* temporary exception storage */
 } ex_ctx_t;
 
 /* the static and dynamic initializers for a context structure */
 #define XBT_CTX_INITIALIZER \
 } ex_ctx_t;
 
 /* the static and dynamic initializers for a context structure */
 #define XBT_CTX_INITIALIZER \
-    { NULL, 0, 0, 0, 0, 0, 0, { /* content */ NULL, 0, 0, \
-                                /*throw point*/ NULL, NULL, NULL, 0, NULL } }
+    { NULL, 0, { /* content */ NULL, 0, 0, \
+                 /* throw point*/ NULL, NULL, NULL, 0, NULL,\
+                 /* backtrace */ {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL},0 } }
 #define XBT_CTX_INITIALIZE(ctx) \
     do { \
         (ctx)->ctx_mctx        = NULL; \
 #define XBT_CTX_INITIALIZE(ctx) \
     do { \
         (ctx)->ctx_mctx        = NULL; \
-        (ctx)->ctx_deferred    = 0;    \
-        (ctx)->ctx_deferring   = 0;    \
-        (ctx)->ctx_defer       = 0;    \
-        (ctx)->ctx_shielding   = 0;    \
-        (ctx)->ctx_shield      = 0;    \
         (ctx)->ctx_caught      = 0;    \
         (ctx)->ctx_ex.msg      = NULL; \
         (ctx)->ctx_ex.category = 0;    \
         (ctx)->ctx_caught      = 0;    \
         (ctx)->ctx_ex.msg      = NULL; \
         (ctx)->ctx_ex.category = 0;    \
@@ -272,6 +251,17 @@ typedef struct {
         (ctx)->ctx_ex.file     = NULL; \
         (ctx)->ctx_ex.line     = 0;    \
         (ctx)->ctx_ex.func     = NULL; \
         (ctx)->ctx_ex.file     = NULL; \
         (ctx)->ctx_ex.line     = 0;    \
         (ctx)->ctx_ex.func     = NULL; \
+        (ctx)->ctx_ex.bt[0]    = NULL; \
+        (ctx)->ctx_ex.bt[1]    = NULL; \
+        (ctx)->ctx_ex.bt[2]    = NULL; \
+        (ctx)->ctx_ex.bt[3]    = NULL; \
+        (ctx)->ctx_ex.bt[4]    = NULL; \
+        (ctx)->ctx_ex.bt[5]    = NULL; \
+        (ctx)->ctx_ex.bt[6]    = NULL; \
+        (ctx)->ctx_ex.bt[7]    = NULL; \
+        (ctx)->ctx_ex.bt[8]    = NULL; \
+        (ctx)->ctx_ex.bt[9]    = NULL; \
+        (ctx)->ctx_ex.used     = 0; \
     } while (0)
 
 /* the exception context */
     } while (0)
 
 /* the exception context */
@@ -280,13 +270,17 @@ extern ex_ctx_cb_t __xbt_ex_ctx;
 extern ex_ctx_t *__xbt_ex_ctx_default(void);
 
 /* the termination handler */
 extern ex_ctx_t *__xbt_ex_ctx_default(void);
 
 /* the termination handler */
-typedef void (*ex_term_cb_t)(ex_t *);
+typedef void (*ex_term_cb_t)(xbt_ex_t *);
 extern ex_term_cb_t __xbt_ex_terminate;
 extern ex_term_cb_t __xbt_ex_terminate;
-extern void __xbt_ex_terminate_default(ex_t *e);
+extern void __xbt_ex_terminate_default(xbt_ex_t *e)  __attribute__((__noreturn__));
 
 /** @brief Introduce a block where exception may be dealed with 
  *  @hideinitializer
  */
 
 /** @brief Introduce a block where exception may be dealed with 
  *  @hideinitializer
  */
+/*        xbt_assert1(1,\
+                "Severe error in exception mecanism: cannot save the catching context: %s", \
+                   strerror(errno)); \
+*/
 #define TRY \
     { \
         ex_ctx_t *__xbt_ex_ctx_ptr = __xbt_ex_ctx(); \
 #define TRY \
     { \
         ex_ctx_t *__xbt_ex_ctx_ptr = __xbt_ex_ctx(); \
@@ -305,8 +299,7 @@ extern void __xbt_ex_terminate_default(ex_t *e);
             else { \
             } \
             __xbt_ex_ctx_ptr->ctx_caught = 0; \
             else { \
             } \
             __xbt_ex_ctx_ptr->ctx_caught = 0; \
-        } \
-        else { \
+        } else { \
             __ex_mctx_restored(&__ex_mctx_me); \
             __xbt_ex_ctx_ptr->ctx_caught = 1; \
         } \
             __ex_mctx_restored(&__ex_mctx_me); \
             __xbt_ex_ctx_ptr->ctx_caught = 1; \
         } \
@@ -323,8 +316,7 @@ extern void __xbt_ex_terminate_default(ex_t *e);
             } \
             if (!(__ex_cleanup)) \
                 __xbt_ex_ctx_ptr->ctx_caught = 0; \
             } \
             if (!(__ex_cleanup)) \
                 __xbt_ex_ctx_ptr->ctx_caught = 0; \
-        } \
-        else { \
+        } else { \
             if (!(__ex_cleanup)) { \
                 __ex_mctx_restored(&__ex_mctx_me); \
                 __xbt_ex_ctx_ptr->ctx_caught = 1; \
             if (!(__ex_cleanup)) { \
                 __ex_mctx_restored(&__ex_mctx_me); \
                 __xbt_ex_ctx_ptr->ctx_caught = 1; \
@@ -344,78 +336,85 @@ extern void __xbt_ex_terminate_default(ex_t *e);
  *  @param v: value (integer)
  *  @param m: message text
  *
  *  @param v: value (integer)
  *  @param m: message text
  *
- * If called from within a sg_try/sg_catch construct, this exception 
- * is copied into the sg_catch relevant variable program control flow 
- * is derouted to the sg_catch (after the optional sg_cleanup). 
+ * If called from within a TRY/CATCH construct, this exception 
+ * is copied into the CATCH relevant variable program control flow 
+ * is derouted to the CATCH (after the optional sg_cleanup). 
  *
  *
- * If no sg_try/sg_catch conctruct embeeds this call, the program calls
+ * If no TRY/CATCH construct embeeds this call, the program calls
  * abort(3). 
  *
  * abort(3). 
  *
- * The sg_throw can be performed everywhere, including inside sg_try
- * sg_cleanup and sg_catch blocks.
+ * The THROW can be performed everywhere, including inside TRY
+ * CLEANUP and CATCH blocks.
  */
  */
-#define THROW(c,v,m) \
-    ((   __xbt_ex_ctx()->ctx_shielding > 0 \
-      || (__xbt_ex_ctx()->ctx_deferring > 0 && __xbt_ex_ctx()->ctx_deferred == 1)) ? 0 : \
-     (__xbt_ex_ctx()->ctx_ex.msg      = bprintf(m), \
-      __xbt_ex_ctx()->ctx_ex.category = (c), \
-      __xbt_ex_ctx()->ctx_ex.value    = (v), \
-      __xbt_ex_ctx()->ctx_ex.host     = (char*)NULL, \
-      __xbt_ex_ctx()->ctx_ex.procname = strdup(xbt_procname()), \
-      __xbt_ex_ctx()->ctx_ex.file     = (char*)__FILE__, \
-      __xbt_ex_ctx()->ctx_ex.line     = __LINE__, \
-      __xbt_ex_ctx()->ctx_ex.func     = (char*)_XBT_FUNCTION, \
-      __xbt_ex_ctx()->ctx_deferred     = 1, \
-      (__xbt_ex_ctx()->ctx_deferring > 0 ? 0 : \
-       (__xbt_ex_ctx()->ctx_mctx == NULL \
-        ? (__xbt_ex_terminate((ex_t *)&(__xbt_ex_ctx()->ctx_ex)), -1) \
-        : (__ex_mctx_restore(__xbt_ex_ctx()->ctx_mctx), 1) ))))
+#include <execinfo.h>
+#define _THROW(c,v,m) \
+  do { /* change this sequence into one block */                               \
+     /* build the exception */ \
+     __xbt_ex_ctx()->ctx_ex.msg      = (m); \
+     __xbt_ex_ctx()->ctx_ex.category = (c); \
+     __xbt_ex_ctx()->ctx_ex.value    = (v);  \
+     __xbt_ex_ctx()->ctx_ex.host     = (char*)NULL;                            \
+     __xbt_ex_ctx()->ctx_ex.procname = strdup(xbt_procname());                 \
+     __xbt_ex_ctx()->ctx_ex.file     = (char*)__FILE__;                        \
+     __xbt_ex_ctx()->ctx_ex.line     = __LINE__;                               \
+     __xbt_ex_ctx()->ctx_ex.func     = (char*)_XBT_FUNCTION;                   \
+     __xbt_ex_ctx()->ctx_ex.used     = backtrace((void**)__xbt_ex_ctx()->ctx_ex.bt,10);\
+     /* deal with the exception */                                             \
+     if (__xbt_ex_ctx()->ctx_mctx == NULL)                                     \
+       __xbt_ex_terminate((xbt_ex_t *)&(__xbt_ex_ctx()->ctx_ex)); /* not catched */\
+     else                                                                      \
+       __ex_mctx_restore(__xbt_ex_ctx()->ctx_mctx); /* catched somewhere */    \
+     abort();/* nope, stupid GCC, we won't survive a THROW (this won't be reached) */ \
+  } while (0)
+
+#define THROW0(c,v,m)                   _THROW(c,v,bprintf(m))
+#define THROW1(c,v,m,a1)                _THROW(c,v,bprintf(m,a1))
+#define THROW2(c,v,m,a1,a2)             _THROW(c,v,bprintf(m,a1,a2))
+#define THROW3(c,v,m,a1,a2,a3)          _THROW(c,v,bprintf(m,a1,a2,a3))
+#define THROW4(c,v,m,a1,a2,a3,a4)       _THROW(c,v,bprintf(m,a1,a2,a3,a4))
+#define THROW5(c,v,m,a1,a2,a3,a4,a5)    _THROW(c,v,bprintf(m,a1,a2,a3,a4,a5))
+#define THROW6(c,v,m,a1,a2,a3,a4,a5,a6) _THROW(c,v,bprintf(m,a1,a2,a3,a4,a5,a6))
+
+#define THROW_IMPOSSIBLE     THROW0(unknown_error,0,"The Impossible Did Happen (yet again)")
+#define DIE_IMPOSSIBLE       xbt_assert0(0,"The Impossible Did Happen (yet again)")
+#define THROW_UNIMPLEMENTED  THROW1(unknown_error,0,"Function %s unimplemented",__FUNCTION__)
 
 /** @brief re-throwing of an already caught exception (ie, pass it to the upper catch block) 
  *  @hideinitializer
  */
 #define RETHROW \
 
 /** @brief re-throwing of an already caught exception (ie, pass it to the upper catch block) 
  *  @hideinitializer
  */
 #define RETHROW \
-    ((   __xbt_ex_ctx()->ctx_shielding > 0 \
-      || __xbt_ex_ctx()->ctx_deferring > 0) ? 0 : \
-      (  __xbt_ex_ctx()->ctx_mctx == NULL \
-       ? (__xbt_ex_terminate((ex_t *)&(__xbt_ex_ctx()->ctx_ex)), -1) \
-       : (__ex_mctx_restore(__xbt_ex_ctx()->ctx_mctx), 1) ))
+  do { \
+   if (__xbt_ex_ctx()->ctx_mctx == NULL) \
+     __xbt_ex_terminate((xbt_ex_t *)&(__xbt_ex_ctx()->ctx_ex)); \
+   else \
+     __ex_mctx_restore(__xbt_ex_ctx()->ctx_mctx); \
+   abort();\
+  } while(0)
 
 
-/** @brief shield an operation from exception handling 
+/** @brief like RETHROW, but adding some details to the message
  *  @hideinitializer
  */
  *  @hideinitializer
  */
-#define SHIELD \
-    for (__xbt_ex_ctx()->ctx_shielding++, \
-         __xbt_ex_ctx()->ctx_shield =  1; \
-         __xbt_ex_ctx()->ctx_shield == 1; \
-         __xbt_ex_ctx()->ctx_shield =  0, \
-         __xbt_ex_ctx()->ctx_shielding--)
 
 
-/** @brief defer immediate exception handling 
- *  @hideinitializer
- */
-#define DEFER \
-    for (((__xbt_ex_ctx()->ctx_deferring)++ == 0 ? __xbt_ex_ctx()->ctx_deferred = 0 : 0), \
-         __xbt_ex_ctx()->ctx_defer =  1;  \
-         __xbt_ex_ctx()->ctx_defer == 1;  \
-         __xbt_ex_ctx()->ctx_defer =  0,  \
-         ((--(__xbt_ex_ctx()->ctx_deferring) == 0 && __xbt_ex_ctx()->ctx_deferred == 1) ? RETHROW : 0))
 
 
-/** @brief exception handling tests 
- *  @hideinitializer
- */
-#define IS_CATCHED \
-    (__xbt_ex_ctx()->ctx_mctx != NULL)
-/** @brief exception handling tests 
- *  @hideinitializer
- */
-#define IS_SHIELDED \
-    (__xbt_ex_ctx()->ctx_shielding > 0)
-/** @brief exception handling tests 
- *  @hideinitializer
- */
-#define IS_DEFERRED \
-    (__xbt_ex_ctx()->ctx_deferring > 0)
+#define _XBT_PRE_RETHROW \
+  do {                                                               \
+    char *_xbt_ex_internal_msg = __xbt_ex_ctx()->ctx_ex.msg;         \
+    __xbt_ex_ctx()->ctx_ex.msg = bprintf(
+#define _XBT_POST_RETHROW \
+ _xbt_ex_internal_msg); \
+    free(_xbt_ex_internal_msg);                                      \
+    RETHROW;                                                         \
+  } while (0)
+
+#define RETHROW0(msg)           _XBT_PRE_RETHROW msg,          _XBT_POST_RETHROW
+#define RETHROW1(msg,a)         _XBT_PRE_RETHROW msg,a,        _XBT_POST_RETHROW
+#define RETHROW2(msg,a,b)       _XBT_PRE_RETHROW msg,a,b,      _XBT_POST_RETHROW
+#define RETHROW3(msg,a,b,c)     _XBT_PRE_RETHROW msg,a,b,c,    _XBT_POST_RETHROW
+#define RETHROW4(msg,a,b,c,d)   _XBT_PRE_RETHROW msg,a,b,c,    _XBT_POST_RETHROW
+#define RETHROW5(msg,a,b,c,d,e) _XBT_PRE_RETHROW msg,a,b,c,d,e _XBT_POST_RETHROW
+
+void xbt_ex_free(xbt_ex_t e);
+const char * xbt_ex_catname(xbt_errcat_t cat);
 
 /** @} */
 #endif /* __XBT_EX_H__ */
 
 /** @} */
 #endif /* __XBT_EX_H__ */
index 103c587..726efad 100644 (file)
@@ -58,20 +58,11 @@ typedef struct xbt_set_elm_ *  xbt_set_elm_t;
  *  @{
  */
 
  *  @{
  */
 
-void xbt_set_add (xbt_set_t      set,
-                  xbt_set_elm_t  elm,
-                  void_f_pvoid_t *free_func);
-
-xbt_error_t xbt_set_get_by_name    (xbt_set_t      set,
-                                   const char     *key,
-                                   /* OUT */xbt_set_elm_t *dst);
-xbt_error_t xbt_set_get_by_name_ext(xbt_set_t      set,
-                                   const char     *name,
-                                   int             name_len,
-                                   /* OUT */xbt_set_elm_t *dst);
-xbt_error_t xbt_set_get_by_id      (xbt_set_t      set,
-                                   int             id,
-                                   /* OUT */xbt_set_elm_t *dst);
+void xbt_set_add (xbt_set_t set, xbt_set_elm_t  elm, void_f_pvoid_t *free_func);
+
+xbt_set_elm_t xbt_set_get_by_name    (xbt_set_t set, const char *key);
+xbt_set_elm_t xbt_set_get_by_name_ext(xbt_set_t set, const char *key, int key_len);
+xbt_set_elm_t xbt_set_get_by_id      (xbt_set_t set, int         id);
                                      
 /** @} */
 /** @name 3. Cursors
                                      
 /** @} */
 /** @name 3. Cursors
index 9a5983e..b917978 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <string.h>
 #include <stdlib.h> 
 
 #include <string.h>
 #include <stdlib.h> 
+#include <stdio.h>
    
 #include "xbt/misc.h"
 #include "xbt/error.h"
    
 #include "xbt/misc.h"
 #include "xbt/error.h"
index 348644e..a8d60ef 100644 (file)
@@ -193,10 +193,10 @@ endif
 endif
 
 libgras_la_SOURCES= $(COMMON_SRC) $(RL_SRC) $(AMOK_SRC)
 endif
 
 libgras_la_SOURCES= $(COMMON_SRC) $(RL_SRC) $(AMOK_SRC)
-libgras_la_LDFLAGS = $(VERSION_INFO) @GRAS_DEP@ -lm
+libgras_la_LDFLAGS = $(VERSION_INFO) @GRAS_DEP@ -lm -Wl,--export-dynamic
 
 libsimgrid_la_SOURCES= $(COMMON_SRC) $(SG_SRC) $(AMOK_SRC)
 
 libsimgrid_la_SOURCES= $(COMMON_SRC) $(SG_SRC) $(AMOK_SRC)
-libsimgrid_la_LDFLAGS = $(VERSION_INFO) @SIMGRID_DEP@ -lm
+libsimgrid_la_LDFLAGS = $(VERSION_INFO) @SIMGRID_DEP@ -lm -Wl,--export-dynamic
 
 
 include $(top_srcdir)/acmacro/dist-files.mk
 
 
 include $(top_srcdir)/acmacro/dist-files.mk
index ae19bdb..c92291f 100644 (file)
@@ -7,6 +7,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "xbt/ex.h"
 #include "amok/Bandwidth/bandwidth_private.h"
 #include "gras/messages.h"
 
 #include "amok/Bandwidth/bandwidth_private.h"
 #include "gras/messages.h"
 
@@ -125,20 +126,25 @@ xbt_error_t amok_bw_test(gras_socket_t peer,
                         /*OUT*/ double *sec, double *bw) {
 
   /* Measurement sockets for the experiments */
                         /*OUT*/ double *sec, double *bw) {
 
   /* Measurement sockets for the experiments */
-  gras_socket_t measMasterIn,measIn,measOut;
+  gras_socket_t measMasterIn=NULL,measIn,measOut;
   int port;
   xbt_error_t errcode;
   bw_request_t request,request_ack;
   int port;
   xbt_error_t errcode;
   bw_request_t request,request_ack;
+  xbt_ex_t e;
   
   
-  for (port = 5000, errcode = system_error;
-       errcode == system_error && port < 10000;
-       errcode = gras_socket_server_ext(++port,buf_size,1,&measMasterIn));
-  if (errcode != no_error) {
-    ERROR1("Error %s encountered while opening a measurement socket",
-          xbt_error_name(errcode));
-    return errcode;
+  for (port = 5000; port < 10000 && measMasterIn == NULL; port++) {
+    TRY {
+      measMasterIn = gras_socket_server_ext(++port,buf_size,1);
+    } CATCH(e) {
+      measMasterIn = NULL;
+      if (port < 10000) {
+       xbt_ex_free(e);
+      } else {
+       RETHROW0("Error caught while opening a measurement socket: %s");
+      }
+    }
   }
   }
-       
+  
   request=xbt_new0(s_bw_request_t,1);
   request->buf_size=buf_size*1024;
   request->exp_size=exp_size*1024;
   request=xbt_new0(s_bw_request_t,1);
   request->buf_size=buf_size*1024;
   request->exp_size=exp_size*1024;
@@ -149,33 +155,34 @@ xbt_error_t amok_bw_test(gras_socket_t peer,
        gras_socket_peer_name(peer),gras_socket_peer_port(peer), request->host.port,
        buf_size,request->buf_size);
 
        gras_socket_peer_name(peer),gras_socket_peer_port(peer), request->host.port,
        buf_size,request->buf_size);
 
-  if ((errcode=gras_msg_send(peer,gras_msgtype_by_name("BW handshake"),&request))) {
-    ERROR1("Error %s encountered while sending the BW request.", xbt_error_name(errcode));
-    return errcode;
+  TRY {
+    gras_msg_send(peer,gras_msgtype_by_name("BW handshake"),&request);
+  } CATCH(e) {
+    RETHROW0("Error encountered while sending the BW request: %s");
   }
   }
-  TRYOLD(gras_socket_meas_accept(measMasterIn,&measIn));
+  measIn = gras_socket_meas_accept(measMasterIn);
 
 
-  if ((errcode=gras_msg_wait(60,gras_msgtype_by_name("BW handshake ACK"),
-                            NULL,&request_ack))) {
-    ERROR1("Error %s encountered while waiting for the answer to BW request.\n",
-           xbt_error_name(errcode));
-    return errcode;
+  TRY {
+    gras_msg_wait(60,gras_msgtype_by_name("BW handshake ACK"),NULL,&request_ack);
+  } CATCH(e) {
+    RETHROW0("Error encountered while waiting for the answer to BW request: %s");
   }
   
   /* FIXME: What if there is a remote error? */
    
   }
   
   /* FIXME: What if there is a remote error? */
    
-  if((errcode=gras_socket_client_ext(gras_socket_peer_name(peer),
-                                    request_ack->host.port, 
-                                    request->buf_size,1,&measOut))) {
-    ERROR3("Error %s encountered while opening the measurement socket to %s:%d for BW test\n",
-           xbt_error_name(errcode),gras_socket_peer_name(peer),request_ack->host.port);
-    return errcode;
+  TRY {
+    measOut=gras_socket_client_ext(gras_socket_peer_name(peer),
+                                  request_ack->host.port, 
+                                  request->buf_size,1);
+  } CATCH(e) {
+    RETHROW2("Error encountered while opening the measurement socket to %s:%d for BW test",
+            gras_socket_peer_name(peer),request_ack->host.port);
   }
   DEBUG1("Got ACK; conduct the experiment (msg_size=%ld)",request->msg_size);
 
   *sec=gras_os_time();
   }
   DEBUG1("Got ACK; conduct the experiment (msg_size=%ld)",request->msg_size);
 
   *sec=gras_os_time();
-  TRYOLD(gras_socket_meas_send(measOut,120,request->exp_size,request->msg_size));
-  TRYOLD(gras_socket_meas_recv(measIn,120,1,1));
+  gras_socket_meas_send(measOut,120,request->exp_size,request->msg_size);
+  gras_socket_meas_recv(measIn,120,1,1);
 
   /*catch
     ERROR1("Error %s encountered while sending the BW experiment.",
 
   /*catch
     ERROR1("Error %s encountered while sending the BW experiment.",
@@ -208,10 +215,10 @@ xbt_error_t amok_bw_test(gras_socket_t peer,
 */
 int amok_bw_cb_bw_handshake(gras_socket_t  expeditor,
                            void          *payload) {
 */
 int amok_bw_cb_bw_handshake(gras_socket_t  expeditor,
                            void          *payload) {
-  gras_socket_t measMasterIn,measIn,measOut;
+  gras_socket_t measMasterIn=NULL,measIn,measOut;
   bw_request_t request=*(bw_request_t*)payload;
   bw_request_t answer;
   bw_request_t request=*(bw_request_t*)payload;
   bw_request_t answer;
-  xbt_error_t errcode;
+  xbt_ex_t e;
   int port;
   
   VERB5("Handshaked to connect to %s:%d (sizes: buf=%lu exp=%lu msg=%lu)",
   int port;
   
   VERB5("Handshaked to connect to %s:%d (sizes: buf=%lu exp=%lu msg=%lu)",
@@ -221,13 +228,17 @@ int amok_bw_cb_bw_handshake(gras_socket_t  expeditor,
   /* Build our answer */
   answer = xbt_new0(s_bw_request_t,1);
   
   /* Build our answer */
   answer = xbt_new0(s_bw_request_t,1);
   
-  for (port = 6000, errcode = system_error;
-       errcode == system_error;
-       errcode = gras_socket_server_ext(++port,request->buf_size,1,&measMasterIn));
-  if (errcode != no_error) {
-    ERROR1("Error %s encountered while opening a measurement server socket", xbt_error_name(errcode));
-    /* FIXME: tell error to remote */
-    return 1;
+  for (port = 6000; port < 10000 && measMasterIn == NULL; port++) {
+    TRY {
+      measMasterIn = gras_socket_server_ext(port,request->buf_size,1);
+    } CATCH(e) {
+      measMasterIn = NULL;
+      if (port < 10000)
+       xbt_ex_free(e);
+      else
+       /* FIXME: tell error to remote */
+       RETHROW0("Error encountered while opening a measurement server socket: %s");
+    }
   }
    
   answer->buf_size=request->buf_size;
   }
    
   answer->buf_size=request->buf_size;
@@ -236,42 +247,39 @@ int amok_bw_cb_bw_handshake(gras_socket_t  expeditor,
   answer->host.port=gras_socket_my_port(measMasterIn);
 
   /* Don't connect asap to leave time to other side to enter the accept() */
   answer->host.port=gras_socket_my_port(measMasterIn);
 
   /* Don't connect asap to leave time to other side to enter the accept() */
-  if ((errcode=gras_socket_client_ext(gras_socket_peer_name(expeditor),
-                                     request->host.port,
-                                     request->buf_size,1,&measOut))) { 
-    ERROR3("Error '%s' encountered while opening a measurement socket back to %s:%d", 
-          xbt_error_name(errcode),gras_socket_peer_name(expeditor),request->host.port);
+  TRY {
+    measOut = gras_socket_client_ext(gras_socket_peer_name(expeditor),
+                                    request->host.port,
+                                    request->buf_size,1);
+  } CATCH(e) {
+    RETHROW2("Error encountered while opening a measurement socket back to %s:%d : %s", 
+            gras_socket_peer_name(expeditor),request->host.port);
     /* FIXME: tell error to remote */
     /* FIXME: tell error to remote */
-    return 1;
   }
 
   }
 
-
-  if ((errcode=gras_msg_send(expeditor,
-                            gras_msgtype_by_name("BW handshake ACK"),
-                            &answer))) {
-    ERROR1("Error %s encountered while sending the answer.",
-           xbt_error_name(errcode));
+  TRY {
+    gras_msg_send(expeditor, gras_msgtype_by_name("BW handshake ACK"), &answer);
+  } CATCH(e) { 
     gras_socket_close(measMasterIn);
     gras_socket_close(measOut);
     /* FIXME: tell error to remote */
     gras_socket_close(measMasterIn);
     gras_socket_close(measOut);
     /* FIXME: tell error to remote */
-    return 1;
+    RETHROW0("Error encountered while sending the answer: %s");
   }
   }
-  TRYOLD(gras_socket_meas_accept(measMasterIn,&measIn));
-  DEBUG4("BW handshake answered. buf_size=%lu exp_size=%lu msg_size=%lu port=%d",
-       answer->buf_size,answer->exp_size,answer->msg_size,answer->host.port);
 
 
-  TRYOLD(gras_socket_meas_recv(measIn, 120,request->exp_size,request->msg_size));
-  TRYOLD(gras_socket_meas_send(measOut,120,1,1));
+  TRY {
+    measIn = gras_socket_meas_accept(measMasterIn);
+    DEBUG4("BW handshake answered. buf_size=%lu exp_size=%lu msg_size=%lu port=%d",
+          answer->buf_size,answer->exp_size,answer->msg_size,answer->host.port);
 
 
-  /*catch
-    ERROR1("Error %s encountered while receiving the experiment.",
-           xbt_error_name(errcode));
+    gras_socket_meas_recv(measIn, 120,request->exp_size,request->msg_size);
+    gras_socket_meas_send(measOut,120,1,1);
+  } CATCH(e) {
     gras_socket_close(measMasterIn);
     gras_socket_close(measIn);
     gras_socket_close(measOut);
     gras_socket_close(measMasterIn);
     gras_socket_close(measIn);
     gras_socket_close(measOut);
-    * FIXME: tell error to remote ? *
-    return 1;
-    }*/
+    /* FIXME: tell error to remote ? */
+    RETHROW0("Error encountered while receiving the experiment: %s");
+  }
 
   if (measIn != measMasterIn)
     gras_socket_close(measMasterIn);
 
   if (measIn != measMasterIn)
     gras_socket_close(measMasterIn);
@@ -311,7 +319,6 @@ xbt_error_t amok_bw_request(const char* from_name,unsigned int from_port,
                            /*OUT*/ double *sec, double*bw) {
   
   gras_socket_t sock;
                            /*OUT*/ double *sec, double*bw) {
   
   gras_socket_t sock;
-  xbt_error_t errcode;
   /* The request */
   bw_request_t request;
   bw_res_t result;
   /* The request */
   bw_request_t request;
   bw_res_t result;
@@ -324,11 +331,11 @@ xbt_error_t amok_bw_request(const char* from_name,unsigned int from_port,
   request->host.name = (char*)to_name;
   request->host.port = to_port;
 
   request->host.name = (char*)to_name;
   request->host.port = to_port;
 
-  TRYOLD(gras_socket_client(from_name,from_port,&sock));
-  TRYOLD(gras_msg_send(sock,gras_msgtype_by_name("BW request"),&request));
+  sock = gras_socket_client(from_name,from_port);
+  gras_msg_send(sock,gras_msgtype_by_name("BW request"),&request);
   free(request);
 
   free(request);
 
-  TRYOLD(gras_msg_wait(240,gras_msgtype_by_name("BW result"),NULL, &result));
+  gras_msg_wait(240,gras_msgtype_by_name("BW result"),NULL, &result);
   
   *sec=result->sec;
   *bw =result->bw;
   
   *sec=result->sec;
   *bw =result->bw;
@@ -345,18 +352,17 @@ xbt_error_t amok_bw_request(const char* from_name,unsigned int from_port,
 int amok_bw_cb_bw_request(gras_socket_t    expeditor,
                          void            *payload) {
                          
 int amok_bw_cb_bw_request(gras_socket_t    expeditor,
                          void            *payload) {
                          
-  xbt_error_t errcode;                   
   /* specification of the test to run, and our answer */
   bw_request_t request = *(bw_request_t*)payload;
   bw_res_t result = xbt_new0(s_bw_res,1);
   gras_socket_t peer;
 
   /* specification of the test to run, and our answer */
   bw_request_t request = *(bw_request_t*)payload;
   bw_res_t result = xbt_new0(s_bw_res,1);
   gras_socket_t peer;
 
-  TRYOLD(gras_socket_client(request->host.name,request->host.port,&peer));
-  TRYOLD(amok_bw_test(peer,
-                  request->buf_size,request->exp_size,request->msg_size,
-                  &(result->sec),&(result->bw)));
+  peer = gras_socket_client(request->host.name,request->host.port);
+  amok_bw_test(peer,
+              request->buf_size,request->exp_size,request->msg_size,
+              &(result->sec),&(result->bw));
 
 
-  TRYOLD(gras_msg_send(expeditor,gras_msgtype_by_name("BW result"),&result));
+  gras_msg_send(expeditor,gras_msgtype_by_name("BW result"),&result);
 
   gras_os_sleep(1);
   gras_socket_close(peer);
 
   gras_os_sleep(1);
   gras_socket_close(peer);
index 1334151..8ecebca 100644 (file)
@@ -10,7 +10,7 @@
 #include "amok/Bandwidth/bandwidth_private.h"
 
 XBT_LOG_EXTERNAL_CATEGORY(bw);
 #include "amok/Bandwidth/bandwidth_private.h"
 
 XBT_LOG_EXTERNAL_CATEGORY(bw);
-XBT_LOG_DEFAULT_CATEGORY(bw);
+/*XBT_LOG_DEFAULT_CATEGORY(bw);*/
 
 #if 0
 /* ***************************************************************************
 
 #if 0
 /* ***************************************************************************
index deeec6a..31bb98f 100644 (file)
@@ -10,7 +10,7 @@
 #include "gras.h"
 #include "amok/base.h"
 
 #include "gras.h"
 #include "amok/base.h"
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(amok,XBT_LOG_ROOT_CAT,"All AMOK categories");
+XBT_LOG_NEW_SUBCATEGORY(amok,XBT_LOG_ROOT_CAT,"All AMOK categories");
 
 amok_remoterr_t amok_remoterr_new(xbt_error_t param_errcode, 
                                  const char* format,...) {
 
 amok_remoterr_t amok_remoterr_new(xbt_error_t param_errcode, 
                                  const char* format,...) {
@@ -51,7 +51,6 @@ void
 amok_repport_error (gras_socket_t sock, gras_msgtype_t msgtype,
                    xbt_error_t param_errcode, const char* format,...) {
   amok_remoterr_t error;
 amok_repport_error (gras_socket_t sock, gras_msgtype_t msgtype,
                    xbt_error_t param_errcode, const char* format,...) {
   amok_remoterr_t error;
-  xbt_error_t errcode;
   va_list ap;
 
   error=xbt_new(s_amok_remoterr_t,1);
   va_list ap;
 
   error=xbt_new(s_amok_remoterr_t,1);
@@ -61,12 +60,14 @@ amok_repport_error (gras_socket_t sock, gras_msgtype_t msgtype,
   vsnprintf(error->msg,1024,format,ap);
   va_end(ap);
 
   vsnprintf(error->msg,1024,format,ap);
   va_end(ap);
 
-  errcode = gras_msg_send(sock,msgtype,error);
+  gras_msg_send(sock,msgtype,error);
+  /* FIXME: error handling while error reporting :-/ 
   if (errcode != no_error) {
      CRITICAL4("Error '%s' while reporting error '%s' to %s:%d",
               xbt_error_name(errcode),error->msg,
               gras_socket_peer_name(sock),gras_socket_peer_port(sock) );
   }
   if (errcode != no_error) {
      CRITICAL4("Error '%s' while reporting error '%s' to %s:%d",
               xbt_error_name(errcode),error->msg,
               gras_socket_peer_name(sock),gras_socket_peer_port(sock) );
   }
+  */
 }
 
 void amok_base_init(void) {
 }
 
 void amok_base_init(void) {
index a9fb374..3077ebd 100644 (file)
@@ -9,6 +9,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "xbt/ex.h"
 #include "gras/DataDesc/datadesc_private.h"
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ddt_cbps,datadesc,"callback persistant state");
 
 #include "gras/DataDesc/datadesc_private.h"
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ddt_cbps,datadesc,"callback persistant state");
 
@@ -26,9 +27,9 @@ typedef struct s_gras_cbps {
   xbt_dynar_t globals;
 } s_gras_cbps_t;
 
   xbt_dynar_t globals;
 } s_gras_cbps_t;
 
-static void free_string(void *d);
+void free_string(void *d);
 
 
-static void free_string(void *d){
+void free_string(void *d){
   free(*(void**)d);
 }
 
   free(*(void**)d);
 }
 
@@ -73,21 +74,25 @@ gras_cbps_v_push(gras_cbps_t          ps,
                 void                *data,
                 gras_datadesc_type_t ddt) {
 
                 void                *data,
                 gras_datadesc_type_t ddt) {
 
-  xbt_dynar_t          varstack,frame;
-  gras_cbps_elm_t       var;
-  xbt_error_t errcode;
-  char *varname = (char*)strdup(name);
+  xbt_dynar_t     varstack,frame;
+  gras_cbps_elm_t var;
+  char           *varname = (char*)strdup(name);
+  xbt_ex_t        e;
 
   DEBUG2("push(%s,%p)",name,(void*)data);
 
   DEBUG2("push(%s,%p)",name,(void*)data);
-  errcode = xbt_dict_get(ps->space, name, (void **)&varstack);
-  if (errcode == mismatch_error) {
-    DEBUG1("Create a new variable stack for '%s' into the space",name);
-    varstack = xbt_dynar_new(sizeof (gras_cbps_elm_t *), NULL);
-    xbt_dict_set(ps->space, varname, (void **)varstack, NULL);
+
+  TRY {
+    varstack = xbt_dict_get(ps->space, name);
+  } CATCH(e) {
+    if (e.category == mismatch_error) {
+      DEBUG1("Create a new variable stack for '%s' into the space",name);
+      varstack = xbt_dynar_new(sizeof (gras_cbps_elm_t *), NULL);
+      xbt_dict_set(ps->space, varname, (void **)varstack, NULL);
+      xbt_ex_free(e);
     /* leaking, you think? only if you do not close all the openned blocks ;)*/
     /* leaking, you think? only if you do not close all the openned blocks ;)*/
-  } else if (errcode != no_error) {
-    return errcode;
+    } else {
+      RETHROW;
+    }
   }
  
   var       = xbt_new0(s_gras_cbps_elm_t,1);
   }
  
   var       = xbt_new0(s_gras_cbps_elm_t,1);
@@ -117,14 +122,18 @@ gras_cbps_v_pop (gras_cbps_t            ps,
   xbt_dynar_t          varstack,frame;
   gras_cbps_elm_t       var            = NULL;
   void                 *data           = NULL;
   xbt_dynar_t          varstack,frame;
   gras_cbps_elm_t       var            = NULL;
   void                 *data           = NULL;
-  xbt_error_t errcode;
+  xbt_ex_t e;
 
   DEBUG1("pop(%s)",name);
 
   DEBUG1("pop(%s)",name);
-  /* FIXME: Error handling */
-  errcode = xbt_dict_get(ps->space, name, (void **)&varstack);
-  if (errcode == mismatch_error) {
-    RAISE1(mismatch_error,"Asked to pop the non-existant %s",
-          name);
+  TRY {
+    varstack = xbt_dict_get(ps->space, name);
+  } CATCH(e) {
+    if (e.category == mismatch_error) {
+      xbt_ex_free(e);
+      THROW1(mismatch_error,1,"Asked to pop the non-existant %s",
+            name);
+    }
+    RETHROW;
   }
   xbt_dynar_pop(varstack, &var);
   
   }
   xbt_dynar_pop(varstack, &var);
   
@@ -136,7 +145,7 @@ gras_cbps_v_pop (gras_cbps_t            ps,
   
   if (ddt)
     *ddt = var->type;  
   
   if (ddt)
     *ddt = var->type;  
-  data    = var->data;
+  data = var->data;
   
   free(var);
   
   
   free(var);
   
@@ -176,14 +185,23 @@ gras_cbps_v_set (gras_cbps_t          ps,
                 void                *data,
                 gras_datadesc_type_t ddt) {
 
                 void                *data,
                 gras_datadesc_type_t ddt) {
 
-  xbt_dynar_t    dynar        = NULL;
-  gras_cbps_elm_t elm          = NULL;
-  xbt_error_t    errcode;
+  xbt_dynar_t dynar = NULL;
+  gras_cbps_elm_t elm = NULL;
+  xbt_ex_t e;
   
   DEBUG1("set(%s)",name);
   
   DEBUG1("set(%s)",name);
-  errcode = xbt_dict_get(ps->space, name, (void **)&dynar);
-  
-  if (errcode == mismatch_error) {
+  TRY {
+    dynar = xbt_dict_get(ps->space, name);
+  } CATCH(e) {
+    if (e.category == mismatch_error) {
+      dynar = NULL;
+      xbt_ex_free(e);
+    } else {
+      RETHROW;
+    }
+  }
+
+  if (dynar == NULL) {
     dynar = xbt_dynar_new(sizeof (gras_cbps_elm_t), NULL);
     xbt_dict_set(ps->space, name, (void **)dynar, NULL);
     
     dynar = xbt_dynar_new(sizeof (gras_cbps_elm_t), NULL);
     xbt_dict_set(ps->space, name, (void **)dynar, NULL);
     
@@ -216,8 +234,7 @@ gras_cbps_v_get (gras_cbps_t           ps,
   gras_cbps_elm_t elm   = NULL;
   
   DEBUG1("get(%s)",name);
   gras_cbps_elm_t elm   = NULL;
   
   DEBUG1("get(%s)",name);
-  /* FIXME: Error handling */
-  xbt_dict_get(ps->space, name, (void **)&dynar);
+  dynar = xbt_dict_get(ps->space, name);
   xbt_dynar_pop(dynar, &elm);
   xbt_dynar_push(dynar, &elm);
   
   xbt_dynar_pop(dynar, &elm);
   xbt_dynar_push(dynar, &elm);
   
@@ -268,7 +285,7 @@ gras_cbps_block_end(gras_cbps_t ps) {
     gras_cbps_elm_t var         = NULL;
  
     DEBUG2("Get ride of %s (%p)",name,(void*)name);
     gras_cbps_elm_t var         = NULL;
  
     DEBUG2("Get ride of %s (%p)",name,(void*)name);
-    xbt_dict_get(ps->space, name, (void **)&varstack);
+    varstack = xbt_dict_get(ps->space, name);
     xbt_dynar_pop(varstack, &var);
  
     if (!xbt_dynar_length(varstack)) {
     xbt_dynar_pop(varstack, &var);
  
     if (!xbt_dynar_length(varstack)) {
index fb7e73d..bef1819 100644 (file)
@@ -14,8 +14,7 @@
 #ifndef GRAS_DATADESC_INTERFACE_H
 #define GRAS_DATADESC_INTERFACE_H
 
 #ifndef GRAS_DATADESC_INTERFACE_H
 #define GRAS_DATADESC_INTERFACE_H
 
-xbt_error_t gras_datadesc_by_id  (long int code,
-                                  gras_datadesc_type_t *type);
+gras_datadesc_type_t gras_datadesc_by_id  (long int code);
 
 /* to debug */
 void gras_datadesc_type_dump(const gras_datadesc_type_t ddt);
 
 /* to debug */
 void gras_datadesc_type_dump(const gras_datadesc_type_t ddt);
@@ -30,8 +29,8 @@ gras_datadesc_type_cmp(const gras_datadesc_type_t d1,
 int  gras_datadesc_size(gras_datadesc_type_t type);
 /* Described data exchanges: direct use */
 xbt_error_t gras_datadesc_cpy(gras_datadesc_type_t type, void *src, void **dst);
 int  gras_datadesc_size(gras_datadesc_type_t type);
 /* Described data exchanges: direct use */
 xbt_error_t gras_datadesc_cpy(gras_datadesc_type_t type, void *src, void **dst);
-xbt_error_t gras_datadesc_send(gras_socket_t sock, gras_datadesc_type_t type, void *src);
-xbt_error_t gras_datadesc_recv(gras_socket_t sock, gras_datadesc_type_t type,
+void gras_datadesc_send(gras_socket_t sock, gras_datadesc_type_t type, void *src);
+void gras_datadesc_recv(gras_socket_t sock, gras_datadesc_type_t type,
                                int r_arch, void *dst);
 
 /* Described data exchanges: IDL compilation */
                                int r_arch, void *dst);
 
 /* Described data exchanges: IDL compilation */
index 5dfcdea..2ab1378 100644 (file)
@@ -10,6 +10,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "xbt/misc.h" /* min()/max() */
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "xbt/misc.h" /* min()/max() */
+#include "xbt/ex.h"
 #include "gras/DataDesc/datadesc_private.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ddt_create,datadesc,"Creating new datadescriptions");
 #include "gras/DataDesc/datadesc_private.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ddt_create,datadesc,"Creating new datadescriptions");
@@ -48,31 +49,26 @@ static gras_datadesc_type_t gras_ddt_new(const char *name) {
 }
 
 /**
 }
 
 /**
- * This returns NULL when no type of this name can be found
+ * This returns NULL no type of this name can be found instead of throwing exceptions which would complicate the GRAS_DEFINE_TYPE macro
  */
 gras_datadesc_type_t gras_datadesc_by_name(const char *name) {
  */
 gras_datadesc_type_t gras_datadesc_by_name(const char *name) {
-
-  gras_datadesc_type_t type;
-
-  XBT_IN1("(%s)",name);
-  if (xbt_set_get_by_name(gras_datadesc_set_local,
-                          name,(xbt_set_elm_t*)&type) == no_error) {
-    XBT_OUT;
-    return type;
-  } else { 
-    XBT_OUT;
-    return NULL;
+  xbt_ex_t e;
+  gras_datadesc_type_t res;
+  TRY {
+    res = (gras_datadesc_type_t)xbt_set_get_by_name(gras_datadesc_set_local,name);
+  } CATCH(e) {
+    if (e.category != mismatch_error)
+      RETHROW;
+    res = NULL;
   }
   }
+  return res;
 }
 
 /**
  * Retrieve a type from its code
  */
 }
 
 /**
  * Retrieve a type from its code
  */
-xbt_error_t gras_datadesc_by_id(long int              code,
-                                gras_datadesc_type_t *type) {
-  XBT_IN;
-  return xbt_set_get_by_id(gras_datadesc_set_local,
-                           code,(xbt_set_elm_t*)type);
+gras_datadesc_type_t gras_datadesc_by_id(long int code) {
+  return (gras_datadesc_type_t)xbt_set_get_by_id(gras_datadesc_set_local,code);
 }
 
 /**
 }
 
 /**
@@ -97,7 +93,7 @@ gras_datadesc_type_t
                 "Redefinition of type %s does not match", name);
     VERB1("Discarding redefinition of %s",name);
     return res;
                 "Redefinition of type %s does not match", name);
     VERB1("Discarding redefinition of %s",name);
     return res;
-  }
+  } 
   res = gras_ddt_new(name);
 
   for (arch = 0; arch < gras_arch_count; arch ++) {
   res = gras_ddt_new(name);
 
   for (arch = 0; arch < gras_arch_count; arch ++) {
@@ -403,6 +399,7 @@ gras_datadesc_type_t
 
   XBT_IN1("(%s)",name);
   res = gras_datadesc_by_name(name);
 
   XBT_IN1("(%s)",name);
   res = gras_datadesc_by_name(name);
+
   if (res) {
     xbt_assert1(res->category_code == e_gras_datadesc_type_cat_ref,
                 "Redefinition of type %s does not match", name);
   if (res) {
     xbt_assert1(res->category_code == e_gras_datadesc_type_cat_ref,
                 "Redefinition of type %s does not match", name);
@@ -624,7 +621,7 @@ gras_datadesc_import_nws(const char           *name,
                         const DataDescriptor *desc,
                         unsigned long         howmany,
               /* OUT */ gras_datadesc_type_t *dst) {
                         const DataDescriptor *desc,
                         unsigned long         howmany,
               /* OUT */ gras_datadesc_type_t *dst) {
-  RAISE_UNIMPLEMENTED;
+  THROW_UNIMPLEMENTED;
 }
 
 /**
 }
 
 /**
index 01eab9e..f72411f 100644 (file)
@@ -9,6 +9,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "xbt/ex.h"
 #include "gras/DataDesc/datadesc_private.h"
 #include "gras/Transport/transport_interface.h" /* gras_trp_chunk_send/recv */
 
 #include "gras/DataDesc/datadesc_private.h"
 #include "gras/Transport/transport_interface.h" /* gras_trp_chunk_send/recv */
 
@@ -21,8 +22,8 @@ const char *gras_datadesc_cat_names[9] = {
 
 static gras_datadesc_type_t int_type = NULL;
 static gras_datadesc_type_t pointer_type = NULL;    
 
 static gras_datadesc_type_t int_type = NULL;
 static gras_datadesc_type_t pointer_type = NULL;    
-static _XBT_INLINE xbt_error_t gras_dd_send_int(gras_socket_t sock,             int  i);
-static _XBT_INLINE xbt_error_t gras_dd_recv_int(gras_socket_t sock, int r_arch, int *i);
+static _XBT_INLINE void gras_dd_send_int(gras_socket_t sock,             int  i);
+static _XBT_INLINE void gras_dd_recv_int(gras_socket_t sock, int r_arch, int *i);
 
 static _XBT_INLINE xbt_error_t
 gras_dd_alloc_ref(xbt_dict_t  refs,  long int     size,
 
 static _XBT_INLINE xbt_error_t
 gras_dd_alloc_ref(xbt_dict_t  refs,  long int     size,
@@ -32,7 +33,7 @@ gras_dd_alloc_ref(xbt_dict_t  refs,  long int     size,
 static _XBT_INLINE int
 gras_dd_is_r_null(char **r_ptr, long int length);
 
 static _XBT_INLINE int
 gras_dd_is_r_null(char **r_ptr, long int length);
 
-static _XBT_INLINE xbt_error_t
+static _XBT_INLINE void
 gras_dd_send_int(gras_socket_t sock,int i) {
 
   if (!int_type) {
 gras_dd_send_int(gras_socket_t sock,int i) {
 
   if (!int_type) {
@@ -41,12 +42,11 @@ gras_dd_send_int(gras_socket_t sock,int i) {
   }
    
   DEBUG1("send_int(%d)",i);
   }
    
   DEBUG1("send_int(%d)",i);
-  return gras_trp_chunk_send(sock, (char*)&i, int_type->size[GRAS_THISARCH]);
+  gras_trp_chunk_send(sock, (char*)&i, int_type->size[GRAS_THISARCH]);
 }
 
 }
 
-static _XBT_INLINE xbt_error_t
+static _XBT_INLINE void
 gras_dd_recv_int(gras_socket_t sock, int r_arch, int *i) {
 gras_dd_recv_int(gras_socket_t sock, int r_arch, int *i) {
-  xbt_error_t errcode;
 
   if (!int_type) {
      int_type = gras_datadesc_by_name("int");
 
   if (!int_type) {
      int_type = gras_datadesc_by_name("int");
@@ -54,20 +54,18 @@ gras_dd_recv_int(gras_socket_t sock, int r_arch, int *i) {
   }
 
   if (int_type->size[GRAS_THISARCH] >= int_type->size[r_arch]) {
   }
 
   if (int_type->size[GRAS_THISARCH] >= int_type->size[r_arch]) {
-    TRYOLD(gras_trp_chunk_recv(sock, (char*)i, int_type->size[r_arch]));
+    gras_trp_chunk_recv(sock, (char*)i, int_type->size[r_arch]);
     if (r_arch != GRAS_THISARCH)
     if (r_arch != GRAS_THISARCH)
-      TRYOLD(gras_dd_convert_elm(int_type,1,r_arch, i,i));
+      gras_dd_convert_elm(int_type,1,r_arch, i,i);
   } else {
     void *ptr = xbt_malloc(int_type->size[r_arch]);
 
   } else {
     void *ptr = xbt_malloc(int_type->size[r_arch]);
 
-    TRYOLD(gras_trp_chunk_recv(sock, (char*)ptr, int_type->size[r_arch]));
+    gras_trp_chunk_recv(sock, (char*)ptr, int_type->size[r_arch]);
     if (r_arch != GRAS_THISARCH)
     if (r_arch != GRAS_THISARCH)
-      TRYOLD(gras_dd_convert_elm(int_type,1,r_arch, ptr,i));
+      gras_dd_convert_elm(int_type,1,r_arch, ptr,i);
     free(ptr);
   }
   DEBUG1("recv_int(%d)",*i);
     free(ptr);
   }
   DEBUG1("recv_int(%d)",*i);
-
-  return no_error;
 }
 
 /*
 }
 
 /*
@@ -128,14 +126,14 @@ gras_dd_alloc_ref(xbt_dict_t  refs,
 xbt_error_t gras_datadesc_cpy(gras_datadesc_type_t type, 
                               void *src, 
                               void **dst) {
 xbt_error_t gras_datadesc_cpy(gras_datadesc_type_t type, 
                               void *src, 
                               void **dst) {
-  RAISE_UNIMPLEMENTED;
+  THROW_UNIMPLEMENTED;
 }
 
 /***
  *** Direct use functions
  ***/
 
 }
 
 /***
  *** Direct use functions
  ***/
 
-static xbt_error_t 
+static void
 gras_datadesc_send_rec(gras_socket_t         sock,
                       gras_cbps_t           state,
                       xbt_dict_t           refs,
 gras_datadesc_send_rec(gras_socket_t         sock,
                       gras_cbps_t           state,
                       xbt_dict_t           refs,
@@ -143,7 +141,7 @@ gras_datadesc_send_rec(gras_socket_t         sock,
                       char                 *data,
                       int                   detect_cycle) {
 
                       char                 *data,
                       int                   detect_cycle) {
 
-  xbt_error_t         errcode;
+  xbt_ex_t             e;
   int                  cpt;
   gras_datadesc_type_t sub_type; /* type on which we recurse */
   
   int                  cpt;
   gras_datadesc_type_t sub_type; /* type on which we recurse */
   
@@ -156,7 +154,7 @@ gras_datadesc_send_rec(gras_socket_t         sock,
 
   switch (type->category_code) {
   case e_gras_datadesc_type_cat_scalar:
 
   switch (type->category_code) {
   case e_gras_datadesc_type_cat_scalar:
-    TRYOLD(gras_trp_chunk_send(sock, data, type->size[GRAS_THISARCH]));
+    gras_trp_chunk_send(sock, data, type->size[GRAS_THISARCH]);
     break;
 
   case e_gras_datadesc_type_cat_struct: {
     break;
 
   case e_gras_datadesc_type_cat_struct: {
@@ -179,8 +177,8 @@ gras_datadesc_send_rec(gras_socket_t         sock,
        field->send(type,state,field_data);
       
       VERB1("Send field %s",field->name);
        field->send(type,state,field_data);
       
       VERB1("Send field %s",field->name);
-      TRYOLD(gras_datadesc_send_rec(sock,state,refs,sub_type, field_data, 
-                                detect_cycle || sub_type->cycle));
+      gras_datadesc_send_rec(sock,state,refs,sub_type, field_data, 
+                            detect_cycle || sub_type->cycle);
       
     }
     VERB1("<< Sent all fields of the structure %s", type->name);
       
     }
     VERB1("<< Sent all fields of the structure %s", type->name);
@@ -210,7 +208,7 @@ gras_datadesc_send_rec(gras_socket_t         sock,
                 type->name, field_num, xbt_dynar_length(union_data.fields));
 
     /* Send the field number */
                 type->name, field_num, xbt_dynar_length(union_data.fields));
 
     /* Send the field number */
-    TRYOLD(gras_dd_send_int(sock, field_num));
+    gras_dd_send_int(sock, field_num);
     
     /* Send the content */
     field = xbt_dynar_get_as(union_data.fields, field_num, gras_dd_cat_field_t);
     
     /* Send the content */
     field = xbt_dynar_get_as(union_data.fields, field_num, gras_dd_cat_field_t);
@@ -219,17 +217,16 @@ gras_datadesc_send_rec(gras_socket_t         sock,
     if (field->send)
       field->send(type,state,data);
     
     if (field->send)
       field->send(type,state,data);
     
-    TRYOLD(gras_datadesc_send_rec(sock,state,refs, sub_type, data, 
-                              detect_cycle || sub_type->cycle));
+    gras_datadesc_send_rec(sock,state,refs, sub_type, data, 
+                          detect_cycle || sub_type->cycle);
           
     break;
   }
     
   case e_gras_datadesc_type_cat_ref: {
     gras_dd_cat_ref_t      ref_data;
           
     break;
   }
     
   case e_gras_datadesc_type_cat_ref: {
     gras_dd_cat_ref_t      ref_data;
-
     void                 **ref=(void**)data;
     void                 **ref=(void**)data;
-    void *dummy;
+    int                    reference_is_to_send;
     
     ref_data = type->category.ref_data;
     
     
     ref_data = type->category.ref_data;
     
@@ -237,7 +234,7 @@ gras_datadesc_send_rec(gras_socket_t         sock,
     sub_type = ref_data.type;
     if (sub_type == NULL) {
       sub_type = (*ref_data.selector)(type,state,data);
     sub_type = ref_data.type;
     if (sub_type == NULL) {
       sub_type = (*ref_data.selector)(type,state,data);
-      TRYOLD(gras_dd_send_int(sock, sub_type->code));
+      gras_dd_send_int(sock, sub_type->code);
     }
     
     /* Send the actual value of the pointer for cycle handling */
     }
     
     /* Send the actual value of the pointer for cycle handling */
@@ -246,29 +243,41 @@ gras_datadesc_send_rec(gras_socket_t         sock,
       xbt_assert(pointer_type);
     }
      
       xbt_assert(pointer_type);
     }
      
-    TRYOLD(gras_trp_chunk_send(sock, (char*)data,
-                           pointer_type->size[GRAS_THISARCH]));
+    gras_trp_chunk_send(sock, (char*)data,
+                       pointer_type->size[GRAS_THISARCH]);
     
     /* Send the pointed data only if not already sent */
     if (*(void**)data == NULL) {
       VERB0("Not sending NULL referenced data");
       break;
     }
     
     /* Send the pointed data only if not already sent */
     if (*(void**)data == NULL) {
       VERB0("Not sending NULL referenced data");
       break;
     }
-    errcode = detect_cycle 
-            ? xbt_dict_get_ext(refs,(char*)ref, sizeof(void*), &dummy)
-            : mismatch_error;
-    if (errcode == mismatch_error) {
+
+    reference_is_to_send = 0;
+    TRY {
+      if (detect_cycle)
+       /* return ignored. Just checking whether it's known or not */
+       xbt_dict_get_ext(refs,(char*)ref, sizeof(void*));
+      else 
+       reference_is_to_send = 1;
+    } CATCH(e) {
+      if (e.category == mismatch_error) {
+       reference_is_to_send = 1;
+       xbt_ex_free(e);
+      } else {
+       RETHROW;
+      }
+    }
+
+    if (reference_is_to_send) {
        VERB1("Sending data referenced at %p", (void*)*ref);
        if (detect_cycle)
         xbt_dict_set_ext(refs, (char*)ref, sizeof(void*), ref, NULL);
        VERB1("Sending data referenced at %p", (void*)*ref);
        if (detect_cycle)
         xbt_dict_set_ext(refs, (char*)ref, sizeof(void*), ref, NULL);
-       TRYOLD(gras_datadesc_send_rec(sock,state,refs, sub_type, *ref, 
-                                 detect_cycle || sub_type->cycle));
+       gras_datadesc_send_rec(sock,state,refs, sub_type, *ref, 
+                             detect_cycle || sub_type->cycle);
          
          
-    } else if (errcode == no_error) {
-       VERB1("Not sending data referenced at %p (already done)", (void*)*ref);
     } else {
     } else {
-       return errcode;
-    }
+       VERB1("Not sending data referenced at %p (already done)", (void*)*ref);
+    } 
     
     break;
   }
     
     break;
   }
@@ -287,7 +296,7 @@ gras_datadesc_send_rec(gras_socket_t         sock,
       count = array_data.dynamic_size(type,state,data);
       xbt_assert1(count >=0,
                   "Invalid (negative) array size for type %s",type->name);
       count = array_data.dynamic_size(type,state,data);
       xbt_assert1(count >=0,
                   "Invalid (negative) array size for type %s",type->name);
-      TRYOLD(gras_dd_send_int(sock, count));
+      gras_dd_send_int(sock, count);
     }
     
     /* send the content */
     }
     
     /* send the content */
@@ -295,21 +304,21 @@ gras_datadesc_send_rec(gras_socket_t         sock,
     elm_size = sub_type->aligned_size[GRAS_THISARCH];
     if (sub_type->category_code == e_gras_datadesc_type_cat_scalar) {
       VERB1("Array of %ld scalars, send it in one shot",count);
     elm_size = sub_type->aligned_size[GRAS_THISARCH];
     if (sub_type->category_code == e_gras_datadesc_type_cat_scalar) {
       VERB1("Array of %ld scalars, send it in one shot",count);
-      TRYOLD(gras_trp_chunk_send(sock, data, 
-                             sub_type->aligned_size[GRAS_THISARCH] * count));
+      gras_trp_chunk_send(sock, data, 
+                         sub_type->aligned_size[GRAS_THISARCH] * count);
     } else if (sub_type->category_code == e_gras_datadesc_type_cat_array &&
               sub_type->category.array_data.fixed_size > 0 &&
               sub_type->category.array_data.type->category_code == e_gras_datadesc_type_cat_scalar) {
        
       VERB1("Array of %ld fixed array of scalars, send it in one shot",count);
     } else if (sub_type->category_code == e_gras_datadesc_type_cat_array &&
               sub_type->category.array_data.fixed_size > 0 &&
               sub_type->category.array_data.type->category_code == e_gras_datadesc_type_cat_scalar) {
        
       VERB1("Array of %ld fixed array of scalars, send it in one shot",count);
-      TRYOLD(gras_trp_chunk_send(sock, data, 
-                             sub_type->category.array_data.type->aligned_size[GRAS_THISARCH] 
-                                * count * sub_type->category.array_data.fixed_size));
+      gras_trp_chunk_send(sock, data, 
+                         sub_type->category.array_data.type->aligned_size[GRAS_THISARCH] 
+                         * count * sub_type->category.array_data.fixed_size);
        
     } else {
       for (cpt=0; cpt<count; cpt++) {
        
     } else {
       for (cpt=0; cpt<count; cpt++) {
-       TRYOLD(gras_datadesc_send_rec(sock,state,refs, sub_type, ptr, 
-                                  detect_cycle || sub_type->cycle));
+       gras_datadesc_send_rec(sock,state,refs, sub_type, ptr, 
+                              detect_cycle || sub_type->cycle);
        ptr += elm_size;
       }
     }
        ptr += elm_size;
       }
     }
@@ -319,8 +328,6 @@ gras_datadesc_send_rec(gras_socket_t         sock,
   default:
     xbt_assert0(0, "Invalid type");
   }
   default:
     xbt_assert0(0, "Invalid type");
   }
-
-  return no_error;
 }
 
 /**
 }
 
 /**
@@ -329,11 +336,11 @@ gras_datadesc_send_rec(gras_socket_t         sock,
  * Copy the data pointed by src and described by type to the socket
  *
  */
  * Copy the data pointed by src and described by type to the socket
  *
  */
-xbt_error_t gras_datadesc_send(gras_socket_t        sock, 
-                               gras_datadesc_type_t type, 
-                               void *src) {
+void gras_datadesc_send(gras_socket_t        sock, 
+                       gras_datadesc_type_t type, 
+                       void *src) {
 
 
-  xbt_error_t errcode;
+  xbt_ex_t e;
   gras_cbps_t  state;
   xbt_dict_t  refs; /* all references already sent */
  
   gras_cbps_t  state;
   xbt_dict_t  refs; /* all references already sent */
  
@@ -342,12 +349,14 @@ xbt_error_t gras_datadesc_send(gras_socket_t        sock,
   refs = xbt_dict_new();
   state = gras_cbps_new();
   
   refs = xbt_dict_new();
   state = gras_cbps_new();
   
-  errcode = gras_datadesc_send_rec(sock,state,refs,type,(char*)src, type->cycle);
-
-  xbt_dict_free(&refs);
-  gras_cbps_free(&state);
-
-  return errcode;
+  TRY {
+    gras_datadesc_send_rec(sock,state,refs,type,(char*)src, type->cycle);
+  } CLEANUP {
+    xbt_dict_free(&refs);
+    gras_cbps_free(&state);
+  } CATCH(e) {
+    RETHROW;
+  }
 }
 
 /**
 }
 
 /**
@@ -362,7 +371,7 @@ xbt_error_t gras_datadesc_send(gras_socket_t        sock,
  * Having this size passed as an argument of the recursive function is a crude
  * hack, but I was told that working code is sometimes better than neat one ;)
  */
  * Having this size passed as an argument of the recursive function is a crude
  * hack, but I was told that working code is sometimes better than neat one ;)
  */
-static xbt_error_t
+static void
 gras_datadesc_recv_rec(gras_socket_t         sock, 
                       gras_cbps_t           state,
                       xbt_dict_t           refs,
 gras_datadesc_recv_rec(gras_socket_t         sock, 
                       gras_cbps_t           state,
                       xbt_dict_t           refs,
@@ -374,9 +383,9 @@ gras_datadesc_recv_rec(gras_socket_t         sock,
                       int                   subsize,
                       int                   detect_cycle) {
 
                       int                   subsize,
                       int                   detect_cycle) {
 
-  xbt_error_t         errcode;
   int                  cpt;
   gras_datadesc_type_t sub_type;
   int                  cpt;
   gras_datadesc_type_t sub_type;
+  xbt_ex_t e;
 
   VERB2("Recv a %s @%p", type->name, (void*)l_data);
   xbt_assert(l_data);
 
   VERB2("Recv a %s @%p", type->name, (void*)l_data);
   xbt_assert(l_data);
@@ -384,15 +393,15 @@ gras_datadesc_recv_rec(gras_socket_t         sock,
   switch (type->category_code) {
   case e_gras_datadesc_type_cat_scalar:
     if (type->size[GRAS_THISARCH] == type->size[r_arch]) {
   switch (type->category_code) {
   case e_gras_datadesc_type_cat_scalar:
     if (type->size[GRAS_THISARCH] == type->size[r_arch]) {
-      TRYOLD(gras_trp_chunk_recv(sock, (char*)l_data, type->size[r_arch]));
+      gras_trp_chunk_recv(sock, (char*)l_data, type->size[r_arch]);
       if (r_arch != GRAS_THISARCH)
       if (r_arch != GRAS_THISARCH)
-       TRYOLD(gras_dd_convert_elm(type,1,r_arch, l_data,l_data));
+       gras_dd_convert_elm(type,1,r_arch, l_data,l_data);
     } else {
       void *ptr = xbt_malloc(type->size[r_arch]);
 
     } else {
       void *ptr = xbt_malloc(type->size[r_arch]);
 
-      TRYOLD(gras_trp_chunk_recv(sock, (char*)ptr, type->size[r_arch]));
+      gras_trp_chunk_recv(sock, (char*)ptr, type->size[r_arch]);
       if (r_arch != GRAS_THISARCH)
       if (r_arch != GRAS_THISARCH)
-       TRYOLD(gras_dd_convert_elm(type,1,r_arch, ptr,l_data));
+       gras_dd_convert_elm(type,1,r_arch, ptr,l_data);
       free(ptr);
     }
     break;
       free(ptr);
     }
     break;
@@ -412,10 +421,10 @@ gras_datadesc_recv_rec(gras_socket_t         sock,
 
       sub_type = field->type;
 
 
       sub_type = field->type;
 
-      TRYOLD(gras_datadesc_recv_rec(sock,state,refs, sub_type,
-                                r_arch,NULL,0,
-                                field_data,-1, 
-                                detect_cycle || sub_type->cycle));
+      gras_datadesc_recv_rec(sock,state,refs, sub_type,
+                            r_arch,NULL,0,
+                            field_data,-1, 
+                            detect_cycle || sub_type->cycle);
        
       if (field->recv)
         field->recv(type,state,(void*)l_data);
        
       if (field->recv)
         field->recv(type,state,(void*)l_data);
@@ -437,23 +446,23 @@ gras_datadesc_recv_rec(gras_socket_t         sock,
                "Please call gras_datadesc_declare_union_close on %s before receiving it",
                type->name);
     /* retrieve the field number */
                "Please call gras_datadesc_declare_union_close on %s before receiving it",
                type->name);
     /* retrieve the field number */
-    TRYOLD(gras_dd_recv_int(sock, r_arch, &field_num));
+    gras_dd_recv_int(sock, r_arch, &field_num);
     if (field_num < 0)
     if (field_num < 0)
-      RAISE1(mismatch_error,
+      THROW1(mismatch_error,0,
             "Received union field for %s is negative", type->name);
     if (field_num < xbt_dynar_length(union_data.fields)) 
             "Received union field for %s is negative", type->name);
     if (field_num < xbt_dynar_length(union_data.fields)) 
-      RAISE3(mismatch_error,
-            "Received union field for %s is %d but there is only %lu fields",
+      THROW3(mismatch_error,0,
+            "Received union field for %s is said to be #%d but there is only %lu fields",
             type->name, field_num, xbt_dynar_length(union_data.fields));
     
     /* Recv the content */
     field = xbt_dynar_get_as(union_data.fields, field_num, gras_dd_cat_field_t);
     sub_type = field->type;
     
             type->name, field_num, xbt_dynar_length(union_data.fields));
     
     /* Recv the content */
     field = xbt_dynar_get_as(union_data.fields, field_num, gras_dd_cat_field_t);
     sub_type = field->type;
     
-    TRYOLD(gras_datadesc_recv_rec(sock,state,refs, sub_type,
-                              r_arch,NULL,0,
-                              l_data,-1,
-                              detect_cycle || sub_type->cycle));
+    gras_datadesc_recv_rec(sock,state,refs, sub_type,
+                          r_arch,NULL,0,
+                          l_data,-1,
+                          detect_cycle || sub_type->cycle);
     if (field->recv)
        field->recv(type,state,l_data);
 
     if (field->recv)
        field->recv(type,state,l_data);
 
@@ -464,6 +473,7 @@ gras_datadesc_recv_rec(gras_socket_t         sock,
     char             **r_ref = NULL;
     char             **l_ref = NULL;
     gras_dd_cat_ref_t  ref_data;
     char             **r_ref = NULL;
     char             **l_ref = NULL;
     gras_dd_cat_ref_t  ref_data;
+    int reference_is_to_recv = 0;
     
     ref_data = type->category.ref_data;
 
     
     ref_data = type->category.ref_data;
 
@@ -471,8 +481,8 @@ gras_datadesc_recv_rec(gras_socket_t         sock,
     sub_type = ref_data.type;
     if (sub_type == NULL) {
       int ref_code;
     sub_type = ref_data.type;
     if (sub_type == NULL) {
       int ref_code;
-      TRYOLD(gras_dd_recv_int(sock, r_arch, &ref_code));
-      TRYOLD(gras_datadesc_by_id(ref_code, &sub_type));
+      gras_dd_recv_int(sock, r_arch, &ref_code);
+      sub_type = gras_datadesc_by_id(ref_code);
     }
 
     /* Get the actual value of the pointer for cycle handling */
     }
 
     /* Get the actual value of the pointer for cycle handling */
@@ -483,8 +493,8 @@ gras_datadesc_recv_rec(gras_socket_t         sock,
 
     r_ref = xbt_malloc(pointer_type->size[r_arch]);
 
 
     r_ref = xbt_malloc(pointer_type->size[r_arch]);
 
-    TRYOLD(gras_trp_chunk_recv(sock, (char*)r_ref,
-                           pointer_type->size[r_arch]));
+    gras_trp_chunk_recv(sock, (char*)r_ref,
+                       pointer_type->size[r_arch]);
 
     /* Receive the pointed data only if not already sent */
     if (gras_dd_is_r_null(r_ref, pointer_type->size[r_arch])) {
 
     /* Receive the pointed data only if not already sent */
     if (gras_dd_is_r_null(r_ref, pointer_type->size[r_arch])) {
@@ -495,61 +505,67 @@ gras_datadesc_recv_rec(gras_socket_t         sock,
       break;
     }
          
       break;
     }
          
-    errcode = detect_cycle
-            ? xbt_dict_get_ext(refs,
-                               (char*)r_ref, pointer_type->size[r_arch],
-                               (void**)&l_ref)
-            : mismatch_error;
-
-    if (errcode == mismatch_error) {
+    reference_is_to_recv = 0;
+    TRY {
+      if (detect_cycle)
+       l_ref = xbt_dict_get_ext(refs, (char*)r_ref, pointer_type->size[r_arch]);
+      else 
+       reference_is_to_recv = 1;
+    } CATCH(e) {
+      if (e.category == mismatch_error) {
+       reference_is_to_recv = 1;
+       xbt_ex_free(e);
+      } else {
+       RETHROW;
+      }
+    }
+    if (reference_is_to_recv) {
       int subsubcount = 0;
       void *l_referenced=NULL;
 
       VERB2("Receiving a ref to '%s', remotely @%p",
            sub_type->name, *(void**)r_ref);
       if (sub_type->category_code == e_gras_datadesc_type_cat_array) {
       int subsubcount = 0;
       void *l_referenced=NULL;
 
       VERB2("Receiving a ref to '%s', remotely @%p",
            sub_type->name, *(void**)r_ref);
       if (sub_type->category_code == e_gras_datadesc_type_cat_array) {
-       /* Damn. Reference to a dynamic array. Allocating the size for it 
+       /* Damn. Reference to a dynamic array. Allocating the space for it 
           is more complicated */
        gras_dd_cat_array_t array_data = sub_type->category.array_data;
        gras_datadesc_type_t subsub_type;
 
        subsubcount = array_data.fixed_size;
        if (subsubcount == 0)
           is more complicated */
        gras_dd_cat_array_t array_data = sub_type->category.array_data;
        gras_datadesc_type_t subsub_type;
 
        subsubcount = array_data.fixed_size;
        if (subsubcount == 0)
-         TRYOLD(gras_dd_recv_int(sock, r_arch, &subsubcount));
+         gras_dd_recv_int(sock, r_arch, &subsubcount);
 
        subsub_type = array_data.type;
 
 
 
        subsub_type = array_data.type;
 
 
-       TRYOLD(gras_dd_alloc_ref(refs,
-                             subsub_type->size[GRAS_THISARCH] * subsubcount, 
-                             r_ref,pointer_type->size[r_arch], 
-                             (char**)&l_referenced,
-                             detect_cycle));
+       gras_dd_alloc_ref(refs,
+                         subsub_type->size[GRAS_THISARCH] * subsubcount, 
+                         r_ref,pointer_type->size[r_arch], 
+                         (char**)&l_referenced,
+                         detect_cycle);
       } else {
       } else {
-       TRYOLD(gras_dd_alloc_ref(refs,sub_type->size[GRAS_THISARCH], 
-                             r_ref,pointer_type->size[r_arch], 
-                             (char**)&l_referenced,
-                             detect_cycle));
+       gras_dd_alloc_ref(refs,sub_type->size[GRAS_THISARCH], 
+                         r_ref,pointer_type->size[r_arch], 
+                         (char**)&l_referenced,
+                         detect_cycle);
       }
 
       }
 
-      TRYOLD(gras_datadesc_recv_rec(sock,state,refs, sub_type,
-                                r_arch,r_ref,pointer_type->size[r_arch],
-                                (char*)l_referenced, subsubcount,
-                                detect_cycle || sub_type->cycle));
+      gras_datadesc_recv_rec(sock,state,refs, sub_type,
+                            r_arch,r_ref,pointer_type->size[r_arch],
+                            (char*)l_referenced, subsubcount,
+                            detect_cycle || sub_type->cycle);
                               
       *(void**)l_data=l_referenced;
       VERB3("'%s' remotely referenced at %p locally at %p",
            sub_type->name, *(void**)r_ref, l_referenced);
       
                               
       *(void**)l_data=l_referenced;
       VERB3("'%s' remotely referenced at %p locally at %p",
            sub_type->name, *(void**)r_ref, l_referenced);
       
-    } else if (errcode == no_error) {
+    } else {
       VERB2("NOT receiving data remotely referenced @%p (already done, @%p here)",
            *(void**)r_ref, *(void**)l_ref);
 
       *(void**)l_data=*l_ref;
 
       VERB2("NOT receiving data remotely referenced @%p (already done, @%p here)",
            *(void**)r_ref, *(void**)l_ref);
 
       *(void**)l_data=*l_ref;
 
-    } else {
-      return errcode;
-    }
+    } 
     free(r_ref);
     break;
   }
     free(r_ref);
     break;
   }
@@ -566,9 +582,9 @@ gras_datadesc_recv_rec(gras_socket_t         sock,
     if (count == 0)
       count = subsize;
     if (count == 0)
     if (count == 0)
       count = subsize;
     if (count == 0)
-      TRYOLD(gras_dd_recv_int(sock, r_arch, &count));
+      gras_dd_recv_int(sock, r_arch, &count);
     if (count == 0)
     if (count == 0)
-      RAISE1(mismatch_error,
+      THROW1(mismatch_error,0,
             "Invalid (=0) array size for type %s",type->name);
 
     /* receive the content */
             "Invalid (=0) array size for type %s",type->name);
 
     /* receive the content */
@@ -577,17 +593,17 @@ gras_datadesc_recv_rec(gras_socket_t         sock,
       VERB1("Array of %d scalars, get it in one shoot", count);
       if (sub_type->aligned_size[GRAS_THISARCH] >= 
          sub_type->aligned_size[r_arch]) {
       VERB1("Array of %d scalars, get it in one shoot", count);
       if (sub_type->aligned_size[GRAS_THISARCH] >= 
          sub_type->aligned_size[r_arch]) {
-       TRYOLD(gras_trp_chunk_recv(sock, (char*)l_data, 
-                               sub_type->aligned_size[r_arch] * count));
+       gras_trp_chunk_recv(sock, (char*)l_data, 
+                           sub_type->aligned_size[r_arch] * count);
        if (r_arch != GRAS_THISARCH)
        if (r_arch != GRAS_THISARCH)
-         TRYOLD(gras_dd_convert_elm(sub_type,count,r_arch, l_data,l_data));
+         gras_dd_convert_elm(sub_type,count,r_arch, l_data,l_data);
       } else {
        ptr = xbt_malloc(sub_type->aligned_size[r_arch] * count);
 
       } else {
        ptr = xbt_malloc(sub_type->aligned_size[r_arch] * count);
 
-       TRYOLD(gras_trp_chunk_recv(sock, (char*)ptr, 
-                               sub_type->size[r_arch] * count));
+       gras_trp_chunk_recv(sock, (char*)ptr, 
+                           sub_type->size[r_arch] * count);
        if (r_arch != GRAS_THISARCH)
        if (r_arch != GRAS_THISARCH)
-         TRYOLD(gras_dd_convert_elm(sub_type,count,r_arch, ptr,l_data));
+         gras_dd_convert_elm(sub_type,count,r_arch, ptr,l_data);
        free(ptr);
       }
     } else if (sub_type->category_code == e_gras_datadesc_type_cat_array &&
        free(ptr);
       }
     } else if (sub_type->category_code == e_gras_datadesc_type_cat_array &&
@@ -600,18 +616,18 @@ gras_datadesc_recv_rec(gras_socket_t         sock,
       VERB1("Array of %d fixed array of scalars, get it in one shot",count);
       if (subsub_type->aligned_size[GRAS_THISARCH] >= 
          subsub_type->aligned_size[r_arch]) {
       VERB1("Array of %d fixed array of scalars, get it in one shot",count);
       if (subsub_type->aligned_size[GRAS_THISARCH] >= 
          subsub_type->aligned_size[r_arch]) {
-       TRYOLD(gras_trp_chunk_recv(sock, (char*)l_data, 
-                               subsub_type->aligned_size[r_arch] * count * 
-                                 array_data.fixed_size));
+       gras_trp_chunk_recv(sock, (char*)l_data, 
+                           subsub_type->aligned_size[r_arch] * count * 
+                           array_data.fixed_size);
        if (r_arch != GRAS_THISARCH)
        if (r_arch != GRAS_THISARCH)
-         TRYOLD(gras_dd_convert_elm(subsub_type,count*array_data.fixed_size,r_arch, l_data,l_data));
+         gras_dd_convert_elm(subsub_type,count*array_data.fixed_size,r_arch, l_data,l_data);
       } else {
        ptr = xbt_malloc(subsub_type->aligned_size[r_arch] * count*array_data.fixed_size);
 
       } else {
        ptr = xbt_malloc(subsub_type->aligned_size[r_arch] * count*array_data.fixed_size);
 
-       TRYOLD(gras_trp_chunk_recv(sock, (char*)ptr, 
-                               subsub_type->size[r_arch] * count*array_data.fixed_size));
+       gras_trp_chunk_recv(sock, (char*)ptr, 
+                           subsub_type->size[r_arch] * count*array_data.fixed_size);
        if (r_arch != GRAS_THISARCH)
        if (r_arch != GRAS_THISARCH)
-         TRYOLD(gras_dd_convert_elm(subsub_type,count*array_data.fixed_size,r_arch, ptr,l_data));
+         gras_dd_convert_elm(subsub_type,count*array_data.fixed_size,r_arch, ptr,l_data);
        free(ptr);
       }
       
        free(ptr);
       }
       
@@ -623,9 +639,9 @@ gras_datadesc_recv_rec(gras_socket_t         sock,
 
       ptr = l_data;
       for (cpt=0; cpt<count; cpt++) {
 
       ptr = l_data;
       for (cpt=0; cpt<count; cpt++) {
-       TRYOLD(gras_datadesc_recv_rec(sock,state,refs, sub_type,
-                                  r_arch, NULL, 0, ptr,-1,
-                                  detect_cycle || sub_type->cycle));
+       gras_datadesc_recv_rec(sock,state,refs, sub_type,
+                              r_arch, NULL, 0, ptr,-1,
+                              detect_cycle || sub_type->cycle);
                                   
        ptr += elm_size;
       }
                                   
        ptr += elm_size;
       }
@@ -640,7 +656,6 @@ gras_datadesc_recv_rec(gras_socket_t         sock,
   if (type->recv)
     type->recv(type,state,l_data);
 
   if (type->recv)
     type->recv(type,state,l_data);
 
-  return no_error;
 }
 
 /**
 }
 
 /**
@@ -650,13 +665,13 @@ gras_datadesc_recv_rec(gras_socket_t         sock,
  * and store a pointer to it in @dst
  *
  */
  * and store a pointer to it in @dst
  *
  */
-xbt_error_t
+void
 gras_datadesc_recv(gras_socket_t         sock, 
                   gras_datadesc_type_t  type,
                   int                   r_arch,
                   void                 *dst) {
 
 gras_datadesc_recv(gras_socket_t         sock, 
                   gras_datadesc_type_t  type,
                   int                   r_arch,
                   void                 *dst) {
 
-  xbt_error_t errcode;
+  xbt_ex_t e;
   gras_cbps_t  state; /* callback persistent state */
   xbt_dict_t  refs;  /* all references already sent */
 
   gras_cbps_t  state; /* callback persistent state */
   xbt_dict_t  refs;  /* all references already sent */
 
@@ -664,15 +679,17 @@ gras_datadesc_recv(gras_socket_t         sock,
   state = gras_cbps_new();
 
   xbt_assert0(type,"called with NULL type descriptor");
   state = gras_cbps_new();
 
   xbt_assert0(type,"called with NULL type descriptor");
-  errcode = gras_datadesc_recv_rec(sock, state, refs, type, 
-                                  r_arch, NULL, 0,
-                                  (char *) dst,-1, 
-                                  type->cycle);
-
-  xbt_dict_free(&refs);
-  gras_cbps_free(&state);
-
-  return errcode;
+  TRY {
+    gras_datadesc_recv_rec(sock, state, refs, type, 
+                          r_arch, NULL, 0,
+                          (char *) dst,-1, 
+                          type->cycle);
+  } CLEANUP {
+    xbt_dict_free(&refs);
+    gras_cbps_free(&state);
+  } CATCH(e) {
+    RETHROW;
+  }
 }
 
 #if 0
 }
 
 #if 0
index d1a495e..b2a42e7 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <ctype.h> /* isdigit */
 
 
 #include <ctype.h> /* isdigit */
 
+#include "xbt/ex.h"
 #include "gras/DataDesc/datadesc_private.h"
 #include "gras/DataDesc/ddt_parse.yy.h"
 
 #include "gras/DataDesc/datadesc_private.h"
 #include "gras/DataDesc/ddt_parse.yy.h"
 
@@ -89,6 +90,7 @@ static void parse_type_modifier(type_modifier_t type_modifier)  {
   XBT_OUT;
 }
 
   XBT_OUT;
 }
 
+static void print_type_modifier(s_type_modifier_t tm) __attribute__((unused));
 static void print_type_modifier(s_type_modifier_t tm) {
   int i;
 
 static void print_type_modifier(s_type_modifier_t tm) {
   int i;
 
@@ -177,7 +179,7 @@ static xbt_error_t parse_statement(char      *definition,
   gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
   if(gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_RA) {
     XBT_OUT;
   gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
   if(gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_RA) {
     XBT_OUT;
-    return mismatch_error; /* end of the englobing structure or union */
+    return old_mismatch_error; /* end of the englobing structure or union */
   }
   
   if (XBT_LOG_ISENABLED(ddt_parse,xbt_log_priority_debug)) {
   }
   
   if (XBT_LOG_ISENABLED(ddt_parse,xbt_log_priority_debug)) {
@@ -252,7 +254,7 @@ static xbt_error_t parse_statement(char      *definition,
       identifier.type = gras_datadesc_by_name("unsigned char");
 
     } else { /* impossible, gcc parses this shit before us */
       identifier.type = gras_datadesc_by_name("unsigned char");
 
     } else { /* impossible, gcc parses this shit before us */
-      RAISE_IMPOSSIBLE;
+      THROW_IMPOSSIBLE;
     }
     
   } else if (!strcmp(identifier.type_name, "float")) {
     }
     
   } else if (!strcmp(identifier.type_name, "float")) {
@@ -397,7 +399,7 @@ static xbt_error_t parse_statement(char      *definition,
              continue;
            }
          }
              continue;
            }
          }
-         RAISE_IMPOSSIBLE;
+         THROW_IMPOSSIBLE;
 
        } else {
          PARSE_ERROR1("Unknown annotation type: '%s'",keyname);
 
        } else {
          PARSE_ERROR1("Unknown annotation type: '%s'",keyname);
@@ -615,5 +617,3 @@ gras_datadesc_parse(const char            *name,
   XBT_OUT;
   return res;
 }
   XBT_OUT;
   return res;
 }
-
-
index 485f981..e326df1 100644 (file)
@@ -486,7 +486,9 @@ char *gras_ddt_parse_text;
 /* Copyright (c) 2004 Arnaud Legrand, Martin Quinson. All rights reserved.  */
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 /* Copyright (c) 2004 Arnaud Legrand, Martin Quinson. All rights reserved.  */
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
-#line 12 "gras/DataDesc/ddt_parse.yy.l"
+/*   char string_buf[GRAS_DDT_PARSE_MAX_STR_CONST];
+     char *string_buf_ptr = NULL; FIXME; killme*/
+#line 15 "gras/DataDesc/ddt_parse.yy.l"
 #include "gras/DataDesc/datadesc_private.h"
 #include "gras/DataDesc/ddt_parse.yy.h"
 #include <string.h>
 #include "gras/DataDesc/datadesc_private.h"
 #include "gras/DataDesc/ddt_parse.yy.h"
 #include <string.h>
@@ -501,7 +503,7 @@ char *gras_ddt_parse_text;
   XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lexer,ddt_parse,"The crude internals of the lexer used for type parsing");
 #define SHOW_WHERE DEBUG4("%d:%d (char #%d): seen '%s'", gras_ddt_parse_line_pos,gras_ddt_parse_col_pos,gras_ddt_parse_char_pos,gras_ddt_parse_text)
 
   XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lexer,ddt_parse,"The crude internals of the lexer used for type parsing");
 #define SHOW_WHERE DEBUG4("%d:%d (char #%d): seen '%s'", gras_ddt_parse_line_pos,gras_ddt_parse_col_pos,gras_ddt_parse_char_pos,gras_ddt_parse_text)
 
-#line 505 "gras/DataDesc/ddt_parse.yy.c"
+#line 507 "gras/DataDesc/ddt_parse.yy.c"
 
 #define INITIAL 0
 #define annotate 1
 
 #define INITIAL 0
 #define annotate 1
@@ -655,15 +657,12 @@ YY_DECL
        register char *yy_cp, *yy_bp;
        register int yy_act;
     
        register char *yy_cp, *yy_bp;
        register int yy_act;
     
-#line 32 "gras/DataDesc/ddt_parse.yy.l"
+#line 35 "gras/DataDesc/ddt_parse.yy.l"
 
    int comment_caller=0;
    int annotate_caller=0;
 
 
    int comment_caller=0;
    int annotate_caller=0;
 
-   char string_buf[GRAS_DDT_PARSE_MAX_STR_CONST];
-   char *string_buf_ptr = NULL;
-
-#line 667 "gras/DataDesc/ddt_parse.yy.c"
+#line 666 "gras/DataDesc/ddt_parse.yy.c"
 
        if ( (yy_init) )
                {
 
        if ( (yy_init) )
                {
@@ -982,7 +981,7 @@ YY_RULE_SETUP
 #line 175 "gras/DataDesc/ddt_parse.yy.l"
 ECHO;
        YY_BREAK
 #line 175 "gras/DataDesc/ddt_parse.yy.l"
 ECHO;
        YY_BREAK
-#line 986 "gras/DataDesc/ddt_parse.yy.c"
+#line 985 "gras/DataDesc/ddt_parse.yy.c"
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(annotate):
 case YY_STATE_EOF(comment):
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(annotate):
 case YY_STATE_EOF(comment):
@@ -2014,6 +2013,9 @@ void  gras_ddt_parse_pointer_string_close(void) {
   gras_ddt_parse_line_pos = 1;
   gras_ddt_parse_char_pos = 0;
   gras_ddt_parse_tok_num = 0;
   gras_ddt_parse_line_pos = 1;
   gras_ddt_parse_char_pos = 0;
   gras_ddt_parse_tok_num = 0;
+
+  if (0)
+    yyunput('\0',NULL); /* fake a use of this function to calm gcc down */
 }
 
 /* Local variables:*/
 }
 
 /* Local variables:*/
index e27f818..35a9c22 100644 (file)
@@ -7,6 +7,9 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+/*   char string_buf[GRAS_DDT_PARSE_MAX_STR_CONST];
+     char *string_buf_ptr = NULL; FIXME; killme*/
+
 %option noyywrap
 %{
 #include "gras/DataDesc/datadesc_private.h"
 %option noyywrap
 %{
 #include "gras/DataDesc/datadesc_private.h"
@@ -33,9 +36,6 @@ digit           [0-9]
    int comment_caller=0;
    int annotate_caller=0;
 
    int comment_caller=0;
    int annotate_caller=0;
 
-   char string_buf[GRAS_DDT_PARSE_MAX_STR_CONST];
-   char *string_buf_ptr = NULL;
-
 "//"[^\n]*
 
 "/*g"{space}* { /****************** ANNOTATION ************************/
 "//"[^\n]*
 
 "/*g"{space}* { /****************** ANNOTATION ************************/
@@ -233,6 +233,9 @@ void  gras_ddt_parse_pointer_string_close(void) {
   gras_ddt_parse_line_pos = 1;
   gras_ddt_parse_char_pos = 0;
   gras_ddt_parse_tok_num = 0;
   gras_ddt_parse_line_pos = 1;
   gras_ddt_parse_char_pos = 0;
   gras_ddt_parse_tok_num = 0;
+
+  if (0)
+    yyunput('\0',NULL); /* fake a use of this function to calm gcc down */
 }
 
 /* Local variables:*/
 }
 
 /* Local variables:*/
index c37b634..88d443f 100644 (file)
@@ -7,7 +7,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-
+#include "xbt/ex.h"
 #include "gras/Msg/msg_private.h"
 #include "gras/DataDesc/datadesc_interface.h"
 #include "gras/Transport/transport_interface.h" /* gras_trp_chunk_send/recv */
 #include "gras/Msg/msg_private.h"
 #include "gras/DataDesc/datadesc_interface.h"
 #include "gras/Transport/transport_interface.h" /* gras_trp_chunk_send/recv */
@@ -138,14 +138,21 @@ gras_msgtype_declare_v(const char           *name,
                       short int             version,
                       gras_datadesc_type_t  payload) {
  
                       short int             version,
                       gras_datadesc_type_t  payload) {
  
-  xbt_error_t   errcode;
   gras_msgtype_t msgtype;
   char *namev=make_namev(name,version);
   gras_msgtype_t msgtype;
   char *namev=make_namev(name,version);
-      
-  errcode = xbt_set_get_by_name(_gras_msgtype_set,
-                                namev,(xbt_set_elm_t*)&msgtype);
+  int found = 0;
+  xbt_ex_t e;    
+  
+  TRY {
+    msgtype = (gras_msgtype_t)xbt_set_get_by_name(_gras_msgtype_set,namev);
+    found = 1;
+  } CATCH(e) {
+    if (e.category != mismatch_error)
+      RETHROW;
+    xbt_ex_free(e);
+  }
 
 
-  if (errcode == no_error) {
+  if (found) {
     VERB2("Re-register version %d of message '%s' (same payload, ignored).",
          version, name);
     xbt_assert3(!gras_datadesc_type_cmp(msgtype->ctn_type, payload),
     VERB2("Re-register version %d of message '%s' (same payload, ignored).",
          version, name);
     xbt_assert3(!gras_datadesc_type_cmp(msgtype->ctn_type, payload),
@@ -156,7 +163,7 @@ gras_msgtype_declare_v(const char           *name,
     return ; /* do really ignore it */
 
   }
     return ; /* do really ignore it */
 
   }
-  xbt_assert_error(mismatch_error); /* expect this error */
+
   VERB3("Register version %d of message '%s' (payload: %s).", 
        version, name, gras_datadesc_get_name(payload));    
 
   VERB3("Register version %d of message '%s' (payload: %s).", 
        version, name, gras_datadesc_get_name(payload));    
 
@@ -179,16 +186,9 @@ gras_msgtype_t gras_msgtype_by_name (const char *name) {
 gras_msgtype_t gras_msgtype_by_namev(const char      *name,
                                     short int        version) {
   gras_msgtype_t res;
 gras_msgtype_t gras_msgtype_by_namev(const char      *name,
                                     short int        version) {
   gras_msgtype_t res;
-
-  xbt_error_t errcode;
   char *namev = make_namev(name,version); 
 
   char *namev = make_namev(name,version); 
 
-  errcode = xbt_set_get_by_name(_gras_msgtype_set, namev,
-                                (xbt_set_elm_t*)&res);
-  if (errcode != no_error)
-    res = NULL;
-  if (!res) 
-     WARN1("msgtype_by_name(%s) returns NULL",namev);
+  res = (gras_msgtype_t)xbt_set_get_by_name(_gras_msgtype_set, namev);
   if (name != namev) 
     free(namev);
   
   if (name != namev) 
     free(namev);
   
@@ -197,16 +197,15 @@ gras_msgtype_t gras_msgtype_by_namev(const char      *name,
 
 /** \brief Send the data pointed by \a payload as a message of type
  * \a msgtype to the peer \a sock */
 
 /** \brief Send the data pointed by \a payload as a message of type
  * \a msgtype to the peer \a sock */
-xbt_error_t
+void
 gras_msg_send(gras_socket_t   sock,
              gras_msgtype_t  msgtype,
              void           *payload) {
 
 gras_msg_send(gras_socket_t   sock,
              gras_msgtype_t  msgtype,
              void           *payload) {
 
-  xbt_error_t errcode;
   static gras_datadesc_type_t string_type=NULL;
 
   if (!msgtype)
   static gras_datadesc_type_t string_type=NULL;
 
   if (!msgtype)
-    RAISE0(mismatch_error,
+    THROW0(mismatch_error,0,
           "Cannot send the NULL message (did msgtype_by_name fail?)");
 
   if (!string_type) {
           "Cannot send the NULL message (did msgtype_by_name fail?)");
 
   if (!string_type) {
@@ -216,25 +215,23 @@ gras_msg_send(gras_socket_t   sock,
 
   DEBUG3("send '%s' to %s:%d", msgtype->name, 
         gras_socket_peer_name(sock),gras_socket_peer_port(sock));
 
   DEBUG3("send '%s' to %s:%d", msgtype->name, 
         gras_socket_peer_name(sock),gras_socket_peer_port(sock));
-  TRYOLD(gras_trp_chunk_send(sock, GRAS_header, 6));
+  gras_trp_chunk_send(sock, GRAS_header, 6);
 
 
-  TRYOLD(gras_datadesc_send(sock, string_type,   &msgtype->name));
+  gras_datadesc_send(sock, string_type,   &msgtype->name);
   if (msgtype->ctn_type)
   if (msgtype->ctn_type)
-    TRYOLD(gras_datadesc_send(sock, msgtype->ctn_type, payload));
-  TRYOLD(gras_trp_flush(sock));
-
-  return no_error;
+    gras_datadesc_send(sock, msgtype->ctn_type, payload);
+  gras_trp_flush(sock);
 }
 /*
  * receive the next message on the given socket.  
  */
 }
 /*
  * receive the next message on the given socket.  
  */
-xbt_error_t
+void
 gras_msg_recv(gras_socket_t    sock,
              gras_msgtype_t  *msgtype,
              void           **payload,
              int             *payload_size) {
 
 gras_msg_recv(gras_socket_t    sock,
              gras_msgtype_t  *msgtype,
              void           **payload,
              int             *payload_size) {
 
-  xbt_error_t errcode;
+  xbt_ex_t e;
   static gras_datadesc_type_t string_type=NULL;
   char header[6];
   int cpt;
   static gras_datadesc_type_t string_type=NULL;
   char header[6];
   int cpt;
@@ -248,28 +245,33 @@ gras_msg_recv(gras_socket_t    sock,
     xbt_assert(string_type);
   }
   
     xbt_assert(string_type);
   }
   
-  errcode=gras_trp_chunk_recv(sock, header, 6);
-  if (errcode!=no_error)
-    RAISE2(errcode,"Got '%s' while trying to get the mesage header on socket %p",
-          xbt_error_name(errcode),sock);
+  TRY {
+    gras_trp_chunk_recv(sock, header, 6);
+  } CATCH(e) {
+    THROW2(e.category,e.value,
+          "Exception caught while trying to get the mesage header on socket %p : %s",
+          sock,e.msg);
+  }
+
   for (cpt=0; cpt<4; cpt++)
     if (header[cpt] != GRAS_header[cpt])
   for (cpt=0; cpt<4; cpt++)
     if (header[cpt] != GRAS_header[cpt])
-      RAISE2(mismatch_error,"Incoming bytes do not look like a GRAS message (header='%.4s' not '%.4s')",header,GRAS_header);
+      THROW2(mismatch_error,0,
+            "Incoming bytes do not look like a GRAS message (header='%.4s' not '%.4s')",header,GRAS_header);
   if (header[4] != GRAS_header[4]) 
   if (header[4] != GRAS_header[4]) 
-    RAISE2(mismatch_error,"GRAS protocol mismatch (got %d, use %d)",
+    THROW2(mismatch_error,0,"GRAS protocol mismatch (got %d, use %d)",
           (int)header[4], (int)GRAS_header[4]);
   r_arch = (int)header[5];
   DEBUG2("Handle an incoming message using protocol %d (remote is %s)",
         (int)header[4],gras_datadesc_arch_name(r_arch));
 
           (int)header[4], (int)GRAS_header[4]);
   r_arch = (int)header[5];
   DEBUG2("Handle an incoming message using protocol %d (remote is %s)",
         (int)header[4],gras_datadesc_arch_name(r_arch));
 
-  TRYOLD(gras_datadesc_recv(sock, string_type, r_arch, &msg_name));
-  errcode = xbt_set_get_by_name(_gras_msgtype_set,
-                                msg_name,(xbt_set_elm_t*)msgtype);
-  if (errcode != no_error)
-    RAISE2(errcode,
-          "Got error %s while retrieving the type associated to messages '%s'",
-          xbt_error_name(errcode),msg_name);
-  /* FIXME: Survive unknown messages */
+  gras_datadesc_recv(sock, string_type, r_arch, &msg_name);
+  TRY {
+    *msgtype = (gras_msgtype_t)xbt_set_get_by_name(_gras_msgtype_set,msg_name);
+  } CATCH(e) {
+    /* FIXME: Survive unknown messages */
+    RETHROW1("Exception caught while retrieving the type associated to messages '%s' : %s",
+            msg_name);
+  }
   free(msg_name);
 
   if ((*msgtype)->ctn_type) {
   free(msg_name);
 
   if ((*msgtype)->ctn_type) {
@@ -279,12 +281,11 @@ gras_msg_recv(gras_socket_t    sock,
                "Dynamic array as payload is forbided for now (FIXME?).",
                "Reference to dynamic array is allowed.");
     *payload = xbt_malloc(*payload_size);
                "Dynamic array as payload is forbided for now (FIXME?).",
                "Reference to dynamic array is allowed.");
     *payload = xbt_malloc(*payload_size);
-    TRYOLD(gras_datadesc_recv(sock, (*msgtype)->ctn_type, r_arch, *payload));
+    gras_datadesc_recv(sock, (*msgtype)->ctn_type, r_arch, *payload);
   } else {
     *payload = NULL;
     *payload_size = 0;
   }
   } else {
     *payload = NULL;
     *payload_size = 0;
   }
-  return no_error;
 }
 
 /** \brief Waits for a message to come in over a given socket. 
 }
 
 /** \brief Waits for a message to come in over a given socket. 
@@ -298,7 +299,7 @@ gras_msg_recv(gras_socket_t    sock,
  * Every message of another type received before the one waited will be queued
  * and used by subsequent call to this function or gras_msg_handle().
  */
  * Every message of another type received before the one waited will be queued
  * and used by subsequent call to this function or gras_msg_handle().
  */
-xbt_error_t
+void
 gras_msg_wait(double           timeout,    
              gras_msgtype_t   msgt_want,
              gras_socket_t   *expeditor,
 gras_msg_wait(double           timeout,    
              gras_msgtype_t   msgt_want,
              gras_socket_t   *expeditor,
@@ -307,7 +308,6 @@ gras_msg_wait(double           timeout,
   gras_msgtype_t msgt_got;
   void *payload_got;
   int payload_size_got;
   gras_msgtype_t msgt_got;
   void *payload_got;
   int payload_size_got;
-  xbt_error_t errcode;
   double start, now;
   gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_get("gras_msg");
   int cpt;
   double start, now;
   gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_get("gras_msg");
   int cpt;
@@ -316,9 +316,7 @@ gras_msg_wait(double           timeout,
   
   payload_got = NULL;
 
   
   payload_got = NULL;
 
-  if (!msgt_want)
-    RAISE0(mismatch_error,
-          "Cannot wait for the NULL message (did msgtype_by_name fail?)");
+  xbt_assert0(msgt_want,"Cannot wait for the NULL message");
 
   VERB1("Waiting for message '%s'",msgt_want->name);
 
 
   VERB1("Waiting for message '%s'",msgt_want->name);
 
@@ -332,20 +330,20 @@ gras_msg_wait(double           timeout,
       free(msg.payload);
       xbt_dynar_cursor_rm(pd->msg_queue, &cpt);
       VERB0("The waited message was queued");
       free(msg.payload);
       xbt_dynar_cursor_rm(pd->msg_queue, &cpt);
       VERB0("The waited message was queued");
-      return no_error;
+      return;
     }
   }
 
   while (1) {
     }
   }
 
   while (1) {
-    TRYOLD(gras_trp_select(timeout - now + start, &expeditor_res));
-    TRYOLD(gras_msg_recv(expeditor_res, &msgt_got, &payload_got, &payload_size_got));
+    expeditor_res = gras_trp_select(timeout - now + start);
+    gras_msg_recv(expeditor_res, &msgt_got, &payload_got, &payload_size_got);
     if (msgt_got->code == msgt_want->code) {
       if (expeditor)
        *expeditor=expeditor_res;
       memcpy(payload, payload_got, payload_size_got);
       free(payload_got);
       VERB0("Got waited message");
     if (msgt_got->code == msgt_want->code) {
       if (expeditor)
        *expeditor=expeditor_res;
       memcpy(payload, payload_got, payload_size_got);
       free(payload_got);
       VERB0("Got waited message");
-      return no_error;
+      return;
     }
 
     /* not expected msg type. Queue it for later */
     }
 
     /* not expected msg type. Queue it for later */
@@ -357,11 +355,12 @@ gras_msg_wait(double           timeout,
     
     now=gras_os_time();
     if (now - start + 0.001 < timeout) {
     
     now=gras_os_time();
     if (now - start + 0.001 < timeout) {
-      RAISE1(timeout_error,"Timeout while waiting for msg %s",msgt_want->name);
+      THROW1(timeout_error,  now-start+0.001-timeout,
+            "Timeout while waiting for msg %s",msgt_want->name);
     }
   }
 
     }
   }
 
-  RAISE_IMPOSSIBLE;
+  THROW_IMPOSSIBLE;
 }
 
 /** @brief Handle an incomming message or timer (or wait up to \a timeOut seconds)
 }
 
 /** @brief Handle an incomming message or timer (or wait up to \a timeOut seconds)
@@ -371,12 +370,11 @@ gras_msg_wait(double           timeout,
  *
  * Messages are passed to the callbacks.
  */
  *
  * Messages are passed to the callbacks.
  */
-xbt_error_t 
+void
 gras_msg_handle(double timeOut) {
   
   double          untiltimer;
    
 gras_msg_handle(double timeOut) {
   
   double          untiltimer;
    
-  xbt_error_t    errcode;
   int             cpt;
 
   s_gras_msg_t    msg;
   int             cpt;
 
   s_gras_msg_t    msg;
@@ -389,7 +387,8 @@ gras_msg_handle(double timeOut) {
   gras_cblist_t  *list=NULL;
   gras_msg_cb_t       cb;
    
   gras_cblist_t  *list=NULL;
   gras_msg_cb_t       cb;
    
-  int timerexpected;
+  int timerexpected, timeouted;
+  xbt_ex_t e;
 
   VERB1("Handling message within the next %.2fs",timeOut);
   
 
   VERB1("Handling message within the next %.2fs",timeOut);
   
@@ -397,7 +396,7 @@ gras_msg_handle(double timeOut) {
   DEBUG2("[%.0f] Next timer in %f sec", gras_os_time(), untiltimer);
   if (untiltimer == 0.0) {
      /* A timer was already elapsed and handled */
   DEBUG2("[%.0f] Next timer in %f sec", gras_os_time(), untiltimer);
   if (untiltimer == 0.0) {
      /* A timer was already elapsed and handled */
-     return no_error;
+     return;
   }
   if (untiltimer != -1.0) {
      timerexpected = 1;
   }
   if (untiltimer != -1.0) {
      timerexpected = 1;
@@ -407,42 +406,53 @@ gras_msg_handle(double timeOut) {
   }
    
   /* get a message (from the queue or from the net) */
   }
    
   /* get a message (from the queue or from the net) */
+  timeouted = 0;
   if (xbt_dynar_length(pd->msg_queue)) {
     DEBUG0("Get a message from the queue");
     xbt_dynar_shift(pd->msg_queue,&msg);
     expeditor = msg.expeditor;
     msgtype   = msg.type;
     payload   = msg.payload;
   if (xbt_dynar_length(pd->msg_queue)) {
     DEBUG0("Get a message from the queue");
     xbt_dynar_shift(pd->msg_queue,&msg);
     expeditor = msg.expeditor;
     msgtype   = msg.type;
     payload   = msg.payload;
-    errcode   = no_error;
   } else {
   } else {
-    errcode = gras_trp_select(timeOut, &expeditor);
-    if (errcode != no_error && errcode != timeout_error)
-       return errcode;
-    if (errcode == no_error) {
-       errcode = gras_msg_recv(expeditor, &msgtype, &payload, &payload_size);
-       if (errcode != no_error) 
-         RAISE2(errcode, "Error '%s' while receiving a message on select()ed socket %p",
-                xbt_error_name(errcode),expeditor);
+    TRY {
+      expeditor = gras_trp_select(timeOut);
+    } CATCH(e) {
+      if (e.category != timeout_error)
+       RETHROW;
+      xbt_ex_free(e);
+      timeouted = 1;
+    }
+
+    if (!timeouted) {
+      TRY {
+       gras_msg_recv(expeditor, &msgtype, &payload, &payload_size);
+      } CATCH(e) {
+       RETHROW1("Error caught  while receiving a message on select()ed socket %p: %s",
+                expeditor);
+      }
     }
   }
 
     }
   }
 
-  if (errcode == timeout_error ) {
+  if (timeouted) {
      if (timerexpected) {
          
        /* A timer elapsed before the arrival of any message even if we select()ed a bit */
        untiltimer = gras_msg_timer_handle();
        if (untiltimer == 0.0) {
      if (timerexpected) {
          
        /* A timer elapsed before the arrival of any message even if we select()ed a bit */
        untiltimer = gras_msg_timer_handle();
        if (untiltimer == 0.0) {
-          return no_error;
+         /* we served a timer, we're done */
+         return;
        } else {
        } else {
-          xbt_assert1(untiltimer>0, "Negative timer (%f). I'm puzzeled", untiltimer);
+          xbt_assert1(untiltimer>0, "Negative timer (%f). I'm 'puzzeled'", untiltimer);
           WARN1("No timer elapsed, in contrary to expectations (next in %f sec)",
                  untiltimer);
           WARN1("No timer elapsed, in contrary to expectations (next in %f sec)",
                  untiltimer);
-          return timeout_error;
+          THROW1(timeout_error,0,
+                 "No timer elapsed, in contrary to expectations (next in %f sec)",
+                 untiltimer);
        }
        
      } else {
        /* select timeouted, and no timer elapsed. Nothing to do */
        }
        
      } else {
        /* select timeouted, and no timer elapsed. Nothing to do */
-       return timeout_error;
+       THROW0(timeout_error, 0, "No new message or timer");
      }
      
   }
      }
      
   }
@@ -459,7 +469,7 @@ gras_msg_handle(double timeOut) {
     INFO1("No callback for the incomming '%s' message. Discarded.", 
          msgtype->name);
     WARN0("FIXME: gras_datadesc_free not implemented => leaking the payload");
     INFO1("No callback for the incomming '%s' message. Discarded.", 
          msgtype->name);
     WARN0("FIXME: gras_datadesc_free not implemented => leaking the payload");
-    return no_error;
+    return;
   }
   
   xbt_dynar_foreach(list->cbs,cpt,cb) { 
   }
   
   xbt_dynar_foreach(list->cbs,cpt,cb) { 
@@ -468,13 +478,12 @@ gras_msg_handle(double timeOut) {
     if ((*cb)(expeditor,payload)) {
       /* cb handled the message */
       free(payload);
     if ((*cb)(expeditor,payload)) {
       /* cb handled the message */
       free(payload);
-      return no_error;
+      return;
     }
   }
 
     }
   }
 
-  INFO1("Message '%s' refused by all registered callbacks", msgtype->name);
-  WARN0("FIXME: gras_datadesc_free not implemented => leaking the payload");
-  return mismatch_error;
+  THROW1(mismatch_error,0,
+        "Message '%s' refused by all registered callbacks", msgtype->name);
 }
 
 void
 }
 
 void
index 1739d8b..782bdcf 100644 (file)
@@ -58,10 +58,10 @@ extern xbt_set_t _gras_msgtype_set; /* of gras_msgtype_t */
 void gras_msgtype_free(void *msgtype);
 
 
 void gras_msgtype_free(void *msgtype);
 
 
-xbt_error_t gras_msg_recv(gras_socket_t    sock,
-                          gras_msgtype_t  *msgtype,
-                          void           **payload,
-                          int             *payload_size);
+void gras_msg_recv(gras_socket_t    sock,
+                  gras_msgtype_t  *msgtype,
+                  void           **payload,
+                  int             *payload_size);
 
 /**
  * gras_cblist_t:
 
 /**
  * gras_cblist_t:
index 8af69cc..3c2d398 100644 (file)
@@ -7,7 +7,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-
+#include "xbt/ex.h"
 #include "gras/Msg/msg_private.h"
 #include "gras/timer.h"
 #include "gras/Virtu/virtu_interface.h"
 #include "gras/Msg/msg_private.h"
 #include "gras/timer.h"
 #include "gras/Virtu/virtu_interface.h"
@@ -43,7 +43,7 @@ void gras_timer_repeat(double interval, void_f_void_t action) {
 }
 
 /** @brief Cancel a delayed task */
 }
 
 /** @brief Cancel a delayed task */
-xbt_error_t gras_timer_cancel_delay(double interval, void_f_void_t action) {
+void gras_timer_cancel_delay(double interval, void_f_void_t action) {
   gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_get("gras_msg");
   int cursor,found;
   s_gras_timer_t timer;
   gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_get("gras_msg");
   int cursor,found;
   s_gras_timer_t timer;
@@ -60,14 +60,13 @@ xbt_error_t gras_timer_cancel_delay(double interval, void_f_void_t action) {
   }
   
   if (!found)
   }
   
   if (!found)
-     RAISE2(mismatch_error,"Cannot remove the action %p delayed of %f second: not found",
+     THROW2(mismatch_error,0,"Cannot remove the action %p delayed of %f second: not found",
            action,interval);
    
            action,interval);
    
-  return no_error;
 }
 
 /** @brief Cancel a repetitive task */
 }
 
 /** @brief Cancel a repetitive task */
-xbt_error_t gras_timer_cancel_repeat(double interval, void_f_void_t action) {
+void gras_timer_cancel_repeat(double interval, void_f_void_t action) {
   gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_get("gras_msg");
   int cursor,found;
   s_gras_timer_t timer;
   gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_get("gras_msg");
   int cursor,found;
   s_gras_timer_t timer;
@@ -84,14 +83,12 @@ xbt_error_t gras_timer_cancel_repeat(double interval, void_f_void_t action) {
   }
   
   if (!found)
   }
   
   if (!found)
-     RAISE2(mismatch_error,"Cannot remove the action %p delayed of %f second: not found",
+     THROW2(mismatch_error,0,"Cannot remove the action %p delayed of %f second: not found",
            action,interval);
            action,interval);
-   
-  return no_error;
 }
 
 /** @brief Cancel all delayed tasks */
 }
 
 /** @brief Cancel all delayed tasks */
-xbt_error_t gras_timer_cancel_delay_all(void) {
+void gras_timer_cancel_delay_all(void) {
   gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_get("gras_msg");
   int cursor, found;
   s_gras_timer_t timer;
   gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_get("gras_msg");
   int cursor, found;
   s_gras_timer_t timer;
@@ -106,30 +103,27 @@ xbt_error_t gras_timer_cancel_delay_all(void) {
   }
   
   if (!found)
   }
   
   if (!found)
-     RAISE0(mismatch_error,"No delayed action to remove");
+     THROW0(mismatch_error,0,"No delayed action to remove");
    
    
-  return no_error;
 }
 
 /** @brief Cancel all repetitive tasks */
 }
 
 /** @brief Cancel all repetitive tasks */
-xbt_error_t gras_timer_cancel_repeat_all(void){
+void gras_timer_cancel_repeat_all(void){
   gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_get("gras_msg");
   int cursor, found;
   s_gras_timer_t timer;
 
   found = FALSE;
   xbt_dynar_foreach(pd->timers,cursor,timer){
   gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_get("gras_msg");
   int cursor, found;
   s_gras_timer_t timer;
 
   found = FALSE;
   xbt_dynar_foreach(pd->timers,cursor,timer){
-     if (timer.repeat   == FALSE) {
-       
-       found = TRUE;
-       xbt_dynar_cursor_rm(pd->timers, &cursor);
-     }
+    if (timer.repeat   == FALSE) {
+      
+      found = TRUE;
+      xbt_dynar_cursor_rm(pd->timers, &cursor);
+    }
   }
   
   if (!found)
   }
   
   if (!found)
-     RAISE0(mismatch_error,"No repetitive action to remove");
-   
-  return no_error;
+    THROW0(mismatch_error,0,"No repetitive action to remove");
 }
 
 /** @brief Cancel all delayed and repetitive tasks */
 }
 
 /** @brief Cancel all delayed and repetitive tasks */
index 2449601..ecbcd06 100644 (file)
@@ -7,6 +7,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "xbt/ex.h"
 #include "portable.h"
 #include "gras/Transport/transport_private.h"
 XBT_LOG_EXTERNAL_CATEGORY(transport);
 #include "portable.h"
 #include "gras/Transport/transport_private.h"
 XBT_LOG_EXTERNAL_CATEGORY(transport);
@@ -23,11 +24,7 @@ XBT_LOG_DEFAULT_CATEGORY(transport);
  *
  * if timeout>0 and no message there, wait at most that amount of time before giving up.
  */
  *
  * if timeout>0 and no message there, wait at most that amount of time before giving up.
  */
-xbt_error_t 
-gras_trp_select(double timeout,
-               gras_socket_t *dst) {
-
-  xbt_error_t errcode;
+gras_socket_t gras_trp_select(double timeout) {
   xbt_dynar_t sockets= gras_socketset_get();
   int done = -1;
   double wakeup = gras_os_time() + timeout;
   xbt_dynar_t sockets= gras_socketset_get();
   int done = -1;
   double wakeup = gras_os_time() + timeout;
@@ -58,7 +55,6 @@ gras_trp_select(double timeout,
 #  endif /* !USE_SYSCONF */
 #endif
 
 #  endif /* !USE_SYSCONF */
 #endif
 
-  *dst=NULL;
   while (done == -1) {
     if (timeout > 0) { /* did we timeout already? */
       now = gras_os_time();
   while (done == -1) {
     if (timeout > 0) { /* did we timeout already? */
       now = gras_os_time();
@@ -88,10 +84,10 @@ gras_trp_select(double timeout,
        if (timeout > 0) {
          DEBUG1("No socket to select onto. Sleep %f sec instead.",timeout);
          gras_os_sleep(timeout);
        if (timeout > 0) {
          DEBUG1("No socket to select onto. Sleep %f sec instead.",timeout);
          gras_os_sleep(timeout);
-         return timeout_error;
+         THROW1(timeout_error,0,"No socket to select onto. Sleep %f sec instead",timeout);
        } else {
          DEBUG0("No socket to select onto. Return directly.");
        } else {
          DEBUG0("No socket to select onto. Return directly.");
-         return timeout_error;
+         THROW0(timeout_error,0, "No socket to select onto. Return directly.");
        }
     }
 
        }
     }
 
@@ -132,15 +128,15 @@ gras_trp_select(double timeout,
        /* if we cared, we would have set an handler */
        continue;
       case EINVAL: /* invalid value */
        /* if we cared, we would have set an handler */
        continue;
       case EINVAL: /* invalid value */
-       RAISE3(system_error,"invalid select: nb fds: %d, timeout: %d.%d",
+       THROW3(system_error,EINVAL,"invalid select: nb fds: %d, timeout: %d.%d",
               max_fds, (int)tout.tv_sec,(int) tout.tv_usec);
       case ENOMEM: 
        xbt_assert0(0,"Malloc error during the select");
       default:
               max_fds, (int)tout.tv_sec,(int) tout.tv_usec);
       case ENOMEM: 
        xbt_assert0(0,"Malloc error during the select");
       default:
-       RAISE2(system_error,"Error during select: %s (%d)",
+       THROW2(system_error,errno,"Error during select: %s (%d)",
               strerror(errno),errno);
       }
               strerror(errno),errno);
       }
-      RAISE_IMPOSSIBLE;
+      THROW_IMPOSSIBLE;
     } else if (ready == 0) {
       continue;         /* this was a timeout */
     }
     } else if (ready == 0) {
       continue;         /* this was a timeout */
     }
@@ -158,7 +154,7 @@ gras_trp_select(double timeout,
         /* not a socket but an ear. accept on it and serve next socket */
         gras_socket_t accepted=NULL;
         
         /* not a socket but an ear. accept on it and serve next socket */
         gras_socket_t accepted=NULL;
         
-        TRYOLD((sock_iter->plugin->socket_accept)(sock_iter,&accepted));
+        accepted = (sock_iter->plugin->socket_accept)(sock_iter);
         DEBUG2("accepted=%p,&accepted=%p",accepted,&accepted);
         accepted->meas = sock_iter->meas;
        } else {
         DEBUG2("accepted=%p,&accepted=%p",accepted,&accepted);
         accepted->meas = sock_iter->meas;
        } else {
@@ -182,9 +178,8 @@ gras_trp_select(double timeout,
         } else { 
 #endif
           /* Got a suited socket ! */
         } else { 
 #endif
           /* Got a suited socket ! */
-          *dst = sock_iter;
           XBT_OUT;
           XBT_OUT;
-          return no_error;
+          return sock_iter;
 #if 0
         }
 #endif
 #if 0
         }
 #endif
@@ -199,10 +194,10 @@ gras_trp_select(double timeout,
   }
 
   XBT_OUT;
   }
 
   XBT_OUT;
-  return timeout_error;
+  return NULL;
 }
 
 }
 
-xbt_error_t gras_trp_sg_setup(gras_trp_plugin_t plug) {
-  return mismatch_error;
+void gras_trp_sg_setup(gras_trp_plugin_t plug) {
+  THROW0(mismatch_error,0,"No SG transport on live platforms");
 }
 
 }
 
index 4448111..12e6392 100644 (file)
@@ -7,6 +7,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "xbt/ex.h"
 #include "gras/Transport/transport_private.h"
 #include "msg/msg.h"
 #include "gras/Virtu/virtu_sg.h"
 #include "gras/Transport/transport_private.h"
 #include "msg/msg.h"
 #include "gras/Virtu/virtu_sg.h"
@@ -25,12 +26,9 @@ XBT_LOG_DEFAULT_CATEGORY(transport);
  *
  * if timeout>0 and no message there, wait at most that amount of time before giving up.
  */
  *
  * if timeout>0 and no message there, wait at most that amount of time before giving up.
  */
-xbt_error_t 
-gras_trp_select(double timeout, 
-               gras_socket_t *dst) {
-
-  xbt_error_t errcode;
-  double startTime=gras_os_time();
+gras_socket_t gras_trp_select(double timeout) {
+  
+  gras_socket_t res;
   gras_trp_procdata_t pd=(gras_trp_procdata_t)gras_libdata_get("gras_trp");
   gras_trp_sg_sock_data_t *sockdata;
   gras_trp_plugin_t trp;
   gras_trp_procdata_t pd=(gras_trp_procdata_t)gras_libdata_get("gras_trp");
   gras_trp_sg_sock_data_t *sockdata;
   gras_trp_plugin_t trp;
@@ -48,11 +46,11 @@ gras_trp_select(double timeout,
         MSG_host_get_name(MSG_host_self()),
         timeout);
 
         MSG_host_get_name(MSG_host_self()),
         timeout);
 
-  TRYOLD(MSG_channel_select_from((m_channel_t) pd->chan, timeout, &r_pid));
+  MSG_channel_select_from((m_channel_t) pd->chan, timeout, &r_pid);
   
   if (r_pid < 0) {
     DEBUG0("TIMEOUT");
   
   if (r_pid < 0) {
     DEBUG0("TIMEOUT");
-    return timeout_error;
+    THROW0(timeout_error,0,"Timeout");
   }
 
   /* Ok, got something. Open a socket back to the expeditor */
   }
 
   /* Ok, got something. Open a socket back to the expeditor */
@@ -66,45 +64,44 @@ gras_trp_select(double timeout,
       continue;
     
     if (sockdata->to_PID == r_pid) {
       continue;
     
     if (sockdata->to_PID == r_pid) {
-      *dst=sock_iter;
-      return no_error;
+      return sock_iter;
     }
   }
   
   /* Socket to expeditor not created yet */
   DEBUG0("Create a socket to the expeditor");
   
     }
   }
   
   /* Socket to expeditor not created yet */
   DEBUG0("Create a socket to the expeditor");
   
-  TRYOLD(gras_trp_plugin_get_by_name("buf",&trp));
+  trp = gras_trp_plugin_get_by_name("buf");
   
   
-  gras_trp_socket_new(1,dst);
-  (*dst)->plugin   = trp;
+  gras_trp_socket_new(1,&res);
+  res->plugin   = trp;
   
   
-  (*dst)->incoming  = 1;
-  (*dst)->outgoing  = 1;
-  (*dst)->accepting = 0;
-  (*dst)->sd        = -1;
+  res->incoming  = 1;
+  res->outgoing  = 1;
+  res->accepting = 0;
+  res->sd        = -1;
   
   
-  (*dst)->port      = -1;
+  res->port      = -1;
   
   sockdata = xbt_new(gras_trp_sg_sock_data_t,1);
   sockdata->from_PID = MSG_process_self_PID();
   sockdata->to_PID   = r_pid;
   sockdata->to_host  = MSG_process_get_host(MSG_process_from_PID(r_pid));
   
   sockdata = xbt_new(gras_trp_sg_sock_data_t,1);
   sockdata->from_PID = MSG_process_self_PID();
   sockdata->to_PID   = r_pid;
   sockdata->to_host  = MSG_process_get_host(MSG_process_from_PID(r_pid));
-  (*dst)->data = sockdata;
-  gras_trp_buf_init_sock(*dst);
+  res->data = sockdata;
+  gras_trp_buf_init_sock(res);
   
   
-  (*dst)->peer_name = strdup(MSG_host_get_name(sockdata->to_host));
+  res->peer_name = strdup(MSG_host_get_name(sockdata->to_host));
   
   remote_hd=(gras_hostdata_t *)MSG_host_get_data(sockdata->to_host);
   xbt_assert0(remote_hd,"Run gras_process_init!!");
   
   sockdata->to_chan = -1;
   
   remote_hd=(gras_hostdata_t *)MSG_host_get_data(sockdata->to_host);
   xbt_assert0(remote_hd,"Run gras_process_init!!");
   
   sockdata->to_chan = -1;
-  (*dst)->peer_port = -10;
+  res->peer_port = -10;
   for (cursor=0; cursor<XBT_MAX_CHANNEL; cursor++) {
     if (remote_hd->proc[cursor] == r_pid) {
       sockdata->to_chan = cursor;
       DEBUG2("Chan %d on %s is for my pal",
   for (cursor=0; cursor<XBT_MAX_CHANNEL; cursor++) {
     if (remote_hd->proc[cursor] == r_pid) {
       sockdata->to_chan = cursor;
       DEBUG2("Chan %d on %s is for my pal",
-            cursor,(*dst)->peer_name);
+            cursor,res->peer_name);
       
       xbt_dynar_foreach(remote_hd->ports, cpt, pr) {
        if (sockdata->to_chan == pr.tochan) {
       
       xbt_dynar_foreach(remote_hd->ports, cpt, pr) {
        if (sockdata->to_chan == pr.tochan) {
@@ -113,7 +110,7 @@ gras_trp_select(double timeout,
            continue;
          }
          
            continue;
          }
          
-         (*dst)->peer_port = pr.port;
+         res->peer_port = pr.port;
          DEBUG1("Cool, it points to port %d", pr.port);
          break;
        } else {
          DEBUG1("Cool, it points to port %d", pr.port);
          break;
        } else {
@@ -121,7 +118,7 @@ gras_trp_select(double timeout,
                 pr.tochan,sockdata->to_chan);
        }
       }
                 pr.tochan,sockdata->to_chan);
        }
       }
-      if ((*dst)->peer_port == -10) {
+      if (res->peer_port == -10) {
        /* was for measurement */
        sockdata->to_chan = -1;
       } else {
        /* was for measurement */
        sockdata->to_chan = -1;
       } else {
@@ -133,17 +130,16 @@ gras_trp_select(double timeout,
   xbt_assert0(sockdata->to_chan != -1,
              "Got a message from a process without channel");
   
   xbt_assert0(sockdata->to_chan != -1,
              "Got a message from a process without channel");
   
-  return no_error;
+  return res;
 }
 
   
 /* dummy implementations of the functions used in RL mode */
 
 }
 
   
 /* dummy implementations of the functions used in RL mode */
 
-xbt_error_t gras_trp_tcp_setup(gras_trp_plugin_t plug) {
-  return mismatch_error;
+void gras_trp_tcp_setup(gras_trp_plugin_t plug) {
 }
 }
-xbt_error_t gras_trp_file_setup(gras_trp_plugin_t plug) {
-  return mismatch_error;
+void gras_trp_file_setup(gras_trp_plugin_t plug) {
+  THROW0(mismatch_error,0,"No file within SG realm");
 }
 
 
 }
 
 
index ae0fb62..6417ea3 100644 (file)
@@ -7,6 +7,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "xbt/ex.h"
 #include "portable.h"
 #include "gras/Transport/transport_private.h"
 
 #include "portable.h"
 #include "gras/Transport/transport_private.h"
 
@@ -19,7 +20,7 @@ static void gras_trp_plugin_free(void *p); /* free one of the plugins */
 
 static void
 gras_trp_plugin_new(const char *name, gras_trp_setup_t setup) {
 
 static void
 gras_trp_plugin_new(const char *name, gras_trp_setup_t setup) {
-  xbt_error_t errcode;
+  xbt_ex_t e;
 
   gras_trp_plugin_t plug = xbt_new0(s_gras_trp_plugin_t, 1);
   
 
   gras_trp_plugin_t plug = xbt_new0(s_gras_trp_plugin_t, 1);
   
@@ -27,23 +28,20 @@ gras_trp_plugin_new(const char *name, gras_trp_setup_t setup) {
 
   plug->name=xbt_strdup(name);
 
 
   plug->name=xbt_strdup(name);
 
-  errcode = setup(plug);
-  switch (errcode) {
-  case mismatch_error:
-    /* SG plugin return mismatch when in RL mode (and vice versa) */
-    free(plug->name);
-    free(plug);
-    break;
-
-  case no_error:
-    xbt_dict_set(_gras_trp_plugins,
-                 name, plug, gras_trp_plugin_free);
-    break;
-
-  default:
-    DIE_IMPOSSIBLE;
+  TRY {
+    setup(plug);
+  } CATCH(e) {
+    if (e.category == mismatch_error) {
+      /* SG plugin raise mismatch when in RL mode (and vice versa) */
+      free(plug->name);
+      free(plug);
+      xbt_ex_free(e);
+    } else {
+      RETHROW;
+    }
   }
 
   }
 
+  xbt_dict_set(_gras_trp_plugins, name, plug, gras_trp_plugin_free);
 }
 
 void gras_trp_init(void){
 }
 
 void gras_trp_init(void){
@@ -182,26 +180,21 @@ void gras_trp_socket_new(int incoming,
  * Opens a server socket and make it ready to be listened to.
  * In real life, you'll get a TCP socket.
  */
  * Opens a server socket and make it ready to be listened to.
  * In real life, you'll get a TCP socket.
  */
-xbt_error_t
+gras_socket_t
 gras_socket_server_ext(unsigned short port,
                       
                       unsigned long int bufSize,
 gras_socket_server_ext(unsigned short port,
                       
                       unsigned long int bufSize,
-                      int measurement,
-                      
-                      /* OUT */ gras_socket_t *dst) {
+                      int measurement) {
  
  
-  xbt_error_t errcode;
+  xbt_ex_t e;
   gras_trp_plugin_t trp;
   gras_socket_t sock;
 
   gras_trp_plugin_t trp;
   gras_socket_t sock;
 
-  *dst = NULL;
-
   DEBUG2("Create a server socket from plugin %s on port %d",
         gras_if_RL() ? "tcp" : "sg",
         port);
   DEBUG2("Create a server socket from plugin %s on port %d",
         gras_if_RL() ? "tcp" : "sg",
         port);
-  TRYOLD(gras_trp_plugin_get_by_name((measurement? (gras_if_RL() ? "tcp" : "sg")
-                                             :"buf"),
-                                 &trp));
+  trp = gras_trp_plugin_get_by_name((measurement? (gras_if_RL() ? "tcp" : "sg")
+                                               :"buf"));
 
   /* defaults settings */
   gras_trp_socket_new(1,&sock);
 
   /* defaults settings */
   gras_trp_socket_new(1,&sock);
@@ -212,20 +205,18 @@ gras_socket_server_ext(unsigned short port,
 
   /* Call plugin socket creation function */
   DEBUG1("Prepare socket with plugin (fct=%p)",trp->socket_server);
 
   /* Call plugin socket creation function */
   DEBUG1("Prepare socket with plugin (fct=%p)",trp->socket_server);
-  errcode = trp->socket_server(trp, sock);
-  DEBUG3("in=%c out=%c accept=%c",
-        sock->incoming?'y':'n', 
-        sock->outgoing?'y':'n',
-        sock->accepting?'y':'n');
-
-  if (errcode != no_error) {
+  TRY {
+    trp->socket_server(trp, sock);
+    DEBUG3("in=%c out=%c accept=%c",
+          sock->incoming?'y':'n', 
+          sock->outgoing?'y':'n',
+          sock->accepting?'y':'n');
+  } CATCH(e) {
     free(sock);
     free(sock);
-    return errcode;
+    RETHROW;
   }
 
   }
 
-  *dst = sock;
-
-  return no_error;
+  return sock;
 }
    
 /**
 }
    
 /**
@@ -234,24 +225,19 @@ gras_socket_server_ext(unsigned short port,
  * Opens a client socket to a remote host.
  * In real life, you'll get a TCP socket.
  */
  * Opens a client socket to a remote host.
  * In real life, you'll get a TCP socket.
  */
-xbt_error_t
+gras_socket_t
 gras_socket_client_ext(const char *host,
                       unsigned short port,
                       
                       unsigned long int bufSize,
 gras_socket_client_ext(const char *host,
                       unsigned short port,
                       
                       unsigned long int bufSize,
-                      int measurement,
-                      
-                      /* OUT */ gras_socket_t *dst) {
+                      int measurement) {
  
  
-  xbt_error_t errcode;
+  xbt_ex_t e;
   gras_trp_plugin_t trp;
   gras_socket_t sock;
 
   gras_trp_plugin_t trp;
   gras_socket_t sock;
 
-  *dst = NULL;
-
-  TRYOLD(gras_trp_plugin_get_by_name((measurement? (gras_if_RL() ? "tcp" : "sg")
-                                             :"buf"),
-                                 &trp));
+  trp = gras_trp_plugin_get_by_name((measurement? (gras_if_RL() ? "tcp" : "sg")
+                                               : "buf"));
 
   DEBUG1("Create a client socket from plugin %s",gras_if_RL() ? "tcp" : "sg");
   /* defaults settings */
 
   DEBUG1("Create a client socket from plugin %s",gras_if_RL() ? "tcp" : "sg");
   /* defaults settings */
@@ -263,20 +249,18 @@ gras_socket_client_ext(const char *host,
   sock->meas = measurement;
 
   /* plugin-specific */
   sock->meas = measurement;
 
   /* plugin-specific */
-  errcode= (*trp->socket_client)(trp, sock);
-  DEBUG3("in=%c out=%c accept=%c",
-        sock->incoming?'y':'n', 
-        sock->outgoing?'y':'n',
-        sock->accepting?'y':'n');
-
-  if (errcode != no_error) {
+  TRY {
+    (*trp->socket_client)(trp, sock);
+    DEBUG3("in=%c out=%c accept=%c",
+          sock->incoming?'y':'n', 
+          sock->outgoing?'y':'n',
+          sock->accepting?'y':'n');
+  } CATCH(e) {
     free(sock);
     free(sock);
-    return errcode;
+    RETHROW;
   }
 
   }
 
-  *dst = sock;
-
-  return no_error;
+  return sock;
 }
 
 /**
 }
 
 /**
@@ -285,10 +269,9 @@ gras_socket_client_ext(const char *host,
  * Opens a server socket and make it ready to be listened to.
  * In real life, you'll get a TCP socket.
  */
  * Opens a server socket and make it ready to be listened to.
  * In real life, you'll get a TCP socket.
  */
-xbt_error_t
-gras_socket_server(unsigned short port,
-                  /* OUT */ gras_socket_t *dst) {
-   return gras_socket_server_ext(port,32,0,dst);
+gras_socket_t
+gras_socket_server(unsigned short port) {
+   return gras_socket_server_ext(port,32,0);
 }
 
 /**
 }
 
 /**
@@ -297,11 +280,10 @@ gras_socket_server(unsigned short port,
  * Opens a client socket to a remote host.
  * In real life, you'll get a TCP socket.
  */
  * Opens a client socket to a remote host.
  * In real life, you'll get a TCP socket.
  */
-xbt_error_t
+gras_socket_t
 gras_socket_client(const char *host,
 gras_socket_client(const char *host,
-                  unsigned short port,
-                  /* OUT */ gras_socket_t *dst) {
-   return gras_socket_client_ext(host,port,32,0,dst);
+                  unsigned short port) {
+   return gras_socket_client_ext(host,port,32,0);
 }
 
 
 }
 
 
@@ -337,7 +319,7 @@ void gras_socket_close(gras_socket_t sock) {
  *
  * Send a bunch of bytes from on socket
  */
  *
  * Send a bunch of bytes from on socket
  */
-xbt_error_t
+void
 gras_trp_chunk_send(gras_socket_t sd,
                    char *data,
                    long int size) {
 gras_trp_chunk_send(gras_socket_t sd,
                    char *data,
                    long int size) {
@@ -347,14 +329,14 @@ gras_trp_chunk_send(gras_socket_t sd,
   xbt_assert1(sd->plugin->chunk_send,
               "No function chunk_send on transport plugin %s",
               sd->plugin->name);
   xbt_assert1(sd->plugin->chunk_send,
               "No function chunk_send on transport plugin %s",
               sd->plugin->name);
-  return (*sd->plugin->chunk_send)(sd,data,size);
+  (*sd->plugin->chunk_send)(sd,data,size);
 }
 /**
  * gras_trp_chunk_recv:
  *
  * Receive a bunch of bytes from a socket
  */
 }
 /**
  * gras_trp_chunk_recv:
  *
  * Receive a bunch of bytes from a socket
  */
-xbt_error_t 
+void
 gras_trp_chunk_recv(gras_socket_t sd,
                    char *data,
                    long int size) {
 gras_trp_chunk_recv(gras_socket_t sd,
                    char *data,
                    long int size) {
@@ -363,7 +345,7 @@ gras_trp_chunk_recv(gras_socket_t sd,
   xbt_assert1(sd->plugin->chunk_recv,
               "No function chunk_recv on transport plugin %s",
               sd->plugin->name);
   xbt_assert1(sd->plugin->chunk_recv,
               "No function chunk_recv on transport plugin %s",
               sd->plugin->name);
-  return (sd->plugin->chunk_recv)(sd,data,size);
+  (sd->plugin->chunk_recv)(sd,data,size);
 }
 
 /**
 }
 
 /**
@@ -371,16 +353,14 @@ gras_trp_chunk_recv(gras_socket_t sd,
  *
  * Make sure all pending communications are done
  */
  *
  * Make sure all pending communications are done
  */
-xbt_error_t 
+void
 gras_trp_flush(gras_socket_t sd) {
 gras_trp_flush(gras_socket_t sd) {
-  return (sd->plugin->flush)(sd);
+  (sd->plugin->flush)(sd);
 }
 
 }
 
-xbt_error_t
-gras_trp_plugin_get_by_name(const char *name,
-                           gras_trp_plugin_t *dst){
-
-  return xbt_dict_get(_gras_trp_plugins,name,(void**)dst);
+gras_trp_plugin_t
+gras_trp_plugin_get_by_name(const char *name){
+  return xbt_dict_get(_gras_trp_plugins,name);
 }
 
 int   gras_socket_my_port  (gras_socket_t sock) {
 }
 
 int   gras_socket_my_port  (gras_socket_t sock) {
@@ -412,11 +392,10 @@ int gras_socket_is_meas(gras_socket_t sock) {
  * there is no way to control what is sent (ie, you cannot use these 
  * functions to exchange data out of band).
  */
  * there is no way to control what is sent (ie, you cannot use these 
  * functions to exchange data out of band).
  */
-xbt_error_t gras_socket_meas_send(gras_socket_t peer, 
-                                 unsigned int timeout,
-                                 unsigned long int exp_size, 
-                                 unsigned long int msg_size) {
-  xbt_error_t errcode;
+void gras_socket_meas_send(gras_socket_t peer, 
+                          unsigned int timeout,
+                          unsigned long int exp_size, 
+                          unsigned long int msg_size) {
   char *chunk = xbt_malloc0(msg_size);
   unsigned long int exp_sofar;
    
   char *chunk = xbt_malloc0(msg_size);
   unsigned long int exp_sofar;
    
@@ -428,7 +407,7 @@ xbt_error_t gras_socket_meas_send(gras_socket_t peer,
      CDEBUG5(trp_meas,"Sent %lu of %lu (msg_size=%ld) to %s:%d",
             exp_sofar,exp_size,msg_size,
             gras_socket_peer_name(peer), gras_socket_peer_port(peer));
      CDEBUG5(trp_meas,"Sent %lu of %lu (msg_size=%ld) to %s:%d",
             exp_sofar,exp_size,msg_size,
             gras_socket_peer_name(peer), gras_socket_peer_port(peer));
-     TRYOLD(gras_trp_chunk_send(peer,chunk,msg_size));
+     gras_trp_chunk_send(peer,chunk,msg_size);
   }
   CDEBUG5(trp_meas,"Sent %lu of %lu (msg_size=%ld) to %s:%d",
          exp_sofar,exp_size,msg_size,
   }
   CDEBUG5(trp_meas,"Sent %lu of %lu (msg_size=%ld) to %s:%d",
          exp_sofar,exp_size,msg_size,
@@ -437,7 +416,6 @@ xbt_error_t gras_socket_meas_send(gras_socket_t peer,
   free(chunk);
 
   XBT_OUT;
   free(chunk);
 
   XBT_OUT;
-  return no_error;
 }
 
 /** \brief Receive a chunk of data over a measurement socket 
 }
 
 /** \brief Receive a chunk of data over a measurement socket 
@@ -445,12 +423,11 @@ xbt_error_t gras_socket_meas_send(gras_socket_t peer,
  * Calls to gras_socket_meas_send() and gras_socket_meas_recv() on 
  * each side of the socket should be paired. 
  */
  * Calls to gras_socket_meas_send() and gras_socket_meas_recv() on 
  * each side of the socket should be paired. 
  */
-xbt_error_t gras_socket_meas_recv(gras_socket_t peer, 
-                                 unsigned int timeout,
-                                 unsigned long int exp_size, 
-                                 unsigned long int msg_size){
+void gras_socket_meas_recv(gras_socket_t peer, 
+                          unsigned int timeout,
+                          unsigned long int exp_size, 
+                          unsigned long int msg_size){
   
   
-  xbt_error_t errcode;
   char *chunk = xbt_malloc(msg_size);
   unsigned long int exp_sofar;
 
   char *chunk = xbt_malloc(msg_size);
   unsigned long int exp_sofar;
 
@@ -462,7 +439,7 @@ xbt_error_t gras_socket_meas_recv(gras_socket_t peer,
      CDEBUG5(trp_meas,"Recvd %ld of %lu (msg_size=%ld) from %s:%d",
             exp_sofar,exp_size,msg_size,
             gras_socket_peer_name(peer), gras_socket_peer_port(peer));
      CDEBUG5(trp_meas,"Recvd %ld of %lu (msg_size=%ld) from %s:%d",
             exp_sofar,exp_size,msg_size,
             gras_socket_peer_name(peer), gras_socket_peer_port(peer));
-     TRYOLD(gras_trp_chunk_recv(peer,chunk,msg_size));
+     gras_trp_chunk_recv(peer,chunk,msg_size);
   }
   CDEBUG5(trp_meas,"Recvd %ld of %lu (msg_size=%ld) from %s:%d",
          exp_sofar,exp_size,msg_size,
   }
   CDEBUG5(trp_meas,"Recvd %ld of %lu (msg_size=%ld) from %s:%d",
          exp_sofar,exp_size,msg_size,
@@ -470,8 +447,6 @@ xbt_error_t gras_socket_meas_recv(gras_socket_t peer,
 
   free(chunk);
   XBT_OUT;
 
   free(chunk);
   XBT_OUT;
-
-  return no_error;
 }
 
 /**
 }
 
 /**
@@ -486,24 +461,22 @@ xbt_error_t gras_socket_meas_recv(gras_socket_t peer,
  * done for regular sockets, but you usually want more control about 
  * what's going on with measurement sockets.
  */
  * done for regular sockets, but you usually want more control about 
  * what's going on with measurement sockets.
  */
-xbt_error_t gras_socket_meas_accept(gras_socket_t peer, gras_socket_t *accepted){
-  xbt_error_t errcode;
+gras_socket_t gras_socket_meas_accept(gras_socket_t peer){
   gras_socket_t res;
   gras_socket_t res;
-  
+
   xbt_assert0(peer->meas,
              "No need to accept on non-measurement sockets (it's automatic)");
 
   if (!peer->accepting) {
     /* nothing to accept here */
   xbt_assert0(peer->meas,
              "No need to accept on non-measurement sockets (it's automatic)");
 
   if (!peer->accepting) {
     /* nothing to accept here */
-    *accepted=peer;
-    return no_error;
+    return peer;
   }
 
   }
 
-  TRYOLD((peer->plugin->socket_accept)(peer,accepted));
-  (*accepted)->meas = peer->meas;
-  CDEBUG1(trp_meas,"meas_accepted onto %d",(*accepted)->sd);
+  res = (peer->plugin->socket_accept)(peer);
+  res->meas = peer->meas;
+  CDEBUG1(trp_meas,"meas_accepted onto %d",res->sd);
 
 
-  return no_error;
+  return res;
 } 
 
 
 } 
 
 
index ba43fe5..e1e8548 100644 (file)
 /***
  *** Main user functions
  ***/
 /***
  *** Main user functions
  ***/
-xbt_error_t gras_trp_chunk_send(gras_socket_t sd,
-                                char *data,
-                                long int size);
-xbt_error_t gras_trp_chunk_recv(gras_socket_t sd,
-                                char *data,
-                                long int size);
-xbt_error_t gras_trp_flush(gras_socket_t sd);
+void gras_trp_chunk_send(gras_socket_t sd,
+                        char *data,
+                        long int size);
+void gras_trp_chunk_recv(gras_socket_t sd,
+                        char *data,
+                        long int size);
+void gras_trp_flush(gras_socket_t sd);
 
 /* Find which socket needs to be read next */
 
 /* Find which socket needs to be read next */
-xbt_error_t 
-gras_trp_select(double timeout,
-               gras_socket_t *dst);
+gras_socket_t gras_trp_select(double timeout);
 
 
 /***
 
 
 /***
@@ -43,39 +41,37 @@ struct gras_trp_plugin_ {
   /* dst pointers are created and initialized with default values
      before call to socket_client/server. 
      Retrive the info you need from there. */
   /* dst pointers are created and initialized with default values
      before call to socket_client/server. 
      Retrive the info you need from there. */
-  xbt_error_t (*socket_client)(gras_trp_plugin_t self,
-                               gras_socket_t    dst);
-  xbt_error_t (*socket_server)(gras_trp_plugin_t self,
-                               gras_socket_t    dst);
+  void (*socket_client)(gras_trp_plugin_t self,
+                       gras_socket_t    dst);
+  void (*socket_server)(gras_trp_plugin_t self,
+                       gras_socket_t    dst);
    
    
-  xbt_error_t (*socket_accept)(gras_socket_t  sock,
-                               gras_socket_t *dst);
+  gras_socket_t (*socket_accept)(gras_socket_t  from);
    
    
    /* socket_close() is responsible of telling the OS that the socket is over,
     but should not free the socket itself (beside the specific part) */
    
    
    /* socket_close() is responsible of telling the OS that the socket is over,
     but should not free the socket itself (beside the specific part) */
-  void         (*socket_close)(gras_socket_t sd);
+  void (*socket_close)(gras_socket_t sd);
     
     
-  xbt_error_t (*chunk_send)(gras_socket_t sd,
-                            const char *data,
-                           unsigned long int size);
-  xbt_error_t (*chunk_recv)(gras_socket_t sd,
-                           char *data,
-                           unsigned long int size);
+  void (*chunk_send)(gras_socket_t sd,
+                    const char *data,
+                    unsigned long int size);
+  void (*chunk_recv)(gras_socket_t sd,
+                    char *data,
+                    unsigned long int size);
 
   /* flush has to make sure that the pending communications are achieved */
 
   /* flush has to make sure that the pending communications are achieved */
-  xbt_error_t (*flush)(gras_socket_t sd);
+  void (*flush)(gras_socket_t sd);
 
 
-  void          *data; /* plugin-specific data */
+  void *data; /* plugin-specific data */
  
    /* exit is responsible for freeing data and telling the OS this plugin goes */
    /* exit=NULL, data gets freed. (ie exit function needed only when data contains pointers) */
  
    /* exit is responsible for freeing data and telling the OS this plugin goes */
    /* exit=NULL, data gets freed. (ie exit function needed only when data contains pointers) */
-  void         (*exit)(gras_trp_plugin_t);
+  void (*exit)(gras_trp_plugin_t);
 };
 
 };
 
-xbt_error_t
-gras_trp_plugin_get_by_name(const char *name,
-                           gras_trp_plugin_t *dst);
+gras_trp_plugin_t
+gras_trp_plugin_get_by_name(const char *name);
 
 /* Data of this module specific to each process
  * (used by sg_process.c to cleanup the SG channel cruft)
 
 /* Data of this module specific to each process
  * (used by sg_process.c to cleanup the SG channel cruft)
index 433fb63..fdcd086 100644 (file)
@@ -13,6 +13,7 @@
 #include "portable.h"
 #include "xbt/misc.h"
 #include "xbt/sysdep.h"
 #include "portable.h"
 #include "xbt/misc.h"
 #include "xbt/sysdep.h"
+#include "xbt/ex.h"
 #include "transport_private.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(trp_buf,transport,
 #include "transport_private.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(trp_buf,transport,
@@ -26,23 +27,22 @@ static gras_trp_plugin_t _buf_super;
  ***/
 void hexa_print(const char*name, unsigned char *data, int size);   /* in gras.c */
    
  ***/
 void hexa_print(const char*name, unsigned char *data, int size);   /* in gras.c */
    
-xbt_error_t gras_trp_buf_socket_client(gras_trp_plugin_t self,
-                                       gras_socket_t sock);
-xbt_error_t gras_trp_buf_socket_server(gras_trp_plugin_t self,
-                                       gras_socket_t sock);
-xbt_error_t gras_trp_buf_socket_accept(gras_socket_t sock,
-                                       gras_socket_t *dst);
+void gras_trp_buf_socket_client(gras_trp_plugin_t self,
+                               gras_socket_t sock);
+void gras_trp_buf_socket_server(gras_trp_plugin_t self,
+                               gras_socket_t sock);
+gras_socket_t gras_trp_buf_socket_accept(gras_socket_t sock);
 
 void         gras_trp_buf_socket_close(gras_socket_t sd);
   
 
 void         gras_trp_buf_socket_close(gras_socket_t sd);
   
-xbt_error_t gras_trp_buf_chunk_send(gras_socket_t sd,
-                                   const char *data,
-                                   unsigned long int size);
+void gras_trp_buf_chunk_send(gras_socket_t sd,
+                            const char *data,
+                            unsigned long int size);
 
 
-xbt_error_t gras_trp_buf_chunk_recv(gras_socket_t sd,
-                                   char *data,
-                                   unsigned long int size);
-xbt_error_t gras_trp_buf_flush(gras_socket_t sock);
+void gras_trp_buf_chunk_recv(gras_socket_t sd,
+                            char *data,
+                            unsigned long int size);
+void gras_trp_buf_flush(gras_socket_t sock);
 
 
 /***
 
 
 /***
@@ -92,14 +92,13 @@ void gras_trp_buf_init_sock(gras_socket_t sock) {
 /***
  *** Code
  ***/
 /***
  *** Code
  ***/
-xbt_error_t
+void
 gras_trp_buf_setup(gras_trp_plugin_t plug) {
 gras_trp_buf_setup(gras_trp_plugin_t plug) {
-  xbt_error_t errcode;
   gras_trp_buf_plug_data_t *data =xbt_new(gras_trp_buf_plug_data_t,1);
 
   XBT_IN;
   gras_trp_buf_plug_data_t *data =xbt_new(gras_trp_buf_plug_data_t,1);
 
   XBT_IN;
-  TRYOLD(gras_trp_plugin_get_by_name(gras_if_RL() ? "tcp" : "sg",
-                                 &_buf_super));
+  _buf_super = gras_trp_plugin_get_by_name(gras_if_RL() ? "tcp" : "sg");
+
   DEBUG1("Derivate a buffer plugin from %s",gras_if_RL() ? "tcp" : "sg");
 
   plug->socket_client = gras_trp_buf_socket_client;
   DEBUG1("Derivate a buffer plugin from %s",gras_if_RL() ? "tcp" : "sg");
 
   plug->socket_client = gras_trp_buf_socket_client;
@@ -114,20 +113,15 @@ gras_trp_buf_setup(gras_trp_plugin_t plug) {
 
   plug->data = (void*)data;
   plug->exit = NULL;
 
   plug->data = (void*)data;
   plug->exit = NULL;
-  
-  return no_error;
 }
 
 }
 
-xbt_error_t gras_trp_buf_socket_client(gras_trp_plugin_t self,
-                                       /* OUT */ gras_socket_t sock){
-  xbt_error_t errcode;
+void gras_trp_buf_socket_client(gras_trp_plugin_t self,
+                               /* OUT */ gras_socket_t sock){
 
   XBT_IN;
 
   XBT_IN;
-  TRYOLD(_buf_super->socket_client(_buf_super,sock));
+  _buf_super->socket_client(_buf_super,sock);
   sock->plugin = self;
   gras_trp_buf_init_sock(sock);
   sock->plugin = self;
   gras_trp_buf_init_sock(sock);
-    
-  return no_error;
 }
 
 /**
 }
 
 /**
@@ -135,32 +129,29 @@ xbt_error_t gras_trp_buf_socket_client(gras_trp_plugin_t self,
  *
  * Open a socket used to receive messages.
  */
  *
  * Open a socket used to receive messages.
  */
-xbt_error_t gras_trp_buf_socket_server(gras_trp_plugin_t self,
-                                       /* OUT */ gras_socket_t sock){
-  xbt_error_t errcode;
+void gras_trp_buf_socket_server(gras_trp_plugin_t self,
+                               /* OUT */ gras_socket_t sock){
 
   XBT_IN;
 
   XBT_IN;
-  TRYOLD(_buf_super->socket_server(_buf_super,sock));
+  _buf_super->socket_server(_buf_super,sock);
   sock->plugin = self;
   gras_trp_buf_init_sock(sock);
   sock->plugin = self;
   gras_trp_buf_init_sock(sock);
-  return no_error;
 }
 
 }
 
-xbt_error_t
-gras_trp_buf_socket_accept(gras_socket_t  sock,
-                          gras_socket_t *dst) {
-  xbt_error_t errcode;
+gras_socket_t
+gras_trp_buf_socket_accept(gras_socket_t  sock) {
+
+  gras_socket_t res;
       
   XBT_IN;
       
   XBT_IN;
-  TRYOLD(_buf_super->socket_accept(sock,dst));
-  (*dst)->plugin = sock->plugin;
-  gras_trp_buf_init_sock(*dst);
+  res = _buf_super->socket_accept(sock);
+  res->plugin = sock->plugin;
+  gras_trp_buf_init_sock(res);
   XBT_OUT;
   XBT_OUT;
-  return no_error;
+  return res;
 }
 
 void gras_trp_buf_socket_close(gras_socket_t sock){
 }
 
 void gras_trp_buf_socket_close(gras_socket_t sock){
-  xbt_error_t errcode;
   gras_trp_bufdata_t *data=sock->bufdata;
 
   XBT_IN;
   gras_trp_bufdata_t *data=sock->bufdata;
 
   XBT_IN;
@@ -188,12 +179,11 @@ void gras_trp_buf_socket_close(gras_socket_t sock){
  *
  * Send data on a buffered socket
  */
  *
  * Send data on a buffered socket
  */
-xbt_error_t 
+void
 gras_trp_buf_chunk_send(gras_socket_t sock,
                        const char *chunk,
                        unsigned long int size) {
 
 gras_trp_buf_chunk_send(gras_socket_t sock,
                        const char *chunk,
                        unsigned long int size) {
 
-  xbt_error_t errcode;
   gras_trp_bufdata_t *data=(gras_trp_bufdata_t*)sock->bufdata;
   int chunk_pos=0;
 
   gras_trp_bufdata_t *data=(gras_trp_bufdata_t*)sock->bufdata;
   int chunk_pos=0;
 
@@ -217,11 +207,10 @@ gras_trp_buf_chunk_send(gras_socket_t sock,
           data->out.size,size-chunk_pos,size,(int)chunk_pos,chunk);
 
     if (data->out.size == data->buffsize) /* out of space. Flush it */
           data->out.size,size-chunk_pos,size,(int)chunk_pos,chunk);
 
     if (data->out.size == data->buffsize) /* out of space. Flush it */
-      TRYOLD(gras_trp_buf_flush(sock));
+      gras_trp_buf_flush(sock);
   }
 
   XBT_OUT;
   }
 
   XBT_OUT;
-  return no_error;
 }
 
 /**
 }
 
 /**
@@ -229,12 +218,12 @@ gras_trp_buf_chunk_send(gras_socket_t sock,
  *
  * Receive data on a buffered socket.
  */
  *
  * Receive data on a buffered socket.
  */
-xbt_error_t 
+void
 gras_trp_buf_chunk_recv(gras_socket_t sock,
                        char *chunk,
                        unsigned long int size) {
 
 gras_trp_buf_chunk_recv(gras_socket_t sock,
                        char *chunk,
                        unsigned long int size) {
 
-  xbt_error_t errcode;
+  xbt_ex_t e;
   gras_trp_bufdata_t *data=sock->bufdata;
   long int chunck_pos = 0;
  
   gras_trp_bufdata_t *data=sock->bufdata;
   long int chunck_pos = 0;
  
@@ -252,17 +241,19 @@ gras_trp_buf_chunk_recv(gras_socket_t sock,
       int nextsize;
       if (gras_if_RL()) {
         DEBUG0("Recv the size");
       int nextsize;
       if (gras_if_RL()) {
         DEBUG0("Recv the size");
-        errcode=_buf_super->chunk_recv(sock,(char*)&nextsize, 4);
-        if (errcode!=no_error)
-          RAISE4(errcode,"Got '%s' while trying to get the chunk size on %p (peer = %s:%d)",
-                 xbt_error_name(errcode),sock,gras_socket_peer_name(sock),gras_socket_peer_port(sock));
+        TRY {
+          _buf_super->chunk_recv(sock,(char*)&nextsize, 4);
+        } CATCH(e) {
+          RETHROW3("Unable to get the chunk size on %p (peer = %s:%d): %s",
+                   sock,gras_socket_peer_name(sock),gras_socket_peer_port(sock));
+        }
         data->in.size = (int)ntohl(nextsize);
         VERB1("Recv the chunk (size=%d)",data->in.size);
       } else {
         data->in.size = -1;
       }
        
         data->in.size = (int)ntohl(nextsize);
         VERB1("Recv the chunk (size=%d)",data->in.size);
       } else {
         data->in.size = -1;
       }
        
-      TRYOLD(_buf_super->chunk_recv(sock, data->in.data, data->in.size));
+      _buf_super->chunk_recv(sock, data->in.data, data->in.size);
        
       if (gras_if_RL()) {
         data->in.pos=0;
        
       if (gras_if_RL()) {
         data->in.pos=0;
@@ -291,7 +282,6 @@ gras_trp_buf_chunk_recv(gras_socket_t sock,
   }
 
   XBT_OUT;
   }
 
   XBT_OUT;
-  return no_error;
 }
 
 /**
 }
 
 /**
@@ -299,9 +289,8 @@ gras_trp_buf_chunk_recv(gras_socket_t sock,
  *
  * Make sure the data is sent
  */
  *
  * Make sure the data is sent
  */
-xbt_error_t 
+void
 gras_trp_buf_flush(gras_socket_t sock) {
 gras_trp_buf_flush(gras_socket_t sock) {
-  xbt_error_t errcode;
   int size;
   gras_trp_bufdata_t *data=sock->bufdata;
   XBT_IN;    
   int size;
   gras_trp_bufdata_t *data=sock->bufdata;
   XBT_IN;    
@@ -311,7 +300,7 @@ gras_trp_buf_flush(gras_socket_t sock) {
      hexa_print("chunck to send ",data->out.data,data->out.size);
   if ((data->out.size - data->out.pos) == (gras_if_RL()?0:4) ) { /* 4 first bytes=size in SG mode*/
      DEBUG2("Nothing to flush (size=%d; pos=%d)",data->out.size,data->out.pos);
      hexa_print("chunck to send ",data->out.data,data->out.size);
   if ((data->out.size - data->out.pos) == (gras_if_RL()?0:4) ) { /* 4 first bytes=size in SG mode*/
      DEBUG2("Nothing to flush (size=%d; pos=%d)",data->out.size,data->out.pos);
-     return no_error;
+     return;
   }
    
   size = (int)data->out.size - data->out.pos;
   }
    
   size = (int)data->out.size - data->out.pos;
@@ -319,7 +308,7 @@ gras_trp_buf_flush(gras_socket_t sock) {
         gras_socket_peer_name(sock),gras_socket_peer_port(sock));
   if (gras_if_RL()) {
      size = (int)htonl(size);
         gras_socket_peer_name(sock),gras_socket_peer_port(sock));
   if (gras_if_RL()) {
      size = (int)htonl(size);
-     TRYOLD(_buf_super->chunk_send(sock,(char*) &size, 4));
+     _buf_super->chunk_send(sock,(char*) &size, 4);
   } else {
      memcpy(data->out.data, &size, 4);
   }
   } else {
      memcpy(data->out.data, &size, 4);
   }
@@ -327,10 +316,9 @@ gras_trp_buf_flush(gras_socket_t sock) {
 
   DEBUG3("Send the chunk (size=%d) to %s:%d",data->out.size,
         gras_socket_peer_name(sock),gras_socket_peer_port(sock));
 
   DEBUG3("Send the chunk (size=%d) to %s:%d",data->out.size,
         gras_socket_peer_name(sock),gras_socket_peer_port(sock));
-  TRYOLD(_buf_super->chunk_send(sock, data->out.data, data->out.size));
+  _buf_super->chunk_send(sock, data->out.data, data->out.size);
   VERB1("Chunk sent (size=%d)",data->out.size);
   if (XBT_LOG_ISENABLED(trp_buf,xbt_log_priority_debug))
      hexa_print("chunck sent    ",data->out.data,data->out.size);
   data->out.size = gras_if_RL()?0:4;
   VERB1("Chunk sent (size=%d)",data->out.size);
   if (XBT_LOG_ISENABLED(trp_buf,xbt_log_priority_debug))
      hexa_print("chunck sent    ",data->out.data,data->out.size);
   data->out.size = gras_if_RL()?0:4;
-  return no_error;
 }
 }
index 86bd04d..a85fa4b 100644 (file)
@@ -9,10 +9,7 @@
 
 #include "portable.h"
 #include "transport_private.h"
 
 #include "portable.h"
 #include "transport_private.h"
-
-#if 0
-#  include <sys/types.h>
-#endif 
+#include "xbt/ex.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(trp_file,transport,
        "Pseudo-transport to write to/read from a file");
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(trp_file,transport,
        "Pseudo-transport to write to/read from a file");
@@ -20,15 +17,15 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(trp_file,transport,
 /***
  *** Prototypes 
  ***/
 /***
  *** Prototypes 
  ***/
-void         gras_trp_file_close(gras_socket_t sd);
+void gras_trp_file_close(gras_socket_t sd);
   
   
-xbt_error_t gras_trp_file_chunk_send(gras_socket_t sd,
-                                    const char *data,
-                                    unsigned long int size);
+void gras_trp_file_chunk_send(gras_socket_t sd,
+                             const char *data,
+                             unsigned long int size);
 
 
-xbt_error_t gras_trp_file_chunk_recv(gras_socket_t sd,
-                                    char *data,
-                                    unsigned long int size);
+void gras_trp_file_chunk_recv(gras_socket_t sd,
+                             char *data,
+                             unsigned long int size);
 
 
 /***
 
 
 /***
@@ -48,7 +45,7 @@ typedef struct {
 /***
  *** Code
  ***/
 /***
  *** Code
  ***/
-xbt_error_t
+void
 gras_trp_file_setup(gras_trp_plugin_t plug) {
 
   gras_trp_file_plug_data_t *file = xbt_new(gras_trp_file_plug_data_t,1);
 gras_trp_file_setup(gras_trp_plugin_t plug) {
 
   gras_trp_file_plug_data_t *file = xbt_new(gras_trp_file_plug_data_t,1);
@@ -59,8 +56,6 @@ gras_trp_file_setup(gras_trp_plugin_t plug) {
   plug->chunk_send   = gras_trp_file_chunk_send;
   plug->chunk_recv   = gras_trp_file_chunk_recv;
   plug->data         = (void*)file;
   plug->chunk_send   = gras_trp_file_chunk_send;
   plug->chunk_recv   = gras_trp_file_chunk_recv;
   plug->data         = (void*)file;
-
-  return no_error;
 }
 
 /**
 }
 
 /**
@@ -70,40 +65,37 @@ gras_trp_file_setup(gras_trp_plugin_t plug) {
  *
  * This only possible in RL, and is mainly for debugging.
  */
  *
  * This only possible in RL, and is mainly for debugging.
  */
-xbt_error_t
-gras_socket_client_from_file(const char*path,
-                            /* OUT */ gras_socket_t *dst) {
-  xbt_error_t errcode;
-  gras_trp_plugin_t trp;
+gras_socket_t
+gras_socket_client_from_file(const char*path) {
+  gras_socket_t res;
 
   xbt_assert0(gras_if_RL(),
               "Cannot use file as socket in the simulator");
 
 
   xbt_assert0(gras_if_RL(),
               "Cannot use file as socket in the simulator");
 
-  gras_trp_socket_new(0,dst);
+  gras_trp_socket_new(0,&res);
 
 
-  TRYOLD(gras_trp_plugin_get_by_name("file",&trp));
-  (*dst)->plugin=trp;
+  res->plugin=gras_trp_plugin_get_by_name("file");
 
   if (strcmp("-", path)) {
 
   if (strcmp("-", path)) {
-    (*dst)->sd = open(path, O_WRONLY|O_CREAT | O_BINARY, S_IRUSR|S_IWUSR|S_IRGRP );
+    res->sd = open(path, O_WRONLY|O_CREAT | O_BINARY, S_IRUSR|S_IWUSR|S_IRGRP );
     
     
-    if ( (*dst)->sd < 0) {
-      RAISE2(system_error,
+    if ( res->sd < 0) {
+      THROW2(system_error,0,
             "Cannot create a client socket from file %s: %s",
             path, strerror(errno));
     }
   } else {
             "Cannot create a client socket from file %s: %s",
             path, strerror(errno));
     }
   } else {
-    (*dst)->sd = 1; /* stdout */
+    res->sd = 1; /* stdout */
   }
 
   DEBUG5("sock_client_from_file(%s): sd=%d in=%c out=%c accept=%c",
         path,
   }
 
   DEBUG5("sock_client_from_file(%s): sd=%d in=%c out=%c accept=%c",
         path,
-        (*dst)->sd,
-        (*dst)->incoming?'y':'n', 
-        (*dst)->outgoing?'y':'n',
-        (*dst)->accepting?'y':'n');
-   
-  return no_error;
+        res->sd,
+        res->incoming?'y':'n', 
+        res->outgoing?'y':'n',
+        res->accepting?'y':'n');
+
+  return res;
 }
 
 /**
 }
 
 /**
@@ -113,40 +105,36 @@ gras_socket_client_from_file(const char*path,
  *
  * This only possible in RL, and is mainly for debugging.
  */
  *
  * This only possible in RL, and is mainly for debugging.
  */
-xbt_error_t
-gras_socket_server_from_file(const char*path,
-                            /* OUT */ gras_socket_t *dst) {
-  xbt_error_t errcode;
-  gras_trp_plugin_t trp;
+gras_socket_t gras_socket_server_from_file(const char*path) {
+  gras_socket_t res;
 
   xbt_assert0(gras_if_RL(),
               "Cannot use file as socket in the simulator");
 
 
   xbt_assert0(gras_if_RL(),
               "Cannot use file as socket in the simulator");
 
-  gras_trp_socket_new(1,dst);
+  gras_trp_socket_new(1,&res);
 
 
-  TRYOLD(gras_trp_plugin_get_by_name("file",&trp));
-  (*dst)->plugin=trp;
+  res->plugin=gras_trp_plugin_get_by_name("file");
 
 
   if (strcmp("-", path)) {
 
 
   if (strcmp("-", path)) {
-    (*dst)->sd = open(path, O_RDONLY | O_BINARY);
+    res->sd = open(path, O_RDONLY | O_BINARY);
 
 
-    if ( (*dst)->sd < 0) {
-      RAISE2(system_error,
+    if ( res->sd < 0) {
+      THROW2(system_error,0,
             "Cannot create a server socket from file %s: %s",
             path, strerror(errno));
     }
   } else {
             "Cannot create a server socket from file %s: %s",
             path, strerror(errno));
     }
   } else {
-    (*dst)->sd = 0; /* stdin */
+    res->sd = 0; /* stdin */
   }
 
   DEBUG4("sd=%d in=%c out=%c accept=%c",
   }
 
   DEBUG4("sd=%d in=%c out=%c accept=%c",
-        (*dst)->sd,
-        (*dst)->incoming?'y':'n', 
-        (*dst)->outgoing?'y':'n',
-        (*dst)->accepting?'y':'n');
+        res->sd,
+        res->incoming?'y':'n', 
+        res->outgoing?'y':'n',
+        res->accepting?'y':'n');
 
 
-  return no_error;
+  return res;
 }
 
 void gras_trp_file_close(gras_socket_t sock){
 }
 
 void gras_trp_file_close(gras_socket_t sock){
@@ -178,7 +166,7 @@ void gras_trp_file_close(gras_socket_t sock){
  *
  * Send data on a file pseudo-socket
  */
  *
  * Send data on a file pseudo-socket
  */
-xbt_error_t 
+void
 gras_trp_file_chunk_send(gras_socket_t sock,
                         const char *data,
                         unsigned long int size) {
 gras_trp_file_chunk_send(gras_socket_t sock,
                         const char *data,
                         unsigned long int size) {
@@ -193,7 +181,7 @@ gras_trp_file_chunk_send(gras_socket_t sock,
     status = write(sock->sd, data, (long int)size);
     
     if (status == -1) {
     status = write(sock->sd, data, (long int)size);
     
     if (status == -1) {
-      RAISE4(system_error,"write(%d,%p,%d) failed: %s",
+      THROW4(system_error,0,"write(%d,%p,%d) failed: %s",
             sock->sd, data, (int)size,
             strerror(errno));
     }
             sock->sd, data, (int)size,
             strerror(errno));
     }
@@ -202,21 +190,19 @@ gras_trp_file_chunk_send(gras_socket_t sock,
       size  -= status;
       data  += status;
     } else {
       size  -= status;
       data  += status;
     } else {
-      RAISE0(system_error,"file descriptor closed");
+      THROW0(system_error,0,"file descriptor closed");
     }
   }
     }
   }
-
-  return no_error;
 }
 /**
  * gras_trp_file_chunk_recv:
  *
  * Receive data on a file pseudo-socket.
  */
 }
 /**
  * gras_trp_file_chunk_recv:
  *
  * Receive data on a file pseudo-socket.
  */
-xbt_error_t 
+void
 gras_trp_file_chunk_recv(gras_socket_t sock,
 gras_trp_file_chunk_recv(gras_socket_t sock,
-                       char *data,
-                       unsigned long int size) {
+                        char *data,
+                        unsigned long int size) {
 
   xbt_assert0(sock, "Cannot recv on an NULL socket");
   xbt_assert0(sock->incoming, "Cannot recv on client file socket");
 
   xbt_assert0(sock, "Cannot recv on an NULL socket");
   xbt_assert0(sock->incoming, "Cannot recv on client file socket");
@@ -229,7 +215,7 @@ gras_trp_file_chunk_recv(gras_socket_t sock,
     DEBUG3("read(%d, %p, %ld);", sock->sd, data, size);
     
     if (status == -1) {
     DEBUG3("read(%d, %p, %ld);", sock->sd, data, size);
     
     if (status == -1) {
-      RAISE4(system_error,"read(%d,%p,%d) failed: %s",
+      THROW4(system_error,0,"read(%d,%p,%d) failed: %s",
             sock->sd, data, (int)size,
             strerror(errno));
     }
             sock->sd, data, (int)size,
             strerror(errno));
     }
@@ -238,10 +224,8 @@ gras_trp_file_chunk_recv(gras_socket_t sock,
       size  -= status;
       data  += status;
     } else {
       size  -= status;
       data  += status;
     } else {
-      RAISE0(system_error,"file descriptor closed");
+      THROW0(system_error,0,"file descriptor closed");
     }
   }
     }
   }
-  
-  return no_error;
 }
 
 }
 
index bc68715..f3243a2 100644 (file)
@@ -11,6 +11,8 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "xbt/ex.h" 
+
 #include "msg/msg.h"
 
 #include "transport_private.h"
 #include "msg/msg.h"
 
 #include "transport_private.h"
@@ -25,23 +27,22 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(trp_sg,transport,"SimGrid pseudo-transport");
 void hexa_print(unsigned char *data, int size);   /* in gras.c */
 
 /* retrieve the port record associated to a numerical port on an host */
 void hexa_print(unsigned char *data, int size);   /* in gras.c */
 
 /* retrieve the port record associated to a numerical port on an host */
-static xbt_error_t find_port(gras_hostdata_t *hd, int port,
-                             gras_sg_portrec_t *hpd);
+static void find_port(gras_hostdata_t *hd, int port, gras_sg_portrec_t *hpd);
 
 
 
 
-xbt_error_t gras_trp_sg_socket_client(gras_trp_plugin_t self,
-                                      /* OUT */ gras_socket_t sock);
-xbt_error_t gras_trp_sg_socket_server(gras_trp_plugin_t self,
-                                      /* OUT */ gras_socket_t sock);
-void         gras_trp_sg_socket_close(gras_socket_t sd);
+void gras_trp_sg_socket_client(gras_trp_plugin_t self,
+                              /* OUT */ gras_socket_t sock);
+void gras_trp_sg_socket_server(gras_trp_plugin_t self,
+                              /* OUT */ gras_socket_t sock);
+void gras_trp_sg_socket_close(gras_socket_t sd);
 
 
-xbt_error_t gras_trp_sg_chunk_send(gras_socket_t sd,
-                                   const char *data,
-                                  unsigned long int size);
+void gras_trp_sg_chunk_send(gras_socket_t sd,
+                           const char *data,
+                           unsigned long int size);
 
 
-xbt_error_t gras_trp_sg_chunk_recv(gras_socket_t sd,
-                                   char *data,
-                                  unsigned long int size);
+void gras_trp_sg_chunk_recv(gras_socket_t sd,
+                           char *data,
+                           unsigned long int size);
 
 /***
  *** Specific plugin part
 
 /***
  *** Specific plugin part
@@ -54,8 +55,8 @@ typedef struct {
 /***
  *** Code
  ***/
 /***
  *** Code
  ***/
-static xbt_error_t find_port(gras_hostdata_t *hd, int port,
-                             gras_sg_portrec_t *hpd) {
+static void find_port(gras_hostdata_t *hd, int port,
+                     gras_sg_portrec_t *hpd) {
   int cpt;
   gras_sg_portrec_t pr;
 
   int cpt;
   gras_sg_portrec_t pr;
 
@@ -64,14 +65,14 @@ static xbt_error_t find_port(gras_hostdata_t *hd, int port,
   xbt_dynar_foreach(hd->ports, cpt, pr) {
     if (pr.port == port) {
       memcpy(hpd,&pr,sizeof(gras_sg_portrec_t));
   xbt_dynar_foreach(hd->ports, cpt, pr) {
     if (pr.port == port) {
       memcpy(hpd,&pr,sizeof(gras_sg_portrec_t));
-      return no_error;
+      return;
     }
   }
     }
   }
-  return mismatch_error;
+  THROW1(mismatch_error,0,"Unable to find any portrec for port #%d",port);
 }
 
 
 }
 
 
-xbt_error_t
+void
 gras_trp_sg_setup(gras_trp_plugin_t plug) {
 
   gras_trp_sg_plug_data_t *data=xbt_new(gras_trp_sg_plug_data_t,1);
 gras_trp_sg_setup(gras_trp_plugin_t plug) {
 
   gras_trp_sg_plug_data_t *data=xbt_new(gras_trp_sg_plug_data_t,1);
@@ -86,14 +87,11 @@ gras_trp_sg_setup(gras_trp_plugin_t plug) {
   plug->chunk_recv    = gras_trp_sg_chunk_recv;
 
   plug->flush         = NULL; /* nothing cached */
   plug->chunk_recv    = gras_trp_sg_chunk_recv;
 
   plug->flush         = NULL; /* nothing cached */
-
-  return no_error;
 }
 
 }
 
-xbt_error_t gras_trp_sg_socket_client(gras_trp_plugin_t self,
-                                      /* OUT */ gras_socket_t sock){
-
-  xbt_error_t errcode;
+void gras_trp_sg_socket_client(gras_trp_plugin_t self,
+                              /* OUT */ gras_socket_t sock){
+  xbt_ex_t e;
 
   m_host_t peer;
   gras_hostdata_t *hd;
 
   m_host_t peer;
   gras_hostdata_t *hd;
@@ -101,32 +99,33 @@ xbt_error_t gras_trp_sg_socket_client(gras_trp_plugin_t self,
   gras_sg_portrec_t pr;
 
   /* make sure this socket will reach someone */
   gras_sg_portrec_t pr;
 
   /* make sure this socket will reach someone */
-  if (!(peer=MSG_get_host_by_name(sock->peer_name))) {
-      fprintf(stderr,"GRAS: can't connect to %s: no such host.\n",sock->peer_name);
-      return mismatch_error;
-  }
-  if (!(hd=(gras_hostdata_t *)MSG_host_get_data(peer))) {
-    RAISE1(mismatch_error,
+  if (!(peer=MSG_get_host_by_name(sock->peer_name))) 
+    THROW1(mismatch_error,0,"Can't connect to %s: no such host.\n",sock->peer_name);
+
+  if (!(hd=(gras_hostdata_t *)MSG_host_get_data(peer))) 
+    THROW1(mismatch_error,0,
           "can't connect to %s: no process on this host",
           sock->peer_name);
           "can't connect to %s: no process on this host",
           sock->peer_name);
+  
+  TRY {
+    find_port(hd,sock->peer_port,&pr);
+  } CATCH(e) {
+    if (e.category == mismatch_error) {
+      xbt_ex_free(e);
+      THROW2(mismatch_error,0,
+            "can't connect to %s:%d, no process listen on this port",
+            sock->peer_name,sock->peer_port);
+    } 
+    RETHROW;
   }
   }
-  errcode = find_port(hd,sock->peer_port,&pr);
-  if (errcode != no_error && errcode != mismatch_error) 
-    return errcode;
-
-  if (errcode == mismatch_error) {
-    RAISE2(mismatch_error,
-          "can't connect to %s:%d, no process listen on this port",
-          sock->peer_name,sock->peer_port);
-  } 
 
   if (pr.meas && !sock->meas) {
 
   if (pr.meas && !sock->meas) {
-    RAISE2(mismatch_error,
+    THROW2(mismatch_error,0,
           "can't connect to %s:%d in regular mode, the process listen "
           "in meas mode on this port",sock->peer_name,sock->peer_port);
   }
   if (!pr.meas && sock->meas) {
           "can't connect to %s:%d in regular mode, the process listen "
           "in meas mode on this port",sock->peer_name,sock->peer_port);
   }
   if (!pr.meas && sock->meas) {
-    RAISE2(mismatch_error,
+    THROW2(mismatch_error,0,
           "can't connect to %s:%d in meas mode, the process listen "
           "in regular mode on this port",sock->peer_name,sock->peer_port);
   }
           "can't connect to %s:%d in meas mode, the process listen "
           "in regular mode on this port",sock->peer_name,sock->peer_port);
   }
@@ -145,44 +144,45 @@ xbt_error_t gras_trp_sg_socket_client(gras_trp_plugin_t self,
          MSG_process_get_name(MSG_process_self()), MSG_process_self_PID(),
          sock->meas?"meas":"regular",
         sock->peer_name,sock->peer_port,data->to_PID);
          MSG_process_get_name(MSG_process_self()), MSG_process_self_PID(),
          sock->meas?"meas":"regular",
         sock->peer_name,sock->peer_port,data->to_PID);
-
-  return no_error;
 }
 
 }
 
-xbt_error_t gras_trp_sg_socket_server(gras_trp_plugin_t self,
-                                      gras_socket_t sock){
-
-  xbt_error_t errcode;
+void gras_trp_sg_socket_server(gras_trp_plugin_t self,
+                              gras_socket_t sock){
 
   gras_hostdata_t *hd=(gras_hostdata_t *)MSG_host_get_data(MSG_host_self());
   gras_trp_procdata_t pd=(gras_trp_procdata_t)gras_libdata_get("gras_trp");
   gras_sg_portrec_t pr;
   gras_trp_sg_sock_data_t *data;
 
   gras_hostdata_t *hd=(gras_hostdata_t *)MSG_host_get_data(MSG_host_self());
   gras_trp_procdata_t pd=(gras_trp_procdata_t)gras_libdata_get("gras_trp");
   gras_sg_portrec_t pr;
   gras_trp_sg_sock_data_t *data;
+  int found;
   
   const char *host=MSG_host_get_name(MSG_host_self());
 
   
   const char *host=MSG_host_get_name(MSG_host_self());
 
+  xbt_ex_t e;
+
   xbt_assert0(hd,"Please run gras_process_init on each process");
 
   sock->accepting = 0; /* no such nuisance in SG */
 
   xbt_assert0(hd,"Please run gras_process_init on each process");
 
   sock->accepting = 0; /* no such nuisance in SG */
 
-  errcode = find_port(hd,sock->port,&pr);
-  switch (errcode) {
-  case no_error: /* Port already used... */
-    RAISE2(mismatch_error,
-          "can't listen on address %s:%d: port already in use\n.",
-          host,sock->port);
-    break;
-
-  case mismatch_error: /* Port not used so far. Do it */
-    pr.tochan = sock->meas ? pd->measChan : pd->chan;
-    pr.port   = sock->port;
-    pr.meas    = sock->meas;
-    xbt_dynar_push(hd->ports,&pr);
-    break;
-    
-  default:
-    return errcode;
+  found = 0;
+  TRY {
+    find_port(hd,sock->port,&pr);
+    found = 1;
+  } CATCH(e) {
+    if (e.category == mismatch_error)
+      xbt_ex_free(e);
+    else
+      RETHROW;
   }
   }
+   
+  if (found) 
+    THROW2(mismatch_error,0,
+          "can't listen on address %s:%d: port already in use.",
+          host,sock->port);
+
+  pr.tochan = sock->meas ? pd->measChan : pd->chan;
+  pr.port   = sock->port;
+  pr.meas    = sock->meas;
+  xbt_dynar_push(hd->ports,&pr);
   
   /* Create the socket */
   data = xbt_new(gras_trp_sg_sock_data_t,1);
   
   /* Create the socket */
   data = xbt_new(gras_trp_sg_sock_data_t,1);
@@ -196,8 +196,6 @@ xbt_error_t gras_trp_sg_socket_server(gras_trp_plugin_t self,
   VERB6("'%s' (%d) ears on %s:%d%s (%p)",
     MSG_process_get_name(MSG_process_self()), MSG_process_self_PID(),
     host,sock->port,sock->meas? " (mode meas)":"",sock);
   VERB6("'%s' (%d) ears on %s:%d%s (%p)",
     MSG_process_get_name(MSG_process_self()), MSG_process_self_PID(),
     host,sock->port,sock->meas? " (mode meas)":"",sock);
-
-  return no_error;
 }
 
 void gras_trp_sg_socket_close(gras_socket_t sock){
 }
 
 void gras_trp_sg_socket_close(gras_socket_t sock){
@@ -235,9 +233,9 @@ typedef struct {
   void *data;
 } sg_task_data_t;
 
   void *data;
 } sg_task_data_t;
 
-xbt_error_t gras_trp_sg_chunk_send(gras_socket_t sock,
-                                   const char *data,
-                                  unsigned long int size) {
+void gras_trp_sg_chunk_send(gras_socket_t sock,
+                           const char *data,
+                           unsigned long int size) {
   m_task_t task=NULL;
   static unsigned int count=0;
   char name[256];
   m_task_t task=NULL;
   static unsigned int count=0;
   char name[256];
@@ -257,15 +255,13 @@ xbt_error_t gras_trp_sg_chunk_send(gras_socket_t sock,
         name, MSG_host_get_name(MSG_host_self()),
         MSG_host_get_name(sock_data->to_host), sock_data->to_chan,size);
   if (MSG_task_put(task, sock_data->to_host,sock_data->to_chan) != MSG_OK) {
         name, MSG_host_get_name(MSG_host_self()),
         MSG_host_get_name(sock_data->to_host), sock_data->to_chan,size);
   if (MSG_task_put(task, sock_data->to_host,sock_data->to_chan) != MSG_OK) {
-    RAISE0(system_error,"Problem during the MSG_task_put");
+    THROW0(system_error,0,"Problem during the MSG_task_put");
   }
   }
-
-  return no_error;
 }
 
 }
 
-xbt_error_t gras_trp_sg_chunk_recv(gras_socket_t sock,
-                                   char *data,
-                                  unsigned long int size){
+void gras_trp_sg_chunk_recv(gras_socket_t sock,
+                           char *data,
+                           unsigned long int size){
   gras_trp_procdata_t pd=(gras_trp_procdata_t)gras_libdata_get("gras_trp");
 
   m_task_t task=NULL;
   gras_trp_procdata_t pd=(gras_trp_procdata_t)gras_libdata_get("gras_trp");
 
   m_task_t task=NULL;
@@ -277,13 +273,13 @@ xbt_error_t gras_trp_sg_chunk_recv(gras_socket_t sock,
         MSG_host_get_name(sock_data->to_host),
         MSG_host_get_name(MSG_host_self()), sock_data->to_chan, size);
   if (MSG_task_get(&task, (sock->meas ? pd->measChan : pd->chan)) != MSG_OK)
         MSG_host_get_name(sock_data->to_host),
         MSG_host_get_name(MSG_host_self()), sock_data->to_chan, size);
   if (MSG_task_get(&task, (sock->meas ? pd->measChan : pd->chan)) != MSG_OK)
-    RAISE0(unknown_error,"Error in MSG_task_get()");
+    THROW0(system_error,0,"Error in MSG_task_get()");
   DEBUG1("Got chuck %s",MSG_task_get_name(task));
 
   task_data = MSG_task_get_data(task);
   if (size != -1) {    
      if (task_data->size != size)
   DEBUG1("Got chuck %s",MSG_task_get_name(task));
 
   task_data = MSG_task_get_data(task);
   if (size != -1) {    
      if (task_data->size != size)
-       RAISE5(mismatch_error,
+       THROW5(mismatch_error,0,
              "Got %d bytes when %ld where expected (in %s->%s:%d)",
              task_data->size, size,
              MSG_host_get_name(sock_data->to_host),
              "Got %d bytes when %ld where expected (in %s->%s:%d)",
              task_data->size, size,
              MSG_host_get_name(sock_data->to_host),
@@ -302,10 +298,9 @@ xbt_error_t gras_trp_sg_chunk_recv(gras_socket_t sock,
   free(task_data);
 
   if (MSG_task_destroy(task) != MSG_OK)
   free(task_data);
 
   if (MSG_task_destroy(task) != MSG_OK)
-    RAISE0(unknown_error,"Error in MSG_task_destroy()");
+    THROW0(system_error,0,"Error in MSG_task_destroy()");
 
   XBT_OUT;
 
   XBT_OUT;
-  return no_error;
 }
 
 #if 0
 }
 
 #if 0
index 2122896..51f44fa 100644 (file)
@@ -8,7 +8,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "portable.h"
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "portable.h"
-
+#include "xbt/ex.h"
 #if 0
 #  include <signal.h>       /* close() pipe() read() write() */
 #  include <sys/wait.h>     /* waitpid() */
 #if 0
 #  include <signal.h>       /* close() pipe() read() write() */
 #  include <sys/wait.h>     /* waitpid() */
@@ -22,22 +22,19 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(trp_tcp,transport,"TCP transport");
 /***
  *** Prototypes 
  ***/
 /***
  *** Prototypes 
  ***/
-xbt_error_t gras_trp_tcp_socket_client(gras_trp_plugin_t self,
-                                       gras_socket_t sock);
-xbt_error_t gras_trp_tcp_socket_server(gras_trp_plugin_t self,
-                                       gras_socket_t sock);
-xbt_error_t gras_trp_tcp_socket_accept(gras_socket_t  sock,
-                                       gras_socket_t *dst);
-
-void         gras_trp_tcp_socket_close(gras_socket_t sd);
+void gras_trp_tcp_socket_client(gras_trp_plugin_t self, gras_socket_t sock);
+void gras_trp_tcp_socket_server(gras_trp_plugin_t self, gras_socket_t sock);
+gras_socket_t gras_trp_tcp_socket_accept(gras_socket_t  sock);
+
+void          gras_trp_tcp_socket_close(gras_socket_t sd);
   
   
-xbt_error_t gras_trp_tcp_chunk_send(gras_socket_t sd,
-                                   const char *data,
-                                   unsigned long int size);
+void gras_trp_tcp_chunk_send(gras_socket_t sd,
+                            const char *data,
+                            unsigned long int size);
 
 
-xbt_error_t gras_trp_tcp_chunk_recv(gras_socket_t sd,
-                                   char *data,
-                                   unsigned long int size);
+void gras_trp_tcp_chunk_recv(gras_socket_t sd,
+                            char *data,
+                            unsigned long int size);
 
 void gras_trp_tcp_exit(gras_trp_plugin_t plug);
 
 
 void gras_trp_tcp_exit(gras_trp_plugin_t plug);
 
@@ -64,7 +61,7 @@ typedef struct {
 /***
  *** Code
  ***/
 /***
  *** Code
  ***/
-xbt_error_t gras_trp_tcp_setup(gras_trp_plugin_t plug) {
+void gras_trp_tcp_setup(gras_trp_plugin_t plug) {
 
   gras_trp_tcp_plug_data_t *data = xbt_new(gras_trp_tcp_plug_data_t,1);
 
 
   gras_trp_tcp_plug_data_t *data = xbt_new(gras_trp_tcp_plug_data_t,1);
 
@@ -83,8 +80,6 @@ xbt_error_t gras_trp_tcp_setup(gras_trp_plugin_t plug) {
 
   plug->data = (void*)data;
   plug->exit = gras_trp_tcp_exit;
 
   plug->data = (void*)data;
   plug->exit = gras_trp_tcp_exit;
-   
-  return no_error;
 }
 
 void gras_trp_tcp_exit(gras_trp_plugin_t plug) {
 }
 
 void gras_trp_tcp_exit(gras_trp_plugin_t plug) {
@@ -92,8 +87,7 @@ void gras_trp_tcp_exit(gras_trp_plugin_t plug) {
   free(plug->data);
 }
 
   free(plug->data);
 }
 
-xbt_error_t gras_trp_tcp_socket_client(gras_trp_plugin_t self,
-                                       gras_socket_t sock){
+void gras_trp_tcp_socket_client(gras_trp_plugin_t self, gras_socket_t sock){
   
   struct sockaddr_in addr;
   struct hostent *he;
   
   struct sockaddr_in addr;
   struct hostent *he;
@@ -105,9 +99,7 @@ xbt_error_t gras_trp_tcp_socket_client(gras_trp_plugin_t self,
   sock->sd = socket (AF_INET, SOCK_STREAM, 0);
   
   if (sock->sd < 0) {
   sock->sd = socket (AF_INET, SOCK_STREAM, 0);
   
   if (sock->sd < 0) {
-    RAISE1(system_error,
-          "Failed to create socket: %s",
-          sock_errstr);
+    THROW1(system_error,0, "Failed to create socket: %s", sock_errstr);
   }
 
   if (setsockopt(sock->sd, SOL_SOCKET, SO_RCVBUF, (char *)&size, sizeof(size)) ||
   }
 
   if (setsockopt(sock->sd, SOL_SOCKET, SO_RCVBUF, (char *)&size, sizeof(size)) ||
@@ -117,8 +109,7 @@ xbt_error_t gras_trp_tcp_socket_client(gras_trp_plugin_t self,
   
   he = gethostbyname (sock->peer_name);
   if (he == NULL) {
   
   he = gethostbyname (sock->peer_name);
   if (he == NULL) {
-    RAISE2(system_error,
-          "Failed to lookup hostname %s: %s",
+    THROW2(system_error,0, "Failed to lookup hostname %s: %s",
           sock->peer_name, sock_errstr);
   }
   
           sock->peer_name, sock_errstr);
   }
   
@@ -131,13 +122,11 @@ xbt_error_t gras_trp_tcp_socket_client(gras_trp_plugin_t self,
 
   if (connect (sock->sd, (struct sockaddr*) &addr, sizeof (addr)) < 0) {
     tcp_close(sock->sd);
 
   if (connect (sock->sd, (struct sockaddr*) &addr, sizeof (addr)) < 0) {
     tcp_close(sock->sd);
-    RAISE3(system_error,
+    THROW3(system_error,0,
           "Failed to connect socket to %s:%d (%s)",
           sock->peer_name, sock->peer_port, sock_errstr);
   }
   VERB4("Connect to %s:%d (sd=%d, port %d here)",sock->peer_name, sock->peer_port, sock->sd, sock->port);
           "Failed to connect socket to %s:%d (%s)",
           sock->peer_name, sock->peer_port, sock_errstr);
   }
   VERB4("Connect to %s:%d (sd=%d, port %d here)",sock->peer_name, sock->peer_port, sock->sd, sock->port);
-   
-  return no_error;
 }
 
 /**
 }
 
 /**
@@ -145,8 +134,7 @@ xbt_error_t gras_trp_tcp_socket_client(gras_trp_plugin_t self,
  *
  * Open a socket used to receive messages.
  */
  *
  * Open a socket used to receive messages.
  */
-xbt_error_t gras_trp_tcp_socket_server(gras_trp_plugin_t self,
-                                       /* OUT */ gras_socket_t sock){
+void gras_trp_tcp_socket_server(gras_trp_plugin_t self, gras_socket_t sock){
   int size = sock->bufSize * 1024; 
   int on = 1;
   struct sockaddr_in server;
   int size = sock->bufSize * 1024; 
   int on = 1;
   struct sockaddr_in server;
@@ -158,14 +146,12 @@ xbt_error_t gras_trp_tcp_socket_server(gras_trp_plugin_t self,
   server.sin_port = htons((u_short)sock->port);
   server.sin_addr.s_addr = INADDR_ANY;
   server.sin_family = AF_INET;
   server.sin_port = htons((u_short)sock->port);
   server.sin_addr.s_addr = INADDR_ANY;
   server.sin_family = AF_INET;
-  if((sock->sd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
-    RAISE1(system_error,"Socket allocation failed: %s", sock_errstr);
-  }
+  if((sock->sd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
+    THROW1(system_error,0,"Socket allocation failed: %s", sock_errstr);
 
 
-  if (setsockopt(sock->sd, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on))) {
-     RAISE1(system_error,"setsockopt failed, cannot condition the socket: %s",
+  if (setsockopt(sock->sd, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)))
+     THROW1(system_error,0,"setsockopt failed, cannot condition the socket: %s",
            sock_errstr);
            sock_errstr);
-  }
    
   if (setsockopt(sock->sd, SOL_SOCKET, SO_RCVBUF, (char *)&size, sizeof(size)) ||
       setsockopt(sock->sd, SOL_SOCKET, SO_SNDBUF, (char *)&size, sizeof(size))) {
    
   if (setsockopt(sock->sd, SOL_SOCKET, SO_RCVBUF, (char *)&size, sizeof(size)) ||
       setsockopt(sock->sd, SOL_SOCKET, SO_SNDBUF, (char *)&size, sizeof(size))) {
@@ -175,13 +161,13 @@ xbt_error_t gras_trp_tcp_socket_server(gras_trp_plugin_t self,
        
   if (bind(sock->sd, (struct sockaddr *)&server, sizeof(server)) == -1) {
     tcp_close(sock->sd);
        
   if (bind(sock->sd, (struct sockaddr *)&server, sizeof(server)) == -1) {
     tcp_close(sock->sd);
-    RAISE2(system_error,"Cannot bind to port %d: %s",sock->port, sock_errstr);
+    THROW2(system_error,0,"Cannot bind to port %d: %s",sock->port, sock_errstr);
   }
 
   DEBUG2("Listen on port %d (sd=%d)",sock->port, sock->sd);
   if (listen(sock->sd, 5) < 0) {
     tcp_close(sock->sd);
   }
 
   DEBUG2("Listen on port %d (sd=%d)",sock->port, sock->sd);
   if (listen(sock->sd, 5) < 0) {
     tcp_close(sock->sd);
-    RAISE2(system_error,"Cannot listen on port %d: %s",sock->port,sock_errstr);
+    THROW2(system_error,0,"Cannot listen on port %d: %s",sock->port,sock_errstr);
   }
 
   if (sock->meas)
   }
 
   if (sock->meas)
@@ -190,13 +176,9 @@ xbt_error_t gras_trp_tcp_socket_server(gras_trp_plugin_t self,
     FD_SET(sock->sd, &(tcp->msg_socks));
 
   VERB2("Openned a server socket on port %d (sd=%d)",sock->port,sock->sd);
     FD_SET(sock->sd, &(tcp->msg_socks));
 
   VERB2("Openned a server socket on port %d (sd=%d)",sock->port,sock->sd);
-  
-  return no_error;
 }
 
 }
 
-xbt_error_t
-gras_trp_tcp_socket_accept(gras_socket_t  sock,
-                          gras_socket_t *dst) {
+gras_socket_t gras_trp_tcp_socket_accept(gras_socket_t  sock) {
   gras_socket_t res;
   
   struct sockaddr_in peer_in;
   gras_socket_t res;
   
   struct sockaddr_in peer_in;
@@ -205,6 +187,9 @@ gras_trp_tcp_socket_accept(gras_socket_t  sock,
   int sd;
   int tmp_errno;
   int size;
   int sd;
   int tmp_errno;
   int size;
+
+  int i = 1;
+  socklen_t s = sizeof(int);
                
   XBT_IN;
   gras_trp_socket_new(1,&res);
                
   XBT_IN;
   gras_trp_socket_new(1,&res);
@@ -214,58 +199,50 @@ gras_trp_tcp_socket_accept(gras_socket_t  sock,
 
   if (sd == -1) {
     gras_socket_close(sock);
 
   if (sd == -1) {
     gras_socket_close(sock);
-    RAISE1(system_error,
+    THROW1(system_error,0,
           "Accept failed (%s). Droping server socket.", sock_errstr);
           "Accept failed (%s). Droping server socket.", sock_errstr);
-  } else {
-    int i = 1;
-    socklen_t s = sizeof(int);
+  }
   
   
-    if (setsockopt(sd, SOL_SOCKET, SO_KEEPALIVE, (char *)&i, s) 
-       || setsockopt(sd, TcpProtoNumber(), TCP_NODELAY, (char *)&i, s)) {
-       RAISE1(system_error,"setsockopt failed, cannot condition the socket: %s",
-             sock_errstr);
-    }
+  if (setsockopt(sd, SOL_SOCKET, SO_KEEPALIVE, (char *)&i, s) 
+      || setsockopt(sd, TcpProtoNumber(), TCP_NODELAY, (char *)&i, s))
+    THROW1(system_error,0,"setsockopt failed, cannot condition the socket: %s",
+          sock_errstr);
 
 
-    res->bufSize = sock->bufSize;
-    size = sock->bufSize * 1024;
-    if (setsockopt(sd, SOL_SOCKET, SO_RCVBUF, (char *)&size, sizeof(size))
-       || setsockopt(sd, SOL_SOCKET, SO_SNDBUF, (char *)&size, sizeof(size))) {
-       WARN1("setsockopt failed, cannot set buffer size: %s",
-            sock_errstr);
-    }
+  res->bufSize = sock->bufSize;
+  size = sock->bufSize * 1024;
+  if (setsockopt(sd, SOL_SOCKET, SO_RCVBUF, (char *)&size, sizeof(size))
+      || setsockopt(sd, SOL_SOCKET, SO_SNDBUF, (char *)&size, sizeof(size)))
+    WARN1("setsockopt failed, cannot set buffer size: %s", sock_errstr);
      
      
-    res->plugin    = sock->plugin;
-    res->incoming  = sock->incoming;
-    res->outgoing  = sock->outgoing;
-    res->accepting = 0;
-    res->sd        = sd;
-    res->port      = -1;
-    res->peer_port = peer_in.sin_port;
-
-    /* FIXME: Lock to protect inet_ntoa */
-    if (((struct sockaddr *)&peer_in)->sa_family != AF_INET) {
-      res->peer_name = (char*)strdup("unknown");
+  res->plugin    = sock->plugin;
+  res->incoming  = sock->incoming;
+  res->outgoing  = sock->outgoing;
+  res->accepting = 0;
+  res->sd        = sd;
+  res->port      = -1;
+  res->peer_port = peer_in.sin_port;
+
+  /* FIXME: Lock to protect inet_ntoa */
+  if (((struct sockaddr *)&peer_in)->sa_family != AF_INET) {
+    res->peer_name = (char*)strdup("unknown");
+  } else {
+    struct in_addr addrAsInAddr;
+    char *tmp;
+    
+    addrAsInAddr.s_addr = peer_in.sin_addr.s_addr;
+    
+    tmp = inet_ntoa(addrAsInAddr);
+    if (tmp != NULL) {
+      res->peer_name = (char*)strdup(tmp);
     } else {
     } else {
-      struct in_addr addrAsInAddr;
-      char *tmp;
-      addrAsInAddr.s_addr = peer_in.sin_addr.s_addr;
-      
-      tmp = inet_ntoa(addrAsInAddr);
-      if (tmp != NULL) {
-       res->peer_name = (char*)strdup(tmp);
-      } else {
-       res->peer_name = (char*)strdup("unknown");
-      }
+      res->peer_name = (char*)strdup("unknown");
     }
     }
-
-    VERB3("Accepted from %s:%d (sd=%d)", res->peer_name,res->peer_port,sd);
-    
-    *dst = res;
-
-    XBT_OUT;
-    return no_error;
   }
   }
+  
+  VERB3("Accepted from %s:%d (sd=%d)", res->peer_name,res->peer_port,sd);
+  
+  XBT_OUT;
+  return res;
 }
 
 void gras_trp_tcp_socket_close(gras_socket_t sock){
 }
 
 void gras_trp_tcp_socket_close(gras_socket_t sock){
@@ -314,7 +291,7 @@ void gras_trp_tcp_socket_close(gras_socket_t sock){
  *
  * Send data on a TCP socket
  */
  *
  * Send data on a TCP socket
  */
-xbt_error_t 
+void
 gras_trp_tcp_chunk_send(gras_socket_t sock,
                        const char *data,
                        unsigned long int size) {
 gras_trp_tcp_chunk_send(gras_socket_t sock,
                        const char *data,
                        unsigned long int size) {
@@ -329,7 +306,7 @@ gras_trp_tcp_chunk_send(gras_socket_t sock,
     DEBUG3("write(%d, %p, %ld);", sock->sd, data, size);
     
     if (status < 0) {
     DEBUG3("write(%d, %p, %ld);", sock->sd, data, size);
     
     if (status < 0) {
-      RAISE4(system_error,"write(%d,%p,%ld) failed: %s",
+      THROW4(system_error,0,"write(%d,%p,%ld) failed: %s",
             sock->sd, data, size,
             sock_errstr);
     }
             sock->sd, data, size,
             sock_errstr);
     }
@@ -338,19 +315,17 @@ gras_trp_tcp_chunk_send(gras_socket_t sock,
       size  -= status;
       data  += status;
     } else {
       size  -= status;
       data  += status;
     } else {
-      RAISE1(system_error,"file descriptor closed (%s)",
+      THROW1(system_error,0,"file descriptor closed (%s)",
              sock_errstr);
     }
   }
              sock_errstr);
     }
   }
-
-  return no_error;
 }
 /**
  * gras_trp_tcp_chunk_recv:
  *
  * Receive data on a TCP socket.
  */
 }
 /**
  * gras_trp_tcp_chunk_recv:
  *
  * Receive data on a TCP socket.
  */
-xbt_error_t 
+void
 gras_trp_tcp_chunk_recv(gras_socket_t sock,
                        char *data,
                        unsigned long int size) {
 gras_trp_tcp_chunk_recv(gras_socket_t sock,
                        char *data,
                        unsigned long int size) {
@@ -366,7 +341,7 @@ gras_trp_tcp_chunk_recv(gras_socket_t sock,
     status = tcp_read(sock->sd, data, (size_t)size);
     
     if (status < 0) {
     status = tcp_read(sock->sd, data, (size_t)size);
     
     if (status < 0) {
-      RAISE4(system_error,"read(%d,%p,%d) failed: %s",
+      THROW4(system_error,0,"read(%d,%p,%d) failed: %s",
             sock->sd, data, (int)size,
             sock_errstr);
     }
             sock->sd, data, (int)size,
             sock_errstr);
     }
@@ -375,12 +350,11 @@ gras_trp_tcp_chunk_recv(gras_socket_t sock,
       size  -= status;
       data  += status;
     } else {
       size  -= status;
       data  += status;
     } else {
-      RAISE3(system_error,"file descriptor closed (nothing read(%d, %p, %ld) on the socket)",
+      THROW3(system_error,0,
+            "file descriptor closed (nothing read(%d, %p, %ld) on the socket)",
              sock->sd, data, size);
     }
   }
              sock->sd, data, size);
     }
   }
-  
-  return no_error;
 }
 
 
 }
 
 
index dae72ff..6d3857f 100644 (file)
@@ -58,12 +58,12 @@ void gras_trp_socket_new(int incomming,
                         gras_socket_t *dst);
 
 /* The drivers */
                         gras_socket_t *dst);
 
 /* The drivers */
-typedef xbt_error_t (*gras_trp_setup_t)(gras_trp_plugin_t dst);
+typedef void (*gras_trp_setup_t)(gras_trp_plugin_t dst);
 
 
-xbt_error_t gras_trp_tcp_setup(gras_trp_plugin_t plug);
-xbt_error_t gras_trp_file_setup(gras_trp_plugin_t plug);
-xbt_error_t gras_trp_sg_setup(gras_trp_plugin_t plug);
-xbt_error_t gras_trp_buf_setup(gras_trp_plugin_t plug);
+void gras_trp_tcp_setup(gras_trp_plugin_t plug);
+void gras_trp_file_setup(gras_trp_plugin_t plug);
+void gras_trp_sg_setup(gras_trp_plugin_t plug);
+void gras_trp_buf_setup(gras_trp_plugin_t plug);
 
 /*
 
 
 /*
 
index 31732a3..e61fa71 100644 (file)
@@ -7,6 +7,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "xbt/ex.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
 #include "xbt/error.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
 #include "xbt/error.h"
@@ -72,13 +73,13 @@ void gras_userdata_set(void *ud) {
 void *gras_libdata_get(const char *name) {
   gras_procdata_t *pd=gras_procdata_get();
   void *res;
 void *gras_libdata_get(const char *name) {
   gras_procdata_t *pd=gras_procdata_get();
   void *res;
-  xbt_error_t errcode;
-   
-  errcode = xbt_dict_get(pd->libdata, name, &res);
-  xbt_assert2(errcode == no_error, 
-             "Cannot retrive the libdata associated to %s: %s",
-             name, xbt_error_name(errcode));
+  xbt_ex_t e;
    
    
+  TRY {
+    res = xbt_dict_get(pd->libdata, name);
+  } CATCH(e) {
+    RETHROW1("Cannot retrive the libdata associated to %s: %s",name);
+  }   
   return res;
 }
 
   return res;
 }
 
@@ -89,24 +90,29 @@ gras_procdata_init() {
    
   int cursor;
    
    
   int cursor;
    
-  xbt_error_t errcode;
+  xbt_ex_t e;
   void *data;
 
   pd->userdata  = NULL;
   pd->libdata   = xbt_dict_new();
    
   xbt_dynar_foreach(_gras_procdata_fabrics,cursor,fab){
   void *data;
 
   pd->userdata  = NULL;
   pd->libdata   = xbt_dict_new();
    
   xbt_dynar_foreach(_gras_procdata_fabrics,cursor,fab){
+    int found = 0;
      
      
-     xbt_assert1(fab.name,"Name of fabric #%d is NULL!",cursor);
-     DEBUG1("Create the procdata for %s",fab.name);
-     /* Check for our own errors */
-     errcode = xbt_dict_get(pd->libdata, fab.name, &data);
-     xbt_assert1(errcode == mismatch_error,
-                "MayDay: two modules use '%s' as libdata name", fab.name);
-     
-     /* Add the data in place */
-     xbt_dict_set(pd->libdata, fab.name, (fab.creator)(), fab.destructor);
-
+    xbt_assert1(fab.name,"Name of fabric #%d is NULL!",cursor);
+    DEBUG1("Create the procdata for %s",fab.name);
+    /* Check for our own errors */
+    TRY {
+      data = xbt_dict_get(pd->libdata, fab.name);
+      found = 1;
+    } CATCH(e) {
+      xbt_ex_free(e);
+    }
+    xbt_assert1(!found,
+               "MayDay: two modules use '%s' as libdata name", fab.name);
+    
+    /* Add the data in place */
+    xbt_dict_set(pd->libdata, fab.name, (fab.creator)(), fab.destructor);
   }
 }
 
   }
 }
 
index 922f227..c6b8d3c 100644 (file)
@@ -11,7 +11,7 @@
 #include "gras/Virtu/virtu_rl.h"
 #include "gras_modinter.h"
 
 #include "gras/Virtu/virtu_rl.h"
 #include "gras_modinter.h"
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(emul,gras,"Emulation support");
+XBT_LOG_NEW_SUBCATEGORY(emul,gras,"Emulation support");
 
 /*** Timing macros: nothing to do in RL. Actually do the job and shutup ***/
 
 
 /*** Timing macros: nothing to do in RL. Actually do the job and shutup ***/
 
index f30aa38..6f1ebe5 100644 (file)
@@ -18,15 +18,13 @@ XBT_LOG_DEFAULT_CATEGORY(process);
 static gras_procdata_t *_gras_procdata = NULL;
 char const *_gras_procname = NULL;
 
 static gras_procdata_t *_gras_procdata = NULL;
 char const *_gras_procname = NULL;
 
-xbt_error_t gras_process_init() {
+void gras_process_init() {
   _gras_procdata=xbt_new(gras_procdata_t,1);
   gras_procdata_init();
   _gras_procdata=xbt_new(gras_procdata_t,1);
   gras_procdata_init();
-  return no_error;
 }
 }
-xbt_error_t gras_process_exit() {
+void gras_process_exit() {
   gras_procdata_exit();
   free(_gras_procdata);
   gras_procdata_exit();
   free(_gras_procdata);
-  return no_error;
 }
 
 const char *xbt_procname(void) {
 }
 
 const char *xbt_procname(void) {
index e2255f4..127cfbe 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "xbt/xbt_portability.h" /* timers */
 #include "xbt/dict.h"
 
 #include "xbt/xbt_portability.h" /* timers */
 #include "xbt/dict.h"
+#include "xbt/ex.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(emul,gras,"Emulation support");
 
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(emul,gras,"Emulation support");
 
@@ -43,9 +44,19 @@ void gras_emul_exit(void) {
 
 static void store_in_dict(xbt_dict_t dict, const char *key, double value)
 {
 
 static void store_in_dict(xbt_dict_t dict, const char *key, double value)
 {
-  double *ir = NULL;
-
-  xbt_dict_get(dict, key, (void *) &ir);
+  double *ir;
+  xbt_ex_t e;
+
+  TRY {
+    ir = xbt_dict_get(dict, key);
+  } CATCH(e) {
+    if (e.category == mismatch_error) {
+      ir = NULL;
+      xbt_ex_free(e);
+    } else {
+      RETHROW;
+    }
+  }
   if (!ir) {
     ir = xbt_new0(double,1);
     xbt_dict_set(dict, key, ir, free);
   if (!ir) {
     ir = xbt_new0(double,1);
     xbt_dict_set(dict, key, ir, free);
@@ -53,11 +64,8 @@ static void store_in_dict(xbt_dict_t dict, const char *key, double value)
   *ir = value;
 }
 
   *ir = value;
 }
 
-static double get_from_dict(xbt_dict_t dict, const char *key)
-{
-  double *ir = NULL;
-
-  xbt_dict_get(dict, key, (void *) &ir);
+static double get_from_dict(xbt_dict_t dict, const char *key) {
+  double *ir = xbt_dict_get(dict, key);
 
   return *ir;
 }
 
   return *ir;
 }
@@ -86,9 +94,9 @@ int gras_bench_always_end(void)
   return 0;
 }
 
   return 0;
 }
 
-int gras_bench_once_begin(const char *location,int line)
-{
+int gras_bench_once_begin(const char *location,int line) { 
   double *ir = NULL;
   double *ir = NULL;
+  xbt_ex_t e;
   xbt_assert0(!benchmarking,"Already benchmarking");
   benchmarking = 1;
 
   xbt_assert0(!benchmarking,"Already benchmarking");
   benchmarking = 1;
 
@@ -98,7 +106,16 @@ int gras_bench_once_begin(const char *location,int line)
   }
   sprintf(locbuf,"%s:%d",location, line);
    
   }
   sprintf(locbuf,"%s:%d",location, line);
    
-  xbt_dict_get(benchmark_set, locbuf, (void *) &ir);
+  TRY {
+    ir = xbt_dict_get(benchmark_set, locbuf);
+  } CATCH(e) {
+    if (e.category == mismatch_error) {
+      xbt_ex_free(e);
+      ir = NULL;
+    } else {
+      RETHROW;
+    }
+  }
   if(!ir) {
     DEBUG1("%s",locbuf); 
     duration = 1;
   if(!ir) {
     DEBUG1("%s",locbuf); 
     duration = 1;
index 2819434..6432e9e 100644 (file)
@@ -7,6 +7,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "xbt/ex.h"
 #include "gras_modinter.h" /* module initialization interface */
 #include "gras/Virtu/virtu_sg.h"
 #include "gras/Msg/msg_interface.h" /* For some checks at simulation end */
 #include "gras_modinter.h" /* module initialization interface */
 #include "gras/Virtu/virtu_sg.h"
 #include "gras/Msg/msg_interface.h" /* For some checks at simulation end */
@@ -15,9 +16,8 @@
 XBT_LOG_EXTERNAL_CATEGORY(process);
 XBT_LOG_DEFAULT_CATEGORY(process);
 
 XBT_LOG_EXTERNAL_CATEGORY(process);
 XBT_LOG_DEFAULT_CATEGORY(process);
 
-xbt_error_t
+void
 gras_process_init() {
 gras_process_init() {
-  xbt_error_t errcode;
   gras_hostdata_t *hd=(gras_hostdata_t *)MSG_host_get_data(MSG_host_self());
   gras_procdata_t *pd=xbt_new(gras_procdata_t,1);
   gras_trp_procdata_t trp_pd;
   gras_hostdata_t *hd=(gras_hostdata_t *)MSG_host_get_data(MSG_host_self());
   gras_procdata_t *pd=xbt_new(gras_procdata_t,1);
   gras_trp_procdata_t trp_pd;
@@ -25,7 +25,7 @@ gras_process_init() {
   int i;
   
   if (MSG_process_set_data(MSG_process_self(),(void*)pd) != MSG_OK)
   int i;
   
   if (MSG_process_set_data(MSG_process_self(),(void*)pd) != MSG_OK)
-    return unknown_error;
+    THROW0(system_error,0,"Error in MSG_process_set_data()");
    
   gras_procdata_init();
 
    
   gras_procdata_init();
 
@@ -37,15 +37,15 @@ gras_process_init() {
     memset(hd->proc, 0, sizeof(hd->proc[0]) * XBT_MAX_CHANNEL); 
 
     if (MSG_host_set_data(MSG_host_self(),(void*)hd) != MSG_OK)
     memset(hd->proc, 0, sizeof(hd->proc[0]) * XBT_MAX_CHANNEL); 
 
     if (MSG_host_set_data(MSG_host_self(),(void*)hd) != MSG_OK)
-      return unknown_error;
+      THROW0(system_error,0,"Error in MSG_host_set_data()");
   }
   
   /* take a free channel for this process */
   trp_pd = (gras_trp_procdata_t)gras_libdata_get("gras_trp");
   for (i=0; i<XBT_MAX_CHANNEL && hd->proc[i]; i++);
   if (i == XBT_MAX_CHANNEL) 
   }
   
   /* take a free channel for this process */
   trp_pd = (gras_trp_procdata_t)gras_libdata_get("gras_trp");
   for (i=0; i<XBT_MAX_CHANNEL && hd->proc[i]; i++);
   if (i == XBT_MAX_CHANNEL) 
-    RAISE2(system_error,
-          "GRAS: Can't add a new process on %s, because all channel are already in use. Please increase MAX CHANNEL (which is %d for now) and recompile GRAS\n.",
+    THROW2(system_error,0,
+          "Can't add a new process on %s, because all channels are already in use. Please increase MAX CHANNEL (which is %d for now) and recompile GRAS.",
            MSG_host_get_name(MSG_host_self()),XBT_MAX_CHANNEL);
 
   trp_pd->chan = i;
            MSG_host_get_name(MSG_host_self()),XBT_MAX_CHANNEL);
 
   trp_pd->chan = i;
@@ -60,8 +60,8 @@ gras_process_init() {
   /* take a free meas channel for this process */
   for (i=0; i<XBT_MAX_CHANNEL && hd->proc[i]; i++);
   if (i == XBT_MAX_CHANNEL) {
   /* take a free meas channel for this process */
   for (i=0; i<XBT_MAX_CHANNEL && hd->proc[i]; i++);
   if (i == XBT_MAX_CHANNEL) {
-    RAISE2(system_error,
-          "GRAS: Can't add a new process on %s, because all channel are already in use. Please increase MAX CHANNEL (which is %d for now) and recompile GRAS\n.",
+    THROW2(system_error,0,
+          "Can't add a new process on %s, because all channels are already in use. Please increase MAX CHANNEL (which is %d for now) and recompile GRAS.",
            MSG_host_get_name(MSG_host_self()),XBT_MAX_CHANNEL);
   }
   trp_pd->measChan = i;
            MSG_host_get_name(MSG_host_self()),XBT_MAX_CHANNEL);
   }
   trp_pd->measChan = i;
@@ -77,10 +77,9 @@ gras_process_init() {
   VERB2("Creating process '%s' (%d)",
           MSG_process_get_name(MSG_process_self()),
           MSG_process_self_PID());
   VERB2("Creating process '%s' (%d)",
           MSG_process_get_name(MSG_process_self()),
           MSG_process_self_PID());
-  return no_error;
 }
 
 }
 
-xbt_error_t
+void
 gras_process_exit() {
   gras_hostdata_t *hd=(gras_hostdata_t *)MSG_host_get_data(MSG_host_self());
   gras_msg_procdata_t msg_pd=(gras_msg_procdata_t)gras_libdata_get("gras_msg");
 gras_process_exit() {
   gras_hostdata_t *hd=(gras_hostdata_t *)MSG_host_get_data(MSG_host_self());
   gras_msg_procdata_t msg_pd=(gras_msg_procdata_t)gras_libdata_get("gras_msg");
@@ -107,8 +106,6 @@ gras_process_exit() {
       xbt_dynar_cursor_rm(hd->ports, &cpt);
     }
   }
       xbt_dynar_cursor_rm(hd->ports, &cpt);
     }
   }
-
-  return no_error;
 }
 
 /* **************************************************************************
 }
 
 /* **************************************************************************
index 32e810e..2cc3aee 100644 (file)
@@ -8,6 +8,7 @@
 #ifndef _SURF_SURF_PARSE_H
 #define _SURF_SURF_PARSE_H
 
 #ifndef _SURF_SURF_PARSE_H
 #define _SURF_SURF_PARSE_H
 
+#include <stdio.h>
 #include "xbt/misc.h"
 #include "surf/trace_mgr.h"
 #include "surfxml.h"
 #include "xbt/misc.h"
 #include "surf/trace_mgr.h"
 #include "surfxml.h"
index c159349..520b2b8 100644 (file)
@@ -124,7 +124,7 @@ m_process_code_t MSG_get_registered_function(const char *name)
 
   xbt_assert0(msg_global,"MSG_global_init_args has to be called before MSG_get_registered_function.");
  
 
   xbt_assert0(msg_global,"MSG_global_init_args has to be called before MSG_get_registered_function.");
  
-  xbt_dict_get(msg_global->registered_functions,name,(void **) &code);
+  code = xbt_dict_get(msg_global->registered_functions,name);
 
   return code;
 }
 
   return code;
 }
@@ -151,7 +151,7 @@ MSG_error_t MSG_get_arguments(int *argc, char ***argv)
   return MSG_OK;
 }
 
   return MSG_OK;
 }
 
-/** \ingroup msg_easier_life
+/* \ingroup msg_easier_life
  * \brief Set the arguments of a process.
  *
  * This functions sets the argument number and the arguments table for a
  * \brief Set the arguments of a process.
  *
  * This functions sets the argument number and the arguments table for a
@@ -162,8 +162,6 @@ MSG_error_t MSG_get_arguments(int *argc, char ***argv)
  */
 MSG_error_t MSG_set_arguments(m_process_t process,int argc, char *argv[])
 {
  */
 MSG_error_t MSG_set_arguments(m_process_t process,int argc, char *argv[])
 {
-  simdata_process_t simdata = NULL;
-
   xbt_assert0(0,"Deprecated ! Do not use anymore. "
              "Use MSG_process_create_with_arguments instead.\n");
 
   xbt_assert0(0,"Deprecated ! Do not use anymore. "
              "Use MSG_process_create_with_arguments instead.\n");
 
index 31aa289..a107bb1 100644 (file)
@@ -66,8 +66,8 @@ void MSG_create_environment(const char *file) {
   surf_timer_resource_init(file);
 
   /* which model do you want today? */
   surf_timer_resource_init(file);
 
   /* which model do you want today? */
-  xbt_cfg_get_string (_msg_cfg_set, "surf_workstation_model",
-                     &workstation_model_name);
+  workstation_model_name = xbt_cfg_get_string (_msg_cfg_set, "surf_workstation_model");
+
   DEBUG1("Model : %s", workstation_model_name);
   if (!strcmp(workstation_model_name,"KCCFLN05")) {
     surf_workstation_resource_init_KCCFLN05(file);
   DEBUG1("Model : %s", workstation_model_name);
   if (!strcmp(workstation_model_name,"KCCFLN05")) {
     surf_workstation_resource_init_KCCFLN05(file);
index 7694c1e..353a8c8 100644 (file)
@@ -498,7 +498,6 @@ MSG_error_t MSG_main(void)
  */
 int MSG_process_killall(int reset_PIDs)
 {
  */
 int MSG_process_killall(int reset_PIDs)
 {
-  xbt_fifo_item_t i = NULL;
   m_process_t p = NULL;
   m_process_t self = MSG_process_self();
 
   m_process_t p = NULL;
   m_process_t self = MSG_process_self();
 
index dd652ea..c57e078 100644 (file)
@@ -73,7 +73,6 @@ MSG_error_t MSG_task_get_with_time_out(m_task_t * task,
   m_host_t h = NULL;
   simdata_task_t t_simdata = NULL;
   simdata_host_t h_simdata = NULL;
   m_host_t h = NULL;
   simdata_task_t t_simdata = NULL;
   simdata_host_t h_simdata = NULL;
-  int warning = 0;
   int first_time = 1;
   e_surf_action_state_t state = SURF_ACTION_NOT_IN_THE_SYSTEM;
   
   int first_time = 1;
   e_surf_action_state_t state = SURF_ACTION_NOT_IN_THE_SYSTEM;
   
index ee04314..aea547c 100644 (file)
@@ -344,7 +344,6 @@ MSG_error_t MSG_process_suspend(m_process_t process)
 {
   simdata_process_t simdata = NULL;
   simdata_task_t simdata_task = NULL;
 {
   simdata_process_t simdata = NULL;
   simdata_task_t simdata_task = NULL;
-  int i;
 
   xbt_assert0(((process) && (process->simdata)), "Invalid parameters");
 
 
   xbt_assert0(((process) && (process->simdata)), "Invalid parameters");
 
@@ -394,7 +393,6 @@ MSG_error_t MSG_process_resume(m_process_t process)
 {
   simdata_process_t simdata = NULL;
   simdata_task_t simdata_task = NULL;
 {
   simdata_process_t simdata = NULL;
   simdata_task_t simdata_task = NULL;
-  int i;
 
   xbt_assert0(((process != NULL) && (process->simdata)), "Invalid parameters");
   CHECK_HOST();
 
   xbt_assert0(((process != NULL) && (process->simdata)), "Invalid parameters");
   CHECK_HOST();
@@ -474,7 +472,6 @@ MSG_error_t __MSG_process_unblock(m_process_t process)
 {
   simdata_process_t simdata = NULL;
   simdata_task_t simdata_task = NULL;
 {
   simdata_process_t simdata = NULL;
   simdata_task_t simdata_task = NULL;
-  int i;
 
   xbt_assert0(((process != NULL) && (process->simdata)), "Invalid parameters");
   CHECK_HOST();
 
   xbt_assert0(((process != NULL) && (process->simdata)), "Invalid parameters");
   CHECK_HOST();
index 7ece16e..0e89502 100644 (file)
@@ -23,12 +23,11 @@ xbt_cfg_t _msg_cfg_set = NULL;
 
 /* callback of the surf_workstation_model variable */
 static void _msg_cfg_cb__surf_workstation_model(const char *name, int pos) {
 
 /* callback of the surf_workstation_model variable */
 static void _msg_cfg_cb__surf_workstation_model(const char *name, int pos) {
-  xbt_error_t errcode;
   char *val;
 
   xbt_assert0(_msg_init_status<2, "Cannot change the model after the initialization");
   
   char *val;
 
   xbt_assert0(_msg_init_status<2, "Cannot change the model after the initialization");
   
-  TRYFAIL(xbt_cfg_get_string (_msg_cfg_set, name, &val));
+  val = xbt_cfg_get_string (_msg_cfg_set, name);
   
   xbt_assert1(!strcmp(val, "CLM03") ||
               !strcmp(val, "KCCFLN05"),
   
   xbt_assert1(!strcmp(val, "CLM03") ||
               !strcmp(val, "KCCFLN05"),
@@ -37,7 +36,6 @@ static void _msg_cfg_cb__surf_workstation_model(const char *name, int pos) {
 
 /* create the config set and register what should be */
 void msg_config_init(void) {
 
 /* create the config set and register what should be */
 void msg_config_init(void) {
-  xbt_error_t errcode;
 
   if (_msg_init_status) 
     return; /* Already inited, nothing to do */
 
   if (_msg_init_status) 
     return; /* Already inited, nothing to do */
@@ -49,7 +47,7 @@ void msg_config_init(void) {
                     "surf_workstation_model", xbt_cfgelm_string, 1,1,
                     &_msg_cfg_cb__surf_workstation_model,NULL);
                     
                     "surf_workstation_model", xbt_cfgelm_string, 1,1,
                     &_msg_cfg_cb__surf_workstation_model,NULL);
                     
-  TRYFAIL(xbt_cfg_set_string(_msg_cfg_set,"surf_workstation_model", "CLM03"));
+  xbt_cfg_set_string(_msg_cfg_set,"surf_workstation_model", "CLM03");
 }
 
 /** \brief set a configuration variable
 }
 
 /** \brief set a configuration variable
@@ -64,18 +62,16 @@ void msg_config_init(void) {
  * Example:
  * MSG_config("surf_workstation_model","CLM03");
  */
  * Example:
  * MSG_config("surf_workstation_model","CLM03");
  */
-xbt_error_t
+void
 MSG_config(const char *name, ...) {
   va_list pa;
 MSG_config(const char *name, ...) {
   va_list pa;
-  xbt_error_t errcode;
     
   if (!_msg_init_status) {
     msg_config_init();
   }
     
   if (!_msg_init_status) {
     msg_config_init();
   }
-xbt_cfg_dump("msg_cfg_set","",_msg_cfg_set);
+  /*  xbt_cfg_dump("msg_cfg_set","",_msg_cfg_set);*/
   va_start(pa,name);
   va_start(pa,name);
-  errcode=xbt_cfg_set_vargs(_msg_cfg_set,name,pa);
+  xbt_cfg_set_vargs(_msg_cfg_set,name,pa);
   va_end(pa);
   va_end(pa);
-  
-  return errcode;
+
 }
 }
index d37ab31..22a8717 100644 (file)
@@ -11,8 +11,6 @@
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(task, msg,
                                "Logging specific to MSG (task)");
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(task, msg,
                                "Logging specific to MSG (task)");
 
-static char sprint_buffer[64];
-
 /** \defgroup m_task_management Managing functions of Tasks
  *  \brief This section describes the task structure of MSG
  *  (#m_task_t) and the functions for managing it.
 /** \defgroup m_task_management Managing functions of Tasks
  *  \brief This section describes the task structure of MSG
  *  (#m_task_t) and the functions for managing it.
@@ -111,9 +109,7 @@ const char *MSG_task_get_name(m_task_t task)
  */
 MSG_error_t MSG_task_destroy(m_task_t task)
 {
  */
 MSG_error_t MSG_task_destroy(m_task_t task)
 {
-  simdata_task_t simdata = NULL;
   surf_action_t action = NULL;
   surf_action_t action = NULL;
-  int i;
 
   xbt_assert0((task != NULL), "Invalid parameter");
 
 
   xbt_assert0((task != NULL), "Invalid parameter");
 
@@ -165,10 +161,7 @@ MSG_error_t MSG_task_cancel(m_task_t task)
  * \brief Returns the computation amount needed to process a task #m_task_t.
  *        Once a task has been processed, this amount is thus set to 0...
  */
  * \brief Returns the computation amount needed to process a task #m_task_t.
  *        Once a task has been processed, this amount is thus set to 0...
  */
-double MSG_task_get_compute_duration(m_task_t task)
-{
-  simdata_task_t simdata = NULL;
-
+double MSG_task_get_compute_duration(m_task_t task) {
   xbt_assert0((task != NULL) && (task->simdata != NULL), "Invalid parameter");
 
   return task->simdata->computation_amount;
   xbt_assert0((task != NULL) && (task->simdata != NULL), "Invalid parameter");
 
   return task->simdata->computation_amount;
@@ -180,8 +173,6 @@ double MSG_task_get_compute_duration(m_task_t task)
  */
 double MSG_task_get_remaining_computation(m_task_t task)
 {
  */
 double MSG_task_get_remaining_computation(m_task_t task)
 {
-  simdata_task_t simdata = NULL;
-
   xbt_assert0((task != NULL) && (task->simdata != NULL), "Invalid parameter");
 
   if(task->simdata->compute) {
   xbt_assert0((task != NULL) && (task->simdata != NULL), "Invalid parameter");
 
   if(task->simdata->compute) {
@@ -195,10 +186,7 @@ double MSG_task_get_remaining_computation(m_task_t task)
  * \brief Returns the size of the data attached to a task #m_task_t.
  *
  */
  * \brief Returns the size of the data attached to a task #m_task_t.
  *
  */
-double MSG_task_get_data_size(m_task_t task)
-{
-  simdata_task_t simdata = NULL;
-
+double MSG_task_get_data_size(m_task_t task) {
   xbt_assert0((task != NULL) && (task->simdata != NULL), "Invalid parameter");
 
   return task->simdata->message_size;
   xbt_assert0((task != NULL) && (task->simdata != NULL), "Invalid parameter");
 
   return task->simdata->message_size;
index fbcf4f1..c8f7b3e 100644 (file)
@@ -86,11 +86,7 @@ static void parse_file(const char *file)
 
 static void *name_service(const char *name)
 {
 
 static void *name_service(const char *name)
 {
-  void *cpu = NULL;
-
-  xbt_dict_get(cpu_set, name, &cpu);
-
-  return cpu;
+  return xbt_dict_get_or_null(cpu_set, name);
 }
 
 static const char *get_resource_name(void *resource_id)
 }
 
 static const char *get_resource_name(void *resource_id)
@@ -160,8 +156,10 @@ static void update_actions_state(double now, double delta)
   surf_action_cpu_Cas01_t next_action = NULL;
   xbt_swag_t running_actions =
       surf_cpu_resource->common_public->states.running_action_set;
   surf_action_cpu_Cas01_t next_action = NULL;
   xbt_swag_t running_actions =
       surf_cpu_resource->common_public->states.running_action_set;
+  /* FIXME: UNUSED
   xbt_swag_t failed_actions =
       surf_cpu_resource->common_public->states.failed_action_set;
   xbt_swag_t failed_actions =
       surf_cpu_resource->common_public->states.failed_action_set;
+  */
 
   xbt_swag_foreach_safe(action, next_action, running_actions) {
     surf_double_update(&(action->generic_action.remains),
 
   xbt_swag_foreach_safe(action, next_action, running_actions) {
     surf_double_update(&(action->generic_action.remains),
index a2a185a..25de6fe 100644 (file)
@@ -81,9 +81,7 @@ static void network_card_free(void *nw_card)
 
 static int network_card_new(const char *card_name)
 {
 
 static int network_card_new(const char *card_name)
 {
-  network_card_CM02_t card = NULL;
-
-  xbt_dict_get(network_card_set, card_name, (void *) &card);
+  network_card_CM02_t card = xbt_dict_get_or_null(network_card_set, card_name);
 
   if (!card) {
     card = xbt_new0(s_network_card_CM02_t, 1);
 
   if (!card) {
     card = xbt_new0(s_network_card_CM02_t, 1);
@@ -102,7 +100,7 @@ static void route_new(int src_id, int dst_id, char **links, int nb_link)
   ROUTE_SIZE(src_id, dst_id) = nb_link;
   link_list = (ROUTE(src_id, dst_id) = xbt_new0(network_link_CM02_t, nb_link));
   for (i = 0; i < nb_link; i++) {
   ROUTE_SIZE(src_id, dst_id) = nb_link;
   link_list = (ROUTE(src_id, dst_id) = xbt_new0(network_link_CM02_t, nb_link));
   for (i = 0; i < nb_link; i++) {
-    xbt_dict_get(network_link_set, links[i], (void *) &(link_list[i]));
+    link_list[i] = xbt_dict_get_or_null(network_link_set, links[i]);
     free(links[i]);
   }
   free(links);
     free(links[i]);
   }
   free(links);
@@ -216,10 +214,7 @@ static void parse_file(const char *file)
 
 static void *name_service(const char *name)
 {
 
 static void *name_service(const char *name)
 {
-  network_card_CM02_t card = NULL;
-
-  xbt_dict_get(network_card_set, name, (void *) &card);
-
+  network_card_CM02_t card = xbt_dict_get_or_null(network_card_set, name);
   return card;
 }
 
   return card;
 }
 
@@ -300,8 +295,10 @@ static void update_actions_state(double now, double delta)
   surf_action_network_CM02_t next_action = NULL;
   xbt_swag_t running_actions =
       surf_network_resource->common_public->states.running_action_set;
   surf_action_network_CM02_t next_action = NULL;
   xbt_swag_t running_actions =
       surf_network_resource->common_public->states.running_action_set;
+  /*
   xbt_swag_t failed_actions =
       surf_network_resource->common_public->states.failed_action_set;
   xbt_swag_t failed_actions =
       surf_network_resource->common_public->states.failed_action_set;
+  */
 
   xbt_swag_foreach_safe(action, next_action, running_actions) {
     deltap = delta;
 
   xbt_swag_foreach_safe(action, next_action, running_actions) {
     deltap = delta;
index c0f80ee..1b07eda 100644 (file)
@@ -78,9 +78,7 @@ static void network_card_free(void *nw_card)
 
 static int network_card_new(const char *card_name)
 {
 
 static int network_card_new(const char *card_name)
 {
-  network_card_DASSF_t card = NULL;
-
-  xbt_dict_get(network_card_set, card_name, (void *) &card);
+  network_card_DASSF_t card = xbt_dict_get_or_null(network_card_set, card_name);
 
   if (!card) {
     card = xbt_new0(s_network_card_DASSF_t, 1);
 
   if (!card) {
     card = xbt_new0(s_network_card_DASSF_t, 1);
@@ -99,7 +97,7 @@ static void route_new(int src_id, int dst_id, char **links, int nb_link)
   ROUTE_SIZE(src_id, dst_id) = nb_link;
   link_list = (ROUTE(src_id, dst_id) = xbt_new0(network_link_DASSF_t, nb_link));
   for (i = 0; i < nb_link; i++) {
   ROUTE_SIZE(src_id, dst_id) = nb_link;
   link_list = (ROUTE(src_id, dst_id) = xbt_new0(network_link_DASSF_t, nb_link));
   for (i = 0; i < nb_link; i++) {
-    xbt_dict_get(network_link_set, links[i], (void *) &(link_list[i]));
+    link_list[i] = xbt_dict_get_or_null(network_link_set, links[i]);
     free(links[i]);
   }
   free(links);
     free(links[i]);
   }
   free(links);
@@ -189,11 +187,7 @@ static void parse_file(const char *file)
 
 static void *name_service(const char *name)
 {
 
 static void *name_service(const char *name)
 {
-  network_card_DASSF_t card = NULL;
-
-  xbt_dict_get(network_card_set, name, (void *) &card);
-
-  return card;
+  return xbt_dict_get_or_null(network_card_set, name);
 }
 
 static const char *get_resource_name(void *resource_id)
 }
 
 static const char *get_resource_name(void *resource_id)
@@ -267,8 +261,10 @@ static void update_actions_state(double now, double delta)
   surf_action_network_DASSF_t next_action = NULL;
   xbt_swag_t running_actions =
       surf_network_resource->common_public->states.running_action_set;
   surf_action_network_DASSF_t next_action = NULL;
   xbt_swag_t running_actions =
       surf_network_resource->common_public->states.running_action_set;
+  /* KILLME: unused
   xbt_swag_t failed_actions =
       surf_network_resource->common_public->states.failed_action_set;
   xbt_swag_t failed_actions =
       surf_network_resource->common_public->states.failed_action_set;
+  */
 
   xbt_swag_foreach_safe(action, next_action, running_actions) {
     deltap = delta;
 
   xbt_swag_foreach_safe(action, next_action, running_actions) {
     deltap = delta;
index 2668ed4..776cb64 100644 (file)
@@ -174,7 +174,6 @@ void  surf_parse_close(void) {
 
 int surf_parse(void)
 {
 
 int surf_parse(void)
 {
-  int ret=0;
   return surf_parse_lex();
 }
 
   return surf_parse_lex();
 }
 
index 57b852c..35ddfa8 100644 (file)
@@ -5,6 +5,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "xbt/ex.h"
 #include "surf_timer_private.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(timer, surf,
 #include "surf_timer_private.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(timer, surf,
index fd1e6b7..25545f9 100644 (file)
@@ -49,7 +49,7 @@ tmgr_trace_t tmgr_trace_new(const char *filename)
   tmgr_event_t last_event = NULL;
 
   if (trace_list) {
   tmgr_event_t last_event = NULL;
 
   if (trace_list) {
-    xbt_dict_get(trace_list, filename, (void **) &trace);
+    trace = xbt_dict_get_or_null(trace_list, filename);
     if (trace)
       return trace;
   }
     if (trace)
       return trace;
   }
@@ -112,9 +112,9 @@ tmgr_trace_t tmgr_trace_new(const char *filename)
 tmgr_trace_t tmgr_empty_trace_new(void)
 {
   tmgr_trace_t trace = NULL;
 tmgr_trace_t tmgr_empty_trace_new(void)
 {
   tmgr_trace_t trace = NULL;
-  double periodicity = -1.0;   /* No periodicity by default */
+  /*double periodicity = -1.0;  No periodicity by default; unused variables
+  tmgr_event_t last_event = NULL;*/
   s_tmgr_event_t event;
   s_tmgr_event_t event;
-  tmgr_event_t last_event = NULL;
 
   trace = xbt_new0(s_tmgr_trace_t, 1);
   trace->event_list = xbt_dynar_new(sizeof(s_tmgr_event_t), NULL);
 
   trace = xbt_new0(s_tmgr_trace_t, 1);
   trace->event_list = xbt_dynar_new(sizeof(s_tmgr_event_t), NULL);
index 22c141b..b4603c1 100644 (file)
@@ -5,6 +5,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "xbt/ex.h"
 #include "xbt/dict.h"
 #include "workstation_private.h"
 #include "cpu_private.h"
 #include "xbt/dict.h"
 #include "workstation_private.h"
 #include "cpu_private.h"
@@ -38,15 +39,16 @@ static void workstation_free(void *workstation)
 
 static void create_workstations(void)
 {
 
 static void create_workstations(void)
 {
-   xbt_dict_cursor_t cursor = NULL;
+  xbt_dict_cursor_t cursor = NULL;
   char *name = NULL;
   void *cpu = NULL;
   void *nw_card = NULL;
 
   xbt_dict_foreach(cpu_set, cursor, name, cpu) {
   char *name = NULL;
   void *cpu = NULL;
   void *nw_card = NULL;
 
   xbt_dict_foreach(cpu_set, cursor, name, cpu) {
-    nw_card = NULL;
-    xbt_dict_get(network_card_set, name, (void *) &nw_card);
-    xbt_assert1(nw_card, "No corresponding card found for %s",name);
+    nw_card = xbt_dict_get_or_null(network_card_set, name);
+    xbt_assert1(nw_card,
+               "No corresponding card found for %s",name);
+
     xbt_dict_set(workstation_set, name,
                 workstation_new(name, cpu, nw_card), workstation_free);
   }
     xbt_dict_set(workstation_set, name,
                 workstation_new(name, cpu, nw_card), workstation_free);
   }
@@ -54,11 +56,7 @@ static void create_workstations(void)
 
 static void *name_service(const char *name)
 {
 
 static void *name_service(const char *name)
 {
-  void *workstation = NULL;
-
-  xbt_dict_get(workstation_set, name, &workstation);
-
-  return workstation;
+  return xbt_dict_get_or_null(workstation_set, name);
 }
 
 static const char *get_resource_name(void *resource_id)
 }
 
 static const char *get_resource_name(void *resource_id)
@@ -160,8 +158,10 @@ static void update_actions_state(double now, double delta)
   surf_action_parallel_task_CSL05_t next_action = NULL;
   xbt_swag_t running_actions =
       surf_workstation_resource->common_public->states.running_action_set;
   surf_action_parallel_task_CSL05_t next_action = NULL;
   xbt_swag_t running_actions =
       surf_workstation_resource->common_public->states.running_action_set;
+  /* FIXME: unused
   xbt_swag_t failed_actions =
       surf_workstation_resource->common_public->states.failed_action_set;
   xbt_swag_t failed_actions =
       surf_workstation_resource->common_public->states.failed_action_set;
+  */
 
   xbt_swag_foreach_safe(action, next_action, running_actions) {
     surf_double_update(&(action->generic_action.remains),
 
   xbt_swag_foreach_safe(action, next_action, running_actions) {
     surf_double_update(&(action->generic_action.remains),
index 956d49d..1d9eda7 100644 (file)
@@ -5,6 +5,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "xbt/ex.h"
 #include "xbt/dict.h"
 #include "workstation_KCCFLN05_private.h"
 
 #include "xbt/dict.h"
 #include "workstation_KCCFLN05_private.h"
 
@@ -121,11 +122,7 @@ static void parse_workstation(void)
 
 static void *name_service(const char *name)
 {
 
 static void *name_service(const char *name)
 {
-  void *workstation = NULL;
-
-  xbt_dict_get(workstation_set, name, &workstation);
-
-  return workstation;
+  return xbt_dict_get_or_null(workstation_set, name);
 }
 
 static const char *get_resource_name(void *resource_id)
 }
 
 static const char *get_resource_name(void *resource_id)
@@ -254,7 +251,7 @@ static void route_new(int src_id, int dst_id, char **links, int nb_link,
   route->size= nb_link;
   link_list = route->links = xbt_new0(network_link_KCCFLN05_t, nb_link);
   for (i = 0; i < nb_link; i++) {
   route->size= nb_link;
   link_list = route->links = xbt_new0(network_link_KCCFLN05_t, nb_link);
   for (i = 0; i < nb_link; i++) {
-    xbt_dict_get(network_link_set, links[i], (void *) &(link_list[i]));
+    link_list[i] = xbt_dict_get(network_link_set, links[i]);
     free(links[i]);
   }
   free(links);
     free(links[i]);
   }
   free(links);
@@ -441,9 +438,10 @@ static void update_actions_network_KCCFLN05_state(double now, double delta)
   surf_action_network_KCCFLN05_t next_action = NULL;
   xbt_swag_t running_actions =
       surf_network_resource->common_public->states.running_action_set;
   surf_action_network_KCCFLN05_t next_action = NULL;
   xbt_swag_t running_actions =
       surf_network_resource->common_public->states.running_action_set;
+  /* FIXME: unused
   xbt_swag_t failed_actions =
       surf_network_resource->common_public->states.failed_action_set;
   xbt_swag_t failed_actions =
       surf_network_resource->common_public->states.failed_action_set;
-
+  */
   xbt_swag_foreach_safe(action, next_action, running_actions) {
     surf_double_update(&(action->generic_action.remains),
                       lmm_variable_getvalue(action->variable) * delta);
   xbt_swag_foreach_safe(action, next_action, running_actions) {
     surf_double_update(&(action->generic_action.remains),
                       lmm_variable_getvalue(action->variable) * delta);
@@ -656,8 +654,10 @@ static void update_actions_cpu_KCCFLN05_state(double now, double delta)
   surf_action_cpu_KCCFLN05_t next_action = NULL;
   xbt_swag_t running_actions =
       surf_cpu_resource->common_public->states.running_action_set;
   surf_action_cpu_KCCFLN05_t next_action = NULL;
   xbt_swag_t running_actions =
       surf_cpu_resource->common_public->states.running_action_set;
+  /*
   xbt_swag_t failed_actions =
       surf_cpu_resource->common_public->states.failed_action_set;
   xbt_swag_t failed_actions =
       surf_cpu_resource->common_public->states.failed_action_set;
+  */
 
   xbt_swag_foreach_safe(action, next_action, running_actions) {
     surf_double_update(&(action->generic_action.remains),
 
   xbt_swag_foreach_safe(action, next_action, running_actions) {
     surf_double_update(&(action->generic_action.remains),
index fc595b2..81c8fb4 100644 (file)
@@ -9,10 +9,12 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include <stdio.h> /* FIXME: killme */
+
 #include "xbt/misc.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
 #include "xbt/misc.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
-#include "xbt/error.h"
+#include "xbt/ex.h"
 #include "xbt/dynar.h"
 #include "xbt/dict.h"
 
 #include "xbt/dynar.h"
 #include "xbt/dict.h"
 
@@ -46,9 +48,8 @@ static const char *xbt_cfgelm_type_name[xbt_cfgelm_type_count]=
 static void xbt_cfgelm_free(void *data);
 
 /* Retrieve the variable we'll modify */
 static void xbt_cfgelm_free(void *data);
 
 /* Retrieve the variable we'll modify */
-static xbt_error_t xbt_cfgelm_get(xbt_cfg_t cfg, const char *name,
-                                   e_xbt_cfgelm_type_t type,
-                                   /* OUT */ xbt_cfgelm_t *whereto);
+static xbt_cfgelm_t xbt_cfgelm_get(xbt_cfg_t cfg, const char *name,
+                                  e_xbt_cfgelm_type_t type);
 
 static void xbt_cfg_str_free(void *d){
   free(*(void**)d);
 
 static void xbt_cfg_str_free(void *d){
   free(*(void**)d);
@@ -198,23 +199,33 @@ void xbt_cfgelm_free(void *data) {
 
 void
 xbt_cfg_register(xbt_cfg_t cfg,
 
 void
 xbt_cfg_register(xbt_cfg_t cfg,
-                 const char *name, e_xbt_cfgelm_type_t type,
-                 int min, int max,
-                 xbt_cfg_cb_t cb_set,  xbt_cfg_cb_t cb_rm){
+                const char *name, e_xbt_cfgelm_type_t type,
+                int min, int max,
+                xbt_cfg_cb_t cb_set,  xbt_cfg_cb_t cb_rm){
   xbt_cfgelm_t res;
   xbt_cfgelm_t res;
-  xbt_error_t errcode;
+  xbt_ex_t e;
+  int found=0;
 
 
+  xbt_assert(cfg);
   xbt_assert4(type>=xbt_cfgelm_int && type<=xbt_cfgelm_host,
               "type of %s not valid (%d should be between %d and %d)",
               name,type,xbt_cfgelm_int, xbt_cfgelm_host);
   DEBUG5("Register cfg elm %s (%d to %d %s (=%d))",name,min,max,xbt_cfgelm_type_name[type],type);
   xbt_assert4(type>=xbt_cfgelm_int && type<=xbt_cfgelm_host,
               "type of %s not valid (%d should be between %d and %d)",
               name,type,xbt_cfgelm_int, xbt_cfgelm_host);
   DEBUG5("Register cfg elm %s (%d to %d %s (=%d))",name,min,max,xbt_cfgelm_type_name[type],type);
-  errcode = xbt_dict_get((xbt_dict_t)cfg,name,(void**)&res);
+  TRY {
+    res = xbt_dict_get((xbt_dict_t)cfg,name);
+  } CATCH(e) {
+    if (e.category == mismatch_error) {
+      found = 1;
+      xbt_ex_free(e);
+    } else {
+      RETHROW;
+    }
+  }
 
 
-  if (errcode == no_error) {
+  if (!found) {
     WARN1("Config elem %s registered twice.",name);
     /* Will be removed by the insertion of the new one */
   } 
     WARN1("Config elem %s registered twice.",name);
     /* Will be removed by the insertion of the new one */
   } 
-  xbt_assert_error(mismatch_error);
 
   res=xbt_new(s_xbt_cfgelm_t,1);
 
 
   res=xbt_new(s_xbt_cfgelm_t,1);
 
@@ -377,29 +388,30 @@ xbt_cfg_check(xbt_cfg_t cfg) {
   return no_error;
 }
 
   return no_error;
 }
 
-static xbt_error_t xbt_cfgelm_get(xbt_cfg_t  cfg,
-                                   const char *name,
-                                   e_xbt_cfgelm_type_t type,
-                                   /* OUT */ xbt_cfgelm_t *whereto){
-   
-  xbt_error_t errcode = xbt_dict_get((xbt_dict_t)cfg,name,
-                                      (void**)whereto);
-
-  if (errcode == mismatch_error) {
-    RAISE1(mismatch_error,
-           "No registered variable '%s' in this config set",
-          name);
+static xbt_cfgelm_t xbt_cfgelm_get(xbt_cfg_t  cfg,
+                                  const char *name,
+                                  e_xbt_cfgelm_type_t type){
+  xbt_cfgelm_t res;
+  xbt_ex_t e;
+
+  TRY {
+    res = xbt_dict_get((xbt_dict_t)cfg,name);
+  } CATCH(e) {
+    if (e.category == mismatch_error) {
+      THROW1(mismatch_error,0,
+            "No registered variable '%s' in this config set",name);
+      xbt_ex_free(e);
+    }
+    RETHROW;
   }
   }
-  if (errcode != no_error)
-     return errcode;
 
 
-  xbt_assert3(type == xbt_cfgelm_any || (*whereto)->type == type,
+  xbt_assert3(type == xbt_cfgelm_any || res->type == type,
               "You tried to access to the config element %s as an %s, but its type is %s.",
               name,
               xbt_cfgelm_type_name[type],
               "You tried to access to the config element %s as an %s, but its type is %s.",
               name,
               xbt_cfgelm_type_name[type],
-              xbt_cfgelm_type_name[(*whereto)->type]);
+              xbt_cfgelm_type_name[res->type]);
 
 
-  return no_error;
+  return res;
 }
 
 /** @brief Get the type of this variable in that configuration set
 }
 
 /** @brief Get the type of this variable in that configuration set
@@ -410,26 +422,26 @@ static xbt_error_t xbt_cfgelm_get(xbt_cfg_t  cfg,
  *
  */
 
  *
  */
 
-xbt_error_t
-xbt_cfg_get_type(xbt_cfg_t cfg, const char *name, 
-                     /* OUT */e_xbt_cfgelm_type_t *type) {
+e_xbt_cfgelm_type_t 
+xbt_cfg_get_type(xbt_cfg_t cfg, const char *name) {
 
 
-  xbt_cfgelm_t variable;
-  xbt_error_t errcode;
-
-  errcode=xbt_dict_get((xbt_dict_t)cfg,name,(void**)&variable);
+  xbt_cfgelm_t variable = NULL;
+  xbt_ex_t e;
 
 
-  if (errcode == mismatch_error) {
-    RAISE1(mismatch_error,"Can't get the type of '%s' since this variable does not exist",
-          name);
-  } else if (errcode != no_error) {
-    return errcode;
+  TRY {
+    variable = xbt_dict_get((xbt_dict_t)cfg,name);
+  } CATCH(e) {
+    if (e.category == mismatch_error) {
+      THROW1(mismatch_error,0,
+            "Can't get the type of '%s' since this variable does not exist",name);
+      xbt_ex_free(e);
+    }
+    RETHROW;
   }
 
   INFO1("type in variable = %d",variable->type);
   }
 
   INFO1("type in variable = %d",variable->type);
-  *type=variable->type;
 
 
-  return no_error;
+  return variable->type;
 }
 
 /*----[ Setting ]---------------------------------------------------------*/
 }
 
 /*----[ Setting ]---------------------------------------------------------*/
@@ -441,48 +453,50 @@ xbt_cfg_get_type(xbt_cfg_t cfg, const char *name,
  *
  * Add some values to the config set.
  */
  *
  * Add some values to the config set.
  */
-xbt_error_t
+void
 xbt_cfg_set_vargs(xbt_cfg_t cfg, const char *name, va_list pa) {
   char *str;
   int i;
   double d;
   e_xbt_cfgelm_type_t type;
 
 xbt_cfg_set_vargs(xbt_cfg_t cfg, const char *name, va_list pa) {
   char *str;
   int i;
   double d;
   e_xbt_cfgelm_type_t type;
 
-  xbt_error_t errcode;
+  xbt_ex_t e;
   
   
-  errcode = xbt_cfg_get_type(cfg,name,&type);
-  if (errcode != no_error) {
-    ERROR1("Can't set the property '%s' since it's not registered",name);
-    return mismatch_error;
+  TRY {
+    type = xbt_cfg_get_type(cfg,name);
+  } CATCH(e) {
+    if (e.category == mismatch_error) {
+      xbt_ex_free(e);
+      THROW1(mismatch_error,0,"Can't set the property '%s' since it's not registered",name);
+    }
+    RETHROW;
   }
 
   switch (type) {
   case xbt_cfgelm_host:
     str = va_arg(pa, char *);
     i=va_arg(pa,int);
   }
 
   switch (type) {
   case xbt_cfgelm_host:
     str = va_arg(pa, char *);
     i=va_arg(pa,int);
-    TRYOLD(xbt_cfg_set_host(cfg,name,str,i));
+    xbt_cfg_set_host(cfg,name,str,i);
     break;
       
   case xbt_cfgelm_string:
     str=va_arg(pa, char *);
     break;
       
   case xbt_cfgelm_string:
     str=va_arg(pa, char *);
-    TRYOLD(xbt_cfg_set_string(cfg, name, str));
+    xbt_cfg_set_string(cfg, name, str);
     break;
 
   case xbt_cfgelm_int:
     i=va_arg(pa,int);
     break;
 
   case xbt_cfgelm_int:
     i=va_arg(pa,int);
-    TRYOLD(xbt_cfg_set_int(cfg,name,i));
+    xbt_cfg_set_int(cfg,name,i);
     break;
 
   case xbt_cfgelm_double:
     d=va_arg(pa,double);
     break;
 
   case xbt_cfgelm_double:
     d=va_arg(pa,double);
-    TRYOLD(xbt_cfg_set_double(cfg,name,d));
+    xbt_cfg_set_double(cfg,name,d);
     break;
 
   default:
     xbt_assert2(0,"Config element variable %s not valid (type=%d)",name,type);
   }
     break;
 
   default:
     xbt_assert2(0,"Config element variable %s not valid (type=%d)",name,type);
   }
-
-  return no_error;
 }
 
 /** @brief Add a NULL-terminated list of pairs {(char*)key, value} to the set
 }
 
 /** @brief Add a NULL-terminated list of pairs {(char*)key, value} to the set
@@ -492,14 +506,12 @@ xbt_cfg_set_vargs(xbt_cfg_t cfg, const char *name, va_list pa) {
  * \arg varargs variable value
  *
  */
  * \arg varargs variable value
  *
  */
-xbt_error_t xbt_cfg_set(xbt_cfg_t cfg, const char *name, ...) {
+void xbt_cfg_set(xbt_cfg_t cfg, const char *name, ...) {
   va_list pa;
   va_list pa;
-  xbt_error_t errcode;
 
   va_start(pa,name);
 
   va_start(pa,name);
-  errcode=xbt_cfg_set_vargs(cfg,name,pa);
+  xbt_cfg_set_vargs(cfg,name,pa);
   va_end(pa);
   va_end(pa);
-  return errcode;
 }
 
 /** @brief Add values parsed from a string into a config set
 }
 
 /** @brief Add values parsed from a string into a config set
@@ -514,8 +526,10 @@ xbt_error_t xbt_cfg_set(xbt_cfg_t cfg, const char *name, ...) {
  * @todo This is a crude manual parser, it should be a proper lexer.
  */
 
  * @todo This is a crude manual parser, it should be a proper lexer.
  */
 
-xbt_error_t
+void
 xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options) {
 xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options) {
+  xbt_ex_t e;
+
   int i;
   double d;
   char *str;
   int i;
   double d;
   char *str;
@@ -525,11 +539,10 @@ xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options) {
   char *option,  *name,*val;
 
   int len;
   char *option,  *name,*val;
 
   int len;
-  xbt_error_t errcode;
 
   XBT_IN;
   if (!options || !strlen(options)) { /* nothing to do */
 
   XBT_IN;
   if (!options || !strlen(options)) { /* nothing to do */
-    return no_error;
+    return;
   }
   optionlist_cpy=xbt_strdup(options);
 
   }
   optionlist_cpy=xbt_strdup(options);
 
@@ -585,95 +598,79 @@ xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options) {
 
     DEBUG2("name='%s';val='%s'",name,val);
 
 
     DEBUG2("name='%s';val='%s'",name,val);
 
-    errcode=xbt_dict_get((xbt_dict_t)cfg,name,(void**)&variable);
-    switch (errcode) {
-    case no_error:
-      break;
-    case mismatch_error:
-      ERROR1("No registrated variable corresponding to '%s'.",name);
+    TRY {
+      variable = xbt_dict_get((xbt_dict_t)cfg,name);
+    } CATCH(e) {
       free(optionlist_cpy);
       free(optionlist_cpy);
-      return mismatch_error;
-      break;
-    default:
-      free(optionlist_cpy);
-      return errcode;
-    }
-
-    switch (variable->type) {
-    case xbt_cfgelm_string:
-      errcode = xbt_cfg_set_string(cfg, name, val);
-      if (errcode != no_error) {
-        free(optionlist_cpy);
-         return errcode;
-      }
-      break;
-
-    case xbt_cfgelm_int:
-      i=strtol(val, &val, 0);
-      if (val==NULL) {
-       free(optionlist_cpy);   
-       xbt_assert1(FALSE,
-                    "Value of option %s not valid. Should be an integer",
-                    name);
-      }
-
-      errcode = xbt_cfg_set_int(cfg,name,i);
-      if (errcode != no_error) {
-        free(optionlist_cpy);
-        return errcode;
-      }
-      break;
-
-    case xbt_cfgelm_double:
-      d=strtod(val, &val);
-      if (val==NULL) {
-       free(optionlist_cpy);   
-       xbt_assert1(FALSE,
-              "Value of option %s not valid. Should be a double",
-              name);
-      }
-
-      errcode = xbt_cfg_set_double(cfg,name,d);
-      if (errcode != no_error) {
-        free(optionlist_cpy);
-        return errcode;
-      }
-      break;
-
-    case xbt_cfgelm_host:
-      str=val;
-      val=strchr(val,':');
-      if (!val) {
-       free(optionlist_cpy);   
-       xbt_assert1(FALSE,
-           "Value of option %s not valid. Should be an host (machine:port)",
-              name);
-      }
-
-      *(val++)='\0';
-      i=strtol(val, &val, 0);
-      if (val==NULL) {
-       free(optionlist_cpy);   
-       xbt_assert1(FALSE,
-           "Value of option %s not valid. Should be an host (machine:port)",
-              name);
+      if (e.category == mismatch_error) {
+       xbt_ex_free(e);
+       THROW1(mismatch_error,0,"No registrated variable corresponding to '%s'.",name);
       }
       }
+      RETHROW;
+    }
 
 
-      errcode = xbt_cfg_set_host(cfg,name,str,i);
-      if (errcode != no_error) {
-        free(optionlist_cpy);
-        return errcode;
+    TRY {
+      switch (variable->type) {
+      case xbt_cfgelm_string:
+       xbt_cfg_set_string(cfg, name, val); /* throws */
+       break;
+
+      case xbt_cfgelm_int:
+       i=strtol(val, &val, 0);
+       if (val==NULL) {
+         free(optionlist_cpy); 
+         xbt_assert1(FALSE,
+                     "Value of option %s not valid. Should be an integer",
+                     name);
+       }
+
+       xbt_cfg_set_int(cfg,name,i); /* throws */
+       break;
+
+      case xbt_cfgelm_double:
+       d=strtod(val, &val);
+       if (val==NULL) {
+         free(optionlist_cpy); 
+         xbt_assert1(FALSE,
+                     "Value of option %s not valid. Should be a double",
+                     name);
+       }
+
+       xbt_cfg_set_double(cfg,name,d); /* throws */
+       break;
+
+      case xbt_cfgelm_host:
+       str=val;
+       val=strchr(val,':');
+       if (!val) {
+         free(optionlist_cpy); 
+         xbt_assert1(FALSE,
+                     "Value of option %s not valid. Should be an host (machine:port)",
+                     name);
+       }
+       
+       *(val++)='\0';
+       i=strtol(val, &val, 0);
+       if (val==NULL) {
+         free(optionlist_cpy); 
+         xbt_assert1(FALSE,
+                     "Value of option %s not valid. Should be an host (machine:port)",
+                     name);
+       }
+
+       xbt_cfg_set_host(cfg,name,str,i); /* throws */ 
+       break;      
+
+      default: 
+       THROW1(unknown_error,0,"Type of config element %s is not valid.",name);
       }
       }
-      break;      
-
-    default: 
+    } CATCH(e) {
       free(optionlist_cpy);
       free(optionlist_cpy);
-      RAISE1(unknown_error,"Type of config element %s is not valid.",name);
+      RETHROW;
     }
     }
-    
   }
   free(optionlist_cpy);
   }
   free(optionlist_cpy);
-  return no_error;
+
 }
 
 /** @brief Set or add an integer value to \a name within \a cfg
 }
 
 /** @brief Set or add an integer value to \a name within \a cfg
@@ -682,13 +679,12 @@ xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options) {
  * \arg name the name of the variable
  * \arg val the value of the variable
  */ 
  * \arg name the name of the variable
  * \arg val the value of the variable
  */ 
-xbt_error_t
+void
 xbt_cfg_set_int(xbt_cfg_t cfg,const char*name, int val) {
   xbt_cfgelm_t variable;
 xbt_cfg_set_int(xbt_cfg_t cfg,const char*name, int val) {
   xbt_cfgelm_t variable;
-  xbt_error_t errcode;
 
   VERB2("Configuration setting: %s=%d",name,val);
 
   VERB2("Configuration setting: %s=%d",name,val);
-  TRYOLD(xbt_cfgelm_get(cfg,name,xbt_cfgelm_int,&variable));
+  variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_int);
 
   if (variable->max == 1) {
     if (variable->cb_rm && xbt_dynar_length(variable->content))
 
   if (variable->max == 1) {
     if (variable->cb_rm && xbt_dynar_length(variable->content))
@@ -697,7 +693,7 @@ xbt_cfg_set_int(xbt_cfg_t cfg,const char*name, int val) {
     xbt_dynar_set(variable->content,0,&val);
   } else {
     if (variable->max && xbt_dynar_length(variable->content) == variable->max)
     xbt_dynar_set(variable->content,0,&val);
   } else {
     if (variable->max && xbt_dynar_length(variable->content) == variable->max)
-      RAISE3(mismatch_error,
+      THROW3(mismatch_error,0,
              "Cannot add value %d to the config element %s since it's already full (size=%d)",
              val,name,variable->max); 
              
              "Cannot add value %d to the config element %s since it's already full (size=%d)",
              val,name,variable->max); 
              
@@ -706,7 +702,6 @@ xbt_cfg_set_int(xbt_cfg_t cfg,const char*name, int val) {
 
   if (variable->cb_set)
     (*variable->cb_set)(name, xbt_dynar_length(variable->content) -1);
 
   if (variable->cb_set)
     (*variable->cb_set)(name, xbt_dynar_length(variable->content) -1);
-  return no_error;
 }
 
 /** @brief Set or add a double value to \a name within \a cfg
 }
 
 /** @brief Set or add a double value to \a name within \a cfg
@@ -716,13 +711,12 @@ xbt_cfg_set_int(xbt_cfg_t cfg,const char*name, int val) {
  * \arg val the doule to set
  */ 
 
  * \arg val the doule to set
  */ 
 
-xbt_error_t
+void
 xbt_cfg_set_double(xbt_cfg_t cfg,const char*name, double val) {
   xbt_cfgelm_t variable;
 xbt_cfg_set_double(xbt_cfg_t cfg,const char*name, double val) {
   xbt_cfgelm_t variable;
-  xbt_error_t errcode;
 
   VERB2("Configuration setting: %s=%f",name,val);
 
   VERB2("Configuration setting: %s=%f",name,val);
-  TRYOLD(xbt_cfgelm_get(cfg,name,xbt_cfgelm_double,&variable));
+  variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_double);
 
   if (variable->max == 1) {
     if (variable->cb_rm && xbt_dynar_length(variable->content))
 
   if (variable->max == 1) {
     if (variable->cb_rm && xbt_dynar_length(variable->content))
@@ -731,7 +725,7 @@ xbt_cfg_set_double(xbt_cfg_t cfg,const char*name, double val) {
     xbt_dynar_set(variable->content,0,&val);
   } else {
     if (variable->max && xbt_dynar_length(variable->content) == variable->max)
     xbt_dynar_set(variable->content,0,&val);
   } else {
     if (variable->max && xbt_dynar_length(variable->content) == variable->max)
-      RAISE3(mismatch_error,
+      THROW3(mismatch_error,0,
              "Cannot add value %f to the config element %s since it's already full (size=%d)",
              val,name,variable->max); 
              
              "Cannot add value %f to the config element %s since it's already full (size=%d)",
              val,name,variable->max); 
              
@@ -740,7 +734,6 @@ xbt_cfg_set_double(xbt_cfg_t cfg,const char*name, double val) {
 
   if (variable->cb_set)
     (*variable->cb_set)(name, xbt_dynar_length(variable->content) -1);
 
   if (variable->cb_set)
     (*variable->cb_set)(name, xbt_dynar_length(variable->content) -1);
-  return no_error;
 }
 
 /** @brief Set or add a string value to \a name within \a cfg
 }
 
 /** @brief Set or add a string value to \a name within \a cfg
@@ -751,14 +744,13 @@ xbt_cfg_set_double(xbt_cfg_t cfg,const char*name, double val) {
  *
  */ 
 
  *
  */ 
 
-xbt_error_t
+void
 xbt_cfg_set_string(xbt_cfg_t cfg,const char*name, const char*val) { 
   xbt_cfgelm_t variable;
 xbt_cfg_set_string(xbt_cfg_t cfg,const char*name, const char*val) { 
   xbt_cfgelm_t variable;
-  xbt_error_t errcode;
   char *newval = xbt_strdup(val);
 
   VERB2("Configuration setting: %s=%s",name,val);
   char *newval = xbt_strdup(val);
 
   VERB2("Configuration setting: %s=%s",name,val);
-  TRYOLD(xbt_cfgelm_get(cfg,name,xbt_cfgelm_string,&variable));
+  variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_string);
 
   if (variable->max == 1) {
     if (variable->cb_rm && xbt_dynar_length(variable->content))
 
   if (variable->max == 1) {
     if (variable->cb_rm && xbt_dynar_length(variable->content))
@@ -767,7 +759,7 @@ xbt_cfg_set_string(xbt_cfg_t cfg,const char*name, const char*val) {
     xbt_dynar_set(variable->content,0,&newval);
   } else {
     if (variable->max && xbt_dynar_length(variable->content) == variable->max)
     xbt_dynar_set(variable->content,0,&newval);
   } else {
     if (variable->max && xbt_dynar_length(variable->content) == variable->max)
-      RAISE3(mismatch_error,
+      THROW3(mismatch_error,0,
              "Cannot add value %s to the config element %s since it's already full (size=%d)",
              name,val,variable->max); 
              
              "Cannot add value %s to the config element %s since it's already full (size=%d)",
              name,val,variable->max); 
              
@@ -776,7 +768,6 @@ xbt_cfg_set_string(xbt_cfg_t cfg,const char*name, const char*val) {
 
   if (variable->cb_set)
     (*variable->cb_set)(name, xbt_dynar_length(variable->content) -1);
 
   if (variable->cb_set)
     (*variable->cb_set)(name, xbt_dynar_length(variable->content) -1);
-  return no_error;
 }
 
 /** @brief Set or add an host value to \a name within \a cfg
 }
 
 /** @brief Set or add an host value to \a name within \a cfg
@@ -789,11 +780,10 @@ xbt_cfg_set_string(xbt_cfg_t cfg,const char*name, const char*val) {
  * \e host values are composed of a string (hostname) and an integer (port)
  */ 
 
  * \e host values are composed of a string (hostname) and an integer (port)
  */ 
 
-xbt_error_t 
+void
 xbt_cfg_set_host(xbt_cfg_t cfg,const char*name, 
                  const char *host,int port) {
   xbt_cfgelm_t variable;
 xbt_cfg_set_host(xbt_cfg_t cfg,const char*name, 
                  const char *host,int port) {
   xbt_cfgelm_t variable;
-  xbt_error_t errcode;
   xbt_host_t *val=xbt_new(xbt_host_t,1);
 
   VERB3("Configuration setting: %s=%s:%d",name,host,port);
   xbt_host_t *val=xbt_new(xbt_host_t,1);
 
   VERB3("Configuration setting: %s=%s:%d",name,host,port);
@@ -801,7 +791,7 @@ xbt_cfg_set_host(xbt_cfg_t cfg,const char*name,
   val->name = xbt_strdup(name);
   val->port = port;
 
   val->name = xbt_strdup(name);
   val->port = port;
 
-  TRYOLD(xbt_cfgelm_get(cfg,name,xbt_cfgelm_host,&variable));
+  variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_host);
 
   if (variable->max == 1) {
     if (variable->cb_rm && xbt_dynar_length(variable->content))
 
   if (variable->max == 1) {
     if (variable->cb_rm && xbt_dynar_length(variable->content))
@@ -810,7 +800,7 @@ xbt_cfg_set_host(xbt_cfg_t cfg,const char*name,
     xbt_dynar_set(variable->content,0,&val);
   } else {
     if (variable->max && xbt_dynar_length(variable->content) == variable->max)
     xbt_dynar_set(variable->content,0,&val);
   } else {
     if (variable->max && xbt_dynar_length(variable->content) == variable->max)
-      RAISE4(mismatch_error,
+      THROW4(mismatch_error,0,
              "Cannot add value %s:%d to the config element %s since it's already full (size=%d)",
              host,port,name,variable->max); 
              
              "Cannot add value %s:%d to the config element %s since it's already full (size=%d)",
              host,port,name,variable->max); 
              
@@ -819,7 +809,6 @@ xbt_cfg_set_host(xbt_cfg_t cfg,const char*name,
 
   if (variable->cb_set)
     (*variable->cb_set)(name, xbt_dynar_length(variable->content) -1);
 
   if (variable->cb_set)
     (*variable->cb_set)(name, xbt_dynar_length(variable->content) -1);
-  return no_error;
 }
 
 /* ---- [ Removing ] ---- */
 }
 
 /* ---- [ Removing ] ---- */
@@ -830,30 +819,28 @@ xbt_cfg_set_host(xbt_cfg_t cfg,const char*name,
  * \arg name the name of the variable
  * \arg val the value to be removed
  */
  * \arg name the name of the variable
  * \arg val the value to be removed
  */
-xbt_error_t xbt_cfg_rm_int(xbt_cfg_t cfg,const char*name, int val) {
+void xbt_cfg_rm_int(xbt_cfg_t cfg,const char*name, int val) {
 
   xbt_cfgelm_t variable;
   int cpt,seen;
 
   xbt_cfgelm_t variable;
   int cpt,seen;
-  xbt_error_t errcode;
 
 
+  variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_int);
+  
   if (xbt_dynar_length(variable->content) == variable->min)
   if (xbt_dynar_length(variable->content) == variable->min)
-    RAISE3(mismatch_error,
+    THROW3(mismatch_error,0,
            "Cannot remove value %d from the config element %s since it's already at its minimal size (=%d)",
            val,name,variable->min); 
 
            "Cannot remove value %d from the config element %s since it's already at its minimal size (=%d)",
            val,name,variable->min); 
 
-  TRYOLD(xbt_cfgelm_get(cfg,name,xbt_cfgelm_int,&variable));
-  
   xbt_dynar_foreach(variable->content,cpt,seen) {
     if (seen == val) {
       if (variable->cb_rm) (*variable->cb_rm)(name, cpt);
       xbt_dynar_cursor_rm(variable->content,&cpt);
   xbt_dynar_foreach(variable->content,cpt,seen) {
     if (seen == val) {
       if (variable->cb_rm) (*variable->cb_rm)(name, cpt);
       xbt_dynar_cursor_rm(variable->content,&cpt);
-      return no_error;
+      return;
     }
   }
 
     }
   }
 
-  ERROR2("Can't remove the value %d of config element %s: value not found.",
-        val,name);
-  return mismatch_error;
+  THROW2(mismatch_error,0,
+        "Can't remove the value %d of config element %s: value not found.",val,name);
 }
 
 /** @brief Remove the provided \e val double value from a variable
 }
 
 /** @brief Remove the provided \e val double value from a variable
@@ -863,30 +850,29 @@ xbt_error_t xbt_cfg_rm_int(xbt_cfg_t cfg,const char*name, int val) {
  * \arg val the value to be removed
  */
 
  * \arg val the value to be removed
  */
 
-xbt_error_t xbt_cfg_rm_double(xbt_cfg_t cfg,const char*name, double val) {
+void xbt_cfg_rm_double(xbt_cfg_t cfg,const char*name, double val) {
   xbt_cfgelm_t variable;
   int cpt;
   double seen;
   xbt_cfgelm_t variable;
   int cpt;
   double seen;
-  xbt_error_t errcode;
 
 
+  variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_double);
+  
   if (xbt_dynar_length(variable->content) == variable->min)
   if (xbt_dynar_length(variable->content) == variable->min)
-    RAISE3(mismatch_error,
+    THROW3(mismatch_error,0,
            "Cannot remove value %f from the config element %s since it's already at its minimal size (=%d)",
            val,name,variable->min); 
 
            "Cannot remove value %f from the config element %s since it's already at its minimal size (=%d)",
            val,name,variable->min); 
 
-  TRYOLD(xbt_cfgelm_get(cfg,name,xbt_cfgelm_double,&variable));
-  
   xbt_dynar_foreach(variable->content,cpt,seen) {
     if (seen == val) {
       xbt_dynar_cursor_rm(variable->content,&cpt);
   xbt_dynar_foreach(variable->content,cpt,seen) {
     if (seen == val) {
       xbt_dynar_cursor_rm(variable->content,&cpt);
-      if (variable->cb_rm) (*variable->cb_rm)(name, cpt);
-      return no_error;
+      if (variable->cb_rm)
+       (*variable->cb_rm)(name, cpt);
+      return;
     }
   }
 
     }
   }
 
-  ERROR2("Can't remove the value %f of config element %s: value not found.",
-        val,name);
-  return mismatch_error;
+  THROW2(mismatch_error,0,
+        "Can't remove the value %f of config element %s: value not found.",val,name);
 }
 
 /** @brief Remove the provided \e val string value from a variable
 }
 
 /** @brief Remove the provided \e val string value from a variable
@@ -895,31 +881,30 @@ xbt_error_t xbt_cfg_rm_double(xbt_cfg_t cfg,const char*name, double val) {
  * \arg name the name of the variable
  * \arg val the value of the string which will be removed
  */
  * \arg name the name of the variable
  * \arg val the value of the string which will be removed
  */
-xbt_error_t
+void
 xbt_cfg_rm_string(xbt_cfg_t cfg,const char*name, const char *val) {
   xbt_cfgelm_t variable;
   int cpt;
   char *seen;
 xbt_cfg_rm_string(xbt_cfg_t cfg,const char*name, const char *val) {
   xbt_cfgelm_t variable;
   int cpt;
   char *seen;
-  xbt_error_t errcode;
 
 
+  variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_string);
+  
   if (xbt_dynar_length(variable->content) == variable->min)
   if (xbt_dynar_length(variable->content) == variable->min)
-    RAISE3(mismatch_error,
+    THROW3(mismatch_error,0,
            "Cannot remove value %s from the config element %s since it's already at its minimal size (=%d)",
            name,val,variable->min); 
            
            "Cannot remove value %s from the config element %s since it's already at its minimal size (=%d)",
            name,val,variable->min); 
            
-  TRYOLD(xbt_cfgelm_get(cfg,name,xbt_cfgelm_string,&variable));
-  
   xbt_dynar_foreach(variable->content,cpt,seen) {
     if (!strcpy(seen,val)) {
   xbt_dynar_foreach(variable->content,cpt,seen) {
     if (!strcpy(seen,val)) {
-      if (variable->cb_rm) (*variable->cb_rm)(name, cpt);
+      if (variable->cb_rm)
+       (*variable->cb_rm)(name, cpt);
       xbt_dynar_cursor_rm(variable->content,&cpt);
       xbt_dynar_cursor_rm(variable->content,&cpt);
-      return no_error;
+      return;
     }
   }
 
     }
   }
 
-  ERROR2("Can't remove the value %s of config element %s: value not found.",
-        val,name);
-  return mismatch_error;
+  THROW2(mismatch_error,0,
+        "Can't remove the value %s of config element %s: value not found.",val,name);
 }
 
 /** @brief Remove the provided \e val host value from a variable
 }
 
 /** @brief Remove the provided \e val host value from a variable
@@ -930,53 +915,47 @@ xbt_cfg_rm_string(xbt_cfg_t cfg,const char*name, const char *val) {
  * \arg port the port number
  */
 
  * \arg port the port number
  */
 
-xbt_error_t
+void
 xbt_cfg_rm_host(xbt_cfg_t cfg,const char*name, const char *host,int port) {
   xbt_cfgelm_t variable;
   int cpt;
   xbt_host_t *seen;
 xbt_cfg_rm_host(xbt_cfg_t cfg,const char*name, const char *host,int port) {
   xbt_cfgelm_t variable;
   int cpt;
   xbt_host_t *seen;
-  xbt_error_t errcode;
 
 
+  variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_host);
+  
   if (xbt_dynar_length(variable->content) == variable->min)
   if (xbt_dynar_length(variable->content) == variable->min)
-    RAISE4(mismatch_error,
+    THROW4(mismatch_error,0,
            "Cannot remove value %s:%d from the config element %s since it's already at its minimal size (=%d)",
            host,port,name,variable->min); 
            
            "Cannot remove value %s:%d from the config element %s since it's already at its minimal size (=%d)",
            host,port,name,variable->min); 
            
-  TRYOLD(xbt_cfgelm_get(cfg,name,xbt_cfgelm_host,&variable));
-  
   xbt_dynar_foreach(variable->content,cpt,seen) {
     if (!strcpy(seen->name,host) && seen->port == port) {
       if (variable->cb_rm) (*variable->cb_rm)(name, cpt);
       xbt_dynar_cursor_rm(variable->content,&cpt);
   xbt_dynar_foreach(variable->content,cpt,seen) {
     if (!strcpy(seen->name,host) && seen->port == port) {
       if (variable->cb_rm) (*variable->cb_rm)(name, cpt);
       xbt_dynar_cursor_rm(variable->content,&cpt);
-      return no_error;
+      return;
     }
   }
 
     }
   }
 
-  ERROR3("Can't remove the value %s:%d of config element %s: value not found.",
+  THROW3(mismatch_error,0,
+        "Can't remove the value %s:%d of config element %s: value not found.",
         host,port,name);
         host,port,name);
-  return mismatch_error;
 }
 
 /** @brief Remove the \e pos th value from the provided variable */
 
 }
 
 /** @brief Remove the \e pos th value from the provided variable */
 
-xbt_error_t xbt_cfg_rm_at   (xbt_cfg_t cfg, const char *name, int pos) {
+void xbt_cfg_rm_at   (xbt_cfg_t cfg, const char *name, int pos) {
 
   xbt_cfgelm_t variable;
 
   xbt_cfgelm_t variable;
-  int cpt;
-  xbt_host_t *seen;
-  xbt_error_t errcode;
 
 
+  variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_any);
+  
   if (xbt_dynar_length(variable->content) == variable->min)
   if (xbt_dynar_length(variable->content) == variable->min)
-    RAISE3(mismatch_error,
+    THROW3(mismatch_error,0,
            "Cannot remove %dth value from the config element %s since it's already at its minimal size (=%d)",
            pos,name,variable->min); 
            "Cannot remove %dth value from the config element %s since it's already at its minimal size (=%d)",
            pos,name,variable->min); 
-           
-  TRYOLD(xbt_cfgelm_get(cfg,name,xbt_cfgelm_any,&variable));
   
   if (variable->cb_rm) (*variable->cb_rm)(name, pos);    
   xbt_dynar_remove_at(variable->content, pos, NULL);
   
   if (variable->cb_rm) (*variable->cb_rm)(name, pos);    
   xbt_dynar_remove_at(variable->content, pos, NULL);
-
-  return mismatch_error;
 }
 
 /** @brief Remove all the values from a variable
 }
 
 /** @brief Remove all the values from a variable
@@ -985,18 +964,20 @@ xbt_error_t xbt_cfg_rm_at   (xbt_cfg_t cfg, const char *name, int pos) {
  * \arg name the name of the variable
  */
 
  * \arg name the name of the variable
  */
 
-xbt_error_t 
+void
 xbt_cfg_empty(xbt_cfg_t cfg,const char*name) {
   xbt_cfgelm_t variable;
 xbt_cfg_empty(xbt_cfg_t cfg,const char*name) {
   xbt_cfgelm_t variable;
-
-  xbt_error_t errcode;
-
-  TRYCATCH(mismatch_error,
-          xbt_dict_get((xbt_dict_t)cfg,name,(void**)&variable));
-  if (errcode == mismatch_error) {
-    ERROR1("Can't empty  '%s' since this config element does not exist",
-          name);
-    return mismatch_error;
+  xbt_ex_t e;
+
+  TRY {
+    variable = xbt_dict_get((xbt_dict_t)cfg,name);
+  } CATCH(e) {
+    if (e.category == mismatch_error) {
+      xbt_ex_free(e);
+      THROW1(mismatch_error,0,
+            "Can't empty  '%s' since this config element does not exist", name);
+    }
+    RETHROW;
   }
 
   if (variable) {
   }
 
   if (variable) {
@@ -1009,7 +990,6 @@ xbt_cfg_empty(xbt_cfg_t cfg,const char*name) {
     }
     xbt_dynar_reset(variable->content);
   }
     }
     xbt_dynar_reset(variable->content);
   }
-  return no_error;
 }
 
 /*----[ Getting ]---------------------------------------------------------*/
 }
 
 /*----[ Getting ]---------------------------------------------------------*/
@@ -1026,22 +1006,16 @@ xbt_cfg_empty(xbt_cfg_t cfg,const char*name) {
  *
  * \warning the returned value is the actual content of the config set
  */
  *
  * \warning the returned value is the actual content of the config set
  */
-xbt_error_t
-xbt_cfg_get_int   (xbt_cfg_t  cfg,
-                   const char *name,
-                   int        *val) {
-  xbt_cfgelm_t variable;
-  xbt_error_t errcode;
-
-  TRYOLD(xbt_cfgelm_get(cfg,name,xbt_cfgelm_int,&variable));
+int 
+xbt_cfg_get_int (xbt_cfg_t  cfg, const char *name) {
+  xbt_cfgelm_t variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_int);
 
   if (xbt_dynar_length(variable->content) > 1) {
     WARN2("You asked for the first value of the config element '%s', but there is %lu values",
 
   if (xbt_dynar_length(variable->content) > 1) {
     WARN2("You asked for the first value of the config element '%s', but there is %lu values",
-            name, xbt_dynar_length(variable->content));
+         name, xbt_dynar_length(variable->content));
   }
 
   }
 
-  *val = xbt_dynar_get_as(variable->content, 0, int);
-  return no_error;
+  return xbt_dynar_get_as(variable->content, 0, int);
 }
 
 /** @brief Retrieve a double value of a variable (get a warning if not uniq)
 }
 
 /** @brief Retrieve a double value of a variable (get a warning if not uniq)
@@ -1057,22 +1031,16 @@ xbt_cfg_get_int   (xbt_cfg_t  cfg,
  * \warning the returned value is the actual content of the config set
  */
 
  * \warning the returned value is the actual content of the config set
  */
 
-xbt_error_t
-xbt_cfg_get_double(xbt_cfg_t  cfg,
-                   const char *name,
-                   double     *val) {
-  xbt_cfgelm_t variable;
-  xbt_error_t  errcode;
-
-  TRYOLD(xbt_cfgelm_get(cfg,name,xbt_cfgelm_double,&variable));
+double
+xbt_cfg_get_double(xbt_cfg_t  cfg, const char *name) {
+  xbt_cfgelm_t variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_double);
 
   if (xbt_dynar_length(variable->content) > 1) {
     WARN2("You asked for the first value of the config element '%s', but there is %lu values\n",
             name, xbt_dynar_length(variable->content));
   }
 
 
   if (xbt_dynar_length(variable->content) > 1) {
     WARN2("You asked for the first value of the config element '%s', but there is %lu values\n",
             name, xbt_dynar_length(variable->content));
   }
 
-  *val = xbt_dynar_get_as(variable->content, 0, double);
-  return no_error;
+  return xbt_dynar_get_as(variable->content, 0, double);
 }
 
 /** @brief Retrieve a string value of a variable (get a warning if not uniq)
 }
 
 /** @brief Retrieve a string value of a variable (get a warning if not uniq)
@@ -1088,23 +1056,15 @@ xbt_cfg_get_double(xbt_cfg_t  cfg,
  * \warning the returned value is the actual content of the config set
  */
 
  * \warning the returned value is the actual content of the config set
  */
 
-xbt_error_t xbt_cfg_get_string(xbt_cfg_t  cfg,
-                                const char *name,
-                                char      **val) {
-  xbt_cfgelm_t  variable;
-  xbt_error_t errcode;
-
-  *val=NULL;
-
-  TRYOLD(xbt_cfgelm_get(cfg,name,xbt_cfgelm_string,&variable));
+char* xbt_cfg_get_string(xbt_cfg_t  cfg, const char *name) {
+  xbt_cfgelm_t variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_string);
 
   if (xbt_dynar_length(variable->content) > 1) {
     WARN2("You asked for the first value of the config element '%s', but there is %lu values\n",
 
   if (xbt_dynar_length(variable->content) > 1) {
     WARN2("You asked for the first value of the config element '%s', but there is %lu values\n",
-            name, xbt_dynar_length(variable->content));
+         name, xbt_dynar_length(variable->content));
   }
 
   }
 
-  *val = xbt_dynar_get_as(variable->content, 0, char *);
-  return no_error;
+  return xbt_dynar_get_as(variable->content, 0, char *);
 }
 
 /** @brief Retrieve an host value of a variable (get a warning if not uniq)
 }
 
 /** @brief Retrieve an host value of a variable (get a warning if not uniq)
@@ -1121,15 +1081,12 @@ xbt_error_t xbt_cfg_get_string(xbt_cfg_t  cfg,
  * \warning the returned value is the actual content of the config set
  */
 
  * \warning the returned value is the actual content of the config set
  */
 
-xbt_error_t xbt_cfg_get_host  (xbt_cfg_t  cfg,
-                                const char *name,
-                                char      **host,
-                                int        *port) {
+void xbt_cfg_get_host  (xbt_cfg_t   cfg,  const char *name,
+                       char      **host, int        *port) {
   xbt_cfgelm_t variable;
   xbt_cfgelm_t variable;
-  xbt_error_t  errcode;
   xbt_host_t  *val;
 
   xbt_host_t  *val;
 
-  TRYOLD(xbt_cfgelm_get(cfg,name,xbt_cfgelm_host,&variable));
+  variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_host);
 
   if (xbt_dynar_length(variable->content) > 1) {
     WARN2("You asked for the first value of the config element '%s', but there is %lu values\n",
 
   if (xbt_dynar_length(variable->content) > 1) {
     WARN2("You asked for the first value of the config element '%s', but there is %lu values\n",
@@ -1139,8 +1096,6 @@ xbt_error_t xbt_cfg_get_host  (xbt_cfg_t  cfg,
   val = xbt_dynar_get_as(variable->content, 0, xbt_host_t*);
   *host=val->name;
   *port=val->port;
   val = xbt_dynar_get_as(variable->content, 0, xbt_host_t*);
   *host=val->name;
   *port=val->port;
-  
-  return no_error;
 }
 
 /** @brief Retrieve the dynar of all the values stored in a variable
 }
 
 /** @brief Retrieve the dynar of all the values stored in a variable
@@ -1153,87 +1108,58 @@ xbt_error_t xbt_cfg_get_host  (xbt_cfg_t  cfg,
  *
  * \warning the returned value is the actual content of the config set
  */
  *
  * \warning the returned value is the actual content of the config set
  */
-xbt_error_t xbt_cfg_get_dynar (xbt_cfg_t    cfg,
-                                const char   *name,
-                                xbt_dynar_t *dynar) {
+xbt_dynar_t xbt_cfg_get_dynar (xbt_cfg_t    cfg, const char *name) {
   xbt_cfgelm_t variable;
   xbt_cfgelm_t variable;
-  xbt_error_t  errcode = xbt_dict_get((xbt_dict_t)cfg,name,
-                                       (void**)&variable);
-
-  if (errcode == mismatch_error) {
-    ERROR1("No registered variable %s in this config set",
-          name);
-    return mismatch_error;
+  xbt_ex_t     e;
+
+  TRY {
+    variable = xbt_dict_get((xbt_dict_t)cfg,name);
+  } CATCH(e) {
+    if (e.category == mismatch_error) {
+      xbt_ex_free(e);
+      THROW1(mismatch_error,0,
+            "No registered variable %s in this config set",name);
+    }
+    RETHROW;
   }
   }
-  if (errcode != no_error)
-     return errcode;
 
 
-  *dynar = variable->content;
-  return no_error;
+  return variable->content;
 }
 
 
 /** @brief Retrieve one of the integer value of a variable */
 }
 
 
 /** @brief Retrieve one of the integer value of a variable */
-xbt_error_t
-xbt_cfg_get_int_at(xbt_cfg_t   cfg,
-                   const char *name,
-                   int         pos,
-                   int        *val) {
+int
+xbt_cfg_get_int_at(xbt_cfg_t cfg, const char *name, int pos) {
                   
                   
-  xbt_cfgelm_t variable;
-  xbt_error_t errcode;
-
-  TRYOLD(xbt_cfgelm_get(cfg,name,xbt_cfgelm_int,&variable));
-  *val = xbt_dynar_get_as(variable->content, pos, int);
-  return no_error; 
+  xbt_cfgelm_t variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_int);
+  return xbt_dynar_get_as(variable->content, pos, int);
 }
 
 /** @brief Retrieve one of the double value of a variable */
 }
 
 /** @brief Retrieve one of the double value of a variable */
-xbt_error_t
-xbt_cfg_get_double_at(xbt_cfg_t   cfg,
-                      const char *name,
-                      int         pos,
-                      double     *val) {
+double
+xbt_cfg_get_double_at(xbt_cfg_t cfg, const char *name, int pos) {
                   
                   
-  xbt_cfgelm_t variable;
-  xbt_error_t errcode;
-
-  TRYOLD(xbt_cfgelm_get(cfg,name,xbt_cfgelm_double,&variable));
-  *val = xbt_dynar_get_as(variable->content, pos, double);
-  return no_error; 
+  xbt_cfgelm_t variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_double);
+  return xbt_dynar_get_as(variable->content, pos, double);
 }
 
 
 /** @brief Retrieve one of the string value of a variable */
 }
 
 
 /** @brief Retrieve one of the string value of a variable */
-xbt_error_t
-xbt_cfg_get_string_at(xbt_cfg_t   cfg,
-                      const char *name,
-                      int         pos,
-                      char      **val) {
+char*
+xbt_cfg_get_string_at(xbt_cfg_t cfg, const char *name, int pos) {
                   
                   
-  xbt_cfgelm_t variable;
-  xbt_error_t errcode;
-
-  TRYOLD(xbt_cfgelm_get(cfg,name,xbt_cfgelm_string,&variable));
-  *val = xbt_dynar_get_as(variable->content, pos, char*);
-  return no_error; 
+  xbt_cfgelm_t variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_string);
+  return xbt_dynar_get_as(variable->content, pos, char*);
 }
 
 /** @brief Retrieve one of the host value of a variable */
 }
 
 /** @brief Retrieve one of the host value of a variable */
-xbt_error_t
-xbt_cfg_get_host_at(xbt_cfg_t   cfg,
-                    const char *name,
-                    int         pos,
-                    char      **host,
-                    int        *port) {
+void
+xbt_cfg_get_host_at(xbt_cfg_t cfg, const char *name, int pos,
+                    char **host, int *port) {
                   
                   
-  xbt_cfgelm_t variable;
-  xbt_error_t errcode;
-  xbt_host_t *val;
+  xbt_cfgelm_t variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_int);
+  xbt_host_t *val = xbt_dynar_get_ptr(variable->content, pos);
 
 
-  TRYOLD(xbt_cfgelm_get(cfg,name,xbt_cfgelm_int,&variable));
-  val = xbt_dynar_get_ptr(variable->content, pos);
   *port = val->port;
   *host = val->name;
   *port = val->port;
   *host = val->name;
-  return no_error; 
 }
 }
index a4f1096..c242608 100644 (file)
@@ -147,7 +147,7 @@ static ex_ctx_t *__context_ex_ctx(void)
 }
 
 /* callback: termination */
 }
 
 /* callback: termination */
-static void __context_ex_terminate(ex_t *e)
+static void __context_ex_terminate(xbt_ex_t *e)
 {
   exit(e->value);
 }
 {
   exit(e->value);
 }
index 3f0ed6c..5dcb9e6 100644 (file)
@@ -7,9 +7,9 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "xbt/ex.h"
 #include "dict_private.h"
 
 #include "dict_private.h"
 
-
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(dict,xbt,
    "Dictionaries provide the same functionnalities than hash tables");
 /*####[ Private prototypes ]#################################################*/
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(dict,xbt,
    "Dictionaries provide the same functionnalities than hash tables");
 /*####[ Private prototypes ]#################################################*/
@@ -105,15 +105,14 @@ xbt_dict_set(xbt_dict_t     dict,
  *
  * Search the given \a key. mismatch_error when not found.
  */
  *
  * Search the given \a key. mismatch_error when not found.
  */
-xbt_error_t
-xbt_dict_get_ext(xbt_dict_t     dict,
-                 const char     *key,
-                 int             key_len,
-                 /* OUT */void **data) {
+void *
+xbt_dict_get_ext(xbt_dict_t      dict,
+                 const char     *key,
+                 int             key_len) {
 
   xbt_assert(dict);
 
 
   xbt_assert(dict);
 
-  return xbt_dictelm_get_ext(dict->head, key, key_len, data);
+  return xbt_dictelm_get_ext(dict->head, key, key_len);
 }
 
 /**
 }
 
 /**
@@ -124,15 +123,35 @@ xbt_dict_get_ext(xbt_dict_t     dict,
  * \param data the data that we are looking for
  * \return xbt_error
  *
  * \param data the data that we are looking for
  * \return xbt_error
  *
- * Search the given \a key. mismatch_error when not found.
+ * Search the given \a key. THROWs mismatch_error when not found. 
+ * Check xbt_dict_get_or_null() for a version returning NULL without exception when 
+ * not found.
  */
  */
-xbt_error_t
+void *
 xbt_dict_get(xbt_dict_t     dict,
 xbt_dict_get(xbt_dict_t     dict,
-             const char     *key,
-             /* OUT */void **data) {
+             const char     *key) {
   xbt_assert(dict);
 
   xbt_assert(dict);
 
-  return xbt_dictelm_get(dict->head, key, data);
+  return xbt_dictelm_get(dict->head, key);
+}
+
+/**
+ * \brief like xbt_dict_get(), but returning NULL when not found
+ */
+void *
+xbt_dict_get_or_null(xbt_dict_t     dict,
+                    const char     *key) {
+  xbt_ex_t e;
+  void *res;
+  TRY {
+    res = xbt_dictelm_get(dict->head, key);
+  } CATCH(e) {
+    if (e.category != mismatch_error) 
+      RETHROW;
+    xbt_ex_free(e);
+    res=NULL;
+  }
+  return res;
 }
 
 
 }
 
 
@@ -166,8 +185,8 @@ xbt_dict_remove_ext(xbt_dict_t  dict,
 xbt_error_t
 xbt_dict_remove(xbt_dict_t  dict,
                 const char  *key) {
 xbt_error_t
 xbt_dict_remove(xbt_dict_t  dict,
                 const char  *key) {
-  if (!dict) 
-     RAISE1(mismatch_error,"Asked to remove key %s from NULL dict",key);
+  if (!dict)
+    THROW1(arg_error,0,"Asked to remove key %s from NULL dict",key);
 
   return xbt_dictelm_remove(dict->head, key);
 }
 
   return xbt_dictelm_remove(dict->head, key);
 }
index 71780eb..9cce716 100644 (file)
@@ -8,6 +8,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "xbt/misc.h"
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "xbt/misc.h"
+#include "xbt/ex.h"
 #include "dict_private.h"
 
 #include <string.h> /* strlen() */
 #include "dict_private.h"
 
 #include <string.h> /* strlen() */
@@ -73,16 +74,13 @@ xbt_dict_cursor_free(xbt_dict_cursor_t *cursor) {
  * Sanity check to see if the head contains something
  */
 static _XBT_INLINE
  * Sanity check to see if the head contains something
  */
 static _XBT_INLINE
-xbt_error_t
+void
 __cursor_not_null(xbt_dict_cursor_t cursor) {
 
   xbt_assert0(cursor, "Null cursor");
 
 __cursor_not_null(xbt_dict_cursor_t cursor) {
 
   xbt_assert0(cursor, "Null cursor");
 
-  if (!cursor->head) {
-    return mismatch_error;
-  }
-
-  return no_error;
+  if (!cursor->head)
+    THROW0(arg_error,0,"Null headed cursor");
 }
 
 
 }
 
 
@@ -171,8 +169,8 @@ int
 xbt_dict_cursor_get_or_free(xbt_dict_cursor_t  *cursor,
                            char               **key,
                            void               **data) {
 xbt_dict_cursor_get_or_free(xbt_dict_cursor_t  *cursor,
                            char               **key,
                            void               **data) {
-  xbt_error_t  errcode = no_error;
-  int           key_len = 0;
+  int      key_len = 0;
+  xbt_ex_t e;
   
   if (!cursor || !(*cursor))
     return FALSE;
   
   if (!cursor || !(*cursor))
     return FALSE;
@@ -185,16 +183,16 @@ xbt_dict_cursor_get_or_free(xbt_dict_cursor_t  *cursor,
   *key    = xbt_dynar_get_as((*cursor)->keys,     (*cursor)->pos,     char*);
   key_len = xbt_dynar_get_as((*cursor)->key_lens, (*cursor)->pos_len, int);
 
   *key    = xbt_dynar_get_as((*cursor)->keys,     (*cursor)->pos,     char*);
   key_len = xbt_dynar_get_as((*cursor)->key_lens, (*cursor)->pos_len, int);
 
-  errcode = xbt_dictelm_get_ext((*cursor)->head, *key, key_len, data);
-  if (errcode == mismatch_error) {
-    xbt_dict_cursor_free(cursor);
-    return FALSE;
+  TRY {
+    *data = xbt_dictelm_get_ext((*cursor)->head, *key, key_len);
+  } CATCH(e) {
+    if (e.category == mismatch_error) {
+      xbt_dict_cursor_free(cursor);
+      xbt_ex_free(e);
+      return FALSE;
+    }
+    RETHROW;
   }
   }
-
-  xbt_assert1(errcode == no_error,
-              "Unexpected problem while retrieving the content of cursor. Got %s",
-              xbt_error_name(errcode));
-
   return TRUE;
 }
 
   return TRUE;
 }
 
@@ -203,16 +201,11 @@ xbt_dict_cursor_get_or_free(xbt_dict_cursor_t  *cursor,
  * @param cursor: the cursor
  * @param key where to put the key
  */
  * @param cursor: the cursor
  * @param key where to put the key
  */
-xbt_error_t
-xbt_dict_cursor_get_key(xbt_dict_cursor_t   cursor,
-                         /*OUT*/char        **key) {
-  xbt_error_t errcode = no_error;
+char *
+xbt_dict_cursor_get_key(xbt_dict_cursor_t   cursor) {
+  __cursor_not_null(cursor);
 
 
-  TRYOLD(__cursor_not_null(cursor));
-
-  *key = xbt_dynar_get_as(cursor->keys, cursor->pos - 1, char*);
-
-  return errcode;
+  return xbt_dynar_get_as(cursor->keys, cursor->pos - 1, char*);
 }
 
 /**
 }
 
 /**
@@ -220,21 +213,17 @@ xbt_dict_cursor_get_key(xbt_dict_cursor_t   cursor,
  * @param cursor the cursor
  * @param data where to put the data
  */
  * @param cursor the cursor
  * @param data where to put the data
  */
-xbt_error_t
-xbt_dict_cursor_get_data(xbt_dict_cursor_t   cursor,
-                          /*OUT*/void        **data) {
-  xbt_error_t  errcode = no_error;
+void *
+xbt_dict_cursor_get_data(xbt_dict_cursor_t   cursor) {
   char         *key     = NULL;
   int           key_len = 0;
 
   char         *key     = NULL;
   int           key_len = 0;
 
-  TRYOLD(__cursor_not_null(cursor));
+  __cursor_not_null(cursor);
 
   key     = xbt_dynar_get_as(cursor->keys,     cursor->pos-1,  char *);
   key_len = xbt_dynar_get_as(cursor->key_lens, cursor->pos_len-1, int);
 
 
   key     = xbt_dynar_get_as(cursor->keys,     cursor->pos-1,  char *);
   key_len = xbt_dynar_get_as(cursor->key_lens, cursor->pos_len-1, int);
 
-  TRYOLD(xbt_dictelm_get_ext(cursor->head, key, key_len, data));
-
-  return errcode;
+  return xbt_dictelm_get_ext(cursor->head, key, key_len);
 }
 
 
 }
 
 
index 714f0bc..8987493 100644 (file)
@@ -7,6 +7,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "xbt/ex.h"
 #include "portable.h" /* PRINTF_STR */
 #include "dict_private.h"  /* prototypes of this module */
 
 #include "portable.h" /* PRINTF_STR */
 #include "dict_private.h"  /* prototypes of this module */
 
@@ -49,11 +50,10 @@ static void _xbt_dictelm_set_rec(s_xbt_dictelm_t *head,
                                  int             offset,
                                  void           *data,
                                  void_f_pvoid_t *free_f);
                                  int             offset,
                                  void           *data,
                                  void_f_pvoid_t *free_f);
-static xbt_error_t _xbt_dictelm_get_rec(s_xbt_dictelm_t *head,
-                                              const char     *key,
-                                              int             key_len,
-                                              int             offset,
-                                              /* OUT */void **data);
+static void * _xbt_dictelm_get_rec(s_xbt_dictelm_t *head,
+                                   const char     *key,
+                                  int             key_len,
+                                  int             offset);
 static xbt_error_t _xbt_dictelm_remove_rec(s_xbt_dictelm_t *head,
                                             const char     *key,
                                             int             key_len,
 static xbt_error_t _xbt_dictelm_remove_rec(s_xbt_dictelm_t *head,
                                             const char     *key,
                                             int             key_len,
@@ -570,7 +570,7 @@ _xbt_dictelm_set_rec(s_xbt_dictelm_t     *p_head,
     }
 
   default:
     }
 
   default:
-    DIE_IMPOSSIBLE;
+    THROW_IMPOSSIBLE;
   }
 }
 
   }
 }
 
@@ -647,12 +647,11 @@ xbt_dictelm_set(s_xbt_dictelm_t **pp_head,
  * Search the given @key. mismatch_error when not found.
  */
 static 
  * Search the given @key. mismatch_error when not found.
  */
 static 
-xbt_error_t
+void *
 _xbt_dictelm_get_rec(s_xbt_dictelm_t *p_head,
                      const char     *key,
                      int             key_len,
 _xbt_dictelm_get_rec(s_xbt_dictelm_t *p_head,
                      const char     *key,
                      int             key_len,
-                     int             offset,
-                     void **data) {
+                     int             offset) {
 
   CDEBUG3(dict_search, "Search %.*s in %p", key_len, key, (void*)p_head); 
 
 
   CDEBUG3(dict_search, "Search %.*s in %p", key_len, key, (void*)p_head); 
 
@@ -660,33 +659,26 @@ _xbt_dictelm_get_rec(s_xbt_dictelm_t *p_head,
 
   /* we did enough recursion, we're done */
   if (offset >= key_len) {
 
   /* we did enough recursion, we're done */
   if (offset >= key_len) {
-    *data = p_head->content;
-
-    return no_error;
+    return p_head->content;
   }
 
   {
     int match = 0;
     int pos   = 0;
 
   }
 
   {
     int match = 0;
     int pos   = 0;
 
-    *data = NULL; /* Let's be clean */
-
     /*** Search where is the good child, and how good it is ***/
     _xbt_dictelm_child_search(p_head, key, key_len, &pos, &offset, &match);
 
     switch (match) {
 
     case 0: /* no child have a common prefix */
     /*** Search where is the good child, and how good it is ***/
     _xbt_dictelm_child_search(p_head, key, key_len, &pos, &offset, &match);
 
     switch (match) {
 
     case 0: /* no child have a common prefix */
-      return mismatch_error;
+      THROW1(mismatch_error,0,"key '%s' not found",key);
 
     case 1: /* A child have exactly this key => Got it */
       {
         s_xbt_dictelm_t *p_child = NULL;
 
     case 1: /* A child have exactly this key => Got it */
       {
         s_xbt_dictelm_t *p_child = NULL;
-
         p_child = xbt_dynar_get_as(p_head->sub, pos, s_xbt_dictelm_t*);
         p_child = xbt_dynar_get_as(p_head->sub, pos, s_xbt_dictelm_t*);
-        *data = p_child->content;
-
-        return no_error;
+        return p_child->content;
       }
 
     case 2: /* A child constitutes a prefix of the key => recurse */
       }
 
     case 2: /* A child constitutes a prefix of the key => recurse */
@@ -695,17 +687,17 @@ _xbt_dictelm_get_rec(s_xbt_dictelm_t *p_head,
 
         p_child = xbt_dynar_get_as(p_head->sub, pos, s_xbt_dictelm_t*);
 
 
         p_child = xbt_dynar_get_as(p_head->sub, pos, s_xbt_dictelm_t*);
 
-        return _xbt_dictelm_get_rec(p_child, key, key_len, offset, data);
+        return _xbt_dictelm_get_rec(p_child, key, key_len, offset);
       }
 
     case 3: /* The key is a prefix of the child => not found */
       }
 
     case 3: /* The key is a prefix of the child => not found */
-      return mismatch_error;
+      THROW1(mismatch_error,0,"key %s not found",key);
 
     case 4: /* A child share a common prefix with this key => not found */
 
     case 4: /* A child share a common prefix with this key => not found */
-      return mismatch_error;
+      THROW1(mismatch_error,0,"key %s not found",key);
 
     default:
 
     default:
-      RAISE_IMPOSSIBLE;
+      THROW_IMPOSSIBLE;
     }
   }
 }
     }
   }
 }
@@ -720,17 +712,15 @@ _xbt_dictelm_get_rec(s_xbt_dictelm_t *p_head,
  *
  * Search the given @key. mismatch_error when not found.
  */
  *
  * Search the given @key. mismatch_error when not found.
  */
-xbt_error_t
+void *
 xbt_dictelm_get_ext(s_xbt_dictelm_t *p_head,
 xbt_dictelm_get_ext(s_xbt_dictelm_t *p_head,
-                         const char     *key,
-                         int             key_len,
-                         /* OUT */void **data) {
+                   const char      *key,
+                   int              key_len) {
   /* there is no head, go to hell */
   /* there is no head, go to hell */
-  if (!p_head) {
-    return mismatch_error;
-  }
+  if (!p_head)
+    THROW1(mismatch_error,0,"Key '%s' not found in dict",key);
 
 
-  return _xbt_dictelm_get_rec(p_head, key, key_len, 0, data);
+  return _xbt_dictelm_get_rec(p_head, key, key_len, 0);
 }
 
 /**
 }
 
 /**
@@ -743,12 +733,11 @@ xbt_dictelm_get_ext(s_xbt_dictelm_t *p_head,
  *
  * Search the given @key. mismatch_error when not found.
  */
  *
  * Search the given @key. mismatch_error when not found.
  */
-xbt_error_t
-xbt_dictelm_get(s_xbt_dictelm_t    *p_head,
-                   const char     *key,
-                   /* OUT */void **data) {
+void *
+xbt_dictelm_get(s_xbt_dictelm_t *p_head,
+               const char      *key) {
 
 
-  return xbt_dictelm_get_ext(p_head, key, strlen(key), data);
+  return xbt_dictelm_get_ext(p_head, key, strlen(key));
 }
 
 /*----[ _xbt_dict_collapse ]------------------------------------------------*/
 }
 
 /*----[ _xbt_dict_collapse ]------------------------------------------------*/
@@ -861,7 +850,7 @@ _xbt_dictelm_remove_rec(xbt_dictelm_t head,
         p_child = xbt_dynar_get_as(head->sub, pos, s_xbt_dictelm_t*);
         /*DEBUG5("Recurse on child %d of %p to remove %.*s (prefix=%d)",
           pos, (void*)p_child, key+offset, key_len-offset,offset);*/
         p_child = xbt_dynar_get_as(head->sub, pos, s_xbt_dictelm_t*);
         /*DEBUG5("Recurse on child %d of %p to remove %.*s (prefix=%d)",
           pos, (void*)p_child, key+offset, key_len-offset,offset);*/
-        TRYOLD(_xbt_dictelm_remove_rec(p_child, key, key_len, offset));
+        _xbt_dictelm_remove_rec(p_child, key, key_len, offset);
 
         _collapse_if_need(head, pos, old_offset);
        return no_error;
 
         _collapse_if_need(head, pos, old_offset);
        return no_error;
@@ -876,7 +865,7 @@ _xbt_dictelm_remove_rec(xbt_dictelm_t head,
 
 
     default:
 
 
     default:
-      RAISE_IMPOSSIBLE;
+      THROW_IMPOSSIBLE;
 
     }
   }
 
     }
   }
@@ -896,9 +885,8 @@ xbt_dictelm_remove_ext(xbt_dictelm_t head,
                        const char  *key,
                        int          key_len) {
   /* there is no head, go to hell */
                        const char  *key,
                        int          key_len) {
   /* there is no head, go to hell */
-  if (!head) {
-    RAISE0(mismatch_error, "there is no head, go to hell");
-  }
+  if (!head) 
+    THROW1(arg_error,0,"Asked to remove key %s from NULL dict",key);
   
   return _xbt_dictelm_remove_rec(head, key, key_len, 0);
 }
   
   return _xbt_dictelm_remove_rec(head, key, key_len, 0);
 }
index 606e4b7..7b85efa 100644 (file)
@@ -27,13 +27,13 @@ static void _free_dict(void*d) {
  * Dynars are not modified during the operation.
  */
 
  * Dynars are not modified during the operation.
  */
 
-xbt_error_t
+void
 xbt_multidict_set_ext(xbt_dict_t  mdict,
                       xbt_dynar_t keys, xbt_dynar_t     lens,
                       void       *data, void_f_pvoid_t *free_ctn) {
 xbt_multidict_set_ext(xbt_dict_t  mdict,
                       xbt_dynar_t keys, xbt_dynar_t     lens,
                       void       *data, void_f_pvoid_t *free_ctn) {
-                      
-  xbt_error_t errcode;
-  xbt_dict_t thislevel,nextlevel;
+      
+  xbt_ex_t e;
+  xbt_dict_t thislevel,nextlevel=NULL;
   int i;
   
   unsigned long int thislen;
   int i;
   
   unsigned long int thislen;
@@ -55,13 +55,17 @@ xbt_multidict_set_ext(xbt_dict_t  mdict,
     DEBUG5("multi_set: at level %d, len=%ld, key=%p |%*s|", i, thislen, thiskey, (int)thislen,thiskey);
 
     /* search the dict of next level */
     DEBUG5("multi_set: at level %d, len=%ld, key=%p |%*s|", i, thislen, thiskey, (int)thislen,thiskey);
 
     /* search the dict of next level */
-    TRYCATCH(xbt_dict_get_ext(thislevel, thiskey, thislen, (void*)&nextlevel), mismatch_error);
-
-    /* make sure the dict of next level exists */
-    if (errcode == mismatch_error) {
-      nextlevel=xbt_dict_new();
-      VERB1("Create a dict (%p)",nextlevel);
-      xbt_dict_set_ext(thislevel, thiskey, thislen, nextlevel, &_free_dict);
+    TRY {
+      nextlevel = xbt_dict_get_ext(thislevel, thiskey, thislen);
+    } CATCH(e) {
+      if (e.category == arg_error || e.category == mismatch_error) {
+       /* make sure the dict of next level exists */
+       nextlevel=xbt_dict_new();
+       VERB1("Create a dict (%p)",nextlevel);
+       xbt_dict_set_ext(thislevel, thiskey, thislen, nextlevel, &_free_dict);
+      } else {
+       RETHROW;
+      }
     }
   }
 
     }
   }
 
@@ -69,8 +73,6 @@ xbt_multidict_set_ext(xbt_dict_t  mdict,
   xbt_dynar_get_cpy(lens, i, &thislen);
   
   xbt_dict_set_ext(thislevel, thiskey, thislen, data, free_ctn);
   xbt_dynar_get_cpy(lens, i, &thislen);
   
   xbt_dict_set_ext(thislevel, thiskey, thislen, data, free_ctn);
-  
-  return no_error;
 }
 
 /** \brief Insert \e data under all the keys contained in \e keys
 }
 
 /** \brief Insert \e data under all the keys contained in \e keys
@@ -80,11 +82,10 @@ xbt_multidict_set_ext(xbt_dict_t  mdict,
  * \arg data: what to store in the structure
  * \arg free_ctn: function to use to free the pushed content on need
  */
  * \arg data: what to store in the structure
  * \arg free_ctn: function to use to free the pushed content on need
  */
-xbt_error_t
+void
 xbt_multidict_set(xbt_dict_t  mdict,
                   xbt_dynar_t keys,
                   void       *data,  void_f_pvoid_t *free_ctn) {
 xbt_multidict_set(xbt_dict_t  mdict,
                   xbt_dynar_t keys,
                   void       *data,  void_f_pvoid_t *free_ctn) {
-  xbt_error_t errcode;
   xbt_dynar_t lens = xbt_dynar_new(sizeof(unsigned long int),NULL);
   int i;
 
   xbt_dynar_t lens = xbt_dynar_new(sizeof(unsigned long int),NULL);
   int i;
 
@@ -95,9 +96,9 @@ xbt_multidict_set(xbt_dict_t  mdict,
     xbt_dynar_push(lens,&thislen);
   }
 
     xbt_dynar_push(lens,&thislen);
   }
 
-  errcode = xbt_multidict_set_ext(mdict, keys, lens, data, free_ctn);
+  xbt_multidict_set_ext(mdict, keys, lens, data, free_ctn);
   xbt_dynar_free(&lens);         
   xbt_dynar_free(&lens);         
-  return errcode;
+
 }
 
 /** \brief Insert \e data under all the keys contained in \e keys, providing their sizes in \e lens.
 }
 
 /** \brief Insert \e data under all the keys contained in \e keys, providing their sizes in \e lens.
@@ -110,11 +111,9 @@ xbt_multidict_set(xbt_dict_t  mdict,
  *
  * Dynars are not modified during the operation.
  */
  *
  * Dynars are not modified during the operation.
  */
-xbt_error_t
+void *
 xbt_multidict_get_ext(xbt_dict_t  mdict,
 xbt_multidict_get_ext(xbt_dict_t  mdict,
-                      xbt_dynar_t keys,   xbt_dynar_t lens,
-                      /*OUT*/void **data) {
-  xbt_error_t errcode;
+                      xbt_dynar_t keys,   xbt_dynar_t lens) {
   xbt_dict_t thislevel,nextlevel;
   int i;
 
   xbt_dict_t thislevel,nextlevel;
   int i;
 
@@ -138,20 +137,20 @@ xbt_multidict_get_ext(xbt_dict_t  mdict,
       i, thislevel, thislen, thiskey, (int)thislen,thiskey);
 
     /* search the dict of next level: let mismatch raise if not found */
       i, thislevel, thislen, thiskey, (int)thislen,thiskey);
 
     /* search the dict of next level: let mismatch raise if not found */
-    TRYOLD(xbt_dict_get_ext(thislevel, thiskey, thislen, (void*)&nextlevel));
+    nextlevel = xbt_dict_get_ext(thislevel, thiskey, thislen);
   }
   
   xbt_dynar_get_cpy(keys, i, &thiskey);
   xbt_dynar_get_cpy(lens, i, &thislen);
   
   }
   
   xbt_dynar_get_cpy(keys, i, &thiskey);
   xbt_dynar_get_cpy(lens, i, &thislen);
   
-  return xbt_dict_get_ext(thislevel, thiskey, thislen, data);
+  return xbt_dict_get_ext(thislevel, thiskey, thislen);
 }
 
 }
 
-xbt_error_t
-xbt_multidict_get(xbt_dict_t mdict, xbt_dynar_t keys, /*OUT*/void **data) {
-  xbt_error_t errcode;
+void *
+xbt_multidict_get(xbt_dict_t mdict, xbt_dynar_t keys) {
   xbt_dynar_t lens = xbt_dynar_new(sizeof(unsigned long int),NULL);
   int i;
   xbt_dynar_t lens = xbt_dynar_new(sizeof(unsigned long int),NULL);
   int i;
+  void *res;
   
   for (i = 0; i < xbt_dynar_length(keys); i++) {
     char *thiskey = xbt_dynar_get_as(keys, i, char*);
   
   for (i = 0; i < xbt_dynar_length(keys); i++) {
     char *thiskey = xbt_dynar_get_as(keys, i, char*);
@@ -159,9 +158,9 @@ xbt_multidict_get(xbt_dict_t mdict, xbt_dynar_t keys, /*OUT*/void **data) {
     xbt_dynar_push(lens,&thislen);
   }
 
     xbt_dynar_push(lens,&thislen);
   }
 
-  errcode = xbt_multidict_get_ext(mdict, keys, lens, data),
+  res = xbt_multidict_get_ext(mdict, keys, lens),
   xbt_dynar_free(&lens);         
   xbt_dynar_free(&lens);         
-  return errcode;
+  return res;
 }
 
 
 }
 
 
@@ -180,9 +179,9 @@ xbt_multidict_get(xbt_dict_t mdict, xbt_dynar_t keys, /*OUT*/void **data) {
 
 xbt_error_t
 xbt_multidict_remove_ext(xbt_dict_t mdict, xbt_dynar_t keys, xbt_dynar_t lens) {
 
 xbt_error_t
 xbt_multidict_remove_ext(xbt_dict_t mdict, xbt_dynar_t keys, xbt_dynar_t lens) {
-  xbt_error_t errcode;
-  xbt_dict_t thislevel,nextlevel;
+  xbt_dict_t thislevel,nextlevel=NULL;
   int i;
   int i;
+  xbt_ex_t e;
 
   unsigned long int thislen;
   char *thiskey;
 
   unsigned long int thislen;
   char *thiskey;
@@ -199,11 +198,15 @@ xbt_multidict_remove_ext(xbt_dict_t mdict, xbt_dynar_t keys, xbt_dynar_t lens) {
     xbt_dynar_get_cpy(lens, i, &thislen);
 
     /* search the dict of next level */
     xbt_dynar_get_cpy(lens, i, &thislen);
 
     /* search the dict of next level */
-    TRYCATCH(xbt_dict_get_ext(thislevel, thiskey, thislen, (void*)&nextlevel), mismatch_error);
-
-    /* If non-existant entry, nothing to do */
-    if (errcode == mismatch_error)
-      return no_error;
+    TRY {
+      nextlevel = xbt_dict_get_ext(thislevel, thiskey, thislen);
+    } CATCH(e) {
+      /* If non-existant entry, nothing to do */
+      if (e.category == arg_error) 
+       xbt_ex_free(e);
+      else 
+       RETHROW;
+    }
   }
 
   xbt_dynar_get_cpy(keys, i, &thiskey);
   }
 
   xbt_dynar_get_cpy(keys, i, &thiskey);
index c0117b5..e48877c 100644 (file)
@@ -14,6 +14,7 @@
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
 #include "xbt/error.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
 #include "xbt/error.h"
+#include "xbt/ex.h"
 #include "xbt/dynar.h"
 #include "xbt/dict.h"
 
 #include "xbt/dynar.h"
 #include "xbt/dict.h"
 
@@ -36,25 +37,23 @@ typedef struct xbt_dict_ {
 typedef struct xbt_dict_cursor_ s_xbt_dict_cursor_t;
 
 /*####[ Function prototypes ]################################################*/
 typedef struct xbt_dict_cursor_ s_xbt_dict_cursor_t;
 
 /*####[ Function prototypes ]################################################*/
-void xbt_dictelm_free      (s_xbt_dictelm_t **pp_elm);
+void  xbt_dictelm_free      (s_xbt_dictelm_t **pp_elm);
 
 
-void xbt_dictelm_set       (s_xbt_dictelm_t **pp_head,
+void  xbt_dictelm_set       (s_xbt_dictelm_t **pp_head,
                             const char      *_key,
                             void            *data,
                             void_f_pvoid_t  *free_ctn);
                             const char      *_key,
                             void            *data,
                             void_f_pvoid_t  *free_ctn);
-void xbt_dictelm_set_ext   (s_xbt_dictelm_t **pp_head,
+void  xbt_dictelm_set_ext   (s_xbt_dictelm_t **pp_head,
                             const char      *_key,
                             int              key_len,
                             void            *data,
                             void_f_pvoid_t  *free_ctn);
 
                             const char      *_key,
                             int              key_len,
                             void            *data,
                             void_f_pvoid_t  *free_ctn);
 
-xbt_error_t xbt_dictelm_get       (s_xbt_dictelm_t *p_head,
-                                    const char     *key,
-                                    /* OUT */void **data);
-xbt_error_t xbt_dictelm_get_ext   (s_xbt_dictelm_t *p_head,
-                                    const char     *key,
-                                    int             key_len,
-                                    /* OUT */void **data);
+void* xbt_dictelm_get       (s_xbt_dictelm_t *p_head, 
+                            const char     *key);
+void* xbt_dictelm_get_ext   (s_xbt_dictelm_t *p_head,
+                            const char     *key,
+                            int             key_len);
 
 xbt_error_t xbt_dictelm_remove    (s_xbt_dictelm_t *p_head,
                                     const char  *key);
 
 xbt_error_t xbt_dictelm_remove    (s_xbt_dictelm_t *p_head,
                                     const char  *key);
index 8534dde..f41d17f 100644 (file)
@@ -424,7 +424,7 @@ xbt_dynar_pop_ptr(xbt_dynar_t  const dynar) {
 /** @brief Get and remove the last element of the dynar */
 void
 xbt_dynar_pop(xbt_dynar_t  const dynar,
 /** @brief Get and remove the last element of the dynar */
 void
 xbt_dynar_pop(xbt_dynar_t  const dynar,
-               void         * const dst) {
+              void         * const dst) {
 
   /* sanity checks done by remove_at */
   DEBUG1("Pop %p",(void*)dynar);
 
   /* sanity checks done by remove_at */
   DEBUG1("Pop %p",(void*)dynar);
index ff7c3af..ba74531 100644 (file)
@@ -23,12 +23,12 @@ const char *xbt_error_name(xbt_error_t errcode)  {
    switch (errcode) {
       
     case no_error: return "success";
    switch (errcode) {
       
     case no_error: return "success";
-    case mismatch_error: return "mismatch";
-    case system_error: return "system";
-    case network_error: return "network";
-    case timeout_error: return "timeout";
-    case thread_error: return "thread";
-    case unknown_error: return "unclassified";
+    case old_mismatch_error: return "mismatch";
+    case old_system_error: return "system";
+    case old_network_error: return "network";
+    case old_timeout_error: return "timeout";
+    case old_thread_error: return "thread";
+    case old_unknown_error: return "unclassified";
     default:
       return "SEVERE ERROR in error repporting module";
    }
     default:
       return "SEVERE ERROR in error repporting module";
    }
index 8e34e72..1f0c064 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <execinfo.h>
 
 #include "xbt/ex.h"
 
 
 #include "xbt/ex.h"
 
@@ -42,19 +43,46 @@ ex_ctx_t *__xbt_ex_ctx_default(void) {
 }
 
 /* default __ex_terminate callback function */
 }
 
 /* default __ex_terminate callback function */
-void __xbt_ex_terminate_default(ex_t *e) {
-
-    fprintf(stderr,
-            "** SimGrid: UNCAUGHT EXCEPTION:\n"
-           "** (%d/%d) %s\n"
-            "** Thrown by %s%s%s at %s:%d:%s\n",
-           e->category, e->value, e->msg,
-           e->procname, (e->host?"@":""),(e->host?e->host:""),
-           e->file,e->line,e->func);
-    abort();
+void __xbt_ex_terminate_default(xbt_ex_t *e)  {
+  char **strings;
+  size_t i;
+
+  fprintf(stderr,
+         "** SimGrid: UNCAUGHT EXCEPTION: category: %s; value: %d\n"
+         "** %s\n"
+         "** Thrown by %s%s%s at %s:%d:%s\n",
+         xbt_ex_catname(e->category), e->value, e->msg,
+         e->procname, (e->host?"@":""),(e->host?e->host:"localhost"),
+         e->file,e->line,e->func);
+
+  fprintf(stderr,"** Backtrace:\n");
+  strings = backtrace_symbols (e->bt, e->used);
+
+  for (i = 0; i < e->used; i++)
+     printf ("   %s\n", strings[i]);
+
+  free (strings);
+  abort();
 }
 
 /* the externally visible API */
 ex_ctx_cb_t  __xbt_ex_ctx       = &__xbt_ex_ctx_default;
 ex_term_cb_t __xbt_ex_terminate = &__xbt_ex_terminate_default;
 
 }
 
 /* the externally visible API */
 ex_ctx_cb_t  __xbt_ex_ctx       = &__xbt_ex_ctx_default;
 ex_term_cb_t __xbt_ex_terminate = &__xbt_ex_terminate_default;
 
+void xbt_ex_free(xbt_ex_t e) {
+  free(e.msg);
+}
+
+/** \brief returns a short name for the given exception category */
+const char * xbt_ex_catname(xbt_errcat_t cat) {
+  switch (cat) {
+  case unknown_error: return  "unknown_err";
+  case arg_error:      return "invalid_arg";
+  case mismatch_error: return "mismatch";
+  case system_error:   return "system_err";
+  case network_error:  return "network_err";
+  case timeout_error:  return "timeout";
+  case thread_error:   return "thread_err";
+  default:             return "INVALID_ERR";
+  }
+}
index f282a6e..70983fb 100644 (file)
@@ -9,7 +9,7 @@
 #include "xbt/error.h"
 #include "fifo_private.h"
 
 #include "xbt/error.h"
 #include "fifo_private.h"
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(fifo,xbt,"FIFO");
+/*XBT_LOG_NEW_DEFAULT_SUBCATEGORY(fifo,xbt,"FIFO"); UNUSED SO FAR */
 
 /** \defgroup XBT_fifo A generic workqueue
   *  \brief This section describes the API to generic workqueue. These functions
 
 /** \defgroup XBT_fifo A generic workqueue
   *  \brief This section describes the API to generic workqueue. These functions
index 83ee7ff..ee613d9 100644 (file)
@@ -9,8 +9,9 @@
 
 
 #include <stdarg.h>
 
 
 #include <stdarg.h>
-#include "gras_config.h" /* to get a workgin stdarg.h */
+#include "gras_config.h" /* to get a working stdarg.h */
 #include <ctype.h>
 #include <ctype.h>
+#include <stdio.h> /* snprintf */
 
 #include "xbt_modinter.h"
 
 
 #include "xbt_modinter.h"
 
@@ -497,7 +498,7 @@ static xbt_error_t _xbt_log_cat_searchsub(xbt_log_category_t cat,char *name,
     if (errcode==no_error)
       return no_error;
   }
     if (errcode==no_error)
       return no_error;
   }
-  return mismatch_error;
+  return old_mismatch_error;
 }
 
 static void _cleanup_double_spaces(char *s) {
 }
 
 static void _cleanup_double_spaces(char *s) {
@@ -583,7 +584,7 @@ void xbt_log_control_set(const char* control_string) {
     _xbt_log_parse_setting(p,set);
     
     errcode = _xbt_log_cat_searchsub(&_XBT_LOGV(root),set->catname,&cat);
     _xbt_log_parse_setting(p,set);
     
     errcode = _xbt_log_cat_searchsub(&_XBT_LOGV(root),set->catname,&cat);
-    if (errcode == mismatch_error) {
+    if (errcode == old_mismatch_error) {
       DEBUG0("Store for further application");
       DEBUG1("push %p to the settings",(void*)set);
       xbt_dynar_push(xbt_log_settings,&set);
       DEBUG0("Store for further application");
       DEBUG1("push %p to the settings",(void*)set);
       xbt_dynar_push(xbt_log_settings,&set);
index e97eed9..f4bc0e1 100644 (file)
@@ -10,7 +10,7 @@
 #include "xbt/misc.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
 #include "xbt/misc.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
-#include "xbt/error.h"
+#include "xbt/ex.h"
 #include "xbt/dynar.h"
 #include "xbt/dict.h"
 
 #include "xbt/dynar.h"
 #include "xbt/dict.h"
 
@@ -60,17 +60,29 @@ void xbt_set_add    (xbt_set_t      set,
                      xbt_set_elm_t  elm,
                      void_f_pvoid_t *free_func) {
 
                      xbt_set_elm_t  elm,
                      void_f_pvoid_t *free_func) {
 
-  xbt_error_t   errcode;
-  xbt_set_elm_t found_in_dict;
+  int found = 1;
+  xbt_set_elm_t found_in_dict = NULL;
+  xbt_ex_t e;
 
   if (elm->name_len <= 0) {
     elm->name_len = strlen(elm->name);
   }
 
 
   if (elm->name_len <= 0) {
     elm->name_len = strlen(elm->name);
   }
 
-  errcode = xbt_dict_get_ext (set->dict, 
-                                   elm->name, elm->name_len,
-                                   (void**)&found_in_dict);
-  if (errcode == no_error) {
+  TRY {
+    found_in_dict = xbt_dict_get_ext (set->dict, 
+                                     elm->name, elm->name_len);
+  } CATCH(e) {
+    if (e.category != mismatch_error) 
+      RETHROW;
+    found = 0;
+    elm->ID = xbt_dynar_length( set->dynar );
+    xbt_dict_set_ext(set->dict, elm->name, elm->name_len, elm, free_func);
+    xbt_dynar_set(set->dynar, elm->ID, &elm);
+    DEBUG2("Insertion of key '%s' (id %d)", elm->name, elm->ID);
+    xbt_ex_free(e);
+  }
+  
+  if (found) {
     if (elm == found_in_dict) {
       DEBUG2("Ignoring request to insert the same element twice (key %s ; id %d)",
             elm->name, elm->ID);
     if (elm == found_in_dict) {
       DEBUG2("Ignoring request to insert the same element twice (key %s ; id %d)",
             elm->name, elm->ID);
@@ -82,15 +94,7 @@ void xbt_set_add    (xbt_set_t      set,
       xbt_dynar_set(set->dynar, elm->ID, &elm);
       return;
     }
       xbt_dynar_set(set->dynar, elm->ID, &elm);
       return;
     }
-  } else {
-    xbt_assert_error(mismatch_error);
   }
   }
-
-  elm->ID = xbt_dynar_length( set->dynar );
-  xbt_dict_set_ext(set->dict, elm->name, elm->name_len, elm, free_func);
-  xbt_dynar_set(set->dynar, elm->ID, &elm);
-  DEBUG2("Insertion of key '%s' (id %d)", elm->name, elm->ID);
-
 }
 
 /** @brief Retrive data by providing its name.
 }
 
 /** @brief Retrive data by providing its name.
@@ -99,13 +103,10 @@ void xbt_set_add    (xbt_set_t      set,
  * \param name Name of the searched cell
  * \param dst where to put the found data into
  */
  * \param name Name of the searched cell
  * \param dst where to put the found data into
  */
-xbt_error_t xbt_set_get_by_name    (xbt_set_t     set,
-                                     const char     *name,
-                                     /* OUT */xbt_set_elm_t *dst) {
-  xbt_error_t errcode;
-  errcode = xbt_dict_get_ext(set->dict, name, strlen(name), (void**) dst);
-  DEBUG2("Lookup key %s: %s",name,xbt_error_name(errcode));
-  return errcode;
+xbt_set_elm_t xbt_set_get_by_name    (xbt_set_t     set,
+                                     const char     *name) {
+  DEBUG1("Lookup key %s",name);
+  return xbt_dict_get_ext(set->dict, name, strlen(name));
 }
 
 /** @brief Retrive data by providing its name and the length of the name
 }
 
 /** @brief Retrive data by providing its name and the length of the name
@@ -118,12 +119,11 @@ xbt_error_t xbt_set_get_by_name    (xbt_set_t     set,
  * This is useful when strlen cannot be trusted because you don't use a char*
  * as name, you weirdo.
  */
  * This is useful when strlen cannot be trusted because you don't use a char*
  * as name, you weirdo.
  */
-xbt_error_t xbt_set_get_by_name_ext(xbt_set_t      set,
+xbt_set_elm_t xbt_set_get_by_name_ext(xbt_set_t      set,
                                      const char     *name,
                                      const char     *name,
-                                     int             name_len,
-                                     /* OUT */xbt_set_elm_t *dst) {
+                                     int             name_len) {
 
 
-  return xbt_dict_get_ext (set->dict, name, name_len, (void**)dst);
+  return xbt_dict_get_ext (set->dict, name, name_len);
 }
 
 /** @brief Retrive data by providing its ID
 }
 
 /** @brief Retrive data by providing its ID
@@ -134,17 +134,16 @@ xbt_error_t xbt_set_get_by_name_ext(xbt_set_t      set,
  *
  * @warning, if the ID does not exists, you're getting into trouble
  */
  *
  * @warning, if the ID does not exists, you're getting into trouble
  */
-xbt_error_t xbt_set_get_by_id      (xbt_set_t      set,
-                                     int             id,
-                                     /* OUT */xbt_set_elm_t *dst) {
-
+xbt_set_elm_t xbt_set_get_by_id (xbt_set_t set, int id) {
+  xbt_set_elm_t res;
+  
   /* Don't bother checking the bounds, the dynar does so */
 
   /* Don't bother checking the bounds, the dynar does so */
 
-  *dst = xbt_dynar_get_as(set->dynar,id,xbt_set_elm_t);
+  res = xbt_dynar_get_as(set->dynar,id,xbt_set_elm_t);
   DEBUG3("Lookup type of id %d (of %lu): %s", 
   DEBUG3("Lookup type of id %d (of %lu): %s", 
-        id, xbt_dynar_length(set->dynar), (*dst)->name);
+        id, xbt_dynar_length(set->dynar), res->name);
   
   
-  return no_error;
+  return res;
 }
 
 /***
 }
 
 /***
index 58bdb0f..6d86b28 100644 (file)
@@ -38,7 +38,7 @@ double xbt_os_time(void) {
 #endif /* HAVE_GETTIMEOFDAY? */        
 }
 
 #endif /* HAVE_GETTIMEOFDAY? */        
 }
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sysdep, xbt, "System dependency");
+/*XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sysdep, xbt, "System dependency");*/
 
 
 struct s_xbt_os_timer {
 
 
 struct s_xbt_os_timer {
index 1477880..4ef95f8 100644 (file)
@@ -20,98 +20,85 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
 int r_arch;
 const char *filename = "datadesc_usage.out";  
 
 int r_arch;
 const char *filename = "datadesc_usage.out";  
 
-xbt_error_t
+void
 write_read(gras_datadesc_type_t type,void *src, void *dst, 
           gras_socket_t sock, int direction);
 
 write_read(gras_datadesc_type_t type,void *src, void *dst, 
           gras_socket_t sock, int direction);
 
-xbt_error_t
+void
 write_read(gras_datadesc_type_t type,void *src, void *dst, 
           gras_socket_t sock, int direction) {
 write_read(gras_datadesc_type_t type,void *src, void *dst, 
           gras_socket_t sock, int direction) {
-  xbt_error_t errcode;
    
   /* write */
   if (direction == RW) 
    
   /* write */
   if (direction == RW) 
-    TRYOLD(gras_socket_client_from_file(filename,&sock));
+    sock = gras_socket_client_from_file(filename);
   if (direction == WRITE || direction == RW)
   if (direction == WRITE || direction == RW)
-    TRYOLD(gras_datadesc_send(sock, type, src));
-/*  TRYOLD(gras_datadesc_gen_send(sock, type, src));*/
+    gras_datadesc_send(sock, type, src);
+/*  gras_datadesc_gen_send(sock, type, src);*/
   if (direction == RW) 
     gras_socket_close(sock);
    
   /* read */
   if (direction == RW) 
   if (direction == RW) 
     gras_socket_close(sock);
    
   /* read */
   if (direction == RW) 
-    TRYOLD(gras_socket_server_from_file(filename,&sock));
+    sock = gras_socket_server_from_file(filename);
 
   if (direction == READ || direction == RW)
 
   if (direction == READ || direction == RW)
-    TRYOLD(gras_datadesc_recv(sock, type, r_arch, dst));
+    gras_datadesc_recv(sock, type, r_arch, dst);
 
   if (direction == RW) 
     gras_socket_close(sock);
 
   if (direction == RW) 
     gras_socket_close(sock);
-  
-  return no_error;
 }
 
 }
 
-xbt_error_t test_int(gras_socket_t sock, int direction);
-xbt_error_t test_float(gras_socket_t sock, int direction);
-xbt_error_t test_double(gras_socket_t sock, int direction);
-xbt_error_t test_array(gras_socket_t sock, int direction);
-xbt_error_t test_dynar_scal(gras_socket_t sock, int direction);
-xbt_error_t test_intref(gras_socket_t sock, int direction);
-xbt_error_t test_string(gras_socket_t sock, int direction);
+void test_int(gras_socket_t sock, int direction);
+void test_float(gras_socket_t sock, int direction);
+void test_double(gras_socket_t sock, int direction);
+void test_array(gras_socket_t sock, int direction);
+void test_dynar_scal(gras_socket_t sock, int direction);
+void test_intref(gras_socket_t sock, int direction);
+void test_string(gras_socket_t sock, int direction);
 
 
-xbt_error_t test_homostruct(gras_socket_t sock, int direction);
-xbt_error_t test_hetestruct(gras_socket_t sock, int direction);
-xbt_error_t test_nestedstruct(gras_socket_t sock, int direction);
-xbt_error_t test_chain_list(gras_socket_t sock, int direction);
-xbt_error_t test_graph(gras_socket_t sock, int direction);
-xbt_error_t test_dynar_ref(gras_socket_t sock, int direction);
+void test_homostruct(gras_socket_t sock, int direction);
+void test_hetestruct(gras_socket_t sock, int direction);
+void test_nestedstruct(gras_socket_t sock, int direction);
+void test_chain_list(gras_socket_t sock, int direction);
+void test_graph(gras_socket_t sock, int direction);
+void test_dynar_ref(gras_socket_t sock, int direction);
 
 
-xbt_error_t test_pbio(gras_socket_t sock, int direction);
-xbt_error_t test_clause(gras_socket_t sock, int direction);
+void test_pbio(gras_socket_t sock, int direction);
+void test_clause(gras_socket_t sock, int direction);
 
 /* defined in datadesc_structures.c, which in perl generated */
 
 /* defined in datadesc_structures.c, which in perl generated */
-xbt_error_t test_structures(gras_socket_t sock, int direction); 
+void test_structures(gras_socket_t sock, int direction); 
 
 
 
 
 
 
-xbt_error_t test_int(gras_socket_t sock, int direction) {
-  xbt_error_t errcode;
+void test_int(gras_socket_t sock, int direction) {
   int i=5,j;
   
   INFO0("---- Test on integer ----");
   int i=5,j;
   
   INFO0("---- Test on integer ----");
-  TRYOLD(write_read(gras_datadesc_by_name("int"), &i,&j, sock,direction));
-  if (direction == READ || direction == RW) {
+  write_read(gras_datadesc_by_name("int"), &i,&j, sock,direction);
+  if (direction == READ || direction == RW) 
     xbt_assert(i == j);
     xbt_assert(i == j);
-  }
-  return no_error;
 }
 }
-xbt_error_t test_float(gras_socket_t sock, int direction) {
-  xbt_error_t errcode;
+void test_float(gras_socket_t sock, int direction) {
   float i=5.0,j;
   
   INFO0("---- Test on float ----");
   float i=5.0,j;
   
   INFO0("---- Test on float ----");
-  TRYOLD(write_read(gras_datadesc_by_name("float"), &i,&j, sock,direction));
-  if (direction == READ || direction == RW) {
+  write_read(gras_datadesc_by_name("float"), &i,&j, sock,direction);
+  if (direction == READ || direction == RW)
     xbt_assert2(i == j,"%f != %f",i,j);
     xbt_assert2(i == j,"%f != %f",i,j);
-  }
-  return no_error;
 }
 }
-xbt_error_t test_double(gras_socket_t sock, int direction) {
-  xbt_error_t errcode;
+void test_double(gras_socket_t sock, int direction) {
   double i=-3252355.1234,j;
   
   INFO0("---- Test on double ----");
   double i=-3252355.1234,j;
   
   INFO0("---- Test on double ----");
-  TRYOLD(write_read(gras_datadesc_by_name("double"), &i,&j, sock,direction));
-  if (direction == READ || direction == RW) {
+  write_read(gras_datadesc_by_name("double"), &i,&j, sock,direction);
+  if (direction == READ || direction == RW)
     xbt_assert2(i == j,"%f != %f",i,j);
     xbt_assert2(i == j,"%f != %f",i,j);
-  }
-  return no_error;
 }
 
 #define SIZE 5
 typedef int array[SIZE];
 }
 
 #define SIZE 5
 typedef int array[SIZE];
-xbt_error_t test_array(gras_socket_t sock, int direction) {
-  xbt_error_t errcode;
+void test_array(gras_socket_t sock, int direction) {
   gras_datadesc_type_t my_type;
   
   array i = { 35212,-6226,74337,11414,7733};
   gras_datadesc_type_t my_type;
   
   array i = { 35212,-6226,74337,11414,7733};
@@ -124,7 +111,7 @@ xbt_error_t test_array(gras_socket_t sock, int direction) {
                                    gras_datadesc_by_name("int"),
                                    SIZE);
 
                                    gras_datadesc_by_name("int"),
                                    SIZE);
 
-  TRYOLD(write_read(my_type, &i,&j, sock,direction));
+  write_read(my_type, &i,&j, sock,direction);
   if (direction == READ || direction == RW) {
     for (cpt=0; cpt<SIZE; cpt++) {
       DEBUG1("Test spot %d",cpt);
   if (direction == READ || direction == RW) {
     for (cpt=0; cpt<SIZE; cpt++) {
       DEBUG1("Test spot %d",cpt);
@@ -132,12 +119,10 @@ xbt_error_t test_array(gras_socket_t sock, int direction) {
                   cpt,i[cpt],cpt,j[cpt]);
     }
   }
                   cpt,i[cpt],cpt,j[cpt]);
     }
   }
-  return no_error;
 }
 /*** Dynar of scalar ***/
 
 }
 /*** Dynar of scalar ***/
 
-xbt_error_t test_dynar_scal(gras_socket_t sock, int direction){
-  xbt_error_t errcode;
+void test_dynar_scal(gras_socket_t sock, int direction){
   gras_datadesc_type_t my_type;
   xbt_dynar_t i,j;
   int cpt;
   gras_datadesc_type_t my_type;
   xbt_dynar_t i,j;
   int cpt;
@@ -150,7 +135,7 @@ xbt_error_t test_dynar_scal(gras_socket_t sock, int direction){
     DEBUG2("Push %d, length=%lu",cpt, xbt_dynar_length(i));
   }
 /*  xbt_dynar_dump(i);*/
     DEBUG2("Push %d, length=%lu",cpt, xbt_dynar_length(i));
   }
 /*  xbt_dynar_dump(i);*/
-  TRYOLD(write_read(my_type, &i,&j, sock, direction));
+  write_read(my_type, &i,&j, sock, direction);
 /*  xbt_dynar_dump(j);*/
   if (direction == READ || direction == RW) {
      for (cpt=0; cpt<64; cpt++){
 /*  xbt_dynar_dump(j);*/
   if (direction == READ || direction == RW) {
      for (cpt=0; cpt<64; cpt++){
@@ -164,11 +149,8 @@ xbt_error_t test_dynar_scal(gras_socket_t sock, int direction){
      xbt_dynar_free(&j);
   }
   xbt_dynar_free(&i);
      xbt_dynar_free(&j);
   }
   xbt_dynar_free(&i);
-
-  return no_error;
 }
 }
-xbt_error_t test_intref(gras_socket_t sock, int direction) {
-  xbt_error_t errcode;
+void test_intref(gras_socket_t sock, int direction) {
   gras_datadesc_type_t my_type;
   int *i,*j;
   
   gras_datadesc_type_t my_type;
   int *i,*j;
   
@@ -179,26 +161,24 @@ xbt_error_t test_intref(gras_socket_t sock, int direction) {
 
   my_type = gras_datadesc_ref("int*",gras_datadesc_by_name("int"));
 
 
   my_type = gras_datadesc_ref("int*",gras_datadesc_by_name("int"));
 
-  TRYOLD(write_read(my_type, &i,&j, sock,direction));
+  write_read(my_type, &i,&j, sock,direction);
   if (direction == READ || direction == RW) {
     xbt_assert(*i == *j);
     free(j);
   }
   free(i);
   if (direction == READ || direction == RW) {
     xbt_assert(*i == *j);
     free(j);
   }
   free(i);
-  return no_error;
 }
 
 /***
  *** string (dynamic array)
  ***/ 
 }
 
 /***
  *** string (dynamic array)
  ***/ 
-xbt_error_t test_string(gras_socket_t sock, int direction) {
-  xbt_error_t errcode;
+void test_string(gras_socket_t sock, int direction) {
   char *i=xbt_strdup("Some data"), *j=NULL;
   int cpt;
   
   INFO0("---- Test on string (ref to dynamic array) ----");
   char *i=xbt_strdup("Some data"), *j=NULL;
   int cpt;
   
   INFO0("---- Test on string (ref to dynamic array) ----");
-  TRYOLD(write_read(gras_datadesc_by_name("string"), &i,&j,
-                sock,direction));
+  write_read(gras_datadesc_by_name("string"), &i,&j,
+            sock,direction);
   if (direction == READ || direction == RW) {
     for (cpt=0; cpt<strlen(i); cpt++) {
       xbt_assert4(i[cpt] == j[cpt],"i[%d]=%c  !=  j[%d]=%c",
   if (direction == READ || direction == RW) {
     for (cpt=0; cpt<strlen(i); cpt++) {
       xbt_assert4(i[cpt] == j[cpt],"i[%d]=%c  !=  j[%d]=%c",
@@ -207,7 +187,6 @@ xbt_error_t test_string(gras_socket_t sock, int direction) {
     free(j);
   }
   free(i);
     free(j);
   }
   free(i);
-  return no_error;
 }
 
 
 }
 
 
@@ -217,8 +196,7 @@ xbt_error_t test_string(gras_socket_t sock, int direction) {
 typedef struct {
   int a,b,c,d;
 } homostruct;
 typedef struct {
   int a,b,c,d;
 } homostruct;
-xbt_error_t test_homostruct(gras_socket_t sock, int direction) {
-  xbt_error_t errcode;
+void test_homostruct(gras_socket_t sock, int direction) {
   gras_datadesc_type_t my_type;
   homostruct *i, *j; 
 
   gras_datadesc_type_t my_type;
   homostruct *i, *j; 
 
@@ -242,7 +220,7 @@ xbt_error_t test_homostruct(gras_socket_t sock, int direction) {
   i->a = 2235;    i->b = 433425;
   i->c = -23423;  i->d = -235235;
 
   i->a = 2235;    i->b = 433425;
   i->c = -23423;  i->d = -235235;
 
-  TRYOLD(write_read(my_type, &i,&j, sock,direction));
+  write_read(my_type, &i,&j, sock,direction);
   if (direction == READ || direction == RW) {
     xbt_assert2(i->a == j->a,"i->a=%d != j->a=%d",i->a,j->a);
     xbt_assert(i->b == j->b);
   if (direction == READ || direction == RW) {
     xbt_assert2(i->a == j->a,"i->a=%d != j->a=%d",i->a,j->a);
     xbt_assert(i->b == j->b);
@@ -251,7 +229,6 @@ xbt_error_t test_homostruct(gras_socket_t sock, int direction) {
     free(j);
   }
   free(i);
     free(j);
   }
   free(i);
-  return no_error;
 }
 
 /***
 }
 
 /***
@@ -263,8 +240,7 @@ typedef struct {
   unsigned char c2;
   unsigned long int l2;
 } hetestruct;
   unsigned char c2;
   unsigned long int l2;
 } hetestruct;
-xbt_error_t test_hetestruct(gras_socket_t sock, int direction) {
-  xbt_error_t errcode;
+void test_hetestruct(gras_socket_t sock, int direction) {
   gras_datadesc_type_t my_type;
   hetestruct *i, *j; 
 
   gras_datadesc_type_t my_type;
   hetestruct *i, *j; 
 
@@ -288,7 +264,7 @@ xbt_error_t test_hetestruct(gras_socket_t sock, int direction) {
   i->c1 = 's'; i->l1 = 123455;
   i->c2 = 'e'; i->l2 = 774531;
 
   i->c1 = 's'; i->l1 = 123455;
   i->c2 = 'e'; i->l2 = 774531;
 
-  TRYOLD(write_read(my_type, &i,&j, sock,direction));
+  write_read(my_type, &i,&j, sock,direction);
   if (direction == READ || direction == RW) {
     xbt_assert(i->c1 == j->c1);
     xbt_assert(i->c2 == j->c2);
   if (direction == READ || direction == RW) {
     xbt_assert(i->c1 == j->c1);
     xbt_assert(i->c2 == j->c2);
@@ -297,7 +273,6 @@ xbt_error_t test_hetestruct(gras_socket_t sock, int direction) {
     free(j);
   }
   free(i);
     free(j);
   }
   free(i);
-  return no_error;
 }
 
 /***
 }
 
 /***
@@ -307,8 +282,7 @@ typedef struct {
   hetestruct hete;
   homostruct homo;
 } nestedstruct;
   hetestruct hete;
   homostruct homo;
 } nestedstruct;
-xbt_error_t test_nestedstruct(gras_socket_t sock, int direction) {
-  xbt_error_t errcode;
+void test_nestedstruct(gras_socket_t sock, int direction) {
   gras_datadesc_type_t my_type;
   nestedstruct *i, *j; 
 
   gras_datadesc_type_t my_type;
   nestedstruct *i, *j; 
 
@@ -330,7 +304,7 @@ xbt_error_t test_nestedstruct(gras_socket_t sock, int direction) {
   i->hete.c1 = 's'; i->hete.l1 = 123455;
   i->hete.c2 = 'e'; i->hete.l2 = 774531;
 
   i->hete.c1 = 's'; i->hete.l1 = 123455;
   i->hete.c2 = 'e'; i->hete.l2 = 774531;
 
-  TRYOLD(write_read(my_type, &i,&j, sock,direction));
+  write_read(my_type, &i,&j, sock,direction);
   if (direction == READ || direction == RW) {
     xbt_assert(i->homo.a == j->homo.a);
     xbt_assert(i->homo.b == j->homo.b);
   if (direction == READ || direction == RW) {
     xbt_assert(i->homo.a == j->homo.a);
     xbt_assert(i->homo.b == j->homo.b);
@@ -343,7 +317,6 @@ xbt_error_t test_nestedstruct(gras_socket_t sock, int direction) {
     free(j);
   }
   free(i);
     free(j);
   }
   free(i);
-  return no_error;
 }
 
 /***
 }
 
 /***
@@ -354,13 +327,12 @@ struct s_chained_list {
   int          v;
   chained_list_t *l;
 };
   int          v;
   chained_list_t *l;
 };
-xbt_error_t declare_chained_list_type(void);
+void declare_chained_list_type(void);
 chained_list_t *cons(int v, chained_list_t *l);
 void list_free(chained_list_t *l);
 int list_eq(chained_list_t*i,chained_list_t*j);
 
 chained_list_t *cons(int v, chained_list_t *l);
 void list_free(chained_list_t *l);
 int list_eq(chained_list_t*i,chained_list_t*j);
 
-xbt_error_t declare_chained_list_type(void) {
-  xbt_error_t errcode;
+void declare_chained_list_type(void) {
   gras_datadesc_type_t my_type,ref_my_type;
 
   my_type=gras_datadesc_struct("chained_list_t");
   gras_datadesc_type_t my_type,ref_my_type;
 
   my_type=gras_datadesc_struct("chained_list_t");
@@ -369,8 +341,6 @@ xbt_error_t declare_chained_list_type(void) {
   gras_datadesc_struct_append(my_type,"v", gras_datadesc_by_name("int"));
   gras_datadesc_struct_append(my_type,"l", ref_my_type);
   gras_datadesc_struct_close(my_type);
   gras_datadesc_struct_append(my_type,"v", gras_datadesc_by_name("int"));
   gras_datadesc_struct_append(my_type,"l", ref_my_type);
   gras_datadesc_struct_close(my_type);
-
-  return no_error;
 }
 
 chained_list_t * cons(int v, chained_list_t *l) {
 }
 
 chained_list_t * cons(int v, chained_list_t *l) {
@@ -393,8 +363,7 @@ int list_eq(chained_list_t*i,chained_list_t*j) {
     return 0;
   return list_eq(i->l, j->l); 
 }
     return 0;
   return list_eq(i->l, j->l); 
 }
-xbt_error_t test_chain_list(gras_socket_t sock, int direction) {
-  xbt_error_t errcode;
+void test_chain_list(gras_socket_t sock, int direction) {
   chained_list_t *i, *j; 
 
   INFO0("---- Test on chained list ----");
   chained_list_t *i, *j; 
 
   INFO0("---- Test on chained list ----");
@@ -403,22 +372,19 @@ xbt_error_t test_chain_list(gras_socket_t sock, int direction) {
   i = cons( 12355, cons( 246264 , cons( 23263, NULL)));
   j = NULL;
 
   i = cons( 12355, cons( 246264 , cons( 23263, NULL)));
   j = NULL;
 
-  TRYOLD(write_read(gras_datadesc_by_name("chained_list_t*"),
-                &i,&j,
-                sock,direction));
+  write_read(gras_datadesc_by_name("chained_list_t*"),
+            &i,&j,  sock,direction);
   if (direction == READ || direction == RW) {
     xbt_assert(list_eq(i,j));    
     list_free(j);
   }
 
   list_free(i);
   if (direction == READ || direction == RW) {
     xbt_assert(list_eq(i,j));    
     list_free(j);
   }
 
   list_free(i);
-  return no_error;
 }
 /***
  *** graph
  ***/
 }
 /***
  *** graph
  ***/
-xbt_error_t test_graph(gras_socket_t sock, int direction) {
-  xbt_error_t errcode;
+void test_graph(gras_socket_t sock, int direction) {
   chained_list_t *i, *j; 
 
   INFO0("---- Test on graph (cyclique chained list) ----");
   chained_list_t *i, *j; 
 
   INFO0("---- Test on graph (cyclique chained list) ----");
@@ -428,8 +394,8 @@ xbt_error_t test_graph(gras_socket_t sock, int direction) {
   j = NULL;
 
   gras_datadesc_cycle_set(gras_datadesc_by_name("chained_list_t*"));
   j = NULL;
 
   gras_datadesc_cycle_set(gras_datadesc_by_name("chained_list_t*"));
-  TRYOLD(write_read(gras_datadesc_by_name("chained_list_t*"),
-                &i,&j, sock,direction));
+  write_read(gras_datadesc_by_name("chained_list_t*"),
+            &i,&j, sock,direction);
   if (direction == READ || direction == RW) {
     
     DEBUG1("i=%p"         ,i);
   if (direction == READ || direction == RW) {
     
     DEBUG1("i=%p"         ,i);
@@ -453,7 +419,6 @@ xbt_error_t test_graph(gras_socket_t sock, int direction) {
   }
   i->l->l->l = NULL; /* do this even in WRITE mode */
   list_free(i);
   }
   i->l->l->l = NULL; /* do this even in WRITE mode */
   list_free(i);
-  return no_error;
 }
 
 
 }
 
 
@@ -461,8 +426,7 @@ xbt_error_t test_graph(gras_socket_t sock, int direction) {
 static void free_string(void *d){ /* used to free the data in dynar */
      free(*(void**)d);
 }
 static void free_string(void *d){ /* used to free the data in dynar */
      free(*(void**)d);
 }
-xbt_error_t test_dynar_ref(gras_socket_t sock, int direction){
-  xbt_error_t errcode;
+void test_dynar_ref(gras_socket_t sock, int direction){
   gras_datadesc_type_t my_type;
   xbt_dynar_t i,j;
   char buf[1024];
   gras_datadesc_type_t my_type;
   xbt_dynar_t i,j;
   char buf[1024];
@@ -479,7 +443,7 @@ xbt_error_t test_dynar_ref(gras_socket_t sock, int direction){
     xbt_dynar_push(i,&s1);
   }
 
     xbt_dynar_push(i,&s1);
   }
 
-  TRYOLD(write_read(my_type, &i,&j, sock, direction));
+  write_read(my_type, &i,&j, sock, direction);
   if (direction == READ || direction == RW) {
      for (cpt=0; cpt< 64; cpt++) {
        sprintf(buf,"%d",cpt);
   if (direction == READ || direction == RW) {
      for (cpt=0; cpt< 64; cpt++) {
        sprintf(buf,"%d",cpt);
@@ -492,8 +456,6 @@ xbt_error_t test_dynar_ref(gras_socket_t sock, int direction){
      xbt_dynar_free(&j);
   }
   xbt_dynar_free(&i);
      xbt_dynar_free(&j);
   }
   xbt_dynar_free(&i);
-
-  return no_error;
 }
 
 
 }
 
 
@@ -518,8 +480,7 @@ struct s_pbio{ /* structure presented in the IEEE article */
                 )
 typedef struct s_pbio pbio_t;
 
                 )
 typedef struct s_pbio pbio_t;
 
-xbt_error_t test_pbio(gras_socket_t sock, int direction) {
-  xbt_error_t errcode;
+void test_pbio(gras_socket_t sock, int direction) {
   int cpt;
   int cpt2;
   gras_datadesc_type_t pbio_type;
   int cpt;
   int cpt2;
   gras_datadesc_type_t pbio_type;
@@ -555,8 +516,8 @@ xbt_error_t test_pbio(gras_socket_t sock, int direction) {
     for (cpt2=0; cpt2<106; cpt2++) 
       i.Cddsdde[cpt][cpt2] = ((double)cpt) * ((double)cpt2);
   }
     for (cpt2=0; cpt2<106; cpt2++) 
       i.Cddsdde[cpt][cpt2] = ((double)cpt) * ((double)cpt2);
   }
-  TRYOLD(write_read(gras_datadesc_by_symbol(s_pbio),
-                &i,&j, sock,direction));
+  write_read(gras_datadesc_by_symbol(s_pbio),
+            &i,&j, sock,direction);
   if (direction == READ || direction == RW) {
     /* Check that the data match */
     xbt_assert(i.Cnstatv == j.Cnstatv);
   if (direction == READ || direction == RW) {
     /* Check that the data match */
     xbt_assert(i.Cnstatv == j.Cnstatv);
@@ -589,8 +550,6 @@ xbt_error_t test_pbio(gras_socket_t sock, int direction) {
                     i.Cddsdde[cpt][cpt2],cpt,cpt2,j.Cddsdde[cpt][cpt2]);
     }
   }
                     i.Cddsdde[cpt][cpt2],cpt,cpt2,j.Cddsdde[cpt][cpt2]);
     }
   }
-
-  return no_error;
 }
 
 GRAS_DEFINE_TYPE(s_clause,
 }
 
 GRAS_DEFINE_TYPE(s_clause,
@@ -600,9 +559,8 @@ struct s_clause {
 };)
 typedef struct s_clause Clause;
 
 };)
 typedef struct s_clause Clause;
 
-xbt_error_t test_clause(gras_socket_t sock, int direction) {
-  xbt_error_t errcode;
-  gras_datadesc_type_t ddt,array_t;
+void test_clause(gras_socket_t sock, int direction) {
+  gras_datadesc_type_t ddt;
   Clause *i,*j;
   int cpt;
   
   Clause *i,*j;
   int cpt;
   
@@ -624,7 +582,7 @@ xbt_error_t test_clause(gras_socket_t sock, int direction) {
 
   ddt=gras_datadesc_ref("Clause*",ddt);
 
 
   ddt=gras_datadesc_ref("Clause*",ddt);
 
-  TRYOLD(write_read(ddt, &i,&j, sock,direction));
+  write_read(ddt, &i,&j, sock,direction);
   if (direction == READ || direction == RW) {
     xbt_assert(i->num_lits == j->num_lits);
     for (cpt=0; cpt<i->num_lits; cpt++)
   if (direction == READ || direction == RW) {
     xbt_assert(i->num_lits == j->num_lits);
     for (cpt=0; cpt<i->num_lits; cpt++)
@@ -635,11 +593,9 @@ xbt_error_t test_clause(gras_socket_t sock, int direction) {
   }
   free(i->literals);
   free(i);
   }
   free(i->literals);
   free(i);
-  return no_error;
 }
 
 int main(int argc,char *argv[]) {
 }
 
 int main(int argc,char *argv[]) {
-  xbt_error_t errcode;
   gras_socket_t sock;
   int direction = RW;
   int cpt;
   gras_socket_t sock;
   int direction = RW;
   int cpt;
@@ -658,43 +614,43 @@ int main(int argc,char *argv[]) {
   }
     
   if (direction == WRITE) {
   }
     
   if (direction == WRITE) {
-    TRYFAIL(gras_socket_client_from_file(filename,&sock));
-    TRYOLD(gras_datadesc_send(sock, gras_datadesc_by_name("char"),
-                          &r_arch_char));
+    sock = gras_socket_client_from_file(filename);
+    gras_datadesc_send(sock, gras_datadesc_by_name("char"),
+                      &r_arch_char);
   }
   if (direction == READ) {
   }
   if (direction == READ) {
-    TRYFAIL(gras_socket_server_from_file(filename,&sock));
-    TRYOLD(gras_datadesc_recv(sock, gras_datadesc_by_name("char"),
-                          gras_arch_selfid(), &r_arch_char));
+    sock = gras_socket_server_from_file(filename);
+    gras_datadesc_recv(sock, gras_datadesc_by_name("char"),
+                      gras_arch_selfid(), &r_arch_char);
     INFO3("This datafile was generated on %s (%d), I'm %s.",
          gras_datadesc_arch_name(r_arch_char),(int)r_arch_char,
          gras_datadesc_arch_name(gras_arch_selfid()));
   }
   r_arch = (int)r_arch_char;
 
     INFO3("This datafile was generated on %s (%d), I'm %s.",
          gras_datadesc_arch_name(r_arch_char),(int)r_arch_char,
          gras_datadesc_arch_name(gras_arch_selfid()));
   }
   r_arch = (int)r_arch_char;
 
-  TRYFAIL(test_int(sock,direction));    
-  TRYFAIL(test_float(sock,direction));  
-  TRYFAIL(test_double(sock,direction));  
-  TRYFAIL(test_array(sock,direction));
-  TRYFAIL(test_dynar_scal(sock,direction));  
-  TRYFAIL(test_intref(sock,direction)); 
+  test_int(sock,direction);    
+  test_float(sock,direction);  
+  test_double(sock,direction);  
+  test_array(sock,direction);
+  test_dynar_scal(sock,direction);  
+  test_intref(sock,direction); 
   
   
-  TRYFAIL(test_string(sock,direction)); 
+  test_string(sock,direction); 
 
 
-  TRYFAIL(test_structures(sock,direction));
+  test_structures(sock,direction);
 
 
-  TRYFAIL(test_homostruct(sock,direction));
-  TRYFAIL(test_hetestruct(sock,direction));
-  TRYFAIL(test_nestedstruct(sock,direction));
+  test_homostruct(sock,direction);
+  test_hetestruct(sock,direction);
+  test_nestedstruct(sock,direction);
 
 
-  TRYFAIL(declare_chained_list_type());
-  TRYFAIL(test_chain_list(sock,direction));
-  TRYFAIL(test_graph(sock,direction)); 
-  TRYFAIL(test_dynar_ref(sock,direction));  
+  declare_chained_list_type();
+  test_chain_list(sock,direction);
+  test_graph(sock,direction); 
+  test_dynar_ref(sock,direction);  
 
 
-  TRYFAIL(test_pbio(sock,direction));
+  test_pbio(sock,direction);
 
 
-  TRYFAIL(test_clause(sock,direction));
+  test_clause(sock,direction);
 
   if (direction != RW) 
     gras_socket_close(sock);
 
   if (direction != RW) 
     gras_socket_close(sock);
index fb842f4..a9b520a 100755 (executable)
@@ -49,9 +49,8 @@ for $i (0..$max_i) { for $j (0..$max_j) { for $k (0..$max_k) { for $l (0..$max_l
 # print "\n#define test(a) do {if (!(a)) { failed = 1; ERROR1(\"%s failed\",#a);}} while (0)\n";
  print "\n#define test(a) xbt_assert(a)\n";
 
 # print "\n#define test(a) do {if (!(a)) { failed = 1; ERROR1(\"%s failed\",#a);}} while (0)\n";
  print "\n#define test(a) xbt_assert(a)\n";
 
-print "\nxbt_error_t test_structures(gras_socket_t *sock, int direction);\n";
-print "\nxbt_error_t test_structures(gras_socket_t *sock, int direction) {\n";
-print "  xbt_error_t errcode;\n";
+print "void test_structures(gras_socket_t *sock, int direction);\n";
+print "void test_structures(gras_socket_t *sock, int direction) {\n";
 for $i (0..$max_i) { for $j (0..$max_j) { for $k (0..$max_k) { for $l (0..$max_l) {
     my $struct=$abrev[$i].$abrev[$j].$abrev[$k].$abrev[$l];
     print "  struct $struct my_$struct = {".$val[$i]."+(".$types[$i].")1,"
 for $i (0..$max_i) { for $j (0..$max_j) { for $k (0..$max_k) { for $l (0..$max_l) {
     my $struct=$abrev[$i].$abrev[$j].$abrev[$k].$abrev[$l];
     print "  struct $struct my_$struct = {".$val[$i]."+(".$types[$i].")1,"
@@ -63,7 +62,7 @@ for $i (0..$max_i) { for $j (0..$max_j) { for $k (0..$max_k) { for $l (0..$max_l
 print "  INFO0(\"---- Test on all possible struct having 3 fields (".(($max_i+1)*($max_j+1)*($max_k+1)*($max_l+1))." structs) ----\");\n";
 for $i (0..$max_i) { for $j (0..$max_j) { for $k (0..$max_k) { for $l (0..$max_l) {
     my $struct=$abrev[$i].$abrev[$j].$abrev[$k].$abrev[$l];
 print "  INFO0(\"---- Test on all possible struct having 3 fields (".(($max_i+1)*($max_j+1)*($max_k+1)*($max_l+1))." structs) ----\");\n";
 for $i (0..$max_i) { for $j (0..$max_j) { for $k (0..$max_k) { for $l (0..$max_l) {
     my $struct=$abrev[$i].$abrev[$j].$abrev[$k].$abrev[$l];
-    print "  TRYOLD(write_read(gras_datadesc_by_symbol($struct), &my_$struct, &my_${struct}2, sock,direction));\n";
+    print "  write_read(gras_datadesc_by_symbol($struct), &my_$struct, &my_${struct}2, sock,direction);\n";
     print "  if (direction == READ || direction == RW) {\n";
     print "     int failed = 0;\n";
     print "     test(my_$struct.a == my_${struct}2.a);\n";
     print "  if (direction == READ || direction == RW) {\n";
     print "     int failed = 0;\n";
     print "     test(my_$struct.a == my_${struct}2.a);\n";
@@ -73,6 +72,5 @@ for $i (0..$max_i) { for $j (0..$max_j) { for $k (0..$max_k) { for $l (0..$max_l
     print "     if (!failed) VERB0(\"Passed $struct\");\n";
     print "  }\n";
 }}}}
     print "     if (!failed) VERB0(\"Passed $struct\");\n";
     print "  }\n";
 }}}}
-    print "  return no_error;\n";
     print "}\n";
     ;
     print "}\n";
     ;
index 69d7076..e894277 100644 (file)
 #include "gras.h"
 #include "gras/Transport/transport_interface.h"
 
 #include "gras.h"
 #include "gras/Transport/transport_interface.h"
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging for this test");
+XBT_LOG_NEW_CATEGORY(test,"Logging for this test");
 
 int main(int argc,char *argv[]) {
   gras_socket_t sock;
 
 int main(int argc,char *argv[]) {
   gras_socket_t sock;
-  xbt_error_t errcode;
   char data_send[256];
 
   memset(data_send,0,sizeof(data_send));
   gras_init(&argc,argv);
 
   fprintf(stderr,"===[CLIENT]=== Contact the server\n");
   char data_send[256];
 
   memset(data_send,0,sizeof(data_send));
   gras_init(&argc,argv);
 
   fprintf(stderr,"===[CLIENT]=== Contact the server\n");
-  TRYFAIL(gras_socket_client_from_file("-",&sock));
+  sock = gras_socket_client_from_file("-");
 
   sprintf(data_send,"Hello, I am a little test data to send.");
   fprintf(stderr,"===[CLIENT]=== Send data\n");
 
   sprintf(data_send,"Hello, I am a little test data to send.");
   fprintf(stderr,"===[CLIENT]=== Send data\n");
-  TRYFAIL(gras_trp_chunk_send(sock,data_send, sizeof(data_send)));
+  gras_trp_chunk_send(sock,data_send, sizeof(data_send));
   
   fprintf(stderr,"===[CLIENT]=== Exiting successfully\n");
   gras_socket_close(sock);
   
   fprintf(stderr,"===[CLIENT]=== Exiting successfully\n");
   gras_socket_close(sock);
index a9cc267..61e5ee3 100644 (file)
 #include "gras.h"
 #include "gras/Transport/transport_interface.h"
 
 #include "gras.h"
 #include "gras/Transport/transport_interface.h"
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging for this test");
+XBT_LOG_NEW_CATEGORY(test,"Logging for this test");
 
 int main(int argc,char *argv[]) {
   gras_socket_t sock, conn;
 
 int main(int argc,char *argv[]) {
   gras_socket_t sock, conn;
-  xbt_error_t errcode;
   char data_recv[256];
 
   gras_init(&argc,argv);
 
   fprintf(stderr,"===[SERVER]=== Create the socket\n");
   char data_recv[256];
 
   gras_init(&argc,argv);
 
   fprintf(stderr,"===[SERVER]=== Create the socket\n");
-  TRYFAIL(gras_socket_server_from_file("-",&sock));
+  sock = gras_socket_server_from_file("-");
 
   fprintf(stderr,"===[SERVER]=== Waiting for incomming connexions\n");
 
   fprintf(stderr,"===[SERVER]=== Waiting for incomming connexions\n");
-  TRYFAIL(gras_trp_select(60,&conn));
+  conn = gras_trp_select(60);
 
   fprintf(stderr,"===[SERVER]=== Contacted ! Waiting for the data\n");
 
   fprintf(stderr,"===[SERVER]=== Contacted ! Waiting for the data\n");
-  TRYFAIL(gras_trp_chunk_recv(conn,data_recv, sizeof(data_recv)));
+  gras_trp_chunk_recv(conn,data_recv, sizeof(data_recv));
   fprintf(stderr,"===[SERVER]=== Got '%s'.\n", data_recv);
 
   fprintf(stderr,"===[SERVER]=== Exiting successfully\n");
   fprintf(stderr,"===[SERVER]=== Got '%s'.\n", data_recv);
 
   fprintf(stderr,"===[SERVER]=== Exiting successfully\n");
index 1d5e27e..98ab372 100644 (file)
 #include "gras.h"
 #include "gras/Transport/transport_interface.h"
 
 #include "gras.h"
 #include "gras/Transport/transport_interface.h"
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging for this test");
+XBT_LOG_NEW_CATEGORY(test,"Logging for this test");
 
 int main(int argc,char *argv[]) {
   gras_socket_t sock;
 
 int main(int argc,char *argv[]) {
   gras_socket_t sock;
-  xbt_error_t errcode;
   char data_send[256];
   char data_recv[256];
 
   char data_send[256];
   char data_recv[256];
 
@@ -25,14 +24,14 @@ int main(int argc,char *argv[]) {
   gras_init(&argc,argv);
 
   fprintf(stderr,"===[CLIENT]=== Contact the server\n");
   gras_init(&argc,argv);
 
   fprintf(stderr,"===[CLIENT]=== Contact the server\n");
-  TRYFAIL(gras_socket_client(NULL,55555,&sock));
+  sock = gras_socket_client(NULL,55555);
 
   sprintf(data_send,"Hello, I am a little test data to send.");
   fprintf(stderr,"===[CLIENT]=== Send data\n");
 
   sprintf(data_send,"Hello, I am a little test data to send.");
   fprintf(stderr,"===[CLIENT]=== Send data\n");
-  TRYFAIL(gras_trp_chunk_send(sock,data_send, sizeof(data_send)));
-  TRYFAIL(gras_trp_flush(sock));
+  gras_trp_chunk_send(sock,data_send, sizeof(data_send));
+  gras_trp_flush(sock);
   fprintf(stderr,"===[CLIENT]=== Waiting for the ACK\n");
   fprintf(stderr,"===[CLIENT]=== Waiting for the ACK\n");
-  TRYFAIL(gras_trp_chunk_recv(sock,data_recv, sizeof(data_recv)));
+  gras_trp_chunk_recv(sock,data_recv, sizeof(data_recv));
   
   if (strcmp(data_send, data_recv)) {
     fprintf(stderr, "===[CLIENT]=== String sent != string received\n");
   
   if (strcmp(data_send, data_recv)) {
     fprintf(stderr, "===[CLIENT]=== String sent != string received\n");
index bcf3ad5..c8d7208 100644 (file)
 #include "gras.h"
 #include "gras/Transport/transport_interface.h"
 
 #include "gras.h"
 #include "gras/Transport/transport_interface.h"
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging for this test");
+XBT_LOG_NEW_CATEGORY(test,"Logging for this test");
 
 int main(int argc,char *argv[]) {
   gras_socket_t sock, conn;
 
 int main(int argc,char *argv[]) {
   gras_socket_t sock, conn;
-  xbt_error_t errcode;
   char data_recv[256];
 
   gras_init(&argc,argv);
 
   fprintf(stderr,"===[SERVER]=== Create the socket\n");
   char data_recv[256];
 
   gras_init(&argc,argv);
 
   fprintf(stderr,"===[SERVER]=== Create the socket\n");
-  TRYFAIL(gras_socket_server(55555,&sock));
+  sock = gras_socket_server(55555);
 
   fprintf(stderr,"===[SERVER]=== Waiting for incomming connexions\n");
 
   fprintf(stderr,"===[SERVER]=== Waiting for incomming connexions\n");
-  TRYFAIL(gras_trp_select(60,&conn));
+  conn = gras_trp_select(60);
 
   fprintf(stderr,"===[SERVER]=== Contacted ! Waiting for the data\n");
 
   fprintf(stderr,"===[SERVER]=== Contacted ! Waiting for the data\n");
-  TRYFAIL(gras_trp_chunk_recv(conn,data_recv, sizeof(data_recv)));
+  gras_trp_chunk_recv(conn,data_recv, sizeof(data_recv));
   fprintf(stderr,"===[SERVER]=== Got '%s'. Send it back.\n", data_recv);
   fprintf(stderr,"===[SERVER]=== Got '%s'. Send it back.\n", data_recv);
-  TRYFAIL(gras_trp_chunk_send(conn,data_recv, sizeof(data_recv)));
-  TRYFAIL(gras_trp_flush(conn));
+  gras_trp_chunk_send(conn,data_recv, sizeof(data_recv));
+  gras_trp_flush(conn);
   gras_socket_close(conn);
 
   fprintf(stderr,"===[SERVER]=== Exiting successfully\n");
   gras_socket_close(conn);
 
   fprintf(stderr,"===[SERVER]=== Exiting successfully\n");
index e44f361..eadbb9d 100755 (executable)
@@ -17,9 +17,9 @@ export LD_LIBRARY_PATH=@top_srcdir@/src/.libs
 ## Args parsing (simplistic for now)
 ##
 if [ xvalgrind = "x$1" ] ; then
 ## Args parsing (simplistic for now)
 ##
 if [ xvalgrind = "x$1" ] ; then
-  valgrind="libtool --mode=execute valgrind --show-reachable=yes"
+  exenv="libtool --mode=execute valgrind --show-reachable=yes"
 else
 else
-  valgrind=
+  exenv=
 fi
 
 ##
 fi
 
 ##
@@ -80,33 +80,32 @@ do
     
     tests_nb=`expr $tests_nb + 1`
     echo "#### Test $test"
     
     tests_nb=`expr $tests_nb + 1`
     echo "#### Test $test"
-    if [ x@EXEEXT@ = x ] ; then 
-      wine=
+    if [ x@EXEEXT@ = x ] ; then
+      :
     else
     else
-      wine=wine
+      # overwrites "valgrind" as a value, but should be exclusive.
+      exenv=wine  
     fi
     if [ "x$test" = "xdict_crash@EXEEXT@" ] ; then
     fi
     if [ "x$test" = "xdict_crash@EXEEXT@" ] ; then
-      $wine ./$test --xbt-log="root.thres=info" 2>&1
+      $exenv ./$test --xbt-log="root.thres=info" 2>&1
       retval=$?
     else 
       retval=$?
     else 
-      winesave=$wine
-      if [ x@EXEEXT@ != x ] ; then 
+      exenvsave=$exenv
+      if [ x@EXEEXT@ != x ] && [ x$exenv = xwine ] ; then 
         if echo ${test} | grep @EXEEXT@ >/dev/null ; then : ; else
         if echo ${test} | grep @EXEEXT@ >/dev/null ; then : ; else
-#         echo "This is not a win32 binary, don't use wine"
-          wine=""
+          exenv=""
         fi
       fi
         fi
       fi
-        # if the user defines valgrind while cross-compiling, too bad
-        $wine $valgrind ./$test --xbt-log="root.thres=info" 2>&1
-        retval=$?
-      wine=$winesave
+      $exenv ./$test --xbt-log="root.thres=info" 2>&1
+      retval=$?
+      exenv=$exenvsave
     fi
     if [ $retval != 0 ] ; then if [ $retval != 77 ]; then
       echo "## failed" # . Rerun $test with full details."
 #      if [ "x$test" = "xdict_crash" ] ; then
     fi
     if [ $retval != 0 ] ; then if [ $retval != 77 ]; then
       echo "## failed" # . Rerun $test with full details."
 #      if [ "x$test" = "xdict_crash" ] ; then
-#      $wine ./$test --xbt-log="root.thres=debug" 2>&1
+#      $exenv ./$test --xbt-log="root.thres=debug" 2>&1
 #    else 
 #    else 
-#      $wine $valgrind ./$test --xbt-log="root.thres=debug" 2>&1
+#      $exenv ./$test --xbt-log="root.thres=debug" 2>&1
 #    fi
       failed_nb=`expr $failed_nb + 1`
       echo "  $test (returned $retval)" >> test.failed
 #    fi
       failed_nb=`expr $failed_nb + 1`
       echo "  $test (returned $retval)" >> test.failed
index 7ca1c67..c9b83a0 100644 (file)
@@ -42,9 +42,6 @@ void test(char *platform)
   surf_action_t actionB = NULL;
   surf_action_t actionC = NULL;
   surf_action_t commAB = NULL;
   surf_action_t actionB = NULL;
   surf_action_t actionC = NULL;
   surf_action_t commAB = NULL;
-  e_surf_action_state_t stateActionA;
-  e_surf_action_state_t stateActionB;
-  e_surf_action_state_t stateActionC;
   double now = -1.0;
 
   surf_workstation_resource_init_CLM03(platform);
   double now = -1.0;
 
   surf_workstation_resource_init_CLM03(platform);
index 6452b55..f4e1eae 100644 (file)
@@ -26,7 +26,7 @@ static xbt_cfg_t make_set(){
 } /* end_of_make_set */
  
 int main(int argc, char **argv) {
 } /* end_of_make_set */
  
 int main(int argc, char **argv) {
-  xbt_error_t errcode;
+  xbt_ex_t e;
   xbt_cfg_t set;
 
   char *str;
   xbt_cfg_t set;
 
   char *str;
@@ -35,7 +35,7 @@ int main(int argc, char **argv) {
 
   fprintf(stderr,"==== Alloc and free a config set.\n");
   set=make_set();
 
   fprintf(stderr,"==== Alloc and free a config set.\n");
   set=make_set();
-  TRYFAIL(xbt_cfg_set_parse(set, "hostname:veloce user:mquinson\nuser:oaumage\tuser:alegrand"));
+  xbt_cfg_set_parse(set, "hostname:veloce user:mquinson\nuser:oaumage\tuser:alegrand");
   xbt_cfg_dump("test set","",set);
   xbt_cfg_free(&set);
   xbt_cfg_free(&set);
   xbt_cfg_dump("test set","",set);
   xbt_cfg_free(&set);
   xbt_cfg_free(&set);
@@ -48,10 +48,16 @@ int main(int argc, char **argv) {
   xbt_cfg_free(&set);
   xbt_cfg_free(&set);
 
   xbt_cfg_free(&set);
   xbt_cfg_free(&set);
 
-  fprintf(stderr,"==== Validation test (ERROR EXPECTED: too many elements)\n");
+  fprintf(stderr,"==== Validation test\n");
   set=make_set();
   set=make_set();
-  xbt_cfg_set_parse(set,"hostname:toto:42");
-  xbt_cfg_set_parse(set,"speed:42 speed:24 speed:34");
+  TRY {
+    xbt_cfg_set_parse(set,"hostname:toto:42");
+    xbt_cfg_set_parse(set,"speed:42 speed:24 speed:34");
+  } CATCH(e) {
+    if (e.category != mismatch_error)
+      RETHROW;
+    xbt_ex_free(e);
+  }
   xbt_cfg_check(set);
   xbt_cfg_free(&set);
   xbt_cfg_free(&set);
   xbt_cfg_check(set);
   xbt_cfg_free(&set);
   xbt_cfg_free(&set);
@@ -63,7 +69,7 @@ int main(int argc, char **argv) {
   xbt_cfg_t myset=make_set();
      
   xbt_cfg_set_parse(myset,"hostname:toto:42 speed:42");
   xbt_cfg_t myset=make_set();
      
   xbt_cfg_set_parse(myset,"hostname:toto:42 speed:42");
-  xbt_cfg_get_int(myset,"speed",&ival); 
+  ival = xbt_cfg_get_int(myset,"speed"); 
   fprintf(stderr,"speed value: %d\n",ival); /* Prints: "speed value: 42" */
   xbt_cfg_free(&myset);
   }
   fprintf(stderr,"speed value: %d\n",ival); /* Prints: "speed value: 42" */
   xbt_cfg_free(&myset);
   }
@@ -78,7 +84,7 @@ int main(int argc, char **argv) {
   xbt_cfg_set_parse(myset, "hostname:veloce user:mquinson\nuser:oaumage\tuser:alegrand");
   xbt_cfg_set_parse(myset,"speed:42");
   xbt_cfg_check(myset); 
   xbt_cfg_set_parse(myset, "hostname:veloce user:mquinson\nuser:oaumage\tuser:alegrand");
   xbt_cfg_set_parse(myset,"speed:42");
   xbt_cfg_check(myset); 
-  xbt_cfg_get_dynar(myset,"user",&dyn);
+  dyn = xbt_cfg_get_dynar(myset,"user");
   fprintf(stderr,"Count: %lu; Options: ",xbt_dynar_length(dyn));
   xbt_dynar_foreach(dyn,ival,str) {
     fprintf(stderr,"%s;",str); 
   fprintf(stderr,"Count: %lu; Options: ",xbt_dynar_length(dyn));
   xbt_dynar_foreach(dyn,ival,str) {
     fprintf(stderr,"%s;",str); 
@@ -91,7 +97,14 @@ int main(int argc, char **argv) {
   fprintf(stderr,"==== Try to use an unregistered option. (ERROR EXPECTED: 'color' not registered)\n");
   {
   xbt_cfg_t myset=make_set();
   fprintf(stderr,"==== Try to use an unregistered option. (ERROR EXPECTED: 'color' not registered)\n");
   {
   xbt_cfg_t myset=make_set();
-  TRYEXPECT(mismatch_error,xbt_cfg_set_parse(myset,"color:blue"));
+  TRY {
+    xbt_cfg_set_parse(myset,"color:blue");
+    THROW1(unknown_error,0,"Found an option which shouldn't be there (%s)","color:blue");
+  } CATCH(e) {
+    if (e.category != mismatch_error)
+      RETHROW;
+    xbt_ex_free(e);
+  }
   /* This spits an error: 'color' not registered */
   xbt_cfg_free(&myset);
   }
   /* This spits an error: 'color' not registered */
   xbt_cfg_free(&myset);
   }
index 5f9ac6c..5315b19 100644 (file)
@@ -122,7 +122,7 @@ int main(int argc,char **argv) {
     for (j=0;j<NB_ELM;j++) {
       
       sprintf(key,"%d",j);
     for (j=0;j<NB_ELM;j++) {
       
       sprintf(key,"%d",j);
-      TRYFAIL(xbt_dict_get(head,key,&data));
+      data = xbt_dict_get(head,key);
       if (strcmp(key,(char*)data)) {
        printf("key=%s != data=%s\n",key,(char*)data);
        abort();
       if (strcmp(key,(char*)data)) {
        printf("key=%s != data=%s\n",key,(char*)data);
        abort();
index f3ae427..04f4680 100644 (file)
 
 #include "gras.h"
 #include "portable.h"
 
 #include "gras.h"
 #include "portable.h"
+#include "xbt/ex.h"
 
 XBT_LOG_EXTERNAL_CATEGORY(dict);
 XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
 
 static void fill(xbt_dict_t *head);
 static void debuged_add(xbt_dict_t head,const char*key);
 
 XBT_LOG_EXTERNAL_CATEGORY(dict);
 XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
 
 static void fill(xbt_dict_t *head);
 static void debuged_add(xbt_dict_t head,const char*key);
-static xbt_error_t search(xbt_dict_t head,const char*key);
-static xbt_error_t debuged_remove(xbt_dict_t head,const char*key);
-static xbt_error_t traverse(xbt_dict_t head);
+static void search(xbt_dict_t head,const char*key);
+static void debuged_remove(xbt_dict_t head,const char*key);
+static void traverse(xbt_dict_t head);
 
 static void print_str(void *str);
 static void print_str(void *str) {
 
 static void print_str(void *str);
 static void print_str(void *str) {
@@ -54,32 +55,24 @@ static void debuged_add(xbt_dict_t head,const char*key)
   }
 }
 
   }
 }
 
-static xbt_error_t search(xbt_dict_t head,const char*key) {
+static void search(xbt_dict_t head,const char*key) {
   void *data;
   void *data;
-  xbt_error_t errcode;
-
   
   
-  errcode=xbt_dict_get(head,key,&data);
+  data=xbt_dict_get(head,key);
   printf("   - Search %s. Found %s\n",PRINTF_STR(key),(char*) PRINTF_STR(data));fflush(stdout);
   printf("   - Search %s. Found %s\n",PRINTF_STR(key),(char*) PRINTF_STR(data));fflush(stdout);
-  if (!data)
-     return errcode;
-  if (strcmp((char*)data,key)) 
-    return mismatch_error;
-  return errcode;
+  if (data && strcmp((char*)data,key)) 
+    THROW2(mismatch_error,0,"Found %s while looking for %s",(char*)data,key);
 }
 
 }
 
-static xbt_error_t debuged_remove(xbt_dict_t head,const char*key)
-{
-  xbt_error_t errcode;
+static void debuged_remove(xbt_dict_t head,const char*key) {
 
   printf("   Remove '%s'\n",PRINTF_STR(key));fflush(stdout);
 
   printf("   Remove '%s'\n",PRINTF_STR(key));fflush(stdout);
-  errcode=xbt_dict_remove(head,key);
+  xbt_dict_remove(head,key);
   /*  xbt_dict_dump(head,(void (*)(void*))&printf); */
   /*  xbt_dict_dump(head,(void (*)(void*))&printf); */
-  return errcode;
 }
 
 
 }
 
 
-static xbt_error_t traverse(xbt_dict_t head) {
+static void traverse(xbt_dict_t head) {
   xbt_dict_cursor_t cursor=NULL;
   char *key;
   char *data;
   xbt_dict_cursor_t cursor=NULL;
   char *key;
   char *data;
@@ -89,11 +82,25 @@ static xbt_error_t traverse(xbt_dict_t head) {
     xbt_assert2(!data || !strcmp(key,data),
                 "Key(%s) != value(%s). Abording\n",key,data);
   }
     xbt_assert2(!data || !strcmp(key,data),
                 "Key(%s) != value(%s). Abording\n",key,data);
   }
-  return no_error;
+}
+
+static void search_not_found(xbt_dict_t head, const char *data) {
+  xbt_ex_t e;
+
+  TRY {    
+    data = xbt_dict_get(head,"Can't be found");
+    THROW1(unknown_error,0,"Found something which shouldn't be there (%s)",data);
+  } CATCH(e) {
+    if (e.category == mismatch_error) {
+      xbt_ex_free(e);
+    } else {
+      RETHROW;
+    }
+  }
 }
 
 int main(int argc,char **argv) {
 }
 
 int main(int argc,char **argv) {
-  xbt_error_t errcode;
+  xbt_ex_t e;
   xbt_dict_t head=NULL;
   char *data;
 
   xbt_dict_t head=NULL;
   char *data;
 
@@ -102,9 +109,14 @@ int main(int argc,char **argv) {
   printf("\nGeneric dictionnary: USAGE test:\n");
 
   printf(" Traverse the empty dictionnary\n");
   printf("\nGeneric dictionnary: USAGE test:\n");
 
   printf(" Traverse the empty dictionnary\n");
-  TRYFAIL(traverse(head));
+  traverse(head);
 
 
+  printf(" Traverse the full dictionnary\n");
   fill(&head);
   fill(&head);
+  search(head,"12a");
+xbt_dict_dump(head,(void (*)(void*))&printf);
+  traverse(head);
+
   printf(" Free the dictionnary (twice)\n");
   xbt_dict_free(&head);
   xbt_dict_free(&head);
   printf(" Free the dictionnary (twice)\n");
   xbt_dict_free(&head);
   xbt_dict_free(&head);
@@ -115,9 +127,9 @@ int main(int argc,char **argv) {
   printf(" - Test that it works with NULL data\n");
   printf("   - Store NULL under 'null'\n");fflush(stdout);
   xbt_dict_set(head,"null",NULL,NULL);
   printf(" - Test that it works with NULL data\n");
   printf("   - Store NULL under 'null'\n");fflush(stdout);
   xbt_dict_set(head,"null",NULL,NULL);
-  TRYFAIL(search(head,"null"));
+  search(head,"null");
   /* xbt_dict_dump(head,(void (*)(void*))&printf); */
   /* xbt_dict_dump(head,(void (*)(void*))&printf); */
-  printf("   Check whether I see it while traversing\n");fflush(stdout);
+  printf("   Check whether I see it while traversing...\n");fflush(stdout);
   {
      xbt_dict_cursor_t cursor=NULL;
      char *key;
   {
      xbt_dict_cursor_t cursor=NULL;
      char *key;
@@ -130,7 +142,8 @@ int main(int argc,char **argv) {
      }
      xbt_assert0(found,"the key 'null', associated to NULL is not found");
   }
      }
      xbt_assert0(found,"the key 'null', associated to NULL is not found");
   }
-   
+  printf("   OK, I did found the searched NULL\n");
+
   printf(" - Change some values\n");
   printf("   - Change 123 to 'Changed 123'\n");
   xbt_dict_set(head,"123",strdup("Changed 123"),&free);
   printf(" - Change some values\n");
   printf("   - Change 123 to 'Changed 123'\n");
   xbt_dict_set(head,"123",strdup("Changed 123"),&free);
@@ -143,26 +156,26 @@ int main(int argc,char **argv) {
 
   /*  xbt_dict_dump(head,(void (*)(void*))&printf); */
   printf(" - Traverse the resulting dictionnary\n");
 
   /*  xbt_dict_dump(head,(void (*)(void*))&printf); */
   printf(" - Traverse the resulting dictionnary\n");
-  TRYFAIL(traverse(head));
+  traverse(head);
 
   printf(" - Retrive values\n");
 
   printf(" - Retrive values\n");
-  TRYFAIL(xbt_dict_get(head,"123",(void**)&data));
+  data = xbt_dict_get(head,"123");
   xbt_assert(data);
   xbt_assert(data);
-  TRYFAIL(strcmp("123",data));
+  strcmp("123",data);
 
 
-  TRYEXPECT(xbt_dict_get(head,"Can't be found",(void**)&data),mismatch_error);
-  TRYEXPECT(xbt_dict_get(head,"123 Can't be found",(void**)&data),mismatch_error);
-  TRYEXPECT(xbt_dict_get(head,"12345678 NOT",(void**)&data),mismatch_error);
+  search_not_found(head,"Can't be found");
+  search_not_found(head,"123 Can't be found");
+  search_not_found(head,"12345678 NOT");
 
 
-  TRYFAIL(search(head,"12a"));
-  TRYFAIL(search(head,"12b"));
-  TRYFAIL(search(head,"12"));
-  TRYFAIL(search(head,"123456"));
-  TRYFAIL(search(head,"1234"));
-  TRYFAIL(search(head,"123457"));
+  search(head,"12a");
+  search(head,"12b");
+  search(head,"12");
+  search(head,"123456");
+  search(head,"1234");
+  search(head,"123457");
 
   printf(" - Traverse the resulting dictionnary\n");
 
   printf(" - Traverse the resulting dictionnary\n");
-  TRYFAIL(traverse(head));
+  traverse(head);
 
   /*  xbt_dict_dump(head,(void (*)(void*))&printf); */
 
 
   /*  xbt_dict_dump(head,(void (*)(void*))&printf); */
 
@@ -171,30 +184,54 @@ int main(int argc,char **argv) {
   xbt_dict_free(&head);
 
   printf(" - Traverse the resulting dictionnary\n");
   xbt_dict_free(&head);
 
   printf(" - Traverse the resulting dictionnary\n");
-  TRYFAIL(traverse(head));
+  traverse(head);
 
   printf("\n");
   fill(&head);
   printf(" - Remove the data (traversing the resulting dictionnary each time)\n");
 
   printf("\n");
   fill(&head);
   printf(" - Remove the data (traversing the resulting dictionnary each time)\n");
-  TRYEXPECT(debuged_remove(head,"Does not exist"),mismatch_error);
-  TRYFAIL(traverse(head));
+  TRY {
+    debuged_remove(head,"Does not exist");
+  } CATCH(e) {
+    if (e.category != mismatch_error) 
+      RETHROW;
+    xbt_ex_free(e);
+  }
+  traverse(head);
 
   xbt_dict_free(&head);
 
   printf(" - Remove data from the NULL dict (error message expected)\n");
 
   xbt_dict_free(&head);
 
   printf(" - Remove data from the NULL dict (error message expected)\n");
-  TRYCATCH(debuged_remove(head,"12345"),mismatch_error);
+  TRY {
+    debuged_remove(head,"12345");
+  } CATCH(e) {
+    if (e.category != arg_error) 
+      RETHROW;
+    xbt_ex_free(e);
+  } 
 
   printf(" - Remove each data manually (traversing the resulting dictionnary each time)\n");
   fill(&head);
 
   printf(" - Remove each data manually (traversing the resulting dictionnary each time)\n");
   fill(&head);
-  TRYFAIL(debuged_remove(head,"12a"));    TRYFAIL(traverse(head));
-  TRYFAIL(debuged_remove(head,"12b"));    TRYFAIL(traverse(head));
-  TRYFAIL(debuged_remove(head,"12"));     TRYFAIL(traverse(head));
-  TRYFAIL(debuged_remove(head,"123456")); TRYFAIL(traverse(head));
-  TRYEXPECT(debuged_remove(head,"12346"),mismatch_error);  TRYFAIL(traverse(head));
-  TRYFAIL(debuged_remove(head,"1234"));   TRYFAIL(traverse(head));
-  TRYFAIL(debuged_remove(head,"123457")); TRYFAIL(traverse(head));
-  TRYFAIL(debuged_remove(head,"123"));    TRYFAIL(traverse(head));
-  TRYEXPECT(debuged_remove(head,"12346"),mismatch_error);  TRYFAIL(traverse(head));
+  debuged_remove(head,"12a");    traverse(head);
+  debuged_remove(head,"12b");    traverse(head);
+  debuged_remove(head,"12");     traverse(head);
+  debuged_remove(head,"123456"); traverse(head);
+  TRY {
+    debuged_remove(head,"12346");
+  } CATCH(e) {
+    if (e.category != mismatch_error) 
+      RETHROW;
+    xbt_ex_free(e);              traverse(head);
+  } 
+  debuged_remove(head,"1234");   traverse(head);
+  debuged_remove(head,"123457"); traverse(head);
+  debuged_remove(head,"123");    traverse(head);
+  TRY {
+    debuged_remove(head,"12346");
+  } CATCH(e) {
+    if (e.category != mismatch_error) 
+      RETHROW;
+    xbt_ex_free(e);              traverse(head);
+  } 
   
   printf(" - Free the dictionnary twice\n");
   xbt_dict_free(&head);
   
   printf(" - Free the dictionnary twice\n");
   xbt_dict_free(&head);
index 74e6610..7e8ef1a 100644 (file)
@@ -13,7 +13,6 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
 
 int main(int argc,char *argv[]) {
    xbt_dynar_t d;
 
 int main(int argc,char *argv[]) {
    xbt_dynar_t d;
-   xbt_error_t errcode;
    int cpt,cursor;
    double d1,d2;
    
    int cpt,cursor;
    double d1,d2;
    
index 164f81e..7082478 100644 (file)
@@ -15,7 +15,6 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
 int main(int argc,char *argv[]) {
    /* Vars_decl [doxygen cruft] */
    xbt_dynar_t d;
 int main(int argc,char *argv[]) {
    /* Vars_decl [doxygen cruft] */
    xbt_dynar_t d;
-   xbt_error_t errcode;
    int i,cpt,cursor;
    int *iptr;
    
    int i,cpt,cursor;
    int *iptr;
    
index 69796a6..645ce5b 100644 (file)
@@ -23,7 +23,6 @@ static void free_string(void *d){
 
 int main(int argc,char *argv[]) {
    xbt_dynar_t d;
 
 int main(int argc,char *argv[]) {
    xbt_dynar_t d;
-   xbt_error_t errcode;
    int cpt;
    char buf[1024];
    char *s1,*s2;
    int cpt;
    char buf[1024];
    char *s1,*s2;
index f242e23..95dd6f8 100644 (file)
 #include "ex_test_ts.h"
 #include "xbt/ex.h"
 
 #include "ex_test_ts.h"
 #include "xbt/ex.h"
 
+XBT_LOG_NEW_CATEGORY(test,"This test");
+
 TS_TEST(test_controlflow)
 {
 TS_TEST(test_controlflow)
 {
-    ex_t ex;
+    xbt_ex_t ex;
     volatile int n;
 
     ts_test_check(TS_CTX, "basic nested control flow");
     volatile int n;
 
     ts_test_check(TS_CTX, "basic nested control flow");
@@ -51,7 +53,7 @@ TS_TEST(test_controlflow)
             if (n != 2)
                 ts_test_fail(TS_CTX, "M2: n=%d (!= 2)", n);
             n++;
             if (n != 2)
                 ts_test_fail(TS_CTX, "M2: n=%d (!= 2)", n);
             n++;
-            THROW(0,0,"something");
+            THROW0(unknown_error,0,"something");
         } CATCH (ex) {
             if (n != 3)
                 ts_test_fail(TS_CTX, "M3: n=%d (!= 1)", n);
         } CATCH (ex) {
             if (n != 3)
                 ts_test_fail(TS_CTX, "M3: n=%d (!= 1)", n);
@@ -71,13 +73,13 @@ TS_TEST(test_controlflow)
 
 TS_TEST(test_value)
 {
 
 TS_TEST(test_value)
 {
-    ex_t ex;
+    xbt_ex_t ex;
 
     TRY {
 
     TRY {
-        THROW(1, 2, "toto");
+        THROW0(unknown_error, 2, "toto");
     } CATCH(ex) {
         ts_test_check(TS_CTX, "exception value passing");
     } CATCH(ex) {
         ts_test_check(TS_CTX, "exception value passing");
-        if (ex.category != 1)
+        if (ex.category != unknown_error)
             ts_test_fail(TS_CTX, "category=%d (!= 1)", ex.category);
         if (ex.value != 2)
             ts_test_fail(TS_CTX, "value=%d (!= 2)", ex.value);
             ts_test_fail(TS_CTX, "category=%d (!= 1)", ex.category);
         if (ex.value != 2)
             ts_test_fail(TS_CTX, "value=%d (!= 2)", ex.value);
@@ -88,7 +90,7 @@ TS_TEST(test_value)
 
 TS_TEST(test_variables)
 {
 
 TS_TEST(test_variables)
 {
-    ex_t ex;
+    xbt_ex_t ex;
     int r1, r2;
     volatile int v1, v2;
 
     int r1, r2;
     volatile int v1, v2;
 
@@ -96,7 +98,7 @@ TS_TEST(test_variables)
     TRY {
         r2 = 5678;
         v2 = 5678;
     TRY {
         r2 = 5678;
         v2 = 5678;
-        THROW(0, 0, 0);
+        THROW0(unknown_error, 0, "toto");
     } CATCH(ex) {
         ts_test_check(TS_CTX, "variable preservation");
         if (r1 != 1234)
     } CATCH(ex) {
         ts_test_check(TS_CTX, "variable preservation");
         if (r1 != 1234)
@@ -109,75 +111,9 @@ TS_TEST(test_variables)
     }
 }
 
     }
 }
 
-TS_TEST(test_defer)
-{
-    ex_t ex;
-    volatile int i1 = 0;
-    volatile int i2 = 0;
-    volatile int i3 = 0;
-
-    ts_test_check(TS_CTX, "exception deferring");
-    if (IS_DEFERRED)
-        ts_test_fail(TS_CTX, "unexpected deferring scope");
-    TRY {
-        DEFER {
-            if (!IS_DEFERRED)
-                ts_test_fail(TS_CTX, "unexpected non-deferring scope");
-            DEFER {
-                i1 = 1;
-                THROW(4711, 0, NULL);
-                i2 = 2;
-                THROW(0, 0, NULL);
-                i3 = 3;
-                THROW(0, 0, NULL);
-            }
-            THROW(0, 0, 0);
-        }
-        ts_test_fail(TS_CTX, "unexpected not occurred deferred throwing");
-    }
-    CATCH(ex) {
-        if (ex.category != 4711)
-            ts_test_fail(TS_CTX, "caught exception with value %d, expected 4711", ex.value);
-    }
-    if (i1 != 1)
-        ts_test_fail(TS_CTX, "v.i1 not set (expected 1, got %d)", i1);
-    if (i2 != 2)
-        ts_test_fail(TS_CTX, "v.i2 not set (expected 2, got %d)", i2);
-    if (i3 != 3)
-        ts_test_fail(TS_CTX, "v.i3 not set (expected 3, got %d)", i3);
-}
-
-TS_TEST(test_shield)
-{
-    ex_t ex;
-
-    ts_test_check(TS_CTX, "exception shielding");
-    if (IS_SHIELDED)
-        ts_test_fail(TS_CTX, "unexpected shielding scope");
-    if (IS_CATCHED)
-        ts_test_fail(TS_CTX, "unexpected catching scope");
-    TRY {
-        SHIELD {
-            if (!IS_SHIELDED)
-                ts_test_fail(TS_CTX, "unexpected non-shielding scope");
-            THROW(0, 0, 0);
-        }
-        if (IS_SHIELDED)
-            ts_test_fail(TS_CTX, "unexpected shielding scope");
-        if (!IS_CATCHED)
-            ts_test_fail(TS_CTX, "unexpected non-catching scope");
-    } CATCH(ex) {
-        ts_test_fail(TS_CTX, "unexpected exception catched");
-        if (IS_CATCHED)
-            ts_test_fail(TS_CTX, "unexpected catching scope");
-    }
-    if (IS_CATCHED)
-        ts_test_fail(TS_CTX, "unexpected catching scope");
-}
-
 TS_TEST(test_cleanup)
 {
 TS_TEST(test_cleanup)
 {
-    ex_t ex;
+    xbt_ex_t ex;
     volatile int v1;
     int c;
 
     volatile int v1;
     int c;
 
@@ -187,7 +123,7 @@ TS_TEST(test_cleanup)
     c = 0;
     TRY {
         v1 = 5678;
     c = 0;
     TRY {
         v1 = 5678;
-        THROW(1, 2, "blah");
+        THROW0(1, 2, "blah");
     } CLEANUP {
         if (v1 != 5678)
             ts_test_fail(TS_CTX, "v1 = %d (!= 5678)", v1);
     } CLEANUP {
         if (v1 != 5678)
             ts_test_fail(TS_CTX, "v1 = %d (!= 5678)", v1);
@@ -211,8 +147,6 @@ int main(int argc, char *argv[])
     ts_suite_test(ts, test_controlflow, "basic nested control flow");
     ts_suite_test(ts, test_value,       "exception value passing");
     ts_suite_test(ts, test_variables,   "variable value preservation");
     ts_suite_test(ts, test_controlflow, "basic nested control flow");
     ts_suite_test(ts, test_value,       "exception value passing");
     ts_suite_test(ts, test_variables,   "variable value preservation");
-    ts_suite_test(ts, test_defer,       "exception deferring");
-    ts_suite_test(ts, test_shield,      "exception shielding");
     ts_suite_test(ts, test_cleanup,     "cleanup handling");
     n = ts_suite_run(ts);
     ts_suite_free(ts);
     ts_suite_test(ts, test_cleanup,     "cleanup handling");
     n = ts_suite_run(ts);
     ts_suite_free(ts);
@@ -260,7 +194,7 @@ static void bad_example(void) {
 
 static void good_example(void) {
   struct {char*first;} *globalcontext;
 
 static void good_example(void) {
   struct {char*first;} *globalcontext;
-  ex_t ex;
+  xbt_ex_t ex;
 
   /* GOOD_EXAMPLE */
   { /*01*/
 
   /* GOOD_EXAMPLE */
   { /*01*/
index 9e8b1a0..2a0e4b0 100644 (file)
@@ -25,7 +25,6 @@ static void str_free(void *s) {
 }
 
 int main(int argc, char *argv[]) {
 }
 
 int main(int argc, char *argv[]) {
-  xbt_error_t errcode;
   xbt_dict_t mdict = NULL;
   int i,j,k,l;
   xbt_dynar_t keys = xbt_dynar_new(sizeof(char*),str_free);
   xbt_dict_t mdict = NULL;
   int i,j,k,l;
   xbt_dynar_t keys = xbt_dynar_new(sizeof(char*),str_free);
@@ -69,9 +68,9 @@ int main(int argc, char *argv[]) {
       }
       if (verbose>0) printf("in multitree %p.\n",mdict);
                                                         
       }
       if (verbose>0) printf("in multitree %p.\n",mdict);
                                                         
-      TRYFAIL(xbt_multidict_set(mdict,keys,xbt_strdup(key),free));
+      xbt_multidict_set(mdict,keys,xbt_strdup(key),free);
 
 
-      TRYFAIL(xbt_multidict_get(mdict,keys,&data));
+      data = xbt_multidict_get(mdict,keys);
 
       xbt_assert2(data && !strcmp((char*)data,key),
                  "Retrieved value (%s) does not match the entrered one (%s)\n",
 
       xbt_assert2(data && !strcmp((char*)data,key),
                  "Retrieved value (%s) does not match the entrered one (%s)\n",
index 2031dd4..23d60a3 100644 (file)
@@ -10,6 +10,7 @@
 #include <stdio.h>
 
 #include "gras.h"
 #include <stdio.h>
 
 #include "gras.h"
+#include "xbt/ex.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
 XBT_LOG_EXTERNAL_CATEGORY(set);
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
 XBT_LOG_EXTERNAL_CATEGORY(set);
@@ -29,11 +30,10 @@ static void debuged_add(xbt_set_t set,const char*key);
 static void debuged_add_with_data(xbt_set_t  set,
                                  const char *name,
                                  const char *data);
 static void debuged_add_with_data(xbt_set_t  set,
                                  const char *name,
                                  const char *data);
-static xbt_error_t search_name(xbt_set_t set,const char*key);
-static xbt_error_t search_id(xbt_set_t head,
-                             int id,
-                             const char*expected_key);
-static xbt_error_t traverse(xbt_set_t set);
+static void search_name(xbt_set_t set,const char*key);
+static void search_id(xbt_set_t head,int id,
+                     const char*expected_key);
+static void traverse(xbt_set_t set);
 
 static void my_elem_free(void *e) {
   my_elem_t elm=(my_elem_t)e;
 
 static void my_elem_free(void *e) {
   my_elem_t elm=(my_elem_t)e;
@@ -86,59 +86,43 @@ static void fill(xbt_set_t *set) {
   debuged_add(*set,"123457");
 }
 
   debuged_add(*set,"123457");
 }
 
-static xbt_error_t search_name(xbt_set_t head,const char*key) {
-  xbt_error_t    errcode;
-  my_elem_t       elm;
-  
-  errcode=xbt_set_get_by_name(head,key,(xbt_set_elm_t*)&elm);
+static void search_name(xbt_set_t head,const char*key) {
+  my_elem_t elm = (my_elem_t)xbt_set_get_by_name(head,key);
+
   printf("   - Search by name %s. Found %s (under ID %d)\n",
         key, 
         elm? elm->data:"(null)",
         elm? elm->ID:-1);
   printf("   - Search by name %s. Found %s (under ID %d)\n",
         key, 
         elm? elm->data:"(null)",
         elm? elm->ID:-1);
-  if (strcmp(key,elm->name)) {
-    printf("    The key (%s) is not the one expected (%s)\n",
+  if (strcmp(key,elm->name))
+    THROW2(mismatch_error,0,"The key (%s) is not the one expected (%s)",
+          key,elm->name);
+  if (strcmp(elm->name,elm->data))
+    THROW2(mismatch_error,0,"The name (%s) != data (%s)",
           key,elm->name);
           key,elm->name);
-    return mismatch_error;
-  }
-  if (strcmp(elm->name,elm->data)) {
-    printf("    The name (%s) != data (%s)\n",
-          elm->name,elm->data);
-    return mismatch_error;
-  }
   fflush(stdout);
   fflush(stdout);
-  return errcode;
 }
 
 }
 
-static xbt_error_t search_id(xbt_set_t head,int id,const char*key) {
-  xbt_error_t errcode;
-  my_elem_t    elm;
-  
-  errcode=xbt_set_get_by_id(head,id,(xbt_set_elm_t*)&elm);
+static void search_id(xbt_set_t head,int id,const char*key) {
+  my_elem_t elm = (my_elem_t) xbt_set_get_by_id(head,id);
+
   printf("   - Search by id %d. Found %s (data %s)\n",
         id, 
         elm? elm->name:"(null)",
         elm? elm->data:"(null)");
   printf("   - Search by id %d. Found %s (data %s)\n",
         id, 
         elm? elm->name:"(null)",
         elm? elm->data:"(null)");
-  if (id != elm->ID) {
-    printf("    The found ID (%d) is not the one expected (%d)\n",
+  if (id != elm->ID)
+    THROW2(mismatch_error,0,"The found ID (%d) is not the one expected (%d)",
           elm->ID,id);
           elm->ID,id);
-    return mismatch_error;
-  }
-  if (strcmp(key,elm->name)) {
-    printf("    The key (%s) is not the one expected (%s)\n",
+  if (strcmp(key,elm->name))
+    THROW2(mismatch_error,0,"The key (%s) is not the one expected (%s)",
           elm->name,key);
           elm->name,key);
-    return mismatch_error;
-  }
-  if (strcmp(elm->name,elm->data)) {
-    printf("    The name (%s) != data (%s)\n",
+  if (strcmp(elm->name,elm->data))
+    THROW2(mismatch_error,0,"The name (%s) != data (%s)",
           elm->name,elm->data);
           elm->name,elm->data);
-    return mismatch_error;
-  }
   fflush(stdout);
   fflush(stdout);
-  return errcode;
 }
 
 
 }
 
 
-static xbt_error_t traverse(xbt_set_t set) {
+static void traverse(xbt_set_t set) {
   xbt_set_cursor_t cursor=NULL;
   my_elem_t         elm=NULL;
 
   xbt_set_cursor_t cursor=NULL;
   my_elem_t         elm=NULL;
 
@@ -149,11 +133,24 @@ static xbt_error_t traverse(xbt_set_t set) {
                 "Key(%s) != value(%s). Abording",
                 elm->name,elm->data);
   }
                 "Key(%s) != value(%s). Abording",
                 elm->name,elm->data);
   }
-  return no_error;
+}
+
+static void search_not_found(xbt_set_t set, const char *data) {
+  xbt_ex_t e;
+  
+  TRY {
+    xbt_set_get_by_name(set,data);
+    THROW1(unknown_error,0,"Found something which shouldn't be there (%s)",data);
+  } CATCH(e) {
+    if (e.category == mismatch_error) {
+      xbt_ex_free(e);
+    } else {
+      RETHROW;
+    }
+  }
 }
 
 int main(int argc,char **argv) {
 }
 
 int main(int argc,char **argv) {
-  xbt_error_t errcode;
   xbt_set_t set=NULL;
   my_elem_t  elm;
 
   xbt_set_t set=NULL;
   my_elem_t  elm;
 
@@ -162,7 +159,7 @@ int main(int argc,char **argv) {
   printf("\nData set: USAGE test:\n");
 
   printf(" Traverse the empty set\n");
   printf("\nData set: USAGE test:\n");
 
   printf(" Traverse the empty set\n");
-  TRYFAIL(traverse(set));
+  traverse(set);
 
   fill(&set);
   printf(" Free the data set\n");
 
   fill(&set);
   printf(" Free the data set\n");
@@ -184,38 +181,35 @@ int main(int argc,char **argv) {
 
   /*  xbt_dict_dump(head,(void (*)(void*))&printf); */
   printf(" - Traverse the resulting data set\n");
 
   /*  xbt_dict_dump(head,(void (*)(void*))&printf); */
   printf(" - Traverse the resulting data set\n");
-  TRYFAIL(traverse(set));
+  traverse(set);
 
   printf(" - Retrive values\n");
 
   printf(" - Retrive values\n");
-  xbt_set_get_by_name(set,"123",(xbt_set_elm_t*)&elm);
+  elm = (my_elem_t) xbt_set_get_by_name(set,"123");
   xbt_assert(elm);
   xbt_assert(elm);
-  TRYFAIL(strcmp("123",elm->data));
-
-  TRYEXPECT(xbt_set_get_by_name(set,"Can't be found",(xbt_set_elm_t*)&elm),
-           mismatch_error);
-  TRYEXPECT(xbt_set_get_by_name(set,"123 Can't be found",(xbt_set_elm_t*)&elm),
-           mismatch_error);
-  TRYEXPECT(xbt_set_get_by_name(set,"12345678 NOT",(xbt_set_elm_t*)&elm),
-           mismatch_error);
-
-  TRYFAIL(search_name(set,"12"));
-  TRYFAIL(search_name(set,"12a"));
-  TRYFAIL(search_name(set,"12b"));
-  TRYFAIL(search_name(set,"123"));
-  TRYFAIL(search_name(set,"123456"));
-  TRYFAIL(search_name(set,"1234"));
-  TRYFAIL(search_name(set,"123457"));
-
-  TRYFAIL(search_id(set,0,"12"));
-  TRYFAIL(search_id(set,1,"12a"));
-  TRYFAIL(search_id(set,2,"12b"));
-  TRYFAIL(search_id(set,3,"123"));
-  TRYFAIL(search_id(set,4,"123456"));
-  TRYFAIL(search_id(set,5,"1234"));
-  TRYFAIL(search_id(set,6,"123457"));
+  strcmp("123",elm->data);
+
+  search_not_found(set,"Can't be found");
+  search_not_found(set,"123 Can't be found");
+  search_not_found(set,"12345678 NOT");
+
+  search_name(set,"12");
+  search_name(set,"12a");
+  search_name(set,"12b");
+  search_name(set,"123");
+  search_name(set,"123456");
+  search_name(set,"1234");
+  search_name(set,"123457");
+
+  search_id(set,0,"12");
+  search_id(set,1,"12a");
+  search_id(set,2,"12b");
+  search_id(set,3,"123");
+  search_id(set,4,"123456");
+  search_id(set,5,"1234");
+  search_id(set,6,"123457");
 
   printf(" - Traverse the resulting data set\n");
 
   printf(" - Traverse the resulting data set\n");
-  TRYFAIL(traverse(set));
+  traverse(set);
 
   /*  xbt_dict_dump(head,(void (*)(void*))&printf); */
 
 
   /*  xbt_dict_dump(head,(void (*)(void*))&printf); */
 
@@ -224,7 +218,7 @@ int main(int argc,char **argv) {
   xbt_set_free(&set);
 
   printf(" - Traverse the resulting data set\n");
   xbt_set_free(&set);
 
   printf(" - Traverse the resulting data set\n");
-  TRYFAIL(traverse(set));
+  traverse(set);
 
   xbt_exit();
   return 0;
 
   xbt_exit();
   return 0;