|
|
| version 1.32, 2026/05/11 15:53:20 | version 1.32.4.2, 2026/07/29 01:09:33 |
|---|---|
| Line 171 SUCH DAMAGE. | Line 171 SUCH DAMAGE. |
| #define powerof2(x) ((((x) - 1) & (x)) == 0) | #define powerof2(x) ((((x) - 1) & (x)) == 0) |
| #endif | #endif |
| /* timespec helpers */ | |
| /* Operations on timevals. */ | |
| #ifndef timerclear | |
| #define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0) | |
| #endif | |
| #ifndef timerisset | |
| #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) | |
| #endif | |
| #ifndef timercmp | |
| #define timercmp(tvp, uvp, cmp) \ | |
| (((tvp)->tv_sec == (uvp)->tv_sec) ? \ | |
| ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ | |
| ((tvp)->tv_sec cmp (uvp)->tv_sec)) | |
| #endif | |
| #ifndef timeradd | |
| #define timeradd(tvp, uvp, vvp) \ | |
| do { \ | |
| (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \ | |
| (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \ | |
| if ((vvp)->tv_usec >= 1000000) { \ | |
| (vvp)->tv_sec++; \ | |
| (vvp)->tv_usec -= 1000000; \ | |
| } \ | |
| } while (0) | |
| #endif | |
| #ifndef timersub | |
| #define timersub(tvp, uvp, vvp) \ | |
| do { \ | |
| (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ | |
| (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \ | |
| if ((vvp)->tv_usec < 0) { \ | |
| (vvp)->tv_sec--; \ | |
| (vvp)->tv_usec += 1000000; \ | |
| } \ | |
| } while (0) | |
| #endif | |
| /* Operations on timespecs. */ | |
| #ifndef timespecclear | |
| #define timespecclear(tsp) ((tsp)->tv_sec = (tsp)->tv_nsec = 0) | |
| #endif | |
| #ifndef timespecisset | |
| #define timespecisset(tsp) ((tsp)->tv_sec || (tsp)->tv_nsec) | |
| #endif | |
| #ifndef timespeccmp | |
| #define timespeccmp(tsp, usp, cmp) \ | |
| (((tsp)->tv_sec == (usp)->tv_sec) ? \ | |
| ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \ | |
| ((tsp)->tv_sec cmp (usp)->tv_sec)) | |
| #endif | |
| #ifndef timespecadd | |
| #define timespecadd(tsp, usp, vsp) \ | |
| do { \ | |
| (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \ | |
| (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec; \ | |
| if ((vsp)->tv_nsec >= 1000000000L) { \ | |
| (vsp)->tv_sec++; \ | |
| (vsp)->tv_nsec -= 1000000000L; \ | |
| } \ | |
| } while (0) | |
| #endif | |
| #ifndef timespecsub | |
| #define timespecsub(tsp, usp, vsp) \ | |
| do { \ | |
| (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \ | |
| (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \ | |
| if ((vsp)->tv_nsec < 0) { \ | |
| (vsp)->tv_sec--; \ | |
| (vsp)->tv_nsec += 1000000000L; \ | |
| } \ | |
| } while (0) | |
| #endif | |
| /* Macros for min/max. */ | /* Macros for min/max. */ |
| #ifndef MIN | #ifndef MIN |
| #define MIN(a, b) (((a) < (b)) ? (a) : (b)) | #define MIN(a, b) (((a) < (b)) ? (a) : (b)) |