Added bit-set

This commit is contained in:
Justin Ethier 2017-08-08 15:27:23 +00:00
parent a247ba03ad
commit be11ed674f

View file

@ -28,7 +28,7 @@
fxarithmetic-shift fxarithmetic-shift
fxarithmetic-shift-left fxarithmetic-shift-right fxarithmetic-shift-left fxarithmetic-shift-right
; fxbit-count fxlength ; fxbit-count fxlength
fxif ;fxbit-set? fxcopy-bit fxif fxbit-set? ;fxcopy-bit
; fxfirst-set-bit fxbit-field ; fxfirst-set-bit fxbit-field
; fxbit-field-rotate fxbit-field-reverse ; fxbit-field-rotate fxbit-field-reverse
) )
@ -46,7 +46,7 @@
fxnot fxand fxior fxxor fxnot fxand fxior fxxor
fxarithmetic-shift fxarithmetic-shift
fxarithmetic-shift-left fxarithmetic-shift-right fxarithmetic-shift-left fxarithmetic-shift-right
fxif fxif fxbit-set?
) )
(begin (begin
(define (fx-width) 31) (define (fx-width) 31)
@ -134,5 +134,11 @@
(bin-num-op fxarithmetic-shift-right ">>") (bin-num-op fxarithmetic-shift-right ">>")
(define (fxif mask i j) (define (fxif mask i j)
(fxior (fxand (fxnot mask) i) (fxand mask j))) (fxior (fxand (fxnot mask) i) (fxand mask j)))
(define-c fxbit-set?
"(void* data, int argc, closure _, object k, object index, object i)"
" Cyc_check_fixnum(data, index);
Cyc_check_fixnum(data, i);
int result = ((obj_obj2int(i)) & (1 << (obj_obj2int(index))));
return_closcall1(data, k, result ? boolean_t : boolean_f); ")
)) ))