Implement vararg support for s390. Minor fix to atomic operation for s390.
[mono.git] / mono / io-layer / timefuncs.c
blob06042ec140e2414421c5ed3d3195329ff2269565
1 /*
2 * timefuncs.c: performance timer and other time functions
4 * Author:
5 * Dick Porter (dick@ximian.com)
7 * (C) 2002 Ximian, Inc.
8 */
10 #include <config.h>
11 #include <glib.h>
12 #include <sys/time.h>
13 #include <stdlib.h>
15 #include <mono/io-layer/wapi.h>
16 #include <mono/io-layer/timefuncs-private.h>
18 #undef DEBUG
20 void _wapi_time_t_to_filetime (time_t timeval, WapiFileTime *filetime)
22 guint64 ticks;
24 ticks = ((guint64)timeval * 10000000) + 116444736000000000ULL;
25 filetime->dwLowDateTime = ticks & 0xFFFFFFFF;
26 filetime->dwHighDateTime = ticks >> 32;
29 void _wapi_timeval_to_filetime (struct timeval *tv, WapiFileTime *filetime)
31 guint64 ticks;
33 ticks = ((guint64)tv->tv_sec * 10000000) +
34 ((guint64)tv->tv_usec * 10) + 116444736000000000ULL;
35 filetime->dwLowDateTime = ticks & 0xFFFFFFFF;
36 filetime->dwHighDateTime = ticks >> 32;
39 gboolean QueryPerformanceCounter(WapiLargeInteger *count G_GNUC_UNUSED)
41 return(FALSE);
44 gboolean QueryPerformanceFrequency(WapiLargeInteger *freq G_GNUC_UNUSED)
46 return(FALSE);
49 guint32 GetTickCount (void)
51 struct timeval tv;
52 guint32 ret;
54 ret=gettimeofday (&tv, NULL);
55 if(ret==-1) {
56 return(0);
59 /* This is supposed to return milliseconds since reboot but I
60 * really can't be bothered to work out the uptime, especially
61 * as the 32bit value wraps around every 47 days
63 ret=(guint32)((tv.tv_sec * 1000) + (tv.tv_usec / 1000));
65 #ifdef DEBUG
66 g_message (G_GNUC_PRETTY_FUNCTION ": returning %d", ret);
67 #endif
69 return(ret);