aboutsummaryrefslogtreecommitdiffstats
path: root/codecs/log2comp.h
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-05-15 03:18:16 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-05-15 03:18:16 +0000
commit7998612185e580fcf23995ed8220adc5ba214c08 (patch)
tree945386a088136d7eebb75e430275159791074815 /codecs/log2comp.h
parentf5c1139da439fb8cb79ed06fd958658cef50ef89 (diff)
don't define a local function with the same name as a library function (bug #4239)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5663 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'codecs/log2comp.h')
-rwxr-xr-xcodecs/log2comp.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/codecs/log2comp.h b/codecs/log2comp.h
index 1a42f35d7..9a669c9c8 100755
--- a/codecs/log2comp.h
+++ b/codecs/log2comp.h
@@ -24,7 +24,7 @@
#if defined(WANT_ASM) && defined(_MSC_VER) && defined(_M_IX86)
/* MS C Inline Asm */
# pragma warning( disable : 4035 )
-static inline int log2(int val) { __asm
+static inline int ilog2(int val) { __asm
{
xor eax, eax
dec eax
@@ -33,7 +33,7 @@ static inline int log2(int val) { __asm
# pragma warning( default : 4035 )
#elif defined(WANT_ASM) && defined(__GNUC__) && (defined(__i386__) || defined(i386))
/* GNU Inline Asm */
-static inline int log2(int val)
+static inline int ilog2(int val)
{
int a;
__asm__
@@ -48,12 +48,22 @@ static inline int log2(int val)
);
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
/* no ASM for this compiler and/or platform */
/* rather slow base 2 log computation
* Using looped shift.
*/
-static inline int log2(int val)
+static inline int ilog2(int val)
{
int i;
for (i = -1; val; ++i, val >>= 1)