2
* $PostgreSQL: /cvsroot/pgsql-server/src/port/gettimeofday.c,v 1.3 2003/11/29 19:52:13 pgsql Exp $
4
* Copyright (c) 2003 SRA, Inc.
5
* Copyright (c) 2003 SKC, Inc.
7
* Permission to use, copy, modify, and distribute this software and
8
* its documentation for any purpose, without fee, and without a
9
* written agreement is hereby granted, provided that the above
10
* copyright notice and this paragraph and the following two
11
* paragraphs appear in all copies.
13
* IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT,
14
* INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
15
* LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
16
* DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED
17
* OF THE POSSIBILITY OF SUCH DAMAGE.
19
* THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
20
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
* A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS
22
* IS" BASIS, AND THE AUTHOR HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE,
23
* SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
30
#ifndef HAVE_GETTIMEOFDAY
32
#include "ac-stdint.h"
36
#include <sys/types.h>
37
#include <sys/timeb.h>
42
/* FILETIME of Jan 1 1970 00:00:00. */
43
static const unsigned __int64 epoch = 116444736000000000L;
46
* timezone information is stored outside the kernel so tzp isn't used anymore.
50
gettimeofday(struct timeval * tp, struct timezone * tzp)
53
SYSTEMTIME system_time;
54
ULARGE_INTEGER ularge;
56
GetSystemTime(&system_time);
57
SystemTimeToFileTime(&system_time, &file_time);
58
ularge.LowPart = file_time.dwLowDateTime;
59
ularge.HighPart = file_time.dwHighDateTime;
61
tp->tv_sec = (long) ((ularge.QuadPart - epoch) / 10000000L);
62
tp->tv_usec = (long) (system_time.wMilliseconds * 1000);