anchor.diff:    (fd :int32)
     (op :int32))
   
  +(defcvar "errno" :int)
  +
  +(defcfun (%strerror "strerror") :string     
  +  (code :int32))
  +(defun get-last-error ()
  +  (error "failed: ~A" (%strerror *errno*)))
  +
  +
   (defstruct mapping 
     fd 
     ptr
     size
     (lock (bt:make-lock)))
  +
  +(defun invalid-pointer-p (handle)
  +  (pointer-eq handle 
  +	      (make-pointer #+(or x86-64 x64 amd64)#xffffffffffffffff
  +			    #-(or x86-64 x64 amd64)#xffffffff)))
   
   (defun open-mapping (path &key size)
     "Opens the file named by PATH and maps it into memory. 
  
positive.code: 		    size 
  		    3 ;; prot_read|prot_write
  		    1 ;; map_shared
  		    fd 
  		    0)))
      (setf (mapping-ptr mapping) ptr
  	  (mapping-size mapping) size)
      mapping))
  
negative.code:   ;; the file is now created and the correct size 
    (let ((fd (with-foreign-string (s path)
  	      (%open s 
  		     2 ;; o_rdwr
  		     600)))) ;; rw
      (when (< fd 0)
        (get-last-error))
      (let ((ptr (%mmap (null-pointer) 
  		      size 
  		      3 ;; prot_read | prot_write
  		      1 ;; map_shared
  		      fd 
  		      0)))
        (when (invalid-pointer-p ptr)
  	(%close fd)
  	(get-last-error))
        (make-mapping :fd fd
  		    :ptr ptr
  		    :size size))))
  