mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 05:05:00 +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
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <AK/BuiltinWrappers.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -51,4 +52,22 @@ int strncasecmp(char const* s1, char const* s2, size_t n)
|
||||||
} while (--n);
|
} while (--n);
|
||||||
return 0;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,5 +15,8 @@ int strcasecmp(char const*, char const*);
|
||||||
int strncasecmp(char const*, char const*, size_t);
|
int strncasecmp(char const*, char const*, size_t);
|
||||||
void bzero(void*, size_t);
|
void bzero(void*, size_t);
|
||||||
void bcopy(void const*, void*, size_t);
|
void bcopy(void const*, void*, size_t);
|
||||||
|
int ffs(int);
|
||||||
|
int ffsl(long int);
|
||||||
|
int ffsll(long long int);
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue