RTTimeNow-posix.cpp revision 9aa6fbc4da65d57d07aadef838a1b032bd659c0f
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/* $Id$ */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/** @file
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * InnoTek Portable Runtime - RTTimeNow, POSIX.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/*
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Copyright (C) 2006 InnoTek Systemberatung GmbH
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync *
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * available from http://www.virtualbox.org. This file is free software;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * you can redistribute it and/or modify it under the terms of the GNU
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * General Public License as published by the Free Software Foundation,
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * distribution. VirtualBox OSE is distributed in the hope that it will
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * be useful, but WITHOUT ANY WARRANTY of any kind.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync *
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * If you received this file as part of a commercial VirtualBox
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * distribution, then only the terms of your commercial VirtualBox
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * license agreement apply instead of the previous paragraph.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/*******************************************************************************
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync* Header Files *
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync*******************************************************************************/
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#define LOG_GROUP RTLOGGROUP_TIME
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#define RTTIME_INCL_TIMEVAL
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#include <sys/time.h>
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#include <time.h>
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#include <iprt/time.h>
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/**
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Gets the current system time.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync *
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * @returns pTime.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * @param pTime Where to store the time.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncRTDECL(PRTTIMESPEC) RTTimeNow(PRTTIMESPEC pTime)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync{
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync struct timeval tv;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync gettimeofday(&tv, NULL);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync return RTTimeSpecSetTimeval(pTime, &tv);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync}
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync