开发者

Does do_div() in Linux work in 32 and 64 bit architectures?

开发者 https://www.devze.com 2023-04-03 05:58 出处:网络
I need to do an integer division in a kernel module and I am using do_div() for that. It seems to work on my machine (I have an i686 processor), however I am not sure that it works everywhere. Could a

I need to do an integer division in a kernel module and I am using do_div() for that. It seems to work on my machine (I have an i686 processor), however I am not sure that it works everywhere. Could anyone confirm whether do_div() should function correctly in 32 bit and 64 bit architectures, or whether there are any know limitations ?

I use Ubuntu 10.04 with kernel 2.6.38, so I am interested in support for kernels >= 2.6.38.

I would also be interested if anyone knows a better way to do an integer division in the 开发者_如何学编程kernel than do_div().

Best Regards

Daniel


do_div() does work on 64bit arch, but unless you really need the remainder and is fully aware of the effects of using do_div(), you should probably be doing bit shifts instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号