Merge pull request #1035 from DavidKarlas/cacheSdb
[mono.git] / mono / io-layer / timefuncs.c
1 /*
2  * timefuncs.c:  performance timer and other time functions
3  *
4  * Author:
5  *      Dick Porter (dick@ximian.com)
6  *
7  * (C) 2002 Ximian, Inc.
8  */
9
10 #include <config.h>
11 #include <glib.h>
12 #include <sys/time.h>
13 #include <stdlib.h>
14 #include <stdio.h>
15
16 #include <mono/io-layer/wapi.h>
17 #include <mono/io-layer/timefuncs-private.h>
18 #include "mono/utils/mono-time.h"
19
20 #undef DEBUG
21
22 void _wapi_time_t_to_filetime (time_t timeval, WapiFileTime *filetime)
23 {
24         guint64 ticks;
25         
26         ticks = ((guint64)timeval * 10000000) + 116444736000000000ULL;
27         filetime->dwLowDateTime = ticks & 0xFFFFFFFF;
28         filetime->dwHighDateTime = ticks >> 32;
29 }
30
31 void _wapi_timeval_to_filetime (struct timeval *tv, WapiFileTime *filetime)
32 {
33         guint64 ticks;
34         
35         ticks = ((guint64)tv->tv_sec * 10000000) +
36                 ((guint64)tv->tv_usec * 10) + 116444736000000000ULL;
37         filetime->dwLowDateTime = ticks & 0xFFFFFFFF;
38         filetime->dwHighDateTime = ticks >> 32;
39 }
40
41 void _wapi_guint64_to_filetime (guint64 ticks, WapiFileTime *filetime)
42 {
43         filetime->dwLowDateTime = ticks & 0xFFFFFFFF;
44         filetime->dwHighDateTime = ticks >> 32;
45 }
46
47 gboolean QueryPerformanceCounter(WapiLargeInteger *count G_GNUC_UNUSED)
48 {
49         return(FALSE);
50 }
51
52 gboolean QueryPerformanceFrequency(WapiLargeInteger *freq G_GNUC_UNUSED)
53 {
54         return(FALSE);
55 }
56
57 guint32 GetTickCount (void)
58 {
59         return mono_msec_ticks ();
60 }