[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20070424100420.2860db68@dxpl.pdx.osdl.net>
Date: Tue, 24 Apr 2007 10:04:20 -0700
From: Stephen Hemminger <shemminger@...ux-foundation.org>
To: Eric Dumazet <dada1@...mosbay.com>
Cc: YOSHIFUJI Hideaki / ____________ <yoshfuji@...ux-ipv6.org>,
bunk@...sta.de, davem@...emloft.net, netdev@...r.kernel.org,
tglx@...utronix.de
Subject: [PATCH] Fix build errors on 32bit platforms with new ktime
Yoshifuji-san had the right idea, but ktime_to_us needs to be defined
in a way that works on both 64 and 32bit platforms.
Signed-off-by: Stephen Hemminger <shemminger@...ux-foundation.org>
---
include/linux/ktime.h | 13 +++++++++++++
net/ipv4/tcp_illinois.c | 2 +-
net/ipv4/tcp_lp.c | 2 +-
net/ipv4/tcp_vegas.c | 2 +-
net/ipv4/tcp_veno.c | 2 +-
5 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index 248305b..c58683a 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -121,6 +121,8 @@ static inline ktime_t timeval_to_ktime(struct timeval tv)
/* Convert ktime_t to nanoseconds - NOP in the scalar storage format: */
#define ktime_to_ns(kt) ((kt).tv64)
+#define ktime_to_us(kt) ((kt).tv64 / NSEC_PER_SEC)
+
#else
/*
@@ -257,6 +259,17 @@ static inline s64 ktime_to_ns(const ktime_t kt)
return (s64) kt.tv.sec * NSEC_PER_SEC + kt.tv.nsec;
}
+/**
+ * ktime_to_us - convert a ktime_t variable to scalar microseconds
+ * @kt: the ktime_t variable to convert
+ *
+ * Returns the scalar nanoseconds representation of @kt
+ */
+static inline s64 ktime_to_us(const ktime_t kt)
+{
+ return (s64) kt.tv_sec * USEC_PER_SEC + kt.tv_nsec / NSEC_PER_USEC;
+}
+
#endif
/*
diff --git a/net/ipv4/tcp_illinois.c b/net/ipv4/tcp_illinois.c
index 8e31659..4adc47c 100644
--- a/net/ipv4/tcp_illinois.c
+++ b/net/ipv4/tcp_illinois.c
@@ -90,7 +90,7 @@ static void tcp_illinois_acked(struct sock *sk, u32 pkts_acked, ktime_t last)
ca->acked = pkts_acked;
- rtt = ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC;
+ rtt = ktime_to_us(net_timedelta(last));
/* ignore bogus values, this prevents wraparound in alpha math */
if (rtt > RTT_MAX)
diff --git a/net/ipv4/tcp_lp.c b/net/ipv4/tcp_lp.c
index b4e062a..43294ad 100644
--- a/net/ipv4/tcp_lp.c
+++ b/net/ipv4/tcp_lp.c
@@ -266,7 +266,7 @@ static void tcp_lp_pkts_acked(struct sock *sk, u32 num_acked, ktime_t last)
struct tcp_sock *tp = tcp_sk(sk);
struct lp *lp = inet_csk_ca(sk);
- tcp_lp_rtt_sample(sk, ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC);
+ tcp_lp_rtt_sample(sk, ktime_to_us(net_timedelta(last)));
/* calc inference */
if (tcp_time_stamp > tp->rx_opt.rcv_tsecr)
diff --git a/net/ipv4/tcp_vegas.c b/net/ipv4/tcp_vegas.c
index 0f0ee7f..73e19cf 100644
--- a/net/ipv4/tcp_vegas.c
+++ b/net/ipv4/tcp_vegas.c
@@ -118,7 +118,7 @@ void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, ktime_t last)
u32 vrtt;
/* Never allow zero rtt or baseRTT */
- vrtt = (ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC) + 1;
+ vrtt = ktime_to_us(net_timedelta(last)) + 1;
/* Filter to find propagation delay: */
if (vrtt < vegas->baseRTT)
diff --git a/net/ipv4/tcp_veno.c b/net/ipv4/tcp_veno.c
index 0b50d06..9edb340 100644
--- a/net/ipv4/tcp_veno.c
+++ b/net/ipv4/tcp_veno.c
@@ -75,7 +75,7 @@ static void tcp_veno_pkts_acked(struct sock *sk, u32 cnt, ktime_t last)
u32 vrtt;
/* Never allow zero rtt or baseRTT */
- vrtt = (ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC) + 1;
+ vrtt = ktime_to_us(net_timedelta(last)) + 1;
/* Filter to find propagation delay: */
if (vrtt < veno->basertt)
--
1.5.0.6
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists