if_mzscheme does not work. I wrote patch for it. Please check the attached patch.
Linux & Windows: Fix startup_mzscheme() to initialize collects and config path properly. Linux: Fix configure script for build error. Windows: Fix make_mvc.mak for build error. Use scheme_register_tls_space() for 64bit Windows (racket provides it for 64bit from version 6.3). Enable DYNAMIC_MZSCHEME with precise GC version of racket which is the binary distributed by racket-lang.org. I tested racket-6.3 64bit, racket-6.3 32bit, racket-5.1.2 64bit and racket 5.0 32bit in Windows10 64bit. And racket-6.3, racket-5.3.6 in Ubuntu 15.04 64bit. -- Yukihiro Nakadaira - yukihiro.nakada...@gmail.com -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
diff --git a/runtime/doc/if_mzsch.txt b/runtime/doc/if_mzsch.txt index b42570a..a6d4794 100644 --- a/runtime/doc/if_mzsch.txt +++ b/runtime/doc/if_mzsch.txt @@ -272,6 +272,9 @@ output then includes |+mzscheme/dyn|. This means that Vim will search for the MzScheme DLL files only when needed. When you don't use the MzScheme interface you don't need them, thus you can use Vim without these DLL files. +NOTE: Newer version of MzScheme (Racket) require earlier (trampolined) +initialisation via scheme_main_setup. So Vim always load MzScheme DLL at +startup if possible. To use the MzScheme interface the MzScheme DLLs must be in your search path. In a console window type "path" to see what directories are used. @@ -282,5 +285,12 @@ For MzScheme version 209 they will be "libmzsch209_000.dll" and command, look for -DDYNAMIC_MZSCH_DLL="something" and -DDYNAMIC_MZGC_DLL="something" in the "Compilation" info. +For example, if MzScheme (Racket) is installed at C:\Racket63, you may need +to set the environment variable as the following: > + + set PATH=%PATH%;C:\Racket63\lib + set PLTCOLLECTS=C:\Racket63\collects + set PLTCONFIGDIR=C:\Racket63\etc +< ====================================================================== vim:tw=78:ts=8:sts=4:ft=help:norl: diff --git a/src/Make_mvc.mak b/src/Make_mvc.mak index f3c19b5..5add91b 100644 --- a/src/Make_mvc.mak +++ b/src/Make_mvc.mak @@ -740,7 +740,7 @@ CFLAGS = $(CFLAGS) -DFEAT_MZSCHEME -I $(MZSCHEME)\include !if EXIST("$(MZSCHEME)\collects\scheme\base.ss") \ || EXIST("$(MZSCHEME)\collects\scheme\base.rkt") \ || EXIST("$(MZSCHEME)\collects\racket\base.rkt") -# for MzScheme >= 4 we need to include byte code for basic Scheme stuff +# Include byte code for basic Scheme stuff (optional) MZSCHEME_EXTRA_DEP = mzscheme_base.c CFLAGS = $(CFLAGS) -DINCLUDE_MZSCHEME_BASE !endif @@ -749,27 +749,43 @@ MZSCHEME_MAIN_LIB=mzsch !else MZSCHEME_MAIN_LIB=racket !endif -!if EXIST("$(MZSCHEME)\lib\msvc\lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).lib") \ - && !EXIST("$(MZSCHEME)\lib\msvc\libmzgc$(MZSCHEME_VER).lib") +!if (EXIST("$(MZSCHEME)\lib\lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).dll") \ + && !EXIST("$(MZSCHEME)\lib\libmzgc$(MZSCHEME_VER).dll")) \ + || (EXIST("$(MZSCHEME)\lib\msvc\lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).lib") \ + && !EXIST("$(MZSCHEME)\lib\msvc\libmzgc$(MZSCHEME_VER).lib")) !message Building with Precise GC MZSCHEME_PRECISE_GC = yes CFLAGS = $(CFLAGS) -DMZ_PRECISE_GC !endif !if "$(DYNAMIC_MZSCHEME)" == "yes" +!message MzScheme DLLs will be loaded dynamically +CFLAGS = $(CFLAGS) -DDYNAMIC_MZSCHEME !if "$(MZSCHEME_PRECISE_GC)" == "yes" -!error MzScheme with Precise GC cannot be loaded dynamically +# Precise GC does not use separate dll +CFLAGS = $(CFLAGS) \ + -DDYNAMIC_MZSCH_DLL=\"lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).dll\" \ + -DDYNAMIC_MZGC_DLL=\"lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).dll\" +!else +CFLAGS = $(CFLAGS) \ + -DDYNAMIC_MZSCH_DLL=\"lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).dll\" \ + -DDYNAMIC_MZGC_DLL=\"libmzgc$(MZSCHEME_VER).dll\" !endif -!message MzScheme DLLs will be loaded dynamically -CFLAGS = $(CFLAGS) -DDYNAMIC_MZSCHEME \ - -DDYNAMIC_MZSCH_DLL=\"lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).dll\" \ - -DDYNAMIC_MZGC_DLL=\"libmzgc$(MZSCHEME_VER).dll\" !else +!if EXIST("$(MZSCHEME)\lib\lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).def") +# create .lib from .def +MZSCHEME_BUILD_LIB=yes +MZSCHEME_EXTRA_DEP = $(MZSCHEME_EXTRA_DEP) lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).lib +!endif !if "$(MZSCHEME_DEBUG)" == "yes" CFLAGS = $(CFLAGS) -DMZSCHEME_FORCE_GC !endif !if "$(MZSCHEME_PRECISE_GC)" == "yes" # Precise GC does not use separate dll +!if "$(MZSCHEME_BUILD_LIB)" == "yes" +MZSCHEME_LIB = lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).lib +!else MZSCHEME_LIB = $(MZSCHEME)\lib\msvc\lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).lib +!endif !else MZSCHEME_LIB = $(MZSCHEME)\lib\msvc\libmzgc$(MZSCHEME_VER).lib \ $(MZSCHEME)\lib\msvc\lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).lib @@ -1138,6 +1154,9 @@ mzscheme_base.c: $(MZSCHEME)\mzc --c-mods mzscheme_base.c ++lib scheme/base !ENDIF +lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).lib: + lib /DEF:$(MZSCHEME)\lib\lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).def + $(OUTDIR)/if_python.obj: $(OUTDIR) if_python.c if_py_both.h $(INCL) $(CC) $(CFLAGS) $(PYTHON_INC) if_python.c diff --git a/src/auto/configure b/src/auto/configure index a045279..cb43d8d 100755 --- a/src/auto/configure +++ b/src/auto/configure @@ -5207,6 +5207,7 @@ fi if test "X$with_plthome" != "X"; then vi_cv_path_mzscheme_pfx="$with_plthome" + vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking PLTHOME environment var" >&5 $as_echo_n "checking PLTHOME environment var... " >&6; } @@ -5214,6 +5215,7 @@ $as_echo_n "checking PLTHOME environment var... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: \"$PLTHOME\"" >&5 $as_echo "\"$PLTHOME\"" >&6; } vi_cv_path_mzscheme_pfx="$PLTHOME" + vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: not set" >&5 $as_echo "not set" >&6; } @@ -5285,54 +5287,63 @@ $as_echo "$vi_cv_path_mzscheme_pfx" >&6; } fi fi - SCHEME_INC= if test "X$vi_cv_path_mzscheme_pfx" != "X"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include" >&5 -$as_echo_n "checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include... " >&6; } - if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then - SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for racket include directory" >&5 +$as_echo_n "checking for racket include directory... " >&6; } + SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'` + if test "X$SCHEME_INC" != "X"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${SCHEME_INC}" >&5 +$as_echo "${SCHEME_INC}" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt" >&5 -$as_echo_n "checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt... " >&6; } - if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include" >&5 +$as_echo_n "checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include... " >&6; } + if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then + SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } - SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket" >&5 -$as_echo_n "checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket... " >&6; } - if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt" >&5 +$as_echo_n "checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt... " >&6; } + if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } - SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket + SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if scheme.h can be found in /usr/include/plt/" >&5 -$as_echo_n "checking if scheme.h can be found in /usr/include/plt/... " >&6; } - if test -f /usr/include/plt/scheme.h; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket" >&5 +$as_echo_n "checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket... " >&6; } + if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } - SCHEME_INC=/usr/include/plt + SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if scheme.h can be found in /usr/include/racket/" >&5 -$as_echo_n "checking if scheme.h can be found in /usr/include/racket/... " >&6; } - if test -f /usr/include/racket/scheme.h; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if scheme.h can be found in /usr/include/plt/" >&5 +$as_echo_n "checking if scheme.h can be found in /usr/include/plt/... " >&6; } + if test -f /usr/include/plt/scheme.h; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } - SCHEME_INC=/usr/include/racket + SCHEME_INC=/usr/include/plt else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - vi_cv_path_mzscheme_pfx= + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if scheme.h can be found in /usr/include/racket/" >&5 +$as_echo_n "checking if scheme.h can be found in /usr/include/racket/... " >&6; } + if test -f /usr/include/racket/scheme.h; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SCHEME_INC=/usr/include/racket + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + vi_cv_path_mzscheme_pfx= + fi fi fi fi @@ -5341,52 +5352,101 @@ $as_echo "no" >&6; } fi if test "X$vi_cv_path_mzscheme_pfx" != "X"; then - if test "x$MACOSX" = "xyes"; then - MZSCHEME_LIBS="-framework Racket" - MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" - elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"; then - MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a" - MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" - elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket3m.a"; then - MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libracket3m.a" - MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" - elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket.a"; then - MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libracket.a ${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a" - elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme.a"; then - MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme.a ${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for racket lib directory" >&5 +$as_echo_n "checking for racket lib directory... " >&6; } + SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'` + if test "X$SCHEME_LIB" != "X"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${SCHEME_LIB}" >&5 +$as_echo "${SCHEME_LIB}" >&6; } else - if test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.so"; then - MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme3m" - MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" - elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket3m.so"; then - MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lracket3m" - MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" - elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket.so"; then - MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lracket -lmzgc" - else - MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme -lmzgc" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + fi + + for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do + if test "X$path" != "X"; then + if test "x$MACOSX" = "xyes"; then + MZSCHEME_LIBS="-framework Racket" + MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" + elif test -f "${path}/libmzscheme3m.a"; then + MZSCHEME_LIBS="${path}/libmzscheme3m.a" + MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" + elif test -f "${path}/libracket3m.a"; then + MZSCHEME_LIBS="${path}/libracket3m.a" + MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" + elif test -f "${path}/libracket.a"; then + MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a" + elif test -f "${path}/libmzscheme.a"; then + MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a" + else + if test -f "${path}/libmzscheme3m.so"; then + MZSCHEME_LIBS="-L${path} -lmzscheme3m" + MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" + elif test -f "${path}/libracket3m.so"; then + MZSCHEME_LIBS="-L${path} -lracket3m" + MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" + elif test -f "${path}/libracket.so"; then + MZSCHEME_LIBS="-L${path} -lracket -lmzgc" + else + if test "$path" != "$SCHEME_LIB"; then + continue + fi + MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc" + fi + if test "$GCC" = yes; then + MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}" + elif test "`(uname) 2>/dev/null`" = SunOS && + uname -r | grep '^5' >/dev/null; then + MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}" + fi + fi fi - if test "$GCC" = yes; then - MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${vi_cv_path_mzscheme_pfx}/lib" - elif test "`(uname) 2>/dev/null`" = SunOS && - uname -r | grep '^5' >/dev/null; then - MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${vi_cv_path_mzscheme_pfx}/lib" + if test "X$MZSCHEME_LIBS" != "X"; then + break fi + done + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if racket requires -pthread" >&5 +$as_echo_n "checking if racket requires -pthread... " >&6; } + if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread" + MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for racket config directory" >&5 +$as_echo_n "checking for racket config directory... " >&6; } + SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'` + if test "X$SCHEME_CONFIGDIR" != "X"; then + MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${SCHEME_CONFIGDIR}" >&5 +$as_echo "${SCHEME_CONFIGDIR}" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for racket collects directory" >&5 $as_echo_n "checking for racket collects directory... " >&6; } - if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then - SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/ - else - if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then - SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/ + SCHEME_COLLECTS=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-collects-dir))) (when (path? p) (let-values (((base _1 _2) (split-path p))) (display base))))'` + if test "X$SCHEME_COLLECTS" = "X"; then + if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then + SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/ else - if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then - SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/ + if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then + SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/ else - if test -d "$vi_cv_path_mzscheme_pfx/collects"; then - SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/ + if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then + SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/ + else + if test -d "$vi_cv_path_mzscheme_pfx/collects"; then + SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/ + fi fi fi fi @@ -5420,7 +5480,6 @@ $as_echo_n "checking for mzscheme_base.c... " >&6; } fi if test "X$MZSCHEME_EXTRA" != "X" ; then MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE" - MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc" { $as_echo "$as_me:${as_lineno-$LINENO}: result: needed" >&5 $as_echo "needed" >&6; } else diff --git a/src/configure.in b/src/configure.in index 17368c1..02798d3 100644 --- a/src/configure.in +++ b/src/configure.in @@ -695,11 +695,13 @@ if test "$enable_mzschemeinterp" = "yes"; then if test "X$with_plthome" != "X"; then vi_cv_path_mzscheme_pfx="$with_plthome" + vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme" else AC_MSG_CHECKING(PLTHOME environment var) if test "X$PLTHOME" != "X"; then AC_MSG_RESULT("$PLTHOME") vi_cv_path_mzscheme_pfx="$PLTHOME" + vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme" else AC_MSG_RESULT(not set) dnl -- try to find MzScheme executable @@ -731,39 +733,45 @@ if test "$enable_mzschemeinterp" = "yes"; then fi fi - SCHEME_INC= if test "X$vi_cv_path_mzscheme_pfx" != "X"; then - AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include) - if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then - SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include - AC_MSG_RESULT(yes) + AC_MSG_CHECKING(for racket include directory) + SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'` + if test "X$SCHEME_INC" != "X"; then + AC_MSG_RESULT(${SCHEME_INC}) else - AC_MSG_RESULT(no) - AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt) - if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then + AC_MSG_RESULT(not found) + AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include) + if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then + SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include AC_MSG_RESULT(yes) - SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt else AC_MSG_RESULT(no) - AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket) - if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then + AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt) + if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then AC_MSG_RESULT(yes) - SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket + SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt else AC_MSG_RESULT(no) - AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/) - if test -f /usr/include/plt/scheme.h; then + AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket) + if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then AC_MSG_RESULT(yes) - SCHEME_INC=/usr/include/plt + SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket else AC_MSG_RESULT(no) - AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/) - if test -f /usr/include/racket/scheme.h; then + AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/) + if test -f /usr/include/plt/scheme.h; then AC_MSG_RESULT(yes) - SCHEME_INC=/usr/include/racket + SCHEME_INC=/usr/include/plt else AC_MSG_RESULT(no) - vi_cv_path_mzscheme_pfx= + AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/) + if test -f /usr/include/racket/scheme.h; then + AC_MSG_RESULT(yes) + SCHEME_INC=/usr/include/racket + else + AC_MSG_RESULT(no) + vi_cv_path_mzscheme_pfx= + fi fi fi fi @@ -772,54 +780,95 @@ if test "$enable_mzschemeinterp" = "yes"; then fi if test "X$vi_cv_path_mzscheme_pfx" != "X"; then - if test "x$MACOSX" = "xyes"; then - MZSCHEME_LIBS="-framework Racket" - MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" - elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"; then - MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a" - MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" - elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket3m.a"; then - MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libracket3m.a" - MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" - elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket.a"; then - MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libracket.a ${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a" - elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme.a"; then - MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme.a ${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a" + + AC_MSG_CHECKING(for racket lib directory) + SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'` + if test "X$SCHEME_LIB" != "X"; then + AC_MSG_RESULT(${SCHEME_LIB}) else - dnl Using shared objects - if test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.so"; then - MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme3m" - MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" - elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket3m.so"; then - MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lracket3m" - MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" - elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket.so"; then - MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lracket -lmzgc" - else - MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme -lmzgc" + AC_MSG_RESULT(not found) + fi + + for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do + if test "X$path" != "X"; then + if test "x$MACOSX" = "xyes"; then + MZSCHEME_LIBS="-framework Racket" + MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" + elif test -f "${path}/libmzscheme3m.a"; then + MZSCHEME_LIBS="${path}/libmzscheme3m.a" + MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" + elif test -f "${path}/libracket3m.a"; then + MZSCHEME_LIBS="${path}/libracket3m.a" + MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" + elif test -f "${path}/libracket.a"; then + MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a" + elif test -f "${path}/libmzscheme.a"; then + MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a" + else + dnl Using shared objects + if test -f "${path}/libmzscheme3m.so"; then + MZSCHEME_LIBS="-L${path} -lmzscheme3m" + MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" + elif test -f "${path}/libracket3m.so"; then + MZSCHEME_LIBS="-L${path} -lracket3m" + MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" + elif test -f "${path}/libracket.so"; then + MZSCHEME_LIBS="-L${path} -lracket -lmzgc" + else + dnl try next until last + if test "$path" != "$SCHEME_LIB"; then + continue + fi + MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc" + fi + if test "$GCC" = yes; then + dnl Make Vim remember the path to the library. For when it's not in + dnl $LD_LIBRARY_PATH. + MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}" + elif test "`(uname) 2>/dev/null`" = SunOS && + uname -r | grep '^5' >/dev/null; then + MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}" + fi + fi fi - if test "$GCC" = yes; then - dnl Make Vim remember the path to the library. For when it's not in - dnl $LD_LIBRARY_PATH. - MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${vi_cv_path_mzscheme_pfx}/lib" - elif test "`(uname) 2>/dev/null`" = SunOS && - uname -r | grep '^5' >/dev/null; then - MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${vi_cv_path_mzscheme_pfx}/lib" + if test "X$MZSCHEME_LIBS" != "X"; then + break fi + done + + AC_MSG_CHECKING([if racket requires -pthread]) + if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then + AC_MSG_RESULT(yes) + MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread" + MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread" + else + AC_MSG_RESULT(no) fi - AC_MSG_CHECKING(for racket collects directory) - if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then - SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/ + AC_MSG_CHECKING(for racket config directory) + SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'` + if test "X$SCHEME_CONFIGDIR" != "X"; then + MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'" + AC_MSG_RESULT(${SCHEME_CONFIGDIR}) else - if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then - SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/ + AC_MSG_RESULT(not found) + fi + + AC_MSG_CHECKING(for racket collects directory) + SCHEME_COLLECTS=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-collects-dir))) (when (path? p) (let-values (((base _1 _2) (split-path p))) (display base))))'` + if test "X$SCHEME_COLLECTS" = "X"; then + if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then + SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/ else - if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then - SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/ + if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then + SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/ else - if test -d "$vi_cv_path_mzscheme_pfx/collects"; then - SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/ + if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then + SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/ + else + if test -d "$vi_cv_path_mzscheme_pfx/collects"; then + SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/ + fi fi fi fi @@ -851,7 +900,6 @@ if test "$enable_mzschemeinterp" = "yes"; then if test "X$MZSCHEME_EXTRA" != "X" ; then dnl need to generate bytecode for MzScheme base MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE" - MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc" AC_MSG_RESULT(needed) else AC_MSG_RESULT(not needed) diff --git a/src/if_mzsch.c b/src/if_mzsch.c index 287ab1a..4ddca0a 100644 --- a/src/if_mzsch.c +++ b/src/if_mzsch.c @@ -29,6 +29,25 @@ * depend". */ #if defined(FEAT_MZSCHEME) || defined(PROTO) +/* + * scheme_register_tls_space is only available on 32-bit Windows until racket-6.3. + * See http://docs.racket-lang.org/inside/im_memoryalloc.html?q=scheme_register_tls_space + */ +#if MZSCHEME_VERSION_MAJOR >= 500 && defined(WIN32) \ + && defined(USE_THREAD_LOCAL) \ + && (!defined(_WIN64) || MZSCHEME_VERSION_MAJOR >= 603) +# define HAVE_TLS_SPACE 1 +#endif + +/* + * Since version 4.x precise GC requires trampolined startup. + * Futures and places in version 5.x need it too. + */ +#if defined(MZ_PRECISE_GC) && MZSCHEME_VERSION_MAJOR >= 400 \ + || MZSCHEME_VERSION_MAJOR >= 500 && (defined(MZ_USE_FUTURES) || defined(MZ_USE_PLACES)) +# define TRAMPOLINED_MZVIM_STARTUP +#endif + /* Base data structures */ #define SCHEME_VIMBUFFERP(obj) SAME_TYPE(SCHEME_TYPE(obj), mz_buffer_type) #define SCHEME_VIMWINDOWP(obj) SAME_TYPE(SCHEME_TYPE(obj), mz_window_type) @@ -140,7 +159,7 @@ static int vim_error_check(void); static int do_mzscheme_command(exarg_T *, void *, Scheme_Closed_Prim *what); static void startup_mzscheme(void); static char *string_to_line(Scheme_Object *obj); -#if MZSCHEME_VERSION_MAJOR >= 500 +#if MZSCHEME_VERSION_MAJOR >= 501 # define OUTPUT_LEN_TYPE intptr_t #else # define OUTPUT_LEN_TYPE long @@ -237,7 +256,7 @@ static Scheme_Object *dll_scheme_true; static Scheme_Thread **dll_scheme_current_thread_ptr; static void (**dll_scheme_console_printf_ptr)(char *str, ...); -static void (**dll_scheme_console_output_ptr)(char *str, long len); +static void (**dll_scheme_console_output_ptr)(char *str, OUTPUT_LEN_TYPE len); static void (**dll_scheme_notify_multithread_ptr)(int on); static void *(*dll_GC_malloc)(size_t size_in_bytes); @@ -255,6 +274,7 @@ static Scheme_Object *(*dll_scheme_apply)(Scheme_Object *rator, int num_rands, static Scheme_Object *(*dll_scheme_builtin_value)(const char *name); # if MZSCHEME_VERSION_MAJOR >= 299 static Scheme_Object *(*dll_scheme_byte_string_to_char_string)(Scheme_Object *s); +static Scheme_Object *(*dll_scheme_make_path)(const char *chars); # endif static void (*dll_scheme_close_input_port)(Scheme_Object *port); static void (*dll_scheme_count_lines)(Scheme_Object *port); @@ -264,7 +284,7 @@ static Scheme_Object *(*dll_scheme_current_continuation_marks)(void); static Scheme_Object *(*dll_scheme_current_continuation_marks)(Scheme_Object *prompt_tag); #endif static void (*dll_scheme_display)(Scheme_Object *obj, Scheme_Object *port); -static char *(*dll_scheme_display_to_string)(Scheme_Object *obj, long *len); +static char *(*dll_scheme_display_to_string)(Scheme_Object *obj, OUTPUT_LEN_TYPE *len); static int (*dll_scheme_eq)(Scheme_Object *obj1, Scheme_Object *obj2); static Scheme_Object *(*dll_scheme_do_eval)(Scheme_Object *obj, int _num_rands, Scheme_Object **rands, int val); @@ -280,7 +300,7 @@ static char *(*dll_scheme_format)(char *format, int flen, int argc, Scheme_Object **argv, long *rlen); # else static char *(*dll_scheme_format_utf8)(char *format, int flen, int argc, - Scheme_Object **argv, long *rlen); + Scheme_Object **argv, OUTPUT_LEN_TYPE *rlen); static Scheme_Object *(*dll_scheme_get_param)(Scheme_Config *c, int pos); # endif static void (*dll_scheme_gc_ptr_ok)(void *p); @@ -289,7 +309,7 @@ static char *(*dll_scheme_get_sized_string_output)(Scheme_Object *, long *len); # else static char *(*dll_scheme_get_sized_byte_string_output)(Scheme_Object *, - long *len); + OUTPUT_LEN_TYPE *len); # endif static Scheme_Object *(*dll_scheme_intern_symbol)(const char *name); static Scheme_Object *(*dll_scheme_lookup_global)(Scheme_Object *symbol, @@ -354,10 +374,33 @@ static void (*dll_scheme_hash_set)(Scheme_Hash_Table *table, static Scheme_Object *(*dll_scheme_hash_get)(Scheme_Hash_Table *table, Scheme_Object *key); static Scheme_Object *(*dll_scheme_make_double)(double d); -# ifdef INCLUDE_MZSCHEME_BASE static Scheme_Object *(*dll_scheme_make_sized_byte_string)(char *chars, long len, int copy); static Scheme_Object *(*dll_scheme_namespace_require)(Scheme_Object *req); +# ifdef MZ_PRECISE_GC +static void *(*dll_GC_malloc_one_tagged)(size_t size_in_bytes); +static void (*dll_GC_register_traversers)(short tag, Size_Proc size, Mark_Proc mark, Fixup_Proc fixup, int is_constant_size, int is_atomic); +# endif +# if MZSCHEME_VERSION_MAJOR >= 400 +static void (*dll_scheme_init_collection_paths)(Scheme_Env *global_env, Scheme_Object *extra_dirs); +static void **(*dll_scheme_malloc_immobile_box)(void *p); +static void (*dll_scheme_free_immobile_box)(void **b); +# endif +# if MZSCHEME_VERSION_MAJOR >= 500 +# ifdef TRAMPOLINED_MZVIM_STARTUP +static int (*dll_scheme_main_setup)(int no_auto_statics, Scheme_Env_Main _main, int argc, char **argv); +# if defined(IMPLEMENT_THREAD_LOCAL_VIA_WIN_TLS) || MZSCHEME_VERSION_MAJOR >= 603 +static void (*dll_scheme_register_tls_space)(void *tls_space, int _tls_index); +# endif +# endif +# if defined(IMPLEMENT_THREAD_LOCAL_VIA_WIN_TLS) || defined(IMPLEMENT_THREAD_LOCAL_EXTERNALLY_VIA_PROC) +static Thread_Local_Variables *(*dll_scheme_external_get_thread_local_variables)(void); +# endif +# endif +# if MZSCHEME_VERSION_MAJOR >= 600 +static void (*dll_scheme_embedded_load)(intptr_t len, const char *s, int predefined); +static void (*dll_scheme_register_embedded_load)(intptr_t len, const char *s); +static void (*dll_scheme_set_config_path)(Scheme_Object *p); # endif /* arrays are imported directly */ @@ -368,7 +411,9 @@ static Scheme_Object *(*dll_scheme_namespace_require)(Scheme_Object *req); # define scheme_true dll_scheme_true /* pointers are GetProceAddress'ed as pointers to pointer */ -# define scheme_current_thread (*dll_scheme_current_thread_ptr) +#if !defined(USE_THREAD_LOCAL) && !defined(LINK_EXTENSIONS_BY_TABLE) +# define scheme_current_thread (*dll_scheme_current_thread_ptr) +# endif # define scheme_console_printf (*dll_scheme_console_printf_ptr) # define scheme_console_output (*dll_scheme_console_output_ptr) # define scheme_notify_multithread (*dll_scheme_notify_multithread_ptr) @@ -384,6 +429,7 @@ static Scheme_Object *(*dll_scheme_namespace_require)(Scheme_Object *req); # define scheme_builtin_value dll_scheme_builtin_value # if MZSCHEME_VERSION_MAJOR >= 299 # define scheme_byte_string_to_char_string dll_scheme_byte_string_to_char_string +# define scheme_make_path dll_scheme_make_path # endif # define scheme_check_threads dll_scheme_check_threads # define scheme_close_input_port dll_scheme_close_input_port @@ -455,9 +501,38 @@ static Scheme_Object *(*dll_scheme_namespace_require)(Scheme_Object *req); # define scheme_hash_set dll_scheme_hash_set # define scheme_hash_get dll_scheme_hash_get # define scheme_make_double dll_scheme_make_double -# ifdef INCLUDE_MZSCHEME_BASE -# define scheme_make_sized_byte_string dll_scheme_make_sized_byte_string -# define scheme_namespace_require dll_scheme_namespace_require +# define scheme_make_sized_byte_string dll_scheme_make_sized_byte_string +# define scheme_namespace_require dll_scheme_namespace_require +# ifdef MZ_PRECISE_GC +# define GC_malloc_one_tagged dll_GC_malloc_one_tagged +# define GC_register_traversers dll_GC_register_traversers +# endif +# if MZSCHEME_VERSION_MAJOR >= 400 +# ifdef TRAMPOLINED_MZVIM_STARTUP +# define scheme_main_setup dll_scheme_main_setup +# if defined(IMPLEMENT_THREAD_LOCAL_VIA_WIN_TLS) || MZSCHEME_VERSION_MAJOR >= 603 +# define scheme_register_tls_space dll_scheme_register_tls_space +# endif +# endif +# define scheme_init_collection_paths dll_scheme_init_collection_paths +# define scheme_malloc_immobile_box dll_scheme_malloc_immobile_box +# define scheme_free_immobile_box dll_scheme_free_immobile_box +# endif +# if MZSCHEME_VERSION_MAJOR >= 600 +# define scheme_embedded_load dll_scheme_embedded_load +# define scheme_register_embedded_load dll_scheme_register_embedded_load +# define scheme_set_config_path dll_scheme_set_config_path +# endif + +# if MZSCHEME_VERSION_MAJOR >= 500 +# if defined(IMPLEMENT_THREAD_LOCAL_VIA_WIN_TLS) || defined(IMPLEMENT_THREAD_LOCAL_EXTERNALLY_VIA_PROC) +/* define as function for macro in schshread.h */ +Thread_Local_Variables * +scheme_external_get_thread_local_variables(void) +{ + return dll_scheme_external_get_thread_local_variables(); +} +# endif # endif typedef struct @@ -477,7 +552,9 @@ static Thunk_Info mzsch_imports[] = { {"scheme_void", (void **)&dll_scheme_void}, {"scheme_null", (void **)&dll_scheme_null}, {"scheme_true", (void **)&dll_scheme_true}, +#if !defined(USE_THREAD_LOCAL) && !defined(LINK_EXTENSIONS_BY_TABLE) {"scheme_current_thread", (void **)&dll_scheme_current_thread_ptr}, +#endif {"scheme_console_printf", (void **)&dll_scheme_console_printf_ptr}, {"scheme_console_output", (void **)&dll_scheme_console_output_ptr}, {"scheme_notify_multithread", @@ -488,6 +565,7 @@ static Thunk_Info mzsch_imports[] = { {"scheme_basic_env", (void **)&dll_scheme_basic_env}, # if MZSCHEME_VERSION_MAJOR >= 299 {"scheme_byte_string_to_char_string", (void **)&dll_scheme_byte_string_to_char_string}, + {"scheme_make_path", (void **)&dll_scheme_make_path}, # endif {"scheme_builtin_value", (void **)&dll_scheme_builtin_value}, {"scheme_check_threads", (void **)&dll_scheme_check_threads}, @@ -564,10 +642,33 @@ static Thunk_Info mzsch_imports[] = { {"scheme_hash_set", (void **)&dll_scheme_hash_set}, {"scheme_hash_get", (void **)&dll_scheme_hash_get}, {"scheme_make_double", (void **)&dll_scheme_make_double}, -# ifdef INCLUDE_MZSCHEME_BASE {"scheme_make_sized_byte_string", (void **)&dll_scheme_make_sized_byte_string}, {"scheme_namespace_require", (void **)&dll_scheme_namespace_require}, -#endif +# ifdef MZ_PRECISE_GC + {"GC_malloc_one_tagged", (void **)&dll_GC_malloc_one_tagged}, + {"GC_register_traversers", (void **)&dll_GC_register_traversers}, +# endif +# if MZSCHEME_VERSION_MAJOR >= 400 +# ifdef TRAMPOLINED_MZVIM_STARTUP + {"scheme_main_setup", (void **)&dll_scheme_main_setup}, +# if defined(IMPLEMENT_THREAD_LOCAL_VIA_WIN_TLS) || MZSCHEME_VERSION_MAJOR >= 603 + {"scheme_register_tls_space", (void **)&dll_scheme_register_tls_space}, +# endif +# endif + {"scheme_init_collection_paths", (void **)&dll_scheme_init_collection_paths}, + {"scheme_malloc_immobile_box", (void **)&dll_scheme_malloc_immobile_box}, + {"scheme_free_immobile_box", (void **)&dll_scheme_free_immobile_box}, +# endif +# if MZSCHEME_VERSION_MAJOR >= 500 +# if defined(IMPLEMENT_THREAD_LOCAL_VIA_WIN_TLS) || defined(IMPLEMENT_THREAD_LOCAL_EXTERNALLY_VIA_PROC) + {"scheme_external_get_thread_local_variables", (void **)&dll_scheme_external_get_thread_local_variables}, +# endif +# endif +# if MZSCHEME_VERSION_MAJOR >= 600 + {"scheme_embedded_load", (void **)&dll_scheme_embedded_load}, + {"scheme_register_embedded_load", (void **)&dll_scheme_register_embedded_load}, + {"scheme_set_config_path", (void **)&dll_scheme_set_config_path}, +# endif {NULL, NULL}}; static HINSTANCE hMzGC = 0; @@ -687,8 +788,6 @@ guaranteed_byte_string_arg(char *proc, int num, int argc, Scheme_Object **argv) /* need to put it here for dynamic stuff to work */ #if defined(INCLUDE_MZSCHEME_BASE) # include "mzscheme_base.c" -#elif MZSCHEME_VERSION_MAJOR >= 400 -# error MzScheme >=4 must include mzscheme_base.c, for MinGW32 you need to define MZSCHEME_GENERATE_BASE=yes #endif /* @@ -701,6 +800,9 @@ static Scheme_Type mz_buffer_type; static Scheme_Type mz_window_type; static int initialized = FALSE; +#ifdef DYNAMIC_MZSCHEME +static int disabled = FALSE; +#endif /* global environment */ static Scheme_Env *environment = NULL; @@ -851,31 +953,24 @@ mzscheme_end(void) #endif } -/* - * scheme_register_tls_space is only available on 32-bit Windows. - * See http://docs.racket-lang.org/inside/im_memoryalloc.html?q=scheme_register_tls_space - */ -#if MZSCHEME_VERSION_MAJOR >= 500 && defined(WIN32) \ - && defined(USE_THREAD_LOCAL) && !defined(_WIN64) -# define HAVE_TLS_SPACE 1 +#if HAVE_TLS_SPACE static __declspec(thread) void *tls_space; #endif -/* - * Since version 4.x precise GC requires trampolined startup. - * Futures and places in version 5.x need it too. - */ -#if defined(MZ_PRECISE_GC) && MZSCHEME_VERSION_MAJOR >= 400 \ - || MZSCHEME_VERSION_MAJOR >= 500 && (defined(MZ_USE_FUTURES) || defined(MZ_USE_PLACES)) -# ifdef DYNAMIC_MZSCHEME -# error Precise GC v.4+ or Racket with futures/places do not support dynamic MzScheme -# endif -# define TRAMPOLINED_MZVIM_STARTUP -#endif - int mzscheme_main(int argc, char** argv) { +#ifdef DYNAMIC_MZSCHEME + /* + * Racket requires trampolined startup. We can not load it later. + * If dynamic dll loading is failed, disable it. + */ + if (!mzscheme_enabled(FALSE)) + { + disabled = TRUE; + return vim_main2(argc, argv); + } +#endif #ifdef HAVE_TLS_SPACE scheme_register_tls_space(&tls_space, 0); #endif @@ -942,87 +1037,45 @@ startup_mzscheme(void) MZ_GC_CHECK(); #ifdef INCLUDE_MZSCHEME_BASE - { - /* - * versions 4.x do not provide Scheme bindings by default - * we need to add them explicitly - */ - Scheme_Object *scheme_base_symbol = NULL; - MZ_GC_DECL_REG(1); - MZ_GC_VAR_IN_REG(0, scheme_base_symbol); - MZ_GC_REG(); - /* invoke function from generated and included mzscheme_base.c */ - declare_modules(environment); - scheme_base_symbol = scheme_intern_symbol("scheme/base"); - MZ_GC_CHECK(); - scheme_namespace_require(scheme_base_symbol); - MZ_GC_CHECK(); - MZ_GC_UNREG(); - } + /* invoke function from generated and included mzscheme_base.c */ + declare_modules(environment); #endif - register_vim_exn(); - /* use new environment to initialise exception handling */ - init_exn_catching_apply(); - - /* redirect output */ - scheme_console_output = do_output; - scheme_console_printf = do_printf; -#ifdef MZSCHEME_COLLECTS /* setup 'current-library-collection-paths' parameter */ # if MZSCHEME_VERSION_MAJOR >= 299 -# ifdef MACOS { - Scheme_Object *coll_byte_string = NULL; - Scheme_Object *coll_char_string = NULL; - Scheme_Object *coll_path = NULL; - - MZ_GC_DECL_REG(3); - MZ_GC_VAR_IN_REG(0, coll_byte_string); - MZ_GC_VAR_IN_REG(1, coll_char_string); - MZ_GC_VAR_IN_REG(2, coll_path); - MZ_GC_REG(); - coll_byte_string = scheme_make_byte_string(MZSCHEME_COLLECTS); - MZ_GC_CHECK(); - coll_char_string = scheme_byte_string_to_char_string(coll_byte_string); - MZ_GC_CHECK(); - coll_path = scheme_char_string_to_path(coll_char_string); - MZ_GC_CHECK(); - scheme_set_collects_path(coll_path); - MZ_GC_CHECK(); - MZ_GC_UNREG(); - } -# else - { - Scheme_Object *coll_byte_string = NULL; - Scheme_Object *coll_char_string = NULL; - Scheme_Object *coll_path = NULL; - Scheme_Object *coll_pair = NULL; - Scheme_Config *config = NULL; + Scheme_Object *coll_path = NULL; + int mustfree = FALSE; + char_u *s; - MZ_GC_DECL_REG(5); - MZ_GC_VAR_IN_REG(0, coll_byte_string); - MZ_GC_VAR_IN_REG(1, coll_char_string); - MZ_GC_VAR_IN_REG(2, coll_path); - MZ_GC_VAR_IN_REG(3, coll_pair); - MZ_GC_VAR_IN_REG(4, config); + MZ_GC_DECL_REG(1); + MZ_GC_VAR_IN_REG(0, coll_path); MZ_GC_REG(); - coll_byte_string = scheme_make_byte_string(MZSCHEME_COLLECTS); - MZ_GC_CHECK(); - coll_char_string = scheme_byte_string_to_char_string(coll_byte_string); - MZ_GC_CHECK(); - coll_path = scheme_char_string_to_path(coll_char_string); - MZ_GC_CHECK(); - coll_pair = scheme_make_pair(coll_path, scheme_null); - MZ_GC_CHECK(); - config = scheme_current_config(); - MZ_GC_CHECK(); - scheme_set_param(config, MZCONFIG_COLLECTION_PATHS, coll_pair); - MZ_GC_CHECK(); + /* workaround for dynamic loading on windows */ + s = vim_getenv("PLTCOLLECTS", &mustfree); + if (s != NULL) + { + coll_path = scheme_make_path(s); + MZ_GC_CHECK(); + if (mustfree) + vim_free(s); + } +# ifdef MZSCHEME_COLLECTS + if (coll_path == NULL) + { + coll_path = scheme_make_path(MZSCHEME_COLLECTS); + MZ_GC_CHECK(); + } +# endif + if (coll_path != NULL) + { + scheme_set_collects_path(coll_path); + MZ_GC_CHECK(); + } MZ_GC_UNREG(); } -# endif # else +# ifdef MZSCHEME_COLLECTS { Scheme_Object *coll_string = NULL; Scheme_Object *coll_pair = NULL; @@ -1045,6 +1098,70 @@ startup_mzscheme(void) } # endif #endif + +# if MZSCHEME_VERSION_MAJOR >= 600 + { + Scheme_Object *config_path = NULL; + int mustfree = FALSE; + char_u *s; + + MZ_GC_DECL_REG(1); + MZ_GC_VAR_IN_REG(0, config_path); + MZ_GC_REG(); + /* workaround for dynamic loading on windows */ + s = vim_getenv("PLTCONFIGDIR", &mustfree); + if (s != NULL) + { + config_path = scheme_make_path(s); + MZ_GC_CHECK(); + if (mustfree) + vim_free(s); + } +#ifdef MZSCHEME_CONFIGDIR + if (config_path == NULL) + { + config_path = scheme_make_path(MZSCHEME_CONFIGDIR); + MZ_GC_CHECK(); + } +#endif + if (config_path != NULL) + { + scheme_set_config_path(config_path); + MZ_GC_CHECK(); + } + MZ_GC_UNREG(); + } +# endif + +#if MZSCHEME_VERSION_MAJOR >= 400 + scheme_init_collection_paths(environment, scheme_null); +#endif + + /* + * versions 4.x do not provide Scheme bindings by default + * we need to add them explicitly + */ + { + Scheme_Object *scheme_base_symbol = NULL; + + MZ_GC_DECL_REG(1); + MZ_GC_VAR_IN_REG(0, scheme_base_symbol); + MZ_GC_REG(); + scheme_base_symbol = scheme_intern_symbol("scheme/base"); + MZ_GC_CHECK(); + scheme_namespace_require(scheme_base_symbol); + MZ_GC_CHECK(); + MZ_GC_UNREG(); + } + + register_vim_exn(); + /* use new environment to initialise exception handling */ + init_exn_catching_apply(); + + /* redirect output */ + scheme_console_output = do_output; + scheme_console_printf = do_printf; + #ifdef HAVE_SANDBOX { Scheme_Object *make_security_guard = NULL; @@ -1130,7 +1247,7 @@ mzscheme_init(void) if (!initialized) { #ifdef DYNAMIC_MZSCHEME - if (!mzscheme_enabled(TRUE)) + if (disabled || !mzscheme_enabled(TRUE)) { EMSG(_("E815: Sorry, this command is disabled, the MzScheme libraries could not be loaded.")); return -1;