📄 hust_time_qiu_5.20.c
字号:
/* time.c - timeadd, timesub, timeflatten, timeunflatten, timecmp */#include <ipOS.h>#include <ipHAL.h>#include "hust_util.h"#include "hust_rtplibcommon.h"/*----------------------------------------------------------------------- * timeadd - add two struct timespecs *----------------------------------------------------------------------- */u32_ttimeadd(u32_t a, u32_t b){ return (a+b);}/*----------------------------------------------------------------------- * timesub - subtract struct timespec b from a *----------------------------------------------------------------------- */s32_ttimesub(u32_t a, u32_t b){/* struct timespec c; c.tv_sec = a.tv_sec - b.tv_sec; c.tv_nsec = a.tv_nsec - b.tv_nsec;*/ /* borrow if necessary *//* if (c.tv_nsec < 0) { c.tv_nsec += 1000000000; c.tv_sec--; } else if (c.tv_nsec > 1000000000) { c.tv_nsec -= 1000000000; c.tv_sec++; }*/ return (a-b);}/*----------------------------------------------------------------------- * timeflatten - convert a struct timespec to a flat time value *----------------------------------------------------------------------- */s32_t timeflatten(s32_t t, u32_t clkrt){ u32_t rv; rv=(t*clkrt)/TICK_RATE;/* int rv; double d; rv = t.tv_sec * clkrt; d = (double) t.tv_nsec * .000000001; d *= (double) clkrt; rv += (int) d;*/ return rv;}/*------------------------------------------------------------------------ * timeunflatten - convert a flat time value to a struct timespec *------------------------------------------------------------------------ */u32_ttimeunflatten(mediatime_t t, int clkrt){ u32_t ts; ts=(t*TICK_RATE)/clkrt; /*double d; ts.tv_sec = t / clkrt; d = ((double) (t % clkrt)) / ((double) clkrt); ts.tv_nsec = (int) (d * (double) 1000000000); */ return ts;}/*------------------------------------------------------------------------ * timecmp - compare two strucxt timespecs. Return -1 if a is after b, * 1 if b is after a, or 0 if equal. Yes, this is backward wrt to * convention. *------------------------------------------------------------------------ */inttimecmp(u32_t a, u32_t b){ if (a < b) return 1; if (a > b) return -1; return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -