Skip to content

Commit

Permalink
[PKT_SCHED]: Use USEC_PER_SEC
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick McHardy <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
kaber authored and David S. Miller committed Jan 9, 2006
1 parent 2941a48 commit 538e43a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
23 changes: 12 additions & 11 deletions include/net/pkt_sched.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef __NET_PKT_SCHED_H
#define __NET_PKT_SCHED_H

#include <linux/jiffies.h>
#include <net/sch_generic.h>

struct qdisc_walker
Expand Down Expand Up @@ -59,8 +60,8 @@ typedef struct timeval psched_time_t;
typedef long psched_tdiff_t;

#define PSCHED_GET_TIME(stamp) do_gettimeofday(&(stamp))
#define PSCHED_US2JIFFIE(usecs) (((usecs)+(1000000/HZ-1))/(1000000/HZ))
#define PSCHED_JIFFIE2US(delay) ((delay)*(1000000/HZ))
#define PSCHED_US2JIFFIE(usecs) usecs_to_jiffies(usecs)
#define PSCHED_JIFFIE2US(delay) jiffies_to_usecs(delay)

#else /* !CONFIG_NET_SCH_CLK_GETTIMEOFDAY */

Expand Down Expand Up @@ -123,9 +124,9 @@ do { \
default: \
__delta = 0; \
case 2: \
__delta += 1000000; \
__delta += USEC_PER_SEC; \
case 1: \
__delta += 1000000; \
__delta += USEC_PER_SEC; \
} \
} \
__delta; \
Expand All @@ -136,9 +137,9 @@ psched_tod_diff(int delta_sec, int bound)
{
int delta;

if (bound <= 1000000 || delta_sec > (0x7FFFFFFF/1000000)-1)
if (bound <= USEC_PER_SEC || delta_sec > (0x7FFFFFFF/USEC_PER_SEC)-1)
return bound;
delta = delta_sec * 1000000;
delta = delta_sec * USEC_PER_SEC;
if (delta > bound || delta < 0)
delta = bound;
return delta;
Expand All @@ -152,9 +153,9 @@ psched_tod_diff(int delta_sec, int bound)
default: \
__delta = psched_tod_diff(__delta_sec, bound); break; \
case 2: \
__delta += 1000000; \
__delta += USEC_PER_SEC; \
case 1: \
__delta += 1000000; \
__delta += USEC_PER_SEC; \
case 0: \
if (__delta > bound || __delta < 0) \
__delta = bound; \
Expand All @@ -170,15 +171,15 @@ psched_tod_diff(int delta_sec, int bound)
({ \
int __delta = (tv).tv_usec + (delta); \
(tv_res).tv_sec = (tv).tv_sec; \
if (__delta > 1000000) { (tv_res).tv_sec++; __delta -= 1000000; } \
if (__delta > USEC_PER_SEC) { (tv_res).tv_sec++; __delta -= USEC_PER_SEC; } \
(tv_res).tv_usec = __delta; \
})

#define PSCHED_TADD(tv, delta) \
({ \
(tv).tv_usec += (delta); \
if ((tv).tv_usec > 1000000) { (tv).tv_sec++; \
(tv).tv_usec -= 1000000; } \
if ((tv).tv_usec > USEC_PER_SEC) { (tv).tv_sec++; \
(tv).tv_usec -= USEC_PER_SEC; } \
})

/* Set/check that time is in the "past perfect";
Expand Down
8 changes: 4 additions & 4 deletions net/sched/sch_hfsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ struct hfsc_sched
do { \
struct timeval tv; \
do_gettimeofday(&tv); \
(stamp) = 1000000ULL * tv.tv_sec + tv.tv_usec; \
(stamp) = 1ULL * USEC_PER_SEC * tv.tv_sec + tv.tv_usec; \
} while (0)
#endif

Expand Down Expand Up @@ -502,8 +502,8 @@ d2dx(u32 d)
u64 dx;

dx = ((u64)d * PSCHED_JIFFIE2US(HZ));
dx += 1000000 - 1;
do_div(dx, 1000000);
dx += USEC_PER_SEC - 1;
do_div(dx, USEC_PER_SEC);
return dx;
}

Expand All @@ -523,7 +523,7 @@ dx2d(u64 dx)
{
u64 d;

d = dx * 1000000;
d = dx * USEC_PER_SEC;
do_div(d, PSCHED_JIFFIE2US(HZ));
return (u32)d;
}
Expand Down

0 comments on commit 538e43a

Please sign in to comment.