X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=nesc.git;a=blobdiff_plain;f=src%2Fnesc-network.c;h=4bec0b507c0259a1469c5f4153939da968634b76;hp=0ecf2e781a656598c1b2716f98034f7a137aaa11;hb=7b54393e237ed8f23c0c74f0a6cbc8de26c5bf98;hpb=57d4530c4d6814fa25338a00cc65b95938c723b6 diff --git a/src/nesc-network.c b/src/nesc-network.c index 0ecf2e7..4bec0b5 100644 --- a/src/nesc-network.c +++ b/src/nesc-network.c @@ -250,7 +250,7 @@ static bool prt_network_lvalue(expression e) else { prt_expression_helper(e, P_CALL); - output(".data"); + output(".nxdata"); } return isbf; @@ -410,7 +410,7 @@ bool prt_network_typedef(data_decl d, variable_decl vd) else { set_location(vd->location); - output("typedef struct { unsigned char data[%d]; } __attribute__((packed)) %s;", + output("typedef struct { unsigned char nxdata[%d]; } __attribute__((packed)) %s;", (int)type_size_int(basetype), vd->ddecl->name); } return TRUE; @@ -443,7 +443,7 @@ static bool prt_network_parameter_copy(declaration parm, bool copies, else { output_hton(ddecl->type); - outputln("(%s.data, %s%s);", ddecl->name, NXBASE_PREFIX, ddecl->name); + outputln("(%s.nxdata, %s%s);", ddecl->name, NXBASE_PREFIX, ddecl->name); } return TRUE; @@ -493,6 +493,7 @@ void prt_network_field_data_decl(data_decl d, struct network_state *ns) { declaration fd; psd_options opts = 0; + type_element interesting; scan_declaration (fd, d->decls) { @@ -521,8 +522,19 @@ void prt_network_field_data_decl(data_decl d, struct network_state *ns) outputln(";"); } } + /* If there's an unnamed struct/union field, we need to print it and + account for its size in ns */ if (!(opts & psd_duplicate)) - prt_interesting_elements(d->modifiers, opts); + scan_type_element (interesting, d->modifiers) + if (is_tag_ref(interesting)) + { + tag_ref tr = CAST(tag_ref, interesting); + + prt_type_element(interesting, opts); + outputln(";"); + if (cval_isinteger(tr->tdecl->size)) + ns->offset += cval_uint_value(tr->tdecl->size); + } } void prt_network_field_declaration(declaration d, struct network_state *ns)