aboutsummaryrefslogtreecommitdiffstats
path: root/translate.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-06-13 20:59:15 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-06-13 20:59:15 +0000
commit7d7f932c01b560eeaf9aae975898ab360e86a8ea (patch)
treecbe430cf815888e54ca03d695d90c0080af272a0 /translate.c
parent8f5e92b24d534e308859bb23b11efbed0858f52e (diff)
use a compiler builtin (which uses processor instructions) for this operation
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@33933 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'translate.c')
-rw-r--r--translate.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/translate.c b/translate.c
index 6bb313871..256130c82 100644
--- a/translate.c
+++ b/translate.c
@@ -74,13 +74,15 @@ static struct translator_path tr_matrix[MAX_FORMAT][MAX_FORMAT];
*/
/*! \brief returns the index of the lowest bit set */
-static int powerof(int d)
+static force_inline int powerof(unsigned int d)
{
- int x;
- for (x = 0; x < MAX_FORMAT; x++)
- if ((1 << x) & d)
- return x;
- ast_log(LOG_WARNING, "Powerof %d: No power??\n", d);
+ int x = ffs(d);
+
+ if (x)
+ return x - 1;
+
+ ast_log(LOG_WARNING, "No bits set? %d\n", d);
+
return -1;
}