File tree Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change 4343/*************************************************************************/
4444
4545#include <stdio.h> // for printf
46- #include <strings.h> // for fls
4746#include "address.h" // for HILOC
4847#include "adr68k.h" // for NativeAligned4FromLAddr, LAddrFromNative
4948#include "array.h" // for arrayblock, ARRAYBLOCKTRAILERCELLS, MAXBUCK...
@@ -128,7 +127,29 @@ struct buffer {
128127#endif /* BYTESWAP */
129128
130129static int integerlength (unsigned int n ) {
131- return (fls (n ));
130+ int p = 0 ;
131+
132+ if (n <= 2 ) return (n ); /* easy case */
133+ if (n >= 65536 ) {
134+ n >>= 16 ;
135+ p += 16 ;
136+ }
137+ if (n >= 256 ) {
138+ n >>= 8 ;
139+ p += 8 ;
140+ }
141+ if (n >= 16 ) {
142+ n >>= 4 ;
143+ p += 4 ;
144+ }
145+ if (n >= 4 ) {
146+ n >>= 2 ;
147+ p += 2 ;
148+ }
149+ if (n >= 2 ) {
150+ p += 1 ;
151+ }
152+ return (p + 1 );
132153}
133154
134155/************************************************************************/
You can’t perform that action at this time.
0 commit comments