fix handling of named (CONS x) types in set-pprint-dispatch
[sbcl.git] / contrib / sb-rotate-byte / rotate-byte.lisp
blob5219ccbcb0305198a9a0222609d94209b28951ee
1 (in-package "SB-ROTATE-BYTE")
3 (defun rotate-byte (count bytespec integer)
4 "Rotates a field of bits within INTEGER; specifically, returns an
5 integer that contains the bits of INTEGER rotated COUNT times
6 leftwards within the byte specified by BYTESPEC, and elsewhere
7 contains the bits of INTEGER."
8 (rotate-byte count bytespec integer))
10 (defun %rotate-byte (count size pos integer)
11 (let ((count (nth-value 1 (round count size)))
12 (mask (1- (ash 1 size))))
13 (logior (logand integer (lognot (ash mask pos)))
14 (let ((field (logand (ash mask pos) integer)))
15 (logand (ash mask pos)
16 (if (> count 0)
17 (logior (ash field count)
18 (ash field (- count size)))
19 (logior (ash field count)
20 (ash field (+ count size)))))))))
22 (defun %unsigned-32-rotate-byte (count integer)
23 ;; inhibit transforms
24 (declare (notinline %rotate-byte))
25 (%rotate-byte count 32 0 integer))
27 #+x86-64
28 (defun %unsigned-64-rotate-byte (count integer)
29 (%unsigned-64-rotate-byte count integer))