X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e5027d10e013486f32881c05c8c90463b1549250..60f31f9d24bd348ccad2ea99ba96424360b11a92:/src/gras/DataDesc/datadesc_private.h diff --git a/src/gras/DataDesc/datadesc_private.h b/src/gras/DataDesc/datadesc_private.h index d6922a6fdc..e3f3f8d325 100644 --- a/src/gras/DataDesc/datadesc_private.h +++ b/src/gras/DataDesc/datadesc_private.h @@ -1,6 +1,8 @@ /* $Id$ */ -/* datadesc_private - declarations visible only from within datadesc */ +/* datadesc - describing the data to exchange */ + +/* module's private interface masked even to other parts of GRAS. */ /* Authors: Olivier Aumage, Martin Quinson */ /* Copyright (C) 2003, 2004 the GRAS posse. */ @@ -14,9 +16,48 @@ #include "gras_private.h" #include "DataDesc/datadesc_interface.h" +/** + * aligned: + * + * Align the data v on the boundary a. + */ #define aligned(v, a) (((v) + (a - 1)) & ~(a - 1)) extern gras_set_t *gras_datadesc_set_local; +void gras_ddt_freev(void *ddt); +/******************************************* + * Descriptions of all known architectures * + *******************************************/ + +#define gras_arch_count 4 +typedef enum { + gras_ddt_scalar_char = 0, + gras_ddt_scalar_short = 1, + gras_ddt_scalar_int = 2, + gras_ddt_scalar_long = 3, + gras_ddt_scalar_long_long = 4, + + gras_ddt_scalar_pdata = 5, + gras_ddt_scalar_pfunc = 6, + + gras_ddt_scalar_float = 7, + gras_ddt_scalar_double = 8 +} gras_ddt_scalar_type_t; + +typedef struct { + const char *name; + + int endian; + + int sizeof_scalars[9]; /* char,short,int,long,long_long, + pdata,pfunc, + float,double */ + + int struct_boundary; +} gras_arch_desc_t; + +extern const gras_arch_desc_t gras_arches[gras_arch_count]; +extern const char *gras_datadesc_cat_names[9]; /**********************************************************/ /* Actual definitions of the stuff in the type descriptor */ @@ -25,22 +66,24 @@ extern gras_set_t *gras_datadesc_set_local; /** * e_gras_datadesc_type_category: * - * Defines all possible type categories + * Defines all possible type categories. */ typedef enum e_gras_datadesc_type_category { - e_gras_datadesc_type_cat_undefined = 0, - - e_gras_datadesc_type_cat_scalar, - e_gras_datadesc_type_cat_struct, - e_gras_datadesc_type_cat_union, - e_gras_datadesc_type_cat_ref, /* ref to an uniq element */ - e_gras_datadesc_type_cat_array, - e_gras_datadesc_type_cat_ignored, + + /* if you edit this, also fix gras_datadesc_cat_names in ddt_exchange.c */ - e_gras_datadesc_type_cat_invalid + e_gras_datadesc_type_cat_undefined = 0, + + e_gras_datadesc_type_cat_scalar = 1, + e_gras_datadesc_type_cat_struct = 2, + e_gras_datadesc_type_cat_union = 3, + e_gras_datadesc_type_cat_ref = 4, /* ref to an uniq element */ + e_gras_datadesc_type_cat_array = 5, + e_gras_datadesc_type_cat_ignored = 6, + + e_gras_datadesc_type_cat_invalid = 7 } gras_datadesc_type_category_t; - /*------------------------------------------------*/ /* definitions of specific data for each category */ /*------------------------------------------------*/ @@ -51,14 +94,15 @@ typedef enum e_gras_datadesc_type_category { */ typedef struct s_gras_dd_cat_field { - char *name; - long int offset; /* only for struct */ - int code; + char *name; + long int offset[gras_arch_count]; + gras_datadesc_type_t *type; gras_datadesc_type_cb_void_t pre; gras_datadesc_type_cb_void_t post; } gras_dd_cat_field_t; + void gras_dd_cat_field_free(void *f); /** @@ -77,6 +121,7 @@ enum e_gras_dd_scalar_encoding { }; typedef struct s_gras_dd_cat_scalar { enum e_gras_dd_scalar_encoding encoding; + gras_ddt_scalar_type_t type; /* to check easily that redefinition matches*/ } gras_dd_cat_scalar_t; /** @@ -85,7 +130,8 @@ typedef struct s_gras_dd_cat_scalar { * Specific fields of a struct */ typedef struct s_gras_dd_cat_struct { - gras_dynar_t *fields; /* elm type = gras_dd_cat_struct_field_t */ + gras_dynar_t *fields; /* elm type = gras_dd_cat_field_t */ + int closed; /* gras_datadesc_declare_struct_close() was called */ } gras_dd_cat_struct_t; /** @@ -94,8 +140,9 @@ typedef struct s_gras_dd_cat_struct { * Specific fields of a union */ typedef struct s_gras_dd_cat_union { - gras_datadesc_type_cb_int_t field_count; - gras_dynar_t *fields; /* elm type = gras_dd_cat_union_field_t */ + gras_datadesc_type_cb_int_t selector; + gras_dynar_t *fields; /* elm type = gras_dd_cat_field_t */ + int closed; /* gras_datadesc_declare_union_close() was called */ } gras_dd_cat_union_t; /** @@ -104,10 +151,10 @@ typedef struct s_gras_dd_cat_union { * Specific fields of a reference */ typedef struct s_gras_dd_cat_ref { - int code; + gras_datadesc_type_t *type; /* callback used to return the referenced type number */ - gras_datadesc_type_cb_int_t discriminant; + gras_datadesc_selector_t selector; } gras_dd_cat_ref_t; @@ -117,13 +164,14 @@ typedef struct s_gras_dd_cat_ref { * Specific fields of an array */ typedef struct s_gras_dd_cat_array { - int code; + gras_datadesc_type_t *type; /* element_count < 0 means dynamically defined */ long int fixed_size; /* callback used to return the dynamic length */ gras_datadesc_type_cb_int_t dynamic_size; + } gras_dd_cat_array_t; /** @@ -168,71 +216,44 @@ struct s_gras_datadesc_type { unsigned int name_len; /* payload */ - long int size; + long int size[gras_arch_count]; - long int alignment; - long int aligned_size; + long int alignment[gras_arch_count]; + long int aligned_size[gras_arch_count]; enum e_gras_datadesc_type_category category_code; union u_gras_datadesc_category category; - gras_datadesc_type_cb_void_t pre; - gras_datadesc_type_cb_void_t post; + gras_datadesc_type_cb_void_t send; + gras_datadesc_type_cb_void_t recv; }; /*************************** - * Type creation functions * + * constructor/desctructor * ***************************/ +void gras_datadesc_free(gras_datadesc_type_t *type); + gras_error_t -gras_ddt_new_scalar(const char *name, - long int size, - enum e_gras_dd_scalar_encoding encoding, - gras_datadesc_type_cb_void_t cb, - gras_datadesc_type_t **dst); -gras_error_t -gras_ddt_new_struct(const char *name, - gras_datadesc_type_cb_void_t pre, - gras_datadesc_type_cb_void_t post, - gras_datadesc_type_t **dst); -gras_error_t -gras_ddt_new_struct_append(gras_datadesc_type_t *struct_type, - const char *name, - gras_datadesc_type_t *field_type, - gras_datadesc_type_cb_void_t pre, - gras_datadesc_type_cb_void_t post); -gras_error_t -gras_ddt_new_union(const char *name, - gras_datadesc_type_cb_int_t field_count, - gras_datadesc_type_cb_void_t post, - gras_datadesc_type_t **dst); -gras_error_t -gras_ddt_new_union_append(gras_datadesc_type_t *union_type, - const char *name, - gras_datadesc_type_t *field_type, - gras_datadesc_type_cb_void_t pre, - gras_datadesc_type_cb_void_t post); -gras_error_t -gras_ddt_new_ref(const char *name, - gras_datadesc_type_t *referenced_type, - gras_datadesc_type_cb_int_t discriminant, - gras_datadesc_type_cb_void_t post, - gras_datadesc_type_t **dst); -gras_error_t -gras_ddt_new_array(const char *name, - gras_datadesc_type_t *element_type, - long int fixed_size, - gras_datadesc_type_cb_int_t dynamic_size, - gras_datadesc_type_cb_void_t post, - gras_datadesc_type_t **dst); -gras_error_t -gras_ddt_new_ignored(const char *name, - void *default_value, - void_f_pvoid_t *free_func, - long int size, - long int alignment, - gras_datadesc_type_cb_void_t post, +gras_datadesc_scalar(const char *name, + gras_ddt_scalar_type_t type, + enum e_gras_dd_scalar_encoding encoding, gras_datadesc_type_t **dst); - +/**************************************************** + * Callback persistant state constructor/destructor * + ****************************************************/ +gras_error_t +gras_cbps_new(gras_cbps_t **dst); +void +gras_cbps_free(gras_cbps_t **state); + +/*************** + * Convertions * + ***************/ +gras_error_t +gras_dd_convert_elm(gras_datadesc_type_t *type, int count, + int r_arch, + void *src, void *dst); #endif /* GRAS_DATADESC_PRIVATE_H */ +