Remove const array initialization

The implementation is not mandatory and clang doesn't support it.
This commit is contained in:
Rodrigo Arias 2021-11-08 17:02:39 +01:00
parent 623a938b1a
commit 73d9e323b9
3 changed files with 76 additions and 79 deletions

6
chan.c
View File

@ -65,8 +65,7 @@ chan_th_init(struct ovni_ethread *th,
int prvth; int prvth;
chan = &th->chan[id]; chan = &th->chan[id];
assert(chan_to_prvtype[id][0] == (int) id); prvth = CHAN_PRV_TH(id);
prvth = chan_to_prvtype[id][1];
chan_init(chan, track, row, prvth, prv, clock); chan_init(chan, track, row, prvth, prv, clock);
@ -95,8 +94,7 @@ chan_cpu_init(struct ovni_cpu *cpu,
int prvcpu; int prvcpu;
chan = &cpu->chan[id]; chan = &cpu->chan[id];
assert(chan_to_prvtype[id][0] == (int) id); prvcpu = CHAN_PRV_CPU(id);
prvcpu = chan_to_prvtype[id][2];
chan_init(chan, track, row, prvcpu, prv, clock); chan_init(chan, track, row, prvcpu, prv, clock);

3
emu.h
View File

@ -193,6 +193,9 @@ static const int chan_to_prvtype[CHAN_MAX][3] = {
{ CHAN_NANOS6_SUBSYSTEM, 50, 100 }, { CHAN_NANOS6_SUBSYSTEM, 50, 100 },
}; };
#define CHAN_PRV_TH(id) chan_to_prvtype[id][CHAN_TH]
#define CHAN_PRV_CPU(id) chan_to_prvtype[id][CHAN_CPU]
struct ovni_chan { struct ovni_chan {
/* Channel id */ /* Channel id */
enum chan id; enum chan id;

146
pcf.c
View File

@ -102,68 +102,61 @@ struct event_value {
struct event_type { struct event_type {
int index; int index;
int type; int chan_id;
int chan_type;
const char *label; const char *label;
struct event_value *values; const struct event_value *values;
}; };
/* ---------------- CHAN_OVNI_PID ---------------- */ /* ---------------- CHAN_OVNI_PID ---------------- */
struct event_value ovni_pid_values[] = { static const struct event_value ovni_pid_values[] = {
{ 0, "None" }, { 0, "None" },
{ ST_TOO_MANY_TH, "Unknown PID: Multiple threads running" }, { ST_TOO_MANY_TH, "Unknown PID: Multiple threads running" },
/* FIXME: PID values may collide with error code values */ /* FIXME: PID values may collide with error code values */
{ -1, NULL }, { -1, NULL },
}; };
struct event_type thread_ovni_pid = { static const struct event_type thread_ovni_pid = {
0, chan_to_prvtype[CHAN_OVNI_PID][CHAN_TH], 0, CHAN_OVNI_PID, CHAN_TH,
"Thread: PID of the RUNNING thread", "Thread: PID of the RUNNING thread",
ovni_pid_values ovni_pid_values
}; };
struct event_type cpu_ovni_pid = { static const struct event_type cpu_ovni_pid = {
0, chan_to_prvtype[CHAN_OVNI_PID][CHAN_CPU], 0, CHAN_OVNI_PID, CHAN_CPU,
"CPU: PID of the RUNNING thread", "CPU: PID of the RUNNING thread",
ovni_pid_values ovni_pid_values
}; };
/* ---------------- CHAN_OVNI_TID ---------------- */ /* ---------------- CHAN_OVNI_TID ---------------- */
struct event_value ovni_tid_values[] = { static const struct event_value ovni_tid_values[] = {
{ 0, "None" }, { 0, "None" },
{ ST_TOO_MANY_TH, "Unknown TID: Multiple threads running" }, { ST_TOO_MANY_TH, "Unknown TID: Multiple threads running" },
/* FIXME: TID values may collide with error code values */ /* FIXME: TID values may collide with error code values */
{ -1, NULL }, { -1, NULL },
}; };
struct event_type thread_ovni_tid = { static const struct event_type thread_ovni_tid = {
0, chan_to_prvtype[CHAN_OVNI_TID][CHAN_TH], 0, CHAN_OVNI_TID, CHAN_TH,
"Thread: TID of the RUNNING thread", "Thread: TID of the RUNNING thread",
ovni_tid_values ovni_tid_values
}; };
struct event_type cpu_ovni_tid = { static const struct event_type cpu_ovni_tid = {
0, chan_to_prvtype[CHAN_OVNI_TID][CHAN_CPU], 0, CHAN_OVNI_TID, CHAN_CPU,
"CPU: TID of the RUNNING thread", "CPU: TID of the RUNNING thread",
ovni_tid_values ovni_tid_values
}; };
/* ---------------- CHAN_OVNI_NRTHREADS ---------------- */ /* ---------------- CHAN_OVNI_NRTHREADS ---------------- */
struct event_value ovni_nthreads_values[] = { /* Not used */
{ -1, NULL },
};
struct event_type cpu_ovni_nthreads = {
0, chan_to_prvtype[CHAN_OVNI_NRTHREADS][CHAN_CPU],
"CPU: Number of RUNNING threads",
ovni_nthreads_values
};
/* ---------------- CHAN_OVNI_STATE ---------------- */ /* ---------------- CHAN_OVNI_STATE ---------------- */
struct event_value ovni_state_values[] = { static const struct event_value ovni_state_values[] = {
{ TH_ST_UNKNOWN, "Unknown" }, { TH_ST_UNKNOWN, "Unknown" },
{ TH_ST_RUNNING, "Running" }, { TH_ST_RUNNING, "Running" },
{ TH_ST_PAUSED, "Paused" }, { TH_ST_PAUSED, "Paused" },
@ -173,8 +166,8 @@ struct event_value ovni_state_values[] = {
{ -1, NULL }, { -1, NULL },
}; };
struct event_type thread_ovni_state = { static const struct event_type thread_ovni_state = {
0, chan_to_prvtype[CHAN_OVNI_STATE][CHAN_TH], 0, CHAN_OVNI_STATE, CHAN_TH,
"Thread: State of the CURRENT thread", "Thread: State of the CURRENT thread",
ovni_state_values ovni_state_values
}; };
@ -187,96 +180,96 @@ struct event_type thread_ovni_state = {
/* ---------------- CHAN_OVNI_CPU ---------------- */ /* ---------------- CHAN_OVNI_CPU ---------------- */
struct event_type thread_cpu_affinity = { static const struct event_type thread_cpu_affinity = {
0, chan_to_prvtype[CHAN_OVNI_CPU][CHAN_TH], 0, CHAN_OVNI_CPU, CHAN_TH,
"Thread: CPU affinity of the CURRENT thread", "Thread: CPU affinity of the CURRENT thread",
/* Ignored */ NULL /* Ignored */ NULL
}; };
/* ---------------- CHAN_OVNI_FLUSH ---------------- */ /* ---------------- CHAN_OVNI_FLUSH ---------------- */
struct event_value ovni_flush_values[] = { static const struct event_value ovni_flush_values[] = {
{ 0, "None" }, { 0, "None" },
{ ST_OVNI_FLUSHING, "Flushing" }, { ST_OVNI_FLUSHING, "Flushing" },
{ ST_TOO_MANY_TH, "Unknown flushing state: Multiple threads running" }, { ST_TOO_MANY_TH, "Unknown flushing state: Multiple threads running" },
{ -1, NULL }, { -1, NULL },
}; };
struct event_type thread_ovni_flush = { static const struct event_type thread_ovni_flush = {
0, chan_to_prvtype[CHAN_OVNI_FLUSH][CHAN_TH], 0, CHAN_OVNI_FLUSH, CHAN_TH,
"Thread: Flushing state of the CURRENT thread", "Thread: Flushing state of the CURRENT thread",
ovni_flush_values ovni_flush_values
}; };
struct event_type cpu_ovni_flush = { static const struct event_type cpu_ovni_flush = {
0, chan_to_prvtype[CHAN_OVNI_FLUSH][CHAN_CPU], 0, CHAN_OVNI_FLUSH, CHAN_CPU,
"CPU: Flusing state of the RUNNING thread", "CPU: Flusing state of the RUNNING thread",
ovni_flush_values ovni_flush_values
}; };
/* ---------------- CHAN_NOSV_TASKID ---------------- */ /* ---------------- CHAN_NOSV_TASKID ---------------- */
struct event_value nosv_taskid_values[] = { static const struct event_value nosv_taskid_values[] = {
{ ST_TOO_MANY_TH, "Unknown TaskID: Multiple threads running" }, { ST_TOO_MANY_TH, "Unknown TaskID: Multiple threads running" },
/* FIXME: Task ID values may collide with error code values */ /* FIXME: Task ID values may collide with error code values */
{ -1, NULL }, { -1, NULL },
}; };
struct event_type thread_nosv_taskid = { static const struct event_type thread_nosv_taskid = {
0, chan_to_prvtype[CHAN_NOSV_TASKID][CHAN_TH], 0, CHAN_NOSV_TASKID, CHAN_TH,
"Thread: nOS-V TaskID of the RUNNING thread", "Thread: nOS-V TaskID of the RUNNING thread",
nosv_taskid_values nosv_taskid_values
}; };
struct event_type cpu_nosv_taskid = { static const struct event_type cpu_nosv_taskid = {
0, chan_to_prvtype[CHAN_NOSV_TASKID][CHAN_CPU], 0, CHAN_NOSV_TASKID, CHAN_CPU,
"CPU: nOS-V TaskID of the RUNNING thread", "CPU: nOS-V TaskID of the RUNNING thread",
nosv_taskid_values nosv_taskid_values
}; };
/* ---------------- CHAN_NOSV_TYPEID ---------------- */ /* ---------------- CHAN_NOSV_TYPEID ---------------- */
struct event_value nosv_typeid_values[] = { static const struct event_value nosv_typeid_values[] = {
{ ST_TOO_MANY_TH, "Unknown Task TypeID: Multiple threads running" }, { ST_TOO_MANY_TH, "Unknown Task TypeID: Multiple threads running" },
/* FIXME: Task ID values may collide with error code values */ /* FIXME: Task ID values may collide with error code values */
{ -1, NULL }, { -1, NULL },
}; };
struct event_type thread_nosv_typeid = { static const struct event_type thread_nosv_typeid = {
0, chan_to_prvtype[CHAN_NOSV_TYPEID][CHAN_TH], 0, CHAN_NOSV_TYPEID, CHAN_TH,
"Thread: nOS-V task TypeID of the RUNNING thread", "Thread: nOS-V task TypeID of the RUNNING thread",
nosv_typeid_values nosv_typeid_values
}; };
struct event_type cpu_nosv_typeid = { static const struct event_type cpu_nosv_typeid = {
0, chan_to_prvtype[CHAN_NOSV_TYPEID][CHAN_CPU], 0, CHAN_NOSV_TYPEID, CHAN_CPU,
"CPU: nOS-V task TypeID of the RUNNING thread", "CPU: nOS-V task TypeID of the RUNNING thread",
nosv_typeid_values nosv_typeid_values
}; };
/* ---------------- CHAN_NOSV_APPID ---------------- */ /* ---------------- CHAN_NOSV_APPID ---------------- */
struct event_value nosv_appid_values[] = { static const struct event_value nosv_appid_values[] = {
{ ST_TOO_MANY_TH, "Unknown Task AppID: Multiple threads running" }, { ST_TOO_MANY_TH, "Unknown Task AppID: Multiple threads running" },
/* FIXME: Task ID values may collide with error code values */ /* FIXME: Task ID values may collide with error code values */
{ -1, NULL }, { -1, NULL },
}; };
struct event_type thread_nosv_appid = { static const struct event_type thread_nosv_appid = {
0, chan_to_prvtype[CHAN_NOSV_APPID][CHAN_TH], 0, CHAN_NOSV_APPID, CHAN_TH,
"Thread: nOS-V task AppID of the RUNNING thread", "Thread: nOS-V task AppID of the RUNNING thread",
nosv_appid_values nosv_appid_values
}; };
struct event_type cpu_nosv_appid = { static const struct event_type cpu_nosv_appid = {
0, chan_to_prvtype[CHAN_NOSV_APPID][CHAN_CPU], 0, CHAN_NOSV_APPID, CHAN_CPU,
"CPU: nOS-V task AppID of the RUNNING thread", "CPU: nOS-V task AppID of the RUNNING thread",
nosv_appid_values nosv_appid_values
}; };
/* ---------------- CHAN_NOSV_SUBSYSTEM ---------------- */ /* ---------------- CHAN_NOSV_SUBSYSTEM ---------------- */
struct event_value nosv_ss_values[] = { static const struct event_value nosv_ss_values[] = {
/* Errors */ /* Errors */
{ ST_BAD, "Unknown subsystem: Bad happened (report bug)" }, { ST_BAD, "Unknown subsystem: Bad happened (report bug)" },
{ ST_TOO_MANY_TH, "Unknown subsystem: Multiple threads running" }, { ST_TOO_MANY_TH, "Unknown subsystem: Multiple threads running" },
@ -302,21 +295,21 @@ struct event_value nosv_ss_values[] = {
{ -1, NULL }, { -1, NULL },
}; };
struct event_type thread_nosv_ss = { static const struct event_type thread_nosv_ss = {
0, chan_to_prvtype[CHAN_NOSV_SUBSYSTEM][CHAN_TH], 0, CHAN_NOSV_SUBSYSTEM, CHAN_TH,
"Thread: nOS-V subsystem of the ACTIVE thread", "Thread: nOS-V subsystem of the ACTIVE thread",
nosv_ss_values nosv_ss_values
}; };
struct event_type cpu_nosv_ss = { static const struct event_type cpu_nosv_ss = {
0, chan_to_prvtype[CHAN_NOSV_SUBSYSTEM][CHAN_CPU], 0, CHAN_NOSV_SUBSYSTEM, CHAN_CPU,
"CPU: nOS-V subsystem of the RUNNING thread", "CPU: nOS-V subsystem of the RUNNING thread",
nosv_ss_values nosv_ss_values
}; };
/* ---------------- CHAN_TAMPI_MODE ---------------- */ /* ---------------- CHAN_TAMPI_MODE ---------------- */
struct event_value tampi_mode_values[] = { static const struct event_value tampi_mode_values[] = {
{ ST_NULL, "NULL" }, { ST_NULL, "NULL" },
{ ST_TOO_MANY_TH, "TAMPI: Unknown, multiple threads running" }, { ST_TOO_MANY_TH, "TAMPI: Unknown, multiple threads running" },
{ ST_TAMPI_SEND, "TAMPI: Send" }, { ST_TAMPI_SEND, "TAMPI: Send" },
@ -328,21 +321,21 @@ struct event_value tampi_mode_values[] = {
{ -1, NULL }, { -1, NULL },
}; };
struct event_type cpu_tampi_mode = { static const struct event_type thread_tampi_mode = {
0, chan_to_prvtype[CHAN_TAMPI_MODE][CHAN_CPU], 0, CHAN_TAMPI_MODE, CHAN_TH,
"CPU: TAMPI mode of the RUNNING thread", "Thread: TAMPI mode of the RUNNING thread",
tampi_mode_values tampi_mode_values
}; };
struct event_type thread_tampi_mode = { static const struct event_type cpu_tampi_mode = {
0, chan_to_prvtype[CHAN_TAMPI_MODE][CHAN_TH], 0, CHAN_TAMPI_MODE, CHAN_CPU,
"Thread: TAMPI mode of the RUNNING thread", "CPU: TAMPI mode of the RUNNING thread",
tampi_mode_values tampi_mode_values
}; };
/* ---------------- CHAN_OPENMP_MODE ---------------- */ /* ---------------- CHAN_OPENMP_MODE ---------------- */
struct event_value openmp_mode_values[] = { static const struct event_value openmp_mode_values[] = {
{ ST_NULL, "NULL" }, { ST_NULL, "NULL" },
{ ST_TOO_MANY_TH, "OpenMP: Unknown, multiple threads running" }, { ST_TOO_MANY_TH, "OpenMP: Unknown, multiple threads running" },
{ ST_OPENMP_TASK, "OpenMP: Task" }, { ST_OPENMP_TASK, "OpenMP: Task" },
@ -350,21 +343,21 @@ struct event_value openmp_mode_values[] = {
{ -1, NULL }, { -1, NULL },
}; };
struct event_type cpu_openmp_mode = { static const struct event_type thread_openmp_mode = {
0, chan_to_prvtype[CHAN_OPENMP_MODE][CHAN_CPU], 0, CHAN_OPENMP_MODE, CHAN_TH,
"CPU: OpenMP mode of the RUNNING thread", "Thread: OpenMP mode of the RUNNING thread",
openmp_mode_values openmp_mode_values
}; };
struct event_type thread_openmp_mode = { static const struct event_type cpu_openmp_mode = {
0, chan_to_prvtype[CHAN_OPENMP_MODE][CHAN_TH], 0, CHAN_OPENMP_MODE, CHAN_CPU,
"Thread: OpenMP mode of the RUNNING thread", "CPU: OpenMP mode of the RUNNING thread",
openmp_mode_values openmp_mode_values
}; };
/* ---------------- CHAN_NANOS6_SUBSYSTEM ---------------- */ /* ---------------- CHAN_NANOS6_SUBSYSTEM ---------------- */
struct event_value nanos6_mode_values[] = { static const struct event_value nanos6_mode_values[] = {
{ ST_NULL, "NULL" }, { ST_NULL, "NULL" },
{ ST_TOO_MANY_TH, "Nanos6: Multiple threads running" }, { ST_TOO_MANY_TH, "Nanos6: Multiple threads running" },
{ ST_NANOS6_REGISTER, "Dependencies: Registering task accesses" }, { ST_NANOS6_REGISTER, "Dependencies: Registering task accesses" },
@ -378,14 +371,14 @@ struct event_value nanos6_mode_values[] = {
{ -1, NULL }, { -1, NULL },
}; };
struct event_type cpu_nanos6_mode = { static const struct event_type cpu_nanos6_mode = {
0, chan_to_prvtype[CHAN_NANOS6_SUBSYSTEM][CHAN_CPU], 0, CHAN_NANOS6_SUBSYSTEM, CHAN_CPU,
"CPU: Nanos6 subsystem of the RUNNING thread", "CPU: Nanos6 subsystem of the RUNNING thread",
nanos6_mode_values nanos6_mode_values
}; };
struct event_type thread_nanos6_mode = { static const struct event_type thread_nanos6_mode = {
0, chan_to_prvtype[CHAN_NANOS6_SUBSYSTEM][CHAN_TH], 0, CHAN_NANOS6_SUBSYSTEM, CHAN_TH,
"Thread: Nanos6 subsystem of the RUNNING thread", "Thread: Nanos6 subsystem of the RUNNING thread",
nanos6_mode_values nanos6_mode_values
}; };
@ -431,11 +424,12 @@ write_event_type_header(FILE *f, int index, int type, const char *label)
} }
static void static void
write_event_type(FILE *f, struct event_type *ev) write_event_type(FILE *f, const struct event_type *ev)
{ {
int i; int i, type;
write_event_type_header(f, ev->index, ev->type, ev->label); type = chan_to_prvtype[ev->chan_id][ev->chan_type];
write_event_type_header(f, ev->index, type, ev->label);
fprintf(f, "VALUES\n"); fprintf(f, "VALUES\n");
@ -448,11 +442,13 @@ write_event_type(FILE *f, struct event_type *ev)
} }
static void static void
write_cpu_type(FILE *f, struct event_type *ev, struct ovni_emu *emu) write_cpu_type(FILE *f, const struct event_type *ev, struct ovni_emu *emu)
{ {
size_t i; size_t i;
int type;
write_event_type_header(f, ev->index, ev->type, ev->label); type = chan_to_prvtype[ev->chan_id][ev->chan_type];
write_event_type_header(f, ev->index, type, ev->label);
fprintf(f, "VALUES\n"); fprintf(f, "VALUES\n");