I always thought these were a bad idea. There's too much temptation to put everything in one big header and include it everywhere, even when it's not needed - this can slow down compilation by quite a bit.
I always break things up, even when the length of the header file doesn't make it seem like a necessary thing. My bit.h is like 15 lines, for example. If you've ever had to split up a big header file, you'll appreciate the reason for this.
(defmacro size-in-array (type)
(let* ((n 100000)
(o (with-output-to-string (s)
(let ((*standard-output* s)
(*trace-output* s))
(eval `(time (make-array ,n :element-type ',type))))))
(o (loop for i = 0 then (1+ j)
as j = (position #\Newline o :start i)
collect (subseq o i j)
while j))
(o (or #+sbcl (caddr (reverse o))
#+clozure (cadr (reverse o))
(error "size-in-array: your platform is not supported")))
(o (coerce (remove-if (lambda (x) (char= x #\,)) (coerce o 'list))
'string))
(o (truncate (read-from-string o) n)))
o))
(defun %grow (s l)
(declare ((SIMPLE-ARRAY (UNSIGNED-BYTE 8) (*)) s)
(fixnum l))
(let* ((n (length s))
(d (vec (* 2 (+ n l)) u1)))
(dotimes (i n) (setf (aref d i) (aref s i)))
d))
(defmacro ser-dup (s n &rest x)
(when (numberp (car x))
(setf x (cons 'lsb x)))
`(loop as i from 0 below ,n
do (,(intern (concatenate 'string "SER-" (symbol-name (car x))))
,s
,@(cdr x))))
(defun ser-lsbmsb (stream n val &key lsb)
(with-gensyms (s v)
`(let ((,s ,stream)
(,v ,val))
,@(mapcar (lambda (i) `(% ,s (ash ,v ,(- (* (if lsb i (- n 1 i)) 8)))))
(rng 0 (- n 1))))))
(defmacro ser-lsb (s n v) (ser-lsbmsb s n v :lsb t))
(defmacro ser-msb (s n v) (ser-lsbmsb s n v :lsb nil))
(defmacro ser-utf8 (s v) `(ser-arr ,s 1 (string-to-utf8 ,v)))