Changeset View
Changeset View
Standalone View
Standalone View
contrib/nvi/common/util.h
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | |||||
/* Macros for min/max. */ | /* Macros for min/max. */ | ||||
#undef MIN | #undef MIN | ||||
#undef MAX | #undef MAX | ||||
#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) | #define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) | ||||
#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) | #define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) | ||||
/* Operations on timespecs */ | /* Operations on timespecs */ | ||||
#undef timespecclear | |||||
#undef timespecisset | |||||
#undef timespeccmp | |||||
#undef timespecadd | #undef timespecadd | ||||
#undef timespecsub | #undef timespecsub | ||||
#define timespecclear(tvp) ((tvp)->tv_sec = (tvp)->tv_nsec = 0) | |||||
#define timespecisset(tvp) ((tvp)->tv_sec || (tvp)->tv_nsec) | |||||
#define timespeccmp(tvp, uvp, cmp) \ | |||||
(((tvp)->tv_sec == (uvp)->tv_sec) ? \ | |||||
((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \ | |||||
((tvp)->tv_sec cmp (uvp)->tv_sec)) | |||||
#define timespecadd(vvp, uvp) \ | #define timespecadd(vvp, uvp) \ | ||||
do { \ | do { \ | ||||
(vvp)->tv_sec += (uvp)->tv_sec; \ | (vvp)->tv_sec += (uvp)->tv_sec; \ | ||||
(vvp)->tv_nsec += (uvp)->tv_nsec; \ | (vvp)->tv_nsec += (uvp)->tv_nsec; \ | ||||
if ((vvp)->tv_nsec >= 1000000000) { \ | if ((vvp)->tv_nsec >= 1000000000) { \ | ||||
(vvp)->tv_sec++; \ | (vvp)->tv_sec++; \ | ||||
(vvp)->tv_nsec -= 1000000000; \ | (vvp)->tv_nsec -= 1000000000; \ | ||||
} \ | } \ | ||||
Show All 10 Lines |