This code fails to compile when SMP is enabled due to some obvious
errors. Fix those and change the logic to avoid CPP to prevent any
future rot from creeping back in.
const char *
sim_cpu_msg_prefix (sim_cpu *cpu)
{
-#if MAX_NR_PROCESSORS == 1
- return "";
-#else
static char *prefix;
+ if (MAX_NR_PROCESSORS == 1)
+ return "";
+
if (prefix == NULL)
{
+ SIM_DESC sd = CPU_STATE (cpu);
int maxlen = 0;
+ int i;
+
for (i = 0; i < MAX_NR_PROCESSORS; ++i)
{
int len = strlen (CPU_NAME (STATE_CPU (sd, i)));
prefix = (char *) xmalloc (maxlen + 5);
}
sprintf (prefix, "%s: ", CPU_NAME (cpu));
+
return prefix;
-#endif
}
/* Cover fn to sim_io_eprintf. */