Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

delete UB*REF/* implementation; import the symbols from nibbles instead

  • Loading branch information...
commit 66313cd106a5cc470c8794725e22ef912daa7e94 1 parent 229ddfe
Nathan Froyd authored March 20, 2012
42  src/common.lisp
@@ -66,48 +66,6 @@
66 66
   (nibbles::byte-ref-fun-name bitsize nil big-endian-p))
67 67
 ) ; EVAL-WHEN
68 68
 
69  
-(macrolet ((define-fetcher (bitsize &optional big-endian)
70  
-             (let ((name (ubref-fun-name bitsize big-endian))
71  
-                   (bytes (truncate bitsize 8)))
72  
-               `(progn
73  
-                 (declaim (inline ,name))
74  
-                 (defun ,name (buffer index)
75  
-                   (declare (type simple-octet-vector buffer))
76  
-                   (declare (type (integer 0 ,(- array-dimension-limit bytes)) index))
77  
-                   (logand ,(1- (ash 1 bitsize))
78  
-                           ,(loop for i from 0 below bytes
79  
-                                  collect (let* ((offset (if big-endian
80  
-                                                             i
81  
-                                                             (- bytes i 1)))
82  
-                                                 (shift (if big-endian
83  
-                                                            (* (- bytes i 1) 8)
84  
-                                                            (* offset 8))))
85  
-                                            `(ash (aref buffer (+ index ,offset)) ,shift)) into forms
86  
-                                  finally (return `(logior ,@forms))))))))
87  
-           (define-storer (bitsize &optional big-endian)
88  
-             (let ((name (ubref-fun-name bitsize big-endian))
89  
-                   (bytes (truncate bitsize 8)))
90  
-               `(progn
91  
-                 (declaim (inline (setf ,name)))
92  
-                 (defun (setf ,name) (value buffer index)
93  
-                   (declare (type simple-octet-vector buffer))
94  
-                   (declare (type (integer 0 ,(- array-dimension-limit bytes)) index))
95  
-                   (declare (type (unsigned-byte ,bitsize) value))
96  
-                   ,@(loop for i from 1 to bytes
97  
-                           collect (let ((offset (if big-endian
98  
-                                                     (- bytes i)
99  
-                                                     (1- i))))
100  
-                                     `(setf (aref buffer (+ index ,offset))
101  
-                                       (,(read-from-string (format nil "~:R-~A" i '#:byte)) value))))
102  
-                   (values)))))
103  
-           (define-fetchers-and-storers (bitsize)
104  
-             `(progn
105  
-               (define-fetcher ,bitsize) (define-fetcher ,bitsize t)
106  
-               (define-storer ,bitsize) (define-storer ,bitsize t))))
107  
-  (define-fetchers-and-storers 16)
108  
-  (define-fetchers-and-storers 32)
109  
-  (define-fetchers-and-storers 64))
110  
-
111 69
 
112 70
 ;;; efficient 32-bit arithmetic, which a lot of algorithms require
113 71
 
4  src/package.lisp
@@ -2,6 +2,10 @@
2 2
   (:use :cl)
3 3
   (:nicknames :crypto)
4 4
   (:shadow null)
  5
+  (:import-from #:nibbles 
  6
+		#:ub16ref/le #:ub16ref/be
  7
+		#:ub32ref/le #:ub32ref/be
  8
+		#:ub64ref/le #:ub64ref/be)
5 9
   (:export
6 10
    ;; referencing multiple-octet values in an octet vector (SETF-able)
7 11
    #:ub16ref/be #:ub16ref/le #:ub32ref/be #:ub32ref/le #:ub64ref/le #:ub64ref/be

0 notes on commit 66313cd

Please sign in to comment.
Something went wrong with that request. Please try again.