@@ -450,15 +450,15 @@ when useGCC_builtins:
450
450
451
451
elif useVCC_builtins:
452
452
# Search the mask data from most significant bit (MSB) to least significant bit (LSB) for a set bit (1).
453
- func bitScanReverse (index: ptr culong , mask: culong ): cuchar {.
453
+ func bitScanReverse (index: ptr culong , mask: culong ): uint8 {.
454
454
importc : " _BitScanReverse" , header : " <intrin.h>" .}
455
- func bitScanReverse64 (index: ptr culong , mask: uint64 ): cuchar {.
455
+ func bitScanReverse64 (index: ptr culong , mask: uint64 ): uint8 {.
456
456
importc : " _BitScanReverse64" , header : " <intrin.h>" .}
457
457
458
458
# Search the mask data from least significant bit (LSB) to the most significant bit (MSB) for a set bit (1).
459
- func bitScanForward (index: ptr culong , mask: culong ): cuchar {.
459
+ func bitScanForward (index: ptr culong , mask: culong ): uint8 {.
460
460
importc : " _BitScanForward" , header : " <intrin.h>" .}
461
- func bitScanForward64 (index: ptr culong , mask: uint64 ): cuchar {.
461
+ func bitScanForward64 (index: ptr culong , mask: uint64 ): uint8 {.
462
462
importc : " _BitScanForward64" , header : " <intrin.h>" .}
463
463
464
464
template vcc_scan_impl (fnc: untyped ; v: untyped ): int =
@@ -468,15 +468,15 @@ elif useVCC_builtins:
468
468
469
469
elif useICC_builtins:
470
470
# Returns the number of trailing 0-bits in x, starting at the least significant bit position. If x is 0, the result is undefined.
471
- func bitScanForward (p: ptr uint32 , b: uint32 ): cuchar {.
471
+ func bitScanForward (p: ptr uint32 , b: uint32 ): uint8 {.
472
472
importc : " _BitScanForward" , header : " <immintrin.h>" .}
473
- func bitScanForward64 (p: ptr uint32 , b: uint64 ): cuchar {.
473
+ func bitScanForward64 (p: ptr uint32 , b: uint64 ): uint8 {.
474
474
importc : " _BitScanForward64" , header : " <immintrin.h>" .}
475
475
476
476
# Returns the number of leading 0-bits in x, starting at the most significant bit position. If x is 0, the result is undefined.
477
- func bitScanReverse (p: ptr uint32 , b: uint32 ): cuchar {.
477
+ func bitScanReverse (p: ptr uint32 , b: uint32 ): uint8 {.
478
478
importc : " _BitScanReverse" , header : " <immintrin.h>" .}
479
- func bitScanReverse64 (p: ptr uint32 , b: uint64 ): cuchar {.
479
+ func bitScanReverse64 (p: ptr uint32 , b: uint64 ): uint8 {.
480
480
importc : " _BitScanReverse64" , header : " <immintrin.h>" .}
481
481
482
482
template icc_scan_impl (fnc: untyped ; v: untyped ): int =
@@ -664,7 +664,7 @@ when useBuiltinsRotate:
664
664
when defined (gcc):
665
665
# GCC was tested until version 4.8.1 and intrinsics were present. Not tested
666
666
# in previous versions.
667
- func builtin_rotl8 (value: cuchar , shift: cint ): cuchar
667
+ func builtin_rotl8 (value: uint8 , shift: cint ): uint8
668
668
{.importc : " __rolb" , header : " <x86intrin.h>" .}
669
669
func builtin_rotl16 (value: cushort , shift: cint ): cushort
670
670
{.importc : " __rolw" , header : " <x86intrin.h>" .}
@@ -674,7 +674,7 @@ when useBuiltinsRotate:
674
674
func builtin_rotl64 (value: culonglong , shift: cint ): culonglong
675
675
{.importc : " __rolq" , header : " <x86intrin.h>" .}
676
676
677
- func builtin_rotr8 (value: cuchar , shift: cint ): cuchar
677
+ func builtin_rotr8 (value: uint8 , shift: cint ): uint8
678
678
{.importc : " __rorb" , header : " <x86intrin.h>" .}
679
679
func builtin_rotr16 (value: cushort , shift: cint ): cushort
680
680
{.importc : " __rorw" , header : " <x86intrin.h>" .}
@@ -690,7 +690,7 @@ when useBuiltinsRotate:
690
690
# https://releases.llvm.org/8.0.0/tools/clang/docs/ReleaseNotes.html#non-comprehensive-list-of-changes-in-this-release
691
691
# https://releases.llvm.org/8.0.0/tools/clang/docs/LanguageExtensions.html#builtin-rotateleft
692
692
# source for correct declarations: https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/Builtins.def
693
- func builtin_rotl8 (value: cuchar , shift: cuchar ): cuchar
693
+ func builtin_rotl8 (value: uint8 , shift: uint8 ): uint8
694
694
{.importc : " __builtin_rotateleft8" , nodecl .}
695
695
func builtin_rotl16 (value: cushort , shift: cushort ): cushort
696
696
{.importc : " __builtin_rotateleft16" , nodecl .}
@@ -700,7 +700,7 @@ when useBuiltinsRotate:
700
700
func builtin_rotl64 (value: culonglong , shift: culonglong ): culonglong
701
701
{.importc : " __builtin_rotateleft64" , nodecl .}
702
702
703
- func builtin_rotr8 (value: cuchar , shift: cuchar ): cuchar
703
+ func builtin_rotr8 (value: uint8 , shift: uint8 ): uint8
704
704
{.importc : " __builtin_rotateright8" , nodecl .}
705
705
func builtin_rotr16 (value: cushort , shift: cushort ): cushort
706
706
{.importc : " __builtin_rotateright16" , nodecl .}
@@ -716,19 +716,19 @@ when useBuiltinsRotate:
716
716
# https://docs.microsoft.com/en-us/cpp/intrinsics/rotl8-rotl16?view=msvc-160
717
717
# https://docs.microsoft.com/en-us/cpp/intrinsics/rotr8-rotr16?view=msvc-160
718
718
# https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/rotl-rotl64-rotr-rotr64?view=msvc-160
719
- func builtin_rotl8 (value: cuchar , shift: cuchar ): cuchar
719
+ func builtin_rotl8 (value: uint8 , shift: uint8 ): uint8
720
720
{.importc : " _rotl8" , header : " <intrin.h>" .}
721
- func builtin_rotl16 (value: cushort , shift: cuchar ): cushort
721
+ func builtin_rotl16 (value: cushort , shift: uint8 ): cushort
722
722
{.importc : " _rotl16" , header : " <intrin.h>" .}
723
723
func builtin_rotl32 (value: cuint , shift: cint ): cuint
724
724
{.importc : " _rotl" , header : " <stdlib.h>" .}
725
725
when defined (amd64):
726
726
func builtin_rotl64 (value: culonglong , shift: cint ): culonglong
727
727
{.importc : " _rotl64" , header : " <stdlib.h>" .}
728
728
729
- func builtin_rotr8 (value: cuchar , shift: cuchar ): cuchar
729
+ func builtin_rotr8 (value: uint8 , shift: uint8 ): uint8
730
730
{.importc : " _rotr8" , header : " <intrin.h>" .}
731
- func builtin_rotr16 (value: cushort , shift: cuchar ): cushort
731
+ func builtin_rotr16 (value: cushort , shift: uint8 ): cushort
732
732
{.importc : " _rotr16" , header : " <intrin.h>" .}
733
733
func builtin_rotr32 (value: cuint , shift: cint ): cuint
734
734
{.importc : " _rotr" , header : " <stdlib.h>" .}
@@ -738,7 +738,7 @@ when useBuiltinsRotate:
738
738
elif defined (icl):
739
739
# Tested on Intel(R) C++ Intel(R) 64 Compiler Classic Version 2021.1.2 Build
740
740
# 20201208_000000 x64 and x86. Not tested in previous versions.
741
- func builtin_rotl8 (value: cuchar , shift: cint ): cuchar
741
+ func builtin_rotl8 (value: uint8 , shift: cint ): uint8
742
742
{.importc : " __rolb" , header : " <immintrin.h>" .}
743
743
func builtin_rotl16 (value: cushort , shift: cint ): cushort
744
744
{.importc : " __rolw" , header : " <immintrin.h>" .}
@@ -748,7 +748,7 @@ when useBuiltinsRotate:
748
748
func builtin_rotl64 (value: culonglong , shift: cint ): culonglong
749
749
{.importc : " __rolq" , header : " <immintrin.h>" .}
750
750
751
- func builtin_rotr8 (value: cuchar , shift: cint ): cuchar
751
+ func builtin_rotr8 (value: uint8 , shift: cint ): uint8
752
752
{.importc : " __rorb" , header : " <immintrin.h>" .}
753
753
func builtin_rotr16 (value: cushort , shift: cint ): cushort
754
754
{.importc : " __rorw" , header : " <immintrin.h>" .}
@@ -777,7 +777,7 @@ func shiftTypeTo(size: static int, shift: int): auto {.inline.} =
777
777
when (defined (vcc) and (size in [4 , 8 ])) or defined (gcc) or defined (icl):
778
778
cint (shift)
779
779
elif (defined (vcc) and (size in [1 , 2 ])) or (defined (clang) and size == 1 ):
780
- cuchar (shift)
780
+ uint8 (shift)
781
781
elif defined (clang):
782
782
when size == 2 :
783
783
cushort (shift)
@@ -802,7 +802,7 @@ func rotateLeftBits*[T: SomeUnsignedInt](value: T, shift: range[0..(sizeof(T) *
802
802
when useBuiltinsRotate:
803
803
const size = sizeof (T)
804
804
when size == 1 :
805
- builtin_rotl8 (value.cuchar , shiftTypeTo (size, shift)).T
805
+ builtin_rotl8 (value.uint8 , shiftTypeTo (size, shift)).T
806
806
elif size == 2 :
807
807
builtin_rotl16 (value.cushort , shiftTypeTo (size, shift)).T
808
808
elif size == 4 :
@@ -830,7 +830,7 @@ func rotateRightBits*[T: SomeUnsignedInt](value: T, shift: range[0..(sizeof(T) *
830
830
when useBuiltinsRotate:
831
831
const size = sizeof (T)
832
832
when size == 1 :
833
- builtin_rotr8 (value.cuchar , shiftTypeTo (size, shift)).T
833
+ builtin_rotr8 (value.uint8 , shiftTypeTo (size, shift)).T
834
834
elif size == 2 :
835
835
builtin_rotr16 (value.cushort , shiftTypeTo (size, shift)).T
836
836
elif size == 4 :
0 commit comments