Changeset 1971 for features/performance/src/common/timer.h
- Timestamp:
- 04/09/08 15:37:35 (9 months ago)
- Files:
-
- 1 modified
-
features/performance/src/common/timer.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
features/performance/src/common/timer.h
r1970 r1971 52 52 53 53 void timerdiv(struct timeval *tvp, float div); 54 void timesdiv(struct timespec *tvs, float div); 54 55 55 56 /* convert float time to struct timeval *tvp */ … … 69 70 #endif 70 71 72 #ifndef TIMESPEC_TO_TIMEVAL 73 #define TIMESPEC_TO_TIMEVAL(tv, ts) { \ 74 (tv)->tv_sec = (ts)->tv_sec; \ 75 (tv)->tv_usec = (ts)->tv_nsec / 1000; } 76 #endif 77 71 78 /* zero out a timer */ 72 79 #ifndef timerclear 73 80 #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 81 #endif 82 83 /* zero out a timespec */ 84 #ifndef timesclear 85 #define timesclear(tvs) (tvs)->tv_sec = (tvs)->tv_nsec = 0 74 86 #endif 75 87 … … 78 90 #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) 79 91 #endif 92 93 /* is timespec non-zero? */ 94 #ifndef timesisset 95 #define timesisset(tvs) ((tvs)->tv_sec || (tvs)->tv_nsec) 96 #endif 97 80 98 81 99 /* add tvp and uvp and store in vvp */ … … 105 123 #endif 106 124 125 #ifndef timessub 126 #define timessub(tsp, usp, vsp) \ 127 do { \ 128 (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \ 129 (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \ 130 if ((vsp)->tv_nsec < 0) { \ 131 (vsp)->tv_sec--; \ 132 (vsp)->tv_nsec += 1000000000; \ 133 } \ 134 } while (0) 135 #endif 136 107 137 /* compare tvp and uvp using cmp */ 108 138 #ifndef timercmp … … 111 141 ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ 112 142 ((tvp)->tv_sec cmp (uvp)->tv_sec)) 143 #endif 144 145 #ifndef timescmp 146 #define timescmp(tsp, usp, cmp) \ 147 (((tsp)->tv_sec == (usp)->tv_sec) ? \ 148 ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \ 149 ((tsp)->tv_sec cmp (usp)->tv_sec)) 113 150 #endif 114 151
