Changeset 597
- Timestamp:
- 03/19/06 20:18:31 (7 years ago)
- Location:
- trunk/pdns/pdns
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/dnsreplay-mindex.cc
r572 r597 67 67 68 68 69 void normalizeTV(struct timeval& tv)70 {71 if(tv.tv_usec > 1000000) {72 ++tv.tv_sec;73 tv.tv_usec-=1000000;74 }75 else if(tv.tv_usec < 0) {76 --tv.tv_sec;77 tv.tv_usec+=1000000;78 }79 }80 81 const struct timeval operator+(const struct timeval& lhs, const struct timeval& rhs)82 {83 struct timeval ret;84 ret.tv_sec=lhs.tv_sec + rhs.tv_sec;85 ret.tv_usec=lhs.tv_usec + rhs.tv_usec;86 normalizeTV(ret);87 return ret;88 }89 90 const struct timeval operator-(const struct timeval& lhs, const struct timeval& rhs)91 {92 struct timeval ret;93 ret.tv_sec=lhs.tv_sec - rhs.tv_sec;94 ret.tv_usec=lhs.tv_usec - rhs.tv_usec;95 normalizeTV(ret);96 return ret;97 }98 69 99 70 const struct timeval operator*(int fact, const struct timeval& rhs) -
trunk/pdns/pdns/misc.cc
r567 r597 379 379 // we don't shuffle the rest 380 380 } 381 382 383 void normalizeTV(struct timeval& tv) 384 { 385 if(tv.tv_usec > 1000000) { 386 ++tv.tv_sec; 387 tv.tv_usec-=1000000; 388 } 389 else if(tv.tv_usec < 0) { 390 --tv.tv_sec; 391 tv.tv_usec+=1000000; 392 } 393 } 394 395 const struct timeval operator+(const struct timeval& lhs, const struct timeval& rhs) 396 { 397 struct timeval ret; 398 ret.tv_sec=lhs.tv_sec + rhs.tv_sec; 399 ret.tv_usec=lhs.tv_usec + rhs.tv_usec; 400 normalizeTV(ret); 401 return ret; 402 } 403 404 const struct timeval operator-(const struct timeval& lhs, const struct timeval& rhs) 405 { 406 struct timeval ret; 407 ret.tv_sec=lhs.tv_sec - rhs.tv_sec; 408 ret.tv_usec=lhs.tv_usec - rhs.tv_usec; 409 normalizeTV(ret); 410 return ret; 411 } -
trunk/pdns/pdns/misc.hh
r567 r597 138 138 inline void set(); //!< Reset the timer 139 139 inline int udiff(); //!< Return the number of microseconds since the timer was last set. 140 void setTimeval(const struct timeval& tv) 141 { 142 d_set=tv; 143 } 144 struct timeval getTimeval() 145 { 146 return d_set; 147 } 140 148 private: 141 149 struct timeval d_set; … … 232 240 string makeHexDump(const string& str); 233 241 void shuffle(vector<DNSResourceRecord>& rrs); 242 243 void normalizeTV(struct timeval& tv); 244 const struct timeval operator+(const struct timeval& lhs, const struct timeval& rhs); 245 const struct timeval operator-(const struct timeval& lhs, const struct timeval& rhs); 246 inline float makeFloat(const struct timeval& tv) 247 { 248 return tv.tv_sec + tv.tv_usec/1000000.0; 249 } 234 250 #endif