Thread (115 messages) 115 messages, 13 authors, 2015-08-27

[PATCH v3 26/31] arm64: Miscellaneous library functions

flat view

From: arnd@arndb.de (Arnd Bergmann)
Date: 2012-09-07 19:52:20
Also in: linux-arch, lkml

On Friday 07 September 2012, Catalin Marinas wrote:
quoted hunk ↗ jump to hunk
+/*
+ * Use compiler builtins for simple inline operations.
+ */
+static inline unsigned long __ffs(unsigned long word)
+{
+	return __builtin_ffsl(word) - 1;
+}
+
+static inline int ffs(int x)
+{
+	return __builtin_ffs(x);
+}
+
+static inline unsigned long __fls(unsigned long word)
+{
+	return BITS_PER_LONG - 1 - __builtin_clzl(word);
+}
+
+static inline int fls(int x)
+{
+	return x ? sizeof(x) * BITS_PER_BYTE - __builtin_clz(x) : 0;
+}
Still waiting for the generic version of these.

	Arnd
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help