Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
This change allow to avoid the Visual C++ compiler Warning that occur when you try...
[simgrid.git] / src / gras / Virtu / process.c
index f1883e6..a978ba3 100644 (file)
 XBT_LOG_NEW_SUBCATEGORY(gras_virtu,gras,"Virtualization code");
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(gras_virtu_process,gras_virtu,"Process manipulation code");
 
-
 /* Functions to handle gras_procdata_t->libdata cells*/
 typedef struct {
    char *name;
-   pvoid_f_void_t *constructor;
-   void_f_pvoid_t *destructor;
+   pvoid_f_void_t constructor;
+   void_f_pvoid_t destructor;
 } s_gras_procdata_fabric_t, *gras_procdata_fabric_t;
 
 static xbt_dynar_t _gras_procdata_fabrics = NULL; /* content: s_gras_procdata_fabric_t */
@@ -81,13 +80,11 @@ void *gras_libdata_by_name(const char *name) {
 void *gras_libdata_by_name_from_procdata(const char*name, gras_procdata_t* pd) {
   void *res=NULL;
   xbt_ex_t e;
-
   if (xbt_set_length(pd->libdata) < xbt_dynar_length(_gras_procdata_fabrics)) {
      /* Damn, some new modules were added since procdata_init(). Amok? */
      /* Get 'em all */
      gras_procdata_init();     
   }
-   
   TRY {
     res = xbt_set_get_by_name(pd->libdata, name);
   } CATCH(e) {
@@ -106,6 +103,7 @@ void *gras_libdata_by_id(int id) {
   return xbt_set_get_by_id(pd->libdata, id);
 }
 
+
 void
 gras_procdata_init() {
   gras_procdata_t *pd=gras_procdata_get();
@@ -120,11 +118,11 @@ gras_procdata_init() {
      pd->userdata  = NULL;
      pd->libdata   = xbt_set_new();
   }
-   
+  
   xbt_dynar_foreach(_gras_procdata_fabrics,cursor,fab){ 
     volatile int found = 0;
      
-    if (cursor+1 <= xbt_set_length(pd->libdata)) {
+    if (cursor+1 <= (int)xbt_set_length(pd->libdata)) {
        DEBUG2("Skip fabric %d: there is already %ld libdata",
             cursor, xbt_set_length(pd->libdata));
        continue; /* allow to recall this function to get recently added fabrics */
@@ -146,13 +144,12 @@ gras_procdata_init() {
       THROW1(unknown_error,0,"MayDay: two modules use '%s' as libdata name", fab.name);
     
     /* Add the data in place, after some more sanity checking */
-    elem = (fab.constructor)();
+    elem = (*(fab.constructor))();
     if (elem->name_len && elem->name_len != strlen(elem->name)) {
        elem->name_len = strlen(elem->name);
        WARN1("Module '%s' constructor is borken: it does not set elem->name_len",
             fab.name);
     }
-     
     xbt_set_add(pd->libdata, elem, fab.destructor);
   }
 }
@@ -170,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;
+}