diff --git a/build.sh b/build.sh index b1416de..771e744 100755 --- a/build.sh +++ b/build.sh @@ -39,7 +39,7 @@ touch sdlquake-1.0.9/Makefile.in mkdir sdlquake-build pushd sdlquake-build CC="${TOOLDIR}/bin/clang -Wl,-optimize=speed+\(safety+0\)+\(debug+0\)+\(space+0\)+\(compilation-speed+0\),-package=:sdlquake" ../sdlquake-1.0.9/configure --host=le32-iota --prefix=${TOOLDIR}/le32-iota --disable-sdltest --with-sdl-prefix=${TOOLDIR}/le32-iota -touch sdlquake-1.0.9/Makefile.in +touch ../sdlquake-1.0.9/Makefile.in make ${MAKEFLAGS} popd cp sdlquake-build/sdlquake sdlquake.lisp diff --git a/iota-provided-symbols b/iota-provided-symbols index bd50052..a719fc8 100644 --- a/iota-provided-symbols +++ b/iota-provided-symbols @@ -17,6 +17,9 @@ llvm.memmove.p0i8.p0i8.i32 memcpy llvm.memcpy.p0i8.p0i8.i32 _exit +llvm.bswap.i16 +llvm.ctlz.i32 +llvm.memcpy.p0i8.p0i8.i64 # Unix support sbrk @@ -31,6 +34,8 @@ access mkdir gettimeofday nanosleep +usleep +link # SDL support _iota_video_init diff --git a/runtime/llvm-runtime.lisp b/runtime/llvm-runtime.lisp index 291bd2d..9bffed3 100644 --- a/runtime/llvm-runtime.lisp +++ b/runtime/llvm-runtime.lisp @@ -627,6 +627,10 @@ PERSONALITY is bound to the context's personality object." (ash (ldb (byte 8 16) value) 8) (ldb (byte 8 24) value))) +(define-llvm-function |llvm.bswap.i16| ((value)) + (logior (ash (ldb (byte 8 0) value) 8) + (ldb (byte 8 8) value))) + (define-llvm-function |llvm.flt.rounds| (()) ;; Rounding mode 1, round to nearest. 1) @@ -666,6 +670,14 @@ PERSONALITY is bound to the context's personality object." (define-llvm-function |llvm.memcpy.p0i8.p0i8.i32| ((d s n align is-volatile)) (real-memmove llvm-context d s n)) +(define-llvm-function |llvm.memcpy.p0i8.p0i8.i64| ((d s n align is-volatile)) + (real-memmove llvm-context d s n)) + + +(define-llvm-function |llvm.ctlz.i32| ((value zero-error-p)) + (- 32 (integer-length values))) + + ;;; It's a UNIX system! I know this! (defun align-stack (context) @@ -944,6 +956,15 @@ Assumes the context is freshly created." (ensure-directories-exist (parse-unix-path unix path :ensure-directory t)) 0)) +;;we don't have hardlinks implemented, so we're just gonna copy. +;;hope this works well enough +(define-llvm-function |link| ((oldpath newpath)) + (let ((old (parse-unix-path unix oldpath)) + (new (parse-unix-path unix new))) + (unless (probe-file new) + (uiop:copy-file old new) + 0))) + (define-llvm-function |gettimeofday| ((tv tz)) (let* ((unix-epoch (encode-universal-time 0 0 0 1 1 1970 0)) (current-time (/ (get-internal-real-time) @@ -966,3 +987,7 @@ Assumes the context is freshly created." (store.i32 0 rem) (store.i32 0 (+ rem 4))) 0) + +(define-llvm-function |usleep| ((usec)) + (sleep (/ usec (* 1000 1000))) + 0) diff --git a/runtime/package.lisp b/runtime/package.lisp index f9ab3b2..60dc3ab 100644 --- a/runtime/package.lisp +++ b/runtime/package.lisp @@ -390,15 +390,20 @@ #:|llvm.memmove.p0i8.p0i8.i32| #:|llvm.memset.p0i8.i32| #:|llvm.memset.p0i8.i64| + #:|llvm.memcpy.p0i8.p0i8.i64| + #:|llvm.bswap.i32| + #:|llvm.ctlz.i32| #:|longjmp| #:|lseek| #:|mkdir| #:|nanosleep| + #:|usleep| #:|open| #:|read| #:|sbrk| #:|setjmp| #:|write| + #:|link| ;; SDL support functions. #:|_iota_video_init| #:|_iota_video_quit|