问题代码
ktime_t calltime, delta, rettime;unsigned long long duration;calltime = ktime_get();/*获取当前时间*/
rettime = ktime_get();
/*计算时间差 ktime_sub(A,B) 计算A-B的时间差 返回纳秒*/
delta = ktime_sub(rettime,calltime);
/*转换成微秒*/
duration = (unsigned long long) ktime_to_ns(delta) >> 10;
printk("[%s] running %lld usecs %d ms at %d\n",__FUNCTION__, duration,(unsigned int)(duration/1000),__LINE__);
编译出错
/rk3288_pad/kernel/drivers/input/sensors/sensor-dev.c:505: undefined reference to `__aeabi_uldivmod'
/data/weiqifa/rk3288_pad/kernel/drivers/input/sensors/sensor-dev.c:529: undefined reference to `__aeabi_uldivmod'
Makefile:997: recipe for target 'vmlinux' failed
make: *** [vmlinux] Error 1
原因
在大多数32位CPU上,必须使用慢库函数实现64位除法。为了防止编译器生成非常慢的代码,Linux不实现这些功能。