Fix xslt_process() to ensure that it inserts a NULL terminator after the
[PostgreSQL.git] / src / port / gettimeofday.c
blobdda69ad2fdbe49391e4b178c2973b02c9381c112
1 /*
2 * gettimeofday.c
3 * Win32 gettimeofday() replacement
5 * $PostgreSQL$
7 * Copyright (c) 2003 SRA, Inc.
8 * Copyright (c) 2003 SKC, Inc.
10 * Permission to use, copy, modify, and distribute this software and
11 * its documentation for any purpose, without fee, and without a
12 * written agreement is hereby granted, provided that the above
13 * copyright notice and this paragraph and the following two
14 * paragraphs appear in all copies.
16 * IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT,
17 * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
18 * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
19 * DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED
20 * OF THE POSSIBILITY OF SUCH DAMAGE.
22 * THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS
25 * IS" BASIS, AND THE AUTHOR HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE,
26 * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
29 #include "c.h"
31 #include <sys/time.h>
34 /* FILETIME of Jan 1 1970 00:00:00. */
35 static const unsigned __int64 epoch = UINT64CONST(116444736000000000);
38 * timezone information is stored outside the kernel so tzp isn't used anymore.
40 * Note: this function is not for Win32 high precision timing purpose. See
41 * elapsed_time().
43 int
44 gettimeofday(struct timeval * tp, struct timezone * tzp)
46 FILETIME file_time;
47 SYSTEMTIME system_time;
48 ULARGE_INTEGER ularge;
50 GetSystemTime(&system_time);
51 SystemTimeToFileTime(&system_time, &file_time);
52 ularge.LowPart = file_time.dwLowDateTime;
53 ularge.HighPart = file_time.dwHighDateTime;
55 tp->tv_sec = (long) ((ularge.QuadPart - epoch) / 10000000L);
56 tp->tv_usec = (long) (system_time.wMilliseconds * 1000);
58 return 0;