Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions iota-provided-symbols
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,6 +34,8 @@ access
mkdir
gettimeofday
nanosleep
usleep
link

# SDL support
_iota_video_init
Expand Down
25 changes: 25 additions & 0 deletions runtime/llvm-runtime.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
5 changes: 5 additions & 0 deletions runtime/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down