public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] sim: cpu: fix SMP msg prefix helper
@ 2022-12-25  7:14 Michael Frysinger
  0 siblings, 0 replies; only message in thread
From: Michael Frysinger @ 2022-12-25  7:14 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=fb749760444f6570fa03bc91aa36024b7e4b4e55

commit fb749760444f6570fa03bc91aa36024b7e4b4e55
Author: Mike Frysinger <vapier@gentoo.org>
Date:   Sat Dec 24 23:43:18 2022 -0500

    sim: cpu: fix SMP msg prefix helper
    
    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.

Diff:
---
 sim/common/sim-utils.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/sim/common/sim-utils.c b/sim/common/sim-utils.c
index 259b14cce29..d4a624c3b6f 100644
--- a/sim/common/sim-utils.c
+++ b/sim/common/sim-utils.c
@@ -123,14 +123,17 @@ sim_cpu_lookup (SIM_DESC sd, const char *cpu_name)
 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)));
@@ -140,8 +143,8 @@ sim_cpu_msg_prefix (sim_cpu *cpu)
       prefix = (char *) xmalloc (maxlen + 5);
     }
   sprintf (prefix, "%s: ", CPU_NAME (cpu));
+
   return prefix;
-#endif
 }
 
 /* Cover fn to sim_io_eprintf.  */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-12-25  7:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-25  7:14 [binutils-gdb] sim: cpu: fix SMP msg prefix helper Michael Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).