mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 23:09:52 +02:00
cleanup Systime to gettimeofday without lean and mean windows
This commit is contained in:
parent
7c9e0927ab
commit
3651eff3d6
6 changed files with 63 additions and 26 deletions
|
@ -13,7 +13,6 @@
|
||||||
#define hifi_Audio_h
|
#define hifi_Audio_h
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define WANT_TIMEVAL
|
|
||||||
#include <Systime.h>
|
#include <Systime.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define WANT_TIMEVAL
|
|
||||||
#include <Systime.h>
|
#include <Systime.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define WANT_TIMEVAL
|
|
||||||
#include <Systime.h>
|
#include <Systime.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#define hifi_BandwidthMeter_h
|
#define hifi_BandwidthMeter_h
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define WANT_TIMEVAL
|
|
||||||
#include <Systime.h>
|
#include <Systime.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,56 @@
|
||||||
#ifdef _WIN32
|
//
|
||||||
|
// Systime.cpp
|
||||||
|
// libraries/shared/src
|
||||||
|
//
|
||||||
|
// Copyright 2013 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gettimeofday
|
||||||
|
* Implementation according to:
|
||||||
|
* The Open Group Base Specifications Issue 6
|
||||||
|
* IEEE Std 1003.1, 2004 Edition
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||||
|
*
|
||||||
|
* This source code is offered for use in the public domain. You may
|
||||||
|
* use, modify or distribute it freely.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful but
|
||||||
|
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||||
|
* DISCLAIMED. This includes but is not limited to warranties of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* Contributed by:
|
||||||
|
* Danny Smith <dannysmith@users.sourceforge.net>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/time.h>
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "Systime.h"
|
|
||||||
|
|
||||||
int gettimeofday(timeval* p_tv, timezone* p_tz) {
|
/** Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */
|
||||||
int tt = timeGetTime();
|
#define _W32_FT_OFFSET (116444736000000000ULL)
|
||||||
|
|
||||||
p_tv->tv_sec = tt / 1000;
|
int __cdecl gettimeofday(struct timeval *__restrict__ tp,
|
||||||
p_tv->tv_usec = tt % 1000 * 1000;
|
void *__restrict__ tzp __attribute__((unused))) {
|
||||||
return 0;
|
union {
|
||||||
}
|
unsigned long long ns100; /**time since 1 Jan 1601 in 100ns units */
|
||||||
|
FILETIME ft;
|
||||||
#endif
|
} _now;
|
||||||
|
|
||||||
|
if (tp) {
|
||||||
|
GetSystemTimeAsFileTime (&_now.ft);
|
||||||
|
tp->tv_usec=(long)((_now.ns100 / 10ULL) % 1000000ULL );
|
||||||
|
tp->tv_sec= (long)((_now.ns100 - _W32_FT_OFFSET) / 10000000ULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Always return 0 as per Open Group Base Specifications Issue 6.
|
||||||
|
Do not set errno on error. */
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -1,17 +1,16 @@
|
||||||
|
//
|
||||||
|
// Systime.h
|
||||||
|
// libraries/shared/src
|
||||||
|
//
|
||||||
|
// Copyright 2013 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef __Systime__
|
#ifndef __Systime__
|
||||||
#define __Systime__
|
#define __Systime__
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
|
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
|
|
||||||
struct timezone {
|
#endif __Systime__
|
||||||
int tz_minuteswest; /* minutes west of Greenwich */
|
|
||||||
int tz_dsttime; /* type of dst correction */
|
|
||||||
};
|
|
||||||
|
|
||||||
int gettimeofday(struct timeval* p_tv, struct timezone* p_tz);
|
|
||||||
|
|
||||||
#endif _Win32
|
|
||||||
|
|
||||||
#endif __Systime__
|
|
Loading…
Reference in a new issue