diff options
author | Jason Sams <jsams@google.com> | 2013-03-14 16:02:18 -0700 |
---|---|---|
committer | Tim Murray <timmurray@google.com> | 2013-03-15 12:01:29 -0700 |
commit | 110f181b7966212a36ef18016f9b81c7322d0a2f (patch) | |
tree | 70a951e191d53b5a3b483c312f1e691174b0f943 /cpu_ref/rsCpuRuntimeMath.cpp | |
parent | 5a1fa4f6c8efa96badaba98afabdd66bb07486d7 (diff) | |
download | rs-110f181b7966212a36ef18016f9b81c7322d0a2f.tar.gz |
Reduce diffs with compat lib.
Change-Id: Ibfa2c7c7da56d158f424ac343e364feacd0a21da
Diffstat (limited to 'cpu_ref/rsCpuRuntimeMath.cpp')
-rw-r--r-- | cpu_ref/rsCpuRuntimeMath.cpp | 141 |
1 files changed, 0 insertions, 141 deletions
diff --git a/cpu_ref/rsCpuRuntimeMath.cpp b/cpu_ref/rsCpuRuntimeMath.cpp index b72565b1..f66677b8 100644 --- a/cpu_ref/rsCpuRuntimeMath.cpp +++ b/cpu_ref/rsCpuRuntimeMath.cpp @@ -80,13 +80,6 @@ static void SC_MatrixTranspose_2x2(Matrix2x2 *m) { m->transpose(); } -static float SC_randf(float max) { - float r = (float)rand(); - r *= max; - r /= RAND_MAX; - return r; -} - static float SC_randf2(float min, float max) { float r = (float)rand(); r /= RAND_MAX; @@ -94,121 +87,12 @@ static float SC_randf2(float min, float max) { return r; } -static int SC_randi(int max) { - return (int)SC_randf(max); -} - -static int SC_randi2(int min, int max) { - return (int)SC_randf2(min, max); -} - static float SC_frac(float v) { int i = (int)floor(v); return fmin(v - i, 0x1.fffffep-1f); } -static int32_t SC_AtomicCas(volatile int32_t *ptr, int32_t expectedValue, int32_t newValue) { - int32_t prev; - - do { - int32_t ret = android_atomic_release_cas(expectedValue, newValue, ptr); - if (!ret) { - // The android cas return 0 if it wrote the value. This means the - // previous value was the expected value and we can return. - return expectedValue; - } - // We didn't write the value and need to load the "previous" value. - prev = *ptr; - - // A race condition exists where the expected value could appear after our cas failed - // above. In this case loop until we have a legit previous value or the - // write passes. - } while (prev == expectedValue); - return prev; -} - - -static int32_t SC_AtomicInc(volatile int32_t *ptr) { - return android_atomic_inc(ptr); -} - -static int32_t SC_AtomicDec(volatile int32_t *ptr) { - return android_atomic_dec(ptr); -} - -static int32_t SC_AtomicAdd(volatile int32_t *ptr, int32_t value) { - return android_atomic_add(value, ptr); -} - -static int32_t SC_AtomicSub(volatile int32_t *ptr, int32_t value) { - int32_t prev, status; - do { - prev = *ptr; - status = android_atomic_release_cas(prev, prev - value, ptr); - } while (CC_UNLIKELY(status != 0)); - return prev; -} - -static int32_t SC_AtomicAnd(volatile int32_t *ptr, int32_t value) { - return android_atomic_and(value, ptr); -} - -static int32_t SC_AtomicOr(volatile int32_t *ptr, int32_t value) { - return android_atomic_or(value, ptr); -} - -static int32_t SC_AtomicXor(volatile int32_t *ptr, int32_t value) { - int32_t prev, status; - do { - prev = *ptr; - status = android_atomic_release_cas(prev, prev ^ value, ptr); - } while (CC_UNLIKELY(status != 0)); - return prev; -} - -static uint32_t SC_AtomicUMin(volatile uint32_t *ptr, uint32_t value) { - uint32_t prev, status; - do { - prev = *ptr; - uint32_t n = rsMin(value, prev); - status = android_atomic_release_cas((int32_t) prev, (int32_t)n, (volatile int32_t*) ptr); - } while (CC_UNLIKELY(status != 0)); - return prev; -} - -static int32_t SC_AtomicMin(volatile int32_t *ptr, int32_t value) { - int32_t prev, status; - do { - prev = *ptr; - int32_t n = rsMin(value, prev); - status = android_atomic_release_cas(prev, n, ptr); - } while (CC_UNLIKELY(status != 0)); - return prev; -} - -static uint32_t SC_AtomicUMax(volatile uint32_t *ptr, uint32_t value) { - uint32_t prev, status; - do { - prev = *ptr; - uint32_t n = rsMax(value, prev); - status = android_atomic_release_cas((int32_t) prev, (int32_t) n, (volatile int32_t*) ptr); - } while (CC_UNLIKELY(status != 0)); - return prev; -} - -static int32_t SC_AtomicMax(volatile int32_t *ptr, int32_t value) { - int32_t prev, status; - do { - prev = *ptr; - int32_t n = rsMax(value, prev); - status = android_atomic_release_cas(prev, n, ptr); - } while (CC_UNLIKELY(status != 0)); - return prev; -} - - - ////////////////////////////////////////////////////////////////////////////// // Class implementation ////////////////////////////////////////////////////////////////////////////// @@ -301,34 +185,9 @@ static RsdCpuReference::CpuSymbol gSyms[] = { { "_Z17rsMatrixTransposeP12rs_matrix2x2", (void *)&SC_MatrixTranspose_2x2, true }, // RS Math - { "_Z6rsRandi", (void *)&SC_randi, true }, - { "_Z6rsRandii", (void *)&SC_randi2, true }, - { "_Z6rsRandf", (void *)&SC_randf, true }, { "_Z6rsRandff", (void *)&SC_randf2, true }, { "_Z6rsFracf", (void *)&SC_frac, true }, - // Atomics - { "_Z11rsAtomicIncPVi", (void *)&SC_AtomicInc, true }, - { "_Z11rsAtomicIncPVj", (void *)&SC_AtomicInc, true }, - { "_Z11rsAtomicDecPVi", (void *)&SC_AtomicDec, true }, - { "_Z11rsAtomicDecPVj", (void *)&SC_AtomicDec, true }, - { "_Z11rsAtomicAddPVii", (void *)&SC_AtomicAdd, true }, - { "_Z11rsAtomicAddPVjj", (void *)&SC_AtomicAdd, true }, - { "_Z11rsAtomicSubPVii", (void *)&SC_AtomicSub, true }, - { "_Z11rsAtomicSubPVjj", (void *)&SC_AtomicSub, true }, - { "_Z11rsAtomicAndPVii", (void *)&SC_AtomicAnd, true }, - { "_Z11rsAtomicAndPVjj", (void *)&SC_AtomicAnd, true }, - { "_Z10rsAtomicOrPVii", (void *)&SC_AtomicOr, true }, - { "_Z10rsAtomicOrPVjj", (void *)&SC_AtomicOr, true }, - { "_Z11rsAtomicXorPVii", (void *)&SC_AtomicXor, true }, - { "_Z11rsAtomicXorPVjj", (void *)&SC_AtomicXor, true }, - { "_Z11rsAtomicMinPVii", (void *)&SC_AtomicMin, true }, - { "_Z11rsAtomicMinPVjj", (void *)&SC_AtomicUMin, true }, - { "_Z11rsAtomicMaxPVii", (void *)&SC_AtomicMax, true }, - { "_Z11rsAtomicMaxPVjj", (void *)&SC_AtomicUMax, true }, - { "_Z11rsAtomicCasPViii", (void *)&SC_AtomicCas, true }, - { "_Z11rsAtomicCasPVjjj", (void *)&SC_AtomicCas, true }, - { NULL, NULL, false } }; |