From 154b857c95773f7ea7fa3b5cb5ad90b0b06c2760 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Mon, 30 Mar 2009 23:17:11 +0000 Subject: [PATCH] * ffsll.c (ffsll): Correct implementation. --- gold/ChangeLog | 4 ++++ gold/ffsll.c | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/gold/ChangeLog b/gold/ChangeLog index b6ad2e29420..0726507999e 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,7 @@ +2009-03-30 Ian Lance Taylor + + * ffsll.c (ffsll): Correct implementation. + 2009-03-27 Ian Lance Taylor * ffsll.c: New file. diff --git a/gold/ffsll.c b/gold/ffsll.c index aeae845f094..b247bc30af3 100644 --- a/gold/ffsll.c +++ b/gold/ffsll.c @@ -36,8 +36,13 @@ ffsll (long long arg) unsigned long long i; int ret; - ret = 0; - for (i = (unsigned long long) arg; i != 0; i >>= 1) - ++ret; + if (arg == 0) + ret = 0; + else + { + ret = 1; + for (i = (unsigned long long) arg; (i & 1) == 0; i >>= 1) + ++ret; + } return ret; } -- 2.30.2