Skip to content

Commit

Permalink
Check for clz clzl availability
Browse files Browse the repository at this point in the history
This defines PERL_USE_CLZ() to be the proper function to call on a
system to execute the equivalent of the count leading zero instruction
on the widest machine word.  It is left undefined if it couldn't find an
appropriate call.

clzll also exists, for long long, but I don't think we have long longs
different from plain long on platforms besides Windows, which doesn't
have this anyway.
  • Loading branch information
khwilliamson committed Jun 14, 2021
1 parent 32fbde8 commit 6fa9fa6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions perl.h
Expand Up @@ -3865,6 +3865,20 @@ hint to the compiler that this condition is likely to be false.
# define __has_builtin(x) 0 /* not a clang style compiler */
#endif

#if PERL_UINTMAX_SIZE == INTSIZE
# if __has_builtin(__builtin_clz) \
|| (defined(__GNUC__) && ( __GNUC__ > 3 \
|| __GNUC__ == 3 && __GNUC_MINOR__ >= 4))
# define PERL_USE_CLZ(x) __builtin_clz(x)
# endif
#elif PERL_UINTMAX_SIZE == LONGSIZE
# if __has_builtin(__builtin_clzl) \
|| (defined(__GNUC__) && ( __GNUC__ > 3 \
|| __GNUC__ == 3 && __GNUC_MINOR__ >= 4))
# define PERL_USE_CLZ(x) __builtin_clzl(x)
# endif
#endif

/*
=for apidoc Am||ASSUME|bool expr
C<ASSUME> is like C<assert()>, but it has a benefit in a release build. It is a
Expand Down

0 comments on commit 6fa9fa6

Please sign in to comment.