libroot: Replace custom ffs implementation with musl's.
It already has a per-arch implementation or a fallback in musl's own arch_atomic.h, which we already imported so we might as well leverage it.
This commit is contained in:
@@ -2,6 +2,7 @@ SubDir HAIKU_TOP src system libroot posix musl misc ;
|
|||||||
|
|
||||||
SubDirSysHdrs [ FDirName $(SUBDIR) .. include ] ;
|
SubDirSysHdrs [ FDirName $(SUBDIR) .. include ] ;
|
||||||
UseHeaders [ FDirName $(SUBDIR) .. internal ] ;
|
UseHeaders [ FDirName $(SUBDIR) .. internal ] ;
|
||||||
|
UseHeaders [ FDirName $(SUBDIR) .. arch $(TARGET_KERNEL_ARCH_DIR) ] ;
|
||||||
|
|
||||||
local architectureObject ;
|
local architectureObject ;
|
||||||
for architectureObject in [ MultiArchSubDirSetup ] {
|
for architectureObject in [ MultiArchSubDirSetup ] {
|
||||||
@@ -10,6 +11,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
|
|||||||
|
|
||||||
MergeObject <$(architecture)>posix_musl_misc.o :
|
MergeObject <$(architecture)>posix_musl_misc.o :
|
||||||
a64l.c
|
a64l.c
|
||||||
|
ffs.c
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#include "atomic.h"
|
||||||
|
|
||||||
|
int ffs(int i)
|
||||||
|
{
|
||||||
|
return i ? a_ctz_l(i)+1 : 0;
|
||||||
|
}
|
||||||
@@ -20,7 +20,6 @@ for architectureObject in [ MultiArchSubDirSetup ] {
|
|||||||
bcmp.c
|
bcmp.c
|
||||||
bcopy.c
|
bcopy.c
|
||||||
bzero.c
|
bzero.c
|
||||||
ffs.cpp
|
|
||||||
memccpy.c
|
memccpy.c
|
||||||
memchr.c
|
memchr.c
|
||||||
memcmp.c
|
memcmp.c
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2020, Adrien Destugues <[email protected]>.
|
|
||||||
* Distributed under the terms of the MIT License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// find first (least significant) set bit
|
|
||||||
extern "C" int
|
|
||||||
ffs(int value)
|
|
||||||
{
|
|
||||||
#ifdef __riscv
|
|
||||||
// TODO: As of this writing, gcc 8.x seems
|
|
||||||
// to have an issue with infinite recursion.
|
|
||||||
// Re-examine in future GCC updates
|
|
||||||
int bit;
|
|
||||||
if (value == 0)
|
|
||||||
return 0;
|
|
||||||
for (bit = 1; !(value & 1); bit++)
|
|
||||||
value >>= 1;
|
|
||||||
return bit;
|
|
||||||
#else
|
|
||||||
return __builtin_ffs(value);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user