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);
dbg("%s state is now Running, iteration %ld",
dbg("%s state is now Running, iteration %lld",
body->name, body->iteration);
return 0;
@ -258,7 +258,7 @@ body_end(struct body_stack *stack, struct body *body)
DL_DELETE(stack->top, body);
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);
return 0;

View File

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

View File

@ -118,18 +118,18 @@ panic(struct emu *emu)
if (emu->ev != NULL) {
err("event: ");
err(" mcv=%s", emu->ev->mcv);
err(" rclock=%ld", emu->ev->rclock);
err(" sclock=%ld", emu->ev->sclock);
err(" dclock=%ld", emu->ev->dclock);
err(" payload_size=%ld", emu->ev->payload_size);
err(" rclock=%lld", emu->ev->rclock);
err(" sclock=%lld", emu->ev->sclock);
err(" dclock=%lld", emu->ev->dclock);
err(" payload_size=%zd", emu->ev->payload_size);
err(" is_jumbo=%d", emu->ev->is_jumbo);
}
if (emu->stream != NULL) {
err("stream: ");
err(" relpath=%s", emu->stream->relpath);
err(" offset=%ld", emu->stream->offset);
err(" clock_offset=%ld", emu->stream->clock_offset);
err(" offset=%lld", emu->stream->offset);
err(" clock_offset=%lld", emu->stream->clock_offset);
}
err("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
}
@ -156,7 +156,7 @@ emu_step(struct emu *emu)
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);

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);
info("%5.1f%% done at avg %.0f kev/s \n",
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);
} else {
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];
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) {
err("track_init failed");
return -1;

View File

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

View File

@ -32,8 +32,8 @@ static int
create_cpu(struct bay *bay, struct breakdown_cpu *bcpu, int64_t gindex)
{
enum chan_type t = CHAN_SINGLE;
chan_init(&bcpu->tr, t, "nanos6.cpu%ld.breakdown.tr", gindex);
chan_init(&bcpu->tri, t, "nanos6.cpu%ld.breakdown.tri", gindex);
chan_init(&bcpu->tr, t, "nanos6.cpu%lld.breakdown.tr", gindex);
chan_init(&bcpu->tri, t, "nanos6.cpu%lld.breakdown.tri", gindex);
/* Register all channels in the bay */
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;
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);
return 0;

View File

@ -437,7 +437,7 @@ pre_flush(struct emu *emu)
double flush_ms = (double) flush_ns * 1e-6;
/* Avoid last flush warnings */
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,
emu->ev->dclock,
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) {
last_clock = r->ev[i]->header.clock;
if (last_clock < clock) {
dbg("found suitable position %ld events backwards",
dbg("found suitable position %zd events backwards",
nback);
return i;
}
@ -100,14 +100,14 @@ find_destination(struct ring *r, uint64_t clock)
if (r->head != 0)
die("ring head expected to be 0");
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;
}
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;
}
@ -183,7 +183,7 @@ write_events(struct ovni_ev **table, long n, uint8_t *buf)
memcpy(buf, ev, size);
buf += size;
dbg("injected event %c%c%c at %ld",
dbg("injected event %c%c%c at %lld",
ev->header.model,
ev->header.category,
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;
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.category,
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);
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.category,
ev->header.value,
@ -254,7 +254,7 @@ static void
write_stream(int fd, void *base, void *dst, const void *src, size_t size)
{
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);
if (written < 0)
@ -270,19 +270,19 @@ static int
execute_sort_plan(struct sortplan *sp)
{
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);
if (min_clock < clock0) {
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 */
int64_t i0 = find_destination(sp->r, clock0);
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");
return -1;
}
@ -291,7 +291,7 @@ execute_sort_plan(struct sortplan *sp)
struct ovni_ev *first = sp->r->ev[i0];
/* 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)
die("bufsize is non-positive");
@ -375,7 +375,7 @@ stream_winsort(struct stream *stream, struct ring *r)
}
if (empty_regions > 0)
warn("stream %s contains %ld empty sort regions",
warn("stream %s contains %zd empty sort regions",
stream->relpath, empty_regions);
if (updated && fdatasync(fd) < 0)
@ -410,7 +410,7 @@ stream_check(struct stream *stream)
uint64_t cur_clock = ovni_ev_get_clock(ev);
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);
backjump = 1;
}
@ -483,7 +483,7 @@ usage(void)
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("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);
rerr("events, so the sort procedure can fail with an error.\n");
rerr("\n");
@ -492,7 +492,7 @@ usage(void)
rerr(" trace is already sorted.\n");
rerr("\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(" tracedir The trace directory generated by ovni.\n");
rerr("\n");

View File

@ -164,7 +164,7 @@ update_clocks(struct player *player, struct stream *stream)
}
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);
if (player->unsorted == 0)
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 */
for (int64_t i = 0; i < n; 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
* 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);
if (bay_register(bay, out) != 0) {
err("bay_register out%ld failed", i);
err("bay_register out%lld failed", i);
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);
stream->active = 0;
} else {
err("impossible, offset %ld bigger than size %ld",
err("impossible, offset %lld bigger than size %lld",
stream->offset, stream->size);
return -1;
}
@ -196,7 +196,7 @@ stream_step(struct stream *stream)
/* It cannot pass the size, otherwise we are reading garbage */
if (stream->offset > stream->size) {
err("stream offset %ld exceeds size %ld",
err("stream offset %lld exceeds size %lld",
stream->offset, stream->size);
return -1;
}
@ -223,7 +223,7 @@ stream_step(struct stream *stream)
/* Ensure the clock grows monotonically if unsorted flag not set */
if (stream->unsorted == 0) {
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,
clock,
stream->relpath,

View File

@ -341,19 +341,19 @@ print_system(struct system *sys)
err("content of system: ");
for (struct loom *l = sys->looms; l; l = l->next) {
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) {
err("| %s gindex=%d pid=%d",
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) {
err("| | %s tid=%d",
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) {
err("| %s gindex=%ld phyid=%d",
err("| %s gindex=%lld phyid=%d",
cpu->name,
cpu->gindex,
cpu->phyid);
@ -361,7 +361,7 @@ print_system(struct system *sys)
err("+ 1 virtual cpu: ", l->ncpus);
struct cpu *cpu = &l->vcpu;
err("| %s gindex=%ld phyid=%d",
err("| %s gindex=%lld phyid=%d",
cpu->name,
cpu->gindex,
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);
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,
* we won't be able to synchronize the clocks */
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);
}

View File

@ -392,7 +392,7 @@ thread_set_cpu(struct thread *th, struct cpu *cpu)
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;
/* Update cpu channel */
@ -413,7 +413,7 @@ thread_unset_cpu(struct thread *th)
return -1;
}
dbg("thread%ld unsets cpu", th->gindex);
dbg("thread%lld unsets cpu", th->gindex);
th->cpu = NULL;
struct chan *c = &th->chan[TH_CHAN_CPU];
@ -433,7 +433,7 @@ thread_migrate_cpu(struct thread *th, struct cpu *cpu)
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;
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)
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);
dbg("Contents before sort: ");
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]);
}
@ -72,7 +72,7 @@ test_case(int64_t n, int64_t run)
dbg("Contents after sort: ");
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]);
}
@ -94,7 +94,7 @@ test_sort_replace(void)
for (int64_t n = nmin; n <= nmax; n += nstep) {
for (int64_t run = 0; run < nrun; run++)
test_case(n, run);
err("n = %ld OK", n);
err("n = %lld OK", n);
}
}