picolisp

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/picolisp.git/
Log | Files | Refs | README | LICENSE

commit 9047219d7ab9e9255bba6b103fdf189d4f8d2877
parent 9104a52ccdad51d64b33952e13bc18301f8cfc21
Author: Alexander Burger <abu@software-lab.de>
Date:   Tue, 30 Aug 2011 08:36:58 +0200

Added preliminary 64-bit OpenBSD support
Diffstat:
MINSTALL | 10+++++-----
Msrc64/Makefile | 94+++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------
Asrc64/sys/x86-64.openBsd.code.l | 41+++++++++++++++++++++++++++++++++++++++++
Asrc64/sys/x86-64.openBsd.defs.l | 146+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 253 insertions(+), 38 deletions(-)

diff --git a/INSTALL b/INSTALL @@ -1,4 +1,4 @@ -16may11abu +29aug11abu (c) Software Lab. Alexander Burger @@ -42,8 +42,8 @@ installation, and invoke them explicitly as desired. $ (cd src; make picolisp) - or - if you have an x86-64/Linux, x86-64/SunOS or ppc64/Linux system - build - the 64-bit version + or - if you have an x86-64 system (under Linux, SunOS or OpenBSD), or a ppc64 + system (under Linux) - build the 64-bit version $ (cd src64; make picolisp) @@ -60,14 +60,14 @@ installation, and invoke them explicitly as desired. - http://software-lab.de/x86-64.linux.tgz - http://software-lab.de/x86-64.sunOs.tgz + - http://software-lab.de/x86-64.openBsd.tgz - http://software-lab.de/ppc64.linux.tgz - Else, build a 32-bit version first, and use the resulting bin/picolisp to generate the "*.s" files: $ (cd src; make) - $ cd src64 - $ make x86-64.linux.base.s x86-64.linux.ext.s x86-64.linux.ht.s + $ (cd src64; make x86-64.linux) After that, the 64-bit binary can be used to rebuild itself. diff --git a/src64/Makefile b/src64/Makefile @@ -1,4 +1,4 @@ -# 16jun11abu +# 29aug11abu # (c) Software Lab. Alexander Burger .SILENT: @@ -6,15 +6,42 @@ bin = ../bin lib = ../lib -ifeq ($(shell uname), Linux) +ifneq ($(filter x86-64.linux, $(MAKECMDGOALS)),) + UNAME = Linux + MACHINE = x86_64 +else + ifneq ($(filter x86-64.sunOs, $(MAKECMDGOALS)),) + UNAME = SunOS + MACHINE = x86_64 + else + ifneq ($(filter x86-64.openBsd, $(MAKECMDGOALS)),) + UNAME = OpenBSD + MACHINE = x86_64 + else + ifneq ($(filter ppc64.linux, $(MAKECMDGOALS)),) + UNAME = Linux + MACHINE = ppc64 + else + UNAME = $(shell uname) + MACHINE = $(shell uname -m) + endif + endif + endif +endif + +ifeq ($(UNAME), Linux) OS = Linux SYS = linux - ifeq ($(shell uname -m), x86_64) + ifeq ($(MACHINE), x86_64) ARCH = x86-64 + MKASM-BASE = + MKASM-LIB = -fpic AS = as else - ifeq ($(shell uname -m), ppc64) + ifeq ($(MACHINE), ppc64) ARCH = ppc64 + MKASM-BASE = -'prSym "ppc64.symtab"' + MKASM-LIB = -fpic -'rdSym "ppc64.symtab"' AS = as -mppc64 -a64 endif endif @@ -22,24 +49,45 @@ ifeq ($(shell uname), Linux) LD-SHARED = gcc -m64 -shared -export-dynamic STRIP = strip else -ifeq ($(shell uname), SunOS) +ifeq ($(UNAME), SunOS) OS = SunOS SYS = sunOs ARCH = x86-64 + MKASM-BASE = + MKASM-LIB = -fpic AS = gas --64 LD-MAIN = gcc -m64 -lc -lm -ldl -lsocket -lnsl LD-SHARED = gcc -m64 -shared STRIP = strip +else +ifeq ($(UNAME), OpenBSD) + OS = OpenBSD + SYS = openBsd + ARCH = x86-64 + MKASM-BASE = + MKASM-LIB = -fpic + AS = as + LD-MAIN = gcc -m64 -rdynamic -lc -lm -ldl + LD-SHARED = gcc -m64 -shared + STRIP = strip +endif endif endif baseFiles = version.l glob.l main.l \ gc.l apply.l flow.l sym.l subr.l big.l io.l db.l net.l err.l -picolisp: $(bin)/picolisp $(lib)/ext $(lib)/ht +sFiles = $(ARCH).$(SYS).base.s $(ARCH).$(SYS).ext.s $(ARCH).$(SYS).ht.s all: picolisp +x86-64.linux: $(sFiles) +x86-64.sunOs: $(sFiles) +x86-64.openBsd: $(sFiles) +ppc64.linux: $(sFiles) + +picolisp: $(bin)/picolisp $(lib)/ext $(lib)/ht + $(bin)/picolisp: $(ARCH).$(SYS).base.o mkdir -p $(bin) $(lib) $(LD-MAIN) -o $(bin)/picolisp $(ARCH).$(SYS).base.o @@ -58,38 +106,18 @@ $(lib)/ht: $(ARCH).$(SYS).ht.o # Explicit builds for cross-assembly -x86-64.linux.base.s: lib/asm.l arch/x86-64.l $(baseFiles) sys/x86-64.linux.code.l - ./mkAsm x86-64 linux Linux base $(lib)/tags $(baseFiles) sys/x86-64.linux.code.l - -x86-64.linux.ext.s: lib/asm.l arch/x86-64.l ext.l - ./mkAsm x86-64 linux Linux ext "" -fpic ext.l - -x86-64.linux.ht.s: lib/asm.l arch/x86-64.l ht.l - ./mkAsm x86-64 linux Linux ht "" -fpic ht.l - - -ppc64.linux.base.s: lib/asm.l arch/ppc64.l $(baseFiles) sys/ppc64.linux.code.l - ./mkAsm ppc64 linux Linux base $(lib)/tags $(baseFiles) sys/ppc64.linux.code.l -'prSym "ppc64.symtab"' - -ppc64.linux.ext.s: lib/asm.l arch/ppc64.l ext.l ppc64.linux.base.s - ./mkAsm ppc64 linux Linux ext "" -fpic -'rdSym "ppc64.symtab"' ext.l - -ppc64.linux.ht.s: lib/asm.l arch/ppc64.l ht.l ppc64.linux.base.s - ./mkAsm ppc64 linux Linux ht "" -fpic -'rdSym "ppc64.symtab"' ht.l - - -x86-64.sunOs.base.s: lib/asm.l arch/x86-64.l $(baseFiles) sys/x86-64.sunOs.code.l - ./mkAsm x86-64 sunOs SunOS base $(lib)/tags $(baseFiles) sys/x86-64.sunOs.code.l +$(ARCH).$(SYS).base.s: lib/asm.l arch/$(ARCH).l $(baseFiles) sys/$(ARCH).$(SYS).code.l + ./mkAsm $(ARCH) $(SYS) $(OS) base $(lib)/tags $(baseFiles) sys/$(ARCH).$(SYS).code.l $(MKASM-BASE) -x86-64.sunOs.ext.s: lib/asm.l arch/x86-64.l ext.l - ./mkAsm x86-64 sunOs SunOS ext "" -fpic ext.l +$(ARCH).$(SYS).ext.s: lib/asm.l arch/$(ARCH).l ext.l $(ARCH).$(SYS).base.s + ./mkAsm $(ARCH) $(SYS) $(OS) ext "" $(MKASM-LIB) ext.l -x86-64.sunOs.ht.s: lib/asm.l arch/x86-64.l ht.l - ./mkAsm x86-64 sunOs SunOS ht "" -fpic ht.l +$(ARCH).$(SYS).ht.s: lib/asm.l arch/$(ARCH).l ht.l $(ARCH).$(SYS).base.s + ./mkAsm $(ARCH) $(SYS) $(OS) ht "" $(MKASM-LIB) ht.l # Clean up clean: - rm -f *.s *.o + rm -f *.s *.o *.symtab # vi:noet:ts=4:sw=4 diff --git a/src64/sys/x86-64.openBsd.code.l b/src64/sys/x86-64.openBsd.code.l @@ -0,0 +1,41 @@ +# 27aug11abu +# Amit Kulkarni <amitkulz@gmail.com> +# (c) Software Lab. Alexander Burger + +# System macros +(code 'errno_A 0) + call ___errno # Get address of 'errno' + ld4 (A) # Load value + ret + +(code 'errnoC 0) + call ___errno # Get address of 'errno' + xchg A C + st4 (C) # Store new value + ret + +(code 's_isdirS_F 0) # S_ISDIR + ld4 (S `(+ I ST_MODE)) # Get 'st_mode' from 'stat' + and A `S_IFMT + cmp A `S_IFDIR + ret + +(code 'wifstoppedS_F 0) # WIFSTOPPED + ld A 0 + cc WIFSTOPPED((S I)) # Get status + nul4 + ret + +(code 'wifsignaledS_F 0) # WIFSIGNALED + ld A 0 + cc WIFSIGNALED((S I)) # Get status + nul4 + ret + +(code 'wtermsigS_A 0) # WTERMSIG + ld A 0 + cc WTERMSIG((S I)) # Get status + nul4 + ret + +# vi:et:ts=3:sw=3 diff --git a/src64/sys/x86-64.openBsd.defs.l b/src64/sys/x86-64.openBsd.defs.l @@ -0,0 +1,146 @@ +# 25aug11abu +# Amit Kulkarni <amitkulz@gmail.com> +# (c) Software Lab. Alexander Burger + +# errno +(equ ENOENT 2) # No such file or directory +(equ EINTR 4) # Interrupted system call +(equ EBADF 9) # Bad file number +(equ EAGAIN 11) # Try again +(equ EACCES 13) # Permission denied +(equ EPIPE 32) # Broken pipe +(equ ECONNRESET 54) # Connection reset by peer + +# open/fcntl +(equ O_RDONLY 0) +(equ O_WRONLY 1) +(equ O_RDWR 2) +(equ O_CREAT 64) +(equ O_EXCL 128) +(equ O_TRUNC 512) +(equ O_APPEND 1024) +(equ F_GETFD 1) +(equ F_SETFD 2) +(equ FD_CLOEXEC 1) + +# stdio +(equ BUFSIZ 1024) +(equ PIPE_BUF 512) + +(equ MAXPATHLEN 1024) + +# dlfcn +(equ RTLD_LAZY 1) +(equ RTLD_GLOBAL 256) + +# fcntl +(equ FLOCK 32) # File lock structure +(equ L_TYPE 0) # 2 +(equ L_WHENCE 2) # 2 +(equ L_START 8) +(equ L_LEN 16) +(equ L_PID 24) +(equ SEEK_SET 0) +(equ SEEK_CUR 1) +(equ F_RDLCK 0) +(equ F_WRLCK 1) +(equ F_UNLCK 2) +(equ F_GETFL 3) +(equ F_SETFL 4) +(equ F_GETLK 5) +(equ F_SETLK 6) +(equ F_SETLKW 7) +(equ F_SETOWN 8) +(equ O_NONBLOCK 2048) +(equ O_ASYNC 8192) + +# stat +(equ STAT 144) # File status structure +(equ ST_MODE 24) # 4 +(equ ST_SIZE 48) +(equ ST_MTIME 88) +(equ S_IFMT (hex "F000")) +(equ S_IFDIR (hex "4000")) + +# times +(equ TMS 32) # 'times' structure +(equ TMS_UTIME 0) +(equ TMS_STIME 8) + +# termios +(equ TERMIOS (+ 44 4)) # Terminal I/O structure (+ Padding) +(equ C_IFLAG 0) +(equ C_LFLAG 12) +(equ C_CC 16) +(equ ISIG 128) +(equ VMIN 16) +(equ VTIME 17) +(equ TCSADRAIN 1) + +# signal +(equ SIGACTION 16) # Sigaction structure +(equ SIGSET_T 8) # 4 -> aligned to word size +(equ SA_HANDLER 0) +(equ SA_MASK 8) +(equ SA_FLAGS 12) + +(equ SIG_DFL 0) +(equ SIG_IGN 1) +(equ SIG_UNBLOCK 2) + +(equ SIGHUP 1) # Signals +(equ SIGINT 2) +(equ SIGUSR1 10) +(equ SIGUSR2 12) +(equ SIGPIPE 13) +(equ SIGALRM 14) +(equ SIGTERM 15) +(equ SIGCHLD 17) +(equ SIGCONT 18) +(equ SIGSTOP 19) +(equ SIGTSTP 20) +(equ SIGTTIN 21) +(equ SIGTTOU 22) +(equ SIGIO 29) +(equ SIGNALS 30) # Highest used signal number plus 1 + +# wait +(equ WNOHANG 1) +(equ WUNTRACED 2) + +# select +(equ FD_SET 128) # 1024 bit + +# time +(equ TM_SEC 0) +(equ TM_MIN 4) +(equ TM_HOUR 8) +(equ TM_MDAY 12) +(equ TM_MON 16) +(equ TM_YEAR 20) + +# dir +(equ D_NAME 8) + +# Sockets +(equ HOSTENT 32) +(equ H_NAME 0) +(equ H_LENGTH 20) +(equ H_ADDR_LIST 24) + +(equ IN_ADDR 4) +(equ S_ADDR 0) + +(equ SOCKADDR_IN 32) +(equ SIN_ADDR 4) +(equ SIN_ADDR.S_ADDR 4) +(equ SIN_PORT 2) +(equ SIN_FAMILY 1) +(equ AF_INET 2) +(equ SOCK_STREAM 1) +(equ SOCK_DGRAM 2) +(equ INADDR_ANY 0) +(equ SOL_SOCKET 65535) +(equ SO_REUSEADDR 4) + +# vi:et:ts=3:sw=3