summaryrefslogtreecommitdiff
path: root/usr.bin/pcc/ccom/pftn.c
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2007-10-07 18:34:42 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2007-10-07 18:34:42 +0000
commit7a319b2ba0bc99a92dfe02a224db2c9c67626fda (patch)
tree336bf97a4986400b2440c59057dc42c57fff74dc /usr.bin/pcc/ccom/pftn.c
parent992ae3f64965e9753eec4344ef0f844a47b49626 (diff)
Merge from ragge's repo:
Add initial support for packed/aligned/rename pragmas. Still missing: Support for architectures with strict alignment. TODO: Cleanup the rename stuff so that it's not depending on gcc compat.
Diffstat (limited to 'usr.bin/pcc/ccom/pftn.c')
-rw-r--r--usr.bin/pcc/ccom/pftn.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/usr.bin/pcc/ccom/pftn.c b/usr.bin/pcc/ccom/pftn.c
index c8f4dd49e2e..9d2ddef2a2c 100644
--- a/usr.bin/pcc/ccom/pftn.c
+++ b/usr.bin/pcc/ccom/pftn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pftn.c,v 1.1 2007/10/07 17:58:51 otto Exp $ */
+/* $OpenBSD: pftn.c,v 1.2 2007/10/07 18:34:41 otto Exp $ */
/*
* Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
@@ -69,6 +69,8 @@
#include <string.h> /* XXX - for strcmp */
+#include "cgram.h"
+
struct symtab *spname;
struct symtab *cftnsp;
static int strunem; /* currently parsed member type */
@@ -761,13 +763,13 @@ bstruct(char *name, int soru)
* Called after a struct is declared to restore the environment.
*/
NODE *
-dclstruct(struct rstack *r)
+dclstruct(struct rstack *r, int pa)
{
NODE *n;
struct params *l, *m;
struct suedef *sue;
struct symtab *p;
- int al, sa, sz;
+ int al, sa, sz, coff;
TWORD temp;
int i, high, low;
@@ -800,6 +802,10 @@ dclstruct(struct rstack *r)
i++;
sue->suelem = permalloc(sizeof(struct symtab *) * i);
+ coff = 0;
+ if (pa == PRAG_PACKED || pa == PRAG_ALIGNED)
+ strucoff = 0; /* must recount it */
+
for (i = 0; l != NULL; l = l->next) {
sue->suelem[i++] = p = l->sym;
@@ -814,11 +820,20 @@ dclstruct(struct rstack *r)
continue;
}
sa = talign(p->stype, p->ssue);
- if (p->sclass & FIELD) {
+ if (p->sclass & FIELD)
sz = p->sclass&FLDSIZ;
- } else {
+ else
sz = tsize(p->stype, p->sdf, p->ssue);
+
+ if (pa == PRAG_PACKED || pa == PRAG_ALIGNED) {
+ p->soffset = coff;
+ if (pa == PRAG_ALIGNED)
+ coff += ALLDOUBLE;
+ else
+ coff += sz;
+ strucoff = coff;
}
+
if (sz > strucoff)
strucoff = sz; /* for use with unions */
/*