From ab52e5aeafdda3721a3843f489f2c43c05c45033 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sun, 2 Jul 2017 12:13:24 +0200 Subject: [PATCH] Define USEC_PER_SEC, use "sec" and "usec" in comments. --- utcp.c | 6 +++--- utcp_priv.h | 17 +++++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/utcp.c b/utcp.c index 1627be7..f2354b1 100644 --- a/utcp.c +++ b/utcp.c @@ -49,7 +49,7 @@ (r)->tv_sec = (a)->tv_sec - (b)->tv_sec;\ (r)->tv_usec = (a)->tv_usec - (b)->tv_usec;\ if((r)->tv_usec < 0)\ - (r)->tv_sec--, (r)->tv_usec += 1000000;\ + (r)->tv_sec--, (r)->tv_usec += USEC_PER_SEC;\ } while (0) #endif @@ -1434,8 +1434,8 @@ struct utcp *utcp_init(utcp_accept_t accept, utcp_pre_accept_t pre_accept, utcp_ utcp->send = send; utcp->priv = priv; utcp->mtu = DEFAULT_MTU; - utcp->timeout = DEFAULT_USER_TIMEOUT; // s - utcp->rto = START_RTO; // us + utcp->timeout = DEFAULT_USER_TIMEOUT; // sec + utcp->rto = START_RTO; // usec return utcp; } diff --git a/utcp_priv.h b/utcp_priv.h index 24f4158..143ed60 100644 --- a/utcp_priv.h +++ b/utcp_priv.h @@ -38,10 +38,11 @@ #define DEFAULT_MTU 1000 -#define DEFAULT_USER_TIMEOUT 60 // s -#define CLOCK_GRANULARITY 1000 // us -#define START_RTO 1000000 // us -#define MAX_RTO 3000000 // us +#define USEC_PER_SEC 1000000 +#define DEFAULT_USER_TIMEOUT 60 // sec +#define CLOCK_GRANULARITY 1000 // usec +#define START_RTO 1000000 // usec +#define MAX_RTO 3000000 // usec struct hdr { uint16_t src; // Source port @@ -164,13 +165,13 @@ struct utcp { // Global socket options uint16_t mtu; - int timeout; // s + int timeout; // sec // RTT variables - uint32_t srtt; // us - uint32_t rttvar; // us - uint32_t rto; // us + uint32_t srtt; // usec + uint32_t rttvar; // usec + uint32_t rto; // usec // Connection management -- 2.39.5