提交 4aeecd93 authored 作者: Michael Jerris's avatar Michael Jerris

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
上级 dbd2bdc8
......@@ -54,6 +54,50 @@
*/
#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)
/*
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论