From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Camm Maguire <camm@debian.org>
Date: Dec, 04 2026 22:51:56 +0000
Subject: [PATCH] <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.

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

Origin: (upstream|backport|vendor|other), (<patch-url>|commit:<commit-id>)
Bug: <upstream-bugtracker-url>
Bug-<Vendor>: <vendor-bugtracker-url>
Forwarded: (no|not-needed|<patch-forwarded-url>)
Applied-Upstream: <version>, (<commit-url>|commit:<commid-id>)
Reviewed-By: <name and email of someone who approved/reviewed the patch>

--- /dev/null
+++ gcl27-2.7.1/ansi-tests/decode-float.lsp
@@ -0,0 +1,51 @@
+(in-package :cl-test)
+
+(deftest integer-decode-float.error.1
+  (signals-error (integer-decode-float) program-error)
+  t)
+
+(deftest integer-decode-float.error.2
+  (signals-error (integer-decode-float 0 0.0) program-error)
+  t)
+
+(defvar *my-floats*
+  (nconc (remove-if-not 'floatp *universe*)
+	 (list* least-positive-long-float least-negative-long-float
+		least-positive-normalized-long-float ;least-negative-normaized-long-float
+		most-positive-long-float most-negative-long-float
+		least-positive-short-float least-negative-short-float
+		least-positive-normalized-short-float ;least-negative-normaized-short-float
+		most-positive-short-float most-negative-short-float
+		compiler::+inf compiler::-inf ;compiler::nan
+		compiler::+sinf compiler::-sinf ;compiler::snan
+		0.0 (- 0.0) 0.0s0 (- 0.0s0)
+		1.2 -1.2 1.2s0 -1.2s0
+		(let (r) (dotimes (i 100 r) (push (- 100.0 (* 2 (random 100.0))) r))))))
+
+(deftest integer-decode-float.1
+    (remove-if (lambda (x)
+	       (multiple-value-bind (a b c) (integer-decode-float x)
+		 (let ((m (typecase x (long-float 900)(short-float 100))))
+		     (if (< b m)
+			 (eql x (float (* c a (expt 2 b)) x))
+			 (eql x (float (* c a (expt 2 m) (expt 2 (- b m))) x))))))
+	       *my-floats*)
+  nil)
+
+(deftest decode-float.error.1
+  (signals-error (decode-float) program-error)
+  t)
+
+(deftest decode-float.error.2
+  (signals-error (decode-float 0 0.0) program-error)
+  t)
+
+(deftest decode-float.1
+    (remove-if (lambda (x)
+	       (multiple-value-bind (a b c) (decode-float x)
+		 (let ((m (typecase x (long-float 900)(short-float 100))))
+		     (if (< b m)
+			 (eql x (* c a (expt (float 2 x) b)))
+			 (eql x (* c a (expt (float 2 x) m) (expt (float 2 x) (- b m))))))))
+	       *my-floats*)
+  nil)
--- gcl27-2.7.1.orig/ansi-tests/load-numbers.lsp
+++ gcl27-2.7.1/ansi-tests/load-numbers.lsp
@@ -99,6 +99,7 @@
 (load "mask-field.lsp")
 
 (load "float.lsp")
+(load "decode-float.lsp")
 (load "floatp.lsp")
 
 (load "rational.lsp")
--- gcl27-2.7.1.orig/cmpnew/gcl_cmpcall.lsp
+++ gcl27-2.7.1/cmpnew/gcl_cmpcall.lsp
@@ -161,7 +161,7 @@
 			(list "case " (write-to-string j) ": _z=(" (gcst (max 1 (+ j la1)) t) "_f->fun.fun_self)(#?);break;
             "))
 		      (make-list (max 0 la1))))
-	    "default: _z=call_proc_cs2(#?);break;
+	    "default: _z=call_proc_cs2(gcl_source_file,#?);break;
         }
         if (!_f->fun.fun_neval && !_f->fun.fun_vv) vs_top=_v ? (object *)_v : sup;
         _z;})")) all))
@@ -327,7 +327,10 @@
   (ms (cdr (assoc (cadr sig) +to-c-var-alist+))
       "("
       (nvfun-wrap "call_proc_cs2" 
-		  (ms (commasep (append (nobs nsup "#") (nobs (- nreq nsup)) `(("#" ,nsup))))) 
+		  (ms (commasep (cons "gcl_source_file"
+				      (append (nobs nsup "#")
+					      (nobs (- nreq nsup))
+					      `(("#" ,nsup))))))
 		  sig fnstr (1+ nreq)) 
       ")"));FIXME better way?
 
@@ -531,7 +534,7 @@
    (write-to-string (argsizes args type 0)) ","
    "(void **)(void *)&Lnk" num ","
    (write-to-string (new-proclaimed-argd args type)) ","
-   "FOO);
+   "FOO,gcl_source_file);
 }"))
 
 
--- gcl27-2.7.1.orig/cmpnew/gcl_cmpenv.lsp
+++ gcl27-2.7.1/cmpnew/gcl_cmpenv.lsp
@@ -253,7 +253,8 @@
 
 (defun inline-asserted (fname)
   (unless *compiler-push-events*
-    (or 
+    (or
+     (not (symbolp fname))
      (member fname *inline*)
      (local-fun-fn fname)
      (get fname 'cmp-inline)
@@ -262,7 +263,7 @@
 	      (remove-duplicates
 	       (mapcar #'symbol-package
 		       (list 'c-t-tt
-			     (mdlsym "fabs");FOXME dladdr macos unreliable, need core mdl in raw images
+			     (mdlsym "fabs");FIXME dladdr macos unreliable, need core mdl in raw images
 			     (mdlsym "sin") (mdlsym "memmove")))))))))
 
 ;; (defun inline-asserted (fname)
--- gcl27-2.7.1.orig/cmpnew/gcl_cmpeval.lsp
+++ gcl27-2.7.1/cmpnew/gcl_cmpeval.lsp
@@ -1633,7 +1633,7 @@
 
 (defun maybe-inline-src (fun fms src &aux fm)
   (when src
-    (cond ((member fun *inline*))
+    (cond ((inline-asserted fun))
 	  ((setq fm (type-fm fun fms)) (known-type-p fm))
 	  ((member fun '(row-major-aref
 			 si::row-major-aset
@@ -1644,16 +1644,11 @@
 			 si::set-0-byte-array-self));FIXME
 	   (flet ((tst (tp) (not (or (type>= tp #tarray) (type>= tp #tvector)))))
 	     (tst (info-type (if (eq fun 'si::row-major-aset) (cadadr fms) (cadar fms))))))
-;	  ((< (cons-count src) 30))
-	  ((not (symbolp fun)))
-	  ((let* ((n (symbol-package fun))(n (when n (package-name n)))(p (find-package :lib))) 
-	     (when n (or (when p (find-symbol n p)) (string-equal "CSTRUCT" n)))));FIXME
-	  ((local-fun-p fun))
 	  ((intersection-p '(&key &rest) (cadr src)))
 	  ((member-if-not (lambda (x) (type>= (car x) (cdr x))) 
 			  (mapcar (lambda (x y) (cons (info-type (cadr x)) (coerce-to-one-value y))) fms (get-arg-types fun))))
 	  ((when (exit-to-fmla-p) (infer-tp-p src)))
-	  ((< (cons-count src) 50)))));100
+	  ((< (cons-count src) 50)))))    ;100
 
 (dolist (l '(upgraded-array-element-type row-major-aref row-major-aset si::set-array array-element-type))
   (setf (get l 'consider-inline) t))
@@ -2051,8 +2046,7 @@
        (mi2 fun args last fms (ff-env (or ff fun))))
      (when (member-if-not 'identity fms :key (lambda (x) (info-type (cadr x))))
        (c1progn (if last (append args (list last)) args) fms))
-     (mi5 (or (when (symbolp fun) fun) ff) info fms last))))
-
+     (mi5 (typecase fun ((or (and symbol (not null)) function) fun)(t ff)) info fms last))))
 
 (defvar *prov-src* nil)
 
--- gcl27-2.7.1.orig/cmpnew/gcl_cmpfun.lsp
+++ gcl27-2.7.1/cmpnew/gcl_cmpfun.lsp
@@ -164,7 +164,7 @@
 					     (list "case " (write-to-string (decf i)) ": _z=(" (gcst (max 1 (+ i la2)) t) "_f->fun.fun_self)(#*_l);break;
           "))
 					   (make-list (max 0 la2))))
-          "default: _z=call_proc_cs2(#*_ll);break;
+          "default: _z=call_proc_cs2(gcl_source_file,#*_ll);break;
         }
         if (!(_f)->fun.fun_neval && !(_f)->fun.fun_vv) vs_top=_v ? (object *)_v : sup;
         _z;})"))
@@ -298,9 +298,14 @@
 		     (list f (or f (num-type-rel rfn t2 t1 t)))))
 	  ((not (and t1 t2)) nil)
 	  ((and (type>= #treal t1) (type>= #treal t2))
-	   (let ((t1 (car  (num-type-bounds t1)))
-		 (t2 (cadr (num-type-bounds t2))))
-	     (and (numberp t1) (numberp t2) (values (funcall fn t1 t2))))))))
+	   (let* ((t1 (car  (num-type-bounds t1)))
+		  (t2 (cadr (num-type-bounds t2)))
+		  (n1 (if (consp t1) (car t1) t1))
+		  (n2 (if (consp t2) (car t2) t2)))
+	     (and (numberp n1) (numberp n2)
+		  (values (or (funcall fn n1 n2)
+			      (unless (and (eq t1 n1) (eq t2 n2))
+				(= n1 n2))))))))))
 
 
 (defun do-num-relations (fn args)
--- gcl27-2.7.1.orig/cmpnew/gcl_cmpinline.lsp
+++ gcl27-2.7.1/cmpnew/gcl_cmpinline.lsp
@@ -946,8 +946,8 @@
 			   ((eql ch #\n)
 			    (wt (length locs)))
 			   ((or (eql ch #\*) (eql ch #\?))
-			    (let* ((f (member (char fun (1- i))  '(#\( #\{)))
-				   (e (member (char fun (+ 2 i)) '(#\) #\})))
+			    (let* ((f (member (char fun (1- i))  '(#\, #\( #\{)))
+				   (e (member (char fun (+ 2 i)) '(#\, #\) #\})))
 				   (locs (nthcdr max locs))
 				   (locs (or locs (when (eql ch #\?) `((fixnum-value nil 0))))))
 			      (dolist (v locs (unless (or f e) (wt ",")))
--- gcl27-2.7.1.orig/cmpnew/gcl_cmpmain.lsp
+++ gcl27-2.7.1/cmpnew/gcl_cmpmain.lsp
@@ -118,9 +118,7 @@
 
 (defun setup-sigs nil
   (clrhash *sigs*)
-  (mapc (lambda (x) (set-first-sig (car x) (cdr x))
-	  (mapc (lambda (x) (set-first-sig (car x) (list (cdr x) nil nil nil nil nil)))
-		(caddr x)))
+  (mapc (lambda (x) (set-first-sig (car x) (cdr x)))
 	si::*sig-discovery-props*))
 
 (defun compile-file (fn &rest l &aux w e (*error-count* 0))
@@ -582,6 +580,7 @@ Cannot compile ~a.~%" (namestring (merge
 	      (si::fwrite *cmpinclude-string* 0
 			  (length *cmpinclude-string*) *compiler-output1*)))
 	    (t (wt-nl1 "#include " *cmpinclude*)))
+      (wt-nl1 "static const char *gcl_source_file __attribute__ ((unused))=\"" *function-filename* "\";")
       (wt-nl1 "#include \""
 	      (namestring
 	        (make-pathname :name
--- gcl27-2.7.1.orig/cmpnew/gcl_cmptop.lsp
+++ gcl27-2.7.1/cmpnew/gcl_cmptop.lsp
@@ -904,10 +904,11 @@
 
 
 (defun get-clv (l &aux (i (cadr l))(obs (append (info-ref-ccb i) (info-ref-clb i))))
-  (list
-   (mapcan (lambda (v) (when (var-p v) `((,v nil)))) obs)
-   (mapcan (lambda (v) (when (fun-p v) `((,v function nil)))) obs)
-   (mapcan (lambda (v) (when (or (blk-p v) (tag-p v)) `((,v ,(if (blk-p v) 'block 'tag) nil)))) obs)))
+  (let ((e1 (mapcan (lambda (v) (when (var-p v) `((,v nil)))) obs))
+	(e2 (mapcan (lambda (v) (when (fun-p v) `((,v function nil)))) obs))
+	(e3 (mapcan (lambda (v) (when (or (blk-p v) (tag-p v)) `((,v ,(if (blk-p v) 'block 'tag) nil)))) obs)))
+    (when (or e1 e2 e3)
+      (list e1 e2 e3))))
 
 (defvar *top-tag* nil)
 
@@ -1106,7 +1107,7 @@
 (defun f-type (x)
   (if (var-p x) (setq x (var-type x)))
   (let ((x (promoted-c-type x)))
-    (let ((x (position x +c-global-arg-types+ :test 'type<=)))
+    (let ((x (position (or x t) +c-global-arg-types+ :test 'type<=)))
       (if x (1+ x) 0))))
 
 (defun argd-sz nil
@@ -1144,7 +1145,7 @@
 
 (defun argsizes (args return &optional max pushed)
   (let* ((x (vald return))
-	 (vv (or (> x 0) (when (zerop x) (not (single-type-p return)))))
+	 (vv (or (> x 0) (when (zerop x) (unless (single-type-p return) return))))
 	 (x (if vv x (- x)))
 	 (la (length args))
 	 (varg (eq (car (last args)) '*))
@@ -1160,9 +1161,9 @@
 
 (defun vald (tp)
   (cond ((single-type-p tp) 0)
-	((type>= #t(values t) tp) 0)
 	((eq tp '*) (- multiple-values-limit 2))
 	((> (length tp) multiple-values-limit) (baboon));FIXME
+	((<= (length tp) 1) 0)
 	((eq (car tp) 'returns-exactly) (- 2 (length tp)))
 	((- (length tp) 2))))
 
--- gcl27-2.7.1.orig/cmpnew/gcl_cmptype.lsp
+++ gcl27-2.7.1/cmpnew/gcl_cmptype.lsp
@@ -88,8 +88,8 @@
 		 (mapcar 'type-or1
 			 (append (cdr x) (null-list (- ly lx)))
 			 (append (cdr y) (null-list (- lx ly)))))))
-	((cmpt x) (type-or1 x `(returns-exactly ,y)))
-	((cmpt y) (type-or1 `(returns-exactly ,x) y))
+	((cmpt x) (if y (type-or1 x `(returns-exactly ,y)) x))
+	((cmpt y) (if x (type-or1 `(returns-exactly ,x) y) y))
 	((tp-or x y))))
 
 (defun type<= (x y)
@@ -1267,3 +1267,11 @@
   (declare (ignore f))
   (if a (object-type (funid-to-fn (car a))) #tfunction));FIXME 0
 (setf (get 'c-symbol-gfdef 'type-propagator) 'symbol-gfdef-propagator)
+
+(defun rando-propagator (f t1 t2)
+  (declare (ignore f t2))
+  (flet ((n (tp &aux (t1 (tp-and t1 tp))(b (real-bnds t1)))
+	   (tp-and (when t1 tp) (if (numberp (cadr b)) (cmp-norm-tp `(real 0 (,(cadr b)))) #t(real 0)))))
+    (tp-or (n #tinteger) (tp-or (n #tshort-float) (n #tlong-float)))))
+(setf (get 'si::rando 'type-propagator) 'rando-propagator)
+(setf (get 'si::rando 'c1no-side-effects) t)
--- gcl27-2.7.1.orig/cmpnew/gcl_lfun_list.lsp
+++ gcl27-2.7.1/cmpnew/gcl_lfun_list.lsp
@@ -6,26 +6,19 @@
 
 (in-package :compiler)
 
-(dolist (l '((((stream) string) . get-output-stream-string)
-	     (((simple-vector seqind) t) . svref)
-	     (((t *) string) . print)
+(dolist (l '((((t *) string) . print)
 	     (((t *) string) . prin1)
 	     (((t *) string) . princ)
 	     (((si::function-identifier) boolean) . fboundp)
 	     (((structure) structure) . si::structure-def)
 	     (((t t t t t t t) pathname) . si::init-pathname)
 	     (((t t *) (or (integer -1 -1 ) seqind)) . si::string-match)
-;	     (((t) t) . si::type-of-c)
-;	     (((list) t) . si::cons-car)
-;	     (((list) t) . si::cons-cdr)
 	     (((structure) symbol) . structure-name)
 	     (((t t) cons) . cons)
 	     (((*) si::proper-list) . list)
 	     (((t *) list) . list*)
 	     (((fixnum) t) . si::nani)
 	     (((t) fixnum) . si::address);FIXME
-;	     (((integer) fixnum) . si::mpz_bitlength)
-;	     (((integer fixnum) integer) . si::shft)
 	     (((number number) number) . si::number-plus)
 	     (((number number) number) . si::number-minus)
 	     (((number number) number) . si::number-times)
@@ -34,24 +27,8 @@
 	     (((real *) (returns-exactly real real)) . ceiling)
 	     (((real *) (returns-exactly real real)) . truncate)
 	     (((real *) (returns-exactly real real)) . round)
-	     ((((or (integer 1) (float (0))) *) (or (integer 0) (float 0))) . random)
-;	     (((cons t) cons) . rplaca)
-;	     (((cons t) cons) . rplacd)
-;	     (((symbol) boolean) . boundp)
-;	     (((symbol) (or null package)) . symbol-package)
-;	     (((symbol) string) . symbol-name)
-;	     (((symbol) t) . symbol-value)
 	     (((symbol t t) t) . si::sputprop)
-;	     (((symbol) (or cons function)) . symbol-function);fixme
-	     ;; (((array rnkind)  seqind) . array-dimension)
-	     ;; (((array)  seqind) . array-total-size)
-	     ;; (((array)  symbol) . array-element-type)
-	     ;; (((array)  rnkind) . array-rank)
-;	     (((vector) seqind) . si::fill-pointer-internal)
 	     (((string) symbol) . make-symbol)
-;	     (((integer integer) integer) . ash)
-	     (((float) (returns-exactly (integer 0) fixnum (member 1 -1))) . integer-decode-float);fixme
-;	     (((t *) nil) . error);fixme
 	     (((*) string) . si::string-concatenate)))
   (let ((x (si::call (cdr l) t)))
     (cond (x (setf (car x) (list (mapcar 'cmp-norm-tp (caar l)) (cmp-norm-tp (cadar l))))
--- gcl27-2.7.1.orig/elisp/gcl.el
+++ gcl27-2.7.1/elisp/gcl.el
@@ -51,11 +51,13 @@ Each directory string should include the
     (define-key map (kbd "v")   'gcl-env)
     (define-key map (kbd "m")   'gcl-form)
     (define-key map (kbd "f")   'gcl-finish)
-    (define-key map (kbd "c")   'gcl-r)
+    (define-key map (kbd "c")   'gcl-continue-and-check)
     (define-key map (kbd "t")   'gcl-bt)
     (define-key map (kbd "l")   'gcl-bl)
     (define-key map (kbd "u")   'gcl-up)
     (define-key map (kbd "d")   'gcl-down)
+    (define-key map (kbd "y")   'gcl-display-last-sexp)
+    (define-key map (kbd "x")   'gcl-undisplay-last-sexp)
     (define-key map (kbd "r")   'gcl-refresh-layout)
     (define-key map (kbd "q")   'gcl-source-overlay-mode-quit) ; Turn off overlays
     map))
@@ -69,10 +71,24 @@ Each directory string should include the
   :init-value nil
   :lighter " GCL-Debug"
   :keymap gcl-source-overlay-mode-map
+  (unless gcl-source-overlay-mode
+    (when (markerp overlay-arrow-position)
+      (set-marker overlay-arrow-position nil)))
   (read-only-mode (if gcl-source-overlay-mode 1 -1)))
 
 ;; Local functions
 
+(defun gcl-continue-and-check nil
+  (interactive)
+  (when
+      (with-current-buffer inferior-lisp-buffer
+	(let ((proc (get-buffer-process (current-buffer)))
+	      (beg (point)))
+	  (process-send-string proc ":r\n")
+	  (accept-process-output proc 0.2)
+	  (string-match-p "\\(?:[^>]\\|^\\)>$" (buffer-substring beg (point)))))
+    (gcl-source-overlay-mode -1)))
+
 (defun gcl-substitute-% (command n)
   (let* (result	(file-line (gcl-find-line)))
     (while (and command (string-match "\\([^%]*\\)%\\([adeflp]\\)" command))
@@ -249,12 +265,22 @@ dynamically to channel the entire file t
 	(message "%s" name)
 	(process-send-string (get-buffer-process inferior-lisp-buffer) (concat name "\n"))))))
 
+(defun gcl-display-last-sexp nil
+  (interactive)
+  (process-send-string
+   (get-buffer-process inferior-lisp-buffer)
+   (concat ":display '" (buffer-substring (save-excursion (backward-sexp) (point)) (point)) "\n")))
+
+(defun gcl-undisplay-last-sexp nil
+  (interactive)
+  (process-send-string
+   (get-buffer-process inferior-lisp-buffer)
+   (concat ":undisplay '" (buffer-substring (save-excursion (backward-sexp) (point)) (point)) "\n")))
+
 (defun gcl-source-overlay-mode-quit ()
   "Safely drop out of the read-only debugger map back to active editing."
   (interactive)
   (gcl-source-overlay-mode -1)
-  (when (markerp overlay-arrow-position)
-    (set-marker overlay-arrow-position nil))
   (gcl-q)
   (message "Debugger keys detached. Editing restored."))
 
@@ -314,6 +340,8 @@ If a non process buffer, just return cur
       (setq-local gcl-gdb-p gdb-p)
 
       (local-set-key (kbd "C-c l") 'gcl-find-and-display-line)
+      (local-set-key (kbd "C-d")   'comint-delchar-or-maybe-eof)
+
       (message "GCL environment bound cleanly to %s" (buffer-name)))))
 
 ;; Filter
@@ -435,7 +463,7 @@ Obeying it means displaying in another w
 (defun gcl (&optional debug)
   (interactive "P")
   (let* ((fn (or (locate-file "saved_ansi_gcl" gcl-dirs nil 'executable)
-		 (shell-command-to-string "gcl27 -batch -eval '(print (si::kcl-self))'")))
+		 (string-trim (shell-command-to-string "gcl27 -batch -eval '(print (si::kcl-self))'"))))
 	 (dir (file-name-directory
 	       (directory-file-name
 		(file-name-directory fn)))))
--- gcl27-2.7.1.orig/git.tag
+++ gcl27-2.7.1/git.tag
@@ -1 +1 @@
-"Version_2_7_2pre45"
+"Version_2_7_2pre46"
--- gcl27-2.7.1.orig/h/compprotos.h
+++ gcl27-2.7.1/h/compprotos.h
@@ -15,8 +15,8 @@ int number_plusp(object);
 int number_zerop(object);
 long int fixint(object);
 object alloc_object(enum type);
-object call_proc_cs2(object,...);
-object call_proc_new23(object,ufixnum,ufixnum,void **,ufixnum,object *);
+object call_proc_cs2(const char *,...);
+object call_proc_new23(object,ufixnum,ufixnum,void **,ufixnum,object *,const char *);
 object coerce_to_string(object);
 object fixnum_big_shift(fixnum,fixnum);
 object fixnum_times(fixnum,fixnum);
--- gcl27-2.7.1.orig/h/protoize.h
+++ gcl27-2.7.1/h/protoize.h
@@ -1467,7 +1467,7 @@ object call_proc_cs1(object,...);
 
 int un_mmap(void *,void *);
 
-object call_proc_cs2(object,...);
+object call_proc_cs2(const char *,...);
 
 void isetq_fix(MP_INT *,int);
 int mpz_to_mpz1(MP_INT *,MP_INT *,void *);
--- gcl27-2.7.1.orig/lsp/gcl_callhash.lsp
+++ gcl27-2.7.1/lsp/gcl_callhash.lsp
@@ -278,12 +278,43 @@
 	       (unless (callers-p s)
 		 (push s r))))))))))
 
-(defun gen-discovery-props (&aux (*sig-discovery* t) q)
-  (do-all-symbols (s) (let ((x (needs-recompile s))) (when x (pushnew (caar x) q))))
-  (when q
-    (format t "~%Pass 1 signature discovery on ~s functions ..." (length q))
-    (mapc (lambda (x) (format t "~s~%" x) (compile x)) q)
-    (gen-discovery-props)))
+(defun tps-callees-first (syms &optional (indices (make-hash-table :test 'eq))
+			  &aux stack result (index 0))
+
+  (labels ((strong-connect (v &aux (mc (unless (gethash v indices) (cons index index))))
+	     (when mc
+	       (setf (gethash v indices) mc)
+	       (incf index)
+	       (push v stack)
+
+	       (dolist (x (intersection (mapcar 'car (callees v)) syms))
+		 (let* ((mcx (strong-connect x))
+			(mcm (or mcx (when (member x stack) (gethash x indices)))))
+		   (when mcm
+		     (setf (cdr mc) (min (cdr mc) (if mcx (cdr mcm) (car mcm)))))))
+
+	       (when (eql (car mc) (cdr mc))
+		 (let* ((n (cdr (member v stack))))
+		   (setq result (append result (ldiff stack n))
+			 stack n)))
+	       mc)))
+
+    (mapc #'strong-connect syms)
+
+    result))
+
+(defun gen-all-syms (&aux r)
+  (do-all-symbols (s r) (pushnew s r)))
+
+(defun gen-discovery-props (&optional (all-syms (gen-all-syms)) &aux (*sig-discovery* t))
+  (let* ((q (tps-callees-first
+	     (mapcan (lambda (x &aux (x (needs-recompile x)))
+		       (when x (list (caar x))))
+		     all-syms))))
+    (when q
+      (format t "~%Pass 1 signature discovery on ~s functions ..." (length q))
+      (mapc (lambda (x) (format t "~s~%" x) (compile x)) q)
+      (gen-discovery-props all-syms))))
 
 (defun do-recomp2 (sp fl &aux *sig-discovery-props* *compile-verbose* r)
   (gen-discovery-props)
--- gcl27-2.7.1.orig/lsp/gcl_debug.lsp
+++ gcl27-2.7.1/lsp/gcl_debug.lsp
@@ -47,7 +47,7 @@
    ))
 
 (defun show-environment nil
-  (dolist (v (reverse (car (current-env))))
+  (dolist (v (reverse (car *break-env*)))
     (format *debug-io* "~%~9a: ~s" (car v) (second v))))
 
 (putprop :a 'show-break-variables 'break-command)
@@ -685,7 +685,7 @@
 	(k nil (get-line-of-form (ihs-fun j) f)))
        ((or k (<= j i)) (when k (list f k j)))))
 
-(defun next-stack-frame (ihs &aux line-info li n i k na)
+(defun next-stack-frame (ihs &aux n i)
   (mv-setq (n i) (get-next-visible-fun ihs))
   (cond
     ((not n) (mv-values nil nil nil nil nil))
--- gcl27-2.7.1.orig/lsp/gcl_deftype.lsp
+++ gcl27-2.7.1/lsp/gcl_deftype.lsp
@@ -266,6 +266,7 @@
 
 
 (defun ctp-num-bnd (x tp inc &aux (a (atom x))(nx (if a x (car x))))
+  (declare (notinline rational));FIXME?
   (flet ((f (b)
 	   (when (fboundp 'fpe::break-on-floating-point-exceptions);FIXME
 	     (fpe::break-on-floating-point-exceptions :suspend t))
@@ -275,10 +276,15 @@
 	     (if (eql z nx) x (if a z (list z))))))
   (case tp
     (integer
-     (let ((nx (if (unless a (integerp (rational nx))) (+ nx inc) nx)))
+     (let ((nx (if (unless a
+		     (multiple-value-bind
+			   (a b) (truncate nx)
+		       (declare (ignore a))
+		       (zerop b)))
+		   (+ nx inc) nx)))
        (if (> inc 0) (ceiling nx) (floor nx))))
     (ratio
-     (let ((z (rational nx)))
+     (let ((z (if (zerop nx) 0 (if (integerp nx) nx (rational nx)))))
        (if (eql z nx) (if (integerp x) (list x) x)
 	   (if (unless (integerp z) a) z (list z)))))
     (short-float (f 0.0s0))
--- gcl27-2.7.1.orig/lsp/gcl_evalmacros.lsp
+++ gcl27-2.7.1/lsp/gcl_evalmacros.lsp
@@ -185,9 +185,9 @@
     (let* ((x (pop y))(z (pop x)))
       (if (constantp z) (when (eval z) (zcollect (if x (?cons 'progn x) z) r rp np) (setq y nil))
 	(if x (zcollect `(if ,z ,@(setq np (list (?cons 'progn x)))) r rp np)
-	  (if (symbolp z) (zcollect `(if ,z ,@(setq np (list z))) r rp np)
+	  (if (and y (symbolp z)) (zcollect `(if ,z ,@(setq np (list z))) r rp np)
 	    (if y (zcollect `(let ((,s ,z)) (if ,s ,@(setq np (list s)))) r rp np)
-	      (zcollect `(values ,z) r rp np))))))))
+	      (zcollect (if (symbolp z) z `(values ,z)) r rp np))))))))
 
 (defmacro when (pred &rest body &aux (x (?cons 'progn body)))
   (declare (optimize (safety 2)))
--- gcl27-2.7.1.orig/lsp/gcl_mislib.lsp
+++ gcl27-2.7.1/lsp/gcl_mislib.lsp
@@ -275,3 +275,30 @@
 (defun gprof-quit (&optional (symtab "gcl_symtab") &aux (gmon (mcleanup)))
   (when gmon
     (gprof-output symtab gmon)))
+
+
+(defvar *missed-fast-calls* nil)
+
+(defun analyze-fast-calls nil
+  (setq *fast-link-warnings* #'fast-call-analysis)
+  (setq *missed-fast-calls* (make-hash-table :test 'eq))  )
+
+(defun cleanup-fast-call-analysis nil
+  (setq *fast-link-warnings* nil *missed-fast-calls* nil))
+
+(defun fast-call-report (&aux r)
+  (maphash (lambda (x y)
+	     (push (cons x (setf (car y) (sort (car y) '> :key 'cadr))) r))
+	   *missed-fast-calls*)
+  (sort r '> :key (lambda (x) (reduce '+ (cdr x) :key 'cadr :initial-value 0))))
+
+(defvar *in-fast-call-analysis* nil)
+
+(defun fast-call-analysis (fun file)
+  (unless *in-fast-call-analysis*
+    (let ((*in-fast-call-analysis* t))
+      (let* ((l (or (gethash fun *missed-fast-calls*)
+		    (setf (gethash fun *missed-fast-calls*) (list nil))))
+	     (f (or (assoc file (car l) :test 'string=)
+		    (car (push (list file 0) (car l))))))
+	(incf (cadr f))))))
--- gcl27-2.7.1.orig/lsp/gcl_numlib.lsp
+++ gcl27-2.7.1/lsp/gcl_numlib.lsp
@@ -207,20 +207,120 @@
 	  :initial-value nil))
 (setf (get 'make-complex 'type-propagator) 'make-complex-propagator)
 
+(defconstant +fa+  (make-array 1 :element-type 'long-float))
+(defconstant +la+  (make-array 1 :element-type 'fixnum       :displaced-to +fa+))
+(defconstant +ia+  (make-array 2 :element-type 'int          :displaced-to +fa+))
+(defconstant +sfa+ (make-array 2 :element-type 'short-float  :displaced-to +fa+))
+
+(declaim (inline float-fixnum-rep))
+(defun float-fixnum-rep (f)
+  (declare (float f))
+  (typecase f
+    (long-float (setf (aref +fa+ 0) f))
+    (short-float (setf (aref +fa+ 0) 0.0
+		       (aref +sfa+
+			     #+(or clx-little-endian (not 64bit)) 0
+			     #-(or clx-little-endian (not 64bit)) 1)
+		       f)))
+  (aref +la+ 0))
+
+(declaim (inline float-fixnum-irep))
+(defun float-fixnum-irep (f)
+  (declare (long-float f))
+  (setf (aref +fa+ 0) f)
+  +ia+)
+
 (defun float-digits (x)
   (declare (optimize (safety 1)))
   (check-type x float);FIXME etypecase
   (typecase x
     (short-float 24)
-    (t 53)))
+    (long-float 53)))
+
+(declaim (inline irep-high irep-low))
+(defun irep-high (a)
+  (aref a #+:clx-little-endian 1 #-:clx-little-endian 0))
+(defun irep-low (a)
+  (aref a #+:clx-little-endian 0 #-:clx-little-endian 1))
+
+(declaim (inline integer-decode-float-inline))
+(defun integer-decode-float-inline (f)
+  (let* ((d (1- (float-digits f)))
+	 (f (float-fixnum-rep f))
+	 (m (logand f (1- (ash 1 d))))
+	 (x (ash f (- d)))
+	 (y (- (logand (+ d (1- int-length)) (- int-length)) d 1))
+	 (e (logand x (1- (ash 1 y))))
+	 (b (if (zerop e) 0 1)))
+    (values (logior m (ash b d))
+	    (- e (- (ash 1 (1- y)) 2) d b)
+	    (- 1 (ash (logand (ash x (- y)) 1) 1)))))
+
+(declaim (inline integer-decode-double-inline))
+(defun integer-decode-double-inline (f)
+  (let* ((d (1- (float-digits f)))
+	 (d1 (- d int-length))
+	 (a (float-fixnum-irep f))
+	 (h (irep-high a))
+	 (m (logand h (1- (ash 1 d1))))
+	 (x (ash h (- d1)))
+	 (y (- (logand (+ d (1- int-length)) (- int-length)) d 1))
+	 (e (logand x (1- (ash 1 y))))
+	 (b (if (zerop e) 0 1)))
+    (values (gmp::mpz_add_ui (gmp::mpz_mul_2exp (logior m (ash b d1)) int-length) (irep-low a))
+	    (- e (- (ash 1 (1- y)) 2) d b)
+	    (- 1 (ash (logand (ash x (- y)) 1) 1)))))
+
+(defun integer-decode-float (f)
+  (declare (optimize (safety 1)))
+  (check-type f float)
+  (typecase f
+    (long-float (#+64bit integer-decode-float-inline #-64bit integer-decode-double-inline f))
+    (short-float (integer-decode-float-inline f))))
+
+(declaim (inline decode-float-inline))
+(defun decode-float-inline (f)
+  (let* ((d (1- (float-digits f)))
+	 (l (float-fixnum-rep f))
+	 (y (- (logand (+ d (1- int-length)) (- int-length)) d 1))
+	 (e (logand (ash l (- d)) (1- (ash 1 y))))
+	 (e (- (- (ash 1 (1- y)) 2)
+	       (if (plusp e) e (- (integer-length (logand l (1- (ash 1 d)))) d)))))
+    (values (scale-float (abs f) e)
+	    (- e)
+	    (float (if (minusp f) -1 1) f))))
+
+(declaim (inline decode-double-inline))
+(defun decode-double-inline (f)
+  (let* ((d (1- (float-digits f)))
+	 (d1 (- d int-length))
+	 (a (float-fixnum-irep f))
+	 (h (irep-high a))
+	 (y (- (logand (+ d (1- int-length)) (- int-length)) d 1))
+	 (e (logand (ash h (- d1)) (1- (ash 1 y))))
+	 (e (- (- (ash 1 (1- y)) 2)
+	       (if (plusp e) e
+		   (- (if (zerop h)
+			  (integer-length (irep-low a))
+			  (+ int-length (integer-length (logand h (1- (ash 1 d1))))))
+		      d)))))
+    (values (scale-float (abs f) e)
+	    (- e)
+	    (float (if (minusp f) -1 1) f))))
+
+(defun decode-float (f)
+  (declare (optimize (safety 1)))
+  (check-type f float)
+  (typecase f
+    (long-float (#+64bit decode-float-inline #-64bit decode-double-inline f))
+    (short-float (decode-float-inline f))))
 
 (defun float-precision (x)
   (declare (optimize (safety 1)))
   (check-type x float);FIXME etypecase
-  (typecase x
-    ((member 0.0 0.0s0) 0)
-    (short-float 24)
-    (t 53)))
+  (if (isnormal x)
+      (float-digits x)
+      (integer-length (integer-decode-float x))))
 
 (defun float-sign (x &optional (y 1.0))
   (declare (optimize (safety 1)))
@@ -264,6 +364,16 @@
 		   ((fry x a (med b a (fryk x a b)))))))
     (fry x a (1+ a))))
 
+(defun rational (x)
+  (declare (optimize (safety 1)))
+  (check-type x real)
+  (typecase x
+    (rational x)
+    (float (multiple-value-bind
+		 (i e s) (integer-decode-float x)
+	     (let ((x (if (>= e 0) (ash i e) (/ i (ash 1 (- e))))))
+	       (if (>= s 0) x (- x)))))))
+
 (defun rationalize (x)
   (declare (optimize (safety 1)))
   (check-type x real)
@@ -277,3 +387,9 @@
 	   (cond ((minusp r) (fryi x (1- f)))
 		 ((zerop r) f)
 		 ((fryi x f))))))))
+
+(defun random (limit &optional (state *random-state*))
+  (declare (optimize (safety 1)))
+  (check-type limit (or (integer 1) (float (0))))
+  (check-type state random-state)
+  (rando limit state))
--- gcl27-2.7.1.orig/lsp/gcl_predlib.lsp
+++ gcl27-2.7.1/lsp/gcl_predlib.lsp
@@ -316,15 +316,6 @@
 		 (if ft res (values (funcall f))))))
 	  (rl l)))
 
-(defun rational (x)
-  (declare (optimize (safety 1)))
-  (check-type x real)
-  (if (rationalp x) x ;too early for typecase
-      (multiple-value-bind
-	    (i e s) (integer-decode-float x)
-	(let ((x (if (>= e 0) (ash i e) (/ i (ash 1 (- e))))))
-	  (if (>= s 0) x (- x))))))
-
 (defun ordered-intersection-eq (l1 l2)
   (let (z zt)
     (do ((l l1 (cdr l))) ((not l))
@@ -422,3 +413,12 @@
 			  (list* '* nil +array-types+))))
 	  '(array simple-array non-simple-array matrix vector)))
 
+
+(defun random-state-p (x)
+  (declare (optimize (safety 1)))
+  (typecase x (random-state t)))
+
+(defun make-random-state (&optional state)
+  (declare (optimize (safety 1)))
+  (check-type state (or boolean random-state))
+  (make_random_state state))
--- gcl27-2.7.1.orig/o/funlink.c
+++ gcl27-2.7.1/o/funlink.c
@@ -242,7 +242,8 @@ typedef union {
 
 
 object
-call_proc_new23(object sym,ufixnum clp,ufixnum vld,void **link,ufixnum argd,object *x) {
+call_proc_new23(object sym,ufixnum clp,ufixnum vld,
+		void **link,ufixnum argd,object *x,const char *calling_file) {
 
   object fun;
   enum type tp;
@@ -311,14 +312,21 @@ call_proc_new23(object sym,ufixnum clp,u
     fas=0;
   }
 
-  if (fas!=Rset && sSAfast_link_warningsA->s.s_dbind==Ct) {
+  if (fas!=Rset && sSAfast_link_warningsA->s.s_dbind!=Cnil) {
     if (tp==t_function) {
-      fprintf(stderr,"Warning: arg/val mismatch in call to %-.*s (%p) prevents fast linking:\n %ld %ld/%ld %d(%d)  %ld %d  %ld %d  %ld, recompile caller\n",
-	      (int)(type_of(sym)==t_symbol ? VLEN(sym->s.s_name) : 0),sym->s.s_name->st.st_self,sym,
-	      argd,(long)fun->fun.fun_argd,
-	      vald,fun->fun.fun_neval,fun->fun.fun_vv,
-	      margs,fun->fun.fun_minarg,nargs,fun->fun.fun_maxarg,pushed);
-      fflush(stderr);
+      if (type_of(sSAfast_link_warningsA->s.s_dbind)==t_function) {
+	struct call_data fcall_ori=fcall;
+	ifuncall2(sSAfast_link_warningsA->s.s_dbind,sym,make_simple_string(calling_file));
+	fcall=fcall_ori;
+      }
+      else {
+	fprintf(stderr,"Warning: arg/val mismatch in call to %-.*s (%p) prevents fast linking:\n %ld %ld/%ld %d(%d)  %ld %d  %ld %d  %ld, recompile caller\n",
+		(int)(type_of(sym)==t_symbol ? VLEN(sym->s.s_name) : 0),sym->s.s_name->st.st_self,sym,
+		argd,(long)fun->fun.fun_argd,
+		vald,fun->fun.fun_neval,fun->fun.fun_vv,
+		margs,fun->fun.fun_minarg,nargs,fun->fun.fun_maxarg,pushed);
+	fflush(stderr);
+      }
     }
 
     /* if (tp==t_cfun) */
@@ -424,17 +432,17 @@ call_proc_new23(object sym,ufixnum clp,u
 }
 
 object
-call_proc_cs2(object first,...) {
+call_proc_cs2(const char *sfn,...) {
 
   int i,nargs=abs(VFUN_NARGS);
   object *x=alloca(nargs*sizeof(*x));
   va_list ap;
 
-  va_start(ap,first);
-  for (i=0;i<nargs;i++) x[i]=i ? va_arg(ap,object) : first;
+  va_start(ap,sfn);
+  for (i=0;i<nargs;i++) x[i]=va_arg(ap,object);
   va_end(ap);
 
-  return call_proc_new23(fcall.fun,1,((31<<12)|(1<<17)|(1<<18)),0,0,x);
+  return call_proc_new23(fcall.fun,1,((31<<12)|(1<<17)|(1<<18)),0,0,x,sfn);
 
 }
 
--- gcl27-2.7.1.orig/o/hash.d
+++ gcl27-2.7.1/o/hash.d
@@ -686,9 +686,8 @@ gcl_init_hash() {
     object x=find_symbol(make_simple_string("MOST-NEGATIVE-FIXNUM"),system_package);
     x=number_negate(x->s.s_dbind);
     for (i=0;i<sizeof(rtb)/sizeof(*rtb);i++) {
-      vs_push(x);
-      Lrandom();
-      rtb[i]=fixint(vs_pop);
+      extern object Vrandom_state;
+      rtb[i]=fixint(fSrando(x,Vrandom_state->s.s_dbind));
     }
   }
 }
--- gcl27-2.7.1.orig/o/num_co.c
+++ gcl27-2.7.1/o/num_co.c
@@ -209,56 +209,6 @@ double_to_rational(double d) {
 
 }
 
-static void
-integer_decode_float(float f, int *mp, int *ep, int *sp)
-{
-	int m;
-	union {float f;int i;} u;
-
-	if (f == 0.0) {
-		*mp = 0;
-		*ep = 0;
-		*sp = 1;
-		return;
-	}
-	u.f=f;
-	m=u.i;
-/* 	m = *(int *)(&f); */
-	if (ISNORMAL(f)) {
-	  *ep = ((m & 0x7f800000) >> 23) - 126 - 24;
-	  *mp = (m & 0x007fffff) | 0x00800000;
-	} else {
-	  *ep = ((m & 0x7f000000) >> 23) - 126 - 24 + 1;
-	  *mp = m & 0x00ffffff;
-	}
-	*sp = (f > 0.0 ? 1 : -1);
-}
-
-static int
-double_exponent(double d)
-{
-	union {double d;int i[2];} u;
-
-	if (d == 0.0)
-		return(0);
-	u.d=d;
-	return (((u.i[HIND] & 0x7ff00000) >> 20) - 1022);
-}
-
-static double
-set_exponent(double d, int e)
-{
-	union {double d;int i[2];} u;
-
-	if (d == 0.0)
-		return(0.0);
-	  
-	u.d=d;
-	u.i[HIND]= (u.i[HIND] & 0x800fffff) | (((e + 1022) << 20) & 0x7ff00000);
-	return(u.d);
-}
-
-
 object
 double_to_integer(double d) {
 
@@ -504,60 +454,6 @@ DEFUN("REM",object,fLrem,LISP,2,2,NONE,O
   RETURN1(y);
 }
 
-DEFUNM("DECODE-FLOAT",object,fLdecode_float,LISP,1,1,NONE,OO,OO,OO,OO,(object x),"") {
-
-  int e,s;
-  fixnum vals=(fixnum)fcall.valp;
-  double d;
-  object *base=vs_top;
-
-  check_type_float(&x);
-
-  if (type_of(x) == t_shortfloat)
-    d = sf(x);
-  else
-    d = lf(x);
-  if (d >= 0.0)
-    s = 1;
-  else {
-    d = -d;
-    s = -1;
-  }
-  e=0;
-  if (!ISNORMAL(d)) {
-    int hp,lp,sp;
-
-    integer_decode_double(d,&hp,&lp,&e,&sp);
-    if (hp!=0 || lp<0)
-      d=number_to_double(bignum2(hp, lp));
-    else
-      d=lp;
-  }
-  e += double_exponent(d);
-  d = set_exponent(d, 0);
-
-  RETURN3(type_of(x) == t_shortfloat ? make_shortfloat((shortfloat)d) : make_longfloat(d),
-	  make_fixnum(e),
-	  type_of(x) == t_shortfloat ? make_shortfloat((shortfloat)s) : make_longfloat((double)s));
-
-}
-
-DEFUNM("INTEGER-DECODE-FLOAT",object,fLinteger_decode_float,LISP,1,1,NONE,OO,OO,OO,OO,(object x),"") {
-
-  int h,l,e,s;
-  fixnum vals=(fixnum)fcall.valp;
-  object *base=vs_top;
-  
-  check_type_float(&x);
-  h=0;
-  if (type_of(x) == t_longfloat)
-    integer_decode_double(lf(x), &h, &l, &e, &s);
-  else
-    integer_decode_float(sf(x), &l, &e, &s);
-  RETURN3((h || l<0) ? bignum2(h, l) : make_fixnum(l),make_fixnum(e),make_fixnum(s));
-
-}
-
 void
 gcl_init_num_co(void) {
 
--- gcl27-2.7.1.orig/o/num_rand.c
+++ gcl27-2.7.1/o/num_rand.c
@@ -165,51 +165,21 @@ make_random_state(object rs) {
 
 }
 
-LFD(Lrandom)(void)
-{
-	int j;
-        object x;
-	
-	j = vs_top - vs_base;
-	if (j == 1)
-		vs_push(symbol_value(Vrandom_state));
-	check_arg(2);
-	check_type_random_state(&vs_base[1]);
-	x = rando(vs_base[0], vs_base[1]);
-	vs_top = vs_base;
-	vs_push(x);
+DEFUN("RANDO",object,fSrando,SI,2,2,NONE,OO,OO,OO,OO,(object x,object y),"") {
+  RETURN1(rando(x,y));
 }
-
-LFD(Lmake_random_state)(void)
-{
-	int j;
-	object x;
-
-	j = vs_top - vs_base;
-	if (j == 0)
-		vs_push(Cnil);
-	check_arg(1);
-	x = make_random_state(vs_head);
-	vs_top = vs_base;
-	vs_push(x);
+#ifdef STATIC_FUNCTION_POINTERS
+object
+fSrando(object x,object y) {
+  return FFN(fSrando)(x,y);
 }
+#endif
 
-LFD(Lrandom_state_p)(void)
-{
-	check_arg(1);
-	if (type_of(vs_pop) == t_random)
-		vs_push(Ct);
-	else
-		vs_push(Cnil);
+DEFUN("MAKE_RANDOM_STATE",object,fSmake_random_state,SI,1,1,NONE,OO,OO,OO,OO,(object x),"") {
+  RETURN1(make_random_state(x));
 }
 
 void
-gcl_init_num_rand(void)
-{
-        Vrandom_state = make_special("*RANDOM-STATE*",
-				     make_random_state(Ct));
-
-	make_function("RANDOM", Lrandom);
-	make_function("MAKE-RANDOM-STATE", Lmake_random_state);
-	make_function("RANDOM-STATE-P", Lrandom_state_p);
+gcl_init_num_rand(void) {
+  Vrandom_state = make_special("*RANDOM-STATE*",make_random_state(Ct));
 }
--- gcl27-2.7.1.orig/pcl/gcl_pcl_defs.lisp
+++ gcl27-2.7.1/pcl/gcl_pcl_defs.lisp
@@ -29,19 +29,113 @@
 (in-package :pcl)
 
 (eval-when (compile load eval)
+
+(defmacro parse-gspec (spec
+		       (non-setf-var . non-setf-case)
+		       (setf-var . setf-case))
+;  (declare (indentation 1 1))
+  #+setf (declare (ignore setf-var setf-case))
+  (once-only (spec)
+    `(cond (#-setf (symbolp ,spec) #+setf t
+	    (let ((,non-setf-var ,spec)) ,@non-setf-case))
+	   #-setf
+	   ((and (listp ,spec)
+		 (eq (car ,spec) 'setf)
+		 (symbolp (cadr ,spec)))
+	    (let ((,setf-var (cadr ,spec))) ,@setf-case))
+	   #-setf
+	   (t
+	    (error
+	      "Can't understand ~S as a generic function specifier.~%~
+               It must be either a symbol which can name a function or~%~
+               a list like ~S, where the car is the symbol ~S and the cadr~%~
+               is a symbol which can name a generic function."
+	      ,spec '(setf <foo>) 'setf)))))
+
+(defun do-satisfies-deftype (name predicate)
+  (declare (ignorable predicate))
+  (unless (get name 'si::deftype-definition)
+;    (print `(deftype ,name nil `(si::std-instance ,(si::coerce-to-standard-class ',name))))
+;    (print (si::coerce-to-standard-class name))
+    (eval `(deftype ,name nil t))
+    (unintern (get name 'si::simple-typep-fn))
+    (remprop name 'si::simple-typep-fn)))
+
+(defun fdefine-carefully (name new-definition)
+  #+Lispm (si:fdefine name new-definition t t)
+  #+Lucid (let ((lucid::*redefinition-action* nil))
+	    (setf (symbol-function name) new-definition))
+  #+excl  (setf (symbol-function name) new-definition)
+  #+xerox (let ((advisedp (member name il:advisedfns :test #'eq))
+                (brokenp (member name il:brokenfns :test #'eq)))
+	    ;; In XeroxLisp (late of envos) tracing is implemented
+	    ;; as a special case of "breaking".  Advising, however,
+	    ;; is treated specially.
+            (xcl:unadvise-function name :no-error t)
+            (xcl:unbreak-function name :no-error t)
+            (setf (symbol-function name) new-definition)
+            (when brokenp (xcl:rebreak-function name))
+            (when advisedp (xcl:readvise-function name)))
+  ;; FIXME add setf expander for fdefinition -- right now we go through
+  ;; the following code which expands to a call to si::fset
+  #+(and setf (not cmu) (not kcl)) (setf (fdefinition name) new-definition)
+  #+kcl (setf (symbol-function (or (si::traced-sym name) name)) new-definition)
+  #+cmu (progn
+	  (c::%%defun name new-definition nil)
+	  (c::note-name-defined name :function)
+	  new-definition)
+  #-(or Lispm Lucid excl Xerox setf kcl cmu)
+  (setf (symbol-function name) new-definition))
+
+(defun gdefinition (spec)
+  (parse-gspec spec
+    (name (or #-setf (macro-function name)		;??
+	      (unencapsulated-fdefinition name)))
+    (name (unencapsulated-fdefinition (get-setf-function-name name)))))
+
+(defun #-setf SETF\ PCL\ GDEFINITION #+setf (setf gdefinition) (new-value spec)
+  (parse-gspec spec
+    (name (fdefine-carefully name new-value))
+    (name (fdefine-carefully (get-setf-function-name name) new-value))))
+
+
+(defun make-type-predicate (name)
+  (let ((cell (find-class-cell name)))
+    #'(lambda (x)
+	(funcall (the function (find-class-cell-predicate cell)) x))))
+
+(defun make-type-predicate-name (name &optional kind)
+  (if (symbol-package name)
+      (intern (format nil
+		      "~@[~A ~]TYPE-PREDICATE ~A ~A"
+		      kind
+		      (package-name (symbol-package name))
+		      (symbol-name name))
+	      *the-pcl-package*)
+      (make-symbol (format nil
+			   "~@[~A ~]TYPE-PREDICATE ~A"
+			   kind
+			   (symbol-name name)))))
+
+  (defun inform-type-system-about-std-class (name)
+    (let ((predicate-name (make-type-predicate-name name)))
+      (setf (gdefinition predicate-name) (make-type-predicate name))
+      (do-satisfies-deftype name predicate-name))))
+
+
+(eval-when (compile load eval)
   
   (defvar *defclass-times*   '(compile load eval)) ;FIXME with eval-when overhaul
 					;Probably have to change this
 					;if you use defconstructor.
   (defvar *defmethod-times*  '(load eval))
-  (defvar *defgeneric-times* '(load eval))
+  (defvar *defgeneric-times* '(load eval)))
 
 ; defvar is now actually in macros
 ;(defvar *boot-state* ())			;NIL
 						;EARLY
 						;BRAID
 						;COMPLETE
-)
 
 (eval-when (load eval)
   (when (eq *boot-state* 'complete)
@@ -70,27 +164,6 @@
 ;;; has a 'real' function spec mechanism can use that instead and in that way
 ;;; get rid of setf generic function names.
 ;;;
-(defmacro parse-gspec (spec
-		       (non-setf-var . non-setf-case)
-		       (setf-var . setf-case))
-;  (declare (indentation 1 1))
-  #+setf (declare (ignore setf-var setf-case))
-  (once-only (spec)
-    `(cond (#-setf (symbolp ,spec) #+setf t
-	    (let ((,non-setf-var ,spec)) ,@non-setf-case))
-	   #-setf
-	   ((and (listp ,spec)
-		 (eq (car ,spec) 'setf)
-		 (symbolp (cadr ,spec)))
-	    (let ((,setf-var (cadr ,spec))) ,@setf-case))
-	   #-setf
-	   (t
-	    (error
-	      "Can't understand ~S as a generic function specifier.~%~
-               It must be either a symbol which can name a function or~%~
-               a list like ~S, where the car is the symbol ~S and the cadr~%~
-               is a symbol which can name a generic function."
-	      ,spec '(setf <foo>) 'setf)))))
 
 ;;;
 ;;; If symbol names a function which is traced or advised, return the
@@ -118,31 +191,6 @@
 ;;; If symbol names a function which is traced or advised, redefine
 ;;; the `real' definition without affecting the advise.
 ;;;
-(defun fdefine-carefully (name new-definition)
-  #+Lispm (si:fdefine name new-definition t t)
-  #+Lucid (let ((lucid::*redefinition-action* nil))
-	    (setf (symbol-function name) new-definition))
-  #+excl  (setf (symbol-function name) new-definition)
-  #+xerox (let ((advisedp (member name il:advisedfns :test #'eq))
-                (brokenp (member name il:brokenfns :test #'eq)))
-	    ;; In XeroxLisp (late of envos) tracing is implemented
-	    ;; as a special case of "breaking".  Advising, however,
-	    ;; is treated specially.
-            (xcl:unadvise-function name :no-error t)
-            (xcl:unbreak-function name :no-error t)
-            (setf (symbol-function name) new-definition)
-            (when brokenp (xcl:rebreak-function name))
-            (when advisedp (xcl:readvise-function name)))
-  ;; FIXME add setf expander for fdefinition -- right now we go through
-  ;; the following code which expands to a call to si::fset
-  #+(and setf (not cmu) (not kcl)) (setf (fdefinition name) new-definition)
-  #+kcl (setf (symbol-function (or (si::traced-sym name) name)) new-definition)
-  #+cmu (progn
-	  (c::%%defun name new-definition nil)
-	  (c::note-name-defined name :function)
-	  new-definition)
-  #-(or Lispm Lucid excl Xerox setf kcl cmu)
-  (setf (symbol-function name) new-definition))
 
 (defun gboundp (spec)
   (parse-gspec spec
@@ -154,16 +202,6 @@
     (name (fmakunbound name))
     (name (fmakunbound (get-setf-function-name name)))))
 
-(defun gdefinition (spec)
-  (parse-gspec spec
-    (name (or #-setf (macro-function name)		;??
-	      (unencapsulated-fdefinition name)))
-    (name (unencapsulated-fdefinition (get-setf-function-name name)))))
-
-(defun #-setf SETF\ PCL\ GDEFINITION #+setf (setf gdefinition) (new-value spec)
-  (parse-gspec spec
-    (name (fdefine-carefully name new-value))
-    (name (fdefine-carefully (get-setf-function-name name) new-value))))
 
 
 (eval-when
@@ -269,16 +307,6 @@
 (defun class-eq-type (class)
   (specializer-type (class-eq-specializer class)))
 
-(defun inform-type-system-about-std-class (name)
-  (let ((predicate-name (make-type-predicate-name name)))
-    (setf (gdefinition predicate-name) (make-type-predicate name))
-    (do-satisfies-deftype name predicate-name)))
-
-(defun make-type-predicate (name)
-  (let ((cell (find-class-cell name)))
-    #'(lambda (x)
-	(funcall (the function (find-class-cell-predicate cell)) x))))
-
 
 ;This stuff isn't right.  Good thing it isn't used.
 ;The satisfies predicate has to be a symbol.  There is no way to
@@ -406,14 +434,6 @@
 	       (subtypep (convert-to-system-type type1)
 			 (convert-to-system-type type2))))))))
 
-(defun do-satisfies-deftype (name predicate)
-  (declare (ignorable predicate))
-  (unless (get name 'si::deftype-definition)
-;    (print `(deftype ,name nil `(si::std-instance ,(si::coerce-to-standard-class ',name))))
-;    (print (si::coerce-to-standard-class name))
-    (eval `(deftype ,name nil t))
-    (unintern (get name 'si::simple-typep-fn))
-    (remprop name 'si::simple-typep-fn)))
 
   ;; #+cmu17 (declare (ignore name predicate))
   ;; #+(or :Genera (and :Lucid (not :Prime)) ExCL :coral)
@@ -439,19 +459,6 @@
   ;; ;; effect on performance of most user code.
   ;; (unless (get name 'si::deftype-definition) (eval `(deftype ,name () '(satisfies ,predicate)))))
 
-(defun make-type-predicate-name (name &optional kind)
-  (if (symbol-package name)
-      (intern (format nil
-		      "~@[~A ~]TYPE-PREDICATE ~A ~A"
-		      kind
-		      (package-name (symbol-package name))
-		      (symbol-name name))
-	      *the-pcl-package*)
-      (make-symbol (format nil
-			   "~@[~A ~]TYPE-PREDICATE ~A"
-			   kind
-			   (symbol-name name)))))
-
 
 
 (defvar *built-in-class-symbols* ())
--- gcl27-2.7.1.orig/pcl/gcl_pcl_dfun.lisp
+++ gcl27-2.7.1/pcl/gcl_pcl_dfun.lisp
@@ -712,11 +712,52 @@ And so, we are saved.
 (defvar *lazy-dfun-compute-p* t)
 (defvar *early-p* nil)
 
+(defconstant +gf-syms+ (mapcar (lambda (x) (declare (ignore x)) (gensym)) (make-list call-arguments-limit)))
+
+(defmacro midfl (i &optional r)
+  (let ((x (ldiff +gf-syms+ (nthcdr i +gf-syms+))))
+    `(lambda (,@x ,@(when r `(&rest ,r)) &aux (args (list* ,@x ,r)))
+       #+copy-&rest-arg (setq args (copy-list args))
+       (initial-dfun gf args))))
+
+(defun gf-ll (gf &aux (def '(&rest r)))
+  (if (eq *boot-state* 'complete)
+      (with-slots (arg-info) gf
+	(let ((ll (arg-info-lambda-list arg-info)))
+	  (if (listp ll) ll
+	      (nconc (ldiff +gf-syms+ (nthcdr (length (arg-info-precedence arg-info)) +gf-syms+))
+		     (when (or (plusp (arg-info-number-optional arg-info))
+			       (arg-info-key/rest-p arg-info))
+		       def)))))
+    def))
+
+(defun get-idf (gf)
+  (let* ((ll (gf-ll gf))
+	 (opts (member lambda-list-keywords ll :test (lambda (x y) (member y x))))
+	 (i (length (ldiff ll opts))))
+    #.`(ecase i
+	 ,@(mapcar (lambda (x) (list x `(if opts (midfl ,x r) (midfl ,x))))
+		   (let ((i -1))
+		     (mapl (lambda (x) (setf (car x) (incf i)))
+			   (make-list call-arguments-limit)))))))
+
+(defmacro mnaml (i &optional r)
+  (let ((x (ldiff +gf-syms+ (nthcdr i +gf-syms+))))
+    `(lambda (,@x ,@(when r `(&rest ,r)) &aux (args (list* ,@x ,r)))
+       (apply #'no-applicable-method gf args))))
+
+(defun get-namf (gf)
+  (let* ((ll (gf-ll gf))
+	 (opts (member lambda-list-keywords ll :test (lambda (x y) (member y x))))
+	 (i (length (ldiff ll opts))))
+    #.`(ecase i
+	 ,@(mapcar (lambda (x) (list x `(if opts (mnaml ,x r) (mnaml ,x))))
+		   (let ((i -1))
+		     (mapl (lambda (x) (setf (car x) (incf i)))
+			   (make-list call-arguments-limit)))))))
+
 (defun make-initial-dfun (gf)
-  (let ((initial-dfun 
-	 (fin-lambda-fn (&rest args)
-	   #+copy-&rest-arg (setq args (copy-list args))
-	   (initial-dfun gf args))))
+  (let ((initial-dfun (get-idf gf)))
     (multiple-value-bind (dfun cache info)
 	(if (and (eq *boot-state* 'complete)
 		 (compute-applicable-methods-emf-std-p gf))
@@ -839,8 +880,7 @@ And so, we are saved.
 	specls all-same-p)
     (cond ((null methods)
 	   (values
-	    (fin-lambda-fn (&rest args)
-	      (apply #'no-applicable-method gf args))
+	    (get-namf gf)
 	    nil
 	    (no-methods-dfun-info)))
 	  ((setq type (final-accessor-dfun-type gf))
@@ -1461,15 +1501,9 @@ And so, we are saved.
 					    &optional all-applicable-p
 					    (all-sorted-p t) function-p)
   (if (null methods)
-      (if function-p
-          #'(lambda (method-alist wrappers)
-	      (declare (ignore method-alist wrappers))
-	      (fin-lambda-fn (&rest args)
-	        (apply #'no-applicable-method gf args)))
-	  #'(lambda (method-alist wrappers)
-	      (declare (ignore method-alist wrappers))
-	      #'(lambda (&rest args)
-		  (apply #'no-applicable-method gf args))))
+      (lambda (method-alist wrappers)
+	(declare (ignore method-alist wrappers))
+	(get-namf gf))
       (let* ((key (car methods))
 	     (ht-value (or (gethash key *effective-method-table*)
 			   (setf (gethash key *effective-method-table*)
--- gcl27-2.7.1.orig/unixport/sys_init.c
+++ gcl27-2.7.1/unixport/sys_init.c
@@ -102,7 +102,6 @@ gcl_init_system(object no_init)
   check_init(lsp,gcl_rename_file,no_init);
   
   check_init(lsp,gcl_callhash,no_init);
-  check_init(lsp,gcl_describe,no_init);
 #ifdef pre_gcl
   check_init(lsp,gcl_bnum,no_init);
 #endif
@@ -110,6 +109,7 @@ gcl_init_system(object no_init)
   check_init(lsp,gcl_mnum,no_init);
 #endif
   check_init(lsp,gcl_numlib,no_init);
+  check_init(lsp,gcl_describe,no_init);
   check_init(lsp,gcl_mislib,no_init);
   check_init(lsp,gcl_iolib,no_init);
   check_init(lsp,gcl_nr,no_init);
