2009-01-19 02:52:58

by Gao, Yunpeng

[permalink] [raw]
Subject:

Hi all,

I have to use 64bit variable in my 2.6.27 kernel NAND driver as below:
---------------------------------------------------------------------------
u64 NAND_capacity;
unsigned int block_num, block_size;
...
block_num = NAND_capacity / block_size;
---------------------------------------------------------------------------
but it failed when compiling and reports 'undefined reference to `__udivdi3'.

Does any idea about this? I need to include some special head file or change something in Kconfig?

BTW, the environment is Fedora Core 9, gcc 4.3.0.

Thanks a lot.

Rgds,
Yunpeng Gao


2009-01-19 03:08:01

by Matthew Wilcox

[permalink] [raw]
Subject: Re: your mail

On Mon, Jan 19, 2009 at 10:54:02AM +0800, Gao, Yunpeng wrote:
> I have to use 64bit variable in my 2.6.27 kernel NAND driver as below:
> ---------------------------------------------------------------------------
> u64 NAND_capacity;
> unsigned int block_num, block_size;
> ...
> block_num = NAND_capacity / block_size;
> ---------------------------------------------------------------------------
> but it failed when compiling and reports 'undefined reference to `__udivdi3'.

Presumably block_size is a power of two, so you can do:

block_num = NAND_capacity >> block_shift;

--
Matthew Wilcox Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."

2009-01-19 04:25:26

by KOSAKI Motohiro

[permalink] [raw]
Subject: how to fix nand driver build breakage

> Hi all,
>
> I have to use 64bit variable in my 2.6.27 kernel NAND driver as below:
> ---------------------------------------------------------------------------
> u64 NAND_capacity;
> unsigned int block_num, block_size;
> ...
> block_num = NAND_capacity / block_size;
> ---------------------------------------------------------------------------
> but it failed when compiling and reports 'undefined reference to `__udivdi3'.
>
> Does any idea about this? I need to include some special head file or change something in Kconfig?
>
> BTW, the environment is Fedora Core 9, gcc 4.3.0.

Couldn't you use do_div()?


2009-01-19 11:46:53

by Simon Holm Thøgersen

[permalink] [raw]
Subject: Re: how to fix nand driver build breakage

man, 19 01 2009 kl. 13:25 +0900, skrev KOSAKI Motohiro:
> > Hi all,
> >
> > I have to use 64bit variable in my 2.6.27 kernel NAND driver as below:
> > ---------------------------------------------------------------------------
> > u64 NAND_capacity;
> > unsigned int block_num, block_size;
> > ...
> > block_num = NAND_capacity / block_size;
> > ---------------------------------------------------------------------------
> > but it failed when compiling and reports 'undefined reference to `__udivdi3'.
> >
> > Does any idea about this? I need to include some special head file or change something in Kconfig?
> >
> > BTW, the environment is Fedora Core 9, gcc 4.3.0.
>
> Couldn't you use do_div()?

Perhaps rather div_u64, but otherwise he should be able to yes.


Simon Holm Thøgersen