1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-03-15 22:37:22 +00:00

Compare commits

..

7 Commits

Author SHA1 Message Date
Nick Briggs
4245764b31 Turn on DTD checking and differentiate error messages. 2023-07-23 18:55:31 -07:00
Nick Briggs
4520609479 Print the bad Lisp pointer as well as where it came from. 2023-07-23 14:51:36 -07:00
Nick Briggs
3b42f0579d The lisp pointers are 28 bits not 24 2023-07-23 12:23:17 -07:00
Nick Briggs
29b492093d Add ARRAYCHECK to makefile slices for macOS 2023-07-22 15:40:11 -07:00
Nick Briggs
1c6d366e3c Catch more pointer problems in NativeAligned4FromLAddr 2023-07-22 15:37:14 -07:00
Nick Briggs
c74e7a0169 Avoid accessing free block chain pointers when block is not free 2023-07-22 15:36:11 -07:00
Nick Briggs
060420ce42 struct buf is missing definition for byte-swapped bigvm case
While there was a definition for the pre-bigvm case, with 24-bit
pointers, for byteswapped (little-endian) systems, there was no
structure definition for the bigvm case, with 28-bit pointers.
2023-07-22 15:34:33 -07:00
33 changed files with 84 additions and 356 deletions

View File

@@ -107,7 +107,7 @@ jobs:
echo "linux=true" >> $GITHUB_OUTPUT;
echo "macos=true" >> $GITHUB_OUTPUT;
echo "windows=true" >> $GITHUB_OUTPUT;
######################################################################################
@@ -123,7 +123,7 @@ jobs:
steps:
# Checkout the actions for this repo owner
- name: Checkout Actions
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
repository: ${{ github.repository_owner }}/.github
path: ./Actions_${{ github.sha }}
@@ -157,7 +157,7 @@ jobs:
steps:
# Checkout the actions for this repo owner
- name: Checkout Actions
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
repository: ${{ github.repository_owner }}/.github
path: ./Actions_${{ github.sha }}
@@ -165,7 +165,7 @@ jobs:
# Checkout the branch
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
# Setup release tag
- name: Setup Release Tag
@@ -272,11 +272,11 @@ jobs:
# Checkout the branch
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
# Checkout the actions for this repo owner
- name: Checkout Actions
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
repository: ${{ github.repository_owner }}/.github
path: ./Actions_${{ github.sha }}
@@ -324,7 +324,7 @@ jobs:
export LDEARCH=aarch64-apple-darwin
./makeright init
mkdir -p ../darwin.universal
exe=ldeinit
exe=ldeinit
lipo -create \
-arch arm64 ../darwin.aarch64/${exe} \
-arch x86_64 ../darwin.x86_64/${exe} \
@@ -346,7 +346,7 @@ jobs:
lipo ${exe} -output ../darwin.x86_64/${exe} -extract x86_64
lipo ${exe} -output ../darwin.aarch64/${exe} -extract arm64
cp -p ${exe} ../darwin.universal/${exe}
done
done
# Create release tar for github.
- name: Make release tar(s)
@@ -369,7 +369,7 @@ jobs:
# Push Release
- name: Push the release
uses: ncipollo/release-action@v1
with:
with:
allowUpdates: true
artifacts:
/tmp/release_tars/${{ steps.tag.outputs.release_tag }}-darwin.x86_64.tgz,
@@ -383,7 +383,7 @@ jobs:
# Windows: build for Windows-Cygwin via Docker build and use results to
# create and push release assets to github
windows:
needs: [inputs, sentry]
@@ -418,7 +418,7 @@ jobs:
# Retrieve SDL2 and install in cygwin
- name: Install SDL2
id: sdl2
env:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release download 2.26.5 --repo interlisp/cygwin-sdl --pattern *.tgz --output .\cygwin\sdl2.tar.gz
@@ -426,13 +426,13 @@ jobs:
# Checkout the branch
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
path: cygwin\maiko
# Checkout the actions for this repo owner
- name: Checkout Actions
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
repository: ${{ github.repository_owner }}/.github
path: ./Actions_${{ github.sha }}
@@ -473,80 +473,6 @@ jobs:
######################################################################################
# Emscripten: build and push Maiko compiled for Emscripten (to run Maiko in browser)
emscripten:
needs: [inputs, sentry]
if: |
needs.inputs.outputs.linux == 'true'
&& (
needs.sentry.outputs.release_not_built == 'true'
|| needs.inputs.outputs.force == 'true'
)
runs-on: ubuntu-latest
steps:
# Checkout the actions for this repo owner
- name: Checkout Actions
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/.github
path: ./Actions_${{ github.sha }}
- run: mv ./Actions_${{ github.sha }}/actions ../actions && rm -rf ./Actions_${{ github.sha }}
# Install SDL2
- name: Install SDL2
run: |
export DEBIAN_FRONTEND=noninteractive
sudo -E apt-get install -y libsdl2-dev libsdl2-2.0-0
# Install Emscripten SDK
- name: Install Empscripten
working-directory: ../
run: |
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
CWD="$(pwd)"
echo "${CWD}" >> ${GITHUB_PATH}
echo "${CWD}/upstream/emscripten" >> ${GITHUB_PATH}
echo "${CWD}/upstream/emscripten/tools" >> ${GITHUB_PATH}
echo "${CWD}/node/$(ls -d node/*64bit | tail -1)/bin" >> ${GITHUB_PATH}
# Checkout the maiko branch
- name: Checkout
uses: actions/checkout@v4
# Setup release tag
- name: Setup Release Tag
id: tag
uses: ./../actions/release-tag-action
# Compile maiko using Emscripten (no load build)
- name: Compile Maiko using Emscripten
working-directory: ./bin
run: |
./makeright wasm
cd ../emscripten.wasm
tar -c -z -f ../${{ steps.tag.outputs.release_tag }}-emscripten.tgz *
# Push Release to github
- name: Push the release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: ${{ steps.tag.outputs.release_tag }}-emscripten.tgz
tag: ${{ steps.tag.outputs.release_tag }}
draft: ${{ needs.inputs.outputs.draft }}
token: ${{ secrets.GITHUB_TOKEN }}
######################################################################################
# Use set-sentry-action to determine set the sentry that says this release has
@@ -559,12 +485,12 @@ jobs:
outputs:
build_successful: ${{ steps.output.outputs.build_successful }}
needs: [inputs, sentry, linux, macos, windows, emscripten]
needs: [inputs, sentry, linux, macos, windows]
steps:
# Checkout the actions for this repo owner
- name: Checkout Actions
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
repository: ${{ github.repository_owner }}/.github
path: ./Actions_${{ github.sha }}

4
.gitignore vendored
View File

@@ -19,10 +19,6 @@ cmake-build-*/**
*.x86_64-x/**
*.x86_64-sdl/**
*.x86_64/**
*.wasm/**
*.wasm-wasm/**
*.wasm_nl/**
*.wasm_nl-wasm_nl/**
*.armv7l-x/**
*.armv7l/**
*.aarch64-x/**

View File

@@ -18,7 +18,7 @@ ENDIF()
find_program(
CLANG_TIDY_EXE
NAMES "clang-tidy" "clang-tidy16" "clang-tidy15" "clang-tidy14" "clang-tidy13" "clang-tidy12" "clang-tidy11" "clang-tidy10"
NAMES "clang-tidy" "clang-tidy13" "clang-tidy12" "clang-tidy11" "clang-tidy10"
DOC "Path to clang-tidy executable"
)
@@ -41,10 +41,6 @@ SET(MAIKO_DEFINITIONS
"-DRELEASE=351"
)
SET(MAIKO_INIT_DEFINITIONS
"-DRELEASE=351" "-DINIT" "-DNOVERSION"
)
OPTION(MAIKO_DISPLAY_X11 "Use X11 for display." ON)
OPTION(MAIKO_DISPLAY_SDL "Use SDL for display." OFF)
@@ -458,18 +454,6 @@ IF(MAIKO_DISPLAY_X11)
TARGET_COMPILE_DEFINITIONS(ldex PUBLIC ${MAIKO_DEFINITIONS} ${MAIKO_DISPLAY_X11_DEFINITIONS})
TARGET_INCLUDE_DIRECTORIES(ldex PUBLIC inc)
TARGET_LINK_LIBRARIES(ldex ${MAIKO_LIBRARIES} ${MAIKO_DISPLAY_X11_LIBRARIES})
ADD_EXECUTABLE(ldeinit
src/main.c
vdate.c
${MAIKO_SRCS}
${MAIKO_HDRS}
${MAIKO_DISPLAY_X11_SRCS}
${MAIKO_DISPLAY_X11_HDRS}
)
TARGET_COMPILE_DEFINITIONS(ldeinit PUBLIC ${MAIKO_INIT_DEFINITIONS} ${MAIKO_DISPLAY_X11_DEFINITIONS})
TARGET_INCLUDE_DIRECTORIES(ldeinit PUBLIC inc)
TARGET_LINK_LIBRARIES(ldeinit ${MAIKO_LIBRARIES} ${MAIKO_DISPLAY_X11_LIBRARIES})
ENDIF()
IF(MAIKO_DISPLAY_SDL)

View File

@@ -4,7 +4,7 @@ Maiko is the implementation of the Medley Interlisp virtual machine, for a
byte-coded Lisp instruction set and some low-level functions for
connecting with Lisp for access to display (via X11) and disk etc.
For an overview, see [Medley Interlisp Introduction](https://interlisp.org/medley/using/docs/medley/).
For an overview, see [Medley Interlisp Introduction](https://github.com/Interlisp/medley/wiki/Medley-Interlisp-Introduction).
See [the Medley repository](https://github.com/Interlisp/medley) for
* [Issues](https://github.com/Interlisp/medley/issues) (note that maiko issues are there too)

View File

@@ -9,8 +9,7 @@
# #
#########################################################################
SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
os=${LDEARCH:-`$SCRIPTPATH/config.guess`}
os=${LDEARCH:-`./config.guess`}
# o/s switch block
case "$os" in
m68k-*) echo m68k ;;

View File

@@ -16,8 +16,8 @@ XFILES = $(OBJECTDIR)xmkicon.o \
XFLAGS = -I/opt/X11/include -DXWINDOW
# OPTFLAGS is normally -O2.
OPTFLAGS = -O2
DEBUGFLAGS = # -DDEBUG -DOPTRACE
OPTFLAGS = -g -O2
DEBUGFLAGS = -DARRAYCHECK -DDTDDEBUG # -DDEBUG -DOPTRACE
DFLAGS = $(DEBUGFLAGS) $(XFLAGS) -DRELEASE=351
LDFLAGS = -L/opt/X11/lib -lX11 -lm

View File

@@ -17,7 +17,7 @@ XFLAGS = -I/opt/X11/include -DXWINDOW
# OPTFLAGS is normally -O2.
OPTFLAGS = -O1 -g
DEBUGFLAGS = # -DDEBUG -DOPTRACE
DEBUGFLAGS = -DARRAYCHECK -DDTDDEBUG # -DDEBUG -DOPTRACE
DFLAGS = $(DEBUGFLAGS) $(XFLAGS) -DRELEASE=351
LDFLAGS = -L/opt/X11/lib -lX11 -lm

View File

@@ -1,22 +0,0 @@
# Options for Emscripten, WASM and SDL
CC = emcc $(CLANG_CFLAGS)
XFILES = $(OBJECTDIR)sdl.o
XFLAGS = -DSDL -sUSE_SDL=2
# OPTFLAGS is normally -O2.
OPTFLAGS = -O2
DFLAGS = $(XFLAGS) -DRELEASE=351 -DMAIKO_OS_EMSCRIPTEN -DMAIKO_ENABLE_NETHUB
# LD not really used - but keeping it here just in case
LD = emcc
LDFLAGS = -sUSE_SDL=2 -sASYNCIFY -sALLOW_MEMORY_GROWTH -sEXIT_RUNTIME=1 -sFORCE_FILESYSTEM -sLZ4
UPFRONT_LDFLAGS = -lidbfs.js
LDELDFLAGS =
OBJECTDIR = ../$(RELEASENAME)/
default : ../$(OSARCHNAME)/ldesdl.js

View File

@@ -1,29 +0,0 @@
# Options for Linux, aarch64 processor, X windows, for INIT processing
CC = gcc $(GCC_CFLAGS)
#CC = clang $(CLANG_CFLAGS)
XFILES = $(OBJECTDIR)xmkicon.o \
$(OBJECTDIR)xbbt.o \
$(OBJECTDIR)dspif.o \
$(OBJECTDIR)xinit.o \
$(OBJECTDIR)xscroll.o \
$(OBJECTDIR)xcursor.o \
$(OBJECTDIR)xlspwin.o \
$(OBJECTDIR)xrdopt.o \
$(OBJECTDIR)xwinman.o
XFLAGS = -DXWINDOW
# OPTFLAGS is normally -O2, for INIT we want unoptimized in case we need to debug it
OPTFLAGS = -O0 -g
DEBUGFLAGS =
DFLAGS = $(DEBUGFLAGS) $(XFLAGS) -DRELEASE=351 -DNOVERSION -DINIT
LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm
LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm
OBJECTDIR = ../$(RELEASENAME)/
default : ../$(OSARCHNAME)/ldeinit

View File

@@ -1,7 +1,7 @@
# Options for Linux, x86 processor, X windows, for INIT processing
CC = gcc $(GCC_CFLAGS)
#CC = clang $(CLANG_CFLAGS)
#CC = gcc -m64 $(GCC_CFLAGS)
CC = clang -m64 $(CLANG_CFLAGS)
XFILES = $(OBJECTDIR)xmkicon.o \
$(OBJECTDIR)xbbt.o \

View File

@@ -1,27 +0,0 @@
# Options for OpenBSD, Intel x86_64 and X-Window
CC = clang -m64 $(CLANG_CFLAGS)
XFILES = $(OBJECTDIR)xmkicon.o \
$(OBJECTDIR)xbbt.o \
$(OBJECTDIR)dspif.o \
$(OBJECTDIR)xinit.o \
$(OBJECTDIR)xscroll.o \
$(OBJECTDIR)xcursor.o \
$(OBJECTDIR)xlspwin.o \
$(OBJECTDIR)xrdopt.o \
$(OBJECTDIR)xwinman.o
XFLAGS = -I/usr/X11R6/include -DXWINDOW
# OPTFLAGS is normally -O2.
OPTFLAGS = -O2 -g3
DFLAGS = $(XFLAGS) -DRELEASE=351 -DNOVERSION -DINIT
LDFLAGS = -L/usr/X11R6/lib -lX11 -lc -lm
LDELDFLAGS = -L/usr/X11R6/lib -lX11 -lc -lm
OBJECTDIR = ../$(RELEASENAME)/
default : ../$(OSARCHNAME)/ldeinit

View File

@@ -1,4 +1,4 @@
# Options for Linux, aarch64 and X-Window
# Options for Linux, ARMv7 and X-Window
CC = gcc $(GCC_CFLAGS)
#CC = clang $(CLANG_CFLAGS)

View File

@@ -148,7 +148,7 @@ $(OSARCHDIR)lde: $(OBJECTDIR)ldeboot.o $(OBJECTDIR)unixfork.o
$(CC) $(OBJECTDIR)ldeboot.o $(OBJECTDIR)unixfork.o $(LDELDFLAGS) -o $(OSARCHDIR)lde
$(OSARCHDIR)$(LDENAME): $(LIBFILES) $(EXTFILES) $(OBJECTDIR)vdate.o
$(CC) $(UPFRONT_LDFLAGS) $(LIBFILES) $(EXTFILES) $(OBJECTDIR)vdate.o $(LDFLAGS) -o $(OSARCHDIR)$(LDENAME)
$(CC) $(LIBFILES) $(EXTFILES) $(OBJECTDIR)vdate.o $(LDFLAGS) -o $(OSARCHDIR)$(LDENAME)
@ echo ""
@ echo "Executable is now named '$(OSARCHDIR)$(LDENAME)'"

View File

@@ -20,7 +20,7 @@
# Nov 20 2001 JDS: Convert to use BASH, not CSH, for open-source...
#
# usage: makeright [display-option] [other-option]
#
#
# example: makeright single ; make lde for mmaped displayFB
# makeright multi ; make lde for cg3,cg6
# makeright x ; make lde for X-windows
@@ -74,11 +74,6 @@ case "$display" in
sdl) releasename=${osversion}.${architecture}-${display}
ldename=ldesdl
;;
wasm) osversion=emscripten
architecture=wasm
releasename=${osversion}.${architecture}-${display}
ldename=ldesdl.js
;;
*) echo "display-option: $display is not supported."
exit
;;

View File

@@ -1,6 +1,5 @@
#!/bin/sh
SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
os=${LDEARCH:-`$SCRIPTPATH/config.guess`}
os=${LDEARCH:-`./config.guess`}
case "$os" in
m68k-*-amigaos) echo amigaos ;;
sparc-sun-sunos*) echo sunos4 ;;

View File

@@ -28,11 +28,19 @@
*/
/**********************************************************************/
#include <execinfo.h>
#include <stddef.h>
#include <stdio.h>
#include "lispemul.h"
#include "lspglob.h"
static inline void dobacktrace()
{
void* callstack[128];
int i, frames = backtrace(callstack, 128);
backtrace_symbols_fd(callstack, frames, 2);
}
static inline LispPTR LAddrFromNative(void *NAddr)
{
if ((uintptr_t)NAddr & 1) {
@@ -48,8 +56,9 @@ static inline DLword *NativeAligned2FromLAddr(LispPTR LAddr)
static inline LispPTR *NativeAligned4FromLAddr(LispPTR LAddr)
{
if (LAddr & 1) {
printf("Misaligned pointer in NativeAligned4FromLAddr 0x%x\n", LAddr);
if (LAddr & 1 || LAddr > 0x0FFFFFFF) {
printf("Misaligned/bad pointer in NativeAligned4FromLAddr 0x%x\n", LAddr);
dobacktrace();
}
return (void *)(Lisp_world + LAddr);
}

View File

@@ -40,7 +40,7 @@ extern int flushing;
#endif
#ifdef DEBUG
#define DBPRINT(X) do { printf("%s:%d ", __FILE__, __LINE__); printf X ; if (flushing) fflush(stdout); } while(0)
#define DBPRINT(X) do {printf X ; if (flushing) fflush(stdout); } while(0)
#define DEBUGGER(X) X
#else
#define DBPRINT(X) if (0) do {printf X ; } while(0)
@@ -51,7 +51,7 @@ extern int flushing;
/* For trace print statements */
#ifdef TRACE
#define TPRINT(X) do { printf("%s:%d ", __FILE__, __LINE__); printf X; if (flushing) fflush(stdout); } while (0)
#define TPRINT(X) do { printf X; if (flushing) fflush(stdout); } while (0)
#define TRACER(X) X
#else /* TRACE */
@@ -64,7 +64,7 @@ extern int flushing;
/* For tracing individual opcode executions */
#ifdef OPTRACE
#define OPTPRINT(X) do { printf("%s:%d ", __FILE__, __LINE__); printf X; if (flushing) fflush(stdout); } while (0)
#define OPTPRINT(X) do { printf X; if (flushing) fflush(stdout); } while (0)
#define OPTRACER(X) X
#else
#define OPTPRINT(X) if (0) do { printf X; } while (0)
@@ -75,7 +75,7 @@ extern int flushing;
/* For tracing function calls */
#ifdef FNTRACE
#define FNTPRINT(X) do { printf("%s:%d ", __FILE__, __LINE__); printf X; if (flushing) fflush(stdout); } while (0)
#define FNTPRINT(X) do { printf X; if (flushing) fflush(stdout); } while (0)
#define FNTRACER(X) X
#else
#define FNTPRINT(X) if (0) do { printf X; } while (0)
@@ -86,7 +86,7 @@ extern int flushing;
/* For function-call & return stack checking */
#ifdef FNSTKCHECK
#define FNCHKPRINT(X) do { printf("%s:%d ", __FILE__, __LINE__); printf X ; if (flushing) fflush(stdout); } while (0)
#define FNCHKPRINT(X) do { printf X ; if (flushing) fflush(stdout); } while (0)
#define FNCHECKER(X) X
#else
#define FNCHKPRINT(X) if (0) do { printf X; } while (0)

View File

@@ -194,9 +194,8 @@ do { \
#endif /* min */
#define LispNumToCInt(Lisp) \
( (((Lisp) & SEGMASK) == S_POSITIVE) ? ((Lisp) & 0xFFFF) : \
(((Lisp) & SEGMASK) == S_NEGATIVE) ? ((Lisp) | 0xFFFF0000) : \
(*((int *)(NativeAligned4FromLAddr(Lisp)))) )
( (((Lisp) & SEGMASK) == S_POSITIVE) ? \
((Lisp) & 0xFFFF) : (*((int *)(NativeAligned4FromLAddr(Lisp)))) )
#define UPLOWDIFF 0x20

View File

@@ -83,19 +83,6 @@
# define MAIKO_OS_DETECTED 1
#endif
#ifdef __EMSCRIPTEN__
# define MAIKO_OS_LINUX 1
# define MAIKO_OS_EMSCRIPTEN 1
# define MAIKO_OS_NAME "Emscripten"
# define MAIKO_EMULATE_TIMER_INTERRUPTS 1
# define MAIKO_EMULATE_ASYNC_INTERRUPTS 1
# define MAIKO_OS_UNIX_LIKE 1
# define MAIKO_OS_DETECTED
# define MAIKO_ARCH_NAME "WebAssembly"
# define MAIKO_ARCH_WORD_BITS 32
# define MAIKO_ARCH_DETECTED 1
#endif
/* __x86_64__: GNU C, __x86_64: Sun Studio, _M_AMD64: Visual Studio */
#if defined(__x86_64__) || defined(__x86_64) || defined(_M_AMD64)
# define MAIKO_ARCH_X86_64 1

View File

@@ -1799,7 +1799,7 @@ void tedit_bltchar(LispPTR *args)
} /* end tedit_bltchar */
#if defined(REALCURSOR)
#if defined(REALCURSOR) || defined(SUNDISPLAY)
#ifndef COLOR
/* Lisp addr hi-word, lo-word, ... */
static int old_cursorin(DLword addrhi, DLword addrlo, int x, int w, int h, int y, int backward)
@@ -1866,4 +1866,4 @@ static int old_cursorin(DLword addrhi, DLword addrlo, int x, int w, int h, int y
} /* COLOR case end */
}
#endif /* COLOR */
#endif /* defined(REALCURSOR) */
#endif /* defined(REALCURSOR) || defined(SUNDISPLAY) */

View File

@@ -2150,8 +2150,7 @@ LispPTR COM_next_file(LispPTR *args)
propp = gfsp->propp;
dfp = &FinfoArray[finfoid];
fp = dfp->next;
if (dfp->head == NULL || fp == NULL) return (SMALLP_MINUSONE);
if (dfp->head == (FINFO *)0 || (fp = dfp->next) == (FINFO *)0) return (SMALLP_MINUSONE);
dfp->next = fp->next;
laddr = gfsp->name;

View File

@@ -156,8 +156,10 @@ LispPTR findptrsbuffer(LispPTR ptr) {
while (LAddrFromNative(bptr) != NIL) {
if (ptr == bptr->vmempage)
return (LAddrFromNative(bptr));
else
else {
if (bptr->sysnext & 0xF0000000) printf("findptrsbuffer: would have failed %p 0x%X\n", bptr, bptr->sysnext);
bptr = (struct buf *)NativeAligned4FromLAddr(bptr->sysnext);
}
}
return (NIL);
}
@@ -224,8 +226,9 @@ LispPTR checkarrayblock(LispPTR base, LispPTR free, LispPTR onfreelist) {
printarrayblock(base);
error("ARRAYBLOCK Trailer INUSE bit set wrong\n");
} else if (!onfreelist || (bbase->arlen < MINARRAYBLOCKSIZE))
/* Remaining tests only for free list. */
return (NIL);
/* Remaining tests only for free list. */
bfwd = (struct arrayblock *)NativeAligned4FromLAddr(bbase->fwd);
bbwd = (struct arrayblock *)NativeAligned4FromLAddr(bbase->bkwd);
if ((bbwd->fwd != base) || (bfwd->bkwd != base)) {
@@ -350,6 +353,7 @@ LispPTR makefreearrayblock(LispPTR block, DLword length) {
/* */
/* */
/************************************************************************/
LispPTR arrayblockmerger(LispPTR base, LispPTR nbase) {
DLword arlens, narlens, secondbite, minblocksize, shaveback;
struct arrayblock *bbase, *bnbase;
@@ -358,23 +362,12 @@ LispPTR arrayblockmerger(LispPTR base, LispPTR nbase) {
arlens = bbase->arlen;
narlens = bnbase->arlen;
secondbite = MAXARRAYBLOCKSIZE - arlens;
/* There are three cases for merging the blocks
* (1) the total size of the two blocks is less than max:
* merge into a single block
* (2) creating a max size block leaves a viable leftover block:
* move the boundary to make a max block and a leftover block
* (3) creating a max size block leaves a non-viable leftover block
* move the boundary to make a big block and a minimum size leftover block
*/
if (base + (2 * arlens) != nbase) {
error("Attempt to merge non-adjacent blocks in array space\n");
}
if (narlens > secondbite) { /* (2) or (3) */
if (narlens > secondbite) {
arlens = MAXARRAYBLOCKSIZE;
narlens = narlens - secondbite;
minblocksize =
((*Hunk_word == ATOM_T) ? (ARRAYBLOCKOVERHEADCELLS + MAXCELLSPERHUNK) : MINARRAYBLOCKSIZE);
if (narlens < minblocksize) { /* (3) */
if (narlens < minblocksize) {
shaveback = narlens - minblocksize;
narlens = minblocksize;
arlens += shaveback;
@@ -398,10 +391,10 @@ LispPTR mergebackward(LispPTR base) {
LispPTR pbase;
struct arrayblock *ptrailer;
ptrailer = (struct arrayblock *)NativeAligned4FromLAddr(base - ARRAYBLOCKTRAILERWORDS);
if (base == NIL)
return (NIL);
ptrailer = (struct arrayblock *)NativeAligned4FromLAddr(base - ARRAYBLOCKTRAILERWORDS);
if ((*ArrayMerging_word == NIL) ||
else if ((*ArrayMerging_word == NIL) ||
((base == *ArraySpace_word) || ((base == *ArraySpace2_word) || (ptrailer->inuse == T))))
return (linkblock(base));
pbase = base - 2 * ptrailer->arlen;
@@ -421,18 +414,16 @@ LispPTR mergebackward(LispPTR base) {
LispPTR mergeforward(LispPTR base) {
LispPTR nbase, nbinuse;
struct arrayblock *bbase, *bnbase;
if (*ArrayMerging_word == NIL) return NIL;
if (base == NIL) return NIL;
if (checkarrayblock(base, T, T)) return NIL;
bbase = (struct arrayblock *)NativeAligned4FromLAddr(base);
nbase = base + 2 * (bbase->arlen);
if (nbase == *ArrayFrLst_word || nbase == *ArrayFrLst2_word) return NIL;
bnbase = (struct arrayblock *)NativeAligned4FromLAddr(nbase);
nbinuse = bnbase->inuse;
if (checkarrayblock(nbase, !nbinuse, NIL)) return NIL;
if (nbinuse) return (NIL);
if ((*ArrayMerging_word == NIL) ||
((base == NIL) ||
(checkarrayblock(base, T, T) ||
((nbase == *ArrayFrLst_word) ||
((nbase == *ArrayFrLst2_word) ||
(checkarrayblock(nbase, (!(nbinuse = bnbase->inuse)), NIL) || nbinuse))))))
return (NIL);
deleteblock(nbase);
deleteblock(base);
return (arrayblockmerger(base, nbase));

View File

@@ -375,6 +375,8 @@ static u_char *make_X_keymap(void) {
table[xcode - 7] = code;
}
XFree(mapping); /* No locking required? */
#ifdef DEBUG
printf("\n\n\tXGetKeyboardMapping table\n\n");
for (i = 0; i < codecount * symspercode; i += symspercode) {
@@ -392,8 +394,6 @@ static u_char *make_X_keymap(void) {
}
#endif /* DEBUG */
XFree(mapping); /* No locking required? */
return (table);
}

View File

@@ -37,7 +37,7 @@
#include "ifpage.h" // for IFPAGE, MACHINETYPE_MAIKO
#include "initsoutdefs.h" // for build_lisp_map, fixp_value, init_for_bitblt
#include "iopage.h" // for IOPAGE
#include "lispemul.h" // for LispPTR, DLword, NIL, BYTESPER_DLWORD, POINTERMASK
#include "lispemul.h" // for LispPTR, DLword, NIL, BYTESPER_DLWORD
#include "lispmap.h" // for ATMHT_OFFSET, ATOMS_OFFSET, DEFS_OFFSET
#include "lspglob.h" // for InterfacePage, IOPage, AtomHT, Closure_Cac...
#include "lsptypes.h" // for GetDTD, TYPE_FIXP, TYPE_LISTP
@@ -405,9 +405,7 @@ void init_for_keyhandle(void) {
MOUSECHORDTICKS68k = MakeAtom68k("\\MOUSECHORDTICKS");
LASTUSERACTION68k = MakeAtom68k("\\LASTUSERACTION");
#ifndef INIT
CLastUserActionCell68k = (LispPTR *)NativeAligned4FromLAddr(*LASTUSERACTION68k & POINTERMASK);
#endif
CLastUserActionCell68k = (LispPTR *)NativeAligned4FromLAddr(*LASTUSERACTION68k & 0xffffff);
DOBUFFEREDTRANSITION_index = MAKEATOM("\\DOBUFFEREDTRANSITIONS");
INTERRUPTFRAME_index = MAKEATOM("\\INTERRUPTFRAME");

View File

@@ -1,24 +0,0 @@
<!doctype html>
<!-- Based on https://github.com/timhutton/sdl-canvas-wasm/blob/main/index.html -->
<!-- html to set up WebAssembly module for Medley running in a browser -->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div style="text-align: center;">
<canvas id="canvas" oncontextmenu="event.preventDefault()"></canvas>
</div>
<script type="text/javascript">
var width = 32*Math.trunc(Math.min(Math.max(window.innerWidth, 512), 1664)/32);
var height = Math.min(Math.max(window.innerHeight, 512), 1260);
var Module = {
preRun: [ function() {ENV.MEDLEYDIR = "{DSK}<medley>";} ],
arguments: ["medley/loadups/full.sysout","-sc", width+"x"+height, "-nh-host", "127.0.0.1"],
canvas: (function() { return document.getElementById('canvas'); })()
};
</script>
<script src="ldesdl.js"></script>
</body>
</html>

View File

@@ -72,7 +72,7 @@ retry:
if (917505 == *(LispPTR *)ptr) error("N_OP_createcell E0001 error");
/* replace dtd_free with newcell's top DLword (it may keep next chain)*/
dtd68k->dtd_free = (*((LispPTR *)ptr)) & POINTERMASK;
if (dtd68k->dtd_free & 0x8000001) error("bad entry on free chain.");
if (dtd68k->dtd_free & 0x8000001) error("bad entry on free chain(1).");
dtd68k->dtd_oldcnt++;
@@ -84,7 +84,7 @@ retry:
return (tos);
} else {
dtd68k->dtd_free = initmdspage(alloc_mdspage(dtd68k->dtd_typeentry), dtd68k->dtd_size, NIL);
if (dtd68k->dtd_free & 0x8000000) error("bad entry on free chain.");
if (dtd68k->dtd_free & 0x8000000) error("bad entry on free chain(2).");
goto retry;
}
@@ -119,7 +119,7 @@ retry:
/* replace dtd_free with newcell's top DLword (it may keep next chain)*/
dtd68k->dtd_free = (*((LispPTR *)ptr)) & POINTERMASK;
if (dtd68k->dtd_free & 0x8000000) error("bad entry on free chain.");
if (dtd68k->dtd_free & 0x8000000) error("bad entry on free chain(3).");
#ifdef DTDDEBUG
if ((dtd68k->dtd_free != 0) && (type != GetTypeNumber(dtd68k->dtd_free)))
@@ -144,7 +144,7 @@ retry:
} else {
dtd68k->dtd_free = initmdspage(alloc_mdspage(dtd68k->dtd_typeentry), dtd68k->dtd_size, NIL);
if (dtd68k->dtd_free & 0x8000000) error("bad entry on free chain.");
if (dtd68k->dtd_free & 0x8000000) error("bad entry on free chain(4).");
#ifdef DTDDEBUG
check_dtd_chain(type);

View File

@@ -118,19 +118,6 @@ void update_miscstats(void) {
MiscStats->diskiotime = 0; /* ?? not available ?? */
MiscStats->diskops = 0;
MiscStats->secondstmp = MiscStats->secondsclock = (time(0) + UNIX_ALTO_TIME_DIFF);
#elif defined(MAIKO_OS_EMSCRIPTEN)
/* Emscripten does not provide getrusage() functionality */
struct timeval timev;
MiscStats->totaltime = gettime(0) - MiscStats->starttime;
MiscStats->swapwaittime = 0;
MiscStats->pagefaults = 0;
MiscStats->swapwrites = 0;
MiscStats->diskiotime = 0;
MiscStats->diskops = 0;
gettimeofday(&timev, NULL);
MiscStats->secondstmp = MiscStats->secondsclock = (timev.tv_sec + UNIX_ALTO_TIME_DIFF);
#else
struct timeval timev;
struct rusage ru;
@@ -301,8 +288,6 @@ void subr_settime(LispPTR args[])
dosday.year = uxtime.tm_year;
dosday.dayofweek = uxtime.tm_wday;
_dos_setdate(&dosday);
#elif defined(MAIKO_OS_EMSCRIPTEN)
(void)args[0];
#else
struct timeval timev;
timev.tv_sec = *((int *)NativeAligned4FromLAddr(args[0])) - UNIX_ALTO_TIME_DIFF;

View File

@@ -518,7 +518,6 @@ LispPTR Unix_handlecomm(LispPTR *args) {
DBPRINT(("Terminating process in slot %d.\n", slot));
if (!valid_slot(slot)) return (ATOM_T);
/* in all cases we need to close() the file descriptor */
if (slot == 0) DBPRINT(("ZERO SLOT\n"));
close(slot);
switch (UJ[slot].type) {
case UJSHELL:
@@ -700,7 +699,7 @@ LispPTR Unix_handlecomm(LispPTR *args) {
if (!valid_slot(slot)) return (NIL); /* No fd open; punt the read */
bufp = (NativeAligned2FromLAddr(args[2])); /* User buffer */
DBPRINT(("Read buffer slot %d, type is %d buffer LAddr 0x%x (native %p)\n", slot, UJ[slot].type, args[2], bufp));
DBPRINT(("Read buffer slot %d, type is %d\n", slot, UJ[slot].type));
switch (UJ[slot].type) {
case UJSHELL:

View File

@@ -98,7 +98,7 @@ static int ForkUnixShell(int slot, char *PtySlave, char *termtype, char *shellar
if (SlaveFD == -1) {
perror("Slave Open");
perror(PtySlave);
exit(1);
exit(0);
}
#ifdef OS5
@@ -132,7 +132,7 @@ static int ForkUnixShell(int slot, char *PtySlave, char *termtype, char *shellar
for (userShell = getusershell(); userShell != NULL && strcmp(shell, userShell) != 0; userShell = getusershell());
if (userShell == NULL) {
perror("$(SHELL) not found in /etc/shells");
exit(1);
exit(0);
}
/* argvec entries initialized to NULL */
@@ -146,7 +146,7 @@ static int ForkUnixShell(int slot, char *PtySlave, char *termtype, char *shellar
/* Should never get here */
perror("execv");
exit(1);
exit(0);
}
/* fork_Unix is the secondary process spawned right after LISP is
@@ -264,14 +264,12 @@ int fork_Unix(void) {
while (1) {
ssize_t len;
len = SAFEREAD(LispPipeIn, IOBuf, 6);
if (len == 0)
exit(0);
if (len < 0) {
perror("Error reading packet by slave");
exit(1);
exit(0);
} else if (len != 6) {
DBPRINT(("Input packet wrong length: %zd", len));
exit(1);
exit(0);
}
slot = IOBuf[3];
IOBuf[3] = 1; /* Start by signalling success in return-code */
@@ -347,7 +345,7 @@ int fork_Unix(void) {
sock = socket(AF_UNIX, SOCK_STREAM, 0);
if (sock < 0) {
perror("slave socket");
exit(1);
exit(0);
}
sprintf(PipeName, "/tmp/LPU%ld-%d", StartTime, slot);
memset(&addr, 0, sizeof(struct sockaddr_un));
@@ -359,7 +357,7 @@ int fork_Unix(void) {
perror("slave connect");
printf("Name = %s.\n", PipeName);
fflush(stdout);
exit(1);
exit(0);
} else {
DBPRINT(("Slave connected on %s.\n", PipeName));
}

View File

@@ -354,7 +354,7 @@ LispPTR vmem_save(char *sysout_file_name)
TIMEOUT(sysout = open(sysout_file_name, O_WRONLY, 0666));
if (sysout == -1) {
/* No file error skip return. */
if (errno != ENOENT) return (FILECANNOTOPEN); /* No such file error.*/
if (errno != 2) return (FILECANNOTOPEN); /* No such file error.*/
} else
TIMEOUT(rval = close(sysout));
@@ -481,7 +481,7 @@ LispPTR vmem_save(char *sysout_file_name)
TIMEOUT(rval = unlink(sysout_file_name));
if (rval == -1) {
/* No file error skip return. */
if (errno != ENOENT) /* No such file error.*/
if (errno != 2) /* No such file error.*/
return (FILECANNOTOPEN);
}
@@ -531,5 +531,5 @@ void lisp_finish(void) {
#ifdef DOS
exit_host_filesystem();
#endif /* DOS */
exit(0);
exit(1);
}

View File

@@ -20,9 +20,6 @@
/* */
/************************************************************************/
#ifdef MAIKO_OS_EMSCRIPTEN
#include <emscripten.h>
#endif
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
@@ -289,9 +286,6 @@ nextopcode:
Irq_Stk_End = 0;
#if defined(MAIKO_EMULATE_ASYNC_INTERRUPTS)
IO_Signalled = TRUE;
#endif
#ifdef MAIKO_OS_EMSCRIPTEN
emscripten_sleep(1);
#endif
pseudoTimerAsyncCountdown = insnsCountdownForTimerAsyncEmulation;
}

View File

@@ -16,7 +16,6 @@
#include <signal.h> // for sig_atomic_t
#include <stdbool.h> // for false, bool, true
#include <stdio.h> // for NULL
#include <stdlib.h> // for exit
#include "adr68k.h" // for NativeAligned4FromLAddr
#include "dbprint.h" // for TPRINT
#include "devif.h" // for (anonymous), MRegion, DspInterface, OUTER_S...
@@ -201,27 +200,6 @@ void Open_Display(DspInterface dsp)
init_Xevent(dsp); /* Turn on the event reporting */
} /* end OpenDisplay */
int X_FatalErrorHandler(Display *display)
{
/* when the fatal error handler gets called it can do cleanup
* and either exit, or return. If it returns, the
* FatalErrorExitHandler will be called
*/
/* If we could do a SAVEVM in the interrupt context we would mark it
* as needed here. Returning will cause the FatalErrorExitHandler
* hook to be called.
*/
return 0;
}
void X_FatalErrorExitHandler(Display *display, void *userdata)
{
/* If we were invoking a SAVEVM/LOGOUT in the interrupt context we
* would not exit here, as the Lisp VM needs to continue to run
*/
exit(1);
}
/*********************************************************************/
/* */
/* X _ i n i t */
@@ -258,10 +236,6 @@ DspInterface X_init(DspInterface dsp, LispPTR lispbitmap, unsigned width_hint, u
/* Try to open the X display. If this isn't possible, we just */
/* return FALSE. */
if ((dsp->display_id = XOpenDisplay(dsp->identifier)) == NULL) return (NULL);
XSetIOErrorHandler(X_FatalErrorHandler);
XSetIOErrorExitHandler(dsp->display_id, X_FatalErrorExitHandler, NULL);
/* Load the dsp structure */
Xscreen = ScreenOfDisplay(dsp->display_id, DefaultScreen(dsp->display_id));

View File

@@ -188,7 +188,6 @@ void process_Xevents(DspInterface dsp)
XNextEvent(dsp->display_id, &report);
if (report.xany.window == dsp->DisplayWindow) /* Try the most important window first. */
switch (report.type) {
#ifndef INIT
case MotionNotify:
*CLastUserActionCell68k = MiscStats->secondstmp;
*EmCursorX68K = (*((DLword *)EmMouseX68K)) =
@@ -236,7 +235,6 @@ void process_Xevents(DspInterface dsp)
break;
case EnterNotify: Mouse_Included = TRUE; break;
case LeaveNotify: Mouse_Included = FALSE; break;
#endif
case Expose:
(dsp->bitblt_to_screen)(dsp, 0, report.xexpose.x + dsp->Visible.x,
report.xexpose.y + dsp->Visible.y, report.xexpose.width,