[英]C - Linux Kernel - How to use timespec_to_ns()?
我正在嘗試將linux內核task_struct
的start_time
轉換為納秒。 我需要給它const struct timespec *
的參數,但是start_time
是struct timespec
類型的。
我如何使其成為常量和指向timespec
結構的指針? 示例代碼:
(*kinfo).start_time = timespec_to_ns((*current).start_time);
我建議您學習C入門,因為您需要非常熟悉C編程(尤其是因為Linux內核使用了本書中所有的C技巧)才能編寫內核代碼(或修改現有的內核代碼) 。 但是,要回答您的問題,您需要將指針傳遞給該值(使用C中的&
運算符完成)。 另外,請對結構的指針使用正確的解引用語法( p->attr
)。
kinfo->start_time = timespec_to_ns(¤t->start_time);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.