X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/da6da59e6a2770e25be5d88661e8f8e32810e0ff..9f21f35eadfc5d1f43d3e7a4b591711fd7fb9616:/examples/msg/dht-pastry/dht-pastry.c?ds=sidebyside diff --git a/examples/msg/dht-pastry/dht-pastry.c b/examples/msg/dht-pastry/dht-pastry.c index 270cb94aed..f60180c02b 100644 --- a/examples/msg/dht-pastry/dht-pastry.c +++ b/examples/msg/dht-pastry/dht-pastry.c @@ -4,8 +4,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. */ -#include #include "simgrid/msg.h" +#include "xbt/fifo.h" +#include XBT_LOG_NEW_DEFAULT_CATEGORY(msg_pastry, "Messages specific for this msg example"); @@ -68,7 +69,7 @@ typedef struct s_task_data { } s_task_data_t, *task_data_t; static void get_mailbox(int node_id, char* mailbox); -static int domain(int a, int level); +static int domain(unsigned int a, unsigned int level); static int shl(int a, int b); static int closest_in_namespace_set(node_t node, int dest); static int routing_next(node_t node, int dest); @@ -86,7 +87,8 @@ static void get_mailbox(int node_id, char* mailbox) /** Get the specific level of a node id */ unsigned int domain_mask = 0; -static int domain(int a, int level) { +static int domain(unsigned int a, unsigned int level) +{ if (domain_mask == 0) domain_mask = pow(2, DOMAIN_SIZE) - 1; unsigned int shift = (LEVELS_COUNT-level-1)*DOMAIN_SIZE; @@ -135,13 +137,12 @@ static int closest_in_namespace_set(node_t node, int dest) { /* Find the next node to forward a message to */ static int routing_next(node_t node, int dest) { int closest = closest_in_namespace_set(node, dest); - int res = -1; if (closest!=-1) return closest; int l = shl(node->id, dest); - res = node->routing_table[l][domain(dest, l)]; - if (res!=-1) + int res = node->routing_table[l][domain(dest, l)]; + if (res != -1) return res; //rare case @@ -583,7 +584,7 @@ int main(int argc, char *argv[]) timeout = xbt_str_parse_int(options[0] + length, "Invalid timeout parameter: %s"); XBT_DEBUG("Set timeout to %d", timeout); } else { - xbt_die("Invalid chord option '%s'", options[0]); + xbt_die("Invalid pastry option '%s'", options[0]); } } options++;