public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix some sim warnings
@ 2021-04-08 16:44 Tom Tromey
  2021-04-08 16:44 ` [PATCH 1/2] Do not use old-style definitions in sim Tom Tromey
  2021-04-08 16:44 ` [PATCH 2/2] Add system includes " Tom Tromey
  0 siblings, 2 replies; 12+ messages in thread
From: Tom Tromey @ 2021-04-08 16:44 UTC (permalink / raw)
  To: gdb-patches

I noticed some sim warnings while building and wrote some patches to
fix some of them.  There are still plenty of warnings left to fix
though.

Tested by rebuilding.  Let me know what you think.

Tom



^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/2] Do not use old-style definitions in sim
  2021-04-08 16:44 [PATCH 0/2] Fix some sim warnings Tom Tromey
@ 2021-04-08 16:44 ` Tom Tromey
  2021-04-08 17:44   ` Mike Frysinger
  2021-04-08 16:44 ` [PATCH 2/2] Add system includes " Tom Tromey
  1 sibling, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2021-04-08 16:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes all the non-generated (hand-written) code in sim to use
"new" (post-K&R) style function definitions.

sim/bpf/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* bpf.c (bpf_def_model_init): Use new-style declaration.

sim/common/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* cgen-utils.c (RORQI, ROLQI, RORHI, ROLHI, RORSI, ROLSI): Use
	new-style declaration.

sim/erc32/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* sis.c (run_sim, main): Use new-style declaration.
	* interf.c (run_sim, sim_open, sim_close, sim_load)
	(sim_create_inferior, sim_store_register, sim_fetch_register)
	(sim_info, sim_stop_reason, flush_windows, sim_do_command): Use
	new-style declaration.
	* help.c (usage, gen_help): Use new-style declaration.
	* func.c (batch, set_regi, set_rega, disp_reg, limcalc)
	(reset_stat, show_stat, init_bpt, int_handler, init_signals)
	(disp_fpu, disp_regs, disp_ctrl, disp_mem, dis_mem, event)
	(init_event, set_int, advance_time, now, wait_for_irq, check_bpt)
	(reset_all, sys_reset, sys_halt): Use new-style declaration.
	* float.c (get_accex, clear_accex, set_fsr): Use new-style
	declaration.
	* exec.c (sub_cc, add_cc, log_cc, dispatch_instruction, fpexec)
	(chk_asi, execute_trap, check_interrupts, init_regs): Use
	new-style declaration.
	* erc32.c (init_sim, reset, decode_ersr, mecparerror)
	(error_mode, decode_memcfg, decode_wcr, decode_mcr, sim_halt)
	(close_port, exit_sim, mec_reset, mec_intack, chk_irq, mec_irq)
	(set_sfsr, mec_read, mec_write, init_stdio, restore_stdio)
	(port_init, read_uart, write_uart, flush_uart, uarta_tx)
	(uartb_tx, uart_rx, uart_intr, uart_irq_start, wdog_intr)
	(wdog_start, rtc_intr, rtc_start, rtc_counter_read)
	(rtc_scaler_set, rtc_reload_set, gpt_intr, gpt_start)
	(gpt_counter_read, gpt_scaler_set, gpt_reload_set, timer_ctrl)
	(memory_read, memory_write, get_mem_ptr, sis_memory_write)
	(sis_memory_read): Use new-style declaration.

sim/frv/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* sim-if.c (sim_open, frv_sim_close, sim_create_inferior): Use
	new-style declaration.

sim/h8300/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* compile.c (cmdline_location): Use new-style declaration.

sim/iq2000/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* sim-if.c (sim_open, sim_create_inferior): Use new-style
	declaration.
	* iq2000.c (fetch_str): Use new-style declaration.

sim/lm32/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* sim-if.c (sim_open, sim_create_inferior): Use new-style
	declaration.

sim/m32r/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* sim-if.c (sim_open, sim_create_inferior): Use new-style
	declaration.
---
 sim/bpf/ChangeLog       |   4 ++
 sim/bpf/bpf.c           |   2 +-
 sim/common/ChangeLog    |   5 ++
 sim/common/cgen-utils.c |  24 ++-----
 sim/erc32/ChangeLog     |  30 +++++++++
 sim/erc32/erc32.c       | 137 ++++++++++++++--------------------------
 sim/erc32/exec.c        |  37 +++--------
 sim/erc32/float.c       |   7 +-
 sim/erc32/func.c        |  82 ++++++++----------------
 sim/erc32/help.c        |   4 +-
 sim/erc32/interf.c      |  56 ++++------------
 sim/erc32/sis.c         |   9 +--
 sim/frv/ChangeLog       |   5 ++
 sim/frv/sim-if.c        |  18 ++----
 sim/h8300/ChangeLog     |   4 ++
 sim/h8300/compile.c     |   2 +-
 sim/iq2000/ChangeLog    |   6 ++
 sim/iq2000/iq2000.c     |   5 +-
 sim/iq2000/sim-if.c     |  14 ++--
 sim/lm32/ChangeLog      |   5 ++
 sim/lm32/sim-if.c       |  14 ++--
 sim/m32r/ChangeLog      |   5 ++
 sim/m32r/sim-if.c       |  14 ++--
 23 files changed, 191 insertions(+), 298 deletions(-)

diff --git a/sim/bpf/bpf.c b/sim/bpf/bpf.c
index 840fb862e7f..a0cc803da82 100644
--- a/sim/bpf/bpf.c
+++ b/sim/bpf/bpf.c
@@ -205,7 +205,7 @@ bpfbf_breakpoint (SIM_CPU *current_cpu)
    several ISAs.  This should be fixed in CGEN.  */
 
 static void
-bpf_def_model_init ()
+bpf_def_model_init (void)
 {
   /* Do nothing.  */
 }
diff --git a/sim/common/cgen-utils.c b/sim/common/cgen-utils.c
index 8e87ceb3485..3d7c2821eaa 100644
--- a/sim/common/cgen-utils.c
+++ b/sim/common/cgen-utils.c
@@ -319,9 +319,7 @@ CONVDISI (val)
 #endif /* DI_FN_SUPPORT */
 \f
 QI
-RORQI (val, shift)
-     QI  val;
-     int shift;
+RORQI (QI val, int shift)
 {
   if (shift != 0)
     {
@@ -336,9 +334,7 @@ RORQI (val, shift)
 }
 
 QI
-ROLQI (val, shift)
-     QI  val;
-     int shift;
+ROLQI (QI val, int shift)
 {
   if (shift != 0)
     {
@@ -353,9 +349,7 @@ ROLQI (val, shift)
 }
 
 HI
-RORHI (val, shift)
-     HI  val;
-     int shift;
+RORHI (HI val, int shift)
 {
   if (shift != 0)
     {
@@ -370,9 +364,7 @@ RORHI (val, shift)
 }
 
 HI
-ROLHI (val, shift)
-     HI  val;
-     int shift;
+ROLHI (HI val, int shift)
 {
   if (shift != 0)
     {
@@ -387,9 +379,7 @@ ROLHI (val, shift)
 }
 
 SI
-RORSI (val, shift)
-     SI  val;
-     int shift;
+RORSI (SI val, int shift)
 {
   if (shift != 0)
     {
@@ -404,9 +394,7 @@ RORSI (val, shift)
 }
 
 SI
-ROLSI (val, shift)
-     SI  val;
-     int shift;
+ROLSI (SI val, int shift)
 {
   if (shift != 0)
     {
diff --git a/sim/erc32/erc32.c b/sim/erc32/erc32.c
index 893e898c4f4..a93b62b798c 100644
--- a/sim/erc32/erc32.c
+++ b/sim/erc32/erc32.c
@@ -297,7 +297,7 @@ extern int	ext_irl;
 /* One-time init */
 
 void
-init_sim()
+init_sim(void)
 {
     port_init();
 }
@@ -305,7 +305,7 @@ init_sim()
 /* Power-on reset init */
 
 void
-reset()
+reset(void)
 {
     mec_reset();
     uart_irq_start();
@@ -313,7 +313,7 @@ reset()
 }
 
 static void
-decode_ersr()
+decode_ersr(void)
 {
     if (mec_ersr & 0x01) {
 	if (!(mec_mcr & 0x20)) {
@@ -375,7 +375,7 @@ iucomperr()
 #endif
 
 static void
-mecparerror()
+mecparerror(void)
 {
     mec_ersr |= 0x20;
     decode_ersr();
@@ -385,8 +385,7 @@ mecparerror()
 /* IU error mode manager */
 
 void
-error_mode(pc)
-    uint32          pc;
+error_mode(uint32 pc)
 {
 
     mec_ersr |= 0x1;
@@ -397,7 +396,7 @@ error_mode(pc)
 /* Check memory settings */
 
 static void
-decode_memcfg()
+decode_memcfg(void)
 {
     if (rom8) mec_memcfg &= ~0x20000;
     else mec_memcfg |= 0x20000;
@@ -421,7 +420,7 @@ decode_memcfg()
 }
 
 static void
-decode_wcr()
+decode_wcr(void)
 {
     mem_ramr_ws = mec_wcr & 3;
     mem_ramw_ws = (mec_wcr >> 2) & 3;
@@ -437,7 +436,7 @@ decode_wcr()
 }
 
 static void
-decode_mcr()
+decode_mcr(void)
 {
     mem_accprot = (mec_wpr[0] | mec_wpr[1]);
     mem_blockprot = (mec_mcr >> 3) & 1;
@@ -456,7 +455,7 @@ decode_mcr()
 /* Flush ports when simulator stops */
 
 void
-sim_halt()
+sim_halt(void)
 {
 #ifdef FAST_UART
     flush_uart();
@@ -471,7 +470,7 @@ sim_stop(SIM_DESC sd)
 }
 
 static void
-close_port()
+close_port(void)
 {
     if (f1open && f1in != stdin)
 	fclose(f1in);
@@ -480,13 +479,13 @@ close_port()
 }
 
 void
-exit_sim()
+exit_sim(void)
 {
     close_port();
 }
 
 static void
-mec_reset()
+mec_reset(void)
 {
     int             i;
 
@@ -547,8 +546,7 @@ mec_reset()
 
 
 static void
-mec_intack(level)
-    int32           level;
+mec_intack(int32 level)
 {
     int             irq_test;
 
@@ -563,7 +561,7 @@ mec_intack(level)
 }
 
 static void
-chk_irq()
+chk_irq(void)
 {
     int32           i;
     uint32          itmp;
@@ -588,19 +586,14 @@ chk_irq()
 }
 
 static void
-mec_irq(level)
-    int32           level;
+mec_irq(int32 level)
 {
     mec_ipr |= (1 << level);
     chk_irq();
 }
 
 static void
-set_sfsr(fault, addr, asi, read)
-    uint32          fault;
-    uint32          addr;
-    uint32          asi;
-    uint32          read;
+set_sfsr(uint32 fault, uint32 addr, uint32 asi, uint32 read)
 {
     if ((asi == 0xa) || (asi == 0xb)) {
 	mec_ffar = addr;
@@ -618,10 +611,7 @@ set_sfsr(fault, addr, asi, read)
 }
 
 static int32
-mec_read(addr, asi, data)
-    uint32          addr;
-    uint32          asi;
-    uint32         *data;
+mec_read(uint32 addr, uint32 asi, uint32 *data)
 {
 
     switch (addr & 0x0ff) {
@@ -748,9 +738,7 @@ mec_read(addr, asi, data)
 }
 
 static int
-mec_write(addr, data)
-    uint32          addr;
-    uint32          data;
+mec_write(uint32 addr, uint32 data)
 {
     if (sis_verbose > 1)
 	printf("MEC write a: %08x, d: %08x\n",addr,data);
@@ -932,7 +920,7 @@ mec_write(addr, data)
 static int      ifd1 = -1, ifd2 = -1, ofd1 = -1, ofd2 = -1;
 
 void
-init_stdio()
+init_stdio(void)
 {
     if (dumbio)
         return; /* do nothing */
@@ -943,7 +931,7 @@ init_stdio()
 }
 
 void
-restore_stdio()
+restore_stdio(void)
 {
     if (dumbio)
         return; /* do nothing */
@@ -960,7 +948,7 @@ restore_stdio()
 
 
 static void
-port_init()
+port_init(void)
 {
 
     if (uben) {
@@ -1037,8 +1025,7 @@ port_init()
 }
 
 static uint32
-read_uart(addr)
-    uint32          addr;
+read_uart(uint32 addr)
 {
 
     unsigned        tmp;
@@ -1159,9 +1146,7 @@ read_uart(addr)
 }
 
 static void
-write_uart(addr, data)
-    uint32          addr;
-    uint32          data;
+write_uart(uint32 addr, uint32 data)
 {
     unsigned char   c;
 
@@ -1235,7 +1220,7 @@ write_uart(addr, data)
 }
 
 static void
-flush_uart()
+flush_uart(void)
 {
     while (wnuma && f1open)
 	wnuma -= fwrite(wbufa, 1, wnuma, f1out);
@@ -1246,7 +1231,7 @@ flush_uart()
 
 
 static void
-uarta_tx()
+uarta_tx(void)
 {
 
     while (f1open && fwrite(&uarta_sreg, 1, 1, f1out) != 1);
@@ -1261,7 +1246,7 @@ uarta_tx()
 }
 
 static void
-uartb_tx()
+uartb_tx(void)
 {
     while (f2open && fwrite(&uartb_sreg, 1, 1, f2out) != 1);
     if (uart_stat_reg & UARTB_HRE) {
@@ -1275,8 +1260,7 @@ uartb_tx()
 }
 
 static void
-uart_rx(arg)
-    caddr_t         arg;
+uart_rx(caddr_t arg)
 {
     int32           rsize;
     char            rxd;
@@ -1318,8 +1302,7 @@ uart_rx(arg)
 }
 
 static void
-uart_intr(arg)
-    caddr_t         arg;
+uart_intr(caddr_t arg)
 {
     read_uart(0xE8);		/* Check for UART interrupts every 1000 clk */
     flush_uart();		/* Flush UART ports      */
@@ -1328,7 +1311,7 @@ uart_intr(arg)
 
 
 static void
-uart_irq_start()
+uart_irq_start(void)
 {
 #ifdef FAST_UART
     event(uart_intr, 0, UART_FLUSH_TIME);
@@ -1342,8 +1325,7 @@ uart_irq_start()
 /* Watch-dog */
 
 static void
-wdog_intr(arg)
-    caddr_t         arg;
+wdog_intr(caddr_t arg)
 {
     if (wdog_status == disabled) {
 	wdog_status = stopped;
@@ -1368,7 +1350,7 @@ wdog_intr(arg)
 }
 
 static void
-wdog_start()
+wdog_start(void)
 {
     event(wdog_intr, 0, wdog_scaler + 1);
     if (sis_verbose)
@@ -1381,8 +1363,7 @@ wdog_start()
 
 
 static void
-rtc_intr(arg)
-    caddr_t         arg;
+rtc_intr(caddr_t arg)
 {
     if (rtc_counter == 0) {
 
@@ -1405,7 +1386,7 @@ rtc_intr(arg)
 }
 
 static void
-rtc_start()
+rtc_start(void)
 {
     if (sis_verbose)
 	printf("RTC started (period %d)\n\r", rtc_scaler + 1);
@@ -1415,28 +1396,25 @@ rtc_start()
 }
 
 static uint32
-rtc_counter_read()
+rtc_counter_read(void)
 {
     return rtc_counter;
 }
 
 static void
-rtc_scaler_set(val)
-    uint32          val;
+rtc_scaler_set(uint32 val)
 {
     rtc_scaler = val & 0x0ff;	/* eight-bit scaler only */
 }
 
 static void
-rtc_reload_set(val)
-    uint32          val;
+rtc_reload_set(uint32 val)
 {
     rtc_reload = val;
 }
 
 static void
-gpt_intr(arg)
-    caddr_t         arg;
+gpt_intr(caddr_t arg)
 {
     if (gpt_counter == 0) {
 	mec_irq(12);
@@ -1458,7 +1436,7 @@ gpt_intr(arg)
 }
 
 static void
-gpt_start()
+gpt_start(void)
 {
     if (sis_verbose)
 	printf("GPT started (period %d)\n\r", gpt_scaler + 1);
@@ -1468,28 +1446,25 @@ gpt_start()
 }
 
 static uint32
-gpt_counter_read()
+gpt_counter_read(void)
 {
     return gpt_counter;
 }
 
 static void
-gpt_scaler_set(val)
-    uint32          val;
+gpt_scaler_set(uint32 val)
 {
     gpt_scaler = val & 0x0ffff;	/* 16-bit scaler */
 }
 
 static void
-gpt_reload_set(val)
-    uint32          val;
+gpt_reload_set(uint32 val)
 {
     gpt_reload = val;
 }
 
 static void
-timer_ctrl(val)
-    uint32          val;
+timer_ctrl(uint32 val)
 {
 
     rtc_cr = ((val & TCR_TCRCR) != 0);
@@ -1577,12 +1552,7 @@ memory_iread (uint32 addr, uint32 *data, int32 *ws)
 }
 
 int
-memory_read(asi, addr, data, sz, ws)
-    int32           asi;
-    uint32          addr;
-    uint32         *data;
-    int32           sz;
-    int32          *ws;
+memory_read(int32 asi, uint32 addr, uint32 *data, int32 sz, int32 *ws)
 {
     int32           mexc;
 
@@ -1648,12 +1618,7 @@ memory_read(asi, addr, data, sz, ws)
 }
 
 int
-memory_write(asi, addr, data, sz, ws)
-    int32           asi;
-    uint32          addr;
-    uint32         *data;
-    int32           sz;
-    int32          *ws;
+memory_write(int32 asi, uint32 addr, uint32 *data, int32 sz, int32 *ws)
 {
     uint32          byte_addr;
     uint32          byte_mask;
@@ -1761,9 +1726,7 @@ memory_write(asi, addr, data, sz, ws)
 }
 
 static unsigned char  *
-get_mem_ptr(addr, size)
-    uint32          addr;
-    uint32          size;
+get_mem_ptr(uint32 addr, uint32 size)
 {
     if ((addr + size) < ROM_SZ) {
 	return &romb[addr];
@@ -1782,10 +1745,7 @@ get_mem_ptr(addr, size)
 }
 
 int
-sis_memory_write(addr, data, length)
-    uint32               addr;
-    const unsigned char *data;
-    uint32               length;
+sis_memory_write(uint32 addr, const unsigned char *data, uint32 length)
 {
     char           *mem;
 
@@ -1797,10 +1757,7 @@ sis_memory_write(addr, data, length)
 }
 
 int
-sis_memory_read(addr, data, length)
-    uint32          addr;
-    char           *data;
-    uint32          length;
+sis_memory_read(uint32 addr, char *data, uint32 length)
 {
     char           *mem;
 
diff --git a/sim/erc32/exec.c b/sim/erc32/exec.c
index baf52f7fd78..8daf759514e 100644
--- a/sim/erc32/exec.c
+++ b/sim/erc32/exec.c
@@ -234,11 +234,7 @@ extern uint32 errtt, errftt;
 #endif
 
 static uint32
-sub_cc(psr, operand1, operand2, result)
-    uint32          psr;
-    int32           operand1;
-    int32           operand2;
-    int32           result;
+sub_cc(uint32 psr, int32 operand1, int32 operand2, int32 result)
 {
     psr = ((psr & ~PSR_N) | ((result >> 8) & PSR_N));
     if (result)
@@ -253,11 +249,7 @@ sub_cc(psr, operand1, operand2, result)
 }
 
 uint32
-add_cc(psr, operand1, operand2, result)
-    uint32          psr;
-    int32           operand1;
-    int32           operand2;
-    int32           result;
+add_cc(uint32 psr, int32 operand1, int32 operand2, int32 result)
 {
     psr = ((psr & ~PSR_N) | ((result >> 8) & PSR_N));
     if (result)
@@ -272,9 +264,7 @@ add_cc(psr, operand1, operand2, result)
 }
 
 static void
-log_cc(result, sregs)
-    int32           result;
-    struct pstate  *sregs;
+log_cc(int32 result, struct pstate *sregs)
 {
     sregs->psr &= ~(PSR_CC);	/* Zero CC bits */
     sregs->psr = (sregs->psr | ((result >> 8) & PSR_N));
@@ -398,8 +388,7 @@ extract_byte_signed (uint32 data, uint32 address)
 }
 
 int
-dispatch_instruction(sregs)
-    struct pstate  *sregs;
+dispatch_instruction(struct pstate *sregs)
 {
 
     uint32          cwp, op, op2, op3, asi, rd, cond, rs1,
@@ -1671,9 +1660,7 @@ dispatch_instruction(sregs)
 
 
 static int
-fpexec(op3, rd, rs1, rs2, sregs)
-    uint32          op3, rd, rs1, rs2;
-    struct pstate  *sregs;
+fpexec(uint32 op3, uint32 rd, uint32 rs1, uint32 rs2, struct pstate *sregs)
 {
     uint32          opf, tem, accex;
     int32           fcc;
@@ -1952,10 +1939,7 @@ fpexec(op3, rd, rs1, rs2, sregs)
 }
 
 static int
-chk_asi(sregs, asi, op3)
-    struct pstate  *sregs;
-    uint32 *asi, op3;
-
+chk_asi(struct pstate *sregs, uint32 *asi, uint32 op3)
 {
     if (!(sregs->psr & PSR_S)) {
 	sregs->trap = TRAP_PRIVI;
@@ -1969,8 +1953,7 @@ chk_asi(sregs, asi, op3)
 }
 
 int
-execute_trap(sregs)
-    struct pstate  *sregs;
+execute_trap(struct pstate *sregs)
 {
     int32           cwp;
 
@@ -2017,8 +2000,7 @@ execute_trap(sregs)
 extern struct irqcell irqarr[16];
 
 int
-check_interrupts(sregs)
-    struct pstate  *sregs;
+check_interrupts(struct pstate *sregs)
 {
 #ifdef ERRINJ
     if (errtt) {
@@ -2040,8 +2022,7 @@ check_interrupts(sregs)
 }
 
 void
-init_regs(sregs)
-    struct pstate  *sregs;
+init_regs(struct pstate *sregs)
 {
     sregs->pc = 0;
     sregs->npc = 4;
diff --git a/sim/erc32/float.c b/sim/erc32/float.c
index ff548a228b4..6d3d2bd73d2 100644
--- a/sim/erc32/float.c
+++ b/sim/erc32/float.c
@@ -32,7 +32,7 @@
 
 /* This routine should return the accrued exceptions */
 int
-get_accex()
+get_accex(void)
 {
     int fexc, accx;
 
@@ -53,15 +53,14 @@ get_accex()
 
 /* How to clear the accrued exceptions */
 void
-clear_accex()
+clear_accex(void)
 {
     feclearexcept (FE_ALL_EXCEPT);
 }
 
 /* How to map SPARC FSR onto the host */
 void
-set_fsr(fsr)
-uint32 fsr;
+set_fsr(uint32 fsr)
 {
     int fround;
 
diff --git a/sim/erc32/func.c b/sim/erc32/func.c
index 1bad6dff806..98217f062ae 100644
--- a/sim/erc32/func.c
+++ b/sim/erc32/func.c
@@ -70,9 +70,7 @@ static void	disp_ctrl (struct pstate *sregs);
 static void	disp_mem (uint32 addr, uint32 len);
 
 static int 
-batch(sregs, fname)
-    struct pstate  *sregs;
-    char           *fname;
+batch(struct pstate *sregs, char *fname)
 {
     FILE           *fp;
     char           *lbuf = NULL;
@@ -97,10 +95,7 @@ batch(sregs, fname)
 }
 
 void
-set_regi(sregs, reg, rval)
-    struct pstate  *sregs;
-    int32           reg;
-    uint32          rval;
+set_regi(struct pstate *sregs, int32 reg, uint32 rval)
 {
     uint32          cwp;
 
@@ -187,10 +182,7 @@ get_regi(struct pstate * sregs, int32 reg, char *buf)
 
 
 static void
-set_rega(sregs, reg, rval)
-    struct pstate  *sregs;
-    char           *reg;
-    uint32          rval;
+set_rega(struct pstate *sregs, char *reg, uint32 rval)
 {
     uint32          cwp;
     int32           err = 0;
@@ -294,9 +286,7 @@ set_rega(sregs, reg, rval)
 }
 
 static void
-disp_reg(sregs, reg)
-    struct pstate  *sregs;
-    char           *reg;
+disp_reg(struct pstate *sregs, char *reg)
 {
     if (strncmp(reg, "w",1) == 0)
 	disp_regs(sregs, VAL(&reg[1]));
@@ -337,8 +327,7 @@ errinjstart()
 #endif
 
 static uint32
-limcalc (freq)
-    float32		freq;
+limcalc (float32 freq)
 {
     uint32          unit, lim;
     double	    flim;
@@ -603,8 +592,7 @@ exec_cmd(struct pstate *sregs, const char *cmd)
 
 
 void
-reset_stat(sregs)
-    struct pstate  *sregs;
+reset_stat(struct pstate *sregs)
 {
     sregs->tottime = 0.0;
     sregs->pwdtime = 0;
@@ -621,8 +609,7 @@ reset_stat(sregs)
 }
 
 void
-show_stat(sregs)
-    struct pstate  *sregs;
+show_stat(struct pstate *sregs)
 {
     uint32          iinst;
     uint32          stime;
@@ -677,8 +664,7 @@ show_stat(sregs)
 
 
 void
-init_bpt(sregs)
-    struct pstate  *sregs;
+init_bpt(struct pstate *sregs)
 {
     sregs->bptnum = 0;
     sregs->histlen = 0;
@@ -688,8 +674,7 @@ init_bpt(sregs)
 }
 
 static void
-int_handler(sig)
-    int32           sig;
+int_handler(int32 sig)
 {
     if (sig != 2)
 	printf("\n\n Signal handler error  (%d)\n\n", sig);
@@ -697,7 +682,7 @@ int_handler(sig)
 }
 
 void
-init_signals()
+init_signals(void)
 {
     typedef void    (*PFI) ();
     static PFI      int_tab[2];
@@ -714,8 +699,7 @@ struct evcell   evbuf[EVENT_MAX];
 struct irqcell  irqarr[16];
 
 static int
-disp_fpu(sregs)
-    struct pstate  *sregs;
+disp_fpu(struct pstate *sregs)
 {
 
     int         i;
@@ -741,9 +725,7 @@ disp_fpu(sregs)
 }
 
 static void
-disp_regs(sregs,cwp)
-    struct pstate  *sregs;
-    int cwp;
+disp_regs(struct pstate *sregs, int cwp)
 {
 
     int           i;
@@ -770,8 +752,7 @@ static void print_insn_sparc_sis(uint32 addr, struct disassemble_info *info)
 }
 
 static void
-disp_ctrl(sregs)
-    struct pstate  *sregs;
+disp_ctrl(struct pstate *sregs)
 {
 
     uint32           i;
@@ -790,9 +771,7 @@ disp_ctrl(sregs)
 }
 
 static void
-disp_mem(addr, len)
-    uint32          addr;
-    uint32          len;
+disp_mem(uint32 addr, uint32 len)
 {
 
     uint32          i;
@@ -823,10 +802,7 @@ disp_mem(addr, len)
 }
 
 void
-dis_mem(addr, len, info)
-    uint32          addr;
-    uint32          len;
-    struct disassemble_info *info;
+dis_mem(uint32 addr, uint32 len, struct disassemble_info *info)
 {
     uint32          i;
     union {
@@ -846,10 +822,7 @@ dis_mem(addr, len, info)
 /* Add event to event queue */
 
 void
-event(cfunc, arg, delta)
-    void            (*cfunc) ();
-    int32           arg;
-    uint64          delta;
+event(void (*cfunc) (), int32 arg, uint64 delta)
 {
     struct evcell  *ev1, *evins;
 
@@ -885,7 +858,7 @@ stop_event()
 #endif
 
 void
-init_event()
+init_event(void)
 {
     int32           i;
 
@@ -898,10 +871,7 @@ init_event()
 }
 
 void
-set_int(level, callback, arg)
-    int32           level;
-    void            (*callback) ();
-    int32           arg;
+set_int(int32 level, void (*callback) (), int32 arg)
 {
     irqarr[level & 0x0f].callback = callback;
     irqarr[level & 0x0f].arg = arg;
@@ -910,8 +880,7 @@ set_int(level, callback, arg)
 /* Advance simulator time */
 
 void
-advance_time(sregs)
-    struct pstate  *sregs;
+advance_time(struct pstate *sregs)
 {
 
     struct evcell  *evrem;
@@ -942,7 +911,7 @@ advance_time(sregs)
 }
 
 uint32
-now()
+now(void)
 {
     return ebase.simtime;
 }
@@ -951,7 +920,7 @@ now()
 /* Advance time until an external interrupt is seen */
 
 int
-wait_for_irq()
+wait_for_irq(void)
 {
     struct evcell  *evrem;
     void            (*cfunc) ();
@@ -980,8 +949,7 @@ wait_for_irq()
 }
 
 int
-check_bpt(sregs)
-    struct pstate  *sregs;
+check_bpt(struct pstate *sregs)
 {
     int32           i;
 
@@ -995,7 +963,7 @@ check_bpt(sregs)
 }
 
 void
-reset_all()
+reset_all(void)
 {
     init_event();		/* Clear event queue */
     init_regs(&sregs);
@@ -1006,14 +974,14 @@ reset_all()
 }
 
 void
-sys_reset()
+sys_reset(void)
 {
     reset_all();
     sregs.trap = 256;		/* Force fake reset trap */
 }
 
 void
-sys_halt()
+sys_halt(void)
 {
     sregs.trap = 257;           /* Force fake halt trap */
 }
diff --git a/sim/erc32/help.c b/sim/erc32/help.c
index ed4f21b8c3b..419ab0d33ef 100644
--- a/sim/erc32/help.c
+++ b/sim/erc32/help.c
@@ -21,7 +21,7 @@
 #include "sis.h"
 
 void
-usage()
+usage(void)
 {
 
     printf("usage: sis [-uart1 uart_device1] [-uart2 uart_device2]\n");
@@ -30,7 +30,7 @@ usage()
 }
 
 void
-gen_help()
+gen_help(void)
 {
 
   printf("\n batch <file>          execute a batch file of SIS commands\n");
diff --git a/sim/erc32/interf.c b/sim/erc32/interf.c
index ca2e9faea21..c8e025b23e0 100644
--- a/sim/erc32/interf.c
+++ b/sim/erc32/interf.c
@@ -60,10 +60,7 @@ int             sis_gdb_break = 1;
 host_callback *sim_callback;
 
 int
-run_sim(sregs, icount, dis)
-    struct pstate  *sregs;
-    uint64          icount;
-    int             dis;
+run_sim(struct pstate *sregs, uint64 icount, int dis)
 {
     int             mexc, irq;
 
@@ -158,11 +155,8 @@ run_sim(sregs, icount, dis)
 }
 
 SIM_DESC
-sim_open (kind, callback, abfd, argv)
-     SIM_OPEN_KIND kind;
-     struct host_callback_struct *callback;
-     struct bfd *abfd;
-     char * const *argv;
+sim_open (SIM_OPEN_KIND kind, struct host_callback_struct *callback,
+	  struct bfd *abfd, char * const *argv)
 {
 
     int             argc = 0;
@@ -263,9 +257,7 @@ sim_open (kind, callback, abfd, argv)
 }
 
 void
-sim_close(sd, quitting)
-     SIM_DESC sd;
-     int quitting;
+sim_close(SIM_DESC sd, int quitting)
 {
 
     exit_sim();
@@ -274,22 +266,15 @@ sim_close(sd, quitting)
 };
 
 SIM_RC
-sim_load(sd, prog, abfd, from_tty)
-     SIM_DESC sd;
-     const char *prog;
-     bfd *abfd;
-     int from_tty;
+sim_load(SIM_DESC sd, const char *prog, bfd *abfd, int from_tty)
 {
     bfd_load (prog);
     return SIM_RC_OK;
 }
 
 SIM_RC
-sim_create_inferior(sd, abfd, argv, env)
-     SIM_DESC sd;
-     struct bfd *abfd;
-     char * const *argv;
-     char * const *env;
+sim_create_inferior(SIM_DESC sd, bfd *abfd, char * const *argv,
+		    char * const *env)
 {
     bfd_vma start_address = 0;
     if (abfd != NULL)
@@ -304,11 +289,7 @@ sim_create_inferior(sd, abfd, argv, env)
 }
 
 int
-sim_store_register(sd, regno, value, length)
-    SIM_DESC sd;
-    int             regno;
-    unsigned char  *value;
-    int length;
+sim_store_register(SIM_DESC sd, int regno, unsigned char *value, int length)
 {
     int regval;
 
@@ -320,11 +301,7 @@ sim_store_register(sd, regno, value, length)
 
 
 int
-sim_fetch_register(sd, regno, buf, length)
-     SIM_DESC sd;
-    int             regno;
-    unsigned char  *buf;
-     int length;
+sim_fetch_register(SIM_DESC sd, int regno, unsigned char *buf, int length)
 {
     get_regi(&sregs, regno, buf);
     return -1;
@@ -353,9 +330,7 @@ sim_read (SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length)
 }
 
 void
-sim_info(sd, verbose)
-     SIM_DESC sd;
-     int verbose;
+sim_info(SIM_DESC sd, int verbose)
 {
     show_stat(&sregs);
 }
@@ -363,10 +338,7 @@ sim_info(sd, verbose)
 int             simstat = OK;
 
 void
-sim_stop_reason(sd, reason, sigrc)
-     SIM_DESC sd;
-     enum sim_stop * reason;
-     int *sigrc;
+sim_stop_reason(SIM_DESC sd, enum sim_stop *reason, int *sigrc)
 {
 
     switch (simstat) {
@@ -400,7 +372,7 @@ sim_stop_reason(sd, reason, sigrc)
 */
 
 static void
-flush_windows ()
+flush_windows (void)
 {
   int invwin;
   int cwp;
@@ -452,9 +424,7 @@ sim_resume(SIM_DESC sd, int step, int siggnal)
 }
 
 void
-sim_do_command(sd, cmd)
-     SIM_DESC sd;
-     const char *cmd;
+sim_do_command(SIM_DESC sd, const char *cmd)
 {
     exec_cmd(&sregs, cmd);
 }
diff --git a/sim/erc32/sis.c b/sim/erc32/sis.c
index 858bcbb9d7b..05044c3ad8f 100644
--- a/sim/erc32/sis.c
+++ b/sim/erc32/sis.c
@@ -65,10 +65,7 @@ extern int era;
 #endif
 
 int
-run_sim(sregs, icount, dis)
-    struct pstate  *sregs;
-    uint64          icount;
-    int             dis;
+run_sim(struct pstate *sregs, uint64 icount, int dis)
 {
     int             irq, mexc, deb;
 
@@ -140,9 +137,7 @@ run_sim(sregs, icount, dis)
 }
 
 int
-main(argc, argv)
-    int             argc;
-    char          **argv;
+main(int argc, char **argv)
 {
 
     int             cont = 1;
diff --git a/sim/frv/sim-if.c b/sim/frv/sim-if.c
index 45cbd1618a4..9351f79e053 100644
--- a/sim/frv/sim-if.c
+++ b/sim/frv/sim-if.c
@@ -43,11 +43,8 @@ free_state (SIM_DESC sd)
 /* Create an instance of the simulator.  */
 
 SIM_DESC
-sim_open (kind, callback, abfd, argv)
-     SIM_OPEN_KIND kind;
-     host_callback *callback;
-     bfd *abfd;
-     char * const *argv;
+sim_open (SIM_OPEN_KIND kind, host_callback *callback, bfd *abfd,
+	  char * const *argv)
 {
   char c;
   int i;
@@ -162,9 +159,7 @@ sim_open (kind, callback, abfd, argv)
 }
 
 void
-frv_sim_close (sd, quitting)
-     SIM_DESC sd;
-     int quitting;
+frv_sim_close (SIM_DESC sd, int quitting)
 {
   int i;
   /* Terminate cache support.  */
@@ -177,11 +172,8 @@ frv_sim_close (sd, quitting)
 }
 \f
 SIM_RC
-sim_create_inferior (sd, abfd, argv, envp)
-     SIM_DESC sd;
-     bfd *abfd;
-     char * const *argv;
-     char * const *envp;
+sim_create_inferior (SIM_DESC sd, bfd *abfd, char * const *argv,
+		     char * const *envp)
 {
   SIM_CPU *current_cpu = STATE_CPU (sd, 0);
   SIM_ADDR addr;
diff --git a/sim/h8300/compile.c b/sim/h8300/compile.c
index 47b0577781a..c30a738c6d1 100644
--- a/sim/h8300/compile.c
+++ b/sim/h8300/compile.c
@@ -465,7 +465,7 @@ lvalue (SIM_DESC sd, int x, int rn, unsigned int *val)
 }
 
 static int
-cmdline_location()
+cmdline_location(void)
 {
   if (h8300smode && !h8300_normal_mode)
     return 0xffff00L;
diff --git a/sim/iq2000/iq2000.c b/sim/iq2000/iq2000.c
index 86151ca9e1e..23a342983ce 100644
--- a/sim/iq2000/iq2000.c
+++ b/sim/iq2000/iq2000.c
@@ -56,10 +56,7 @@ enum libgloss_syscall
 
 /* Read a null terminated string from memory, return in a buffer */
 static char *
-fetch_str (current_cpu, pc, addr)
-     SIM_CPU *current_cpu;
-     PCADDR pc;
-     DI addr;
+fetch_str (SIM_CPU *current_cpu, PCADDR pc, DI addr)
 {
   char *buf;
   int nr = 0;
diff --git a/sim/iq2000/sim-if.c b/sim/iq2000/sim-if.c
index 496b10659ea..158c6e7574a 100644
--- a/sim/iq2000/sim-if.c
+++ b/sim/iq2000/sim-if.c
@@ -50,11 +50,8 @@ free_state (SIM_DESC sd)
 /* Create an instance of the simulator.  */
 
 SIM_DESC
-sim_open (kind, callback, abfd, argv)
-     SIM_OPEN_KIND kind;
-     host_callback *callback;
-     struct bfd *abfd;
-     char * const *argv;
+sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
+	  char * const *argv)
 {
   char c;
   int i;
@@ -130,11 +127,8 @@ sim_open (kind, callback, abfd, argv)
 }
 \f
 SIM_RC
-sim_create_inferior (sd, abfd, argv, envp)
-     SIM_DESC sd;
-     struct bfd *abfd;
-     char * const *argv;
-     char * const *envp;
+sim_create_inferior (SIM_DESC sd, struct bfd *abfd, char * const *argv,
+		     char * const *envp)
 {
   SIM_CPU *current_cpu = STATE_CPU (sd, 0);
   SIM_ADDR addr;
diff --git a/sim/lm32/sim-if.c b/sim/lm32/sim-if.c
index 176456ed62d..398eb60c67a 100644
--- a/sim/lm32/sim-if.c
+++ b/sim/lm32/sim-if.c
@@ -80,11 +80,8 @@ find_limit (SIM_DESC sd)
 /* Create an instance of the simulator.  */
 
 SIM_DESC
-sim_open (kind, callback, abfd, argv)
-     SIM_OPEN_KIND kind;
-     host_callback *callback;
-     struct bfd *abfd;
-     char * const *argv;
+sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
+	  char * const *argv)
 {
   SIM_DESC sd = sim_state_alloc (kind, callback);
   char c;
@@ -190,11 +187,8 @@ sim_open (kind, callback, abfd, argv)
 }
 \f
 SIM_RC
-sim_create_inferior (sd, abfd, argv, envp)
-     SIM_DESC sd;
-     struct bfd *abfd;
-     char * const *argv;
-     char * const *envp;
+sim_create_inferior (SIM_DESC sd, struct bfd *abfd, char * const *argv,
+		     char * const *envp)
 {
   SIM_CPU *current_cpu = STATE_CPU (sd, 0);
   SIM_ADDR addr;
diff --git a/sim/m32r/sim-if.c b/sim/m32r/sim-if.c
index 58d46946eb7..42cf728e79e 100644
--- a/sim/m32r/sim-if.c
+++ b/sim/m32r/sim-if.c
@@ -44,11 +44,8 @@ free_state (SIM_DESC sd)
 /* Create an instance of the simulator.  */
 
 SIM_DESC
-sim_open (kind, callback, abfd, argv)
-     SIM_OPEN_KIND kind;
-     host_callback *callback;
-     struct bfd *abfd;
-     char * const *argv;
+sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
+	  char * const *argv)
 {
   SIM_DESC sd = sim_state_alloc (kind, callback);
   char c;
@@ -142,11 +139,8 @@ sim_open (kind, callback, abfd, argv)
 }
 \f
 SIM_RC
-sim_create_inferior (sd, abfd, argv, envp)
-     SIM_DESC sd;
-     struct bfd *abfd;
-     char * const *argv;
-     char * const *envp;
+sim_create_inferior (SIM_DESC sd, struct bfd *abfd, char * const *argv,
+		     char * const *envp)
 {
   SIM_CPU *current_cpu = STATE_CPU (sd, 0);
   SIM_ADDR addr;
-- 
2.26.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 2/2] Add system includes in sim
  2021-04-08 16:44 [PATCH 0/2] Fix some sim warnings Tom Tromey
  2021-04-08 16:44 ` [PATCH 1/2] Do not use old-style definitions in sim Tom Tromey
@ 2021-04-08 16:44 ` Tom Tromey
  2021-04-08 17:43   ` Mike Frysinger
  1 sibling, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2021-04-08 16:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This updates various parts of the sim to include missing system
headers.  I made the includes unconditional, because other parts of
the tree are already doing this.

sim/cris/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* traps.c: Include stdlib.h.
	* cris-tmpl.c: Include stdlib.h.

sim/erc32/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* func.c: Include sys/time.h.

sim/frv/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* traps.c: Include stdlib.h.
	* registers.c: Include stdlib.h.
	* profile.c: Include stdlib.h.
	* memory.c: Include stdlib.h.
	* interrupts.c: Include stdlib.h.
	* frv.c: Include stdlib.h.
	* cache.c: Include stdlib.h.

sim/iq2000/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* iq2000.c: Include stdlib.h.

sim/m32r/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* traps.c: Include stdlib.h.
	* m32r.c: Include stdlib.h.

sim/ppc/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* emul_unix.c: Include time.h.
---
 sim/cris/ChangeLog   |  5 +++++
 sim/cris/cris-tmpl.c |  2 ++
 sim/cris/traps.c     |  1 +
 sim/erc32/ChangeLog  |  4 ++++
 sim/erc32/func.c     |  1 +
 sim/frv/ChangeLog    | 10 ++++++++++
 sim/frv/cache.c      |  1 +
 sim/frv/frv.c        |  1 +
 sim/frv/interrupts.c |  1 +
 sim/frv/memory.c     |  1 +
 sim/frv/profile.c    |  1 +
 sim/frv/registers.c  |  1 +
 sim/frv/traps.c      |  2 ++
 sim/iq2000/ChangeLog |  4 ++++
 sim/iq2000/iq2000.c  |  1 +
 sim/m32r/ChangeLog   |  5 +++++
 sim/m32r/m32r.c      |  1 +
 sim/m32r/traps.c     |  1 +
 sim/ppc/ChangeLog    |  4 ++++
 sim/ppc/emul_unix.c  |  1 +
 20 files changed, 48 insertions(+)

diff --git a/sim/cris/cris-tmpl.c b/sim/cris/cris-tmpl.c
index b5ad7189191..95579dbffa9 100644
--- a/sim/cris/cris-tmpl.c
+++ b/sim/cris/cris-tmpl.c
@@ -25,6 +25,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "cgen-mem.h"
 #include "cgen-ops.h"
 
+#include <stdlib.h>
+
 #define MY(f) XCONCAT3(crisv,BASENUM,f)
 
 /* Dispatcher for break insn.  */
diff --git a/sim/cris/traps.c b/sim/cris/traps.c
index 2aaa1f43b16..1c8ca41d14e 100644
--- a/sim/cris/traps.c
+++ b/sim/cris/traps.c
@@ -23,6 +23,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "bfd.h"
 /* FIXME: get rid of targ-vals.h usage everywhere else.  */
 
+#include <stdlib.h>
 #include <stdarg.h>
 #include <errno.h>
 #ifdef HAVE_UNISTD_H
diff --git a/sim/erc32/func.c b/sim/erc32/func.c
index 98217f062ae..c6dfa1927ad 100644
--- a/sim/erc32/func.c
+++ b/sim/erc32/func.c
@@ -26,6 +26,7 @@
 #include <dis-asm.h>
 #include "sim-config.h"
 #include <inttypes.h>
+#include <sys/time.h>
 
 #define	VAL(x)	strtoul(x,(char **)NULL,0)
 
diff --git a/sim/frv/cache.c b/sim/frv/cache.c
index 9e2a99f5f7e..c10d46373f5 100644
--- a/sim/frv/cache.c
+++ b/sim/frv/cache.c
@@ -24,6 +24,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "sim-main.h"
 #include "cache.h"
 #include "bfd.h"
+#include <stdlib.h>
 
 void
 frv_cache_init (SIM_CPU *cpu, FRV_CACHE *cache)
diff --git a/sim/frv/frv.c b/sim/frv/frv.c
index 88290be3e8e..fee59c2aae7 100644
--- a/sim/frv/frv.c
+++ b/sim/frv/frv.c
@@ -28,6 +28,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "bfd.h"
 #include "gdb/sim-frv.h"
 #include <math.h>
+#include <stdlib.h>
 
 /* Maintain a flag in order to know when to write the address of the next
    VLIW instruction into the LR register.  Used by JMPL. JMPIL, and CALL
diff --git a/sim/frv/interrupts.c b/sim/frv/interrupts.c
index d38620c9a72..0b8ed763987 100644
--- a/sim/frv/interrupts.c
+++ b/sim/frv/interrupts.c
@@ -22,6 +22,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "sim-main.h"
 #include "bfd.h"
+#include <stdlib.h>
 
 /* FR-V Interrupt table.
    Describes the interrupts supported by the FR-V.
diff --git a/sim/frv/memory.c b/sim/frv/memory.c
index ea7f68e4349..5978d151627 100644
--- a/sim/frv/memory.c
+++ b/sim/frv/memory.c
@@ -23,6 +23,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "sim-main.h"
 #include "cgen-mem.h"
 #include "bfd.h"
+#include <stdlib.h>
 
 /* Check for alignment and access restrictions.  Return the corrected address.
  */
diff --git a/sim/frv/profile.c b/sim/frv/profile.c
index c08950886d1..441590eb581 100644
--- a/sim/frv/profile.c
+++ b/sim/frv/profile.c
@@ -24,6 +24,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 #include "sim-main.h"
 #include "bfd.h"
+#include <stdlib.h>
 
 #if WITH_PROFILE_MODEL_P
 
diff --git a/sim/frv/registers.c b/sim/frv/registers.c
index c9d26fda018..764a6755b3f 100644
--- a/sim/frv/registers.c
+++ b/sim/frv/registers.c
@@ -22,6 +22,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "sim-main.h"
 #include "bfd.h"
+#include <stdlib.h>
 
 #define IMPL 1 /* Implemented */
 #define SUP  1 /* Supervisor register */
diff --git a/sim/frv/traps.c b/sim/frv/traps.c
index 79ea1571ac2..c0ed9b1c49f 100644
--- a/sim/frv/traps.c
+++ b/sim/frv/traps.c
@@ -29,6 +29,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "bfd.h"
 #include "libiberty.h"
 
+#include <stdlib.h>
+
 CGEN_ATTR_VALUE_ENUM_TYPE frv_current_fm_slot;
 
 /* The semantic code invokes this for invalid (unrecognized) instructions.  */
diff --git a/sim/iq2000/iq2000.c b/sim/iq2000/iq2000.c
index 23a342983ce..e03c47919fd 100644
--- a/sim/iq2000/iq2000.c
+++ b/sim/iq2000/iq2000.c
@@ -23,6 +23,7 @@
 #include "sim-main.h"
 #include "cgen-mem.h"
 #include "cgen-ops.h"
+#include <stdlib.h>
 
 enum
 {
diff --git a/sim/m32r/m32r.c b/sim/m32r/m32r.c
index 1c5379cfd74..1d0a7356bb0 100644
--- a/sim/m32r/m32r.c
+++ b/sim/m32r/m32r.c
@@ -23,6 +23,7 @@
 #include "sim-main.h"
 #include "cgen-mem.h"
 #include "cgen-ops.h"
+#include <stdlib.h>
 
 /* Return the size of REGNO in bytes.  */
 
diff --git a/sim/m32r/traps.c b/sim/m32r/traps.c
index 9edf66b58f1..9fca2b1ec1d 100644
--- a/sim/m32r/traps.c
+++ b/sim/m32r/traps.c
@@ -20,6 +20,7 @@
 #include "sim-main.h"
 #include "sim-syscall.h"
 #include "targ-vals.h"
+#include <stdlib.h>
 
 #define TRAP_FLUSH_CACHE 12
 /* The semantic code invokes this for invalid (unrecognized) instructions.  */
diff --git a/sim/ppc/emul_unix.c b/sim/ppc/emul_unix.c
index 92c3c1ededf..2616ae408ba 100644
--- a/sim/ppc/emul_unix.c
+++ b/sim/ppc/emul_unix.c
@@ -124,6 +124,7 @@ int getrusage();
 #endif
 
 #include <stdlib.h>
+#include <time.h>
 
 #if defined(BSD) && !defined(errno) && (BSD < 199306)	/* here BSD as just a bug */
 extern int errno;
-- 
2.26.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] Add system includes in sim
  2021-04-08 16:44 ` [PATCH 2/2] Add system includes " Tom Tromey
@ 2021-04-08 17:43   ` Mike Frysinger
  2021-04-08 18:32     ` Tom Tromey
  0 siblings, 1 reply; 12+ messages in thread
From: Mike Frysinger @ 2021-04-08 17:43 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 08 Apr 2021 10:44, Tom Tromey wrote:
> This updates various parts of the sim to include missing system
> headers.  I made the includes unconditional, because other parts of
> the tree are already doing this.

stdlib.h & time.h are fine as they're in C99.

> 	* func.c: Include sys/time.h.

this one isn't in C99.  we seem to sometimes protect against it, but not
always.  if we go by gnulib's notes, it seems like we should just assume
it everywhere.  wdyt ?
https://www.gnu.org/software/gnulib/manual/html_node/sys_002ftime_002eh.html#sys_002ftime_002eh
-mike

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] Do not use old-style definitions in sim
  2021-04-08 16:44 ` [PATCH 1/2] Do not use old-style definitions in sim Tom Tromey
@ 2021-04-08 17:44   ` Mike Frysinger
  0 siblings, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2021-04-08 17:44 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 08 Apr 2021 10:44, Tom Tromey wrote:
> This changes all the non-generated (hand-written) code in sim to use
> "new" (post-K&R) style function definitions.

thanks ... this is one of those tiresome cleanups :)
-mike

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] Add system includes in sim
  2021-04-08 17:43   ` Mike Frysinger
@ 2021-04-08 18:32     ` Tom Tromey
  2021-04-08 18:43       ` Tom Tromey
                         ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Tom Tromey @ 2021-04-08 18:32 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

>> * func.c: Include sys/time.h.

Mike> this one isn't in C99.  we seem to sometimes protect against it, but not
Mike> always.  if we go by gnulib's notes, it seems like we should just assume
Mike> it everywhere.  wdyt ?
Mike> https://www.gnu.org/software/gnulib/manual/html_node/sys_002ftime_002eh.html#sys_002ftime_002eh

Makes sense to me.

Also, BFD removed the check for time.h, among other things, in commit
83c79df86.  If BFD can remove it, I think it's fine.

Tom

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] Add system includes in sim
  2021-04-08 18:32     ` Tom Tromey
@ 2021-04-08 18:43       ` Tom Tromey
  2021-04-08 19:26       ` Mike Frysinger
  2021-04-08 20:34       ` Tom Tromey
  2 siblings, 0 replies; 12+ messages in thread
From: Tom Tromey @ 2021-04-08 18:43 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Tom> Also, BFD removed the check for time.h, among other things, in commit
Tom> 83c79df86.  If BFD can remove it, I think it's fine.

I have a patch to remove this check from sim.
I'll send it soon, with some other build patches I wrote.

Tom

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] Add system includes in sim
  2021-04-08 18:32     ` Tom Tromey
  2021-04-08 18:43       ` Tom Tromey
@ 2021-04-08 19:26       ` Mike Frysinger
  2021-04-08 19:30         ` Tom Tromey
  2021-04-08 20:34       ` Tom Tromey
  2 siblings, 1 reply; 12+ messages in thread
From: Mike Frysinger @ 2021-04-08 19:26 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 08 Apr 2021 12:32, Tom Tromey wrote:
> >> * func.c: Include sys/time.h.
> 
> Mike> this one isn't in C99.  we seem to sometimes protect against it, but not
> Mike> always.  if we go by gnulib's notes, it seems like we should just assume
> Mike> it everywhere.  wdyt ?
> Mike> https://www.gnu.org/software/gnulib/manual/html_node/sys_002ftime_002eh.html#sys_002ftime_002eh
> 
> Makes sense to me.
> 
> Also, BFD removed the check for time.h, among other things, in commit
> 83c79df86.  If BFD can remove it, I think it's fine.

we removed time.h checks in 68ed2854284d415a71efd856a40343f550881ede in sim
since it's in C99.  this question is about sys/time.h which is different.
-mike

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] Add system includes in sim
  2021-04-08 19:26       ` Mike Frysinger
@ 2021-04-08 19:30         ` Tom Tromey
  2021-04-08 20:12           ` Mike Frysinger
  0 siblings, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2021-04-08 19:30 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

>>>>> "Mike" == Mike Frysinger <vapier@gentoo.org> writes:

Mike> On 08 Apr 2021 12:32, Tom Tromey wrote:
>> >> * func.c: Include sys/time.h.
>> 
Mike> this one isn't in C99.  we seem to sometimes protect against it, but not
Mike> always.  if we go by gnulib's notes, it seems like we should just assume
Mike> it everywhere.  wdyt ?
Mike> https://www.gnu.org/software/gnulib/manual/html_node/sys_002ftime_002eh.html#sys_002ftime_002eh
>> 
>> Makes sense to me.
>> 
>> Also, BFD removed the check for time.h, among other things, in commit
>> 83c79df86.  If BFD can remove it, I think it's fine.

Mike> we removed time.h checks in 68ed2854284d415a71efd856a40343f550881ede in sim
Mike> since it's in C99.  this question is about sys/time.h which is different.

Sorry, I meant to say sys/time.h there.
The BFD ChangeLog says:

	* configure.ac: Don't check for long long or long double type.
	Don't check for alloca.h, limits.h, stddef.h, stdlib.h, string.h,
	strings.h, time.h, wchar.h, wctype.h or sys/time.h.  [...]

So I still think it's fine.

Tom

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] Add system includes in sim
  2021-04-08 19:30         ` Tom Tromey
@ 2021-04-08 20:12           ` Mike Frysinger
  0 siblings, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2021-04-08 20:12 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 08 Apr 2021 13:30, Tom Tromey wrote:
> >>>>> "Mike" == Mike Frysinger <vapier@gentoo.org> writes:
> 
> Mike> On 08 Apr 2021 12:32, Tom Tromey wrote:
> >> >> * func.c: Include sys/time.h.
> >> 
> Mike> this one isn't in C99.  we seem to sometimes protect against it, but not
> Mike> always.  if we go by gnulib's notes, it seems like we should just assume
> Mike> it everywhere.  wdyt ?
> Mike> https://www.gnu.org/software/gnulib/manual/html_node/sys_002ftime_002eh.html#sys_002ftime_002eh
> >> 
> >> Makes sense to me.
> >> 
> >> Also, BFD removed the check for time.h, among other things, in commit
> >> 83c79df86.  If BFD can remove it, I think it's fine.
> 
> Mike> we removed time.h checks in 68ed2854284d415a71efd856a40343f550881ede in sim
> Mike> since it's in C99.  this question is about sys/time.h which is different.
> 
> Sorry, I meant to say sys/time.h there.
> The BFD ChangeLog says:
> 
> 	* configure.ac: Don't check for long long or long double type.
> 	Don't check for alloca.h, limits.h, stddef.h, stdlib.h, string.h,
> 	strings.h, time.h, wchar.h, wctype.h or sys/time.h.  [...]
> 
> So I still think it's fine.

gdb & sim document their expectations (C11/C++11).  i guess we nee to do the
same thing under BFD ?  and include the stuff it expects beyond C11.
-mike

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] Add system includes in sim
  2021-04-08 18:32     ` Tom Tromey
  2021-04-08 18:43       ` Tom Tromey
  2021-04-08 19:26       ` Mike Frysinger
@ 2021-04-08 20:34       ` Tom Tromey
  2021-04-08 20:58         ` Mike Frysinger
  2 siblings, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2021-04-08 20:34 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

>>> * func.c: Include sys/time.h.
Mike> this one isn't in C99.  we seem to sometimes protect against it, but not
Mike> always.  if we go by gnulib's notes, it seems like we should just assume
Mike> it everywhere.  wdyt ?
Mike> https://www.gnu.org/software/gnulib/manual/html_node/sys_002ftime_002eh.html#sys_002ftime_002eh

Tom> Makes sense to me.

I'm going to go ahead & check in both of these.

Tom

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] Add system includes in sim
  2021-04-08 20:34       ` Tom Tromey
@ 2021-04-08 20:58         ` Mike Frysinger
  0 siblings, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2021-04-08 20:58 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 08 Apr 2021 14:34, Tom Tromey wrote:
> >>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
> 
> >>> * func.c: Include sys/time.h.
> Mike> this one isn't in C99.  we seem to sometimes protect against it, but not
> Mike> always.  if we go by gnulib's notes, it seems like we should just assume
> Mike> it everywhere.  wdyt ?
> Mike> https://www.gnu.org/software/gnulib/manual/html_node/sys_002ftime_002eh.html#sys_002ftime_002eh
> 
> Tom> Makes sense to me.
> 
> I'm going to go ahead & check in both of these.

of course, thanks
-mike

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-04-08 20:58 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-08 16:44 [PATCH 0/2] Fix some sim warnings Tom Tromey
2021-04-08 16:44 ` [PATCH 1/2] Do not use old-style definitions in sim Tom Tromey
2021-04-08 17:44   ` Mike Frysinger
2021-04-08 16:44 ` [PATCH 2/2] Add system includes " Tom Tromey
2021-04-08 17:43   ` Mike Frysinger
2021-04-08 18:32     ` Tom Tromey
2021-04-08 18:43       ` Tom Tromey
2021-04-08 19:26       ` Mike Frysinger
2021-04-08 19:30         ` Tom Tromey
2021-04-08 20:12           ` Mike Frysinger
2021-04-08 20:34       ` Tom Tromey
2021-04-08 20:58         ` Mike 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).