X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fppc-vm.lisp;h=79ddf319dcd2eea94dfe80a90889ccbfca87caec;hb=dc33d6a6b84f8338e603759cec8e25da29055d50;hp=a8fc742649d8b4d14c09fb05d1c34ef73cba2bf9;hpb=c94a9f9d1be535ce5df6127cce722d3edd9a6345;p=sbcl.git diff --git a/src/code/ppc-vm.lisp b/src/code/ppc-vm.lisp index a8fc742..79ddf31 100644 --- a/src/code/ppc-vm.lisp +++ b/src/code/ppc-vm.lisp @@ -2,9 +2,6 @@ ;;; (in-package "SB!VM") -(defvar *number-of-signals* 64) -(defvar *bits-per-word* 32) - (define-alien-type os-context-t (struct os-context-t-struct)) @@ -14,14 +11,32 @@ "Returns a string describing the type of the local machine." "PowerPC") -(defun machine-version () - "Returns a string describing the version of the local machine." - "who-knows?") - - +;;; support for CL:MACHINE-VERSION defined OAOO elsewhere +(defun get-machine-version () + #!+linux + (with-open-file (stream "/proc/cpuinfo" + ;; /proc is optional even in Linux, so + ;; fail gracefully. + :if-does-not-exist nil) + (loop with line while (setf line (read-line stream nil)) + ;; hoping "cpu" exists and gives something useful in + ;; all relevant Linuxen... + ;; + ;; from Lars Brinkhoff sbcl-devel 26 Jun 2003: + ;; I examined different versions of Linux/PPC at + ;; http://lxr.linux.no/ (the file that outputs + ;; /proc/cpuinfo is arch/ppc/kernel/setup.c, if + ;; you want to check), and all except 2.0.x + ;; seemed to do the same thing as far as the + ;; "cpu" field is concerned, i.e. it always + ;; starts with the (C-syntax) string "cpu\t\t: ". + when (eql (search "cpu" line) 0) + return (string-trim " " (subseq line (1+ (position #\: line)))))) + #!-linux + nil) -;;; FIXUP-CODE-OBJECT -- Interface -;;; +;;;; FIXUP-CODE-OBJECT + (defun fixup-code-object (code offset fixup kind) (declare (type index offset)) (unless (zerop (rem offset n-word-bytes)) @@ -71,6 +86,13 @@ (declare (type (alien (* os-context-t)) context)) (deref (context-register-addr context index))) +(define-alien-routine ("os_context_lr_addr" context-lr-addr) (* unsigned-long) + (context (* os-context-t))) + +(defun context-lr (context) + (declare (type (alien (* os-context-t)) context)) + (int-sap (deref (context-lr-addr context)))) + (defun %set-context-register (context index new) (declare (type (alien (* os-context-t)) context)) (setf (deref (context-register-addr context index)) @@ -97,13 +119,12 @@ ;;; Given a signal context, return the floating point modes word in ;;; the same format as returned by FLOATING-POINT-MODES. -(defun context-floating-point-modes (context) - ;; FIXME: As of sbcl-0.6.7 and the big rewrite of signal handling - ;; for POSIXness and (at the Lisp level) opaque signal contexts, - ;; this is needs to be rewritten as an alien function. - (warn "stub CONTEXT-FLOATING-POINT-MODES") - 0) - +;;; +;;; FIXME: surely this must be accessible somewhere under Darwin? +#!-darwin +(define-alien-routine ("os_context_fp_control" context-floating-point-modes) + (sb!alien:unsigned 32) + (context (* os-context-t))) ;;;; INTERNAL-ERROR-ARGS. @@ -148,17 +169,14 @@ (declare (type system-area-pointer pc) (type (unsigned-byte 8) length) (type (simple-array (unsigned-byte 8) (*)) vector)) - (copy-from-system-area pc (* sb!vm:n-byte-bits 5) - vector (* sb!vm:n-word-bits - sb!vm:vector-data-offset) - (* length sb!vm:n-byte-bits)) + (copy-ub8-from-system-area pc 5 vector 0 length) (let* ((index 0) - (error-number (sb!c::read-var-integer vector index))) + (error-number (sb!c:read-var-integer vector index))) (collect ((sc-offsets)) (loop (when (>= index length) (return)) - (sc-offsets (sb!c::read-var-integer vector index))) + (sc-offsets (sb!c:read-var-integer vector index))) (values error-number (sc-offsets))))))