X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=base%2Fcmucl-compat.lisp;h=d285788121f222fdde3d206690e560deab3cfb9a;hb=fa32c4233b4a02ae631602dbb0a234ab10df8aaf;hp=a479bc1e687181d3a61ce0fa718c55425c4efbba;hpb=998937376fa6f9ce29bd3c7954fb0ebca91c37d7;p=clsql.git diff --git a/base/cmucl-compat.lisp b/base/cmucl-compat.lisp index a479bc1..d285788 100644 --- a/base/cmucl-compat.lisp +++ b/base/cmucl-compat.lisp @@ -2,45 +2,49 @@ ;;;; ************************************************************************* ;;;; FILE IDENTIFICATION ;;;; -;;;; Name: cmucl-compat.sql +;;;; Name: cmucl-compat.lisp ;;;; Purpose: Compatiblity library for CMUCL functions ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Feb 2002 ;;;; -;;;; $Id: cmucl-compat.lisp,v 1.1 2002/09/30 10:19:01 kevin Exp $ +;;;; $Id$ ;;;; -;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg +;;;; This file, part of CLSQL, is Copyright (c) 2002-2004 by Kevin M. Rosenberg ;;;; ;;;; CLSQL users are granted the rights to distribute and use this software ;;;; as governed by the terms of the Lisp Lesser GNU Public License ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. ;;;; ************************************************************************* -(declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0))) -(in-package :cl-user) +(in-package #:cl-user) -(defpackage :cmucl-compat +(defpackage #:cmucl-compat + (:use #:common-lisp) (:export #:shrink-vector #:make-sequence-of-type #:result-type-or-lose #:required-argument )) -(in-package :cmucl-compat) +(in-package #:cmucl-compat) -#+cmu +#+(or cmu scl) (defmacro required-argument () `(ext:required-argument)) -#-cmu +#-(or cmu scl) (defun required-argument () (error "~&A required keyword argument was not supplied")) -#+cmu +#+(or cmu scl) (defmacro shrink-vector (vec len) `(lisp::shrink-vector ,vec ,len)) -#-cmu +#+sbcl +(defmacro shrink-vector (vec len) + `(sb-kernel::shrink-vector ,vec ,len)) + +#-(or cmu sbcl scl) (defmacro shrink-vector (vec len) "Shrinks a vector. Optimized if vector has a fill pointer. Needs to be a macro to overwrite value of VEC." @@ -51,9 +55,11 @@ Needs to be a macro to overwrite value of VEC." ((typep ,vec 'simple-array) (let ((,new-vec (make-array ,len :element-type (array-element-type ,vec)))) - (dotimes (i ,len) - (declare (fixnum i)) - (setf (aref ,new-vec i) (aref ,vec i))) + (check-type ,len fixnum) + (locally (declare (optimize (speed 3) (safety 0) (space 0)) ) + (dotimes (i ,len) + (declare (fixnum i)) + (setf (aref ,new-vec i) (aref ,vec i)))) (setq ,vec ,new-vec))) ((typep ,vec 'vector) (setf (fill-pointer ,vec) ,len) @@ -63,37 +69,19 @@ Needs to be a macro to overwrite value of VEC." ))) - -#-cmu +#-(or cmu scl) (defun make-sequence-of-type (type length) "Returns a sequence of the given TYPE and LENGTH." - (declare (fixnum length)) - (case type - (list - (make-list length)) - ((bit-vector simple-bit-vector) - (make-array length :element-type '(mod 2))) - ((string simple-string base-string simple-base-string) - (make-string length)) - (simple-vector - (make-array length)) - ((array simple-array vector) - (if (listp type) - (make-array length :element-type (cadr type)) - (make-array length))) - (t - (make-sequence-of-type (result-type-or-lose type t) length)))) - + (make-sequence type length)) -#+cmu +#+(or cmu scl) (if (fboundp 'lisp::make-sequence-of-type) (defun make-sequence-of-type (type len) (lisp::make-sequence-of-type type len)) (defun make-sequence-of-type (type len) - (system::make-sequence-of-type type len))) - + (common-lisp::make-sequence-of-type type len))) -#-cmu +#-(or cmu scl) (defun result-type-or-lose (type nil-ok) (unless (or type nil-ok) (error "NIL output type invalid for this sequence function")) @@ -110,6 +98,6 @@ Needs to be a macro to overwrite value of VEC." (error "~S is a bad type specifier for sequence functions." type)) )) -#+cmu +#+(or cmu scl) (defun result-type-or-lose (type nil-ok) (lisp::result-type-or-lose type nil-ok))