Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit64235fe

Browse files
committed
Don't require users of src/port/gettimeofday.c to initialize it.
Commit8001fe6 introduced thisrequirement, but per discussion, we want to avoid requirements ofthis type to make things easier on the calling code. An especiallyimportant consideration is that this may be used in frontend code,not just the backend.Asif Naeem, reviewed by Michael Paquier
1 parentf2874fe commit64235fe

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

‎src/backend/main/main.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,6 @@ startup_hacks(const char *progname)
261261

262262
/* In case of general protection fault, don't show GUI popup box */
263263
SetErrorMode(SEM_FAILCRITICALERRORS |SEM_NOGPFAULTERRORBOX);
264-
265-
#ifndefHAVE_GETTIMEOFDAY
266-
/* Figure out which syscall to use to capture timestamp information */
267-
init_win32_gettimeofday();
268-
#endif
269-
270264
}
271265
#endif/* WIN32 */
272266

‎src/include/port.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,6 @@ extern FILE *pgwin32_popen(const char *command, const char *type);
328328
#ifndefHAVE_GETTIMEOFDAY
329329
/* Last parameter not used */
330330
externintgettimeofday(structtimeval*tp,structtimezone*tzp);
331-
/* On windows we need to call some backend start setup for accurate timing */
332-
externvoidinit_win32_gettimeofday(void);
333331
#endif
334332
#else/* !WIN32 */
335333

‎src/port/gettimeofday.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#include<sys/time.h>
3232

33+
staticvoidinit_gettimeofday(LPFILETIMElpSystemTimeAsFileTime);
3334

3435
/* FILETIME of Jan 1 1970 00:00:00, the PostgreSQL epoch */
3536
staticconstunsigned__int64epoch=UINT64CONST(116444736000000000);
@@ -49,14 +50,15 @@ static const unsigned __int64 epoch = UINT64CONST(116444736000000000);
4950
typedefVOID (WINAPI*PgGetSystemTimeFn)(LPFILETIME);
5051

5152
/* Storage for the function we pick at runtime */
52-
staticPgGetSystemTimeFnpg_get_system_time=NULL;
53+
staticPgGetSystemTimeFnpg_get_system_time=&init_gettimeofday;
5354

5455
/*
55-
* During backend startup, determine if GetSystemTimePreciseAsFileTime is
56-
* available and use it; if not, fall back to GetSystemTimeAsFileTime.
56+
* One time initializer. Determine whether GetSystemTimePreciseAsFileTime
57+
* is available and if so, plan to use it; if not, fall back to
58+
* GetSystemTimeAsFileTime.
5759
*/
58-
void
59-
init_win32_gettimeofday(void)
60+
staticvoid
61+
init_gettimeofday(LPFILETIMElpSystemTimeAsFileTime)
6062
{
6163
/*
6264
* Because it's guaranteed that kernel32.dll will be linked into our
@@ -80,14 +82,16 @@ init_win32_gettimeofday(void)
8082
* The expected error from GetLastError() is ERROR_PROC_NOT_FOUND, if
8183
* the function isn't present. No other error should occur.
8284
*
83-
* It's too early in startup to elog(...) if we get some unexpected
84-
* error, and not serious enough to warrant a fprintf to stderr about
85-
* it or save the error and report it later. So silently fall back to
85+
* We can't report an error here because this might be running in
86+
* frontend code; and even if we're in the backend, it's too early
87+
* to elog(...) if we get some unexpected error. Also, it's not a
88+
* serious problem, so just silently fall back to
8689
* GetSystemTimeAsFileTime irrespective of why the failure occurred.
8790
*/
8891
pg_get_system_time=&GetSystemTimeAsFileTime;
8992
}
9093

94+
(*pg_get_system_time)(lpSystemTimeAsFileTime);
9195
}
9296

9397
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp