mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-25 15:08:53 +00:00
use a compiler builtin (which uses processor instructions) for this operation
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@33933 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1334,12 +1334,13 @@ static struct ast_channel *agent_request(const char *type, int format, void *dat
|
|||||||
return chan;
|
return chan;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int powerof(unsigned int v)
|
static force_inline int powerof(unsigned int d)
|
||||||
{
|
{
|
||||||
int x;
|
int x = ffs(d);
|
||||||
for (x=0;x<32;x++) {
|
|
||||||
if (v & (1 << x)) return x;
|
if (x)
|
||||||
}
|
return x - 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
translate.c
14
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 */
|
/*! \brief returns the index of the lowest bit set */
|
||||||
static int powerof(int d)
|
static force_inline int powerof(unsigned int d)
|
||||||
{
|
{
|
||||||
int x;
|
int x = ffs(d);
|
||||||
for (x = 0; x < MAX_FORMAT; x++)
|
|
||||||
if ((1 << x) & d)
|
if (x)
|
||||||
return x;
|
return x - 1;
|
||||||
ast_log(LOG_WARNING, "Powerof %d: No power??\n", d);
|
|
||||||
|
ast_log(LOG_WARNING, "No bits set? %d\n", d);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user