don't define a local function with the same name as a library function (bug #4239)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5663 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Kevin P. Fleming
2005-05-15 03:18:16 +00:00
parent 0356b70224
commit 977fd5a157
2 changed files with 18 additions and 8 deletions

View File

@@ -214,7 +214,7 @@ static int fmult(int an, int srn)
int retval; int retval;
anmag = (an > 0) ? an : ((-an) & 0x1FFF); anmag = (an > 0) ? an : ((-an) & 0x1FFF);
anexp = log2(anmag) - 5; anexp = ilog2(anmag) - 5;
anmant = (anmag == 0) ? 32 : anmant = (anmag == 0) ? 32 :
(anexp >= 0) ? anmag >> anexp : anmag << -anexp; (anexp >= 0) ? anmag >> anexp : anmag << -anexp;
wanexp = anexp + ((srn >> 6) & 0xF) - 13; wanexp = anexp + ((srn >> 6) & 0xF) - 13;
@@ -297,7 +297,7 @@ static int quantize(
* Compute base 2 log of 'd', and store in 'dl'. * Compute base 2 log of 'd', and store in 'dl'.
*/ */
dqm = abs(d); dqm = abs(d);
exp = log2(dqm); exp = ilog2(dqm);
if (exp < 0) if (exp < 0)
exp = 0; exp = 0;
mant = ((dqm << 7) >> exp) & 0x7F; /* Fractional portion. */ mant = ((dqm << 7) >> exp) & 0x7F; /* Fractional portion. */
@@ -515,7 +515,7 @@ static void update(
if (mag == 0) { if (mag == 0) {
state_ptr->dq[0] = (dq >= 0) ? 0x20 : 0x20 - 0x400; state_ptr->dq[0] = (dq >= 0) ? 0x20 : 0x20 - 0x400;
} else { } else {
exp = log2(mag) + 1; exp = ilog2(mag) + 1;
state_ptr->dq[0] = (dq >= 0) ? state_ptr->dq[0] = (dq >= 0) ?
(exp << 6) + ((mag << 6) >> exp) : (exp << 6) + ((mag << 6) >> exp) :
(exp << 6) + ((mag << 6) >> exp) - 0x400; (exp << 6) + ((mag << 6) >> exp) - 0x400;
@@ -530,11 +530,11 @@ static void update(
if (sr == 0) { if (sr == 0) {
state_ptr->sr[0] = 0x20; state_ptr->sr[0] = 0x20;
} else if (sr > 0) { } else if (sr > 0) {
exp = log2(sr) + 1; exp = ilog2(sr) + 1;
state_ptr->sr[0] = (exp << 6) + ((sr << 6) >> exp); state_ptr->sr[0] = (exp << 6) + ((sr << 6) >> exp);
} else if (sr > -0x8000) { } else if (sr > -0x8000) {
mag = -sr; mag = -sr;
exp = log2(mag) + 1; exp = ilog2(mag) + 1;
state_ptr->sr[0] = (exp << 6) + ((mag << 6) >> exp) - 0x400; state_ptr->sr[0] = (exp << 6) + ((mag << 6) >> exp) - 0x400;
} else } else
state_ptr->sr[0] = 0x20 - 0x400; state_ptr->sr[0] = 0x20 - 0x400;

View File

@@ -24,7 +24,7 @@
#if defined(WANT_ASM) && defined(_MSC_VER) && defined(_M_IX86) #if defined(WANT_ASM) && defined(_MSC_VER) && defined(_M_IX86)
/* MS C Inline Asm */ /* MS C Inline Asm */
# pragma warning( disable : 4035 ) # pragma warning( disable : 4035 )
static inline int log2(int val) { __asm static inline int ilog2(int val) { __asm
{ {
xor eax, eax xor eax, eax
dec eax dec eax
@@ -33,7 +33,7 @@ static inline int log2(int val) { __asm
# pragma warning( default : 4035 ) # pragma warning( default : 4035 )
#elif defined(WANT_ASM) && defined(__GNUC__) && (defined(__i386__) || defined(i386)) #elif defined(WANT_ASM) && defined(__GNUC__) && (defined(__i386__) || defined(i386))
/* GNU Inline Asm */ /* GNU Inline Asm */
static inline int log2(int val) static inline int ilog2(int val)
{ {
int a; int a;
__asm__ __asm__
@@ -48,12 +48,22 @@ static inline int log2(int val)
); );
return a; return a;
} }
#elif defined(WANT_ASM) && defined(__GNUC__) && defined(__powerpc__)
static inline int ilog2(int val)
{
int a;
__asm__ ("cntlzw %0,%1"
: "=r" (a)
: "r" (val)
);
return 31-a;
}
#else #else
/* no ASM for this compiler and/or platform */ /* no ASM for this compiler and/or platform */
/* rather slow base 2 log computation /* rather slow base 2 log computation
* Using looped shift. * Using looped shift.
*/ */
static inline int log2(int val) static inline int ilog2(int val)
{ {
int i; int i;
for (i = -1; val; ++i, val >>= 1) for (i = -1; val; ++i, val >>= 1)