mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:04:59 +00:00
LibC: Add ffs{,l,ll}
Those are wrappers around AK::bit_scan_forward().
This commit is contained in:
parent
aa788581f2
commit
09a2db89c9
2 changed files with 22 additions and 0 deletions
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/BuiltinWrappers.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
@ -51,4 +52,22 @@ int strncasecmp(char const* s1, char const* s2, size_t n)
|
|||
} while (--n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/009696799/functions/ffs.html
|
||||
int ffs(int i)
|
||||
{
|
||||
return bit_scan_forward(i);
|
||||
}
|
||||
|
||||
// https://linux.die.net/man/3/ffsl (GNU extension)
|
||||
int ffsl(long int i)
|
||||
{
|
||||
return bit_scan_forward(i);
|
||||
}
|
||||
|
||||
// https://linux.die.net/man/3/ffsll (GNU extension)
|
||||
int ffsll(long long int i)
|
||||
{
|
||||
return bit_scan_forward(i);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue