]> oss.titaniummirror.com Git - nesc.git/blobdiff - src/nesc-network.c
Pristine nesc-1.3.2
[nesc.git] / src / nesc-network.c
index 0ecf2e781a656598c1b2716f98034f7a137aaa11..4bec0b507c0259a1469c5f4153939da968634b76 100644 (file)
@@ -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)