kernel/lib: Adjustments to use musl's ffs implementation.

This actually has another advantage: if we can use musl sources
in the kernel POSIX support, then we can drop some of the BSD
sources that are used only in the kernel and have a different
implementation in userland (e.g. strtod) and have just one
version for both.
This commit is contained in:
Augustin Cavalier 2022-06-09 18:29:33 -04:00
parent 0afb8a1b49
commit 0d29def7d2
3 changed files with 13 additions and 2 deletions

View File

@ -47,6 +47,14 @@ SEARCH_SOURCE += [ FDirName $(posixSources) time ] ;
SEARCH_SOURCE += [ FDirName $(posixSources) unistd ] ;
SEARCH_SOURCE += [ FDirName $(gnuSources) ] ;
local muslSources =
ffs.c
;
SourceHdrs $(muslSources) :
[ FDirName $(posixSources) musl internal ]
[ FDirName $(posixSources) musl arch $(TARGET_KERNEL_ARCH_DIR) ] ;
KernelMergeObject kernel_lib_posix.o :
# main
kernel_errno.cpp
@ -99,7 +107,6 @@ KernelMergeObject kernel_lib_posix.o :
usergroup.cpp
write.c
# string
ffs.cpp
memchr.c
memcmp.c
memmem.c
@ -129,9 +136,12 @@ KernelMergeObject kernel_lib_posix.o :
strupr.c
stpcpy.c
$(muslSources)
: $(TARGET_KERNEL_PIC_CCFLAGS)
;
SEARCH on [ FGristFiles $(muslSources) ] += [ FDirName $(posixSources) musl misc ] ;
# misc
SEARCH_SOURCE = [ FDirName $(HAIKU_TOP) src kits support ] ;

View File

@ -2,7 +2,7 @@ SubDir HAIKU_TOP src system libroot posix musl misc ;
SubDirSysHdrs [ FDirName $(SUBDIR) .. include ] ;
UseHeaders [ FDirName $(SUBDIR) .. internal ] ;
UseHeaders [ FDirName $(SUBDIR) .. arch $(TARGET_KERNEL_ARCH_DIR) ] ;
UseHeaders [ FDirName $(SUBDIR) .. arch $(TARGET_ARCH) ] ;
local architectureObject ;
for architectureObject in [ MultiArchSubDirSetup ] {

View File

@ -1,5 +1,6 @@
#include "atomic.h"
int ffs(int i);
int ffs(int i)
{
return i ? a_ctz_l(i)+1 : 0;