Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Simply say fun_ptr(...) instead of (*fun_ptr)(...).
[simgrid.git] / src / gras / Msg / gras_msg_exchange.c
index d2178bc..127ce0f 100644 (file)
@@ -46,7 +46,7 @@ gras_msg_wait_ext_(double timeout,
       (gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
   unsigned int cpt;
 
-  xbt_assert0(msg_got, "msg_got is an output parameter");
+  xbt_assert(msg_got, "msg_got is an output parameter");
 
   start = gras_os_time();
   XBT_VERB("Waiting for message '%s' for %fs",
@@ -152,11 +152,11 @@ gras_msg_wait_(double timeout,
   gras_msg_wait_ext_(timeout, msgt_want, NULL, NULL, NULL, &msg);
 
   if (msgt_want->ctn_type) {
-    xbt_assert1(payload,
+    xbt_assert(payload,
                 "Message type '%s' convey a payload that you must accept",
                 msgt_want->name);
   } else {
-    xbt_assert1(!payload,
+    xbt_assert(!payload,
                 "No payload was declared for message type '%s' (don't expect one)",
                 msgt_want->name);
   }
@@ -209,7 +209,7 @@ void gras_msg_wait_or(double timeout,
                      &gras_msg_wait_or_filter, (void *) msgt_want, &msg);
 
   if (msg.type->ctn_type) {
-    xbt_assert1(payload,
+    xbt_assert(payload,
                 "Message type '%s' convey a payload you must accept",
                 msg.type->name);
   }
@@ -235,11 +235,11 @@ void gras_msg_send_(gras_socket_t sock, gras_msgtype_t msgtype,
 {
 
   if (msgtype->ctn_type) {
-    xbt_assert1(payload,
+    xbt_assert(payload,
                 "Message type '%s' convey a payload you must provide",
                 msgtype->name);
   } else {
-    xbt_assert1(!payload,
+    xbt_assert(!payload,
                 "No payload was declared for message type '%s'",
                 msgtype->name);
   }
@@ -290,13 +290,13 @@ void gras_msg_handleall(double period)
  *
  * @sa gras_msg_handleall().
  */
-void gras_msg_handle(double timeOut)
+void gras_msg_handle(volatile double timeOut)
 {
 
   double untiltimer;
 
   unsigned int cpt;
-  int volatile ran_ok;
+  volatile int ran_ok;
 
   s_gras_msg_t msg;
 
@@ -306,7 +306,7 @@ void gras_msg_handle(double timeOut)
   gras_msg_cb_t cb;
   s_gras_msg_cb_ctx_t ctx;
 
-  int timerexpected, timeouted;
+  volatile int timerexpected, timeouted;
   xbt_ex_t e;
 
   XBT_VERB("Handling message within the next %.2fs", timeOut);
@@ -352,7 +352,7 @@ void gras_msg_handle(double timeOut)
         /* we served a timer, we're done */
         return;
       } else {
-        xbt_assert1(untiltimer > 0, "Negative timer (%f). I'm 'puzzeled'",
+        xbt_assert(untiltimer > 0, "Negative timer (%f). I'm 'puzzeled'",
                     untiltimer);
         XBT_WARN
             ("No timer elapsed, in contrary to expectations (next in %f sec)",
@@ -398,16 +398,18 @@ void gras_msg_handle(double timeOut)
     ran_ok = 0;
     TRY {
       xbt_dynar_foreach(list->cbs, cpt, cb) {
+        volatile unsigned int cpt2 = cpt;
         if (!ran_ok) {
           XBT_DEBUG
               ("Use the callback #%d (@%p) for incomming msg '%s' (payload_size=%d)",
                cpt + 1, cb, msg.type->name, msg.payl_size);
-          if (!(*cb) (&ctx, msg.payl)) {
+          if (!cb(&ctx, msg.payl)) {
             /* cb handled the message */
             free(msg.payl);
             ran_ok = 1;
           }
         }
+        cpt = cpt2;
       }
     }
     CATCH(e) {
@@ -444,7 +446,7 @@ void gras_msg_handle(double timeOut)
       }
     }
 
-    xbt_assert1(!ctx.answer_due,
+    xbt_assert(!ctx.answer_due,
                 "Bug in user code: RPC callback to message '%s' didn't call gras_msg_rpcreturn",
                 msg.type->name);
     if (ctx.answer_due)