time-darwin.cpp revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/* $Id$ */
/** @file
* InnoTek Portable Runtime - Time, Darwin.
*/
/*
* Copyright (C) 2006 InnoTek Systemberatung GmbH
*
* 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 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.
*
* If you received this file as part of a commercial VirtualBox
* distribution, then only the terms of your commercial VirtualBox
* license agreement apply instead of the previous paragraph.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP RTLOGGROUP_TIME
#define RTTIME_INCL_TIMEVAL
#include <mach/mach_time.h>
#include <mach/kern_return.h>
#include <time.h>
{
static struct mach_timebase_info s_Info = { 0, 0 };
static double s_rdFactor = 0.0;
/* get the factors the first time (pray we're not racing anyone) */
{
static bool s_fFailedToGetTimeBaseInfo = false;
{
struct mach_timebase_info Info;
{
}
else
{
s_fFailedToGetTimeBaseInfo = true;
}
}
}
/* special case: absolute time is in nanoseconds */
return mach_absolute_time();
/* general case: multiply by factor to get nanoseconds. */
if (s_rdFactor != 0.0)
return mach_absolute_time() * s_rdFactor;
/* worst case: fallback to gettimeofday(). */
}
/**
* Gets the current nanosecond timestamp.
*
* This differs from RTTimeNanoTS in that it will use system APIs and not do any
* resolution or performance optimizations.
*
* @returns nanosecond timestamp.
*/
{
return rtTimeGetSystemNanoTS();
}
/**
* Gets the current millisecond timestamp.
*
* This differs from RTTimeNanoTS in that it will use system APIs and not do any
* resolution or performance optimizations.
*
* @returns millisecond timestamp.
*/
{
return rtTimeGetSystemNanoTS();
}
/**
* Gets the current system time.
*
* @returns pTime.
* @param pTime Where to store the time.
*/
{
/** @todo find nanosecond API for getting time of day. */
}