summaryrefslogtreecommitdiffstats
path: root/source/ap/vim/patches/7.3.441
blob: 9a7539b5a725064629d3ec9d2377002c7bed347f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
To: vim_dev@googlegroups.com
Subject: Patch 7.3.441
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.3.441
Problem:    Newer versions of MzScheme (Racket) require earlier (trampolined)
            initialisation.
Solution:   Call mzscheme_main() early in main(). (Sergey Khorev)
Files:      src/Make_mvc.mak, src/if_mzsch.c, src/main.c,
            src/proto/if_mzsch.pro
    

*** ../vim-7.3.440/src/Make_mvc.mak	2011-09-14 19:01:38.000000000 +0200
--- src/Make_mvc.mak	2012-02-12 01:46:05.000000000 +0100
***************
*** 740,745 ****
--- 740,747 ----
  !endif
  !endif
  MZSCHEME_OBJ = $(OUTDIR)\if_mzsch.obj
+ # increase stack size
+ MZSCHEME_LIB = $(MZSCHEME_LIB) /STACK:8388608
  !endif
  
  # Perl interface
*** ../vim-7.3.440/src/if_mzsch.c	2010-11-03 21:59:23.000000000 +0100
--- src/if_mzsch.c	2012-02-12 01:47:31.000000000 +0100
***************
*** 31,38 ****
   * 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)
--- 31,36 ----
***************
*** 559,575 ****
      hMzSch = vimLoadLib(sch_dll);
      hMzGC = vimLoadLib(gc_dll);
  
!     if (!hMzSch)
      {
  	if (verbose)
! 	    EMSG2(_(e_loadlib), sch_dll);
  	return FAIL;
      }
  
!     if (!hMzGC)
      {
  	if (verbose)
! 	    EMSG2(_(e_loadlib), gc_dll);
  	return FAIL;
      }
  
--- 557,573 ----
      hMzSch = vimLoadLib(sch_dll);
      hMzGC = vimLoadLib(gc_dll);
  
!     if (!hMzGC)
      {
  	if (verbose)
! 	    EMSG2(_(e_loadlib), gc_dll);
  	return FAIL;
      }
  
!     if (!hMzSch)
      {
  	if (verbose)
! 	    EMSG2(_(e_loadlib), sch_dll);
  	return FAIL;
      }
  
***************
*** 798,862 ****
  static __declspec(thread) void *tls_space;
  #endif
  
!     void
! mzscheme_main(void)
  {
  #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);
  #else
!     mzscheme_env_main(NULL, 0, NULL);
  #endif
  }
  
      static int
! mzscheme_env_main(Scheme_Env *env, int argc UNUSED, char **argv UNUSED)
  {
!     /* 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
!      */
      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
!     main_loop(FALSE, FALSE);
! #if defined(MZ_PRECISE_GC) && MZSCHEME_VERSION_MAJOR < 400
      /* releasing dummy */
      MZ_GC_REG();
      MZ_GC_UNREG();
  #endif
!     return 0;
  }
  
      static void
  startup_mzscheme(void)
  {
! #if !defined(MZ_PRECISE_GC) || MZSCHEME_VERSION_MAJOR < 400
      scheme_set_stack_base(stack_base, 1);
  #endif
  
--- 796,863 ----
  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)
  {
  #if MZSCHEME_VERSION_MAJOR >= 500 && defined(WIN32) && defined(USE_THREAD_LOCAL)
      scheme_register_tls_space(&tls_space, 0);
  #endif
! #ifdef TRAMPOLINED_MZVIM_STARTUP
!     return scheme_main_setup(TRUE, mzscheme_env_main, argc, argv);
  #else
!     return mzscheme_env_main(NULL, argc, argv);
  #endif
  }
  
      static int
! mzscheme_env_main(Scheme_Env *env, int argc, char **argv)
  {
!     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
      int dummy = 0;
      stack_base = (void *)&dummy;
+ # endif
  #endif
! 
!     /* 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 vim_main_result;
  }
  
      static void
  startup_mzscheme(void)
  {
! #ifndef TRAMPOLINED_MZVIM_STARTUP
      scheme_set_stack_base(stack_base, 1);
  #endif
  
***************
*** 868,874 ****
      MZ_REGISTER_STATIC(exn_message);
      MZ_REGISTER_STATIC(vim_exn);
  
! #if !defined(MZ_PRECISE_GC) || MZSCHEME_VERSION_MAJOR < 400
      /* in newer versions of precise GC the initial env has been created */
      environment = scheme_basic_env();
  #endif
--- 869,875 ----
      MZ_REGISTER_STATIC(exn_message);
      MZ_REGISTER_STATIC(vim_exn);
  
! #ifndef TRAMPOLINED_MZVIM_STARTUP
      /* in newer versions of precise GC the initial env has been created */
      environment = scheme_basic_env();
  #endif
***************
*** 3013,3019 ****
  	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();
  
--- 3014,3019 ----
*** ../vim-7.3.440/src/main.c	2011-12-08 15:57:54.000000000 +0100
--- src/main.c	2012-02-12 01:49:50.000000000 +0100
***************
*** 554,559 ****
--- 554,584 ----
      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,970 ****
  
      /*
       * 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;
  }
--- 982,989 ----
  
      /*
       * Call the main command loop.  This never returns.
!     */
      main_loop(FALSE, FALSE);
  
      return 0;
  }
*** ../vim-7.3.440/src/proto/if_mzsch.pro	2010-08-15 21:57:28.000000000 +0200
--- src/proto/if_mzsch.pro	2012-02-12 01:50:57.000000000 +0100
***************
*** 14,19 ****
  void mzvim_reset_timer __ARGS((void));
  void *mzvim_eval_string __ARGS((char_u *str));
  int mzthreads_allowed __ARGS((void));
! void mzscheme_main __ARGS((void));
  void do_mzeval __ARGS((char_u *str, typval_T *rettv));
  /* vim: set ft=c : */
--- 14,20 ----
  void mzvim_reset_timer __ARGS((void));
  void *mzvim_eval_string __ARGS((char_u *str));
  int mzthreads_allowed __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 : */
*** ../vim-7.3.440/src/version.c	2012-02-12 01:35:06.000000000 +0100
--- src/version.c	2012-02-12 01:54:14.000000000 +0100
***************
*** 716,717 ****
--- 716,719 ----
  {   /* Add new patch number below this line */
+ /**/
+     441,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
43. You tell the kids they can't use the computer because "Daddy's got work to
    do" and you don't even have a job.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///