lib/rnrs/bytevectors.ss
(library (rnrs bytevectors (6))
  (export endianness
	  native-endianntess
	  (rename (bytes? bytevector?)
		  (make-bytes make-bytevector)
		  (bytes->list bytevector->u8-list)
		  (list->bytes u8-list->bytevector)
		  (bytes-length bytevector-length)
		  (bytes-ref bytevector-ref)
		  (bytes-set! u8vector-set!)
		  (bytes-copy u8vector-copy)
		  bytes=?
		  bytevector-copy!)
 
  (define (byte-vector=? v1 v2) ; enforces binary arity.
    (bytes=? v1 v2))
      
  (define (bytevector-copy! src src-start dest dest-start n)
    (bytes-copy! dest dest-start src src-start (+ src-start n))))

	  (rename (bytes? bytevector?)
		  (make-bytes make-bytevector)
		  (bytes-length bytevector-length)
		  (bytes=? bytevector=?)
  (import (rnrs base)
          (primitives system-big-endian?))

  (define-syntax endianness
    (syntax-rules (big little)
      ((endianness big)    (values))
      ((endianness little) (values))))

  (define (native-endianness)
    (if (system-big-endian?)
	'big
	'little))