houmkh 36fd013004
实现gettimeofday()系统调用和clocksource+timekeeping子模块 (#278)
- 实现gettimeofday()系统调用
- 实现clocksource+timekeeping子模块部分功能
- 实现了timespec转换成日期时间
2023-06-17 22:48:15 +08:00

25 lines
693 B
C

#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
// #include <sleep.h>
#include <unistd.h>
#include <time.h>
int main()
{
struct timeval *tv = malloc(sizeof(struct timeval));
// struct timezone *tz = malloc(sizeof(struct timezone));
// for (int i = 0; i < 15; i++)
// {
// gettimeofday(tv, NULL);
// printf("%ld.%06ld\n", tv->tv_sec, tv->tv_usec);
// for (int i = 0; i < 10; i++)
// {
// usleep(500000);
// }
// }
gettimeofday(tv, NULL);
printf("tv = %ld.%06ld\n", tv->tv_sec, tv->tv_usec);
// printf("tz_minuteswest = %d,tz_dsttime = %d", (*tz).tz_minuteswest, (*tz).tz_dsttime);
return 0;
}