|
|
@ -27,3 +27,22 @@ |
|
|
|
(at i (type-cast data (addr uint8_t)))) |
|
|
|
s-crc32-table) |
|
|
|
(bit-shift->> (deref crc-out) 8))))) |
|
|
|
|
|
|
|
(defun hash-crc32-string-null-terminated |
|
|
|
(str (addr (const char)) |
|
|
|
&return uint32_t) |
|
|
|
(unless (at 0 s-crc32-table) |
|
|
|
(assert (and (at 0 s-crc32-table) "Need to call hash-crc32-initialize first")) |
|
|
|
(return 0)) |
|
|
|
(unless str |
|
|
|
(return 0)) |
|
|
|
(var result uint32_t 0) |
|
|
|
(while (deref str) |
|
|
|
(set result |
|
|
|
(bit-xor |
|
|
|
(at (bit-xor (type-cast result uint8_t) |
|
|
|
(deref (type-cast str (addr uint8_t)))) |
|
|
|
s-crc32-table) |
|
|
|
(bit-shift->> result 8))) |
|
|
|
(incr str)) |
|
|
|
(return result)) |
|
|
|