Comment 0 for bug 787237

Revision history for this message
mon_key (mon-key) wrote :

;; SB-IMPL::ROUND-BYTES-TO-WORDS
;; sbcl/src/code/run-program.lisp
Though the likelihood of something like the following occuring is prob. less
than realistic, it is the case that where N is a fixnum near the boundaries
of CL:MOST-POSITIVE-FIXNUM that the addition of N to (1- ,bytes-per-word) may
overflow the value of CL:MOST-POSITIVE-FIXNUM causing the second fixnum
assertion to fail erroneously, e.g.:
 (sb-impl::round-bytes-to-words (1- most-positive-fixnum))
 (macroexpand-1 '(sb-impl::round-bytes-to-words (1- most-positive-fixnum)))

Also, when is it permissible for the byte N to be a negative integer?

(defmacro tt--round-bytes-to-words (n)
  (let ((bytes-per-word (/ sb-vm:n-machine-word-bits sb-vm:n-byte-bits)))
    `(logandc2 (the fixnum (+ (the fixnum ,n)
                              (1- ,bytes-per-word))) (1- ,bytes-per-word))))

--
/s_P\