|
@@ -62,12 +62,52 @@ unsigned cmTimeElapsedMicros( const cmTimeSpec_t* t0, const cmTimeSpec_t* t1 )
|
62
|
62
|
|
63
|
63
|
unsigned cmTimeAbsElapsedMicros( const cmTimeSpec_t* t0, const cmTimeSpec_t* t1 )
|
64
|
64
|
{
|
65
|
|
- if( t1->tv_sec > t0->tv_sec )
|
|
65
|
+ if( cmTimeIsLTE(t0,t1) )
|
66
|
66
|
return cmTimeElapsedMicros(t0,t1);
|
67
|
67
|
|
68
|
|
- if( t1->tv_sec == t0->tv_sec )
|
69
|
|
- if( t1->tv_nsec > t0->tv_nsec )
|
70
|
|
- return cmTimeElapsedMicros(t0,t1);
|
71
|
|
-
|
72
|
68
|
return cmTimeElapsedMicros(t1,t0);
|
73
|
69
|
}
|
|
70
|
+
|
|
71
|
+int cmTimeDiffMicros( const cmTimeSpec_t* t0, const cmTimeSpec_t* t1 )
|
|
72
|
+{
|
|
73
|
+ if( cmTimeIsLTE(t0,t1) )
|
|
74
|
+ return cmTimeElapsedMicros(t0,t1);
|
|
75
|
+
|
|
76
|
+ return -((int)cmTimeElapsedMicros(t1,t0));
|
|
77
|
+}
|
|
78
|
+
|
|
79
|
+bool cmTimeIsLTE( const cmTimeSpec_t* t0, const cmTimeSpec_t* t1 )
|
|
80
|
+{
|
|
81
|
+ if( t0->tv_sec < t1->tv_sec )
|
|
82
|
+ return true;
|
|
83
|
+
|
|
84
|
+ if( t0->tv_sec == t1->tv_sec )
|
|
85
|
+ return t0->tv_nsec <= t1->tv_nsec;
|
|
86
|
+
|
|
87
|
+ return false;
|
|
88
|
+}
|
|
89
|
+
|
|
90
|
+bool cmTimeIsGTE( const cmTimeSpec_t* t0, const cmTimeSpec_t* t1 )
|
|
91
|
+{
|
|
92
|
+ if( t0->tv_sec > t1->tv_sec )
|
|
93
|
+ return true;
|
|
94
|
+
|
|
95
|
+ if( t0->tv_sec == t1->tv_sec )
|
|
96
|
+ return t0->tv_nsec >= t1->tv_nsec;
|
|
97
|
+
|
|
98
|
+ return false;
|
|
99
|
+}
|
|
100
|
+
|
|
101
|
+bool cmTimeIsEqual( const cmTimeSpec_t* t0, const cmTimeSpec_t* t1 )
|
|
102
|
+{ return t0->tv_sec==t1->tv_sec && t0->tv_nsec==t1->tv_nsec; }
|
|
103
|
+
|
|
104
|
+bool cmTimeIsZero( const cmTimeSpec_t* t0 )
|
|
105
|
+{ return t0->tv_sec==0 && t0->tv_nsec==0; }
|
|
106
|
+
|
|
107
|
+void cmTimeSetZero( cmTimeSpec_t* t0 )
|
|
108
|
+{
|
|
109
|
+ t0->tv_sec = 0;
|
|
110
|
+ t0->tv_nsec = 0;
|
|
111
|
+}
|
|
112
|
+
|
|
113
|
+
|