|
名称: do_settimeofday()
功能:设定系统时间
原型:
#include <linux/time.h>
void do_settimeofday (struct timeval *tv); //2.4内核
int do_settimeofday (struct timespec *tv); //2.6 内核
说明:把 tv 的时间设定为系统时间
变量:
tv 2.4 内核中使用 struct timeval 结构体指定以秒和微妙表示的时间地址; 2.6 内核中使用 struct timespec 结构体指定以秒和纳秒表示的时间地址。
返回值:
2.4 内核没有返回值; 2.6 内核中运行正常时返回 0 , tv_nsec 超过 NSEC_PER_SEC (#define NSEC_PER_SEC 1000000000L)的值就返回 -EINVAL
struct timespec 结构体:
struct timepsec {
time_t tv_sec;
long tv_nsec; // 1/1,000,000,000
};
struct timespec 结构体在 2.6 内核中使用,用在 do_settimeofday() 函数上。tv_sec 变量把当前时间换算为秒,tv_nsec 值指定 tv_sec 无法表示的 ns 单位时间。 |
|