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

Commit7ae2db1

Browse files
committed
Try to get pg_test_thread to compile on Windows by using a sleeper
thread.
1 parent58d7462 commit7ae2db1

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

‎contrib/pg_test_fsync/pg_test_fsync.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,26 @@
2828
#defineOPS_FORMAT"%9.3f ops/sec"
2929

3030
/* These are macros to avoid timing the function call overhead. */
31+
#ifndefWIN32
3132
#defineSTART_TIMER\
3233
do { \
3334
alarm_triggered = false; \
3435
alarm(secs_per_test); \
3536
gettimeofday(&start_t, NULL); \
3637
} while (0)
38+
#else
39+
#defineSTART_TIMER\
40+
do { \
41+
alarm_triggered = false; \
42+
if (CreateThread(NULL, 0, process_alarm, NULL, 0, NULL) == \
43+
INVALID_HANDLE_VALUE) \
44+
{ \
45+
fprintf(stderr, "Cannot create thread for alarm\n"); \
46+
exit(1); \
47+
} \
48+
gettimeofday(&start_t, NULL); \
49+
} while (0)
50+
#endif
3751

3852
#defineSTOP_TIMER\
3953
do { \
@@ -82,7 +96,9 @@ main(int argc, char *argv[])
8296
/* Prevent leaving behind the test file */
8397
signal(SIGINT,signal_cleanup);
8498
signal(SIGTERM,signal_cleanup);
99+
#ifndefWIN32
85100
signal(SIGALRM,process_alarm);
101+
#endif
86102
#ifdefSIGHUP
87103
/* Not defined on win32 */
88104
signal(SIGHUP,signal_cleanup);
@@ -553,7 +569,13 @@ print_elapse(struct timeval start_t, struct timeval stop_t, int ops)
553569
staticvoid
554570
process_alarm(intsig)
555571
{
572+
#ifdefWIN32
573+
sleep(secs_per_test);
574+
#endif
556575
alarm_triggered= true;
576+
#ifdefWIN32
577+
ExitThread(0);
578+
#endif
557579
}
558580

559581
staticvoid

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp