PostgreSQL Source Code  git master
win32gettimeofday.c File Reference
#include "c.h"
#include <sysinfoapi.h>
#include <sys/time.h>
Include dependency graph for win32gettimeofday.c:

Go to the source code of this file.

Macros

#define FILETIME_UNITS_PER_SEC   10000000L
 
#define FILETIME_UNITS_PER_USEC   10
 

Functions

int gettimeofday (struct timeval *tp, void *tzp)
 

Variables

static const unsigned __int64 epoch = UINT64CONST(116444736000000000)
 

Macro Definition Documentation

◆ FILETIME_UNITS_PER_SEC

#define FILETIME_UNITS_PER_SEC   10000000L

Definition at line 42 of file win32gettimeofday.c.

◆ FILETIME_UNITS_PER_USEC

#define FILETIME_UNITS_PER_USEC   10

Definition at line 43 of file win32gettimeofday.c.

Function Documentation

◆ gettimeofday()

int gettimeofday ( struct timeval *  tp,
void *  tzp 
)

Definition at line 53 of file win32gettimeofday.c.

54 {
55  FILETIME file_time;
56  ULARGE_INTEGER ularge;
57 
58  /*
59  * POSIX declines to define what tzp points to, saying "If tzp is not a
60  * null pointer, the behavior is unspecified". Let's take this
61  * opportunity to verify that noplace in Postgres tries to use any
62  * unportable behavior.
63  */
64  Assert(tzp == NULL);
65 
66  GetSystemTimePreciseAsFileTime(&file_time);
67  ularge.LowPart = file_time.dwLowDateTime;
68  ularge.HighPart = file_time.dwHighDateTime;
69 
70  tp->tv_sec = (long) ((ularge.QuadPart - epoch) / FILETIME_UNITS_PER_SEC);
71  tp->tv_usec = (long) (((ularge.QuadPart - epoch) % FILETIME_UNITS_PER_SEC)
73 
74  return 0;
75 }
Assert(fmt[strlen(fmt) - 1] !='\n')
#define FILETIME_UNITS_PER_USEC
#define FILETIME_UNITS_PER_SEC
static const unsigned __int64 epoch

References Assert(), epoch, FILETIME_UNITS_PER_SEC, and FILETIME_UNITS_PER_USEC.

Referenced by basic_archive_file_internal(), BootStrapXLOG(), feGetCurrentTimestamp(), get_formatted_log_time(), GetCurrentTimestamp(), GuessControlValues(), IsCheckpointOnSchedule(), log_status_format(), main(), make_outputdirs(), PerformRadiusTransaction(), pg_rusage_init(), pqTraceFormatTimestamp(), ResetUsage(), run_permutation(), ShowUsage(), timeofday(), and try_complete_step().

Variable Documentation

◆ epoch