From: mquinson Date: Sun, 15 Jul 2007 11:34:14 +0000 (+0000) Subject: new function gras_os_hostport, returning a constant form of gras_os_myname():gras_os_... X-Git-Tag: v3.3~1570 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/c45ece9f4e79e326e1c803151d6a2ea7cffafa33 new function gras_os_hostport, returning a constant form of gras_os_myname():gras_os_myport() git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3790 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/ChangeLog b/ChangeLog index 341723f9bf..11f30bd546 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,6 +25,8 @@ SimGrid (3.3-cvs) unstable; urgency=low linux ones too) [Mt] * New function: gras_agent_spawn() to launch a new process on current host. Only working in simulation for now.. [Mt] + * New function: gras_os_hostport() returning a constant form (ie, + not needing to be freed) of "gras_os_hostname():gras_os_myport()" XBT: * Make the backtrace of exceptions more human readable [Mt] diff --git a/include/gras/virtu.h b/include/gras/virtu.h index 837ede6ab6..8fe94ab9c3 100644 --- a/include/gras/virtu.h +++ b/include/gras/virtu.h @@ -53,6 +53,13 @@ gras_os_myname(void); /** @brief returns the number on which this process is listening for incoming messages */ XBT_PUBLIC(int) gras_os_myport(void); +/** @brief get the uri of the current process + * + * Returns the concatenation of gras_os_myname():gras_os_myport(). Please do not free the result. + */ +XBT_PUBLIC(const char *) +gras_os_hostport(void); + /** @brief get process identification * * Returns the process ID of the current process. (This is often used diff --git a/src/gras/Virtu/process.c b/src/gras/Virtu/process.c index 8f2ab4d80a..8daf4b7778 100644 --- a/src/gras/Virtu/process.c +++ b/src/gras/Virtu/process.c @@ -167,3 +167,12 @@ gras_procdata_exit() { } xbt_dynar_free( & _gras_procdata_fabrics ); } + + +const char *gras_os_hostport() { + static char *res=NULL; + if (res) + free(res); /* my port may have changed */ + res = bprintf("%s:%d",gras_os_myname(),gras_os_myport()); + return (const char*)res; +}