2004-10-14 00:21:07 +04:00
|
|
|
/*
|
2006-08-23 04:29:35 +04:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
2014-07-27 00:17:09 +04:00
|
|
|
* Copyright (c) 2004-2014 The University of Tennessee and The University
|
2006-08-23 04:29:35 +04:00
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
2004-10-14 00:21:07 +04:00
|
|
|
*/
|
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "opal_config.h"
|
2014-07-27 00:17:09 +04:00
|
|
|
#include "opal/win32/opal_time.h"
|
2004-10-14 00:21:07 +04:00
|
|
|
|
2005-12-18 01:07:04 +03:00
|
|
|
#include<time.h>
|
2004-10-14 00:21:07 +04:00
|
|
|
|
2004-11-03 06:57:20 +03:00
|
|
|
#define EPOCHFILETIME (116444736000000000LL)
|
|
|
|
|
2006-08-20 22:50:47 +04:00
|
|
|
int gettimeofday(struct timeval *tv, struct timezone *tz)
|
2005-12-18 01:07:04 +03:00
|
|
|
{
|
2004-10-14 00:21:07 +04:00
|
|
|
FILETIME file_time;
|
2004-11-03 06:57:20 +03:00
|
|
|
LARGE_INTEGER place_holder;
|
2004-10-14 00:21:07 +04:00
|
|
|
__int64 time;
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2004-10-14 00:21:07 +04:00
|
|
|
|
|
|
|
/* returns 64 bit value which is the number of 100 nanosecond
|
|
|
|
intervals since 1601(UTC) */
|
|
|
|
GetSystemTimeAsFileTime (&file_time);
|
|
|
|
|
2015-06-24 06:59:57 +03:00
|
|
|
/* Windows recommends that we should copy the FILETIME returned
|
2004-10-14 00:21:07 +04:00
|
|
|
into a ULARGE_INTEGER and then perform the arithmetic on that */
|
|
|
|
place_holder.LowPart = file_time.dwLowDateTime;
|
|
|
|
place_holder.HighPart = file_time.dwHighDateTime;
|
|
|
|
time = place_holder.QuadPart;
|
2004-11-03 06:57:20 +03:00
|
|
|
time -= EPOCHFILETIME;
|
|
|
|
|
2004-10-14 00:21:07 +04:00
|
|
|
/* Now we can use arithmetic operations on time which is nothing but
|
|
|
|
a 64 bit integer holding time in 100 nanosec intervals */
|
|
|
|
|
|
|
|
/* convert 100 nanoseconds intervals into microseconds .. divide by 10 */
|
|
|
|
time /= 10;
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2004-10-14 00:21:07 +04:00
|
|
|
tv->tv_sec = (long)(time / 1000000);
|
|
|
|
tv->tv_usec = (long)(time % 1000000);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|