时间函数与定时器timerfd

时间结构体

struct timeval
{
__time_t tv_sec;        //Seconds.
__suseconds_t tv_usec;  //Microseconds.
};

struct timespec {
time_t tv_sec; // seconds
long tv_nsec; //  nanoseconds
};

struct tm {
   int tm_sec;    /* Seconds (0-60) */
   int tm_min;    /* Minutes (0-59) */
   int tm_hour;   /* Hours (0-23) */
   int tm_mday;   /* Day of the month (1-31) */
   int tm_mon;    /* Month (0-11) */
   int tm_year;   /* Year - 1900 */
   int tm_wday;   /* Day of the week (0-6, Sunday = 0) */
   int tm_yday;   /* Day in the year (0-365, 1 Jan = 0) */
   int tm_isdst;  /* Daylight saving time */
};

时间函数

gettimeofday函数

int gettimeofday(struct timeval*tv, struct timezone *tz);

gettimeofday()会把目前的时间用tv 结构体返回。tz可以设为NULL。函数执行成功后返回0,失败后返回-1,错误代码存于errno中。

clock_gettime函数

int clock_gettime(clockid_t clk_id, struct t
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值