Use proper format specifiers

Allows compiling for architectures with different data type sizes
This commit is contained in:
Miquel Vidal i Pinyol 2024-04-19 15:54:36 +02:00 committed by Rodrigo Arias
parent 42feb53c86
commit 478ed1f5d0
15 changed files with 55 additions and 55 deletions

View File

@ -135,7 +135,7 @@ body_execute(struct body_stack *stack, struct body *body)
DL_PREPEND(stack->top, body); DL_PREPEND(stack->top, body);
dbg("%s state is now Running, iteration %ld", dbg("%s state is now Running, iteration %lld",
body->name, body->iteration); body->name, body->iteration);
return 0; return 0;
@ -258,7 +258,7 @@ body_end(struct body_stack *stack, struct body *body)
DL_DELETE(stack->top, body); DL_DELETE(stack->top, body);
body->stack = NULL; body->stack = NULL;
dbg("%s state is now Dead, completed iteration %ld", dbg("%s state is now Dead, completed iteration %lld",
body->name, body->iteration); body->name, body->iteration);
return 0; return 0;

View File

@ -83,9 +83,9 @@ set_name(struct cpu *cpu)
int n; int n;
if (cpu->is_virtual) if (cpu->is_virtual)
n = snprintf(cpu->name, PATH_MAX, "vCPU %ld.*", i); n = snprintf(cpu->name, PATH_MAX, "vCPU %zu.*", i);
else else
n = snprintf(cpu->name, PATH_MAX, " CPU %ld.%ld", i, j); n = snprintf(cpu->name, PATH_MAX, " CPU %zu.%zu", i, j);
if (n >= PATH_MAX) { if (n >= PATH_MAX) {
err("cpu name too long"); err("cpu name too long");
@ -248,7 +248,7 @@ cpu_update(struct cpu *cpu)
err("chan_set pid failed"); err("chan_set pid failed");
return -1; return -1;
} }
dbg("cpu%ld sets th_running to %s", dbg("cpu%lld sets th_running to %s",
cpu->gindex, value_str(gid_running)); cpu->gindex, value_str(gid_running));
if (chan_set(&cpu->chan[CPU_CHAN_THRUN], gid_running) != 0) { if (chan_set(&cpu->chan[CPU_CHAN_THRUN], gid_running) != 0) {
err("chan_set gid_running failed"); err("chan_set gid_running failed");

View File

@ -118,18 +118,18 @@ panic(struct emu *emu)
if (emu->ev != NULL) { if (emu->ev != NULL) {
err("event: "); err("event: ");
err(" mcv=%s", emu->ev->mcv); err(" mcv=%s", emu->ev->mcv);
err(" rclock=%ld", emu->ev->rclock); err(" rclock=%lld", emu->ev->rclock);
err(" sclock=%ld", emu->ev->sclock); err(" sclock=%lld", emu->ev->sclock);
err(" dclock=%ld", emu->ev->dclock); err(" dclock=%lld", emu->ev->dclock);
err(" payload_size=%ld", emu->ev->payload_size); err(" payload_size=%zd", emu->ev->payload_size);
err(" is_jumbo=%d", emu->ev->is_jumbo); err(" is_jumbo=%d", emu->ev->is_jumbo);
} }
if (emu->stream != NULL) { if (emu->stream != NULL) {
err("stream: "); err("stream: ");
err(" relpath=%s", emu->stream->relpath); err(" relpath=%s", emu->stream->relpath);
err(" offset=%ld", emu->stream->offset); err(" offset=%lld", emu->stream->offset);
err(" clock_offset=%ld", emu->stream->clock_offset); err(" clock_offset=%lld", emu->stream->clock_offset);
} }
err("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); err("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
} }
@ -156,7 +156,7 @@ emu_step(struct emu *emu)
return -1; return -1;
} }
dbg("----- mvc=%s dclock=%ld -----", emu->ev->mcv, emu->ev->dclock); dbg("----- mvc=%s dclock=%lld -----", emu->ev->mcv, emu->ev->dclock);
emu_stat_update(&emu->stat, &emu->player); emu_stat_update(&emu->stat, &emu->player);

View File

@ -58,7 +58,7 @@ emu_stat_report(struct emu_stat *stat, struct player *player, int last)
int tsec = (int) ((time_elapsed / 60.0 - tmin) * 60.0); int tsec = (int) ((time_elapsed / 60.0 - tmin) * 60.0);
info("%5.1f%% done at avg %.0f kev/s \n", info("%5.1f%% done at avg %.0f kev/s \n",
progress * 100.0, avgspeed * 1e-3, tmin, tsec); progress * 100.0, avgspeed * 1e-3, tmin, tsec);
info("processed %ld input events in %.2f s\n", info("processed %lld input events in %.2f s\n",
nprocessed, time_elapsed); nprocessed, time_elapsed);
} else { } else {
int tmin = (int) (time_left / 60.0); int tmin = (int) (time_left / 60.0);

View File

@ -40,7 +40,7 @@ init_chan(struct model_cpu *cpu, const struct model_chan_spec *spec, int64_t gin
const char *ch_name = spec->ch_names[i]; const char *ch_name = spec->ch_names[i];
int track_mode = spec->track[i]; int track_mode = spec->track[i];
if (track_init(track, cpu->bay, TRACK_TYPE_TH, track_mode, "%s.cpu%ld.%s", if (track_init(track, cpu->bay, TRACK_TYPE_TH, track_mode, "%s.cpu%lld.%s",
name, gindex, ch_name) != 0) { name, gindex, ch_name) != 0) {
err("track_init failed"); err("track_init failed");
return -1; return -1;

View File

@ -25,7 +25,7 @@ default_select(struct mux *mux,
int64_t index = key.i; int64_t index = key.i;
if (index < 0 || index >= mux->ninputs) { if (index < 0 || index >= mux->ninputs) {
err("index out of bounds %ld", index); err("index out of bounds %lld", index);
return -1; return -1;
} }

View File

@ -32,8 +32,8 @@ static int
create_cpu(struct bay *bay, struct breakdown_cpu *bcpu, int64_t gindex) create_cpu(struct bay *bay, struct breakdown_cpu *bcpu, int64_t gindex)
{ {
enum chan_type t = CHAN_SINGLE; enum chan_type t = CHAN_SINGLE;
chan_init(&bcpu->tr, t, "nanos6.cpu%ld.breakdown.tr", gindex); chan_init(&bcpu->tr, t, "nanos6.cpu%lld.breakdown.tr", gindex);
chan_init(&bcpu->tri, t, "nanos6.cpu%ld.breakdown.tri", gindex); chan_init(&bcpu->tri, t, "nanos6.cpu%lld.breakdown.tri", gindex);
/* Register all channels in the bay */ /* Register all channels in the bay */
if (bay_register(bay, &bcpu->tr) != 0) { if (bay_register(bay, &bcpu->tr) != 0) {
@ -131,7 +131,7 @@ select_tr(struct mux *mux, struct value value, struct mux_input **input)
int64_t i = in_body; int64_t i = in_body;
char *inputs[] = { "subsystem", "task_type" }; char *inputs[] = { "subsystem", "task_type" };
dbg("selecting input %ld (%s)", i, inputs[i]); dbg("selecting input %lld (%s)", i, inputs[i]);
*input = mux_get_input(mux, i); *input = mux_get_input(mux, i);
return 0; return 0;

View File

@ -437,7 +437,7 @@ pre_flush(struct emu *emu)
double flush_ms = (double) flush_ns * 1e-6; double flush_ms = (double) flush_ns * 1e-6;
/* Avoid last flush warnings */ /* Avoid last flush warnings */
if (flush_ms > 10.0 && emu->thread->is_running) if (flush_ms > 10.0 && emu->thread->is_running)
warn("large flush of %.1f ms at dclock=%ld ns in tid=%d", warn("large flush of %.1f ms at dclock=%lld ns in tid=%d",
flush_ms, flush_ms,
emu->ev->dclock, emu->ev->dclock,
emu->thread->tid); emu->thread->tid);

View File

@ -86,7 +86,7 @@ find_destination(struct ring *r, uint64_t clock)
for (ssize_t i = start; i != end; i = i - 1 < 0 ? r->size - 1 : i - 1) { for (ssize_t i = start; i != end; i = i - 1 < 0 ? r->size - 1 : i - 1) {
last_clock = r->ev[i]->header.clock; last_clock = r->ev[i]->header.clock;
if (last_clock < clock) { if (last_clock < clock) {
dbg("found suitable position %ld events backwards", dbg("found suitable position %zd events backwards",
nback); nback);
return i; return i;
} }
@ -100,14 +100,14 @@ find_destination(struct ring *r, uint64_t clock)
if (r->head != 0) if (r->head != 0)
die("ring head expected to be 0"); die("ring head expected to be 0");
if (r->tail >= r->size - 1) if (r->tail >= r->size - 1)
die("ring tail=%ld expected to be less than %ld", r->tail, r->size - 1); die("ring tail=%zd expected to be less than %zd", r->tail, r->size - 1);
dbg("starting of ring with nback=%ld", nback); dbg("starting of ring with nback=%zd", nback);
return r->head; return r->head;
} }
err("cannot find a event previous to clock %lu", clock); err("cannot find a event previous to clock %lu", clock);
err("nback=%ld, last_clock=%lu", nback, last_clock); err("nback=%zd, last_clock=%lu", nback, last_clock);
return -1; return -1;
} }
@ -183,7 +183,7 @@ write_events(struct ovni_ev **table, long n, uint8_t *buf)
memcpy(buf, ev, size); memcpy(buf, ev, size);
buf += size; buf += size;
dbg("injected event %c%c%c at %ld", dbg("injected event %c%c%c at %lld",
ev->header.model, ev->header.model,
ev->header.category, ev->header.category,
ev->header.value, ev->header.value,
@ -216,7 +216,7 @@ sort_buf(uint8_t *src, uint8_t *buf, int64_t bufsize)
{ {
struct ovni_ev *ev = (struct ovni_ev *) src; struct ovni_ev *ev = (struct ovni_ev *) src;
dbg("first event before sorting %c%c%c at %ld", dbg("first event before sorting %c%c%c at %lld",
ev->header.model, ev->header.model,
ev->header.category, ev->header.category,
ev->header.value, ev->header.value,
@ -238,7 +238,7 @@ sort_buf(uint8_t *src, uint8_t *buf, int64_t bufsize)
qsort(table, n, sizeof(struct ovni_ev *), cmp_ev); qsort(table, n, sizeof(struct ovni_ev *), cmp_ev);
write_events(table, n, buf); write_events(table, n, buf);
dbg("first event after sorting %c%c%c at %ld", dbg("first event after sorting %c%c%c at %lld",
ev->header.model, ev->header.model,
ev->header.category, ev->header.category,
ev->header.value, ev->header.value,
@ -254,7 +254,7 @@ static void
write_stream(int fd, void *base, void *dst, const void *src, size_t size) write_stream(int fd, void *base, void *dst, const void *src, size_t size)
{ {
while (size > 0) { while (size > 0) {
off_t offset = (off_t) ((int64_t) dst - (int64_t) base); off_t offset = (off_t) dst - (off_t) base;
ssize_t written = pwrite(fd, src, size, offset); ssize_t written = pwrite(fd, src, size, offset);
if (written < 0) if (written < 0)
@ -270,19 +270,19 @@ static int
execute_sort_plan(struct sortplan *sp) execute_sort_plan(struct sortplan *sp)
{ {
uint64_t clock0 = sp->bad0->header.clock; uint64_t clock0 = sp->bad0->header.clock;
dbg("attempt to sort: start clock %ld", sp->bad0->header.clock); dbg("attempt to sort: start clock %lld", sp->bad0->header.clock);
uint64_t min_clock = find_min_clock((void *) sp->bad0, (void *) sp->next); uint64_t min_clock = find_min_clock((void *) sp->bad0, (void *) sp->next);
if (min_clock < clock0) { if (min_clock < clock0) {
clock0 = min_clock; clock0 = min_clock;
dbg("region not sorted, using min clock=%ld", clock0); dbg("region not sorted, using min clock=%lld", clock0);
} }
/* Cannot sort in one pass; just fail for now */ /* Cannot sort in one pass; just fail for now */
int64_t i0 = find_destination(sp->r, clock0); int64_t i0 = find_destination(sp->r, clock0);
if (i0 < 0) { if (i0 < 0) {
err("cannot find destination for region starting at clock %ld", clock0); err("cannot find destination for region starting at clock %lld", clock0);
err("consider increasing the look back size with -n"); err("consider increasing the look back size with -n");
return -1; return -1;
} }
@ -291,7 +291,7 @@ execute_sort_plan(struct sortplan *sp)
struct ovni_ev *first = sp->r->ev[i0]; struct ovni_ev *first = sp->r->ev[i0];
/* Allocate a working buffer */ /* Allocate a working buffer */
int64_t bufsize = ((int64_t) sp->next) - ((int64_t) first); uintptr_t bufsize = (uintptr_t) sp->next - (uintptr_t) first;
if (bufsize <= 0) if (bufsize <= 0)
die("bufsize is non-positive"); die("bufsize is non-positive");
@ -375,7 +375,7 @@ stream_winsort(struct stream *stream, struct ring *r)
} }
if (empty_regions > 0) if (empty_regions > 0)
warn("stream %s contains %ld empty sort regions", warn("stream %s contains %zd empty sort regions",
stream->relpath, empty_regions); stream->relpath, empty_regions);
if (updated && fdatasync(fd) < 0) if (updated && fdatasync(fd) < 0)
@ -410,7 +410,7 @@ stream_check(struct stream *stream)
uint64_t cur_clock = ovni_ev_get_clock(ev); uint64_t cur_clock = ovni_ev_get_clock(ev);
if (cur_clock < last_clock) { if (cur_clock < last_clock) {
err("backwards jump in time %ld -> %ld for stream %s", err("backwards jump in time %lld -> %lld for stream %s",
last_clock, cur_clock, stream->relpath); last_clock, cur_clock, stream->relpath);
backjump = 1; backjump = 1;
} }
@ -483,7 +483,7 @@ usage(void)
rerr("Sorts the events in each stream of the trace given in\n"); rerr("Sorts the events in each stream of the trace given in\n");
rerr("tracedir, so they are suitable for the emulator ovniemu.\n"); rerr("tracedir, so they are suitable for the emulator ovniemu.\n");
rerr("Only the events enclosed by OU[ OU] are sorted. At most a\n"); rerr("Only the events enclosed by OU[ OU] are sorted. At most a\n");
rerr("total of %ld events are looked back to insert the unsorted\n", rerr("total of %zd events are looked back to insert the unsorted\n",
max_look_back); max_look_back);
rerr("events, so the sort procedure can fail with an error.\n"); rerr("events, so the sort procedure can fail with an error.\n");
rerr("\n"); rerr("\n");
@ -492,7 +492,7 @@ usage(void)
rerr(" trace is already sorted.\n"); rerr(" trace is already sorted.\n");
rerr("\n"); rerr("\n");
rerr(" -n Set the number of events to look back.\n"); rerr(" -n Set the number of events to look back.\n");
rerr(" Defaul: %ld\n", max_look_back); rerr(" Default: %zd\n", max_look_back);
rerr("\n"); rerr("\n");
rerr(" tracedir The trace directory generated by ovni.\n"); rerr(" tracedir The trace directory generated by ovni.\n");
rerr("\n"); rerr("\n");

View File

@ -164,7 +164,7 @@ update_clocks(struct player *player, struct stream *stream)
} }
if (sclock < player->lastclock) { if (sclock < player->lastclock) {
err("backwards jump in time %ld -> %ld in stream '%s'", err("backwards jump in time %lld -> %lld in stream '%s'",
player->lastclock, sclock, stream->relpath); player->lastclock, sclock, stream->relpath);
if (player->unsorted == 0) if (player->unsorted == 0)
return -1; return -1;

View File

@ -165,7 +165,7 @@ sort_init(struct sort *sort, struct bay *bay, int64_t n, const char *name)
/* Init and register outputs */ /* Init and register outputs */
for (int64_t i = 0; i < n; i++) { for (int64_t i = 0; i < n; i++) {
struct chan *out = &sort->outputs[i]; struct chan *out = &sort->outputs[i];
chan_init(out, CHAN_SINGLE, "%s.out%ld", name, i); chan_init(out, CHAN_SINGLE, "%s.out%lld", name, i);
/* The sort module may write multiple times to the same /* The sort module may write multiple times to the same
* channel if we update more than one input. */ * channel if we update more than one input. */
@ -176,7 +176,7 @@ sort_init(struct sort *sort, struct bay *bay, int64_t n, const char *name)
chan_prop_set(out, CHAN_ALLOW_DUP, 1); chan_prop_set(out, CHAN_ALLOW_DUP, 1);
if (bay_register(bay, out) != 0) { if (bay_register(bay, out) != 0) {
err("bay_register out%ld failed", i); err("bay_register out%lld failed", i);
return -1; return -1;
} }
} }

View File

@ -118,7 +118,7 @@ stream_load(struct stream *stream, const char *tracedir, const char *relpath)
warn("stream '%s' has zero events", stream->relpath); warn("stream '%s' has zero events", stream->relpath);
stream->active = 0; stream->active = 0;
} else { } else {
err("impossible, offset %ld bigger than size %ld", err("impossible, offset %lld bigger than size %lld",
stream->offset, stream->size); stream->offset, stream->size);
return -1; return -1;
} }
@ -196,7 +196,7 @@ stream_step(struct stream *stream)
/* It cannot pass the size, otherwise we are reading garbage */ /* It cannot pass the size, otherwise we are reading garbage */
if (stream->offset > stream->size) { if (stream->offset > stream->size) {
err("stream offset %ld exceeds size %ld", err("stream offset %lld exceeds size %lld",
stream->offset, stream->size); stream->offset, stream->size);
return -1; return -1;
} }
@ -223,7 +223,7 @@ stream_step(struct stream *stream)
/* Ensure the clock grows monotonically if unsorted flag not set */ /* Ensure the clock grows monotonically if unsorted flag not set */
if (stream->unsorted == 0) { if (stream->unsorted == 0) {
if (clock < stream->lastclock) { if (clock < stream->lastclock) {
err("clock goes backwards %ld -> %ld in stream '%s' at offset %ld", err("clock goes backwards %lld -> %lld in stream '%s' at offset %lld",
stream->lastclock, stream->lastclock,
clock, clock,
stream->relpath, stream->relpath,

View File

@ -341,19 +341,19 @@ print_system(struct system *sys)
err("content of system: "); err("content of system: ");
for (struct loom *l = sys->looms; l; l = l->next) { for (struct loom *l = sys->looms; l; l = l->next) {
err("%s gindex=%d", l->id, l->gindex); err("%s gindex=%d", l->id, l->gindex);
err("+ %ld processes: ", l->nprocs); err("+ %zd processes: ", l->nprocs);
for (struct proc *p = l->procs; p; p = p->hh.next) { for (struct proc *p = l->procs; p; p = p->hh.next) {
err("| %s gindex=%d pid=%d", err("| %s gindex=%d pid=%d",
p->id, p->gindex, p->pid); p->id, p->gindex, p->pid);
err("| + %ld threads: ", p->nthreads); err("| + %d threads: ", p->nthreads);
for (struct thread *t = p->threads; t; t = t->hh.next) { for (struct thread *t = p->threads; t; t = t->hh.next) {
err("| | %s tid=%d", err("| | %s tid=%d",
t->id, t->tid); t->id, t->tid);
} }
} }
err("+ %ld phy cpus: ", l->ncpus); err("+ %zd phy cpus: ", l->ncpus);
for (struct cpu *cpu = l->cpus; cpu; cpu = cpu->hh.next) { for (struct cpu *cpu = l->cpus; cpu; cpu = cpu->hh.next) {
err("| %s gindex=%ld phyid=%d", err("| %s gindex=%lld phyid=%d",
cpu->name, cpu->name,
cpu->gindex, cpu->gindex,
cpu->phyid); cpu->phyid);
@ -361,7 +361,7 @@ print_system(struct system *sys)
err("+ 1 virtual cpu: ", l->ncpus); err("+ 1 virtual cpu: ", l->ncpus);
struct cpu *cpu = &l->vcpu; struct cpu *cpu = &l->vcpu;
err("| %s gindex=%ld phyid=%d", err("| %s gindex=%lld phyid=%d",
cpu->name, cpu->name,
cpu->gindex, cpu->gindex,
cpu->phyid); cpu->phyid);
@ -424,7 +424,7 @@ init_end_system(struct system *sys)
} }
} }
info("loaded %ld looms, %ld processes, %ld threads and %ld cpus", info("loaded %zd looms, %zd processes, %zd threads and %zd cpus",
sys->nlooms, sys->nprocs, sys->nthreads, sys->nphycpus); sys->nlooms, sys->nprocs, sys->nthreads, sys->nphycpus);
return 0; return 0;
@ -518,7 +518,7 @@ init_offsets(struct system *sys, struct trace *trace)
/* If we have more than one hostname and no offset table has been found, /* If we have more than one hostname and no offset table has been found,
* we won't be able to synchronize the clocks */ * we won't be able to synchronize the clocks */
if (n == 0 && sys->nlooms > 1) { if (n == 0 && sys->nlooms > 1) {
warn("no clock offset file loaded with %ld looms", warn("no clock offset file loaded with %zd looms",
sys->nlooms); sys->nlooms);
} }

View File

@ -392,7 +392,7 @@ thread_set_cpu(struct thread *th, struct cpu *cpu)
return -1; return -1;
} }
dbg("thread%ld sets cpu%ld", th->gindex, cpu->gindex); dbg("thread%lld sets cpu%lld", th->gindex, cpu->gindex);
th->cpu = cpu; th->cpu = cpu;
/* Update cpu channel */ /* Update cpu channel */
@ -413,7 +413,7 @@ thread_unset_cpu(struct thread *th)
return -1; return -1;
} }
dbg("thread%ld unsets cpu", th->gindex); dbg("thread%lld unsets cpu", th->gindex);
th->cpu = NULL; th->cpu = NULL;
struct chan *c = &th->chan[TH_CHAN_CPU]; struct chan *c = &th->chan[TH_CHAN_CPU];
@ -433,7 +433,7 @@ thread_migrate_cpu(struct thread *th, struct cpu *cpu)
return -1; return -1;
} }
dbg("thread%ld migrates to cpu%d", th->gindex, cpu->gindex); dbg("thread%lld migrates to cpu%lld", th->gindex, cpu->gindex);
th->cpu = cpu; th->cpu = cpu;
struct chan *c = &th->chan[TH_CHAN_CPU]; struct chan *c = &th->chan[TH_CHAN_CPU];

View File

@ -56,12 +56,12 @@ test_case(int64_t n, int64_t run)
while (old == new) while (old == new)
new = randint(); new = randint();
dbg("-- CASE run=%ld n=%ld iold=%ld old=%ld new=%ld\n", dbg("-- CASE run=%lld n=%lld iold=%lld old=%lld new=%lld\n",
run, n, iold, old, new); run, n, iold, old, new);
dbg("Contents before sort: "); dbg("Contents before sort: ");
for (int64_t i = 0; i < n; i++) { for (int64_t i = 0; i < n; i++) {
dbg("i=%ld, arr[i]=%ld, copy[i]=%ld\n", dbg("i=%lld, arr[i]=%lld, copy[i]=%lld\n",
i, arr[i], copy[i]); i, arr[i], copy[i]);
} }
@ -72,7 +72,7 @@ test_case(int64_t n, int64_t run)
dbg("Contents after sort: "); dbg("Contents after sort: ");
for (int64_t i = 0; i < n; i++) { for (int64_t i = 0; i < n; i++) {
dbg("i=%ld, arr[i]=%ld, copy[i]=%ld\n", dbg("i=%lld, arr[i]=%lld, copy[i]=%lld\n",
i, arr[i], copy[i]); i, arr[i], copy[i]);
} }
@ -94,7 +94,7 @@ test_sort_replace(void)
for (int64_t n = nmin; n <= nmax; n += nstep) { for (int64_t n = nmin; n <= nmax; n += nstep) {
for (int64_t run = 0; run < nrun; run++) for (int64_t run = 0; run < nrun; run++)
test_case(n, run); test_case(n, run);
err("n = %ld OK", n); err("n = %lld OK", n);
} }
} }