linux驱动编程里,整形和浮点相称,有问题吗?
u_char temp1,temp2;
int result;
.....
.....
result=(int)(temp2<<8 | temp1)* 0.0625;//这句有问题
==============================
我的理解是和浮点型数乘后转换成整形,应该不会有问题,可是执行make 编译报错,只有去掉浮点数才可以通过编译
报如下错误
....省略部分
ERROR: "__aeabi_d2iz" [drivers/mytestdriver/upstar2440_ds18b20.ko] undefined!
ERROR: "__aeabi_dmul" [drivers/mytestdriver/upstar2440_ds18b20.ko] undefined!
ERROR: "__aeabi_i2d" [drivers/mytestdriver/upstar2440_ds18b20.ko] undefined!
make[1]: *** [__modpost] Error 1
make: *** [modules] Error 2
===================
这种问题,如何解决???
------解决方案--------------------
别在内核里用浮点运算,不支持。
ldd3里第二章这样描述:“Kernel code cannot do floating point arithmetic. Enabling floating point would require that the kernel save and restore the floating point processor’s state on each entry to, and exit from, kernel space—at least, on some architectures. Given that there really is no need for floating point in kernel code, the extra overhead is not worthwhile.”
------解决方案--------------------
内核里不支持浮点运算的