1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-02-04 07:33:07 +00:00

Replaces integerlength(n) implementation with call to fls(n) and makes it static

This commit is contained in:
Nick Briggs
2025-07-17 18:52:15 -07:00
parent 0a6f8ac72b
commit 1ffd1ba7cb
2 changed files with 3 additions and 17 deletions

View File

@@ -2,7 +2,6 @@
#define GCFINALDEFS_H 1 #define GCFINALDEFS_H 1
#include "lispemul.h" /* for LispPTR, DLword */ #include "lispemul.h" /* for LispPTR, DLword */
void printarrayblock(LispPTR base); void printarrayblock(LispPTR base);
int integerlength(unsigned int n);
LispPTR findptrsbuffer(LispPTR ptr); LispPTR findptrsbuffer(LispPTR ptr);
LispPTR releasingvmempage(LispPTR ptr); LispPTR releasingvmempage(LispPTR ptr);
LispPTR checkarrayblock(LispPTR base, LispPTR free, LispPTR onfreelist); LispPTR checkarrayblock(LispPTR base, LispPTR free, LispPTR onfreelist);

View File

@@ -43,6 +43,7 @@
/*************************************************************************/ /*************************************************************************/
#include <stdio.h> // for printf #include <stdio.h> // for printf
#include <strings.h> // for fls
#include "address.h" // for HILOC #include "address.h" // for HILOC
#include "adr68k.h" // for NativeAligned4FromLAddr, LAddrFromNative #include "adr68k.h" // for NativeAligned4FromLAddr, LAddrFromNative
#include "array.h" // for arrayblock, ARRAYBLOCKTRAILERCELLS, MAXBUCK... #include "array.h" // for arrayblock, ARRAYBLOCKTRAILERCELLS, MAXBUCK...
@@ -123,24 +124,10 @@ struct buf {
#endif /* BIGVM */ #endif /* BIGVM */
#endif /* BYTESWAP */ #endif /* BYTESWAP */
/************* The following procedure is common !! **************************/ static int integerlength(unsigned int n) {
return (fls(n));
int integerlength(unsigned int n) {
int cnt;
if (n <= 2)
return (n);
else {
cnt = 1;
do {
cnt++;
n = (n >> 1);
} while (n != 1);
return (cnt);
}
} }
/************* The above procedure is common !! **************************/
/************************************************************************/ /************************************************************************/
/* */ /* */
/* f i n d p t r s b u f f e r */ /* f i n d p t r s b u f f e r */