ref: 30cd5966d7653904c1c1c542f6085f204c148e32
parent: 60625231d3fe36f878c8286f23ab533de8edfed6
author: Quentin Rameau <quinq@fifth.space>
date: Sat Dec 10 07:56:39 EST 2016
Replace sizes.h with cstd.h And get rid of the file copy of the header, use include path instead.
--- a/Makefile
+++ b/Makefile
@@ -60,4 +60,3 @@
distclean: clean
rm -rf bin
- rm inc/sizes.h
--- a/cc1/Makefile
+++ b/cc1/Makefile
@@ -1,6 +1,8 @@
# See LICENSE file for copyright and license details.
.POSIX:
+CSTDINC = -I../inc/$(STD)
+
include ../config.mk
OBJS = types.o decl.o lex.o error.o symbol.o main.o expr.o \
@@ -9,10 +11,7 @@
all: cc1-$(ARCH)
cpp.o: stallman.msg
-$(OBJS): cc1.h ../inc/cc.h ../inc/sizes.h
-
-../inc/sizes.h:
- cp ../inc/sizes_$(STD).h $@
+$(OBJS): cc1.h ../inc/cc.h ../inc/$(STD)/cstd.h
../lib/libcc.a:
cd ../lib && $(MAKE) -e
--- a/cc1/cpp.c
+++ b/cc1/cpp.c
@@ -7,7 +7,7 @@
#include <string.h>
#include <time.h>
-#include "../inc/sizes.h"
+#include <cstd.h>
#include "../inc/cc.h"
#include "cc1.h"
--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -6,7 +6,7 @@
#include <stdlib.h>
#include <string.h>
-#include "../inc/sizes.h"
+#include <cstd.h>
#include "../inc/cc.h"
#include "cc1.h"
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -5,8 +5,8 @@
#include <stdlib.h>
#include <string.h>
+#include <cstd.h>
#include "../inc/cc.h"
-#include "../inc/sizes.h"
#include "cc1.h"
#define XCHG(lp, rp, np) (np = lp, lp = rp, rp = np)
--- a/cc1/init.c
+++ b/cc1/init.c
@@ -5,8 +5,8 @@
#include <stdlib.h>
#include <string.h>
+#include <cstd.h>
#include "../inc/cc.h"
-#include "../inc/sizes.h"
#include "cc1.h"
--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -7,7 +7,7 @@
#include <stdlib.h>
#include <string.h>
-#include "../inc/sizes.h"
+#include <cstd.h>
#include "../inc/cc.h"
#include "cc1.h"
--- a/cc1/stmt.c
+++ b/cc1/stmt.c
@@ -4,8 +4,8 @@
#include <setjmp.h>
#include <stdio.h>
+#include <cstd.h>
#include "../inc/cc.h"
-#include "../inc/sizes.h"
#include "cc1.h"
Symbol *curfun;
--- a/cc1/symbol.c
+++ b/cc1/symbol.c
@@ -5,8 +5,8 @@
#include <stdlib.h>
#include <string.h>
+#include <cstd.h>
#include "../inc/cc.h"
-#include "../inc/sizes.h"
#include "cc1.h"
#define NR_SYM_HASH 64
--- a/cc1/types.c
+++ b/cc1/types.c
@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <string.h>
-#include "../inc/sizes.h"
+#include <cstd.h>
#include "../inc/cc.h"
#include "cc1.h"
--- a/cc2/Makefile
+++ b/cc2/Makefile
@@ -1,6 +1,8 @@
# See LICENSE file for copyright and license details.
.POSIX:
+CSTDINC = -I../inc/$(STD)
+
include ../config.mk
OBJS = main.o parser.o peep.o symbol.o node.o code.o optm.o\
@@ -10,7 +12,7 @@
all: cc2-$(ARCH)
main.o: error.h
-$(OBJS): cc2.h ../inc/sizes.h ../inc/cc.h
+$(OBJS): cc2.h ../inc/$(STD)/cstd.h ../inc/cc.h
arch/$(ARCH)/code.o: arch/$(ARCH)/arch.h
arch/$(ARCH)/cgen.o: arch/$(ARCH)/arch.h
@@ -20,9 +22,6 @@
../lib/libcc.a:
cd ../lib && $(MAKE) -e
-
-../inc/sizes.h:
- cp ../inc/sizes_$(STD).h $@
cc2-$(ARCH): $(OBJS) ../lib/libcc.a
$(CC) $(SCC_LDFLAGS) $(OBJS) ../lib/libcc.a -o $@
--- a/cc2/arch/amd64-sysv/code.c
+++ b/cc2/arch/amd64-sysv/code.c
@@ -4,10 +4,10 @@
#include <stdio.h>
#include <stdlib.h>
+#include <cstd.h>
#include "arch.h"
#include "../../../inc/cc.h"
#include "../../cc2.h"
-#include "../../../inc/sizes.h"
enum segment {
CODESEG,
--- a/cc2/arch/i386-sysv/code.c
+++ b/cc2/arch/i386-sysv/code.c
@@ -3,10 +3,10 @@
#include <stdio.h>
#include <stdlib.h>
+#include <cstd.h>
#include "arch.h"
#include "../../../inc/cc.h"
#include "../../cc2.h"
-#include "../../../inc/sizes.h"
enum segment {
CODESEG,
--- a/cc2/arch/qbe/cgen.c
+++ b/cc2/arch/qbe/cgen.c
@@ -4,10 +4,10 @@
#include <assert.h>
#include <stdlib.h>
+#include <cstd.h>
#include "arch.h"
#include "../../../inc/cc.h"
#include "../../cc2.h"
-#include "../../../inc/sizes.h"
enum sflags {
ISTMP = 1,
--- a/cc2/arch/qbe/code.c
+++ b/cc2/arch/qbe/code.c
@@ -5,10 +5,10 @@
#include <stdlib.h>
#include <string.h>
+#include <cstd.h>
#include "arch.h"
#include "../../../inc/cc.h"
#include "../../cc2.h"
-#include "../../../inc/sizes.h"
#define ADDR_LEN (INTIDENTSIZ+64)
--- a/cc2/arch/z80/code.c
+++ b/cc2/arch/z80/code.c
@@ -4,10 +4,10 @@
#include <stdio.h>
#include <stdlib.h>
+#include <cstd.h>
#include "arch.h"
#include "../../../inc/cc.h"
#include "../../cc2.h"
-#include "../../../inc/sizes.h"
enum segment {
CODESEG,
--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -5,8 +5,8 @@
#include <stdlib.h>
#include <string.h>
+#include <cstd.h>
#include "../inc/cc.h"
-#include "../inc/sizes.h"
#include "cc2.h"
--- a/config.mk
+++ b/config.mk
@@ -7,8 +7,7 @@
ARCH = qbe
DRIVER = posix
-# Remove inc/sizes.h if STD is changed
-# can be c89 or c99
+# Can be c89 or c99
STD = c99
# paths
@@ -21,6 +20,7 @@
# for Plan9 add -D_SUSV2_SOURCE
SCC_CFLAGS = -DARCH=\"$(ARCH)\" \
+ $(CSTDINC) \
-DPREFIX=\"$(PREFIX)\" \
-DNDEBUG \
$(CFLAGS)
--- /dev/null
+++ b/inc/c89/cstd.h
@@ -1,0 +1,102 @@
+/* See LICENSE file for copyright and license details. */
+
+/*
+ * 15 nesting levels of compound statements, iteration control
+ * structures, and selection control structures
+ */
+#define NR_BLOCK 15
+/*
+ * 8 nesting levels of conditional inclusion
+ */
+#define NR_COND 8
+/*
+ * 12 pointer, array, and function declarators (in any combinations)
+ * modifying an arithmetic, a structure, a union, or an incomplete type
+ * in a declaration
+ */
+#define NR_DECLARATORS 12
+/*
+ * 31 declarators nested by parentheses within a full declarator
+ */
+#define NR_SUBTYPE 31
+/*
+ * 32 expressions nested by parentheses within a full expression
+ */
+#define NR_SUBEXPR 32
+/*
+ * 31 significant initial characters in an internal identifier or a
+ * macro name
+ */
+#define INTIDENTSIZ 31
+/*
+ * 6 significant initial characters in an external identifier
+ */
+#define EXTIDENTSIZ 6
+/*
+ * 511 external identifiers in one translation unit
+ */
+#define NR_EXT_IDENT 511
+/*
+ * 127 identifiers with block scope declared in one block
+ */
+#define NR_INT_IDENT 127
+/*
+ * 1024 macro identifiers simultaneously defined in one translation
+ * unit
+ */
+#define NR_MACROIDENT 1024
+/*
+ * 31 parameters in one function definition
+ */
+#define NR_FUNPARAM 31
+/*
+ * 31 arguments in one function call
+ */
+#define NR_FUNARG 31
+/*
+ * 31 parameters in one macro definition
+ */
+#define NR_MACROPARAM 31
+/*
+ * 31 arguments in one macro invocation
+ */
+#define NR_MACROARG 31
+/*
+ * 509 characters in a logical source line
+ */
+#define LINESIZ 509
+/*
+ * 509 characters in a character string literal or wide string literal
+ * (after concatenation)
+ */
+#define STRINGSIZ 509
+/*
+ * 32767 bytes in an object (in a hosted environment only)
+ */
+#define OBJECTSIZ 32767
+/*
+ * 8 nesting levels for #include'd files
+ */
+#define NR_INCLUDE 8
+/*
+ * 257 case labels for a switch statement (excluding those for any
+ * nested switch statements)
+ */
+#define NR_SWITCH 257
+/*
+ * 127 members in a single structure or union
+ */
+#define NR_FIELDS 127
+/*
+ * 127 enumeration constants in a single enumeration
+ */
+#define NR_ENUM_CTES 127
+/*
+ * 15 levels of nested structure or union definitions in a single
+ * struct-declaration-list
+ */
+#define NR_STRUCT_LEVEL 15
+/*
+ * number of defined structs/unions in one translation unit
+ */
+#define NR_MAXSTRUCTS 127
--- /dev/null
+++ b/inc/c99/cstd.h
@@ -1,0 +1,110 @@
+/* See LICENSE file for copyright and license details. */
+
+/*
+ * 127 nesting levels of blocks
+ */
+#define NR_BLOCK 127
+/*
+ * 63 nesting levels of conditional inclusion
+ */
+#define NR_COND 63
+/*
+ * 12 pointer, array, and function declarators (in any combinations)
+ * modifying an arithmetic, a structure, a union, or an incomplete type
+ * in a declaration
+ */
+#define NR_DECLARATORS 12
+/*
+ * 63 nesting levels of parenthesized declarators within a full
+ * declarator
+ */
+#define NR_SUBTYPE 63
+/*
+ * 63 nesting levels of parenthesized expressions within a full
+ * expression
+ */
+#define NR_SUBEXPR 63
+/*
+ * 63 significant initial characters in an internal identifier or a
+ * macro name (each universal character name or extended source
+ * character is considered a single character)
+ */
+#define INTIDENTSIZ 63
+/*
+ * 31 significant initial characters in an external identifier (each
+ * universal character name specifying a short identifier of 0000FFFF
+ * or less is considered 6 characters, each universal character name
+ * specifying a short identifier of 00010000 or more is considered 10
+ * characters, and each extended source character is considered the
+ * same number of characters as the corresponding universal character
+ * name, if any)
+ */
+#define EXTIDENTSIZ 31
+/*
+ * 4095 external identifiers in one translation unit
+ */
+#define NR_EXT_IDENT 4095
+/*
+ * 511 identifiers with block scope declared in one block
+ */
+#define NR_INT_IDENT 511
+/*
+ * 4096 macro identifiers simultaneously defined in one preprocessing
+ * translation unit
+ */
+#define NR_MACROIDENT 4096
+/*
+ * 127 parameters in one function definition
+ */
+#define NR_FUNPARAM 127
+/*
+ * 127 arguments in one function call
+ */
+#define NR_FUNARG 127
+/*
+ * 127 parameters in one macro definition
+ */
+#define NR_MACROPARAM 127
+/*
+ * 127 arguments in one macro invocation
+ */
+#define NR_MACROARG 127
+/*
+ * 4095 characters in a logical source line
+ */
+#define LINESIZ 4095
+/*
+ * 4095 characters in a character string literal or wide string literal
+ * (after concatenation)
+ */
+#define STRINGSIZ 4095
+/*
+ * 65535 bytes in an object (in a hosted environment only)
+ */
+#define OBJECTSIZ 65535
+/*
+ * 15 nesting levels for #include'd files
+ */
+#define NR_INCLUDE 15
+/*
+ * 1023 case labels for a switch statement (excluding those for any
+ * nested switch statements)
+ */
+#define NR_SWITCH 1023
+/*
+ * 1023 members in a single structure or union
+ */
+#define NR_FIELDS 1023
+/*
+ * 1023 enumeration constants in a single enumeration
+ */
+#define NR_ENUM_CTES 1023
+/*
+ * 63 levels of nested structure or union definitions in a single
+ * struct-declaration-list
+ */
+#define NR_STRUCT_LEVEL 63
+/*
+ * number of defined structs/unions in one translation unit
+ */
+#define NR_MAXSTRUCTS 127
--- a/inc/sizes_c89.h
+++ /dev/null
@@ -1,102 +1,0 @@
-/* See LICENSE file for copyright and license details. */
-
-/*
- * 15 nesting levels of compound statements, iteration control
- * structures, and selection control structures
- */
-#define NR_BLOCK 15
-/*
- * 8 nesting levels of conditional inclusion
- */
-#define NR_COND 8
-/*
- * 12 pointer, array, and function declarators (in any combinations)
- * modifying an arithmetic, a structure, a union, or an incomplete type
- * in a declaration
- */
-#define NR_DECLARATORS 12
-/*
- * 31 declarators nested by parentheses within a full declarator
- */
-#define NR_SUBTYPE 31
-/*
- * 32 expressions nested by parentheses within a full expression
- */
-#define NR_SUBEXPR 32
-/*
- * 31 significant initial characters in an internal identifier or a
- * macro name
- */
-#define INTIDENTSIZ 31
-/*
- * 6 significant initial characters in an external identifier
- */
-#define EXTIDENTSIZ 6
-/*
- * 511 external identifiers in one translation unit
- */
-#define NR_EXT_IDENT 511
-/*
- * 127 identifiers with block scope declared in one block
- */
-#define NR_INT_IDENT 127
-/*
- * 1024 macro identifiers simultaneously defined in one translation
- * unit
- */
-#define NR_MACROIDENT 1024
-/*
- * 31 parameters in one function definition
- */
-#define NR_FUNPARAM 31
-/*
- * 31 arguments in one function call
- */
-#define NR_FUNARG 31
-/*
- * 31 parameters in one macro definition
- */
-#define NR_MACROPARAM 31
-/*
- * 31 arguments in one macro invocation
- */
-#define NR_MACROARG 31
-/*
- * 509 characters in a logical source line
- */
-#define LINESIZ 509
-/*
- * 509 characters in a character string literal or wide string literal
- * (after concatenation)
- */
-#define STRINGSIZ 509
-/*
- * 32767 bytes in an object (in a hosted environment only)
- */
-#define OBJECTSIZ 32767
-/*
- * 8 nesting levels for #include'd files
- */
-#define NR_INCLUDE 8
-/*
- * 257 case labels for a switch statement (excluding those for any
- * nested switch statements)
- */
-#define NR_SWITCH 257
-/*
- * 127 members in a single structure or union
- */
-#define NR_FIELDS 127
-/*
- * 127 enumeration constants in a single enumeration
- */
-#define NR_ENUM_CTES 127
-/*
- * 15 levels of nested structure or union definitions in a single
- * struct-declaration-list
- */
-#define NR_STRUCT_LEVEL 15
-/*
- * number of defined structs/unions in one translation unit
- */
-#define NR_MAXSTRUCTS 127
--- a/inc/sizes_c99.h
+++ /dev/null
@@ -1,110 +1,0 @@
-/* See LICENSE file for copyright and license details. */
-
-/*
- * 127 nesting levels of blocks
- */
-#define NR_BLOCK 127
-/*
- * 63 nesting levels of conditional inclusion
- */
-#define NR_COND 63
-/*
- * 12 pointer, array, and function declarators (in any combinations)
- * modifying an arithmetic, a structure, a union, or an incomplete type
- * in a declaration
- */
-#define NR_DECLARATORS 12
-/*
- * 63 nesting levels of parenthesized declarators within a full
- * declarator
- */
-#define NR_SUBTYPE 63
-/*
- * 63 nesting levels of parenthesized expressions within a full
- * expression
- */
-#define NR_SUBEXPR 63
-/*
- * 63 significant initial characters in an internal identifier or a
- * macro name (each universal character name or extended source
- * character is considered a single character)
- */
-#define INTIDENTSIZ 63
-/*
- * 31 significant initial characters in an external identifier (each
- * universal character name specifying a short identifier of 0000FFFF
- * or less is considered 6 characters, each universal character name
- * specifying a short identifier of 00010000 or more is considered 10
- * characters, and each extended source character is considered the
- * same number of characters as the corresponding universal character
- * name, if any)
- */
-#define EXTIDENTSIZ 31
-/*
- * 4095 external identifiers in one translation unit
- */
-#define NR_EXT_IDENT 4095
-/*
- * 511 identifiers with block scope declared in one block
- */
-#define NR_INT_IDENT 511
-/*
- * 4096 macro identifiers simultaneously defined in one preprocessing
- * translation unit
- */
-#define NR_MACROIDENT 4096
-/*
- * 127 parameters in one function definition
- */
-#define NR_FUNPARAM 127
-/*
- * 127 arguments in one function call
- */
-#define NR_FUNARG 127
-/*
- * 127 parameters in one macro definition
- */
-#define NR_MACROPARAM 127
-/*
- * 127 arguments in one macro invocation
- */
-#define NR_MACROARG 127
-/*
- * 4095 characters in a logical source line
- */
-#define LINESIZ 4095
-/*
- * 4095 characters in a character string literal or wide string literal
- * (after concatenation)
- */
-#define STRINGSIZ 4095
-/*
- * 65535 bytes in an object (in a hosted environment only)
- */
-#define OBJECTSIZ 65535
-/*
- * 15 nesting levels for #include'd files
- */
-#define NR_INCLUDE 15
-/*
- * 1023 case labels for a switch statement (excluding those for any
- * nested switch statements)
- */
-#define NR_SWITCH 1023
-/*
- * 1023 members in a single structure or union
- */
-#define NR_FIELDS 1023
-/*
- * 1023 enumeration constants in a single enumeration
- */
-#define NR_ENUM_CTES 1023
-/*
- * 63 levels of nested structure or union definitions in a single
- * struct-declaration-list
- */
-#define NR_STRUCT_LEVEL 63
-/*
- * number of defined structs/unions in one translation unit
- */
-#define NR_MAXSTRUCTS 127