/* $Id$ */
/** @file
* IPRT - Time, Ring-0 Driver, Linux.
*/
/*
* Copyright (C) 2006-2014 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "the-linux-kernel.h"
{
/*
* Use ktime_get_ts, this is also what clock_gettime(CLOCK_MONOTONIC,) is using.
*/
ktime_get_ts(&Ts);
return u64;
/*
* Seems there is no way of getting to the exact source of
* sys_clock_gettime(CLOCK_MONOTONIC, &ts) here, I think. But
* 64-bit jiffies adjusted for the initial value should be pretty
* much the same I hope.
*/
# ifdef INITIAL_JIFFIES
u64 += INITIAL_JIFFIES;
# endif
return u64;
#else /* < 2.5.60 */
# if BITS_PER_LONG >= 64
/*
* This is the same as above, except that there is no get_jiffies_64()
* here and we rely on long, and therefor jiffies, being 64-bit instead.
*/
# ifdef INITIAL_JIFFIES
u64 += INITIAL_JIFFIES;
# endif
return u64;
# else /* 32 bit jiffies */
/*
* We'll have to try track jiffy rollovers here or we'll be
* in trouble every time it flips.
*
* The high dword of the s_u64Last is the rollover count, the
* low dword is the previous jiffies. Updating is done by
* atomic compare & exchange of course.
*/
for (;;)
{
/* sample the values */
continue; /* try again */
# ifdef INITIAL_JIFFIES
ulNow += INITIAL_JIFFIES;
# endif
/*
* Check for rollover and update the static last value.
*
* We have to make sure we update it successfully to rule out
* an underrun because of racing someone.
*/
if (iDelta < 0)
{
cRollovers++;
continue; /* race, try again */
}
else
{
}
/* calculate the return value */
break;
}
return u64;
# endif /* 32 bit jiffies */
#endif /* < 2.5.60 */
}
{
return rtTimeGetSystemNanoTS();
}
{
return rtTimeGetSystemNanoTS() / RT_NS_1MS;
}
{
return rtTimeGetSystemNanoTS();
}
{
return rtTimeGetSystemNanoTS() / RT_NS_1MS;
}
{
#else /* < 2.6.16 */
#endif
}