lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20070304190440.21142.496.sendpatchset@localhost.localdomain>
Date:	Sun,  4 Mar 2007 20:05:31 +0100 (MET)
From:	Patrick McHardy <kaber@...sh.net>
To:	netdev@...r.kernel.org
Cc:	Patrick McHardy <kaber@...sh.net>, shemminger@...ux-foundation.org
Subject: [RFC TIME 01/03]: Add jiffies_to_nsecs/nsecs_to_jiffies

[TIME]: Add jiffies_to_nsecs/nsecs_to_jiffies

Signed-off-by: Patrick McHardy <kaber@...sh.net>

---
commit 861b3967e1bb01335e544220df779f91b20a27e7
tree cd877a5091f461008ec708b801a2fa04d3c26004
parent 2ff7354fe888f46f6629b57e463b0a1eb956c02b
author Patrick McHardy <kaber@...sh.net> Fri, 02 Mar 2007 02:49:43 +0100
committer Patrick McHardy <kaber@...sh.net> Sun, 04 Mar 2007 19:31:38 +0100

 include/linux/jiffies.h |    2 ++
 kernel/time.c           |   26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
index c080f61..e01f8f2 100644
--- a/include/linux/jiffies.h
+++ b/include/linux/jiffies.h
@@ -263,8 +263,10 @@ #endif
  */
 extern unsigned int jiffies_to_msecs(const unsigned long j);
 extern unsigned int jiffies_to_usecs(const unsigned long j);
+extern unsigned int jiffies_to_nsecs(const unsigned long j);
 extern unsigned long msecs_to_jiffies(const unsigned int m);
 extern unsigned long usecs_to_jiffies(const unsigned int u);
+extern unsigned long nsecs_to_jiffies(const unsigned int n);
 extern unsigned long timespec_to_jiffies(const struct timespec *value);
 extern void jiffies_to_timespec(const unsigned long jiffies,
 				struct timespec *value);
diff --git a/kernel/time.c b/kernel/time.c
index c6c80ea..736f5e1 100644
--- a/kernel/time.c
+++ b/kernel/time.c
@@ -500,6 +500,18 @@ #endif
 }
 EXPORT_SYMBOL(jiffies_to_usecs);
 
+unsigned int jiffies_to_nsecs(const unsigned long j)
+{
+#if HZ <= NSEC_PER_SEC && !(NSEC_PER_SEC % HZ)
+	return (NSEC_PER_SEC / HZ) * j;
+#elif HZ > NSEC_PER_SEC && !(HZ % NSEC_PER_SEC)
+	return (j + (HZ / NSEC_PER_SEC) - 1)/(HZ / NSEC_PER_SEC);
+#else
+	return (j * NSEC_PER_SEC) / HZ;
+#endif
+}
+EXPORT_SYMBOL(jiffies_to_nsecs);
+
 /*
  * When we convert to jiffies then we interpret incoming values
  * the following way:
@@ -569,6 +581,20 @@ #endif
 }
 EXPORT_SYMBOL(usecs_to_jiffies);
 
+unsigned long nsecs_to_jiffies(const unsigned int n)
+{
+	if (n > jiffies_to_nsecs(MAX_JIFFY_OFFSET))
+		return MAX_JIFFY_OFFSET;
+#if HZ <= NSEC_PER_SEC && (!NSEC_PER_SEC % HZ)
+	return (n + (NSEC_PER_SEC / HZ) - 1) / (NSEC_PER_SEC / HZ);
+#elif HZ > NSEC_PER_SEC && !(HZ % NSEC_PER_SEC)
+	return n * (HZ / NSEC_PER_SEC);
+#else
+	return (n * HZ + NSEC_PER_SEC - 1) / NSEC_PER_SEC;
+#endif
+}
+EXPORT_SYMBOL(nsecs_to_jiffies);
+
 /*
  * The TICK_NSEC - 1 rounds up the value to the next resolution.  Note
  * that a remainder subtract here would not do the right thing as the
-
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ