summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/syscalls.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2014-10-08 21:03:40 +0000
committerCorinna Vinschen <corinna@vinschen.de>2014-10-08 21:03:40 +0000
commitd326f841c3c9e9927d5ac56efc202ce7f80a66d1 (patch)
tree0dd00f29df1f545d37bc4f854c38acb252abfcfd /winsup/cygwin/syscalls.cc
parent2fb56bbfaa9f6cc2787bb1f50a666bf65e7d227a (diff)
downloadcygnal-d326f841c3c9e9927d5ac56efc202ce7f80a66d1.tar.gz
cygnal-d326f841c3c9e9927d5ac56efc202ce7f80a66d1.tar.bz2
cygnal-d326f841c3c9e9927d5ac56efc202ce7f80a66d1.zip
* common.din (ffsl): Export.
(ffsll): Export. * syscalls.cc (ffs): Implement using GCC intrinsic. (ffsl): Ditto. (ffsll): Ditto. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r--winsup/cygwin/syscalls.cc29
1 files changed, 13 insertions, 16 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 044e0036a..933bfe464 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -3836,22 +3836,19 @@ nice (int incr)
extern "C" int
ffs (int i)
{
- static const unsigned char table[] =
- {
- 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
- 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
- 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
- 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
- 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
- };
- unsigned x = i & -i;
-
- int a = x <= 0xffff ? (x <= 0xff ? 0 : 8) : (x <= 0xffffff ? 16 : 24);
-
- return table[x >> a] + a;
+ return __builtin_ffs (i);
+}
+
+extern "C" int
+ffsl (long i)
+{
+ return __builtin_ffsl (i);
+}
+
+extern "C" int
+ffsll (long long i)
+{
+ return __builtin_ffsll (i);
}
static void