ref: 6e1c06a139de53efc75a40734b0feaba60071f16
parent: aedd026dfd916a0f93e13530af0d7dbaef791247
author: Roberto E. Vargas Caballero <[email protected]>
date: Thu Mar 12 15:14:41 EDT 2015
Increment plan9 portability This patch removes some initialization of bitfields, substitute a stdint by a inttypes and fix some problems with the makefile
--- 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"
--- a/cc2/Makefile
+++ b/cc2/Makefile
@@ -9,7 +9,7 @@
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 $@
--- 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 @@
short size;
uint8_t align;
char letter;
- bool sign : 1;
- bool c_int : 1;
+ uint8_t flags;
} Type;
struct symbol {
--- a/cc2/generror
+++ b/cc2/generror
@@ -1,4 +1,4 @@
-#!/usr/bin/awk -f
+#!/usr/bin/env awk -f
BEGIN {
print "char *errlist[] = {"
--- a/cc2/optm.c
+++ b/cc2/optm.c
@@ -18,7 +18,7 @@
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;
}
--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -33,8 +33,7 @@
.letter = L_INT8,
.size = 1,
.align = 2,
- .sign = 1,
- .c_int = 1,
+ .flags = SIGNF | INTF
};
Type l_int16 = {
@@ -41,8 +40,8 @@
.letter = L_INT16,
.size = 2,
.align = 2,
- .sign = 1,
- .c_int = 1,
+ .flags = SIGNF | INTF
+
};
Type l_int32 = {
@@ -49,8 +48,8 @@
.letter = L_INT32,
.size = 4,
.align = 4,
- .sign = 1,
- .c_int = 1,
+ .flags = SIGNF | INTF
+
};
Type l_int64 = {
@@ -57,8 +56,8 @@
.letter = L_INT64,
.size = 8,
.align = 8,
- .sign = 1,
- .c_int = 1,
+ .flags = SIGNF | INTF
+
};
Type l_uint8 = {
@@ -65,7 +64,7 @@
.letter = L_UINT8,
.size = 1,
.align = 2,
- .c_int = 1,
+ .flags = INTF
};
Type l_uint16 = {
@@ -72,7 +71,7 @@
.letter = L_UINT16,
.size = 2,
.align = 2,
- .c_int = 1,
+ .flags = INTF
};
Type l_uint32 = {
@@ -79,7 +78,7 @@
.letter = L_UINT32,
.size = 4,
.align = 4,
- .c_int = 1,
+ .flags = INTF
};
Type l_uint64 = {
@@ -86,7 +85,7 @@
.letter = L_UINT64,
.size = 8,
.align = 8,
- .c_int = 1,
+ .flags = INTF
};