Forwarding again as this patch didn't make it to lse-tech, ckrm-tech and elsa-devel. Please include Andrew Morton and lkml on replies. -- Shailabh
-------- Original Message -------- Subject: [Patch 1/6] Delay accounting: timespec diff Date: Tue, 03 Jan 2006 23:23:59 +0000 From: Shailabh Nagar <[EMAIL PROTECTED]> To: Shailabh Nagar <[EMAIL PROTECTED]> CC: Andrew Morton <[EMAIL PROTECTED]>, linux-kernel <linux-kernel@vger.kernel.org>, elsa-devel <[EMAIL PROTECTED]>, LSE <[EMAIL PROTECTED]>, ckrm-tech <ckrm-tech@lists.sourceforge.net> References: <[EMAIL PROTECTED]> nstimestamp_diff.patch Add kernel utility function for measuring the interval (diff) between two timespec values, adjusting for overflow Signed-off-by: Shailabh Nagar <[EMAIL PROTECTED]> include/linux/time.h | 15 +++++++++++++++ 1 files changed, 15 insertions(+) Index: linux-2.6.15-rc7/include/linux/time.h =================================================================== --- linux-2.6.15-rc7.orig/include/linux/time.h +++ linux-2.6.15-rc7/include/linux/time.h @@ -114,6 +114,21 @@ set_normalized_timespec (struct timespec ts->tv_nsec = nsec; } +/* + * timespec_diff_ns - Return difference of two timestamps in nanoseconds + * In the rare case of @end being earlier than @start, return zero + */ +static inline unsigned long long +timespec_diff_ns(struct timespec *start, struct timespec *end) +{ + long long ret; + + ret = end->tv_sec*(1000000000) + end->tv_nsec; + ret -= start->tv_sec*(1000000000) + start->tv_nsec; + if (ret < 0) + return 0; + return ret; +} #endif /* __KERNEL__ */ #define NFDBITS __NFDBITS ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ ckrm-tech mailing list https://lists.sourceforge.net/lists/listinfo/ckrm-tech