From e940c9ea2100c3cae987f18b684ff3b08bf9c370 Mon Sep 17 00:00:00 2001
From: wlott <wlott>
Date: Mon, 13 Jul 1992 01:45:12 +0000
Subject: [PATCH] Generalized the static-mumble-offset routines to also
 consider nil a static symbol at offset 0.

---
 compiler/generic/utils.lisp | 39 ++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 18 deletions(-)

diff --git a/compiler/generic/utils.lisp b/compiler/generic/utils.lisp
index 839747805..37191e48b 100644
--- a/compiler/generic/utils.lisp
+++ b/compiler/generic/utils.lisp
@@ -7,12 +7,10 @@
 ;;; Scott Fahlman or slisp-group@cs.cmu.edu.
 ;;;
 (ext:file-comment
-  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/generic/utils.lisp,v 1.3 1992/03/12 15:25:02 wlott Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/generic/utils.lisp,v 1.4 1992/07/13 01:45:12 wlott Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
-;;; $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/generic/utils.lisp,v 1.3 1992/03/12 15:25:02 wlott Exp $
-;;;
 ;;; Utility functions needed by the back end to generate code.
 ;;;
 ;;; Written by William Lott.
@@ -38,27 +36,32 @@
 ;;;; Routines for dealing with static symbols.
 
 (defun static-symbol-p (symbol)
-  (member symbol static-symbols))
+  (or (null symbol)
+      (and (member symbol static-symbols) t)))
 
 (defun static-symbol-offset (symbol)
   "Returns the byte offset of the static symbol Symbol."
-  (let ((posn (position symbol static-symbols)))
-    (unless posn (error "~S is not a static symbol." symbol))
-    (+ (* posn (pad-data-block symbol-size))
-       (pad-data-block (1- symbol-size))
-       other-pointer-type
-       (- list-pointer-type))))
+  (if symbol
+      (let ((posn (position symbol static-symbols)))
+	(unless posn (error "~S is not a static symbol." symbol))
+	(+ (* posn (pad-data-block symbol-size))
+	   (pad-data-block (1- symbol-size))
+	   other-pointer-type
+	   (- list-pointer-type)))
+      0))
 
 (defun offset-static-symbol (offset)
   "Given a byte offset, Offset, returns the appropriate static symbol."
-  (multiple-value-bind
-      (n rem)
-      (truncate (+ offset list-pointer-type (- other-pointer-type)
-		   (- (pad-data-block (1- symbol-size))))
-		(pad-data-block symbol-size))
-    (unless (and (zerop rem) (<= 0 n (1- (length static-symbols))))
-      (error "Byte offset, ~D, is not correct." offset))
-    (elt static-symbols n)))
+  (if (zerop offset)
+      nil
+      (multiple-value-bind
+	  (n rem)
+	  (truncate (+ offset list-pointer-type (- other-pointer-type)
+		       (- (pad-data-block (1- symbol-size))))
+		    (pad-data-block symbol-size))
+	(unless (and (zerop rem) (<= 0 n (1- (length static-symbols))))
+	  (error "Byte offset, ~D, is not correct." offset))
+	(elt static-symbols n))))
 
 (defun static-function-offset (name)
   "Return the (byte) offset from NIL to the start of the fdefn object
-- 
GitLab