[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
clear option for RLET
- To: ENGBER@ARISTOTLE.ILS.NWU.EDU
- Subject: clear option for RLET
- From: ST.CLAIR@AppleLink.Apple.COM (St. Clair, William)
- Date: 11 Jul 91 22:04 GMT
- Cc: INFO-MCL@CAMBRIDGE.APPLE.COM
Sub: a :clear option for rlet
From: engber@aristotle.ils.nwu.edu (Mike Engber)
Message-Id: <9107052052.AA05946@aristotle.ils.nwu.edu>
To: info-mcl@cambridge.apple.com
It would be nice if rlet allowed a :clear option like make-record
does. This would be especially helpful for allocating parameter
blocks which are notorious for causing problems unless 'unused'
fields are zeroed out.
I realize there is probably not as nice(efficient) a way to do
this as there is for make-record, but it would still be helpful.
I much prefer rlet to make-record.
If someone can tell me a slick way to zero the contents of a
macptr I'd be happy to implement it myself. Off the top of
my head all I can think of is a loop and %put-xxx. There has
to be a better way.
We didn't include the clear option as we couldn't do it much better than
you can. I suppose we could have included a FILL-MEMORY function written
in assembler. If you're really adverse to using %put-xxx, try the
following assembler code. It could be fancier by doing longword
moves for most of its work, but I doubt you'll notice the difference.
#|
; Here's what it does
(defun fill-memory (macptr length &optional (byte 0))
(dotimes (i length)
(declare (fixnum i))
(%put-byte macptr byte i)))
|#
(in-package :ccl)
(export 'fill-memory)
(eval-when (compile eval)
(require 'lapmacros))
(defun fill-memory (macptr length &optional (byte 0))
(setq length (require-type length 'fixnum))
(setq byte (require-type byte 'fixnum))
(lap-inline (macptr length byte)
(move.l arg_x atemp0) ; macptr
(jsr_subprim $sp-macptrptr) ; address in atemp0
(getint arg_y) ; unbox length
(getint arg_z) ; unbox byte
(dbfloop.l arg_y
(move.b arg_z atemp0@+)))
nil)