Changeset View
Changeset View
Standalone View
Standalone View
head/sys/sys/time.h
Show First 20 Lines • Show All 283 Lines • ▼ Show 20 Lines | |||||
tvtosbt(struct timeval _tv) | tvtosbt(struct timeval _tv) | ||||
{ | { | ||||
return (((sbintime_t)_tv.tv_sec << 32) + ustosbt(_tv.tv_usec)); | return (((sbintime_t)_tv.tv_sec << 32) + ustosbt(_tv.tv_usec)); | ||||
} | } | ||||
#endif /* __BSD_VISIBLE */ | #endif /* __BSD_VISIBLE */ | ||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
/* | |||||
* Simple macros to convert ticks to milliseconds | |||||
* or microseconds and vice-versa. The answer | |||||
* will always be at least 1. Note the return | |||||
* value is a uint32_t however we step up the | |||||
* operations to 64 bit to avoid any overflow/underflow | |||||
* problems. | |||||
*/ | |||||
#define TICKS_2_MSEC(t) max(1, (uint32_t)(hz == 1000) ? \ | |||||
(t) : (((uint64_t)(t) * (uint64_t)1000)/(uint64_t)hz)) | |||||
#define TICKS_2_USEC(t) max(1, (uint32_t)(hz == 1000) ? \ | |||||
((t) * 1000) : (((uint64_t)(t) * (uint64_t)1000000)/(uint64_t)hz)) | |||||
#define MSEC_2_TICKS(m) max(1, (uint32_t)((hz == 1000) ? \ | |||||
(m) : ((uint64_t)(m) * (uint64_t)hz)/(uint64_t)1000)) | |||||
#define USEC_2_TICKS(u) max(1, (uint32_t)((hz == 1000) ? \ | |||||
((u) / 1000) : ((uint64_t)(u) * (uint64_t)hz)/(uint64_t)1000000)) | |||||
/* Operations on timespecs */ | /* Operations on timespecs */ | ||||
#define timespecclear(tvp) ((tvp)->tv_sec = (tvp)->tv_nsec = 0) | #define timespecclear(tvp) ((tvp)->tv_sec = (tvp)->tv_nsec = 0) | ||||
#define timespecisset(tvp) ((tvp)->tv_sec || (tvp)->tv_nsec) | #define timespecisset(tvp) ((tvp)->tv_sec || (tvp)->tv_nsec) | ||||
#define timespeccmp(tvp, uvp, cmp) \ | #define timespeccmp(tvp, uvp, cmp) \ | ||||
(((tvp)->tv_sec == (uvp)->tv_sec) ? \ | (((tvp)->tv_sec == (uvp)->tv_sec) ? \ | ||||
((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \ | ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \ | ||||
((tvp)->tv_sec cmp (uvp)->tv_sec)) | ((tvp)->tv_sec cmp (uvp)->tv_sec)) | ||||
▲ Show 20 Lines • Show All 249 Lines • Show Last 20 Lines |