From: Patrick McHardy Date: Sun, 4 Mar 2007 19:15:04 +0000 (+0100) Subject: Increase internal clock resolution to nsec X-Git-Tag: v2.6.23-071016~62 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd784ccaf649128965be016f857708669e798479;p=thirdparty%2Fiproute2.git Increase internal clock resolution to nsec [IPROUTE]: Increase internal clock resolution to nsec Signed-off-by: Patrick McHardy Signed-off-by: Stephen Hemminger --- diff --git a/tc/tc_core.h b/tc/tc_core.h index a139da6f6..28bf97a2e 100644 --- a/tc/tc_core.h +++ b/tc/tc_core.h @@ -4,7 +4,7 @@ #include #include -#define TIME_UNITS_PER_SEC 1000000 +#define TIME_UNITS_PER_SEC 1000000000 int tc_core_time2big(long time); long tc_core_time2tick(long time); diff --git a/tc/tc_util.c b/tc/tc_util.c index a7e42572d..a07c6aad9 100644 --- a/tc/tc_util.c +++ b/tc/tc_util.c @@ -228,6 +228,9 @@ int get_time(unsigned *time, const char *str) else if (strcasecmp(p, "us") == 0 || strcasecmp(p, "usec")==0 || strcasecmp(p, "usecs") == 0) 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 return -1; } @@ -245,8 +248,10 @@ void print_time(char *buf, int len, __u32 time) snprintf(buf, len, "%.1fs", tmp/TIME_UNITS_PER_SEC); else if (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 - snprintf(buf, len, "%uus", time); + snprintf(buf, len, "%uns", time); } char * sprint_time(__u32 time, char *buf)