summaryrefslogtreecommitdiff
path: root/proto.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2021-07-20 11:57:39 -0600
committerKarl Williamson <khw@cpan.org>2021-07-30 05:41:28 -0600
commit330cd0ce7cbde4175b21369c749c6a3186d2ac77 (patch)
tree499d612a443c881e4504fd595b05a3b6ff4a1cfa /proto.h
parentb5288edf08d3f057f4cb70d49137c0a10da649a4 (diff)
downloadperl-330cd0ce7cbde4175b21369c749c6a3186d2ac77.tar.gz
Create and use 32 and 64 bit msbit_pos() fcns
The existing code to determine the position of the most significant 1 bit in a word is extracted from variant_byte_number(), and generalized to use the deBruijn method previously added that works on any bit in the word, rather than the existing method which looks just at the msb of each byte. The code is moved to a new function in preparation for being called from other places. A U32 version is created, and on 64 bit platforms, a second, parallel, version taking a U64 argument is also created. This is because future commits may care about the word size differences.
Diffstat (limited to 'proto.h')
-rw-r--r--proto.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/proto.h b/proto.h
index 1ced39d14b..92c371a649 100644
--- a/proto.h
+++ b/proto.h
@@ -2152,6 +2152,12 @@ PERL_CALLCONV void Perl_mro_set_mro(pTHX_ struct mro_meta *const meta, SV *const
PERL_CALLCONV SV* Perl_mro_set_private_data(pTHX_ struct mro_meta *const smeta, const struct mro_alg *const which, SV *const data);
#define PERL_ARGS_ASSERT_MRO_SET_PRIVATE_DATA \
assert(smeta); assert(which); assert(data)
+#ifndef PERL_NO_INLINE_FUNCTIONS
+PERL_STATIC_INLINE unsigned Perl_msbit_pos32(U32 word)
+ __attribute__warn_unused_result__;
+#define PERL_ARGS_ASSERT_MSBIT_POS32
+#endif
+
PERL_CALLCONV SV* Perl_multiconcat_stringify(pTHX_ const OP* o);
#define PERL_ARGS_ASSERT_MULTICONCAT_STRINGIFY \
assert(o)
@@ -6724,6 +6730,12 @@ PERL_STATIC_INLINE unsigned Perl_lsbit_pos64(U64 word)
#endif
#ifndef PERL_NO_INLINE_FUNCTIONS
+PERL_STATIC_INLINE unsigned Perl_msbit_pos64(U64 word)
+ __attribute__warn_unused_result__;
+#define PERL_ARGS_ASSERT_MSBIT_POS64
+#endif
+
+#ifndef PERL_NO_INLINE_FUNCTIONS
PERL_STATIC_INLINE unsigned Perl_single_1bit_pos64(U64 word)
__attribute__warn_unused_result__;
#define PERL_ARGS_ASSERT_SINGLE_1BIT_POS64