(define impc:aot:insert-header
(lambda (libname)
(if (output-port? *impc:aot:current-output-port*)
(begin
(display (string-append "(sys:load-preload-check '" (substring libname 3) ")\n")
*impc:aot:current-output-port*)
(display (string-append "(define *xtmlib-" (substring libname 3) "-loaded* #t)\n")
*impc:aot:current-output-port*)
(display (string-append "(define *xtmlib-" (substring libname 3) "-loaded-timer* (clock:clock))\n")
*impc:aot:current-output-port*)
(display "(set! *impc:aot:prev-compiler-message-level* *impc:compiler:message:level*)\n(set! *impc:compiler:message:level* 'low)\n"
*impc:aot:current-output-port*)
(display (string-append "\n(print \"Loading \")\n(print-with-colors 'blue 'default #t (print '"
libname "))\n(print \" library... \")\n")
*impc:aot:current-output-port*)
(if *impc:compiler:aot:dll*
(begin
(display (string-append "(bind-dylib " libname " \"" libname
(cond ((string=? (sys:platform) "Linux") ".so\")\n")
((string=? (sys:platform) "Windows") ".dll\")\n")
((string=? (sys:platform) "OSX") ".dylib\")\n")))
*impc:aot:current-output-port*)
(write
`(if (not ,(string->symbol libname))
(begin
(print-with-colors '*impc:compiler:pretty-print-error-color* 'default #t (print "Error"))
(print ": could not load the AOT-compilied " ,libname
" dynamic library\n")
(error "")))
*impc:aot:current-output-port*)
(display (string-append ";; flush the JIT-compilation queue, so we only get this file's code in the module\n"
"(impc:compiler:flush-jit-compilation-queue)\n")
*impc:aot:current-output-port*)))))))