Skip to content

Commit 68b34b2

Browse files
committed
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.
1 parent 1657b37 commit 68b34b2

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/bin/pgbench/pgbench.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ typedef struct socket_set
121121
#define THREAD_T HANDLE
122122
#define THREAD_FUNC_RETURN_TYPE unsigned
123123
#define THREAD_FUNC_RETURN return 0
124+
#define THREAD_FUNC_CC __stdcall
124125
#define THREAD_CREATE(handle, function, arg) \
125126
((*(handle) = (HANDLE) _beginthreadex(NULL, 0, (function), (arg), 0, NULL)) == 0 ? errno : 0)
126127
#define THREAD_JOIN(handle) \
@@ -139,6 +140,7 @@ typedef struct socket_set
139140
#define THREAD_T pthread_t
140141
#define THREAD_FUNC_RETURN_TYPE void *
141142
#define THREAD_FUNC_RETURN return NULL
143+
#define THREAD_FUNC_CC
142144
#define THREAD_CREATE(handle, function, arg) \
143145
pthread_create((handle), NULL, (function), (arg))
144146
#define THREAD_JOIN(handle) \
@@ -153,6 +155,7 @@ typedef struct socket_set
153155
#define THREAD_T void *
154156
#define THREAD_FUNC_RETURN_TYPE void *
155157
#define THREAD_FUNC_RETURN return NULL
158+
#define THREAD_FUNC_CC
156159
#define THREAD_BARRIER_T int
157160
#define THREAD_BARRIER_INIT(barrier, n) (*(barrier) = 0)
158161
#define THREAD_BARRIER_WAIT(barrier)
@@ -639,7 +642,7 @@ static void doLog(TState *thread, CState *st,
639642
static void processXactStats(TState *thread, CState *st, pg_time_usec_t *now,
640643
bool skipped, StatsData *agg);
641644
static void addScript(ParsedScript script);
642-
static THREAD_FUNC_RETURN_TYPE threadRun(void *arg);
645+
static THREAD_FUNC_RETURN_TYPE THREAD_FUNC_CC threadRun(void *arg);
643646
static void finishCon(CState *st);
644647
static void setalarm(int seconds);
645648
static socket_set *alloc_socket_set(int count);
@@ -3565,10 +3568,12 @@ doLog(TState *thread, CState *st,
35653568
{
35663569
/* no, print raw transactions */
35673570
if (skipped)
3568-
fprintf(logfile, "%d " INT64_FORMAT " skipped %d %ld %ld",
3571+
fprintf(logfile, "%d " INT64_FORMAT " skipped %d " INT64_FORMAT " "
3572+
INT64_FORMAT,
35693573
st->id, st->cnt, st->use_file, now / 1000000, now % 1000000);
35703574
else
3571-
fprintf(logfile, "%d " INT64_FORMAT " %.0f %d %ld %ld",
3575+
fprintf(logfile, "%d " INT64_FORMAT " %.0f %d " INT64_FORMAT " "
3576+
INT64_FORMAT,
35723577
st->id, st->cnt, latency, st->use_file,
35733578
now / 1000000, now % 1000000);
35743579
if (throttle_delay)
@@ -6222,7 +6227,7 @@ main(int argc, char **argv)
62226227
return exit_code;
62236228
}
62246229

6225-
static THREAD_FUNC_RETURN_TYPE
6230+
static THREAD_FUNC_RETURN_TYPE THREAD_FUNC_CC
62266231
threadRun(void *arg)
62276232
{
62286233
TState *thread = (TState *) arg;

0 commit comments

Comments
 (0)