A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
This avoid a warning on the Microsoft compiler
[simgrid.git]
/
src
/
gras
/
DataDesc
/
ddt_exchange.c
diff --git
a/src/gras/DataDesc/ddt_exchange.c
b/src/gras/DataDesc/ddt_exchange.c
index
019aa5f
..
d020c77
100644
(file)
--- a/
src/gras/DataDesc/ddt_exchange.c
+++ b/
src/gras/DataDesc/ddt_exchange.c
@@
-20,42
+20,42
@@
const char *gras_datadesc_cat_names[9] = {
"scalar", "struct", "union", "ref", "array", "ignored",
"invalid"};
"scalar", "struct", "union", "ref", "array", "ignored",
"invalid"};
-static gras_datadesc_type_t int_type = NULL;
+static gras_datadesc_type_t
u
int_type = NULL;
static gras_datadesc_type_t pointer_type = NULL;
static gras_datadesc_type_t pointer_type = NULL;
-static
_
XBT_INLINE void
-gras_dd_send_
int(gras_socket_t sock,
int *i, int stable) {
+static XBT_INLINE void
+gras_dd_send_
uint(gras_socket_t sock,unsigned
int *i, int stable) {
- if (!int_type) {
-
int_type = gras_datadesc_by_name("
int");
-
xbt_assert(
int_type);
+ if (!
u
int_type) {
+
uint_type = gras_datadesc_by_name("unsigned
int");
+
xbt_assert(u
int_type);
}
}
- DEBUG1("send_
int(%d
)",*i);
- gras_trp_send(sock, (char*)i, int_type->size[GRAS_THISARCH], stable);
+ DEBUG1("send_
uint(%u
)",*i);
+ gras_trp_send(sock, (char*)i,
u
int_type->size[GRAS_THISARCH], stable);
}
}
-static
_
XBT_INLINE void
-gras_dd_recv_
int(gras_socket_t sock, int r_arch,
int *i) {
+static XBT_INLINE void
+gras_dd_recv_
uint(gras_socket_t sock, int r_arch, unsigned
int *i) {
- if (!int_type) {
-
int_type = gras_datadesc_by_name("
int");
- xbt_assert(int_type);
+ if (!
u
int_type) {
+
uint_type = gras_datadesc_by_name("unsigned
int");
+ xbt_assert(
u
int_type);
}
}
- if (
int_type->size[GRAS_THISARCH] >=
int_type->size[r_arch]) {
- gras_trp_recv(sock, (char*)i, int_type->size[r_arch]);
+ if (
uint_type->size[GRAS_THISARCH] >= u
int_type->size[r_arch]) {
+ gras_trp_recv(sock, (char*)i,
u
int_type->size[r_arch]);
if (r_arch != GRAS_THISARCH)
if (r_arch != GRAS_THISARCH)
- gras_dd_convert_elm(int_type,1,r_arch, i,i);
+ gras_dd_convert_elm(
u
int_type,1,r_arch, i,i);
} else {
} else {
- void *ptr = xbt_malloc(int_type->size[r_arch]);
+ void *ptr = xbt_malloc(
u
int_type->size[r_arch]);
- gras_trp_recv(sock, (char*)ptr, int_type->size[r_arch]);
+ gras_trp_recv(sock, (char*)ptr,
u
int_type->size[r_arch]);
if (r_arch != GRAS_THISARCH)
if (r_arch != GRAS_THISARCH)
- gras_dd_convert_elm(int_type,1,r_arch, ptr,i);
+ gras_dd_convert_elm(
u
int_type,1,r_arch, ptr,i);
free(ptr);
}
free(ptr);
}
- DEBUG1("recv_
int(%d
)",*i);
+ DEBUG1("recv_
uint(%u
)",*i);
}
/*
}
/*
@@
-63,7
+63,7
@@
gras_dd_recv_int(gras_socket_t sock, int r_arch, int *i) {
* of 'length' bytes set to 0.
* FIXME: Check in configure?
*/
* of 'length' bytes set to 0.
* FIXME: Check in configure?
*/
-static
_
XBT_INLINE int
+static XBT_INLINE int
gras_dd_is_r_null(char **r_ptr, long int length) {
int i;
gras_dd_is_r_null(char **r_ptr, long int length) {
int i;
@@
-76,7
+76,7
@@
gras_dd_is_r_null(char **r_ptr, long int length) {
return 1;
}
return 1;
}
-static
_
XBT_INLINE void
+static XBT_INLINE void
gras_dd_alloc_ref(xbt_dict_t refs,
long int size,
char **r_ref,
gras_dd_alloc_ref(xbt_dict_t refs,
long int size,
char **r_ref,
@@
-95,18
+95,17
@@
gras_dd_alloc_ref(xbt_dict_t refs,
if (detect_cycle && r_ref && !gras_dd_is_r_null( r_ref, r_len)) {
void *ptr = xbt_malloc(sizeof(void *));
if (detect_cycle && r_ref && !gras_dd_is_r_null( r_ref, r_len)) {
void *ptr = xbt_malloc(sizeof(void *));
- CRITICAL0("Check for cycles");
memcpy(ptr,l_ref, sizeof(void *));
DEBUG2("Insert l_ref=%p under r_ref=%p",*(void**)ptr, *(void**)r_ref);
memcpy(ptr,l_ref, sizeof(void *));
DEBUG2("Insert l_ref=%p under r_ref=%p",*(void**)ptr, *(void**)r_ref);
-
+
if (detect_cycle)
if (detect_cycle)
- xbt_dict_set_ext(refs,(const char *) r_ref, r_len, ptr,
free
);
+ xbt_dict_set_ext(refs,(const char *) r_ref, r_len, ptr,
xbt_free_f
);
}
}
static int
}
}
static int
-gras_datadesc_
co
py_rec(gras_cbps_t state,
+gras_datadesc_
memc
py_rec(gras_cbps_t state,
xbt_dict_t refs,
gras_datadesc_type_t type,
char *src,
xbt_dict_t refs,
gras_datadesc_type_t type,
char *src,
@@
-116,7
+115,7
@@
gras_datadesc_copy_rec(gras_cbps_t state,
xbt_ex_t e;
xbt_ex_t e;
-
int
cpt;
+
unsigned int
cpt;
gras_datadesc_type_t sub_type; /* type on which we recurse */
int count = 0;
gras_datadesc_type_t sub_type; /* type on which we recurse */
int count = 0;
@@
-155,7
+154,7
@@
gras_datadesc_copy_rec(gras_cbps_t state,
field->send(type,state,field_src);
DEBUG1("Copy field %s",field->name);
field->send(type,state,field_src);
DEBUG1("Copy field %s",field->name);
- count += gras_datadesc_
co
py_rec(state,refs,sub_type, field_src, field_dst, 0,
+ count += gras_datadesc_
memc
py_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)) {
detect_cycle || sub_type->cycle);
if (XBT_LOG_ISENABLED(gras_ddt_exchange,xbt_log_priority_verbose)) {
@@
-185,7
+184,7
@@
gras_datadesc_copy_rec(gras_cbps_t state,
case e_gras_datadesc_type_cat_union: {
gras_dd_cat_union_t union_data;
gras_dd_cat_field_t field=NULL;
case e_gras_datadesc_type_cat_union: {
gras_dd_cat_union_t union_data;
gras_dd_cat_field_t field=NULL;
-
int
field_num;
+
unsigned int
field_num;
union_data = type->category.union_data;
union_data = type->category.union_data;
@@
-210,7
+209,7
@@
gras_datadesc_copy_rec(gras_cbps_t state,
if (field->send)
field->send(type,state,src);
if (field->send)
field->send(type,state,src);
- count += gras_datadesc_
co
py_rec(state,refs, sub_type, src, dst,0,
+ count += gras_datadesc_
memc
py_rec(state,refs, sub_type, src, dst,0,
detect_cycle || sub_type->cycle);
break;
detect_cycle || sub_type->cycle);
break;
@@
-240,11
+239,12
@@
gras_datadesc_copy_rec(gras_cbps_t state,
reference_is_to_cpy = 0;
TRY {
reference_is_to_cpy = 0;
TRY {
- if (detect_cycle)
+ if (detect_cycle)
{
/* return ignored. Just checking whether it's known or not */
n_ref=xbt_dict_get_ext(refs,(char*)o_ref, sizeof(char*));
/* return ignored. Just checking whether it's known or not */
n_ref=xbt_dict_get_ext(refs,(char*)o_ref, sizeof(char*));
- else
+ } else {
reference_is_to_cpy = 1;
reference_is_to_cpy = 1;
+ }
} CATCH(e) {
if (e.category != not_found_error)
RETHROW;
} CATCH(e) {
if (e.category != not_found_error)
RETHROW;
@@
-285,7
+285,7
@@
gras_datadesc_copy_rec(gras_cbps_t state,
detect_cycle);
}
detect_cycle);
}
- count += gras_datadesc_
co
py_rec(state,refs, sub_type,
+ count += gras_datadesc_
memc
py_rec(state,refs, sub_type,
*o_ref,(char*)l_referenced, subsubcount,
detect_cycle || sub_type->cycle);
*o_ref,(char*)l_referenced, subsubcount,
detect_cycle || sub_type->cycle);
@@
-342,9
+342,9
@@
gras_datadesc_copy_rec(gras_cbps_t state,
} else {
VERB1("Array of %ld stuff, copy it in one after the other",array_count);
} else {
VERB1("Array of %ld stuff, copy it in one after the other",array_count);
- for (cpt=0; cpt<array_count; cpt++) {
+ for (cpt=0; cpt<
(unsigned int)
array_count; cpt++) {
VERB2("Copy the %dth stuff out of %ld",cpt,array_count);
VERB2("Copy the %dth stuff out of %ld",cpt,array_count);
- count += gras_datadesc_
co
py_rec(state,refs, sub_type, src_ptr, dst_ptr, 0,
+ count += gras_datadesc_
memc
py_rec(state,refs, sub_type, src_ptr, dst_ptr, 0,
detect_cycle || sub_type->cycle);
src_ptr += elm_size;
dst_ptr += elm_size;
detect_cycle || sub_type->cycle);
src_ptr += elm_size;
dst_ptr += elm_size;
@@
-360,30
+360,32
@@
gras_datadesc_copy_rec(gras_cbps_t state,
return count;
}
/**
return count;
}
/**
- * gras_datadesc_
co
py:
+ * gras_datadesc_
memc
py:
*
* Copy the data pointed by src and described by type
* to a new location, and store a pointer to it in dst.
*
*/
*
* 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_
co
py(gras_datadesc_type_t type,
+int gras_datadesc_
memc
py(gras_datadesc_type_t type,
void *src, void *dst) {
xbt_ex_t e;
void *src, void *dst) {
xbt_ex_t e;
-
gras_cbps_t state
;
-
xbt_dict_t refs
; /* all references already sent */
+
static gras_cbps_t state=NULL
;
+
static xbt_dict_t refs=NULL
; /* all references already sent */
int size=0;
xbt_assert0(type,"called with NULL type descriptor");
int size=0;
xbt_assert0(type,"called with NULL type descriptor");
- refs = xbt_dict_new();
- state = gras_cbps_new();
+ if (!state) {
+ state = gras_cbps_new();
+ refs = xbt_dict_new();
+ }
TRY {
TRY {
- size = gras_datadesc_
co
py_rec(state,refs,type,(char*)src,(char*)dst,0,
- type->cycle);
+ size = gras_datadesc_
memc
py_rec(state,refs,type,(char*)src,(char*)dst,0,
+
type->cycle);
} CLEANUP {
} CLEANUP {
- xbt_dict_
free(&
refs);
- gras_cbps_
free(&
state);
+ xbt_dict_
reset(
refs);
+ gras_cbps_
reset(
state);
} CATCH(e) {
RETHROW;
}
} CATCH(e) {
RETHROW;
}
@@
-403,7
+405,7
@@
gras_datadesc_send_rec(gras_socket_t sock,
int detect_cycle) {
xbt_ex_t e;
int detect_cycle) {
xbt_ex_t e;
-
int
cpt;
+
unsigned int
cpt;
gras_datadesc_type_t sub_type; /* type on which we recurse */
VERB2("Send a %s (%s)",
gras_datadesc_type_t sub_type; /* type on which we recurse */
VERB2("Send a %s (%s)",
@@
-456,7
+458,7
@@
gras_datadesc_send_rec(gras_socket_t sock,
case e_gras_datadesc_type_cat_union: {
gras_dd_cat_union_t union_data;
gras_dd_cat_field_t field=NULL;
case e_gras_datadesc_type_cat_union: {
gras_dd_cat_union_t union_data;
gras_dd_cat_field_t field=NULL;
-
int
field_num;
+
unsigned int
field_num;
union_data = type->category.union_data;
union_data = type->category.union_data;
@@
-475,7
+477,7
@@
gras_datadesc_send_rec(gras_socket_t sock,
type->name, field_num, xbt_dynar_length(union_data.fields));
/* Send the field number */
type->name, field_num, xbt_dynar_length(union_data.fields));
/* Send the field number */
- gras_dd_send_int(sock, &field_num, 0 /* not stable */);
+ gras_dd_send_
u
int(sock, &field_num, 0 /* not stable */);
/* Send the content */
field = xbt_dynar_get_as(union_data.fields, field_num, gras_dd_cat_field_t);
/* Send the content */
field = xbt_dynar_get_as(union_data.fields, field_num, gras_dd_cat_field_t);
@@
-501,7
+503,7
@@
gras_datadesc_send_rec(gras_socket_t sock,
sub_type = ref_data.type;
if (sub_type == NULL) {
sub_type = (*ref_data.selector)(type,state,data);
sub_type = ref_data.type;
if (sub_type == NULL) {
sub_type = (*ref_data.selector)(type,state,data);
- gras_dd_send_
int(sock, (int*)
&(sub_type->code),1 /*stable*/);
+ gras_dd_send_
uint(sock,
&(sub_type->code),1 /*stable*/);
}
/* Send the actual value of the pointer for cycle handling */
}
/* Send the actual value of the pointer for cycle handling */
@@
-549,7
+551,7
@@
gras_datadesc_send_rec(gras_socket_t sock,
case e_gras_datadesc_type_cat_array: {
gras_dd_cat_array_t array_data;
case e_gras_datadesc_type_cat_array: {
gras_dd_cat_array_t array_data;
-
int
count;
+
unsigned int
count;
char *ptr=data;
long int elm_size;
char *ptr=data;
long int elm_size;
@@
-561,7
+563,7
@@
gras_datadesc_send_rec(gras_socket_t sock,
count = array_data.dynamic_size(type,state,data);
xbt_assert1(count >=0,
"Invalid (negative) array size for type %s",type->name);
count = array_data.dynamic_size(type,state,data);
xbt_assert1(count >=0,
"Invalid (negative) array size for type %s",type->name);
- gras_dd_send_int(sock, &count, 0/*non-stable*/);
+ gras_dd_send_
u
int(sock, &count, 0/*non-stable*/);
}
/* send the content */
}
/* send the content */
@@
-609,18
+611,19
@@
void gras_datadesc_send(gras_socket_t sock,
xbt_ex_t e;
static gras_cbps_t state=NULL;
xbt_ex_t e;
static gras_cbps_t state=NULL;
-
xbt_dict_t refs
; /* all references already sent */
+
static xbt_dict_t refs=NULL
; /* all references already sent */
xbt_assert0(type,"called with NULL type descriptor");
xbt_assert0(type,"called with NULL type descriptor");
- refs = xbt_dict_new();
- if (!state)
+ if (!state) {
state = gras_cbps_new();
state = gras_cbps_new();
-
+ refs = xbt_dict_new();
+ }
+
TRY {
gras_datadesc_send_rec(sock,state,refs,type,(char*)src, type->cycle);
} CLEANUP {
TRY {
gras_datadesc_send_rec(sock,state,refs,type,(char*)src, type->cycle);
} CLEANUP {
- xbt_dict_
free(&
refs);
+ xbt_dict_
reset(
refs);
gras_cbps_reset(state);
} CATCH(e) {
RETHROW;
gras_cbps_reset(state);
} CATCH(e) {
RETHROW;
@@
-651,7
+654,7
@@
gras_datadesc_recv_rec(gras_socket_t sock,
int subsize,
int detect_cycle) {
int subsize,
int detect_cycle) {
-
int
cpt;
+
unsigned int
cpt;
gras_datadesc_type_t sub_type;
xbt_ex_t e;
gras_datadesc_type_t sub_type;
xbt_ex_t e;
@@
-708,7
+711,7
@@
gras_datadesc_recv_rec(gras_socket_t sock,
case e_gras_datadesc_type_cat_union: {
gras_dd_cat_union_t union_data;
gras_dd_cat_field_t field=NULL;
case e_gras_datadesc_type_cat_union: {
gras_dd_cat_union_t union_data;
gras_dd_cat_field_t field=NULL;
-
int
field_num;
+
unsigned int
field_num;
union_data = type->category.union_data;
union_data = type->category.union_data;
@@
-716,7
+719,7
@@
gras_datadesc_recv_rec(gras_socket_t sock,
"Please call gras_datadesc_declare_union_close on %s before receiving it",
type->name);
/* retrieve the field number */
"Please call gras_datadesc_declare_union_close on %s before receiving it",
type->name);
/* retrieve the field number */
- gras_dd_recv_int(sock, r_arch, &field_num);
+ gras_dd_recv_
u
int(sock, r_arch, &field_num);
if (field_num < 0)
THROW1(mismatch_error,0,
"Received union field for %s is negative", type->name);
if (field_num < 0)
THROW1(mismatch_error,0,
"Received union field for %s is negative", type->name);
@@
-750,8
+753,8
@@
gras_datadesc_recv_rec(gras_socket_t sock,
/* Get the referenced type locally or from peer */
sub_type = ref_data.type;
if (sub_type == NULL) {
/* Get the referenced type locally or from peer */
sub_type = ref_data.type;
if (sub_type == NULL) {
- int ref_code;
- gras_dd_recv_int(sock, r_arch, &ref_code);
+
unsigned
int ref_code;
+ gras_dd_recv_
u
int(sock, r_arch, &ref_code);
sub_type = gras_datadesc_by_id(ref_code);
}
sub_type = gras_datadesc_by_id(ref_code);
}
@@
-777,18
+780,20
@@
gras_datadesc_recv_rec(gras_socket_t sock,
reference_is_to_recv = 0;
TRY {
reference_is_to_recv = 0;
TRY {
- if (detect_cycle)
+ if (detect_cycle)
{
l_ref = xbt_dict_get_ext(refs, (char*)r_ref, pointer_type->size[r_arch]);
l_ref = xbt_dict_get_ext(refs, (char*)r_ref, pointer_type->size[r_arch]);
- else
+ } else {
reference_is_to_recv = 1;
reference_is_to_recv = 1;
+ }
} CATCH(e) {
if (e.category != not_found_error)
RETHROW;
reference_is_to_recv = 1;
xbt_ex_free(e);
}
} CATCH(e) {
if (e.category != not_found_error)
RETHROW;
reference_is_to_recv = 1;
xbt_ex_free(e);
}
+
if (reference_is_to_recv) {
if (reference_is_to_recv) {
- int subsubcount = 0;
+
unsigned
int subsubcount = 0;
void *l_referenced=NULL;
VERB2("Receiving a ref to '%s', remotely @%p",
void *l_referenced=NULL;
VERB2("Receiving a ref to '%s', remotely @%p",
@@
-801,7
+806,7
@@
gras_datadesc_recv_rec(gras_socket_t sock,
subsubcount = array_data.fixed_size;
if (subsubcount == 0)
subsubcount = array_data.fixed_size;
if (subsubcount == 0)
- gras_dd_recv_int(sock, r_arch, &subsubcount);
+ gras_dd_recv_
u
int(sock, r_arch, &subsubcount);
subsub_type = array_data.type;
subsub_type = array_data.type;
@@
-840,7
+845,7
@@
gras_datadesc_recv_rec(gras_socket_t sock,
case e_gras_datadesc_type_cat_array: {
gras_dd_cat_array_t array_data;
case e_gras_datadesc_type_cat_array: {
gras_dd_cat_array_t array_data;
-
int
count;
+
unsigned int
count;
char *ptr;
long int elm_size;
char *ptr;
long int elm_size;
@@
-850,7
+855,7
@@
gras_datadesc_recv_rec(gras_socket_t sock,
if (count == 0)
count = subsize;
if (count == 0)
if (count == 0)
count = subsize;
if (count == 0)
- gras_dd_recv_int(sock, r_arch, &count);
+ gras_dd_recv_
u
int(sock, r_arch, &count);
if (count == 0)
THROW1(mismatch_error,0,
"Invalid (=0) array size for type %s",type->name);
if (count == 0)
THROW1(mismatch_error,0,
"Invalid (=0) array size for type %s",type->name);
@@
-944,12
+949,13
@@
gras_datadesc_recv(gras_socket_t sock,
xbt_ex_t e;
static gras_cbps_t state=NULL; /* callback persistent state */
xbt_ex_t e;
static gras_cbps_t state=NULL; /* callback persistent state */
-
xbt_dict_t refs
; /* all references already sent */
+
static xbt_dict_t refs=NULL
; /* all references already sent */
- refs = xbt_dict_new();
- if (!state)
+ if (!state) {
state = gras_cbps_new();
state = gras_cbps_new();
-
+ refs = xbt_dict_new();
+ }
+
xbt_assert0(type,"called with NULL type descriptor");
TRY {
gras_datadesc_recv_rec(sock, state, refs, type,
xbt_assert0(type,"called with NULL type descriptor");
TRY {
gras_datadesc_recv_rec(sock, state, refs, type,
@@
-957,7
+963,7
@@
gras_datadesc_recv(gras_socket_t sock,
(char *) dst,-1,
type->cycle);
} CLEANUP {
(char *) dst,-1,
type->cycle);
} CLEANUP {
- xbt_dict_
free(&
refs);
+ xbt_dict_
reset(
refs);
gras_cbps_reset(state);
} CATCH(e) {
RETHROW;
gras_cbps_reset(state);
} CATCH(e) {
RETHROW;