diff --git a/src/common.h b/src/common.h index 974e0d8..d20d2ef 100644 --- a/src/common.h +++ b/src/common.h @@ -6,6 +6,7 @@ #include #include +#include extern int is_debug_enabled; diff --git a/src/emu/clkoff.c b/src/emu/clkoff.c index 76a6325..4da675c 100644 --- a/src/emu/clkoff.c +++ b/src/emu/clkoff.c @@ -59,7 +59,7 @@ cparse(struct clkoff *table, FILE *file) if (buf[0] == '\n') continue; - int ret = sscanf(buf, "%ld %s %lf %lf %lf", + int ret = sscanf(buf, "%" SCNi64 "%s %lf %lf %lf", &e.index, e.name, &e.median, &e.mean, &e.stdev); diff --git a/src/emu/nanos6/breakdown.c b/src/emu/nanos6/breakdown.c index 18aee19..b401744 100644 --- a/src/emu/nanos6/breakdown.c +++ b/src/emu/nanos6/breakdown.c @@ -302,7 +302,7 @@ model_nanos6_breakdown_finish(struct emu *emu, struct prf *prf = pvt_get_prf(bemu->pvt); for (int64_t row = 0; row < bemu->nphycpus; row++) { char name[128]; - if (snprintf(name, 128, "~CPU %4ld", bemu->nphycpus - row) >= 128) { + if (snprintf(name, 128, "~CPU %4" PRIi64, bemu->nphycpus - row) >= 128) { err("label too long"); return -1; } diff --git a/src/emu/ovnidump.c b/src/emu/ovnidump.c index 550dcc4..b0f5843 100644 --- a/src/emu/ovnidump.c +++ b/src/emu/ovnidump.c @@ -23,7 +23,7 @@ emit(struct model *model, struct player *player) struct emu_ev *ev = player_ev(player); struct stream *stream = player_stream(player); - printf("%10ld %c%c%c %s ", + printf("%10" PRIi64 " %c%c%c %s ", ev->rclock, ev->m, ev->c, diff --git a/src/emu/pv/prv.c b/src/emu/pv/prv.c index 66e1453..d66dad1 100644 --- a/src/emu/pv/prv.c +++ b/src/emu/pv/prv.c @@ -71,7 +71,7 @@ find_prv_chan(struct prv *prv, long id) static void write_line(struct prv *prv, long row_base1, long type, long value) { - fprintf(prv->file, "2:0:1:1:%ld:%ld:%ld:%ld\n", + fprintf(prv->file, "2:0:1:1:%ld:%" PRIi64 ":%ld:%ld\n", row_base1, prv->time, type, value); } diff --git a/src/emu/value.h b/src/emu/value.h index 82d78f9..f3c9704 100644 --- a/src/emu/value.h +++ b/src/emu/value.h @@ -68,7 +68,7 @@ value_str(struct value a) ret = snprintf(buf, n, "{NULL}"); break; case VALUE_INT64: - ret = snprintf(buf, n, "{int64_t %ld}", a.i); + ret = snprintf(buf, n, "{int64_t %" PRIi64 "}", a.i); break; case VALUE_DOUBLE: ret = snprintf(buf, n, "{double %e}", a.d); diff --git a/test/emu/nanos6/breakdown-no-black.c b/test/emu/nanos6/breakdown-no-black.c index 600c086..b9dfea8 100644 --- a/test/emu/nanos6/breakdown-no-black.c +++ b/test/emu/nanos6/breakdown-no-black.c @@ -35,13 +35,13 @@ main(void) die("fopen failed:"); /* Ensure non-zero for A (first event) */ - fprintf(f, "grep ':%ld:%d:[^0][0-9]*$' ovni/nanos6-breakdown.prv\n", + fprintf(f, "grep ':%" PRIi64 ":%d:[^0][0-9]*$' ovni/nanos6-breakdown.prv\n", get_delta(), PRV_NANOS6_BREAKDOWN); instr_nanos6_worker_loop_enter(); /* And for B */ - fprintf(f, "grep ':%ld:%d:[^0][0-9]*$' ovni/nanos6-breakdown.prv\n", + fprintf(f, "grep ':%" PRIi64 ":%d:[^0][0-9]*$' ovni/nanos6-breakdown.prv\n", get_delta(), PRV_NANOS6_BREAKDOWN); instr_nanos6_worker_loop_exit(); diff --git a/test/emu/nanos6/delayed-connect-ss.c b/test/emu/nanos6/delayed-connect-ss.c index 89372c2..2af9a60 100644 --- a/test/emu/nanos6/delayed-connect-ss.c +++ b/test/emu/nanos6/delayed-connect-ss.c @@ -34,16 +34,16 @@ main(void) int type = PRV_NANOS6_SUBSYSTEM; int64_t t = get_delta(); int value = ST_WORKER_LOOP; - fprintf(f, "grep ':%ld:%d:%d$' ovni/thread.prv\n", t, type, value); - fprintf(f, "grep ':%ld:%d:%d$' ovni/cpu.prv\n", t, type, value); + fprintf(f, "grep ':%" PRIi64 ":%d:%d$' ovni/thread.prv\n", t, type, value); + fprintf(f, "grep ':%" PRIi64 ":%d:%d$' ovni/cpu.prv\n", t, type, value); instr_nanos6_worker_loop_exit(); /* Also test when exitting the stacked subsystem */ t = get_delta(); value = 0; - fprintf(f, "grep ':%ld:%d:%d$' ovni/thread.prv\n", t, type, value); - fprintf(f, "grep ':%ld:%d:%d$' ovni/cpu.prv\n", t, type, value); + fprintf(f, "grep ':%" PRIi64 ":%d:%d$' ovni/thread.prv\n", t, type, value); + fprintf(f, "grep ':%" PRIi64 ":%d:%d$' ovni/cpu.prv\n", t, type, value); fclose(f); diff --git a/test/emu/nanos6/sponge-breakdown.c b/test/emu/nanos6/sponge-breakdown.c index dea22cd..3800f89 100644 --- a/test/emu/nanos6/sponge-breakdown.c +++ b/test/emu/nanos6/sponge-breakdown.c @@ -29,21 +29,21 @@ main(void) instr_nanos6_absorbing(); /* Ensure the only row in breakdown is in absorbing */ - fprintf(f, "grep '1:%ld:%d:%d$' ovni/nanos6-breakdown.prv\n", + fprintf(f, "grep '1:%" PRIi64 ":%d:%d$' ovni/nanos6-breakdown.prv\n", get_delta(), type, ST_ABSORBING); /* Set state to Resting */ instr_nanos6_resting(); /* Ensure the only row in breakdown is in Resting */ - fprintf(f, "grep '1:%ld:%d:%d$' ovni/nanos6-breakdown.prv\n", + fprintf(f, "grep '1:%" PRIi64 ":%d:%d$' ovni/nanos6-breakdown.prv\n", get_delta(), type, ST_RESTING); instr_nanos6_progressing(); /* Now the state must follow the subsystem, which should be * sponge mode */ - fprintf(f, "grep '1:%ld:%d:%d$' ovni/nanos6-breakdown.prv\n", + fprintf(f, "grep '1:%" PRIi64 ":%d:%d$' ovni/nanos6-breakdown.prv\n", get_delta(), type, ST_SPONGE); fclose(f); diff --git a/test/emu/nanos6/sponge.c b/test/emu/nanos6/sponge.c index 15f93e2..1cd5c7d 100644 --- a/test/emu/nanos6/sponge.c +++ b/test/emu/nanos6/sponge.c @@ -25,15 +25,15 @@ main(void) int type = PRV_NANOS6_SUBSYSTEM; int64_t t = get_delta(); int value = ST_SPONGE; - fprintf(f, "grep ':%ld:%d:%d$' ovni/thread.prv\n", t, type, value); - fprintf(f, "grep ':%ld:%d:%d$' ovni/cpu.prv\n", t, type, value); + fprintf(f, "grep ':%" PRIi64 ":%d:%d$' ovni/thread.prv\n", t, type, value); + fprintf(f, "grep ':%" PRIi64 ":%d:%d$' ovni/cpu.prv\n", t, type, value); instr_nanos6_sponge_exit(); t = get_delta(); value = 0; - fprintf(f, "grep ':%ld:%d:%d$' ovni/thread.prv\n", t, type, value); - fprintf(f, "grep ':%ld:%d:%d$' ovni/cpu.prv\n", t, type, value); + fprintf(f, "grep ':%" PRIi64 ":%d:%d$' ovni/thread.prv\n", t, type, value); + fprintf(f, "grep ':%" PRIi64 ":%d:%d$' ovni/cpu.prv\n", t, type, value); fclose(f); diff --git a/test/emu/nanos6/switch-same-type.c b/test/emu/nanos6/switch-same-type.c index 4969fb6..6f1eb1d 100644 --- a/test/emu/nanos6/switch-same-type.c +++ b/test/emu/nanos6/switch-same-type.c @@ -41,14 +41,14 @@ main(void) /* Check the task type */ int prvtype = PRV_NANOS6_TYPE; int64_t t = get_delta(); - fprintf(f, "grep ':%ld:%d:%d$' ovni/thread.prv\n", t, prvtype, gid); - fprintf(f, "grep ':%ld:%d:%d$' ovni/cpu.prv\n", t, prvtype, gid); + fprintf(f, "grep ':%" PRIi64 ":%d:%d$' ovni/thread.prv\n", t, prvtype, gid); + fprintf(f, "grep ':%" PRIi64 ":%d:%d$' ovni/cpu.prv\n", t, prvtype, gid); /* Check the rank */ prvtype = PRV_NANOS6_RANK; int rank = 0 + 1; /* Starts at one */ - fprintf(f, "grep ':%ld:%d:%d$' ovni/thread.prv\n", t, prvtype, rank); - fprintf(f, "grep ':%ld:%d:%d$' ovni/cpu.prv\n", t, prvtype, rank); + fprintf(f, "grep ':%" PRIi64 ":%d:%d$' ovni/thread.prv\n", t, prvtype, rank); + fprintf(f, "grep ':%" PRIi64 ":%d:%d$' ovni/cpu.prv\n", t, prvtype, rank); fclose(f); /* Exit from tasks and subsystem */ diff --git a/test/emu/nosv/switch-same-type.c b/test/emu/nosv/switch-same-type.c index 77099e8..85f4237 100644 --- a/test/emu/nosv/switch-same-type.c +++ b/test/emu/nosv/switch-same-type.c @@ -39,20 +39,20 @@ main(void) /* Check the task type */ int prvtype = PRV_NOSV_TYPE; int64_t t = get_delta(); - fprintf(f, "grep ':%ld:%d:%d$' ovni/thread.prv\n", t, prvtype, gid); - fprintf(f, "grep ':%ld:%d:%d$' ovni/cpu.prv\n", t, prvtype, gid); + fprintf(f, "grep ':%" PRIi64 ":%d:%d$' ovni/thread.prv\n", t, prvtype, gid); + fprintf(f, "grep ':%" PRIi64 ":%d:%d$' ovni/cpu.prv\n", t, prvtype, gid); /* Check the task appid */ prvtype = PRV_NOSV_APPID; int appid = 1; /* Starts at one */ - fprintf(f, "grep ':%ld:%d:%d$' ovni/thread.prv\n", t, prvtype, appid); - fprintf(f, "grep ':%ld:%d:%d$' ovni/cpu.prv\n", t, prvtype, appid); + fprintf(f, "grep ':%" PRIi64 ":%d:%d$' ovni/thread.prv\n", t, prvtype, appid); + fprintf(f, "grep ':%" PRIi64 ":%d:%d$' ovni/cpu.prv\n", t, prvtype, appid); /* Check the rank */ prvtype = PRV_NOSV_RANK; int rank = 0 + 1; /* Starts at one */ - fprintf(f, "grep ':%ld:%d:%d$' ovni/thread.prv\n", t, prvtype, rank); - fprintf(f, "grep ':%ld:%d:%d$' ovni/cpu.prv\n", t, prvtype, rank); + fprintf(f, "grep ':%" PRIi64 ":%d:%d$' ovni/thread.prv\n", t, prvtype, rank); + fprintf(f, "grep ':%" PRIi64 ":%d:%d$' ovni/cpu.prv\n", t, prvtype, rank); fclose(f); /* Exit from tasks and subsystem */ diff --git a/test/emu/nosv/task-pause-from-submit.c b/test/emu/nosv/task-pause-from-submit.c index 40240a6..da9d642 100644 --- a/test/emu/nosv/task-pause-from-submit.c +++ b/test/emu/nosv/task-pause-from-submit.c @@ -40,22 +40,22 @@ main(void) * the "Task: In body" state */ int prvtype = PRV_NOSV_SUBSYSTEM; int st = ST_TASK_BODY; - fprintf(f, "grep ':%ld:%d:%d$' ovni/thread.prv\n", get_delta(), prvtype, st); - fprintf(f, "grep ':%ld:%d:%d$' ovni/cpu.prv\n", get_delta(), prvtype, st); + fprintf(f, "grep ':%" PRIi64 ":%d:%d$' ovni/thread.prv\n", get_delta(), prvtype, st); + fprintf(f, "grep ':%" PRIi64 ":%d:%d$' ovni/cpu.prv\n", get_delta(), prvtype, st); instr_nosv_submit_enter(); /* Blocking submit */ instr_nosv_task_pause(1, 0); /* Should be left in the submit state, so no state transition in * subsystems view */ - fprintf(f, "! grep ':%ld:%d:[0-9]*$' ovni/thread.prv\n", get_delta(), prvtype); - fprintf(f, "! grep ':%ld:%d:[0-9]*$' ovni/cpu.prv\n", get_delta(), prvtype); + fprintf(f, "! grep ':%" PRIi64 ":%d:[0-9]*$' ovni/thread.prv\n", get_delta(), prvtype); + fprintf(f, "! grep ':%" PRIi64 ":%d:[0-9]*$' ovni/cpu.prv\n", get_delta(), prvtype); /* But the task state must be set to pause, so the task id * must be null */ prvtype = PRV_NOSV_TASKID; - fprintf(f, "grep ':%ld:%d:0$' ovni/thread.prv\n", get_delta(), prvtype); - fprintf(f, "grep ':%ld:%d:0$' ovni/cpu.prv\n", get_delta(), prvtype); + fprintf(f, "grep ':%" PRIi64 ":%d:0$' ovni/thread.prv\n", get_delta(), prvtype); + fprintf(f, "grep ':%" PRIi64 ":%d:0$' ovni/cpu.prv\n", get_delta(), prvtype); instr_nosv_submit_exit(); instr_nosv_task_resume(1, 0); diff --git a/test/unit/prv.c b/test/unit/prv.c index 9050dde..68a7391 100644 --- a/test/unit/prv.c +++ b/test/unit/prv.c @@ -116,7 +116,7 @@ count_prv_lines(char *fpath, int64_t time, int row0, long type, long value) int64_t ftime; long frow1, ftype, fvalue; - int ret = sscanf(line, "2:0:1:1:%ld:%ld:%ld:%ld", + int ret = sscanf(line, "2:0:1:1:%ld:%" SCNi64 ":%ld:%ld", &frow1, &ftime, &ftype, &fvalue); if (ret != 4)