Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
New function allowing to alias datatypes
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 19 Jul 2007 04:50:48 +0000 (04:50 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 19 Jul 2007 04:50:48 +0000 (04:50 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3866 48e7efb5-ca39-0410-a469-dd3cf9ba447f

include/gras/datadesc.h
src/gras/DataDesc/ddt_create.c
src/gras/DataDesc/ddt_exchange.c
src/gras/Msg/sg_msg.c

index 0966e86..a3c27d2 100644 (file)
@@ -348,6 +348,9 @@ XBT_PUBLIC(void) gras_datadesc_union_close(gras_datadesc_type_t    union_type);
 XBT_PUBLIC(gras_datadesc_type_t) 
   gras_datadesc_ref(const char          *name,
                    gras_datadesc_type_t referenced_type);
+XBT_PUBLIC(gras_datadesc_type_t) 
+  gras_datadesc_copy(const char          *name,
+                    gras_datadesc_type_t copied_type);
 XBT_PUBLIC(gras_datadesc_type_t) 
   gras_datadesc_ref_generic(const char              *name,
                            gras_datadesc_selector_t selector);
index d0e2792..87e7c56 100644 (file)
@@ -373,6 +373,22 @@ gras_datadesc_union_close(gras_datadesc_type_t union_type) {
    union_type->category.union_data.closed = 1;
 }
 
+/** \brief Copy a type under another name
+ * 
+ * This may reveal useful to circumvent parsing macro limitations
+ */
+gras_datadesc_type_t 
+  gras_datadesc_copy(const char           *name,
+                    gras_datadesc_type_t  copied) {
+
+     gras_datadesc_type_t res = gras_ddt_new(name);
+     char *name_cpy = res->name;
+     
+     memcpy(res,copied,sizeof(s_gras_datadesc_type_t));
+     res->name = name_cpy;
+     return res;
+  }
+
 /** \brief Declare a new type being a reference to the one passed in arg */
 gras_datadesc_type_t 
   gras_datadesc_ref(const char           *name,
index 8c15e20..e0d59d1 100644 (file)
@@ -105,7 +105,7 @@ gras_dd_alloc_ref(xbt_dict_t  refs,
 }
 
 static int
-gras_datadesc_copy_rec(gras_cbps_t           state,
+gras_datadesc_memcpy_rec(gras_cbps_t           state,
                       xbt_dict_t            refs,
                       gras_datadesc_type_t  type, 
                       char                 *src,
@@ -154,7 +154,7 @@ gras_datadesc_copy_rec(gras_cbps_t           state,
        field->send(type,state,field_src);
       
       DEBUG1("Copy field %s",field->name);
-      count += gras_datadesc_copy_rec(state,refs,sub_type, field_src, field_dst, 0,
+      count += gras_datadesc_memcpy_rec(state,refs,sub_type, field_src, field_dst, 0,
                                      detect_cycle || sub_type->cycle);
        
        if (XBT_LOG_ISENABLED(gras_ddt_exchange,xbt_log_priority_verbose)) {
@@ -209,7 +209,7 @@ gras_datadesc_copy_rec(gras_cbps_t           state,
     if (field->send)
       field->send(type,state,src);
     
-    count += gras_datadesc_copy_rec(state,refs, sub_type, src, dst,0,
+    count += gras_datadesc_memcpy_rec(state,refs, sub_type, src, dst,0,
                                    detect_cycle || sub_type->cycle);
           
     break;
@@ -285,7 +285,7 @@ gras_datadesc_copy_rec(gras_cbps_t           state,
                           detect_cycle);
        }
        
-       count += gras_datadesc_copy_rec(state,refs, sub_type,
+       count += gras_datadesc_memcpy_rec(state,refs, sub_type,
                                       *o_ref,(char*)l_referenced, subsubcount,
                                       detect_cycle || sub_type->cycle);
                               
@@ -344,7 +344,7 @@ gras_datadesc_copy_rec(gras_cbps_t           state,
       VERB1("Array of %ld stuff, copy it in one after the other",array_count);
       for (cpt=0; cpt<array_count; cpt++) {
        VERB2("Copy the %dth stuff out of %ld",cpt,array_count);
-       count += gras_datadesc_copy_rec(state,refs, sub_type, src_ptr, dst_ptr, 0,
+       count += gras_datadesc_memcpy_rec(state,refs, sub_type, src_ptr, dst_ptr, 0,
                                        detect_cycle || sub_type->cycle);
        src_ptr += elm_size;
        dst_ptr += elm_size;
@@ -360,13 +360,13 @@ gras_datadesc_copy_rec(gras_cbps_t           state,
   return count;
 }
 /**
- * gras_datadesc_copy:
+ * gras_datadesc_memcpy:
  *
  * Copy the data pointed by src and described by type 
  * to a new location, and store a pointer to it in dst.
  *
  */
-int gras_datadesc_copy(gras_datadesc_type_t type, 
+int gras_datadesc_memcpy(gras_datadesc_type_t type, 
                       void *src, void *dst) {
   xbt_ex_t e;
   static gras_cbps_t state=NULL;
@@ -381,8 +381,8 @@ int gras_datadesc_copy(gras_datadesc_type_t type,
   }
   
   TRY {
-    size = gras_datadesc_copy_rec(state,refs,type,(char*)src,(char*)dst,0, 
-                                 type->cycle);
+    size = gras_datadesc_memcpy_rec(state,refs,type,(char*)src,(char*)dst,0, 
+                                   type->cycle);
   } CLEANUP {
     xbt_dict_reset(refs);
     gras_cbps_reset(state);
index 0012b3e..6abe45c 100644 (file)
@@ -54,20 +54,20 @@ void gras_msg_send_ext(gras_socket_t   sock,
      /* error on remote host, carfull, payload is an exception */
     msg->payl_size=gras_datadesc_size(gras_datadesc_by_name("ex_t"));
     msg->payl=xbt_malloc(msg->payl_size);
-    whole_payload_size = gras_datadesc_copy(gras_datadesc_by_name("ex_t"),
-                                           payload,msg->payl);
+    whole_payload_size = gras_datadesc_memcpy(gras_datadesc_by_name("ex_t"),
+                                             payload,msg->payl);
   } else if (kind == e_gras_msg_kind_rpcanswer) {
     msg->payl_size=gras_datadesc_size(msgtype->answer_type);
     msg->payl=xbt_malloc(msg->payl_size);
     if (msgtype->answer_type)
-      whole_payload_size = gras_datadesc_copy(msgtype->answer_type,
-                                             payload, msg->payl);
+      whole_payload_size = gras_datadesc_memcpy(msgtype->answer_type,
+                                               payload, msg->payl);
   } else {
     msg->payl_size=gras_datadesc_size(msgtype->ctn_type);
     msg->payl=msg->payl_size?xbt_malloc(msg->payl_size):NULL;
     if (msgtype->ctn_type)
-      whole_payload_size = gras_datadesc_copy(msgtype->ctn_type,
-                                             payload, msg->payl);
+      whole_payload_size = gras_datadesc_memcpy(msgtype->ctn_type,
+                                               payload, msg->payl);
   }
 
        /* put the selectable socket on the queue */