(bind-func swap_bytes_inplace
;; super dangerous - use only if you know what you're doing
(lambda (buf:i8* nbytes)
(let ((tmp 0)
(i 0))
(dotimes (i (/ nbytes 2))
(set! tmp (pref buf i))
(pset! buf i (pref buf (- nbytes 1 i)))
(pset! buf (- nbytes 1 i) tmp)))))