我正在尝试将linux内核start_time的task_struct转换为纳秒。我需要给出const struct timespec *的论点,但是start_time是struct timespec类型的。
如何使它成为指向timespec结构的常量和指针?示例代码:
(*kinfo).start_time = timespec_to_ns((*current).start_time);发布于 2015-09-18 00:19:59
我建议学习C的入门,因为您需要非常熟悉C编程(特别是因为Linux内核使用书中的所有C技巧)来编写内核代码(或修改现有的内核代码)。但是,要回答您的问题,您需要传递一个指向值的指针(在C中使用&操作符完成)。此外,请对指向结构的指针(p->attr)使用正确的去引用语法。
kinfo->start_time = timespec_to_ns(¤t->start_time);https://stackoverflow.com/questions/32641193
复制相似问题