klib,int64: implement clzsi2() and ctzsi2()
* this is to support 64-bit divisions in fceux
This commit is contained in:
parent
a149aba788
commit
bbf856f3fd
|
@ -283,17 +283,19 @@ __umoddi3(du_int a, du_int b)
|
|||
}
|
||||
|
||||
|
||||
#include <klib.h>
|
||||
|
||||
// for more details, refer to
|
||||
// https://gcc.gnu.org/onlinedocs/gccint/Integer-library-routines.html
|
||||
|
||||
// only use for linking
|
||||
|
||||
int __clzsi2 (unsigned int a) {
|
||||
_halt(1);
|
||||
if (a == 0) return 0;
|
||||
int bit = 31;
|
||||
while ((a & (1 << bit)) == 0) bit --;
|
||||
return bit;
|
||||
}
|
||||
|
||||
int __ctzsi2 (unsigned int a) {
|
||||
_halt(1);
|
||||
if (a == 0) return 0;
|
||||
int bit = 0;
|
||||
while ((a & (1 << bit)) == 0) bit ++;
|
||||
return bit;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue