当前仓库属于关闭状态,部分功能使用受限,详情请查阅 仓库状态说明
73 Star 131 Fork 43

yuanhack / sarudp
关闭

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
yhtime.c 1.68 KB
一键复制 编辑 原始数据 按行查看 历史
yuanhack 提交于 2015-10-04 13:27 . add yhdaemon
#include "yhtime.h"
void maketimeout_minutes(struct timespec *tsp, long minutes)
{
struct timeval now;
gettimeofday(&now, NULL);
tsp->tv_sec = now.tv_sec + minutes * 60;
tsp->tv_nsec = now.tv_usec * 1000;
}
void maketimeout_seconds(struct timespec *tsp, long seconds)
{
struct timeval now;
gettimeofday(&now, NULL);
tsp->tv_sec = now.tv_sec + seconds;
tsp->tv_nsec = now.tv_usec * 1000;
}
void maketimeout_milliseconds(struct timespec *tsp, long millisconds)
{
struct timeval now;
gettimeofday(&now, NULL);
tsp->tv_sec = now.tv_sec + millisconds / 1000;
tsp->tv_nsec = now.tv_usec * 1000 + millisconds % 1000 * 1000000;
}
void maketimeout_microsecond(struct timespec *tsp, long microsecond)
{
struct timeval now;
gettimeofday(&now, NULL);
tsp->tv_sec = now.tv_sec + microsecond / 1000000;
tsp->tv_nsec = now.tv_usec * 1000 + microsecond % 1000000 * 1000;
}
void maketimeout_nanoseconds(struct timespec *tsp, long nanoseconds)
{
struct timeval now;
gettimeofday(&now, NULL);
tsp->tv_sec = now.tv_sec + nanoseconds / 1000000000UL;
tsp->tv_nsec = now.tv_usec * 1000 + nanoseconds % 1000000000UL;
}
void maketimeout_min(struct timespec *tsp, long minutes)
{
maketimeout_minutes(tsp, minutes);
}
void maketimeout_sec(struct timespec *tsp, long seconds)
{
maketimeout_seconds(tsp, seconds);
}
void maketimeout_msec(struct timespec *tsp, long millisconds)
{
maketimeout_milliseconds(tsp, millisconds);
}
void maketimeout_usec(struct timespec *tsp, long microsecond)
{
maketimeout_microsecond(tsp, microsecond);
}
void maketimeout_nsec(struct timespec *tsp, long nanoseconds)
{
maketimeout_nanoseconds(tsp, nanoseconds);
}
C
1
https://gitee.com/yuanhack/sarudp.git
git@gitee.com:yuanhack/sarudp.git
yuanhack
sarudp
sarudp
master

搜索帮助