From d326f841c3c9e9927d5ac56efc202ce7f80a66d1 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 8 Oct 2014 21:03:40 +0000 Subject: [PATCH] * 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. --- winsup/cygwin/common.din | 2 ++ winsup/cygwin/include/cygwin/version.h | 3 ++- winsup/cygwin/syscalls.cc | 29 ++++++++++++-------------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/winsup/cygwin/common.din b/winsup/cygwin/common.din index bf20fde7a..1268f83b1 100644 --- a/winsup/cygwin/common.din +++ b/winsup/cygwin/common.din @@ -374,6 +374,8 @@ feupdateenv SIGFE fexecve SIGFE fflush SIGFE ffs NOSIGFE +ffsl NOSIGFE +ffsll NOSIGFE fgetc SIGFE fgetpos SIGFE fgets SIGFE diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index e0ec40dc4..a5c482da9 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -451,12 +451,13 @@ details. */ 275: Introduce account mapping from Windows account DBs. Add CW_SETENT, CW_GETENT, CW_ENDENT, CW_GETNSSSEP, CW_GETPWSID, CW_GETGRSID, CW_CYGNAME_FROM_WINNAME. + 276: Export ffsl, ffsll. */ /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */ #define CYGWIN_VERSION_API_MAJOR 0 -#define CYGWIN_VERSION_API_MINOR 275 +#define CYGWIN_VERSION_API_MINOR 276 /* There is also a compatibity version number associated with the shared memory regions. It is incremented when incompatible 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 -- 2.43.5