lib/srfi/n66.ss
;; TODO: rewrite in terms of rnrs bytevectors
(library (srfi-66)
  (export (rename (bytes? u8vector?)
		  (make-bytes make-u8vector)
		  (bytes u8vector)
		  (bytes->list u8vector->list)
		  (list->bytes list->u8vector)
		  (bytes-length u8vector-length)
		  (bytes-ref u8vector-ref)
		  (bytes-set! u8vector-set!)
		  (bytes-copy u8vector-copy))
	  u8vector=?
	  u8vector-compare
	  u8vector-copy!)
  (import (rnrs base)
          (primitives bytes?
		      make-bytes
		      bytes
		      bytes->list
		      list->bytes
		      bytes-length
		      bytes-ref
		      bytes-set!
		      bytes-copy
		      bytes-copy!
		      bytes=?
		      bytes<?
		      bytes>?))
		      
  (define (u8vector=? v1 v2)
    (bytes=? v1 v2))
  
  (define (u8vector-compare v1 v2)
    (cond ((bytes<? v1 v2) -1)
          ((bytes>? v1 v2)  1)
          (else             0)))
    
  (define (u8vector-copy! src src-start dest dest-start n)
    (bytes-copy! dest dest-start src src-start (+ src-start n)))

  ) ; end srfi-66