Commit 7ae2db1d authored by Bruce Momjian's avatar Bruce Momjian

Try to get pg_test_thread to compile on Windows by using a sleeper

thread.
parent 58d74621
...@@ -28,12 +28,26 @@ ...@@ -28,12 +28,26 @@
#define OPS_FORMAT "%9.3f ops/sec" #define OPS_FORMAT "%9.3f ops/sec"
/* These are macros to avoid timing the function call overhead. */ /* These are macros to avoid timing the function call overhead. */
#ifndef WIN32
#define START_TIMER \ #define START_TIMER \
do { \ do { \
alarm_triggered = false; \ alarm_triggered = false; \
alarm(secs_per_test); \ alarm(secs_per_test); \
gettimeofday(&start_t, NULL); \ gettimeofday(&start_t, NULL); \
} while (0) } while (0)
#else
#define START_TIMER \
do { \
alarm_triggered = false; \
if (CreateThread(NULL, 0, process_alarm, NULL, 0, NULL) == \
INVALID_HANDLE_VALUE) \
{ \
fprintf(stderr, "Cannot create thread for alarm\n"); \
exit(1); \
} \
gettimeofday(&start_t, NULL); \
} while (0)
#endif
#define STOP_TIMER \ #define STOP_TIMER \
do { \ do { \
...@@ -82,7 +96,9 @@ main(int argc, char *argv[]) ...@@ -82,7 +96,9 @@ main(int argc, char *argv[])
/* Prevent leaving behind the test file */ /* Prevent leaving behind the test file */
signal(SIGINT, signal_cleanup); signal(SIGINT, signal_cleanup);
signal(SIGTERM, signal_cleanup); signal(SIGTERM, signal_cleanup);
#ifndef WIN32
signal(SIGALRM, process_alarm); signal(SIGALRM, process_alarm);
#endif
#ifdef SIGHUP #ifdef SIGHUP
/* Not defined on win32 */ /* Not defined on win32 */
signal(SIGHUP, signal_cleanup); signal(SIGHUP, signal_cleanup);
...@@ -553,7 +569,13 @@ print_elapse(struct timeval start_t, struct timeval stop_t, int ops) ...@@ -553,7 +569,13 @@ print_elapse(struct timeval start_t, struct timeval stop_t, int ops)
static void static void
process_alarm(int sig) process_alarm(int sig)
{ {
#ifdef WIN32
sleep(secs_per_test);
#endif
alarm_triggered = true; alarm_triggered = true;
#ifdef WIN32
ExitThread(0);
#endif
} }
static void static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment