Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 gcl (2.6.7+dfsga-22) unstable; urgency=high
 .
   * fix stack definition issues on i386
Author: Camm Maguire <camm@debian.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: http://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- gcl-2.6.7+dfsga.orig/h/unrandomize.h
+++ gcl-2.6.7+dfsga/h/unrandomize.h
@@ -23,6 +23,7 @@
 	int i;
 	char **n,**a;
 	for (i=0;envp[i];i++);
+	cs_org=(void *)&flag;/*get right stack for potential gc in malloc*/
 	n=malloc((i+2)*sizeof(*n));
 	n[i+1]=0;
 	n[i--]="GCL_UNRANDOMIZE=t";
--- gcl-2.6.7+dfsga.orig/o/main.c
+++ gcl-2.6.7+dfsga/o/main.c
@@ -124,8 +124,22 @@ cstack_dir(fixnum j) {
 }
 
 fixnum log_maxpage_bound=sizeof(fixnum)*8-1;
-#define mbrk(x_) ({void *_c=sbrk(0);_c==sbrk(x_-_c) ? 0 : -1;})
-
+inline int
+mbrk(void *v) {
+  ufixnum uv=(ufixnum)v,uc=(ufixnum)sbrk(0),ux,um;
+  fixnum m=((1UL<<(sizeof(fixnum)*8-1))-1);
+  if (uv<uc) {
+    um=uv;
+    ux=uc;
+  } else {
+    um=uc;
+    ux=uv;
+  }
+  if (((fixnum)(ux-um))<0)
+    return mbrk((void *)uc+(uv<uc ? -m : m)) || mbrk(v);
+  return uc==(ufixnum)sbrk(uv-uc) ? 0 : -1;
+}
+    
 int
 update_real_maxpage(void) {
 
--- gcl-2.6.7+dfsga.orig/o/gbc.c
+++ gcl-2.6.7+dfsga/o/gbc.c
@@ -529,7 +529,7 @@ mark_object(object x) {
       mark_object(x->sm.sm_object1);
       if (saving_system)
 	{FILE *fp = x->sm.sm_fp;
-	if (fp != 0 && fp != stdin && fp !=stdout
+	if (fp != 0 /* && fp != stdin && fp !=stdout */
 	    )
 	  {fclose(fp);
 	  x->sm.sm_fp=0;
