From: Michael Jerris Date: Tue, 15 May 2007 17:22:49 +0000 (+0000) Subject: fix the fallback atomic operation implementation for use on arm devices. X-Git-Tag: v1.0-beta1~303 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4aeecd93b5d808a9b4751cf345bf4810b22a4a70;p=thirdparty%2Ffreeswitch.git 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 --- diff --git a/libs/js/nsprpub/pr/src/misc/pratom.c b/libs/js/nsprpub/pr/src/misc/pratom.c index 24028e56bd..a903e98a50 100644 --- a/libs/js/nsprpub/pr/src/misc/pratom.c +++ b/libs/js/nsprpub/pr/src/misc/pratom.c @@ -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) /*