sim: replace custom attributes with ansidecl.h

Message ID 20210502043053.834-1-vapier@gentoo.org
State New
Headers show
Series
  • sim: replace custom attributes with ansidecl.h
Related show

Commit Message

Weimin Pan via Gdb-patches May 2, 2021, 4:30 a.m.
A lot of this code predates the common attributes.  We had already
started migrating over piece by piece, so just do a pass across all
the attributes and replace most of them.
---
 sim/bfin/bfin-sim.c      |  9 +++++----
 sim/common/callback.c    |  5 +----
 sim/common/hw-device.h   |  8 ++++----
 sim/common/hw-events.h   |  2 +-
 sim/common/hw-tree.h     |  2 +-
 sim/common/sim-basics.h  |  9 ---------
 sim/common/sim-engine.h  |  6 +++---
 sim/common/sim-hw.h      |  4 ++--
 sim/common/sim-inline.h  | 16 +---------------
 sim/common/sim-io.h      |  8 ++++----
 sim/common/sim-profile.c |  2 +-
 sim/common/sim-trace.h   | 10 ++++------
 sim/igen/lf.h            |  4 ++--
 sim/m32c/m32c.opc        |  3 +--
 sim/m32c/opc2c.c         |  7 ++++---
 sim/m32c/r8c.opc         |  3 +--
 16 files changed, 35 insertions(+), 63 deletions(-)

-- 
2.31.1

Comments

Weimin Pan via Gdb-patches May 2, 2021, 1:32 p.m. | #1
On 2021-05-02 12:30 a.m., Mike Frysinger via Gdb-patches wrote:
> A lot of this code predates the common attributes.  We had already

> started migrating over piece by piece, so just do a pass across all

> the attributes and replace most of them.


Given that I added uses of ATTRIBUTE_PRINTF in a preceding patch, +1
from me.

Simon

Patch

diff --git a/sim/bfin/bfin-sim.c b/sim/bfin/bfin-sim.c
index 674ae87d5e76..33bbc6e4963f 100644
--- a/sim/bfin/bfin-sim.c
+++ b/sim/bfin/bfin-sim.c
@@ -25,6 +25,7 @@ 
 #include <string.h>
 #include <inttypes.h>
 
+#include "ansidecl.h"
 #include "opcode/bfin.h"
 #include "sim-main.h"
 #include "dv-bfin_cec.h"
@@ -35,7 +36,7 @@ 
 #define SIGNEXTEND(v, n) \
   (((bs32)(v) << (HOST_LONG_WORD_SIZE - (n))) >> (HOST_LONG_WORD_SIZE - (n)))
 
-static __attribute__ ((noreturn)) void
+static ATTRIBUTE_NORETURN void
 illegal_instruction (SIM_CPU *cpu)
 {
   TRACE_INSN (cpu, "ILLEGAL INSTRUCTION");
@@ -43,7 +44,7 @@  illegal_instruction (SIM_CPU *cpu)
     cec_exception (cpu, VEC_UNDEF_I);
 }
 
-static __attribute__ ((noreturn)) void
+static ATTRIBUTE_NORETURN void
 illegal_instruction_combination (SIM_CPU *cpu)
 {
   TRACE_INSN (cpu, "ILLEGAL INSTRUCTION COMBINATION");
@@ -51,7 +52,7 @@  illegal_instruction_combination (SIM_CPU *cpu)
     cec_exception (cpu, VEC_ILGAL_I);
 }
 
-static __attribute__ ((noreturn)) void
+static ATTRIBUTE_NORETURN void
 illegal_instruction_or_combination (SIM_CPU *cpu)
 {
   if (PARALLEL_GROUP != BFIN_PARALLEL_NONE)
@@ -60,7 +61,7 @@  illegal_instruction_or_combination (SIM_CPU *cpu)
     illegal_instruction (cpu);
 }
 
-static __attribute__ ((noreturn)) void
+static ATTRIBUTE_NORETURN void
 unhandled_instruction (SIM_CPU *cpu, const char *insn)
 {
   SIM_DESC sd = CPU_STATE (cpu);
diff --git a/sim/common/callback.c b/sim/common/callback.c
index aae0630d645c..55280abb04b9 100644
--- a/sim/common/callback.c
+++ b/sim/common/callback.c
@@ -698,10 +698,7 @@  os_evprintf_filtered (host_callback *p ATTRIBUTE_UNUSED, const char *format, va_
 }
 
 /* VARARGS */
-#ifdef __GNUC__
-__attribute__ ((__noreturn__))
-#endif
-static void ATTRIBUTE_PRINTF (2, 3)
+static void ATTRIBUTE_PRINTF (2, 3) ATTRIBUTE_NORETURN
 os_error (host_callback *p ATTRIBUTE_UNUSED, const char *format, ...)
 {
   va_list args;
diff --git a/sim/common/hw-device.h b/sim/common/hw-device.h
index a745cb78c748..ffd627a441f0 100644
--- a/sim/common/hw-device.h
+++ b/sim/common/hw-device.h
@@ -432,17 +432,17 @@  int hw_ioctl
 void hw_abort
 (struct hw *me,
  const char *fmt,
- ...) __attribute__ ((format (printf, 2, 3), noreturn));
+ ...) ATTRIBUTE_PRINTF (2, 3) ATTRIBUTE_NORETURN;
 
 void hw_vabort
 (struct hw *me,
  const char *fmt,
- va_list ap) __attribute__ ((noreturn));
+ va_list ap) ATTRIBUTE_NORETURN;
 
 void hw_halt
 (struct hw *me,
  int reason,
- int status) __attribute__ ((noreturn));
+ int status) ATTRIBUTE_NORETURN;
 
 
 #define hw_trace_p(hw) ((hw)->trace_of_hw_p + 0)
@@ -450,7 +450,7 @@  void hw_halt
 void hw_trace
 (struct hw *me,
  const char *fmt,
- ...) __attribute__ ((format (printf, 2, 3)));
+ ...) ATTRIBUTE_PRINTF (2, 3);
 
 #define HW_TRACE(ARGS) \
 do { \
diff --git a/sim/common/hw-events.h b/sim/common/hw-events.h
index 9307f8d131b0..901063b73da2 100644
--- a/sim/common/hw-events.h
+++ b/sim/common/hw-events.h
@@ -39,7 +39,7 @@  struct hw_event *hw_event_queue_schedule_tracef
  hw_event_callback *handler,
  void *data,
  const char *fmt,
- ...) __attribute__ ((format (printf, 5, 6)));
+ ...) ATTRIBUTE_PRINTF (5, 6);
 
 struct hw_event *hw_event_queue_schedule_vtracef
 (struct hw *me,
diff --git a/sim/common/hw-tree.h b/sim/common/hw-tree.h
index 55975df9e9c1..86ebf1709cad 100644
--- a/sim/common/hw-tree.h
+++ b/sim/common/hw-tree.h
@@ -34,7 +34,7 @@  void hw_tree_delete
 struct hw *hw_tree_parse
 (struct hw *root,
  const char *fmt,
- ...) __attribute__ ((format (printf, 2, 3)));
+ ...) ATTRIBUTE_PRINTF (2, 3);
 
 struct hw *hw_tree_vparse
 (struct hw *root,
diff --git a/sim/common/sim-basics.h b/sim/common/sim-basics.h
index 52c9b2fa40c3..e822fb2eb818 100644
--- a/sim/common/sim-basics.h
+++ b/sim/common/sim-basics.h
@@ -51,15 +51,6 @@ 
 #endif
 
 
-/* Some versions of GCC include an attribute operator, define it */
-
-#if !defined (__attribute__)
-#if (!defined(__GNUC__) || (__GNUC__ < 2) || (__GNUC__ == 2 && __GNUC_MINOR__ < 6))
-#define __attribute__(arg)
-#endif
-#endif
-
-
 /* Global types that code manipulates */
 
 struct hw;
diff --git a/sim/common/sim-engine.h b/sim/common/sim-engine.h
index 5adce8deedbc..3ebf8acbaccc 100644
--- a/sim/common/sim-engine.h
+++ b/sim/common/sim-engine.h
@@ -62,7 +62,7 @@  extern void sim_engine_halt
  sim_cpu *next_cpu, /* NULL -> succ (last_cpu) or event-mgr */
  sim_cia cia,
  enum sim_stop reason,
- int sigrc) __attribute__ ((noreturn));
+ int sigrc) ATTRIBUTE_NORETURN;
 
 /* Halt hook - allow target specific operation when halting a
    simulator */
@@ -115,14 +115,14 @@  extern void sim_engine_abort
  sim_cpu *cpu,
  sim_cia cia,
  const char *fmt,
- ...) ATTRIBUTE_PRINTF (4, 5) __attribute__ ((noreturn));
+ ...) ATTRIBUTE_PRINTF (4, 5) ATTRIBUTE_NORETURN;
 
 extern void sim_engine_vabort
 (SIM_DESC sd,
  sim_cpu *cpu,
  sim_cia cia,
  const char *fmt,
- va_list ap) ATTRIBUTE_PRINTF (4, 0) __attribute__ ((noreturn));
+ va_list ap) ATTRIBUTE_PRINTF (4, 0) ATTRIBUTE_NORETURN;
 
 /* No abort hook - when possible this function exits using the
    engine_halt function (and SIM_ENGINE_HALT_HOOK). */
diff --git a/sim/common/sim-hw.h b/sim/common/sim-hw.h
index 95b98560fccd..976a22007169 100644
--- a/sim/common/sim-hw.h
+++ b/sim/common/sim-hw.h
@@ -32,7 +32,7 @@  SIM_RC sim_hw_install
 struct hw *sim_hw_parse
 (struct sim_state *sd,
  const char *fmt,
- ...) __attribute__ ((format (printf, 2, 3)));
+ ...) ATTRIBUTE_PRINTF (2, 3);
 
 
 /* Print the hardware tree */
@@ -48,7 +48,7 @@  void sim_hw_abort
 (SIM_DESC sd,
  struct hw *hw,
  const char *fmt,
- ...) __attribute__ ((format (printf, 3, 4), noreturn));
+ ...) ATTRIBUTE_PRINTF (3, 4) ATTRIBUTE_NORETURN;
 
 
 
diff --git a/sim/common/sim-inline.h b/sim/common/sim-inline.h
index ed7baa4b7106..2750fa93cbc7 100644
--- a/sim/common/sim-inline.h
+++ b/sim/common/sim-inline.h
@@ -325,24 +325,10 @@ 
 #endif
 
 
-/* Your compiler's no-return reserved word */
-
-#ifndef NORETURN
-#define NORETURN
-#endif
-
-
-
 /* Your compilers's unused reserved word */
 
 #if !defined (UNUSED)
-#if (!defined (__GNUC__) \
-     || (__GNUC__ < 2) \
-     || (__GNUC__ == 2 && __GNUC_MINOR__ < 7))
-#define UNUSED
-#else
-#define UNUSED __attribute__((__unused__))
-#endif
+#define UNUSED ATTRIBUTE_UNUSED
 #endif
 
 
diff --git a/sim/common/sim-io.h b/sim/common/sim-io.h
index 33dfa78ef098..f018538ce469 100644
--- a/sim/common/sim-io.h
+++ b/sim/common/sim-io.h
@@ -63,21 +63,21 @@  int sim_io_close (SIM_DESC sd, int);
 
 void sim_io_printf (SIM_DESC sd,
 		    const char *fmt,
-		    ...) __attribute__ ((format (printf, 2, 3)));
+		    ...) ATTRIBUTE_PRINTF (2, 3);
 
 void sim_io_vprintf (SIM_DESC sd, const char *fmt, va_list ap);
 
 void sim_io_eprintf (SIM_DESC sd,
 		     const char *fmt,
-		     ...) __attribute__ ((format (printf, 2, 3)));
+		     ...) ATTRIBUTE_PRINTF (2, 3);
 
 void sim_io_evprintf (SIM_DESC sd, const char *fmt, va_list ap);
 
 void sim_io_error (SIM_DESC sd,
 		   const char *fmt,
 		   ...)
-  __attribute__ ((format (printf, 2, 3)))
-  __attribute__ ((__noreturn__));
+  ATTRIBUTE_PRINTF (2, 3)
+  ATTRIBUTE_NORETURN;
 
 void sim_io_poll_quit (SIM_DESC sd);
 
diff --git a/sim/common/sim-profile.c b/sim/common/sim-profile.c
index 5508f0f516d6..75bdc70298cc 100644
--- a/sim/common/sim-profile.c
+++ b/sim/common/sim-profile.c
@@ -466,7 +466,7 @@  profile_vprintf (SIM_DESC sd, sim_cpu *cpu, const char *fmt, va_list ap)
     sim_io_evprintf (sd, fmt, ap);
 }
 
-__attribute__ ((format (printf, 3, 4)))
+ATTRIBUTE_PRINTF (3, 4)
 static void
 profile_printf (SIM_DESC sd, sim_cpu *cpu, const char *fmt, ...)
 {
diff --git a/sim/common/sim-trace.h b/sim/common/sim-trace.h
index e96e68479565..7ff7b021b337 100644
--- a/sim/common/sim-trace.h
+++ b/sim/common/sim-trace.h
@@ -333,8 +333,7 @@  extern void trace_prefix (SIM_DESC sd,
 			  const char *file_name,
 			  int line_nr,
 			  const char *fmt,
-			  ...)
-       __attribute__((format (printf, 8, 9)));
+			  ...) ATTRIBUTE_PRINTF (8, 9);
 
 /* Generic trace print, assumes trace_prefix() has been called */
 
@@ -342,8 +341,7 @@  extern void trace_generic (SIM_DESC sd,
 			   sim_cpu *cpu,
 			   int trace_idx,
 			   const char *fmt,
-			   ...)
-     __attribute__((format (printf, 4, 5)));
+			   ...) ATTRIBUTE_PRINTF (4, 5);
 
 /* Disassemble the specified address.  */
 
@@ -655,7 +653,7 @@  do { \
 
 
 extern void trace_printf (SIM_DESC, sim_cpu *, const char *, ...)
-     __attribute__((format (printf, 3, 4)));
+     ATTRIBUTE_PRINTF (3, 4);
 
 extern void trace_vprintf (SIM_DESC, sim_cpu *, const char *, va_list);
 
@@ -676,6 +674,6 @@  int trace_load_symbols (SIM_DESC);
 bfd_vma trace_sym_value (SIM_DESC, const char *name);
 
 extern void sim_debug_printf (sim_cpu *, const char *, ...)
-     __attribute__((format (printf, 2, 3)));
+    ATTRIBUTE_PRINTF (2, 3);
 
 #endif /* SIM_TRACE_H */
diff --git a/sim/igen/lf.h b/sim/igen/lf.h
index c6185dbab861..5a6d5a7b8f2f 100644
--- a/sim/igen/lf.h
+++ b/sim/igen/lf.h
@@ -19,7 +19,7 @@ 
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-
+#include "ansidecl.h"
 
 /* LF: Line Numbered Output Stream */
 
@@ -72,7 +72,7 @@  extern int lf_putint (lf *file, int decimal);
 extern int lf_putbin (lf *file, int decimal, int width);
 
 extern int lf_printf
-  (lf *file, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
+  (lf *file, const char *fmt, ...) ATTRIBUTE_PRINTF (2, 3);
 
 
 /* Indentation control.
diff --git a/sim/m32c/m32c.opc b/sim/m32c/m32c.opc
index feee1e933971..efe049568bdd 100644
--- a/sim/m32c/m32c.opc
+++ b/sim/m32c/m32c.opc
@@ -22,13 +22,12 @@  along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "ansidecl.h"
 #include "cpu.h"
 #include "mem.h"
 #include "misc.h"
 #include "int.h"
 
-#define AU  __attribute__((unused))
-
 #define tprintf if (trace) printf
 
 static unsigned char
diff --git a/sim/m32c/opc2c.c b/sim/m32c/opc2c.c
index 3d8f2c1bac8f..64874279179a 100644
--- a/sim/m32c/opc2c.c
+++ b/sim/m32c/opc2c.c
@@ -249,13 +249,14 @@  dump_lines (opcode * op, int level, Indirect * ind)
 	      errors++;
 	    }
 	  else if (shift && (mask != 0xff))
-	    printf ("%*s  int %s AU = (op[%d] >> %d) & 0x%02x;\n",
+	    printf ("%*s  int %s ATTRIBUTE_UNUSED = (op[%d] >> %d) & 0x%02x;\n",
 		    level, "", name, byte, shift, mask);
 	  else if (mask != 0xff)
-	    printf ("%*s  int %s AU = op[%d] & 0x%02x;\n",
+	    printf ("%*s  int %s ATTRIBUTE_UNUSED = op[%d] & 0x%02x;\n",
 		    level, "", name, byte, mask);
 	  else
-	    printf ("%*s  int %s AU = op[%d];\n", level, "", name, byte);
+	    printf ("%*s  int %s ATTRIBUTE_UNUSED = op[%d];\n", level, "", name,
+		    byte);
 	}
       else
 	i++;
diff --git a/sim/m32c/r8c.opc b/sim/m32c/r8c.opc
index aba2679c19ed..dc447b5b391a 100644
--- a/sim/m32c/r8c.opc
+++ b/sim/m32c/r8c.opc
@@ -22,13 +22,12 @@  along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "ansidecl.h"
 #include "cpu.h"
 #include "mem.h"
 #include "misc.h"
 #include "int.h"
 
-#define AU  __attribute__((unused))
-
 #define tprintf if (trace) printf
 
 static unsigned char