2011-11-05 74 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);'。另外,我建議你在繼續之前閱讀一些關於指針的信息。 –