Stefan Israelsson Tampe
2018-09-05 17:53:02 UTC
Hi,
The code velow does not compile when the define-inlinable of id is active.
If in stead
id defined by define is used it all compiles just fine.
Tested on latest tar ball for guile 2.4
-------------------------------------------
(use-modules (rnrs bytevectors))
(define-inlinable (id x) x)
;(define (id x) x)
(define-syntax-rule (mkcrc crc_hqx high xor mask)
(define (crc_hqx data value)
(let ((n (bytevector-length data))
(d data))
(let lp ((i 0) (v value))
(if (< i n)
(let ((b (id (bytevector-u8-ref d i))))
(let lp2 ((j 0) (x 1) (v v))
(if (> j -8)
(let ((bit (ash (logand x b) j))
(hbit (logand v high)))
(if (= hbit 0)
(lp2 (- j 1) (ash x 1) (logior bit (ash v 1)))
(lp2 (- j 1) (ash x 1) (logxor
xor
(logand mask
(logior
bit
(ash v 1)))))))
(lp (+ i 1) v))))
v)))))
(mkcrc crc_hqx #x8000 #x1021 #xffff)
(mkcrc crc32 #x80000000 #x04c11db7 #xffffffff)
The code velow does not compile when the define-inlinable of id is active.
If in stead
id defined by define is used it all compiles just fine.
Tested on latest tar ball for guile 2.4
-------------------------------------------
(use-modules (rnrs bytevectors))
(define-inlinable (id x) x)
;(define (id x) x)
(define-syntax-rule (mkcrc crc_hqx high xor mask)
(define (crc_hqx data value)
(let ((n (bytevector-length data))
(d data))
(let lp ((i 0) (v value))
(if (< i n)
(let ((b (id (bytevector-u8-ref d i))))
(let lp2 ((j 0) (x 1) (v v))
(if (> j -8)
(let ((bit (ash (logand x b) j))
(hbit (logand v high)))
(if (= hbit 0)
(lp2 (- j 1) (ash x 1) (logior bit (ash v 1)))
(lp2 (- j 1) (ash x 1) (logxor
xor
(logand mask
(logior
bit
(ash v 1)))))))
(lp (+ i 1) v))))
v)))))
(mkcrc crc_hqx #x8000 #x1021 #xffff)
(mkcrc crc32 #x80000000 #x04c11db7 #xffffffff)