~ubuntu-branches/ubuntu/utopic/gcl/utopic

« back to all changes in this revision

Viewing changes to debian/patches/dummy-writable_malloc-in-tkMain.c

  • Committer: Package Import Robot
  • Author(s): Camm Maguire
  • Date: 2014-04-21 14:09:37 UTC
  • mfrom: (13.1.109 sid)
  • Revision ID: package-import@ubuntu.com-20140421140937-dlz68m10fzssuhbv
Tags: 2.6.10-8
2.6.11preĀ testĀ 7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Description: <short summary of the patch>
 
2
 TODO: Put a short summary on the line above and replace this paragraph
 
3
 with a longer explanation of this change. Complete the meta-information
 
4
 with other relevant fields (see below for details). To make it easier, the
 
5
 information below has been extracted from the changelog. Adjust it or drop
 
6
 it.
 
7
 .
 
8
 gcl (2.6.10-5) unstable; urgency=high
 
9
 .
 
10
   * 2.6.11pre test 4
 
11
Author: Camm Maguire <camm@debian.org>
 
12
 
 
13
---
 
14
The information above should follow the Patch Tagging Guidelines, please
 
15
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
 
16
are templates for supplementary fields that you might want to add:
 
17
 
 
18
Origin: <vendor|upstream|other>, <url of original patch>
 
19
Bug: <url in upstream bugtracker>
 
20
Bug-Debian: http://bugs.debian.org/<bugnumber>
 
21
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
 
22
Forwarded: <no|not-needed|url proving that it has been forwarded>
 
23
Reviewed-By: <name and email of someone who approved the patch>
 
24
Last-Update: <YYYY-MM-DD>
 
25
 
 
26
--- gcl-2.6.10.orig/configure
 
27
+++ gcl-2.6.10/configure
 
28
@@ -8428,6 +8428,16 @@ fi
 
29
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
30
 
 
31
 
 
32
+for ac_func in sigaltstack
 
33
+do :
 
34
+  ac_fn_c_check_func "$LINENO" "sigaltstack" "ac_cv_func_sigaltstack"
 
35
+if test "x$ac_cv_func_sigaltstack" = xyes; then :
 
36
+  cat >>confdefs.h <<_ACEOF
 
37
+#define HAVE_SIGALTSTACK 1
 
38
+_ACEOF
 
39
+
 
40
+fi
 
41
+done
 
42
 
 
43
 
 
44
 #if test $use = "386-linux" ; then
 
45
--- gcl-2.6.10.orig/configure.in
 
46
+++ gcl-2.6.10/configure.in
 
47
@@ -2410,8 +2410,7 @@ int joe=SIGEMT;
 
48
  AC_MSG_RESULT(yes)],
 
49
 AC_MSG_RESULT(no))
 
50
 
 
51
-
 
52
-
 
53
+AC_CHECK_FUNCS(sigaltstack)
 
54
 
 
55
 #if test $use = "386-linux" ; then
 
56
        AC_CHECK_HEADERS(asm/sigcontext.h)
 
57
--- gcl-2.6.10.orig/gcl-tk/tkMain.c
 
58
+++ gcl-2.6.10/gcl-tk/tkMain.c
 
59
@@ -55,6 +55,8 @@
 
60
 #include <signal.h>
 
61
 #include <errno.h>
 
62
 
 
63
+int writable_malloc=0; /*FIXME, don't wrap fopen here, exclude notcomp.h or equivalent */
 
64
+
 
65
 #include "guis.h"
 
66
 struct connection_state *dsfd;
 
67
 /*-------------------------------------------------------------------*/
 
68
--- gcl-2.6.10.orig/h/386-bsd.h
 
69
+++ gcl-2.6.10/h/386-bsd.h
 
70
@@ -50,9 +50,6 @@
 
71
 #endif
 
72
 /* end listen for input */
 
73
 
 
74
-/* we dont need to worry about zeroing fp->_base , to prevent  */
 
75
-#define FCLOSE_SETBUF_OK 
 
76
-
 
77
 #define DATA_BEGIN (char *)N_DATADDR(header);
 
78
 #define UNIXSAVE "unexlin.c"
 
79
 
 
80
@@ -81,10 +78,6 @@
 
81
 #define DONT_NEED_MALLOC
 
82
 #endif
 
83
 
 
84
-#define INSTALL_SEGMENTATION_CATCHER \
 
85
-        (void) signal(SIGSEGV,segmentation_catcher); \
 
86
-        (void) signal(SIGBUS,segmentation_catcher)
 
87
-
 
88
 /* Begin for cmpinclude */
 
89
 
 
90
 #define WANT_SGC
 
91
--- gcl-2.6.10.orig/h/386-macosx.h
 
92
+++ gcl-2.6.10/h/386-macosx.h
 
93
@@ -113,18 +113,6 @@ extern int seek_to_end_ofile (FILE *);
 
94
 /* Copied from {Net,Free,Open}BSD.h  */
 
95
 /* Modified according to Camm's instructions on April 15, 2004.  */
 
96
 #define HAVE_SIGPROCMASK
 
97
-/* #define SIG_STACK_SIZE (SIGSTKSZ/sizeof(double)) */
 
98
-#define SETUP_SIG_STACK                                \
 
99
-{                                                      \
 
100
-static stack_t estack;                                 \
 
101
-static double estack_buf [SIG_STACK_SIZE];             \
 
102
-bzero(estack_buf, sizeof(estack_buf));                 \
 
103
-estack.ss_sp = (char *) &estack_buf[SIG_STACK_SIZE-1]; \
 
104
-estack.ss_flags = 0;                                   \
 
105
-estack.ss_size = SIGSTKSZ;                             \
 
106
-if (sigaltstack(&estack, 0) < 0)                       \
 
107
-    perror("sigaltstack");                             \
 
108
-}
 
109
 
 
110
 /* until the sgc/save problem can be fixed.  20050114 CM*/
 
111
 /* #define SGC */
 
112
@@ -141,10 +129,6 @@ do {
 
113
   sigaction (SIGSEGV, &sact, 0);                        \
 
114
 } while (0);
 
115
 
 
116
-#define INSTALL_SEGMENTATION_CATCHER                \
 
117
-  (void) signal (SIGSEGV, segmentation_catcher);    \
 
118
-  (void) signal (SIGBUS, segmentation_catcher)
 
119
-
 
120
 /* si_addr not containing the faulting address is a bug in Darwin.
 
121
    Work around this by looking at the dar field of the exception state.  */
 
122
 #define GET_FAULT_ADDR(sig,code,sv,a) ((siginfo_t *)code)->si_addr
 
123
@@ -190,9 +174,6 @@ do {int c=0;
 
124
         return(FALSE);                                                  \
 
125
 } while (0)
 
126
 
 
127
-/* We (hopefully) dont need to worry about zeroing fp->_base.  */
 
128
-#define FCLOSE_SETBUF_OK 
 
129
-
 
130
 #define GET_FULL_PATH_SELF(a_)                              \
 
131
 do {                                                        \
 
132
 extern int _NSGetExecutablePath (char *, unsigned long *);  \
 
133
--- gcl-2.6.10.orig/h/FreeBSD.h
 
134
+++ gcl-2.6.10/h/FreeBSD.h
 
135
@@ -79,23 +79,6 @@ do {                                                         \
 
136
 #define HAVE_SIGPROCMASK
 
137
 #define SIG_STACK_SIZE (SIGSTKSZ/sizeof(double))
 
138
 
 
139
-#undef SETUP_SIG_STACK
 
140
-#define SETUP_SIG_STACK {                                      \
 
141
-       static struct sigaltstack estack;                       \
 
142
-       if (estack.ss_sp == NULL &&                             \
 
143
-           (estack.ss_sp = malloc(SIGSTKSZ)) == NULL)          \
 
144
-               perror("malloc");                               \
 
145
-       estack.ss_size = SIGSTKSZ;                              \
 
146
-       estack.ss_flags = 0;                                    \
 
147
-       if (sigaltstack(&estack, 0) < 0)                        \
 
148
-               perror("sigaltstack");                          \
 
149
-}
 
150
-
 
151
-#undef INSTALL_SEGMENTATION_CATCHER
 
152
-#define INSTALL_SEGMENTATION_CATCHER                           \
 
153
-        (void) gcl_signal(SIGSEGV, segmentation_catcher);      \
 
154
-        (void) gcl_signal(SIGBUS, segmentation_catcher)
 
155
-
 
156
 /*
 
157
  * The next two defines are for SGC,
 
158
  *     one of which needs to go in cmpinclude.h.
 
159
--- gcl-2.6.10.orig/h/NetBSD.h
 
160
+++ gcl-2.6.10/h/NetBSD.h
 
161
@@ -76,18 +76,6 @@
 
162
 
 
163
 /* end stuff for dumping and reloading */
 
164
 
 
165
-/* begin setup alternate signal stack */
 
166
-#define SIG_STACK_SIZE SIGSTKSZ
 
167
-#define SETUP_SIG_STACK \
 
168
-{ static struct sigaltstack estack ; \
 
169
-  estack.ss_size = sizeof(estack_buf) ; \
 
170
-  estack.ss_flags = 0; \
 
171
-  estack.ss_base = (char *) &estack_buf[SIG_STACK_SIZE-1]; \
 
172
-  if (sigaltstack(&estack, (struct sigaltstack *)0) < 0) \
 
173
-               perror("sigaltstack");} \
 
174
-
 
175
-/* end setup signal stack  */
 
176
-
 
177
 #define HZ             60
 
178
 
 
179
 /* begin  for GC */
 
180
@@ -114,13 +102,3 @@
 
181
        fflush(save);
 
182
 
 
183
 /* end read header */
 
184
-
 
185
-#define INSTALL_SEGMENTATION_CATCHER \
 
186
-        (void) signal(SIGSEGV,segmentation_catcher); \
 
187
-        (void) signal(SIGBUS,segmentation_catcher)
 
188
-
 
189
-
 
190
-
 
191
-
 
192
-
 
193
-
 
194
--- gcl-2.6.10.orig/h/OpenBSD.h
 
195
+++ gcl-2.6.10/h/OpenBSD.h
 
196
@@ -19,9 +19,6 @@
 
197
 #define I386
 
198
 #define        IEEEFLOAT
 
199
 
 
200
-/* we don't need to worry about zeroing fp->_base, to prevent what??? */
 
201
-#define FCLOSE_SETBUF_OK 
 
202
-
 
203
 /* #undef HAVE_XDR */
 
204
 
 
205
 #define USE_ATT_TIME
 
206
@@ -59,21 +56,6 @@
 
207
 #define PAGEWIDTH 12           /* i386 sees 4096 byte pages */
 
208
 /* end for GC */
 
209
 
 
210
-#define SIG_STACK_SIZE (SIGSTKSZ/sizeof(double))
 
211
-#define SETUP_SIG_STACK \
 
212
-{ \
 
213
-       static struct sigaltstack estack; \
 
214
-       estack.ss_sp = estack_buf; \
 
215
-       estack.ss_size = SIGSTKSZ; \
 
216
-       estack.ss_flags = 0; \
 
217
-       if (sigaltstack(&estack, 0) < 0) \
 
218
-         perror("sigaltstack"); \
 
219
-}
 
220
-
 
221
-#define INSTALL_SEGMENTATION_CATCHER \
 
222
-        (void) gcl_signal(SIGSEGV, segmentation_catcher); \
 
223
-        (void) gcl_signal(SIGBUS, segmentation_catcher)
 
224
-
 
225
 /*
 
226
  * The next two defines are for SGC,
 
227
  *     one of which needs to go in cmpinclude.h.
 
228
--- gcl-2.6.10.orig/h/gclincl.h.in
 
229
+++ gcl-2.6.10/h/gclincl.h.in
 
230
@@ -180,6 +180,9 @@
 
231
 /* have setenv call */
 
232
 #undef HAVE_SETENV
 
233
 
 
234
+/* Define to 1 if you have the `sigaltstack' function. */
 
235
+#undef HAVE_SIGALTSTACK
 
236
+
 
237
 /* have sigcontext */
 
238
 #undef HAVE_SIGCONTEXT
 
239
 
 
240
--- gcl-2.6.10.orig/h/gnuwin95.h
 
241
+++ gcl-2.6.10/h/gnuwin95.h
 
242
@@ -50,7 +50,6 @@ extern DBEGIN_TY _dbegin;
 
243
 
 
244
 #define HAVE_SIGACTION
 
245
 /* a noop */
 
246
-#define SETUP_SIG_STACK
 
247
 #define SA_ONSTACK 0
 
248
 
 
249
 #define brk(x) printf("not doing break\n");
 
250
@@ -82,8 +81,6 @@ extern DBEGIN_TY _dbegin;
 
251
        ungetc(i, fp); \
 
252
     } while (0)
 
253
                
 
254
-#define FCLOSE_SETBUF_OK 
 
255
-
 
256
 #define RUN_PROCESS
 
257
 
 
258
 #define        IEEEFLOAT
 
259
--- gcl-2.6.10.orig/h/hp300-bsd.h
 
260
+++ gcl-2.6.10/h/hp300-bsd.h
 
261
@@ -47,13 +47,6 @@
 
262
  */
 
263
 #define GET_FAULT_ADDR(sig,code,sv,a) ((char *) code)
 
264
 
 
265
-#define INSTALL_SEGMENTATION_CATCHER \
 
266
-        (void) signal(SIGSEGV,segmentation_catcher); \
 
267
-        (void) signal(SIGBUS,segmentation_catcher)
 
268
-
 
269
-
 
270
-
 
271
-
 
272
 /* Begin for cmpinclude */
 
273
 
 
274
 
 
275
--- gcl-2.6.10.orig/h/linux.h
 
276
+++ gcl-2.6.10/h/linux.h
 
277
@@ -79,8 +79,6 @@ do {static struct sigaction action; \
 
278
 
 
279
 #undef HAVE_SIGVEC
 
280
 #define HAVE_SIGACTION
 
281
-/* make this a noop */
 
282
-/* #define SETUP_SIG_STACK */
 
283
 #ifndef HAVE_SV_ONSTACK
 
284
 #define SV_ONSTACK 0
 
285
 #endif
 
286
@@ -109,9 +107,6 @@ do { int c = 0; \
 
287
      && (ioctl((fp)->_fileno, FIONREAD, &c),c<=0)) \
 
288
      return 0;} while (0)
 
289
 
 
290
-/* we dont need to worry about zeroing fp->_base , to prevent  */
 
291
-#define FCLOSE_SETBUF_OK 
 
292
-
 
293
 /* #define DATA_BEGIN((TXTRELOC+header.a_text+(SEGSIZ-1)) & ~(SEGSIZ-1)); */
 
294
 #define DATA_BEGIN (char *)(char *)N_DATADDR(header);
 
295
 
 
296
@@ -123,11 +118,6 @@ do { int c = 0; \
 
297
 #define GETPATHNAME
 
298
 #define PATHNAME_CACHE 10
 
299
 
 
300
-
 
301
-#define INSTALL_SEGMENTATION_CATCHER \
 
302
-        (void) gcl_signal(SIGSEGV,segmentation_catcher)
 
303
-
 
304
-
 
305
 /* get the fileno of a FILE* */
 
306
 #define FILENO(x) fileno(x)
 
307
 
 
308
--- gcl-2.6.10.orig/h/mingw.h
 
309
+++ gcl-2.6.10/h/mingw.h
 
310
@@ -95,7 +95,6 @@ extern DBEGIN_TY _stacktop, _stackbottom
 
311
 #define NEED_TO_REINSTALL_SIGNALS
 
312
 
 
313
 /*#define HAVE_SIGACTION*/
 
314
-#define SETUP_SIG_STACK
 
315
 #define SV_ONSTACK 0
 
316
 #define SA_RESTART 0
 
317
 
 
318
@@ -141,7 +140,6 @@ extern DBEGIN_TY _stacktop, _stackbottom
 
319
         ungetc(i, fp); \
 
320
     } while (0)
 
321
                
 
322
-#define FCLOSE_SETBUF_OK 
 
323
 #define        IEEEFLOAT
 
324
 #define I386
 
325
 
 
326
--- gcl-2.6.10.orig/h/notcomp.h
 
327
+++ gcl-2.6.10/h/notcomp.h
 
328
@@ -284,3 +284,7 @@ gcl_init_cmp_anon(void);
 
329
 #include "gmp_wrappers.h"
 
330
 
 
331
 #define massert(a_) if (!(a_)) assert_error(#a_,__LINE__,__FILE__,__FUNCTION__)
 
332
+
 
333
+extern bool writable_malloc;
 
334
+#define writable_malloc_wrap(f_,rt_,a_...) ({rt_ v;bool w=writable_malloc;writable_malloc=1;v=f_(a_);writable_malloc=w;v;})
 
335
+#define fopen(a_,b_) writable_malloc_wrap(fopen,FILE *,a_,b_)
 
336
--- gcl-2.6.10.orig/h/powerpc-macosx.h
 
337
+++ gcl-2.6.10/h/powerpc-macosx.h
 
338
@@ -98,18 +98,6 @@ do {
 
339
 /* Copied from {Net,Free,Open}BSD.h  */
 
340
 /* Modified according to Camm's instructions on April 15, 2004.  */
 
341
 #define HAVE_SIGPROCMASK
 
342
-/* #define SIG_STACK_SIZE (SIGSTKSZ/sizeof(double)) */
 
343
-#define SETUP_SIG_STACK                                \
 
344
-{                                                      \
 
345
-static struct sigaltstack estack;                      \
 
346
-static double estack_buf [SIG_STACK_SIZE];             \
 
347
-bzero(estack_buf, sizeof(estack_buf));                 \
 
348
-estack.ss_sp = (char *) &estack_buf[SIG_STACK_SIZE-1]; \
 
349
-estack.ss_flags = 0;                                   \
 
350
-estack.ss_size = SIGSTKSZ;                             \
 
351
-if (sigaltstack(&estack, 0) < 0)                       \
 
352
-    perror("sigaltstack");                             \
 
353
-}
 
354
 
 
355
 /* until the sgc/save problem can be fixed.  20050114 CM*/
 
356
 /* #define SGC */
 
357
@@ -126,10 +114,6 @@ do {
 
358
   sigaction (SIGSEGV, &sact, 0);                        \
 
359
 } while (0);
 
360
 
 
361
-#define INSTALL_SEGMENTATION_CATCHER                \
 
362
-  (void) signal (SIGSEGV, segmentation_catcher);    \
 
363
-  (void) signal (SIGBUS, segmentation_catcher)
 
364
-
 
365
 /* si_addr not containing the faulting address is a bug in Darwin.
 
366
    Work around this by looking at the dar field of the exception state.  */
 
367
 #define GET_FAULT_ADDR(sig,code,scp,addr) ((char *) (((ucontext_t *) scp)->uc_mcontext->es.dar))
 
368
@@ -174,9 +158,6 @@ do {int c=0;
 
369
         return(FALSE);                                                  \
 
370
 } while (0)
 
371
 
 
372
-/* We (hopefully) dont need to worry about zeroing fp->_base.  */
 
373
-#define FCLOSE_SETBUF_OK 
 
374
-
 
375
 #define GET_FULL_PATH_SELF(a_)                              \
 
376
 do {                                                        \
 
377
 extern int _NSGetExecutablePath (char *, unsigned long *);  \
 
378
--- gcl-2.6.10.orig/h/protoize.h
 
379
+++ gcl-2.6.10/h/protoize.h
 
380
@@ -1899,3 +1899,7 @@ object
 
381
 number_dpb(object,object,object);
 
382
 object
 
383
 number_dpf(object,object,object);
 
384
+
 
385
+#if defined(DARWIN)
 
386
+void init_darwin_zone_compat ();
 
387
+#endif
 
388
--- gcl-2.6.10.orig/h/rios-aix3.h
 
389
+++ gcl-2.6.10/h/rios-aix3.h
 
390
@@ -225,11 +225,6 @@ for the kernel.   See aix3_mprotect dire
 
391
 #undef VSSIZE
 
392
 #define VSSIZE 81520
 
393
 
 
394
-
 
395
-#define INSTALL_SEGMENTATION_CATCHER \
 
396
-        sigstack(&estack,0); \
 
397
-        (void) gcl_signal(SIGSEGV,segmentation_catcher);
 
398
-
 
399
 #if defined(IN_SOCKETS) || defined(IN_GUIS)
 
400
 #include <sys/select.h>
 
401
 #undef bzero
 
402
--- gcl-2.6.10.orig/h/rios.h
 
403
+++ gcl-2.6.10/h/rios.h
 
404
@@ -235,10 +235,6 @@ for the kernel.   See aix3_mprotect dire
 
405
 #define VSSIZE 81520
 
406
 
 
407
 
 
408
-#define INSTALL_SEGMENTATION_CATCHER \
 
409
-        sigstack(&estack,0); \
 
410
-        (void) gcl_signal(SIGSEGV,segmentation_catcher);
 
411
-
 
412
 #if defined(IN_SOCKETS) || defined(IN_GUIS)
 
413
 #include <sys/select.h>
 
414
 #undef bzero
 
415
--- gcl-2.6.10.orig/h/sun4.h
 
416
+++ gcl-2.6.10/h/sun4.h
 
417
@@ -22,14 +22,6 @@
 
418
 #define GET_FAULT_ADDR(sig,code,scp,addr) \
 
419
   (code ? ((siginfo_t *)code )->si_addr : error("no address info"))
 
420
 
 
421
-#define SETUP_SIG_STACK \
 
422
-{ static stack_t estack ; \
 
423
-  estack.ss_size = sizeof(estack_buf) ; \
 
424
-  estack.ss_flags = 0; \
 
425
-  estack.ss_sp = (char *) &estack_buf[SIG_STACK_SIZE-1]; \
 
426
-  if (sigaltstack(&estack, (stack_t *)0) < 0) \
 
427
-               perror("sigaltstack");} \
 
428
-  
 
429
 #undef HAVE_AOUT
 
430
 #define HAVE_AOUT <elf.h>
 
431
 #define HAVE_ELF
 
432
--- gcl-2.6.10.orig/o/alloc.c
 
433
+++ gcl-2.6.10/o/alloc.c
 
434
@@ -1063,33 +1063,27 @@ gcl_init_alloc(void *cs_start) {
 
435
   cs_limit = cs_org + CSTACK_DIRECTION*cssize;
 
436
 
 
437
 #ifdef __ia64__
 
438
-    {
 
439
-      extern void * __libc_ia64_register_backing_store_base;
 
440
-      cs_org2=cs_base2=__libc_ia64_register_backing_store_base;
 
441
-    }
 
442
+  {
 
443
+    extern void * __libc_ia64_register_backing_store_base;
 
444
+    cs_org2=cs_base2=__libc_ia64_register_backing_store_base;
 
445
+  }
 
446
 #endif
 
447
-
 
448
-#ifdef SETUP_SIG_STACK
 
449
-  SETUP_SIG_STACK
 
450
-#else
 
451
-#if defined(HAVE_SIGACTION) || defined(HAVE_SIGVEC)
 
452
-    {
 
453
-      /* make sure the stack is 8 byte aligned */
 
454
-      static double estack_buf[32*SIGSTKSZ];
 
455
-      static struct sigaltstack estack;
 
456
-      
 
457
-      bzero(estack_buf,sizeof(estack_buf));
 
458
-      estack.ss_sp = estack_buf;
 
459
-      estack.ss_flags = 0;                                   
 
460
-      estack.ss_size = sizeof(estack_buf);                             
 
461
-      massert(sigaltstack(&estack, 0)>=0);
 
462
-      
 
463
-    }
 
464
-#endif 
 
465
+  
 
466
+#ifdef HAVE_SIGALTSTACK
 
467
+  {
 
468
+    /* make sure the stack is 8 byte aligned */
 
469
+    static double estack_buf[32*SIGSTKSZ];
 
470
+    static stack_t estack;
 
471
+    
 
472
+    estack.ss_sp = estack_buf;
 
473
+    estack.ss_flags = 0;                                   
 
474
+    estack.ss_size = sizeof(estack_buf);                             
 
475
+    massert(sigaltstack(&estack, 0)>=0);
 
476
+  }
 
477
 #endif 
 
478
-
 
479
+  
 
480
   install_segmentation_catcher();
 
481
-
 
482
+  
 
483
 #ifdef SGC
 
484
 
 
485
   massert(getpagesize()<=PAGESIZE);
 
486
@@ -1592,6 +1586,8 @@ static char *baby_malloc(n)
 
487
 /*  } */
 
488
 /*  #endif */
 
489
 
 
490
+bool writable_malloc=0;
 
491
+
 
492
 void *
 
493
 malloc(size_t size) {
 
494
 
 
495
@@ -1609,7 +1605,8 @@ malloc(size_t size) {
 
496
   malloc_list = make_cons(Cnil, malloc_list);
 
497
   malloc_list->c.c_car = alloc_simple_string(size);
 
498
   malloc_list->c.c_car->st.st_self = alloc_contblock(size);
 
499
-  
 
500
+  malloc_list->c.c_car->st.st_adjustable=writable_malloc;
 
501
+
 
502
   /* FIXME: this is just to handle clean freeing of the
 
503
      monstartup memory allocated automatically on raw image
 
504
      startup.  In saved images, monstartup memory is only
 
505
--- gcl-2.6.10.orig/o/file.d
 
506
+++ gcl-2.6.10/o/file.d
 
507
@@ -309,34 +309,27 @@ BEGIN:
 
508
 
 
509
 void
 
510
 setup_stream_buffer(object x) {
 
511
-#ifndef NO_SETBUF
 
512
-  char *buf=alloc_contblock(BUFSIZ);
 
513
-  x->sm.sm_buffer = buf;
 
514
-  setbuf(x->sm.sm_fp, buf);
 
515
+#ifdef NO_SETBUF
 
516
+  massert(!setvbuf(x->sm.sm_fp,x->sm.sm_buffer=NULL,_IONBF,0));
 
517
 #else
 
518
-  setvbuf(x->sm.sm_fp,NULL,_IONBF,0);
 
519
-  x->sm.sm_buffer=0;
 
520
+  massert(!setvbuf(x->sm.sm_fp,x->sm.sm_buffer=writable_malloc_wrap(malloc,void *,BUFSIZ),_IOFBF,BUFSIZ));
 
521
 #endif
 
522
 }      
 
523
 
 
524
 static void
 
525
 deallocate_stream_buffer(object strm) {
 
526
 
 
527
+  if (strm->sm.sm_buffer==NULL)
 
528
+    return;
 
529
+
 
530
 /* SGC contblock pages: Its possible this is on an old page CM 20030827 */
 
531
-  if (strm->sm.sm_buffer) {
 
532
 #ifdef SGC
 
533
-    insert_maybe_sgc_contblock(strm->sm.sm_buffer, BUFSIZ); 
 
534
+  insert_maybe_sgc_contblock(strm->sm.sm_buffer,BUFSIZ); 
 
535
 #else
 
536
-    insert_contblock(strm->sm.sm_buffer, BUFSIZ); 
 
537
+  insert_contblock(strm->sm.sm_buffer,BUFSIZ); 
 
538
 #endif
 
539
-    if (strm->sm.sm_fp)
 
540
-      setvbuf(strm->sm.sm_fp,NULL,_IONBF,0);
 
541
-    strm->sm.sm_buffer = 0;
 
542
-  } 
 
543
 
 
544
-#ifndef FCLOSE_SETBUF_OK
 
545
-  strm->sm.sm_fp->_base = NULL;
 
546
-#endif
 
547
+  massert(!setvbuf(strm->sm.sm_fp,strm->sm.sm_buffer=NULL,_IONBF,0));
 
548
 
 
549
 }
 
550
 
 
551
--- gcl-2.6.10.orig/o/main.c
 
552
+++ gcl-2.6.10/o/main.c
 
553
@@ -105,15 +105,6 @@ int sgc_enabled;
 
554
 #endif
 
555
 void install_segmentation_catcher(void);
 
556
 
 
557
-#ifndef SIG_STACK_SIZE
 
558
-#define SIG_STACK_SIZE 1000
 
559
-#endif
 
560
-#ifndef SETUP_SIG_STACK
 
561
-#if defined(HAVE_SIGACTION) || defined(HAVE_SIGVEC)
 
562
-        struct sigstack estack;
 
563
-#endif
 
564
-#endif
 
565
-
 
566
 int
 
567
 cstack_dir(fixnum j) {
 
568
   static fixnum n;
 
569
@@ -362,13 +353,8 @@ main(int argc, char **argv, char **envp)
 
570
 /* catch certain signals */
 
571
 void install_segmentation_catcher(void)
 
572
 {
 
573
-#ifdef INSTALL_SEGMENTATION_CATCHER
 
574
-  INSTALL_SEGMENTATION_CATCHER;
 
575
-#else
 
576
-#ifdef SIGSEGV
 
577
-       (void) gcl_signal(SIGSEGV,segmentation_catcher);
 
578
-#endif
 
579
-#endif
 
580
+  (void) gcl_signal(SIGSEGV,segmentation_catcher);
 
581
+  (void) gcl_signal(SIGBUS,segmentation_catcher);
 
582
 }
 
583
 
 
584
 int catch_fatal=1;
 
585
@@ -585,13 +571,6 @@ ihs_overflow(void) {
 
586
 
 
587
 void
 
588
 segmentation_catcher(int i) {
 
589
-#ifndef SIG_STACK_SIZE 
 
590
-  int x;
 
591
-  if (&x < cs_limit)
 
592
-    cs_overflow();
 
593
-  else 
 
594
-    printf("Segmentation violation: c stack ok:signalling error");
 
595
-#endif
 
596
   error("Segmentation violation.");
 
597
 }
 
598
 
 
599
--- gcl-2.6.10.orig/o/sfaslcoff.c
 
600
+++ gcl-2.6.10/o/sfaslcoff.c
 
601
@@ -59,7 +59,8 @@ struct reloc {
 
602
 } __attribute__ ((packed));
 
603
 #define R_ABS         0x0000  /* absolute, no relocation is necessary */
 
604
 #define R_DIR32       0x0006  /* Direct 32-bit reference to the symbols virtual address */
 
605
-#define R_PCRLONG     0x0014  /* 32-bit reference pc relative  to the symbols virtual address */
 
606
+#define R_SECREL32    0x000B  /* Currently ignored, used only for debugging strings FIXME */
 
607
+#define R_PCRLONG     0x0014  /* 32-bit reference pc relative to the symbols virtual address */
 
608
 
 
609
 struct syment {
 
610
   union {
 
611
@@ -113,6 +114,7 @@ relocate(struct scnhdr *sec,struct reloc
 
612
   switch(rel->r_type) {
 
613
 
 
614
   case R_ABS:
 
615
+  case R_SECREL32:
 
616
     break;
 
617
 
 
618
   case R_DIR32:
 
619
--- gcl-2.6.10.orig/o/sgbc.c
 
620
+++ gcl-2.6.10/o/sgbc.c
 
621
@@ -415,7 +415,7 @@ sgc_mark_object1(object x) {
 
622
       sgc_mark_object(x->sm.sm_object1);
 
623
       if (saving_system) {
 
624
        FILE *fp = x->sm.sm_fp;
 
625
-       if (fp != 0 && fp != stdin && fp !=stdout) {
 
626
+       if (fp != 0 /* && fp != stdin && fp !=stdout */) {
 
627
          fclose(fp);
 
628
          x->sm.sm_fp=0;
 
629
        }
 
630
@@ -1309,19 +1309,6 @@ sgc_start(void) {
 
631
        SET_WRITABLE(page(pi));
 
632
       else
 
633
        tm_of(pi->type)->tm_alt_npage++;
 
634
-#ifndef NO_SETBUF /*FIXME, implement restartable getc with read in readc_stream*/
 
635
-      {
 
636
-       void *v,*ve;
 
637
-       if (pi->type!=(tm=tm_of(t_stream))->tm_type) continue;
 
638
-       for (v=pagetochar(page(pi)),ve=v+tm->tm_nppage*tm->tm_size;v<ve;v+=tm->tm_size) {
 
639
-         object x=v;
 
640
-         if (type_of(x)!=t_stream || is_free(x)) continue;
 
641
-         if (x->sm.sm_buffer) 
 
642
-           for (i=page(x->sm.sm_buffer);i<=page(x->sm.sm_buffer+BUFSIZ-1);i++)
 
643
-             SET_WRITABLE(i);
 
644
-       }
 
645
-      }
 
646
-#endif
 
647
     }
 
648
     for (pi=contblock_list_head;pi;pi=pi->next)/*FIXME*/
 
649
       if (pi->sgc_flags&SGC_WRITABLE)
 
650
@@ -1329,14 +1316,16 @@ sgc_start(void) {
 
651
          SET_WRITABLE(page(pi)+i);
 
652
       else
 
653
        tm_of(t_contiguous)->tm_alt_npage+=pi->in_use;
 
654
-#ifdef GCL_GPROF
 
655
     {
 
656
-      extern object gprof_array;
 
657
-      if (gprof_array!=Cnil)
 
658
-       for (i=0;i<(gprof_array->st.st_fillp +PAGESIZE-1)/PAGESIZE;i++)
 
659
-         SET_WRITABLE(page(gprof_array->st.st_self)+i);
 
660
+      extern object malloc_list;
 
661
+      object x;
 
662
+
 
663
+      for (x=malloc_list;x!=Cnil;x=x->c.c_cdr)
 
664
+       if (x->c.c_car->st.st_adjustable)
 
665
+         for (i=page(x->c.c_car->st.st_self);i<=page(x->c.c_car->st.st_self+x->c.c_car->st.st_fillp-1);i++)
 
666
+           SET_WRITABLE(i);
 
667
     }
 
668
-#endif
 
669
+
 
670
     for (i=page(heap_end);i<page(old_rb_start);i++)
 
671
        SET_WRITABLE(i);
 
672
     tm_of(t_relocatable)->tm_alt_npage=page(rb_start)-page(old_rb_start);
 
673
--- gcl-2.6.10.orig/o/unixsave.c
 
674
+++ gcl-2.6.10/o/unixsave.c
 
675
@@ -140,33 +140,19 @@ char *original_file, *save_file;
 
676
 
 
677
 extern void _cleanup();
 
678
 
 
679
-LFD(Lsave)()
 
680
-{
 
681
-       char filename[256];
 
682
-
 
683
-       check_arg(1);
 
684
-       check_type_or_pathname_string_symbol_stream(&vs_base[0]);
 
685
-       coerce_to_filename(vs_base[0], filename);
 
686
-
 
687
-       _cleanup();
 
688
-/*
 
689
-       {
 
690
-               FILE *p;
 
691
-               int nfile;
 
692
-
 
693
-
 
694
-               nfile = NUMBER_OPEN_FILES;
 
695
-
 
696
-               for (p = &_iob[3];  p < &_iob[nfile];  p++)
 
697
-                       fclose(p);
 
698
-       }
 
699
-*/
 
700
-       memory_save(kcl_self, filename);
 
701
-/*
 
702
-       _exit(0);
 
703
-*/
 
704
-       exit(0);
 
705
-       /*  no return  */
 
706
+LFD(Lsave)() {
 
707
+  char filename[256];
 
708
+  
 
709
+  check_arg(1);
 
710
+  check_type_or_pathname_string_symbol_stream(&vs_base[0]);
 
711
+  coerce_to_filename(vs_base[0], filename);
 
712
+  malloc_list=Cnil;
 
713
+  
 
714
+  _cleanup();
 
715
+  
 
716
+  memory_save(kcl_self, filename);
 
717
+  exit(0);
 
718
+  /*  no return  */
 
719
 }
 
720
 
 
721
 #endif /* UNIXSAVE include */