Use format macro constants for fprintf and fscanf family functions
This commit is contained in:
parent
478ed1f5d0
commit
3103018404
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
extern int is_debug_enabled;
|
extern int is_debug_enabled;
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ cparse(struct clkoff *table, FILE *file)
|
|||||||
if (buf[0] == '\n')
|
if (buf[0] == '\n')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int ret = sscanf(buf, "%ld %s %lf %lf %lf",
|
int ret = sscanf(buf, "%" SCNi64 "%s %lf %lf %lf",
|
||||||
&e.index, e.name,
|
&e.index, e.name,
|
||||||
&e.median, &e.mean, &e.stdev);
|
&e.median, &e.mean, &e.stdev);
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ model_nanos6_breakdown_finish(struct emu *emu,
|
|||||||
struct prf *prf = pvt_get_prf(bemu->pvt);
|
struct prf *prf = pvt_get_prf(bemu->pvt);
|
||||||
for (int64_t row = 0; row < bemu->nphycpus; row++) {
|
for (int64_t row = 0; row < bemu->nphycpus; row++) {
|
||||||
char name[128];
|
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");
|
err("label too long");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ emit(struct model *model, struct player *player)
|
|||||||
struct emu_ev *ev = player_ev(player);
|
struct emu_ev *ev = player_ev(player);
|
||||||
struct stream *stream = player_stream(player);
|
struct stream *stream = player_stream(player);
|
||||||
|
|
||||||
printf("%10ld %c%c%c %s ",
|
printf("%10" PRIi64 " %c%c%c %s ",
|
||||||
ev->rclock,
|
ev->rclock,
|
||||||
ev->m,
|
ev->m,
|
||||||
ev->c,
|
ev->c,
|
||||||
|
@ -71,7 +71,7 @@ find_prv_chan(struct prv *prv, long id)
|
|||||||
static void
|
static void
|
||||||
write_line(struct prv *prv, long row_base1, long type, long value)
|
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);
|
row_base1, prv->time, type, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ value_str(struct value a)
|
|||||||
ret = snprintf(buf, n, "{NULL}");
|
ret = snprintf(buf, n, "{NULL}");
|
||||||
break;
|
break;
|
||||||
case VALUE_INT64:
|
case VALUE_INT64:
|
||||||
ret = snprintf(buf, n, "{int64_t %ld}", a.i);
|
ret = snprintf(buf, n, "{int64_t %" PRIi64 "}", a.i);
|
||||||
break;
|
break;
|
||||||
case VALUE_DOUBLE:
|
case VALUE_DOUBLE:
|
||||||
ret = snprintf(buf, n, "{double %e}", a.d);
|
ret = snprintf(buf, n, "{double %e}", a.d);
|
||||||
|
@ -35,13 +35,13 @@ main(void)
|
|||||||
die("fopen failed:");
|
die("fopen failed:");
|
||||||
|
|
||||||
/* Ensure non-zero for A (first event) */
|
/* 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);
|
get_delta(), PRV_NANOS6_BREAKDOWN);
|
||||||
|
|
||||||
instr_nanos6_worker_loop_enter();
|
instr_nanos6_worker_loop_enter();
|
||||||
|
|
||||||
/* And for B */
|
/* 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);
|
get_delta(), PRV_NANOS6_BREAKDOWN);
|
||||||
|
|
||||||
instr_nanos6_worker_loop_exit();
|
instr_nanos6_worker_loop_exit();
|
||||||
|
@ -34,16 +34,16 @@ main(void)
|
|||||||
int type = PRV_NANOS6_SUBSYSTEM;
|
int type = PRV_NANOS6_SUBSYSTEM;
|
||||||
int64_t t = get_delta();
|
int64_t t = get_delta();
|
||||||
int value = ST_WORKER_LOOP;
|
int value = ST_WORKER_LOOP;
|
||||||
fprintf(f, "grep ':%ld:%d:%d$' ovni/thread.prv\n", t, type, value);
|
fprintf(f, "grep ':%" PRIi64 ":%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/cpu.prv\n", t, type, value);
|
||||||
|
|
||||||
instr_nanos6_worker_loop_exit();
|
instr_nanos6_worker_loop_exit();
|
||||||
|
|
||||||
/* Also test when exitting the stacked subsystem */
|
/* Also test when exitting the stacked subsystem */
|
||||||
t = get_delta();
|
t = get_delta();
|
||||||
value = 0;
|
value = 0;
|
||||||
fprintf(f, "grep ':%ld:%d:%d$' ovni/thread.prv\n", t, type, value);
|
fprintf(f, "grep ':%" PRIi64 ":%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/cpu.prv\n", t, type, value);
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
|
@ -29,21 +29,21 @@ main(void)
|
|||||||
instr_nanos6_absorbing();
|
instr_nanos6_absorbing();
|
||||||
|
|
||||||
/* Ensure the only row in breakdown is in 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);
|
get_delta(), type, ST_ABSORBING);
|
||||||
|
|
||||||
/* Set state to Resting */
|
/* Set state to Resting */
|
||||||
instr_nanos6_resting();
|
instr_nanos6_resting();
|
||||||
|
|
||||||
/* Ensure the only row in breakdown is in 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);
|
get_delta(), type, ST_RESTING);
|
||||||
|
|
||||||
instr_nanos6_progressing();
|
instr_nanos6_progressing();
|
||||||
|
|
||||||
/* Now the state must follow the subsystem, which should be
|
/* Now the state must follow the subsystem, which should be
|
||||||
* sponge mode */
|
* 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);
|
get_delta(), type, ST_SPONGE);
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
@ -25,15 +25,15 @@ main(void)
|
|||||||
int type = PRV_NANOS6_SUBSYSTEM;
|
int type = PRV_NANOS6_SUBSYSTEM;
|
||||||
int64_t t = get_delta();
|
int64_t t = get_delta();
|
||||||
int value = ST_SPONGE;
|
int value = ST_SPONGE;
|
||||||
fprintf(f, "grep ':%ld:%d:%d$' ovni/thread.prv\n", t, type, value);
|
fprintf(f, "grep ':%" PRIi64 ":%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/cpu.prv\n", t, type, value);
|
||||||
|
|
||||||
instr_nanos6_sponge_exit();
|
instr_nanos6_sponge_exit();
|
||||||
|
|
||||||
t = get_delta();
|
t = get_delta();
|
||||||
value = 0;
|
value = 0;
|
||||||
fprintf(f, "grep ':%ld:%d:%d$' ovni/thread.prv\n", t, type, value);
|
fprintf(f, "grep ':%" PRIi64 ":%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/cpu.prv\n", t, type, value);
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
|
@ -41,14 +41,14 @@ main(void)
|
|||||||
/* Check the task type */
|
/* Check the task type */
|
||||||
int prvtype = PRV_NANOS6_TYPE;
|
int prvtype = PRV_NANOS6_TYPE;
|
||||||
int64_t t = get_delta();
|
int64_t t = get_delta();
|
||||||
fprintf(f, "grep ':%ld:%d:%d$' ovni/thread.prv\n", t, prvtype, gid);
|
fprintf(f, "grep ':%" PRIi64 ":%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/cpu.prv\n", t, prvtype, gid);
|
||||||
|
|
||||||
/* Check the rank */
|
/* Check the rank */
|
||||||
prvtype = PRV_NANOS6_RANK;
|
prvtype = PRV_NANOS6_RANK;
|
||||||
int rank = 0 + 1; /* Starts at one */
|
int rank = 0 + 1; /* Starts at one */
|
||||||
fprintf(f, "grep ':%ld:%d:%d$' ovni/thread.prv\n", t, prvtype, rank);
|
fprintf(f, "grep ':%" PRIi64 ":%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/cpu.prv\n", t, prvtype, rank);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
/* Exit from tasks and subsystem */
|
/* Exit from tasks and subsystem */
|
||||||
|
@ -39,20 +39,20 @@ main(void)
|
|||||||
/* Check the task type */
|
/* Check the task type */
|
||||||
int prvtype = PRV_NOSV_TYPE;
|
int prvtype = PRV_NOSV_TYPE;
|
||||||
int64_t t = get_delta();
|
int64_t t = get_delta();
|
||||||
fprintf(f, "grep ':%ld:%d:%d$' ovni/thread.prv\n", t, prvtype, gid);
|
fprintf(f, "grep ':%" PRIi64 ":%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/cpu.prv\n", t, prvtype, gid);
|
||||||
|
|
||||||
/* Check the task appid */
|
/* Check the task appid */
|
||||||
prvtype = PRV_NOSV_APPID;
|
prvtype = PRV_NOSV_APPID;
|
||||||
int appid = 1; /* Starts at one */
|
int appid = 1; /* Starts at one */
|
||||||
fprintf(f, "grep ':%ld:%d:%d$' ovni/thread.prv\n", t, prvtype, appid);
|
fprintf(f, "grep ':%" PRIi64 ":%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/cpu.prv\n", t, prvtype, appid);
|
||||||
|
|
||||||
/* Check the rank */
|
/* Check the rank */
|
||||||
prvtype = PRV_NOSV_RANK;
|
prvtype = PRV_NOSV_RANK;
|
||||||
int rank = 0 + 1; /* Starts at one */
|
int rank = 0 + 1; /* Starts at one */
|
||||||
fprintf(f, "grep ':%ld:%d:%d$' ovni/thread.prv\n", t, prvtype, rank);
|
fprintf(f, "grep ':%" PRIi64 ":%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/cpu.prv\n", t, prvtype, rank);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
/* Exit from tasks and subsystem */
|
/* Exit from tasks and subsystem */
|
||||||
|
@ -40,22 +40,22 @@ main(void)
|
|||||||
* the "Task: In body" state */
|
* the "Task: In body" state */
|
||||||
int prvtype = PRV_NOSV_SUBSYSTEM;
|
int prvtype = PRV_NOSV_SUBSYSTEM;
|
||||||
int st = ST_TASK_BODY;
|
int st = ST_TASK_BODY;
|
||||||
fprintf(f, "grep ':%ld:%d:%d$' ovni/thread.prv\n", get_delta(), prvtype, st);
|
fprintf(f, "grep ':%" PRIi64 ":%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/cpu.prv\n", get_delta(), prvtype, st);
|
||||||
|
|
||||||
instr_nosv_submit_enter(); /* Blocking submit */
|
instr_nosv_submit_enter(); /* Blocking submit */
|
||||||
instr_nosv_task_pause(1, 0);
|
instr_nosv_task_pause(1, 0);
|
||||||
|
|
||||||
/* Should be left in the submit state, so no state transition in
|
/* Should be left in the submit state, so no state transition in
|
||||||
* subsystems view */
|
* subsystems view */
|
||||||
fprintf(f, "! grep ':%ld:%d:[0-9]*$' ovni/thread.prv\n", get_delta(), prvtype);
|
fprintf(f, "! grep ':%" PRIi64 ":%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/cpu.prv\n", get_delta(), prvtype);
|
||||||
|
|
||||||
/* But the task state must be set to pause, so the task id
|
/* But the task state must be set to pause, so the task id
|
||||||
* must be null */
|
* must be null */
|
||||||
prvtype = PRV_NOSV_TASKID;
|
prvtype = PRV_NOSV_TASKID;
|
||||||
fprintf(f, "grep ':%ld:%d:0$' ovni/thread.prv\n", get_delta(), prvtype);
|
fprintf(f, "grep ':%" PRIi64 ":%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/cpu.prv\n", get_delta(), prvtype);
|
||||||
|
|
||||||
instr_nosv_submit_exit();
|
instr_nosv_submit_exit();
|
||||||
instr_nosv_task_resume(1, 0);
|
instr_nosv_task_resume(1, 0);
|
||||||
|
@ -116,7 +116,7 @@ count_prv_lines(char *fpath, int64_t time, int row0, long type, long value)
|
|||||||
|
|
||||||
int64_t ftime;
|
int64_t ftime;
|
||||||
long frow1, ftype, fvalue;
|
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);
|
&frow1, &ftime, &ftype, &fvalue);
|
||||||
|
|
||||||
if (ret != 4)
|
if (ret != 4)
|
||||||
|
Loading…
Reference in New Issue
Block a user