aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/dccp.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/dccp/dccp.h')
-rw-r--r--net/dccp/dccp.h44
1 files changed, 40 insertions, 4 deletions
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index 6ba21509e797..5cd9e794bbe2 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -429,17 +429,53 @@ extern int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state);
429extern void dccp_ackpkts_check_rcv_ackno(struct dccp_ackpkts *ap, 429extern void dccp_ackpkts_check_rcv_ackno(struct dccp_ackpkts *ap,
430 struct sock *sk, u64 ackno); 430 struct sock *sk, u64 ackno);
431 431
432static inline suseconds_t timeval_usecs(const struct timeval *tv)
433{
434 return tv->tv_sec * USEC_PER_SEC + tv->tv_usec;
435}
436
437static inline suseconds_t timeval_delta(const struct timeval *large,
438 const struct timeval *small)
439{
440 time_t secs = large->tv_sec - small->tv_sec;
441 suseconds_t usecs = large->tv_usec - small->tv_usec;
442
443 if (usecs < 0) {
444 secs--;
445 usecs += USEC_PER_SEC;
446 }
447 return secs * USEC_PER_SEC + usecs;
448}
449
450static inline void timeval_add_usecs(struct timeval *tv,
451 const suseconds_t usecs)
452{
453 tv->tv_usec += usecs;
454 while (tv->tv_usec >= USEC_PER_SEC) {
455 tv->tv_sec++;
456 tv->tv_usec -= USEC_PER_SEC;
457 }
458}
459
460static inline void timeval_sub_usecs(struct timeval *tv,
461 const suseconds_t usecs)
462{
463 tv->tv_usec -= usecs;
464 while (tv->tv_usec < 0) {
465 tv->tv_sec--;
466 tv->tv_usec += USEC_PER_SEC;
467 }
468}
469
432/* 470/*
433 * Returns the difference in usecs between timeval 471 * Returns the difference in usecs between timeval
434 * passed in and current time 472 * passed in and current time
435 */ 473 */
436static inline u32 now_delta(struct timeval tv) 474static inline suseconds_t timeval_now_delta(const struct timeval *tv)
437{ 475{
438 struct timeval now; 476 struct timeval now;
439
440 do_gettimeofday(&now); 477 do_gettimeofday(&now);
441 return (now.tv_sec - tv.tv_sec) * USEC_PER_SEC + 478 return timeval_delta(&now, tv);
442 (now.tv_usec - tv.tv_usec);
443} 479}
444 480
445#ifdef CONFIG_IP_DCCP_DEBUG 481#ifdef CONFIG_IP_DCCP_DEBUG