From: mquinson Date: Wed, 12 Jul 2006 11:39:35 +0000 (+0000) Subject: s/xbt_host_t/xbt_peer_t/ X-Git-Tag: v3.3~2822 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b511b8e4a7d720584d9d9a72b874709869bc10d0 s/xbt_host_t/xbt_peer_t/ git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@2536 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/examples/amok/bandwidth/bandwidth.c b/examples/amok/bandwidth/bandwidth.c index 2568bf4930..148a86ceca 100644 --- a/examples/amok/bandwidth/bandwidth.c +++ b/examples/amok/bandwidth/bandwidth.c @@ -10,7 +10,7 @@ #include "gras.h" #include "amok/bandwidth.h" -#include "amok/hostmanagement.h" +#include "amok/peermanagement.h" XBT_LOG_NEW_DEFAULT_CATEGORY(Bandwidth,"Messages specific to this example"); @@ -59,7 +59,7 @@ int maestro(int argc,char *argv[]) { gras_socket_t peer; gras_socket_t mysock; - xbt_host_t h1,h2; + xbt_peer_t h1,h2; xbt_dynar_t group; gras_init(&argc, argv); @@ -82,8 +82,8 @@ int maestro(int argc,char *argv[]) { xbt_dynar_length(group)); xbt_die(msg); } - h1 = *(xbt_host_t*) xbt_dynar_get_ptr(group, 0); - h2 = *(xbt_host_t*)xbt_dynar_get_ptr(group, 1); + h1 = *(xbt_peer_t*) xbt_dynar_get_ptr(group, 0); + h2 = *(xbt_peer_t*)xbt_dynar_get_ptr(group, 1); INFO2("Contact %s:%d",h1->name, h1->port); peer = gras_socket_client(h1->name, h1->port); diff --git a/examples/amok/saturate/saturate.c b/examples/amok/saturate/saturate.c index ca62e93b29..108e595052 100644 --- a/examples/amok/saturate/saturate.c +++ b/examples/amok/saturate/saturate.c @@ -14,7 +14,7 @@ #include "gras.h" #include "amok/bandwidth.h" -#include "amok/hostmanagement.h" +#include "amok/peermanagement.h" XBT_LOG_NEW_DEFAULT_CATEGORY(saturate,"Messages specific to this example"); @@ -100,12 +100,12 @@ static void kill_buddy(char *name,int port){ gras_socket_close(sock); } static void kill_buddy_dynar(void *b) { - xbt_host_t buddy=*(xbt_host_t*)b; + xbt_peer_t buddy=*(xbt_peer_t*)b; kill_buddy(buddy->name,buddy->port); } -static void free_host(void *d){ - xbt_host_t h=*(xbt_host_t*)d; +static void free_peer(void *d){ + xbt_peer_t h=*(xbt_peer_t*)d; free(h->name); free(h); } @@ -139,8 +139,8 @@ static void full_fledged_saturation(int argc, char*argv[]) { int begin; /* where are the sensors */ - xbt_dynar_t hosts; - int nb_hosts; + xbt_dynar_t peers; + int nb_peers; /* results */ double *bw; @@ -148,16 +148,16 @@ static void full_fledged_saturation(int argc, char*argv[]) { /* iterators */ int i,j,k,l; - xbt_host_t h1,h2,h3,h4; + xbt_peer_t h1,h2,h3,h4; /* Init the group */ - hosts=amok_hm_group_new("saturate"); + peers=amok_hm_group_new("saturate"); /* wait 4 dudes */ gras_msg_handle(60); gras_msg_handle(60); gras_msg_handle(60); gras_msg_handle(60); - nb_hosts = xbt_dynar_length(hosts); + nb_peers = xbt_dynar_length(peers); INFO0("Let's go for the bw_matrix"); @@ -165,15 +165,15 @@ static void full_fledged_saturation(int argc, char*argv[]) { begin=time(NULL); begin_simulated=gras_os_time(); - bw=amok_bw_matrix(hosts,buf_size,exp_size,msg_size,min_duration); + bw=amok_bw_matrix(peers,buf_size,exp_size,msg_size,min_duration); INFO2("Did all BW tests in %ld sec (%.2f simulated(?) sec)", time(NULL)-begin,gras_os_time()-begin_simulated); /* Do the test with saturation */ - bw_sat=xbt_new(double,nb_hosts*nb_hosts); - xbt_dynar_foreach(hosts,i,h1) { - xbt_dynar_foreach(hosts,j,h2) { + bw_sat=xbt_new(double,nb_peers*nb_peers); + xbt_dynar_foreach(peers,i,h1) { + xbt_dynar_foreach(peers,j,h2) { if (i==j) continue; TRY { @@ -182,16 +182,16 @@ static void full_fledged_saturation(int argc, char*argv[]) { 0, /* Be nice, compute msg_size yourself */ 0 /* no timeout */); } CATCH(e) { - RETHROW0("Cannot ask hosts to saturate the link: %s"); + RETHROW0("Cannot ask peers to saturate the link: %s"); } gras_os_sleep(5); begin=time(NULL); begin_simulated=gras_os_time(); - xbt_dynar_foreach(hosts,k,h3) { + xbt_dynar_foreach(peers,k,h3) { if (i==k || j==k) continue; - xbt_dynar_foreach(hosts,l,h4) { + xbt_dynar_foreach(peers,l,h4) { double ratio; if (i==l || j==l || k==l) continue; @@ -199,13 +199,13 @@ static void full_fledged_saturation(int argc, char*argv[]) { h1->name,h2->name,h3->name,h4->name); amok_bw_request(h3->name,h3->port, h4->name,h4->port, buf_size,exp_size,msg_size,min_duration, - NULL,&(bw_sat[k*nb_hosts + l])); + NULL,&(bw_sat[k*nb_peers + l])); - ratio=bw_sat[k*nb_hosts + l] / bw[k*nb_hosts + l]; + ratio=bw_sat[k*nb_peers + l] / bw[k*nb_peers + l]; INFO8("SATURATED BW XP(%s %s // %s %s) => %f (%f vs %f)%s", h1->name,h2->name,h3->name,h4->name, ratio, - bw[k*nb_hosts + l] , bw_sat[k*nb_hosts + l], + bw[k*nb_peers + l] , bw_sat[k*nb_peers + l], ratio < 0.7 ? " THERE IS SOME INTERFERENCE !!!": ""); } } diff --git a/examples/gras/all2all/all2all.c b/examples/gras/all2all/all2all.c index badb0680b6..5c029dad7d 100644 --- a/examples/gras/all2all/all2all.c +++ b/examples/gras/all2all/all2all.c @@ -80,21 +80,21 @@ int sender (int argc,char *argv[]) { int i; /* iterator */ char *data; /* data exchanged */ int datasize; /* size of message */ - xbt_host_t h; /* iterator */ + xbt_peer_t h; /* iterator */ gras_socket_t peer; /* socket to node */ - /* xbt_dynar for hosts */ - xbt_dynar_t hosts = xbt_dynar_new(sizeof(xbt_host_t),&xbt_host_free_voidp); + /* xbt_dynar for peers */ + xbt_dynar_t peers = xbt_dynar_new(sizeof(xbt_peer_t),&xbt_peer_free_voidp); /* Init the GRAS infrastructure and declare my globals */ gras_init(&argc,argv); /* Get the node location from argc/argv */ for (i=1; iname,h->port); gras_msg_send(peer,gras_msgtype_by_name("data"),&data); @@ -123,7 +123,7 @@ int sender (int argc,char *argv[]) { } /* Free the allocated resources, and shut GRAS down */ - xbt_dynar_free(&hosts); + xbt_dynar_free(&peers); gras_exit(); return 0; diff --git a/examples/gras/pmm/pmm.c b/examples/gras/pmm/pmm.c index dc7da5bd15..b41dfad43f 100755 --- a/examples/gras/pmm/pmm.c +++ b/examples/gras/pmm/pmm.c @@ -10,7 +10,7 @@ #include "gras.h" #include "xbt/matrix.h" -#include "amok/hostmanagement.h" +#include "amok/peermanagement.h" #define PROC_MATRIX_SIZE 3 #define NEIGHBOR_COUNT PROC_MATRIX_SIZE - 1 @@ -33,8 +33,8 @@ typedef struct s_result result_t; GRAS_DEFINE_TYPE(s_pmm_assignment,struct s_pmm_assignment { int linepos; int rowpos; - xbt_host_t line[NEIGHBOR_COUNT]; - xbt_host_t row[NEIGHBOR_COUNT]; + xbt_peer_t line[NEIGHBOR_COUNT]; + xbt_peer_t row[NEIGHBOR_COUNT]; xbt_matrix_t A GRAS_ANNOTE(subtype,double); xbt_matrix_t B GRAS_ANNOTE(subtype,double); }); @@ -86,8 +86,8 @@ int master (int argc,char *argv[]) { gras_socket_t from; - xbt_dynar_t hosts; /* group of slaves */ - xbt_host_t grid[SLAVE_COUNT]; /* The slaves as an array */ + xbt_dynar_t peers; /* group of slaves */ + xbt_peer_t grid[SLAVE_COUNT]; /* The slaves as an array */ gras_socket_t socket[SLAVE_COUNT]; /* sockets for brodcast to slaves */ /* Init the GRAS's infrastructure */ @@ -102,16 +102,16 @@ int master (int argc,char *argv[]) { /* Create the connexions */ gras_socket_server(atoi(argv[1])); - hosts=amok_hm_group_new("pmm"); + peers=amok_hm_group_new("pmm"); INFO0("Wait for peers for 10 sec"); gras_msg_handleall(10); /* friends, we're ready. Come and play */ - INFO1("Got %ld pals",xbt_dynar_length(hosts)); + INFO1("Got %ld pals",xbt_dynar_length(peers)); for (i=0; - iname,grid[i]->port); INFO2("Connected to %s:%d.",grid[i]->name,grid[i]->port); } @@ -120,10 +120,10 @@ int master (int argc,char *argv[]) { i,SLAVE_COUNT); /* Kill surnumerous slaves */ - for (i=SLAVE_COUNT; iname,h->port); free(h); } @@ -252,12 +252,12 @@ static int pmm_worker_cb(gras_msg_cb_ctx_t ctx, void *payload) { for (i=0 ; iname, assignment.line[i]->port); - xbt_host_free(assignment.line[i]); + xbt_peer_free(assignment.line[i]); } for (i=0 ; iname, assignment.row[i]->port); - xbt_host_free(assignment.row[i]); + xbt_peer_free(assignment.row[i]); } for (step=0; step #include @@ -71,4 +71,4 @@ void amok_hm_group_shutdown_remote(gras_socket_t master, const char *group_name) /** @} */ -#endif /* AMOK_HOST_MANAGEMENT_H */ +#endif /* AMOK_peer_MANAGEMENT_H */ diff --git a/include/xbt.h b/include/xbt.h index 8a528a4cfe..4cd44e7205 100644 --- a/include/xbt.h +++ b/include/xbt.h @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include diff --git a/include/xbt/config.h b/include/xbt/config.h index da9457da06..25254ad0bd 100644 --- a/include/xbt/config.h +++ b/include/xbt/config.h @@ -107,8 +107,8 @@ 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); +void xbt_cfg_set_peer (xbt_cfg_t cfg, const char *name, + const char *peer,int port); /* Remove the provided value from the cell @name in @cfg. @@ -119,8 +119,8 @@ 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); +void xbt_cfg_rm_peer (xbt_cfg_t cfg, const char *name, + const char *peer,int port); /* Remove the value at position \e pos from the config \e cfg @@ -143,7 +143,7 @@ void xbt_cfg_empty(xbt_cfg_t cfg, const char *name); xbt_cfgelm_int=0, /**< int */ xbt_cfgelm_double, /**< double */ xbt_cfgelm_string, /**< char* */ - xbt_cfgelm_host, /**< both a char* (representing the hostname) and an integer (representing the port) */ + xbt_cfgelm_peer, /**< both a char* (representing the peername) and an integer (representing the port) */ xbt_cfgelm_any, /* not shown to users to prevent errors */ xbt_cfgelm_type_count @@ -193,13 +193,13 @@ void xbt_cfg_empty(xbt_cfg_t cfg, const char *name); 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); + void xbt_cfg_get_peer (xbt_cfg_t cfg, const char *name, char **peer, int *port); xbt_dynar_t xbt_cfg_get_dynar (xbt_cfg_t cfg, const char *name); 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); + void xbt_cfg_get_peer_at (xbt_cfg_t cfg, const char *name, int pos, char **peer, int *port); /** @} */ diff --git a/include/xbt/host.h b/include/xbt/host.h deleted file mode 100644 index 8fd25a20eb..0000000000 --- a/include/xbt/host.h +++ /dev/null @@ -1,32 +0,0 @@ -/* $Id$ */ - -/* host.h - host management functions */ - -/* Copyright (c) 2006 Arnaud Legrand. */ -/* 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. */ - -#ifndef XBT_HOST_H -#define XBT_HOST_H - -#include "xbt/misc.h" - -SG_BEGIN_DECL() - -typedef struct { - char *name; - int port; -} s_xbt_host_t, *xbt_host_t; - -xbt_host_t xbt_host_new(const char *name, int port); -xbt_host_t xbt_host_from_string(const char *hostport); -xbt_host_t xbt_host_copy(xbt_host_t h); -void xbt_host_free(xbt_host_t host); -void xbt_host_free_voidp(void *d); - -SG_END_DECL() - - -#endif /* XBT_MISC_H */ diff --git a/include/xbt/peer.h b/include/xbt/peer.h new file mode 100644 index 0000000000..5f56799883 --- /dev/null +++ b/include/xbt/peer.h @@ -0,0 +1,33 @@ +/* $Id$ */ + +/* peer.h - peer (remote processes) management functions */ + +/* Copyright (c) 2006 Arnaud Legrand. */ +/* Copyright (c) 2006 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. */ + +#ifndef XBT_PEER_H +#define XBT_PEER_H + +#include "xbt/misc.h" + +SG_BEGIN_DECL() + +typedef struct { + char *name; + int port; +} s_xbt_peer_t, *xbt_peer_t; + +xbt_peer_t xbt_peer_new(const char *name, int port); +xbt_peer_t xbt_peer_from_string(const char *peerport); +xbt_peer_t xbt_peer_copy(xbt_peer_t h); +void xbt_peer_free(xbt_peer_t peer); +void xbt_peer_free_voidp(void *d); + +SG_END_DECL() + + +#endif /* XBT_PEER_H */ diff --git a/src/xbt/xbt_host.c b/src/xbt/xbt_host.c deleted file mode 100644 index d1b3930e66..0000000000 --- a/src/xbt/xbt_host.c +++ /dev/null @@ -1,54 +0,0 @@ -/* $Id$ */ - -/* xbt_host_t management functions */ - -/* Copyright (c) 2006 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. */ - -#include "xbt/sysdep.h" -#include "xbt/log.h" -#include "xbt/host.h" - -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(host,xbt,"Host management"); - -/** \brief constructor */ -xbt_host_t xbt_host_new(const char *name, int port) { - xbt_host_t res=xbt_new(s_xbt_host_t, 1); - res->name = xbt_strdup(name); - res->port = port; - return res; -} - -xbt_host_t xbt_host_copy(xbt_host_t h) { - return xbt_host_new(h->name,h->port); -} - -/** \brief constructor. Argument should be of form ':'. */ -xbt_host_t xbt_host_from_string(const char *hostport) { - xbt_host_t res=xbt_new(s_xbt_host_t, 1); - char *name=xbt_strdup(hostport); - char *port_str=strchr(name,':'); - xbt_assert1(port_str,"argument of xbt_host_from_string should be of form :, it's '%s'", hostport); - *port_str='\0'; - port_str++; - - res->name = xbt_strdup(name); /* it will be shorter now that we cut the port */ - res->port = atoi(port_str); - free(name); - return res; -} - -/** \brief destructor */ -void xbt_host_free(xbt_host_t host) { - if (host) { - if (host->name) free(host->name); - free(host); - } -} - -/** \brief Freeing function for dynars of xbt_host_t */ -void xbt_host_free_voidp(void *d) { - xbt_host_free( (xbt_host_t) *(void**)d ); -} diff --git a/src/xbt/xbt_peer.c b/src/xbt/xbt_peer.c new file mode 100644 index 0000000000..d5b3598725 --- /dev/null +++ b/src/xbt/xbt_peer.c @@ -0,0 +1,54 @@ +/* $Id$ */ + +/* xbt_peer_t management functions */ + +/* Copyright (c) 2006 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. */ + +#include "xbt/sysdep.h" +#include "xbt/log.h" +#include "xbt/peer.h" + +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(peer,xbt,"peer management"); + +/** \brief constructor */ +xbt_peer_t xbt_peer_new(const char *name, int port) { + xbt_peer_t res=xbt_new(s_xbt_peer_t, 1); + res->name = xbt_strdup(name); + res->port = port; + return res; +} + +xbt_peer_t xbt_peer_copy(xbt_peer_t h) { + return xbt_peer_new(h->name,h->port); +} + +/** \brief constructor. Argument should be of form ':'. */ +xbt_peer_t xbt_peer_from_string(const char *peerport) { + xbt_peer_t res=xbt_new(s_xbt_peer_t, 1); + char *name=xbt_strdup(peerport); + char *port_str=strchr(name,':'); + xbt_assert1(port_str,"argument of xbt_peer_from_string should be of form :, it's '%s'", peerport); + *port_str='\0'; + port_str++; + + res->name = xbt_strdup(name); /* it will be shorter now that we cut the port */ + res->port = atoi(port_str); + free(name); + return res; +} + +/** \brief destructor */ +void xbt_peer_free(xbt_peer_t peer) { + if (peer) { + if (peer->name) free(peer->name); + free(peer); + } +} + +/** \brief Freeing function for dynars of xbt_peer_t */ +void xbt_peer_free_voidp(void *d) { + xbt_peer_free( (xbt_peer_t) *(void**)d ); +}