ref: 78557956a11d64da5519d76561f5ff1c318d1124
parent: 47d23949f797eeb99110bfad4cac4fbddc0081e0
parent: c12769c0bab4525e8f34ea63296cd3a2feb1bc32
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Aug 28 06:49:16 EDT 2018
Merge branch 'master' of ssh://simple-cc.org:/var/gitrepos/scc
--- a/driver/posix/scc.c
+++ b/driver/posix/scc.c
@@ -151,13 +151,13 @@
break;
}
n = snprintf(NULL, 0,
- "%s/lib/scc/crt/%s-%s-%s/crt.o",
+ "%s/lib/scc/%s-%s-%s/crt.o",
prefix, arch, abi, sys);
if (n < 0)
die("scc: wrong crt file name");
crt = xmalloc(++n);
sprintf(crt,
- "%s/lib/scc/crt/%s-%s-%s/crt.o",
+ "%s/lib/scc/%s-%s-%s/crt.o",
prefix, arch, abi, sys);
addarg(tool, crt);
break;
--- a/inc/ldflags.def.h
+++ b/inc/ldflags.def.h
@@ -1,6 +1,5 @@
char *ldflags[] = {
"-static",
- /* on OpenBSD, disable pie */
- /* "-nopie", */
+ "-z","nodefaultlib",
NULL
};
--- a/inc/syscrts.def.h
+++ b/inc/syscrts.def.h
@@ -1,5 +1,5 @@
char *syscrts[] = {
/* configure below your system crts */
- /* PREFIX "/lib/scc/crt0.o", */
+ /* PREFIX "/lib/scc/crt.o", */
NULL
};
--- a/ld/Makefile
+++ b/ld/Makefile
@@ -7,7 +7,7 @@
OBJ = main.o coff32.o obj.o
LIB = $(LIBDIR)/libscc.a $(LIBDIR)/libcoff32.a
-TARGET = $(BINDIR)/ld
+TARGET = ld
all: $(TARGET)
--- a/lib/c/_fpopen.c
+++ b/lib/c/_fpopen.c
@@ -2,13 +2,15 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
+#include <sys.h>
#include "syscall.h"
+#include "libc.h"
#undef fopen
FILE *
_fpopen(const char * restrict fname,
- const char * restrict mode,
- FILE * restrict fp)
+ const char * restrict mode,
+ FILE * restrict fp)
{
int i, flags, fd, rw, bin;
--- a/lib/c/fopen.c
+++ b/lib/c/fopen.c
@@ -3,6 +3,7 @@
#include <stdio.h>
#include "syscall.h"
+#include "libc.h"
#undef fopen
--- a/lib/c/freopen.c
+++ b/lib/c/freopen.c
@@ -2,6 +2,7 @@
#include <stdio.h>
#include "syscall.h"
+#include "libc.h"
#undef freopen
FILE *
--- /dev/null
+++ b/lib/c/libc.h
@@ -1,0 +1,5 @@
+#ifdef stdin
+extern FILE *_fpopen(const char * restrict fname,
+ const char * restrict mode,
+ FILE * restrict fp);
+#endif
--- a/lib/c/syscall.h
+++ b/lib/c/syscall.h
@@ -6,18 +6,3 @@
extern int _lseek(int fd, long off, int whence);
extern void _Exit(int status);
extern int _access(char *path, int mode);
-
-/* auxiliar functions */
-
-#ifdef stdin
-extern FILE *_fpopen(const char * restrict fname,
- const char * restrict mode,
- FILE * restrict fp);
-#endif
-
-#define O_WRONLY 1
-#define O_RDONLY 2
-#define O_RDWR 4
-#define O_TRUNC 8
-#define O_APPEND 16
-#define O_CREAT 32
--- a/lib/c/target/Makefile
+++ b/lib/c/target/Makefile
@@ -4,13 +4,12 @@
include $(PROJECTDIR)/rules.mk
DIRS = amd64-sysv-linux \
- amd64-sysv-openbsd
+ amd64-sysv-openbsd \
+ amd64-sysv-netbsd \
-# i386-sysv-linux-elf \
-# z80-scc-none-none
+all clean distclean:
+ $(FORALL)
dep:
./script/objlst.sh
-
-all clean distclean:
$(FORALL)
--- a/lib/c/target/amd64-sysv-linux/.gitignore
+++ b/lib/c/target/amd64-sysv-linux/.gitignore
@@ -6,5 +6,5 @@
_lseek.s
_open.s
_read.s
-_rt_sigaction.s
+_sigaction.s
_write.s
--- a/lib/c/target/amd64-sysv-linux/Makefile
+++ b/lib/c/target/amd64-sysv-linux/Makefile
@@ -4,7 +4,7 @@
include $(PROJECTDIR)/rules.mk
SYSNAME = amd64-sysv-linux
-SCC_CFLAGS = -nostdinc -I$(INCDIR) -I$(INCDIR)/bits/amd64-sysv/
+SCC_CFLAGS = -static -nostdinc -I$(INCDIR) -I$(INCDIR)/bits/amd64-sysv/ -I.
SYSOBJ = raise.o signal.o
include syscall.mk
--- /dev/null
+++ b/lib/c/target/amd64-sysv-linux/sys.h
@@ -1,0 +1,20 @@
+
+#define O_RDONLY 0x00000000
+#define O_WRONLY 0x00000001
+#define O_RDWR 0x00000002
+
+#define O_TRUNC 0x00000400
+#define O_APPEND 0x00000008
+#define O_CREAT 0x00000200
+
+typedef int pid_t;
+
+struct sigaction {
+ void (*sa_handler)(int);
+ int sa_mask;
+ int sa_flags;
+};
+
+extern pid_t _getpid(void);
+extern int _kill(pid_t pid, int signum);
+extern int _sigaction(int sig, struct sigaction *new, struct sigaction *old);
--- a/lib/c/target/amd64-sysv-linux/syscall.lst
+++ b/lib/c/target/amd64-sysv-linux/syscall.lst
@@ -1,13 +1,11 @@
#number name
-0 _read
-1 _write
-2 _open
-3 _close
-3 _lseek
-12 _brk
-13 _rt_sigaction
-38 _getpid
-60 _Exit
-32 _kill
-39 _getpid
-62 _kill
+1 _Exit
+3 _read
+4 _write
+5 _open
+6 _close
+17 _brk
+20 _getpid
+37 _kill
+46 _sigaction
+199 _lseek
--- a/lib/c/target/amd64-sysv-linux/syscall.mk
+++ b/lib/c/target/amd64-sysv-linux/syscall.mk
@@ -1,1 +1,1 @@
-SYSCALL = _read.o _write.o _open.o _close.o _lseek.o _brk.o _rt_sigaction.o _getpid.o _Exit.o _kill.o _getpid.o _kill.o
+SYSCALL = _Exit.o _read.o _write.o _open.o _close.o _brk.o _getpid.o _kill.o _sigaction.o _lseek.o
--- /dev/null
+++ b/lib/c/target/amd64-sysv-netbsd/.gitignore
@@ -1,0 +1,10 @@
+_Exit.s
+_brk.s
+_close.s
+_getpid.s
+_kill.s
+_lseek.s
+_open.s
+_read.s
+_write.s
+_sigaction.s
--- /dev/null
+++ b/lib/c/target/amd64-sysv-netbsd/Makefile
@@ -1,0 +1,15 @@
+.POSIX:
+
+PROJECTDIR = ../../../..
+include $(PROJECTDIR)/rules.mk
+
+SYSNAME = amd64-sysv-netbsd
+SCC_CFLAGS = -static -nostdinc -I$(INCDIR) -I$(INCDIR)/bits/amd64-sysv/ -I.
+SYSOBJ = raise.o signal.o
+
+include syscall.mk
+include ../script/objlst.mk
+include ../script/common.mk
+
+raise.o: ../posix/raise.c ../../syscall.h
+signal.o: ../posix/signal.c ../../syscall.h
--- /dev/null
+++ b/lib/c/target/amd64-sysv-netbsd/sys.h
@@ -1,0 +1,20 @@
+
+#define O_RDONLY 0x00000000
+#define O_WRONLY 0x00000001
+#define O_RDWR 0x00000002
+
+#define O_TRUNC 0x00000400
+#define O_APPEND 0x00000008
+#define O_CREAT 0x00000200
+
+typedef int pid_t;
+
+struct sigaction {
+ void (*sa_handler)(int);
+ int sa_mask;
+ int sa_flags;
+};
+
+extern pid_t _getpid(void);
+extern int _kill(pid_t pid, int signum);
+extern int _sigaction(int sig, struct sigaction *new, struct sigaction *old);
--- /dev/null
+++ b/lib/c/target/amd64-sysv-netbsd/syscall.lst
@@ -1,0 +1,11 @@
+#number name
+1 _Exit
+3 _read
+4 _write
+5 _open
+6 _close
+17 _brk
+20 _getpid
+37 _kill
+199 _lseek
+340 _sigaction
--- /dev/null
+++ b/lib/c/target/amd64-sysv-netbsd/syscall.mk
@@ -1,0 +1,1 @@
+SYSCALL = _Exit.o _read.o _write.o _open.o _close.o _brk.o _getpid.o _kill.o _sigaction.o _lseek.o
--- /dev/null
+++ b/lib/c/target/amd64-sysv-openbsd/.gitignore
@@ -1,0 +1,10 @@
+_Exit.s
+_brk.s
+_close.s
+_getpid.s
+_kill.s
+_lseek.s
+_open.s
+_read.s
+_sigaction.s
+_write.s
--- a/lib/c/target/amd64-sysv-openbsd/Makefile
+++ b/lib/c/target/amd64-sysv-openbsd/Makefile
@@ -1,10 +1,15 @@
.POSIX:
PROJECTDIR = ../../../..
-SYSNAME = amd64-sysv-openbsd
-
include $(PROJECTDIR)/rules.mk
+
+SYSNAME = amd64-sysv-netbsd
+SCC_CFLAGS = -static -nostdinc -I$(INCDIR) -I$(INCDIR)/bits/amd64-sysv/ -I.
+SYSOBJ = raise.o signal.o
+
+include syscall.mk
include ../script/objlst.mk
include ../script/common.mk
-SCC_CFLAGS = -nostdinc -I$(INCDIR) -I$(INCDIR)/bits/amd64-sysv/
+raise.o: ../posix/raise.c ../../syscall.h
+signal.o: ../posix/signal.c ../../syscall.h
--- /dev/null
+++ b/lib/c/target/amd64-sysv-openbsd/sys.h
@@ -1,0 +1,20 @@
+
+#define O_RDONLY 0x00000000
+#define O_WRONLY 0x00000001
+#define O_RDWR 0x00000002
+
+#define O_TRUNC 0x00000400
+#define O_APPEND 0x00000008
+#define O_CREAT 0x00000200
+
+typedef int pid_t;
+
+struct sigaction {
+ void (*sa_handler)(int);
+ int sa_mask;
+ int sa_flags;
+};
+
+extern pid_t _getpid(void);
+extern int _kill(pid_t pid, int signum);
+extern int _sigaction(int sig, struct sigaction *new, struct sigaction *old);
--- /dev/null
+++ b/lib/c/target/amd64-sysv-openbsd/syscall.lst
@@ -1,0 +1,11 @@
+#number name
+1 _Exit
+3 _read
+4 _write
+5 _open
+6 _close
+17 _brk
+20 _getpid
+37 _kill
+46 _sigaction
+199 _lseek
--- /dev/null
+++ b/lib/c/target/amd64-sysv-openbsd/syscall.mk
@@ -1,0 +1,1 @@
+SYSCALL = _Exit.o _read.o _write.o _open.o _close.o _brk.o _getpid.o _kill.o _sigaction.o _lseek.o
--- a/lib/c/target/posix/raise.c
+++ b/lib/c/target/posix/raise.c
@@ -1,14 +1,9 @@
#include <stddef.h>
#include <signal.h>
-#include "../../syscall.h"
+#include <sys.h>
#undef raise
-
-/* TODO: Add sys.h and store these definitions there */
-
-extern int _getpid(void);
-extern int _kill(int pid, int signum);
int
raise(int signum)
--- a/lib/c/target/posix/signal.c
+++ b/lib/c/target/posix/signal.c
@@ -1,9 +1,22 @@
+#include <stddef.h>
#include <signal.h>
+#include <sys.h>
+#include "../../syscall.h"
+
#undef signal
void
(*signal(int signum, void (*func)(int)))(int)
{
+ struct sigaction sa = {
+ .sa_handler = func,
+ .sa_flags = 0,
+ };
+
+ if (_sigaction(signum, &sa, &sa) < 0)
+ return SIG_ERR;
+
+ return sa.sa_handler;
}
--- a/lib/c/target/script/common.mk
+++ b/lib/c/target/script/common.mk
@@ -14,3 +14,6 @@
$(SYSASM): syscall.lst
../script/amd64-sysv.sh
+
+dep:
+ ../script/syscall.sh
--- a/lib/crt/Makefile
+++ b/lib/crt/Makefile
@@ -3,31 +3,12 @@
PROJECTDIR = ../..
include $(PROJECTDIR)/rules.mk
-#TARGETS = $(LIBDIR)/amd64-sysv-linux/crt.o \
-# $(LIBDIR)/amd64-sysv-openbsd/crt.o \
-# $(LIBDIR)/i386-sysv-linux/crt.o \
-# $(LIBDIR)/i386-sysv-openbsd/crt.o \
-# $(LIBDIR)/z80-scc-none/z80-scc-none/crt.o
+DIRS = amd64-sysv-linux amd64-sysv-openbsd amd64-sysv-netbsd
-TARGETS = $(LIBDIR)/amd64-sysv-linux/crt.o
+all: $(DIRS)
-all: $(TARGETS)
+$(DIRS): FORCE
+ @cd $@ && $(MAKE)
-$(LIBDIR)/amd64-sysv-linux/crt.o: amd64-sysv-linux/crt.o
- cp amd64-sysv-linux/crt.o $@
-
-$(LIBDIR)/amd64-sysv-openbsd/crt.o: amd64-sysv-openbsd/crt.o
- cp amd64-sysv-openbsd/crt.o $@
-
-$(LIBDIR)/i386-sysv-linux/crt.o: i386-sysv-linux/crt.o
- cp i386-sysv-linux/crt.o $@
-
-$(LIBDIR)/i386-sysv-openbsd/crt.o: i386-sysv-openbsd/crt.o
- cp i386-sysv-openbsd/crt.o $@
-
-$(LIBDIR)/z80-scc-none/crt.o: z80-scc-none/crt.o
- cp z80-scc-none/crt.o $@
-
clean:
- rm -f */*.o
- rm -f $(TARGETS)
+ $(FORALL)
--- /dev/null
+++ b/lib/crt/amd64-sysv-linux/Makefile
@@ -1,0 +1,9 @@
+.POSIX:
+
+PROJECTDIR = ../../..
+include $(PROJECTDIR)/rules.mk
+
+CRT = $(LIBDIR)/amd64-sysv-linux/crt.o
+TARGETS = $(CRT)
+
+include ../common.mk
--- a/lib/crt/amd64-sysv-linux/crt.s
+++ b/lib/crt/amd64-sysv-linux/crt.s
@@ -5,4 +5,4 @@
_start:
call main
movl %eax, %edi
- call exit
+ jmp exit
--- /dev/null
+++ b/lib/crt/amd64-sysv-netbsd/Makefile
@@ -1,0 +1,9 @@
+.POSIX:
+
+PROJECTDIR = ../../..
+include $(PROJECTDIR)/rules.mk
+
+CRT = $(LIBDIR)/amd64-sysv-netbsd/crt.o
+TARGETS = $(CRT)
+
+include ../common.mk
--- /dev/null
+++ b/lib/crt/amd64-sysv-netbsd/crt.s
@@ -1,0 +1,17 @@
+ .file "crt.s"
+
+ .section .note.netbsd.ident
+ .long 7
+ .long 4
+ .long 1
+ .ascii "NetBSD\0"
+ .p2align 2
+ .long 200000000
+
+ .text
+ .align 8
+ .global _start
+_start:
+ call main
+ movl %eax, %edi
+ jmp exit
--- /dev/null
+++ b/lib/crt/amd64-sysv-openbsd/Makefile
@@ -1,0 +1,9 @@
+.POSIX:
+
+PROJECTDIR = ../../..
+include $(PROJECTDIR)/rules.mk
+
+CRT = $(LIBDIR)/amd64-sysv-openbsd/crt.o
+TARGETS = $(CRT)
+
+include ../common.mk
--- a/lib/crt/amd64-sysv-openbsd/crt.s
+++ b/lib/crt/amd64-sysv-openbsd/crt.s
@@ -15,9 +15,4 @@
_start:
call main
movl %eax, %edi
- call exit
-
- .data
- .global __guard_local
-__guard_local:
- .long 0
+ jmp exit
--- /dev/null
+++ b/lib/crt/common.mk
@@ -1,0 +1,8 @@
+all: $(TARGETS)
+
+$(CRT): crt.o
+ cp crt.o $@
+
+clean:
+ rm -f *.o
+ rm -f $(TARGETS)
--- a/rootdir/include/scc/bits/amd64-sysv/arch/signal.h
+++ b/rootdir/include/scc/bits/amd64-sysv/arch/signal.h
@@ -1,8 +1,8 @@
typedef int sig_atomic_t;
-#define SIG_ERR -1
-#define SIG_DFL 0
-#define SIG_IGN 1
+#define SIG_ERR ((void (*)(int))-1)
+#define SIG_DFL ((void (*)(int)) 0)
+#define SIG_IGN ((void (*)(int)) 1)
#define SIGHUP 1
#define SIGINT 2
--- /dev/null
+++ b/rootdir/lib/scc/amd64-sysv-netbsd/README
@@ -1,0 +1,1 @@
+This is a placeholder for VCS
--- a/tests/ar/execute/Makefile
+++ b/tests/ar/execute/Makefile
@@ -6,7 +6,7 @@
all: tests
tests: master.a
- PATH=$(ROOT)/bin:$$PATH ./chktest.sh
+ TZ=UTC PATH=$(ROOT)/bin:$$PATH ./chktest.sh
master.a:
./mkmaster.sh
--- a/tests/ar/execute/mkmaster.sh
+++ b/tests/ar/execute/mkmaster.sh
@@ -2,7 +2,7 @@
uid=`id -u`
gid=`id -g`
-time=`date -d "1980-01-01" +%s`
+time=315532800
cat <<EOF >master.a
!<arch>
--- a/tests/libc/execute/cc.sh
+++ b/tests/libc/execute/cc.sh
@@ -24,7 +24,7 @@
esac
done
-sys=${sys:-linux}
+sys=${sys:-`uname | tr 'A-Z' 'a-z'`}
abi=${abi:-amd64-sysv}
root=${root:-$SCCPREFIX}
inc=$root/include/scc
@@ -33,5 +33,4 @@
obj=${1%.c}.o
c99 -nostdinc -I$inc -I$arch_inc -c $1
-echo ld -L$lib $lib/crt.o $obj -lc >&2
-ld -L$lib $lib/crt.o $obj -lc
+ld -z nodefaultlib -static -L$lib $lib/crt.o $obj -lc
--- a/tests/libc/execute/chktest.sh
+++ b/tests/libc/execute/chktest.sh
@@ -3,13 +3,12 @@
file=${1?' empty input file'}
ttyflags=`stty -g`
-trap "stty $ttyflags;tabs -8;rm -f a.out" 0 1 2 3 15
+#trap "stty $ttyflags;tabs -8;rm -f a.out" 0 1 2 3 15
stty tabs
tabs 40
ulimit -c 0
rm -f test.log
-cat $file |
while read i state
do
echo $i >>test.log
@@ -19,4 +18,4 @@
(./cc.sh $CFLAGS $i && ./a.out) 2>test.log &&
echo "[OK]" || echo "[FAILED]"
-done
+done < $file
--- a/tests/nm/execute/Makefile
+++ b/tests/nm/execute/Makefile
@@ -1,6 +1,5 @@
.POSIX:
-PROJECTDIR=$$PWD/../../..
ROOT=$(PROJECTDIR)/rootdir
OUT = z80.out
--- a/tests/scc/error/Makefile
+++ b/tests/scc/error/Makefile
@@ -1,10 +1,11 @@
.POSIX:
+ROOT=../../../rootdir
+
all: tests
tests:
- CFLAGS='' SCCEXECPATH=../../bin PATH=../../bin:$$PATH ./chktest.sh < scc-tests.lst
+ @CFLAGS='' SCCPREFIX=$(ROOT) PATH=$(ROOT)/bin:$$PATH ./chktest.sh scc-tests.lst
clean:
rm -f *.as *.o *.ir *.qbe *core test.log
-
--- a/tests/scc/error/chktest.sh
+++ b/tests/scc/error/chktest.sh
@@ -1,9 +1,11 @@
#!/bin/sh
+file=${1?' empty input file'}
err=/tmp/$$.err
chk=/tmp/$$.chk
trap "tabs -8;rm -f a.out *.o $chk $err" 0 1 2 3 15
+stty tabs
tabs 40
ulimit -c 0
rm -f test.log
@@ -17,4 +19,4 @@
echo "/^PATTERN/+;/^\./-w $chk" | ed -s $i
diff -c $chk $err >> test.log && echo [OK] || echo [FAILED]
rm -f *.o
-done
+done < $file
--- a/tests/scc/execute/0137-int-cast.c
+++ b/tests/scc/execute/0137-int-cast.c
@@ -1,137 +1,3 @@
-/*
-name: TEST013
-description: Basic test of integer types and integer conversions
-comments: This test depends of the configuration in the type system.
- With the current configuration char is equal to unsigned char,
- short is equal to int, and unsigned short is equal to unsigned.
-error:
-output:
-G1 I "a
-G2 N "b
-G3 K "c
-G4 C "d
-G5 K "e
-G6 W "f
-G7 Z "g
-G8 Q "h
-G9 O "i
-G10 I "j
-G11 N "k
-G13 I F "main
-{
-\
- G1 G2 gI :I
- G1 G3 gI :I
- G1 G4 gI :I
- G1 G5 gI :I
- G1 G6 gI :I
- G1 G7 gI :I
- G1 G8 gI :I
- G1 G9 gI :I
- G1 G10 :I
- G1 G11 gI :I
- G2 G1 gN :N
- G2 G3 gN :N
- G2 G4 gN :N
- G2 G5 gN :N
- G2 G6 gN :N
- G2 G7 gN :N
- G2 G8 gN :N
- G2 G9 gN :N
- G2 G10 gN :N
- G2 G11 :N
- G3 G1 gK :K
- G3 G2 gK :K
- G3 G4 gK :K
- G3 G5 :K
- G3 G6 gK :K
- G3 G7 gK :K
- G3 G8 gK :K
- G3 G9 gK :K
- G3 G10 gK :K
- G3 G11 gK :K
- G4 G1 gC :C
- G4 G2 gC :C
- G4 G3 gC :C
- G4 G5 gC :C
- G4 G6 gC :C
- G4 G7 gC :C
- G4 G8 gC :C
- G4 G9 gC :C
- G4 G10 gC :C
- G4 G11 gC :C
- G5 G1 gK :K
- G5 G2 gK :K
- G5 G3 :K
- G5 G4 gK :K
- G5 G6 gK :K
- G5 G7 gK :K
- G5 G8 gK :K
- G5 G9 gK :K
- G5 G10 gK :K
- G5 G11 gK :K
- G6 G1 gW :W
- G6 G2 gW :W
- G6 G3 gW :W
- G6 G4 gW :W
- G6 G5 gW :W
- G6 G7 gW :W
- G6 G8 gW :W
- G6 G9 gW :W
- G6 G10 gW :W
- G6 G11 gW :W
- G7 G1 gZ :Z
- G7 G2 gZ :Z
- G7 G3 gZ :Z
- G7 G4 gZ :Z
- G7 G5 gZ :Z
- G7 G6 gZ :Z
- G7 G8 gZ :Z
- G7 G9 gZ :Z
- G7 G10 gZ :Z
- G7 G11 gZ :Z
- G8 G1 gQ :Q
- G8 G2 gQ :Q
- G8 G3 gQ :Q
- G8 G4 gQ :Q
- G8 G5 gQ :Q
- G8 G6 gQ :Q
- G8 G7 gQ :Q
- G8 G9 gQ :Q
- G8 G10 gQ :Q
- G8 G11 gQ :Q
- G9 G1 gO :O
- G9 G2 gO :O
- G9 G3 gO :O
- G9 G4 gO :O
- G9 G5 gO :O
- G9 G6 gO :O
- G9 G7 gO :O
- G9 G8 gO :O
- G9 G10 gO :O
- G9 G11 gO :O
- G10 G1 :I
- G10 G2 gI :I
- G10 G3 gI :I
- G10 G4 gI :I
- G10 G5 gI :I
- G10 G6 gI :I
- G10 G7 gI :I
- G10 G8 gI :I
- G10 G9 gI :I
- G10 G11 gI :I
- G11 G1 gN :N
- G11 G2 :N
- G11 G3 gN :N
- G11 G4 gN :N
- G11 G5 gN :N
- G11 G6 gN :N
- G11 G7 gN :N
- G11 G8 gN :N
- G11 G10 gN :N
- G11 G9 gN :N
-}
-*/
int a;
unsigned b;
--- a/tests/scc/execute/0154-if-defined
+++ /dev/null
@@ -1,15 +1,0 @@
-#if defined(FOO)
-int a;
-#elif !defined(FOO) && defined(BAR)
-int b;
-#elif !defined(FOO) && !defined(BAR)
-int c;
-#else
-int d;
-#endif
-
-int
-main(void)
-{
- return c;
-}
--- /dev/null
+++ b/tests/scc/execute/0154-if-defined.c
@@ -1,0 +1,15 @@
+#if defined(FOO)
+int a;
+#elif !defined(FOO) && defined(BAR)
+int b;
+#elif !defined(FOO) && !defined(BAR)
+int c;
+#else
+int d;
+#endif
+
+int
+main(void)
+{
+ return c;
+}
--- /dev/null
+++ b/tests/scc/execute/0181-stringize.c
@@ -1,0 +1,17 @@
+
+#define XSTR(x) #x
+#define STR(x) XSTR(x)
+#define S y = "str"
+
+int
+main()
+{
+ char *s, *t = STR(S);
+
+ for (s = "y = \"str\""; *s && *t; ++s, ++t) {
+ if (*s != *t)
+ return 1;
+ }
+
+ return 0;
+}
--- a/tests/scc/execute/Makefile
+++ b/tests/scc/execute/Makefile
@@ -5,7 +5,7 @@
all: tests
tests:
- CFLAGS='' SCCPREFIX=$(ROOT) PATH=$(ROOT)/bin:$$PATH ./chktest.sh scc-tests.lst
+ @CFLAGS='' SCCPREFIX=$(ROOT) PATH=$(ROOT)/bin:$$PATH ./chktest.sh scc-tests.lst
clean:
rm -f *.as *.o *.ir *.qbe *core test.log
--- a/tests/scc/execute/chktest.sh
+++ b/tests/scc/execute/chktest.sh
@@ -8,7 +8,13 @@
ulimit -c 0
rm -f test.log
-cat $file |
+SYS=`uname | tr A-Z a-z`
+FORMAT=elf
+ABI=sysv
+ARCH=amd64
+
+export SYS FORMAT ABI ARCH
+
while read i state
do
echo $i >>test.log
@@ -15,6 +21,7 @@
printf "%s\t" $i
printf "%s" $state
rm -f a.out
- (scc -Isysinclude $CFLAGS "$i" && ./a.out) 2>test.log &&
+
+ (scc -Isysinclude $CFLAGS "$i" && ./a.out) 2>>test.log &&
echo "[OK]" || echo "[FAILED]"
-done
+done < $file
--- a/tests/scc/execute/scc-tests.lst
+++ b/tests/scc/execute/scc-tests.lst
@@ -125,24 +125,24 @@
0132-forward.c [TODO]
0133-ftn-ptr.c [TODO]
0134-arith.c [TODO]
-0135-unary.c [TODO]
-0136-if.c [TODO]
+0135-unary.c
+0136-if.c
0137-int-cast.c [TODO]
-0138-namespace.c [TODO]
+0138-namespace.c
0139-ptr-ary.c [TODO]
0140-int-fold.c [TODO]
0141-int-iden.c [TODO]
0142-char-const.c [TODO]
-0143-int-const.c [TODO]
-0144-long-const.c [TODO]
+0143-int-const.c
+0144-long-const.c
0145-llong-const.c [TODO]
-0146-ifdef.c [TODO]
-0147-intern-cpp.c [TODO]
-0148-cpp-string.c [TODO]
-0149-define.c [TODO]
-0150-define.c [TODO]
+0146-ifdef.c
+0147-intern-cpp.c
+0148-cpp-string.c
+0149-define.c
+0150-define.c
0151-vararg.c [TODO]
-0152-cat.c [TODO]
+0152-cat.c
0153-cpp-string.c [TODO]
0154-if-defined [TODO]
0155-struct-compl.c [TODO]
@@ -152,7 +152,7 @@
0159-typedef.c [TODO]
0160-cpp-if.c [TODO]
0161-struct.c [TODO]
-0162-array.c [TODO]
+0162-array.c
0163-array.c [TODO]
0164-struct.c [TODO]
0165-struct.c [TODO]
@@ -163,11 +163,12 @@
0170-line.c [TODO]
0171-macros.c [TODO]
0172-hexa.c [TODO]
-0173-macro.c [TODO]
+0173-macro.c
0174-decay.c [TODO]
-0175-defined.c [TODO]
+0175-defined.c
0176-macro.c [TODO]
0177-literal.c [TODO]
0178-include.c [TODO]
0179-sizeof.c [TODO]
0180-incomplete.c
+0181-stringize.c [TODO]