2011-11-05 71 views

回答

1

在Linux 2.6.39,do_posix_clock_monotomic_gettimeinclude/linux/time.h定义为这样:

#define do_posix_clock_monotonic_gettime(ts) ktime_get_ts(ts) 

ktime_get_ts在kernel/time/timekeeping.c实现。上面的注释说明了这个论点:

/** 
* ktime_get_ts - get the monotonic clock in timespec format 
* @ts:   pointer to timespec variable 
* 
* The function calculates the monotonic clock from the realtime 
* clock and the wall_to_monotonic offset and stores the result 
* in normalized timespec format in the variable pointed to by @ts. 
*/ 
+0

好的,我正在尝试这个。我创建了一个timespec结构并用{0,0}初始化它,然后在我的模块中执行以下命令:int time = do_posix_clock_monotonic_gettime(ts.tv_sec),我希望它将时间放在timepec调用的tv_sec部分但是当我做文件时,它给出错误'void value not ignored,it should be'以及警告'传递'ktime_gets_ts'的参数1使得来自整型的指针没有强制转换。你知道我做错了什么吗? – sam

+0

指针是输出参数,函数不返回任何值。以kernel/timer.c中的do_sysinfo为例:'struct timespec tp; ktime_get_ts(&tp);'。另外,我建议你在继续之前阅读一些关于指针的信息。 –