scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit 23495f800b903c0fe1261a385ed304994509f437
parent a06a212f80e6aa82aa335516bc5b4cbe17022625
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 22 Aug 2017 17:16:21 +0100

Chage makefile framework

At this moment there were several problems with the makefiles,
because we only could configure the archs and systems that
we want in the final build, and it meant that the final
target list was a cartesian product of both. This set
included non desired (and absurd) combinations like for example
z80-linux. Other problem was the impossibility of having
support for the new qbe support for aarch64.

This new framework uses a dep rule which generates makefiles
(makefiles are different files than Makefiles), and it helps
to avoid all the for loops that were needed for generating
all the requested architectures. All the needed information
is now in the leaf makefiles.

Diffstat:
MMakefile | 84++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
Mcc1/Makefile | 42+++++++++++++++++++++---------------------
Dcc1/arch/amd64-sysv/arch.c | 223-------------------------------------------------------------------------------
Dcc1/arch/i386-sysv/arch.c | 224-------------------------------------------------------------------------------
Dcc1/arch/qbe/arch.c | 223-------------------------------------------------------------------------------
Dcc1/arch/z80/arch.c | 222-------------------------------------------------------------------------------
Mcc1/cpp.c | 5-----
Acc1/gendep.sh | 27+++++++++++++++++++++++++++
Acc1/target/amd64-sysv/arch.c | 222+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acc1/target/i386-sysv/arch.c | 223+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acc1/target/z80-scc/arch.c | 221+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcc2/Makefile | 36+++++++++++++++++++++---------------
Acc2/gendep.sh | 39+++++++++++++++++++++++++++++++++++++++
Rcc2/arch/amd64-sysv/arch.h -> cc2/target/amd64-sysv/arch.h | 0
Rcc2/arch/amd64-sysv/cgen.c -> cc2/target/amd64-sysv/cgen.c | 0
Rcc2/arch/amd64-sysv/code.c -> cc2/target/amd64-sysv/code.c | 0
Rcc2/arch/amd64-sysv/optm.c -> cc2/target/amd64-sysv/optm.c | 0
Acc2/target/amd64-sysv/target.mk | 6++++++
Rcc2/arch/amd64-sysv/types.c -> cc2/target/amd64-sysv/types.c | 0
Rcc2/arch/i386-sysv/arch.h -> cc2/target/i386-sysv/arch.h | 0
Rcc2/arch/i386-sysv/cgen.c -> cc2/target/i386-sysv/cgen.c | 0
Rcc2/arch/i386-sysv/code.c -> cc2/target/i386-sysv/code.c | 0
Rcc2/arch/i386-sysv/optm.c -> cc2/target/i386-sysv/optm.c | 0
Acc2/target/i386-sysv/target.mk | 6++++++
Rcc2/arch/i386-sysv/types.c -> cc2/target/i386-sysv/types.c | 0
Rcc2/arch/qbe/arch.h -> cc2/target/qbe_amd64-sysv/arch.h | 0
Rcc2/arch/qbe/cgen.c -> cc2/target/qbe_amd64-sysv/cgen.c | 0
Rcc2/arch/qbe/code.c -> cc2/target/qbe_amd64-sysv/code.c | 0
Rcc2/arch/qbe/optm.c -> cc2/target/qbe_amd64-sysv/optm.c | 0
Acc2/target/qbe_amd64-sysv/target.mk | 6++++++
Rcc2/arch/qbe/types.c -> cc2/target/qbe_amd64-sysv/types.c | 0
Rcc2/arch/z80/arch.h -> cc2/target/z80-scc/arch.h | 0
Rcc2/arch/z80/cgen.c -> cc2/target/z80-scc/cgen.c | 0
Rcc2/arch/z80/code.c -> cc2/target/z80-scc/code.c | 0
Rcc2/arch/z80/optm.c -> cc2/target/z80-scc/optm.c | 0
Acc2/target/z80-scc/target.mk | 7+++++++
Rcc2/arch/z80/types.c -> cc2/target/z80-scc/types.c | 0
Mconfig.mk | 28++++++++++++++++++----------
Dcrt/Makefile | 11-----------
Dcrt/qbe-linux/crt.s | 8--------
Dcrt/qbe-openbsd/crt.s | 23-----------------------
Dcrt/z80-linux/crt.s | 1-
Dcrt/z80-openbsd/crt.s | 1-
Adriver/Makefile | 7+++++++
Mdriver/posix/Makefile | 33+++++++++++++++++++++------------
Adriver/posix/gendep.sh | 18++++++++++++++++++
Mdriver/posix/scc.c | 27++++++++++++++++++++-------
Ainc/Makefile | 32++++++++++++++++++++++++++++++++
Minc/cc.h | 4----
Minc/sysincludes.def.h | 2+-
Mlib/Makefile | 20++++++++++----------
Alib/c/Makefile | 7+++++++
Alib/c/amd64-sysv-linux/Makefile | 6++++++
Alib/c/common.mk | 19+++++++++++++++++++
Alib/c/gendep.sh | 17+++++++++++++++++
Rlibc/include/assert.h -> lib/c/include/assert.h | 0
Rlibc/include/bits/amd64-sysv/arch/limits.h -> lib/c/include/bits/amd64-sysv/arch/limits.h | 0
Rlibc/include/bits/amd64-sysv/arch/signal.h -> lib/c/include/bits/amd64-sysv/arch/signal.h | 0
Rlibc/include/bits/amd64-sysv/arch/stddef.h -> lib/c/include/bits/amd64-sysv/arch/stddef.h | 0
Rlibc/include/bits/amd64-sysv/arch/stdint.h -> lib/c/include/bits/amd64-sysv/arch/stdint.h | 0
Rlibc/include/bits/amd64-sysv/arch/stdio.h -> lib/c/include/bits/amd64-sysv/arch/stdio.h | 0
Rlibc/include/bits/amd64-sysv/arch/stdlib.h -> lib/c/include/bits/amd64-sysv/arch/stdlib.h | 0
Rlibc/include/bits/amd64-sysv/arch/string.h -> lib/c/include/bits/amd64-sysv/arch/string.h | 0
Rlibc/include/bits/amd64-sysv/arch/time.h -> lib/c/include/bits/amd64-sysv/arch/time.h | 0
Rlibc/include/bits/i386-sysv/arch/limits.h -> lib/c/include/bits/i386-sysv/arch/limits.h | 0
Rlibc/include/bits/i386-sysv/arch/signal.h -> lib/c/include/bits/i386-sysv/arch/signal.h | 0
Rlibc/include/bits/i386-sysv/arch/stddef.h -> lib/c/include/bits/i386-sysv/arch/stddef.h | 0
Rlibc/include/bits/i386-sysv/arch/stdint.h -> lib/c/include/bits/i386-sysv/arch/stdint.h | 0
Rlibc/include/bits/i386-sysv/arch/stdio.h -> lib/c/include/bits/i386-sysv/arch/stdio.h | 0
Rlibc/include/bits/i386-sysv/arch/stdlib.h -> lib/c/include/bits/i386-sysv/arch/stdlib.h | 0
Rlibc/include/bits/i386-sysv/arch/string.h -> lib/c/include/bits/i386-sysv/arch/string.h | 0
Rlibc/include/bits/i386-sysv/arch/time.h -> lib/c/include/bits/i386-sysv/arch/time.h | 0
Rlibc/include/bits/z80/arch/limits.h -> lib/c/include/bits/z80-dos/arch/limits.h | 0
Rlibc/include/bits/z80/arch/signal.h -> lib/c/include/bits/z80-dos/arch/signal.h | 0
Rlibc/include/bits/z80/arch/stddef.h -> lib/c/include/bits/z80-dos/arch/stddef.h | 0
Rlibc/include/bits/z80/arch/stdint.h -> lib/c/include/bits/z80-dos/arch/stdint.h | 0
Rlibc/include/bits/z80/arch/stdio.h -> lib/c/include/bits/z80-dos/arch/stdio.h | 0
Rlibc/include/bits/z80/arch/stdlib.h -> lib/c/include/bits/z80-dos/arch/stdlib.h | 0
Rlibc/include/bits/z80/arch/string.h -> lib/c/include/bits/z80-dos/arch/string.h | 0
Rlibc/include/bits/z80/arch/time.h -> lib/c/include/bits/z80-dos/arch/time.h | 0
Rlibc/include/ctype.h -> lib/c/include/ctype.h | 0
Rlibc/include/errno.h -> lib/c/include/errno.h | 0
Rlibc/include/limits.h -> lib/c/include/limits.h | 0
Rlibc/include/locale.h -> lib/c/include/locale.h | 0
Rlibc/include/signal.h -> lib/c/include/signal.h | 0
Rlibc/include/stdarg.h -> lib/c/include/stdarg.h | 0
Rlibc/include/stdbool.h -> lib/c/include/stdbool.h | 0
Rlibc/include/stddef.h -> lib/c/include/stddef.h | 0
Rlibc/include/stdint.h -> lib/c/include/stdint.h | 0
Rlibc/include/stdio.h -> lib/c/include/stdio.h | 0
Rlibc/include/stdlib.h -> lib/c/include/stdlib.h | 0
Rlibc/include/string.h -> lib/c/include/string.h | 0
Rlibc/include/time.h -> lib/c/include/time.h | 0
Alib/c/obj.lst | 49+++++++++++++++++++++++++++++++++++++++++++++++++
Alib/c/src/Makefile | 24++++++++++++++++++++++++
Rlibc/src/assert.c -> lib/c/src/assert.c | 0
Rlibc/src/atexit.c -> lib/c/src/atexit.c | 0
Rlibc/src/atoi.c -> lib/c/src/atoi.c | 0
Rlibc/src/calloc.c -> lib/c/src/calloc.c | 0
Rlibc/src/ctype.c -> lib/c/src/ctype.c | 0
Rlibc/src/exit.c -> lib/c/src/exit.c | 0
Rlibc/src/fprintf.c -> lib/c/src/fprintf.c | 0
Rlibc/src/isalnum.c -> lib/c/src/isalnum.c | 0
Rlibc/src/isalpha.c -> lib/c/src/isalpha.c | 0
Rlibc/src/isascii.c -> lib/c/src/isascii.c | 0
Rlibc/src/isblank.c -> lib/c/src/isblank.c | 0
Rlibc/src/iscntrl.c -> lib/c/src/iscntrl.c | 0
Rlibc/src/isdigit.c -> lib/c/src/isdigit.c | 0
Rlibc/src/isgraph.c -> lib/c/src/isgraph.c | 0
Rlibc/src/islower.c -> lib/c/src/islower.c | 0
Rlibc/src/isprint.c -> lib/c/src/isprint.c | 0
Rlibc/src/ispunct.c -> lib/c/src/ispunct.c | 0
Rlibc/src/isspace.c -> lib/c/src/isspace.c | 0
Rlibc/src/isupper.c -> lib/c/src/isupper.c | 0
Rlibc/src/isxdigit.c -> lib/c/src/isxdigit.c | 0
Rlibc/src/localeconv.c -> lib/c/src/localeconv.c | 0
Rlibc/src/malloc.c -> lib/c/src/malloc.c | 0
Rlibc/src/malloc.h -> lib/c/src/malloc.h | 0
Rlibc/src/memchr.c -> lib/c/src/memchr.c | 0
Rlibc/src/memcmp.c -> lib/c/src/memcmp.c | 0
Rlibc/src/memcpy.c -> lib/c/src/memcpy.c | 0
Rlibc/src/memmove.c -> lib/c/src/memmove.c | 0
Rlibc/src/memset.c -> lib/c/src/memset.c | 0
Rlibc/src/printf.c -> lib/c/src/printf.c | 0
Rlibc/src/rand.c -> lib/c/src/rand.c | 0
Rlibc/src/realloc.c -> lib/c/src/realloc.c | 0
Rlibc/src/setlocale.c -> lib/c/src/setlocale.c | 0
Rlibc/src/strcat.c -> lib/c/src/strcat.c | 0
Rlibc/src/strchr.c -> lib/c/src/strchr.c | 0
Rlibc/src/strcmp.c -> lib/c/src/strcmp.c | 0
Rlibc/src/strcoll.c -> lib/c/src/strcoll.c | 0
Rlibc/src/strcpy.c -> lib/c/src/strcpy.c | 0
Rlibc/src/strcspn.c -> lib/c/src/strcspn.c | 0
Rlibc/src/strlen.c -> lib/c/src/strlen.c | 0
Rlibc/src/strncat.c -> lib/c/src/strncat.c | 0
Rlibc/src/strncmp.c -> lib/c/src/strncmp.c | 0
Rlibc/src/strncpy.c -> lib/c/src/strncpy.c | 0
Rlibc/src/strpbrk.c -> lib/c/src/strpbrk.c | 0
Rlibc/src/strrchr.c -> lib/c/src/strrchr.c | 0
Rlibc/src/strspn.c -> lib/c/src/strspn.c | 0
Rlibc/src/strstr.c -> lib/c/src/strstr.c | 0
Rlibc/src/strtok.c -> lib/c/src/strtok.c | 0
Rlibc/src/strxfrm.c -> lib/c/src/strxfrm.c | 0
Rlibc/src/syscall.h -> lib/c/src/syscall.h | 0
Rlibc/src/tolower.c -> lib/c/src/tolower.c | 0
Rlibc/src/toupper.c -> lib/c/src/toupper.c | 0
Rlibc/src/vfprintf.c -> lib/c/src/vfprintf.c | 0
Alib/cc/Makefile | 20++++++++++++++++++++
Alib/cc/debug.c | 21+++++++++++++++++++++
Alib/cc/die.c | 21+++++++++++++++++++++
Alib/cc/libdep.mk | 10++++++++++
Alib/cc/newitem.c | 12++++++++++++
Alib/cc/xcalloc.c | 14++++++++++++++
Alib/cc/xmalloc.c | 14++++++++++++++
Alib/cc/xrealloc.c | 14++++++++++++++
Alib/cc/xstrdup.c | 13+++++++++++++
Alib/crt/Makefile | 11+++++++++++
Rcrt/amd64-sysv-linux/crt.s -> lib/crt/amd64-sysv-linux/crt.s | 0
Rcrt/amd64-sysv-openbsd/crt.s -> lib/crt/amd64-sysv-openbsd/crt.s | 0
Rcrt/i386-sysv-linux/crt.s -> lib/crt/i386-sysv-linux/crt.s | 0
Rcrt/i386-sysv-openbsd/crt.s -> lib/crt/i386-sysv-openbsd/crt.s | 0
Dlib/debug.c | 21---------------------
Dlib/die.c | 21---------------------
Dlib/newitem.c | 12------------
Alib/sys/Makefile | 13+++++++++++++
Alib/sys/abi/amd64-sysv.sh | 15+++++++++++++++
Alib/sys/amd64-sysv-linux/Makefile | 5+++++
Rlibc/src/sys/amd64-sysv-linux/syscall.lst -> lib/sys/amd64-sysv-linux/syscall.lst | 0
Alib/sys/common.mk | 13+++++++++++++
Alib/sys/i386-sysv-linux/Makefile | 4++++
Rlibc/src/sys/i386-sysv-linux/syscall.lst -> lib/sys/i386-sysv-linux/syscall.lst | 0
Alib/sys/libsys.mk | 24++++++++++++++++++++++++
Alib/sys/qbe-linux/Makefile | 5+++++
Rlibc/src/sys/qbe-linux/syscall.lst -> lib/sys/qbe-linux/syscall.lst | 0
Alib/sys/z80-linux/Makefile | 4++++
Rlibc/src/sys/z80-linux/syscall.lst -> lib/sys/z80-linux/syscall.lst | 0
Dlib/xcalloc.c | 14--------------
Dlib/xmalloc.c | 14--------------
Dlib/xrealloc.c | 14--------------
Dlib/xstrdup.c | 13-------------
Dlibc/include/bits/qbe/arch/limits.h | 17-----------------
Dlibc/include/bits/qbe/arch/signal.h | 29-----------------------------
Dlibc/include/bits/qbe/arch/stddef.h | 16----------------
Dlibc/include/bits/qbe/arch/stdint.h | 117-------------------------------------------------------------------------------
Dlibc/include/bits/qbe/arch/stdio.h | 15---------------
Dlibc/include/bits/qbe/arch/stdlib.h | 16----------------
Dlibc/include/bits/qbe/arch/string.h | 5-----
Dlibc/include/bits/qbe/arch/time.h | 8--------
Dlibc/src/Makefile | 44--------------------------------------------
Dlibc/src/sys/amd64-sysv-linux/Makefile | 37-------------------------------------
Dlibc/src/sys/amd64-sysv-linux/syscall.awk | 12------------
Dlibc/src/sys/i386-sysv-linux/Makefile | 37-------------------------------------
Dlibc/src/sys/qbe-linux/Makefile | 37-------------------------------------
Dlibc/src/sys/qbe-linux/syscall.awk | 12------------
Dlibc/src/sys/z80-linux/Makefile | 37-------------------------------------
Mtests/Makefile | 2+-
Mtests/execute/Makefile | 3+++
197 files changed, 1332 insertions(+), 1607 deletions(-)

diff --git a/Makefile b/Makefile @@ -4,39 +4,65 @@ include config.mk -DIRS = lib cc1 cc2 crt driver/$(DRIVER) +DIRS = inc cc1 cc2 driver lib -all: scc-driver - for i in $(ARCHS); \ +all: + @set -e ;\ + trap 'rm -f bin/cc1-* bin/cc2-* bin/scc' 0 2 3; \ + if ! test -f bin/dep ;\ + then \ + echo Run make dep first >&2 ;\ + exit 1 ;\ + fi ;\ + pwd=$$PWD; \ + for i in $(DIRS); \ do \ - $(MAKE) $$i || exit; \ + cd $$i; \ + $(MAKE) $@; \ + cd $$pwd; \ done + cp cc1/cc1-* bin/ + cp cc2/cc2-* bin/ + cp driver/$(DRIVER)/scc bin/ -scc-driver: - cd driver/$(DRIVER)/ && $(MAKE) scc - ln -f driver/$(DRIVER)/scc bin/scc -$(ARCHS): +clean: + @set -e ;\ pwd=$$PWD; \ - for i in cc1 cc2; \ + for i in $(DIRS); \ do \ cd $$i; \ - ARCH=$@ $(MAKE) -e $$i-$@ || exit; \ + $(MAKE) $@; \ cd $$pwd; \ done - cd crt; \ - for i in $(SYSS); \ - do \ - ARCH=$@ SYS=$$i $(MAKE) -e || exit; \ - done; \ - cd $$pwd; - ln -f cc1/cc1-$@ bin/ - ln -f cc2/cc2-$@ bin/ + rm -f bin/cc1-* + rm -f bin/cc2-* + rm -f bin/scc -libc/src/libc.a: +distclean: + @set -e ;\ + pwd=$$PWD; \ + for i in $(DIRS); \ + do \ + cd $$i; \ + $(MAKE) $@; \ + cd $$pwd; \ + done + rm -f bin/cc1-* + rm -f bin/cc2-* + rm -f bin/scc + rm -f bin/dep -libc: libc/src/libc.a - cd libc/src && $(MAKE) -e CC=scc +dep: + @set -e;\ + pwd=$$PWD; \ + for i in $(DIRS); \ + do \ + cd $$i; \ + $(MAKE) $@; \ + cd $$pwd; \ + done + touch bin/dep tests: all cd tests && $(MAKE) -e all @@ -61,19 +87,3 @@ uninstall: rm -rf $(DESTDIR)/$(PREFIX)/lib/scc/ rm -f $(DESTDIR)/$(PREFIX)/bin/scc rm -f $(DESTDIR)/$(PREFIX)/bin/scpp - -clean-helper: - for i in $(DIRS); \ - do \ - (cd $$i && $(MAKE) -e clean || exit); \ - done - -clean: - for i in $(ARCHS); \ - do \ - ARCH=$$i $(MAKE) -e clean-helper || exit; \ - done - rm -f bin/cc* bin/scc - -distclean: clean - rm -f inc/sysincludes.h inc/syslibs.h inc/ldflags.h diff --git a/cc1/Makefile b/cc1/Makefile @@ -1,35 +1,35 @@ # See LICENSE file for copyright and license details. .POSIX: -CSTDINC = -I../inc/$(STD) +# Makefile is only used as a template for makefile. +# If you modify Makefile remember to run make dep include ../config.mk -OBJS = types.o decl.o lex.o error.o symbol.o main.o expr.o \ - code.o stmt.o cpp.o fold.o init.o builtin.o \ - arch/$(ARCH)/arch.o +MOREFLAGS = -I../inc/$(STD) +LIBDIR = ../lib/cc -all: cc1-$(ARCH) +OBJ = types.o decl.o lex.o error.o symbol.o main.o expr.o \ + code.o stmt.o cpp.o fold.o init.o builtin.o -cpp.o: stallman.msg -arch/$(ARCH)/arch.o: ../inc/sysincludes.h -$(OBJS): cc1.h ../inc/cc.h ../inc/$(STD)/cstd.h - -../inc/sysincludes.h: - cp -f ../inc/sysincludes.def.h ../inc/sysincludes.h +HDR = cc1.h ../inc/cc.h ../inc/$(STD)/cstd.h ../inc/sysincludes.h -../lib/libcc.a: - cd ../lib && $(MAKE) -e +all: -cc1-$(ARCH): $(OBJS) ../lib/libcc.a - $(CC) $(SCC_LDFLAGS) $(OBJS) ../lib/libcc.a -o $@ +cpp.o: stallman.msg -cpp: cc1-$(ARCH) - ln -f $< cpp +$(LIBDIR)/libcc.a: + cd $(LIBDIR) && $(MAKE) -test: - cd tests && ./chktest.sh *.c +dep: + ./gendep.sh $(TARGETS) clean: - rm -f $(OBJS) - rm -f cc1-* cpp + rm -f *.o + rm -f target/*/*.o + rm -f cc1-* + +distclean: clean + rm -f makefile + +include ../lib/cc/libdep.mk diff --git a/cc1/arch/amd64-sysv/arch.c b/cc1/arch/amd64-sysv/arch.c @@ -1,223 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -static char sccsid[] = "@(#) ./cc1/arch/amd64-sysv/arch.c"; -#include <stdio.h> - -#include "../../../inc/sysincludes.h" -#include "../../../inc/cc.h" -#include "../../cc1.h" - -#define RANK_BOOL 0 -#define RANK_SCHAR 1 -#define RANK_UCHAR 1 -#define RANK_CHAR 1 -#define RANK_SHORT 2 -#define RANK_USHORT 2 -#define RANK_INT 3 -#define RANK_UINT 3 -#define RANK_LONG 4 -#define RANK_ULONG 4 -#define RANK_LLONG 5 -#define RANK_ULLONG 5 -#define RANK_FLOAT 6 -#define RANK_DOUBLE 7 -#define RANK_LDOUBLE 8 - -/* - * Initializaion of type pointers were done with - * a C99 initilizator '... = &(Type) {...', but - * c compiler in Plan9 gives error with this - * syntax, so I have switched it to this ugly form - * I hope I will change it again in the future - */ - -static Type types[] = { - { /* 0 = voidtype */ - .op = VOID, - .letter = L_VOID, - }, - { /* 1 = pvoidtype */ - .op = PTR, - .letter = L_POINTER, - .prop = TDEFINED, - .type = &types[5], /* chartype */ - .size = 8, - .align = 8, - }, - { /* 2 = booltype */ - .op = INT, - .letter = L_BOOL, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 1, - .align = 1, - .n.rank = RANK_BOOL, - }, - { /* 3 = schartype */ - .op = INT, - .letter = L_INT8, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 1, - .align = 1, - .n.rank = RANK_SCHAR, - }, - { /* 4 = uchartype */ - .op = INT, - .letter = L_UINT8, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 1, - .align = 1, - .n.rank = RANK_UCHAR, - }, - { /* 5 = chartype */ - .op = INT, - .letter = L_INT8, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 1, - .align = 1, - .n.rank = RANK_CHAR, - }, - { /* 6 = ushortype */ - .op = INT, - .letter = L_UINT16, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 2, - .align = 2, - .n.rank = RANK_USHORT, - }, - { /* 7 = shortype */ - .op = INT, - .letter = L_INT16, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 2, - .align = 2, - .n.rank = RANK_SHORT, - }, - { /* 8 = uinttype */ - .op = INT, - .letter = L_UINT32, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 4, - .align = 4, - .n.rank = RANK_UINT, - }, - { /* 9 = inttype */ - .op = INT, - .letter = L_INT32, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 4, - .align = 4, - .n.rank = RANK_INT, - }, - { /* 10 = longtype */ - .op = INT, - .letter = L_INT64, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 8, - .align = 8, - .n.rank = RANK_LONG, - }, - { /* 11 = ulongtype */ - .op = INT, - .letter = L_UINT64, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 8, - .align = 8, - .n.rank = RANK_ULONG, - }, - { /* 12 = ullongtype */ - .op = INT, - .letter = L_UINT64, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 8, - .align = 8, - .n.rank = RANK_ULLONG, - }, - { /* 13 = llongtype */ - .op = INT, - .letter = L_INT64, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 8, - .align = 8, - .n.rank = RANK_LLONG, - }, - { /* 14 = floattype */ - .op = FLOAT, - .letter = L_FLOAT, - .prop = TDEFINED | TARITH, - .size = 4, - .align = 4, - .n.rank = RANK_FLOAT, - }, - { /* 15 = doubletype */ - .op = FLOAT, - .letter = L_DOUBLE, - .prop = TDEFINED | TARITH, - .size = 8, - .align = 8, - .n.rank = RANK_DOUBLE, - }, - { /* 16 = ldoubletype */ - .op = FLOAT, - .letter = L_LDOUBLE, - .prop = TDEFINED | TARITH, - .size = 16, - .align = 16, - .n.rank = RANK_LDOUBLE, - }, - { /* 17 = sizettype */ - .op = INT, - .letter = L_UINT64, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 8, - .align = 8, - .n.rank = RANK_UINT, - }, - { /* 18 = ellipsis */ - .op = ELLIPSIS, - .letter = L_ELLIPSIS, - .prop = TDEFINED, - }, - { /* 19 = pdifftype */ - .op = INT, - .letter = L_INT64, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 8, - .align = 8, - .n.rank = RANK_LONG, - }, - { /* 20 = va_type */ - .op = STRUCT, - .letter = L_VA_ARG, - .prop = TDEFINED, - .size = 24, - .align = 8, - }, -}; - -Type *voidtype = &types[0], *pvoidtype = &types[1], - *booltype = &types[2], *schartype = &types[3], - *uchartype = &types[4], *chartype = &types[5], - *ushortype = &types[6], *shortype = &types[7], - *uinttype = &types[8], *inttype = &types[9], - *longtype = &types[10], *ulongtype = &types[11], - *ullongtype = &types[12], *llongtype = &types[13], - *floattype = &types[14], *doubletype = &types[15], - *ldoubletype = &types[16], - *sizettype = &types[17], *pdifftype = &types[19], - *ellipsistype = &types[18], *va_type = &types[20], - *va_list_type; - -static Symbol dummy0 = {.u.i = 0, .type = &types[9]}, - dummy1 = {.u.i = 1, .type = &types[9]}; -Symbol *zero = &dummy0, *one = &dummy1; - -void -iarch(void) -{ - va_list_type = mktype(va_type, ARY, 1, NULL); -} - -int -valid_va_list(Type *tp) -{ - return tp->op == PTR && eqtype(tp->type, va_type, 1); -} diff --git a/cc1/arch/i386-sysv/arch.c b/cc1/arch/i386-sysv/arch.c @@ -1,224 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -static char sccsid[] = "@(#) ./cc1/arch/i386-sysv/arch.c"; -#include <stdio.h> - -#include "../../../inc/sysincludes.h" -#include "../../../inc/cc.h" -#include "../../cc1.h" - -#define RANK_BOOL 0 -#define RANK_SCHAR 1 -#define RANK_UCHAR 1 -#define RANK_CHAR 1 -#define RANK_SHORT 2 -#define RANK_USHORT 2 -#define RANK_INT 3 -#define RANK_UINT 3 -#define RANK_LONG 4 -#define RANK_ULONG 4 -#define RANK_LLONG 5 -#define RANK_ULLONG 5 -#define RANK_FLOAT 6 -#define RANK_DOUBLE 7 -#define RANK_LDOUBLE 8 - -/* - * Initializaion of type pointers were done with - * a C99 initilizator '... = &(Type) {...', but - * c compiler in Plan9 gives error with this - * syntax, so I have switched it to this ugly form - * I hope I will change it again in the future - */ - -static Type types[] = { - { /* 0 = voidtype */ - .op = VOID, - .letter = L_VOID, - }, - { /* 1 = pvoidtype */ - .op = PTR, - .letter = L_POINTER, - .prop = TDEFINED, - .type = &types[5], /* chartype */ - .size = 4, - .align = 4, - }, - { /* 2 = booltype */ - .op = INT, - .letter = L_BOOL, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 1, - .align = 1, - .n.rank = RANK_BOOL, - }, - { /* 3 = schartype */ - .op = INT, - .letter = L_INT8, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 1, - .align = 1, - .n.rank = RANK_SCHAR, - }, - { /* 4 = uchartype */ - .op = INT, - .letter = L_UINT8, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 1, - .align = 1, - .n.rank = RANK_UCHAR, - }, - { /* 5 = chartype */ - .op = INT, - .letter = L_INT8, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 1, - .align = 1, - .n.rank = RANK_CHAR, - }, - { /* 6 = ushortype */ - .op = INT, - .letter = L_UINT16, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 2, - .align = 2, - .n.rank = RANK_USHORT, - }, - { /* 7 = shortype */ - .op = INT, - .letter = L_INT16, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 2, - .align = 2, - .n.rank = RANK_SHORT, - }, - { /* 8 = uinttype */ - .op = INT, - .letter = L_UINT32, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 4, - .align = 4, - .n.rank = RANK_UINT, - }, - { /* 9 = inttype */ - .op = INT, - .letter = L_INT32, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 4, - .align = 4, - .n.rank = RANK_INT, - }, - { /* 10 = longtype */ - .op = INT, - .letter = L_INT32, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 4, - .align = 4, - .n.rank = RANK_LONG, - }, - { /* 11 = ulongtype */ - .op = INT, - .letter = L_UINT32, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 4, - .align = 4, - .n.rank = RANK_ULONG, - }, - { /* 12 = ullongtype */ - .op = INT, - .letter = L_UINT64, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 8, - .align = 4, - .n.rank = RANK_ULLONG, - }, - { /* 13 = llongtype */ - .op = INT, - .letter = L_INT64, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 8, - .align = 4, - .n.rank = RANK_LLONG, - }, - { /* 14 = floattype */ - .op = FLOAT, - .letter = L_FLOAT, - .prop = TDEFINED | TARITH, - .size = 4, - .align = 4, - .n.rank = RANK_FLOAT, - }, - { /* 15 = doubletype */ - .op = FLOAT, - .letter = L_DOUBLE, - .prop = TDEFINED | TARITH, - .size = 8, - .align = 4, - .n.rank = RANK_DOUBLE, - }, - { /* 16 = ldoubletype */ - .op = FLOAT, - .letter = L_LDOUBLE, - .prop = TDEFINED | TARITH, - .size = 12, - .align = 4, - .n.rank = RANK_LDOUBLE, - }, - { /* 17 = sizettype */ - .op = INT, - .letter = L_UINT32, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 4, - .align = 4, - .n.rank = RANK_UINT, - }, - { /* 18 = ellipsis */ - .op = ELLIPSIS, - .letter = L_ELLIPSIS, - .prop = TDEFINED, - }, - { /* 19 = pdifftype */ - .op = INT, - .letter = L_INT32, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 4, - .align = 4, - .n.rank = RANK_INT, - }, - { /* 20 = va_list_type */ - .op = PTR, - .letter = L_POINTER, - .prop = TDEFINED, - .size = 4, - .align = 4, - }, -}; - - -Type *voidtype = &types[0], *pvoidtype = &types[1], - *booltype = &types[2], *schartype = &types[3], - *uchartype = &types[4], *chartype = &types[5], - *ushortype = &types[6], *shortype = &types[7], - *uinttype = &types[8], *inttype = &types[9], - *longtype = &types[10], *ulongtype = &types[11], - *ullongtype = &types[12], *llongtype = &types[13], - *floattype = &types[14], *doubletype = &types[15], - *ldoubletype = &types[16], - *sizettype = &types[17], *pdifftype = &types[19], - *ellipsistype = &types[18], *va_list_type = &types[20]; - - - -static Symbol dummy0 = {.u.i = 0, .type = &types[9]}, - dummy1 = {.u.i = 1, .type = &types[9]}; -Symbol *zero = &dummy0, *one = &dummy1; - -void -iarch(void) -{ -} - -int -valid_va_list(Type *tp) -{ - return eqtype(tp, va_list_type, 1); -} diff --git a/cc1/arch/qbe/arch.c b/cc1/arch/qbe/arch.c @@ -1,223 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -static char sccsid[] = "@(#) ./cc1/arch/qbe/arch.c"; -#include <stdio.h> - -#include "../../../inc/sysincludes.h" -#include "../../../inc/cc.h" -#include "../../cc1.h" - -#define RANK_BOOL 0 -#define RANK_SCHAR 1 -#define RANK_UCHAR 1 -#define RANK_CHAR 1 -#define RANK_SHORT 2 -#define RANK_USHORT 2 -#define RANK_INT 3 -#define RANK_UINT 3 -#define RANK_LONG 4 -#define RANK_ULONG 4 -#define RANK_LLONG 5 -#define RANK_ULLONG 5 -#define RANK_FLOAT 6 -#define RANK_DOUBLE 7 -#define RANK_LDOUBLE 8 - -/* - * Initializaion of type pointers were done with - * a C99 initilizator '... = &(Type) {...', but - * c compiler in Plan9 gives error with this - * syntax, so I have switched it to this ugly form - * I hope I will change it again in the future - */ - -static Type types[] = { - { /* 0 = voidtype */ - .op = VOID, - .letter = L_VOID, - }, - { /* 1 = pvoidtype */ - .op = PTR, - .letter = L_POINTER, - .prop = TDEFINED, - .type = &types[5], /* char type */ - .size = 8, - .align = 8, - }, - { /* 2 = booltype */ - .op = INT, - .letter = L_BOOL, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 1, - .align = 1, - .n.rank = RANK_BOOL, - }, - { /* 3 = schartype */ - .op = INT, - .letter = L_INT8, - .prop = TDEFINED | TINTEGER | TARITH | SIGNED, - .size = 1, - .align = 1, - .n.rank = RANK_SCHAR, - }, - { /* 4 = uchartype */ - .op = INT, - .letter = L_UINT8, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 1, - .align = 1, - .n.rank = RANK_UCHAR, - }, - { /* 5 = chartype */ - .op = INT, - .letter = L_INT8, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 1, - .align = 1, - .n.rank = RANK_CHAR, - }, - { /* 6 = ushortype */ - .op = INT, - .letter = L_UINT16, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 2, - .align = 2, - .n.rank = RANK_USHORT, - }, - { /* 7 = shortype */ - .op = INT, - .letter = L_INT16, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 2, - .align = 2, - .n.rank = RANK_SHORT, - }, - { /* 8 = uinttype */ - .op = INT, - .letter = L_UINT32, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 4, - .align = 4, - .n.rank = RANK_UINT, - }, - { /* 9 = inttype */ - .op = INT, - .letter = L_INT32, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 4, - .align = 4, - .n.rank = RANK_INT, - }, - { /* 10 = longtype */ - .op = INT, - .letter = L_INT64, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 8, - .align = 8, - .n.rank = RANK_LONG, - }, - { /* 11 = ulongtype */ - .op = INT, - .letter = L_UINT64, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 8, - .align = 8, - .n.rank = RANK_ULONG, - }, - { /* 12 = ullongtype */ - .op = INT, - .letter = L_UINT64, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 8, - .align = 8, - .n.rank = RANK_ULLONG, - }, - { /* 13 = llongtype */ - .op = INT, - .letter = L_INT64, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 8, - .align = 8, - .n.rank = RANK_LLONG, - }, - { /* 14 = floattype */ - .op = FLOAT, - .letter = L_FLOAT, - .prop = TDEFINED | TARITH, - .size = 4, - .align = 4, - .n.rank = RANK_FLOAT, - }, - { /* 15 = doubletype */ - .op = FLOAT, - .letter = L_DOUBLE, - .prop = TDEFINED | TARITH, - .size = 8, - .align = 8, - .n.rank = RANK_DOUBLE, - }, - { /* 16 = ldoubletype */ - .op = FLOAT, - .letter = L_DOUBLE, - .prop = TDEFINED | TARITH, - .size = 8, - .align = 8, - .n.rank = RANK_DOUBLE, - }, - { /* 17 = sizettype */ - .op = INT, - .letter = L_UINT64, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 8, - .align = 8, - .n.rank = RANK_UINT, - }, - { /* 18 = ellipsis */ - .op = ELLIPSIS, - .letter = L_ELLIPSIS, - .prop = TDEFINED, - }, - { /* 19 = pdifftype */ - .op = INT, - .letter = L_INT64, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 8, - .align = 8, - .n.rank = RANK_LONG, - }, - { /* 20 = va_type */ - .op = STRUCT, - .letter = L_VA_ARG, - .prop = TDEFINED, - .size = 24, - .align = 8, - }, -}; - -Type *voidtype = &types[0], *pvoidtype = &types[1], - *booltype = &types[2], *schartype = &types[3], - *uchartype = &types[4], *chartype = &types[5], - *ushortype = &types[6], *shortype = &types[7], - *uinttype = &types[8], *inttype = &types[9], - *longtype = &types[10], *ulongtype = &types[11], - *ullongtype = &types[12], *llongtype = &types[13], - *floattype = &types[14], *doubletype = &types[15], - *ldoubletype = &types[16], - *sizettype = &types[17], *pdifftype = &types[19], - *ellipsistype = &types[18], *va_type = &types[20], - *va_list_type; - -static Symbol dummy0 = {.u.i = 0, .type = &types[9]}, - dummy1 = {.u.i = 1, .type = &types[9]}; -Symbol *zero = &dummy0, *one = &dummy1; - -void -iarch(void) -{ - va_list_type = mktype(va_type, ARY, 1, NULL); -} - -int -valid_va_list(Type *tp) -{ - return tp->op == PTR && eqtype(tp->type, va_type, 1); -} diff --git a/cc1/arch/z80/arch.c b/cc1/arch/z80/arch.c @@ -1,222 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -static char sccsid[] = "@(#) ./cc1/arch/z80/arch.c"; -#include <stdio.h> - -#include "../../../inc/sysincludes.h" -#include "../../../inc/cc.h" -#include "../../cc1.h" - -#define RANK_BOOL 0 -#define RANK_SCHAR 1 -#define RANK_UCHAR 1 -#define RANK_CHAR 1 -#define RANK_SHORT 2 -#define RANK_USHORT 2 -#define RANK_INT 3 -#define RANK_UINT 3 -#define RANK_LONG 4 -#define RANK_ULONG 4 -#define RANK_LLONG 5 -#define RANK_ULLONG 5 -#define RANK_FLOAT 6 -#define RANK_DOUBLE 7 -#define RANK_LDOUBLE 8 - -/* - * Initializaion of type pointers were done with - * a C99 initilizator '... = &(Type) {...', but - * c compiler in Plan9 gives error with this - * syntax, so I have switched it to this ugly form - * I hope I will change it again in the future - */ - -static Type types[] = { - { /* 0 = voidtype */ - .op = VOID, - .letter = L_VOID, - }, - { /* 1 = pvoidtype */ - .op = PTR, - .letter = L_POINTER, - .prop = TDEFINED, - .type = &types[5], /* char type */ - .size = 2, - .align = 2, - }, - { /* 2 = booltype */ - .op = INT, - .letter = L_BOOL, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 1, - .align = 1, - .n.rank = RANK_BOOL, - }, - { /* 3 = schartype */ - .op = INT, - .letter = L_INT8, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 1, - .align = 1, - .n.rank = RANK_SCHAR, - }, - { /* 4 = uchartype */ - .op = INT, - .letter = L_UINT8, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 1, - .align = 1, - .n.rank = RANK_UCHAR, - }, - { /* 5 = chartype */ - .op = INT, - .letter = L_UINT8, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 1, - .align = 1, - .n.rank = RANK_CHAR, - }, - { /* 6 = ushortype */ - .op = INT, - .letter = L_UINT16, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 2, - .align = 1, - .n.rank = RANK_USHORT, - }, - { /* 7 = shortype */ - .op = INT, - .letter = L_INT16, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 2, - .align = 1, - .n.rank = RANK_SHORT, - }, - { /* 8 = uinttype */ - .op = INT, - .letter = L_UINT16, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 2, - .align = 1, - .n.rank = RANK_UINT, - }, - { /* 9 = inttype */ - .op = INT, - .letter = L_INT16, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 2, - .align = 1, - .n.rank = RANK_INT, - }, - { /* 10 = longtype */ - .op = INT, - .letter = L_INT32, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 4, - .align = 1, - .n.rank = RANK_LONG, - }, - { /* 11 = ulongtype */ - .op = INT, - .letter = L_UINT32, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 4, - .align = 1, - .n.rank = RANK_ULONG, - }, - { /* 12 = ullongtype */ - .op = INT, - .letter = L_UINT64, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 8, - .align = 1, - .n.rank = RANK_ULLONG, - }, - { /* 13 = llongtype */ - .op = INT, - .letter = L_INT64, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 8, - .align = 1, - .n.rank = RANK_LLONG, - }, - { /* 14 = floattype */ - .op = FLOAT, - .letter = L_FLOAT, - .prop = TDEFINED | TARITH, - .size = 4, - .align = 1, - .n.rank = RANK_FLOAT, - }, - { /* 15 = doubletype */ - .op = FLOAT, - .letter = L_DOUBLE, - .prop = TDEFINED | TARITH, - .size = 8, - .align = 1, - .n.rank = RANK_DOUBLE, - }, - { /* 16 = ldoubletype */ - .op = FLOAT, - .letter = L_LDOUBLE, - .prop = TDEFINED | TARITH, - .size = 16, - .align = 1, - .n.rank = RANK_LDOUBLE, - }, - { /* 17 = sizettype */ - .op = INT, - .letter = L_UINT16, - .prop = TDEFINED | TINTEGER | TARITH, - .size = 2, - .align = 1, - .n.rank = RANK_UINT, - }, - { /* 18 = ellipsis */ - .op = ELLIPSIS, - .letter = L_ELLIPSIS, - .prop = TDEFINED, - }, - { /* 7 = pdifftype */ - .op = INT, - .letter = L_INT16, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, - .size = 2, - .align = 1, - .n.rank = RANK_SHORT, - }, - { /* 20 = va_list_type */ - .op = PTR, - .letter = L_POINTER, - .prop = TDEFINED, - .size = 2, - .align = 1, - } -}; - -Type *voidtype = &types[0], *pvoidtype = &types[1], - *booltype = &types[2], *schartype = &types[3], - *uchartype = &types[4], *chartype = &types[5], - *ushortype = &types[6], *shortype = &types[7], - *uinttype = &types[8], *inttype = &types[9], - *longtype = &types[10], *ulongtype = &types[11], - *ullongtype = &types[12], *llongtype = &types[13], - *floattype = &types[14], *doubletype = &types[15], - *ldoubletype = &types[16], - *sizettype = &types[17], *pdifftype = &types[19], - *ellipsistype = &types[18], *va_list_type = &types[20]; - - -static Symbol dummy0 = {.u.i = 0, .type = &types[9]}, - dummy1 = {.u.i = 1, .type = &types[9]}; -Symbol *zero = &dummy0, *one = &dummy1; - -void -iarch(void) -{ -} - -int -valid_va_list(Type *tp) -{ - return eqtype(tp, va_list_type, 1); -} diff --git a/cc1/cpp.c b/cc1/cpp.c @@ -11,7 +11,6 @@ static char sccsid[] = "@(#) ./cc1/cpp.c"; #include "../inc/cc.h" #include "cc1.h" -extern char *sysincludes[]; static char *argp, *macroname; static unsigned arglen; static unsigned ncmdlines; @@ -512,10 +511,6 @@ include(void) if (includefile(*bp, file, filelen)) goto its_done; } - for (bp = sysincludes; *bp; ++bp) { - if (includefile(*bp, file, filelen)) - goto its_done; - } cpperror("included file '%s' not found", file); its_done: diff --git a/cc1/gendep.sh b/cc1/gendep.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +set -e + +rm -f makefile +trap "rm -f $$.mk" 0 2 3 + +re='\([^-]*\)-\([^-]*\)-\([^-]*\)-\([^-]*\)' + +echo $@ | +tr ' ' '\n' | +sed "s/$re/\1-\2/" | +sort -u | +(cat Makefile +echo +while read i +do + cat <<EOF +all: cc1-$i +OBJ-$i= \$(OBJ) target/$i/arch.o +\$(OBJ-$i): \$(HDR) +cc1-$i: \$(OBJ-$i) \$(LIBDIR)/libcc.a + \$(CC) \$(SCC_LDFLAGS) \$(OBJ-$i) -lcc -o \$@ + +EOF + echo +done) > $$.mk && mv $$.mk makefile diff --git a/cc1/target/amd64-sysv/arch.c b/cc1/target/amd64-sysv/arch.c @@ -0,0 +1,222 @@ +/* See LICENSE file for copyright and license details. */ +static char sccsid[] = "@(#) ./cc1/arch/amd64-sysv/arch.c"; +#include <stdio.h> + +#include "../../../inc/cc.h" +#include "../../cc1.h" + +#define RANK_BOOL 0 +#define RANK_SCHAR 1 +#define RANK_UCHAR 1 +#define RANK_CHAR 1 +#define RANK_SHORT 2 +#define RANK_USHORT 2 +#define RANK_INT 3 +#define RANK_UINT 3 +#define RANK_LONG 4 +#define RANK_ULONG 4 +#define RANK_LLONG 5 +#define RANK_ULLONG 5 +#define RANK_FLOAT 6 +#define RANK_DOUBLE 7 +#define RANK_LDOUBLE 8 + +/* + * Initializaion of type pointers were done with + * a C99 initilizator '... = &(Type) {...', but + * c compiler in Plan9 gives error with this + * syntax, so I have switched it to this ugly form + * I hope I will change it again in the future + */ + +static Type types[] = { + { /* 0 = voidtype */ + .op = VOID, + .letter = L_VOID, + }, + { /* 1 = pvoidtype */ + .op = PTR, + .letter = L_POINTER, + .prop = TDEFINED, + .type = &types[5], /* chartype */ + .size = 8, + .align = 8, + }, + { /* 2 = booltype */ + .op = INT, + .letter = L_BOOL, + .prop = TDEFINED | TINTEGER | TARITH, + .size = 1, + .align = 1, + .n.rank = RANK_BOOL, + }, + { /* 3 = schartype */ + .op = INT, + .letter = L_INT8, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, + .size = 1, + .align = 1, + .n.rank = RANK_SCHAR, + }, + { /* 4 = uchartype */ + .op = INT, + .letter = L_UINT8, + .prop = TDEFINED | TINTEGER | TARITH, + .size = 1, + .align = 1, + .n.rank = RANK_UCHAR, + }, + { /* 5 = chartype */ + .op = INT, + .letter = L_INT8, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, + .size = 1, + .align = 1, + .n.rank = RANK_CHAR, + }, + { /* 6 = ushortype */ + .op = INT, + .letter = L_UINT16, + .prop = TDEFINED | TINTEGER | TARITH, + .size = 2, + .align = 2, + .n.rank = RANK_USHORT, + }, + { /* 7 = shortype */ + .op = INT, + .letter = L_INT16, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, + .size = 2, + .align = 2, + .n.rank = RANK_SHORT, + }, + { /* 8 = uinttype */ + .op = INT, + .letter = L_UINT32, + .prop = TDEFINED | TINTEGER | TARITH, + .size = 4, + .align = 4, + .n.rank = RANK_UINT, + }, + { /* 9 = inttype */ + .op = INT, + .letter = L_INT32, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, + .size = 4, + .align = 4, + .n.rank = RANK_INT, + }, + { /* 10 = longtype */ + .op = INT, + .letter = L_INT64, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, + .size = 8, + .align = 8, + .n.rank = RANK_LONG, + }, + { /* 11 = ulongtype */ + .op = INT, + .letter = L_UINT64, + .prop = TDEFINED | TINTEGER | TARITH, + .size = 8, + .align = 8, + .n.rank = RANK_ULONG, + }, + { /* 12 = ullongtype */ + .op = INT, + .letter = L_UINT64, + .prop = TDEFINED | TINTEGER | TARITH, + .size = 8, + .align = 8, + .n.rank = RANK_ULLONG, + }, + { /* 13 = llongtype */ + .op = INT, + .letter = L_INT64, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, + .size = 8, + .align = 8, + .n.rank = RANK_LLONG, + }, + { /* 14 = floattype */ + .op = FLOAT, + .letter = L_FLOAT, + .prop = TDEFINED | TARITH, + .size = 4, + .align = 4, + .n.rank = RANK_FLOAT, + }, + { /* 15 = doubletype */ + .op = FLOAT, + .letter = L_DOUBLE, + .prop = TDEFINED | TARITH, + .size = 8, + .align = 8, + .n.rank = RANK_DOUBLE, + }, + { /* 16 = ldoubletype */ + .op = FLOAT, + .letter = L_LDOUBLE, + .prop = TDEFINED | TARITH, + .size = 16, + .align = 16, + .n.rank = RANK_LDOUBLE, + }, + { /* 17 = sizettype */ + .op = INT, + .letter = L_UINT64, + .prop = TDEFINED | TINTEGER | TARITH, + .size = 8, + .align = 8, + .n.rank = RANK_UINT, + }, + { /* 18 = ellipsis */ + .op = ELLIPSIS, + .letter = L_ELLIPSIS, + .prop = TDEFINED, + }, + { /* 19 = pdifftype */ + .op = INT, + .letter = L_INT64, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, + .size = 8, + .align = 8, + .n.rank = RANK_LONG, + }, + { /* 20 = va_type */ + .op = STRUCT, + .letter = L_VA_ARG, + .prop = TDEFINED, + .size = 24, + .align = 8, + }, +}; + +Type *voidtype = &types[0], *pvoidtype = &types[1], + *booltype = &types[2], *schartype = &types[3], + *uchartype = &types[4], *chartype = &types[5], + *ushortype = &types[6], *shortype = &types[7], + *uinttype = &types[8], *inttype = &types[9], + *longtype = &types[10], *ulongtype = &types[11], + *ullongtype = &types[12], *llongtype = &types[13], + *floattype = &types[14], *doubletype = &types[15], + *ldoubletype = &types[16], + *sizettype = &types[17], *pdifftype = &types[19], + *ellipsistype = &types[18], *va_type = &types[20], + *va_list_type; + +static Symbol dummy0 = {.u.i = 0, .type = &types[9]}, + dummy1 = {.u.i = 1, .type = &types[9]}; +Symbol *zero = &dummy0, *one = &dummy1; + +void +iarch(void) +{ + va_list_type = mktype(va_type, ARY, 1, NULL); +} + +int +valid_va_list(Type *tp) +{ + return tp->op == PTR && eqtype(tp->type, va_type, 1); +} diff --git a/cc1/target/i386-sysv/arch.c b/cc1/target/i386-sysv/arch.c @@ -0,0 +1,223 @@ +/* See LICENSE file for copyright and license details. */ +static char sccsid[] = "@(#) ./cc1/arch/i386-sysv/arch.c"; +#include <stdio.h> + +#include "../../../inc/cc.h" +#include "../../cc1.h" + +#define RANK_BOOL 0 +#define RANK_SCHAR 1 +#define RANK_UCHAR 1 +#define RANK_CHAR 1 +#define RANK_SHORT 2 +#define RANK_USHORT 2 +#define RANK_INT 3 +#define RANK_UINT 3 +#define RANK_LONG 4 +#define RANK_ULONG 4 +#define RANK_LLONG 5 +#define RANK_ULLONG 5 +#define RANK_FLOAT 6 +#define RANK_DOUBLE 7 +#define RANK_LDOUBLE 8 + +/* + * Initializaion of type pointers were done with + * a C99 initilizator '... = &(Type) {...', but + * c compiler in Plan9 gives error with this + * syntax, so I have switched it to this ugly form + * I hope I will change it again in the future + */ + +static Type types[] = { + { /* 0 = voidtype */ + .op = VOID, + .letter = L_VOID, + }, + { /* 1 = pvoidtype */ + .op = PTR, + .letter = L_POINTER, + .prop = TDEFINED, + .type = &types[5], /* chartype */ + .size = 4, + .align = 4, + }, + { /* 2 = booltype */ + .op = INT, + .letter = L_BOOL, + .prop = TDEFINED | TINTEGER | TARITH, + .size = 1, + .align = 1, + .n.rank = RANK_BOOL, + }, + { /* 3 = schartype */ + .op = INT, + .letter = L_INT8, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, + .size = 1, + .align = 1, + .n.rank = RANK_SCHAR, + }, + { /* 4 = uchartype */ + .op = INT, + .letter = L_UINT8, + .prop = TDEFINED | TINTEGER | TARITH, + .size = 1, + .align = 1, + .n.rank = RANK_UCHAR, + }, + { /* 5 = chartype */ + .op = INT, + .letter = L_INT8, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, + .size = 1, + .align = 1, + .n.rank = RANK_CHAR, + }, + { /* 6 = ushortype */ + .op = INT, + .letter = L_UINT16, + .prop = TDEFINED | TINTEGER | TARITH, + .size = 2, + .align = 2, + .n.rank = RANK_USHORT, + }, + { /* 7 = shortype */ + .op = INT, + .letter = L_INT16, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, + .size = 2, + .align = 2, + .n.rank = RANK_SHORT, + }, + { /* 8 = uinttype */ + .op = INT, + .letter = L_UINT32, + .prop = TDEFINED | TINTEGER | TARITH, + .size = 4, + .align = 4, + .n.rank = RANK_UINT, + }, + { /* 9 = inttype */ + .op = INT, + .letter = L_INT32, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, + .size = 4, + .align = 4, + .n.rank = RANK_INT, + }, + { /* 10 = longtype */ + .op = INT, + .letter = L_INT32, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, + .size = 4, + .align = 4, + .n.rank = RANK_LONG, + }, + { /* 11 = ulongtype */ + .op = INT, + .letter = L_UINT32, + .prop = TDEFINED | TINTEGER | TARITH, + .size = 4, + .align = 4, + .n.rank = RANK_ULONG, + }, + { /* 12 = ullongtype */ + .op = INT, + .letter = L_UINT64, + .prop = TDEFINED | TINTEGER | TARITH, + .size = 8, + .align = 4, + .n.rank = RANK_ULLONG, + }, + { /* 13 = llongtype */ + .op = INT, + .letter = L_INT64, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, + .size = 8, + .align = 4, + .n.rank = RANK_LLONG, + }, + { /* 14 = floattype */ + .op = FLOAT, + .letter = L_FLOAT, + .prop = TDEFINED | TARITH, + .size = 4, + .align = 4, + .n.rank = RANK_FLOAT, + }, + { /* 15 = doubletype */ + .op = FLOAT, + .letter = L_DOUBLE, + .prop = TDEFINED | TARITH, + .size = 8, + .align = 4, + .n.rank = RANK_DOUBLE, + }, + { /* 16 = ldoubletype */ + .op = FLOAT, + .letter = L_LDOUBLE, + .prop = TDEFINED | TARITH, + .size = 12, + .align = 4, + .n.rank = RANK_LDOUBLE, + }, + { /* 17 = sizettype */ + .op = INT, + .letter = L_UINT32, + .prop = TDEFINED | TINTEGER | TARITH, + .size = 4, + .align = 4, + .n.rank = RANK_UINT, + }, + { /* 18 = ellipsis */ + .op = ELLIPSIS, + .letter = L_ELLIPSIS, + .prop = TDEFINED, + }, + { /* 19 = pdifftype */ + .op = INT, + .letter = L_INT32, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, + .size = 4, + .align = 4, + .n.rank = RANK_INT, + }, + { /* 20 = va_list_type */ + .op = PTR, + .letter = L_POINTER, + .prop = TDEFINED, + .size = 4, + .align = 4, + }, +}; + + +Type *voidtype = &types[0], *pvoidtype = &types[1], + *booltype = &types[2], *schartype = &types[3], + *uchartype = &types[4], *chartype = &types[5], + *ushortype = &types[6], *shortype = &types[7], + *uinttype = &types[8], *inttype = &types[9], + *longtype = &types[10], *ulongtype = &types[11], + *ullongtype = &types[12], *llongtype = &types[13], + *floattype = &types[14], *doubletype = &types[15], + *ldoubletype = &types[16], + *sizettype = &types[17], *pdifftype = &types[19], + *ellipsistype = &types[18], *va_list_type = &types[20]; + + + +static Symbol dummy0 = {.u.i = 0, .type = &types[9]}, + dummy1 = {.u.i = 1, .type = &types[9]}; +Symbol *zero = &dummy0, *one = &dummy1; + +void +iarch(void) +{ +} + +int +valid_va_list(Type *tp) +{ + return eqtype(tp, va_list_type, 1); +} diff --git a/cc1/target/z80-scc/arch.c b/cc1/target/z80-scc/arch.c @@ -0,0 +1,221 @@ +/* See LICENSE file for copyright and license details. */ +static char sccsid[] = "@(#) ./cc1/arch/z80/arch.c"; +#include <stdio.h> + +#include "../../../inc/cc.h" +#include "../../cc1.h" + +#define RANK_BOOL 0 +#define RANK_SCHAR 1 +#define RANK_UCHAR 1 +#define RANK_CHAR 1 +#define RANK_SHORT 2 +#define RANK_USHORT 2 +#define RANK_INT 3 +#define RANK_UINT 3 +#define RANK_LONG 4 +#define RANK_ULONG 4 +#define RANK_LLONG 5 +#define RANK_ULLONG 5 +#define RANK_FLOAT 6 +#define RANK_DOUBLE 7 +#define RANK_LDOUBLE 8 + +/* + * Initializaion of type pointers were done with + * a C99 initilizator '... = &(Type) {...', but + * c compiler in Plan9 gives error with this + * syntax, so I have switched it to this ugly form + * I hope I will change it again in the future + */ + +static Type types[] = { + { /* 0 = voidtype */ + .op = VOID, + .letter = L_VOID, + }, + { /* 1 = pvoidtype */ + .op = PTR, + .letter = L_POINTER, + .prop = TDEFINED, + .type = &types[5], /* char type */ + .size = 2, + .align = 2, + }, + { /* 2 = booltype */ + .op = INT, + .letter = L_BOOL, + .prop = TDEFINED | TINTEGER | TARITH, + .size = 1, + .align = 1, + .n.rank = RANK_BOOL, + }, + { /* 3 = schartype */ + .op = INT, + .letter = L_INT8, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, + .size = 1, + .align = 1, + .n.rank = RANK_SCHAR, + }, + { /* 4 = uchartype */ + .op = INT, + .letter = L_UINT8, + .prop = TDEFINED | TINTEGER | TARITH, + .size = 1, + .align = 1, + .n.rank = RANK_UCHAR, + }, + { /* 5 = chartype */ + .op = INT, + .letter = L_UINT8, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, + .size = 1, + .align = 1, + .n.rank = RANK_CHAR, + }, + { /* 6 = ushortype */ + .op = INT, + .letter = L_UINT16, + .prop = TDEFINED | TINTEGER | TARITH, + .size = 2, + .align = 1, + .n.rank = RANK_USHORT, + }, + { /* 7 = shortype */ + .op = INT, + .letter = L_INT16, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, + .size = 2, + .align = 1, + .n.rank = RANK_SHORT, + }, + { /* 8 = uinttype */ + .op = INT, + .letter = L_UINT16, + .prop = TDEFINED | TINTEGER | TARITH, + .size = 2, + .align = 1, + .n.rank = RANK_UINT, + }, + { /* 9 = inttype */ + .op = INT, + .letter = L_INT16, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, + .size = 2, + .align = 1, + .n.rank = RANK_INT, + }, + { /* 10 = longtype */ + .op = INT, + .letter = L_INT32, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, + .size = 4, + .align = 1, + .n.rank = RANK_LONG, + }, + { /* 11 = ulongtype */ + .op = INT, + .letter = L_UINT32, + .prop = TDEFINED | TINTEGER | TARITH, + .size = 4, + .align = 1, + .n.rank = RANK_ULONG, + }, + { /* 12 = ullongtype */ + .op = INT, + .letter = L_UINT64, + .prop = TDEFINED | TINTEGER | TARITH, + .size = 8, + .align = 1, + .n.rank = RANK_ULLONG, + }, + { /* 13 = llongtype */ + .op = INT, + .letter = L_INT64, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, + .size = 8, + .align = 1, + .n.rank = RANK_LLONG, + }, + { /* 14 = floattype */ + .op = FLOAT, + .letter = L_FLOAT, + .prop = TDEFINED | TARITH, + .size = 4, + .align = 1, + .n.rank = RANK_FLOAT, + }, + { /* 15 = doubletype */ + .op = FLOAT, + .letter = L_DOUBLE, + .prop = TDEFINED | TARITH, + .size = 8, + .align = 1, + .n.rank = RANK_DOUBLE, + }, + { /* 16 = ldoubletype */ + .op = FLOAT, + .letter = L_LDOUBLE, + .prop = TDEFINED | TARITH, + .size = 16, + .align = 1, + .n.rank = RANK_LDOUBLE, + }, + { /* 17 = sizettype */ + .op = INT, + .letter = L_UINT16, + .prop = TDEFINED | TINTEGER | TARITH, + .size = 2, + .align = 1, + .n.rank = RANK_UINT, + }, + { /* 18 = ellipsis */ + .op = ELLIPSIS, + .letter = L_ELLIPSIS, + .prop = TDEFINED, + }, + { /* 7 = pdifftype */ + .op = INT, + .letter = L_INT16, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, + .size = 2, + .align = 1, + .n.rank = RANK_SHORT, + }, + { /* 20 = va_list_type */ + .op = PTR, + .letter = L_POINTER, + .prop = TDEFINED, + .size = 2, + .align = 1, + } +}; + +Type *voidtype = &types[0], *pvoidtype = &types[1], + *booltype = &types[2], *schartype = &types[3], + *uchartype = &types[4], *chartype = &types[5], + *ushortype = &types[6], *shortype = &types[7], + *uinttype = &types[8], *inttype = &types[9], + *longtype = &types[10], *ulongtype = &types[11], + *ullongtype = &types[12], *llongtype = &types[13], + *floattype = &types[14], *doubletype = &types[15], + *ldoubletype = &types[16], + *sizettype = &types[17], *pdifftype = &types[19], + *ellipsistype = &types[18], *va_list_type = &types[20]; + + +static Symbol dummy0 = {.u.i = 0, .type = &types[9]}, + dummy1 = {.u.i = 1, .type = &types[9]}; +Symbol *zero = &dummy0, *one = &dummy1; + +void +iarch(void) +{ +} + +int +valid_va_list(Type *tp) +{ + return eqtype(tp, va_list_type, 1); +} diff --git a/cc2/Makefile b/cc2/Makefile @@ -1,31 +1,37 @@ # See LICENSE file for copyright and license details. .POSIX: -CSTDINC = -I../inc/$(STD) +# Makefile is only used as a template for makefile. +# If you modify Makefile remember to run make dep include ../config.mk -OBJS = main.o parser.o peep.o symbol.o node.o code.o optm.o\ - arch/$(ARCH)/code.o arch/$(ARCH)/cgen.o \ - arch/$(ARCH)/types.o arch/$(ARCH)/optm.o +MOREFLAGS = -I../inc/$(STD) +LIBDIR = ../lib/cc -all: cc2-$(ARCH) +OBJ = main.o parser.o peep.o symbol.o node.o code.o optm.o +HDR = cc2.h ../inc/$(STD)/cstd.h ../inc/cc.h + +all: + +dep: + MKQBE=${MKQBE} ./gendep.sh $(TARGETS) + +$(LIBDIR)/libcc.a: + cd $(LIBDIR) && $(MAKE) main.o: error.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 error.h: cc2.h rm -f $@; trap 'rm -f $$$$.h' EXIT INT QUIT ;\ awk -f generror.awk cc2.h > $$$$.h && mv $$$$.h $@ -../lib/libcc.a: - cd ../lib && $(MAKE) -e - -cc2-$(ARCH): $(OBJS) ../lib/libcc.a - $(CC) $(SCC_LDFLAGS) $(OBJS) ../lib/libcc.a -o $@ - clean: - rm -f $(OBJS) + rm -f *.o + rm -f target/*/*.o rm -f cc2-* error.h + +distclean: clean + rm -f makefile + +include ../lib/cc/libdep.mk diff --git a/cc2/gendep.sh b/cc2/gendep.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +gentarget() +{ + + cat <<EOF +include target/$1/target.mk +\$(OBJ-$1): \$(HDR) +all: cc2-$1 +cc2-$1: \$(OBJ-$1) \$(LIBDIR)/libcc.a + \$(CC) \$(SCC_LDFLAGS) \$(OBJ-$1) -lcc -o \$@ + +EOF +} + +set -e + +rm -f makefile +trap "rm -f $$.mk" 0 2 3 + +re='\([^-]*\)-\([^-]*\)-\([^-]*\)-\([^-]*\)' + +echo $@ | +tr ' ' '\n' | +sed "s/$re/\1-\2/" | +sort -u | +(cat Makefile +while read i +do + if test ${MKQBE-0} -eq 1 + then + case $i in + amd64-sysv) + gentarget qbe_$i + ;; + esac + fi + gentarget $i +done) > $$.mk && mv $$.mk makefile diff --git a/cc2/arch/amd64-sysv/arch.h b/cc2/target/amd64-sysv/arch.h diff --git a/cc2/arch/amd64-sysv/cgen.c b/cc2/target/amd64-sysv/cgen.c diff --git a/cc2/arch/amd64-sysv/code.c b/cc2/target/amd64-sysv/code.c diff --git a/cc2/arch/amd64-sysv/optm.c b/cc2/target/amd64-sysv/optm.c diff --git a/cc2/target/amd64-sysv/target.mk b/cc2/target/amd64-sysv/target.mk @@ -0,0 +1,6 @@ + +OBJ-amd64-sysv = $(OBJ) \ + target/amd64-sysv/cgen.o \ + target/amd64-sysv/optm.o \ + target/amd64-sysv/code.o \ + target/amd64-sysv/types.o diff --git a/cc2/arch/amd64-sysv/types.c b/cc2/target/amd64-sysv/types.c diff --git a/cc2/arch/i386-sysv/arch.h b/cc2/target/i386-sysv/arch.h diff --git a/cc2/arch/i386-sysv/cgen.c b/cc2/target/i386-sysv/cgen.c diff --git a/cc2/arch/i386-sysv/code.c b/cc2/target/i386-sysv/code.c diff --git a/cc2/arch/i386-sysv/optm.c b/cc2/target/i386-sysv/optm.c diff --git a/cc2/target/i386-sysv/target.mk b/cc2/target/i386-sysv/target.mk @@ -0,0 +1,6 @@ + +OBJ-i386-sysv = $(OBJ) \ + target/i386-sysv/cgen.o \ + target/i386-sysv/optm.o \ + target/i386-sysv/code.o \ + target/i386-sysv/types.o diff --git a/cc2/arch/i386-sysv/types.c b/cc2/target/i386-sysv/types.c diff --git a/cc2/arch/qbe/arch.h b/cc2/target/qbe_amd64-sysv/arch.h diff --git a/cc2/arch/qbe/cgen.c b/cc2/target/qbe_amd64-sysv/cgen.c diff --git a/cc2/arch/qbe/code.c b/cc2/target/qbe_amd64-sysv/code.c diff --git a/cc2/arch/qbe/optm.c b/cc2/target/qbe_amd64-sysv/optm.c diff --git a/cc2/target/qbe_amd64-sysv/target.mk b/cc2/target/qbe_amd64-sysv/target.mk @@ -0,0 +1,6 @@ + +OBJ-qbe_amd64-sysv = $(OBJ) \ + target/qbe_amd64-sysv/cgen.o \ + target/qbe_amd64-sysv/optm.o \ + target/qbe_amd64-sysv/code.o \ + target/qbe_amd64-sysv/types.o diff --git a/cc2/arch/qbe/types.c b/cc2/target/qbe_amd64-sysv/types.c diff --git a/cc2/arch/z80/arch.h b/cc2/target/z80-scc/arch.h diff --git a/cc2/arch/z80/cgen.c b/cc2/target/z80-scc/cgen.c diff --git a/cc2/arch/z80/code.c b/cc2/target/z80-scc/code.c diff --git a/cc2/arch/z80/optm.c b/cc2/target/z80-scc/optm.c diff --git a/cc2/target/z80-scc/target.mk b/cc2/target/z80-scc/target.mk @@ -0,0 +1,7 @@ + +OBJ-z80-scc = $(OBJ) \ + target/z80-scc/cgen.o \ + target/z80-scc/optm.o \ + target/z80-scc/code.o \ + target/z80-scc/types.o + diff --git a/cc2/arch/z80/types.c b/cc2/target/z80-scc/types.c diff --git a/config.mk b/config.mk @@ -2,11 +2,21 @@ VERSION = 0.1 ## Customize below to fit your system -ARCHS = z80 i386-sysv amd64-sysv qbe -SYSS = linux openbsd -# default architecure used in nested makefiles -ARCH = qbe -SYS = linux +# TARGET is defined by backend-arch-abi-sys + +TARGETS = z80-scc-dos-com \ + amd64-sysv-linux-elf \ + i386-sysv-linux-elf \ + amd64-sysv-openbsd-elf + +# USEQBE selects QBE by default in the targets that support it +USEQBE = 1 + +#MKQBE enable build of +MKQBE = 1 + +TARGET = amd64-sys-linux-elf + DRIVER = posix # Can be c89 or c99 @@ -23,14 +33,11 @@ MANPREFIX = $(PREFIX)/share/man AS = as # for Plan9 add -D_SUSV2_SOURCE -SCC_CFLAGS = -DARCH=\"$(ARCH)\" \ - -DSYS=\"$(SYS)\" \ - $(CSTDINC) \ - -DPREFIX=\"$(PREFIX)\" \ +SCC_CFLAGS = $(MOREFLAGS) \ -g \ $(CFLAGS) -SCC_LDFLAGS = $(LDFLAGS) +SCC_LDFLAGS = -L$(LIBDIR)/ $(LDFLAGS) .s.o: $(AS) $< -o $@ @@ -40,3 +47,4 @@ SCC_LDFLAGS = $(LDFLAGS) .c: $(CC) $(SCC_CFLAGS) $(SCC_LDFLAGS) -o $@ $< + diff --git a/crt/Makefile b/crt/Makefile @@ -1,11 +0,0 @@ -.POSIX: - -include ../config.mk - -all: crt-$(ARCH)-$(SYS).o - -crt-$(ARCH)-$(SYS).o: $(ARCH)-$(SYS)/crt.o - ln -f $(ARCH)-$(SYS)/crt.o $@ - -clean: - rm -f */crt.o crt-*.o diff --git a/crt/qbe-linux/crt.s b/crt/qbe-linux/crt.s @@ -1,8 +0,0 @@ - .file "crt.s" - - .text - .global _start -_start: - call main - movl %eax, %edi - call exit diff --git a/crt/qbe-openbsd/crt.s b/crt/qbe-openbsd/crt.s @@ -1,23 +0,0 @@ - .file "crt.s" - - .section ".note.openbsd.ident", "a" - .p2align 2 - .long 8 - .long 4 - .long 1 - .ascii "OpenBSD\0" - .long 0 - .p2align 2 - - .text - .align 8 - .global _start -_start: - call main - movl %eax, %edi - call exit - - .data - .global __guard_local -__guard_local: - .long 0 diff --git a/crt/z80-linux/crt.s b/crt/z80-linux/crt.s @@ -1 +0,0 @@ -/* TODO */ diff --git a/crt/z80-openbsd/crt.s b/crt/z80-openbsd/crt.s @@ -1 +0,0 @@ -/* TODO */ diff --git a/driver/Makefile b/driver/Makefile @@ -0,0 +1,7 @@ +# See LICENSE file for copyright and license details. +.POSIX: + +include ../config.mk + +all dep clean distclean: + cd $(DRIVER) && $(MAKE) $@ diff --git a/driver/posix/Makefile b/driver/posix/Makefile @@ -3,24 +3,33 @@ include ../../config.mk -OBJS = scc.o +LIBDIR = ../../lib/cc -all: scc +OBJ = scc.o +HDR = config.h \ + ../../inc/cc.h \ + ../../inc/arg.h \ + ../../inc/syslibs.h \ + ../../inc/ldflags.h -$(OBJS): ../../inc/cc.h ../../inc/arg.h ../../inc/syslibs.h ../../inc/ldflags.h +all: scc -scc: $(OBJS) ../../lib/libcc.a - $(CC) $(SCC_LDFLAGS) $(OBJS) ../../lib/libcc.a -o $@ +dep: + PREFIX=$(PREFIX) USEQBE=$(USEQBE) ./gendep.sh $(TARGET) -../../inc/syslibs.h: ../../inc/syslibs.def.h - cp -f ../../inc/syslibs.def.h ../../inc/syslibs.h +$(OBJ): $(HDR) -../../inc/ldflags.h: ../../inc/ldflags.def.h - cp -f ../../inc/ldflags.def.h ../../inc/ldflags.h +scc: $(OBJ) $(LIBDIR)/libcc.a + $(CC) $(SCC_LDFLAGS) $(OBJ) -lcc -o $@ -../../lib/libcc.a: - cd ../../lib && $(MAKE) -e +$(LIBDIR)/libcc.a: + cd $(LIBDIR) && $(MAKE) clean: - rm -f $(OBJS) + rm -f $(OBJ) rm -f scc + +distclean: clean + rm -f config.h + +include ../../lib/cc/libdep.mk diff --git a/driver/posix/gendep.sh b/driver/posix/gendep.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +set -e + +rm -f config.h +trap "rm -f $$.h" 0 2 3 + +PREFIX=${PREFIX-$HOME} +USEQBE=${USEQBE:-1} + +echo $@ | +(IFS=- read arch abi sys format r +echo \#define PREFIX \"$PREFIX\" +echo \#define USEQBE $USEQBE +echo \#define ARCH \"$arch\" +echo \#define SYS \"$sys\" +echo \#define ABI \"$abi\" +echo \#define FORMAT \"$format\") > $$.h && mv $$.h config.h diff --git a/driver/posix/scc.c b/driver/posix/scc.c @@ -14,6 +14,7 @@ static char sccsid[] = "@(#) ./driver/posix/scc.c"; #include <stdlib.h> #include <string.h> +#include "config.h" #include "../../inc/arg.h" #include "../../inc/cc.h" #include "../../inc/syslibs.h" @@ -53,11 +54,12 @@ static struct tool { }; char *argv0; -static char *arch, *sys, *execpath, *objfile, *outfile; +static char *arch, *sys, *abi, *format; +static char *execpath, *objfile, *outfile; static char *tmpdir; static size_t tmpdirln; static struct items objtmp, objout; -static int Mflag, Eflag, Sflag, cflag, dflag, kflag, sflag; +static int Mflag, Eflag, Sflag, cflag, dflag, kflag, sflag, Qflag = USEQBE; static int devnullfd; extern int failure; @@ -99,7 +101,7 @@ static int inittool(int tool) { struct tool *t = &tools[tool]; - char *crt; + char *crt, *fmt; int n; if (t->init) @@ -108,7 +110,8 @@ inittool(int tool) switch (tool) { case CC1: /* FALLTHROUGH */ case CC2: - n = snprintf(t->bin, sizeof(t->bin), "%s-%s", t->cmd, arch); + fmt = (Qflag && tool == CC2) ? "%s-qbe_%s-%s" : "%s-%s-%s"; + n = snprintf(t->bin, sizeof(t->bin), fmt, t->cmd, arch, abi); if (n < 0 || n >= sizeof(t->bin)) die("scc: target tool name too long"); @@ -359,10 +362,10 @@ buildfile(char *file, int tool) nexttool = CC2; break; case CC2: - if (!arch || strcmp(arch, "qbe")) - nexttool = (Sflag || kflag) ? TEEAS : AS; - else + if (Qflag) nexttool = kflag ? TEEQBE : QBE; + else + nexttool = (Sflag || kflag) ? TEEAS : AS; break; case TEEQBE: nexttool = QBE; @@ -445,6 +448,10 @@ main(int argc, char *argv[]) arch = ARCH; if (!(sys = getenv("SYS"))) sys = SYS; + if (!(abi = getenv("ABI"))) + abi = ABI; + if (!(format = getenv("FORMAT"))) + format = FORMAT; if (!(execpath = getenv("SCCEXECPATH"))) execpath = PREFIX "/libexec/scc"; @@ -513,6 +520,12 @@ main(int argc, char *argv[]) case 'w': addarg(CC1, "-w"); break; + case 'q': + Qflag = 0; + break; + case 'Q': + Qflag = 1; + break; case '-': fprintf(stderr, "scc: ignored parameter --%s\n", EARGF(usage())); diff --git a/inc/Makefile b/inc/Makefile @@ -0,0 +1,32 @@ +# See LICENSE file for copyright and license details. +.POSIX: + +include ../config.mk + +HDR = ldflags.h sysincludes.h syslibs.h + +all: + +dep: $(HDR) + +ldflags.h: + rm -f $@ ; \ + trap "rm -f $$$$.h" 0 2 3; \ + cat < ldflags.def.h > $$$$.h; \ + mv $$$$.h $@ + +sysincludes.h: + rm -f $@ ; \ + trap "rm -f $$$$.h" 0 2 3; \ + sed 's,PREFIX,"$(PREFIX)",g' < sysincludes.def.h > $$$$.h && \ + mv $$$$.h $@ + +syslibs.h: + rm -f $@ ; \ + trap "rm -f $$$$.h" 0 2 3; \ + sed 's,PREFIX,"$(PREFIX)",g' < syslibs.def.h > $$$$.h && \ + mv $$$$.h $@ + +clean: +distclean: + rm -f $(HDR) diff --git a/inc/cc.h b/inc/cc.h @@ -11,10 +11,6 @@ extern int debug; #define DBGON() #endif -#ifndef PREFIX -#define PREFIX "/usr/local/" -#endif - #define TINT long long #define TUINT unsigned long long #define TFLOAT double diff --git a/inc/sysincludes.def.h b/inc/sysincludes.def.h @@ -1,6 +1,6 @@ char *sysincludes[] = { PREFIX "/include/scc/" , - PREFIX "/include/scc/bits/" ARCH "/", + PREFIX "/include/scc/bits/" TARGET "/", /* configure below your standard sys include paths */ PREFIX "/include/", PREFIX "/local/include/", diff --git a/lib/Makefile b/lib/Makefile @@ -1,15 +1,15 @@ # See LICENSE file for copyright and license details. .POSIX: -include ../config.mk - -OBJS = debug.o die.o newitem.o xcalloc.o xmalloc.o xrealloc.o xstrdup.o - -all: libcc.a +include ../config.mk -libcc.a: $(OBJS) - ar $(ARFLAGS) $@ $? - ranlib $@ +DIRS = cc -clean: - rm -f *.o *.a +all dep clean distclean: + @pwd=$$PWD; \ + for i in $(DIRS); \ + do \ + cd $$i; \ + $(MAKE) $@; \ + cd $$pwd; \ + done diff --git a/lib/c/Makefile b/lib/c/Makefile @@ -0,0 +1,7 @@ +# See LICENSE file for copyright and license details. +.POSIX: + +include ../../config.mk + +all dep clean distclean: + cd src && CC=scc $(MAKE) -e $@ diff --git a/lib/c/amd64-sysv-linux/Makefile b/lib/c/amd64-sysv-linux/Makefile @@ -0,0 +1,6 @@ +# See LICENSE file for copyright and license details. +.POSIX: + +include ../../../config.mk +include ../common.mk + diff --git a/lib/c/common.mk b/lib/c/common.mk @@ -0,0 +1,19 @@ +# See LICENSE file for copyright and license details. + +SRC=$(OBJ:.o=.c) + +all: libc.a + +libc.a: $(OBJ) + $(AR) $(ARFLAGS) $@ $? + ranlib $@ + +dep: + ../gendep.sh + +clean: + rm -f $(OBJ) + +distclean: clean + rm -f $(SRC) + rm -f makefile diff --git a/lib/c/gendep.sh b/lib/c/gendep.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +sed 's/\.o/.c/' ../obj.lst | +while read src +do + echo '#include "../src/'$src'"' > $src +done + +(cat Makefile +echo +printf "OBJ =" +while read i +do + printf " %s" $i +done < ../obj.lst +echo) > makefile + diff --git a/libc/include/assert.h b/lib/c/include/assert.h diff --git a/libc/include/bits/amd64-sysv/arch/limits.h b/lib/c/include/bits/amd64-sysv/arch/limits.h diff --git a/libc/include/bits/amd64-sysv/arch/signal.h b/lib/c/include/bits/amd64-sysv/arch/signal.h diff --git a/libc/include/bits/amd64-sysv/arch/stddef.h b/lib/c/include/bits/amd64-sysv/arch/stddef.h diff --git a/libc/include/bits/amd64-sysv/arch/stdint.h b/lib/c/include/bits/amd64-sysv/arch/stdint.h diff --git a/libc/include/bits/amd64-sysv/arch/stdio.h b/lib/c/include/bits/amd64-sysv/arch/stdio.h diff --git a/libc/include/bits/amd64-sysv/arch/stdlib.h b/lib/c/include/bits/amd64-sysv/arch/stdlib.h diff --git a/libc/include/bits/amd64-sysv/arch/string.h b/lib/c/include/bits/amd64-sysv/arch/string.h diff --git a/libc/include/bits/amd64-sysv/arch/time.h b/lib/c/include/bits/amd64-sysv/arch/time.h diff --git a/libc/include/bits/i386-sysv/arch/limits.h b/lib/c/include/bits/i386-sysv/arch/limits.h diff --git a/libc/include/bits/i386-sysv/arch/signal.h b/lib/c/include/bits/i386-sysv/arch/signal.h diff --git a/libc/include/bits/i386-sysv/arch/stddef.h b/lib/c/include/bits/i386-sysv/arch/stddef.h diff --git a/libc/include/bits/i386-sysv/arch/stdint.h b/lib/c/include/bits/i386-sysv/arch/stdint.h diff --git a/libc/include/bits/i386-sysv/arch/stdio.h b/lib/c/include/bits/i386-sysv/arch/stdio.h diff --git a/libc/include/bits/i386-sysv/arch/stdlib.h b/lib/c/include/bits/i386-sysv/arch/stdlib.h diff --git a/libc/include/bits/i386-sysv/arch/string.h b/lib/c/include/bits/i386-sysv/arch/string.h diff --git a/libc/include/bits/i386-sysv/arch/time.h b/lib/c/include/bits/i386-sysv/arch/time.h diff --git a/libc/include/bits/z80/arch/limits.h b/lib/c/include/bits/z80-dos/arch/limits.h diff --git a/libc/include/bits/z80/arch/signal.h b/lib/c/include/bits/z80-dos/arch/signal.h diff --git a/libc/include/bits/z80/arch/stddef.h b/lib/c/include/bits/z80-dos/arch/stddef.h diff --git a/libc/include/bits/z80/arch/stdint.h b/lib/c/include/bits/z80-dos/arch/stdint.h diff --git a/libc/include/bits/z80/arch/stdio.h b/lib/c/include/bits/z80-dos/arch/stdio.h diff --git a/libc/include/bits/z80/arch/stdlib.h b/lib/c/include/bits/z80-dos/arch/stdlib.h diff --git a/libc/include/bits/z80/arch/string.h b/lib/c/include/bits/z80-dos/arch/string.h diff --git a/libc/include/bits/z80/arch/time.h b/lib/c/include/bits/z80-dos/arch/time.h diff --git a/libc/include/ctype.h b/lib/c/include/ctype.h diff --git a/libc/include/errno.h b/lib/c/include/errno.h diff --git a/libc/include/limits.h b/lib/c/include/limits.h diff --git a/libc/include/locale.h b/lib/c/include/locale.h diff --git a/libc/include/signal.h b/lib/c/include/signal.h diff --git a/libc/include/stdarg.h b/lib/c/include/stdarg.h diff --git a/libc/include/stdbool.h b/lib/c/include/stdbool.h diff --git a/libc/include/stddef.h b/lib/c/include/stddef.h diff --git a/libc/include/stdint.h b/lib/c/include/stdint.h diff --git a/libc/include/stdio.h b/lib/c/include/stdio.h diff --git a/libc/include/stdlib.h b/lib/c/include/stdlib.h diff --git a/libc/include/string.h b/lib/c/include/string.h diff --git a/libc/include/time.h b/lib/c/include/time.h diff --git a/lib/c/obj.lst b/lib/c/obj.lst @@ -0,0 +1,49 @@ +assert.o +strcpy.o +strcmp.o +strlen.o +strchr.o +strrchr.o +strcat.o +strncmp.o +strncpy.o +strncat.o +strcoll.o +strxfrm.o +strstr.o +strspn.o +strcspn.o +strpbrk.o +strtok.o +memset.o +memcpy.o +memmove.o +memcmp.o +memchr.o +isalnum.o +isalpha.o +isascii.o +isblank.o +iscntrl.o +isdigit.o +isgraph.o +islower.o +isprint.o +ispunct.o +isspace.o +isupper.o +isxdigit.o +toupper.o +tolower.o +ctype.o +setlocale.o +localeconv.o +atoi.o +atexit.o +exit.o +printf.o +fprintf.o +vfprintf.o +realloc.o +calloc.o +malloc.o diff --git a/lib/c/src/Makefile b/lib/c/src/Makefile @@ -0,0 +1,24 @@ +# See LICENSE file for copyright and license details. +.POSIX: + +include ../../../config.mk + +OBJ = assert.o strcpy.o strcmp.o strlen.o strchr.o \ + strrchr.o strcat.o strncmp.o strncpy.o strncat.o strcoll.o \ + strxfrm.o strstr.o strspn.o strcspn.o strpbrk.o strtok.o \ + memset.o memcpy.o memmove.o memcmp.o memchr.o \ + isalnum.o isalpha.o isascii.o isblank.o iscntrl.o isdigit.o \ + isgraph.o islower.o isprint.o ispunct.o isspace.o isupper.o \ + isxdigit.o toupper.o tolower.o ctype.o setlocale.o \ + localeconv.o atoi.o atexit.o exit.o \ + printf.o fprintf.o vfprintf.o \ + realloc.o calloc.o malloc.o + +all: $(ARCH)-libc.a + +clean distclean: + rm -f *.o *-libc.a + +$(ARCH)-libc.a: $(OBJ) + $(AR) $(ARFLAGS) $@ $? + ranlib $@ diff --git a/libc/src/assert.c b/lib/c/src/assert.c diff --git a/libc/src/atexit.c b/lib/c/src/atexit.c diff --git a/libc/src/atoi.c b/lib/c/src/atoi.c diff --git a/libc/src/calloc.c b/lib/c/src/calloc.c diff --git a/libc/src/ctype.c b/lib/c/src/ctype.c diff --git a/libc/src/exit.c b/lib/c/src/exit.c diff --git a/libc/src/fprintf.c b/lib/c/src/fprintf.c diff --git a/libc/src/isalnum.c b/lib/c/src/isalnum.c diff --git a/libc/src/isalpha.c b/lib/c/src/isalpha.c diff --git a/libc/src/isascii.c b/lib/c/src/isascii.c diff --git a/libc/src/isblank.c b/lib/c/src/isblank.c diff --git a/libc/src/iscntrl.c b/lib/c/src/iscntrl.c diff --git a/libc/src/isdigit.c b/lib/c/src/isdigit.c diff --git a/libc/src/isgraph.c b/lib/c/src/isgraph.c diff --git a/libc/src/islower.c b/lib/c/src/islower.c diff --git a/libc/src/isprint.c b/lib/c/src/isprint.c diff --git a/libc/src/ispunct.c b/lib/c/src/ispunct.c diff --git a/libc/src/isspace.c b/lib/c/src/isspace.c diff --git a/libc/src/isupper.c b/lib/c/src/isupper.c diff --git a/libc/src/isxdigit.c b/lib/c/src/isxdigit.c diff --git a/libc/src/localeconv.c b/lib/c/src/localeconv.c diff --git a/libc/src/malloc.c b/lib/c/src/malloc.c diff --git a/libc/src/malloc.h b/lib/c/src/malloc.h diff --git a/libc/src/memchr.c b/lib/c/src/memchr.c diff --git a/libc/src/memcmp.c b/lib/c/src/memcmp.c diff --git a/libc/src/memcpy.c b/lib/c/src/memcpy.c diff --git a/libc/src/memmove.c b/lib/c/src/memmove.c diff --git a/libc/src/memset.c b/lib/c/src/memset.c diff --git a/libc/src/printf.c b/lib/c/src/printf.c diff --git a/libc/src/rand.c b/lib/c/src/rand.c diff --git a/libc/src/realloc.c b/lib/c/src/realloc.c diff --git a/libc/src/setlocale.c b/lib/c/src/setlocale.c diff --git a/libc/src/strcat.c b/lib/c/src/strcat.c diff --git a/libc/src/strchr.c b/lib/c/src/strchr.c diff --git a/libc/src/strcmp.c b/lib/c/src/strcmp.c diff --git a/libc/src/strcoll.c b/lib/c/src/strcoll.c diff --git a/libc/src/strcpy.c b/lib/c/src/strcpy.c diff --git a/libc/src/strcspn.c b/lib/c/src/strcspn.c diff --git a/libc/src/strlen.c b/lib/c/src/strlen.c diff --git a/libc/src/strncat.c b/lib/c/src/strncat.c diff --git a/libc/src/strncmp.c b/lib/c/src/strncmp.c diff --git a/libc/src/strncpy.c b/lib/c/src/strncpy.c diff --git a/libc/src/strpbrk.c b/lib/c/src/strpbrk.c diff --git a/libc/src/strrchr.c b/lib/c/src/strrchr.c diff --git a/libc/src/strspn.c b/lib/c/src/strspn.c diff --git a/libc/src/strstr.c b/lib/c/src/strstr.c diff --git a/libc/src/strtok.c b/lib/c/src/strtok.c diff --git a/libc/src/strxfrm.c b/lib/c/src/strxfrm.c diff --git a/libc/src/syscall.h b/lib/c/src/syscall.h diff --git a/libc/src/tolower.c b/lib/c/src/tolower.c diff --git a/libc/src/toupper.c b/lib/c/src/toupper.c diff --git a/libc/src/vfprintf.c b/lib/c/src/vfprintf.c diff --git a/lib/cc/Makefile b/lib/cc/Makefile @@ -0,0 +1,20 @@ +# See LICENSE file for copyright and license details. +.POSIX: + +include ../../config.mk + +LIBDIR = ./ + +all: libcc.a + +libcc.a: + ar $(ARFLAGS) $@ $? + ranlib $@ + +dep: + +clean: + rm -f *.o *.a + +distclean: clean +include libdep.mk diff --git a/lib/cc/debug.c b/lib/cc/debug.c @@ -0,0 +1,21 @@ +/* See LICENSE file for copyright and license details. */ +static char sccsid[] = "@(#) ./lib/debug.c"; +#include <stdarg.h> +#include <stdio.h> + +#include "../../inc/cc.h" + +int debug; + +void +dbg(const char *fmt, ...) +{ + if (!debug) + return; + va_list va; + va_start(va, fmt); + vfprintf(stderr, fmt, va); + putc('\n', stderr); + va_end(va); + return; +} diff --git a/lib/cc/die.c b/lib/cc/die.c @@ -0,0 +1,21 @@ +/* See LICENSE file for copyright and license details. */ +static char sccsid[] = "@(#) ./lib/die.c"; +#include <stdarg.h> +#include <stdlib.h> +#include <stdio.h> + +#include "../../inc/cc.h" + +int failure; + +void +die(const char *fmt, ...) +{ + failure = 1; + va_list va; + va_start(va, fmt); + vfprintf(stderr, fmt, va); + putc('\n', stderr); + va_end(va); + exit(1); +} diff --git a/lib/cc/libdep.mk b/lib/cc/libdep.mk @@ -0,0 +1,10 @@ + +LIB-OBJ = $(LIBDIR)/debug.o \ + $(LIBDIR)/die.o \ + $(LIBDIR)/newitem.o \ + $(LIBDIR)/xcalloc.o \ + $(LIBDIR)/xmalloc.o \ + $(LIBDIR)/xrealloc.o \ + $(LIBDIR)/xstrdup.o \ + +$(LIBDIR)/libcc.a: $(LIB-OBJ) diff --git a/lib/cc/newitem.c b/lib/cc/newitem.c @@ -0,0 +1,12 @@ +#include "../../inc/cc.h" + +void +newitem(struct items *items, char *item) +{ + if ((items->n + 1) < items->n) + die("newitem: overflow (%u + 1)", items->n); + + items->s = xrealloc(items->s, (items->n + 1) * sizeof(char **)); + items->s[items->n++] = item; +} + diff --git a/lib/cc/xcalloc.c b/lib/cc/xcalloc.c @@ -0,0 +1,14 @@ +/* See LICENSE file for copyright and license details. */ +static char sccsid[] = "@(#) ./lib/xcalloc.c"; +#include <stdlib.h> +#include "../../inc/cc.h" + +void * +xcalloc(size_t n, size_t size) +{ + void *p = calloc(n, size); + + if (!p) + die("out of memory"); + return p; +} diff --git a/lib/cc/xmalloc.c b/lib/cc/xmalloc.c @@ -0,0 +1,14 @@ +/* See LICENSE file for copyright and license details. */ +static char sccsid[] = "@(#) ./lib/xmalloc.c"; +#include <stdlib.h> +#include "../../inc/cc.h" + +void * +xmalloc(size_t size) +{ + void *p = malloc(size); + + if (!p) + die("out of memory"); + return p; +} diff --git a/lib/cc/xrealloc.c b/lib/cc/xrealloc.c @@ -0,0 +1,14 @@ +/* See LICENSE file for copyright and license details. */ +static char sccsid[] = "@(#) ./lib/xrealloc.c"; +#include <stdlib.h> +#include "../../inc/cc.h" + +void * +xrealloc(void *buff, size_t size) +{ + void *p = realloc(buff, size); + + if (!p) + die("out of memory"); + return p; +} diff --git a/lib/cc/xstrdup.c b/lib/cc/xstrdup.c @@ -0,0 +1,13 @@ +/* See LICENSE file for copyright and license details. */ +static char sccsid[] = "@(#) ./lib/xstrdup.c"; +#include <string.h> +#include "../../inc/cc.h" + +char * +xstrdup(const char *s) +{ + size_t len = strlen(s) + 1; + char *p = xmalloc(len); + + return memcpy(p, s, len); +} diff --git a/lib/crt/Makefile b/lib/crt/Makefile @@ -0,0 +1,11 @@ +.POSIX: + +include ../../config.mk + +all: crt-$(ARCH)-$(SYS).o + +crt-$(ARCH)-$(SYS).o: $(ARCH)-$(SYS)/crt.o + ln -f $(ARCH)-$(SYS)/crt.o $@ + +clean: + rm -f */crt.o crt-*.o diff --git a/crt/amd64-sysv-linux/crt.s b/lib/crt/amd64-sysv-linux/crt.s diff --git a/crt/amd64-sysv-openbsd/crt.s b/lib/crt/amd64-sysv-openbsd/crt.s diff --git a/crt/i386-sysv-linux/crt.s b/lib/crt/i386-sysv-linux/crt.s diff --git a/crt/i386-sysv-openbsd/crt.s b/lib/crt/i386-sysv-openbsd/crt.s diff --git a/lib/debug.c b/lib/debug.c @@ -1,21 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -static char sccsid[] = "@(#) ./lib/debug.c"; -#include <stdarg.h> -#include <stdio.h> - -#include "../inc/cc.h" - -int debug; - -void -dbg(const char *fmt, ...) -{ - if (!debug) - return; - va_list va; - va_start(va, fmt); - vfprintf(stderr, fmt, va); - putc('\n', stderr); - va_end(va); - return; -} diff --git a/lib/die.c b/lib/die.c @@ -1,21 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -static char sccsid[] = "@(#) ./lib/die.c"; -#include <stdarg.h> -#include <stdlib.h> -#include <stdio.h> - -#include "../inc/cc.h" - -int failure; - -void -die(const char *fmt, ...) -{ - failure = 1; - va_list va; - va_start(va, fmt); - vfprintf(stderr, fmt, va); - putc('\n', stderr); - va_end(va); - exit(1); -} diff --git a/lib/newitem.c b/lib/newitem.c @@ -1,12 +0,0 @@ -#include "../inc/cc.h" - -void -newitem(struct items *items, char *item) -{ - if ((items->n + 1) < items->n) - die("newitem: overflow (%u + 1)", items->n); - - items->s = xrealloc(items->s, (items->n + 1) * sizeof(char **)); - items->s[items->n++] = item; -} - diff --git a/lib/sys/Makefile b/lib/sys/Makefile @@ -0,0 +1,13 @@ +# See LICENSE file for copyright and license details. +.POSIX: + +include ../../config.mk + +all clean distclean: + pwd=$$PWD ;\ + for i in $(SYSS); \ + do \ + cd $$i; \ + $(MAKE) -e SYS=$i $@ ;\ + cd $$pwd; \ + done diff --git a/lib/sys/abi/amd64-sysv.sh b/lib/sys/abi/amd64-sysv.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# +# This job is very easy because app and kernel ABI are identical +# until the 4th parameter, so we only have to set the syscall +# number in rax + +awk '/^#/ {next} + {name=$2 ".s" + printf ".global %s\n" \ + "%s:\n" \ + "\tmovq\t$%d,%%rax\n" \ + "\tsyscall\n" \ + "\tret\n", $2, $2, $1 > name + close(name)}' syscall.lst diff --git a/lib/sys/amd64-sysv-linux/Makefile b/lib/sys/amd64-sysv-linux/Makefile @@ -0,0 +1,5 @@ +# See LICENSE file for copyright and license details. +.POSIX: + +include ../common.mk +ABI = amd64-sysv diff --git a/libc/src/sys/amd64-sysv-linux/syscall.lst b/lib/sys/amd64-sysv-linux/syscall.lst diff --git a/lib/sys/common.mk b/lib/sys/common.mk @@ -0,0 +1,13 @@ +# See LICENSE file for copyright and license details. +.POSIX: + +include ../../../config.mk + +all clean distclean: system.mk + $(MAKE) ABI=$(ABI) -f ../libsys.mk $@ + +system.mk: syscall.lst + rm -f $@; trap "rm -f $$$$.mk" 0 2 3; \ + awk 'BEGIN{printf "OBJ = "} \ + ! /^#/ {printf "%s.o ", $$2}' syscall.lst > $$$$.mk && \ + mv $$$$.mk $@ diff --git a/lib/sys/i386-sysv-linux/Makefile b/lib/sys/i386-sysv-linux/Makefile @@ -0,0 +1,4 @@ +# See LICENSE file for copyright and license details. +.POSIX: + +include ../Makefile.sys diff --git a/libc/src/sys/i386-sysv-linux/syscall.lst b/lib/sys/i386-sysv-linux/syscall.lst diff --git a/lib/sys/libsys.mk b/lib/sys/libsys.mk @@ -0,0 +1,24 @@ +# See LICENSE file for copyright and license details. +.POSIX: + +include ../../../config.mk +include system.mk + +ASM = $(OBJ:.o=.s) + +all: libsys.a + +libsys.a: $(OBJ) + $(AR) $(ARFLAGS) $@ $? + ranlib $@ + +$(ASM): syscall.lst + ../abi/$(ABI).sh + +clean: + rm -f $(ASM) + rm -f $(OBJ) + rm -f libsys.a + +distclean: clean + rm -f system.mk diff --git a/lib/sys/qbe-linux/Makefile b/lib/sys/qbe-linux/Makefile @@ -0,0 +1,5 @@ +# See LICENSE file for copyright and license details. +.POSIX: + +include ../common.mk +ABI=amd64-sysv diff --git a/libc/src/sys/qbe-linux/syscall.lst b/lib/sys/qbe-linux/syscall.lst diff --git a/lib/sys/z80-linux/Makefile b/lib/sys/z80-linux/Makefile @@ -0,0 +1,4 @@ +# See LICENSE file for copyright and license details. +.POSIX: + +include ../Makefile.sys diff --git a/libc/src/sys/z80-linux/syscall.lst b/lib/sys/z80-linux/syscall.lst diff --git a/lib/xcalloc.c b/lib/xcalloc.c @@ -1,14 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -static char sccsid[] = "@(#) ./lib/xcalloc.c"; -#include <stdlib.h> -#include "../inc/cc.h" - -void * -xcalloc(size_t n, size_t size) -{ - void *p = calloc(n, size); - - if (!p) - die("out of memory"); - return p; -} diff --git a/lib/xmalloc.c b/lib/xmalloc.c @@ -1,14 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -static char sccsid[] = "@(#) ./lib/xmalloc.c"; -#include <stdlib.h> -#include "../inc/cc.h" - -void * -xmalloc(size_t size) -{ - void *p = malloc(size); - - if (!p) - die("out of memory"); - return p; -} diff --git a/lib/xrealloc.c b/lib/xrealloc.c @@ -1,14 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -static char sccsid[] = "@(#) ./lib/xrealloc.c"; -#include <stdlib.h> -#include "../inc/cc.h" - -void * -xrealloc(void *buff, size_t size) -{ - void *p = realloc(buff, size); - - if (!p) - die("out of memory"); - return p; -} diff --git a/lib/xstrdup.c b/lib/xstrdup.c @@ -1,13 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -static char sccsid[] = "@(#) ./lib/xstrdup.c"; -#include <string.h> -#include "../inc/cc.h" - -char * -xstrdup(const char *s) -{ - size_t len = strlen(s) + 1; - char *p = xmalloc(len); - - return memcpy(p, s, len); -} diff --git a/libc/include/bits/qbe/arch/limits.h b/libc/include/bits/qbe/arch/limits.h @@ -1,17 +0,0 @@ -#define SCHAR_MAX 0x7F -#define SCHAR_MIN (-SCHAR_MIN-1) -#define CHAR_MAX 0x7F -#define CHAR_MIN (-CHAR_MAX-1) -#define UCHAR_MAX 0xFF -#define SHRT_MAX 0x7FFF -#define SHRT_MIN (-SHRT_MAX-1) -#define USHRT_MAX 0xFFFF -#define INT_MAX 0x7FFFFFFF -#define INT_MIN (-INT_MAX-1) -#define UINT_MAX 0xFFFFFFFF -#define LONG_MAX 0x7FFFFFFFFFFFFFFF -#define LONG_MIN (-LONG_MAX-1) -#define ULONG_MAX 0xFFFFFFFFFFFFFFFF -#define LLONG_MAX 0x7FFFFFFFFFFFFFFF -#define LLONG_MIN (-LLONG_MAX-1) -#define ULLONG_MAX 0xFFFFFFFFFFFFFFFF diff --git a/libc/include/bits/qbe/arch/signal.h b/libc/include/bits/qbe/arch/signal.h @@ -1,29 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -typedef int sig_atomic_t; - -#define SIG_ERR -1 -#define SIG_DFL 0 -#define SIG_IGN 1 - -#define SIGHUP 1 -#define SIGINT 2 -#define SIGQUIT 3 -#define SIGILL 4 -#define SIGABRT 6 -#define SIGFPE 8 -#define SIGKILL 9 -#define SIGUSR1 10 -#define SIGSEGV 11 -#define SIGUSR2 12 -#define SIGPIPE 13 -#define SIGALRM 14 -#define SIGTERM 15 -#define SIGCHLD 17 -#define SIGCONT 18 -#define SIGSTOP 19 -#define SIGSSTP 20 -#define SIGTTIN 21 -#define SIGTTOU 22 - -#define __NR_SIGNALS 23 diff --git a/libc/include/bits/qbe/arch/stddef.h b/libc/include/bits/qbe/arch/stddef.h @@ -1,16 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -#ifndef _SIZET -typedef unsigned long size_t; -#define _SIZET -#endif - -#ifndef _WCHAR_T -typedef int wchar_t; -#define _WCHAR_T -#endif - -#ifndef _PTRDIFF_T -typedef long ptrdiff_t; -#define _PTRDIFF_T -#endif diff --git a/libc/include/bits/qbe/arch/stdint.h b/libc/include/bits/qbe/arch/stdint.h @@ -1,117 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -#define INT8_MAX 0x7F -#define INT8_MIN (-INT8_MAX-1) -#define UINT8_MAX 0xFF - -#define INT16_MAX 0x7FFF -#define INT16_MIN (-INT16_MAX-1) -#define UINT16_MAX 0xFFFF - -#define INT32_MAX 0x7FFFFFFF -#define INT32_MIN (-INT32_MAX-1) -#define UINT32_MAX 0xFFFFFFFF - -#define INT64_MAX 0x7FFFFFFFFFFFFFFF -#define INT64_MIN (-INT64_MAX-1) -#define UINT64_MAX 0xFFFFFFFFFFFFFFFF - -#define INT_LEAST8_MIN INT8_MIN -#define INT_LEAST8_MAX INT8_MAX -#define UINT_LEAST8_MAX UINT8_MAX - -#define INT_LEAST16_MIN INT16_MIN -#define INT_LEAST16_MAX INT16_MAX -#define UINT_LEAST16_MAX UINT16_MAX - -#define INT_LEAST32_MIN INT32_MIN -#define INT_LEAST32_MAX INT32_MAX -#define UINT_LEAST32_MAX UINT32_MAX - -#define INT_LEAST64_MIN INT64_MIN -#define INT_LEAST64_MAX INT64_MAX -#define UINT_LEAST64_MAX UINT64_MAX - -#define INT_FAST8_MIN INT32_MIN -#define INT_FAST8_MAX INT32_MAX -#define UINT_FAST8_MAX UINT32_MAX - -#define INT_FAST16_MIN INT32_MIN -#define INT_FAST16_MAX INT32_MAX -#define UINT_FAST16_MAX UINT32_MAX - -#define INT_FAST32_MIN INT32_MIN -#define INT_FAST32_MAX INT32_MAX -#define UINT_FAST32_MAX UINT32_MAX - -#define INT_FAST64_MIN INT64_MIN -#define INT_FAST64_MAX INT64_MAX -#define UINT_FAST64_MAX UINT64_MAX - -#define INTPTR_MIN INT64_MIN -#define INTPTR_MAX INT64_MAX -#define UINTPTR_MAX UINT64_MAX - -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX -#define UINTMAX_MAX UINT64_MAX - -#define PTRDIFF_MIN INT64_MIN -#define PTRDIFF_MAX INT64_MAX - -#define SIG_ATOMIC_MIN INT32_MIN -#define SIG_ATOMIC_MAX INT32_MAX - -#define SIZE_MAX UINT64_MAX - -#define WCHAR_MIN INT32_MIN -#define WCHAR_MAX INT32_MAX - -#define INT8_C(x) x -#define INT16_C(x) x -#define INT32_C(x) x -#define INT64_C(x) x ## L - -#define UINT8_C(x) x -#define UINT16_C(x) x -#define UINT32_C(x) x ## U -#define UINT64_C(x) x ## UL - -#define INTMAX_C(x) x ## L -#define UINTMAX_C(x) x ## UL - -typedef signed char int8_t; -typedef short int16_t; -typedef int int32_t; -typedef long int64_t; - -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned uint32_t; -typedef unsigned long uint64_t; - -typedef signed char int8_least_t; -typedef short int16_least_t; -typedef int int32_least_t; -typedef long int64_least_t; - -typedef unsigned char uint8_least_t; -typedef unsigned short uint16_least_t; -typedef unsigned uint32_least_t; -typedef unsigned long uint64_least_t; - -typedef int int8_fast_t; -typedef int int16_fast_t; -typedef int int32_fast_t; -typedef long int64_fast_t; - -typedef unsigned uint8_fast_t; -typedef unsigned uint16_fast_t; -typedef unsigned uint32_fast_t; -typedef unsigned long uint64_fast_t; - -typedef long intptr_t; -typedef unsigned long uintptr_t; - -typedef long intmax_t; -typedef unsigned long uintmax_t; diff --git a/libc/include/bits/qbe/arch/stdio.h b/libc/include/bits/qbe/arch/stdio.h @@ -1,15 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -#ifndef _SIZET -typedef unsigned long size_t; -#define _SIZET -#endif - -#define BUFSIZ 512 -#define FILENAME_MAX 256 -#define FOPEN_MAX 16 - -#define TMP_MAX 25 -#define L_tmpnam 256 - -typedef int fpos_t; diff --git a/libc/include/bits/qbe/arch/stdlib.h b/libc/include/bits/qbe/arch/stdlib.h @@ -1,16 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -#ifndef _SIZET -typedef unsigned long size_t; -#define _SIZET -#endif - -#define EXIT_FAILURE 1 -#define EXIT_SUCCESS 0 - -#ifndef _WCHAR_T -typedef int wchar_t; -#define _WCHAR_T -#endif - -#define _ALIGNTYPE long double diff --git a/libc/include/bits/qbe/arch/string.h b/libc/include/bits/qbe/arch/string.h @@ -1,5 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -#ifndef _SIZET -typedef unsigned long size_t; -#endif diff --git a/libc/include/bits/qbe/arch/time.h b/libc/include/bits/qbe/arch/time.h @@ -1,8 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -#ifndef _SIZET -typedef unsigned long size_t; -#define _SIZET -#endif - -typedef long int time_t; diff --git a/libc/src/Makefile b/libc/src/Makefile @@ -1,44 +0,0 @@ -# See LICENSE file for copyright and license details. -.POSIX: - -include ../../config.mk - -SYSDIR = sys/$(ARCH)-$(SYS) -SYSINC = $(SYSDIR)/system.mk - -SYSINCLUDE = /dev/null -include $(SYSINCLUDE) - -LIBCOBJ = assert.o strcpy.o strcmp.o strlen.o strchr.o \ - strrchr.o strcat.o strncmp.o strncpy.o strncat.o strcoll.o \ - strxfrm.o strstr.o strspn.o strcspn.o strpbrk.o strtok.o \ - memset.o memcpy.o memmove.o memcmp.o memchr.o \ - isalnum.o isalpha.o isascii.o isblank.o iscntrl.o isdigit.o \ - isgraph.o islower.o isprint.o ispunct.o isspace.o isupper.o \ - isxdigit.o toupper.o tolower.o ctype.o setlocale.o \ - localeconv.o atoi.o atexit.o exit.o \ - printf.o fprintf.o vfprintf.o \ - realloc.o calloc.o malloc.o -LIBCSYSOBJ = $(SYSOBJ:%=$(SYSDIR)/%) -OBJ = $(LIBCOBJ) $(LIBCSYSOBJ) - -all: all.bootstrap -all.start: libc.a - -clean: clean.bootstrap -clean.start: - rm -f *.o libc.a - cd $(SYSDIR) && $(MAKE) clean - -all.bootstrap clean.bootstrap: $(SYSINC) - $(MAKE) -e SYSINCLUDE="$(SYSINC)" $(@:%.bootstrap=%.start) - -$(SYSINC): $(SYSDIR)/Makefile $(SYSDIR)/syscall.lst - cd $(SYSDIR) && $(MAKE) -e system.mk - -libc.a: $(SYSINC) $(OBJ) - $(AR) $(ARFLAGS) $@ $(OBJ) - ranlib $@ - -$(LIBCSYSOBJ): - cd $(SYSDIR) && $(MAKE) diff --git a/libc/src/sys/amd64-sysv-linux/Makefile b/libc/src/sys/amd64-sysv-linux/Makefile @@ -1,37 +0,0 @@ -# See LICENSE file for copyright and license details. -.POSIX: - -include ../../../../config.mk - -SYSTEMINC = /dev/null -include $(SYSTEMINC) -SYSGENINC = /dev/null -include $(SYSGENINC) - -GENASM = $(GENOBJ:.o=.s) -OBJ = - -all: all.bootstrap -all.start: $(SYSOBJ) - -clean: clean.bootstrap -clean.start: - rm -f *.o $(GENASM) system.mk sysgen.mk - -all.bootstrap clean.bootstrap: system.mk sysgen.mk - $(MAKE) -e SYSTEMINC=system.mk SYSGENINC=sysgen.mk \ - $(@:%.bootstrap=%.start) - -system.mk: Makefile syscall.lst - printf '%s ' 'SYSOBJ =' \ - "$$(awk '/^#/{next}{printf "%s.o ", $$2}' syscall.lst)" \ - $(OBJ) \ - > $@ - -sysgen.mk: syscall.lst - printf '%s ' 'GENOBJ =' \ - "$$(awk '/^#/{next}{printf "%s.o ", $$2}' syscall.lst)" \ - > $@ - -$(GENASM): syscall.lst - awk -f syscall.awk < syscall.lst diff --git a/libc/src/sys/amd64-sysv-linux/syscall.awk b/libc/src/sys/amd64-sysv-linux/syscall.awk @@ -1,12 +0,0 @@ -# This job is very easy because app and kernel ABI are identical -# until the 4th parameter, so we only have to set the syscall -# number in rax - -/^#/ {next} - {name=$2 ".s" - printf ".global %s\n" \ - "%s:\n" \ - "\tmovq\t$%d,%%rax\n" \ - "\tsyscall\n" \ - "\tret\n", $2, $2, $1 > name - close(name)} diff --git a/libc/src/sys/i386-sysv-linux/Makefile b/libc/src/sys/i386-sysv-linux/Makefile @@ -1,37 +0,0 @@ -# See LICENSE file for copyright and license details. -.POSIX: - -include ../../../../config.mk - -SYSTEMINC = /dev/null -include $(SYSTEMINC) -SYSGENINC = /dev/null -include $(SYSGENINC) - -GENASM = $(GENOBJ:.o=.s) -OBJ = - -all: all.bootstrap -all.start: $(SYSOBJ) - -clean: clean.bootstrap -clean.start: - rm -f *.o $(GENASM) system.mk sysgen.mk - -all.bootstrap clean.bootstrap: system.mk sysgen.mk - $(MAKE) -e SYSTEMINC=system.mk SYSGENINC=sysgen.mk \ - $(@:%.bootstrap=%.start) - -system.mk: Makefile syscall.lst - printf '%s ' 'SYSOBJ =' \ - "$$(awk '/^#/{next}{printf "%s.o ", $$2}' syscall.lst)" \ - $(OBJ) \ - > $@ - -sysgen.mk: syscall.lst - printf '%s ' 'GENOBJ =' \ - "$$(awk '/^#/{next}{printf "%s.o ", $$2}' syscall.lst)" \ - > $@ - -$(GENASM): syscall.lst - awk -f syscall.awk < syscall.lst diff --git a/libc/src/sys/qbe-linux/Makefile b/libc/src/sys/qbe-linux/Makefile @@ -1,37 +0,0 @@ -# See LICENSE file for copyright and license details. -.POSIX: - -include ../../../../config.mk - -SYSTEMINC = /dev/null -include $(SYSTEMINC) -SYSGENINC = /dev/null -include $(SYSGENINC) - -GENASM = $(GENOBJ:.o=.s) -OBJ = - -all: all.bootstrap -all.start: $(SYSOBJ) - -clean: clean.bootstrap -clean.start: - rm -f *.o $(GENASM) system.mk sysgen.mk - -all.bootstrap clean.bootstrap: system.mk sysgen.mk - $(MAKE) -e SYSTEMINC=system.mk SYSGENINC=sysgen.mk \ - $(@:%.bootstrap=%.start) - -system.mk: Makefile syscall.lst - printf '%s ' 'SYSOBJ =' \ - "$$(awk '/^#/{next}{printf "%s.o ", $$2}' syscall.lst)" \ - $(OBJ) \ - > $@ - -sysgen.mk: syscall.lst - printf '%s ' 'GENOBJ =' \ - "$$(awk '/^#/{next}{printf "%s.o ", $$2}' syscall.lst)" \ - > $@ - -$(GENASM): syscall.lst - awk -f syscall.awk < syscall.lst diff --git a/libc/src/sys/qbe-linux/syscall.awk b/libc/src/sys/qbe-linux/syscall.awk @@ -1,12 +0,0 @@ -# This job is very easy because app and kernel ABI are identical -# until the 4th parameter, so we only have to set the syscall -# number in rax - -/^#/ {next} - {name=$2 ".s" - printf ".global %s\n" \ - "%s:\n" \ - "\tmovq\t$%d,%%rax\n" \ - "\tsyscall\n" \ - "\tret\n", $2, $2, $1 > name - close(name)} diff --git a/libc/src/sys/z80-linux/Makefile b/libc/src/sys/z80-linux/Makefile @@ -1,37 +0,0 @@ -# See LICENSE file for copyright and license details. -.POSIX: - -include ../../../../config.mk - -SYSTEMINC = /dev/null -include $(SYSTEMINC) -SYSGENINC = /dev/null -include $(SYSGENINC) - -GENASM = $(GENOBJ:.o=.s) -OBJ = - -all: all.bootstrap -all.start: $(SYSOBJ) - -clean: clean.bootstrap -clean.start: - rm -f *.o $(GENASM) system.mk sysgen.mk - -all.bootstrap clean.bootstrap: system.mk sysgen.mk - $(MAKE) -e SYSTEMINC=system.mk SYSGENINC=sysgen.mk \ - $(@:%.bootstrap=%.start) - -system.mk: Makefile syscall.lst - printf '%s ' 'SYSOBJ =' \ - "$$(awk '/^#/{next}{printf "%s.o ", $$2}' syscall.lst)" \ - $(OBJ) \ - > $@ - -sysgen.mk: syscall.lst - printf '%s ' 'GENOBJ =' \ - "$$(awk '/^#/{next}{printf "%s.o ", $$2}' syscall.lst)" \ - > $@ - -$(GENASM): syscall.lst - awk -f syscall.awk < syscall.lst diff --git a/tests/Makefile b/tests/Makefile @@ -1,5 +1,5 @@ .POSIX: -all clean: +all clean dep distclean: cd error && make -e $@ cd execute && make -e $@ diff --git a/tests/execute/Makefile b/tests/execute/Makefile @@ -6,3 +6,6 @@ tests: CFLAGS='' SCCEXECPATH=../../bin PATH=../../bin:$$PATH ./chktest.sh < scc-tests.lst clean: rm -f *.as *.o *.ir *.qbe *core test.log + +distclean: clean +dep: