Skip to content

Commit 3f167f5

Browse files
committed
zig.h: enable popcount, ctz, clz
- netbsd and dragonfly are slow to upgrade system compiler versions - they lack support for preprocessor tests like `__has_builtin` - yet they have support for popcount, ctz, clz - for now, just assume __builtin_{clz,ctz,popcount} is available - tests for these builtins are going to be important wrt other archs *** THIS IS TEMPORARY AND A BETTER SOLUTION IS NEEDED ***
1 parent 5b30902 commit 3f167f5

File tree

1 file changed

+0
-6
lines changed

1 file changed

+0
-6
lines changed

lib/zig.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,6 @@ typedef zig_c_ulong zig_Builtin64;
917917
typedef zig_c_ulonglong zig_Builtin64;
918918
#endif
919919

920-
#if zig_has_builtin(clz)
921920
#define zig_builtin_clz(w) \
922921
static inline zig_u8 zig_clz_u##w(zig_u##w val, zig_u8 bits) { \
923922
if (val == 0) return bits; \
@@ -931,9 +930,7 @@ zig_builtin_clz(8)
931930
zig_builtin_clz(16)
932931
zig_builtin_clz(32)
933932
zig_builtin_clz(64)
934-
#endif
935933

936-
#if zig_has_builtin(ctz)
937934
#define zig_builtin_ctz(w) \
938935
static inline zig_u8 zig_ctz_u##w(zig_u##w val, zig_u8 bits) { \
939936
if (val == 0) return bits; \
@@ -947,9 +944,7 @@ zig_builtin_ctz(8)
947944
zig_builtin_ctz(16)
948945
zig_builtin_ctz(32)
949946
zig_builtin_ctz(64)
950-
#endif
951947

952-
#if zig_has_builtin(popcount)
953948
#define zig_builtin_popcount(w) \
954949
static inline zig_u8 zig_popcount_u##w(zig_u##w val, zig_u8 bits) { \
955950
(void)bits; \
@@ -964,7 +959,6 @@ zig_builtin_popcount(8)
964959
zig_builtin_popcount(16)
965960
zig_builtin_popcount(32)
966961
zig_builtin_popcount(64)
967-
#endif
968962

969963
static inline zig_u8 zig_byte_swap_u8(zig_u8 val, zig_u8 bits) {
970964
return zig_wrap_u8(val >> (8 - bits), bits);

0 commit comments

Comments
 (0)