内核当前时间
来源:互联网 发布:傲盾网络加速器 编辑:程序博客网 时间:2024/06/03 16:59
current_kernel_time
struct timespec current_kernel_time(void){ struct timespec now; unsigned long seq; do { seq = read_seqbegin(&xtime_lock); now = xtime; } while (read_seqretry(&xtime_lock, seq)); return now;}
do_gettimeofday
struct timespec { __kernel_time_t tv_sec; /* seconds */ long tv_nsec; /* nanoseconds */};void do_gettimeofday(struct timeval *tv){ struct timespec now; getnstimeofday(&now); tv->tv_sec = now.tv_sec; tv->tv_usec = now.tv_nsec/1000;}void getnstimeofday(struct timespec *ts){ unsigned long seq; s64 nsecs; WARN_ON(timekeeping_suspended); do { seq = read_seqbegin(&xtime_lock); *ts = xtime; nsecs = timekeeping_get_ns(); /* If arch requires, add in gettimeoffset() */ nsecs += arch_gettimeoffset(); } while (read_seqretry(&xtime_lock, seq)); timespec_add_ns(ts, nsecs);}
rtc_time_to_tm
struct rtc_time { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst;};int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time){ *time = mktime(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); return 0;}
rtc_time_to_tm
void rtc_time_to_tm(unsigned long time, struct rtc_time *tm){ unsigned int month, year; int days; days = time / 86400; time -= (unsigned int) days * 86400; /* day of the week, 1970-01-01 was a Thursday */ tm->tm_wday = (days + 4) % 7; year = 1970 + days / 365; days -= (year - 1970) * 365 + LEAPS_THRU_END_OF(year - 1) - LEAPS_THRU_END_OF(1970 - 1); if (days < 0) { year -= 1; days += 365 + is_leap_year(year); } tm->tm_year = year - 1900; tm->tm_yday = days + 1; for (month = 0; month < 11; month++) { int newdays; newdays = days - rtc_month_days(month, year); if (newdays < 0) break; days = newdays; } tm->tm_mon = month; tm->tm_mday = days + 1; tm->tm_hour = time / 3600; time -= tm->tm_hour * 3600; tm->tm_min = time / 60; tm->tm_sec = time - tm->tm_min * 60;}
阅读全文
1 0
- 内核当前时间
- Linux内核中获取当前时间
- linux内核获取当前系统时间
- 内核获得开机嘀嗒数和当前时间
- Linux内核获取当前时间、定时器、延时函数
- Windows内核编程基础篇之获取当前系统时间
- 当前时间
- 当前时间
- mysql 当前日期,当前时间
- mysql获取当前时间,格式化当前时间,增减当前时间
- 获取当前时间,当前时间加减计算
- 获取当前时间 时间戳
- 当前时间的诱惑
- 当前跳动时间
- java取当前时间
- java取当前时间
- 打印当前时间
- 当前时间代码
- javascript
- 家庭服务机器人仿真平台运行指南
- 万元大奖邀您参与阿里云数加 MaxCompute最佳实践征文大赛
- JZ2440 中断分析
- JAVA 方法内部类为何只能访问外部final类型变量
- 内核当前时间
- Android的App Shortcut功能
- Android官方语言:Kotlin
- Yii控制器直接校验系统验证码
- Java基础算法
- 《阿里感悟》- 技术人员的职业规划
- Android7.0中文文档(API) --- CheckedTextView
- spring-boot 加载本地静态资源文件路径配置
- 从北京到南京