forked from facebookarchive/RakNet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgettimeofday.h
74 lines (55 loc) · 1.5 KB
/
gettimeofday.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* Copyright (c) 2014, Oculus VR, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#ifndef __GET_TIME_OF_DAY_H
#define __GET_TIME_OF_DAY_H
#if defined(_WIN32) && !defined(__GNUC__) &&!defined(__GCCXML__)
#include < time.h >
struct timezone
{
int tz_minuteswest; /* minutes W of Greenwich */
int tz_dsttime; /* type of dst correction */
};
#if defined(WINDOWS_STORE_RT)
struct timeval {
long tv_sec;
long tv_usec;
};
#endif
int gettimeofday(struct timeval *tv, struct timezone *tz);
#else
#include <sys/time.h>
#include <unistd.h>
// Uncomment this if you need to
/*
// http://www.halcode.com/archives/2008/08/26/retrieving-system-time-gettimeofday/
struct timezone
{
int tz_minuteswest;
int tz_dsttime;
};
#ifdef __cplusplus
void GetSystemTimeAsFileTime(FILETIME*);
inline int gettimeofday(struct timeval* p, void* tz )
{
union {
long long ns100; // time since 1 Jan 1601 in 100ns units
FILETIME ft;
} now;
GetSystemTimeAsFileTime( &(now.ft) );
p->tv_usec=(long)((now.ns100 / 10LL) % 1000000LL );
p->tv_sec= (long)((now.ns100-(116444736000000000LL))/10000000LL);
return 0;
}
#else
int gettimeofday(struct timeval* p, void* tz );
#endif
*/
#endif
#endif