Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix make dist.
[simgrid.git] / examples / gras / mmrpc / mmrpc.c
index c64f323..fa9de31 100644 (file)
@@ -6,7 +6,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. */
 
-#define GRAS_DEFINE_TYPE_EXTERN
+#define XBT_DEFINE_TYPE_EXTERN
 #include "xbt/matrix.h"
 #include "mmrpc.h"
 
@@ -16,12 +16,12 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(MatMult, "Messages specific to this example");
    (common to client and server) */
 void mmrpc_register_messages(void)
 {
-  gras_datadesc_type_t matrix_type, request_type;
+  xbt_datadesc_type_t matrix_type, request_type;
 
-  matrix_type = gras_datadesc_matrix(gras_datadesc_by_name("double"),
+  matrix_type = xbt_datadesc_matrix(xbt_datadesc_by_name("double"),
                                      NULL);
   request_type =
-      gras_datadesc_array_fixed("s_matrix_t(double)[2]", matrix_type, 2);
+      xbt_datadesc_array_fixed("s_matrix_t(double)[2]", matrix_type, 2);
 
   gras_msgtype_declare("answer", matrix_type);
   gras_msgtype_declare("request", request_type);
@@ -32,7 +32,7 @@ static int server_cb_request_handler(gras_msg_cb_ctx_t ctx,
                                      void *payload_data)
 {
 
-  gras_socket_t expeditor = gras_msg_cb_ctx_from(ctx);
+  xbt_socket_t expeditor = gras_msg_cb_ctx_from(ctx);
 
   /* 1. Get the payload into the data variable */
   xbt_matrix_t *request = (xbt_matrix_t *) payload_data;
@@ -55,8 +55,7 @@ static int server_cb_request_handler(gras_msg_cb_ctx_t ctx,
 
 int server(int argc, char *argv[])
 {
-  xbt_ex_t e;
-  gras_socket_t sock = NULL;
+  xbt_socket_t sock = NULL;
   int port = 4000;
 
   /* 1. Init the GRAS infrastructure */
@@ -72,8 +71,8 @@ int server(int argc, char *argv[])
   TRY {
     sock = gras_socket_server(port);
   }
-  CATCH(e) {
-    RETHROW0("Unable to establish a server socket: %s");
+  CATCH_ANONYMOUS {
+    RETHROWF("Unable to establish a server socket: %s");
   }
 
   /* 4. Register the known messages and payloads. */
@@ -82,7 +81,7 @@ int server(int argc, char *argv[])
   /* 5. Register my callback */
   gras_cb_register("request", &server_cb_request_handler);
 
-  /* 6. Wait up to 10 minutes for an incomming message to handle */
+  /* 6. Wait up to 10 minutes for an incoming message to handle */
   gras_msg_handle(600.0);
 
   /* 7. Free the allocated resources, and shut GRAS down */
@@ -96,10 +95,9 @@ int server(int argc, char *argv[])
 
 int client(int argc, char *argv[])
 {
-  xbt_ex_t e;
-  gras_socket_t toserver = NULL;        /* peer */
+  xbt_socket_t toserver = NULL;        /* peer */
 
-  gras_socket_t from;
+  xbt_socket_t from;
   xbt_matrix_t request[2], answer;
 
   int i, j;
@@ -125,8 +123,8 @@ int client(int argc, char *argv[])
   TRY {
     toserver = gras_socket_client(host, port);
   }
-  CATCH(e) {
-    RETHROW0("Unable to connect to the server: %s");
+  CATCH_ANONYMOUS {
+    RETHROWF("Unable to connect to the server: %s");
   }
   XBT_INFO("Connected to %s:%d.", host, port);
 
@@ -136,7 +134,7 @@ int client(int argc, char *argv[])
 
   /* 6. Keep the user informed of what's going on */
   XBT_INFO(">>>>>>>> Connected to server which is on %s:%d <<<<<<<<",
-        gras_socket_peer_name(toserver), gras_socket_peer_port(toserver));
+        xbt_socket_peer_name(toserver), xbt_socket_peer_port(toserver));
 
   /* 7. Prepare and send the request to the server */
 
@@ -153,7 +151,7 @@ int client(int argc, char *argv[])
   xbt_matrix_free(request[0]);
 
   XBT_INFO(">>>>>>>> Request sent to %s:%d <<<<<<<<",
-        gras_socket_peer_name(toserver), gras_socket_peer_port(toserver));
+        xbt_socket_peer_name(toserver), xbt_socket_peer_port(toserver));
 
   /* 8. Wait for the answer from the server, and deal with issues */
   gras_msg_wait(6000, "answer", &from, &answer);
@@ -163,7 +161,7 @@ int client(int argc, char *argv[])
    */
   for (i = 0; i < MATSIZE; i++)
     for (j = 0; i < MATSIZE; i++)
-      xbt_assert4(xbt_matrix_get_as(answer, i, j, double) ==
+      xbt_assert(xbt_matrix_get_as(answer, i, j, double) ==
                   xbt_matrix_get_as(request[1], i, j, double),
                   "Answer does not match expectations. Found %f at cell %d,%d instead of %f",
                   xbt_matrix_get_as(answer, i, j, double), i, j,
@@ -171,7 +169,7 @@ int client(int argc, char *argv[])
 
   /* 9. Keep the user informed of what's going on, again */
   XBT_INFO(">>>>>>>> Got answer from %s:%d (values are right) <<<<<<<<",
-        gras_socket_peer_name(from), gras_socket_peer_port(from));
+        xbt_socket_peer_name(from), xbt_socket_peer_port(from));
 
   /* 10. Free the allocated resources, and shut GRAS down */
   xbt_matrix_free(request[1]);