#define np2 ((struct nnode *)p2)
structident(p1, np2);
t2 = np2->nn_type;
- if (t2==INT && np2->nn_nmlist->nl_flag&FFIELD)
+ if (t2==INT && np2->nn_nmlist->/*nl_flag&FFIELD*/nl_dtype->t_id==BITFLD)
t2 = UNSIGN;
t = incref0(t2);
chkw(p1, -1);
*cp++ = (struct node *)block(PLUS, t, np2->nn_subsp, np2->nn_strp,
p1, (struct node *)cblock(np2->nn_nmlist->nl_offset));
build(STAR);
- if (np2->nn_nmlist->nl_flag&FFIELD)
+ if (np2->nn_nmlist->/*nl_flag&FFIELD*/nl_dtype->t_id==BITFLD)
#if 1
cp[-1] = (struct node *)block(FSEL, UNSIGN, (int *)NULL, (union str *)NULL,
- cp[-1], (struct node *)np2->nn_nmlist->nl_strp);
+ cp[-1], (struct node *)/*np2->nn_nmlist->nl_strp*/&((struct btype *)np2->nn_nmlist->nl_dtype)->bt_F);
#else
*cp++ = (struct node *)block(FSEL, UNSIGN, (int *)NULL, (union str *)NULL,
- *--cp, (struct node *)np2->nn_nmlist->nl_strp);
+ *--cp, (struct node *)/*np2->nn_nmlist->nl_strp*/&((struct btype *)np2->nn_nmlist->nl_dtype)->bt_F);
#endif
return;
#undef np2
np = nporig = p2->nn_nmlist;
for (;;) {
if (namesame && p1->n_type==STRUCT+PTR && p1->n_strp == np->nl_sparent) {
+ /*fprintf(stderr, "found %p type %x strp %p\n", np, np->nl_type, np->nl_strp);*/
p2->nn_type = np->nl_type;
p2->nn_strp = np->nl_strp;
p2->nn_subsp = np->nl_subsp;
/* ssym->nl_strp = (union str *)Dblock(sizeof(struct SS));*/
stype = (struct stype *)Dblock(sizeof(struct stype));
stype->st_id = STRUCT;
- ssym->nl_strp = (union str *)&stype->st_S;
- ssym->nl_dtype = (struct type *)stype;
/*ssym->nl_strp->S.ssize*/stype->st_ssize = 0;
/*ssym->nl_strp->S.memlist*/stype->st_memlist = NULL;
+ ssym->nl_strp = (union str *)&stype->st_S;
+ ssym->nl_dtype = (struct type *)stype;
}
/* strp = ssym->nl_strp;*/
else
}
elsize = 0;
if (skw==MOS) {
+ /*fprintf(stderr, "mos %p name %s\n", dsym, dsym->nl_name);*/
elsize = length(/*(struct node *)dsym*/dtype);
if ((peeksym = symbol())==COLON) {
elsize = 0;
peeksym = -1;
t1 = conexp();
a = align(/*type*/dtype, offset, t1);
- if (dsym->nl_flag&FFIELD) {
- if (dsym->nl_strp->F.bitoffs!=bitoffs
- || dsym->nl_strp->F.flen!=t1)
+ /*fprintf(stderr, "a bitfield strp %p\n", dsym->nl_strp);*/
+ if (/*dsym->nl_flag&FFIELD*/dtype->t_id == BITFLD) {
+#define bdtype ((struct btype *)dtype)
+ if (/*dsym->nl_strp->F.bitoffs*/bdtype->bt_bitoffs!=bitoffs
+ || /*dsym->nl_strp->F.flen*/bdtype->bt_flen!=t1)
redec();
+#undef bdtype
} else {
- dsym->nl_strp = (union str *)Dblock(sizeof(struct FS));
+ /* dsym->nl_strp = (union str *)Dblock(sizeof(struct FS));*/
+#define bdtype (*(struct btype **)&dtype)
+ bdtype = (struct btype *)Dblock(sizeof(struct btype));
+ bdtype->bt_id = BITFLD;
+ bdtype->bt_flen = t1;
+ bdtype->bt_bitoffs = bitoffs;
+ dsym->nl_strp = (union str *)&bdtype->bt_F;
+ dsym->nl_dtype = (struct type *)bdtype;
+#undef bdtype
}
- dsym->nl_flag |= FFIELD;
+ /*fprintf(stderr, "b bitfield strp %p\n", dsym->nl_strp);*/
+ /* dsym->nl_flag |= FFIELD;
dsym->nl_strp->F.bitoffs = bitoffs;
- dsym->nl_strp->F.flen = t1;
+ dsym->nl_strp->F.flen = t1;*/
bitoffs += t1;
} else
a = align(/*type*/dtype, offset, 0);
* Enforce alignment restrictions in structures,
* including bit-field considerations.
*/
+/* really means make sure aflen bits can be allocated after current position */
+/* takes size in bytes and the global bitoffs, returns size increase in bytes */
int align(type, offset, aflen) /*int*/struct type *type; int offset; int aflen; {
register int a, /*t,*/ flen;
register struct type *t;
* UNLONG 9
* VOID 10
* REF 11 (used with PTR, FUNC or ARRAY)
+ * BITFLD 12 (means it's a struct btype)
* PTR 020 (means it's a struct rtype)
* FUNC 040 (means it's a struct ftype)
* ARRAY 060 (means it's a struct atype)
struct stype {
struct type st_type;
#define st_id st_type.t_id
- struct SS st_S;
+ struct SS st_S; /* structure specification */
#define st_ssize st_S.ssize
#define st_memlist st_S.memlist
};
+struct btype {
+ struct type bt_type;
+#define bt_id bt_type.t_id
+ struct FS bt_F; /* bitfield specification */
+#define bt_flen bt_F.flen
+#define bt_bitoffs bt_F.bitoffs
+};
struct rtype {
struct type rt_type;
#define rt_id rt_type.t_id
#define UNLONG 9
#define VOID 10
#define REF 11
+#define BITFLD 12
#define ALIGN 01 /* pass 0 only */
#define TYPE 017