* undefined reference to `__ffs'
@ 2004-08-27 14:28 Brian T
2004-08-27 15:35 ` Brian T
0 siblings, 1 reply; 16+ messages in thread
From: Brian T @ 2004-08-27 14:28 UTC (permalink / raw)
To: linux-mtd
Hi,
With kernel 2.4.27 and the snapshot patch from 8/26 (yesterday) I am getting
the following error :
make[1]: Leaving directory
`/usr/src/Lineo/current_build2/linux-2.4.27/arch/i386/lib'
ld -m elf_i386 -T
/usr/src/Lineo/current_build2/linux-2.4.27/arch/i386/vmlinux.lds -e stext
arch/i386/kernel/head.o arch/i386/kernel/init_task.o init/main.o
init/version.o init/do_mounts.o \
--start-group \
arch/i386/kernel/kernel.o arch/i386/mm/mm.o kernel/kernel.o mm/mm.o
fs/fs.o ipc/ipc.o \
drivers/char/char.o drivers/block/block.o drivers/misc/misc.o
drivers/net/net.o drivers/pci/driver.o drivers/mtd/mtdlink.o
drivers/net/pcmcia/pcmcia_net.o drivers/media/media.o \
net/network.o \
/usr/src/Lineo/current_build2/linux-2.4.27/arch/i386/lib/lib.a
/usr/src/Lineo/current_build2/linux-2.4.27/lib/lib.a
/usr/src/Lineo/current_build2/linux-2.4.27/arch/i386/lib/lib.a \
--end-group \
-o vmlinux
drivers/mtd/mtdlink.o: In function `cfi_intelext_partition_fixup':
drivers/mtd/mtdlink.o(.text+0x76c6): undefined reference to `__ffs'
make: *** [vmlinux] Error 1
Any ideas?
-Brian
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: undefined reference to `__ffs'
2004-08-27 14:28 undefined reference to `__ffs' Brian T
@ 2004-08-27 15:35 ` Brian T
2004-08-27 16:05 ` Nicolas Pitre
0 siblings, 1 reply; 16+ messages in thread
From: Brian T @ 2004-08-27 15:35 UTC (permalink / raw)
To: linux-mtd
> drivers/mtd/mtdlink.o: In function `cfi_intelext_partition_fixup':
> drivers/mtd/mtdlink.o(.text+0x76c6): undefined reference to `__ffs'
> make: *** [vmlinux] Error 1
>
Hmmm,
Looks like _ffs is defined in :
[root@Smog include]# grep -l -r "__ffs" *
asm-ia64/topology.h
asm-ia64/bitops.h
asm-ppc64/bitops.h
but in asm-i386/bitops.h it is defined as ffs()
So, should there be a macro rule for ffs->__ffs for compiling for i386?
-Brian
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: undefined reference to `__ffs'
2004-08-27 15:35 ` Brian T
@ 2004-08-27 16:05 ` Nicolas Pitre
2004-08-27 18:04 ` Brian T
0 siblings, 1 reply; 16+ messages in thread
From: Nicolas Pitre @ 2004-08-27 16:05 UTC (permalink / raw)
To: Brian T; +Cc: linux-mtd
On Fri, 27 Aug 2004, Brian T wrote:
>> drivers/mtd/mtdlink.o: In function `cfi_intelext_partition_fixup':
>> drivers/mtd/mtdlink.o(.text+0x76c6): undefined reference to `__ffs'
>> make: *** [vmlinux] Error 1
>>
>
> Hmmm,
>
> Looks like _ffs is defined in :
>
> [root@Smog include]# grep -l -r "__ffs" *
> asm-ia64/topology.h
> asm-ia64/bitops.h
> asm-ppc64/bitops.h
>
> but in asm-i386/bitops.h it is defined as ffs()
>
> So, should there be a macro rule for ffs->__ffs for compiling for i386?
No, they aren't equivalent.
>From linux/asm-i386/bitops.h in 2.6.8:
/**
* __ffs - find first bit in word.
* @word: The word to search
*
* Undefined if no bit exists, so code should check against 0 first.
*/
static inline unsigned long __ffs(unsigned long word)
{
__asm__("bsfl %1,%0"
:"=r" (word)
:"rm" (word));
return word;
}
Nicolas
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: undefined reference to `__ffs'
2004-08-27 16:05 ` Nicolas Pitre
@ 2004-08-27 18:04 ` Brian T
2004-08-27 18:10 ` Josh Boyer
2004-08-27 18:25 ` Thomas Gleixner
0 siblings, 2 replies; 16+ messages in thread
From: Brian T @ 2004-08-27 18:04 UTC (permalink / raw)
To: linux-mtd
>
> No, they aren't equivalent.
>
> >From linux/asm-i386/bitops.h in 2.6.8:
>
> /**
> * __ffs - find first bit in word.
> * @word: The word to search
> *
> * Undefined if no bit exists, so code should check against 0 first.
> */
> static inline unsigned long __ffs(unsigned long word)
> {
> __asm__("bsfl %1,%0"
> :"=r" (word)
> :"rm" (word));
> return word;
> }
>
Ok,
So MTD is no longer compatable with the current 2.4 tree? I just unpacked
it and didn't see it in linux/asm-i386/bitops.h . Am I looking in the wrong
place?
-Brian
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: undefined reference to `__ffs'
2004-08-27 18:04 ` Brian T
@ 2004-08-27 18:10 ` Josh Boyer
2004-08-27 18:26 ` David Woodhouse
2004-08-27 18:25 ` Thomas Gleixner
1 sibling, 1 reply; 16+ messages in thread
From: Josh Boyer @ 2004-08-27 18:10 UTC (permalink / raw)
To: Brian T; +Cc: linux-mtd
On Fri, 2004-08-27 at 13:04, Brian T wrote:
> Ok,
>
> So MTD is no longer compatable with the current 2.4 tree? I just unpacked
> it and didn't see it in linux/asm-i386/bitops.h . Am I looking in the wrong
> place?
Not really. Some efforts have been made to fixup the current code to
work with 2.4, but I don't know to what extent. It shouldn't take too
much effort to get whatever is broken working again (famous last words).
As long as it doesn't make the 2.6 code ugly. Right, dwmw2... ;)
josh
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: undefined reference to `__ffs'
2004-08-27 18:04 ` Brian T
2004-08-27 18:10 ` Josh Boyer
@ 2004-08-27 18:25 ` Thomas Gleixner
2004-08-27 19:22 ` Brian T
2004-08-30 16:36 ` Brian T
1 sibling, 2 replies; 16+ messages in thread
From: Thomas Gleixner @ 2004-08-27 18:25 UTC (permalink / raw)
To: Brian T; +Cc: linux-mtd
On Fri, 2004-08-27 at 20:04, Brian T wrote:
> So MTD is no longer compatable with the current 2.4 tree? I just unpacked
> it and didn't see it in linux/asm-i386/bitops.h . Am I looking in the wrong
> place?
__ffs was never in 2.4. Move to 2.6 or add it to compatmac.h and provide
a nice patch, if you really want to hang on with 2.4
tglx
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: undefined reference to `__ffs'
2004-08-27 18:10 ` Josh Boyer
@ 2004-08-27 18:26 ` David Woodhouse
0 siblings, 0 replies; 16+ messages in thread
From: David Woodhouse @ 2004-08-27 18:26 UTC (permalink / raw)
To: Josh Boyer; +Cc: Brian T, linux-mtd
On Fri, 2004-08-27 at 13:10 -0500, Josh Boyer wrote:
> As long as it doesn't make the 2.6 code ugly. Right, dwmw2... ;)
Maybe.
Friends don't let friends use 2.4.
--
dwmw2
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: undefined reference to `__ffs'
2004-08-27 18:25 ` Thomas Gleixner
@ 2004-08-27 19:22 ` Brian T
2004-08-30 16:36 ` Brian T
1 sibling, 0 replies; 16+ messages in thread
From: Brian T @ 2004-08-27 19:22 UTC (permalink / raw)
To: linux-mtd
> __ffs was never in 2.4. Move to 2.6 or add it to compatmac.h and provide
> a nice patch, if you really want to hang on with 2.4
>
Thanks, I'll try to get that working and test it. If it works I'll send in
a patch.
-Brian
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: undefined reference to `__ffs'
2004-08-27 18:25 ` Thomas Gleixner
2004-08-27 19:22 ` Brian T
@ 2004-08-30 16:36 ` Brian T
2004-08-30 17:52 ` Josh Boyer
1 sibling, 1 reply; 16+ messages in thread
From: Brian T @ 2004-08-30 16:36 UTC (permalink / raw)
To: linux-mtd
[-- Attachment #1: Type: text/plain, Size: 472 bytes --]
> On Fri, 2004-08-27 at 20:04, Brian T wrote:
> > So MTD is no longer compatable with the current 2.4 tree? I just
unpacked
> > it and didn't see it in linux/asm-i386/bitops.h . Am I looking in the
wrong
> > place?
>
> __ffs was never in 2.4. Move to 2.6 or add it to compatmac.h and provide
> a nice patch, if you really want to hang on with 2.4
>
> tglx
compatmac.h patch attached for __ffs() .
Compiles against 2.4.27 now. Hope I didn't break anything.
-Brian
[-- Attachment #2: compatmac.diff --]
[-- Type: application/octet-stream, Size: 674 bytes --]
--- include/linux/mtd/compatmac.h.orig Mon Aug 30 09:17:28 2004
+++ include/linux/mtd/compatmac.h Mon Aug 30 11:22:18 2004
@@ -64,6 +64,22 @@
#include <linux/sched.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+/**
+ * * __ffs - find first bit in word.
+ * * @word: The word to search
+ * *
+ * * Undefined if no bit exists, so code should check against 0 first.
+ * */
+static inline unsigned long __ffs(unsigned long word)
+{
+ __asm__("bsfl %1,%0"
+ :"=r" (word)
+ :"rm" (word));
+ return word;
+}
+#endif /* < 2.5.0 */
+
#ifdef __rh_config_h__
#define sigmask_lock sighand->siglock
#define sig sighand
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: undefined reference to `__ffs'
2004-08-30 16:36 ` Brian T
@ 2004-08-30 17:52 ` Josh Boyer
2004-08-30 18:20 ` Brian T
0 siblings, 1 reply; 16+ messages in thread
From: Josh Boyer @ 2004-08-30 17:52 UTC (permalink / raw)
To: Brian T; +Cc: linux-mtd
On Mon, 2004-08-30 at 11:36, Brian T wrote:
>
> > On Fri, 2004-08-27 at 20:04, Brian T wrote:
> > > So MTD is no longer compatable with the current 2.4 tree? I just
> unpacked
> > > it and didn't see it in linux/asm-i386/bitops.h . Am I looking in the
> wrong
> > > place?
> >
> > __ffs was never in 2.4. Move to 2.6 or add it to compatmac.h and provide
> > a nice patch, if you really want to hang on with 2.4
> >
> > tglx
>
> compatmac.h patch attached for __ffs() .
>
> Compiles against 2.4.27 now. Hope I didn't break anything.
Hrm... that won't work on non-x86 architectures.
josh
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: undefined reference to `__ffs'
2004-08-30 17:52 ` Josh Boyer
@ 2004-08-30 18:20 ` Brian T
2004-08-30 18:35 ` Josh Boyer
0 siblings, 1 reply; 16+ messages in thread
From: Brian T @ 2004-08-30 18:20 UTC (permalink / raw)
To: Josh Boyer; +Cc: linux-mtd
> >
> > compatmac.h patch attached for __ffs() .
> >
> > Compiles against 2.4.27 now. Hope I didn't break anything.
>
> Hrm... that won't work on non-x86 architectures.
>
> josh
>
Not sure how to fix it for non-x86 then. Point me in the right direction?
-Brian
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: undefined reference to `__ffs'
2004-08-30 18:20 ` Brian T
@ 2004-08-30 18:35 ` Josh Boyer
2004-08-30 18:53 ` Nicolas Pitre
0 siblings, 1 reply; 16+ messages in thread
From: Josh Boyer @ 2004-08-30 18:35 UTC (permalink / raw)
To: Brian T; +Cc: linux-mtd
On Mon, 2004-08-30 at 13:20, Brian T wrote:
> Not sure how to fix it for non-x86 then. Point me in the right direction?
Welcome to the hell that is compatmac.h ;).
Seriously though, maybe take a look at generic_ffs() in
include/linux/bitops.h (in the 2.6 kernel). It's not optimized, but it
should work for all architectures if I am reading things right.
josh
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: undefined reference to `__ffs'
2004-08-30 18:35 ` Josh Boyer
@ 2004-08-30 18:53 ` Nicolas Pitre
2004-08-30 19:04 ` Josh Boyer
0 siblings, 1 reply; 16+ messages in thread
From: Nicolas Pitre @ 2004-08-30 18:53 UTC (permalink / raw)
To: Josh Boyer; +Cc: Brian T, linux-mtd
On Mon, 30 Aug 2004, Josh Boyer wrote:
> On Mon, 2004-08-30 at 13:20, Brian T wrote:
>> Not sure how to fix it for non-x86 then. Point me in the right direction?
>
> Welcome to the hell that is compatmac.h ;).
>
> Seriously though, maybe take a look at generic_ffs() in
> include/linux/bitops.h (in the 2.6 kernel).
Again, ffs()/generic_ffs() are not equivalent to __ffs().
For a generic solution to add to compatmac.h, just use:
#define __ffs(x) (ffs(x) - 1)
Nicolas
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: undefined reference to `__ffs'
2004-08-30 18:53 ` Nicolas Pitre
@ 2004-08-30 19:04 ` Josh Boyer
2004-08-30 20:03 ` Nicolas Pitre
0 siblings, 1 reply; 16+ messages in thread
From: Josh Boyer @ 2004-08-30 19:04 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: Brian T, linux-mtd
On Mon, 2004-08-30 at 13:53, Nicolas Pitre wrote:
> On Mon, 30 Aug 2004, Josh Boyer wrote:
>
> > On Mon, 2004-08-30 at 13:20, Brian T wrote:
> >> Not sure how to fix it for non-x86 then. Point me in the right direction?
> >
> > Welcome to the hell that is compatmac.h ;).
> >
> > Seriously though, maybe take a look at generic_ffs() in
> > include/linux/bitops.h (in the 2.6 kernel).
>
> Again, ffs()/generic_ffs() are not equivalent to __ffs().
Hm, I remember you saying that now. Care to explain how they are
different?
josh
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: undefined reference to `__ffs'
2004-08-30 19:04 ` Josh Boyer
@ 2004-08-30 20:03 ` Nicolas Pitre
2004-08-30 20:20 ` Josh Boyer
0 siblings, 1 reply; 16+ messages in thread
From: Nicolas Pitre @ 2004-08-30 20:03 UTC (permalink / raw)
To: Josh Boyer; +Cc: Brian T, linux-mtd
On Mon, 30 Aug 2004, Josh Boyer wrote:
> On Mon, 2004-08-30 at 13:53, Nicolas Pitre wrote:
>> On Mon, 30 Aug 2004, Josh Boyer wrote:
>>
>>> On Mon, 2004-08-30 at 13:20, Brian T wrote:
>>>> Not sure how to fix it for non-x86 then. Point me in the right direction?
>>>
>>> Welcome to the hell that is compatmac.h ;).
>>>
>>> Seriously though, maybe take a look at generic_ffs() in
>>> include/linux/bitops.h (in the 2.6 kernel).
>>
>> Again, ffs()/generic_ffs() are not equivalent to __ffs().
>
> Hm, I remember you saying that now. Care to explain how they are
> different?
Guys, you really should look at the source...
linux-2.6.8/include/asm-i386/bitops.h:
/**
* __ffs - find first bit in word.
* @word: The word to search
*
* Undefined if no bit exists, so code should check against 0 first.
*/
[...]
/**
* ffz - find first zero in word.
* @word: The word to search
*
* Undefined if no zero exists, so code should check against ~0UL first.
*/
[...]
/**
* ffs - find first bit set
* @x: the word to search
*
* This is defined the same way as
* the libc and compiler builtin ffs routines, therefore
* differs in spirit from the above ffz (man ffs).
*/
In short, one starts at 0 while the other one starts at 1.
Nicolas
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: undefined reference to `__ffs'
2004-08-30 20:03 ` Nicolas Pitre
@ 2004-08-30 20:20 ` Josh Boyer
0 siblings, 0 replies; 16+ messages in thread
From: Josh Boyer @ 2004-08-30 20:20 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: Brian T, linux-mtd
On Mon, 2004-08-30 at 15:03, Nicolas Pitre wrote:
> On Mon, 30 Aug 2004, Josh Boyer wrote:
>
> > On Mon, 2004-08-30 at 13:53, Nicolas Pitre wrote:
> >> On Mon, 30 Aug 2004, Josh Boyer wrote:
> >>
> >>> On Mon, 2004-08-30 at 13:20, Brian T wrote:
> >>>> Not sure how to fix it for non-x86 then. Point me in the right direction?
> >>>
> >>> Welcome to the hell that is compatmac.h ;).
> >>>
> >>> Seriously though, maybe take a look at generic_ffs() in
> >>> include/linux/bitops.h (in the 2.6 kernel).
> >>
> >> Again, ffs()/generic_ffs() are not equivalent to __ffs().
> >
> > Hm, I remember you saying that now. Care to explain how they are
> > different?
>
> Guys, you really should look at the source...
Yes, I should have. I did right after I sent my last email. Sorry. I
deserve my scolding for being lazy ;).
At least it's in the archives now though.
josh
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2004-08-30 20:21 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-27 14:28 undefined reference to `__ffs' Brian T
2004-08-27 15:35 ` Brian T
2004-08-27 16:05 ` Nicolas Pitre
2004-08-27 18:04 ` Brian T
2004-08-27 18:10 ` Josh Boyer
2004-08-27 18:26 ` David Woodhouse
2004-08-27 18:25 ` Thomas Gleixner
2004-08-27 19:22 ` Brian T
2004-08-30 16:36 ` Brian T
2004-08-30 17:52 ` Josh Boyer
2004-08-30 18:20 ` Brian T
2004-08-30 18:35 ` Josh Boyer
2004-08-30 18:53 ` Nicolas Pitre
2004-08-30 19:04 ` Josh Boyer
2004-08-30 20:03 ` Nicolas Pitre
2004-08-30 20:20 ` Josh Boyer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox