diff --git a/src/backend/main/main.c b/src/backend/main/main.c index 582198f..2f07a58 100644 --- a/src/backend/main/main.c +++ b/src/backend/main/main.c @@ -261,12 +261,6 @@ startup_hacks(const char *progname) /* In case of general protection fault, don't show GUI popup box */ SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX); - -#ifndef HAVE_GETTIMEOFDAY - /* Figure out which syscall to use to capture timestamp information */ - init_win32_gettimeofday(); -#endif - } #endif /* WIN32 */ diff --git a/src/include/port.h b/src/include/port.h index 26d7fcd..a1ab42e 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -328,8 +328,6 @@ extern FILE *pgwin32_popen(const char *command, const char *type); #ifndef HAVE_GETTIMEOFDAY /* Last parameter not used */ extern int gettimeofday(struct timeval * tp, struct timezone * tzp); -/* On windows we need to call some backend start setup for accurate timing */ -extern void init_win32_gettimeofday(void); #endif #else /* !WIN32 */ diff --git a/src/port/gettimeofday.c b/src/port/gettimeofday.c index eabf161..660ed5e 100644 --- a/src/port/gettimeofday.c +++ b/src/port/gettimeofday.c @@ -30,6 +30,8 @@ #include +static void +init_gettimeofday(LPFILETIME lpSystemTimeAsFileTime); /* FILETIME of Jan 1 1970 00:00:00, the PostgreSQL epoch */ static const unsigned __int64 epoch = UINT64CONST(116444736000000000); @@ -49,14 +51,14 @@ static const unsigned __int64 epoch = UINT64CONST(116444736000000000); typedef VOID (WINAPI *PgGetSystemTimeFn)(LPFILETIME); /* Storage for the function we pick at runtime */ -static PgGetSystemTimeFn pg_get_system_time = NULL; +static PgGetSystemTimeFn pg_get_system_time = &init_gettimeofday; /* - * During backend startup, determine if GetSystemTimePreciseAsFileTime is + * One time initializer, determine if GetSystemTimePreciseAsFileTime is * available and use it; if not, fall back to GetSystemTimeAsFileTime. */ -void -init_win32_gettimeofday(void) +static void +init_gettimeofday(LPFILETIME lpSystemTimeAsFileTime) { /* * Because it's guaranteed that kernel32.dll will be linked into our @@ -88,6 +90,7 @@ init_win32_gettimeofday(void) pg_get_system_time = &GetSystemTimeAsFileTime; } + (*pg_get_system_time)(lpSystemTimeAsFileTime); } /*