Closed charlesgregory closed 4 years ago
Theoretically could fail on a rare platform where UINT is 16 bits, although I suspect even 32 bit windows builds may be OK? The C code contains condition:
#if HAVE___BUILTIN_CLZ && UINT_MAX == 4294967295U
Anyway I couldnt find CLZ for DMD either but CTLZ can also be defined as (bitwidth-1) - BSR, and DMD does have BSR in std.bitops
. NO need to change this, but just for your information.
Also I didn't see any unit test, are you sure it works as intended? I won't re open the issue.
I didn't add a unittest as I wasn't sure how the function was used. I also don't think this will be a widely used function. But I think the addition of some unittests for the kstring module would be useful in case someone wants to use it.
When trying to run unittests it seems that the linker wants kputuw. I found this in kstring.d: https://github.com/blachlylab/dhtslib/blob/58684842f739469cc7d7215a2957754ae431120f/source/htslib/kstring.d#L271-L275
I decided to implement this (this issue is just for record keeping). @jblachly Can you check if my implementation is a correct port? Please reopen if there are issues.
I was able to use a clz builtin for ldc but was unable to find one for dmd.