scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 6e1c06a139de53efc75a40734b0feaba60071f16
parent aedd026dfd916a0f93e13530af0d7dbaef791247
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 12 Mar 2015 19:14:41 +0000

Increment plan9 portability

This patch removes some initialization of bitfields, substitute
a stdint by a inttypes and fix some problems with the makefile

Diffstat:
Mcc1/stmt.c | 2+-
Mcc2/Makefile | 2+-
Mcc2/cc2.h | 6++++--
Mcc2/generror | 2+-
Mcc2/optm.c | 2+-
Mcc2/parser.c | 23+++++++++++------------
6 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/cc1/stmt.c b/cc1/stmt.c @@ -1,6 +1,6 @@ #include <stddef.h> -#include <stdint.h> +#include <inttypes.h> #include <stdio.h> #include "../inc/cc.h" diff --git a/cc2/Makefile b/cc2/Makefile @@ -9,7 +9,7 @@ $(OBJS): ../inc/cc.h ../inc/sizes.h cc2.h main.o: error.h error.h: cc2.h - ./generror cc2.h > $@ + awk -f generror cc2.h > $@ cc2: $(OBJS) ../lib/libcc.a $(CC) -L../lib $(LDFLAGS) $(OBJS) $(LIBS) -o $@ diff --git a/cc2/cc2.h b/cc2/cc2.h @@ -1,4 +1,7 @@ +#define SIGNF 1 +#define INTF 2 + typedef struct symbol Symbol; typedef struct node Node; @@ -6,8 +9,7 @@ typedef struct { short size; uint8_t align; char letter; - bool sign : 1; - bool c_int : 1; + uint8_t flags; } Type; struct symbol { diff --git a/cc2/generror b/cc2/generror @@ -1,4 +1,4 @@ -#!/usr/bin/awk -f +#!/usr/bin/env awk -f BEGIN { print "char *errlist[] = {" diff --git a/cc2/optm.c b/cc2/optm.c @@ -18,7 +18,7 @@ repeat: switch (np->op) { case OCAST: /* TODO: be careful with the sign */ - if (np->type.c_int && np->type.size >= tp->size) { + if (np->type.flags & INTF && np->type.size >= tp->size) { np = np->left; goto repeat; } diff --git a/cc2/parser.c b/cc2/parser.c @@ -33,60 +33,59 @@ Type l_int8 = { .letter = L_INT8, .size = 1, .align = 2, - .sign = 1, - .c_int = 1, + .flags = SIGNF | INTF }; Type l_int16 = { .letter = L_INT16, .size = 2, .align = 2, - .sign = 1, - .c_int = 1, + .flags = SIGNF | INTF + }; Type l_int32 = { .letter = L_INT32, .size = 4, .align = 4, - .sign = 1, - .c_int = 1, + .flags = SIGNF | INTF + }; Type l_int64 = { .letter = L_INT64, .size = 8, .align = 8, - .sign = 1, - .c_int = 1, + .flags = SIGNF | INTF + }; Type l_uint8 = { .letter = L_UINT8, .size = 1, .align = 2, - .c_int = 1, + .flags = INTF }; Type l_uint16 = { .letter = L_UINT16, .size = 2, .align = 2, - .c_int = 1, + .flags = INTF }; Type l_uint32 = { .letter = L_UINT32, .size = 4, .align = 4, - .c_int = 1, + .flags = INTF }; Type l_uint64 = { .letter = L_UINT64, .size = 8, .align = 8, - .c_int = 1, + .flags = INTF };