scc

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

commit 3392e2335ae20127606a01f6878f16c597dee087
parent b22f4577b97edea4a07fbcc0de1fac2e1732626b
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 21 Sep 2018 15:56:07 +0100

Merge branch 'master' of ssh://simple-cc.org:/var/gitrepos/scc

Diffstat:
M.gitignore | 18+++++++++---------
MMakefile | 2+-
Mar/posix/driver.h | 1-
Mas/target/x80/proc.h | 1-
Mas/target/x86/proc.h | 1-
Mconfig.mk | 2+-
Minc/ar.h | 1-
Minc/coff32/aouthdr.h | 1-
Minc/coff32/coff32.h | 1-
Minc/coff32/filehdr.h | 1-
Minc/coff32/linenum.h | 1-
Minc/coff32/reloc.h | 1-
Minc/coff32/scnhdr.h | 1-
Minc/coff32/syms.h | 1-
Minc/myro.h | 1-
Minc/syslibs.def.h | 1-
Mld/ld.h | 1-
Mlib/c/__abs.c | 1-
Mlib/c/__getc.c | 1-
Mlib/c/__labs.c | 1-
Mlib/c/__llabs.c | 1-
Mlib/c/__putc.c | 1-
Mlib/c/_flsbuf.c | 1-
Mlib/c/_fpopen.c | 1-
Mlib/c/abort.c | 1-
Mlib/c/abs.c | 1-
Mlib/c/bsearch.c | 1-
Mlib/c/clearerr.c | 1-
Mlib/c/fclose.c | 1-
Mlib/c/feof.c | 1-
Mlib/c/ferror.c | 1-
Mlib/c/fgetc.c | 1-
Mlib/c/fopen.c | 1-
Mlib/c/fputc.c | 1-
Mlib/c/fputs.c | 1-
Mlib/c/fread.c | 1-
Mlib/c/freopen.c | 1-
Mlib/c/fseek.c | 1-
Mlib/c/fwrite.c | 1-
Mlib/c/getc.c | 1-
Mlib/c/getchar.c | 1-
Mlib/c/isblank.c | 1-
Mlib/c/labs.c | 1-
Mlib/c/llabs.c | 1-
Mlib/c/perror.c | 1-
Mlib/c/putc.c | 1-
Mlib/c/putchar.c | 1-
Mlib/c/puts.c | 1-
Mlib/c/qsort.c | 1-
Mlib/c/rewind.c | 1-
Mlib/c/setbuf.c | 1-
Mlib/c/setvbuf.c | 1-
Mlib/c/snprintf.c | 1-
Mlib/c/sprintf.c | 1-
Mlib/c/stdio.c | 1-
Mlib/c/strerror.c | 1-
Mlib/c/target/amd64-sysv-linux/sys.h | 1-
Mlib/c/target/amd64-sysv-netbsd/_sigaction.c | 1-
Mlib/c/target/amd64-sysv-netbsd/sys.h | 1-
Mlib/c/target/amd64-sysv-openbsd/sys.h | 1-
Alib/c/target/posix/getenv.c | 22++++++++++++++++++++++
Mlib/c/target/posix/raise.c | 1-
Mlib/c/target/posix/signal.c | 1-
Mlib/c/target/script/objlst.mk | 5+----
Mlib/c/tmpnam.c | 1-
Mlib/c/vfprintf.c | 2+-
Mlib/c/vsnprintf.c | 1-
Mlib/c/vsprintf.c | 1-
Dlib/c/wcsnlen.c | 10----------
Mlib/coff32/coff32_pack_aout.c | 1-
Mlib/coff32/coff32_pack_ent.c | 1-
Mlib/coff32/coff32_pack_hdr.c | 1-
Mlib/coff32/coff32_pack_scn.c | 1-
Mlib/coff32/coff32_unpack_aout.c | 1-
Mlib/coff32/coff32_unpack_ent.c | 1-
Mlib/coff32/coff32_unpack_hdr.c | 1-
Mlib/coff32/coff32_unpack_scn.c | 1-
Mlib/crt/amd64-sysv-netbsd/crt.s | 8+++++++-
Mlib/scc/bpack.c | 1-
Mlib/scc/lpack.c | 1-
Mnm/coff32.c | 1-
Mnm/formats.c | 1-
Mnm/nm.h | 1-
Mobjdump/main.c | 1-
Rrootdir/bin/README -> root/bin/README | 0
Aroot/include/scc/assert.h | 8++++++++
Rrootdir/include/scc/bits/.gitignore -> root/include/scc/bits/.gitignore | 0
Rrootdir/include/scc/bits/amd64-sysv/arch/limits.h -> root/include/scc/bits/amd64-sysv/arch/limits.h | 0
Rrootdir/include/scc/bits/amd64-sysv/arch/setjmp.h -> root/include/scc/bits/amd64-sysv/arch/setjmp.h | 0
Rrootdir/include/scc/bits/amd64-sysv/arch/stddef.h -> root/include/scc/bits/amd64-sysv/arch/stddef.h | 0
Rrootdir/include/scc/bits/amd64-sysv/arch/stdint.h -> root/include/scc/bits/amd64-sysv/arch/stdint.h | 0
Rrootdir/include/scc/bits/amd64-sysv/arch/stdio.h -> root/include/scc/bits/amd64-sysv/arch/stdio.h | 0
Rrootdir/include/scc/bits/amd64-sysv/arch/stdlib.h -> root/include/scc/bits/amd64-sysv/arch/stdlib.h | 0
Rrootdir/include/scc/bits/amd64-sysv/arch/string.h -> root/include/scc/bits/amd64-sysv/arch/string.h | 0
Rrootdir/include/scc/bits/amd64-sysv/arch/time.h -> root/include/scc/bits/amd64-sysv/arch/time.h | 0
Rrootdir/include/scc/bits/i386-sysv/arch/limits.h -> root/include/scc/bits/i386-sysv/arch/limits.h | 0
Rrootdir/include/scc/bits/i386-sysv/arch/stddef.h -> root/include/scc/bits/i386-sysv/arch/stddef.h | 0
Rrootdir/include/scc/bits/i386-sysv/arch/stdint.h -> root/include/scc/bits/i386-sysv/arch/stdint.h | 0
Rrootdir/include/scc/bits/i386-sysv/arch/stdio.h -> root/include/scc/bits/i386-sysv/arch/stdio.h | 0
Rrootdir/include/scc/bits/i386-sysv/arch/stdlib.h -> root/include/scc/bits/i386-sysv/arch/stdlib.h | 0
Rrootdir/include/scc/bits/i386-sysv/arch/string.h -> root/include/scc/bits/i386-sysv/arch/string.h | 0
Rrootdir/include/scc/bits/i386-sysv/arch/time.h -> root/include/scc/bits/i386-sysv/arch/time.h | 0
Rrootdir/include/scc/bits/linux/sys/signal.h -> root/include/scc/bits/linux/sys/signal.h | 0
Rrootdir/include/scc/bits/netbsd/sys/signal.h -> root/include/scc/bits/netbsd/sys/signal.h | 0
Rrootdir/include/scc/bits/openbsd/sys/signal.h -> root/include/scc/bits/openbsd/sys/signal.h | 0
Rrootdir/include/scc/bits/z80-dos/arch/limits.h -> root/include/scc/bits/z80-dos/arch/limits.h | 0
Rrootdir/include/scc/bits/z80-dos/arch/stddef.h -> root/include/scc/bits/z80-dos/arch/stddef.h | 0
Rrootdir/include/scc/bits/z80-dos/arch/stdint.h -> root/include/scc/bits/z80-dos/arch/stdint.h | 0
Rrootdir/include/scc/bits/z80-dos/arch/stdio.h -> root/include/scc/bits/z80-dos/arch/stdio.h | 0
Rrootdir/include/scc/bits/z80-dos/arch/stdlib.h -> root/include/scc/bits/z80-dos/arch/stdlib.h | 0
Rrootdir/include/scc/bits/z80-dos/arch/string.h -> root/include/scc/bits/z80-dos/arch/string.h | 0
Rrootdir/include/scc/bits/z80-dos/arch/time.h -> root/include/scc/bits/z80-dos/arch/time.h | 0
Rrootdir/include/scc/ctype.h -> root/include/scc/ctype.h | 0
Rrootdir/include/scc/errno.h -> root/include/scc/errno.h | 0
Rrootdir/include/scc/float.h -> root/include/scc/float.h | 0
Rrootdir/include/scc/limits.h -> root/include/scc/limits.h | 0
Rrootdir/include/scc/locale.h -> root/include/scc/locale.h | 0
Rrootdir/include/scc/math.h -> root/include/scc/math.h | 0
Rrootdir/include/scc/setjmp.h -> root/include/scc/setjmp.h | 0
Rrootdir/include/scc/signal.h -> root/include/scc/signal.h | 0
Rrootdir/include/scc/stdarg.h -> root/include/scc/stdarg.h | 0
Rrootdir/include/scc/stdbool.h -> root/include/scc/stdbool.h | 0
Rrootdir/include/scc/stddef.h -> root/include/scc/stddef.h | 0
Rrootdir/include/scc/stdint.h -> root/include/scc/stdint.h | 0
Rrootdir/include/scc/stdio.h -> root/include/scc/stdio.h | 0
Rrootdir/include/scc/stdlib.h -> root/include/scc/stdlib.h | 0
Rrootdir/include/scc/string.h -> root/include/scc/string.h | 0
Rrootdir/include/scc/time.h -> root/include/scc/time.h | 0
Aroot/include/scc/wchar.h | 92+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aroot/include/scc/wctype.h | 30++++++++++++++++++++++++++++++
Rrootdir/lib/scc/amd64-sysv-linux/README -> root/lib/scc/amd64-sysv-linux/README | 0
Rrootdir/lib/scc/amd64-sysv-netbsd/README -> root/lib/scc/amd64-sysv-netbsd/README | 0
Rrootdir/lib/scc/amd64-sysv-openbsd/README -> root/lib/scc/amd64-sysv-openbsd/README | 0
Rrootdir/lib/scc/i386-sysv-linux/README -> root/lib/scc/i386-sysv-linux/README | 0
Rrootdir/lib/scc/i386-sysv-openbsd/README -> root/lib/scc/i386-sysv-openbsd/README | 0
Rrootdir/lib/scc/z80-scc-none/README -> root/lib/scc/z80-scc-none/README | 0
Rrootdir/libexec/scc/README -> root/libexec/scc/README | 0
Drootdir/include/scc/assert.h | 9---------
Drootdir/include/scc/wchar.h | 11-----------
Mrules.mk | 8++++----
Mtests/ar/execute/Makefile | 2+-
Mtests/as/execute/Makefile | 2+-
Mtests/libc/execute/0002-assert.c | 1-
Mtests/libc/execute/Makefile | 2+-
Mtests/nm/execute/Makefile | 2+-
Mtests/scc/error/Makefile | 2+-
Mtests/scc/execute/0137-int-cast.c | 1-
Mtests/scc/execute/0178-include.c | 1-
Mtests/scc/execute/0178-include.h | 1-
Mtests/scc/execute/0179-sizeof.c | 1-
Mtests/scc/execute/0180-incomplete.c | 1-
Mtests/scc/execute/0181-stringize.c | 1-
Mtests/scc/execute/Makefile | 2+-
153 files changed, 182 insertions(+), 140 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,14 +1,14 @@ *.o *.a -rootdir/libexec/scc/cc1-* -rootdir/libexec/scc/cc2-* -rootdir/libexec/scc/as-* -rootdir/bin/ld -rootdir/bin/scc -rootdir/bin/scpp -rootdir/bin/ar -rootdir/bin/nm -rootdir/bin/objdump +root/libexec/scc/cc1-* +root/libexec/scc/cc2-* +root/libexec/scc/as-* +root/bin/ld +root/bin/scc +root/bin/scpp +root/bin/ar +root/bin/nm +root/bin/objdump test.log cc2/error.h instbl.c diff --git a/Makefile b/Makefile @@ -32,7 +32,7 @@ config: install: all mkdir -p $(DESTDIR)$(PREFIX)/ - cp -r rootdir/* $(DESTDIR)$(PREFIX)/ + cp -r root/* $(DESTDIR)$(PREFIX)/ cd $(DESTDIR)$(PREFIX)/libexec/scc/ && chmod 755 cc* cd $(DESTDIR)$(PREFIX)/bin && chmod 755 scc cpp mkdir -p $(DESTDIR)$(MANPREFIX)/man1 diff --git a/ar/posix/driver.h b/ar/posix/driver.h @@ -1,4 +1,3 @@ - #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> diff --git a/as/target/x80/proc.h b/as/target/x80/proc.h @@ -1,4 +1,3 @@ - enum args { AREG_AF = AMAX, AREG_A, diff --git a/as/target/x86/proc.h b/as/target/x86/proc.h @@ -1,4 +1,3 @@ - enum args { AREG_CS = AMAX, AREG_DS, diff --git a/config.mk b/config.mk @@ -8,7 +8,7 @@ DRIVER = posix STD = c99 # paths -PREFIX = $(PWD)/$(PROJECTDIR)/rootdir +PREFIX = $(PWD)/$(PROJECTDIR)/root MANPREFIX = $(PREFIX)/share/man # scc expects to be built by a C99 compiler diff --git a/inc/ar.h b/inc/ar.h @@ -1,4 +1,3 @@ - #define ARMAG "!<arch>\n" /* ar "magic number" */ #define SARMAG 8 /* strlen(ARMAG); */ #define ARFMAG "`\n" diff --git a/inc/coff32/aouthdr.h b/inc/coff32/aouthdr.h @@ -1,4 +1,3 @@ - /* This file is inspired in the book "Understanding and using COFF" */ struct aouthdr { diff --git a/inc/coff32/coff32.h b/inc/coff32/coff32.h @@ -1,4 +1,3 @@ - typedef int (*packfun)(unsigned char *, char *, ...); #ifdef AOUTHDR diff --git a/inc/coff32/filehdr.h b/inc/coff32/filehdr.h @@ -1,4 +1,3 @@ - /* This file is inspired in the book "Understanding and using COFF" */ struct filehdr { diff --git a/inc/coff32/linenum.h b/inc/coff32/linenum.h @@ -1,4 +1,3 @@ - /* This file is inspired in the book "Understanding and using COFF" */ struct lineno { diff --git a/inc/coff32/reloc.h b/inc/coff32/reloc.h @@ -1,4 +1,3 @@ - /* This file is inspired in the book "Understanding and using COFF" */ struct reloc { diff --git a/inc/coff32/scnhdr.h b/inc/coff32/scnhdr.h @@ -1,4 +1,3 @@ - /* This file is inspired in the book "Understanding and using COFF" */ #define SCNNMLEN 8 diff --git a/inc/coff32/syms.h b/inc/coff32/syms.h @@ -1,4 +1,3 @@ - /* This file is inspired in the book "Understanding and using COFF" */ #define E_SYMNMLEN 8 diff --git a/inc/myro.h b/inc/myro.h @@ -1,4 +1,3 @@ - #define MYROHDR_SIZ 48 #define MYROSECT_SIZ 24 #define MYROSYM_SIZ 26 diff --git a/inc/syslibs.def.h b/inc/syslibs.def.h @@ -1,4 +1,3 @@ - #define MAX_LIB_PATHS 32 char *syslibs[MAX_LIB_PATHS + 1] = { diff --git a/ld/ld.h b/ld/ld.h @@ -1,4 +1,3 @@ - #define INSTALL 1 #define NOINSTALL 0 diff --git a/lib/c/__abs.c b/lib/c/__abs.c @@ -1,4 +1,3 @@ - #define __USE_MACROS #include <stdlib.h> diff --git a/lib/c/__getc.c b/lib/c/__getc.c @@ -1,4 +1,3 @@ - #include <errno.h> #include <stdio.h> #include "syscall.h" diff --git a/lib/c/__labs.c b/lib/c/__labs.c @@ -1,4 +1,3 @@ - #define __USE_MACROS #include <stdlib.h> diff --git a/lib/c/__llabs.c b/lib/c/__llabs.c @@ -1,4 +1,3 @@ - #define __USE_MACROS #include <stdlib.h> diff --git a/lib/c/__putc.c b/lib/c/__putc.c @@ -1,4 +1,3 @@ - #include <errno.h> #include <stdio.h> #include <stdlib.h> diff --git a/lib/c/_flsbuf.c b/lib/c/_flsbuf.c @@ -1,4 +1,3 @@ - #include <errno.h> #include <stdio.h> #include "syscall.h" diff --git a/lib/c/_fpopen.c b/lib/c/_fpopen.c @@ -1,4 +1,3 @@ - #include <errno.h> #include <stdio.h> #include <stdlib.h> diff --git a/lib/c/abort.c b/lib/c/abort.c @@ -1,4 +1,3 @@ - #include <signal.h> #include <stdlib.h> #undef abort diff --git a/lib/c/abs.c b/lib/c/abs.c @@ -1,4 +1,3 @@ - #include <stdlib.h> #undef abs diff --git a/lib/c/bsearch.c b/lib/c/bsearch.c @@ -1,4 +1,3 @@ - #include <stdlib.h> void * diff --git a/lib/c/clearerr.c b/lib/c/clearerr.c @@ -1,4 +1,3 @@ - #include <stdio.h> #undef clearerr diff --git a/lib/c/fclose.c b/lib/c/fclose.c @@ -1,4 +1,3 @@ - #include <stdlib.h> #include <stdio.h> #include "syscall.h" diff --git a/lib/c/feof.c b/lib/c/feof.c @@ -1,4 +1,3 @@ - #include <stdio.h> #undef feof diff --git a/lib/c/ferror.c b/lib/c/ferror.c @@ -1,4 +1,3 @@ - #include <stdio.h> #undef ferror diff --git a/lib/c/fgetc.c b/lib/c/fgetc.c @@ -1,4 +1,3 @@ - #include <stdio.h> #undef fgetc diff --git a/lib/c/fopen.c b/lib/c/fopen.c @@ -1,4 +1,3 @@ - #include <errno.h> #include <stdio.h> diff --git a/lib/c/fputc.c b/lib/c/fputc.c @@ -1,4 +1,3 @@ - #include <stdio.h> #undef fputc diff --git a/lib/c/fputs.c b/lib/c/fputs.c @@ -1,4 +1,3 @@ - #include <stdio.h> #undef fputs diff --git a/lib/c/fread.c b/lib/c/fread.c @@ -1,4 +1,3 @@ - #include <stdio.h> #undef fread diff --git a/lib/c/freopen.c b/lib/c/freopen.c @@ -1,4 +1,3 @@ - #include <stdio.h> #include "syscall.h" diff --git a/lib/c/fseek.c b/lib/c/fseek.c @@ -1,4 +1,3 @@ - #include <stdio.h> #include "syscall.h" #undef fseek diff --git a/lib/c/fwrite.c b/lib/c/fwrite.c @@ -1,4 +1,3 @@ - #include <stdio.h> #undef fwrite diff --git a/lib/c/getc.c b/lib/c/getc.c @@ -1,4 +1,3 @@ - #include <stdio.h> #undef getc diff --git a/lib/c/getchar.c b/lib/c/getchar.c @@ -1,4 +1,3 @@ - #include <stdio.h> #undef getchar diff --git a/lib/c/isblank.c b/lib/c/isblank.c @@ -1,4 +1,3 @@ - #include <ctype.h> int diff --git a/lib/c/labs.c b/lib/c/labs.c @@ -1,4 +1,3 @@ - #include <stdlib.h> #undef labs diff --git a/lib/c/llabs.c b/lib/c/llabs.c @@ -1,4 +1,3 @@ - #include <stdlib.h> #undef llabs diff --git a/lib/c/perror.c b/lib/c/perror.c @@ -1,4 +1,3 @@ - #include <errno.h> #include <stdio.h> #include <string.h> diff --git a/lib/c/putc.c b/lib/c/putc.c @@ -1,4 +1,3 @@ - #include <stdio.h> #undef putc diff --git a/lib/c/putchar.c b/lib/c/putchar.c @@ -1,4 +1,3 @@ - #include <stdio.h> #undef putchar diff --git a/lib/c/puts.c b/lib/c/puts.c @@ -1,4 +1,3 @@ - #include <stdio.h> #undef puts diff --git a/lib/c/qsort.c b/lib/c/qsort.c @@ -1,4 +1,3 @@ - #include <stdlib.h> #include <string.h> #undef qsort diff --git a/lib/c/rewind.c b/lib/c/rewind.c @@ -1,4 +1,3 @@ - #include <stdio.h> #undef rewind diff --git a/lib/c/setbuf.c b/lib/c/setbuf.c @@ -1,4 +1,3 @@ - #include <stdio.h> #undef setbuf diff --git a/lib/c/setvbuf.c b/lib/c/setvbuf.c @@ -1,4 +1,3 @@ - #include <errno.h> #include <stdio.h> #include <stdlib.h> diff --git a/lib/c/snprintf.c b/lib/c/snprintf.c @@ -1,4 +1,3 @@ - #include <stdarg.h> #include <stdio.h> #undef snprintf diff --git a/lib/c/sprintf.c b/lib/c/sprintf.c @@ -1,4 +1,3 @@ - #include <stdarg.h> #include <stdio.h> #undef sprintf diff --git a/lib/c/stdio.c b/lib/c/stdio.c @@ -1,4 +1,3 @@ - #include <stdio.h> static unsigned char inbuf[BUFSIZ]; diff --git a/lib/c/strerror.c b/lib/c/strerror.c @@ -1,4 +1,3 @@ - #include <errno.h> #include <string.h> #undef strerror diff --git a/lib/c/target/amd64-sysv-linux/sys.h b/lib/c/target/amd64-sysv-linux/sys.h @@ -1,4 +1,3 @@ - #define O_RDONLY 0x00000000 #define O_WRONLY 0x00000001 #define O_RDWR 0x00000002 diff --git a/lib/c/target/amd64-sysv-netbsd/_sigaction.c b/lib/c/target/amd64-sysv-netbsd/_sigaction.c @@ -1,4 +1,3 @@ - #include <stddef.h> #include <sys.h> diff --git a/lib/c/target/amd64-sysv-netbsd/sys.h b/lib/c/target/amd64-sysv-netbsd/sys.h @@ -1,4 +1,3 @@ - #define O_RDONLY 0x00000000 #define O_WRONLY 0x00000001 #define O_RDWR 0x00000002 diff --git a/lib/c/target/amd64-sysv-openbsd/sys.h b/lib/c/target/amd64-sysv-openbsd/sys.h @@ -1,4 +1,3 @@ - #define O_RDONLY 0x00000000 #define O_WRONLY 0x00000001 #define O_RDWR 0x00000002 diff --git a/lib/c/target/posix/getenv.c b/lib/c/target/posix/getenv.c @@ -0,0 +1,22 @@ +#include <stdlib.h> +#include <string.h> +#undef getenv + +extern char **environ; + +char * +getenv(const char *name) +{ + char **p; + size_t len = strlen(name); + + for (p = environ; *p; ++p) { + if (!memcmp(name, *p, len) && (*p)[len] == '=') + break; + } + + if (!*p) + return NULL; + + return &(*p)[len]; +} diff --git a/lib/c/target/posix/raise.c b/lib/c/target/posix/raise.c @@ -1,4 +1,3 @@ - #include <stddef.h> #include <signal.h> #include <sys.h> diff --git a/lib/c/target/posix/signal.c b/lib/c/target/posix/signal.c @@ -1,4 +1,3 @@ - #include <stddef.h> #include <signal.h> #include <sys.h> diff --git a/lib/c/target/script/objlst.mk b/lib/c/target/script/objlst.mk @@ -20,7 +20,7 @@ LIBOBJ = bsearch.o qsort.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 atol.o atoll.o atexit.o abort.o exit.o \ - errno.o _sys_errlist.o strnlen.o wcsnlen.o + errno.o _sys_errlist.o strnlen.o #rules __abs.o: ../../__abs.c @@ -314,6 +314,3 @@ vsnprintf.o: ../../vsnprintf.c vsprintf.o: ../../vsprintf.c $(CC) $(SCC_CFLAGS) ../../vsprintf.c -c -wcsnlen.o: ../../wcsnlen.c - $(CC) $(SCC_CFLAGS) ../../wcsnlen.c -c - diff --git a/lib/c/tmpnam.c b/lib/c/tmpnam.c @@ -1,4 +1,3 @@ - #include <stdio.h> #include <string.h> #include "syscall.h" diff --git a/lib/c/vfprintf.c b/lib/c/vfprintf.c @@ -343,7 +343,7 @@ flags: case 's': if (flags & LONG) { ws = va_arg(va, wchar_t *); - len = wcsnlen(ws, conv.prec); + /* len = wcsnlen(ws, conv.prec); */ goto wstrout; } else { s = va_arg(va, char *); diff --git a/lib/c/vsnprintf.c b/lib/c/vsnprintf.c @@ -1,4 +1,3 @@ - #include <stdarg.h> #include <stdio.h> #undef vsnprintf diff --git a/lib/c/vsprintf.c b/lib/c/vsprintf.c @@ -1,4 +1,3 @@ - #include <limits.h> #include <stdarg.h> #include <stdint.h> diff --git a/lib/c/wcsnlen.c b/lib/c/wcsnlen.c @@ -1,10 +0,0 @@ -#include <stdio.h> -#include <wchar.h> - -#undef wcsnlen - -size_t -wcsnlen(const wchar_t *s, size_t maxlen) -{ - return 0; -} diff --git a/lib/coff32/coff32_pack_aout.c b/lib/coff32/coff32_pack_aout.c @@ -1,4 +1,3 @@ - #include <assert.h> #include "../../inc/coff32/aouthdr.h" diff --git a/lib/coff32/coff32_pack_ent.c b/lib/coff32/coff32_pack_ent.c @@ -1,4 +1,3 @@ - #include <assert.h> #include "../../inc/coff32/syms.h" diff --git a/lib/coff32/coff32_pack_hdr.c b/lib/coff32/coff32_pack_hdr.c @@ -1,4 +1,3 @@ - #include <assert.h> #include "../../inc/coff32/filehdr.h" diff --git a/lib/coff32/coff32_pack_scn.c b/lib/coff32/coff32_pack_scn.c @@ -1,4 +1,3 @@ - #include <assert.h> #include "../../inc/coff32/scnhdr.h" diff --git a/lib/coff32/coff32_unpack_aout.c b/lib/coff32/coff32_unpack_aout.c @@ -1,4 +1,3 @@ - #include <assert.h> #include "../../inc/coff32/aouthdr.h" diff --git a/lib/coff32/coff32_unpack_ent.c b/lib/coff32/coff32_unpack_ent.c @@ -1,4 +1,3 @@ - #include <assert.h> #include "../../inc/coff32/syms.h" diff --git a/lib/coff32/coff32_unpack_hdr.c b/lib/coff32/coff32_unpack_hdr.c @@ -1,4 +1,3 @@ - #include <assert.h> #include "../../inc/coff32/filehdr.h" diff --git a/lib/coff32/coff32_unpack_scn.c b/lib/coff32/coff32_unpack_scn.c @@ -1,4 +1,3 @@ - #include <assert.h> #include "../../inc/coff32/scnhdr.h" diff --git a/lib/crt/amd64-sysv-netbsd/crt.s b/lib/crt/amd64-sysv-netbsd/crt.s @@ -8,10 +8,16 @@ .p2align 2 .long 200000000 + .bss +environ: + .quad 0 + .text .align 8 .global _start _start: + movq 16(%rbp),%rbx + movq %rbx,environ call main - movl %eax, %edi + movl %eax,%edi jmp exit diff --git a/lib/scc/bpack.c b/lib/scc/bpack.c @@ -1,4 +1,3 @@ - #include <ctype.h> #include <stdarg.h> diff --git a/lib/scc/lpack.c b/lib/scc/lpack.c @@ -1,4 +1,3 @@ - #include <ctype.h> #include <stdarg.h> diff --git a/nm/coff32.c b/nm/coff32.c @@ -1,4 +1,3 @@ - static char sccsid[] = "@(#) ./nm/coff.c"; #include <assert.h> diff --git a/nm/formats.c b/nm/formats.c @@ -1,4 +1,3 @@ - static char sccsid[] = "@(#) ./nm/probe.c"; #include <stdio.h> diff --git a/nm/nm.h b/nm/nm.h @@ -1,4 +1,3 @@ - struct symbol { char *name; int type; diff --git a/objdump/main.c b/objdump/main.c @@ -1,4 +1,3 @@ - #include <errno.h> #include <limits.h> #include <stdint.h> diff --git a/rootdir/bin/README b/root/bin/README diff --git a/root/include/scc/assert.h b/root/include/scc/assert.h @@ -0,0 +1,8 @@ +extern void __assert(char *exp, char *file, long line); + +#undef assert +#ifndef NDEBUG +# define assert(exp) ((exp) ? (void) 0 : __assert(#exp, __FILE__, __LINE__)) +#else +# define assert(exp) ((void)0) +#endif diff --git a/rootdir/include/scc/bits/.gitignore b/root/include/scc/bits/.gitignore diff --git a/rootdir/include/scc/bits/amd64-sysv/arch/limits.h b/root/include/scc/bits/amd64-sysv/arch/limits.h diff --git a/rootdir/include/scc/bits/amd64-sysv/arch/setjmp.h b/root/include/scc/bits/amd64-sysv/arch/setjmp.h diff --git a/rootdir/include/scc/bits/amd64-sysv/arch/stddef.h b/root/include/scc/bits/amd64-sysv/arch/stddef.h diff --git a/rootdir/include/scc/bits/amd64-sysv/arch/stdint.h b/root/include/scc/bits/amd64-sysv/arch/stdint.h diff --git a/rootdir/include/scc/bits/amd64-sysv/arch/stdio.h b/root/include/scc/bits/amd64-sysv/arch/stdio.h diff --git a/rootdir/include/scc/bits/amd64-sysv/arch/stdlib.h b/root/include/scc/bits/amd64-sysv/arch/stdlib.h diff --git a/rootdir/include/scc/bits/amd64-sysv/arch/string.h b/root/include/scc/bits/amd64-sysv/arch/string.h diff --git a/rootdir/include/scc/bits/amd64-sysv/arch/time.h b/root/include/scc/bits/amd64-sysv/arch/time.h diff --git a/rootdir/include/scc/bits/i386-sysv/arch/limits.h b/root/include/scc/bits/i386-sysv/arch/limits.h diff --git a/rootdir/include/scc/bits/i386-sysv/arch/stddef.h b/root/include/scc/bits/i386-sysv/arch/stddef.h diff --git a/rootdir/include/scc/bits/i386-sysv/arch/stdint.h b/root/include/scc/bits/i386-sysv/arch/stdint.h diff --git a/rootdir/include/scc/bits/i386-sysv/arch/stdio.h b/root/include/scc/bits/i386-sysv/arch/stdio.h diff --git a/rootdir/include/scc/bits/i386-sysv/arch/stdlib.h b/root/include/scc/bits/i386-sysv/arch/stdlib.h diff --git a/rootdir/include/scc/bits/i386-sysv/arch/string.h b/root/include/scc/bits/i386-sysv/arch/string.h diff --git a/rootdir/include/scc/bits/i386-sysv/arch/time.h b/root/include/scc/bits/i386-sysv/arch/time.h diff --git a/rootdir/include/scc/bits/linux/sys/signal.h b/root/include/scc/bits/linux/sys/signal.h diff --git a/rootdir/include/scc/bits/netbsd/sys/signal.h b/root/include/scc/bits/netbsd/sys/signal.h diff --git a/rootdir/include/scc/bits/openbsd/sys/signal.h b/root/include/scc/bits/openbsd/sys/signal.h diff --git a/rootdir/include/scc/bits/z80-dos/arch/limits.h b/root/include/scc/bits/z80-dos/arch/limits.h diff --git a/rootdir/include/scc/bits/z80-dos/arch/stddef.h b/root/include/scc/bits/z80-dos/arch/stddef.h diff --git a/rootdir/include/scc/bits/z80-dos/arch/stdint.h b/root/include/scc/bits/z80-dos/arch/stdint.h diff --git a/rootdir/include/scc/bits/z80-dos/arch/stdio.h b/root/include/scc/bits/z80-dos/arch/stdio.h diff --git a/rootdir/include/scc/bits/z80-dos/arch/stdlib.h b/root/include/scc/bits/z80-dos/arch/stdlib.h diff --git a/rootdir/include/scc/bits/z80-dos/arch/string.h b/root/include/scc/bits/z80-dos/arch/string.h diff --git a/rootdir/include/scc/bits/z80-dos/arch/time.h b/root/include/scc/bits/z80-dos/arch/time.h diff --git a/rootdir/include/scc/ctype.h b/root/include/scc/ctype.h diff --git a/rootdir/include/scc/errno.h b/root/include/scc/errno.h diff --git a/rootdir/include/scc/float.h b/root/include/scc/float.h diff --git a/rootdir/include/scc/limits.h b/root/include/scc/limits.h diff --git a/rootdir/include/scc/locale.h b/root/include/scc/locale.h diff --git a/rootdir/include/scc/math.h b/root/include/scc/math.h diff --git a/rootdir/include/scc/setjmp.h b/root/include/scc/setjmp.h diff --git a/rootdir/include/scc/signal.h b/root/include/scc/signal.h diff --git a/rootdir/include/scc/stdarg.h b/root/include/scc/stdarg.h diff --git a/rootdir/include/scc/stdbool.h b/root/include/scc/stdbool.h diff --git a/rootdir/include/scc/stddef.h b/root/include/scc/stddef.h diff --git a/rootdir/include/scc/stdint.h b/root/include/scc/stdint.h diff --git a/rootdir/include/scc/stdio.h b/root/include/scc/stdio.h diff --git a/rootdir/include/scc/stdlib.h b/root/include/scc/stdlib.h diff --git a/rootdir/include/scc/string.h b/root/include/scc/string.h diff --git a/rootdir/include/scc/time.h b/root/include/scc/time.h diff --git a/root/include/scc/wchar.h b/root/include/scc/wchar.h @@ -0,0 +1,92 @@ +#ifndef _WCHAR_H +#define _WCHAR_H + +/* TODO: This is only a placeholder */ +typedef long wchar_t; +/* typedef long size_t; */ +typedef long mbstate_t; +typedef long wint_t; +struct tm; + +/* #define WCHAR_MAX 1 */ +/* #define WCHAR_MIN 1 */ +/* #define WEOF -1 */ +/* #define NULL 0 */ + +#ifdef _STDARG_H +extern int vswscanf(const wchar_t * restrict s, const wchar_t * restrict format, va_list arg); +extern int vwprintf(const wchar_t * restrict format, va_list arg); +extern int vwscanf(const wchar_t * restrict format, va_list arg); +#endif + +#ifdef _STDIO_H +extern int fwprintf(FILE * restrict stream, const wchar_t * restrict format, ...); +extern int fwscanf(FILE * restrict stream, const wchar_t * restrict format, ...); + +#ifdef _STDARG_H +extern int vfwprintf(FILE * restrict stream, const wchar_t * restrict format, va_list arg); +extern int vfwscanf(FILE * restrict stream, const wchar_t * restrict format, va_list arg); +extern int vswprintf(wchar_t * restrict s, size_t n, const wchar_t * restrict format, va_list arg); +#endif + +extern wint_t fgetwc(FILE *stream); +extern wint_t fputwc(wchar_t c, FILE *stream); +extern wint_t getwc(FILE *stream); +extern wint_t putwc(wchar_t c, FILE *stream); +extern int fwide(FILE *stream, int mode); +extern wint_t ungetwc(wint_t c, FILE *stream); +extern wchar_t *fgetws(wchar_t * restrict s, int n, FILE * restrict stream); +extern int fputws(const wchar_t * restrict s, FILE * restrict stream); +#endif + +extern int swprintf(wchar_t * restrict s, size_t n, const wchar_t * restrict format, ...); +extern int swscanf(const wchar_t * restrict s, const wchar_t * restrict format, ...); +extern int wprintf(const wchar_t * restrict format, ...); +extern int wscanf(const wchar_t * restrict format, ...); + +extern wint_t getwchar(void); +extern wint_t putwchar(wchar_t c); + +extern double wcstod(const wchar_t * restrict nptr, wchar_t ** restrict endptr); +extern float wcstof(const wchar_t * restrict nptr, wchar_t ** restrict endptr); +extern long double wcstold(const wchar_t * restrict nptr, wchar_t ** restrict endptr); + +extern long int wcstol(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base); +extern long long int wcstoll(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base); +extern unsigned long int wcstoul(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base); +extern unsigned long long int wcstoull(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base); + +extern wchar_t *wcscpy(wchar_t * restrict s1, const wchar_t * restrict s2); +extern wchar_t *wcsncpy(wchar_t * restrict s1, const wchar_t * restrict s2, size_t n); + +extern wchar_t *wmemcpy(wchar_t * restrict s1, const wchar_t * restrict s2, size_t n); +extern wchar_t *wmemmove(wchar_t *s1, const wchar_t *s2, size_t n); +extern wchar_t *wcscat(wchar_t * restrict s1, const wchar_t * restrict s2); +extern wchar_t *wcsncat(wchar_t * restrict s1, const wchar_t * restrict s2, size_t n); +extern int wcscmp(const wchar_t *s1, const wchar_t *s2); +extern int wcscoll(const wchar_t *s1, const wchar_t *s2); +extern int wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n); +extern size_t wcsxfrm(wchar_t * restrict s1, const wchar_t * restrict s2, size_t n); +extern int wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n); +extern wchar_t *wcschr(const wchar_t *s, wchar_t c); +extern size_t wcscspn(const wchar_t *s1, const wchar_t *s2); +extern wchar_t *wcspbrk(const wchar_t *s1, const wchar_t *s2); +extern wchar_t *wcsrchr(const wchar_t *s, wchar_t c); +extern size_t wcsspn(const wchar_t *s1, const wchar_t *s2); +extern wchar_t *wcsstr(const wchar_t *s1, const wchar_t *s2); +extern wchar_t *wcstok(wchar_t * restrict s1, const wchar_t * restrict s2, wchar_t ** restrict ptr); +extern wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n); +extern size_t wcslen(const wchar_t *s); +extern wchar_t *wmemset(wchar_t *s, wchar_t c, size_t n); +extern size_t wcsftime(wchar_t * restrict s, size_t maxsize, const wchar_t * restrict format, const struct tm * restrict timeptr); +extern wint_t btowc(int c); +extern int wctob(wint_t c); +extern int mbsinit(const mbstate_t *ps); +extern size_t mbrlen(const char * restrict s, size_t n, mbstate_t * restrict ps); +extern size_t mbrtowc(wchar_t * restrict pwc, const char * restrict s, size_t n, mbstate_t * restrict ps); +extern size_t wcrtomb(char * restrict s, wchar_t wc, mbstate_t * restrict ps); +extern size_t mbsrtowcs(wchar_t * restrict dst, const char ** restrict src, size_t len, mbstate_t * restrict ps); +extern size_t wcsrtombs(char * restrict dst, const wchar_t ** restrict src, size_t len, mbstate_t * restrict ps); + + +#endif diff --git a/root/include/scc/wctype.h b/root/include/scc/wctype.h @@ -0,0 +1,30 @@ +#ifndef _WCTYPE_H +#define _WCTYPE_H + +/* TODO: This is only a placeholder */ +typedef int wint_t; +typedef int wctrans_t; +typedef int wctype_t; + +#define WEOF -1 + +extern int iswalnum(wint_t wc); +extern int iswalpha(wint_t wc); +extern int iswblank(wint_t wc); +extern int iswcntrl(wint_t wc); +extern int iswdigit(wint_t wc); +extern int iswgraph(wint_t wc); +extern int iswlower(wint_t wc); +extern int iswprint(wint_t wc); +extern int iswpunct(wint_t wc); +extern int iswspace(wint_t wc); +extern int iswupper(wint_t wc); +extern int iswxdigit(wint_t wc); +extern int iswctype(wint_t wc, wctype_t desc); +extern wctype_t wctype(const char *property); +extern wint_t towlower(wint_t wc); +extern wint_t towupper(wint_t wc); +extern wint_t towctrans(wint_t wc, wctrans_t desc); +extern wctrans_t wctrans(const char *property); + +#endif diff --git a/rootdir/lib/scc/amd64-sysv-linux/README b/root/lib/scc/amd64-sysv-linux/README diff --git a/rootdir/lib/scc/amd64-sysv-netbsd/README b/root/lib/scc/amd64-sysv-netbsd/README diff --git a/rootdir/lib/scc/amd64-sysv-openbsd/README b/root/lib/scc/amd64-sysv-openbsd/README diff --git a/rootdir/lib/scc/i386-sysv-linux/README b/root/lib/scc/i386-sysv-linux/README diff --git a/rootdir/lib/scc/i386-sysv-openbsd/README b/root/lib/scc/i386-sysv-openbsd/README diff --git a/rootdir/lib/scc/z80-scc-none/README b/root/lib/scc/z80-scc-none/README diff --git a/rootdir/libexec/scc/README b/root/libexec/scc/README diff --git a/rootdir/include/scc/assert.h b/rootdir/include/scc/assert.h @@ -1,9 +0,0 @@ - -extern void __assert(char *exp, char *file, long line); - -#undef assert -#ifndef NDEBUG -# define assert(exp) ((exp) ? (void) 0 : __assert(#exp, __FILE__, __LINE__)) -#else -# define assert(exp) ((void)0) -#endif diff --git a/rootdir/include/scc/wchar.h b/rootdir/include/scc/wchar.h @@ -1,11 +0,0 @@ -#ifndef _WCHAR_H -#define _WCHAR_H - -/* TODO: This is only a placeholder */ -typedef long wchar_t; -typedef long wint_t; - -extern size_t wcsnlen(const wchar_t *s, size_t maxlen); -extern wint_t putwc(wchar_t wc, FILE *fp); - -#endif diff --git a/rules.mk b/rules.mk @@ -2,10 +2,10 @@ include $(PROJECTDIR)/config.mk INCLUDE = $(PROJECTDIR)/inc -BINDIR = $(PROJECTDIR)/rootdir/bin -INCDIR = $(PROJECTDIR)/rootdir/include/scc -LIBDIR = $(PROJECTDIR)/rootdir/lib/scc -LIBEXEC = $(PROJECTDIR)/rootdir/libexec/scc +BINDIR = $(PROJECTDIR)/root/bin +INCDIR = $(PROJECTDIR)/root/include/scc +LIBDIR = $(PROJECTDIR)/root/lib/scc +LIBEXEC = $(PROJECTDIR)/root/libexec/scc LIBSCC = $(PROJECTDIR)/lib/scc LIBCOFF32 = $(PROJECTDIR)/lib/coff32 diff --git a/tests/ar/execute/Makefile b/tests/ar/execute/Makefile @@ -1,7 +1,7 @@ .POSIX: PROJECTDIR=$$PWD/../../../ -ROOT=$(PROJECTDIR)/rootdir +ROOT=$(PROJECTDIR)/root all: tests diff --git a/tests/as/execute/Makefile b/tests/as/execute/Makefile @@ -1,7 +1,7 @@ .POSIX: PROJECTDIR=$$PWD/../../../ -ROOT=$(PROJECTDIR)/rootdir +ROOT=$(PROJECTDIR)/root all: tests diff --git a/tests/libc/execute/0002-assert.c b/tests/libc/execute/0002-assert.c @@ -1,4 +1,3 @@ - #include <assert.h> #include <signal.h> #include <stdio.h> diff --git a/tests/libc/execute/Makefile b/tests/libc/execute/Makefile @@ -1,6 +1,6 @@ .POSIX: -ROOT = ../../../rootdir +ROOT = ../../../root CFLAGS = CC = SCCPREFIX=$(ROOT) ./cc.sh diff --git a/tests/nm/execute/Makefile b/tests/nm/execute/Makefile @@ -1,6 +1,6 @@ .POSIX: -ROOT=$(PROJECTDIR)/rootdir +ROOT=$(PROJECTDIR)/root OUT = z80.out diff --git a/tests/scc/error/Makefile b/tests/scc/error/Makefile @@ -1,6 +1,6 @@ .POSIX: -ROOT=../../../rootdir +ROOT=../../../root all: tests diff --git a/tests/scc/execute/0137-int-cast.c b/tests/scc/execute/0137-int-cast.c @@ -1,4 +1,3 @@ - int a; unsigned b; char c; diff --git a/tests/scc/execute/0178-include.c b/tests/scc/execute/0178-include.c @@ -1,4 +1,3 @@ - #define FILE "0178-include.h" #include FILE diff --git a/tests/scc/execute/0178-include.h b/tests/scc/execute/0178-include.h @@ -1,2 +1 @@ - #define RET 0 diff --git a/tests/scc/execute/0179-sizeof.c b/tests/scc/execute/0179-sizeof.c @@ -1,4 +1,3 @@ - int main(void) { diff --git a/tests/scc/execute/0180-incomplete.c b/tests/scc/execute/0180-incomplete.c @@ -1,4 +1,3 @@ - struct dummy; void * diff --git a/tests/scc/execute/0181-stringize.c b/tests/scc/execute/0181-stringize.c @@ -1,4 +1,3 @@ - #define XSTR(x) #x #define STR(x) XSTR(x) #define S y = "str" diff --git a/tests/scc/execute/Makefile b/tests/scc/execute/Makefile @@ -1,6 +1,6 @@ .POSIX: -ROOT=../../../rootdir +ROOT=../../../root all: tests