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
+11 -1
View File
@@ -47,6 +47,14 @@ SEARCH_SOURCE += [ FDirName $(posixSources) time ] ;
SEARCH_SOURCE += [ FDirName $(posixSources) unistd ] ; SEARCH_SOURCE += [ FDirName $(posixSources) unistd ] ;
SEARCH_SOURCE += [ FDirName $(gnuSources) ] ; 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 : KernelMergeObject kernel_lib_posix.o :
# main # main
kernel_errno.cpp kernel_errno.cpp
@@ -99,7 +107,6 @@ KernelMergeObject kernel_lib_posix.o :
usergroup.cpp usergroup.cpp
write.c write.c
# string # string
ffs.cpp
memchr.c memchr.c
memcmp.c memcmp.c
memmem.c memmem.c
@@ -129,9 +136,12 @@ KernelMergeObject kernel_lib_posix.o :
strupr.c strupr.c
stpcpy.c stpcpy.c
$(muslSources)
: $(TARGET_KERNEL_PIC_CCFLAGS) : $(TARGET_KERNEL_PIC_CCFLAGS)
; ;
SEARCH on [ FGristFiles $(muslSources) ] += [ FDirName $(posixSources) musl misc ] ;
# misc # misc
SEARCH_SOURCE = [ FDirName $(HAIKU_TOP) src kits support ] ; SEARCH_SOURCE = [ FDirName $(HAIKU_TOP) src kits support ] ;
+1 -1
View File
@@ -2,7 +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) ] ; UseHeaders [ FDirName $(SUBDIR) .. arch $(TARGET_ARCH) ] ;
local architectureObject ; local architectureObject ;
for architectureObject in [ MultiArchSubDirSetup ] { for architectureObject in [ MultiArchSubDirSetup ] {
+1
View File
@@ -1,5 +1,6 @@
#include "atomic.h" #include "atomic.h"
int ffs(int i);
int ffs(int i) int ffs(int i)
{ {
return i ? a_ctz_l(i)+1 : 0; return i ? a_ctz_l(i)+1 : 0;