Chez Scheme: add PPC Mac OS

This commit is contained in:
Matthew Flatt 2020-11-29 21:15:37 -07:00
parent 6e0c9c00b9
commit ea620f2a4a
16 changed files with 138 additions and 28 deletions

View File

@ -0,0 +1,32 @@
# Mf-ppc32osx
m ?= ppc32osx
Cpu ?= PPC32
mdinclude = -I/opt/X11/include/
o = o
mdsrc ?= ppc32.c
mdobj ?= ppc32.o
.SUFFIXES:
.SUFFIXES: .c .o
.c.o:
$C -c -D${Cpu} -I${Include} ${zlibInc} ${LZ4Inc} ${mdinclude} $*.c
include Mf-base
${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep}
${LD} -r -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib}
${KernelLib}: ${kernelobj}
${AR} ${ARFLAGS} ${KernelLib} ${kernelobj}
${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main}
$C -o ${Scheme} ${Main} ${Kernel} ${KernelLinkLibs} ${LDFLAGS} ${LIBS}
../zlib/configure.log:
(cd ../zlib; ${SetConfigEnv} CFLAGS="${CFLAGS}" ./configure)
../lz4/lib/liblz4.a: ${LZ4Sources}
(cd ../lz4/lib; ${SetConfigEnv} CFLAGS="${CFLAGS}" ${MAKE} liblz4.a)

View File

@ -0,0 +1,5 @@
# Mf-tppc32osx
m ?= tppc32osx
include Mf-ppc32osx

View File

@ -54,11 +54,16 @@ void S_doflush(uptr start, uptr end) {
}
void S_machine_init() {
#if defined(__linux__)
if ((l1_dcache_line_size = sysconf(_SC_LEVEL1_DCACHE_LINESIZE)) <= 0) {
l1_dcache_line_size = DEFAULT_L1_MAX_CACHE_LINE_SIZE;
}
if ((l1_icache_line_size = sysconf(_SC_LEVEL1_ICACHE_LINESIZE)) <= 0) {
l1_icache_line_size = DEFAULT_L1_MAX_CACHE_LINE_SIZE;
}
#else
l1_dcache_line_size = DEFAULT_L1_MAX_CACHE_LINE_SIZE;
l1_icache_line_size = DEFAULT_L1_MAX_CACHE_LINE_SIZE;
#endif
l1_max_cache_line_size = l1_dcache_line_size > l1_icache_line_size ? l1_dcache_line_size : l1_icache_line_size;
}

View File

@ -87,8 +87,16 @@
# define S_ENABLE_CODE_WRITE(on) pthread_jit_write_protect_np(!(on))
#endif
#if (machine_type == machine_type_ppc32osx || machine_type == machine_type_tppc32osx)
# define OS_ANY_MACOSX
# if (machine_type == machine_type_tppc32osx)
# define PTHREADS
# endif
# define FLUSHCACHE
#endif
#if (machine_type == machine_type_pb)
# if defined(__powerpc__) && !defined(__powerpc64__)
# if (defined(__powerpc__) || defined(__POWERPC__)) && !defined(__powerpc64__)
# define PORTABLE_BYTECODE_BIGENDIAN
# endif
# if defined(__linux__)
@ -314,7 +322,9 @@ typedef int tputsputcchar;
#define USE_MMAP
#define MMAP_HEAP
#define IEEE_DOUBLE
#define LITTLE_ENDIAN_IEEE_DOUBLE
#if !defined(__POWERPC__)
# define LITTLE_ENDIAN_IEEE_DOUBLE
#endif
#define LDEXP
#define ARCHYPERBOLIC
#define GETPAGESIZE() getpagesize()

View File

@ -59,6 +59,7 @@ disablex11=no
disablecurses=no
addflags=yes
addwarningflags=no
default_warning_flags="-Wpointer-arith -Wall -Wextra -Werror -Wno-implicit-fallthrough"
: ${CC:="gcc"}
: ${CPPFLAGS:=""}
: ${CFLAGS:=""}
@ -159,6 +160,10 @@ case "${CONFIG_UNAME}" in
elif uname -a | egrep 'arm|aarch' > /dev/null 2>&1 ; then
m64=arm64osx
tm64=tarm6osx
elif uname -a | egrep 'Power' > /dev/null 2>&1 ; then
m64=ppc32osx
tm64=tppc32osx
default_warning_flags=""
fi
installprefix=/usr/local
installmansuffix=share/man
@ -475,7 +480,7 @@ fi
optFlags=-O2
if [ "$cflagsset" = "no" -o "$addwarningflags" = "yes" ] ; then
warningFlags="-Wpointer-arith -Wall -Wextra -Werror -Wno-implicit-fallthrough"
warningFlags="$default_warning_flags"
else
warningFlags=""
fi
@ -545,6 +550,9 @@ if [ "$cflagsset" = "no" ] ; then
ppc32le|tppc32le)
CFLAGS="-m32 ${optFlags}"
;;
ppc32osx|tppc32osx)
CFLAGS="${optFlags}"
;;
esac
fi

View File

@ -0,0 +1,14 @@
# Mf-ppc32osx
m ?= ppc32osx
fsrc = foreign1.c foreign2.c foreign3.c foreign4.c
fobj = foreign1.so
include Mf-base
foreign1.so: ${fsrc} ../boot/$m/scheme.h
cc --dynamiclib -undefined dynamic_lookup -I${Include} -o foreign1.so ${fsrc}
cat_flush: cat_flush.c
cc -o cat_flush cat_flush.c

View File

@ -0,0 +1,5 @@
# Mf-tppc32osx
m ?= tppc32osx
include Mf-ppc32osx

View File

@ -0,0 +1,6 @@
# Mf-ppc32osx
m ?= ppc32osx
archincludes = ppc32.ss
include Mf-base

View File

@ -14,6 +14,5 @@
# limitations under the License.
m = ti3osx
archincludes = x86.ss
include Mf-base
include Mf-i3osx

View File

@ -0,0 +1,5 @@
# Mf-tppc32osx
m = tppc32osx
include Mf-ppc32osx

View File

@ -395,6 +395,7 @@
ppc32le tppc32le
arm64le tarm64le
arm64osx tarm64osx
ppc32osx tppc32osx
)
(include "machine.def")

View File

@ -652,9 +652,12 @@
(pr " : \"r\" (addr) \\~%")
(pr " : \"flags\", \"memory\")~%")))]
[(ppc32)
(let ([reg (constant-case machine-type-name
[(ppc32osx tppc32osx) ""]
[else "%%"])])
(pr "#define INITLOCK(addr) \\~%")
(pr " __asm__ __volatile__ (\"li %%r0, 0\\n\\t\"\\~%")
(pr " \"stw %%r0, 0(%0)\\n\\t\"\\~%")
(pr " __asm__ __volatile__ (\"li ~ar0, 0\\n\\t\"\\~%" reg)
(pr " \"stw ~ar0, 0(%0)\\n\\t\"\\~%" reg)
(pr " : \\~%")
(pr " : \"b\" (addr)\\~%")
(pr " :\"memory\", \"r0\")~%")
@ -662,16 +665,16 @@
(nl)
(pr "#define SPINLOCK(addr) \\~%")
(pr " __asm__ __volatile__ (\"0:\\n\\t\"\\~%") ; top:
(pr " \"lwarx %%r0, 0, %0\\n\\t\"\\~%") ; start lock acquisition
(pr " \"cmpwi %%r0, 0\\n\\t\"\\~%") ; see if someone already owns the lock
(pr " \"lwarx ~ar0, 0, %0\\n\\t\"\\~%" reg) ; start lock acquisition
(pr " \"cmpwi ~ar0, 0\\n\\t\"\\~%" reg) ; see if someone already owns the lock
(pr " \"bne 1f\\n\\t\"\\~%") ; if so, go to our try_again loop
(pr " \"li %%r0, 1\\n\\t\"\\~%") ; attempt to store the value 1
(pr " \"stwcx. %%r0, 0, %0\\n\\t\"\\~%") ;
(pr " \"li ~ar0, 1\\n\\t\"\\~%" reg) ; attempt to store the value 1
(pr " \"stwcx. ~ar0, 0, %0\\n\\t\"\\~%" reg);
(pr " \"beq 2f\\n\\t\"\\~%") ; if we succeed, we own the lock
(pr " \"1:\\n\\t\"\\~%") ; again:
(pr " \"isync\\n\\t\"\\~%") ; sync things to pause the processor
(pr " \"lwz %%r0, 0(%0)\\n\\t\"\\~%") ; try a non-reserved load to see if we are likely to succeed
(pr " \"cmpwi %%r0, 0\\n\\t\"\\~%") ; if it is = 0, try to acquire at start
(pr " \"lwz ~ar0, 0(%0)\\n\\t\"\\~%" reg) ; try a non-reserved load to see if we are likely to succeed
(pr " \"cmpwi ~ar0, 0\\n\\t\"\\~%" reg) ; if it is = 0, try to acquire at start
(pr " \"beq 0b\\n\\t\"\\~%") ;
(pr " \"b 1b\\n\\t\"\\~%") ; othwerise loop through the try again
(pr " \"2:\\n\\t\"\\~%") ; done:
@ -681,8 +684,8 @@
(nl)
(pr "#define UNLOCK(addr) \\~%")
(pr " __asm__ __volatile__ (\"li %%r0, 0\\n\\t\"\\~%")
(pr " \"stw %%r0, 0(%0)\\n\\t\"\\~%")
(pr " __asm__ __volatile__ (\"li ~ar0, 0\\n\\t\"\\~%" reg)
(pr " \"stw ~ar0, 0(%0)\\n\\t\"\\~%" reg)
(pr " : \\~%")
(pr " : \"b\" (addr)\\~%")
(pr " :\"memory\", \"r0\")~%")
@ -691,11 +694,11 @@
(pr "#define LOCKED_INCR(addr, ret) \\~%")
(pr " __asm__ __volatile__ (\"li %0, 0\\n\\t\"\\~%")
(pr " \"0:\\n\\t\"\\~%")
(pr " \"lwarx %%r12, 0, %1\\n\\t\"\\~%")
(pr " \"addi %%r12, %%r12, 1\\n\\t\"\\~%")
(pr " \"stwcx. %%r12, 0, %1\\n\\t\"\\~%")
(pr " \"lwarx ~ar12, 0, %1\\n\\t\"\\~%" reg)
(pr " \"addi ~ar12, ~ar12, 1\\n\\t\"\\~%" reg reg)
(pr " \"stwcx. ~ar12, 0, %1\\n\\t\"\\~%" reg)
(pr " \"bne 0b\\n\\t\"\\~%")
(pr " \"cmpwi %%r12, 0\\n\\t\"\\~%")
(pr " \"cmpwi ~ar12, 0\\n\\t\"\\~%" reg)
(pr " \"bne 1f\\n\\t\"\\~%")
(pr " \"li %0, 1\\n\\t\"\\~%")
(pr " \"1:\\n\\t\"\\~%")
@ -707,17 +710,17 @@
(pr "#define LOCKED_DECR(addr, ret) \\~%")
(pr " __asm__ __volatile__ (\"li %0, 0\\n\\t\"\\~%")
(pr " \"0:\\n\\t\"\\~%")
(pr " \"lwarx %%r12, 0, %1\\n\\t\"\\~%")
(pr " \"addi %%r12, %%r12, -1\\n\\t\"\\~%")
(pr " \"stwcx. %%r12, 0, %1\\n\\t\"\\~%")
(pr " \"lwarx ~ar12, 0, %1\\n\\t\"\\~%" reg)
(pr " \"addi ~ar12, ~ar12, -1\\n\\t\"\\~%" reg reg)
(pr " \"stwcx. ~ar12, 0, %1\\n\\t\"\\~%" reg)
(pr " \"bne 0b\\n\\t\"\\~%")
(pr " \"cmpwi %%r12, 0\\n\\t\"\\~%")
(pr " \"cmpwi ~ar12, 0\\n\\t\"\\~%" reg)
(pr " \"bne 1f\\n\\t\"\\~%")
(pr " \"li %0, 1\\n\\t\"\\~%")
(pr " \"1:\\n\\t\"\\~%")
(pr " : \"=&r\" (ret)\\~%")
(pr " : \"r\" (addr)\\~%")
(pr " : \"cc\", \"memory\", \"r12\")~%")]
(pr " : \"cc\", \"memory\", \"r12\")~%"))]
[(arm32)
(pr "#define INITLOCK(addr) \\~%")
(pr " __asm__ __volatile__ (\"mov r12, #0\\n\\t\"\\~%")

View File

@ -0,0 +1,6 @@
;;; ppc32osx.def
(define-constant machine-type (constant machine-type-ppc32osx))
(features iconv expeditor)
(include "ppc32.def")
(include "default.def")

View File

@ -0,0 +1,6 @@
;;; tppc32le.def
(define-constant machine-type (constant machine-type-tppc32osx))
(features iconv expeditor pthreads)
(include "ppc32.def")
(include "default.def")

View File

@ -65,6 +65,7 @@ case "$Mhost" in
i3qnx) ;;
i3s2) ;;
ppc32le) ;;
ppc32osx) ;;
ta6fb) Muni=a6fb ;;
ta6le) Muni=a6le ;;
ta6nb) Muni=a6nb ;;
@ -84,6 +85,7 @@ case "$Mhost" in
ti3qnx) Muni=i3qnx ;;
ti3s2) Muni=i3s2 ;;
tppc32le) Muni=ppc32le ;;
tppc32osx) Muni=ppc32osx ;;
*) echo "Unrecognized machine name $Mhost"; exit 1 ;;
esac
@ -113,7 +115,7 @@ case "$Muniarch" in
i3qnx) March=i3 ;;
i3s2) March=i3 ;;
ppc32le) March=ppc32 ;;
pb) March=pb ;;
ppc32osx) March=ppc32 ;;
*) March="" ;;
esac

View File

@ -19,7 +19,7 @@
(define os-symbol
(case (machine-type)
[(a6osx ta6osx i3osx ti3osx arm64osx tarm64osx)
[(a6osx ta6osx i3osx ti3osx arm64osx tarm64osx ppc32osx tppc32osx)
(if unix-style-macos? 'unix 'macosx)]
[(a6nt ta6nt i3nt ti3nt) 'windows]
[else 'unix]))
@ -28,7 +28,8 @@
(case (machine-type)
[(a6osx ta6osx
i3osx ti3osx
arm64osx tarm64osx)
arm64osx tarm64osx
ppc32osx tppc32osx)
(if unix-style-macos?
'darwin
'macosx)]
@ -63,7 +64,9 @@
'i386]
[(arm32le tarm32le) 'arm]
[(arm64le tarm64le arm64osx tarm64osx) 'aarch64]
[(ppc32le tppc32le) 'ppc]
[(ppc32le tppc32le
ppc32osx tppc32osx)
'ppc]
[else (error 'system-type "internal error: unknown architecture")]))
(define link-symbol