fix the fallback atomic operation implementation for use on arm devices.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5186 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2007-05-15 17:22:49 +00:00
parent dbd2bdc89c
commit 4aeecd93b5
1 changed files with 44 additions and 0 deletions

View File

@ -54,6 +54,50 @@
*/ */
#if !defined(_PR_HAVE_ATOMIC_OPS) #if !defined(_PR_HAVE_ATOMIC_OPS)
#include "prbit.h"
/*
** Compute the log of the least power of 2 greater than or equal to n
*/
PR_IMPLEMENT(PRIntn) PR_CeilingLog2(PRUint32 n)
{
PRIntn log2 = 0;
if (n & (n-1))
log2++;
if (n >> 16)
log2 += 16, n >>= 16;
if (n >> 8)
log2 += 8, n >>= 8;
if (n >> 4)
log2 += 4, n >>= 4;
if (n >> 2)
log2 += 2, n >>= 2;
if (n >> 1)
log2++;
return log2;
}
/*
** Compute the log of the greatest power of 2 less than or equal to n.
** This really just finds the highest set bit in the word.
*/
PR_IMPLEMENT(PRIntn) PR_FloorLog2(PRUint32 n)
{
PRIntn log2 = 0;
if (n >> 16)
log2 += 16, n >>= 16;
if (n >> 8)
log2 += 8, n >>= 8;
if (n >> 4)
log2 += 4, n >>= 4;
if (n >> 2)
log2 += 2, n >>= 2;
if (n >> 1)
log2++;
return log2;
}
#if defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS) #if defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS)
/* /*