for (arch = 0; arch < gras_arch_count; arch ++) {
res->size[arch] = gras_arches[arch].sizeofs[type];
res->alignment[arch] = gras_arches[arch].boundaries[type];
- res->aligned_size[arch] = aligned(res->size[arch], res->alignment[arch]);
+ res->aligned_size[arch] = ddt_aligned(res->size[arch], res->alignment[arch]);
}
res->category_code = e_gras_datadesc_type_cat_scalar;
for (arch=0; arch<gras_arch_count; arch ++) {
- field->offset[arch] = aligned(struct_type->size[arch],
- field_type->alignment[arch]);
+ field->offset[arch] = ddt_aligned(struct_type->size[arch],
+ field_type->alignment[arch]);
struct_type->size[arch] = field->offset[arch] + field_type->size[arch];
struct_type->alignment[arch] = max(struct_type->alignment[arch],
field_type->alignment[arch]);
- struct_type->aligned_size[arch] = aligned(struct_type->size[arch],
- struct_type->alignment[arch]);
+ struct_type->aligned_size[arch] = ddt_aligned(struct_type->size[arch],
+ struct_type->alignment[arch]);
}
field->type = field_type;
field->send = NULL;
field_type->size[arch]);
union_type->alignment[arch] = max(union_type->alignment[arch],
field_type->alignment[arch]);
- union_type->aligned_size[arch] = aligned(union_type->size[arch],
- union_type->alignment[arch]);
+ union_type->aligned_size[arch] = ddt_aligned(union_type->size[arch],
+ union_type->alignment[arch]);
}
}
return res;
}
+/*
+ *##
+ *## Constructor of container datatypes
+ *##
+ */
+
#include "xbt/dynar_private.h"
static void gras_datadesc_dynar_cb(gras_datadesc_type_t typedesc, gras_cbps_t vars, void *data) {
gras_datadesc_type_t subtype;
}
/** \brief Declare a new type being a dynar in which each elements are of the given type
+ *
+ * The type gets registered under the name "dynar(%s)_s", where %s is the name of the subtype.
+ * For example, a dynar of doubles will be called "dynar(double)_s" and a dynar of dynar of
+ * strings will be called "dynar(dynar(string)_s)_s".
*
* \param elm_t: the datadesc of the elements
* \param free_func: the function to use to free the elements when the dynar gets freed
char *buffname;
gras_datadesc_type_t res;
- buffname=xbt_new0(char, strlen(elm_t->name)+10);
- sprintf(buffname,"dynar(%s)_s",elm_t->name);
+ asprintf(&buffname,"dynar(%s)_s",elm_t->name);
res = gras_datadesc_struct(buffname);
- gras_datadesc_struct_append(res, "size", gras_datadesc_by_name("unsigned long int"));
+ gras_datadesc_struct_append(res, "size",
+ gras_datadesc_by_name("unsigned long int"));
- gras_datadesc_struct_append(res, "used", gras_datadesc_by_name("unsigned long int"));
- gras_datadesc_cb_field_push(res, "used");
+ gras_datadesc_struct_append(res, "used",
+ gras_datadesc_by_name("unsigned long int"));
- gras_datadesc_struct_append(res, "elmsize", gras_datadesc_by_name("unsigned long int"));
+ gras_datadesc_struct_append(res, "elmsize",
+ gras_datadesc_by_name("unsigned long int"));
- gras_datadesc_struct_append(res, "data", gras_datadesc_ref_pop_arr (elm_t));
+ gras_datadesc_struct_append(res, "data",
+ gras_datadesc_ref_pop_arr (elm_t));
- gras_datadesc_struct_append(res, "free_f", gras_datadesc_by_name("function pointer"));
+ gras_datadesc_struct_append(res, "free_f",
+ gras_datadesc_by_name("function pointer"));
memcpy(res->extra,&free_func,sizeof(free_func));
gras_datadesc_struct_close(res);
+ gras_datadesc_cb_field_push(res, "used");
gras_datadesc_cb_recv(res, &gras_datadesc_dynar_cb);
/* build a ref to it */
- sprintf(buffname,"dynar(%s)",elm_t->name);
+ free(buffname);
+ asprintf(&buffname,"dynar(%s)",elm_t->name);
res=gras_datadesc_ref(buffname,res);
free(buffname);
return res;
}
+#include "xbt/matrix.h"
+static void gras_datadesc_matrix_cb(gras_datadesc_type_t typedesc, gras_cbps_t vars, void *data) {
+ gras_datadesc_type_t subtype;
+ xbt_matrix_t matrix=(xbt_matrix_t)data;
+
+ memcpy(&matrix->free_f, &typedesc->extra, sizeof(matrix->free_f));
+
+ /* search for the elemsize in what we have. If elements are "int", typedesc got is "int[]*" */
+ subtype = gras_dd_find_field(typedesc,"data")->type;
+
+ /* this is now a ref to array of what we're looking for */
+ subtype = subtype->category.ref_data.type;
+ subtype = subtype->category.array_data.type;
+
+ DEBUG1("subtype is %s",subtype->name);
+
+ matrix->elmsize = subtype->size[GRAS_THISARCH];
+}
+gras_datadesc_type_t
+gras_datadesc_matrix(gras_datadesc_type_t elm_t,
+ void_f_pvoid_t * const free_f) {
+ char *buffname;
+ gras_datadesc_type_t res;
+
+ asprintf(&buffname,"s_xbt_matrix_t(%s)",elm_t->name);
+ res = gras_datadesc_struct(buffname);
+
+ gras_datadesc_struct_append(res, "lines",
+ gras_datadesc_by_name("unsigned int"));
+ gras_datadesc_struct_append(res, "rows",
+ gras_datadesc_by_name("unsigned int"));
+
+ gras_datadesc_struct_append(res, "elmsize",
+ gras_datadesc_by_name("unsigned long int"));
+
+ gras_datadesc_struct_append(res, "data",
+ gras_datadesc_ref_pop_arr (elm_t));
+ gras_datadesc_struct_append(res, "free_f",
+ gras_datadesc_by_name("function pointer"));
+ gras_datadesc_struct_close(res);
+
+ gras_datadesc_cb_field_push(res, "lines");
+ gras_datadesc_cb_field_push_multiplier(res, "rows");
+
+ gras_datadesc_cb_recv(res, &gras_datadesc_dynar_cb);
+ memcpy(res->extra,&free_f,sizeof(free_f));
+
+ /* build a ref to it */
+ free(buffname);
+ asprintf(&buffname,"xbt_matrix_t(%s)",elm_t->name);
+ res=gras_datadesc_ref(buffname,res);
+ free(buffname);
+ return res;
+}
gras_datadesc_type_t
gras_datadesc_import_nws(const char *name,