summaryrefslogtreecommitdiff
path: root/embed.fnc
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 /embed.fnc
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 'embed.fnc')
-rw-r--r--embed.fnc2
1 files changed, 2 insertions, 0 deletions
diff --git a/embed.fnc b/embed.fnc
index b4e5870118..a883f0cfac 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -1143,9 +1143,11 @@ ATidRp |bool |is_utf8_invariant_string_loc|NN const U8* const s \
|NULLOK const U8 ** ep
CTiRp |unsigned|single_1bit_pos32|U32 word
CTiRp |unsigned|lsbit_pos32|U32 word
+CTiRp |unsigned|msbit_pos32|U32 word
#ifdef U64TYPE /* HAS_QUAD undefined outside of core */
CTiRp |unsigned|single_1bit_pos64|U64 word
CTiRp |unsigned|lsbit_pos64|U64 word
+CTiRp |unsigned|msbit_pos64|U64 word
#endif
#ifndef EBCDIC
CTiRp |unsigned int|variant_byte_number|PERL_UINTMAX_T word