Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <1524098460-8072-3-git-send-email-armccurdy@gmail.com>
Date: Wed, 18 Apr 2018 17:41:00 -0700
From: Andre McCurdy <armccurdy@...il.com>
To: musl@...ts.openwall.com
Cc: Andre McCurdy <armccurdy@...il.com>
Subject: [PATCH 2/2] provide a_ctz_32 helper

Provide an ARM specific a_ctz_32 helper function for architecture
versions for which it can be implemented efficiently via the "rbit"
instruction (ie all Thumb-2 capable versions of ARM v6 and above).
---
 arch/arm/atomic_arch.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/atomic_arch.h b/arch/arm/atomic_arch.h
index c5c56f8..72fcddb 100644
--- a/arch/arm/atomic_arch.h
+++ b/arch/arm/atomic_arch.h
@@ -91,4 +91,16 @@ static inline int a_clz_32(uint32_t x)
 	return x;
 }
 
+#if __ARM_ARCH_6T2__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH >= 7
+
+#define a_ctz_32 a_ctz_32
+static inline int a_ctz_32(uint32_t x)
+{
+	uint32_t xr;
+	__asm__ ("rbit %0, %1" : "=r"(xr) : "r"(x));
+	return a_clz_32(xr);
+}
+
+#endif
+
 #endif
-- 
1.9.1

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.