Increase internal clock resolution to nsec

[IPROUTE]: Increase internal clock resolution to nsec

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
This commit is contained in:
Patrick McHardy 2007-03-04 20:15:04 +01:00 committed by Stephen Hemminger
parent 147e1d4b5a
commit fd784ccaf6
2 changed files with 7 additions and 2 deletions

View File

@ -4,7 +4,7 @@
#include <asm/types.h> #include <asm/types.h>
#include <linux/pkt_sched.h> #include <linux/pkt_sched.h>
#define TIME_UNITS_PER_SEC 1000000 #define TIME_UNITS_PER_SEC 1000000000
int tc_core_time2big(long time); int tc_core_time2big(long time);
long tc_core_time2tick(long time); long tc_core_time2tick(long time);

View File

@ -228,6 +228,9 @@ int get_time(unsigned *time, const char *str)
else if (strcasecmp(p, "us") == 0 || strcasecmp(p, "usec")==0 || else if (strcasecmp(p, "us") == 0 || strcasecmp(p, "usec")==0 ||
strcasecmp(p, "usecs") == 0) strcasecmp(p, "usecs") == 0)
t *= TIME_UNITS_PER_SEC/1000000; t *= TIME_UNITS_PER_SEC/1000000;
else if (strcasecmp(p, "ns") == 0 || strcasecmp(p, "nsec")==0 ||
strcasecmp(p, "nsecs") == 0)
t *= TIME_UNITS_PER_SEC/1000000000;
else else
return -1; return -1;
} }
@ -245,8 +248,10 @@ void print_time(char *buf, int len, __u32 time)
snprintf(buf, len, "%.1fs", tmp/TIME_UNITS_PER_SEC); snprintf(buf, len, "%.1fs", tmp/TIME_UNITS_PER_SEC);
else if (tmp >= TIME_UNITS_PER_SEC/1000) else if (tmp >= TIME_UNITS_PER_SEC/1000)
snprintf(buf, len, "%.1fms", tmp/(TIME_UNITS_PER_SEC/1000)); snprintf(buf, len, "%.1fms", tmp/(TIME_UNITS_PER_SEC/1000));
else if (tmp >= TIME_UNITS_PER_SEC/1000000)
snprintf(buf, len, "%.1fus", tmp/(TIME_UNITS_PER_SEC/1000000));
else else
snprintf(buf, len, "%uus", time); snprintf(buf, len, "%uns", time);
} }
char * sprint_time(__u32 time, char *buf) char * sprint_time(__u32 time, char *buf)