From d5ad457f4dcc4b9a5a3ffcb90e4024b7f3b0b649 Mon Sep 17 00:00:00 2001
From: toy <toy>
Date: Mon, 25 Jun 2001 16:48:22 +0000
Subject: [PATCH] Add OFFSET-STATIC-FUNCTION to return the static function
 symbol given the offset to the static function.

---
 compiler/generic/utils.lisp | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/compiler/generic/utils.lisp b/compiler/generic/utils.lisp
index 0c345b0e8..256341bb7 100644
--- a/compiler/generic/utils.lisp
+++ b/compiler/generic/utils.lisp
@@ -5,7 +5,7 @@
 ;;; Carnegie Mellon University, and has been placed in the public domain.
 ;;;
 (ext:file-comment
-  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/generic/utils.lisp,v 1.5 1994/10/31 04:38:06 ram Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/generic/utils.lisp,v 1.6 2001/06/25 16:48:22 toy Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -73,3 +73,19 @@
        (- list-pointer-type)
        (* static-function-index (pad-data-block fdefn-size))
        (* fdefn-raw-addr-slot word-bytes))))
+
+(defun offset-static-function (offset)
+  "Given a byte offset, Offset, returns the appropriate static function
+   symbol."
+  (let* ((static-syms (length static-symbols))
+	 (offsets (+ (* static-syms (pad-data-block symbol-size))
+		     (pad-data-block (1- symbol-size))
+		     (- list-pointer-type)
+		     (* fdefn-raw-addr-slot word-bytes))))
+    (multiple-value-bind (index rmdr)
+	(floor (- offset offsets) (pad-data-block fdefn-size))
+      (unless (and (zerop rmdr)
+		   (>= index 0)
+		   (< index (length static-symbols)))
+	(error "Byte offset, ~D, is not correct." offset))
+      (elt static-functions index))))
-- 
GitLab