time-win.cpp revision 1c94c0a63ba68be1a7b2c640e70d7a06464e4fca
/* $Id$ */
/** @file
* innotek Portable Runtime - Time, win32.
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP RTLOGGROUP_TIME
#include <Windows.h>
#define USE_TICK_COUNT
//#define USE_PERFORMANCE_COUNTER
#if 0//defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)
# define USE_INTERRUPT_TIME
#else
//# define USE_FILE_TIME
#endif
#ifdef USE_INTERRUPT_TIME
typedef struct _MY_KSYSTEM_TIME
{
typedef struct _MY_KUSER_SHARED_DATA
{
volatile MY_KSYSTEM_TIME InterruptTime;
/* The rest is not relevant. */
#endif /* USE_INTERRUPT_TIME */
{
#if defined USE_TICK_COUNT
/*
* This would work if it didn't flip over every 49 (or so) days.
*/
#elif defined USE_PERFORMANCE_COUNTER
/*
* Slow and no derived from InterruptTime.
*/
static LARGE_INTEGER llFreq;
static unsigned uMult;
{
if (!QueryPerformanceFrequency(&llFreq))
}
if (QueryPerformanceCounter(&ll))
else
#elif defined USE_FILE_TIME
/*
* This is SystemTime not InterruptTime.
*/
return u64 * 100;
#elif defined USE_INTERRUPT_TIME
/*
* This is exactly what we want, but we have to obtain it by non-official
* means.
*/
if (!s_pUserSharedData)
{
/** @todo find official way of getting this or some more clever
* detection algorithm if necessary. The com debugger class
* exports this too, windbg knows it too... */
}
/* use interrupt time */
do
{
#else
# error "Must select a method bright guy!"
#endif
}
/**
* 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.
*/
{
}
/**
* Gets the current local system time.
*
* @returns pTime.
* @param pTime Where to store the local time.
*/
{
}
/**
* Gets the delta between UTC and local time.
*
* @code
* RTTIMESPEC LocalTime;
* RTTimeSpecAddNano(RTTimeNow(&LocalTime), RTTimeLocalDeltaNano());
* @endcode
*
* @returns Returns the nanosecond delta between UTC and local time.
*/
{
/*
* UTC = local + Tzi.Bias;
* The bias is given in minutes.
*/
return 0;
}
/**
* Explodes a time spec to the localized timezone.
*
* @returns pTime.
* @param pTime Where to store the exploded time.
* @param pTimeSpec The time spec to exploded. (UTC)
*/
{
/*
* FileTimeToLocalFileTime does not do the right thing, so we'll have
* to convert to system time and SystemTimeToTzSpecificLocalTime instead.
*/
{
{
{
if (pTime)
return pTime;
}
}
}
/*
* The fallback is to use the current offset.
* (A better fallback would be to use the offset of the same time of the year.)
*/
if (pTime)
return pTime;
}