- case e_gras_datadesc_type_cat_array: {
- gras_dd_cat_array_t array_data;
- int count;
- char *ptr;
- long int elm_size;
-
- array_data = type->category.array_data;
- /* determine element count locally or from peer */
- count = array_data.fixed_size;
- if (count <= 0)
- TRY(gras_dd_recv_int(sock, r_arch, &count));
- if (count < 0)
- RAISE1(mismatch_error,
- "Invalid (negative) array size for type %s",type->name);
-
- /* receive the content */
- TRY(gras_datadesc_by_id(array_data.code, &sub_type));
- elm_size = sub_type->aligned_size[GRAS_THISARCH];
- VERB2("Receive a %d-long array of %s",count, sub_type->name);
-
- if (!l_data) {
- TRY(gras_dd_alloc_ref(refs,elm_size*count,r_data,r_lgr, &l_data));
- }
-
- ptr = l_data;
- for (cpt=0; cpt<count; cpt++) {
- TRY(gras_datadesc_recv_rec(sock,state,refs, sub_type,
- r_arch, NULL, 0, ptr));
- ptr += elm_size;
+ case e_gras_datadesc_type_cat_array:{
+ gras_dd_cat_array_t array_data;
+ int count;
+ char *ptr;
+ long int elm_size;
+
+ array_data = type->category.array_data;
+ /* determine element count locally, or from caller, or from peer */
+ count = array_data.fixed_size;
+ if (count == -1)
+ count = subsize;
+ if (count == -1)
+ gras_dd_recv_int(sock, r_arch, &count);
+ if (count == -1)
+ THROWF(mismatch_error, 0,
+ "Invalid (=-1) array size for type %s", type->name);
+
+ /* receive the content */
+ sub_type = array_data.type;
+ if (sub_type->category_code == e_gras_datadesc_type_cat_scalar) {
+ XBT_VERB("Array of %d scalars, get it in one shoot", count);
+ if (sub_type->aligned_size[GRAS_THISARCH] >=
+ sub_type->aligned_size[r_arch]) {
+ gras_trp_recv(sock, (char *) l_data,
+ sub_type->aligned_size[r_arch] * count);
+ if (r_arch != GRAS_THISARCH)
+ gras_dd_convert_elm(sub_type, count, r_arch, l_data, l_data);
+ } else {
+ ptr = xbt_malloc(sub_type->aligned_size[r_arch] * count);
+
+ gras_trp_recv(sock, (char *) ptr,
+ sub_type->size[r_arch] * count);
+ if (r_arch != GRAS_THISARCH)
+ gras_dd_convert_elm(sub_type, count, r_arch, ptr, l_data);
+ free(ptr);
+ }
+ } else if (sub_type->category_code == e_gras_datadesc_type_cat_array
+ && sub_type->category.array_data.fixed_size >= 0
+ && sub_type->category.array_data.type->category_code ==
+ e_gras_datadesc_type_cat_scalar) {
+ gras_datadesc_type_t subsub_type;
+ array_data = sub_type->category.array_data;
+ subsub_type = array_data.type;
+
+ XBT_VERB("Array of %d fixed array of scalars, get it in one shot",
+ count);
+ if (subsub_type->aligned_size[GRAS_THISARCH] >=
+ subsub_type->aligned_size[r_arch]) {
+ gras_trp_recv(sock, (char *) l_data,
+ subsub_type->aligned_size[r_arch] * count *
+ array_data.fixed_size);
+ if (r_arch != GRAS_THISARCH)
+ gras_dd_convert_elm(subsub_type, count * array_data.fixed_size,
+ r_arch, l_data, l_data);
+ } else {
+ ptr =
+ xbt_malloc(subsub_type->aligned_size[r_arch] * count *
+ array_data.fixed_size);
+
+ gras_trp_recv(sock, (char *) ptr,
+ subsub_type->size[r_arch] * count *
+ array_data.fixed_size);
+ if (r_arch != GRAS_THISARCH)
+ gras_dd_convert_elm(subsub_type, count * array_data.fixed_size,
+ r_arch, ptr, l_data);
+ free(ptr);
+ }
+
+
+ } else {
+ /* not scalar content, get it recursively (may contain pointers) */
+ elm_size = sub_type->aligned_size[GRAS_THISARCH];
+ XBT_VERB("Receive a %d-long array of %s", count, sub_type->name);
+
+ ptr = l_data;
+ for (cpt = 0; cpt < count; cpt++) {
+ gras_datadesc_recv_rec(sock, state, refs, sub_type,
+ r_arch, NULL, 0, ptr, -1,
+ detect_cycle || sub_type->cycle);
+
+ ptr += elm_size;
+ }
+ }
+ break;