Skip to content

Commit

Permalink
Add macros to call the appropriate ffs() function
Browse files Browse the repository at this point in the history
ffs finds the least significant 1 bit.  POSIX defines it only for
integer arguments, but many implementations have a version for longs as
well.

This commit defines a macro for the appropriate one for this platform,
if any.  Future commits will use this.
  • Loading branch information
khwilliamson committed Jun 6, 2021
1 parent d4d6ddf commit 7699fce
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions perl.h
Expand Up @@ -3872,12 +3872,18 @@ hint to the compiler that this condition is likely to be false.
|| __GNUC__ == 3 && __GNUC_MINOR__ >= 4))
# define PERL_USE_CLZ(x) __builtin_clz(x)
# endif
# ifdef HAS_FFS
# define PERL_USE_FFS(x) ffs(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
# ifdef HAS_FFS
# define PERL_USE_FFS(x) ffsl(x)
# endif
#endif

/*
Expand Down

0 comments on commit 7699fce

Please sign in to comment.