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-16) unstable; urgency=high
 .
   * no linker script on hurd;fix OBJ_ALIGN
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/object.h
+++ gcl-2.6.7+dfsga/h/object.h
@@ -170,23 +170,11 @@ struct fixnum_struct {
 
 
 #define type_of(x)       ({register object _z=(object)(x);\
-                           _z==Cnil ? t_symbol : \
                            (is_imm_fixnum(_z) ? t_fixnum : \
-                           (valid_cdr(_z) ?  t_cons  : _z->d.t));})
-
-/* #define type_of(x)       ({register object _z=(object)(x);\ */
-/*       _z==Cnil ? t_symbol : is_imm_fixnum(_z) ? t_fixnum : _z->d.t;}) */
+			    (valid_cdr(_z) ?  (_z==Cnil ? t_symbol : t_cons)  : _z->d.t));})
   
 #define set_type_of(x,y) ({object _x=(object)(x);enum type _y=(y);_x->d.f=0;if (_y!=t_cons) {_x->d.e=1;_x->d.t=_y;}})
 
-/* ({register object _z=(object)(x);			   \ */
-/*   _z==Cnil ? t_symbol :					   \ */
-/*     (is_imm_fixnum(_z) ? t_fixnum :					\ */
-/*      (valid_cdr(_z) ?  t_cons  : _z->d.t));}) */
-
-/* #define consp(x) (type_of(x)==t_cons) */
-/* #define listp(x) ({register object _z=x;_z==Cnil || type_of(x)==t_cons;}) */
-/* #define atom(x)  !consp(x) */
 
 #define consp(x)         ({register object _z=(object)(x);\
                            (_z!=Cnil && !is_imm_fixnum(_z) && valid_cdr(_z));})
@@ -355,6 +343,14 @@ struct package {
 EXTER struct package *pack_pointer;	/*  package pointer  */
 
 #define Scdr(a_) ({union lispunion _t={.vw=(a_)->c.c_cdr};unmark(&_t);_t.vw;})
+/* #define pageinfo(x) ((struct pageinfo *)(((ufixnum)x)&(-PAGESIZE))) */
+/* #define make_cons(a_,b_) ({struct typemanager *tm=tm_table+t_cons;\ */
+/*                            object _x=tm->tm_free;\ */
+/* 			   _x==OBJNULL ? make_cons1(a_,b_) : \ */
+/* 			     ({tm->tm_free=OBJ_LINK(_x);\ */
+/* 			       tm->tm_nfree--;\ */
+/* 			       _x->c.c_car=a_;_x->c.c_cdr=b_;pageinfo(_x)->in_use++;_x;});}) */
+
 struct cons {
   /* FIRSTWORD; */
   object	c_cdr;		/*  cdr  */
@@ -876,7 +872,6 @@ struct typemanager {
 	object	tm_free;	/*  free list  */
 				/*  Note that it is of type object.  */
 	long	tm_nfree;	/*  number of free elements  */
-	long	tm_nused;	/*  number of elements used  */
 	long	tm_npage;	/*  number of pages  */
 	long	tm_maxpage;	/*  maximum number of pages  */
 	char	*tm_name;	/*  type name  */
@@ -1153,30 +1148,6 @@ EXTER unsigned plong signals_allowed, si
 EXTER struct symbol Dotnil_body;
 #define Dotnil ((object)&Dotnil_body)
 
-/* #define	endp(x)	({\ */
-/*       static union lispunion s_my_dot={.c={1,0,0,0,t_cons,0,0,0,Dotnil,Dotnil}}; \ */
-/*     object _x=(x);\ */
-/*     bool _b=FALSE;\ */
-/*     \ */
-/*     if (type_of(_x)==t_cons) {\ */
-/*        if (type_of(_x->c.c_cdr)!=t_cons && _x->c.c_cdr!=Cnil)\ */
-/*           s_my_dot.c.c_car=_x->c.c_cdr;\ */
-/*        else \ */
-/*           s_my_dot.c.c_car=Dotnil;\ */
-/*     } else {\ */
-/*        if (_x==s_my_dot.c.c_car)\ */
-/* 	 x=&s_my_dot;\ */
-/*        else {\ */
-/*          s_my_dot.c.c_car=Dotnil;\ */
-/*          if (_x==Cnil || _x==Dotnil)\ */
-/*              _b=TRUE;\ */
-/*          else\ */
-/*              FEwrong_type_argument(sLlist, _x);\ */
-/*        }\ */
-/*     }\ */
-/*     _b;\ */
-/*     }) */
-
 #define endp_prop(a) (consp(a) ? FALSE : ((a)==Cnil ? TRUE : (FEwrong_type_argument(sLlist, (a)),FALSE)))
 #define endp(a) endp_prop(a)
     
--- gcl-2.6.7+dfsga.orig/h/page.h
+++ gcl-2.6.7+dfsga/h/page.h
@@ -5,7 +5,8 @@
 #ifndef page
 #define page(p)	(((unsigned long)(p))>>PAGEWIDTH)
 #define	pagetochar(x)	((char *)((((unsigned long)x) << PAGEWIDTH) + sizeof(struct pageinfo)))
-#define pageinfo(x) ((struct pageinfo *)((((ufixnum)x)>>PAGEWIDTH)<<PAGEWIDTH))
+/* #define pageinfo(x) ((struct pageinfo *)((((ufixnum)x)>>PAGEWIDTH)<<PAGEWIDTH)) */
+#define pageinfo(x) ((struct pageinfo *)(((ufixnum)x)&(-PAGESIZE)))
 #define pagetoinfo(x) ((struct pageinfo *)((((ufixnum)x)<<PAGEWIDTH)))
 #endif
   
--- gcl-2.6.7+dfsga.orig/h/att_ext.h
+++ gcl-2.6.7+dfsga/h/att_ext.h
@@ -66,8 +66,8 @@ object big_plus();
 object big_times();
 object normalize_big_to_object();
 double big_to_double();
-EXTER  struct bignum big_fixnum1_body,big_fixnum2_body;
-EXTER object big_fixnum1,big_fixnum2;
+EXTER  struct bignum big_fixnum1_body,big_fixnum2_body,big_fixnum3_body,big_fixnum4_body;
+EXTER object big_fixnum1,big_fixnum2,big_fixnum3,big_fixnum4;
 object maybe_replace_big();
 
 
--- gcl-2.6.7+dfsga.orig/lsp/gcl_sharp.lsp
+++ gcl-2.6.7+dfsga/lsp/gcl_sharp.lsp
@@ -12,27 +12,31 @@
     (let ((v (context-vec *sharp-eq-context*)))
       (if (< i (length v)) (aref v i)
 	(let ((h (context-hash *sharp-eq-context*)))
-	  (when h (values (gethash i h))))))))
+	  (when h (gethash1 i h)))))))
 
 (defun push-context (i)
   (declare (fixnum i))
   (unless *sharp-eq-context* (setq *sharp-eq-context* (make-context)))
   (let* ((v (context-vec *sharp-eq-context*))(l (length v))(x (cons nil nil)))
-    (cond ((< i l) (error))
+    (cond ((< i l) (error "#~s= multiply defined" i))
 	  ((= i l) (vector-push-extend x v (1+ l)) x)
 	  ((let ((h (context-hash *sharp-eq-context*)))
-	     (if h (when (gethash i h) (error)) 
+	     (if h (when (gethash1 i h) (error "#~s= multiply defined" i)) 
 	       (setf (context-hash *sharp-eq-context*) (setq h (make-hash-table :test 'eql :rehash-size 2.0))))
 	     (setf (gethash i h) x))))))
 
+(defconstant +nil-proxy+ (cons nil nil))
+
 (defun sharp-eq-reader (stream subchar i &aux (x (push-context i)))
   (declare (ignore subchar)(fixnum i))
-  (prog1 (setf (car x) (read stream t 'eof t))
-    (when (eq (car x) (cdr x)) (error))))
+  (let ((y (read stream t 'eof t)))
+    (when (when y (eq y (cdr x))) (error "#= circularly defined"))
+    (setf (car x) (or y +nil-proxy+))
+    y))
 
 (defun sharp-sharp-reader (stream subchar i &aux (x (get-context i)))
   (declare (ignore stream subchar)(fixnum i))
-  (unless x (error))
+  (unless x (error "#~s# without preceding #~s=" i i))
   (or (cdr x) (let ((s (alloc-spice))) (setf (gethash s (context-spice *sharp-eq-context*)) x (cdr x) s))))
 
 (defun patch-sharp (x) 
@@ -50,7 +54,10 @@
       (dotimes (i (structure-length x) x)
 	(declare (fixnum i))
 	(structure-set x d i (patch-sharp (structure-ref x d i))))))
-   (spice (or (car (gethash1 x (context-spice *sharp-eq-context*))) (error "patch-sharp failure")))
+   (spice (let* ((y (gethash1 x (context-spice *sharp-eq-context*)))
+		 (z (car y)))
+	    (unless y (error "Spice ~s not defined" x))
+	    (unless (eq z +nil-proxy+) z)))
    (otherwise x)))
 
 (set-dispatch-macro-character #\# #\= #'sharp-eq-reader)
--- gcl-2.6.7+dfsga.orig/o/symbol.d
+++ gcl-2.6.7+dfsga/o/symbol.d
@@ -279,7 +279,6 @@ putf(p, v, i)
 object p, v, i;
 {
 	object l;
-	vs_mark;
 
 	for (l = p;  !cendp(l);  l = l->c.c_cdr->c.c_cdr) {
 		if (cendp(l->c.c_cdr))
@@ -290,11 +289,7 @@ object p, v, i;
 		}
 	}
         if(l!=Cnil) FEerror("Bad plist ~a",1,p);
-	l = make_cons(v, p);
-	vs_push(l);
-	l = make_cons(i, l);
-	vs_reset;
-	return(l);
+	return listA(3,i,v,p);
 }
 
 object
--- gcl-2.6.7+dfsga.orig/o/num_arith.c
+++ gcl-2.6.7+dfsga/o/num_arith.c
@@ -837,16 +837,16 @@ number_divide(object x, object y)
 object
 integer_divide1(object x, object y)
 {
-	object q, r;
+	object q;
 
-	integer_quotient_remainder_1(x, y, &q, &r);
+	integer_quotient_remainder_1(x, y, &q, NULL);
 	return(q);
 }
 
 object
 get_gcd(object x, object y)
 {
-	object	q, r;
+	object	r;
 
 	if (number_minusp(x))
 		x = number_negate(x);
@@ -899,7 +899,7 @@ L:
 	if (type_of(y) == t_fixnum && fix(y) == 0) {
 		return(x);
 	}
-	integer_quotient_remainder_1(x, y, &q, &r);
+	integer_quotient_remainder_1(x, y, NULL, &r);
 	 x = y;
 	 y = r;
 	goto L;
--- gcl-2.6.7+dfsga.orig/o/alloc.c
+++ gcl-2.6.7+dfsga/o/alloc.c
@@ -521,7 +521,6 @@ alloc_from_freelist(struct typemanager *
     if ((p=tm->tm_free)!=OBJNULL) {
       tm->tm_free = OBJ_LINK(p);
       tm->tm_nfree--;
-      tm->tm_nused++;
       return(p);
     }
     break;
@@ -715,10 +714,9 @@ alloc_after_reclaiming_pages(struct type
 }
 
 inline void *
-alloc_mem(enum type t,fixnum n) {
+alloc_mem(struct typemanager *tm,fixnum n) {
 
   void *p;
-  struct typemanager *tm=tm_of(t);
 
   CHECK_INTERRUPT;
   
@@ -730,7 +728,7 @@ alloc_mem(enum type t,fixnum n) {
     return p;
   if ((p=alloc_after_reclaiming_pages(tm,n)))
     return p;
-  return exhausted_report(t,tm);
+  return exhausted_report(tm->tm_type,tm);
 }
 
 inline object
@@ -739,7 +737,7 @@ alloc_object(enum type t)  {
   object obj;
   struct typemanager *tm=tm_of(t);
   
-  obj=alloc_mem(t,tm->tm_size);
+  obj=alloc_mem(tm,tm->tm_size);
   set_type_of(obj,t);
   
   pageinfo(obj)->in_use++;
@@ -750,13 +748,13 @@ alloc_object(enum type t)  {
 
 inline void *
 alloc_contblock(size_t n) {
-  return alloc_mem(t_contiguous,ROUND_UP_PTR_CONT(n));
+  return alloc_mem(tm_of(t_contiguous),ROUND_UP_PTR_CONT(n));
 }
 
 inline void *
 alloc_relblock(size_t n) {
 
-  return alloc_mem(t_relocatable,ROUND_UP_PTR(n));
+  return alloc_mem(tm_of(t_relocatable),ROUND_UP_PTR(n));
 
 }
 
@@ -764,11 +762,14 @@ alloc_relblock(size_t n) {
 inline object
 make_cons(object a,object d) {
 
-  object obj=alloc_object(t_cons);
+  static struct typemanager *tm=tm_table+t_cons;/*FIXME*/
+  object obj=alloc_mem(tm,tm->tm_size);
 
   obj->c.c_car = a;
   obj->c.c_cdr = d;
 
+  pageinfo(obj)->in_use++;
+
   return(obj);
 
 }
@@ -804,7 +805,7 @@ DEFUN_NEW("ALLOCATED",object,fSallocated
 	     RV(make_fixnum(tm->tm_maxpage)),
 	     RV(make_fixnum(tm->tm_nppage)),
 	     RV(make_fixnum(tm->tm_gbccount)),
-	     RV(make_fixnum(tm->tm_nused))
+	     RV(make_fixnum(tm->tm_npage*tm->tm_nppage-tm->tm_nfree))
 	     ));
 }
  
@@ -1002,7 +1003,7 @@ set_maxpage(void) {
      maxpage are here */ 
 #ifdef SGC
 
-  massert(getpagesize()==PAGESIZE);
+  massert(getpagesize()<=PAGESIZE);
 
   if (gcl_alloc_initialized) {
     extern long maxpage;
--- gcl-2.6.7+dfsga.orig/o/list.d
+++ gcl-2.6.7+dfsga/o/list.d
@@ -304,16 +304,15 @@ object list_vector_new(int n,object firs
 }*/
 
    
-object list(int n,...) { 
+object listqA(int a,int n,va_list ap) { 
 
-  va_list ap;
   struct typemanager *tm=(&tm_table[(int)t_cons]);
   object tail=tm->tm_free,lis=tail;
 
   if (n<=0) return Cnil;
-  va_start(ap,n);
 
   CHECK_INTERRUPT;
+
   if (/* stack_alloc_start || */ tm->tm_nfree < n )  {
     
     object *p = vs_top;
@@ -323,6 +322,8 @@ object list(int n,...) {
       { *p=make_cons(va_arg(ap,object),Cnil);
       p= &((*p)->c.c_cdr);
       }
+    if (a) 
+      *p=va_arg(ap,object);
     return(vs_pop);
 
   }
@@ -333,42 +334,49 @@ object list(int n,...) {
     BEGIN_NO_INTERRUPT;
 
     tm->tm_nfree -= n;
-    tm->tm_nused += n;
     while (--n) {
-      set_type_of(tail,t_cons);/*FIXME try removing this*/
       pageinfo(tail)->in_use++;
       tail->c.c_cdr=OBJ_LINK(tail);
       tail->c.c_car=va_arg(ap,object); 
       tail=tail->c.c_cdr;
     }
     tm->tm_free=OBJ_LINK(tail);
-    set_type_of(tail,t_cons);/*FIXME try removing this*/
     pageinfo(tail)->in_use++;
     tail->c.c_car=va_arg(ap,object); 
-    tail->c.c_cdr=Cnil;
+    tail->c.c_cdr=a ? va_arg(ap,object) : Cnil;
     
     END_NO_INTERRUPT;
-    va_end(ap);
     return lis;
     
   }
 
 }
 
-object listA(int n, ...)
-{       va_list ap;
-	object *p = vs_top;
-	va_start(ap,n);
-	vs_push(Cnil);
-	while(--n>0)
-	  { *p=make_cons(va_arg(ap,object),Cnil);
-	    p= &((*p)->c.c_cdr);
-	  }
-	*p=va_arg(ap,object);
-	va_end(ap);
-	return(vs_pop);
+object list(int n,...) { 
+
+  va_list ap;
+  object lis;
+
+  va_start(ap,n);
+  lis=listqA(0,n,ap);
+  va_end(ap);
+  return lis;
+
+}
+
+object listA(int n,...) { 
+
+  va_list ap;
+  object lis;
+
+  va_start(ap,n);
+  lis=listqA(1,n-1,ap);
+  va_end(ap);
+  return lis;
+
 }
 
+
 static bool
 tree_equal(x, y)
 object x, y;
@@ -501,6 +509,32 @@ object new, tree;
 		vs_check_push(tree);
 }
 
+/* static object */
+/* subst1(object new, object tree) { */
+
+/*   if (TEST(tree)) */
+/*     return new; */
+/*   else if (type_of(tree) == t_cons) { */
+/*     object oa=tree->c.c_car,a=subst1(new,oa),od=tree->c.c_cdr,d=subst1(new,od); */
+/*     return a==oa && d==od ? tree : make_cons(a,d); */
+/*   } else */
+/*     return tree; */
+
+/* } */
+
+/* static object */
+/* subst1qi(object new, object tree) { */
+
+/*   if (item_compared == tree) */
+/*     return new; */
+/*   else if (type_of(tree) == t_cons) { */
+/*     object oa=tree->c.c_car,a=subst1qi(new,oa),od=tree->c.c_cdr,d=subst1qi(new,od); */
+/*     return a==oa && d==od ? tree : make_cons(a,d); */
+/*   } else */
+/*     return tree; */
+
+/* } */
+
 /*
 	Nsubst(new, treep) stores
 	the result of nsubstituting new in *treep
@@ -1082,6 +1116,13 @@ LFD(Lrplacd)()
 	setupTEST(old, test, test_not, key);
 	subst(new, tree);
 	tree = vs_pop;
+        /* if (kf==identity && */
+	/*     tf==test_eql && */
+	/*     (is_imm_fixnum(item_compared) || */
+	/*      ({enum type tp=type_of(item_compared);tp>t_complex || tp<t_fixnum;}))) */
+	/*   tree=subst1qi(new,tree); */
+	/* else */
+	/*   tree=subst1(new,tree); */
 	restoreTEST;
 	@(return tree)
 @)
--- gcl-2.6.7+dfsga.orig/o/gmp_big.c
+++ gcl-2.6.7+dfsga/o/gmp_big.c
@@ -500,18 +500,18 @@ bignum2(unsigned int h, unsigned int l)
 }
 
 void
-integer_quotient_remainder_1(object x, object y, object *qp, object *rp)
-{
-  *qp = new_bignum();
-  *rp = new_bignum();
+integer_quotient_remainder_1(object x, object y, object *qp, object *rp) {
+  
+  object q=qp ? new_bignum() : big_fixnum3;
+  object r=rp ? new_bignum() : big_fixnum4;
+
   /* we may need to coerce the fixnums to MP here, and
      we use the temporary storage of the rp/qp as inputs.
      since overlap is allowed in the mpz_tdiv_qr operation..
   */    
-  mpz_tdiv_qr(MP(*qp),MP(*rp),INTEGER_TO_MP(x,big_fixnum1),
-	      INTEGER_TO_MP(y,big_fixnum2));
-  *qp = normalize_big(*qp);
-  *rp = normalize_big(*rp);
+  mpz_tdiv_qr(MP(q),MP(r),INTEGER_TO_MP(x,big_fixnum1),INTEGER_TO_MP(y,big_fixnum2));
+  if (qp) *qp = normalize_big(q);
+  if (rp) *rp = normalize_big(r);
   return;
 }
 
@@ -543,9 +543,13 @@ gcl_init_big(void)
   MP_ALLOCATED(big_gcprotect)=0;
   big_fixnum1=new_bignum();
   big_fixnum2=new_bignum();
+  big_fixnum3=new_bignum();
+  big_fixnum4=new_bignum();
   enter_mark_origin(&big_fixnum1);
   enter_mark_origin(&big_gcprotect);
   enter_mark_origin(&big_fixnum2);
+  enter_mark_origin(&big_fixnum3);
+  enter_mark_origin(&big_fixnum4);
   gcl_init_big1();
 
 
--- gcl-2.6.7+dfsga.orig/o/main.c
+++ gcl-2.6.7+dfsga/o/main.c
@@ -533,9 +533,16 @@ initlisp(void) {
 #endif
 	    /* || NULL_OR_ON_C_STACK(vv) */
 	    || NULL_OR_ON_C_STACK(pagetoinfo(first_data_page))
-	    || NULL_OR_ON_C_STACK(core_end-1))
+	    || NULL_OR_ON_C_STACK(core_end-1)) {
 	  /* check person has correct definition of above */
+	  fprintf(stderr,"%p %d %p %d %p %d %p %d %p %d\n",
+		  v,NULL_OR_ON_C_STACK(v),
+		  (void *)IM_FIX_BASE,NULL_OR_ON_C_STACK(IM_FIX_BASE),
+		  (void *)(IM_FIX_BASE|IM_FIX_LIM),NULL_OR_ON_C_STACK(IM_FIX_BASE|IM_FIX_LIM),
+		  pagetoinfo(first_data_page),NULL_OR_ON_C_STACK(pagetoinfo(first_data_page)),
+		  core_end-1,NULL_OR_ON_C_STACK(core_end-1));
 	  error("NULL_OR_ON_C_STACK macro invalid");
+	}
 	
 	gcl_init_alloc();
 	
--- gcl-2.6.7+dfsga.orig/o/cmac.c
+++ gcl-2.6.7+dfsga/o/cmac.c
@@ -106,10 +106,10 @@ cmod(object x) {
 
   } else {
 
-    object qp,rp,mod2;
+    object rp,mod2;
     int compare;
 
-    integer_quotient_remainder_1(x,mod,&qp,&rp);
+    integer_quotient_remainder_1(x,mod,NULL,&rp);
     mod2=shift_integer(mod,-1);
     compare = number_compare(rp,small_fixnum(0));
     if (compare >= 0) {
