POSIX: add ffsl and ffsll from musl sources.

appeared in issue 8:
https://pubs.opengroup.org/onlinepubs/9799919799/functions/ffs.html
Change-Id: Ic382498c3e2d6138aedbeb88578882457ee875ee
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9836
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Jérôme Duval
2025-11-11 16:50:29 +00:00
committed by waddlesplash
parent 11d8ab2a71
commit b739532218
7 changed files with 22 additions and 14 deletions
+3 -1
View File
@@ -14,7 +14,9 @@
extern "C" {
#endif
static __inline__ int ffs(int i) { return __builtin_ffs(i); }
extern int ffs(int i);
extern int ffsl(long i);
extern int ffsll(long long i);
extern int strcasecmp(const char *string1, const char *string2);
extern int strncasecmp(const char *string1, const char *string2,
@@ -28,18 +28,6 @@ static __inline int imin(int a, int b) { return (a < b ? a : b); }
extern int abs(int a);
static __inline __pure2 int
ffsl(long mask)
{
return (__builtin_ffsl((u_long)mask));
}
static __inline __pure2 int
ffsll(long long mask)
{
return (__builtin_ffsll((unsigned long long)mask));
}
static __inline __pure2 int
fls(int mask)
{
+2
View File
@@ -50,6 +50,8 @@ SEARCH_SOURCE += [ FDirName $(posixSources) musl string ] ;
local muslSources =
ffs.c
ffsl.c
ffsll.c
rand.c
rand_r.c
;
@@ -14,6 +14,8 @@ for architectureObject in [ MultiArchSubDirSetup ] {
basename.c
dirname.c
ffs.c
ffsl.c
ffsll.c
ftw.c
getsubopt.c
nftw.c
+1 -1
View File
@@ -1,6 +1,6 @@
#include <strings.h>
#include "atomic.h"
int ffs(int i);
int ffs(int i)
{
return i ? a_ctz_l(i)+1 : 0;
@@ -0,0 +1,7 @@
#include <strings.h>
#include "atomic.h"
int ffsl(long i)
{
return i ? a_ctz_l(i)+1 : 0;
}
@@ -0,0 +1,7 @@
#include <strings.h>
#include "atomic.h"
int ffsll(long long i)
{
return i ? a_ctz_64(i)+1 : 0;
}