All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-core] [PATCH] fls() not available in Linux 2.4
@ 2007-08-16  7:42 Wolfgang Grandegger
  2007-08-16  7:51 ` Gilles Chanteperdrix
  2007-08-16 11:16 ` Gilles Chanteperdrix
  0 siblings, 2 replies; 5+ messages in thread
From: Wolfgang Grandegger @ 2007-08-16  7:42 UTC (permalink / raw)
  To: xenomai-core

[-- Attachment #1: Type: text/plain, Size: 460 bytes --]

Hello,

the attached patch fixes the following compilation error with Xenomai's 
head of trunk under Linux 2.4:

kernel/kernel.o(.text+0x135a4): In function `__rthal_generic_full_divmod64':
/temp/rtcan/devel/linuxppc_2_4_devel-xenomai/kernel/xenomai/arch/generic/hal.c:918: 
undefined reference to `fls'
kernel/kernel.o(.text+0x135b4):/temp/rtcan/devel/linuxppc_2_4_devel-xenomai/kernel/xenomai/arch/generic/hal.c:918: 
undefined reference to `fls'

Wolfgang.

[-- Attachment #2: xenomai-fls.patch --]
[-- Type: text/x-patch, Size: 710 bytes --]

Index: include/asm-generic/wrappers.h
===================================================================
--- include/asm-generic/wrappers.h	(revision 2922)
+++ include/asm-generic/wrappers.h	(working copy)
@@ -183,6 +183,18 @@ void show_stack(struct task_struct *task
 #define __deprecated  __attribute__((deprecated))
 #endif
 
+/*
+ * fls: find last (most-significant) bit set.
+ * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
+ */
+static __inline__ int fls(unsigned int x)
+{
+        int lz;
+
+        asm ("cntlzw %0,%1" : "=r" (lz) : "r" (x));
+        return 32 - lz;
+}
+
 #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) */
 
 #define compat_module_param_array(name, type, count, perm) \

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-08-16 11:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-16  7:42 [Xenomai-core] [PATCH] fls() not available in Linux 2.4 Wolfgang Grandegger
2007-08-16  7:51 ` Gilles Chanteperdrix
2007-08-16  8:12   ` Wolfgang Grandegger
2007-08-16  8:22     ` Gilles Chanteperdrix
2007-08-16 11:16 ` Gilles Chanteperdrix

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.