diff options
author | Thomas Munro <tmunro@postgresql.org> | 2021-03-10 20:18:15 +1300 |
---|---|---|
committer | Thomas Munro <tmunro@postgresql.org> | 2021-03-10 21:12:11 +1300 |
commit | 68b34b2338f013cb025dea360b37a3b4fc930179 (patch) | |
tree | cc6fa3b6120b405baafda4564e206713676221e8 /src | |
parent | 1657b37d7cce5c35e4c1d500f0a2f3736a087d82 (diff) | |
download | postgresql-68b34b2338f013cb025dea360b37a3b4fc930179.tar.gz postgresql-68b34b2338f013cb025dea360b37a3b4fc930179.zip |
Try to fix portability bugs in recent pgbench commits.
1. pg_time_usec_t needs to be printed with INT64_FORMAT, not %ld, or 32
bit systems complain, per lapwing.
2. Some Windows compilers didn't like a thread function not marked with
__stdcall, per whelk; let's see if this fixes the problem.
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/pgbench/pgbench.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index c0d2a124a92..e4dfbcf4720 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -121,6 +121,7 @@ typedef struct socket_set #define THREAD_T HANDLE #define THREAD_FUNC_RETURN_TYPE unsigned #define THREAD_FUNC_RETURN return 0 +#define THREAD_FUNC_CC __stdcall #define THREAD_CREATE(handle, function, arg) \ ((*(handle) = (HANDLE) _beginthreadex(NULL, 0, (function), (arg), 0, NULL)) == 0 ? errno : 0) #define THREAD_JOIN(handle) \ @@ -139,6 +140,7 @@ typedef struct socket_set #define THREAD_T pthread_t #define THREAD_FUNC_RETURN_TYPE void * #define THREAD_FUNC_RETURN return NULL +#define THREAD_FUNC_CC #define THREAD_CREATE(handle, function, arg) \ pthread_create((handle), NULL, (function), (arg)) #define THREAD_JOIN(handle) \ @@ -153,6 +155,7 @@ typedef struct socket_set #define THREAD_T void * #define THREAD_FUNC_RETURN_TYPE void * #define THREAD_FUNC_RETURN return NULL +#define THREAD_FUNC_CC #define THREAD_BARRIER_T int #define THREAD_BARRIER_INIT(barrier, n) (*(barrier) = 0) #define THREAD_BARRIER_WAIT(barrier) @@ -639,7 +642,7 @@ static void doLog(TState *thread, CState *st, static void processXactStats(TState *thread, CState *st, pg_time_usec_t *now, bool skipped, StatsData *agg); static void addScript(ParsedScript script); -static THREAD_FUNC_RETURN_TYPE threadRun(void *arg); +static THREAD_FUNC_RETURN_TYPE THREAD_FUNC_CC threadRun(void *arg); static void finishCon(CState *st); static void setalarm(int seconds); static socket_set *alloc_socket_set(int count); @@ -3565,10 +3568,12 @@ doLog(TState *thread, CState *st, { /* no, print raw transactions */ if (skipped) - fprintf(logfile, "%d " INT64_FORMAT " skipped %d %ld %ld", + fprintf(logfile, "%d " INT64_FORMAT " skipped %d " INT64_FORMAT " " + INT64_FORMAT, st->id, st->cnt, st->use_file, now / 1000000, now % 1000000); else - fprintf(logfile, "%d " INT64_FORMAT " %.0f %d %ld %ld", + fprintf(logfile, "%d " INT64_FORMAT " %.0f %d " INT64_FORMAT " " + INT64_FORMAT, st->id, st->cnt, latency, st->use_file, now / 1000000, now % 1000000); if (throttle_delay) @@ -6222,7 +6227,7 @@ main(int argc, char **argv) return exit_code; } -static THREAD_FUNC_RETURN_TYPE +static THREAD_FUNC_RETURN_TYPE THREAD_FUNC_CC threadRun(void *arg) { TState *thread = (TState *) arg; |