summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2012-02-12 01:55:55 +0100
committerBram Moolenaar <Bram@vim.org>2012-02-12 01:55:55 +0100
commitbbc98db7c45ed9c8a6bbc7e2ac7c67180ccbab16 (patch)
tree8066ae85f9917e7b16f69beff79c630176fb7d40
parentefcb54b78cfc4f396531cdac6af37e183bc9ee53 (diff)
updated for version 7.3.441v7.3.441
Problem: Newer versions of MzScheme (Racket) require earlier (trampolined) initialisation. Solution: Call mzscheme_main() early in main(). (Sergey Khorev)
-rw-r--r--src/Make_mvc.mak2
-rw-r--r--src/if_mzsch.c78
-rw-r--r--src/main.c33
-rw-r--r--src/proto/if_mzsch.pro3
-rw-r--r--src/version.c2
5 files changed, 71 insertions, 47 deletions
diff --git a/src/Make_mvc.mak b/src/Make_mvc.mak
index b103bdd8c4..c6a8e3158b 100644
--- a/src/Make_mvc.mak
+++ b/src/Make_mvc.mak
@@ -740,6 +740,8 @@ MZSCHEME_LIB = $(MZSCHEME)\lib\msvc\libmzgc$(MZSCHEME_VER).lib \
!endif
!endif
MZSCHEME_OBJ = $(OUTDIR)\if_mzsch.obj
+# increase stack size
+MZSCHEME_LIB = $(MZSCHEME_LIB) /STACK:8388608
!endif
# Perl interface
diff --git a/src/if_mzsch.c b/src/if_mzsch.c
index 65873c9139..86e96bd335 100644
--- a/src/if_mzsch.c
+++ b/src/if_mzsch.c
@@ -31,8 +31,6 @@
* depend". */
#if defined(FEAT_MZSCHEME) || defined(PROTO)
-#include <assert.h>
-
/* 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)
@@ -559,17 +557,17 @@ mzscheme_runtime_link_init(char *sch_dll, char *gc_dll, int verbose)
hMzSch = vimLoadLib(sch_dll);
hMzGC = vimLoadLib(gc_dll);
- if (!hMzSch)
+ if (!hMzGC)
{
if (verbose)
- EMSG2(_(e_loadlib), sch_dll);
+ EMSG2(_(e_loadlib), gc_dll);
return FAIL;
}
- if (!hMzGC)
+ if (!hMzSch)
{
if (verbose)
- EMSG2(_(e_loadlib), gc_dll);
+ EMSG2(_(e_loadlib), sch_dll);
return FAIL;
}
@@ -798,65 +796,68 @@ mzscheme_end(void)
static __declspec(thread) void *tls_space;
#endif
- void
-mzscheme_main(void)
+/*
+ * 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)
{
#if MZSCHEME_VERSION_MAJOR >= 500 && defined(WIN32) && defined(USE_THREAD_LOCAL)
scheme_register_tls_space(&tls_space, 0);
#endif
-#if defined(MZ_PRECISE_GC) && MZSCHEME_VERSION_MAJOR >= 400
- /* use trampoline for precise GC in MzScheme >= 4.x */
- scheme_main_setup(TRUE, mzscheme_env_main, 0, NULL);
+#ifdef TRAMPOLINED_MZVIM_STARTUP
+ return scheme_main_setup(TRUE, mzscheme_env_main, argc, argv);
#else
- mzscheme_env_main(NULL, 0, NULL);
+ return mzscheme_env_main(NULL, argc, argv);
#endif
}
static int
-mzscheme_env_main(Scheme_Env *env, int argc UNUSED, char **argv UNUSED)
+mzscheme_env_main(Scheme_Env *env, int argc, char **argv)
{
- /* neither argument nor return values are used */
-#ifdef MZ_PRECISE_GC
-# if MZSCHEME_VERSION_MAJOR < 400
- /*
- * Starting from version 4.x, embedding applications must use
- * scheme_main_setup/scheme_main_stack_setup trampolines
- * rather than setting stack base directly with scheme_set_stack_base
- */
+ int vim_main_result;
+#ifdef TRAMPOLINED_MZVIM_STARTUP
+ /* Scheme has created the environment for us */
+ environment = env;
+#else
+# ifdef MZ_PRECISE_GC
Scheme_Object *dummy = NULL;
MZ_GC_DECL_REG(1);
MZ_GC_VAR_IN_REG(0, dummy);
stack_base = &__gc_var_stack__;
# else
- /* environment has been created by us by Scheme */
- environment = env;
-# endif
- /*
- * In 4.x, all activities must be performed inside trampoline
- * so we are forced to initialise GC immediately
- * This can be postponed in 3.x but I see no point in implementing
- * a feature which will work in older versions only.
- * One would better use conservative GC if he needs dynamic MzScheme
- */
- mzscheme_init();
-#else
int dummy = 0;
stack_base = (void *)&dummy;
+# endif
#endif
- main_loop(FALSE, FALSE);
-#if defined(MZ_PRECISE_GC) && MZSCHEME_VERSION_MAJOR < 400
+
+ /* mzscheme_main is called as a trampoline from main.
+ * We trampoline into vim_main2
+ * Passing argc, argv through from mzscheme_main
+ */
+ vim_main_result = vim_main2(argc, argv);
+#if !defined(TRAMPOLINED_MZVIM_STARTUP) && defined(MZ_PRECISE_GC)
/* releasing dummy */
MZ_GC_REG();
MZ_GC_UNREG();
#endif
- return 0;
+ return vim_main_result;
}
static void
startup_mzscheme(void)
{
-#if !defined(MZ_PRECISE_GC) || MZSCHEME_VERSION_MAJOR < 400
+#ifndef TRAMPOLINED_MZVIM_STARTUP
scheme_set_stack_base(stack_base, 1);
#endif
@@ -868,7 +869,7 @@ startup_mzscheme(void)
MZ_REGISTER_STATIC(exn_message);
MZ_REGISTER_STATIC(vim_exn);
-#if !defined(MZ_PRECISE_GC) || MZSCHEME_VERSION_MAJOR < 400
+#ifndef TRAMPOLINED_MZVIM_STARTUP
/* in newer versions of precise GC the initial env has been created */
environment = scheme_basic_env();
#endif
@@ -3013,7 +3014,6 @@ register_vim_exn(void)
MZ_GC_REG();
tmp = scheme_make_struct_names(exn_name, scheme_null, 0, &nc);
- assert(nc <= 5);
mch_memmove(exn_names, tmp, nc * sizeof(Scheme_Object *));
MZ_GC_CHECK();
diff --git a/src/main.c b/src/main.c
index d1702fe570..d9f8df4b45 100644
--- a/src/main.c
+++ b/src/main.c
@@ -554,6 +554,31 @@ main
debug_break_level = params.use_debug_break_level;
#endif
+#ifdef FEAT_MZSCHEME
+ /*
+ * Newer version of MzScheme (Racket) require earlier (trampolined)
+ * initialisation via scheme_main_setup.
+ * Implement this by initialising it as early as possible
+ * and splitting off remaining Vim main into vim_main2
+ */
+ {
+ /* Pack up preprocessed command line arguments.
+ * It is safe because Scheme does not access argc/argv. */
+ char *args[2];
+ args[0] = (char *)fname;
+ args[1] = (char *)&params;
+ return mzscheme_main(2, args);
+ }
+}
+
+int vim_main2(int argc, char **argv)
+{
+ char_u *fname = (char_u *)argv[0];
+ mparm_T params;
+
+ memcpy(&params, argv[1], sizeof(params));
+#endif
+
/* Execute --cmd arguments. */
exe_pre_commands(&params);
@@ -957,14 +982,8 @@ main
/*
* Call the main command loop. This never returns.
- * For embedded MzScheme the main_loop will be called by Scheme
- * for proper stack tracking
- */
-#ifndef FEAT_MZSCHEME
+ */
main_loop(FALSE, FALSE);
-#else
- mzscheme_main();
-#endif
return 0;
}
diff --git a/src/proto/if_mzsch.pro b/src/proto/if_mzsch.pro
index 60e99bdff4..d1180bfa1e 100644
--- a/src/proto/if_mzsch.pro
+++ b/src/proto/if_mzsch.pro
@@ -14,6 +14,7 @@ void mzvim_check_threads __ARGS((void));
void mzvim_reset_timer __ARGS((void));
void *mzvim_eval_string __ARGS((char_u *str));
int mzthreads_allowed __ARGS((void));
-void mzscheme_main __ARGS((void));
+int mzscheme_main __ARGS((int argc, char **argv));
void do_mzeval __ARGS((char_u *str, typval_T *rettv));
+int vim_main2 __ARGS((int argc, char **argv));
/* vim: set ft=c : */
diff --git a/src/version.c b/src/version.c
index 2519664468..9285e438ae 100644
--- a/src/version.c
+++ b/src/version.c
@@ -715,6 +715,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 441,
+/**/
440,
/**/
439,