[rtems commit] bsps/powerpc: Add ppc_count_leading_zeros()
Sebastian Huber
sebh at rtems.org
Tue Jul 9 14:36:12 UTC 2013
Module: rtems
Branch: master
Commit: 4fe3ad2f99fc21db2f58c9bfb2a5e8cf5237cc63
Changeset: http://git.rtems.org/rtems/commit/?id=4fe3ad2f99fc21db2f58c9bfb2a5e8cf5237cc63
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Tue Jul 9 16:37:32 2013 +0200
bsps/powerpc: Add ppc_count_leading_zeros()
---
.../powerpc/shared/include/powerpc-utility.h | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/c/src/lib/libcpu/powerpc/shared/include/powerpc-utility.h b/c/src/lib/libcpu/powerpc/shared/include/powerpc-utility.h
index 79024eb..71567d5 100644
--- a/c/src/lib/libcpu/powerpc/shared/include/powerpc-utility.h
+++ b/c/src/lib/libcpu/powerpc/shared/include/powerpc-utility.h
@@ -407,6 +407,19 @@ static inline void ppc_external_exceptions_disable(uint32_t msr)
RTEMS_COMPILER_MEMORY_BARRIER();
}
+static inline uint32_t ppc_count_leading_zeros(uint32_t value)
+{
+ uint32_t count;
+
+ __asm__ (
+ "cntlzw %0, %1;"
+ : "=r" (count)
+ : "r" (value)
+ );
+
+ return count;
+}
+
/*
* Simple spin delay in microsecond units for device drivers.
* This is very dependent on the clock speed of the target.
More information about the vc
mailing list