⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timeval.c

📁 支持Telnet功能的Modem通讯程序
💻 C
字号:
#include <sys/time.h>	/*timeval*/#include "timeval.h"	/*(timevalXXX)*//* a = b [10mS] */voidtimevalSet10ms(struct timeval *ap, int b){    ap->tv_sec = b / 100;    ap->tv_usec = (b % 100) * 10*1000;}/* a += b */voidtimevalAdd(struct timeval *ap, const struct timeval *bp){    ap->tv_sec += bp->tv_sec;    ap->tv_usec += bp->tv_usec;    if (ap->tv_usec >= 1000*1000) {	ap->tv_usec -= 1000*1000;	ap->tv_sec += 1;    }}/* a -= b */voidtimevalSub(struct timeval *ap, const struct timeval *bp){    ap->tv_sec -= bp->tv_sec;    ap->tv_usec -= bp->tv_usec;    if (ap->tv_usec < 0) {	ap->tv_usec += 1000*1000;	ap->tv_sec -= 1;    }}/* (a < b): -1, (a==b): 0, (a > b): 1 */inttimevalCmp(const struct timeval *ap, const struct timeval *bp){    if (ap->tv_sec < bp->tv_sec) return -1;    if (ap->tv_sec > bp->tv_sec) return 1;    if (ap->tv_usec < bp->tv_usec) return -1;    if (ap->tv_usec > bp->tv_usec) return 1;    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -