From ecc082c61b6da9a8b2ae0c07aa3331673834d94a Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Thu, 31 Jul 2014 02:38:23 -0400 Subject: implement ffsl and ffsll functions per the resolution of Austin Group issue #617, these are accepted for XSI option in POSIX future and thus I'm treating them as standard functions. --- include/strings.h | 2 ++ src/misc/ffsl.c | 7 +++++++ src/misc/ffsll.c | 7 +++++++ 3 files changed, 16 insertions(+) create mode 100644 src/misc/ffsl.c create mode 100644 src/misc/ffsll.c diff --git a/include/strings.h b/include/strings.h index 4d7d69c3..db0960b4 100644 --- a/include/strings.h +++ b/include/strings.h @@ -22,6 +22,8 @@ char *rindex (const char *, int); #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) int ffs (int); +int ffsl (long); +int ffsll (long long); #endif int strcasecmp (const char *, const char *); diff --git a/src/misc/ffsl.c b/src/misc/ffsl.c new file mode 100644 index 00000000..0105c66a --- /dev/null +++ b/src/misc/ffsl.c @@ -0,0 +1,7 @@ +#include +#include "atomic.h" + +int ffsl(long i) +{ + return i ? a_ctz_l(i)+1 : 0; +} diff --git a/src/misc/ffsll.c b/src/misc/ffsll.c new file mode 100644 index 00000000..0c5ced82 --- /dev/null +++ b/src/misc/ffsll.c @@ -0,0 +1,7 @@ +#include +#include "atomic.h" + +int ffsll(long long i) +{ + return i ? a_ctz_64(i)+1 : 0; +} -- cgit v1.2.1