mirror of
https://github.com/Interlisp/maiko.git
synced 2026-02-27 17:12:42 +00:00
Merge remote-tracking branch 'no-defun-allowed/master' into incorporate-wasm-changes
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -19,6 +19,9 @@ cmake-build-*/**
|
||||
*.x86_64-x/**
|
||||
*.x86_64-sdl/**
|
||||
*.x86_64/**
|
||||
*.wasm/**
|
||||
!emscripten.wasm/ldesdl.html
|
||||
*.wasm-wasm/**
|
||||
*.armv7l-x/**
|
||||
*.armv7l/**
|
||||
*.aarch64-x/**
|
||||
|
||||
19
bin/makefile-emscripten.wasm-wasm
Normal file
19
bin/makefile-emscripten.wasm-wasm
Normal file
@@ -0,0 +1,19 @@
|
||||
# Options for Emscripten, WASM and SDL
|
||||
|
||||
CC = emcc -sUSE_SDL=2 -sASYNCIFY -sALLOW_MEMORY_GROWTH $(CLANG_CFLAGS)
|
||||
|
||||
XFILES = $(OBJECTDIR)sdl.o
|
||||
|
||||
XFLAGS = -DSDL
|
||||
|
||||
# OPTFLAGS is normally -O2.
|
||||
OPTFLAGS = -O2 -g3
|
||||
DFLAGS = $(XFLAGS) -DRELEASE=351
|
||||
|
||||
LD = emcc
|
||||
LDFLAGS = -sUSE_SDL=2 --preload-file $(SYSOUT)@full.sysout
|
||||
LDELDFLAGS =
|
||||
|
||||
OBJECTDIR = ../$(RELEASENAME)/
|
||||
|
||||
default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldesdl.js
|
||||
@@ -74,6 +74,11 @@ 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
|
||||
;;
|
||||
|
||||
20
emscripten.wasm/ldesdl.html
Normal file
20
emscripten.wasm/ldesdl.html
Normal file
@@ -0,0 +1,20 @@
|
||||
<!doctype html>
|
||||
<!-- Based on https://github.com/timhutton/sdl-canvas-wasm/blob/main/index.html -->
|
||||
<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 Module = {
|
||||
arguments: ["full.sysout"],
|
||||
canvas: (function() { return document.getElementById('canvas'); })()
|
||||
};
|
||||
</script>
|
||||
<script src="ldesdl.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -83,6 +83,19 @@
|
||||
# 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
|
||||
|
||||
@@ -73,6 +73,11 @@ extern int ether_fd;
|
||||
extern DspInterface currentdsp;
|
||||
#endif /* XWINDOW */
|
||||
|
||||
#ifdef MAIKO_OS_EMSCRIPTEN
|
||||
/* We can't touch the system clock */
|
||||
#define settimeofday(tv, tz)
|
||||
#endif
|
||||
|
||||
#define LISP_UNIX_TIME_DIFF 29969152
|
||||
#define LISP_ALTO_TIME_MASK 0x80000000
|
||||
#define UNIX_ALTO_TIME_DIFF 2177452800U
|
||||
|
||||
@@ -45,6 +45,11 @@
|
||||
int flushing = 0;
|
||||
#endif
|
||||
|
||||
#ifdef MAIKO_OS_EMSCRIPTEN
|
||||
/* We don't have any shell */
|
||||
#define getusershell() NULL
|
||||
#endif
|
||||
|
||||
/* Used to communicate between Unix subprocesses and LISP */
|
||||
|
||||
static long StartTime; /* Time, for creating pipe filenames */
|
||||
|
||||
10
src/xc.c
10
src/xc.c
@@ -33,6 +33,10 @@
|
||||
#include <sys/time.h>
|
||||
#endif /* DOS */
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h> /* Defines emscripten_sleep */
|
||||
#endif /* __EMSCRIPTEN__ */
|
||||
|
||||
#include "lispemul.h"
|
||||
#include "emlglob.h"
|
||||
#include "address.h"
|
||||
@@ -183,6 +187,9 @@ static int pseudoTimerAsyncCountdown = MAIKO_TIMER_ASYNC_EMULATION_INSNS_COUNTDO
|
||||
|
||||
void dispatch(void) {
|
||||
InstPtr pccache;
|
||||
#ifdef __EMSCRIPTEN__
|
||||
int cycles = 0;
|
||||
#endif
|
||||
|
||||
#if defined(OPDISP)
|
||||
static const void* optable[256] = {
|
||||
@@ -261,6 +268,9 @@ op_ufn : {
|
||||
/* DISPATCH "LOOP" */
|
||||
|
||||
nextopcode:
|
||||
#ifdef __EMSCRIPTEN__
|
||||
if (++cycles % 1000000 == 0) emscripten_sleep(1);
|
||||
#endif
|
||||
#ifdef MYOPTRACE
|
||||
if ((struct fnhead *)NativeAligned4FromLAddr(0x2ed600) == FuncObj) {
|
||||
quick_stack_check();
|
||||
|
||||
Reference in New Issue
Block a user